viborm 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +529 -0
- package/dist/adapters.d.mts +2 -0
- package/dist/adapters.mjs +1 -0
- package/dist/bun-sql.d.mts +3 -0
- package/dist/bun-sql.mjs +2 -0
- package/dist/bun-sql.mjs.map +1 -0
- package/dist/bun-sqlite.d.mts +3 -0
- package/dist/bun-sqlite.mjs +2 -0
- package/dist/bun-sqlite.mjs.map +1 -0
- package/dist/cache/cloudflare-kv.d.mts +3 -0
- package/dist/cache/cloudflare-kv.mjs +2 -0
- package/dist/cache/cloudflare-kv.mjs.map +1 -0
- package/dist/cache/memory.d.mts +3 -0
- package/dist/cache/memory.mjs +2 -0
- package/dist/cache/memory.mjs.map +1 -0
- package/dist/cache.d.mts +4 -0
- package/dist/cache.mjs +1 -0
- package/dist/cli.d.mts +1 -0
- package/dist/cli.mjs +41 -0
- package/dist/cli.mjs.map +1 -0
- package/dist/client-CgdtiDGV.mjs +2 -0
- package/dist/client-CgdtiDGV.mjs.map +1 -0
- package/dist/client.d.mts +3 -0
- package/dist/client.mjs +1 -0
- package/dist/cloudflare-kv-DauXhtnT.d.mts +1110 -0
- package/dist/d1-http.d.mts +3 -0
- package/dist/d1-http.mjs +2 -0
- package/dist/d1-http.mjs.map +1 -0
- package/dist/d1.d.mts +3 -0
- package/dist/d1.mjs +2 -0
- package/dist/d1.mjs.map +1 -0
- package/dist/driver-B_vBzQ6A.mjs +2 -0
- package/dist/driver-B_vBzQ6A.mjs.map +1 -0
- package/dist/driver-Cj1EbciY.mjs +2 -0
- package/dist/driver-Cj1EbciY.mjs.map +1 -0
- package/dist/driver.d.mts +2 -0
- package/dist/driver.mjs +1 -0
- package/dist/errors-DvcqIdEo.mjs +2 -0
- package/dist/errors-DvcqIdEo.mjs.map +1 -0
- package/dist/helper-cDCDjRAD.d.mts +3020 -0
- package/dist/helpers-WNr9B-2U.mjs +2 -0
- package/dist/helpers-WNr9B-2U.mjs.map +1 -0
- package/dist/hydration-CFnwc7j6.mjs +2 -0
- package/dist/hydration-CFnwc7j6.mjs.map +1 -0
- package/dist/index-3sdVKfeG.d.mts +1447 -0
- package/dist/index-BGmpst1h.d.mts +2158 -0
- package/dist/index.d.mts +46 -0
- package/dist/index.mjs +2 -0
- package/dist/index.mjs.map +1 -0
- package/dist/instrumentation.d.mts +2 -0
- package/dist/instrumentation.mjs +1 -0
- package/dist/libsql.d.mts +3 -0
- package/dist/libsql.mjs +2 -0
- package/dist/libsql.mjs.map +1 -0
- package/dist/migrations.d.mts +1588 -0
- package/dist/migrations.mjs +11 -0
- package/dist/migrations.mjs.map +1 -0
- package/dist/mysql-adapter-0catKeCI.mjs +6 -0
- package/dist/mysql-adapter-0catKeCI.mjs.map +1 -0
- package/dist/mysql-utils-BPw9qhac.mjs +2 -0
- package/dist/mysql-utils-BPw9qhac.mjs.map +1 -0
- package/dist/mysql2.d.mts +3 -0
- package/dist/mysql2.mjs +2 -0
- package/dist/mysql2.mjs.map +1 -0
- package/dist/native-types-BwICkVjz.mjs +2 -0
- package/dist/native-types-BwICkVjz.mjs.map +1 -0
- package/dist/neon-http.d.mts +3 -0
- package/dist/neon-http.mjs +2 -0
- package/dist/neon-http.mjs.map +1 -0
- package/dist/pending-operation-CkzYTpi4.mjs +2 -0
- package/dist/pending-operation-CkzYTpi4.mjs.map +1 -0
- package/dist/pg.d.mts +3 -0
- package/dist/pg.mjs +2 -0
- package/dist/pg.mjs.map +1 -0
- package/dist/pglite.d.mts +3 -0
- package/dist/pglite.mjs +2 -0
- package/dist/pglite.mjs.map +1 -0
- package/dist/planetscale.d.mts +3 -0
- package/dist/planetscale.mjs +2 -0
- package/dist/planetscale.mjs.map +1 -0
- package/dist/postgres-adapter-Blzqj1bl.mjs +6 -0
- package/dist/postgres-adapter-Blzqj1bl.mjs.map +1 -0
- package/dist/postgres.d.mts +3 -0
- package/dist/postgres.mjs +2 -0
- package/dist/postgres.mjs.map +1 -0
- package/dist/push-qZreXYkb.mjs +252 -0
- package/dist/push-qZreXYkb.mjs.map +1 -0
- package/dist/result-parsing-FNQbuHvC.mjs +2 -0
- package/dist/result-parsing-FNQbuHvC.mjs.map +1 -0
- package/dist/schema-DeAJZocc.mjs +2 -0
- package/dist/schema-DeAJZocc.mjs.map +1 -0
- package/dist/schema.d.mts +293 -0
- package/dist/schema.mjs +2 -0
- package/dist/schema.mjs.map +1 -0
- package/dist/spans-CJt5UgbJ.mjs +2 -0
- package/dist/spans-CJt5UgbJ.mjs.map +1 -0
- package/dist/sqlite-adapter-5Em_-oGU.mjs +6 -0
- package/dist/sqlite-adapter-5Em_-oGU.mjs.map +1 -0
- package/dist/sqlite-utils-BW7elKTz.mjs +2 -0
- package/dist/sqlite-utils-BW7elKTz.mjs.map +1 -0
- package/dist/sqlite3.d.mts +3 -0
- package/dist/sqlite3.mjs +2 -0
- package/dist/sqlite3.mjs.map +1 -0
- package/dist/tracer-CGzIAsj8.mjs +2 -0
- package/dist/tracer-CGzIAsj8.mjs.map +1 -0
- package/dist/validation-RtU-wu4N.mjs +2 -0
- package/dist/validation-RtU-wu4N.mjs.map +1 -0
- package/dist/validation.d.mts +2 -0
- package/dist/validation.mjs +1 -0
- package/dist/validator-DpJsJcd7.mjs +3 -0
- package/dist/validator-DpJsJcd7.mjs.map +1 -0
- package/package.json +278 -0
- package/readme/README.md +69 -0
|
@@ -0,0 +1,3020 @@
|
|
|
1
|
+
import { A as BasePointSchema, At as EnumSchema, D as StringSchema, F as OptionalSchema, Gt as BaseBigIntSchema, H as BaseNumberSchema, Ht as BlobSchema, Kt as BigIntSchema, Lt as BaseBooleanSchema, M as PointSchema, Rt as BooleanSchema, U as IntegerSchema, V as BaseIntegerSchema, Vt as BaseBlobSchema, W as NumberSchema, _t as BaseIsoTimestampSchema, b as BaseVectorSchema, bt as IsoTimestampSchema, cn as InferInput, dn as InferOutputShape, dt as JsonValue, gt as BaseIsoTimeSchema, ht as BaseIsoDateSchema, i as TransformSchema, j as Point, jt as EnumValues, kt as BaseEnumSchema, ln as InferInputShape, lt as BaseJsonSchema, on as ComputeInput, r as V, sn as ComputeOutput, ut as JsonSchema, vt as IsoDateSchema, w as UnionSchema, x as VectorSchema, yn as VibSchema, yt as IsoTimeSchema, z as ObjectSchema } from "./index-3sdVKfeG.mjs";
|
|
2
|
+
import { StandardSchemaOf, StandardSchemaV1 } from "@standard-schema/spec";
|
|
3
|
+
|
|
4
|
+
//#region src/schema/relation/types.d.ts
|
|
5
|
+
/** Workaround to allow circular dependencies */
|
|
6
|
+
type Getter = () => any;
|
|
7
|
+
/** Relation cardinality types */
|
|
8
|
+
type RelationType = "oneToOne" | "oneToMany" | "manyToOne" | "manyToMany";
|
|
9
|
+
/** Referential action for foreign key constraints */
|
|
10
|
+
type ReferentialAction = "cascade" | "setNull" | "restrict" | "noAction";
|
|
11
|
+
/**
|
|
12
|
+
* Unified relation state interface
|
|
13
|
+
* All properties are optional except type and getter
|
|
14
|
+
* Specific relation types will only use relevant properties
|
|
15
|
+
*/
|
|
16
|
+
interface RelationState {
|
|
17
|
+
type: RelationType;
|
|
18
|
+
getter: Getter;
|
|
19
|
+
name?: string;
|
|
20
|
+
fields?: string[];
|
|
21
|
+
references?: string[];
|
|
22
|
+
optional?: boolean;
|
|
23
|
+
onDelete?: ReferentialAction;
|
|
24
|
+
onUpdate?: ReferentialAction;
|
|
25
|
+
through?: string;
|
|
26
|
+
A?: string;
|
|
27
|
+
B?: string;
|
|
28
|
+
}
|
|
29
|
+
/** State for ToOne relations (oneToOne, manyToOne) */
|
|
30
|
+
interface ToOneRelationState extends RelationState {
|
|
31
|
+
type: "oneToOne" | "manyToOne";
|
|
32
|
+
}
|
|
33
|
+
/** State for ToMany relations (oneToMany) */
|
|
34
|
+
interface ToManyRelationState extends RelationState {
|
|
35
|
+
type: "oneToMany";
|
|
36
|
+
}
|
|
37
|
+
/** State for ManyToMany relations */
|
|
38
|
+
interface ManyToManyRelationState extends RelationState {
|
|
39
|
+
type: "manyToMany";
|
|
40
|
+
}
|
|
41
|
+
//#endregion
|
|
42
|
+
//#region src/schema/fields/common.d.ts
|
|
43
|
+
/**
|
|
44
|
+
* Name slots for fields, models, and relations.
|
|
45
|
+
* These are hydrated by the client at initialization time when the full
|
|
46
|
+
* schema context is available.
|
|
47
|
+
*
|
|
48
|
+
* - ts: TypeScript/schema key name (e.g., "email", "User")
|
|
49
|
+
* - sql: Resolved database name (e.g., "email_column", "users")
|
|
50
|
+
*/
|
|
51
|
+
interface SchemaNames {
|
|
52
|
+
/** TypeScript key name in the schema */
|
|
53
|
+
ts?: string;
|
|
54
|
+
/** Resolved SQL name (column/table) */
|
|
55
|
+
sql?: string;
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Hydrated schema names - guaranteed to have both ts and sql defined.
|
|
59
|
+
* Returned by model["~"].getFieldName() and model["~"].getRelationName().
|
|
60
|
+
*/
|
|
61
|
+
interface HydratedSchemaNames {
|
|
62
|
+
/** TypeScript key name in the schema */
|
|
63
|
+
ts: string;
|
|
64
|
+
/** Resolved SQL name (column/table) */
|
|
65
|
+
sql: string;
|
|
66
|
+
}
|
|
67
|
+
type ScalarFieldType = "string" | "int" | "float" | "decimal" | "boolean" | "datetime" | "date" | "time" | "bigint" | "json" | "blob" | "vector" | "point" | "enum";
|
|
68
|
+
type AutoGenerateType = "uuid" | "ulid" | "nanoid" | "cuid" | "increment" | "now" | "updatedAt";
|
|
69
|
+
/**
|
|
70
|
+
* Complete state for a field instance.
|
|
71
|
+
* This is the single generic that flows through the field class.
|
|
72
|
+
*/
|
|
73
|
+
interface FieldState<T extends ScalarFieldType = ScalarFieldType> {
|
|
74
|
+
type: T;
|
|
75
|
+
nullable: boolean;
|
|
76
|
+
array: boolean;
|
|
77
|
+
hasDefault: boolean;
|
|
78
|
+
isId: boolean;
|
|
79
|
+
isUnique: boolean;
|
|
80
|
+
default: DefaultValue<any> | undefined;
|
|
81
|
+
autoGenerate: AutoGenerateType | undefined;
|
|
82
|
+
schema: StandardSchemaV1<any, any> | undefined;
|
|
83
|
+
optional: boolean;
|
|
84
|
+
/** Custom column name in the database (set via .map()) */
|
|
85
|
+
columnName: string | undefined;
|
|
86
|
+
base: VibSchema;
|
|
87
|
+
withTimezone?: boolean | undefined;
|
|
88
|
+
/** Custom enum type name in the database (set via .name() on enum fields) */
|
|
89
|
+
enumName?: string | undefined;
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Computes the new state type after applying an update.
|
|
93
|
+
* Used by chainable methods to derive the return type.
|
|
94
|
+
*
|
|
95
|
+
* @example
|
|
96
|
+
* nullable(): StringField<UpdateState<State, { nullable: true }>>
|
|
97
|
+
*/
|
|
98
|
+
type UpdateState$1<State extends FieldState, Update extends Partial<FieldState>> = Omit<State, keyof Update> & Update;
|
|
99
|
+
/**
|
|
100
|
+
* Conditionally wraps a type with null
|
|
101
|
+
*/
|
|
102
|
+
type MaybeNullable<T, Nullable extends boolean = false> = Nullable extends true ? T | null : T;
|
|
103
|
+
/**
|
|
104
|
+
* Conditionally wraps a type as array
|
|
105
|
+
*/
|
|
106
|
+
type MaybeArray<T, IsArray extends boolean = false> = IsArray extends true ? T[] : T;
|
|
107
|
+
/**
|
|
108
|
+
* Type for default value - can be direct value or factory function
|
|
109
|
+
*/
|
|
110
|
+
type DefaultValue<T> = T | (() => T);
|
|
111
|
+
type DefaultValueInput<S extends FieldState> = DefaultValue<MaybeNullable<MaybeArray<InferInput<S["base"]>, S["array"]>, S["nullable"]>>;
|
|
112
|
+
//#endregion
|
|
113
|
+
//#region src/schema/fields/bigint/schemas.d.ts
|
|
114
|
+
type BigIntFilterBase<S extends V.Schema> = {
|
|
115
|
+
equals: S;
|
|
116
|
+
in: V.BigInt<{
|
|
117
|
+
array: true;
|
|
118
|
+
}>;
|
|
119
|
+
notIn: V.BigInt<{
|
|
120
|
+
array: true;
|
|
121
|
+
}>;
|
|
122
|
+
lt: V.BigInt;
|
|
123
|
+
lte: V.BigInt;
|
|
124
|
+
gt: V.BigInt;
|
|
125
|
+
gte: V.BigInt;
|
|
126
|
+
};
|
|
127
|
+
type BigIntFilterSchema<S extends V.Schema> = V.Union<readonly [V.ShorthandFilter<S>, V.Object<BigIntFilterBase<S> & {
|
|
128
|
+
not: V.Union<readonly [V.ShorthandFilter<S>, V.Object<BigIntFilterBase<S>>]>;
|
|
129
|
+
}>]>;
|
|
130
|
+
type BigIntListFilterBase<S extends V.Schema> = {
|
|
131
|
+
equals: S;
|
|
132
|
+
has: V.BigInt;
|
|
133
|
+
hasEvery: V.BigInt<{
|
|
134
|
+
array: true;
|
|
135
|
+
}>;
|
|
136
|
+
hasSome: V.BigInt<{
|
|
137
|
+
array: true;
|
|
138
|
+
}>;
|
|
139
|
+
isEmpty: V.Boolean;
|
|
140
|
+
};
|
|
141
|
+
type BigIntListFilterSchema<S extends V.Schema> = V.Union<readonly [V.ShorthandFilter<S>, V.Object<BigIntListFilterBase<S> & {
|
|
142
|
+
not: V.Union<readonly [V.ShorthandFilter<S>, V.Object<BigIntListFilterBase<S>>]>;
|
|
143
|
+
}>]>;
|
|
144
|
+
type BigIntUpdateSchema<S extends V.Schema> = V.Union<readonly [V.ShorthandUpdate<S>, V.Object<{
|
|
145
|
+
set: S;
|
|
146
|
+
increment: V.BigInt;
|
|
147
|
+
decrement: V.BigInt;
|
|
148
|
+
multiply: V.BigInt;
|
|
149
|
+
divide: V.BigInt;
|
|
150
|
+
}>]>;
|
|
151
|
+
type BigIntListUpdateSchema<S extends V.Schema> = V.Union<readonly [V.ShorthandUpdate<S>, V.Object<{
|
|
152
|
+
set: S;
|
|
153
|
+
push: V.Union<readonly [V.ShorthandArray<V.BigInt>, V.BigInt<{
|
|
154
|
+
array: true;
|
|
155
|
+
}>]>;
|
|
156
|
+
unshift: V.Union<readonly [V.ShorthandArray<V.BigInt>, V.BigInt<{
|
|
157
|
+
array: true;
|
|
158
|
+
}>]>;
|
|
159
|
+
}>]>;
|
|
160
|
+
interface BigIntSchemas<F$1 extends FieldState<"bigint">> {
|
|
161
|
+
base: F$1["base"];
|
|
162
|
+
create: BaseBigIntSchema<F$1>;
|
|
163
|
+
update: F$1["array"] extends true ? BigIntListUpdateSchema<F$1["base"]> : BigIntUpdateSchema<F$1["base"]>;
|
|
164
|
+
filter: F$1["array"] extends true ? BigIntListFilterSchema<F$1["base"]> : BigIntFilterSchema<F$1["base"]>;
|
|
165
|
+
}
|
|
166
|
+
//#endregion
|
|
167
|
+
//#region src/schema/fields/native-types.d.ts
|
|
168
|
+
interface NativeType {
|
|
169
|
+
readonly db: "pg" | "mysql" | "sqlite";
|
|
170
|
+
readonly type: string;
|
|
171
|
+
}
|
|
172
|
+
declare const PG: {
|
|
173
|
+
readonly STRING: {
|
|
174
|
+
readonly TEXT: {
|
|
175
|
+
readonly db: "pg";
|
|
176
|
+
readonly type: "text";
|
|
177
|
+
};
|
|
178
|
+
readonly VARCHAR: (n: number) => NativeType;
|
|
179
|
+
readonly CHAR: (n: number) => NativeType;
|
|
180
|
+
readonly CITEXT: {
|
|
181
|
+
readonly db: "pg";
|
|
182
|
+
readonly type: "citext";
|
|
183
|
+
};
|
|
184
|
+
readonly UUID: {
|
|
185
|
+
readonly db: "pg";
|
|
186
|
+
readonly type: "uuid";
|
|
187
|
+
};
|
|
188
|
+
readonly BIT: (n: number) => NativeType;
|
|
189
|
+
readonly VARBIT: (n?: number) => NativeType;
|
|
190
|
+
readonly XML: {
|
|
191
|
+
readonly db: "pg";
|
|
192
|
+
readonly type: "xml";
|
|
193
|
+
};
|
|
194
|
+
readonly INET: {
|
|
195
|
+
readonly db: "pg";
|
|
196
|
+
readonly type: "inet";
|
|
197
|
+
};
|
|
198
|
+
readonly CIDR: {
|
|
199
|
+
readonly db: "pg";
|
|
200
|
+
readonly type: "cidr";
|
|
201
|
+
};
|
|
202
|
+
readonly MACADDR: {
|
|
203
|
+
readonly db: "pg";
|
|
204
|
+
readonly type: "macaddr";
|
|
205
|
+
};
|
|
206
|
+
readonly MACADDR8: {
|
|
207
|
+
readonly db: "pg";
|
|
208
|
+
readonly type: "macaddr8";
|
|
209
|
+
};
|
|
210
|
+
readonly TSVECTOR: {
|
|
211
|
+
readonly db: "pg";
|
|
212
|
+
readonly type: "tsvector";
|
|
213
|
+
};
|
|
214
|
+
readonly TSQUERY: {
|
|
215
|
+
readonly db: "pg";
|
|
216
|
+
readonly type: "tsquery";
|
|
217
|
+
};
|
|
218
|
+
};
|
|
219
|
+
readonly INT: {
|
|
220
|
+
readonly SMALLINT: {
|
|
221
|
+
readonly db: "pg";
|
|
222
|
+
readonly type: "smallint";
|
|
223
|
+
};
|
|
224
|
+
readonly INTEGER: {
|
|
225
|
+
readonly db: "pg";
|
|
226
|
+
readonly type: "integer";
|
|
227
|
+
};
|
|
228
|
+
readonly OID: {
|
|
229
|
+
readonly db: "pg";
|
|
230
|
+
readonly type: "oid";
|
|
231
|
+
};
|
|
232
|
+
};
|
|
233
|
+
readonly BIGINT: {
|
|
234
|
+
readonly BIGINT: {
|
|
235
|
+
readonly db: "pg";
|
|
236
|
+
readonly type: "bigint";
|
|
237
|
+
};
|
|
238
|
+
};
|
|
239
|
+
readonly FLOAT: {
|
|
240
|
+
readonly REAL: {
|
|
241
|
+
readonly db: "pg";
|
|
242
|
+
readonly type: "real";
|
|
243
|
+
};
|
|
244
|
+
readonly DOUBLE_PRECISION: {
|
|
245
|
+
readonly db: "pg";
|
|
246
|
+
readonly type: "double precision";
|
|
247
|
+
};
|
|
248
|
+
};
|
|
249
|
+
readonly DECIMAL: {
|
|
250
|
+
readonly DECIMAL: (precision?: number, scale?: number) => NativeType;
|
|
251
|
+
readonly NUMERIC: (precision?: number, scale?: number) => NativeType;
|
|
252
|
+
readonly MONEY: {
|
|
253
|
+
readonly db: "pg";
|
|
254
|
+
readonly type: "money";
|
|
255
|
+
};
|
|
256
|
+
};
|
|
257
|
+
readonly BOOLEAN: {
|
|
258
|
+
readonly BOOLEAN: {
|
|
259
|
+
readonly db: "pg";
|
|
260
|
+
readonly type: "boolean";
|
|
261
|
+
};
|
|
262
|
+
};
|
|
263
|
+
readonly DATETIME: {
|
|
264
|
+
readonly TIMESTAMP: (precision?: number) => NativeType;
|
|
265
|
+
readonly TIMESTAMPTZ: (precision?: number) => NativeType;
|
|
266
|
+
readonly DATE: {
|
|
267
|
+
readonly db: "pg";
|
|
268
|
+
readonly type: "date";
|
|
269
|
+
};
|
|
270
|
+
readonly TIME: (precision?: number) => NativeType;
|
|
271
|
+
readonly TIMETZ: (precision?: number) => NativeType;
|
|
272
|
+
readonly INTERVAL: {
|
|
273
|
+
readonly db: "pg";
|
|
274
|
+
readonly type: "interval";
|
|
275
|
+
};
|
|
276
|
+
};
|
|
277
|
+
readonly JSON: {
|
|
278
|
+
readonly JSON: {
|
|
279
|
+
readonly db: "pg";
|
|
280
|
+
readonly type: "json";
|
|
281
|
+
};
|
|
282
|
+
readonly JSONB: {
|
|
283
|
+
readonly db: "pg";
|
|
284
|
+
readonly type: "jsonb";
|
|
285
|
+
};
|
|
286
|
+
};
|
|
287
|
+
readonly BLOB: {
|
|
288
|
+
readonly BYTEA: {
|
|
289
|
+
readonly db: "pg";
|
|
290
|
+
readonly type: "bytea";
|
|
291
|
+
};
|
|
292
|
+
};
|
|
293
|
+
readonly POINT: {
|
|
294
|
+
readonly POINT: {
|
|
295
|
+
readonly db: "pg";
|
|
296
|
+
readonly type: "point";
|
|
297
|
+
};
|
|
298
|
+
readonly GEOMETRY_POINT: {
|
|
299
|
+
readonly db: "pg";
|
|
300
|
+
readonly type: "geometry(Point)";
|
|
301
|
+
};
|
|
302
|
+
readonly GEOGRAPHY_POINT: {
|
|
303
|
+
readonly db: "pg";
|
|
304
|
+
readonly type: "geography(Point)";
|
|
305
|
+
};
|
|
306
|
+
};
|
|
307
|
+
};
|
|
308
|
+
declare const MYSQL: {
|
|
309
|
+
readonly STRING: {
|
|
310
|
+
readonly VARCHAR: (n: number) => NativeType;
|
|
311
|
+
readonly CHAR: (n: number) => NativeType;
|
|
312
|
+
readonly TEXT: {
|
|
313
|
+
readonly db: "mysql";
|
|
314
|
+
readonly type: "TEXT";
|
|
315
|
+
};
|
|
316
|
+
readonly TINYTEXT: {
|
|
317
|
+
readonly db: "mysql";
|
|
318
|
+
readonly type: "TINYTEXT";
|
|
319
|
+
};
|
|
320
|
+
readonly MEDIUMTEXT: {
|
|
321
|
+
readonly db: "mysql";
|
|
322
|
+
readonly type: "MEDIUMTEXT";
|
|
323
|
+
};
|
|
324
|
+
readonly LONGTEXT: {
|
|
325
|
+
readonly db: "mysql";
|
|
326
|
+
readonly type: "LONGTEXT";
|
|
327
|
+
};
|
|
328
|
+
readonly BIT: (n: number) => NativeType;
|
|
329
|
+
};
|
|
330
|
+
readonly INT: {
|
|
331
|
+
readonly TINYINT: {
|
|
332
|
+
readonly db: "mysql";
|
|
333
|
+
readonly type: "TINYINT";
|
|
334
|
+
};
|
|
335
|
+
readonly TINYINT_UNSIGNED: {
|
|
336
|
+
readonly db: "mysql";
|
|
337
|
+
readonly type: "TINYINT UNSIGNED";
|
|
338
|
+
};
|
|
339
|
+
readonly SMALLINT: {
|
|
340
|
+
readonly db: "mysql";
|
|
341
|
+
readonly type: "SMALLINT";
|
|
342
|
+
};
|
|
343
|
+
readonly SMALLINT_UNSIGNED: {
|
|
344
|
+
readonly db: "mysql";
|
|
345
|
+
readonly type: "SMALLINT UNSIGNED";
|
|
346
|
+
};
|
|
347
|
+
readonly MEDIUMINT: {
|
|
348
|
+
readonly db: "mysql";
|
|
349
|
+
readonly type: "MEDIUMINT";
|
|
350
|
+
};
|
|
351
|
+
readonly MEDIUMINT_UNSIGNED: {
|
|
352
|
+
readonly db: "mysql";
|
|
353
|
+
readonly type: "MEDIUMINT UNSIGNED";
|
|
354
|
+
};
|
|
355
|
+
readonly INT: {
|
|
356
|
+
readonly db: "mysql";
|
|
357
|
+
readonly type: "INT";
|
|
358
|
+
};
|
|
359
|
+
readonly INT_UNSIGNED: {
|
|
360
|
+
readonly db: "mysql";
|
|
361
|
+
readonly type: "INT UNSIGNED";
|
|
362
|
+
};
|
|
363
|
+
readonly YEAR: {
|
|
364
|
+
readonly db: "mysql";
|
|
365
|
+
readonly type: "YEAR";
|
|
366
|
+
};
|
|
367
|
+
};
|
|
368
|
+
readonly BIGINT: {
|
|
369
|
+
readonly BIGINT: {
|
|
370
|
+
readonly db: "mysql";
|
|
371
|
+
readonly type: "BIGINT";
|
|
372
|
+
};
|
|
373
|
+
readonly BIGINT_UNSIGNED: {
|
|
374
|
+
readonly db: "mysql";
|
|
375
|
+
readonly type: "BIGINT UNSIGNED";
|
|
376
|
+
};
|
|
377
|
+
};
|
|
378
|
+
readonly FLOAT: {
|
|
379
|
+
readonly FLOAT: {
|
|
380
|
+
readonly db: "mysql";
|
|
381
|
+
readonly type: "FLOAT";
|
|
382
|
+
};
|
|
383
|
+
readonly DOUBLE: {
|
|
384
|
+
readonly db: "mysql";
|
|
385
|
+
readonly type: "DOUBLE";
|
|
386
|
+
};
|
|
387
|
+
};
|
|
388
|
+
readonly DECIMAL: {
|
|
389
|
+
readonly DECIMAL: (precision?: number, scale?: number) => NativeType;
|
|
390
|
+
readonly NUMERIC: (precision?: number, scale?: number) => NativeType;
|
|
391
|
+
};
|
|
392
|
+
readonly BOOLEAN: {
|
|
393
|
+
readonly TINYINT: {
|
|
394
|
+
readonly db: "mysql";
|
|
395
|
+
readonly type: "TINYINT(1)";
|
|
396
|
+
};
|
|
397
|
+
};
|
|
398
|
+
readonly DATETIME: {
|
|
399
|
+
readonly DATETIME: (precision?: number) => NativeType;
|
|
400
|
+
readonly TIMESTAMP: (precision?: number) => NativeType;
|
|
401
|
+
readonly DATE: {
|
|
402
|
+
readonly db: "mysql";
|
|
403
|
+
readonly type: "DATE";
|
|
404
|
+
};
|
|
405
|
+
readonly TIME: (precision?: number) => NativeType;
|
|
406
|
+
};
|
|
407
|
+
readonly JSON: {
|
|
408
|
+
readonly JSON: {
|
|
409
|
+
readonly db: "mysql";
|
|
410
|
+
readonly type: "JSON";
|
|
411
|
+
};
|
|
412
|
+
};
|
|
413
|
+
readonly BLOB: {
|
|
414
|
+
readonly BLOB: {
|
|
415
|
+
readonly db: "mysql";
|
|
416
|
+
readonly type: "BLOB";
|
|
417
|
+
};
|
|
418
|
+
readonly TINYBLOB: {
|
|
419
|
+
readonly db: "mysql";
|
|
420
|
+
readonly type: "TINYBLOB";
|
|
421
|
+
};
|
|
422
|
+
readonly MEDIUMBLOB: {
|
|
423
|
+
readonly db: "mysql";
|
|
424
|
+
readonly type: "MEDIUMBLOB";
|
|
425
|
+
};
|
|
426
|
+
readonly LONGBLOB: {
|
|
427
|
+
readonly db: "mysql";
|
|
428
|
+
readonly type: "LONGBLOB";
|
|
429
|
+
};
|
|
430
|
+
readonly BINARY: (n: number) => NativeType;
|
|
431
|
+
readonly VARBINARY: (n: number) => NativeType;
|
|
432
|
+
};
|
|
433
|
+
};
|
|
434
|
+
declare const SQLITE: {
|
|
435
|
+
readonly STRING: {
|
|
436
|
+
readonly TEXT: {
|
|
437
|
+
readonly db: "sqlite";
|
|
438
|
+
readonly type: "TEXT";
|
|
439
|
+
};
|
|
440
|
+
};
|
|
441
|
+
readonly INT: {
|
|
442
|
+
readonly INTEGER: {
|
|
443
|
+
readonly db: "sqlite";
|
|
444
|
+
readonly type: "INTEGER";
|
|
445
|
+
};
|
|
446
|
+
};
|
|
447
|
+
readonly BIGINT: {
|
|
448
|
+
readonly INTEGER: {
|
|
449
|
+
readonly db: "sqlite";
|
|
450
|
+
readonly type: "INTEGER";
|
|
451
|
+
};
|
|
452
|
+
};
|
|
453
|
+
readonly FLOAT: {
|
|
454
|
+
readonly REAL: {
|
|
455
|
+
readonly db: "sqlite";
|
|
456
|
+
readonly type: "REAL";
|
|
457
|
+
};
|
|
458
|
+
};
|
|
459
|
+
readonly DECIMAL: {
|
|
460
|
+
readonly REAL: {
|
|
461
|
+
readonly db: "sqlite";
|
|
462
|
+
readonly type: "REAL";
|
|
463
|
+
};
|
|
464
|
+
readonly NUMERIC: {
|
|
465
|
+
readonly db: "sqlite";
|
|
466
|
+
readonly type: "NUMERIC";
|
|
467
|
+
};
|
|
468
|
+
};
|
|
469
|
+
readonly BOOLEAN: {
|
|
470
|
+
readonly INTEGER: {
|
|
471
|
+
readonly db: "sqlite";
|
|
472
|
+
readonly type: "INTEGER";
|
|
473
|
+
};
|
|
474
|
+
};
|
|
475
|
+
readonly DATETIME: {
|
|
476
|
+
readonly TEXT: {
|
|
477
|
+
readonly db: "sqlite";
|
|
478
|
+
readonly type: "TEXT";
|
|
479
|
+
};
|
|
480
|
+
readonly REAL: {
|
|
481
|
+
readonly db: "sqlite";
|
|
482
|
+
readonly type: "REAL";
|
|
483
|
+
};
|
|
484
|
+
readonly INTEGER: {
|
|
485
|
+
readonly db: "sqlite";
|
|
486
|
+
readonly type: "INTEGER";
|
|
487
|
+
};
|
|
488
|
+
};
|
|
489
|
+
readonly JSON: {
|
|
490
|
+
readonly TEXT: {
|
|
491
|
+
readonly db: "sqlite";
|
|
492
|
+
readonly type: "TEXT";
|
|
493
|
+
};
|
|
494
|
+
};
|
|
495
|
+
readonly BLOB: {
|
|
496
|
+
readonly BLOB: {
|
|
497
|
+
readonly db: "sqlite";
|
|
498
|
+
readonly type: "BLOB";
|
|
499
|
+
};
|
|
500
|
+
};
|
|
501
|
+
};
|
|
502
|
+
//#endregion
|
|
503
|
+
//#region src/schema/fields/blob/schemas.d.ts
|
|
504
|
+
type BlobFilterBase<S extends V.Schema> = {
|
|
505
|
+
equals: S;
|
|
506
|
+
};
|
|
507
|
+
type BlobFilterSchema<S extends V.Schema> = V.Union<readonly [V.ShorthandFilter<S>, V.Object<BlobFilterBase<S> & {
|
|
508
|
+
not: V.Union<readonly [V.ShorthandFilter<S>, V.Object<BlobFilterBase<S>>]>;
|
|
509
|
+
}>]>;
|
|
510
|
+
type BlobUpdateSchema<S extends V.Schema> = V.Union<readonly [V.ShorthandUpdate<S>, V.Object<{
|
|
511
|
+
set: S;
|
|
512
|
+
}, {
|
|
513
|
+
partial: false;
|
|
514
|
+
}>]>;
|
|
515
|
+
interface BlobSchemas<F$1 extends FieldState<"blob">> {
|
|
516
|
+
base: F$1["base"];
|
|
517
|
+
create: BaseBlobSchema<F$1>;
|
|
518
|
+
update: BlobUpdateSchema<F$1["base"]>;
|
|
519
|
+
filter: BlobFilterSchema<F$1["base"]>;
|
|
520
|
+
}
|
|
521
|
+
//#endregion
|
|
522
|
+
//#region src/schema/fields/blob/field.d.ts
|
|
523
|
+
declare class BlobField<State extends FieldState<"blob">> {
|
|
524
|
+
private _schemas;
|
|
525
|
+
private readonly state;
|
|
526
|
+
private readonly _nativeType?;
|
|
527
|
+
constructor(state: State, _nativeType?: NativeType);
|
|
528
|
+
nullable(): BlobField<UpdateState$1<this["~"]["state"], {
|
|
529
|
+
readonly nullable: true;
|
|
530
|
+
readonly hasDefault: true;
|
|
531
|
+
readonly default: null;
|
|
532
|
+
readonly optional: true;
|
|
533
|
+
readonly base: BlobSchema<Uint8Array<ArrayBufferLike> | null, Uint8Array<ArrayBufferLike> | null>;
|
|
534
|
+
}>>;
|
|
535
|
+
default<V$1 extends DefaultValueInput<State>>(value: V$1): BlobField<UpdateState$1<this["~"]["state"], {
|
|
536
|
+
readonly hasDefault: true;
|
|
537
|
+
readonly default: V$1;
|
|
538
|
+
readonly optional: true;
|
|
539
|
+
}>>;
|
|
540
|
+
/**
|
|
541
|
+
* Maps this field to a custom column name in the database
|
|
542
|
+
*/
|
|
543
|
+
map(columnName: string): BlobField<UpdateState$1<this["~"]["state"], {
|
|
544
|
+
readonly columnName: string;
|
|
545
|
+
}>>;
|
|
546
|
+
array(): never;
|
|
547
|
+
id(): never;
|
|
548
|
+
unique(): never;
|
|
549
|
+
get ["~"](): {
|
|
550
|
+
state: State;
|
|
551
|
+
schemas: BlobSchemas<State>;
|
|
552
|
+
nativeType: NativeType | undefined;
|
|
553
|
+
};
|
|
554
|
+
}
|
|
555
|
+
//#endregion
|
|
556
|
+
//#region src/schema/fields/boolean/schemas.d.ts
|
|
557
|
+
type BooleanFilterBase<S extends V.Schema> = {
|
|
558
|
+
equals: S;
|
|
559
|
+
};
|
|
560
|
+
type BooleanFilterSchema<S extends V.Schema> = V.Union<readonly [V.ShorthandFilter<S>, V.Object<BooleanFilterBase<S> & {
|
|
561
|
+
not: V.Union<readonly [V.ShorthandFilter<S>, V.Object<BooleanFilterBase<S>>]>;
|
|
562
|
+
}>]>;
|
|
563
|
+
type BooleanListFilterBase<S extends V.Schema> = {
|
|
564
|
+
equals: S;
|
|
565
|
+
has: V.Boolean;
|
|
566
|
+
hasEvery: V.Boolean<{
|
|
567
|
+
array: true;
|
|
568
|
+
}>;
|
|
569
|
+
hasSome: V.Boolean<{
|
|
570
|
+
array: true;
|
|
571
|
+
}>;
|
|
572
|
+
isEmpty: V.Boolean;
|
|
573
|
+
};
|
|
574
|
+
type BooleanListFilterSchema<S extends V.Schema> = V.Union<readonly [V.ShorthandFilter<S>, V.Object<BooleanListFilterBase<S> & {
|
|
575
|
+
not: V.Union<readonly [V.ShorthandFilter<S>, V.Object<BooleanListFilterBase<S>>]>;
|
|
576
|
+
}>]>;
|
|
577
|
+
type BooleanUpdateSchema<S extends V.Schema> = V.Union<readonly [V.ShorthandUpdate<S>, V.Object<{
|
|
578
|
+
set: S;
|
|
579
|
+
}, {
|
|
580
|
+
partial: false;
|
|
581
|
+
}>]>;
|
|
582
|
+
type BooleanListUpdateSchema<S extends V.Schema> = V.Union<readonly [V.ShorthandUpdate<S>, V.Object<{
|
|
583
|
+
set: S;
|
|
584
|
+
push: V.Union<readonly [V.ShorthandArray<V.Boolean>, V.Boolean<{
|
|
585
|
+
array: true;
|
|
586
|
+
}>]>;
|
|
587
|
+
unshift: V.Union<readonly [V.ShorthandArray<V.Boolean>, V.Boolean<{
|
|
588
|
+
array: true;
|
|
589
|
+
}>]>;
|
|
590
|
+
}>]>;
|
|
591
|
+
interface BooleanSchemas<F$1 extends FieldState<"boolean">> {
|
|
592
|
+
base: F$1["base"];
|
|
593
|
+
create: BaseBooleanSchema<F$1>;
|
|
594
|
+
update: F$1["array"] extends true ? BooleanListUpdateSchema<F$1["base"]> : BooleanUpdateSchema<F$1["base"]>;
|
|
595
|
+
filter: F$1["array"] extends true ? BooleanListFilterSchema<F$1["base"]> : BooleanFilterSchema<F$1["base"]>;
|
|
596
|
+
}
|
|
597
|
+
//#endregion
|
|
598
|
+
//#region src/schema/fields/boolean/field.d.ts
|
|
599
|
+
declare class BooleanField<State extends FieldState<"boolean">> {
|
|
600
|
+
private _schemas;
|
|
601
|
+
private readonly state;
|
|
602
|
+
private readonly _nativeType?;
|
|
603
|
+
constructor(state: State, _nativeType?: NativeType);
|
|
604
|
+
nullable(): BooleanField<UpdateState$1<this["~"]["state"], {
|
|
605
|
+
readonly nullable: true;
|
|
606
|
+
readonly hasDefault: true;
|
|
607
|
+
readonly default: null;
|
|
608
|
+
readonly optional: true;
|
|
609
|
+
readonly base: BooleanSchema<ComputeInput<boolean, {
|
|
610
|
+
nullable: true;
|
|
611
|
+
array: State["array"];
|
|
612
|
+
}>, ComputeOutput<boolean, {
|
|
613
|
+
nullable: true;
|
|
614
|
+
array: State["array"];
|
|
615
|
+
}>>;
|
|
616
|
+
}>>;
|
|
617
|
+
array(): BooleanField<UpdateState$1<this["~"]["state"], {
|
|
618
|
+
readonly array: true;
|
|
619
|
+
readonly base: BooleanSchema<ComputeInput<boolean, {
|
|
620
|
+
nullable: State["nullable"];
|
|
621
|
+
array: true;
|
|
622
|
+
}>, ComputeOutput<boolean, {
|
|
623
|
+
nullable: State["nullable"];
|
|
624
|
+
array: true;
|
|
625
|
+
}>>;
|
|
626
|
+
}>>;
|
|
627
|
+
default<V$1 extends DefaultValueInput<State>>(value: V$1): BooleanField<UpdateState$1<this["~"]["state"], {
|
|
628
|
+
readonly hasDefault: true;
|
|
629
|
+
readonly default: V$1;
|
|
630
|
+
readonly optional: true;
|
|
631
|
+
}>>;
|
|
632
|
+
/**
|
|
633
|
+
* Maps this field to a custom column name in the database
|
|
634
|
+
*/
|
|
635
|
+
map(columnName: string): BooleanField<UpdateState$1<this["~"]["state"], {
|
|
636
|
+
readonly columnName: string;
|
|
637
|
+
}>>;
|
|
638
|
+
get ["~"](): {
|
|
639
|
+
state: State;
|
|
640
|
+
schemas: BooleanSchemas<State>;
|
|
641
|
+
nativeType: NativeType | undefined;
|
|
642
|
+
};
|
|
643
|
+
}
|
|
644
|
+
//#endregion
|
|
645
|
+
//#region src/schema/fields/datetime/schemas.d.ts
|
|
646
|
+
type DateTimeFilterBase<S extends V.Schema> = {
|
|
647
|
+
equals: S;
|
|
648
|
+
in: V.IsoTimestamp<{
|
|
649
|
+
array: true;
|
|
650
|
+
}>;
|
|
651
|
+
notIn: V.IsoTimestamp<{
|
|
652
|
+
array: true;
|
|
653
|
+
}>;
|
|
654
|
+
lt: V.IsoTimestamp;
|
|
655
|
+
lte: V.IsoTimestamp;
|
|
656
|
+
gt: V.IsoTimestamp;
|
|
657
|
+
gte: V.IsoTimestamp;
|
|
658
|
+
};
|
|
659
|
+
type DateTimeFilterSchema<S extends V.Schema> = V.Union<readonly [V.ShorthandFilter<S>, V.Object<DateTimeFilterBase<S> & {
|
|
660
|
+
not: V.Union<readonly [V.ShorthandFilter<S>, V.Object<DateTimeFilterBase<S>>]>;
|
|
661
|
+
}>]>;
|
|
662
|
+
type DateTimeListFilterBase<S extends V.Schema> = {
|
|
663
|
+
equals: S;
|
|
664
|
+
has: V.IsoTimestamp;
|
|
665
|
+
hasEvery: V.IsoTimestamp<{
|
|
666
|
+
array: true;
|
|
667
|
+
}>;
|
|
668
|
+
hasSome: V.IsoTimestamp<{
|
|
669
|
+
array: true;
|
|
670
|
+
}>;
|
|
671
|
+
isEmpty: V.Boolean;
|
|
672
|
+
};
|
|
673
|
+
type DateTimeListFilterSchema<S extends V.Schema> = V.Union<readonly [V.ShorthandFilter<S>, V.Object<DateTimeListFilterBase<S> & {
|
|
674
|
+
not: V.Union<readonly [V.ShorthandFilter<S>, V.Object<DateTimeListFilterBase<S>>]>;
|
|
675
|
+
}>]>;
|
|
676
|
+
type DateTimeUpdateSchema<S extends V.Schema> = V.Union<readonly [V.ShorthandUpdate<S>, V.Object<{
|
|
677
|
+
set: S;
|
|
678
|
+
}, {
|
|
679
|
+
partial: false;
|
|
680
|
+
}>]>;
|
|
681
|
+
type DateTimeListUpdateSchema<S extends V.Schema> = V.Union<readonly [V.ShorthandUpdate<S>, V.Object<{
|
|
682
|
+
set: S;
|
|
683
|
+
push: V.Union<readonly [V.ShorthandArray<V.IsoTimestamp>, V.IsoTimestamp<{
|
|
684
|
+
array: true;
|
|
685
|
+
}>]>;
|
|
686
|
+
unshift: V.Union<readonly [V.ShorthandArray<V.IsoTimestamp>, V.IsoTimestamp<{
|
|
687
|
+
array: true;
|
|
688
|
+
}>]>;
|
|
689
|
+
}>]>;
|
|
690
|
+
type DateFilterBase<S extends V.Schema> = {
|
|
691
|
+
equals: S;
|
|
692
|
+
in: V.IsoDate<{
|
|
693
|
+
array: true;
|
|
694
|
+
}>;
|
|
695
|
+
notIn: V.IsoDate<{
|
|
696
|
+
array: true;
|
|
697
|
+
}>;
|
|
698
|
+
lt: V.IsoDate;
|
|
699
|
+
lte: V.IsoDate;
|
|
700
|
+
gt: V.IsoDate;
|
|
701
|
+
gte: V.IsoDate;
|
|
702
|
+
};
|
|
703
|
+
type DateFilterSchema<S extends V.Schema> = V.Union<readonly [V.ShorthandFilter<S>, V.Object<DateFilterBase<S> & {
|
|
704
|
+
not: V.Union<readonly [V.ShorthandFilter<S>, V.Object<DateFilterBase<S>>]>;
|
|
705
|
+
}>]>;
|
|
706
|
+
type DateListFilterBase<S extends V.Schema> = {
|
|
707
|
+
equals: S;
|
|
708
|
+
has: V.IsoDate;
|
|
709
|
+
hasEvery: V.IsoDate<{
|
|
710
|
+
array: true;
|
|
711
|
+
}>;
|
|
712
|
+
hasSome: V.IsoDate<{
|
|
713
|
+
array: true;
|
|
714
|
+
}>;
|
|
715
|
+
isEmpty: V.Boolean;
|
|
716
|
+
};
|
|
717
|
+
type DateListFilterSchema<S extends V.Schema> = V.Union<readonly [V.ShorthandFilter<S>, V.Object<DateListFilterBase<S> & {
|
|
718
|
+
not: V.Union<readonly [V.ShorthandFilter<S>, V.Object<DateListFilterBase<S>>]>;
|
|
719
|
+
}>]>;
|
|
720
|
+
type DateUpdateSchema<S extends V.Schema> = V.Union<readonly [V.ShorthandUpdate<S>, V.Object<{
|
|
721
|
+
set: S;
|
|
722
|
+
}, {
|
|
723
|
+
partial: false;
|
|
724
|
+
}>]>;
|
|
725
|
+
type DateListUpdateSchema<S extends V.Schema> = V.Union<readonly [V.ShorthandUpdate<S>, V.Object<{
|
|
726
|
+
set: S;
|
|
727
|
+
push: V.Union<readonly [V.ShorthandArray<V.IsoDate>, V.IsoDate<{
|
|
728
|
+
array: true;
|
|
729
|
+
}>]>;
|
|
730
|
+
unshift: V.Union<readonly [V.ShorthandArray<V.IsoDate>, V.IsoDate<{
|
|
731
|
+
array: true;
|
|
732
|
+
}>]>;
|
|
733
|
+
}>]>;
|
|
734
|
+
type TimeFilterBase<S extends V.Schema> = {
|
|
735
|
+
equals: S;
|
|
736
|
+
in: V.IsoTime<{
|
|
737
|
+
array: true;
|
|
738
|
+
}>;
|
|
739
|
+
notIn: V.IsoTime<{
|
|
740
|
+
array: true;
|
|
741
|
+
}>;
|
|
742
|
+
lt: V.IsoTime;
|
|
743
|
+
lte: V.IsoTime;
|
|
744
|
+
gt: V.IsoTime;
|
|
745
|
+
gte: V.IsoTime;
|
|
746
|
+
};
|
|
747
|
+
type TimeFilterSchema<S extends V.Schema> = V.Union<readonly [V.ShorthandFilter<S>, V.Object<TimeFilterBase<S> & {
|
|
748
|
+
not: V.Union<readonly [V.ShorthandFilter<S>, V.Object<TimeFilterBase<S>>]>;
|
|
749
|
+
}>]>;
|
|
750
|
+
type TimeListFilterBase<S extends V.Schema> = {
|
|
751
|
+
equals: S;
|
|
752
|
+
has: V.IsoTime;
|
|
753
|
+
hasEvery: V.IsoTime<{
|
|
754
|
+
array: true;
|
|
755
|
+
}>;
|
|
756
|
+
hasSome: V.IsoTime<{
|
|
757
|
+
array: true;
|
|
758
|
+
}>;
|
|
759
|
+
isEmpty: V.Boolean;
|
|
760
|
+
};
|
|
761
|
+
type TimeListFilterSchema<S extends V.Schema> = V.Union<readonly [V.ShorthandFilter<S>, V.Object<TimeListFilterBase<S> & {
|
|
762
|
+
not: V.Union<readonly [V.ShorthandFilter<S>, V.Object<TimeListFilterBase<S>>]>;
|
|
763
|
+
}>]>;
|
|
764
|
+
type TimeUpdateSchema<S extends V.Schema> = V.Union<readonly [V.ShorthandUpdate<S>, V.Object<{
|
|
765
|
+
set: S;
|
|
766
|
+
}, {
|
|
767
|
+
partial: false;
|
|
768
|
+
}>]>;
|
|
769
|
+
type TimeListUpdateSchema<S extends V.Schema> = V.Union<readonly [V.ShorthandUpdate<S>, V.Object<{
|
|
770
|
+
set: S;
|
|
771
|
+
push: V.Union<readonly [V.ShorthandArray<V.IsoTime>, V.IsoTime<{
|
|
772
|
+
array: true;
|
|
773
|
+
}>]>;
|
|
774
|
+
unshift: V.Union<readonly [V.ShorthandArray<V.IsoTime>, V.IsoTime<{
|
|
775
|
+
array: true;
|
|
776
|
+
}>]>;
|
|
777
|
+
}>]>;
|
|
778
|
+
interface DateTimeSchemas<F$1 extends FieldState<"datetime">> {
|
|
779
|
+
base: F$1["base"];
|
|
780
|
+
create: BaseIsoTimestampSchema<F$1>;
|
|
781
|
+
update: F$1["array"] extends true ? DateTimeListUpdateSchema<F$1["base"]> : DateTimeUpdateSchema<F$1["base"]>;
|
|
782
|
+
filter: F$1["array"] extends true ? DateTimeListFilterSchema<F$1["base"]> : DateTimeFilterSchema<F$1["base"]>;
|
|
783
|
+
}
|
|
784
|
+
interface DateSchemas<F$1 extends FieldState<"date">> {
|
|
785
|
+
base: F$1["base"];
|
|
786
|
+
create: BaseIsoDateSchema<F$1>;
|
|
787
|
+
update: F$1["array"] extends true ? DateListUpdateSchema<F$1["base"]> : DateUpdateSchema<F$1["base"]>;
|
|
788
|
+
filter: F$1["array"] extends true ? DateListFilterSchema<F$1["base"]> : DateFilterSchema<F$1["base"]>;
|
|
789
|
+
}
|
|
790
|
+
interface TimeSchemas<F$1 extends FieldState<"time">> {
|
|
791
|
+
base: F$1["base"];
|
|
792
|
+
create: BaseIsoTimeSchema<F$1>;
|
|
793
|
+
update: F$1["array"] extends true ? TimeListUpdateSchema<F$1["base"]> : TimeUpdateSchema<F$1["base"]>;
|
|
794
|
+
filter: F$1["array"] extends true ? TimeListFilterSchema<F$1["base"]> : TimeFilterSchema<F$1["base"]>;
|
|
795
|
+
}
|
|
796
|
+
//#endregion
|
|
797
|
+
//#region src/schema/fields/datetime/date-field.d.ts
|
|
798
|
+
declare class DateField<State extends FieldState<"date">> {
|
|
799
|
+
private _schemas;
|
|
800
|
+
private readonly state;
|
|
801
|
+
private readonly _nativeType?;
|
|
802
|
+
constructor(state: State, _nativeType?: NativeType);
|
|
803
|
+
nullable(): DateField<UpdateState$1<this["~"]["state"], {
|
|
804
|
+
readonly nullable: true;
|
|
805
|
+
readonly hasDefault: true;
|
|
806
|
+
readonly default: null;
|
|
807
|
+
readonly optional: true;
|
|
808
|
+
readonly base: IsoDateSchema<ComputeInput<string | Date, {
|
|
809
|
+
nullable: true;
|
|
810
|
+
array: State["array"];
|
|
811
|
+
}>, ComputeOutput<string, {
|
|
812
|
+
nullable: true;
|
|
813
|
+
array: State["array"];
|
|
814
|
+
}>>;
|
|
815
|
+
}>>;
|
|
816
|
+
array(): DateField<UpdateState$1<this["~"]["state"], {
|
|
817
|
+
readonly array: true;
|
|
818
|
+
readonly base: IsoDateSchema<ComputeInput<string | Date, {
|
|
819
|
+
nullable: State["nullable"];
|
|
820
|
+
array: true;
|
|
821
|
+
}>, ComputeOutput<string, {
|
|
822
|
+
nullable: State["nullable"];
|
|
823
|
+
array: true;
|
|
824
|
+
}>>;
|
|
825
|
+
}>>;
|
|
826
|
+
id(): DateField<UpdateState$1<this["~"]["state"], {
|
|
827
|
+
readonly isId: true;
|
|
828
|
+
readonly isUnique: true;
|
|
829
|
+
}>>;
|
|
830
|
+
unique(): DateField<UpdateState$1<this["~"]["state"], {
|
|
831
|
+
readonly isUnique: true;
|
|
832
|
+
}>>;
|
|
833
|
+
schema<S extends StandardSchemaOf<string>>(schema: S): DateField<UpdateState$1<this["~"]["state"], {
|
|
834
|
+
readonly schema: S;
|
|
835
|
+
readonly base: IsoDateSchema<ComputeInput<string | Date, {
|
|
836
|
+
nullable: State["nullable"];
|
|
837
|
+
array: State["array"];
|
|
838
|
+
schema: S;
|
|
839
|
+
}>, ComputeOutput<string, {
|
|
840
|
+
nullable: State["nullable"];
|
|
841
|
+
array: State["array"];
|
|
842
|
+
schema: S;
|
|
843
|
+
}>>;
|
|
844
|
+
}>>;
|
|
845
|
+
default<V$1 extends DefaultValueInput<State>>(value: V$1): DateField<UpdateState$1<this["~"]["state"], {
|
|
846
|
+
readonly hasDefault: true;
|
|
847
|
+
readonly default: V$1;
|
|
848
|
+
readonly optional: true;
|
|
849
|
+
}>>;
|
|
850
|
+
/**
|
|
851
|
+
* Maps this field to a custom column name in the database
|
|
852
|
+
*/
|
|
853
|
+
map(columnName: string): DateField<UpdateState$1<this["~"]["state"], {
|
|
854
|
+
readonly columnName: string;
|
|
855
|
+
}>>;
|
|
856
|
+
now(): DateField<UpdateState$1<this["~"]["state"], {
|
|
857
|
+
readonly hasDefault: true;
|
|
858
|
+
readonly autoGenerate: "now";
|
|
859
|
+
readonly default: () => string;
|
|
860
|
+
readonly optional: true;
|
|
861
|
+
}>>;
|
|
862
|
+
updatedAt(): DateField<UpdateState$1<this["~"]["state"], {
|
|
863
|
+
readonly hasDefault: true;
|
|
864
|
+
readonly autoGenerate: "updatedAt";
|
|
865
|
+
readonly default: () => string;
|
|
866
|
+
readonly optional: true;
|
|
867
|
+
}>>;
|
|
868
|
+
get ["~"](): {
|
|
869
|
+
state: State;
|
|
870
|
+
schemas: DateSchemas<State>;
|
|
871
|
+
nativeType: NativeType | undefined;
|
|
872
|
+
};
|
|
873
|
+
}
|
|
874
|
+
//#endregion
|
|
875
|
+
//#region src/schema/fields/datetime/field.d.ts
|
|
876
|
+
declare class DateTimeField<State extends FieldState<"datetime">> {
|
|
877
|
+
private _schemas;
|
|
878
|
+
private readonly state;
|
|
879
|
+
private readonly _nativeType?;
|
|
880
|
+
constructor(state: State, _nativeType?: NativeType);
|
|
881
|
+
nullable(): DateTimeField<UpdateState$1<this["~"]["state"], {
|
|
882
|
+
readonly nullable: true;
|
|
883
|
+
readonly hasDefault: true;
|
|
884
|
+
readonly default: null;
|
|
885
|
+
readonly optional: true;
|
|
886
|
+
readonly base: IsoTimestampSchema<ComputeInput<string | Date, {
|
|
887
|
+
nullable: true;
|
|
888
|
+
array: State["array"];
|
|
889
|
+
}>, ComputeOutput<string, {
|
|
890
|
+
nullable: true;
|
|
891
|
+
array: State["array"];
|
|
892
|
+
}>>;
|
|
893
|
+
}>>;
|
|
894
|
+
array(): DateTimeField<UpdateState$1<this["~"]["state"], {
|
|
895
|
+
readonly array: true;
|
|
896
|
+
readonly base: IsoTimestampSchema<ComputeInput<string | Date, {
|
|
897
|
+
nullable: State["nullable"];
|
|
898
|
+
array: true;
|
|
899
|
+
}>, ComputeOutput<string, {
|
|
900
|
+
nullable: State["nullable"];
|
|
901
|
+
array: true;
|
|
902
|
+
}>>;
|
|
903
|
+
}>>;
|
|
904
|
+
id(): DateTimeField<UpdateState$1<this["~"]["state"], {
|
|
905
|
+
readonly isId: true;
|
|
906
|
+
readonly isUnique: true;
|
|
907
|
+
}>>;
|
|
908
|
+
unique(): DateTimeField<UpdateState$1<this["~"]["state"], {
|
|
909
|
+
readonly isUnique: true;
|
|
910
|
+
}>>;
|
|
911
|
+
schema<S extends StandardSchemaOf<string>>(schema: S): DateTimeField<UpdateState$1<this["~"]["state"], {
|
|
912
|
+
readonly schema: S;
|
|
913
|
+
readonly base: IsoTimestampSchema<ComputeInput<string | Date, {
|
|
914
|
+
nullable: State["nullable"];
|
|
915
|
+
array: State["array"];
|
|
916
|
+
schema: S;
|
|
917
|
+
}>, ComputeOutput<string, {
|
|
918
|
+
nullable: State["nullable"];
|
|
919
|
+
array: State["array"];
|
|
920
|
+
schema: S;
|
|
921
|
+
}>>;
|
|
922
|
+
}>>;
|
|
923
|
+
default<V$1 extends DefaultValueInput<State>>(value: V$1): DateTimeField<UpdateState$1<this["~"]["state"], {
|
|
924
|
+
readonly hasDefault: true;
|
|
925
|
+
readonly default: V$1;
|
|
926
|
+
readonly optional: true;
|
|
927
|
+
}>>;
|
|
928
|
+
map(columnName: string): DateTimeField<UpdateState$1<this["~"]["state"], {
|
|
929
|
+
readonly columnName: string;
|
|
930
|
+
}>>;
|
|
931
|
+
now(): DateTimeField<UpdateState$1<this["~"]["state"], {
|
|
932
|
+
readonly hasDefault: true;
|
|
933
|
+
readonly autoGenerate: "now";
|
|
934
|
+
readonly default: () => string;
|
|
935
|
+
readonly optional: true;
|
|
936
|
+
}>>;
|
|
937
|
+
updatedAt(): DateTimeField<UpdateState$1<this["~"]["state"], {
|
|
938
|
+
readonly hasDefault: true;
|
|
939
|
+
readonly autoGenerate: "updatedAt";
|
|
940
|
+
readonly default: () => string;
|
|
941
|
+
readonly optional: true;
|
|
942
|
+
}>>;
|
|
943
|
+
withoutTimezone(): DateTimeField<UpdateState$1<this["~"]["state"], {
|
|
944
|
+
readonly withTimezone: false;
|
|
945
|
+
}>>;
|
|
946
|
+
get ["~"](): {
|
|
947
|
+
state: State;
|
|
948
|
+
schemas: DateTimeSchemas<State>;
|
|
949
|
+
nativeType: NativeType | undefined;
|
|
950
|
+
};
|
|
951
|
+
}
|
|
952
|
+
//#endregion
|
|
953
|
+
//#region src/schema/fields/datetime/time-field.d.ts
|
|
954
|
+
declare class TimeField<State extends FieldState<"time">> {
|
|
955
|
+
private _schemas;
|
|
956
|
+
private readonly state;
|
|
957
|
+
private readonly _nativeType?;
|
|
958
|
+
constructor(state: State, _nativeType?: NativeType);
|
|
959
|
+
nullable(): TimeField<UpdateState$1<this["~"]["state"], {
|
|
960
|
+
readonly nullable: true;
|
|
961
|
+
readonly hasDefault: true;
|
|
962
|
+
readonly default: null;
|
|
963
|
+
readonly optional: true;
|
|
964
|
+
readonly base: IsoTimeSchema<ComputeInput<string | Date, {
|
|
965
|
+
nullable: true;
|
|
966
|
+
array: State["array"];
|
|
967
|
+
}>, ComputeOutput<string, {
|
|
968
|
+
nullable: true;
|
|
969
|
+
array: State["array"];
|
|
970
|
+
}>>;
|
|
971
|
+
}>>;
|
|
972
|
+
array(): TimeField<UpdateState$1<this["~"]["state"], {
|
|
973
|
+
readonly array: true;
|
|
974
|
+
readonly base: IsoTimeSchema<ComputeInput<string | Date, {
|
|
975
|
+
nullable: State["nullable"];
|
|
976
|
+
array: true;
|
|
977
|
+
}>, ComputeOutput<string, {
|
|
978
|
+
nullable: State["nullable"];
|
|
979
|
+
array: true;
|
|
980
|
+
}>>;
|
|
981
|
+
}>>;
|
|
982
|
+
id(): TimeField<UpdateState$1<this["~"]["state"], {
|
|
983
|
+
readonly isId: true;
|
|
984
|
+
readonly isUnique: true;
|
|
985
|
+
}>>;
|
|
986
|
+
unique(): TimeField<UpdateState$1<this["~"]["state"], {
|
|
987
|
+
readonly isUnique: true;
|
|
988
|
+
}>>;
|
|
989
|
+
schema<S extends StandardSchemaOf<string>>(schema: S): TimeField<UpdateState$1<this["~"]["state"], {
|
|
990
|
+
readonly schema: S;
|
|
991
|
+
readonly base: IsoTimeSchema<ComputeInput<string | Date, {
|
|
992
|
+
nullable: State["nullable"];
|
|
993
|
+
array: State["array"];
|
|
994
|
+
schema: S;
|
|
995
|
+
}>, ComputeOutput<string, {
|
|
996
|
+
nullable: State["nullable"];
|
|
997
|
+
array: State["array"];
|
|
998
|
+
schema: S;
|
|
999
|
+
}>>;
|
|
1000
|
+
}>>;
|
|
1001
|
+
default<V$1 extends DefaultValueInput<State>>(value: V$1): TimeField<UpdateState$1<this["~"]["state"], {
|
|
1002
|
+
readonly hasDefault: true;
|
|
1003
|
+
readonly default: V$1;
|
|
1004
|
+
readonly optional: true;
|
|
1005
|
+
}>>;
|
|
1006
|
+
/**
|
|
1007
|
+
* Maps this field to a custom column name in the database
|
|
1008
|
+
*/
|
|
1009
|
+
map(columnName: string): TimeField<UpdateState$1<this["~"]["state"], {
|
|
1010
|
+
readonly columnName: string;
|
|
1011
|
+
}>>;
|
|
1012
|
+
now(): TimeField<UpdateState$1<this["~"]["state"], {
|
|
1013
|
+
readonly hasDefault: true;
|
|
1014
|
+
readonly autoGenerate: "now";
|
|
1015
|
+
readonly default: () => string;
|
|
1016
|
+
readonly optional: true;
|
|
1017
|
+
}>>;
|
|
1018
|
+
updatedAt(): TimeField<UpdateState$1<this["~"]["state"], {
|
|
1019
|
+
readonly hasDefault: true;
|
|
1020
|
+
readonly autoGenerate: "updatedAt";
|
|
1021
|
+
readonly default: () => string;
|
|
1022
|
+
readonly optional: true;
|
|
1023
|
+
}>>;
|
|
1024
|
+
/**
|
|
1025
|
+
* Stores time without timezone information.
|
|
1026
|
+
* Maps to PostgreSQL TIME (without time zone) instead of TIMETZ.
|
|
1027
|
+
*
|
|
1028
|
+
* Use this when:
|
|
1029
|
+
* - You want to store local times (e.g., "store opens at 9:00 AM")
|
|
1030
|
+
* - The time should not be converted based on timezone
|
|
1031
|
+
*/
|
|
1032
|
+
withoutTimezone(): TimeField<UpdateState$1<this["~"]["state"], {
|
|
1033
|
+
readonly withTimezone: false;
|
|
1034
|
+
}>>;
|
|
1035
|
+
get ["~"](): {
|
|
1036
|
+
state: State;
|
|
1037
|
+
schemas: TimeSchemas<State>;
|
|
1038
|
+
nativeType: NativeType | undefined;
|
|
1039
|
+
};
|
|
1040
|
+
}
|
|
1041
|
+
//#endregion
|
|
1042
|
+
//#region src/schema/fields/float/schemas.d.ts
|
|
1043
|
+
type FloatFilterBase<S extends V.Schema> = {
|
|
1044
|
+
equals: S;
|
|
1045
|
+
in: V.Number<{
|
|
1046
|
+
array: true;
|
|
1047
|
+
}>;
|
|
1048
|
+
notIn: V.Number<{
|
|
1049
|
+
array: true;
|
|
1050
|
+
}>;
|
|
1051
|
+
lt: V.Number;
|
|
1052
|
+
lte: V.Number;
|
|
1053
|
+
gt: V.Number;
|
|
1054
|
+
gte: V.Number;
|
|
1055
|
+
};
|
|
1056
|
+
type FloatFilterSchema<S extends V.Schema> = V.Union<readonly [V.ShorthandFilter<S>, V.Object<FloatFilterBase<S> & {
|
|
1057
|
+
not: V.Union<readonly [V.ShorthandFilter<S>, V.Object<FloatFilterBase<S>>]>;
|
|
1058
|
+
}>]>;
|
|
1059
|
+
type FloatListFilterBase<S extends V.Schema> = {
|
|
1060
|
+
equals: S;
|
|
1061
|
+
has: V.Number;
|
|
1062
|
+
hasEvery: V.Number<{
|
|
1063
|
+
array: true;
|
|
1064
|
+
}>;
|
|
1065
|
+
hasSome: V.Number<{
|
|
1066
|
+
array: true;
|
|
1067
|
+
}>;
|
|
1068
|
+
isEmpty: V.Boolean;
|
|
1069
|
+
};
|
|
1070
|
+
type FloatListFilterSchema<S extends V.Schema> = V.Union<readonly [V.ShorthandFilter<S>, V.Object<FloatListFilterBase<S> & {
|
|
1071
|
+
not: V.Union<readonly [V.ShorthandFilter<S>, V.Object<FloatListFilterBase<S>>]>;
|
|
1072
|
+
}>]>;
|
|
1073
|
+
type FloatUpdateSchema<S extends V.Schema> = V.Union<readonly [V.ShorthandUpdate<S>, V.Object<{
|
|
1074
|
+
set: S;
|
|
1075
|
+
increment: V.Number;
|
|
1076
|
+
decrement: V.Number;
|
|
1077
|
+
multiply: V.Number;
|
|
1078
|
+
divide: V.Number;
|
|
1079
|
+
}>]>;
|
|
1080
|
+
type FloatListUpdateSchema<S extends V.Schema> = V.Union<readonly [V.ShorthandUpdate<S>, V.Object<{
|
|
1081
|
+
set: S;
|
|
1082
|
+
push: V.Union<readonly [V.ShorthandArray<V.Number>, V.Number<{
|
|
1083
|
+
array: true;
|
|
1084
|
+
}>]>;
|
|
1085
|
+
unshift: V.Union<readonly [V.ShorthandArray<V.Number>, V.Number<{
|
|
1086
|
+
array: true;
|
|
1087
|
+
}>]>;
|
|
1088
|
+
}>]>;
|
|
1089
|
+
interface FloatSchemas<F$1 extends FieldState<"float">> {
|
|
1090
|
+
base: F$1["base"];
|
|
1091
|
+
create: BaseNumberSchema<F$1>;
|
|
1092
|
+
update: F$1["array"] extends true ? FloatListUpdateSchema<F$1["base"]> : FloatUpdateSchema<F$1["base"]>;
|
|
1093
|
+
filter: F$1["array"] extends true ? FloatListFilterSchema<F$1["base"]> : FloatFilterSchema<F$1["base"]>;
|
|
1094
|
+
}
|
|
1095
|
+
//#endregion
|
|
1096
|
+
//#region src/schema/fields/decimal/schemas.d.ts
|
|
1097
|
+
interface DecimalSchemas<F$1 extends FieldState<"decimal">> {
|
|
1098
|
+
base: F$1["base"];
|
|
1099
|
+
create: BaseNumberSchema<F$1>;
|
|
1100
|
+
update: F$1["array"] extends true ? FloatListUpdateSchema<F$1["base"]> : FloatUpdateSchema<F$1["base"]>;
|
|
1101
|
+
filter: F$1["array"] extends true ? FloatListFilterSchema<F$1["base"]> : FloatFilterSchema<F$1["base"]>;
|
|
1102
|
+
}
|
|
1103
|
+
//#endregion
|
|
1104
|
+
//#region src/schema/fields/decimal/field.d.ts
|
|
1105
|
+
declare class DecimalField<State extends FieldState<"decimal">> {
|
|
1106
|
+
private readonly state;
|
|
1107
|
+
private readonly _nativeType?;
|
|
1108
|
+
private _schemas;
|
|
1109
|
+
constructor(state: State, _nativeType?: NativeType);
|
|
1110
|
+
nullable(): DecimalField<UpdateState$1<this["~"]["state"], {
|
|
1111
|
+
readonly nullable: true;
|
|
1112
|
+
readonly hasDefault: true;
|
|
1113
|
+
readonly default: null;
|
|
1114
|
+
readonly optional: true;
|
|
1115
|
+
readonly base: NumberSchema<ComputeInput<number, {
|
|
1116
|
+
nullable: true;
|
|
1117
|
+
array: State["array"];
|
|
1118
|
+
}>, ComputeOutput<number, {
|
|
1119
|
+
nullable: true;
|
|
1120
|
+
array: State["array"];
|
|
1121
|
+
}>>;
|
|
1122
|
+
}>>;
|
|
1123
|
+
array(): DecimalField<UpdateState$1<this["~"]["state"], {
|
|
1124
|
+
readonly array: true;
|
|
1125
|
+
readonly base: NumberSchema<ComputeInput<number, {
|
|
1126
|
+
nullable: State["nullable"];
|
|
1127
|
+
array: true;
|
|
1128
|
+
}>, ComputeOutput<number, {
|
|
1129
|
+
nullable: State["nullable"];
|
|
1130
|
+
array: true;
|
|
1131
|
+
}>>;
|
|
1132
|
+
}>>;
|
|
1133
|
+
id(): DecimalField<UpdateState$1<this["~"]["state"], {
|
|
1134
|
+
readonly isId: true;
|
|
1135
|
+
readonly isUnique: true;
|
|
1136
|
+
}>>;
|
|
1137
|
+
unique(): DecimalField<UpdateState$1<this["~"]["state"], {
|
|
1138
|
+
readonly isUnique: true;
|
|
1139
|
+
}>>;
|
|
1140
|
+
default<V$1 extends DefaultValueInput<State>>(value: V$1): DecimalField<UpdateState$1<this["~"]["state"], {
|
|
1141
|
+
readonly hasDefault: true;
|
|
1142
|
+
readonly default: V$1;
|
|
1143
|
+
readonly optional: true;
|
|
1144
|
+
}>>;
|
|
1145
|
+
schema<S extends StandardSchemaOf<number>>(schema: S): DecimalField<UpdateState$1<this["~"]["state"], {
|
|
1146
|
+
readonly schema: S;
|
|
1147
|
+
readonly base: NumberSchema<ComputeInput<number, {
|
|
1148
|
+
nullable: State["nullable"];
|
|
1149
|
+
array: State["array"];
|
|
1150
|
+
schema: S;
|
|
1151
|
+
}>, ComputeOutput<number, {
|
|
1152
|
+
nullable: State["nullable"];
|
|
1153
|
+
array: State["array"];
|
|
1154
|
+
schema: S;
|
|
1155
|
+
}>>;
|
|
1156
|
+
}>>;
|
|
1157
|
+
map(columnName: string): DecimalField<UpdateState$1<this["~"]["state"], {
|
|
1158
|
+
readonly columnName: string;
|
|
1159
|
+
}>>;
|
|
1160
|
+
get ["~"](): {
|
|
1161
|
+
state: State;
|
|
1162
|
+
schemas: DecimalSchemas<State>;
|
|
1163
|
+
nativeType: NativeType | undefined;
|
|
1164
|
+
};
|
|
1165
|
+
}
|
|
1166
|
+
//#endregion
|
|
1167
|
+
//#region src/schema/fields/enum/schemas.d.ts
|
|
1168
|
+
type EnumFilterBase<S extends V.Schema, Values extends string[]> = {
|
|
1169
|
+
equals: S;
|
|
1170
|
+
in: V.Enum<Values, {
|
|
1171
|
+
array: true;
|
|
1172
|
+
}>;
|
|
1173
|
+
notIn: V.Enum<Values, {
|
|
1174
|
+
array: true;
|
|
1175
|
+
}>;
|
|
1176
|
+
};
|
|
1177
|
+
type EnumFilterSchema<S extends V.Schema, Values extends string[]> = V.Union<readonly [V.ShorthandFilter<S>, V.Object<EnumFilterBase<S, Values> & {
|
|
1178
|
+
not: V.Union<readonly [V.ShorthandFilter<S>, V.Object<EnumFilterBase<S, Values>>]>;
|
|
1179
|
+
}>]>;
|
|
1180
|
+
type EnumListFilterBase<S extends V.Schema, Values extends string[]> = {
|
|
1181
|
+
equals: S;
|
|
1182
|
+
has: V.Enum<Values>;
|
|
1183
|
+
hasEvery: V.Enum<Values, {
|
|
1184
|
+
array: true;
|
|
1185
|
+
}>;
|
|
1186
|
+
hasSome: V.Enum<Values, {
|
|
1187
|
+
array: true;
|
|
1188
|
+
}>;
|
|
1189
|
+
isEmpty: V.Boolean;
|
|
1190
|
+
};
|
|
1191
|
+
type EnumListFilterSchema<S extends V.Schema, Values extends string[]> = V.Union<readonly [V.ShorthandFilter<S>, V.Object<EnumListFilterBase<S, Values> & {
|
|
1192
|
+
not: V.Union<readonly [V.ShorthandFilter<S>, V.Object<EnumListFilterBase<S, Values>>]>;
|
|
1193
|
+
}>]>;
|
|
1194
|
+
type EnumUpdateSchema<S extends V.Schema> = V.Union<readonly [V.ShorthandUpdate<S>, V.Object<{
|
|
1195
|
+
set: S;
|
|
1196
|
+
}, {
|
|
1197
|
+
partial: false;
|
|
1198
|
+
}>]>;
|
|
1199
|
+
type EnumListUpdateSchema<S extends V.Schema, Values extends string[]> = V.Union<readonly [V.ShorthandUpdate<S>, V.Object<{
|
|
1200
|
+
set: S;
|
|
1201
|
+
push: V.Union<readonly [V.ShorthandArray<V.Enum<Values>>, V.Enum<Values, {
|
|
1202
|
+
array: true;
|
|
1203
|
+
}>]>;
|
|
1204
|
+
unshift: V.Union<readonly [V.ShorthandArray<V.Enum<Values>>, V.Enum<Values, {
|
|
1205
|
+
array: true;
|
|
1206
|
+
}>]>;
|
|
1207
|
+
}>]>;
|
|
1208
|
+
interface EnumSchemas<Values extends string[], F$1 extends FieldState<"enum">> {
|
|
1209
|
+
base: F$1["base"];
|
|
1210
|
+
create: BaseEnumSchema<Values, F$1>;
|
|
1211
|
+
update: F$1["array"] extends true ? EnumListUpdateSchema<F$1["base"], Values> : EnumUpdateSchema<F$1["base"]>;
|
|
1212
|
+
filter: F$1["array"] extends true ? EnumListFilterSchema<F$1["base"], Values> : EnumFilterSchema<F$1["base"], Values>;
|
|
1213
|
+
}
|
|
1214
|
+
//#endregion
|
|
1215
|
+
//#region src/schema/fields/enum/field.d.ts
|
|
1216
|
+
declare class EnumField<State extends FieldState<"enum">> {
|
|
1217
|
+
private _schemas;
|
|
1218
|
+
private readonly state;
|
|
1219
|
+
private readonly _nativeType?;
|
|
1220
|
+
constructor(state: State, _nativeType?: NativeType);
|
|
1221
|
+
get enumValues(): EnumValues<State["base"]>;
|
|
1222
|
+
nullable(): EnumField<UpdateState$1<this["~"]["state"], {
|
|
1223
|
+
readonly nullable: true;
|
|
1224
|
+
readonly hasDefault: true;
|
|
1225
|
+
readonly default: null;
|
|
1226
|
+
readonly optional: true;
|
|
1227
|
+
readonly base: EnumSchema<EnumValues<State["base"]>, ComputeInput<EnumValues<State["base"]>[number], {
|
|
1228
|
+
nullable: true;
|
|
1229
|
+
array: State["array"];
|
|
1230
|
+
}>, ComputeOutput<EnumValues<State["base"]>[number], {
|
|
1231
|
+
nullable: true;
|
|
1232
|
+
array: State["array"];
|
|
1233
|
+
}>>;
|
|
1234
|
+
}>>;
|
|
1235
|
+
array(): EnumField<UpdateState$1<this["~"]["state"], {
|
|
1236
|
+
readonly array: true;
|
|
1237
|
+
readonly base: EnumSchema<EnumValues<State["base"]>, ComputeInput<EnumValues<State["base"]>[number], {
|
|
1238
|
+
nullable: State["nullable"];
|
|
1239
|
+
array: true;
|
|
1240
|
+
}>, ComputeOutput<EnumValues<State["base"]>[number], {
|
|
1241
|
+
nullable: State["nullable"];
|
|
1242
|
+
array: true;
|
|
1243
|
+
}>>;
|
|
1244
|
+
}>>;
|
|
1245
|
+
default<V$1 extends DefaultValueInput<State>>(value: V$1): EnumField<UpdateState$1<this["~"]["state"], {
|
|
1246
|
+
readonly hasDefault: true;
|
|
1247
|
+
readonly default: V$1;
|
|
1248
|
+
readonly optional: true;
|
|
1249
|
+
}>>;
|
|
1250
|
+
map(columnName: string): EnumField<UpdateState$1<this["~"]["state"], {
|
|
1251
|
+
readonly columnName: string;
|
|
1252
|
+
}>>;
|
|
1253
|
+
/**
|
|
1254
|
+
* Set a custom name for the enum type in the database.
|
|
1255
|
+
* This allows reusing the same enum across multiple tables.
|
|
1256
|
+
*
|
|
1257
|
+
* @example
|
|
1258
|
+
* ```ts
|
|
1259
|
+
* const Status = s.enum(["PENDING", "ACTIVE"]).name("status");
|
|
1260
|
+
*
|
|
1261
|
+
* const user = s.model({ status: Status });
|
|
1262
|
+
* const order = s.model({ status: Status }); // Same "status" enum type
|
|
1263
|
+
* ```
|
|
1264
|
+
*/
|
|
1265
|
+
name(enumName: string): EnumField<UpdateState$1<this["~"]["state"], {
|
|
1266
|
+
readonly enumName: string;
|
|
1267
|
+
}>>;
|
|
1268
|
+
get ["~"](): {
|
|
1269
|
+
state: State;
|
|
1270
|
+
schemas: EnumSchemas<EnumValues<State["base"]>, State>;
|
|
1271
|
+
nativeType: NativeType | undefined;
|
|
1272
|
+
};
|
|
1273
|
+
}
|
|
1274
|
+
//#endregion
|
|
1275
|
+
//#region src/schema/fields/float/field.d.ts
|
|
1276
|
+
declare class FloatField<State extends FieldState<"float">> {
|
|
1277
|
+
private readonly state;
|
|
1278
|
+
private readonly _nativeType?;
|
|
1279
|
+
private _schemas;
|
|
1280
|
+
constructor(state: State, _nativeType?: NativeType);
|
|
1281
|
+
nullable(): FloatField<UpdateState$1<this["~"]["state"], {
|
|
1282
|
+
readonly nullable: true;
|
|
1283
|
+
readonly hasDefault: true;
|
|
1284
|
+
readonly default: null;
|
|
1285
|
+
readonly optional: true;
|
|
1286
|
+
readonly base: NumberSchema<ComputeInput<number, {
|
|
1287
|
+
nullable: true;
|
|
1288
|
+
array: State["array"];
|
|
1289
|
+
}>, ComputeOutput<number, {
|
|
1290
|
+
nullable: true;
|
|
1291
|
+
array: State["array"];
|
|
1292
|
+
}>>;
|
|
1293
|
+
}>>;
|
|
1294
|
+
array(): FloatField<UpdateState$1<this["~"]["state"], {
|
|
1295
|
+
readonly array: true;
|
|
1296
|
+
readonly base: NumberSchema<ComputeInput<number, {
|
|
1297
|
+
nullable: State["nullable"];
|
|
1298
|
+
array: true;
|
|
1299
|
+
}>, ComputeOutput<number, {
|
|
1300
|
+
nullable: State["nullable"];
|
|
1301
|
+
array: true;
|
|
1302
|
+
}>>;
|
|
1303
|
+
}>>;
|
|
1304
|
+
id(): FloatField<UpdateState$1<this["~"]["state"], {
|
|
1305
|
+
readonly isId: true;
|
|
1306
|
+
readonly isUnique: true;
|
|
1307
|
+
}>>;
|
|
1308
|
+
unique(): FloatField<UpdateState$1<this["~"]["state"], {
|
|
1309
|
+
readonly isUnique: true;
|
|
1310
|
+
}>>;
|
|
1311
|
+
default<V$1 extends DefaultValueInput<State>>(value: V$1): FloatField<UpdateState$1<this["~"]["state"], {
|
|
1312
|
+
readonly hasDefault: true;
|
|
1313
|
+
readonly default: V$1;
|
|
1314
|
+
readonly optional: true;
|
|
1315
|
+
}>>;
|
|
1316
|
+
schema<S extends StandardSchemaOf<number>>(schema: S): FloatField<UpdateState$1<this["~"]["state"], {
|
|
1317
|
+
readonly schema: S;
|
|
1318
|
+
readonly base: NumberSchema<ComputeInput<number, {
|
|
1319
|
+
nullable: State["nullable"];
|
|
1320
|
+
array: State["array"];
|
|
1321
|
+
schema: S;
|
|
1322
|
+
}>, ComputeOutput<number, {
|
|
1323
|
+
nullable: State["nullable"];
|
|
1324
|
+
array: State["array"];
|
|
1325
|
+
schema: S;
|
|
1326
|
+
}>>;
|
|
1327
|
+
}>>;
|
|
1328
|
+
map(columnName: string): FloatField<UpdateState$1<this["~"]["state"], {
|
|
1329
|
+
readonly columnName: string;
|
|
1330
|
+
}>>;
|
|
1331
|
+
get ["~"](): {
|
|
1332
|
+
state: State;
|
|
1333
|
+
schemas: FloatSchemas<State>;
|
|
1334
|
+
nativeType: NativeType | undefined;
|
|
1335
|
+
};
|
|
1336
|
+
}
|
|
1337
|
+
//#endregion
|
|
1338
|
+
//#region src/schema/fields/int/schemas.d.ts
|
|
1339
|
+
type IntFilterBase<S extends V.Schema> = {
|
|
1340
|
+
equals: S;
|
|
1341
|
+
in: V.Integer<{
|
|
1342
|
+
array: true;
|
|
1343
|
+
}>;
|
|
1344
|
+
notIn: V.Integer<{
|
|
1345
|
+
array: true;
|
|
1346
|
+
}>;
|
|
1347
|
+
lt: V.Integer;
|
|
1348
|
+
lte: V.Integer;
|
|
1349
|
+
gt: V.Integer;
|
|
1350
|
+
gte: V.Integer;
|
|
1351
|
+
};
|
|
1352
|
+
type IntFilterSchema<S extends V.Schema> = V.Union<readonly [V.ShorthandFilter<S>, V.Object<IntFilterBase<S> & {
|
|
1353
|
+
not: V.Union<readonly [V.ShorthandFilter<S>, V.Object<IntFilterBase<S>>]>;
|
|
1354
|
+
}>]>;
|
|
1355
|
+
type IntListFilterBase<S extends V.Schema> = {
|
|
1356
|
+
equals: S;
|
|
1357
|
+
has: V.Integer;
|
|
1358
|
+
hasEvery: V.Integer<{
|
|
1359
|
+
array: true;
|
|
1360
|
+
}>;
|
|
1361
|
+
hasSome: V.Integer<{
|
|
1362
|
+
array: true;
|
|
1363
|
+
}>;
|
|
1364
|
+
isEmpty: V.Boolean;
|
|
1365
|
+
};
|
|
1366
|
+
type IntListFilterSchema<S extends V.Schema> = V.Union<readonly [V.ShorthandFilter<S>, V.Object<IntListFilterBase<S> & {
|
|
1367
|
+
not: V.Union<readonly [V.ShorthandFilter<S>, V.Object<IntListFilterBase<S>>]>;
|
|
1368
|
+
}>]>;
|
|
1369
|
+
type IntUpdateSchema<S extends V.Schema> = V.Union<readonly [V.ShorthandUpdate<S>, V.Object<{
|
|
1370
|
+
set: S;
|
|
1371
|
+
increment: V.Integer;
|
|
1372
|
+
decrement: V.Integer;
|
|
1373
|
+
multiply: V.Integer;
|
|
1374
|
+
divide: V.Integer;
|
|
1375
|
+
}>]>;
|
|
1376
|
+
type IntListUpdateSchema<S extends V.Schema> = V.Union<readonly [V.ShorthandUpdate<S>, V.Object<{
|
|
1377
|
+
set: S;
|
|
1378
|
+
push: V.Union<readonly [V.ShorthandArray<V.Integer>, V.Integer<{
|
|
1379
|
+
array: true;
|
|
1380
|
+
}>]>;
|
|
1381
|
+
unshift: V.Union<readonly [V.ShorthandArray<V.Integer>, V.Integer<{
|
|
1382
|
+
array: true;
|
|
1383
|
+
}>]>;
|
|
1384
|
+
}>]>;
|
|
1385
|
+
interface IntSchemas<F$1 extends FieldState<"int">> {
|
|
1386
|
+
base: F$1["base"];
|
|
1387
|
+
create: BaseIntegerSchema<F$1>;
|
|
1388
|
+
update: F$1["array"] extends true ? IntListUpdateSchema<F$1["base"]> : IntUpdateSchema<F$1["base"]>;
|
|
1389
|
+
filter: F$1["array"] extends true ? IntListFilterSchema<F$1["base"]> : IntFilterSchema<F$1["base"]>;
|
|
1390
|
+
}
|
|
1391
|
+
//#endregion
|
|
1392
|
+
//#region src/schema/fields/int/field.d.ts
|
|
1393
|
+
declare class IntField<State extends FieldState<"int">> {
|
|
1394
|
+
private _schemas;
|
|
1395
|
+
private readonly state;
|
|
1396
|
+
private readonly _nativeType?;
|
|
1397
|
+
constructor(state: State, _nativeType?: NativeType);
|
|
1398
|
+
nullable(): IntField<UpdateState$1<this["~"]["state"], {
|
|
1399
|
+
readonly nullable: true;
|
|
1400
|
+
readonly hasDefault: true;
|
|
1401
|
+
readonly default: null;
|
|
1402
|
+
readonly optional: true;
|
|
1403
|
+
readonly base: IntegerSchema<ComputeInput<number, {
|
|
1404
|
+
nullable: true;
|
|
1405
|
+
array: State["array"];
|
|
1406
|
+
}>, ComputeOutput<number, {
|
|
1407
|
+
nullable: true;
|
|
1408
|
+
array: State["array"];
|
|
1409
|
+
}>>;
|
|
1410
|
+
}>>;
|
|
1411
|
+
array(): IntField<UpdateState$1<this["~"]["state"], {
|
|
1412
|
+
readonly array: true;
|
|
1413
|
+
readonly base: IntegerSchema<ComputeInput<number, {
|
|
1414
|
+
nullable: State["nullable"];
|
|
1415
|
+
array: true;
|
|
1416
|
+
}>, ComputeOutput<number, {
|
|
1417
|
+
nullable: State["nullable"];
|
|
1418
|
+
array: true;
|
|
1419
|
+
}>>;
|
|
1420
|
+
}>>;
|
|
1421
|
+
id(): IntField<UpdateState$1<this["~"]["state"], {
|
|
1422
|
+
readonly isId: true;
|
|
1423
|
+
readonly isUnique: true;
|
|
1424
|
+
}>>;
|
|
1425
|
+
unique(): IntField<UpdateState$1<this["~"]["state"], {
|
|
1426
|
+
readonly isUnique: true;
|
|
1427
|
+
}>>;
|
|
1428
|
+
default<V$1 extends DefaultValueInput<State>>(value: V$1): IntField<UpdateState$1<this["~"]["state"], {
|
|
1429
|
+
readonly hasDefault: true;
|
|
1430
|
+
readonly default: V$1;
|
|
1431
|
+
readonly optional: true;
|
|
1432
|
+
}>>;
|
|
1433
|
+
schema<S extends StandardSchemaOf<number>>(schema: S): IntField<UpdateState$1<this["~"]["state"], {
|
|
1434
|
+
readonly schema: S;
|
|
1435
|
+
readonly base: IntegerSchema<ComputeInput<number, {
|
|
1436
|
+
nullable: State["nullable"];
|
|
1437
|
+
array: State["array"];
|
|
1438
|
+
schema: S;
|
|
1439
|
+
}>, ComputeOutput<number, {
|
|
1440
|
+
nullable: State["nullable"];
|
|
1441
|
+
array: State["array"];
|
|
1442
|
+
schema: S;
|
|
1443
|
+
}>>;
|
|
1444
|
+
}>>;
|
|
1445
|
+
map(columnName: string): IntField<UpdateState$1<this["~"]["state"], {
|
|
1446
|
+
readonly columnName: string;
|
|
1447
|
+
}>>;
|
|
1448
|
+
increment(): IntField<UpdateState$1<this["~"]["state"], {
|
|
1449
|
+
readonly hasDefault: true;
|
|
1450
|
+
readonly autoGenerate: "increment";
|
|
1451
|
+
readonly default: 0;
|
|
1452
|
+
readonly optional: true;
|
|
1453
|
+
}>>;
|
|
1454
|
+
get ["~"](): {
|
|
1455
|
+
state: State;
|
|
1456
|
+
schemas: IntSchemas<State>;
|
|
1457
|
+
nativeType: NativeType | undefined;
|
|
1458
|
+
};
|
|
1459
|
+
}
|
|
1460
|
+
//#endregion
|
|
1461
|
+
//#region src/schema/fields/json/schemas.d.ts
|
|
1462
|
+
type JsonFilterBase<S extends V.Schema> = {
|
|
1463
|
+
equals: S;
|
|
1464
|
+
path: V.Array<V.String>;
|
|
1465
|
+
string_contains: V.String;
|
|
1466
|
+
string_starts_with: V.String;
|
|
1467
|
+
string_ends_with: V.String;
|
|
1468
|
+
array_contains: S;
|
|
1469
|
+
array_starts_with: S;
|
|
1470
|
+
array_ends_with: S;
|
|
1471
|
+
};
|
|
1472
|
+
type JsonFilterSchema<S extends V.Schema> = V.Object<JsonFilterBase<S> & {
|
|
1473
|
+
not: V.Object<JsonFilterBase<S>>;
|
|
1474
|
+
}>;
|
|
1475
|
+
type JsonUpdateSchema<S extends V.Schema> = V.Coerce<S, {
|
|
1476
|
+
set: S[" vibInferred"]["1"];
|
|
1477
|
+
}>;
|
|
1478
|
+
interface JsonSchemas<F$1 extends FieldState<"json">> {
|
|
1479
|
+
base: F$1["base"];
|
|
1480
|
+
create: BaseJsonSchema<F$1>;
|
|
1481
|
+
update: JsonUpdateSchema<F$1["base"]>;
|
|
1482
|
+
filter: JsonFilterSchema<F$1["base"]>;
|
|
1483
|
+
}
|
|
1484
|
+
//#endregion
|
|
1485
|
+
//#region src/schema/fields/json/field.d.ts
|
|
1486
|
+
declare class JsonField<State extends FieldState<"json"> = FieldState<"json">> {
|
|
1487
|
+
private _schemas;
|
|
1488
|
+
private readonly state;
|
|
1489
|
+
private readonly _nativeType?;
|
|
1490
|
+
constructor(state: State, _nativeType?: NativeType);
|
|
1491
|
+
nullable(): JsonField<UpdateState$1<this["~"]["state"], {
|
|
1492
|
+
readonly nullable: true;
|
|
1493
|
+
readonly hasDefault: true;
|
|
1494
|
+
readonly default: null;
|
|
1495
|
+
readonly optional: true;
|
|
1496
|
+
readonly base: JsonSchema<ComputeInput<JsonValue, {
|
|
1497
|
+
nullable: true;
|
|
1498
|
+
schema: State["schema"];
|
|
1499
|
+
}>, ComputeOutput<JsonValue, {
|
|
1500
|
+
nullable: true;
|
|
1501
|
+
schema: State["schema"];
|
|
1502
|
+
}>>;
|
|
1503
|
+
}>>;
|
|
1504
|
+
default<V$1 extends DefaultValueInput<State>>(value: V$1): JsonField<UpdateState$1<this["~"]["state"], {
|
|
1505
|
+
readonly hasDefault: true;
|
|
1506
|
+
readonly default: V$1;
|
|
1507
|
+
readonly optional: true;
|
|
1508
|
+
}>>;
|
|
1509
|
+
schema<S extends StandardSchemaOf<JsonValue>>(schema: S): JsonField<UpdateState$1<this["~"]["state"], {
|
|
1510
|
+
readonly schema: S;
|
|
1511
|
+
readonly base: JsonSchema<ComputeInput<JsonValue, {
|
|
1512
|
+
nullable: State["nullable"];
|
|
1513
|
+
schema: S;
|
|
1514
|
+
}>, ComputeOutput<JsonValue, {
|
|
1515
|
+
nullable: State["nullable"];
|
|
1516
|
+
schema: S;
|
|
1517
|
+
}>>;
|
|
1518
|
+
}>>;
|
|
1519
|
+
map(columnName: string): JsonField<UpdateState$1<this["~"]["state"], {
|
|
1520
|
+
readonly columnName: string;
|
|
1521
|
+
}>>;
|
|
1522
|
+
get ["~"](): {
|
|
1523
|
+
state: State;
|
|
1524
|
+
schemas: JsonSchemas<State>;
|
|
1525
|
+
nativeType: NativeType | undefined;
|
|
1526
|
+
};
|
|
1527
|
+
}
|
|
1528
|
+
//#endregion
|
|
1529
|
+
//#region src/schema/fields/point/schemas.d.ts
|
|
1530
|
+
type PointFilterBase<S extends V.Schema> = {
|
|
1531
|
+
equals: S;
|
|
1532
|
+
intersects: S;
|
|
1533
|
+
contains: S;
|
|
1534
|
+
within: S;
|
|
1535
|
+
crosses: S;
|
|
1536
|
+
overlaps: S;
|
|
1537
|
+
touches: S;
|
|
1538
|
+
covers: S;
|
|
1539
|
+
dWithin: V.Object<{
|
|
1540
|
+
geometry: S;
|
|
1541
|
+
distance: V.Number;
|
|
1542
|
+
}>;
|
|
1543
|
+
};
|
|
1544
|
+
type PointFilterSchema<S extends V.Schema> = V.Union<readonly [V.ShorthandFilter<S>, V.Object<PointFilterBase<S> & {
|
|
1545
|
+
not: V.Union<readonly [V.ShorthandFilter<S>, V.Object<PointFilterBase<S>>]>;
|
|
1546
|
+
}>]>;
|
|
1547
|
+
type PointUpdateSchema<S extends V.Schema> = V.Union<readonly [V.ShorthandUpdate<S>, V.Object<{
|
|
1548
|
+
set: S;
|
|
1549
|
+
}, {
|
|
1550
|
+
partial: false;
|
|
1551
|
+
}>]>;
|
|
1552
|
+
interface PointSchemas<F$1 extends FieldState<"point">> {
|
|
1553
|
+
base: F$1["base"];
|
|
1554
|
+
create: BasePointSchema<F$1>;
|
|
1555
|
+
update: PointUpdateSchema<F$1["base"]>;
|
|
1556
|
+
filter: PointFilterSchema<F$1["base"]>;
|
|
1557
|
+
}
|
|
1558
|
+
//#endregion
|
|
1559
|
+
//#region src/schema/fields/point/field.d.ts
|
|
1560
|
+
declare class PointField<State extends FieldState<"point">> {
|
|
1561
|
+
private _schemas;
|
|
1562
|
+
private readonly state;
|
|
1563
|
+
private readonly _nativeType?;
|
|
1564
|
+
constructor(state: State, _nativeType?: NativeType);
|
|
1565
|
+
nullable(): PointField<UpdateState$1<this["~"]["state"], {
|
|
1566
|
+
readonly nullable: true;
|
|
1567
|
+
readonly hasDefault: true;
|
|
1568
|
+
readonly default: null;
|
|
1569
|
+
readonly optional: true;
|
|
1570
|
+
readonly base: PointSchema<Point | null, Point | null>;
|
|
1571
|
+
}>>;
|
|
1572
|
+
default<V$1 extends DefaultValueInput<State>>(value: V$1): PointField<UpdateState$1<this["~"]["state"], {
|
|
1573
|
+
readonly hasDefault: true;
|
|
1574
|
+
readonly default: V$1;
|
|
1575
|
+
readonly optional: true;
|
|
1576
|
+
}>>;
|
|
1577
|
+
map(columnName: string): PointField<UpdateState$1<this["~"]["state"], {
|
|
1578
|
+
readonly columnName: string;
|
|
1579
|
+
}>>;
|
|
1580
|
+
get ["~"](): {
|
|
1581
|
+
state: State;
|
|
1582
|
+
schemas: PointSchemas<State>;
|
|
1583
|
+
nativeType: NativeType | undefined;
|
|
1584
|
+
};
|
|
1585
|
+
}
|
|
1586
|
+
//#endregion
|
|
1587
|
+
//#region src/schema/fields/string/schemas.d.ts
|
|
1588
|
+
type StringFilterBase<S extends V.Schema> = {
|
|
1589
|
+
equals: S;
|
|
1590
|
+
lt: S;
|
|
1591
|
+
lte: S;
|
|
1592
|
+
gt: S;
|
|
1593
|
+
gte: S;
|
|
1594
|
+
in: V.String<{
|
|
1595
|
+
array: true;
|
|
1596
|
+
}>;
|
|
1597
|
+
notIn: V.String<{
|
|
1598
|
+
array: true;
|
|
1599
|
+
}>;
|
|
1600
|
+
contains: V.String;
|
|
1601
|
+
startsWith: V.String;
|
|
1602
|
+
endsWith: V.String;
|
|
1603
|
+
mode: V.Enum<["default", "insensitive"]>;
|
|
1604
|
+
};
|
|
1605
|
+
type StringFilterSchema<S extends V.Schema> = V.Union<readonly [V.ShorthandFilter<S>, V.Object<StringFilterBase<S> & {
|
|
1606
|
+
not: V.Union<readonly [V.ShorthandFilter<S>, V.Object<StringFilterBase<S>>]>;
|
|
1607
|
+
}>]>;
|
|
1608
|
+
type StringListFilterBaseSchema<S extends V.Schema> = {
|
|
1609
|
+
equals: S;
|
|
1610
|
+
has: V.String;
|
|
1611
|
+
hasEvery: V.String<{
|
|
1612
|
+
array: true;
|
|
1613
|
+
}>;
|
|
1614
|
+
hasSome: V.String<{
|
|
1615
|
+
array: true;
|
|
1616
|
+
}>;
|
|
1617
|
+
isEmpty: V.Boolean;
|
|
1618
|
+
};
|
|
1619
|
+
type StringListFilterSchema<S extends V.Schema> = V.Union<readonly [V.ShorthandFilter<S>, V.Object<StringListFilterBaseSchema<S> & {
|
|
1620
|
+
not: V.Union<readonly [V.ShorthandFilter<S>, V.Object<StringListFilterBaseSchema<S>>]>;
|
|
1621
|
+
}>]>;
|
|
1622
|
+
type StringUpdateSchema<S extends V.Schema> = V.Union<readonly [V.ShorthandUpdate<S>, V.Object<{
|
|
1623
|
+
set: S;
|
|
1624
|
+
}, {
|
|
1625
|
+
partial: false;
|
|
1626
|
+
}>]>;
|
|
1627
|
+
type StringListUpdateSchema<S extends V.Schema> = V.Union<[V.ShorthandUpdate<S>, V.Object<{
|
|
1628
|
+
set: S;
|
|
1629
|
+
push: V.Union<readonly [V.ShorthandArray<V.String>, V.String<{
|
|
1630
|
+
array: true;
|
|
1631
|
+
}>]>;
|
|
1632
|
+
unshift: V.Union<readonly [V.ShorthandArray<V.String>, V.String<{
|
|
1633
|
+
array: true;
|
|
1634
|
+
}>]>;
|
|
1635
|
+
}>]>;
|
|
1636
|
+
interface StringSchemas<F$1 extends FieldState<"string">> {
|
|
1637
|
+
base: F$1["base"];
|
|
1638
|
+
create: V.String<F$1>;
|
|
1639
|
+
update: F$1["array"] extends true ? StringListUpdateSchema<F$1["base"]> : StringUpdateSchema<F$1["base"]>;
|
|
1640
|
+
filter: F$1["array"] extends true ? StringListFilterSchema<F$1["base"]> : StringFilterSchema<F$1["base"]>;
|
|
1641
|
+
}
|
|
1642
|
+
//#endregion
|
|
1643
|
+
//#region src/schema/fields/string/field.d.ts
|
|
1644
|
+
declare class StringField<State extends FieldState<"string">> {
|
|
1645
|
+
private _schemas;
|
|
1646
|
+
private readonly state;
|
|
1647
|
+
private readonly _nativeType?;
|
|
1648
|
+
constructor(state: State, _nativeType?: NativeType);
|
|
1649
|
+
nullable(): StringField<UpdateState$1<this["~"]["state"], {
|
|
1650
|
+
readonly nullable: true;
|
|
1651
|
+
readonly hasDefault: true;
|
|
1652
|
+
readonly default: null;
|
|
1653
|
+
readonly optional: true;
|
|
1654
|
+
readonly base: StringSchema<ComputeInput<string, {
|
|
1655
|
+
nullable: true;
|
|
1656
|
+
array: State["array"];
|
|
1657
|
+
schema: State["schema"];
|
|
1658
|
+
}>, ComputeOutput<string, {
|
|
1659
|
+
nullable: true;
|
|
1660
|
+
array: State["array"];
|
|
1661
|
+
schema: State["schema"];
|
|
1662
|
+
}>>;
|
|
1663
|
+
}>>;
|
|
1664
|
+
array(): StringField<UpdateState$1<this["~"]["state"], {
|
|
1665
|
+
readonly array: true;
|
|
1666
|
+
readonly base: StringSchema<ComputeInput<string, {
|
|
1667
|
+
nullable: State["nullable"];
|
|
1668
|
+
array: true;
|
|
1669
|
+
schema: State["schema"];
|
|
1670
|
+
}>, ComputeOutput<string, {
|
|
1671
|
+
nullable: State["nullable"];
|
|
1672
|
+
array: true;
|
|
1673
|
+
schema: State["schema"];
|
|
1674
|
+
}>>;
|
|
1675
|
+
}>>;
|
|
1676
|
+
id(prefix?: string): StringField<UpdateState$1<this["~"]["state"], {
|
|
1677
|
+
readonly isId: true;
|
|
1678
|
+
readonly isUnique: true;
|
|
1679
|
+
readonly autoGenerate: "ulid";
|
|
1680
|
+
readonly default: () => string;
|
|
1681
|
+
readonly optional: true;
|
|
1682
|
+
}>>;
|
|
1683
|
+
unique(): StringField<UpdateState$1<this["~"]["state"], {
|
|
1684
|
+
readonly isUnique: true;
|
|
1685
|
+
}>>;
|
|
1686
|
+
default<V$1 extends DefaultValueInput<State>>(value: V$1): StringField<UpdateState$1<this["~"]["state"], {
|
|
1687
|
+
readonly hasDefault: true;
|
|
1688
|
+
readonly default: V$1;
|
|
1689
|
+
readonly optional: true;
|
|
1690
|
+
}>>;
|
|
1691
|
+
schema<S extends StandardSchemaOf<string>>(schema: S): StringField<UpdateState$1<this["~"]["state"], {
|
|
1692
|
+
readonly schema: S;
|
|
1693
|
+
readonly base: StringSchema<ComputeInput<string, {
|
|
1694
|
+
nullable: State["nullable"];
|
|
1695
|
+
array: State["array"];
|
|
1696
|
+
schema: S;
|
|
1697
|
+
}>, ComputeOutput<string, {
|
|
1698
|
+
nullable: State["nullable"];
|
|
1699
|
+
array: State["array"];
|
|
1700
|
+
schema: S;
|
|
1701
|
+
}>>;
|
|
1702
|
+
}>>;
|
|
1703
|
+
/**
|
|
1704
|
+
* Maps this field to a custom column name in the database
|
|
1705
|
+
*/
|
|
1706
|
+
map(columnName: string): StringField<UpdateState$1<this["~"]["state"], {
|
|
1707
|
+
readonly columnName: string;
|
|
1708
|
+
}>>;
|
|
1709
|
+
uuid(prefix?: string): StringField<UpdateState$1<this["~"]["state"], {
|
|
1710
|
+
readonly hasDefault: true;
|
|
1711
|
+
readonly default: () => string;
|
|
1712
|
+
readonly autoGenerate: "uuid";
|
|
1713
|
+
readonly optional: true;
|
|
1714
|
+
}>>;
|
|
1715
|
+
ulid(prefix?: string): StringField<UpdateState$1<this["~"]["state"], {
|
|
1716
|
+
readonly hasDefault: true;
|
|
1717
|
+
readonly default: () => string;
|
|
1718
|
+
readonly autoGenerate: "ulid";
|
|
1719
|
+
readonly optional: true;
|
|
1720
|
+
}>>;
|
|
1721
|
+
nanoid(length?: number, prefix?: string): StringField<UpdateState$1<this["~"]["state"], {
|
|
1722
|
+
readonly hasDefault: true;
|
|
1723
|
+
readonly default: () => string;
|
|
1724
|
+
readonly autoGenerate: "nanoid";
|
|
1725
|
+
readonly optional: true;
|
|
1726
|
+
}>>;
|
|
1727
|
+
cuid(prefix?: string): StringField<UpdateState$1<this["~"]["state"], {
|
|
1728
|
+
readonly hasDefault: true;
|
|
1729
|
+
readonly default: () => string;
|
|
1730
|
+
readonly autoGenerate: "cuid";
|
|
1731
|
+
readonly optional: true;
|
|
1732
|
+
}>>;
|
|
1733
|
+
get ["~"](): {
|
|
1734
|
+
state: State;
|
|
1735
|
+
schemas: StringSchemas<State>;
|
|
1736
|
+
nativeType: NativeType | undefined;
|
|
1737
|
+
};
|
|
1738
|
+
}
|
|
1739
|
+
//#endregion
|
|
1740
|
+
//#region src/schema/fields/vector/schemas.d.ts
|
|
1741
|
+
type VectorFilterBase<S extends V.Schema> = {
|
|
1742
|
+
l2: S;
|
|
1743
|
+
cosine: S;
|
|
1744
|
+
};
|
|
1745
|
+
type VectorFilterSchema<S extends V.Schema> = V.Union<readonly [V.Coerce<S, {
|
|
1746
|
+
cosine: S[" vibInferred"]["1"];
|
|
1747
|
+
}>, V.Object<VectorFilterBase<S>>]>;
|
|
1748
|
+
type VectorUpdateSchema<S extends V.Schema> = V.Union<readonly [V.ShorthandUpdate<S>, V.Object<{
|
|
1749
|
+
set: S;
|
|
1750
|
+
}, {
|
|
1751
|
+
partial: false;
|
|
1752
|
+
}>]>;
|
|
1753
|
+
interface VectorSchemas<F$1 extends FieldState<"vector">> {
|
|
1754
|
+
base: F$1["base"];
|
|
1755
|
+
create: BaseVectorSchema<F$1>;
|
|
1756
|
+
update: VectorUpdateSchema<F$1["base"]>;
|
|
1757
|
+
filter: VectorFilterSchema<F$1["base"]>;
|
|
1758
|
+
}
|
|
1759
|
+
//#endregion
|
|
1760
|
+
//#region src/schema/fields/vector/field.d.ts
|
|
1761
|
+
declare class VectorField<State extends FieldState<"vector">> {
|
|
1762
|
+
private _schemas;
|
|
1763
|
+
private readonly state;
|
|
1764
|
+
private readonly _nativeType?;
|
|
1765
|
+
constructor(state: State, _nativeType?: NativeType);
|
|
1766
|
+
nullable(): VectorField<UpdateState$1<this["~"]["state"], {
|
|
1767
|
+
readonly nullable: true;
|
|
1768
|
+
readonly hasDefault: true;
|
|
1769
|
+
readonly default: null;
|
|
1770
|
+
readonly optional: true;
|
|
1771
|
+
readonly base: VectorSchema<number[] | null, number[] | null> & {
|
|
1772
|
+
dimensions?: number;
|
|
1773
|
+
};
|
|
1774
|
+
}>>;
|
|
1775
|
+
default<V$1 extends DefaultValueInput<State>>(value: V$1): VectorField<UpdateState$1<this["~"]["state"], {
|
|
1776
|
+
readonly hasDefault: true;
|
|
1777
|
+
readonly default: V$1;
|
|
1778
|
+
readonly optional: true;
|
|
1779
|
+
}>>;
|
|
1780
|
+
/**
|
|
1781
|
+
* Maps this field to a custom column name in the database
|
|
1782
|
+
*/
|
|
1783
|
+
map(columnName: string): VectorField<UpdateState$1<this["~"]["state"], {
|
|
1784
|
+
readonly columnName: string;
|
|
1785
|
+
}>>;
|
|
1786
|
+
dimension(dim: number): VectorField<any>;
|
|
1787
|
+
get ["~"](): {
|
|
1788
|
+
state: State;
|
|
1789
|
+
schemas: VectorSchemas<State>;
|
|
1790
|
+
nativeType: NativeType | undefined;
|
|
1791
|
+
};
|
|
1792
|
+
}
|
|
1793
|
+
//#endregion
|
|
1794
|
+
//#region src/schema/fields/index.d.ts
|
|
1795
|
+
type NumberField = IntField<FieldState<"int">> | FloatField<FieldState<"float">> | DecimalField<FieldState<"decimal">>;
|
|
1796
|
+
//#endregion
|
|
1797
|
+
//#region src/schema/fields/bigint/field.d.ts
|
|
1798
|
+
declare class BigIntField<State extends FieldState<"bigint">> {
|
|
1799
|
+
private _schemas;
|
|
1800
|
+
private readonly state;
|
|
1801
|
+
private readonly _nativeType?;
|
|
1802
|
+
constructor(state: State, _nativeType?: NativeType);
|
|
1803
|
+
nullable(): BigIntField<UpdateState$1<this["~"]["state"], {
|
|
1804
|
+
readonly nullable: true;
|
|
1805
|
+
readonly hasDefault: true;
|
|
1806
|
+
readonly default: null;
|
|
1807
|
+
readonly optional: true;
|
|
1808
|
+
readonly base: BigIntSchema<ComputeInput<bigint, {
|
|
1809
|
+
nullable: true;
|
|
1810
|
+
array: State["array"];
|
|
1811
|
+
}>, ComputeOutput<bigint, {
|
|
1812
|
+
nullable: true;
|
|
1813
|
+
array: State["array"];
|
|
1814
|
+
}>>;
|
|
1815
|
+
}>>;
|
|
1816
|
+
array(): BigIntField<UpdateState$1<this["~"]["state"], State & {
|
|
1817
|
+
readonly array: true;
|
|
1818
|
+
readonly base: BigIntSchema<ComputeInput<bigint, {
|
|
1819
|
+
nullable: State["nullable"];
|
|
1820
|
+
array: true;
|
|
1821
|
+
}>, ComputeOutput<bigint, {
|
|
1822
|
+
nullable: State["nullable"];
|
|
1823
|
+
array: true;
|
|
1824
|
+
}>>;
|
|
1825
|
+
}>>;
|
|
1826
|
+
id(): BigIntField<UpdateState$1<this["~"]["state"], {
|
|
1827
|
+
readonly isId: true;
|
|
1828
|
+
readonly isUnique: true;
|
|
1829
|
+
}>>;
|
|
1830
|
+
unique(): BigIntField<UpdateState$1<this["~"]["state"], {
|
|
1831
|
+
readonly isUnique: true;
|
|
1832
|
+
}>>;
|
|
1833
|
+
default<V$1 extends DefaultValueInput<State>>(value: V$1): BigIntField<UpdateState$1<this["~"]["state"], {
|
|
1834
|
+
readonly hasDefault: true;
|
|
1835
|
+
readonly default: V$1;
|
|
1836
|
+
readonly optional: true;
|
|
1837
|
+
}>>;
|
|
1838
|
+
schema<S extends StandardSchemaOf<bigint>>(schema: S): BigIntField<UpdateState$1<this["~"]["state"], {
|
|
1839
|
+
readonly schema: S;
|
|
1840
|
+
readonly base: BigIntSchema<ComputeInput<bigint, {
|
|
1841
|
+
nullable: State["nullable"];
|
|
1842
|
+
array: State["array"];
|
|
1843
|
+
schema: S;
|
|
1844
|
+
}>, ComputeOutput<bigint, {
|
|
1845
|
+
nullable: State["nullable"];
|
|
1846
|
+
array: State["array"];
|
|
1847
|
+
schema: S;
|
|
1848
|
+
}>>;
|
|
1849
|
+
}>>;
|
|
1850
|
+
map(columnName: string): BigIntField<UpdateState$1<this["~"]["state"], {
|
|
1851
|
+
readonly columnName: string;
|
|
1852
|
+
}>>;
|
|
1853
|
+
increment(): BigIntField<UpdateState$1<this["~"]["state"], {
|
|
1854
|
+
readonly hasDefault: true;
|
|
1855
|
+
readonly autoGenerate: "increment";
|
|
1856
|
+
readonly default: 0n;
|
|
1857
|
+
readonly optional: true;
|
|
1858
|
+
}>>;
|
|
1859
|
+
get ["~"](): {
|
|
1860
|
+
state: State;
|
|
1861
|
+
schemas: BigIntSchemas<State>;
|
|
1862
|
+
nativeType: NativeType | undefined;
|
|
1863
|
+
};
|
|
1864
|
+
}
|
|
1865
|
+
//#endregion
|
|
1866
|
+
//#region src/schema/fields/base.d.ts
|
|
1867
|
+
/**
|
|
1868
|
+
* Union type of all concrete field classes with any state.
|
|
1869
|
+
* This is the canonical "Field" type used throughout the codebase.
|
|
1870
|
+
*
|
|
1871
|
+
* Benefits over an interface:
|
|
1872
|
+
* - No need to maintain a separate interface in sync with classes
|
|
1873
|
+
* - TypeScript infers exact shape from actual implementations
|
|
1874
|
+
* - Adding new properties (like nativeType) automatically works
|
|
1875
|
+
*/
|
|
1876
|
+
type Field = StringField<FieldState<"string">> | IntField<FieldState<"int">> | FloatField<FieldState<"float">> | DecimalField<FieldState<"decimal">> | BooleanField<FieldState<"boolean">> | DateTimeField<FieldState<"datetime">> | DateField<FieldState<"date">> | TimeField<FieldState<"time">> | BigIntField<FieldState<"bigint">> | JsonField<FieldState<"json">> | VectorField<FieldState<"vector">> | BlobField<FieldState<"blob">> | PointField<FieldState<"point">> | EnumField<FieldState<"enum">>;
|
|
1877
|
+
//#endregion
|
|
1878
|
+
//#region src/schema/model/model.d.ts
|
|
1879
|
+
interface ModelState {
|
|
1880
|
+
fields: FieldRecord;
|
|
1881
|
+
compoundId: Record<string, ObjectSchema<Record<string, VibSchema>>> | undefined;
|
|
1882
|
+
compoundUniques: Record<string, ObjectSchema<Record<string, VibSchema>>> | undefined;
|
|
1883
|
+
tableName: string | undefined;
|
|
1884
|
+
indexes: IndexDefinition[];
|
|
1885
|
+
omit: Record<string, true> | undefined;
|
|
1886
|
+
scalars: Record<string, Field>;
|
|
1887
|
+
relations: Record<string, AnyRelation>;
|
|
1888
|
+
uniques: Record<string, Field>;
|
|
1889
|
+
}
|
|
1890
|
+
/**
|
|
1891
|
+
* Internal accessor return type for Model["~"]
|
|
1892
|
+
* Explicit type annotation to avoid TS7056 (type too complex to serialize)
|
|
1893
|
+
*/
|
|
1894
|
+
interface ModelInternal<T extends ModelState> {
|
|
1895
|
+
state: T;
|
|
1896
|
+
schemas: ModelSchemas<T>;
|
|
1897
|
+
names: SchemaNames;
|
|
1898
|
+
nameRegistry: {
|
|
1899
|
+
fields: Map<string, SchemaNames>;
|
|
1900
|
+
relations: Map<string, SchemaNames>;
|
|
1901
|
+
};
|
|
1902
|
+
getFieldName: (key: string) => HydratedSchemaNames;
|
|
1903
|
+
getRelationName: (key: string) => HydratedSchemaNames;
|
|
1904
|
+
/** Cached scalar field names (computed once on first access) */
|
|
1905
|
+
scalarFieldNames: string[];
|
|
1906
|
+
/** Cached scalar field Set for O(1) lookup (computed once on first access) */
|
|
1907
|
+
scalarFieldSet: Set<string>;
|
|
1908
|
+
/** Cached relation names (computed once on first access) */
|
|
1909
|
+
relationNames: string[];
|
|
1910
|
+
/** Cached relation Set for O(1) lookup (computed once on first access) */
|
|
1911
|
+
relationSet: Set<string>;
|
|
1912
|
+
}
|
|
1913
|
+
type IndexType = "btree" | "hash" | "gin" | "gist";
|
|
1914
|
+
interface IndexOptions {
|
|
1915
|
+
name?: string;
|
|
1916
|
+
unique?: boolean;
|
|
1917
|
+
type?: IndexType;
|
|
1918
|
+
where?: string;
|
|
1919
|
+
}
|
|
1920
|
+
interface IndexDefinition<Keys extends string[] = string[], O extends IndexOptions = IndexOptions> {
|
|
1921
|
+
fields: Keys;
|
|
1922
|
+
options: O;
|
|
1923
|
+
}
|
|
1924
|
+
type UpdateIndexDefinition<State extends ModelState, Index extends IndexDefinition> = [...State["indexes"], Index];
|
|
1925
|
+
type UpdateState<State extends ModelState, Update extends Partial<ModelState>> = Omit<State, keyof Update> & Update;
|
|
1926
|
+
declare class Model<State extends ModelState> {
|
|
1927
|
+
private _names;
|
|
1928
|
+
private _nameRegistry;
|
|
1929
|
+
private readonly state;
|
|
1930
|
+
private _schemas;
|
|
1931
|
+
private _scalarFieldNames;
|
|
1932
|
+
private _scalarFieldSet;
|
|
1933
|
+
private _relationNames;
|
|
1934
|
+
private _relationSet;
|
|
1935
|
+
constructor(state: State);
|
|
1936
|
+
/**
|
|
1937
|
+
* Maps the model to a specific database table name
|
|
1938
|
+
*/
|
|
1939
|
+
map<Name extends string>(tableName: Name): Model<UpdateState<State, {
|
|
1940
|
+
tableName: Name;
|
|
1941
|
+
}>>;
|
|
1942
|
+
omit<OmitItems extends Record<string, true>>(items: OmitItems): Model<UpdateState<State, {
|
|
1943
|
+
omit: OmitItems;
|
|
1944
|
+
}>>;
|
|
1945
|
+
index<const Keys extends StringKeyOf<State["scalars"]>[], O extends IndexOptions = IndexOptions>(fields: Keys, options?: O): Model<UpdateState<State, {
|
|
1946
|
+
indexes: UpdateIndexDefinition<State, {
|
|
1947
|
+
fields: any;
|
|
1948
|
+
options: any;
|
|
1949
|
+
}>;
|
|
1950
|
+
}>>;
|
|
1951
|
+
id<const Keys extends StringKeyOf<State["scalars"]>[], Name extends string | undefined = undefined>(fields: Keys, options?: {
|
|
1952
|
+
name?: Name;
|
|
1953
|
+
}): Model<UpdateState<State, {
|
|
1954
|
+
compoundId: { [K in Name extends undefined ? NameFromKeys<Keys> : Name]: ObjectSchema<{ [K2 in Keys[number]]: State["scalars"][K2]["~"]["schemas"]["base"] }> };
|
|
1955
|
+
}>>;
|
|
1956
|
+
unique<const Keys extends StringKeyOf<State["scalars"]>[], Name extends string | undefined = undefined>(fields: Keys, options?: {
|
|
1957
|
+
name?: Name;
|
|
1958
|
+
}): Model<UpdateState<State, {
|
|
1959
|
+
compoundUniques: { [K in Name extends undefined ? NameFromKeys<Keys> : Name]: ObjectSchema<{ [K2 in Keys[number]]: State["scalars"][K2]["~"]["schemas"]["base"] }> };
|
|
1960
|
+
}>>;
|
|
1961
|
+
extends<ETFields extends FieldRecord>(fields: ETFields): Model<UpdateState<State, {
|
|
1962
|
+
fields: State["fields"] & ETFields;
|
|
1963
|
+
scalars: ScalarFields<State["fields"] & ETFields>;
|
|
1964
|
+
relations: RelationFields<State["fields"] & ETFields>;
|
|
1965
|
+
uniques: UniqueFields<State["fields"] & ETFields>;
|
|
1966
|
+
}>>;
|
|
1967
|
+
get "~"(): ModelInternal<State>;
|
|
1968
|
+
}
|
|
1969
|
+
type AnyModel = Model<any>;
|
|
1970
|
+
//#endregion
|
|
1971
|
+
//#region src/schema/model/schemas/core/create.d.ts
|
|
1972
|
+
/**
|
|
1973
|
+
* Build scalar create schema - all scalar fields for create input
|
|
1974
|
+
*/
|
|
1975
|
+
type ScalarCreateSchema<T extends ModelState> = V.FromObject<T["scalars"], "~.schemas.create", {
|
|
1976
|
+
atLeast: RequiredFieldKeys<T["fields"]>[];
|
|
1977
|
+
}>;
|
|
1978
|
+
/**
|
|
1979
|
+
* Build relation create schema - combines all relation create inputs
|
|
1980
|
+
*/
|
|
1981
|
+
type RelationCreateSchema<T extends ModelState> = V.FromObject<T["relations"], "~.schemas.create">;
|
|
1982
|
+
/**
|
|
1983
|
+
* Build full create schema - scalar + relation creates
|
|
1984
|
+
*
|
|
1985
|
+
* FK fields (like authorId) are optional because they can be derived from
|
|
1986
|
+
* nested relation operations (connect, create).
|
|
1987
|
+
*/
|
|
1988
|
+
type CreateSchema<T extends ModelState> = V.Object<V.FromObject<T["scalars"], "~.schemas.create">["entries"] & V.FromObject<T["relations"], "~.schemas.create">["entries"], {
|
|
1989
|
+
atLeast: RequiredFieldKeys<T["fields"]>[];
|
|
1990
|
+
}>;
|
|
1991
|
+
//#endregion
|
|
1992
|
+
//#region src/schema/model/schemas/core/filter.d.ts
|
|
1993
|
+
type ScalarFilterSchema<T extends ModelState> = V.FromObject<T["scalars"], "~.schemas.filter">;
|
|
1994
|
+
type UniqueFilterSchema<T extends ModelState> = V.FromObject<T["uniques"], "~.schemas.base">;
|
|
1995
|
+
type RelationFilterSchema<T extends ModelState> = V.FromObject<T["relations"], "~.schemas.filter">;
|
|
1996
|
+
/**
|
|
1997
|
+
* Build compound constraint filter schema
|
|
1998
|
+
* Creates an object schema where each compound key maps to an optional object of field base schemas
|
|
1999
|
+
*/
|
|
2000
|
+
type CompoundConstraintFilterSchema<T extends ModelState> = T["compoundId"] extends Record<string, Record<string, Field>> ? T["compoundUniques"] extends Record<string, Record<string, Field>> ? ObjectSchema<T["compoundId"] & T["compoundUniques"]> : ObjectSchema<T["compoundId"]> : T["compoundUniques"] extends Record<string, Record<string, Field>> ? ObjectSchema<T["compoundUniques"]> : ObjectSchema<{}, undefined>;
|
|
2001
|
+
type CompoundIdFilterSchema<T extends ModelState> = V.Object<T["compoundId"]>;
|
|
2002
|
+
//#endregion
|
|
2003
|
+
//#region src/schema/model/schemas/core/orderby.d.ts
|
|
2004
|
+
type OrderEnum = V.Enum<["asc", "desc"]>;
|
|
2005
|
+
type SortOrderSchema = V.Union<readonly [OrderEnum, V.Object<{
|
|
2006
|
+
sort: OrderEnum;
|
|
2007
|
+
nulls: V.Enum<["first", "last"]>;
|
|
2008
|
+
}, {
|
|
2009
|
+
partial: false;
|
|
2010
|
+
}>]>;
|
|
2011
|
+
/**
|
|
2012
|
+
* Build orderBy schema - sort direction for each scalar field and nested relation ordering
|
|
2013
|
+
*/
|
|
2014
|
+
type OrderBySchema<T extends ModelState> = V.Object<V.FromKeys<StringKeyOf<T["scalars"]>[], SortOrderSchema>["entries"] & V.FromObject<T["relations"], "~.schemas.orderBy">["entries"]>;
|
|
2015
|
+
//#endregion
|
|
2016
|
+
//#region src/schema/model/schemas/core/select.d.ts
|
|
2017
|
+
/**
|
|
2018
|
+
* Build select schema - boolean selection for each scalar field, nested select for relations
|
|
2019
|
+
*/
|
|
2020
|
+
type SelectSchema<T extends ModelState> = V.Object<V.FromKeys<StringKeyOf<T["scalars"]>[], V.Boolean>["entries"] & V.FromObject<T["relations"], "~.schemas.select">["entries"] & {
|
|
2021
|
+
_count: V.Object<{
|
|
2022
|
+
select: V.FromObject<T["relations"], "~.schemas.countFilter", {
|
|
2023
|
+
optional: true;
|
|
2024
|
+
}>;
|
|
2025
|
+
}, {
|
|
2026
|
+
optional: true;
|
|
2027
|
+
}>;
|
|
2028
|
+
}>;
|
|
2029
|
+
/**
|
|
2030
|
+
* Build include schema - nested include for each relation
|
|
2031
|
+
*/
|
|
2032
|
+
type IncludeSchema<T extends ModelState> = V.FromObject<T["relations"], "~.schemas.include", {
|
|
2033
|
+
optional: true;
|
|
2034
|
+
}>;
|
|
2035
|
+
//#endregion
|
|
2036
|
+
//#region src/schema/model/schemas/core/update.d.ts
|
|
2037
|
+
/**
|
|
2038
|
+
* Build scalar update schema - all scalar fields for update input (all optional)
|
|
2039
|
+
*/
|
|
2040
|
+
type ScalarUpdateSchema<T extends ModelState> = V.FromObject<T["scalars"], "~.schemas.update">;
|
|
2041
|
+
/**
|
|
2042
|
+
* Build relation update schema - combines all relation update inputs
|
|
2043
|
+
*/
|
|
2044
|
+
type RelationUpdateSchema<T extends ModelState> = V.FromObject<T["relations"], "~.schemas.update">;
|
|
2045
|
+
/**
|
|
2046
|
+
* Build full update schema - scalar + relation updates (all optional)
|
|
2047
|
+
*/
|
|
2048
|
+
type UpdateSchema<T extends ModelState> = V.Object<ScalarUpdateSchema<T>["entries"] & RelationUpdateSchema<T>["entries"]>;
|
|
2049
|
+
//#endregion
|
|
2050
|
+
//#region src/schema/model/schemas/core/where.d.ts
|
|
2051
|
+
/**
|
|
2052
|
+
* Build full where schema - scalar + relation filters + AND/OR/NOT
|
|
2053
|
+
* Uses thunks for recursive self-references
|
|
2054
|
+
*/
|
|
2055
|
+
type WhereSchemaBase<T extends ModelState> = V.Object<V.FromObject<T["scalars"], "~.schemas.filter">["entries"] & V.FromObject<T["relations"], "~.schemas.filter">["entries"]>;
|
|
2056
|
+
type WhereSchema<T extends ModelState> = V.Object<{
|
|
2057
|
+
AND: () => V.Optional<V.Union<readonly [WhereSchema<T>, V.Array<WhereSchema<T>>]>>;
|
|
2058
|
+
OR: () => V.Optional<V.Array<WhereSchema<T>>>;
|
|
2059
|
+
NOT: () => V.Optional<V.Union<readonly [WhereSchema<T>, V.Array<WhereSchema<T>>]>>;
|
|
2060
|
+
} & WhereSchemaBase<T>["entries"]>;
|
|
2061
|
+
/**
|
|
2062
|
+
* Build whereUnique schema - unique fields + compound constraints
|
|
2063
|
+
* Combines single-field uniques with compound ID and compound uniques
|
|
2064
|
+
*/
|
|
2065
|
+
type WhereUniqueSchema<T extends ModelState> = V.Object<V.FromObject<T["uniques"], "~.schemas.base">["entries"] & CompoundConstraintFilterSchema<T>["entries"]>;
|
|
2066
|
+
//#endregion
|
|
2067
|
+
//#region src/schema/model/schemas/core/index.d.ts
|
|
2068
|
+
/**
|
|
2069
|
+
* Type representing all core schemas for a model.
|
|
2070
|
+
* Used by args factories to reference schema types.
|
|
2071
|
+
*/
|
|
2072
|
+
type CoreSchemas<T extends ModelState> = {
|
|
2073
|
+
scalarFilter: ScalarFilterSchema<T>;
|
|
2074
|
+
uniqueFilter: UniqueFilterSchema<T>;
|
|
2075
|
+
relationFilter: RelationFilterSchema<T>;
|
|
2076
|
+
compoundIdFilter: CompoundIdFilterSchema<T>;
|
|
2077
|
+
compoundConstraintFilter: CompoundConstraintFilterSchema<T>;
|
|
2078
|
+
scalarCreate: ScalarCreateSchema<T>;
|
|
2079
|
+
relationCreate: RelationCreateSchema<T>;
|
|
2080
|
+
scalarUpdate: ScalarUpdateSchema<T>;
|
|
2081
|
+
relationUpdate: RelationUpdateSchema<T>;
|
|
2082
|
+
where: WhereSchema<T>;
|
|
2083
|
+
whereUnique: WhereUniqueSchema<T>;
|
|
2084
|
+
create: CreateSchema<T>;
|
|
2085
|
+
update: UpdateSchema<T>;
|
|
2086
|
+
select: SelectSchema<T>;
|
|
2087
|
+
include: IncludeSchema<T>;
|
|
2088
|
+
orderBy: OrderBySchema<T>;
|
|
2089
|
+
};
|
|
2090
|
+
//#endregion
|
|
2091
|
+
//#region src/schema/model/schemas/args/aggregate.d.ts
|
|
2092
|
+
/**
|
|
2093
|
+
* Build aggregate field schemas (for _count, _avg, _sum, _min, _max)
|
|
2094
|
+
* Following Prisma's API:
|
|
2095
|
+
* - _count: can be `true` or object with `_all` + all scalar field names
|
|
2096
|
+
* - _avg, _sum: only numeric fields (int, float, decimal, bigint)
|
|
2097
|
+
* - _min, _max: all comparable types (all scalars)
|
|
2098
|
+
*/
|
|
2099
|
+
type OptionalBoolean = V.Boolean<{
|
|
2100
|
+
optional: true;
|
|
2101
|
+
}>;
|
|
2102
|
+
/**
|
|
2103
|
+
* Count keys include "_all" plus all scalar field names
|
|
2104
|
+
*/
|
|
2105
|
+
type CountFieldKeys<T extends ModelState> = "_all" | ScalarFieldKeys<T["scalars"]>;
|
|
2106
|
+
/**
|
|
2107
|
+
* Aggregate field schemas with proper typing
|
|
2108
|
+
*/
|
|
2109
|
+
type AggregateFieldSchemas<T extends ModelState> = {
|
|
2110
|
+
/** Count can include _all and any scalar field */
|
|
2111
|
+
count: V.FromKeys<CountFieldKeys<T>[], OptionalBoolean>;
|
|
2112
|
+
/** Avg only works on numeric fields */
|
|
2113
|
+
avg: V.FromKeys<NumericFieldKeys<T["scalars"]>[], OptionalBoolean>;
|
|
2114
|
+
/** Sum only works on numeric fields */
|
|
2115
|
+
sum: V.FromKeys<NumericFieldKeys<T["scalars"]>[], OptionalBoolean>;
|
|
2116
|
+
/** Min works on all comparable types (all scalars) */
|
|
2117
|
+
min: V.FromKeys<ScalarFieldKeys<T["scalars"]>[], OptionalBoolean>;
|
|
2118
|
+
/** Max works on all comparable types (all scalars) */
|
|
2119
|
+
max: V.FromKeys<ScalarFieldKeys<T["scalars"]>[], OptionalBoolean>;
|
|
2120
|
+
};
|
|
2121
|
+
/**
|
|
2122
|
+
* Count args following Prisma's API:
|
|
2123
|
+
* - where: filter records before counting
|
|
2124
|
+
* - cursor: cursor-based pagination
|
|
2125
|
+
* - take: limit number of records
|
|
2126
|
+
* - skip: skip number of records
|
|
2127
|
+
* - select: which fields to count (including _all for total count)
|
|
2128
|
+
*/
|
|
2129
|
+
type CountArgs<T extends ModelState> = V.Object<{
|
|
2130
|
+
where: CoreSchemas<T>["where"];
|
|
2131
|
+
cursor: CoreSchemas<T>["whereUnique"];
|
|
2132
|
+
take: V.Number;
|
|
2133
|
+
skip: V.Number;
|
|
2134
|
+
select: AggregateFieldSchemas<T>["count"];
|
|
2135
|
+
}, {
|
|
2136
|
+
optional: true;
|
|
2137
|
+
}>;
|
|
2138
|
+
/**
|
|
2139
|
+
* Aggregate args: { where?, orderBy?, cursor?, take?, skip?, _count?, _avg?, _sum?, _min?, _max? }
|
|
2140
|
+
*/
|
|
2141
|
+
type AggregateArgs<T extends ModelState> = V.Object<{
|
|
2142
|
+
where: CoreSchemas<T>["where"];
|
|
2143
|
+
orderBy: V.Union<readonly [CoreSchemas<T>["orderBy"], V.Array<CoreSchemas<T>["orderBy"]>]>;
|
|
2144
|
+
cursor: CoreSchemas<T>["whereUnique"];
|
|
2145
|
+
take: V.Number;
|
|
2146
|
+
skip: V.Number;
|
|
2147
|
+
_count: V.Union<readonly [V.Literal<true>, AggregateFieldSchemas<T>["count"]]>;
|
|
2148
|
+
_avg: AggregateFieldSchemas<T>["avg"];
|
|
2149
|
+
_sum: AggregateFieldSchemas<T>["sum"];
|
|
2150
|
+
_min: AggregateFieldSchemas<T>["min"];
|
|
2151
|
+
_max: AggregateFieldSchemas<T>["max"];
|
|
2152
|
+
}>;
|
|
2153
|
+
/**
|
|
2154
|
+
* Having schema for groupBy follows Prisma's pattern.
|
|
2155
|
+
*
|
|
2156
|
+
* Allows filtering on:
|
|
2157
|
+
* - Direct field filters (for fields in `by`): { country: "USA" } / { country: { in: ["USA", "UK"] } }
|
|
2158
|
+
* - Aggregate values: { profileViews: { _avg: { gt: 100 } }, id: { _count: { gte: 5 } } }
|
|
2159
|
+
*
|
|
2160
|
+
* For each scalar field key, we accept either:
|
|
2161
|
+
* - the field's regular filter schema (same as WHERE), OR
|
|
2162
|
+
* - an aggregate filter object with _count/_avg/_sum/_min/_max.
|
|
2163
|
+
*/
|
|
2164
|
+
type NumericFilterOps = V.Object<{
|
|
2165
|
+
equals: V.Number;
|
|
2166
|
+
gt: V.Number;
|
|
2167
|
+
gte: V.Number;
|
|
2168
|
+
lt: V.Number;
|
|
2169
|
+
lte: V.Number;
|
|
2170
|
+
not: V.Number;
|
|
2171
|
+
}, {
|
|
2172
|
+
optional: true;
|
|
2173
|
+
}>;
|
|
2174
|
+
type HavingAggregateFieldSchema = V.Object<{
|
|
2175
|
+
_count: NumericFilterOps;
|
|
2176
|
+
_avg: NumericFilterOps;
|
|
2177
|
+
_sum: NumericFilterOps;
|
|
2178
|
+
_min: NumericFilterOps;
|
|
2179
|
+
_max: NumericFilterOps;
|
|
2180
|
+
}, {
|
|
2181
|
+
optional: true;
|
|
2182
|
+
}>;
|
|
2183
|
+
type ScalarFilterEntries<T extends ModelState> = V.FromObject<T["scalars"], "~.schemas.filter">["entries"];
|
|
2184
|
+
type HavingSchemaEntries<T extends ModelState> = { [K in keyof ScalarFilterEntries<T>]: V.Union<readonly [HavingAggregateFieldSchema, ScalarFilterEntries<T>[K]]> };
|
|
2185
|
+
type HavingSchema<T extends ModelState> = V.Object<HavingSchemaEntries<T>, {
|
|
2186
|
+
optional: true;
|
|
2187
|
+
}>;
|
|
2188
|
+
/**
|
|
2189
|
+
* GroupBy args: { by, where?, having?, orderBy?, take?, skip?, _count?, _avg?, _sum?, _min?, _max? }
|
|
2190
|
+
*/
|
|
2191
|
+
type EnumOfFields<T extends ModelState> = V.Enum<StringKeyOf<T["fields"]>[]>;
|
|
2192
|
+
type GroupByArgs<T extends ModelState> = V.Object<{
|
|
2193
|
+
by: V.Union<readonly [EnumOfFields<T>, V.Array<EnumOfFields<T>>]>;
|
|
2194
|
+
where: CoreSchemas<T>["where"];
|
|
2195
|
+
having: HavingSchema<T>;
|
|
2196
|
+
orderBy: V.Union<readonly [CoreSchemas<T>["orderBy"], V.Array<CoreSchemas<T>["orderBy"]>]>;
|
|
2197
|
+
take: V.Number;
|
|
2198
|
+
skip: V.Number;
|
|
2199
|
+
_count: V.Union<readonly [V.Literal<true>, AggregateFieldSchemas<T>["count"]]>;
|
|
2200
|
+
_avg: AggregateFieldSchemas<T>["avg"];
|
|
2201
|
+
_sum: AggregateFieldSchemas<T>["sum"];
|
|
2202
|
+
_min: AggregateFieldSchemas<T>["min"];
|
|
2203
|
+
_max: AggregateFieldSchemas<T>["max"];
|
|
2204
|
+
}, {
|
|
2205
|
+
atLeast: ["by"];
|
|
2206
|
+
}>;
|
|
2207
|
+
//#endregion
|
|
2208
|
+
//#region src/schema/model/schemas/args/find.d.ts
|
|
2209
|
+
/**
|
|
2210
|
+
* FindUnique args: { where: whereUnique, select?, include? }
|
|
2211
|
+
*/
|
|
2212
|
+
type FindUniqueArgs<T extends ModelState> = V.Object<{
|
|
2213
|
+
where: CoreSchemas<T>["whereUnique"];
|
|
2214
|
+
select: CoreSchemas<T>["select"];
|
|
2215
|
+
include: CoreSchemas<T>["include"];
|
|
2216
|
+
}, {
|
|
2217
|
+
atLeast: ["where"];
|
|
2218
|
+
}>;
|
|
2219
|
+
/**
|
|
2220
|
+
* FindFirst args: { where?, orderBy?, take?, skip?, cursor?, select?, include? }
|
|
2221
|
+
*/
|
|
2222
|
+
type FindFirstArgs<T extends ModelState> = V.Object<{
|
|
2223
|
+
where: CoreSchemas<T>["where"];
|
|
2224
|
+
orderBy: V.Union<readonly [CoreSchemas<T>["orderBy"], V.Array<CoreSchemas<T>["orderBy"]>]>;
|
|
2225
|
+
take: V.Number;
|
|
2226
|
+
skip: V.Number;
|
|
2227
|
+
cursor: CoreSchemas<T>["whereUnique"];
|
|
2228
|
+
select: CoreSchemas<T>["select"];
|
|
2229
|
+
include: CoreSchemas<T>["include"];
|
|
2230
|
+
}, {
|
|
2231
|
+
optional: true;
|
|
2232
|
+
}>;
|
|
2233
|
+
/**
|
|
2234
|
+
* FindMany args: { where?, orderBy?, take?, skip?, cursor?, select?, include?, distinct? }
|
|
2235
|
+
*/
|
|
2236
|
+
type FindManyArgs<T extends ModelState> = V.Object<{
|
|
2237
|
+
where: CoreSchemas<T>["where"];
|
|
2238
|
+
orderBy: V.Union<readonly [CoreSchemas<T>["orderBy"], V.Array<CoreSchemas<T>["orderBy"]>]>;
|
|
2239
|
+
take: V.Number;
|
|
2240
|
+
skip: V.Number;
|
|
2241
|
+
cursor: CoreSchemas<T>["whereUnique"];
|
|
2242
|
+
select: CoreSchemas<T>["select"];
|
|
2243
|
+
include: CoreSchemas<T>["include"];
|
|
2244
|
+
distinct: V.Enum<StringKeyOf<T["scalars"]>[], {
|
|
2245
|
+
array: true;
|
|
2246
|
+
}>;
|
|
2247
|
+
}, {
|
|
2248
|
+
optional: true;
|
|
2249
|
+
}>;
|
|
2250
|
+
//#endregion
|
|
2251
|
+
//#region src/cache/schema.d.ts
|
|
2252
|
+
type CacheInvalidationSchemaEntries = {
|
|
2253
|
+
invalidate: V.String<{
|
|
2254
|
+
array: true;
|
|
2255
|
+
optional: true;
|
|
2256
|
+
}>;
|
|
2257
|
+
autoInvalidate: V.Boolean<{
|
|
2258
|
+
optional: true;
|
|
2259
|
+
}>;
|
|
2260
|
+
};
|
|
2261
|
+
type CacheInvalidationSchema = V.Object<CacheInvalidationSchemaEntries, {
|
|
2262
|
+
optional: true;
|
|
2263
|
+
}>;
|
|
2264
|
+
declare const cacheInvalidationSchema: ObjectSchema<{
|
|
2265
|
+
/**
|
|
2266
|
+
* Specific keys to clear from cache
|
|
2267
|
+
* Can end with a * to invalidate all keys starting with the given prefix
|
|
2268
|
+
*/
|
|
2269
|
+
invalidate: StringSchema<string[] | undefined, string[]>;
|
|
2270
|
+
/**
|
|
2271
|
+
* Automatically invalidate all cache entries for this model after mutation
|
|
2272
|
+
* @default false
|
|
2273
|
+
*/
|
|
2274
|
+
autoInvalidate: BooleanSchema<boolean | undefined, boolean>;
|
|
2275
|
+
}, {
|
|
2276
|
+
readonly optional: true;
|
|
2277
|
+
readonly default: {
|
|
2278
|
+
readonly autoInvalidate: false;
|
|
2279
|
+
};
|
|
2280
|
+
}, Partial<InferInputShape<{
|
|
2281
|
+
/**
|
|
2282
|
+
* Specific keys to clear from cache
|
|
2283
|
+
* Can end with a * to invalidate all keys starting with the given prefix
|
|
2284
|
+
*/
|
|
2285
|
+
invalidate: StringSchema<string[] | undefined, string[]>;
|
|
2286
|
+
/**
|
|
2287
|
+
* Automatically invalidate all cache entries for this model after mutation
|
|
2288
|
+
* @default false
|
|
2289
|
+
*/
|
|
2290
|
+
autoInvalidate: BooleanSchema<boolean | undefined, boolean>;
|
|
2291
|
+
}>> | undefined, InferOutputShape<{
|
|
2292
|
+
/**
|
|
2293
|
+
* Specific keys to clear from cache
|
|
2294
|
+
* Can end with a * to invalidate all keys starting with the given prefix
|
|
2295
|
+
*/
|
|
2296
|
+
invalidate: StringSchema<string[] | undefined, string[]>;
|
|
2297
|
+
/**
|
|
2298
|
+
* Automatically invalidate all cache entries for this model after mutation
|
|
2299
|
+
* @default false
|
|
2300
|
+
*/
|
|
2301
|
+
autoInvalidate: BooleanSchema<boolean | undefined, boolean>;
|
|
2302
|
+
}>>;
|
|
2303
|
+
/**
|
|
2304
|
+
* Input type for cache invalidation options (inferred from schema)
|
|
2305
|
+
*/
|
|
2306
|
+
type CacheInvalidationOptions = CacheInvalidationSchema[" vibInferred"]["0"];
|
|
2307
|
+
/**
|
|
2308
|
+
* Default TTL: 5 minutes (in milliseconds)
|
|
2309
|
+
*/
|
|
2310
|
+
declare const DEFAULT_CACHE_TTL: number;
|
|
2311
|
+
type WithCacheSchemaEntries = {
|
|
2312
|
+
ttl: V.Optional<V.Union<[V.String, V.Number]>>;
|
|
2313
|
+
swr: V.Optional<V.Union<[V.Boolean, V.String, V.Number]>>;
|
|
2314
|
+
key: V.String<{
|
|
2315
|
+
optional: true;
|
|
2316
|
+
}>;
|
|
2317
|
+
bypass: V.Boolean<{
|
|
2318
|
+
optional: true;
|
|
2319
|
+
}>;
|
|
2320
|
+
};
|
|
2321
|
+
type WithCacheSchema = V.Object<WithCacheSchemaEntries, {
|
|
2322
|
+
optional: true;
|
|
2323
|
+
}>;
|
|
2324
|
+
declare const withCacheSchema: ObjectSchema<{
|
|
2325
|
+
/**
|
|
2326
|
+
* Time to live for cache entries
|
|
2327
|
+
* Can be a number (milliseconds) or a string like "1 hour", "20 seconds"
|
|
2328
|
+
* @default 300000 (5 minutes)
|
|
2329
|
+
*/
|
|
2330
|
+
ttl: TransformSchema<string | number | undefined, number> & {
|
|
2331
|
+
wrapped: OptionalSchema<UnionSchema<readonly [StringSchema<string, string>, NumberSchema<number, number>], string | number, string | number>, number, string | number | undefined, string | number>;
|
|
2332
|
+
};
|
|
2333
|
+
/**
|
|
2334
|
+
* Enable stale-while-revalidate pattern
|
|
2335
|
+
* When true, returns stale data immediately and revalidates in background
|
|
2336
|
+
*
|
|
2337
|
+
* The value represents the "stale window" - how long data can be served stale.
|
|
2338
|
+
* Storage TTL is automatically calculated as `ttl + staleWindow`.
|
|
2339
|
+
*
|
|
2340
|
+
* Can be a boolean or a duration value (number in ms or string like "1 hour")
|
|
2341
|
+
* - true: stale window = ttl (storage TTL = 2x ttl)
|
|
2342
|
+
* - false/undefined: SWR disabled
|
|
2343
|
+
* - number/string: custom stale window duration (storage TTL = ttl + swr)
|
|
2344
|
+
* @default false
|
|
2345
|
+
*/
|
|
2346
|
+
swr: TransformSchema<string | number | boolean | undefined, number | boolean | undefined> & {
|
|
2347
|
+
wrapped: OptionalSchema<UnionSchema<readonly [BooleanSchema<boolean, boolean>, StringSchema<string, string>, NumberSchema<number, number>], string | number | boolean, string | number | boolean>, undefined, string | number | boolean | undefined, string | number | boolean | undefined>;
|
|
2348
|
+
};
|
|
2349
|
+
/**
|
|
2350
|
+
* Custom cache key override
|
|
2351
|
+
* If not provided, key is generated from model, operation, and args
|
|
2352
|
+
*/
|
|
2353
|
+
key: StringSchema<string | undefined, string>;
|
|
2354
|
+
/**
|
|
2355
|
+
* Bypass cache read and force fresh data
|
|
2356
|
+
* Still writes result to cache for subsequent requests
|
|
2357
|
+
* @default false
|
|
2358
|
+
*/
|
|
2359
|
+
bypass: BooleanSchema<boolean | undefined, boolean>;
|
|
2360
|
+
}, {
|
|
2361
|
+
readonly optional: true;
|
|
2362
|
+
readonly default: {
|
|
2363
|
+
readonly ttl: number;
|
|
2364
|
+
readonly swr: false;
|
|
2365
|
+
readonly bypass: false;
|
|
2366
|
+
};
|
|
2367
|
+
}, Partial<InferInputShape<{
|
|
2368
|
+
/**
|
|
2369
|
+
* Time to live for cache entries
|
|
2370
|
+
* Can be a number (milliseconds) or a string like "1 hour", "20 seconds"
|
|
2371
|
+
* @default 300000 (5 minutes)
|
|
2372
|
+
*/
|
|
2373
|
+
ttl: TransformSchema<string | number | undefined, number> & {
|
|
2374
|
+
wrapped: OptionalSchema<UnionSchema<readonly [StringSchema<string, string>, NumberSchema<number, number>], string | number, string | number>, number, string | number | undefined, string | number>;
|
|
2375
|
+
};
|
|
2376
|
+
/**
|
|
2377
|
+
* Enable stale-while-revalidate pattern
|
|
2378
|
+
* When true, returns stale data immediately and revalidates in background
|
|
2379
|
+
*
|
|
2380
|
+
* The value represents the "stale window" - how long data can be served stale.
|
|
2381
|
+
* Storage TTL is automatically calculated as `ttl + staleWindow`.
|
|
2382
|
+
*
|
|
2383
|
+
* Can be a boolean or a duration value (number in ms or string like "1 hour")
|
|
2384
|
+
* - true: stale window = ttl (storage TTL = 2x ttl)
|
|
2385
|
+
* - false/undefined: SWR disabled
|
|
2386
|
+
* - number/string: custom stale window duration (storage TTL = ttl + swr)
|
|
2387
|
+
* @default false
|
|
2388
|
+
*/
|
|
2389
|
+
swr: TransformSchema<string | number | boolean | undefined, number | boolean | undefined> & {
|
|
2390
|
+
wrapped: OptionalSchema<UnionSchema<readonly [BooleanSchema<boolean, boolean>, StringSchema<string, string>, NumberSchema<number, number>], string | number | boolean, string | number | boolean>, undefined, string | number | boolean | undefined, string | number | boolean | undefined>;
|
|
2391
|
+
};
|
|
2392
|
+
/**
|
|
2393
|
+
* Custom cache key override
|
|
2394
|
+
* If not provided, key is generated from model, operation, and args
|
|
2395
|
+
*/
|
|
2396
|
+
key: StringSchema<string | undefined, string>;
|
|
2397
|
+
/**
|
|
2398
|
+
* Bypass cache read and force fresh data
|
|
2399
|
+
* Still writes result to cache for subsequent requests
|
|
2400
|
+
* @default false
|
|
2401
|
+
*/
|
|
2402
|
+
bypass: BooleanSchema<boolean | undefined, boolean>;
|
|
2403
|
+
}>> | undefined, InferOutputShape<{
|
|
2404
|
+
/**
|
|
2405
|
+
* Time to live for cache entries
|
|
2406
|
+
* Can be a number (milliseconds) or a string like "1 hour", "20 seconds"
|
|
2407
|
+
* @default 300000 (5 minutes)
|
|
2408
|
+
*/
|
|
2409
|
+
ttl: TransformSchema<string | number | undefined, number> & {
|
|
2410
|
+
wrapped: OptionalSchema<UnionSchema<readonly [StringSchema<string, string>, NumberSchema<number, number>], string | number, string | number>, number, string | number | undefined, string | number>;
|
|
2411
|
+
};
|
|
2412
|
+
/**
|
|
2413
|
+
* Enable stale-while-revalidate pattern
|
|
2414
|
+
* When true, returns stale data immediately and revalidates in background
|
|
2415
|
+
*
|
|
2416
|
+
* The value represents the "stale window" - how long data can be served stale.
|
|
2417
|
+
* Storage TTL is automatically calculated as `ttl + staleWindow`.
|
|
2418
|
+
*
|
|
2419
|
+
* Can be a boolean or a duration value (number in ms or string like "1 hour")
|
|
2420
|
+
* - true: stale window = ttl (storage TTL = 2x ttl)
|
|
2421
|
+
* - false/undefined: SWR disabled
|
|
2422
|
+
* - number/string: custom stale window duration (storage TTL = ttl + swr)
|
|
2423
|
+
* @default false
|
|
2424
|
+
*/
|
|
2425
|
+
swr: TransformSchema<string | number | boolean | undefined, number | boolean | undefined> & {
|
|
2426
|
+
wrapped: OptionalSchema<UnionSchema<readonly [BooleanSchema<boolean, boolean>, StringSchema<string, string>, NumberSchema<number, number>], string | number | boolean, string | number | boolean>, undefined, string | number | boolean | undefined, string | number | boolean | undefined>;
|
|
2427
|
+
};
|
|
2428
|
+
/**
|
|
2429
|
+
* Custom cache key override
|
|
2430
|
+
* If not provided, key is generated from model, operation, and args
|
|
2431
|
+
*/
|
|
2432
|
+
key: StringSchema<string | undefined, string>;
|
|
2433
|
+
/**
|
|
2434
|
+
* Bypass cache read and force fresh data
|
|
2435
|
+
* Still writes result to cache for subsequent requests
|
|
2436
|
+
* @default false
|
|
2437
|
+
*/
|
|
2438
|
+
bypass: BooleanSchema<boolean | undefined, boolean>;
|
|
2439
|
+
}>>;
|
|
2440
|
+
/**
|
|
2441
|
+
* Input type for $withCache options (inferred from schema)
|
|
2442
|
+
*/
|
|
2443
|
+
type WithCacheOptions = WithCacheSchema[" vibInferred"]["0"];
|
|
2444
|
+
//#endregion
|
|
2445
|
+
//#region src/schema/model/schemas/args/mutation.d.ts
|
|
2446
|
+
/**
|
|
2447
|
+
* Create args: { data: create, select?, include? }
|
|
2448
|
+
*/
|
|
2449
|
+
type CreateArgs<T extends ModelState> = V.Object<{
|
|
2450
|
+
data: CoreSchemas<T>["create"];
|
|
2451
|
+
select: CoreSchemas<T>["select"];
|
|
2452
|
+
include: CoreSchemas<T>["include"];
|
|
2453
|
+
cache: CacheInvalidationSchema;
|
|
2454
|
+
}, {
|
|
2455
|
+
atLeast: ["data"];
|
|
2456
|
+
}>;
|
|
2457
|
+
/**
|
|
2458
|
+
* CreateMany args: { data: create[], skipDuplicates? }
|
|
2459
|
+
*/
|
|
2460
|
+
type CreateManyArgs<T extends ModelState> = V.Object<{
|
|
2461
|
+
data: V.Array<CoreSchemas<T>["scalarCreate"]>;
|
|
2462
|
+
skipDuplicates: V.Boolean<{
|
|
2463
|
+
optional: true;
|
|
2464
|
+
}>;
|
|
2465
|
+
cache: CacheInvalidationSchema;
|
|
2466
|
+
}, {
|
|
2467
|
+
atLeast: ["data"];
|
|
2468
|
+
}>;
|
|
2469
|
+
/**
|
|
2470
|
+
* Update args: { where: whereUnique, data: update, select?, include? }
|
|
2471
|
+
*/
|
|
2472
|
+
type UpdateArgs<T extends ModelState> = V.Object<{
|
|
2473
|
+
where: CoreSchemas<T>["whereUnique"];
|
|
2474
|
+
data: CoreSchemas<T>["update"];
|
|
2475
|
+
select: CoreSchemas<T>["select"];
|
|
2476
|
+
include: CoreSchemas<T>["include"];
|
|
2477
|
+
cache: CacheInvalidationSchema;
|
|
2478
|
+
}, {
|
|
2479
|
+
atLeast: ["where", "data"];
|
|
2480
|
+
}>;
|
|
2481
|
+
/**
|
|
2482
|
+
* UpdateMany args: { where?, data: update }
|
|
2483
|
+
*/
|
|
2484
|
+
type UpdateManyArgs<T extends ModelState> = V.Object<{
|
|
2485
|
+
where: CoreSchemas<T>["where"];
|
|
2486
|
+
data: CoreSchemas<T>["update"];
|
|
2487
|
+
cache: CacheInvalidationSchema;
|
|
2488
|
+
}, {
|
|
2489
|
+
atLeast: ["data"];
|
|
2490
|
+
}>;
|
|
2491
|
+
/**
|
|
2492
|
+
* Delete args: { where: whereUnique, select?, include? }
|
|
2493
|
+
*/
|
|
2494
|
+
type DeleteArgs<T extends ModelState> = V.Object<{
|
|
2495
|
+
where: CoreSchemas<T>["whereUnique"];
|
|
2496
|
+
select: CoreSchemas<T>["select"];
|
|
2497
|
+
include: CoreSchemas<T>["include"];
|
|
2498
|
+
cache: CacheInvalidationSchema;
|
|
2499
|
+
}, {
|
|
2500
|
+
atLeast: ["where"];
|
|
2501
|
+
}>;
|
|
2502
|
+
/**
|
|
2503
|
+
* DeleteMany args: { where? }
|
|
2504
|
+
*/
|
|
2505
|
+
type DeleteManyArgs<T extends ModelState> = V.Object<{
|
|
2506
|
+
where: CoreSchemas<T>["where"];
|
|
2507
|
+
cache: CacheInvalidationSchema;
|
|
2508
|
+
}, {
|
|
2509
|
+
optional: true;
|
|
2510
|
+
}>;
|
|
2511
|
+
/**
|
|
2512
|
+
* Upsert args: { where: whereUnique, create, update, select?, include?, cache?, targetWhere?, setWhere? }
|
|
2513
|
+
*
|
|
2514
|
+
* Additional options for advanced ON CONFLICT handling:
|
|
2515
|
+
* - targetWhere: WHERE clause for partial unique index matching
|
|
2516
|
+
* PostgreSQL: ON CONFLICT (id) WHERE <targetWhere> DO UPDATE ...
|
|
2517
|
+
* - setWhere: WHERE clause for conditional updates
|
|
2518
|
+
* PostgreSQL: ON CONFLICT ... DO UPDATE SET x = y WHERE <setWhere>
|
|
2519
|
+
*/
|
|
2520
|
+
type UpsertArgs<T extends ModelState> = V.Object<{
|
|
2521
|
+
where: CoreSchemas<T>["whereUnique"];
|
|
2522
|
+
create: CoreSchemas<T>["create"];
|
|
2523
|
+
update: CoreSchemas<T>["update"];
|
|
2524
|
+
select: CoreSchemas<T>["select"];
|
|
2525
|
+
include: CoreSchemas<T>["include"];
|
|
2526
|
+
cache: CacheInvalidationSchema;
|
|
2527
|
+
/** WHERE clause for partial unique index matching (PostgreSQL/SQLite only) */
|
|
2528
|
+
targetWhere: CoreSchemas<T>["where"];
|
|
2529
|
+
/** WHERE clause for conditional updates (PostgreSQL/SQLite only) */
|
|
2530
|
+
setWhere: CoreSchemas<T>["where"];
|
|
2531
|
+
}, {
|
|
2532
|
+
atLeast: ["where", "create", "update"];
|
|
2533
|
+
}>;
|
|
2534
|
+
//#endregion
|
|
2535
|
+
//#region src/schema/model/schemas/args/index.d.ts
|
|
2536
|
+
type ModelArgs<T extends ModelState> = {
|
|
2537
|
+
findUnique: FindUniqueArgs<T>;
|
|
2538
|
+
findFirst: FindFirstArgs<T>;
|
|
2539
|
+
findMany: FindManyArgs<T>;
|
|
2540
|
+
create: CreateArgs<T>;
|
|
2541
|
+
createMany: CreateManyArgs<T>;
|
|
2542
|
+
update: UpdateArgs<T>;
|
|
2543
|
+
updateMany: UpdateManyArgs<T>;
|
|
2544
|
+
delete: DeleteArgs<T>;
|
|
2545
|
+
deleteMany: DeleteManyArgs<T>;
|
|
2546
|
+
upsert: UpsertArgs<T>;
|
|
2547
|
+
count: CountArgs<T>;
|
|
2548
|
+
aggregate: AggregateArgs<T>;
|
|
2549
|
+
groupBy: GroupByArgs<T>;
|
|
2550
|
+
};
|
|
2551
|
+
//#endregion
|
|
2552
|
+
//#region src/schema/model/schemas/model-schemas.d.ts
|
|
2553
|
+
/**
|
|
2554
|
+
* Lazy model schemas class.
|
|
2555
|
+
* Builds core schemas and operation args on-demand for optimal performance.
|
|
2556
|
+
*
|
|
2557
|
+
* Instead of building all 28+ schemas upfront, each schema is built only
|
|
2558
|
+
* when first accessed and then cached for subsequent access.
|
|
2559
|
+
*/
|
|
2560
|
+
declare class ModelSchemas<T extends ModelState> {
|
|
2561
|
+
private readonly state;
|
|
2562
|
+
private _scalarFilter?;
|
|
2563
|
+
private _uniqueFilter?;
|
|
2564
|
+
private _relationFilter?;
|
|
2565
|
+
private _compoundIdFilter?;
|
|
2566
|
+
private _compoundConstraintFilter?;
|
|
2567
|
+
private _scalarCreate?;
|
|
2568
|
+
private _relationCreate?;
|
|
2569
|
+
private _scalarUpdate?;
|
|
2570
|
+
private _relationUpdate?;
|
|
2571
|
+
private _where?;
|
|
2572
|
+
private _whereUnique?;
|
|
2573
|
+
private _create?;
|
|
2574
|
+
private _update?;
|
|
2575
|
+
private _select?;
|
|
2576
|
+
private _include?;
|
|
2577
|
+
private _orderBy?;
|
|
2578
|
+
private _args?;
|
|
2579
|
+
constructor(state: T);
|
|
2580
|
+
get scalarFilter(): ScalarFilterSchema<T>;
|
|
2581
|
+
get uniqueFilter(): UniqueFilterSchema<T>;
|
|
2582
|
+
get relationFilter(): RelationFilterSchema<T>;
|
|
2583
|
+
get compoundIdFilter(): CompoundIdFilterSchema<T>;
|
|
2584
|
+
get compoundConstraintFilter(): CompoundConstraintFilterSchema<T>;
|
|
2585
|
+
get scalarCreate(): ScalarCreateSchema<T>;
|
|
2586
|
+
get relationCreate(): RelationCreateSchema<T>;
|
|
2587
|
+
get scalarUpdate(): ScalarUpdateSchema<T>;
|
|
2588
|
+
get relationUpdate(): RelationUpdateSchema<T>;
|
|
2589
|
+
get where(): WhereSchema<T>;
|
|
2590
|
+
get whereUnique(): WhereUniqueSchema<T>;
|
|
2591
|
+
get create(): CreateSchema<T>;
|
|
2592
|
+
get update(): UpdateSchema<T>;
|
|
2593
|
+
get select(): SelectSchema<T>;
|
|
2594
|
+
get include(): IncludeSchema<T>;
|
|
2595
|
+
get orderBy(): OrderBySchema<T>;
|
|
2596
|
+
get args(): ModelArgs<T>;
|
|
2597
|
+
}
|
|
2598
|
+
//#endregion
|
|
2599
|
+
//#region src/schema/relation/schemas/helpers.d.ts
|
|
2600
|
+
type TargetModel<S extends RelationState> = S["getter"] extends (() => infer T) ? T extends AnyModel ? T : never : never;
|
|
2601
|
+
/** Infer a specific schema type from the target model */
|
|
2602
|
+
type InferTargetSchema<S extends RelationState, K$1 extends keyof ModelSchemas<TargetModel<S>>> = TargetModel<S>["~"]["schemas"][K$1];
|
|
2603
|
+
//#endregion
|
|
2604
|
+
//#region src/schema/relation/schemas/count-filter.d.ts
|
|
2605
|
+
/**
|
|
2606
|
+
* Count filter schema: true or { where: <filter> }
|
|
2607
|
+
*
|
|
2608
|
+
* Used in _count select to filter which related records to count.
|
|
2609
|
+
* - true: count all related records
|
|
2610
|
+
* - { where: ... }: count related records matching the filter
|
|
2611
|
+
*/
|
|
2612
|
+
type CountFilterSchema<S extends RelationState> = V.Union<readonly [V.Literal<true>, V.Object<{
|
|
2613
|
+
where: () => InferTargetSchema<S, "where">;
|
|
2614
|
+
}>]>;
|
|
2615
|
+
declare const countFilterFactory: <S extends RelationState>(state: S) => CountFilterSchema<S>;
|
|
2616
|
+
//#endregion
|
|
2617
|
+
//#region src/schema/relation/schemas/create.d.ts
|
|
2618
|
+
/**
|
|
2619
|
+
* To-one create: { create?, connect?, connectOrCreate? }
|
|
2620
|
+
*/
|
|
2621
|
+
type ToOneCreateSchema<S extends RelationState> = V.Object<{
|
|
2622
|
+
create: () => InferTargetSchema<S, "create">;
|
|
2623
|
+
connect: () => InferTargetSchema<S, "whereUnique">;
|
|
2624
|
+
connectOrCreate: V.Object<{
|
|
2625
|
+
where: () => InferTargetSchema<S, "whereUnique">;
|
|
2626
|
+
create: () => InferTargetSchema<S, "create">;
|
|
2627
|
+
}>;
|
|
2628
|
+
}, {
|
|
2629
|
+
optional: true;
|
|
2630
|
+
}>;
|
|
2631
|
+
declare const toOneCreateFactory: <S extends RelationState>(state: S) => ToOneCreateSchema<S>;
|
|
2632
|
+
/**
|
|
2633
|
+
* To-many create: { create?, createMany?, connect?, connectOrCreate? }
|
|
2634
|
+
* All accept single or array, normalized to array
|
|
2635
|
+
* Uses thunks for lazy evaluation to avoid circular reference issues
|
|
2636
|
+
*
|
|
2637
|
+
* Note: createMany uses scalarCreate (no nested relations) because
|
|
2638
|
+
* nested creates within createMany are not supported.
|
|
2639
|
+
*/
|
|
2640
|
+
type ToManyCreateSchema<S extends RelationState> = V.Object<{
|
|
2641
|
+
create: () => V.SingleOrArray<InferTargetSchema<S, "create">>;
|
|
2642
|
+
createMany: V.Object<{
|
|
2643
|
+
data: () => V.Array<InferTargetSchema<S, "scalarCreate">>;
|
|
2644
|
+
skipDuplicates: V.Boolean<{
|
|
2645
|
+
optional: true;
|
|
2646
|
+
}>;
|
|
2647
|
+
}>;
|
|
2648
|
+
connect: () => V.SingleOrArray<InferTargetSchema<S, "whereUnique">>;
|
|
2649
|
+
connectOrCreate: () => V.SingleOrArray<V.Object<{
|
|
2650
|
+
where: () => InferTargetSchema<S, "whereUnique">;
|
|
2651
|
+
create: () => InferTargetSchema<S, "create">;
|
|
2652
|
+
}, {
|
|
2653
|
+
partial: false;
|
|
2654
|
+
}>>;
|
|
2655
|
+
}, {
|
|
2656
|
+
optional: true;
|
|
2657
|
+
}>;
|
|
2658
|
+
declare const toManyCreateFactory: <S extends RelationState>(state: S) => ToManyCreateSchema<S>;
|
|
2659
|
+
//#endregion
|
|
2660
|
+
//#region src/schema/relation/schemas/filter.d.ts
|
|
2661
|
+
/**
|
|
2662
|
+
* To-one filter: { is?, isNot? }
|
|
2663
|
+
* For optional relations, `is` can also be null
|
|
2664
|
+
* Uses thunks for lazy evaluation to avoid circular reference issues
|
|
2665
|
+
*/
|
|
2666
|
+
type ToOneFilterSchema<S extends RelationState> = V.Object<{
|
|
2667
|
+
is: () => V.MaybeNullable<InferTargetSchema<S, "where">, S["optional"] extends true ? true : false>;
|
|
2668
|
+
isNot: () => V.MaybeNullable<InferTargetSchema<S, "where">, S["optional"] extends true ? true : false>;
|
|
2669
|
+
}>;
|
|
2670
|
+
declare const toOneFilterFactory: <S extends RelationState>(state: S) => ToOneFilterSchema<S>;
|
|
2671
|
+
/**
|
|
2672
|
+
* To-many filter: { some?, every?, none? }
|
|
2673
|
+
* Uses thunks for lazy evaluation - getTargetWhereSchema already returns thunk
|
|
2674
|
+
*/
|
|
2675
|
+
type ToManyFilterSchema<S extends RelationState> = V.Object<{
|
|
2676
|
+
some: () => V.MaybeNullable<InferTargetSchema<S, "where">, S["optional"] extends true ? true : false>;
|
|
2677
|
+
every: () => V.MaybeNullable<InferTargetSchema<S, "where">, S["optional"] extends true ? true : false>;
|
|
2678
|
+
none: () => V.MaybeNullable<InferTargetSchema<S, "where">, S["optional"] extends true ? true : false>;
|
|
2679
|
+
}>;
|
|
2680
|
+
declare const toManyFilterFactory: <S extends RelationState>(state: S) => ToManyFilterSchema<S>;
|
|
2681
|
+
//#endregion
|
|
2682
|
+
//#region src/schema/relation/schemas/order-by.d.ts
|
|
2683
|
+
/**
|
|
2684
|
+
* To-one orderBy: nested orderBy from the related model's fields
|
|
2685
|
+
* e.g., orderBy: { author: { name: 'asc' } }
|
|
2686
|
+
*/
|
|
2687
|
+
type ToOneOrderBySchema<S extends RelationState> = () => InferTargetSchema<S, "orderBy">;
|
|
2688
|
+
declare const toOneOrderByFactory: <S extends RelationState>(state: S) => ToOneOrderBySchema<S>;
|
|
2689
|
+
/**
|
|
2690
|
+
* To-many orderBy: can order by _count aggregate
|
|
2691
|
+
* e.g., orderBy: { posts: { _count: 'desc' } }
|
|
2692
|
+
*/
|
|
2693
|
+
type ToManyOrderBySchema<S extends RelationState> = V.Object<{
|
|
2694
|
+
_count: V.Enum<["asc", "desc"]>;
|
|
2695
|
+
}>;
|
|
2696
|
+
declare const toManyOrderByFactory: <S extends RelationState>(_state: S) => ToManyOrderBySchema<S>;
|
|
2697
|
+
//#endregion
|
|
2698
|
+
//#region src/schema/relation/schemas/select-include.d.ts
|
|
2699
|
+
type IncludeToField<Schema extends V.Object<any>> = V.Coerce<Schema, Schema[" vibInferred"]["1"] & {
|
|
2700
|
+
select?: Record<string, true>;
|
|
2701
|
+
}>;
|
|
2702
|
+
type BooleanToSelect = V.Coerce<V.Boolean, {
|
|
2703
|
+
select: Record<string, true> | false;
|
|
2704
|
+
}>;
|
|
2705
|
+
/**
|
|
2706
|
+
* To-one select: true or nested { select }
|
|
2707
|
+
*/
|
|
2708
|
+
type ToOneSelect<S extends RelationState> = V.Union<readonly [BooleanToSelect, V.Object<{
|
|
2709
|
+
select: () => InferTargetSchema<S, "select">;
|
|
2710
|
+
}>]>;
|
|
2711
|
+
declare const toOneSelectFactory: <S extends RelationState>(state: S) => ToOneSelect<S>;
|
|
2712
|
+
/**
|
|
2713
|
+
* To-many select: true or nested { where, orderBy, take, skip, select }
|
|
2714
|
+
*/
|
|
2715
|
+
type ToManySelect<S extends RelationState> = V.Union<readonly [BooleanToSelect, V.Object<{
|
|
2716
|
+
where: () => InferTargetSchema<S, "where">;
|
|
2717
|
+
orderBy: () => InferTargetSchema<S, "orderBy">;
|
|
2718
|
+
take: V.Number;
|
|
2719
|
+
skip: V.Number;
|
|
2720
|
+
cursor: V.String;
|
|
2721
|
+
select: () => InferTargetSchema<S, "select">;
|
|
2722
|
+
}>]>;
|
|
2723
|
+
declare const toManySelectFactory: <S extends RelationState>(state: S) => ToManySelect<S>;
|
|
2724
|
+
/**
|
|
2725
|
+
* To-one include: true or nested { select, include }
|
|
2726
|
+
*/
|
|
2727
|
+
type ToOneInclude<S extends RelationState> = V.Union<readonly [BooleanToSelect, IncludeToField<V.Object<{
|
|
2728
|
+
select: () => InferTargetSchema<S, "select">;
|
|
2729
|
+
include: () => InferTargetSchema<S, "include">;
|
|
2730
|
+
}>>]>;
|
|
2731
|
+
declare const toOneIncludeFactory: <S extends RelationState>(state: S) => ToOneInclude<S>;
|
|
2732
|
+
/**
|
|
2733
|
+
* To-many include: true or nested { where, orderBy, take, skip, cursor, select, include }
|
|
2734
|
+
*/
|
|
2735
|
+
type ToManyInclude<S extends RelationState> = V.Union<readonly [BooleanToSelect, IncludeToField<V.Object<{
|
|
2736
|
+
where: () => InferTargetSchema<S, "where">;
|
|
2737
|
+
orderBy: () => InferTargetSchema<S, "orderBy">;
|
|
2738
|
+
take: V.Number;
|
|
2739
|
+
skip: V.Number;
|
|
2740
|
+
cursor: V.String;
|
|
2741
|
+
select: () => InferTargetSchema<S, "select">;
|
|
2742
|
+
include: () => InferTargetSchema<S, "include">;
|
|
2743
|
+
}>>]>;
|
|
2744
|
+
declare const toManyIncludeFactory: <S extends RelationState>(state: S) => ToManyInclude<S>;
|
|
2745
|
+
//#endregion
|
|
2746
|
+
//#region src/schema/relation/schemas/update.d.ts
|
|
2747
|
+
/**
|
|
2748
|
+
* To-one update: { create?, connect?, connectOrCreate?, update?, upsert?, disconnect?, delete? }
|
|
2749
|
+
* disconnect and delete only available for optional relations
|
|
2750
|
+
*/
|
|
2751
|
+
type ToOneUpdateSchemaBase<S extends RelationState> = V.Object<{
|
|
2752
|
+
create: () => InferTargetSchema<S, "create">;
|
|
2753
|
+
connect: () => InferTargetSchema<S, "whereUnique">;
|
|
2754
|
+
connectOrCreate: V.Object<{
|
|
2755
|
+
where: () => InferTargetSchema<S, "whereUnique">;
|
|
2756
|
+
create: () => InferTargetSchema<S, "create">;
|
|
2757
|
+
}>;
|
|
2758
|
+
}>;
|
|
2759
|
+
type ToOneUpdateSchemaOptional<S extends RelationState> = V.Object<{
|
|
2760
|
+
disconnect: V.Boolean;
|
|
2761
|
+
delete: V.Boolean;
|
|
2762
|
+
}>;
|
|
2763
|
+
type ToOneUpdateSchema<S extends RelationState> = S["optional"] extends true ? V.Object<ToOneUpdateSchemaOptional<S>["entries"] & ToOneUpdateSchemaBase<S>["entries"]> : ToOneUpdateSchemaBase<S>;
|
|
2764
|
+
declare const toOneUpdateFactory: <S extends RelationState>(state: S) => ToOneUpdateSchema<S>;
|
|
2765
|
+
/**
|
|
2766
|
+
* To-many update: { create?, connect?, disconnect?, set?, delete?, update?, updateMany?, deleteMany?, upsert? }
|
|
2767
|
+
* Most operations accept single or array
|
|
2768
|
+
*/
|
|
2769
|
+
type ToManyUpdateSchema<S extends RelationState> = V.Object<{
|
|
2770
|
+
create: () => V.SingleOrArray<InferTargetSchema<S, "create">>;
|
|
2771
|
+
connect: () => V.SingleOrArray<InferTargetSchema<S, "whereUnique">>;
|
|
2772
|
+
disconnect: () => V.Union<readonly [V.Boolean, V.SingleOrArray<InferTargetSchema<S, "whereUnique">>]>;
|
|
2773
|
+
delete: () => V.SingleOrArray<InferTargetSchema<S, "whereUnique">>;
|
|
2774
|
+
connectOrCreate: V.SingleOrArray<V.Object<{
|
|
2775
|
+
where: () => InferTargetSchema<S, "whereUnique">;
|
|
2776
|
+
create: () => InferTargetSchema<S, "create">;
|
|
2777
|
+
}>>;
|
|
2778
|
+
set: () => V.SingleOrArray<InferTargetSchema<S, "whereUnique">>;
|
|
2779
|
+
update: V.SingleOrArray<V.Object<{
|
|
2780
|
+
where: () => InferTargetSchema<S, "where">;
|
|
2781
|
+
data: () => InferTargetSchema<S, "update">;
|
|
2782
|
+
}>>;
|
|
2783
|
+
updateMany: V.SingleOrArray<V.Object<{
|
|
2784
|
+
where: () => InferTargetSchema<S, "where">;
|
|
2785
|
+
data: () => InferTargetSchema<S, "update">;
|
|
2786
|
+
}>>;
|
|
2787
|
+
deleteMany: () => V.SingleOrArray<InferTargetSchema<S, "where">>;
|
|
2788
|
+
upsert: V.SingleOrArray<V.Object<{
|
|
2789
|
+
where: () => InferTargetSchema<S, "whereUnique">;
|
|
2790
|
+
create: () => InferTargetSchema<S, "create">;
|
|
2791
|
+
update: () => InferTargetSchema<S, "update">;
|
|
2792
|
+
}>>;
|
|
2793
|
+
}>;
|
|
2794
|
+
declare const toManyUpdateFactory: <S extends RelationState>(state: S) => ToManyUpdateSchema<S>;
|
|
2795
|
+
//#endregion
|
|
2796
|
+
//#region src/schema/relation/schemas/index.d.ts
|
|
2797
|
+
type ToOneSchemas<S extends RelationState> = {
|
|
2798
|
+
filter: ReturnType<typeof toOneFilterFactory<S>>;
|
|
2799
|
+
create: ReturnType<typeof toOneCreateFactory<S>>;
|
|
2800
|
+
update: ReturnType<typeof toOneUpdateFactory<S>>;
|
|
2801
|
+
select: ReturnType<typeof toOneSelectFactory<S>>;
|
|
2802
|
+
include: ReturnType<typeof toOneIncludeFactory<S>>;
|
|
2803
|
+
orderBy: ReturnType<typeof toOneOrderByFactory<S>>;
|
|
2804
|
+
countFilter: ReturnType<typeof countFilterFactory<S>>;
|
|
2805
|
+
};
|
|
2806
|
+
type ToManySchemas<S extends RelationState> = {
|
|
2807
|
+
filter: ReturnType<typeof toManyFilterFactory<S>>;
|
|
2808
|
+
create: ReturnType<typeof toManyCreateFactory<S>>;
|
|
2809
|
+
update: ReturnType<typeof toManyUpdateFactory<S>>;
|
|
2810
|
+
select: ReturnType<typeof toManySelectFactory<S>>;
|
|
2811
|
+
include: ReturnType<typeof toManyIncludeFactory<S>>;
|
|
2812
|
+
orderBy: ReturnType<typeof toManyOrderByFactory<S>>;
|
|
2813
|
+
countFilter: ReturnType<typeof countFilterFactory<S>>;
|
|
2814
|
+
};
|
|
2815
|
+
type InferRelationSchemas<S extends RelationState> = S["type"] extends "manyToMany" | "oneToMany" ? ToManySchemas<S> : ToOneSchemas<S>;
|
|
2816
|
+
//#endregion
|
|
2817
|
+
//#region src/schema/relation/many-to-many.d.ts
|
|
2818
|
+
/**
|
|
2819
|
+
* Relation class for many-to-many relations
|
|
2820
|
+
* Supports configuration for junction table name and field names
|
|
2821
|
+
*
|
|
2822
|
+
* @example
|
|
2823
|
+
* ```ts
|
|
2824
|
+
* // Simple - auto-generated junction table "post_tag"
|
|
2825
|
+
* const post = s.model({
|
|
2826
|
+
* tags: s.manyToMany(() => tag),
|
|
2827
|
+
* });
|
|
2828
|
+
*
|
|
2829
|
+
* // With explicit junction table
|
|
2830
|
+
* const post = s.model({
|
|
2831
|
+
* tags: s.manyToMany(() => tag).through("post_tags"),
|
|
2832
|
+
* });
|
|
2833
|
+
*
|
|
2834
|
+
* // With custom field names in junction table
|
|
2835
|
+
* const post = s.model({
|
|
2836
|
+
* tags: s.manyToMany(() => tag)
|
|
2837
|
+
* .through("post_tags")
|
|
2838
|
+
* .A("postId")
|
|
2839
|
+
* .B("tagId"),
|
|
2840
|
+
* });
|
|
2841
|
+
* ```
|
|
2842
|
+
*/
|
|
2843
|
+
declare class ManyToManyRelation<State extends ManyToManyRelationState> {
|
|
2844
|
+
private readonly _state;
|
|
2845
|
+
private _schemas;
|
|
2846
|
+
constructor(state: State);
|
|
2847
|
+
/**
|
|
2848
|
+
* Specify the junction table name
|
|
2849
|
+
*/
|
|
2850
|
+
through(tableName: string): ManyToManyRelation<State & {
|
|
2851
|
+
through: string;
|
|
2852
|
+
}>;
|
|
2853
|
+
/**
|
|
2854
|
+
* Specify the source field name in the junction table
|
|
2855
|
+
*/
|
|
2856
|
+
A(fieldName: string): ManyToManyRelation<State & {
|
|
2857
|
+
A: string;
|
|
2858
|
+
}>;
|
|
2859
|
+
/**
|
|
2860
|
+
* Specify the target field name in the junction table
|
|
2861
|
+
*/
|
|
2862
|
+
B(fieldName: string): ManyToManyRelation<State & {
|
|
2863
|
+
B: string;
|
|
2864
|
+
}>;
|
|
2865
|
+
/**
|
|
2866
|
+
* Specify the referential action when a related record is deleted
|
|
2867
|
+
*/
|
|
2868
|
+
onDelete(action: ReferentialAction): ManyToManyRelation<State & {
|
|
2869
|
+
onDelete: ReferentialAction;
|
|
2870
|
+
}>;
|
|
2871
|
+
/**
|
|
2872
|
+
* Specify the referential action when a related record's key is updated
|
|
2873
|
+
*/
|
|
2874
|
+
onUpdate(action: ReferentialAction): ManyToManyRelation<State & {
|
|
2875
|
+
onUpdate: ReferentialAction;
|
|
2876
|
+
}>;
|
|
2877
|
+
/**
|
|
2878
|
+
* Set a custom name for this relation
|
|
2879
|
+
*/
|
|
2880
|
+
name(name: string): ManyToManyRelation<State & {
|
|
2881
|
+
name: string;
|
|
2882
|
+
}>;
|
|
2883
|
+
/**
|
|
2884
|
+
* Internal accessor for state and schemas
|
|
2885
|
+
*/
|
|
2886
|
+
get "~"(): {
|
|
2887
|
+
state: State;
|
|
2888
|
+
schemas: InferRelationSchemas<State>;
|
|
2889
|
+
};
|
|
2890
|
+
}
|
|
2891
|
+
//#endregion
|
|
2892
|
+
//#region src/schema/relation/to-many.d.ts
|
|
2893
|
+
/**
|
|
2894
|
+
* Relation class for one-to-many relations (oneToMany)
|
|
2895
|
+
* This is the inverse side of a relationship - FK lives on the other model
|
|
2896
|
+
* Minimal configuration needed since it doesn't own the FK
|
|
2897
|
+
*
|
|
2898
|
+
* @example
|
|
2899
|
+
* ```ts
|
|
2900
|
+
* const user = s.model({
|
|
2901
|
+
* posts: s.oneToMany(() => post), // No config needed - FK is on post.authorId
|
|
2902
|
+
* });
|
|
2903
|
+
* ```
|
|
2904
|
+
*/
|
|
2905
|
+
declare class ToManyRelation<State extends ToManyRelationState> {
|
|
2906
|
+
private readonly _state;
|
|
2907
|
+
private _schemas;
|
|
2908
|
+
constructor(state: State);
|
|
2909
|
+
/**
|
|
2910
|
+
* Set a custom name for this relation
|
|
2911
|
+
*/
|
|
2912
|
+
name(name: string): ToManyRelation<State & {
|
|
2913
|
+
name: string;
|
|
2914
|
+
}>;
|
|
2915
|
+
/**
|
|
2916
|
+
* Internal accessor for state and schemas
|
|
2917
|
+
*/
|
|
2918
|
+
get "~"(): {
|
|
2919
|
+
state: State;
|
|
2920
|
+
schemas: InferRelationSchemas<State>;
|
|
2921
|
+
};
|
|
2922
|
+
}
|
|
2923
|
+
//#endregion
|
|
2924
|
+
//#region src/schema/relation/to-one.d.ts
|
|
2925
|
+
/**
|
|
2926
|
+
* Relation class for to-one relations (oneToOne, manyToOne)
|
|
2927
|
+
* Supports chainable configuration for FK fields, references, and referential actions
|
|
2928
|
+
*
|
|
2929
|
+
* @example
|
|
2930
|
+
* ```ts
|
|
2931
|
+
* // Simple relation
|
|
2932
|
+
* s.manyToOne(() => user)
|
|
2933
|
+
*
|
|
2934
|
+
* // With FK configuration
|
|
2935
|
+
* s.manyToOne(() => user)
|
|
2936
|
+
* .fields("authorId")
|
|
2937
|
+
* .references("id")
|
|
2938
|
+
* .onDelete("cascade")
|
|
2939
|
+
*
|
|
2940
|
+
* // Optional relation
|
|
2941
|
+
* s.oneToOne(() => profile).optional()
|
|
2942
|
+
* ```
|
|
2943
|
+
*/
|
|
2944
|
+
declare class ToOneRelation<State extends ToOneRelationState> {
|
|
2945
|
+
private readonly _state;
|
|
2946
|
+
private _schemas;
|
|
2947
|
+
constructor(state: State);
|
|
2948
|
+
/**
|
|
2949
|
+
* Specify the foreign key field(s) on this model
|
|
2950
|
+
*/
|
|
2951
|
+
fields(...fields: string[]): ToOneRelation<State & {
|
|
2952
|
+
fields: string[];
|
|
2953
|
+
}>;
|
|
2954
|
+
/**
|
|
2955
|
+
* Specify the referenced field(s) on the target model
|
|
2956
|
+
*/
|
|
2957
|
+
references(...refs: string[]): ToOneRelation<State & {
|
|
2958
|
+
references: string[];
|
|
2959
|
+
}>;
|
|
2960
|
+
/**
|
|
2961
|
+
* Mark this relation as optional (FK can be null)
|
|
2962
|
+
*/
|
|
2963
|
+
optional(): ToOneRelation<State & {
|
|
2964
|
+
optional: true;
|
|
2965
|
+
}>;
|
|
2966
|
+
/**
|
|
2967
|
+
* Specify the referential action when the referenced record is deleted
|
|
2968
|
+
*/
|
|
2969
|
+
onDelete(action: ReferentialAction): ToOneRelation<State & {
|
|
2970
|
+
onDelete: ReferentialAction;
|
|
2971
|
+
}>;
|
|
2972
|
+
/**
|
|
2973
|
+
* Specify the referential action when the referenced record's key is updated
|
|
2974
|
+
*/
|
|
2975
|
+
onUpdate(action: ReferentialAction): ToOneRelation<State & {
|
|
2976
|
+
onUpdate: ReferentialAction;
|
|
2977
|
+
}>;
|
|
2978
|
+
/**
|
|
2979
|
+
* Set a custom name for this relation
|
|
2980
|
+
*/
|
|
2981
|
+
name(name: string): ToOneRelation<State & {
|
|
2982
|
+
name: string;
|
|
2983
|
+
}>;
|
|
2984
|
+
/**
|
|
2985
|
+
* Internal accessor for state and schemas
|
|
2986
|
+
*/
|
|
2987
|
+
get "~"(): {
|
|
2988
|
+
state: State;
|
|
2989
|
+
schemas: InferRelationSchemas<State>;
|
|
2990
|
+
};
|
|
2991
|
+
}
|
|
2992
|
+
//#endregion
|
|
2993
|
+
//#region src/schema/relation/index.d.ts
|
|
2994
|
+
/** Union type of all relation classes */
|
|
2995
|
+
type AnyRelation = ToOneRelation<ToOneRelationState> | ToManyRelation<ToManyRelationState> | ManyToManyRelation<ManyToManyRelationState>;
|
|
2996
|
+
//#endregion
|
|
2997
|
+
//#region src/schema/model/helper.d.ts
|
|
2998
|
+
/**
|
|
2999
|
+
* Record of model fields - the canonical type for field definitions.
|
|
3000
|
+
* Supports both scalar Field types and relation types.
|
|
3001
|
+
*/
|
|
3002
|
+
type FieldRecord = Record<string, Field | AnyRelation>;
|
|
3003
|
+
type NameFromKeys<TFields extends string[], TName extends string = ""> = TFields extends readonly [infer F extends string, ...infer R extends string[]] ? R extends [] ? `${TName}_${F}` : NameFromKeys<R, TName extends "" ? F : `${TName}_${F}`> : never;
|
|
3004
|
+
type ToString<T> = T extends string | number | bigint | boolean | null | undefined ? `${T}` : never;
|
|
3005
|
+
type StringKeyOf<T extends Record<string, any>> = { [K in keyof T]: K extends string ? K : never }[keyof T];
|
|
3006
|
+
type ScalarFieldKeys<T extends FieldRecord> = { [K in keyof T]: T[K] extends Field ? ToString<K> : never }[keyof T];
|
|
3007
|
+
/** Extract relation keys from ModelState */
|
|
3008
|
+
type RelationKeys<T extends FieldRecord> = { [K in keyof T]: T[K] extends AnyRelation ? ToString<K> : never }[keyof T];
|
|
3009
|
+
type RequiredFieldKeys<T extends FieldRecord> = { [K in keyof T]: T[K] extends Field ? T[K]["~"]["state"]["optional"] extends true ? never : ToString<K> : never }[keyof T];
|
|
3010
|
+
type UniqueFieldKeys<T extends FieldRecord> = { [K in keyof T]: T[K] extends Field ? T[K]["~"]["state"]["isId"] extends true ? ToString<K> : T[K]["~"]["state"]["isUnique"] extends true ? ToString<K> : never : never }[keyof T];
|
|
3011
|
+
/** Numeric field types for aggregations (avg, sum) */
|
|
3012
|
+
type NumericFieldType = "int" | "float" | "decimal" | "bigint";
|
|
3013
|
+
/** Extract keys of numeric fields from a FieldRecord */
|
|
3014
|
+
type NumericFieldKeys<T extends FieldRecord> = { [K in keyof T]: T[K] extends Field ? T[K]["~"]["state"]["type"] extends NumericFieldType ? ToString<K> : never : never }[keyof T];
|
|
3015
|
+
type ScalarFields<T extends FieldRecord> = { [K in ScalarFieldKeys<T>]: T[K] extends Field ? T[K] : never };
|
|
3016
|
+
type RelationFields<T extends FieldRecord> = { [K in RelationKeys<T>]: T[K] extends AnyRelation ? T[K] : never };
|
|
3017
|
+
type UniqueFields<T extends FieldRecord> = { [K in UniqueFieldKeys<T>]: T[K] extends Field ? T[K] : never };
|
|
3018
|
+
//#endregion
|
|
3019
|
+
export { TimeField as A, Getter as B, VectorField as C, FloatField as D, IntField as E, MYSQL as F, RelationType as H, NativeType as I, PG as L, DateField as M, BooleanField as N, EnumField as O, BlobField as P, SQLITE as R, NumberField as S, JsonField as T, ReferentialAction as V, Model as _, AnyRelation as a, Field as b, ManyToManyRelation as c, DEFAULT_CACHE_TTL as d, WithCacheOptions as f, AnyModel as g, withCacheSchema as h, UniqueFields as i, DateTimeField as j, DecimalField as k, CacheInvalidationOptions as l, cacheInvalidationSchema as m, RelationFields as n, ToOneRelation as o, WithCacheSchema as p, ScalarFields as r, ToManyRelation as s, FieldRecord as t, CacheInvalidationSchema as u, ModelState as v, StringField as w, BigIntField as x, UpdateState as y, FieldState as z };
|
|
3020
|
+
//# sourceMappingURL=helper-cDCDjRAD.d.mts.map
|