@bobbykim/manguito-cms-cli 0.2.2 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1,53 +1,42 @@
1
1
  #!/usr/bin/env node
2
2
  import { createRequire as __cjsRequire } from 'module';
3
3
  const require = __cjsRequire(import.meta.url);
4
- var __create = Object.create;
5
- var __defProp = Object.defineProperty;
6
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
7
- var __getOwnPropNames = Object.getOwnPropertyNames;
8
- var __getProtoOf = Object.getPrototypeOf;
9
- var __hasOwnProp = Object.prototype.hasOwnProperty;
10
- var __require = /* @__PURE__ */ ((x2) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x2, {
11
- get: (a2, b2) => (typeof require !== "undefined" ? require : a2)[b2]
12
- }) : x2)(function(x2) {
13
- if (typeof require !== "undefined") return require.apply(this, arguments);
14
- throw Error('Dynamic require of "' + x2 + '" is not supported');
15
- });
16
- var __esm = (fn, res) => function __init() {
17
- return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
18
- };
19
- var __commonJS = (cb, mod) => function __require2() {
20
- return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
21
- };
22
- var __export = (target, all) => {
23
- for (var name in all)
24
- __defProp(target, name, { get: all[name], enumerable: true });
25
- };
26
- var __copyProps = (to, from, except2, desc2) => {
27
- if (from && typeof from === "object" || typeof from === "function") {
28
- for (let key of __getOwnPropNames(from))
29
- if (!__hasOwnProp.call(to, key) && key !== except2)
30
- __defProp(to, key, { get: () => from[key], enumerable: !(desc2 = __getOwnPropDesc(from, key)) || desc2.enumerable });
31
- }
32
- return to;
33
- };
34
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
35
- // If the importer is in node compatibility mode or this is not an ESM
36
- // file that has been converted to a CommonJS file using a Babel-
37
- // compatible transform (i.e. "__esModule" has not been set), then set
38
- // "default" to the CommonJS "module.exports" for node compatibility.
39
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
40
- mod
41
- ));
42
-
43
- // ../../node_modules/.pnpm/tsup@8.5.1_jiti@2.7.0_postcss@8.5.16_tsx@4.23.0_typescript@6.0.3_yaml@2.9.0/node_modules/tsup/assets/esm_shims.js
44
- import path from "path";
45
- import { fileURLToPath } from "url";
46
- var init_esm_shims = __esm({
47
- "../../node_modules/.pnpm/tsup@8.5.1_jiti@2.7.0_postcss@8.5.16_tsx@4.23.0_typescript@6.0.3_yaml@2.9.0/node_modules/tsup/assets/esm_shims.js"() {
48
- "use strict";
49
- }
50
- });
4
+ import {
5
+ Column,
6
+ Columns,
7
+ Param,
8
+ PgColumn,
9
+ PgColumnBuilder,
10
+ Placeholder,
11
+ SQL,
12
+ Schema,
13
+ StringChunk,
14
+ Subquery,
15
+ Table,
16
+ View,
17
+ ViewBaseConfig,
18
+ WithSubquery,
19
+ __commonJS,
20
+ __export,
21
+ __require,
22
+ __toESM,
23
+ buildRelationsMap,
24
+ deleteParagraphField,
25
+ entityKind,
26
+ fillPlaceholders,
27
+ getTableName,
28
+ getTableUniqueName,
29
+ init_esm_shims,
30
+ is,
31
+ isDriverValueEncoder,
32
+ isSQLWrapper,
33
+ persistJunctionField,
34
+ persistParagraphField,
35
+ resolveRelationBareIds,
36
+ resolveRelationField,
37
+ sql,
38
+ tracer
39
+ } from "./chunk-UVGV7NVV.js";
51
40
 
52
41
  // ../../node_modules/.pnpm/yaml@2.9.0/node_modules/yaml/dist/nodes/identity.js
