viborm 1.16.0 → 1.16.1
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/adapters.d.mts +1 -1
- package/dist/args-7WgBFd_f.mjs +1 -1
- package/dist/batch-refs-Bd8HvwUc.mjs +1 -1
- package/dist/better-auth.d.mts +1 -1
- package/dist/bun-sql.d.mts +1 -1
- package/dist/bun-sql.mjs +1 -1
- package/dist/bun-sqlite.d.mts +1 -1
- package/dist/bun-sqlite.mjs +1 -1
- package/dist/cache/cloudflare-kv.d.mts +1 -1
- package/dist/cache/memory.d.mts +1 -1
- package/dist/cache.d.mts +2 -2
- package/dist/call-0bd_B9Vp.mjs +1 -1
- package/dist/cli.mjs +2 -2
- package/dist/{client-Dlz3-2JC.d.mts → client-Bb2oZOzg.d.mts} +1 -1
- package/dist/{client-DEfFqv4S.mjs → client-BvAmGuYW.mjs} +5 -5
- package/dist/client-BvAmGuYW.mjs.map +1 -0
- package/dist/{client-D7sWgUt2.mjs → client-Q4zkYZbn.mjs} +2 -2
- package/dist/{client-D7sWgUt2.mjs.map → client-Q4zkYZbn.mjs.map} +1 -1
- package/dist/client.d.mts +2 -2
- package/dist/config.d.mts +1 -1
- package/dist/coordination-BxMskOgi.mjs +1 -1
- package/dist/d1.d.mts +1 -1
- package/dist/d1.mjs +1 -1
- package/dist/{database-adapter-BMjJiBFm.d.mts → database-adapter-01J6mYq5.d.mts} +1 -1
- package/dist/defaults-DAPb-tJ4.mjs +1 -1
- package/dist/{document-CHaVF7Vn.d.mts → document-DRPqjDv_.d.mts} +1 -1
- package/dist/{driver-BvTixv-m.d.mts → driver-CTjq1yxj.d.mts} +1 -1
- package/dist/driver.d.mts +1 -1
- package/dist/durable-object.d.mts +1 -1
- package/dist/durable-object.mjs +1 -1
- package/dist/error-mapping-B9rSvgG9.mjs +1 -1
- package/dist/every-CgeIFxWR.mjs +2 -0
- package/dist/{every-JpbiHdMb.mjs.map → every-CgeIFxWR.mjs.map} +1 -1
- package/dist/{exports-DYnTfvQo.d.mts → exports-nC8lsVKO.d.mts} +1 -1
- package/dist/extension-Dh1ddrlA.mjs +1 -1
- package/dist/geo-area-codec-Bti2PA2i.mjs +1 -1
- package/dist/index.d.mts +1 -1
- package/dist/index.mjs +1 -1
- package/dist/instrumentation.d.mts +1 -1
- package/dist/instrumentation.mjs +1 -1
- package/dist/{introspect-q3Rf_Xv8.mjs → introspect-rGqr93B3.mjs} +2 -2
- package/dist/{introspect-q3Rf_Xv8.mjs.map → introspect-rGqr93B3.mjs.map} +1 -1
- package/dist/judge-words-k5GCc4cV.mjs +1 -1
- package/dist/keys-DZdKAd4n.mjs +1 -1
- package/dist/{libsql-DEZ0uhK2.mjs → libsql-BZAXy5PY.mjs} +3 -3
- package/dist/{libsql-DEZ0uhK2.mjs.map → libsql-BZAXy5PY.mjs.map} +1 -1
- package/dist/libsql.d.mts +1 -1
- package/dist/libsql.mjs +1 -1
- package/dist/{memory-BaGWNdvk.mjs → memory-DgBGBQdJ.mjs} +2 -2
- package/dist/{memory-BaGWNdvk.mjs.map → memory-DgBGBQdJ.mjs.map} +1 -1
- package/dist/methods-part-BaNx3o7b.mjs +1 -1
- package/dist/migrations/mysql.d.mts +4 -4
- package/dist/migrations/mysql.mjs +1 -1
- package/dist/migrations/postgres.d.mts +4 -4
- package/dist/migrations/postgres.mjs +1 -1
- package/dist/migrations/snowflake.d.mts +4 -4
- package/dist/migrations/snowflake.mjs +1 -1
- package/dist/migrations/sqlite.d.mts +4 -4
- package/dist/migrations/sqlite.mjs +1 -1
- package/dist/migrations/surrealdb.d.mts +4 -4
- package/dist/migrations/surrealdb.mjs +1 -1
- package/dist/migrations/tenant.d.mts +2 -2
- package/dist/migrations/tenant.mjs +1 -1
- package/dist/migrations.d.mts +4 -4
- package/dist/migrations.mjs +1 -1
- package/dist/{mysql-BFPF8xyv.mjs → mysql-BjIAoFH6.mjs} +4 -4
- package/dist/{mysql-BFPF8xyv.mjs.map → mysql-BjIAoFH6.mjs.map} +1 -1
- package/dist/mysql2.d.mts +1 -1
- package/dist/mysql2.mjs +1 -1
- package/dist/named-statements-CkOOD__I.mjs +1 -1
- package/dist/native-types-1ewJXVks.mjs +1 -1
- package/dist/neon-http.d.mts +1 -1
- package/dist/neon-http.mjs +1 -1
- package/dist/{object-store-C4qmW7xf.d.mts → object-store-BBDTj8x3.d.mts} +3 -3
- package/dist/on.d.mts +1 -1
- package/dist/ordering.d.mts +1 -1
- package/dist/pending-operation-D4gUKMxD.mjs +1 -1
- package/dist/permissions.d.mts +1 -1
- package/dist/permissions.mjs +1 -1
- package/dist/pg.d.mts +1 -1
- package/dist/pg.mjs +1 -1
- package/dist/pglite.d.mts +1 -1
- package/dist/pglite.mjs +1 -1
- package/dist/pinned-session-Y7-2pRBJ.mjs +1 -1
- package/dist/planetscale.d.mts +1 -1
- package/dist/planetscale.mjs +1 -1
- package/dist/{planner-C-zjj19U.d.mts → planner-CYu6_q4w.d.mts} +1 -1
- package/dist/{postgres-DQQE2ys_.mjs → postgres-CaMB2Y4p.mjs} +13 -12
- package/dist/postgres-CaMB2Y4p.mjs.map +1 -0
- package/dist/postgres-adapter-psTVfuw7.mjs +1 -1
- package/dist/postgres.d.mts +1 -1
- package/dist/postgres.mjs +1 -1
- package/dist/provider-limits-SdI1SaJS.mjs +2 -0
- package/dist/provider-limits-SdI1SaJS.mjs.map +1 -0
- package/dist/query-BTb6iakn.mjs +1 -1
- package/dist/raw-DqEb71JZ.mjs +1 -1
- package/dist/rows-of-Bgl9GVtK.mjs +1 -1
- package/dist/rule-words-DMbQuvD2.mjs +1 -1
- package/dist/schema/introspect.d.mts +2 -2
- package/dist/schema/introspect.mjs +1 -1
- package/dist/schema/json.d.mts +2 -2
- package/dist/schema-DDkAUfOb.mjs +1 -1
- package/dist/schema.d.mts +1 -1
- package/dist/{serializer-ettLu5xG.mjs → serializer-Br9JgpQI.mjs} +16 -16
- package/dist/serializer-Br9JgpQI.mjs.map +1 -0
- package/dist/settled-DYYPcaBX.mjs +1 -1
- package/dist/{snowflake-BfF8xwfP.mjs → snowflake-B8Ei88bg.mjs} +2 -2
- package/dist/{snowflake-BfF8xwfP.mjs.map → snowflake-B8Ei88bg.mjs.map} +1 -1
- package/dist/snowflake.d.mts +1 -1
- package/dist/snowflake.mjs +1 -1
- package/dist/soft-delete.d.mts +1 -1
- package/dist/{sql-Bu63iAfT.mjs → sql-M5WsPhqr.mjs} +2 -2
- package/dist/{sql-Bu63iAfT.mjs.map → sql-M5WsPhqr.mjs.map} +1 -1
- package/dist/sqlite3.d.mts +1 -1
- package/dist/sqlite3.mjs +1 -1
- package/dist/standard-sql-Bl2OHGfi.mjs +1 -1
- package/dist/surrealdb.d.mts +1 -1
- package/dist/surrealdb.mjs +1 -1
- package/dist/{surrealql-DY74AUeD.mjs → surrealql-f2Rgu47F.mjs} +2 -2
- package/dist/{surrealql-DY74AUeD.mjs.map → surrealql-f2Rgu47F.mjs.map} +1 -1
- package/dist/unit-words-BXpLpyr2.mjs +1 -1
- package/dist/validation-BHjx13zG.mjs +1 -1
- package/dist/validation.d.mts +1 -1
- package/dist/validator-DMzH5Tz0.mjs +1 -1
- package/dist/version-Bu2LCuaj.mjs +2 -0
- package/dist/{version-0BDwfy7C.mjs.map → version-Bu2LCuaj.mjs.map} +1 -1
- package/package.json +1 -1
- package/dist/client-DEfFqv4S.mjs.map +0 -1
- package/dist/every-JpbiHdMb.mjs +0 -2
- package/dist/postgres-DQQE2ys_.mjs.map +0 -1
- package/dist/provider-limits-Bcsz0EJv.mjs +0 -2
- package/dist/provider-limits-Bcsz0EJv.mjs.map +0 -1
- package/dist/serializer-ettLu5xG.mjs.map +0 -1
- package/dist/version-0BDwfy7C.mjs +0 -2
package/dist/client.d.mts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { Br as NoExtraOperationKeys, Cr as UnwrapPendingOperation, Ct as RowsFragment, Di as LinkedClientConfig, Ei as Linked, Fr as CachedClient, Gr as Schema, Hr as OperationPayloadSchema, Ir as CallOptions, Jr as BatchPayload, K as StampedFields, Ki as IndexDefinition, Kr as ValidatedOperationPayload, Lr as Client, Oi as Links, Pr as CacheableOperations, Qr as InferSelectInclude, Rr as InferDatabase, Sr as PendingOperation, St as RawOperation, Ti as FlatSchema, Tr as isPendingOperation, U as PlacedArgument, Ur as OperationResult, Vr as OperationPayload, Wr as Operations, Xr as CountResultType, Yr as ClientHiddenContext, Zr as GroupByResultType, _r as getOperationPayloadSchema, br as validateOperationPayload, bt as ExtensionResultConsumerState, ct as ExtendedClient, et as AddedProjectedState, ki as RelationLinks, nt as ClientTypeState, qi as IndexOptions, qr as AggregateResultType, qt as VibSchema, tt as CachedClientOf, va as ObjectSchema, vr as renderOperationResultType, wi as ClientSchema, wr as UnwrapPendingOperations, xr as ProjectedModelOperations, yr as renderSchemaType, zr as MutationOperations } from "./database-adapter-
|
|
2
|
-
import { n as ClientOmitConfig, r as ExactClientOmitConfig, t as defaultOmit } from "./exports-
|
|
1
|
+
import { Br as NoExtraOperationKeys, Cr as UnwrapPendingOperation, Ct as RowsFragment, Di as LinkedClientConfig, Ei as Linked, Fr as CachedClient, Gr as Schema, Hr as OperationPayloadSchema, Ir as CallOptions, Jr as BatchPayload, K as StampedFields, Ki as IndexDefinition, Kr as ValidatedOperationPayload, Lr as Client, Oi as Links, Pr as CacheableOperations, Qr as InferSelectInclude, Rr as InferDatabase, Sr as PendingOperation, St as RawOperation, Ti as FlatSchema, Tr as isPendingOperation, U as PlacedArgument, Ur as OperationResult, Vr as OperationPayload, Wr as Operations, Xr as CountResultType, Yr as ClientHiddenContext, Zr as GroupByResultType, _r as getOperationPayloadSchema, br as validateOperationPayload, bt as ExtensionResultConsumerState, ct as ExtendedClient, et as AddedProjectedState, ki as RelationLinks, nt as ClientTypeState, qi as IndexOptions, qr as AggregateResultType, qt as VibSchema, tt as CachedClientOf, va as ObjectSchema, vr as renderOperationResultType, wi as ClientSchema, wr as UnwrapPendingOperations, xr as ProjectedModelOperations, yr as renderSchemaType, zr as MutationOperations } from "./database-adapter-01J6mYq5.mjs";
|
|
2
|
+
import { n as ClientOmitConfig, r as ExactClientOmitConfig, t as defaultOmit } from "./exports-nC8lsVKO.mjs";
|
|
3
3
|
export { type AddedProjectedState, type AggregateResultType, type BatchPayload, type CacheableOperations, type CachedClient, type CachedClientOf, type CallOptions, type Client, type ClientHiddenContext, type ClientOmitConfig, type ClientSchema, type ClientTypeState, type CountResultType, type ExactClientOmitConfig, type ExtendedClient, type ExtensionResultConsumerState, type FlatSchema, type GroupByResultType, type IndexDefinition, type IndexOptions, type InferDatabase, type InferSelectInclude, type Linked, type LinkedClientConfig, type Links, type MutationOperations, type NoExtraOperationKeys, type ObjectSchema, type OperationPayload, type OperationPayloadSchema, type OperationResult, type Operations, PendingOperation, type PlacedArgument, type ProjectedModelOperations, type RawOperation, type RelationLinks, type RowsFragment, type Schema, type StampedFields, type UnwrapPendingOperation, type UnwrapPendingOperations, type ValidatedOperationPayload, type VibSchema, defaultOmit, getOperationPayloadSchema, isPendingOperation, renderOperationResultType, renderSchemaType, validateOperationPayload };
|
package/dist/config.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { i as ResolveCallback, t as MigrationClient } from "./planner-
|
|
1
|
+
import { i as ResolveCallback, t as MigrationClient } from "./planner-CYu6_q4w.mjs";
|
|
2
2
|
import { n as MigrationStorageWriter } from "./contract-CxJn0_cV.mjs";
|
|
3
3
|
|
|
4
4
|
//#region src/cli/utils.d.ts
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{r as e,t}from"./transaction-operation-CaWzo7gE.mjs";import{N as n,i as r,t as i,y as a}from"./error-mapping-B9rSvgG9.mjs";import{S as o,a as s,b as c,t as l}from"./base-17NSFtrA.mjs";import{c as u,d,l as f,o as p,p as m,s as h,u as g,y as ee}from"./validation-ATmgN5RE.mjs";import{n as _,t as v}from"./transaction-Bv5nyp-U.mjs";import{s as y,t as b}from"./normalized-result-D7nVkF36.mjs";import{r as x}from"./routed-operations-CcKOdn51.mjs";function S(e,t,n){if(e.kind===`foreignKey`)return new a(e.message,{meta:{model:t,operation:n}});if(e.kind===`nestedWrite`){let t=new f(e.message,e.relation??``);return e.lg&&(t.meta.lg=!0),t}if(e.kind===`notFound`)return new g(t,n);if(e.kind===`forbidden`)return new p(t,n,e.reason===void 0?void 0:{reason:e.reason});let r=new _(e.message,{meta:{model:t,operation:n}});return e.lg&&(r.meta.lg=!0),r}async function C(e,t,n,r=[]){if(!(e instanceof u))return e;let a=e.meta.statementIndex;if(typeof a==`number`){let n=t.find(e=>e.gd===a);return n?S(n.failure,n.model,n.operation):e}if(t.length>0&&i(r,n.dialect,new Set(t.map(e=>e.gd))))return e;for(let e of t){let t=(await n._execute(e.mv,r[e.gd]?.context)).rows.length>0;if(e.pz===`exists`?!t:t)return S(e.failure,e.model,e.operation)}let[o]=t;return o?t.every(e=>w(e,o))?S(o.failure,o.model,o.operation):e:new f(h,``,{code:`V7006`,cause:e})}function w(e,t){return e.model===t.model&&e.operation===t.operation&&e.failure.kind===t.failure.kind&&e.failure.message===t.failure.message&&e.failure.relation===t.failure.relation&&e.failure.reason===t.failure.reason&&e.failure.lg===t.failure.lg}function te(t,n,r,i){let a,o;try{let e=t.length;if(!Number.isInteger(e)||e<0||e>4294967295)throw new v;let n=Array(e);for(let r=0;r<e;r+=1)n[r]=t[r];a=n}catch(e){o=e}let s=t=>{if(a===void 0)throw o;if(le(a,n),a.length===0)return Promise.resolve(a);if(t===void 0)for(let t of[`input`,`plan`])for(let n of a)e(n).mz(n,t);return ne(a,n,r,i,t)},c=n.el?.rq;if(c===void 0)return T(a,n,s);let l={};return T(a,n,()=>c.run({kind:`batch`,operation:`$transaction([...])`,context:i,certainty:()=>l.certainty},()=>s(l)))}function T(t,n,r){let i=n.el;if(i?.fields===void 0&&i?.watch===void 0)return r();let a=[...t??[]];return r().then(async t=>{let n=[];for(let[r,i]of a.entries()){let a=e(i);try{a.hg&&(t[r]=await a.hg(i,t[r]))}catch(e){n.push(e)}}if(n.length===1)throw n[0];if(n.length>1)throw AggregateError(n,`Array members failed after commit.`,{cause:n[0]});return t})}function ne(e,t,n,r,i){let{driver:a}=t,o=!a.supportsTransactions&&a.supportsBatch;o||se(a);let s=t.el,c=s?.df;return c&&(s?.rq?o||c.oz:c.qv?.(e))?re(e,t,n,r,i,c,o):o?D(e,a,n,r):E(e,t,n,r,i)}async function re(t,n,r,i,a,o,s){let{driver:c}=n,l=$(n,a??{}),u=t.map(t=>({operation:t,owner:e(t),child:N()})),d=await n.el?.rq?.members(u.map(e=>[{...e.owner.unit(e.operation),certainty:()=>e.certainty},()=>e.child.promise.then(O,O).then(()=>k(e))]));try{for(let e of u)e.owner.pp(e.operation,c);for(let e of[`input`,`plan`])for(let t of u)await t.owner.ow(t.operation,c,()=>t.owner.mz(t.operation,e))}catch(e){for(let t of u)t.child.reject(e);throw e}let f=await o.oz?.(u,l);if(f!==void 0)throw j(f[0],f.slice(1));let p;try{p=await(s?D(t,c,r,i,u,l,a):E(t,n,r,i,a,u,l))}catch(e){for(let t of u)t.child.reject(e);throw e}return await d?.done,p}function E(t,n,r,i,a,o,s){let c=t;return Q(n,r,i,async n=>{for(let r=0;r<t.length;r+=1){let i=t[r],a=o?.[r];if(a===void 0){c[r]=await e(i).fh(i,n);continue}a.owner.jm(i,n,a.notifications).then(a.child.resolve,a.child.reject);try{c[r]=await k(a)}catch(e){await A(o.slice(r+1),[e])}}return c},s,a)}async function D(t,n,r,i,a,o,s){if(a===void 0)for(let r of t)e(r).pp(r,n);let c,l=[],u=async e=>{if(!c){c=e,s&&(s.certainty=e);for(let t of a){t.certainty=e;try{await t.notifications?.[e===`committed`?`committed`:`mayHaveCommitted`]()}catch(e){l.push(e)}}try{await o?.outcomes?.publish(e)}catch(e){l.push(e)}}},d=async(e,t)=>{if(a===void 0)return e;t&&await u(`may-have-committed`),await A(a,[c?M(e,c):e],l)},f,p,m;try{({queries:f,s7:p,parsers:m}=await ie(t,n))}catch(e){throw await d(e)}let h;try{h=await ae(n,f,p,r,i,a&&n.supportsOrderedCommittedSegments?()=>u(`committed`):void 0),a&&await u(`committed`),oe(n,h,f.length)}catch(e){throw await d(e,!0)}let g=t;for(let e=0;e<m.length;e+=1){let t=a?.[e];if(t===void 0)g[e]=await m[e](h);else try{t.child.resolve(await m[e](h))}catch(e){t.child.reject(M(e,`committed`))}}return a&&await A(a,[],l.map(e=>M(e,`committed`)),g),g}const O=()=>void 0;function k(e){return e.query??e.child.promise}async function A(e,t,n=[],r=[]){for(let n of e)n.child.reject(t[0]);for(let[n,i]of(await Promise.allSettled(e.map(k))).entries())i.status===`fulfilled`?r[n]=i.value:t.push(i.reason);if(t.push(...n),t.length>0)throw j(t[0],t.slice(1))}function j(e,t){let n=t.filter(t=>t!==e);return n.length===0?e:AggregateError([e,...n],`Array transaction and post-work failed.`,{cause:e})}function M(e,t){return s(e)?r(e,t):e}function N(){let e,t,n=new Promise((n,r)=>{e=n,t=r});return n.catch(O),{promise:n,resolve:e,reject:t}}async function ie(t,n){let r=[],i=[],a=[];for(let o of t){let t=e(o),s=await t.ow(o,n,async()=>{let e=t.prepare(o,n);return e?{prepared:e}:{bm:await t.prepareBatch(o)}}),c=r.length;if(s.prepared){r.push(s.prepared),a.push(e=>t.ow(o,n,()=>{let r=e[c];if(!r)throw P(n,`omitted result for "${t.operation(o)}"`,{operation:t.operation(o)});return t.parseResult(o,r)}));continue}let{bm:l}=s;if(!l)throw ce(n);let u=l.queries.length;for(let e of l.queries)r.push(e);for(let e of l.s7??[])i.push({...e,gd:c+e.gd});a.push(e=>t.ow(o,n,()=>l.parseResult(e.slice(c,c+u))))}return{queries:r,s7:i,parsers:a}}async function ae(e,t,n,r,i,a){try{return await e._executeBatch(t,r,i,a)}catch(r){throw await C(r,n,e,t)}}function oe(e,t,n){b(t,n,{provider:e.driverName,operation:`$transaction([...])`})}function se(e){if(!(e.supportsTransactions||e.supportsBatch))throw P(e,`lacks transactions and atomic batch`)}function ce(e){return P(e,`cannot batch atomically without transactions`)}function P(e,t,n={method:`$transaction([...])`}){return new _(`Driver "${e.driverName}" ${t}.`,{meta:{driver:e.driverName,...n}})}function le(e,n){for(let r of e){if(typeof r!=`object`||!r)throw new v;let e=t(r);if(e===void 0)throw new v;if(e.clientId(r)!==n.clientId)throw d.clientMismatch(e.model(r),e.operation(r));if(e.gx(r)!==n.gx)throw d.scopeMismatch(e.model(r),e.operation(r))}}const F=Symbol(`viborm.call`),I=Symbol(`viborm.scope`),L=Symbol(`viborm.attempt`),R=e=>typeof e==`object`&&!!e,z=e=>typeof e==`object`&&!!e&&`engine`in e;function B(e){let t=Reflect.get(e,F);return R(t)?t:void 0}function V(e){return Reflect.get(e,L)}function H(e){let t=Reflect.get(e,I);return z(t)?t:void 0}function U(e){return B(e)?.of?.engine??H(e)?.engine}const W=`called run() after its second moment returned`;function G(e,t,n,r,i,a,o){return e!==void 0||o?r||o?K(e,t,n,r,i,a,o,q):q(e,t,e=>n(void 0,e),a?.hm,a?.ml):n()}function K(e,t,n,r,i,a,o,s){let c=o?[o]:e?.call?.m9,l=c?.[0]?.tell?.(c,i),u=!1,d,f=e=>async()=>{u=!0,i||(d=e),await l?.(e)},p={committed:f(`committed`),mayHaveCommitted:f(`may-have-committed`)},m=async e=>{let t=await n(p,e);return r&&!u&&await p.committed(),t};return s&&e&&t?.length?s(e,t,m,()=>d??a?.hm?.(),a?.ml):m()}function q(e,t,n,r,i){let a=(o,s)=>{let c=t?.[o];return c===void 0?n(s):ue(e,c,e=>a(o+1,e??s),r,i,()=>n(s))};return a(0)}async function ue(e,t,n,r,i,a){let{extension:o}=t,s=e.mode===`direct`,c=s&&e.kind===`model`&&x(e.operation),l=c,u,d,f=t=>(d===void 0&&(d=J(o,e,t),i?.(d)),d),p={open:!0,failed:!1,done:!1,direct:s,c4:c,certainty:r,start(e){if(!p.open)throw f(`called run() more than once`);if(p.done)throw f(W);return p.open=!1,p.failed=!1,u=(async()=>n(e))(),u.then(void 0,()=>{p.failed=!0}),u}},m=Object.defineProperties(()=>{if(!p.done)return p.start();if(!l)throw f(W);return l=!1,(async()=>a())()},{input:{get:()=>e.input},mode:{value:e.mode},[F]:{value:e.kind===`model`?e.call:void 0},[L]:{value:p}}),h;try{h={value:await t.handler(e,m)}}catch(e){h={reason:e}}p.done=!0;let g=`reason`in h&&(d===void 0||h.reason!==d)?de(o,e,h.reason,r?.()):void 0;if(u===void 0){if(g!==void 0)throw g;if(e.mode===`array`||e.kind!==`model`||!x(e.operation))throw J(o,e,`returned without run()`)}else g!==void 0&&!p.failed&&i?.(g),await u;if(`value`in h&&d===void 0)return h.value;throw d??g}function de(e,t,n,r){return o(n)?n:J(e,t,`failed`,c(n),r)}function J(e,t,n,r,i){return new m(`Extension "${e}" around() for ${t.kind===`model`?`${t.model}.${t.operation}`:t.operation} ${n}.`,{...r&&{cause:r},meta:{method:`around`,model:t.model,operation:t.operation,...i===void 0?{}:{commitCertainty:i}}})}var fe=class{zd=[];publish(e){return X(this.zd.filter(e=>e.ok),{certainty:e})}async end({parent:e,root:t},n,i){if(!i)return e?Y(e).zd.push(...this.zd.filter(e=>e.ok)):await this.publish(`committed`),n;let{certainty:a}=t;if(e||a===void 0)throw n;let o=s(n)?r(n,a):n;try{await this.publish(a)}catch(e){throw ee(o,e)}throw o}};function Y(e){return e.outcomes??=new fe,e.outcomes}function pe(e,t){if(t===void 0)return t=>X(e,{certainty:t});for(let n of e)(n.collect?.(t)??t.outcomes)?.zd.push(n);return async()=>{for(let t of e)t.ok=!0}}async function X(e,t){let n;for(let{extension:r,listener:i}of e)try{await i(t)}catch(e){n??=e instanceof l?e:new m(`Extension "${r}" settled() failed (${t.certainty}).`,{cause:c(e),meta:{method:`settled`,commitCertainty:t.certainty}})}if(n)throw n}function Z(t){return t.some(t=>{let{cq:n,registration:r}=e(t).around(t);return n?.length||r})}async function me(e,t){for(let n of e){let{write:e,registration:r}=n.owner.around(n.operation);if(r===void 0)continue;let i=K(void 0,void 0,e=>(n.notifications=e,n.child.promise),e,t,void 0,r);n.query=i,i.catch(he)}}const he=()=>void 0;function ge(e,t,n){let r=e.map(e=>e.owner.around(e.operation));return _e(e,(i,a,o)=>{let{context:s,cq:c,write:l,registration:u}=r[e.indexOf(i)];return c?.length||u?n(s,c,a,l,t,o,u):a()})}async function _e(e,t){let n,r=e.length,i=N();r===0&&i.resolve();for(let a of e){let e=e=>{let t=a.admissionFailures??=[];t.includes(e)||t.push(e),n??={failure:e},i.reject(e)},o;try{o=t(a,e=>(a.notifications=e,--r,r===0&&i.resolve(),a.child.promise),{ml:e,hm:()=>a.certainty})}catch(t){e(t),o=Promise.reject(t)}a.query=o,o.catch(e)}try{if(await i.promise,await Promise.resolve(),n)throw n.failure;return}catch(t){for(let n of e)n.child.reject(t);await Promise.allSettled(e.map(k));let n=[];for(let t of e)for(let e of t.admissionFailures??[])n.includes(e)||n.push(e);return n}}const ve={rank:-1},ye={rank:1,cw:K,qv:Z,oz:me},be={rank:2,cw:G,qv:Z,oz:(e,t)=>ge(e,t,G)};function xe(e,t,n){n&&(e.collect=n),(e.df===void 0||t.rank>e.df.rank)&&(e.df=t)}function Q(e,t,r,i,a,o=a?.root??{}){let s=e.el,c=e.transaction,l,u=e=>t=>{if(e||c||(o.certainty=`committed`),!l?.outcomes){if(e)throw t;return t}let n=l.outcomes.end(l,t,e);return n.catch(()=>void 0),n},d=e.driver.withTransaction(t=>(l=a??$(e,o),i(t,l)),t,c||!(s?.df||s?.methods)?r:n(r,{oq:()=>{o.certainty=`may-have-committed`},committed:()=>{o.certainty=`committed`}}));return c?y(d,u()):d.then(u(),u(!0))}function $(e,t){let n={parent:e.transaction,root:t};return e.el?.collect?.(n),n}export{Q as a,pe as c,V as d,B as f,S as g,te as h,xe as i,F as l,H as m,be as n,Y as o,U as p,ve as r,X as s,ye as t,I as u};
|
|
1
|
+
import{r as e,t}from"./transaction-operation-CaWzo7gE.mjs";import{N as n,i as r,t as i,y as a}from"./error-mapping-B9rSvgG9.mjs";import{S as o,a as s,b as c,t as l}from"./base-17NSFtrA.mjs";import{c as u,d,l as f,o as p,p as m,s as h,u as g,y as ee}from"./validation-ATmgN5RE.mjs";import{n as _,t as v}from"./transaction-Bv5nyp-U.mjs";import{s as y,t as b}from"./normalized-result-D7nVkF36.mjs";import{r as x}from"./routed-operations-CcKOdn51.mjs";function S(e,t,n){if(e.kind===`foreignKey`)return new a(e.message,{meta:{model:t,operation:n}});if(e.kind===`nestedWrite`){let t=new f(e.message,e.relation??``);return e.lg&&(t.meta.lg=!0),t}if(e.kind===`notFound`)return new g(t,n);if(e.kind===`forbidden`)return new p(t,n,e.reason===void 0?void 0:{reason:e.reason});let r=new _(e.message,{meta:{model:t,operation:n}});return e.lg&&(r.meta.lg=!0),r}async function C(e,t,n,r=[]){if(!(e instanceof u))return e;let a=e.meta.statementIndex;if(typeof a==`number`){let n=t.find(e=>e.gd===a);return n?S(n.failure,n.model,n.operation):e}if(t.length>0&&i(r,n.dialect,new Set(t.map(e=>e.gd))))return e;for(let e of t){let t=(await n._execute(e.mv,r[e.gd]?.context)).rows.length>0;if(e.pz===`exists`?!t:t)return S(e.failure,e.model,e.operation)}let[o]=t;return o?t.every(e=>w(e,o))?S(o.failure,o.model,o.operation):e:new f(h,``,{code:`V7006`,cause:e})}function w(e,t){return e.model===t.model&&e.operation===t.operation&&e.failure.kind===t.failure.kind&&e.failure.message===t.failure.message&&e.failure.relation===t.failure.relation&&e.failure.reason===t.failure.reason&&e.failure.lg===t.failure.lg}function te(t,n,r,i){let a,o;try{let e=t.length;if(!Number.isInteger(e)||e<0||e>4294967295)throw new v;let n=Array(e);for(let r=0;r<e;r+=1)n[r]=t[r];a=n}catch(e){o=e}let s=t=>{if(a===void 0)throw o;if(le(a,n),a.length===0)return Promise.resolve(a);if(t===void 0)for(let t of[`input`,`plan`])for(let n of a)e(n).mz(n,t);return ne(a,n,r,i,t)},c=n.el?.rq;if(c===void 0)return T(a,n,s);let l={};return T(a,n,()=>c.run({kind:`batch`,operation:`$transaction([...])`,context:i,certainty:()=>l.certainty},()=>s(l)))}function T(t,n,r){let i=n.el;if(i?.fields===void 0&&i?.watch===void 0)return r();let a=[...t??[]];return r().then(async t=>{let n=[];for(let[r,i]of a.entries()){let a=e(i);try{a.hg&&(t[r]=await a.hg(i,t[r]))}catch(e){n.push(e)}}if(n.length===1)throw n[0];if(n.length>1)throw AggregateError(n,`Array members failed after commit.`,{cause:n[0]});return t})}function ne(e,t,n,r,i){let{driver:a}=t,o=!a.supportsTransactions&&a.supportsBatch;o||se(a);let s=t.el,c=s?.dh;return c&&(s?.rq?o||c.oz:c.qv?.(e))?re(e,t,n,r,i,c,o):o?D(e,a,n,r):E(e,t,n,r,i)}async function re(t,n,r,i,a,o,s){let{driver:c}=n,l=$(n,a??{}),u=t.map(t=>({operation:t,owner:e(t),child:N()})),d=await n.el?.rq?.members(u.map(e=>[{...e.owner.unit(e.operation),certainty:()=>e.certainty},()=>e.child.promise.then(O,O).then(()=>k(e))]));try{for(let e of u)e.owner.pp(e.operation,c);for(let e of[`input`,`plan`])for(let t of u)await t.owner.ow(t.operation,c,()=>t.owner.mz(t.operation,e))}catch(e){for(let t of u)t.child.reject(e);throw e}let f=await o.oz?.(u,l);if(f!==void 0)throw j(f[0],f.slice(1));let p;try{p=await(s?D(t,c,r,i,u,l,a):E(t,n,r,i,a,u,l))}catch(e){for(let t of u)t.child.reject(e);throw e}return await d?.done,p}function E(t,n,r,i,a,o,s){let c=t;return Q(n,r,i,async n=>{for(let r=0;r<t.length;r+=1){let i=t[r],a=o?.[r];if(a===void 0){c[r]=await e(i).fh(i,n);continue}a.owner.jm(i,n,a.notifications).then(a.child.resolve,a.child.reject);try{c[r]=await k(a)}catch(e){await A(o.slice(r+1),[e])}}return c},s,a)}async function D(t,n,r,i,a,o,s){if(a===void 0)for(let r of t)e(r).pp(r,n);let c,l=[],u=async e=>{if(!c){c=e,s&&(s.certainty=e);for(let t of a){t.certainty=e;try{await t.notifications?.[e===`committed`?`committed`:`mayHaveCommitted`]()}catch(e){l.push(e)}}try{await o?.outcomes?.publish(e)}catch(e){l.push(e)}}},d=async(e,t)=>{if(a===void 0)return e;t&&await u(`may-have-committed`),await A(a,[c?M(e,c):e],l)},f,p,m;try{({queries:f,s7:p,parsers:m}=await ie(t,n))}catch(e){throw await d(e)}let h;try{h=await ae(n,f,p,r,i,a&&n.supportsOrderedCommittedSegments?()=>u(`committed`):void 0),a&&await u(`committed`),oe(n,h,f.length)}catch(e){throw await d(e,!0)}let g=t;for(let e=0;e<m.length;e+=1){let t=a?.[e];if(t===void 0)g[e]=await m[e](h);else try{t.child.resolve(await m[e](h))}catch(e){t.child.reject(M(e,`committed`))}}return a&&await A(a,[],l.map(e=>M(e,`committed`)),g),g}const O=()=>void 0;function k(e){return e.query??e.child.promise}async function A(e,t,n=[],r=[]){for(let n of e)n.child.reject(t[0]);for(let[n,i]of(await Promise.allSettled(e.map(k))).entries())i.status===`fulfilled`?r[n]=i.value:t.push(i.reason);if(t.push(...n),t.length>0)throw j(t[0],t.slice(1))}function j(e,t){let n=t.filter(t=>t!==e);return n.length===0?e:AggregateError([e,...n],`Array transaction and post-work failed.`,{cause:e})}function M(e,t){return s(e)?r(e,t):e}function N(){let e,t,n=new Promise((n,r)=>{e=n,t=r});return n.catch(O),{promise:n,resolve:e,reject:t}}async function ie(t,n){let r=[],i=[],a=[];for(let o of t){let t=e(o),s=await t.ow(o,n,async()=>{let e=t.prepare(o,n);return e?{prepared:e}:{bm:await t.prepareBatch(o)}}),c=r.length;if(s.prepared){r.push(s.prepared),a.push(e=>t.ow(o,n,()=>{let r=e[c];if(!r)throw P(n,`omitted result for "${t.operation(o)}"`,{operation:t.operation(o)});return t.parseResult(o,r)}));continue}let{bm:l}=s;if(!l)throw ce(n);let u=l.queries.length;for(let e of l.queries)r.push(e);for(let e of l.s7??[])i.push({...e,gd:c+e.gd});a.push(e=>t.ow(o,n,()=>l.parseResult(e.slice(c,c+u))))}return{queries:r,s7:i,parsers:a}}async function ae(e,t,n,r,i,a){try{return await e._executeBatch(t,r,i,a)}catch(r){throw await C(r,n,e,t)}}function oe(e,t,n){b(t,n,{provider:e.driverName,operation:`$transaction([...])`})}function se(e){if(!(e.supportsTransactions||e.supportsBatch))throw P(e,`lacks transactions and atomic batch`)}function ce(e){return P(e,`cannot batch atomically without transactions`)}function P(e,t,n={method:`$transaction([...])`}){return new _(`Driver "${e.driverName}" ${t}.`,{meta:{driver:e.driverName,...n}})}function le(e,n){for(let r of e){if(typeof r!=`object`||!r)throw new v;let e=t(r);if(e===void 0)throw new v;if(e.clientId(r)!==n.clientId)throw d.clientMismatch(e.model(r),e.operation(r));if(e.gx(r)!==n.gx)throw d.scopeMismatch(e.model(r),e.operation(r))}}const F=Symbol(`viborm.call`),I=Symbol(`viborm.scope`),L=Symbol(`viborm.attempt`),R=e=>typeof e==`object`&&!!e,z=e=>typeof e==`object`&&!!e&&`engine`in e;function B(e){let t=Reflect.get(e,F);return R(t)?t:void 0}function V(e){return Reflect.get(e,L)}function H(e){let t=Reflect.get(e,I);return z(t)?t:void 0}function U(e){return B(e)?.of?.engine??H(e)?.engine}const W=`called run() after its second moment returned`;function G(e,t,n,r,i,a,o){return e!==void 0||o?r||o?K(e,t,n,r,i,a,o,q):q(e,t,e=>n(void 0,e),a?.hm,a?.ml):n()}function K(e,t,n,r,i,a,o,s){let c=o?[o]:e?.call?.m8,l=c?.[0]?.tell?.(c,i),u=!1,d,f=e=>async()=>{u=!0,i||(d=e),await l?.(e)},p={committed:f(`committed`),mayHaveCommitted:f(`may-have-committed`)},m=async e=>{let t=await n(p,e);return r&&!u&&await p.committed(),t};return s&&e&&t?.length?s(e,t,m,()=>d??a?.hm?.(),a?.ml):m()}function q(e,t,n,r,i){let a=(o,s)=>{let c=t?.[o];return c===void 0?n(s):ue(e,c,e=>a(o+1,e??s),r,i,()=>n(s))};return a(0)}async function ue(e,t,n,r,i,a){let{extension:o}=t,s=e.mode===`direct`,c=s&&e.kind===`model`&&x(e.operation),l=c,u,d,f=t=>(d===void 0&&(d=J(o,e,t),i?.(d)),d),p={open:!0,failed:!1,done:!1,direct:s,c3:c,certainty:r,start(e){if(!p.open)throw f(`called run() more than once`);if(p.done)throw f(W);return p.open=!1,p.failed=!1,u=(async()=>n(e))(),u.then(void 0,()=>{p.failed=!0}),u}},m=Object.defineProperties(()=>{if(!p.done)return p.start();if(!l)throw f(W);return l=!1,(async()=>a())()},{input:{get:()=>e.input},mode:{value:e.mode},[F]:{value:e.kind===`model`?e.call:void 0},[L]:{value:p}}),h;try{h={value:await t.handler(e,m)}}catch(e){h={reason:e}}p.done=!0;let g=`reason`in h&&(d===void 0||h.reason!==d)?de(o,e,h.reason,r?.()):void 0;if(u===void 0){if(g!==void 0)throw g;if(e.mode===`array`||e.kind!==`model`||!x(e.operation))throw J(o,e,`returned without run()`)}else g!==void 0&&!p.failed&&i?.(g),await u;if(`value`in h&&d===void 0)return h.value;throw d??g}function de(e,t,n,r){return o(n)?n:J(e,t,`failed`,c(n),r)}function J(e,t,n,r,i){return new m(`Extension "${e}" around() for ${t.kind===`model`?`${t.model}.${t.operation}`:t.operation} ${n}.`,{...r&&{cause:r},meta:{method:`around`,model:t.model,operation:t.operation,...i===void 0?{}:{commitCertainty:i}}})}var fe=class{zd=[];publish(e){return X(this.zd.filter(e=>e.ok),{certainty:e})}async end({parent:e,root:t},n,i){if(!i)return e?Y(e).zd.push(...this.zd.filter(e=>e.ok)):await this.publish(`committed`),n;let{certainty:a}=t;if(e||a===void 0)throw n;let o=s(n)?r(n,a):n;try{await this.publish(a)}catch(e){throw ee(o,e)}throw o}};function Y(e){return e.outcomes??=new fe,e.outcomes}function pe(e,t){if(t===void 0)return t=>X(e,{certainty:t});for(let n of e)(n.collect?.(t)??t.outcomes)?.zd.push(n);return async()=>{for(let t of e)t.ok=!0}}async function X(e,t){let n;for(let{extension:r,listener:i}of e)try{await i(t)}catch(e){n??=e instanceof l?e:new m(`Extension "${r}" settled() failed (${t.certainty}).`,{cause:c(e),meta:{method:`settled`,commitCertainty:t.certainty}})}if(n)throw n}function Z(t){return t.some(t=>{let{cq:n,registration:r}=e(t).around(t);return n?.length||r})}async function me(e,t){for(let n of e){let{write:e,registration:r}=n.owner.around(n.operation);if(r===void 0)continue;let i=K(void 0,void 0,e=>(n.notifications=e,n.child.promise),e,t,void 0,r);n.query=i,i.catch(he)}}const he=()=>void 0;function ge(e,t,n){let r=e.map(e=>e.owner.around(e.operation));return _e(e,(i,a,o)=>{let{context:s,cq:c,write:l,registration:u}=r[e.indexOf(i)];return c?.length||u?n(s,c,a,l,t,o,u):a()})}async function _e(e,t){let n,r=e.length,i=N();r===0&&i.resolve();for(let a of e){let e=e=>{let t=a.admissionFailures??=[];t.includes(e)||t.push(e),n??={failure:e},i.reject(e)},o;try{o=t(a,e=>(a.notifications=e,--r,r===0&&i.resolve(),a.child.promise),{ml:e,hm:()=>a.certainty})}catch(t){e(t),o=Promise.reject(t)}a.query=o,o.catch(e)}try{if(await i.promise,await Promise.resolve(),n)throw n.failure;return}catch(t){for(let n of e)n.child.reject(t);await Promise.allSettled(e.map(k));let n=[];for(let t of e)for(let e of t.admissionFailures??[])n.includes(e)||n.push(e);return n}}const ve={rank:-1},ye={rank:1,cw:K,qv:Z,oz:me},be={rank:2,cw:G,qv:Z,oz:(e,t)=>ge(e,t,G)};function xe(e,t,n){n&&(e.collect=n),(e.dh===void 0||t.rank>e.dh.rank)&&(e.dh=t)}function Q(e,t,r,i,a,o=a?.root??{}){let s=e.el,c=e.transaction,l,u=e=>t=>{if(e||c||(o.certainty=`committed`),!l?.outcomes){if(e)throw t;return t}let n=l.outcomes.end(l,t,e);return n.catch(()=>void 0),n},d=e.driver.withTransaction(t=>(l=a??$(e,o),i(t,l)),t,c||!(s?.dh||s?.methods)?r:n(r,{oq:()=>{o.certainty=`may-have-committed`},committed:()=>{o.certainty=`committed`}}));return c?y(d,u()):d.then(u(),u(!0))}function $(e,t){let n={parent:e.transaction,root:t};return e.el?.collect?.(n),n}export{Q as a,pe as c,V as d,B as f,S as g,te as h,xe as i,F as l,H as m,be as n,Y as o,U as p,ve as r,X as s,ye as t,I as u};
|
|
2
2
|
//# sourceMappingURL=coordination-BxMskOgi.mjs.map
|
package/dist/d1.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { $a as QueryExecutionContext, C as DriverResultParser, Di as LinkedClientConfig, Gr as Schema, Ja as TransactionOptionSupport, Xa as BatchQuery, Za as CommittedBatchNotification, b as SqliteMigrationCapability, eo as QueryResult, h as Driver, pt as VibORMClient, st as DriverConfig, t as DatabaseAdapter, ut as NoExtraDriverConfigKeys } from "./database-adapter-
|
|
1
|
+
import { $a as QueryExecutionContext, C as DriverResultParser, Di as LinkedClientConfig, Gr as Schema, Ja as TransactionOptionSupport, Xa as BatchQuery, Za as CommittedBatchNotification, b as SqliteMigrationCapability, eo as QueryResult, h as Driver, pt as VibORMClient, st as DriverConfig, t as DatabaseAdapter, ut as NoExtraDriverConfigKeys } from "./database-adapter-01J6mYq5.mjs";
|
|
2
2
|
import { D1Database, D1DatabaseSession } from "@cloudflare/workers-types";
|
|
3
3
|
|
|
4
4
|
//#region src/drivers/d1/index.d.ts
|
package/dist/d1.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{h as e}from"./error-mapping-B9rSvgG9.mjs";import{p as t}from"./validation-ATmgN5RE.mjs";import{i as n,n as r}from"./normalized-result-D7nVkF36.mjs";import{t as i}from"./bind-parameter-capacity-BAFQM9Jt.mjs";import{f as a,n as o,u as s}from"./client-
|
|
1
|
+
import{h as e}from"./error-mapping-B9rSvgG9.mjs";import{p as t}from"./validation-ATmgN5RE.mjs";import{i as n,n as r}from"./normalized-result-D7nVkF36.mjs";import{t as i}from"./bind-parameter-capacity-BAFQM9Jt.mjs";import{f as a,n as o,u as s}from"./client-Q4zkYZbn.mjs";import{r as c}from"./provider-parameter-snapshot-cyTUDutH.mjs";import{t as l}from"./sqlite-adapter-Cb-SJw2f.mjs";import{f as u,h as d,r as f,t as p,u as m}from"./driver-lShUkDmf.mjs";import{l as h,o as g,r as _}from"./sqlite-utils-Bfmtkt1b.mjs";import{n as v,t as y}from"./sqlite-statement-classifier-JBHiQO6Q.mjs";const b={database:!0};function x(e){return _(e).map(e=>typeof e==`bigint`?e.toString():e)}const S=new Set(`aggregate count create createManyAndReturn delete deleteManyAndReturn exist findFirst findMany findUnique groupBy update updateManyAndReturn upsert`.split(` `));function C(e,n){let r=e.operation??`execute`;return new t(`Driver "d1" malformed payload for "${r}": ${n}.`,{meta:{driver:`d1`,...e,operation:r}})}function w(e,t){let r=n(e)?e.meta:void 0;if(!n(e)||e.success!==!0||e.results!==null&&!(Array.isArray(e.results)&&e.results.every(n))||!n(r)||!Number.isSafeInteger(r.changes)||r.changes<0||!Number.isInteger(r.last_row_id))throw C(t,`invalid results/meta`)}function T(e,t,n,r){let i=n.operation??`execute`;w(e,n);let a;if(e.results===null){if(r&&S.has(i)||y(t)!==`no-rows`)throw C(n,`null results`);a=[]}else a=e.results;let o=v(t)&&Number.isSafeInteger(e.meta.last_row_id)?e.meta.last_row_id:void 0;return{rows:a,rowCount:e.meta.changes===0?a.length:e.meta.changes,...o!==void 0&&o>0?{insertId:o}:{}}}function E(e){let{result:t}=e;return[e,t,t.parseField,t.parseRelation,t.parseResult]}const D=new WeakMap;function O(e){if(!(e instanceof j))return!1;let t=D.get(e);if(!t)return!1;let{adapter:n}=e,{result:r}=n;return Object.getPrototypeOf(e)===j.prototype&&e._execute===M&&e.execute===N&&e.executeTypedStatement===P&&e.result===h&&e.result.parseField===g&&e.result.parseRelation===void 0&&e.result.parseResult===void 0&&t[0]===n&&t[1]===r&&t[2]===r.parseField&&t[3]===r.parseRelation&&t[4]===r.parseResult}async function k(e,t,n,r){let i=x(n);return T(await e.prepare(t).bind(...i).run(),t,r,!0)}function A(e,t,n){return e.executeTypedStatement(t,n,async(t,n,i,a)=>{if(!O(e)){let o=await e.execute(t,n,i,a);return r(o,{provider:e.driverName,operation:a.operation??`execute`}),{kind:`borrowed`,result:o}}let o=x(i),c=await t.prepare(n).bind(...o).raw({columnNames:!0}),[l,...u]=Array.isArray(c)?c:[],d=l??[];if(!(Array.isArray(c)&&Array.isArray(d)&&d.every(e=>typeof e==`string`)))throw C(a,`malformed positional rows`);return s(u,d,{provider:e.driverName,operation:a.operation??`execute`}),{kind:`positional`,rows:u,columns:d}})}var j=class extends f{static get name(){return`D1Driver`}adapter=new l({temporaryObjects:!1,deepExpressions:!1,sharedRelationBodies:!0,compoundSelectTerms:5,relationsPerStatement:256,countsCascadedChanges:!0});maxBindParametersPerStatement=100;result=h;supportsTransactions=!1;supportsBatch=!0;supportsOrderedCommittedSegments=!0;sqliteMigrationCapability=p;_o;constructor(e){super(`sqlite`,`d1`),this._o=e,this.client=e.database,D.set(this,E(this.adapter)),a(this,(e,t)=>A(this,e,t),O)}async initClient(){return this._o.database}async closeClient(e){}async execute(e,t,n,r){return k(e,t,n,r??{operation:`execute`})}async executeRaw(e,t,n,r){let a=n??[];return i({values:a},this.driverName,this.maxBindParametersPerStatement,`raw statement`),k(e,t,a,r??{operation:`executeRaw`})}transactionOptionSupport(){return{isolationLevel:`unsupported`,isolationLevelReason:`D1 batch has no configurable tx`,timeout:!1,timeoutReason:`D1 batch has no interactive body`,maxWait:`unsupported`,maxWaitReason:`D1 batch has no connection wait`}}transaction(t,n){return Promise.reject(e(this.driverName))}async executeBatch(e,t,n,r){let a=n??{operation:`executeBatch`},o=[];for(let n of t){let t=n.context??a;c(n)&&i({values:n.params??[]},this.driverName,this.maxBindParametersPerStatement,`raw statement`);try{let t=n.params?x(n.params):[];o.push(e.prepare(n.sql).bind(...t))}catch(e){throw u(this,e,n.sql,m(n),t,!0)}}let s=await e.batch(o);if(await r?.(),!Array.isArray(s)||s.length!==t.length){let e=Array.isArray(s)?s.length:0;throw C(a,`expected ${t.length} results, got ${e}`)}let l=[];for(let e=0;e<s.length;e+=1){let n=t[e];if(!n)throw C(a,`missing query ${e}`);l.push(T(s[e],n.sql,n.context??a,!1))}return l}};const M=j.prototype._execute,N=j.prototype.execute,P=j.prototype.executeTypedStatement;function F(e){d(e,`d1`,b);let{database:t}=e;return o(e,new j({database:t}))}export{j as D1Driver,F as createClient};
|
|
2
2
|
//# sourceMappingURL=d1.mjs.map
|
|
@@ -5065,7 +5065,7 @@ declare class DecimalScalar<out State$1 extends ScalarState<"decimal">> extends
|
|
|
5065
5065
|
* a schema document round-trips to the same declaration. A value outside the
|
|
5066
5066
|
* declared domain fails at the call that wrote it, not at the first write.
|
|
5067
5067
|
*/
|
|
5068
|
-
default<V$2 extends DefaultValueInput<State$1>>(value: V$2): DecimalScalar<Omit<DecimalScalarState<State$1>, "optional" | "
|
|
5068
|
+
default<V$2 extends DefaultValueInput<State$1>>(value: V$2): DecimalScalar<Omit<DecimalScalarState<State$1>, "optional" | "default" | "hasDefault"> & {
|
|
5069
5069
|
readonly hasDefault: true;
|
|
5070
5070
|
readonly default: unknown;
|
|
5071
5071
|
readonly optional: true;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{i as e,r as t}from"./extension-Dh1ddrlA.mjs";import{d as n}from"./model-Dtd37Sky.mjs";import{i as r}from"./keys-DZdKAd4n.mjs";import{i}from"./schema-DDkAUfOb.mjs";import{pt as a}from"./query-BTb6iakn.mjs";import{h as o,m as s,n as c,p as l,t as u}from"./rule-words-DMbQuvD2.mjs";function d(e,t){return{seal({next:n}){let r={...n.omit?.config};r[e]=Object.freeze({...r[e],[t]:!0}),n.omit=Object.freeze({config:Object.freeze(r)})}}}const f=new Set([`json`,`vector`,`point`,`blob`]);function p(e,t){let i=Array.isArray(t)?t:[t],{scalars:a}=e[`~`].state;return r(e).
|
|
1
|
+
import{i as e,r as t}from"./extension-Dh1ddrlA.mjs";import{d as n}from"./model-Dtd37Sky.mjs";import{i as r}from"./keys-DZdKAd4n.mjs";import{i}from"./schema-DDkAUfOb.mjs";import{pt as a}from"./query-BTb6iakn.mjs";import{h as o,m as s,n as c,p as l,t as u}from"./rule-words-DMbQuvD2.mjs";function d(e,t){return{seal({next:n}){let r={...n.omit?.config};r[e]=Object.freeze({...r[e],[t]:!0}),n.omit=Object.freeze({config:Object.freeze(r)})}}}const f=new Set([`json`,`vector`,`point`,`blob`]);function p(e,t){let i=Array.isArray(t)?t:[t],{scalars:a}=e[`~`].state;return r(e).uh!==void 0&&i.length>0&&i.every(e=>{let[t,...r]=n(e)?Object.keys(e):[],i=t!==void 0&&Object.hasOwn(a,t)?a[t][`~`].state:void 0,o=i&&e[t];return r.length===0&&(o===`asc`||o===`desc`)&&!i.array&&!f.has(i.type)})?i.map(e=>({...e})):void 0}var m=class{rows;queries;defaults=this;pl=void 0;se=void 0;#e;constructor(e,t){this.rows=e,this.queries=t}prepare(e,t){return this.queries.tm(e,t)}conjunction(){return null}reads(){return this.#e??=this.queries.e7(this)}selector(){}bound(){}lw(){return!1}af(){}};const h=new WeakMap;function g(e,t){let n=i(i(h,e,()=>new WeakMap),this.domain,()=>new m(this.domain,e));return{rows:this,domain:n,defaults:n,instant:t}}const _=new Map;var v=class{#e;#t;constructor({iy:e,fl:t}){let n={root:_,related:_,...e&&{order:new Map(Object.entries(e))}};this.#t=t,this.#e={domain:n,...t&&{fl:t.all},prepare:g}}call(e,t){let n=this.#t;return n?.named?{...this.#e,fl:n.of(t)}:this.#e}};const y=e=>new v(e),b=new Set([`orderBy`,`create`,`update`,`fields`]);var x=class extends u{join({key:e,field:t,model:n,wh:r,refuse:i}){e!==`fields.${t}`&&i(`${e} does not take omitted`),r(d(n,t))}};const S=C();function C(){return new x}function w(e,t,r){if(e===void 0)return;if(!n(e))return r(`data is an object of fields`);let i={};for(let[n,a]of Object.entries(e))Object.hasOwn(t,n)||r(`names unknown field "${n}"`),i[n]=a instanceof c&&a.s1?a.s1():a;return i}const T=(e,t)=>t===void 0?e:{...e,...t};function E(e,r,i){let a={order:{},data:{},kb:[]},{order:o,data:s,kb:c}=a;for(let[a,l]of Object.entries(r)){let r=n=>t(`Extension "${e}" defaults.${a}: ${n}.`,e);Object.hasOwn(i,a)||t(`Extension "${e}" defaults names unknown model "${a}".`,e),n(l)||r(`an entry is an object`);for(let e of Object.keys(l))b.has(e)||r(`"${e}" is not a defaults key`);let d=i[a],{scalars:f}=d[`~`].state;l.orderBy!==void 0&&(o[a]=p(d,l.orderBy)??r(`orderBy maps a model with a key to { field: "asc" | "desc" } terms over its ordered scalars`));for(let e of[`create`,`update`]){let t=w(l[e],f,r);t!==void 0&&(s[a]={...s[a],[e]:T(s[a]?.[e],t)})}if(l.fields!==void 0){n(l.fields)||r(`fields is an object`);for(let[e,t]of Object.entries(l.fields)){let n=`fields.${e}`;t instanceof u||r(`${n} is written omitted`),t.join({model:a,key:n,field:e,schema:i,wh:e=>c.push(e),lazy:!1,entry:()=>r(`${n} is written omitted`),refuse:r})}}}return a}function D(t){let n={join(r){let{name:i,next:s,schema:c}=r,{order:u,data:d,kb:f}=e(r,n,()=>E(i,t(c),c));for(let e of f)r.wh(e);if(Object.keys(u).length>0&&(s.iy={...s.iy,...u}),Object.keys(d).length===0)return;let p=[],m={...s.jp};for(let[e,t]of Object.entries(d)){let n=m[e];m[e]={create:T(n?.create,t.create),update:T(n?.update,t.update)};for(let e of[...Object.values(t.create??{}),...Object.values(t.update??{})])e instanceof a&&e.arg!==void 0&&p.push(e.arg)}o(r,p),s.jp=m,s.fl=new l(s.jp)},seal(e){s(e,y)}};return n}function O(e){return D(t=>typeof e==`function`?e(t):e)}export{S as n,O as t};
|
|
2
2
|
//# sourceMappingURL=defaults-DAPb-tJ4.mjs.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Ft as ScalarType, Go as NativeTypeMap, Ha as ReferentialAction, Ji as IndexType, Uo as NativeType, Va as JunctionReferentialAction, jt as AutoGenerateType, sa as JsonValue } from "./database-adapter-
|
|
1
|
+
import { Ft as ScalarType, Go as NativeTypeMap, Ha as ReferentialAction, Ji as IndexType, Uo as NativeType, Va as JunctionReferentialAction, jt as AutoGenerateType, sa as JsonValue } from "./database-adapter-01J6mYq5.mjs";
|
|
2
2
|
|
|
3
3
|
//#region src/schema/json/document.d.ts
|
|
4
4
|
|
package/dist/driver.d.mts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { $a as QueryExecutionContext, C as DriverResultParser, Co as UniqueConstraintError, Ga as sqliteResultParser, Lo as isRetryableError, Qa as Dialect, So as NotNullConstraintError, Xa as BatchQuery, _ as MigrationFrameDriver, ao as FeatureNotSupportedError, b as SqliteMigrationCapability, bo as CheckConstraintError, eo as QueryResult, fo as QueryError, g as MigrationFrame, h as Driver, io as ConnectionError, no as TransactionError, p as AnyDriver, xo as ForeignKeyError, y as SQLITE_MIGRATION_CAPABILITY } from "./database-adapter-
|
|
1
|
+
import { $a as QueryExecutionContext, C as DriverResultParser, Co as UniqueConstraintError, Ga as sqliteResultParser, Lo as isRetryableError, Qa as Dialect, So as NotNullConstraintError, Xa as BatchQuery, _ as MigrationFrameDriver, ao as FeatureNotSupportedError, b as SqliteMigrationCapability, bo as CheckConstraintError, eo as QueryResult, fo as QueryError, g as MigrationFrame, h as Driver, io as ConnectionError, no as TransactionError, p as AnyDriver, xo as ForeignKeyError, y as SQLITE_MIGRATION_CAPABILITY } from "./database-adapter-01J6mYq5.mjs";
|
|
2
2
|
export { type AnyDriver, type BatchQuery, CheckConstraintError, ConnectionError, type Dialect, Driver, type DriverResultParser, FeatureNotSupportedError, ForeignKeyError, type MigrationFrame, type MigrationFrameDriver, NotNullConstraintError, QueryError, type QueryExecutionContext, type QueryResult, SQLITE_MIGRATION_CAPABILITY, type SqliteMigrationCapability, TransactionError, UniqueConstraintError, isRetryableError, sqliteResultParser };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { $a as QueryExecutionContext, C as DriverResultParser, Di as LinkedClientConfig, Gr as Schema, Ja as TransactionOptionSupport, b as SqliteMigrationCapability, eo as QueryResult, g as MigrationFrame, h as Driver, pt as VibORMClient, st as DriverConfig, t as DatabaseAdapter, ut as NoExtraDriverConfigKeys, x as TransactionBoundDriver } from "./database-adapter-
|
|
1
|
+
import { $a as QueryExecutionContext, C as DriverResultParser, Di as LinkedClientConfig, Gr as Schema, Ja as TransactionOptionSupport, b as SqliteMigrationCapability, eo as QueryResult, g as MigrationFrame, h as Driver, pt as VibORMClient, st as DriverConfig, t as DatabaseAdapter, ut as NoExtraDriverConfigKeys, x as TransactionBoundDriver } from "./database-adapter-01J6mYq5.mjs";
|
|
2
2
|
import { DurableObjectStorage as DurableObjectStorage$1 } from "@cloudflare/workers-types";
|
|
3
3
|
|
|
4
4
|
//#region src/drivers/durable-object/index.d.ts
|
package/dist/durable-object.mjs
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{B as e,f as t}from"./error-mapping-B9rSvgG9.mjs";import{m as n,r}from"./validation-ATmgN5RE.mjs";import{t as i}from"./bind-parameter-capacity-BAFQM9Jt.mjs";import{n as a}from"./client-
|
|
1
|
+
import{B as e,f as t}from"./error-mapping-B9rSvgG9.mjs";import{m as n,r}from"./validation-ATmgN5RE.mjs";import{t as i}from"./bind-parameter-capacity-BAFQM9Jt.mjs";import{n as a}from"./client-Q4zkYZbn.mjs";import{t as o}from"./sqlite-adapter-Cb-SJw2f.mjs";import{a as s,h as c,n as l,r as u}from"./driver-lShUkDmf.mjs";import{l as d,n as f,t as p}from"./sqlite-utils-Bfmtkt1b.mjs";import{r as m}from"./sqlite-statement-classifier-JBHiQO6Q.mjs";const h={storage:!0,adapter:!0};function g(e){let t=f(e);return typeof t==`bigint`?Number.isSafeInteger(Number(t))?Number(t):`${t}`:ArrayBuffer.isView(t)?t.buffer.slice(t.byteOffset,t.byteOffset+t.byteLength):t}function _(e,t){let n=t;for(;;){let t=e.charCodeAt(n),r=e.charCodeAt(n+1);if(t===32||t>=9&&t<=13||t===65279||t===59)n+=1;else if(t===45&&r===45){let t=e.indexOf(`
|
|
2
2
|
`,n);n=t<0?e.length:t+1}else if(t===47&&r===42){let t=e.indexOf(`*/`,n+2);n=t<0?e.length:t+2}else return n}}function v(e,t){let n=t;for(;;){let t=e.charCodeAt(n);if(!(t>=65&&t<=90||t>=97&&t<=122||t>=48&&t<=57||t===95))return n;n+=1}}function y(e,t){let n=_(e,t),r=v(e,n);return[e.slice(n,r).toUpperCase(),r]}const b=new Set([`BEGIN`,`COMMIT`,`END`,`RELEASE`,`ROLLBACK`,`SAVEPOINT`]);function x(e){let[t,n]=y(e,0);if(b.has(t))return t;if(t!==`PRAGMA`)return;let[r,i]=y(e,n),a=_(e,i);return e.charCodeAt(a)===46&&([r,i]=y(e,a+1)),r===`BUSY_TIMEOUT`?`PRAGMA busy_timeout`:void 0}var S=class extends u{adapter;maxBindParametersPerStatement=100;result=d;supportsTransactions=!0;supportsBatch=!1;sqliteMigrationCapability=l;serializeTransactions=!0;storage;constructor(e,t){super(`sqlite`,`durable-object`),this.storage=e,this.client=e,this.adapter=t}createTransactionBoundDriver(e,t){return new C(this,e,t)}initClient(){return Promise.resolve(this.storage)}closeClient(){return Promise.resolve()}async execute(e,t,r){let i=x(t);if(i!==void 0)throw new n(`Driver 'durable-object' does not send ${i}: a transaction on a Durable Object is a ctx.storage.transaction() call. Use $transaction(async (tx) => ...), which nests at any depth and has no lock to wait for.`);let a=e.sql.exec(t,...r.map(g)),o=a.toArray();if(a.columnNames.length>0||!m(t))return{rows:o,rowCount:o.length};let{changes:s}=e.sql.exec(`SELECT changes() AS changes`).one();return{rows:o,rowCount:s}}async executeRaw(e,t,n){let r=n??[];return i({values:r},this.driverName,this.maxBindParametersPerStatement,`raw statement`),await this.execute(e,t,r)}transactionOptionSupport(){return p}transaction(n,r,i){return t({run:e=>n.transaction(()=>e(n)),callback:r,he:e(i),close:()=>Promise.resolve()})}async beforeForeignKeysOff(){await this.storage.sync()}async openMigrationFrame(){let e=()=>void 0,t=new Promise(t=>{e=t}),n=()=>void 0,r=new Promise(e=>{n=e}),i=Error(`The migration frame was rolled back.`),a=this.storage.transaction(async()=>{if(n(),!await t)throw i});return await Promise.race([r,a]),{commit:()=>(e(!0),a),rollback:async()=>{e(!1),await a.catch(e=>{if(e!==i)throw e})}}}},C=class e extends s{createTransactionBoundDriver(t,n){return new e(this,t,n)}transaction(e,t){return this.assertTransactionCommittable(),e.transaction(()=>t(e))}};const w=new WeakMap;function T(e,t){let n=w.get(e.sql);if(n===void 0){let n=new S(e,t??new o({temporaryObjects:!1,deepExpressions:!1}));return w.set(e.sql,n),n}if(t!==void 0&&t!==n.adapter)throw new r(`This Durable Object storage already has a driver, created with another adapter. Create the adapter once and pass that same object.`,{meta:{driver:`durable-object`}});return n}function E(e){return c(e,`durable-object`,h),a(e,T(e.storage,e.adapter))}export{E as createClient,T as createDurableObjectDriver};
|
|
3
3
|
//# sourceMappingURL=durable-object.mjs.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{C as e,D as t,E as n,S as r,T as i,_ as a,a as o,d as s,f as c,l,p as u,r as d,t as f,u as p,v as m,w as ee,x as te,y as ne}from"./base-17NSFtrA.mjs";import{t as re}from"./migrations-DIUltjr3.mjs";import{a as ie,c as h,d as ae,f as g,i as _,l as oe,m as se,o as ce,p as v,r as le,s as ue,t as de,u as fe}from"./validation-ATmgN5RE.mjs";import{n as y,t as pe}from"./transaction-Bv5nyp-U.mjs";import{n as me,t as he}from"./suppressed-failure-CFUDJrUw.mjs";var ge=class e{#e;model;operation;static#t={configurable:!1,enumerable:!0,get(){return e.values(this)?.ig?.()}};constructor(t){this.#e=t,t.m&&(this.model=t.m),this.operation=t.o,t.ig?Object.defineProperty(this,`correlationId`,e.#t):this.correlationId=t.id||void 0,t.n!==void 0&&(this.named=t.n),Object.freeze(this)}static values(e){return#e in e?e.#e:void 0}};const b=e=>ge.values(e),_e=e=>b(e)??C(e),x=(e,t)=>S({..._e(e),...t});function ve(e,t,n,r){if(!t)return ye(e,void 0,void 0,n);let i;return S({cs:r,ig:()=>i??=t(),ec:n,m:T(e,`model`),n:E(e),o:T(e,`operation`)})}function ye(e,t,n,r){let i=e?b(e):void 0,a=i??C(e),o=t?b(t):void 0,s=e===t?a:o??C(t),c=a.ig??(a.id===void 0?s.ig:void 0),l={cs:a.cs??s.cs,id:c?void 0:a.id??s.id,ig:c,ec:a.ec??s.ec??r,m:a.m??s.m,n:a.n??s.n,o:a.o??s.o??n,tp:a.tp??s.tp,...(a.rc??s.rc)&&{rc:!0}};return e&&i&&w(i,l)?e:t&&o&&w(o,l)?t:S(l)}function be(e){return x(e,{rc:!0})}function xe(e){return e!==void 0&&b(e)?.rc===!0}function Se(e,t){return x(e,{m:t})}const Ce=Symbol(`viborm.client.diagnostics`);function we(e){return e?b(e)?.ec:void 0}function Te(e){return b(e)===void 0?void 0:e}function Ee(e){return e?b(e)?.cs:void 0}function De(e,t){return x(e,{tp:t})}function Oe(e,t){let n=_e(e),r=n.tp;return S({...n,tp:r===void 0?t:{oq:()=>{t.oq(),r.oq()},committed:()=>{t.committed(),r.committed()}}})}function ke(e){return e?b(e)?.tp:void 0}function S(e){return new ge(e)}function C(e){return{id:T(e,`correlationId`),m:T(e,`model`),n:E(e),o:T(e,`operation`)}}function w(e,t){return e.rc===t.rc&&e.n===t.n&&e.cs===t.cs&&e.m===t.m&&e.o===t.o&&e.id===t.id&&e.ig===t.ig&&e.ec===t.ec&&e.tp===t.tp}function T(e,t){let n=D(e,t);return typeof n==`string`?n:void 0}function E(e){let t=D(e,`named`);return typeof t==`boolean`?t:void 0}function D(e,t){if(!(typeof e!=`object`&&typeof e!=`function`||!e))try{return Reflect.get(e,t)}catch{return}}var O=class extends d(`CacheInvalidTTLError`,`V10001`){static get name(){return`CacheInvalidTTLError`}},k=class extends d(`CacheInvalidKeyError`,`V10002`){static get name(){return`CacheInvalidKeyError`}},A=class extends f{static get name(){return`CacheOperationNotCacheableError`}static diagnosticName=`CacheOperationNotCacheableError`;constructor(e,t,n){super(`"${e}" is not cacheable; reads only: ${t.join(`, `)}`,`V10003`,{meta:{...n?.meta,operation:e}})}},j=class extends d(`CacheConfigurationError`,`V10004`){static get name(){return`CacheConfigurationError`}},M=class extends d(`UniqueConstraintError`,`V3001`){static get name(){return`UniqueConstraintError`}},N=class extends d(`ForeignKeyError`,`V3002`){static get name(){return`ForeignKeyError`}},P=class extends d(`NotNullConstraintError`,`V3003`){static get name(){return`NotNullConstraintError`}},F=class extends d(`CheckConstraintError`,`V3004`){static get name(){return`CheckConstraintError`}},I=class extends d(`ValueTooLongError`,`V3005`){static get name(){return`ValueTooLongError`}};function Ae(e){return e instanceof M}function je(e){return e instanceof N}function Me(e){return e instanceof P}function Ne(e){return e instanceof F}function Pe(e){return e instanceof I}function L(e,t){let n=o(e)?e:new g(`Record-series failed at committed segment.`,e instanceof Error?{cause:e}:void 0),r=s(n),i=r??m(t);return i?(Object.defineProperty(n.meta,`recordSeriesProgress`,{configurable:!0,enumerable:!0,value:i,writable:!0}),r||c(n,i),n):e}const Fe=[`findFirst`,`findMany`,`findUnique`,`create`,`createMany`,`createManyAndReturn`,`update`,`updateMany`,`updateManyAndReturn`,`delete`,`deleteMany`,`deleteManyAndReturn`,`upsert`,`count`,`aggregate`,`groupBy`,`exist`],R=new WeakMap;function Ie(e,t){R.set(t,R.get(e)??e)}function Le(e){return typeof e==`object`&&e?R.get(e)??e:e}function Re(e){return new y(`Driver "${e}": nested state outside tx.`,{meta:{driver:e,method:`$transaction`}})}function ze(e){return new y(`Driver "${e}" lacks callback transactions.`,{meta:{driver:e,method:`$transaction(callback)`}})}var z=class extends y{static get name(){return`ProviderTransactionContractError`}};async function Be(e){let t=0,n={status:`pending`},r=()=>n,i,a=!1,o=[],s=async()=>{let t=i!==void 0&&r().status===`pending`;if(i&&t){a=!0;try{await e.close()}catch(e){o.push(e)}await i.catch(()=>void 0)}return t},c=e=>new z(`Transaction provider ${e}.`);try{await e.run(r=>{if(t++,t>1)throw c(`invoked callback more than once`);return i=(async()=>{try{let t=await e.callback(r);return e.he?.oq(),n={status:`fulfilled`,value:t},t}catch(e){throw n={status:`rejected`,error:e},e}})(),i.catch(()=>void 0),i})}catch(t){let n=await s(),i=r();if(i.status===`rejected`&&!n&&t===i.error)throw t;let l=i.status===`rejected`?i.error:t,u=[];n&&u.push(c(`settled before callback`)),i.status===`rejected`&&t!==i.error&&u.push(...We(t,i.error)),u.push(...o);let d=u.map(V);return a||d.push(e.close),B(l,d)}let l=await s(),u=r(),d=[];if(t!==1&&d.push(c(t===0?`completed without invoking callback`:`invoked callback more than once`)),l&&d.push(c(`completed before callback settled`)),u.status===`rejected`&&d.push(c(`resolved after callback rejected`)),d.length>0){let t=u.status===`rejected`?u.error:d.shift(),n=[...d.map(V),...o.map(V)];return a||n.push(e.close),B(t,n)}return u.status===`fulfilled`?(e.he?.committed(),u.value):B(new z(`Callback outcome not recorded.`),[e.close])}async function Ve(e){let t=()=>e.close?[e.rollback,e.close]:[e.rollback];try{await e.begin()}catch(t){return B(t,e.close?[e.close]:[])}let n;try{n=await e.callback()}catch(e){return B(e,t())}e.he?.oq();try{await e.commit()}catch(e){return B(e,t())}return e.he?.committed(),e.close&&await e.close(),n}const He=async(e,t)=>{let n=`sp_${crypto.randomUUID().replace(/-/g,``)}`;await e(`SAVEPOINT ${n}`);let r=[()=>e(`ROLLBACK TO SAVEPOINT ${n}`),()=>e(`RELEASE SAVEPOINT ${n}`)],i;try{i=await t()}catch(e){return B(e,r)}try{await e(`RELEASE SAVEPOINT ${n}`)}catch(e){return B(e,r)}return i};function Ue(e,t){return AggregateError([e,...t],Ge(e),{cause:e})}function We(e,t){try{return!(e instanceof AggregateError)||e.cause!==t?[e]:e.errors[0]===t?e.errors.slice(1):[e]}catch{return[e]}}async function B(e,t){let n=[];for(let e of t)try{await e()}catch(e){n.push(e)}throw n.length>0?Ue(e,n):e}function V(e){return()=>{throw e}}function Ge(e){try{return e instanceof Error&&typeof e.message==`string`?e.message:`Transaction failed`}catch{return`Transaction failed`}}const Ke=`driver model operation correlationId callsite query params`.split(` `),qe=/\(sqlstate ([^)]+)\)/i,Je=/for key '([^']+)'/;function H(e,t){try{return Reflect.get(e,t)}catch{return}}function Ye(t,n){let r=f.prototype.toJSON.call(t),i=H(r,`meta`);return{snapshot:r,meta:a(e(i)?i:{},n)}}function U(e,t){let{snapshot:n,meta:r}=Ye(e,t.diagnostics);if(t.hb===!1)return u(t.diagnostics).includeCallsite&&t.callsite&&(r.callsite=t.callsite),W(e,r,n,t.diagnostics);let i=a(ot({},t,``),t.diagnostics);for(let e of Ke)Reflect.deleteProperty(r,e);for(let e of Object.keys(i))ne(r,e,i[e]);return W(e,r,n,t.diagnostics)}function Xe(e,t){let n=p(e),{snapshot:r,meta:i}=Ye(e,n);return t(i)?W(e,i,r,n):e}function Ze(e,t){return Xe(e,e=>{let n=!1;for(let[r,i]of Object.entries(t))i===void 0||e[r]!==void 0||(e[r]=i,n=!0);return n})}function Qe(e,t){return Xe(e,e=>(e.commitCertainty=t,!0))}function W(e,t,n,i){let a=f;if(e instanceof de){let r=$e(e,n,t,i);if(r)return Ie(e,r),G(e,r)}else a=it(e);let o=typeof n.message==`string`?n.message:`VibORM operation failed`,s=at(n.code)?n.code:`V9001`,c=l(e),u={...r(c)?{cause:c}:{},diagnostics:i,meta:t},d=typeof a==`function`?a:f,p;try{p=Reflect.construct(f,[o,s,u],d)}catch{p=new f(o,s,u)}let m=p instanceof f?p:new f(o,s,u);return Ie(e,m),G(e,m)}function G(e,t){for(let n of he(e))me(t,n);return t}function $e(e,t,n,i){let a=et(H(t,`source`)),o=H(t,`issues`);if(!(a&&te(o)))return;let s=tt(o),c=l(e);return new de(a,s,{...r(c)?{cause:c}:{},diagnostics:i,meta:n})}function et(t){if(!e(t))return;let n=e=>{let n=H(t,e);return typeof n==`string`?n:void 0},r=e=>{let t=n(e);return t===void 0?void 0:{[e]:t}},i=H(t,`kind`);if(i===`operation`){let e=H(t,`operation`);return nt(e)?{kind:i,operation:e,...r(`model`)}:void 0}if(i===`registry`)return{kind:i,...r(`model`),...r(`property`)};if(i===`schema-builder`){let e=n(`builder`),t=n(`path`);return e!==void 0&&t!==void 0?{kind:i,builder:e,path:t}:void 0}if(i===`json-schema`)return{kind:i,...r(`target`),...r(`schemaType`)}}function tt(t){let r=[],a=Math.min(i(t),128);for(let i=0;i<a;i+=1){let a=n(t,String(i));if(!(a&&`value`in a&&e(a.value)))continue;let o=H(a.value,`path`),s=H(a.value,`message`);typeof o!=`string`||typeof s!=`string`||r.push({path:o,message:s})}return r}function nt(e){return typeof e==`string`&&Fe.includes(e)}const rt=[j,k,O,A,F,le,_,ie,ce,N,pe,re,h,oe,fe,P,ae,g,v,y,M,se,I];function it(e){try{let t=Object.getPrototypeOf(e);return t===z.prototype?y:rt.find(e=>e.prototype===t)??f}catch{return f}}function at(e){return ee(e)}function ot(e,n,r){let i={driver:n.driverName},a=u(n.diagnostics),o=(e,t)=>{t&&(i[e]=t)};a.includeCallsite&&o(`callsite`,n.callsite),o(`model`,n.model),o(`operation`,n.operation),o(`correlationId`,n.correlationId),n.statementIndex!==void 0&&(i.statementIndex=n.statementIndex),a.includeSql&&n.query!==void 0&&(i.query=n.query),a.includeParams&&n.params!==void 0&&(i.params=n.params);let s=(e,t)=>{(typeof t==`string`||typeof t==`number`)&&(i[e]=t)},c=e.code??e.l0;s(`providerCode`,c),typeof e.errno==`number`&&(i.fp=e.errno);let l=e.sqlState??e.sqlstate??t(c)??qe.exec(r)?.[1];typeof l==`string`&&(i.providerSqlState=l),s(`providerStatus`,e.status??e.statusCode),o(`constraint`,e.constraint??e.constraint_name),o(`table`,e.table??e.table_name);let d=e.column??e.column_name;if(d&&(i.columns=[d]),!i.constraint){let e=Je.exec(r)?.[1];if(e){let t=e.indexOf(`.`);i.constraint=t===-1?e:e.slice(t+1),t!==-1&&!i.table&&(i.table=e.slice(0,t))}}return i}const st=/^[0-9A-Z]{5}$/,ct=/^(?:CONNECTION_(?:CLOSED|DESTROYED|ENDED)$|ECONNREFUSED|ECONNRESET|ENOTFOUND|EAI_AGAIN|ETIMEDOUT|EPIPE$|ERR_POSTGRES_CONNECTION_|08[0-9A-Z]{3}$|57P0[123]$)/,lt=/constraint failed: ([^:]+)/,ut=new Set([`Connection terminated unexpectedly`,`Client has encountered a connection error and is not queryable`]),dt=/^SQLITE_(?:BUSY|LOCKED)(?:_[A-Z0-9]+)*$/,ft=/[A-Za-z0-9_]+/g,pt=/\(errno (\d+)\)/,mt=`__viborm_assert__`,ht=`__viborm_judged__`,gt=/json(?!_each\(\?\)\))|->/i,_t={postgresql:/[/%]/,mysql:gt,sqlite:gt};function vt(e,t,n){let r=_t[t];for(let[t,i]of e.entries()){if(i.sql.includes(mt)||i.sql.includes(ht)){if(n&&!n.has(t))return!0;continue}if(r?.test(i.sql))return!0}return!1}const yt=/division by zero|malformed JSON|Invalid JSON text/;function bt(e){if(typeof e!=`number`||!Number.isInteger(e)||e<=0)return!1;let t=e&255;return t===5||t===6}function xt(e,t,n,r){if(r!==`sqlite`)return!1;if(typeof e==`string`&&dt.test(e)||bt(e)||bt(t))return!0;for(let e of n.matchAll(ft))if(dt.test(e[0]))return!0;return!1}const St=[h,ue],Ct=[y,`Database is locked`,`V5006`],K=[[M,`Unique constraint violation`,void 0,[`23505`,`SQLITE_CONSTRAINT_UNIQUE`],[1062],[`ER_DUP_ENTRY`],`UNIQUE constraint failed`,!0],[N,`Foreign key constraint violation`,void 0,[`23503`,`23001`,`SQLITE_CONSTRAINT_FOREIGNKEY`],[1452,1451],[`ER_NO_REFERENCED_ROW_2`,`ER_ROW_IS_REFERENCED_2`],`FOREIGN KEY constraint failed`],[P,`Not-null constraint violation`,void 0,[`23502`,`SQLITE_CONSTRAINT_NOTNULL`],[1048],[`ER_BAD_NULL_ERROR`],`NOT NULL constraint failed`,!0],[F,`Check constraint violation`,void 0,[`23514`,`SQLITE_CONSTRAINT_CHECK`],[3819],[`ER_CHECK_CONSTRAINT_VIOLATED`],`CHECK constraint failed`],[I,`Value too long for column type`,void 0,[`22001`],[1406],[`ER_DATA_TOO_LONG`]],[y,`Transaction serialization failure`,`V5004`,[`40001`]],[y,`Database lock is unavailable`,`V5006`,[`55P03`]],[y,`Transaction deadlock detected`,`V5003`,[`40P01`],[1213],[`ER_LOCK_DEADLOCK`]]],q=e=>new Set(e.split(` `)),wt=q(`28P01 28000 3D000 ER_ACCESS_DENIED_ERROR ER_BAD_DB_ERROR`),Tt=q(`53300 ER_CON_COUNT_ERROR ER_TOO_MANY_USER_CONNECTIONS`),Et=[[`Table or column not found`,`V2004`,q(`42P01 42703 ER_NO_SUCH_TABLE ER_BAD_FIELD_ERROR`),[1146,1054],/no such (?:table|column):|has no column named/],[`Numeric value out of range`,`V2005`,q(`22003 ER_WARN_DATA_OUT_OF_RANGE ER_DATA_OUT_OF_RANGE`),[1264,1690],/integer overflow/],[`Query timed out`,`V2002`,q(`57014 ER_LOCK_WAIT_TIMEOUT QUERY_TIMEOUT`),[1205]]],J=`Unknown provider error`,Dt=(e,t,n,r,i)=>typeof e==`string`&&n.has(e)||t===r||t===i,Ot=(e,t)=>Dt(e,t,wt,1045,1049),kt=(e,t)=>Dt(e,t,Tt,1040,1203);function Y(e,t,n){return new le(`Database auth/config failed`,{cause:e,meta:n,diagnostics:t.diagnostics})}function At(e,t){let n=It(e),r=Lt(n),i=Vt(e);return{cause:n,ze:r,i9:i,meta:ot(i,t,r)}}function X(e,t,n,r,i,a=!1){return new _(a?`Connection capacity exhausted`:i,{cause:t,diagnostics:n.diagnostics,meta:r,code:a?`V1005`:e===`ETIMEDOUT`?`V1002`:`V1001`})}function jt(e,t){if(Ft(e)){let n=U(e,t),r=s(e);return r?L(n,r):n}return Mt(e,t)}function Mt(e,t){let{cause:n,ze:r,i9:i,meta:a}=At(e,t),o=i.s2,s=t.driverName===`bun-sql`&&typeof i.code==`string`&&i.code.startsWith(`ERR_POSTGRES`)&&st.test(o??``)?o:void 0,c=s??i.sqlstate??i.code;s&&(a.providerCode=s);let l=i.errno??Ut(r),u={cause:n,diagnostics:t.diagnostics,meta:a},d;if(Ot(c,i.errno))d=Y(n,t,a);else if(c===void 0&&t.dialect===`postgresql`&&ut.has(r)||typeof c==`string`&&ct.test(c))d=X(c,n,t,a,`Database connection failed`);else{l!==void 0&&a.fp===void 0&&(a.fp=l);let e=typeof c==`string`,i=t.dialect===`sqlite`;if(kt(c,l))d=X(c,n,t,a,``,!0);else{let n=Et.find(([,,t,n,a])=>e&&t.has(c)||l!==void 0&&n.includes(l)||i&&a?.test(r)===!0);if(n)d=new v(n[0],{...u,code:n[1]});else{let e=Nt(c,l,r,a,t);d=e?new e[0](e[1],{...u,code:e[2]}):new v(`Query execution failed`,u)}}}return G(e,d),d}function Nt(e,t,n,r,i){if(i.query?.includes(ht)&&(n.includes(`__viborm_refused__`)||t===3143||e===`ER_INVALID_JSON_PATH`)||i.query?.includes(mt)&&(e===`22012`||e===`ER_INVALID_JSON_TEXT_IN_PARAM`||t===3141||yt.test(n)))return St;let a=K.find(t=>t[3].includes(e))??K.find(n=>n[4]?.includes(t)||n[5]?.includes(e));return a?(a[7]&&typeof e==`string`&&e.startsWith(`SQLITE_`)&&Jt(n,r),a):xt(e,t,n,i.dialect)?Ct:Wt(n,r)}function Pt(e,t,n=`Database connection failed`){if(Ft(e))return U(e,t);let{cause:r,ze:i,i9:a,meta:o}=At(e,t),s=a.errno??Ut(i);s!==void 0&&o.fp===void 0&&(o.fp=s);let c=a.sqlstate??a.code,l=Ot(c,s)?Y(r,t,o):X(c,r,t,o,n,kt(c,s));return G(e,l),l}const Z=(e,t)=>{try{return e()}catch{return t}};function Ft(e){return Z(()=>o(e),!1)}const It=e=>Z(()=>e instanceof Error?e:void 0,void 0)??Error(J),Lt=e=>Z(()=>typeof e.message==`string`?e.message:J,J),Rt=e=>e!==null&&(typeof e==`object`||typeof e==`function`),zt=`constraint table column constraint_name table_name column_name sqlState sqlstate`.split(` `),Bt=[`code`,`status`,`statusCode`];function Vt(e){if(!Rt(e))return{};let t=H(e,`body`),n=H(e,`errno`),r={l0:Rt(t)?Ht(t,`code`):void 0,errno:typeof n==`number`?n:void 0,s2:typeof n==`string`?n:void 0};for(let t of zt){let n=H(e,t);typeof n==`string`&&Reflect.set(r,t,n)}for(let t of Bt){let n=Ht(e,t);n!==void 0&&Reflect.set(r,t,n)}return r}function Ht(e,t){let n=H(e,t);return typeof n==`string`||typeof n==`number`?n:void 0}function Ut(e){let t=pt.exec(e)?.[1];return t?+t:void 0}function Wt(e,t){let n=K.find(t=>t[6]&&e.includes(t[6]));return n?.[7]&&Jt(e,t),n}const Q=String.raw`(?:"(?:[^"]|"")*"|\`(?:[^\`]|\`\`)*\`|\[[^\]]+\]|[A-Za-z_][A-Za-z0-9_$]*)`,$=`${Q}(?:\\s*\\.\\s*${Q})*`,Gt=RegExp(`^\\s*${$}(?:\\s*,\\s*${$})*\\s*$`),Kt=new RegExp($,`g`),qt=new RegExp(Q,`g`);function Jt(e,t){let n=lt.exec(e);if(!(n?.[1]&&Gt.test(n[1])))return;let r=n[1].match(Kt);if(!r)return;let i=[],a=new Set;for(let e of r){let t=e.match(qt);if(!t?.length)return;let n=t.map(e=>{let t=e[0];return t===`"`||t==="`"?e.slice(1,-1).replaceAll(t+t,t):t===`[`?e.slice(1,-1):e}),r=n.pop();if(r===void 0)return;i.push(r),n.length&&a.add(n.join(`.`))}t.columns=i,a.size===1&&(t.table=a.values().next().value)}export{O as A,ke as B,Ne as C,Pe as D,Ae as E,ve as F,ye as H,be as I,Se as L,Ce as M,Oe as N,j as O,De as P,Ee as R,I as S,Me as T,Te as U,xe as V,L as _,U as a,P as b,z as c,We as d,Be as f,Le as g,ze as h,Qe as i,A as j,k,Ue as l,Ve as m,Pt as n,Ze as o,He as p,jt as r,G as s,vt as t,Re as u,F as v,je as w,M as x,N as y,we as z};
|
|
1
|
+
import{C as e,D as t,E as n,S as r,T as i,_ as a,a as o,d as s,f as c,l,p as u,r as d,t as f,u as p,v as m,w as ee,x as te,y as ne}from"./base-17NSFtrA.mjs";import{t as re}from"./migrations-DIUltjr3.mjs";import{a as ie,c as h,d as ae,f as g,i as _,l as oe,m as se,o as ce,p as v,r as le,s as ue,t as de,u as fe}from"./validation-ATmgN5RE.mjs";import{n as y,t as pe}from"./transaction-Bv5nyp-U.mjs";import{n as me,t as he}from"./suppressed-failure-CFUDJrUw.mjs";var ge=class e{#e;model;operation;static#t={configurable:!1,enumerable:!0,get(){return e.values(this)?.ig?.()}};constructor(t){this.#e=t,t.m&&(this.model=t.m),this.operation=t.o,t.ig?Object.defineProperty(this,`correlationId`,e.#t):this.correlationId=t.id||void 0,t.n!==void 0&&(this.named=t.n),Object.freeze(this)}static values(e){return#e in e?e.#e:void 0}};const b=e=>ge.values(e),_e=e=>b(e)??C(e),x=(e,t)=>S({..._e(e),...t});function ve(e,t,n,r){if(!t)return ye(e,void 0,void 0,n);let i;return S({cs:r,ig:()=>i??=t(),ec:n,m:T(e,`model`),n:E(e),o:T(e,`operation`)})}function ye(e,t,n,r){let i=e?b(e):void 0,a=i??C(e),o=t?b(t):void 0,s=e===t?a:o??C(t),c=a.ig??(a.id===void 0?s.ig:void 0),l={cs:a.cs??s.cs,id:c?void 0:a.id??s.id,ig:c,ec:a.ec??s.ec??r,m:a.m??s.m,n:a.n??s.n,o:a.o??s.o??n,tp:a.tp??s.tp,...(a.rc??s.rc)&&{rc:!0}};return e&&i&&w(i,l)?e:t&&o&&w(o,l)?t:S(l)}function be(e){return x(e,{rc:!0})}function xe(e){return e!==void 0&&b(e)?.rc===!0}function Se(e,t){return x(e,{m:t})}const Ce=Symbol(`viborm.client.diagnostics`);function we(e){return e?b(e)?.ec:void 0}function Te(e){return b(e)===void 0?void 0:e}function Ee(e){return e?b(e)?.cs:void 0}function De(e,t){return x(e,{tp:t})}function Oe(e,t){let n=_e(e),r=n.tp;return S({...n,tp:r===void 0?t:{oq:()=>{t.oq(),r.oq()},committed:()=>{t.committed(),r.committed()}}})}function ke(e){return e?b(e)?.tp:void 0}function S(e){return new ge(e)}function C(e){return{id:T(e,`correlationId`),m:T(e,`model`),n:E(e),o:T(e,`operation`)}}function w(e,t){return e.rc===t.rc&&e.n===t.n&&e.cs===t.cs&&e.m===t.m&&e.o===t.o&&e.id===t.id&&e.ig===t.ig&&e.ec===t.ec&&e.tp===t.tp}function T(e,t){let n=D(e,t);return typeof n==`string`?n:void 0}function E(e){let t=D(e,`named`);return typeof t==`boolean`?t:void 0}function D(e,t){if(!(typeof e!=`object`&&typeof e!=`function`||!e))try{return Reflect.get(e,t)}catch{return}}var O=class extends d(`CacheInvalidTTLError`,`V10001`){static get name(){return`CacheInvalidTTLError`}},k=class extends d(`CacheInvalidKeyError`,`V10002`){static get name(){return`CacheInvalidKeyError`}},A=class extends f{static get name(){return`CacheOperationNotCacheableError`}static diagnosticName=`CacheOperationNotCacheableError`;constructor(e,t,n){super(`"${e}" is not cacheable; reads only: ${t.join(`, `)}`,`V10003`,{meta:{...n?.meta,operation:e}})}},j=class extends d(`CacheConfigurationError`,`V10004`){static get name(){return`CacheConfigurationError`}},M=class extends d(`UniqueConstraintError`,`V3001`){static get name(){return`UniqueConstraintError`}},N=class extends d(`ForeignKeyError`,`V3002`){static get name(){return`ForeignKeyError`}},P=class extends d(`NotNullConstraintError`,`V3003`){static get name(){return`NotNullConstraintError`}},F=class extends d(`CheckConstraintError`,`V3004`){static get name(){return`CheckConstraintError`}},I=class extends d(`ValueTooLongError`,`V3005`){static get name(){return`ValueTooLongError`}};function Ae(e){return e instanceof M}function je(e){return e instanceof N}function Me(e){return e instanceof P}function Ne(e){return e instanceof F}function Pe(e){return e instanceof I}function L(e,t){let n=o(e)?e:new g(`Record-series failed at committed segment.`,e instanceof Error?{cause:e}:void 0),r=s(n),i=r??m(t);return i?(Object.defineProperty(n.meta,`recordSeriesProgress`,{configurable:!0,enumerable:!0,value:i,writable:!0}),r||c(n,i),n):e}const Fe=[`findFirst`,`findMany`,`findUnique`,`create`,`createMany`,`createManyAndReturn`,`update`,`updateMany`,`updateManyAndReturn`,`delete`,`deleteMany`,`deleteManyAndReturn`,`upsert`,`count`,`aggregate`,`groupBy`,`exist`],R=new WeakMap;function Ie(e,t){R.set(t,R.get(e)??e)}function Le(e){return typeof e==`object`&&e?R.get(e)??e:e}function Re(e){return new y(`Driver "${e}": nested state outside tx.`,{meta:{driver:e,method:`$transaction`}})}function ze(e){return new y(`Driver "${e}" lacks callback transactions.`,{meta:{driver:e,method:`$transaction(callback)`}})}var z=class extends y{static get name(){return`ProviderTransactionContractError`}};async function Be(e){let t=0,n={status:`pending`},r=()=>n,i,a=!1,o=[],s=async()=>{let t=i!==void 0&&r().status===`pending`;if(i&&t){a=!0;try{await e.close()}catch(e){o.push(e)}await i.catch(()=>void 0)}return t},c=e=>new z(`Transaction provider ${e}.`);try{await e.run(r=>{if(t++,t>1)throw c(`invoked callback more than once`);return i=(async()=>{try{let t=await e.callback(r);return e.he?.oq(),n={status:`fulfilled`,value:t},t}catch(e){throw n={status:`rejected`,error:e},e}})(),i.catch(()=>void 0),i})}catch(t){let n=await s(),i=r();if(i.status===`rejected`&&!n&&t===i.error)throw t;let l=i.status===`rejected`?i.error:t,u=[];n&&u.push(c(`settled before callback`)),i.status===`rejected`&&t!==i.error&&u.push(...We(t,i.error)),u.push(...o);let d=u.map(V);return a||d.push(e.close),B(l,d)}let l=await s(),u=r(),d=[];if(t!==1&&d.push(c(t===0?`completed without invoking callback`:`invoked callback more than once`)),l&&d.push(c(`completed before callback settled`)),u.status===`rejected`&&d.push(c(`resolved after callback rejected`)),d.length>0){let t=u.status===`rejected`?u.error:d.shift(),n=[...d.map(V),...o.map(V)];return a||n.push(e.close),B(t,n)}return u.status===`fulfilled`?(e.he?.committed(),u.value):B(new z(`Callback outcome not recorded.`),[e.close])}async function Ve(e){let t=()=>e.close?[e.rollback,e.close]:[e.rollback];try{await e.begin()}catch(t){return B(t,e.close?[e.close]:[])}let n;try{n=await e.callback()}catch(e){return B(e,t())}e.he?.oq();try{await e.commit()}catch(e){return B(e,t())}return e.he?.committed(),e.close&&await e.close(),n}const He=async(e,t)=>{let n=`sp_${crypto.randomUUID().replace(/-/g,``)}`;await e(`SAVEPOINT ${n}`);let r=[()=>e(`ROLLBACK TO SAVEPOINT ${n}`),()=>e(`RELEASE SAVEPOINT ${n}`)],i;try{i=await t()}catch(e){return B(e,r)}try{await e(`RELEASE SAVEPOINT ${n}`)}catch(e){return B(e,r)}return i};function Ue(e,t){return AggregateError([e,...t],Ge(e),{cause:e})}function We(e,t){try{return!(e instanceof AggregateError)||e.cause!==t?[e]:e.errors[0]===t?e.errors.slice(1):[e]}catch{return[e]}}async function B(e,t){let n=[];for(let e of t)try{await e()}catch(e){n.push(e)}throw n.length>0?Ue(e,n):e}function V(e){return()=>{throw e}}function Ge(e){try{return e instanceof Error&&typeof e.message==`string`?e.message:`Transaction failed`}catch{return`Transaction failed`}}const Ke=`driver model operation correlationId callsite query params`.split(` `),qe=/\(sqlstate ([^)]+)\)/i,Je=/for key '([^']+)'/;function H(e,t){try{return Reflect.get(e,t)}catch{return}}function Ye(t,n){let r=f.prototype.toJSON.call(t),i=H(r,`meta`);return{snapshot:r,meta:a(e(i)?i:{},n)}}function U(e,t){let{snapshot:n,meta:r}=Ye(e,t.diagnostics);if(t.hb===!1)return u(t.diagnostics).includeCallsite&&t.callsite&&(r.callsite=t.callsite),W(e,r,n,t.diagnostics);let i=a(ot({},t,``),t.diagnostics);for(let e of Ke)Reflect.deleteProperty(r,e);for(let e of Object.keys(i))ne(r,e,i[e]);return W(e,r,n,t.diagnostics)}function Xe(e,t){let n=p(e),{snapshot:r,meta:i}=Ye(e,n);return t(i)?W(e,i,r,n):e}function Ze(e,t){return Xe(e,e=>{let n=!1;for(let[r,i]of Object.entries(t))i===void 0||e[r]!==void 0||(e[r]=i,n=!0);return n})}function Qe(e,t){return Xe(e,e=>(e.commitCertainty=t,!0))}function W(e,t,n,i){let a=f;if(e instanceof de){let r=$e(e,n,t,i);if(r)return Ie(e,r),G(e,r)}else a=it(e);let o=typeof n.message==`string`?n.message:`VibORM operation failed`,s=at(n.code)?n.code:`V9001`,c=l(e),u={...r(c)?{cause:c}:{},diagnostics:i,meta:t},d=typeof a==`function`?a:f,p;try{p=Reflect.construct(f,[o,s,u],d)}catch{p=new f(o,s,u)}let m=p instanceof f?p:new f(o,s,u);return Ie(e,m),G(e,m)}function G(e,t){for(let n of he(e))me(t,n);return t}function $e(e,t,n,i){let a=et(H(t,`source`)),o=H(t,`issues`);if(!(a&&te(o)))return;let s=tt(o),c=l(e);return new de(a,s,{...r(c)?{cause:c}:{},diagnostics:i,meta:n})}function et(t){if(!e(t))return;let n=e=>{let n=H(t,e);return typeof n==`string`?n:void 0},r=e=>{let t=n(e);return t===void 0?void 0:{[e]:t}},i=H(t,`kind`);if(i===`operation`){let e=H(t,`operation`);return nt(e)?{kind:i,operation:e,...r(`model`)}:void 0}if(i===`registry`)return{kind:i,...r(`model`),...r(`property`)};if(i===`schema-builder`){let e=n(`builder`),t=n(`path`);return e!==void 0&&t!==void 0?{kind:i,builder:e,path:t}:void 0}if(i===`json-schema`)return{kind:i,...r(`target`),...r(`schemaType`)}}function tt(t){let r=[],a=Math.min(i(t),128);for(let i=0;i<a;i+=1){let a=n(t,String(i));if(!(a&&`value`in a&&e(a.value)))continue;let o=H(a.value,`path`),s=H(a.value,`message`);typeof o!=`string`||typeof s!=`string`||r.push({path:o,message:s})}return r}function nt(e){return typeof e==`string`&&Fe.includes(e)}const rt=[j,k,O,A,F,le,_,ie,ce,N,pe,re,h,oe,fe,P,ae,g,v,y,M,se,I];function it(e){try{let t=Object.getPrototypeOf(e);return t===z.prototype?y:rt.find(e=>e.prototype===t)??f}catch{return f}}function at(e){return ee(e)}function ot(e,n,r){let i={driver:n.driverName},a=u(n.diagnostics),o=(e,t)=>{t&&(i[e]=t)};a.includeCallsite&&o(`callsite`,n.callsite),o(`model`,n.model),o(`operation`,n.operation),o(`correlationId`,n.correlationId),n.statementIndex!==void 0&&(i.statementIndex=n.statementIndex),a.includeSql&&n.query!==void 0&&(i.query=n.query),a.includeParams&&n.params!==void 0&&(i.params=n.params);let s=(e,t)=>{(typeof t==`string`||typeof t==`number`)&&(i[e]=t)},c=e.code??e.o9;s(`providerCode`,c),typeof e.errno==`number`&&(i.fp=e.errno);let l=e.sqlState??e.sqlstate??t(c)??qe.exec(r)?.[1];typeof l==`string`&&(i.providerSqlState=l),s(`providerStatus`,e.status??e.statusCode),o(`constraint`,e.constraint??e.constraint_name),o(`table`,e.table??e.table_name);let d=e.column??e.column_name;if(d&&(i.columns=[d]),!i.constraint){let e=Je.exec(r)?.[1];if(e){let t=e.indexOf(`.`);i.constraint=t===-1?e:e.slice(t+1),t!==-1&&!i.table&&(i.table=e.slice(0,t))}}return i}const st=/^[0-9A-Z]{5}$/,ct=/^(?:CONNECTION_(?:CLOSED|DESTROYED|ENDED)$|ECONNREFUSED|ECONNRESET|ENOTFOUND|EAI_AGAIN|ETIMEDOUT|EPIPE$|ERR_POSTGRES_CONNECTION_|08[0-9A-Z]{3}$|57P0[123]$)/,lt=/constraint failed: ([^:]+)/,ut=new Set([`Connection terminated unexpectedly`,`Client has encountered a connection error and is not queryable`]),dt=/^SQLITE_(?:BUSY|LOCKED)(?:_[A-Z0-9]+)*$/,ft=/[A-Za-z0-9_]+/g,pt=/\(errno (\d+)\)/,mt=`__viborm_assert__`,ht=`__viborm_judged__`,gt=/json(?!_each\(\?\)\))|->/i,_t={postgresql:/[/%]/,mysql:gt,sqlite:gt};function vt(e,t,n){let r=_t[t];for(let[t,i]of e.entries()){if(i.sql.includes(mt)||i.sql.includes(ht)){if(n&&!n.has(t))return!0;continue}if(r?.test(i.sql))return!0}return!1}const yt=/division by zero|malformed JSON|Invalid JSON text/;function bt(e){if(typeof e!=`number`||!Number.isInteger(e)||e<=0)return!1;let t=e&255;return t===5||t===6}function xt(e,t,n,r){if(r!==`sqlite`)return!1;if(typeof e==`string`&&dt.test(e)||bt(e)||bt(t))return!0;for(let e of n.matchAll(ft))if(dt.test(e[0]))return!0;return!1}const St=[h,ue],Ct=[y,`Database is locked`,`V5006`],K=[[M,`Unique constraint violation`,void 0,[`23505`,`SQLITE_CONSTRAINT_UNIQUE`],[1062],[`ER_DUP_ENTRY`],`UNIQUE constraint failed`,!0],[N,`Foreign key constraint violation`,void 0,[`23503`,`23001`,`SQLITE_CONSTRAINT_FOREIGNKEY`],[1452,1451],[`ER_NO_REFERENCED_ROW_2`,`ER_ROW_IS_REFERENCED_2`],`FOREIGN KEY constraint failed`],[P,`Not-null constraint violation`,void 0,[`23502`,`SQLITE_CONSTRAINT_NOTNULL`],[1048],[`ER_BAD_NULL_ERROR`],`NOT NULL constraint failed`,!0],[F,`Check constraint violation`,void 0,[`23514`,`SQLITE_CONSTRAINT_CHECK`],[3819],[`ER_CHECK_CONSTRAINT_VIOLATED`],`CHECK constraint failed`],[I,`Value too long for column type`,void 0,[`22001`],[1406],[`ER_DATA_TOO_LONG`]],[y,`Transaction serialization failure`,`V5004`,[`40001`]],[y,`Database lock is unavailable`,`V5006`,[`55P03`]],[y,`Transaction deadlock detected`,`V5003`,[`40P01`],[1213],[`ER_LOCK_DEADLOCK`]]],q=e=>new Set(e.split(` `)),wt=q(`28P01 28000 3D000 ER_ACCESS_DENIED_ERROR ER_BAD_DB_ERROR`),Tt=q(`53300 ER_CON_COUNT_ERROR ER_TOO_MANY_USER_CONNECTIONS`),Et=[[`Table or column not found`,`V2004`,q(`42P01 42703 ER_NO_SUCH_TABLE ER_BAD_FIELD_ERROR`),[1146,1054],/no such (?:table|column):|has no column named/],[`Numeric value out of range`,`V2005`,q(`22003 ER_WARN_DATA_OUT_OF_RANGE ER_DATA_OUT_OF_RANGE`),[1264,1690],/integer overflow/],[`Query timed out`,`V2002`,q(`57014 ER_LOCK_WAIT_TIMEOUT QUERY_TIMEOUT`),[1205]]],J=`Unknown provider error`,Dt=(e,t,n,r,i)=>typeof e==`string`&&n.has(e)||t===r||t===i,Ot=(e,t)=>Dt(e,t,wt,1045,1049),kt=(e,t)=>Dt(e,t,Tt,1040,1203);function Y(e,t,n){return new le(`Database auth/config failed`,{cause:e,meta:n,diagnostics:t.diagnostics})}function At(e,t){let n=It(e),r=Lt(n),i=Vt(e);return{cause:n,ze:r,i9:i,meta:ot(i,t,r)}}function X(e,t,n,r,i,a=!1){return new _(a?`Connection capacity exhausted`:i,{cause:t,diagnostics:n.diagnostics,meta:r,code:a?`V1005`:e===`ETIMEDOUT`?`V1002`:`V1001`})}function jt(e,t){if(Ft(e)){let n=U(e,t),r=s(e);return r?L(n,r):n}return Mt(e,t)}function Mt(e,t){let{cause:n,ze:r,i9:i,meta:a}=At(e,t),o=i.s2,s=t.driverName===`bun-sql`&&typeof i.code==`string`&&i.code.startsWith(`ERR_POSTGRES`)&&st.test(o??``)?o:void 0,c=s??i.sqlstate??i.code;s&&(a.providerCode=s);let l=i.errno??Ut(r),u={cause:n,diagnostics:t.diagnostics,meta:a},d;if(Ot(c,i.errno))d=Y(n,t,a);else if(c===void 0&&t.dialect===`postgresql`&&ut.has(r)||typeof c==`string`&&ct.test(c))d=X(c,n,t,a,`Database connection failed`);else{l!==void 0&&a.fp===void 0&&(a.fp=l);let e=typeof c==`string`,i=t.dialect===`sqlite`;if(kt(c,l))d=X(c,n,t,a,``,!0);else{let n=Et.find(([,,t,n,a])=>e&&t.has(c)||l!==void 0&&n.includes(l)||i&&a?.test(r)===!0);if(n)d=new v(n[0],{...u,code:n[1]});else{let e=Nt(c,l,r,a,t);d=e?new e[0](e[1],{...u,code:e[2]}):new v(`Query execution failed`,u)}}}return G(e,d),d}function Nt(e,t,n,r,i){if(i.query?.includes(ht)&&(n.includes(`__viborm_refused__`)||t===3143||e===`ER_INVALID_JSON_PATH`)||i.query?.includes(mt)&&(e===`22012`||e===`ER_INVALID_JSON_TEXT_IN_PARAM`||t===3141||yt.test(n)))return St;let a=K.find(t=>t[3].includes(e))??K.find(n=>n[4]?.includes(t)||n[5]?.includes(e));return a?(a[7]&&typeof e==`string`&&e.startsWith(`SQLITE_`)&&Jt(n,r),a):xt(e,t,n,i.dialect)?Ct:Wt(n,r)}function Pt(e,t,n=`Database connection failed`){if(Ft(e))return U(e,t);let{cause:r,ze:i,i9:a,meta:o}=At(e,t),s=a.errno??Ut(i);s!==void 0&&o.fp===void 0&&(o.fp=s);let c=a.sqlstate??a.code,l=Ot(c,s)?Y(r,t,o):X(c,r,t,o,n,kt(c,s));return G(e,l),l}const Z=(e,t)=>{try{return e()}catch{return t}};function Ft(e){return Z(()=>o(e),!1)}const It=e=>Z(()=>e instanceof Error?e:void 0,void 0)??Error(J),Lt=e=>Z(()=>typeof e.message==`string`?e.message:J,J),Rt=e=>e!==null&&(typeof e==`object`||typeof e==`function`),zt=`constraint table column constraint_name table_name column_name sqlState sqlstate`.split(` `),Bt=[`code`,`status`,`statusCode`];function Vt(e){if(!Rt(e))return{};let t=H(e,`body`),n=H(e,`errno`),r={o9:Rt(t)?Ht(t,`code`):void 0,errno:typeof n==`number`?n:void 0,s2:typeof n==`string`?n:void 0};for(let t of zt){let n=H(e,t);typeof n==`string`&&Reflect.set(r,t,n)}for(let t of Bt){let n=Ht(e,t);n!==void 0&&Reflect.set(r,t,n)}return r}function Ht(e,t){let n=H(e,t);return typeof n==`string`||typeof n==`number`?n:void 0}function Ut(e){let t=pt.exec(e)?.[1];return t?+t:void 0}function Wt(e,t){let n=K.find(t=>t[6]&&e.includes(t[6]));return n?.[7]&&Jt(e,t),n}const Q=String.raw`(?:"(?:[^"]|"")*"|\`(?:[^\`]|\`\`)*\`|\[[^\]]+\]|[A-Za-z_][A-Za-z0-9_$]*)`,$=`${Q}(?:\\s*\\.\\s*${Q})*`,Gt=RegExp(`^\\s*${$}(?:\\s*,\\s*${$})*\\s*$`),Kt=new RegExp($,`g`),qt=new RegExp(Q,`g`);function Jt(e,t){let n=lt.exec(e);if(!(n?.[1]&&Gt.test(n[1])))return;let r=n[1].match(Kt);if(!r)return;let i=[],a=new Set;for(let e of r){let t=e.match(qt);if(!t?.length)return;let n=t.map(e=>{let t=e[0];return t===`"`||t==="`"?e.slice(1,-1).replaceAll(t+t,t):t===`[`?e.slice(1,-1):e}),r=n.pop();if(r===void 0)return;i.push(r),n.length&&a.add(n.join(`.`))}t.columns=i,a.size===1&&(t.table=a.values().next().value)}export{O as A,ke as B,Ne as C,Pe as D,Ae as E,ve as F,ye as H,be as I,Se as L,Ce as M,Oe as N,j as O,De as P,Ee as R,I as S,Me as T,Te as U,xe as V,L as _,U as a,P as b,z as c,We as d,Be as f,Le as g,ze as h,Qe as i,A as j,k,Ue as l,Ve as m,Pt as n,Ze as o,He as p,jt as r,G as s,vt as t,Re as u,F as v,je as w,M as x,N as y,we as z};
|
|
2
2
|
//# sourceMappingURL=error-mapping-B9rSvgG9.mjs.map
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{x as e}from"./serializer-Br9JgpQI.mjs";import{n as t,t as n}from"./libsql-BZAXy5PY.mjs";import{t as r}from"./mysql-BjIAoFH6.mjs";import{t as i}from"./postgres-CaMB2Y4p.mjs";import{t as a}from"./snowflake-B8Ei88bg.mjs";import{t as o}from"./surrealql-f2Rgu47F.mjs";function s(){e(i),e(t),e(n),e(r),e(o),e(a)}export{s as t};
|
|
2
|
+
//# sourceMappingURL=every-CgeIFxWR.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"every-
|
|
1
|
+
{"version":3,"file":"every-CgeIFxWR.mjs","names":[],"sources":["../src/migrations/dialects/every.ts"],"sourcesContent":["/**\n * Every dialect's migration driver. Callers register from their own entry\n * statement (`viborm/migrations`, the CLI), so the registration stays with\n * the entry a bundler keeps.\n */\n\nimport { registerMigrationDriver } from \"../drivers\";\nimport { libsqlMigrationDriver } from \"../drivers/libsql\";\nimport { mysqlMigrationDriver } from \"../drivers/mysql\";\nimport { postgresMigrationDriver } from \"../drivers/postgres\";\nimport { snowflakeMigrationDriver } from \"../drivers/snowflake\";\nimport { sqlite3MigrationDriver } from \"../drivers/sqlite\";\nimport { surrealMigrationDriver } from \"../drivers/surrealql\";\n\nexport function registerEveryMigrationDriver(): void {\n registerMigrationDriver(postgresMigrationDriver);\n registerMigrationDriver(sqlite3MigrationDriver);\n registerMigrationDriver(libsqlMigrationDriver);\n registerMigrationDriver(mysqlMigrationDriver);\n registerMigrationDriver(surrealMigrationDriver);\n registerMigrationDriver(snowflakeMigrationDriver);\n}\n"],"mappings":"8QAcA,SAAgB,GAAqC,CACnD,EAAwB,EAAwB,CAChD,EAAwB,EAAuB,CAC/C,EAAwB,EAAsB,CAC9C,EAAwB,EAAqB,CAC7C,EAAwB,EAAuB,CAC/C,EAAwB,EAAyB"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Gi as AnyModel, I as Extension, L as Facts, O as AnyTarget, wi as ClientSchema } from "./database-adapter-
|
|
1
|
+
import { Gi as AnyModel, I as Extension, L as Facts, O as AnyTarget, wi as ClientSchema } from "./database-adapter-01J6mYq5.mjs";
|
|
2
2
|
|
|
3
3
|
//#region src/client/omit.d.ts
|
|
4
4
|
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{r as e}from"./validation-ATmgN5RE.mjs";import{o as t}from"./value-guards-CBVIJXlI.mjs";const n=[`declare`,`join`,`seal`];function r(t,n){throw new e(t,{meta:n?{extension:n}:void 0})}function i(e,t,i,a,o,s){t?.extensions.some(e=>e.name===i)&&r(`Extension "${i}" is already present on this client.`,i);let c=new Set(e),l={...t,extensions:[...t?.extensions??[],{name:i}]},u={name:i,
|
|
1
|
+
import{r as e}from"./validation-ATmgN5RE.mjs";import{o as t}from"./value-guards-CBVIJXlI.mjs";const n=[`declare`,`join`,`seal`];function r(t,n){throw new e(t,{meta:n?{extension:n}:void 0})}function i(e,t,i,a,o,s){t?.extensions.some(e=>e.name===i)&&r(`Extension "${i}" is already present on this client.`,i);let c=new Set(e),l={...t,extensions:[...t?.extensions??[],{name:i}]},u={name:i,u7:t,next:l,owner:{name:i},schema:a,registry:s,wh:e=>{c.add(e)},g3:o};for(let e of n)for(let t of c)t[e]?.(u);return l}function a({g3:e,schema:t},n,r){let i=e.get(t),a=Object.keys(t);(i===void 0||a.length!==Object.keys(i.models).length||a.some(e=>i.models[e]!==t[e]))&&(i={models:{...t},values:new Map},e.set(t,i));let{values:o}=i;return o.has(n)||o.set(n,r()),o.get(n)}const o=e=>t(e)&&(typeof e.declare==`function`||typeof e.join==`function`||typeof e.seal==`function`);function s(e,...t){(typeof e!=`string`||e.trim().length===0)&&r(`An extension's name must be a non-empty string.`),t.every(o)||r(`Extension "${e}" takes parts built by viborm's part builders.`,e);let n=new WeakMap,a={name:e,append:(r,a,o)=>i(t,r,e,a,n,o)};return Object.freeze(a)}const c=e=>typeof e==`object`&&!!e&&`append`in e&&typeof e.append==`function`;export{a as i,c as n,r,s as t};
|
|
2
2
|
//# sourceMappingURL=extension-Dh1ddrlA.mjs.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{J as e,Q as t,S as n,Ut as r,Y as i,d as a,f as o,it as s,rt as c,u as l,w as u}from"./native-types-1ewJXVks.mjs";const d=1e-10,f=Math.PI/180,p=6371008.8,m=(e=-90,t=90)=>({south:e,west:-180,north:t,east:180});function h({latitude:e,longitude:t},n){if(n<=0)return{south:e,west:t,north:e,east:t};let r=n/p;if(r>=Math.PI)return m();let i=r/f,a=Math.max(-90,e-i-d),o=Math.min(90,e+i+d);if(a===-90||o===90)return m(a,o);let s=Math.asin(Math.min(1,Math.sin(r)/Math.cos(e*f)))/f+d;return{south:a,west:g(t-s),north:o,east:g(t+s)}}function g(e){return((e+180)%360+360)%360-180}const _=n({south:l,west:a,north:l,east:a},{partial:!1});function v(e){let t=s(_,e);return t.issues?t:t.value.south>t.value.north?i(`south > north`,[`south`]):t}const y=(e,t)=>i(`GeoPolygon ${e}`,t);function b(e){let n=c(e,t);return n.issues?n:n.value.length<r?y(`ring needs >= ${r} vertices`):c(n.value,o)}const x=n({outer:e(`array`,b),holes:u(e(`array`,e=>c(e,b)))},{partial:!1}),S=1e-9*f,C=2*Math.sin(.005*f),w=`contains pole`,T=`self-intersects`,E=`hole outside ring`,D=`holes overlap`,O=1/0;function k(e,t){let n=Math.cos(t*f);return[n*Math.cos(e*f),n*Math.sin(e*f),Math.sin(t*f)]}function A(e,t){return e[0]*t[0]+e[1]*t[1]+e[2]*t[2]}function j(e,t){let n=e[0]-t[0],r=e[1]-t[1],i=e[2]-t[2],a=e[0]+t[0],o=e[1]+t[1],s=e[2]+t[2];return[(r*s-i*o)/2,(i*a-n*s)/2,(n*o-r*a)/2]}function M(e){let t=Math.hypot(...e);return[e[0]/t,e[1]/t,e[2]/t]}function N(e,t){return Math.hypot(e[0]-t[0],e[1]-t[1],e[2]-t[2])}function P(e){return[-e[0],-e[1],-e[2]]}const F=e=>e>180?-360:e<-180?360:0,I=e=>e===180?-180:e;function L(e,n){let r=[];for(let t=0;t<e.length;t++){let i=e[t],a=k(i.longitude,i.latitude);if(Math.hypot(a[0],a[1])<=S)return y(w,[...n,t]);let o=r.at(-1);(!o||N(o.v,a)>S)&&r.push({pt:i,i:t,v:a})}let i=r[0],a=r.at(-1);i&&a&&N(a.v,i.v)>S&&r.push(i);let o=0;for(let e=1;e<r.length;e++)o+=F(r[e].pt.longitude-r[e-1].pt.longitude);let s=[],c=0,l,u;for(let{pt:e,i:t,v:i}of r){let r;if(l){let t=e.longitude-l.raw;Math.abs(t)===180&&(r=[0,0,Math.sign(e.latitude+l.
|
|
1
|
+
import{J as e,Q as t,S as n,Ut as r,Y as i,d as a,f as o,it as s,rt as c,u as l,w as u}from"./native-types-1ewJXVks.mjs";const d=1e-10,f=Math.PI/180,p=6371008.8,m=(e=-90,t=90)=>({south:e,west:-180,north:t,east:180});function h({latitude:e,longitude:t},n){if(n<=0)return{south:e,west:t,north:e,east:t};let r=n/p;if(r>=Math.PI)return m();let i=r/f,a=Math.max(-90,e-i-d),o=Math.min(90,e+i+d);if(a===-90||o===90)return m(a,o);let s=Math.asin(Math.min(1,Math.sin(r)/Math.cos(e*f)))/f+d;return{south:a,west:g(t-s),north:o,east:g(t+s)}}function g(e){return((e+180)%360+360)%360-180}const _=n({south:l,west:a,north:l,east:a},{partial:!1});function v(e){let t=s(_,e);return t.issues?t:t.value.south>t.value.north?i(`south > north`,[`south`]):t}const y=(e,t)=>i(`GeoPolygon ${e}`,t);function b(e){let n=c(e,t);return n.issues?n:n.value.length<r?y(`ring needs >= ${r} vertices`):c(n.value,o)}const x=n({outer:e(`array`,b),holes:u(e(`array`,e=>c(e,b)))},{partial:!1}),S=1e-9*f,C=2*Math.sin(.005*f),w=`contains pole`,T=`self-intersects`,E=`hole outside ring`,D=`holes overlap`,O=1/0;function k(e,t){let n=Math.cos(t*f);return[n*Math.cos(e*f),n*Math.sin(e*f),Math.sin(t*f)]}function A(e,t){return e[0]*t[0]+e[1]*t[1]+e[2]*t[2]}function j(e,t){let n=e[0]-t[0],r=e[1]-t[1],i=e[2]-t[2],a=e[0]+t[0],o=e[1]+t[1],s=e[2]+t[2];return[(r*s-i*o)/2,(i*a-n*s)/2,(n*o-r*a)/2]}function M(e){let t=Math.hypot(...e);return[e[0]/t,e[1]/t,e[2]/t]}function N(e,t){return Math.hypot(e[0]-t[0],e[1]-t[1],e[2]-t[2])}function P(e){return[-e[0],-e[1],-e[2]]}const F=e=>e>180?-360:e<-180?360:0,I=e=>e===180?-180:e;function L(e,n){let r=[];for(let t=0;t<e.length;t++){let i=e[t],a=k(i.longitude,i.latitude);if(Math.hypot(a[0],a[1])<=S)return y(w,[...n,t]);let o=r.at(-1);(!o||N(o.v,a)>S)&&r.push({pt:i,i:t,v:a})}let i=r[0],a=r.at(-1);i&&a&&N(a.v,i.v)>S&&r.push(i);let o=0;for(let e=1;e<r.length;e++)o+=F(r[e].pt.longitude-r[e-1].pt.longitude);let s=[],c=0,l,u;for(let{pt:e,i:t,v:i}of r){let r;if(l){let t=e.longitude-l.raw;Math.abs(t)===180&&(r=[0,0,Math.sign(e.latitude+l.g4)],Math.abs(t-o)===180&&(c-=o)),c+=F(t)}let a={f7:e.longitude+c,g4:e.latitude,raw:e.longitude,v:i};if(l){if(N(P(l.v),i)<C)return y(`antipodal edge`,[...n,t]);if(r&&u&&r[2]!==u[2])return y(w,[...n]);u??=r,s.push({f:l,t:a,s:l.v,e:i,n:M(j(l.v,i)),p:r})}l=a}if(c!==0)return y(w,[...n]);let[d,...f]=s;if(!d||f.length<3&&f.every(({s:e})=>Math.abs(R(d,e))<=S))return y(`zero area ring`,[...n]);for(let e=0;e<s.length;e++){let t=s[e],r=s[(e+1)%s.length];if(z(r.e,t)||z(t.s,r))return y(T,[...n])}return t([d,...f])}function R(e,t){return A(e.n,t)}function z(e,t){return Math.abs(R(t,e))<=S&&A(j(t.s,e),t.n)>=-S&&A(j(e,t.e),t.n)>=-S}function B(e,t){return e>S&&t<-S||e<-S&&t>S}function V(e,t){if(!(B(R(e,t.s),R(e,t.e))&&B(R(t,e.s),R(t,e.e))))return!1;let n=j(e.n,t.n);return A(n,e.s)+A(n,e.e)>0==A(n,t.s)+A(n,t.e)>0}function H(e,t){return V(e,t)||z(e.s,t)||z(e.e,t)||z(t.s,e)||z(t.e,e)}function U(e,t){let n=A(t.n,e.w);return Math.abs(n)>S?n<0:A(t.n,e.e)<0}function W(e,t){let n=e;for(let e=23;e>=0;e--){let r=n.n[e];for(;r?.s&&A(r.s.n,t)>S;)n=r,r=n.n[e]}return n}function G(e,t,n){let r={s:t,p:Array(n),n:Array(n)},i=e;for(let e=23;e>=0;e--){let a=i.n[e];for(;a?.s&&!U(t,a.s);)i=a,a=i.n[e];e<n&&(r.p[e]=i,r.n[e]=a,a&&(a.p[e]=r),i.n[e]=r)}return r}function K(e){for(let t=0;t<e.p.length;t++){let n=e.p[t],r=e.n[t];n.n[t]=r,r&&(r.p[t]=n)}}const q=k(180,0);function J(e){let t=M(j(e.n,[-q[1],q[0],0]));return A(t,q)<0?P(t):t}function Y(e,t,n,r,i){let a={s:i,e:void 0};e.push({x:t,k:1,s:a},{x:n,k:r,s:a})}function X(e,t){let{f:n,t:r,n:i,p:a}=e.a,o=I(n.raw),s=I(r.raw);if(o===s){let[i,a]=n.g4<r.g4?[n,r]:[r,n];t.push({x:o,k:2,u:{p:e,s:i.v,n:a.v}});return}let c=n.f7<r.f7,[l,u]=c?[n,r]:[r,n],d=c?i:P(i),[f,p]=c?[o,s]:[s,o],m=(n,r,i,a,o)=>Y(t,n,r,i,{p:e,w:a,e:o,n:d,ew:c});if(a){for(let{raw:i,v:o}of[n,r])t.push({x:I(i),k:2,u:{p:e,s:a[2]>0?o:a,n:a[2]>0?a:o}});f<p?m(f,p,0,a,a):(m(f,180,0,a,a),p>-180&&m(-180,p,0,a,a));return}f<p?m(f,p,3,l.v,u.v):(m(f,180,3,l.v,u.v),m(-180,p,3,J(e.a),u.v))}function Z(e){return Math.atan2(e[2],Math.hypot(e[0],e[1]))}function Q(e,t){let n=[];for(let t of e)X(t,n);n.sort((e,t)=>e.x-t.x||e.k-t.k);let r={s:void 0,p:Array(24),n:Array(24)},i=(e,n)=>e&&n&&!t(e,n)&&H(e.a,n.a)?[e,n]:void 0,a=[],o=new Map,s=()=>{let e=Array.from(o,([e,{e:t,w:n}])=>{let r=t.n[0];for(;r?.s?.p.r===e;)r=r.n[0];return{r:e,h:Z(n),n:r?.s}});e.sort((e,t)=>t.h-e.h);for(let t of e)a.push(t);o.clear()},c=new Set;for(let e=0;e<n.length;e++){let t=n[e];if(t.k===1){let a=1+Math.floor(-Math.log2(1-Math.random())),l=t.s.s,u=G(r,l,Math.min(24,a));t.s.e=u;let d=i(u.p[0]?.s?.p,l.p)??i(l.p,u.n[0]?.s?.p);if(d)return{m:d};let{p:f,w:p}=l,m=o.get(f.r);(!c.has(f.r)||m&&Z(p)>Z(m.w))&&(c.add(f.r),o.set(f.r,{e:u,w:p}));let h=n[e+1];(h?.k!==1||h.x!==t.x)&&s()}else if(t.k===2){let{u:e}=t,n=W(r,e.s);for(n=n.s?n:n.n[0];n?.s;){let t=i(e.p,n.s.p);if(t)return{m:t};if(A(n.s.n,e.n)<-S)break;n=n.n[0]}}else if(t.s.e){let e=t.s.e;K(e);let n=i(e.p[0]?.s?.p,e.n[0]?.s?.p);if(n)return{m:n}}}return{p:a}}function ee(e){let t=0,n=0,r,i=0;for(let a of e){let e=j(a.s,a.e)[2],o=1+A(a.s,a.e),s=a.s[2]+a.e[2];s>=0?(t+=2*Math.atan2(e,o+s),r!==void 0&&(n+=a.f.f7-r),r=void 0):(t+=2*Math.atan2(-e,o-s),r??=a.f.f7),i=a.t.f7}return r!==void 0&&(n+=i-r),t+2*n*f}function $(e,t,n){return{i:n,h:n===0?O:n-1,g5:e,a:t,g0:ee(t)>0,out:void 0,in:!1,fa:O,fw:O}}function te(e){let n=s(x,e);if(n.issues)return n;let r=L(n.value.outer,[`outer`]);if(r.issues)return r;let i=$(n.value.outer,r.value,0),a=[],o=n.value.holes??[];for(let e=0;e<o.length;e++){let t=o[e],n=L(t,[`holes`,e]);if(n.issues)return n;a.push($(t,n.value,e+1))}let c=[];for(let e=0;e<=a.length;e++){let t=e===0?i:a[e-1];for(let e=0;e<t.a.length;e++)c.push({a:t.a[e],r:t,i:e})}let l=Q(c,(e,t)=>{if(e.r!==t.r)return!1;let n=Math.abs(e.i-t.i);return n<=1||n===e.r.a.length-1});if(l.m){let[e,t]=l.m,n=Math.max(e.r.i,t.r.i),r=n===0?[`outer`]:[`holes`,n-1];return y(e.r===t.r?T:Math.min(e.r.i,t.r.i)===0?E:D,r)}for(let{r:e,n:t}of l.p){let n=t?.p.r,r=n===void 0||n.g0!==t?.ew?n:n.out;e.out=r,e.in=r!==void 0&&(r.i===0||r.in),e.fa=r?Math.min(r.h,r.fa):O}for(let{r:e}of l.p.reverse()){let{out:t}=e;t&&(t.fw=Math.min(t.fw,e.h,e.fw))}for(let{h:e,in:t,fa:n,fw:r}of a){if(!t)return y(E,[`holes`,e]);if(Math.min(n,r)<e)return y(D,[`holes`,e])}let u=i.g0?i.g5:i.g5.reverse(),d=a.map(({g5:e,g0:t})=>t?e.reverse():e);return t(d.length>0?{outer:u,holes:d}:{outer:u})}const ne=n({bounds:e(`object`,v),polygon:e(`object`,te)});function re(e){let n=s(ne,e);if(n.issues)return n;let{bounds:r,polygon:a}=n.value;return r&&!a?t({bounds:r}):a&&!r?t({polygon:a}):i(`Expected bounds or polygon`)}function ie(){return e(`geo_area`,re)}export{ie as n,h as r,p as t};
|
|
2
2
|
//# sourceMappingURL=geo-area-codec-Bti2PA2i.mjs.map
|
package/dist/index.d.mts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { $ as With, $i as UpdateState, $n as extension, A as BoundAccepted, Aa as AnyJsonNullSentinel, Ai as ModelToOneRelation, An as reads, Ao as CacheConfigurationError, At as AutoGenerate, B as Outcome, Ba as Getter, Bi as AnyFieldRef, Bn as gate, Bo as wrapError, Ca as Decimal, Ci as BlobScalar, Cn as text, Co as UniqueConstraintError, Cr as UnwrapPendingOperation, Ct as RowsFragment, D as AnyFacts, Da as BlobSchema, Di as LinkedClientConfig, Dn as parts, Do as isNotNullConstraintError, Dr as WriteKind, Dt as VariantToOneRelation, E as AnyCallContext, Ei as Linked, En as rule, Eo as isForeignKeyError, Er as WriteOutcome, Et as VariantToManyRelation, F as Exact, Fa as JsonNullSentinel, Fn as methods, Fo as VibORMError, G as Selection, Gi as AnyModel, Gn as exists, Gr as Schema, H as Parts, Ha as ReferentialAction, Hi as ModelFieldRefs, Hn as lazy, I as Extension, Ia as isJsonNullSentinel, Ii as VectorSchema, In as modelMethods, Io as VibORMErrorCode, It as UpdateState$1, J as TargetOf, Jn as provided, K as StampedFields, Ki as IndexDefinition, Kn as nothing, L as Facts, Li as StringSchema, Ln as key, Lo as isRetryableError, M as CallResult, Ma as DbNull, Mi as ModelToManyRelation, Mn as target, Mo as CacheInvalidTTLError, Mr as InsertValueContext, Mt as GeneratorDefaultBrand, N as ConfiguredBy, Na as JsonNull, Nn as writes, No as CacheOperationNotCacheableError, Nr as ModelSql, Nt as InitialScalarState, O as AnyTarget, Oi as Links, On as deletes, Oo as isUniqueConstraintError, Or as around, Ot as Scalar, P as EmptyFacts, Pa as JsonNullKind, Pn as work, Po as PrismaErrorCode, Pt as ScalarState, Q as Watcher, Qi as ModelState, Qn as fields, R as NoArguments, Rn as check, Ro as isVibORMError, Sa as DecimalDescriptor, Si as BooleanScalar, Sn as table, So as NotNullConstraintError, Sr as PendingOperation, St as RawOperation, T as Accepted, Ta as BooleanSchema, Ti as FlatSchema, Tn as settled, To as isCheckConstraintError, Tr as isPendingOperation, Tt as ScalarKeys, U as PlacedArgument, Ua as RelationCardinality, Ui as createModelFieldRefs, Un as only, V as Part, Vi as FieldRef, Vn as keep, Vo as DiagnosticDisclosure, W as Run, Wa as RelationSlot, Wi as isFieldRef, Wn as arg, X as UnitKind, Xi as Model, Xn as unless, Y as UnitContext, Yi as InitialModelState, Yn as row, Yr as ClientHiddenContext, Z as UnitOutcome, Zi as ModelInternal, Zn as when, _a as GeoPolygon, _i as NumberScalar, _n as origin, _o as isUnsupportedOperationError, _r as getOperationPayloadSchema, _t as ChainedExtensionState, aa as InputJsonValue, ai as DecimalScalar, an as getRowKey, ao as FeatureNotSupportedError, ar as Database, at as DelegateOperationPayload, ba as EnumSchema, bi as DateTimeScalar, bn as statement, bo as CheckConstraintError, br as validateOperationPayload, bt as ExtensionResultConsumerState, ci as validateSchemaOrThrow, cn as computed, co as NestedWriteError, cr as Codec, ct as ExtendedClient, d as ValidationErrorSource, da as IsoDateSchema, di as SchemaValidationIssue, dn as BatchMember, do as QueryEngineError, dr as via, dt as TransactionClient, ei as NumericScalar, er as disclosed, et as AddedProjectedState, f as isValidationError, fa as IsoTimeSchema, fi as Severity, fn as correlation, fo as QueryError, fr as watch, ft as TransactionClientOf, ga as GeoPoint, gi as StringScalar, gn as notes, go as isPendingOperationError, gr as oneOf, gt as AddedExtensionState, ha as GeoBounds, hi as ViewState, hn as note, ho as isNotFoundError, hr as bound, ht as createClient, ii as EnumScalar, in as getSchemas, io as ConnectionError, ir as omitted, it as DelegateOperationArgs, j as CallContext, ja as AnyNull, ji as ReferencesStage, jn as selecting, jo as CacheInvalidKeyError, k as ArgTest, ka as BigIntSchema, ki as RelationLinks, kn as models, ko as isValueTooLongError, kr as call, kt as BigIntScalar, li as SchemaValidationError, ln as joined, lo as NotFoundError, lr as codec, lt as ExtendedOperationResult, ma as GeoArea, mn as failure, mo as isClientInitializationError, mr as args, mt as VibORMConfig, na as IntegerSchema, ni as PointScalar, no as TransactionError, nr as disclosure, nt as ClientTypeState, oa as JsonSchema, oi as s, on as VIBORM_VERSION, oo as ForbiddenError, or as database, ot as DelegateOperationResult, pa as IsoTimestampSchema, pi as ValidationResult, pn as driver, po as UnsupportedOperationError, pr as accepts, pt as VibORMClient, q as Target, qi as IndexOptions, qn as now, qt as VibSchema, ra as NumberSchema, ri as JsonScalar, ro as ClientInitializationError, rr as defaults, rt as DelegateConfig, sa as JsonValue, si as validateSchema, sn as JoinedSource, so as NestedWriteAssertionError, sr as within, ti as VectorScalar, to as InvalidTransactionInputError, tr as DisclosurePolicy, u as ValidationError, ui as isSchemaValidationError, un as stored, uo as PendingOperationError, ur as again, va as ObjectSchema, vi as IntScalar, vn as parameters, vo as MigrationError, vr as renderOperationResultType, vt as ClientExtensionState, wi as ClientSchema, wn as unit, wo as ValueTooLongError, wr as UnwrapPendingOperations, wt as ModelShape, xa as DecimalSchema, xi as DateScalar, xn as statements, xo as ForeignKeyError, xr as ProjectedModelOperations, xt as ExtensionStateConstraint, yi as TimeScalar, yn as run, yo as isMigrationError, yr as renderSchemaType, yt as EmptyClientExtensionState, z as OperationSet, za as AnyRelation, zi as PointSchema, zn as facts, zo as toPrismaErrorCode } from "./database-adapter-
|
|
1
|
+
import { $ as With, $i as UpdateState, $n as extension, A as BoundAccepted, Aa as AnyJsonNullSentinel, Ai as ModelToOneRelation, An as reads, Ao as CacheConfigurationError, At as AutoGenerate, B as Outcome, Ba as Getter, Bi as AnyFieldRef, Bn as gate, Bo as wrapError, Ca as Decimal, Ci as BlobScalar, Cn as text, Co as UniqueConstraintError, Cr as UnwrapPendingOperation, Ct as RowsFragment, D as AnyFacts, Da as BlobSchema, Di as LinkedClientConfig, Dn as parts, Do as isNotNullConstraintError, Dr as WriteKind, Dt as VariantToOneRelation, E as AnyCallContext, Ei as Linked, En as rule, Eo as isForeignKeyError, Er as WriteOutcome, Et as VariantToManyRelation, F as Exact, Fa as JsonNullSentinel, Fn as methods, Fo as VibORMError, G as Selection, Gi as AnyModel, Gn as exists, Gr as Schema, H as Parts, Ha as ReferentialAction, Hi as ModelFieldRefs, Hn as lazy, I as Extension, Ia as isJsonNullSentinel, Ii as VectorSchema, In as modelMethods, Io as VibORMErrorCode, It as UpdateState$1, J as TargetOf, Jn as provided, K as StampedFields, Ki as IndexDefinition, Kn as nothing, L as Facts, Li as StringSchema, Ln as key, Lo as isRetryableError, M as CallResult, Ma as DbNull, Mi as ModelToManyRelation, Mn as target, Mo as CacheInvalidTTLError, Mr as InsertValueContext, Mt as GeneratorDefaultBrand, N as ConfiguredBy, Na as JsonNull, Nn as writes, No as CacheOperationNotCacheableError, Nr as ModelSql, Nt as InitialScalarState, O as AnyTarget, Oi as Links, On as deletes, Oo as isUniqueConstraintError, Or as around, Ot as Scalar, P as EmptyFacts, Pa as JsonNullKind, Pn as work, Po as PrismaErrorCode, Pt as ScalarState, Q as Watcher, Qi as ModelState, Qn as fields, R as NoArguments, Rn as check, Ro as isVibORMError, Sa as DecimalDescriptor, Si as BooleanScalar, Sn as table, So as NotNullConstraintError, Sr as PendingOperation, St as RawOperation, T as Accepted, Ta as BooleanSchema, Ti as FlatSchema, Tn as settled, To as isCheckConstraintError, Tr as isPendingOperation, Tt as ScalarKeys, U as PlacedArgument, Ua as RelationCardinality, Ui as createModelFieldRefs, Un as only, V as Part, Vi as FieldRef, Vn as keep, Vo as DiagnosticDisclosure, W as Run, Wa as RelationSlot, Wi as isFieldRef, Wn as arg, X as UnitKind, Xi as Model, Xn as unless, Y as UnitContext, Yi as InitialModelState, Yn as row, Yr as ClientHiddenContext, Z as UnitOutcome, Zi as ModelInternal, Zn as when, _a as GeoPolygon, _i as NumberScalar, _n as origin, _o as isUnsupportedOperationError, _r as getOperationPayloadSchema, _t as ChainedExtensionState, aa as InputJsonValue, ai as DecimalScalar, an as getRowKey, ao as FeatureNotSupportedError, ar as Database, at as DelegateOperationPayload, ba as EnumSchema, bi as DateTimeScalar, bn as statement, bo as CheckConstraintError, br as validateOperationPayload, bt as ExtensionResultConsumerState, ci as validateSchemaOrThrow, cn as computed, co as NestedWriteError, cr as Codec, ct as ExtendedClient, d as ValidationErrorSource, da as IsoDateSchema, di as SchemaValidationIssue, dn as BatchMember, do as QueryEngineError, dr as via, dt as TransactionClient, ei as NumericScalar, er as disclosed, et as AddedProjectedState, f as isValidationError, fa as IsoTimeSchema, fi as Severity, fn as correlation, fo as QueryError, fr as watch, ft as TransactionClientOf, ga as GeoPoint, gi as StringScalar, gn as notes, go as isPendingOperationError, gr as oneOf, gt as AddedExtensionState, ha as GeoBounds, hi as ViewState, hn as note, ho as isNotFoundError, hr as bound, ht as createClient, ii as EnumScalar, in as getSchemas, io as ConnectionError, ir as omitted, it as DelegateOperationArgs, j as CallContext, ja as AnyNull, ji as ReferencesStage, jn as selecting, jo as CacheInvalidKeyError, k as ArgTest, ka as BigIntSchema, ki as RelationLinks, kn as models, ko as isValueTooLongError, kr as call, kt as BigIntScalar, li as SchemaValidationError, ln as joined, lo as NotFoundError, lr as codec, lt as ExtendedOperationResult, ma as GeoArea, mn as failure, mo as isClientInitializationError, mr as args, mt as VibORMConfig, na as IntegerSchema, ni as PointScalar, no as TransactionError, nr as disclosure, nt as ClientTypeState, oa as JsonSchema, oi as s, on as VIBORM_VERSION, oo as ForbiddenError, or as database, ot as DelegateOperationResult, pa as IsoTimestampSchema, pi as ValidationResult, pn as driver, po as UnsupportedOperationError, pr as accepts, pt as VibORMClient, q as Target, qi as IndexOptions, qn as now, qt as VibSchema, ra as NumberSchema, ri as JsonScalar, ro as ClientInitializationError, rr as defaults, rt as DelegateConfig, sa as JsonValue, si as validateSchema, sn as JoinedSource, so as NestedWriteAssertionError, sr as within, ti as VectorScalar, to as InvalidTransactionInputError, tr as DisclosurePolicy, u as ValidationError, ui as isSchemaValidationError, un as stored, uo as PendingOperationError, ur as again, va as ObjectSchema, vi as IntScalar, vn as parameters, vo as MigrationError, vr as renderOperationResultType, vt as ClientExtensionState, wi as ClientSchema, wn as unit, wo as ValueTooLongError, wr as UnwrapPendingOperations, wt as ModelShape, xa as DecimalSchema, xi as DateScalar, xn as statements, xo as ForeignKeyError, xr as ProjectedModelOperations, xt as ExtensionStateConstraint, yi as TimeScalar, yn as run, yo as isMigrationError, yr as renderSchemaType, yt as EmptyClientExtensionState, z as OperationSet, za as AnyRelation, zi as PointSchema, zn as facts, zo as toPrismaErrorCode } from "./database-adapter-01J6mYq5.mjs";
|
|
2
2
|
import { a as isSql, c as sqlTag, i as empty, n as Sql, o as join, r as Value, s as raw, t as RawValue } from "./sql-C4_sFNDm.mjs";
|
|
3
3
|
export { Accepted, type AddedExtensionState, type AddedProjectedState, AnyCallContext, AnyFacts, type AnyFieldRef, type AnyJsonNullSentinel, type AnyModel, AnyNull, type AnyRelation, AnyTarget, ArgTest, type AutoGenerate, BatchMember, type BigIntScalar, type BigIntSchema, type BlobScalar, type BlobSchema, type BooleanScalar, type BooleanSchema, BoundAccepted, CacheConfigurationError, CacheInvalidKeyError, CacheInvalidTTLError, CacheOperationNotCacheableError, CallContext, CallResult, type ChainedExtensionState, CheckConstraintError, type ClientExtensionState, type ClientHiddenContext, ClientInitializationError, type ClientSchema, type ClientTypeState, Codec, type InsertValueContext as ComputedContext, ConfiguredBy, ConnectionError, Database, type DateScalar, type DateTimeScalar, DbNull, Decimal, type DecimalDescriptor, type DecimalScalar, type DecimalSchema, type DelegateConfig, type DelegateOperationArgs, type DelegateOperationPayload, type DelegateOperationResult, type DiagnosticDisclosure, DisclosurePolicy, type EmptyClientExtensionState, EmptyFacts, type EnumScalar, type EnumSchema, Exact, type ExtendedClient, type ExtendedOperationResult, Extension, type ExtensionResultConsumerState, type ExtensionStateConstraint as ExtensionState, Facts, FeatureNotSupportedError, type FieldRef, type FlatSchema, ForbiddenError, ForeignKeyError, type GeneratorDefaultBrand, type GeoArea, type GeoBounds, type GeoPoint, type GeoPolygon, type Getter, type IndexDefinition, type IndexOptions, type InitialModelState, type InitialScalarState, type InputJsonValue, type IntScalar, type IntegerSchema, InvalidTransactionInputError, type IsoDateSchema, type IsoTimeSchema, type IsoTimestampSchema, type JoinedSource, JsonNull, type JsonNullKind, JsonNullSentinel, type JsonScalar, type JsonValue, type JsonSchema as JsonValueSchema, type Linked, type LinkedClientConfig, type Links, MigrationError, type Model, type ModelFieldRefs, type ModelInternal, type ModelShape, type ModelSql, type ModelState, type ModelToManyRelation, type ModelToOneRelation, type UpdateState as ModelUpdateState, NestedWriteAssertionError, NestedWriteError, type NoArguments, NotFoundError, NotNullConstraintError, type NumberScalar, type NumberSchema, type NumericScalar, type ObjectSchema, OperationSet, Outcome, Part, Parts, PendingOperation, PendingOperationError, type PlacedArgument, type PointScalar, type PointSchema, type PrismaErrorCode, type ProjectedModelOperations, QueryEngineError, QueryError, type RawOperation, type RawValue, type ReferencesStage, type ReferentialAction, type RelationCardinality, type RelationLinks, type RelationSlot, type RowsFragment, Run, type Scalar, type ScalarKeys, type ScalarState, type UpdateState$1 as ScalarUpdateState, type Schema, SchemaValidationError, type SchemaValidationIssue, Selection, type Severity, Sql, type StampedFields, type StringScalar, type StringSchema, Target, TargetOf, type TimeScalar, type TransactionClient, type TransactionClientOf, TransactionError, UniqueConstraintError, UnitContext, UnitKind, UnitOutcome, UnsupportedOperationError, type UnwrapPendingOperation, type UnwrapPendingOperations, VIBORM_VERSION, ValidationError, type ValidationErrorSource, type ValidationResult, type Value, ValueTooLongError, type VariantToManyRelation, type VariantToOneRelation, type VectorScalar, type VectorSchema, type VibORMClient, type VibORMConfig, VibORMError, VibORMErrorCode, type VibSchema, type ViewState, Watcher, With, WriteKind, WriteOutcome, accepts, again, arg, args, around, bound, call, check, codec, computed, correlation, createClient, createModelFieldRefs, database, defaults, deletes, disclosed, disclosure, driver, empty, exists, extension, facts, failure, fields, gate, getOperationPayloadSchema, getRowKey, getSchemas, isCheckConstraintError, isClientInitializationError, isFieldRef, isForeignKeyError, isJsonNullSentinel, isMigrationError, isNotFoundError, isNotNullConstraintError, isPendingOperation, isPendingOperationError, isRetryableError, isSchemaValidationError, isSql, isUniqueConstraintError, isUnsupportedOperationError, isValidationError, isValueTooLongError, isVibORMError, join, joined, keep, key, lazy, methods, modelMethods, models, note, notes, nothing, now, omitted, oneOf, only, origin, parameters, parts, provided, raw, reads, renderOperationResultType, renderSchemaType, row, rule, run, s, selecting, settled, sqlTag as sql, statement, statements, stored, table, target, text, toPrismaErrorCode, unit, unless, validateOperationPayload, validateSchema, validateSchemaOrThrow, via, watch, when, within, work, wrapError, writes };
|
package/dist/index.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{A as e,C as t,D as n,E as r,O as i,S as a,T as o,b as s,j as c,k as l,v as u,w as d,x as f,y as p}from"./error-mapping-B9rSvgG9.mjs";import{a as m,i as h,n as g,o as _,s as v,t as y}from"./base-17NSFtrA.mjs";import{n as b,t as x}from"./migrations-DIUltjr3.mjs";import{_ as S,a as ee,c as te,d as ne,f as re,g as ie,h as ae,i as oe,l as se,m as ce,n as le,o as ue,p as de,r as fe,t as pe,u as me,v as he}from"./validation-ATmgN5RE.mjs";import{n as ge,t as _e}from"./transaction-Bv5nyp-U.mjs";import{a as C,i as w,n as T,o as E,r as D,t as O}from"./sql-tegqTqGq.mjs";import{o as k}from"./value-guards-CBVIJXlI.mjs";import{r as A,t as j}from"./extension-Dh1ddrlA.mjs";import{dt as M,ft as N,ht as P,mt as F,pt as I,vt as ve,xt as ye}from"./model-Dtd37Sky.mjs";import{U as be}from"./native-types-1ewJXVks.mjs";import{a as xe}from"./keys-DZdKAd4n.mjs";import{r as Se,t as Ce}from"./pending-operation-D4gUKMxD.mjs";import{a as we,i as Te,r as Ee,t as De}from"./client-
|
|
1
|
+
import{A as e,C as t,D as n,E as r,O as i,S as a,T as o,b as s,j as c,k as l,v as u,w as d,x as f,y as p}from"./error-mapping-B9rSvgG9.mjs";import{a as m,i as h,n as g,o as _,s as v,t as y}from"./base-17NSFtrA.mjs";import{n as b,t as x}from"./migrations-DIUltjr3.mjs";import{_ as S,a as ee,c as te,d as ne,f as re,g as ie,h as ae,i as oe,l as se,m as ce,n as le,o as ue,p as de,r as fe,t as pe,u as me,v as he}from"./validation-ATmgN5RE.mjs";import{n as ge,t as _e}from"./transaction-Bv5nyp-U.mjs";import{a as C,i as w,n as T,o as E,r as D,t as O}from"./sql-tegqTqGq.mjs";import{o as k}from"./value-guards-CBVIJXlI.mjs";import{r as A,t as j}from"./extension-Dh1ddrlA.mjs";import{dt as M,ft as N,ht as P,mt as F,pt as I,vt as ve,xt as ye}from"./model-Dtd37Sky.mjs";import{U as be}from"./native-types-1ewJXVks.mjs";import{a as xe}from"./keys-DZdKAd4n.mjs";import{r as Se,t as Ce}from"./pending-operation-D4gUKMxD.mjs";import{a as we,i as Te,r as Ee,t as De}from"./client-Q4zkYZbn.mjs";import{a as Oe,s as ke}from"./scalar-Dm9brvAU.mjs";import{a as Ae,o as je}from"./time-step-DJaIhpAz.mjs";import{i as Me}from"./validation-BHjx13zG.mjs";import{a as Ne,i as Pe}from"./validator-DMzH5Tz0.mjs";import{i as Fe,n as Ie,r as Le,t as Re}from"./schema-introspection-Bbo4DN_d.mjs";import{n as L,t as R}from"./methods-part-BaNx3o7b.mjs";import{a as ze,c as z,l as Be,n as Ve,o as He,r as Ue}from"./on-ZkOVmE4-.mjs";import{i as We,n as B,r as Ge,t as Ke}from"./args-7WgBFd_f.mjs";import{n as V,t as H}from"./call-0bd_B9Vp.mjs";import{i as qe,n as Je,r as Ye,t as Xe}from"./settled-DYYPcaBX.mjs";import{n as Ze,r as Qe,t as $e}from"./key-BDH6oTyC.mjs";import{a as et,c as tt,d as nt,i as rt,o as it,r as at,s as ot,u as st}from"./rule-words-DMbQuvD2.mjs";import{a as ct,c as U,i as lt,n as ut,o as dt,r as ft,s as pt}from"./judge-words-k5GCc4cV.mjs";import{t as mt}from"./confine-CyI9IwjC.mjs";import{n as ht,t as W}from"./defaults-DAPb-tJ4.mjs";import{n as G,r as gt,t as K}from"./unit-DUPX5Sdd.mjs";import{a as _t,c as vt,d as yt,f as bt,h as xt,i as St,l as Ct,n as wt,o as Tt,r as Et,s as Dt,t as Ot,u as kt}from"./unit-words-BXpLpyr2.mjs";import{n as At,r as jt,t as Mt}from"./values-Ch2cTlss.mjs";import{t as q}from"./schema-DqR_Kcje.mjs";import{t as Nt}from"./version-Bu2LCuaj.mjs";const J=`$allModels`,Pt=new Set([`createMany`,`updateMany`,`deleteMany`]);function Y(e,t,n,r){let i=e[n[`~`].names.ts]??[],a=k(r?.select)?r.select:void 0,o=k(r?.include)?r.include:void 0,s=k(r?.omit)?r.omit:void 0,c=[],l=a??o,u=l;if(l!==void 0){let r=t.get(n);for(let n of Object.keys(l)){let i=r?.get(n),a=l[n];if(!i||Te(i)||a!==!0&&!k(a))continue;let o=we(i),s=a===!0?void 0:a,d=Y(e,t,o,s);d!==void 0&&(c.push([n,d.node]),s?.recurse!==void 0&&d.node.relations.push([n,d.node]),d.args!==s&&(u={...u,[n]:d.args}))}}let d=new Map;for(let[e,t]of i.entries())d.set(t.name,e);let f=e=>(a?a[e]===!0:!0)&&s?.[e]!==!0,p=[],m=!1;for(let[e,t]of d)m||=(a??s)?.[e]!==void 0,f(e)&&p.push(t);if(p.length===0&&c.length===0&&!m)return;let h=new Set,g=new Set,_=e=>{if(!h.has(e)){h.add(e);for(let t of i[e].needs)typeof t==`number`?_(t):g.add(t)}};for(let e of p)_(e);let v=new Set;for(let e of g)f(e)||v.add(e);let y=r;if(s!==void 0){let e={...s};for(let t of d.keys())s[t]!==void 0&&!Object.hasOwn(n[`~`].state.scalars,t)&&delete e[t];for(let t of g)s[t]===!0&&(e[t]=!1);y={...y,omit:e}}if(a!==void 0){let e={...u};for(let t of d.keys())delete e[t];for(let t of g)e[t]=!0;if(!Object.values(e).some(e=>e!==!1)){let[t]=je(n);t!==void 0&&(e[t]=!0,f(t)||v.add(t))}y={...y,select:e}}else u!==l&&(y={...y,include:u});return{args:y,node:{fields:i,outputs:p,reads:[...g],strip:[...v],relations:c}}}function X(e,t){return Array.isArray(e)?e.map(e=>Z(e,t)):Z(e,t)}function Z(e,t){if(!k(e))return e;let n={...e};for(let[e,r]of t.relations)n[e]!==void 0&&(n[e]=X(n[e],r));for(let e of t.strip)delete n[e];let r=e;for(let n of t.reads){let t=e[n];typeof t!=`object`||!t||(r===e&&(r={...e}),r[n]=Q(t))}let i=new Map,a=e=>{if(i.has(e))return i.get(e);let n=t.fields[e],o={};for(let e of n.needs)typeof e==`number`?o[t.fields[e].name]=a(e):o[e]=r[e];let s=n.compute(o);return i.set(e,s),s};for(let e of t.outputs){let r=t.fields[e].name,i=e=>(Object.defineProperty(n,r,{value:e,writable:!0,enumerable:!0,configurable:!0}),e);Object.defineProperty(n,r,{get:()=>i(a(e)),set:i,enumerable:!0,configurable:!0})}return n}function Q(e){if(typeof e!=`object`||!e)return e;if(Array.isArray(e))return e.map(Q);if(e instanceof Date)return new Date(e.getTime());if(ArrayBuffer.isView(e))return Object.getPrototypeOf(Uint8Array.prototype).slice.call(e);let t=Object.getPrototypeOf(e);if(t!==Object.prototype&&t!==null)return e;let n={};for(let t in e)n[t]=Q(e[t]);return n}function Ft(e){return{join({next:t,name:n,schema:r}){for(let t of Object.keys(e))t!==J&&!Object.hasOwn(r,t)&&A(`Extension "${n}" result names unknown model "${t}".`,n);let i={...t.fields?.fields};for(let t of Object.keys(r)){let a=r[t],o=[...i[t]??[]],s=new Set(Ae(a));for(let r of[J,t])for(let[i,{needs:c={},compute:l}]of Object.entries(e[r]??{})){let e=`Extension "${n}" result.${r}.${i}`;(i===`_count`||i===`_aggregate`||Object.hasOwn(a[`~`].state.relations,i))&&A(`${e} cannot be computed: "${i}" is a relation of model "${t}" or its relation output.`,n);let u=Object.keys(c).filter(e=>c[e]).map(r=>{for(let e=o.length-1;e>=0;e--)if(o[e].name===r)return e;return s.has(r)?r:A(`${e} needs "${r}", which is not a readable scalar or an earlier computed field of model "${t}".`,n)});o.push({name:i,compute:l,needs:u})}o.length>0&&(i[t]=o)}t.fields={fields:i,plan:(e,t,n,r)=>{if(!(Ee.has(n)||Pt.has(n)&&(r.select!==void 0||r.omit!==void 0)))return;let a=Y(i,e,t,r);if(a===void 0)return;let{node:o}=a;return{args:a.args,finish:e=>X(e,o)}}}}}}function $(e){return Ft(e)}function It(){return{extension:j,call:V,around:H,target:z,unit:K,rule:U,defaults:W,disclosure:G,args:B,methods:R,modelMethods:L,fields:$}}const Lt=e=>Me(e).proxy;export{M as AnyNull,i as CacheConfigurationError,l as CacheInvalidKeyError,e as CacheInvalidTTLError,c as CacheOperationNotCacheableError,u as CheckConstraintError,fe as ClientInitializationError,oe as ConnectionError,N as DbNull,be as Decimal,ee as FeatureNotSupportedError,ue as ForbiddenError,p as ForeignKeyError,_e as InvalidTransactionInputError,I as JsonNull,F as JsonNullSentinel,x as MigrationError,te as NestedWriteAssertionError,se as NestedWriteError,me as NotFoundError,s as NotNullConstraintError,Ce as PendingOperation,ne as PendingOperationError,re as QueryEngineError,de as QueryError,Oe as SchemaValidationError,O as Sql,ge as TransactionError,f as UniqueConstraintError,ce as UnsupportedOperationError,Nt as VIBORM_VERSION,pe as ValidationError,a as ValueTooLongError,y as VibORMError,g as VibORMErrorCode,Ke as accepts,Je as again,at as arg,B as args,H as around,Ge as bound,V as call,ut as check,Qe as codec,Mt as computed,Ot as correlation,De as createClient,ve as createModelFieldRefs,Ze as database,W as defaults,Ve as deletes,gt as disclosed,G as disclosure,wt as driver,T as empty,rt as exists,j as extension,ft as facts,Et as failure,$ as fields,lt as gate,Re as getOperationPayloadSchema,xe as getRowKey,Lt as getSchemas,t as isCheckConstraintError,ae as isClientInitializationError,ye as isFieldRef,d as isForeignKeyError,P as isJsonNullSentinel,b as isMigrationError,ie as isNotFoundError,o as isNotNullConstraintError,Se as isPendingOperation,S as isPendingOperationError,h as isRetryableError,ke as isSchemaValidationError,D as isSql,r as isUniqueConstraintError,he as isUnsupportedOperationError,le as isValidationError,n as isValueTooLongError,m as isVibORMError,w as join,At as joined,ct as keep,$e as key,dt as lazy,R as methods,L as modelMethods,Ue as models,St as note,_t as notes,et as nothing,it as now,ht as omitted,We as oneOf,pt as only,Tt as origin,Dt as parameters,It as parts,ot as provided,C as raw,ze as reads,Ie as renderOperationResultType,Le as renderSchemaType,tt as row,U as rule,vt as run,q as s,He as selecting,Xe as settled,E as sql,Ct as statement,kt as statements,jt as stored,yt as table,z as target,bt as text,_ as toPrismaErrorCode,K as unit,st as unless,Fe as validateOperationPayload,Pe as validateSchema,Ne as validateSchemaOrThrow,Ye as via,qe as watch,nt as when,mt as within,xt as work,v as wrapError,Be as writes};
|
|
2
2
|
//# sourceMappingURL=index.mjs.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Fo as VibORMError, I as Extension, O as AnyTarget, P as EmptyFacts, Vo as DiagnosticDisclosure } from "./database-adapter-
|
|
1
|
+
import { Fo as VibORMError, I as Extension, O as AnyTarget, P as EmptyFacts, Vo as DiagnosticDisclosure } from "./database-adapter-01J6mYq5.mjs";
|
|
2
2
|
|
|
3
3
|
//#region src/instrumentation/types.d.ts
|
|
4
4
|
|
package/dist/instrumentation.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{a as e}from"./base-17NSFtrA.mjs";import{t}from"./extension-Dh1ddrlA.mjs";import{n,r,t as i}from"./unit-DUPX5Sdd.mjs";import{a,d as o,f as s,n as c,o as l,r as u,s as d,t as f,u as p}from"./unit-words-BXpLpyr2.mjs";import{t as m}from"./version-
|
|
1
|
+
import{a as e}from"./base-17NSFtrA.mjs";import{t}from"./extension-Dh1ddrlA.mjs";import{n,r,t as i}from"./unit-DUPX5Sdd.mjs";import{a,d as o,f as s,n as c,o as l,r as u,s as d,t as f,u as p}from"./unit-words-BXpLpyr2.mjs";import{t as m}from"./version-Bu2LCuaj.mjs";import{C as h,D as g,E as _,S as v,T as y,_ as b,a as x,b as S,c as C,d as w,f as ee,g as te,h as ne,i as re,l as T,m as E,n as D,o as O,p as k,r as ie,s as A,t as ae,u as oe,v as se,w as j,x as ce,y as le}from"./spans-DwDXMvyd.mjs";const ue=new Set([`bypass`,`hit`,`miss`,`revalidate`]),de=new Set([`cache-set-failed`,`error`,`fresh`,`stale`,`start`,`success`]);function fe(e){let{event:t,status:n}=e;return{...ue.has(t)?{event:t}:{},...de.has(n)?{status:n}:{}}}function pe(e){let t=e.timestamp.toISOString(),n=e.duration===void 0?``:`${e.duration}ms`,r=e.model?[e.model,e.operation].filter(Boolean).join(`.`):e.operation??``;switch(e.level){case`query`:console.log([`[QUERY]`,t,r||`query`,n].filter(Boolean).join(` `)),e.sql&&console.log(` ${e.sql}`),e.params?.length&&console.log(` params: ${JSON.stringify(e.params)}`);break;case`cache`:console.log(`[CACHE]`,t,typeof e.meta?.event==`string`?e.meta.event:`unknown`,typeof e.meta?.status==`string`?`(${e.meta.status})`:``);break;case`error`:console.error(`[ERROR]`,t,r,n),e.error&&console.error(` ${e.error.message}`),e.sql&&console.error(` ${e.sql}`);break}}function me(e){let t=t=>e[t]??e.all;return Object.freeze({log(e){try{let n=t(e.level);if(!n)return;let r={level:e.level,timestamp:e.timestamp,duration:e.duration,model:e.model,operation:e.operation,correlationId:e.correlationId,sql:e.sql,params:e.params,error:e.error,meta:e.meta},i=()=>{try{pe(r)}catch{}};n===!0?i():Promise.resolve(n(r,i)).catch(()=>void 0)}catch{}},qy(e){return t(e)!==void 0}})}const he={SpanStatusCode:{OK:1,ERROR:2}},ge=m,M=new WeakSet;function N(e={}){let{tracer:t}=e,n=Object.freeze((e.ignoreSpanTypes??[]).map(e=>typeof e==`string`?e:new RegExp(e.source,e.flags)));function r(e){return!n.some(t=>typeof t==`string`?t===e:new RegExp(t.source,t.flags).test(e))}let i,a,o=t===void 0?import(`@opentelemetry/api`).then(e=>{i=e},()=>{i=null}):void 0;return Object.freeze({traces:r,async startActiveSpan(e,n){if(t!==void 0)return r(e.name)?P(n,he,n=>t.startActiveSpan(e.name,t=>(I(t,e.attributes??{}),n(t)))):n();if(i===void 0&&await o,!(i&&r(e.name)))return n();let s,c;try{let t={...e.attributes},n=i.SpanKind.INTERNAL,r=e.root?i.ROOT_CONTEXT:i.context.active();a??=i.trace.getTracer(`viborm`,ge),s=a.startSpan(e.name,{kind:n,attributes:t},r),c=i.trace.setSpan(r,s)}catch{return n()}let l=i;return P(n,l,e=>l.context.with(c,()=>e(s)),s)}})}function P(e,t,n,r){let i=new Set,a,o,s=(e,n)=>{a=e,o=n;for(let r of i)F(r,e,t,n)},c,l=!1,u=n=>{if(n!==void 0&&(i.add(n),a!==void 0&&F(n,a,t,o)),c)return c;if(l)return Promise.reject(z());l=!0;try{return c=new Promise((t,r)=>{try{Promise.resolve(e(n)).then(e=>{s(!1),t(e)},e=>{s(!0,e),r(e)})}catch(e){s(!0,e),r(e)}}),c}finally{l=!1}};try{Promise.resolve(n(u)).catch(R)}catch{}return u(r)}function F(e,t,n,r){if(!M.has(e)){if(M.add(e),t){let t=r instanceof Error?r:{},i=typeof t.name==`string`?t.name:`Error`,{code:a}=t,o=t.meta?.providerSqlState;I(e,{"error.type":i,...typeof a==`string`&&i!==`Error`?{"viborm.error.code":a}:{},...typeof o==`string`?{"db.response.sqlstate":o}:{}}),L(()=>e.setStatus?.({code:n.SpanStatusCode.ERROR,message:`Operation failed`}));let s=z();s.name=i,L(()=>e.recordException?.(s))}else L(()=>e.setStatus?.({code:n.SpanStatusCode.OK}));L(()=>e.end())}}function I(e,t){for(let[n,r]of Object.entries(t))L(()=>e?.setAttribute(n,r))}function L(e){try{let t=e(),n=typeof t==`object`&&t||typeof t==`function`?Reflect.get(t,`then`):void 0;typeof n==`function`&&Reflect.apply(n,t,[void 0,R])}catch{}}function R(){}function z(){let e=Error(`Operation failed`);return e.stack=void 0,e}function _e({tracing:e,logging:t}){let n=Object.freeze({tracing:e===!0||e===void 0?e:ve(e),logging:t===!0||t===void 0?t:ye(t)});return Object.freeze({config:n,tracer:n.tracing&&N(n.tracing===!0?{}:n.tracing),logger:n.logging&&me(n.logging===!0?{all:!0}:n.logging),l7:new WeakSet})}function ve({includeParams:e,includeSql:t,ignoreSpanTypes:n,tracer:r}){return Object.freeze({includeParams:e===!0,includeSql:t===!0,ignoreSpanTypes:n,tracer:r})}function ye({all:e,cache:t,error:n,query:r,includeParams:i,includeSql:a}){if(e||t||n||r)return Object.freeze({includeParams:i===!0,includeSql:a===!0,all:e,cache:t,error:n,query:r})}const be=/OrThrow$/;function B(e){if(e===void 0)return{};let{dialect:t,driverName:n,namespace:r}=e;return{[k]:t,[O]:n,...r===void 0?{}:{[A]:r}}}function V(e){return e?{[b]:e}:{}}function xe(e){return e.operation?.replace(be,``)}const H=e=>typeof e==`object`&&e?e:void 0,Se=new Set([_,y,g,h,j]),Ce=e=>!Se.has(e.span)||e.span===_&&e.root===!0;function U(e){let t={};for(let[n,r]of Object.entries(e))r!==void 0&&!n.startsWith(`db.query.`)&&(t[n]=r);return t}function we(e,t){return{name:t.span,attributes:U({...B(t.database),...V(f(e)),...t.attributes}),root:t.root===!0}}function W(e,t,n){let{error:i}=n;return{level:t,timestamp:new Date(n.at??Date.now()),model:n.model??e.model,operation:n.operation??xe(e),correlationId:f(e),error:i instanceof Error?r(i):void 0,meta:n.meta===void 0?void 0:fe(n.meta)}}function Te(e){return{name:_,attributes:G(e,o(e))}}function G(e,t){let{operation:n}=e;return{...B(c(e)),...t?{[x]:t}:{},...n?{[C]:n}:{},...V(f(e))}}function Ee(e,t,n,r){let{includeParams:i,includeSql:a}=K(e),o=G(t,t.model);if(a&&n!==void 0&&(o[w]=n),i)for(let[e,t]of(r??[]).entries())o[`${T}.${e}`]=typeof t==`string`?t:String(JSON.stringify(t));return{name:y,attributes:o}}function K(e){return e&&e!==!0?e:{}}function De(e,t){return{name:e,attributes:G(t,t.model)}}function Oe(t){let n=e(t)?t.meta.statementIndex:void 0;return typeof n==`number`?n:void 0}function ke(e,t,n,i,a,o){let c=K(e),l=o===void 0?void 0:Oe(o),u=l===void 0?void 0:p(t)?.[l],d=u?.sql??s(t),m=u===void 0||l===void 0?a:Ae(a,l);return{level:o===void 0?`query`:`error`,timestamp:new Date(n+i),duration:i,model:u===void 0?t.model:u.model,operation:u===void 0?t.operation:u.operation,correlationId:u===void 0?f(t):u.correlation,sql:c.includeSql?d:void 0,params:c.includeParams?[...m??[]]:void 0,error:o===void 0?void 0:r(o,{sql:c.includeSql,parameters:c.includeParams})}}function Ae(e,t){let n=e?.[t];return Array.isArray(n)?n:void 0}const q=`viborm.instrumentation`,J=()=>void 0;function je(e){let r=_e(e),{logging:a,tracing:o}=r.config,{diagnostics:s={}}=e,c=n({sql:s.includeSql,parameters:s.includeParams,providerDetails:s.includeProviderDetails,callsite:s.includeCallsite});return o===void 0&&a===void 0?t(q,c):t(q,i((e,t)=>Y(r,e,t)),c)}function Y(e,t,n){let r,i=()=>(r??=n(),r);return Promise.resolve(Me(e,t,i)).then(J,J).then(()=>r===void 0?i().then(J):void 0)}function X(e,t){return e.tracer?.traces(t)===!0}function Z(e,t){return e.logger?.qy(t)===!0}function Me(e,t,n){switch(t.kind){case`operation`:return Ne(e,t,n);case`statement`:return Pe(e,t,n);case`transaction`:case`savepoint`:case`connection`:return Fe(e,t,n);case`batch`:return;default:return Ie(e,t,n)}}function Q(e,t,n,i,a){let o=e=>{let t=Date.now();return i().then(i=>{if(a?.(i,t,e),i.status===`failure`&&i.recovered!==!0)throw r(u(n))})};return e.tracer&&t?e.tracer.startActiveSpan(t,o):o()}function Ne(e,t,n){return Q(e,X(e,_)?Te(t):void 0,t,n,(n,r)=>{for(let n of a(t)){let r=H(n);r?.log===`cache`&&$(e,t,r)}let i=u(t);n.status===`failure`&&i instanceof Error&&Z(e,`error`)&&!e.l7.has(l(i))&&e.logger?.log({...W(t,`error`,{at:r+n.duration,error:i}),duration:n.duration})})}function Pe(e,t,n){let r=X(e,y),i=Z(e,`query`),a=Z(e,`error`);if(!(r||i||a))return;let{logging:o,tracing:c}=e.config,f=(i||a)&&K(o).includeParams||r&&K(c).includeParams?d(t):void 0,p=Date.now();return Q(e,r?Ee(c,t,s(t),f):void 0,t,n,({duration:n,recovered:r,status:s})=>{let c=u(t),d=s===`failure`&&c instanceof Error;r===!0||!(d?a:s===`success`&&i)||(d&&e.l7.add(l(c)),e.logger?.log(ke(o,t,p,n,f,d?c:void 0)))})}function Fe(e,t,n){let r=t.kind===`connection`?t.operation===`$disconnect`||t.operation===`disconnect`?j:h:g;if(X(e,r))return Q(e,De(r,t),t,n)}function $(e,t,n){n?.log!==void 0&&Z(e,n.log)&&e.logger?.log(W(t,n.log,n))}function Ie(e,t,n){let r=a(t).length,i;for(let n of a(t)){let r=H(n);i===void 0&&r?.span!==void 0&&(i={...r,span:r.span}),$(e,t,r)}return Q(e,i!==void 0&&e.tracer!==void 0&&Ce(i)?we(t,i):void 0,t,n,(n,i,o)=>{for(let n of a(t).slice(r)){let r=H(n);r?.attributes!==void 0&&I(o,U(r.attributes)),$(e,t,r)}})}export{ae as ATTR_CACHE_DRIVER,D as ATTR_CACHE_RESULT,ie as ATTR_CACHE_TTL,re as ATTR_DB_BATCH_SIZE,x as ATTR_DB_COLLECTION,O as ATTR_DB_DRIVER,A as ATTR_DB_NAMESPACE,C as ATTR_DB_OPERATION_NAME,T as ATTR_DB_QUERY_PARAMETER_PREFIX,oe as ATTR_DB_QUERY_SUMMARY,w as ATTR_DB_QUERY_TEXT,ee as ATTR_DB_ROWS_RETURNED,k as ATTR_DB_SYSTEM,E as ATTR_ERROR_TYPE,ne as ATTR_SERVER_ADDRESS,te as ATTR_SERVER_PORT,b as ATTR_VIBORM_CORRELATION_ID,se as SPAN_CACHE_CLEAR,le as SPAN_CACHE_DELETE,S as SPAN_CACHE_GET,ce as SPAN_CACHE_INVALIDATE,v as SPAN_CACHE_SET,h as SPAN_CONNECT,j as SPAN_DISCONNECT,y as SPAN_EXECUTE,_ as SPAN_OPERATION,g as SPAN_TRANSACTION,je as instrumentation};
|
|
2
2
|
//# sourceMappingURL=instrumentation.mjs.map
|