diff --git a/go.mod b/go.mod index 37477e7..6970b2b 100644 --- a/go.mod +++ b/go.mod @@ -3,7 +3,7 @@ module git.warky.dev/wdevs/whatshooked go 1.25.5 require ( - github.com/bitechdev/ResolveSpec v1.0.49 + github.com/bitechdev/ResolveSpec v1.0.53 github.com/eclipse/paho.mqtt.golang v1.5.1 github.com/golang-jwt/jwt/v5 v5.3.1 github.com/google/uuid v1.6.0 @@ -28,6 +28,7 @@ require ( require ( filippo.io/edwards25519 v1.1.0 // indirect + git.warky.dev/wdevs/relspecgo v1.0.37 // indirect github.com/beeper/argo-go v1.1.2 // indirect github.com/beorn7/perks v1.0.1 // indirect github.com/bradfitz/gomemcache v0.0.0-20250403215159-8d39553ac7cf // indirect @@ -39,6 +40,8 @@ require ( github.com/elliotchance/orderedmap/v3 v3.1.0 // indirect github.com/fatih/color v1.18.0 // indirect github.com/fsnotify/fsnotify v1.9.0 // indirect + github.com/gdamore/encoding v1.0.1 // indirect + github.com/gdamore/tcell/v2 v2.8.1 // indirect github.com/getsentry/sentry-go v0.40.0 // indirect github.com/go-viper/mapstructure/v2 v2.4.0 // indirect github.com/golang-sql/civil v0.0.0-20220223132316-b832511892a9 // indirect @@ -52,9 +55,11 @@ require ( github.com/jinzhu/inflection v1.0.0 // indirect github.com/jinzhu/now v1.1.5 // indirect github.com/klauspost/compress v1.18.2 // indirect + github.com/lucasb-eyer/go-colorful v1.2.0 // indirect github.com/mattn/go-colorable v0.1.14 // indirect github.com/mattn/go-isatty v0.0.20 // indirect - github.com/microsoft/go-mssqldb v1.9.5 // indirect + github.com/mattn/go-runewidth v0.0.16 // indirect + github.com/microsoft/go-mssqldb v1.9.6 // indirect github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect github.com/ncruces/go-strftime v1.0.0 // indirect github.com/pelletier/go-toml/v2 v2.2.4 // indirect @@ -67,6 +72,8 @@ require ( github.com/puzpuzpuz/xsync/v3 v3.5.1 // indirect github.com/redis/go-redis/v9 v9.17.2 // indirect github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec // indirect + github.com/rivo/tview v0.42.0 // indirect + github.com/rivo/uniseg v0.4.7 // indirect github.com/sagikazarmark/locafero v0.12.0 // indirect github.com/shopspring/decimal v1.4.0 // indirect github.com/spf13/afero v1.15.0 // indirect @@ -107,8 +114,8 @@ require ( gorm.io/driver/sqlserver v1.6.3 // indirect gorm.io/gorm v1.31.1 // indirect mellium.im/sasl v0.3.2 // indirect - modernc.org/libc v1.67.4 // indirect + modernc.org/libc v1.67.6 // indirect modernc.org/mathutil v1.7.1 // indirect modernc.org/memory v1.11.0 // indirect - modernc.org/sqlite v1.42.2 // indirect + modernc.org/sqlite v1.44.3 // indirect ) diff --git a/go.sum b/go.sum index 92a1ac1..6336087 100644 --- a/go.sum +++ b/go.sum @@ -2,6 +2,8 @@ dario.cat/mergo v1.0.2 h1:85+piFYR1tMbRrLcDwR18y4UKJ3aH1Tbzi24VRW1TK8= dario.cat/mergo v1.0.2/go.mod h1:E/hbnu0NxMFBjpMIE34DRGLWqDy0g5FuKDhCb31ngxA= filippo.io/edwards25519 v1.1.0 h1:FNf4tywRC1HmFuKW5xopWpigGjJKiJSV0Cqo0cJWDaA= filippo.io/edwards25519 v1.1.0/go.mod h1:BxyFTGdWcka3PhytdK4V28tE5sGfRvvvRV7EaN4VDT4= +git.warky.dev/wdevs/relspecgo v1.0.37 h1:gx7uYlhktkZfu8WgyIjeWWqPZybLeB5PIUJ6r1WH1UQ= +git.warky.dev/wdevs/relspecgo v1.0.37/go.mod h1:Gt1xwVfbZQYkuOz00JDdyMt5D+kH0uyVeaOTjS+VE24= github.com/Azure/azure-sdk-for-go/sdk/azcore v1.7.0/go.mod h1:bjGvMhVMb+EEm3VRNQawDMUyMMjo+S5ewNjflkep/0Q= github.com/Azure/azure-sdk-for-go/sdk/azcore v1.7.1/go.mod h1:bjGvMhVMb+EEm3VRNQawDMUyMMjo+S5ewNjflkep/0Q= github.com/Azure/azure-sdk-for-go/sdk/azcore v1.11.1/go.mod h1:a6xsAQUZg+VsS3TJ05SRp524Hs4pZ/AeFSr5ENf0Yjo= @@ -44,6 +46,8 @@ github.com/bitechdev/ResolveSpec v1.0.48 h1:llXELDnzhcKC6YfRt9vRDKtW8hH3FaoDGWFO github.com/bitechdev/ResolveSpec v1.0.48/go.mod h1:sEeRZxpZvYS2zQ7RPcLqpRKw5iprmroYeMwUdxe/7to= github.com/bitechdev/ResolveSpec v1.0.49 h1:Ij1JQYElUU2UixB/FqPWC4MDRIJCxlTIz4cZptdvIHI= github.com/bitechdev/ResolveSpec v1.0.49/go.mod h1:sEeRZxpZvYS2zQ7RPcLqpRKw5iprmroYeMwUdxe/7to= +github.com/bitechdev/ResolveSpec v1.0.53 h1:y48RXRap9n06R5AfR70div72rDdR6kAmWvoju9EbUPM= +github.com/bitechdev/ResolveSpec v1.0.53/go.mod h1:sEeRZxpZvYS2zQ7RPcLqpRKw5iprmroYeMwUdxe/7to= github.com/bradfitz/gomemcache v0.0.0-20250403215159-8d39553ac7cf h1:TqhNAT4zKbTdLa62d2HDBFdvgSbIGB3eJE8HqhgiL9I= github.com/bradfitz/gomemcache v0.0.0-20250403215159-8d39553ac7cf/go.mod h1:r5xuitiExdLAJ09PR7vBVENGvp4ZuTBeWTGtxuX3K+c= github.com/bsm/ginkgo/v2 v2.12.0 h1:Ny8MWAHyOepLGlLKYmXG4IEkioBysk6GpaRTLC8zwWs= @@ -100,6 +104,10 @@ github.com/frankban/quicktest v1.14.6 h1:7Xjx+VpznH+oBnejlPUj8oUpdxnVs4f8XU8WnHk github.com/frankban/quicktest v1.14.6/go.mod h1:4ptaffx2x8+WTWXmUCuVU6aPUX1/Mz7zb5vbUoiM6w0= github.com/fsnotify/fsnotify v1.9.0 h1:2Ml+OJNzbYCTzsxtv8vKSFD9PbJjmhYF14k/jKC7S9k= github.com/fsnotify/fsnotify v1.9.0/go.mod h1:8jBTzvmWwFyi3Pb8djgCCO5IBqzKJ/Jwo8TRcHyHii0= +github.com/gdamore/encoding v1.0.1 h1:YzKZckdBL6jVt2Gc+5p82qhrGiqMdG/eNs6Wy0u3Uhw= +github.com/gdamore/encoding v1.0.1/go.mod h1:0Z0cMFinngz9kS1QfMjCP8TY7em3bZYeeklsSDPivEo= +github.com/gdamore/tcell/v2 v2.8.1 h1:KPNxyqclpWpWQlPLx6Xui1pMk8S+7+R37h3g07997NU= +github.com/gdamore/tcell/v2 v2.8.1/go.mod h1:bj8ori1BG3OYMjmb3IklZVWfZUJ1UBQt9JXrOCOhGWw= github.com/getsentry/sentry-go v0.40.0 h1:VTJMN9zbTvqDqPwheRVLcp0qcUcM+8eFivvGocAaSbo= github.com/getsentry/sentry-go v0.40.0/go.mod h1:eRXCoh3uvmjQLY6qu63BjUZnaBu5L5WhMV1RwYO8W5s= github.com/go-errors/errors v1.4.2 h1:J6MZopCL4uSllY1OfXM374weqZFFItUbrImctkmUxIA= @@ -173,6 +181,8 @@ github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0 github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+fNqagV/RAw= github.com/lib/pq v1.10.9 h1:YXG7RB+JIjhP29X+OtkiDnYaXQwpS4JEWq7dtCCRUEw= github.com/lib/pq v1.10.9/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o= +github.com/lucasb-eyer/go-colorful v1.2.0 h1:1nnpGOrhyZZuNyfu1QjKiUICQ74+3FNCN69Aj6K7nkY= +github.com/lucasb-eyer/go-colorful v1.2.0/go.mod h1:R4dSotOR9KMtayYi1e77YzuveK+i7ruzyGqttikkLy0= github.com/lufia/plan9stats v0.0.0-20211012122336-39d0f177ccd0 h1:6E+4a0GO5zZEnZ81pIr0yLvtUWk2if982qA3F3QD6H4= github.com/lufia/plan9stats v0.0.0-20211012122336-39d0f177ccd0/go.mod h1:zJYVVT2jmtg6P3p1VtQj7WsuWi/y4VnjVBn7F8KPB3I= github.com/magiconair/properties v1.8.10 h1:s31yESBquKXCV9a/ScB3ESkOjUYYv+X0rg8SYxI99mE= @@ -184,6 +194,8 @@ github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/ github.com/mattn/go-isatty v0.0.19/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY= github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= +github.com/mattn/go-runewidth v0.0.16 h1:E5ScNMtiwvlvB5paMFdw9p4kSQzbXFikJ5SQO6TULQc= +github.com/mattn/go-runewidth v0.0.16/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w= github.com/mattn/go-sqlite3 v1.14.33 h1:A5blZ5ulQo2AtayQ9/limgHEkFreKj1Dv226a1K73s0= github.com/mattn/go-sqlite3 v1.14.33/go.mod h1:Uh1q+B4BYcTPb+yiD3kU8Ct7aC0hY9fxUwlHK0RXw+Y= github.com/mdp/qrterminal/v3 v3.2.1 h1:6+yQjiiOsSuXT5n9/m60E54vdgFsw0zhADHhHLrFet4= @@ -191,6 +203,8 @@ github.com/mdp/qrterminal/v3 v3.2.1/go.mod h1:jOTmXvnBsMy5xqLniO0R++Jmjs2sTm9dFS github.com/microsoft/go-mssqldb v1.8.2/go.mod h1:vp38dT33FGfVotRiTmDo3bFyaHq+p3LektQrjTULowo= github.com/microsoft/go-mssqldb v1.9.5 h1:orwya0X/5bsL1o+KasupTkk2eNTNFkTQG0BEe/HxCn0= github.com/microsoft/go-mssqldb v1.9.5/go.mod h1:VCP2a0KEZZtGLRHd1PsLavLFYy/3xX2yJUPycv3Sr2Q= +github.com/microsoft/go-mssqldb v1.9.6 h1:1MNQg5UiSsokiPz3++K2KPx4moKrwIqly1wv+RyCKTw= +github.com/microsoft/go-mssqldb v1.9.6/go.mod h1:yYMPDufyoF2vVuVCUGtZARr06DKFIhMrluTcgWlXpr4= github.com/moby/docker-image-spec v1.3.1 h1:jMKff3w6PgbfSa69GfNg+zN/XLhfXJGnEx3Nl2EsFP0= github.com/moby/docker-image-spec v1.3.1/go.mod h1:eKmb5VW8vQEh/BAr2yvVNvuiJuY6UIocYsFu/DxxRpo= github.com/moby/go-archive v0.1.0 h1:Kk/5rdW/g+H8NHdJW2gsXyZ7UnzvJNOy6VKJqueWdcQ= @@ -247,6 +261,12 @@ github.com/redis/go-redis/v9 v9.17.2 h1:P2EGsA4qVIM3Pp+aPocCJ7DguDHhqrXNhVcEp4Vi github.com/redis/go-redis/v9 v9.17.2/go.mod h1:u410H11HMLoB+TP67dz8rL9s6QW2j76l0//kSOd3370= github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec h1:W09IVJc94icq4NjY3clb7Lk8O1qJ8BdBEF8z0ibU0rE= github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec/go.mod h1:qqbHyh8v60DhA7CoWK5oRCqLrMHRGoxYCSS9EjAz6Eo= +github.com/rivo/tview v0.42.0 h1:b/ftp+RxtDsHSaynXTbJb+/n/BxDEi+W3UfF5jILK6c= +github.com/rivo/tview v0.42.0/go.mod h1:cSfIYfhpSGCjp3r/ECJb+GKS7cGJnqV8vfjQPwoXyfY= +github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc= +github.com/rivo/uniseg v0.4.3/go.mod h1:FN3SvrM+Zdj16jyLfmOkMNblXMcoc8DfTHruCPUcx88= +github.com/rivo/uniseg v0.4.7 h1:WUdvkW8uEhrYfLC4ZzdpI2ztxP1I582+49Oc5Mq64VQ= +github.com/rivo/uniseg v0.4.7/go.mod h1:FN3SvrM+Zdj16jyLfmOkMNblXMcoc8DfTHruCPUcx88= github.com/rogpeppe/go-internal v1.9.0/go.mod h1:WtVeX8xhTBvf0smdhujwtBcq4Qrzq/fJaraNFVN+nFs= github.com/rogpeppe/go-internal v1.12.0 h1:exVL4IDcn6na9z1rAb56Vxr+CgyK3nn3O+epU5NdKM8= github.com/rogpeppe/go-internal v1.12.0/go.mod h1:E+RYuTGaKKdloAfM02xzb0FW3Paa99yedzYV+kq4uf4= @@ -413,6 +433,7 @@ golang.org/x/sync v0.3.0/go.mod h1:FU7BRWz2tNW+3quACPkgCx/L+uEAv1htQ0V83Z9Rj+Y= golang.org/x/sync v0.6.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= golang.org/x/sync v0.7.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= golang.org/x/sync v0.9.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= +golang.org/x/sync v0.10.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= golang.org/x/sync v0.19.0 h1:vV+1eWNmZ5geRlYjzm2adRgW2/mcpevXNg50YZtPCE4= golang.org/x/sync v0.19.0/go.mod h1:9KTHXmSnoGruLpwFjVSX0lNNA75CykiMECbovNTZqGI= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= @@ -435,6 +456,7 @@ golang.org/x/sys v0.18.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/sys v0.19.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/sys v0.20.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/sys v0.21.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/sys v0.29.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/sys v0.39.0 h1:CvCKL8MeisomCi6qNZ+wbb0DN9E5AATixKsvNtMoMFk= golang.org/x/sys v0.39.0/go.mod h1:OgkHotnGiDImocRcuBABYBEXf8A9a87e/uXjp9XT3ks= golang.org/x/telemetry v0.0.0-20240228155512-f48c80bd79b2/go.mod h1:TeRTkGYfJXctD9OcfyVLyj2J3IxLnKwHJR8f4D8a3YE= @@ -452,6 +474,7 @@ golang.org/x/term v0.18.0/go.mod h1:ILwASektA3OnRv7amZ1xhE/KTR+u50pbXfZ03+6Nx58= golang.org/x/term v0.19.0/go.mod h1:2CuTdWZ7KHSQwUzKva0cbMg6q2DMI3Mmxp+gKJbskEk= golang.org/x/term v0.20.0/go.mod h1:8UkIAJTvZgivsXaD6/pH6U9ecQzZ45awqEOzuCvwpFY= golang.org/x/term v0.21.0/go.mod h1:ooXLefLobQVslOqselCNF4SxFAaoS6KujMbsGzSDmX0= +golang.org/x/term v0.28.0/go.mod h1:Sw/lC2IAUZ92udQNf3WodGtn4k/XoLyZoh8v/8uiwek= golang.org/x/term v0.38.0 h1:PQ5pkm/rLO6HnxFR7N2lJHOZX6Kez5Y1gDSJla6jo7Q= golang.org/x/term v0.38.0/go.mod h1:bSEAKrOT1W+VSu9TSCMtoGEOUcKxOKgl3LE5QEF/xVg= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= @@ -467,6 +490,7 @@ golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= golang.org/x/text v0.15.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= golang.org/x/text v0.16.0/go.mod h1:GhwF1Be+LQoKShO3cGOHzqOgRrGaYc9AvblQOmPVHnI= golang.org/x/text v0.20.0/go.mod h1:D4IsuqiFMhST5bX19pQ9ikHC2GsaKyk/oF+pn3ducp4= +golang.org/x/text v0.21.0/go.mod h1:4IBbMaMmOPCJ8SecivzSH54+73PCFmPWxNTLm+vZkEQ= golang.org/x/text v0.32.0 h1:ZD01bjUt1FQ9WJ0ClOL5vxgxOI/sVCNgX1YtKwcY0mU= golang.org/x/text v0.32.0/go.mod h1:o/rUWzghvpD5TXrTIBuJU77MTaN0ljMWE47kxGJQ7jY= golang.org/x/time v0.14.0 h1:MRx4UaLrDotUKUdCIqzPC48t1Y9hANFKIRpNx+Te8PI= @@ -517,6 +541,8 @@ modernc.org/goabi0 v0.2.0 h1:HvEowk7LxcPd0eq6mVOAEMai46V+i7Jrj13t4AzuNks= modernc.org/goabi0 v0.2.0/go.mod h1:CEFRnnJhKvWT1c1JTI3Avm+tgOWbkOu5oPA8eH8LnMI= modernc.org/libc v1.67.4 h1:zZGmCMUVPORtKv95c2ReQN5VDjvkoRm9GWPTEPuvlWg= modernc.org/libc v1.67.4/go.mod h1:QvvnnJ5P7aitu0ReNpVIEyesuhmDLQ8kaEoyMjIFZJA= +modernc.org/libc v1.67.6 h1:eVOQvpModVLKOdT+LvBPjdQqfrZq+pC39BygcT+E7OI= +modernc.org/libc v1.67.6/go.mod h1:JAhxUVlolfYDErnwiqaLvUqc8nfb2r6S6slAgZOnaiE= modernc.org/mathutil v1.7.1 h1:GCZVGXdaN8gTqB1Mf/usp1Y/hSqgI2vAGGP4jZMCxOU= modernc.org/mathutil v1.7.1/go.mod h1:4p5IwJITfppl0G4sUEDtCr4DthTaT47/N3aT6MhfgJg= modernc.org/memory v1.11.0 h1:o4QC8aMQzmcwCK3t3Ux/ZHmwFPzE6hf2Y5LbkRs+hbI= @@ -527,6 +553,8 @@ modernc.org/sortutil v1.2.1 h1:+xyoGf15mM3NMlPDnFqrteY07klSFxLElE2PVuWIJ7w= modernc.org/sortutil v1.2.1/go.mod h1:7ZI3a3REbai7gzCLcotuw9AC4VZVpYMjDzETGsSMqJE= modernc.org/sqlite v1.42.2 h1:7hkZUNJvJFN2PgfUdjni9Kbvd4ef4mNLOu0B9FGxM74= modernc.org/sqlite v1.42.2/go.mod h1:+VkC6v3pLOAE0A0uVucQEcbVW0I5nHCeDaBf+DpsQT8= +modernc.org/sqlite v1.44.3 h1:+39JvV/HWMcYslAwRxHb8067w+2zowvFOUrOWIy9PjY= +modernc.org/sqlite v1.44.3/go.mod h1:CzbrU2lSB1DKUusvwGz7rqEKIq+NUd8GWuBBZDs9/nA= modernc.org/strutil v1.2.1 h1:UneZBkQA+DX2Rp35KcM69cSsNES9ly8mQWD71HKlOA0= modernc.org/strutil v1.2.1/go.mod h1:EHkiggD70koQxjVdSBM3JKM7k6L0FbGE5eymy9i3B9A= modernc.org/token v1.1.0 h1:Xl7Ap9dKaEs5kLoOQeQmPWevfnk/DM5qcLcYlA8ys6Y= diff --git a/pkg/models/sql_public_api_keys.go b/pkg/models/sql_public_api_keys.go index 8ba6e44..5e30910 100644 --- a/pkg/models/sql_public_api_keys.go +++ b/pkg/models/sql_public_api_keys.go @@ -7,64 +7,64 @@ import ( "github.com/uptrace/bun" ) -type ModelPublicAPIKey struct { - bun.BaseModel `bun:"table:api_keys,alias:api_keys"` - ID resolvespec_common.SqlString `bun:"id,type:varchar(36),pk," json:"id"` // UUID - Active bool `bun:"active,type:boolean,default:true,notnull," json:"active"` - CreatedAt resolvespec_common.SqlTime `bun:"created_at,type:timestamp,default:now(),notnull," json:"created_at"` - DeletedAt resolvespec_common.SqlTime `bun:"deleted_at,type:timestamp,nullzero," json:"deleted_at"` - ExpiresAt resolvespec_common.SqlTime `bun:"expires_at,type:timestamp,nullzero," json:"expires_at"` - Key resolvespec_common.SqlString `bun:"key,type:varchar(255),notnull," json:"key"` // Hashed API key - KeyPrefix resolvespec_common.SqlString `bun:"key_prefix,type:varchar(20),nullzero," json:"key_prefix"` // First few characters for display - LastUsedAt resolvespec_common.SqlTime `bun:"last_used_at,type:timestamp,nullzero," json:"last_used_at"` - Name resolvespec_common.SqlString `bun:"name,type:varchar(255),notnull," json:"name"` // Friendly name for the API key - Permissions resolvespec_common.SqlString `bun:"permissions,type:text,nullzero," json:"permissions"` // JSON array of permissions - UpdatedAt resolvespec_common.SqlTime `bun:"updated_at,type:timestamp,default:now(),notnull," json:"updated_at"` - UserID resolvespec_common.SqlString `bun:"user_id,type:varchar(36),notnull," json:"user_id"` - RelUserID *ModelPublicUser `bun:"rel:has-one,join:user_id=id" json:"reluserid,omitempty"` // Has one ModelPublicUser +type ModelPublicAPIKeys struct { + bun.BaseModel `bun:"table:public.api_keys,alias:api_keys"` + ID resolvespec_common.SqlString `bun:"id,type:varchar(36),pk," json:"id"` // UUID + Active bool `bun:"active,type:boolean,default:true,notnull," json:"active"` + CreatedAt resolvespec_common.SqlTimeStamp `bun:"created_at,type:timestamp,default:now(),notnull," json:"created_at"` + DeletedAt resolvespec_common.SqlTimeStamp `bun:"deleted_at,type:timestamp,nullzero," json:"deleted_at"` + ExpiresAt resolvespec_common.SqlTimeStamp `bun:"expires_at,type:timestamp,nullzero," json:"expires_at"` + Key resolvespec_common.SqlString `bun:"key,type:varchar(255),notnull," json:"key"` // Hashed API key + KeyPrefix resolvespec_common.SqlString `bun:"key_prefix,type:varchar(20),nullzero," json:"key_prefix"` // First few characters for display + LastUsedAt resolvespec_common.SqlTimeStamp `bun:"last_used_at,type:timestamp,nullzero," json:"last_used_at"` + Name resolvespec_common.SqlString `bun:"name,type:varchar(255),notnull," json:"name"` // Friendly name for the API key + Permissions resolvespec_common.SqlString `bun:"permissions,type:text,nullzero," json:"permissions"` // JSON array of permissions + UpdatedAt resolvespec_common.SqlTimeStamp `bun:"updated_at,type:timestamp,default:now(),notnull," json:"updated_at"` + UserID resolvespec_common.SqlString `bun:"user_id,type:varchar(36),notnull," json:"user_id"` + RelUserID *ModelPublicUsers `bun:"rel:has-one,join:user_id=id" json:"reluserid,omitempty"` // Has one ModelPublicUsers } -// TableName returns the table name for ModelPublicAPIKey -func (m ModelPublicAPIKey) TableName() string { +// TableName returns the table name for ModelPublicAPIKeys +func (m ModelPublicAPIKeys) TableName() string { + return "public.api_keys" +} + +// TableNameOnly returns the table name without schema for ModelPublicAPIKeys +func (m ModelPublicAPIKeys) TableNameOnly() string { return "api_keys" } -// TableNameOnly returns the table name without schema for ModelPublicAPIKey -func (m ModelPublicAPIKey) TableNameOnly() string { - return "api_keys" -} - -// SchemaName returns the schema name for ModelPublicAPIKey -func (m ModelPublicAPIKey) SchemaName() string { +// SchemaName returns the schema name for ModelPublicAPIKeys +func (m ModelPublicAPIKeys) SchemaName() string { return "public" } // GetID returns the primary key value -func (m ModelPublicAPIKey) GetID() int64 { +func (m ModelPublicAPIKeys) GetID() int64 { return m.ID.Int64() } // GetIDStr returns the primary key as a string -func (m ModelPublicAPIKey) GetIDStr() string { +func (m ModelPublicAPIKeys) GetIDStr() string { return fmt.Sprintf("%d", m.ID) } // SetID sets the primary key value -func (m ModelPublicAPIKey) SetID(newid int64) { +func (m ModelPublicAPIKeys) SetID(newid int64) { m.UpdateID(newid) } // UpdateID updates the primary key value -func (m *ModelPublicAPIKey) UpdateID(newid int64) { +func (m *ModelPublicAPIKeys) UpdateID(newid int64) { m.ID.FromString(fmt.Sprintf("%d", newid)) } // GetIDName returns the name of the primary key column -func (m ModelPublicAPIKey) GetIDName() string { +func (m ModelPublicAPIKeys) GetIDName() string { return "id" } // GetPrefix returns the table prefix -func (m ModelPublicAPIKey) GetPrefix() string { +func (m ModelPublicAPIKeys) GetPrefix() string { return "AKP" } diff --git a/pkg/models/sql_public_event_logs.go b/pkg/models/sql_public_event_logs.go index 112faff..b37c206 100644 --- a/pkg/models/sql_public_event_logs.go +++ b/pkg/models/sql_public_event_logs.go @@ -7,64 +7,64 @@ import ( "github.com/uptrace/bun" ) -type ModelPublicEventLog struct { - bun.BaseModel `bun:"table:event_logs,alias:event_logs"` - ID resolvespec_common.SqlString `bun:"id,type:varchar(36),pk," json:"id"` // UUID - Action resolvespec_common.SqlString `bun:"action,type:varchar(50),nullzero," json:"action"` // create - CreatedAt resolvespec_common.SqlTime `bun:"created_at,type:timestamp,default:now(),notnull," json:"created_at"` - Data resolvespec_common.SqlString `bun:"data,type:text,nullzero," json:"data"` // JSON encoded event data - EntityID resolvespec_common.SqlString `bun:"entity_id,type:varchar(36),nullzero," json:"entity_id"` - EntityType resolvespec_common.SqlString `bun:"entity_type,type:varchar(100),nullzero," json:"entity_type"` // user - Error resolvespec_common.SqlString `bun:"error,type:text,nullzero," json:"error"` - EventType resolvespec_common.SqlString `bun:"event_type,type:varchar(100),notnull," json:"event_type"` - IpAddress resolvespec_common.SqlString `bun:"ip_address,type:varchar(50),nullzero," json:"ip_address"` - Success bool `bun:"success,type:boolean,default:true,notnull," json:"success"` - UserAgent resolvespec_common.SqlString `bun:"user_agent,type:text,nullzero," json:"user_agent"` - UserID resolvespec_common.SqlString `bun:"user_id,type:varchar(36),nullzero," json:"user_id"` // Optional user reference - RelUserID *ModelPublicUser `bun:"rel:has-one,join:user_id=id" json:"reluserid,omitempty"` // Has one ModelPublicUser +type ModelPublicEventLogs struct { + bun.BaseModel `bun:"table:public.event_logs,alias:event_logs"` + ID resolvespec_common.SqlString `bun:"id,type:varchar(36),pk," json:"id"` // UUID + Action resolvespec_common.SqlString `bun:"action,type:varchar(50),nullzero," json:"action"` // create + CreatedAt resolvespec_common.SqlTimeStamp `bun:"created_at,type:timestamp,default:now(),notnull," json:"created_at"` + Data resolvespec_common.SqlString `bun:"data,type:text,nullzero," json:"data"` // JSON encoded event data + EntityID resolvespec_common.SqlString `bun:"entity_id,type:varchar(36),nullzero," json:"entity_id"` + EntityType resolvespec_common.SqlString `bun:"entity_type,type:varchar(100),nullzero," json:"entity_type"` // user + Error resolvespec_common.SqlString `bun:"error,type:text,nullzero," json:"error"` + EventType resolvespec_common.SqlString `bun:"event_type,type:varchar(100),notnull," json:"event_type"` + IpAddress resolvespec_common.SqlString `bun:"ip_address,type:varchar(50),nullzero," json:"ip_address"` + Success bool `bun:"success,type:boolean,default:true,notnull," json:"success"` + UserAgent resolvespec_common.SqlString `bun:"user_agent,type:text,nullzero," json:"user_agent"` + UserID resolvespec_common.SqlString `bun:"user_id,type:varchar(36),nullzero," json:"user_id"` // Optional user reference + RelUserID *ModelPublicUsers `bun:"rel:has-one,join:user_id=id" json:"reluserid,omitempty"` // Has one ModelPublicUsers } -// TableName returns the table name for ModelPublicEventLog -func (m ModelPublicEventLog) TableName() string { +// TableName returns the table name for ModelPublicEventLogs +func (m ModelPublicEventLogs) TableName() string { + return "public.event_logs" +} + +// TableNameOnly returns the table name without schema for ModelPublicEventLogs +func (m ModelPublicEventLogs) TableNameOnly() string { return "event_logs" } -// TableNameOnly returns the table name without schema for ModelPublicEventLog -func (m ModelPublicEventLog) TableNameOnly() string { - return "event_logs" -} - -// SchemaName returns the schema name for ModelPublicEventLog -func (m ModelPublicEventLog) SchemaName() string { +// SchemaName returns the schema name for ModelPublicEventLogs +func (m ModelPublicEventLogs) SchemaName() string { return "public" } // GetID returns the primary key value -func (m ModelPublicEventLog) GetID() int64 { +func (m ModelPublicEventLogs) GetID() int64 { return m.ID.Int64() } // GetIDStr returns the primary key as a string -func (m ModelPublicEventLog) GetIDStr() string { +func (m ModelPublicEventLogs) GetIDStr() string { return fmt.Sprintf("%d", m.ID) } // SetID sets the primary key value -func (m ModelPublicEventLog) SetID(newid int64) { +func (m ModelPublicEventLogs) SetID(newid int64) { m.UpdateID(newid) } // UpdateID updates the primary key value -func (m *ModelPublicEventLog) UpdateID(newid int64) { +func (m *ModelPublicEventLogs) UpdateID(newid int64) { m.ID.FromString(fmt.Sprintf("%d", newid)) } // GetIDName returns the name of the primary key column -func (m ModelPublicEventLog) GetIDName() string { +func (m ModelPublicEventLogs) GetIDName() string { return "id" } // GetPrefix returns the table prefix -func (m ModelPublicEventLog) GetPrefix() string { +func (m ModelPublicEventLogs) GetPrefix() string { return "ELV" } diff --git a/pkg/models/sql_public_hooks.go b/pkg/models/sql_public_hooks.go index a468df3..9c49b11 100644 --- a/pkg/models/sql_public_hooks.go +++ b/pkg/models/sql_public_hooks.go @@ -7,68 +7,68 @@ import ( "github.com/uptrace/bun" ) -type ModelPublicHook struct { - bun.BaseModel `bun:"table:hooks,alias:hooks"` - ID resolvespec_common.SqlString `bun:"id,type:varchar(36),pk," json:"id"` // UUID - Active bool `bun:"active,type:boolean,default:true,notnull," json:"active"` - AllowInsecure bool `bun:"allow_insecure,type:boolean,default:false,notnull," json:"allow_insecure"` // Skip TLS certificate verification - CreatedAt resolvespec_common.SqlTime `bun:"created_at,type:timestamp,default:now(),notnull," json:"created_at"` - DeletedAt resolvespec_common.SqlTime `bun:"deleted_at,type:timestamp,nullzero," json:"deleted_at"` - Description resolvespec_common.SqlString `bun:"description,type:text,nullzero," json:"description"` - Events resolvespec_common.SqlString `bun:"events,type:text,nullzero," json:"events"` // JSON array of event types - Headers resolvespec_common.SqlString `bun:"headers,type:text,nullzero," json:"headers"` // JSON encoded headers - Method resolvespec_common.SqlString `bun:"method,type:varchar(10),default:POST,notnull," json:"method"` // HTTP method - Name resolvespec_common.SqlString `bun:"name,type:varchar(255),notnull," json:"name"` - RetryCount resolvespec_common.SqlInt32 `bun:"retry_count,type:int,default:3,notnull," json:"retry_count"` - Secret resolvespec_common.SqlString `bun:"secret,type:varchar(255),nullzero," json:"secret"` // HMAC signature secret - Timeout resolvespec_common.SqlInt32 `bun:"timeout,type:int,default:30,notnull," json:"timeout"` // Timeout in seconds - UpdatedAt resolvespec_common.SqlTime `bun:"updated_at,type:timestamp,default:now(),notnull," json:"updated_at"` - URL resolvespec_common.SqlString `bun:"url,type:text,notnull," json:"url"` - UserID resolvespec_common.SqlString `bun:"user_id,type:varchar(36),notnull," json:"user_id"` - RelUserID *ModelPublicUser `bun:"rel:has-one,join:user_id=id" json:"reluserid,omitempty"` // Has one ModelPublicUser +type ModelPublicHooks struct { + bun.BaseModel `bun:"table:public.hooks,alias:hooks"` + ID resolvespec_common.SqlString `bun:"id,type:varchar(36),pk," json:"id"` // UUID + Active bool `bun:"active,type:boolean,default:true,notnull," json:"active"` + AllowInsecure bool `bun:"allow_insecure,type:boolean,default:false,notnull," json:"allow_insecure"` // Skip TLS certificate verification + CreatedAt resolvespec_common.SqlTimeStamp `bun:"created_at,type:timestamp,default:now(),notnull," json:"created_at"` + DeletedAt resolvespec_common.SqlTimeStamp `bun:"deleted_at,type:timestamp,nullzero," json:"deleted_at"` + Description resolvespec_common.SqlString `bun:"description,type:text,nullzero," json:"description"` + Events resolvespec_common.SqlString `bun:"events,type:text,nullzero," json:"events"` // JSON array of event types + Headers resolvespec_common.SqlString `bun:"headers,type:text,nullzero," json:"headers"` // JSON encoded headers + Method resolvespec_common.SqlString `bun:"method,type:varchar(10),default:'POST',notnull," json:"method"` // HTTP method + Name resolvespec_common.SqlString `bun:"name,type:varchar(255),notnull," json:"name"` + RetryCount resolvespec_common.SqlInt32 `bun:"retry_count,type:int,default:3,notnull," json:"retry_count"` + Secret resolvespec_common.SqlString `bun:"secret,type:varchar(255),nullzero," json:"secret"` // HMAC signature secret + Timeout resolvespec_common.SqlInt32 `bun:"timeout,type:int,default:30,notnull," json:"timeout"` // Timeout in seconds + UpdatedAt resolvespec_common.SqlTimeStamp `bun:"updated_at,type:timestamp,default:now(),notnull," json:"updated_at"` + URL resolvespec_common.SqlString `bun:"url,type:text,notnull," json:"url"` + UserID resolvespec_common.SqlString `bun:"user_id,type:varchar(36),notnull," json:"user_id"` + RelUserID *ModelPublicUsers `bun:"rel:has-one,join:user_id=id" json:"reluserid,omitempty"` // Has one ModelPublicUsers } -// TableName returns the table name for ModelPublicHook -func (m ModelPublicHook) TableName() string { +// TableName returns the table name for ModelPublicHooks +func (m ModelPublicHooks) TableName() string { + return "public.hooks" +} + +// TableNameOnly returns the table name without schema for ModelPublicHooks +func (m ModelPublicHooks) TableNameOnly() string { return "hooks" } -// TableNameOnly returns the table name without schema for ModelPublicHook -func (m ModelPublicHook) TableNameOnly() string { - return "hooks" -} - -// SchemaName returns the schema name for ModelPublicHook -func (m ModelPublicHook) SchemaName() string { +// SchemaName returns the schema name for ModelPublicHooks +func (m ModelPublicHooks) SchemaName() string { return "public" } // GetID returns the primary key value -func (m ModelPublicHook) GetID() int64 { +func (m ModelPublicHooks) GetID() int64 { return m.ID.Int64() } // GetIDStr returns the primary key as a string -func (m ModelPublicHook) GetIDStr() string { +func (m ModelPublicHooks) GetIDStr() string { return fmt.Sprintf("%d", m.ID) } // SetID sets the primary key value -func (m ModelPublicHook) SetID(newid int64) { +func (m ModelPublicHooks) SetID(newid int64) { m.UpdateID(newid) } // UpdateID updates the primary key value -func (m *ModelPublicHook) UpdateID(newid int64) { +func (m *ModelPublicHooks) UpdateID(newid int64) { m.ID.FromString(fmt.Sprintf("%d", newid)) } // GetIDName returns the name of the primary key column -func (m ModelPublicHook) GetIDName() string { +func (m ModelPublicHooks) GetIDName() string { return "id" } // GetPrefix returns the table prefix -func (m ModelPublicHook) GetPrefix() string { +func (m ModelPublicHooks) GetPrefix() string { return "HOO" } diff --git a/pkg/models/sql_public_message_cache.go b/pkg/models/sql_public_message_cache.go index 5804608..bec396c 100644 --- a/pkg/models/sql_public_message_cache.go +++ b/pkg/models/sql_public_message_cache.go @@ -8,21 +8,21 @@ import ( ) type ModelPublicMessageCache struct { - bun.BaseModel `bun:"table:message_cache,alias:message_cache"` - ID resolvespec_common.SqlString `bun:"id,type:varchar(36),pk," json:"id"` // UUID - AccountID resolvespec_common.SqlString `bun:"account_id,type:varchar(36),notnull," json:"account_id"` - ChatID resolvespec_common.SqlString `bun:"chat_id,type:varchar(255),notnull," json:"chat_id"` - Content resolvespec_common.SqlString `bun:"content,type:text,notnull," json:"content"` // JSON encoded message content - CreatedAt resolvespec_common.SqlTime `bun:"created_at,type:timestamp,default:now(),notnull," json:"created_at"` - FromMe bool `bun:"from_me,type:boolean,notnull," json:"from_me"` - MessageID resolvespec_common.SqlString `bun:"message_id,type:varchar(255),notnull," json:"message_id"` - MessageType resolvespec_common.SqlString `bun:"message_type,type:varchar(50),notnull," json:"message_type"` // text - Timestamp resolvespec_common.SqlTime `bun:"timestamp,type:timestamp,notnull," json:"timestamp"` + bun.BaseModel `bun:"table:public.message_cache,alias:message_cache"` + ID resolvespec_common.SqlString `bun:"id,type:varchar(36),pk," json:"id"` // UUID + AccountID resolvespec_common.SqlString `bun:"account_id,type:varchar(36),notnull," json:"account_id"` + ChatID resolvespec_common.SqlString `bun:"chat_id,type:varchar(255),notnull," json:"chat_id"` + Content resolvespec_common.SqlString `bun:"content,type:text,notnull," json:"content"` // JSON encoded message content + CreatedAt resolvespec_common.SqlTimeStamp `bun:"created_at,type:timestamp,default:now(),notnull," json:"created_at"` + FromMe bool `bun:"from_me,type:boolean,notnull," json:"from_me"` + MessageID resolvespec_common.SqlString `bun:"message_id,type:varchar(255),notnull," json:"message_id"` + MessageType resolvespec_common.SqlString `bun:"message_type,type:varchar(50),notnull," json:"message_type"` // text + Timestamp resolvespec_common.SqlTimeStamp `bun:"timestamp,type:timestamp,notnull," json:"timestamp"` } // TableName returns the table name for ModelPublicMessageCache func (m ModelPublicMessageCache) TableName() string { - return "message_cache" + return "public.message_cache" } // TableNameOnly returns the table name without schema for ModelPublicMessageCache diff --git a/pkg/models/sql_public_sessions.go b/pkg/models/sql_public_sessions.go index fda0f09..e85777b 100644 --- a/pkg/models/sql_public_sessions.go +++ b/pkg/models/sql_public_sessions.go @@ -7,60 +7,60 @@ import ( "github.com/uptrace/bun" ) -type ModelPublicSession struct { - bun.BaseModel `bun:"table:sessions,alias:sessions"` - ID resolvespec_common.SqlString `bun:"id,type:varchar(36),pk," json:"id"` // UUID - CreatedAt resolvespec_common.SqlTime `bun:"created_at,type:timestamp,default:now(),notnull," json:"created_at"` - ExpiresAt resolvespec_common.SqlTime `bun:"expires_at,type:timestamp,notnull," json:"expires_at"` - IpAddress resolvespec_common.SqlString `bun:"ip_address,type:varchar(50),nullzero," json:"ip_address"` - Token resolvespec_common.SqlString `bun:"token,type:varchar(255),notnull," json:"token"` // Session token hash - UpdatedAt resolvespec_common.SqlTime `bun:"updated_at,type:timestamp,default:now(),notnull," json:"updated_at"` - UserAgent resolvespec_common.SqlString `bun:"user_agent,type:text,nullzero," json:"user_agent"` - UserID resolvespec_common.SqlString `bun:"user_id,type:varchar(36),notnull," json:"user_id"` - RelUserID *ModelPublicUser `bun:"rel:has-one,join:user_id=id" json:"reluserid,omitempty"` // Has one ModelPublicUser +type ModelPublicSessions struct { + bun.BaseModel `bun:"table:public.sessions,alias:sessions"` + ID resolvespec_common.SqlString `bun:"id,type:varchar(36),pk," json:"id"` // UUID + CreatedAt resolvespec_common.SqlTimeStamp `bun:"created_at,type:timestamp,default:now(),notnull," json:"created_at"` + ExpiresAt resolvespec_common.SqlTimeStamp `bun:"expires_at,type:timestamp,notnull," json:"expires_at"` + IpAddress resolvespec_common.SqlString `bun:"ip_address,type:varchar(50),nullzero," json:"ip_address"` + Token resolvespec_common.SqlString `bun:"token,type:varchar(255),notnull," json:"token"` // Session token hash + UpdatedAt resolvespec_common.SqlTimeStamp `bun:"updated_at,type:timestamp,default:now(),notnull," json:"updated_at"` + UserAgent resolvespec_common.SqlString `bun:"user_agent,type:text,nullzero," json:"user_agent"` + UserID resolvespec_common.SqlString `bun:"user_id,type:varchar(36),notnull," json:"user_id"` + RelUserID *ModelPublicUsers `bun:"rel:has-one,join:user_id=id" json:"reluserid,omitempty"` // Has one ModelPublicUsers } -// TableName returns the table name for ModelPublicSession -func (m ModelPublicSession) TableName() string { +// TableName returns the table name for ModelPublicSessions +func (m ModelPublicSessions) TableName() string { + return "public.sessions" +} + +// TableNameOnly returns the table name without schema for ModelPublicSessions +func (m ModelPublicSessions) TableNameOnly() string { return "sessions" } -// TableNameOnly returns the table name without schema for ModelPublicSession -func (m ModelPublicSession) TableNameOnly() string { - return "sessions" -} - -// SchemaName returns the schema name for ModelPublicSession -func (m ModelPublicSession) SchemaName() string { +// SchemaName returns the schema name for ModelPublicSessions +func (m ModelPublicSessions) SchemaName() string { return "public" } // GetID returns the primary key value -func (m ModelPublicSession) GetID() int64 { +func (m ModelPublicSessions) GetID() int64 { return m.ID.Int64() } // GetIDStr returns the primary key as a string -func (m ModelPublicSession) GetIDStr() string { +func (m ModelPublicSessions) GetIDStr() string { return fmt.Sprintf("%d", m.ID) } // SetID sets the primary key value -func (m ModelPublicSession) SetID(newid int64) { +func (m ModelPublicSessions) SetID(newid int64) { m.UpdateID(newid) } // UpdateID updates the primary key value -func (m *ModelPublicSession) UpdateID(newid int64) { +func (m *ModelPublicSessions) UpdateID(newid int64) { m.ID.FromString(fmt.Sprintf("%d", newid)) } // GetIDName returns the name of the primary key column -func (m ModelPublicSession) GetIDName() string { +func (m ModelPublicSessions) GetIDName() string { return "id" } // GetPrefix returns the table prefix -func (m ModelPublicSession) GetPrefix() string { +func (m ModelPublicSessions) GetPrefix() string { return "SES" } diff --git a/pkg/models/sql_public_users.go b/pkg/models/sql_public_users.go index 46f19c4..89cece6 100644 --- a/pkg/models/sql_public_users.go +++ b/pkg/models/sql_public_users.go @@ -7,66 +7,66 @@ import ( "github.com/uptrace/bun" ) -type ModelPublicUser struct { - bun.BaseModel `bun:"table:users,alias:users"` - ID resolvespec_common.SqlString `bun:"id,type:varchar(36),pk," json:"id"` // UUID - Active bool `bun:"active,type:boolean,default:true,notnull," json:"active"` - CreatedAt resolvespec_common.SqlTime `bun:"created_at,type:timestamp,default:now(),notnull," json:"created_at"` - DeletedAt resolvespec_common.SqlTime `bun:"deleted_at,type:timestamp,nullzero," json:"deleted_at"` // Soft delete - Email resolvespec_common.SqlString `bun:"email,type:varchar(255),notnull," json:"email"` - FullName resolvespec_common.SqlString `bun:"full_name,type:varchar(255),nullzero," json:"full_name"` - Password resolvespec_common.SqlString `bun:"password,type:varchar(255),notnull," json:"password"` // Bcrypt hashed password - Role resolvespec_common.SqlString `bun:"role,type:varchar(50),default:user,notnull," json:"role"` // admin - UpdatedAt resolvespec_common.SqlTime `bun:"updated_at,type:timestamp,default:now(),notnull," json:"updated_at"` - Username resolvespec_common.SqlString `bun:"username,type:varchar(255),notnull," json:"username"` - RelUserIDPublicAPIKeys []*ModelPublicAPIKey `bun:"rel:has-many,join:id=user_id" json:"reluseridpublicapikeys,omitempty"` // Has many ModelPublicAPIKey - RelUserIDPublicHooks []*ModelPublicHook `bun:"rel:has-many,join:id=user_id" json:"reluseridpublichooks,omitempty"` // Has many ModelPublicHook - RelUserIDPublicWhatsappAccounts []*ModelPublicWhatsappAccount `bun:"rel:has-many,join:id=user_id" json:"reluseridpublicwhatsappaccounts,omitempty"` // Has many ModelPublicWhatsappAccount - RelUserIDPublicEventLogs []*ModelPublicEventLog `bun:"rel:has-many,join:id=user_id" json:"reluseridpubliceventlogs,omitempty"` // Has many ModelPublicEventLog - RelUserIDPublicSessions []*ModelPublicSession `bun:"rel:has-many,join:id=user_id" json:"reluseridpublicsessions,omitempty"` // Has many ModelPublicSession +type ModelPublicUsers struct { + bun.BaseModel `bun:"table:public.users,alias:users"` + ID resolvespec_common.SqlString `bun:"id,type:varchar(36),pk," json:"id"` // UUID + Active bool `bun:"active,type:boolean,default:true,notnull," json:"active"` + CreatedAt resolvespec_common.SqlTimeStamp `bun:"created_at,type:timestamp,default:now(),notnull," json:"created_at"` + DeletedAt resolvespec_common.SqlTimeStamp `bun:"deleted_at,type:timestamp,nullzero," json:"deleted_at"` // Soft delete + Email resolvespec_common.SqlString `bun:"email,type:varchar(255),notnull," json:"email"` + FullName resolvespec_common.SqlString `bun:"full_name,type:varchar(255),nullzero," json:"full_name"` + Password resolvespec_common.SqlString `bun:"password,type:varchar(255),notnull," json:"password"` // Bcrypt hashed password + Role resolvespec_common.SqlString `bun:"role,type:varchar(50),default:'user',notnull," json:"role"` // admin + UpdatedAt resolvespec_common.SqlTimeStamp `bun:"updated_at,type:timestamp,default:now(),notnull," json:"updated_at"` + Username resolvespec_common.SqlString `bun:"username,type:varchar(255),notnull," json:"username"` + RelUserIDPublicAPIKeys []*ModelPublicAPIKeys `bun:"rel:has-many,join:id=user_id" json:"reluseridpublicapikeys,omitempty"` // Has many ModelPublicAPIKeys + RelUserIDPublicHooks []*ModelPublicHooks `bun:"rel:has-many,join:id=user_id" json:"reluseridpublichooks,omitempty"` // Has many ModelPublicHooks + RelUserIDPublicWhatsappAccounts []*ModelPublicWhatsappAccounts `bun:"rel:has-many,join:id=user_id" json:"reluseridpublicwhatsappaccounts,omitempty"` // Has many ModelPublicWhatsappAccounts + RelUserIDPublicEventLogs []*ModelPublicEventLogs `bun:"rel:has-many,join:id=user_id" json:"reluseridpubliceventlogs,omitempty"` // Has many ModelPublicEventLogs + RelUserIDPublicSessions []*ModelPublicSessions `bun:"rel:has-many,join:id=user_id" json:"reluseridpublicsessions,omitempty"` // Has many ModelPublicSessions } -// TableName returns the table name for ModelPublicUser -func (m ModelPublicUser) TableName() string { +// TableName returns the table name for ModelPublicUsers +func (m ModelPublicUsers) TableName() string { + return "public.users" +} + +// TableNameOnly returns the table name without schema for ModelPublicUsers +func (m ModelPublicUsers) TableNameOnly() string { return "users" } -// TableNameOnly returns the table name without schema for ModelPublicUser -func (m ModelPublicUser) TableNameOnly() string { - return "users" -} - -// SchemaName returns the schema name for ModelPublicUser -func (m ModelPublicUser) SchemaName() string { +// SchemaName returns the schema name for ModelPublicUsers +func (m ModelPublicUsers) SchemaName() string { return "public" } // GetID returns the primary key value -func (m ModelPublicUser) GetID() int64 { +func (m ModelPublicUsers) GetID() int64 { return m.ID.Int64() } // GetIDStr returns the primary key as a string -func (m ModelPublicUser) GetIDStr() string { +func (m ModelPublicUsers) GetIDStr() string { return fmt.Sprintf("%d", m.ID) } // SetID sets the primary key value -func (m ModelPublicUser) SetID(newid int64) { +func (m ModelPublicUsers) SetID(newid int64) { m.UpdateID(newid) } // UpdateID updates the primary key value -func (m *ModelPublicUser) UpdateID(newid int64) { +func (m *ModelPublicUsers) UpdateID(newid int64) { m.ID.FromString(fmt.Sprintf("%d", newid)) } // GetIDName returns the name of the primary key column -func (m ModelPublicUser) GetIDName() string { +func (m ModelPublicUsers) GetIDName() string { return "id" } // GetPrefix returns the table prefix -func (m ModelPublicUser) GetPrefix() string { +func (m ModelPublicUsers) GetPrefix() string { return "USE" } diff --git a/pkg/models/sql_public_whatsapp_accounts.go b/pkg/models/sql_public_whatsapp_accounts.go index a99e679..0bb715c 100644 --- a/pkg/models/sql_public_whatsapp_accounts.go +++ b/pkg/models/sql_public_whatsapp_accounts.go @@ -7,66 +7,65 @@ import ( "github.com/uptrace/bun" ) -type ModelPublicWhatsappAccount struct { - bun.BaseModel `bun:"table:whatsapp_accounts,alias:whatsapp_accounts"` - ID resolvespec_common.SqlString `bun:"id,type:varchar(36),pk," json:"id"` // UUID - AccountID resolvespec_common.SqlString `bun:"account_id,type:varchar(100),unique,nullzero," json:"account_id"` // User-friendly unique identifier - AccountType resolvespec_common.SqlString `bun:"account_type,type:varchar(50),notnull," json:"account_type"` // whatsmeow or business-api - Active bool `bun:"active,type:boolean,default:true,notnull," json:"active"` - Config resolvespec_common.SqlString `bun:"config,type:text,nullzero," json:"config"` // JSON encoded additional config - CreatedAt resolvespec_common.SqlTime `bun:"created_at,type:timestamp,default:now(),notnull," json:"created_at"` - DeletedAt resolvespec_common.SqlTime `bun:"deleted_at,type:timestamp,nullzero," json:"deleted_at"` - DisplayName resolvespec_common.SqlString `bun:"display_name,type:varchar(255),nullzero," json:"display_name"` - LastConnectedAt resolvespec_common.SqlTime `bun:"last_connected_at,type:timestamp,nullzero," json:"last_connected_at"` - PhoneNumber resolvespec_common.SqlString `bun:"phone_number,type:varchar(50),notnull," json:"phone_number"` - SessionPath resolvespec_common.SqlString `bun:"session_path,type:text,nullzero," json:"session_path"` - Status resolvespec_common.SqlString `bun:"status,type:varchar(50),default:disconnected,notnull," json:"status"` // connected - UpdatedAt resolvespec_common.SqlTime `bun:"updated_at,type:timestamp,default:now(),notnull," json:"updated_at"` - UserID resolvespec_common.SqlString `bun:"user_id,type:varchar(36),notnull," json:"user_id"` - RelUserID *ModelPublicUser `bun:"rel:has-one,join:user_id=id" json:"reluserid,omitempty"` // Has one ModelPublicUser +type ModelPublicWhatsappAccounts struct { + bun.BaseModel `bun:"table:public.whatsapp_accounts,alias:whatsapp_accounts"` + ID resolvespec_common.SqlString `bun:"id,type:varchar(36),pk," json:"id"` // UUID + AccountType resolvespec_common.SqlString `bun:"account_type,type:varchar(50),notnull," json:"account_type"` // whatsmeow or business-api + Active bool `bun:"active,type:boolean,default:true,notnull," json:"active"` + Config resolvespec_common.SqlString `bun:"config,type:text,nullzero," json:"config"` // JSON encoded additional config + CreatedAt resolvespec_common.SqlTimeStamp `bun:"created_at,type:timestamp,default:now(),notnull," json:"created_at"` + DeletedAt resolvespec_common.SqlTimeStamp `bun:"deleted_at,type:timestamp,nullzero," json:"deleted_at"` + DisplayName resolvespec_common.SqlString `bun:"display_name,type:varchar(255),nullzero," json:"display_name"` + LastConnectedAt resolvespec_common.SqlTimeStamp `bun:"last_connected_at,type:timestamp,nullzero," json:"last_connected_at"` + PhoneNumber resolvespec_common.SqlString `bun:"phone_number,type:varchar(50),notnull," json:"phone_number"` + SessionPath resolvespec_common.SqlString `bun:"session_path,type:text,nullzero," json:"session_path"` + Status resolvespec_common.SqlString `bun:"status,type:varchar(50),default:'disconnected',notnull," json:"status"` // connected + UpdatedAt resolvespec_common.SqlTimeStamp `bun:"updated_at,type:timestamp,default:now(),notnull," json:"updated_at"` + UserID resolvespec_common.SqlString `bun:"user_id,type:varchar(36),notnull," json:"user_id"` + RelUserID *ModelPublicUsers `bun:"rel:has-one,join:user_id=id" json:"reluserid,omitempty"` // Has one ModelPublicUsers } -// TableName returns the table name for ModelPublicWhatsappAccount -func (m ModelPublicWhatsappAccount) TableName() string { +// TableName returns the table name for ModelPublicWhatsappAccounts +func (m ModelPublicWhatsappAccounts) TableName() string { + return "public.whatsapp_accounts" +} + +// TableNameOnly returns the table name without schema for ModelPublicWhatsappAccounts +func (m ModelPublicWhatsappAccounts) TableNameOnly() string { return "whatsapp_accounts" } -// TableNameOnly returns the table name without schema for ModelPublicWhatsappAccount -func (m ModelPublicWhatsappAccount) TableNameOnly() string { - return "whatsapp_accounts" -} - -// SchemaName returns the schema name for ModelPublicWhatsappAccount -func (m ModelPublicWhatsappAccount) SchemaName() string { +// SchemaName returns the schema name for ModelPublicWhatsappAccounts +func (m ModelPublicWhatsappAccounts) SchemaName() string { return "public" } // GetID returns the primary key value -func (m ModelPublicWhatsappAccount) GetID() int64 { +func (m ModelPublicWhatsappAccounts) GetID() int64 { return m.ID.Int64() } // GetIDStr returns the primary key as a string -func (m ModelPublicWhatsappAccount) GetIDStr() string { +func (m ModelPublicWhatsappAccounts) GetIDStr() string { return fmt.Sprintf("%d", m.ID) } // SetID sets the primary key value -func (m ModelPublicWhatsappAccount) SetID(newid int64) { +func (m ModelPublicWhatsappAccounts) SetID(newid int64) { m.UpdateID(newid) } // UpdateID updates the primary key value -func (m *ModelPublicWhatsappAccount) UpdateID(newid int64) { +func (m *ModelPublicWhatsappAccounts) UpdateID(newid int64) { m.ID.FromString(fmt.Sprintf("%d", newid)) } // GetIDName returns the name of the primary key column -func (m ModelPublicWhatsappAccount) GetIDName() string { +func (m ModelPublicWhatsappAccounts) GetIDName() string { return "id" } // GetPrefix returns the table prefix -func (m ModelPublicWhatsappAccount) GetPrefix() string { +func (m ModelPublicWhatsappAccounts) GetPrefix() string { return "WAH" }