@bobbykim/manguito-cms-cli 0.3.0 → 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
  }
@@ -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) {
@@ -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(
@@ -29487,7 +29476,7 @@ function loadSchemaFile(filePath) {
29487
29476
  ]
29488
29477
  };
29489
29478
  }
29490
- const ext = path2.extname(filePath).toLowerCase();
29479
+ const ext = path.extname(filePath).toLowerCase();
29491
29480
  if (ext === ".json") {
29492
29481
  try {
29493
29482
  return { ok: true, value: JSON.parse(raw2) };
@@ -29549,7 +29538,7 @@ function walkSchemaDirectory(config3) {
29549
29538
  const resolvedFolderPaths = /* @__PURE__ */ new Map();
29550
29539
  for (const folderKey of Object.keys(FOLDER_KEY_TO_SCHEMA_TYPE)) {
29551
29540
  const folderName = config3.folders[folderKey];
29552
- const absFolder = path2.resolve(config3.base_path, folderName);
29541
+ const absFolder = path.resolve(config3.base_path, folderName);
29553
29542
  const existing = resolvedFolderPaths.get(absFolder);
29554
29543
  if (existing !== void 0) {
29555
29544
  errors.push({
@@ -29566,7 +29555,7 @@ function walkSchemaDirectory(config3) {
29566
29555
  FOLDER_KEY_TO_SCHEMA_TYPE
29567
29556
  )) {
29568
29557
  const folderName = config3.folders[folderKey];
29569
- const folderPath = path2.resolve(config3.base_path, folderName);
29558
+ const folderPath = path.resolve(config3.base_path, folderName);
29570
29559
  if (!directoryExists(folderPath)) {
29571
29560
  errors.push({
29572
29561
  file: folderPath,
@@ -29579,8 +29568,8 @@ function walkSchemaDirectory(config3) {
29579
29568
  const expectedPrefix = SCHEMA_TYPE_TO_PREFIX[schemaType];
29580
29569
  for (const entry of entries) {
29581
29570
  if (!isSupportedExtension(entry)) continue;
29582
- const filePath = path2.join(folderPath, entry);
29583
- const baseName = path2.basename(entry, path2.extname(entry));
29571
+ const filePath = path.join(folderPath, entry);
29572
+ const baseName = path.basename(entry, path.extname(entry));
29584
29573
  if (!hasCorrectPrefix(baseName, expectedPrefix)) {
29585
29574
  errors.push({
29586
29575
  file: filePath,
@@ -29615,7 +29604,7 @@ function readDirEntries(dirPath) {
29615
29604
  }
29616
29605
  }
29617
29606
  function isSupportedExtension(filename) {
29618
- const ext = path2.extname(filename).toLowerCase();
29607
+ const ext = path.extname(filename).toLowerCase();
29619
29608
  return ext === ".json" || ext === ".yaml" || ext === ".yml";
29620
29609
  }
29621
29610
  function hasCorrectPrefix(baseName, expectedPrefix) {
@@ -30174,1167 +30163,6 @@ init_esm_shims();
30174
30163
 
30175
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
30176
30165
  init_esm_shims();
30177
-
30178
- // ../../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
30179
- init_esm_shims();
30180
-
30181
- // ../../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
30182
- init_esm_shims();
30183
- var entityKind = /* @__PURE__ */ Symbol.for("drizzle:entityKind");
30184
- function is(value, type) {
30185
- if (!value || typeof value !== "object") {
30186
- return false;
30187
- }
30188
- if (value instanceof type) {
30189
- return true;
30190
- }
30191
- if (!Object.prototype.hasOwnProperty.call(type, entityKind)) {
30192
- throw new Error(
30193
- `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.`
30194
- );
30195
- }
30196
- let cls = Object.getPrototypeOf(value).constructor;
30197
- if (cls) {
30198
- while (cls) {
30199
- if (entityKind in cls && cls[entityKind] === type[entityKind]) {
30200
- return true;
30201
- }
30202
- cls = Object.getPrototypeOf(cls);
30203
- }
30204
- }
30205
- return false;
30206
- }
30207
-
30208
- // ../../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
30209
- var Column = class {
30210
- constructor(table, config3) {
30211
- this.table = table;
30212
- this.config = config3;
30213
- this.name = config3.name;
30214
- this.keyAsName = config3.keyAsName;
30215
- this.notNull = config3.notNull;
30216
- this.default = config3.default;
30217
- this.defaultFn = config3.defaultFn;
30218
- this.onUpdateFn = config3.onUpdateFn;
30219
- this.hasDefault = config3.hasDefault;
30220
- this.primary = config3.primaryKey;
30221
- this.isUnique = config3.isUnique;
30222
- this.uniqueName = config3.uniqueName;
30223
- this.uniqueType = config3.uniqueType;
30224
- this.dataType = config3.dataType;
30225
- this.columnType = config3.columnType;
30226
- this.generated = config3.generated;
30227
- this.generatedIdentity = config3.generatedIdentity;
30228
- }
30229
- static [entityKind] = "Column";
30230
- name;
30231
- keyAsName;
30232
- primary;
30233
- notNull;
30234
- default;
30235
- defaultFn;
30236
- onUpdateFn;
30237
- hasDefault;
30238
- isUnique;
30239
- uniqueName;
30240
- uniqueType;
30241
- dataType;
30242
- columnType;
30243
- enumValues = void 0;
30244
- generated = void 0;
30245
- generatedIdentity = void 0;
30246
- config;
30247
- mapFromDriverValue(value) {
30248
- return value;
30249
- }
30250
- mapToDriverValue(value) {
30251
- return value;
30252
- }
30253
- // ** @internal */
30254
- shouldDisableInsert() {
30255
- return this.config.generated !== void 0 && this.config.generated.type !== "byDefault";
30256
- }
30257
- };
30258
-
30259
- // ../../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
30260
- init_esm_shims();
30261
-
30262
- // ../../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
30263
- init_esm_shims();
30264
-
30265
- // ../../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
30266
- init_esm_shims();
30267
-
30268
- // ../../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
30269
- init_esm_shims();
30270
- var ColumnBuilder = class {
30271
- static [entityKind] = "ColumnBuilder";
30272
- config;
30273
- constructor(name, dataType, columnType) {
30274
- this.config = {
30275
- name,
30276
- keyAsName: name === "",
30277
- notNull: false,
30278
- default: void 0,
30279
- hasDefault: false,
30280
- primaryKey: false,
30281
- isUnique: false,
30282
- uniqueName: void 0,
30283
- uniqueType: void 0,
30284
- dataType,
30285
- columnType,
30286
- generated: void 0
30287
- };
30288
- }
30289
- /**
30290
- * Changes the data type of the column. Commonly used with `json` columns. Also, useful for branded types.
30291
- *
30292
- * @example
30293
- * ```ts
30294
- * const users = pgTable('users', {
30295
- * id: integer('id').$type<UserId>().primaryKey(),
30296
- * details: json('details').$type<UserDetails>().notNull(),
30297
- * });
30298
- * ```
30299
- */
30300
- $type() {
30301
- return this;
30302
- }
30303
- /**
30304
- * Adds a `not null` clause to the column definition.
30305
- *
30306
- * Affects the `select` model of the table - columns *without* `not null` will be nullable on select.
30307
- */
30308
- notNull() {
30309
- this.config.notNull = true;
30310
- return this;
30311
- }
30312
- /**
30313
- * Adds a `default <value>` clause to the column definition.
30314
- *
30315
- * Affects the `insert` model of the table - columns *with* `default` are optional on insert.
30316
- *
30317
- * If you need to set a dynamic default value, use {@link $defaultFn} instead.
30318
- */
30319
- default(value) {
30320
- this.config.default = value;
30321
- this.config.hasDefault = true;
30322
- return this;
30323
- }
30324
- /**
30325
- * Adds a dynamic default value to the column.
30326
- * The function will be called when the row is inserted, and the returned value will be used as the column value.
30327
- *
30328
- * **Note:** This value does not affect the `drizzle-kit` behavior, it is only used at runtime in `drizzle-orm`.
30329
- */
30330
- $defaultFn(fn) {
30331
- this.config.defaultFn = fn;
30332
- this.config.hasDefault = true;
30333
- return this;
30334
- }
30335
- /**
30336
- * Alias for {@link $defaultFn}.
30337
- */
30338
- $default = this.$defaultFn;
30339
- /**
30340
- * Adds a dynamic update value to the column.
30341
- * 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.
30342
- * 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.
30343
- *
30344
- * **Note:** This value does not affect the `drizzle-kit` behavior, it is only used at runtime in `drizzle-orm`.
30345
- */
30346
- $onUpdateFn(fn) {
30347
- this.config.onUpdateFn = fn;
30348
- this.config.hasDefault = true;
30349
- return this;
30350
- }
30351
- /**
30352
- * Alias for {@link $onUpdateFn}.
30353
- */
30354
- $onUpdate = this.$onUpdateFn;
30355
- /**
30356
- * Adds a `primary key` clause to the column definition. This implicitly makes the column `not null`.
30357
- *
30358
- * In SQLite, `integer primary key` implicitly makes the column auto-incrementing.
30359
- */
30360
- primaryKey() {
30361
- this.config.primaryKey = true;
30362
- this.config.notNull = true;
30363
- return this;
30364
- }
30365
- /** @internal Sets the name of the column to the key within the table definition if a name was not given. */
30366
- setName(name) {
30367
- if (this.config.name !== "") return;
30368
- this.config.name = name;
30369
- }
30370
- };
30371
-
30372
- // ../../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
30373
- init_esm_shims();
30374
-
30375
- // ../../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
30376
- init_esm_shims();
30377
- var TableName = /* @__PURE__ */ Symbol.for("drizzle:Name");
30378
-
30379
- // ../../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
30380
- var ForeignKeyBuilder = class {
30381
- static [entityKind] = "PgForeignKeyBuilder";
30382
- /** @internal */
30383
- reference;
30384
- /** @internal */
30385
- _onUpdate = "no action";
30386
- /** @internal */
30387
- _onDelete = "no action";
30388
- constructor(config3, actions) {
30389
- this.reference = () => {
30390
- const { name, columns, foreignColumns } = config3();
30391
- return { name, columns, foreignTable: foreignColumns[0].table, foreignColumns };
30392
- };
30393
- if (actions) {
30394
- this._onUpdate = actions.onUpdate;
30395
- this._onDelete = actions.onDelete;
30396
- }
30397
- }
30398
- onUpdate(action) {
30399
- this._onUpdate = action === void 0 ? "no action" : action;
30400
- return this;
30401
- }
30402
- onDelete(action) {
30403
- this._onDelete = action === void 0 ? "no action" : action;
30404
- return this;
30405
- }
30406
- /** @internal */
30407
- build(table) {
30408
- return new ForeignKey(table, this);
30409
- }
30410
- };
30411
- var ForeignKey = class {
30412
- constructor(table, builder) {
30413
- this.table = table;
30414
- this.reference = builder.reference;
30415
- this.onUpdate = builder._onUpdate;
30416
- this.onDelete = builder._onDelete;
30417
- }
30418
- static [entityKind] = "PgForeignKey";
30419
- reference;
30420
- onUpdate;
30421
- onDelete;
30422
- getName() {
30423
- const { name, columns, foreignColumns } = this.reference();
30424
- const columnNames = columns.map((column) => column.name);
30425
- const foreignColumnNames = foreignColumns.map((column) => column.name);
30426
- const chunks = [
30427
- this.table[TableName],
30428
- ...columnNames,
30429
- foreignColumns[0].table[TableName],
30430
- ...foreignColumnNames
30431
- ];
30432
- return name ?? `${chunks.join("_")}_fk`;
30433
- }
30434
- };
30435
-
30436
- // ../../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
30437
- init_esm_shims();
30438
- function iife(fn, ...args) {
30439
- return fn(...args);
30440
- }
30441
-
30442
- // ../../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
30443
- init_esm_shims();
30444
- function uniqueKeyName(table, columns) {
30445
- return `${table[TableName]}_${columns.join("_")}_unique`;
30446
- }
30447
- var UniqueConstraintBuilder = class {
30448
- constructor(columns, name) {
30449
- this.name = name;
30450
- this.columns = columns;
30451
- }
30452
- static [entityKind] = "PgUniqueConstraintBuilder";
30453
- /** @internal */
30454
- columns;
30455
- /** @internal */
30456
- nullsNotDistinctConfig = false;
30457
- nullsNotDistinct() {
30458
- this.nullsNotDistinctConfig = true;
30459
- return this;
30460
- }
30461
- /** @internal */
30462
- build(table) {
30463
- return new UniqueConstraint(table, this.columns, this.nullsNotDistinctConfig, this.name);
30464
- }
30465
- };
30466
- var UniqueOnConstraintBuilder = class {
30467
- static [entityKind] = "PgUniqueOnConstraintBuilder";
30468
- /** @internal */
30469
- name;
30470
- constructor(name) {
30471
- this.name = name;
30472
- }
30473
- on(...columns) {
30474
- return new UniqueConstraintBuilder(columns, this.name);
30475
- }
30476
- };
30477
- var UniqueConstraint = class {
30478
- constructor(table, columns, nullsNotDistinct, name) {
30479
- this.table = table;
30480
- this.columns = columns;
30481
- this.name = name ?? uniqueKeyName(this.table, this.columns.map((column) => column.name));
30482
- this.nullsNotDistinct = nullsNotDistinct;
30483
- }
30484
- static [entityKind] = "PgUniqueConstraint";
30485
- columns;
30486
- name;
30487
- nullsNotDistinct = false;
30488
- getName() {
30489
- return this.name;
30490
- }
30491
- };
30492
-
30493
- // ../../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
30494
- init_esm_shims();
30495
- function parsePgArrayValue(arrayString, startFrom, inQuotes) {
30496
- for (let i = startFrom; i < arrayString.length; i++) {
30497
- const char2 = arrayString[i];
30498
- if (char2 === "\\") {
30499
- i++;
30500
- continue;
30501
- }
30502
- if (char2 === '"') {
30503
- return [arrayString.slice(startFrom, i).replace(/\\/g, ""), i + 1];
30504
- }
30505
- if (inQuotes) {
30506
- continue;
30507
- }
30508
- if (char2 === "," || char2 === "}") {
30509
- return [arrayString.slice(startFrom, i).replace(/\\/g, ""), i];
30510
- }
30511
- }
30512
- return [arrayString.slice(startFrom).replace(/\\/g, ""), arrayString.length];
30513
- }
30514
- function parsePgNestedArray(arrayString, startFrom = 0) {
30515
- const result = [];
30516
- let i = startFrom;
30517
- let lastCharIsComma = false;
30518
- while (i < arrayString.length) {
30519
- const char2 = arrayString[i];
30520
- if (char2 === ",") {
30521
- if (lastCharIsComma || i === startFrom) {
30522
- result.push("");
30523
- }
30524
- lastCharIsComma = true;
30525
- i++;
30526
- continue;
30527
- }
30528
- lastCharIsComma = false;
30529
- if (char2 === "\\") {
30530
- i += 2;
30531
- continue;
30532
- }
30533
- if (char2 === '"') {
30534
- const [value2, startFrom2] = parsePgArrayValue(arrayString, i + 1, true);
30535
- result.push(value2);
30536
- i = startFrom2;
30537
- continue;
30538
- }
30539
- if (char2 === "}") {
30540
- return [result, i + 1];
30541
- }
30542
- if (char2 === "{") {
30543
- const [value2, startFrom2] = parsePgNestedArray(arrayString, i + 1);
30544
- result.push(value2);
30545
- i = startFrom2;
30546
- continue;
30547
- }
30548
- const [value, newStartFrom] = parsePgArrayValue(arrayString, i, false);
30549
- result.push(value);
30550
- i = newStartFrom;
30551
- }
30552
- return [result, i];
30553
- }
30554
- function parsePgArray(arrayString) {
30555
- const [result] = parsePgNestedArray(arrayString, 1);
30556
- return result;
30557
- }
30558
- function makePgArray(array2) {
30559
- return `{${array2.map((item) => {
30560
- if (Array.isArray(item)) {
30561
- return makePgArray(item);
30562
- }
30563
- if (typeof item === "string") {
30564
- return `"${item.replace(/\\/g, "\\\\").replace(/"/g, '\\"')}"`;
30565
- }
30566
- return `${item}`;
30567
- }).join(",")}}`;
30568
- }
30569
-
30570
- // ../../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
30571
- var PgColumnBuilder = class extends ColumnBuilder {
30572
- foreignKeyConfigs = [];
30573
- static [entityKind] = "PgColumnBuilder";
30574
- array(size) {
30575
- return new PgArrayBuilder(this.config.name, this, size);
30576
- }
30577
- references(ref, actions = {}) {
30578
- this.foreignKeyConfigs.push({ ref, actions });
30579
- return this;
30580
- }
30581
- unique(name, config3) {
30582
- this.config.isUnique = true;
30583
- this.config.uniqueName = name;
30584
- this.config.uniqueType = config3?.nulls;
30585
- return this;
30586
- }
30587
- generatedAlwaysAs(as2) {
30588
- this.config.generated = {
30589
- as: as2,
30590
- type: "always",
30591
- mode: "stored"
30592
- };
30593
- return this;
30594
- }
30595
- /** @internal */
30596
- buildForeignKeys(column, table) {
30597
- return this.foreignKeyConfigs.map(({ ref, actions }) => {
30598
- return iife(
30599
- (ref2, actions2) => {
30600
- const builder = new ForeignKeyBuilder(() => {
30601
- const foreignColumn = ref2();
30602
- return { columns: [column], foreignColumns: [foreignColumn] };
30603
- });
30604
- if (actions2.onUpdate) {
30605
- builder.onUpdate(actions2.onUpdate);
30606
- }
30607
- if (actions2.onDelete) {
30608
- builder.onDelete(actions2.onDelete);
30609
- }
30610
- return builder.build(table);
30611
- },
30612
- ref,
30613
- actions
30614
- );
30615
- });
30616
- }
30617
- /** @internal */
30618
- buildExtraConfigColumn(table) {
30619
- return new ExtraConfigColumn(table, this.config);
30620
- }
30621
- };
30622
- var PgColumn = class extends Column {
30623
- constructor(table, config3) {
30624
- if (!config3.uniqueName) {
30625
- config3.uniqueName = uniqueKeyName(table, [config3.name]);
30626
- }
30627
- super(table, config3);
30628
- this.table = table;
30629
- }
30630
- static [entityKind] = "PgColumn";
30631
- };
30632
- var ExtraConfigColumn = class extends PgColumn {
30633
- static [entityKind] = "ExtraConfigColumn";
30634
- getSQLType() {
30635
- return this.getSQLType();
30636
- }
30637
- indexConfig = {
30638
- order: this.config.order ?? "asc",
30639
- nulls: this.config.nulls ?? "last",
30640
- opClass: this.config.opClass
30641
- };
30642
- defaultConfig = {
30643
- order: "asc",
30644
- nulls: "last",
30645
- opClass: void 0
30646
- };
30647
- asc() {
30648
- this.indexConfig.order = "asc";
30649
- return this;
30650
- }
30651
- desc() {
30652
- this.indexConfig.order = "desc";
30653
- return this;
30654
- }
30655
- nullsFirst() {
30656
- this.indexConfig.nulls = "first";
30657
- return this;
30658
- }
30659
- nullsLast() {
30660
- this.indexConfig.nulls = "last";
30661
- return this;
30662
- }
30663
- /**
30664
- * ### PostgreSQL documentation quote
30665
- *
30666
- * > An operator class with optional parameters can be specified for each column of an index.
30667
- * The operator class identifies the operators to be used by the index for that column.
30668
- * For example, a B-tree index on four-byte integers would use the int4_ops class;
30669
- * this operator class includes comparison functions for four-byte integers.
30670
- * In practice the default operator class for the column's data type is usually sufficient.
30671
- * The main point of having operator classes is that for some data types, there could be more than one meaningful ordering.
30672
- * For example, we might want to sort a complex-number data type either by absolute value or by real part.
30673
- * We could do this by defining two operator classes for the data type and then selecting the proper class when creating an index.
30674
- * More information about operator classes check:
30675
- *
30676
- * ### Useful links
30677
- * https://www.postgresql.org/docs/current/sql-createindex.html
30678
- *
30679
- * https://www.postgresql.org/docs/current/indexes-opclass.html
30680
- *
30681
- * https://www.postgresql.org/docs/current/xindex.html
30682
- *
30683
- * ### Additional types
30684
- * If you have the `pg_vector` extension installed in your database, you can use the
30685
- * `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.
30686
- *
30687
- * **You can always specify any string you want in the operator class, in case Drizzle doesn't have it natively in its types**
30688
- *
30689
- * @param opClass
30690
- * @returns
30691
- */
30692
- op(opClass) {
30693
- this.indexConfig.opClass = opClass;
30694
- return this;
30695
- }
30696
- };
30697
- var IndexedColumn = class {
30698
- static [entityKind] = "IndexedColumn";
30699
- constructor(name, keyAsName, type, indexConfig) {
30700
- this.name = name;
30701
- this.keyAsName = keyAsName;
30702
- this.type = type;
30703
- this.indexConfig = indexConfig;
30704
- }
30705
- name;
30706
- keyAsName;
30707
- type;
30708
- indexConfig;
30709
- };
30710
- var PgArrayBuilder = class extends PgColumnBuilder {
30711
- static [entityKind] = "PgArrayBuilder";
30712
- constructor(name, baseBuilder, size) {
30713
- super(name, "array", "PgArray");
30714
- this.config.baseBuilder = baseBuilder;
30715
- this.config.size = size;
30716
- }
30717
- /** @internal */
30718
- build(table) {
30719
- const baseColumn = this.config.baseBuilder.build(table);
30720
- return new PgArray(
30721
- table,
30722
- this.config,
30723
- baseColumn
30724
- );
30725
- }
30726
- };
30727
- var PgArray = class _PgArray extends PgColumn {
30728
- constructor(table, config3, baseColumn, range) {
30729
- super(table, config3);
30730
- this.baseColumn = baseColumn;
30731
- this.range = range;
30732
- this.size = config3.size;
30733
- }
30734
- size;
30735
- static [entityKind] = "PgArray";
30736
- getSQLType() {
30737
- return `${this.baseColumn.getSQLType()}[${typeof this.size === "number" ? this.size : ""}]`;
30738
- }
30739
- mapFromDriverValue(value) {
30740
- if (typeof value === "string") {
30741
- value = parsePgArray(value);
30742
- }
30743
- return value.map((v2) => this.baseColumn.mapFromDriverValue(v2));
30744
- }
30745
- mapToDriverValue(value, isNestedArray = false) {
30746
- const a2 = value.map(
30747
- (v2) => v2 === null ? null : is(this.baseColumn, _PgArray) ? this.baseColumn.mapToDriverValue(v2, true) : this.baseColumn.mapToDriverValue(v2)
30748
- );
30749
- if (isNestedArray) return a2;
30750
- return makePgArray(a2);
30751
- }
30752
- };
30753
-
30754
- // ../../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
30755
- var PgEnumObjectColumnBuilder = class extends PgColumnBuilder {
30756
- static [entityKind] = "PgEnumObjectColumnBuilder";
30757
- constructor(name, enumInstance) {
30758
- super(name, "string", "PgEnumObjectColumn");
30759
- this.config.enum = enumInstance;
30760
- }
30761
- /** @internal */
30762
- build(table) {
30763
- return new PgEnumObjectColumn(
30764
- table,
30765
- this.config
30766
- );
30767
- }
30768
- };
30769
- var PgEnumObjectColumn = class extends PgColumn {
30770
- static [entityKind] = "PgEnumObjectColumn";
30771
- enum;
30772
- enumValues = this.config.enum.enumValues;
30773
- constructor(table, config3) {
30774
- super(table, config3);
30775
- this.enum = config3.enum;
30776
- }
30777
- getSQLType() {
30778
- return this.enum.enumName;
30779
- }
30780
- };
30781
- var isPgEnumSym = /* @__PURE__ */ Symbol.for("drizzle:isPgEnum");
30782
- function isPgEnum(obj) {
30783
- return !!obj && typeof obj === "function" && isPgEnumSym in obj && obj[isPgEnumSym] === true;
30784
- }
30785
- var PgEnumColumnBuilder = class extends PgColumnBuilder {
30786
- static [entityKind] = "PgEnumColumnBuilder";
30787
- constructor(name, enumInstance) {
30788
- super(name, "string", "PgEnumColumn");
30789
- this.config.enum = enumInstance;
30790
- }
30791
- /** @internal */
30792
- build(table) {
30793
- return new PgEnumColumn(
30794
- table,
30795
- this.config
30796
- );
30797
- }
30798
- };
30799
- var PgEnumColumn = class extends PgColumn {
30800
- static [entityKind] = "PgEnumColumn";
30801
- enum = this.config.enum;
30802
- enumValues = this.config.enum.enumValues;
30803
- constructor(table, config3) {
30804
- super(table, config3);
30805
- this.enum = config3.enum;
30806
- }
30807
- getSQLType() {
30808
- return this.enum.enumName;
30809
- }
30810
- };
30811
-
30812
- // ../../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
30813
- init_esm_shims();
30814
- var Subquery = class {
30815
- static [entityKind] = "Subquery";
30816
- constructor(sql2, fields, alias, isWith = false, usedTables = []) {
30817
- this._ = {
30818
- brand: "Subquery",
30819
- sql: sql2,
30820
- selectedFields: fields,
30821
- alias,
30822
- isWith,
30823
- usedTables
30824
- };
30825
- }
30826
- // getSQL(): SQL<unknown> {
30827
- // return new SQL([this]);
30828
- // }
30829
- };
30830
- var WithSubquery = class extends Subquery {
30831
- static [entityKind] = "WithSubquery";
30832
- };
30833
-
30834
- // ../../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
30835
- init_esm_shims();
30836
-
30837
- // ../../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
30838
- init_esm_shims();
30839
- var version2 = "0.45.2";
30840
-
30841
- // ../../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
30842
- var otel;
30843
- var rawTracer;
30844
- var tracer = {
30845
- startActiveSpan(name, fn) {
30846
- if (!otel) {
30847
- return fn();
30848
- }
30849
- if (!rawTracer) {
30850
- rawTracer = otel.trace.getTracer("drizzle-orm", version2);
30851
- }
30852
- return iife(
30853
- (otel2, rawTracer2) => rawTracer2.startActiveSpan(
30854
- name,
30855
- (span) => {
30856
- try {
30857
- return fn(span);
30858
- } catch (e) {
30859
- span.setStatus({
30860
- code: otel2.SpanStatusCode.ERROR,
30861
- message: e instanceof Error ? e.message : "Unknown error"
30862
- // eslint-disable-line no-instanceof/no-instanceof
30863
- });
30864
- throw e;
30865
- } finally {
30866
- span.end();
30867
- }
30868
- }
30869
- ),
30870
- otel,
30871
- rawTracer
30872
- );
30873
- }
30874
- };
30875
-
30876
- // ../../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
30877
- init_esm_shims();
30878
- var ViewBaseConfig = /* @__PURE__ */ Symbol.for("drizzle:ViewBaseConfig");
30879
-
30880
- // ../../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
30881
- init_esm_shims();
30882
- var Schema = /* @__PURE__ */ Symbol.for("drizzle:Schema");
30883
- var Columns = /* @__PURE__ */ Symbol.for("drizzle:Columns");
30884
- var ExtraConfigColumns = /* @__PURE__ */ Symbol.for("drizzle:ExtraConfigColumns");
30885
- var OriginalName = /* @__PURE__ */ Symbol.for("drizzle:OriginalName");
30886
- var BaseName = /* @__PURE__ */ Symbol.for("drizzle:BaseName");
30887
- var IsAlias = /* @__PURE__ */ Symbol.for("drizzle:IsAlias");
30888
- var ExtraConfigBuilder = /* @__PURE__ */ Symbol.for("drizzle:ExtraConfigBuilder");
30889
- var IsDrizzleTable = /* @__PURE__ */ Symbol.for("drizzle:IsDrizzleTable");
30890
- var Table = class {
30891
- static [entityKind] = "Table";
30892
- /** @internal */
30893
- static Symbol = {
30894
- Name: TableName,
30895
- Schema,
30896
- OriginalName,
30897
- Columns,
30898
- ExtraConfigColumns,
30899
- BaseName,
30900
- IsAlias,
30901
- ExtraConfigBuilder
30902
- };
30903
- /**
30904
- * @internal
30905
- * Can be changed if the table is aliased.
30906
- */
30907
- [TableName];
30908
- /**
30909
- * @internal
30910
- * Used to store the original name of the table, before any aliasing.
30911
- */
30912
- [OriginalName];
30913
- /** @internal */
30914
- [Schema];
30915
- /** @internal */
30916
- [Columns];
30917
- /** @internal */
30918
- [ExtraConfigColumns];
30919
- /**
30920
- * @internal
30921
- * Used to store the table name before the transformation via the `tableCreator` functions.
30922
- */
30923
- [BaseName];
30924
- /** @internal */
30925
- [IsAlias] = false;
30926
- /** @internal */
30927
- [IsDrizzleTable] = true;
30928
- /** @internal */
30929
- [ExtraConfigBuilder] = void 0;
30930
- constructor(name, schema, baseName) {
30931
- this[TableName] = this[OriginalName] = name;
30932
- this[Schema] = schema;
30933
- this[BaseName] = baseName;
30934
- }
30935
- };
30936
- function getTableName(table) {
30937
- return table[TableName];
30938
- }
30939
- function getTableUniqueName(table) {
30940
- return `${table[Schema] ?? "public"}.${table[TableName]}`;
30941
- }
30942
-
30943
- // ../../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
30944
- var FakePrimitiveParam = class {
30945
- static [entityKind] = "FakePrimitiveParam";
30946
- };
30947
- function isSQLWrapper(value) {
30948
- return value !== null && value !== void 0 && typeof value.getSQL === "function";
30949
- }
30950
- function mergeQueries(queries) {
30951
- const result = { sql: "", params: [] };
30952
- for (const query of queries) {
30953
- result.sql += query.sql;
30954
- result.params.push(...query.params);
30955
- if (query.typings?.length) {
30956
- if (!result.typings) {
30957
- result.typings = [];
30958
- }
30959
- result.typings.push(...query.typings);
30960
- }
30961
- }
30962
- return result;
30963
- }
30964
- var StringChunk = class {
30965
- static [entityKind] = "StringChunk";
30966
- value;
30967
- constructor(value) {
30968
- this.value = Array.isArray(value) ? value : [value];
30969
- }
30970
- getSQL() {
30971
- return new SQL([this]);
30972
- }
30973
- };
30974
- var SQL = class _SQL {
30975
- constructor(queryChunks) {
30976
- this.queryChunks = queryChunks;
30977
- for (const chunk of queryChunks) {
30978
- if (is(chunk, Table)) {
30979
- const schemaName = chunk[Table.Symbol.Schema];
30980
- this.usedTables.push(
30981
- schemaName === void 0 ? chunk[Table.Symbol.Name] : schemaName + "." + chunk[Table.Symbol.Name]
30982
- );
30983
- }
30984
- }
30985
- }
30986
- static [entityKind] = "SQL";
30987
- /** @internal */
30988
- decoder = noopDecoder;
30989
- shouldInlineParams = false;
30990
- /** @internal */
30991
- usedTables = [];
30992
- append(query) {
30993
- this.queryChunks.push(...query.queryChunks);
30994
- return this;
30995
- }
30996
- toQuery(config3) {
30997
- return tracer.startActiveSpan("drizzle.buildSQL", (span) => {
30998
- const query = this.buildQueryFromSourceParams(this.queryChunks, config3);
30999
- span?.setAttributes({
31000
- "drizzle.query.text": query.sql,
31001
- "drizzle.query.params": JSON.stringify(query.params)
31002
- });
31003
- return query;
31004
- });
31005
- }
31006
- buildQueryFromSourceParams(chunks, _config) {
31007
- const config3 = Object.assign({}, _config, {
31008
- inlineParams: _config.inlineParams || this.shouldInlineParams,
31009
- paramStartIndex: _config.paramStartIndex || { value: 0 }
31010
- });
31011
- const {
31012
- casing,
31013
- escapeName,
31014
- escapeParam,
31015
- prepareTyping,
31016
- inlineParams,
31017
- paramStartIndex
31018
- } = config3;
31019
- return mergeQueries(chunks.map((chunk) => {
31020
- if (is(chunk, StringChunk)) {
31021
- return { sql: chunk.value.join(""), params: [] };
31022
- }
31023
- if (is(chunk, Name)) {
31024
- return { sql: escapeName(chunk.value), params: [] };
31025
- }
31026
- if (chunk === void 0) {
31027
- return { sql: "", params: [] };
31028
- }
31029
- if (Array.isArray(chunk)) {
31030
- const result = [new StringChunk("(")];
31031
- for (const [i, p2] of chunk.entries()) {
31032
- result.push(p2);
31033
- if (i < chunk.length - 1) {
31034
- result.push(new StringChunk(", "));
31035
- }
31036
- }
31037
- result.push(new StringChunk(")"));
31038
- return this.buildQueryFromSourceParams(result, config3);
31039
- }
31040
- if (is(chunk, _SQL)) {
31041
- return this.buildQueryFromSourceParams(chunk.queryChunks, {
31042
- ...config3,
31043
- inlineParams: inlineParams || chunk.shouldInlineParams
31044
- });
31045
- }
31046
- if (is(chunk, Table)) {
31047
- const schemaName = chunk[Table.Symbol.Schema];
31048
- const tableName = chunk[Table.Symbol.Name];
31049
- return {
31050
- sql: schemaName === void 0 || chunk[IsAlias] ? escapeName(tableName) : escapeName(schemaName) + "." + escapeName(tableName),
31051
- params: []
31052
- };
31053
- }
31054
- if (is(chunk, Column)) {
31055
- const columnName = casing.getColumnCasing(chunk);
31056
- if (_config.invokeSource === "indexes") {
31057
- return { sql: escapeName(columnName), params: [] };
31058
- }
31059
- const schemaName = chunk.table[Table.Symbol.Schema];
31060
- return {
31061
- 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),
31062
- params: []
31063
- };
31064
- }
31065
- if (is(chunk, View)) {
31066
- const schemaName = chunk[ViewBaseConfig].schema;
31067
- const viewName = chunk[ViewBaseConfig].name;
31068
- return {
31069
- sql: schemaName === void 0 || chunk[ViewBaseConfig].isAlias ? escapeName(viewName) : escapeName(schemaName) + "." + escapeName(viewName),
31070
- params: []
31071
- };
31072
- }
31073
- if (is(chunk, Param)) {
31074
- if (is(chunk.value, Placeholder)) {
31075
- return { sql: escapeParam(paramStartIndex.value++, chunk), params: [chunk], typings: ["none"] };
31076
- }
31077
- const mappedValue = chunk.value === null ? null : chunk.encoder.mapToDriverValue(chunk.value);
31078
- if (is(mappedValue, _SQL)) {
31079
- return this.buildQueryFromSourceParams([mappedValue], config3);
31080
- }
31081
- if (inlineParams) {
31082
- return { sql: this.mapInlineParam(mappedValue, config3), params: [] };
31083
- }
31084
- let typings = ["none"];
31085
- if (prepareTyping) {
31086
- typings = [prepareTyping(chunk.encoder)];
31087
- }
31088
- return { sql: escapeParam(paramStartIndex.value++, mappedValue), params: [mappedValue], typings };
31089
- }
31090
- if (is(chunk, Placeholder)) {
31091
- return { sql: escapeParam(paramStartIndex.value++, chunk), params: [chunk], typings: ["none"] };
31092
- }
31093
- if (is(chunk, _SQL.Aliased) && chunk.fieldAlias !== void 0) {
31094
- return { sql: escapeName(chunk.fieldAlias), params: [] };
31095
- }
31096
- if (is(chunk, Subquery)) {
31097
- if (chunk._.isWith) {
31098
- return { sql: escapeName(chunk._.alias), params: [] };
31099
- }
31100
- return this.buildQueryFromSourceParams([
31101
- new StringChunk("("),
31102
- chunk._.sql,
31103
- new StringChunk(") "),
31104
- new Name(chunk._.alias)
31105
- ], config3);
31106
- }
31107
- if (isPgEnum(chunk)) {
31108
- if (chunk.schema) {
31109
- return { sql: escapeName(chunk.schema) + "." + escapeName(chunk.enumName), params: [] };
31110
- }
31111
- return { sql: escapeName(chunk.enumName), params: [] };
31112
- }
31113
- if (isSQLWrapper(chunk)) {
31114
- if (chunk.shouldOmitSQLParens?.()) {
31115
- return this.buildQueryFromSourceParams([chunk.getSQL()], config3);
31116
- }
31117
- return this.buildQueryFromSourceParams([
31118
- new StringChunk("("),
31119
- chunk.getSQL(),
31120
- new StringChunk(")")
31121
- ], config3);
31122
- }
31123
- if (inlineParams) {
31124
- return { sql: this.mapInlineParam(chunk, config3), params: [] };
31125
- }
31126
- return { sql: escapeParam(paramStartIndex.value++, chunk), params: [chunk], typings: ["none"] };
31127
- }));
31128
- }
31129
- mapInlineParam(chunk, { escapeString }) {
31130
- if (chunk === null) {
31131
- return "null";
31132
- }
31133
- if (typeof chunk === "number" || typeof chunk === "boolean") {
31134
- return chunk.toString();
31135
- }
31136
- if (typeof chunk === "string") {
31137
- return escapeString(chunk);
31138
- }
31139
- if (typeof chunk === "object") {
31140
- const mappedValueAsString = chunk.toString();
31141
- if (mappedValueAsString === "[object Object]") {
31142
- return escapeString(JSON.stringify(chunk));
31143
- }
31144
- return escapeString(mappedValueAsString);
31145
- }
31146
- throw new Error("Unexpected param value: " + chunk);
31147
- }
31148
- getSQL() {
31149
- return this;
31150
- }
31151
- as(alias) {
31152
- if (alias === void 0) {
31153
- return this;
31154
- }
31155
- return new _SQL.Aliased(this, alias);
31156
- }
31157
- mapWith(decoder) {
31158
- this.decoder = typeof decoder === "function" ? { mapFromDriverValue: decoder } : decoder;
31159
- return this;
31160
- }
31161
- inlineParams() {
31162
- this.shouldInlineParams = true;
31163
- return this;
31164
- }
31165
- /**
31166
- * This method is used to conditionally include a part of the query.
31167
- *
31168
- * @param condition - Condition to check
31169
- * @returns itself if the condition is `true`, otherwise `undefined`
31170
- */
31171
- if(condition) {
31172
- return condition ? this : void 0;
31173
- }
31174
- };
31175
- var Name = class {
31176
- constructor(value) {
31177
- this.value = value;
31178
- }
31179
- static [entityKind] = "Name";
31180
- brand;
31181
- getSQL() {
31182
- return new SQL([this]);
31183
- }
31184
- };
31185
- function isDriverValueEncoder(value) {
31186
- return typeof value === "object" && value !== null && "mapToDriverValue" in value && typeof value.mapToDriverValue === "function";
31187
- }
31188
- var noopDecoder = {
31189
- mapFromDriverValue: (value) => value
31190
- };
31191
- var noopEncoder = {
31192
- mapToDriverValue: (value) => value
31193
- };
31194
- var noopMapper = {
31195
- ...noopDecoder,
31196
- ...noopEncoder
31197
- };
31198
- var Param = class {
31199
- /**
31200
- * @param value - Parameter value
31201
- * @param encoder - Encoder to convert the value to a driver parameter
31202
- */
31203
- constructor(value, encoder = noopEncoder) {
31204
- this.value = value;
31205
- this.encoder = encoder;
31206
- }
31207
- static [entityKind] = "Param";
31208
- brand;
31209
- getSQL() {
31210
- return new SQL([this]);
31211
- }
31212
- };
31213
- function sql(strings, ...params) {
31214
- const queryChunks = [];
31215
- if (params.length > 0 || strings.length > 0 && strings[0] !== "") {
31216
- queryChunks.push(new StringChunk(strings[0]));
31217
- }
31218
- for (const [paramIndex, param2] of params.entries()) {
31219
- queryChunks.push(param2, new StringChunk(strings[paramIndex + 1]));
31220
- }
31221
- return new SQL(queryChunks);
31222
- }
31223
- ((sql2) => {
31224
- function empty() {
31225
- return new SQL([]);
31226
- }
31227
- sql2.empty = empty;
31228
- function fromList(list) {
31229
- return new SQL(list);
31230
- }
31231
- sql2.fromList = fromList;
31232
- function raw2(str2) {
31233
- return new SQL([new StringChunk(str2)]);
31234
- }
31235
- sql2.raw = raw2;
31236
- function join13(chunks, separator) {
31237
- const result = [];
31238
- for (const [i, chunk] of chunks.entries()) {
31239
- if (i > 0 && separator !== void 0) {
31240
- result.push(separator);
31241
- }
31242
- result.push(chunk);
31243
- }
31244
- return new SQL(result);
31245
- }
31246
- sql2.join = join13;
31247
- function identifier(value) {
31248
- return new Name(value);
31249
- }
31250
- sql2.identifier = identifier;
31251
- function placeholder2(name2) {
31252
- return new Placeholder(name2);
31253
- }
31254
- sql2.placeholder = placeholder2;
31255
- function param2(value, encoder) {
31256
- return new Param(value, encoder);
31257
- }
31258
- sql2.param = param2;
31259
- })(sql || (sql = {}));
31260
- ((SQL2) => {
31261
- class Aliased {
31262
- constructor(sql2, fieldAlias) {
31263
- this.sql = sql2;
31264
- this.fieldAlias = fieldAlias;
31265
- }
31266
- static [entityKind] = "SQL.Aliased";
31267
- /** @internal */
31268
- isSelectionField = false;
31269
- getSQL() {
31270
- return this.sql;
31271
- }
31272
- /** @internal */
31273
- clone() {
31274
- return new Aliased(this.sql, this.fieldAlias);
31275
- }
31276
- }
31277
- SQL2.Aliased = Aliased;
31278
- })(SQL || (SQL = {}));
31279
- var Placeholder = class {
31280
- constructor(name2) {
31281
- this.name = name2;
31282
- }
31283
- static [entityKind] = "Placeholder";
31284
- getSQL() {
31285
- return new SQL([this]);
31286
- }
31287
- };
31288
- function fillPlaceholders(params, values) {
31289
- return params.map((p2) => {
31290
- if (is(p2, Placeholder)) {
31291
- if (!(p2.name in values)) {
31292
- throw new Error(`No value for placeholder "${p2.name}" was provided`);
31293
- }
31294
- return values[p2.name];
31295
- }
31296
- if (is(p2, Param) && is(p2.value, Placeholder)) {
31297
- if (!(p2.value.name in values)) {
31298
- throw new Error(`No value for placeholder "${p2.value.name}" was provided`);
31299
- }
31300
- return p2.encoder.mapToDriverValue(values[p2.value.name]);
31301
- }
31302
- return p2;
31303
- });
31304
- }
31305
- var IsDrizzleView = /* @__PURE__ */ Symbol.for("drizzle:IsDrizzleView");
31306
- var View = class {
31307
- static [entityKind] = "View";
31308
- /** @internal */
31309
- [ViewBaseConfig];
31310
- /** @internal */
31311
- [IsDrizzleView] = true;
31312
- constructor({ name: name2, schema, selectedFields, query }) {
31313
- this[ViewBaseConfig] = {
31314
- name: name2,
31315
- originalName: name2,
31316
- schema,
31317
- selectedFields,
31318
- query,
31319
- isExisting: !query,
31320
- isAlias: false
31321
- };
31322
- }
31323
- getSQL() {
31324
- return new SQL([this]);
31325
- }
31326
- };
31327
- Column.prototype.getSQL = function() {
31328
- return new SQL([this]);
31329
- };
31330
- Table.prototype.getSQL = function() {
31331
- return new SQL([this]);
31332
- };
31333
- Subquery.prototype.getSQL = function() {
31334
- return new SQL([this]);
31335
- };
31336
-
31337
- // ../../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
31338
30166
  var ColumnAliasProxyHandler = class {
31339
30167
  constructor(table) {
31340
30168
  this.table = table;
@@ -31535,7 +30363,7 @@ init_esm_shims();
31535
30363
  function mapResultRow(columns, row, joinsNotNullableMap) {
31536
30364
  const nullifyMap = {};
31537
30365
  const result = columns.reduce(
31538
- (result2, { path: path4, field }, columnIndex) => {
30366
+ (result2, { path: path3, field }, columnIndex) => {
31539
30367
  let decoder;
31540
30368
  if (is(field, Column)) {
31541
30369
  decoder = field;
@@ -31547,8 +30375,8 @@ function mapResultRow(columns, row, joinsNotNullableMap) {
31547
30375
  decoder = field.sql.decoder;
31548
30376
  }
31549
30377
  let node = result2;
31550
- for (const [pathChunkIndex, pathChunk] of path4.entries()) {
31551
- if (pathChunkIndex < path4.length - 1) {
30378
+ for (const [pathChunkIndex, pathChunk] of path3.entries()) {
30379
+ if (pathChunkIndex < path3.length - 1) {
31552
30380
  if (!(pathChunk in node)) {
31553
30381
  node[pathChunk] = {};
31554
30382
  }
@@ -31556,8 +30384,8 @@ function mapResultRow(columns, row, joinsNotNullableMap) {
31556
30384
  } else {
31557
30385
  const rawValue = row[columnIndex];
31558
30386
  const value = node[pathChunk] = rawValue === null ? null : decoder.mapFromDriverValue(rawValue);
31559
- if (joinsNotNullableMap && is(field, Column) && path4.length === 2) {
31560
- const objectName = path4[0];
30387
+ if (joinsNotNullableMap && is(field, Column) && path3.length === 2) {
30388
+ const objectName = path3[0];
31561
30389
  if (!(objectName in nullifyMap)) {
31562
30390
  nullifyMap[objectName] = value === null ? getTableName(field.table) : false;
31563
30391
  } else if (typeof nullifyMap[objectName] === "string" && nullifyMap[objectName] !== getTableName(field.table)) {
@@ -33923,7 +32751,7 @@ var PgDialect = class {
33923
32751
  table,
33924
32752
  joins,
33925
32753
  orderBy,
33926
- groupBy: groupBy2,
32754
+ groupBy,
33927
32755
  limit,
33928
32756
  offset,
33929
32757
  lockingClause,
@@ -33957,8 +32785,8 @@ var PgDialect = class {
33957
32785
  orderBySql = sql` order by ${sql.join(orderBy, sql`, `)}`;
33958
32786
  }
33959
32787
  let groupBySql;
33960
- if (groupBy2 && groupBy2.length > 0) {
33961
- groupBySql = sql` group by ${sql.join(groupBy2, sql`, `)}`;
32788
+ if (groupBy && groupBy.length > 0) {
32789
+ groupBySql = sql` group by ${sql.join(groupBy, sql`, `)}`;
33962
32790
  }
33963
32791
  const limitSql = typeof limit === "object" || typeof limit === "number" && limit >= 0 ? sql` limit ${limit}` : void 0;
33964
32792
  const offsetSql = offset ? sql` offset ${offset}` : void 0;
@@ -35438,13 +34266,13 @@ var PgSelectQueryBuilderBase = class extends TypedQueryBuilder {
35438
34266
  }
35439
34267
  groupBy(...columns) {
35440
34268
  if (typeof columns[0] === "function") {
35441
- const groupBy2 = columns[0](
34269
+ const groupBy = columns[0](
35442
34270
  new Proxy(
35443
34271
  this.config.fields,
35444
34272
  new SelectionProxyHandler({ sqlAliasedBehavior: "alias", sqlBehavior: "sql" })
35445
34273
  )
35446
34274
  );
35447
- this.config.groupBy = Array.isArray(groupBy2) ? groupBy2 : [groupBy2];
34275
+ this.config.groupBy = Array.isArray(groupBy) ? groupBy : [groupBy];
35448
34276
  } else {
35449
34277
  this.config.groupBy = columns;
35450
34278
  }
@@ -42775,7 +41603,7 @@ function drizzle2(...params) {
42775
41603
  // ../db/dist/index.mjs
42776
41604
  import { execSync, spawnSync } from "child_process";
42777
41605
  import crypto2 from "crypto";
42778
- import path3 from "path";
41606
+ import path2 from "path";
42779
41607
  import fs2 from "fs/promises";
42780
41608
  import { readFileSync as readFileSync2 } from "fs";
42781
41609
  import path22 from "path";
@@ -43262,14 +42090,14 @@ async function seedSystemTables(db, registry2, options = {}) {
43262
42090
  }
43263
42091
  function resolvedPathEnv() {
43264
42092
  const root = process.cwd();
43265
- const localBin = path3.join(root, "node_modules", ".bin");
43266
- const existing = (process.env.PATH ?? "").split(path3.delimiter).filter(Boolean).map((entry) => path3.isAbsolute(entry) ? entry : path3.resolve(root, entry));
43267
- 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) };
43268
42096
  }
43269
42097
  async function runDevMigration(configPath) {
43270
42098
  execSync(`drizzle-kit push --config=${configPath}`, {
43271
42099
  stdio: "inherit",
43272
- cwd: path3.dirname(configPath),
42100
+ cwd: path2.dirname(configPath),
43273
42101
  env: resolvedPathEnv()
43274
42102
  });
43275
42103
  }
@@ -43282,7 +42110,7 @@ async function generateMigration(configPath, migrationsFolder) {
43282
42110
  }
43283
42111
  execSync(`drizzle-kit generate --config=${configPath}`, {
43284
42112
  stdio: "inherit",
43285
- cwd: path3.dirname(configPath),
42113
+ cwd: path2.dirname(configPath),
43286
42114
  env: resolvedPathEnv()
43287
42115
  });
43288
42116
  let afterFiles = [];
@@ -43308,13 +42136,13 @@ async function applyMigrations(configPath, db, options) {
43308
42136
  if (statusBefore.pending.length > 0) {
43309
42137
  let journalEntries = [];
43310
42138
  try {
43311
- const journalPath = path3.join(migrationsFolder, "meta", "_journal.json");
42139
+ const journalPath = path2.join(migrationsFolder, "meta", "_journal.json");
43312
42140
  const raw2 = await fs2.readFile(journalPath, "utf-8");
43313
42141
  journalEntries = JSON.parse(raw2).entries;
43314
42142
  } catch {
43315
42143
  }
43316
42144
  for (const pendingFile of statusBefore.pending) {
43317
- const sqlPath = path3.join(migrationsFolder, pendingFile);
42145
+ const sqlPath = path2.join(migrationsFolder, pendingFile);
43318
42146
  let sqlContent;
43319
42147
  try {
43320
42148
  sqlContent = await fs2.readFile(sqlPath, "utf-8");
@@ -43347,7 +42175,7 @@ async function applyMigrations(configPath, db, options) {
43347
42175
  "drizzle-kit",
43348
42176
  ["migrate", `--config=${configPath}`],
43349
42177
  {
43350
- cwd: path3.dirname(configPath),
42178
+ cwd: path2.dirname(configPath),
43351
42179
  // inherit lets drizzle-kit write its spinner and errors directly to the
43352
42180
  // terminal in real time — capturing stdout/stderr swallows ANSI overwrites
43353
42181
  // and hides the actual error message.
@@ -43373,7 +42201,7 @@ async function getMigrationStatus(db, options) {
43373
42201
  const { migrationsTable, migrationsFolder } = options;
43374
42202
  let journalEntries;
43375
42203
  try {
43376
- const journalPath = path3.join(migrationsFolder, "meta", "_journal.json");
42204
+ const journalPath = path2.join(migrationsFolder, "meta", "_journal.json");
43377
42205
  const raw2 = await fs2.readFile(journalPath, "utf-8");
43378
42206
  const journal = JSON.parse(raw2);
43379
42207
  journalEntries = journal.entries;
@@ -44361,6 +43189,7 @@ const { app } = createCmsApp({
44361
43189
  resolvers: programmaticResolvers,
44362
43190
  ...(config.api.media ? { media: config.api.media } : {}),
44363
43191
  ...(config.api.rateLimit ? { rateLimit: config.api.rateLimit } : {}),
43192
+ ...(config.api.graphql ? { graphql: config.api.graphql } : {}),
44364
43193
  ...(config.server.cors ? { cors: config.server.cors } : {}),
44365
43194
  })`;
44366
43195
  }
@@ -44992,26 +43821,26 @@ var handleParsingNestedValues = (form, key, value) => {
44992
43821
 
44993
43822
  // ../../node_modules/.pnpm/hono@4.12.28/node_modules/hono/dist/utils/url.js
44994
43823
  init_esm_shims();
44995
- var splitPath = (path4) => {
44996
- const paths = path4.split("/");
43824
+ var splitPath = (path3) => {
43825
+ const paths = path3.split("/");
44997
43826
  if (paths[0] === "") {
44998
43827
  paths.shift();
44999
43828
  }
45000
43829
  return paths;
45001
43830
  };
45002
43831
  var splitRoutingPath = (routePath) => {
45003
- const { groups, path: path4 } = extractGroupsFromPath(routePath);
45004
- const paths = splitPath(path4);
43832
+ const { groups, path: path3 } = extractGroupsFromPath(routePath);
43833
+ const paths = splitPath(path3);
45005
43834
  return replaceGroupMarks(paths, groups);
45006
43835
  };
45007
- var extractGroupsFromPath = (path4) => {
43836
+ var extractGroupsFromPath = (path3) => {
45008
43837
  const groups = [];
45009
- path4 = path4.replace(/\{[^}]+\}/g, (match2, index) => {
43838
+ path3 = path3.replace(/\{[^}]+\}/g, (match2, index) => {
45010
43839
  const mark = `@${index}`;
45011
43840
  groups.push([mark, match2]);
45012
43841
  return mark;
45013
43842
  });
45014
- return { groups, path: path4 };
43843
+ return { groups, path: path3 };
45015
43844
  };
45016
43845
  var replaceGroupMarks = (paths, groups) => {
45017
43846
  for (let i = groups.length - 1; i >= 0; i--) {
@@ -45068,8 +43897,8 @@ var getPath = (request) => {
45068
43897
  const queryIndex = url2.indexOf("?", i);
45069
43898
  const hashIndex = url2.indexOf("#", i);
45070
43899
  const end = queryIndex === -1 ? hashIndex === -1 ? void 0 : hashIndex : hashIndex === -1 ? queryIndex : Math.min(queryIndex, hashIndex);
45071
- const path4 = url2.slice(start, end);
45072
- 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);
45073
43902
  } else if (charCode === 63 || charCode === 35) {
45074
43903
  break;
45075
43904
  }
@@ -45086,11 +43915,11 @@ var mergePath = (base, sub, ...rest) => {
45086
43915
  }
45087
43916
  return `${base?.[0] === "/" ? "" : "/"}${base}${sub === "/" ? "" : `${base?.at(-1) === "/" ? "" : "/"}${sub?.[0] === "/" ? sub.slice(1) : sub}`}`;
45088
43917
  };
45089
- var checkOptionalParameter = (path4) => {
45090
- if (path4.charCodeAt(path4.length - 1) !== 63 || !path4.includes(":")) {
43918
+ var checkOptionalParameter = (path3) => {
43919
+ if (path3.charCodeAt(path3.length - 1) !== 63 || !path3.includes(":")) {
45091
43920
  return null;
45092
43921
  }
45093
- const segments = path4.split("/");
43922
+ const segments = path3.split("/");
45094
43923
  const results = [];
45095
43924
  let basePath = "";
45096
43925
  segments.forEach((segment) => {
@@ -45231,9 +44060,9 @@ var HonoRequest = class {
45231
44060
  */
45232
44061
  path;
45233
44062
  bodyCache = {};
45234
- constructor(request, path4 = "/", matchResult = [[]]) {
44063
+ constructor(request, path3 = "/", matchResult = [[]]) {
45235
44064
  this.raw = request;
45236
- this.path = path4;
44065
+ this.path = path3;
45237
44066
  this.#matchResult = matchResult;
45238
44067
  this.#validatedData = {};
45239
44068
  }
@@ -45988,8 +44817,8 @@ var Hono = class _Hono {
45988
44817
  return this;
45989
44818
  };
45990
44819
  });
45991
- this.on = (method, path4, ...handlers) => {
45992
- for (const p2 of [path4].flat()) {
44820
+ this.on = (method, path3, ...handlers) => {
44821
+ for (const p2 of [path3].flat()) {
45993
44822
  this.#path = p2;
45994
44823
  for (const m2 of [method].flat()) {
45995
44824
  handlers.map((handler) => {
@@ -46046,8 +44875,8 @@ var Hono = class _Hono {
46046
44875
  * app.route("/api", app2) // GET /api/user
46047
44876
  * ```
46048
44877
  */
46049
- route(path4, app) {
46050
- const subApp = this.basePath(path4);
44878
+ route(path3, app) {
44879
+ const subApp = this.basePath(path3);
46051
44880
  app.routes.map((r) => {
46052
44881
  let handler;
46053
44882
  if (app.errorHandler === errorHandler) {
@@ -46073,9 +44902,9 @@ var Hono = class _Hono {
46073
44902
  * const api = new Hono().basePath('/api')
46074
44903
  * ```
46075
44904
  */
46076
- basePath(path4) {
44905
+ basePath(path3) {
46077
44906
  const subApp = this.#clone();
46078
- subApp._basePath = mergePath(this._basePath, path4);
44907
+ subApp._basePath = mergePath(this._basePath, path3);
46079
44908
  return subApp;
46080
44909
  }
46081
44910
  /**
@@ -46149,7 +44978,7 @@ var Hono = class _Hono {
46149
44978
  * })
46150
44979
  * ```
46151
44980
  */
46152
- mount(path4, applicationHandler, options) {
44981
+ mount(path3, applicationHandler, options) {
46153
44982
  let replaceRequest;
46154
44983
  let optionHandler;
46155
44984
  if (options) {
@@ -46176,7 +45005,7 @@ var Hono = class _Hono {
46176
45005
  return [c.env, executionContext];
46177
45006
  };
46178
45007
  replaceRequest ||= (() => {
46179
- const mergedPath = mergePath(this._basePath, path4);
45008
+ const mergedPath = mergePath(this._basePath, path3);
46180
45009
  const pathPrefixLength = mergedPath === "/" ? 0 : mergedPath.length;
46181
45010
  return (request) => {
46182
45011
  const url2 = new URL(request.url);
@@ -46191,19 +45020,19 @@ var Hono = class _Hono {
46191
45020
  }
46192
45021
  await next();
46193
45022
  };
46194
- this.#addRoute(METHOD_NAME_ALL, mergePath(path4, "*"), handler);
45023
+ this.#addRoute(METHOD_NAME_ALL, mergePath(path3, "*"), handler);
46195
45024
  return this;
46196
45025
  }
46197
- #addRoute(method, path4, handler, baseRoutePath) {
45026
+ #addRoute(method, path3, handler, baseRoutePath) {
46198
45027
  method = method.toUpperCase();
46199
- path4 = mergePath(this._basePath, path4);
45028
+ path3 = mergePath(this._basePath, path3);
46200
45029
  const r = {
46201
45030
  basePath: baseRoutePath !== void 0 ? mergePath(this._basePath, baseRoutePath) : this._basePath,
46202
- path: path4,
45031
+ path: path3,
46203
45032
  method,
46204
45033
  handler
46205
45034
  };
46206
- this.router.add(method, path4, [handler, r]);
45035
+ this.router.add(method, path3, [handler, r]);
46207
45036
  this.routes.push(r);
46208
45037
  }
46209
45038
  #handleError(err, c) {
@@ -46216,10 +45045,10 @@ var Hono = class _Hono {
46216
45045
  if (method === "HEAD") {
46217
45046
  return (async () => new Response(null, await this.#dispatch(request, executionCtx, env, "GET")))();
46218
45047
  }
46219
- const path4 = this.getPath(request, { env });
46220
- const matchResult = this.router.match(method, path4);
45048
+ const path3 = this.getPath(request, { env });
45049
+ const matchResult = this.router.match(method, path3);
46221
45050
  const c = new Context(request, {
46222
- path: path4,
45051
+ path: path3,
46223
45052
  matchResult,
46224
45053
  env,
46225
45054
  executionCtx,
@@ -46326,7 +45155,7 @@ init_esm_shims();
46326
45155
  // ../../node_modules/.pnpm/hono@4.12.28/node_modules/hono/dist/router/reg-exp-router/matcher.js
46327
45156
  init_esm_shims();
46328
45157
  var emptyParam = [];
46329
- function match(method, path4) {
45158
+ function match(method, path3) {
46330
45159
  const matchers = this.buildAllMatchers();
46331
45160
  const match2 = ((method2, path23) => {
46332
45161
  const matcher = matchers[method2] || matchers[METHOD_NAME_ALL];
@@ -46342,7 +45171,7 @@ function match(method, path4) {
46342
45171
  return [matcher[1][index], match3];
46343
45172
  });
46344
45173
  this.match = match2;
46345
- return match2(method, path4);
45174
+ return match2(method, path3);
46346
45175
  }
46347
45176
 
46348
45177
  // ../../node_modules/.pnpm/hono@4.12.28/node_modules/hono/dist/router/reg-exp-router/node.js
@@ -46459,12 +45288,12 @@ init_esm_shims();
46459
45288
  var Trie = class {
46460
45289
  #context = { varIndex: 0 };
46461
45290
  #root = new Node();
46462
- insert(path4, index, pathErrorCheckOnly) {
45291
+ insert(path3, index, pathErrorCheckOnly) {
46463
45292
  const paramAssoc = [];
46464
45293
  const groups = [];
46465
45294
  for (let i = 0; ; ) {
46466
45295
  let replaced = false;
46467
- path4 = path4.replace(/\{[^}]+\}/g, (m2) => {
45296
+ path3 = path3.replace(/\{[^}]+\}/g, (m2) => {
46468
45297
  const mark = `@\\${i}`;
46469
45298
  groups[i] = [mark, m2];
46470
45299
  i++;
@@ -46475,7 +45304,7 @@ var Trie = class {
46475
45304
  break;
46476
45305
  }
46477
45306
  }
46478
- const tokens = path4.match(/(?::[^\/]+)|(?:\/\*$)|./g) || [];
45307
+ const tokens = path3.match(/(?::[^\/]+)|(?:\/\*$)|./g) || [];
46479
45308
  for (let i = groups.length - 1; i >= 0; i--) {
46480
45309
  const [mark] = groups[i];
46481
45310
  for (let j = tokens.length - 1; j >= 0; j--) {
@@ -46514,9 +45343,9 @@ var Trie = class {
46514
45343
  // ../../node_modules/.pnpm/hono@4.12.28/node_modules/hono/dist/router/reg-exp-router/router.js
46515
45344
  var nullMatcher = [/^$/, [], /* @__PURE__ */ Object.create(null)];
46516
45345
  var wildcardRegExpCache = /* @__PURE__ */ Object.create(null);
46517
- function buildWildcardRegExp(path4) {
46518
- return wildcardRegExpCache[path4] ??= new RegExp(
46519
- path4 === "*" ? "" : `^${path4.replace(
45346
+ function buildWildcardRegExp(path3) {
45347
+ return wildcardRegExpCache[path3] ??= new RegExp(
45348
+ path3 === "*" ? "" : `^${path3.replace(
46520
45349
  /\/\*$|([.\\+*[^\]$()])/g,
46521
45350
  (_, metaChar) => metaChar ? `\\${metaChar}` : "(?:|/.*)"
46522
45351
  )}$`
@@ -46538,17 +45367,17 @@ function buildMatcherFromPreprocessedRoutes(routes) {
46538
45367
  );
46539
45368
  const staticMap = /* @__PURE__ */ Object.create(null);
46540
45369
  for (let i = 0, j = -1, len = routesWithStaticPathFlag.length; i < len; i++) {
46541
- const [pathErrorCheckOnly, path4, handlers] = routesWithStaticPathFlag[i];
45370
+ const [pathErrorCheckOnly, path3, handlers] = routesWithStaticPathFlag[i];
46542
45371
  if (pathErrorCheckOnly) {
46543
- staticMap[path4] = [handlers.map(([h]) => [h, /* @__PURE__ */ Object.create(null)]), emptyParam];
45372
+ staticMap[path3] = [handlers.map(([h]) => [h, /* @__PURE__ */ Object.create(null)]), emptyParam];
46544
45373
  } else {
46545
45374
  j++;
46546
45375
  }
46547
45376
  let paramAssoc;
46548
45377
  try {
46549
- paramAssoc = trie.insert(path4, j, pathErrorCheckOnly);
45378
+ paramAssoc = trie.insert(path3, j, pathErrorCheckOnly);
46550
45379
  } catch (e) {
46551
- throw e === PATH_ERROR ? new UnsupportedPathError(path4) : e;
45380
+ throw e === PATH_ERROR ? new UnsupportedPathError(path3) : e;
46552
45381
  }
46553
45382
  if (pathErrorCheckOnly) {
46554
45383
  continue;
@@ -46582,12 +45411,12 @@ function buildMatcherFromPreprocessedRoutes(routes) {
46582
45411
  }
46583
45412
  return [regexp, handlerMap, staticMap];
46584
45413
  }
46585
- function findMiddleware(middleware, path4) {
45414
+ function findMiddleware(middleware, path3) {
46586
45415
  if (!middleware) {
46587
45416
  return void 0;
46588
45417
  }
46589
45418
  for (const k of Object.keys(middleware).sort((a2, b2) => b2.length - a2.length)) {
46590
- if (buildWildcardRegExp(k).test(path4)) {
45419
+ if (buildWildcardRegExp(k).test(path3)) {
46591
45420
  return [...middleware[k]];
46592
45421
  }
46593
45422
  }
@@ -46601,7 +45430,7 @@ var RegExpRouter = class {
46601
45430
  this.#middleware = { [METHOD_NAME_ALL]: /* @__PURE__ */ Object.create(null) };
46602
45431
  this.#routes = { [METHOD_NAME_ALL]: /* @__PURE__ */ Object.create(null) };
46603
45432
  }
46604
- add(method, path4, handler) {
45433
+ add(method, path3, handler) {
46605
45434
  const middleware = this.#middleware;
46606
45435
  const routes = this.#routes;
46607
45436
  if (!middleware || !routes) {
@@ -46616,18 +45445,18 @@ var RegExpRouter = class {
46616
45445
  });
46617
45446
  });
46618
45447
  }
46619
- if (path4 === "/*") {
46620
- path4 = "*";
45448
+ if (path3 === "/*") {
45449
+ path3 = "*";
46621
45450
  }
46622
- const paramCount = (path4.match(/\/:/g) || []).length;
46623
- if (/\*$/.test(path4)) {
46624
- const re = buildWildcardRegExp(path4);
45451
+ const paramCount = (path3.match(/\/:/g) || []).length;
45452
+ if (/\*$/.test(path3)) {
45453
+ const re = buildWildcardRegExp(path3);
46625
45454
  if (method === METHOD_NAME_ALL) {
46626
45455
  Object.keys(middleware).forEach((m2) => {
46627
- 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) || [];
46628
45457
  });
46629
45458
  } else {
46630
- 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) || [];
46631
45460
  }
46632
45461
  Object.keys(middleware).forEach((m2) => {
46633
45462
  if (method === METHOD_NAME_ALL || method === m2) {
@@ -46645,7 +45474,7 @@ var RegExpRouter = class {
46645
45474
  });
46646
45475
  return;
46647
45476
  }
46648
- const paths = checkOptionalParameter(path4) || [path4];
45477
+ const paths = checkOptionalParameter(path3) || [path3];
46649
45478
  for (let i = 0, len = paths.length; i < len; i++) {
46650
45479
  const path23 = paths[i];
46651
45480
  Object.keys(routes).forEach((m2) => {
@@ -46672,13 +45501,13 @@ var RegExpRouter = class {
46672
45501
  const routes = [];
46673
45502
  let hasOwnRoute = method === METHOD_NAME_ALL;
46674
45503
  [this.#middleware, this.#routes].forEach((r) => {
46675
- 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]]) : [];
46676
45505
  if (ownRoute.length !== 0) {
46677
45506
  hasOwnRoute ||= true;
46678
45507
  routes.push(...ownRoute);
46679
45508
  } else if (method !== METHOD_NAME_ALL) {
46680
45509
  routes.push(
46681
- ...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]])
46682
45511
  );
46683
45512
  }
46684
45513
  });
@@ -46705,13 +45534,13 @@ var SmartRouter = class {
46705
45534
  constructor(init) {
46706
45535
  this.#routers = init.routers;
46707
45536
  }
46708
- add(method, path4, handler) {
45537
+ add(method, path3, handler) {
46709
45538
  if (!this.#routes) {
46710
45539
  throw new Error(MESSAGE_MATCHER_IS_ALREADY_BUILT);
46711
45540
  }
46712
- this.#routes.push([method, path4, handler]);
45541
+ this.#routes.push([method, path3, handler]);
46713
45542
  }
46714
- match(method, path4) {
45543
+ match(method, path3) {
46715
45544
  if (!this.#routes) {
46716
45545
  throw new Error("Fatal error");
46717
45546
  }
@@ -46726,7 +45555,7 @@ var SmartRouter = class {
46726
45555
  for (let i2 = 0, len2 = routes.length; i2 < len2; i2++) {
46727
45556
  router.add(...routes[i2]);
46728
45557
  }
46729
- res = router.match(method, path4);
45558
+ res = router.match(method, path3);
46730
45559
  } catch (e) {
46731
45560
  if (e instanceof UnsupportedPathError) {
46732
45561
  continue;
@@ -46783,10 +45612,10 @@ var Node2 = class _Node2 {
46783
45612
  }
46784
45613
  this.#patterns = [];
46785
45614
  }
46786
- insert(method, path4, handler) {
45615
+ insert(method, path3, handler) {
46787
45616
  this.#order = ++this.#order;
46788
45617
  let curNode = this;
46789
- const parts = splitRoutingPath(path4);
45618
+ const parts = splitRoutingPath(path3);
46790
45619
  const possibleKeys = [];
46791
45620
  for (let i = 0, len = parts.length; i < len; i++) {
46792
45621
  const p2 = parts[i];
@@ -46835,12 +45664,12 @@ var Node2 = class _Node2 {
46835
45664
  }
46836
45665
  }
46837
45666
  }
46838
- search(method, path4) {
45667
+ search(method, path3) {
46839
45668
  const handlerSets = [];
46840
45669
  this.#params = emptyParams;
46841
45670
  const curNode = this;
46842
45671
  let curNodes = [curNode];
46843
- const parts = splitPath(path4);
45672
+ const parts = splitPath(path3);
46844
45673
  const curNodesQueue = [];
46845
45674
  const len = parts.length;
46846
45675
  let partOffsets = null;
@@ -46882,13 +45711,13 @@ var Node2 = class _Node2 {
46882
45711
  if (matcher instanceof RegExp) {
46883
45712
  if (partOffsets === null) {
46884
45713
  partOffsets = new Array(len);
46885
- let offset = path4[0] === "/" ? 1 : 0;
45714
+ let offset = path3[0] === "/" ? 1 : 0;
46886
45715
  for (let p2 = 0; p2 < len; p2++) {
46887
45716
  partOffsets[p2] = offset;
46888
45717
  offset += parts[p2].length + 1;
46889
45718
  }
46890
45719
  }
46891
- const restPathString = path4.substring(partOffsets[i]);
45720
+ const restPathString = path3.substring(partOffsets[i]);
46892
45721
  const m2 = matcher.exec(restPathString);
46893
45722
  if (m2) {
46894
45723
  params[name] = m2[0];
@@ -46941,18 +45770,18 @@ var TrieRouter = class {
46941
45770
  constructor() {
46942
45771
  this.#node = new Node2();
46943
45772
  }
46944
- add(method, path4, handler) {
46945
- const results = checkOptionalParameter(path4);
45773
+ add(method, path3, handler) {
45774
+ const results = checkOptionalParameter(path3);
46946
45775
  if (results) {
46947
45776
  for (let i = 0, len = results.length; i < len; i++) {
46948
45777
  this.#node.insert(method, results[i], handler);
46949
45778
  }
46950
45779
  return;
46951
45780
  }
46952
- this.#node.insert(method, path4, handler);
45781
+ this.#node.insert(method, path3, handler);
46953
45782
  }
46954
- match(method, path4) {
46955
- return this.#node.search(method, path4);
45783
+ match(method, path3) {
45784
+ return this.#node.search(method, path3);
46956
45785
  }
46957
45786
  };
46958
45787
 
@@ -47725,10 +46554,9 @@ var decode4 = Jwt.decode;
47725
46554
  var sign2 = Jwt.sign;
47726
46555
 
47727
46556
  // ../api/dist/index.mjs
47728
- import crypto3 from "crypto";
47729
46557
  import { randomBytes } from "crypto";
46558
+ import crypto3 from "crypto";
47730
46559
  import crypto22 from "crypto";
47731
- import crypto32 from "crypto";
47732
46560
  function createCorsMiddleware(corsConfig) {
47733
46561
  const allowList = Array.isArray(corsConfig.origin) ? corsConfig.origin : [corsConfig.origin];
47734
46562
  const wildcard = allowList.includes("*");
@@ -47755,26 +46583,43 @@ function createCorsMiddleware(corsConfig) {
47755
46583
  return next();
47756
46584
  };
47757
46585
  }
46586
+ var GRAPHIQL_CDN = "https://unpkg.com";
47758
46587
  function createSecurityHeadersMiddleware(options = {}) {
47759
46588
  const connectSrc = ["'self'", ...options.connectSrc ?? []].join(" ");
47760
- const csp = [
47761
- "default-src 'self'",
47762
- "img-src 'self' data: https:",
47763
- "media-src 'self' https:",
47764
- "style-src 'self' 'unsafe-inline'",
47765
- "script-src 'self'",
47766
- "font-src 'self' data:",
47767
- `connect-src ${connectSrc}`,
47768
- "frame-ancestors 'none'",
47769
- "base-uri 'self'",
47770
- "form-action 'self'"
47771
- ].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;
47772
46616
  return async function securityHeaders(c, next) {
47773
46617
  await next();
47774
46618
  c.res.headers.set("X-Content-Type-Options", "nosniff");
47775
46619
  c.res.headers.set("X-Frame-Options", "DENY");
47776
46620
  c.res.headers.set("Referrer-Policy", "no-referrer");
47777
- 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);
47778
46623
  };
47779
46624
  }
47780
46625
  var ERROR_STATUS_MAP = {
@@ -47849,8 +46694,8 @@ function setAuthCookie(c, name, token, options) {
47849
46694
  sameSite: "Strict"
47850
46695
  });
47851
46696
  }
47852
- function clearAuthCookie(c, name, path4) {
47853
- 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);
47854
46699
  }
47855
46700
  function createAuthMiddleware(db) {
47856
46701
  return async (c, next) => {
@@ -48307,11 +47152,11 @@ function isPublished(item) {
48307
47152
  return item["published"] === true;
48308
47153
  }
48309
47154
  function registerPublicContentRoutes(app, registry2, repos, listRateLimit, resolver) {
48310
- function registerListRoute(path4, handler) {
47155
+ function registerListRoute(path3, handler) {
48311
47156
  if (listRateLimit) {
48312
- app.get(path4, listRateLimit, handler);
47157
+ app.get(path3, listRateLimit, handler);
48313
47158
  } else {
48314
- app.get(path4, handler);
47159
+ app.get(path3, handler);
48315
47160
  }
48316
47161
  }
48317
47162
  registerListRoute("/api/content", (c) => {
@@ -48613,223 +47458,6 @@ function quoteIdent(name) {
48613
47458
  if (!/^[a-z][a-z0-9_-]*$/.test(name)) throw new Error(`Unsafe identifier: ${name}`);
48614
47459
  return `"${name}"`;
48615
47460
  }
48616
- function paragraphMediaFieldNames(pType) {
48617
- return new Set(
48618
- pType.fields.filter((f) => f.field_type === "image" || f.field_type === "video" || f.field_type === "file").map((f) => f.name)
48619
- );
48620
- }
48621
- async function fetchParagraphMediaIds(db, pType, itemId, fieldName) {
48622
- 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);
48623
- if (mediaColumns.length === 0) return [];
48624
- const tbl = sql.raw(quoteIdent(pType.db.table_name));
48625
- const cols = sql.join(mediaColumns.map((c) => sql.raw(quoteIdent(c))), sql`, `);
48626
- const result = await db.execute(
48627
- sql`SELECT ${cols} FROM ${tbl} WHERE parent_id = ${itemId} AND parent_field = ${fieldName}`
48628
- );
48629
- const ids = [];
48630
- for (const row of result.rows) {
48631
- for (const col of mediaColumns) {
48632
- const v2 = row[col];
48633
- if (typeof v2 === "string" && v2 !== "") ids.push(v2);
48634
- }
48635
- }
48636
- return ids;
48637
- }
48638
- async function persistParagraphField(db, itemId, parentType, fieldName, pType, items) {
48639
- const removed = await fetchParagraphMediaIds(db, pType, itemId, fieldName);
48640
- const tbl = sql.raw(quoteIdent(pType.db.table_name));
48641
- await db.execute(sql`DELETE FROM ${tbl} WHERE parent_id = ${itemId} AND parent_field = ${fieldName}`);
48642
- const mediaFieldNames = paragraphMediaFieldNames(pType);
48643
- const added = [];
48644
- for (let i = 0; i < items.length; i++) {
48645
- const pItem = items[i];
48646
- const data = {
48647
- id: crypto3.randomUUID(),
48648
- parent_id: itemId,
48649
- parent_type: parentType,
48650
- parent_field: fieldName,
48651
- order: i,
48652
- created_at: /* @__PURE__ */ new Date(),
48653
- updated_at: /* @__PURE__ */ new Date()
48654
- };
48655
- for (const pf of pType.fields) {
48656
- if (!pf.db_column || pf.db_column.junction) continue;
48657
- data[pf.db_column.column_name] = pItem[pf.name] ?? null;
48658
- }
48659
- const cols = sql.join(Object.keys(data).map((k) => sql.raw(quoteIdent(k))), sql`, `);
48660
- const vals = sql.join(Object.values(data).map((v2) => sql`${v2}`), sql`, `);
48661
- await db.execute(sql`INSERT INTO ${tbl} (${cols}) VALUES (${vals})`);
48662
- for (const name of mediaFieldNames) {
48663
- const val = pItem[name];
48664
- if (typeof val === "string" && val !== "") added.push(val);
48665
- }
48666
- }
48667
- return { added, removed };
48668
- }
48669
- async function deleteParagraphField(db, itemId, fieldName, pType) {
48670
- const removed = await fetchParagraphMediaIds(db, pType, itemId, fieldName);
48671
- const tbl = sql.raw(quoteIdent(pType.db.table_name));
48672
- await db.execute(sql`DELETE FROM ${tbl} WHERE parent_id = ${itemId} AND parent_field = ${fieldName}`);
48673
- return { added: [], removed };
48674
- }
48675
- async function persistJunctionField(db, itemId, junction, relatedIds) {
48676
- const tbl = sql.raw(quoteIdent(junction.table_name));
48677
- const left = sql.raw(quoteIdent(junction.left_column));
48678
- const right = sql.raw(quoteIdent(junction.right_column));
48679
- await db.execute(sql`DELETE FROM ${tbl} WHERE ${left} = ${itemId}`);
48680
- for (const rid of relatedIds) {
48681
- await db.execute(sql`INSERT INTO ${tbl} (${left}, ${right}) VALUES (${itemId}, ${rid})`);
48682
- }
48683
- }
48684
- function buildRelationsMap(fields, registry2) {
48685
- const relations = {};
48686
- for (const field of fields) {
48687
- if (field.field_type === "image" || field.field_type === "video" || field.field_type === "file") {
48688
- if (!field.db_column) continue;
48689
- relations[field.name] = { type: "media", fk_column: field.db_column.column_name };
48690
- } else if (field.field_type === "paragraph") {
48691
- const ref = field.ui_component.ref;
48692
- const pType = ref ? registry2.paragraph_types[ref] : void 0;
48693
- if (!pType) continue;
48694
- relations[field.name] = { type: "paragraph", table: pType.db.table_name };
48695
- } else if (field.field_type === "reference") {
48696
- if (!field.db_column) continue;
48697
- if (field.db_column.junction) {
48698
- const j = field.db_column.junction;
48699
- relations[field.name] = {
48700
- type: "junction",
48701
- table: j.right_table,
48702
- junction_table: j.table_name,
48703
- left_column: j.left_column,
48704
- right_column: j.right_column,
48705
- order_column: j.order_column
48706
- };
48707
- } else if (field.db_column.foreign_key) {
48708
- relations[field.name] = {
48709
- type: "reference",
48710
- table: field.db_column.foreign_key.table,
48711
- fk_column: field.db_column.column_name
48712
- };
48713
- }
48714
- }
48715
- }
48716
- return relations;
48717
- }
48718
- function groupBy(items, key) {
48719
- const result = {};
48720
- for (const item of items) {
48721
- const k = String(item[key]);
48722
- if (!result[k]) result[k] = [];
48723
- result[k].push(item);
48724
- }
48725
- return result;
48726
- }
48727
- async function resolveRelationField(db, rows, fieldName, rel, cache) {
48728
- if (rows.length === 0) return;
48729
- if (rel.type === "paragraph") {
48730
- const parentIds = rows.map((r) => r["id"]);
48731
- const inList = sql.join(parentIds.map((id) => sql`${id}`), sql`, `);
48732
- const result = await db.execute(
48733
- sql`SELECT * FROM ${sql.raw(quoteIdent(rel.table))} WHERE parent_id IN (${inList}) ORDER BY "order" ASC`
48734
- );
48735
- const byParent = groupBy(result.rows, "parent_id");
48736
- for (const row of rows) {
48737
- row[fieldName] = byParent[row["id"]] ?? [];
48738
- }
48739
- } else if (rel.type === "reference") {
48740
- const fkValues = rows.map((r) => r[rel.fk_column]).filter(Boolean);
48741
- if (fkValues.length === 0) {
48742
- for (const row of rows) row[fieldName] = null;
48743
- return;
48744
- }
48745
- const unique = [...new Set(fkValues)];
48746
- const uncached = unique.filter((id) => !cache.has(`${rel.table}:${id}`));
48747
- if (uncached.length > 0) {
48748
- const inList = sql.join(uncached.map((id) => sql`${id}`), sql`, `);
48749
- const result = await db.execute(
48750
- sql`SELECT * FROM ${sql.raw(quoteIdent(rel.table))} WHERE id IN (${inList})`
48751
- );
48752
- for (const item of result.rows) {
48753
- cache.set(`${rel.table}:${item["id"]}`, item);
48754
- }
48755
- }
48756
- for (const row of rows) {
48757
- const fkVal = row[rel.fk_column];
48758
- row[fieldName] = fkVal ? cache.get(`${rel.table}:${fkVal}`) ?? null : null;
48759
- }
48760
- } else if (rel.type === "junction") {
48761
- const parentIds = rows.map((r) => r["id"]);
48762
- const inList = sql.join(parentIds.map((id) => sql`${id}`), sql`, `);
48763
- const orderBy = rel.order_column ? sql` ORDER BY "order" ASC` : sql``;
48764
- const junctionResult = await db.execute(
48765
- sql`SELECT * FROM ${sql.raw(quoteIdent(rel.junction_table))} WHERE ${sql.raw(quoteIdent(rel.left_column))} IN (${inList})${orderBy}`
48766
- );
48767
- const jRows = junctionResult.rows;
48768
- const rightIds = [...new Set(jRows.map((r) => r[rel.right_column]))];
48769
- const uncached = rightIds.filter((id) => !cache.has(`${rel.table}:${id}`));
48770
- if (uncached.length > 0) {
48771
- const rightInList = sql.join(uncached.map((id) => sql`${id}`), sql`, `);
48772
- const entitiesResult = await db.execute(
48773
- sql`SELECT * FROM ${sql.raw(quoteIdent(rel.table))} WHERE id IN (${rightInList})`
48774
- );
48775
- for (const item of entitiesResult.rows) {
48776
- cache.set(`${rel.table}:${item["id"]}`, item);
48777
- }
48778
- }
48779
- const byLeft = groupBy(jRows, rel.left_column);
48780
- for (const row of rows) {
48781
- const jEntries = byLeft[row["id"]] ?? [];
48782
- row[fieldName] = jEntries.map((jr) => cache.get(`${rel.table}:${jr[rel.right_column]}`)).filter(Boolean);
48783
- }
48784
- } else if (rel.type === "media") {
48785
- const fkValues = rows.map((r) => r[rel.fk_column]).filter(Boolean);
48786
- if (fkValues.length === 0) {
48787
- for (const row of rows) row[fieldName] = null;
48788
- return;
48789
- }
48790
- const unique = [...new Set(fkValues)];
48791
- const uncached = unique.filter((id) => !cache.has(`media:${id}`));
48792
- if (uncached.length > 0) {
48793
- const inList = sql.join(uncached.map((id) => sql`${id}`), sql`, `);
48794
- const result = await db.execute(sql`SELECT * FROM "media" WHERE id IN (${inList})`);
48795
- for (const item of result.rows) {
48796
- cache.set(`media:${item["id"]}`, item);
48797
- }
48798
- }
48799
- for (const row of rows) {
48800
- const fkVal = row[rel.fk_column];
48801
- row[fieldName] = fkVal ? cache.get(`media:${fkVal}`) ?? null : null;
48802
- }
48803
- }
48804
- }
48805
- async function resolveRelationBareIds(db, rows, fieldName, rel) {
48806
- if (rows.length === 0) return;
48807
- if (rel.type === "paragraph") {
48808
- const parentIds = rows.map((r) => r["id"]);
48809
- const inList = sql.join(parentIds.map((id) => sql`${id}`), sql`, `);
48810
- const result = await db.execute(
48811
- sql`SELECT id, parent_id FROM ${sql.raw(quoteIdent(rel.table))} WHERE parent_id IN (${inList}) ORDER BY "order" ASC`
48812
- );
48813
- const byParent = groupBy(result.rows, "parent_id");
48814
- for (const row of rows) {
48815
- row[fieldName] = (byParent[row["id"]] ?? []).map((r) => r["id"]);
48816
- }
48817
- } else if (rel.type === "junction") {
48818
- const parentIds = rows.map((r) => r["id"]);
48819
- const inList = sql.join(parentIds.map((id) => sql`${id}`), sql`, `);
48820
- const result = await db.execute(
48821
- 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})`
48822
- );
48823
- const byLeft = groupBy(result.rows, "left_id");
48824
- for (const row of rows) {
48825
- row[fieldName] = (byLeft[row["id"]] ?? []).map((r) => r["right_id"]);
48826
- }
48827
- }
48828
- }
48829
- function quoteIdent2(name) {
48830
- if (!/^[a-z][a-z0-9_-]*$/.test(name)) throw new Error(`Unsafe identifier: ${name}`);
48831
- return `"${name}"`;
48832
- }
48833
47461
  async function lookupBasePathId(db, pathOrName) {
48834
47462
  const r = await db.execute(
48835
47463
  sql`SELECT id FROM base_paths WHERE path = ${pathOrName} OR name = ${pathOrName} LIMIT 1`
@@ -48982,13 +47610,13 @@ function registerAdminContentRoutes(app, registry2, repos, mediaRepo, requirePer
48982
47610
  const pType = registry2.paragraph_types[comp.ref];
48983
47611
  if (!pType) continue;
48984
47612
  const r = await db.execute(
48985
- 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`
48986
47614
  );
48987
47615
  row[f.name] = r.rows;
48988
47616
  } else if (f.db_column.junction) {
48989
47617
  const j = f.db_column.junction;
48990
47618
  const r = await db.execute(
48991
- 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}`
48992
47620
  );
48993
47621
  row[f.name] = r.rows.map(
48994
47622
  (row2) => row2[j.right_column]
@@ -50436,7 +49064,7 @@ function registerUserRoutes(app, db, requirePermission, requireHierarchy) {
50436
49064
  }
50437
49065
  var API_VERSION = (() => {
50438
49066
  try {
50439
- return "0.2.0";
49067
+ return "0.3.0";
50440
49068
  } catch {
50441
49069
  return "0.0.0";
50442
49070
  }
@@ -50542,7 +49170,7 @@ function codeError(code, message) {
50542
49170
  err.code = code;
50543
49171
  return err;
50544
49172
  }
50545
- function quoteIdent3(name) {
49173
+ function quoteIdent2(name) {
50546
49174
  if (!/^[a-z][a-z0-9_-]*$/.test(name)) {
50547
49175
  throw new Error(`Unsafe SQL identifier: ${name}`);
50548
49176
  }
@@ -50591,9 +49219,9 @@ function whereFragment(conds) {
50591
49219
  return conds.length > 0 ? sql` WHERE ${sql.join(conds, sql` AND `)}` : sql``;
50592
49220
  }
50593
49221
  function createDrizzleContentRepository(db, tableName, options = {}) {
50594
- const { relations = {} } = options;
49222
+ const { relations = {}, publishedRelations = false } = options;
50595
49223
  function tableRaw() {
50596
- return sql.raw(quoteIdent3(tableName));
49224
+ return sql.raw(quoteIdent2(tableName));
50597
49225
  }
50598
49226
  async function resolveRows(rows, include, cache) {
50599
49227
  if (rows.length === 0) return rows;
@@ -50604,7 +49232,7 @@ function createDrizzleContentRepository(db, tableName, options = {}) {
50604
49232
  }
50605
49233
  for (const [fieldName, rel] of Object.entries(relations)) {
50606
49234
  if (rel.type === "media") {
50607
- await resolveRelationField(db, rows, fieldName, rel, cache);
49235
+ await resolveRelationField(db, rows, fieldName, rel, cache, publishedRelations);
50608
49236
  } else if (!include.includes(fieldName)) {
50609
49237
  await resolveRelationBareIds(db, rows, fieldName, rel);
50610
49238
  }
@@ -50612,7 +49240,7 @@ function createDrizzleContentRepository(db, tableName, options = {}) {
50612
49240
  for (const fieldName of include) {
50613
49241
  const rel = relations[fieldName];
50614
49242
  if (rel.type !== "media") {
50615
- await resolveRelationField(db, rows, fieldName, rel, cache);
49243
+ await resolveRelationField(db, rows, fieldName, rel, cache, publishedRelations);
50616
49244
  }
50617
49245
  }
50618
49246
  return rows;
@@ -50635,7 +49263,7 @@ function createDrizzleContentRepository(db, tableName, options = {}) {
50635
49263
  const offset = (page - 1) * per_page;
50636
49264
  const conds = buildConditions(published_only, filters, search);
50637
49265
  const where = whereFragment(conds);
50638
- const sortCol = sql.raw(quoteIdent3(sort_by));
49266
+ const sortCol = sql.raw(quoteIdent2(sort_by));
50639
49267
  const sortDir = sql.raw(sort_order === "desc" ? "DESC" : "ASC");
50640
49268
  const countResult = await db.execute(
50641
49269
  sql`SELECT COUNT(*) AS total FROM ${tableRaw()}${where}`
@@ -50684,12 +49312,12 @@ function createDrizzleContentRepository(db, tableName, options = {}) {
50684
49312
  async create(data) {
50685
49313
  const record2 = {
50686
49314
  ...data,
50687
- id: crypto22.randomUUID(),
49315
+ id: crypto3.randomUUID(),
50688
49316
  created_at: /* @__PURE__ */ new Date(),
50689
49317
  updated_at: /* @__PURE__ */ new Date()
50690
49318
  };
50691
49319
  const entries = Object.entries(record2).filter(([, v2]) => v2 !== void 0);
50692
- 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`, `);
50693
49321
  const valsSql = sql.join(entries.map(([, v2]) => sql`${v2}`), sql`, `);
50694
49322
  const result = await db.execute(
50695
49323
  sql`INSERT INTO ${tableRaw()} (${colsSql}) VALUES (${valsSql}) RETURNING *`
@@ -50706,7 +49334,7 @@ function createDrizzleContentRepository(db, tableName, options = {}) {
50706
49334
  return this.findOne(id);
50707
49335
  }
50708
49336
  const setClauses = sql.join(
50709
- entries.map(([k, v2]) => sql`${sql.raw(quoteIdent3(k))} = ${v2}`),
49337
+ entries.map(([k, v2]) => sql`${sql.raw(quoteIdent2(k))} = ${v2}`),
50710
49338
  sql`, `
50711
49339
  );
50712
49340
  const result = await db.execute(
@@ -50773,7 +49401,7 @@ function createMediaRepository(db) {
50773
49401
  async create(data) {
50774
49402
  const record2 = {
50775
49403
  ...data,
50776
- id: crypto32.randomUUID(),
49404
+ id: crypto22.randomUUID(),
50777
49405
  reference_count: 0,
50778
49406
  created_at: /* @__PURE__ */ new Date(),
50779
49407
  updated_at: /* @__PURE__ */ new Date()
@@ -50844,7 +49472,14 @@ function createCmsApp(options) {
50844
49472
  const programmaticResolver = createProgrammaticResolver(resolverMap);
50845
49473
  const app = new Hono2();
50846
49474
  const uploadOrigins = storage.getUploadOrigins?.() ?? [];
50847
- 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
+ );
50848
49483
  app.use("*", createCorsMiddleware(cors ?? { origin: "*", enabled: true }));
50849
49484
  app.onError(errorHandler2);
50850
49485
  const listRateLimit = resolveListRateLimit(rateLimit);
@@ -50879,7 +49514,8 @@ function createCmsApp(options) {
50879
49514
  Object.entries(registry2.content_types).map(([typeName, ct2]) => [
50880
49515
  typeName,
50881
49516
  createDrizzleContentRepository(db, ct2.db.table_name, {
50882
- relations: buildRelationsMap(ct2.fields, registry2)
49517
+ relations: buildRelationsMap(ct2.fields, registry2),
49518
+ publishedRelations: true
50883
49519
  })
50884
49520
  ])
50885
49521
  );
@@ -50887,7 +49523,8 @@ function createCmsApp(options) {
50887
49523
  Object.entries(registry2.taxonomy_types).map(([typeName, tt2]) => [
50888
49524
  typeName,
50889
49525
  createDrizzleContentRepository(db, tt2.db.table_name, {
50890
- relations: buildRelationsMap(tt2.fields, registry2)
49526
+ relations: buildRelationsMap(tt2.fields, registry2),
49527
+ publishedRelations: true
50891
49528
  })
50892
49529
  ])
50893
49530
  );
@@ -50928,6 +49565,35 @@ function createCmsApp(options) {
50928
49565
  );
50929
49566
  registerPublicContentRoutes(app, registry2, publicRepos, listRateLimit, programmaticResolver);
50930
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
+ }
50931
49597
  registerConfigRoute(
50932
49598
  app,
50933
49599
  {
@@ -51001,6 +49667,16 @@ async function generateNav(registry2, targetDir) {
51001
49667
  await writeFile7(join9(targetDir, "nav.ts"), content, "utf8");
51002
49668
  }
51003
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);
49678
+ }
49679
+
51004
49680
  // src/utils/db.ts
51005
49681
  init_esm_shims();
51006
49682
  async function connectDb(_config) {
@@ -51163,6 +49839,7 @@ async function runDev(options, deps) {
51163
49839
  ...config3.api.prefix ? { prefix: config3.api.prefix } : {},
51164
49840
  ...config3.api.media?.max_file_size ? { media: { max_file_size: config3.api.media.max_file_size } } : {},
51165
49841
  ...config3.api.rateLimit ? { rateLimit: config3.api.rateLimit } : {},
49842
+ ...config3.api.graphql ? { graphql: config3.api.graphql } : {},
51166
49843
  ...config3.server.cors ? { cors: config3.server.cors } : {}
51167
49844
  });
51168
49845
  let honoFetch = (req) => adapter.app.fetch(req);
@@ -51185,7 +49862,7 @@ async function runDev(options, deps) {
51185
49862
  const httpServer = createHttpServer(async (req, res) => {
51186
49863
  try {
51187
49864
  const url2 = req.url ?? "/";
51188
- if (url2.startsWith(apiPrefix) || url2.startsWith("/admin/api")) {
49865
+ if (shouldBridgeToHono(url2, apiPrefix)) {
51189
49866
  await bridgeToHono(req, res, honoFetch);
51190
49867
  return;
51191
49868
  }
@@ -51306,6 +49983,7 @@ async function onSchemaFileChange(args) {
51306
49983
  ...config3.api.prefix ? { prefix: config3.api.prefix } : {},
51307
49984
  ...config3.api.media?.max_file_size ? { media: { max_file_size: config3.api.media.max_file_size } } : {},
51308
49985
  ...config3.api.rateLimit ? { rateLimit: config3.api.rateLimit } : {},
49986
+ ...config3.api.graphql ? { graphql: config3.api.graphql } : {},
51309
49987
  ...config3.server.cors ? { cors: config3.server.cors } : {}
51310
49988
  });
51311
49989
  updateFetch((req) => newAdapter.app.fetch(req));
@@ -52008,8 +50686,8 @@ async function runUsersDemote(options, deps) {
52008
50686
 
52009
50687
  // src/index.ts
52010
50688
  var require2 = createRequire3(import.meta.url);
52011
- var { version: version3 } = require2("../package.json");
52012
- 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);
52013
50691
  registerBuild(program);
52014
50692
  registerDev(program);
52015
50693
  registerStart(program);