@ckirg/corelib-cloud 0.1.22

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.
Files changed (56) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +252 -0
  3. package/dist/aws/RequestUnlimited-EKXQGSQT.mjs +2 -0
  4. package/dist/aws/bun-GK5CEVAU.mjs +2 -0
  5. package/dist/aws/chunk-27GDSGEE.mjs +2 -0
  6. package/dist/aws/chunk-F2KTMAO3.mjs +6 -0
  7. package/dist/aws/chunk-QCE23AKJ.mjs +8 -0
  8. package/dist/aws/chunk-STPKE4A5.mjs +24 -0
  9. package/dist/aws/chunk-V3XZ4XYN.mjs +2 -0
  10. package/dist/aws/chunk-VULBPPPP.mjs +2 -0
  11. package/dist/aws/chunk-Y7RZHZ53.mjs +2 -0
  12. package/dist/aws/cloudflare-BDB3FS4Y.mjs +2 -0
  13. package/dist/aws/deno-AIUOFIXG.mjs +2 -0
  14. package/dist/aws/dist-VV3A6A7N.mjs +118 -0
  15. package/dist/aws/gcp-ZEEIATV7.mjs +438 -0
  16. package/dist/aws/handler.mjs +63 -0
  17. package/dist/aws/lambda-S3DVSSBV.mjs +3 -0
  18. package/dist/aws/node-A7ZN443L.mjs +2 -0
  19. package/dist/aws/node-RM2WPPZL.mjs +8 -0
  20. package/dist/aws/src-W4SC2UPB.mjs +23 -0
  21. package/dist/aws/utils-KMHFLZAJ.mjs +2 -0
  22. package/dist/cloudflare/RequestUnlimited-QCOTVU4G.js +1 -0
  23. package/dist/cloudflare/bun-O4EJPGLH.js +1 -0
  24. package/dist/cloudflare/chunk-DGDAVQYC.js +1 -0
  25. package/dist/cloudflare/chunk-EQSCULS7.js +2 -0
  26. package/dist/cloudflare/chunk-O3XYZ4KS.js +1 -0
  27. package/dist/cloudflare/chunk-PVAE643M.js +1 -0
  28. package/dist/cloudflare/chunk-QPTGW2LL.js +1 -0
  29. package/dist/cloudflare/cloudflare-I5A4OJEG.js +1 -0
  30. package/dist/cloudflare/deno-KE6IVNNU.js +1 -0
  31. package/dist/cloudflare/dist-GZV6T6K3.js +117 -0
  32. package/dist/cloudflare/gcp-MNKOPDML.js +1 -0
  33. package/dist/cloudflare/lambda-PLZQW4BF.js +1 -0
  34. package/dist/cloudflare/node-DRV76TUB.js +1 -0
  35. package/dist/cloudflare/utils-7K7MHQMD.js +1 -0
  36. package/dist/cloudflare/worker.js +62 -0
  37. package/dist/cloudrun/RequestUnlimited-YQAPYTOH.js +2 -0
  38. package/dist/cloudrun/bun-BONNABBU.js +2 -0
  39. package/dist/cloudrun/chunk-5B5BV7SP.js +8 -0
  40. package/dist/cloudrun/chunk-5CIUNKHO.js +2 -0
  41. package/dist/cloudrun/chunk-CFQMQATE.js +24 -0
  42. package/dist/cloudrun/chunk-FYZPEVAA.js +2 -0
  43. package/dist/cloudrun/chunk-GB4XIPDS.js +6 -0
  44. package/dist/cloudrun/chunk-JUVTJQ7I.js +2 -0
  45. package/dist/cloudrun/chunk-ZXZVHMQF.js +2 -0
  46. package/dist/cloudrun/cloudflare-Q3ZW7CDF.js +2 -0
  47. package/dist/cloudrun/deno-CPTVGH3A.js +2 -0
  48. package/dist/cloudrun/dist-VT4HJLSH.js +118 -0
  49. package/dist/cloudrun/gcp-W76U73T6.js +438 -0
  50. package/dist/cloudrun/lambda-NKM4QA4M.js +3 -0
  51. package/dist/cloudrun/node-LVHXMIYI.js +8 -0
  52. package/dist/cloudrun/node-SKMPZMFE.js +2 -0
  53. package/dist/cloudrun/server.js +67 -0
  54. package/dist/cloudrun/src-2WWXNWVC.js +23 -0
  55. package/dist/cloudrun/utils-SDRX3ZUT.js +2 -0
  56. package/package.json +52 -0
