@nanokajs/core 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/LICENSE +21 -0
- package/README.md +408 -0
- package/dist/chunk-F5OBRXXY.js +571 -0
- package/dist/chunk-F5OBRXXY.js.map +1 -0
- package/dist/cli.d.ts +3 -0
- package/dist/cli.js +181 -0
- package/dist/cli.js.map +1 -0
- package/dist/config.d.ts +17 -0
- package/dist/config.js +10 -0
- package/dist/config.js.map +1 -0
- package/dist/factories-CDsk1Hdt.d.ts +402 -0
- package/dist/index.d.ts +366 -0
- package/dist/index.js +268 -0
- package/dist/index.js.map +1 -0
- package/package.json +80 -0
|
@@ -0,0 +1,571 @@
|
|
|
1
|
+
import { text, integer, real } from 'drizzle-orm/sqlite-core';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
|
|
4
|
+
// src/field/factories.ts
|
|
5
|
+
|
|
6
|
+
// src/field/builder.ts
|
|
7
|
+
var BaseFieldBuilder = class {
|
|
8
|
+
tsType = void 0;
|
|
9
|
+
modifiers;
|
|
10
|
+
constructor(modifiers) {
|
|
11
|
+
this.modifiers = Object.freeze(modifiers ?? {});
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Returns the Zod schema with all modifiers applied.
|
|
15
|
+
* Order: base schema → format/min/max constraints → optional → default
|
|
16
|
+
*/
|
|
17
|
+
applyModifiersToZod(baseSchema) {
|
|
18
|
+
let schema = baseSchema;
|
|
19
|
+
if (this.modifiers.optional) {
|
|
20
|
+
schema = schema.optional();
|
|
21
|
+
}
|
|
22
|
+
if (this.modifiers.hasDefault) {
|
|
23
|
+
const defaultValue = this.modifiers.defaultValue;
|
|
24
|
+
schema = schema.default(defaultValue);
|
|
25
|
+
}
|
|
26
|
+
return schema;
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
// src/field/factories.ts
|
|
31
|
+
var StringFieldBuilder = class _StringFieldBuilder extends BaseFieldBuilder {
|
|
32
|
+
kind = "string";
|
|
33
|
+
get zodBase() {
|
|
34
|
+
let schema = z.string();
|
|
35
|
+
if (this.modifiers.min !== void 0) {
|
|
36
|
+
schema = schema.min(this.modifiers.min);
|
|
37
|
+
}
|
|
38
|
+
if (this.modifiers.max !== void 0) {
|
|
39
|
+
schema = schema.max(this.modifiers.max);
|
|
40
|
+
}
|
|
41
|
+
if (this.modifiers.format === "email") {
|
|
42
|
+
schema = schema.email();
|
|
43
|
+
}
|
|
44
|
+
return this.applyModifiersToZod(schema);
|
|
45
|
+
}
|
|
46
|
+
drizzleColumn(name) {
|
|
47
|
+
let col = text(name);
|
|
48
|
+
if (!this.modifiers.optional) {
|
|
49
|
+
col = col.notNull();
|
|
50
|
+
}
|
|
51
|
+
if (this.modifiers.primary) {
|
|
52
|
+
col = col.primaryKey();
|
|
53
|
+
}
|
|
54
|
+
if (this.modifiers.unique) {
|
|
55
|
+
col = col.unique();
|
|
56
|
+
}
|
|
57
|
+
if (this.modifiers.hasDefault) {
|
|
58
|
+
const defaultValue = this.modifiers.defaultValue;
|
|
59
|
+
if (typeof defaultValue === "function") {
|
|
60
|
+
col = col.$defaultFn(defaultValue);
|
|
61
|
+
} else {
|
|
62
|
+
col = col.default(defaultValue);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
return col;
|
|
66
|
+
}
|
|
67
|
+
cloneWithModifiers(mods) {
|
|
68
|
+
return new _StringFieldBuilder(mods);
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Marks this field as optional (allows undefined / null).
|
|
72
|
+
*/
|
|
73
|
+
optional() {
|
|
74
|
+
const newMods = { ...this.modifiers, optional: true };
|
|
75
|
+
return new _StringFieldBuilder(newMods);
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Marks this field as the primary key of its table.
|
|
79
|
+
*/
|
|
80
|
+
primary() {
|
|
81
|
+
const newMods = { ...this.modifiers, primary: true };
|
|
82
|
+
return this.cloneWithModifiers(newMods);
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Adds a unique constraint to this field.
|
|
86
|
+
*/
|
|
87
|
+
unique() {
|
|
88
|
+
const newMods = { ...this.modifiers, unique: true };
|
|
89
|
+
return this.cloneWithModifiers(newMods);
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Sets a default value for this field.
|
|
93
|
+
*/
|
|
94
|
+
default(value) {
|
|
95
|
+
const newMods = { ...this.modifiers, hasDefault: true, defaultValue: value };
|
|
96
|
+
return this.cloneWithModifiers(newMods);
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* Adds email format validation.
|
|
100
|
+
*/
|
|
101
|
+
email() {
|
|
102
|
+
const newMods = { ...this.modifiers, format: "email" };
|
|
103
|
+
return this.cloneWithModifiers(newMods);
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* Sets minimum string length.
|
|
107
|
+
*/
|
|
108
|
+
min(n) {
|
|
109
|
+
const newMods = { ...this.modifiers, min: n };
|
|
110
|
+
return this.cloneWithModifiers(newMods);
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* Sets maximum string length.
|
|
114
|
+
*/
|
|
115
|
+
max(n) {
|
|
116
|
+
const newMods = { ...this.modifiers, max: n };
|
|
117
|
+
return this.cloneWithModifiers(newMods);
|
|
118
|
+
}
|
|
119
|
+
};
|
|
120
|
+
var UuidFieldBuilder = class _UuidFieldBuilder extends BaseFieldBuilder {
|
|
121
|
+
kind = "uuid";
|
|
122
|
+
get zodBase() {
|
|
123
|
+
let schema = z.string().uuid();
|
|
124
|
+
if (this.modifiers.min !== void 0) {
|
|
125
|
+
schema = schema.min(this.modifiers.min);
|
|
126
|
+
}
|
|
127
|
+
if (this.modifiers.max !== void 0) {
|
|
128
|
+
schema = schema.max(this.modifiers.max);
|
|
129
|
+
}
|
|
130
|
+
return this.applyModifiersToZod(schema);
|
|
131
|
+
}
|
|
132
|
+
drizzleColumn(name) {
|
|
133
|
+
let col = text(name);
|
|
134
|
+
if (!this.modifiers.optional) {
|
|
135
|
+
col = col.notNull();
|
|
136
|
+
}
|
|
137
|
+
if (this.modifiers.primary) {
|
|
138
|
+
col = col.primaryKey();
|
|
139
|
+
}
|
|
140
|
+
if (this.modifiers.unique) {
|
|
141
|
+
col = col.unique();
|
|
142
|
+
}
|
|
143
|
+
if (this.modifiers.hasDefault) {
|
|
144
|
+
const defaultValue = this.modifiers.defaultValue;
|
|
145
|
+
if (typeof defaultValue === "function") {
|
|
146
|
+
col = col.$defaultFn(defaultValue);
|
|
147
|
+
} else {
|
|
148
|
+
col = col.default(defaultValue);
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
return col;
|
|
152
|
+
}
|
|
153
|
+
cloneWithModifiers(mods) {
|
|
154
|
+
return new _UuidFieldBuilder(mods);
|
|
155
|
+
}
|
|
156
|
+
/**
|
|
157
|
+
* Marks this field as optional (allows undefined / null).
|
|
158
|
+
*/
|
|
159
|
+
optional() {
|
|
160
|
+
const newMods = { ...this.modifiers, optional: true };
|
|
161
|
+
return new _UuidFieldBuilder(newMods);
|
|
162
|
+
}
|
|
163
|
+
/**
|
|
164
|
+
* Marks this field as the primary key of its table.
|
|
165
|
+
*/
|
|
166
|
+
primary() {
|
|
167
|
+
const newMods = { ...this.modifiers, primary: true };
|
|
168
|
+
return this.cloneWithModifiers(newMods);
|
|
169
|
+
}
|
|
170
|
+
/**
|
|
171
|
+
* Adds a unique constraint to this field.
|
|
172
|
+
*/
|
|
173
|
+
unique() {
|
|
174
|
+
const newMods = { ...this.modifiers, unique: true };
|
|
175
|
+
return this.cloneWithModifiers(newMods);
|
|
176
|
+
}
|
|
177
|
+
/**
|
|
178
|
+
* Sets a default value for this field.
|
|
179
|
+
*/
|
|
180
|
+
default(value) {
|
|
181
|
+
const newMods = { ...this.modifiers, hasDefault: true, defaultValue: value };
|
|
182
|
+
return this.cloneWithModifiers(newMods);
|
|
183
|
+
}
|
|
184
|
+
/**
|
|
185
|
+
* Sets minimum string length.
|
|
186
|
+
*/
|
|
187
|
+
min(n) {
|
|
188
|
+
const newMods = { ...this.modifiers, min: n };
|
|
189
|
+
return this.cloneWithModifiers(newMods);
|
|
190
|
+
}
|
|
191
|
+
/**
|
|
192
|
+
* Sets maximum string length.
|
|
193
|
+
*/
|
|
194
|
+
max(n) {
|
|
195
|
+
const newMods = { ...this.modifiers, max: n };
|
|
196
|
+
return this.cloneWithModifiers(newMods);
|
|
197
|
+
}
|
|
198
|
+
};
|
|
199
|
+
var NumberFieldBuilder = class _NumberFieldBuilder extends BaseFieldBuilder {
|
|
200
|
+
kind = "number";
|
|
201
|
+
get zodBase() {
|
|
202
|
+
let schema = z.number();
|
|
203
|
+
if (this.modifiers.min !== void 0) {
|
|
204
|
+
schema = schema.min(this.modifiers.min);
|
|
205
|
+
}
|
|
206
|
+
if (this.modifiers.max !== void 0) {
|
|
207
|
+
schema = schema.max(this.modifiers.max);
|
|
208
|
+
}
|
|
209
|
+
return this.applyModifiersToZod(schema);
|
|
210
|
+
}
|
|
211
|
+
drizzleColumn(name) {
|
|
212
|
+
let col = real(name);
|
|
213
|
+
if (!this.modifiers.optional) {
|
|
214
|
+
col = col.notNull();
|
|
215
|
+
}
|
|
216
|
+
if (this.modifiers.primary) {
|
|
217
|
+
col = col.primaryKey();
|
|
218
|
+
}
|
|
219
|
+
if (this.modifiers.unique) {
|
|
220
|
+
col = col.unique();
|
|
221
|
+
}
|
|
222
|
+
if (this.modifiers.hasDefault) {
|
|
223
|
+
const defaultValue = this.modifiers.defaultValue;
|
|
224
|
+
if (typeof defaultValue === "function") {
|
|
225
|
+
col = col.$defaultFn(defaultValue);
|
|
226
|
+
} else {
|
|
227
|
+
col = col.default(defaultValue);
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
return col;
|
|
231
|
+
}
|
|
232
|
+
cloneWithModifiers(mods) {
|
|
233
|
+
return new _NumberFieldBuilder(mods);
|
|
234
|
+
}
|
|
235
|
+
/**
|
|
236
|
+
* Marks this field as optional (allows undefined / null).
|
|
237
|
+
*/
|
|
238
|
+
optional() {
|
|
239
|
+
const newMods = { ...this.modifiers, optional: true };
|
|
240
|
+
return new _NumberFieldBuilder(newMods);
|
|
241
|
+
}
|
|
242
|
+
/**
|
|
243
|
+
* Marks this field as the primary key of its table.
|
|
244
|
+
*/
|
|
245
|
+
primary() {
|
|
246
|
+
const newMods = { ...this.modifiers, primary: true };
|
|
247
|
+
return this.cloneWithModifiers(newMods);
|
|
248
|
+
}
|
|
249
|
+
/**
|
|
250
|
+
* Adds a unique constraint to this field.
|
|
251
|
+
*/
|
|
252
|
+
unique() {
|
|
253
|
+
const newMods = { ...this.modifiers, unique: true };
|
|
254
|
+
return this.cloneWithModifiers(newMods);
|
|
255
|
+
}
|
|
256
|
+
/**
|
|
257
|
+
* Sets a default value for this field.
|
|
258
|
+
*/
|
|
259
|
+
default(value) {
|
|
260
|
+
const newMods = { ...this.modifiers, hasDefault: true, defaultValue: value };
|
|
261
|
+
return this.cloneWithModifiers(newMods);
|
|
262
|
+
}
|
|
263
|
+
/**
|
|
264
|
+
* Sets minimum value.
|
|
265
|
+
*/
|
|
266
|
+
min(n) {
|
|
267
|
+
const newMods = { ...this.modifiers, min: n };
|
|
268
|
+
return this.cloneWithModifiers(newMods);
|
|
269
|
+
}
|
|
270
|
+
/**
|
|
271
|
+
* Sets maximum value.
|
|
272
|
+
*/
|
|
273
|
+
max(n) {
|
|
274
|
+
const newMods = { ...this.modifiers, max: n };
|
|
275
|
+
return this.cloneWithModifiers(newMods);
|
|
276
|
+
}
|
|
277
|
+
};
|
|
278
|
+
var IntegerFieldBuilder = class _IntegerFieldBuilder extends BaseFieldBuilder {
|
|
279
|
+
kind = "integer";
|
|
280
|
+
get zodBase() {
|
|
281
|
+
let schema = z.number().int();
|
|
282
|
+
if (this.modifiers.min !== void 0) {
|
|
283
|
+
schema = schema.min(this.modifiers.min);
|
|
284
|
+
}
|
|
285
|
+
if (this.modifiers.max !== void 0) {
|
|
286
|
+
schema = schema.max(this.modifiers.max);
|
|
287
|
+
}
|
|
288
|
+
return this.applyModifiersToZod(schema);
|
|
289
|
+
}
|
|
290
|
+
drizzleColumn(name) {
|
|
291
|
+
let col = integer(name);
|
|
292
|
+
if (!this.modifiers.optional) {
|
|
293
|
+
col = col.notNull();
|
|
294
|
+
}
|
|
295
|
+
if (this.modifiers.primary) {
|
|
296
|
+
col = col.primaryKey();
|
|
297
|
+
}
|
|
298
|
+
if (this.modifiers.unique) {
|
|
299
|
+
col = col.unique();
|
|
300
|
+
}
|
|
301
|
+
if (this.modifiers.hasDefault) {
|
|
302
|
+
const defaultValue = this.modifiers.defaultValue;
|
|
303
|
+
if (typeof defaultValue === "function") {
|
|
304
|
+
col = col.$defaultFn(defaultValue);
|
|
305
|
+
} else {
|
|
306
|
+
col = col.default(defaultValue);
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
return col;
|
|
310
|
+
}
|
|
311
|
+
cloneWithModifiers(mods) {
|
|
312
|
+
return new _IntegerFieldBuilder(mods);
|
|
313
|
+
}
|
|
314
|
+
/**
|
|
315
|
+
* Marks this field as optional (allows undefined / null).
|
|
316
|
+
*/
|
|
317
|
+
optional() {
|
|
318
|
+
const newMods = { ...this.modifiers, optional: true };
|
|
319
|
+
return new _IntegerFieldBuilder(newMods);
|
|
320
|
+
}
|
|
321
|
+
/**
|
|
322
|
+
* Marks this field as the primary key of its table.
|
|
323
|
+
*/
|
|
324
|
+
primary() {
|
|
325
|
+
const newMods = { ...this.modifiers, primary: true };
|
|
326
|
+
return this.cloneWithModifiers(newMods);
|
|
327
|
+
}
|
|
328
|
+
/**
|
|
329
|
+
* Adds a unique constraint to this field.
|
|
330
|
+
*/
|
|
331
|
+
unique() {
|
|
332
|
+
const newMods = { ...this.modifiers, unique: true };
|
|
333
|
+
return this.cloneWithModifiers(newMods);
|
|
334
|
+
}
|
|
335
|
+
/**
|
|
336
|
+
* Sets a default value for this field.
|
|
337
|
+
*/
|
|
338
|
+
default(value) {
|
|
339
|
+
const newMods = { ...this.modifiers, hasDefault: true, defaultValue: value };
|
|
340
|
+
return this.cloneWithModifiers(newMods);
|
|
341
|
+
}
|
|
342
|
+
/**
|
|
343
|
+
* Sets minimum value.
|
|
344
|
+
*/
|
|
345
|
+
min(n) {
|
|
346
|
+
const newMods = { ...this.modifiers, min: n };
|
|
347
|
+
return this.cloneWithModifiers(newMods);
|
|
348
|
+
}
|
|
349
|
+
/**
|
|
350
|
+
* Sets maximum value.
|
|
351
|
+
*/
|
|
352
|
+
max(n) {
|
|
353
|
+
const newMods = { ...this.modifiers, max: n };
|
|
354
|
+
return this.cloneWithModifiers(newMods);
|
|
355
|
+
}
|
|
356
|
+
};
|
|
357
|
+
var BooleanFieldBuilder = class _BooleanFieldBuilder extends BaseFieldBuilder {
|
|
358
|
+
kind = "boolean";
|
|
359
|
+
get zodBase() {
|
|
360
|
+
return this.applyModifiersToZod(z.boolean());
|
|
361
|
+
}
|
|
362
|
+
drizzleColumn(name) {
|
|
363
|
+
let col = integer(name, { mode: "boolean" });
|
|
364
|
+
if (!this.modifiers.optional) {
|
|
365
|
+
col = col.notNull();
|
|
366
|
+
}
|
|
367
|
+
if (this.modifiers.primary) {
|
|
368
|
+
col = col.primaryKey();
|
|
369
|
+
}
|
|
370
|
+
if (this.modifiers.unique) {
|
|
371
|
+
col = col.unique();
|
|
372
|
+
}
|
|
373
|
+
if (this.modifiers.hasDefault) {
|
|
374
|
+
const defaultValue = this.modifiers.defaultValue;
|
|
375
|
+
if (typeof defaultValue === "function") {
|
|
376
|
+
col = col.$defaultFn(defaultValue);
|
|
377
|
+
} else {
|
|
378
|
+
col = col.default(defaultValue);
|
|
379
|
+
}
|
|
380
|
+
}
|
|
381
|
+
return col;
|
|
382
|
+
}
|
|
383
|
+
cloneWithModifiers(mods) {
|
|
384
|
+
return new _BooleanFieldBuilder(mods);
|
|
385
|
+
}
|
|
386
|
+
/**
|
|
387
|
+
* Marks this field as optional (allows undefined / null).
|
|
388
|
+
*/
|
|
389
|
+
optional() {
|
|
390
|
+
const newMods = { ...this.modifiers, optional: true };
|
|
391
|
+
return new _BooleanFieldBuilder(newMods);
|
|
392
|
+
}
|
|
393
|
+
/**
|
|
394
|
+
* Marks this field as the primary key of its table.
|
|
395
|
+
*/
|
|
396
|
+
primary() {
|
|
397
|
+
const newMods = { ...this.modifiers, primary: true };
|
|
398
|
+
return this.cloneWithModifiers(newMods);
|
|
399
|
+
}
|
|
400
|
+
/**
|
|
401
|
+
* Adds a unique constraint to this field.
|
|
402
|
+
*/
|
|
403
|
+
unique() {
|
|
404
|
+
const newMods = { ...this.modifiers, unique: true };
|
|
405
|
+
return this.cloneWithModifiers(newMods);
|
|
406
|
+
}
|
|
407
|
+
/**
|
|
408
|
+
* Sets a default value for this field.
|
|
409
|
+
*/
|
|
410
|
+
default(value) {
|
|
411
|
+
const newMods = { ...this.modifiers, hasDefault: true, defaultValue: value };
|
|
412
|
+
return this.cloneWithModifiers(newMods);
|
|
413
|
+
}
|
|
414
|
+
};
|
|
415
|
+
var TimestampFieldBuilder = class _TimestampFieldBuilder extends BaseFieldBuilder {
|
|
416
|
+
kind = "timestamp";
|
|
417
|
+
get zodBase() {
|
|
418
|
+
return this.applyModifiersToZod(z.coerce.date());
|
|
419
|
+
}
|
|
420
|
+
drizzleColumn(name) {
|
|
421
|
+
let col = integer(name, { mode: "timestamp_ms" });
|
|
422
|
+
if (!this.modifiers.optional) {
|
|
423
|
+
col = col.notNull();
|
|
424
|
+
}
|
|
425
|
+
if (this.modifiers.primary) {
|
|
426
|
+
col = col.primaryKey();
|
|
427
|
+
}
|
|
428
|
+
if (this.modifiers.unique) {
|
|
429
|
+
col = col.unique();
|
|
430
|
+
}
|
|
431
|
+
if (this.modifiers.hasDefault) {
|
|
432
|
+
const defaultValue = this.modifiers.defaultValue;
|
|
433
|
+
if (typeof defaultValue === "function") {
|
|
434
|
+
col = col.$defaultFn(defaultValue);
|
|
435
|
+
} else {
|
|
436
|
+
col = col.default(defaultValue);
|
|
437
|
+
}
|
|
438
|
+
}
|
|
439
|
+
return col;
|
|
440
|
+
}
|
|
441
|
+
cloneWithModifiers(mods) {
|
|
442
|
+
return new _TimestampFieldBuilder(mods);
|
|
443
|
+
}
|
|
444
|
+
/**
|
|
445
|
+
* Marks this field as optional (allows undefined / null).
|
|
446
|
+
*/
|
|
447
|
+
optional() {
|
|
448
|
+
const newMods = { ...this.modifiers, optional: true };
|
|
449
|
+
return new _TimestampFieldBuilder(newMods);
|
|
450
|
+
}
|
|
451
|
+
/**
|
|
452
|
+
* Marks this field as the primary key of its table.
|
|
453
|
+
*/
|
|
454
|
+
primary() {
|
|
455
|
+
const newMods = { ...this.modifiers, primary: true };
|
|
456
|
+
return this.cloneWithModifiers(newMods);
|
|
457
|
+
}
|
|
458
|
+
/**
|
|
459
|
+
* Adds a unique constraint to this field.
|
|
460
|
+
*/
|
|
461
|
+
unique() {
|
|
462
|
+
const newMods = { ...this.modifiers, unique: true };
|
|
463
|
+
return this.cloneWithModifiers(newMods);
|
|
464
|
+
}
|
|
465
|
+
/**
|
|
466
|
+
* Sets a default value for this field.
|
|
467
|
+
*/
|
|
468
|
+
default(value) {
|
|
469
|
+
const newMods = { ...this.modifiers, hasDefault: true, defaultValue: value };
|
|
470
|
+
return this.cloneWithModifiers(newMods);
|
|
471
|
+
}
|
|
472
|
+
};
|
|
473
|
+
var JsonFieldBuilder = class _JsonFieldBuilder extends BaseFieldBuilder {
|
|
474
|
+
kind = "json";
|
|
475
|
+
get zodBase() {
|
|
476
|
+
return this.applyModifiersToZod(z.unknown());
|
|
477
|
+
}
|
|
478
|
+
drizzleColumn(name) {
|
|
479
|
+
let col = text(name, { mode: "json" }).$type();
|
|
480
|
+
if (!this.modifiers.optional) {
|
|
481
|
+
col = col.notNull();
|
|
482
|
+
}
|
|
483
|
+
if (this.modifiers.primary) {
|
|
484
|
+
col = col.primaryKey();
|
|
485
|
+
}
|
|
486
|
+
if (this.modifiers.unique) {
|
|
487
|
+
col = col.unique();
|
|
488
|
+
}
|
|
489
|
+
if (this.modifiers.hasDefault) {
|
|
490
|
+
const defaultValue = this.modifiers.defaultValue;
|
|
491
|
+
if (typeof defaultValue === "function") {
|
|
492
|
+
col = col.$defaultFn(defaultValue);
|
|
493
|
+
} else {
|
|
494
|
+
col = col.default(defaultValue);
|
|
495
|
+
}
|
|
496
|
+
}
|
|
497
|
+
return col;
|
|
498
|
+
}
|
|
499
|
+
cloneWithModifiers(mods) {
|
|
500
|
+
return new _JsonFieldBuilder(mods);
|
|
501
|
+
}
|
|
502
|
+
/**
|
|
503
|
+
* Marks this field as optional (allows undefined / null).
|
|
504
|
+
*/
|
|
505
|
+
optional() {
|
|
506
|
+
const newMods = { ...this.modifiers, optional: true };
|
|
507
|
+
return new _JsonFieldBuilder(newMods);
|
|
508
|
+
}
|
|
509
|
+
/**
|
|
510
|
+
* Marks this field as the primary key of its table.
|
|
511
|
+
*/
|
|
512
|
+
primary() {
|
|
513
|
+
const newMods = { ...this.modifiers, primary: true };
|
|
514
|
+
return this.cloneWithModifiers(newMods);
|
|
515
|
+
}
|
|
516
|
+
/**
|
|
517
|
+
* Adds a unique constraint to this field.
|
|
518
|
+
*/
|
|
519
|
+
unique() {
|
|
520
|
+
const newMods = { ...this.modifiers, unique: true };
|
|
521
|
+
return this.cloneWithModifiers(newMods);
|
|
522
|
+
}
|
|
523
|
+
/**
|
|
524
|
+
* Sets a default value for this field.
|
|
525
|
+
*/
|
|
526
|
+
default(value) {
|
|
527
|
+
const newMods = { ...this.modifiers, hasDefault: true, defaultValue: value };
|
|
528
|
+
return this.cloneWithModifiers(newMods);
|
|
529
|
+
}
|
|
530
|
+
};
|
|
531
|
+
var t = {
|
|
532
|
+
string() {
|
|
533
|
+
return new StringFieldBuilder();
|
|
534
|
+
},
|
|
535
|
+
uuid() {
|
|
536
|
+
return new UuidFieldBuilder();
|
|
537
|
+
},
|
|
538
|
+
number() {
|
|
539
|
+
return new NumberFieldBuilder();
|
|
540
|
+
},
|
|
541
|
+
integer() {
|
|
542
|
+
return new IntegerFieldBuilder();
|
|
543
|
+
},
|
|
544
|
+
boolean() {
|
|
545
|
+
return new BooleanFieldBuilder();
|
|
546
|
+
},
|
|
547
|
+
timestamp() {
|
|
548
|
+
return new TimestampFieldBuilder();
|
|
549
|
+
},
|
|
550
|
+
/**
|
|
551
|
+
* JSON フィールド。任意の JSON 値を受け入れる(Zod 内部表現は `z.unknown()`)。
|
|
552
|
+
*
|
|
553
|
+
* ⚠️ セキュリティ警告:
|
|
554
|
+
* このフィールドの zod ベースは `z.unknown()` のため、型パラメータ `T` で
|
|
555
|
+
* 指定した制約は **コンパイル時のみ** 適用され、validator() 経由でも
|
|
556
|
+
* runtime バリデーションは行われません。API 入力として晒す場合は:
|
|
557
|
+
* - `model.validator(target, { omit: ['<json field name>'] })` で除外する、または
|
|
558
|
+
* - ハンドラ側で別途 Zod スキーマを使って手動検証する、
|
|
559
|
+
* のいずれかを必ず実施してください。型パラメータが `unknown` 以外の値を
|
|
560
|
+
* runtime で保証することはありません。
|
|
561
|
+
*
|
|
562
|
+
* Phase 2 以降で `t.json(zodSchema)` 形式の引数追加を検討中。
|
|
563
|
+
*/
|
|
564
|
+
json() {
|
|
565
|
+
return new JsonFieldBuilder();
|
|
566
|
+
}
|
|
567
|
+
};
|
|
568
|
+
|
|
569
|
+
export { t };
|
|
570
|
+
//# sourceMappingURL=chunk-F5OBRXXY.js.map
|
|
571
|
+
//# sourceMappingURL=chunk-F5OBRXXY.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/field/builder.ts","../src/field/factories.ts"],"names":["zLib"],"mappings":";;;;;;AAiBO,IAAe,mBAAf,MAMP;AAAA,EACW,MAAA,GAAa,MAAA;AAAA,EAEb,SAAA;AAAA,EAET,YAAY,SAAA,EAAkB;AAC5B,IAAA,IAAA,CAAK,SAAA,GAAY,MAAA,CAAO,MAAA,CAAQ,SAAA,IAAa,EAAW,CAAA;AAAA,EA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-F5OBRXXY.js","sourcesContent":["import type { SQLiteColumnBuilderBase } from 'drizzle-orm/sqlite-core'\nimport type { z } from 'zod'\nimport type { Field, FieldKind, FieldModifiers } from './types'\n\n/**\n * Abstract base class for field builders.\n * Provides shared implementation for Zod and Drizzle integration.\n *\n * Subclasses must implement:\n * - `zodBase: ZB` getter\n * - `drizzleColumn(name: string): SQLiteColumnBuilderBase` method\n * - Modifier chain methods (optional, primary, unique, default) that return the subclass type\n *\n * @template TS - The TypeScript type of the field\n * @template Mods - The type of modifiers currently applied\n * @template ZB - The Zod base schema type for this field\n */\nexport abstract class BaseFieldBuilder<\n TS,\n // biome-ignore lint/complexity/noBannedTypes: {} is used intentionally for the default empty modifiers\n Mods extends FieldModifiers = {},\n ZB extends z.ZodTypeAny = z.ZodTypeAny,\n> implements Field<TS, Mods, ZB>\n{\n readonly tsType: TS = undefined as unknown as TS\n abstract readonly kind: FieldKind\n readonly modifiers: Readonly<Mods>\n\n constructor(modifiers?: Mods) {\n this.modifiers = Object.freeze((modifiers ?? {}) as Mods)\n }\n\n abstract get zodBase(): ZB\n abstract drizzleColumn(name: string): SQLiteColumnBuilderBase\n\n /**\n * Creates an immutable copy of this field with updated modifiers.\n * Subclasses must implement this to maintain their concrete type.\n */\n // biome-ignore lint/suspicious/noExplicitAny: Field builders return polymorphic types\n protected abstract cloneWithModifiers(mods: FieldModifiers): any\n\n /**\n * Returns the Zod schema with all modifiers applied.\n * Order: base schema → format/min/max constraints → optional → default\n */\n protected applyModifiersToZod(baseSchema: z.ZodTypeAny): z.ZodTypeAny {\n let schema = baseSchema\n\n // Apply optional\n if (this.modifiers.optional) {\n schema = schema.optional()\n }\n\n // Apply default\n if (this.modifiers.hasDefault) {\n const defaultValue = this.modifiers.defaultValue\n schema = schema.default(defaultValue)\n }\n\n return schema\n }\n}\n","import type { SQLiteColumnBuilderBase } from 'drizzle-orm/sqlite-core'\nimport { integer, real, text } from 'drizzle-orm/sqlite-core'\nimport type { z } from 'zod'\nimport { z as zLib } from 'zod'\nimport { BaseFieldBuilder } from './builder'\nimport type { FieldModifiers } from './types'\n\n// ==================== StringFieldBuilder ====================\n\nclass StringFieldBuilder<\n TS = string,\n // biome-ignore lint/complexity/noBannedTypes: {} is used intentionally for the default empty modifiers\n Mods extends FieldModifiers = {},\n ZB extends z.ZodType<TS, z.ZodTypeDef, TS> = z.ZodType<TS, z.ZodTypeDef, TS>,\n> extends BaseFieldBuilder<TS, Mods, ZB> {\n readonly kind = 'string' as const\n\n get zodBase(): ZB {\n let schema: z.ZodTypeAny = zLib.string()\n\n if (this.modifiers.min !== undefined) {\n // biome-ignore lint/suspicious/noExplicitAny: Chaining Zod methods\n schema = (schema as any).min(this.modifiers.min)\n }\n if (this.modifiers.max !== undefined) {\n // biome-ignore lint/suspicious/noExplicitAny: Chaining Zod methods\n schema = (schema as any).max(this.modifiers.max)\n }\n if (this.modifiers.format === 'email') {\n // biome-ignore lint/suspicious/noExplicitAny: Chaining Zod methods\n schema = (schema as any).email()\n }\n\n // biome-ignore lint/suspicious/noExplicitAny: Return type cast for generic ZB parameter\n return this.applyModifiersToZod(schema) as any\n }\n\n drizzleColumn(name: string): SQLiteColumnBuilderBase {\n // biome-ignore lint/suspicious/noExplicitAny: Drizzle column builder chaining\n let col = text(name) as any\n\n if (!this.modifiers.optional) {\n col = col.notNull()\n }\n if (this.modifiers.primary) {\n col = col.primaryKey()\n }\n if (this.modifiers.unique) {\n col = col.unique()\n }\n if (this.modifiers.hasDefault) {\n const defaultValue = this.modifiers.defaultValue\n if (typeof defaultValue === 'function') {\n // biome-ignore lint/suspicious/noExplicitAny: Drizzle API\n col = col.$defaultFn(defaultValue as any)\n } else {\n // biome-ignore lint/suspicious/noExplicitAny: Drizzle API\n col = col.default(defaultValue as any)\n }\n }\n\n return col as SQLiteColumnBuilderBase\n }\n\n protected cloneWithModifiers<NewMods extends FieldModifiers>(\n mods: NewMods,\n ): StringFieldBuilder<TS, NewMods> {\n return new StringFieldBuilder<TS, NewMods>(mods)\n }\n\n /**\n * Marks this field as optional (allows undefined / null).\n */\n optional(\n this: StringFieldBuilder<TS, Mods>,\n ): StringFieldBuilder<TS | undefined, Mods & { optional: true }> {\n const newMods = { ...this.modifiers, optional: true } as Mods & { optional: true }\n return new StringFieldBuilder<TS | undefined, Mods & { optional: true }>(newMods)\n }\n\n /**\n * Marks this field as the primary key of its table.\n */\n primary(this: StringFieldBuilder<TS, Mods>): StringFieldBuilder<TS, Mods & { primary: true }> {\n const newMods = { ...this.modifiers, primary: true } as Mods & { primary: true }\n return this.cloneWithModifiers(newMods)\n }\n\n /**\n * Adds a unique constraint to this field.\n */\n unique(this: StringFieldBuilder<TS, Mods>): StringFieldBuilder<TS, Mods & { unique: true }> {\n const newMods = { ...this.modifiers, unique: true } as Mods & { unique: true }\n return this.cloneWithModifiers(newMods)\n }\n\n /**\n * Sets a default value for this field.\n */\n default(\n this: StringFieldBuilder<TS, Mods>,\n value: TS | (() => TS),\n ): StringFieldBuilder<TS, Mods & { hasDefault: true }> {\n const newMods = { ...this.modifiers, hasDefault: true, defaultValue: value } as Mods & {\n hasDefault: true\n }\n return this.cloneWithModifiers(newMods)\n }\n\n /**\n * Adds email format validation.\n */\n email(this: StringFieldBuilder<TS, Mods>): StringFieldBuilder<TS, Mods & { format: 'email' }> {\n const newMods = { ...this.modifiers, format: 'email' as const } as Mods & { format: 'email' }\n return this.cloneWithModifiers(newMods)\n }\n\n /**\n * Sets minimum string length.\n */\n min(\n this: StringFieldBuilder<TS, Mods>,\n n: number,\n ): StringFieldBuilder<TS, Mods & { min: number }> {\n const newMods = { ...this.modifiers, min: n } as Mods & { min: number }\n return this.cloneWithModifiers(newMods)\n }\n\n /**\n * Sets maximum string length.\n */\n max(\n this: StringFieldBuilder<TS, Mods>,\n n: number,\n ): StringFieldBuilder<TS, Mods & { max: number }> {\n const newMods = { ...this.modifiers, max: n } as Mods & { max: number }\n return this.cloneWithModifiers(newMods)\n }\n}\n\n// ==================== UuidFieldBuilder ====================\n\nclass UuidFieldBuilder<\n TS = string,\n // biome-ignore lint/complexity/noBannedTypes: {} is used intentionally for the default empty modifiers\n Mods extends FieldModifiers = {},\n ZB extends z.ZodType<TS, z.ZodTypeDef, TS> = z.ZodType<TS, z.ZodTypeDef, TS>,\n> extends BaseFieldBuilder<TS, Mods, ZB> {\n readonly kind = 'uuid' as const\n\n get zodBase(): ZB {\n let schema: z.ZodTypeAny = zLib.string().uuid()\n\n if (this.modifiers.min !== undefined) {\n // biome-ignore lint/suspicious/noExplicitAny: Chaining Zod methods\n schema = (schema as any).min(this.modifiers.min)\n }\n if (this.modifiers.max !== undefined) {\n // biome-ignore lint/suspicious/noExplicitAny: Chaining Zod methods\n schema = (schema as any).max(this.modifiers.max)\n }\n\n // biome-ignore lint/suspicious/noExplicitAny: Return type cast for generic ZB parameter\n return this.applyModifiersToZod(schema) as any\n }\n\n drizzleColumn(name: string): SQLiteColumnBuilderBase {\n // biome-ignore lint/suspicious/noExplicitAny: Drizzle column builder chaining\n let col = text(name) as any\n\n if (!this.modifiers.optional) {\n col = col.notNull()\n }\n if (this.modifiers.primary) {\n col = col.primaryKey()\n }\n if (this.modifiers.unique) {\n col = col.unique()\n }\n if (this.modifiers.hasDefault) {\n const defaultValue = this.modifiers.defaultValue\n if (typeof defaultValue === 'function') {\n // biome-ignore lint/suspicious/noExplicitAny: Drizzle API\n col = col.$defaultFn(defaultValue as any)\n } else {\n // biome-ignore lint/suspicious/noExplicitAny: Drizzle API\n col = col.default(defaultValue as any)\n }\n }\n\n return col as SQLiteColumnBuilderBase\n }\n\n protected cloneWithModifiers<NewMods extends FieldModifiers>(\n mods: NewMods,\n ): UuidFieldBuilder<TS, NewMods> {\n return new UuidFieldBuilder<TS, NewMods>(mods)\n }\n\n /**\n * Marks this field as optional (allows undefined / null).\n */\n optional(\n this: UuidFieldBuilder<TS, Mods>,\n ): UuidFieldBuilder<TS | undefined, Mods & { optional: true }> {\n const newMods = { ...this.modifiers, optional: true } as Mods & { optional: true }\n return new UuidFieldBuilder<TS | undefined, Mods & { optional: true }>(newMods)\n }\n\n /**\n * Marks this field as the primary key of its table.\n */\n primary(this: UuidFieldBuilder<TS, Mods>): UuidFieldBuilder<TS, Mods & { primary: true }> {\n const newMods = { ...this.modifiers, primary: true } as Mods & { primary: true }\n return this.cloneWithModifiers(newMods)\n }\n\n /**\n * Adds a unique constraint to this field.\n */\n unique(this: UuidFieldBuilder<TS, Mods>): UuidFieldBuilder<TS, Mods & { unique: true }> {\n const newMods = { ...this.modifiers, unique: true } as Mods & { unique: true }\n return this.cloneWithModifiers(newMods)\n }\n\n /**\n * Sets a default value for this field.\n */\n default(\n this: UuidFieldBuilder<TS, Mods>,\n value: TS | (() => TS),\n ): UuidFieldBuilder<TS, Mods & { hasDefault: true }> {\n const newMods = { ...this.modifiers, hasDefault: true, defaultValue: value } as Mods & {\n hasDefault: true\n }\n return this.cloneWithModifiers(newMods)\n }\n\n /**\n * Sets minimum string length.\n */\n min(this: UuidFieldBuilder<TS, Mods>, n: number): UuidFieldBuilder<TS, Mods & { min: number }> {\n const newMods = { ...this.modifiers, min: n } as Mods & { min: number }\n return this.cloneWithModifiers(newMods)\n }\n\n /**\n * Sets maximum string length.\n */\n max(this: UuidFieldBuilder<TS, Mods>, n: number): UuidFieldBuilder<TS, Mods & { max: number }> {\n const newMods = { ...this.modifiers, max: n } as Mods & { max: number }\n return this.cloneWithModifiers(newMods)\n }\n}\n\n// ==================== NumberFieldBuilder ====================\n\nclass NumberFieldBuilder<\n TS = number,\n // biome-ignore lint/complexity/noBannedTypes: {} is used intentionally for the default empty modifiers\n Mods extends FieldModifiers = {},\n ZB extends z.ZodType<TS, z.ZodTypeDef, TS> = z.ZodType<TS, z.ZodTypeDef, TS>,\n> extends BaseFieldBuilder<TS, Mods, ZB> {\n readonly kind = 'number' as const\n\n get zodBase(): ZB {\n let schema: z.ZodTypeAny = zLib.number()\n\n if (this.modifiers.min !== undefined) {\n // biome-ignore lint/suspicious/noExplicitAny: Chaining Zod methods\n schema = (schema as any).min(this.modifiers.min)\n }\n if (this.modifiers.max !== undefined) {\n // biome-ignore lint/suspicious/noExplicitAny: Chaining Zod methods\n schema = (schema as any).max(this.modifiers.max)\n }\n\n // biome-ignore lint/suspicious/noExplicitAny: Return type cast for generic ZB parameter\n return this.applyModifiersToZod(schema) as any\n }\n\n drizzleColumn(name: string): SQLiteColumnBuilderBase {\n // biome-ignore lint/suspicious/noExplicitAny: Drizzle column builder chaining\n let col = real(name) as any\n\n if (!this.modifiers.optional) {\n col = col.notNull()\n }\n if (this.modifiers.primary) {\n col = col.primaryKey()\n }\n if (this.modifiers.unique) {\n col = col.unique()\n }\n if (this.modifiers.hasDefault) {\n const defaultValue = this.modifiers.defaultValue\n if (typeof defaultValue === 'function') {\n // biome-ignore lint/suspicious/noExplicitAny: Drizzle API\n col = col.$defaultFn(defaultValue as any)\n } else {\n // biome-ignore lint/suspicious/noExplicitAny: Drizzle API\n col = col.default(defaultValue as any)\n }\n }\n\n return col as SQLiteColumnBuilderBase\n }\n\n protected cloneWithModifiers<NewMods extends FieldModifiers>(\n mods: NewMods,\n ): NumberFieldBuilder<TS, NewMods> {\n return new NumberFieldBuilder<TS, NewMods>(mods)\n }\n\n /**\n * Marks this field as optional (allows undefined / null).\n */\n optional(\n this: NumberFieldBuilder<TS, Mods>,\n ): NumberFieldBuilder<TS | undefined, Mods & { optional: true }> {\n const newMods = { ...this.modifiers, optional: true } as Mods & { optional: true }\n return new NumberFieldBuilder<TS | undefined, Mods & { optional: true }>(newMods)\n }\n\n /**\n * Marks this field as the primary key of its table.\n */\n primary(this: NumberFieldBuilder<TS, Mods>): NumberFieldBuilder<TS, Mods & { primary: true }> {\n const newMods = { ...this.modifiers, primary: true } as Mods & { primary: true }\n return this.cloneWithModifiers(newMods)\n }\n\n /**\n * Adds a unique constraint to this field.\n */\n unique(this: NumberFieldBuilder<TS, Mods>): NumberFieldBuilder<TS, Mods & { unique: true }> {\n const newMods = { ...this.modifiers, unique: true } as Mods & { unique: true }\n return this.cloneWithModifiers(newMods)\n }\n\n /**\n * Sets a default value for this field.\n */\n default(\n this: NumberFieldBuilder<TS, Mods>,\n value: TS | (() => TS),\n ): NumberFieldBuilder<TS, Mods & { hasDefault: true }> {\n const newMods = { ...this.modifiers, hasDefault: true, defaultValue: value } as Mods & {\n hasDefault: true\n }\n return this.cloneWithModifiers(newMods)\n }\n\n /**\n * Sets minimum value.\n */\n min(\n this: NumberFieldBuilder<TS, Mods>,\n n: number,\n ): NumberFieldBuilder<TS, Mods & { min: number }> {\n const newMods = { ...this.modifiers, min: n } as Mods & { min: number }\n return this.cloneWithModifiers(newMods)\n }\n\n /**\n * Sets maximum value.\n */\n max(\n this: NumberFieldBuilder<TS, Mods>,\n n: number,\n ): NumberFieldBuilder<TS, Mods & { max: number }> {\n const newMods = { ...this.modifiers, max: n } as Mods & { max: number }\n return this.cloneWithModifiers(newMods)\n }\n}\n\n// ==================== IntegerFieldBuilder ====================\n\nclass IntegerFieldBuilder<\n TS = number,\n // biome-ignore lint/complexity/noBannedTypes: {} is used intentionally for the default empty modifiers\n Mods extends FieldModifiers = {},\n ZB extends z.ZodType<TS, z.ZodTypeDef, TS> = z.ZodType<TS, z.ZodTypeDef, TS>,\n> extends BaseFieldBuilder<TS, Mods, ZB> {\n readonly kind = 'integer' as const\n\n get zodBase(): ZB {\n let schema: z.ZodTypeAny = zLib.number().int()\n\n if (this.modifiers.min !== undefined) {\n // biome-ignore lint/suspicious/noExplicitAny: Chaining Zod methods\n schema = (schema as any).min(this.modifiers.min)\n }\n if (this.modifiers.max !== undefined) {\n // biome-ignore lint/suspicious/noExplicitAny: Chaining Zod methods\n schema = (schema as any).max(this.modifiers.max)\n }\n\n // biome-ignore lint/suspicious/noExplicitAny: Return type cast for generic ZB parameter\n return this.applyModifiersToZod(schema) as any\n }\n\n drizzleColumn(name: string): SQLiteColumnBuilderBase {\n // biome-ignore lint/suspicious/noExplicitAny: Drizzle column builder chaining\n let col = integer(name) as any\n\n if (!this.modifiers.optional) {\n col = col.notNull()\n }\n if (this.modifiers.primary) {\n col = col.primaryKey()\n }\n if (this.modifiers.unique) {\n col = col.unique()\n }\n if (this.modifiers.hasDefault) {\n const defaultValue = this.modifiers.defaultValue\n if (typeof defaultValue === 'function') {\n // biome-ignore lint/suspicious/noExplicitAny: Drizzle API\n col = col.$defaultFn(defaultValue as any)\n } else {\n // biome-ignore lint/suspicious/noExplicitAny: Drizzle API\n col = col.default(defaultValue as any)\n }\n }\n\n return col as SQLiteColumnBuilderBase\n }\n\n protected cloneWithModifiers<NewMods extends FieldModifiers>(\n mods: NewMods,\n ): IntegerFieldBuilder<TS, NewMods> {\n return new IntegerFieldBuilder<TS, NewMods>(mods)\n }\n\n /**\n * Marks this field as optional (allows undefined / null).\n */\n optional(\n this: IntegerFieldBuilder<TS, Mods>,\n ): IntegerFieldBuilder<TS | undefined, Mods & { optional: true }> {\n const newMods = { ...this.modifiers, optional: true } as Mods & { optional: true }\n return new IntegerFieldBuilder<TS | undefined, Mods & { optional: true }>(newMods)\n }\n\n /**\n * Marks this field as the primary key of its table.\n */\n primary(this: IntegerFieldBuilder<TS, Mods>): IntegerFieldBuilder<TS, Mods & { primary: true }> {\n const newMods = { ...this.modifiers, primary: true } as Mods & { primary: true }\n return this.cloneWithModifiers(newMods)\n }\n\n /**\n * Adds a unique constraint to this field.\n */\n unique(this: IntegerFieldBuilder<TS, Mods>): IntegerFieldBuilder<TS, Mods & { unique: true }> {\n const newMods = { ...this.modifiers, unique: true } as Mods & { unique: true }\n return this.cloneWithModifiers(newMods)\n }\n\n /**\n * Sets a default value for this field.\n */\n default(\n this: IntegerFieldBuilder<TS, Mods>,\n value: TS | (() => TS),\n ): IntegerFieldBuilder<TS, Mods & { hasDefault: true }> {\n const newMods = { ...this.modifiers, hasDefault: true, defaultValue: value } as Mods & {\n hasDefault: true\n }\n return this.cloneWithModifiers(newMods)\n }\n\n /**\n * Sets minimum value.\n */\n min(\n this: IntegerFieldBuilder<TS, Mods>,\n n: number,\n ): IntegerFieldBuilder<TS, Mods & { min: number }> {\n const newMods = { ...this.modifiers, min: n } as Mods & { min: number }\n return this.cloneWithModifiers(newMods)\n }\n\n /**\n * Sets maximum value.\n */\n max(\n this: IntegerFieldBuilder<TS, Mods>,\n n: number,\n ): IntegerFieldBuilder<TS, Mods & { max: number }> {\n const newMods = { ...this.modifiers, max: n } as Mods & { max: number }\n return this.cloneWithModifiers(newMods)\n }\n}\n\n// ==================== BooleanFieldBuilder ====================\n\nclass BooleanFieldBuilder<\n TS = boolean,\n // biome-ignore lint/complexity/noBannedTypes: {} is used intentionally for the default empty modifiers\n Mods extends FieldModifiers = {},\n ZB extends z.ZodType<TS, z.ZodTypeDef, TS> = z.ZodType<TS, z.ZodTypeDef, TS>,\n> extends BaseFieldBuilder<TS, Mods, ZB> {\n readonly kind = 'boolean' as const\n\n get zodBase(): ZB {\n return this.applyModifiersToZod(zLib.boolean()) as ZB\n }\n\n drizzleColumn(name: string): SQLiteColumnBuilderBase {\n // biome-ignore lint/suspicious/noExplicitAny: Drizzle column builder chaining\n let col = integer(name, { mode: 'boolean' }) as any\n\n if (!this.modifiers.optional) {\n col = col.notNull()\n }\n if (this.modifiers.primary) {\n col = col.primaryKey()\n }\n if (this.modifiers.unique) {\n col = col.unique()\n }\n if (this.modifiers.hasDefault) {\n const defaultValue = this.modifiers.defaultValue\n if (typeof defaultValue === 'function') {\n // biome-ignore lint/suspicious/noExplicitAny: Drizzle API\n col = col.$defaultFn(defaultValue as any)\n } else {\n // biome-ignore lint/suspicious/noExplicitAny: Drizzle API\n col = col.default(defaultValue as any)\n }\n }\n\n return col as SQLiteColumnBuilderBase\n }\n\n protected cloneWithModifiers<NewMods extends FieldModifiers>(\n mods: NewMods,\n ): BooleanFieldBuilder<TS, NewMods> {\n return new BooleanFieldBuilder<TS, NewMods>(mods)\n }\n\n /**\n * Marks this field as optional (allows undefined / null).\n */\n optional(\n this: BooleanFieldBuilder<TS, Mods>,\n ): BooleanFieldBuilder<TS | undefined, Mods & { optional: true }> {\n const newMods = { ...this.modifiers, optional: true } as Mods & { optional: true }\n return new BooleanFieldBuilder<TS | undefined, Mods & { optional: true }>(newMods)\n }\n\n /**\n * Marks this field as the primary key of its table.\n */\n primary(this: BooleanFieldBuilder<TS, Mods>): BooleanFieldBuilder<TS, Mods & { primary: true }> {\n const newMods = { ...this.modifiers, primary: true } as Mods & { primary: true }\n return this.cloneWithModifiers(newMods)\n }\n\n /**\n * Adds a unique constraint to this field.\n */\n unique(this: BooleanFieldBuilder<TS, Mods>): BooleanFieldBuilder<TS, Mods & { unique: true }> {\n const newMods = { ...this.modifiers, unique: true } as Mods & { unique: true }\n return this.cloneWithModifiers(newMods)\n }\n\n /**\n * Sets a default value for this field.\n */\n default(\n this: BooleanFieldBuilder<TS, Mods>,\n value: TS | (() => TS),\n ): BooleanFieldBuilder<TS, Mods & { hasDefault: true }> {\n const newMods = { ...this.modifiers, hasDefault: true, defaultValue: value } as Mods & {\n hasDefault: true\n }\n return this.cloneWithModifiers(newMods)\n }\n}\n\n// ==================== TimestampFieldBuilder ====================\n\nclass TimestampFieldBuilder<\n TS = Date,\n // biome-ignore lint/complexity/noBannedTypes: {} is used intentionally for the default empty modifiers\n Mods extends FieldModifiers = {},\n ZB extends z.ZodType<TS, z.ZodTypeDef, Date | string | number> = z.ZodType<\n TS,\n z.ZodTypeDef,\n Date | string | number\n >,\n> extends BaseFieldBuilder<TS, Mods, ZB> {\n readonly kind = 'timestamp' as const\n\n get zodBase(): ZB {\n return this.applyModifiersToZod(zLib.coerce.date()) as ZB\n }\n\n drizzleColumn(name: string): SQLiteColumnBuilderBase {\n // biome-ignore lint/suspicious/noExplicitAny: Drizzle column builder chaining\n let col = integer(name, { mode: 'timestamp_ms' }) as any\n\n if (!this.modifiers.optional) {\n col = col.notNull()\n }\n if (this.modifiers.primary) {\n col = col.primaryKey()\n }\n if (this.modifiers.unique) {\n col = col.unique()\n }\n if (this.modifiers.hasDefault) {\n const defaultValue = this.modifiers.defaultValue\n if (typeof defaultValue === 'function') {\n // biome-ignore lint/suspicious/noExplicitAny: Drizzle API\n col = col.$defaultFn(defaultValue as any)\n } else {\n // biome-ignore lint/suspicious/noExplicitAny: Drizzle API\n col = col.default(defaultValue as any)\n }\n }\n\n return col as SQLiteColumnBuilderBase\n }\n\n protected cloneWithModifiers<NewMods extends FieldModifiers>(\n mods: NewMods,\n ): TimestampFieldBuilder<TS, NewMods> {\n return new TimestampFieldBuilder<TS, NewMods>(mods)\n }\n\n /**\n * Marks this field as optional (allows undefined / null).\n */\n optional(\n this: TimestampFieldBuilder<TS, Mods>,\n ): TimestampFieldBuilder<TS | undefined, Mods & { optional: true }> {\n const newMods = { ...this.modifiers, optional: true } as Mods & { optional: true }\n return new TimestampFieldBuilder<TS | undefined, Mods & { optional: true }>(newMods)\n }\n\n /**\n * Marks this field as the primary key of its table.\n */\n primary(\n this: TimestampFieldBuilder<TS, Mods>,\n ): TimestampFieldBuilder<TS, Mods & { primary: true }> {\n const newMods = { ...this.modifiers, primary: true } as Mods & { primary: true }\n return this.cloneWithModifiers(newMods)\n }\n\n /**\n * Adds a unique constraint to this field.\n */\n unique(\n this: TimestampFieldBuilder<TS, Mods>,\n ): TimestampFieldBuilder<TS, Mods & { unique: true }> {\n const newMods = { ...this.modifiers, unique: true } as Mods & { unique: true }\n return this.cloneWithModifiers(newMods)\n }\n\n /**\n * Sets a default value for this field.\n */\n default(\n this: TimestampFieldBuilder<TS, Mods>,\n value: TS | (() => TS),\n ): TimestampFieldBuilder<TS, Mods & { hasDefault: true }> {\n const newMods = { ...this.modifiers, hasDefault: true, defaultValue: value } as Mods & {\n hasDefault: true\n }\n return this.cloneWithModifiers(newMods)\n }\n}\n\n// ==================== JsonFieldBuilder ====================\n\n/**\n * JSON フィールドビルダー。\n *\n * ⚠️ セキュリティ警告: zod ベースは `z.unknown()` のため、API に晒す際は\n * `validator()` で除外するか、別途検証が必須。\n */\nclass JsonFieldBuilder<\n T = unknown,\n TS = T,\n // biome-ignore lint/complexity/noBannedTypes: {} is used intentionally for the default empty modifiers\n Mods extends FieldModifiers = {},\n ZB extends z.ZodType<TS, z.ZodTypeDef, TS> = z.ZodType<TS, z.ZodTypeDef, TS>,\n> extends BaseFieldBuilder<TS, Mods, ZB> {\n readonly kind = 'json' as const\n\n get zodBase(): ZB {\n return this.applyModifiersToZod(zLib.unknown()) as ZB\n }\n\n drizzleColumn(name: string): SQLiteColumnBuilderBase {\n // biome-ignore lint/suspicious/noExplicitAny: Drizzle column builder chaining\n let col = text(name, { mode: 'json' }).$type<T>() as any\n\n if (!this.modifiers.optional) {\n col = col.notNull()\n }\n if (this.modifiers.primary) {\n col = col.primaryKey()\n }\n if (this.modifiers.unique) {\n col = col.unique()\n }\n if (this.modifiers.hasDefault) {\n const defaultValue = this.modifiers.defaultValue\n if (typeof defaultValue === 'function') {\n // biome-ignore lint/suspicious/noExplicitAny: Drizzle API\n col = col.$defaultFn(defaultValue as any)\n } else {\n // biome-ignore lint/suspicious/noExplicitAny: Drizzle API\n col = col.default(defaultValue as any)\n }\n }\n\n return col as SQLiteColumnBuilderBase\n }\n\n protected cloneWithModifiers<NewMods extends FieldModifiers>(\n mods: NewMods,\n ): JsonFieldBuilder<T, TS, NewMods> {\n return new JsonFieldBuilder<T, TS, NewMods>(mods)\n }\n\n /**\n * Marks this field as optional (allows undefined / null).\n */\n optional(\n this: JsonFieldBuilder<T, TS, Mods>,\n ): JsonFieldBuilder<T, TS | undefined, Mods & { optional: true }> {\n const newMods = { ...this.modifiers, optional: true } as Mods & { optional: true }\n return new JsonFieldBuilder<T, TS | undefined, Mods & { optional: true }>(newMods)\n }\n\n /**\n * Marks this field as the primary key of its table.\n */\n primary(this: JsonFieldBuilder<T, TS, Mods>): JsonFieldBuilder<T, TS, Mods & { primary: true }> {\n const newMods = { ...this.modifiers, primary: true } as Mods & { primary: true }\n return this.cloneWithModifiers(newMods)\n }\n\n /**\n * Adds a unique constraint to this field.\n */\n unique(this: JsonFieldBuilder<T, TS, Mods>): JsonFieldBuilder<T, TS, Mods & { unique: true }> {\n const newMods = { ...this.modifiers, unique: true } as Mods & { unique: true }\n return this.cloneWithModifiers(newMods)\n }\n\n /**\n * Sets a default value for this field.\n */\n default(\n this: JsonFieldBuilder<T, TS, Mods>,\n value: TS | (() => TS),\n ): JsonFieldBuilder<T, TS, Mods & { hasDefault: true }> {\n const newMods = { ...this.modifiers, hasDefault: true, defaultValue: value } as Mods & {\n hasDefault: true\n }\n return this.cloneWithModifiers(newMods)\n }\n}\n\n// ==================== Factory ====================\n\n/**\n * Field DSL factory for building type-safe database fields.\n *\n * @example\n * const nameField = t.string().min(1).max(255)\n * const emailField = t.string().email()\n * const idField = t.uuid().primary()\n * const ageField = t.integer().min(0).max(150)\n * const createdAtField = t.timestamp().default(() => new Date())\n * const dataField = t.json<{ foo: string }>()\n */\nexport const t = {\n string(): StringFieldBuilder<\n string,\n // biome-ignore lint/complexity/noBannedTypes: {} is used intentionally for the default empty modifiers\n {}\n > {\n // biome-ignore lint/complexity/noBannedTypes: {} is used intentionally for the default empty modifiers\n return new StringFieldBuilder<string, {}>()\n },\n\n uuid(): UuidFieldBuilder<\n string,\n // biome-ignore lint/complexity/noBannedTypes: {} is used intentionally for the default empty modifiers\n {}\n > {\n // biome-ignore lint/complexity/noBannedTypes: {} is used intentionally for the default empty modifiers\n return new UuidFieldBuilder<string, {}>()\n },\n\n number(): NumberFieldBuilder<\n number,\n // biome-ignore lint/complexity/noBannedTypes: {} is used intentionally for the default empty modifiers\n {}\n > {\n // biome-ignore lint/complexity/noBannedTypes: {} is used intentionally for the default empty modifiers\n return new NumberFieldBuilder<number, {}>()\n },\n\n integer(): IntegerFieldBuilder<\n number,\n // biome-ignore lint/complexity/noBannedTypes: {} is used intentionally for the default empty modifiers\n {}\n > {\n // biome-ignore lint/complexity/noBannedTypes: {} is used intentionally for the default empty modifiers\n return new IntegerFieldBuilder<number, {}>()\n },\n\n boolean(): BooleanFieldBuilder<\n boolean,\n // biome-ignore lint/complexity/noBannedTypes: {} is used intentionally for the default empty modifiers\n {}\n > {\n // biome-ignore lint/complexity/noBannedTypes: {} is used intentionally for the default empty modifiers\n return new BooleanFieldBuilder<boolean, {}>()\n },\n\n timestamp(): TimestampFieldBuilder<\n Date,\n // biome-ignore lint/complexity/noBannedTypes: {} is used intentionally for the default empty modifiers\n {}\n > {\n // biome-ignore lint/complexity/noBannedTypes: {} is used intentionally for the default empty modifiers\n return new TimestampFieldBuilder<Date, {}>()\n },\n\n /**\n * JSON フィールド。任意の JSON 値を受け入れる(Zod 内部表現は `z.unknown()`)。\n *\n * ⚠️ セキュリティ警告:\n * このフィールドの zod ベースは `z.unknown()` のため、型パラメータ `T` で\n * 指定した制約は **コンパイル時のみ** 適用され、validator() 経由でも\n * runtime バリデーションは行われません。API 入力として晒す場合は:\n * - `model.validator(target, { omit: ['<json field name>'] })` で除外する、または\n * - ハンドラ側で別途 Zod スキーマを使って手動検証する、\n * のいずれかを必ず実施してください。型パラメータが `unknown` 以外の値を\n * runtime で保証することはありません。\n *\n * Phase 2 以降で `t.json(zodSchema)` 形式の引数追加を検討中。\n */\n json<T = unknown>(): JsonFieldBuilder<\n T,\n T,\n // biome-ignore lint/complexity/noBannedTypes: {} is used intentionally for the default empty modifiers\n {}\n > {\n // biome-ignore lint/complexity/noBannedTypes: {} is used intentionally for the default empty modifiers\n return new JsonFieldBuilder<T, T, {}>()\n },\n}\n"]}
|
package/dist/cli.d.ts
ADDED