palgres 0.65.0 → 0.68.0

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.
@@ -0,0 +1,4 @@
1
+ /*! palgres 0.68.0 — Palbase SDK License (see LICENSE) */
2
+ var R=Symbol.for("palbase.backend.httpError"),b=Symbol.for("palbase.backend.engineRaised"),a=Object.freeze({uniqueViolation:"23505",foreignKeyViolation:"23503",serializationFailure:"40001",deadlockDetected:"40P01",queryCancelled:"57014",lockNotAvailable:"55P03",inFailedTransaction:"25P02",insufficientPrivilege:"42501"}),i=class extends Error{[R]=!0;status;error;errorDescription;data;retryAfter;constructor(n,o,e,r,s){super(e),this.name="HttpError",this.status=n,this.error=o,this.errorDescription=e,r!==void 0&&(this.data=r),s!==void 0&&(this.retryAfter=s)}};function O(t){return t[b]=!0,t}function q(t){return typeof t=="object"&&t!==null&&t[b]===!0}function c(t){let n=t.replace(/([a-z0-9])([A-Z])/g,"$1 $2");return n.charAt(0).toUpperCase()+n.slice(1).toLowerCase()}var g=class extends i{constructor(n,o){super(400,"bad_request",o??c("BadRequest"),n),this.name="BadRequest"}},E=class extends i{constructor(n,o,e){super(404,o??"not_found",n??c("NotFound"),e),this.name="NotFound"}},l=class extends i{constructor(n,o,e){super(409,o??"conflict",n??c("Conflict"),e),this.name="Conflict"}},p=class extends l{constraint;sqlstate=a.uniqueViolation;static is(n){return typeof n=="object"&&n!==null&&n.name==="UniqueViolation"&&typeof n.constraint=="string"}constructor(n,o,e,r){super(o??"Unique constraint violated",e??"unique_violation",r),this.name="UniqueViolation",this.constraint=n}};function x(t){if(typeof t!="object"||t===null||t.retryable!==!0)return!1;let n=t.sqlstate;return n===a.serializationFailure||n===a.deadlockDetected}var m=class extends l{retryable=!0;sqlstate;static is(n){return typeof n=="object"&&n!==null&&n.name==="SerializationFailure"}constructor(n=a.serializationFailure,o,e){super(o??"the transaction could not be serialized with a concurrent one \u2014 run it again from the start (put the reads a decision rests on and its writes in $atomic, with { retry: n })","serialization_failure",e),this.name="SerializationFailure",this.sqlstate=n}},y=class extends l{retryable=!0;sqlstate;static is(n){return typeof n=="object"&&n!==null&&n.name==="DeadlockDetected"}constructor(n=a.deadlockDetected,o,e){super(o??"deadlock: two transactions waited on each other's locks and this one was cancelled \u2014 take locks in one order: Database.$lockRows(table, ids) when you have the ids, Database.$lockRowsWhere(table, filter) when you have a filter","deadlock_detected",e),this.name="DeadlockDetected",this.sqlstate=n}},w=class extends Error{sqlstate=a.inFailedTransaction;static is(n){return typeof n=="object"&&n!==null&&n.name==="TransactionAborted"}constructor(n,o){super(n,{cause:o}),this.name="TransactionAborted"}},k=class extends i{constructor(n,o){super(429,"too_many_requests",o??c("TooManyRequests"),n,n.retryAfter),this.name="TooManyRequests"}};function h(t){let n=t,o=e=>typeof e=="string"&&/^[0-9A-Z]{5}$/.test(e);if(o(n?.code))return n.code;if(o(n?.errno))return n.errno}var _=new Set(["57P03","53300","08001","08004","ERR_POSTGRES_CONNECTION_REFUSED","ERR_POSTGRES_CONNECTION_FAILED","ERR_POSTGRES_CONNECTION_TIMEOUT","ECONNREFUSED","CONNECT_TIMEOUT"]),N=new Set(["57P01","57P02","08000","08003","08006","08007","08P01","ERR_POSTGRES_CONNECTION_CLOSED","CONNECTION_CLOSED","CONNECTION_DESTROYED","ECONNRESET","ETIMEDOUT","EPIPE"]);function C(t){return t instanceof Error&&t.code===void 0&&t.message==="connection must be a PostgresSQLConnection"}function D(t){let n=t;for(let o=0;o<4&&typeof n=="object"&&n!==null;o++){let e=h(n),r=n.code,s=f=>e!==void 0&&f.has(e)||typeof r=="string"&&f.has(r);if(s(N))return"lost";if(s(_))return"never";n=n.cause}}function A(t){let n=t;for(let o=0;o<4&&typeof n=="object"&&n!==null;o++){let e=n.sqlstate,r=h(n)??(typeof e=="string"?e:void 0);if(r!==void 0)return!r.startsWith("08")&&!/^57P0[123]$/.test(r);n=n.cause}return!1}function I(t){let n=t,o=n?.constraint??n?.constraint_name;if(typeof o=="string"&&o.length>0)return o;let e=String(t?.message??"");return/violates unique constraint "([^"]+)"/.exec(e)?.[1]??""}var u=t=>`"${t.replace(/"/g,'""')}"`,P=(t,n)=>`${u(t)}.${u(n)}`,$=t=>`'${t.replace(/'/g,"''")}'`;function F(t){if(t.includes("\0"))throw new TypeError("a NUL character cannot be sent to Postgres");return`E'${t.replace(/\\/g,"\\\\").replace(/'/g,"''")}'`}var z=t=>t.map(u).join(", "),T=new Set(["now","current_timestamp","current_date","current_time","localtimestamp","localtime","transaction_timestamp","statement_timestamp"]);function M(t){return[...d(t)].some(n=>n.call&&!T.has(n.name.toLowerCase()))}function*d(t){let n=0;for(;n<t.length;){let o=t[n];if(o==="'"){for(n++;n<t.length;)if(t[n]==="'"&&t[n+1]==="'")n+=2;else{if(t[n]==="'")break;n++}n++;continue}if(o==="$"){let e=/^\$[A-Za-z_]*\$/.exec(t.slice(n));if(e){let r=t.indexOf(e[0],n+e[0].length);n=r<0?t.length:r+e[0].length;continue}}if(o==='"'){let e=n+1,r="";for(;e<t.length;)if(t[e]==='"'&&t[e+1]==='"')r+='"',e+=2;else{if(t[e]==='"')break;r+=t[e++]}let s=e+1;yield{start:n,end:s,name:r,quoted:!0,call:/^\s*\(/.test(t.slice(s))},n=s;continue}if(/[A-Za-z_]/.test(o)&&(n===0||!/[A-Za-z0-9_$]/.test(t[n-1]))){let e=/^[A-Za-z_][A-Za-z0-9_$]*/.exec(t.slice(n)),r=n+e[0].length;yield{start:n,end:r,name:e[0],quoted:!1,call:/^\s*\(/.test(t.slice(r))},n=r;continue}n++}}function j(t,n){for(let o of d(t))if(!o.call&&(o.quoted?o.name===n:o.name.toLowerCase()===n.toLowerCase()))return!0;return!1}function U(t,n){if(n.size===0)return t;let o="",e=0;for(let r of d(t)){if(r.call)continue;let s=n.get(r.quoted?r.name:S(n,r.name)??"");s!==void 0&&(o+=t.slice(e,r.start)+u(s),e=r.end)}return o+t.slice(e)}function S(t,n){if(t.has(n))return n;let o=n.toLowerCase();for(let e of t.keys())if(e.toLowerCase()===o)return e}var v=t=>`(NOT EXISTS (SELECT 1 FROM unnest(i.indclass::oid[]) AS oc(oid) JOIN pg_catalog.pg_opclass o ON o.oid = oc.oid WHERE NOT o.opcdefault)
3
+ AND NOT i.indnullsnotdistinct AND ${t}.reloptions IS NULL
4
+ AND NOT EXISTS (SELECT 1 FROM unnest(i.indcollation::oid[], i.indkey::int2[]) AS x(coll, att) JOIN pg_catalog.pg_attribute a ON a.attrelid = i.indrelid AND a.attnum = x.att WHERE x.att > 0 AND x.coll <> a.attcollation))`;export{u as a,P as b,$ as c,F as d,z as e,M as f,j as g,U as h,v as i,R as j,b as k,a as l,i as m,O as n,q as o,g as p,E as q,l as r,p as s,x as t,m as u,y as v,w,k as x,h as y,_ as z,N as A,C as B,D as C,A as D,I as E};