viborm 1.3.0 → 1.3.2
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-BpMbLKpL.mjs → adapter-namespace-B8XWzCev.mjs} +1 -1
- package/dist/{adapter-namespace-BpMbLKpL.mjs.map → adapter-namespace-B8XWzCev.mjs.map} +1 -1
- package/dist/adapters.d.mts +1 -1
- package/dist/adapters.mjs +1 -1
- package/dist/{batch-refs-B4zn-FAu.mjs → batch-refs-DoWlPD2h.mjs} +1 -1
- package/dist/{batch-refs-B4zn-FAu.mjs.map → batch-refs-DoWlPD2h.mjs.map} +1 -1
- package/dist/{builder-Df24l2Bd.mjs → builder-DhxaVYP2.mjs} +2 -2
- package/dist/{builder-Df24l2Bd.mjs.map → builder-DhxaVYP2.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/cache.mjs.map +1 -1
- package/dist/chain-BjJ_M7EE.mjs +2 -0
- package/dist/chain-BjJ_M7EE.mjs.map +1 -0
- package/dist/cli.mjs +1 -1
- package/dist/client-BCgMXn6N.mjs +2 -0
- package/dist/client-BCgMXn6N.mjs.map +1 -0
- package/dist/{client-70MrTq1E.d.mts → client-Df81J4oB.d.mts} +1 -1
- package/dist/{client-DM1UHfYG.mjs → client-q6ccRgdO.mjs} +2 -2
- package/dist/{client-DM1UHfYG.mjs.map → client-q6ccRgdO.mjs.map} +1 -1
- package/dist/client.d.mts +1 -1
- package/dist/client.mjs +1 -1
- package/dist/{clock-C24RcpwO.mjs → clock-YTLtjLFS.mjs} +1 -1
- package/dist/{clock-C24RcpwO.mjs.map → clock-YTLtjLFS.mjs.map} +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/{driver-CPD0Xxw2.mjs → driver-D6_Ik58x.mjs} +2 -2
- package/dist/{driver-CPD0Xxw2.mjs.map → driver-D6_Ik58x.mjs.map} +1 -1
- package/dist/{driver-B9fIori_.mjs → driver-Ddt147dK.mjs} +2 -2
- package/dist/{driver-B9fIori_.mjs.map → driver-Ddt147dK.mjs.map} +1 -1
- package/dist/driver.d.mts +1 -1
- package/dist/driver.mjs +1 -1
- package/dist/every-dpzVDwzu.mjs +2 -0
- package/dist/{every-1pKZteeB.mjs.map → every-dpzVDwzu.mjs.map} +1 -1
- package/dist/{fs-estate-i8Zlr1OQ.mjs → fs-estate-azK36i9V.mjs} +2 -2
- package/dist/{fs-estate-i8Zlr1OQ.mjs.map → fs-estate-azK36i9V.mjs.map} +1 -1
- package/dist/{hydration-DsyHNSDS.mjs → hydration-C2uXmJy6.mjs} +2 -2
- package/dist/{hydration-DsyHNSDS.mjs.map → hydration-C2uXmJy6.mjs.map} +1 -1
- package/dist/{identifier-conversion-DaZ9yNpv.mjs → identifier-conversion-C2pwwFOS.mjs} +2 -2
- package/dist/{identifier-conversion-DaZ9yNpv.mjs.map → identifier-conversion-C2pwwFOS.mjs.map} +1 -1
- package/dist/identity-Bj2EN6Ss.mjs +2 -0
- package/dist/identity-Bj2EN6Ss.mjs.map +1 -0
- package/dist/{index-VsM29vYN.d.mts → index-D4O0Twvs.d.mts} +16 -8
- 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/{key-D_kagnFv.mjs → key-B7vuAYPG.mjs} +2 -2
- package/dist/{key-D_kagnFv.mjs.map → key-B7vuAYPG.mjs.map} +1 -1
- package/dist/{libsql-DFAoHXrI.mjs → libsql-DUO6vHad.mjs} +2 -2
- package/dist/{libsql-DFAoHXrI.mjs.map → libsql-DUO6vHad.mjs.map} +1 -1
- package/dist/libsql.d.mts +1 -1
- package/dist/libsql.mjs +1 -1
- package/dist/{memory-GTWgeDNY.mjs → memory-BApsTkt1.mjs} +2 -2
- package/dist/{memory-GTWgeDNY.mjs.map → memory-BApsTkt1.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/storage/durable-object.mjs +1 -1
- package/dist/migrations/storage/fs.mjs +1 -1
- package/dist/migrations/storage/r2.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-xChEivOe.mjs → mysql-D1GlcktG.mjs} +2 -2
- package/dist/{mysql-xChEivOe.mjs.map → mysql-D1GlcktG.mjs.map} +1 -1
- package/dist/{mysql-adapter-C6c5govr.mjs → mysql-adapter-ClOoHKpn.mjs} +2 -2
- package/dist/{mysql-adapter-C6c5govr.mjs.map → mysql-adapter-ClOoHKpn.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/{object-store-D9mvOHP4.d.mts → object-store-BN64q8Zn.d.mts} +3 -3
- package/dist/{object-store-ChYHlOMD.mjs → object-store-CZADAv4c.mjs} +2 -2
- package/dist/{object-store-ChYHlOMD.mjs.map → object-store-CZADAv4c.mjs.map} +1 -1
- package/dist/permissions.d.mts +2 -2
- 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/{pinned-session-BTplL3iZ.mjs → pinned-session-CjvR0Ge2.mjs} +2 -2
- package/dist/{pinned-session-BTplL3iZ.mjs.map → pinned-session-CjvR0Ge2.mjs.map} +1 -1
- package/dist/planetscale.d.mts +1 -1
- package/dist/planetscale.mjs +1 -1
- package/dist/{planner-C1NzLBge.d.mts → planner-8smxUOt9.d.mts} +1 -1
- package/dist/{postgres-BqAxDWTQ.mjs → postgres-Be0jMJWI.mjs} +2 -2
- package/dist/{postgres-BqAxDWTQ.mjs.map → postgres-Be0jMJWI.mjs.map} +1 -1
- package/dist/{postgres-adapter-CxEit2-v.mjs → postgres-adapter-BoQ4RRwr.mjs} +2 -2
- package/dist/{postgres-adapter-CxEit2-v.mjs.map → postgres-adapter-BoQ4RRwr.mjs.map} +1 -1
- package/dist/{postgres-adapter-CGthb5yh.mjs → postgres-adapter-C_Mt8lVC.mjs} +2 -2
- package/dist/{postgres-adapter-CGthb5yh.mjs.map → postgres-adapter-C_Mt8lVC.mjs.map} +1 -1
- package/dist/{postgres-result-KyBKBNJr.mjs → postgres-result-CYu1dyI_.mjs} +1 -1
- package/dist/{postgres-result-KyBKBNJr.mjs.map → postgres-result-CYu1dyI_.mjs.map} +1 -1
- package/dist/postgres.d.mts +1 -1
- package/dist/postgres.mjs +1 -1
- package/dist/result-shape-DQc-tDJ5.mjs +2 -0
- package/dist/{result-shape-CDgX_vzn.mjs.map → result-shape-DQc-tDJ5.mjs.map} +1 -1
- package/dist/rows-JXjhWwyb.mjs +2 -0
- package/dist/rows-JXjhWwyb.mjs.map +1 -0
- package/dist/{scalar-S8yMvdmx.mjs → scalar-CqqZ6jWd.mjs} +2 -2
- package/dist/{scalar-S8yMvdmx.mjs.map → scalar-CqqZ6jWd.mjs.map} +1 -1
- package/dist/schema/json.d.mts +1 -1
- package/dist/schema/json.mjs +1 -1
- package/dist/{schema-9N9jQlVL.mjs → schema-Cv-hhpl5.mjs} +2 -2
- package/dist/{schema-9N9jQlVL.mjs.map → schema-Cv-hhpl5.mjs.map} +1 -1
- package/dist/{schema-introspection-CyXKReK1.mjs → schema-introspection-B2Rvqgut.mjs} +3 -3
- package/dist/{schema-introspection-CyXKReK1.mjs.map → schema-introspection-B2Rvqgut.mjs.map} +1 -1
- package/dist/schema.d.mts +1 -1
- package/dist/schema.mjs +1 -1
- package/dist/{select-assembly-CkGe2ABs.mjs → select-assembly-BxtETbG9.mjs} +1 -1
- package/dist/{select-assembly-CkGe2ABs.mjs.map → select-assembly-BxtETbG9.mjs.map} +1 -1
- package/dist/{settle-CS_k6Ztm.mjs → settle-etgtP1WM.mjs} +2 -2
- package/dist/{settle-CS_k6Ztm.mjs.map → settle-etgtP1WM.mjs.map} +1 -1
- package/dist/sha256-CEYo7k7R.mjs +2 -0
- package/dist/sha256-CEYo7k7R.mjs.map +1 -0
- package/dist/soft-delete.d.mts +1 -1
- package/dist/{sql-statement-tokens-CFi1y3bK.mjs → sql-statement-tokens-BW7Q-rF-.mjs} +1 -1
- package/dist/{sql-statement-tokens-CFi1y3bK.mjs.map → sql-statement-tokens-BW7Q-rF-.mjs.map} +1 -1
- package/dist/{sqlite-adapter-BXAJy3mI.mjs → sqlite-adapter-B_LNxPA0.mjs} +2 -2
- package/dist/{sqlite-adapter-BXAJy3mI.mjs.map → sqlite-adapter-B_LNxPA0.mjs.map} +1 -1
- package/dist/{sqlite-utils-D_cypcyW.mjs → sqlite-utils-DIOll4P7.mjs} +1 -1
- package/dist/{sqlite-utils-D_cypcyW.mjs.map → sqlite-utils-DIOll4P7.mjs.map} +1 -1
- package/dist/sqlite3.d.mts +1 -1
- package/dist/sqlite3.mjs +1 -1
- package/dist/{standard-sql-CoGqv-iX.mjs → standard-sql-mJt0RHHE.mjs} +1 -1
- package/dist/{standard-sql-CoGqv-iX.mjs.map → standard-sql-mJt0RHHE.mjs.map} +1 -1
- package/dist/{to-many-C1PuFIpf.mjs → to-many-BSipkSbK.mjs} +2 -2
- package/dist/{to-many-C1PuFIpf.mjs.map → to-many-BSipkSbK.mjs.map} +1 -1
- package/dist/{utils-CtFUE8UN.mjs → utils-DjXObbUK.mjs} +2 -2
- package/dist/{utils-CtFUE8UN.mjs.map → utils-DjXObbUK.mjs.map} +1 -1
- package/dist/v-CrJYqdzu.mjs +2 -0
- package/dist/v-CrJYqdzu.mjs.map +1 -0
- package/dist/validation.d.mts +1 -1
- package/dist/validation.mjs +1 -1
- package/dist/{validator-DgffZq9C.mjs → validator-BqzpyNmt.mjs} +2 -2
- package/dist/{validator-DgffZq9C.mjs.map → validator-BqzpyNmt.mjs.map} +1 -1
- package/dist/version-Dus3if78.mjs +2 -0
- package/dist/{version-CXuJzC-q.mjs.map → version-Dus3if78.mjs.map} +1 -1
- package/package.json +16 -15
- package/dist/chain-C7c1YTXD.mjs +0 -2
- package/dist/chain-C7c1YTXD.mjs.map +0 -1
- package/dist/client-_WKrPNmm.mjs +0 -2
- package/dist/client-_WKrPNmm.mjs.map +0 -1
- package/dist/controls-Da-efekX.mjs +0 -2
- package/dist/controls-Da-efekX.mjs.map +0 -1
- package/dist/every-1pKZteeB.mjs +0 -2
- package/dist/identity-oQvIe7u8.mjs +0 -2
- package/dist/identity-oQvIe7u8.mjs.map +0 -1
- package/dist/result-shape-CDgX_vzn.mjs +0 -2
- package/dist/v-CYTUI0H5.mjs +0 -2
- package/dist/v-CYTUI0H5.mjs.map +0 -1
- package/dist/version-CXuJzC-q.mjs +0 -2
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{n as e}from"./chunk-BuuaeEvq.mjs";import{o as t}from"./value-guards-CK9guf2Z.mjs";import{t as n}from"./validation-BamBwne9.mjs";import{A as r,D as i,S as a,b as o,m as s,n as c,w as l,y as u}from"./v-CYTUI0H5.mjs";import{rt as d}from"./geo-point-codec-DyEHMdJg.mjs";import{_ as f,a as p,c as m,l as h,n as g,o as _,u as v,v as y}from"./scalar-S8yMvdmx.mjs";import{t as b}from"./current-oXcxSCBQ.mjs";const x=c.bigint();var S=class BigIntScalar{state;_nativeType;constructor(e,t){this.state=e,this._nativeType=t}nullable(){return new BigIntScalar(v(this,{nullable:!0,hasDefault:!0,default:m(this.state),optional:!0,base:c.bigint({nullable:!0,array:this.state.array,schema:this.state.schema})}),this._nativeType)}array(){return new BigIntScalar(v(this,{array:!0,base:c.bigint({nullable:this.state.nullable,array:!0,schema:this.state.schema})}),this._nativeType)}id(){return new BigIntScalar(v(this,{isId:!0,isUnique:!0}),this._nativeType)}unique(){return new BigIntScalar(v(this,{isUnique:!0}),this._nativeType)}default(e){return new BigIntScalar(v(this,{hasDefault:!0,default:e,optional:!0}),this._nativeType)}schema(e){return new BigIntScalar(v(this,{schema:e,base:c.bigint({nullable:this.state.nullable,array:this.state.array,schema:e})}),this._nativeType)}map(e){return new BigIntScalar(v(this,{columnName:e}),this._nativeType)}increment(){return new BigIntScalar(v(this,{hasDefault:!0,autoGenerate:{kind:`increment`},default:void 0,disallowZero:!0,optional:!0}),this._nativeType)}get"~"(){return{state:this.state,nativeType:this._nativeType}}};const bigInt=e=>new S(p(`bigint`,x),g(`s.bigInt`,e)),C=c.blob();var w=class BlobScalar{state;_nativeType;constructor(e,t){this.state=e,this._nativeType=t}nullable(){return new BlobScalar(v(this,{nullable:!0,hasDefault:!0,default:m(this.state),optional:!0,base:c.blob({nullable:!0})}),this._nativeType)}default(e){return new BlobScalar(v(this,{hasDefault:!0,default:e,optional:!0}),this._nativeType)}map(e){return new BlobScalar(v(this,{columnName:e}),this._nativeType)}array(){throw Error(`Blob scalars don't support array modifier`)}id(){throw Error(`Blob scalars cannot be used as IDs`)}unique(){throw Error(`Blob scalars cannot be unique`)}get"~"(){return{state:this.state,nativeType:this._nativeType}}};const blob=e=>new w(p(`blob`,C),g(`s.blob`,e)),T=c.boolean();var E=class BooleanScalar{state;_nativeType;constructor(e,t){this.state=e,this._nativeType=t}nullable(){return new BooleanScalar(v(this,{nullable:!0,hasDefault:!0,default:m(this.state),optional:!0,base:c.boolean({nullable:!0,array:this.state.array})}),this._nativeType)}array(){return new BooleanScalar(v(this,{array:!0,base:c.boolean({nullable:this.state.nullable,array:!0})}),this._nativeType)}default(e){return new BooleanScalar(v(this,{hasDefault:!0,default:e,optional:!0}),this._nativeType)}map(e){return new BooleanScalar(v(this,{columnName:e}),this._nativeType)}_internal;get"~"(){return this._internal??={state:this.state,nativeType:this._nativeType}}};const boolean=e=>new E(p(`boolean`,T),g(`s.boolean`,e)),D=_(()=>b(`date`)),O=_(()=>b(`date`)),k=c.isoDate();var A=class DateScalar{state;_nativeType;constructor(e,t){this.state=e,this._nativeType=t}nullable(){return new DateScalar(v(this,{nullable:!0,hasDefault:!0,default:m(this.state),optional:!0,base:c.isoDate({nullable:!0,array:this.state.array,schema:this.state.schema})}),this._nativeType)}array(){return(this.state.autoGenerate?.kind===`now`||this.state.autoGenerate?.kind===`updatedAt`)&&h(`s.date`),new DateScalar(v(this,{array:!0,base:c.isoDate({nullable:this.state.nullable,array:!0,schema:this.state.schema})}),this._nativeType)}id(){return new DateScalar(v(this,{isId:!0,isUnique:!0}),this._nativeType)}unique(){return new DateScalar(v(this,{isUnique:!0}),this._nativeType)}schema(e){return new DateScalar(v(this,{schema:e,base:c.isoDate({nullable:this.state.nullable,array:this.state.array,schema:e})}),this._nativeType)}default(e){return new DateScalar(v(this,{hasDefault:!0,default:e,optional:!0}),this._nativeType)}map(e){return new DateScalar(v(this,{columnName:e}),this._nativeType)}now(){return this.state.array&&h(`s.date`),new DateScalar(v(this,{hasDefault:!0,autoGenerate:{kind:`now`},default:D,optional:!0}),this._nativeType)}updatedAt(){return this.state.array&&h(`s.date`),new DateScalar(v(this,{hasDefault:!0,autoGenerate:{kind:`updatedAt`},default:O,optional:!0}),this._nativeType)}get"~"(){return{state:this.state,nativeType:this._nativeType}}};const date=e=>new A(p(`date`,k),g(`s.date`,e)),j=_(()=>b(`datetime`)),M=_(()=>b(`datetime`)),N=c.isoTimestamp();var P=class DateTimeScalar{state;_nativeType;constructor(e,t){this.state=e,this._nativeType=t}nullable(){return new DateTimeScalar(v(this,{nullable:!0,hasDefault:!0,default:m(this.state),optional:!0,base:c.isoTimestamp({nullable:!0,array:this.state.array,schema:this.state.schema})}),this._nativeType)}array(){return(this.state.autoGenerate?.kind===`now`||this.state.autoGenerate?.kind===`updatedAt`)&&h(`s.dateTime`),new DateTimeScalar(v(this,{array:!0,base:c.isoTimestamp({nullable:this.state.nullable,array:!0,schema:this.state.schema})}),this._nativeType)}id(){return new DateTimeScalar(v(this,{isId:!0,isUnique:!0}),this._nativeType)}unique(){return new DateTimeScalar(v(this,{isUnique:!0}),this._nativeType)}schema(e){return new DateTimeScalar(v(this,{schema:e,base:c.isoTimestamp({nullable:this.state.nullable,array:this.state.array,schema:e})}),this._nativeType)}default(e){return new DateTimeScalar(v(this,{hasDefault:!0,default:e,optional:!0}),this._nativeType)}map(e){return new DateTimeScalar(v(this,{columnName:e}),this._nativeType)}now(){return this.state.array&&h(`s.dateTime`),new DateTimeScalar(v(this,{hasDefault:!0,autoGenerate:{kind:`now`},default:j,optional:!0}),this._nativeType)}updatedAt(){return this.state.array&&h(`s.dateTime`),new DateTimeScalar(v(this,{hasDefault:!0,autoGenerate:{kind:`updatedAt`},default:M,optional:!0}),this._nativeType)}withoutTimezone(){return new DateTimeScalar(v(this,{withTimezone:!1}),this._nativeType)}get"~"(){return{state:this.state,nativeType:this._nativeType}}};const dateTime=e=>new P({...p(`datetime`,N),withTimezone:!0},g(`s.dateTime`,e)),F=_(()=>b(`time`)),I=_(()=>b(`time`)),L=c.isoTime();var R=class TimeScalar{state;_nativeType;constructor(e,t){this.state=e,this._nativeType=t}nullable(){return new TimeScalar(v(this,{nullable:!0,hasDefault:!0,default:m(this.state),optional:!0,base:c.isoTime({nullable:!0,array:this.state.array,schema:this.state.schema})}),this._nativeType)}array(){return(this.state.autoGenerate?.kind===`now`||this.state.autoGenerate?.kind===`updatedAt`)&&h(`s.time`),new TimeScalar(v(this,{array:!0,base:c.isoTime({nullable:this.state.nullable,array:!0,schema:this.state.schema})}),this._nativeType)}id(){return new TimeScalar(v(this,{isId:!0,isUnique:!0}),this._nativeType)}unique(){return new TimeScalar(v(this,{isUnique:!0}),this._nativeType)}schema(e){return new TimeScalar(v(this,{schema:e,base:c.isoTime({nullable:this.state.nullable,array:this.state.array,schema:e})}),this._nativeType)}default(e){return new TimeScalar(v(this,{hasDefault:!0,default:e,optional:!0}),this._nativeType)}map(e){return new TimeScalar(v(this,{columnName:e}),this._nativeType)}now(){return this.state.array&&h(`s.time`),new TimeScalar(v(this,{hasDefault:!0,autoGenerate:{kind:`now`},default:F,optional:!0}),this._nativeType)}updatedAt(){return this.state.array&&h(`s.time`),new TimeScalar(v(this,{hasDefault:!0,autoGenerate:{kind:`updatedAt`},default:I,optional:!0}),this._nativeType)}withoutTimezone(){return new TimeScalar(v(this,{withTimezone:!1}),this._nativeType)}get"~"(){return{state:this.state,nativeType:this._nativeType}}};const time=e=>new R({...p(`time`,L),withTimezone:!1},g(`s.time`,e));function refuse(e,t){throw new n({kind:`schema-builder`,builder:`s.decimal`,path:e},[{path:e,message:t}])}function readDecimalDescriptor(e){let n=t(e)?e.precision:void 0,r=t(e)?e.scale:void 0;return typeof n==`number`&&Number.isSafeInteger(n)&&n>=1||refuse(`descriptor.precision`,`'precision' must be an integer between 1 and the maximum safe integer`),typeof r==`number`&&Number.isSafeInteger(r)&&r>=0&&r<=n&&!Object.is(r,-0)||refuse(`descriptor.scale`,`'scale' must be an integer between 0 and precision`),Object.freeze({precision:n,scale:r})}function refuseDecimalListKey(e){let t=`a fixed-decimal list cannot be an ID, a unique field, an index member, a foreign-key member, or a relation identity member`;refuse(e,e===`array`?`A decimal key cannot become a list: ${t}`:`A decimal list cannot be declared '.${e}()': ${t}`)}function normalizeDecimalDefault(e,t){if(typeof e==`function`)return e;let n=d(t,e);return n.issues!==void 0&&refuse(`default`,`The decimal default did not satisfy its field schema`),n.value}var z=class DecimalScalar{state;constructor(e){this.state=e}get descriptor(){return this.state.decimal}nullable(){return new DecimalScalar(v(this,{nullable:!0,hasDefault:!0,default:m(this.state),optional:!0,base:c.decimal({nullable:!0,array:this.state.array,decimal:this.descriptor,schema:this.state.schema})}))}array(){(this.state.isId||this.state.isUnique)&&refuseDecimalListKey(`array`);let e=c.decimal({nullable:this.state.nullable,array:!0,decimal:this.descriptor,schema:this.state.schema}),t=v(this,{array:!0,base:e});return this.state.hasDefault&&typeof this.state.default!=`function`&&Object.defineProperty(t,`default`,{value:normalizeDecimalDefault(this.state.default,e),configurable:!0,enumerable:!0,writable:!0}),new DecimalScalar(t)}id(){return this.state.array&&refuseDecimalListKey(`id`),new DecimalScalar(v(this,{isId:!0,isUnique:!0}))}unique(){return this.state.array&&refuseDecimalListKey(`unique`),new DecimalScalar(v(this,{isUnique:!0}))}default(e){return withValidatedDecimalDefault(this,normalizeDecimalDefault(e,this.state.base))}schema(e){let t=c.decimal({nullable:this.state.nullable,array:this.state.array,decimal:this.descriptor,schema:e}),n=v(this,{schema:e,base:t});return this.state.hasDefault&&typeof this.state.default!=`function`&&Object.defineProperty(n,`default`,{value:normalizeDecimalDefault(this.state.default,t),configurable:!0,enumerable:!0,writable:!0}),new DecimalScalar(n)}map(e){return new DecimalScalar(v(this,{columnName:e}))}get"~"(){return{state:this.state}}};function withValidatedDecimalDefault(e,t){return new z(v(e,{hasDefault:!0,default:t,optional:!0}))}const buildDecimalScalar=e=>{let t=readDecimalDescriptor(e);return new z({...p(`decimal`,c.decimal({decimal:t})),decimal:t})},decimal=e=>buildDecimalScalar(e);var B=class EnumScalar{state;_nativeType;constructor(e,t){this.state=e,this._nativeType=t}get enumValues(){return`values`in this.state.base?this.state.base.values:[]}nullable(){return new EnumScalar(v(this,{nullable:!0,hasDefault:!0,default:m(this.state),optional:!0,base:c.enum(this.enumValues,{nullable:!0,array:this.state.array})}),this._nativeType)}array(){return new EnumScalar(v(this,{array:!0,base:c.enum(this.enumValues,{nullable:this.state.nullable,array:!0})}),this._nativeType)}default(e){return new EnumScalar(v(this,{hasDefault:!0,default:e,optional:!0}),this._nativeType)}map(e){return new EnumScalar(v(this,{columnName:e}),this._nativeType)}name(e){return new EnumScalar(v(this,{enumName:e}),this._nativeType)}get"~"(){return{state:this.state,nativeType:this._nativeType}}};const enumScalar=(e,t)=>new B(p(`enum`,c.enum(e)),g(`s.enum`,t)),V=c.integer();var H=class IntScalar{state;_nativeType;constructor(e,t){this.state=e,this._nativeType=t}nullable(){return new IntScalar(v(this,{nullable:!0,hasDefault:!0,default:m(this.state),optional:!0,base:c.integer({nullable:!0,array:this.state.array,schema:this.state.schema})}),this._nativeType)}array(){return new IntScalar(v(this,{array:!0,base:c.integer({nullable:this.state.nullable,array:!0,schema:this.state.schema})}),this._nativeType)}id(){return new IntScalar(v(this,{isId:!0,isUnique:!0}),this._nativeType)}unique(){return new IntScalar(v(this,{isUnique:!0}),this._nativeType)}default(e){return new IntScalar(v(this,{hasDefault:!0,default:e,optional:!0}),this._nativeType)}schema(e){return new IntScalar(v(this,{schema:e,base:c.integer({nullable:this.state.nullable,array:this.state.array,schema:e})}),this._nativeType)}map(e){return new IntScalar(v(this,{columnName:e}),this._nativeType)}increment(){return new IntScalar(v(this,{hasDefault:!0,autoGenerate:{kind:`increment`},default:void 0,disallowZero:!0,optional:!0}),this._nativeType)}_internal;get"~"(){return this._internal??={state:this.state,nativeType:this._nativeType}}};const int=e=>new H(p(`int`,V),g(`s.int`,e)),U=c.json();var W=class JsonScalar{state;_nativeType;constructor(e,t){this.state=e,this._nativeType=t}nullable(){return new JsonScalar(v(this,{nullable:!0,hasDefault:!0,default:m(this.state),optional:!0,base:c.json({nullable:!0,schema:this.state.schema})}),this._nativeType)}default(e){let t=r(e);if(t===`AnyNull`||t===`DbNull`&&!this.state.nullable)throw new n({kind:`schema-builder`,builder:`s.json`,path:`default`},[{path:`default`,message:`JSON default must name a null this column can store`}]);let a=e===null&&!this.state.nullable?i:e;return new JsonScalar(v(this,{hasDefault:!0,default:a,optional:!0}),this._nativeType)}schema(e){return new JsonScalar(v(this,{schema:e,base:c.json({nullable:this.state.nullable,schema:e})}),this._nativeType)}map(e){return new JsonScalar(v(this,{columnName:e}),this._nativeType)}get"~"(){return{state:this.state,nativeType:this._nativeType}}};const json=e=>new W(p(`json`,U),g(`s.json`,e)),G=c.number();var K=class NumberScalar{state;_nativeType;constructor(e,t){this.state=e,this._nativeType=t}nullable(){return new NumberScalar(v(this,{nullable:!0,hasDefault:!0,default:m(this.state),optional:!0,base:c.number({nullable:!0,array:this.state.array,schema:this.state.schema})}),this._nativeType)}array(){return new NumberScalar(v(this,{array:!0,base:c.number({nullable:this.state.nullable,array:!0,schema:this.state.schema})}),this._nativeType)}id(){return new NumberScalar(v(this,{isId:!0,isUnique:!0}),this._nativeType)}unique(){return new NumberScalar(v(this,{isUnique:!0}),this._nativeType)}default(e){return new NumberScalar(v(this,{hasDefault:!0,default:e,optional:!0}),this._nativeType)}schema(e){return new NumberScalar(v(this,{schema:e,base:c.number({nullable:this.state.nullable,array:this.state.array,schema:e})}),this._nativeType)}map(e){return new NumberScalar(v(this,{columnName:e}),this._nativeType)}get"~"(){return{state:this.state,nativeType:this._nativeType}}};const number=e=>new K(p(`number`,G),g(`s.number`,e)),q=c.point();var J=class PointScalar{state;constructor(e){this.state=e}nullable(){return new PointScalar(v(this,{nullable:!0,hasDefault:!0,default:m(this.state),optional:!0,base:c.point({nullable:!0})}))}default(e){return new PointScalar(v(this,{hasDefault:!0,default:normalizePointDefault(e,this.state.base),optional:!0}))}map(e){return new PointScalar(v(this,{columnName:e}))}get"~"(){return{state:this.state}}};function normalizePointDefault(e,t){if(typeof e==`function`)return e;let r=d(t,e);if(!r.issues)return r.value;throw new n({kind:`schema-builder`,builder:`s.point`,path:`default`},r.issues.map(e=>({path:e.path?.join(`.`)??`default`,message:e.message})))}function point(...e){if(e.length!==0)throw new n({kind:`schema-builder`,builder:`s.point`,path:`arguments`},[{path:`arguments`,message:`s.point() takes no native type or options`}]);return new J(p(`point`,q))}const Y=c.vector();var X=class VectorScalar{state;_nativeType;constructor(e,t){this.state=e,this._nativeType=t}nullable(){return new VectorScalar(v(this,{nullable:!0,hasDefault:!0,default:m(this.state),optional:!0,base:c.vector(this.state.dimension,{nullable:!0})}),this._nativeType)}default(e){return new VectorScalar(v(this,{hasDefault:!0,default:e,optional:!0}),this._nativeType)}map(e){return new VectorScalar(v(this,{columnName:e}),this._nativeType)}dimension(e){if(!Number.isSafeInteger(e)||e<=0)throw new n({kind:`schema-builder`,builder:`s.vector`,path:`dimension`},[{path:`dimension`,message:`Vector dimension must be a positive safe integer`}]);return new VectorScalar(v(this,{dimension:e,base:c.vector(e,{nullable:this.state.nullable})}),this._nativeType)}get"~"(){return{state:this.state,nativeType:this._nativeType}}};const vector=e=>new X(p(`vector`,Y),g(`s.vector`,e));var Z=class ModelToMany{#e;#t;constructor(e){this.#e=Object.freeze(e),this.#t=Object.freeze({state:this.#e,settleTarget:s(()=>this.#e.target.getter)})}name(e){return new ModelToMany({...this.#e,name:a(`s.toMany`,e)})}through(e){return this.#n({...this.#e.junction,table:o(`through`,e)})}source(e){return this.#n({...this.#e.junction,source:o(`source`,e)})}target(e){return this.#n({...this.#e.junction,target:o(`target`,e)})}onDelete(e){return this.#n({...this.#e.junction,onDelete:u(`onDelete`,e)})}onUpdate(e){return this.#n({...this.#e.junction,onUpdate:u(`onUpdate`,e)})}#n(e){return new ModelToMany({...this.#e,junction:Object.freeze(e)})}get"~"(){return this.#t}};function toMany(e,t){return typeof e==`function`?(arguments.length>1&&l(`s.toMany`,`options`,`A model-target relation takes exactly one argument`),new Z({kind:`relation`,cardinality:`many`,target:{kind:`model`,getter:e}})):y({kind:`relation`,cardinality:`many`,target:{kind:`variants`,entries:f(`s.toMany`,e,t)}})}export{bigInt as _,json as a,z as c,withValidatedDecimalDefault as d,time as f,blob as g,boolean as h,number as i,buildDecimalScalar as l,date as m,vector as n,int as o,dateTime as p,point as r,enumScalar as s,toMany as t,decimal as u};
|
|
2
|
-
//# sourceMappingURL=to-many-
|
|
1
|
+
import{n as e}from"./chunk-BuuaeEvq.mjs";import{o as t}from"./value-guards-CK9guf2Z.mjs";import{t as n}from"./validation-BamBwne9.mjs";import{A as r,D as i,S as a,b as o,m as s,n as c,w as l,y as u}from"./v-CrJYqdzu.mjs";import{rt as d}from"./geo-point-codec-DyEHMdJg.mjs";import{_ as f,a as p,c as m,l as h,n as g,o as _,u as v,v as y}from"./scalar-CqqZ6jWd.mjs";import{t as b}from"./current-oXcxSCBQ.mjs";const x=c.bigint();var S=class BigIntScalar{state;_nativeType;constructor(e,t){this.state=e,this._nativeType=t}nullable(){return new BigIntScalar(v(this,{nullable:!0,hasDefault:!0,default:m(this.state),optional:!0,base:c.bigint({nullable:!0,array:this.state.array,schema:this.state.schema})}),this._nativeType)}array(){return new BigIntScalar(v(this,{array:!0,base:c.bigint({nullable:this.state.nullable,array:!0,schema:this.state.schema})}),this._nativeType)}id(){return new BigIntScalar(v(this,{isId:!0,isUnique:!0}),this._nativeType)}unique(){return new BigIntScalar(v(this,{isUnique:!0}),this._nativeType)}default(e){return new BigIntScalar(v(this,{hasDefault:!0,default:e,optional:!0}),this._nativeType)}schema(e){return new BigIntScalar(v(this,{schema:e,base:c.bigint({nullable:this.state.nullable,array:this.state.array,schema:e})}),this._nativeType)}map(e){return new BigIntScalar(v(this,{columnName:e}),this._nativeType)}increment(){return new BigIntScalar(v(this,{hasDefault:!0,autoGenerate:{kind:`increment`},default:void 0,disallowZero:!0,optional:!0}),this._nativeType)}get"~"(){return{state:this.state,nativeType:this._nativeType}}};const bigInt=e=>new S(p(`bigint`,x),g(`s.bigInt`,e)),C=c.blob();var w=class BlobScalar{state;_nativeType;constructor(e,t){this.state=e,this._nativeType=t}nullable(){return new BlobScalar(v(this,{nullable:!0,hasDefault:!0,default:m(this.state),optional:!0,base:c.blob({nullable:!0})}),this._nativeType)}default(e){return new BlobScalar(v(this,{hasDefault:!0,default:e,optional:!0}),this._nativeType)}map(e){return new BlobScalar(v(this,{columnName:e}),this._nativeType)}array(){throw Error(`Blob scalars don't support array modifier`)}id(){throw Error(`Blob scalars cannot be used as IDs`)}unique(){throw Error(`Blob scalars cannot be unique`)}get"~"(){return{state:this.state,nativeType:this._nativeType}}};const blob=e=>new w(p(`blob`,C),g(`s.blob`,e)),T=c.boolean();var E=class BooleanScalar{state;_nativeType;constructor(e,t){this.state=e,this._nativeType=t}nullable(){return new BooleanScalar(v(this,{nullable:!0,hasDefault:!0,default:m(this.state),optional:!0,base:c.boolean({nullable:!0,array:this.state.array})}),this._nativeType)}array(){return new BooleanScalar(v(this,{array:!0,base:c.boolean({nullable:this.state.nullable,array:!0})}),this._nativeType)}default(e){return new BooleanScalar(v(this,{hasDefault:!0,default:e,optional:!0}),this._nativeType)}map(e){return new BooleanScalar(v(this,{columnName:e}),this._nativeType)}_internal;get"~"(){return this._internal??={state:this.state,nativeType:this._nativeType}}};const boolean=e=>new E(p(`boolean`,T),g(`s.boolean`,e)),D=_(()=>b(`date`)),O=_(()=>b(`date`)),k=c.isoDate();var A=class DateScalar{state;_nativeType;constructor(e,t){this.state=e,this._nativeType=t}nullable(){return new DateScalar(v(this,{nullable:!0,hasDefault:!0,default:m(this.state),optional:!0,base:c.isoDate({nullable:!0,array:this.state.array,schema:this.state.schema})}),this._nativeType)}array(){return(this.state.autoGenerate?.kind===`now`||this.state.autoGenerate?.kind===`updatedAt`)&&h(`s.date`),new DateScalar(v(this,{array:!0,base:c.isoDate({nullable:this.state.nullable,array:!0,schema:this.state.schema})}),this._nativeType)}id(){return new DateScalar(v(this,{isId:!0,isUnique:!0}),this._nativeType)}unique(){return new DateScalar(v(this,{isUnique:!0}),this._nativeType)}schema(e){return new DateScalar(v(this,{schema:e,base:c.isoDate({nullable:this.state.nullable,array:this.state.array,schema:e})}),this._nativeType)}default(e){return new DateScalar(v(this,{hasDefault:!0,default:e,optional:!0}),this._nativeType)}map(e){return new DateScalar(v(this,{columnName:e}),this._nativeType)}now(){return this.state.array&&h(`s.date`),new DateScalar(v(this,{hasDefault:!0,autoGenerate:{kind:`now`},default:D,optional:!0}),this._nativeType)}updatedAt(){return this.state.array&&h(`s.date`),new DateScalar(v(this,{hasDefault:!0,autoGenerate:{kind:`updatedAt`},default:O,optional:!0}),this._nativeType)}get"~"(){return{state:this.state,nativeType:this._nativeType}}};const date=e=>new A(p(`date`,k),g(`s.date`,e)),j=_(()=>b(`datetime`)),M=_(()=>b(`datetime`)),N=c.isoTimestamp();var P=class DateTimeScalar{state;_nativeType;constructor(e,t){this.state=e,this._nativeType=t}nullable(){return new DateTimeScalar(v(this,{nullable:!0,hasDefault:!0,default:m(this.state),optional:!0,base:c.isoTimestamp({nullable:!0,array:this.state.array,schema:this.state.schema})}),this._nativeType)}array(){return(this.state.autoGenerate?.kind===`now`||this.state.autoGenerate?.kind===`updatedAt`)&&h(`s.dateTime`),new DateTimeScalar(v(this,{array:!0,base:c.isoTimestamp({nullable:this.state.nullable,array:!0,schema:this.state.schema})}),this._nativeType)}id(){return new DateTimeScalar(v(this,{isId:!0,isUnique:!0}),this._nativeType)}unique(){return new DateTimeScalar(v(this,{isUnique:!0}),this._nativeType)}schema(e){return new DateTimeScalar(v(this,{schema:e,base:c.isoTimestamp({nullable:this.state.nullable,array:this.state.array,schema:e})}),this._nativeType)}default(e){return new DateTimeScalar(v(this,{hasDefault:!0,default:e,optional:!0}),this._nativeType)}map(e){return new DateTimeScalar(v(this,{columnName:e}),this._nativeType)}now(){return this.state.array&&h(`s.dateTime`),new DateTimeScalar(v(this,{hasDefault:!0,autoGenerate:{kind:`now`},default:j,optional:!0}),this._nativeType)}updatedAt(){return this.state.array&&h(`s.dateTime`),new DateTimeScalar(v(this,{hasDefault:!0,autoGenerate:{kind:`updatedAt`},default:M,optional:!0}),this._nativeType)}withoutTimezone(){return new DateTimeScalar(v(this,{withTimezone:!1}),this._nativeType)}get"~"(){return{state:this.state,nativeType:this._nativeType}}};const dateTime=e=>new P({...p(`datetime`,N),withTimezone:!0},g(`s.dateTime`,e)),F=_(()=>b(`time`)),I=_(()=>b(`time`)),L=c.isoTime();var R=class TimeScalar{state;_nativeType;constructor(e,t){this.state=e,this._nativeType=t}nullable(){return new TimeScalar(v(this,{nullable:!0,hasDefault:!0,default:m(this.state),optional:!0,base:c.isoTime({nullable:!0,array:this.state.array,schema:this.state.schema})}),this._nativeType)}array(){return(this.state.autoGenerate?.kind===`now`||this.state.autoGenerate?.kind===`updatedAt`)&&h(`s.time`),new TimeScalar(v(this,{array:!0,base:c.isoTime({nullable:this.state.nullable,array:!0,schema:this.state.schema})}),this._nativeType)}id(){return new TimeScalar(v(this,{isId:!0,isUnique:!0}),this._nativeType)}unique(){return new TimeScalar(v(this,{isUnique:!0}),this._nativeType)}schema(e){return new TimeScalar(v(this,{schema:e,base:c.isoTime({nullable:this.state.nullable,array:this.state.array,schema:e})}),this._nativeType)}default(e){return new TimeScalar(v(this,{hasDefault:!0,default:e,optional:!0}),this._nativeType)}map(e){return new TimeScalar(v(this,{columnName:e}),this._nativeType)}now(){return this.state.array&&h(`s.time`),new TimeScalar(v(this,{hasDefault:!0,autoGenerate:{kind:`now`},default:F,optional:!0}),this._nativeType)}updatedAt(){return this.state.array&&h(`s.time`),new TimeScalar(v(this,{hasDefault:!0,autoGenerate:{kind:`updatedAt`},default:I,optional:!0}),this._nativeType)}withoutTimezone(){return new TimeScalar(v(this,{withTimezone:!1}),this._nativeType)}get"~"(){return{state:this.state,nativeType:this._nativeType}}};const time=e=>new R({...p(`time`,L),withTimezone:!1},g(`s.time`,e));function refuse(e,t){throw new n({kind:`schema-builder`,builder:`s.decimal`,path:e},[{path:e,message:t}])}function readDecimalDescriptor(e){let n=t(e)?e.precision:void 0,r=t(e)?e.scale:void 0;return typeof n==`number`&&Number.isSafeInteger(n)&&n>=1||refuse(`descriptor.precision`,`'precision' must be an integer between 1 and the maximum safe integer`),typeof r==`number`&&Number.isSafeInteger(r)&&r>=0&&r<=n&&!Object.is(r,-0)||refuse(`descriptor.scale`,`'scale' must be an integer between 0 and precision`),Object.freeze({precision:n,scale:r})}function refuseDecimalListKey(e){let t=`a fixed-decimal list cannot be an ID, a unique field, an index member, a foreign-key member, or a relation identity member`;refuse(e,e===`array`?`A decimal key cannot become a list: ${t}`:`A decimal list cannot be declared '.${e}()': ${t}`)}function normalizeDecimalDefault(e,t){if(typeof e==`function`)return e;let n=d(t,e);return n.issues!==void 0&&refuse(`default`,`The decimal default did not satisfy its field schema`),n.value}var z=class DecimalScalar{state;constructor(e){this.state=e}get descriptor(){return this.state.decimal}nullable(){return new DecimalScalar(v(this,{nullable:!0,hasDefault:!0,default:m(this.state),optional:!0,base:c.decimal({nullable:!0,array:this.state.array,decimal:this.descriptor,schema:this.state.schema})}))}array(){(this.state.isId||this.state.isUnique)&&refuseDecimalListKey(`array`);let e=c.decimal({nullable:this.state.nullable,array:!0,decimal:this.descriptor,schema:this.state.schema}),t=v(this,{array:!0,base:e});return this.state.hasDefault&&typeof this.state.default!=`function`&&Object.defineProperty(t,`default`,{value:normalizeDecimalDefault(this.state.default,e),configurable:!0,enumerable:!0,writable:!0}),new DecimalScalar(t)}id(){return this.state.array&&refuseDecimalListKey(`id`),new DecimalScalar(v(this,{isId:!0,isUnique:!0}))}unique(){return this.state.array&&refuseDecimalListKey(`unique`),new DecimalScalar(v(this,{isUnique:!0}))}default(e){return withValidatedDecimalDefault(this,normalizeDecimalDefault(e,this.state.base))}schema(e){let t=c.decimal({nullable:this.state.nullable,array:this.state.array,decimal:this.descriptor,schema:e}),n=v(this,{schema:e,base:t});return this.state.hasDefault&&typeof this.state.default!=`function`&&Object.defineProperty(n,`default`,{value:normalizeDecimalDefault(this.state.default,t),configurable:!0,enumerable:!0,writable:!0}),new DecimalScalar(n)}map(e){return new DecimalScalar(v(this,{columnName:e}))}get"~"(){return{state:this.state}}};function withValidatedDecimalDefault(e,t){return new z(v(e,{hasDefault:!0,default:t,optional:!0}))}const buildDecimalScalar=e=>{let t=readDecimalDescriptor(e);return new z({...p(`decimal`,c.decimal({decimal:t})),decimal:t})},decimal=e=>buildDecimalScalar(e);var B=class EnumScalar{state;_nativeType;constructor(e,t){this.state=e,this._nativeType=t}get enumValues(){return`values`in this.state.base?this.state.base.values:[]}nullable(){return new EnumScalar(v(this,{nullable:!0,hasDefault:!0,default:m(this.state),optional:!0,base:c.enum(this.enumValues,{nullable:!0,array:this.state.array})}),this._nativeType)}array(){return new EnumScalar(v(this,{array:!0,base:c.enum(this.enumValues,{nullable:this.state.nullable,array:!0})}),this._nativeType)}default(e){return new EnumScalar(v(this,{hasDefault:!0,default:e,optional:!0}),this._nativeType)}map(e){return new EnumScalar(v(this,{columnName:e}),this._nativeType)}name(e){return new EnumScalar(v(this,{enumName:e}),this._nativeType)}get"~"(){return{state:this.state,nativeType:this._nativeType}}};const enumScalar=(e,t)=>new B(p(`enum`,c.enum(e)),g(`s.enum`,t)),V=c.integer();var H=class IntScalar{state;_nativeType;constructor(e,t){this.state=e,this._nativeType=t}nullable(){return new IntScalar(v(this,{nullable:!0,hasDefault:!0,default:m(this.state),optional:!0,base:c.integer({nullable:!0,array:this.state.array,schema:this.state.schema})}),this._nativeType)}array(){return new IntScalar(v(this,{array:!0,base:c.integer({nullable:this.state.nullable,array:!0,schema:this.state.schema})}),this._nativeType)}id(){return new IntScalar(v(this,{isId:!0,isUnique:!0}),this._nativeType)}unique(){return new IntScalar(v(this,{isUnique:!0}),this._nativeType)}default(e){return new IntScalar(v(this,{hasDefault:!0,default:e,optional:!0}),this._nativeType)}schema(e){return new IntScalar(v(this,{schema:e,base:c.integer({nullable:this.state.nullable,array:this.state.array,schema:e})}),this._nativeType)}map(e){return new IntScalar(v(this,{columnName:e}),this._nativeType)}increment(){return new IntScalar(v(this,{hasDefault:!0,autoGenerate:{kind:`increment`},default:void 0,disallowZero:!0,optional:!0}),this._nativeType)}_internal;get"~"(){return this._internal??={state:this.state,nativeType:this._nativeType}}};const int=e=>new H(p(`int`,V),g(`s.int`,e)),U=c.json();var W=class JsonScalar{state;_nativeType;constructor(e,t){this.state=e,this._nativeType=t}nullable(){return new JsonScalar(v(this,{nullable:!0,hasDefault:!0,default:m(this.state),optional:!0,base:c.json({nullable:!0,schema:this.state.schema})}),this._nativeType)}default(e){let t=r(e);if(t===`AnyNull`||t===`DbNull`&&!this.state.nullable)throw new n({kind:`schema-builder`,builder:`s.json`,path:`default`},[{path:`default`,message:`JSON default must name a null this column can store`}]);let a=e===null&&!this.state.nullable?i:e;return new JsonScalar(v(this,{hasDefault:!0,default:a,optional:!0}),this._nativeType)}schema(e){return new JsonScalar(v(this,{schema:e,base:c.json({nullable:this.state.nullable,schema:e})}),this._nativeType)}map(e){return new JsonScalar(v(this,{columnName:e}),this._nativeType)}get"~"(){return{state:this.state,nativeType:this._nativeType}}};const json=e=>new W(p(`json`,U),g(`s.json`,e)),G=c.number();var K=class NumberScalar{state;_nativeType;constructor(e,t){this.state=e,this._nativeType=t}nullable(){return new NumberScalar(v(this,{nullable:!0,hasDefault:!0,default:m(this.state),optional:!0,base:c.number({nullable:!0,array:this.state.array,schema:this.state.schema})}),this._nativeType)}array(){return new NumberScalar(v(this,{array:!0,base:c.number({nullable:this.state.nullable,array:!0,schema:this.state.schema})}),this._nativeType)}id(){return new NumberScalar(v(this,{isId:!0,isUnique:!0}),this._nativeType)}unique(){return new NumberScalar(v(this,{isUnique:!0}),this._nativeType)}default(e){return new NumberScalar(v(this,{hasDefault:!0,default:e,optional:!0}),this._nativeType)}schema(e){return new NumberScalar(v(this,{schema:e,base:c.number({nullable:this.state.nullable,array:this.state.array,schema:e})}),this._nativeType)}map(e){return new NumberScalar(v(this,{columnName:e}),this._nativeType)}get"~"(){return{state:this.state,nativeType:this._nativeType}}};const number=e=>new K(p(`number`,G),g(`s.number`,e)),q=c.point();var J=class PointScalar{state;constructor(e){this.state=e}nullable(){return new PointScalar(v(this,{nullable:!0,hasDefault:!0,default:m(this.state),optional:!0,base:c.point({nullable:!0})}))}default(e){return new PointScalar(v(this,{hasDefault:!0,default:normalizePointDefault(e,this.state.base),optional:!0}))}map(e){return new PointScalar(v(this,{columnName:e}))}get"~"(){return{state:this.state}}};function normalizePointDefault(e,t){if(typeof e==`function`)return e;let r=d(t,e);if(!r.issues)return r.value;throw new n({kind:`schema-builder`,builder:`s.point`,path:`default`},r.issues.map(e=>({path:e.path?.join(`.`)??`default`,message:e.message})))}function point(...e){if(e.length!==0)throw new n({kind:`schema-builder`,builder:`s.point`,path:`arguments`},[{path:`arguments`,message:`s.point() takes no native type or options`}]);return new J(p(`point`,q))}const Y=c.vector();var X=class VectorScalar{state;_nativeType;constructor(e,t){this.state=e,this._nativeType=t}nullable(){return new VectorScalar(v(this,{nullable:!0,hasDefault:!0,default:m(this.state),optional:!0,base:c.vector(this.state.dimension,{nullable:!0})}),this._nativeType)}default(e){return new VectorScalar(v(this,{hasDefault:!0,default:e,optional:!0}),this._nativeType)}map(e){return new VectorScalar(v(this,{columnName:e}),this._nativeType)}dimension(e){if(!Number.isSafeInteger(e)||e<=0)throw new n({kind:`schema-builder`,builder:`s.vector`,path:`dimension`},[{path:`dimension`,message:`Vector dimension must be a positive safe integer`}]);return new VectorScalar(v(this,{dimension:e,base:c.vector(e,{nullable:this.state.nullable})}),this._nativeType)}get"~"(){return{state:this.state,nativeType:this._nativeType}}};const vector=e=>new X(p(`vector`,Y),g(`s.vector`,e));var Z=class ModelToMany{#e;#t;constructor(e){this.#e=Object.freeze(e),this.#t=Object.freeze({state:this.#e,settleTarget:s(()=>this.#e.target.getter)})}name(e){return new ModelToMany({...this.#e,name:a(`s.toMany`,e)})}through(e){return this.#n({...this.#e.junction,table:o(`through`,e)})}source(e){return this.#n({...this.#e.junction,source:o(`source`,e)})}target(e){return this.#n({...this.#e.junction,target:o(`target`,e)})}onDelete(e){return this.#n({...this.#e.junction,onDelete:u(`onDelete`,e)})}onUpdate(e){return this.#n({...this.#e.junction,onUpdate:u(`onUpdate`,e)})}#n(e){return new ModelToMany({...this.#e,junction:Object.freeze(e)})}get"~"(){return this.#t}};function toMany(e,t){return typeof e==`function`?(arguments.length>1&&l(`s.toMany`,`options`,`A model-target relation takes exactly one argument`),new Z({kind:`relation`,cardinality:`many`,target:{kind:`model`,getter:e}})):y({kind:`relation`,cardinality:`many`,target:{kind:`variants`,entries:f(`s.toMany`,e,t)}})}export{bigInt as _,json as a,z as c,withValidatedDecimalDefault as d,time as f,blob as g,boolean as h,number as i,buildDecimalScalar as l,date as m,vector as n,int as o,dateTime as p,point as r,enumScalar as s,toMany as t,decimal as u};
|
|
2
|
+
//# sourceMappingURL=to-many-BSipkSbK.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"to-many-C1PuFIpf.mjs","names":["v","v","v","defaultNow","defaultUpdatedAt","v","defaultNow","defaultUpdatedAt","v","v","v","v","v","v","v","v","v","#state","#internal","#withJunction"],"sources":["../src/schema/scalars/bigint/scalar.ts","../src/schema/scalars/blob/scalar.ts","../src/schema/scalars/boolean/scalar.ts","../src/schema/scalars/datetime/date-scalar.ts","../src/schema/scalars/datetime/scalar.ts","../src/schema/scalars/datetime/time-scalar.ts","../src/schema/scalars/decimal/descriptor.ts","../src/schema/scalars/decimal/scalar.ts","../src/schema/scalars/enum/scalar.ts","../src/schema/scalars/int/scalar.ts","../src/schema/scalars/json/scalar.ts","../src/schema/scalars/number/scalar.ts","../src/schema/scalars/point/scalar.ts","../src/schema/scalars/vector/scalar.ts","../src/schema/relation/to-many.ts"],"sourcesContent":["// BigInt Scalar\n// Standalone scalar class with State generic pattern\n\nimport type { StandardSchemaV1 } from \"@standard-schema/spec\";\nimport v from \"@validation/primitives/v\";\nimport {\n createDefaultState,\n type DefaultValueInput,\n nullableDefault,\n type ScalarState,\n updateState,\n} from \"../common\";\nimport { admitNativeType } from \"../native-catalog\";\nimport type {\n ExactNativeTypeMap,\n NativeDialect,\n NativeTypeArgument,\n NativeTypeDeclaration,\n} from \"../native-types\";\n\nconst bigIntBase = v.bigint();\n\nexport class BigIntScalar<State extends ScalarState<\"bigint\">> {\n private readonly state: State;\n private readonly _nativeType?: NativeTypeDeclaration | undefined;\n\n constructor(state: State, _nativeType?: NativeTypeDeclaration) {\n this.state = state;\n this._nativeType = _nativeType;\n }\n\n nullable() {\n return new BigIntScalar(\n updateState(this, {\n nullable: true,\n hasDefault: true,\n default: nullableDefault(this.state),\n optional: true,\n base: v.bigint<{\n nullable: true;\n array: State[\"array\"];\n schema: State[\"schema\"];\n }>({\n nullable: true,\n array: this.state.array,\n schema: this.state.schema,\n }),\n }),\n this._nativeType\n );\n }\n\n array() {\n return new BigIntScalar(\n updateState(this, {\n array: true,\n base: v.bigint<{\n nullable: State[\"nullable\"];\n array: true;\n schema: State[\"schema\"];\n }>({\n nullable: this.state.nullable,\n array: true,\n schema: this.state.schema,\n }),\n }),\n this._nativeType\n );\n }\n\n id() {\n return new BigIntScalar(\n updateState(this, { isId: true, isUnique: true }),\n this._nativeType\n );\n }\n\n unique() {\n return new BigIntScalar(\n updateState(this, { isUnique: true }),\n this._nativeType\n );\n }\n\n default<V extends DefaultValueInput<State>>(value: V) {\n return new BigIntScalar(\n updateState(this, { hasDefault: true, default: value, optional: true }),\n this._nativeType\n );\n }\n\n schema<S extends StandardSchemaV1<bigint>>(schema: S) {\n return new BigIntScalar(\n updateState(this, {\n schema,\n base: v.bigint<{\n nullable: State[\"nullable\"];\n array: State[\"array\"];\n schema: S;\n }>({\n nullable: this.state.nullable,\n array: this.state.array,\n schema,\n }),\n }),\n this._nativeType\n );\n }\n\n map(columnName: string) {\n return new BigIntScalar(\n updateState(this, { columnName }),\n this._nativeType\n );\n }\n\n increment() {\n return new BigIntScalar(\n updateState(this, {\n hasDefault: true,\n autoGenerate: { kind: \"increment\" },\n default: undefined,\n disallowZero: true,\n optional: true,\n }),\n this._nativeType\n );\n }\n\n get [\"~\"]() {\n return {\n state: this.state,\n nativeType: this._nativeType,\n };\n }\n}\n\nexport const bigInt = <\n Db extends NativeDialect = never,\n const Given extends ExactNativeTypeMap<Given> = never,\n>(\n nativeType?: NativeTypeArgument<Db, Given>\n) =>\n new BigIntScalar(\n createDefaultState(\"bigint\", bigIntBase),\n admitNativeType(\"s.bigInt\", nativeType)\n );\n","// Blob Scalar\n// Standalone scalar class with State generic pattern\n\nimport v from \"@validation/primitives/v\";\nimport {\n createDefaultState,\n type DefaultValueInput,\n nullableDefault,\n type ScalarState,\n updateState,\n} from \"../common\";\nimport { admitNativeType } from \"../native-catalog\";\nimport type {\n ExactNativeTypeMap,\n NativeDialect,\n NativeTypeArgument,\n NativeTypeDeclaration,\n} from \"../native-types\";\n\nconst blobBase = v.blob();\n\nexport class BlobScalar<State extends ScalarState<\"blob\">> {\n private readonly state: State;\n private readonly _nativeType?: NativeTypeDeclaration | undefined;\n\n constructor(state: State, _nativeType?: NativeTypeDeclaration) {\n this.state = state;\n this._nativeType = _nativeType;\n }\n\n nullable() {\n return new BlobScalar(\n updateState(this, {\n nullable: true,\n hasDefault: true,\n default: nullableDefault(this.state),\n optional: true,\n base: v.blob<{\n nullable: true;\n }>({\n nullable: true,\n }),\n }),\n this._nativeType\n );\n }\n\n default<V extends DefaultValueInput<State>>(value: V) {\n return new BlobScalar(\n updateState(this, {\n hasDefault: true,\n default: value,\n optional: true,\n }),\n this._nativeType\n );\n }\n\n /**\n * Maps this scalar to a custom column name in the database\n */\n map(columnName: string) {\n return new BlobScalar(updateState(this, { columnName }), this._nativeType);\n }\n\n // Blob scalars don't support array(), id(), or unique()\n array(): never {\n throw new Error(\"Blob scalars don't support array modifier\");\n }\n\n id(): never {\n throw new Error(\"Blob scalars cannot be used as IDs\");\n }\n\n unique(): never {\n throw new Error(\"Blob scalars cannot be unique\");\n }\n\n get [\"~\"]() {\n return {\n state: this.state,\n nativeType: this._nativeType,\n };\n }\n}\n\nexport const blob = <\n Db extends NativeDialect = never,\n const Given extends ExactNativeTypeMap<Given> = never,\n>(\n nativeType?: NativeTypeArgument<Db, Given>\n) =>\n new BlobScalar(\n createDefaultState(\"blob\", blobBase),\n admitNativeType(\"s.blob\", nativeType)\n );\n","// Boolean Scalar\n// Standalone scalar class with State generic pattern\n\nimport v from \"@validation/primitives/v\";\nimport {\n createDefaultState,\n type DefaultValueInput,\n nullableDefault,\n type ScalarState,\n updateState,\n} from \"../common\";\nimport { admitNativeType } from \"../native-catalog\";\nimport type {\n ExactNativeTypeMap,\n NativeDialect,\n NativeTypeArgument,\n NativeTypeDeclaration,\n} from \"../native-types\";\n\nconst booleanBase = v.boolean();\n\nexport class BooleanScalar<State extends ScalarState<\"boolean\">> {\n private readonly state: State;\n private readonly _nativeType?: NativeTypeDeclaration | undefined;\n\n constructor(state: State, _nativeType?: NativeTypeDeclaration) {\n this.state = state;\n this._nativeType = _nativeType;\n }\n\n nullable() {\n return new BooleanScalar(\n updateState(this, {\n nullable: true,\n hasDefault: true,\n default: nullableDefault(this.state),\n optional: true,\n base: v.boolean<{\n nullable: true;\n array: State[\"array\"];\n }>({\n nullable: true,\n array: this.state.array,\n }),\n }),\n this._nativeType\n );\n }\n\n array() {\n return new BooleanScalar(\n updateState(this, {\n array: true,\n base: v.boolean<{\n nullable: State[\"nullable\"];\n array: true;\n }>({\n nullable: this.state.nullable,\n array: true,\n }),\n }),\n this._nativeType\n );\n }\n\n default<V extends DefaultValueInput<State>>(value: V) {\n return new BooleanScalar(\n updateState(this, {\n hasDefault: true,\n default: value,\n optional: true,\n }),\n this._nativeType\n );\n }\n\n /**\n * Maps this scalar to a custom column name in the database\n */\n map(columnName: string) {\n return new BooleanScalar(\n updateState(this, { columnName }),\n this._nativeType\n );\n }\n\n private _internal?: {\n state: State;\n nativeType: NativeTypeDeclaration | undefined;\n };\n\n get [\"~\"]() {\n return (this._internal ??= {\n state: this.state,\n nativeType: this._nativeType,\n });\n }\n}\n\nexport const boolean = <\n Db extends NativeDialect = never,\n const Given extends ExactNativeTypeMap<Given> = never,\n>(\n nativeType?: NativeTypeArgument<Db, Given>\n) =>\n new BooleanScalar(\n createDefaultState(\"boolean\", booleanBase),\n admitNativeType(\"s.boolean\", nativeType)\n );\n","// Date Scalar\n// Standalone scalar class with State generic pattern\n\nimport type { StandardSchemaV1 } from \"@standard-schema/spec\";\nimport v from \"@validation/primitives/v\";\nimport {\n createDefaultState,\n type DefaultValueInput,\n generatorDefault,\n nullableDefault,\n refuseListGenerator,\n type ScalarState,\n updateState,\n} from \"../common\";\nimport { admitNativeType } from \"../native-catalog\";\nimport type {\n ExactNativeTypeMap,\n NativeDialect,\n NativeTypeArgument,\n NativeTypeDeclaration,\n} from \"../native-types\";\nimport { currentTemporalValue } from \"./current\";\n\nconst defaultNow = generatorDefault(() => currentTemporalValue(\"date\"));\nconst defaultUpdatedAt = generatorDefault(() => currentTemporalValue(\"date\"));\nconst dateBase = v.isoDate();\n\nexport class DateScalar<State extends ScalarState<\"date\">> {\n private readonly state: State;\n private readonly _nativeType?: NativeTypeDeclaration | undefined;\n\n constructor(state: State, _nativeType?: NativeTypeDeclaration) {\n this.state = state;\n this._nativeType = _nativeType;\n }\n\n nullable() {\n return new DateScalar(\n updateState(this, {\n nullable: true,\n hasDefault: true,\n default: nullableDefault(this.state),\n optional: true,\n base: v.isoDate<{\n nullable: true;\n array: State[\"array\"];\n schema: State[\"schema\"];\n }>({\n nullable: true,\n array: this.state.array,\n schema: this.state.schema,\n }),\n }),\n this._nativeType\n );\n }\n\n array() {\n if (\n this.state.autoGenerate?.kind === \"now\" ||\n this.state.autoGenerate?.kind === \"updatedAt\"\n )\n refuseListGenerator(\"s.date\");\n return new DateScalar(\n updateState(this, {\n array: true,\n base: v.isoDate<{\n nullable: State[\"nullable\"];\n array: true;\n schema: State[\"schema\"];\n }>({\n nullable: this.state.nullable,\n array: true,\n schema: this.state.schema,\n }),\n }),\n this._nativeType\n );\n }\n\n id() {\n return new DateScalar(\n updateState(this, { isId: true, isUnique: true }),\n this._nativeType\n );\n }\n\n unique() {\n return new DateScalar(\n updateState(this, { isUnique: true }),\n this._nativeType\n );\n }\n\n schema<S extends StandardSchemaV1<string>>(schema: S) {\n return new DateScalar(\n updateState(this, {\n schema,\n base: v.isoDate<{\n nullable: State[\"nullable\"];\n array: State[\"array\"];\n schema: S;\n }>({\n nullable: this.state.nullable,\n array: this.state.array,\n schema,\n }),\n }),\n this._nativeType\n );\n }\n\n default<V extends DefaultValueInput<State>>(value: V) {\n return new DateScalar(\n updateState(this, {\n hasDefault: true,\n default: value,\n optional: true,\n }),\n this._nativeType\n );\n }\n\n /**\n * Maps this scalar to a custom column name in the database\n */\n map(columnName: string) {\n return new DateScalar(updateState(this, { columnName }), this._nativeType);\n }\n\n now() {\n if (this.state.array) refuseListGenerator(\"s.date\");\n return new DateScalar(\n updateState(this, {\n hasDefault: true,\n autoGenerate: { kind: \"now\" },\n default: defaultNow,\n optional: true,\n }),\n this._nativeType\n );\n }\n\n updatedAt() {\n if (this.state.array) refuseListGenerator(\"s.date\");\n return new DateScalar(\n updateState(this, {\n hasDefault: true,\n autoGenerate: { kind: \"updatedAt\" },\n default: defaultUpdatedAt,\n optional: true,\n }),\n this._nativeType\n );\n }\n\n get [\"~\"]() {\n return {\n state: this.state,\n nativeType: this._nativeType,\n };\n }\n}\n\nexport const date = <\n Db extends NativeDialect = never,\n const Given extends ExactNativeTypeMap<Given> = never,\n>(\n nativeType?: NativeTypeArgument<Db, Given>\n) =>\n new DateScalar(\n createDefaultState(\"date\", dateBase),\n admitNativeType(\"s.date\", nativeType)\n );\n","// DateTime Scalar\n// Standalone scalar class with State generic pattern\n\nimport type { StandardSchemaV1 } from \"@standard-schema/spec\";\nimport v from \"@validation/primitives/v\";\nimport {\n createDefaultState,\n type DefaultValueInput,\n generatorDefault,\n nullableDefault,\n refuseListGenerator,\n type ScalarState,\n updateState,\n} from \"../common\";\nimport { admitNativeType } from \"../native-catalog\";\nimport type {\n ExactNativeTypeMap,\n NativeDialect,\n NativeTypeArgument,\n NativeTypeDeclaration,\n} from \"../native-types\";\nimport { currentTemporalValue } from \"./current\";\n\nconst defaultNow = generatorDefault(() => currentTemporalValue(\"datetime\"));\nconst defaultUpdatedAt = generatorDefault(() =>\n currentTemporalValue(\"datetime\")\n);\nconst datetimeBase = v.isoTimestamp();\n\nexport class DateTimeScalar<State extends ScalarState<\"datetime\">> {\n private readonly state: State;\n private readonly _nativeType?: NativeTypeDeclaration | undefined;\n constructor(state: State, _nativeType?: NativeTypeDeclaration) {\n this.state = state;\n this._nativeType = _nativeType;\n }\n\n nullable() {\n return new DateTimeScalar(\n updateState(this, {\n nullable: true,\n hasDefault: true,\n default: nullableDefault(this.state),\n optional: true,\n base: v.isoTimestamp<{\n nullable: true;\n array: State[\"array\"];\n schema: State[\"schema\"];\n }>({\n nullable: true,\n array: this.state.array,\n schema: this.state.schema,\n }),\n }),\n this._nativeType\n );\n }\n\n array() {\n if (\n this.state.autoGenerate?.kind === \"now\" ||\n this.state.autoGenerate?.kind === \"updatedAt\"\n )\n refuseListGenerator(\"s.dateTime\");\n return new DateTimeScalar(\n updateState(this, {\n array: true,\n base: v.isoTimestamp<{\n nullable: State[\"nullable\"];\n array: true;\n schema: State[\"schema\"];\n }>({\n nullable: this.state.nullable,\n array: true,\n schema: this.state.schema,\n }),\n }),\n this._nativeType\n );\n }\n\n id() {\n return new DateTimeScalar(\n updateState(this, { isId: true, isUnique: true }),\n this._nativeType\n );\n }\n\n unique() {\n return new DateTimeScalar(\n updateState(this, { isUnique: true }),\n this._nativeType\n );\n }\n\n schema<S extends StandardSchemaV1<string>>(schema: S) {\n return new DateTimeScalar(\n updateState(this, {\n schema,\n base: v.isoTimestamp<{\n nullable: State[\"nullable\"];\n array: State[\"array\"];\n schema: S;\n }>({\n nullable: this.state.nullable,\n array: this.state.array,\n schema,\n }),\n }),\n this._nativeType\n );\n }\n\n default<V extends DefaultValueInput<State>>(value: V) {\n return new DateTimeScalar(\n updateState(this, {\n hasDefault: true,\n default: value,\n optional: true,\n }),\n this._nativeType\n );\n }\n\n map(columnName: string) {\n return new DateTimeScalar(\n updateState(this, { columnName }),\n this._nativeType\n );\n }\n\n now() {\n if (this.state.array) refuseListGenerator(\"s.dateTime\");\n return new DateTimeScalar(\n updateState(this, {\n hasDefault: true,\n autoGenerate: { kind: \"now\" },\n default: defaultNow,\n optional: true,\n }),\n this._nativeType\n );\n }\n\n updatedAt() {\n if (this.state.array) refuseListGenerator(\"s.dateTime\");\n return new DateTimeScalar(\n updateState(this, {\n hasDefault: true,\n autoGenerate: { kind: \"updatedAt\" },\n default: defaultUpdatedAt,\n optional: true,\n }),\n this._nativeType\n );\n }\n\n withoutTimezone() {\n return new DateTimeScalar(\n updateState(this, { withTimezone: false }),\n this._nativeType\n );\n }\n\n get [\"~\"]() {\n return {\n state: this.state,\n nativeType: this._nativeType,\n };\n }\n}\n\nexport const dateTime = <\n Db extends NativeDialect = never,\n const Given extends ExactNativeTypeMap<Given> = never,\n>(\n nativeType?: NativeTypeArgument<Db, Given>\n) =>\n new DateTimeScalar(\n { ...createDefaultState(\"datetime\", datetimeBase), withTimezone: true },\n admitNativeType(\"s.dateTime\", nativeType)\n );\n","// Time Scalar\n// Standalone scalar class with State generic pattern\n\nimport type { StandardSchemaV1 } from \"@standard-schema/spec\";\nimport v from \"@validation/primitives/v\";\nimport {\n createDefaultState,\n type DefaultValueInput,\n generatorDefault,\n nullableDefault,\n refuseListGenerator,\n type ScalarState,\n updateState,\n} from \"../common\";\nimport { admitNativeType } from \"../native-catalog\";\nimport type {\n ExactNativeTypeMap,\n NativeDialect,\n NativeTypeArgument,\n NativeTypeDeclaration,\n} from \"../native-types\";\nimport { currentTemporalValue } from \"./current\";\n\nconst defaultNow = generatorDefault(() => currentTemporalValue(\"time\"));\nconst defaultUpdatedAt = generatorDefault(() => currentTemporalValue(\"time\"));\nconst timeBase = v.isoTime();\n\nexport class TimeScalar<State extends ScalarState<\"time\">> {\n private readonly state: State;\n private readonly _nativeType?: NativeTypeDeclaration | undefined;\n\n constructor(state: State, _nativeType?: NativeTypeDeclaration) {\n this.state = state;\n this._nativeType = _nativeType;\n }\n\n nullable() {\n return new TimeScalar(\n updateState(this, {\n nullable: true,\n hasDefault: true,\n default: nullableDefault(this.state),\n optional: true,\n base: v.isoTime<{\n nullable: true;\n array: State[\"array\"];\n schema: State[\"schema\"];\n }>({\n nullable: true,\n array: this.state.array,\n schema: this.state.schema,\n }),\n }),\n this._nativeType\n );\n }\n\n array() {\n if (\n this.state.autoGenerate?.kind === \"now\" ||\n this.state.autoGenerate?.kind === \"updatedAt\"\n )\n refuseListGenerator(\"s.time\");\n return new TimeScalar(\n updateState(this, {\n array: true,\n base: v.isoTime<{\n nullable: State[\"nullable\"];\n array: true;\n schema: State[\"schema\"];\n }>({\n nullable: this.state.nullable,\n array: true,\n schema: this.state.schema,\n }),\n }),\n this._nativeType\n );\n }\n\n id() {\n return new TimeScalar(\n updateState(this, { isId: true, isUnique: true }),\n this._nativeType\n );\n }\n\n unique() {\n return new TimeScalar(\n updateState(this, { isUnique: true }),\n this._nativeType\n );\n }\n\n schema<S extends StandardSchemaV1<string>>(schema: S) {\n return new TimeScalar(\n updateState(this, {\n schema,\n base: v.isoTime<{\n nullable: State[\"nullable\"];\n array: State[\"array\"];\n schema: S;\n }>({\n nullable: this.state.nullable,\n array: this.state.array,\n schema,\n }),\n }),\n this._nativeType\n );\n }\n\n default<V extends DefaultValueInput<State>>(value: V) {\n return new TimeScalar(\n updateState(this, {\n hasDefault: true,\n default: value,\n optional: true,\n }),\n this._nativeType\n );\n }\n\n /**\n * Maps this scalar to a custom column name in the database\n */\n map(columnName: string) {\n return new TimeScalar(updateState(this, { columnName }), this._nativeType);\n }\n\n now() {\n if (this.state.array) refuseListGenerator(\"s.time\");\n return new TimeScalar(\n updateState(this, {\n hasDefault: true,\n autoGenerate: { kind: \"now\" },\n default: defaultNow,\n optional: true,\n }),\n this._nativeType\n );\n }\n\n updatedAt() {\n if (this.state.array) refuseListGenerator(\"s.time\");\n return new TimeScalar(\n updateState(this, {\n hasDefault: true,\n autoGenerate: { kind: \"updatedAt\" },\n default: defaultUpdatedAt,\n optional: true,\n }),\n this._nativeType\n );\n }\n\n /**\n * Stores time without timezone information (the default).\n * Use an explicit native type for an existing TIMETZ column.\n *\n * Use this when:\n * - You want to store local times (e.g., \"store opens at 9:00 AM\")\n * - The time should not be converted based on timezone\n */\n withoutTimezone() {\n return new TimeScalar(\n updateState(this, { withTimezone: false }),\n this._nativeType\n );\n }\n\n get [\"~\"]() {\n return {\n state: this.state,\n nativeType: this._nativeType,\n };\n }\n}\n\nexport const time = <\n Db extends NativeDialect = never,\n const Given extends ExactNativeTypeMap<Given> = never,\n>(\n nativeType?: NativeTypeArgument<Db, Given>\n) =>\n new TimeScalar(\n { ...createDefaultState(\"time\", timeBase), withTimezone: false },\n admitNativeType(\"s.time\", nativeType)\n );\n","/**\n * The definition boundary for `s.decimal({ precision, scale })`.\n *\n * A scale cannot be inferred from storage, a value, a driver, or an operation:\n * SQLite ignores the numbers in `DECIMAL(10,5)` and may put a fractional value\n * in a binary64 double. So the domain is DECLARED once, here, and every later\n * consumer — validation, DDL, binding, decoding, comparison, arithmetic,\n * migration — reads that one frozen fact off the resolved scalar.\n *\n * The descriptor is the developer's own argument, or two numbers a schema\n * document carried verbatim; neither is a hostile object, so it is read like\n * any other argument — no read-once snapshot, no key enumeration. What this\n * module owns is whether the two numbers name a domain at all.\n */\n\nimport { ValidationError } from \"@errors\";\nimport type { StandardSchemaV1 } from \"@standard-schema/spec\";\nimport type { DecimalDescriptor } from \"@validation/primitives/decimal-codec\";\nimport { validateSchema } from \"@validation/primitives/helpers\";\nimport { isRecord } from \"@validation/value-guards\";\n\n/** The one construction-time refusal of a decimal declaration. */\nfunction refuse(path: string, message: string): never {\n throw new ValidationError(\n { kind: \"schema-builder\", builder: \"s.decimal\", path },\n [{ path, message }]\n );\n}\n\n/**\n * The frozen fixed-decimal domain the two numbers name: `precision` an integer\n * from 1 to the maximum safe integer, `scale` an integer from 0 to `precision`,\n * so \"at most `precision` total digits and at most `scale` fractional digits\"\n * is a domain with values in it.\n *\n * Its unique coverage is the schema document and an untyped JavaScript caller:\n * `read.ts` hands the numbers over as they were written, so `10.5`, `1e300` and\n * `-0` (which `JSON.parse` keeps and `JSON.stringify` loses) reach this check\n * and nothing earlier. The argument is `unknown` because the document seam\n * passes it untyped; it is read as an ordinary object, not a hostile one.\n * Whether a given PROVIDER can store the domain is a different question with a\n * different owner: the adapter answers it once when the schema is bound.\n */\nexport function readDecimalDescriptor(source: unknown): DecimalDescriptor {\n const precision = isRecord(source) ? source.precision : undefined;\n const scale = isRecord(source) ? source.scale : undefined;\n if (\n !(\n typeof precision === \"number\" &&\n Number.isSafeInteger(precision) &&\n precision >= 1\n )\n ) {\n refuse(\n \"descriptor.precision\",\n \"'precision' must be an integer between 1 and the maximum safe integer\"\n );\n }\n if (\n !(\n typeof scale === \"number\" &&\n Number.isSafeInteger(scale) &&\n scale >= 0 &&\n scale <= precision &&\n !Object.is(scale, -0)\n )\n ) {\n refuse(\n \"descriptor.scale\",\n \"'scale' must be an integer between 0 and precision\"\n );\n }\n return Object.freeze({ precision, scale });\n}\n\n/**\n * A fixed-decimal LIST is not a key, and this is where a chain that tries to\n * make one into a key stops (plan 2.1).\n *\n * Both directions are refused because the chain has two of them:\n * `.array().id()` names a list and then a key, `.id().array()` names a key and\n * then a list, and only refusing the one that comes second would leave the\n * other spelling admitted. The exclusion is the DECLARATION's, not the\n * database's: a decimal list is stored as one container value on two of three\n * providers, so a key over it would be a key over a JSON document whose\n * identity is its spelling rather than its members — and there is no member\n * arrangement that could make it addressable.\n *\n * The whole-schema rule F007 (\"an ID cannot be an array\") is untouched and\n * still owns every OTHER scalar type. This refuses earlier, at the call that\n * writes the illegal chain, and it also owns `.unique()`, which no rule in the\n * repository refuses on a list of any type.\n */\nexport function refuseDecimalListKey(\n position: \"id\" | \"unique\" | \"array\"\n): never {\n const explanation =\n \"a fixed-decimal list cannot be an ID, a unique field, an index member, a foreign-key member, or a relation identity member\";\n refuse(\n position,\n position === \"array\"\n ? `A decimal key cannot become a list: ${explanation}`\n : `A decimal list cannot be declared '.${position}()': ${explanation}`\n );\n}\n\n/**\n * A literal default, normalized through the field's complete current schema at\n * DEFINITION time, so model metadata holds the canonical logical value the DDL\n * renderer, the schema-document serializer and the create schema's trusted\n * default all read. A value outside the declared domain fails at the call that\n * wrote it, not at the first write.\n *\n * A function default keeps its closure, exactly as every other scalar's does:\n * a closure has no canonical spelling to retain, and the create schema runs the\n * field codec on each value it returns.\n */\nexport function normalizeDecimalDefault(\n value: unknown,\n schema: StandardSchemaV1<unknown, unknown>\n): unknown {\n if (typeof value === \"function\") return value;\n const result = validateSchema(schema, value);\n if (result.issues !== undefined) {\n refuse(\"default\", \"The decimal default did not satisfy its field schema\");\n }\n return result.value;\n}\n","import type { StandardSchemaV1 } from \"@standard-schema/spec\";\nimport type { DecimalDescriptor } from \"@validation/primitives/decimal-codec\";\nimport type { Decimal } from \"@validation/primitives/decimal-value\";\nimport v from \"@validation/primitives/v\";\nimport {\n createDefaultState,\n type DefaultValueInput,\n nullableDefault,\n type ScalarState,\n updateState,\n} from \"../common\";\nimport {\n normalizeDecimalDefault,\n readDecimalDescriptor,\n refuseDecimalListKey,\n} from \"./descriptor\";\n\n/**\n * The shared L1 descriptor supplies the two required keys. This intersection\n * makes that surface exact for held objects too, without declaring a second L2\n * precision/scale bag.\n */\ntype KeysOfUnion<Given> = Given extends unknown ? keyof Given : never;\n\ntype ExactDomain<Given> = Given &\n Record<Exclude<KeysOfUnion<Given>, keyof DecimalDescriptor>, never>;\n\n/**\n * The type-level half of plan 2.1's list exclusion.\n *\n * A key position is refused by making the RECEIVER unassignable, which is what\n * lets the diagnostic carry the reason: TypeScript reports the missing property\n * by name, so `s.decimal({...}).array().id()` reads as \"a fixed-decimal list\n * cannot be a key\" rather than as an arity or an argument error. The scalar's\n * own type is intersected in, so inside the method body `this` is the scalar it\n * has always been and no assertion is needed to reach its state.\n *\n * `unknown` on the legal side is inert: intersecting it changes nothing, so a\n * non-list decimal keeps exactly the chain it had, and a scalar whose arity is\n * still the unresolved `boolean` is admitted — only a declared list is refused.\n */\ninterface DecimalListKeyRefusal {\n readonly \"a fixed-decimal list cannot be a key\": never;\n}\n\ntype NotAList<State extends ScalarState<\"decimal\">> =\n State[\"array\"] extends true ? DecimalListKeyRefusal : unknown;\n\ntype NotAKey<State extends ScalarState<\"decimal\">> = State[\"isId\"] extends true\n ? DecimalListKeyRefusal\n : State[\"isUnique\"] extends true\n ? DecimalListKeyRefusal\n : unknown;\n\ntype DecimalScalarState<State extends ScalarState<\"decimal\">> = State & {\n readonly decimal: DecimalDescriptor;\n};\n\nexport class DecimalScalar<State extends ScalarState<\"decimal\">> {\n private readonly state: DecimalScalarState<State>;\n\n constructor(state: DecimalScalarState<State>) {\n this.state = state;\n }\n\n /** The frozen domain, carried by reference so identity survives a chain. */\n private get descriptor(): DecimalDescriptor {\n return this.state.decimal;\n }\n\n nullable() {\n return new DecimalScalar(\n updateState(this, {\n nullable: true,\n hasDefault: true,\n default: nullableDefault(this.state),\n optional: true,\n // The custom schema travels with the rebuilt base. `create` reads\n // `state.schema` directly, but `set`, `equals` and the field's own\n // value schema all read `state.base` — dropping it here would make one\n // field refine on create and not on update.\n base: v.decimal<{\n nullable: true;\n array: State[\"array\"];\n decimal: DecimalDescriptor;\n schema: State[\"schema\"];\n }>({\n nullable: true,\n array: this.state.array,\n decimal: this.descriptor,\n schema: this.state.schema,\n }),\n })\n );\n }\n\n array(this: DecimalScalar<State> & NotAKey<State>) {\n if (this.state.isId || this.state.isUnique) refuseDecimalListKey(\"array\");\n const base = v.decimal<{\n nullable: State[\"nullable\"];\n array: true;\n decimal: DecimalDescriptor;\n schema: State[\"schema\"];\n }>({\n nullable: this.state.nullable,\n array: true,\n decimal: this.descriptor,\n schema: this.state.schema,\n });\n const state = updateState(this, { array: true, base });\n if (this.state.hasDefault && typeof this.state.default !== \"function\") {\n Object.defineProperty(state, \"default\", {\n value: normalizeDecimalDefault(this.state.default, base),\n configurable: true,\n enumerable: true,\n writable: true,\n });\n }\n return new DecimalScalar(state);\n }\n\n id(this: DecimalScalar<State> & NotAList<State>) {\n if (this.state.array) refuseDecimalListKey(\"id\");\n return new DecimalScalar(updateState(this, { isId: true, isUnique: true }));\n }\n\n unique(this: DecimalScalar<State> & NotAList<State>) {\n if (this.state.array) refuseDecimalListKey(\"unique\");\n return new DecimalScalar(updateState(this, { isUnique: true }));\n }\n\n /**\n * A literal default is normalized through the field codec HERE, at\n * definition time, so model metadata retains the canonical logical value and\n * a schema document round-trips to the same declaration. A value outside the\n * declared domain fails at the call that wrote it, not at the first write.\n */\n default<V extends DefaultValueInput<State>>(value: V) {\n return withValidatedDecimalDefault(\n this,\n normalizeDecimalDefault(value, this.state.base)\n );\n }\n\n /**\n * Refine or brand the exact value. The schema observes a `Decimal` — the\n * public value type — and the declared domain validates whatever it returns\n * LAST, so a custom schema can narrow the domain but never escape it, and it\n * cannot change the value family the field reads back as.\n */\n schema<S extends StandardSchemaV1<Decimal>>(schema: S) {\n const base = v.decimal<{\n nullable: State[\"nullable\"];\n array: State[\"array\"];\n decimal: DecimalDescriptor;\n schema: S;\n }>({\n nullable: this.state.nullable,\n array: this.state.array,\n decimal: this.descriptor,\n schema,\n });\n const state = updateState(this, { schema, base });\n if (this.state.hasDefault && typeof this.state.default !== \"function\") {\n Object.defineProperty(state, \"default\", {\n value: normalizeDecimalDefault(this.state.default, base),\n configurable: true,\n enumerable: true,\n writable: true,\n });\n }\n return new DecimalScalar(state);\n }\n\n map(columnName: string) {\n return new DecimalScalar(updateState(this, { columnName }));\n }\n\n get [\"~\"](): {\n state: DecimalScalarState<State>;\n nativeType?: undefined;\n } {\n // A fixed decimal has no native-type override: PostgreSQL's `NUMERIC(p,s)`,\n // MySQL's `DECIMAL(p,s)` and SQLite's checked scaled `INTEGER` are all\n // DERIVED from the declared domain, and a second spelling beside it would\n // be a second answer to what the column is. The absence is DECLARED so the\n // scalar union keeps one internal shape for every reader.\n return { state: this.state };\n }\n}\n\n/**\n * Store the canonical verdict of the field's current base schema.\n *\n * This is an internal schema-document seam, deliberately absent from the\n * public decimal barrel. The document interpreter already has to validate a\n * decoded default to own its J008 diagnostic; feeding that verdict back\n * through `.default()` would run the same field codec a second time.\n */\nexport function withValidatedDecimalDefault<\n State extends ScalarState<\"decimal\">,\n>(scalar: DecimalScalar<State>, value: unknown) {\n return new DecimalScalar(\n updateState(scalar, {\n hasDefault: true,\n default: value,\n optional: true,\n })\n );\n}\n\n/**\n * The one public decimal factory.\n *\n * `precision` is the maximum total digit count and `scale` the maximum\n * fractional digit count; values are multiples of `10^-scale`, and an input\n * that does not fit is refused rather than silently rounded. There is no\n * zero-argument form, no native-type override, and no second \"fixed decimal\"\n * factory: portable exact decimal arithmetic needs these two numbers, and\n * SQLite cannot supply them from storage, so they are declared once here.\n */\nexport const buildDecimalScalar = (descriptor: unknown) => {\n const domain = readDecimalDescriptor(descriptor);\n return new DecimalScalar({\n ...createDefaultState(\n \"decimal\",\n v.decimal<{ decimal: DecimalDescriptor }>({ decimal: domain })\n ),\n decimal: domain,\n });\n};\n\n/** The exact public argument surface over the untyped construction seam. */\nexport const decimal = <const D>(\n descriptor: D & NoInfer<DecimalDescriptor & ExactDomain<D>>\n) => buildDecimalScalar(descriptor);\n","// Enum Scalar\n// Standalone scalar class with State generic pattern\n\nimport type { EnumValues } from \"@validation/primitives/enum\";\nimport v from \"@validation/primitives/v\";\nimport {\n createDefaultState,\n type DefaultValueInput,\n nullableDefault,\n type ScalarState,\n updateState,\n} from \"../common\";\nimport { admitNativeType } from \"../native-catalog\";\nimport type {\n ExactNativeTypeMap,\n NativeDialect,\n NativeTypeArgument,\n NativeTypeDeclaration,\n} from \"../native-types\";\n\nexport class EnumScalar<State extends ScalarState<\"enum\">> {\n private readonly state: State;\n private readonly _nativeType?: NativeTypeDeclaration | undefined;\n constructor(state: State, _nativeType?: NativeTypeDeclaration) {\n this.state = state;\n this._nativeType = _nativeType;\n }\n\n get enumValues() {\n return (\n \"values\" in this.state.base ? this.state.base.values : []\n ) as EnumValues<State[\"base\"]>;\n }\n\n nullable() {\n return new EnumScalar(\n updateState(this, {\n nullable: true,\n hasDefault: true,\n default: nullableDefault(this.state),\n optional: true,\n base: v.enum<\n typeof this.enumValues,\n {\n nullable: true;\n array: State[\"array\"];\n }\n >(this.enumValues, {\n nullable: true,\n array: this.state.array,\n }),\n }),\n this._nativeType\n );\n }\n\n array() {\n return new EnumScalar(\n updateState(this, {\n array: true,\n base: v.enum<\n typeof this.enumValues,\n {\n nullable: State[\"nullable\"];\n array: true;\n }\n >(this.enumValues, {\n nullable: this.state.nullable,\n array: true,\n }),\n }),\n this._nativeType\n );\n }\n\n default<V extends DefaultValueInput<State>>(value: V) {\n return new EnumScalar(\n updateState(this, {\n hasDefault: true,\n default: value,\n optional: true,\n }),\n this._nativeType\n );\n }\n\n map(columnName: string) {\n return new EnumScalar(updateState(this, { columnName }), this._nativeType);\n }\n\n /**\n * Set a custom name for the enum type in the database.\n * This allows reusing the same enum across multiple tables.\n *\n * @example\n * ```ts\n * const Status = s.enum([\"PENDING\", \"ACTIVE\"]).name(\"status\");\n *\n * const user = s.model({ status: Status });\n * const order = s.model({ status: Status }); // Same \"status\" enum type\n * ```\n */\n name(enumName: string) {\n return new EnumScalar(updateState(this, { enumName }), this._nativeType);\n }\n\n get [\"~\"]() {\n return {\n state: this.state,\n nativeType: this._nativeType,\n };\n }\n}\n\nexport const enumScalar = <\n // A readonly tuple is admitted; see `enum_` for the mutable arm.\n const T extends string[] | readonly string[],\n Db extends NativeDialect = never,\n const Given extends ExactNativeTypeMap<Given> = never,\n>(\n values: T,\n nativeType?: NativeTypeArgument<Db, Given>\n) => {\n return new EnumScalar(\n createDefaultState(\"enum\", v.enum(values)),\n admitNativeType(\"s.enum\", nativeType)\n );\n};\n","import type { StandardSchemaV1 } from \"@standard-schema/spec\";\nimport v from \"@validation/primitives/v\";\nimport {\n createDefaultState,\n type DefaultValueInput,\n nullableDefault,\n type ScalarState,\n updateState,\n} from \"../common\";\nimport { admitNativeType } from \"../native-catalog\";\nimport type {\n ExactNativeTypeMap,\n NativeDialect,\n NativeTypeArgument,\n NativeTypeDeclaration,\n} from \"../native-types\";\n\nconst intBase = v.integer();\n\nexport class IntScalar<State extends ScalarState<\"int\">> {\n private readonly state: State;\n private readonly _nativeType?: NativeTypeDeclaration | undefined;\n\n constructor(state: State, _nativeType?: NativeTypeDeclaration) {\n this.state = state;\n this._nativeType = _nativeType;\n }\n\n nullable() {\n return new IntScalar(\n updateState(this, {\n nullable: true,\n hasDefault: true,\n default: nullableDefault(this.state),\n optional: true,\n base: v.integer<{\n nullable: true;\n array: State[\"array\"];\n schema: State[\"schema\"];\n }>({\n nullable: true,\n array: this.state.array,\n schema: this.state.schema,\n }),\n }),\n this._nativeType\n );\n }\n\n array() {\n return new IntScalar(\n updateState(this, {\n array: true,\n base: v.integer<{\n nullable: State[\"nullable\"];\n array: true;\n schema: State[\"schema\"];\n }>({\n nullable: this.state.nullable,\n array: true,\n schema: this.state.schema,\n }),\n }),\n this._nativeType\n );\n }\n\n id() {\n return new IntScalar(\n updateState(this, { isId: true, isUnique: true }),\n this._nativeType\n );\n }\n\n unique() {\n return new IntScalar(\n updateState(this, { isUnique: true }),\n this._nativeType\n );\n }\n\n default<V extends DefaultValueInput<State>>(value: V) {\n return new IntScalar(\n updateState(this, {\n hasDefault: true,\n default: value,\n optional: true,\n }),\n this._nativeType\n );\n }\n\n schema<S extends StandardSchemaV1<number>>(schema: S) {\n return new IntScalar(\n updateState(this, {\n schema,\n base: v.integer<{\n nullable: State[\"nullable\"];\n array: State[\"array\"];\n schema: S;\n }>({\n nullable: this.state.nullable,\n array: this.state.array,\n schema,\n }),\n }),\n this._nativeType\n );\n }\n\n map(columnName: string) {\n return new IntScalar(updateState(this, { columnName }), this._nativeType);\n }\n\n increment() {\n return new IntScalar(\n updateState(this, {\n hasDefault: true,\n autoGenerate: { kind: \"increment\" },\n default: undefined,\n disallowZero: true,\n optional: true,\n }),\n this._nativeType\n );\n }\n\n private _internal?: {\n state: State;\n nativeType: NativeTypeDeclaration | undefined;\n };\n\n get [\"~\"]() {\n return (this._internal ??= {\n state: this.state,\n nativeType: this._nativeType,\n });\n }\n}\n\nexport const int = <\n Db extends NativeDialect = never,\n const Given extends ExactNativeTypeMap<Given> = never,\n>(\n nativeType?: NativeTypeArgument<Db, Given>\n) =>\n new IntScalar(\n createDefaultState(\"int\", intBase),\n admitNativeType(\"s.int\", nativeType)\n );\n","import { ValidationError } from \"@errors\";\nimport {\n JsonNull,\n type JsonNullSentinel,\n jsonNullKindOf,\n} from \"@schema/json-null\";\nimport type { StandardSchemaV1 } from \"@standard-schema/spec\";\nimport type { JsonValue } from \"@validation\";\nimport type { JsonInput } from \"@validation/primitives/json\";\nimport v from \"@validation/primitives/v\";\nimport {\n createDefaultState,\n type DefaultValue,\n type DefaultValueInput,\n nullableDefault,\n type ScalarState,\n updateState,\n} from \"../common\";\nimport { admitNativeType } from \"../native-catalog\";\nimport type {\n ExactNativeTypeMap,\n NativeDialect,\n NativeTypeArgument,\n NativeTypeDeclaration,\n} from \"../native-types\";\n\nconst jsonBase = v.json();\n\nexport class JsonScalar<\n State extends ScalarState<\"json\"> = ScalarState<\"json\">,\n> {\n private readonly state: State;\n private readonly _nativeType?: NativeTypeDeclaration | undefined;\n constructor(state: State, _nativeType?: NativeTypeDeclaration) {\n this.state = state;\n this._nativeType = _nativeType;\n }\n\n nullable() {\n return new JsonScalar(\n updateState(this, {\n nullable: true,\n hasDefault: true,\n default: nullableDefault(this.state),\n optional: true,\n base: v.json<{\n nullable: true;\n schema: State[\"schema\"];\n }>({\n nullable: true,\n schema: this.state.schema,\n }),\n }),\n this._nativeType\n );\n }\n\n default<\n V extends\n | DefaultValueInput<State>\n | DefaultValue<\n JsonNullSentinel<\n State[\"nullable\"] extends true ? \"JsonNull\" | \"DbNull\" : \"JsonNull\"\n >\n >,\n >(value: V) {\n const kind = jsonNullKindOf(value);\n if (kind === \"AnyNull\" || (kind === \"DbNull\" && !this.state.nullable)) {\n throw new ValidationError(\n { kind: \"schema-builder\", builder: \"s.json\", path: \"default\" },\n [\n {\n path: \"default\",\n message: \"JSON default must name a null this column can store\",\n },\n ]\n );\n }\n const defaultValue =\n value === null && !this.state.nullable ? JsonNull : value;\n return new JsonScalar(\n updateState(this, {\n hasDefault: true,\n default: defaultValue,\n optional: true,\n }),\n this._nativeType\n );\n }\n\n schema<S extends StandardSchemaV1<JsonInput, JsonValue>>(schema: S) {\n return new JsonScalar(\n updateState(this, {\n schema,\n base: v.json<{\n nullable: State[\"nullable\"];\n schema: S;\n }>({\n nullable: this.state.nullable,\n schema,\n }),\n }),\n this._nativeType\n );\n }\n\n map(columnName: string) {\n return new JsonScalar(updateState(this, { columnName }), this._nativeType);\n }\n\n get [\"~\"]() {\n return {\n state: this.state,\n nativeType: this._nativeType,\n };\n }\n}\n\nexport const json = <\n Db extends NativeDialect = never,\n const Given extends ExactNativeTypeMap<Given> = never,\n>(\n nativeType?: NativeTypeArgument<Db, Given>\n) =>\n new JsonScalar(\n createDefaultState(\"json\", jsonBase),\n admitNativeType(\"s.json\", nativeType)\n );\n","import type { StandardSchemaV1 } from \"@standard-schema/spec\";\nimport v from \"@validation/primitives/v\";\nimport {\n createDefaultState,\n type DefaultValueInput,\n nullableDefault,\n type ScalarState,\n updateState,\n} from \"../common\";\nimport { admitNativeType } from \"../native-catalog\";\nimport type {\n ExactNativeTypeMap,\n NativeDialect,\n NativeTypeArgument,\n NativeTypeDeclaration,\n} from \"../native-types\";\n\nconst numberBase = v.number();\n\nexport class NumberScalar<State extends ScalarState<\"number\">> {\n private readonly state: State;\n private readonly _nativeType?: NativeTypeDeclaration | undefined;\n\n constructor(state: State, _nativeType?: NativeTypeDeclaration) {\n this.state = state;\n this._nativeType = _nativeType;\n }\n\n nullable() {\n return new NumberScalar(\n updateState(this, {\n nullable: true,\n hasDefault: true,\n default: nullableDefault(this.state),\n optional: true,\n base: v.number<{\n nullable: true;\n array: State[\"array\"];\n schema: State[\"schema\"];\n }>({\n nullable: true,\n array: this.state.array,\n schema: this.state.schema,\n }),\n }),\n this._nativeType\n );\n }\n\n array() {\n return new NumberScalar(\n updateState(this, {\n array: true,\n base: v.number<{\n nullable: State[\"nullable\"];\n array: true;\n schema: State[\"schema\"];\n }>({\n nullable: this.state.nullable,\n array: true,\n schema: this.state.schema,\n }),\n }),\n this._nativeType\n );\n }\n\n id() {\n return new NumberScalar(\n updateState(this, { isId: true, isUnique: true }),\n this._nativeType\n );\n }\n\n unique() {\n return new NumberScalar(\n updateState(this, { isUnique: true }),\n this._nativeType\n );\n }\n\n default<V extends DefaultValueInput<State>>(value: V) {\n return new NumberScalar(\n updateState(this, {\n hasDefault: true,\n default: value,\n optional: true,\n }),\n this._nativeType\n );\n }\n\n schema<S extends StandardSchemaV1<number>>(schema: S) {\n return new NumberScalar(\n updateState(this, {\n schema,\n base: v.number<{\n nullable: State[\"nullable\"];\n array: State[\"array\"];\n schema: S;\n }>({\n nullable: this.state.nullable,\n array: this.state.array,\n schema,\n }),\n }),\n this._nativeType\n );\n }\n\n map(columnName: string) {\n return new NumberScalar(\n updateState(this, { columnName }),\n this._nativeType\n );\n }\n\n get [\"~\"]() {\n return {\n state: this.state,\n nativeType: this._nativeType,\n };\n }\n}\n\nexport const number = <\n Db extends NativeDialect = never,\n const Given extends ExactNativeTypeMap<Given> = never,\n>(\n nativeType?: NativeTypeArgument<Db, Given>\n) =>\n new NumberScalar(\n createDefaultState(\"number\", numberBase),\n admitNativeType(\"s.number\", nativeType)\n );\n","import { ValidationError } from \"@errors\";\nimport { validateSchema } from \"@validation/primitives/helpers\";\nimport v from \"@validation/primitives/v\";\nimport {\n createDefaultState,\n type DefaultValueInput,\n nullableDefault,\n type ScalarState,\n updateState,\n} from \"../common\";\n\nconst pointBase = v.point();\n\nexport class PointScalar<State extends ScalarState<\"point\">> {\n private readonly state: State;\n constructor(state: State) {\n this.state = state;\n }\n\n nullable() {\n return new PointScalar(\n updateState(this, {\n nullable: true,\n hasDefault: true,\n default: nullableDefault(this.state),\n optional: true,\n base: v.point<{\n nullable: true;\n }>({\n nullable: true,\n }),\n })\n );\n }\n\n default<V extends DefaultValueInput<State>>(value: V) {\n return new PointScalar(\n updateState(this, {\n hasDefault: true,\n default: normalizePointDefault(value, this.state.base),\n optional: true,\n })\n );\n }\n\n map(columnName: string) {\n return new PointScalar(updateState(this, { columnName }));\n }\n\n get [\"~\"](): { state: State; nativeType?: undefined } {\n return { state: this.state };\n }\n}\n\nfunction normalizePointDefault(value: unknown, schema: StateSchema): unknown {\n if (typeof value === \"function\") return value;\n const result = validateSchema(schema, value);\n if (!result.issues) return result.value;\n throw new ValidationError(\n { kind: \"schema-builder\", builder: \"s.point\", path: \"default\" },\n result.issues.map((issue) => ({\n path: issue.path?.join(\".\") ?? \"default\",\n message: issue.message,\n }))\n );\n}\n\ntype StateSchema = ScalarState<\"point\">[\"base\"];\n\n/** The one public GeoPoint scalar factory; EPSG:4326 is not configurable. */\nexport function point(...args: []) {\n if (args.length !== 0) {\n throw new ValidationError(\n { kind: \"schema-builder\", builder: \"s.point\", path: \"arguments\" },\n [\n {\n path: \"arguments\",\n message: \"s.point() takes no native type or options\",\n },\n ]\n );\n }\n return new PointScalar(createDefaultState(\"point\", pointBase));\n}\n","// Vector Scalar\n// Standalone scalar class with State generic pattern\n\nimport { ValidationError } from \"@errors\";\nimport v from \"@validation/primitives/v\";\nimport {\n createDefaultState,\n type DefaultValueInput,\n nullableDefault,\n type ScalarState,\n updateState,\n} from \"../common\";\nimport { admitNativeType } from \"../native-catalog\";\nimport type {\n ExactNativeTypeMap,\n NativeDialect,\n NativeTypeArgument,\n NativeTypeDeclaration,\n} from \"../native-types\";\n\nconst vectorBase = v.vector();\n\nexport class VectorScalar<State extends ScalarState<\"vector\">> {\n private readonly state: State;\n private readonly _nativeType?: NativeTypeDeclaration | undefined;\n\n constructor(state: State, _nativeType?: NativeTypeDeclaration) {\n this.state = state;\n this._nativeType = _nativeType;\n }\n\n nullable() {\n return new VectorScalar(\n updateState(this, {\n nullable: true,\n hasDefault: true,\n default: nullableDefault(this.state),\n optional: true,\n base: v.vector<{\n nullable: true;\n }>(this.state.dimension, {\n nullable: true,\n }),\n }),\n this._nativeType\n );\n }\n\n default<V extends DefaultValueInput<State>>(value: V) {\n return new VectorScalar(\n updateState(this, {\n hasDefault: true,\n default: value,\n optional: true,\n }),\n this._nativeType\n );\n }\n\n /**\n * Maps this scalar to a custom column name in the database\n */\n map(columnName: string) {\n return new VectorScalar(\n updateState(this, { columnName }),\n this._nativeType\n );\n }\n\n dimension(dim: number) {\n if (!Number.isSafeInteger(dim) || dim <= 0) {\n throw new ValidationError(\n { kind: \"schema-builder\", builder: \"s.vector\", path: \"dimension\" },\n [\n {\n path: \"dimension\",\n message: \"Vector dimension must be a positive safe integer\",\n },\n ]\n );\n }\n return new VectorScalar(\n updateState(this, {\n dimension: dim,\n base: v.vector(dim, { nullable: this.state.nullable }),\n }),\n this._nativeType\n );\n }\n\n get [\"~\"]() {\n return {\n state: this.state,\n nativeType: this._nativeType,\n };\n }\n}\n\nexport const vector = <\n Db extends NativeDialect = never,\n const Given extends ExactNativeTypeMap<Given> = never,\n>(\n nativeType?: NativeTypeArgument<Db, Given>\n) =>\n new VectorScalar(\n createDefaultState(\"vector\", vectorBase),\n admitNativeType(\"s.vector\", nativeType)\n );\n","// `s.toMany` — the other of the two relation factories.\n//\n// The factory states the SLOT CARDINALITY (many) and its argument states the\n// TARGET DOMAIN. A model-target collection is junction-capable and an empty\n// collection is `[]`, so there is no `.optional()` here and no `.unique()`\n// anywhere: the paired slot cardinality owns remote uniqueness.\n\nimport {\n type ExactVariantOptions,\n type NormalizedManyEntries,\n normalizeVariantEntries,\n type VariantGetterMap,\n type VariantMapGuard,\n type VariantOptions,\n type VariantToManyRelation,\n variantToManyTerminal,\n} from \"./polymorphic\";\nimport {\n createTargetSettlement,\n normalizeJunctionActions,\n normalizeJunctionToken,\n normalizeRelationName,\n refuseRelationInput,\n} from \"./terminal\";\nimport type {\n AnyRelation,\n Getter,\n GetterOnly,\n JunctionReferentialAction,\n JunctionSideActions,\n ModelToManyState,\n OrdinaryJunctionOverrides,\n RelationInternal,\n Replace,\n} from \"./types\";\n\n// =============================================================================\n// TERMINAL CAPABILITY SURFACE\n// =============================================================================\n\n/** A junction action: the symmetric shorthand, or one action per side. */\nexport type JunctionActionDeclaration =\n | JunctionReferentialAction\n | JunctionSideActions;\n\n/** Every key any map member of `Action` declares; a bare action declares none. */\ntype DeclaredMapKeys<Action> = Action extends JunctionReferentialAction\n ? never\n : keyof Action;\n\n/**\n * `{ source, target }` is exact: a key beside the two sides is refused\n * structurally, so a map held in a variable cannot carry one past\n * excess-property checking either. The keys are gathered across a union\n * before the check, so one clean member cannot vouch for another that carries\n * an extra key.\n */\nexport type ExactJunctionActions<Action> = Record<\n Exclude<DeclaredMapKeys<Action>, keyof JunctionSideActions>,\n never\n>;\n\n/**\n * A model-target collection slot.\n *\n * The junction overrides are independent, meaningful facts rather than stages of\n * one all-or-nothing value, so any subset may override its canonical default.\n * Exactly one endpoint owns all supplied overrides; the other endpoint supplies\n * none and consumes the mirrored resolved view. Whether these overrides belong\n * on the resolved physical owner is one full-schema topology rule, not a second\n * type-level guess — which is why they are offered before the inverse graph\n * exists and why the state does not carry them as a public type parameter.\n */\nexport type ModelToManyRelation<State> = {\n readonly \"~\": RelationInternal<State>;\n name<const Name extends string>(\n name: Name\n ): ModelToManyRelation<Replace<State, { readonly name: Name }>>;\n through(table: string): ModelToManyRelation<State>;\n source(token: string): ModelToManyRelation<State>;\n target(token: string): ModelToManyRelation<State>;\n onDelete<const Action extends JunctionActionDeclaration>(\n action: Action & ExactJunctionActions<Action>\n ): ModelToManyRelation<State>;\n onUpdate<const Action extends JunctionActionDeclaration>(\n action: Action & ExactJunctionActions<Action>\n ): ModelToManyRelation<State>;\n};\n\n// =============================================================================\n// PRIVATE TERMINAL\n// =============================================================================\n\nclass ModelToMany {\n readonly #state: ModelToManyState;\n readonly #internal: RelationInternal<ModelToManyState>;\n\n constructor(state: ModelToManyState) {\n this.#state = Object.freeze(state);\n this.#internal = Object.freeze({\n state: this.#state,\n settleTarget: createTargetSettlement(() => this.#state.target.getter),\n });\n }\n\n name(name: string): ModelToMany {\n return new ModelToMany({\n ...this.#state,\n name: normalizeRelationName(\"s.toMany\", name),\n });\n }\n\n through(table: string): ModelToMany {\n return this.#withJunction({\n ...this.#state.junction,\n table: normalizeJunctionToken(\"through\", table),\n });\n }\n\n source(token: string): ModelToMany {\n return this.#withJunction({\n ...this.#state.junction,\n source: normalizeJunctionToken(\"source\", token),\n });\n }\n\n target(token: string): ModelToMany {\n return this.#withJunction({\n ...this.#state.junction,\n target: normalizeJunctionToken(\"target\", token),\n });\n }\n\n onDelete(action: JunctionActionDeclaration): ModelToMany {\n return this.#withJunction({\n ...this.#state.junction,\n onDelete: normalizeJunctionActions(\"onDelete\", action),\n });\n }\n\n onUpdate(action: JunctionActionDeclaration): ModelToMany {\n return this.#withJunction({\n ...this.#state.junction,\n onUpdate: normalizeJunctionActions(\"onUpdate\", action),\n });\n }\n\n #withJunction(junction: OrdinaryJunctionOverrides): ModelToMany {\n return new ModelToMany({\n ...this.#state,\n junction: Object.freeze(junction),\n });\n }\n\n get \"~\"(): RelationInternal<ModelToManyState> {\n return this.#internal;\n }\n}\n\n// =============================================================================\n// FACTORY\n// =============================================================================\n\n/**\n * Declare a slot that holds a COLLECTION.\n *\n * The map overload is declared first so a variant map is never swallowed by the\n * broad getter overload. Dispatch examines only the argument representation and\n * never invokes a getter.\n */\nexport function toMany<\n const Entries extends VariantGetterMap,\n const Options extends VariantOptions<Entries> | undefined = undefined,\n>(\n variants: Entries & VariantMapGuard<Entries>,\n options?: Options & ExactVariantOptions<Options, Entries>\n): VariantToManyRelation<{\n readonly kind: \"relation\";\n readonly cardinality: \"many\";\n readonly target: {\n readonly kind: \"variants\";\n readonly entries: NormalizedManyEntries<Entries>;\n };\n}>;\nexport function toMany<const G>(getter: G & GetterOnly<G>): G extends Getter\n ? ModelToManyRelation<{\n readonly kind: \"relation\";\n readonly cardinality: \"many\";\n readonly target: { readonly kind: \"model\"; readonly getter: G };\n }>\n : never;\nexport function toMany(target: unknown, options?: unknown): AnyRelation {\n if (typeof target === \"function\") {\n // biome-ignore lint/complexity/noArguments: distinguishes omission from explicit undefined without changing the factory's public arity\n if (arguments.length > 1) {\n refuseRelationInput(\n \"s.toMany\",\n \"options\",\n \"A model-target relation takes exactly one argument\"\n );\n }\n return new ModelToMany({\n kind: \"relation\",\n cardinality: \"many\",\n target: { kind: \"model\", getter: target },\n });\n }\n return variantToManyTerminal({\n kind: \"relation\",\n cardinality: \"many\",\n target: {\n kind: \"variants\",\n entries: normalizeVariantEntries(\"s.toMany\", target, options),\n },\n });\n}\n"],"mappings":"uZAoBA,MAAM,EAAaA,EAAE,QAAQ,CAE7B,IAAa,EAAb,MAAa,YAAkD,CAC7D,MACA,YAEA,YAAY,EAAc,EAAqC,CAC7D,KAAK,MAAQ,EACb,KAAK,YAAc,EAGrB,UAAW,CACT,OAAO,IAAI,aACT,EAAY,KAAM,CAChB,SAAU,GACV,WAAY,GACZ,QAAS,EAAgB,KAAK,MAAM,CACpC,SAAU,GACV,KAAMA,EAAE,OAIL,CACD,SAAU,GACV,MAAO,KAAK,MAAM,MAClB,OAAQ,KAAK,MAAM,OACpB,CAAC,CACH,CAAC,CACF,KAAK,YACN,CAGH,OAAQ,CACN,OAAO,IAAI,aACT,EAAY,KAAM,CAChB,MAAO,GACP,KAAMA,EAAE,OAIL,CACD,SAAU,KAAK,MAAM,SACrB,MAAO,GACP,OAAQ,KAAK,MAAM,OACpB,CAAC,CACH,CAAC,CACF,KAAK,YACN,CAGH,IAAK,CACH,OAAO,IAAI,aACT,EAAY,KAAM,CAAE,KAAM,GAAM,SAAU,GAAM,CAAC,CACjD,KAAK,YACN,CAGH,QAAS,CACP,OAAO,IAAI,aACT,EAAY,KAAM,CAAE,SAAU,GAAM,CAAC,CACrC,KAAK,YACN,CAGH,QAA4C,EAAU,CACpD,OAAO,IAAI,aAC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AY,EAAO,CACvD,CAAC,CAGJ,SAAS,EAAgD,CACvD,OAAO,MAAA,EAAmB,CACxB,GAAG,MAAA,EAAY,SACf,SAAU,EAAyB,WAAY,EAAO,CACvD,CAAC,CAGJ,GAAc,EAAkD,CAC9D,OAAO,IAAI,YAAY,CACrB,GAAG,MAAA,EACH,SAAU,OAAO,OAAO,EAAS,CAClC,CAAC,CAGJ,GAAI,KAA0C,CAC5C,OAAO,MAAA,IAoCX,SAAgB,OAAO,EAAiB,EAAgC,CAgBtE,OAfI,OAAO,GAAW,YAEhB,UAAU,OAAS,GACrB,EACE,WACA,UACA,qDACD,CAEI,IAAI,EAAY,CACrB,KAAM,WACN,YAAa,OACb,OAAQ,CAAE,KAAM,QAAS,OAAQ,EAAQ,CAC1C,CAAC,EAEG,EAAsB,CAC3B,KAAM,WACN,YAAa,OACb,OAAQ,CACN,KAAM,WACN,QAAS,EAAwB,WAAY,EAAQ,EAAQ,CAC9D,CACF,CAAC"}
|
|
1
|
+
{"version":3,"file":"to-many-BSipkSbK.mjs","names":["v","v","v","defaultNow","defaultUpdatedAt","v","defaultNow","defaultUpdatedAt","v","v","v","v","v","v","v","v","v","#state","#internal","#withJunction"],"sources":["../src/schema/scalars/bigint/scalar.ts","../src/schema/scalars/blob/scalar.ts","../src/schema/scalars/boolean/scalar.ts","../src/schema/scalars/datetime/date-scalar.ts","../src/schema/scalars/datetime/scalar.ts","../src/schema/scalars/datetime/time-scalar.ts","../src/schema/scalars/decimal/descriptor.ts","../src/schema/scalars/decimal/scalar.ts","../src/schema/scalars/enum/scalar.ts","../src/schema/scalars/int/scalar.ts","../src/schema/scalars/json/scalar.ts","../src/schema/scalars/number/scalar.ts","../src/schema/scalars/point/scalar.ts","../src/schema/scalars/vector/scalar.ts","../src/schema/relation/to-many.ts"],"sourcesContent":["// BigInt Scalar\n// Standalone scalar class with State generic pattern\n\nimport type { StandardSchemaV1 } from \"@standard-schema/spec\";\nimport v from \"@validation/primitives/v\";\nimport {\n createDefaultState,\n type DefaultValueInput,\n nullableDefault,\n type ScalarState,\n updateState,\n} from \"../common\";\nimport { admitNativeType } from \"../native-catalog\";\nimport type {\n ExactNativeTypeMap,\n NativeDialect,\n NativeTypeArgument,\n NativeTypeDeclaration,\n} from \"../native-types\";\n\nconst bigIntBase = v.bigint();\n\nexport class BigIntScalar<State extends ScalarState<\"bigint\">> {\n private readonly state: State;\n private readonly _nativeType?: NativeTypeDeclaration | undefined;\n\n constructor(state: State, _nativeType?: NativeTypeDeclaration) {\n this.state = state;\n this._nativeType = _nativeType;\n }\n\n nullable() {\n return new BigIntScalar(\n updateState(this, {\n nullable: true,\n hasDefault: true,\n default: nullableDefault(this.state),\n optional: true,\n base: v.bigint<{\n nullable: true;\n array: State[\"array\"];\n schema: State[\"schema\"];\n }>({\n nullable: true,\n array: this.state.array,\n schema: this.state.schema,\n }),\n }),\n this._nativeType\n );\n }\n\n array() {\n return new BigIntScalar(\n updateState(this, {\n array: true,\n base: v.bigint<{\n nullable: State[\"nullable\"];\n array: true;\n schema: State[\"schema\"];\n }>({\n nullable: this.state.nullable,\n array: true,\n schema: this.state.schema,\n }),\n }),\n this._nativeType\n );\n }\n\n id() {\n return new BigIntScalar(\n updateState(this, { isId: true, isUnique: true }),\n this._nativeType\n );\n }\n\n unique() {\n return new BigIntScalar(\n updateState(this, { isUnique: true }),\n this._nativeType\n );\n }\n\n default<V extends DefaultValueInput<State>>(value: V) {\n return new BigIntScalar(\n updateState(this, { hasDefault: true, default: value, optional: true }),\n this._nativeType\n );\n }\n\n schema<S extends StandardSchemaV1<bigint>>(schema: S) {\n return new BigIntScalar(\n updateState(this, {\n schema,\n base: v.bigint<{\n nullable: State[\"nullable\"];\n array: State[\"array\"];\n schema: S;\n }>({\n nullable: this.state.nullable,\n array: this.state.array,\n schema,\n }),\n }),\n this._nativeType\n );\n }\n\n map(columnName: string) {\n return new BigIntScalar(\n updateState(this, { columnName }),\n this._nativeType\n );\n }\n\n increment() {\n return new BigIntScalar(\n updateState(this, {\n hasDefault: true,\n autoGenerate: { kind: \"increment\" },\n default: undefined,\n disallowZero: true,\n optional: true,\n }),\n this._nativeType\n );\n }\n\n get [\"~\"]() {\n return {\n state: this.state,\n nativeType: this._nativeType,\n };\n }\n}\n\nexport const bigInt = <\n Db extends NativeDialect = never,\n const Given extends ExactNativeTypeMap<Given> = never,\n>(\n nativeType?: NativeTypeArgument<Db, Given>\n) =>\n new BigIntScalar(\n createDefaultState(\"bigint\", bigIntBase),\n admitNativeType(\"s.bigInt\", nativeType)\n );\n","// Blob Scalar\n// Standalone scalar class with State generic pattern\n\nimport v from \"@validation/primitives/v\";\nimport {\n createDefaultState,\n type DefaultValueInput,\n nullableDefault,\n type ScalarState,\n updateState,\n} from \"../common\";\nimport { admitNativeType } from \"../native-catalog\";\nimport type {\n ExactNativeTypeMap,\n NativeDialect,\n NativeTypeArgument,\n NativeTypeDeclaration,\n} from \"../native-types\";\n\nconst blobBase = v.blob();\n\nexport class BlobScalar<State extends ScalarState<\"blob\">> {\n private readonly state: State;\n private readonly _nativeType?: NativeTypeDeclaration | undefined;\n\n constructor(state: State, _nativeType?: NativeTypeDeclaration) {\n this.state = state;\n this._nativeType = _nativeType;\n }\n\n nullable() {\n return new BlobScalar(\n updateState(this, {\n nullable: true,\n hasDefault: true,\n default: nullableDefault(this.state),\n optional: true,\n base: v.blob<{\n nullable: true;\n }>({\n nullable: true,\n }),\n }),\n this._nativeType\n );\n }\n\n default<V extends DefaultValueInput<State>>(value: V) {\n return new BlobScalar(\n updateState(this, {\n hasDefault: true,\n default: value,\n optional: true,\n }),\n this._nativeType\n );\n }\n\n /**\n * Maps this scalar to a custom column name in the database\n */\n map(columnName: string) {\n return new BlobScalar(updateState(this, { columnName }), this._nativeType);\n }\n\n // Blob scalars don't support array(), id(), or unique()\n array(): never {\n throw new Error(\"Blob scalars don't support array modifier\");\n }\n\n id(): never {\n throw new Error(\"Blob scalars cannot be used as IDs\");\n }\n\n unique(): never {\n throw new Error(\"Blob scalars cannot be unique\");\n }\n\n get [\"~\"]() {\n return {\n state: this.state,\n nativeType: this._nativeType,\n };\n }\n}\n\nexport const blob = <\n Db extends NativeDialect = never,\n const Given extends ExactNativeTypeMap<Given> = never,\n>(\n nativeType?: NativeTypeArgument<Db, Given>\n) =>\n new BlobScalar(\n createDefaultState(\"blob\", blobBase),\n admitNativeType(\"s.blob\", nativeType)\n );\n","// Boolean Scalar\n// Standalone scalar class with State generic pattern\n\nimport v from \"@validation/primitives/v\";\nimport {\n createDefaultState,\n type DefaultValueInput,\n nullableDefault,\n type ScalarState,\n updateState,\n} from \"../common\";\nimport { admitNativeType } from \"../native-catalog\";\nimport type {\n ExactNativeTypeMap,\n NativeDialect,\n NativeTypeArgument,\n NativeTypeDeclaration,\n} from \"../native-types\";\n\nconst booleanBase = v.boolean();\n\nexport class BooleanScalar<State extends ScalarState<\"boolean\">> {\n private readonly state: State;\n private readonly _nativeType?: NativeTypeDeclaration | undefined;\n\n constructor(state: State, _nativeType?: NativeTypeDeclaration) {\n this.state = state;\n this._nativeType = _nativeType;\n }\n\n nullable() {\n return new BooleanScalar(\n updateState(this, {\n nullable: true,\n hasDefault: true,\n default: nullableDefault(this.state),\n optional: true,\n base: v.boolean<{\n nullable: true;\n array: State[\"array\"];\n }>({\n nullable: true,\n array: this.state.array,\n }),\n }),\n this._nativeType\n );\n }\n\n array() {\n return new BooleanScalar(\n updateState(this, {\n array: true,\n base: v.boolean<{\n nullable: State[\"nullable\"];\n array: true;\n }>({\n nullable: this.state.nullable,\n array: true,\n }),\n }),\n this._nativeType\n );\n }\n\n default<V extends DefaultValueInput<State>>(value: V) {\n return new BooleanScalar(\n updateState(this, {\n hasDefault: true,\n default: value,\n optional: true,\n }),\n this._nativeType\n );\n }\n\n /**\n * Maps this scalar to a custom column name in the database\n */\n map(columnName: string) {\n return new BooleanScalar(\n updateState(this, { columnName }),\n this._nativeType\n );\n }\n\n private _internal?: {\n state: State;\n nativeType: NativeTypeDeclaration | undefined;\n };\n\n get [\"~\"]() {\n return (this._internal ??= {\n state: this.state,\n nativeType: this._nativeType,\n });\n }\n}\n\nexport const boolean = <\n Db extends NativeDialect = never,\n const Given extends ExactNativeTypeMap<Given> = never,\n>(\n nativeType?: NativeTypeArgument<Db, Given>\n) =>\n new BooleanScalar(\n createDefaultState(\"boolean\", booleanBase),\n admitNativeType(\"s.boolean\", nativeType)\n );\n","// Date Scalar\n// Standalone scalar class with State generic pattern\n\nimport type { StandardSchemaV1 } from \"@standard-schema/spec\";\nimport v from \"@validation/primitives/v\";\nimport {\n createDefaultState,\n type DefaultValueInput,\n generatorDefault,\n nullableDefault,\n refuseListGenerator,\n type ScalarState,\n updateState,\n} from \"../common\";\nimport { admitNativeType } from \"../native-catalog\";\nimport type {\n ExactNativeTypeMap,\n NativeDialect,\n NativeTypeArgument,\n NativeTypeDeclaration,\n} from \"../native-types\";\nimport { currentTemporalValue } from \"./current\";\n\nconst defaultNow = generatorDefault(() => currentTemporalValue(\"date\"));\nconst defaultUpdatedAt = generatorDefault(() => currentTemporalValue(\"date\"));\nconst dateBase = v.isoDate();\n\nexport class DateScalar<State extends ScalarState<\"date\">> {\n private readonly state: State;\n private readonly _nativeType?: NativeTypeDeclaration | undefined;\n\n constructor(state: State, _nativeType?: NativeTypeDeclaration) {\n this.state = state;\n this._nativeType = _nativeType;\n }\n\n nullable() {\n return new DateScalar(\n updateState(this, {\n nullable: true,\n hasDefault: true,\n default: nullableDefault(this.state),\n optional: true,\n base: v.isoDate<{\n nullable: true;\n array: State[\"array\"];\n schema: State[\"schema\"];\n }>({\n nullable: true,\n array: this.state.array,\n schema: this.state.schema,\n }),\n }),\n this._nativeType\n );\n }\n\n array() {\n if (\n this.state.autoGenerate?.kind === \"now\" ||\n this.state.autoGenerate?.kind === \"updatedAt\"\n )\n refuseListGenerator(\"s.date\");\n return new DateScalar(\n updateState(this, {\n array: true,\n base: v.isoDate<{\n nullable: State[\"nullable\"];\n array: true;\n schema: State[\"schema\"];\n }>({\n nullable: this.state.nullable,\n array: true,\n schema: this.state.schema,\n }),\n }),\n this._nativeType\n );\n }\n\n id() {\n return new DateScalar(\n updateState(this, { isId: true, isUnique: true }),\n this._nativeType\n );\n }\n\n unique() {\n return new DateScalar(\n updateState(this, { isUnique: true }),\n this._nativeType\n );\n }\n\n schema<S extends StandardSchemaV1<string>>(schema: S) {\n return new DateScalar(\n updateState(this, {\n schema,\n base: v.isoDate<{\n nullable: State[\"nullable\"];\n array: State[\"array\"];\n schema: S;\n }>({\n nullable: this.state.nullable,\n array: this.state.array,\n schema,\n }),\n }),\n this._nativeType\n );\n }\n\n default<V extends DefaultValueInput<State>>(value: V) {\n return new DateScalar(\n updateState(this, {\n hasDefault: true,\n default: value,\n optional: true,\n }),\n this._nativeType\n );\n }\n\n /**\n * Maps this scalar to a custom column name in the database\n */\n map(columnName: string) {\n return new DateScalar(updateState(this, { columnName }), this._nativeType);\n }\n\n now() {\n if (this.state.array) refuseListGenerator(\"s.date\");\n return new DateScalar(\n updateState(this, {\n hasDefault: true,\n autoGenerate: { kind: \"now\" },\n default: defaultNow,\n optional: true,\n }),\n this._nativeType\n );\n }\n\n updatedAt() {\n if (this.state.array) refuseListGenerator(\"s.date\");\n return new DateScalar(\n updateState(this, {\n hasDefault: true,\n autoGenerate: { kind: \"updatedAt\" },\n default: defaultUpdatedAt,\n optional: true,\n }),\n this._nativeType\n );\n }\n\n get [\"~\"]() {\n return {\n state: this.state,\n nativeType: this._nativeType,\n };\n }\n}\n\nexport const date = <\n Db extends NativeDialect = never,\n const Given extends ExactNativeTypeMap<Given> = never,\n>(\n nativeType?: NativeTypeArgument<Db, Given>\n) =>\n new DateScalar(\n createDefaultState(\"date\", dateBase),\n admitNativeType(\"s.date\", nativeType)\n );\n","// DateTime Scalar\n// Standalone scalar class with State generic pattern\n\nimport type { StandardSchemaV1 } from \"@standard-schema/spec\";\nimport v from \"@validation/primitives/v\";\nimport {\n createDefaultState,\n type DefaultValueInput,\n generatorDefault,\n nullableDefault,\n refuseListGenerator,\n type ScalarState,\n updateState,\n} from \"../common\";\nimport { admitNativeType } from \"../native-catalog\";\nimport type {\n ExactNativeTypeMap,\n NativeDialect,\n NativeTypeArgument,\n NativeTypeDeclaration,\n} from \"../native-types\";\nimport { currentTemporalValue } from \"./current\";\n\nconst defaultNow = generatorDefault(() => currentTemporalValue(\"datetime\"));\nconst defaultUpdatedAt = generatorDefault(() =>\n currentTemporalValue(\"datetime\")\n);\nconst datetimeBase = v.isoTimestamp();\n\nexport class DateTimeScalar<State extends ScalarState<\"datetime\">> {\n private readonly state: State;\n private readonly _nativeType?: NativeTypeDeclaration | undefined;\n constructor(state: State, _nativeType?: NativeTypeDeclaration) {\n this.state = state;\n this._nativeType = _nativeType;\n }\n\n nullable() {\n return new DateTimeScalar(\n updateState(this, {\n nullable: true,\n hasDefault: true,\n default: nullableDefault(this.state),\n optional: true,\n base: v.isoTimestamp<{\n nullable: true;\n array: State[\"array\"];\n schema: State[\"schema\"];\n }>({\n nullable: true,\n array: this.state.array,\n schema: this.state.schema,\n }),\n }),\n this._nativeType\n );\n }\n\n array() {\n if (\n this.state.autoGenerate?.kind === \"now\" ||\n this.state.autoGenerate?.kind === \"updatedAt\"\n )\n refuseListGenerator(\"s.dateTime\");\n return new DateTimeScalar(\n updateState(this, {\n array: true,\n base: v.isoTimestamp<{\n nullable: State[\"nullable\"];\n array: true;\n schema: State[\"schema\"];\n }>({\n nullable: this.state.nullable,\n array: true,\n schema: this.state.schema,\n }),\n }),\n this._nativeType\n );\n }\n\n id() {\n return new DateTimeScalar(\n updateState(this, { isId: true, isUnique: true }),\n this._nativeType\n );\n }\n\n unique() {\n return new DateTimeScalar(\n updateState(this, { isUnique: true }),\n this._nativeType\n );\n }\n\n schema<S extends StandardSchemaV1<string>>(schema: S) {\n return new DateTimeScalar(\n updateState(this, {\n schema,\n base: v.isoTimestamp<{\n nullable: State[\"nullable\"];\n array: State[\"array\"];\n schema: S;\n }>({\n nullable: this.state.nullable,\n array: this.state.array,\n schema,\n }),\n }),\n this._nativeType\n );\n }\n\n default<V extends DefaultValueInput<State>>(value: V) {\n return new DateTimeScalar(\n updateState(this, {\n hasDefault: true,\n default: value,\n optional: true,\n }),\n this._nativeType\n );\n }\n\n map(columnName: string) {\n return new DateTimeScalar(\n updateState(this, { columnName }),\n this._nativeType\n );\n }\n\n now() {\n if (this.state.array) refuseListGenerator(\"s.dateTime\");\n return new DateTimeScalar(\n updateState(this, {\n hasDefault: true,\n autoGenerate: { kind: \"now\" },\n default: defaultNow,\n optional: true,\n }),\n this._nativeType\n );\n }\n\n updatedAt() {\n if (this.state.array) refuseListGenerator(\"s.dateTime\");\n return new DateTimeScalar(\n updateState(this, {\n hasDefault: true,\n autoGenerate: { kind: \"updatedAt\" },\n default: defaultUpdatedAt,\n optional: true,\n }),\n this._nativeType\n );\n }\n\n withoutTimezone() {\n return new DateTimeScalar(\n updateState(this, { withTimezone: false }),\n this._nativeType\n );\n }\n\n get [\"~\"]() {\n return {\n state: this.state,\n nativeType: this._nativeType,\n };\n }\n}\n\nexport const dateTime = <\n Db extends NativeDialect = never,\n const Given extends ExactNativeTypeMap<Given> = never,\n>(\n nativeType?: NativeTypeArgument<Db, Given>\n) =>\n new DateTimeScalar(\n { ...createDefaultState(\"datetime\", datetimeBase), withTimezone: true },\n admitNativeType(\"s.dateTime\", nativeType)\n );\n","// Time Scalar\n// Standalone scalar class with State generic pattern\n\nimport type { StandardSchemaV1 } from \"@standard-schema/spec\";\nimport v from \"@validation/primitives/v\";\nimport {\n createDefaultState,\n type DefaultValueInput,\n generatorDefault,\n nullableDefault,\n refuseListGenerator,\n type ScalarState,\n updateState,\n} from \"../common\";\nimport { admitNativeType } from \"../native-catalog\";\nimport type {\n ExactNativeTypeMap,\n NativeDialect,\n NativeTypeArgument,\n NativeTypeDeclaration,\n} from \"../native-types\";\nimport { currentTemporalValue } from \"./current\";\n\nconst defaultNow = generatorDefault(() => currentTemporalValue(\"time\"));\nconst defaultUpdatedAt = generatorDefault(() => currentTemporalValue(\"time\"));\nconst timeBase = v.isoTime();\n\nexport class TimeScalar<State extends ScalarState<\"time\">> {\n private readonly state: State;\n private readonly _nativeType?: NativeTypeDeclaration | undefined;\n\n constructor(state: State, _nativeType?: NativeTypeDeclaration) {\n this.state = state;\n this._nativeType = _nativeType;\n }\n\n nullable() {\n return new TimeScalar(\n updateState(this, {\n nullable: true,\n hasDefault: true,\n default: nullableDefault(this.state),\n optional: true,\n base: v.isoTime<{\n nullable: true;\n array: State[\"array\"];\n schema: State[\"schema\"];\n }>({\n nullable: true,\n array: this.state.array,\n schema: this.state.schema,\n }),\n }),\n this._nativeType\n );\n }\n\n array() {\n if (\n this.state.autoGenerate?.kind === \"now\" ||\n this.state.autoGenerate?.kind === \"updatedAt\"\n )\n refuseListGenerator(\"s.time\");\n return new TimeScalar(\n updateState(this, {\n array: true,\n base: v.isoTime<{\n nullable: State[\"nullable\"];\n array: true;\n schema: State[\"schema\"];\n }>({\n nullable: this.state.nullable,\n array: true,\n schema: this.state.schema,\n }),\n }),\n this._nativeType\n );\n }\n\n id() {\n return new TimeScalar(\n updateState(this, { isId: true, isUnique: true }),\n this._nativeType\n );\n }\n\n unique() {\n return new TimeScalar(\n updateState(this, { isUnique: true }),\n this._nativeType\n );\n }\n\n schema<S extends StandardSchemaV1<string>>(schema: S) {\n return new TimeScalar(\n updateState(this, {\n schema,\n base: v.isoTime<{\n nullable: State[\"nullable\"];\n array: State[\"array\"];\n schema: S;\n }>({\n nullable: this.state.nullable,\n array: this.state.array,\n schema,\n }),\n }),\n this._nativeType\n );\n }\n\n default<V extends DefaultValueInput<State>>(value: V) {\n return new TimeScalar(\n updateState(this, {\n hasDefault: true,\n default: value,\n optional: true,\n }),\n this._nativeType\n );\n }\n\n /**\n * Maps this scalar to a custom column name in the database\n */\n map(columnName: string) {\n return new TimeScalar(updateState(this, { columnName }), this._nativeType);\n }\n\n now() {\n if (this.state.array) refuseListGenerator(\"s.time\");\n return new TimeScalar(\n updateState(this, {\n hasDefault: true,\n autoGenerate: { kind: \"now\" },\n default: defaultNow,\n optional: true,\n }),\n this._nativeType\n );\n }\n\n updatedAt() {\n if (this.state.array) refuseListGenerator(\"s.time\");\n return new TimeScalar(\n updateState(this, {\n hasDefault: true,\n autoGenerate: { kind: \"updatedAt\" },\n default: defaultUpdatedAt,\n optional: true,\n }),\n this._nativeType\n );\n }\n\n /**\n * Stores time without timezone information (the default).\n * Use an explicit native type for an existing TIMETZ column.\n *\n * Use this when:\n * - You want to store local times (e.g., \"store opens at 9:00 AM\")\n * - The time should not be converted based on timezone\n */\n withoutTimezone() {\n return new TimeScalar(\n updateState(this, { withTimezone: false }),\n this._nativeType\n );\n }\n\n get [\"~\"]() {\n return {\n state: this.state,\n nativeType: this._nativeType,\n };\n }\n}\n\nexport const time = <\n Db extends NativeDialect = never,\n const Given extends ExactNativeTypeMap<Given> = never,\n>(\n nativeType?: NativeTypeArgument<Db, Given>\n) =>\n new TimeScalar(\n { ...createDefaultState(\"time\", timeBase), withTimezone: false },\n admitNativeType(\"s.time\", nativeType)\n );\n","/**\n * The definition boundary for `s.decimal({ precision, scale })`.\n *\n * A scale cannot be inferred from storage, a value, a driver, or an operation:\n * SQLite ignores the numbers in `DECIMAL(10,5)` and may put a fractional value\n * in a binary64 double. So the domain is DECLARED once, here, and every later\n * consumer — validation, DDL, binding, decoding, comparison, arithmetic,\n * migration — reads that one frozen fact off the resolved scalar.\n *\n * The descriptor is the developer's own argument, or two numbers a schema\n * document carried verbatim; neither is a hostile object, so it is read like\n * any other argument — no read-once snapshot, no key enumeration. What this\n * module owns is whether the two numbers name a domain at all.\n */\n\nimport { ValidationError } from \"@errors\";\nimport type { StandardSchemaV1 } from \"@standard-schema/spec\";\nimport type { DecimalDescriptor } from \"@validation/primitives/decimal-codec\";\nimport { validateSchema } from \"@validation/primitives/helpers\";\nimport { isRecord } from \"@validation/value-guards\";\n\n/** The one construction-time refusal of a decimal declaration. */\nfunction refuse(path: string, message: string): never {\n throw new ValidationError(\n { kind: \"schema-builder\", builder: \"s.decimal\", path },\n [{ path, message }]\n );\n}\n\n/**\n * The frozen fixed-decimal domain the two numbers name: `precision` an integer\n * from 1 to the maximum safe integer, `scale` an integer from 0 to `precision`,\n * so \"at most `precision` total digits and at most `scale` fractional digits\"\n * is a domain with values in it.\n *\n * Its unique coverage is the schema document and an untyped JavaScript caller:\n * `read.ts` hands the numbers over as they were written, so `10.5`, `1e300` and\n * `-0` (which `JSON.parse` keeps and `JSON.stringify` loses) reach this check\n * and nothing earlier. The argument is `unknown` because the document seam\n * passes it untyped; it is read as an ordinary object, not a hostile one.\n * Whether a given PROVIDER can store the domain is a different question with a\n * different owner: the adapter answers it once when the schema is bound.\n */\nexport function readDecimalDescriptor(source: unknown): DecimalDescriptor {\n const precision = isRecord(source) ? source.precision : undefined;\n const scale = isRecord(source) ? source.scale : undefined;\n if (\n !(\n typeof precision === \"number\" &&\n Number.isSafeInteger(precision) &&\n precision >= 1\n )\n ) {\n refuse(\n \"descriptor.precision\",\n \"'precision' must be an integer between 1 and the maximum safe integer\"\n );\n }\n if (\n !(\n typeof scale === \"number\" &&\n Number.isSafeInteger(scale) &&\n scale >= 0 &&\n scale <= precision &&\n !Object.is(scale, -0)\n )\n ) {\n refuse(\n \"descriptor.scale\",\n \"'scale' must be an integer between 0 and precision\"\n );\n }\n return Object.freeze({ precision, scale });\n}\n\n/**\n * A fixed-decimal LIST is not a key, and this is where a chain that tries to\n * make one into a key stops (plan 2.1).\n *\n * Both directions are refused because the chain has two of them:\n * `.array().id()` names a list and then a key, `.id().array()` names a key and\n * then a list, and only refusing the one that comes second would leave the\n * other spelling admitted. The exclusion is the DECLARATION's, not the\n * database's: a decimal list is stored as one container value on two of three\n * providers, so a key over it would be a key over a JSON document whose\n * identity is its spelling rather than its members — and there is no member\n * arrangement that could make it addressable.\n *\n * The whole-schema rule F007 (\"an ID cannot be an array\") is untouched and\n * still owns every OTHER scalar type. This refuses earlier, at the call that\n * writes the illegal chain, and it also owns `.unique()`, which no rule in the\n * repository refuses on a list of any type.\n */\nexport function refuseDecimalListKey(\n position: \"id\" | \"unique\" | \"array\"\n): never {\n const explanation =\n \"a fixed-decimal list cannot be an ID, a unique field, an index member, a foreign-key member, or a relation identity member\";\n refuse(\n position,\n position === \"array\"\n ? `A decimal key cannot become a list: ${explanation}`\n : `A decimal list cannot be declared '.${position}()': ${explanation}`\n );\n}\n\n/**\n * A literal default, normalized through the field's complete current schema at\n * DEFINITION time, so model metadata holds the canonical logical value the DDL\n * renderer, the schema-document serializer and the create schema's trusted\n * default all read. A value outside the declared domain fails at the call that\n * wrote it, not at the first write.\n *\n * A function default keeps its closure, exactly as every other scalar's does:\n * a closure has no canonical spelling to retain, and the create schema runs the\n * field codec on each value it returns.\n */\nexport function normalizeDecimalDefault(\n value: unknown,\n schema: StandardSchemaV1<unknown, unknown>\n): unknown {\n if (typeof value === \"function\") return value;\n const result = validateSchema(schema, value);\n if (result.issues !== undefined) {\n refuse(\"default\", \"The decimal default did not satisfy its field schema\");\n }\n return result.value;\n}\n","import type { StandardSchemaV1 } from \"@standard-schema/spec\";\nimport type { DecimalDescriptor } from \"@validation/primitives/decimal-codec\";\nimport type { Decimal } from \"@validation/primitives/decimal-value\";\nimport v from \"@validation/primitives/v\";\nimport {\n createDefaultState,\n type DefaultValueInput,\n nullableDefault,\n type ScalarState,\n updateState,\n} from \"../common\";\nimport {\n normalizeDecimalDefault,\n readDecimalDescriptor,\n refuseDecimalListKey,\n} from \"./descriptor\";\n\n/**\n * The shared L1 descriptor supplies the two required keys. This intersection\n * makes that surface exact for held objects too, without declaring a second L2\n * precision/scale bag.\n */\ntype KeysOfUnion<Given> = Given extends unknown ? keyof Given : never;\n\ntype ExactDomain<Given> = Given &\n Record<Exclude<KeysOfUnion<Given>, keyof DecimalDescriptor>, never>;\n\n/**\n * The type-level half of plan 2.1's list exclusion.\n *\n * A key position is refused by making the RECEIVER unassignable, which is what\n * lets the diagnostic carry the reason: TypeScript reports the missing property\n * by name, so `s.decimal({...}).array().id()` reads as \"a fixed-decimal list\n * cannot be a key\" rather than as an arity or an argument error. The scalar's\n * own type is intersected in, so inside the method body `this` is the scalar it\n * has always been and no assertion is needed to reach its state.\n *\n * `unknown` on the legal side is inert: intersecting it changes nothing, so a\n * non-list decimal keeps exactly the chain it had, and a scalar whose arity is\n * still the unresolved `boolean` is admitted — only a declared list is refused.\n */\ninterface DecimalListKeyRefusal {\n readonly \"a fixed-decimal list cannot be a key\": never;\n}\n\ntype NotAList<State extends ScalarState<\"decimal\">> =\n State[\"array\"] extends true ? DecimalListKeyRefusal : unknown;\n\ntype NotAKey<State extends ScalarState<\"decimal\">> = State[\"isId\"] extends true\n ? DecimalListKeyRefusal\n : State[\"isUnique\"] extends true\n ? DecimalListKeyRefusal\n : unknown;\n\ntype DecimalScalarState<State extends ScalarState<\"decimal\">> = State & {\n readonly decimal: DecimalDescriptor;\n};\n\nexport class DecimalScalar<State extends ScalarState<\"decimal\">> {\n private readonly state: DecimalScalarState<State>;\n\n constructor(state: DecimalScalarState<State>) {\n this.state = state;\n }\n\n /** The frozen domain, carried by reference so identity survives a chain. */\n private get descriptor(): DecimalDescriptor {\n return this.state.decimal;\n }\n\n nullable() {\n return new DecimalScalar(\n updateState(this, {\n nullable: true,\n hasDefault: true,\n default: nullableDefault(this.state),\n optional: true,\n // The custom schema travels with the rebuilt base. `create` reads\n // `state.schema` directly, but `set`, `equals` and the field's own\n // value schema all read `state.base` — dropping it here would make one\n // field refine on create and not on update.\n base: v.decimal<{\n nullable: true;\n array: State[\"array\"];\n decimal: DecimalDescriptor;\n schema: State[\"schema\"];\n }>({\n nullable: true,\n array: this.state.array,\n decimal: this.descriptor,\n schema: this.state.schema,\n }),\n })\n );\n }\n\n array(this: DecimalScalar<State> & NotAKey<State>) {\n if (this.state.isId || this.state.isUnique) refuseDecimalListKey(\"array\");\n const base = v.decimal<{\n nullable: State[\"nullable\"];\n array: true;\n decimal: DecimalDescriptor;\n schema: State[\"schema\"];\n }>({\n nullable: this.state.nullable,\n array: true,\n decimal: this.descriptor,\n schema: this.state.schema,\n });\n const state = updateState(this, { array: true, base });\n if (this.state.hasDefault && typeof this.state.default !== \"function\") {\n Object.defineProperty(state, \"default\", {\n value: normalizeDecimalDefault(this.state.default, base),\n configurable: true,\n enumerable: true,\n writable: true,\n });\n }\n return new DecimalScalar(state);\n }\n\n id(this: DecimalScalar<State> & NotAList<State>) {\n if (this.state.array) refuseDecimalListKey(\"id\");\n return new DecimalScalar(updateState(this, { isId: true, isUnique: true }));\n }\n\n unique(this: DecimalScalar<State> & NotAList<State>) {\n if (this.state.array) refuseDecimalListKey(\"unique\");\n return new DecimalScalar(updateState(this, { isUnique: true }));\n }\n\n /**\n * A literal default is normalized through the field codec HERE, at\n * definition time, so model metadata retains the canonical logical value and\n * a schema document round-trips to the same declaration. A value outside the\n * declared domain fails at the call that wrote it, not at the first write.\n */\n default<V extends DefaultValueInput<State>>(value: V) {\n return withValidatedDecimalDefault(\n this,\n normalizeDecimalDefault(value, this.state.base)\n );\n }\n\n /**\n * Refine or brand the exact value. The schema observes a `Decimal` — the\n * public value type — and the declared domain validates whatever it returns\n * LAST, so a custom schema can narrow the domain but never escape it, and it\n * cannot change the value family the field reads back as.\n */\n schema<S extends StandardSchemaV1<Decimal>>(schema: S) {\n const base = v.decimal<{\n nullable: State[\"nullable\"];\n array: State[\"array\"];\n decimal: DecimalDescriptor;\n schema: S;\n }>({\n nullable: this.state.nullable,\n array: this.state.array,\n decimal: this.descriptor,\n schema,\n });\n const state = updateState(this, { schema, base });\n if (this.state.hasDefault && typeof this.state.default !== \"function\") {\n Object.defineProperty(state, \"default\", {\n value: normalizeDecimalDefault(this.state.default, base),\n configurable: true,\n enumerable: true,\n writable: true,\n });\n }\n return new DecimalScalar(state);\n }\n\n map(columnName: string) {\n return new DecimalScalar(updateState(this, { columnName }));\n }\n\n get [\"~\"](): {\n state: DecimalScalarState<State>;\n nativeType?: undefined;\n } {\n // A fixed decimal has no native-type override: PostgreSQL's `NUMERIC(p,s)`,\n // MySQL's `DECIMAL(p,s)` and SQLite's checked scaled `INTEGER` are all\n // DERIVED from the declared domain, and a second spelling beside it would\n // be a second answer to what the column is. The absence is DECLARED so the\n // scalar union keeps one internal shape for every reader.\n return { state: this.state };\n }\n}\n\n/**\n * Store the canonical verdict of the field's current base schema.\n *\n * This is an internal schema-document seam, deliberately absent from the\n * public decimal barrel. The document interpreter already has to validate a\n * decoded default to own its J008 diagnostic; feeding that verdict back\n * through `.default()` would run the same field codec a second time.\n */\nexport function withValidatedDecimalDefault<\n State extends ScalarState<\"decimal\">,\n>(scalar: DecimalScalar<State>, value: unknown) {\n return new DecimalScalar(\n updateState(scalar, {\n hasDefault: true,\n default: value,\n optional: true,\n })\n );\n}\n\n/**\n * The one public decimal factory.\n *\n * `precision` is the maximum total digit count and `scale` the maximum\n * fractional digit count; values are multiples of `10^-scale`, and an input\n * that does not fit is refused rather than silently rounded. There is no\n * zero-argument form, no native-type override, and no second \"fixed decimal\"\n * factory: portable exact decimal arithmetic needs these two numbers, and\n * SQLite cannot supply them from storage, so they are declared once here.\n */\nexport const buildDecimalScalar = (descriptor: unknown) => {\n const domain = readDecimalDescriptor(descriptor);\n return new DecimalScalar({\n ...createDefaultState(\n \"decimal\",\n v.decimal<{ decimal: DecimalDescriptor }>({ decimal: domain })\n ),\n decimal: domain,\n });\n};\n\n/** The exact public argument surface over the untyped construction seam. */\nexport const decimal = <const D>(\n descriptor: D & NoInfer<DecimalDescriptor & ExactDomain<D>>\n) => buildDecimalScalar(descriptor);\n","// Enum Scalar\n// Standalone scalar class with State generic pattern\n\nimport type { EnumValues } from \"@validation/primitives/enum\";\nimport v from \"@validation/primitives/v\";\nimport {\n createDefaultState,\n type DefaultValueInput,\n nullableDefault,\n type ScalarState,\n updateState,\n} from \"../common\";\nimport { admitNativeType } from \"../native-catalog\";\nimport type {\n ExactNativeTypeMap,\n NativeDialect,\n NativeTypeArgument,\n NativeTypeDeclaration,\n} from \"../native-types\";\n\nexport class EnumScalar<State extends ScalarState<\"enum\">> {\n private readonly state: State;\n private readonly _nativeType?: NativeTypeDeclaration | undefined;\n constructor(state: State, _nativeType?: NativeTypeDeclaration) {\n this.state = state;\n this._nativeType = _nativeType;\n }\n\n get enumValues() {\n return (\n \"values\" in this.state.base ? this.state.base.values : []\n ) as EnumValues<State[\"base\"]>;\n }\n\n nullable() {\n return new EnumScalar(\n updateState(this, {\n nullable: true,\n hasDefault: true,\n default: nullableDefault(this.state),\n optional: true,\n base: v.enum<\n typeof this.enumValues,\n {\n nullable: true;\n array: State[\"array\"];\n }\n >(this.enumValues, {\n nullable: true,\n array: this.state.array,\n }),\n }),\n this._nativeType\n );\n }\n\n array() {\n return new EnumScalar(\n updateState(this, {\n array: true,\n base: v.enum<\n typeof this.enumValues,\n {\n nullable: State[\"nullable\"];\n array: true;\n }\n >(this.enumValues, {\n nullable: this.state.nullable,\n array: true,\n }),\n }),\n this._nativeType\n );\n }\n\n default<V extends DefaultValueInput<State>>(value: V) {\n return new EnumScalar(\n updateState(this, {\n hasDefault: true,\n default: value,\n optional: true,\n }),\n this._nativeType\n );\n }\n\n map(columnName: string) {\n return new EnumScalar(updateState(this, { columnName }), this._nativeType);\n }\n\n /**\n * Set a custom name for the enum type in the database.\n * This allows reusing the same enum across multiple tables.\n *\n * @example\n * ```ts\n * const Status = s.enum([\"PENDING\", \"ACTIVE\"]).name(\"status\");\n *\n * const user = s.model({ status: Status });\n * const order = s.model({ status: Status }); // Same \"status\" enum type\n * ```\n */\n name(enumName: string) {\n return new EnumScalar(updateState(this, { enumName }), this._nativeType);\n }\n\n get [\"~\"]() {\n return {\n state: this.state,\n nativeType: this._nativeType,\n };\n }\n}\n\nexport const enumScalar = <\n // A readonly tuple is admitted; see `enum_` for the mutable arm.\n const T extends string[] | readonly string[],\n Db extends NativeDialect = never,\n const Given extends ExactNativeTypeMap<Given> = never,\n>(\n values: T,\n nativeType?: NativeTypeArgument<Db, Given>\n) => {\n return new EnumScalar(\n createDefaultState(\"enum\", v.enum(values)),\n admitNativeType(\"s.enum\", nativeType)\n );\n};\n","import type { StandardSchemaV1 } from \"@standard-schema/spec\";\nimport v from \"@validation/primitives/v\";\nimport {\n createDefaultState,\n type DefaultValueInput,\n nullableDefault,\n type ScalarState,\n updateState,\n} from \"../common\";\nimport { admitNativeType } from \"../native-catalog\";\nimport type {\n ExactNativeTypeMap,\n NativeDialect,\n NativeTypeArgument,\n NativeTypeDeclaration,\n} from \"../native-types\";\n\nconst intBase = v.integer();\n\nexport class IntScalar<State extends ScalarState<\"int\">> {\n private readonly state: State;\n private readonly _nativeType?: NativeTypeDeclaration | undefined;\n\n constructor(state: State, _nativeType?: NativeTypeDeclaration) {\n this.state = state;\n this._nativeType = _nativeType;\n }\n\n nullable() {\n return new IntScalar(\n updateState(this, {\n nullable: true,\n hasDefault: true,\n default: nullableDefault(this.state),\n optional: true,\n base: v.integer<{\n nullable: true;\n array: State[\"array\"];\n schema: State[\"schema\"];\n }>({\n nullable: true,\n array: this.state.array,\n schema: this.state.schema,\n }),\n }),\n this._nativeType\n );\n }\n\n array() {\n return new IntScalar(\n updateState(this, {\n array: true,\n base: v.integer<{\n nullable: State[\"nullable\"];\n array: true;\n schema: State[\"schema\"];\n }>({\n nullable: this.state.nullable,\n array: true,\n schema: this.state.schema,\n }),\n }),\n this._nativeType\n );\n }\n\n id() {\n return new IntScalar(\n updateState(this, { isId: true, isUnique: true }),\n this._nativeType\n );\n }\n\n unique() {\n return new IntScalar(\n updateState(this, { isUnique: true }),\n this._nativeType\n );\n }\n\n default<V extends DefaultValueInput<State>>(value: V) {\n return new IntScalar(\n updateState(this, {\n hasDefault: true,\n default: value,\n optional: true,\n }),\n this._nativeType\n );\n }\n\n schema<S extends StandardSchemaV1<number>>(schema: S) {\n return new IntScalar(\n updateState(this, {\n schema,\n base: v.integer<{\n nullable: State[\"nullable\"];\n array: State[\"array\"];\n schema: S;\n }>({\n nullable: this.state.nullable,\n array: this.state.array,\n schema,\n }),\n }),\n this._nativeType\n );\n }\n\n map(columnName: string) {\n return new IntScalar(updateState(this, { columnName }), this._nativeType);\n }\n\n increment() {\n return new IntScalar(\n updateState(this, {\n hasDefault: true,\n autoGenerate: { kind: \"increment\" },\n default: undefined,\n disallowZero: true,\n optional: true,\n }),\n this._nativeType\n );\n }\n\n private _internal?: {\n state: State;\n nativeType: NativeTypeDeclaration | undefined;\n };\n\n get [\"~\"]() {\n return (this._internal ??= {\n state: this.state,\n nativeType: this._nativeType,\n });\n }\n}\n\nexport const int = <\n Db extends NativeDialect = never,\n const Given extends ExactNativeTypeMap<Given> = never,\n>(\n nativeType?: NativeTypeArgument<Db, Given>\n) =>\n new IntScalar(\n createDefaultState(\"int\", intBase),\n admitNativeType(\"s.int\", nativeType)\n );\n","import { ValidationError } from \"@errors\";\nimport {\n JsonNull,\n type JsonNullSentinel,\n jsonNullKindOf,\n} from \"@schema/json-null\";\nimport type { StandardSchemaV1 } from \"@standard-schema/spec\";\nimport type { JsonValue } from \"@validation\";\nimport type { JsonInput } from \"@validation/primitives/json\";\nimport v from \"@validation/primitives/v\";\nimport {\n createDefaultState,\n type DefaultValue,\n type DefaultValueInput,\n nullableDefault,\n type ScalarState,\n updateState,\n} from \"../common\";\nimport { admitNativeType } from \"../native-catalog\";\nimport type {\n ExactNativeTypeMap,\n NativeDialect,\n NativeTypeArgument,\n NativeTypeDeclaration,\n} from \"../native-types\";\n\nconst jsonBase = v.json();\n\nexport class JsonScalar<\n State extends ScalarState<\"json\"> = ScalarState<\"json\">,\n> {\n private readonly state: State;\n private readonly _nativeType?: NativeTypeDeclaration | undefined;\n constructor(state: State, _nativeType?: NativeTypeDeclaration) {\n this.state = state;\n this._nativeType = _nativeType;\n }\n\n nullable() {\n return new JsonScalar(\n updateState(this, {\n nullable: true,\n hasDefault: true,\n default: nullableDefault(this.state),\n optional: true,\n base: v.json<{\n nullable: true;\n schema: State[\"schema\"];\n }>({\n nullable: true,\n schema: this.state.schema,\n }),\n }),\n this._nativeType\n );\n }\n\n default<\n V extends\n | DefaultValueInput<State>\n | DefaultValue<\n JsonNullSentinel<\n State[\"nullable\"] extends true ? \"JsonNull\" | \"DbNull\" : \"JsonNull\"\n >\n >,\n >(value: V) {\n const kind = jsonNullKindOf(value);\n if (kind === \"AnyNull\" || (kind === \"DbNull\" && !this.state.nullable)) {\n throw new ValidationError(\n { kind: \"schema-builder\", builder: \"s.json\", path: \"default\" },\n [\n {\n path: \"default\",\n message: \"JSON default must name a null this column can store\",\n },\n ]\n );\n }\n const defaultValue =\n value === null && !this.state.nullable ? JsonNull : value;\n return new JsonScalar(\n updateState(this, {\n hasDefault: true,\n default: defaultValue,\n optional: true,\n }),\n this._nativeType\n );\n }\n\n schema<S extends StandardSchemaV1<JsonInput, JsonValue>>(schema: S) {\n return new JsonScalar(\n updateState(this, {\n schema,\n base: v.json<{\n nullable: State[\"nullable\"];\n schema: S;\n }>({\n nullable: this.state.nullable,\n schema,\n }),\n }),\n this._nativeType\n );\n }\n\n map(columnName: string) {\n return new JsonScalar(updateState(this, { columnName }), this._nativeType);\n }\n\n get [\"~\"]() {\n return {\n state: this.state,\n nativeType: this._nativeType,\n };\n }\n}\n\nexport const json = <\n Db extends NativeDialect = never,\n const Given extends ExactNativeTypeMap<Given> = never,\n>(\n nativeType?: NativeTypeArgument<Db, Given>\n) =>\n new JsonScalar(\n createDefaultState(\"json\", jsonBase),\n admitNativeType(\"s.json\", nativeType)\n );\n","import type { StandardSchemaV1 } from \"@standard-schema/spec\";\nimport v from \"@validation/primitives/v\";\nimport {\n createDefaultState,\n type DefaultValueInput,\n nullableDefault,\n type ScalarState,\n updateState,\n} from \"../common\";\nimport { admitNativeType } from \"../native-catalog\";\nimport type {\n ExactNativeTypeMap,\n NativeDialect,\n NativeTypeArgument,\n NativeTypeDeclaration,\n} from \"../native-types\";\n\nconst numberBase = v.number();\n\nexport class NumberScalar<State extends ScalarState<\"number\">> {\n private readonly state: State;\n private readonly _nativeType?: NativeTypeDeclaration | undefined;\n\n constructor(state: State, _nativeType?: NativeTypeDeclaration) {\n this.state = state;\n this._nativeType = _nativeType;\n }\n\n nullable() {\n return new NumberScalar(\n updateState(this, {\n nullable: true,\n hasDefault: true,\n default: nullableDefault(this.state),\n optional: true,\n base: v.number<{\n nullable: true;\n array: State[\"array\"];\n schema: State[\"schema\"];\n }>({\n nullable: true,\n array: this.state.array,\n schema: this.state.schema,\n }),\n }),\n this._nativeType\n );\n }\n\n array() {\n return new NumberScalar(\n updateState(this, {\n array: true,\n base: v.number<{\n nullable: State[\"nullable\"];\n array: true;\n schema: State[\"schema\"];\n }>({\n nullable: this.state.nullable,\n array: true,\n schema: this.state.schema,\n }),\n }),\n this._nativeType\n );\n }\n\n id() {\n return new NumberScalar(\n updateState(this, { isId: true, isUnique: true }),\n this._nativeType\n );\n }\n\n unique() {\n return new NumberScalar(\n updateState(this, { isUnique: true }),\n this._nativeType\n );\n }\n\n default<V extends DefaultValueInput<State>>(value: V) {\n return new NumberScalar(\n updateState(this, {\n hasDefault: true,\n default: value,\n optional: true,\n }),\n this._nativeType\n );\n }\n\n schema<S extends StandardSchemaV1<number>>(schema: S) {\n return new NumberScalar(\n updateState(this, {\n schema,\n base: v.number<{\n nullable: State[\"nullable\"];\n array: State[\"array\"];\n schema: S;\n }>({\n nullable: this.state.nullable,\n array: this.state.array,\n schema,\n }),\n }),\n this._nativeType\n );\n }\n\n map(columnName: string) {\n return new NumberScalar(\n updateState(this, { columnName }),\n this._nativeType\n );\n }\n\n get [\"~\"]() {\n return {\n state: this.state,\n nativeType: this._nativeType,\n };\n }\n}\n\nexport const number = <\n Db extends NativeDialect = never,\n const Given extends ExactNativeTypeMap<Given> = never,\n>(\n nativeType?: NativeTypeArgument<Db, Given>\n) =>\n new NumberScalar(\n createDefaultState(\"number\", numberBase),\n admitNativeType(\"s.number\", nativeType)\n );\n","import { ValidationError } from \"@errors\";\nimport { validateSchema } from \"@validation/primitives/helpers\";\nimport v from \"@validation/primitives/v\";\nimport {\n createDefaultState,\n type DefaultValueInput,\n nullableDefault,\n type ScalarState,\n updateState,\n} from \"../common\";\n\nconst pointBase = v.point();\n\nexport class PointScalar<State extends ScalarState<\"point\">> {\n private readonly state: State;\n constructor(state: State) {\n this.state = state;\n }\n\n nullable() {\n return new PointScalar(\n updateState(this, {\n nullable: true,\n hasDefault: true,\n default: nullableDefault(this.state),\n optional: true,\n base: v.point<{\n nullable: true;\n }>({\n nullable: true,\n }),\n })\n );\n }\n\n default<V extends DefaultValueInput<State>>(value: V) {\n return new PointScalar(\n updateState(this, {\n hasDefault: true,\n default: normalizePointDefault(value, this.state.base),\n optional: true,\n })\n );\n }\n\n map(columnName: string) {\n return new PointScalar(updateState(this, { columnName }));\n }\n\n get [\"~\"](): { state: State; nativeType?: undefined } {\n return { state: this.state };\n }\n}\n\nfunction normalizePointDefault(value: unknown, schema: StateSchema): unknown {\n if (typeof value === \"function\") return value;\n const result = validateSchema(schema, value);\n if (!result.issues) return result.value;\n throw new ValidationError(\n { kind: \"schema-builder\", builder: \"s.point\", path: \"default\" },\n result.issues.map((issue) => ({\n path: issue.path?.join(\".\") ?? \"default\",\n message: issue.message,\n }))\n );\n}\n\ntype StateSchema = ScalarState<\"point\">[\"base\"];\n\n/** The one public GeoPoint scalar factory; EPSG:4326 is not configurable. */\nexport function point(...args: []) {\n if (args.length !== 0) {\n throw new ValidationError(\n { kind: \"schema-builder\", builder: \"s.point\", path: \"arguments\" },\n [\n {\n path: \"arguments\",\n message: \"s.point() takes no native type or options\",\n },\n ]\n );\n }\n return new PointScalar(createDefaultState(\"point\", pointBase));\n}\n","// Vector Scalar\n// Standalone scalar class with State generic pattern\n\nimport { ValidationError } from \"@errors\";\nimport v from \"@validation/primitives/v\";\nimport {\n createDefaultState,\n type DefaultValueInput,\n nullableDefault,\n type ScalarState,\n updateState,\n} from \"../common\";\nimport { admitNativeType } from \"../native-catalog\";\nimport type {\n ExactNativeTypeMap,\n NativeDialect,\n NativeTypeArgument,\n NativeTypeDeclaration,\n} from \"../native-types\";\n\nconst vectorBase = v.vector();\n\nexport class VectorScalar<State extends ScalarState<\"vector\">> {\n private readonly state: State;\n private readonly _nativeType?: NativeTypeDeclaration | undefined;\n\n constructor(state: State, _nativeType?: NativeTypeDeclaration) {\n this.state = state;\n this._nativeType = _nativeType;\n }\n\n nullable() {\n return new VectorScalar(\n updateState(this, {\n nullable: true,\n hasDefault: true,\n default: nullableDefault(this.state),\n optional: true,\n base: v.vector<{\n nullable: true;\n }>(this.state.dimension, {\n nullable: true,\n }),\n }),\n this._nativeType\n );\n }\n\n default<V extends DefaultValueInput<State>>(value: V) {\n return new VectorScalar(\n updateState(this, {\n hasDefault: true,\n default: value,\n optional: true,\n }),\n this._nativeType\n );\n }\n\n /**\n * Maps this scalar to a custom column name in the database\n */\n map(columnName: string) {\n return new VectorScalar(\n updateState(this, { columnName }),\n this._nativeType\n );\n }\n\n dimension(dim: number) {\n if (!Number.isSafeInteger(dim) || dim <= 0) {\n throw new ValidationError(\n { kind: \"schema-builder\", builder: \"s.vector\", path: \"dimension\" },\n [\n {\n path: \"dimension\",\n message: \"Vector dimension must be a positive safe integer\",\n },\n ]\n );\n }\n return new VectorScalar(\n updateState(this, {\n dimension: dim,\n base: v.vector(dim, { nullable: this.state.nullable }),\n }),\n this._nativeType\n );\n }\n\n get [\"~\"]() {\n return {\n state: this.state,\n nativeType: this._nativeType,\n };\n }\n}\n\nexport const vector = <\n Db extends NativeDialect = never,\n const Given extends ExactNativeTypeMap<Given> = never,\n>(\n nativeType?: NativeTypeArgument<Db, Given>\n) =>\n new VectorScalar(\n createDefaultState(\"vector\", vectorBase),\n admitNativeType(\"s.vector\", nativeType)\n );\n","// `s.toMany` — the other of the two relation factories.\n//\n// The factory states the SLOT CARDINALITY (many) and its argument states the\n// TARGET DOMAIN. A model-target collection is junction-capable and an empty\n// collection is `[]`, so there is no `.optional()` here and no `.unique()`\n// anywhere: the paired slot cardinality owns remote uniqueness.\n\nimport {\n type ExactVariantOptions,\n type NormalizedManyEntries,\n normalizeVariantEntries,\n type VariantGetterMap,\n type VariantMapGuard,\n type VariantOptions,\n type VariantToManyRelation,\n variantToManyTerminal,\n} from \"./polymorphic\";\nimport {\n createTargetSettlement,\n normalizeJunctionActions,\n normalizeJunctionToken,\n normalizeRelationName,\n refuseRelationInput,\n} from \"./terminal\";\nimport type {\n AnyRelation,\n Getter,\n GetterOnly,\n JunctionReferentialAction,\n JunctionSideActions,\n ModelToManyState,\n OrdinaryJunctionOverrides,\n RelationInternal,\n Replace,\n} from \"./types\";\n\n// =============================================================================\n// TERMINAL CAPABILITY SURFACE\n// =============================================================================\n\n/** A junction action: the symmetric shorthand, or one action per side. */\nexport type JunctionActionDeclaration =\n | JunctionReferentialAction\n | JunctionSideActions;\n\n/** Every key any map member of `Action` declares; a bare action declares none. */\ntype DeclaredMapKeys<Action> = Action extends JunctionReferentialAction\n ? never\n : keyof Action;\n\n/**\n * `{ source, target }` is exact: a key beside the two sides is refused\n * structurally, so a map held in a variable cannot carry one past\n * excess-property checking either. The keys are gathered across a union\n * before the check, so one clean member cannot vouch for another that carries\n * an extra key.\n */\nexport type ExactJunctionActions<Action> = Record<\n Exclude<DeclaredMapKeys<Action>, keyof JunctionSideActions>,\n never\n>;\n\n/**\n * A model-target collection slot.\n *\n * The junction overrides are independent, meaningful facts rather than stages of\n * one all-or-nothing value, so any subset may override its canonical default.\n * Exactly one endpoint owns all supplied overrides; the other endpoint supplies\n * none and consumes the mirrored resolved view. Whether these overrides belong\n * on the resolved physical owner is one full-schema topology rule, not a second\n * type-level guess — which is why they are offered before the inverse graph\n * exists and why the state does not carry them as a public type parameter.\n */\nexport type ModelToManyRelation<State> = {\n readonly \"~\": RelationInternal<State>;\n name<const Name extends string>(\n name: Name\n ): ModelToManyRelation<Replace<State, { readonly name: Name }>>;\n through(table: string): ModelToManyRelation<State>;\n source(token: string): ModelToManyRelation<State>;\n target(token: string): ModelToManyRelation<State>;\n onDelete<const Action extends JunctionActionDeclaration>(\n action: Action & ExactJunctionActions<Action>\n ): ModelToManyRelation<State>;\n onUpdate<const Action extends JunctionActionDeclaration>(\n action: Action & ExactJunctionActions<Action>\n ): ModelToManyRelation<State>;\n};\n\n// =============================================================================\n// PRIVATE TERMINAL\n// =============================================================================\n\nclass ModelToMany {\n readonly #state: ModelToManyState;\n readonly #internal: RelationInternal<ModelToManyState>;\n\n constructor(state: ModelToManyState) {\n this.#state = Object.freeze(state);\n this.#internal = Object.freeze({\n state: this.#state,\n settleTarget: createTargetSettlement(() => this.#state.target.getter),\n });\n }\n\n name(name: string): ModelToMany {\n return new ModelToMany({\n ...this.#state,\n name: normalizeRelationName(\"s.toMany\", name),\n });\n }\n\n through(table: string): ModelToMany {\n return this.#withJunction({\n ...this.#state.junction,\n table: normalizeJunctionToken(\"through\", table),\n });\n }\n\n source(token: string): ModelToMany {\n return this.#withJunction({\n ...this.#state.junction,\n source: normalizeJunctionToken(\"source\", token),\n });\n }\n\n target(token: string): ModelToMany {\n return this.#withJunction({\n ...this.#state.junction,\n target: normalizeJunctionToken(\"target\", token),\n });\n }\n\n onDelete(action: JunctionActionDeclaration): ModelToMany {\n return this.#withJunction({\n ...this.#state.junction,\n onDelete: normalizeJunctionActions(\"onDelete\", action),\n });\n }\n\n onUpdate(action: JunctionActionDeclaration): ModelToMany {\n return this.#withJunction({\n ...this.#state.junction,\n onUpdate: normalizeJunctionActions(\"onUpdate\", action),\n });\n }\n\n #withJunction(junction: OrdinaryJunctionOverrides): ModelToMany {\n return new ModelToMany({\n ...this.#state,\n junction: Object.freeze(junction),\n });\n }\n\n get \"~\"(): RelationInternal<ModelToManyState> {\n return this.#internal;\n }\n}\n\n// =============================================================================\n// FACTORY\n// =============================================================================\n\n/**\n * Declare a slot that holds a COLLECTION.\n *\n * The map overload is declared first so a variant map is never swallowed by the\n * broad getter overload. Dispatch examines only the argument representation and\n * never invokes a getter.\n */\nexport function toMany<\n const Entries extends VariantGetterMap,\n const Options extends VariantOptions<Entries> | undefined = undefined,\n>(\n variants: Entries & VariantMapGuard<Entries>,\n options?: Options & ExactVariantOptions<Options, Entries>\n): VariantToManyRelation<{\n readonly kind: \"relation\";\n readonly cardinality: \"many\";\n readonly target: {\n readonly kind: \"variants\";\n readonly entries: NormalizedManyEntries<Entries>;\n };\n}>;\nexport function toMany<const G>(getter: G & GetterOnly<G>): G extends Getter\n ? ModelToManyRelation<{\n readonly kind: \"relation\";\n readonly cardinality: \"many\";\n readonly target: { readonly kind: \"model\"; readonly getter: G };\n }>\n : never;\nexport function toMany(target: unknown, options?: unknown): AnyRelation {\n if (typeof target === \"function\") {\n // biome-ignore lint/complexity/noArguments: distinguishes omission from explicit undefined without changing the factory's public arity\n if (arguments.length > 1) {\n refuseRelationInput(\n \"s.toMany\",\n \"options\",\n \"A model-target relation takes exactly one argument\"\n );\n }\n return new ModelToMany({\n kind: \"relation\",\n cardinality: \"many\",\n target: { kind: \"model\", getter: target },\n });\n }\n return variantToManyTerminal({\n kind: \"relation\",\n cardinality: \"many\",\n target: {\n kind: \"variants\",\n entries: normalizeVariantEntries(\"s.toMany\", target, options),\n },\n });\n}\n"],"mappings":"uZAoBA,MAAM,EAAaA,EAAE,QAAQ,CAE7B,IAAa,EAAb,MAAa,YAAkD,CAC7D,MACA,YAEA,YAAY,EAAc,EAAqC,CAC7D,KAAK,MAAQ,EACb,KAAK,YAAc,EAGrB,UAAW,CACT,OAAO,IAAI,aACT,EAAY,KAAM,CAChB,SAAU,GACV,WAAY,GACZ,QAAS,EAAgB,KAAK,MAAM,CACpC,SAAU,GACV,KAAMA,EAAE,OAIL,CACD,SAAU,GACV,MAAO,KAAK,MAAM,MAClB,OAAQ,KAAK,MAAM,OACpB,CAAC,CACH,CAAC,CACF,KAAK,YACN,CAGH,OAAQ,CACN,OAAO,IAAI,aACT,EAAY,KAAM,CAChB,MAAO,GACP,KAAMA,EAAE,OAIL,CACD,SAAU,KAAK,MAAM,SACrB,MAAO,GACP,OAAQ,KAAK,MAAM,OACpB,CAAC,CACH,CAAC,CACF,KAAK,YACN,CAGH,IA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,CAChD,CAAC,CAGJ,OAAO,EAA4B,CACjC,OAAO,MAAA,EAAmB,CACxB,GAAG,MAAA,EAAY,SACf,OAAQ,EAAuB,SAAU,EAAM,CAChD,CAAC,CAGJ,SAAS,EAAgD,CACvD,OAAO,MAAA,EAAmB,CACxB,GAAG,MAAA,EAAY,SACf,SAAU,EAAyB,WAAY,EAAO,CACvD,CAAC,CAGJ,SAAS,EAAgD,CACvD,OAAO,MAAA,EAAmB,CACxB,GAAG,MAAA,EAAY,SACf,SAAU,EAAyB,WAAY,EAAO,CACvD,CAAC,CAGJ,GAAc,EAAkD,CAC9D,OAAO,IAAI,YAAY,CACrB,GAAG,MAAA,EACH,SAAU,OAAO,OAAO,EAAS,CAClC,CAAC,CAGJ,GAAI,KAA0C,CAC5C,OAAO,MAAA,IAoCX,SAAgB,OAAO,EAAiB,EAAgC,CAgBtE,OAfI,OAAO,GAAW,YAEhB,UAAU,OAAS,GACrB,EACE,WACA,UACA,qDACD,CAEI,IAAI,EAAY,CACrB,KAAM,WACN,YAAa,OACb,OAAQ,CAAE,KAAM,QAAS,OAAQ,EAAQ,CAC1C,CAAC,EAEG,EAAsB,CAC3B,KAAM,WACN,YAAa,OACb,OAAQ,CACN,KAAM,WACN,QAAS,EAAwB,WAAY,EAAQ,EAAQ,CAC9D,CACF,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{n as e}from"./chunk-BuuaeEvq.mjs";import{i as t}from"./base-D3m1S7Uc.mjs";import{a as n}from"./validator-
|
|
1
|
+
import{n as e}from"./chunk-BuuaeEvq.mjs";import{i as t}from"./base-D3m1S7Uc.mjs";import{a as n}from"./validator-BqzpyNmt.mjs";import{n as r}from"./suppressed-failure-Bdo2aK81.mjs";import{existsSync as i}from"node:fs";import{resolve as a}from"node:path";import{loadEnvFile as o}from"node:process";import{createJiti as s}from"jiti";const c=[`viborm.config.ts`,`viborm.config.mts`,`viborm.config.js`,`viborm.config.mjs`];function findFile(e,t){for(let n of t){let t=a(e,n);if(i(t))return t}return null}function failCli(e,n=!1){let r=t(e),i=e instanceof Error?e.message:typeof e==`string`?e:`CLI operation failed`,a=r?e.code:void 0,o=a?.startsWith(`V11`)?Number(a.slice(1))-11e3+10:r?2:1;process.stderr.write(n?`${JSON.stringify({error:r?e.toJSON():{name:e instanceof Error?e.name:`Error`,message:i},exitCode:o})}\n`:`${a?`[${a}] `:``}${i}\n`),process.exit(o)}async function finishCli(e,t,n=!1){let i=t;try{await e?.$disconnect()}catch(e){i={value:t?r(t.value,e):e}}i&&(n?failCli(i.value,!0):failCli(i.value))}async function runCli(e,t,n){let r,i;try{let t=await loadConfig(e);r=t.client,await n(t)}catch(e){i={value:e}}finally{await finishCli(r,i,t)}}function printJson(e,t){if(t){process.stdout.write(`${JSON.stringify(e,null,2)}\n`);return}let n=[],render=(e,t=``)=>{if(Array.isArray(e)){for(let r of e)n.push(`${t}-`),render(r,`${t} `);e.length===0&&n.push(`${t}(none)`)}else if(typeof e==`object`&&e)for(let[r,i]of Object.entries(e))typeof i==`object`&&i?(n.push(`${t}${r}:`),render(i,`${t} `)):n.push(`${t}${r}: ${String(i)}`);else n.push(`${t}${String(e)}`)};render(e),process.stdout.write(`${n.join(`
|
|
2
2
|
`)}\n`)}async function loadConfig(e={}){let t=process.cwd(),r=a(t,`.env`);i(r)&&o(r);let s=e.config?a(t,e.config):findFile(t,c);if(!(s&&i(s))){let t=e.config?[e.config]:c;throw Error(`Could not find VibORM configuration file.
|
|
3
3
|
|
|
4
4
|
Searched for:\n${t.map(e=>` - ${e}`).join(`
|
|
@@ -23,4 +23,4 @@ Searched for:\n${t.map(e=>` - ${e}`).join(`
|
|
|
23
23
|
name: s.string(),
|
|
24
24
|
});
|
|
25
25
|
`);return e.skipValidation||n(p),{client:u.client,driver:d,models:p,migrations:u.migrations}}function loadCliModule(e){return s(e,{tsconfigPaths:!0,interopDefault:!0}).import(e)}function extractModels(e){let t={};for(let[n,r]of Object.entries(e))isModel(r)&&(t[n]=r);return t}function isModel(e){if(typeof e!=`object`||!e)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&&`scalars`in n}function isValidClient(e){return e===null||typeof e!=`object`&&typeof e!=`function`?!1:Reflect.get(e,`$driver`)!==void 0&&Reflect.get(e,`$schema`)!==void 0}function defineConfig(e){return e}export{runCli as i,loadCliModule as n,printJson as r,defineConfig as t};
|
|
26
|
-
//# sourceMappingURL=utils-
|
|
26
|
+
//# sourceMappingURL=utils-DjXObbUK.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils-CtFUE8UN.mjs","names":[],"sources":["../src/cli/utils.ts"],"sourcesContent":["/**\n * CLI Utilities\n *\n * Configuration loading and other CLI utilities.\n *\n * Config file pattern similar to:\n * - drizzle.config.ts\n * - prisma (uses schema.prisma but we use TS)\n */\n\nimport { existsSync } from \"node:fs\";\nimport { resolve } from \"node:path\";\nimport { loadEnvFile } from \"node:process\";\nimport { createJiti } from \"jiti\";\nimport type { AnyDriver } from \"../drivers/driver\";\nimport { withSuppressedFailure } from \"../drivers/shared/suppressed-failure\";\nimport { isVibORMError } from \"../errors\";\nimport type { MigrationClient } from \"../migrations/push/planner\";\nimport type { MigrationStorageWriter } from \"../migrations/storage/contract\";\nimport type { ResolveCallback } from \"../migrations/types\";\nimport type { AnyModel } from \"../schema/model\";\nimport { validateSchemaOrThrow } from \"../schema/validation\";\n\n// =============================================================================\n// CONFIG TYPES\n// =============================================================================\n\n/**\n * Migration configuration options.\n */\nexport interface MigrationConfig {\n /** Estate directory (default: \"./migrations\") */\n dir?: string;\n /** Immutable exact physical table scope; include junctions and rename destinations. */\n tables?: readonly string[];\n /** Explicit rename, destructive-change and enum-value decisions for CLI planning. */\n resolve?: ResolveCallback;\n /**\n * Estate storage writer. Defaults to filesystem storage at `dir`.\n *\n * @example\n * ```ts\n * import { createFsStorageWriter } from \"viborm/migrations/storage/fs\";\n *\n * migrations: {\n * storage: createFsStorageWriter(\"./migrations\"),\n * }\n * ```\n */\n storage?: MigrationStorageWriter;\n}\n\n/**\n * VibORM configuration file format.\n *\n * Example viborm.config.ts:\n * ```ts\n * import { defineConfig } from \"viborm/config\";\n * import { client } from \"./src/db\";\n *\n * export default defineConfig({\n * client,\n * });\n * ```\n */\nexport interface VibORMConfig {\n /** VibORM client instance */\n client: MigrationClient & { $disconnect(): Promise<void> };\n /** Optional: Migration configuration */\n migrations?: MigrationConfig;\n}\n\nexport interface LoadConfigOptions {\n /** Path to config file (default: ./viborm.config.ts) */\n config?: string;\n /** Leave validation to the caller (`viborm check` reports every issue). */\n skipValidation?: boolean;\n}\n\nexport interface LoadedConfig {\n client: VibORMConfig[\"client\"];\n driver: AnyDriver;\n models: Record<string, AnyModel>;\n migrations?: MigrationConfig;\n}\n\n// =============================================================================\n// CONFIG FILE DISCOVERY\n// =============================================================================\n\nconst CONFIG_FILES = [\n \"viborm.config.ts\",\n \"viborm.config.mts\",\n \"viborm.config.js\",\n \"viborm.config.mjs\",\n];\n\n/**\n * Finds the first existing file from a list of candidates.\n */\nfunction findFile(cwd: string, candidates: string[]): string | null {\n for (const candidate of candidates) {\n const fullPath = resolve(cwd, candidate);\n if (existsSync(fullPath)) {\n return fullPath;\n }\n }\n return null;\n}\n\n// =============================================================================\n// CONFIG LOADING\n// =============================================================================\n\n/**\n * Loads VibORM configuration from viborm.config.ts file.\n *\n * The config file should export a default configuration object with:\n * - client: VibORM client instance created with createClient()\n */\nexport function failCli(error: unknown, json = false): never {\n const trusted = isVibORMError(error);\n const message =\n error instanceof Error\n ? error.message\n : typeof error === \"string\"\n ? error\n : \"CLI operation failed\";\n const code = trusted ? error.code : undefined;\n const exitCode = code?.startsWith(\"V11\")\n ? Number(code.slice(1)) - 11_000 + 10\n : trusted\n ? 2\n : 1;\n process.stderr.write(\n json\n ? `${JSON.stringify({ error: trusted ? error.toJSON() : { name: error instanceof Error ? error.name : \"Error\", message }, exitCode })}\\n`\n : `${code ? `[${code}] ` : \"\"}${message}\\n`\n );\n process.exit(exitCode);\n}\n\n/** Await owned CLI cleanup before reporting either the primary or cleanup failure. */\nexport async function finishCli(\n client: { $disconnect(): Promise<void> } | undefined,\n failure: { value: unknown } | undefined,\n json = false\n): Promise<void> {\n let outcome = failure;\n try {\n await client?.$disconnect();\n } catch (cleanup) {\n outcome = {\n value: failure ? withSuppressedFailure(failure.value, cleanup) : cleanup,\n };\n }\n if (outcome) {\n if (json) failCli(outcome.value, true);\n else failCli(outcome.value);\n }\n}\n\n/** Every command's frame: load the config, own its client, report through {@link finishCli}. */\nexport async function runCli(\n load: LoadConfigOptions,\n json: boolean | undefined,\n body: (config: LoadedConfig) => Promise<void>\n): Promise<void> {\n let client: { $disconnect(): Promise<void> } | undefined;\n let failure: { value: unknown } | undefined;\n try {\n const config = await loadConfig(load);\n client = config.client;\n await body(config);\n } catch (error) {\n failure = { value: error };\n } finally {\n await finishCli(client, failure, json);\n }\n}\n\n/** JSON for `--json`, else an indented outline of the same value. */\nexport function printJson(value: unknown, json: boolean): void {\n if (json) {\n process.stdout.write(`${JSON.stringify(value, null, 2)}\\n`);\n return;\n }\n const lines: string[] = [];\n const render = (item: unknown, indent = \"\") => {\n if (Array.isArray(item)) {\n for (const entry of item) {\n lines.push(`${indent}-`);\n render(entry, `${indent} `);\n }\n if (item.length === 0) lines.push(`${indent}(none)`);\n } else if (item !== null && typeof item === \"object\") {\n for (const [key, entry] of Object.entries(item)) {\n if (entry !== null && typeof entry === \"object\") {\n lines.push(`${indent}${key}:`);\n render(entry, `${indent} `);\n } else lines.push(`${indent}${key}: ${String(entry)}`);\n }\n } else lines.push(`${indent}${String(item)}`);\n };\n render(value);\n process.stdout.write(`${lines.join(\"\\n\")}\\n`);\n}\n\nexport async function loadConfig(\n options: LoadConfigOptions = {}\n): Promise<LoadedConfig> {\n const cwd = process.cwd();\n const envPath = resolve(cwd, \".env\");\n if (existsSync(envPath)) loadEnvFile(envPath);\n\n // Find config file\n const configPath = options.config\n ? resolve(cwd, options.config)\n : findFile(cwd, CONFIG_FILES);\n\n if (!(configPath && existsSync(configPath))) {\n const searchedPaths = options.config ? [options.config] : CONFIG_FILES;\n\n throw new Error(\n \"Could not find VibORM configuration file.\\n\\n\" +\n `Searched for:\\n${searchedPaths.map((f) => ` - ${f}`).join(\"\\n\")}\\n\\n` +\n \"Create a viborm.config.ts file:\\n\\n\" +\n ` import { defineConfig } from \"viborm/config\";\\n` +\n ` import { client } from \"./src/db\";\\n\\n` +\n \" export default defineConfig({\\n\" +\n \" client,\\n\" +\n \" });\\n\"\n );\n }\n\n // Load the config file\n const configModule = await loadCliModule<\n VibORMConfig & { default?: VibORMConfig; config?: VibORMConfig }\n >(configPath);\n\n // Extract config (handle both default export and named export)\n const config: VibORMConfig =\n (Object.hasOwn(configModule, \"default\") && configModule.default) ||\n configModule.config ||\n configModule;\n\n // Validate client\n if (!config.client) {\n throw new Error(\n `Missing \"client\" in ${configPath}.\\n\\n` +\n \"Your config should include a VibORM client:\\n\\n\" +\n ` import { createClient } from \"viborm\";\\n` +\n \" const client = createClient({ driver, schema });\\n\\n\" +\n \" export default defineConfig({\\n\" +\n \" client,\\n\" +\n \" });\\n\"\n );\n }\n\n if (!isValidClient(config.client)) {\n throw new Error(\n `Invalid \"client\" in ${configPath}.\\n\\n` +\n \"The client must be created with createClient().\\n\"\n );\n }\n\n // Extract driver and schema from client\n const driver = config.client.$driver;\n const schemaInput = config.client.$schema;\n\n // Extract models from schema (filter out non-model exports)\n const models = extractModels(schemaInput);\n\n if (Object.keys(models).length === 0) {\n throw new Error(\n `No models found in client schema from ${configPath}.\\n\\n` +\n \"Make sure your client was created with schema models:\\n\\n\" +\n \" // src/schema.ts\\n\" +\n ` import { s } from \"viborm\";\\n\\n` +\n \" export const user = s.model({\\n\" +\n \" id: s.string().id(),\\n\" +\n \" name: s.string(),\\n\" +\n \" });\\n\"\n );\n }\n\n // Validate schema before proceeding\n if (!options.skipValidation) validateSchemaOrThrow(models);\n\n return {\n client: config.client,\n driver,\n models,\n migrations: config.migrations,\n };\n}\n\n/**\n * Dynamically imports a TypeScript/JavaScript module.\n */\nexport function loadCliModule<T>(filePath: string): Promise<T> {\n // Dependency imports need CJS interop; consumers select only authored defaults.\n return createJiti(filePath, {\n tsconfigPaths: true,\n interopDefault: true,\n }).import<T>(filePath);\n}\n\n/**\n * Extracts model objects from a module by checking for Model instances.\n */\nfunction extractModels(\n schema: Record<string, unknown>\n): Record<string, AnyModel> {\n const models: Record<string, AnyModel> = {};\n\n for (const [key, value] of Object.entries(schema)) {\n if (isModel(value)) {\n models[key] = value;\n }\n }\n\n return models;\n}\n\n/**\n * Checks if a value is a VibORM Model instance.\n */\nfunction isModel(value: unknown): value is AnyModel {\n if (value === null || typeof value !== \"object\") return false;\n const metadata = Reflect.get(value, \"~\");\n if (metadata === null || typeof metadata !== \"object\") return false;\n const state = Reflect.get(metadata, \"state\");\n // Model state exposes `scalars`/`relations` (never `fields`); the rest of\n // the codebase discriminates models the same way (see serializer).\n return state !== null && typeof state === \"object\" && \"scalars\" in state;\n}\n\n/**\n * Checks if a value is a valid VibORM client instance.\n */\nfunction isValidClient(value: unknown): boolean {\n // The client is a Proxy whose only trap is `get`, so `\"$driver\" in value`\n // (which triggers the `has` trap / falls back to the bare target) is always\n // false. Probe via property access instead.\n // `typeof null === \"object\"`, so null has to be refused here: Reflect.get\n // throws on it rather than answering undefined.\n if (\n value === null ||\n (typeof value !== \"object\" && typeof value !== \"function\")\n ) {\n return false;\n }\n return (\n Reflect.get(value, \"$driver\") !== undefined &&\n Reflect.get(value, \"$schema\") !== undefined\n );\n}\n\n// =============================================================================\n// DEFINE CONFIG HELPER\n// =============================================================================\n\n/**\n * Helper function for defining VibORM configuration with type safety.\n *\n * @example\n * ```ts\n * // viborm.config.ts\n * import { defineConfig } from \"viborm/config\";\n * import { client } from \"./src/db\";\n *\n * export default defineConfig({\n * client,\n * });\n * ```\n */\nexport function defineConfig<const C extends VibORMConfig>(\n config: C &\n Record<Exclude<keyof C, keyof VibORMConfig>, never> &\n (C extends { migrations: infer M }\n ? {\n migrations: M &\n Record<Exclude<keyof M, keyof MigrationConfig>, never>;\n }\n : unknown)\n): C {\n return config;\n}\n"],"mappings":"0UA0FA,MAAM,EAAe,CACnB,mBACA,oBACA,mBACA,oBACD,CAKD,SAAS,SAAS,EAAa,EAAqC,CAClE,IAAK,IAAM,KAAa,EAAY,CAClC,IAAM,EAAW,EAAQ,EAAK,EAAU,CACxC,GAAI,EAAW,EAAS,CACtB,OAAO,EAGX,OAAO,KAaT,SAAgB,QAAQ,EAAgB,EAAO,GAAc,CAC3D,IAAM,EAAU,EAAc,EAAM,CAC9B,EACJ,aAAiB,MACb,EAAM,QACN,OAAO,GAAU,SACf,EACA,uBACF,EAAO,EAAU,EAAM,KAAO,IAAA,GAC9B,EAAW,GAAM,WAAW,MAAM,CACpC,OAAO,EAAK,MAAM,EAAE,CAAC,CAAG,KAAS,GACjC,EACE,EACA,EACN,QAAQ,OAAO,MACb,EACI,GAAG,KAAK,UAAU,CAAE,MAAO,EAAU,EAAM,QAAQ,CAAG,CAAE,KAAM,aAAiB,MAAQ,EAAM,KAAO,QAAS,UAAS,CAAE,WAAU,CAAC,CAAC,IACpI,GAAG,EAAO,IAAI,EAAK,IAAM,KAAK,EAAQ,IAC3C,CACD,QAAQ,KAAK,EAAS,CAIxB,eAAsB,UACpB,EACA,EACA,EAAO,GACQ,CACf,IAAI,EAAU,EACd,GAAI,CACF,MAAM,GAAQ,aAAa,OACpB,EAAS,CAChB,EAAU,CACR,MAAO,EAAU,EAAsB,EAAQ,MAAO,EAAQ,CAAG,EAClE,CAEC,IACE,EAAM,QAAQ,EAAQ,MAAO,GAAK,CACjC,QAAQ,EAAQ,MAAM,EAK/B,eAAsB,OACpB,EACA,EACA,EACe,CACf,IAAI,EACA,EACJ,GAAI,CACF,IAAM,EAAS,MAAM,WAAW,EAAK,CACrC,EAAS,EAAO,OAChB,MAAM,EAAK,EAAO,OACX,EAA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AgB,aACd,EAQG,CACH,OAAO"}
|
|
1
|
+
{"version":3,"file":"utils-DjXObbUK.mjs","names":[],"sources":["../src/cli/utils.ts"],"sourcesContent":["/**\n * CLI Utilities\n *\n * Configuration loading and other CLI utilities.\n *\n * Config file pattern similar to:\n * - drizzle.config.ts\n * - prisma (uses schema.prisma but we use TS)\n */\n\nimport { existsSync } from \"node:fs\";\nimport { resolve } from \"node:path\";\nimport { loadEnvFile } from \"node:process\";\nimport { createJiti } from \"jiti\";\nimport type { AnyDriver } from \"../drivers/driver\";\nimport { withSuppressedFailure } from \"../drivers/shared/suppressed-failure\";\nimport { isVibORMError } from \"../errors\";\nimport type { MigrationClient } from \"../migrations/push/planner\";\nimport type { MigrationStorageWriter } from \"../migrations/storage/contract\";\nimport type { ResolveCallback } from \"../migrations/types\";\nimport type { AnyModel } from \"../schema/model\";\nimport { validateSchemaOrThrow } from \"../schema/validation\";\n\n// =============================================================================\n// CONFIG TYPES\n// =============================================================================\n\n/**\n * Migration configuration options.\n */\nexport interface MigrationConfig {\n /** Estate directory (default: \"./migrations\") */\n dir?: string;\n /** Immutable exact physical table scope; include junctions and rename destinations. */\n tables?: readonly string[];\n /** Explicit rename, destructive-change and enum-value decisions for CLI planning. */\n resolve?: ResolveCallback;\n /**\n * Estate storage writer. Defaults to filesystem storage at `dir`.\n *\n * @example\n * ```ts\n * import { createFsStorageWriter } from \"viborm/migrations/storage/fs\";\n *\n * migrations: {\n * storage: createFsStorageWriter(\"./migrations\"),\n * }\n * ```\n */\n storage?: MigrationStorageWriter;\n}\n\n/**\n * VibORM configuration file format.\n *\n * Example viborm.config.ts:\n * ```ts\n * import { defineConfig } from \"viborm/config\";\n * import { client } from \"./src/db\";\n *\n * export default defineConfig({\n * client,\n * });\n * ```\n */\nexport interface VibORMConfig {\n /** VibORM client instance */\n client: MigrationClient & { $disconnect(): Promise<void> };\n /** Optional: Migration configuration */\n migrations?: MigrationConfig;\n}\n\nexport interface LoadConfigOptions {\n /** Path to config file (default: ./viborm.config.ts) */\n config?: string;\n /** Leave validation to the caller (`viborm check` reports every issue). */\n skipValidation?: boolean;\n}\n\nexport interface LoadedConfig {\n client: VibORMConfig[\"client\"];\n driver: AnyDriver;\n models: Record<string, AnyModel>;\n migrations?: MigrationConfig;\n}\n\n// =============================================================================\n// CONFIG FILE DISCOVERY\n// =============================================================================\n\nconst CONFIG_FILES = [\n \"viborm.config.ts\",\n \"viborm.config.mts\",\n \"viborm.config.js\",\n \"viborm.config.mjs\",\n];\n\n/**\n * Finds the first existing file from a list of candidates.\n */\nfunction findFile(cwd: string, candidates: string[]): string | null {\n for (const candidate of candidates) {\n const fullPath = resolve(cwd, candidate);\n if (existsSync(fullPath)) {\n return fullPath;\n }\n }\n return null;\n}\n\n// =============================================================================\n// CONFIG LOADING\n// =============================================================================\n\n/**\n * Loads VibORM configuration from viborm.config.ts file.\n *\n * The config file should export a default configuration object with:\n * - client: VibORM client instance created with createClient()\n */\nexport function failCli(error: unknown, json = false): never {\n const trusted = isVibORMError(error);\n const message =\n error instanceof Error\n ? error.message\n : typeof error === \"string\"\n ? error\n : \"CLI operation failed\";\n const code = trusted ? error.code : undefined;\n const exitCode = code?.startsWith(\"V11\")\n ? Number(code.slice(1)) - 11_000 + 10\n : trusted\n ? 2\n : 1;\n process.stderr.write(\n json\n ? `${JSON.stringify({ error: trusted ? error.toJSON() : { name: error instanceof Error ? error.name : \"Error\", message }, exitCode })}\\n`\n : `${code ? `[${code}] ` : \"\"}${message}\\n`\n );\n process.exit(exitCode);\n}\n\n/** Await owned CLI cleanup before reporting either the primary or cleanup failure. */\nexport async function finishCli(\n client: { $disconnect(): Promise<void> } | undefined,\n failure: { value: unknown } | undefined,\n json = false\n): Promise<void> {\n let outcome = failure;\n try {\n await client?.$disconnect();\n } catch (cleanup) {\n outcome = {\n value: failure ? withSuppressedFailure(failure.value, cleanup) : cleanup,\n };\n }\n if (outcome) {\n if (json) failCli(outcome.value, true);\n else failCli(outcome.value);\n }\n}\n\n/** Every command's frame: load the config, own its client, report through {@link finishCli}. */\nexport async function runCli(\n load: LoadConfigOptions,\n json: boolean | undefined,\n body: (config: LoadedConfig) => Promise<void>\n): Promise<void> {\n let client: { $disconnect(): Promise<void> } | undefined;\n let failure: { value: unknown } | undefined;\n try {\n const config = await loadConfig(load);\n client = config.client;\n await body(config);\n } catch (error) {\n failure = { value: error };\n } finally {\n await finishCli(client, failure, json);\n }\n}\n\n/** JSON for `--json`, else an indented outline of the same value. */\nexport function printJson(value: unknown, json: boolean): void {\n if (json) {\n process.stdout.write(`${JSON.stringify(value, null, 2)}\\n`);\n return;\n }\n const lines: string[] = [];\n const render = (item: unknown, indent = \"\") => {\n if (Array.isArray(item)) {\n for (const entry of item) {\n lines.push(`${indent}-`);\n render(entry, `${indent} `);\n }\n if (item.length === 0) lines.push(`${indent}(none)`);\n } else if (item !== null && typeof item === \"object\") {\n for (const [key, entry] of Object.entries(item)) {\n if (entry !== null && typeof entry === \"object\") {\n lines.push(`${indent}${key}:`);\n render(entry, `${indent} `);\n } else lines.push(`${indent}${key}: ${String(entry)}`);\n }\n } else lines.push(`${indent}${String(item)}`);\n };\n render(value);\n process.stdout.write(`${lines.join(\"\\n\")}\\n`);\n}\n\nexport async function loadConfig(\n options: LoadConfigOptions = {}\n): Promise<LoadedConfig> {\n const cwd = process.cwd();\n const envPath = resolve(cwd, \".env\");\n if (existsSync(envPath)) loadEnvFile(envPath);\n\n // Find config file\n const configPath = options.config\n ? resolve(cwd, options.config)\n : findFile(cwd, CONFIG_FILES);\n\n if (!(configPath && existsSync(configPath))) {\n const searchedPaths = options.config ? [options.config] : CONFIG_FILES;\n\n throw new Error(\n \"Could not find VibORM configuration file.\\n\\n\" +\n `Searched for:\\n${searchedPaths.map((f) => ` - ${f}`).join(\"\\n\")}\\n\\n` +\n \"Create a viborm.config.ts file:\\n\\n\" +\n ` import { defineConfig } from \"viborm/config\";\\n` +\n ` import { client } from \"./src/db\";\\n\\n` +\n \" export default defineConfig({\\n\" +\n \" client,\\n\" +\n \" });\\n\"\n );\n }\n\n // Load the config file\n const configModule = await loadCliModule<\n VibORMConfig & { default?: VibORMConfig; config?: VibORMConfig }\n >(configPath);\n\n // Extract config (handle both default export and named export)\n const config: VibORMConfig =\n (Object.hasOwn(configModule, \"default\") && configModule.default) ||\n configModule.config ||\n configModule;\n\n // Validate client\n if (!config.client) {\n throw new Error(\n `Missing \"client\" in ${configPath}.\\n\\n` +\n \"Your config should include a VibORM client:\\n\\n\" +\n ` import { createClient } from \"viborm\";\\n` +\n \" const client = createClient({ driver, schema });\\n\\n\" +\n \" export default defineConfig({\\n\" +\n \" client,\\n\" +\n \" });\\n\"\n );\n }\n\n if (!isValidClient(config.client)) {\n throw new Error(\n `Invalid \"client\" in ${configPath}.\\n\\n` +\n \"The client must be created with createClient().\\n\"\n );\n }\n\n // Extract driver and schema from client\n const driver = config.client.$driver;\n const schemaInput = config.client.$schema;\n\n // Extract models from schema (filter out non-model exports)\n const models = extractModels(schemaInput);\n\n if (Object.keys(models).length === 0) {\n throw new Error(\n `No models found in client schema from ${configPath}.\\n\\n` +\n \"Make sure your client was created with schema models:\\n\\n\" +\n \" // src/schema.ts\\n\" +\n ` import { s } from \"viborm\";\\n\\n` +\n \" export const user = s.model({\\n\" +\n \" id: s.string().id(),\\n\" +\n \" name: s.string(),\\n\" +\n \" });\\n\"\n );\n }\n\n // Validate schema before proceeding\n if (!options.skipValidation) validateSchemaOrThrow(models);\n\n return {\n client: config.client,\n driver,\n models,\n migrations: config.migrations,\n };\n}\n\n/**\n * Dynamically imports a TypeScript/JavaScript module.\n */\nexport function loadCliModule<T>(filePath: string): Promise<T> {\n // Dependency imports need CJS interop; consumers select only authored defaults.\n return createJiti(filePath, {\n tsconfigPaths: true,\n interopDefault: true,\n }).import<T>(filePath);\n}\n\n/**\n * Extracts model objects from a module by checking for Model instances.\n */\nfunction extractModels(\n schema: Record<string, unknown>\n): Record<string, AnyModel> {\n const models: Record<string, AnyModel> = {};\n\n for (const [key, value] of Object.entries(schema)) {\n if (isModel(value)) {\n models[key] = value;\n }\n }\n\n return models;\n}\n\n/**\n * Checks if a value is a VibORM Model instance.\n */\nfunction isModel(value: unknown): value is AnyModel {\n if (value === null || typeof value !== \"object\") return false;\n const metadata = Reflect.get(value, \"~\");\n if (metadata === null || typeof metadata !== \"object\") return false;\n const state = Reflect.get(metadata, \"state\");\n // Model state exposes `scalars`/`relations` (never `fields`); the rest of\n // the codebase discriminates models the same way (see serializer).\n return state !== null && typeof state === \"object\" && \"scalars\" in state;\n}\n\n/**\n * Checks if a value is a valid VibORM client instance.\n */\nfunction isValidClient(value: unknown): boolean {\n // The client is a Proxy whose only trap is `get`, so `\"$driver\" in value`\n // (which triggers the `has` trap / falls back to the bare target) is always\n // false. Probe via property access instead.\n // `typeof null === \"object\"`, so null has to be refused here: Reflect.get\n // throws on it rather than answering undefined.\n if (\n value === null ||\n (typeof value !== \"object\" && typeof value !== \"function\")\n ) {\n return false;\n }\n return (\n Reflect.get(value, \"$driver\") !== undefined &&\n Reflect.get(value, \"$schema\") !== undefined\n );\n}\n\n// =============================================================================\n// DEFINE CONFIG HELPER\n// =============================================================================\n\n/**\n * Helper function for defining VibORM configuration with type safety.\n *\n * @example\n * ```ts\n * // viborm.config.ts\n * import { defineConfig } from \"viborm/config\";\n * import { client } from \"./src/db\";\n *\n * export default defineConfig({\n * client,\n * });\n * ```\n */\nexport function defineConfig<const C extends VibORMConfig>(\n config: C &\n Record<Exclude<keyof C, keyof VibORMConfig>, never> &\n (C extends { migrations: infer M }\n ? {\n migrations: M &\n Record<Exclude<keyof M, keyof MigrationConfig>, never>;\n }\n : unknown)\n): C {\n return config;\n}\n"],"mappings":"0UA0FA,MAAM,EAAe,CACnB,mBACA,oBACA,mBACA,oBACD,CAKD,SAAS,SAAS,EAAa,EAAqC,CAClE,IAAK,IAAM,KAAa,EAAY,CAClC,IAAM,EAAW,EAAQ,EAAK,EAAU,CACxC,GAAI,EAAW,EAAS,CACtB,OAAO,EAGX,OAAO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