@shipeasy/openapi 1.0.0 → 1.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.
Files changed (39) hide show
  1. package/dist/index.d.ts +9 -7
  2. package/dist/index.js +484 -2665
  3. package/dist/resources/alert-rules.d.ts +48 -0
  4. package/dist/resources/alert-rules.js +66 -0
  5. package/dist/resources/configs.d.ts +6 -2
  6. package/dist/resources/configs.js +67 -2375
  7. package/dist/resources/experiments.d.ts +88 -2
  8. package/dist/resources/experiments.js +138 -98
  9. package/dist/resources/gates.d.ts +51 -8
  10. package/dist/resources/gates.js +102 -70
  11. package/dist/resources/index.d.ts +156 -10
  12. package/dist/resources/index.js +483 -2664
  13. package/dist/resources/killswitches.d.ts +6 -2
  14. package/dist/resources/killswitches.js +113 -2412
  15. package/dist/resources/universes.d.ts +7 -4
  16. package/dist/resources/universes.js +30 -20
  17. package/dist/schemas/alert-rules.d.ts +43 -0
  18. package/dist/schemas/alert-rules.js +27 -0
  19. package/dist/schemas/configs.d.ts +154 -0
  20. package/dist/schemas/configs.js +134 -0
  21. package/dist/schemas/constants.d.ts +6 -0
  22. package/dist/schemas/constants.js +7 -0
  23. package/dist/schemas/experiments.d.ts +245 -0
  24. package/dist/schemas/experiments.js +216 -0
  25. package/dist/schemas/folder.d.ts +10 -0
  26. package/dist/schemas/folder.js +8 -0
  27. package/dist/schemas/gates.d.ts +304 -0
  28. package/dist/schemas/gates.js +172 -0
  29. package/dist/schemas/index.d.ts +11 -0
  30. package/dist/schemas/index.js +729 -0
  31. package/dist/schemas/killswitches.d.ts +110 -0
  32. package/dist/schemas/killswitches.js +226 -0
  33. package/dist/schemas/metric-name.d.ts +5 -0
  34. package/dist/schemas/metric-name.js +6 -0
  35. package/dist/schemas/pagination.d.ts +37 -0
  36. package/dist/schemas/pagination.js +44 -0
  37. package/dist/schemas/universes.d.ts +35 -0
  38. package/dist/schemas/universes.js +55 -0
  39. package/package.json +13 -10
@@ -1,2333 +1,23 @@
1
1
  // src/resources/configs.ts
