@kyro-cms/core 0.12.44 → 0.12.46
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{WebhookService-C19xR8qE.d.ts → WebhookService-CZf_na-J.d.ts} +1 -1
- package/dist/{WebhookService-BBcCHBo8.d.cts → WebhookService-DgIx21X-.d.cts} +1 -1
- package/dist/api-handler-graphql.cjs +1 -1
- package/dist/api-handler-graphql.js +2 -1
- package/dist/api-handler-trpc.cjs +1 -1
- package/dist/api-handler-trpc.js +2 -1
- package/dist/api-handler.cjs +1 -1
- package/dist/api-handler.js +1 -1
- package/dist/{base-yXdYZxFK.d.ts → base-7vJMzr4V.d.ts} +1 -1
- package/dist/{base-C2iwjdJQ.d.cts → base-DDEmdRqV.d.cts} +1 -1
- package/dist/bcryptjs-AZA6WEN2.js +2 -0
- package/dist/bcryptjs-WIQSWJGK.cjs +1 -0
- package/dist/better-sqlite3-42Q3FG3E.js +2 -0
- package/dist/better-sqlite3-5IISPX34.cjs +1 -0
- package/dist/bootstrap-7CI3NVSY.js +1 -0
- package/dist/bootstrap-DOOM2CNQ.cjs +1 -0
- package/dist/bowser-FI5JQGKZ.js +11 -0
- package/dist/bowser-VX6B6ZSE.cjs +10 -0
- package/dist/chokidar-24HVS6XD.cjs +5 -0
- package/dist/chokidar-43DT7CVN.js +6 -0
- package/dist/chunk-227MEHYX.cjs +269 -0
- package/dist/chunk-26Q7JXM4.cjs +3 -0
- package/dist/chunk-2BUODBE2.js +2 -0
- package/dist/chunk-2WFTETFB.js +2 -0
- package/dist/chunk-35PGCW3S.cjs +1 -0
- package/dist/chunk-3VXEK5ZW.cjs +1 -0
- package/dist/chunk-45TJAB5X.js +301 -0
- package/dist/chunk-5DWYVUQR.cjs +1 -0
- package/dist/chunk-5LPNEYK5.cjs +1 -0
- package/dist/chunk-66BJXVFJ.js +2 -0
- package/dist/chunk-6KRR7YHA.js +2 -0
- package/dist/chunk-6KUL2BSA.cjs +133 -0
- package/dist/chunk-6MSS5X77.js +2 -0
- package/dist/chunk-6QWLXJ7L.js +2 -0
- package/dist/chunk-73D2PNHD.cjs +7 -0
- package/dist/chunk-7ACHOBWY.cjs +13 -0
- package/dist/chunk-7AQSH3KR.js +2 -0
- package/dist/chunk-7GGZA5YU.cjs +2 -0
- package/dist/chunk-7I6URA6F.js +4 -0
- package/dist/chunk-7JWQ2PZP.cjs +1 -0
- package/dist/chunk-7T35572E.js +75 -0
- package/dist/chunk-7V67ONUD.js +4 -0
- package/dist/chunk-7WMMKGEO.cjs +1 -0
- package/dist/chunk-A73AVVFR.js +11 -0
- package/dist/chunk-AK754S3T.cjs +2 -0
- package/dist/chunk-AMGJ5AFH.cjs +1 -0
- package/dist/chunk-ATBH763U.js +2 -0
- package/dist/chunk-B3GDQ7UI.cjs +114 -0
- package/dist/chunk-BAVN7VDR.cjs +1 -0
- package/dist/chunk-BCEE4NBZ.cjs +2 -0
- package/dist/{chunk-J4252I5B.cjs → chunk-BHR7OAU4.cjs} +4 -4
- package/dist/chunk-BLH2MRK4.js +2 -0
- package/dist/chunk-BPMA2ECA.js +10 -0
- package/dist/chunk-BUNLC3II.cjs +1 -0
- package/dist/chunk-C2PXMVR5.js +2 -0
- package/dist/chunk-CAJ4ZJO6.cjs +1 -0
- package/dist/chunk-CGPAS4U5.js +4 -0
- package/dist/chunk-DS5DE5BU.js +2 -0
- package/dist/chunk-DT3LHRQT.js +57 -0
- package/dist/chunk-DUO523BH.cjs +1 -0
- package/dist/chunk-DVWYO3KK.cjs +1 -0
- package/dist/chunk-E27KEZPT.js +2 -0
- package/dist/chunk-EHWUALGH.cjs +1 -0
- package/dist/chunk-EN65ZEK2.cjs +2 -0
- package/dist/chunk-EOOZDOL7.js +3 -0
- package/dist/chunk-EZIDQBXI.cjs +1 -0
- package/dist/chunk-F4ITQ6XQ.cjs +3 -0
- package/dist/chunk-GIS6X43A.cjs +3 -0
- package/dist/chunk-GNEVCEJU.cjs +3 -0
- package/dist/chunk-GNOSG3PK.cjs +1 -0
- package/dist/chunk-HLAEJB5R.js +384 -0
- package/dist/chunk-HPYH7GTS.cjs +1 -0
- package/dist/chunk-HT44I66C.js +24 -0
- package/dist/chunk-HTYVI2HK.cjs +9 -0
- package/dist/chunk-ICVQWR2A.js +2 -0
- package/dist/chunk-IP6JUEH3.js +3 -0
- package/dist/chunk-IPXOY4RI.js +2 -0
- package/dist/chunk-IUAWDAUD.cjs +56 -0
- package/dist/chunk-J6U5LWZ7.js +11 -0
- package/dist/{chunk-UHFDH3PG.js → chunk-JT36FTHY.cjs} +4 -4
- package/dist/chunk-JUJZOG6P.js +2 -0
- package/dist/{chunk-2BTRHVT3.cjs → chunk-K7YNEKVE.js} +5 -4
- package/dist/chunk-KCHPADCH.cjs +7 -0
- package/dist/chunk-KH7LM52S.js +3 -0
- package/dist/chunk-LEBM6ZSZ.cjs +10 -0
- package/dist/chunk-LQ3YZTPU.cjs +15 -0
- package/dist/chunk-LY7N3UHH.cjs +23 -0
- package/dist/chunk-MCZ3YZ2L.js +2 -0
- package/dist/chunk-MP5VC5ER.cjs +1 -0
- package/dist/chunk-MVX2PYJJ.cjs +1 -0
- package/dist/chunk-MY42EWZP.js +2 -0
- package/dist/chunk-MZOWPV4D.js +20 -0
- package/dist/chunk-NGNJSUGL.cjs +1 -0
- package/dist/chunk-NWCREF47.js +3 -0
- package/dist/chunk-OMWQVPV7.js +14 -0
- package/dist/chunk-ORG67NXX.js +3 -0
- package/dist/chunk-OSAVAYJZ.js +16 -0
- package/dist/chunk-P7XYIKL6.cjs +300 -0
- package/dist/chunk-PBOZJOKN.js +2 -0
- package/dist/chunk-PITMDQYN.cjs +18 -0
- package/dist/chunk-PL5AIE6F.js +2 -0
- package/dist/chunk-PTWQQMWW.js +270 -0
- package/dist/chunk-QC4YXUBT.cjs +383 -0
- package/dist/chunk-QDHP5E4P.cjs +2 -0
- package/dist/chunk-QVDY6S4B.js +2 -0
- package/dist/chunk-QYI3GOHF.cjs +1 -0
- package/dist/chunk-R3NEPC4I.js +3 -0
- package/dist/chunk-R4LXRAMX.js +2 -0
- package/dist/chunk-S5HTTLN7.cjs +2 -0
- package/dist/chunk-STX5V7HG.cjs +20 -0
- package/dist/chunk-SVYUTQVE.js +115 -0
- package/dist/chunk-SYEP5QLG.js +19 -0
- package/dist/chunk-TR3ZS3T3.js +3 -0
- package/dist/chunk-UB5TJHQR.js +2 -0
- package/dist/chunk-UD6ZPO7T.js +2 -0
- package/dist/chunk-UNYXWPLZ.cjs +2 -0
- package/dist/chunk-VBPAAQEF.js +2 -0
- package/dist/chunk-VIUU4D5I.js +2 -0
- package/dist/chunk-VJ2WMKPK.js +21 -0
- package/dist/chunk-VOQUO2EZ.cjs +74 -0
- package/dist/chunk-VQ53TFYA.cjs +1 -0
- package/dist/chunk-VRZC4TTF.cjs +1 -0
- package/dist/chunk-W46LZ4MY.js +2 -0
- package/dist/chunk-WCFHS7EZ.cjs +1 -0
- package/dist/chunk-WGESLAWV.js +8 -0
- package/dist/chunk-WSP7PSXC.js +8 -0
- package/dist/chunk-X54XZACS.cjs +10 -0
- package/dist/{chunk-Q2UYCYKV.js → chunk-XBH4YMC7.js} +5 -4
- package/dist/chunk-XDE7CFV6.cjs +19 -0
- package/dist/chunk-XOACKBG7.js +4 -0
- package/dist/chunk-XPPVX4GQ.cjs +1 -0
- package/dist/chunk-ZJE3VAAW.js +134 -0
- package/dist/chunk-ZO3YB5DK.cjs +1 -0
- package/dist/chunk-ZOVH6QT5.cjs +1 -0
- package/dist/cli/index.cjs +197 -78
- package/dist/cli/index.js +198 -78
- package/dist/client.cjs +1 -1
- package/dist/client.d.cts +1 -1
- package/dist/client.d.ts +1 -1
- package/dist/client.js +2 -1
- package/dist/d1-5ZQJOFDX.cjs +1 -0
- package/dist/d1-VPH75GI2.js +2 -0
- package/dist/dist-es-3SSNUZST.cjs +1 -0
- package/dist/dist-es-6SVFVYN3.js +1 -0
- package/dist/dist-es-6TQTDPE7.js +2 -0
- package/dist/dist-es-A5OF2STN.cjs +2 -0
- package/dist/dist-es-BOW5V247.cjs +6 -0
- package/dist/dist-es-CRIMATLL.cjs +2 -0
- package/dist/dist-es-DL3VLVP6.cjs +1 -0
- package/dist/dist-es-EMUQ6ZNZ.js +3 -0
- package/dist/dist-es-MNIQZC4U.js +2 -0
- package/dist/dist-es-P25IKLBI.cjs +1 -0
- package/dist/dist-es-SJ76GYCI.js +2 -0
- package/dist/dist-es-SRPWSAF4.cjs +1 -0
- package/dist/dist-es-T2H2W5BX.cjs +3 -0
- package/dist/dist-es-TX4DBXEW.js +3 -0
- package/dist/dist-es-U4ZB3ZDA.js +7 -0
- package/dist/dist-es-XZBHIIKY.js +4 -0
- package/dist/drizzle/index.cjs +1 -1
- package/dist/drizzle/index.d.cts +2 -2
- package/dist/drizzle/index.d.ts +2 -2
- package/dist/drizzle/index.js +1 -1
- package/dist/drizzle-orm-47ELDEM6.cjs +1 -0
- package/dist/drizzle-orm-7YTX5NTT.js +1 -0
- package/dist/event-streams-25YJ2Z6R.js +1 -0
- package/dist/event-streams-JBMWCI2O.cjs +1 -0
- package/dist/fields/index.cjs +1 -1
- package/dist/fields/index.js +1 -1
- package/dist/fs-DGKZLRM6.cjs +1 -0
- package/dist/fs-YZJ5FM6J.js +2 -0
- package/dist/graphql/index.cjs +1 -1
- package/dist/graphql/index.d.cts +2 -2
- package/dist/graphql/index.d.ts +2 -2
- package/dist/graphql/index.js +1 -1
- package/dist/{index-DTz6u7w9.d.cts → index-BJ1rwHxk.d.cts} +1 -1
- package/dist/{index-BeQtbl3z.d.ts → index-BTjlptCL.d.ts} +1 -1
- package/dist/index.cjs +28 -46
- package/dist/index.d.cts +23 -9
- package/dist/index.d.ts +23 -9
- package/dist/index.js +29 -46
- package/dist/integration.cjs +1 -1
- package/dist/integration.js +1 -1
- package/dist/jsonwebtoken-DFB6ZBZA.cjs +8 -0
- package/dist/jsonwebtoken-S7BG2YWK.js +9 -0
- package/dist/lib-5QYYN6ML.cjs +12 -0
- package/dist/lib-IYW32OER.js +13 -0
- package/dist/loadSso-JY4WDQPS.cjs +2 -0
- package/dist/loadSso-YTG2GQGW.js +3 -0
- package/dist/local-VDCSEMC2.js +1 -0
- package/dist/local-YCWBUF3R.cjs +1 -0
- package/dist/media-3Z6YW5J4.cjs +1 -0
- package/dist/media-HK2IZMUZ.js +1 -0
- package/dist/mongo-auth-adapter-7K64Y2QM.cjs +1 -0
- package/dist/mongo-auth-adapter-BUKINEZL.js +1 -0
- package/dist/mongodb/index.cjs +1 -1
- package/dist/mongodb/index.d.cts +2 -2
- package/dist/mongodb/index.d.ts +2 -2
- package/dist/mongodb/index.js +1 -1
- package/dist/nodemailer-AXROO37D.js +54 -0
- package/dist/nodemailer-IDML4L6W.cjs +53 -0
- package/dist/postgres-auth-adapter-2M4RNEY3.cjs +1 -0
- package/dist/postgres-auth-adapter-MKSHIJDL.js +1 -0
- package/dist/postgres-js-3Y54EXVQ.cjs +1 -0
- package/dist/postgres-js-INQPBHJP.js +1 -0
- package/dist/redis-adapter-EGMUN65D.cjs +1 -0
- package/dist/redis-adapter-SXOXLHNH.js +1 -0
- package/dist/rest/index.cjs +1 -1
- package/dist/rest/index.d.cts +5 -5
- package/dist/rest/index.d.ts +5 -5
- package/dist/rest/index.js +1 -1
- package/dist/schema-RT6WSUYC.cjs +1 -0
- package/dist/schema-XC5ISGNR.js +2 -0
- package/dist/signin-KZBIAHGS.js +3 -0
- package/dist/signin-VFBLX7EL.cjs +2 -0
- package/dist/sqlite-adapter-DV7ZX2EJ.js +1 -0
- package/dist/sqlite-adapter-ZTABLT2X.cjs +1 -0
- package/dist/src-6LAUXXDM.cjs +1 -0
- package/dist/src-GZRZ4VAO.js +1 -0
- package/dist/sso-oidc-54BIRYR6.cjs +2 -0
- package/dist/sso-oidc-SX5OIQGG.js +3 -0
- package/dist/sts-HVGDJYIF.js +3 -0
- package/dist/sts-YLXXIB3X.cjs +2 -0
- package/dist/templates/index.cjs +1 -1
- package/dist/templates/index.d.cts +1 -1
- package/dist/templates/index.d.ts +1 -1
- package/dist/templates/index.js +1 -1
- package/dist/trpc/index.cjs +1 -1
- package/dist/trpc/index.d.cts +7 -7
- package/dist/trpc/index.d.ts +7 -7
- package/dist/trpc/index.js +1 -1
- package/dist/{types-CaXXmV9h.d.ts → types-CYGXsNcJ.d.ts} +5 -5
- package/dist/{types-BjivdGbU.d.cts → types-DOKMyC3y.d.cts} +5 -5
- package/dist/ws/index.cjs +1 -1
- package/dist/ws/index.js +1 -1
- package/package.json +2 -2
- package/dist/bootstrap-ROSTPMVL.js +0 -1
- package/dist/bootstrap-WW5NJ6EB.cjs +0 -1
- package/dist/chunk-3CVLI5C5.cjs +0 -3
- package/dist/chunk-3Q2WUG63.cjs +0 -2
- package/dist/chunk-3RSMK4DA.cjs +0 -2
- package/dist/chunk-4IGWJMBY.cjs +0 -2
- package/dist/chunk-4ORJMSJU.cjs +0 -1
- package/dist/chunk-4RMFCTWH.js +0 -1
- package/dist/chunk-5B6X2GBJ.js +0 -2
- package/dist/chunk-5J6HXUF6.js +0 -1
- package/dist/chunk-5KOQYQEE.js +0 -1
- package/dist/chunk-5SEHX7ON.js +0 -1
- package/dist/chunk-6ROHVUXF.js +0 -1
- package/dist/chunk-6SPPR5JZ.js +0 -3
- package/dist/chunk-7IVN6TTY.js +0 -133
- package/dist/chunk-AHSFSERC.cjs +0 -1
- package/dist/chunk-B5XWYVWK.js +0 -1
- package/dist/chunk-BGX27ZRG.cjs +0 -300
- package/dist/chunk-C2W5PSHC.js +0 -300
- package/dist/chunk-CCUQZ66T.cjs +0 -133
- package/dist/chunk-D5P2IPGX.cjs +0 -3
- package/dist/chunk-EPMGPNBE.js +0 -1
- package/dist/chunk-FHJJKFAU.cjs +0 -1
- package/dist/chunk-FVZ5RFLO.js +0 -2
- package/dist/chunk-FZ6Q2EBJ.cjs +0 -20
- package/dist/chunk-G3J2EU5D.cjs +0 -1
- package/dist/chunk-G7SSHELM.cjs +0 -1
- package/dist/chunk-GKYEJ2UF.js +0 -1
- package/dist/chunk-GO34AOBZ.cjs +0 -1
- package/dist/chunk-GYQMNXXW.cjs +0 -114
- package/dist/chunk-HLSB2MCK.js +0 -1
- package/dist/chunk-HQP2Y7QQ.js +0 -251
- package/dist/chunk-HS2KNFAB.cjs +0 -2
- package/dist/chunk-HVXO3OFB.cjs +0 -1
- package/dist/chunk-IETGL7WJ.js +0 -1
- package/dist/chunk-IFJ73O3A.cjs +0 -1
- package/dist/chunk-ILEZ3NYX.cjs +0 -2
- package/dist/chunk-INB4LNA6.js +0 -90
- package/dist/chunk-K6WUOU6P.js +0 -1
- package/dist/chunk-KD7LUCFY.cjs +0 -1
- package/dist/chunk-KDNYHLD2.js +0 -1
- package/dist/chunk-LHW4R367.js +0 -1
- package/dist/chunk-MIOMMB23.cjs +0 -1
- package/dist/chunk-N5VNHUJS.cjs +0 -4
- package/dist/chunk-NRLIGDYF.js +0 -1
- package/dist/chunk-NY47CFVP.cjs +0 -1
- package/dist/chunk-NZJAGASC.cjs +0 -251
- package/dist/chunk-OG7CNQGU.js +0 -1
- package/dist/chunk-PP5S2UBV.js +0 -0
- package/dist/chunk-PP7W5UKL.js +0 -2
- package/dist/chunk-Q3Q7BJVQ.cjs +0 -1
- package/dist/chunk-QCA3AP3M.cjs +0 -1
- package/dist/chunk-QOCHBPMK.js +0 -2
- package/dist/chunk-QYFU5Y7S.js +0 -3
- package/dist/chunk-RHCWCG3O.js +0 -114
- package/dist/chunk-SK2Q4PRV.cjs +0 -90
- package/dist/chunk-TFBHE5FF.cjs +0 -1
- package/dist/chunk-UBRYJP2G.js +0 -1
- package/dist/chunk-V65NPSR5.cjs +0 -1
- package/dist/chunk-VGQ4VUG6.js +0 -2
- package/dist/chunk-W7C6SJXZ.js +0 -20
- package/dist/chunk-WIZ6C5QZ.cjs +0 -1
- package/dist/chunk-ZIWJJRWQ.js +0 -4
- package/dist/chunk-ZUVP4UK7.cjs +0 -1
- package/dist/media-L5XDD47D.js +0 -1
- package/dist/media-OUBQTIQP.cjs +0 -1
- package/dist/mongo-auth-adapter-5TJO5J5U.js +0 -1
- package/dist/mongo-auth-adapter-JVE5M3S4.cjs +0 -1
- package/dist/postgres-auth-adapter-33QOIRXT.js +0 -1
- package/dist/postgres-auth-adapter-JKDYYULH.cjs +0 -1
- package/dist/redis-adapter-NN3H4GRX.js +0 -1
- package/dist/redis-adapter-OUKQGYCH.cjs +0 -1
- package/dist/schema-HIUSHSUI.cjs +0 -1
- package/dist/schema-KFYUM674.js +0 -1
- package/dist/sqlite-adapter-GTTVSXRV.cjs +0 -1
- package/dist/sqlite-adapter-UPANATIW.js +0 -1
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
'use strict';var chunkBUNLC3II_cjs=require('./chunk-BUNLC3II.cjs'),mn=require('os'),dn=require('fs'),Qt=require('net'),xr=require('tls'),ze=require('crypto'),ht=require('stream'),perf_hooks=require('perf_hooks');function _interopDefault(e){return e&&e.__esModule?e:{default:e}}var mn__default=/*#__PURE__*/_interopDefault(mn);var dn__default=/*#__PURE__*/_interopDefault(dn);var Qt__default=/*#__PURE__*/_interopDefault(Qt);var xr__default=/*#__PURE__*/_interopDefault(xr);var ze__default=/*#__PURE__*/_interopDefault(ze);var ht__default=/*#__PURE__*/_interopDefault(ht);chunkBUNLC3II_cjs.h();chunkBUNLC3II_cjs.h();chunkBUNLC3II_cjs.h();var Qe=new Map,nt=new Map,st=Symbol("OriginError"),Ce={},re=class extends Promise{constructor(r,n,a,i,u={}){let o,c;super((d,j)=>{o=d,c=j;}),this.tagged=Array.isArray(r.raw),this.strings=r,this.args=n,this.handler=a,this.canceller=i,this.options=u,this.state=null,this.statement=null,this.resolve=d=>(this.active=false,o(d)),this.reject=d=>(this.active=false,c(d)),this.active=false,this.cancelled=null,this.executed=false,this.signature="",this[st]=this.handler.debug?new Error:this.tagged&&Gr(this.strings);}get origin(){return (this.handler.debug?this[st].stack:this.tagged&&nt.has(this.strings)?nt.get(this.strings):nt.set(this.strings,this[st].stack).get(this.strings))||""}static get[Symbol.species](){return Promise}cancel(){return this.canceller&&(this.canceller(this),this.canceller=null)}simple(){return this.options.simple=true,this.options.prepare=false,this}async readable(){return this.simple(),this.streaming=true,this}async writable(){return this.simple(),this.streaming=true,this}cursor(r=1,n){if(this.options.simple=false,typeof r=="function"&&(n=r,r=1),this.cursorRows=r,typeof n=="function")return this.cursorFn=n,this;let a;return {[Symbol.asyncIterator]:()=>({next:()=>{if(this.executed&&!this.active)return {done:true};a&&a();let i=new Promise((u,o)=>{this.cursorFn=c=>(u({value:c,done:false}),new Promise(d=>a=d)),this.resolve=()=>(this.active=false,u({done:true})),this.reject=c=>(this.active=false,o(c));});return this.execute(),i},return(){return a&&a(Ce),{done:true}}})}}describe(){return this.options.simple=false,this.onlyDescribe=this.options.prepare=true,this}stream(){throw new Error(".stream has been renamed to .forEach")}forEach(r){return this.forEachFn=r,this.handle(),this}raw(){return this.isRaw=true,this}values(){return this.isRaw="values",this}async handle(){!this.executed&&(this.executed=true)&&await 1&&this.handler(this);}execute(){return this.handle(),this}then(){return this.handle(),super.then.apply(this,arguments)}catch(){return this.handle(),super.catch.apply(this,arguments)}finally(){return this.handle(),super.finally.apply(this,arguments)}};function Gr(e){if(Qe.has(e))return Qe.get(e);let r=Error.stackTraceLimit;return Error.stackTraceLimit=4,Qe.set(e,new Error),Error.stackTraceLimit=r,Qe.get(e)}chunkBUNLC3II_cjs.h();var Ee=class extends Error{constructor(r){super(r.message),this.name=this.constructor.name,Object.assign(this,r);}},z={connection:It,postgres:Nt,generic:Ut,notSupported:jt};function It(e,r,n){let{host:a,port:i}=n||r,u=Object.assign(new Error("write "+e+" "+(r.path||a+":"+i)),{code:e,errno:e,address:r.path||a},r.path?{}:{port:i});return Error.captureStackTrace(u,It),u}function Nt(e){let r=new Ee(e);return Error.captureStackTrace(r,Nt),r}function Ut(e,r){let n=Object.assign(new Error(e+": "+r),{code:e});return Error.captureStackTrace(n,Ut),n}function jt(e){let r=Object.assign(new Error(e+" (B) is not supported"),{code:"MESSAGE_NOT_SUPPORTED",name:e});return Error.captureStackTrace(r,jt),r}var Qr={string:{to:25,from:null,serialize:e=>""+e},number:{to:0,from:[21,23,26,700,701],serialize:e=>""+e,parse:e=>+e},json:{to:114,from:[114,3802],serialize:e=>JSON.stringify(e),parse:e=>JSON.parse(e)},boolean:{to:16,from:16,serialize:e=>e===true?"t":"f",parse:e=>e==="t"},date:{to:1184,from:[1082,1114,1184],serialize:e=>(e instanceof Date?e:new Date(e)).toISOString(),parse:e=>new Date(e)},bytea:{to:17,from:17,serialize:e=>"\\x"+Buffer.from(e).toString("hex"),parse:e=>Buffer.from(e.slice(2),"hex")}},De=class{then(){at();}catch(){at();}finally(){at();}},Te=class extends De{constructor(r){super(),this.value=Ye(r);}},ie=class extends De{constructor(r,n,a){super(),this.value=r,this.type=n,this.array=a;}},ke=class extends De{constructor(r,n){super(),this.first=r,this.rest=n;}build(r,n,a,i){let u=Hr.map(([o,c])=>({fn:c,i:r.search(o)})).sort((o,c)=>o.i-c.i).pop();return u.i===-1?ut(this.first,i):u.fn(this.first,this.rest,n,a,i)}};function Ve(e,r,n,a){let i=e instanceof ie?e.value:e;if(i===void 0&&(e instanceof ie?e.value=a.transform.undefined:i=e=a.transform.undefined,i===void 0))throw z.generic("UNDEFINED_VALUE","Undefined values are not allowed");return "$"+n.push(e instanceof ie?(r.push(e.value),e.array?e.array[e.type||Ke(e.value)]||e.type||Ft(e.value):e.type):(r.push(e),Ke(e)))}var Dt=Mt(Qr);function ct(e,r,n,a,i,u){for(let o=1;o<e.strings.length;o++)r+=lt(r,n,a,i,u)+e.strings[o],n=e.args[o];return r}function lt(e,r,n,a,i){return r instanceof ke?r.build(e,n,a,i):r instanceof re?it(r,n,a,i):r instanceof Te?r.value:r&&r[0]instanceof re?r.reduce((u,o)=>u+" "+it(o,n,a,i),""):Ve(r,n,a,i)}function it(e,r,n,a){return e.fragment=true,ct(e,e.strings[0],e.args[0],r,n,a)}function kt(e,r,n,a,i){return e.map(u=>"("+a.map(o=>lt("values",u[o],r,n,i)).join(",")+")").join(",")}function Rt(e,r,n,a,i){let u=Array.isArray(e[0]),o=r.length?r.flat():Object.keys(u?e[0]:e);return kt(u?e:[e],n,a,o,i)}function He(e,r,n,a,i){if(typeof e=="string"&&(e=[e].concat(r)),Array.isArray(e))return ut(e,i);let u;return (r.length?r.flat():Object.keys(e)).map(c=>(u=e[c],(u instanceof re?it(u,n,a,i):u instanceof Te?u.value:Ve(u,n,a,i))+" as "+Ye(i.transform.column.to?i.transform.column.to(c):c))).join(",")}var Hr=Object.entries({values:Rt,in:(...e)=>{let r=Rt(...e);return r==="()"?"(null)":r},select:He,as:He,returning:He,"\\(":He,update(e,r,n,a,i){return (r.length?r.flat():Object.keys(e)).map(u=>Ye(i.transform.column.to?i.transform.column.to(u):u)+"="+lt("values",e[u],n,a,i))},insert(e,r,n,a,i){let u=r.length?r.flat():Object.keys(Array.isArray(e)?e[0]:e);return "("+ut(u,i)+")values"+kt(Array.isArray(e)?e:[e],n,a,u,i)}}).map(([e,r])=>[new RegExp("((?:^|[\\s(])"+e+"(?:$|[\\s(]))(?![\\s\\S]*\\1)","i"),r]);function at(){throw z.generic("NOT_TAGGED_CALL","Query not called as a tagged template literal")}var Kr=Dt.serializers,Vr=Dt.parsers;function Ft(e){return Array.isArray(e)?Ft(e[0]):typeof e=="string"?1009:0}var Lt=function(e){let r=Mt(e||{});return {serializers:Object.assign({},Kr,r.serializers),parsers:Object.assign({},Vr,r.parsers)}};function Mt(e){return Object.keys(e).reduce((r,n)=>(e[n].from&&[].concat(e[n].from).forEach(a=>r.parsers[a]=e[n].parse),e[n].serialize&&(r.serializers[e[n].to]=e[n].serialize,e[n].from&&[].concat(e[n].from).forEach(a=>r.serializers[a]=e[n].serialize)),r),{parsers:{},serializers:{}})}function ut(e,{transform:{column:r}}){return e.map(n=>Ye(r.to?r.to(n):n)).join(",")}var Ye=function(r){return '"'+r.replace(/"/g,'""').replace(/\./g,'"."')+'"'},Ke=function e(r){return r instanceof ie?r.type:r instanceof Date?1184:r instanceof Uint8Array?17:r===true||r===false?16:typeof r=="bigint"?20:Array.isArray(r)?e(r[0]):0},Yr=/\\/g,Wr=/"/g;function Xr(e){return e.replace(Yr,"\\\\").replace(Wr,'\\"')}var zt=function e(r,n,a,i){if(Array.isArray(r)===false)return r;if(!r.length)return "{}";let u=r[0],o=i===1020?";":",";return Array.isArray(u)&&!u.type?"{"+r.map(c=>e(c,n,a,i)).join(o)+"}":"{"+r.map(c=>{if(c===void 0&&(c=a.transform.undefined,c===void 0))throw z.generic("UNDEFINED_VALUE","Undefined values are not allowed");return c===null?"null":'"'+Xr(n?n(c.type?c.value:c):""+c)+'"'}).join(o)+"}"},ot={i:0,char:null,str:"",quoted:false,last:0},$t=function(r,n,a){return ot.i=ot.last=0,Gt(ot,r,n,a)};function Gt(e,r,n,a){let i=[],u=a===1020?";":",";for(;e.i<r.length;e.i++){if(e.char=r[e.i],e.quoted)e.char==="\\"?e.str+=r[++e.i]:e.char==='"'?(i.push(n?n(e.str):e.str),e.str="",e.quoted=r[e.i+1]==='"',e.last=e.i+2):e.str+=e.char;else if(e.char==='"')e.quoted=true;else if(e.char==="{")e.last=++e.i,i.push(Gt(e,r,n,a));else if(e.char==="}"){e.quoted=false,e.last<e.i&&i.push(n?n(r.slice(e.last,e.i)):r.slice(e.last,e.i)),e.last=e.i+1;break}else e.char===u&&e.p!=="}"&&e.p!=='"'&&(i.push(n?n(r.slice(e.last,e.i)):r.slice(e.last,e.i)),e.last=e.i+1);e.p=e.char;}return e.last<e.i&&i.push(n?n(r.slice(e.last,e.i+1)):r.slice(e.last,e.i+1)),i}var _e=e=>{let r=e[0];for(let n=1;n<e.length;n++)r+=e[n]==="_"?e[++n].toUpperCase():e[n];return r},Se=e=>{let r=e[0].toUpperCase();for(let n=1;n<e.length;n++)r+=e[n]==="_"?e[++n].toUpperCase():e[n];return r},ve=e=>e.replace(/_/g,"-"),Fe=e=>e.replace(/([A-Z])/g,"_$1").toLowerCase(),Le=e=>(e.slice(0,1)+e.slice(1).replace(/([A-Z])/g,"_$1")).toLowerCase(),Me=e=>e.replace(/-/g,"_");function ft(e){return function r(n,a){return typeof n=="object"&&n!==null&&(a.type===114||a.type===3802)?Array.isArray(n)?n.map(i=>r(i,a)):Object.entries(n).reduce((i,[u,o])=>Object.assign(i,{[e(u)]:r(o,a)}),{}):n}}_e.column={from:_e};_e.value={from:ft(_e)};Fe.column={to:Fe};var mt={..._e};mt.column.to=Fe;Se.column={from:Se};Se.value={from:ft(Se)};Le.column={to:Le};var dt={...Se};dt.column.to=Le;ve.column={from:ve};ve.value={from:ft(ve)};Me.column={to:Me};var pt={...ve};pt.column.to=Me;chunkBUNLC3II_cjs.h();chunkBUNLC3II_cjs.h();var ye=class extends Array{constructor(){super(),Object.defineProperties(this,{count:{value:null,writable:true},state:{value:null,writable:true},command:{value:null,writable:true},columns:{value:null,writable:true},statement:{value:null,writable:true}});}static get[Symbol.species](){return Array}};chunkBUNLC3II_cjs.h();var ne=Jr;function Jr(e=[]){let r=e.slice(),n=0;return {get length(){return r.length-n},remove:a=>{let i=r.indexOf(a);return i===-1?null:(r.splice(i,1),a)},push:a=>(r.push(a),a),shift:()=>{let a=r[n++];return n===r.length?(n=0,r=[]):r[n-1]=void 0,a}}}chunkBUNLC3II_cjs.h();var X=Buffer.allocUnsafe(256),Zr="BCcDdEFfHPpQSX".split("").reduce((e,r)=>{let n=r.charCodeAt(0);return e[r]=()=>(X[0]=n,B.i=5,B),e},{}),B=Object.assign(qr,Zr,{N:"\0",i:0,inc(e){return B.i+=e,B},str(e){let r=Buffer.byteLength(e);return We(r),B.i+=X.write(e,B.i,r,"utf8"),B},i16(e){return We(2),X.writeUInt16BE(e,B.i),B.i+=2,B},i32(e,r){return r||r===0?(X.writeUInt32BE(e,r),B):(We(4),X.writeUInt32BE(e,B.i),B.i+=4,B)},z(e){return We(e),X.fill(0,B.i,B.i+e),B.i+=e,B},raw(e){return X=Buffer.concat([X.subarray(0,B.i),e]),B.i=X.length,B},end(e=1){X.writeUInt32BE(B.i-e,e);let r=X.subarray(0,B.i);return B.i=0,X=Buffer.allocUnsafe(256),r}}),p=B;function We(e){if(X.length-B.i<e){let r=X,n=r.length;X=Buffer.allocUnsafe(n+(n>>1)+e),r.copy(X);}}function qr(){return B.i=0,B}var yt=Yt,en=1,we=p().S().end(),Kt=p().H().end(),tn=p().i32(8).i32(80877103).end(8),rn=Buffer.concat([p().E().str(p.N).i32(0).end(),we]),nn=p().D().str("S").str(p.N).end(),Ie=()=>{},sn=new Set(["FetchPreparedStatement","RevalidateCachedQuery","transformAssignedExpr"]),an={83:"severity_local",86:"severity",67:"code",77:"message",68:"detail",72:"hint",80:"position",112:"internal_position",113:"internal_query",87:"where",115:"schema_name",116:"table_name",99:"column_name",100:"data type_name",110:"constraint_name",70:"file",76:"line",82:"routine"};function Yt(e,r={},{onopen:n=Ie,onend:a=Ie,onclose:i=Ie}={}){let{sslnegotiation:u,ssl:o,max:c,user:d,host:j,port:C,database:P,parsers:b,transform:E,onnotice:R,onnotify:g,onparameter:H,max_pipeline:N,keep_alive:oe,backoff:se,target_session_attrs:ee}=e,S=ne(),pe=en++,le={pid:null,secret:null},Ae=gt(tt,e.idle_timeout),be=gt(tt,e.max_lifetime),v=gt(tr,e.connect_timeout),m=null,ue,x=null,A=new ye,J=Buffer.alloc(0),Oe=e.fetch_types,fe={},l={},y=Math.random().toString(36).slice(2),U=1,$=0,L=0,w=0,O=0,k=0,F=0,G=0,Z=null,T=null,me=false,ce=null,he=null,V=null,D=null,I=null,te=null,$e=null,xe=null,f=null,Ne=null,Y={queue:r.closed,idleTimer:Ae,connect(t){V=t,Ot();},terminate:Re,execute:Ue,cancel:Zt,end:tt,count:0,id:pe};return r.closed&&r.closed.push(Y),Y;async function Jt(){let t;try{t=e.socket?await Promise.resolve(e.socket(e)):new Qt__default.default.Socket;}catch(s){Be(s);return}return t.on("error",Be),t.on("close",Pt),t.on("drain",vt),t}async function Zt({pid:t,secret:s},h,_){try{ue=p().i32(16).i32(80877102).i32(t).i32(s).end(16),await At(),m.once("error",_),m.once("close",h);}catch(M){_(M);}}function Ue(t){if(me)return je(t,z.connection("CONNECTION_DESTROYED",e));if(I)return je(t,z.generic("COPY_IN_PROGRESS","You cannot execute queries during copy"));if(!t.cancelled)try{return t.state=le,f?S.push(t):(f=t,f.active=!0),er(t),K(qt(t))&&!t.describeFirst&&!t.cursorFn&&S.length<N&&(!t.options.onexecute||t.options.onexecute(Y))}catch(s){return S.length===0&&K(we),ae(s),true}}function qt(t){if(t.parameters.length>=65534)throw z.generic("MAX_PARAMETERS_EXCEEDED","Max number of parameters (65534) exceeded");return t.options.simple?p().Q().str(t.statement.string+p.N).end():t.describeFirst?Buffer.concat([Et(t),Kt]):t.prepare?t.prepared?Ge(t):Buffer.concat([Et(t),Ge(t)]):xt(t)}function Et(t){return Buffer.concat([Ct(t.statement.string,t.parameters,t.statement.types,t.statement.name),Mr("S",t.statement.name)])}function Ge(t){return Buffer.concat([Lr(t.parameters,t.statement.types,t.statement.name,t.cursorName),t.cursorFn?Tt("",t.cursorRows):rn])}function xt(t){return Buffer.concat([Ct(t.statement.string,t.parameters,t.statement.types),nn,Ge(t)])}function er(t){let s=[],h=[],_=ct(t,t.strings[0],t.args[0],s,h,e);!t.tagged&&t.args.forEach(M=>Ve(M,s,h,e)),t.prepare=e.prepare&&("prepare"in t.options?t.options.prepare:true),t.string=_,t.signature=t.prepare&&h+_,t.onlyDescribe&&delete l[t.signature],t.parameters=t.parameters||s,t.prepared=t.prepare&&t.signature in l,t.describeFirst=t.onlyDescribe||s.length&&!t.prepared,t.statement=t.prepared?l[t.signature]:{string:_,types:h,name:t.prepare?y+U++:""},typeof e.debug=="function"&&e.debug(pe,_,s,h);}function K(t,s){return te=te?Buffer.concat([te,t]):Buffer.from(t),s||te.length>=1024?_t(s):(T===null&&(T=setImmediate(_t)),true)}function _t(t){let s=m.write(te,t);return T!==null&&clearImmediate(T),te=T=null,s}function tr(){ae(z.connection("CONNECT_TIMEOUT",e,m)),m.destroy();}async function St(){if(u!=="direct"&&(K(tn),!await new Promise(h=>m.once("data",_=>h(_[0]===83)))&&o==="prefer"))return Pe();let t={socket:m,servername:Qt__default.default.isIP(m.host)?void 0:m.host};u==="direct"&&(t.ALPNProtocols=["postgresql"]),o==="require"||o==="allow"||o==="prefer"?t.rejectUnauthorized=false:typeof o=="object"&&Object.assign(t,o),m.removeAllListeners(),m=xr__default.default.connect(t),m.on("secureConnect",Pe),m.on("error",Be),m.on("close",Pt),m.on("drain",vt);}function vt(){!f&&n(Y);}function et(t){if(!(ce&&(ce.push(t),L-=t.length,L>0)))for(J=ce?Buffer.concat(ce,k-L):J.length===0?t:Buffer.concat([J,t],J.length+t.length);J.length>4;){if(k=J.readUInt32BE(1),k>=J.length){L=k-J.length,ce=[J];break}try{rr(J.subarray(0,k+1));}catch(s){f&&(f.cursorFn||f.describeFirst)&&K(we),ae(s);}J=J.subarray(k+1),L=0,ce=null;}}async function At(){if(me=false,fe={},m||(m=await Jt()),!!m){if(v.start(),e.socket)return o?St():Pe();if(m.on("connect",o?St:Pe),e.path)return m.connect(e.path);m.ssl=o,m.connect(C[w],j[w]),m.host=j[w],m.port=C[w],w=(w+1)%C.length;}}function Ot(){setTimeout(At,$?Math.max(0,$+F-perf_hooks.performance.now()):0);}function Pe(){try{l={},Oe=e.fetch_types,y=Math.random().toString(36).slice(2),U=1,be.start(),m.on("data",et),oe&&m.setKeepAlive&&m.setKeepAlive(!0,1e3*oe);let t=$r();K(t);}catch(t){Be(t);}}function Be(t){if(!(Y.queue===r.connecting&&e.host[O+1]))for(ae(t);S.length;)je(S.shift(),t);}function ae(t){I&&(I.destroy(t),I=null),f&&je(f,t),V&&(je(V,t),V=null);}function je(t,s){if(t.reserve)return t.reject(s);(!s||typeof s!="object")&&(s=new Error(s)),"query"in s||"parameters"in s||Object.defineProperties(s,{stack:{value:s.stack+t.origin.replace(/.*\n/,`
|
|
2
|
+
`),enumerable:e.debug},query:{value:t.string,enumerable:e.debug},parameters:{value:t.parameters,enumerable:e.debug},args:{value:t.args,enumerable:e.debug},types:{value:t.statement&&t.statement.types,enumerable:e.debug}}),t.reject(s);}function tt(){return D||(!Y.reserved&&a(Y),!Y.reserved&&!V&&!f&&S.length===0?(Re(),new Promise(t=>m&&m.readyState!=="closed"?m.once("close",t):t())):D=new Promise(t=>$e=t))}function Re(){me=true,(I||f||V||S.length)&&Be(z.connection("CONNECTION_DESTROYED",e)),clearImmediate(T),m&&(m.removeListener("data",et),m.removeListener("connect",Pe),m.readyState==="open"&&m.end(p().X().end())),$e&&($e(),D=$e=null);}async function Pt(t){if(J=Buffer.alloc(0),L=0,ce=null,clearImmediate(T),m.removeListener("data",et),m.removeListener("connect",Pe),Ae.cancel(),be.cancel(),v.cancel(),m.removeAllListeners(),m=null,V)return Ot();!t&&(f||S.length)&&Be(z.connection("CONNECTION_CLOSED",e,m)),$=perf_hooks.performance.now(),t&&e.shared.retries++,F=(typeof se=="function"?se(e.shared.retries):se)*1e3,i(Y,z.connection("CONNECTION_CLOSED",e,m));}function rr(t,s=t[0]){(s===68?nr:s===100?Ir:s===65?Ar:s===83?sr:s===90?ar:s===67?or:s===50?Bt:s===49?ir:s===116?cr:s===84?lr:s===82?ur:s===110?gr:s===75?yr:s===69?Sr:s===115?Or:s===51?Pr:s===71?Br:s===78?Ur:s===72?Cr:s===99?Nr:s===73?jr:s===86?Rr:s===118?Dr:s===87?Tr:kr)(t);}function nr(t){let s=7,h,_,M,W=f.isRaw?new Array(f.statement.columns.length):{};for(let q=0;q<f.statement.columns.length;q++)_=f.statement.columns[q],h=t.readInt32BE(s),s+=4,M=h===-1?null:f.isRaw===true?t.subarray(s,s+=h):_.parser===void 0?t.toString("utf8",s,s+=h):_.parser.array===true?_.parser(t.toString("utf8",s+1,s+=h)):_.parser(t.toString("utf8",s,s+=h)),f.isRaw?W[q]=f.isRaw===true?M:E.value.from?E.value.from(M,_):M:W[_.name]=E.value.from?E.value.from(M,_):M;f.forEachFn?f.forEachFn(E.row.from?E.row.from(W):W,A):A[G++]=E.row.from?E.row.from(W):W;}function sr(t){let[s,h]=t.toString("utf8",5,t.length-1).split(p.N);fe[s]=h,e.parameters[s]!==h&&(e.parameters[s]=h,H&&H(s,h));}function ar(t){if(f?x?f.retried?ae(f.retried):f.prepared&&sn.has(x.routine)?vr(f,x):ae(x):f.resolve(he||A):x&&ae(x),f=he=x=null,A=new ye,v.cancel(),V){if(ee){if(!fe.in_hot_standby||!fe.default_transaction_read_only)return _r();if(Er(ee,fe))return Re()}if(Oe)return V.reserve&&(V=null),wr();V&&!V.reserve&&Ue(V),e.shared.retries=O=0,V=null;return}for(;S.length&&(f=S.shift())&&(f.active=true,f.cancelled);)Yt(e).cancel(f.state,f.cancelled.resolve,f.cancelled.reject);f||(Y.reserved?!Y.reserved.release&&t[5]===73?D?Re():(Y.reserved=null,n(Y)):Y.reserved():D?Re():n(Y));}function or(t){G=0;for(let s=t.length-1;s>0;s--)if(t[s]===32&&t[s+1]<58&&A.count===null&&(A.count=+t.toString("utf8",s+1,t.length-1)),t[s-1]>=65){A.command=t.toString("utf8",5,s),A.state=le;break}if(Ne&&(Ne(),Ne=null),A.command==="BEGIN"&&c!==1&&!Y.reserved)return ae(z.generic("UNSAFE_TRANSACTION","Only use sql.begin, sql.reserved or max: 1"));if(f.options.simple)return Bt();f.cursorFn&&(A.count&&f.cursorFn(A),K(we));}function ir(){f.parsing=false;}function Bt(){!A.statement&&(A.statement=f.statement),A.columns=f.statement.columns;}function cr(t){let s=t.readUInt16BE(5);for(let h=0;h<s;++h)!f.statement.types[h]&&(f.statement.types[h]=t.readUInt32BE(7+h*4));f.prepare&&(l[f.signature]=f.statement),f.describeFirst&&!f.onlyDescribe&&(K(Ge(f)),f.describeFirst=false);}function lr(t){A.command&&(he=he||[A],he.push(A=new ye),A.count=null,f.statement.columns=null);let s=t.readUInt16BE(5),h=7,_;f.statement.columns=Array(s);for(let M=0;M<s;++M){for(_=h;t[h++]!==0;);let W=t.readUInt32BE(h),q=t.readUInt16BE(h+4),ge=t.readUInt32BE(h+6);f.statement.columns[M]={name:E.column.from?E.column.from(t.toString("utf8",_,h-1)):t.toString("utf8",_,h-1),parser:b[ge],table:W,number:q,type:ge},h+=18;}if(A.statement=f.statement,f.onlyDescribe)return f.resolve(f.statement),K(we)}async function ur(t,s=t.readUInt32BE(5)){(s===3?fr:s===5?mr:s===10?dr:s===11?pr:s===12?hr:s!==0?Fr:Ie)(t,s);}async function fr(){let t=await rt();K(p().p().str(t).z(1).end());}async function mr(t){let s="md5"+await Vt(Buffer.concat([Buffer.from(await Vt(await rt()+d)),t.subarray(9)]));K(p().p().str(s).z(1).end());}async function dr(){xe=(await ze__default.default.randomBytes(18)).toString("base64"),p().p().str("SCRAM-SHA-256"+p.N);let t=p.i;K(p.inc(4).str("n,,n=*,r="+xe).i32(p.i-t-4,t).end());}async function pr(t){let s=t.toString("utf8",9).split(",").reduce((q,ge)=>(q[ge[0]]=ge.slice(2),q),{}),h=await ze__default.default.pbkdf2Sync(await rt(),Buffer.from(s.s,"base64"),parseInt(s.i),32,"sha256"),_=await Je(h,"Client Key"),M="n=*,r="+xe+",r="+s.r+",s="+s.s+",i="+s.i+",c=biws,r="+s.r;Z=(await Je(await Je(h,"Server Key"),M)).toString("base64");let W="c=biws,r="+s.r+",p="+cn(_,Buffer.from(await Je(await on(_),M))).toString("base64");K(p().p().str(W).end());}function hr(t){t.toString("utf8",9).split(p.N,1)[0].slice(2)!==Z&&(ae(z.generic("SASL_SIGNATURE_MISMATCH","The server did not return the correct signature")),m.destroy());}function rt(){return Promise.resolve(typeof e.pass=="function"?e.pass():e.pass)}function gr(){if(A.statement=f.statement,A.statement.columns=[],f.onlyDescribe)return f.resolve(f.statement),K(we)}function yr(t){le.pid=t.readUInt32BE(5),le.secret=t.readUInt32BE(9);}async function wr(){Oe=false,(await new re([`
|
|
3
|
+
select b.oid, b.typarray
|
|
4
|
+
from pg_catalog.pg_type a
|
|
5
|
+
left join pg_catalog.pg_type b on b.oid = a.typelem
|
|
6
|
+
where a.typcategory = 'A'
|
|
7
|
+
group by b.oid, b.typarray
|
|
8
|
+
order by b.oid
|
|
9
|
+
`],[],Ue)).forEach(({oid:s,typarray:h})=>br(s,h));}function br(t,s){if(e.parsers[s]&&e.serializers[s])return;let h=e.parsers[t];e.shared.typeArrayMap[t]=s,e.parsers[s]=_=>$t(_,h,s),e.parsers[s].array=true,e.serializers[s]=_=>zt(_,e.serializers[t],e,s);}function Er(t,s){return t==="read-write"&&s.default_transaction_read_only==="on"||t==="read-only"&&s.default_transaction_read_only==="off"||t==="primary"&&s.in_hot_standby==="on"||t==="standby"&&s.in_hot_standby==="off"||t==="prefer-standby"&&s.in_hot_standby==="off"&&e.host[O]}function _r(){let t=new re([`
|
|
10
|
+
show transaction_read_only;
|
|
11
|
+
select pg_catalog.pg_is_in_recovery()
|
|
12
|
+
`],[],Ue,null,{simple:true});t.resolve=([[s],[h]])=>{fe.default_transaction_read_only=s.transaction_read_only,fe.in_hot_standby=h.pg_is_in_recovery?"on":"off";},t.execute();}function Sr(t){f?((f.cursorFn||f.describeFirst)&&K(we),x=z.postgres(Xe(t))):ae(z.postgres(Xe(t)));}function vr(t,s){delete l[t.signature],t.retried=s,Ue(t);}function Ar(t){if(!g)return;let s=9;for(;t[s++]!==0;);g(t.toString("utf8",9,s-1),t.toString("utf8",s,t.length-1));}async function Or(){try{let t=await Promise.resolve(f.cursorFn(A));G=0,t===Ce?K(zr(f.portal)):(A=new ye,K(Tt("",f.cursorRows)));}catch(t){K(we),f.reject(t);}}function Pr(){A.count&&f.cursorFn(A),f.resolve(A);}function Br(){I=new ht__default.default.Writable({autoDestroy:true,write(t,s,h){m.write(p().d().raw(t).end(),h);},destroy(t,s){s(t),m.write(p().f().str(t+p.N).end()),I=null;},final(t){m.write(p().c().end()),Ne=t,I=null;}}),f.resolve(I);}function Cr(){I=new ht__default.default.Readable({read(){m.resume();}}),f.resolve(I);}function Tr(){I=new ht__default.default.Duplex({autoDestroy:true,read(){m.resume();},write(t,s,h){m.write(p().d().raw(t).end(),h);},destroy(t,s){s(t),m.write(p().f().str(t+p.N).end()),I=null;},final(t){m.write(p().c().end()),Ne=t;}}),f.resolve(I);}function Ir(t){I&&(I.push(t.subarray(5))||m.pause());}function Nr(){I&&I.push(null),I=null;}function Ur(t){R?R(Xe(t)):console.log(Xe(t));}function jr(){}function Rr(){ae(z.notSupported("FunctionCallResponse"));}function Dr(){ae(z.notSupported("NegotiateProtocolVersion"));}function kr(t){console.error("Postgres.js : Unknown Message:",t[0]);}function Fr(t,s){console.error("Postgres.js : Unknown Auth:",s);}function Lr(t,s,h="",_=""){let M,W;return p().B().str(_+p.N).str(h+p.N).i16(0).i16(t.length),t.forEach((q,ge)=>{if(q===null)return p.i32(4294967295);W=s[ge],t[ge]=q=W in e.serializers?e.serializers[W](q):""+q,M=p.i,p.inc(4).str(q).i32(p.i-M-4,M);}),p.i16(0),p.end()}function Ct(t,s,h,_=""){return p().P().str(_+p.N).str(t+p.N).i16(s.length),s.forEach((M,W)=>p.i32(h[W]||0)),p.end()}function Mr(t,s=""){return p().D().str(t).str(s+p.N).end()}function Tt(t="",s=0){return Buffer.concat([p().E().str(t+p.N).i32(s).end(),Kt])}function zr(t=""){return Buffer.concat([p().C().str("P").str(t+p.N).end(),p().S().end()])}function $r(){return ue||p().inc(4).i16(3).z(2).str(Object.entries(Object.assign({user:d,database:P,client_encoding:"UTF8"},e.connection)).filter(([,t])=>t).map(([t,s])=>t+p.N+s).join(p.N)).z(2).end(0)}}function Xe(e){let r={},n=5;for(let a=5;a<e.length-1;a++)e[a]===0&&(r[an[e[n]]]=e.toString("utf8",n+1,a),n=a+1);return r}function Vt(e){return ze__default.default.createHash("md5").update(e).digest("hex")}function Je(e,r){return ze__default.default.createHmac("sha256",e).update(r).digest()}function on(e){return ze__default.default.createHash("sha256").update(e).digest()}function cn(e,r){let n=Math.max(e.length,r.length),a=Buffer.allocUnsafe(n);for(let i=0;i<n;i++)a[i]=e[i]^r[i];return a}function gt(e,r){if(r=typeof r=="function"?r():r,!r)return {cancel:Ie,start:Ie};let n;return {cancel(){n&&(clearTimeout(n),n=null);},start(){n&&clearTimeout(n),n=setTimeout(a,r*1e3,arguments);}};function a(i){e.apply(null,i),n=null;}}chunkBUNLC3II_cjs.h();var Wt=()=>{};function wt(e,r){let n=new Map,a="postgresjs_"+Math.random().toString(36).slice(2),i={},u,o,c=false,d=P.sql=e({...r,transform:{column:{},value:{},row:{}},max:1,fetch_types:false,idle_timeout:null,max_lifetime:null,connection:{...r.connection,replication:"database"},onclose:async function(){c||(o=null,i.pid=i.secret=void 0,b(await E(d,a,r.publications)),n.forEach(g=>g.forEach(({onsubscribe:H})=>H())));},no_subscribe:true}),j=d.end,C=d.close;return d.end=async()=>(c=true,o&&await new Promise(g=>(o.once("close",g),o.end())),j()),d.close=async()=>(o&&await new Promise(g=>(o.once("close",g),o.end())),C()),P;async function P(g,H,N=Wt,oe=Wt){g=fn(g),u||(u=E(d,a,r.publications));let se={fn:H,onsubscribe:N},ee=n.has(g)?n.get(g).add(se):n.set(g,new Set([se])).get(g),S=()=>{ee.delete(se),ee.size===0&&n.delete(g);};return u.then(pe=>(b(pe),N(),o&&o.on("error",oe),{unsubscribe:S,state:i,sql:d}))}function b(g){o=g.stream,i.pid=g.state.pid,i.secret=g.state.secret;}async function E(g,H,N){if(!N)throw new Error("Missing publication names");let oe=await g.unsafe(`CREATE_REPLICATION_SLOT ${H} TEMPORARY LOGICAL pgoutput NOEXPORT_SNAPSHOT`),[se]=oe,ee=await g.unsafe(`START_REPLICATION SLOT ${H} LOGICAL ${se.consistent_point} (proto_version '1', publication_names '${N}')`).writable(),S={lsn:Buffer.concat(se.consistent_point.split("/").map(v=>Buffer.from(("00000000"+v).slice(-8),"hex")))};return ee.on("data",le),ee.on("error",pe),ee.on("close",g.close),{stream:ee,state:oe.state};function pe(v){console.error("Unexpected error during logical streaming - reconnecting",v);}function le(v){v[0]===119?un(v.subarray(25),S,g.options.parsers,Ae,r.transform):v[0]===107&&v[17]&&(S.lsn=v.subarray(1,9),be());}function Ae(v,m){let ue=m.relation.schema+"."+m.relation.table;R("*",v,m),R("*:"+ue,v,m),m.relation.keys.length&&R("*:"+ue+"="+m.relation.keys.map(x=>v[x.name]),v,m),R(m.command,v,m),R(m.command+":"+ue,v,m),m.relation.keys.length&&R(m.command+":"+ue+"="+m.relation.keys.map(x=>v[x.name]),v,m);}function be(){let v=Buffer.alloc(34);v[0]=114,v.fill(S.lsn,1),v.writeBigInt64BE(BigInt(Date.now()-Date.UTC(2e3,0,1))*BigInt(1e3),25),ee.write(v);}}function R(g,H,N){n.has(g)&&n.get(g).forEach(({fn:oe})=>oe(H,N,g));}}function ln(e){return new Date(Date.UTC(2e3,0,1)+Number(e/BigInt(1e3)))}function un(e,r,n,a,i){let u=(o,[c,d])=>(o[c.charCodeAt(0)]=d,o);Object.entries({R:o=>{let c=1,d=r[o.readUInt32BE(c)]={schema:o.toString("utf8",c+=4,c=o.indexOf(0,c))||"pg_catalog",table:o.toString("utf8",c+1,c=o.indexOf(0,c+1)),columns:Array(o.readUInt16BE(c+=2)),keys:[]};c+=2;let j=0,C;for(;c<o.length;)C=d.columns[j++]={key:o[c++],name:i.column.from?i.column.from(o.toString("utf8",c,c=o.indexOf(0,c))):o.toString("utf8",c,c=o.indexOf(0,c)),type:o.readUInt32BE(c+=1),parser:n[o.readUInt32BE(c)],atttypmod:o.readUInt32BE(c+=4)},C.key&&d.keys.push(C),c+=4;},Y:()=>{},O:()=>{},B:o=>{r.date=ln(o.readBigInt64BE(9)),r.lsn=o.subarray(1,9);},I:o=>{let c=1,d=r[o.readUInt32BE(c)],{row:j}=Ze(o,d.columns,c+=7,i);a(j,{command:"insert",relation:d});},D:o=>{let c=1,d=r[o.readUInt32BE(c)];c+=4;let j=o[c]===75;a(j||o[c]===79?Ze(o,d.columns,c+=3,i).row:null,{command:"delete",relation:d,key:j});},U:o=>{let c=1,d=r[o.readUInt32BE(c)];c+=4;let j=o[c]===75,C=j||o[c]===79?Ze(o,d.columns,c+=3,i):null;C&&(c=C.i);let{row:P}=Ze(o,d.columns,c+3,i);a(P,{command:"update",relation:d,key:j,old:C&&C.row});},T:()=>{},C:()=>{}}).reduce(u,{})[e[0]](e);}function Ze(e,r,n,a){let i,u,o,c=a.raw?new Array(r.length):{};for(let d=0;d<r.length;d++)i=e[n++],u=r[d],o=i===110?null:i===117?void 0:u.parser===void 0?e.toString("utf8",n+4,n+=4+e.readUInt32BE(n)):u.parser.array===true?u.parser(e.toString("utf8",n+5,n+=4+e.readUInt32BE(n))):u.parser(e.toString("utf8",n+4,n+=4+e.readUInt32BE(n))),a.raw?c[d]=a.raw===true?o:a.value.from?a.value.from(o,u):o:c[u.name]=a.value.from?a.value.from(o,u):o;return {i:n,row:a.row.from?a.row.from(c):c}}function fn(e){let r=e.match(/^(\*|insert|update|delete)?:?([^.]+?\.?[^=]+)?=?(.+)?/i)||[];if(!r)throw new Error("Malformed subscribe pattern: "+e);let[,n,a,i]=r;return (n||"*")+(a?":"+(a.indexOf(".")===-1?"public."+a:a):"")+(i?"="+i:"")}chunkBUNLC3II_cjs.h();function bt(e,r,n=393216){return new Promise(async(a,i)=>{await e.begin(async u=>{let o;!r&&([{oid:r}]=await u`select lo_creat(-1) as oid`);let[{fd:c}]=await u`select lo_open(${r}, ${n}) as fd`,d={writable:C,readable:j,close:()=>u`select lo_close(${c})`.then(o),tell:()=>u`select lo_tell64(${c})`,read:P=>u`select loread(${c}, ${P}) as data`,write:P=>u`select lowrite(${c}, ${P})`,truncate:P=>u`select lo_truncate64(${c}, ${P})`,seek:(P,b=0)=>u`select lo_lseek64(${c}, ${P}, ${b})`,size:()=>u`
|
|
13
|
+
select
|
|
14
|
+
lo_lseek64(${c}, location, 0) as position,
|
|
15
|
+
seek.size
|
|
16
|
+
from (
|
|
17
|
+
select
|
|
18
|
+
lo_lseek64($1, 0, 2) as size,
|
|
19
|
+
tell.location
|
|
20
|
+
from (select lo_tell64($1) as location) tell
|
|
21
|
+
) seek
|
|
22
|
+
`};return a(d),new Promise(async P=>o=P);async function j({highWaterMark:P=2048*8,start:b=0,end:E=1/0}={}){let R=E-b;return b&&await d.seek(b),new ht__default.default.Readable({highWaterMark:P,async read(g){let H=g>R?g-R:g;R-=g;let[{data:N}]=await d.read(H);this.push(N),N.length<g&&this.push(null);}})}async function C({highWaterMark:P=2048*8,start:b=0}={}){return b&&await d.seek(b),new ht__default.default.Writable({highWaterMark:P,write(E,R,g){d.write(E).then(()=>g(),g);}})}}).catch(i);})}Object.assign(qe,{PostgresError:Ee,toPascal:Se,pascal:dt,toCamel:_e,camel:mt,toKebab:ve,kebab:pt,fromPascal:Le,fromCamel:Fe,fromKebab:Me,BigInt:{to:20,from:[20],parse:e=>BigInt(e),serialize:e=>e.toString()}});var cs=qe;function qe(e,r){let n=pn(e,r),a=n.no_subscribe||wt(qe,{...n}),i=false,u=ne(),o=ne(),c=ne(),d=ne(),j=ne(),C=ne(),P=ne(),b=ne(),E={connecting:o,closed:d},R=[...Array(n.max)].map(()=>yt(n,E,{onopen:Oe,onend:J,onclose:fe})),g=H(Ae);return Object.assign(g,{get parameters(){return n.parameters},largeObject:bt.bind(null,g),subscribe:a,CLOSE:Ce,END:Ce,PostgresError:Ee,options:n,reserve:se,listen:N,begin:ee,close:ue,end:m}),g;function H(l){return l.debug=n.debug,Object.entries(n.types).reduce((w,[O,k])=>(w[O]=F=>new ie(F,k.to),w),y),Object.assign(U,{types:y,typed:y,unsafe:$,notify:oe,array:le,json:pe,file:L}),U;function y(w,O){return new ie(w,O)}function U(w,...O){return w&&Array.isArray(w.raw)?new re(w,O,l,v):typeof w=="string"&&!O.length?new Te(n.transform.column.to?n.transform.column.to(w):w):new ke(w,O)}function $(w,O=[],k={}){return arguments.length===2&&!Array.isArray(O)&&(k=O,O=[]),new re([w],O,l,v,{prepare:false,...k,simple:"simple"in k?k.simple:O.length===0})}function L(w,O=[],k={}){return arguments.length===2&&!Array.isArray(O)&&(k=O,O=[]),new re([],O,G=>{dn__default.default.readFile(w,"utf8",(Z,T)=>{if(Z)return G.reject(Z);G.strings=[T],l(G);});},v,{...k,simple:"simple"in k?k.simple:O.length===0})}}async function N(l,y,U){let $={fn:y,onlisten:U},L=N.sql||(N.sql=qe({...n,max:1,idle_timeout:null,max_lifetime:null,fetch_types:false,onclose(){Object.entries(N.channels).forEach(([G,{listeners:Z}])=>{delete N.channels[G],Promise.all(Z.map(T=>N(G,T.fn,T.onlisten).catch(()=>{})));});},onnotify(G,Z){G in N.channels&&N.channels[G].listeners.forEach(T=>T.fn(Z));}})),w=N.channels||(N.channels={});if(l in w){w[l].listeners.push($);let G=await w[l].result;return $.onlisten&&$.onlisten(),{state:G.state,unlisten:F}}w[l]={result:L`listen ${L.unsafe('"'+l.replace(/"/g,'""')+'"')}`,listeners:[$]};let k=await w[l].result;return $.onlisten&&$.onlisten(),{state:k.state,unlisten:F};async function F(){if(l in w&&(w[l].listeners=w[l].listeners.filter(G=>G!==$),!w[l].listeners.length))return delete w[l],L`unlisten ${L.unsafe('"'+l.replace(/"/g,'""')+'"')}`}}async function oe(l,y){return await g`select pg_notify(${l}, ${""+y})`}async function se(){let l=ne(),y=C.length?C.shift():await new Promise((L,w)=>{let O={reserve:L,reject:w};u.push(O),d.length&&A(d.shift(),O);});S(y,c),y.reserved=()=>l.length?y.execute(l.shift()):S(y,c),y.reserved.release=true;let U=H($);return U.release=()=>{y.reserved=null,Oe(y);},U;function $(L){y.queue===b?l.push(L):y.execute(L)||S(y,b);}}async function ee(l,y){!y&&(y=l,l="");let U=ne(),$=0,L,w=null;try{return await g.unsafe("begin "+l.replace(/[^a-z ]/ig,""),[],{onexecute:k}).execute(),await Promise.race([O(L,y),new Promise((F,G)=>L.onclose=G)])}catch(F){throw F}async function O(F,G,Z){let T=H(V);T.savepoint=he,T.prepare=D=>w=D.replace(/[^a-z0-9$-_. ]/gi);let me,ce;Z&&await T`savepoint ${T(Z)}`;try{if(ce=await new Promise((D,I)=>{let te=G(T);Promise.resolve(Array.isArray(te)?Promise.all(te):te).then(D,I);}),me)throw me}catch(D){throw await(Z?T`rollback to ${T(Z)}`:T`rollback`),D instanceof Ee&&D.code==="25P02"&&me||D}return Z||(w?await T`prepare transaction '${T.unsafe(w)}'`:await T`commit`),ce;function he(D,I){return D&&Array.isArray(D.raw)?he(te=>te.apply(te,arguments)):(arguments.length===1&&(I=D,D=null),O(F,I,"s"+$+++(D?"_"+D:"")))}function V(D){D.catch(I=>me||(me=I)),F.queue===b?U.push(D):F.execute(D)||S(F,b);}}function k(F){L=F,S(F,c),F.reserved=()=>U.length?F.execute(U.shift()):S(F,c);}}function S(l,y){return l.queue.remove(l),y.push(l),l.queue=y,y===C?l.idleTimer.start():l.idleTimer.cancel(),l}function pe(l){return new ie(l,3802)}function le(l,y){return Array.isArray(l)?new ie(l,y||(l.length?Ke(l)||25:0),n.shared.typeArrayMap):le(Array.from(arguments))}function Ae(l){if(i)return l.reject(z.connection("CONNECTION_ENDED",n,n));if(C.length)return be(C.shift(),l);if(d.length)return A(d.shift(),l);P.length?be(P.shift(),l):u.push(l);}function be(l,y){return l.execute(y)?S(l,P):S(l,b)}function v(l){return new Promise((y,U)=>{l.state?l.active?yt(n).cancel(l.state,y,U):l.cancelled={resolve:y,reject:U}:(u.remove(l),l.cancelled=true,l.reject(z.generic("57014","canceling statement due to user request")),y());})}async function m({timeout:l=null}={}){if(i)return i;await 1;let y;return i=Promise.race([new Promise(U=>l!==null&&(y=setTimeout(x,l*1e3,U))),Promise.all(R.map(U=>U.end()).concat(N.sql?N.sql.end({timeout:0}):[],a.sql?a.sql.end({timeout:0}):[]))]).then(()=>clearTimeout(y))}async function ue(){await Promise.all(R.map(l=>l.end()));}async function x(l){for(await Promise.all(R.map(y=>y.terminate()));u.length;)u.shift().reject(z.connection("CONNECTION_DESTROYED",n));l();}function A(l,y){return S(l,o),l.connect(y),l}function J(l){S(l,j);}function Oe(l){if(u.length===0)return S(l,C);let y=Math.ceil(u.length/(o.length+1)),U=true;for(;U&&u.length&&y-- >0;){let $=u.shift();if($.reserve)return $.reserve(l);U=l.execute($);}U?S(l,P):S(l,b);}function fe(l,y){S(l,d),l.reserved=null,l.onclose&&(l.onclose(y),l.onclose=null),n.onclose&&n.onclose(l.id),u.length&&A(l,u.shift());}}function pn(e,r){if(e&&e.shared)return e;let n=process.env,a=(!e||typeof e=="string"?r:e)||{},{url:i,multihost:u}=bn(e),o=[...i.searchParams].reduce((b,[E,R])=>(b[E]=R,b),{}),c=a.hostname||a.host||u||i.hostname||n.PGHOST||"localhost",d=a.port||i.port||n.PGPORT||5432,j=a.user||a.username||i.username||n.PGUSERNAME||n.PGUSER||En();a.no_prepare&&(a.prepare=false),o.sslmode&&(o.ssl=o.sslmode,delete o.sslmode),"timeout"in a&&(console.log("The timeout option is deprecated, use idle_timeout instead"),a.idle_timeout=a.timeout),o.sslrootcert==="system"&&(o.ssl="verify-full");let C=["idle_timeout","connect_timeout","max_lifetime","max_pipeline","backoff","keep_alive"],P={max:globalThis.Cloudflare?3:10,ssl:false,sslnegotiation:null,idle_timeout:null,connect_timeout:30,max_lifetime:yn,max_pipeline:100,backoff:gn,keep_alive:60,prepare:true,debug:false,fetch_types:true,publications:"alltables",target_session_attrs:null};return {host:Array.isArray(c)?c:c.split(",").map(b=>b.split(":")[0]),port:Array.isArray(d)?d:c.split(",").map(b=>parseInt(b.split(":")[1]||d)),path:a.path||c.indexOf("/")>-1&&c+"/.s.PGSQL."+d,database:a.database||a.db||(i.pathname||"").slice(1)||n.PGDATABASE||j,user:j,pass:a.pass||a.password||i.password||n.PGPASSWORD||"",...Object.entries(P).reduce((b,[E,R])=>{let g=E in a?a[E]:E in o?o[E]==="disable"||o[E]==="false"?false:o[E]:n["PG"+E.toUpperCase()]||R;return b[E]=typeof g=="string"&&C.includes(E)?+g:g,b},{}),connection:{application_name:n.PGAPPNAME||"postgres.js",...a.connection,...Object.entries(o).reduce((b,[E,R])=>(E in P||(b[E]=R),b),{})},types:a.types||{},target_session_attrs:hn(a,i,n),onnotice:a.onnotice,onnotify:a.onnotify,onclose:a.onclose,onparameter:a.onparameter,socket:a.socket,transform:wn(a.transform||{undefined:void 0}),parameters:{},shared:{retries:0,typeArrayMap:{}},...Lt(a.types)}}function hn(e,r,n){let a=e.target_session_attrs||r.searchParams.get("target_session_attrs")||n.PGTARGETSESSIONATTRS;if(!a||["read-write","read-only","primary","standby","prefer-standby"].includes(a))return a;throw new Error("target_session_attrs "+a+" is not supported")}function gn(e){return (.5+Math.random()/2)*Math.min(3**e/100,20)}function yn(){return 60*(30+Math.random()*30)}function wn(e){return {undefined:e.undefined,column:{from:typeof e.column=="function"?e.column:e.column&&e.column.from,to:e.column&&e.column.to},value:{from:typeof e.value=="function"?e.value:e.value&&e.value.from,to:e.value&&e.value.to},row:{from:typeof e.row=="function"?e.row:e.row&&e.row.from,to:e.row&&e.row.to}}}function bn(e){if(!e||typeof e!="string")return {url:{searchParams:new Map}};let r=e;r=r.slice(r.indexOf("://")+3).split(/[?/]/)[0],r=decodeURIComponent(r.slice(r.indexOf("@")+1));let n=new URL(e.replace(r,r.split(",")[0]));return {url:{username:decodeURIComponent(n.username),password:decodeURIComponent(n.password),host:n.host,hostname:n.hostname,port:n.port,pathname:n.pathname,searchParams:n.searchParams},multihost:r.indexOf(",")>-1&&r}}function En(){try{return mn__default.default.userInfo().username}catch{return process.env.USERNAME||process.env.USER||process.env.LOGNAME}}
|
|
23
|
+
exports.a=cs;
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import {createRequire}from'module';import {b}from'./chunk-6KRR7YHA.js';import {g as g$1}from'./chunk-C2PXMVR5.js';createRequire(import.meta.url);
|
|
2
|
+
g$1();var d=class{collections=new Map;globals=new Map;connected=false;tenantContext;setTenantContext(e){this.tenantContext=e;}getTenantContext(){return this.tenantContext}async init(e,n=[]){for(let t of e)this.collections.set(t.slug,t);for(let t of n)this.globals.set(t.slug,t);await this.connect();}getCollection(e){let n=this.collections.get(e);if(!n)throw console.error(`[Adapter] Missing collection "${e}". Available collections:`,Array.from(this.collections.keys())),new Error(`Collection "${e}" not found in adapter`);return n}applyTenantFilter(e={},n){return n?{...e,tenantId:{equals:n}}:e}getTableName(e){return e.replace(/-/g,"_")}prepareData(e,n){let t={...e};if(n.timestamps){let r=new Date().toISOString();t.updatedAt=r,t.createdAt||(t.createdAt=r);}return n.auth&&t.password,t}processRelationships(e,n,t){return e}parseSort(e){return e?e.startsWith("-")?{field:e.slice(1),direction:"desc"}:{field:e,direction:"asc"}:{field:"createdAt",direction:"desc"}}calculatePagination(e,n,t){let r=Math.ceil(t/n);return {totalDocs:t,limit:n,totalPages:r,page:e,pagingCounter:(e-1)*n+1,hasPrevPage:e>1,hasNextPage:e<r,prevPage:e>1?e-1:null,nextPage:e<r?e+1:null}}selectFields(e,n){if(!n||n.length===0)return e;let t={};for(let r of n)r in e&&(t[r]=e[r]);return t.id=e.id,t}isRelationshipField(e){return e.type==="relationship"}isUploadField(e){return e.type==="upload"}getRelationshipFields(e){let n=[];for(let t of e)t.type==="relationship"?n.push(t):"fields"in t&&t.fields&&n.push(...this.getRelationshipFields(t.fields));return n}getUploadFields(e){let n=[];for(let t of e)t.type==="upload"?n.push(t):"fields"in t&&t.fields&&n.push(...this.getUploadFields(t.fields));return n}};g$1();var o={tenantEnabled:true,tenantField:"tenantId",ownershipRules:{posts:{ownerField:"authorId",bypassRoles:["super_admin","admin","editor"]},pages:{ownerField:"authorId",bypassRoles:["super_admin","admin","editor"]},media:{ownerField:"uploadedBy",bypassRoles:["super_admin","admin","editor"]},orders:{ownerField:"customerId",bypassRoles:["super_admin","admin","editor"]},customers:{ownerField:"id",bypassRoles:["super_admin","admin"]},navigation:{ownerField:"id",bypassRoles:["super_admin","admin"]}}};function g(i,e,n=o){return !n.tenantEnabled||e.isSuperAdmin?i:{...i,where:{...i.where,[n.tenantField]:e.tenantId}}}function p(i,e,n,t=o){let r=t.ownershipRules[e];return !r||r.bypassRoles&&b({role:n.role},r.bypassRoles)?i:r.ownerField==="id"&&n.userId?{...i,where:{...i.where,id:n.userId}}:r.ownerField&&n.userId?{...i,where:{...i.where,[r.ownerField]:n.userId}}:i}function m(i,e,n,t=o){let r=i;return r=g(r,n,t),r=p(r,e,n,t),r}function h(i,e,n,t=o){if(n.isSuperAdmin)return true;if(t.tenantEnabled&&i[t.tenantField]!==n.tenantId)return false;let r=t.ownershipRules[e];return !r||r.bypassRoles&&b({role:n.role},r.bypassRoles)?true:r.ownerField==="id"?i.id===n.userId:r.ownerField?i[r.ownerField]===n.userId:true}export{d as a,o as b,m as c,h as d};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
'use strict';var chunkAK754S3T_cjs=require('./chunk-AK754S3T.cjs'),chunkDUO523BH_cjs=require('./chunk-DUO523BH.cjs'),chunkZOVH6QT5_cjs=require('./chunk-ZOVH6QT5.cjs'),chunkBUNLC3II_cjs=require('./chunk-BUNLC3II.cjs');chunkBUNLC3II_cjs.h();chunkBUNLC3II_cjs.h();async function V(e){let a=chunkAK754S3T_cjs.o(e.db),t={db:e.db,registry:e.registry,req:e.req,user:e.user,tenantId:e.tenantId,webhookService:a,settings:e.settings},n=chunkDUO523BH_cjs.f(e.req);if(n){let r=await chunkDUO523BH_cjs.e(n,e.db,async o=>{try{return await e.db.findByID({collection:"users",id:o})||null}catch{return null}});r.valid&&(t.user=r.user||e.user,t.tenantId=r.tenantId||e.tenantId,t.apiKey=chunkDUO523BH_cjs.g(r));}return t}chunkBUNLC3II_cjs.h();var G={_media:{create:chunkAK754S3T_cjs.d.MEDIA_UPLOAD,update:chunkAK754S3T_cjs.d.MEDIA_UPLOAD,delete:chunkAK754S3T_cjs.d.MEDIA_DELETE}};function R(e,a){let t=G[e];return t?t[a]:`collection.${a}`}async function q(e,a,t){if(e.webhookService)try{await e.webhookService.trigger(a,{collection:t.collection,operation:t.operation,data:t.data,previousData:t.previousData,user:e.user?{id:e.user.id,email:e.user.email,role:e.user.role}:void 0,tenantId:e.tenantId});}catch(n){console.error(`[Webhook] Failed to trigger ${a}:`,n);}}function I(e,a){if(!(!e||typeof e!="object"))for(let t of a){if(t.type==="tabs"&&Array.isArray(t.tabs)){let r=t.name?e[t.name]:e;if(r&&typeof r=="object")for(let o of t.tabs)Array.isArray(o.fields)&&I(r,o.fields);continue}if(!t.name||!(t.name in e))continue;if(e[t.name]===""&&(t.type==="text"||t.type==="textarea"||t.type==="code"||t.type==="markdown"||t.type==="email"||t.type==="password"||t.type==="color"||(e[t.name]=null)),(t.type==="group"||t.type==="collapsible")&&t.name&&Array.isArray(t.fields)&&e[t.name]&&typeof e[t.name]=="object")I(e[t.name],t.fields);else if(t.type==="array"&&t.name&&Array.isArray(t.fields)&&Array.isArray(e[t.name]))for(let r of e[t.name])r&&typeof r=="object"&&I(r,t.fields);else if(t.type==="blocks"&&t.name&&Array.isArray(t.blocks)&&Array.isArray(e[t.name]))for(let r of e[t.name]){if(!r||typeof r!="object")continue;let o=r.type||r.blockType;if(!o)continue;let s=t.blocks.find(i=>i.slug===o);if(!s||!Array.isArray(s.fields))continue;let u=r.data&&typeof r.data=="object"?r.data:r;I(u,s.fields);}}}async function b(e,a,t){let n=await chunkAK754S3T_cjs.b(e,a,{user:t.user,req:t.req,tenantId:t.tenantId,apiKey:t.apiKey});if(!n.allowed)throw new Error(n.error||"Access denied");t.tenantId&&t.db.setTenantContext({tenantId:t.tenantId,userId:t.user?.id??"",role:t.user?.role,isSuperAdmin:t.user?.role==="super_admin"});}function P(e){return async a=>{let{collection:t,where:n,sort:r,limit:o,page:s,depth:u,select:i,draft:d}=a,l=e.registry.getCollection(t);if(await b(l,"read",e),l.hooks?.beforeRead)for(let p of l.hooks.beforeRead)await p({collection:t,req:e.req,user:e.user,tenantId:e.tenantId,operation:"read",where:n});let c=d??!!e.user,h=await e.db.find({collection:t,where:n||{},sort:r,limit:o||10,page:s||1,depth:u||0,tenantId:e.tenantId,select:i,draft:c});if(l.hooks?.afterRead)for(let p of h.docs)for(let k of l.hooks.afterRead)await k({collection:t,doc:p,req:e.req,user:e.user,tenantId:e.tenantId,operation:"read"});return await chunkAK754S3T_cjs.a(h.docs,l.fields,e.db,e.registry,1,u||0),chunkZOVH6QT5_cjs.a(h)}}function v(e){return async a=>{let{collection:t,id:n,depth:r,select:o,draft:s}=a,u=e.registry.getCollection(t);await b(u,"read",e);let i=s??!!e.user,d=await e.db.findByID({collection:t,id:n,depth:r||0,tenantId:e.tenantId,select:o,draft:i});if(!d)throw new Error(`Document not found: ${t}/${n}`);if(u.hooks?.afterRead)for(let l of u.hooks.afterRead)await l({collection:t,doc:d,req:e.req,user:e.user,tenantId:e.tenantId,operation:"read",id:n});return await chunkAK754S3T_cjs.a([d],u.fields,e.db,e.registry,1,r||0),chunkZOVH6QT5_cjs.a(d)}}function K(e){return async a=>{let{collection:t,data:n,depth:r,select:o}=a,s=e.registry.getCollection(t);await b(s,"create",e);let i=e.registry.getCreateZodSchema(t).parse(n);if(s.tenantScoped&&e.tenantId&&(i.tenantId=e.tenantId),s.hooks?.beforeValidate)for(let l of s.hooks.beforeValidate){let c=await l({collection:t,data:i,req:e.req,user:e.user,tenantId:e.tenantId,operation:"create"});c&&typeof c=="object"&&!Array.isArray(c)&&Object.assign(i,c);}if(s.hooks?.beforeChange)for(let l of s.hooks.beforeChange){let c=await l({collection:t,data:i,req:e.req,user:e.user,tenantId:e.tenantId,operation:"create"});c&&typeof c=="object"&&!Array.isArray(c)&&Object.assign(i,c);}let d=await e.db.create({collection:t,data:i,depth:r||0,tenantId:e.tenantId,select:o});if(s.hooks?.afterChange)for(let l of s.hooks.afterChange)await l({collection:t,doc:d,data:i,req:e.req,user:e.user,tenantId:e.tenantId,operation:"create"});return await q(e,R(t,"create"),{collection:t,data:d,operation:"create"}),{doc:d}}}function E(e){return async a=>{let{collection:t,id:n,data:r,depth:o,select:s,baseUpdatedAt:u}=a,i=e.registry.getCollection(t);await b(i,"update",e);let d=await e.db.findByID({collection:t,id:n,tenantId:e.tenantId,draft:true});if(!d)throw new Error(`Document not found: ${t}/${n}`);if(u&&d.updatedAt&&u!==d.updatedAt)throw new Error(`Revision conflict: document has changed since ${u}. Current updatedAt: ${d.updatedAt}`);I(r,i.fields);let c=e.registry.getUpdateZodSchema(t).parse(r);if(i.tenantScoped&&e.tenantId&&(c.tenantId=e.tenantId),i.hooks?.beforeValidate)for(let m of i.hooks.beforeValidate){let f=await m({collection:t,data:c,originalDoc:d,req:e.req,user:e.user,tenantId:e.tenantId,operation:"update",id:n});f&&typeof f=="object"&&!Array.isArray(f)&&Object.assign(c,f);}if(i.hooks?.beforeChange)for(let m of i.hooks.beforeChange){let f=await m({collection:t,data:c,originalDoc:d,req:e.req,user:e.user,tenantId:e.tenantId,operation:"update",id:n});f&&typeof f=="object"&&!Array.isArray(f)&&Object.assign(c,f);}let h=e.req&&typeof e.req.headers?.get=="function"&&e.req.headers.get("x-draft")==="true"||a.draft===true,p=i.versions?.drafts===true,k=e.req?.query?.autosave==="true"||e.req?.url?.includes("autosave=true")||a.autosave===true,g;if(p&&h?(await e.db.createVersion({collection:t,documentId:n,data:c,status:"draft",autosave:k,createdBy:e.user?.id,tenantId:e.tenantId}),g=await e.db.findByID({collection:t,id:n,tenantId:e.tenantId,draft:true})):p?(g=await e.db.update({collection:t,id:n,data:{...c,status:"published"},depth:o||0,tenantId:e.tenantId,select:s}),await e.db.createVersion({collection:t,documentId:n,data:c,status:"published",createdBy:e.user?.id,tenantId:e.tenantId})):g=await e.db.update({collection:t,id:n,data:c,depth:o||0,tenantId:e.tenantId,select:s}),i.hooks?.afterChange)for(let m of i.hooks.afterChange)await m({collection:t,doc:g,data:c,originalDoc:d,req:e.req,user:e.user,tenantId:e.tenantId,operation:"update",id:n});return await q(e,R(t,"update"),{collection:t,data:g,previousData:d,operation:"update"}),{doc:g}}}function j(e){return async a=>{let{collection:t,id:n}=a,r=e.registry.getCollection(t);await b(r,"delete",e);let o=await e.db.findByID({collection:t,id:n,tenantId:e.tenantId,draft:true});if(!o)throw new Error(`Document not found: ${t}/${n}`);if(r.hooks?.beforeDelete)for(let u of r.hooks.beforeDelete)await u({collection:t,doc:o,req:e.req,user:e.user,tenantId:e.tenantId,operation:"delete",id:n});let s=await e.db.delete({collection:t,id:n,tenantId:e.tenantId});if(r.hooks?.afterDelete)for(let u of r.hooks.afterDelete)await u({collection:t,doc:s,req:e.req,user:e.user,tenantId:e.tenantId,operation:"delete",id:n});return await q(e,R(t,"delete"),{collection:t,data:s,previousData:o,operation:"delete"}),{doc:s,message:"Deleted successfully"}}}function S(e){return async a=>{let{collection:t,where:n}=a,r=e.registry.getCollection(t);return await b(r,"read",e),{totalDocs:await e.db.count({collection:t,where:n||{},tenantId:e.tenantId})}}}chunkBUNLC3II_cjs.h();async function W(e,a,t){let n=await chunkAK754S3T_cjs.c(e,a,{user:t.user,req:t.req,tenantId:t.tenantId});if(!n.allowed)throw new Error(n.error||"Access denied");t.tenantId&&t.db.setTenantContext({tenantId:t.tenantId,userId:t.user?.id??"",role:t.user?.role,isSuperAdmin:t.user?.role==="super_admin"});}function O(e){let a={},t=e.registry.getCollections();for(let r of t){let o=r.slug;a[o]={find:P(e),findByID:v(e),create:K(e),update:E(e),delete:j(e),count:S(e)};}let n=e.registry.getGlobals();for(let r of n){let o=r.slug;a[`_globals_${o}`]={get:async s=>(await W(r,"read",e),await e.db.findOne({collection:`_globals_${o}`,where:{},tenantId:e.tenantId,depth:s?.depth,draft:s?.draft,select:s?.select})),update:async s=>{await W(r,"update",e);let i=e.registry.getZodSchema(o).parse(s.data),d=await e.db.findOne({collection:`_globals_${o}`,where:{},tenantId:e.tenantId,draft:true}),l;return d?l=await e.db.update({collection:`_globals_${o}`,id:d.id,data:i,tenantId:e.tenantId}):l=await e.db.create({collection:`_globals_${o}`,data:{...i,id:o},tenantId:e.tenantId}),l}};}return a}function L(e){if(e.settings?.access?.apiAccess?.trpcEnabled===false)throw new Error("tRPC API is disabled");return O(e)}exports.a=V;exports.b=P;exports.c=v;exports.d=K;exports.e=E;exports.f=j;exports.g=S;exports.h=O;exports.i=L;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
'use strict';var chunkBUNLC3II_cjs=require('./chunk-BUNLC3II.cjs');chunkBUNLC3II_cjs.h();function n(e){return {ipAddress:e.headers.get("x-forwarded-for")?.split(",")[0]?.trim()||e.headers.get("x-real-ip")||"unknown",userAgent:e.headers.get("user-agent")||"unknown"}}exports.a=n;
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import {createRequire}from'module';import {b}from'./chunk-A73AVVFR.js';import {p as p$1}from'./chunk-XOACKBG7.js';import {g}from'./chunk-C2PXMVR5.js';createRequire(import.meta.url);
|
|
2
|
+
g();g();var C="AWS_ACCESS_KEY_ID",A="AWS_SECRET_ACCESS_KEY",p="AWS_SESSION_TOKEN",I="AWS_CREDENTIAL_EXPIRATION",a="AWS_CREDENTIAL_SCOPE",i="AWS_ACCOUNT_ID",V=o=>async()=>{o?.logger?.debug("@aws-sdk/credential-provider-env - fromEnv");let E=process.env[C],r=process.env[A],n=process.env[p],s=process.env[I],t=process.env[a],c=process.env[i];if(E&&r){let _={accessKeyId:E,secretAccessKey:r,...n&&{sessionToken:n},...s&&{expiration:new Date(s)},...t&&{credentialScope:t},...c&&{accountId:c}};return b(_,"CREDENTIALS_ENV_VARS","g"),_}throw new p$1("Unable to find environment variable credentials.",{logger:o?.logger})};export{C as a,A as b,p as c,I as d,a as e,i as f,V as g};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import {createRequire}from'module';import {a,c,b,d}from'./chunk-MCZ3YZ2L.js';import {a as a$1}from'./chunk-BLH2MRK4.js';import {g}from'./chunk-C2PXMVR5.js';import {randomBytes}from'crypto';createRequire(import.meta.url);
|
|
2
|
+
g();g();var _;function x(){return _||(_=createRequire("file:///")("node:sqlite").DatabaseSync,_)}function N(T){let e=[];for(let a of T)if(a.type==="tabs"&&"tabs"in a)for(let n of a.tabs)e.push(...N(n.fields));else a.type==="row"&&"fields"in a?e.push(...N(a.fields)):a.type==="collapsible"&&"fields"in a?e.push(...N(a.fields)):e.push(a);return e}function B(T,e){let a=e,n=T[a.name];if(a.type==="json"||a.type==="richtext"||a.type==="array"||a.type==="group"||a.type==="blocks"||a.type==="list"||a.type==="relationship-block")try{n=n?JSON.parse(n):null;}catch{n=null;}if(a.type==="checkbox"&&(n=!!n),a.type==="date"&&n)try{let i=new Date(n);isNaN(i.getTime())?n=null:n=i.toISOString();}catch{n=null;}if((a.type==="upload"||a.type==="image")&&n)try{let i=JSON.parse(n);Array.isArray(i)?n=i.map(o=>typeof o=="object"&&o!==null?o:{id:o}):n=typeof i=="object"?i:{id:i};}catch{n={id:n};}if(a.type==="relationship"&&n)try{let i=JSON.parse(n);Array.isArray(i),n=i;}catch{n={relationTo:Array.isArray(a.relationTo)?a.relationTo[0]:a.relationTo,value:n};}if(a.type==="list"&&n)try{let i=JSON.parse(n);n=Array.isArray(i)?i:[];}catch{n=[];}if(a.type==="relationship-block"&&n)try{let i=JSON.parse(n);n=Array.isArray(i)?i:[];}catch{n=[];}return n}function P(T,e){return Array.isArray(T)?T.map(a=>{if(!a||typeof a!="object")return a;let n=a.data?{...a.data}:void 0;if(!n)return a;let i=e.find(o=>o.slug===a.type||o.slug===a.slug);if(!i||!Array.isArray(i.fields))return a;for(let o of i.fields){if(o.name&&(o.type==="upload"||o.type==="image")&&n[o.name]){let t=n[o.name];Array.isArray(t)?n[o.name]=t.map(s=>typeof s=="string"?{id:s}:s):typeof t=="string"&&(n[o.name]={id:t});}if(o.type==="blocks"&&o.name&&n[o.name]){let t=o.blocks||[];n[o.name]=P(n[o.name],t);}}return {...a,data:n}}):T}function O(T,e){try{return T.prepare(`PRAGMA table_info(${e})`).all().map(n=>n.name)}catch{return []}}var L=class extends a{db;path;migrations=new Map;versionsTableName="kyro_versions";constructor(e){super(),this.path=e.path,e.db?this.db=e.db:this.db=null;}async connect(){if(!this.db)this.db=new(x())(this.path||":memory:");else try{this.db.exec("SELECT 1");}catch{this.db=new(x())(this.path||":memory:");}if(this.db&&typeof this.db.prepare=="function"&&!this.db.prepare.__wrapped){let e=this.db.prepare.bind(this.db),a=n=>{let i=e(n),o=t=>typeof t=="boolean"?t?1:0:t===void 0?null:t;return new Proxy(i,{get(t,s,r){if(s==="all")return (...c)=>t.all(...c.map(o));if(s==="get")return (...c)=>t.get(...c.map(o));if(s==="run")return (...c)=>t.run(...c.map(o));let l=Reflect.get(t,s,r);return typeof l=="function"?l.bind(t):l}})};a.__wrapped=true,this.db.prepare=a;}this.db.exec("PRAGMA journal_mode = WAL"),this.db.exec("PRAGMA foreign_keys = ON"),this.connected=true;}async disconnect(){if(this.db){try{this.db.close();}catch{}this.db=null;}this.connected=false;}ensureTable(e,a){let n=a||this.getTableNameFor(e.slug),i=["id TEXT PRIMARY KEY"];for(let s of N(e.fields)){if(!s.name||s.name==="id")continue;let r=this.fieldToSQL(s);r&&i.push(r);}let o=N(e.fields);o.some(s=>s.name==="createdAt")||i.push(`${this.col("createdAt")} TEXT DEFAULT (datetime('now'))`),o.some(s=>s.name==="updatedAt")||i.push(`${this.col("updatedAt")} TEXT DEFAULT (datetime('now'))`),o.some(s=>s.name==="status")||i.push("status TEXT DEFAULT 'draft'"),o.some(s=>s.name==="hasDraft")||i.push("hasDraft INTEGER DEFAULT 0"),e.tenantScoped&&i.push("tenant_id TEXT NOT NULL");let t=O(this.db,n);if(t.length===0){let s=`CREATE TABLE IF NOT EXISTS ${n} (${i.join(", ")})`;this.db.exec(s),this.db.exec(`CREATE INDEX IF NOT EXISTS idx_${n}_status ON ${n}(status)`);for(let r of N(e.fields))r.name&&r.indexed&&this.db.exec(`CREATE INDEX IF NOT EXISTS idx_${n}_${r.name} ON ${n}(${this.col(r.name)})`),r.name&&r.unique&&this.db.exec(`CREATE UNIQUE INDEX IF NOT EXISTS idx_${n}_${r.name}_unique ON ${n}(${this.col(r.name)})`);}else {let s=new Set(t);for(let r of i){let l=r.split(" ")[0].replace(/^"/,"").replace(/"$/,"");if(!s.has(l)&&l!=="id")try{l==="status"?this.db.exec(`ALTER TABLE ${n} ADD COLUMN ${this.col(l)} TEXT DEFAULT 'published'`):l==="hasDraft"?this.db.exec(`ALTER TABLE ${n} ADD COLUMN ${this.col(l)} INTEGER DEFAULT 0`):this.db.exec(`ALTER TABLE ${n} ADD COLUMN ${this.col(l)} TEXT`);}catch{}}}this.migrations.set(n,true);}ensureVersionsTable(){this.db.exec(`
|
|
3
|
+
CREATE TABLE IF NOT EXISTS ${this.versionsTableName} (
|
|
4
|
+
id TEXT PRIMARY KEY,
|
|
5
|
+
collection_slug TEXT NOT NULL,
|
|
6
|
+
document_id TEXT NOT NULL,
|
|
7
|
+
tenant_id TEXT,
|
|
8
|
+
version INTEGER NOT NULL,
|
|
9
|
+
status TEXT NOT NULL DEFAULT 'draft',
|
|
10
|
+
autosave INTEGER NOT NULL DEFAULT 0,
|
|
11
|
+
data TEXT NOT NULL,
|
|
12
|
+
created_by TEXT,
|
|
13
|
+
change_description TEXT,
|
|
14
|
+
published_at TEXT,
|
|
15
|
+
created_at TEXT DEFAULT (datetime('now')),
|
|
16
|
+
updated_at TEXT DEFAULT (datetime('now'))
|
|
17
|
+
)
|
|
18
|
+
`);try{this.db.exec(`ALTER TABLE ${this.versionsTableName} ADD COLUMN autosave INTEGER NOT NULL DEFAULT 0`);}catch{}this.db.exec(`CREATE INDEX IF NOT EXISTS idx_${this.versionsTableName}_doc ON ${this.versionsTableName}(collection_slug, document_id)`),this.db.exec(`CREATE INDEX IF NOT EXISTS idx_${this.versionsTableName}_status ON ${this.versionsTableName}(status)`),this.db.exec(`CREATE INDEX IF NOT EXISTS idx_${this.versionsTableName}_autosave ON ${this.versionsTableName}(autosave)`);}resolveCol(e,a){let n=a.replace(/^-/,""),i=O(this.db,e);if(!i.includes(n)){if(n==="created_at"&&i.includes("createdAt"))return '"createdAt"';if(n==="createdAt"&&i.includes("created_at"))return '"created_at"';if(n==="updated_at"&&i.includes("updatedAt"))return '"updatedAt"';if(n==="updatedAt"&&i.includes("updated_at"))return '"updated_at"'}return this.col(n)}col(e){return `"${e}"`}fieldToSQL(e){switch(e.type){case "text":case "email":case "password":case "textarea":case "color":case "icon":case "code":case "markdown":case "url":return this.col(e.name)+" TEXT";case "number":return this.col(e.name)+" REAL";case "checkbox":return this.col(e.name)+" INTEGER DEFAULT 0";case "date":return this.col(e.name)+" TEXT";case "select":case "radio":return this.col(e.name)+" TEXT";case "relationship":case "upload":return this.col(e.name)+" TEXT";case "json":case "richtext":case "array":case "group":case "blocks":return this.col(e.name)+" TEXT";default:return null}}parseGlobalsSlug(e){if(e.startsWith("_globals_")){let a=e.replace("_globals_","");return {isGlobal:true,globalSlug:a,tableName:`global_${a.replace(/-/g,"_")}`}}return {isGlobal:false,globalSlug:"",tableName:this.getTableNameFor(e)}}async find(e){let{collection:a,where:n={},sort:i,limit:o=10,page:t=1,tenantId:s,draft:r=false}=e,l=this.parseGlobalsSlug(a),c$1=l.isGlobal?this.globals.get(l.globalSlug):this.getCollection(a);this.ensureTable(c$1,l.tableName);let d$1=l.tableName,y=`SELECT * FROM ${d$1}`,u=[],p=[],f={...n};this.tenantContext&&c$1.tenantScoped&&(f=c({where:f},a,this.tenantContext,b).where||{});let E=c$1.fields.find(h=>h.name==="status"),b$1=E?.type==="select"&&Array.isArray(E.options)&&E.options.some(h=>h.value==="published");!r&&b$1&&(p.push("status = ?"),u.push("published")),s&&c$1.tenantScoped&&(p.push("tenant_id = ?"),u.push(s));for(let[h,m]of Object.entries(f)){if(h==="AND"||h==="OR")continue;let S=this.resolveCol(d$1,h);typeof m=="object"&&m!==null?(m.equals!==void 0&&(p.push(`${S} = ?`),u.push(m.equals)),m.in!==void 0&&(p.push(`${S} IN (${m.in.map(()=>"?").join(", ")})`),u.push(...m.in)),m.not_equals!==void 0&&(p.push(`${S} != ?`),u.push(m.not_equals))):(p.push(`${S} = ?`),u.push(m));}p.length>0&&(y+=` WHERE ${p.join(" AND ")}`);let g=i||"-createdAt",w=this.resolveCol(d$1,g),M=g.startsWith("-")?"DESC":"ASC";y+=` ORDER BY ${w} ${M}`;let U=y.replace("SELECT *","SELECT COUNT(*) as count"),D=this.db.prepare(U).get(...u)?.count||0;y+=" LIMIT ? OFFSET ?",u.push(o,(t-1)*o);let A=this.db.prepare(y).all(...u).map(h=>this.rowToDoc(h,c$1));return this.tenantContext&&!this.tenantContext.isSuperAdmin&&(A=A.filter(h=>d(h,a,this.tenantContext,b))),r&&(A=await Promise.all(A.map(async h=>{let m=this.db.prepare(`SELECT * FROM ${this.versionsTableName} WHERE collection_slug = ? AND document_id = ? AND tenant_id IS NULL ORDER BY version DESC LIMIT 1`).get(a,h.id);if(m){let S=m.data?JSON.parse(m.data):{};return a$1({...h,...S,status:h.status})}return h}))),A=A.map(h=>a$1(h)),{docs:A,totalDocs:D,limit:o,totalPages:Math.ceil(D/o),page:t,pagingCounter:(t-1)*o+1,hasPrevPage:t>1,hasNextPage:t<Math.ceil(D/o),prevPage:t>1?t-1:null,nextPage:t<Math.ceil(D/o)?t+1:null}}async findByID(e){let{collection:a,id:n,tenantId:i,draft:o=false}=e,t=this.parseGlobalsSlug(a),s=t.isGlobal?this.globals.get(t.globalSlug):this.getCollection(a);this.ensureTable(s,t.tableName);let l=`SELECT * FROM ${t.tableName} WHERE id = ?`,c=[n];if(this.tenantContext&&s.tenantScoped){let f={id:n,tenant_id:this.tenantContext.tenantId};if(!d(f,a,this.tenantContext,b))return null}let d$1=s.fields.find(f=>f.name==="status"),y=d$1?.type==="select"&&Array.isArray(d$1.options)&&d$1.options.some(f=>f.value==="published");!o&&y&&(l+=" AND status = ?",c.push("published")),i&&s.tenantScoped&&(l+=" AND tenant_id = ?",c.push(i));let u=this.db.prepare(l).get(...c);if(!u)return null;let p=this.rowToDoc(u,s);if(o){let f=this.db.prepare(`SELECT * FROM ${this.versionsTableName} WHERE collection_slug = ? AND document_id = ? AND tenant_id IS NULL ORDER BY version DESC LIMIT 1`).get(a,p.id);if(f){let E=f.data?JSON.parse(f.data):{};p={...p,...E,status:p.status};}}return a$1(p)}async create(e){let{collection:a,data:n,tenantId:i}=e,o=this.parseGlobalsSlug(a),t=o.isGlobal?this.globals.get(o.globalSlug):this.getCollection(a);this.ensureTable(t,o.tableName);let s=o.tableName,r=o.isGlobal?o.globalSlug:n.id||this.generateId(),l=this.prepareData(n,t);l.id=r;let c=new Date().toISOString();l.created_at=c,l.updated_at=c,i&&t.tenantScoped&&(l.tenant_id=i);let d=Object.keys(l),y=O(this.db,s),u={};for(let g of d)y.includes(g)&&(u[g]=l[g]);let p=Object.keys(u),f=p.map(g=>this.col(g)),E=p.map(()=>"?").join(", "),b=Object.values(u).map(g=>g!==null&&typeof g=="object"?JSON.stringify(g):g);return this.db.prepare(`INSERT OR REPLACE INTO ${s} (${f.join(", ")}) VALUES (${E})`).run(...b),this.ensureVersionsTable(),this.findByID({collection:a,id:r,tenantId:i,draft:true})}async update(e){let{collection:a,id:n,data:i,tenantId:o}=e,t=this.parseGlobalsSlug(a),s=t.isGlobal?this.globals.get(t.globalSlug):this.getCollection(a);this.ensureTable(s,t.tableName);let r=t.tableName,l=this.prepareData(i,s);l.updated_at=new Date().toISOString();let c=O(this.db,r),d={};for(let b of Object.keys(l))c.includes(b)&&(d[b]=l[b]);let u=Object.keys(d).map(b=>`${this.col(b)} = ?`).join(", "),p=Object.values(d).map(b=>b!==null&&typeof b=="object"?JSON.stringify(b):b),f=`UPDATE ${r} SET ${u} WHERE id = ?`,E=[...p,n];return o&&s.tenantScoped&&(f+=" AND tenant_id = ?",E.push(o)),this.db.prepare(f).run(...E),this.ensureVersionsTable(),this.findByID({collection:a,id:n,tenantId:o,draft:true})}async delete(e){let{collection:a,id:n,tenantId:i}=e,o=this.parseGlobalsSlug(a),t=o.isGlobal?this.globals.get(o.globalSlug):this.getCollection(a);this.ensureTable(t,o.tableName),this.ensureVersionsTable();let s=await this.findByID({collection:a,id:n,tenantId:i,draft:true});if(!s)throw new Error(`Document not found: ${a}/${n}`);let l=`DELETE FROM ${o.tableName} WHERE id = ?`,c=[n];return i&&t.tenantScoped&&(l+=" AND tenant_id = ?",c.push(i)),this.db.prepare(l).run(...c),s}async count(e){let{collection:a,tenantId:n}=e,i=this.parseGlobalsSlug(a),o=i.isGlobal?this.globals.get(i.globalSlug):this.getCollection(a);this.ensureTable(o,i.tableName);let s=`SELECT COUNT(*) as count FROM ${i.tableName}`,r=[];return n&&o.tenantScoped&&(s+=" WHERE tenant_id = ?",r.push(n)),this.db.prepare(s).get(...r)?.count||0}async findOne(e){let a=this.parseGlobalsSlug(e.collection);if(a.isGlobal){let i=this.globals.get(a.globalSlug);if(!i)throw new Error(`Global "${a.globalSlug}" not found in adapter`);this.ensureTable(i,a.tableName);let o=`SELECT * FROM ${a.tableName}`,t=[],s=[],r=i.fields.find(d=>d.name==="status"),l=r?.type==="select"&&Array.isArray(r.options)&&r.options.some(d=>d.value==="published");!e.draft&&i.versions&&l&&t.push("status = 'published'"),t.length>0&&(o+=` WHERE ${t.join(" AND ")}`),o+=" LIMIT 1";let c=this.db.prepare(o).get(...s);if(c){let d=this.rowToDoc(c,i);if(e.draft){let y=this.db.prepare(`SELECT * FROM ${this.versionsTableName} WHERE collection_slug = ? AND document_id = ? AND tenant_id IS NULL ORDER BY version DESC LIMIT 1`).get(e.collection,a.globalSlug);if(y){let u=y.data?JSON.parse(y.data):{};d={...d,...u,status:d.status};}}return d}return null}return (await this.find({...e,limit:1})).docs[0]||null}async findVersions(e){this.ensureVersionsTable();let{collection:a,documentId:n,tenantId:i,limit:o=20,page:t=1}=e,s=["collection_slug = ?","document_id = ?","autosave = 0"],r=[a,n];i?(s.push("tenant_id = ?"),r.push(i)):s.push("tenant_id IS NULL");let l=`WHERE ${s.join(" AND ")}`,d=this.db.prepare(`SELECT COUNT(*) as count FROM ${this.versionsTableName} ${l}`).get(...r)?.count||0,y=(t-1)*o;return {docs:this.db.prepare(`SELECT * FROM ${this.versionsTableName} ${l} ORDER BY version DESC LIMIT ? OFFSET ?`).all(...r,o,y).map(f=>this.rowToVersion(f)),totalDocs:d,limit:o,totalPages:Math.ceil(d/o),page:t,pagingCounter:(t-1)*o+1,hasPrevPage:t>1,hasNextPage:t<Math.ceil(d/o),prevPage:t>1?t-1:null,nextPage:t<Math.ceil(d/o)?t+1:null}}async findVersionByID(e){this.ensureVersionsTable();let a=this.db.prepare(`SELECT * FROM ${this.versionsTableName} WHERE id = ? AND collection_slug = ? LIMIT 1`).get(e.versionId,e.collection);return a?this.rowToVersion(a):null}async createVersion(e){this.ensureVersionsTable();let a=new Date().toISOString();if(e.autosave){let s=`SELECT * FROM ${this.versionsTableName} WHERE collection_slug = ? AND document_id = ? AND autosave = 1`,r=[e.collection,e.documentId];e.tenantId?(s+=" AND tenant_id = ?",r.push(e.tenantId)):s+=" AND tenant_id IS NULL",s+=" LIMIT 1";let l=this.db.prepare(s).get(...r);if(l){this.db.prepare(`UPDATE ${this.versionsTableName} SET data = ?, status = ?, updated_at = ? WHERE id = ?`).run(JSON.stringify(e.data),e.status,a,l.id);let c=await this.findVersionByID({collection:e.collection,versionId:l.id});if(c)return c}}let n=this.generateId(),o=(this.db.prepare(`SELECT version FROM ${this.versionsTableName} WHERE collection_slug = ? AND document_id = ? AND autosave = 0 ORDER BY version DESC LIMIT 1`).get(e.collection,e.documentId)?.version??0)+1;if(this.db.prepare(`INSERT INTO ${this.versionsTableName} (
|
|
19
|
+
id, collection_slug, document_id, tenant_id, version, status, autosave, data, created_by, change_description, published_at, created_at, updated_at
|
|
20
|
+
) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`).run(n,e.collection,e.documentId,e.tenantId??null,o,e.status,e.autosave?1:0,JSON.stringify(e.data),e.createdBy??null,e.changeDescription??null,e.status==="published"?a:null,a,a),!e.autosave){let r=this.collections.get(e.collection)?.versions?.maxPerDoc;r&&r>0&&await this.deleteVersions({collection:e.collection,documentId:e.documentId,keepLatest:r,tenantId:e.tenantId});}return await this.findVersionByID({collection:e.collection,versionId:n})}async updateLatestVersion(e){return this.createVersion({...e,autosave:true})}async deleteVersions(e){this.ensureVersionsTable();let{collection:a,documentId:n,keepLatest:i,tenantId:o}=e;if(i&&i>0){let t=this.db.prepare(`SELECT id, status, autosave FROM ${this.versionsTableName} WHERE collection_slug = ? AND document_id = ? ORDER BY version DESC`).all(a,n),s=0,r=[];for(let l of t)l.status==="published"||l.autosave===1||(s++,s>i&&r.push(l.id));for(let l of r)this.db.prepare(`DELETE FROM ${this.versionsTableName} WHERE id = ?`).run(l);}else {let t=`DELETE FROM ${this.versionsTableName} WHERE collection_slug = ? AND document_id = ?`,s=[a,n];o&&(t+=" AND tenant_id = ?",s.push(o)),this.db.prepare(t).run(...s);}}rowToVersion(e){return {id:String(e.id),collection:e.collection_slug,documentId:e.document_id,version:e.version,status:e.status,data:e.data?JSON.parse(e.data):{},createdBy:e.created_by??void 0,changeDescription:e.change_description??void 0,publishedAt:e.published_at??null,createdAt:e.created_at,updatedAt:e.updated_at}}prepareData(e,a){let n={},i=N(a.fields),o=(t,s)=>{let r=t;if(r.type==="json"||r.type==="richtext"||r.type==="array"||r.type==="group"||r.type==="blocks"||r.type==="list"||r.type==="relationship-block")return s!=null?JSON.stringify(s):null;if(r.type==="checkbox")return s?1:0;if(r.type==="number")return s!==null&&s!==""?Number(s):null;if(r.type==="upload"||r.type==="image"){if(s==null)return null;if(Array.isArray(s)){let l=s.map(c=>typeof c=="string"?c:typeof c=="object"?c.id||c._id||c:String(c));return JSON.stringify(l)}return typeof s=="string"?s:typeof s=="object"?JSON.stringify(s):String(s)}else if(t.type==="relationship"){if(s==null)return null;if(Array.isArray(s)){let l=s.map(c=>typeof c=="string"?c:typeof c=="object"?JSON.stringify({relationTo:t.relationTo,value:c.id||c}):String(c));return JSON.stringify(l)}return typeof s=="string"?s:typeof s=="object"?JSON.stringify({relationTo:t.relationTo,value:s.id||s}):String(s)}return s};for(let t of i){if(!t.name||t.name==="id"||a.fields.some(l=>l.type==="tabs"&&l.name&&"tabs"in l&&l.tabs.some(c=>c.fields.some(d=>d.name===t.name))))continue;let r=e[t.name];r!==void 0&&(n[t.name]=o(t,r));}for(let t of a.fields)if(t.type==="tabs"&&"tabs"in t&&t.name){let s=e[t.name];if(s&&typeof s=="object"){for(let r of t.tabs)for(let l of r.fields)if(l.name&&l.name!=="id"){let c=s[l.name];c!==void 0&&(n[l.name]=o(l,c));}}}return n}rowToDoc(e,a){let n={id:e.id};for(let i of N(a.fields)){if(!i.name||i.name==="id")continue;let o=i,t=e[o.name];if(o.type==="json"||o.type==="richtext"||o.type==="array"||o.type==="group"||o.type==="blocks"||o.type==="list"||o.type==="relationship-block")try{t=t?JSON.parse(t):null;}catch{t=null;}if(o.type==="blocks"&&t&&Array.isArray(t)){let s=o.blocks||[];t=P(t,s);}if(i.type==="checkbox"&&(t=!!t),i.type==="date"&&t)try{let s=new Date(t);isNaN(s.getTime())?(console.warn(`[LocalAdapter] Invalid date value for field "${i.name}":`,t),t=null):t=s.toISOString();}catch{t=null;}if((i.type==="upload"||i.type==="image")&&t)try{let s=JSON.parse(t);Array.isArray(s)?t=s.map(r=>typeof r=="object"&&r!==null?r:{id:r}):t=typeof s=="object"?s:{id:s};}catch{t={id:t};}if(i.type==="relationship"&&t)try{let s=JSON.parse(t);Array.isArray(s),t=s;}catch{t={relationTo:Array.isArray(i.relationTo)?i.relationTo[0]:i.relationTo,value:t};}n[i.name]=t;}for(let i of a.fields)if(!(!i.name||i.name==="id"||i.name==="row"||i.name==="collapsible")&&i.type==="tabs"&&"tabs"in i){let o={};for(let t of i.tabs)for(let s of t.fields)s.name&&s.name!=="id"&&(o[s.name]=B(e,s));n[i.name]=o;}if(a.timestamps){let i=e.createdAt||e.created_at,o=e.updatedAt||e.updated_at;if(i)try{let t=new Date(i);isNaN(t.getTime())||(n.createdAt=t.toISOString());}catch{}if(o)try{let t=new Date(o);isNaN(t.getTime())||(n.updatedAt=t.toISOString());}catch{}}a.tenantScoped&&(n.tenantId=e.tenant_id),n.status=e.status??"published",n.hasDraft=e.hasDraft?!!e.hasDraft:false;for(let i of Object.keys(n))/^\d+$/.test(i)&&delete n[i];return n}generateId(){let e=Date.now().toString(16).padStart(12,"0"),a=randomBytes(6).toString("hex");return e+a}getMediaById(e){try{let a=this.getTableNameFor("media"),n=this.db.prepare(`SELECT id, url, thumbnail_url FROM ${a} WHERE id = ?`).get(e);if(n)return {id:n.id,url:n.url,thumbnailUrl:n.thumbnail_url||n.url}}catch{}return null}getTableNameFor(e){return e.replace(/-/g,"_")}async migrate(){for(let e of this.collections.values())this.ensureTable(e);}async rollback(){}async transaction(e){return new Promise((a,n)=>{let i=this.db.transaction(async()=>e({db:this.db}));try{let o=i();a(o);}catch(o){n(o);}})}getDatabase(){return this.db}exec(e){this.db.exec(e);}prepare(e){return this.db.prepare(e)}};function k(T){return new L(T||{})}export{L as a,k as b};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
'use strict';var chunkVRZC4TTF_cjs=require('./chunk-VRZC4TTF.cjs'),chunkBUNLC3II_cjs=require('./chunk-BUNLC3II.cjs');chunkBUNLC3II_cjs.h();chunkBUNLC3II_cjs.h();function p(r){return chunkVRZC4TTF_cjs.J`count(${r||chunkVRZC4TTF_cjs.J.raw("*")})`.mapWith(Number)}function a(r){return chunkVRZC4TTF_cjs.J`count(distinct ${r})`.mapWith(Number)}function s(r){return chunkVRZC4TTF_cjs.J`avg(${r})`.mapWith(String)}function x(r){return chunkVRZC4TTF_cjs.J`avg(distinct ${r})`.mapWith(String)}function y(r){return chunkVRZC4TTF_cjs.J`sum(${r})`.mapWith(String)}function g(r){return chunkVRZC4TTF_cjs.J`sum(distinct ${r})`.mapWith(String)}function A(r){return chunkVRZC4TTF_cjs.J`max(${r})`.mapWith(chunkVRZC4TTF_cjs.c(r,chunkVRZC4TTF_cjs.d)?r:String)}function h(r){return chunkVRZC4TTF_cjs.J`min(${r})`.mapWith(chunkVRZC4TTF_cjs.c(r,chunkVRZC4TTF_cjs.d)?r:String)}chunkBUNLC3II_cjs.h();function o(r){return JSON.stringify(r)}function d(r,t){return Array.isArray(t)?chunkVRZC4TTF_cjs.J`${r} <-> ${o(t)}`:chunkVRZC4TTF_cjs.J`${r} <-> ${t}`}function q(r,t){return Array.isArray(t)?chunkVRZC4TTF_cjs.J`${r} <+> ${o(t)}`:chunkVRZC4TTF_cjs.J`${r} <+> ${t}`}function N(r,t){return Array.isArray(t)?chunkVRZC4TTF_cjs.J`${r} <#> ${o(t)}`:chunkVRZC4TTF_cjs.J`${r} <#> ${t}`}function b(r,t){return Array.isArray(t)?chunkVRZC4TTF_cjs.J`${r} <=> ${o(t)}`:chunkVRZC4TTF_cjs.J`${r} <=> ${t}`}function j(r,t){return Array.isArray(t)?chunkVRZC4TTF_cjs.J`${r} <~> ${o(t)}`:chunkVRZC4TTF_cjs.J`${r} <~> ${t}`}function w(r,t){return Array.isArray(t)?chunkVRZC4TTF_cjs.J`${r} <%> ${o(t)}`:chunkVRZC4TTF_cjs.J`${r} <%> ${t}`}exports.a=p;exports.b=a;exports.c=s;exports.d=x;exports.e=y;exports.f=g;exports.g=A;exports.h=h;exports.i=d;exports.j=q;exports.k=N;exports.l=b;exports.m=j;exports.n=w;
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import {createRequire}from'module';import {a as a$1,h}from'./chunk-E27KEZPT.js';import {a}from'./chunk-BLH2MRK4.js';import {a as a$2}from'./chunk-6KRR7YHA.js';import {g}from'./chunk-C2PXMVR5.js';import {createHmac,randomBytes,randomUUID}from'crypto';createRequire(import.meta.url);
|
|
2
|
+
g();var _={COLLECTION_CREATE:"collection.create",COLLECTION_UPDATE:"collection.update",COLLECTION_DELETE:"collection.delete",MEDIA_UPLOAD:"media.upload",MEDIA_DELETE:"media.delete",AUTH_LOGIN:"auth.login",AUTH_REGISTER:"auth.register",AUTH_LOGOUT:"auth.logout",ORDER_CREATED:"order.created",ORDER_PAID:"order.paid",ORDER_SHIPPED:"order.shipped",ORDER_DELIVERED:"order.delivered"},G=Object.values(_);var k="_webhooks",w="_webhook_deliveries";g();g();g();g();async function L(o,t,s,e={}){let r=e.timeout||3e4,i=Date.now(),u=new AbortController,c=setTimeout(()=>u.abort(),r);try{let a=await fetch(o,{method:"POST",headers:t,body:s,signal:u.signal});clearTimeout(c);let n=Date.now()-i,l;try{l=(await a.text()).slice(0,1e3);}catch{}let d={success:a.ok,status:a.status,statusText:a.statusText,body:l,duration:n};return d.success&&e.onSuccess?e.onSuccess(d):!d.success&&e.onFailure&&e.onFailure(`HTTP ${a.status}: ${a.statusText}`),d}catch(a){clearTimeout(c);let n=Date.now()-i,l=a.name==="AbortError"?`Request timed out after ${r}ms`:a.message||"Unknown error";return e.onFailure&&e.onFailure(l),{success:false,status:0,duration:n,error:l}}}async function $(o,t,s={}){let e=JSON.stringify(t),r={"Content-Type":"application/json","User-Agent":"Kyro-CMS-Webhook/1.0","X-Webhook-Event":t.event,"X-Webhook-Delivery":t.id,"X-Webhook-Timestamp":t.timestamp,...o.headers||{}};return o.secret&&(r["X-Webhook-Signature"]=P(e,o.secret)),L(o.url,r,e,s)}g();async function j(o,t,s={}){let e=o.config||{},r=process.env.GITHUB_TOKEN;if(!r)return {success:false,status:0,duration:0,error:"GITHUB_TOKEN environment variable is not set"};if(!e.githubOwner||!e.githubRepo)return {success:false,status:0,duration:0,error:"GitHub owner and repo are required"};let i=e.githubBranch||"main",u=Date.now(),c=async(a,n,l)=>{let d=await fetch(a,{method:n,headers:{"Content-Type":"application/json",Accept:"application/vnd.github+json",Authorization:`Bearer ${r}`,"X-GitHub-Api-Version":"2022-11-28","User-Agent":"Kyro-CMS-Webhook/1.0"},body:l?JSON.stringify(l):void 0});if(!d.ok){let y=await d.text();throw new Error(`GitHub API HTTP ${d.status}: ${y}`)}return d.json()};try{let a=`https://api.github.com/repos/${e.githubOwner}/${e.githubRepo}/git/refs/heads/${i}`,l=(await c(a,"GET")).object.sha,d=`https://api.github.com/repos/${e.githubOwner}/${e.githubRepo}/git/commits/${l}`,f=(await c(d,"GET")).tree.sha,p=`https://api.github.com/repos/${e.githubOwner}/${e.githubRepo}/git/commits`,b=(await c(p,"POST",{message:`Content updated via Kyro CMS (${t.event})`,tree:f,parents:[l]})).sha;return await c(a,"PATCH",{sha:b,force:!1}),{success:!0,status:201,duration:Date.now()-u,body:`Successfully pushed empty commit ${b} to branch ${i}`}}catch(a){return {success:false,status:0,duration:Date.now()-u,error:a.message||"Failed to push empty commit to GitHub"}}}var K={generic:$,"github-push":j};function S(o){return K[o||"generic"]||K.generic}function P(o,t){return `sha256=${createHmac("sha256",t).update(o).digest("hex")}`}function x(){return randomBytes(32).toString("hex")}async function U(o,t,s={}){return S(o.action)(o,t,s)}async function I(o,t,s,e={}){let r=e.maxRetries??5,i=e.retryDelay??1e3,u=null;for(let c=0;c<=r;c++){if(c>0){let a=Math.min(i*Math.pow(2,c-1),3e4);e.onRetry&&e.onRetry(c,`Retrying in ${a}ms...`),await F(a);}if(e.onRetry&&c>0&&e.onRetry(c,`Attempt ${c+1}/${r+1}`),u=await U(o,t,{...e,onRetry:void 0,onSuccess:void 0,onFailure:void 0}),u.success)return u;if(!(u.error?.includes("timed out")&&c<r)&&u.status>=400&&u.status<500)return u}return u||{success:false,status:0,duration:0,error:"All delivery attempts failed"}}function H(o,t,s,e,r,i){return {id:o,webhookId:t,event:s,payload:e,attempt:r,status:i.success?"success":"failed",responseStatus:i.status||void 0,responseBody:i.body,duration:i.duration,error:i.error,createdAt:new Date().toISOString(),deliveredAt:i.success?new Date().toISOString():void 0}}function F(o){return new Promise(t=>setTimeout(t,o))}function z(){return {id:`test_${Date.now()}`,event:"collection.create",timestamp:new Date().toISOString(),collection:"test",operation:"create",data:{message:"This is a test webhook delivery"},user:{id:"system",email:"system@kyro.dev",role:"super_admin"}}}g();function N(o){let t=new Set,s=[];for(let e of o){let r=e==="create"||e==="update"||e==="delete"?`collection.${e}`:e;t.has(r)||(t.add(r),s.push(r));}return s}var O=class{db;constructor(t){this.db=t;}async getWebhooks(t){let e=(await this.db.find({collection:k,where:t?.status?{status:{equals:t.status}}:{},limit:100,page:1,draft:true})).docs;return t?.event?e.filter(r=>r.events.includes(t.event)):e}async getWebhookById(t){return this.db.findByID({collection:k,id:t,draft:true})}async createWebhook(t){let s=new Date().toISOString(),e=t.secret||x(),r={id:randomUUID(),name:t.name,url:t.url,events:N(t.events),collections:t.collections||[],status:t.status||"active",secret:e,headers:t.headers||{},action:t.action||"generic",config:t.config||{},createdAt:s,updatedAt:s};return await this.db.create({collection:k,data:r}),r}async updateWebhook(t,s){let e=await this.getWebhookById(t);if(!e)return null;let r={...e,...s,events:s.events?N(s.events):e.events,collections:s.collections!==void 0?s.collections:e.collections,action:s.action!==void 0?s.action:e.action,config:s.config!==void 0?{...e.config,...s.config}:e.config,updatedAt:new Date().toISOString()};return s.secret===""&&"secret"in s&&delete r.secret,await this.db.update({collection:k,id:t,data:r}),r}async deleteWebhook(t){await this.db.delete({collection:k,id:t});}async trigger(t,s){let e=await this.getWebhooks({status:"active",event:t}),r=s.collection,i=e.filter(a=>!a.collections||a.collections.length===0||!r?true:a.collections.includes(r));if(i.length===0)return [];let u={id:randomUUID(),event:t,timestamp:new Date().toISOString(),...s},c=[];for(let a of i){let n=await this.triggerWebhook(a,u);c.push(n);}return c}async triggerWebhook(t,s){let e=randomUUID();try{let r=await I(t,s,e,{maxRetries:5,retryDelay:1e3}),i=H(e,t.id,t.events[0],s,1,r);try{await this.db.create({collection:w,data:i});}catch{console.warn("[WebhookService] Failed to save delivery record:",e);}return r.success?await this.updateWebhook(t.id,{lastTriggered:new Date().toISOString(),lastError:null}).catch(()=>{}):await this.updateWebhook(t.id,{lastError:r.error||`HTTP ${r.status}`}).catch(()=>{}),{deliveryId:e,webhookId:t.id,event:t.events[0],status:r.success?"success":"failed",responseStatus:r.status,duration:r.duration,error:r.error}}catch(r){return {deliveryId:e,webhookId:t.id,event:t.events[0],status:"failed",error:r.message}}}async testWebhook(t){let s=await this.getWebhookById(t);if(!s)return null;let e={id:randomUUID(),event:s.events[0]||"collection.create",timestamp:new Date().toISOString(),collection:"test",operation:"create",data:{message:"This is a test webhook delivery from Kyro CMS"},user:{id:"system",email:"system@kyro.dev",role:"super_admin"}};return this.triggerWebhook(s,e)}async getDeliveryHistory(t,s=50){return (await this.db.find({collection:w,where:{webhookId:{equals:t}},sort:"-createdAt",limit:s,page:1})).docs}async retryDelivery(t){let s=await this.db.findByID({collection:w,id:t});if(!s)return null;let e=await this.getWebhookById(s.webhookId);return e?this.triggerWebhook(e,s.payload):null}};function X(o){return new O(o)}g();g();function Y(o){if(!o)return [];if(typeof o=="string")return [{id:o}];if(Array.isArray(o))return o.map(t=>typeof t=="object"?{id:t.value??t.id??t,relationTo:t.relationTo}:{id:t});if(typeof o=="object"){let t=o.value??o.id??o;if(typeof t=="string")return [{id:t,relationTo:o.relationTo}];if(Array.isArray(t))return t.map(s=>({id:s,relationTo:o.relationTo}))}return []}function W(o,t,s){if(!(!o||typeof o!="object")){for(let e of t)if(!(!e.name&&e.type!=="row"&&e.type!=="collapsible"&&e.type!=="tabs")){if(e.type==="relationship"||e.type==="upload")s(e,o);else if(e.type==="group"||e.type==="collapsible"||e.type==="row"){let r=e.name?o[e.name]:o;W(r,e.fields||[],s);}else if(e.type==="tabs"&&e.tabs){let r=e.name?o[e.name]:o;for(let i of e.tabs)W(r,i.fields||[],s);}else if(e.type==="array"&&e.name&&Array.isArray(o[e.name]))for(let r of o[e.name])W(r,e.fields||[],s);else if(e.type==="blocks"&&e.name&&Array.isArray(o[e.name]))for(let r of o[e.name]){if(!r||typeof r!="object")continue;let i=r.type||r.blockType;if(!i)continue;let u=e.blocks?.find(c=>c.slug===i);if(u&&Array.isArray(u.fields)){let c=r.data&&typeof r.data=="object"?r.data:r;W(c,u.fields,s);}}}}}function J(o,t,s){W(o,t,(e,r)=>{let i=r[e.name];if(!i)return;let u=Array.isArray(e.relationTo)?e.relationTo:[e.relationTo],c=Y(i);for(let a of c){if(!a.id)continue;let n=a.relationTo?[a.relationTo]:u;for(let l of n)l!=="*"&&(s.has(l)||s.set(l,new Set),s.get(l).add(a.id));}});}function Q(o,t,s){W(o,t,(e,r)=>{let i=r[e.name];if(!i)return;let u=Array.isArray(e.relationTo)?e.relationTo:[e.relationTo],c=n=>{r[e.name]=n;},a=(n,l)=>{let d=l?[l]:u;for(let y of d){let f=s.get(y);if(f&&f.has(n))return f.get(n)}return null};if(typeof i=="string"){let n=a(i);c(n||{id:i});}else if(Array.isArray(i))c(i.map(n=>{let l=typeof n=="object"?n.value??n.id:n,d=typeof n=="object"?n.relationTo:void 0,y=a(l,d);return y||{id:l}}));else if(typeof i=="object"){let n=i.value??i.id,l=i.relationTo,d=a(n,l);c(d||{id:n});}});}async function Z(o,t,s,e,r=1,i=0){if(!o||o.length===0||r>i)return;let u=new Map;for(let n of o)J(n,t,u);if(u.size===0)return;let c=new Map,a$1=new Map;for(let[n,l]of u.entries()){if(l.size===0||!e.getCollection(n))continue;let y=new Map,f=Array.from(l),p=[];for(let E of f){try{let v=(await s.find({collection:n,where:{id:{in:f}},limit:f.length,draft:!0}))?.docs||[];for(let A of v)A&&A.id&&(y.set(String(A.id),A),p.push(A));}catch{for(let b of f)try{let v=await s.findByID({collection:n,id:b,draft:!0});v&&(y.set(b,v),p.push(v));}catch{}}break}c.set(n,y),p.length>0&&a$1.set(n,p);}if(r<i)for(let[n,l]of a$1.entries()){let d=e.getCollection(n);d&&await Z(l,d.fields,s,e,r+1,i);}for(let n=0;n<o.length;n++)Q(o[n],t,c),o[n]=a(o[n]);}g();function M(o){return o==="read"?"read":o==="create"?"create":o==="update"?"update":"delete"}function ee(o,t){return {none:false,read:o==="read",create:o==="read"||o==="create",update:o==="read"||o==="create"||o==="update",delete:o==="read"||o==="create"||o==="update"||o==="delete",admin:true}[t]||false}async function Le(o,t,s,e={}){let{user:r,req:i,tenantId:u,apiKey:c}=s,{enablePublicAccess:a=true,defaultAccess:n="none"}=e,l=o.access?.[t];if(l){let y=await a$1(l,{req:i,user:r,tenantId:u});return y===false?{allowed:false,error:"Access denied",status:403}:typeof y=="object"?{allowed:true,extraWhere:y}:{allowed:true}}if(c?.permissions?.length>0){let y=o.slug,f=M(t),p=`${y}:${f}`;return !h(c.permissions,p)&&!h(c.permissions,`${y}:admin`)?{allowed:false,error:"Access denied: insufficient permissions",status:403}:{allowed:true}}if(r){let y=o.slug,f=M(t),p=`${y}:${f}`,E=a$2({id:r.id,email:r.email,role:r.role},p),b=a$2({id:r.id,email:r.email,role:r.role},`${y}:admin`);return E||b?{allowed:true}:{allowed:false,error:"Access denied: missing RBAC permission",status:403}}let d=ee(t,n);return a&&d?{allowed:true}:{allowed:false,error:"Authentication required",status:401}}async function $e(o,t,s,e={}){let{user:r,req:i,tenantId:u}=s,{enablePublicAccess:c=true}=e,a=o.access?.[t];if(a)return await a$1(a,{req:i,user:r,tenantId:u})===false?{allowed:false,error:"Access denied",status:403}:{allowed:true};if(r){let n=`globals:${t}`,l=a$2({id:r.id,email:r.email,role:r.role},n),d=a$2({id:r.id,email:r.email,role:r.role},"globals:admin");return l||d?{allowed:true}:{allowed:false,error:"Access denied: missing RBAC permission",status:403}}return c?{allowed:true}:{allowed:false,error:"Authentication required",status:401}}
|
|
3
|
+
export{Z as a,Le as b,$e as c,_ as d,G as e,k as f,w as g,P as h,x as i,U as j,I as k,H as l,z as m,O as n,X as o};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import {createRequire}from'module';import {b}from'./chunk-VBPAAQEF.js';import {f,R as R$1,h,g as g$1,S as S$1,X as X$1,p,n,P,j,Q,d as d$1}from'./chunk-IP6JUEH3.js';import {t,a,Y,N,J as J$1,c,A,d,R,v,i,l,H as H$1,w,e,f as f$1,_}from'./chunk-7AQSH3KR.js';import {g}from'./chunk-C2PXMVR5.js';createRequire(import.meta.url);
|
|
2
|
+
g();g();g();var X=class{static[a]="SQLiteForeignKeyBuilder";reference;_onUpdate;_onDelete;constructor(e,t){this.reference=()=>{let{name:n,columns:s,foreignColumns:o}=e();return {name:n,columns:s,foreignTable:o[0].table,foreignColumns:o}},t&&(this._onUpdate=t.onUpdate,this._onDelete=t.onDelete);}onUpdate(e){return this._onUpdate=e,this}onDelete(e){return this._onDelete=e,this}build(e){return new re(e,this)}},re=class{constructor(e,t){this.table=e,this.reference=t.reference,this.onUpdate=t._onUpdate,this.onDelete=t._onDelete;}static[a]="SQLiteForeignKey";reference;onUpdate;onDelete;getName(){let{name:e,columns:t,foreignColumns:n}=this.reference(),s=t.map(r=>r.name),o=n.map(r=>r.name),u=[this.table[f$1],...s,n[0].table[f$1],...o];return e??`${u.join("_")}_fk`}};g();function ue(a,e){return `${a[f$1]}_${e.join("_")}_unique`}var q=class extends e{static[a]="SQLiteColumnBuilder";foreignKeyConfigs=[];references(e,t={}){return this.foreignKeyConfigs.push({ref:e,actions:t}),this}unique(e){return this.config.isUnique=true,this.config.uniqueName=e,this}generatedAlwaysAs(e,t){return this.config.generated={as:e,type:"always",mode:t?.mode??"virtual"},this}buildForeignKeys(e,t){return this.foreignKeyConfigs.map(({ref:n,actions:s})=>((o,u)=>{let r=new X(()=>{let c=o();return {columns:[e],foreignColumns:[c]}});return u.onUpdate&&r.onUpdate(u.onUpdate),u.onDelete&&r.onDelete(u.onDelete),r.build(t)})(n,s))}},S=class extends d{constructor(e,t){t.uniqueName||(t.uniqueName=ue(e,[t.name])),super(e,t),this.table=e;}static[a]="SQLiteColumn"};var k=class extends q{static[a]="SQLiteBaseIntegerBuilder";constructor(e,t,n){super(e,t,n),this.config.autoIncrement=false;}primaryKey(e){return e?.autoIncrement&&(this.config.autoIncrement=true),this.config.hasDefault=true,super.primaryKey()}},J=class extends S{static[a]="SQLiteBaseInteger";autoIncrement=this.config.autoIncrement;getSQLType(){return "integer"}},ae=class extends k{static[a]="SQLiteIntegerBuilder";constructor(e){super(e,"number","SQLiteInteger");}build(e){return new le(e,this.config)}},le=class extends J{static[a]="SQLiteInteger"},me=class extends k{static[a]="SQLiteTimestampBuilder";constructor(e,t){super(e,"date","SQLiteTimestamp"),this.config.mode=t;}defaultNow(){return this.default(J$1`(cast((julianday('now') - 2440587.5)*86400000 as integer))`)}build(e){return new ce(e,this.config)}},ce=class extends J{static[a]="SQLiteTimestamp";mode=this.config.mode;mapFromDriverValue(e){return this.config.mode==="timestamp"?new Date(e*1e3):new Date(e)}mapToDriverValue(e){let t=e.getTime();return this.config.mode==="timestamp"?Math.floor(t/1e3):t}},fe=class extends k{static[a]="SQLiteBooleanBuilder";constructor(e,t){super(e,"boolean","SQLiteBoolean"),this.config.mode=t;}build(e){return new de(e,this.config)}},de=class extends J{static[a]="SQLiteBoolean";mode=this.config.mode;mapFromDriverValue(e){return Number(e)===1}mapToDriverValue(e){return e?1:0}};function Ge(a,e){let{name:t,config:n}=Y(a,e);return n?.mode==="timestamp"||n?.mode==="timestamp_ms"?new me(t,n.mode):n?.mode==="boolean"?new fe(t,n.mode):new ae(t)}g();var pe=class extends q{static[a]="SQLiteNumericBuilder";constructor(e){super(e,"string","SQLiteNumeric");}build(e){return new he(e,this.config)}},he=class extends S{static[a]="SQLiteNumeric";mapFromDriverValue(e){return typeof e=="string"?e:String(e)}getSQLType(){return "numeric"}},ge=class extends q{static[a]="SQLiteNumericNumberBuilder";constructor(e){super(e,"number","SQLiteNumericNumber");}build(e){return new ye(e,this.config)}},ye=class extends S{static[a]="SQLiteNumericNumber";mapFromDriverValue(e){return typeof e=="number"?e:Number(e)}mapToDriverValue=String;getSQLType(){return "numeric"}},be=class extends q{static[a]="SQLiteNumericBigIntBuilder";constructor(e){super(e,"bigint","SQLiteNumericBigInt");}build(e){return new Se(e,this.config)}},Se=class extends S{static[a]="SQLiteNumericBigInt";mapFromDriverValue=BigInt;mapToDriverValue=String;getSQLType(){return "numeric"}};function He(a,e){let{name:t,config:n}=Y(a,e),s=n?.mode;return s==="number"?new ge(t):s==="bigint"?new be(t):new pe(t)}g();var $e=class extends q{static[a]="SQLiteTextBuilder";constructor(e,t){super(e,"string","SQLiteText"),this.config.enumValues=t.enum,this.config.length=t.length;}build(e){return new Te(e,this.config)}},Te=class extends S{static[a]="SQLiteText";enumValues=this.config.enumValues;length=this.config.length;constructor(e,t){super(e,t);}getSQLType(){return `text${this.config.length?`(${this.config.length})`:""}`}},Ce=class extends q{static[a]="SQLiteTextJsonBuilder";constructor(e){super(e,"json","SQLiteTextJson");}build(e){return new we(e,this.config)}},we=class extends S{static[a]="SQLiteTextJson";getSQLType(){return "text"}mapFromDriverValue(e){return JSON.parse(e)}mapToDriverValue(e){return JSON.stringify(e)}};function Ze(a,e={}){let{name:t,config:n}=Y(a,e);return n.mode==="json"?new Ce(t):new $e(t,n)}g();g();g();var Le=class extends q{static[a]="SQLiteBigIntBuilder";constructor(e){super(e,"bigint","SQLiteBigInt");}build(e){return new qe(e,this.config)}},qe=class extends S{static[a]="SQLiteBigInt";getSQLType(){return "blob"}mapFromDriverValue(e){if(typeof Buffer<"u"&&Buffer.from){let t=Buffer.isBuffer(e)?e:e instanceof ArrayBuffer?Buffer.from(e):e.buffer?Buffer.from(e.buffer,e.byteOffset,e.byteLength):Buffer.from(e);return BigInt(t.toString("utf8"))}return BigInt(_.decode(e))}mapToDriverValue(e){return Buffer.from(e.toString())}},xe=class extends q{static[a]="SQLiteBlobJsonBuilder";constructor(e){super(e,"json","SQLiteBlobJson");}build(e){return new Qe(e,this.config)}},Qe=class extends S{static[a]="SQLiteBlobJson";getSQLType(){return "blob"}mapFromDriverValue(e){if(typeof Buffer<"u"&&Buffer.from){let t=Buffer.isBuffer(e)?e:e instanceof ArrayBuffer?Buffer.from(e):e.buffer?Buffer.from(e.buffer,e.byteOffset,e.byteLength):Buffer.from(e);return JSON.parse(t.toString("utf8"))}return JSON.parse(_.decode(e))}mapToDriverValue(e){return Buffer.from(JSON.stringify(e))}},Be=class extends q{static[a]="SQLiteBlobBufferBuilder";constructor(e){super(e,"buffer","SQLiteBlobBuffer");}build(e){return new Ne(e,this.config)}},Ne=class extends S{static[a]="SQLiteBlobBuffer";mapFromDriverValue(e){return Buffer.isBuffer(e)?e:Buffer.from(e)}getSQLType(){return "blob"}};function et(a,e){let{name:t,config:n}=Y(a,e);return n?.mode==="json"?new xe(t):n?.mode==="bigint"?new Le(t):new Be(t)}g();var Oe=class extends q{static[a]="SQLiteCustomColumnBuilder";constructor(e,t,n){super(e,"custom","SQLiteCustomColumn"),this.config.fieldConfig=t,this.config.customTypeParams=n;}build(e){return new ve(e,this.config)}},ve=class extends S{static[a]="SQLiteCustomColumn";sqlName;mapTo;mapFrom;constructor(e,t){super(e,t),this.sqlName=t.customTypeParams.dataType(t.fieldConfig),this.mapTo=t.customTypeParams.toDriver,this.mapFrom=t.customTypeParams.fromDriver;}getSQLType(){return this.sqlName}mapFromDriverValue(e){return typeof this.mapFrom=="function"?this.mapFrom(e):e}mapToDriverValue(e){return typeof this.mapTo=="function"?this.mapTo(e):e}};function tt(a){return (e,t)=>{let{name:n,config:s}=Y(e,t);return new Oe(n,s,a)}}g();var _e=class extends q{static[a]="SQLiteRealBuilder";constructor(e){super(e,"number","SQLiteReal");}build(e){return new De(e,this.config)}},De=class extends S{static[a]="SQLiteReal";getSQLType(){return "real"}};function it(a){return new _e(a??"")}function nt(){return {blob:et,customType:tt,integer:Ge,numeric:He,real:it,text:Ze}}var Ke=Symbol.for("drizzle:SQLiteInlineForeignKeys"),F=class extends t{static[a]="SQLiteTable";static Symbol=Object.assign({},t.Symbol,{InlineForeignKeys:Ke});[t.Symbol.Columns];[Ke]=[];[t.Symbol.ExtraConfigBuilder]=void 0};function lt(a,e,t$1,n,s=a){let o=new F(a,n,s),u=typeof e=="function"?e(nt()):e,r=Object.fromEntries(Object.entries(u).map(([f,p])=>{let $=p;$.setName(f);let x=$.build(o);return o[Ke].push(...$.buildForeignKeys(x,o)),[f,x]})),c=Object.assign(o,r);return c[t.Symbol.Columns]=r,c[t.Symbol.ExtraConfigColumns]=r,t$1&&(c[F.Symbol.ExtraConfigBuilder]=t$1),c}var fi=(a,e,t)=>lt(a,e,t);g();g();var G=class extends N{static[a]="SQLiteViewBase"};var H=class{static[a]="SQLiteDialect";casing;constructor(e){this.casing=new b(e?.casing);}escapeName(e){return `"${e}"`}escapeParam(e){return "?"}escapeString(e){return `'${e.replace(/'/g,"''")}'`}buildWithCTE(e){if(!e?.length)return;let t=[J$1`with `];for(let[n,s]of e.entries())t.push(J$1`${J$1.identifier(s._.alias)} as (${s._.sql})`),n<e.length-1&&t.push(J$1`, `);return t.push(J$1` `),J$1.join(t)}buildDeleteQuery({table:e,where:t,returning:n,withList:s,limit:o,orderBy:u}){let r=this.buildWithCTE(s),c=n?J$1` returning ${this.buildSelection(n,{isSingleTable:true})}`:void 0,f=t?J$1` where ${t}`:void 0,p=this.buildOrderBy(u),$=this.buildLimit(o);return J$1`${r}delete from ${e}${f}${c}${p}${$}`}buildUpdateSet(e,t$1){let n=e[t.Symbol.Columns],s=Object.keys(n).filter(u=>t$1[u]!==void 0||n[u]?.onUpdateFn!==void 0),o=s.length;return J$1.join(s.flatMap((u,r)=>{let c=n[u],f=t$1[u]??J$1.param(c.onUpdateFn(),c),p=J$1`${J$1.identifier(this.casing.getColumnCasing(c))} = ${f}`;return r<o-1?[p,J$1.raw(", ")]:[p]}))}buildUpdateQuery({table:e,set:t,where:n,returning:s,withList:o,joins:u,from:r,limit:c,orderBy:f}){let p=this.buildWithCTE(o),$=this.buildUpdateSet(e,t),x=r&&J$1.join([J$1.raw(" from "),this.buildFromTable(r)]),Q=this.buildJoins(u),w=s?J$1` returning ${this.buildSelection(s,{isSingleTable:true})}`:void 0,b=n?J$1` where ${n}`:void 0,T=this.buildOrderBy(f),C=this.buildLimit(c);return J$1`${p}update ${e} set ${$}${x}${Q}${b}${w}${T}${C}`}buildSelection(e,{isSingleTable:t$1=false}={}){let n=e.length,s=e.flatMap(({field:o},u)=>{let r=[];if(c(o,A.Aliased)&&o.isSelectionField)r.push(J$1.identifier(o.fieldAlias));else if(c(o,A.Aliased)||c(o,A)){let c$1=c(o,A.Aliased)?o.sql:o;t$1?r.push(new A(c$1.queryChunks.map(f=>c(f,d)?J$1.identifier(this.casing.getColumnCasing(f)):f))):r.push(c$1),c(o,A.Aliased)&&r.push(J$1` as ${J$1.identifier(o.fieldAlias)}`);}else if(c(o,d)){let c=o.table[t.Symbol.Name];o.columnType==="SQLiteNumericBigInt"?t$1?r.push(J$1`cast(${J$1.identifier(this.casing.getColumnCasing(o))} as text)`):r.push(J$1`cast(${J$1.identifier(c)}.${J$1.identifier(this.casing.getColumnCasing(o))} as text)`):t$1?r.push(J$1.identifier(this.casing.getColumnCasing(o))):r.push(J$1`${J$1.identifier(c)}.${J$1.identifier(this.casing.getColumnCasing(o))}`);}return u<n-1&&r.push(J$1`, `),r});return J$1.join(s)}buildJoins(e){if(!e||e.length===0)return;let t=[];if(e)for(let[n,s]of e.entries()){n===0&&t.push(J$1` `);let o=s.table,u=s.on?J$1` on ${s.on}`:void 0;if(c(o,F)){let r=o[F.Symbol.Name],c=o[F.Symbol.Schema],f=o[F.Symbol.OriginalName],p=r===f?void 0:s.alias;t.push(J$1`${J$1.raw(s.joinType)} join ${c?J$1`${J$1.identifier(c)}.`:void 0}${J$1.identifier(f)}${p&&J$1` ${J$1.identifier(p)}`}${u}`);}else t.push(J$1`${J$1.raw(s.joinType)} join ${o}${u}`);n<e.length-1&&t.push(J$1` `);}return J$1.join(t)}buildLimit(e){return typeof e=="object"||typeof e=="number"&&e>=0?J$1` limit ${e}`:void 0}buildOrderBy(e){let t=[];if(e)for(let[n,s]of e.entries())t.push(s),n<e.length-1&&t.push(J$1`, `);return t.length>0?J$1` order by ${J$1.join(t)}`:void 0}buildFromTable(e){return c(e,t)&&e[t.Symbol.IsAlias]?J$1`${J$1`${J$1.identifier(e[t.Symbol.Schema]??"")}.`.if(e[t.Symbol.Schema])}${J$1.identifier(e[t.Symbol.OriginalName])} ${J$1.identifier(e[t.Symbol.Name])}`:e}buildSelectQuery({withList:e,fields:t$1,fieldsFlat:n,where:s,having:o,table:u,joins:r,orderBy:c$1,groupBy:f,limit:p,offset:$,distinct:x,setOperators:Q}){let w=n??R(t$1);for(let K of w)if(c(K.field,d)&&v(K.field.table)!==(c(u,i)?u._.alias:c(u,G)?u[l].name:c(u,A)?void 0:v(u))&&!(j=>r?.some(({alias:Y})=>Y===(j[t.Symbol.IsAlias]?v(j):j[t.Symbol.BaseName])))(K.field.table)){let j=v(K.field.table);throw new Error(`Your "${K.path.join("->")}" field references a column "${j}"."${K.field.name}", but the table "${j}" is not part of the query! Did you forget to join it?`)}let b=!r||r.length===0,T=this.buildWithCTE(e),C=x?J$1` distinct`:void 0,O=this.buildSelection(w,{isSingleTable:b}),B=this.buildFromTable(u),h=this.buildJoins(r),V=s?J$1` where ${s}`:void 0,v$1=o?J$1` having ${o}`:void 0,m=[];if(f)for(let[K,j]of f.entries())m.push(j),K<f.length-1&&m.push(J$1`, `);let g=m.length>0?J$1` group by ${J$1.join(m)}`:void 0,R$1=this.buildOrderBy(c$1),P=this.buildLimit(p),Z=$?J$1` offset ${$}`:void 0,A$1=J$1`${T}select${C} ${O} from ${B}${h}${V}${g}${v$1}${R$1}${P}${Z}`;return Q.length>0?this.buildSetOperations(A$1,Q):A$1}buildSetOperations(e,t){let[n,...s]=t;if(!n)throw new Error("Cannot pass undefined values to any set operator");return s.length===0?this.buildSetOperationQuery({leftSelect:e,setOperator:n}):this.buildSetOperations(this.buildSetOperationQuery({leftSelect:e,setOperator:n}),s)}buildSetOperationQuery({leftSelect:e,setOperator:{type:t,isAll:n,rightSelect:s,limit:o,orderBy:u,offset:r}}){let c$1=J$1`${e.getSQL()} `,f=J$1`${s.getSQL()}`,p;if(u&&u.length>0){let w=[];for(let b of u)if(c(b,S))w.push(J$1.identifier(b.name));else if(c(b,A)){for(let T=0;T<b.queryChunks.length;T++){let C=b.queryChunks[T];c(C,S)&&(b.queryChunks[T]=J$1.identifier(this.casing.getColumnCasing(C)));}w.push(J$1`${b}`);}else w.push(J$1`${b}`);p=J$1` order by ${J$1.join(w,J$1`, `)}`;}let $=typeof o=="object"||typeof o=="number"&&o>=0?J$1` limit ${o}`:void 0,x=J$1.raw(`${t} ${n?"all ":""}`),Q=r?J$1` offset ${r}`:void 0;return J$1`${c$1}${x}${f}${p}${$}${Q}`}buildInsertQuery({table:e,values:t$1,onConflict:n,returning:s,withList:o,select:u}){let r=[],c$1=e[t.Symbol.Columns],f=Object.entries(c$1).filter(([b,T])=>!T.shouldDisableInsert()),p=f.map(([,b])=>J$1.identifier(this.casing.getColumnCasing(b)));if(u){let b=t$1;c(b,A)?r.push(b):r.push(b.getSQL());}else {let b=t$1;r.push(J$1.raw("values "));for(let[T,C]of b.entries()){let O=[];for(let[B,h]of f){let V=C[B];if(V===void 0||c(V,H$1)&&V.value===void 0){let v;if(h.default!==null&&h.default!==void 0)v=c(h.default,A)?h.default:J$1.param(h.default,h);else if(h.defaultFn!==void 0){let m=h.defaultFn();v=c(m,A)?m:J$1.param(m,h);}else if(!h.default&&h.onUpdateFn!==void 0){let m=h.onUpdateFn();v=c(m,A)?m:J$1.param(m,h);}else v=J$1`null`;O.push(v);}else O.push(V);}r.push(O),T<b.length-1&&r.push(J$1`, `);}}let $=this.buildWithCTE(o),x=J$1.join(r),Q=s?J$1` returning ${this.buildSelection(s,{isSingleTable:true})}`:void 0,w=n?.length?J$1.join(n):void 0;return J$1`${$}insert into ${e} ${p} ${x}${w}${Q}`}sqlToQuery(e,t){return e.toQuery({casing:this.casing,escapeName:this.escapeName,escapeParam:this.escapeParam,escapeString:this.escapeString,invokeSource:t})}buildRelationalQuery({fullSchema:e,schema:t,tableNamesMap:n$1,table:s,tableConfig:o,queryConfig:u,tableAlias:r,nestedQueryRelation:c$1,joinOn:f$1}){let p$1=[],$,x,Q$1=[],w$1,b=[];if(u===true)p$1=Object.entries(o.columns).map(([O,B])=>({dbKey:B.name,tsKey:O,field:f(B,r),relationTableTsKey:void 0,isJson:false,selection:[]}));else {let C=Object.fromEntries(Object.entries(o.columns).map(([m,g])=>[m,f(g,r)]));if(u.where){let m=typeof u.where=="function"?u.where(C,R$1()):u.where;w$1=m&&h(m,r);}let O=[],B=[];if(u.columns){let m=false;for(let[g,R]of Object.entries(u.columns))R!==void 0&&g in o.columns&&(!m&&R===true&&(m=true),B.push(g));B.length>0&&(B=m?B.filter(g=>u.columns?.[g]===true):Object.keys(o.columns).filter(g=>!B.includes(g)));}else B=Object.keys(o.columns);for(let m of B){let g=o.columns[m];O.push({tsKey:m,value:g});}let h$1=[];u.with&&(h$1=Object.entries(u.with).filter(m=>!!m[1]).map(([m,g])=>({tsKey:m,queryConfig:g,relation:o.relations[m]})));let V;if(u.extras){V=typeof u.extras=="function"?u.extras(C,{sql:J$1}):u.extras;for(let[m,g]of Object.entries(V))O.push({tsKey:m,value:g$1(g,r)});}for(let{tsKey:m,value:g}of O)p$1.push({dbKey:c(g,A.Aliased)?g.fieldAlias:o.columns[m].name,tsKey:m,field:c(g,d)?f(g,r):g,relationTableTsKey:void 0,isJson:false,selection:[]});let v=typeof u.orderBy=="function"?u.orderBy(C,S$1()):u.orderBy??[];Array.isArray(v)||(v=[v]),Q$1=v.map(m=>c(m,d)?f(m,r):h(m,r)),$=u.limit,x=u.offset;for(let{tsKey:m,queryConfig:g,relation:R}of h$1){let P$1=X$1(t,n$1,R),Z=w(R.referencedTable),A=n$1[Z],K=`${r}_${m}`,j=p(...P$1.fields.map((ut,at)=>n(f(P$1.references[at],K),f(ut,r)))),Y=this.buildRelationalQuery({fullSchema:e,schema:t,tableNamesMap:n$1,table:e[A],tableConfig:t[A],queryConfig:c(R,P)?g===true?{limit:1}:{...g,limit:1}:g,tableAlias:K,joinOn:j,nestedQueryRelation:R}),st=J$1`(${Y.sql})`.as(m);p$1.push({dbKey:m,tsKey:m,field:st,relationTableTsKey:A,isJson:true,selection:Y.selection});}}if(p$1.length===0)throw new j({message:`No fields selected for table "${o.tsName}" ("${r}"). You need to have at least one item in "columns", "with" or "extras". If you need to select all columns, omit the "columns" key or set it to undefined.`});let T;if(w$1=p(f$1,w$1),c$1){let C=J$1`json_array(${J$1.join(p$1.map(({field:h})=>c(h,S)?J$1.identifier(this.casing.getColumnCasing(h)):c(h,A.Aliased)?h.sql:h),J$1`, `)})`;c(c$1,Q)&&(C=J$1`coalesce(json_group_array(${C}), json_array())`);let O=[{dbKey:"data",tsKey:"data",field:C.as("data"),isJson:true,relationTableTsKey:o.tsName,selection:p$1}];$!==void 0||x!==void 0||Q$1.length>0?(T=this.buildSelectQuery({table:d$1(s,r),fields:{},fieldsFlat:[{path:[],field:J$1.raw("*")}],where:w$1,limit:$,offset:x,orderBy:Q$1,setOperators:[]}),w$1=void 0,$=void 0,x=void 0,Q$1=void 0):T=d$1(s,r),T=this.buildSelectQuery({table:c(T,F)?T:new i(T,{},r),fields:{},fieldsFlat:O.map(({field:h})=>({path:[],field:c(h,d)?f(h,r):h})),joins:b,where:w$1,limit:$,offset:x,orderBy:Q$1,setOperators:[]});}else T=this.buildSelectQuery({table:d$1(s,r),fields:{},fieldsFlat:p$1.map(({field:C})=>({path:[],field:c(C,d)?f(C,r):C})),joins:b,where:w$1,limit:$,offset:x,orderBy:Q$1,setOperators:[]});return {tableTsKey:o.tsName,sql:T,selection:p$1}}},rt=class extends H{static[a]="SQLiteSyncDialect";migrate(e,t,n){let s=n===void 0||typeof n=="string"?"__drizzle_migrations":n.migrationsTable??"__drizzle_migrations",o=J$1`
|
|
3
|
+
CREATE TABLE IF NOT EXISTS ${J$1.identifier(s)} (
|
|
4
|
+
id SERIAL PRIMARY KEY,
|
|
5
|
+
hash text NOT NULL,
|
|
6
|
+
created_at numeric
|
|
7
|
+
)
|
|
8
|
+
`;t.run(o);let r=t.values(J$1`SELECT id, hash, created_at FROM ${J$1.identifier(s)} ORDER BY created_at DESC LIMIT 1`)[0]??void 0;t.run(J$1`BEGIN`);try{for(let c of e)if(!r||Number(r[2])<c.folderMillis){for(let f of c.sql)t.run(J$1.raw(f));t.run(J$1`INSERT INTO ${J$1.identifier(s)} ("hash", "created_at") VALUES(${c.hash}, ${c.folderMillis})`);}t.run(J$1`COMMIT`);}catch(c){throw t.run(J$1`ROLLBACK`),c}}},ot=class extends H{static[a]="SQLiteAsyncDialect";async migrate(e,t,n){let s=n===void 0||typeof n=="string"?"__drizzle_migrations":n.migrationsTable??"__drizzle_migrations",o=J$1`
|
|
9
|
+
CREATE TABLE IF NOT EXISTS ${J$1.identifier(s)} (
|
|
10
|
+
id SERIAL PRIMARY KEY,
|
|
11
|
+
hash text NOT NULL,
|
|
12
|
+
created_at numeric
|
|
13
|
+
)
|
|
14
|
+
`;await t.run(o);let r=(await t.values(J$1`SELECT id, hash, created_at FROM ${J$1.identifier(s)} ORDER BY created_at DESC LIMIT 1`))[0]??void 0;await t.transaction(async c=>{for(let f of e)if(!r||Number(r[2])<f.folderMillis){for(let p of f.sql)await c.run(J$1.raw(p));await c.run(J$1`INSERT INTO ${J$1.identifier(s)} ("hash", "created_at") VALUES(${f.hash}, ${f.folderMillis})`);}});}};export{Ge as a,He as b,Ze as c,F as d,fi as e,G as f,H as g,rt as h,ot as i};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import {createRequire}from'module';createRequire(import.meta.url);
|
|
2
|
+
var i={name:"@aws-sdk/nested-clients",version:"3.997.33",description:"Nested clients for AWS SDK packages.",homepage:"https://github.com/aws/aws-sdk-js-v3/tree/main/packages/nested-clients",license:"Apache-2.0",author:{name:"AWS SDK for JavaScript Team",url:"https://aws.amazon.com/sdk-for-javascript/"},repository:{type:"git",url:"https://github.com/aws/aws-sdk-js-v3.git",directory:"packages/nested-clients"},files:["./cognito-identity.d.ts","./cognito-identity.js","./signin.d.ts","./signin.js","./sso-oidc.d.ts","./sso-oidc.js","./sso.d.ts","./sso.js","./sts.d.ts","./sts.js","dist-*/**"],sideEffects:false,main:"./dist-cjs/index.js",module:"./dist-es/index.js",browser:{"./dist-es/submodules/cognito-identity/runtimeConfig":"./dist-es/submodules/cognito-identity/runtimeConfig.browser","./dist-es/submodules/signin/runtimeConfig":"./dist-es/submodules/signin/runtimeConfig.browser","./dist-es/submodules/sso-oidc/runtimeConfig":"./dist-es/submodules/sso-oidc/runtimeConfig.browser","./dist-es/submodules/sso/runtimeConfig":"./dist-es/submodules/sso/runtimeConfig.browser","./dist-es/submodules/sts/runtimeConfig":"./dist-es/submodules/sts/runtimeConfig.browser"},types:"./dist-types/index.d.ts",typesVersions:{"<4.5":{"dist-types/*":["dist-types/ts3.4/*"],"*":["dist-types/ts3.4/submodules/*/index.d.ts"]}},"react-native":{},exports:{"./package.json":"./package.json","./sso-oidc":{types:"./dist-types/submodules/sso-oidc/index.d.ts",module:"./dist-es/submodules/sso-oidc/index.js",node:"./dist-cjs/submodules/sso-oidc/index.js",import:"./dist-es/submodules/sso-oidc/index.js",require:"./dist-cjs/submodules/sso-oidc/index.js"},"./sts":{types:"./dist-types/submodules/sts/index.d.ts",module:"./dist-es/submodules/sts/index.js",node:"./dist-cjs/submodules/sts/index.js",import:"./dist-es/submodules/sts/index.js",require:"./dist-cjs/submodules/sts/index.js"},"./signin":{types:"./dist-types/submodules/signin/index.d.ts",module:"./dist-es/submodules/signin/index.js",node:"./dist-cjs/submodules/signin/index.js",import:"./dist-es/submodules/signin/index.js",require:"./dist-cjs/submodules/signin/index.js"},"./cognito-identity":{types:"./dist-types/submodules/cognito-identity/index.d.ts",module:"./dist-es/submodules/cognito-identity/index.js",node:"./dist-cjs/submodules/cognito-identity/index.js",import:"./dist-es/submodules/cognito-identity/index.js",require:"./dist-cjs/submodules/cognito-identity/index.js"},"./sso":{types:"./dist-types/submodules/sso/index.d.ts",module:"./dist-es/submodules/sso/index.js",node:"./dist-cjs/submodules/sso/index.js",import:"./dist-es/submodules/sso/index.js",require:"./dist-cjs/submodules/sso/index.js"}},scripts:{build:"concurrently 'yarn:build:types' 'yarn:build:es' && yarn build:cjs","build:cjs":"node ../../scripts/compilation/inline","build:es":"premove dist-es && tsc -p tsconfig.es.json","build:include:deps":'yarn g:turbo run build -F="$npm_package_name"',"build:types":"premove dist-types && tsc -p tsconfig.types.json","build:types:downlevel":"downlevel-dts dist-types dist-types/ts3.4",clean:"premove dist-cjs dist-es dist-types",lint:"node ../../scripts/validation/submodules-linter.js",prebuild:"yarn lint",test:"yarn g:vitest run","test:watch":"yarn g:vitest watch"},dependencies:{"@aws-sdk/core":"^3.975.3","@aws-sdk/signature-v4-multi-region":"^3.996.41","@aws-sdk/types":"^3.974.2","@smithy/core":"^3.29.4","@smithy/fetch-http-handler":"^5.6.6","@smithy/node-http-handler":"^4.9.6","@smithy/types":"^4.16.1",tslib:"^2.6.2"},devDependencies:{concurrently:"7.0.0","downlevel-dts":"0.10.1",premove:"4.0.0",typescript:"~5.8.3"},engines:{node:">=20.0.0"}};
|
|
3
|
+
export{i as a};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import {createRequire}from'module';import {g as g$1}from'./chunk-C2PXMVR5.js';import {getRandomValues}from'crypto';import {ReadStream,lstatSync,fstatSync}from'fs';import {Readable,Writable}from'stream';createRequire(import.meta.url);
|
|
2
|
+
g$1();g$1();g$1();var J=e=>typeof ArrayBuffer=="function"&&e instanceof ArrayBuffer||Object.prototype.toString.call(e)==="[object ArrayBuffer]";var B=(e,t=0,r=e.byteLength-t)=>{if(!J(e))throw new TypeError(`The "input" argument must be ArrayBuffer. Received type ${typeof e} (${e})`);return Buffer.from(e,t,r)},U=(e,t)=>{if(typeof e!="string")throw new TypeError(`The "input" argument must be of type string. Received type ${typeof e} (${e})`);return t?Buffer.from(e,t):Buffer.from(e)};var R=e=>{let t=U(e,"utf8");return new Uint8Array(t.buffer,t.byteOffset,t.byteLength/Uint8Array.BYTES_PER_ELEMENT)};g$1();var se=e=>{if(typeof e=="string")return e;if(typeof e!="object"||typeof e.byteOffset!="number"||typeof e.byteLength!="number")throw new Error("@smithy/util-utf8: toUtf8 encoder function only accepts string | Uint8Array.");return B(e.buffer,e.byteOffset,e.byteLength).toString("utf8")};g$1();var ie={},W={};for(let e=0;e<256;e++){let t=e.toString(16).toLowerCase();t.length===1&&(t=`0${t}`),ie[e]=t,W[t]=e;}function De(e){if(e.length%2!==0)throw new Error("Hex encoded strings must have an even number length");let t=new Uint8Array(e.length/2);for(let r=0;r<e.length;r+=2){let n=e.slice(r,r+2).toLowerCase();if(n in W)t[r/2]=W[n];else throw new Error(`Cannot decode unrecognized sequence ${n} as hexadecimal`)}return t}function z(e){let t="";for(let r=0;r<e.byteLength;r++)t+=ie[e[r]];return t}g$1();g$1();var _e=/^[A-Za-z0-9+/]*={0,2}$/,ae=e=>{if(e.length*3%4!==0)throw new TypeError("Incorrect padding on base64 string.");if(!_e.exec(e))throw new TypeError("Invalid base64 string.");let t=U(e,"base64");return new Uint8Array(t.buffer,t.byteOffset,t.byteLength)};g$1();var F=e=>{let t;if(typeof e=="string"?t=R(e):t=e,typeof t!="object"||typeof t.byteOffset!="number"||typeof t.byteLength!="number")throw new Error("@smithy/util-base64: toBase64 encoder function only accepts string | Uint8Array.");return B(t.buffer,t.byteOffset,t.byteLength).toString("base64")};g$1();function fe(e,t,r,n){return class O extends Uint8Array{static fromString(s,a="utf-8"){if(typeof s=="string")return a==="base64"?O.mutate(n(s)):O.mutate(t(s));throw new Error(`Unsupported conversion from ${typeof s} to Uint8ArrayBlobAdapter.`)}static mutate(s){return Object.setPrototypeOf(s,O.prototype),s}transformToString(s="utf-8"){return s==="base64"?r(this):e(this)}}}g$1();var l=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,"0"));function ce(e){return typeof crypto<"u"&&typeof crypto.randomUUID=="function"?()=>crypto.randomUUID():()=>{let t=new Uint8Array(16);return e(t),t[6]=t[6]&15|64,t[8]=t[8]&63|128,l[t[0]]+l[t[1]]+l[t[2]]+l[t[3]]+"-"+l[t[4]]+l[t[5]]+"-"+l[t[6]]+l[t[7]]+"-"+l[t[8]]+l[t[9]]+"-"+l[t[10]]+l[t[11]]+l[t[12]]+l[t[13]]+l[t[14]]+l[t[15]]}}g$1();g$1();var j=e=>{if(e!=null){if(typeof e=="string"){let t=parseFloat(e);if(!Number.isNaN(t))return String(t)!==String(e)&&ze.warn(We(`Expected number but observed string: ${e}`)),t}if(typeof e=="number")return e;throw new TypeError(`Expected number, got ${typeof e}: ${e}`)}},ke=Math.ceil(34028234663852886e22),ue=e=>{let t=j(e);if(t!==void 0&&!Number.isNaN(t)&&t!==1/0&&t!==-1/0&&Math.abs(t)>ke)throw new TypeError(`Expected 32-bit float, got ${e}`);return t},Pe=e=>{if(e!=null){if(Number.isInteger(e)&&!Number.isNaN(e))return e;throw new TypeError(`Expected integer, got ${typeof e}: ${e}`)}};var de=e=>me(e,16),pe=e=>me(e,8),me=(e,t)=>{let r=Pe(e);if(r!==void 0&&He(r,t)!==r)throw new TypeError(`Expected ${t}-bit integer, got ${e}`);return r},He=(e,t)=>{switch(t){case 32:return Int32Array.of(e)[0];case 16:return Int16Array.of(e)[0];case 8:return Int8Array.of(e)[0]}};var he=e=>j(typeof e=="string"?L(e):e);var ye=e=>ue(typeof e=="string"?L(e):e),Je=/(-?(?:0|[1-9]\d*)(?:\.\d+)?(?:[eE][+-]?\d+)?)|(-?Infinity)|(NaN)/g,L=e=>{let t=e.match(Je);if(t===null||t[0].length!==e.length)throw new TypeError("Expected real number, got implicit NaN");return parseFloat(e)};var N=e=>de(typeof e=="string"?L(e):e),le=e=>pe(typeof e=="string"?L(e):e),We=e=>String(new TypeError(e).stack||e).split(`
|
|
3
|
+
`).slice(0,5).filter(t=>!t.includes("stackTraceWarning")).join(`
|
|
4
|
+
`),ze={warn:console.warn};var je=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],Y=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function qe(e){let t=e.getUTCFullYear(),r=e.getUTCMonth(),n=e.getUTCDay(),o=e.getUTCDate(),s=e.getUTCHours(),a=e.getUTCMinutes(),f=e.getUTCSeconds(),c=o<10?`0${o}`:`${o}`,u=s<10?`0${s}`:`${s}`,m=a<10?`0${a}`:`${a}`,h=f<10?`0${f}`:`${f}`;return `${je[n]}, ${c} ${Y[r]} ${t} ${u}:${m}:${h} GMT`}var Ye=new RegExp(/^(\d{4})-(\d{2})-(\d{2})[tT](\d{2}):(\d{2}):(\d{2})(?:\.(\d+))?[zZ]$/),Ve=e=>{if(e==null)return;if(typeof e!="string")throw new TypeError("RFC-3339 date-times must be expressed as strings");let t=Ye.exec(e);if(!t)throw new TypeError("Invalid RFC-3339 date-time value");let[r,n,o,s,a,f,c,u]=t,m=N(C(n)),h=w(o,"month",1,12),y=w(s,"day",1,31);return M(m,h,y,{hours:a,minutes:f,seconds:c,fractionalMilliseconds:u})},Ge=new RegExp(/^(\d{4})-(\d{2})-(\d{2})[tT](\d{2}):(\d{2}):(\d{2})(?:\.(\d+))?(([-+]\d{2}:\d{2})|[zZ])$/),Xe=e=>{if(e==null)return;if(typeof e!="string")throw new TypeError("RFC-3339 date-times must be expressed as strings");let t=Ge.exec(e);if(!t)throw new TypeError("Invalid RFC-3339 date-time value");let[r,n,o,s,a,f,c,u,m]=t,h=N(C(n)),y=w(o,"month",1,12),b=w(s,"day",1,31),x=M(h,y,b,{hours:a,minutes:f,seconds:c,fractionalMilliseconds:u});return m.toUpperCase()!="Z"&&x.setTime(x.getTime()-ft(m)),x},Ze=new RegExp(/^(?:Mon|Tue|Wed|Thu|Fri|Sat|Sun), (\d{2}) (Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec) (\d{4}) (\d{1,2}):(\d{2}):(\d{2})(?:\.(\d+))? GMT$/),Ke=new RegExp(/^(?:Monday|Tuesday|Wednesday|Thursday|Friday|Saturday|Sunday), (\d{2})-(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)-(\d{2}) (\d{1,2}):(\d{2}):(\d{2})(?:\.(\d+))? GMT$/),Qe=new RegExp(/^(?:Mon|Tue|Wed|Thu|Fri|Sat|Sun) (Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec) ( [1-9]|\d{2}) (\d{1,2}):(\d{2}):(\d{2})(?:\.(\d+))? (\d{4})$/),ve=e=>{if(e==null)return;if(typeof e!="string")throw new TypeError("RFC-7231 date-times must be expressed as strings");let t=Ze.exec(e);if(t){let[r,n,o,s,a,f,c,u]=t;return M(N(C(s)),q(o),w(n,"day",1,31),{hours:a,minutes:f,seconds:c,fractionalMilliseconds:u})}if(t=Ke.exec(e),t){let[r,n,o,s,a,f,c,u]=t;return nt(M(tt(s),q(o),w(n,"day",1,31),{hours:a,minutes:f,seconds:c,fractionalMilliseconds:u}))}if(t=Qe.exec(e),t){let[r,n,o,s,a,f,c,u]=t;return M(N(C(u)),q(n),w(o.trimLeft(),"day",1,31),{hours:s,minutes:a,seconds:f,fractionalMilliseconds:c})}throw new TypeError("Invalid RFC-7231 date-time value")},et=e=>{if(e==null)return;let t;if(typeof e=="number")t=e;else if(typeof e=="string")t=he(e);else if(typeof e=="object"&&e.tag===1)t=e.value;else throw new TypeError("Epoch timestamps must be expressed as floating point numbers or their string representation");if(Number.isNaN(t)||t===1/0||t===-1/0)throw new TypeError("Epoch timestamps must be valid, non-Infinite, non-NaN numerics");return new Date(Math.round(t*1e3))},M=(e,t,r,n)=>{let o=t-1;return st(e,o,r),new Date(Date.UTC(e,o,r,w(n.hours,"hour",0,23),w(n.minutes,"minute",0,59),w(n.seconds,"seconds",0,60),at(n.fractionalMilliseconds)))},tt=e=>{let t=new Date().getUTCFullYear(),r=Math.floor(t/100)*100+N(C(e));return r<t?r+100:r},rt=50*365*24*60*60*1e3,nt=e=>e.getTime()-new Date().getTime()>rt?new Date(Date.UTC(e.getUTCFullYear()-100,e.getUTCMonth(),e.getUTCDate(),e.getUTCHours(),e.getUTCMinutes(),e.getUTCSeconds(),e.getUTCMilliseconds())):e,q=e=>{let t=Y.indexOf(e);if(t<0)throw new TypeError(`Invalid month: ${e}`);return t+1},ot=[31,28,31,30,31,30,31,31,30,31,30,31],st=(e,t,r)=>{let n=ot[t];if(t===1&&it(e)&&(n=29),r>n)throw new TypeError(`Invalid day for ${Y[t]} in ${e}: ${r}`)},it=e=>e%4===0&&(e%100!==0||e%400===0),w=(e,t,r,n)=>{let o=le(C(e));if(o<r||o>n)throw new TypeError(`${t} must be between ${r} and ${n}, inclusive`);return o},at=e=>e==null?0:ye("0."+e)*1e3,ft=e=>{let t=e[0],r=1;if(t=="+")r=1;else if(t=="-")r=-1;else throw new TypeError(`Offset direction, ${t}, must be "+" or "-"`);let n=Number(e.substring(1,3)),o=Number(e.substring(4,6));return r*(n*60+o)*60*1e3},C=e=>{let t=0;for(;t<e.length-1&&e.charAt(t)==="0";)t++;return t===0?e:e.slice(t)};g$1();var T=function(t){return Object.assign(new String(t),{deserializeJSON(){return JSON.parse(String(t))},toString(){return String(t)},toJSON(){return String(t)}})};T.from=e=>e&&typeof e=="object"&&(e instanceof T||"deserializeJSON"in e)?e:typeof e=="string"||Object.getPrototypeOf(e)===String.prototype?T(String(e)):T(JSON.stringify(e));T.fromObject=T.from;g$1();function ct(e){return (e.includes(",")||e.includes('"'))&&(e=`"${e.replace(/"/g,'\\"')}"`),e}g$1();var V="(?:Mon|Tue|Wed|Thu|Fri|Sat|Sun)(?:[ne|u?r]?s?day)?",G="(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)",X="(\\d?\\d):(\\d{2}):(\\d{2})(?:\\.(\\d+))?",be="(\\d?\\d)",ge="(\\d{4})",ut=new RegExp(/^(\d{4})-(\d\d)-(\d\d)[tT](\d\d):(\d\d):(\d\d)(\.(\d+))?(([-+]\d\d:\d\d)|[zZ])$/),dt=new RegExp(`^${V}, ${be} ${G} ${ge} ${X} GMT$`),pt=new RegExp(`^${V}, ${be}-${G}-(\\d\\d) ${X} GMT$`),mt=new RegExp(`^${V} ${G} ( [1-9]|\\d\\d) ${X} ${ge}$`),ht=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],yt=e=>{if(e==null)return;let t=NaN;if(typeof e=="number")t=e;else if(typeof e=="string"){if(!/^-?\d*\.?\d+$/.test(e))throw new TypeError("parseEpochTimestamp - numeric string invalid.");t=Number.parseFloat(e);}else typeof e=="object"&&e.tag===1&&(t=e.value);if(isNaN(t)||Math.abs(t)===1/0)throw new TypeError("Epoch timestamps must be valid finite numbers.");return new Date(Math.round(t*1e3))},lt=e=>{if(e==null)return;if(typeof e!="string")throw new TypeError("RFC3339 timestamps must be strings");let t=ut.exec(e);if(!t)throw new TypeError(`Invalid RFC3339 timestamp format ${e}`);let[,r,n,o,s,a,f,,c,u]=t;S(n,1,12),S(o,1,31),S(s,0,23),S(a,0,59),S(f,0,60);let m=new Date(Date.UTC(Number(r),Number(n)-1,Number(o),Number(s),Number(a),Number(f),Number(c)?Math.round(parseFloat(`0.${c}`)*1e3):0));if(m.setUTCFullYear(Number(r)),u.toUpperCase()!="Z"){let[,h,y,b]=/([+-])(\d\d):(\d\d)/.exec(u)||[void 0,"+",0,0],x=h==="-"?1:-1;m.setTime(m.getTime()+x*(Number(y)*60*60*1e3+Number(b)*60*1e3));}return m},bt=e=>{if(e==null)return;if(typeof e!="string")throw new TypeError("RFC7231 timestamps must be strings.");let t,r,n,o,s,a,f,c;if((c=dt.exec(e))?[,t,r,n,o,s,a,f]=c:(c=pt.exec(e))?([,t,r,n,o,s,a,f]=c,n=(Number(n)+1900).toString()):(c=mt.exec(e))&&([,r,t,o,s,a,f,n]=c),n&&a){let u=Date.UTC(Number(n),ht.indexOf(r),Number(t),Number(o),Number(s),Number(a),f?Math.round(parseFloat(`0.${f}`)*1e3):0);S(t,1,31),S(o,0,23),S(s,0,59),S(a,0,60);let m=new Date(u);return m.setUTCFullYear(Number(n)),m}throw new TypeError(`Invalid RFC7231 date-time value ${e}.`)};function S(e,t,r){let n=Number(e);if(n<t||n>r)throw new Error(`Value ${n} out of range [${t}, ${r}]`)}g$1();function gt(e,t,r){if(r<=0||!Number.isInteger(r))throw new Error("Invalid number of delimiters ("+r+") for splitEvery.");let n=e.split(t);if(r===1)return n;let o=[],s="";for(let a=0;a<n.length;a++)s===""?s=n[a]:s+=t+n[a],(a+1)%r===0&&(o.push(s),s="");return s!==""&&o.push(s),o}g$1();var wt=e=>{let t=e.length,r=[],n=false,o,s=0;for(let a=0;a<t;++a){let f=e[a];switch(f){case '"':o!=="\\"&&(n=!n);break;case ",":n||(r.push(e.slice(s,a)),s=a+1);break;}o=f;}return r.push(e.slice(s)),r.map(a=>{a=a.trim();let f=a.length;return f<2?a:(a[0]==='"'&&a[f-1]==='"'&&(a=a.slice(1,f-1)),a.replace(/\\"/g,'"'))})};g$1();var we=/^-?\d*(\.\d+)?$/,Z=class e{string;type;constructor(t,r){if(this.string=t,this.type=r,!we.test(t))throw new Error('@smithy/core/serde - NumericValue must only contain [0-9], at most one decimal point ".", and an optional negation prefix "-".')}toString(){return this.string}static[Symbol.hasInstance](t){if(!t||typeof t!="object")return false;let r=t;return e.prototype.isPrototypeOf(t)||r.type==="bigDecimal"&&we.test(r.string)}};g$1();var Tt=e=>{if(!e)return 0;if(typeof e=="string")return Buffer.byteLength(e);if(typeof e.byteLength=="number")return e.byteLength;if(typeof e.size=="number")return e.size;if(typeof e.start=="number"&&typeof e.end=="number")return e.end+1-e.start;if(e instanceof ReadStream){if(e.path!=null)return lstatSync(e.path).size;if(typeof e.fd=="number")return fstatSync(e.fd).size}throw new Error(`Body Length computation failed for ${e}`)};g$1();var $t=e=>e instanceof Uint8Array?e:typeof e=="string"?R(e):ArrayBuffer.isView(e)?new Uint8Array(e.buffer,e.byteOffset,e.byteLength/Uint8Array.BYTES_PER_ELEMENT):new Uint8Array(e);g$1();function I(e,t){if(t===void 0){t=0;for(let o of e)t+=o.byteLength;}let r=new Uint8Array(t),n=0;for(let o of e)r.set(o,n),n+=o.byteLength;return r}g$1();var D=class extends Readable{expectedChecksum;checksumSourceLocation;checksum;source;base64Encoder;constructor({expectedChecksum:t,checksum:r,source:n,checksumSourceLocation:o,base64Encoder:s}){if(super(),typeof n.pipe!="function")throw new Error(`@smithy/util-stream: unsupported source type ${n?.constructor?.name??n} in ChecksumStream.`);this.source=n,this.base64Encoder=s??F,this.expectedChecksum=t,this.checksum=r,this.checksumSourceLocation=o,this.source.on("data",this.onSourceData),this.source.on("end",this.onSourceEnd),this.source.on("error",this.onSourceError),this.source.on("close",this.onSourceClose),this.source.pause();}onSourceData=t=>{if(!this.destroyed){try{this.checksum.update(t);}catch(r){this.destroy(r);return}this.push(t)||this.source.pause();}};onSourceEnd=async()=>{if(!this.destroyed){try{let t=await this.checksum.digest(),r=this.base64Encoder(t);if(this.expectedChecksum!==r){this.destroy(new Error(`Checksum mismatch: expected "${this.expectedChecksum}" but received "${r}" in response header "${this.checksumSourceLocation}".`));return}}catch(t){this.destroy(t);return}this.push(null);}};onSourceError=t=>{this.destroy(t);};onSourceClose=()=>{!this.destroyed&&!this.source.readableEnded&&this.destroy(new Error("Connection lost or stream closed before all data was received."));};_read(t){this.source.resume();}_destroy(t,r){this.source?.removeListener("data",this.onSourceData),this.source?.removeListener("end",this.onSourceEnd),this.source?.removeListener("error",this.onSourceError),this.source?.removeListener("close",this.onSourceClose),this.source?.destroy(),r(t);}};g$1();g$1();var g=e=>typeof ReadableStream=="function"&&(e?.constructor?.name===ReadableStream.name||e instanceof ReadableStream),_=e=>typeof Blob=="function"&&(e?.constructor?.name===Blob.name||e instanceof Blob);g$1();g$1();g$1();var xe=e=>new TextEncoder().encode(e);g$1();var Se="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";Object.entries(Se).reduce((e,[t,r])=>(e[r]=Number(t),e),{});var Ee=Se.split(""),k=6,K=8,Te=63;function P(e){let t;typeof e=="string"?t=xe(e):t=e;let r=typeof t=="object"&&typeof t.length=="number",n=typeof t=="object"&&typeof t.byteOffset=="number"&&typeof t.byteLength=="number";if(!r&&!n)throw new Error("@smithy/util-base64: toBase64 encoder function only accepts string | Uint8Array.");let o="";for(let s=0;s<t.length;s+=3){let a=0,f=0;for(let u=s,m=Math.min(s+3,t.length);u<m;u++)a|=t[u]<<(m-u-1)*K,f+=K;let c=Math.ceil(f/k);a<<=c*k-f;for(let u=1;u<=c;u++){let m=(c-u)*k;o+=Ee[(a&Te<<m)>>m];}o+="==".slice(0,4-c);}return o}g$1();var Bt=typeof ReadableStream=="function"?ReadableStream:function(){},H=class extends Bt{};var $e=({expectedChecksum:e,checksum:t,source:r,checksumSourceLocation:n,base64Encoder:o})=>{if(!g(r))throw new Error(`@smithy/util-stream: unsupported source type ${r?.constructor?.name??r} in ChecksumStream.`);let s=o??P;if(typeof TransformStream!="function")throw new Error("@smithy/util-stream: unable to instantiate ChecksumStream because API unavailable: ReadableStream/TransformStream.");let a=new TransformStream({start(){},async transform(c,u){t.update(c),u.enqueue(c);},async flush(c){let u=await t.digest(),m=s(u);if(e!==m){let h=new Error(`Checksum mismatch: expected "${e}" but received "${m}" in response header "${n}".`);c.error(h);}else c.terminate();}});r.pipeThrough(a);let f=a.readable;return Object.setPrototypeOf(f,H.prototype),f};function Rt(e){return typeof ReadableStream=="function"&&g(e.source)?$e(e):new D(e)}g$1();g$1();var $=class{allocByteArray;byteLength=0;byteArrays=[];constructor(t){this.allocByteArray=t;}push(t){this.byteArrays.push(t),this.byteLength+=t.byteLength;}flush(){if(this.byteArrays.length===1){let n=this.byteArrays[0];return this.reset(),n}let t=this.allocByteArray(this.byteLength),r=0;for(let n=0;n<this.byteArrays.length;++n){let o=this.byteArrays[n];t.set(o,r),r+=o.byteLength;}return this.reset(),t}reset(){this.byteArrays=[],this.byteLength=0;}};g$1();function Ae(e,t,r){let n=e.getReader(),o=false,s=0,a=["",new $(u=>new Uint8Array(u))],f=-1,c=async u=>{let{value:m,done:h}=await n.read(),y=m;if(h){if(f!==-1){let b=A(a,f);E(b)>0&&u.enqueue(b);}u.close();}else {let b=v(y,false);if(f!==b&&(f>=0&&u.enqueue(A(a,f)),f=b),f===-1){u.enqueue(y);return}let x=E(y);s+=x;let Le=E(a[f]);if(x>=t&&Le===0)u.enqueue(y);else {let Ie=Q(a,f,y);!o&&s>t*2&&(o=true,r?.warn(`@smithy/util-stream - stream chunk size ${x} is below threshold of ${t}, automatically buffering.`)),Ie>=t?u.enqueue(A(a,f)):await c(u);}}};return new ReadableStream({pull:c})}function Q(e,t,r){switch(t){case 0:return e[0]+=r,E(e[0]);case 1:case 2:return e[t].push(r),E(e[t])}}function A(e,t){switch(t){case 0:let r=e[0];return e[0]="",r;case 1:case 2:return e[t].flush()}throw new Error(`@smithy/util-stream - invalid index ${t} given to flush()`)}function E(e){return e?.byteLength??e?.length??0}function v(e,t=true){return t&&typeof Buffer<"u"&&e instanceof Buffer?2:e instanceof Uint8Array?1:typeof e=="string"?0:-1}function Ct(e,t,r){if(g(e))return Ae(e,t,r);let n=new Readable({read(){}}),o=false,s=0,a=["",new $(c=>new Uint8Array(c)),new $(c=>Buffer.from(new Uint8Array(c)))],f=-1;return e.on("data",c=>{let u=v(c,true);if(f!==u&&(f>=0&&n.push(A(a,f)),f=u),f===-1){n.push(c);return}let m=E(c);s+=m;let h=E(a[f]);if(m>=t&&h===0)n.push(c);else {let y=Q(a,f,c);!o&&s>t*2&&(o=true,r?.warn(`@smithy/util-stream - stream chunk size ${m} is below threshold of ${t}, automatically buffering.`)),y>=t&&n.push(A(a,f));}}),e.on("end",()=>{if(f!==-1){let c=A(a,f);E(c)>0&&n.push(c);}n.push(null);}),n}g$1();g$1();var Be=(e,t)=>{let{base64Encoder:r,bodyLengthChecker:n,checksumAlgorithmFn:o,checksumLocationName:s,streamHasher:a}=t,f=r!==void 0&&n!==void 0&&o!==void 0&&s!==void 0&&a!==void 0,c=f?a(o,e):void 0,u=e.getReader();return new ReadableStream({async pull(m){let{value:h,done:y}=await u.read();if(y){if(m.enqueue(`0\r
|
|
5
|
+
`),f){let b=r(await c);m.enqueue(`${s}:${b}\r
|
|
6
|
+
`),m.enqueue(`\r
|
|
7
|
+
`);}m.close();}else m.enqueue(`${(n(h)||0).toString(16)}\r
|
|
8
|
+
${h}\r
|
|
9
|
+
`);}})};function Ut(e,t){let r=e,n=e;if(g(n))return Be(n,t);let{base64Encoder:o,bodyLengthChecker:s,checksumAlgorithmFn:a,checksumLocationName:f,streamHasher:c}=t,u=o!==void 0&&a!==void 0&&f!==void 0&&c!==void 0,m=u?c(a,r):void 0,h=new Readable({read:()=>{}});return r.on("data",y=>{let b=s(y)||0;b!==0&&(h.push(`${b.toString(16)}\r
|
|
10
|
+
`),h.push(y),h.push(`\r
|
|
11
|
+
`));}),r.on("end",async()=>{if(h.push(`0\r
|
|
12
|
+
`),u){let y=o(await m);h.push(`${f}:${y}\r
|
|
13
|
+
`),h.push(`\r
|
|
14
|
+
`);}h.push(null);}),h}g$1();g$1();g$1();var Re=e=>{if(typeof e=="string")return e;if(typeof e!="object"||typeof e.byteOffset!="number"||typeof e.byteLength!="number")throw new Error("@smithy/util-utf8: toUtf8 encoder function only accepts string | Uint8Array.");return new TextDecoder("utf-8").decode(e)};g$1();var Ne=async e=>_(e)?ee(e):te(e);async function ee(e){return e.arrayBuffer().then(t=>new Uint8Array(t))}async function te(e){let t=[],r=e.getReader(),n=0;for(;;){let{done:o,value:s}=await r.read();if(s&&(t.push(s),n+=s.length),o)break}return I(t,n)}var Ce="The stream has already been transformed.",Ue=e=>{if(!Me(e)&&!g(e)){let o=e?.__proto__?.constructor?.name||e;throw new Error(`Unexpected stream implementation, expect Blob or ReadableStream, got ${o}`)}let t=false,r=async()=>{if(t)throw new Error(Ce);return t=true,await Ne(e)},n=o=>{if(typeof o.stream!="function")throw new Error(`Cannot transform payload Blob to web stream. Please make sure the Blob.stream() is polyfilled.
|
|
15
|
+
If you are using React Native, this API is not yet supported, see: https://react-native.canny.io/feature-requests/p/fetch-streaming-body`);return o.stream()};return Object.assign(e,{transformToByteArray:r,transformToString:async o=>{let s=await r();if(o==="base64")return P(s);if(o==="hex")return z(s);if(o===void 0||o==="utf8"||o==="utf-8")return Re(s);if(typeof TextDecoder=="function")return new TextDecoder(o).decode(s);throw new Error("TextDecoder is not available, please make sure polyfill is provided.")},transformToWebStream:()=>{if(t)throw new Error(Ce);if(t=true,Me(e))return n(e);if(g(e))return e;throw new Error(`Cannot transform payload to web stream, got ${e}`)}})},Me=e=>typeof Blob=="function"&&e instanceof Blob;g$1();var ne=e=>_(e)?ee(e):g(e)?te(e):new Promise((t,r)=>{let n=new re,o=e;o.pipe(n),o.on("error",s=>{n.end(),r(s);}),n.on("error",r),n.on("finish",function(){let s=I(this.bufferedBytes);t(s);});}),re=class extends Writable{bufferedBytes=[];_write(t,r,n){this.bufferedBytes.push(t),n();}};var Fe="The stream has already been transformed.",Ot=e=>{if(!(e instanceof Readable))try{return Ue(e)}catch{let o=e?.__proto__?.constructor?.name||e;throw new Error(`Unexpected stream implementation, expect Stream.Readable instance, got ${o}`)}let t=false,r=async()=>{if(t)throw new Error(Fe);return t=true,await ne(e)};return Object.assign(e,{transformToByteArray:r,transformToString:async n=>{let o=await r();return n===void 0||Buffer.isEncoding(n)?B(o.buffer,o.byteOffset,o.byteLength).toString(n):new TextDecoder(n).decode(o)},transformToWebStream:()=>{if(t)throw new Error(Fe);if(e.readableFlowing!==null)throw new Error("The stream has been consumed by other callbacks.");if(typeof Readable.toWeb!="function")throw new Error("Readable.toWeb() is not supported. Please ensure a polyfill is available.");return t=true,Readable.toWeb(e)}})};var Oe=class extends fe(se,R,F,ae){},It=getRandomValues,Dt=ce(It),no=Dt;
|
|
16
|
+
export{Ot as A,Oe as B,Dt as C,no as D,J as a,ae as b,R as c,F as d,se as e,qe as f,Ve as g,Xe as h,ve as i,et as j,T as k,ct as l,yt as m,lt as n,bt as o,gt as p,wt as q,Z as r,De as s,z as t,Tt as u,$t as v,Rt as w,Ct as x,Ut as y,ne as z};
|