viborm 1.7.0 → 1.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{adapter-namespace-BMss0hKo.mjs → adapter-namespace-VikEzb7o.mjs} +2 -2
- package/dist/{adapter-namespace-BMss0hKo.mjs.map → adapter-namespace-VikEzb7o.mjs.map} +1 -1
- package/dist/adapters.d.mts +1 -1
- package/dist/adapters.mjs +1 -1
- package/dist/{batch-refs-DWMYN0fw.mjs → batch-refs-ZHBzfoBC.mjs} +2 -2
- package/dist/{batch-refs-DWMYN0fw.mjs.map → batch-refs-ZHBzfoBC.mjs.map} +1 -1
- package/dist/{builder-B4n-7I7Q.mjs → builder-CEQ2TIq7.mjs} +2 -2
- package/dist/{builder-B4n-7I7Q.mjs.map → builder-CEQ2TIq7.mjs.map} +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/cloudflare-kv.mjs +1 -1
- package/dist/cache/memory.d.mts +1 -1
- package/dist/cache/memory.mjs +1 -1
- package/dist/cache.d.mts +1 -1
- package/dist/cache.mjs +1 -1
- package/dist/{chain-DVuRxjPO.mjs → chain-DG_4uSjk.mjs} +2 -2
- package/dist/{chain-DVuRxjPO.mjs.map → chain-DG_4uSjk.mjs.map} +1 -1
- package/dist/cli.mjs +1 -1
- package/dist/{client-l7dSOul5.mjs → client-BJuTpcYj.mjs} +20 -20
- package/dist/client-BJuTpcYj.mjs.map +1 -0
- package/dist/client-BpQs13Fn.mjs +2 -0
- package/dist/client-BpQs13Fn.mjs.map +1 -0
- package/dist/{client-7ApJka0M.d.mts → client-CrBKhXo-.d.mts} +2 -2
- package/dist/client.d.mts +1 -1
- package/dist/client.mjs +1 -1
- package/dist/config.d.mts +1 -1
- package/dist/config.mjs +1 -1
- package/dist/d1.d.mts +1 -1
- package/dist/d1.mjs +1 -1
- package/dist/{datetime-physical-codec-DTdvABny.mjs → datetime-physical-codec-Cdgq6sGs.mjs} +2 -2
- package/dist/{datetime-physical-codec-DTdvABny.mjs.map → datetime-physical-codec-Cdgq6sGs.mjs.map} +1 -1
- package/dist/{driver-DaBNytbz.mjs → driver-DX8GWgGf.mjs} +2 -2
- package/dist/{driver-DaBNytbz.mjs.map → driver-DX8GWgGf.mjs.map} +1 -1
- package/dist/{driver-CK_IKqDa.mjs → driver-XlmOJFRH.mjs} +2 -2
- package/dist/{driver-CK_IKqDa.mjs.map → driver-XlmOJFRH.mjs.map} +1 -1
- package/dist/driver.d.mts +1 -1
- package/dist/driver.mjs +1 -1
- package/dist/every-CyllpuCG.mjs +2 -0
- package/dist/{every-6VrIclsx.mjs.map → every-CyllpuCG.mjs.map} +1 -1
- package/dist/{geo-area-codec-DvHcWF3g.mjs → geo-area-codec-B3QtKij8.mjs} +2 -2
- package/dist/{geo-area-codec-DvHcWF3g.mjs.map → geo-area-codec-B3QtKij8.mjs.map} +1 -1
- package/dist/{geo-point-codec-CIZxuIvE.mjs → geo-point-codec-Ggv29hSH.mjs} +2 -2
- package/dist/{geo-point-codec-CIZxuIvE.mjs.map → geo-point-codec-Ggv29hSH.mjs.map} +1 -1
- package/dist/{hydration-BUBkHlCK.mjs → hydration-Dd2H4EyY.mjs} +2 -2
- package/dist/{hydration-BUBkHlCK.mjs.map → hydration-Dd2H4EyY.mjs.map} +1 -1
- package/dist/{identifier-conversion-BXrBYgAq.mjs → identifier-conversion-BVE8cfFA.mjs} +2 -2
- package/dist/{identifier-conversion-BXrBYgAq.mjs.map → identifier-conversion-BVE8cfFA.mjs.map} +1 -1
- package/dist/{index-CsO6vG2h.d.mts → index-BlBkgxtx.d.mts} +82 -8
- package/dist/index.d.mts +3 -3
- package/dist/index.mjs +1 -1
- package/dist/instrumentation.d.mts +1 -1
- package/dist/instrumentation.mjs +1 -1
- package/dist/{key-Cz83fdLO.mjs → key-B4B1etH3.mjs} +2 -2
- package/dist/{key-Cz83fdLO.mjs.map → key-B4B1etH3.mjs.map} +1 -1
- package/dist/{keys-EP1Eq2eD.mjs → keys-CyfjT6uC.mjs} +2 -2
- package/dist/{keys-EP1Eq2eD.mjs.map → keys-CyfjT6uC.mjs.map} +1 -1
- package/dist/{libsql-ClGi2zY2.mjs → libsql-CcKrXiun.mjs} +2 -2
- package/dist/{libsql-ClGi2zY2.mjs.map → libsql-CcKrXiun.mjs.map} +1 -1
- package/dist/libsql.d.mts +1 -1
- package/dist/libsql.mjs +1 -1
- package/dist/{memory-B1GnzgZr.mjs → memory-B0HOEpPu.mjs} +2 -2
- package/dist/{memory-B1GnzgZr.mjs.map → memory-B0HOEpPu.mjs.map} +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/sqlite.d.mts +4 -4
- package/dist/migrations/sqlite.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/{model-DsXZ_pHE.mjs → model-u8Ug971J.mjs} +2 -2
- package/dist/{model-DsXZ_pHE.mjs.map → model-u8Ug971J.mjs.map} +1 -1
- package/dist/{mysql-adapter-D-Dq2FN9.mjs → mysql-adapter-CWisQgdc.mjs} +2 -2
- package/dist/{mysql-adapter-D-Dq2FN9.mjs.map → mysql-adapter-CWisQgdc.mjs.map} +1 -1
- package/dist/{mysql-hoo290Dd.mjs → mysql-sGTzkV2q.mjs} +2 -2
- package/dist/{mysql-hoo290Dd.mjs.map → mysql-sGTzkV2q.mjs.map} +1 -1
- package/dist/mysql2.d.mts +1 -1
- package/dist/mysql2.mjs +1 -1
- package/dist/neon-http.d.mts +1 -1
- package/dist/neon-http.mjs +1 -1
- package/dist/{normalized-result-23DWxZVY.mjs → normalized-result-ByvlIQqa.mjs} +2 -2
- package/dist/{normalized-result-23DWxZVY.mjs.map → normalized-result-ByvlIQqa.mjs.map} +1 -1
- package/dist/{object-store-9VfS-3sY.d.mts → object-store-C-VOh0LP.d.mts} +3 -3
- package/dist/on.d.mts +1 -1
- package/dist/ordering.d.mts +55 -19
- package/dist/ordering.mjs +8 -8
- package/dist/ordering.mjs.map +1 -1
- package/dist/permissions.d.mts +22 -3
- package/dist/permissions.mjs +1 -1
- package/dist/permissions.mjs.map +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/{physical-t_gDjUCD.mjs → physical-CjG29tya.mjs} +2 -2
- package/dist/{physical-t_gDjUCD.mjs.map → physical-CjG29tya.mjs.map} +1 -1
- package/dist/planetscale.d.mts +1 -1
- package/dist/planetscale.mjs +1 -1
- package/dist/{planner-Cc3ABIUU.d.mts → planner-syQCWHHr.d.mts} +1 -1
- package/dist/{postgres-CqcP_qv-.mjs → postgres-C2uUUh0t.mjs} +2 -2
- package/dist/{postgres-CqcP_qv-.mjs.map → postgres-C2uUUh0t.mjs.map} +1 -1
- package/dist/{postgres-adapter-CYZAL2uo.mjs → postgres-adapter-CdUHI_lw.mjs} +2 -2
- package/dist/{postgres-adapter-CYZAL2uo.mjs.map → postgres-adapter-CdUHI_lw.mjs.map} +1 -1
- package/dist/{postgres-adapter-_o6EWuxW.mjs → postgres-adapter-D4v50VQk.mjs} +2 -2
- package/dist/{postgres-adapter-_o6EWuxW.mjs.map → postgres-adapter-D4v50VQk.mjs.map} +1 -1
- package/dist/{postgres-result-D94PyZ78.mjs → postgres-result-ehQiy2H-.mjs} +2 -2
- package/dist/{postgres-result-D94PyZ78.mjs.map → postgres-result-ehQiy2H-.mjs.map} +1 -1
- package/dist/postgres.d.mts +1 -1
- package/dist/postgres.mjs +1 -1
- package/dist/{provider-limits-kO9B3KCF.mjs → provider-limits-DolYOv3_.mjs} +2 -2
- package/dist/{provider-limits-kO9B3KCF.mjs.map → provider-limits-DolYOv3_.mjs.map} +1 -1
- package/dist/{result-shape-uaCsF_SZ.mjs → result-shape-dG_6HE7s.mjs} +2 -2
- package/dist/{result-shape-uaCsF_SZ.mjs.map → result-shape-dG_6HE7s.mjs.map} +1 -1
- package/dist/{rows-AtX0guAb.mjs → rows-CEYfrodD.mjs} +2 -2
- package/dist/rows-CEYfrodD.mjs.map +1 -0
- package/dist/rows-of-Djavcb19.mjs +2 -0
- package/dist/rows-of-Djavcb19.mjs.map +1 -0
- package/dist/{scalar-CZ_q89Hc.mjs → scalar-DNshDNz3.mjs} +2 -2
- package/dist/{scalar-CZ_q89Hc.mjs.map → scalar-DNshDNz3.mjs.map} +1 -1
- package/dist/schema/json.d.mts +1 -1
- package/dist/schema/json.mjs +1 -1
- package/dist/schema-DYPfTOQl.mjs +2 -0
- package/dist/{schema-CZTCxG2p.mjs.map → schema-DYPfTOQl.mjs.map} +1 -1
- package/dist/{schema-introspection-DoZHc1o7.mjs → schema-introspection-Bu2N__75.mjs} +2 -2
- package/dist/{schema-introspection-DoZHc1o7.mjs.map → schema-introspection-Bu2N__75.mjs.map} +1 -1
- package/dist/schema.d.mts +1 -1
- package/dist/schema.mjs +1 -1
- package/dist/{select-assembly-BtNtBsUh.mjs → select-assembly-Dcaqm09G.mjs} +2 -2
- package/dist/{select-assembly-BtNtBsUh.mjs.map → select-assembly-Dcaqm09G.mjs.map} +1 -1
- package/dist/soft-delete.d.mts +116 -14
- package/dist/soft-delete.mjs +1 -1
- package/dist/soft-delete.mjs.map +1 -1
- package/dist/sql-BsBoKwaf.mjs +2 -0
- package/dist/sql-BsBoKwaf.mjs.map +1 -0
- package/dist/{sql-BnXk8adi.d.mts → sql-D7JnXgUh.d.mts} +5 -0
- package/dist/sql.d.mts +1 -1
- package/dist/sql.mjs +1 -1
- package/dist/{sqlite-adapter-CnAwmszh.mjs → sqlite-adapter-BHx--tnz.mjs} +2 -2
- package/dist/{sqlite-adapter-CnAwmszh.mjs.map → sqlite-adapter-BHx--tnz.mjs.map} +1 -1
- package/dist/sqlite3.d.mts +1 -1
- package/dist/sqlite3.mjs +1 -1
- package/dist/{standard-sql-Ci8ROrql.mjs → standard-sql-BtzSzrof.mjs} +2 -2
- package/dist/standard-sql-BtzSzrof.mjs.map +1 -0
- package/dist/{to-many-BtLpp5cW.mjs → to-many-5gt2AWLE.mjs} +2 -2
- package/dist/{to-many-BtLpp5cW.mjs.map → to-many-5gt2AWLE.mjs.map} +1 -1
- package/dist/{utils-CAACs9Jw.mjs → utils-CmNRGkRq.mjs} +2 -2
- package/dist/{utils-CAACs9Jw.mjs.map → utils-CmNRGkRq.mjs.map} +1 -1
- package/dist/{v-Pb_jJOjC.mjs → v-CWY9ntMb.mjs} +2 -2
- package/dist/{v-Pb_jJOjC.mjs.map → v-CWY9ntMb.mjs.map} +1 -1
- package/dist/{validation-BSpO4DjI.mjs → validation-CMvAxrIo.mjs} +2 -2
- package/dist/{validation-BSpO4DjI.mjs.map → validation-CMvAxrIo.mjs.map} +1 -1
- package/dist/validation.d.mts +1 -1
- package/dist/validation.mjs +1 -1
- package/dist/{validator-Dthaj1Hz.mjs → validator-CYKdGTvX.mjs} +2 -2
- package/dist/{validator-Dthaj1Hz.mjs.map → validator-CYKdGTvX.mjs.map} +1 -1
- package/dist/version-B7NRPl4T.mjs +2 -0
- package/dist/{version-DvynkoaW.mjs.map → version-B7NRPl4T.mjs.map} +1 -1
- package/package.json +23 -23
- package/dist/client-Yqn0LqmI.mjs +0 -2
- package/dist/client-Yqn0LqmI.mjs.map +0 -1
- package/dist/client-l7dSOul5.mjs.map +0 -1
- package/dist/every-6VrIclsx.mjs +0 -2
- package/dist/insert-value-Cbp_bNxj.mjs +0 -2
- package/dist/insert-value-Cbp_bNxj.mjs.map +0 -1
- package/dist/rows-AtX0guAb.mjs.map +0 -1
- package/dist/schema-CZTCxG2p.mjs +0 -2
- package/dist/sql-DGtEeP8z.mjs +0 -2
- package/dist/sql-DGtEeP8z.mjs.map +0 -1
- package/dist/standard-sql-Ci8ROrql.mjs.map +0 -1
- package/dist/version-DvynkoaW.mjs +0 -2
package/dist/libsql.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { A as Schema,
|
|
1
|
+
import { A as Schema, F as LinkedClientConfig, Ft as NoExtraDriverConfigKeys, It as VibORMClient, Nn as DriverTransactionOptions, Pn as TransactionOptionSupport, Rn as QueryExecutionContext, h as DriverResultParser, jt as DriverConfig, s as DatabaseAdapter, u as Driver, zn as QueryResult } from "./index-BlBkgxtx.mjs";
|
|
2
2
|
import { Client, Config, Transaction } from "@libsql/client";
|
|
3
3
|
|
|
4
4
|
//#region src/drivers/libsql/index.d.ts
|
package/dist/libsql.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{n as e}from"./chunk-BuuaeEvq.mjs";import{o as t}from"./normalized-result-
|
|
1
|
+
import{n as e}from"./chunk-BuuaeEvq.mjs";import{o as t}from"./normalized-result-ByvlIQqa.mjs";import{l as n}from"./execution-context-_oajgBi4.mjs";import{n as r}from"./base-wlv81COV.mjs";import{m as i,u as a}from"./error-mapping-D--MVRCY.mjs";import{n as o}from"./query-CTna5P9o.mjs";import{n as s}from"./client-BpQs13Fn.mjs";import{c,i as l,r as u,t as d}from"./driver-XlmOJFRH.mjs";import{c as f,i as p,l as m,n as h}from"./sqlite-utils-DztTzv08.mjs";import{t as g}from"./sqlite-adapter-BHx--tnz.mjs";const _=new WeakSet,v={client:!0,databaseUrl:!0,dataDir:!0,authToken:!0,options:!0};function convertValuesForLibSQL(e){return e.map(e=>{let t=h(e);if(typeof t==`string`&&t.includes(`\0`))throw TypeError(`libSQL cannot preserve strings containing NUL bytes`);if(p(t))return t instanceof ArrayBuffer?t:f(t);if(t===null||typeof t==`string`||typeof t==`number`||typeof t==`bigint`||typeof t==`boolean`||t instanceof Date)return t;throw TypeError(`Driver "libsql" received an unsupported SQLite parameter value.`)})}const libsqlRowCount=(e,n)=>{let r=t(e.rowsAffected,{provider:`libsql`,operation:n});return e.rows.length>0?e.rows.length:r};var LibSQLDriver=class extends d{adapter=new g;maxBindParametersPerStatement=32766;result=m;serializeTransactions;driverOptions;suppliedClient;constructor(e={}){if(super(`sqlite`,`libsql`),this.driverOptions=e,this.suppliedClient=e.client,this.suppliedClient)this.serializeTransactions=this.suppliedClient.protocol===`file`;else{let e=this.getDatabaseUrl();this.serializeTransactions=e===`:memory:`||e.startsWith(`file:`)}this.suppliedClient&&(this.client=this.suppliedClient,this.serializeTransactions&&Object.defineProperty(this,`connectionQueue`,{value:u(this.suppliedClient)}))}async initClient(){if(this.suppliedClient)return this.suppliedClient;let{createClient:e}=await import(`@libsql/client`),t=this.getDatabaseUrl(),n=this.driverOptions.authToken;return e({url:t,authToken:n,timeout:5e3,...this.driverOptions.options??{},intMode:`bigint`})}async closeClient(e){e!==this.suppliedClient&&`close`in e&&(e.close(),`commit`in e||_.delete(e))}async execute(e,t,n,r){let i=r?.operation??`execute`,a=convertValuesForLibSQL(n),o=await this.executeStatement(e,{sql:t,args:a});return{rows:o.rows,rowCount:libsqlRowCount(o,i)}}async executeRaw(e,t,n,r){let i=r?.operation??`executeRaw`,a=n?convertValuesForLibSQL(n):[],o=await this.executeStatement(e,{sql:t,args:a});return{rows:o.rows,rowCount:libsqlRowCount(o,i)}}transactionOptionSupport(){return{isolationLevel:`serializable-only`,isolationLevelReason:`libSQL serializes writers the way SQLite does and has no statement to weaken isolation, so only Serializable can be honored truthfully`,timeout:!0,maxWait:this.serializeTransactions?`queue`:`acquisition`}}async transaction(e,t,r,o){if(`commit`in e)throw a(this.driverName);let s=await l(()=>this.quarantineOnBusy(e,()=>e.transaction(`write`)),e=>e.close(),o?.maxWaitMs,{driverName:this.driverName,form:`callback`});return i({begin:()=>void 0,callback:()=>t(s),commit:()=>s.commit(),rollback:()=>s.rollback(),phases:n(r),close:()=>s.close()})}transactionCleanupFailed(e){}executeStatement(e,t){return this.quarantineOnBusy(e,()=>e.execute(t))}async quarantineOnBusy(e,t){try{return await t()}catch(t){throw this.serializeTransactions&&!(`commit`in e)&&typeof t==`object`&&t&&`code`in t&&typeof t.code==`string`&&(t.code===`SQLITE_BUSY`||t.code.startsWith(`SQLITE_BUSY_`))&&(_.add(e),this.closeRetryClient=e,this.client=null,this.initPromise=null),t}}async getClient(e){let t=await super.getClient(e);return this.assertLocalClientUsable(t),t}assertLocalClientUsable(e){if(!(`commit`in e)&&_.has(e))throw new o(`Local libSQL execution encountered SQLITE_BUSY; disconnect an owned driver, or close and replace the supplied native client, before reuse.`,{code:r.CONNECTION_CLOSED,meta:{driver:`libsql`}})}getDatabaseUrl(){return this.driverOptions.databaseUrl?this.driverOptions.databaseUrl:this.driverOptions.dataDir?`file:${this.driverOptions.dataDir}`:`file::memory:`}};function createClient(e){c(e,`libsql`,v);let{client:t,databaseUrl:n,dataDir:r,authToken:i,options:a}=e;return s(e,new LibSQLDriver({client:t,databaseUrl:n,dataDir:r,authToken:i,options:a}))}export{LibSQLDriver,createClient};
|
|
2
2
|
//# sourceMappingURL=libsql.mjs.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{n as e}from"./chunk-BuuaeEvq.mjs";import{n as t}from"./base-wlv81COV.mjs";import{t as n}from"./migrations-OE5D32qo.mjs";import{D as r}from"./client-
|
|
2
|
-
//# sourceMappingURL=memory-
|
|
1
|
+
import{n as e}from"./chunk-BuuaeEvq.mjs";import{n as t}from"./base-wlv81COV.mjs";import{t as n}from"./migrations-OE5D32qo.mjs";import{D as r}from"./client-BJuTpcYj.mjs";import{n as i}from"./canonical-json-B6J5VbLv.mjs";import{a,c as o}from"./identity-BtuwgqhS.mjs";const isCorruption=e=>e instanceof n&&e.code===t.MIGRATION_CORRUPTION;function createStorageConformanceSuite(e){return[{name:`identical content-addressed publish is idempotent`,run:async()=>{let t=e(),n=o(`hello`),i=r(n),a=await t.publishSql(i,n),s=await t.publishSql(i,n);if(a.outcome!==`created`||s.outcome!==`identical`)throw Error(`idempotent publish failed`)}},{name:`same hash with different bytes is corruption`,run:async()=>{let t=e(),n=o(`hello`),i=r(n);await t.publishSql(i,n);try{await t.publishSql(i,o(`other`))}catch(e){if(isCorruption(e))return}throw Error(`corrupt publish was accepted`)}},{name:`listStates returns only committed manifests`,run:async()=>{if((await e().listStates()).length!==0)throw Error(`fresh writer is not empty`)}},{name:`estate publish is idempotent for identical bytes`,run:async()=>{let t=e(),n=o(`{"format":"1"}`),r=await t.publishEstate(n),i=await t.publishEstate(n);if(r.outcome!==`created`||i.outcome!==`identical`)throw Error(`estate idempotent publish failed`)}},{name:`concurrent identical creates report created exactly once`,run:async()=>{let t=e(),n=o(`race-identical`),i=r(n),a=(await Promise.all(Array.from({length:8},()=>t.publishState(i,n)))).filter(e=>e.outcome===`created`).length;if(a!==1)throw Error(`${a} of 8 concurrent creates won`)}},{name:`concurrent conflicting creates keep one winner and refuse the rest`,run:async()=>{let t=e(),n=r(o(`race-conflicting`)),a=Array.from({length:8},(e,t)=>o(`{"racer":${t}}`)),s=await Promise.allSettled(a.map(e=>t.publishState(n,e))),c=a.filter((e,t)=>s[t]?.status===`fulfilled`),l=s.filter(e=>e.status===`rejected`&&isCorruption(e.reason)).length,u=await t.readState(n);if(c.length!==1||l!==7||!(u&&i(u,c[0])))throw Error(`${c.length} winners and ${l} refusals of 8 conflicting creates`)}},{name:`absent artifacts read as null`,run:async()=>{let t=e(),n=r(o(`absent`));if((await Promise.all([t.readState(n),t.readSnapshot(n),t.readSql(n)])).some(e=>e!==null))throw Error(`an absent artifact read as bytes`)}},{name:`published artifacts are listed as soon as publish returns`,run:async()=>{let t=e(),n=Array.from({length:5},(e,t)=>o(`listed-${t}`)),i=n.map(r);for(let[e,r]of i.entries())await t.publishState(r,n[e]),await t.publishSnapshot(r,n[e]),await t.publishSql(r,n[e]);if((await Promise.all([t.listStates(),t.listSnapshots(),t.listSql()])).some(e=>i.some(t=>!e.includes(t))))throw Error(`a published artifact is missing from its listing`)}},{name:`a listed state's snapshot and SQL are already readable (manifest last)`,run:async()=>{let t=e(),n=o(`manifest-last`),i=r(n),a=!1,s=(async()=>{await t.publishSnapshot(i,n),await t.publishSql(i,n),await t.publishState(i,n)})().finally(()=>{a=!0});try{for(;;){let e=a;if((await t.listStates()).includes(i))break;if(e)throw Error(`a published state is not listed`)}let[e,n]=await Promise.all([t.readSnapshot(i),t.readSql(i)]);if(!(e&&n))throw Error(`a listed state's artifacts are not readable yet`)}finally{await s}}}]}var MemoryEstateStorage=class{estate=null;states=new Map;snapshots=new Map;sql=new Map;async readEstate(){return this.estate?this.estate.slice():null}async listStates(){return[...this.states.keys()].sort()}async listSnapshots(){return[...this.snapshots.keys()].sort()}async listSql(){return[...this.sql.keys()].sort()}async readState(e){let t=this.states.get(e);return t?t.slice():null}async readSnapshot(e){let t=this.snapshots.get(e);return t?t.slice():null}async readSql(e){let t=this.sql.get(e);return t?t.slice():null}async publishEstate(e){if(this.estate&&!i(this.estate,e))throw new n(`estate.json already exists with different bytes`,t.MIGRATION_CORRUPTION);return this.estate?{outcome:`identical`}:(this.estate=e.slice(),{outcome:`created`})}async publishSnapshot(e,t){return publishMap(this.snapshots,e,t,`snapshot`)}async publishSql(e,t){return publishMap(this.sql,e,t,`sql`)}async publishState(e,r){if(!a(e))throw new n(`State id is not a SHA-256 digest`,t.MIGRATION_INVALID_ESTATE);return publishMap(this.states,e,r,`state`)}};function publishMap(e,r,a,o){let s=e.get(r);if(s){if(!i(s,a))throw new n(`${o} ${r} already holds different bytes`,t.MIGRATION_CORRUPTION);return{outcome:`identical`}}return e.set(r,a.slice()),{outcome:`created`}}export{createStorageConformanceSuite as n,MemoryEstateStorage as t};
|
|
2
|
+
//# sourceMappingURL=memory-B0HOEpPu.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"memory-B1GnzgZr.mjs","names":[],"sources":["../src/migrations/storage/conformance.ts","../src/migrations/storage/memory.ts"],"sourcesContent":["/**\n * Reusable storage conformance suite. A writable driver that cannot pass\n * these tests is not a V1 estate owner.\n */\n\nimport { MigrationError, VibORMErrorCode } from \"../../errors\";\nimport { bytesEqual } from \"../canonical-json\";\nimport { utf8Bytes } from \"../identity\";\nimport { encodeSqlBlob } from \"../v1-parse\";\nimport type { MigrationStorageWriter } from \"./contract\";\n\nconst RACERS = 8;\nconst LISTED = 5;\n\nconst isCorruption = (error: unknown): boolean =>\n error instanceof MigrationError &&\n error.code === VibORMErrorCode.MIGRATION_CORRUPTION;\n\nexport function createStorageConformanceSuite(\n createWriter: () => MigrationStorageWriter\n): { readonly name: string; readonly run: () => Promise<void> }[] {\n return [\n {\n name: \"identical content-addressed publish is idempotent\",\n run: async () => {\n const storage = createWriter();\n const bytes = utf8Bytes(\"hello\");\n const hash = encodeSqlBlob(bytes);\n const first = await storage.publishSql(hash, bytes);\n const second = await storage.publishSql(hash, bytes);\n if (first.outcome !== \"created\" || second.outcome !== \"identical\") {\n throw new Error(\"idempotent publish failed\");\n }\n },\n },\n {\n name: \"same hash with different bytes is corruption\",\n run: async () => {\n const storage = createWriter();\n const bytes = utf8Bytes(\"hello\");\n const hash = encodeSqlBlob(bytes);\n await storage.publishSql(hash, bytes);\n try {\n await storage.publishSql(hash, utf8Bytes(\"other\"));\n } catch (error) {\n if (isCorruption(error)) return;\n }\n throw new Error(\"corrupt publish was accepted\");\n },\n },\n {\n name: \"listStates returns only committed manifests\",\n run: async () => {\n const storage = createWriter();\n const listed = await storage.listStates();\n if (listed.length !== 0) throw new Error(\"fresh writer is not empty\");\n },\n },\n {\n name: \"estate publish is idempotent for identical bytes\",\n run: async () => {\n const storage = createWriter();\n const bytes = utf8Bytes('{\"format\":\"1\"}');\n const first = await storage.publishEstate(bytes);\n const second = await storage.publishEstate(bytes);\n if (first.outcome !== \"created\" || second.outcome !== \"identical\") {\n throw new Error(\"estate idempotent publish failed\");\n }\n },\n },\n {\n name: \"concurrent identical creates report created exactly once\",\n run: async () => {\n const storage = createWriter();\n const bytes = utf8Bytes(\"race-identical\");\n const id = encodeSqlBlob(bytes);\n const outcomes = await Promise.all(\n Array.from({ length: RACERS }, () => storage.publishState(id, bytes))\n );\n const created = outcomes.filter((o) => o.outcome === \"created\").length;\n if (created !== 1) {\n throw new Error(`${created} of ${RACERS} concurrent creates won`);\n }\n },\n },\n {\n name: \"concurrent conflicting creates keep one winner and refuse the rest\",\n run: async () => {\n const storage = createWriter();\n const id = encodeSqlBlob(utf8Bytes(\"race-conflicting\"));\n const candidates = Array.from({ length: RACERS }, (_, n) =>\n utf8Bytes(`{\"racer\":${n}}`)\n );\n const settled = await Promise.allSettled(\n candidates.map((bytes) => storage.publishState(id, bytes))\n );\n const winners = candidates.filter(\n (_, n) => settled[n]?.status === \"fulfilled\"\n );\n const refused = settled.filter(\n (result) =>\n result.status === \"rejected\" && isCorruption(result.reason)\n ).length;\n const stored = await storage.readState(id);\n if (\n winners.length !== 1 ||\n refused !== RACERS - 1 ||\n !(stored && bytesEqual(stored, winners[0]!))\n ) {\n throw new Error(\n `${winners.length} winners and ${refused} refusals of ${RACERS} conflicting creates`\n );\n }\n },\n },\n {\n name: \"absent artifacts read as null\",\n run: async () => {\n const storage = createWriter();\n const id = encodeSqlBlob(utf8Bytes(\"absent\"));\n const reads = await Promise.all([\n storage.readState(id),\n storage.readSnapshot(id),\n storage.readSql(id),\n ]);\n if (reads.some((bytes) => bytes !== null)) {\n throw new Error(\"an absent artifact read as bytes\");\n }\n },\n },\n {\n name: \"published artifacts are listed as soon as publish returns\",\n run: async () => {\n const storage = createWriter();\n const artifacts = Array.from({ length: LISTED }, (_, n) =>\n utf8Bytes(`listed-${n}`)\n );\n const ids = artifacts.map(encodeSqlBlob);\n for (const [n, id] of ids.entries()) {\n await storage.publishState(id, artifacts[n]!);\n await storage.publishSnapshot(id, artifacts[n]!);\n await storage.publishSql(id, artifacts[n]!);\n }\n const listings = await Promise.all([\n storage.listStates(),\n storage.listSnapshots(),\n storage.listSql(),\n ]);\n if (listings.some((listed) => ids.some((id) => !listed.includes(id)))) {\n throw new Error(\"a published artifact is missing from its listing\");\n }\n },\n },\n {\n name: \"a listed state's snapshot and SQL are already readable (manifest last)\",\n run: async () => {\n const storage = createWriter();\n const bytes = utf8Bytes(\"manifest-last\");\n const hash = encodeSqlBlob(bytes);\n let published = false;\n const publishing = (async () => {\n await storage.publishSnapshot(hash, bytes);\n await storage.publishSql(hash, bytes);\n await storage.publishState(hash, bytes);\n })().finally(() => {\n published = true;\n });\n try {\n for (;;) {\n const settled = published;\n if ((await storage.listStates()).includes(hash)) break;\n if (settled) throw new Error(\"a published state is not listed\");\n }\n const [snapshot, sql] = await Promise.all([\n storage.readSnapshot(hash),\n storage.readSql(hash),\n ]);\n if (!(snapshot && sql)) {\n throw new Error(\"a listed state's artifacts are not readable yet\");\n }\n } finally {\n await publishing;\n }\n },\n },\n ];\n}\n","/**\n * In-memory estate writer for tests and conformance.\n * Conditional create: same hash + same bytes is identical; different bytes is corruption.\n */\n\nimport { MigrationError, VibORMErrorCode } from \"../../errors\";\nimport { bytesEqual } from \"../canonical-json\";\nimport { isSha256, type Sha256 } from \"../identity\";\nimport type { MigrationStorageWriter, PublishResult } from \"./contract\";\n\nexport class MemoryEstateStorage implements MigrationStorageWriter {\n private estate: Uint8Array | null = null;\n private readonly states = new Map<Sha256, Uint8Array>();\n private readonly snapshots = new Map<Sha256, Uint8Array>();\n private readonly sql = new Map<Sha256, Uint8Array>();\n\n async readEstate(): Promise<Uint8Array | null> {\n return this.estate ? this.estate.slice() : null;\n }\n\n async listStates(): Promise<readonly Sha256[]> {\n return [...this.states.keys()].sort();\n }\n\n async listSnapshots(): Promise<readonly Sha256[]> {\n return [...this.snapshots.keys()].sort();\n }\n\n async listSql(): Promise<readonly Sha256[]> {\n return [...this.sql.keys()].sort();\n }\n\n async readState(id: Sha256): Promise<Uint8Array | null> {\n const bytes = this.states.get(id);\n return bytes ? bytes.slice() : null;\n }\n\n async readSnapshot(hash: Sha256): Promise<Uint8Array | null> {\n const bytes = this.snapshots.get(hash);\n return bytes ? bytes.slice() : null;\n }\n\n async readSql(hash: Sha256): Promise<Uint8Array | null> {\n const bytes = this.sql.get(hash);\n return bytes ? bytes.slice() : null;\n }\n\n async publishEstate(bytes: Uint8Array): Promise<PublishResult> {\n if (this.estate && !bytesEqual(this.estate, bytes)) {\n throw new MigrationError(\n \"estate.json already exists with different bytes\",\n VibORMErrorCode.MIGRATION_CORRUPTION\n );\n }\n if (this.estate) return { outcome: \"identical\" };\n this.estate = bytes.slice();\n return { outcome: \"created\" };\n }\n\n async publishSnapshot(\n hash: Sha256,\n bytes: Uint8Array\n ): Promise<PublishResult> {\n return publishMap(this.snapshots, hash, bytes, \"snapshot\");\n }\n\n async publishSql(hash: Sha256, bytes: Uint8Array): Promise<PublishResult> {\n return publishMap(this.sql, hash, bytes, \"sql\");\n }\n\n async publishState(id: Sha256, bytes: Uint8Array): Promise<PublishResult> {\n if (!isSha256(id)) {\n throw new MigrationError(\n \"State id is not a SHA-256 digest\",\n VibORMErrorCode.MIGRATION_INVALID_ESTATE\n );\n }\n return publishMap(this.states, id, bytes, \"state\");\n }\n}\n\nfunction publishMap(\n store: Map<Sha256, Uint8Array>,\n key: Sha256,\n bytes: Uint8Array,\n label: string\n): PublishResult {\n const existing = store.get(key);\n if (existing) {\n if (!bytesEqual(existing, bytes)) {\n throw new MigrationError(\n `${label} ${key} already holds different bytes`,\n VibORMErrorCode.MIGRATION_CORRUPTION\n );\n }\n return { outcome: \"identical\" };\n }\n store.set(key, bytes.slice());\n return { outcome: \"created\" };\n}\n"],"mappings":"yQAWA,MAGM,aAAgB,GACpB,aAAiB,GACjB,EAAM,OAAS,EAAgB,qBAEjC,SAAgB,8BACd,EACgE,CAChE,MAAO,CACL,CACE,KAAM,oDACN,IAAK,SAAY,CACf,IAAM,EAAU,GAAc,CACxB,EAAQ,EAAU,QAAQ,CAC1B,EAAO,EAAc,EAAM,CAC3B,EAAQ,MAAM,EAAQ,WAAW,EAA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AAM,EAAQ,KAAK,UAAU,IAAI,EAAK,CACtC,OAAO,EAAQ,EAAM,OAAO,CAAG,KAGjC,MAAM,QAAQ,EAA0C,CACtD,IAAM,EAAQ,KAAK,IAAI,IAAI,EAAK,CAChC,OAAO,EAAQ,EAAM,OAAO,CAAG,KAGjC,MAAM,cAAc,EAA2C,CAC7D,GAAI,KAAK,QAAU,CAAC,EAAW,KAAK,OAAQ,EAAM,CAChD,MAAM,IAAI,EACR,kDACA,EAAgB,qBACjB,CAIH,OAFI,KAAK,OAAe,CAAE,QAAS,YAAa,EAChD,KAAK,OAAS,EAAM,OAAO,CACpB,CAAE,QAAS,UAAW,EAG/B,MAAM,gBACJ,EACA,EACwB,CACxB,OAAO,WAAW,KAAK,UAAW,EAAM,EAAO,WAAW,CAG5D,MAAM,WAAW,EAAc,EAA2C,CACxE,OAAO,WAAW,KAAK,IAAK,EAAM,EAAO,MAAM,CAGjD,MAAM,aAAa,EAAY,EAA2C,CACxE,GAAI,CAAC,EAAS,EAAG,CACf,MAAM,IAAI,EACR,mCACA,EAAgB,yBACjB,CAEH,OAAO,WAAW,KAAK,OAAQ,EAAI,EAAO,QAAQ,GAItD,SAAS,WACP,EACA,EACA,EACA,EACe,CACf,IAAM,EAAW,EAAM,IAAI,EAAI,CAC/B,GAAI,EAAU,CACZ,GAAI,CAAC,EAAW,EAAU,EAAM,CAC9B,MAAM,IAAI,EACR,GAAG,EAAM,GAAG,EAAI,gCAChB,EAAgB,qBACjB,CAEH,MAAO,CAAE,QAAS,YAAa,CAGjC,OADA,EAAM,IAAI,EAAK,EAAM,OAAO,CAAC,CACtB,CAAE,QAAS,UAAW"}
|
|
1
|
+
{"version":3,"file":"memory-B0HOEpPu.mjs","names":[],"sources":["../src/migrations/storage/conformance.ts","../src/migrations/storage/memory.ts"],"sourcesContent":["/**\n * Reusable storage conformance suite. A writable driver that cannot pass\n * these tests is not a V1 estate owner.\n */\n\nimport { MigrationError, VibORMErrorCode } from \"../../errors\";\nimport { bytesEqual } from \"../canonical-json\";\nimport { utf8Bytes } from \"../identity\";\nimport { encodeSqlBlob } from \"../v1-parse\";\nimport type { MigrationStorageWriter } from \"./contract\";\n\nconst RACERS = 8;\nconst LISTED = 5;\n\nconst isCorruption = (error: unknown): boolean =>\n error instanceof MigrationError &&\n error.code === VibORMErrorCode.MIGRATION_CORRUPTION;\n\nexport function createStorageConformanceSuite(\n createWriter: () => MigrationStorageWriter\n): { readonly name: string; readonly run: () => Promise<void> }[] {\n return [\n {\n name: \"identical content-addressed publish is idempotent\",\n run: async () => {\n const storage = createWriter();\n const bytes = utf8Bytes(\"hello\");\n const hash = encodeSqlBlob(bytes);\n const first = await storage.publishSql(hash, bytes);\n const second = await storage.publishSql(hash, bytes);\n if (first.outcome !== \"created\" || second.outcome !== \"identical\") {\n throw new Error(\"idempotent publish failed\");\n }\n },\n },\n {\n name: \"same hash with different bytes is corruption\",\n run: async () => {\n const storage = createWriter();\n const bytes = utf8Bytes(\"hello\");\n const hash = encodeSqlBlob(bytes);\n await storage.publishSql(hash, bytes);\n try {\n await storage.publishSql(hash, utf8Bytes(\"other\"));\n } catch (error) {\n if (isCorruption(error)) return;\n }\n throw new Error(\"corrupt publish was accepted\");\n },\n },\n {\n name: \"listStates returns only committed manifests\",\n run: async () => {\n const storage = createWriter();\n const listed = await storage.listStates();\n if (listed.length !== 0) throw new Error(\"fresh writer is not empty\");\n },\n },\n {\n name: \"estate publish is idempotent for identical bytes\",\n run: async () => {\n const storage = createWriter();\n const bytes = utf8Bytes('{\"format\":\"1\"}');\n const first = await storage.publishEstate(bytes);\n const second = await storage.publishEstate(bytes);\n if (first.outcome !== \"created\" || second.outcome !== \"identical\") {\n throw new Error(\"estate idempotent publish failed\");\n }\n },\n },\n {\n name: \"concurrent identical creates report created exactly once\",\n run: async () => {\n const storage = createWriter();\n const bytes = utf8Bytes(\"race-identical\");\n const id = encodeSqlBlob(bytes);\n const outcomes = await Promise.all(\n Array.from({ length: RACERS }, () => storage.publishState(id, bytes))\n );\n const created = outcomes.filter((o) => o.outcome === \"created\").length;\n if (created !== 1) {\n throw new Error(`${created} of ${RACERS} concurrent creates won`);\n }\n },\n },\n {\n name: \"concurrent conflicting creates keep one winner and refuse the rest\",\n run: async () => {\n const storage = createWriter();\n const id = encodeSqlBlob(utf8Bytes(\"race-conflicting\"));\n const candidates = Array.from({ length: RACERS }, (_, n) =>\n utf8Bytes(`{\"racer\":${n}}`)\n );\n const settled = await Promise.allSettled(\n candidates.map((bytes) => storage.publishState(id, bytes))\n );\n const winners = candidates.filter(\n (_, n) => settled[n]?.status === \"fulfilled\"\n );\n const refused = settled.filter(\n (result) =>\n result.status === \"rejected\" && isCorruption(result.reason)\n ).length;\n const stored = await storage.readState(id);\n if (\n winners.length !== 1 ||\n refused !== RACERS - 1 ||\n !(stored && bytesEqual(stored, winners[0]!))\n ) {\n throw new Error(\n `${winners.length} winners and ${refused} refusals of ${RACERS} conflicting creates`\n );\n }\n },\n },\n {\n name: \"absent artifacts read as null\",\n run: async () => {\n const storage = createWriter();\n const id = encodeSqlBlob(utf8Bytes(\"absent\"));\n const reads = await Promise.all([\n storage.readState(id),\n storage.readSnapshot(id),\n storage.readSql(id),\n ]);\n if (reads.some((bytes) => bytes !== null)) {\n throw new Error(\"an absent artifact read as bytes\");\n }\n },\n },\n {\n name: \"published artifacts are listed as soon as publish returns\",\n run: async () => {\n const storage = createWriter();\n const artifacts = Array.from({ length: LISTED }, (_, n) =>\n utf8Bytes(`listed-${n}`)\n );\n const ids = artifacts.map(encodeSqlBlob);\n for (const [n, id] of ids.entries()) {\n await storage.publishState(id, artifacts[n]!);\n await storage.publishSnapshot(id, artifacts[n]!);\n await storage.publishSql(id, artifacts[n]!);\n }\n const listings = await Promise.all([\n storage.listStates(),\n storage.listSnapshots(),\n storage.listSql(),\n ]);\n if (listings.some((listed) => ids.some((id) => !listed.includes(id)))) {\n throw new Error(\"a published artifact is missing from its listing\");\n }\n },\n },\n {\n name: \"a listed state's snapshot and SQL are already readable (manifest last)\",\n run: async () => {\n const storage = createWriter();\n const bytes = utf8Bytes(\"manifest-last\");\n const hash = encodeSqlBlob(bytes);\n let published = false;\n const publishing = (async () => {\n await storage.publishSnapshot(hash, bytes);\n await storage.publishSql(hash, bytes);\n await storage.publishState(hash, bytes);\n })().finally(() => {\n published = true;\n });\n try {\n for (;;) {\n const settled = published;\n if ((await storage.listStates()).includes(hash)) break;\n if (settled) throw new Error(\"a published state is not listed\");\n }\n const [snapshot, sql] = await Promise.all([\n storage.readSnapshot(hash),\n storage.readSql(hash),\n ]);\n if (!(snapshot && sql)) {\n throw new Error(\"a listed state's artifacts are not readable yet\");\n }\n } finally {\n await publishing;\n }\n },\n },\n ];\n}\n","/**\n * In-memory estate writer for tests and conformance.\n * Conditional create: same hash + same bytes is identical; different bytes is corruption.\n */\n\nimport { MigrationError, VibORMErrorCode } from \"../../errors\";\nimport { bytesEqual } from \"../canonical-json\";\nimport { isSha256, type Sha256 } from \"../identity\";\nimport type { MigrationStorageWriter, PublishResult } from \"./contract\";\n\nexport class MemoryEstateStorage implements MigrationStorageWriter {\n private estate: Uint8Array | null = null;\n private readonly states = new Map<Sha256, Uint8Array>();\n private readonly snapshots = new Map<Sha256, Uint8Array>();\n private readonly sql = new Map<Sha256, Uint8Array>();\n\n async readEstate(): Promise<Uint8Array | null> {\n return this.estate ? this.estate.slice() : null;\n }\n\n async listStates(): Promise<readonly Sha256[]> {\n return [...this.states.keys()].sort();\n }\n\n async listSnapshots(): Promise<readonly Sha256[]> {\n return [...this.snapshots.keys()].sort();\n }\n\n async listSql(): Promise<readonly Sha256[]> {\n return [...this.sql.keys()].sort();\n }\n\n async readState(id: Sha256): Promise<Uint8Array | null> {\n const bytes = this.states.get(id);\n return bytes ? bytes.slice() : null;\n }\n\n async readSnapshot(hash: Sha256): Promise<Uint8Array | null> {\n const bytes = this.snapshots.get(hash);\n return bytes ? bytes.slice() : null;\n }\n\n async readSql(hash: Sha256): Promise<Uint8Array | null> {\n const bytes = this.sql.get(hash);\n return bytes ? bytes.slice() : null;\n }\n\n async publishEstate(bytes: Uint8Array): Promise<PublishResult> {\n if (this.estate && !bytesEqual(this.estate, bytes)) {\n throw new MigrationError(\n \"estate.json already exists with different bytes\",\n VibORMErrorCode.MIGRATION_CORRUPTION\n );\n }\n if (this.estate) return { outcome: \"identical\" };\n this.estate = bytes.slice();\n return { outcome: \"created\" };\n }\n\n async publishSnapshot(\n hash: Sha256,\n bytes: Uint8Array\n ): Promise<PublishResult> {\n return publishMap(this.snapshots, hash, bytes, \"snapshot\");\n }\n\n async publishSql(hash: Sha256, bytes: Uint8Array): Promise<PublishResult> {\n return publishMap(this.sql, hash, bytes, \"sql\");\n }\n\n async publishState(id: Sha256, bytes: Uint8Array): Promise<PublishResult> {\n if (!isSha256(id)) {\n throw new MigrationError(\n \"State id is not a SHA-256 digest\",\n VibORMErrorCode.MIGRATION_INVALID_ESTATE\n );\n }\n return publishMap(this.states, id, bytes, \"state\");\n }\n}\n\nfunction publishMap(\n store: Map<Sha256, Uint8Array>,\n key: Sha256,\n bytes: Uint8Array,\n label: string\n): PublishResult {\n const existing = store.get(key);\n if (existing) {\n if (!bytesEqual(existing, bytes)) {\n throw new MigrationError(\n `${label} ${key} already holds different bytes`,\n VibORMErrorCode.MIGRATION_CORRUPTION\n );\n }\n return { outcome: \"identical\" };\n }\n store.set(key, bytes.slice());\n return { outcome: \"created\" };\n}\n"],"mappings":"yQAWA,MAGM,aAAgB,GACpB,aAAiB,GACjB,EAAM,OAAS,EAAgB,qBAEjC,SAAgB,8BACd,EACgE,CAChE,MAAO,CACL,CACE,KAAM,oDACN,IAAK,SAAY,CACf,IAAM,EAAU,GAAc,CACxB,EAAQ,EAAU,QAAQ,CAC1B,EAAO,EAAc,EAAM,CAC3B,EAAQ,MAAM,EAAQ,WAAW,EAAM,EAAM,CAC7C,EAAS,MAAM,EAAQ,WAAW,EAAM,EAAM,CACpD,GAAI,EAAM,UAAY,WAAa,EAAO,UAAY,YACpD,MAAU,MAA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M,EAAQ,KAAK,IAAI,IAAI,EAAK,CAChC,OAAO,EAAQ,EAAM,OAAO,CAAG,KAGjC,MAAM,cAAc,EAA2C,CAC7D,GAAI,KAAK,QAAU,CAAC,EAAW,KAAK,OAAQ,EAAM,CAChD,MAAM,IAAI,EACR,kDACA,EAAgB,qBACjB,CAIH,OAFI,KAAK,OAAe,CAAE,QAAS,YAAa,EAChD,KAAK,OAAS,EAAM,OAAO,CACpB,CAAE,QAAS,UAAW,EAG/B,MAAM,gBACJ,EACA,EACwB,CACxB,OAAO,WAAW,KAAK,UAAW,EAAM,EAAO,WAAW,CAG5D,MAAM,WAAW,EAAc,EAA2C,CACxE,OAAO,WAAW,KAAK,IAAK,EAAM,EAAO,MAAM,CAGjD,MAAM,aAAa,EAAY,EAA2C,CACxE,GAAI,CAAC,EAAS,EAAG,CACf,MAAM,IAAI,EACR,mCACA,EAAgB,yBACjB,CAEH,OAAO,WAAW,KAAK,OAAQ,EAAI,EAAO,QAAQ,GAItD,SAAS,WACP,EACA,EACA,EACA,EACe,CACf,IAAM,EAAW,EAAM,IAAI,EAAI,CAC/B,GAAI,EAAU,CACZ,GAAI,CAAC,EAAW,EAAU,EAAM,CAC9B,MAAM,IAAI,EACR,GAAG,EAAM,GAAG,EAAI,gCAChB,EAAgB,qBACjB,CAEH,MAAO,CAAE,QAAS,YAAa,CAGjC,OADA,EAAM,IAAI,EAAK,EAAM,OAAO,CAAC,CACtB,CAAE,QAAS,UAAW"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { a as ResolveChange, i as ResolveCallback, o as SchemaSnapshot, r as MigrationTarget, s as MigrationLimits } from "../planner-
|
|
1
|
+
import { Ci as MigrationError, wi as isMigrationError } from "../index-BlBkgxtx.mjs";
|
|
2
|
+
import { a as ResolveChange, i as ResolveCallback, o as SchemaSnapshot, r as MigrationTarget, s as MigrationLimits } from "../planner-syQCWHHr.mjs";
|
|
3
3
|
import { n as MigrationStorageWriter, r as PublishResult, t as MigrationStorageReader } from "../contract-CYl0OzhZ.mjs";
|
|
4
|
-
import { a as MemoryEstateStorage, c as auditStorage, d as lenientResolver, f as rejectAllResolver, g as sqliteCanonicalTimeExpression, h as sqliteCanonicalDateTimeExpression, i as refuseWorkersKvWritable, l as addDropResolver, m as identifierConversionChecks, n as ObjectStoreConditionalPut, o as createStorageConformanceSuite, p as IdentifierConversionRequest, r as ObjectStoreEstateStorage, s as StorageColumnAudit, t as MemoryConditionalObjectStore, u as createPredefinedResolver } from "../object-store-
|
|
5
|
-
import { A as InvalidIndex, B as MigrationCheckInput, C as MigrationStateListItem, D as PruneResult, E as PruneOptions, F as ExactPushOptions, G as PushConsent, H as MigrationEstateDescriptorV1, I as GenerateV1Options, J as ResetV1Options, K as PushOptionsV1, L as ManualMigrationInput, M as BaselineOptions, N as DownPreviewEdgeV1, O as CheckFinding, P as DownV1Options, R as ManualTransitionInput, S as MigrationStateDetails, T as ShowResult, V as MigrationDecisionV1, W as MigrationStateManifestV1, X as StateSelector, Y as ResolveV1Options, _ as PushPreview, a as LiveMigrations, b as MigrationEdgeMetadata, c as ReadableMigrations, d as ResolveResult, f as StatusResult, g as PushApplyResult, h as createMigrationClient, i as GenerateResult, j as ApplyV1Options, k as CheckResult, l as ReanchorResult, m as WritableMigrations, n as BaselineResult, o as LogResult, p as VerifyResult, q as ReanchorOptions, r as DownResult, s as MigrationClientOptions, t as ApplyResult, u as ResetResult, v as GraphResult, w as MigrationStateMetadata, x as MigrationRollbackMetadata, y as ListResult, z as MigrationApprovalV1 } from "../client-
|
|
4
|
+
import { a as MemoryEstateStorage, c as auditStorage, d as lenientResolver, f as rejectAllResolver, g as sqliteCanonicalTimeExpression, h as sqliteCanonicalDateTimeExpression, i as refuseWorkersKvWritable, l as addDropResolver, m as identifierConversionChecks, n as ObjectStoreConditionalPut, o as createStorageConformanceSuite, p as IdentifierConversionRequest, r as ObjectStoreEstateStorage, s as StorageColumnAudit, t as MemoryConditionalObjectStore, u as createPredefinedResolver } from "../object-store-C-VOh0LP.mjs";
|
|
5
|
+
import { A as InvalidIndex, B as MigrationCheckInput, C as MigrationStateListItem, D as PruneResult, E as PruneOptions, F as ExactPushOptions, G as PushConsent, H as MigrationEstateDescriptorV1, I as GenerateV1Options, J as ResetV1Options, K as PushOptionsV1, L as ManualMigrationInput, M as BaselineOptions, N as DownPreviewEdgeV1, O as CheckFinding, P as DownV1Options, R as ManualTransitionInput, S as MigrationStateDetails, T as ShowResult, V as MigrationDecisionV1, W as MigrationStateManifestV1, X as StateSelector, Y as ResolveV1Options, _ as PushPreview, a as LiveMigrations, b as MigrationEdgeMetadata, c as ReadableMigrations, d as ResolveResult, f as StatusResult, g as PushApplyResult, h as createMigrationClient, i as GenerateResult, j as ApplyV1Options, k as CheckResult, l as ReanchorResult, m as WritableMigrations, n as BaselineResult, o as LogResult, p as VerifyResult, q as ReanchorOptions, r as DownResult, s as MigrationClientOptions, t as ApplyResult, u as ResetResult, v as GraphResult, w as MigrationStateMetadata, x as MigrationRollbackMetadata, y as ListResult, z as MigrationApprovalV1 } from "../client-CrBKhXo-.mjs";
|
|
6
6
|
export { ApplyV1Options as ApplyOptions, ApplyResult, BaselineOptions, BaselineResult, CheckFinding, CheckResult, DownV1Options as DownOptions, DownPreviewEdgeV1 as DownPreviewEdge, DownResult, ExactPushOptions, GenerateV1Options as GenerateOptions, GenerateResult, GraphResult, IdentifierConversionRequest, InvalidIndex, ListResult, LiveMigrations, LogResult, ManualMigrationInput, ManualTransitionInput, MemoryConditionalObjectStore, MemoryEstateStorage, MigrationApprovalV1 as MigrationApproval, MigrationCheckInput, MigrationClientOptions, MigrationDecisionV1 as MigrationDecision, MigrationEdgeMetadata, MigrationError, MigrationEstateDescriptorV1, MigrationLimits, MigrationRollbackMetadata, MigrationStateDetails, MigrationStateListItem, MigrationStateManifestV1, MigrationStateMetadata, MigrationStorageReader, MigrationStorageWriter, MigrationTarget, ObjectStoreConditionalPut, ObjectStoreEstateStorage, PruneOptions, PruneResult, PublishResult, PushApplyResult, PushConsent, PushOptionsV1 as PushOptions, PushPreview, ReadableMigrations, ReanchorOptions, ReanchorResult, ResetV1Options as ResetOptions, ResetResult, ResolveCallback, ResolveChange, ResolveV1Options as ResolveOptions, ResolveResult, SchemaSnapshot, ShowResult, StateSelector, StatusResult, StorageColumnAudit, VerifyResult, WritableMigrations, addDropResolver, auditStorage, createMigrationClient, createPredefinedResolver, createStorageConformanceSuite, identifierConversionChecks, isMigrationError, lenientResolver, refuseWorkersKvWritable, rejectAllResolver, sqliteCanonicalDateTimeExpression, sqliteCanonicalTimeExpression };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{n as e,t}from"../migrations-OE5D32qo.mjs";import{C as n,E as r,T as i,l as a,p as o,s,t as c,u as l,w as u}from"../client-
|
|
1
|
+
import{n as e,t}from"../migrations-OE5D32qo.mjs";import{C as n,E as r,T as i,l as a,p as o,s,t as c,u as l,w as u}from"../client-BJuTpcYj.mjs";import{t as d}from"../identifier-conversion-BVE8cfFA.mjs";import{t as f}from"../mysql-sGTzkV2q.mjs";import{n as p,t as m}from"../memory-B0HOEpPu.mjs";import{n as h,r as g,t as _}from"../object-store-DdgcT8d9.mjs";o(f);export{_ as MemoryConditionalObjectStore,m as MemoryEstateStorage,t as MigrationError,h as ObjectStoreEstateStorage,n as addDropResolver,s as auditStorage,c as createMigrationClient,u as createPredefinedResolver,p as createStorageConformanceSuite,d as identifierConversionChecks,e as isMigrationError,i as lenientResolver,g as refuseWorkersKvWritable,r as rejectAllResolver,a as sqliteCanonicalDateTimeExpression,l as sqliteCanonicalTimeExpression};
|
|
2
2
|
//# sourceMappingURL=mysql.mjs.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { a as ResolveChange, i as ResolveCallback, o as SchemaSnapshot, r as MigrationTarget, s as MigrationLimits } from "../planner-
|
|
1
|
+
import { Ci as MigrationError, wi as isMigrationError } from "../index-BlBkgxtx.mjs";
|
|
2
|
+
import { a as ResolveChange, i as ResolveCallback, o as SchemaSnapshot, r as MigrationTarget, s as MigrationLimits } from "../planner-syQCWHHr.mjs";
|
|
3
3
|
import { n as MigrationStorageWriter, r as PublishResult, t as MigrationStorageReader } from "../contract-CYl0OzhZ.mjs";
|
|
4
|
-
import { a as MemoryEstateStorage, c as auditStorage, d as lenientResolver, f as rejectAllResolver, g as sqliteCanonicalTimeExpression, h as sqliteCanonicalDateTimeExpression, i as refuseWorkersKvWritable, l as addDropResolver, m as identifierConversionChecks, n as ObjectStoreConditionalPut, o as createStorageConformanceSuite, p as IdentifierConversionRequest, r as ObjectStoreEstateStorage, s as StorageColumnAudit, t as MemoryConditionalObjectStore, u as createPredefinedResolver } from "../object-store-
|
|
5
|
-
import { A as InvalidIndex, B as MigrationCheckInput, C as MigrationStateListItem, D as PruneResult, E as PruneOptions, F as ExactPushOptions, G as PushConsent, H as MigrationEstateDescriptorV1, I as GenerateV1Options, J as ResetV1Options, K as PushOptionsV1, L as ManualMigrationInput, M as BaselineOptions, N as DownPreviewEdgeV1, O as CheckFinding, P as DownV1Options, R as ManualTransitionInput, S as MigrationStateDetails, T as ShowResult, V as MigrationDecisionV1, W as MigrationStateManifestV1, X as StateSelector, Y as ResolveV1Options, _ as PushPreview, a as LiveMigrations, b as MigrationEdgeMetadata, c as ReadableMigrations, d as ResolveResult, f as StatusResult, g as PushApplyResult, h as createMigrationClient, i as GenerateResult, j as ApplyV1Options, k as CheckResult, l as ReanchorResult, m as WritableMigrations, n as BaselineResult, o as LogResult, p as VerifyResult, q as ReanchorOptions, r as DownResult, s as MigrationClientOptions, t as ApplyResult, u as ResetResult, v as GraphResult, w as MigrationStateMetadata, x as MigrationRollbackMetadata, y as ListResult, z as MigrationApprovalV1 } from "../client-
|
|
4
|
+
import { a as MemoryEstateStorage, c as auditStorage, d as lenientResolver, f as rejectAllResolver, g as sqliteCanonicalTimeExpression, h as sqliteCanonicalDateTimeExpression, i as refuseWorkersKvWritable, l as addDropResolver, m as identifierConversionChecks, n as ObjectStoreConditionalPut, o as createStorageConformanceSuite, p as IdentifierConversionRequest, r as ObjectStoreEstateStorage, s as StorageColumnAudit, t as MemoryConditionalObjectStore, u as createPredefinedResolver } from "../object-store-C-VOh0LP.mjs";
|
|
5
|
+
import { A as InvalidIndex, B as MigrationCheckInput, C as MigrationStateListItem, D as PruneResult, E as PruneOptions, F as ExactPushOptions, G as PushConsent, H as MigrationEstateDescriptorV1, I as GenerateV1Options, J as ResetV1Options, K as PushOptionsV1, L as ManualMigrationInput, M as BaselineOptions, N as DownPreviewEdgeV1, O as CheckFinding, P as DownV1Options, R as ManualTransitionInput, S as MigrationStateDetails, T as ShowResult, V as MigrationDecisionV1, W as MigrationStateManifestV1, X as StateSelector, Y as ResolveV1Options, _ as PushPreview, a as LiveMigrations, b as MigrationEdgeMetadata, c as ReadableMigrations, d as ResolveResult, f as StatusResult, g as PushApplyResult, h as createMigrationClient, i as GenerateResult, j as ApplyV1Options, k as CheckResult, l as ReanchorResult, m as WritableMigrations, n as BaselineResult, o as LogResult, p as VerifyResult, q as ReanchorOptions, r as DownResult, s as MigrationClientOptions, t as ApplyResult, u as ResetResult, v as GraphResult, w as MigrationStateMetadata, x as MigrationRollbackMetadata, y as ListResult, z as MigrationApprovalV1 } from "../client-CrBKhXo-.mjs";
|
|
6
6
|
export { ApplyV1Options as ApplyOptions, ApplyResult, BaselineOptions, BaselineResult, CheckFinding, CheckResult, DownV1Options as DownOptions, DownPreviewEdgeV1 as DownPreviewEdge, DownResult, ExactPushOptions, GenerateV1Options as GenerateOptions, GenerateResult, GraphResult, IdentifierConversionRequest, InvalidIndex, ListResult, LiveMigrations, LogResult, ManualMigrationInput, ManualTransitionInput, MemoryConditionalObjectStore, MemoryEstateStorage, MigrationApprovalV1 as MigrationApproval, MigrationCheckInput, MigrationClientOptions, MigrationDecisionV1 as MigrationDecision, MigrationEdgeMetadata, MigrationError, MigrationEstateDescriptorV1, MigrationLimits, MigrationRollbackMetadata, MigrationStateDetails, MigrationStateListItem, MigrationStateManifestV1, MigrationStateMetadata, MigrationStorageReader, MigrationStorageWriter, MigrationTarget, ObjectStoreConditionalPut, ObjectStoreEstateStorage, PruneOptions, PruneResult, PublishResult, PushApplyResult, PushConsent, PushOptionsV1 as PushOptions, PushPreview, ReadableMigrations, ReanchorOptions, ReanchorResult, ResetV1Options as ResetOptions, ResetResult, ResolveCallback, ResolveChange, ResolveV1Options as ResolveOptions, ResolveResult, SchemaSnapshot, ShowResult, StateSelector, StatusResult, StorageColumnAudit, VerifyResult, WritableMigrations, addDropResolver, auditStorage, createMigrationClient, createPredefinedResolver, createStorageConformanceSuite, identifierConversionChecks, isMigrationError, lenientResolver, refuseWorkersKvWritable, rejectAllResolver, sqliteCanonicalDateTimeExpression, sqliteCanonicalTimeExpression };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{n as e,t}from"../migrations-OE5D32qo.mjs";import{C as n,E as r,T as i,l as a,p as o,s,t as c,u as l,w as u}from"../client-
|
|
1
|
+
import{n as e,t}from"../migrations-OE5D32qo.mjs";import{C as n,E as r,T as i,l as a,p as o,s,t as c,u as l,w as u}from"../client-BJuTpcYj.mjs";import{t as d}from"../identifier-conversion-BVE8cfFA.mjs";import{t as f}from"../postgres-C2uUUh0t.mjs";import{n as p,t as m}from"../memory-B0HOEpPu.mjs";import{n as h,r as g,t as _}from"../object-store-DdgcT8d9.mjs";o(f);export{_ as MemoryConditionalObjectStore,m as MemoryEstateStorage,t as MigrationError,h as ObjectStoreEstateStorage,n as addDropResolver,s as auditStorage,c as createMigrationClient,u as createPredefinedResolver,p as createStorageConformanceSuite,d as identifierConversionChecks,e as isMigrationError,i as lenientResolver,g as refuseWorkersKvWritable,r as rejectAllResolver,a as sqliteCanonicalDateTimeExpression,l as sqliteCanonicalTimeExpression};
|
|
2
2
|
//# sourceMappingURL=postgres.mjs.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { a as ResolveChange, i as ResolveCallback, o as SchemaSnapshot, r as MigrationTarget, s as MigrationLimits } from "../planner-
|
|
1
|
+
import { Ci as MigrationError, wi as isMigrationError } from "../index-BlBkgxtx.mjs";
|
|
2
|
+
import { a as ResolveChange, i as ResolveCallback, o as SchemaSnapshot, r as MigrationTarget, s as MigrationLimits } from "../planner-syQCWHHr.mjs";
|
|
3
3
|
import { n as MigrationStorageWriter, r as PublishResult, t as MigrationStorageReader } from "../contract-CYl0OzhZ.mjs";
|
|
4
|
-
import { a as MemoryEstateStorage, c as auditStorage, d as lenientResolver, f as rejectAllResolver, g as sqliteCanonicalTimeExpression, h as sqliteCanonicalDateTimeExpression, i as refuseWorkersKvWritable, l as addDropResolver, m as identifierConversionChecks, n as ObjectStoreConditionalPut, o as createStorageConformanceSuite, p as IdentifierConversionRequest, r as ObjectStoreEstateStorage, s as StorageColumnAudit, t as MemoryConditionalObjectStore, u as createPredefinedResolver } from "../object-store-
|
|
5
|
-
import { A as InvalidIndex, B as MigrationCheckInput, C as MigrationStateListItem, D as PruneResult, E as PruneOptions, F as ExactPushOptions, G as PushConsent, H as MigrationEstateDescriptorV1, I as GenerateV1Options, J as ResetV1Options, K as PushOptionsV1, L as ManualMigrationInput, M as BaselineOptions, N as DownPreviewEdgeV1, O as CheckFinding, P as DownV1Options, R as ManualTransitionInput, S as MigrationStateDetails, T as ShowResult, V as MigrationDecisionV1, W as MigrationStateManifestV1, X as StateSelector, Y as ResolveV1Options, _ as PushPreview, a as LiveMigrations, b as MigrationEdgeMetadata, c as ReadableMigrations, d as ResolveResult, f as StatusResult, g as PushApplyResult, h as createMigrationClient, i as GenerateResult, j as ApplyV1Options, k as CheckResult, l as ReanchorResult, m as WritableMigrations, n as BaselineResult, o as LogResult, p as VerifyResult, q as ReanchorOptions, r as DownResult, s as MigrationClientOptions, t as ApplyResult, u as ResetResult, v as GraphResult, w as MigrationStateMetadata, x as MigrationRollbackMetadata, y as ListResult, z as MigrationApprovalV1 } from "../client-
|
|
4
|
+
import { a as MemoryEstateStorage, c as auditStorage, d as lenientResolver, f as rejectAllResolver, g as sqliteCanonicalTimeExpression, h as sqliteCanonicalDateTimeExpression, i as refuseWorkersKvWritable, l as addDropResolver, m as identifierConversionChecks, n as ObjectStoreConditionalPut, o as createStorageConformanceSuite, p as IdentifierConversionRequest, r as ObjectStoreEstateStorage, s as StorageColumnAudit, t as MemoryConditionalObjectStore, u as createPredefinedResolver } from "../object-store-C-VOh0LP.mjs";
|
|
5
|
+
import { A as InvalidIndex, B as MigrationCheckInput, C as MigrationStateListItem, D as PruneResult, E as PruneOptions, F as ExactPushOptions, G as PushConsent, H as MigrationEstateDescriptorV1, I as GenerateV1Options, J as ResetV1Options, K as PushOptionsV1, L as ManualMigrationInput, M as BaselineOptions, N as DownPreviewEdgeV1, O as CheckFinding, P as DownV1Options, R as ManualTransitionInput, S as MigrationStateDetails, T as ShowResult, V as MigrationDecisionV1, W as MigrationStateManifestV1, X as StateSelector, Y as ResolveV1Options, _ as PushPreview, a as LiveMigrations, b as MigrationEdgeMetadata, c as ReadableMigrations, d as ResolveResult, f as StatusResult, g as PushApplyResult, h as createMigrationClient, i as GenerateResult, j as ApplyV1Options, k as CheckResult, l as ReanchorResult, m as WritableMigrations, n as BaselineResult, o as LogResult, p as VerifyResult, q as ReanchorOptions, r as DownResult, s as MigrationClientOptions, t as ApplyResult, u as ResetResult, v as GraphResult, w as MigrationStateMetadata, x as MigrationRollbackMetadata, y as ListResult, z as MigrationApprovalV1 } from "../client-CrBKhXo-.mjs";
|
|
6
6
|
export { ApplyV1Options as ApplyOptions, ApplyResult, BaselineOptions, BaselineResult, CheckFinding, CheckResult, DownV1Options as DownOptions, DownPreviewEdgeV1 as DownPreviewEdge, DownResult, ExactPushOptions, GenerateV1Options as GenerateOptions, GenerateResult, GraphResult, IdentifierConversionRequest, InvalidIndex, ListResult, LiveMigrations, LogResult, ManualMigrationInput, ManualTransitionInput, MemoryConditionalObjectStore, MemoryEstateStorage, MigrationApprovalV1 as MigrationApproval, MigrationCheckInput, MigrationClientOptions, MigrationDecisionV1 as MigrationDecision, MigrationEdgeMetadata, MigrationError, MigrationEstateDescriptorV1, MigrationLimits, MigrationRollbackMetadata, MigrationStateDetails, MigrationStateListItem, MigrationStateManifestV1, MigrationStateMetadata, MigrationStorageReader, MigrationStorageWriter, MigrationTarget, ObjectStoreConditionalPut, ObjectStoreEstateStorage, PruneOptions, PruneResult, PublishResult, PushApplyResult, PushConsent, PushOptionsV1 as PushOptions, PushPreview, ReadableMigrations, ReanchorOptions, ReanchorResult, ResetV1Options as ResetOptions, ResetResult, ResolveCallback, ResolveChange, ResolveV1Options as ResolveOptions, ResolveResult, SchemaSnapshot, ShowResult, StateSelector, StatusResult, StorageColumnAudit, VerifyResult, WritableMigrations, addDropResolver, auditStorage, createMigrationClient, createPredefinedResolver, createStorageConformanceSuite, identifierConversionChecks, isMigrationError, lenientResolver, refuseWorkersKvWritable, rejectAllResolver, sqliteCanonicalDateTimeExpression, sqliteCanonicalTimeExpression };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{n as e,t}from"../migrations-OE5D32qo.mjs";import{C as n,E as r,T as i,l as a,p as o,s,t as c,u as l,w as u}from"../client-
|
|
1
|
+
import{n as e,t}from"../migrations-OE5D32qo.mjs";import{C as n,E as r,T as i,l as a,p as o,s,t as c,u as l,w as u}from"../client-BJuTpcYj.mjs";import{t as d}from"../identifier-conversion-BVE8cfFA.mjs";import{n as f,t as p}from"../libsql-CcKrXiun.mjs";import{n as m,t as h}from"../memory-B0HOEpPu.mjs";import{n as g,r as _,t as v}from"../object-store-DdgcT8d9.mjs";o(f),o(p);export{v as MemoryConditionalObjectStore,h as MemoryEstateStorage,t as MigrationError,g as ObjectStoreEstateStorage,n as addDropResolver,s as auditStorage,c as createMigrationClient,u as createPredefinedResolver,m as createStorageConformanceSuite,d as identifierConversionChecks,e as isMigrationError,i as lenientResolver,_ as refuseWorkersKvWritable,r as rejectAllResolver,a as sqliteCanonicalDateTimeExpression,l as sqliteCanonicalTimeExpression};
|
|
2
2
|
//# sourceMappingURL=sqlite.mjs.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { s as MigrationLimits, t as MigrationClient } from "../planner-
|
|
1
|
+
import { s as MigrationLimits, t as MigrationClient } from "../planner-syQCWHHr.mjs";
|
|
2
2
|
import { i as Sha256, n as MigrationStorageWriter } from "../contract-CYl0OzhZ.mjs";
|
|
3
|
-
import { U as MigrationMarkerV1, V as MigrationDecisionV1, c as ReadableMigrations } from "../client-
|
|
3
|
+
import { U as MigrationMarkerV1, V as MigrationDecisionV1, c as ReadableMigrations } from "../client-CrBKhXo-.mjs";
|
|
4
4
|
|
|
5
5
|
//#region src/migrations/tenant.d.ts
|
|
6
6
|
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{n as e}from"../chunk-BuuaeEvq.mjs";import{i as t,n,r}from"../base-wlv81COV.mjs";import{S as i,i as a,r as o,t as s,w as c}from"../client-
|
|
1
|
+
import{n as e}from"../chunk-BuuaeEvq.mjs";import{i as t,n,r}from"../base-wlv81COV.mjs";import{S as i,i as a,r as o,t as s,w as c}from"../client-BJuTpcYj.mjs";const l=new Set([n.MIGRATION_PARTIAL_EFFECT,n.MIGRATION_AMBIGUOUS_COMMIT,n.MIGRATION_UNFINISHED_ATTEMPT]),u=new Set([n.MIGRATION_FAILED,n.MIGRATION_MARKER_CONFLICT]);function createTenantMigrator({client:e,history:t,tables:n,limits:r}){let i={storage:t,tables:n,limits:r},l=s(e,i),u=Promise.resolve(),exclusive=async(e,t)=>{let n=u,release=()=>void 0;u=new Promise(e=>{release=e}).then(()=>n);try{return await untilAborted(n,t),await e()}finally{release()}},change=async(n,{decisions:r=[],signal:l,beforeDestructive:u}={})=>{let d,f;try{l?.throwIfAborted(),a(o(e),`batch`,`apply()`),f=s({$driver:e.$driver,$schema:n},i);let p=c(r);if(u&&await isDestructive(f,p,t)){l?.throwIfAborted();try{await u()}catch(e){return{kind:`refused`,error:describe(e)}}}l?.throwIfAborted(),d=(await f.generate({resolve:p})).outcome===`published`}catch(e){return{kind:classify(e),error:describe(e)}}for(let e=1;;e+=1)try{let e=await f.apply();return e.outcome===`noop`&&!d?{kind:`noop`}:{kind:`applied`,path:e.path,...e.warnings?{warnings:e.warnings}:{}}}catch(t){let n=classify(t),r=d&&n===`refused`?`failed`:n;if(e===4||r!==`failed`||!retryable(t)||!await backoff(e,l))return withMarker({kind:r,error:describe(t)},f)}};return Object.freeze({change:(e,t)=>exclusive(()=>change(e,t),t?.signal).catch(e=>({kind:`failed`,error:describe(e)})),status:()=>l.status(),log:()=>l.log(),resolve:e=>exclusive(()=>l.resolve(e)),down:e=>exclusive(()=>l.down(e)),reanchor:e=>exclusive(()=>l.reanchor(e)),prune:e=>exclusive(()=>l.prune(e))})}async function isDestructive(e,t,n){if((await e.generate({dryRun:!0,resolve:t})).operations.some(i))return!0;if(!await n.readEstate())return!1;let{states:r,edges:a}=await e.graph();if(r.length===0)return!1;let{path:o}=await e.apply({dryRun:!0});return a.some(e=>o.includes(e.toState)&&(e.approvals.length>0||e.risks.includes(`destructive`)))}function retryable(e){if(t(e)&&e.code===n.MIGRATION_LOCK_FAILED)return!0;for(let t=e;t instanceof Error;t=t.cause)if(r(t))return!0;return!1}function classify(e){return t(e)?l.has(e.code)||e.meta.partial===!0?`ambiguous`:u.has(e.code)||retryable(e)?`failed`:`refused`:`failed`}async function withMarker(e,t){try{return{...e,marker:(await t.status()).marker}}catch{return e}}function describe(e){if(!(e instanceof Error))return{name:`Error`,message:String(e)};let n=e.cause instanceof Error?Reflect.get(e.cause,`code`):null,r=t(e)?e.meta.providerSqlState:void 0;return{name:e.name,...t(e)?{code:e.code}:{},message:e.message,...typeof n==`string`?{causeCode:n}:{},...typeof r==`string`?{providerSqlState:r}:{}}}function untilAborted(e,t){if(!t)return e;t.throwIfAborted();let abort=()=>void 0,n=new Promise((e,n)=>{abort=()=>n(t.reason),t.addEventListener(`abort`,abort,{once:!0})});return Promise.race([e,n]).finally(()=>t.removeEventListener(`abort`,abort))}async function backoff(e,t){let n=200*2**(e-1)*(.5+Math.random()/2);try{return await untilAborted(new Promise(e=>setTimeout(e,n)),t),!0}catch{return!1}}export{createTenantMigrator};
|
|
2
2
|
//# sourceMappingURL=tenant.mjs.map
|
package/dist/migrations.d.mts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { a as ResolveChange, i as ResolveCallback, o as SchemaSnapshot, r as MigrationTarget, s as MigrationLimits } from "./planner-
|
|
1
|
+
import { Ci as MigrationError, wi as isMigrationError } from "./index-BlBkgxtx.mjs";
|
|
2
|
+
import { a as ResolveChange, i as ResolveCallback, o as SchemaSnapshot, r as MigrationTarget, s as MigrationLimits } from "./planner-syQCWHHr.mjs";
|
|
3
3
|
import { n as MigrationStorageWriter, r as PublishResult, t as MigrationStorageReader } from "./contract-CYl0OzhZ.mjs";
|
|
4
|
-
import { a as MemoryEstateStorage, c as auditStorage, d as lenientResolver, f as rejectAllResolver, g as sqliteCanonicalTimeExpression, h as sqliteCanonicalDateTimeExpression, i as refuseWorkersKvWritable, l as addDropResolver, m as identifierConversionChecks, n as ObjectStoreConditionalPut, o as createStorageConformanceSuite, p as IdentifierConversionRequest, r as ObjectStoreEstateStorage, s as StorageColumnAudit, t as MemoryConditionalObjectStore, u as createPredefinedResolver } from "./object-store-
|
|
5
|
-
import { A as InvalidIndex, B as MigrationCheckInput, C as MigrationStateListItem, D as PruneResult, E as PruneOptions, F as ExactPushOptions, G as PushConsent, H as MigrationEstateDescriptorV1, I as GenerateV1Options, J as ResetV1Options, K as PushOptionsV1, L as ManualMigrationInput, M as BaselineOptions, N as DownPreviewEdgeV1, O as CheckFinding, P as DownV1Options, R as ManualTransitionInput, S as MigrationStateDetails, T as ShowResult, V as MigrationDecisionV1, W as MigrationStateManifestV1, X as StateSelector, Y as ResolveV1Options, _ as PushPreview, a as LiveMigrations, b as MigrationEdgeMetadata, c as ReadableMigrations, d as ResolveResult, f as StatusResult, g as PushApplyResult, h as createMigrationClient, i as GenerateResult, j as ApplyV1Options, k as CheckResult, l as ReanchorResult, m as WritableMigrations, n as BaselineResult, o as LogResult, p as VerifyResult, q as ReanchorOptions, r as DownResult, s as MigrationClientOptions, t as ApplyResult, u as ResetResult, v as GraphResult, w as MigrationStateMetadata, x as MigrationRollbackMetadata, y as ListResult, z as MigrationApprovalV1 } from "./client-
|
|
4
|
+
import { a as MemoryEstateStorage, c as auditStorage, d as lenientResolver, f as rejectAllResolver, g as sqliteCanonicalTimeExpression, h as sqliteCanonicalDateTimeExpression, i as refuseWorkersKvWritable, l as addDropResolver, m as identifierConversionChecks, n as ObjectStoreConditionalPut, o as createStorageConformanceSuite, p as IdentifierConversionRequest, r as ObjectStoreEstateStorage, s as StorageColumnAudit, t as MemoryConditionalObjectStore, u as createPredefinedResolver } from "./object-store-C-VOh0LP.mjs";
|
|
5
|
+
import { A as InvalidIndex, B as MigrationCheckInput, C as MigrationStateListItem, D as PruneResult, E as PruneOptions, F as ExactPushOptions, G as PushConsent, H as MigrationEstateDescriptorV1, I as GenerateV1Options, J as ResetV1Options, K as PushOptionsV1, L as ManualMigrationInput, M as BaselineOptions, N as DownPreviewEdgeV1, O as CheckFinding, P as DownV1Options, R as ManualTransitionInput, S as MigrationStateDetails, T as ShowResult, V as MigrationDecisionV1, W as MigrationStateManifestV1, X as StateSelector, Y as ResolveV1Options, _ as PushPreview, a as LiveMigrations, b as MigrationEdgeMetadata, c as ReadableMigrations, d as ResolveResult, f as StatusResult, g as PushApplyResult, h as createMigrationClient, i as GenerateResult, j as ApplyV1Options, k as CheckResult, l as ReanchorResult, m as WritableMigrations, n as BaselineResult, o as LogResult, p as VerifyResult, q as ReanchorOptions, r as DownResult, s as MigrationClientOptions, t as ApplyResult, u as ResetResult, v as GraphResult, w as MigrationStateMetadata, x as MigrationRollbackMetadata, y as ListResult, z as MigrationApprovalV1 } from "./client-CrBKhXo-.mjs";
|
|
6
6
|
export { ApplyV1Options as ApplyOptions, ApplyResult, BaselineOptions, BaselineResult, CheckFinding, CheckResult, DownV1Options as DownOptions, DownPreviewEdgeV1 as DownPreviewEdge, DownResult, ExactPushOptions, GenerateV1Options as GenerateOptions, GenerateResult, GraphResult, IdentifierConversionRequest, InvalidIndex, ListResult, LiveMigrations, LogResult, ManualMigrationInput, ManualTransitionInput, MemoryConditionalObjectStore, MemoryEstateStorage, MigrationApprovalV1 as MigrationApproval, MigrationCheckInput, MigrationClientOptions, MigrationDecisionV1 as MigrationDecision, MigrationEdgeMetadata, MigrationError, MigrationEstateDescriptorV1, MigrationLimits, MigrationRollbackMetadata, MigrationStateDetails, MigrationStateListItem, MigrationStateManifestV1, MigrationStateMetadata, MigrationStorageReader, MigrationStorageWriter, MigrationTarget, ObjectStoreConditionalPut, ObjectStoreEstateStorage, PruneOptions, PruneResult, PublishResult, PushApplyResult, PushConsent, PushOptionsV1 as PushOptions, PushPreview, ReadableMigrations, ReanchorOptions, ReanchorResult, ResetV1Options as ResetOptions, ResetResult, ResolveCallback, ResolveChange, ResolveV1Options as ResolveOptions, ResolveResult, SchemaSnapshot, ShowResult, StateSelector, StatusResult, StorageColumnAudit, VerifyResult, WritableMigrations, addDropResolver, auditStorage, createMigrationClient, createPredefinedResolver, createStorageConformanceSuite, identifierConversionChecks, isMigrationError, lenientResolver, refuseWorkersKvWritable, rejectAllResolver, sqliteCanonicalDateTimeExpression, sqliteCanonicalTimeExpression };
|
package/dist/migrations.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{n as e,t}from"./migrations-OE5D32qo.mjs";import{C as n,E as r,T as i,l as a,s as o,t as s,u as c,w as l}from"./client-
|
|
1
|
+
import{n as e,t}from"./migrations-OE5D32qo.mjs";import{C as n,E as r,T as i,l as a,s as o,t as s,u as c,w as l}from"./client-BJuTpcYj.mjs";import{t as u}from"./identifier-conversion-BVE8cfFA.mjs";import{t as d}from"./every-CyllpuCG.mjs";import{n as f,t as p}from"./memory-B0HOEpPu.mjs";import{n as m,r as h,t as g}from"./object-store-DdgcT8d9.mjs";d();export{g as MemoryConditionalObjectStore,p as MemoryEstateStorage,t as MigrationError,m as ObjectStoreEstateStorage,n as addDropResolver,o as auditStorage,s as createMigrationClient,l as createPredefinedResolver,f as createStorageConformanceSuite,u as identifierConversionChecks,e as isMigrationError,i as lenientResolver,h as refuseWorkersKvWritable,r as rejectAllResolver,a as sqliteCanonicalDateTimeExpression,c as sqliteCanonicalTimeExpression};
|
|
2
2
|
//# sourceMappingURL=migrations.mjs.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{n as e}from"./chunk-BuuaeEvq.mjs";import{C as t,S as n,_ as r,g as i,h as a,m as o,n as s,v as c,w as l,x as u}from"./v-
|
|
2
|
-
//# sourceMappingURL=model-
|
|
1
|
+
import{n as e}from"./chunk-BuuaeEvq.mjs";import{C as t,S as n,_ as r,g as i,h as a,m as o,n as s,v as c,w as l,x as u}from"./v-CWY9ntMb.mjs";import{Pt as d}from"./geo-point-codec-Ggv29hSH.mjs";function emptyRecord(){return Object.create(null)}function put(e,t,n){Object.defineProperty(e,t,{value:n,enumerable:!0,writable:!0,configurable:!0})}function own(e,t){if(!(e===void 0||!Object.hasOwn(e,t)))return e[t]}const f=/^[A-Za-z0-9][A-Za-z0-9._:-]{0,190}$/,p=[`table`,`source`,`target`];function normalizeVariantEntries(e,n,i){r(n)||l(e,`target`,"A relation target is either `() => model` or a plain map of named `() => model` getters");let o=a(n);o.length===0&&l(e,`target`,`A variant map needs at least one variant`);let s=readStoredValues(e,o,i),c={};for(let r of o){d(r)||l(e,`target.${r}`,`Variant key '${r}' is not a valid schema identifier`);let i=t(e,n,r,`target.${r}`);typeof i!=`function`&&l(e,`target.${r}`,`Variant '${r}' must be a lazy getter; write \`() => model\` rather than the model itself`),c[r]=Object.freeze({getter:i,storedValue:s[r]??r})}return Object.freeze(c)}function readStoredValues(e,n,o){if(o===void 0)return{};r(o)||l(e,`options`,"Relation options must be a plain `{ values }` record; omit the argument to use each variant key as its stored value"),i(a(o),[`values`])||l(e,`options`,"Relation options carry exactly one key, `values`; omit the argument to use each variant key as its stored value");let s=t(e,o,`values`,`options.values`);r(s)||l(e,`options.values`,"`values` must be a plain record keyed by every variant");let c=a(s);i(c,n)||l(e,`options.values`,`\`values\` must be exact over the variant keys ${renderKeys(n)}; it declares ${renderKeys(c)}`);let u={},d=new Set;for(let r of n){let n=t(e,s,r,`options.values.${r}`);(typeof n!=`string`||!f.test(n))&&l(e,`options.values.${r}`,`Stored value for variant '${r}' must match the stored-discriminator grammar`),d.has(n)&&l(e,`options.values.${r}`,`Stored value '${n}' is declared for more than one variant`),d.add(n),u[r]=n}return u}function renderKeys(e){return`[${e.map(e=>`'${e}'`).join(`, `)}]`}function foldMemberJunctions(e,n){let o=Object.keys(e);r(n)||l(`s.toMany`,`through`,"`.through()` takes a plain map keyed by every variant"),i(a(n),o)||l(`s.toMany`,`through`,`\`.through()\` must be exact over the variant keys ${renderKeys(o)}`);let s={};for(let[r,i]of Object.entries(e)){let e=t(`s.toMany`,n,r,`through.${r}`);s[r]=Object.freeze({...i,junction:readJunctionOverride(r,e)})}return Object.freeze(s)}function readJunctionOverride(e,n){let o=`through.${e}`;r(n)||l(`s.toMany`,o,`Member junction '${e}' must be a plain \`{ table, source, target }\` record`);let s=t(`s.toMany`,n,`table`,`${o}.table`),c=t(`s.toMany`,n,`source`,`${o}.source`),u=t(`s.toMany`,n,`target`,`${o}.target`);return(!i(a(n),p)||typeof s!=`string`||typeof c!=`string`||typeof u!=`string`)&&l(`s.toMany`,o,`Member junction '${e}' declares exactly \`table\`, \`source\` and \`target\`, all strings`),Object.freeze({table:s,source:c,target:u})}var m=class VariantToOne{#e;#t;constructor(e){this.#e=Object.freeze(e),this.#t=Object.freeze({state:this.#e,settleTarget:o(e=>readVariantGetter(this.#e,e))})}name(e){return new VariantToOne({...this.#e,name:n(`s.toOne`,e)})}optional(){return new VariantToOne({...this.#e,optional:!0})}get"~"(){return this.#t}},h=class VariantToMany{#e;#t;constructor(e){this.#e=Object.freeze(e),this.#t=Object.freeze({state:this.#e,settleTarget:o(e=>readVariantGetter(this.#e,e))})}name(e){return new VariantToMany({...this.#e,name:n(`s.toMany`,e)})}through(e){return new VariantToMany({...this.#e,target:{kind:`variants`,entries:foldMemberJunctions(this.#e.target.entries,e)}})}get"~"(){return this.#t}};function variantToOneTerminal(e){return new m(e)}function variantToManyTerminal(e){return new h(e)}function readVariantGetter(e,t){if(t===void 0)return;let n=e.target.entries[t];return n===void 0?void 0:n.getter}var g=class ModelToOne{#e;#t;constructor(e){this.#e=Object.freeze(e),this.#t=Object.freeze({state:this.#e,settleTarget:o(()=>this.#e.target.getter)})}name(e){return new ModelToOne({...this.#e,name:n(`s.toOne`,e)})}fields(...e){return new _(this.#e,c(`s.toOne`,`fields`,e))}onDelete(e){return this.#n(`onDelete`,e)}onUpdate(e){return this.#n(`onUpdate`,e)}#n(e,t){let n=this.#e.foreignKey;return n===void 0&&l(`s.toOne`,e,`'${e}' is available only after \`.fields(...).references(...)\` declares a foreign key`),new ModelToOne({...this.#e,foreignKey:Object.freeze({...n,[e]:u(e,t)})})}get"~"(){return this.#t}},_=class PendingReferences{#e;#t;constructor(e,t){this.#e=e,this.#t=t}name(e){return new PendingReferences({...this.#e,name:n(`s.toOne`,e)},this.#t)}references(...e){let t=c(`s.toOne`,`references`,e);t.length!==this.#t.length&&refuseReferenceArity(t.length,this.#t.length);let n=this.#e.foreignKey,r={fields:this.#t,references:t,...n?.onDelete===void 0?{}:{onDelete:n.onDelete},...n?.onUpdate===void 0?{}:{onUpdate:n.onUpdate}};return new g({...this.#e,foreignKey:Object.freeze(r)})}};function isReferencesStage(e){return e instanceof _}function toOne(e,t){return typeof e==`function`?(arguments.length>1&&l(`s.toOne`,`options`,`A model-target relation takes exactly one argument`),new g({kind:`relation`,cardinality:`one`,target:{kind:`model`,getter:e}})):variantToOneTerminal({kind:`relation`,cardinality:`one`,target:{kind:`variants`,entries:normalizeVariantEntries(`s.toOne`,e,t)}})}function refuseReferenceArity(e,t){return l(`s.toOne`,`references`,`\`.references(...)\` declares ${e} field(s) against ${t} local field(s); a foreign key pairs them positionally`)}function isRelation(e){if((typeof e!=`object`||!e)&&typeof e!=`function`)return!1;let t=Reflect.get(e,`~`);if(typeof t!=`object`||!t)return!1;let n=Reflect.get(t,`state`);return typeof n==`object`&&!!n&&Reflect.get(n,`kind`)===`relation`}const v=new Set([`string`,`int`,`number`,`decimal`,`boolean`,`datetime`,`date`,`time`,`bigint`,`json`,`blob`,`vector`,`point`,`enum`]);function isScalar(e){if((typeof e!=`object`||!e)&&typeof e!=`function`)return!1;let t=Reflect.get(e,`~`);if(typeof t!=`object`||!t)return!1;let n=Reflect.get(t,`state`);if(typeof n!=`object`||!n)return!1;let r=Reflect.get(n,`type`);return typeof r==`string`&&v.has(r)}const extractScalarMap=e=>{let t=emptyRecord();for(let[n,r]of Object.entries(e))isScalar(r)&&(t[n]=r);return t},extractRelationMap=e=>{let t=emptyRecord();for(let[n,r]of Object.entries(e))isRelation(r)?t[n]=r:isReferencesStage(r)&&l(`s.model`,n,`Relation '${n}' started \`.fields(...)\` without \`.references(...)\`; complete the foreign key before using it as a model field`);return t},extractUniqueScalarMap=e=>{let t=emptyRecord();for(let[n,r]of Object.entries(e))isScalar(r)&&(r[`~`].state.isUnique||r[`~`].state.isId)&&(t[n]=r);return t},getNameFromKeys=(e,t)=>e??t.join(`_`);function isTotalIndex(e){return!e.where}const mergeIndexDefinitions=(e,t)=>[...e.indexes,t];function compoundMembers(e,t,n){refuseDuplicateModelKeyMembers(t,n);let r=emptyRecord();for(let i of t){let t=i in e.scalars?e.scalars[i]:void 0;if(!t)throw Error(i in e.relations?`${n} field '${i}' is a relation and cannot be a key member`:`${n} field '${i}' does not exist`);put(r,i,t[`~`].state.base)}return r}function withCompound(e,t,n,r,i){let a=snapshotModelKeyMembers(r,n),o=getNameFromKeys(i?.name,a);if(Object.hasOwn(e[t]??{},o))throw Error(`${n} name '${o}' is already used by another compound key; give this tuple a distinct name`);let c=compoundMembers(e,a,n);return new y({...e,[t]:{...e[t],[o]:s.object(c,{partial:!1})}})}function snapshotModelKeyMembers(e,t){if(!Array.isArray(e))throw Error(`${t} fields must be a dense array of strings`);let n=e.length,r=Array(n);for(let i=0;i<n;i++){if(!Object.hasOwn(e,i))throw Error(`${t} fields must be a dense array of strings`);let n=e[i];if(typeof n!=`string`)throw Error(`${t} fields must be a dense array of strings`);r[i]=n}return r}function snapshotIndexOptions(e){let t=e.name,n=e.unique,r=e.type,i=e.where;return{...t===void 0?{}:{name:t},...n===void 0?{}:{unique:n},...r===void 0?{}:{type:r},...i===void 0?{}:{where:i}}}function refuseDuplicateModelKeyMembers(e,t){if(new Set(e).size!==e.length)throw Error(`${t} cannot repeat a field in one tuple`)}var y=class Model{#e={};#t={fields:new Map};#n;#r;#i;#a;constructor(e){this.#n=e}map(e){return new Model({...this.#n,tableName:e})}omit(e){return new Model({...this.#n,omit:e})}index(e,t={}){let n=snapshotModelKeyMembers(e,`Index`);refuseDuplicateModelKeyMembers(n,`Index`);let r=snapshotIndexOptions(t);return new Model({...this.#n,indexes:mergeIndexDefinitions(this.#n,{fields:n,options:r})})}id(e,t){return withCompound(this.#n,`compoundId`,`Compound ID`,e,t)}unique(e,t){return withCompound(this.#n,`compoundUniques`,`Compound unique`,e,t)}extends(e){let t={...this.#n.shape,...e};return new Model({...this.#n,shape:t,scalars:extractScalarMap(t),relations:extractRelationMap(t),uniques:extractUniqueScalarMap(t)})}get"~"(){if(this.#a)return this.#a;let e=this;return this.#a={state:this.#n,get names(){return e.#e},get nameRegistry(){return e.#t},getFieldName:t=>{let n=e.#t.fields.get(t);if(n)return n;throw Error(`Scalar "${t}" not found in nameRegistry`)},get scalarFieldNames(){return e.#r??=Object.keys(e.#n.scalars)},get relationNames(){return e.#i??=Object.keys(e.#n.relations)}},this.#a}};const model=e=>new y({compoundId:void 0,compoundUniques:void 0,tableName:void 0,indexes:[],omit:void 0,shape:e,scalars:extractScalarMap(e),relations:extractRelationMap(e),uniques:extractUniqueScalarMap(e)});function getTableName(e,t=`unknown`){return e[`~`].names.sql??e[`~`].state.tableName??t}function getColumnName(e,t){return e[`~`].getFieldName(t).sql}export{model as a,variantToManyTerminal as c,put as d,isTotalIndex as i,emptyRecord as l,getColumnName as n,toOne as o,getTableName as r,normalizeVariantEntries as s,y as t,own as u};
|
|
2
|
+
//# sourceMappingURL=model-u8Ug971J.mjs.map
|