@bobbykim/manguito-cms-cli 0.4.5 → 0.5.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
|
@@ -38,7 +38,7 @@ import {
|
|
|
38
38
|
resolveRelationField,
|
|
39
39
|
sql,
|
|
40
40
|
tracer
|
|
41
|
-
} from "./chunk-
|
|
41
|
+
} from "./chunk-LFMOJRYP.js";
|
|
42
42
|
|
|
43
43
|
// ../../node_modules/.pnpm/yaml@2.9.0/node_modules/yaml/dist/nodes/identity.js
|
|
44
44
|
var require_identity = __commonJS({
|
|
@@ -119,17 +119,17 @@ var require_visit = __commonJS({
|
|
|
119
119
|
visit.BREAK = BREAK;
|
|
120
120
|
visit.SKIP = SKIP;
|
|
121
121
|
visit.REMOVE = REMOVE;
|
|
122
|
-
function visit_(key, node, visitor,
|
|
123
|
-
const ctrl = callVisitor(key, node, visitor,
|
|
122
|
+
function visit_(key, node, visitor, path7) {
|
|
123
|
+
const ctrl = callVisitor(key, node, visitor, path7);
|
|
124
124
|
if (identity.isNode(ctrl) || identity.isPair(ctrl)) {
|
|
125
|
-
replaceNode(key,
|
|
126
|
-
return visit_(key, ctrl, visitor,
|
|
125
|
+
replaceNode(key, path7, ctrl);
|
|
126
|
+
return visit_(key, ctrl, visitor, path7);
|
|
127
127
|
}
|
|
128
128
|
if (typeof ctrl !== "symbol") {
|
|
129
129
|
if (identity.isCollection(node)) {
|
|
130
|
-
|
|
130
|
+
path7 = Object.freeze(path7.concat(node));
|
|
131
131
|
for (let i = 0; i < node.items.length; ++i) {
|
|
132
|
-
const ci = visit_(i, node.items[i], visitor,
|
|
132
|
+
const ci = visit_(i, node.items[i], visitor, path7);
|
|
133
133
|
if (typeof ci === "number")
|
|
134
134
|
i = ci - 1;
|
|
135
135
|
else if (ci === BREAK)
|
|
@@ -140,13 +140,13 @@ var require_visit = __commonJS({
|
|
|
140
140
|
}
|
|
141
141
|
}
|
|
142
142
|
} else if (identity.isPair(node)) {
|
|
143
|
-
|
|
144
|
-
const ck = visit_("key", node.key, visitor,
|
|
143
|
+
path7 = Object.freeze(path7.concat(node));
|
|
144
|
+
const ck = visit_("key", node.key, visitor, path7);
|
|
145
145
|
if (ck === BREAK)
|
|
146
146
|
return BREAK;
|
|
147
147
|
else if (ck === REMOVE)
|
|
148
148
|
node.key = null;
|
|
149
|
-
const cv = visit_("value", node.value, visitor,
|
|
149
|
+
const cv = visit_("value", node.value, visitor, path7);
|
|
150
150
|
if (cv === BREAK)
|
|
151
151
|
return BREAK;
|
|
152
152
|
else if (cv === REMOVE)
|
|
@@ -167,17 +167,17 @@ var require_visit = __commonJS({
|
|
|
167
167
|
visitAsync.BREAK = BREAK;
|
|
168
168
|
visitAsync.SKIP = SKIP;
|
|
169
169
|
visitAsync.REMOVE = REMOVE;
|
|
170
|
-
async function visitAsync_(key, node, visitor,
|
|
171
|
-
const ctrl = await callVisitor(key, node, visitor,
|
|
170
|
+
async function visitAsync_(key, node, visitor, path7) {
|
|
171
|
+
const ctrl = await callVisitor(key, node, visitor, path7);
|
|
172
172
|
if (identity.isNode(ctrl) || identity.isPair(ctrl)) {
|
|
173
|
-
replaceNode(key,
|
|
174
|
-
return visitAsync_(key, ctrl, visitor,
|
|
173
|
+
replaceNode(key, path7, ctrl);
|
|
174
|
+
return visitAsync_(key, ctrl, visitor, path7);
|
|
175
175
|
}
|
|
176
176
|
if (typeof ctrl !== "symbol") {
|
|
177
177
|
if (identity.isCollection(node)) {
|
|
178
|
-
|
|
178
|
+
path7 = Object.freeze(path7.concat(node));
|
|
179
179
|
for (let i = 0; i < node.items.length; ++i) {
|
|
180
|
-
const ci = await visitAsync_(i, node.items[i], visitor,
|
|
180
|
+
const ci = await visitAsync_(i, node.items[i], visitor, path7);
|
|
181
181
|
if (typeof ci === "number")
|
|
182
182
|
i = ci - 1;
|
|
183
183
|
else if (ci === BREAK)
|
|
@@ -188,13 +188,13 @@ var require_visit = __commonJS({
|
|
|
188
188
|
}
|
|
189
189
|
}
|
|
190
190
|
} else if (identity.isPair(node)) {
|
|
191
|
-
|
|
192
|
-
const ck = await visitAsync_("key", node.key, visitor,
|
|
191
|
+
path7 = Object.freeze(path7.concat(node));
|
|
192
|
+
const ck = await visitAsync_("key", node.key, visitor, path7);
|
|
193
193
|
if (ck === BREAK)
|
|
194
194
|
return BREAK;
|
|
195
195
|
else if (ck === REMOVE)
|
|
196
196
|
node.key = null;
|
|
197
|
-
const cv = await visitAsync_("value", node.value, visitor,
|
|
197
|
+
const cv = await visitAsync_("value", node.value, visitor, path7);
|
|
198
198
|
if (cv === BREAK)
|
|
199
199
|
return BREAK;
|
|
200
200
|
else if (cv === REMOVE)
|
|
@@ -221,23 +221,23 @@ var require_visit = __commonJS({
|
|
|
221
221
|
}
|
|
222
222
|
return visitor;
|
|
223
223
|
}
|
|
224
|
-
function callVisitor(key, node, visitor,
|
|
224
|
+
function callVisitor(key, node, visitor, path7) {
|
|
225
225
|
if (typeof visitor === "function")
|
|
226
|
-
return visitor(key, node,
|
|
226
|
+
return visitor(key, node, path7);
|
|
227
227
|
if (identity.isMap(node))
|
|
228
|
-
return visitor.Map?.(key, node,
|
|
228
|
+
return visitor.Map?.(key, node, path7);
|
|
229
229
|
if (identity.isSeq(node))
|
|
230
|
-
return visitor.Seq?.(key, node,
|
|
230
|
+
return visitor.Seq?.(key, node, path7);
|
|
231
231
|
if (identity.isPair(node))
|
|
232
|
-
return visitor.Pair?.(key, node,
|
|
232
|
+
return visitor.Pair?.(key, node, path7);
|
|
233
233
|
if (identity.isScalar(node))
|
|
234
|
-
return visitor.Scalar?.(key, node,
|
|
234
|
+
return visitor.Scalar?.(key, node, path7);
|
|
235
235
|
if (identity.isAlias(node))
|
|
236
|
-
return visitor.Alias?.(key, node,
|
|
236
|
+
return visitor.Alias?.(key, node, path7);
|
|
237
237
|
return void 0;
|
|
238
238
|
}
|
|
239
|
-
function replaceNode(key,
|
|
240
|
-
const parent =
|
|
239
|
+
function replaceNode(key, path7, node) {
|
|
240
|
+
const parent = path7[path7.length - 1];
|
|
241
241
|
if (identity.isCollection(parent)) {
|
|
242
242
|
parent.items[key] = node;
|
|
243
243
|
} else if (identity.isPair(parent)) {
|
|
@@ -856,10 +856,10 @@ var require_Collection = __commonJS({
|
|
|
856
856
|
var createNode = require_createNode();
|
|
857
857
|
var identity = require_identity();
|
|
858
858
|
var Node3 = require_Node();
|
|
859
|
-
function collectionFromPath(schema,
|
|
859
|
+
function collectionFromPath(schema, path7, value) {
|
|
860
860
|
let v2 = value;
|
|
861
|
-
for (let i =
|
|
862
|
-
const k =
|
|
861
|
+
for (let i = path7.length - 1; i >= 0; --i) {
|
|
862
|
+
const k = path7[i];
|
|
863
863
|
if (typeof k === "number" && Number.isInteger(k) && k >= 0) {
|
|
864
864
|
const a2 = [];
|
|
865
865
|
a2[k] = v2;
|
|
@@ -878,7 +878,7 @@ var require_Collection = __commonJS({
|
|
|
878
878
|
sourceObjects: /* @__PURE__ */ new Map()
|
|
879
879
|
});
|
|
880
880
|
}
|
|
881
|
-
var isEmptyPath = (
|
|
881
|
+
var isEmptyPath = (path7) => path7 == null || typeof path7 === "object" && !!path7[Symbol.iterator]().next().done;
|
|
882
882
|
var Collection = class extends Node3.NodeBase {
|
|
883
883
|
constructor(type, schema) {
|
|
884
884
|
super(type);
|
|
@@ -908,11 +908,11 @@ var require_Collection = __commonJS({
|
|
|
908
908
|
* be a Pair instance or a `{ key, value }` object, which may not have a key
|
|
909
909
|
* that already exists in the map.
|
|
910
910
|
*/
|
|
911
|
-
addIn(
|
|
912
|
-
if (isEmptyPath(
|
|
911
|
+
addIn(path7, value) {
|
|
912
|
+
if (isEmptyPath(path7))
|
|
913
913
|
this.add(value);
|
|
914
914
|
else {
|
|
915
|
-
const [key, ...rest] =
|
|
915
|
+
const [key, ...rest] = path7;
|
|
916
916
|
const node = this.get(key, true);
|
|
917
917
|
if (identity.isCollection(node))
|
|
918
918
|
node.addIn(rest, value);
|
|
@@ -926,8 +926,8 @@ var require_Collection = __commonJS({
|
|
|
926
926
|
* Removes a value from the collection.
|
|
927
927
|
* @returns `true` if the item was found and removed.
|
|
928
928
|
*/
|
|
929
|
-
deleteIn(
|
|
930
|
-
const [key, ...rest] =
|
|
929
|
+
deleteIn(path7) {
|
|
930
|
+
const [key, ...rest] = path7;
|
|
931
931
|
if (rest.length === 0)
|
|
932
932
|
return this.delete(key);
|
|
933
933
|
const node = this.get(key, true);
|
|
@@ -941,8 +941,8 @@ var require_Collection = __commonJS({
|
|
|
941
941
|
* scalar values from their surrounding node; to disable set `keepScalar` to
|
|
942
942
|
* `true` (collections are always returned intact).
|
|
943
943
|
*/
|
|
944
|
-
getIn(
|
|
945
|
-
const [key, ...rest] =
|
|
944
|
+
getIn(path7, keepScalar) {
|
|
945
|
+
const [key, ...rest] = path7;
|
|
946
946
|
const node = this.get(key, true);
|
|
947
947
|
if (rest.length === 0)
|
|
948
948
|
return !keepScalar && identity.isScalar(node) ? node.value : node;
|
|
@@ -960,8 +960,8 @@ var require_Collection = __commonJS({
|
|
|
960
960
|
/**
|
|
961
961
|
* Checks if the collection includes a value with the key `key`.
|
|
962
962
|
*/
|
|
963
|
-
hasIn(
|
|
964
|
-
const [key, ...rest] =
|
|
963
|
+
hasIn(path7) {
|
|
964
|
+
const [key, ...rest] = path7;
|
|
965
965
|
if (rest.length === 0)
|
|
966
966
|
return this.has(key);
|
|
967
967
|
const node = this.get(key, true);
|
|
@@ -971,8 +971,8 @@ var require_Collection = __commonJS({
|
|
|
971
971
|
* Sets a value in this collection. For `!!set`, `value` needs to be a
|
|
972
972
|
* boolean to add/remove the item from the set.
|
|
973
973
|
*/
|
|
974
|
-
setIn(
|
|
975
|
-
const [key, ...rest] =
|
|
974
|
+
setIn(path7, value) {
|
|
975
|
+
const [key, ...rest] = path7;
|
|
976
976
|
if (rest.length === 0) {
|
|
977
977
|
this.set(key, value);
|
|
978
978
|
} else {
|
|
@@ -3522,9 +3522,9 @@ var require_Document = __commonJS({
|
|
|
3522
3522
|
this.contents.add(value);
|
|
3523
3523
|
}
|
|
3524
3524
|
/** Adds a value to the document. */
|
|
3525
|
-
addIn(
|
|
3525
|
+
addIn(path7, value) {
|
|
3526
3526
|
if (assertCollection(this.contents))
|
|
3527
|
-
this.contents.addIn(
|
|
3527
|
+
this.contents.addIn(path7, value);
|
|
3528
3528
|
}
|
|
3529
3529
|
/**
|
|
3530
3530
|
* Create a new `Alias` node, ensuring that the target `node` has the required anchor.
|
|
@@ -3599,14 +3599,14 @@ var require_Document = __commonJS({
|
|
|
3599
3599
|
* Removes a value from the document.
|
|
3600
3600
|
* @returns `true` if the item was found and removed.
|
|
3601
3601
|
*/
|
|
3602
|
-
deleteIn(
|
|
3603
|
-
if (Collection.isEmptyPath(
|
|
3602
|
+
deleteIn(path7) {
|
|
3603
|
+
if (Collection.isEmptyPath(path7)) {
|
|
3604
3604
|
if (this.contents == null)
|
|
3605
3605
|
return false;
|
|
3606
3606
|
this.contents = null;
|
|
3607
3607
|
return true;
|
|
3608
3608
|
}
|
|
3609
|
-
return assertCollection(this.contents) ? this.contents.deleteIn(
|
|
3609
|
+
return assertCollection(this.contents) ? this.contents.deleteIn(path7) : false;
|
|
3610
3610
|
}
|
|
3611
3611
|
/**
|
|
3612
3612
|
* Returns item at `key`, or `undefined` if not found. By default unwraps
|
|
@@ -3621,10 +3621,10 @@ var require_Document = __commonJS({
|
|
|
3621
3621
|
* scalar values from their surrounding node; to disable set `keepScalar` to
|
|
3622
3622
|
* `true` (collections are always returned intact).
|
|
3623
3623
|
*/
|
|
3624
|
-
getIn(
|
|
3625
|
-
if (Collection.isEmptyPath(
|
|
3624
|
+
getIn(path7, keepScalar) {
|
|
3625
|
+
if (Collection.isEmptyPath(path7))
|
|
3626
3626
|
return !keepScalar && identity.isScalar(this.contents) ? this.contents.value : this.contents;
|
|
3627
|
-
return identity.isCollection(this.contents) ? this.contents.getIn(
|
|
3627
|
+
return identity.isCollection(this.contents) ? this.contents.getIn(path7, keepScalar) : void 0;
|
|
3628
3628
|
}
|
|
3629
3629
|
/**
|
|
3630
3630
|
* Checks if the document includes a value with the key `key`.
|
|
@@ -3635,10 +3635,10 @@ var require_Document = __commonJS({
|
|
|
3635
3635
|
/**
|
|
3636
3636
|
* Checks if the document includes a value at `path`.
|
|
3637
3637
|
*/
|
|
3638
|
-
hasIn(
|
|
3639
|
-
if (Collection.isEmptyPath(
|
|
3638
|
+
hasIn(path7) {
|
|
3639
|
+
if (Collection.isEmptyPath(path7))
|
|
3640
3640
|
return this.contents !== void 0;
|
|
3641
|
-
return identity.isCollection(this.contents) ? this.contents.hasIn(
|
|
3641
|
+
return identity.isCollection(this.contents) ? this.contents.hasIn(path7) : false;
|
|
3642
3642
|
}
|
|
3643
3643
|
/**
|
|
3644
3644
|
* Sets a value in this document. For `!!set`, `value` needs to be a
|
|
@@ -3655,13 +3655,13 @@ var require_Document = __commonJS({
|
|
|
3655
3655
|
* Sets a value in this document. For `!!set`, `value` needs to be a
|
|
3656
3656
|
* boolean to add/remove the item from the set.
|
|
3657
3657
|
*/
|
|
3658
|
-
setIn(
|
|
3659
|
-
if (Collection.isEmptyPath(
|
|
3658
|
+
setIn(path7, value) {
|
|
3659
|
+
if (Collection.isEmptyPath(path7)) {
|
|
3660
3660
|
this.contents = value;
|
|
3661
3661
|
} else if (this.contents == null) {
|
|
3662
|
-
this.contents = Collection.collectionFromPath(this.schema, Array.from(
|
|
3662
|
+
this.contents = Collection.collectionFromPath(this.schema, Array.from(path7), value);
|
|
3663
3663
|
} else if (assertCollection(this.contents)) {
|
|
3664
|
-
this.contents.setIn(
|
|
3664
|
+
this.contents.setIn(path7, value);
|
|
3665
3665
|
}
|
|
3666
3666
|
}
|
|
3667
3667
|
/**
|
|
@@ -5641,9 +5641,9 @@ var require_cst_visit = __commonJS({
|
|
|
5641
5641
|
visit.BREAK = BREAK;
|
|
5642
5642
|
visit.SKIP = SKIP;
|
|
5643
5643
|
visit.REMOVE = REMOVE;
|
|
5644
|
-
visit.itemAtPath = (cst,
|
|
5644
|
+
visit.itemAtPath = (cst, path7) => {
|
|
5645
5645
|
let item = cst;
|
|
5646
|
-
for (const [field, index] of
|
|
5646
|
+
for (const [field, index] of path7) {
|
|
5647
5647
|
const tok = item?.[field];
|
|
5648
5648
|
if (tok && "items" in tok) {
|
|
5649
5649
|
item = tok.items[index];
|
|
@@ -5652,23 +5652,23 @@ var require_cst_visit = __commonJS({
|
|
|
5652
5652
|
}
|
|
5653
5653
|
return item;
|
|
5654
5654
|
};
|
|
5655
|
-
visit.parentCollection = (cst,
|
|
5656
|
-
const parent = visit.itemAtPath(cst,
|
|
5657
|
-
const field =
|
|
5655
|
+
visit.parentCollection = (cst, path7) => {
|
|
5656
|
+
const parent = visit.itemAtPath(cst, path7.slice(0, -1));
|
|
5657
|
+
const field = path7[path7.length - 1][0];
|
|
5658
5658
|
const coll = parent?.[field];
|
|
5659
5659
|
if (coll && "items" in coll)
|
|
5660
5660
|
return coll;
|
|
5661
5661
|
throw new Error("Parent collection not found");
|
|
5662
5662
|
};
|
|
5663
|
-
function _visit(
|
|
5664
|
-
let ctrl = visitor(item,
|
|
5663
|
+
function _visit(path7, item, visitor) {
|
|
5664
|
+
let ctrl = visitor(item, path7);
|
|
5665
5665
|
if (typeof ctrl === "symbol")
|
|
5666
5666
|
return ctrl;
|
|
5667
5667
|
for (const field of ["key", "value"]) {
|
|
5668
5668
|
const token = item[field];
|
|
5669
5669
|
if (token && "items" in token) {
|
|
5670
5670
|
for (let i = 0; i < token.items.length; ++i) {
|
|
5671
|
-
const ci = _visit(Object.freeze(
|
|
5671
|
+
const ci = _visit(Object.freeze(path7.concat([[field, i]])), token.items[i], visitor);
|
|
5672
5672
|
if (typeof ci === "number")
|
|
5673
5673
|
i = ci - 1;
|
|
5674
5674
|
else if (ci === BREAK)
|
|
@@ -5679,10 +5679,10 @@ var require_cst_visit = __commonJS({
|
|
|
5679
5679
|
}
|
|
5680
5680
|
}
|
|
5681
5681
|
if (typeof ctrl === "function" && field === "key")
|
|
5682
|
-
ctrl = ctrl(item,
|
|
5682
|
+
ctrl = ctrl(item, path7);
|
|
5683
5683
|
}
|
|
5684
5684
|
}
|
|
5685
|
-
return typeof ctrl === "function" ? ctrl(item,
|
|
5685
|
+
return typeof ctrl === "function" ? ctrl(item, path7) : ctrl;
|
|
5686
5686
|
}
|
|
5687
5687
|
exports.visit = visit;
|
|
5688
5688
|
}
|
|
@@ -6988,14 +6988,14 @@ var require_parser = __commonJS({
|
|
|
6988
6988
|
case "scalar":
|
|
6989
6989
|
case "single-quoted-scalar":
|
|
6990
6990
|
case "double-quoted-scalar": {
|
|
6991
|
-
const
|
|
6991
|
+
const fs7 = this.flowScalar(this.type);
|
|
6992
6992
|
if (atNextItem || it2.value) {
|
|
6993
|
-
map2.items.push({ start, key:
|
|
6993
|
+
map2.items.push({ start, key: fs7, sep: [] });
|
|
6994
6994
|
this.onKeyLine = true;
|
|
6995
6995
|
} else if (it2.sep) {
|
|
6996
|
-
this.stack.push(
|
|
6996
|
+
this.stack.push(fs7);
|
|
6997
6997
|
} else {
|
|
6998
|
-
Object.assign(it2, { key:
|
|
6998
|
+
Object.assign(it2, { key: fs7, sep: [] });
|
|
6999
6999
|
this.onKeyLine = true;
|
|
7000
7000
|
}
|
|
7001
7001
|
return;
|
|
@@ -7123,13 +7123,13 @@ var require_parser = __commonJS({
|
|
|
7123
7123
|
case "scalar":
|
|
7124
7124
|
case "single-quoted-scalar":
|
|
7125
7125
|
case "double-quoted-scalar": {
|
|
7126
|
-
const
|
|
7126
|
+
const fs7 = this.flowScalar(this.type);
|
|
7127
7127
|
if (!it2 || it2.value)
|
|
7128
|
-
fc.items.push({ start: [], key:
|
|
7128
|
+
fc.items.push({ start: [], key: fs7, sep: [] });
|
|
7129
7129
|
else if (it2.sep)
|
|
7130
|
-
this.stack.push(
|
|
7130
|
+
this.stack.push(fs7);
|
|
7131
7131
|
else
|
|
7132
|
-
Object.assign(it2, { key:
|
|
7132
|
+
Object.assign(it2, { key: fs7, sep: [] });
|
|
7133
7133
|
return;
|
|
7134
7134
|
}
|
|
7135
7135
|
case "flow-map-end":
|
|
@@ -7521,13 +7521,13 @@ var require_bcrypt = __commonJS({
|
|
|
7521
7521
|
throw Error("Illegal callback: " + typeof callback);
|
|
7522
7522
|
_async(callback);
|
|
7523
7523
|
} else
|
|
7524
|
-
return new Promise(function(
|
|
7524
|
+
return new Promise(function(resolve12, reject) {
|
|
7525
7525
|
_async(function(err, res) {
|
|
7526
7526
|
if (err) {
|
|
7527
7527
|
reject(err);
|
|
7528
7528
|
return;
|
|
7529
7529
|
}
|
|
7530
|
-
|
|
7530
|
+
resolve12(res);
|
|
7531
7531
|
});
|
|
7532
7532
|
});
|
|
7533
7533
|
};
|
|
@@ -7556,13 +7556,13 @@ var require_bcrypt = __commonJS({
|
|
|
7556
7556
|
throw Error("Illegal callback: " + typeof callback);
|
|
7557
7557
|
_async(callback);
|
|
7558
7558
|
} else
|
|
7559
|
-
return new Promise(function(
|
|
7559
|
+
return new Promise(function(resolve12, reject) {
|
|
7560
7560
|
_async(function(err, res) {
|
|
7561
7561
|
if (err) {
|
|
7562
7562
|
reject(err);
|
|
7563
7563
|
return;
|
|
7564
7564
|
}
|
|
7565
|
-
|
|
7565
|
+
resolve12(res);
|
|
7566
7566
|
});
|
|
7567
7567
|
});
|
|
7568
7568
|
};
|
|
@@ -7607,13 +7607,13 @@ var require_bcrypt = __commonJS({
|
|
|
7607
7607
|
throw Error("Illegal callback: " + typeof callback);
|
|
7608
7608
|
_async(callback);
|
|
7609
7609
|
} else
|
|
7610
|
-
return new Promise(function(
|
|
7610
|
+
return new Promise(function(resolve12, reject) {
|
|
7611
7611
|
_async(function(err, res) {
|
|
7612
7612
|
if (err) {
|
|
7613
7613
|
reject(err);
|
|
7614
7614
|
return;
|
|
7615
7615
|
}
|
|
7616
|
-
|
|
7616
|
+
resolve12(res);
|
|
7617
7617
|
});
|
|
7618
7618
|
});
|
|
7619
7619
|
};
|
|
@@ -10880,15 +10880,15 @@ var require_pg_connection_string = __commonJS({
|
|
|
10880
10880
|
if (config3.sslnegotiation === "direct" && config3.ssl === void 0) {
|
|
10881
10881
|
config3.ssl = true;
|
|
10882
10882
|
}
|
|
10883
|
-
const
|
|
10883
|
+
const fs7 = config3.sslcert || config3.sslkey || config3.sslrootcert ? __require("fs") : null;
|
|
10884
10884
|
if (config3.sslcert) {
|
|
10885
|
-
config3.ssl.cert =
|
|
10885
|
+
config3.ssl.cert = fs7.readFileSync(config3.sslcert).toString();
|
|
10886
10886
|
}
|
|
10887
10887
|
if (config3.sslkey) {
|
|
10888
|
-
config3.ssl.key =
|
|
10888
|
+
config3.ssl.key = fs7.readFileSync(config3.sslkey).toString();
|
|
10889
10889
|
}
|
|
10890
10890
|
if (config3.sslrootcert) {
|
|
10891
|
-
config3.ssl.ca =
|
|
10891
|
+
config3.ssl.ca = fs7.readFileSync(config3.sslrootcert).toString();
|
|
10892
10892
|
}
|
|
10893
10893
|
if (options.useLibpqCompat && config3.uselibpqcompat) {
|
|
10894
10894
|
throw new Error("Both useLibpqCompat and uselibpqcompat are set. Please use only one of them.");
|
|
@@ -12334,7 +12334,7 @@ var require_dist2 = __commonJS({
|
|
|
12334
12334
|
function parse4(stream, callback) {
|
|
12335
12335
|
const parser = new parser_1.Parser();
|
|
12336
12336
|
stream.on("data", (buffer) => parser.parse(buffer, callback));
|
|
12337
|
-
return new Promise((
|
|
12337
|
+
return new Promise((resolve12) => stream.on("end", () => resolve12()));
|
|
12338
12338
|
}
|
|
12339
12339
|
}
|
|
12340
12340
|
});
|
|
@@ -12722,7 +12722,7 @@ var require_helper = __commonJS({
|
|
|
12722
12722
|
"../../node_modules/.pnpm/pgpass@1.0.5/node_modules/pgpass/lib/helper.js"(exports, module) {
|
|
12723
12723
|
"use strict";
|
|
12724
12724
|
init_esm_shims();
|
|
12725
|
-
var
|
|
12725
|
+
var path7 = __require("path");
|
|
12726
12726
|
var Stream = __require("stream").Stream;
|
|
12727
12727
|
var split = require_split2();
|
|
12728
12728
|
var util = __require("util");
|
|
@@ -12761,7 +12761,7 @@ var require_helper = __commonJS({
|
|
|
12761
12761
|
};
|
|
12762
12762
|
module.exports.getFileName = function(rawEnv) {
|
|
12763
12763
|
var env = rawEnv || process.env;
|
|
12764
|
-
var file2 = env.PGPASSFILE || (isWin ?
|
|
12764
|
+
var file2 = env.PGPASSFILE || (isWin ? path7.join(env.APPDATA || "./", "postgresql", "pgpass.conf") : path7.join(env.HOME || "./", ".pgpass"));
|
|
12765
12765
|
return file2;
|
|
12766
12766
|
};
|
|
12767
12767
|
module.exports.usePgPass = function(stats, fname) {
|
|
@@ -12894,16 +12894,16 @@ var require_lib = __commonJS({
|
|
|
12894
12894
|
"../../node_modules/.pnpm/pgpass@1.0.5/node_modules/pgpass/lib/index.js"(exports, module) {
|
|
12895
12895
|
"use strict";
|
|
12896
12896
|
init_esm_shims();
|
|
12897
|
-
var
|
|
12898
|
-
var
|
|
12897
|
+
var path7 = __require("path");
|
|
12898
|
+
var fs7 = __require("fs");
|
|
12899
12899
|
var helper = require_helper();
|
|
12900
12900
|
module.exports = function(connInfo, cb) {
|
|
12901
12901
|
var file2 = helper.getFileName();
|
|
12902
|
-
|
|
12902
|
+
fs7.stat(file2, function(err, stat) {
|
|
12903
12903
|
if (err || !helper.usePgPass(stat, file2)) {
|
|
12904
12904
|
return cb(void 0);
|
|
12905
12905
|
}
|
|
12906
|
-
var st =
|
|
12906
|
+
var st = fs7.createReadStream(file2);
|
|
12907
12907
|
helper.getPassword(connInfo, st, cb);
|
|
12908
12908
|
});
|
|
12909
12909
|
};
|
|
@@ -13103,12 +13103,12 @@ var require_client = __commonJS({
|
|
|
13103
13103
|
this._connect(callback);
|
|
13104
13104
|
return;
|
|
13105
13105
|
}
|
|
13106
|
-
return new this._Promise((
|
|
13106
|
+
return new this._Promise((resolve12, reject) => {
|
|
13107
13107
|
this._connect((error51) => {
|
|
13108
13108
|
if (error51) {
|
|
13109
13109
|
reject(error51);
|
|
13110
13110
|
} else {
|
|
13111
|
-
|
|
13111
|
+
resolve12(this);
|
|
13112
13112
|
}
|
|
13113
13113
|
});
|
|
13114
13114
|
});
|
|
@@ -13455,8 +13455,8 @@ var require_client = __commonJS({
|
|
|
13455
13455
|
} else {
|
|
13456
13456
|
query = new Query2(config3, values, callback);
|
|
13457
13457
|
if (!query.callback) {
|
|
13458
|
-
result = new this._Promise((
|
|
13459
|
-
query.callback = (err, res) => err ? reject(err) :
|
|
13458
|
+
result = new this._Promise((resolve12, reject) => {
|
|
13459
|
+
query.callback = (err, res) => err ? reject(err) : resolve12(res);
|
|
13460
13460
|
}).catch((err) => {
|
|
13461
13461
|
Error.captureStackTrace(err);
|
|
13462
13462
|
throw err;
|
|
@@ -13540,8 +13540,8 @@ var require_client = __commonJS({
|
|
|
13540
13540
|
if (cb) {
|
|
13541
13541
|
this.connection.once("end", cb);
|
|
13542
13542
|
} else {
|
|
13543
|
-
return new this._Promise((
|
|
13544
|
-
this.connection.once("end",
|
|
13543
|
+
return new this._Promise((resolve12) => {
|
|
13544
|
+
this.connection.once("end", resolve12);
|
|
13545
13545
|
});
|
|
13546
13546
|
}
|
|
13547
13547
|
}
|
|
@@ -13591,8 +13591,8 @@ var require_pg_pool = __commonJS({
|
|
|
13591
13591
|
const cb = function(err, client) {
|
|
13592
13592
|
err ? rej(err) : res(client);
|
|
13593
13593
|
};
|
|
13594
|
-
const result = new Promise2(function(
|
|
13595
|
-
res =
|
|
13594
|
+
const result = new Promise2(function(resolve12, reject) {
|
|
13595
|
+
res = resolve12;
|
|
13596
13596
|
rej = reject;
|
|
13597
13597
|
}).catch((err) => {
|
|
13598
13598
|
Error.captureStackTrace(err);
|
|
@@ -13653,7 +13653,7 @@ var require_pg_pool = __commonJS({
|
|
|
13653
13653
|
if (typeof Promise2.try === "function") {
|
|
13654
13654
|
return Promise2.try(f);
|
|
13655
13655
|
}
|
|
13656
|
-
return new Promise2((
|
|
13656
|
+
return new Promise2((resolve12) => resolve12(f()));
|
|
13657
13657
|
}
|
|
13658
13658
|
_isFull() {
|
|
13659
13659
|
return this._clients.length >= this.options.max;
|
|
@@ -14047,8 +14047,8 @@ var require_query2 = __commonJS({
|
|
|
14047
14047
|
NativeQuery.prototype._getPromise = function() {
|
|
14048
14048
|
if (this._promise) return this._promise;
|
|
14049
14049
|
this._promise = new Promise(
|
|
14050
|
-
function(
|
|
14051
|
-
this._once("end",
|
|
14050
|
+
function(resolve12, reject) {
|
|
14051
|
+
this._once("end", resolve12);
|
|
14052
14052
|
this._once("error", reject);
|
|
14053
14053
|
}.bind(this)
|
|
14054
14054
|
);
|
|
@@ -14227,12 +14227,12 @@ var require_client2 = __commonJS({
|
|
|
14227
14227
|
this._connect(callback);
|
|
14228
14228
|
return;
|
|
14229
14229
|
}
|
|
14230
|
-
return new this._Promise((
|
|
14230
|
+
return new this._Promise((resolve12, reject) => {
|
|
14231
14231
|
this._connect((error51) => {
|
|
14232
14232
|
if (error51) {
|
|
14233
14233
|
reject(error51);
|
|
14234
14234
|
} else {
|
|
14235
|
-
|
|
14235
|
+
resolve12(this);
|
|
14236
14236
|
}
|
|
14237
14237
|
});
|
|
14238
14238
|
});
|
|
@@ -14256,8 +14256,8 @@ var require_client2 = __commonJS({
|
|
|
14256
14256
|
query = new NativeQuery(config3, values, callback);
|
|
14257
14257
|
if (!query.callback) {
|
|
14258
14258
|
let resolveOut, rejectOut;
|
|
14259
|
-
result = new this._Promise((
|
|
14260
|
-
resolveOut =
|
|
14259
|
+
result = new this._Promise((resolve12, reject) => {
|
|
14260
|
+
resolveOut = resolve12;
|
|
14261
14261
|
rejectOut = reject;
|
|
14262
14262
|
}).catch((err) => {
|
|
14263
14263
|
Error.captureStackTrace(err);
|
|
@@ -14320,8 +14320,8 @@ var require_client2 = __commonJS({
|
|
|
14320
14320
|
}
|
|
14321
14321
|
let result;
|
|
14322
14322
|
if (!cb) {
|
|
14323
|
-
result = new this._Promise(function(
|
|
14324
|
-
cb = (err) => err ? reject(err) :
|
|
14323
|
+
result = new this._Promise(function(resolve12, reject) {
|
|
14324
|
+
cb = (err) => err ? reject(err) : resolve12();
|
|
14325
14325
|
});
|
|
14326
14326
|
}
|
|
14327
14327
|
this.native.end(function() {
|
|
@@ -14468,8 +14468,8 @@ import { Command } from "commander";
|
|
|
14468
14468
|
|
|
14469
14469
|
// src/commands/build.ts
|
|
14470
14470
|
init_esm_shims();
|
|
14471
|
-
import { mkdirSync, statSync as statSync2, existsSync as existsSync3, readdirSync as
|
|
14472
|
-
import { resolve as resolve3, join as
|
|
14471
|
+
import { mkdirSync, statSync as statSync2, existsSync as existsSync3, readdirSync as readdirSync3, writeFileSync } from "fs";
|
|
14472
|
+
import { resolve as resolve3, join as join8, dirname } from "path";
|
|
14473
14473
|
import { createRequire } from "module";
|
|
14474
14474
|
import { build as viteBuild } from "vite";
|
|
14475
14475
|
import { build as tsupBuild } from "tsup";
|
|
@@ -15256,10 +15256,10 @@ function mergeDefs(...defs) {
|
|
|
15256
15256
|
function cloneDef(schema) {
|
|
15257
15257
|
return mergeDefs(schema._zod.def);
|
|
15258
15258
|
}
|
|
15259
|
-
function getElementAtPath(obj,
|
|
15260
|
-
if (!
|
|
15259
|
+
function getElementAtPath(obj, path7) {
|
|
15260
|
+
if (!path7)
|
|
15261
15261
|
return obj;
|
|
15262
|
-
return
|
|
15262
|
+
return path7.reduce((acc, key) => acc?.[key], obj);
|
|
15263
15263
|
}
|
|
15264
15264
|
function promiseAllObject(promisesObj) {
|
|
15265
15265
|
const keys = Object.keys(promisesObj);
|
|
@@ -15668,11 +15668,11 @@ function explicitlyAborted(x2, startIndex = 0) {
|
|
|
15668
15668
|
}
|
|
15669
15669
|
return false;
|
|
15670
15670
|
}
|
|
15671
|
-
function prefixIssues(
|
|
15671
|
+
function prefixIssues(path7, issues) {
|
|
15672
15672
|
return issues.map((iss) => {
|
|
15673
15673
|
var _a3;
|
|
15674
15674
|
(_a3 = iss).path ?? (_a3.path = []);
|
|
15675
|
-
iss.path.unshift(
|
|
15675
|
+
iss.path.unshift(path7);
|
|
15676
15676
|
return iss;
|
|
15677
15677
|
});
|
|
15678
15678
|
}
|
|
@@ -15819,16 +15819,16 @@ function flattenError(error51, mapper = (issue2) => issue2.message) {
|
|
|
15819
15819
|
}
|
|
15820
15820
|
function formatError(error51, mapper = (issue2) => issue2.message) {
|
|
15821
15821
|
const fieldErrors = { _errors: [] };
|
|
15822
|
-
const processError = (error52,
|
|
15822
|
+
const processError = (error52, path7 = []) => {
|
|
15823
15823
|
for (const issue2 of error52.issues) {
|
|
15824
15824
|
if (issue2.code === "invalid_union" && issue2.errors.length) {
|
|
15825
|
-
issue2.errors.map((issues) => processError({ issues }, [...
|
|
15825
|
+
issue2.errors.map((issues) => processError({ issues }, [...path7, ...issue2.path]));
|
|
15826
15826
|
} else if (issue2.code === "invalid_key") {
|
|
15827
|
-
processError({ issues: issue2.issues }, [...
|
|
15827
|
+
processError({ issues: issue2.issues }, [...path7, ...issue2.path]);
|
|
15828
15828
|
} else if (issue2.code === "invalid_element") {
|
|
15829
|
-
processError({ issues: issue2.issues }, [...
|
|
15829
|
+
processError({ issues: issue2.issues }, [...path7, ...issue2.path]);
|
|
15830
15830
|
} else {
|
|
15831
|
-
const fullpath = [...
|
|
15831
|
+
const fullpath = [...path7, ...issue2.path];
|
|
15832
15832
|
if (fullpath.length === 0) {
|
|
15833
15833
|
fieldErrors._errors.push(mapper(issue2));
|
|
15834
15834
|
} else {
|
|
@@ -15855,17 +15855,17 @@ function formatError(error51, mapper = (issue2) => issue2.message) {
|
|
|
15855
15855
|
}
|
|
15856
15856
|
function treeifyError(error51, mapper = (issue2) => issue2.message) {
|
|
15857
15857
|
const result = { errors: [] };
|
|
15858
|
-
const processError = (error52,
|
|
15858
|
+
const processError = (error52, path7 = []) => {
|
|
15859
15859
|
var _a3, _b;
|
|
15860
15860
|
for (const issue2 of error52.issues) {
|
|
15861
15861
|
if (issue2.code === "invalid_union" && issue2.errors.length) {
|
|
15862
|
-
issue2.errors.map((issues) => processError({ issues }, [...
|
|
15862
|
+
issue2.errors.map((issues) => processError({ issues }, [...path7, ...issue2.path]));
|
|
15863
15863
|
} else if (issue2.code === "invalid_key") {
|
|
15864
|
-
processError({ issues: issue2.issues }, [...
|
|
15864
|
+
processError({ issues: issue2.issues }, [...path7, ...issue2.path]);
|
|
15865
15865
|
} else if (issue2.code === "invalid_element") {
|
|
15866
|
-
processError({ issues: issue2.issues }, [...
|
|
15866
|
+
processError({ issues: issue2.issues }, [...path7, ...issue2.path]);
|
|
15867
15867
|
} else {
|
|
15868
|
-
const fullpath = [...
|
|
15868
|
+
const fullpath = [...path7, ...issue2.path];
|
|
15869
15869
|
if (fullpath.length === 0) {
|
|
15870
15870
|
result.errors.push(mapper(issue2));
|
|
15871
15871
|
continue;
|
|
@@ -15897,8 +15897,8 @@ function treeifyError(error51, mapper = (issue2) => issue2.message) {
|
|
|
15897
15897
|
}
|
|
15898
15898
|
function toDotPath(_path) {
|
|
15899
15899
|
const segs = [];
|
|
15900
|
-
const
|
|
15901
|
-
for (const seg of
|
|
15900
|
+
const path7 = _path.map((seg) => typeof seg === "object" ? seg.key : seg);
|
|
15901
|
+
for (const seg of path7) {
|
|
15902
15902
|
if (typeof seg === "number")
|
|
15903
15903
|
segs.push(`[${seg}]`);
|
|
15904
15904
|
else if (typeof seg === "symbol")
|
|
@@ -28671,13 +28671,13 @@ function resolveRef(ref, ctx) {
|
|
|
28671
28671
|
if (!ref.startsWith("#")) {
|
|
28672
28672
|
throw new Error("External $ref is not supported, only local refs (#/...) are allowed");
|
|
28673
28673
|
}
|
|
28674
|
-
const
|
|
28675
|
-
if (
|
|
28674
|
+
const path7 = ref.slice(1).split("/").filter(Boolean);
|
|
28675
|
+
if (path7.length === 0) {
|
|
28676
28676
|
return ctx.rootSchema;
|
|
28677
28677
|
}
|
|
28678
28678
|
const defsKey = ctx.version === "draft-2020-12" ? "$defs" : "definitions";
|
|
28679
|
-
if (
|
|
28680
|
-
const key =
|
|
28679
|
+
if (path7[0] === defsKey) {
|
|
28680
|
+
const key = path7[1];
|
|
28681
28681
|
if (!key || !ctx.defs[key]) {
|
|
28682
28682
|
throw new Error(`Reference not found: ${ref}`);
|
|
28683
28683
|
}
|
|
@@ -29088,9 +29088,13 @@ config(en_default());
|
|
|
29088
29088
|
|
|
29089
29089
|
// ../core/dist/index.mjs
|
|
29090
29090
|
var import_yaml = __toESM(require_dist(), 1);
|
|
29091
|
+
import * as fs2 from "fs";
|
|
29092
|
+
import * as path2 from "path";
|
|
29091
29093
|
import * as fs from "fs";
|
|
29092
29094
|
import * as path from "path";
|
|
29093
29095
|
var import_bcryptjs = __toESM(require_bcryptjs(), 1);
|
|
29096
|
+
import * as fs3 from "fs";
|
|
29097
|
+
import * as path3 from "path";
|
|
29094
29098
|
var snakeCaseName = external_exports.string().regex(/^[a-z][a-z0-9_]*$/, 'Must be snake_case (e.g. "blog_post")');
|
|
29095
29099
|
var maxSizeString = external_exports.string().regex(
|
|
29096
29100
|
/^\d+(\.\d+)?\s*(B|KB|MB|GB)$/i,
|
|
@@ -29119,7 +29123,19 @@ var refTargetMachineName = external_exports.string().regex(
|
|
|
29119
29123
|
var RawFieldBase = external_exports.object({
|
|
29120
29124
|
name: snakeCaseName,
|
|
29121
29125
|
label: external_exports.string().min(1),
|
|
29122
|
-
required: external_exports.boolean()
|
|
29126
|
+
required: external_exports.boolean(),
|
|
29127
|
+
// ─── Version declarations ───────────────────────────────────────────────────
|
|
29128
|
+
//
|
|
29129
|
+
// A field's storage column is STATED here, never derived from a rename
|
|
29130
|
+
// history. All three are optional and default to the pre-versioning
|
|
29131
|
+
// behaviour, so every schema authored before versioning existed keeps its
|
|
29132
|
+
// exact meaning.
|
|
29133
|
+
/** Storage column. Defaults to `name`. Stating it is how a rename works: the name changes, the column does not. */
|
|
29134
|
+
column: snakeCaseName.optional(),
|
|
29135
|
+
/** Tombstone — the column is retained for older live versions, and this version does not expose it. */
|
|
29136
|
+
removed: external_exports.boolean().optional(),
|
|
29137
|
+
/** Value served for rows created after the removal. Meaningful only on a tombstone. */
|
|
29138
|
+
fallback: external_exports.unknown().optional()
|
|
29123
29139
|
});
|
|
29124
29140
|
var RawTextPlainFieldSchema = RawFieldBase.extend({
|
|
29125
29141
|
type: external_exports.literal("text/plain"),
|
|
@@ -29456,6 +29472,17 @@ var FOLDER_KEY_TO_SCHEMA_TYPE = {
|
|
|
29456
29472
|
taxonomy_types: "taxonomy-type",
|
|
29457
29473
|
enum_types: "enum-type"
|
|
29458
29474
|
};
|
|
29475
|
+
function directoryExists(dirPath) {
|
|
29476
|
+
try {
|
|
29477
|
+
return fs.statSync(dirPath).isDirectory();
|
|
29478
|
+
} catch {
|
|
29479
|
+
return false;
|
|
29480
|
+
}
|
|
29481
|
+
}
|
|
29482
|
+
function isSupportedExtension(filename) {
|
|
29483
|
+
const ext = path.extname(filename).toLowerCase();
|
|
29484
|
+
return ext === ".json" || ext === ".yaml" || ext === ".yml";
|
|
29485
|
+
}
|
|
29459
29486
|
var SCHEMA_TYPE_TO_PREFIX = {
|
|
29460
29487
|
"content-type": "content",
|
|
29461
29488
|
"paragraph-type": "paragraph",
|
|
@@ -29465,7 +29492,7 @@ var SCHEMA_TYPE_TO_PREFIX = {
|
|
|
29465
29492
|
function loadSchemaFile(filePath) {
|
|
29466
29493
|
let raw2;
|
|
29467
29494
|
try {
|
|
29468
|
-
raw2 =
|
|
29495
|
+
raw2 = fs2.readFileSync(filePath, "utf-8");
|
|
29469
29496
|
} catch (err) {
|
|
29470
29497
|
return {
|
|
29471
29498
|
ok: false,
|
|
@@ -29478,7 +29505,7 @@ function loadSchemaFile(filePath) {
|
|
|
29478
29505
|
]
|
|
29479
29506
|
};
|
|
29480
29507
|
}
|
|
29481
|
-
const ext =
|
|
29508
|
+
const ext = path2.extname(filePath).toLowerCase();
|
|
29482
29509
|
if (ext === ".json") {
|
|
29483
29510
|
try {
|
|
29484
29511
|
return { ok: true, value: JSON.parse(raw2) };
|
|
@@ -29540,7 +29567,7 @@ function walkSchemaDirectory(config3) {
|
|
|
29540
29567
|
const resolvedFolderPaths = /* @__PURE__ */ new Map();
|
|
29541
29568
|
for (const folderKey of Object.keys(FOLDER_KEY_TO_SCHEMA_TYPE)) {
|
|
29542
29569
|
const folderName = config3.folders[folderKey];
|
|
29543
|
-
const absFolder =
|
|
29570
|
+
const absFolder = path2.resolve(config3.base_path, folderName);
|
|
29544
29571
|
const existing = resolvedFolderPaths.get(absFolder);
|
|
29545
29572
|
if (existing !== void 0) {
|
|
29546
29573
|
errors.push({
|
|
@@ -29557,7 +29584,7 @@ function walkSchemaDirectory(config3) {
|
|
|
29557
29584
|
FOLDER_KEY_TO_SCHEMA_TYPE
|
|
29558
29585
|
)) {
|
|
29559
29586
|
const folderName = config3.folders[folderKey];
|
|
29560
|
-
const folderPath =
|
|
29587
|
+
const folderPath = path2.resolve(config3.base_path, folderName);
|
|
29561
29588
|
if (!directoryExists(folderPath)) {
|
|
29562
29589
|
errors.push({
|
|
29563
29590
|
file: folderPath,
|
|
@@ -29570,8 +29597,8 @@ function walkSchemaDirectory(config3) {
|
|
|
29570
29597
|
const expectedPrefix = SCHEMA_TYPE_TO_PREFIX[schemaType];
|
|
29571
29598
|
for (const entry of entries) {
|
|
29572
29599
|
if (!isSupportedExtension(entry)) continue;
|
|
29573
|
-
const filePath =
|
|
29574
|
-
const baseName =
|
|
29600
|
+
const filePath = path2.join(folderPath, entry);
|
|
29601
|
+
const baseName = path2.basename(entry, path2.extname(entry));
|
|
29575
29602
|
if (!hasCorrectPrefix(baseName, expectedPrefix)) {
|
|
29576
29603
|
errors.push({
|
|
29577
29604
|
file: filePath,
|
|
@@ -29591,24 +29618,13 @@ function walkSchemaDirectory(config3) {
|
|
|
29591
29618
|
if (errors.length > 0) return { ok: false, errors };
|
|
29592
29619
|
return { ok: true, value: files };
|
|
29593
29620
|
}
|
|
29594
|
-
function directoryExists(dirPath) {
|
|
29595
|
-
try {
|
|
29596
|
-
return fs.statSync(dirPath).isDirectory();
|
|
29597
|
-
} catch {
|
|
29598
|
-
return false;
|
|
29599
|
-
}
|
|
29600
|
-
}
|
|
29601
29621
|
function readDirEntries(dirPath) {
|
|
29602
29622
|
try {
|
|
29603
|
-
return
|
|
29623
|
+
return fs2.readdirSync(dirPath);
|
|
29604
29624
|
} catch {
|
|
29605
29625
|
return [];
|
|
29606
29626
|
}
|
|
29607
29627
|
}
|
|
29608
|
-
function isSupportedExtension(filename) {
|
|
29609
|
-
const ext = path.extname(filename).toLowerCase();
|
|
29610
|
-
return ext === ".json" || ext === ".yaml" || ext === ".yml";
|
|
29611
|
-
}
|
|
29612
29628
|
function hasCorrectPrefix(baseName, expectedPrefix) {
|
|
29613
29629
|
return baseName.startsWith(`${expectedPrefix}--`);
|
|
29614
29630
|
}
|
|
@@ -29791,6 +29807,10 @@ var fieldTypeRegistry = {
|
|
|
29791
29807
|
ui_component: { component: "computed-display" }
|
|
29792
29808
|
})
|
|
29793
29809
|
};
|
|
29810
|
+
function isColumnBacked2(field) {
|
|
29811
|
+
const col = field.db_column;
|
|
29812
|
+
return col !== null && col.column_name !== "" && !col.junction;
|
|
29813
|
+
}
|
|
29794
29814
|
var CONTENT_SYSTEM_FIELDS = [
|
|
29795
29815
|
{ name: "id", db_type: "uuid", primary_key: true, default: "gen_random_uuid()", nullable: false },
|
|
29796
29816
|
{ name: "slug", db_type: "varchar", nullable: false },
|
|
@@ -29821,8 +29841,8 @@ function getNameSegment(machineName) {
|
|
|
29821
29841
|
const idx = machineName.indexOf("--");
|
|
29822
29842
|
return idx === -1 ? machineName : machineName.slice(idx + 2);
|
|
29823
29843
|
}
|
|
29824
|
-
function zodPathToString(
|
|
29825
|
-
return
|
|
29844
|
+
function zodPathToString(path42) {
|
|
29845
|
+
return path42.reduce((acc, seg) => {
|
|
29826
29846
|
const s = typeof seg === "symbol" ? String(seg) : seg;
|
|
29827
29847
|
return typeof s === "number" ? `${acc}[${s}]` : acc ? `${acc}.${s}` : s;
|
|
29828
29848
|
}, "");
|
|
@@ -29858,6 +29878,61 @@ function checkDuplicateFieldNames(fields, sourceFile, schemaName) {
|
|
|
29858
29878
|
}
|
|
29859
29879
|
return errors;
|
|
29860
29880
|
}
|
|
29881
|
+
function hasStorageColumn(f) {
|
|
29882
|
+
if (f.type === "paragraph" || f.type === "programmatic") return false;
|
|
29883
|
+
if (f.type === "reference" && f.rel === "many-to-many") return false;
|
|
29884
|
+
return true;
|
|
29885
|
+
}
|
|
29886
|
+
function checkDuplicateColumns(fields, sourceFile, schemaName) {
|
|
29887
|
+
const owner = /* @__PURE__ */ new Map();
|
|
29888
|
+
const errors = [];
|
|
29889
|
+
for (const f of fields) {
|
|
29890
|
+
if (!hasStorageColumn(f)) continue;
|
|
29891
|
+
const column = f.column ?? f.name;
|
|
29892
|
+
const first = owner.get(column);
|
|
29893
|
+
if (first !== void 0) {
|
|
29894
|
+
errors.push({
|
|
29895
|
+
file: sourceFile,
|
|
29896
|
+
code: "DUPLICATE_COLUMN",
|
|
29897
|
+
message: `Fields "${first}" and "${f.name}" in schema "${schemaName}" both resolve to column "${column}". One column backs exactly one field. If "${f.name}" replaced "${first}", delete the old field instead of keeping both; if they are genuinely different fields, give one an explicit "column".`
|
|
29898
|
+
});
|
|
29899
|
+
continue;
|
|
29900
|
+
}
|
|
29901
|
+
owner.set(column, f.name);
|
|
29902
|
+
}
|
|
29903
|
+
return errors;
|
|
29904
|
+
}
|
|
29905
|
+
function checkFieldDeclarations(rawField, built, sourceFile, schemaName) {
|
|
29906
|
+
const errors = [];
|
|
29907
|
+
const tombstone = rawField.removed === true;
|
|
29908
|
+
if (!isColumnBacked2(built) && (rawField.column !== void 0 || tombstone)) {
|
|
29909
|
+
const declaredKeys = [
|
|
29910
|
+
...rawField.column !== void 0 ? ['"column"'] : [],
|
|
29911
|
+
...tombstone ? ['"removed"'] : []
|
|
29912
|
+
];
|
|
29913
|
+
const declared = declaredKeys.join(" and ");
|
|
29914
|
+
errors.push({
|
|
29915
|
+
file: sourceFile,
|
|
29916
|
+
code: "UNRENAMEABLE_FIELD_KIND",
|
|
29917
|
+
message: `Field "${rawField.name}" in "${schemaName}" declares ${declared}, but a ${rawField.type} field has no storage column of its own \u2014 its name already is its identity, so there is nothing to rename or retain. Remove the declaration.`
|
|
29918
|
+
});
|
|
29919
|
+
}
|
|
29920
|
+
if (tombstone && rawField.required) {
|
|
29921
|
+
errors.push({
|
|
29922
|
+
file: sourceFile,
|
|
29923
|
+
code: "TOMBSTONE_REQUIRED",
|
|
29924
|
+
message: `Field "${rawField.name}" in "${schemaName}" is marked both "removed" and "required". A tombstone retains a column nothing writes any more, so a required tombstone can never be satisfied. Set "required": false, or remove "removed" to bring the field back.`
|
|
29925
|
+
});
|
|
29926
|
+
}
|
|
29927
|
+
if (rawField.fallback !== void 0 && !tombstone) {
|
|
29928
|
+
errors.push({
|
|
29929
|
+
file: sourceFile,
|
|
29930
|
+
code: "FALLBACK_WITHOUT_TOMBSTONE",
|
|
29931
|
+
message: `Field "${rawField.name}" in "${schemaName}" declares a "fallback" but is not marked "removed": true. A fallback is the value served for rows created after a removal, so it is meaningful only on a tombstone. Add "removed": true, or remove the fallback.`
|
|
29932
|
+
});
|
|
29933
|
+
}
|
|
29934
|
+
return errors;
|
|
29935
|
+
}
|
|
29861
29936
|
function buildParsedField(rawField, order, sourceFile, ownerTableName) {
|
|
29862
29937
|
const build = fieldTypeRegistry[rawField.type];
|
|
29863
29938
|
if (!build) {
|
|
@@ -29871,20 +29946,40 @@ function buildParsedField(rawField, order, sourceFile, ownerTableName) {
|
|
|
29871
29946
|
};
|
|
29872
29947
|
}
|
|
29873
29948
|
const { name, label } = rawField;
|
|
29874
|
-
const
|
|
29949
|
+
const built = build(rawField, { ownerTableName });
|
|
29950
|
+
const declErrors = checkFieldDeclarations(rawField, built, sourceFile, ownerTableName);
|
|
29951
|
+
if (declErrors.length > 0) return { ok: false, errors: declErrors };
|
|
29952
|
+
const { validation, ui_component } = built;
|
|
29875
29953
|
const required2 = validation.required;
|
|
29954
|
+
const tombstone = rawField.removed === true;
|
|
29955
|
+
let db_column = built.db_column;
|
|
29956
|
+
if (isColumnBacked2(built)) {
|
|
29957
|
+
db_column = {
|
|
29958
|
+
...db_column,
|
|
29959
|
+
column_name: rawField.column ?? db_column.column_name,
|
|
29960
|
+
// A tombstone is always nullable, overriding the builder — including
|
|
29961
|
+
// `boolean`, the one type whose column is otherwise always NOT NULL.
|
|
29962
|
+
// Rows written after the removal cannot populate the column.
|
|
29963
|
+
...tombstone && { nullable: true }
|
|
29964
|
+
};
|
|
29965
|
+
}
|
|
29876
29966
|
return {
|
|
29877
29967
|
ok: true,
|
|
29878
29968
|
value: {
|
|
29879
29969
|
name,
|
|
29880
29970
|
label,
|
|
29881
29971
|
field_type: rawField.type,
|
|
29882
|
-
required
|
|
29883
|
-
|
|
29972
|
+
// Nothing writes a tombstone, so it can be neither required nor NOT NULL.
|
|
29973
|
+
required: tombstone ? false : required2,
|
|
29974
|
+
nullable: tombstone ? true : !required2,
|
|
29884
29975
|
order,
|
|
29885
|
-
validation,
|
|
29976
|
+
validation: tombstone ? { ...validation, required: false } : validation,
|
|
29886
29977
|
db_column,
|
|
29887
|
-
ui_component
|
|
29978
|
+
ui_component,
|
|
29979
|
+
// Omitted entirely when absent, never set to `false`/`undefined`: an
|
|
29980
|
+
// ordinary field must be byte-identical to its pre-versioning shape.
|
|
29981
|
+
...tombstone && { removed: true },
|
|
29982
|
+
...rawField.fallback !== void 0 && { fallback: rawField.fallback }
|
|
29888
29983
|
}
|
|
29889
29984
|
};
|
|
29890
29985
|
}
|
|
@@ -29918,7 +30013,10 @@ function parseContentType(raw2, sourceFile) {
|
|
|
29918
30013
|
}
|
|
29919
30014
|
tabs.push({ name: tab.name, label: tab.label, fields: tabFieldNames });
|
|
29920
30015
|
}
|
|
29921
|
-
const dupErrors =
|
|
30016
|
+
const dupErrors = [
|
|
30017
|
+
...checkDuplicateFieldNames(flatRawFields, sourceFile, v2.name),
|
|
30018
|
+
...checkDuplicateColumns(flatRawFields, sourceFile, v2.name)
|
|
30019
|
+
];
|
|
29922
30020
|
if (dupErrors.length > 0) return { ok: false, errors: dupErrors };
|
|
29923
30021
|
const tableName = machineNameToTableName(v2.name);
|
|
29924
30022
|
const { fields, errors } = buildFields(flatRawFields, sourceFile, tableName);
|
|
@@ -29968,7 +30066,10 @@ function parseParagraphType(raw2, sourceFile) {
|
|
|
29968
30066
|
return { ok: false, errors: zodErrorsToParseErrors(result.error, sourceFile) };
|
|
29969
30067
|
}
|
|
29970
30068
|
const v2 = result.data;
|
|
29971
|
-
const dupErrors =
|
|
30069
|
+
const dupErrors = [
|
|
30070
|
+
...checkDuplicateFieldNames(v2.fields, sourceFile, v2.name),
|
|
30071
|
+
...checkDuplicateColumns(v2.fields, sourceFile, v2.name)
|
|
30072
|
+
];
|
|
29972
30073
|
if (dupErrors.length > 0) return { ok: false, errors: dupErrors };
|
|
29973
30074
|
const tableName = machineNameToTableName(v2.name);
|
|
29974
30075
|
const { fields, errors } = buildFields(v2.fields, sourceFile, tableName);
|
|
@@ -29990,7 +30091,10 @@ function parseTaxonomyType(raw2, sourceFile) {
|
|
|
29990
30091
|
return { ok: false, errors: zodErrorsToParseErrors(result.error, sourceFile) };
|
|
29991
30092
|
}
|
|
29992
30093
|
const v2 = result.data;
|
|
29993
|
-
const dupErrors =
|
|
30094
|
+
const dupErrors = [
|
|
30095
|
+
...checkDuplicateFieldNames(v2.fields, sourceFile, v2.name),
|
|
30096
|
+
...checkDuplicateColumns(v2.fields, sourceFile, v2.name)
|
|
30097
|
+
];
|
|
29994
30098
|
if (dupErrors.length > 0) return { ok: false, errors: dupErrors };
|
|
29995
30099
|
const tableName = machineNameToTableName(v2.name);
|
|
29996
30100
|
const { fields, errors } = buildFields(v2.fields, sourceFile, tableName);
|
|
@@ -30159,6 +30263,342 @@ async function hashPassword(password2) {
|
|
|
30159
30263
|
async function verifyPassword(password2, stored) {
|
|
30160
30264
|
return import_bcryptjs.default.compare(password2, stored);
|
|
30161
30265
|
}
|
|
30266
|
+
var STRUCTURAL_KINDS = ["content_types", "taxonomy_types"];
|
|
30267
|
+
function typeEntries(registry2, kinds = STRUCTURAL_KINDS) {
|
|
30268
|
+
const out = [];
|
|
30269
|
+
for (const kind of kinds) {
|
|
30270
|
+
for (const [name, type] of Object.entries(registry2[kind])) {
|
|
30271
|
+
out.push([name, type.fields]);
|
|
30272
|
+
}
|
|
30273
|
+
}
|
|
30274
|
+
return out;
|
|
30275
|
+
}
|
|
30276
|
+
function fieldsByColumn(registry2, kinds = STRUCTURAL_KINDS) {
|
|
30277
|
+
const out = /* @__PURE__ */ new Map();
|
|
30278
|
+
for (const [typeName, fields] of typeEntries(registry2, kinds)) {
|
|
30279
|
+
const byColumn2 = /* @__PURE__ */ new Map();
|
|
30280
|
+
for (const f of fields) {
|
|
30281
|
+
if (!isColumnBacked2(f)) continue;
|
|
30282
|
+
byColumn2.set(f.db_column.column_name, f);
|
|
30283
|
+
}
|
|
30284
|
+
out.set(typeName, byColumn2);
|
|
30285
|
+
}
|
|
30286
|
+
return out;
|
|
30287
|
+
}
|
|
30288
|
+
function checkUnionCompleteness(input2) {
|
|
30289
|
+
const { union: union3, projections, currentVersion, snapshots } = input2;
|
|
30290
|
+
const errors = [];
|
|
30291
|
+
const unionColumns = fieldsByColumn(union3);
|
|
30292
|
+
for (const [version3, projection] of Object.entries(projections)) {
|
|
30293
|
+
if (version3 === currentVersion) continue;
|
|
30294
|
+
for (const [typeName, type] of Object.entries(projection.types)) {
|
|
30295
|
+
const columns = unionColumns.get(typeName);
|
|
30296
|
+
if (columns === void 0) {
|
|
30297
|
+
errors.push({
|
|
30298
|
+
file: `schemas/versions/${version3}`,
|
|
30299
|
+
code: "VERSION_COLUMN_MISSING",
|
|
30300
|
+
message: `Live version ${version3} exposes type "${typeName}", which the current schema no longer defines. Every column a live version serves must still exist. Keep "${typeName}" in the current schema with its fields marked "removed": true, or retire it with \`manguito version:retire ${version3}\` \u2014 which will refuse if ${version3} is the newest cut version.`
|
|
30301
|
+
});
|
|
30302
|
+
continue;
|
|
30303
|
+
}
|
|
30304
|
+
for (const f of type.fields) {
|
|
30305
|
+
if (columns.has(f.column_name)) continue;
|
|
30306
|
+
errors.push({
|
|
30307
|
+
file: `schemas/versions/${version3}`,
|
|
30308
|
+
code: "VERSION_COLUMN_MISSING",
|
|
30309
|
+
message: `Live version ${version3} exposes column "${f.column_name}" on "${typeName}" (as "${f.exposed_as}"), which the current schema neither exposes nor retains. Either add "column": "${f.column_name}" to the field that replaced it, or add a field { "name": "${f.exposed_as}", "column": "${f.column_name}", "removed": true } to retain the column while ${version3} is live \u2014 use a different "name" if "${f.exposed_as}" is still a live field.`
|
|
30310
|
+
});
|
|
30311
|
+
}
|
|
30312
|
+
}
|
|
30313
|
+
}
|
|
30314
|
+
const paragraphColumns = fieldsByColumn(union3, ["paragraph_types"]);
|
|
30315
|
+
for (const snap of snapshots) {
|
|
30316
|
+
for (const [typeName, fields] of typeEntries(snap.registry, ["paragraph_types"])) {
|
|
30317
|
+
const columns = paragraphColumns.get(typeName);
|
|
30318
|
+
if (columns === void 0) {
|
|
30319
|
+
errors.push({
|
|
30320
|
+
file: `schemas/versions/${snap.version}`,
|
|
30321
|
+
code: "VERSION_COLUMN_MISSING",
|
|
30322
|
+
message: `Live version ${snap.version} exposes paragraph type "${typeName}", which the current schema no longer defines. Every column a live version serves must still exist. Keep "${typeName}" in the current schema with its fields marked "removed": true, or retire it with \`manguito version:retire ${snap.version}\` \u2014 which will refuse if ${snap.version} is the newest cut version.`
|
|
30323
|
+
});
|
|
30324
|
+
continue;
|
|
30325
|
+
}
|
|
30326
|
+
for (const f of fields) {
|
|
30327
|
+
if (!isColumnBacked2(f) || f.removed === true) continue;
|
|
30328
|
+
const column = f.db_column.column_name;
|
|
30329
|
+
if (columns.has(column)) continue;
|
|
30330
|
+
errors.push({
|
|
30331
|
+
file: `schemas/versions/${snap.version}`,
|
|
30332
|
+
code: "VERSION_COLUMN_MISSING",
|
|
30333
|
+
message: `Live version ${snap.version} exposes column "${column}" on paragraph type "${typeName}" (as "${f.name}"), which the current schema neither exposes nor retains. Either add "column": "${column}" to the field that replaced it, or add a field { "name": "${f.name}", "column": "${column}", "removed": true } to retain the column while ${snap.version} is live \u2014 use a different "name" if "${f.name}" is still a live field.`
|
|
30334
|
+
});
|
|
30335
|
+
}
|
|
30336
|
+
}
|
|
30337
|
+
}
|
|
30338
|
+
return errors;
|
|
30339
|
+
}
|
|
30340
|
+
function checkOrphanedTombstones(input2) {
|
|
30341
|
+
const { current, projections, currentVersion, snapshots } = input2;
|
|
30342
|
+
const errors = [];
|
|
30343
|
+
const exposed = /* @__PURE__ */ new Set();
|
|
30344
|
+
for (const [version3, projection] of Object.entries(projections)) {
|
|
30345
|
+
if (version3 === currentVersion) continue;
|
|
30346
|
+
for (const [typeName, type] of Object.entries(projection.types)) {
|
|
30347
|
+
for (const f of type.fields) exposed.add(`${typeName}.${f.column_name}`);
|
|
30348
|
+
}
|
|
30349
|
+
}
|
|
30350
|
+
for (const [typeName, fields] of typeEntries(current)) {
|
|
30351
|
+
for (const f of fields) {
|
|
30352
|
+
if (f.removed !== true || !isColumnBacked2(f)) continue;
|
|
30353
|
+
if (exposed.has(`${typeName}.${f.db_column.column_name}`)) continue;
|
|
30354
|
+
errors.push({
|
|
30355
|
+
file: current.schemas[typeName]?.source_file ?? "",
|
|
30356
|
+
code: "ORPHANED_TOMBSTONE",
|
|
30357
|
+
message: `Field "${f.name}" on "${typeName}" is marked "removed": true, retaining column "${f.db_column.column_name}", but no live version exposes that column any more. It is a column nothing can read. Delete the field \u2014 that shrinks the union and lets db codegen drop the column.`
|
|
30358
|
+
});
|
|
30359
|
+
}
|
|
30360
|
+
}
|
|
30361
|
+
const paragraphExposed = /* @__PURE__ */ new Set();
|
|
30362
|
+
for (const snap of snapshots) {
|
|
30363
|
+
for (const [typeName, fields] of typeEntries(snap.registry, ["paragraph_types"])) {
|
|
30364
|
+
for (const f of fields) {
|
|
30365
|
+
if (!isColumnBacked2(f) || f.removed === true) continue;
|
|
30366
|
+
paragraphExposed.add(`${typeName}.${f.db_column.column_name}`);
|
|
30367
|
+
}
|
|
30368
|
+
}
|
|
30369
|
+
}
|
|
30370
|
+
for (const [typeName, fields] of typeEntries(current, ["paragraph_types"])) {
|
|
30371
|
+
for (const f of fields) {
|
|
30372
|
+
if (f.removed !== true || !isColumnBacked2(f)) continue;
|
|
30373
|
+
if (paragraphExposed.has(`${typeName}.${f.db_column.column_name}`)) continue;
|
|
30374
|
+
errors.push({
|
|
30375
|
+
file: current.schemas[typeName]?.source_file ?? "",
|
|
30376
|
+
code: "ORPHANED_TOMBSTONE",
|
|
30377
|
+
message: `Field "${f.name}" on paragraph type "${typeName}" is marked "removed": true, retaining column "${f.db_column.column_name}", but no live version exposes that column any more. It is a column nothing can read. Delete the field \u2014 that shrinks the union and lets db codegen drop the column.`
|
|
30378
|
+
});
|
|
30379
|
+
}
|
|
30380
|
+
}
|
|
30381
|
+
return errors;
|
|
30382
|
+
}
|
|
30383
|
+
function checkFieldTypeChangedWhileLive(input2) {
|
|
30384
|
+
const { current, snapshots } = input2;
|
|
30385
|
+
const errors = [];
|
|
30386
|
+
function compare(kinds, typeLabel) {
|
|
30387
|
+
const currentByType = fieldsByColumn(current, kinds);
|
|
30388
|
+
for (const snap of snapshots) {
|
|
30389
|
+
for (const [typeName, snapColumns] of fieldsByColumn(snap.registry, kinds)) {
|
|
30390
|
+
const currentColumns = currentByType.get(typeName);
|
|
30391
|
+
if (!currentColumns) continue;
|
|
30392
|
+
for (const [col, oldField] of snapColumns) {
|
|
30393
|
+
const currentField = currentColumns.get(col);
|
|
30394
|
+
if (!currentField) continue;
|
|
30395
|
+
if (currentField.field_type === oldField.field_type) continue;
|
|
30396
|
+
errors.push({
|
|
30397
|
+
file: `schemas/versions/${snap.version}`,
|
|
30398
|
+
code: "FIELD_TYPE_CHANGED_WHILE_LIVE",
|
|
30399
|
+
message: `Column "${col}" on ${typeLabel}"${typeName}" is exposed by live version ${snap.version} as ${oldField.field_type}, but the current schema now types it ${currentField.field_type}. A live version's contract cannot change type under its consumers \u2014 retire ${snap.version} first, or keep the field's type stable and introduce the change as a new column instead.`
|
|
30400
|
+
});
|
|
30401
|
+
}
|
|
30402
|
+
}
|
|
30403
|
+
}
|
|
30404
|
+
}
|
|
30405
|
+
compare(STRUCTURAL_KINDS, "");
|
|
30406
|
+
compare(["paragraph_types"], "paragraph type ");
|
|
30407
|
+
return errors;
|
|
30408
|
+
}
|
|
30409
|
+
function validateVersionModel(input2) {
|
|
30410
|
+
return [
|
|
30411
|
+
...checkUnionCompleteness(input2),
|
|
30412
|
+
...checkOrphanedTombstones(input2),
|
|
30413
|
+
...checkFieldTypeChangedWhileLive(input2)
|
|
30414
|
+
];
|
|
30415
|
+
}
|
|
30416
|
+
function collectFallbacks(current) {
|
|
30417
|
+
const out = /* @__PURE__ */ new Map();
|
|
30418
|
+
for (const [typeName, type] of [
|
|
30419
|
+
...Object.entries(current.content_types),
|
|
30420
|
+
...Object.entries(current.taxonomy_types)
|
|
30421
|
+
]) {
|
|
30422
|
+
for (const f of type.fields) {
|
|
30423
|
+
if (f.fallback === void 0 || !isColumnBacked2(f)) continue;
|
|
30424
|
+
out.set(`${typeName}.${f.db_column.column_name}`, f.fallback);
|
|
30425
|
+
}
|
|
30426
|
+
}
|
|
30427
|
+
return out;
|
|
30428
|
+
}
|
|
30429
|
+
function buildProjections(input2) {
|
|
30430
|
+
const { current, currentVersion, snapshots } = input2;
|
|
30431
|
+
const byVersion = [
|
|
30432
|
+
...snapshots,
|
|
30433
|
+
{ version: currentVersion, registry: current }
|
|
30434
|
+
];
|
|
30435
|
+
const fallbacks = collectFallbacks(current);
|
|
30436
|
+
const out = {};
|
|
30437
|
+
for (const { version: version3, registry: registry2 } of byVersion) {
|
|
30438
|
+
const types3 = {};
|
|
30439
|
+
for (const [typeName, type] of [
|
|
30440
|
+
...Object.entries(registry2.content_types),
|
|
30441
|
+
...Object.entries(registry2.taxonomy_types)
|
|
30442
|
+
]) {
|
|
30443
|
+
const fields = type.fields.filter((f) => isColumnBacked2(f) && f.removed !== true).map((f) => {
|
|
30444
|
+
const column_name = f.db_column.column_name;
|
|
30445
|
+
const fallback = fallbacks.get(`${typeName}.${column_name}`);
|
|
30446
|
+
return fallback === void 0 ? { column_name, exposed_as: f.name } : { column_name, exposed_as: f.name, fallback };
|
|
30447
|
+
});
|
|
30448
|
+
types3[typeName] = { fields };
|
|
30449
|
+
}
|
|
30450
|
+
out[version3] = { version: version3, types: types3 };
|
|
30451
|
+
}
|
|
30452
|
+
return out;
|
|
30453
|
+
}
|
|
30454
|
+
function versionNumber(version3) {
|
|
30455
|
+
const n = Number.parseInt(version3.replace(/^v/, ""), 10);
|
|
30456
|
+
return Number.isNaN(n) ? 0 : n;
|
|
30457
|
+
}
|
|
30458
|
+
function computeVersionModel(input2) {
|
|
30459
|
+
const { current, snapshots } = input2;
|
|
30460
|
+
const highest = snapshots.reduce((max, s) => Math.max(max, versionNumber(s.version)), 0);
|
|
30461
|
+
const currentVersion = `v${highest + 1}`;
|
|
30462
|
+
const live = [
|
|
30463
|
+
...new Set(snapshots.map((s) => s.version).sort((a2, b2) => versionNumber(a2) - versionNumber(b2))),
|
|
30464
|
+
currentVersion
|
|
30465
|
+
];
|
|
30466
|
+
const union3 = current;
|
|
30467
|
+
const projections = buildProjections({ current, currentVersion, snapshots });
|
|
30468
|
+
const errors = validateVersionModel({ current, currentVersion, snapshots, union: union3, projections });
|
|
30469
|
+
if (errors.length > 0) return { ok: false, errors };
|
|
30470
|
+
return { ok: true, value: { current: currentVersion, live, union: union3, projections } };
|
|
30471
|
+
}
|
|
30472
|
+
function discoverSnapshotDirs(versionsDir) {
|
|
30473
|
+
const entries = fs3.readdirSync(versionsDir, { withFileTypes: true });
|
|
30474
|
+
return entries.filter((e) => e.isDirectory() && /^v\d+$/.test(e.name)).map((e) => ({ version: e.name, n: Number.parseInt(e.name.slice(1), 10) })).sort((a2, b2) => a2.n - b2.n).map(({ version: version3 }) => ({ version: version3, dir: path3.join(versionsDir, version3) }));
|
|
30475
|
+
}
|
|
30476
|
+
function walkSnapshotFolders(dir, folders) {
|
|
30477
|
+
const files = [];
|
|
30478
|
+
const errors = [];
|
|
30479
|
+
for (const [folderKey, schemaType] of Object.entries(FOLDER_KEY_TO_SCHEMA_TYPE)) {
|
|
30480
|
+
const folderPath = path3.join(dir, folders[folderKey]);
|
|
30481
|
+
if (!directoryExists(folderPath)) continue;
|
|
30482
|
+
let entries;
|
|
30483
|
+
try {
|
|
30484
|
+
entries = fs3.readdirSync(folderPath);
|
|
30485
|
+
} catch {
|
|
30486
|
+
entries = [];
|
|
30487
|
+
}
|
|
30488
|
+
for (const entry of entries) {
|
|
30489
|
+
if (!isSupportedExtension(entry)) continue;
|
|
30490
|
+
const filePath = path3.join(folderPath, entry);
|
|
30491
|
+
const result = loadSchemaFile(filePath);
|
|
30492
|
+
if (!result.ok) {
|
|
30493
|
+
errors.push(...result.errors);
|
|
30494
|
+
continue;
|
|
30495
|
+
}
|
|
30496
|
+
files.push({ path: filePath, raw: result.value, schema_type: schemaType });
|
|
30497
|
+
}
|
|
30498
|
+
}
|
|
30499
|
+
if (errors.length > 0) return { ok: false, errors };
|
|
30500
|
+
return { ok: true, value: files };
|
|
30501
|
+
}
|
|
30502
|
+
function wrapAsSnapshotInvalid(version3, errors) {
|
|
30503
|
+
return errors.map((e) => ({
|
|
30504
|
+
file: e.file,
|
|
30505
|
+
code: "VERSION_SNAPSHOT_INVALID",
|
|
30506
|
+
message: `Snapshot ${version3} failed to load: ${e.message}`,
|
|
30507
|
+
...e.path !== void 0 ? { path: e.path } : {}
|
|
30508
|
+
}));
|
|
30509
|
+
}
|
|
30510
|
+
function loadSnapshot(version3, dir, folders, current) {
|
|
30511
|
+
const walked = walkSnapshotFolders(dir, folders);
|
|
30512
|
+
if (!walked.ok) return { ok: false, errors: wrapAsSnapshotInvalid(version3, walked.errors) };
|
|
30513
|
+
const schemas = [];
|
|
30514
|
+
const errors = [];
|
|
30515
|
+
for (const file2 of walked.value) {
|
|
30516
|
+
const parsed = parseSchema(file2.raw, file2.schema_type, file2.path);
|
|
30517
|
+
if (!parsed.ok) {
|
|
30518
|
+
errors.push(...parsed.errors);
|
|
30519
|
+
continue;
|
|
30520
|
+
}
|
|
30521
|
+
schemas.push(parsed.schema);
|
|
30522
|
+
}
|
|
30523
|
+
if (errors.length > 0) return { ok: false, errors: wrapAsSnapshotInvalid(version3, errors) };
|
|
30524
|
+
const registry2 = buildSchemaRegistry(schemas, current.routes, current.roles);
|
|
30525
|
+
return { ok: true, value: { version: version3, registry: registry2 } };
|
|
30526
|
+
}
|
|
30527
|
+
function loadVersionSnapshots(config3, current) {
|
|
30528
|
+
const versionsDir = path3.join(config3.base_path, "versions");
|
|
30529
|
+
if (!directoryExists(versionsDir)) return { ok: true, value: [] };
|
|
30530
|
+
const snapshots = [];
|
|
30531
|
+
const errors = [];
|
|
30532
|
+
for (const { version: version3, dir } of discoverSnapshotDirs(versionsDir)) {
|
|
30533
|
+
const result = loadSnapshot(version3, dir, config3.folders, current);
|
|
30534
|
+
if (!result.ok) {
|
|
30535
|
+
errors.push(...result.errors);
|
|
30536
|
+
continue;
|
|
30537
|
+
}
|
|
30538
|
+
snapshots.push(result.value);
|
|
30539
|
+
}
|
|
30540
|
+
if (errors.length > 0) return { ok: false, errors };
|
|
30541
|
+
return { ok: true, value: snapshots };
|
|
30542
|
+
}
|
|
30543
|
+
function typeEntries2(registry2) {
|
|
30544
|
+
return [
|
|
30545
|
+
...Object.entries(registry2.content_types),
|
|
30546
|
+
...Object.entries(registry2.taxonomy_types),
|
|
30547
|
+
...Object.entries(registry2.paragraph_types)
|
|
30548
|
+
].map(([name, type]) => [name, type.fields]);
|
|
30549
|
+
}
|
|
30550
|
+
function byColumn(fields) {
|
|
30551
|
+
const out = /* @__PURE__ */ new Map();
|
|
30552
|
+
for (const f of fields) {
|
|
30553
|
+
if (!isColumnBacked2(f)) continue;
|
|
30554
|
+
out.set(f.db_column.column_name, f);
|
|
30555
|
+
}
|
|
30556
|
+
return out;
|
|
30557
|
+
}
|
|
30558
|
+
function describeSchemaChange(input2) {
|
|
30559
|
+
const { from, to } = input2;
|
|
30560
|
+
const fromTypes = new Map(from === null ? [] : typeEntries2(from.registry));
|
|
30561
|
+
const types3 = [];
|
|
30562
|
+
for (const [typeName, toFields] of typeEntries2(to.registry)) {
|
|
30563
|
+
const fromFields = fromTypes.get(typeName);
|
|
30564
|
+
const fromByColumn = byColumn(fromFields ?? []);
|
|
30565
|
+
const fields = [];
|
|
30566
|
+
for (const [column, toField] of byColumn(toFields)) {
|
|
30567
|
+
const fromField = fromByColumn.get(column);
|
|
30568
|
+
if (fromField === void 0) {
|
|
30569
|
+
fields.push({ kind: "added", column, name: toField.name, field_type: toField.field_type });
|
|
30570
|
+
continue;
|
|
30571
|
+
}
|
|
30572
|
+
const wasTombstone = fromField.removed === true;
|
|
30573
|
+
const isTombstone = toField.removed === true;
|
|
30574
|
+
if (!wasTombstone && isTombstone) {
|
|
30575
|
+
fields.push({
|
|
30576
|
+
kind: "tombstoned",
|
|
30577
|
+
column,
|
|
30578
|
+
name: toField.name,
|
|
30579
|
+
// Omitted entirely rather than set undefined, so an equality check
|
|
30580
|
+
// against the no-fallback case is clean.
|
|
30581
|
+
...toField.fallback !== void 0 && { fallback: toField.fallback }
|
|
30582
|
+
});
|
|
30583
|
+
continue;
|
|
30584
|
+
}
|
|
30585
|
+
if (wasTombstone && !isTombstone) {
|
|
30586
|
+
fields.push({ kind: "restored", column, name: toField.name });
|
|
30587
|
+
continue;
|
|
30588
|
+
}
|
|
30589
|
+
if (fromField.name !== toField.name) {
|
|
30590
|
+
fields.push({ kind: "renamed", column, from_name: fromField.name, to_name: toField.name });
|
|
30591
|
+
}
|
|
30592
|
+
}
|
|
30593
|
+
types3.push({
|
|
30594
|
+
type: typeName,
|
|
30595
|
+
status: fromFields === void 0 ? "added" : "present",
|
|
30596
|
+
fields
|
|
30597
|
+
});
|
|
30598
|
+
}
|
|
30599
|
+
const identical = types3.every((t) => t.status === "present" && t.fields.length === 0);
|
|
30600
|
+
return { from: from?.version ?? null, to: to.version, types: types3, identical };
|
|
30601
|
+
}
|
|
30162
30602
|
|
|
30163
30603
|
// ../db/dist/index.mjs
|
|
30164
30604
|
init_esm_shims();
|
|
@@ -30365,7 +30805,7 @@ init_esm_shims();
|
|
|
30365
30805
|
function mapResultRow(columns, row, joinsNotNullableMap) {
|
|
30366
30806
|
const nullifyMap = {};
|
|
30367
30807
|
const result = columns.reduce(
|
|
30368
|
-
(result2, { path:
|
|
30808
|
+
(result2, { path: path7, field }, columnIndex) => {
|
|
30369
30809
|
let decoder;
|
|
30370
30810
|
if (is(field, Column)) {
|
|
30371
30811
|
decoder = field;
|
|
@@ -30377,8 +30817,8 @@ function mapResultRow(columns, row, joinsNotNullableMap) {
|
|
|
30377
30817
|
decoder = field.sql.decoder;
|
|
30378
30818
|
}
|
|
30379
30819
|
let node = result2;
|
|
30380
|
-
for (const [pathChunkIndex, pathChunk] of
|
|
30381
|
-
if (pathChunkIndex <
|
|
30820
|
+
for (const [pathChunkIndex, pathChunk] of path7.entries()) {
|
|
30821
|
+
if (pathChunkIndex < path7.length - 1) {
|
|
30382
30822
|
if (!(pathChunk in node)) {
|
|
30383
30823
|
node[pathChunk] = {};
|
|
30384
30824
|
}
|
|
@@ -30386,8 +30826,8 @@ function mapResultRow(columns, row, joinsNotNullableMap) {
|
|
|
30386
30826
|
} else {
|
|
30387
30827
|
const rawValue = row[columnIndex];
|
|
30388
30828
|
const value = node[pathChunk] = rawValue === null ? null : decoder.mapFromDriverValue(rawValue);
|
|
30389
|
-
if (joinsNotNullableMap && is(field, Column) &&
|
|
30390
|
-
const objectName =
|
|
30829
|
+
if (joinsNotNullableMap && is(field, Column) && path7.length === 2) {
|
|
30830
|
+
const objectName = path7[0];
|
|
30391
30831
|
if (!(objectName in nullifyMap)) {
|
|
30392
30832
|
nullifyMap[objectName] = value === null ? getTableName(field.table) : false;
|
|
30393
30833
|
} else if (typeof nullifyMap[objectName] === "string" && nullifyMap[objectName] !== getTableName(field.table)) {
|
|
@@ -33755,7 +34195,7 @@ var PgSelectQueryBuilderBase = class extends TypedQueryBuilder {
|
|
|
33755
34195
|
const baseTableName = this.tableName;
|
|
33756
34196
|
const tableName = getTableLikeName(table);
|
|
33757
34197
|
for (const item of extractUsedTable(table)) this.usedTables.add(item);
|
|
33758
|
-
if (typeof tableName === "string" && this.config.joins?.some((
|
|
34198
|
+
if (typeof tableName === "string" && this.config.joins?.some((join14) => join14.alias === tableName)) {
|
|
33759
34199
|
throw new Error(`Alias "${tableName}" is already used in this query`);
|
|
33760
34200
|
}
|
|
33761
34201
|
if (!this.isPartialSelect) {
|
|
@@ -34979,7 +35419,7 @@ var PgUpdateBase = class extends QueryPromise {
|
|
|
34979
35419
|
createJoin(joinType) {
|
|
34980
35420
|
return (table, on) => {
|
|
34981
35421
|
const tableName = getTableLikeName(table);
|
|
34982
|
-
if (typeof tableName === "string" && this.config.joins.some((
|
|
35422
|
+
if (typeof tableName === "string" && this.config.joins.some((join14) => join14.alias === tableName)) {
|
|
34983
35423
|
throw new Error(`Alias "${tableName}" is already used in this query`);
|
|
34984
35424
|
}
|
|
34985
35425
|
if (typeof on === "function") {
|
|
@@ -35075,10 +35515,10 @@ var PgUpdateBase = class extends QueryPromise {
|
|
|
35075
35515
|
const fromFields = this.getTableLikeFields(this.config.from);
|
|
35076
35516
|
fields[tableName] = fromFields;
|
|
35077
35517
|
}
|
|
35078
|
-
for (const
|
|
35079
|
-
const tableName2 = getTableLikeName(
|
|
35080
|
-
if (typeof tableName2 === "string" && !is(
|
|
35081
|
-
const fromFields = this.getTableLikeFields(
|
|
35518
|
+
for (const join14 of this.config.joins) {
|
|
35519
|
+
const tableName2 = getTableLikeName(join14.table);
|
|
35520
|
+
if (typeof tableName2 === "string" && !is(join14.table, SQL)) {
|
|
35521
|
+
const fromFields = this.getTableLikeFields(join14.table);
|
|
35082
35522
|
fields[tableName2] = fromFields;
|
|
35083
35523
|
}
|
|
35084
35524
|
}
|
|
@@ -38842,7 +39282,7 @@ var ds = T((th, ps) => {
|
|
|
38842
39282
|
return /^(?:[a-zA-Z0-9+/]{4})*(?:[a-zA-Z0-9+/]{2}==|[a-zA-Z0-9+/]{3}=)?$/.test(r);
|
|
38843
39283
|
}
|
|
38844
39284
|
a(ls, "isBase64");
|
|
38845
|
-
function
|
|
39285
|
+
function fs7(r) {
|
|
38846
39286
|
if (typeof r != "string") throw new TypeError("SASL: attribute pairs text must be a string");
|
|
38847
39287
|
return new Map(r.split(",").map((e) => {
|
|
38848
39288
|
if (!/^.=/.test(e)) throw new Error("SASL: Invalid attribute pair entry");
|
|
@@ -38850,9 +39290,9 @@ var ds = T((th, ps) => {
|
|
|
38850
39290
|
return [t, n];
|
|
38851
39291
|
}));
|
|
38852
39292
|
}
|
|
38853
|
-
a(
|
|
39293
|
+
a(fs7, "parseAttributePairs");
|
|
38854
39294
|
function qu(r) {
|
|
38855
|
-
let e =
|
|
39295
|
+
let e = fs7(r), t = e.get("r");
|
|
38856
39296
|
if (t) {
|
|
38857
39297
|
if (!Ou(t)) throw new Error("SASL: SCRAM-SERVER-FIRST-MESSAGE: nonce must only contain printable characters");
|
|
38858
39298
|
} else throw new Error("SASL: SCRAM-SERVER-FIRST-MESSAGE: nonce missing");
|
|
@@ -38869,7 +39309,7 @@ var ds = T((th, ps) => {
|
|
|
38869
39309
|
}
|
|
38870
39310
|
a(qu, "parseServerFirstMessage");
|
|
38871
39311
|
function Qu(r) {
|
|
38872
|
-
let t =
|
|
39312
|
+
let t = fs7(r).get("v");
|
|
38873
39313
|
if (t) {
|
|
38874
39314
|
if (!ls(t)) throw new Error("SASL: SCRAM-SERVER-FINAL-MESSAGE: server signature must be base64");
|
|
38875
39315
|
} else throw new Error("SASL: SCRAM-SERVER-FINAL-MESSAGE: server signature is missing");
|
|
@@ -41605,8 +42045,8 @@ function drizzle2(...params) {
|
|
|
41605
42045
|
// ../db/dist/index.mjs
|
|
41606
42046
|
import { execSync, spawnSync } from "child_process";
|
|
41607
42047
|
import crypto2 from "crypto";
|
|
41608
|
-
import
|
|
41609
|
-
import
|
|
42048
|
+
import path4 from "path";
|
|
42049
|
+
import fs4 from "fs/promises";
|
|
41610
42050
|
import { readFileSync as readFileSync2 } from "fs";
|
|
41611
42051
|
import path22 from "path";
|
|
41612
42052
|
function createPostgresAdapter(options = {}) {
|
|
@@ -42092,32 +42532,32 @@ async function seedSystemTables(db, registry2, options = {}) {
|
|
|
42092
42532
|
}
|
|
42093
42533
|
function resolvedPathEnv() {
|
|
42094
42534
|
const root = process.cwd();
|
|
42095
|
-
const localBin =
|
|
42096
|
-
const existing = (process.env.PATH ?? "").split(
|
|
42097
|
-
return { ...process.env, PATH: [localBin, ...existing].join(
|
|
42535
|
+
const localBin = path4.join(root, "node_modules", ".bin");
|
|
42536
|
+
const existing = (process.env.PATH ?? "").split(path4.delimiter).filter(Boolean).map((entry) => path4.isAbsolute(entry) ? entry : path4.resolve(root, entry));
|
|
42537
|
+
return { ...process.env, PATH: [localBin, ...existing].join(path4.delimiter) };
|
|
42098
42538
|
}
|
|
42099
42539
|
async function runDevMigration(configPath) {
|
|
42100
42540
|
execSync(`drizzle-kit push --config=${configPath}`, {
|
|
42101
42541
|
stdio: "inherit",
|
|
42102
|
-
cwd:
|
|
42542
|
+
cwd: path4.dirname(configPath),
|
|
42103
42543
|
env: resolvedPathEnv()
|
|
42104
42544
|
});
|
|
42105
42545
|
}
|
|
42106
42546
|
async function generateMigration(configPath, migrationsFolder) {
|
|
42107
42547
|
let beforeFiles = [];
|
|
42108
42548
|
try {
|
|
42109
|
-
const entries = await
|
|
42549
|
+
const entries = await fs4.readdir(migrationsFolder);
|
|
42110
42550
|
beforeFiles = entries.filter((f) => f.endsWith(".sql"));
|
|
42111
42551
|
} catch {
|
|
42112
42552
|
}
|
|
42113
42553
|
execSync(`drizzle-kit generate --config=${configPath}`, {
|
|
42114
42554
|
stdio: "inherit",
|
|
42115
|
-
cwd:
|
|
42555
|
+
cwd: path4.dirname(configPath),
|
|
42116
42556
|
env: resolvedPathEnv()
|
|
42117
42557
|
});
|
|
42118
42558
|
let afterFiles = [];
|
|
42119
42559
|
try {
|
|
42120
|
-
const entries = await
|
|
42560
|
+
const entries = await fs4.readdir(migrationsFolder);
|
|
42121
42561
|
afterFiles = entries.filter((f) => f.endsWith(".sql"));
|
|
42122
42562
|
} catch {
|
|
42123
42563
|
}
|
|
@@ -42138,16 +42578,16 @@ async function applyMigrations(configPath, db, options) {
|
|
|
42138
42578
|
if (statusBefore.pending.length > 0) {
|
|
42139
42579
|
let journalEntries = [];
|
|
42140
42580
|
try {
|
|
42141
|
-
const journalPath =
|
|
42142
|
-
const raw2 = await
|
|
42581
|
+
const journalPath = path4.join(migrationsFolder, "meta", "_journal.json");
|
|
42582
|
+
const raw2 = await fs4.readFile(journalPath, "utf-8");
|
|
42143
42583
|
journalEntries = JSON.parse(raw2).entries;
|
|
42144
42584
|
} catch {
|
|
42145
42585
|
}
|
|
42146
42586
|
for (const pendingFile of statusBefore.pending) {
|
|
42147
|
-
const sqlPath =
|
|
42587
|
+
const sqlPath = path4.join(migrationsFolder, pendingFile);
|
|
42148
42588
|
let sqlContent;
|
|
42149
42589
|
try {
|
|
42150
|
-
sqlContent = await
|
|
42590
|
+
sqlContent = await fs4.readFile(sqlPath, "utf-8");
|
|
42151
42591
|
} catch {
|
|
42152
42592
|
continue;
|
|
42153
42593
|
}
|
|
@@ -42177,7 +42617,7 @@ async function applyMigrations(configPath, db, options) {
|
|
|
42177
42617
|
"drizzle-kit",
|
|
42178
42618
|
["migrate", `--config=${configPath}`],
|
|
42179
42619
|
{
|
|
42180
|
-
cwd:
|
|
42620
|
+
cwd: path4.dirname(configPath),
|
|
42181
42621
|
// inherit lets drizzle-kit write its spinner and errors directly to the
|
|
42182
42622
|
// terminal in real time — capturing stdout/stderr swallows ANSI overwrites
|
|
42183
42623
|
// and hides the actual error message.
|
|
@@ -42203,8 +42643,8 @@ async function getMigrationStatus(db, options) {
|
|
|
42203
42643
|
const { migrationsTable, migrationsFolder } = options;
|
|
42204
42644
|
let journalEntries;
|
|
42205
42645
|
try {
|
|
42206
|
-
const journalPath =
|
|
42207
|
-
const raw2 = await
|
|
42646
|
+
const journalPath = path4.join(migrationsFolder, "meta", "_journal.json");
|
|
42647
|
+
const raw2 = await fs4.readFile(journalPath, "utf-8");
|
|
42208
42648
|
const journal = JSON.parse(raw2);
|
|
42209
42649
|
journalEntries = journal.entries;
|
|
42210
42650
|
} catch {
|
|
@@ -42302,17 +42742,17 @@ function scanMigrationFiles(filePaths) {
|
|
|
42302
42742
|
// src/codegen/registry.ts
|
|
42303
42743
|
init_esm_shims();
|
|
42304
42744
|
import { writeFile } from "fs/promises";
|
|
42305
|
-
import { join as
|
|
42745
|
+
import { join as join3 } from "path";
|
|
42306
42746
|
async function generateSchemaRegistry(registry2, targetDir) {
|
|
42307
42747
|
const content = `export const schemaRegistry = ${JSON.stringify(registry2, null, 2)} as const
|
|
42308
42748
|
`;
|
|
42309
|
-
await writeFile(
|
|
42749
|
+
await writeFile(join3(targetDir, "schema-registry.ts"), content, "utf8");
|
|
42310
42750
|
}
|
|
42311
42751
|
|
|
42312
42752
|
// src/codegen/routes.ts
|
|
42313
42753
|
init_esm_shims();
|
|
42314
42754
|
import { writeFile as writeFile2 } from "fs/promises";
|
|
42315
|
-
import { join as
|
|
42755
|
+
import { join as join4 } from "path";
|
|
42316
42756
|
|
|
42317
42757
|
// ../api/dist/codegen/index.mjs
|
|
42318
42758
|
init_esm_shims();
|
|
@@ -42985,13 +43425,13 @@ function generateRoutes(registry2) {
|
|
|
42985
43425
|
// src/codegen/routes.ts
|
|
42986
43426
|
async function generateRoutes2(registry2, targetDir) {
|
|
42987
43427
|
const content = generateRoutes(registry2);
|
|
42988
|
-
await writeFile2(
|
|
43428
|
+
await writeFile2(join4(targetDir, "routes.ts"), content, "utf8");
|
|
42989
43429
|
}
|
|
42990
43430
|
|
|
42991
43431
|
// src/codegen/forms.ts
|
|
42992
43432
|
init_esm_shims();
|
|
42993
43433
|
import { mkdir, writeFile as writeFile3 } from "fs/promises";
|
|
42994
|
-
import { join as
|
|
43434
|
+
import { join as join5 } from "path";
|
|
42995
43435
|
|
|
42996
43436
|
// ../admin/dist/codegen/index.js
|
|
42997
43437
|
init_esm_shims();
|
|
@@ -43082,7 +43522,7 @@ function renderField(field, indent) {
|
|
|
43082
43522
|
return lines.join("\n");
|
|
43083
43523
|
}
|
|
43084
43524
|
function generateFormComponent(schema) {
|
|
43085
|
-
const
|
|
43525
|
+
const fields = schema.fields.filter((f) => f.removed !== true);
|
|
43086
43526
|
const neededComponents = /* @__PURE__ */ new Set();
|
|
43087
43527
|
const paragraphRefs = [];
|
|
43088
43528
|
const seenRefs = /* @__PURE__ */ new Set();
|
|
@@ -43132,7 +43572,9 @@ function generateFormComponent(schema) {
|
|
|
43132
43572
|
for (const tab of schema.ui.tabs) {
|
|
43133
43573
|
templateLines.push(` <Tab name="${escAttr(tab.name)}" label="${escAttr(tab.label)}">`);
|
|
43134
43574
|
for (const fieldName of tab.fields) {
|
|
43135
|
-
|
|
43575
|
+
const field = fieldByName.get(fieldName);
|
|
43576
|
+
if (!field) continue;
|
|
43577
|
+
templateLines.push(renderField(field, " "));
|
|
43136
43578
|
}
|
|
43137
43579
|
templateLines.push(" </Tab>");
|
|
43138
43580
|
}
|
|
@@ -43157,19 +43599,19 @@ async function generateForms(registry2, formsDir) {
|
|
|
43157
43599
|
];
|
|
43158
43600
|
for (const schema of schemas) {
|
|
43159
43601
|
const content = generateFormComponent(schema);
|
|
43160
|
-
await writeFile3(
|
|
43602
|
+
await writeFile3(join5(formsDir, `${schema.name}.vue`), content, "utf8");
|
|
43161
43603
|
}
|
|
43162
43604
|
}
|
|
43163
43605
|
|
|
43164
43606
|
// src/codegen/server-entries.ts
|
|
43165
43607
|
init_esm_shims();
|
|
43166
43608
|
import { writeFile as writeFile4 } from "fs/promises";
|
|
43167
|
-
import { join as
|
|
43609
|
+
import { join as join6 } from "path";
|
|
43168
43610
|
async function generateServerEntries(options, targetDir) {
|
|
43169
43611
|
await Promise.all([
|
|
43170
|
-
writeFile4(
|
|
43171
|
-
writeFile4(
|
|
43172
|
-
writeFile4(
|
|
43612
|
+
writeFile4(join6(targetDir, "server.ts"), serverEntry(options), "utf8"),
|
|
43613
|
+
writeFile4(join6(targetDir, "handler.ts"), lambdaEntry(options), "utf8"),
|
|
43614
|
+
writeFile4(join6(targetDir, "vercel.ts"), vercelEntry(options), "utf8")
|
|
43173
43615
|
]);
|
|
43174
43616
|
}
|
|
43175
43617
|
function appSetup() {
|
|
@@ -43353,7 +43795,7 @@ export default handle(app)
|
|
|
43353
43795
|
// src/codegen/programmatic-registry.ts
|
|
43354
43796
|
init_esm_shims();
|
|
43355
43797
|
import { writeFile as writeFile5 } from "fs/promises";
|
|
43356
|
-
import { join as
|
|
43798
|
+
import { join as join7, relative } from "path";
|
|
43357
43799
|
function importSpecifier(targetDir, file2) {
|
|
43358
43800
|
let rel = relative(targetDir, file2).replace(/\\/g, "/");
|
|
43359
43801
|
if (!rel.startsWith(".")) rel = `./${rel}`;
|
|
@@ -43375,7 +43817,7 @@ export const programmaticResolvers = new Map<string, ProgrammaticFieldDefinition
|
|
|
43375
43817
|
${entries},
|
|
43376
43818
|
])
|
|
43377
43819
|
`;
|
|
43378
|
-
await writeFile5(
|
|
43820
|
+
await writeFile5(join7(targetDir, "programmatic-registry.ts"), body, "utf8");
|
|
43379
43821
|
}
|
|
43380
43822
|
|
|
43381
43823
|
// src/utils/config.ts
|
|
@@ -43555,10 +43997,10 @@ async function runBuild(options, deps) {
|
|
|
43555
43997
|
);
|
|
43556
43998
|
const generatedDir = resolve3(cwd, "dist/generated");
|
|
43557
43999
|
mkdirSync(generatedDir, { recursive: true });
|
|
43558
|
-
writeFileSync(
|
|
44000
|
+
writeFileSync(join8(generatedDir, "schema.ts"), generateSchemaFile(registry2), "utf8");
|
|
43559
44001
|
await generateSchemaRegistry(registry2, generatedDir);
|
|
43560
44002
|
await generateRoutes2(registry2, generatedDir);
|
|
43561
|
-
await generateForms(registry2,
|
|
44003
|
+
await generateForms(registry2, join8(generatedDir, "forms"));
|
|
43562
44004
|
const programmaticDir = resolve3(cwd, config3.programmatic.dir);
|
|
43563
44005
|
const resolverFiles = existsSync3(programmaticDir) ? walkFiles(programmaticDir).filter((f) => /\.(ts|mjs|js)$/.test(f)) : [];
|
|
43564
44006
|
await generateProgrammaticRegistry(resolverFiles, generatedDir);
|
|
@@ -43625,14 +44067,14 @@ async function needsRebuild(cwd) {
|
|
|
43625
44067
|
);
|
|
43626
44068
|
}
|
|
43627
44069
|
function resolveAdminRoot(cwd) {
|
|
43628
|
-
const cwdRequire = createRequire(
|
|
44070
|
+
const cwdRequire = createRequire(join8(cwd, "package.json"));
|
|
43629
44071
|
const adminPkgJson = cwdRequire.resolve("@bobbykim/manguito-cms-admin/package.json");
|
|
43630
44072
|
return dirname(adminPkgJson);
|
|
43631
44073
|
}
|
|
43632
44074
|
function walkFiles(dir) {
|
|
43633
44075
|
const files = [];
|
|
43634
|
-
for (const entry of
|
|
43635
|
-
const full =
|
|
44076
|
+
for (const entry of readdirSync3(dir, { withFileTypes: true })) {
|
|
44077
|
+
const full = join8(dir, entry.name);
|
|
43636
44078
|
if (entry.isDirectory()) {
|
|
43637
44079
|
files.push(...walkFiles(full));
|
|
43638
44080
|
} else {
|
|
@@ -43646,7 +44088,7 @@ function walkFiles(dir) {
|
|
|
43646
44088
|
init_esm_shims();
|
|
43647
44089
|
import { createServer as createHttpServer } from "http";
|
|
43648
44090
|
import { existsSync as existsSync5 } from "fs";
|
|
43649
|
-
import { resolve as resolve6, join as
|
|
44091
|
+
import { resolve as resolve6, join as join12, dirname as dirname2, extname as extname4 } from "path";
|
|
43650
44092
|
import { mkdir as mkdir2, writeFile as writeFile8, watch, readFile } from "fs/promises";
|
|
43651
44093
|
import { createRequire as createRequire2 } from "module";
|
|
43652
44094
|
import { createServer as createViteServer, searchForWorkspaceRoot } from "vite";
|
|
@@ -43823,26 +44265,26 @@ var handleParsingNestedValues = (form, key, value) => {
|
|
|
43823
44265
|
|
|
43824
44266
|
// ../../node_modules/.pnpm/hono@4.12.28/node_modules/hono/dist/utils/url.js
|
|
43825
44267
|
init_esm_shims();
|
|
43826
|
-
var splitPath = (
|
|
43827
|
-
const paths =
|
|
44268
|
+
var splitPath = (path7) => {
|
|
44269
|
+
const paths = path7.split("/");
|
|
43828
44270
|
if (paths[0] === "") {
|
|
43829
44271
|
paths.shift();
|
|
43830
44272
|
}
|
|
43831
44273
|
return paths;
|
|
43832
44274
|
};
|
|
43833
44275
|
var splitRoutingPath = (routePath) => {
|
|
43834
|
-
const { groups, path:
|
|
43835
|
-
const paths = splitPath(
|
|
44276
|
+
const { groups, path: path7 } = extractGroupsFromPath(routePath);
|
|
44277
|
+
const paths = splitPath(path7);
|
|
43836
44278
|
return replaceGroupMarks(paths, groups);
|
|
43837
44279
|
};
|
|
43838
|
-
var extractGroupsFromPath = (
|
|
44280
|
+
var extractGroupsFromPath = (path7) => {
|
|
43839
44281
|
const groups = [];
|
|
43840
|
-
|
|
44282
|
+
path7 = path7.replace(/\{[^}]+\}/g, (match2, index) => {
|
|
43841
44283
|
const mark = `@${index}`;
|
|
43842
44284
|
groups.push([mark, match2]);
|
|
43843
44285
|
return mark;
|
|
43844
44286
|
});
|
|
43845
|
-
return { groups, path:
|
|
44287
|
+
return { groups, path: path7 };
|
|
43846
44288
|
};
|
|
43847
44289
|
var replaceGroupMarks = (paths, groups) => {
|
|
43848
44290
|
for (let i = groups.length - 1; i >= 0; i--) {
|
|
@@ -43899,8 +44341,8 @@ var getPath = (request) => {
|
|
|
43899
44341
|
const queryIndex = url2.indexOf("?", i);
|
|
43900
44342
|
const hashIndex = url2.indexOf("#", i);
|
|
43901
44343
|
const end = queryIndex === -1 ? hashIndex === -1 ? void 0 : hashIndex : hashIndex === -1 ? queryIndex : Math.min(queryIndex, hashIndex);
|
|
43902
|
-
const
|
|
43903
|
-
return tryDecodeURI(
|
|
44344
|
+
const path7 = url2.slice(start, end);
|
|
44345
|
+
return tryDecodeURI(path7.includes("%25") ? path7.replace(/%25/g, "%2525") : path7);
|
|
43904
44346
|
} else if (charCode === 63 || charCode === 35) {
|
|
43905
44347
|
break;
|
|
43906
44348
|
}
|
|
@@ -43917,11 +44359,11 @@ var mergePath = (base, sub, ...rest) => {
|
|
|
43917
44359
|
}
|
|
43918
44360
|
return `${base?.[0] === "/" ? "" : "/"}${base}${sub === "/" ? "" : `${base?.at(-1) === "/" ? "" : "/"}${sub?.[0] === "/" ? sub.slice(1) : sub}`}`;
|
|
43919
44361
|
};
|
|
43920
|
-
var checkOptionalParameter = (
|
|
43921
|
-
if (
|
|
44362
|
+
var checkOptionalParameter = (path7) => {
|
|
44363
|
+
if (path7.charCodeAt(path7.length - 1) !== 63 || !path7.includes(":")) {
|
|
43922
44364
|
return null;
|
|
43923
44365
|
}
|
|
43924
|
-
const segments =
|
|
44366
|
+
const segments = path7.split("/");
|
|
43925
44367
|
const results = [];
|
|
43926
44368
|
let basePath = "";
|
|
43927
44369
|
segments.forEach((segment) => {
|
|
@@ -44062,9 +44504,9 @@ var HonoRequest = class {
|
|
|
44062
44504
|
*/
|
|
44063
44505
|
path;
|
|
44064
44506
|
bodyCache = {};
|
|
44065
|
-
constructor(request,
|
|
44507
|
+
constructor(request, path7 = "/", matchResult = [[]]) {
|
|
44066
44508
|
this.raw = request;
|
|
44067
|
-
this.path =
|
|
44509
|
+
this.path = path7;
|
|
44068
44510
|
this.#matchResult = matchResult;
|
|
44069
44511
|
this.#validatedData = {};
|
|
44070
44512
|
}
|
|
@@ -44819,8 +45261,8 @@ var Hono = class _Hono {
|
|
|
44819
45261
|
return this;
|
|
44820
45262
|
};
|
|
44821
45263
|
});
|
|
44822
|
-
this.on = (method,
|
|
44823
|
-
for (const p2 of [
|
|
45264
|
+
this.on = (method, path7, ...handlers) => {
|
|
45265
|
+
for (const p2 of [path7].flat()) {
|
|
44824
45266
|
this.#path = p2;
|
|
44825
45267
|
for (const m2 of [method].flat()) {
|
|
44826
45268
|
handlers.map((handler) => {
|
|
@@ -44877,8 +45319,8 @@ var Hono = class _Hono {
|
|
|
44877
45319
|
* app.route("/api", app2) // GET /api/user
|
|
44878
45320
|
* ```
|
|
44879
45321
|
*/
|
|
44880
|
-
route(
|
|
44881
|
-
const subApp = this.basePath(
|
|
45322
|
+
route(path7, app) {
|
|
45323
|
+
const subApp = this.basePath(path7);
|
|
44882
45324
|
app.routes.map((r) => {
|
|
44883
45325
|
let handler;
|
|
44884
45326
|
if (app.errorHandler === errorHandler) {
|
|
@@ -44904,9 +45346,9 @@ var Hono = class _Hono {
|
|
|
44904
45346
|
* const api = new Hono().basePath('/api')
|
|
44905
45347
|
* ```
|
|
44906
45348
|
*/
|
|
44907
|
-
basePath(
|
|
45349
|
+
basePath(path7) {
|
|
44908
45350
|
const subApp = this.#clone();
|
|
44909
|
-
subApp._basePath = mergePath(this._basePath,
|
|
45351
|
+
subApp._basePath = mergePath(this._basePath, path7);
|
|
44910
45352
|
return subApp;
|
|
44911
45353
|
}
|
|
44912
45354
|
/**
|
|
@@ -44980,7 +45422,7 @@ var Hono = class _Hono {
|
|
|
44980
45422
|
* })
|
|
44981
45423
|
* ```
|
|
44982
45424
|
*/
|
|
44983
|
-
mount(
|
|
45425
|
+
mount(path7, applicationHandler, options) {
|
|
44984
45426
|
let replaceRequest;
|
|
44985
45427
|
let optionHandler;
|
|
44986
45428
|
if (options) {
|
|
@@ -45007,7 +45449,7 @@ var Hono = class _Hono {
|
|
|
45007
45449
|
return [c.env, executionContext];
|
|
45008
45450
|
};
|
|
45009
45451
|
replaceRequest ||= (() => {
|
|
45010
|
-
const mergedPath = mergePath(this._basePath,
|
|
45452
|
+
const mergedPath = mergePath(this._basePath, path7);
|
|
45011
45453
|
const pathPrefixLength = mergedPath === "/" ? 0 : mergedPath.length;
|
|
45012
45454
|
return (request) => {
|
|
45013
45455
|
const url2 = new URL(request.url);
|
|
@@ -45022,19 +45464,19 @@ var Hono = class _Hono {
|
|
|
45022
45464
|
}
|
|
45023
45465
|
await next();
|
|
45024
45466
|
};
|
|
45025
|
-
this.#addRoute(METHOD_NAME_ALL, mergePath(
|
|
45467
|
+
this.#addRoute(METHOD_NAME_ALL, mergePath(path7, "*"), handler);
|
|
45026
45468
|
return this;
|
|
45027
45469
|
}
|
|
45028
|
-
#addRoute(method,
|
|
45470
|
+
#addRoute(method, path7, handler, baseRoutePath) {
|
|
45029
45471
|
method = method.toUpperCase();
|
|
45030
|
-
|
|
45472
|
+
path7 = mergePath(this._basePath, path7);
|
|
45031
45473
|
const r = {
|
|
45032
45474
|
basePath: baseRoutePath !== void 0 ? mergePath(this._basePath, baseRoutePath) : this._basePath,
|
|
45033
|
-
path:
|
|
45475
|
+
path: path7,
|
|
45034
45476
|
method,
|
|
45035
45477
|
handler
|
|
45036
45478
|
};
|
|
45037
|
-
this.router.add(method,
|
|
45479
|
+
this.router.add(method, path7, [handler, r]);
|
|
45038
45480
|
this.routes.push(r);
|
|
45039
45481
|
}
|
|
45040
45482
|
#handleError(err, c) {
|
|
@@ -45047,10 +45489,10 @@ var Hono = class _Hono {
|
|
|
45047
45489
|
if (method === "HEAD") {
|
|
45048
45490
|
return (async () => new Response(null, await this.#dispatch(request, executionCtx, env, "GET")))();
|
|
45049
45491
|
}
|
|
45050
|
-
const
|
|
45051
|
-
const matchResult = this.router.match(method,
|
|
45492
|
+
const path7 = this.getPath(request, { env });
|
|
45493
|
+
const matchResult = this.router.match(method, path7);
|
|
45052
45494
|
const c = new Context(request, {
|
|
45053
|
-
path:
|
|
45495
|
+
path: path7,
|
|
45054
45496
|
matchResult,
|
|
45055
45497
|
env,
|
|
45056
45498
|
executionCtx,
|
|
@@ -45157,7 +45599,7 @@ init_esm_shims();
|
|
|
45157
45599
|
// ../../node_modules/.pnpm/hono@4.12.28/node_modules/hono/dist/router/reg-exp-router/matcher.js
|
|
45158
45600
|
init_esm_shims();
|
|
45159
45601
|
var emptyParam = [];
|
|
45160
|
-
function match(method,
|
|
45602
|
+
function match(method, path7) {
|
|
45161
45603
|
const matchers = this.buildAllMatchers();
|
|
45162
45604
|
const match2 = ((method2, path23) => {
|
|
45163
45605
|
const matcher = matchers[method2] || matchers[METHOD_NAME_ALL];
|
|
@@ -45173,7 +45615,7 @@ function match(method, path3) {
|
|
|
45173
45615
|
return [matcher[1][index], match3];
|
|
45174
45616
|
});
|
|
45175
45617
|
this.match = match2;
|
|
45176
|
-
return match2(method,
|
|
45618
|
+
return match2(method, path7);
|
|
45177
45619
|
}
|
|
45178
45620
|
|
|
45179
45621
|
// ../../node_modules/.pnpm/hono@4.12.28/node_modules/hono/dist/router/reg-exp-router/node.js
|
|
@@ -45290,12 +45732,12 @@ init_esm_shims();
|
|
|
45290
45732
|
var Trie = class {
|
|
45291
45733
|
#context = { varIndex: 0 };
|
|
45292
45734
|
#root = new Node();
|
|
45293
|
-
insert(
|
|
45735
|
+
insert(path7, index, pathErrorCheckOnly) {
|
|
45294
45736
|
const paramAssoc = [];
|
|
45295
45737
|
const groups = [];
|
|
45296
45738
|
for (let i = 0; ; ) {
|
|
45297
45739
|
let replaced = false;
|
|
45298
|
-
|
|
45740
|
+
path7 = path7.replace(/\{[^}]+\}/g, (m2) => {
|
|
45299
45741
|
const mark = `@\\${i}`;
|
|
45300
45742
|
groups[i] = [mark, m2];
|
|
45301
45743
|
i++;
|
|
@@ -45306,7 +45748,7 @@ var Trie = class {
|
|
|
45306
45748
|
break;
|
|
45307
45749
|
}
|
|
45308
45750
|
}
|
|
45309
|
-
const tokens =
|
|
45751
|
+
const tokens = path7.match(/(?::[^\/]+)|(?:\/\*$)|./g) || [];
|
|
45310
45752
|
for (let i = groups.length - 1; i >= 0; i--) {
|
|
45311
45753
|
const [mark] = groups[i];
|
|
45312
45754
|
for (let j = tokens.length - 1; j >= 0; j--) {
|
|
@@ -45345,9 +45787,9 @@ var Trie = class {
|
|
|
45345
45787
|
// ../../node_modules/.pnpm/hono@4.12.28/node_modules/hono/dist/router/reg-exp-router/router.js
|
|
45346
45788
|
var nullMatcher = [/^$/, [], /* @__PURE__ */ Object.create(null)];
|
|
45347
45789
|
var wildcardRegExpCache = /* @__PURE__ */ Object.create(null);
|
|
45348
|
-
function buildWildcardRegExp(
|
|
45349
|
-
return wildcardRegExpCache[
|
|
45350
|
-
|
|
45790
|
+
function buildWildcardRegExp(path7) {
|
|
45791
|
+
return wildcardRegExpCache[path7] ??= new RegExp(
|
|
45792
|
+
path7 === "*" ? "" : `^${path7.replace(
|
|
45351
45793
|
/\/\*$|([.\\+*[^\]$()])/g,
|
|
45352
45794
|
(_, metaChar) => metaChar ? `\\${metaChar}` : "(?:|/.*)"
|
|
45353
45795
|
)}$`
|
|
@@ -45369,17 +45811,17 @@ function buildMatcherFromPreprocessedRoutes(routes) {
|
|
|
45369
45811
|
);
|
|
45370
45812
|
const staticMap = /* @__PURE__ */ Object.create(null);
|
|
45371
45813
|
for (let i = 0, j = -1, len = routesWithStaticPathFlag.length; i < len; i++) {
|
|
45372
|
-
const [pathErrorCheckOnly,
|
|
45814
|
+
const [pathErrorCheckOnly, path7, handlers] = routesWithStaticPathFlag[i];
|
|
45373
45815
|
if (pathErrorCheckOnly) {
|
|
45374
|
-
staticMap[
|
|
45816
|
+
staticMap[path7] = [handlers.map(([h]) => [h, /* @__PURE__ */ Object.create(null)]), emptyParam];
|
|
45375
45817
|
} else {
|
|
45376
45818
|
j++;
|
|
45377
45819
|
}
|
|
45378
45820
|
let paramAssoc;
|
|
45379
45821
|
try {
|
|
45380
|
-
paramAssoc = trie.insert(
|
|
45822
|
+
paramAssoc = trie.insert(path7, j, pathErrorCheckOnly);
|
|
45381
45823
|
} catch (e) {
|
|
45382
|
-
throw e === PATH_ERROR ? new UnsupportedPathError(
|
|
45824
|
+
throw e === PATH_ERROR ? new UnsupportedPathError(path7) : e;
|
|
45383
45825
|
}
|
|
45384
45826
|
if (pathErrorCheckOnly) {
|
|
45385
45827
|
continue;
|
|
@@ -45413,12 +45855,12 @@ function buildMatcherFromPreprocessedRoutes(routes) {
|
|
|
45413
45855
|
}
|
|
45414
45856
|
return [regexp, handlerMap, staticMap];
|
|
45415
45857
|
}
|
|
45416
|
-
function findMiddleware(middleware,
|
|
45858
|
+
function findMiddleware(middleware, path7) {
|
|
45417
45859
|
if (!middleware) {
|
|
45418
45860
|
return void 0;
|
|
45419
45861
|
}
|
|
45420
45862
|
for (const k of Object.keys(middleware).sort((a2, b2) => b2.length - a2.length)) {
|
|
45421
|
-
if (buildWildcardRegExp(k).test(
|
|
45863
|
+
if (buildWildcardRegExp(k).test(path7)) {
|
|
45422
45864
|
return [...middleware[k]];
|
|
45423
45865
|
}
|
|
45424
45866
|
}
|
|
@@ -45432,7 +45874,7 @@ var RegExpRouter = class {
|
|
|
45432
45874
|
this.#middleware = { [METHOD_NAME_ALL]: /* @__PURE__ */ Object.create(null) };
|
|
45433
45875
|
this.#routes = { [METHOD_NAME_ALL]: /* @__PURE__ */ Object.create(null) };
|
|
45434
45876
|
}
|
|
45435
|
-
add(method,
|
|
45877
|
+
add(method, path7, handler) {
|
|
45436
45878
|
const middleware = this.#middleware;
|
|
45437
45879
|
const routes = this.#routes;
|
|
45438
45880
|
if (!middleware || !routes) {
|
|
@@ -45447,18 +45889,18 @@ var RegExpRouter = class {
|
|
|
45447
45889
|
});
|
|
45448
45890
|
});
|
|
45449
45891
|
}
|
|
45450
|
-
if (
|
|
45451
|
-
|
|
45892
|
+
if (path7 === "/*") {
|
|
45893
|
+
path7 = "*";
|
|
45452
45894
|
}
|
|
45453
|
-
const paramCount = (
|
|
45454
|
-
if (/\*$/.test(
|
|
45455
|
-
const re = buildWildcardRegExp(
|
|
45895
|
+
const paramCount = (path7.match(/\/:/g) || []).length;
|
|
45896
|
+
if (/\*$/.test(path7)) {
|
|
45897
|
+
const re = buildWildcardRegExp(path7);
|
|
45456
45898
|
if (method === METHOD_NAME_ALL) {
|
|
45457
45899
|
Object.keys(middleware).forEach((m2) => {
|
|
45458
|
-
middleware[m2][
|
|
45900
|
+
middleware[m2][path7] ||= findMiddleware(middleware[m2], path7) || findMiddleware(middleware[METHOD_NAME_ALL], path7) || [];
|
|
45459
45901
|
});
|
|
45460
45902
|
} else {
|
|
45461
|
-
middleware[method][
|
|
45903
|
+
middleware[method][path7] ||= findMiddleware(middleware[method], path7) || findMiddleware(middleware[METHOD_NAME_ALL], path7) || [];
|
|
45462
45904
|
}
|
|
45463
45905
|
Object.keys(middleware).forEach((m2) => {
|
|
45464
45906
|
if (method === METHOD_NAME_ALL || method === m2) {
|
|
@@ -45476,7 +45918,7 @@ var RegExpRouter = class {
|
|
|
45476
45918
|
});
|
|
45477
45919
|
return;
|
|
45478
45920
|
}
|
|
45479
|
-
const paths = checkOptionalParameter(
|
|
45921
|
+
const paths = checkOptionalParameter(path7) || [path7];
|
|
45480
45922
|
for (let i = 0, len = paths.length; i < len; i++) {
|
|
45481
45923
|
const path23 = paths[i];
|
|
45482
45924
|
Object.keys(routes).forEach((m2) => {
|
|
@@ -45503,13 +45945,13 @@ var RegExpRouter = class {
|
|
|
45503
45945
|
const routes = [];
|
|
45504
45946
|
let hasOwnRoute = method === METHOD_NAME_ALL;
|
|
45505
45947
|
[this.#middleware, this.#routes].forEach((r) => {
|
|
45506
|
-
const ownRoute = r[method] ? Object.keys(r[method]).map((
|
|
45948
|
+
const ownRoute = r[method] ? Object.keys(r[method]).map((path7) => [path7, r[method][path7]]) : [];
|
|
45507
45949
|
if (ownRoute.length !== 0) {
|
|
45508
45950
|
hasOwnRoute ||= true;
|
|
45509
45951
|
routes.push(...ownRoute);
|
|
45510
45952
|
} else if (method !== METHOD_NAME_ALL) {
|
|
45511
45953
|
routes.push(
|
|
45512
|
-
...Object.keys(r[METHOD_NAME_ALL]).map((
|
|
45954
|
+
...Object.keys(r[METHOD_NAME_ALL]).map((path7) => [path7, r[METHOD_NAME_ALL][path7]])
|
|
45513
45955
|
);
|
|
45514
45956
|
}
|
|
45515
45957
|
});
|
|
@@ -45536,13 +45978,13 @@ var SmartRouter = class {
|
|
|
45536
45978
|
constructor(init) {
|
|
45537
45979
|
this.#routers = init.routers;
|
|
45538
45980
|
}
|
|
45539
|
-
add(method,
|
|
45981
|
+
add(method, path7, handler) {
|
|
45540
45982
|
if (!this.#routes) {
|
|
45541
45983
|
throw new Error(MESSAGE_MATCHER_IS_ALREADY_BUILT);
|
|
45542
45984
|
}
|
|
45543
|
-
this.#routes.push([method,
|
|
45985
|
+
this.#routes.push([method, path7, handler]);
|
|
45544
45986
|
}
|
|
45545
|
-
match(method,
|
|
45987
|
+
match(method, path7) {
|
|
45546
45988
|
if (!this.#routes) {
|
|
45547
45989
|
throw new Error("Fatal error");
|
|
45548
45990
|
}
|
|
@@ -45557,7 +45999,7 @@ var SmartRouter = class {
|
|
|
45557
45999
|
for (let i2 = 0, len2 = routes.length; i2 < len2; i2++) {
|
|
45558
46000
|
router.add(...routes[i2]);
|
|
45559
46001
|
}
|
|
45560
|
-
res = router.match(method,
|
|
46002
|
+
res = router.match(method, path7);
|
|
45561
46003
|
} catch (e) {
|
|
45562
46004
|
if (e instanceof UnsupportedPathError) {
|
|
45563
46005
|
continue;
|
|
@@ -45614,10 +46056,10 @@ var Node2 = class _Node2 {
|
|
|
45614
46056
|
}
|
|
45615
46057
|
this.#patterns = [];
|
|
45616
46058
|
}
|
|
45617
|
-
insert(method,
|
|
46059
|
+
insert(method, path7, handler) {
|
|
45618
46060
|
this.#order = ++this.#order;
|
|
45619
46061
|
let curNode = this;
|
|
45620
|
-
const parts = splitRoutingPath(
|
|
46062
|
+
const parts = splitRoutingPath(path7);
|
|
45621
46063
|
const possibleKeys = [];
|
|
45622
46064
|
for (let i = 0, len = parts.length; i < len; i++) {
|
|
45623
46065
|
const p2 = parts[i];
|
|
@@ -45666,12 +46108,12 @@ var Node2 = class _Node2 {
|
|
|
45666
46108
|
}
|
|
45667
46109
|
}
|
|
45668
46110
|
}
|
|
45669
|
-
search(method,
|
|
46111
|
+
search(method, path7) {
|
|
45670
46112
|
const handlerSets = [];
|
|
45671
46113
|
this.#params = emptyParams;
|
|
45672
46114
|
const curNode = this;
|
|
45673
46115
|
let curNodes = [curNode];
|
|
45674
|
-
const parts = splitPath(
|
|
46116
|
+
const parts = splitPath(path7);
|
|
45675
46117
|
const curNodesQueue = [];
|
|
45676
46118
|
const len = parts.length;
|
|
45677
46119
|
let partOffsets = null;
|
|
@@ -45713,13 +46155,13 @@ var Node2 = class _Node2 {
|
|
|
45713
46155
|
if (matcher instanceof RegExp) {
|
|
45714
46156
|
if (partOffsets === null) {
|
|
45715
46157
|
partOffsets = new Array(len);
|
|
45716
|
-
let offset =
|
|
46158
|
+
let offset = path7[0] === "/" ? 1 : 0;
|
|
45717
46159
|
for (let p2 = 0; p2 < len; p2++) {
|
|
45718
46160
|
partOffsets[p2] = offset;
|
|
45719
46161
|
offset += parts[p2].length + 1;
|
|
45720
46162
|
}
|
|
45721
46163
|
}
|
|
45722
|
-
const restPathString =
|
|
46164
|
+
const restPathString = path7.substring(partOffsets[i]);
|
|
45723
46165
|
const m2 = matcher.exec(restPathString);
|
|
45724
46166
|
if (m2) {
|
|
45725
46167
|
params[name] = m2[0];
|
|
@@ -45772,18 +46214,18 @@ var TrieRouter = class {
|
|
|
45772
46214
|
constructor() {
|
|
45773
46215
|
this.#node = new Node2();
|
|
45774
46216
|
}
|
|
45775
|
-
add(method,
|
|
45776
|
-
const results = checkOptionalParameter(
|
|
46217
|
+
add(method, path7, handler) {
|
|
46218
|
+
const results = checkOptionalParameter(path7);
|
|
45777
46219
|
if (results) {
|
|
45778
46220
|
for (let i = 0, len = results.length; i < len; i++) {
|
|
45779
46221
|
this.#node.insert(method, results[i], handler);
|
|
45780
46222
|
}
|
|
45781
46223
|
return;
|
|
45782
46224
|
}
|
|
45783
|
-
this.#node.insert(method,
|
|
46225
|
+
this.#node.insert(method, path7, handler);
|
|
45784
46226
|
}
|
|
45785
|
-
match(method,
|
|
45786
|
-
return this.#node.search(method,
|
|
46227
|
+
match(method, path7) {
|
|
46228
|
+
return this.#node.search(method, path7);
|
|
45787
46229
|
}
|
|
45788
46230
|
};
|
|
45789
46231
|
|
|
@@ -46713,8 +47155,8 @@ function setAuthCookie(c, name, token, options) {
|
|
|
46713
47155
|
sameSite: "Strict"
|
|
46714
47156
|
});
|
|
46715
47157
|
}
|
|
46716
|
-
function clearAuthCookie(c, name,
|
|
46717
|
-
deleteCookie(c, name,
|
|
47158
|
+
function clearAuthCookie(c, name, path7) {
|
|
47159
|
+
deleteCookie(c, name, path7 !== void 0 ? { path: path7 } : void 0);
|
|
46718
47160
|
}
|
|
46719
47161
|
function createAuthMiddleware(db) {
|
|
46720
47162
|
return async (c, next) => {
|
|
@@ -47220,11 +47662,11 @@ function isPublished(item) {
|
|
|
47220
47662
|
return item["published"] === true;
|
|
47221
47663
|
}
|
|
47222
47664
|
function registerPublicContentRoutes(app, registry2, repos, projectors, paths, listRateLimit, resolver) {
|
|
47223
|
-
function registerListRoute(
|
|
47665
|
+
function registerListRoute(path7, handler) {
|
|
47224
47666
|
if (listRateLimit) {
|
|
47225
|
-
app.get(
|
|
47667
|
+
app.get(path7, listRateLimit, handler);
|
|
47226
47668
|
} else {
|
|
47227
|
-
app.get(
|
|
47669
|
+
app.get(path7, handler);
|
|
47228
47670
|
}
|
|
47229
47671
|
}
|
|
47230
47672
|
registerListRoute(paths.collection("content"), (c) => {
|
|
@@ -49189,7 +49631,7 @@ function registerUserRoutes(app, db, requirePermission, requireHierarchy) {
|
|
|
49189
49631
|
}
|
|
49190
49632
|
var API_VERSION = (() => {
|
|
49191
49633
|
try {
|
|
49192
|
-
return "0.4.
|
|
49634
|
+
return "0.4.3";
|
|
49193
49635
|
} catch {
|
|
49194
49636
|
return "0.0.0";
|
|
49195
49637
|
}
|
|
@@ -49232,6 +49674,9 @@ function registerConfigRoute(app, config3, registry2, db) {
|
|
|
49232
49674
|
});
|
|
49233
49675
|
});
|
|
49234
49676
|
}
|
|
49677
|
+
function liveFields(fields) {
|
|
49678
|
+
return fields.filter((f) => f.removed !== true);
|
|
49679
|
+
}
|
|
49235
49680
|
function registerSchemaRoute(app, registry2, db) {
|
|
49236
49681
|
app.get("/admin/api/schema", (c) => {
|
|
49237
49682
|
const content_types = Object.values(registry2.content_types).map((ct2) => ({
|
|
@@ -49240,19 +49685,19 @@ function registerSchemaRoute(app, registry2, db) {
|
|
|
49240
49685
|
only_one: ct2.only_one,
|
|
49241
49686
|
ui: ct2.ui,
|
|
49242
49687
|
system_fields: ct2.system_fields,
|
|
49243
|
-
fields: ct2.fields
|
|
49688
|
+
fields: liveFields(ct2.fields)
|
|
49244
49689
|
}));
|
|
49245
49690
|
const taxonomy_types = Object.values(registry2.taxonomy_types).map((tt2) => ({
|
|
49246
49691
|
name: tt2.name,
|
|
49247
49692
|
label: tt2.label,
|
|
49248
49693
|
system_fields: tt2.system_fields,
|
|
49249
|
-
fields: tt2.fields
|
|
49694
|
+
fields: liveFields(tt2.fields)
|
|
49250
49695
|
}));
|
|
49251
49696
|
const paragraph_types = Object.values(registry2.paragraph_types).map((pt) => ({
|
|
49252
49697
|
name: pt.name,
|
|
49253
49698
|
label: pt.label,
|
|
49254
49699
|
system_fields: pt.system_fields,
|
|
49255
|
-
fields: pt.fields
|
|
49700
|
+
fields: liveFields(pt.fields)
|
|
49256
49701
|
}));
|
|
49257
49702
|
const enum_types = Object.values(registry2.enum_types).map((et2) => ({
|
|
49258
49703
|
name: et2.name,
|
|
@@ -49738,7 +50183,7 @@ function createCmsApp(options) {
|
|
|
49738
50183
|
const gqlOptions = options.graphql;
|
|
49739
50184
|
let gqlHandler = null;
|
|
49740
50185
|
let initError = null;
|
|
49741
|
-
const ready = import("./handler-
|
|
50186
|
+
const ready = import("./handler-45O5OX2C-OIEJ52PN.js").then(({ createGraphQLHandler }) => {
|
|
49742
50187
|
gqlHandler = createGraphQLHandler(registry2, graphqlRepos, fieldKeyMaps, programmaticResolver, db, gqlOptions);
|
|
49743
50188
|
}).catch((err) => {
|
|
49744
50189
|
initError = err;
|
|
@@ -49787,7 +50232,7 @@ function createCmsApp(options) {
|
|
|
49787
50232
|
// src/codegen/drizzle-config.ts
|
|
49788
50233
|
init_esm_shims();
|
|
49789
50234
|
import { writeFile as writeFile6 } from "fs/promises";
|
|
49790
|
-
import { join as
|
|
50235
|
+
import { join as join9, relative as relative2, resolve as resolve4 } from "path";
|
|
49791
50236
|
async function generateDrizzleConfig(config3, targetDir) {
|
|
49792
50237
|
const migrationsFolder = config3.migrations?.folder ?? "./migrations";
|
|
49793
50238
|
const migrationsTable = config3.migrations?.table ?? "__manguito_migrations";
|
|
@@ -49809,13 +50254,13 @@ async function generateDrizzleConfig(config3, targetDir) {
|
|
|
49809
50254
|
` tablesFilter: ['!${migrationsTable}'],`,
|
|
49810
50255
|
`})`
|
|
49811
50256
|
].join("\n");
|
|
49812
|
-
await writeFile6(
|
|
50257
|
+
await writeFile6(join9(targetDir, "drizzle.config.ts"), content, "utf8");
|
|
49813
50258
|
}
|
|
49814
50259
|
|
|
49815
50260
|
// src/codegen/nav.ts
|
|
49816
50261
|
init_esm_shims();
|
|
49817
50262
|
import { writeFile as writeFile7 } from "fs/promises";
|
|
49818
|
-
import { join as
|
|
50263
|
+
import { join as join10 } from "path";
|
|
49819
50264
|
function schemaBasePath(name) {
|
|
49820
50265
|
const segment = name.includes("--") ? name.slice(name.indexOf("--") + 2) : name;
|
|
49821
50266
|
return segment.replace(/_/g, "-");
|
|
@@ -49833,17 +50278,17 @@ async function generateNav(registry2, targetDir) {
|
|
|
49833
50278
|
})).sort((a2, b2) => a2.label.localeCompare(b2.label));
|
|
49834
50279
|
const content = `export const nav = ${JSON.stringify({ contentTypes, taxonomyTypes }, null, 2)}
|
|
49835
50280
|
`;
|
|
49836
|
-
await writeFile7(
|
|
50281
|
+
await writeFile7(join10(targetDir, "nav.ts"), content, "utf8");
|
|
49837
50282
|
}
|
|
49838
50283
|
|
|
49839
50284
|
// src/commands/dev-routing.ts
|
|
49840
50285
|
init_esm_shims();
|
|
49841
50286
|
var ABSOLUTE_BACKEND_PATHS = ["/graphql"];
|
|
49842
50287
|
function shouldBridgeToHono(url2, apiPrefix) {
|
|
49843
|
-
const
|
|
49844
|
-
if (
|
|
49845
|
-
if (
|
|
49846
|
-
return ABSOLUTE_BACKEND_PATHS.includes(
|
|
50288
|
+
const path7 = url2.split("?")[0] ?? "";
|
|
50289
|
+
if (path7.startsWith(apiPrefix)) return true;
|
|
50290
|
+
if (path7.startsWith("/admin/api")) return true;
|
|
50291
|
+
return ABSOLUTE_BACKEND_PATHS.includes(path7);
|
|
49847
50292
|
}
|
|
49848
50293
|
|
|
49849
50294
|
// src/utils/db.ts
|
|
@@ -49878,7 +50323,7 @@ function createPromptAdapter() {
|
|
|
49878
50323
|
init_esm_shims();
|
|
49879
50324
|
import { existsSync as existsSync4 } from "fs";
|
|
49880
50325
|
import { readdir } from "fs/promises";
|
|
49881
|
-
import { resolve as resolve5, join as
|
|
50326
|
+
import { resolve as resolve5, join as join11, extname as extname3 } from "path";
|
|
49882
50327
|
import { pathToFileURL as pathToFileURL2 } from "url";
|
|
49883
50328
|
var RESOLVER_EXTENSIONS = /* @__PURE__ */ new Set([".ts", ".mjs", ".js"]);
|
|
49884
50329
|
function isProgrammaticFieldDefinition(v2) {
|
|
@@ -49887,10 +50332,10 @@ function isProgrammaticFieldDefinition(v2) {
|
|
|
49887
50332
|
async function walkTsFiles(dir) {
|
|
49888
50333
|
const out = [];
|
|
49889
50334
|
for (const entry of await readdir(dir, { withFileTypes: true })) {
|
|
49890
|
-
const full =
|
|
50335
|
+
const full = join11(dir, entry.name);
|
|
49891
50336
|
if (entry.isDirectory()) {
|
|
49892
50337
|
out.push(...await walkTsFiles(full));
|
|
49893
|
-
} else if (RESOLVER_EXTENSIONS.has(
|
|
50338
|
+
} else if (RESOLVER_EXTENSIONS.has(extname3(entry.name))) {
|
|
49894
50339
|
out.push(full);
|
|
49895
50340
|
}
|
|
49896
50341
|
}
|
|
@@ -49950,7 +50395,7 @@ async function runDev(options, deps) {
|
|
|
49950
50395
|
const needsSeed = !await db.tableExists("users");
|
|
49951
50396
|
const bootstrapRegistry = await parseAllSchemas(cwd, config3);
|
|
49952
50397
|
await generateDrizzleConfig(config3, manguitoDir);
|
|
49953
|
-
await writeFile8(
|
|
50398
|
+
await writeFile8(join12(manguitoDir, "schema.ts"), generateSchemaFile(bootstrapRegistry), "utf8");
|
|
49954
50399
|
await runDevMigration(drizzleConfigPath);
|
|
49955
50400
|
printSuccess(needsSeed ? "Schema tables created" : "Schema tables up to date");
|
|
49956
50401
|
if (needsSeed) {
|
|
@@ -49996,7 +50441,7 @@ async function runDev(options, deps) {
|
|
|
49996
50441
|
);
|
|
49997
50442
|
await generateSchemaRegistry(registry2, manguitoDir);
|
|
49998
50443
|
await generateRoutes2(registry2, manguitoDir);
|
|
49999
|
-
await generateForms(registry2,
|
|
50444
|
+
await generateForms(registry2, join12(manguitoDir, "forms"));
|
|
50000
50445
|
await generateNav(registry2, manguitoDir);
|
|
50001
50446
|
const resolverMap = await loadProgrammaticResolvers(cwd, config3.programmatic.dir);
|
|
50002
50447
|
const adapter = createCmsApp({
|
|
@@ -50046,7 +50491,7 @@ async function runDev(options, deps) {
|
|
|
50046
50491
|
}
|
|
50047
50492
|
try {
|
|
50048
50493
|
const data = await readFile(filePath);
|
|
50049
|
-
const ext =
|
|
50494
|
+
const ext = extname4(filePath).slice(1).toLowerCase();
|
|
50050
50495
|
const mime = UPLOAD_MIME_MAP[ext] ?? "application/octet-stream";
|
|
50051
50496
|
res.setHeader("Content-Type", mime);
|
|
50052
50497
|
res.setHeader("X-Content-Type-Options", "nosniff");
|
|
@@ -50130,10 +50575,10 @@ async function onSchemaFileChange(args) {
|
|
|
50130
50575
|
return;
|
|
50131
50576
|
}
|
|
50132
50577
|
await generateDrizzleConfig(config3, manguitoDir);
|
|
50133
|
-
await writeFile8(
|
|
50578
|
+
await writeFile8(join12(manguitoDir, "schema.ts"), generateSchemaFile(registry2), "utf8");
|
|
50134
50579
|
await generateSchemaRegistry(registry2, manguitoDir);
|
|
50135
50580
|
await generateRoutes2(registry2, manguitoDir);
|
|
50136
|
-
await generateForms(registry2,
|
|
50581
|
+
await generateForms(registry2, join12(manguitoDir, "forms"));
|
|
50137
50582
|
await generateNav(registry2, manguitoDir);
|
|
50138
50583
|
try {
|
|
50139
50584
|
await runDevMigration(drizzleConfigPath);
|
|
@@ -50198,7 +50643,7 @@ async function parseAllSchemas(cwd, config3) {
|
|
|
50198
50643
|
return buildSchemaRegistry(parsedSchemas, routesResult.value, rolesResult.value);
|
|
50199
50644
|
}
|
|
50200
50645
|
function resolveAdminRoot2(cwd) {
|
|
50201
|
-
const cwdRequire = createRequire2(
|
|
50646
|
+
const cwdRequire = createRequire2(join12(cwd, "package.json"));
|
|
50202
50647
|
const adminPkgJson = cwdRequire.resolve("@bobbykim/manguito-cms-admin/package.json");
|
|
50203
50648
|
return dirname2(adminPkgJson);
|
|
50204
50649
|
}
|
|
@@ -50336,7 +50781,7 @@ async function runStart(options, deps) {
|
|
|
50336
50781
|
|
|
50337
50782
|
// src/commands/migrate.ts
|
|
50338
50783
|
init_esm_shims();
|
|
50339
|
-
import { resolve as resolve8, join as
|
|
50784
|
+
import { resolve as resolve8, join as join13 } from "path";
|
|
50340
50785
|
import { readFile as readFile2 } from "fs/promises";
|
|
50341
50786
|
function registerMigrate(program2) {
|
|
50342
50787
|
program2.command("migrate").description("Apply pending database migrations").option("--env <path>", "path to .env file to load").option("--status", "show migration state without applying").option("--dry-run", "preview migrations without writing").option("--force", "skip destructive-change confirmation prompt").action(async (options) => {
|
|
@@ -50425,7 +50870,7 @@ async function runMigrate(options, deps) {
|
|
|
50425
50870
|
const generatedDir = resolve8(cwd, "dist/generated");
|
|
50426
50871
|
await generateDrizzleConfig(config3, generatedDir);
|
|
50427
50872
|
const newFileNames = await generateMigration(deps.configPath, migrationsFolder);
|
|
50428
|
-
const newFilePaths = newFileNames.map((f) =>
|
|
50873
|
+
const newFilePaths = newFileNames.map((f) => join13(migrationsFolder, f));
|
|
50429
50874
|
printSuccess(
|
|
50430
50875
|
newFileNames.length === 0 ? "No new migration files generated" : `Generated ${newFileNames.length} migration file${newFileNames.length !== 1 ? "s" : ""}: ${newFileNames.join(", ")}`
|
|
50431
50876
|
);
|
|
@@ -50853,6 +51298,333 @@ async function runUsersDemote(options, deps) {
|
|
|
50853
51298
|
printSuccess(`${email3} demoted to ${targetRole.name}.`);
|
|
50854
51299
|
}
|
|
50855
51300
|
|
|
51301
|
+
// src/commands/version.ts
|
|
51302
|
+
init_esm_shims();
|
|
51303
|
+
import fs6 from "fs";
|
|
51304
|
+
import path6 from "path";
|
|
51305
|
+
|
|
51306
|
+
// src/utils/registry.ts
|
|
51307
|
+
init_esm_shims();
|
|
51308
|
+
import { resolve as resolve11 } from "path";
|
|
51309
|
+
|
|
51310
|
+
// src/utils/schema-config.ts
|
|
51311
|
+
init_esm_shims();
|
|
51312
|
+
import { resolve as resolve10 } from "path";
|
|
51313
|
+
function resolveSchemaConfig(cwd, config3) {
|
|
51314
|
+
return {
|
|
51315
|
+
base_path: resolve10(cwd, config3.schema.base_path),
|
|
51316
|
+
folders: config3.schema.folders
|
|
51317
|
+
};
|
|
51318
|
+
}
|
|
51319
|
+
|
|
51320
|
+
// src/utils/registry.ts
|
|
51321
|
+
function loadWorkingRegistry(cwd, config3, command) {
|
|
51322
|
+
const schema = resolveSchemaConfig(cwd, config3);
|
|
51323
|
+
const allErrors = [];
|
|
51324
|
+
const parsedSchemas = [];
|
|
51325
|
+
const walkResult = walkSchemaDirectory(schema);
|
|
51326
|
+
if (!walkResult.ok) {
|
|
51327
|
+
allErrors.push(...walkResult.errors);
|
|
51328
|
+
} else {
|
|
51329
|
+
for (const file2 of walkResult.value) {
|
|
51330
|
+
const parseResult = parseSchema(file2.raw, file2.schema_type, file2.path);
|
|
51331
|
+
if (!parseResult.ok) {
|
|
51332
|
+
allErrors.push(...parseResult.errors);
|
|
51333
|
+
} else {
|
|
51334
|
+
parsedSchemas.push(parseResult.schema);
|
|
51335
|
+
}
|
|
51336
|
+
}
|
|
51337
|
+
}
|
|
51338
|
+
const rolesPath = resolve11(schema.base_path, "roles.json");
|
|
51339
|
+
let parsedRoles = null;
|
|
51340
|
+
const rolesLoad = loadSchemaFile(rolesPath);
|
|
51341
|
+
if (!rolesLoad.ok) {
|
|
51342
|
+
allErrors.push(...rolesLoad.errors);
|
|
51343
|
+
} else {
|
|
51344
|
+
const rolesParse = parseRoles(rolesLoad.value, rolesPath);
|
|
51345
|
+
if (!rolesParse.ok) allErrors.push(...rolesParse.errors);
|
|
51346
|
+
else parsedRoles = rolesParse.value;
|
|
51347
|
+
}
|
|
51348
|
+
const routesPath = resolve11(schema.base_path, "routes.json");
|
|
51349
|
+
let parsedRoutes = null;
|
|
51350
|
+
const routesLoad = loadSchemaFile(routesPath);
|
|
51351
|
+
if (!routesLoad.ok) {
|
|
51352
|
+
allErrors.push(...routesLoad.errors);
|
|
51353
|
+
} else {
|
|
51354
|
+
const routesParse = parseRoutes(routesLoad.value, routesPath);
|
|
51355
|
+
if (!routesParse.ok) allErrors.push(...routesParse.errors);
|
|
51356
|
+
else parsedRoutes = routesParse.value;
|
|
51357
|
+
}
|
|
51358
|
+
if (allErrors.length > 0 || parsedRoles === null || parsedRoutes === null) {
|
|
51359
|
+
printValidationErrors(allErrors, "Schema parse errors", command);
|
|
51360
|
+
process.exit(1);
|
|
51361
|
+
}
|
|
51362
|
+
return buildSchemaRegistry(parsedSchemas, parsedRoutes, parsedRoles);
|
|
51363
|
+
}
|
|
51364
|
+
|
|
51365
|
+
// src/commands/version-report.ts
|
|
51366
|
+
init_esm_shims();
|
|
51367
|
+
function formatField(change) {
|
|
51368
|
+
switch (change.kind) {
|
|
51369
|
+
case "added":
|
|
51370
|
+
return ` + ${change.name} ${change.field_type} new`;
|
|
51371
|
+
case "renamed":
|
|
51372
|
+
return ` ~ ${change.to_name} was "${change.from_name}" \u2192 column ${change.column}`;
|
|
51373
|
+
case "tombstoned": {
|
|
51374
|
+
const fallback = change.fallback === void 0 ? "" : `, fallback ${JSON.stringify(change.fallback)}`;
|
|
51375
|
+
return ` \u2298 ${change.name} tombstoned \u2192 column ${change.column} retained${fallback}`;
|
|
51376
|
+
}
|
|
51377
|
+
case "restored":
|
|
51378
|
+
return ` \u21BA ${change.name} restored \u2192 column ${change.column} exposed again`;
|
|
51379
|
+
}
|
|
51380
|
+
}
|
|
51381
|
+
function formatSchemaChange(change) {
|
|
51382
|
+
const header = change.from === null ? `Working schema \u2014 nothing has been cut yet, so ${change.to} would be the first version` : `Working schema vs ${change.from} (highest snapshot) \u2014 would become ${change.to}`;
|
|
51383
|
+
if (change.identical) {
|
|
51384
|
+
return `${header}
|
|
51385
|
+
|
|
51386
|
+
No column added, renamed, tombstoned or restored.`;
|
|
51387
|
+
}
|
|
51388
|
+
const blocks = change.types.map((type) => {
|
|
51389
|
+
const label = type.status === "added" ? `${type.type} (new type)` : type.type;
|
|
51390
|
+
if (type.fields.length === 0) return `${label}
|
|
51391
|
+
(no changes)`;
|
|
51392
|
+
return [label, ...type.fields.map(formatField)].join("\n");
|
|
51393
|
+
});
|
|
51394
|
+
return [header, "", ...blocks].join("\n");
|
|
51395
|
+
}
|
|
51396
|
+
|
|
51397
|
+
// src/commands/version-fs.ts
|
|
51398
|
+
init_esm_shims();
|
|
51399
|
+
import fs5 from "fs";
|
|
51400
|
+
import path5 from "path";
|
|
51401
|
+
var SUPPORTED = /* @__PURE__ */ new Set([".json", ".yaml", ".yml"]);
|
|
51402
|
+
function copySnapshotFolders(input2) {
|
|
51403
|
+
const { fromRoot, toDir, folders } = input2;
|
|
51404
|
+
for (const folder of Object.values(folders)) {
|
|
51405
|
+
const src = path5.join(fromRoot, folder);
|
|
51406
|
+
if (!fs5.existsSync(src) || !fs5.statSync(src).isDirectory()) continue;
|
|
51407
|
+
const dest = path5.join(toDir, folder);
|
|
51408
|
+
fs5.mkdirSync(dest, { recursive: true });
|
|
51409
|
+
for (const entry of fs5.readdirSync(src)) {
|
|
51410
|
+
if (!SUPPORTED.has(path5.extname(entry).toLowerCase())) continue;
|
|
51411
|
+
fs5.copyFileSync(path5.join(src, entry), path5.join(dest, entry));
|
|
51412
|
+
}
|
|
51413
|
+
}
|
|
51414
|
+
}
|
|
51415
|
+
function retireSnapshotDir(versionsDir, version3) {
|
|
51416
|
+
const from = path5.join(versionsDir, version3);
|
|
51417
|
+
const staging = path5.join(versionsDir, `.${version3}.removing`);
|
|
51418
|
+
fs5.rmSync(staging, { recursive: true, force: true });
|
|
51419
|
+
fs5.renameSync(from, staging);
|
|
51420
|
+
fs5.rmSync(staging, { recursive: true, force: true });
|
|
51421
|
+
}
|
|
51422
|
+
function writeSnapshotAtomically(input2) {
|
|
51423
|
+
const { fromRoot, versionsDir, version: version3, folders } = input2;
|
|
51424
|
+
const target = path5.join(versionsDir, version3);
|
|
51425
|
+
const staging = path5.join(versionsDir, `.${version3}.tmp`);
|
|
51426
|
+
fs5.rmSync(staging, { recursive: true, force: true });
|
|
51427
|
+
try {
|
|
51428
|
+
copySnapshotFolders({ fromRoot, toDir: staging, folders });
|
|
51429
|
+
fs5.renameSync(staging, target);
|
|
51430
|
+
} catch (err) {
|
|
51431
|
+
fs5.rmSync(staging, { recursive: true, force: true });
|
|
51432
|
+
throw err;
|
|
51433
|
+
}
|
|
51434
|
+
}
|
|
51435
|
+
|
|
51436
|
+
// src/commands/version.ts
|
|
51437
|
+
function highestSnapshot(snapshots) {
|
|
51438
|
+
let best = null;
|
|
51439
|
+
let bestN = -1;
|
|
51440
|
+
for (const s of snapshots) {
|
|
51441
|
+
const n = Number.parseInt(s.version.replace(/^v/, ""), 10);
|
|
51442
|
+
if (Number.isNaN(n) || n <= bestN) continue;
|
|
51443
|
+
best = s;
|
|
51444
|
+
bestN = n;
|
|
51445
|
+
}
|
|
51446
|
+
return best;
|
|
51447
|
+
}
|
|
51448
|
+
async function loadVersionContext(options, deps, command) {
|
|
51449
|
+
loadEnvFile(options.env);
|
|
51450
|
+
const config3 = await resolveConfig(deps.cwd);
|
|
51451
|
+
const schema = resolveSchemaConfig(deps.cwd, config3);
|
|
51452
|
+
const registry2 = loadWorkingRegistry(deps.cwd, config3, command);
|
|
51453
|
+
const snapshots = loadVersionSnapshots(schema, registry2);
|
|
51454
|
+
if (!snapshots.ok) {
|
|
51455
|
+
printValidationErrors(snapshots.errors, "Snapshot errors", command);
|
|
51456
|
+
process.exit(1);
|
|
51457
|
+
}
|
|
51458
|
+
const model = computeVersionModel({ current: registry2, snapshots: snapshots.value });
|
|
51459
|
+
if (!model.ok) {
|
|
51460
|
+
printValidationErrors(model.errors, "Version model errors", command);
|
|
51461
|
+
process.exit(1);
|
|
51462
|
+
}
|
|
51463
|
+
return { schema, registry: registry2, snapshots: snapshots.value, model: model.value };
|
|
51464
|
+
}
|
|
51465
|
+
function orphanedTombstoneErrors(input2) {
|
|
51466
|
+
const remaining = input2.snapshots.filter((s) => s.version !== input2.retiring);
|
|
51467
|
+
const model = computeVersionModel({ current: input2.registry, snapshots: remaining });
|
|
51468
|
+
if (model.ok) return [];
|
|
51469
|
+
return model.errors.filter((e) => e.code === "ORPHANED_TOMBSTONE");
|
|
51470
|
+
}
|
|
51471
|
+
function registerVersion(program2) {
|
|
51472
|
+
program2.command("version:diff").description("Show what cutting a new version would freeze").option("--env <path>", "path to .env file to load").action(async (options) => {
|
|
51473
|
+
await runVersionDiff(options, { cwd: process.cwd() });
|
|
51474
|
+
});
|
|
51475
|
+
program2.command("version:cut").description("Freeze the working schema as a new version").option("--env <path>", "path to .env file to load").option("--yes", "skip the confirmation prompt").action(async (options) => {
|
|
51476
|
+
await runVersionCut(options, { cwd: process.cwd(), prompt: createPromptAdapter() });
|
|
51477
|
+
});
|
|
51478
|
+
program2.command("version:retire <version>").description("Stop serving a cut version and delete its snapshot").option("--env <path>", "path to .env file to load").option("--yes", "skip the confirmation prompt").action(async (version3, options) => {
|
|
51479
|
+
await runVersionRetire(version3, options, { cwd: process.cwd(), prompt: createPromptAdapter() });
|
|
51480
|
+
});
|
|
51481
|
+
}
|
|
51482
|
+
async function runVersionDiff(options, deps) {
|
|
51483
|
+
const ctx = await loadVersionContext(options, deps, "manguito version:diff");
|
|
51484
|
+
const from = highestSnapshot(ctx.snapshots);
|
|
51485
|
+
const change = describeSchemaChange({
|
|
51486
|
+
from,
|
|
51487
|
+
to: { version: ctx.model.current, registry: ctx.registry }
|
|
51488
|
+
});
|
|
51489
|
+
process.stdout.write(`${formatSchemaChange(change)}
|
|
51490
|
+
`);
|
|
51491
|
+
if (change.identical) {
|
|
51492
|
+
process.stdout.write(
|
|
51493
|
+
`
|
|
51494
|
+
Nothing to cut \u2014 no column was added, renamed, tombstoned or restored, so ${ctx.model.current} would expose the same contract.
|
|
51495
|
+
`
|
|
51496
|
+
);
|
|
51497
|
+
return;
|
|
51498
|
+
}
|
|
51499
|
+
printSuccess(`Cutting now would create ${ctx.schema.base_path}/versions/${ctx.model.current}/`);
|
|
51500
|
+
}
|
|
51501
|
+
async function runVersionCut(options, deps) {
|
|
51502
|
+
const ctx = await loadVersionContext(options, deps, "manguito version:cut");
|
|
51503
|
+
const from = highestSnapshot(ctx.snapshots);
|
|
51504
|
+
const version3 = ctx.model.current;
|
|
51505
|
+
const change = describeSchemaChange({
|
|
51506
|
+
from,
|
|
51507
|
+
to: { version: version3, registry: ctx.registry }
|
|
51508
|
+
});
|
|
51509
|
+
if (change.identical) {
|
|
51510
|
+
printGuidedError(
|
|
51511
|
+
`No column was added, renamed, tombstoned or restored since ${from?.version ?? "the last cut"} \u2014 cutting ${version3} would freeze an identical contract.`,
|
|
51512
|
+
"Changes to paragraph, programmatic, many-to-many and enum definitions are not versioned and need no new version. A live version commits you to retaining every column it exposes, so cut only when a column actually changed \u2014 or run `manguito version:retire <version>` if you meant to shrink the live set."
|
|
51513
|
+
);
|
|
51514
|
+
process.exit(1);
|
|
51515
|
+
}
|
|
51516
|
+
const versionsDir = path6.join(ctx.schema.base_path, "versions");
|
|
51517
|
+
const target = path6.join(versionsDir, version3);
|
|
51518
|
+
if (fs6.existsSync(target)) {
|
|
51519
|
+
printGuidedError(
|
|
51520
|
+
`${target} already exists.`,
|
|
51521
|
+
"A snapshot directory is never overwritten. Remove or rename it, then run version:cut again."
|
|
51522
|
+
);
|
|
51523
|
+
process.exit(1);
|
|
51524
|
+
}
|
|
51525
|
+
process.stdout.write(`${formatSchemaChange(change)}
|
|
51526
|
+
|
|
51527
|
+
`);
|
|
51528
|
+
const live = [...ctx.model.live.filter((v2) => v2 !== version3), version3].join(" ");
|
|
51529
|
+
process.stdout.write(
|
|
51530
|
+
`After cutting, ${live} are live. Every column those versions expose must stay in the
|
|
51531
|
+
schema \u2014 as a live field or a tombstone \u2014 until you retire them.
|
|
51532
|
+
|
|
51533
|
+
`
|
|
51534
|
+
);
|
|
51535
|
+
if (options.yes !== true) {
|
|
51536
|
+
const ok = await deps.prompt.confirm(`Freeze the working schema as ${version3}?`);
|
|
51537
|
+
if (!ok) {
|
|
51538
|
+
process.stdout.write("Cancelled. Nothing was written.\n");
|
|
51539
|
+
return;
|
|
51540
|
+
}
|
|
51541
|
+
}
|
|
51542
|
+
try {
|
|
51543
|
+
writeSnapshotAtomically({ fromRoot: ctx.schema.base_path, versionsDir, version: version3, folders: ctx.schema.folders });
|
|
51544
|
+
} catch (err) {
|
|
51545
|
+
printGuidedError(
|
|
51546
|
+
`Failed to write ${target}: ${err instanceof Error ? err.message : String(err)}`,
|
|
51547
|
+
"Nothing was left behind \u2014 the snapshot is written to a temporary directory and renamed into place only once it is complete."
|
|
51548
|
+
);
|
|
51549
|
+
process.exit(1);
|
|
51550
|
+
}
|
|
51551
|
+
printSuccess(`Froze the working schema as ${version3} at ${target}`);
|
|
51552
|
+
process.stdout.write(`Live: ${live}. Working schema is now v${Number.parseInt(version3.slice(1), 10) + 1}.
|
|
51553
|
+
`);
|
|
51554
|
+
}
|
|
51555
|
+
async function runVersionRetire(version3, options, deps) {
|
|
51556
|
+
if (!/^v\d+$/.test(version3)) {
|
|
51557
|
+
printGuidedError(`"${version3}" is not a version name.`, "Expected v<number>, for example v1.");
|
|
51558
|
+
process.exit(1);
|
|
51559
|
+
}
|
|
51560
|
+
const ctx = await loadVersionContext(options, deps, "manguito version:retire");
|
|
51561
|
+
if (!ctx.snapshots.some((s) => s.version === version3)) {
|
|
51562
|
+
const existing = ctx.snapshots.map((s) => s.version).join(", ");
|
|
51563
|
+
printGuidedError(
|
|
51564
|
+
`${version3} is not a cut version.`,
|
|
51565
|
+
existing === "" ? "No versions have been cut yet \u2014 run `manguito version:cut` first." : `Cut versions: ${existing}.`
|
|
51566
|
+
);
|
|
51567
|
+
process.exit(1);
|
|
51568
|
+
}
|
|
51569
|
+
const highest = highestSnapshot(ctx.snapshots);
|
|
51570
|
+
if (highest !== null && highest.version === version3) {
|
|
51571
|
+
const target = path6.join(ctx.schema.base_path, "versions", version3);
|
|
51572
|
+
printGuidedError(
|
|
51573
|
+
`${version3} is the newest cut version and cannot be retired.`,
|
|
51574
|
+
`The working schema is ${ctx.model.current} because ${version3} is the highest snapshot \u2014 retiring it would renumber the working schema back onto ${version3}, and anyone pinned to ${version3} would get a different contract. Cutting a version with a real contract change makes ${version3} retirable. If ${version3} was cut in error, delete ${target} by hand \u2014 safe only while nothing yet consumes ${version3}, since deleting the newest snapshot renumbers the working schema back onto it.`
|
|
51575
|
+
);
|
|
51576
|
+
process.exit(1);
|
|
51577
|
+
}
|
|
51578
|
+
const orphans = orphanedTombstoneErrors({
|
|
51579
|
+
registry: ctx.registry,
|
|
51580
|
+
snapshots: ctx.snapshots,
|
|
51581
|
+
retiring: version3
|
|
51582
|
+
});
|
|
51583
|
+
process.stdout.write(`Retiring ${version3} will delete ${path6.join(ctx.schema.base_path, "versions", version3)}
|
|
51584
|
+
|
|
51585
|
+
`);
|
|
51586
|
+
if (orphans.length > 0) {
|
|
51587
|
+
process.stdout.write(
|
|
51588
|
+
`${orphans.length} tombstone${orphans.length === 1 ? "" : "s"} will be orphaned \u2014 their columns are no
|
|
51589
|
+
longer exposed by any live version. You must then delete these fields:
|
|
51590
|
+
|
|
51591
|
+
`
|
|
51592
|
+
);
|
|
51593
|
+
for (const o of orphans) {
|
|
51594
|
+
process.stdout.write(` ${o.file}
|
|
51595
|
+
${o.message}
|
|
51596
|
+
|
|
51597
|
+
`);
|
|
51598
|
+
}
|
|
51599
|
+
process.stdout.write(
|
|
51600
|
+
"Until you do, `manguito validate` will report ORPHANED_TOMBSTONE. Deleting them\nshrinks the union and lets the next migration DROP those columns.\n\n"
|
|
51601
|
+
);
|
|
51602
|
+
}
|
|
51603
|
+
if (options.yes !== true) {
|
|
51604
|
+
const ok = await deps.prompt.confirm(`Retire ${version3}?`);
|
|
51605
|
+
if (!ok) {
|
|
51606
|
+
process.stdout.write("Cancelled. Nothing was deleted.\n");
|
|
51607
|
+
return;
|
|
51608
|
+
}
|
|
51609
|
+
}
|
|
51610
|
+
const versionsDir = path6.join(ctx.schema.base_path, "versions");
|
|
51611
|
+
try {
|
|
51612
|
+
retireSnapshotDir(versionsDir, version3);
|
|
51613
|
+
} catch (err) {
|
|
51614
|
+
printGuidedError(
|
|
51615
|
+
`Failed to retire ${version3}: ${err instanceof Error ? err.message : String(err)}`,
|
|
51616
|
+
"The snapshot is renamed out of the way before it is deleted, so the version is either fully retired or untouched."
|
|
51617
|
+
);
|
|
51618
|
+
process.exit(1);
|
|
51619
|
+
}
|
|
51620
|
+
printSuccess(`Retired ${version3}`);
|
|
51621
|
+
if (orphans.length > 0) {
|
|
51622
|
+
process.stdout.write(`
|
|
51623
|
+
Delete the ${orphans.length} orphaned tombstone field(s) listed above.
|
|
51624
|
+
`);
|
|
51625
|
+
}
|
|
51626
|
+
}
|
|
51627
|
+
|
|
50856
51628
|
// src/index.ts
|
|
50857
51629
|
var require2 = createRequire3(import.meta.url);
|
|
50858
51630
|
var { version: version2 } = require2("../package.json");
|
|
@@ -50864,6 +51636,7 @@ registerMigrate(program);
|
|
|
50864
51636
|
registerValidate(program);
|
|
50865
51637
|
registerCreateSuperuser(program);
|
|
50866
51638
|
registerUsers(program);
|
|
51639
|
+
registerVersion(program);
|
|
50867
51640
|
program.parse();
|
|
50868
51641
|
/*! Bundled license information:
|
|
50869
51642
|
|