@@ -0,0 +1,23 @@
1
+ import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
+ import{h as Q}from"./chunk-5CIUNKHO.js";Q();import dn from"os";import pn from"fs";Q();Q();var He=new Map,st=new Map,at=Symbol("OriginError"),Te={},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=!1,o(d)),this.reject=d=>(this.active=!1,c(d)),this.active=!1,this.cancelled=null,this.executed=!1,this.signature="",this[at]=this.handler.debug?new Error:this.tagged&&Qr(this.strings)}get origin(){return(this.handler.debug?this[at].stack:this.tagged&&st.has(this.strings)?st.get(this.strings):st.set(this.strings,this[at].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=!0,this.options.prepare=!1,this}async readable(){return this.simple(),this.streaming=!0,this}async writable(){return this.simple(),this.streaming=!0,this}cursor(r=1,n){if(this.options.simple=!1,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:!0};a&&a();let i=new Promise((u,o)=>{this.cursorFn=c=>(u({value:c,done:!1}),new Promise(d=>a=d)),this.resolve=()=>(this.active=!1,u({done:!0})),this.reject=c=>(this.active=!1,o(c))});return this.execute(),i},return(){return a&&a(Te),{done:!0}}})}}describe(){return this.options.simple=!1,this.onlyDescribe=this.options.prepare=!0,this}stream(){throw new Error(".stream has been renamed to .forEach")}forEach(r){return this.forEachFn=r,this.handle(),this}raw(){return this.isRaw=!0,this}values(){return this.isRaw="values",this}async handle(){!this.executed&&(this.executed=!0)&&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 Qr(e){if(He.has(e))return He.get(e);let r=Error.stackTraceLimit;return Error.stackTraceLimit=4,He.set(e,new Error),Error.stackTraceLimit=r,He.get(e)}Q();var _e=class extends Error{constructor(r){super(r.message),this.name=this.constructor.name,Object.assign(this,r)}},z={connection:Nt,postgres:Ut,generic:jt,notSupported:Rt};function Nt(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,Nt),u}function Ut(e){let r=new _e(e);return Error.captureStackTrace(r,Ut),r}function jt(e,r){let n=Object.assign(new Error(e+": "+r),{code:e});return Error.captureStackTrace(n,jt),n}function Rt(e){let r=Object.assign(new Error(e+" (B) is not supported"),{code:"MESSAGE_NOT_SUPPORTED",name:e});return Error.captureStackTrace(r,Rt),r}var Hr={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===!0?"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")}},ke=class{then(){ot()}catch(){ot()}finally(){ot()}},Ie=class extends ke{constructor(r){super(),this.value=We(r)}},ie=class extends ke{constructor(r,n,a){super(),this.value=r,this.type=n,this.array=a}},Fe=class extends ke{constructor(r,n){super(),this.first=r,this.rest=n}build(r,n,a,i){let u=Kr.map(([o,c])=>({fn:c,i:r.search(o)})).sort((o,c)=>o.i-c.i).pop();return u.i===-1?ft(this.first,i):u.fn(this.first,this.rest,n,a,i)}};function Ye(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||Ve(e.value)]||e.type||Lt(e.value):e.type):(r.push(e),Ve(e)))}var kt=zt(Hr);function lt(e,r,n,a,i,u){for(let o=1;o<e.strings.length;o++)r+=ut(r,n,a,i,u)+e.strings[o],n=e.args[o];return r}function ut(e,r,n,a,i){return r instanceof Fe?r.build(e,n,a,i):r instanceof re?ct(r,n,a,i):r instanceof Ie?r.value:r&&r[0]instanceof re?r.reduce((u,o)=>u+" "+ct(o,n,a,i),""):Ye(r,n,a,i)}function ct(e,r,n,a){return e.fragment=!0,lt(e,e.strings[0],e.args[0],r,n,a)}function Ft(e,r,n,a,i){return e.map(u=>"("+a.map(o=>ut("values",u[o],r,n,i)).join(",")+")").join(",")}function Dt(e,r,n,a,i){let u=Array.isArray(e[0]),o=r.length?r.flat():Object.keys(u?e[0]:e);return Ft(u?e:[e],n,a,o,i)}function Ke(e,r,n,a,i){if(typeof e=="string"&&(e=[e].concat(r)),Array.isArray(e))return ft(e,i);let u;return(r.length?r.flat():Object.keys(e)).map(c=>(u=e[c],(u instanceof re?ct(u,n,a,i):u instanceof Ie?u.value:Ye(u,n,a,i))+" as "+We(i.transform.column.to?i.transform.column.to(c):c))).join(",")}var Kr=Object.entries({values:Dt,in:(...e)=>{let r=Dt(...e);return r==="()"?"(null)":r},select:Ke,as:Ke,returning:Ke,"\\(":Ke,update(e,r,n,a,i){return(r.length?r.flat():Object.keys(e)).map(u=>We(i.transform.column.to?i.transform.column.to(u):u)+"="+ut("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"("+ft(u,i)+")values"+Ft(Array.isArray(e)?e:[e],n,a,u,i)}}).map(([e,r])=>[new RegExp("((?:^|[\\s(])"+e+"(?:$|[\\s(]))(?![\\s\\S]*\\1)","i"),r]);function ot(){throw z.generic("NOT_TAGGED_CALL","Query not called as a tagged template literal")}var Vr=kt.serializers,Yr=kt.parsers;function Lt(e){return Array.isArray(e)?Lt(e[0]):typeof e=="string"?1009:0}var Mt=function(e){let r=zt(e||{});return{serializers:Object.assign({},Vr,r.serializers),parsers:Object.assign({},Yr,r.parsers)}};function zt(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 ft(e,{transform:{column:r}}){return e.map(n=>We(r.to?r.to(n):n)).join(",")}var We=function(r){return'"'+r.replace(/"/g,'""').replace(/\./g,'"."')+'"'},Ve=function e(r){return r instanceof ie?r.type:r instanceof Date?1184:r instanceof Uint8Array?17:r===!0||r===!1?16:typeof r=="bigint"?20:Array.isArray(r)?e(r[0]):0},Wr=/\\/g,Xr=/"/g;function Jr(e){return e.replace(Wr,"\\\\").replace(Xr,'\\"')}var $t=function e(r,n,a,i){if(Array.isArray(r)===!1)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":'"'+Jr(n?n(c.type?c.value:c):""+c)+'"'}).join(o)+"}"},it={i:0,char:null,str:"",quoted:!1,last:0},Gt=function(r,n,a){return it.i=it.last=0,Qt(it,r,n,a)};function Qt(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=!0;else if(e.char==="{")e.last=++e.i,i.push(Qt(e,r,n,a));else if(e.char==="}"){e.quoted=!1,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 Se=e=>{let r=e[0];for(let n=1;n<e.length;n++)r+=e[n]==="_"?e[++n].toUpperCase():e[n];return r},ve=e=>{let r=e[0].toUpperCase();for(let n=1;n<e.length;n++)r+=e[n]==="_"?e[++n].toUpperCase():e[n];return r},Ae=e=>e.replace(/_/g,"-"),Le=e=>e.replace(/([A-Z])/g,"_$1").toLowerCase(),Me=e=>(e.slice(0,1)+e.slice(1).replace(/([A-Z])/g,"_$1")).toLowerCase(),ze=e=>e.replace(/-/g,"_");function mt(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}}Se.column={from:Se};Se.value={from:mt(Se)};Le.column={to:Le};var dt={...Se};dt.column.to=Le;ve.column={from:ve};ve.value={from:mt(ve)};Me.column={to:Me};var pt={...ve};pt.column.to=Me;Ae.column={from:Ae};Ae.value={from:mt(Ae)};ze.column={to:ze};var ht={...Ae};ht.column.to=ze;Q();import Ht from"net";import en from"tls";import $e from"crypto";import gt from"stream";import{performance as Kt}from"perf_hooks";Q();var we=class extends Array{constructor(){super(),Object.defineProperties(this,{count:{value:null,writable:!0},state:{value:null,writable:!0},command:{value:null,writable:!0},columns:{value:null,writable:!0},statement:{value:null,writable:!0}})}static get[Symbol.species](){return Array}};Q();var ne=Zr;function Zr(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}}}Q();var X=Buffer.allocUnsafe(256),qr="BCcDdEFfHPpQSX".split("").reduce((e,r)=>{let n=r.charCodeAt(0);return e[r]=()=>(X[0]=n,B.i=5,B),e},{}),B=Object.assign(xr,qr,{N:"\0",i:0,inc(e){return B.i+=e,B},str(e){let r=Buffer.byteLength(e);return Xe(r),B.i+=X.write(e,B.i,r,"utf8"),B},i16(e){return Xe(2),X.writeUInt16BE(e,B.i),B.i+=2,B},i32(e,r){return r||r===0?(X.writeUInt32BE(e,r),B):(Xe(4),X.writeUInt32BE(e,B.i),B.i+=4,B)},z(e){return Xe(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 Xe(e){if(X.length-B.i<e){let r=X,n=r.length;X=Buffer.allocUnsafe(n+(n>>1)+e),r.copy(X)}}function xr(){return B.i=0,B}var wt=Wt,tn=1,be=p().S().end(),Vt=p().H().end(),rn=p().i32(8).i32(80877103).end(8),nn=Buffer.concat([p().E().str(p.N).i32(0).end(),be]),sn=p().D().str("S").str(p.N).end(),Ne=()=>{},an=new Set(["FetchPreparedStatement","RevalidateCachedQuery","transformAssignedExpr"]),on={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 Wt(e,r={},{onopen:n=Ne,onend:a=Ne,onclose:i=Ne}={}){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(),he=tn++,le={pid:null,secret:null},Oe=yt(rt,e.idle_timeout),Ee=yt(rt,e.max_lifetime),v=yt(rr,e.connect_timeout),m=null,ue,x=null,A=new we,J=Buffer.alloc(0),Pe=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=!1,ce=null,ge=null,V=null,D=null,I=null,te=null,Ge=null,et=null,f=null,Ue=null,Y={queue:r.closed,idleTimer:Oe,connect(t){V=t,Pt()},terminate:De,execute:je,cancel:qt,end:rt,count:0,id:he};return r.closed&&r.closed.push(Y),Y;async function Zt(){let t;try{t=e.socket?await Promise.resolve(e.socket(e)):new Ht.Socket}catch(s){Ce(s);return}return t.on("error",Ce),t.on("close",Bt),t.on("drain",At),t}async function qt({pid:t,secret:s},h,_){try{ue=p().i32(16).i32(80877102).i32(t).i32(s).end(16),await Ot(),m.once("error",_),m.once("close",h)}catch(M){_(M)}}function je(t){if(me)return Re(t,z.connection("CONNECTION_DESTROYED",e));if(I)return Re(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),tr(t),K(xt(t))&&!t.describeFirst&&!t.cursorFn&&S.length<N&&(!t.options.onexecute||t.options.onexecute(Y))}catch(s){return S.length===0&&K(be),ae(s),!0}}function xt(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([_t(t),Vt]):t.prepare?t.prepared?Qe(t):Buffer.concat([_t(t),Qe(t)]):er(t)}function _t(t){return Buffer.concat([Tt(t.statement.string,t.parameters,t.statement.types,t.statement.name),zr("S",t.statement.name)])}function Qe(t){return Buffer.concat([Mr(t.parameters,t.statement.types,t.statement.name,t.cursorName),t.cursorFn?It("",t.cursorRows):nn])}function er(t){return Buffer.concat([Tt(t.statement.string,t.parameters,t.statement.types),sn,Qe(t)])}function tr(t){let s=[],h=[],_=lt(t,t.strings[0],t.args[0],s,h,e);!t.tagged&&t.args.forEach(M=>Ye(M,s,h,e)),t.prepare=e.prepare&&("prepare"in t.options?t.options.prepare:!0),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(he,_,s,h)}function K(t,s){return te=te?Buffer.concat([te,t]):Buffer.from(t),s||te.length>=1024?St(s):(T===null&&(T=setImmediate(St)),!0)}function St(t){let s=m.write(te,t);return T!==null&&clearImmediate(T),te=T=null,s}function rr(){ae(z.connection("CONNECT_TIMEOUT",e,m)),m.destroy()}async function vt(){if(u!=="direct"&&(K(rn),!await new Promise(h=>m.once("data",_=>h(_[0]===83)))&&o==="prefer"))return Be();let t={socket:m,servername:Ht.isIP(m.host)?void 0:m.host};u==="direct"&&(t.ALPNProtocols=["postgresql"]),o==="require"||o==="allow"||o==="prefer"?t.rejectUnauthorized=!1:typeof o=="object"&&Object.assign(t,o),m.removeAllListeners(),m=en.connect(t),m.on("secureConnect",Be),m.on("error",Ce),m.on("close",Bt),m.on("drain",At)}function At(){!f&&n(Y)}function tt(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{nr(J.subarray(0,k+1))}catch(s){f&&(f.cursorFn||f.describeFirst)&&K(be),ae(s)}J=J.subarray(k+1),L=0,ce=null}}async function Ot(){if(me=!1,fe={},m||(m=await Zt()),!!m){if(v.start(),e.socket)return o?vt():Be();if(m.on("connect",o?vt:Be),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 Pt(){setTimeout(Ot,$?Math.max(0,$+F-Kt.now()):0)}function Be(){try{l={},Pe=e.fetch_types,y=Math.random().toString(36).slice(2),U=1,Ee.start(),m.on("data",tt),oe&&m.setKeepAlive&&m.setKeepAlive(!0,1e3*oe);let t=Gr();K(t)}catch(t){Ce(t)}}function Ce(t){if(!(Y.queue===r.connecting&&e.host[O+1]))for(ae(t);S.length;)Re(S.shift(),t)}function ae(t){I&&(I.destroy(t),I=null),f&&Re(f,t),V&&(Re(V,t),V=null)}function Re(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/,`
3
+ `),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 rt(){return D||(!Y.reserved&&a(Y),!Y.reserved&&!V&&!f&&S.length===0?(De(),new Promise(t=>m&&m.readyState!=="closed"?m.once("close",t):t())):D=new Promise(t=>Ge=t))}function De(){me=!0,(I||f||V||S.length)&&Ce(z.connection("CONNECTION_DESTROYED",e)),clearImmediate(T),m&&(m.removeListener("data",tt),m.removeListener("connect",Be),m.readyState==="open"&&m.end(p().X().end())),Ge&&(Ge(),D=Ge=null)}async function Bt(t){if(J=Buffer.alloc(0),L=0,ce=null,clearImmediate(T),m.removeListener("data",tt),m.removeListener("connect",Be),Oe.cancel(),Ee.cancel(),v.cancel(),m.removeAllListeners(),m=null,V)return Pt();!t&&(f||S.length)&&Ce(z.connection("CONNECTION_CLOSED",e,m)),$=Kt.now(),t&&e.shared.retries++,F=(typeof se=="function"?se(e.shared.retries):se)*1e3,i(Y,z.connection("CONNECTION_CLOSED",e,m))}function nr(t,s=t[0]){(s===68?sr:s===100?Nr:s===65?Or:s===83?ar:s===90?or:s===67?ir:s===50?Ct:s===49?cr:s===116?lr:s===84?ur:s===82?fr:s===110?yr:s===75?wr:s===69?vr:s===115?Pr:s===51?Br:s===71?Cr:s===78?jr:s===72?Tr:s===99?Ur:s===73?Rr:s===86?Dr:s===118?kr:s===87?Ir:Fr)(t)}function sr(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===!0?t.subarray(s,s+=h):_.parser===void 0?t.toString("utf8",s,s+=h):_.parser.array===!0?_.parser(t.toString("utf8",s+1,s+=h)):_.parser(t.toString("utf8",s,s+=h)),f.isRaw?W[q]=f.isRaw===!0?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 ar(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 or(t){if(f?x?f.retried?ae(f.retried):f.prepared&&an.has(x.routine)?Ar(f,x):ae(x):f.resolve(ge||A):x&&ae(x),f=ge=x=null,A=new we,v.cancel(),V){if(ee){if(!fe.in_hot_standby||!fe.default_transaction_read_only)return Sr();if(_r(ee,fe))return De()}if(Pe)return V.reserve&&(V=null),br();V&&!V.reserve&&je(V),e.shared.retries=O=0,V=null;return}for(;S.length&&(f=S.shift())&&(f.active=!0,f.cancelled);)Wt(e).cancel(f.state,f.cancelled.resolve,f.cancelled.reject);f||(Y.reserved?!Y.reserved.release&&t[5]===73?D?De():(Y.reserved=null,n(Y)):Y.reserved():D?De():n(Y))}function ir(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(Ue&&(Ue(),Ue=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 Ct();f.cursorFn&&(A.count&&f.cursorFn(A),K(be))}function cr(){f.parsing=!1}function Ct(){!A.statement&&(A.statement=f.statement),A.columns=f.statement.columns}function lr(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(Qe(f)),f.describeFirst=!1)}function ur(t){A.command&&(ge=ge||[A],ge.push(A=new we),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),ye=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[ye],table:W,number:q,type:ye},h+=18}if(A.statement=f.statement,f.onlyDescribe)return f.resolve(f.statement),K(be)}async function fr(t,s=t.readUInt32BE(5)){(s===3?mr:s===5?dr:s===10?pr:s===11?hr:s===12?gr:s!==0?Lr:Ne)(t,s)}async function mr(){let t=await nt();K(p().p().str(t).z(1).end())}async function dr(t){let s="md5"+await Yt(Buffer.concat([Buffer.from(await Yt(await nt()+d)),t.subarray(9)]));K(p().p().str(s).z(1).end())}async function pr(){et=(await $e.randomBytes(18)).toString("base64"),p().p().str("SCRAM-SHA-256"+p.N);let t=p.i;K(p.inc(4).str("n,,n=*,r="+et).i32(p.i-t-4,t).end())}async function hr(t){let s=t.toString("utf8",9).split(",").reduce((q,ye)=>(q[ye[0]]=ye.slice(2),q),{}),h=await $e.pbkdf2Sync(await nt(),Buffer.from(s.s,"base64"),parseInt(s.i),32,"sha256"),_=await Ze(h,"Client Key"),M="n=*,r="+et+",r="+s.r+",s="+s.s+",i="+s.i+",c=biws,r="+s.r;Z=(await Ze(await Ze(h,"Server Key"),M)).toString("base64");let W="c=biws,r="+s.r+",p="+ln(_,Buffer.from(await Ze(await cn(_),M))).toString("base64");K(p().p().str(W).end())}function gr(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 nt(){return Promise.resolve(typeof e.pass=="function"?e.pass():e.pass)}function yr(){if(A.statement=f.statement,A.statement.columns=[],f.onlyDescribe)return f.resolve(f.statement),K(be)}function wr(t){le.pid=t.readUInt32BE(5),le.secret=t.readUInt32BE(9)}async function br(){Pe=!1,(await new re([`
4
+ select b.oid, b.typarray
5
+ from pg_catalog.pg_type a
6
+ left join pg_catalog.pg_type b on b.oid = a.typelem
7
+ where a.typcategory = 'A'
8
+ group by b.oid, b.typarray
9
+ order by b.oid
10
+ `],[],je)).forEach(({oid:s,typarray:h})=>Er(s,h))}function Er(t,s){if(e.parsers[s]&&e.serializers[s])return;let h=e.parsers[t];e.shared.typeArrayMap[t]=s,e.parsers[s]=_=>Gt(_,h,s),e.parsers[s].array=!0,e.serializers[s]=_=>$t(_,e.serializers[t],e,s)}function _r(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 Sr(){let t=new re([`
11
+ show transaction_read_only;
12
+ select pg_catalog.pg_is_in_recovery()
13
+ `],[],je,null,{simple:!0});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 vr(t){f?((f.cursorFn||f.describeFirst)&&K(be),x=z.postgres(Je(t))):ae(z.postgres(Je(t)))}function Ar(t,s){delete l[t.signature],t.retried=s,je(t)}function Or(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 Pr(){try{let t=await Promise.resolve(f.cursorFn(A));G=0,t===Te?K($r(f.portal)):(A=new we,K(It("",f.cursorRows)))}catch(t){K(be),f.reject(t)}}function Br(){A.count&&f.cursorFn(A),f.resolve(A)}function Cr(){I=new gt.Writable({autoDestroy:!0,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()),Ue=t,I=null}}),f.resolve(I)}function Tr(){I=new gt.Readable({read(){m.resume()}}),f.resolve(I)}function Ir(){I=new gt.Duplex({autoDestroy:!0,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()),Ue=t}}),f.resolve(I)}function Nr(t){I&&(I.push(t.subarray(5))||m.pause())}function Ur(){I&&I.push(null),I=null}function jr(t){R?R(Je(t)):console.log(Je(t))}function Rr(){}function Dr(){ae(z.notSupported("FunctionCallResponse"))}function kr(){ae(z.notSupported("NegotiateProtocolVersion"))}function Fr(t){console.error("Postgres.js : Unknown Message:",t[0])}function Lr(t,s){console.error("Postgres.js : Unknown Auth:",s)}function Mr(t,s,h="",_=""){let M,W;return p().B().str(_+p.N).str(h+p.N).i16(0).i16(t.length),t.forEach((q,ye)=>{if(q===null)return p.i32(4294967295);W=s[ye],t[ye]=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 Tt(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 zr(t,s=""){return p().D().str(t).str(s+p.N).end()}function It(t="",s=0){return Buffer.concat([p().E().str(t+p.N).i32(s).end(),Vt])}function $r(t=""){return Buffer.concat([p().C().str("P").str(t+p.N).end(),p().S().end()])}function Gr(){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 Je(e){let r={},n=5;for(let a=5;a<e.length-1;a++)e[a]===0&&(r[on[e[n]]]=e.toString("utf8",n+1,a),n=a+1);return r}function Yt(e){return $e.createHash("md5").update(e).digest("hex")}function Ze(e,r){return $e.createHmac("sha256",e).update(r).digest()}function cn(e){return $e.createHash("sha256").update(e).digest()}function ln(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 yt(e,r){if(r=typeof r=="function"?r():r,!r)return{cancel:Ne,start:Ne};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}}Q();var Xt=()=>{};function bt(e,r){let n=new Map,a="postgresjs_"+Math.random().toString(36).slice(2),i={},u,o,c=!1,d=P.sql=e({...r,transform:{column:{},value:{},row:{}},max:1,fetch_types:!1,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:!0}),j=d.end,C=d.close;return d.end=async()=>(c=!0,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=Xt,oe=Xt){g=mn(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(he=>(b(he),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",he),ee.on("close",g.close),{stream:ee,state:oe.state};function he(v){console.error("Unexpected error during logical streaming - reconnecting",v)}function le(v){v[0]===119?fn(v.subarray(25),S,g.options.parsers,Oe,r.transform):v[0]===107&&v[17]&&(S.lsn=v.subarray(1,9),Ee())}function Oe(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 Ee(){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 un(e){return new Date(Date.UTC(2e3,0,1)+Number(e/BigInt(1e3)))}function fn(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=un(o.readBigInt64BE(9)),r.lsn=o.subarray(1,9)},I:o=>{let c=1,d=r[o.readUInt32BE(c)],{row:j}=qe(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?qe(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?qe(o,d.columns,c+=3,i):null;C&&(c=C.i);let{row:P}=qe(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 qe(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===!0?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===!0?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 mn(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:"")}Q();import Jt from"stream";function Et(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`
14
+ select
15
+ lo_lseek64(${c}, location, 0) as position,
16
+ seek.size
17
+ from (
18
+ select
19
+ lo_lseek64($1, 0, 2) as size,
20
+ tell.location
21
+ from (select lo_tell64($1) as location) tell
22
+ ) seek
23
+ `};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 Jt.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 Jt.Writable({highWaterMark:P,write(E,R,g){d.write(E).then(()=>g(),g)}})}}).catch(i)})}Object.assign(xe,{PostgresError:_e,toPascal:ve,pascal:pt,toCamel:Se,camel:dt,toKebab:Ae,kebab:ht,fromPascal:Me,fromCamel:Le,fromKebab:ze,BigInt:{to:20,from:[20],parse:e=>BigInt(e),serialize:e=>e.toString()}});var ls=xe;function xe(e,r){let n=hn(e,r),a=n.no_subscribe||bt(xe,{...n}),i=!1,u=ne(),o=ne(),c=ne(),d=ne(),j=ne(),C=ne(),P=ne(),b=ne(),E={connecting:o,reserved:c,closed:d,ended:j,open:C,busy:P,full:b},R=[...Array(n.max)].map(()=>wt(n,E,{onopen:Pe,onend:J,onclose:fe})),g=H(Oe);return Object.assign(g,{get parameters(){return n.parameters},largeObject:Et.bind(null,g),subscribe:a,CLOSE:Te,END:Te,PostgresError:_e,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:he,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 Ie(n.transform.column.to?n.transform.column.to(w):w):new Fe(w,O)}function $(w,O=[],k={}){return arguments.length===2&&!Array.isArray(O)&&(k=O,O=[]),new re([w],O,l,v,{prepare:!1,...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=>{pn.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=xe({...n,max:1,idle_timeout:null,max_lifetime:null,fetch_types:!1,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=!0;let U=H($);return U.release=()=>{y.reserved=null,Pe(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=ge,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 _e&&D.code==="25P02"&&me||D}return Z||(w?await T`prepare transaction '${T.unsafe(w)}'`:await T`commit`),ce;function ge(D,I){return D&&Array.isArray(D.raw)?ge(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 he(l){return new ie(l,3802)}function le(l,y){return Array.isArray(l)?new ie(l,y||(l.length?Ve(l)||25:0),n.shared.typeArrayMap):le(Array.from(arguments))}function Oe(l){if(i)return l.reject(z.connection("CONNECTION_ENDED",n,n));if(C.length)return Ee(C.shift(),l);if(d.length)return A(d.shift(),l);P.length?Ee(P.shift(),l):u.push(l)}function Ee(l,y){return l.execute(y)?S(l,P):S(l,b)}function v(l){return new Promise((y,U)=>{l.state?l.active?wt(n).cancel(l.state,y,U):l.cancelled={resolve:y,reject:U}:(u.remove(l),l.cancelled=!0,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 Pe(l){if(u.length===0)return S(l,C);let y=Math.ceil(u.length/(o.length+1)),U=!0;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 hn(e,r){if(e&&e.shared)return e;let n=process.env,a=(!e||typeof e=="string"?r:e)||{},{url:i,multihost:u}=En(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||_n();a.no_prepare&&(a.prepare=!1),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:!1,sslnegotiation:null,idle_timeout:null,connect_timeout:30,max_lifetime:wn,max_pipeline:100,backoff:yn,keep_alive:60,prepare:!0,debug:!1,fetch_types:!0,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"?!1: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:gn(a,i,n),onnotice:a.onnotice,onnotify:a.onnotify,onclose:a.onclose,onparameter:a.onparameter,socket:a.socket,transform:bn(a.transform||{undefined:void 0}),parameters:{},shared:{retries:0,typeArrayMap:{}},...Mt(a.types)}}function gn(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 yn(e){return(.5+Math.random()/2)*Math.min(3**e/100,20)}function wn(){return 60*(30+Math.random()*30)}function bn(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 En(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 _n(){try{return dn.userInfo().username}catch{return process.env.USERNAME||process.env.USER||process.env.LOGNAME}}export{ls as default};
@@ -0,0 +1,2 @@
1
+ import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
+ import{b as d,c as e,d as f,e as g,f as h,g as i,h as j,i as k,j as l,k as m,l as n,m as o,n as p,o as q}from"./chunk-JUVTJQ7I.js";import{a,b,c}from"./chunk-FYZPEVAA.js";import"./chunk-5CIUNKHO.js";export{c as SysInfo,g as Utils,a as detectRuntime,k as existsSync,i as getAllEnv,l as getCwd,m as getDirname,h as getEnv,o as getMode,n as getPlatform,f as getRequire,b as getSysInfo,p as getTempDir,d as includeExcludeCron,e as nextCid,j as readTextFileSync,q as sleep};
package/package.json ADDED
@@ -0,0 +1,52 @@
1
+ {
2
+ "name": "@ckirg/corelib-cloud",
3
+ "version": "0.1.22",
4
+ "publishConfig": {
5
+ "access": "public"
6
+ },
7
+ "main": "dist/index.js",
8
+ "type": "module",
9
+ "types": "dist/index.d.ts",
10
+ "files": [
11
+ "dist"
12
+ ],
13
+ "dependencies": {
14
+ "@hono/node-server": "^2.0.4",
15
+ "hono": "^4.12.23",
16
+ "ky": "^2.0.2",
17
+ "serialize-error": "^13.0.1",
18
+ "@ckirg/corelib": "0.1.22",
19
+ "@ckirg/corelib-markets": "0.1.22"
20
+ },
21
+ "devDependencies": {
22
+ "@cloudflare/vite-plugin": "^1.40.0",
23
+ "@cloudflare/vitest-pool-workers": "^0.16.13",
24
+ "@cloudflare/workers-types": "^4.20260606.1",
25
+ "@types/aws-lambda": "^8.10.161",
26
+ "@types/deno": "^2.7.0",
27
+ "@types/node": "^25.9.2",
28
+ "bun-types": "^1.3.14",
29
+ "miniflare": "^4.20260603.0",
30
+ "tsup": "^8.5.1",
31
+ "typedoc": "^0.28.19",
32
+ "typescript": "^6.0.3",
33
+ "vite": "^8.0.16",
34
+ "vitest": "^4.1.8",
35
+ "wrangler": "^4.98.0"
36
+ },
37
+ "scripts": {
38
+ "dev": "wrangler dev",
39
+ "build": "tsup",
40
+ "postbuild": "node -e \"const fs=require('fs');const path=require('path');const awsDir=path.join('dist','aws');const crDir=path.join('dist','cloudrun');[awsDir, crDir].forEach(d => { if(!fs.existsSync(d)) fs.mkdirSync(d, {recursive:true}); const rust=path.join('..','ts-core','corelib-rust.node'); if(fs.existsSync(rust)) { fs.copyFileSync(rust, path.join(d,'corelib-rust.node')); console.log('✅ Copied corelib-rust.node to ' + d); } });\"",
41
+ "watch": "tsup --watch",
42
+ "test": "vitest",
43
+ "test:run": "vitest run",
44
+ "test:integration": "vitest run --config vitest.integration.config.ts && vitest run --config vitest.integration.worker.config.ts",
45
+ "test:worker": "vitest --config vitest.config.ts",
46
+ "typecheck": "tsc --noEmit",
47
+ "lint": "biome check . --write --unsafe --max-diagnostics=100",
48
+ "format": "biome format . --write",
49
+ "docs": "typedoc",
50
+ "clean": "del dist"
51
+ }
52
+ }