53
42
  var require_identity = __commonJS({
@@ -128,17 +117,17 @@ var require_visit = __commonJS({
128
117
  visit.BREAK = BREAK;
129
118
  visit.SKIP = SKIP;
130
119
  visit.REMOVE = REMOVE;
131
- function visit_(key, node, visitor, path4) {
132
- const ctrl = callVisitor(key, node, visitor, path4);
120
+ function visit_(key, node, visitor, path3) {
121
+ const ctrl = callVisitor(key, node, visitor, path3);
133
122
  if (identity.isNode(ctrl) || identity.isPair(ctrl)) {
134
- replaceNode(key, path4, ctrl);
135
- return visit_(key, ctrl, visitor, path4);
123
+ replaceNode(key, path3, ctrl);
124
+ return visit_(key, ctrl, visitor, path3);
136
125
  }
137
126
  if (typeof ctrl !== "symbol") {
138
127
  if (identity.isCollection(node)) {
139
- path4 = Object.freeze(path4.concat(node));
128
+ path3 = Object.freeze(path3.concat(node));
140
129
  for (let i = 0; i < node.items.length; ++i) {
141
- const ci = visit_(i, node.items[i], visitor, path4);
130
+ const ci = visit_(i, node.items[i], visitor, path3);
142
131
  if (typeof ci === "number")
143
132
  i = ci - 1;
144
133
  else if (ci === BREAK)
@@ -149,13 +138,13 @@ var require_visit = __commonJS({
149
138
  }
150
139
  }
151
140
  } else if (identity.isPair(node)) {
152
- path4 = Object.freeze(path4.concat(node));
153
- const ck = visit_("key", node.key, visitor, path4);
141
+ path3 = Object.freeze(path3.concat(node));
142
+ const ck = visit_("key", node.key, visitor, path3);
154
143
  if (ck === BREAK)
155
144
  return BREAK;
156
145
  else if (ck === REMOVE)
157
146
  node.key = null;
158
- const cv = visit_("value", node.value, visitor, path4);
147
+ const cv = visit_("value", node.value, visitor, path3);
159
148
  if (cv === BREAK)
160
149
  return BREAK;
161
150
  else if (cv === REMOVE)
@@ -176,17 +165,17 @@ var require_visit = __commonJS({
176
165
  visitAsync.BREAK = BREAK;
177
166
  visitAsync.SKIP = SKIP;
178
167
  visitAsync.REMOVE = REMOVE;
179
- async function visitAsync_(key, node, visitor, path4) {
180
- const ctrl = await callVisitor(key, node, visitor, path4);
168
+ async function visitAsync_(key, node, visitor, path3) {
169
+ const ctrl = await callVisitor(key, node, visitor, path3);
181
170
  if (identity.isNode(ctrl) || identity.isPair(ctrl)) {
182
- replaceNode(key, path4, ctrl);
183
- return visitAsync_(key, ctrl, visitor, path4);
171
+ replaceNode(key, path3, ctrl);
172
+ return visitAsync_(key, ctrl, visitor, path3);
184
173
  }
185
174
  if (typeof ctrl !== "symbol") {
186
175
  if (identity.isCollection(node)) {
187
- path4 = Object.freeze(path4.concat(node));
176
+ path3 = Object.freeze(path3.concat(node));
188
177
  for (let i = 0; i < node.items.length; ++i) {
189
- const ci = await visitAsync_(i, node.items[i], visitor, path4);
178
+ const ci = await visitAsync_(i, node.items[i], visitor, path3);
190
179
  if (typeof ci === "number")
191
180
  i = ci - 1;
192
181
  else if (ci === BREAK)
@@ -197,13 +186,13 @@ var require_visit = __commonJS({
197
186
  }
198
187
  }
199
188
  } else if (identity.isPair(node)) {
200
- path4 = Object.freeze(path4.concat(node));
201
- const ck = await visitAsync_("key", node.key, visitor, path4);
189
+ path3 = Object.freeze(path3.concat(node));
190
+ const ck = await visitAsync_("key", node.key, visitor, path3);
202
191
  if (ck === BREAK)
203
192
  return BREAK;
204
193
  else if (ck === REMOVE)
205
194
  node.key = null;
206
- const cv = await visitAsync_("value", node.value, visitor, path4);
195
+ const cv = await visitAsync_("value", node.value, visitor, path3);
207
196
  if (cv === BREAK)
208
197
  return BREAK;
209
198
  else if (cv === REMOVE)
@@ -230,23 +219,23 @@ var require_visit = __commonJS({
230
219
  }
231
220
  return visitor;
232
221
  }
233
- function callVisitor(key, node, visitor, path4) {
222
+ function callVisitor(key, node, visitor, path3) {
234
223
  if (typeof visitor === "function")
235
- return visitor(key, node, path4);
224
+ return visitor(key, node, path3);
236
225
  if (identity.isMap(node))
237
- return visitor.Map?.(key, node, path4);
226
+ return visitor.Map?.(key, node, path3);
238
227
  if (identity.isSeq(node))
239
- return visitor.Seq?.(key, node, path4);
228
+ return visitor.Seq?.(key, node, path3);
240
229
  if (identity.isPair(node))
241
- return visitor.Pair?.(key, node, path4);
230
+ return visitor.Pair?.(key, node, path3);
242
231
  if (identity.isScalar(node))
243
- return visitor.Scalar?.(key, node, path4);
232
+ return visitor.Scalar?.(key, node, path3);
244
233
  if (identity.isAlias(node))
245
- return visitor.Alias?.(key, node, path4);
234
+ return visitor.Alias?.(key, node, path3);
246
235
  return void 0;
247
236
  }
248
- function replaceNode(key, path4, node) {
249
- const parent = path4[path4.length - 1];
237
+ function replaceNode(key, path3, node) {
238
+ const parent = path3[path3.length - 1];
250
239
  if (identity.isCollection(parent)) {
251
240
  parent.items[key] = node;
252
241
  } else if (identity.isPair(parent)) {
@@ -344,13 +333,13 @@ var require_directives = __commonJS({
344
333
  onError(0, "%YAML directive should contain exactly one part");
345
334
  return false;
346
335
  }
347
- const [version4] = parts;
348
- if (version4 === "1.1" || version4 === "1.2") {
349
- this.yaml.version = version4;
336
+ const [version3] = parts;
337
+ if (version3 === "1.1" || version3 === "1.2") {
338
+ this.yaml.version = version3;
350
339
  return true;
351
340
  } else {
352
- const isValid = /^\d+\.\d+$/.test(version4);
353
- onError(6, `Unsupported YAML version ${version4}`, isValid);
341
+ const isValid = /^\d+\.\d+$/.test(version3);
342
+ onError(6, `Unsupported YAML version ${version3}`, isValid);
354
343
  return false;
355
344
  }
356
345
  }
@@ -865,10 +854,10 @@ var require_Collection = __commonJS({
865
854
  var createNode = require_createNode();
866
855
  var identity = require_identity();
867
856
  var Node3 = require_Node();
868
- function collectionFromPath(schema, path4, value) {
857
+ function collectionFromPath(schema, path3, value) {
869
858
  let v2 = value;
870
- for (let i = path4.length - 1; i >= 0; --i) {
871
- const k = path4[i];
859
+ for (let i = path3.length - 1; i >= 0; --i) {
860
+ const k = path3[i];
872
861
  if (typeof k === "number" && Number.isInteger(k) && k >= 0) {
873
862
  const a2 = [];
874
863
  a2[k] = v2;
@@ -887,7 +876,7 @@ var require_Collection = __commonJS({
887
876
  sourceObjects: /* @__PURE__ */ new Map()
888
877
  });
889
878
  }
890
- var isEmptyPath = (path4) => path4 == null || typeof path4 === "object" && !!path4[Symbol.iterator]().next().done;
879
+ var isEmptyPath = (path3) => path3 == null || typeof path3 === "object" && !!path3[Symbol.iterator]().next().done;
891
880
  var Collection = class extends Node3.NodeBase {
892
881
  constructor(type, schema) {
893
882
  super(type);
@@ -917,11 +906,11 @@ var require_Collection = __commonJS({
917
906
  * be a Pair instance or a `{ key, value }` object, which may not have a key
918
907
  * that already exists in the map.
919
908
  */
920
- addIn(path4, value) {
921
- if (isEmptyPath(path4))
909
+ addIn(path3, value) {
910
+ if (isEmptyPath(path3))
922
911
  this.add(value);
923
912
  else {
924
- const [key, ...rest] = path4;
913
+ const [key, ...rest] = path3;
925
914
  const node = this.get(key, true);
926
915
  if (identity.isCollection(node))
927
916
  node.addIn(rest, value);
@@ -935,8 +924,8 @@ var require_Collection = __commonJS({
935
924
  * Removes a value from the collection.
936
925
  * @returns `true` if the item was found and removed.
937
926
  */
938
- deleteIn(path4) {
939
- const [key, ...rest] = path4;
927
+ deleteIn(path3) {
928
+ const [key, ...rest] = path3;
940
929
  if (rest.length === 0)
941
930
  return this.delete(key);
942
931
  const node = this.get(key, true);
@@ -950,8 +939,8 @@ var require_Collection = __commonJS({
950
939
  * scalar values from their surrounding node; to disable set `keepScalar` to
951
940
  * `true` (collections are always returned intact).
952
941
  */
953
- getIn(path4, keepScalar) {
954
- const [key, ...rest] = path4;
942
+ getIn(path3, keepScalar) {
943
+ const [key, ...rest] = path3;
955
944
  const node = this.get(key, true);
956
945
  if (rest.length === 0)
957
946
  return !keepScalar && identity.isScalar(node) ? node.value : node;
@@ -969,8 +958,8 @@ var require_Collection = __commonJS({
969
958
  /**
970
959
  * Checks if the collection includes a value with the key `key`.
971
960
  */
972
- hasIn(path4) {
973
- const [key, ...rest] = path4;
961
+ hasIn(path3) {
962
+ const [key, ...rest] = path3;
974
963
  if (rest.length === 0)
975
964
  return this.has(key);
976
965
  const node = this.get(key, true);
@@ -980,8 +969,8 @@ var require_Collection = __commonJS({
980
969
  * Sets a value in this collection. For `!!set`, `value` needs to be a
981
970
  * boolean to add/remove the item from the set.
982
971
  */
983
- setIn(path4, value) {
984
- const [key, ...rest] = path4;
972
+ setIn(path3, value) {
973
+ const [key, ...rest] = path3;
985
974
  if (rest.length === 0) {
986
975
  this.set(key, value);
987
976
  } else {
@@ -3493,14 +3482,14 @@ var require_Document = __commonJS({
3493
3482
  version: "1.2"
3494
3483
  }, options);
3495
3484
  this.options = opt;
3496
- let { version: version4 } = opt;
3485
+ let { version: version3 } = opt;
3497
3486
  if (options?._directives) {
3498
3487
  this.directives = options._directives.atDocument();
3499
3488
  if (this.directives.yaml.explicit)
3500
- version4 = this.directives.yaml.version;
3489
+ version3 = this.directives.yaml.version;
3501
3490
  } else
3502
- this.directives = new directives.Directives({ version: version4 });
3503
- this.setSchema(version4, options);
3491
+ this.directives = new directives.Directives({ version: version3 });
3492
+ this.setSchema(version3, options);
3504
3493
  this.contents = value === void 0 ? null : this.createNode(value, _replacer, options);
3505
3494
  }
3506
3495
  /**
@@ -3531,9 +3520,9 @@ var require_Document = __commonJS({
3531
3520
  this.contents.add(value);
3532
3521
  }
3533
3522
  /** Adds a value to the document. */
3534
- addIn(path4, value) {
3523
+ addIn(path3, value) {
3535
3524
  if (assertCollection(this.contents))
3536
- this.contents.addIn(path4, value);
3525
+ this.contents.addIn(path3, value);
3537
3526
  }
3538
3527
  /**
3539
3528
  * Create a new `Alias` node, ensuring that the target `node` has the required anchor.
@@ -3608,14 +3597,14 @@ var require_Document = __commonJS({
3608
3597
  * Removes a value from the document.
3609
3598
  * @returns `true` if the item was found and removed.
3610
3599
  */
3611
- deleteIn(path4) {
3612
- if (Collection.isEmptyPath(path4)) {
3600
+ deleteIn(path3) {
3601
+ if (Collection.isEmptyPath(path3)) {
3613
3602
  if (this.contents == null)
3614
3603
  return false;
3615
3604
  this.contents = null;
3616
3605
  return true;
3617
3606
  }
3618
- return assertCollection(this.contents) ? this.contents.deleteIn(path4) : false;
3607
+ return assertCollection(this.contents) ? this.contents.deleteIn(path3) : false;
3619
3608
  }
3620
3609
  /**
3621
3610
  * Returns item at `key`, or `undefined` if not found. By default unwraps
@@ -3630,10 +3619,10 @@ var require_Document = __commonJS({
3630
3619
  * scalar values from their surrounding node; to disable set `keepScalar` to
3631
3620
  * `true` (collections are always returned intact).
3632
3621
  */
3633
- getIn(path4, keepScalar) {
3634
- if (Collection.isEmptyPath(path4))
3622
+ getIn(path3, keepScalar) {
3623
+ if (Collection.isEmptyPath(path3))
3635
3624
  return !keepScalar && identity.isScalar(this.contents) ? this.contents.value : this.contents;
3636
- return identity.isCollection(this.contents) ? this.contents.getIn(path4, keepScalar) : void 0;
3625
+ return identity.isCollection(this.contents) ? this.contents.getIn(path3, keepScalar) : void 0;
3637
3626
  }
3638
3627
  /**
3639
3628
  * Checks if the document includes a value with the key `key`.
@@ -3644,10 +3633,10 @@ var require_Document = __commonJS({
3644
3633
  /**
3645
3634
  * Checks if the document includes a value at `path`.
3646
3635
  */
3647
- hasIn(path4) {
3648
- if (Collection.isEmptyPath(path4))
3636
+ hasIn(path3) {
3637
+ if (Collection.isEmptyPath(path3))
3649
3638
  return this.contents !== void 0;
3650
- return identity.isCollection(this.contents) ? this.contents.hasIn(path4) : false;
3639
+ return identity.isCollection(this.contents) ? this.contents.hasIn(path3) : false;
3651
3640
  }
3652
3641
  /**
3653
3642
  * Sets a value in this document. For `!!set`, `value` needs to be a
@@ -3664,13 +3653,13 @@ var require_Document = __commonJS({
3664
3653
  * Sets a value in this document. For `!!set`, `value` needs to be a
3665
3654
  * boolean to add/remove the item from the set.
3666
3655
  */
3667
- setIn(path4, value) {
3668
- if (Collection.isEmptyPath(path4)) {
3656
+ setIn(path3, value) {
3657
+ if (Collection.isEmptyPath(path3)) {
3669
3658
  this.contents = value;
3670
3659
  } else if (this.contents == null) {
3671
- this.contents = Collection.collectionFromPath(this.schema, Array.from(path4), value);
3660
+ this.contents = Collection.collectionFromPath(this.schema, Array.from(path3), value);
3672
3661
  } else if (assertCollection(this.contents)) {
3673
- this.contents.setIn(path4, value);
3662
+ this.contents.setIn(path3, value);
3674
3663
  }
3675
3664
  }
3676
3665
  /**
@@ -3680,11 +3669,11 @@ var require_Document = __commonJS({
3680
3669
  *
3681
3670
  * Overrides all previously set schema options.
3682
3671
  */
3683
- setSchema(version4, options = {}) {
3684
- if (typeof version4 === "number")
3685
- version4 = String(version4);
3672
+ setSchema(version3, options = {}) {
3673
+ if (typeof version3 === "number")
3674
+ version3 = String(version3);
3686
3675
  let opt;
3687
- switch (version4) {
3676
+ switch (version3) {
3688
3677
  case "1.1":
3689
3678
  if (this.directives)
3690
3679
  this.directives.yaml.version = "1.1";
@@ -3695,9 +3684,9 @@ var require_Document = __commonJS({
3695
3684
  case "1.2":
3696
3685
  case "next":
3697
3686
  if (this.directives)
3698
- this.directives.yaml.version = version4;
3687
+ this.directives.yaml.version = version3;
3699
3688
  else
3700
- this.directives = new directives.Directives({ version: version4 });
3689
+ this.directives = new directives.Directives({ version: version3 });
3701
3690
  opt = { resolveKnownTags: true, schema: "core" };
3702
3691
  break;
3703
3692
  case null:
@@ -3706,7 +3695,7 @@ var require_Document = __commonJS({
3706
3695
  opt = null;
3707
3696
  break;
3708
3697
  default: {
3709
- const sv = JSON.stringify(version4);
3698
+ const sv = JSON.stringify(version3);
3710
3699
  throw new Error(`Expected '1.1', '1.2' or null as first argument, but found: ${sv}`);
3711
3700
  }
3712
3701
  }
@@ -5650,9 +5639,9 @@ var require_cst_visit = __commonJS({
5650
5639
  visit.BREAK = BREAK;
5651
5640
  visit.SKIP = SKIP;
5652
5641
  visit.REMOVE = REMOVE;
5653
- visit.itemAtPath = (cst, path4) => {
5642
+ visit.itemAtPath = (cst, path3) => {
5654
5643
  let item = cst;
5655
- for (const [field, index] of path4) {
5644
+ for (const [field, index] of path3) {
5656
5645
  const tok = item?.[field];
5657
5646
  if (tok && "items" in tok) {
5658
5647
  item = tok.items[index];
@@ -5661,23 +5650,23 @@ var require_cst_visit = __commonJS({
5661
5650
  }
5662
5651
  return item;
5663
5652
  };
5664
- visit.parentCollection = (cst, path4) => {
5665
- const parent = visit.itemAtPath(cst, path4.slice(0, -1));
5666
- const field = path4[path4.length - 1][0];
5653
+ visit.parentCollection = (cst, path3) => {
5654
+ const parent = visit.itemAtPath(cst, path3.slice(0, -1));
5655
+ const field = path3[path3.length - 1][0];
5667
5656
  const coll = parent?.[field];
5668
5657
  if (coll && "items" in coll)
5669
5658
  return coll;
5670
5659
  throw new Error("Parent collection not found");
5671
5660
  };
5672
- function _visit(path4, item, visitor) {
5673
- let ctrl = visitor(item, path4);
5661
+ function _visit(path3, item, visitor) {
5662
+ let ctrl = visitor(item, path3);
5674
5663
  if (typeof ctrl === "symbol")
5675
5664
  return ctrl;
5676
5665
  for (const field of ["key", "value"]) {
5677
5666
  const token = item[field];
5678
5667
  if (token && "items" in token) {
5679
5668
  for (let i = 0; i < token.items.length; ++i) {
5680
- const ci = _visit(Object.freeze(path4.concat([[field, i]])), token.items[i], visitor);
5669
+ const ci = _visit(Object.freeze(path3.concat([[field, i]])), token.items[i], visitor);
5681
5670
  if (typeof ci === "number")
5682
5671
  i = ci - 1;
5683
5672
  else if (ci === BREAK)
@@ -5688,10 +5677,10 @@ var require_cst_visit = __commonJS({
5688
5677
  }
5689
5678
  }
5690
5679
  if (typeof ctrl === "function" && field === "key")
5691
- ctrl = ctrl(item, path4);
5680
+ ctrl = ctrl(item, path3);
5692
5681
  }
5693
5682
  }
5694
- return typeof ctrl === "function" ? ctrl(item, path4) : ctrl;
5683
+ return typeof ctrl === "function" ? ctrl(item, path3) : ctrl;
5695
5684
  }
5696
5685
  exports.visit = visit;
5697
5686
  }
@@ -7530,13 +7519,13 @@ var require_bcrypt = __commonJS({
7530
7519
  throw Error("Illegal callback: " + typeof callback);
7531
7520
  _async(callback);
7532
7521
  } else
7533
- return new Promise(function(resolve9, reject) {
7522
+ return new Promise(function(resolve10, reject) {
7534
7523
  _async(function(err, res) {
7535
7524
  if (err) {
7536
7525
  reject(err);
7537
7526
  return;
7538
7527
  }
7539
- resolve9(res);
7528
+ resolve10(res);
7540
7529
  });
7541
7530
  });
7542
7531
  };
@@ -7565,13 +7554,13 @@ var require_bcrypt = __commonJS({
7565
7554
  throw Error("Illegal callback: " + typeof callback);
7566
7555
  _async(callback);
7567
7556
  } else
7568
- return new Promise(function(resolve9, reject) {
7557
+ return new Promise(function(resolve10, reject) {
7569
7558
  _async(function(err, res) {
7570
7559
  if (err) {
7571
7560
  reject(err);
7572
7561
  return;
7573
7562
  }
7574
- resolve9(res);
7563
+ resolve10(res);
7575
7564
  });
7576
7565
  });
7577
7566
  };
@@ -7616,13 +7605,13 @@ var require_bcrypt = __commonJS({
7616
7605
  throw Error("Illegal callback: " + typeof callback);
7617
7606
  _async(callback);
7618
7607
  } else
7619
- return new Promise(function(resolve9, reject) {
7608
+ return new Promise(function(resolve10, reject) {
7620
7609
  _async(function(err, res) {
7621
7610
  if (err) {
7622
7611
  reject(err);
7623
7612
  return;
7624
7613
  }
7625
- resolve9(res);
7614
+ resolve10(res);
7626
7615
  });
7627
7616
  });
7628
7617
  };
@@ -12343,7 +12332,7 @@ var require_dist2 = __commonJS({
12343
12332
  function parse4(stream, callback) {
12344
12333
  const parser = new parser_1.Parser();
12345
12334
  stream.on("data", (buffer) => parser.parse(buffer, callback));
12346
- return new Promise((resolve9) => stream.on("end", () => resolve9()));
12335
+ return new Promise((resolve10) => stream.on("end", () => resolve10()));
12347
12336
  }
12348
12337
  }
12349
12338
  });
@@ -12731,7 +12720,7 @@ var require_helper = __commonJS({
12731
12720
  "../../node_modules/.pnpm/pgpass@1.0.5/node_modules/pgpass/lib/helper.js"(exports, module) {
12732
12721
  "use strict";
12733
12722
  init_esm_shims();
12734
- var path4 = __require("path");
12723
+ var path3 = __require("path");
12735
12724
  var Stream = __require("stream").Stream;
12736
12725
  var split = require_split2();
12737
12726
  var util = __require("util");
@@ -12770,7 +12759,7 @@ var require_helper = __commonJS({
12770
12759
  };
12771
12760
  module.exports.getFileName = function(rawEnv) {
12772
12761
  var env = rawEnv || process.env;
12773
- var file2 = env.PGPASSFILE || (isWin ? path4.join(env.APPDATA || "./", "postgresql", "pgpass.conf") : path4.join(env.HOME || "./", ".pgpass"));
12762
+ var file2 = env.PGPASSFILE || (isWin ? path3.join(env.APPDATA || "./", "postgresql", "pgpass.conf") : path3.join(env.HOME || "./", ".pgpass"));
12774
12763
  return file2;
12775
12764
  };
12776
12765
  module.exports.usePgPass = function(stats, fname) {
@@ -12903,7 +12892,7 @@ var require_lib = __commonJS({
12903
12892
  "../../node_modules/.pnpm/pgpass@1.0.5/node_modules/pgpass/lib/index.js"(exports, module) {
12904
12893
  "use strict";
12905
12894
  init_esm_shims();
12906
- var path4 = __require("path");
12895
+ var path3 = __require("path");
12907
12896
  var fs3 = __require("fs");
12908
12897
  var helper = require_helper();
12909
12898
  module.exports = function(connInfo, cb) {
@@ -13112,12 +13101,12 @@ var require_client = __commonJS({
13112
13101
  this._connect(callback);
13113
13102
  return;
13114
13103
  }
13115
- return new this._Promise((resolve9, reject) => {
13104
+ return new this._Promise((resolve10, reject) => {
13116
13105
  this._connect((error51) => {
13117
13106
  if (error51) {
13118
13107
  reject(error51);
13119
13108
  } else {
13120
- resolve9(this);
13109
+ resolve10(this);
13121
13110
  }
13122
13111
  });
13123
13112
  });
@@ -13464,8 +13453,8 @@ var require_client = __commonJS({
13464
13453
  } else {
13465
13454
  query = new Query2(config3, values, callback);
13466
13455
  if (!query.callback) {
13467
- result = new this._Promise((resolve9, reject) => {
13468
- query.callback = (err, res) => err ? reject(err) : resolve9(res);
13456
+ result = new this._Promise((resolve10, reject) => {
13457
+ query.callback = (err, res) => err ? reject(err) : resolve10(res);
13469
13458
  }).catch((err) => {
13470
13459
  Error.captureStackTrace(err);
13471
13460
  throw err;
@@ -13549,8 +13538,8 @@ var require_client = __commonJS({
13549
13538
  if (cb) {
13550
13539
  this.connection.once("end", cb);
13551
13540
  } else {
13552
- return new this._Promise((resolve9) => {
13553
- this.connection.once("end", resolve9);
13541
+ return new this._Promise((resolve10) => {
13542
+ this.connection.once("end", resolve10);
13554
13543
  });
13555
13544
  }
13556
13545
  }
@@ -13600,8 +13589,8 @@ var require_pg_pool = __commonJS({
13600
13589
  const cb = function(err, client) {
13601
13590
  err ? rej(err) : res(client);
13602
13591
  };
13603
- const result = new Promise2(function(resolve9, reject) {
13604
- res = resolve9;
13592
+ const result = new Promise2(function(resolve10, reject) {
13593
+ res = resolve10;
13605
13594
  rej = reject;
13606
13595
  }).catch((err) => {
13607
13596
  Error.captureStackTrace(err);
@@ -13662,7 +13651,7 @@ var require_pg_pool = __commonJS({
13662
13651
  if (typeof Promise2.try === "function") {
13663
13652
  return Promise2.try(f);
13664
13653
  }
13665
- return new Promise2((resolve9) => resolve9(f()));
13654
+ return new Promise2((resolve10) => resolve10(f()));
13666
13655
  }
13667
13656
  _isFull() {
13668
13657
  return this._clients.length >= this.options.max;
@@ -14056,8 +14045,8 @@ var require_query2 = __commonJS({
14056
14045
  NativeQuery.prototype._getPromise = function() {
14057
14046
  if (this._promise) return this._promise;
14058
14047
  this._promise = new Promise(
14059
- function(resolve9, reject) {
14060
- this._once("end", resolve9);
14048
+ function(resolve10, reject) {
14049
+ this._once("end", resolve10);
14061
14050
  this._once("error", reject);
14062
14051
  }.bind(this)
14063
14052
  );
@@ -14236,12 +14225,12 @@ var require_client2 = __commonJS({
14236
14225
  this._connect(callback);
14237
14226
  return;
14238
14227
  }
14239
- return new this._Promise((resolve9, reject) => {
14228
+ return new this._Promise((resolve10, reject) => {
14240
14229
  this._connect((error51) => {
14241
14230
  if (error51) {
14242
14231
  reject(error51);
14243
14232
  } else {
14244
- resolve9(this);
14233
+ resolve10(this);
14245
14234
  }
14246
14235
  });
14247
14236
  });
@@ -14265,8 +14254,8 @@ var require_client2 = __commonJS({
14265
14254
  query = new NativeQuery(config3, values, callback);
14266
14255
  if (!query.callback) {
14267
14256
  let resolveOut, rejectOut;
14268
- result = new this._Promise((resolve9, reject) => {
14269
- resolveOut = resolve9;
14257
+ result = new this._Promise((resolve10, reject) => {
14258
+ resolveOut = resolve10;
14270
14259
  rejectOut = reject;
14271
14260
  }).catch((err) => {
14272
14261
  Error.captureStackTrace(err);
@@ -14329,8 +14318,8 @@ var require_client2 = __commonJS({
14329
14318
  }
14330
14319
  let result;
14331
14320
  if (!cb) {
14332
- result = new this._Promise(function(resolve9, reject) {
14333
- cb = (err) => err ? reject(err) : resolve9();
14321
+ result = new this._Promise(function(resolve10, reject) {
14322
+ cb = (err) => err ? reject(err) : resolve10();
14334
14323
  });
14335
14324
  }
14336
14325
  this.native.end(function() {
@@ -14478,7 +14467,7 @@ import { Command } from "commander";
14478
14467
  // src/commands/build.ts
14479
14468
  init_esm_shims();
14480
14469
  import { mkdirSync, statSync as statSync2, existsSync as existsSync3, readdirSync as readdirSync2, writeFileSync } from "fs";
14481
- import { resolve as resolve3, join as join6, dirname } from "path";
14470
+ import { resolve as resolve3, join as join7, dirname } from "path";
14482
14471
  import { createRequire } from "module";
14483
14472
  import { build as viteBuild } from "vite";
14484
14473
  import { build as tsupBuild } from "tsup";
@@ -15265,10 +15254,10 @@ function mergeDefs(...defs) {
15265
15254
  function cloneDef(schema) {
15266
15255
  return mergeDefs(schema._zod.def);
15267
15256
  }
15268
- function getElementAtPath(obj, path4) {
15269
- if (!path4)
15257
+ function getElementAtPath(obj, path3) {
15258
+ if (!path3)
15270
15259
  return obj;
15271
- return path4.reduce((acc, key) => acc?.[key], obj);
15260
+ return path3.reduce((acc, key) => acc?.[key], obj);
15272
15261
  }
15273
15262
  function promiseAllObject(promisesObj) {
15274
15263
  const keys = Object.keys(promisesObj);
@@ -15677,11 +15666,11 @@ function explicitlyAborted(x2, startIndex = 0) {
15677
15666
  }
15678
15667
  return false;
15679
15668
  }
15680
- function prefixIssues(path4, issues) {
15669
+ function prefixIssues(path3, issues) {
15681
15670
  return issues.map((iss) => {
15682
15671
  var _a3;
15683
15672
  (_a3 = iss).path ?? (_a3.path = []);
15684
- iss.path.unshift(path4);
15673
+ iss.path.unshift(path3);
15685
15674
  return iss;
15686
15675
  });
15687
15676
  }
@@ -15828,16 +15817,16 @@ function flattenError(error51, mapper = (issue2) => issue2.message) {
15828
15817
  }
15829
15818
  function formatError(error51, mapper = (issue2) => issue2.message) {
15830
15819
  const fieldErrors = { _errors: [] };
15831
- const processError = (error52, path4 = []) => {
15820
+ const processError = (error52, path3 = []) => {
15832
15821
  for (const issue2 of error52.issues) {
15833
15822
  if (issue2.code === "invalid_union" && issue2.errors.length) {
15834
- issue2.errors.map((issues) => processError({ issues }, [...path4, ...issue2.path]));
15823
+ issue2.errors.map((issues) => processError({ issues }, [...path3, ...issue2.path]));
15835
15824
  } else if (issue2.code === "invalid_key") {
15836
- processError({ issues: issue2.issues }, [...path4, ...issue2.path]);
15825
+ processError({ issues: issue2.issues }, [...path3, ...issue2.path]);
15837
15826
  } else if (issue2.code === "invalid_element") {
15838
- processError({ issues: issue2.issues }, [...path4, ...issue2.path]);
15827
+ processError({ issues: issue2.issues }, [...path3, ...issue2.path]);
15839
15828
  } else {
15840
- const fullpath = [...path4, ...issue2.path];
15829
+ const fullpath = [...path3, ...issue2.path];
15841
15830
  if (fullpath.length === 0) {
15842
15831
  fieldErrors._errors.push(mapper(issue2));
15843
15832
  } else {
@@ -15864,17 +15853,17 @@ function formatError(error51, mapper = (issue2) => issue2.message) {
15864
15853
  }
15865
15854
  function treeifyError(error51, mapper = (issue2) => issue2.message) {
15866
15855
  const result = { errors: [] };
15867
- const processError = (error52, path4 = []) => {
15856
+ const processError = (error52, path3 = []) => {
15868
15857
  var _a3, _b;
15869
15858
  for (const issue2 of error52.issues) {
15870
15859
  if (issue2.code === "invalid_union" && issue2.errors.length) {
15871
- issue2.errors.map((issues) => processError({ issues }, [...path4, ...issue2.path]));
15860
+ issue2.errors.map((issues) => processError({ issues }, [...path3, ...issue2.path]));
15872
15861
  } else if (issue2.code === "invalid_key") {
15873
- processError({ issues: issue2.issues }, [...path4, ...issue2.path]);
15862
+ processError({ issues: issue2.issues }, [...path3, ...issue2.path]);
15874
15863
  } else if (issue2.code === "invalid_element") {
15875
- processError({ issues: issue2.issues }, [...path4, ...issue2.path]);
15864
+ processError({ issues: issue2.issues }, [...path3, ...issue2.path]);
15876
15865
  } else {
15877
- const fullpath = [...path4, ...issue2.path];
15866
+ const fullpath = [...path3, ...issue2.path];
15878
15867
  if (fullpath.length === 0) {
15879
15868
  result.errors.push(mapper(issue2));
15880
15869
  continue;
@@ -15906,8 +15895,8 @@ function treeifyError(error51, mapper = (issue2) => issue2.message) {
15906
15895
  }
15907
15896
  function toDotPath(_path) {
15908
15897
  const segs = [];
15909
- const path4 = _path.map((seg) => typeof seg === "object" ? seg.key : seg);
15910
- for (const seg of path4) {
15898
+ const path3 = _path.map((seg) => typeof seg === "object" ? seg.key : seg);
15899
+ for (const seg of path3) {
15911
15900
  if (typeof seg === "number")
15912
15901
  segs.push(`[${seg}]`);
15913
15902
  else if (typeof seg === "symbol")
@@ -16100,10 +16089,10 @@ var nanoid = /^[a-zA-Z0-9_-]{21}$/;
16100
16089
  var duration = /^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/;
16101
16090
  var extendedDuration = /^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/;
16102
16091
  var guid = /^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/;
16103
- var uuid = (version4) => {
16104
- if (!version4)
16092
+ var uuid = (version3) => {
16093
+ if (!version3)
16105
16094
  return /^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/;
16106
- return new RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${version4}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`);
16095
+ return new RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${version3}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`);
16107
16096
  };
16108
16097
  var uuid4 = /* @__PURE__ */ uuid(4);
16109
16098
  var uuid6 = /* @__PURE__ */ uuid(6);
@@ -28680,13 +28669,13 @@ function resolveRef(ref, ctx) {
28680
28669
  if (!ref.startsWith("#")) {
28681
28670
  throw new Error("External $ref is not supported, only local refs (#/...) are allowed");
28682
28671
  }
28683
- const path4 = ref.slice(1).split("/").filter(Boolean);
28684
- if (path4.length === 0) {
28672
+ const path3 = ref.slice(1).split("/").filter(Boolean);
28673
+ if (path3.length === 0) {
28685
28674
  return ctx.rootSchema;
28686
28675
  }
28687
28676
  const defsKey = ctx.version === "draft-2020-12" ? "$defs" : "definitions";
28688
- if (path4[0] === defsKey) {
28689
- const key = path4[1];
28677
+ if (path3[0] === defsKey) {
28678
+ const key = path3[1];
28690
28679
  if (!key || !ctx.defs[key]) {
28691
28680
  throw new Error(`Reference not found: ${ref}`);
28692
28681
  }
@@ -29053,10 +29042,10 @@ function fromJSONSchema(schema, params) {
29053
29042
  } catch {
29054
29043
  throw new Error("fromJSONSchema input is not valid JSON (possibly cyclic); use $defs/$ref for recursive schemas");
29055
29044
  }
29056
- const version4 = detectVersion(normalized, params?.defaultTarget);
29045
+ const version3 = detectVersion(normalized, params?.defaultTarget);
29057
29046
  const defs = normalized.$defs || normalized.definitions || {};
29058
29047
  const ctx = {
29059
- version: version4,
29048
+ version: version3,
29060
29049
  defs,
29061
29050
  refs: /* @__PURE__ */ new Map(),
29062
29051
  processing: /* @__PURE__ */ new Set(),
@@ -29098,7 +29087,7 @@ config(en_default());
29098
29087
  // ../core/dist/index.mjs
29099
29088
  var import_yaml = __toESM(require_dist(), 1);
29100
29089
  import * as fs from "fs";
29101
- import * as path2 from "path";
29090
+ import * as path from "path";
29102
29091
  var import_bcryptjs = __toESM(require_bcryptjs(), 1);
29103
29092
  var snakeCaseName = external_exports.string().regex(/^[a-z][a-z0-9_]*$/, 'Must be snake_case (e.g. "blog_post")');
29104
29093
  var maxSizeString = external_exports.string().regex(
@@ -29155,6 +29144,10 @@ var RawBooleanFieldSchema = RawFieldBase.extend({
29155
29144
  var RawDateFieldSchema = RawFieldBase.extend({
29156
29145
  type: external_exports.literal("date")
29157
29146
  });
29147
+ var RawProgrammaticFieldSchema = RawFieldBase.extend({
29148
+ type: external_exports.literal("programmatic"),
29149
+ required: external_exports.boolean().optional()
29150
+ });
29158
29151
  var RawImageFieldSchema = RawFieldBase.extend({
29159
29152
  type: external_exports.literal("image"),
29160
29153
  max_size: maxSizeString.optional(),
@@ -29201,7 +29194,8 @@ var RawNonEnumFieldSchema = external_exports.discriminatedUnion("type", [
29201
29194
  RawVideoFieldSchema,
29202
29195
  RawFileFieldSchema,
29203
29196
  RawParagraphFieldSchema,
29204
- RawReferenceFieldSchema
29197
+ RawReferenceFieldSchema,
29198
+ RawProgrammaticFieldSchema
29205
29199
  ]);
29206
29200
  var RawFieldSchema = external_exports.union([RawNonEnumFieldSchema, RawEnumFieldSchema]);
29207
29201
  var RawTabSchema = external_exports.object({
@@ -29482,7 +29476,7 @@ function loadSchemaFile(filePath) {
29482
29476
  ]
29483
29477
  };
29484
29478
  }
29485
- const ext = path2.extname(filePath).toLowerCase();
29479
+ const ext = path.extname(filePath).toLowerCase();
29486
29480
  if (ext === ".json") {
29487
29481
  try {
29488
29482
  return { ok: true, value: JSON.parse(raw2) };
@@ -29544,7 +29538,7 @@ function walkSchemaDirectory(config3) {
29544
29538
  const resolvedFolderPaths = /* @__PURE__ */ new Map();
29545
29539
  for (const folderKey of Object.keys(FOLDER_KEY_TO_SCHEMA_TYPE)) {
29546
29540
  const folderName = config3.folders[folderKey];
29547
- const absFolder = path2.resolve(config3.base_path, folderName);
29541
+ const absFolder = path.resolve(config3.base_path, folderName);
29548
29542
  const existing = resolvedFolderPaths.get(absFolder);
29549
29543
  if (existing !== void 0) {
29550
29544
  errors.push({
@@ -29561,7 +29555,7 @@ function walkSchemaDirectory(config3) {
29561
29555
  FOLDER_KEY_TO_SCHEMA_TYPE
29562
29556
  )) {
29563
29557
  const folderName = config3.folders[folderKey];
29564
- const folderPath = path2.resolve(config3.base_path, folderName);
29558
+ const folderPath = path.resolve(config3.base_path, folderName);
29565
29559
  if (!directoryExists(folderPath)) {
29566
29560
  errors.push({
29567
29561
  file: folderPath,
@@ -29574,8 +29568,8 @@ function walkSchemaDirectory(config3) {
29574
29568
  const expectedPrefix = SCHEMA_TYPE_TO_PREFIX[schemaType];
29575
29569
  for (const entry of entries) {
29576
29570
  if (!isSupportedExtension(entry)) continue;
29577
- const filePath = path2.join(folderPath, entry);
29578
- const baseName = path2.basename(entry, path2.extname(entry));
29571
+ const filePath = path.join(folderPath, entry);
29572
+ const baseName = path.basename(entry, path.extname(entry));
29579
29573
  if (!hasCorrectPrefix(baseName, expectedPrefix)) {
29580
29574
  errors.push({
29581
29575
  file: filePath,
@@ -29610,7 +29604,7 @@ function readDirEntries(dirPath) {
29610
29604
  }
29611
29605
  }
29612
29606
  function isSupportedExtension(filename) {
29613
- const ext = path2.extname(filename).toLowerCase();
29607
+ const ext = path.extname(filename).toLowerCase();
29614
29608
  return ext === ".json" || ext === ".yaml" || ext === ".yml";
29615
29609
  }
29616
29610
  function hasCorrectPrefix(baseName, expectedPrefix) {
@@ -29786,7 +29780,14 @@ var fieldTypeRegistry = {
29786
29780
  db_column,
29787
29781
  ui_component: { component: "typeahead-select", ref: raw2.target, rel: raw2.rel }
29788
29782
  };
29789
- }
29783
+ },
29784
+ // ── Programmatic — computed at read time, no column ─────────────────────────
29785
+ // Inert marker: the value is produced by a user resolver in the api layer.
29786
+ programmatic: () => ({
29787
+ validation: { required: false },
29788
+ db_column: null,
29789
+ ui_component: { component: "computed-display" }
29790
+ })
29790
29791
  };
29791
29792
  var CONTENT_SYSTEM_FIELDS = [
29792
29793
  { name: "id", db_type: "uuid", primary_key: true, default: "gen_random_uuid()", nullable: false },
@@ -29867,8 +29868,9 @@ function buildParsedField(rawField, order, sourceFile, ownerTableName) {
29867
29868
  }]
29868
29869
  };
29869
29870
  }
29870
- const { name, label, required: required2 } = rawField;
29871
+ const { name, label } = rawField;
29871
29872
  const { validation, db_column, ui_component } = build(rawField, { ownerTableName });
29873
+ const required2 = validation.required;
29872
29874
  return {
29873
29875
  ok: true,
29874
29876
  value: {
@@ -30161,1167 +30163,6 @@ init_esm_shims();
30161
30163
 
30162
30164
  // ../../node_modules/.pnpm/drizzle-orm@0.45.2_@neondatabase+serverless@1.1.0_@opentelemetry+api@1.9.1_@types+pg@8.20.0_kysely@0.28.16_pg@8.22.0/node_modules/drizzle-orm/alias.js
30163
30165
  init_esm_shims();
30164
-
30165
- // ../../node_modules/.pnpm/drizzle-orm@0.45.2_@neondatabase+serverless@1.1.0_@opentelemetry+api@1.9.1_@types+pg@8.20.0_kysely@0.28.16_pg@8.22.0/node_modules/drizzle-orm/column.js
30166
- init_esm_shims();
30167
-
30168
- // ../../node_modules/.pnpm/drizzle-orm@0.45.2_@neondatabase+serverless@1.1.0_@opentelemetry+api@1.9.1_@types+pg@8.20.0_kysely@0.28.16_pg@8.22.0/node_modules/drizzle-orm/entity.js
30169
- init_esm_shims();
30170
- var entityKind = /* @__PURE__ */ Symbol.for("drizzle:entityKind");
30171
- function is(value, type) {
30172
- if (!value || typeof value !== "object") {
30173
- return false;
30174
- }
30175
- if (value instanceof type) {
30176
- return true;
30177
- }
30178
- if (!Object.prototype.hasOwnProperty.call(type, entityKind)) {
30179
- throw new Error(
30180
- `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.`
30181
- );
30182
- }
30183
- let cls = Object.getPrototypeOf(value).constructor;
30184
- if (cls) {
30185
- while (cls) {
30186
- if (entityKind in cls && cls[entityKind] === type[entityKind]) {
30187
- return true;
30188
- }
30189
- cls = Object.getPrototypeOf(cls);
30190
- }
30191
- }
30192
- return false;
30193
- }
30194
-
30195
- // ../../node_modules/.pnpm/drizzle-orm@0.45.2_@neondatabase+serverless@1.1.0_@opentelemetry+api@1.9.1_@types+pg@8.20.0_kysely@0.28.16_pg@8.22.0/node_modules/drizzle-orm/column.js
30196
- var Column = class {
30197
- constructor(table, config3) {
30198
- this.table = table;
30199
- this.config = config3;
30200
- this.name = config3.name;
30201
- this.keyAsName = config3.keyAsName;
30202
- this.notNull = config3.notNull;
30203
- this.default = config3.default;
30204
- this.defaultFn = config3.defaultFn;
30205
- this.onUpdateFn = config3.onUpdateFn;
30206
- this.hasDefault = config3.hasDefault;
30207
- this.primary = config3.primaryKey;
30208
- this.isUnique = config3.isUnique;
30209
- this.uniqueName = config3.uniqueName;
30210
- this.uniqueType = config3.uniqueType;
30211
- this.dataType = config3.dataType;
30212
- this.columnType = config3.columnType;
30213
- this.generated = config3.generated;
30214
- this.generatedIdentity = config3.generatedIdentity;
30215
- }
30216
- static [entityKind] = "Column";
30217
- name;
30218
- keyAsName;
30219
- primary;
30220
- notNull;
30221
- default;
30222
- defaultFn;
30223
- onUpdateFn;
30224
- hasDefault;
30225
- isUnique;
30226
- uniqueName;
30227
- uniqueType;
30228
- dataType;
30229
- columnType;
30230
- enumValues = void 0;
30231
- generated = void 0;
30232
- generatedIdentity = void 0;
30233
- config;
30234
- mapFromDriverValue(value) {
30235
- return value;
30236
- }
30237
- mapToDriverValue(value) {
30238
- return value;
30239
- }
30240
- // ** @internal */
30241
- shouldDisableInsert() {
30242
- return this.config.generated !== void 0 && this.config.generated.type !== "byDefault";
30243
- }
30244
- };
30245
-
30246
- // ../../node_modules/.pnpm/drizzle-orm@0.45.2_@neondatabase+serverless@1.1.0_@opentelemetry+api@1.9.1_@types+pg@8.20.0_kysely@0.28.16_pg@8.22.0/node_modules/drizzle-orm/sql/sql.js
30247
- init_esm_shims();
30248
-
30249
- // ../../node_modules/.pnpm/drizzle-orm@0.45.2_@neondatabase+serverless@1.1.0_@opentelemetry+api@1.9.1_@types+pg@8.20.0_kysely@0.28.16_pg@8.22.0/node_modules/drizzle-orm/pg-core/columns/enum.js
30250
- init_esm_shims();
30251
-
30252
- // ../../node_modules/.pnpm/drizzle-orm@0.45.2_@neondatabase+serverless@1.1.0_@opentelemetry+api@1.9.1_@types+pg@8.20.0_kysely@0.28.16_pg@8.22.0/node_modules/drizzle-orm/pg-core/columns/common.js
30253
- init_esm_shims();
30254
-
30255
- // ../../node_modules/.pnpm/drizzle-orm@0.45.2_@neondatabase+serverless@1.1.0_@opentelemetry+api@1.9.1_@types+pg@8.20.0_kysely@0.28.16_pg@8.22.0/node_modules/drizzle-orm/column-builder.js
30256
- init_esm_shims();
30257
- var ColumnBuilder = class {
30258
- static [entityKind] = "ColumnBuilder";
30259
- config;
30260
- constructor(name, dataType, columnType) {
30261
- this.config = {
30262
- name,
30263
- keyAsName: name === "",
30264
- notNull: false,
30265
- default: void 0,
30266
- hasDefault: false,
30267
- primaryKey: false,
30268
- isUnique: false,
30269
- uniqueName: void 0,
30270
- uniqueType: void 0,
30271
- dataType,
30272
- columnType,
30273
- generated: void 0
30274
- };
30275
- }
30276
- /**
30277
- * Changes the data type of the column. Commonly used with `json` columns. Also, useful for branded types.
30278
- *
30279
- * @example
30280
- * ```ts
30281
- * const users = pgTable('users', {
30282
- * id: integer('id').$type<UserId>().primaryKey(),
30283
- * details: json('details').$type<UserDetails>().notNull(),
30284
- * });
30285
- * ```
30286
- */
30287
- $type() {
30288
- return this;
30289
- }
30290
- /**
30291
- * Adds a `not null` clause to the column definition.
30292
- *
30293
- * Affects the `select` model of the table - columns *without* `not null` will be nullable on select.
30294
- */
30295
- notNull() {
30296
- this.config.notNull = true;
30297
- return this;
30298
- }
30299
- /**
30300
- * Adds a `default <value>` clause to the column definition.
30301
- *
30302
- * Affects the `insert` model of the table - columns *with* `default` are optional on insert.
30303
- *
30304
- * If you need to set a dynamic default value, use {@link $defaultFn} instead.
30305
- */
30306
- default(value) {
30307
- this.config.default = value;
30308
- this.config.hasDefault = true;
30309
- return this;
30310
- }
30311
- /**
30312
- * Adds a dynamic default value to the column.
30313
- * The function will be called when the row is inserted, and the returned value will be used as the column value.
30314
- *
30315
- * **Note:** This value does not affect the `drizzle-kit` behavior, it is only used at runtime in `drizzle-orm`.
30316
- */
30317
- $defaultFn(fn) {
30318
- this.config.defaultFn = fn;
30319
- this.config.hasDefault = true;
30320
- return this;
30321
- }
30322
- /**
30323
- * Alias for {@link $defaultFn}.
30324
- */
30325
- $default = this.$defaultFn;
30326
- /**
30327
- * Adds a dynamic update value to the column.
30328
- * 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.
30329
- * 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.
30330
- *
30331
- * **Note:** This value does not affect the `drizzle-kit` behavior, it is only used at runtime in `drizzle-orm`.
30332
- */
30333
- $onUpdateFn(fn) {
30334
- this.config.onUpdateFn = fn;
30335
- this.config.hasDefault = true;
30336
- return this;
30337
- }
30338
- /**
30339
- * Alias for {@link $onUpdateFn}.
30340
- */
30341
- $onUpdate = this.$onUpdateFn;
30342
- /**
30343
- * Adds a `primary key` clause to the column definition. This implicitly makes the column `not null`.
30344
- *
30345
- * In SQLite, `integer primary key` implicitly makes the column auto-incrementing.
30346
- */
30347
- primaryKey() {
30348
- this.config.primaryKey = true;
30349
- this.config.notNull = true;
30350
- return this;
30351
- }
30352
- /** @internal Sets the name of the column to the key within the table definition if a name was not given. */
30353
- setName(name) {
30354
- if (this.config.name !== "") return;
30355
- this.config.name = name;
30356
- }
30357
- };
30358
-
30359
- // ../../node_modules/.pnpm/drizzle-orm@0.45.2_@neondatabase+serverless@1.1.0_@opentelemetry+api@1.9.1_@types+pg@8.20.0_kysely@0.28.16_pg@8.22.0/node_modules/drizzle-orm/pg-core/foreign-keys.js
30360
- init_esm_shims();
30361
-
30362
- // ../../node_modules/.pnpm/drizzle-orm@0.45.2_@neondatabase+serverless@1.1.0_@opentelemetry+api@1.9.1_@types+pg@8.20.0_kysely@0.28.16_pg@8.22.0/node_modules/drizzle-orm/table.utils.js
30363
- init_esm_shims();
30364
- var TableName = /* @__PURE__ */ Symbol.for("drizzle:Name");
30365
-
30366
- // ../../node_modules/.pnpm/drizzle-orm@0.45.2_@neondatabase+serverless@1.1.0_@opentelemetry+api@1.9.1_@types+pg@8.20.0_kysely@0.28.16_pg@8.22.0/node_modules/drizzle-orm/pg-core/foreign-keys.js
30367
- var ForeignKeyBuilder = class {
30368
- static [entityKind] = "PgForeignKeyBuilder";
30369
- /** @internal */
30370
- reference;
30371
- /** @internal */
30372
- _onUpdate = "no action";
30373
- /** @internal */
30374
- _onDelete = "no action";
30375
- constructor(config3, actions) {
30376
- this.reference = () => {
30377
- const { name, columns, foreignColumns } = config3();
30378
- return { name, columns, foreignTable: foreignColumns[0].table, foreignColumns };
30379
- };
30380
- if (actions) {
30381
- this._onUpdate = actions.onUpdate;
30382
- this._onDelete = actions.onDelete;
30383
- }
30384
- }
30385
- onUpdate(action) {
30386
- this._onUpdate = action === void 0 ? "no action" : action;
30387
- return this;
30388
- }
30389
- onDelete(action) {
30390
- this._onDelete = action === void 0 ? "no action" : action;
30391
- return this;
30392
- }
30393
- /** @internal */
30394
- build(table) {
30395
- return new ForeignKey(table, this);
30396
- }
30397
- };
30398
- var ForeignKey = class {
30399
- constructor(table, builder) {
30400
- this.table = table;
30401
- this.reference = builder.reference;
30402
- this.onUpdate = builder._onUpdate;
30403
- this.onDelete = builder._onDelete;
30404
- }
30405
- static [entityKind] = "PgForeignKey";
30406
- reference;
30407
- onUpdate;
30408
- onDelete;
30409
- getName() {
30410
- const { name, columns, foreignColumns } = this.reference();
30411
- const columnNames = columns.map((column) => column.name);
30412
- const foreignColumnNames = foreignColumns.map((column) => column.name);
30413
- const chunks = [
30414
- this.table[TableName],
30415
- ...columnNames,
30416
- foreignColumns[0].table[TableName],
30417
- ...foreignColumnNames
30418
- ];
30419
- return name ?? `${chunks.join("_")}_fk`;
30420
- }
30421
- };
30422
-
30423
- // ../../node_modules/.pnpm/drizzle-orm@0.45.2_@neondatabase+serverless@1.1.0_@opentelemetry+api@1.9.1_@types+pg@8.20.0_kysely@0.28.16_pg@8.22.0/node_modules/drizzle-orm/tracing-utils.js
30424
- init_esm_shims();
30425
- function iife(fn, ...args) {
30426
- return fn(...args);
30427
- }
30428
-
30429
- // ../../node_modules/.pnpm/drizzle-orm@0.45.2_@neondatabase+serverless@1.1.0_@opentelemetry+api@1.9.1_@types+pg@8.20.0_kysely@0.28.16_pg@8.22.0/node_modules/drizzle-orm/pg-core/unique-constraint.js
30430
- init_esm_shims();
30431
- function uniqueKeyName(table, columns) {
30432
- return `${table[TableName]}_${columns.join("_")}_unique`;
30433
- }
30434
- var UniqueConstraintBuilder = class {
30435
- constructor(columns, name) {
30436
- this.name = name;
30437
- this.columns = columns;
30438
- }
30439
- static [entityKind] = "PgUniqueConstraintBuilder";
30440
- /** @internal */
30441
- columns;
30442
- /** @internal */
30443
- nullsNotDistinctConfig = false;
30444
- nullsNotDistinct() {
30445
- this.nullsNotDistinctConfig = true;
30446
- return this;
30447
- }
30448
- /** @internal */
30449
- build(table) {
30450
- return new UniqueConstraint(table, this.columns, this.nullsNotDistinctConfig, this.name);
30451
- }
30452
- };
30453
- var UniqueOnConstraintBuilder = class {
30454
- static [entityKind] = "PgUniqueOnConstraintBuilder";
30455
- /** @internal */
30456
- name;
30457
- constructor(name) {
30458
- this.name = name;
30459
- }
30460
- on(...columns) {
30461
- return new UniqueConstraintBuilder(columns, this.name);
30462
- }
30463
- };
30464
- var UniqueConstraint = class {
30465
- constructor(table, columns, nullsNotDistinct, name) {
30466
- this.table = table;
30467
- this.columns = columns;
30468
- this.name = name ?? uniqueKeyName(this.table, this.columns.map((column) => column.name));
30469
- this.nullsNotDistinct = nullsNotDistinct;
30470
- }
30471
- static [entityKind] = "PgUniqueConstraint";
30472
- columns;
30473
- name;
30474
- nullsNotDistinct = false;
30475
- getName() {
30476
- return this.name;
30477
- }
30478
- };
30479
-
30480
- // ../../node_modules/.pnpm/drizzle-orm@0.45.2_@neondatabase+serverless@1.1.0_@opentelemetry+api@1.9.1_@types+pg@8.20.0_kysely@0.28.16_pg@8.22.0/node_modules/drizzle-orm/pg-core/utils/array.js
30481
- init_esm_shims();
30482
- function parsePgArrayValue(arrayString, startFrom, inQuotes) {
30483
- for (let i = startFrom; i < arrayString.length; i++) {
30484
- const char2 = arrayString[i];
30485
- if (char2 === "\\") {
30486
- i++;
30487
- continue;
30488
- }
30489
- if (char2 === '"') {
30490
- return [arrayString.slice(startFrom, i).replace(/\\/g, ""), i + 1];
30491
- }
30492
- if (inQuotes) {
30493
- continue;
30494
- }
30495
- if (char2 === "," || char2 === "}") {
30496
- return [arrayString.slice(startFrom, i).replace(/\\/g, ""), i];
30497
- }
30498
- }
30499
- return [arrayString.slice(startFrom).replace(/\\/g, ""), arrayString.length];
30500
- }
30501
- function parsePgNestedArray(arrayString, startFrom = 0) {
30502
- const result = [];
30503
- let i = startFrom;
30504
- let lastCharIsComma = false;
30505
- while (i < arrayString.length) {
30506
- const char2 = arrayString[i];
30507
- if (char2 === ",") {
30508
- if (lastCharIsComma || i === startFrom) {
30509
- result.push("");
30510
- }
30511
- lastCharIsComma = true;
30512
- i++;
30513
- continue;
30514
- }
30515
- lastCharIsComma = false;
30516
- if (char2 === "\\") {
30517
- i += 2;
30518
- continue;
30519
- }
30520
- if (char2 === '"') {
30521
- const [value2, startFrom2] = parsePgArrayValue(arrayString, i + 1, true);
30522
- result.push(value2);
30523
- i = startFrom2;
30524
- continue;
30525
- }
30526
- if (char2 === "}") {
30527
- return [result, i + 1];
30528
- }
30529
- if (char2 === "{") {
30530
- const [value2, startFrom2] = parsePgNestedArray(arrayString, i + 1);
30531
- result.push(value2);
30532
- i = startFrom2;
30533
- continue;
30534
- }
30535
- const [value, newStartFrom] = parsePgArrayValue(arrayString, i, false);
30536
- result.push(value);
30537
- i = newStartFrom;
30538
- }
30539
- return [result, i];
30540
- }
30541
- function parsePgArray(arrayString) {
30542
- const [result] = parsePgNestedArray(arrayString, 1);
30543
- return result;
30544
- }
30545
- function makePgArray(array2) {
30546
- return `{${array2.map((item) => {
30547
- if (Array.isArray(item)) {
30548
- return makePgArray(item);
30549
- }
30550
- if (typeof item === "string") {
30551
- return `"${item.replace(/\\/g, "\\\\").replace(/"/g, '\\"')}"`;
30552
- }
30553
- return `${item}`;
30554
- }).join(",")}}`;
30555
- }
30556
-
30557
- // ../../node_modules/.pnpm/drizzle-orm@0.45.2_@neondatabase+serverless@1.1.0_@opentelemetry+api@1.9.1_@types+pg@8.20.0_kysely@0.28.16_pg@8.22.0/node_modules/drizzle-orm/pg-core/columns/common.js
30558
- var PgColumnBuilder = class extends ColumnBuilder {
30559
- foreignKeyConfigs = [];
30560
- static [entityKind] = "PgColumnBuilder";
30561
- array(size) {
30562
- return new PgArrayBuilder(this.config.name, this, size);
30563
- }
30564
- references(ref, actions = {}) {
30565
- this.foreignKeyConfigs.push({ ref, actions });
30566
- return this;
30567
- }
30568
- unique(name, config3) {
30569
- this.config.isUnique = true;
30570
- this.config.uniqueName = name;
30571
- this.config.uniqueType = config3?.nulls;
30572
- return this;
30573
- }
30574
- generatedAlwaysAs(as2) {
30575
- this.config.generated = {
30576
- as: as2,
30577
- type: "always",
30578
- mode: "stored"
30579
- };
30580
- return this;
30581
- }
30582
- /** @internal */
30583
- buildForeignKeys(column, table) {
30584
- return this.foreignKeyConfigs.map(({ ref, actions }) => {
30585
- return iife(
30586
- (ref2, actions2) => {
30587
- const builder = new ForeignKeyBuilder(() => {
30588
- const foreignColumn = ref2();
30589
- return { columns: [column], foreignColumns: [foreignColumn] };
30590
- });
30591
- if (actions2.onUpdate) {
30592
- builder.onUpdate(actions2.onUpdate);
30593
- }
30594
- if (actions2.onDelete) {
30595
- builder.onDelete(actions2.onDelete);
30596
- }
30597
- return builder.build(table);
30598
- },
30599
- ref,
30600
- actions
30601
- );
30602
- });
30603
- }
30604
- /** @internal */
30605
- buildExtraConfigColumn(table) {
30606
- return new ExtraConfigColumn(table, this.config);
30607
- }
30608
- };
30609
- var PgColumn = class extends Column {
30610
- constructor(table, config3) {
30611
- if (!config3.uniqueName) {
30612
- config3.uniqueName = uniqueKeyName(table, [config3.name]);
30613
- }
30614
- super(table, config3);
30615
- this.table = table;
30616
- }
30617
- static [entityKind] = "PgColumn";
30618
- };
30619
- var ExtraConfigColumn = class extends PgColumn {
30620
- static [entityKind] = "ExtraConfigColumn";
30621
- getSQLType() {
30622
- return this.getSQLType();
30623
- }
30624
- indexConfig = {
30625
- order: this.config.order ?? "asc",
30626
- nulls: this.config.nulls ?? "last",
30627
- opClass: this.config.opClass
30628
- };
30629
- defaultConfig = {
30630
- order: "asc",
30631
- nulls: "last",
30632
- opClass: void 0
30633
- };
30634
- asc() {
30635
- this.indexConfig.order = "asc";
30636
- return this;
30637
- }
30638
- desc() {
30639
- this.indexConfig.order = "desc";
30640
- return this;
30641
- }
30642
- nullsFirst() {
30643
- this.indexConfig.nulls = "first";
30644
- return this;
30645
- }
30646
- nullsLast() {
30647
- this.indexConfig.nulls = "last";
30648
- return this;
30649
- }
30650
- /**
30651
- * ### PostgreSQL documentation quote
30652
- *
30653
- * > An operator class with optional parameters can be specified for each column of an index.
30654
- * The operator class identifies the operators to be used by the index for that column.
30655
- * For example, a B-tree index on four-byte integers would use the int4_ops class;
30656
- * this operator class includes comparison functions for four-byte integers.
30657
- * In practice the default operator class for the column's data type is usually sufficient.
30658
- * The main point of having operator classes is that for some data types, there could be more than one meaningful ordering.
30659
- * For example, we might want to sort a complex-number data type either by absolute value or by real part.
30660
- * We could do this by defining two operator classes for the data type and then selecting the proper class when creating an index.
30661
- * More information about operator classes check:
30662
- *
30663
- * ### Useful links
30664
- * https://www.postgresql.org/docs/current/sql-createindex.html
30665
- *
30666
- * https://www.postgresql.org/docs/current/indexes-opclass.html
30667
- *
30668
- * https://www.postgresql.org/docs/current/xindex.html
30669
- *
30670
- * ### Additional types
30671
- * If you have the `pg_vector` extension installed in your database, you can use the
30672
- * `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.
30673
- *
30674
- * **You can always specify any string you want in the operator class, in case Drizzle doesn't have it natively in its types**
30675
- *
30676
- * @param opClass
30677
- * @returns
30678
- */
30679
- op(opClass) {
30680
- this.indexConfig.opClass = opClass;
30681
- return this;
30682
- }
30683
- };
30684
- var IndexedColumn = class {
30685
- static [entityKind] = "IndexedColumn";
30686
- constructor(name, keyAsName, type, indexConfig) {
30687
- this.name = name;
30688
- this.keyAsName = keyAsName;
30689
- this.type = type;
30690
- this.indexConfig = indexConfig;
30691
- }
30692
- name;
30693
- keyAsName;
30694
- type;
30695
- indexConfig;
30696
- };
30697
- var PgArrayBuilder = class extends PgColumnBuilder {
30698
- static [entityKind] = "PgArrayBuilder";
30699
- constructor(name, baseBuilder, size) {
30700
- super(name, "array", "PgArray");
30701
- this.config.baseBuilder = baseBuilder;
30702
- this.config.size = size;
30703
- }
30704
- /** @internal */
30705
- build(table) {
30706
- const baseColumn = this.config.baseBuilder.build(table);
30707
- return new PgArray(
30708
- table,
30709
- this.config,
30710
- baseColumn
30711
- );
30712
- }
30713
- };
30714
- var PgArray = class _PgArray extends PgColumn {
30715
- constructor(table, config3, baseColumn, range) {
30716
- super(table, config3);
30717
- this.baseColumn = baseColumn;
30718
- this.range = range;
30719
- this.size = config3.size;
30720
- }
30721
- size;
30722
- static [entityKind] = "PgArray";
30723
- getSQLType() {
30724
- return `${this.baseColumn.getSQLType()}[${typeof this.size === "number" ? this.size : ""}]`;
30725
- }
30726
- mapFromDriverValue(value) {
30727
- if (typeof value === "string") {
30728
- value = parsePgArray(value);
30729
- }
30730
- return value.map((v2) => this.baseColumn.mapFromDriverValue(v2));
30731
- }
30732
- mapToDriverValue(value, isNestedArray = false) {
30733
- const a2 = value.map(
30734
- (v2) => v2 === null ? null : is(this.baseColumn, _PgArray) ? this.baseColumn.mapToDriverValue(v2, true) : this.baseColumn.mapToDriverValue(v2)
30735
- );
30736
- if (isNestedArray) return a2;
30737
- return makePgArray(a2);
30738
- }
30739
- };
30740
-
30741
- // ../../node_modules/.pnpm/drizzle-orm@0.45.2_@neondatabase+serverless@1.1.0_@opentelemetry+api@1.9.1_@types+pg@8.20.0_kysely@0.28.16_pg@8.22.0/node_modules/drizzle-orm/pg-core/columns/enum.js
30742
- var PgEnumObjectColumnBuilder = class extends PgColumnBuilder {
30743
- static [entityKind] = "PgEnumObjectColumnBuilder";
30744
- constructor(name, enumInstance) {
30745
- super(name, "string", "PgEnumObjectColumn");
30746
- this.config.enum = enumInstance;
30747
- }
30748
- /** @internal */
30749
- build(table) {
30750
- return new PgEnumObjectColumn(
30751
- table,
30752
- this.config
30753
- );
30754
- }
30755
- };
30756
- var PgEnumObjectColumn = class extends PgColumn {
30757
- static [entityKind] = "PgEnumObjectColumn";
30758
- enum;
30759
- enumValues = this.config.enum.enumValues;
30760
- constructor(table, config3) {
30761
- super(table, config3);
30762
- this.enum = config3.enum;
30763
- }
30764
- getSQLType() {
30765
- return this.enum.enumName;
30766
- }
30767
- };
30768
- var isPgEnumSym = /* @__PURE__ */ Symbol.for("drizzle:isPgEnum");
30769
- function isPgEnum(obj) {
30770
- return !!obj && typeof obj === "function" && isPgEnumSym in obj && obj[isPgEnumSym] === true;
30771
- }
30772
- var PgEnumColumnBuilder = class extends PgColumnBuilder {
30773
- static [entityKind] = "PgEnumColumnBuilder";
30774
- constructor(name, enumInstance) {
30775
- super(name, "string", "PgEnumColumn");
30776
- this.config.enum = enumInstance;
30777
- }
30778
- /** @internal */
30779
- build(table) {
30780
- return new PgEnumColumn(
30781
- table,
30782
- this.config
30783
- );
30784
- }
30785
- };
30786
- var PgEnumColumn = class extends PgColumn {
30787
- static [entityKind] = "PgEnumColumn";
30788
- enum = this.config.enum;
30789
- enumValues = this.config.enum.enumValues;
30790
- constructor(table, config3) {
30791
- super(table, config3);
30792
- this.enum = config3.enum;
30793
- }
30794
- getSQLType() {
30795
- return this.enum.enumName;
30796
- }
30797
- };
30798
-
30799
- // ../../node_modules/.pnpm/drizzle-orm@0.45.2_@neondatabase+serverless@1.1.0_@opentelemetry+api@1.9.1_@types+pg@8.20.0_kysely@0.28.16_pg@8.22.0/node_modules/drizzle-orm/subquery.js
30800
- init_esm_shims();
30801
- var Subquery = class {
30802
- static [entityKind] = "Subquery";
30803
- constructor(sql2, fields, alias, isWith = false, usedTables = []) {
30804
- this._ = {
30805
- brand: "Subquery",
30806
- sql: sql2,
30807
- selectedFields: fields,
30808
- alias,
30809
- isWith,
30810
- usedTables
30811
- };
30812
- }
30813
- // getSQL(): SQL<unknown> {
30814
- // return new SQL([this]);
30815
- // }
30816
- };
30817
- var WithSubquery = class extends Subquery {
30818
- static [entityKind] = "WithSubquery";
30819
- };
30820
-
30821
- // ../../node_modules/.pnpm/drizzle-orm@0.45.2_@neondatabase+serverless@1.1.0_@opentelemetry+api@1.9.1_@types+pg@8.20.0_kysely@0.28.16_pg@8.22.0/node_modules/drizzle-orm/tracing.js
30822
- init_esm_shims();
30823
-
30824
- // ../../node_modules/.pnpm/drizzle-orm@0.45.2_@neondatabase+serverless@1.1.0_@opentelemetry+api@1.9.1_@types+pg@8.20.0_kysely@0.28.16_pg@8.22.0/node_modules/drizzle-orm/version.js
30825
- init_esm_shims();
30826
- var version2 = "0.45.2";
30827
-
30828
- // ../../node_modules/.pnpm/drizzle-orm@0.45.2_@neondatabase+serverless@1.1.0_@opentelemetry+api@1.9.1_@types+pg@8.20.0_kysely@0.28.16_pg@8.22.0/node_modules/drizzle-orm/tracing.js
30829
- var otel;
30830
- var rawTracer;
30831
- var tracer = {
30832
- startActiveSpan(name, fn) {
30833
- if (!otel) {
30834
- return fn();
30835
- }
30836
- if (!rawTracer) {
30837
- rawTracer = otel.trace.getTracer("drizzle-orm", version2);
30838
- }
30839
- return iife(
30840
- (otel2, rawTracer2) => rawTracer2.startActiveSpan(
30841
- name,
30842
- (span) => {
30843
- try {
30844
- return fn(span);
30845
- } catch (e) {
30846
- span.setStatus({
30847
- code: otel2.SpanStatusCode.ERROR,
30848
- message: e instanceof Error ? e.message : "Unknown error"
30849
- // eslint-disable-line no-instanceof/no-instanceof
30850
- });
30851
- throw e;
30852
- } finally {
30853
- span.end();
30854
- }
30855
- }
30856
- ),
30857
- otel,
30858
- rawTracer
30859
- );
30860
- }
30861
- };
30862
-
30863
- // ../../node_modules/.pnpm/drizzle-orm@0.45.2_@neondatabase+serverless@1.1.0_@opentelemetry+api@1.9.1_@types+pg@8.20.0_kysely@0.28.16_pg@8.22.0/node_modules/drizzle-orm/view-common.js
30864
- init_esm_shims();
30865
- var ViewBaseConfig = /* @__PURE__ */ Symbol.for("drizzle:ViewBaseConfig");
30866
-
30867
- // ../../node_modules/.pnpm/drizzle-orm@0.45.2_@neondatabase+serverless@1.1.0_@opentelemetry+api@1.9.1_@types+pg@8.20.0_kysely@0.28.16_pg@8.22.0/node_modules/drizzle-orm/table.js
30868
- init_esm_shims();
30869
- var Schema = /* @__PURE__ */ Symbol.for("drizzle:Schema");
30870
- var Columns = /* @__PURE__ */ Symbol.for("drizzle:Columns");
30871
- var ExtraConfigColumns = /* @__PURE__ */ Symbol.for("drizzle:ExtraConfigColumns");
30872
- var OriginalName = /* @__PURE__ */ Symbol.for("drizzle:OriginalName");
30873
- var BaseName = /* @__PURE__ */ Symbol.for("drizzle:BaseName");
30874
- var IsAlias = /* @__PURE__ */ Symbol.for("drizzle:IsAlias");
30875
- var ExtraConfigBuilder = /* @__PURE__ */ Symbol.for("drizzle:ExtraConfigBuilder");
30876
- var IsDrizzleTable = /* @__PURE__ */ Symbol.for("drizzle:IsDrizzleTable");
30877
- var Table = class {
30878
- static [entityKind] = "Table";
30879
- /** @internal */
30880
- static Symbol = {
30881
- Name: TableName,
30882
- Schema,
30883
- OriginalName,
30884
- Columns,
30885
- ExtraConfigColumns,
30886
- BaseName,
30887
- IsAlias,
30888
- ExtraConfigBuilder
30889
- };
30890
- /**
30891
- * @internal
30892
- * Can be changed if the table is aliased.
30893
- */
30894
- [TableName];
30895
- /**
30896
- * @internal
30897
- * Used to store the original name of the table, before any aliasing.
30898
- */
30899
- [OriginalName];
30900
- /** @internal */
30901
- [Schema];
30902
- /** @internal */
30903
- [Columns];
30904
- /** @internal */
30905
- [ExtraConfigColumns];
30906
- /**
30907
- * @internal
30908
- * Used to store the table name before the transformation via the `tableCreator` functions.
30909
- */
30910
- [BaseName];
30911
- /** @internal */
30912
- [IsAlias] = false;
30913
- /** @internal */
30914
- [IsDrizzleTable] = true;
30915
- /** @internal */
30916
- [ExtraConfigBuilder] = void 0;
30917
- constructor(name, schema, baseName) {
30918
- this[TableName] = this[OriginalName] = name;
30919
- this[Schema] = schema;
30920
- this[BaseName] = baseName;
30921
- }
30922
- };
30923
- function getTableName(table) {
30924
- return table[TableName];
30925
- }
30926
- function getTableUniqueName(table) {
30927
- return `${table[Schema] ?? "public"}.${table[TableName]}`;
30928
- }
30929
-
30930
- // ../../node_modules/.pnpm/drizzle-orm@0.45.2_@neondatabase+serverless@1.1.0_@opentelemetry+api@1.9.1_@types+pg@8.20.0_kysely@0.28.16_pg@8.22.0/node_modules/drizzle-orm/sql/sql.js
30931
- var FakePrimitiveParam = class {
30932
- static [entityKind] = "FakePrimitiveParam";
30933
- };
30934
- function isSQLWrapper(value) {
30935
- return value !== null && value !== void 0 && typeof value.getSQL === "function";
30936
- }
30937
- function mergeQueries(queries) {
30938
- const result = { sql: "", params: [] };
30939
- for (const query of queries) {
30940
- result.sql += query.sql;
30941
- result.params.push(...query.params);
30942
- if (query.typings?.length) {
30943
- if (!result.typings) {
30944
- result.typings = [];
30945
- }
30946
- result.typings.push(...query.typings);
30947
- }
30948
- }
30949
- return result;
30950
- }
30951
- var StringChunk = class {
30952
- static [entityKind] = "StringChunk";
30953
- value;
30954
- constructor(value) {
30955
- this.value = Array.isArray(value) ? value : [value];
30956
- }
30957
- getSQL() {
30958
- return new SQL([this]);
30959
- }
30960
- };
30961
- var SQL = class _SQL {
30962
- constructor(queryChunks) {
30963
- this.queryChunks = queryChunks;
30964
- for (const chunk of queryChunks) {
30965
- if (is(chunk, Table)) {
30966
- const schemaName = chunk[Table.Symbol.Schema];
30967
- this.usedTables.push(
30968
- schemaName === void 0 ? chunk[Table.Symbol.Name] : schemaName + "." + chunk[Table.Symbol.Name]
30969
- );
30970
- }
30971
- }
30972
- }
30973
- static [entityKind] = "SQL";
30974
- /** @internal */
30975
- decoder = noopDecoder;
30976
- shouldInlineParams = false;
30977
- /** @internal */
30978
- usedTables = [];
30979
- append(query) {
30980
- this.queryChunks.push(...query.queryChunks);
30981
- return this;
30982
- }
30983
- toQuery(config3) {
30984
- return tracer.startActiveSpan("drizzle.buildSQL", (span) => {
30985
- const query = this.buildQueryFromSourceParams(this.queryChunks, config3);
30986
- span?.setAttributes({
30987
- "drizzle.query.text": query.sql,
30988
- "drizzle.query.params": JSON.stringify(query.params)
30989
- });
30990
- return query;
30991
- });
30992
- }
30993
- buildQueryFromSourceParams(chunks, _config) {
30994
- const config3 = Object.assign({}, _config, {
30995
- inlineParams: _config.inlineParams || this.shouldInlineParams,
30996
- paramStartIndex: _config.paramStartIndex || { value: 0 }
30997
- });
30998
- const {
30999
- casing,
31000
- escapeName,
31001
- escapeParam,
31002
- prepareTyping,
31003
- inlineParams,
31004
- paramStartIndex
31005
- } = config3;
31006
- return mergeQueries(chunks.map((chunk) => {
31007
- if (is(chunk, StringChunk)) {
31008
- return { sql: chunk.value.join(""), params: [] };
31009
- }
31010
- if (is(chunk, Name)) {
31011
- return { sql: escapeName(chunk.value), params: [] };
31012
- }
31013
- if (chunk === void 0) {
31014
- return { sql: "", params: [] };
31015
- }
31016
- if (Array.isArray(chunk)) {
31017
- const result = [new StringChunk("(")];
31018
- for (const [i, p2] of chunk.entries()) {
31019
- result.push(p2);
31020
- if (i < chunk.length - 1) {
31021
- result.push(new StringChunk(", "));
31022
- }
31023
- }
31024
- result.push(new StringChunk(")"));
31025
- return this.buildQueryFromSourceParams(result, config3);
31026
- }
31027
- if (is(chunk, _SQL)) {
31028
- return this.buildQueryFromSourceParams(chunk.queryChunks, {
31029
- ...config3,
31030
- inlineParams: inlineParams || chunk.shouldInlineParams
31031
- });
31032
- }
31033
- if (is(chunk, Table)) {
31034
- const schemaName = chunk[Table.Symbol.Schema];
31035
- const tableName = chunk[Table.Symbol.Name];
31036
- return {
31037
- sql: schemaName === void 0 || chunk[IsAlias] ? escapeName(tableName) : escapeName(schemaName) + "." + escapeName(tableName),
31038
- params: []
31039
- };
31040
- }
31041
- if (is(chunk, Column)) {
31042
- const columnName = casing.getColumnCasing(chunk);
31043
- if (_config.invokeSource === "indexes") {
31044
- return { sql: escapeName(columnName), params: [] };
31045
- }
31046
- const schemaName = chunk.table[Table.Symbol.Schema];
31047
- return {
31048
- 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),
31049
- params: []
31050
- };
31051
- }
31052
- if (is(chunk, View)) {
31053
- const schemaName = chunk[ViewBaseConfig].schema;
31054
- const viewName = chunk[ViewBaseConfig].name;
31055
- return {
31056
- sql: schemaName === void 0 || chunk[ViewBaseConfig].isAlias ? escapeName(viewName) : escapeName(schemaName) + "." + escapeName(viewName),
31057
- params: []
31058
- };
31059
- }
31060
- if (is(chunk, Param)) {
31061
- if (is(chunk.value, Placeholder)) {
31062
- return { sql: escapeParam(paramStartIndex.value++, chunk), params: [chunk], typings: ["none"] };
31063
- }
31064
- const mappedValue = chunk.value === null ? null : chunk.encoder.mapToDriverValue(chunk.value);
31065
- if (is(mappedValue, _SQL)) {
31066
- return this.buildQueryFromSourceParams([mappedValue], config3);
31067
- }
31068
- if (inlineParams) {
31069
- return { sql: this.mapInlineParam(mappedValue, config3), params: [] };
31070
- }
31071
- let typings = ["none"];
31072
- if (prepareTyping) {
31073
- typings = [prepareTyping(chunk.encoder)];
31074
- }
31075
- return { sql: escapeParam(paramStartIndex.value++, mappedValue), params: [mappedValue], typings };
31076
- }
31077
- if (is(chunk, Placeholder)) {
31078
- return { sql: escapeParam(paramStartIndex.value++, chunk), params: [chunk], typings: ["none"] };
31079
- }
31080
- if (is(chunk, _SQL.Aliased) && chunk.fieldAlias !== void 0) {
31081
- return { sql: escapeName(chunk.fieldAlias), params: [] };
31082
- }
31083
- if (is(chunk, Subquery)) {
31084
- if (chunk._.isWith) {
31085
- return { sql: escapeName(chunk._.alias), params: [] };
31086
- }
31087
- return this.buildQueryFromSourceParams([
31088
- new StringChunk("("),
31089
- chunk._.sql,
31090
- new StringChunk(") "),
31091
- new Name(chunk._.alias)
31092
- ], config3);
31093
- }
31094
- if (isPgEnum(chunk)) {
31095
- if (chunk.schema) {
31096
- return { sql: escapeName(chunk.schema) + "." + escapeName(chunk.enumName), params: [] };
31097
- }
31098
- return { sql: escapeName(chunk.enumName), params: [] };
31099
- }
31100
- if (isSQLWrapper(chunk)) {
31101
- if (chunk.shouldOmitSQLParens?.()) {
31102
- return this.buildQueryFromSourceParams([chunk.getSQL()], config3);
31103
- }
31104
- return this.buildQueryFromSourceParams([
31105
- new StringChunk("("),
31106
- chunk.getSQL(),
31107
- new StringChunk(")")
31108
- ], config3);
31109
- }
31110
- if (inlineParams) {
31111
- return { sql: this.mapInlineParam(chunk, config3), params: [] };
31112
- }
31113
- return { sql: escapeParam(paramStartIndex.value++, chunk), params: [chunk], typings: ["none"] };
31114
- }));
31115
- }
31116
- mapInlineParam(chunk, { escapeString }) {
31117
- if (chunk === null) {
31118
- return "null";
31119
- }
31120
- if (typeof chunk === "number" || typeof chunk === "boolean") {
31121
- return chunk.toString();
31122
- }
31123
- if (typeof chunk === "string") {
31124
- return escapeString(chunk);
31125
- }
31126
- if (typeof chunk === "object") {
31127
- const mappedValueAsString = chunk.toString();
31128
- if (mappedValueAsString === "[object Object]") {
31129
- return escapeString(JSON.stringify(chunk));
31130
- }
31131
- return escapeString(mappedValueAsString);
31132
- }
31133
- throw new Error("Unexpected param value: " + chunk);
31134
- }
31135
- getSQL() {
31136
- return this;
31137
- }
31138
- as(alias) {
31139
- if (alias === void 0) {
31140
- return this;
31141
- }
31142
- return new _SQL.Aliased(this, alias);
31143
- }
31144
- mapWith(decoder) {
31145
- this.decoder = typeof decoder === "function" ? { mapFromDriverValue: decoder } : decoder;
31146
- return this;
31147
- }
31148
- inlineParams() {
31149
- this.shouldInlineParams = true;
31150
- return this;
31151
- }
31152
- /**
31153
- * This method is used to conditionally include a part of the query.
31154
- *
31155
- * @param condition - Condition to check
31156
- * @returns itself if the condition is `true`, otherwise `undefined`
31157
- */
31158
- if(condition) {
31159
- return condition ? this : void 0;
31160
- }
31161
- };
31162
- var Name = class {
31163
- constructor(value) {
31164
- this.value = value;
31165
- }
31166
- static [entityKind] = "Name";
31167
- brand;
31168
- getSQL() {
31169
- return new SQL([this]);
31170
- }
31171
- };
31172
- function isDriverValueEncoder(value) {
31173
- return typeof value === "object" && value !== null && "mapToDriverValue" in value && typeof value.mapToDriverValue === "function";
31174
- }
31175
- var noopDecoder = {
31176
- mapFromDriverValue: (value) => value
31177
- };
31178
- var noopEncoder = {
31179
- mapToDriverValue: (value) => value
31180
- };
31181
- var noopMapper = {
31182
- ...noopDecoder,
31183
- ...noopEncoder
31184
- };
31185
- var Param = class {
31186
- /**
31187
- * @param value - Parameter value
31188
- * @param encoder - Encoder to convert the value to a driver parameter
31189
- */
31190
- constructor(value, encoder = noopEncoder) {
31191
- this.value = value;
31192
- this.encoder = encoder;
31193
- }
31194
- static [entityKind] = "Param";
31195
- brand;
31196
- getSQL() {
31197
- return new SQL([this]);
31198
- }
31199
- };
31200
- function sql(strings, ...params) {
31201
- const queryChunks = [];
31202
- if (params.length > 0 || strings.length > 0 && strings[0] !== "") {
31203
- queryChunks.push(new StringChunk(strings[0]));
31204
- }
31205
- for (const [paramIndex, param2] of params.entries()) {
31206
- queryChunks.push(param2, new StringChunk(strings[paramIndex + 1]));
31207
- }
31208
- return new SQL(queryChunks);
31209
- }
31210
- ((sql2) => {
31211
- function empty() {
31212
- return new SQL([]);
31213
- }
31214
- sql2.empty = empty;
31215
- function fromList(list) {
31216
- return new SQL(list);
31217
- }
31218
- sql2.fromList = fromList;
31219
- function raw2(str2) {
31220
- return new SQL([new StringChunk(str2)]);
31221
- }
31222
- sql2.raw = raw2;
31223
- function join11(chunks, separator) {
31224
- const result = [];
31225
- for (const [i, chunk] of chunks.entries()) {
31226
- if (i > 0 && separator !== void 0) {
31227
- result.push(separator);
31228
- }
31229
- result.push(chunk);
31230
- }
31231
- return new SQL(result);
31232
- }
31233
- sql2.join = join11;
31234
- function identifier(value) {
31235
- return new Name(value);
31236
- }
31237
- sql2.identifier = identifier;
31238
- function placeholder2(name2) {
31239
- return new Placeholder(name2);
31240
- }
31241
- sql2.placeholder = placeholder2;
31242
- function param2(value, encoder) {
31243
- return new Param(value, encoder);
31244
- }
31245
- sql2.param = param2;
31246
- })(sql || (sql = {}));
31247
- ((SQL2) => {
31248
- class Aliased {
31249
- constructor(sql2, fieldAlias) {
31250
- this.sql = sql2;
31251
- this.fieldAlias = fieldAlias;
31252
- }
31253
- static [entityKind] = "SQL.Aliased";
31254
- /** @internal */
31255
- isSelectionField = false;
31256
- getSQL() {
31257
- return this.sql;
31258
- }
31259
- /** @internal */
31260
- clone() {
31261
- return new Aliased(this.sql, this.fieldAlias);
31262
- }
31263
- }
31264
- SQL2.Aliased = Aliased;
31265
- })(SQL || (SQL = {}));
31266
- var Placeholder = class {
31267
- constructor(name2) {
31268
- this.name = name2;
31269
- }
31270
- static [entityKind] = "Placeholder";
31271
- getSQL() {
31272
- return new SQL([this]);
31273
- }
31274
- };
31275
- function fillPlaceholders(params, values) {
31276
- return params.map((p2) => {
31277
- if (is(p2, Placeholder)) {
31278
- if (!(p2.name in values)) {
31279
- throw new Error(`No value for placeholder "${p2.name}" was provided`);
31280
- }
31281
- return values[p2.name];
31282
- }
31283
- if (is(p2, Param) && is(p2.value, Placeholder)) {
31284
- if (!(p2.value.name in values)) {
31285
- throw new Error(`No value for placeholder "${p2.value.name}" was provided`);
31286
- }
31287
- return p2.encoder.mapToDriverValue(values[p2.value.name]);
31288
- }
31289
- return p2;
31290
- });
31291
- }
31292
- var IsDrizzleView = /* @__PURE__ */ Symbol.for("drizzle:IsDrizzleView");
31293
- var View = class {
31294
- static [entityKind] = "View";
31295
- /** @internal */
31296
- [ViewBaseConfig];
31297
- /** @internal */
31298
- [IsDrizzleView] = true;
31299
- constructor({ name: name2, schema, selectedFields, query }) {
31300
- this[ViewBaseConfig] = {
31301
- name: name2,
31302
- originalName: name2,
31303
- schema,
31304
- selectedFields,
31305
- query,
31306
- isExisting: !query,
31307
- isAlias: false
31308
- };
31309
- }
31310
- getSQL() {
31311
- return new SQL([this]);
31312
- }
31313
- };
31314
- Column.prototype.getSQL = function() {
31315
- return new SQL([this]);
31316
- };
31317
- Table.prototype.getSQL = function() {
31318
- return new SQL([this]);
31319
- };
31320
- Subquery.prototype.getSQL = function() {
31321
- return new SQL([this]);
31322
- };
31323
-
31324
- // ../../node_modules/.pnpm/drizzle-orm@0.45.2_@neondatabase+serverless@1.1.0_@opentelemetry+api@1.9.1_@types+pg@8.20.0_kysely@0.28.16_pg@8.22.0/node_modules/drizzle-orm/alias.js
31325
30166
  var ColumnAliasProxyHandler = class {
31326
30167
  constructor(table) {
31327
30168
  this.table = table;
@@ -31522,7 +30363,7 @@ init_esm_shims();
31522
30363
  function mapResultRow(columns, row, joinsNotNullableMap) {
31523
30364
  const nullifyMap = {};
31524
30365
  const result = columns.reduce(
31525
- (result2, { path: path4, field }, columnIndex) => {
30366
+ (result2, { path: path3, field }, columnIndex) => {
31526
30367
  let decoder;
31527
30368
  if (is(field, Column)) {
31528
30369
  decoder = field;
@@ -31534,8 +30375,8 @@ function mapResultRow(columns, row, joinsNotNullableMap) {
31534
30375
  decoder = field.sql.decoder;
31535
30376
  }
31536
30377
  let node = result2;
31537
- for (const [pathChunkIndex, pathChunk] of path4.entries()) {
31538
- if (pathChunkIndex < path4.length - 1) {
30378
+ for (const [pathChunkIndex, pathChunk] of path3.entries()) {
30379
+ if (pathChunkIndex < path3.length - 1) {
31539
30380
  if (!(pathChunk in node)) {
31540
30381
  node[pathChunk] = {};
31541
30382
  }
@@ -31543,8 +30384,8 @@ function mapResultRow(columns, row, joinsNotNullableMap) {
31543
30384
  } else {
31544
30385
  const rawValue = row[columnIndex];
31545
30386
  const value = node[pathChunk] = rawValue === null ? null : decoder.mapFromDriverValue(rawValue);
31546
- if (joinsNotNullableMap && is(field, Column) && path4.length === 2) {
31547
- const objectName = path4[0];
30387
+ if (joinsNotNullableMap && is(field, Column) && path3.length === 2) {
30388
+ const objectName = path3[0];
31548
30389
  if (!(objectName in nullifyMap)) {
31549
30390
  nullifyMap[objectName] = value === null ? getTableName(field.table) : false;
31550
30391
  } else if (typeof nullifyMap[objectName] === "string" && nullifyMap[objectName] !== getTableName(field.table)) {
@@ -33910,7 +32751,7 @@ var PgDialect = class {
33910
32751
  table,
33911
32752
  joins,
33912
32753
  orderBy,
33913
- groupBy: groupBy2,
32754
+ groupBy,
33914
32755
  limit,
33915
32756
  offset,
33916
32757
  lockingClause,
@@ -33944,8 +32785,8 @@ var PgDialect = class {
33944
32785
  orderBySql = sql` order by ${sql.join(orderBy, sql`, `)}`;
33945
32786
  }
33946
32787
  let groupBySql;
33947
- if (groupBy2 && groupBy2.length > 0) {
33948
- groupBySql = sql` group by ${sql.join(groupBy2, sql`, `)}`;
32788
+ if (groupBy && groupBy.length > 0) {
32789
+ groupBySql = sql` group by ${sql.join(groupBy, sql`, `)}`;
33949
32790
  }
33950
32791
  const limitSql = typeof limit === "object" || typeof limit === "number" && limit >= 0 ? sql` limit ${limit}` : void 0;
33951
32792
  const offsetSql = offset ? sql` offset ${offset}` : void 0;
@@ -34912,7 +33753,7 @@ var PgSelectQueryBuilderBase = class extends TypedQueryBuilder {
34912
33753
  const baseTableName = this.tableName;
34913
33754
  const tableName = getTableLikeName(table);
34914
33755
  for (const item of extractUsedTable(table)) this.usedTables.add(item);
34915
- if (typeof tableName === "string" && this.config.joins?.some((join11) => join11.alias === tableName)) {
33756
+ if (typeof tableName === "string" && this.config.joins?.some((join13) => join13.alias === tableName)) {
34916
33757
  throw new Error(`Alias "${tableName}" is already used in this query`);
34917
33758
  }
34918
33759
  if (!this.isPartialSelect) {
@@ -35425,13 +34266,13 @@ var PgSelectQueryBuilderBase = class extends TypedQueryBuilder {
35425
34266
  }
35426
34267
  groupBy(...columns) {
35427
34268
  if (typeof columns[0] === "function") {
35428
- const groupBy2 = columns[0](
34269
+ const groupBy = columns[0](
35429
34270
  new Proxy(
35430
34271
  this.config.fields,
35431
34272
  new SelectionProxyHandler({ sqlAliasedBehavior: "alias", sqlBehavior: "sql" })
35432
34273
  )
35433
34274
  );
35434
- this.config.groupBy = Array.isArray(groupBy2) ? groupBy2 : [groupBy2];
34275
+ this.config.groupBy = Array.isArray(groupBy) ? groupBy : [groupBy];
35435
34276
  } else {
35436
34277
  this.config.groupBy = columns;
35437
34278
  }
@@ -36136,7 +34977,7 @@ var PgUpdateBase = class extends QueryPromise {
36136
34977
  createJoin(joinType) {
36137
34978
  return (table, on) => {
36138
34979
  const tableName = getTableLikeName(table);
36139
- if (typeof tableName === "string" && this.config.joins.some((join11) => join11.alias === tableName)) {
34980
+ if (typeof tableName === "string" && this.config.joins.some((join13) => join13.alias === tableName)) {
36140
34981
  throw new Error(`Alias "${tableName}" is already used in this query`);
36141
34982
  }
36142
34983
  if (typeof on === "function") {
@@ -36232,10 +35073,10 @@ var PgUpdateBase = class extends QueryPromise {
36232
35073
  const fromFields = this.getTableLikeFields(this.config.from);
36233
35074
  fields[tableName] = fromFields;
36234
35075
  }
36235
- for (const join11 of this.config.joins) {
36236
- const tableName2 = getTableLikeName(join11.table);
36237
- if (typeof tableName2 === "string" && !is(join11.table, SQL)) {
36238
- const fromFields = this.getTableLikeFields(join11.table);
35076
+ for (const join13 of this.config.joins) {
35077
+ const tableName2 = getTableLikeName(join13.table);
35078
+ if (typeof tableName2 === "string" && !is(join13.table, SQL)) {
35079
+ const fromFields = this.getTableLikeFields(join13.table);
36239
35080
  fields[tableName2] = fromFields;
36240
35081
  }
36241
35082
  }
@@ -42762,7 +41603,7 @@ function drizzle2(...params) {
42762
41603
  // ../db/dist/index.mjs
42763
41604
  import { execSync, spawnSync } from "child_process";
42764
41605
  import crypto2 from "crypto";
42765
- import path3 from "path";
41606
+ import path2 from "path";
42766
41607
  import fs2 from "fs/promises";
42767
41608
  import { readFileSync as readFileSync2 } from "fs";
42768
41609
  import path22 from "path";
@@ -43249,14 +42090,14 @@ async function seedSystemTables(db, registry2, options = {}) {
43249
42090
  }
43250
42091
  function resolvedPathEnv() {
43251
42092
  const root = process.cwd();
43252
- const localBin = path3.join(root, "node_modules", ".bin");
43253
- const existing = (process.env.PATH ?? "").split(path3.delimiter).filter(Boolean).map((entry) => path3.isAbsolute(entry) ? entry : path3.resolve(root, entry));
43254
- return { ...process.env, PATH: [localBin, ...existing].join(path3.delimiter) };
42093
+ const localBin = path2.join(root, "node_modules", ".bin");
42094
+ const existing = (process.env.PATH ?? "").split(path2.delimiter).filter(Boolean).map((entry) => path2.isAbsolute(entry) ? entry : path2.resolve(root, entry));
42095
+ return { ...process.env, PATH: [localBin, ...existing].join(path2.delimiter) };
43255
42096
  }
43256
42097
  async function runDevMigration(configPath) {
43257
42098
  execSync(`drizzle-kit push --config=${configPath}`, {
43258
42099
  stdio: "inherit",
43259
- cwd: path3.dirname(configPath),
42100
+ cwd: path2.dirname(configPath),
43260
42101
  env: resolvedPathEnv()
43261
42102
  });
43262
42103
  }
@@ -43269,7 +42110,7 @@ async function generateMigration(configPath, migrationsFolder) {
43269
42110
  }
43270
42111
  execSync(`drizzle-kit generate --config=${configPath}`, {
43271
42112
  stdio: "inherit",
43272
- cwd: path3.dirname(configPath),
42113
+ cwd: path2.dirname(configPath),
43273
42114
  env: resolvedPathEnv()
43274
42115
  });
43275
42116
  let afterFiles = [];
@@ -43295,13 +42136,13 @@ async function applyMigrations(configPath, db, options) {
43295
42136
  if (statusBefore.pending.length > 0) {
43296
42137
  let journalEntries = [];
43297
42138
  try {
43298
- const journalPath = path3.join(migrationsFolder, "meta", "_journal.json");
42139
+ const journalPath = path2.join(migrationsFolder, "meta", "_journal.json");
43299
42140
  const raw2 = await fs2.readFile(journalPath, "utf-8");
43300
42141
  journalEntries = JSON.parse(raw2).entries;
43301
42142
  } catch {
43302
42143
  }
43303
42144
  for (const pendingFile of statusBefore.pending) {
43304
- const sqlPath = path3.join(migrationsFolder, pendingFile);
42145
+ const sqlPath = path2.join(migrationsFolder, pendingFile);
43305
42146
  let sqlContent;
43306
42147
  try {
43307
42148
  sqlContent = await fs2.readFile(sqlPath, "utf-8");
@@ -43334,7 +42175,7 @@ async function applyMigrations(configPath, db, options) {
43334
42175
  "drizzle-kit",
43335
42176
  ["migrate", `--config=${configPath}`],
43336
42177
  {
43337
- cwd: path3.dirname(configPath),
42178
+ cwd: path2.dirname(configPath),
43338
42179
  // inherit lets drizzle-kit write its spinner and errors directly to the
43339
42180
  // terminal in real time — capturing stdout/stderr swallows ANSI overwrites
43340
42181
  // and hides the actual error message.
@@ -43360,7 +42201,7 @@ async function getMigrationStatus(db, options) {
43360
42201
  const { migrationsTable, migrationsFolder } = options;
43361
42202
  let journalEntries;
43362
42203
  try {
43363
- const journalPath = path3.join(migrationsFolder, "meta", "_journal.json");
42204
+ const journalPath = path2.join(migrationsFolder, "meta", "_journal.json");
43364
42205
  const raw2 = await fs2.readFile(journalPath, "utf-8");
43365
42206
  const journal = JSON.parse(raw2);
43366
42207
  journalEntries = journal.entries;
@@ -44162,7 +43003,8 @@ var COMPONENT_NAME = {
44162
43003
  "file-upload": "MediaUpload",
44163
43004
  select: "EnumSelect",
44164
43005
  "typeahead-select": "ReferenceSelect",
44165
- "paragraph-embed": "ParagraphEmbed"
43006
+ "paragraph-embed": "ParagraphEmbed",
43007
+ "computed-display": "ComputedDisplay"
44166
43008
  };
44167
43009
  var COMPONENT_IMPORT = {
44168
43010
  TextInput: `${ADMIN_PKG}/src/components/fields/TextInput.vue`,
@@ -44173,7 +43015,8 @@ var COMPONENT_IMPORT = {
44173
43015
  MediaUpload: `${ADMIN_PKG}/src/components/fields/MediaUpload.vue`,
44174
43016
  EnumSelect: `${ADMIN_PKG}/src/components/fields/EnumSelect.vue`,
44175
43017
  ReferenceSelect: `${ADMIN_PKG}/src/components/fields/ReferenceSelect.vue`,
44176
- ParagraphEmbed: `${ADMIN_PKG}/src/components/fields/ParagraphEmbed.vue`
43018
+ ParagraphEmbed: `${ADMIN_PKG}/src/components/fields/ParagraphEmbed.vue`,
43019
+ ComputedDisplay: `${ADMIN_PKG}/src/components/fields/ComputedDisplay.vue`
44177
43020
  };
44178
43021
  function esc2(s) {
44179
43022
  return s.replace(/\\/g, "\\\\").replace(/'/g, "\\'");
@@ -44220,6 +43063,9 @@ function renderField(field, indent) {
44220
43063
  const compName = COMPONENT_NAME[field.ui_component.component];
44221
43064
  const fieldObj = buildFieldObject(field);
44222
43065
  const attr = indent + " ";
43066
+ if (field.ui_component.component === "computed-display") {
43067
+ return [`${indent}<${compName}`, `${attr}:field="${fieldObj}"`, `${indent}/>`].join("\n");
43068
+ }
44223
43069
  const lines = [`${indent}<${compName}`];
44224
43070
  lines.push(`${attr}:field="${fieldObj}"`);
44225
43071
  if (field.ui_component.component === "paragraph-embed") {
@@ -44327,6 +43173,7 @@ async function generateServerEntries(options, targetDir) {
44327
43173
  function appSetup() {
44328
43174
  return `import config from '../../manguito.config.js'
44329
43175
  import { schemaRegistry } from './schema-registry.js'
43176
+ import { programmaticResolvers } from './programmatic-registry.js'
44330
43177
  import { createCmsApp } from '@bobbykim/manguito-cms-api'
44331
43178
  import { createPostgresAdapter } from '@bobbykim/manguito-cms-db'
44332
43179
 
@@ -44339,8 +43186,10 @@ const { app } = createCmsApp({
44339
43186
  db: dbAdapter.getDb(),
44340
43187
  storage: config.storage,
44341
43188
  prefix: config.api.prefix,
43189
+ resolvers: programmaticResolvers,
44342
43190
  ...(config.api.media ? { media: config.api.media } : {}),
44343
43191
  ...(config.api.rateLimit ? { rateLimit: config.api.rateLimit } : {}),
43192
+ ...(config.api.graphql ? { graphql: config.api.graphql } : {}),
44344
43193
  ...(config.server.cors ? { cors: config.server.cors } : {}),
44345
43194
  })`;
44346
43195
  }
@@ -44499,6 +43348,34 @@ export default handle(app)
44499
43348
  `;
44500
43349
  }
44501
43350
 
43351
+ // src/codegen/programmatic-registry.ts
43352
+ init_esm_shims();
43353
+ import { writeFile as writeFile5 } from "fs/promises";
43354
+ import { join as join6, relative } from "path";
43355
+ function importSpecifier(targetDir, file2) {
43356
+ let rel = relative(targetDir, file2).replace(/\\/g, "/");
43357
+ if (!rel.startsWith(".")) rel = `./${rel}`;
43358
+ return rel.replace(/\.ts$/, ".js");
43359
+ }
43360
+ async function generateProgrammaticRegistry(files, targetDir) {
43361
+ const sorted = [...files].sort();
43362
+ const imports = sorted.map((file2, i) => `import def${i} from '${importSpecifier(targetDir, file2)}'`).join("\n");
43363
+ const defs = sorted.map((_f, i) => `def${i}`);
43364
+ const entries = defs.map((d2) => ` [\`\${${d2}.schema}::\${${d2}.field}\`, ${d2}] as const`).join(",\n");
43365
+ const typeImport = "import type { ProgrammaticFieldDefinition } from '@bobbykim/manguito-cms-core'";
43366
+ const body = sorted.length === 0 ? `${typeImport}
43367
+
43368
+ export const programmaticResolvers = new Map<string, ProgrammaticFieldDefinition>()
43369
+ ` : `${typeImport}
43370
+ ${imports}
43371
+
43372
+ export const programmaticResolvers = new Map<string, ProgrammaticFieldDefinition>([
43373
+ ${entries},
43374
+ ])
43375
+ `;
43376
+ await writeFile5(join6(targetDir, "programmatic-registry.ts"), body, "utf8");
43377
+ }
43378
+
44502
43379
  // src/utils/config.ts
44503
43380
  init_esm_shims();
44504
43381
  import { existsSync } from "fs";
@@ -44676,10 +43553,13 @@ async function runBuild(options, deps) {
44676
43553
  );
44677
43554
  const generatedDir = resolve3(cwd, "dist/generated");
44678
43555
  mkdirSync(generatedDir, { recursive: true });
44679
- writeFileSync(join6(generatedDir, "schema.ts"), generateSchemaFile(registry2), "utf8");
43556
+ writeFileSync(join7(generatedDir, "schema.ts"), generateSchemaFile(registry2), "utf8");
44680
43557
  await generateSchemaRegistry(registry2, generatedDir);
44681
43558
  await generateRoutes2(registry2, generatedDir);
44682
- await generateForms(registry2, join6(generatedDir, "forms"));
43559
+ await generateForms(registry2, join7(generatedDir, "forms"));
43560
+ const programmaticDir = resolve3(cwd, config3.programmatic.dir);
43561
+ const resolverFiles = existsSync3(programmaticDir) ? walkFiles(programmaticDir).filter((f) => /\.(ts|mjs|js)$/.test(f)) : [];
43562
+ await generateProgrammaticRegistry(resolverFiles, generatedDir);
44683
43563
  await generateServerEntries(
44684
43564
  { adminPrefix: config3.admin.prefix, apiPrefix: config3.api.prefix },
44685
43565
  generatedDir
@@ -44743,14 +43623,14 @@ async function needsRebuild(cwd) {
44743
43623
  );
44744
43624
  }
44745
43625
  function resolveAdminRoot(cwd) {
44746
- const cwdRequire = createRequire(join6(cwd, "package.json"));
43626
+ const cwdRequire = createRequire(join7(cwd, "package.json"));
44747
43627
  const adminPkgJson = cwdRequire.resolve("@bobbykim/manguito-cms-admin/package.json");
44748
43628
  return dirname(adminPkgJson);
44749
43629
  }
44750
43630
  function walkFiles(dir) {
44751
43631
  const files = [];
44752
43632
  for (const entry of readdirSync2(dir, { withFileTypes: true })) {
44753
- const full = join6(dir, entry.name);
43633
+ const full = join7(dir, entry.name);
44754
43634
  if (entry.isDirectory()) {
44755
43635
  files.push(...walkFiles(full));
44756
43636
  } else {
@@ -44763,8 +43643,9 @@ function walkFiles(dir) {
44763
43643
  // src/commands/dev.ts
44764
43644
  init_esm_shims();
44765
43645
  import { createServer as createHttpServer } from "http";
44766
- import { resolve as resolve5, join as join9, dirname as dirname2, extname as extname2 } from "path";
44767
- import { mkdir as mkdir2, writeFile as writeFile7, watch, readFile } from "fs/promises";
43646
+ import { existsSync as existsSync5 } from "fs";
43647
+ import { resolve as resolve6, join as join11, dirname as dirname2, extname as extname3 } from "path";
43648
+ import { mkdir as mkdir2, writeFile as writeFile8, watch, readFile } from "fs/promises";
44768
43649
  import { createRequire as createRequire2 } from "module";
44769
43650
  import { createServer as createViteServer, searchForWorkspaceRoot } from "vite";
44770
43651
 
@@ -44940,26 +43821,26 @@ var handleParsingNestedValues = (form, key, value) => {
44940
43821
 
44941
43822
  // ../../node_modules/.pnpm/hono@4.12.28/node_modules/hono/dist/utils/url.js
44942
43823
  init_esm_shims();
44943
- var splitPath = (path4) => {
44944
- const paths = path4.split("/");
43824
+ var splitPath = (path3) => {
43825
+ const paths = path3.split("/");
44945
43826
  if (paths[0] === "") {
44946
43827
  paths.shift();
44947
43828
  }
44948
43829
  return paths;
44949
43830
  };
44950
43831
  var splitRoutingPath = (routePath) => {
44951
- const { groups, path: path4 } = extractGroupsFromPath(routePath);
44952
- const paths = splitPath(path4);
43832
+ const { groups, path: path3 } = extractGroupsFromPath(routePath);
43833
+ const paths = splitPath(path3);
44953
43834
  return replaceGroupMarks(paths, groups);
44954
43835
  };
44955
- var extractGroupsFromPath = (path4) => {
43836
+ var extractGroupsFromPath = (path3) => {
44956
43837
  const groups = [];
44957
- path4 = path4.replace(/\{[^}]+\}/g, (match2, index) => {
43838
+ path3 = path3.replace(/\{[^}]+\}/g, (match2, index) => {
44958
43839
  const mark = `@${index}`;
44959
43840
  groups.push([mark, match2]);
44960
43841
  return mark;
44961
43842
  });
44962
- return { groups, path: path4 };
43843
+ return { groups, path: path3 };
44963
43844
  };
44964
43845
  var replaceGroupMarks = (paths, groups) => {
44965
43846
  for (let i = groups.length - 1; i >= 0; i--) {
@@ -45016,8 +43897,8 @@ var getPath = (request) => {
45016
43897
  const queryIndex = url2.indexOf("?", i);
45017
43898
  const hashIndex = url2.indexOf("#", i);
45018
43899
  const end = queryIndex === -1 ? hashIndex === -1 ? void 0 : hashIndex : hashIndex === -1 ? queryIndex : Math.min(queryIndex, hashIndex);
45019
- const path4 = url2.slice(start, end);
45020
- return tryDecodeURI(path4.includes("%25") ? path4.replace(/%25/g, "%2525") : path4);
43900
+ const path3 = url2.slice(start, end);
43901
+ return tryDecodeURI(path3.includes("%25") ? path3.replace(/%25/g, "%2525") : path3);
45021
43902
  } else if (charCode === 63 || charCode === 35) {
45022
43903
  break;
45023
43904
  }
@@ -45034,11 +43915,11 @@ var mergePath = (base, sub, ...rest) => {
45034
43915
  }
45035
43916
  return `${base?.[0] === "/" ? "" : "/"}${base}${sub === "/" ? "" : `${base?.at(-1) === "/" ? "" : "/"}${sub?.[0] === "/" ? sub.slice(1) : sub}`}`;
45036
43917
  };
45037
- var checkOptionalParameter = (path4) => {
45038
- if (path4.charCodeAt(path4.length - 1) !== 63 || !path4.includes(":")) {
43918
+ var checkOptionalParameter = (path3) => {
43919
+ if (path3.charCodeAt(path3.length - 1) !== 63 || !path3.includes(":")) {
45039
43920
  return null;
45040
43921
  }
45041
- const segments = path4.split("/");
43922
+ const segments = path3.split("/");
45042
43923
  const results = [];
45043
43924
  let basePath = "";
45044
43925
  segments.forEach((segment) => {
@@ -45179,9 +44060,9 @@ var HonoRequest = class {
45179
44060
  */
45180
44061
  path;
45181
44062
  bodyCache = {};
45182
- constructor(request, path4 = "/", matchResult = [[]]) {
44063
+ constructor(request, path3 = "/", matchResult = [[]]) {
45183
44064
  this.raw = request;
45184
- this.path = path4;
44065
+ this.path = path3;
45185
44066
  this.#matchResult = matchResult;
45186
44067
  this.#validatedData = {};
45187
44068
  }
@@ -45936,8 +44817,8 @@ var Hono = class _Hono {
45936
44817
  return this;
45937
44818
  };
45938
44819
  });
45939
- this.on = (method, path4, ...handlers) => {
45940
- for (const p2 of [path4].flat()) {
44820
+ this.on = (method, path3, ...handlers) => {
44821
+ for (const p2 of [path3].flat()) {
45941
44822
  this.#path = p2;
45942
44823
  for (const m2 of [method].flat()) {
45943
44824
  handlers.map((handler) => {
@@ -45994,8 +44875,8 @@ var Hono = class _Hono {
45994
44875
  * app.route("/api", app2) // GET /api/user
45995
44876
  * ```
45996
44877
  */
45997
- route(path4, app) {
45998
- const subApp = this.basePath(path4);
44878
+ route(path3, app) {
44879
+ const subApp = this.basePath(path3);
45999
44880
  app.routes.map((r) => {
46000
44881
  let handler;
46001
44882
  if (app.errorHandler === errorHandler) {
@@ -46021,9 +44902,9 @@ var Hono = class _Hono {
46021
44902
  * const api = new Hono().basePath('/api')
46022
44903
  * ```
46023
44904
  */
46024
- basePath(path4) {
44905
+ basePath(path3) {
46025
44906
  const subApp = this.#clone();
46026
- subApp._basePath = mergePath(this._basePath, path4);
44907
+ subApp._basePath = mergePath(this._basePath, path3);
46027
44908
  return subApp;
46028
44909
  }
46029
44910
  /**
@@ -46097,7 +44978,7 @@ var Hono = class _Hono {
46097
44978
  * })
46098
44979
  * ```
46099
44980
  */
46100
- mount(path4, applicationHandler, options) {
44981
+ mount(path3, applicationHandler, options) {
46101
44982
  let replaceRequest;
46102
44983
  let optionHandler;
46103
44984
  if (options) {
@@ -46124,7 +45005,7 @@ var Hono = class _Hono {
46124
45005
  return [c.env, executionContext];
46125
45006
  };
46126
45007
  replaceRequest ||= (() => {
46127
- const mergedPath = mergePath(this._basePath, path4);
45008
+ const mergedPath = mergePath(this._basePath, path3);
46128
45009
  const pathPrefixLength = mergedPath === "/" ? 0 : mergedPath.length;
46129
45010
  return (request) => {
46130
45011
  const url2 = new URL(request.url);
@@ -46139,19 +45020,19 @@ var Hono = class _Hono {
46139
45020
  }
46140
45021
  await next();
46141
45022
  };
46142
- this.#addRoute(METHOD_NAME_ALL, mergePath(path4, "*"), handler);
45023
+ this.#addRoute(METHOD_NAME_ALL, mergePath(path3, "*"), handler);
46143
45024
  return this;
46144
45025
  }
46145
- #addRoute(method, path4, handler, baseRoutePath) {
45026
+ #addRoute(method, path3, handler, baseRoutePath) {
46146
45027
  method = method.toUpperCase();
46147
- path4 = mergePath(this._basePath, path4);
45028
+ path3 = mergePath(this._basePath, path3);
46148
45029
  const r = {
46149
45030
  basePath: baseRoutePath !== void 0 ? mergePath(this._basePath, baseRoutePath) : this._basePath,
46150
- path: path4,
45031
+ path: path3,
46151
45032
  method,
46152
45033
  handler
46153
45034
  };
46154
- this.router.add(method, path4, [handler, r]);
45035
+ this.router.add(method, path3, [handler, r]);
46155
45036
  this.routes.push(r);
46156
45037
  }
46157
45038
  #handleError(err, c) {
@@ -46164,10 +45045,10 @@ var Hono = class _Hono {
46164
45045
  if (method === "HEAD") {
46165
45046
  return (async () => new Response(null, await this.#dispatch(request, executionCtx, env, "GET")))();
46166
45047
  }
46167
- const path4 = this.getPath(request, { env });
46168
- const matchResult = this.router.match(method, path4);
45048
+ const path3 = this.getPath(request, { env });
45049
+ const matchResult = this.router.match(method, path3);
46169
45050
  const c = new Context(request, {
46170
- path: path4,
45051
+ path: path3,
46171
45052
  matchResult,
46172
45053
  env,
46173
45054
  executionCtx,
@@ -46274,7 +45155,7 @@ init_esm_shims();
46274
45155
  // ../../node_modules/.pnpm/hono@4.12.28/node_modules/hono/dist/router/reg-exp-router/matcher.js
46275
45156
  init_esm_shims();
46276
45157
  var emptyParam = [];
46277
- function match(method, path4) {
45158
+ function match(method, path3) {
46278
45159
  const matchers = this.buildAllMatchers();
46279
45160
  const match2 = ((method2, path23) => {
46280
45161
  const matcher = matchers[method2] || matchers[METHOD_NAME_ALL];
@@ -46290,7 +45171,7 @@ function match(method, path4) {
46290
45171
  return [matcher[1][index], match3];
46291
45172
  });
46292
45173
  this.match = match2;
46293
- return match2(method, path4);
45174
+ return match2(method, path3);
46294
45175
  }
46295
45176
 
46296
45177
  // ../../node_modules/.pnpm/hono@4.12.28/node_modules/hono/dist/router/reg-exp-router/node.js
@@ -46407,12 +45288,12 @@ init_esm_shims();
46407
45288
  var Trie = class {
46408
45289
  #context = { varIndex: 0 };
46409
45290
  #root = new Node();
46410
- insert(path4, index, pathErrorCheckOnly) {
45291
+ insert(path3, index, pathErrorCheckOnly) {
46411
45292
  const paramAssoc = [];
46412
45293
  const groups = [];
46413
45294
  for (let i = 0; ; ) {
46414
45295
  let replaced = false;
46415
- path4 = path4.replace(/\{[^}]+\}/g, (m2) => {
45296
+ path3 = path3.replace(/\{[^}]+\}/g, (m2) => {
46416
45297
  const mark = `@\\${i}`;
46417
45298
  groups[i] = [mark, m2];
46418
45299
  i++;
@@ -46423,7 +45304,7 @@ var Trie = class {
46423
45304
  break;
46424
45305
  }
46425
45306
  }
46426
- const tokens = path4.match(/(?::[^\/]+)|(?:\/\*$)|./g) || [];
45307
+ const tokens = path3.match(/(?::[^\/]+)|(?:\/\*$)|./g) || [];
46427
45308
  for (let i = groups.length - 1; i >= 0; i--) {
46428
45309
  const [mark] = groups[i];
46429
45310
  for (let j = tokens.length - 1; j >= 0; j--) {
@@ -46462,9 +45343,9 @@ var Trie = class {
46462
45343
  // ../../node_modules/.pnpm/hono@4.12.28/node_modules/hono/dist/router/reg-exp-router/router.js
46463
45344
  var nullMatcher = [/^$/, [], /* @__PURE__ */ Object.create(null)];
46464
45345
  var wildcardRegExpCache = /* @__PURE__ */ Object.create(null);
46465
- function buildWildcardRegExp(path4) {
46466
- return wildcardRegExpCache[path4] ??= new RegExp(
46467
- path4 === "*" ? "" : `^${path4.replace(
45346
+ function buildWildcardRegExp(path3) {
45347
+ return wildcardRegExpCache[path3] ??= new RegExp(
45348
+ path3 === "*" ? "" : `^${path3.replace(
46468
45349
  /\/\*$|([.\\+*[^\]$()])/g,
46469
45350
  (_, metaChar) => metaChar ? `\\${metaChar}` : "(?:|/.*)"
46470
45351
  )}$`
@@ -46486,17 +45367,17 @@ function buildMatcherFromPreprocessedRoutes(routes) {
46486
45367
  );
46487
45368
  const staticMap = /* @__PURE__ */ Object.create(null);
46488
45369
  for (let i = 0, j = -1, len = routesWithStaticPathFlag.length; i < len; i++) {
46489
- const [pathErrorCheckOnly, path4, handlers] = routesWithStaticPathFlag[i];
45370
+ const [pathErrorCheckOnly, path3, handlers] = routesWithStaticPathFlag[i];
46490
45371
  if (pathErrorCheckOnly) {
46491
- staticMap[path4] = [handlers.map(([h]) => [h, /* @__PURE__ */ Object.create(null)]), emptyParam];
45372
+ staticMap[path3] = [handlers.map(([h]) => [h, /* @__PURE__ */ Object.create(null)]), emptyParam];
46492
45373
  } else {
46493
45374
  j++;
46494
45375
  }
46495
45376
  let paramAssoc;
46496
45377
  try {
46497
- paramAssoc = trie.insert(path4, j, pathErrorCheckOnly);
45378
+ paramAssoc = trie.insert(path3, j, pathErrorCheckOnly);
46498
45379
  } catch (e) {
46499
- throw e === PATH_ERROR ? new UnsupportedPathError(path4) : e;
45380
+ throw e === PATH_ERROR ? new UnsupportedPathError(path3) : e;
46500
45381
  }
46501
45382
  if (pathErrorCheckOnly) {
46502
45383
  continue;
@@ -46530,12 +45411,12 @@ function buildMatcherFromPreprocessedRoutes(routes) {
46530
45411
  }
46531
45412
  return [regexp, handlerMap, staticMap];
46532
45413
  }
46533
- function findMiddleware(middleware, path4) {
45414
+ function findMiddleware(middleware, path3) {
46534
45415
  if (!middleware) {
46535
45416
  return void 0;
46536
45417
  }
46537
45418
  for (const k of Object.keys(middleware).sort((a2, b2) => b2.length - a2.length)) {
46538
- if (buildWildcardRegExp(k).test(path4)) {
45419
+ if (buildWildcardRegExp(k).test(path3)) {
46539
45420
  return [...middleware[k]];
46540
45421
  }
46541
45422
  }
@@ -46549,7 +45430,7 @@ var RegExpRouter = class {
46549
45430
  this.#middleware = { [METHOD_NAME_ALL]: /* @__PURE__ */ Object.create(null) };
46550
45431
  this.#routes = { [METHOD_NAME_ALL]: /* @__PURE__ */ Object.create(null) };
46551
45432
  }
46552
- add(method, path4, handler) {
45433
+ add(method, path3, handler) {
46553
45434
  const middleware = this.#middleware;
46554
45435
  const routes = this.#routes;
46555
45436
  if (!middleware || !routes) {
@@ -46564,18 +45445,18 @@ var RegExpRouter = class {
46564
45445
  });
46565
45446
  });
46566
45447
  }
46567
- if (path4 === "/*") {
46568
- path4 = "*";
45448
+ if (path3 === "/*") {
45449
+ path3 = "*";
46569
45450
  }
46570
- const paramCount = (path4.match(/\/:/g) || []).length;
46571
- if (/\*$/.test(path4)) {
46572
- const re = buildWildcardRegExp(path4);
45451
+ const paramCount = (path3.match(/\/:/g) || []).length;
45452
+ if (/\*$/.test(path3)) {
45453
+ const re = buildWildcardRegExp(path3);
46573
45454
  if (method === METHOD_NAME_ALL) {
46574
45455
  Object.keys(middleware).forEach((m2) => {
46575
- middleware[m2][path4] ||= findMiddleware(middleware[m2], path4) || findMiddleware(middleware[METHOD_NAME_ALL], path4) || [];
45456
+ middleware[m2][path3] ||= findMiddleware(middleware[m2], path3) || findMiddleware(middleware[METHOD_NAME_ALL], path3) || [];
46576
45457
  });
46577
45458
  } else {
46578
- middleware[method][path4] ||= findMiddleware(middleware[method], path4) || findMiddleware(middleware[METHOD_NAME_ALL], path4) || [];
45459
+ middleware[method][path3] ||= findMiddleware(middleware[method], path3) || findMiddleware(middleware[METHOD_NAME_ALL], path3) || [];
46579
45460
  }
46580
45461
  Object.keys(middleware).forEach((m2) => {
46581
45462
  if (method === METHOD_NAME_ALL || method === m2) {
@@ -46593,7 +45474,7 @@ var RegExpRouter = class {
46593
45474
  });
46594
45475
  return;
46595
45476
  }
46596
- const paths = checkOptionalParameter(path4) || [path4];
45477
+ const paths = checkOptionalParameter(path3) || [path3];
46597
45478
  for (let i = 0, len = paths.length; i < len; i++) {
46598
45479
  const path23 = paths[i];
46599
45480
  Object.keys(routes).forEach((m2) => {
@@ -46620,13 +45501,13 @@ var RegExpRouter = class {
46620
45501
  const routes = [];
46621
45502
  let hasOwnRoute = method === METHOD_NAME_ALL;
46622
45503
  [this.#middleware, this.#routes].forEach((r) => {
46623
- const ownRoute = r[method] ? Object.keys(r[method]).map((path4) => [path4, r[method][path4]]) : [];
45504
+ const ownRoute = r[method] ? Object.keys(r[method]).map((path3) => [path3, r[method][path3]]) : [];
46624
45505
  if (ownRoute.length !== 0) {
46625
45506
  hasOwnRoute ||= true;
46626
45507
  routes.push(...ownRoute);
46627
45508
  } else if (method !== METHOD_NAME_ALL) {
46628
45509
  routes.push(
46629
- ...Object.keys(r[METHOD_NAME_ALL]).map((path4) => [path4, r[METHOD_NAME_ALL][path4]])
45510
+ ...Object.keys(r[METHOD_NAME_ALL]).map((path3) => [path3, r[METHOD_NAME_ALL][path3]])
46630
45511
  );
46631
45512
  }
46632
45513
  });
@@ -46653,13 +45534,13 @@ var SmartRouter = class {
46653
45534
  constructor(init) {
46654
45535
  this.#routers = init.routers;
46655
45536
  }
46656
- add(method, path4, handler) {
45537
+ add(method, path3, handler) {
46657
45538
  if (!this.#routes) {
46658
45539
  throw new Error(MESSAGE_MATCHER_IS_ALREADY_BUILT);
46659
45540
  }
46660
- this.#routes.push([method, path4, handler]);
45541
+ this.#routes.push([method, path3, handler]);
46661
45542
  }
46662
- match(method, path4) {
45543
+ match(method, path3) {
46663
45544
  if (!this.#routes) {
46664
45545
  throw new Error("Fatal error");
46665
45546
  }
@@ -46674,7 +45555,7 @@ var SmartRouter = class {
46674
45555
  for (let i2 = 0, len2 = routes.length; i2 < len2; i2++) {
46675
45556
  router.add(...routes[i2]);
46676
45557
  }
46677
- res = router.match(method, path4);
45558
+ res = router.match(method, path3);
46678
45559
  } catch (e) {
46679
45560
  if (e instanceof UnsupportedPathError) {
46680
45561
  continue;
@@ -46731,10 +45612,10 @@ var Node2 = class _Node2 {
46731
45612
  }
46732
45613
  this.#patterns = [];
46733
45614
  }
46734
- insert(method, path4, handler) {
45615
+ insert(method, path3, handler) {
46735
45616
  this.#order = ++this.#order;
46736
45617
  let curNode = this;
46737
- const parts = splitRoutingPath(path4);
45618
+ const parts = splitRoutingPath(path3);
46738
45619
  const possibleKeys = [];
46739
45620
  for (let i = 0, len = parts.length; i < len; i++) {
46740
45621
  const p2 = parts[i];
@@ -46783,12 +45664,12 @@ var Node2 = class _Node2 {
46783
45664
  }
46784
45665
  }
46785
45666
  }
46786
- search(method, path4) {
45667
+ search(method, path3) {
46787
45668
  const handlerSets = [];
46788
45669
  this.#params = emptyParams;
46789
45670
  const curNode = this;
46790
45671
  let curNodes = [curNode];
46791
- const parts = splitPath(path4);
45672
+ const parts = splitPath(path3);
46792
45673
  const curNodesQueue = [];
46793
45674
  const len = parts.length;
46794
45675
  let partOffsets = null;
@@ -46830,13 +45711,13 @@ var Node2 = class _Node2 {
46830
45711
  if (matcher instanceof RegExp) {
46831
45712
  if (partOffsets === null) {
46832
45713
  partOffsets = new Array(len);
46833
- let offset = path4[0] === "/" ? 1 : 0;
45714
+ let offset = path3[0] === "/" ? 1 : 0;
46834
45715
  for (let p2 = 0; p2 < len; p2++) {
46835
45716
  partOffsets[p2] = offset;
46836
45717
  offset += parts[p2].length + 1;
46837
45718
  }
46838
45719
  }
46839
- const restPathString = path4.substring(partOffsets[i]);
45720
+ const restPathString = path3.substring(partOffsets[i]);
46840
45721
  const m2 = matcher.exec(restPathString);
46841
45722
  if (m2) {
46842
45723
  params[name] = m2[0];
@@ -46889,18 +45770,18 @@ var TrieRouter = class {
46889
45770
  constructor() {
46890
45771
  this.#node = new Node2();
46891
45772
  }
46892
- add(method, path4, handler) {
46893
- const results = checkOptionalParameter(path4);
45773
+ add(method, path3, handler) {
45774
+ const results = checkOptionalParameter(path3);
46894
45775
  if (results) {
46895
45776
  for (let i = 0, len = results.length; i < len; i++) {
46896
45777
  this.#node.insert(method, results[i], handler);
46897
45778
  }
46898
45779
  return;
46899
45780
  }
46900
- this.#node.insert(method, path4, handler);
45781
+ this.#node.insert(method, path3, handler);
46901
45782
  }
46902
- match(method, path4) {
46903
- return this.#node.search(method, path4);
45783
+ match(method, path3) {
45784
+ return this.#node.search(method, path3);
46904
45785
  }
46905
45786
  };
46906
45787
 
@@ -47673,10 +46554,9 @@ var decode4 = Jwt.decode;
47673
46554
  var sign2 = Jwt.sign;
47674
46555
 
47675
46556
  // ../api/dist/index.mjs
47676
- import crypto3 from "crypto";
47677
46557
  import { randomBytes } from "crypto";
46558
+ import crypto3 from "crypto";
47678
46559
  import crypto22 from "crypto";
47679
- import crypto32 from "crypto";
47680
46560
  function createCorsMiddleware(corsConfig) {
47681
46561
  const allowList = Array.isArray(corsConfig.origin) ? corsConfig.origin : [corsConfig.origin];
47682
46562
  const wildcard = allowList.includes("*");
@@ -47703,26 +46583,43 @@ function createCorsMiddleware(corsConfig) {
47703
46583
  return next();
47704
46584
  };
47705
46585
  }
46586
+ var GRAPHIQL_CDN = "https://unpkg.com";
47706
46587
  function createSecurityHeadersMiddleware(options = {}) {
47707
46588
  const connectSrc = ["'self'", ...options.connectSrc ?? []].join(" ");
47708
- const csp = [
47709
- "default-src 'self'",
47710
- "img-src 'self' data: https:",
47711
- "media-src 'self' https:",
47712
- "style-src 'self' 'unsafe-inline'",
47713
- "script-src 'self'",
47714
- "font-src 'self' data:",
47715
- `connect-src ${connectSrc}`,
47716
- "frame-ancestors 'none'",
47717
- "base-uri 'self'",
47718
- "form-action 'self'"
47719
- ].join("; ");
46589
+ function buildCsp(parts) {
46590
+ return [
46591
+ "default-src 'self'",
46592
+ "img-src 'self' data: https:",
46593
+ "media-src 'self' https:",
46594
+ `style-src ${parts.styleSrc}`,
46595
+ `script-src ${parts.scriptSrc}`,
46596
+ "font-src 'self' data:",
46597
+ `connect-src ${parts.connectSrc}`,
46598
+ ...parts.workerSrc ? [`worker-src ${parts.workerSrc}`] : [],
46599
+ "frame-ancestors 'none'",
46600
+ "base-uri 'self'",
46601
+ "form-action 'self'"
46602
+ ].join("; ");
46603
+ }
46604
+ const csp = buildCsp({
46605
+ scriptSrc: "'self'",
46606
+ styleSrc: "'self' 'unsafe-inline'",
46607
+ connectSrc
46608
+ });
46609
+ const graphiqlCsp = buildCsp({
46610
+ scriptSrc: `'self' 'unsafe-inline' ${GRAPHIQL_CDN}`,
46611
+ styleSrc: `'self' 'unsafe-inline' ${GRAPHIQL_CDN}`,
46612
+ connectSrc: `${connectSrc} ${GRAPHIQL_CDN}`,
46613
+ workerSrc: "'self' blob:"
46614
+ });
46615
+ const graphiqlPath = options.graphiqlPath;
47720
46616
  return async function securityHeaders(c, next) {
47721
46617
  await next();
47722
46618
  c.res.headers.set("X-Content-Type-Options", "nosniff");
47723
46619
  c.res.headers.set("X-Frame-Options", "DENY");
47724
46620
  c.res.headers.set("Referrer-Policy", "no-referrer");
47725
- c.res.headers.set("Content-Security-Policy", csp);
46621
+ const isGraphiql = graphiqlPath !== void 0 && c.req.path === graphiqlPath;
46622
+ c.res.headers.set("Content-Security-Policy", isGraphiql ? graphiqlCsp : csp);
47726
46623
  };
47727
46624
  }
47728
46625
  var ERROR_STATUS_MAP = {
@@ -47797,8 +46694,8 @@ function setAuthCookie(c, name, token, options) {
47797
46694
  sameSite: "Strict"
47798
46695
  });
47799
46696
  }
47800
- function clearAuthCookie(c, name, path4) {
47801
- deleteCookie(c, name, path4 !== void 0 ? { path: path4 } : void 0);
46697
+ function clearAuthCookie(c, name, path3) {
46698
+ deleteCookie(c, name, path3 !== void 0 ? { path: path3 } : void 0);
47802
46699
  }
47803
46700
  function createAuthMiddleware(db) {
47804
46701
  return async (c, next) => {
@@ -48074,6 +46971,138 @@ function buildRolesRegistry(roles2) {
48074
46971
  validateRoles(roles2);
48075
46972
  return Object.fromEntries(roles2.map((r) => [r.name, r]));
48076
46973
  }
46974
+ var DEFAULT_TIMEOUT_MS = 5e3;
46975
+ var LIST_CONCURRENCY = 10;
46976
+ function resolverKey(schema, field) {
46977
+ return `${schema}::${field}`;
46978
+ }
46979
+ function validateResolverBindings(registry2, resolvers) {
46980
+ const declared = /* @__PURE__ */ new Set();
46981
+ const schemas = [
46982
+ ...Object.values(registry2.content_types),
46983
+ ...Object.values(registry2.taxonomy_types)
46984
+ ];
46985
+ for (const schema of schemas) {
46986
+ for (const field of schema.fields) {
46987
+ if (field.field_type === "programmatic") {
46988
+ declared.add(resolverKey(schema.name, field.name));
46989
+ }
46990
+ }
46991
+ }
46992
+ const missing = [];
46993
+ for (const key of declared) if (!resolvers.has(key)) missing.push(key);
46994
+ const orphans = [];
46995
+ for (const key of resolvers.keys()) if (!declared.has(key)) orphans.push(key);
46996
+ if (missing.length === 0 && orphans.length === 0) return;
46997
+ const lines = ["\u2717 Programmatic field resolver bindings are invalid."];
46998
+ if (missing.length > 0) {
46999
+ lines.push("", ' Declared as `type: "programmatic"` but no resolver found:');
47000
+ for (const k of missing) lines.push(` - ${k} (add a programmaticField in src/programmatic)`);
47001
+ }
47002
+ if (orphans.length > 0) {
47003
+ lines.push("", " Resolver has no matching programmatic field in the schema:");
47004
+ for (const k of orphans) lines.push(` - ${k}`);
47005
+ }
47006
+ lines.push("", "Exiting.");
47007
+ throw new Error(lines.join("\n"));
47008
+ }
47009
+ function buildContext(row) {
47010
+ return {
47011
+ get: (name) => row[name],
47012
+ record: row
47013
+ };
47014
+ }
47015
+ async function withTimeout(p2, ms2) {
47016
+ let timer;
47017
+ const timeout = new Promise((_, reject) => {
47018
+ timer = setTimeout(() => reject(new Error("resolver timeout")), ms2);
47019
+ });
47020
+ try {
47021
+ return await Promise.race([p2, timeout]);
47022
+ } finally {
47023
+ clearTimeout(timer);
47024
+ }
47025
+ }
47026
+ async function runOne(def, row, onError) {
47027
+ const fallback = def.fallback ?? null;
47028
+ try {
47029
+ const result = await withTimeout(
47030
+ Promise.resolve(def.resolve(buildContext(row))),
47031
+ def.timeout ?? DEFAULT_TIMEOUT_MS
47032
+ );
47033
+ return { value: result === void 0 ? null : result, failed: false };
47034
+ } catch (err) {
47035
+ onError(
47036
+ `\u26A0 programmatic field ${resolverKey(def.schema, def.field)} failed: ${err instanceof Error ? err.message : String(err)}`
47037
+ );
47038
+ return { value: fallback, failed: true };
47039
+ }
47040
+ }
47041
+ async function runPool(items, limit, fn) {
47042
+ let i = 0;
47043
+ async function worker() {
47044
+ while (i < items.length) {
47045
+ const idx = i++;
47046
+ await fn(items[idx]);
47047
+ }
47048
+ }
47049
+ const workers = Array.from({ length: Math.min(limit, items.length) }, worker);
47050
+ await Promise.all(workers);
47051
+ }
47052
+ function createProgrammaticResolver(resolvers, options) {
47053
+ const onError = options?.onError ?? ((message) => {
47054
+ process.stderr.write(message + "\n");
47055
+ });
47056
+ const bySchema = /* @__PURE__ */ new Map();
47057
+ for (const def of resolvers.values()) {
47058
+ const arr = bySchema.get(def.schema) ?? [];
47059
+ arr.push(def);
47060
+ bySchema.set(def.schema, arr);
47061
+ }
47062
+ const cache = /* @__PURE__ */ new Map();
47063
+ async function resolveField(def, row) {
47064
+ const itemId = row["id"] !== void 0 ? String(row["id"]) : "";
47065
+ if (def.cache && itemId) {
47066
+ const key = `${resolverKey(def.schema, def.field)}::${itemId}`;
47067
+ const now = Date.now();
47068
+ const hit = cache.get(key);
47069
+ if (hit && hit.expires > now) return hit.value;
47070
+ const { value: value2, failed } = await runOne(def, row, onError);
47071
+ if (!failed) cache.set(key, { value: value2, expires: now + def.cache.ttl * 1e3 });
47072
+ return value2;
47073
+ }
47074
+ const { value } = await runOne(def, row, onError);
47075
+ return value;
47076
+ }
47077
+ async function resolveItem(schema, row) {
47078
+ const defs = bySchema.get(schema);
47079
+ if (!defs || defs.length === 0) return { ...row };
47080
+ const out = { ...row };
47081
+ await Promise.all(
47082
+ defs.map(async (def) => {
47083
+ out[def.field] = await resolveField(def, row);
47084
+ })
47085
+ );
47086
+ return out;
47087
+ }
47088
+ async function resolveList(schema, rows) {
47089
+ const defs = (bySchema.get(schema) ?? []).filter((d2) => d2.on_list === true);
47090
+ if (defs.length === 0) return rows.map((r) => ({ ...r }));
47091
+ const out = rows.map((r) => ({ ...r }));
47092
+ const tasks = [];
47093
+ for (let i = 0; i < rows.length; i++) {
47094
+ for (const def of defs) tasks.push({ rowIndex: i, def });
47095
+ }
47096
+ await runPool(tasks, LIST_CONCURRENCY, async ({ rowIndex, def }) => {
47097
+ out[rowIndex][def.field] = await resolveField(def, rows[rowIndex]);
47098
+ });
47099
+ return out;
47100
+ }
47101
+ function hasSchema(schema) {
47102
+ return bySchema.has(schema);
47103
+ }
47104
+ return { resolveItem, resolveList, hasSchema };
47105
+ }
48077
47106
  var SORTABLE_FIELDS = /* @__PURE__ */ new Set(["title", "created_at", "updated_at"]);
48078
47107
  var RELATION_FIELD_TYPES = /* @__PURE__ */ new Set([
48079
47108
  "paragraph",
@@ -48122,12 +47151,12 @@ function parseFilters(url2, validFields) {
48122
47151
  function isPublished(item) {
48123
47152
  return item["published"] === true;
48124
47153
  }
48125
- function registerPublicContentRoutes(app, registry2, repos, listRateLimit) {
48126
- function registerListRoute(path4, handler) {
47154
+ function registerPublicContentRoutes(app, registry2, repos, listRateLimit, resolver) {
47155
+ function registerListRoute(path3, handler) {
48127
47156
  if (listRateLimit) {
48128
- app.get(path4, listRateLimit, handler);
47157
+ app.get(path3, listRateLimit, handler);
48129
47158
  } else {
48130
- app.get(path4, handler);
47159
+ app.get(path3, handler);
48131
47160
  }
48132
47161
  }
48133
47162
  registerListRoute("/api/content", (c) => {
@@ -48149,13 +47178,13 @@ function registerPublicContentRoutes(app, registry2, repos, listRateLimit) {
48149
47178
  const basePath = contentType.default_base_path;
48150
47179
  const repo = repos[typeName];
48151
47180
  if (!repo) continue;
48152
- const schemaFieldNames = /* @__PURE__ */ new Set([
48153
- ...contentType.fields.map((f) => f.name),
48154
- ...contentType.system_fields.map((f) => f.name)
48155
- ]);
48156
47181
  const relationFieldNames = new Set(
48157
47182
  contentType.fields.filter((f) => RELATION_FIELD_TYPES.has(f.field_type)).map((f) => f.name)
48158
47183
  );
47184
+ const filterableFieldNames = /* @__PURE__ */ new Set([
47185
+ ...contentType.fields.filter((f) => f.field_type !== "programmatic").map((f) => f.name),
47186
+ ...contentType.system_fields.map((f) => f.name)
47187
+ ]);
48159
47188
  if (contentType.only_one) {
48160
47189
  app.get(`/api/${basePath}`, async (c) => {
48161
47190
  const result = await repo.findMany({ published_only: true, page: 1, per_page: 1 });
@@ -48165,7 +47194,9 @@ function registerPublicContentRoutes(app, registry2, repos, listRateLimit) {
48165
47194
  404
48166
47195
  );
48167
47196
  }
48168
- return c.json({ ok: true, data: result.data[0] });
47197
+ let data = result.data[0];
47198
+ if (resolver?.hasSchema(typeName)) data = await resolver.resolveItem(typeName, data);
47199
+ return c.json({ ok: true, data });
48169
47200
  });
48170
47201
  } else {
48171
47202
  registerListRoute(`/api/${basePath}`, async (c) => {
@@ -48208,7 +47239,7 @@ function registerPublicContentRoutes(app, registry2, repos, listRateLimit) {
48208
47239
  400
48209
47240
  );
48210
47241
  }
48211
- const filtersResult = parseFilters(c.req.url, schemaFieldNames);
47242
+ const filtersResult = parseFilters(c.req.url, filterableFieldNames);
48212
47243
  if (!filtersResult.ok) {
48213
47244
  return c.json(
48214
47245
  {
@@ -48245,6 +47276,10 @@ function registerPublicContentRoutes(app, registry2, repos, listRateLimit) {
48245
47276
  filters: filtersResult.filters,
48246
47277
  include
48247
47278
  });
47279
+ if (resolver?.hasSchema(typeName)) {
47280
+ const resolved = await resolver.resolveList(typeName, result.data);
47281
+ return c.json({ ...result, data: resolved });
47282
+ }
48248
47283
  return c.json(result);
48249
47284
  });
48250
47285
  app.get(`/api/${basePath}/:slug`, async (c) => {
@@ -48274,7 +47309,9 @@ function registerPublicContentRoutes(app, registry2, repos, listRateLimit) {
48274
47309
  404
48275
47310
  );
48276
47311
  }
48277
- return c.json({ ok: true, data: item });
47312
+ let data = item;
47313
+ if (resolver?.hasSchema(typeName)) data = await resolver.resolveItem(typeName, data);
47314
+ return c.json({ ok: true, data });
48278
47315
  });
48279
47316
  }
48280
47317
  }
@@ -48300,6 +47337,10 @@ function registerPublicContentRoutes(app, registry2, repos, listRateLimit) {
48300
47337
  page: pagination.page,
48301
47338
  per_page: pagination.per_page
48302
47339
  });
47340
+ if (resolver?.hasSchema(typeName)) {
47341
+ const resolved = await resolver.resolveList(typeName, result.data);
47342
+ return c.json({ ...result, data: resolved });
47343
+ }
48303
47344
  return c.json(result);
48304
47345
  });
48305
47346
  app.get(`/api/taxonomy/${typeName}/:id`, async (c) => {
@@ -48314,7 +47355,9 @@ function registerPublicContentRoutes(app, registry2, repos, listRateLimit) {
48314
47355
  404
48315
47356
  );
48316
47357
  }
48317
- return c.json({ ok: true, data: item });
47358
+ let data = item;
47359
+ if (resolver?.hasSchema(typeName)) data = await resolver.resolveItem(typeName, data);
47360
+ return c.json({ ok: true, data });
48318
47361
  });
48319
47362
  }
48320
47363
  }
@@ -48415,223 +47458,6 @@ function quoteIdent(name) {
48415
47458
  if (!/^[a-z][a-z0-9_-]*$/.test(name)) throw new Error(`Unsafe identifier: ${name}`);
48416
47459
  return `"${name}"`;
48417
47460
  }
48418
- function paragraphMediaFieldNames(pType) {
48419
- return new Set(
48420
- pType.fields.filter((f) => f.field_type === "image" || f.field_type === "video" || f.field_type === "file").map((f) => f.name)
48421
- );
48422
- }
48423
- async function fetchParagraphMediaIds(db, pType, itemId, fieldName) {
48424
- const mediaColumns = pType.fields.filter((f) => f.field_type === "image" || f.field_type === "video" || f.field_type === "file").map((f) => f.db_column.column_name);
48425
- if (mediaColumns.length === 0) return [];
48426
- const tbl = sql.raw(quoteIdent(pType.db.table_name));
48427
- const cols = sql.join(mediaColumns.map((c) => sql.raw(quoteIdent(c))), sql`, `);
48428
- const result = await db.execute(
48429
- sql`SELECT ${cols} FROM ${tbl} WHERE parent_id = ${itemId} AND parent_field = ${fieldName}`
48430
- );
48431
- const ids = [];
48432
- for (const row of result.rows) {
48433
- for (const col of mediaColumns) {
48434
- const v2 = row[col];
48435
- if (typeof v2 === "string" && v2 !== "") ids.push(v2);
48436
- }
48437
- }
48438
- return ids;
48439
- }
48440
- async function persistParagraphField(db, itemId, parentType, fieldName, pType, items) {
48441
- const removed = await fetchParagraphMediaIds(db, pType, itemId, fieldName);
48442
- const tbl = sql.raw(quoteIdent(pType.db.table_name));
48443
- await db.execute(sql`DELETE FROM ${tbl} WHERE parent_id = ${itemId} AND parent_field = ${fieldName}`);
48444
- const mediaFieldNames = paragraphMediaFieldNames(pType);
48445
- const added = [];
48446
- for (let i = 0; i < items.length; i++) {
48447
- const pItem = items[i];
48448
- const data = {
48449
- id: crypto3.randomUUID(),
48450
- parent_id: itemId,
48451
- parent_type: parentType,
48452
- parent_field: fieldName,
48453
- order: i,
48454
- created_at: /* @__PURE__ */ new Date(),
48455
- updated_at: /* @__PURE__ */ new Date()
48456
- };
48457
- for (const pf of pType.fields) {
48458
- if (!pf.db_column || pf.db_column.junction) continue;
48459
- data[pf.db_column.column_name] = pItem[pf.name] ?? null;
48460
- }
48461
- const cols = sql.join(Object.keys(data).map((k) => sql.raw(quoteIdent(k))), sql`, `);
48462
- const vals = sql.join(Object.values(data).map((v2) => sql`${v2}`), sql`, `);
48463
- await db.execute(sql`INSERT INTO ${tbl} (${cols}) VALUES (${vals})`);
48464
- for (const name of mediaFieldNames) {
48465
- const val = pItem[name];
48466
- if (typeof val === "string" && val !== "") added.push(val);
48467
- }
48468
- }
48469
- return { added, removed };
48470
- }
48471
- async function deleteParagraphField(db, itemId, fieldName, pType) {
48472
- const removed = await fetchParagraphMediaIds(db, pType, itemId, fieldName);
48473
- const tbl = sql.raw(quoteIdent(pType.db.table_name));
48474
- await db.execute(sql`DELETE FROM ${tbl} WHERE parent_id = ${itemId} AND parent_field = ${fieldName}`);
48475
- return { added: [], removed };
48476
- }
48477
- async function persistJunctionField(db, itemId, junction, relatedIds) {
48478
- const tbl = sql.raw(quoteIdent(junction.table_name));
48479
- const left = sql.raw(quoteIdent(junction.left_column));
48480
- const right = sql.raw(quoteIdent(junction.right_column));
48481
- await db.execute(sql`DELETE FROM ${tbl} WHERE ${left} = ${itemId}`);
48482
- for (const rid of relatedIds) {
48483
- await db.execute(sql`INSERT INTO ${tbl} (${left}, ${right}) VALUES (${itemId}, ${rid})`);
48484
- }
48485
- }
48486
- function buildRelationsMap(fields, registry2) {
48487
- const relations = {};
48488
- for (const field of fields) {
48489
- if (field.field_type === "image" || field.field_type === "video" || field.field_type === "file") {
48490
- if (!field.db_column) continue;
48491
- relations[field.name] = { type: "media", fk_column: field.db_column.column_name };
48492
- } else if (field.field_type === "paragraph") {
48493
- const ref = field.ui_component.ref;
48494
- const pType = ref ? registry2.paragraph_types[ref] : void 0;
48495
- if (!pType) continue;
48496
- relations[field.name] = { type: "paragraph", table: pType.db.table_name };
48497
- } else if (field.field_type === "reference") {
48498
- if (!field.db_column) continue;
48499
- if (field.db_column.junction) {
48500
- const j = field.db_column.junction;
48501
- relations[field.name] = {
48502
- type: "junction",
48503
- table: j.right_table,
48504
- junction_table: j.table_name,
48505
- left_column: j.left_column,
48506
- right_column: j.right_column,
48507
- order_column: j.order_column
48508
- };
48509
- } else if (field.db_column.foreign_key) {
48510
- relations[field.name] = {
48511
- type: "reference",
48512
- table: field.db_column.foreign_key.table,
48513
- fk_column: field.db_column.column_name
48514
- };
48515
- }
48516
- }
48517
- }
48518
- return relations;
48519
- }
48520
- function groupBy(items, key) {
48521
- const result = {};
48522
- for (const item of items) {
48523
- const k = String(item[key]);
48524
- if (!result[k]) result[k] = [];
48525
- result[k].push(item);
48526
- }
48527
- return result;
48528
- }
48529
- async function resolveRelationField(db, rows, fieldName, rel, cache) {
48530
- if (rows.length === 0) return;
48531
- if (rel.type === "paragraph") {
48532
- const parentIds = rows.map((r) => r["id"]);
48533
- const inList = sql.join(parentIds.map((id) => sql`${id}`), sql`, `);
48534
- const result = await db.execute(
48535
- sql`SELECT * FROM ${sql.raw(quoteIdent(rel.table))} WHERE parent_id IN (${inList}) ORDER BY "order" ASC`
48536
- );
48537
- const byParent = groupBy(result.rows, "parent_id");
48538
- for (const row of rows) {
48539
- row[fieldName] = byParent[row["id"]] ?? [];
48540
- }
48541
- } else if (rel.type === "reference") {
48542
- const fkValues = rows.map((r) => r[rel.fk_column]).filter(Boolean);
48543
- if (fkValues.length === 0) {
48544
- for (const row of rows) row[fieldName] = null;
48545
- return;
48546
- }
48547
- const unique = [...new Set(fkValues)];
48548
- const uncached = unique.filter((id) => !cache.has(`${rel.table}:${id}`));
48549
- if (uncached.length > 0) {
48550
- const inList = sql.join(uncached.map((id) => sql`${id}`), sql`, `);
48551
- const result = await db.execute(
48552
- sql`SELECT * FROM ${sql.raw(quoteIdent(rel.table))} WHERE id IN (${inList})`
48553
- );
48554
- for (const item of result.rows) {
48555
- cache.set(`${rel.table}:${item["id"]}`, item);
48556
- }
48557
- }
48558
- for (const row of rows) {
48559
- const fkVal = row[rel.fk_column];
48560
- row[fieldName] = fkVal ? cache.get(`${rel.table}:${fkVal}`) ?? null : null;
48561
- }
48562
- } else if (rel.type === "junction") {
48563
- const parentIds = rows.map((r) => r["id"]);
48564
- const inList = sql.join(parentIds.map((id) => sql`${id}`), sql`, `);
48565
- const orderBy = rel.order_column ? sql` ORDER BY "order" ASC` : sql``;
48566
- const junctionResult = await db.execute(
48567
- sql`SELECT * FROM ${sql.raw(quoteIdent(rel.junction_table))} WHERE ${sql.raw(quoteIdent(rel.left_column))} IN (${inList})${orderBy}`
48568
- );
48569
- const jRows = junctionResult.rows;
48570
- const rightIds = [...new Set(jRows.map((r) => r[rel.right_column]))];
48571
- const uncached = rightIds.filter((id) => !cache.has(`${rel.table}:${id}`));
48572
- if (uncached.length > 0) {
48573
- const rightInList = sql.join(uncached.map((id) => sql`${id}`), sql`, `);
48574
- const entitiesResult = await db.execute(
48575
- sql`SELECT * FROM ${sql.raw(quoteIdent(rel.table))} WHERE id IN (${rightInList})`
48576
- );
48577
- for (const item of entitiesResult.rows) {
48578
- cache.set(`${rel.table}:${item["id"]}`, item);
48579
- }
48580
- }
48581
- const byLeft = groupBy(jRows, rel.left_column);
48582
- for (const row of rows) {
48583
- const jEntries = byLeft[row["id"]] ?? [];
48584
- row[fieldName] = jEntries.map((jr) => cache.get(`${rel.table}:${jr[rel.right_column]}`)).filter(Boolean);
48585
- }
48586
- } else if (rel.type === "media") {
48587
- const fkValues = rows.map((r) => r[rel.fk_column]).filter(Boolean);
48588
- if (fkValues.length === 0) {
48589
- for (const row of rows) row[fieldName] = null;
48590
- return;
48591
- }
48592
- const unique = [...new Set(fkValues)];
48593
- const uncached = unique.filter((id) => !cache.has(`media:${id}`));
48594
- if (uncached.length > 0) {
48595
- const inList = sql.join(uncached.map((id) => sql`${id}`), sql`, `);
48596
- const result = await db.execute(sql`SELECT * FROM "media" WHERE id IN (${inList})`);
48597
- for (const item of result.rows) {
48598
- cache.set(`media:${item["id"]}`, item);
48599
- }
48600
- }
48601
- for (const row of rows) {
48602
- const fkVal = row[rel.fk_column];
48603
- row[fieldName] = fkVal ? cache.get(`media:${fkVal}`) ?? null : null;
48604
- }
48605
- }
48606
- }
48607
- async function resolveRelationBareIds(db, rows, fieldName, rel) {
48608
- if (rows.length === 0) return;
48609
- if (rel.type === "paragraph") {
48610
- const parentIds = rows.map((r) => r["id"]);
48611
- const inList = sql.join(parentIds.map((id) => sql`${id}`), sql`, `);
48612
- const result = await db.execute(
48613
- sql`SELECT id, parent_id FROM ${sql.raw(quoteIdent(rel.table))} WHERE parent_id IN (${inList}) ORDER BY "order" ASC`
48614
- );
48615
- const byParent = groupBy(result.rows, "parent_id");
48616
- for (const row of rows) {
48617
- row[fieldName] = (byParent[row["id"]] ?? []).map((r) => r["id"]);
48618
- }
48619
- } else if (rel.type === "junction") {
48620
- const parentIds = rows.map((r) => r["id"]);
48621
- const inList = sql.join(parentIds.map((id) => sql`${id}`), sql`, `);
48622
- const result = await db.execute(
48623
- sql`SELECT ${sql.raw(quoteIdent(rel.left_column))} AS left_id, ${sql.raw(quoteIdent(rel.right_column))} AS right_id FROM ${sql.raw(quoteIdent(rel.junction_table))} WHERE ${sql.raw(quoteIdent(rel.left_column))} IN (${inList})`
48624
- );
48625
- const byLeft = groupBy(result.rows, "left_id");
48626
- for (const row of rows) {
48627
- row[fieldName] = (byLeft[row["id"]] ?? []).map((r) => r["right_id"]);
48628
- }
48629
- }
48630
- }
48631
- function quoteIdent2(name) {
48632
- if (!/^[a-z][a-z0-9_-]*$/.test(name)) throw new Error(`Unsafe identifier: ${name}`);
48633
- return `"${name}"`;
48634
- }
48635
47461
  async function lookupBasePathId(db, pathOrName) {
48636
47462
  const r = await db.execute(
48637
47463
  sql`SELECT id FROM base_paths WHERE path = ${pathOrName} OR name = ${pathOrName} LIMIT 1`
@@ -48784,13 +47610,13 @@ function registerAdminContentRoutes(app, registry2, repos, mediaRepo, requirePer
48784
47610
  const pType = registry2.paragraph_types[comp.ref];
48785
47611
  if (!pType) continue;
48786
47612
  const r = await db.execute(
48787
- sql`SELECT * FROM ${sql.raw(quoteIdent2(pType.db.table_name))} WHERE parent_id = ${id} AND parent_field = ${f.name} ORDER BY "order" ASC`
47613
+ sql`SELECT * FROM ${sql.raw(quoteIdent(pType.db.table_name))} WHERE parent_id = ${id} AND parent_field = ${f.name} ORDER BY "order" ASC`
48788
47614
  );
48789
47615
  row[f.name] = r.rows;
48790
47616
  } else if (f.db_column.junction) {
48791
47617
  const j = f.db_column.junction;
48792
47618
  const r = await db.execute(
48793
- sql`SELECT ${sql.raw(quoteIdent2(j.right_column))} FROM ${sql.raw(quoteIdent2(j.table_name))} WHERE ${sql.raw(quoteIdent2(j.left_column))} = ${id}`
47619
+ sql`SELECT ${sql.raw(quoteIdent(j.right_column))} FROM ${sql.raw(quoteIdent(j.table_name))} WHERE ${sql.raw(quoteIdent(j.left_column))} = ${id}`
48794
47620
  );
48795
47621
  row[f.name] = r.rows.map(
48796
47622
  (row2) => row2[j.right_column]
@@ -50238,7 +49064,7 @@ function registerUserRoutes(app, db, requirePermission, requireHierarchy) {
50238
49064
  }
50239
49065
  var API_VERSION = (() => {
50240
49066
  try {
50241
- return "0.1.1";
49067
+ return "0.3.0";
50242
49068
  } catch {
50243
49069
  return "0.0.0";
50244
49070
  }
@@ -50344,7 +49170,7 @@ function codeError(code, message) {
50344
49170
  err.code = code;
50345
49171
  return err;
50346
49172
  }
50347
- function quoteIdent3(name) {
49173
+ function quoteIdent2(name) {
50348
49174
  if (!/^[a-z][a-z0-9_-]*$/.test(name)) {
50349
49175
  throw new Error(`Unsafe SQL identifier: ${name}`);
50350
49176
  }
@@ -50393,9 +49219,9 @@ function whereFragment(conds) {
50393
49219
  return conds.length > 0 ? sql` WHERE ${sql.join(conds, sql` AND `)}` : sql``;
50394
49220
  }
50395
49221
  function createDrizzleContentRepository(db, tableName, options = {}) {
50396
- const { relations = {} } = options;
49222
+ const { relations = {}, publishedRelations = false } = options;
50397
49223
  function tableRaw() {
50398
- return sql.raw(quoteIdent3(tableName));
49224
+ return sql.raw(quoteIdent2(tableName));
50399
49225
  }
50400
49226
  async function resolveRows(rows, include, cache) {
50401
49227
  if (rows.length === 0) return rows;
@@ -50406,7 +49232,7 @@ function createDrizzleContentRepository(db, tableName, options = {}) {
50406
49232
  }
50407
49233
  for (const [fieldName, rel] of Object.entries(relations)) {
50408
49234
  if (rel.type === "media") {
50409
- await resolveRelationField(db, rows, fieldName, rel, cache);
49235
+ await resolveRelationField(db, rows, fieldName, rel, cache, publishedRelations);
50410
49236
  } else if (!include.includes(fieldName)) {
50411
49237
  await resolveRelationBareIds(db, rows, fieldName, rel);
50412
49238
  }
@@ -50414,7 +49240,7 @@ function createDrizzleContentRepository(db, tableName, options = {}) {
50414
49240
  for (const fieldName of include) {
50415
49241
  const rel = relations[fieldName];
50416
49242
  if (rel.type !== "media") {
50417
- await resolveRelationField(db, rows, fieldName, rel, cache);
49243
+ await resolveRelationField(db, rows, fieldName, rel, cache, publishedRelations);
50418
49244
  }
50419
49245
  }
50420
49246
  return rows;
@@ -50437,7 +49263,7 @@ function createDrizzleContentRepository(db, tableName, options = {}) {
50437
49263
  const offset = (page - 1) * per_page;
50438
49264
  const conds = buildConditions(published_only, filters, search);
50439
49265
  const where = whereFragment(conds);
50440
- const sortCol = sql.raw(quoteIdent3(sort_by));
49266
+ const sortCol = sql.raw(quoteIdent2(sort_by));
50441
49267
  const sortDir = sql.raw(sort_order === "desc" ? "DESC" : "ASC");
50442
49268
  const countResult = await db.execute(
50443
49269
  sql`SELECT COUNT(*) AS total FROM ${tableRaw()}${where}`
@@ -50486,12 +49312,12 @@ function createDrizzleContentRepository(db, tableName, options = {}) {
50486
49312
  async create(data) {
50487
49313
  const record2 = {
50488
49314
  ...data,
50489
- id: crypto22.randomUUID(),
49315
+ id: crypto3.randomUUID(),
50490
49316
  created_at: /* @__PURE__ */ new Date(),
50491
49317
  updated_at: /* @__PURE__ */ new Date()
50492
49318
  };
50493
49319
  const entries = Object.entries(record2).filter(([, v2]) => v2 !== void 0);
50494
- const colsSql = sql.join(entries.map(([k]) => sql.raw(quoteIdent3(k))), sql`, `);
49320
+ const colsSql = sql.join(entries.map(([k]) => sql.raw(quoteIdent2(k))), sql`, `);
50495
49321
  const valsSql = sql.join(entries.map(([, v2]) => sql`${v2}`), sql`, `);
50496
49322
  const result = await db.execute(
50497
49323
  sql`INSERT INTO ${tableRaw()} (${colsSql}) VALUES (${valsSql}) RETURNING *`
@@ -50508,7 +49334,7 @@ function createDrizzleContentRepository(db, tableName, options = {}) {
50508
49334
  return this.findOne(id);
50509
49335
  }
50510
49336
  const setClauses = sql.join(
50511
- entries.map(([k, v2]) => sql`${sql.raw(quoteIdent3(k))} = ${v2}`),
49337
+ entries.map(([k, v2]) => sql`${sql.raw(quoteIdent2(k))} = ${v2}`),
50512
49338
  sql`, `
50513
49339
  );
50514
49340
  const result = await db.execute(
@@ -50575,7 +49401,7 @@ function createMediaRepository(db) {
50575
49401
  async create(data) {
50576
49402
  const record2 = {
50577
49403
  ...data,
50578
- id: crypto32.randomUUID(),
49404
+ id: crypto22.randomUUID(),
50579
49405
  reference_count: 0,
50580
49406
  created_at: /* @__PURE__ */ new Date(),
50581
49407
  updated_at: /* @__PURE__ */ new Date()
@@ -50641,9 +49467,19 @@ function createCmsApp(options) {
50641
49467
  const cmsName = options.name ?? "Manguito CMS";
50642
49468
  const maxFileSize = media?.max_file_size;
50643
49469
  const rolesRegistry = buildRolesRegistry(registry2.roles.roles);
49470
+ const resolverMap = options.resolvers ?? /* @__PURE__ */ new Map();
49471
+ validateResolverBindings(registry2, resolverMap);
49472
+ const programmaticResolver = createProgrammaticResolver(resolverMap);
50644
49473
  const app = new Hono2();
50645
49474
  const uploadOrigins = storage.getUploadOrigins?.() ?? [];
50646
- app.use("*", createSecurityHeadersMiddleware({ connectSrc: uploadOrigins }));
49475
+ const graphiqlEnabled = options.graphql?.enabled === true && options.graphql.graphiql === true;
49476
+ app.use(
49477
+ "*",
49478
+ createSecurityHeadersMiddleware({
49479
+ connectSrc: uploadOrigins,
49480
+ ...graphiqlEnabled && { graphiqlPath: "/graphql" }
49481
+ })
49482
+ );
50647
49483
  app.use("*", createCorsMiddleware(cors ?? { origin: "*", enabled: true }));
50648
49484
  app.onError(errorHandler2);
50649
49485
  const listRateLimit = resolveListRateLimit(rateLimit);
@@ -50678,7 +49514,8 @@ function createCmsApp(options) {
50678
49514
  Object.entries(registry2.content_types).map(([typeName, ct2]) => [
50679
49515
  typeName,
50680
49516
  createDrizzleContentRepository(db, ct2.db.table_name, {
50681
- relations: buildRelationsMap(ct2.fields, registry2)
49517
+ relations: buildRelationsMap(ct2.fields, registry2),
49518
+ publishedRelations: true
50682
49519
  })
50683
49520
  ])
50684
49521
  );
@@ -50686,7 +49523,8 @@ function createCmsApp(options) {
50686
49523
  Object.entries(registry2.taxonomy_types).map(([typeName, tt2]) => [
50687
49524
  typeName,
50688
49525
  createDrizzleContentRepository(db, tt2.db.table_name, {
50689
- relations: buildRelationsMap(tt2.fields, registry2)
49526
+ relations: buildRelationsMap(tt2.fields, registry2),
49527
+ publishedRelations: true
50690
49528
  })
50691
49529
  ])
50692
49530
  );
@@ -50725,8 +49563,37 @@ function createCmsApp(options) {
50725
49563
  paths: {}
50726
49564
  })
50727
49565
  );
50728
- registerPublicContentRoutes(app, registry2, publicRepos, listRateLimit);
49566
+ registerPublicContentRoutes(app, registry2, publicRepos, listRateLimit, programmaticResolver);
50729
49567
  registerPublicMediaRoutes(app, mediaRepo, listRateLimit);
49568
+ if (options.graphql?.enabled) {
49569
+ const gqlOptions = options.graphql;
49570
+ let gqlHandler = null;
49571
+ let initError = null;
49572
+ const ready = import("./handler-GMCFYZY5-F3656HCZ.js").then(({ createGraphQLHandler }) => {
49573
+ gqlHandler = createGraphQLHandler(registry2, publicRepos, programmaticResolver, db, gqlOptions);
49574
+ }).catch((err) => {
49575
+ initError = err;
49576
+ const message = err instanceof Error ? err.message : String(err);
49577
+ process.stderr.write(`\u2717 GraphQL schema failed to initialize; /graphql will return 500. ${message}
49578
+ `);
49579
+ });
49580
+ const invokeGraphQL = async (c) => {
49581
+ if (!gqlHandler && !initError) await ready;
49582
+ if (!gqlHandler) {
49583
+ return c.json(
49584
+ { ok: false, error: { code: "GRAPHQL_INIT_FAILED", message: "GraphQL schema failed to initialize" } },
49585
+ 500
49586
+ );
49587
+ }
49588
+ return gqlHandler(c, async () => {
49589
+ });
49590
+ };
49591
+ if (listRateLimit) {
49592
+ app.all("/graphql", listRateLimit, invokeGraphQL);
49593
+ } else {
49594
+ app.all("/graphql", invokeGraphQL);
49595
+ }
49596
+ }
50730
49597
  registerConfigRoute(
50731
49598
  app,
50732
49599
  {
@@ -50750,12 +49617,12 @@ function createCmsApp(options) {
50750
49617
 
50751
49618
  // src/codegen/drizzle-config.ts
50752
49619
  init_esm_shims();
50753
- import { writeFile as writeFile5 } from "fs/promises";
50754
- import { join as join7, relative, resolve as resolve4 } from "path";
49620
+ import { writeFile as writeFile6 } from "fs/promises";
49621
+ import { join as join8, relative as relative2, resolve as resolve4 } from "path";
50755
49622
  async function generateDrizzleConfig(config3, targetDir) {
50756
49623
  const migrationsFolder = config3.migrations?.folder ?? "./migrations";
50757
49624
  const migrationsTable = config3.migrations?.table ?? "__manguito_migrations";
50758
- const outPath = relative(resolve4(targetDir), resolve4(migrationsFolder)).replace(/\\/g, "/");
49625
+ const outPath = relative2(resolve4(targetDir), resolve4(migrationsFolder)).replace(/\\/g, "/");
50759
49626
  const content = [
50760
49627
  `import { defineConfig } from 'drizzle-kit'`,
50761
49628
  ``,
@@ -50773,13 +49640,13 @@ async function generateDrizzleConfig(config3, targetDir) {
50773
49640
  ` tablesFilter: ['!${migrationsTable}'],`,
50774
49641
  `})`
50775
49642
  ].join("\n");
50776
- await writeFile5(join7(targetDir, "drizzle.config.ts"), content, "utf8");
49643
+ await writeFile6(join8(targetDir, "drizzle.config.ts"), content, "utf8");
50777
49644
  }
50778
49645
 
50779
49646
  // src/codegen/nav.ts
50780
49647
  init_esm_shims();
50781
- import { writeFile as writeFile6 } from "fs/promises";
50782
- import { join as join8 } from "path";
49648
+ import { writeFile as writeFile7 } from "fs/promises";
49649
+ import { join as join9 } from "path";
50783
49650
  function schemaBasePath(name) {
50784
49651
  const segment = name.includes("--") ? name.slice(name.indexOf("--") + 2) : name;
50785
49652
  return segment.replace(/_/g, "-");
@@ -50797,7 +49664,17 @@ async function generateNav(registry2, targetDir) {
50797
49664
  })).sort((a2, b2) => a2.label.localeCompare(b2.label));
50798
49665
  const content = `export const nav = ${JSON.stringify({ contentTypes, taxonomyTypes }, null, 2)}
50799
49666
  `;
50800
- await writeFile6(join8(targetDir, "nav.ts"), content, "utf8");
49667
+ await writeFile7(join9(targetDir, "nav.ts"), content, "utf8");
49668
+ }
49669
+
49670
+ // src/commands/dev-routing.ts
49671
+ init_esm_shims();
49672
+ var ABSOLUTE_BACKEND_PATHS = ["/graphql"];
49673
+ function shouldBridgeToHono(url2, apiPrefix) {
49674
+ const path3 = url2.split("?")[0] ?? "";
49675
+ if (path3.startsWith(apiPrefix)) return true;
49676
+ if (path3.startsWith("/admin/api")) return true;
49677
+ return ABSOLUTE_BACKEND_PATHS.includes(path3);
50801
49678
  }
50802
49679
 
50803
49680
  // src/utils/db.ts
@@ -50828,6 +49705,49 @@ function createPromptAdapter() {
50828
49705
  };
50829
49706
  }
50830
49707
 
49708
+ // src/utils/programmatic-loader.ts
49709
+ init_esm_shims();
49710
+ import { existsSync as existsSync4 } from "fs";
49711
+ import { readdir } from "fs/promises";
49712
+ import { resolve as resolve5, join as join10, extname as extname2 } from "path";
49713
+ import { pathToFileURL as pathToFileURL2 } from "url";
49714
+ var RESOLVER_EXTENSIONS = /* @__PURE__ */ new Set([".ts", ".mjs", ".js"]);
49715
+ function isProgrammaticFieldDefinition(v2) {
49716
+ return v2 !== null && typeof v2 === "object" && v2.__manguito_programmatic === true && typeof v2.schema === "string" && typeof v2.field === "string" && typeof v2.resolve === "function";
49717
+ }
49718
+ async function walkTsFiles(dir) {
49719
+ const out = [];
49720
+ for (const entry of await readdir(dir, { withFileTypes: true })) {
49721
+ const full = join10(dir, entry.name);
49722
+ if (entry.isDirectory()) {
49723
+ out.push(...await walkTsFiles(full));
49724
+ } else if (RESOLVER_EXTENSIONS.has(extname2(entry.name))) {
49725
+ out.push(full);
49726
+ }
49727
+ }
49728
+ return out;
49729
+ }
49730
+ async function loadProgrammaticResolvers(cwd, dir) {
49731
+ const abs = resolve5(cwd, dir);
49732
+ const map2 = /* @__PURE__ */ new Map();
49733
+ if (!existsSync4(abs)) return map2;
49734
+ for (const file2 of (await walkTsFiles(abs)).sort()) {
49735
+ const mod = await import(pathToFileURL2(file2).href);
49736
+ const def = mod.default;
49737
+ if (!isProgrammaticFieldDefinition(def)) {
49738
+ throw new Error(
49739
+ `\u2717 ${file2} does not default-export a programmaticField(). Each resolver file must \`export default programmaticField({ schema, field }, resolver)\`.`
49740
+ );
49741
+ }
49742
+ const key = resolverKey(def.schema, def.field);
49743
+ if (map2.has(key)) {
49744
+ throw new Error(`\u2717 Duplicate programmatic resolver for ${key} (found again in ${file2}).`);
49745
+ }
49746
+ map2.set(key, def);
49747
+ }
49748
+ return map2;
49749
+ }
49750
+
50831
49751
  // src/commands/dev.ts
50832
49752
  var UPLOAD_MIME_MAP = {
50833
49753
  jpg: "image/jpeg",
@@ -50855,13 +49775,13 @@ async function runDev(options, deps) {
50855
49775
  printSuccess("Config loaded");
50856
49776
  const db = await connectDb(config3);
50857
49777
  printSuccess("Database connected");
50858
- const manguitoDir = resolve5(cwd, ".manguito");
49778
+ const manguitoDir = resolve6(cwd, ".manguito");
50859
49779
  await mkdir2(manguitoDir, { recursive: true });
50860
- const drizzleConfigPath = resolve5(manguitoDir, "drizzle.config.ts");
49780
+ const drizzleConfigPath = resolve6(manguitoDir, "drizzle.config.ts");
50861
49781
  const needsSeed = !await db.tableExists("users");
50862
49782
  const bootstrapRegistry = await parseAllSchemas(cwd, config3);
50863
49783
  await generateDrizzleConfig(config3, manguitoDir);
50864
- await writeFile7(join9(manguitoDir, "schema.ts"), generateSchemaFile(bootstrapRegistry), "utf8");
49784
+ await writeFile8(join11(manguitoDir, "schema.ts"), generateSchemaFile(bootstrapRegistry), "utf8");
50865
49785
  await runDevMigration(drizzleConfigPath);
50866
49786
  printSuccess(needsSeed ? "Schema tables created" : "Schema tables up to date");
50867
49787
  if (needsSeed) {
@@ -50907,16 +49827,19 @@ async function runDev(options, deps) {
50907
49827
  );
50908
49828
  await generateSchemaRegistry(registry2, manguitoDir);
50909
49829
  await generateRoutes2(registry2, manguitoDir);
50910
- await generateForms(registry2, join9(manguitoDir, "forms"));
49830
+ await generateForms(registry2, join11(manguitoDir, "forms"));
50911
49831
  await generateNav(registry2, manguitoDir);
49832
+ const resolverMap = await loadProgrammaticResolvers(cwd, config3.programmatic.dir);
50912
49833
  const adapter = createCmsApp({
50913
49834
  name: config3.name,
50914
49835
  registry: registry2,
50915
49836
  db: db.getDb(),
50916
49837
  storage: config3.storage,
49838
+ resolvers: resolverMap,
50917
49839
  ...config3.api.prefix ? { prefix: config3.api.prefix } : {},
50918
49840
  ...config3.api.media?.max_file_size ? { media: { max_file_size: config3.api.media.max_file_size } } : {},
50919
49841
  ...config3.api.rateLimit ? { rateLimit: config3.api.rateLimit } : {},
49842
+ ...config3.api.graphql ? { graphql: config3.api.graphql } : {},
50920
49843
  ...config3.server.cors ? { cors: config3.server.cors } : {}
50921
49844
  });
50922
49845
  let honoFetch = (req) => adapter.app.fetch(req);
@@ -50939,14 +49862,14 @@ async function runDev(options, deps) {
50939
49862
  const httpServer = createHttpServer(async (req, res) => {
50940
49863
  try {
50941
49864
  const url2 = req.url ?? "/";
50942
- if (url2.startsWith(apiPrefix) || url2.startsWith("/admin/api")) {
49865
+ if (shouldBridgeToHono(url2, apiPrefix)) {
50943
49866
  await bridgeToHono(req, res, honoFetch);
50944
49867
  return;
50945
49868
  }
50946
49869
  if (url2.startsWith("/uploads/")) {
50947
49870
  const relativePath = (url2.slice("/uploads/".length).split("?")[0] ?? "").replace(/\.\./g, "");
50948
- const uploadsDir = resolve5(cwd, "uploads");
50949
- const filePath = resolve5(uploadsDir, relativePath);
49871
+ const uploadsDir = resolve6(cwd, "uploads");
49872
+ const filePath = resolve6(uploadsDir, relativePath);
50950
49873
  if (!filePath.startsWith(uploadsDir + "/") && filePath !== uploadsDir) {
50951
49874
  res.statusCode = 403;
50952
49875
  res.end("Forbidden");
@@ -50954,7 +49877,7 @@ async function runDev(options, deps) {
50954
49877
  }
50955
49878
  try {
50956
49879
  const data = await readFile(filePath);
50957
- const ext = extname2(filePath).slice(1).toLowerCase();
49880
+ const ext = extname3(filePath).slice(1).toLowerCase();
50958
49881
  const mime = UPLOAD_MIME_MAP[ext] ?? "application/octet-stream";
50959
49882
  res.setHeader("Content-Type", mime);
50960
49883
  res.setHeader("X-Content-Type-Options", "nosniff");
@@ -50987,7 +49910,7 @@ async function runDev(options, deps) {
50987
49910
  printSuccess(`Dev server running at http://localhost:${port}`);
50988
49911
  printSuccess(`Admin panel at http://localhost:${port}${config3.admin.prefix}`);
50989
49912
  });
50990
- const schemasDir = resolve5(cwd, config3.schema.base_path);
49913
+ const schemasDir = resolve6(cwd, config3.schema.base_path);
50991
49914
  const watcher = watch(schemasDir, { recursive: true });
50992
49915
  void (async () => {
50993
49916
  for await (const event of watcher) {
@@ -51000,14 +49923,36 @@ async function runDev(options, deps) {
51000
49923
  db,
51001
49924
  updateFetch: (fetch2) => {
51002
49925
  honoFetch = fetch2;
51003
- }
49926
+ },
49927
+ getResolvers: () => loadProgrammaticResolvers(cwd, config3.programmatic.dir)
51004
49928
  });
51005
49929
  }
51006
49930
  }
51007
49931
  })();
49932
+ const programmaticDir = resolve6(cwd, config3.programmatic.dir);
49933
+ if (existsSync5(programmaticDir)) {
49934
+ const progWatcher = watch(programmaticDir, { recursive: true });
49935
+ void (async () => {
49936
+ for await (const event of progWatcher) {
49937
+ if (event.filename && /\.(ts|mjs|js)$/.test(event.filename)) {
49938
+ await onSchemaFileChange({
49939
+ cwd,
49940
+ config: config3,
49941
+ manguitoDir,
49942
+ drizzleConfigPath,
49943
+ db,
49944
+ updateFetch: (fetch2) => {
49945
+ honoFetch = fetch2;
49946
+ },
49947
+ getResolvers: () => loadProgrammaticResolvers(cwd, config3.programmatic.dir)
49948
+ });
49949
+ }
49950
+ }
49951
+ })();
49952
+ }
51008
49953
  }
51009
49954
  async function onSchemaFileChange(args) {
51010
- const { cwd, config: config3, manguitoDir, drizzleConfigPath, db, updateFetch } = args;
49955
+ const { cwd, config: config3, manguitoDir, drizzleConfigPath, db, updateFetch, getResolvers } = args;
51011
49956
  let registry2;
51012
49957
  try {
51013
49958
  registry2 = await parseAllSchemas(cwd, config3);
@@ -51016,10 +49961,10 @@ async function onSchemaFileChange(args) {
51016
49961
  return;
51017
49962
  }
51018
49963
  await generateDrizzleConfig(config3, manguitoDir);
51019
- await writeFile7(join9(manguitoDir, "schema.ts"), generateSchemaFile(registry2), "utf8");
49964
+ await writeFile8(join11(manguitoDir, "schema.ts"), generateSchemaFile(registry2), "utf8");
51020
49965
  await generateSchemaRegistry(registry2, manguitoDir);
51021
49966
  await generateRoutes2(registry2, manguitoDir);
51022
- await generateForms(registry2, join9(manguitoDir, "forms"));
49967
+ await generateForms(registry2, join11(manguitoDir, "forms"));
51023
49968
  await generateNav(registry2, manguitoDir);
51024
49969
  try {
51025
49970
  await runDevMigration(drizzleConfigPath);
@@ -51028,14 +49973,17 @@ async function onSchemaFileChange(args) {
51028
49973
  `);
51029
49974
  return;
51030
49975
  }
49976
+ const resolverMap = await getResolvers();
51031
49977
  const newAdapter = createCmsApp({
51032
49978
  name: config3.name,
51033
49979
  registry: registry2,
51034
49980
  db: db.getDb(),
51035
49981
  storage: config3.storage,
49982
+ resolvers: resolverMap,
51036
49983
  ...config3.api.prefix ? { prefix: config3.api.prefix } : {},
51037
49984
  ...config3.api.media?.max_file_size ? { media: { max_file_size: config3.api.media.max_file_size } } : {},
51038
49985
  ...config3.api.rateLimit ? { rateLimit: config3.api.rateLimit } : {},
49986
+ ...config3.api.graphql ? { graphql: config3.api.graphql } : {},
51039
49987
  ...config3.server.cors ? { cors: config3.server.cors } : {}
51040
49988
  });
51041
49989
  updateFetch((req) => newAdapter.app.fetch(req));
@@ -51056,7 +50004,7 @@ async function parseAllSchemas(cwd, config3) {
51056
50004
  }
51057
50005
  parsedSchemas.push(parseResult.schema);
51058
50006
  }
51059
- const rolesPath = resolve5(cwd, config3.schema.base_path, "roles.json");
50007
+ const rolesPath = resolve6(cwd, config3.schema.base_path, "roles.json");
51060
50008
  const rolesLoad = loadSchemaFile(rolesPath);
51061
50009
  if (!rolesLoad.ok) {
51062
50010
  printGuidedError("Could not read roles.json.");
@@ -51067,7 +50015,7 @@ async function parseAllSchemas(cwd, config3) {
51067
50015
  printGuidedError("roles.json parse errors \u2014 run `manguito validate` for details.");
51068
50016
  process.exit(1);
51069
50017
  }
51070
- const routesPath = resolve5(cwd, config3.schema.base_path, "routes.json");
50018
+ const routesPath = resolve6(cwd, config3.schema.base_path, "routes.json");
51071
50019
  const routesLoad = loadSchemaFile(routesPath);
51072
50020
  if (!routesLoad.ok) {
51073
50021
  printGuidedError("Could not read routes.json.");
@@ -51081,7 +50029,7 @@ async function parseAllSchemas(cwd, config3) {
51081
50029
  return buildSchemaRegistry(parsedSchemas, routesResult.value, rolesResult.value);
51082
50030
  }
51083
50031
  function resolveAdminRoot2(cwd) {
51084
- const cwdRequire = createRequire2(join9(cwd, "package.json"));
50032
+ const cwdRequire = createRequire2(join11(cwd, "package.json"));
51085
50033
  const adminPkgJson = cwdRequire.resolve("@bobbykim/manguito-cms-admin/package.json");
51086
50034
  return dirname2(adminPkgJson);
51087
50035
  }
@@ -51127,8 +50075,8 @@ async function bridgeToHono(req, res, honoFetch) {
51127
50075
 
51128
50076
  // src/commands/start.ts
51129
50077
  init_esm_shims();
51130
- import { resolve as resolve6 } from "path";
51131
- import { pathToFileURL as pathToFileURL2 } from "url";
50078
+ import { resolve as resolve7 } from "path";
50079
+ import { pathToFileURL as pathToFileURL3 } from "url";
51132
50080
  function registerStart(program2) {
51133
50081
  program2.command("start").description("Start the production server from dist/").option("--env <path>", "path to .env file to load").action(async (options) => {
51134
50082
  await runStart(options, { cwd: process.cwd() });
@@ -51140,7 +50088,7 @@ async function runStart(options, deps) {
51140
50088
  const config3 = await resolveConfig(cwd);
51141
50089
  const db = await connectDb(config3);
51142
50090
  const migrationsTable = config3.migrations?.table ?? "__manguito_migrations";
51143
- const migrationsFolder = config3.migrations?.folder ? resolve6(cwd, config3.migrations.folder) : resolve6(cwd, "./migrations");
50091
+ const migrationsFolder = config3.migrations?.folder ? resolve7(cwd, config3.migrations.folder) : resolve7(cwd, "./migrations");
51144
50092
  const trackingTableExists = await db.tableExists(migrationsTable);
51145
50093
  if (!trackingTableExists) {
51146
50094
  printGuidedError(
@@ -51175,7 +50123,7 @@ async function runStart(options, deps) {
51175
50123
  } else {
51176
50124
  allErrors.push(...walkResult.errors);
51177
50125
  }
51178
- const rolesPath = resolve6(cwd, config3.schema.base_path, "roles.json");
50126
+ const rolesPath = resolve7(cwd, config3.schema.base_path, "roles.json");
51179
50127
  const rolesLoad = loadSchemaFile(rolesPath);
51180
50128
  let parsedRoles = null;
51181
50129
  if (rolesLoad.ok) {
@@ -51188,7 +50136,7 @@ async function runStart(options, deps) {
51188
50136
  } else {
51189
50137
  allErrors.push(...rolesLoad.errors);
51190
50138
  }
51191
- const routesPath = resolve6(cwd, config3.schema.base_path, "routes.json");
50139
+ const routesPath = resolve7(cwd, config3.schema.base_path, "routes.json");
51192
50140
  const routesLoad = loadSchemaFile(routesPath);
51193
50141
  let parsedRoutes = null;
51194
50142
  if (routesLoad.ok) {
@@ -51210,7 +50158,7 @@ async function runStart(options, deps) {
51210
50158
  }
51211
50159
  const registry2 = buildSchemaRegistry(parsedSchemas, parsedRoutes, parsedRoles);
51212
50160
  await seedSystemTables(db.getDb(), registry2);
51213
- const serverUrl = pathToFileURL2(resolve6(cwd, "dist/server.js")).href;
50161
+ const serverUrl = pathToFileURL3(resolve7(cwd, "dist/server.js")).href;
51214
50162
  await (deps.loadServer ? deps.loadServer(serverUrl) : import(serverUrl));
51215
50163
  const port = Number(process.env["PORT"] ?? 3e3);
51216
50164
  printSuccess(`Server running at http://localhost:${port}`);
@@ -51219,7 +50167,7 @@ async function runStart(options, deps) {
51219
50167
 
51220
50168
  // src/commands/migrate.ts
51221
50169
  init_esm_shims();
51222
- import { resolve as resolve7, join as join10 } from "path";
50170
+ import { resolve as resolve8, join as join12 } from "path";
51223
50171
  import { readFile as readFile2 } from "fs/promises";
51224
50172
  function registerMigrate(program2) {
51225
50173
  program2.command("migrate").description("Apply pending database migrations").option("--env <path>", "path to .env file to load").option("--status", "show migration state without applying").option("--dry-run", "preview migrations without writing").option("--force", "skip destructive-change confirmation prompt").action(async (options) => {
@@ -51237,8 +50185,8 @@ function buildDeps(options, cwd) {
51237
50185
  buildRunner: async () => runBuild(options.env ? { env: options.env } : {}, { cwd }),
51238
50186
  needsRebuild: () => needsRebuild(cwd),
51239
50187
  db: createPostgresAdapter(),
51240
- migrationsFolder: resolve7(cwd, "./migrations"),
51241
- configPath: resolve7(cwd, "dist/generated/drizzle.config.ts"),
50188
+ migrationsFolder: resolve8(cwd, "./migrations"),
50189
+ configPath: resolve8(cwd, "dist/generated/drizzle.config.ts"),
51242
50190
  prompt: createPromptAdapter()
51243
50191
  };
51244
50192
  }
@@ -51253,7 +50201,7 @@ async function runMigrate(options, deps) {
51253
50201
  }
51254
50202
  const config4 = await resolveConfig(process.cwd());
51255
50203
  const migrationsTable2 = config4.migrations?.table ?? "__manguito_migrations";
51256
- const migrationsFolder2 = config4.migrations?.folder ? resolve7(process.cwd(), config4.migrations.folder) : deps.migrationsFolder;
50204
+ const migrationsFolder2 = config4.migrations?.folder ? resolve8(process.cwd(), config4.migrations.folder) : deps.migrationsFolder;
51257
50205
  const status = await getMigrationStatus(deps.db.getDb(), { migrationsTable: migrationsTable2, migrationsFolder: migrationsFolder2 });
51258
50206
  if (status.applied.length === 0 && status.pending.length === 0) {
51259
50207
  process.stdout.write(
@@ -51285,7 +50233,7 @@ async function runMigrate(options, deps) {
51285
50233
  loadEnvFile(options.env);
51286
50234
  const cwd = process.cwd();
51287
50235
  const config3 = await resolveConfig(cwd);
51288
- const migrationsFolder = config3.migrations?.folder ? resolve7(cwd, config3.migrations.folder) : deps.migrationsFolder;
50236
+ const migrationsFolder = config3.migrations?.folder ? resolve8(cwd, config3.migrations.folder) : deps.migrationsFolder;
51289
50237
  const migrationsTable = config3.migrations?.table ?? "__manguito_migrations";
51290
50238
  try {
51291
50239
  await deps.db.connect();
@@ -51305,10 +50253,10 @@ async function runMigrate(options, deps) {
51305
50253
  }
51306
50254
  }
51307
50255
  printSuccess("Build complete");
51308
- const generatedDir = resolve7(cwd, "dist/generated");
50256
+ const generatedDir = resolve8(cwd, "dist/generated");
51309
50257
  await generateDrizzleConfig(config3, generatedDir);
51310
50258
  const newFileNames = await generateMigration(deps.configPath, migrationsFolder);
51311
- const newFilePaths = newFileNames.map((f) => join10(migrationsFolder, f));
50259
+ const newFilePaths = newFileNames.map((f) => join12(migrationsFolder, f));
51312
50260
  printSuccess(
51313
50261
  newFileNames.length === 0 ? "No new migration files generated" : `Generated ${newFileNames.length} migration file${newFileNames.length !== 1 ? "s" : ""}: ${newFileNames.join(", ")}`
51314
50262
  );
@@ -51378,7 +50326,7 @@ async function runMigrate(options, deps) {
51378
50326
  } else {
51379
50327
  allErrors.push(...walkResult.errors);
51380
50328
  }
51381
- const rolesPath = resolve7(cwd, config3.schema.base_path, "roles.json");
50329
+ const rolesPath = resolve8(cwd, config3.schema.base_path, "roles.json");
51382
50330
  const rolesLoad = loadSchemaFile(rolesPath);
51383
50331
  let parsedRoles = null;
51384
50332
  if (rolesLoad.ok) {
@@ -51391,7 +50339,7 @@ async function runMigrate(options, deps) {
51391
50339
  } else {
51392
50340
  allErrors.push(...rolesLoad.errors);
51393
50341
  }
51394
- const routesPath = resolve7(cwd, config3.schema.base_path, "routes.json");
50342
+ const routesPath = resolve8(cwd, config3.schema.base_path, "routes.json");
51395
50343
  const routesLoad = loadSchemaFile(routesPath);
51396
50344
  let parsedRoutes = null;
51397
50345
  if (routesLoad.ok) {
@@ -51423,7 +50371,7 @@ async function runMigrate(options, deps) {
51423
50371
 
51424
50372
  // src/commands/validate.ts
51425
50373
  init_esm_shims();
51426
- import { resolve as resolve8 } from "path";
50374
+ import { resolve as resolve9 } from "path";
51427
50375
  function registerValidate(program2) {
51428
50376
  program2.command("validate").description("Parse and validate all schemas, config, roles, and routes").option("--env <path>", "path to .env file to load").action(async (options) => {
51429
50377
  await runValidate(options, { cwd: process.cwd() });
@@ -51448,7 +50396,7 @@ async function runValidate(options, deps) {
51448
50396
  }
51449
50397
  }
51450
50398
  }
51451
- const rolesPath = resolve8(cwd, config3.schema.base_path, "roles.json");
50399
+ const rolesPath = resolve9(cwd, config3.schema.base_path, "roles.json");
51452
50400
  const rolesLoadResult = loadSchemaFile(rolesPath);
51453
50401
  let parsedRoles = null;
51454
50402
  if (!rolesLoadResult.ok) {
@@ -51461,7 +50409,7 @@ async function runValidate(options, deps) {
51461
50409
  parsedRoles = rolesParseResult.value;
51462
50410
  }
51463
50411
  }
51464
- const routesPath = resolve8(cwd, config3.schema.base_path, "routes.json");
50412
+ const routesPath = resolve9(cwd, config3.schema.base_path, "routes.json");
51465
50413
  const routesLoadResult = loadSchemaFile(routesPath);
51466
50414
  let parsedRoutesDef = null;
51467
50415
  if (!routesLoadResult.ok) {
@@ -51738,8 +50686,8 @@ async function runUsersDemote(options, deps) {
51738
50686
 
51739
50687
  // src/index.ts
51740
50688
  var require2 = createRequire3(import.meta.url);
51741
- var { version: version3 } = require2("../package.json");
51742
- var program = new Command().name("manguito").description("Manguito CMS \u2014 developer lifecycle CLI").version(version3);
50689
+ var { version: version2 } = require2("../package.json");
50690
+ var program = new Command().name("manguito").description("Manguito CMS \u2014 developer lifecycle CLI").version(version2);
51743
50691
  registerBuild(program);
51744
50692
  registerDev(program);
51745
50693
  registerStart(program);