2
- import { z as z2 } from "zod";
3
-
4
- // ../core/src/schemas/configs.ts
5
- import { z } from "zod";
6
-
7
- // ../../node_modules/.pnpm/drizzle-orm@0.36.4_@cloudflare+workers-types@4.20260416.2_@types+better-sqlite3@7.6.13__6bda8a68f3e10d0b03cd2031bac7989c/node_modules/drizzle-orm/entity.js
8
- var entityKind = /* @__PURE__ */ Symbol.for("drizzle:entityKind");
9
- function is(value, type) {
10
- if (!value || typeof value !== "object") {
11
- return false;
12
- }
13
- if (value instanceof type) {
14
- return true;
15
- }
16
- if (!Object.prototype.hasOwnProperty.call(type, entityKind)) {
17
- throw new Error(
18
- `Class "${type.name ?? "<unknown>"}" doesn't look like a Drizzle entity. If this is incorrect and the class is provided by Drizzle, please report this as a bug.`
19
- );
20
- }
21
- let cls = Object.getPrototypeOf(value).constructor;
22
- if (cls) {
23
- while (cls) {
24
- if (entityKind in cls && cls[entityKind] === type[entityKind]) {
25
- return true;
26
- }
27
- cls = Object.getPrototypeOf(cls);
28
- }
29
- }
30
- return false;
31
- }
32
-
33
- // ../../node_modules/.pnpm/drizzle-orm@0.36.4_@cloudflare+workers-types@4.20260416.2_@types+better-sqlite3@7.6.13__6bda8a68f3e10d0b03cd2031bac7989c/node_modules/drizzle-orm/column.js
34
- var Column = class {
35
- constructor(table, config) {
36
- this.table = table;
37
- this.config = config;
38
- this.name = config.name;
39
- this.keyAsName = config.keyAsName;
40
- this.notNull = config.notNull;
41
- this.default = config.default;
42
- this.defaultFn = config.defaultFn;
43
- this.onUpdateFn = config.onUpdateFn;
44
- this.hasDefault = config.hasDefault;
45
- this.primary = config.primaryKey;
46
- this.isUnique = config.isUnique;
47
- this.uniqueName = config.uniqueName;
48
- this.uniqueType = config.uniqueType;
49
- this.dataType = config.dataType;
50
- this.columnType = config.columnType;
51
- this.generated = config.generated;
52
- this.generatedIdentity = config.generatedIdentity;
53
- }
54
- static [entityKind] = "Column";
55
- name;
56
- keyAsName;
57
- primary;
58
- notNull;
59
- default;
60
- defaultFn;
61
- onUpdateFn;
62
- hasDefault;
63
- isUnique;
64
- uniqueName;
65
- uniqueType;
66
- dataType;
67
- columnType;
68
- enumValues = void 0;
69
- generated = void 0;
70
- generatedIdentity = void 0;
71
- config;
72
- mapFromDriverValue(value) {
73
- return value;
74
- }
75
- mapToDriverValue(value) {
76
- return value;
77
- }
78
- // ** @internal */
79
- shouldDisableInsert() {
80
- return this.config.generated !== void 0 && this.config.generated.type !== "byDefault";
81
- }
82
- };
83
-
84
- // ../../node_modules/.pnpm/drizzle-orm@0.36.4_@cloudflare+workers-types@4.20260416.2_@types+better-sqlite3@7.6.13__6bda8a68f3e10d0b03cd2031bac7989c/node_modules/drizzle-orm/column-builder.js
85
- var ColumnBuilder = class {
86
- static [entityKind] = "ColumnBuilder";
87
- config;
88
- constructor(name, dataType, columnType) {
89
- this.config = {
90
- name,
91
- keyAsName: name === "",
92
- notNull: false,
93
- default: void 0,
94
- hasDefault: false,
95
- primaryKey: false,
96
- isUnique: false,
97
- uniqueName: void 0,
98
- uniqueType: void 0,
99
- dataType,
100
- columnType,
101
- generated: void 0
102
- };
103
- }
104
- /**
105
- * Changes the data type of the column. Commonly used with `json` columns. Also, useful for branded types.
106
- *
107
- * @example
108
- * ```ts
109
- * const users = pgTable('users', {
110
- * id: integer('id').$type<UserId>().primaryKey(),
111
- * details: json('details').$type<UserDetails>().notNull(),
112
- * });
113
- * ```
114
- */
115
- $type() {
116
- return this;
117
- }
118
- /**
119
- * Adds a `not null` clause to the column definition.
120
- *
121
- * Affects the `select` model of the table - columns *without* `not null` will be nullable on select.
122
- */
123
- notNull() {
124
- this.config.notNull = true;
125
- return this;
126
- }
127
- /**
128
- * Adds a `default <value>` clause to the column definition.
129
- *
130
- * Affects the `insert` model of the table - columns *with* `default` are optional on insert.
131
- *
132
- * If you need to set a dynamic default value, use {@link $defaultFn} instead.
133
- */
134
- default(value) {
135
- this.config.default = value;
136
- this.config.hasDefault = true;
137
- return this;
138
- }
139
- /**
140
- * Adds a dynamic default value to the column.
141
- * The function will be called when the row is inserted, and the returned value will be used as the column value.
142
- *
143
- * **Note:** This value does not affect the `drizzle-kit` behavior, it is only used at runtime in `drizzle-orm`.
144
- */
145
- $defaultFn(fn) {
146
- this.config.defaultFn = fn;
147
- this.config.hasDefault = true;
148
- return this;
149
- }
150
- /**
151
- * Alias for {@link $defaultFn}.
152
- */
153
- $default = this.$defaultFn;
154
- /**
155
- * Adds a dynamic update value to the column.
156
- * The function will be called when the row is updated, and the returned value will be used as the column value if none is provided.
157
- * If no `default` (or `$defaultFn`) value is provided, the function will be called when the row is inserted as well, and the returned value will be used as the column value.
158
- *
159
- * **Note:** This value does not affect the `drizzle-kit` behavior, it is only used at runtime in `drizzle-orm`.
160
- */
161
- $onUpdateFn(fn) {
162
- this.config.onUpdateFn = fn;
163
- this.config.hasDefault = true;
164
- return this;
165
- }
166
- /**
167
- * Alias for {@link $onUpdateFn}.
168
- */
169
- $onUpdate = this.$onUpdateFn;
170
- /**
171
- * Adds a `primary key` clause to the column definition. This implicitly makes the column `not null`.
172
- *
173
- * In SQLite, `integer primary key` implicitly makes the column auto-incrementing.
174
- */
175
- primaryKey() {
176
- this.config.primaryKey = true;
177
- this.config.notNull = true;
178
- return this;
179
- }
180
- /** @internal Sets the name of the column to the key within the table definition if a name was not given. */
181
- setName(name) {
182
- if (this.config.name !== "")
183
- return;
184
- this.config.name = name;
185
- }
186
- };
187
-
188
- // ../../node_modules/.pnpm/drizzle-orm@0.36.4_@cloudflare+workers-types@4.20260416.2_@types+better-sqlite3@7.6.13__6bda8a68f3e10d0b03cd2031bac7989c/node_modules/drizzle-orm/table.utils.js
189
- var TableName = /* @__PURE__ */ Symbol.for("drizzle:Name");
190
-
191
- // ../../node_modules/.pnpm/drizzle-orm@0.36.4_@cloudflare+workers-types@4.20260416.2_@types+better-sqlite3@7.6.13__6bda8a68f3e10d0b03cd2031bac7989c/node_modules/drizzle-orm/pg-core/foreign-keys.js
192
- var ForeignKeyBuilder = class {
193
- static [entityKind] = "PgForeignKeyBuilder";
194
- /** @internal */
195
- reference;
196
- /** @internal */
197
- _onUpdate = "no action";
198
- /** @internal */
199
- _onDelete = "no action";
200
- constructor(config, actions) {
201
- this.reference = () => {
202
- const { name, columns, foreignColumns } = config();
203
- return { name, columns, foreignTable: foreignColumns[0].table, foreignColumns };
204
- };
205
- if (actions) {
206
- this._onUpdate = actions.onUpdate;
207
- this._onDelete = actions.onDelete;
208
- }
209
- }
210
- onUpdate(action) {
211
- this._onUpdate = action === void 0 ? "no action" : action;
212
- return this;
213
- }
214
- onDelete(action) {
215
- this._onDelete = action === void 0 ? "no action" : action;
216
- return this;
217
- }
218
- /** @internal */
219
- build(table) {
220
- return new ForeignKey(table, this);
221
- }
222
- };
223
- var ForeignKey = class {
224
- constructor(table, builder) {
225
- this.table = table;
226
- this.reference = builder.reference;
227
- this.onUpdate = builder._onUpdate;
228
- this.onDelete = builder._onDelete;
229
- }
230
- static [entityKind] = "PgForeignKey";
231
- reference;
232
- onUpdate;
233
- onDelete;
234
- getName() {
235
- const { name, columns, foreignColumns } = this.reference();
236
- const columnNames = columns.map((column) => column.name);
237
- const foreignColumnNames = foreignColumns.map((column) => column.name);
238
- const chunks = [
239
- this.table[TableName],
240
- ...columnNames,
241
- foreignColumns[0].table[TableName],
242
- ...foreignColumnNames
243
- ];
244
- return name ?? `${chunks.join("_")}_fk`;
245
- }
246
- };
247
-
248
- // ../../node_modules/.pnpm/drizzle-orm@0.36.4_@cloudflare+workers-types@4.20260416.2_@types+better-sqlite3@7.6.13__6bda8a68f3e10d0b03cd2031bac7989c/node_modules/drizzle-orm/tracing-utils.js
249
- function iife(fn, ...args) {
250
- return fn(...args);
251
- }
252
-
253
- // ../../node_modules/.pnpm/drizzle-orm@0.36.4_@cloudflare+workers-types@4.20260416.2_@types+better-sqlite3@7.6.13__6bda8a68f3e10d0b03cd2031bac7989c/node_modules/drizzle-orm/pg-core/unique-constraint.js
254
- function uniqueKeyName(table, columns) {
255
- return `${table[TableName]}_${columns.join("_")}_unique`;
256
- }
257
- var UniqueConstraintBuilder = class {
258
- constructor(columns, name) {
259
- this.name = name;
260
- this.columns = columns;
261
- }
262
- static [entityKind] = "PgUniqueConstraintBuilder";
263
- /** @internal */
264
- columns;
265
- /** @internal */
266
- nullsNotDistinctConfig = false;
267
- nullsNotDistinct() {
268
- this.nullsNotDistinctConfig = true;
269
- return this;
270
- }
271
- /** @internal */
272
- build(table) {
273
- return new UniqueConstraint(table, this.columns, this.nullsNotDistinctConfig, this.name);
274
- }
275
- };
276
- var UniqueOnConstraintBuilder = class {
277
- static [entityKind] = "PgUniqueOnConstraintBuilder";
278
- /** @internal */
279
- name;
280
- constructor(name) {
281
- this.name = name;
282
- }
283
- on(...columns) {
284
- return new UniqueConstraintBuilder(columns, this.name);
285
- }
286
- };
287
- var UniqueConstraint = class {
288
- constructor(table, columns, nullsNotDistinct, name) {
289
- this.table = table;
290
- this.columns = columns;
291
- this.name = name ?? uniqueKeyName(this.table, this.columns.map((column) => column.name));
292
- this.nullsNotDistinct = nullsNotDistinct;
293
- }
294
- static [entityKind] = "PgUniqueConstraint";
295
- columns;
296
- name;
297
- nullsNotDistinct = false;
298
- getName() {
299
- return this.name;
300
- }
301
- };
302
-
303
- // ../../node_modules/.pnpm/drizzle-orm@0.36.4_@cloudflare+workers-types@4.20260416.2_@types+better-sqlite3@7.6.13__6bda8a68f3e10d0b03cd2031bac7989c/node_modules/drizzle-orm/pg-core/utils/array.js
304
- function parsePgArrayValue(arrayString, startFrom, inQuotes) {
305
- for (let i = startFrom; i < arrayString.length; i++) {
306
- const char = arrayString[i];
307
- if (char === "\\") {
308
- i++;
309
- continue;
310
- }
311
- if (char === '"') {
312
- return [arrayString.slice(startFrom, i).replace(/\\/g, ""), i + 1];
313
- }
314
- if (inQuotes) {
315
- continue;
316
- }
317
- if (char === "," || char === "}") {
318
- return [arrayString.slice(startFrom, i).replace(/\\/g, ""), i];
319
- }
320
- }
321
- return [arrayString.slice(startFrom).replace(/\\/g, ""), arrayString.length];
322
- }
323
- function parsePgNestedArray(arrayString, startFrom = 0) {
324
- const result = [];
325
- let i = startFrom;
326
- let lastCharIsComma = false;
327
- while (i < arrayString.length) {
328
- const char = arrayString[i];
329
- if (char === ",") {
330
- if (lastCharIsComma || i === startFrom) {
331
- result.push("");
332
- }
333
- lastCharIsComma = true;
334
- i++;
335
- continue;
336
- }
337
- lastCharIsComma = false;
338
- if (char === "\\") {
339
- i += 2;
340
- continue;
341
- }
342
- if (char === '"') {
343
- const [value2, startFrom2] = parsePgArrayValue(arrayString, i + 1, true);
344
- result.push(value2);
345
- i = startFrom2;
346
- continue;
347
- }
348
- if (char === "}") {
349
- return [result, i + 1];
350
- }
351
- if (char === "{") {
352
- const [value2, startFrom2] = parsePgNestedArray(arrayString, i + 1);
353
- result.push(value2);
354
- i = startFrom2;
355
- continue;
356
- }
357
- const [value, newStartFrom] = parsePgArrayValue(arrayString, i, false);
358
- result.push(value);
359
- i = newStartFrom;
360
- }
361
- return [result, i];
362
- }
363
- function parsePgArray(arrayString) {
364
- const [result] = parsePgNestedArray(arrayString, 1);
365
- return result;
366
- }
367
- function makePgArray(array) {
368
- return `{${array.map((item) => {
369
- if (Array.isArray(item)) {
370
- return makePgArray(item);
371
- }
372
- if (typeof item === "string") {
373
- return `"${item.replace(/\\/g, "\\\\").replace(/"/g, '\\"')}"`;
374
- }
375
- return `${item}`;
376
- }).join(",")}}`;
377
- }
378
-
379
- // ../../node_modules/.pnpm/drizzle-orm@0.36.4_@cloudflare+workers-types@4.20260416.2_@types+better-sqlite3@7.6.13__6bda8a68f3e10d0b03cd2031bac7989c/node_modules/drizzle-orm/pg-core/columns/common.js
380
- var PgColumnBuilder = class extends ColumnBuilder {
381
- foreignKeyConfigs = [];
382
- static [entityKind] = "PgColumnBuilder";
383
- array(size) {
384
- return new PgArrayBuilder(this.config.name, this, size);
385
- }
386
- references(ref, actions = {}) {
387
- this.foreignKeyConfigs.push({ ref, actions });
388
- return this;
389
- }
390
- unique(name, config) {
391
- this.config.isUnique = true;
392
- this.config.uniqueName = name;
393
- this.config.uniqueType = config?.nulls;
394
- return this;
395
- }
396
- generatedAlwaysAs(as) {
397
- this.config.generated = {
398
- as,
399
- type: "always",
400
- mode: "stored"
401
- };
402
- return this;
403
- }
404
- /** @internal */
405
- buildForeignKeys(column, table) {
406
- return this.foreignKeyConfigs.map(({ ref, actions }) => {
407
- return iife(
408
- (ref2, actions2) => {
409
- const builder = new ForeignKeyBuilder(() => {
410
- const foreignColumn = ref2();
411
- return { columns: [column], foreignColumns: [foreignColumn] };
412
- });
413
- if (actions2.onUpdate) {
414
- builder.onUpdate(actions2.onUpdate);
415
- }
416
- if (actions2.onDelete) {
417
- builder.onDelete(actions2.onDelete);
418
- }
419
- return builder.build(table);
420
- },
421
- ref,
422
- actions
423
- );
424
- });
425
- }
426
- /** @internal */
427
- buildExtraConfigColumn(table) {
428
- return new ExtraConfigColumn(table, this.config);
429
- }
430
- };
431
- var PgColumn = class extends Column {
432
- constructor(table, config) {
433
- if (!config.uniqueName) {
434
- config.uniqueName = uniqueKeyName(table, [config.name]);
435
- }
436
- super(table, config);
437
- this.table = table;
438
- }
439
- static [entityKind] = "PgColumn";
440
- };
441
- var ExtraConfigColumn = class extends PgColumn {
442
- static [entityKind] = "ExtraConfigColumn";
443
- getSQLType() {
444
- return this.getSQLType();
445
- }
446
- indexConfig = {
447
- order: this.config.order ?? "asc",
448
- nulls: this.config.nulls ?? "last",
449
- opClass: this.config.opClass
450
- };
451
- defaultConfig = {
452
- order: "asc",
453
- nulls: "last",
454
- opClass: void 0
455
- };
456
- asc() {
457
- this.indexConfig.order = "asc";
458
- return this;
459
- }
460
- desc() {
461
- this.indexConfig.order = "desc";
462
- return this;
463
- }
464
- nullsFirst() {
465
- this.indexConfig.nulls = "first";
466
- return this;
467
- }
468
- nullsLast() {
469
- this.indexConfig.nulls = "last";
470
- return this;
471
- }
472
- /**
473
- * ### PostgreSQL documentation quote
474
- *
475
- * > An operator class with optional parameters can be specified for each column of an index.
476
- * The operator class identifies the operators to be used by the index for that column.
477
- * For example, a B-tree index on four-byte integers would use the int4_ops class;
478
- * this operator class includes comparison functions for four-byte integers.
479
- * In practice the default operator class for the column's data type is usually sufficient.
480
- * The main point of having operator classes is that for some data types, there could be more than one meaningful ordering.
481
- * For example, we might want to sort a complex-number data type either by absolute value or by real part.
482
- * We could do this by defining two operator classes for the data type and then selecting the proper class when creating an index.
483
- * More information about operator classes check:
484
- *
485
- * ### Useful links
486
- * https://www.postgresql.org/docs/current/sql-createindex.html
487
- *
488
- * https://www.postgresql.org/docs/current/indexes-opclass.html
489
- *
490
- * https://www.postgresql.org/docs/current/xindex.html
491
- *
492
- * ### Additional types
493
- * If you have the `pg_vector` extension installed in your database, you can use the
494
- * `vector_l2_ops`, `vector_ip_ops`, `vector_cosine_ops`, `vector_l1_ops`, `bit_hamming_ops`, `bit_jaccard_ops`, `halfvec_l2_ops`, `sparsevec_l2_ops` options, which are predefined types.
495
- *
496
- * **You can always specify any string you want in the operator class, in case Drizzle doesn't have it natively in its types**
497
- *
498
- * @param opClass
499
- * @returns
500
- */
501
- op(opClass) {
502
- this.indexConfig.opClass = opClass;
503
- return this;
504
- }
505
- };
506
- var IndexedColumn = class {
507
- static [entityKind] = "IndexedColumn";
508
- constructor(name, keyAsName, type, indexConfig) {
509
- this.name = name;
510
- this.keyAsName = keyAsName;
511
- this.type = type;
512
- this.indexConfig = indexConfig;
513
- }
514
- name;
515
- keyAsName;
516
- type;
517
- indexConfig;
518
- };
519
- var PgArrayBuilder = class extends PgColumnBuilder {
520
- static [entityKind] = "PgArrayBuilder";
521
- constructor(name, baseBuilder, size) {
522
- super(name, "array", "PgArray");
523
- this.config.baseBuilder = baseBuilder;
524
- this.config.size = size;
525
- }
526
- /** @internal */
527
- build(table) {
528
- const baseColumn = this.config.baseBuilder.build(table);
529
- return new PgArray(
530
- table,
531
- this.config,
532
- baseColumn
533
- );
534
- }
535
- };
536
- var PgArray = class _PgArray extends PgColumn {
537
- constructor(table, config, baseColumn, range) {
538
- super(table, config);
539
- this.baseColumn = baseColumn;
540
- this.range = range;
541
- this.size = config.size;
542
- }
543
- size;
544
- static [entityKind] = "PgArray";
545
- getSQLType() {
546
- return `${this.baseColumn.getSQLType()}[${typeof this.size === "number" ? this.size : ""}]`;
547
- }
548
- mapFromDriverValue(value) {
549
- if (typeof value === "string") {
550
- value = parsePgArray(value);
551
- }
552
- return value.map((v) => this.baseColumn.mapFromDriverValue(v));
553
- }
554
- mapToDriverValue(value, isNestedArray = false) {
555
- const a = value.map(
556
- (v) => v === null ? null : is(this.baseColumn, _PgArray) ? this.baseColumn.mapToDriverValue(v, true) : this.baseColumn.mapToDriverValue(v)
557
- );
558
- if (isNestedArray)
559
- return a;
560
- return makePgArray(a);
561
- }
562
- };
563
-
564
- // ../../node_modules/.pnpm/drizzle-orm@0.36.4_@cloudflare+workers-types@4.20260416.2_@types+better-sqlite3@7.6.13__6bda8a68f3e10d0b03cd2031bac7989c/node_modules/drizzle-orm/pg-core/columns/enum.js
565
- var isPgEnumSym = /* @__PURE__ */ Symbol.for("drizzle:isPgEnum");
566
- function isPgEnum(obj) {
567
- return !!obj && typeof obj === "function" && isPgEnumSym in obj && obj[isPgEnumSym] === true;
568
- }
569
- var PgEnumColumnBuilder = class extends PgColumnBuilder {
570
- static [entityKind] = "PgEnumColumnBuilder";
571
- constructor(name, enumInstance) {
572
- super(name, "string", "PgEnumColumn");
573
- this.config.enum = enumInstance;
574
- }
575
- /** @internal */
576
- build(table) {
577
- return new PgEnumColumn(
578
- table,
579
- this.config
580
- );
581
- }
582
- };
583
- var PgEnumColumn = class extends PgColumn {
584
- static [entityKind] = "PgEnumColumn";
585
- enum = this.config.enum;
586
- enumValues = this.config.enum.enumValues;
587
- constructor(table, config) {
588
- super(table, config);
589
- this.enum = config.enum;
590
- }
591
- getSQLType() {
592
- return this.enum.enumName;
593
- }
594
- };
595
-
596
- // ../../node_modules/.pnpm/drizzle-orm@0.36.4_@cloudflare+workers-types@4.20260416.2_@types+better-sqlite3@7.6.13__6bda8a68f3e10d0b03cd2031bac7989c/node_modules/drizzle-orm/subquery.js
597
- var Subquery = class {
598
- static [entityKind] = "Subquery";
599
- constructor(sql2, selection, alias, isWith = false) {
600
- this._ = {
601
- brand: "Subquery",
602
- sql: sql2,
603
- selectedFields: selection,
604
- alias,
605
- isWith
606
- };
607
- }
608
- // getSQL(): SQL<unknown> {
609
- // return new SQL([this]);
610
- // }
611
- };
612
- var WithSubquery = class extends Subquery {
613
- static [entityKind] = "WithSubquery";
614
- };
615
-
616
- // ../../node_modules/.pnpm/drizzle-orm@0.36.4_@cloudflare+workers-types@4.20260416.2_@types+better-sqlite3@7.6.13__6bda8a68f3e10d0b03cd2031bac7989c/node_modules/drizzle-orm/version.js
617
- var version = "0.36.4";
618
-
619
- // ../../node_modules/.pnpm/drizzle-orm@0.36.4_@cloudflare+workers-types@4.20260416.2_@types+better-sqlite3@7.6.13__6bda8a68f3e10d0b03cd2031bac7989c/node_modules/drizzle-orm/tracing.js
620
- var otel;
621
- var rawTracer;
622
- var tracer = {
623
- startActiveSpan(name, fn) {
624
- if (!otel) {
625
- return fn();
626
- }
627
- if (!rawTracer) {
628
- rawTracer = otel.trace.getTracer("drizzle-orm", version);
629
- }
630
- return iife(
631
- (otel2, rawTracer2) => rawTracer2.startActiveSpan(
632
- name,
633
- (span) => {
634
- try {
635
- return fn(span);
636
- } catch (e) {
637
- span.setStatus({
638
- code: otel2.SpanStatusCode.ERROR,
639
- message: e instanceof Error ? e.message : "Unknown error"
640
- // eslint-disable-line no-instanceof/no-instanceof
641
- });
642
- throw e;
643
- } finally {
644
- span.end();
645
- }
646
- }
647
- ),
648
- otel,
649
- rawTracer
650
- );
651
- }
652
- };
653
-
654
- // ../../node_modules/.pnpm/drizzle-orm@0.36.4_@cloudflare+workers-types@4.20260416.2_@types+better-sqlite3@7.6.13__6bda8a68f3e10d0b03cd2031bac7989c/node_modules/drizzle-orm/view-common.js
655
- var ViewBaseConfig = /* @__PURE__ */ Symbol.for("drizzle:ViewBaseConfig");
656
-
657
- // ../../node_modules/.pnpm/drizzle-orm@0.36.4_@cloudflare+workers-types@4.20260416.2_@types+better-sqlite3@7.6.13__6bda8a68f3e10d0b03cd2031bac7989c/node_modules/drizzle-orm/table.js
658
- var Schema = /* @__PURE__ */ Symbol.for("drizzle:Schema");
659
- var Columns = /* @__PURE__ */ Symbol.for("drizzle:Columns");
660
- var ExtraConfigColumns = /* @__PURE__ */ Symbol.for("drizzle:ExtraConfigColumns");
661
- var OriginalName = /* @__PURE__ */ Symbol.for("drizzle:OriginalName");
662
- var BaseName = /* @__PURE__ */ Symbol.for("drizzle:BaseName");
663
- var IsAlias = /* @__PURE__ */ Symbol.for("drizzle:IsAlias");
664
- var ExtraConfigBuilder = /* @__PURE__ */ Symbol.for("drizzle:ExtraConfigBuilder");
665
- var IsDrizzleTable = /* @__PURE__ */ Symbol.for("drizzle:IsDrizzleTable");
666
- var Table = class {
667
- static [entityKind] = "Table";
668
- /** @internal */
669
- static Symbol = {
670
- Name: TableName,
671
- Schema,
672
- OriginalName,
673
- Columns,
674
- ExtraConfigColumns,
675
- BaseName,
676
- IsAlias,
677
- ExtraConfigBuilder
678
- };
679
- /**
680
- * @internal
681
- * Can be changed if the table is aliased.
682
- */
683
- [TableName];
684
- /**
685
- * @internal
686
- * Used to store the original name of the table, before any aliasing.
687
- */
688
- [OriginalName];
689
- /** @internal */
690
- [Schema];
691
- /** @internal */
692
- [Columns];
693
- /** @internal */
694
- [ExtraConfigColumns];
695
- /**
696
- * @internal
697
- * Used to store the table name before the transformation via the `tableCreator` functions.
698
- */
699
- [BaseName];
700
- /** @internal */
701
- [IsAlias] = false;
702
- /** @internal */
703
- [IsDrizzleTable] = true;
704
- /** @internal */
705
- [ExtraConfigBuilder] = void 0;
706
- constructor(name, schema, baseName) {
707
- this[TableName] = this[OriginalName] = name;
708
- this[Schema] = schema;
709
- this[BaseName] = baseName;
710
- }
711
- };
2
+ import { z as z3 } from "zod";
712
3
 
713
- // ../../node_modules/.pnpm/drizzle-orm@0.36.4_@cloudflare+workers-types@4.20260416.2_@types+better-sqlite3@7.6.13__6bda8a68f3e10d0b03cd2031bac7989c/node_modules/drizzle-orm/sql/sql.js
714
- var FakePrimitiveParam = class {
715
- static [entityKind] = "FakePrimitiveParam";
716
- };
717
- function isSQLWrapper(value) {
718
- return value !== null && value !== void 0 && typeof value.getSQL === "function";
719
- }
720
- function mergeQueries(queries) {
721
- const result = { sql: "", params: [] };
722
- for (const query of queries) {
723
- result.sql += query.sql;
724
- result.params.push(...query.params);
725
- if (query.typings?.length) {
726
- if (!result.typings) {
727
- result.typings = [];
728
- }
729
- result.typings.push(...query.typings);
730
- }
731
- }
732
- return result;
733
- }
734
- var StringChunk = class {
735
- static [entityKind] = "StringChunk";
736
- value;
737
- constructor(value) {
738
- this.value = Array.isArray(value) ? value : [value];
739
- }
740
- getSQL() {
741
- return new SQL([this]);
742
- }
743
- };
744
- var SQL = class _SQL {
745
- constructor(queryChunks) {
746
- this.queryChunks = queryChunks;
747
- }
748
- static [entityKind] = "SQL";
749
- /** @internal */
750
- decoder = noopDecoder;
751
- shouldInlineParams = false;
752
- append(query) {
753
- this.queryChunks.push(...query.queryChunks);
754
- return this;
755
- }
756
- toQuery(config) {
757
- return tracer.startActiveSpan("drizzle.buildSQL", (span) => {
758
- const query = this.buildQueryFromSourceParams(this.queryChunks, config);
759
- span?.setAttributes({
760
- "drizzle.query.text": query.sql,
761
- "drizzle.query.params": JSON.stringify(query.params)
762
- });
763
- return query;
764
- });
765
- }
766
- buildQueryFromSourceParams(chunks, _config) {
767
- const config = Object.assign({}, _config, {
768
- inlineParams: _config.inlineParams || this.shouldInlineParams,
769
- paramStartIndex: _config.paramStartIndex || { value: 0 }
770
- });
771
- const {
772
- casing,
773
- escapeName,
774
- escapeParam,
775
- prepareTyping,
776
- inlineParams,
777
- paramStartIndex
778
- } = config;
779
- return mergeQueries(chunks.map((chunk) => {
780
- if (is(chunk, StringChunk)) {
781
- return { sql: chunk.value.join(""), params: [] };
782
- }
783
- if (is(chunk, Name)) {
784
- return { sql: escapeName(chunk.value), params: [] };
785
- }
786
- if (chunk === void 0) {
787
- return { sql: "", params: [] };
788
- }
789
- if (Array.isArray(chunk)) {
790
- const result = [new StringChunk("(")];
791
- for (const [i, p] of chunk.entries()) {
792
- result.push(p);
793
- if (i < chunk.length - 1) {
794
- result.push(new StringChunk(", "));
795
- }
796
- }
797
- result.push(new StringChunk(")"));
798
- return this.buildQueryFromSourceParams(result, config);
799
- }
800
- if (is(chunk, _SQL)) {
801
- return this.buildQueryFromSourceParams(chunk.queryChunks, {
802
- ...config,
803
- inlineParams: inlineParams || chunk.shouldInlineParams
804
- });
805
- }
806
- if (is(chunk, Table)) {
807
- const schemaName = chunk[Table.Symbol.Schema];
808
- const tableName = chunk[Table.Symbol.Name];
809
- return {
810
- sql: schemaName === void 0 ? escapeName(tableName) : escapeName(schemaName) + "." + escapeName(tableName),
811
- params: []
812
- };
813
- }
814
- if (is(chunk, Column)) {
815
- const columnName = casing.getColumnCasing(chunk);
816
- if (_config.invokeSource === "indexes") {
817
- return { sql: escapeName(columnName), params: [] };
818
- }
819
- const schemaName = chunk.table[Table.Symbol.Schema];
820
- return {
821
- sql: chunk.table[IsAlias] || schemaName === void 0 ? escapeName(chunk.table[Table.Symbol.Name]) + "." + escapeName(columnName) : escapeName(schemaName) + "." + escapeName(chunk.table[Table.Symbol.Name]) + "." + escapeName(columnName),
822
- params: []
823
- };
824
- }
825
- if (is(chunk, View)) {
826
- const schemaName = chunk[ViewBaseConfig].schema;
827
- const viewName = chunk[ViewBaseConfig].name;
828
- return {
829
- sql: schemaName === void 0 ? escapeName(viewName) : escapeName(schemaName) + "." + escapeName(viewName),
830
- params: []
831
- };
832
- }
833
- if (is(chunk, Param)) {
834
- if (is(chunk.value, Placeholder)) {
835
- return { sql: escapeParam(paramStartIndex.value++, chunk), params: [chunk], typings: ["none"] };
836
- }
837
- const mappedValue = chunk.value === null ? null : chunk.encoder.mapToDriverValue(chunk.value);
838
- if (is(mappedValue, _SQL)) {
839
- return this.buildQueryFromSourceParams([mappedValue], config);
840
- }
841
- if (inlineParams) {
842
- return { sql: this.mapInlineParam(mappedValue, config), params: [] };
843
- }
844
- let typings = ["none"];
845
- if (prepareTyping) {
846
- typings = [prepareTyping(chunk.encoder)];
847
- }
848
- return { sql: escapeParam(paramStartIndex.value++, mappedValue), params: [mappedValue], typings };
849
- }
850
- if (is(chunk, Placeholder)) {
851
- return { sql: escapeParam(paramStartIndex.value++, chunk), params: [chunk], typings: ["none"] };
852
- }
853
- if (is(chunk, _SQL.Aliased) && chunk.fieldAlias !== void 0) {
854
- return { sql: escapeName(chunk.fieldAlias), params: [] };
855
- }
856
- if (is(chunk, Subquery)) {
857
- if (chunk._.isWith) {
858
- return { sql: escapeName(chunk._.alias), params: [] };
859
- }
860
- return this.buildQueryFromSourceParams([
861
- new StringChunk("("),
862
- chunk._.sql,
863
- new StringChunk(") "),
864
- new Name(chunk._.alias)
865
- ], config);
866
- }
867
- if (isPgEnum(chunk)) {
868
- if (chunk.schema) {
869
- return { sql: escapeName(chunk.schema) + "." + escapeName(chunk.enumName), params: [] };
870
- }
871
- return { sql: escapeName(chunk.enumName), params: [] };
872
- }
873
- if (isSQLWrapper(chunk)) {
874
- if (chunk.shouldOmitSQLParens?.()) {
875
- return this.buildQueryFromSourceParams([chunk.getSQL()], config);
876
- }
877
- return this.buildQueryFromSourceParams([
878
- new StringChunk("("),
879
- chunk.getSQL(),
880
- new StringChunk(")")
881
- ], config);
882
- }
883
- if (inlineParams) {
884
- return { sql: this.mapInlineParam(chunk, config), params: [] };
885
- }
886
- return { sql: escapeParam(paramStartIndex.value++, chunk), params: [chunk], typings: ["none"] };
887
- }));
888
- }
889
- mapInlineParam(chunk, { escapeString }) {
890
- if (chunk === null) {
891
- return "null";
892
- }
893
- if (typeof chunk === "number" || typeof chunk === "boolean") {
894
- return chunk.toString();
895
- }
896
- if (typeof chunk === "string") {
897
- return escapeString(chunk);
898
- }
899
- if (typeof chunk === "object") {
900
- const mappedValueAsString = chunk.toString();
901
- if (mappedValueAsString === "[object Object]") {
902
- return escapeString(JSON.stringify(chunk));
903
- }
904
- return escapeString(mappedValueAsString);
905
- }
906
- throw new Error("Unexpected param value: " + chunk);
907
- }
908
- getSQL() {
909
- return this;
910
- }
911
- as(alias) {
912
- if (alias === void 0) {
913
- return this;
914
- }
915
- return new _SQL.Aliased(this, alias);
916
- }
917
- mapWith(decoder) {
918
- this.decoder = typeof decoder === "function" ? { mapFromDriverValue: decoder } : decoder;
919
- return this;
920
- }
921
- inlineParams() {
922
- this.shouldInlineParams = true;
923
- return this;
924
- }
925
- /**
926
- * This method is used to conditionally include a part of the query.
927
- *
928
- * @param condition - Condition to check
929
- * @returns itself if the condition is `true`, otherwise `undefined`
930
- */
931
- if(condition) {
932
- return condition ? this : void 0;
933
- }
934
- };
935
- var Name = class {
936
- constructor(value) {
937
- this.value = value;
938
- }
939
- static [entityKind] = "Name";
940
- brand;
941
- getSQL() {
942
- return new SQL([this]);
943
- }
944
- };
945
- var noopDecoder = {
946
- mapFromDriverValue: (value) => value
947
- };
948
- var noopEncoder = {
949
- mapToDriverValue: (value) => value
950
- };
951
- var noopMapper = {
952
- ...noopDecoder,
953
- ...noopEncoder
954
- };
955
- var Param = class {
956
- /**
957
- * @param value - Parameter value
958
- * @param encoder - Encoder to convert the value to a driver parameter
959
- */
960
- constructor(value, encoder = noopEncoder) {
961
- this.value = value;
962
- this.encoder = encoder;
963
- }
964
- static [entityKind] = "Param";
965
- brand;
966
- getSQL() {
967
- return new SQL([this]);
968
- }
969
- };
970
- function sql(strings, ...params) {
971
- const queryChunks = [];
972
- if (params.length > 0 || strings.length > 0 && strings[0] !== "") {
973
- queryChunks.push(new StringChunk(strings[0]));
974
- }
975
- for (const [paramIndex, param2] of params.entries()) {
976
- queryChunks.push(param2, new StringChunk(strings[paramIndex + 1]));
977
- }
978
- return new SQL(queryChunks);
979
- }
980
- ((sql2) => {
981
- function empty() {
982
- return new SQL([]);
983
- }
984
- sql2.empty = empty;
985
- function fromList(list) {
986
- return new SQL(list);
987
- }
988
- sql2.fromList = fromList;
989
- function raw(str) {
990
- return new SQL([new StringChunk(str)]);
991
- }
992
- sql2.raw = raw;
993
- function join(chunks, separator) {
994
- const result = [];
995
- for (const [i, chunk] of chunks.entries()) {
996
- if (i > 0 && separator !== void 0) {
997
- result.push(separator);
998
- }
999
- result.push(chunk);
1000
- }
1001
- return new SQL(result);
1002
- }
1003
- sql2.join = join;
1004
- function identifier(value) {
1005
- return new Name(value);
1006
- }
1007
- sql2.identifier = identifier;
1008
- function placeholder2(name2) {
1009
- return new Placeholder(name2);
1010
- }
1011
- sql2.placeholder = placeholder2;
1012
- function param2(value, encoder) {
1013
- return new Param(value, encoder);
1014
- }
1015
- sql2.param = param2;
1016
- })(sql || (sql = {}));
1017
- ((SQL2) => {
1018
- class Aliased {
1019
- constructor(sql2, fieldAlias) {
1020
- this.sql = sql2;
1021
- this.fieldAlias = fieldAlias;
1022
- }
1023
- static [entityKind] = "SQL.Aliased";
1024
- /** @internal */
1025
- isSelectionField = false;
1026
- getSQL() {
1027
- return this.sql;
1028
- }
1029
- /** @internal */
1030
- clone() {
1031
- return new Aliased(this.sql, this.fieldAlias);
1032
- }
1033
- }
1034
- SQL2.Aliased = Aliased;
1035
- })(SQL || (SQL = {}));
1036
- var Placeholder = class {
1037
- constructor(name2) {
1038
- this.name = name2;
1039
- }
1040
- static [entityKind] = "Placeholder";
1041
- getSQL() {
1042
- return new SQL([this]);
1043
- }
1044
- };
1045
- var View = class {
1046
- static [entityKind] = "View";
1047
- /** @internal */
1048
- [ViewBaseConfig];
1049
- constructor({ name: name2, schema, selectedFields, query }) {
1050
- this[ViewBaseConfig] = {
1051
- name: name2,
1052
- originalName: name2,
1053
- schema,
1054
- selectedFields,
1055
- query,
1056
- isExisting: !query,
1057
- isAlias: false
1058
- };
1059
- }
1060
- getSQL() {
1061
- return new SQL([this]);
1062
- }
1063
- };
1064
- Column.prototype.getSQL = function() {
1065
- return new SQL([this]);
1066
- };
1067
- Table.prototype.getSQL = function() {
1068
- return new SQL([this]);
1069
- };
1070
- Subquery.prototype.getSQL = function() {
1071
- return new SQL([this]);
1072
- };
1073
-
1074
- // ../../node_modules/.pnpm/drizzle-orm@0.36.4_@cloudflare+workers-types@4.20260416.2_@types+better-sqlite3@7.6.13__6bda8a68f3e10d0b03cd2031bac7989c/node_modules/drizzle-orm/utils.js
1075
- function getColumnNameAndConfig(a, b) {
1076
- return {
1077
- name: typeof a === "string" && a.length > 0 ? a : "",
1078
- config: typeof a === "object" ? a : b
1079
- };
1080
- }
1081
-
1082
- // ../../node_modules/.pnpm/drizzle-orm@0.36.4_@cloudflare+workers-types@4.20260416.2_@types+better-sqlite3@7.6.13__6bda8a68f3e10d0b03cd2031bac7989c/node_modules/drizzle-orm/sqlite-core/foreign-keys.js
1083
- var ForeignKeyBuilder2 = class {
1084
- static [entityKind] = "SQLiteForeignKeyBuilder";
1085
- /** @internal */
1086
- reference;
1087
- /** @internal */
1088
- _onUpdate;
1089
- /** @internal */
1090
- _onDelete;
1091
- constructor(config, actions) {
1092
- this.reference = () => {
1093
- const { name, columns, foreignColumns } = config();
1094
- return { name, columns, foreignTable: foreignColumns[0].table, foreignColumns };
1095
- };
1096
- if (actions) {
1097
- this._onUpdate = actions.onUpdate;
1098
- this._onDelete = actions.onDelete;
1099
- }
1100
- }
1101
- onUpdate(action) {
1102
- this._onUpdate = action;
1103
- return this;
1104
- }
1105
- onDelete(action) {
1106
- this._onDelete = action;
1107
- return this;
1108
- }
1109
- /** @internal */
1110
- build(table) {
1111
- return new ForeignKey2(table, this);
1112
- }
1113
- };
1114
- var ForeignKey2 = class {
1115
- constructor(table, builder) {
1116
- this.table = table;
1117
- this.reference = builder.reference;
1118
- this.onUpdate = builder._onUpdate;
1119
- this.onDelete = builder._onDelete;
1120
- }
1121
- static [entityKind] = "SQLiteForeignKey";
1122
- reference;
1123
- onUpdate;
1124
- onDelete;
1125
- getName() {
1126
- const { name, columns, foreignColumns } = this.reference();
1127
- const columnNames = columns.map((column) => column.name);
1128
- const foreignColumnNames = foreignColumns.map((column) => column.name);
1129
- const chunks = [
1130
- this.table[TableName],
1131
- ...columnNames,
1132
- foreignColumns[0].table[TableName],
1133
- ...foreignColumnNames
1134
- ];
1135
- return name ?? `${chunks.join("_")}_fk`;
1136
- }
1137
- };
1138
-
1139
- // ../../node_modules/.pnpm/drizzle-orm@0.36.4_@cloudflare+workers-types@4.20260416.2_@types+better-sqlite3@7.6.13__6bda8a68f3e10d0b03cd2031bac7989c/node_modules/drizzle-orm/sqlite-core/unique-constraint.js
1140
- function uniqueKeyName2(table, columns) {
1141
- return `${table[TableName]}_${columns.join("_")}_unique`;
1142
- }
1143
- var UniqueConstraintBuilder2 = class {
1144
- constructor(columns, name) {
1145
- this.name = name;
1146
- this.columns = columns;
1147
- }
1148
- static [entityKind] = "SQLiteUniqueConstraintBuilder";
1149
- /** @internal */
1150
- columns;
1151
- /** @internal */
1152
- build(table) {
1153
- return new UniqueConstraint2(table, this.columns, this.name);
1154
- }
1155
- };
1156
- var UniqueOnConstraintBuilder2 = class {
1157
- static [entityKind] = "SQLiteUniqueOnConstraintBuilder";
1158
- /** @internal */
1159
- name;
1160
- constructor(name) {
1161
- this.name = name;
1162
- }
1163
- on(...columns) {
1164
- return new UniqueConstraintBuilder2(columns, this.name);
1165
- }
1166
- };
1167
- var UniqueConstraint2 = class {
1168
- constructor(table, columns, name) {
1169
- this.table = table;
1170
- this.columns = columns;
1171
- this.name = name ?? uniqueKeyName2(this.table, this.columns.map((column) => column.name));
1172
- }
1173
- static [entityKind] = "SQLiteUniqueConstraint";
1174
- columns;
1175
- name;
1176
- getName() {
1177
- return this.name;
1178
- }
1179
- };
1180
-
1181
- // ../../node_modules/.pnpm/drizzle-orm@0.36.4_@cloudflare+workers-types@4.20260416.2_@types+better-sqlite3@7.6.13__6bda8a68f3e10d0b03cd2031bac7989c/node_modules/drizzle-orm/sqlite-core/columns/common.js
1182
- var SQLiteColumnBuilder = class extends ColumnBuilder {
1183
- static [entityKind] = "SQLiteColumnBuilder";
1184
- foreignKeyConfigs = [];
1185
- references(ref, actions = {}) {
1186
- this.foreignKeyConfigs.push({ ref, actions });
1187
- return this;
1188
- }
1189
- unique(name) {
1190
- this.config.isUnique = true;
1191
- this.config.uniqueName = name;
1192
- return this;
1193
- }
1194
- generatedAlwaysAs(as, config) {
1195
- this.config.generated = {
1196
- as,
1197
- type: "always",
1198
- mode: config?.mode ?? "virtual"
1199
- };
1200
- return this;
1201
- }
1202
- /** @internal */
1203
- buildForeignKeys(column, table) {
1204
- return this.foreignKeyConfigs.map(({ ref, actions }) => {
1205
- return ((ref2, actions2) => {
1206
- const builder = new ForeignKeyBuilder2(() => {
1207
- const foreignColumn = ref2();
1208
- return { columns: [column], foreignColumns: [foreignColumn] };
1209
- });
1210
- if (actions2.onUpdate) {
1211
- builder.onUpdate(actions2.onUpdate);
1212
- }
1213
- if (actions2.onDelete) {
1214
- builder.onDelete(actions2.onDelete);
1215
- }
1216
- return builder.build(table);
1217
- })(ref, actions);
1218
- });
1219
- }
1220
- };
1221
- var SQLiteColumn = class extends Column {
1222
- constructor(table, config) {
1223
- if (!config.uniqueName) {
1224
- config.uniqueName = uniqueKeyName2(table, [config.name]);
1225
- }
1226
- super(table, config);
1227
- this.table = table;
1228
- }
1229
- static [entityKind] = "SQLiteColumn";
1230
- };
1231
-
1232
- // ../../node_modules/.pnpm/drizzle-orm@0.36.4_@cloudflare+workers-types@4.20260416.2_@types+better-sqlite3@7.6.13__6bda8a68f3e10d0b03cd2031bac7989c/node_modules/drizzle-orm/sqlite-core/columns/blob.js
1233
- var SQLiteBigIntBuilder = class extends SQLiteColumnBuilder {
1234
- static [entityKind] = "SQLiteBigIntBuilder";
1235
- constructor(name) {
1236
- super(name, "bigint", "SQLiteBigInt");
1237
- }
1238
- /** @internal */
1239
- build(table) {
1240
- return new SQLiteBigInt(table, this.config);
1241
- }
1242
- };
1243
- var SQLiteBigInt = class extends SQLiteColumn {
1244
- static [entityKind] = "SQLiteBigInt";
1245
- getSQLType() {
1246
- return "blob";
1247
- }
1248
- mapFromDriverValue(value) {
1249
- return BigInt(Buffer.isBuffer(value) ? value.toString() : String.fromCodePoint(...value));
1250
- }
1251
- mapToDriverValue(value) {
1252
- return Buffer.from(value.toString());
1253
- }
1254
- };
1255
- var SQLiteBlobJsonBuilder = class extends SQLiteColumnBuilder {
1256
- static [entityKind] = "SQLiteBlobJsonBuilder";
1257
- constructor(name) {
1258
- super(name, "json", "SQLiteBlobJson");
1259
- }
1260
- /** @internal */
1261
- build(table) {
1262
- return new SQLiteBlobJson(
1263
- table,
1264
- this.config
1265
- );
1266
- }
1267
- };
1268
- var SQLiteBlobJson = class extends SQLiteColumn {
1269
- static [entityKind] = "SQLiteBlobJson";
1270
- getSQLType() {
1271
- return "blob";
1272
- }
1273
- mapFromDriverValue(value) {
1274
- return JSON.parse(Buffer.isBuffer(value) ? value.toString() : String.fromCodePoint(...value));
1275
- }
1276
- mapToDriverValue(value) {
1277
- return Buffer.from(JSON.stringify(value));
1278
- }
1279
- };
1280
- var SQLiteBlobBufferBuilder = class extends SQLiteColumnBuilder {
1281
- static [entityKind] = "SQLiteBlobBufferBuilder";
1282
- constructor(name) {
1283
- super(name, "buffer", "SQLiteBlobBuffer");
1284
- }
1285
- /** @internal */
1286
- build(table) {
1287
- return new SQLiteBlobBuffer(table, this.config);
1288
- }
1289
- };
1290
- var SQLiteBlobBuffer = class extends SQLiteColumn {
1291
- static [entityKind] = "SQLiteBlobBuffer";
1292
- getSQLType() {
1293
- return "blob";
1294
- }
1295
- };
1296
- function blob(a, b) {
1297
- const { name, config } = getColumnNameAndConfig(a, b);
1298
- if (config?.mode === "json") {
1299
- return new SQLiteBlobJsonBuilder(name);
1300
- }
1301
- if (config?.mode === "bigint") {
1302
- return new SQLiteBigIntBuilder(name);
1303
- }
1304
- return new SQLiteBlobBufferBuilder(name);
1305
- }
1306
-
1307
- // ../../node_modules/.pnpm/drizzle-orm@0.36.4_@cloudflare+workers-types@4.20260416.2_@types+better-sqlite3@7.6.13__6bda8a68f3e10d0b03cd2031bac7989c/node_modules/drizzle-orm/sqlite-core/columns/custom.js
1308
- var SQLiteCustomColumnBuilder = class extends SQLiteColumnBuilder {
1309
- static [entityKind] = "SQLiteCustomColumnBuilder";
1310
- constructor(name, fieldConfig, customTypeParams) {
1311
- super(name, "custom", "SQLiteCustomColumn");
1312
- this.config.fieldConfig = fieldConfig;
1313
- this.config.customTypeParams = customTypeParams;
1314
- }
1315
- /** @internal */
1316
- build(table) {
1317
- return new SQLiteCustomColumn(
1318
- table,
1319
- this.config
1320
- );
1321
- }
1322
- };
1323
- var SQLiteCustomColumn = class extends SQLiteColumn {
1324
- static [entityKind] = "SQLiteCustomColumn";
1325
- sqlName;
1326
- mapTo;
1327
- mapFrom;
1328
- constructor(table, config) {
1329
- super(table, config);
1330
- this.sqlName = config.customTypeParams.dataType(config.fieldConfig);
1331
- this.mapTo = config.customTypeParams.toDriver;
1332
- this.mapFrom = config.customTypeParams.fromDriver;
1333
- }
1334
- getSQLType() {
1335
- return this.sqlName;
1336
- }
1337
- mapFromDriverValue(value) {
1338
- return typeof this.mapFrom === "function" ? this.mapFrom(value) : value;
1339
- }
1340
- mapToDriverValue(value) {
1341
- return typeof this.mapTo === "function" ? this.mapTo(value) : value;
1342
- }
1343
- };
1344
- function customType(customTypeParams) {
1345
- return (a, b) => {
1346
- const { name, config } = getColumnNameAndConfig(a, b);
1347
- return new SQLiteCustomColumnBuilder(
1348
- name,
1349
- config,
1350
- customTypeParams
1351
- );
1352
- };
1353
- }
1354
-
1355
- // ../../node_modules/.pnpm/drizzle-orm@0.36.4_@cloudflare+workers-types@4.20260416.2_@types+better-sqlite3@7.6.13__6bda8a68f3e10d0b03cd2031bac7989c/node_modules/drizzle-orm/sqlite-core/columns/integer.js
1356
- var SQLiteBaseIntegerBuilder = class extends SQLiteColumnBuilder {
1357
- static [entityKind] = "SQLiteBaseIntegerBuilder";
1358
- constructor(name, dataType, columnType) {
1359
- super(name, dataType, columnType);
1360
- this.config.autoIncrement = false;
1361
- }
1362
- primaryKey(config) {
1363
- if (config?.autoIncrement) {
1364
- this.config.autoIncrement = true;
1365
- }
1366
- this.config.hasDefault = true;
1367
- return super.primaryKey();
1368
- }
1369
- };
1370
- var SQLiteBaseInteger = class extends SQLiteColumn {
1371
- static [entityKind] = "SQLiteBaseInteger";
1372
- autoIncrement = this.config.autoIncrement;
1373
- getSQLType() {
1374
- return "integer";
1375
- }
1376
- };
1377
- var SQLiteIntegerBuilder = class extends SQLiteBaseIntegerBuilder {
1378
- static [entityKind] = "SQLiteIntegerBuilder";
1379
- constructor(name) {
1380
- super(name, "number", "SQLiteInteger");
1381
- }
1382
- build(table) {
1383
- return new SQLiteInteger(
1384
- table,
1385
- this.config
1386
- );
1387
- }
1388
- };
1389
- var SQLiteInteger = class extends SQLiteBaseInteger {
1390
- static [entityKind] = "SQLiteInteger";
1391
- };
1392
- var SQLiteTimestampBuilder = class extends SQLiteBaseIntegerBuilder {
1393
- static [entityKind] = "SQLiteTimestampBuilder";
1394
- constructor(name, mode) {
1395
- super(name, "date", "SQLiteTimestamp");
1396
- this.config.mode = mode;
1397
- }
1398
- /**
1399
- * @deprecated Use `default()` with your own expression instead.
1400
- *
1401
- * Adds `DEFAULT (cast((julianday('now') - 2440587.5)*86400000 as integer))` to the column, which is the current epoch timestamp in milliseconds.
1402
- */
1403
- defaultNow() {
1404
- return this.default(sql`(cast((julianday('now') - 2440587.5)*86400000 as integer))`);
1405
- }
1406
- build(table) {
1407
- return new SQLiteTimestamp(
1408
- table,
1409
- this.config
1410
- );
1411
- }
1412
- };
1413
- var SQLiteTimestamp = class extends SQLiteBaseInteger {
1414
- static [entityKind] = "SQLiteTimestamp";
1415
- mode = this.config.mode;
1416
- mapFromDriverValue(value) {
1417
- if (this.config.mode === "timestamp") {
1418
- return new Date(value * 1e3);
1419
- }
1420
- return new Date(value);
1421
- }
1422
- mapToDriverValue(value) {
1423
- const unix = value.getTime();
1424
- if (this.config.mode === "timestamp") {
1425
- return Math.floor(unix / 1e3);
1426
- }
1427
- return unix;
1428
- }
1429
- };
1430
- var SQLiteBooleanBuilder = class extends SQLiteBaseIntegerBuilder {
1431
- static [entityKind] = "SQLiteBooleanBuilder";
1432
- constructor(name, mode) {
1433
- super(name, "boolean", "SQLiteBoolean");
1434
- this.config.mode = mode;
1435
- }
1436
- build(table) {
1437
- return new SQLiteBoolean(
1438
- table,
1439
- this.config
1440
- );
1441
- }
1442
- };
1443
- var SQLiteBoolean = class extends SQLiteBaseInteger {
1444
- static [entityKind] = "SQLiteBoolean";
1445
- mode = this.config.mode;
1446
- mapFromDriverValue(value) {
1447
- return Number(value) === 1;
1448
- }
1449
- mapToDriverValue(value) {
1450
- return value ? 1 : 0;
1451
- }
1452
- };
1453
- function integer(a, b) {
1454
- const { name, config } = getColumnNameAndConfig(a, b);
1455
- if (config?.mode === "timestamp" || config?.mode === "timestamp_ms") {
1456
- return new SQLiteTimestampBuilder(name, config.mode);
1457
- }
1458
- if (config?.mode === "boolean") {
1459
- return new SQLiteBooleanBuilder(name, config.mode);
1460
- }
1461
- return new SQLiteIntegerBuilder(name);
1462
- }
1463
-
1464
- // ../../node_modules/.pnpm/drizzle-orm@0.36.4_@cloudflare+workers-types@4.20260416.2_@types+better-sqlite3@7.6.13__6bda8a68f3e10d0b03cd2031bac7989c/node_modules/drizzle-orm/sqlite-core/columns/numeric.js
1465
- var SQLiteNumericBuilder = class extends SQLiteColumnBuilder {
1466
- static [entityKind] = "SQLiteNumericBuilder";
1467
- constructor(name) {
1468
- super(name, "string", "SQLiteNumeric");
1469
- }
1470
- /** @internal */
1471
- build(table) {
1472
- return new SQLiteNumeric(
1473
- table,
1474
- this.config
1475
- );
1476
- }
1477
- };
1478
- var SQLiteNumeric = class extends SQLiteColumn {
1479
- static [entityKind] = "SQLiteNumeric";
1480
- getSQLType() {
1481
- return "numeric";
1482
- }
1483
- };
1484
- function numeric(name) {
1485
- return new SQLiteNumericBuilder(name ?? "");
1486
- }
1487
-
1488
- // ../../node_modules/.pnpm/drizzle-orm@0.36.4_@cloudflare+workers-types@4.20260416.2_@types+better-sqlite3@7.6.13__6bda8a68f3e10d0b03cd2031bac7989c/node_modules/drizzle-orm/sqlite-core/columns/real.js
1489
- var SQLiteRealBuilder = class extends SQLiteColumnBuilder {
1490
- static [entityKind] = "SQLiteRealBuilder";
1491
- constructor(name) {
1492
- super(name, "number", "SQLiteReal");
1493
- }
1494
- /** @internal */
1495
- build(table) {
1496
- return new SQLiteReal(table, this.config);
1497
- }
1498
- };
1499
- var SQLiteReal = class extends SQLiteColumn {
1500
- static [entityKind] = "SQLiteReal";
1501
- getSQLType() {
1502
- return "real";
1503
- }
1504
- };
1505
- function real(name) {
1506
- return new SQLiteRealBuilder(name ?? "");
1507
- }
1508
-
1509
- // ../../node_modules/.pnpm/drizzle-orm@0.36.4_@cloudflare+workers-types@4.20260416.2_@types+better-sqlite3@7.6.13__6bda8a68f3e10d0b03cd2031bac7989c/node_modules/drizzle-orm/sqlite-core/columns/text.js
1510
- var SQLiteTextBuilder = class extends SQLiteColumnBuilder {
1511
- static [entityKind] = "SQLiteTextBuilder";
1512
- constructor(name, config) {
1513
- super(name, "string", "SQLiteText");
1514
- this.config.enumValues = config.enum;
1515
- this.config.length = config.length;
1516
- }
1517
- /** @internal */
1518
- build(table) {
1519
- return new SQLiteText(table, this.config);
1520
- }
1521
- };
1522
- var SQLiteText = class extends SQLiteColumn {
1523
- static [entityKind] = "SQLiteText";
1524
- enumValues = this.config.enumValues;
1525
- length = this.config.length;
1526
- constructor(table, config) {
1527
- super(table, config);
1528
- }
1529
- getSQLType() {
1530
- return `text${this.config.length ? `(${this.config.length})` : ""}`;
1531
- }
1532
- };
1533
- var SQLiteTextJsonBuilder = class extends SQLiteColumnBuilder {
1534
- static [entityKind] = "SQLiteTextJsonBuilder";
1535
- constructor(name) {
1536
- super(name, "json", "SQLiteTextJson");
1537
- }
1538
- /** @internal */
1539
- build(table) {
1540
- return new SQLiteTextJson(
1541
- table,
1542
- this.config
1543
- );
1544
- }
1545
- };
1546
- var SQLiteTextJson = class extends SQLiteColumn {
1547
- static [entityKind] = "SQLiteTextJson";
1548
- getSQLType() {
1549
- return "text";
1550
- }
1551
- mapFromDriverValue(value) {
1552
- return JSON.parse(value);
1553
- }
1554
- mapToDriverValue(value) {
1555
- return JSON.stringify(value);
1556
- }
1557
- };
1558
- function text(a, b = {}) {
1559
- const { name, config } = getColumnNameAndConfig(a, b);
1560
- if (config.mode === "json") {
1561
- return new SQLiteTextJsonBuilder(name);
1562
- }
1563
- return new SQLiteTextBuilder(name, config);
1564
- }
1565
-
1566
- // ../../node_modules/.pnpm/drizzle-orm@0.36.4_@cloudflare+workers-types@4.20260416.2_@types+better-sqlite3@7.6.13__6bda8a68f3e10d0b03cd2031bac7989c/node_modules/drizzle-orm/sqlite-core/columns/all.js
1567
- function getSQLiteColumnBuilders() {
1568
- return {
1569
- blob,
1570
- customType,
1571
- integer,
1572
- numeric,
1573
- real,
1574
- text
1575
- };
1576
- }
1577
-
1578
- // ../../node_modules/.pnpm/drizzle-orm@0.36.4_@cloudflare+workers-types@4.20260416.2_@types+better-sqlite3@7.6.13__6bda8a68f3e10d0b03cd2031bac7989c/node_modules/drizzle-orm/sqlite-core/table.js
1579
- var InlineForeignKeys = /* @__PURE__ */ Symbol.for("drizzle:SQLiteInlineForeignKeys");
1580
- var SQLiteTable = class extends Table {
1581
- static [entityKind] = "SQLiteTable";
1582
- /** @internal */
1583
- static Symbol = Object.assign({}, Table.Symbol, {
1584
- InlineForeignKeys
1585
- });
1586
- /** @internal */
1587
- [Table.Symbol.Columns];
1588
- /** @internal */
1589
- [InlineForeignKeys] = [];
1590
- /** @internal */
1591
- [Table.Symbol.ExtraConfigBuilder] = void 0;
1592
- };
1593
- function sqliteTableBase(name, columns, extraConfig, schema, baseName = name) {
1594
- const rawTable = new SQLiteTable(name, schema, baseName);
1595
- const parsedColumns = typeof columns === "function" ? columns(getSQLiteColumnBuilders()) : columns;
1596
- const builtColumns = Object.fromEntries(
1597
- Object.entries(parsedColumns).map(([name2, colBuilderBase]) => {
1598
- const colBuilder = colBuilderBase;
1599
- colBuilder.setName(name2);
1600
- const column = colBuilder.build(rawTable);
1601
- rawTable[InlineForeignKeys].push(...colBuilder.buildForeignKeys(column, rawTable));
1602
- return [name2, column];
1603
- })
1604
- );
1605
- const table = Object.assign(rawTable, builtColumns);
1606
- table[Table.Symbol.Columns] = builtColumns;
1607
- table[Table.Symbol.ExtraConfigColumns] = builtColumns;
1608
- if (extraConfig) {
1609
- table[SQLiteTable.Symbol.ExtraConfigBuilder] = extraConfig;
1610
- }
1611
- return table;
1612
- }
1613
- var sqliteTable = (name, columns, extraConfig) => {
1614
- return sqliteTableBase(name, columns, extraConfig);
1615
- };
1616
-
1617
- // ../../node_modules/.pnpm/drizzle-orm@0.36.4_@cloudflare+workers-types@4.20260416.2_@types+better-sqlite3@7.6.13__6bda8a68f3e10d0b03cd2031bac7989c/node_modules/drizzle-orm/sqlite-core/indexes.js
1618
- var IndexBuilderOn = class {
1619
- constructor(name, unique) {
1620
- this.name = name;
1621
- this.unique = unique;
1622
- }
1623
- static [entityKind] = "SQLiteIndexBuilderOn";
1624
- on(...columns) {
1625
- return new IndexBuilder(this.name, columns, this.unique);
1626
- }
1627
- };
1628
- var IndexBuilder = class {
1629
- static [entityKind] = "SQLiteIndexBuilder";
1630
- /** @internal */
1631
- config;
1632
- constructor(name, columns, unique) {
1633
- this.config = {
1634
- name,
1635
- columns,
1636
- unique,
1637
- where: void 0
1638
- };
1639
- }
1640
- /**
1641
- * Condition for partial index.
1642
- */
1643
- where(condition) {
1644
- this.config.where = condition;
1645
- return this;
1646
- }
1647
- /** @internal */
1648
- build(table) {
1649
- return new Index(this.config, table);
1650
- }
1651
- };
1652
- var Index = class {
1653
- static [entityKind] = "SQLiteIndex";
1654
- config;
1655
- constructor(config, table) {
1656
- this.config = { ...config, table };
1657
- }
1658
- };
1659
- function index(name) {
1660
- return new IndexBuilderOn(name, false);
1661
- }
1662
- function uniqueIndex(name) {
1663
- return new IndexBuilderOn(name, true);
1664
- }
1665
-
1666
- // ../../node_modules/.pnpm/drizzle-orm@0.36.4_@cloudflare+workers-types@4.20260416.2_@types+better-sqlite3@7.6.13__6bda8a68f3e10d0b03cd2031bac7989c/node_modules/drizzle-orm/sqlite-core/primary-keys.js
1667
- function primaryKey(...config) {
1668
- if (config[0].columns) {
1669
- return new PrimaryKeyBuilder(config[0].columns, config[0].name);
1670
- }
1671
- return new PrimaryKeyBuilder(config);
1672
- }
1673
- var PrimaryKeyBuilder = class {
1674
- static [entityKind] = "SQLitePrimaryKeyBuilder";
1675
- /** @internal */
1676
- columns;
1677
- /** @internal */
1678
- name;
1679
- constructor(columns, name) {
1680
- this.columns = columns;
1681
- this.name = name;
1682
- }
1683
- /** @internal */
1684
- build(table) {
1685
- return new PrimaryKey(table, this.columns, this.name);
1686
- }
1687
- };
1688
- var PrimaryKey = class {
1689
- constructor(table, columns, name) {
1690
- this.table = table;
1691
- this.columns = columns;
1692
- this.name = name;
1693
- }
1694
- static [entityKind] = "SQLitePrimaryKey";
1695
- columns;
1696
- name;
1697
- getName() {
1698
- return this.name ?? `${this.table[SQLiteTable.Symbol.Name]}_${this.columns.map((column) => column.name).join("_")}_pk`;
1699
- }
1700
- };
4
+ // src/schemas/configs.ts
5
+ import { z as z2 } from "zod";
1701
6
 
1702
- // ../core/src/db/schema.ts
1703
- var projects = sqliteTable(
1704
- "projects",
1705
- {
1706
- id: text("id").primaryKey(),
1707
- name: text("name").notNull(),
1708
- domain: text("domain"),
1709
- ownerEmail: text("owner_email").notNull(),
1710
- plan: text("plan", { enum: ["free", "paid"] }).notNull().default("free"),
1711
- status: text("status", { enum: ["active", "inactive"] }).notNull().default("active"),
1712
- // Stripe billing
1713
- stripeCustomerId: text("stripe_customer_id").unique(),
1714
- stripeSubscriptionId: text("stripe_subscription_id").unique(),
1715
- stripeItemIdBase: text("stripe_item_id_base"),
1716
- stripeItemIdExperiments: text("stripe_item_id_experiments"),
1717
- stripeItemIdGates: text("stripe_item_id_gates"),
1718
- stripeItemIdConfigs: text("stripe_item_id_configs"),
1719
- subscriptionStatus: text("subscription_status", {
1720
- enum: ["none", "trialing", "active", "past_due", "canceled", "incomplete"]
1721
- }).notNull().default("none"),
1722
- currentPeriodEnd: text("current_period_end"),
1723
- trialEndsAt: text("trial_ends_at"),
1724
- cancelAtPeriodEnd: integer("cancel_at_period_end").notNull().default(0),
1725
- billingInterval: text("billing_interval", { enum: ["monthly", "annual"] }).notNull().default("monthly"),
1726
- // Per-project module toggles. Control which surfaces (admin tabs, devtools
1727
- // panels) are exposed for this project. All default to enabled so existing
1728
- // projects keep their full feature set after the migration.
1729
- moduleTranslations: integer("module_translations", { mode: "boolean" }).notNull().default(true),
1730
- moduleConfigs: integer("module_configs", { mode: "boolean" }).notNull().default(true),
1731
- moduleGates: integer("module_gates", { mode: "boolean" }).notNull().default(true),
1732
- moduleExperiments: integer("module_experiments", { mode: "boolean" }).notNull().default(true),
1733
- moduleFeedback: integer("module_feedback", { mode: "boolean" }).notNull().default(true),
1734
- moduleUser: integer("module_user", { mode: "boolean" }).notNull().default(true),
1735
- moduleEvents: integer("module_events", { mode: "boolean" }).notNull().default(true),
1736
- createdAt: text("created_at").notNull(),
1737
- updatedAt: text("updated_at").notNull()
1738
- },
1739
- (t) => ({
1740
- // One project per (owner, domain): a single account can't accidentally
1741
- // create two projects pointing at the same site. Multiple projects per
1742
- // owner are still allowed across different domains, and `domain` may be
1743
- // NULL for projects without a configured site (SQLite treats each NULL
1744
- // as distinct under UNIQUE, so multiple no-domain projects per owner are
1745
- // permitted).
1746
- ownerDomainUniq: uniqueIndex("projects_owner_domain_uniq").on(t.ownerEmail, t.domain)
1747
- })
1748
- );
1749
- var users = sqliteTable("users", {
1750
- email: text("email").primaryKey(),
1751
- termsAcceptedAt: text("terms_accepted_at"),
1752
- termsVersion: text("terms_version"),
1753
- onboardingCompletedAt: text("onboarding_completed_at"),
1754
- createdAt: text("created_at").notNull(),
1755
- updatedAt: text("updated_at").notNull()
1756
- });
1757
- var projectMembers = sqliteTable(
1758
- "project_members",
1759
- {
1760
- id: text("id").primaryKey(),
1761
- projectId: text("project_id").notNull().references(() => projects.id, { onDelete: "cascade" }),
1762
- email: text("email").notNull(),
1763
- role: text("role", { enum: ["admin", "editor", "viewer"] }).notNull().default("editor"),
1764
- status: text("status", { enum: ["active", "pending", "removed"] }).notNull().default("pending"),
1765
- invitedByEmail: text("invited_by_email").notNull(),
1766
- invitedAt: text("invited_at").notNull(),
1767
- acceptedAt: text("accepted_at"),
1768
- removedAt: text("removed_at")
1769
- },
1770
- (t) => ({
1771
- projectIdx: index("project_members_project").on(t.projectId, t.status),
1772
- projectEmailUniq: uniqueIndex("project_members_project_email").on(t.projectId, t.email)
1773
- })
1774
- );
1775
- var sdkKeys = sqliteTable(
1776
- "sdk_keys",
1777
- {
1778
- id: text("id").primaryKey(),
1779
- projectId: text("project_id").notNull().references(() => projects.id, { onDelete: "cascade" }),
1780
- keyHash: text("key_hash").unique().notNull(),
1781
- type: text("type", { enum: ["server", "client", "admin"] }).notNull(),
1782
- scope: text("scope", { enum: ["experiments", "i18n"] }).notNull().default("experiments"),
1783
- createdAt: text("created_at").notNull(),
1784
- revokedAt: text("revoked_at"),
1785
- expiresAt: text("expires_at"),
1786
- // Email of the human who minted this key (admin keys via dashboard or
1787
- // CLI device-flow). Used to authorize cross-project --project overrides
1788
- // by joining against project_members. Null for older keys + for
1789
- // service-to-service keys without a human owner.
1790
- createdByEmail: text("created_by_email")
1791
- },
1792
- (t) => ({ hashIdx: index("sdk_keys_hash").on(t.keyHash) })
1793
- );
1794
- var cliAuthSessions = sqliteTable(
1795
- "cli_auth_sessions",
1796
- {
1797
- state: text("state").primaryKey(),
1798
- codeChallenge: text("code_challenge").notNull(),
1799
- projectId: text("project_id").references(() => projects.id),
1800
- tokenHash: text("token_hash"),
1801
- status: text("status", { enum: ["pending", "complete", "expired"] }).notNull().default("pending"),
1802
- createdAt: text("created_at").notNull(),
1803
- expiresAt: text("expires_at").notNull(),
1804
- completedAt: text("completed_at")
1805
- },
1806
- (t) => ({ expiresIdx: index("cli_auth_sessions_expires").on(t.expiresAt) })
1807
- );
1808
- var cliTokens = sqliteTable(
1809
- "cli_tokens",
1810
- {
1811
- tokenId: text("token_id").primaryKey(),
1812
- projectId: text("project_id").notNull().references(() => projects.id, { onDelete: "cascade" }),
1813
- userEmail: text("user_email").notNull(),
1814
- issuedAt: text("issued_at").notNull(),
1815
- expiresAt: text("expires_at").notNull(),
1816
- revokedAt: text("revoked_at"),
1817
- lastUsedAt: text("last_used_at")
1818
- },
1819
- (t) => ({
1820
- projectIdx: index("cli_tokens_project").on(t.projectId),
1821
- expiresIdx: index("cli_tokens_expires").on(t.expiresAt)
1822
- })
1823
- );
1824
- var analysisFailures = sqliteTable("analysis_failures", {
1825
- projectId: text("project_id").primaryKey().references(() => projects.id),
1826
- failedAt: text("failed_at").notNull(),
1827
- retryCount: integer("retry_count").notNull().default(3),
1828
- messageBody: text("message_body"),
1829
- resolvedAt: text("resolved_at")
1830
- });
1831
- var systemHealth = sqliteTable("system_health", {
1832
- key: text("key").primaryKey(),
1833
- lastFiredAt: text("last_fired_at").notNull(),
1834
- projectsEnqueued: integer("projects_enqueued")
1835
- });
1836
- var auditLog = sqliteTable(
1837
- "audit_log",
1838
- {
1839
- id: text("id").primaryKey(),
1840
- projectId: text("project_id").notNull().references(() => projects.id),
1841
- actorEmail: text("actor_email").notNull(),
1842
- actorType: text("actor_type", { enum: ["user", "cli", "system"] }).notNull(),
1843
- action: text("action").notNull(),
1844
- resourceType: text("resource_type").notNull(),
1845
- resourceId: text("resource_id"),
1846
- payload: text("payload"),
1847
- createdAt: text("created_at").notNull()
1848
- },
1849
- (t) => ({
1850
- projectIdx: index("audit_log_project").on(t.projectId, t.createdAt),
1851
- actorIdx: index("audit_log_actor").on(t.actorEmail),
1852
- resourceIdx: index("audit_log_resource").on(t.resourceType, t.resourceId)
1853
- })
1854
- );
1855
- var gates = sqliteTable(
1856
- "gates",
1857
- {
1858
- id: text("id").primaryKey(),
1859
- projectId: text("project_id").notNull().references(() => projects.id, { onDelete: "cascade" }),
1860
- name: text("name").notNull(),
1861
- rules: text("rules", { mode: "json" }).$type().notNull(),
1862
- rolloutPct: integer("rollout_pct").notNull().default(0),
1863
- salt: text("salt").notNull(),
1864
- enabled: integer("enabled").notNull().default(1),
1865
- // Gatekeeper metadata + ordered sub-gate stack. Stack is null on rows that
1866
- // predate the gatekeeper migration; eval falls back to rules+rolloutPct.
1867
- title: text("title"),
1868
- description: text("description"),
1869
- folder: text("folder"),
1870
- groupName: text("group_name"),
1871
- ownerEmail: text("owner_email"),
1872
- stack: text("stack", { mode: "json" }).$type(),
1873
- updatedAt: text("updated_at").notNull(),
1874
- deletedAt: text("deleted_at")
1875
- },
1876
- (t) => ({
1877
- projectIdx: index("gates_project").on(t.projectId),
1878
- projectNameUniq: uniqueIndex("gates_project_name").on(t.projectId, t.name).where(sql`deleted_at is null`)
1879
- })
1880
- );
7
+ // src/schemas/constants.ts
1881
8
  var CONFIG_ENVS = ["dev", "staging", "prod"];
1882
9
  var CONFIG_KINDS = ["config", "killswitch"];
1883
- var DEFAULT_CONFIG_SCHEMA = {
1884
- type: "object",
1885
- properties: {},
1886
- additionalProperties: true
1887
- };
1888
- var configs = sqliteTable(
1889
- "configs",
1890
- {
1891
- id: text("id").primaryKey(),
1892
- projectId: text("project_id").notNull().references(() => projects.id, { onDelete: "cascade" }),
1893
- name: text("name").notNull(),
1894
- description: text("description"),
1895
- kind: text("kind", { enum: CONFIG_KINDS }).notNull().default("config"),
1896
- schemaJson: text("schema_json", { mode: "json" }).$type().notNull().default(DEFAULT_CONFIG_SCHEMA),
1897
- updatedAt: text("updated_at").notNull(),
1898
- deletedAt: text("deleted_at")
1899
- },
1900
- (t) => ({
1901
- uniq: uniqueIndex("configs_project_name").on(t.projectId, t.name).where(sql`deleted_at is null`)
1902
- })
1903
- );
1904
- var configValues = sqliteTable(
1905
- "config_values",
1906
- {
1907
- id: text("id").primaryKey(),
1908
- projectId: text("project_id").notNull().references(() => projects.id, { onDelete: "cascade" }),
1909
- configId: text("config_id").notNull().references(() => configs.id, { onDelete: "cascade" }),
1910
- env: text("env", { enum: CONFIG_ENVS }).notNull(),
1911
- valueJson: text("value_json", { mode: "json" }).$type().notNull(),
1912
- version: integer("version").notNull(),
1913
- publishedAt: text("published_at").notNull(),
1914
- publishedBy: text("published_by").notNull()
1915
- },
1916
- (t) => ({
1917
- projectIdx: index("config_values_project").on(t.projectId),
1918
- configEnvIdx: index("config_values_config_env").on(t.configId, t.env, t.version),
1919
- uniq: uniqueIndex("config_values_config_env_version").on(t.configId, t.env, t.version)
1920
- })
1921
- );
1922
- var configDrafts = sqliteTable(
1923
- "config_drafts",
1924
- {
1925
- id: text("id").primaryKey(),
1926
- projectId: text("project_id").notNull().references(() => projects.id, { onDelete: "cascade" }),
1927
- configId: text("config_id").notNull().references(() => configs.id, { onDelete: "cascade" }),
1928
- env: text("env", { enum: CONFIG_ENVS }).notNull(),
1929
- valueJson: text("value_json", { mode: "json" }).$type().notNull(),
1930
- baseVersion: integer("base_version").notNull(),
1931
- authorEmail: text("author_email").notNull(),
1932
- createdAt: text("created_at").notNull(),
1933
- updatedAt: text("updated_at").notNull()
1934
- },
1935
- (t) => ({
1936
- projectIdx: index("config_drafts_project").on(t.projectId),
1937
- uniq: uniqueIndex("config_drafts_config_env").on(t.configId, t.env)
1938
- })
1939
- );
1940
- var universes = sqliteTable(
1941
- "universes",
1942
- {
1943
- id: text("id").primaryKey(),
1944
- projectId: text("project_id").notNull().references(() => projects.id, { onDelete: "cascade" }),
1945
- name: text("name").notNull(),
1946
- unitType: text("unit_type").notNull().default("user_id"),
1947
- holdoutRange: text("holdout_range", { mode: "json" }).$type(),
1948
- createdAt: text("created_at").notNull(),
1949
- deletedAt: text("deleted_at")
1950
- },
1951
- (t) => ({
1952
- projectIdx: index("universes_project").on(t.projectId),
1953
- projectUniq: uniqueIndex("universes_project_name").on(t.projectId, t.name).where(sql`deleted_at is null`)
1954
- })
1955
- );
1956
- var experiments = sqliteTable(
1957
- "experiments",
1958
- {
1959
- id: text("id").primaryKey(),
1960
- projectId: text("project_id").notNull().references(() => projects.id, { onDelete: "cascade" }),
1961
- name: text("name").notNull(),
1962
- description: text("description"),
1963
- tag: text("tag"),
1964
- universe: text("universe").notNull(),
1965
- targetingGate: text("targeting_gate"),
1966
- allocationPct: integer("allocation_pct").notNull().default(0),
1967
- salt: text("salt").notNull(),
1968
- params: text("params", { mode: "json" }).$type().notNull(),
1969
- groups: text("groups", { mode: "json" }).$type().notNull(),
1970
- status: text("status", { enum: ["draft", "running", "stopped", "archived"] }).notNull().default("draft"),
1971
- startedAt: text("started_at"),
1972
- stoppedAt: text("stopped_at"),
1973
- significanceThreshold: real("significance_threshold").notNull().default(0.05),
1974
- minRuntimeDays: integer("min_runtime_days").notNull().default(0),
1975
- minSampleSize: integer("min_sample_size").notNull().default(100),
1976
- cupedFrozenAt: text("cuped_frozen_at"),
1977
- sequentialTesting: integer("sequential_testing", { mode: "boolean" }).notNull().default(false),
1978
- hashVersion: integer("hash_version").notNull().default(1),
1979
- updatedAt: text("updated_at").notNull()
1980
- },
1981
- (t) => ({
1982
- projectIdx: index("experiments_project").on(t.projectId),
1983
- projectUniq: uniqueIndex("experiments_project_name").on(t.projectId, t.name)
1984
- })
1985
- );
1986
- var events = sqliteTable(
1987
- "events",
1988
- {
1989
- id: text("id").primaryKey(),
1990
- projectId: text("project_id").notNull().references(() => projects.id, { onDelete: "cascade" }),
1991
- name: text("name").notNull(),
1992
- description: text("description"),
1993
- properties: text("properties", { mode: "json" }).$type().notNull().default([]),
1994
- pending: integer("pending").notNull().default(0),
1995
- createdAt: text("created_at").notNull(),
1996
- deletedAt: text("deleted_at")
1997
- },
1998
- (t) => ({
1999
- projectIdx: index("events_project").on(t.projectId),
2000
- projectUniq: uniqueIndex("events_project_name").on(t.projectId, t.name).where(sql`deleted_at is null`)
2001
- })
2002
- );
2003
- var metrics = sqliteTable(
2004
- "metrics",
2005
- {
2006
- id: text("id").primaryKey(),
2007
- projectId: text("project_id").notNull().references(() => projects.id, { onDelete: "cascade" }),
2008
- name: text("name").notNull(),
2009
- eventName: text("event_name").notNull(),
2010
- valuePath: text("value_path"),
2011
- aggregation: text("aggregation", {
2012
- enum: ["count_users", "count_events", "sum", "avg", "retention_Nd"]
2013
- }).notNull().default("count_users"),
2014
- winsorizePct: integer("winsorize_pct").notNull().default(99),
2015
- minDetectableEffect: real("min_detectable_effect"),
2016
- updatedAt: text("updated_at").notNull(),
2017
- deletedAt: text("deleted_at")
2018
- },
2019
- (t) => ({
2020
- uniq: uniqueIndex("metrics_project_name").on(t.projectId, t.name).where(sql`deleted_at is null`)
2021
- })
2022
- );
2023
- var experimentMetrics = sqliteTable(
2024
- "experiment_metrics",
2025
- {
2026
- id: text("id").primaryKey(),
2027
- experimentId: text("experiment_id").notNull().references(() => experiments.id, { onDelete: "cascade" }),
2028
- metricId: text("metric_id").notNull().references(() => metrics.id, { onDelete: "cascade" }),
2029
- role: text("role", { enum: ["goal", "guardrail", "secondary"] }).notNull(),
2030
- createdAt: integer("created_at").notNull()
2031
- },
2032
- (t) => ({ uniq: uniqueIndex("exp_metrics_uniq").on(t.experimentId, t.metricId) })
2033
- );
2034
- var experimentResults = sqliteTable(
2035
- "experiment_results",
2036
- {
2037
- projectId: text("project_id").notNull(),
2038
- experiment: text("experiment").notNull(),
2039
- metric: text("metric").notNull(),
2040
- groupName: text("group_name").notNull(),
2041
- ds: text("ds").notNull(),
2042
- n: integer("n"),
2043
- mean: real("mean"),
2044
- variance: real("variance"),
2045
- delta: real("delta"),
2046
- deltaPct: real("delta_pct"),
2047
- ci95Low: real("ci_95_low"),
2048
- ci95High: real("ci_95_high"),
2049
- ci99Low: real("ci_99_low"),
2050
- ci99High: real("ci_99_high"),
2051
- pValue: real("p_value"),
2052
- expectedN: integer("expected_n"),
2053
- srmPValue: real("srm_p_value"),
2054
- srmDetected: integer("srm_detected").notNull().default(0),
2055
- msprtLambda: real("msprt_lambda"),
2056
- msprtSignificant: integer("msprt_significant"),
2057
- isFinal: integer("is_final").notNull().default(0),
2058
- peekWarning: integer("peek_warning").notNull().default(0)
2059
- },
2060
- (t) => ({
2061
- pk: primaryKey({ columns: [t.projectId, t.experiment, t.metric, t.groupName, t.ds] }),
2062
- dsIdx: index("experiment_results_ds").on(t.projectId, t.ds)
2063
- })
2064
- );
2065
- var userMetricBaseline = sqliteTable(
2066
- "user_metric_baseline",
2067
- {
2068
- projectId: text("project_id").notNull(),
2069
- userId: text("user_id").notNull(),
2070
- metricName: text("metric_name").notNull(),
2071
- avgValue: real("avg_value").notNull(),
2072
- updatedDs: text("updated_ds").notNull()
2073
- },
2074
- (t) => ({ pk: primaryKey({ columns: [t.projectId, t.userId, t.metricName] }) })
2075
- );
2076
- var userAliases = sqliteTable(
2077
- "user_aliases",
2078
- {
2079
- projectId: text("project_id").notNull(),
2080
- anonymousId: text("anonymous_id").notNull(),
2081
- userId: text("user_id").notNull(),
2082
- createdAt: text("created_at").notNull()
2083
- },
2084
- (t) => ({
2085
- pk: primaryKey({ columns: [t.projectId, t.anonymousId] }),
2086
- userIdx: index("user_aliases_user").on(t.projectId, t.userId)
2087
- })
2088
- );
2089
- var userAttributes = sqliteTable(
2090
- "user_attributes",
2091
- {
2092
- id: text("id").primaryKey(),
2093
- projectId: text("project_id").notNull().references(() => projects.id, { onDelete: "cascade" }),
2094
- name: text("name").notNull(),
2095
- type: text("type", { enum: ["string", "number", "boolean", "enum", "date"] }).notNull(),
2096
- enumValues: text("enum_values", { mode: "json" }).$type(),
2097
- required: integer("required").notNull().default(0),
2098
- description: text("description"),
2099
- sdkPath: text("sdk_path"),
2100
- createdAt: text("created_at").notNull(),
2101
- deletedAt: text("deleted_at")
2102
- },
2103
- (t) => ({
2104
- projectIdx: index("user_attributes_project").on(t.projectId),
2105
- projectUniq: uniqueIndex("user_attributes_project_name").on(t.projectId, t.name).where(sql`deleted_at is null`)
2106
- })
2107
- );
2108
- var labelProfiles = sqliteTable(
2109
- "label_profiles",
2110
- {
2111
- id: text("id").primaryKey(),
2112
- projectId: text("project_id").notNull().references(() => projects.id, { onDelete: "cascade" }),
2113
- name: text("name").notNull(),
2114
- defaultChunkId: text("default_chunk_id"),
2115
- createdAt: text("created_at").notNull(),
2116
- deletedAt: text("deleted_at")
2117
- },
2118
- (t) => ({
2119
- projectIdx: index("label_profiles_project").on(t.projectId),
2120
- projectNameUniq: uniqueIndex("label_profiles_project_name").on(t.projectId, t.name).where(sql`deleted_at is null`)
2121
- })
2122
- );
2123
- var labelChunks = sqliteTable(
2124
- "label_chunks",
2125
- {
2126
- id: text("id").primaryKey(),
2127
- projectId: text("project_id").notNull(),
2128
- profileId: text("profile_id").notNull().references(() => labelProfiles.id, { onDelete: "cascade" }),
2129
- name: text("name").notNull(),
2130
- isIndex: integer("is_index").notNull().default(0),
2131
- publishedUrl: text("published_url"),
2132
- publishedHash: text("published_hash"),
2133
- publishedAt: text("published_at"),
2134
- etag: text("etag")
2135
- },
2136
- (t) => ({
2137
- projectIdx: index("label_chunks_project").on(t.projectId),
2138
- profileNameUniq: uniqueIndex("label_chunks_profile_name").on(t.profileId, t.name)
2139
- })
2140
- );
2141
- var labelKeys = sqliteTable(
2142
- "label_keys",
2143
- {
2144
- id: text("id").primaryKey(),
2145
- projectId: text("project_id").notNull(),
2146
- profileId: text("profile_id").notNull().references(() => labelProfiles.id, { onDelete: "cascade" }),
2147
- chunkId: text("chunk_id").notNull().references(() => labelChunks.id, { onDelete: "cascade" }),
2148
- key: text("key").notNull(),
2149
- value: text("value").notNull(),
2150
- description: text("description"),
2151
- // JSON array of variable names extracted from the value's {{var}} placeholders.
2152
- // `null` = no variables detected; `[]` = explicitly none (normalized).
2153
- variables: text("variables", { mode: "json" }).$type(),
2154
- updatedAt: text("updated_at").notNull(),
2155
- updatedBy: text("updated_by").notNull()
2156
- },
2157
- (t) => ({
2158
- projectIdx: index("label_keys_project").on(t.projectId),
2159
- chunkIdx: index("label_keys_chunk").on(t.chunkId),
2160
- profileKeyUniq: uniqueIndex("label_keys_profile_key").on(t.profileId, t.key)
2161
- })
2162
- );
2163
- var labelDrafts = sqliteTable(
2164
- "label_drafts",
2165
- {
2166
- id: text("id").primaryKey(),
2167
- projectId: text("project_id").notNull(),
2168
- profileId: text("profile_id").notNull().references(() => labelProfiles.id, { onDelete: "cascade" }),
2169
- name: text("name").notNull(),
2170
- sourceProfileId: text("source_profile_id").references(() => labelProfiles.id, {
2171
- onDelete: "set null"
2172
- }),
2173
- createdBy: text("created_by").notNull(),
2174
- status: text("status", { enum: ["open", "merged", "abandoned"] }).notNull().default("open"),
2175
- createdAt: text("created_at").notNull(),
2176
- publishedAt: text("published_at")
2177
- },
2178
- (t) => ({
2179
- projectIdx: index("label_drafts_project").on(t.projectId),
2180
- projectNameUniq: uniqueIndex("label_drafts_project_name").on(t.projectId, t.name)
2181
- })
2182
- );
2183
- var labelDraftKeys = sqliteTable(
2184
- "label_draft_keys",
2185
- {
2186
- id: text("id").primaryKey(),
2187
- projectId: text("project_id").notNull(),
2188
- draftId: text("draft_id").notNull().references(() => labelDrafts.id, { onDelete: "cascade" }),
2189
- key: text("key").notNull(),
2190
- value: text("value").notNull(),
2191
- description: text("description"),
2192
- variables: text("variables", { mode: "json" }).$type(),
2193
- updatedBy: text("updated_by").notNull(),
2194
- updatedAt: text("updated_at").notNull()
2195
- },
2196
- (t) => ({
2197
- draftKeyUniq: uniqueIndex("label_draft_keys_draft_key").on(t.draftId, t.key),
2198
- projectIdx: index("label_draft_keys_project").on(t.projectId)
2199
- })
2200
- );
2201
- var BUG_STATUSES = ["open", "triaged", "in_progress", "resolved", "wont_fix"];
2202
- var BUG_PRIORITIES = ["low", "medium", "high", "critical"];
2203
- var bugReports = sqliteTable(
2204
- "bug_reports",
2205
- {
2206
- id: text("id").primaryKey(),
2207
- projectId: text("project_id").notNull().references(() => projects.id, { onDelete: "cascade" }),
2208
- title: text("title").notNull(),
2209
- stepsToReproduce: text("steps_to_reproduce").notNull().default(""),
2210
- actualResult: text("actual_result").notNull().default(""),
2211
- expectedResult: text("expected_result").notNull().default(""),
2212
- status: text("status", { enum: BUG_STATUSES }).notNull().default("open"),
2213
- priority: text("priority", { enum: BUG_PRIORITIES }),
2214
- reporterEmail: text("reporter_email"),
2215
- pageUrl: text("page_url"),
2216
- userAgent: text("user_agent"),
2217
- viewport: text("viewport"),
2218
- context: text("context", { mode: "json" }).$type(),
2219
- createdAt: text("created_at").notNull(),
2220
- updatedAt: text("updated_at").notNull()
2221
- },
2222
- (t) => ({
2223
- projectIdx: index("bug_reports_project").on(t.projectId, t.status),
2224
- createdIdx: index("bug_reports_created").on(t.projectId, t.createdAt)
2225
- })
2226
- );
2227
- var FEATURE_REQUEST_STATUSES = [
2228
- "open",
2229
- "considering",
2230
- "planned",
2231
- "shipped",
2232
- "declined"
2233
- ];
2234
- var FEATURE_REQUEST_IMPORTANCES = ["nice_to_have", "important", "critical"];
2235
- var featureRequests = sqliteTable(
2236
- "feature_requests",
2237
- {
2238
- id: text("id").primaryKey(),
2239
- projectId: text("project_id").notNull().references(() => projects.id, { onDelete: "cascade" }),
2240
- title: text("title").notNull(),
2241
- description: text("description").notNull().default(""),
2242
- useCase: text("use_case").notNull().default(""),
2243
- importance: text("importance", { enum: FEATURE_REQUEST_IMPORTANCES }).notNull().default("nice_to_have"),
2244
- status: text("status", { enum: FEATURE_REQUEST_STATUSES }).notNull().default("open"),
2245
- reporterEmail: text("reporter_email"),
2246
- pageUrl: text("page_url"),
2247
- userAgent: text("user_agent"),
2248
- context: text("context", { mode: "json" }).$type(),
2249
- createdAt: text("created_at").notNull(),
2250
- updatedAt: text("updated_at").notNull()
2251
- },
2252
- (t) => ({
2253
- projectIdx: index("feature_requests_project").on(t.projectId, t.status),
2254
- createdIdx: index("feature_requests_created").on(t.projectId, t.createdAt)
2255
- })
2256
- );
2257
- var REPORT_KINDS = ["bug", "feature_request"];
2258
- var ATTACHMENT_KINDS = ["screenshot", "recording", "file"];
2259
- var reportAttachments = sqliteTable(
2260
- "report_attachments",
2261
- {
2262
- id: text("id").primaryKey(),
2263
- projectId: text("project_id").notNull().references(() => projects.id, { onDelete: "cascade" }),
2264
- reportKind: text("report_kind", { enum: REPORT_KINDS }).notNull(),
2265
- reportId: text("report_id").notNull(),
2266
- kind: text("kind", { enum: ATTACHMENT_KINDS }).notNull(),
2267
- filename: text("filename").notNull(),
2268
- mimeType: text("mime_type").notNull(),
2269
- sizeBytes: integer("size_bytes").notNull(),
2270
- r2Key: text("r2_key").notNull(),
2271
- createdAt: text("created_at").notNull()
2272
- },
2273
- (t) => ({
2274
- reportIdx: index("report_attachments_report").on(t.projectId, t.reportKind, t.reportId)
2275
- })
2276
- );
2277
- var CONNECTOR_PROVIDERS = ["google_sheets"];
2278
- var connectors = sqliteTable(
2279
- "connectors",
2280
- {
2281
- id: text("id").primaryKey(),
2282
- projectId: text("project_id").notNull().references(() => projects.id, { onDelete: "cascade" }),
2283
- provider: text("provider", { enum: CONNECTOR_PROVIDERS }).notNull(),
2284
- name: text("name").notNull(),
2285
- enabled: integer("enabled", { mode: "boolean" }).notNull().default(true),
2286
- events: text("events", { mode: "json" }).$type().notNull(),
2287
- config: text("config", { mode: "json" }).$type().notNull(),
2288
- // AES-GCM encrypted JSON: { refresh_token, access_token, expires_at, scope }
2289
- credentialsCipher: text("credentials_cipher"),
2290
- // Display label (e.g., the OAuth account email)
2291
- accountLabel: text("account_label"),
2292
- createdAt: text("created_at").notNull(),
2293
- updatedAt: text("updated_at").notNull()
2294
- },
2295
- (t) => ({
2296
- projectIdx: index("connectors_project").on(t.projectId, t.provider)
2297
- })
2298
- );
2299
- var i18nUsageDaily = sqliteTable(
2300
- "i18n_usage_daily",
2301
- {
2302
- projectId: text("project_id").notNull(),
2303
- sdkKeyId: text("sdk_key_id").notNull(),
2304
- date: text("date").notNull(),
2305
- requestCount: integer("request_count").notNull().default(0)
2306
- },
2307
- (t) => ({
2308
- pk: primaryKey({ columns: [t.projectId, t.sdkKeyId, t.date] }),
2309
- projectDateIdx: index("i18n_usage_daily_project_date").on(t.projectId, t.date)
2310
- })
2311
- );
2312
- var billingEvents = sqliteTable(
2313
- "billing_events",
2314
- {
2315
- // Stripe event ID — INSERT OR IGNORE makes webhook handling idempotent
2316
- id: text("id").primaryKey(),
2317
- projectId: text("project_id").references(() => projects.id, { onDelete: "set null" }),
2318
- type: text("type").notNull(),
2319
- payload: text("payload", { mode: "json" }).$type().notNull(),
2320
- receivedAt: text("received_at").notNull()
2321
- },
2322
- (t) => ({
2323
- projectIdx: index("billing_events_project").on(t.projectId)
2324
- })
10
+
11
+ // src/schemas/folder.ts
12
+ import { z } from "zod";
13
+ var folderSchema = z.string().max(256).regex(/^[a-zA-Z0-9_-]+$/, "Folder must be alphanumeric, `_` or `-` (no `/`).").nullable().optional().describe(
14
+ "Optional folder name used to group items in the dashboard. Part of the SDK lookup key: an item in folder `checkout` named `new-cart` is referenced as `checkout/new-cart` from the SDK."
2325
15
  );
2326
16
 
2327
- // ../core/src/schemas/configs.ts
17
+ // src/schemas/configs.ts
2328
18
  var SEGMENT = /^[a-z0-9](?:[a-z0-9_-]*[a-z0-9])?$/;
2329
19
  var RESERVED_FOLDER = "_default";
2330
- var configNameSchema = z.string().max(128).refine(
20
+ var configNameSchema = z2.string().max(128).refine(
2331
21
  (s) => {
2332
22
  const parts = s.split(".");
2333
23
  if (parts.length !== 2) return false;
@@ -2339,90 +29,92 @@ var configNameSchema = z.string().max(128).refine(
2339
29
  ).describe(
2340
30
  "Stable config key in `folder.name` form (two lowercase segments separated by a dot, e.g. `pricing.tiers`). Used by SDKs as `Shipeasy.getConfig('<name>')`. Immutable after create."
2341
31
  );
2342
- var configKindSchema = z.enum(CONFIG_KINDS);
2343
- var configEnvSchema = z.enum(CONFIG_ENVS).describe("Target environment. One of the project's configured envs (`dev`, `stage`, `prod`).");
2344
- var jsonSchemaSchema = z.record(z.string(), z.unknown()).refine((s) => s.type === "object", { message: "Top-level schema type must be 'object'" }).describe(
32
+ var configKindSchema = z2.enum(CONFIG_KINDS);
33
+ var configEnvSchema = z2.enum(CONFIG_ENVS).describe("Target environment. One of the project's configured envs (`dev`, `stage`, `prod`).");
34
+ var jsonSchemaSchema = z2.record(z2.string(), z2.unknown()).refine((s) => s.type === "object", { message: "Top-level schema type must be 'object'" }).describe(
2345
35
  "JSON Schema (draft 2020-12) describing the shape of the config value. Top-level `type` must be `'object'`; every published value is validated against this schema."
2346
36
  );
2347
- var initialValuesSchema = z.union([z.unknown(), z.record(configEnvSchema, z.unknown())]).describe(
37
+ var initialValuesSchema = z2.union([z2.unknown(), z2.record(configEnvSchema, z2.unknown())]).describe(
2348
38
  "Initial config value. Either a single JSON object applied to every env, or a `{ env: value }` map seeding per-env values. Must match `schema`. Defaults to `{}` on every env when omitted."
2349
39
  );
2350
- var configCreateSchema = z.object({
40
+ var configCreateSchema = z2.object({
2351
41
  name: configNameSchema,
2352
- description: z.string().max(512).optional().describe("Optional free-form description shown in the dashboard. Max 512 chars."),
42
+ description: z2.string().max(512).optional().describe("Optional free-form description shown in the dashboard. Max 512 chars."),
43
+ folder: folderSchema,
2353
44
  schema: jsonSchemaSchema,
2354
45
  value: initialValuesSchema.optional()
2355
46
  }).describe("Body for `POST /api/admin/configs`. `name` + `schema` required.");
2356
- var configUpdateSchema = z.object({
47
+ var configUpdateSchema = z2.object({
2357
48
  schema: jsonSchemaSchema.optional().describe(
2358
49
  "Replacement schema. When supplied, the new schema is validated against every published value before it lands."
2359
50
  ),
2360
- value: z.unknown().optional().describe(
51
+ value: z2.unknown().optional().describe(
2361
52
  "Flat value applied to **every** env. Publishes a new version per env. To target one env, use `PUT /{id}/drafts` then `POST /{id}/publish`."
2362
- )
53
+ ),
54
+ folder: folderSchema
2363
55
  }).describe(
2364
56
  "Body for `PATCH /api/admin/configs/{id}`. Partial \u2014 only supplied fields change. `value` republishes on every env."
2365
57
  );
2366
- var configSchemaUpdateSchema = z.object({ schema: jsonSchemaSchema }).describe("Schema-only update. Does not bump value versions or rebuild KV.");
2367
- var configDraftUpsertSchema = z.object({
58
+ var configSchemaUpdateSchema = z2.object({ schema: jsonSchemaSchema }).describe("Schema-only update. Does not bump value versions or rebuild KV.");
59
+ var configDraftUpsertSchema = z2.object({
2368
60
  env: configEnvSchema,
2369
- value: z.unknown().describe("Draft value to stage on `env`. Validated against the config's current schema.")
61
+ value: z2.unknown().describe("Draft value to stage on `env`. Validated against the config's current schema.")
2370
62
  }).describe(
2371
63
  "Body for `PUT /api/admin/configs/{id}/drafts`. Stages a value for a single env without publishing."
2372
64
  );
2373
- var configPublishSchema = z.object({ env: configEnvSchema }).describe(
65
+ var configPublishSchema = z2.object({ env: configEnvSchema }).describe(
2374
66
  "Body for `POST /api/admin/configs/{id}/publish` and `DELETE /api/admin/configs/{id}/drafts`. Names the target env."
2375
67
  );
2376
- var configEnvPublishedSchema = z.object({
2377
- version: z.number().int().describe("Monotonically increasing version per env."),
2378
- publishedAt: z.string().describe("ISO-8601 publish timestamp."),
2379
- publishedBy: z.string().describe("Email/id of the actor who published this version.")
68
+ var configEnvPublishedSchema = z2.object({
69
+ version: z2.number().int().describe("Monotonically increasing version per env."),
70
+ publishedAt: z2.string().describe("ISO-8601 publish timestamp."),
71
+ publishedBy: z2.string().describe("Email/id of the actor who published this version.")
2380
72
  });
2381
- var configDraftSummarySchema = z.object({
2382
- updatedAt: z.string().describe("ISO-8601 last-edit timestamp on the draft."),
2383
- authorEmail: z.string().describe("Email/id of the actor who last edited the draft."),
2384
- baseVersion: z.number().int().describe("Published version the draft was forked from.")
73
+ var configDraftSummarySchema = z2.object({
74
+ updatedAt: z2.string().describe("ISO-8601 last-edit timestamp on the draft."),
75
+ authorEmail: z2.string().describe("Email/id of the actor who last edited the draft."),
76
+ baseVersion: z2.number().int().describe("Published version the draft was forked from.")
2385
77
  });
2386
- var configResponseSchema = z.object({
2387
- id: z.string().describe("Stable opaque config id (`cfg_\u2026`)."),
78
+ var configResponseSchema = z2.object({
79
+ id: z2.string().describe("Stable opaque config id (`cfg_\u2026`)."),
2388
80
  name: configNameSchema,
2389
- description: z.string().nullable(),
81
+ description: z2.string().nullable(),
2390
82
  schema: jsonSchemaSchema,
2391
- updatedAt: z.string().describe("ISO-8601 timestamp of last mutation."),
2392
- envs: z.record(configEnvSchema, configEnvPublishedSchema).describe("Per-env latest published version metadata."),
2393
- drafts: z.record(configEnvSchema, configDraftSummarySchema).describe("Per-env active drafts (if any)."),
2394
- values: z.record(configEnvSchema, z.unknown()).optional().describe("Per-env latest published values (only returned by `GET /{id}`, not list)."),
2395
- draftValues: z.record(configEnvSchema, z.unknown()).optional().describe("Per-env draft values (only returned by `GET /{id}`).")
83
+ updatedAt: z2.string().describe("ISO-8601 timestamp of last mutation."),
84
+ envs: z2.record(configEnvSchema, configEnvPublishedSchema).describe("Per-env latest published version metadata."),
85
+ drafts: z2.record(configEnvSchema, configDraftSummarySchema).describe("Per-env active drafts (if any)."),
86
+ values: z2.record(configEnvSchema, z2.unknown()).optional().describe("Per-env latest published values (only returned by `GET /{id}`, not list)."),
87
+ draftValues: z2.record(configEnvSchema, z2.unknown()).optional().describe("Per-env draft values (only returned by `GET /{id}`).")
2396
88
  });
2397
- var configCreateResponseSchema = z.object({
2398
- id: z.string().describe("Newly assigned config id."),
89
+ var configCreateResponseSchema = z2.object({
90
+ id: z2.string().describe("Newly assigned config id."),
2399
91
  name: configNameSchema
2400
92
  });
2401
- var configUpdateResponseSchema = z.object({
2402
- id: z.string().describe("Config id that was updated.")
93
+ var configUpdateResponseSchema = z2.object({
94
+ id: z2.string().describe("Config id that was updated.")
2403
95
  });
2404
- var configDeleteResponseSchema = z.object({ ok: z.literal(true) });
2405
- var configDraftSaveResponseSchema = z.object({
2406
- id: z.string(),
96
+ var configDeleteResponseSchema = z2.object({ ok: z2.literal(true) });
97
+ var configDraftSaveResponseSchema = z2.object({
98
+ id: z2.string(),
2407
99
  env: configEnvSchema,
2408
- baseVersion: z.number().int().describe("Published version the draft is based on."),
2409
- updatedAt: z.string()
100
+ baseVersion: z2.number().int().describe("Published version the draft is based on."),
101
+ updatedAt: z2.string()
2410
102
  });
2411
- var configDraftDiscardResponseSchema = z.object({ ok: z.literal(true) });
2412
- var configPublishResponseSchema = z.object({
2413
- id: z.string(),
103
+ var configDraftDiscardResponseSchema = z2.object({ ok: z2.literal(true) });
104
+ var configPublishResponseSchema = z2.object({
105
+ id: z2.string(),
2414
106
  env: configEnvSchema,
2415
- version: z.number().int().describe("Newly published version on `env`.")
107
+ version: z2.number().int().describe("Newly published version on `env`.")
2416
108
  });
2417
- var configActivityEntrySchema = z.object({
2418
- id: z.string(),
2419
- action: z.string().describe("Audit action (e.g. `config.create`, `config.publish`)."),
2420
- actorEmail: z.string(),
2421
- actorType: z.enum(["user", "cli", "system"]),
2422
- payload: z.unknown().nullable(),
2423
- createdAt: z.string().describe("ISO-8601 timestamp.")
109
+ var configActivityEntrySchema = z2.object({
110
+ id: z2.string(),
111
+ action: z2.string().describe("Audit action (e.g. `config.create`, `config.publish`)."),
112
+ actorEmail: z2.string(),
113
+ actorType: z2.enum(["user", "cli", "system"]),
114
+ payload: z2.unknown().nullable(),
115
+ createdAt: z2.string().describe("ISO-8601 timestamp.")
2424
116
  });
2425
- var configActivityResponseSchema = z.array(configActivityEntrySchema).describe("Recent audit rows for one config, newest first.");
117
+ var configActivityResponseSchema = z2.array(configActivityEntrySchema).describe("Recent audit rows for one config, newest first.");
2426
118
 
2427
119
  // src/transport.ts
2428
120
  var ApiError = class extends Error {
@@ -2435,9 +127,9 @@ var ApiError = class extends Error {
2435
127
  };
2436
128
 
2437
129
  // src/resources/configs.ts
2438
- var configListResponseSchema = z2.object({
2439
- data: z2.array(configResponseSchema),
2440
- next_cursor: z2.string().nullable()
130
+ var configListResponseSchema = z3.object({
131
+ data: z3.array(configResponseSchema),
132
+ next_cursor: z3.string().nullable()
2441
133
  });
2442
134
  var BASE = "/api/admin/configs";
2443
135
  function configsClient(t) {
@@ -2790,7 +482,7 @@ var configsResource = {
2790
482
  pathParams: { id: "Stable opaque config id." },
2791
483
  queryParams: {
2792
484
  limit: {
2793
- schema: z2.coerce.number().int().min(1).max(100).default(20),
485
+ schema: z3.coerce.number().int().min(1).max(100).default(20),
2794
486
  description: "Max rows to return (1\u2013100). Defaults to 20."
2795
487
  }
2796
488
  },