@bobbykim/manguito-cms-cli 0.4.6 → 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 +942 -276
- package/package.json +5 -5
package/dist/index.js
CHANGED
|
@@ -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
|
}
|
|
@@ -29093,6 +29093,8 @@ import * as path2 from "path";
|
|
|
29093
29093
|
import * as fs from "fs";
|
|
29094
29094
|
import * as path from "path";
|
|
29095
29095
|
var import_bcryptjs = __toESM(require_bcryptjs(), 1);
|
|
29096
|
+
import * as fs3 from "fs";
|
|
29097
|
+
import * as path3 from "path";
|
|
29096
29098
|
var snakeCaseName = external_exports.string().regex(/^[a-z][a-z0-9_]*$/, 'Must be snake_case (e.g. "blog_post")');
|
|
29097
29099
|
var maxSizeString = external_exports.string().regex(
|
|
29098
29100
|
/^\d+(\.\d+)?\s*(B|KB|MB|GB)$/i,
|
|
@@ -29839,8 +29841,8 @@ function getNameSegment(machineName) {
|
|
|
29839
29841
|
const idx = machineName.indexOf("--");
|
|
29840
29842
|
return idx === -1 ? machineName : machineName.slice(idx + 2);
|
|
29841
29843
|
}
|
|
29842
|
-
function zodPathToString(
|
|
29843
|
-
return
|
|
29844
|
+
function zodPathToString(path42) {
|
|
29845
|
+
return path42.reduce((acc, seg) => {
|
|
29844
29846
|
const s = typeof seg === "symbol" ? String(seg) : seg;
|
|
29845
29847
|
return typeof s === "number" ? `${acc}[${s}]` : acc ? `${acc}.${s}` : s;
|
|
29846
29848
|
}, "");
|
|
@@ -30261,6 +30263,342 @@ async function hashPassword(password2) {
|
|
|
30261
30263
|
async function verifyPassword(password2, stored) {
|
|
30262
30264
|
return import_bcryptjs.default.compare(password2, stored);
|
|
30263
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
|
+
}
|
|
30264
30602
|
|
|
30265
30603
|
// ../db/dist/index.mjs
|
|
30266
30604
|
init_esm_shims();
|
|
@@ -30467,7 +30805,7 @@ init_esm_shims();
|
|
|
30467
30805
|
function mapResultRow(columns, row, joinsNotNullableMap) {
|
|
30468
30806
|
const nullifyMap = {};
|
|
30469
30807
|
const result = columns.reduce(
|
|
30470
|
-
(result2, { path:
|
|
30808
|
+
(result2, { path: path7, field }, columnIndex) => {
|
|
30471
30809
|
let decoder;
|
|
30472
30810
|
if (is(field, Column)) {
|
|
30473
30811
|
decoder = field;
|
|
@@ -30479,8 +30817,8 @@ function mapResultRow(columns, row, joinsNotNullableMap) {
|
|
|
30479
30817
|
decoder = field.sql.decoder;
|
|
30480
30818
|
}
|
|
30481
30819
|
let node = result2;
|
|
30482
|
-
for (const [pathChunkIndex, pathChunk] of
|
|
30483
|
-
if (pathChunkIndex <
|
|
30820
|
+
for (const [pathChunkIndex, pathChunk] of path7.entries()) {
|
|
30821
|
+
if (pathChunkIndex < path7.length - 1) {
|
|
30484
30822
|
if (!(pathChunk in node)) {
|
|
30485
30823
|
node[pathChunk] = {};
|
|
30486
30824
|
}
|
|
@@ -30488,8 +30826,8 @@ function mapResultRow(columns, row, joinsNotNullableMap) {
|
|
|
30488
30826
|
} else {
|
|
30489
30827
|
const rawValue = row[columnIndex];
|
|
30490
30828
|
const value = node[pathChunk] = rawValue === null ? null : decoder.mapFromDriverValue(rawValue);
|
|
30491
|
-
if (joinsNotNullableMap && is(field, Column) &&
|
|
30492
|
-
const objectName =
|
|
30829
|
+
if (joinsNotNullableMap && is(field, Column) && path7.length === 2) {
|
|
30830
|
+
const objectName = path7[0];
|
|
30493
30831
|
if (!(objectName in nullifyMap)) {
|
|
30494
30832
|
nullifyMap[objectName] = value === null ? getTableName(field.table) : false;
|
|
30495
30833
|
} else if (typeof nullifyMap[objectName] === "string" && nullifyMap[objectName] !== getTableName(field.table)) {
|
|
@@ -33857,7 +34195,7 @@ var PgSelectQueryBuilderBase = class extends TypedQueryBuilder {
|
|
|
33857
34195
|
const baseTableName = this.tableName;
|
|
33858
34196
|
const tableName = getTableLikeName(table);
|
|
33859
34197
|
for (const item of extractUsedTable(table)) this.usedTables.add(item);
|
|
33860
|
-
if (typeof tableName === "string" && this.config.joins?.some((
|
|
34198
|
+
if (typeof tableName === "string" && this.config.joins?.some((join14) => join14.alias === tableName)) {
|
|
33861
34199
|
throw new Error(`Alias "${tableName}" is already used in this query`);
|
|
33862
34200
|
}
|
|
33863
34201
|
if (!this.isPartialSelect) {
|
|
@@ -35081,7 +35419,7 @@ var PgUpdateBase = class extends QueryPromise {
|
|
|
35081
35419
|
createJoin(joinType) {
|
|
35082
35420
|
return (table, on) => {
|
|
35083
35421
|
const tableName = getTableLikeName(table);
|
|
35084
|
-
if (typeof tableName === "string" && this.config.joins.some((
|
|
35422
|
+
if (typeof tableName === "string" && this.config.joins.some((join14) => join14.alias === tableName)) {
|
|
35085
35423
|
throw new Error(`Alias "${tableName}" is already used in this query`);
|
|
35086
35424
|
}
|
|
35087
35425
|
if (typeof on === "function") {
|
|
@@ -35177,10 +35515,10 @@ var PgUpdateBase = class extends QueryPromise {
|
|
|
35177
35515
|
const fromFields = this.getTableLikeFields(this.config.from);
|
|
35178
35516
|
fields[tableName] = fromFields;
|
|
35179
35517
|
}
|
|
35180
|
-
for (const
|
|
35181
|
-
const tableName2 = getTableLikeName(
|
|
35182
|
-
if (typeof tableName2 === "string" && !is(
|
|
35183
|
-
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);
|
|
35184
35522
|
fields[tableName2] = fromFields;
|
|
35185
35523
|
}
|
|
35186
35524
|
}
|
|
@@ -38944,7 +39282,7 @@ var ds = T((th, ps) => {
|
|
|
38944
39282
|
return /^(?:[a-zA-Z0-9+/]{4})*(?:[a-zA-Z0-9+/]{2}==|[a-zA-Z0-9+/]{3}=)?$/.test(r);
|
|
38945
39283
|
}
|
|
38946
39284
|
a(ls, "isBase64");
|
|
38947
|
-
function
|
|
39285
|
+
function fs7(r) {
|
|
38948
39286
|
if (typeof r != "string") throw new TypeError("SASL: attribute pairs text must be a string");
|
|
38949
39287
|
return new Map(r.split(",").map((e) => {
|
|
38950
39288
|
if (!/^.=/.test(e)) throw new Error("SASL: Invalid attribute pair entry");
|
|
@@ -38952,9 +39290,9 @@ var ds = T((th, ps) => {
|
|
|
38952
39290
|
return [t, n];
|
|
38953
39291
|
}));
|
|
38954
39292
|
}
|
|
38955
|
-
a(
|
|
39293
|
+
a(fs7, "parseAttributePairs");
|
|
38956
39294
|
function qu(r) {
|
|
38957
|
-
let e =
|
|
39295
|
+
let e = fs7(r), t = e.get("r");
|
|
38958
39296
|
if (t) {
|
|
38959
39297
|
if (!Ou(t)) throw new Error("SASL: SCRAM-SERVER-FIRST-MESSAGE: nonce must only contain printable characters");
|
|
38960
39298
|
} else throw new Error("SASL: SCRAM-SERVER-FIRST-MESSAGE: nonce missing");
|
|
@@ -38971,7 +39309,7 @@ var ds = T((th, ps) => {
|
|
|
38971
39309
|
}
|
|
38972
39310
|
a(qu, "parseServerFirstMessage");
|
|
38973
39311
|
function Qu(r) {
|
|
38974
|
-
let t =
|
|
39312
|
+
let t = fs7(r).get("v");
|
|
38975
39313
|
if (t) {
|
|
38976
39314
|
if (!ls(t)) throw new Error("SASL: SCRAM-SERVER-FINAL-MESSAGE: server signature must be base64");
|
|
38977
39315
|
} else throw new Error("SASL: SCRAM-SERVER-FINAL-MESSAGE: server signature is missing");
|
|
@@ -41707,8 +42045,8 @@ function drizzle2(...params) {
|
|
|
41707
42045
|
// ../db/dist/index.mjs
|
|
41708
42046
|
import { execSync, spawnSync } from "child_process";
|
|
41709
42047
|
import crypto2 from "crypto";
|
|
41710
|
-
import
|
|
41711
|
-
import
|
|
42048
|
+
import path4 from "path";
|
|
42049
|
+
import fs4 from "fs/promises";
|
|
41712
42050
|
import { readFileSync as readFileSync2 } from "fs";
|
|
41713
42051
|
import path22 from "path";
|
|
41714
42052
|
function createPostgresAdapter(options = {}) {
|
|
@@ -42194,32 +42532,32 @@ async function seedSystemTables(db, registry2, options = {}) {
|
|
|
42194
42532
|
}
|
|
42195
42533
|
function resolvedPathEnv() {
|
|
42196
42534
|
const root = process.cwd();
|
|
42197
|
-
const localBin =
|
|
42198
|
-
const existing = (process.env.PATH ?? "").split(
|
|
42199
|
-
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) };
|
|
42200
42538
|
}
|
|
42201
42539
|
async function runDevMigration(configPath) {
|
|
42202
42540
|
execSync(`drizzle-kit push --config=${configPath}`, {
|
|
42203
42541
|
stdio: "inherit",
|
|
42204
|
-
cwd:
|
|
42542
|
+
cwd: path4.dirname(configPath),
|
|
42205
42543
|
env: resolvedPathEnv()
|
|
42206
42544
|
});
|
|
42207
42545
|
}
|
|
42208
42546
|
async function generateMigration(configPath, migrationsFolder) {
|
|
42209
42547
|
let beforeFiles = [];
|
|
42210
42548
|
try {
|
|
42211
|
-
const entries = await
|
|
42549
|
+
const entries = await fs4.readdir(migrationsFolder);
|
|
42212
42550
|
beforeFiles = entries.filter((f) => f.endsWith(".sql"));
|
|
42213
42551
|
} catch {
|
|
42214
42552
|
}
|
|
42215
42553
|
execSync(`drizzle-kit generate --config=${configPath}`, {
|
|
42216
42554
|
stdio: "inherit",
|
|
42217
|
-
cwd:
|
|
42555
|
+
cwd: path4.dirname(configPath),
|
|
42218
42556
|
env: resolvedPathEnv()
|
|
42219
42557
|
});
|
|
42220
42558
|
let afterFiles = [];
|
|
42221
42559
|
try {
|
|
42222
|
-
const entries = await
|
|
42560
|
+
const entries = await fs4.readdir(migrationsFolder);
|
|
42223
42561
|
afterFiles = entries.filter((f) => f.endsWith(".sql"));
|
|
42224
42562
|
} catch {
|
|
42225
42563
|
}
|
|
@@ -42240,16 +42578,16 @@ async function applyMigrations(configPath, db, options) {
|
|
|
42240
42578
|
if (statusBefore.pending.length > 0) {
|
|
42241
42579
|
let journalEntries = [];
|
|
42242
42580
|
try {
|
|
42243
|
-
const journalPath =
|
|
42244
|
-
const raw2 = await
|
|
42581
|
+
const journalPath = path4.join(migrationsFolder, "meta", "_journal.json");
|
|
42582
|
+
const raw2 = await fs4.readFile(journalPath, "utf-8");
|
|
42245
42583
|
journalEntries = JSON.parse(raw2).entries;
|
|
42246
42584
|
} catch {
|
|
42247
42585
|
}
|
|
42248
42586
|
for (const pendingFile of statusBefore.pending) {
|
|
42249
|
-
const sqlPath =
|
|
42587
|
+
const sqlPath = path4.join(migrationsFolder, pendingFile);
|
|
42250
42588
|
let sqlContent;
|
|
42251
42589
|
try {
|
|
42252
|
-
sqlContent = await
|
|
42590
|
+
sqlContent = await fs4.readFile(sqlPath, "utf-8");
|
|
42253
42591
|
} catch {
|
|
42254
42592
|
continue;
|
|
42255
42593
|
}
|
|
@@ -42279,7 +42617,7 @@ async function applyMigrations(configPath, db, options) {
|
|
|
42279
42617
|
"drizzle-kit",
|
|
42280
42618
|
["migrate", `--config=${configPath}`],
|
|
42281
42619
|
{
|
|
42282
|
-
cwd:
|
|
42620
|
+
cwd: path4.dirname(configPath),
|
|
42283
42621
|
// inherit lets drizzle-kit write its spinner and errors directly to the
|
|
42284
42622
|
// terminal in real time — capturing stdout/stderr swallows ANSI overwrites
|
|
42285
42623
|
// and hides the actual error message.
|
|
@@ -42305,8 +42643,8 @@ async function getMigrationStatus(db, options) {
|
|
|
42305
42643
|
const { migrationsTable, migrationsFolder } = options;
|
|
42306
42644
|
let journalEntries;
|
|
42307
42645
|
try {
|
|
42308
|
-
const journalPath =
|
|
42309
|
-
const raw2 = await
|
|
42646
|
+
const journalPath = path4.join(migrationsFolder, "meta", "_journal.json");
|
|
42647
|
+
const raw2 = await fs4.readFile(journalPath, "utf-8");
|
|
42310
42648
|
const journal = JSON.parse(raw2);
|
|
42311
42649
|
journalEntries = journal.entries;
|
|
42312
42650
|
} catch {
|
|
@@ -42404,17 +42742,17 @@ function scanMigrationFiles(filePaths) {
|
|
|
42404
42742
|
// src/codegen/registry.ts
|
|
42405
42743
|
init_esm_shims();
|
|
42406
42744
|
import { writeFile } from "fs/promises";
|
|
42407
|
-
import { join as
|
|
42745
|
+
import { join as join3 } from "path";
|
|
42408
42746
|
async function generateSchemaRegistry(registry2, targetDir) {
|
|
42409
42747
|
const content = `export const schemaRegistry = ${JSON.stringify(registry2, null, 2)} as const
|
|
42410
42748
|
`;
|
|
42411
|
-
await writeFile(
|
|
42749
|
+
await writeFile(join3(targetDir, "schema-registry.ts"), content, "utf8");
|
|
42412
42750
|
}
|
|
42413
42751
|
|
|
42414
42752
|
// src/codegen/routes.ts
|
|
42415
42753
|
init_esm_shims();
|
|
42416
42754
|
import { writeFile as writeFile2 } from "fs/promises";
|
|
42417
|
-
import { join as
|
|
42755
|
+
import { join as join4 } from "path";
|
|
42418
42756
|
|
|
42419
42757
|
// ../api/dist/codegen/index.mjs
|
|
42420
42758
|
init_esm_shims();
|
|
@@ -43087,13 +43425,13 @@ function generateRoutes(registry2) {
|
|
|
43087
43425
|
// src/codegen/routes.ts
|
|
43088
43426
|
async function generateRoutes2(registry2, targetDir) {
|
|
43089
43427
|
const content = generateRoutes(registry2);
|
|
43090
|
-
await writeFile2(
|
|
43428
|
+
await writeFile2(join4(targetDir, "routes.ts"), content, "utf8");
|
|
43091
43429
|
}
|
|
43092
43430
|
|
|
43093
43431
|
// src/codegen/forms.ts
|
|
43094
43432
|
init_esm_shims();
|
|
43095
43433
|
import { mkdir, writeFile as writeFile3 } from "fs/promises";
|
|
43096
|
-
import { join as
|
|
43434
|
+
import { join as join5 } from "path";
|
|
43097
43435
|
|
|
43098
43436
|
// ../admin/dist/codegen/index.js
|
|
43099
43437
|
init_esm_shims();
|
|
@@ -43261,19 +43599,19 @@ async function generateForms(registry2, formsDir) {
|
|
|
43261
43599
|
];
|
|
43262
43600
|
for (const schema of schemas) {
|
|
43263
43601
|
const content = generateFormComponent(schema);
|
|
43264
|
-
await writeFile3(
|
|
43602
|
+
await writeFile3(join5(formsDir, `${schema.name}.vue`), content, "utf8");
|
|
43265
43603
|
}
|
|
43266
43604
|
}
|
|
43267
43605
|
|
|
43268
43606
|
// src/codegen/server-entries.ts
|
|
43269
43607
|
init_esm_shims();
|
|
43270
43608
|
import { writeFile as writeFile4 } from "fs/promises";
|
|
43271
|
-
import { join as
|
|
43609
|
+
import { join as join6 } from "path";
|
|
43272
43610
|
async function generateServerEntries(options, targetDir) {
|
|
43273
43611
|
await Promise.all([
|
|
43274
|
-
writeFile4(
|
|
43275
|
-
writeFile4(
|
|
43276
|
-
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")
|
|
43277
43615
|
]);
|
|
43278
43616
|
}
|
|
43279
43617
|
function appSetup() {
|
|
@@ -43457,7 +43795,7 @@ export default handle(app)
|
|
|
43457
43795
|
// src/codegen/programmatic-registry.ts
|
|
43458
43796
|
init_esm_shims();
|
|
43459
43797
|
import { writeFile as writeFile5 } from "fs/promises";
|
|
43460
|
-
import { join as
|
|
43798
|
+
import { join as join7, relative } from "path";
|
|
43461
43799
|
function importSpecifier(targetDir, file2) {
|
|
43462
43800
|
let rel = relative(targetDir, file2).replace(/\\/g, "/");
|
|
43463
43801
|
if (!rel.startsWith(".")) rel = `./${rel}`;
|
|
@@ -43479,7 +43817,7 @@ export const programmaticResolvers = new Map<string, ProgrammaticFieldDefinition
|
|
|
43479
43817
|
${entries},
|
|
43480
43818
|
])
|
|
43481
43819
|
`;
|
|
43482
|
-
await writeFile5(
|
|
43820
|
+
await writeFile5(join7(targetDir, "programmatic-registry.ts"), body, "utf8");
|
|
43483
43821
|
}
|
|
43484
43822
|
|
|
43485
43823
|
// src/utils/config.ts
|
|
@@ -43659,10 +43997,10 @@ async function runBuild(options, deps) {
|
|
|
43659
43997
|
);
|
|
43660
43998
|
const generatedDir = resolve3(cwd, "dist/generated");
|
|
43661
43999
|
mkdirSync(generatedDir, { recursive: true });
|
|
43662
|
-
writeFileSync(
|
|
44000
|
+
writeFileSync(join8(generatedDir, "schema.ts"), generateSchemaFile(registry2), "utf8");
|
|
43663
44001
|
await generateSchemaRegistry(registry2, generatedDir);
|
|
43664
44002
|
await generateRoutes2(registry2, generatedDir);
|
|
43665
|
-
await generateForms(registry2,
|
|
44003
|
+
await generateForms(registry2, join8(generatedDir, "forms"));
|
|
43666
44004
|
const programmaticDir = resolve3(cwd, config3.programmatic.dir);
|
|
43667
44005
|
const resolverFiles = existsSync3(programmaticDir) ? walkFiles(programmaticDir).filter((f) => /\.(ts|mjs|js)$/.test(f)) : [];
|
|
43668
44006
|
await generateProgrammaticRegistry(resolverFiles, generatedDir);
|
|
@@ -43729,14 +44067,14 @@ async function needsRebuild(cwd) {
|
|
|
43729
44067
|
);
|
|
43730
44068
|
}
|
|
43731
44069
|
function resolveAdminRoot(cwd) {
|
|
43732
|
-
const cwdRequire = createRequire(
|
|
44070
|
+
const cwdRequire = createRequire(join8(cwd, "package.json"));
|
|
43733
44071
|
const adminPkgJson = cwdRequire.resolve("@bobbykim/manguito-cms-admin/package.json");
|
|
43734
44072
|
return dirname(adminPkgJson);
|
|
43735
44073
|
}
|
|
43736
44074
|
function walkFiles(dir) {
|
|
43737
44075
|
const files = [];
|
|
43738
|
-
for (const entry of
|
|
43739
|
-
const full =
|
|
44076
|
+
for (const entry of readdirSync3(dir, { withFileTypes: true })) {
|
|
44077
|
+
const full = join8(dir, entry.name);
|
|
43740
44078
|
if (entry.isDirectory()) {
|
|
43741
44079
|
files.push(...walkFiles(full));
|
|
43742
44080
|
} else {
|
|
@@ -43750,7 +44088,7 @@ function walkFiles(dir) {
|
|
|
43750
44088
|
init_esm_shims();
|
|
43751
44089
|
import { createServer as createHttpServer } from "http";
|
|
43752
44090
|
import { existsSync as existsSync5 } from "fs";
|
|
43753
|
-
import { resolve as resolve6, join as
|
|
44091
|
+
import { resolve as resolve6, join as join12, dirname as dirname2, extname as extname4 } from "path";
|
|
43754
44092
|
import { mkdir as mkdir2, writeFile as writeFile8, watch, readFile } from "fs/promises";
|
|
43755
44093
|
import { createRequire as createRequire2 } from "module";
|
|
43756
44094
|
import { createServer as createViteServer, searchForWorkspaceRoot } from "vite";
|
|
@@ -43927,26 +44265,26 @@ var handleParsingNestedValues = (form, key, value) => {
|
|
|
43927
44265
|
|
|
43928
44266
|
// ../../node_modules/.pnpm/hono@4.12.28/node_modules/hono/dist/utils/url.js
|
|
43929
44267
|
init_esm_shims();
|
|
43930
|
-
var splitPath = (
|
|
43931
|
-
const paths =
|
|
44268
|
+
var splitPath = (path7) => {
|
|
44269
|
+
const paths = path7.split("/");
|
|
43932
44270
|
if (paths[0] === "") {
|
|
43933
44271
|
paths.shift();
|
|
43934
44272
|
}
|
|
43935
44273
|
return paths;
|
|
43936
44274
|
};
|
|
43937
44275
|
var splitRoutingPath = (routePath) => {
|
|
43938
|
-
const { groups, path:
|
|
43939
|
-
const paths = splitPath(
|
|
44276
|
+
const { groups, path: path7 } = extractGroupsFromPath(routePath);
|
|
44277
|
+
const paths = splitPath(path7);
|
|
43940
44278
|
return replaceGroupMarks(paths, groups);
|
|
43941
44279
|
};
|
|
43942
|
-
var extractGroupsFromPath = (
|
|
44280
|
+
var extractGroupsFromPath = (path7) => {
|
|
43943
44281
|
const groups = [];
|
|
43944
|
-
|
|
44282
|
+
path7 = path7.replace(/\{[^}]+\}/g, (match2, index) => {
|
|
43945
44283
|
const mark = `@${index}`;
|
|
43946
44284
|
groups.push([mark, match2]);
|
|
43947
44285
|
return mark;
|
|
43948
44286
|
});
|
|
43949
|
-
return { groups, path:
|
|
44287
|
+
return { groups, path: path7 };
|
|
43950
44288
|
};
|
|
43951
44289
|
var replaceGroupMarks = (paths, groups) => {
|
|
43952
44290
|
for (let i = groups.length - 1; i >= 0; i--) {
|
|
@@ -44003,8 +44341,8 @@ var getPath = (request) => {
|
|
|
44003
44341
|
const queryIndex = url2.indexOf("?", i);
|
|
44004
44342
|
const hashIndex = url2.indexOf("#", i);
|
|
44005
44343
|
const end = queryIndex === -1 ? hashIndex === -1 ? void 0 : hashIndex : hashIndex === -1 ? queryIndex : Math.min(queryIndex, hashIndex);
|
|
44006
|
-
const
|
|
44007
|
-
return tryDecodeURI(
|
|
44344
|
+
const path7 = url2.slice(start, end);
|
|
44345
|
+
return tryDecodeURI(path7.includes("%25") ? path7.replace(/%25/g, "%2525") : path7);
|
|
44008
44346
|
} else if (charCode === 63 || charCode === 35) {
|
|
44009
44347
|
break;
|
|
44010
44348
|
}
|
|
@@ -44021,11 +44359,11 @@ var mergePath = (base, sub, ...rest) => {
|
|
|
44021
44359
|
}
|
|
44022
44360
|
return `${base?.[0] === "/" ? "" : "/"}${base}${sub === "/" ? "" : `${base?.at(-1) === "/" ? "" : "/"}${sub?.[0] === "/" ? sub.slice(1) : sub}`}`;
|
|
44023
44361
|
};
|
|
44024
|
-
var checkOptionalParameter = (
|
|
44025
|
-
if (
|
|
44362
|
+
var checkOptionalParameter = (path7) => {
|
|
44363
|
+
if (path7.charCodeAt(path7.length - 1) !== 63 || !path7.includes(":")) {
|
|
44026
44364
|
return null;
|
|
44027
44365
|
}
|
|
44028
|
-
const segments =
|
|
44366
|
+
const segments = path7.split("/");
|
|
44029
44367
|
const results = [];
|
|
44030
44368
|
let basePath = "";
|
|
44031
44369
|
segments.forEach((segment) => {
|
|
@@ -44166,9 +44504,9 @@ var HonoRequest = class {
|
|
|
44166
44504
|
*/
|
|
44167
44505
|
path;
|
|
44168
44506
|
bodyCache = {};
|
|
44169
|
-
constructor(request,
|
|
44507
|
+
constructor(request, path7 = "/", matchResult = [[]]) {
|
|
44170
44508
|
this.raw = request;
|
|
44171
|
-
this.path =
|
|
44509
|
+
this.path = path7;
|
|
44172
44510
|
this.#matchResult = matchResult;
|
|
44173
44511
|
this.#validatedData = {};
|
|
44174
44512
|
}
|
|
@@ -44923,8 +45261,8 @@ var Hono = class _Hono {
|
|
|
44923
45261
|
return this;
|
|
44924
45262
|
};
|
|
44925
45263
|
});
|
|
44926
|
-
this.on = (method,
|
|
44927
|
-
for (const p2 of [
|
|
45264
|
+
this.on = (method, path7, ...handlers) => {
|
|
45265
|
+
for (const p2 of [path7].flat()) {
|
|
44928
45266
|
this.#path = p2;
|
|
44929
45267
|
for (const m2 of [method].flat()) {
|
|
44930
45268
|
handlers.map((handler) => {
|
|
@@ -44981,8 +45319,8 @@ var Hono = class _Hono {
|
|
|
44981
45319
|
* app.route("/api", app2) // GET /api/user
|
|
44982
45320
|
* ```
|
|
44983
45321
|
*/
|
|
44984
|
-
route(
|
|
44985
|
-
const subApp = this.basePath(
|
|
45322
|
+
route(path7, app) {
|
|
45323
|
+
const subApp = this.basePath(path7);
|
|
44986
45324
|
app.routes.map((r) => {
|
|
44987
45325
|
let handler;
|
|
44988
45326
|
if (app.errorHandler === errorHandler) {
|
|
@@ -45008,9 +45346,9 @@ var Hono = class _Hono {
|
|
|
45008
45346
|
* const api = new Hono().basePath('/api')
|
|
45009
45347
|
* ```
|
|
45010
45348
|
*/
|
|
45011
|
-
basePath(
|
|
45349
|
+
basePath(path7) {
|
|
45012
45350
|
const subApp = this.#clone();
|
|
45013
|
-
subApp._basePath = mergePath(this._basePath,
|
|
45351
|
+
subApp._basePath = mergePath(this._basePath, path7);
|
|
45014
45352
|
return subApp;
|
|
45015
45353
|
}
|
|
45016
45354
|
/**
|
|
@@ -45084,7 +45422,7 @@ var Hono = class _Hono {
|
|
|
45084
45422
|
* })
|
|
45085
45423
|
* ```
|
|
45086
45424
|
*/
|
|
45087
|
-
mount(
|
|
45425
|
+
mount(path7, applicationHandler, options) {
|
|
45088
45426
|
let replaceRequest;
|
|
45089
45427
|
let optionHandler;
|
|
45090
45428
|
if (options) {
|
|
@@ -45111,7 +45449,7 @@ var Hono = class _Hono {
|
|
|
45111
45449
|
return [c.env, executionContext];
|
|
45112
45450
|
};
|
|
45113
45451
|
replaceRequest ||= (() => {
|
|
45114
|
-
const mergedPath = mergePath(this._basePath,
|
|
45452
|
+
const mergedPath = mergePath(this._basePath, path7);
|
|
45115
45453
|
const pathPrefixLength = mergedPath === "/" ? 0 : mergedPath.length;
|
|
45116
45454
|
return (request) => {
|
|
45117
45455
|
const url2 = new URL(request.url);
|
|
@@ -45126,19 +45464,19 @@ var Hono = class _Hono {
|
|
|
45126
45464
|
}
|
|
45127
45465
|
await next();
|
|
45128
45466
|
};
|
|
45129
|
-
this.#addRoute(METHOD_NAME_ALL, mergePath(
|
|
45467
|
+
this.#addRoute(METHOD_NAME_ALL, mergePath(path7, "*"), handler);
|
|
45130
45468
|
return this;
|
|
45131
45469
|
}
|
|
45132
|
-
#addRoute(method,
|
|
45470
|
+
#addRoute(method, path7, handler, baseRoutePath) {
|
|
45133
45471
|
method = method.toUpperCase();
|
|
45134
|
-
|
|
45472
|
+
path7 = mergePath(this._basePath, path7);
|
|
45135
45473
|
const r = {
|
|
45136
45474
|
basePath: baseRoutePath !== void 0 ? mergePath(this._basePath, baseRoutePath) : this._basePath,
|
|
45137
|
-
path:
|
|
45475
|
+
path: path7,
|
|
45138
45476
|
method,
|
|
45139
45477
|
handler
|
|
45140
45478
|
};
|
|
45141
|
-
this.router.add(method,
|
|
45479
|
+
this.router.add(method, path7, [handler, r]);
|
|
45142
45480
|
this.routes.push(r);
|
|
45143
45481
|
}
|
|
45144
45482
|
#handleError(err, c) {
|
|
@@ -45151,10 +45489,10 @@ var Hono = class _Hono {
|
|
|
45151
45489
|
if (method === "HEAD") {
|
|
45152
45490
|
return (async () => new Response(null, await this.#dispatch(request, executionCtx, env, "GET")))();
|
|
45153
45491
|
}
|
|
45154
|
-
const
|
|
45155
|
-
const matchResult = this.router.match(method,
|
|
45492
|
+
const path7 = this.getPath(request, { env });
|
|
45493
|
+
const matchResult = this.router.match(method, path7);
|
|
45156
45494
|
const c = new Context(request, {
|
|
45157
|
-
path:
|
|
45495
|
+
path: path7,
|
|
45158
45496
|
matchResult,
|
|
45159
45497
|
env,
|
|
45160
45498
|
executionCtx,
|
|
@@ -45261,7 +45599,7 @@ init_esm_shims();
|
|
|
45261
45599
|
// ../../node_modules/.pnpm/hono@4.12.28/node_modules/hono/dist/router/reg-exp-router/matcher.js
|
|
45262
45600
|
init_esm_shims();
|
|
45263
45601
|
var emptyParam = [];
|
|
45264
|
-
function match(method,
|
|
45602
|
+
function match(method, path7) {
|
|
45265
45603
|
const matchers = this.buildAllMatchers();
|
|
45266
45604
|
const match2 = ((method2, path23) => {
|
|
45267
45605
|
const matcher = matchers[method2] || matchers[METHOD_NAME_ALL];
|
|
@@ -45277,7 +45615,7 @@ function match(method, path4) {
|
|
|
45277
45615
|
return [matcher[1][index], match3];
|
|
45278
45616
|
});
|
|
45279
45617
|
this.match = match2;
|
|
45280
|
-
return match2(method,
|
|
45618
|
+
return match2(method, path7);
|
|
45281
45619
|
}
|
|
45282
45620
|
|
|
45283
45621
|
// ../../node_modules/.pnpm/hono@4.12.28/node_modules/hono/dist/router/reg-exp-router/node.js
|
|
@@ -45394,12 +45732,12 @@ init_esm_shims();
|
|
|
45394
45732
|
var Trie = class {
|
|
45395
45733
|
#context = { varIndex: 0 };
|
|
45396
45734
|
#root = new Node();
|
|
45397
|
-
insert(
|
|
45735
|
+
insert(path7, index, pathErrorCheckOnly) {
|
|
45398
45736
|
const paramAssoc = [];
|
|
45399
45737
|
const groups = [];
|
|
45400
45738
|
for (let i = 0; ; ) {
|
|
45401
45739
|
let replaced = false;
|
|
45402
|
-
|
|
45740
|
+
path7 = path7.replace(/\{[^}]+\}/g, (m2) => {
|
|
45403
45741
|
const mark = `@\\${i}`;
|
|
45404
45742
|
groups[i] = [mark, m2];
|
|
45405
45743
|
i++;
|
|
@@ -45410,7 +45748,7 @@ var Trie = class {
|
|
|
45410
45748
|
break;
|
|
45411
45749
|
}
|
|
45412
45750
|
}
|
|
45413
|
-
const tokens =
|
|
45751
|
+
const tokens = path7.match(/(?::[^\/]+)|(?:\/\*$)|./g) || [];
|
|
45414
45752
|
for (let i = groups.length - 1; i >= 0; i--) {
|
|
45415
45753
|
const [mark] = groups[i];
|
|
45416
45754
|
for (let j = tokens.length - 1; j >= 0; j--) {
|
|
@@ -45449,9 +45787,9 @@ var Trie = class {
|
|
|
45449
45787
|
// ../../node_modules/.pnpm/hono@4.12.28/node_modules/hono/dist/router/reg-exp-router/router.js
|
|
45450
45788
|
var nullMatcher = [/^$/, [], /* @__PURE__ */ Object.create(null)];
|
|
45451
45789
|
var wildcardRegExpCache = /* @__PURE__ */ Object.create(null);
|
|
45452
|
-
function buildWildcardRegExp(
|
|
45453
|
-
return wildcardRegExpCache[
|
|
45454
|
-
|
|
45790
|
+
function buildWildcardRegExp(path7) {
|
|
45791
|
+
return wildcardRegExpCache[path7] ??= new RegExp(
|
|
45792
|
+
path7 === "*" ? "" : `^${path7.replace(
|
|
45455
45793
|
/\/\*$|([.\\+*[^\]$()])/g,
|
|
45456
45794
|
(_, metaChar) => metaChar ? `\\${metaChar}` : "(?:|/.*)"
|
|
45457
45795
|
)}$`
|
|
@@ -45473,17 +45811,17 @@ function buildMatcherFromPreprocessedRoutes(routes) {
|
|
|
45473
45811
|
);
|
|
45474
45812
|
const staticMap = /* @__PURE__ */ Object.create(null);
|
|
45475
45813
|
for (let i = 0, j = -1, len = routesWithStaticPathFlag.length; i < len; i++) {
|
|
45476
|
-
const [pathErrorCheckOnly,
|
|
45814
|
+
const [pathErrorCheckOnly, path7, handlers] = routesWithStaticPathFlag[i];
|
|
45477
45815
|
if (pathErrorCheckOnly) {
|
|
45478
|
-
staticMap[
|
|
45816
|
+
staticMap[path7] = [handlers.map(([h]) => [h, /* @__PURE__ */ Object.create(null)]), emptyParam];
|
|
45479
45817
|
} else {
|
|
45480
45818
|
j++;
|
|
45481
45819
|
}
|
|
45482
45820
|
let paramAssoc;
|
|
45483
45821
|
try {
|
|
45484
|
-
paramAssoc = trie.insert(
|
|
45822
|
+
paramAssoc = trie.insert(path7, j, pathErrorCheckOnly);
|
|
45485
45823
|
} catch (e) {
|
|
45486
|
-
throw e === PATH_ERROR ? new UnsupportedPathError(
|
|
45824
|
+
throw e === PATH_ERROR ? new UnsupportedPathError(path7) : e;
|
|
45487
45825
|
}
|
|
45488
45826
|
if (pathErrorCheckOnly) {
|
|
45489
45827
|
continue;
|
|
@@ -45517,12 +45855,12 @@ function buildMatcherFromPreprocessedRoutes(routes) {
|
|
|
45517
45855
|
}
|
|
45518
45856
|
return [regexp, handlerMap, staticMap];
|
|
45519
45857
|
}
|
|
45520
|
-
function findMiddleware(middleware,
|
|
45858
|
+
function findMiddleware(middleware, path7) {
|
|
45521
45859
|
if (!middleware) {
|
|
45522
45860
|
return void 0;
|
|
45523
45861
|
}
|
|
45524
45862
|
for (const k of Object.keys(middleware).sort((a2, b2) => b2.length - a2.length)) {
|
|
45525
|
-
if (buildWildcardRegExp(k).test(
|
|
45863
|
+
if (buildWildcardRegExp(k).test(path7)) {
|
|
45526
45864
|
return [...middleware[k]];
|
|
45527
45865
|
}
|
|
45528
45866
|
}
|
|
@@ -45536,7 +45874,7 @@ var RegExpRouter = class {
|
|
|
45536
45874
|
this.#middleware = { [METHOD_NAME_ALL]: /* @__PURE__ */ Object.create(null) };
|
|
45537
45875
|
this.#routes = { [METHOD_NAME_ALL]: /* @__PURE__ */ Object.create(null) };
|
|
45538
45876
|
}
|
|
45539
|
-
add(method,
|
|
45877
|
+
add(method, path7, handler) {
|
|
45540
45878
|
const middleware = this.#middleware;
|
|
45541
45879
|
const routes = this.#routes;
|
|
45542
45880
|
if (!middleware || !routes) {
|
|
@@ -45551,18 +45889,18 @@ var RegExpRouter = class {
|
|
|
45551
45889
|
});
|
|
45552
45890
|
});
|
|
45553
45891
|
}
|
|
45554
|
-
if (
|
|
45555
|
-
|
|
45892
|
+
if (path7 === "/*") {
|
|
45893
|
+
path7 = "*";
|
|
45556
45894
|
}
|
|
45557
|
-
const paramCount = (
|
|
45558
|
-
if (/\*$/.test(
|
|
45559
|
-
const re = buildWildcardRegExp(
|
|
45895
|
+
const paramCount = (path7.match(/\/:/g) || []).length;
|
|
45896
|
+
if (/\*$/.test(path7)) {
|
|
45897
|
+
const re = buildWildcardRegExp(path7);
|
|
45560
45898
|
if (method === METHOD_NAME_ALL) {
|
|
45561
45899
|
Object.keys(middleware).forEach((m2) => {
|
|
45562
|
-
middleware[m2][
|
|
45900
|
+
middleware[m2][path7] ||= findMiddleware(middleware[m2], path7) || findMiddleware(middleware[METHOD_NAME_ALL], path7) || [];
|
|
45563
45901
|
});
|
|
45564
45902
|
} else {
|
|
45565
|
-
middleware[method][
|
|
45903
|
+
middleware[method][path7] ||= findMiddleware(middleware[method], path7) || findMiddleware(middleware[METHOD_NAME_ALL], path7) || [];
|
|
45566
45904
|
}
|
|
45567
45905
|
Object.keys(middleware).forEach((m2) => {
|
|
45568
45906
|
if (method === METHOD_NAME_ALL || method === m2) {
|
|
@@ -45580,7 +45918,7 @@ var RegExpRouter = class {
|
|
|
45580
45918
|
});
|
|
45581
45919
|
return;
|
|
45582
45920
|
}
|
|
45583
|
-
const paths = checkOptionalParameter(
|
|
45921
|
+
const paths = checkOptionalParameter(path7) || [path7];
|
|
45584
45922
|
for (let i = 0, len = paths.length; i < len; i++) {
|
|
45585
45923
|
const path23 = paths[i];
|
|
45586
45924
|
Object.keys(routes).forEach((m2) => {
|
|
@@ -45607,13 +45945,13 @@ var RegExpRouter = class {
|
|
|
45607
45945
|
const routes = [];
|
|
45608
45946
|
let hasOwnRoute = method === METHOD_NAME_ALL;
|
|
45609
45947
|
[this.#middleware, this.#routes].forEach((r) => {
|
|
45610
|
-
const ownRoute = r[method] ? Object.keys(r[method]).map((
|
|
45948
|
+
const ownRoute = r[method] ? Object.keys(r[method]).map((path7) => [path7, r[method][path7]]) : [];
|
|
45611
45949
|
if (ownRoute.length !== 0) {
|
|
45612
45950
|
hasOwnRoute ||= true;
|
|
45613
45951
|
routes.push(...ownRoute);
|
|
45614
45952
|
} else if (method !== METHOD_NAME_ALL) {
|
|
45615
45953
|
routes.push(
|
|
45616
|
-
...Object.keys(r[METHOD_NAME_ALL]).map((
|
|
45954
|
+
...Object.keys(r[METHOD_NAME_ALL]).map((path7) => [path7, r[METHOD_NAME_ALL][path7]])
|
|
45617
45955
|
);
|
|
45618
45956
|
}
|
|
45619
45957
|
});
|
|
@@ -45640,13 +45978,13 @@ var SmartRouter = class {
|
|
|
45640
45978
|
constructor(init) {
|
|
45641
45979
|
this.#routers = init.routers;
|
|
45642
45980
|
}
|
|
45643
|
-
add(method,
|
|
45981
|
+
add(method, path7, handler) {
|
|
45644
45982
|
if (!this.#routes) {
|
|
45645
45983
|
throw new Error(MESSAGE_MATCHER_IS_ALREADY_BUILT);
|
|
45646
45984
|
}
|
|
45647
|
-
this.#routes.push([method,
|
|
45985
|
+
this.#routes.push([method, path7, handler]);
|
|
45648
45986
|
}
|
|
45649
|
-
match(method,
|
|
45987
|
+
match(method, path7) {
|
|
45650
45988
|
if (!this.#routes) {
|
|
45651
45989
|
throw new Error("Fatal error");
|
|
45652
45990
|
}
|
|
@@ -45661,7 +45999,7 @@ var SmartRouter = class {
|
|
|
45661
45999
|
for (let i2 = 0, len2 = routes.length; i2 < len2; i2++) {
|
|
45662
46000
|
router.add(...routes[i2]);
|
|
45663
46001
|
}
|
|
45664
|
-
res = router.match(method,
|
|
46002
|
+
res = router.match(method, path7);
|
|
45665
46003
|
} catch (e) {
|
|
45666
46004
|
if (e instanceof UnsupportedPathError) {
|
|
45667
46005
|
continue;
|
|
@@ -45718,10 +46056,10 @@ var Node2 = class _Node2 {
|
|
|
45718
46056
|
}
|
|
45719
46057
|
this.#patterns = [];
|
|
45720
46058
|
}
|
|
45721
|
-
insert(method,
|
|
46059
|
+
insert(method, path7, handler) {
|
|
45722
46060
|
this.#order = ++this.#order;
|
|
45723
46061
|
let curNode = this;
|
|
45724
|
-
const parts = splitRoutingPath(
|
|
46062
|
+
const parts = splitRoutingPath(path7);
|
|
45725
46063
|
const possibleKeys = [];
|
|
45726
46064
|
for (let i = 0, len = parts.length; i < len; i++) {
|
|
45727
46065
|
const p2 = parts[i];
|
|
@@ -45770,12 +46108,12 @@ var Node2 = class _Node2 {
|
|
|
45770
46108
|
}
|
|
45771
46109
|
}
|
|
45772
46110
|
}
|
|
45773
|
-
search(method,
|
|
46111
|
+
search(method, path7) {
|
|
45774
46112
|
const handlerSets = [];
|
|
45775
46113
|
this.#params = emptyParams;
|
|
45776
46114
|
const curNode = this;
|
|
45777
46115
|
let curNodes = [curNode];
|
|
45778
|
-
const parts = splitPath(
|
|
46116
|
+
const parts = splitPath(path7);
|
|
45779
46117
|
const curNodesQueue = [];
|
|
45780
46118
|
const len = parts.length;
|
|
45781
46119
|
let partOffsets = null;
|
|
@@ -45817,13 +46155,13 @@ var Node2 = class _Node2 {
|
|
|
45817
46155
|
if (matcher instanceof RegExp) {
|
|
45818
46156
|
if (partOffsets === null) {
|
|
45819
46157
|
partOffsets = new Array(len);
|
|
45820
|
-
let offset =
|
|
46158
|
+
let offset = path7[0] === "/" ? 1 : 0;
|
|
45821
46159
|
for (let p2 = 0; p2 < len; p2++) {
|
|
45822
46160
|
partOffsets[p2] = offset;
|
|
45823
46161
|
offset += parts[p2].length + 1;
|
|
45824
46162
|
}
|
|
45825
46163
|
}
|
|
45826
|
-
const restPathString =
|
|
46164
|
+
const restPathString = path7.substring(partOffsets[i]);
|
|
45827
46165
|
const m2 = matcher.exec(restPathString);
|
|
45828
46166
|
if (m2) {
|
|
45829
46167
|
params[name] = m2[0];
|
|
@@ -45876,18 +46214,18 @@ var TrieRouter = class {
|
|
|
45876
46214
|
constructor() {
|
|
45877
46215
|
this.#node = new Node2();
|
|
45878
46216
|
}
|
|
45879
|
-
add(method,
|
|
45880
|
-
const results = checkOptionalParameter(
|
|
46217
|
+
add(method, path7, handler) {
|
|
46218
|
+
const results = checkOptionalParameter(path7);
|
|
45881
46219
|
if (results) {
|
|
45882
46220
|
for (let i = 0, len = results.length; i < len; i++) {
|
|
45883
46221
|
this.#node.insert(method, results[i], handler);
|
|
45884
46222
|
}
|
|
45885
46223
|
return;
|
|
45886
46224
|
}
|
|
45887
|
-
this.#node.insert(method,
|
|
46225
|
+
this.#node.insert(method, path7, handler);
|
|
45888
46226
|
}
|
|
45889
|
-
match(method,
|
|
45890
|
-
return this.#node.search(method,
|
|
46227
|
+
match(method, path7) {
|
|
46228
|
+
return this.#node.search(method, path7);
|
|
45891
46229
|
}
|
|
45892
46230
|
};
|
|
45893
46231
|
|
|
@@ -46817,8 +47155,8 @@ function setAuthCookie(c, name, token, options) {
|
|
|
46817
47155
|
sameSite: "Strict"
|
|
46818
47156
|
});
|
|
46819
47157
|
}
|
|
46820
|
-
function clearAuthCookie(c, name,
|
|
46821
|
-
deleteCookie(c, name,
|
|
47158
|
+
function clearAuthCookie(c, name, path7) {
|
|
47159
|
+
deleteCookie(c, name, path7 !== void 0 ? { path: path7 } : void 0);
|
|
46822
47160
|
}
|
|
46823
47161
|
function createAuthMiddleware(db) {
|
|
46824
47162
|
return async (c, next) => {
|
|
@@ -47324,11 +47662,11 @@ function isPublished(item) {
|
|
|
47324
47662
|
return item["published"] === true;
|
|
47325
47663
|
}
|
|
47326
47664
|
function registerPublicContentRoutes(app, registry2, repos, projectors, paths, listRateLimit, resolver) {
|
|
47327
|
-
function registerListRoute(
|
|
47665
|
+
function registerListRoute(path7, handler) {
|
|
47328
47666
|
if (listRateLimit) {
|
|
47329
|
-
app.get(
|
|
47667
|
+
app.get(path7, listRateLimit, handler);
|
|
47330
47668
|
} else {
|
|
47331
|
-
app.get(
|
|
47669
|
+
app.get(path7, handler);
|
|
47332
47670
|
}
|
|
47333
47671
|
}
|
|
47334
47672
|
registerListRoute(paths.collection("content"), (c) => {
|
|
@@ -49293,7 +49631,7 @@ function registerUserRoutes(app, db, requirePermission, requireHierarchy) {
|
|
|
49293
49631
|
}
|
|
49294
49632
|
var API_VERSION = (() => {
|
|
49295
49633
|
try {
|
|
49296
|
-
return "0.4.
|
|
49634
|
+
return "0.4.3";
|
|
49297
49635
|
} catch {
|
|
49298
49636
|
return "0.0.0";
|
|
49299
49637
|
}
|
|
@@ -49894,7 +50232,7 @@ function createCmsApp(options) {
|
|
|
49894
50232
|
// src/codegen/drizzle-config.ts
|
|
49895
50233
|
init_esm_shims();
|
|
49896
50234
|
import { writeFile as writeFile6 } from "fs/promises";
|
|
49897
|
-
import { join as
|
|
50235
|
+
import { join as join9, relative as relative2, resolve as resolve4 } from "path";
|
|
49898
50236
|
async function generateDrizzleConfig(config3, targetDir) {
|
|
49899
50237
|
const migrationsFolder = config3.migrations?.folder ?? "./migrations";
|
|
49900
50238
|
const migrationsTable = config3.migrations?.table ?? "__manguito_migrations";
|
|
@@ -49916,13 +50254,13 @@ async function generateDrizzleConfig(config3, targetDir) {
|
|
|
49916
50254
|
` tablesFilter: ['!${migrationsTable}'],`,
|
|
49917
50255
|
`})`
|
|
49918
50256
|
].join("\n");
|
|
49919
|
-
await writeFile6(
|
|
50257
|
+
await writeFile6(join9(targetDir, "drizzle.config.ts"), content, "utf8");
|
|
49920
50258
|
}
|
|
49921
50259
|
|
|
49922
50260
|
// src/codegen/nav.ts
|
|
49923
50261
|
init_esm_shims();
|
|
49924
50262
|
import { writeFile as writeFile7 } from "fs/promises";
|
|
49925
|
-
import { join as
|
|
50263
|
+
import { join as join10 } from "path";
|
|
49926
50264
|
function schemaBasePath(name) {
|
|
49927
50265
|
const segment = name.includes("--") ? name.slice(name.indexOf("--") + 2) : name;
|
|
49928
50266
|
return segment.replace(/_/g, "-");
|
|
@@ -49940,17 +50278,17 @@ async function generateNav(registry2, targetDir) {
|
|
|
49940
50278
|
})).sort((a2, b2) => a2.label.localeCompare(b2.label));
|
|
49941
50279
|
const content = `export const nav = ${JSON.stringify({ contentTypes, taxonomyTypes }, null, 2)}
|
|
49942
50280
|
`;
|
|
49943
|
-
await writeFile7(
|
|
50281
|
+
await writeFile7(join10(targetDir, "nav.ts"), content, "utf8");
|
|
49944
50282
|
}
|
|
49945
50283
|
|
|
49946
50284
|
// src/commands/dev-routing.ts
|
|
49947
50285
|
init_esm_shims();
|
|
49948
50286
|
var ABSOLUTE_BACKEND_PATHS = ["/graphql"];
|
|
49949
50287
|
function shouldBridgeToHono(url2, apiPrefix) {
|
|
49950
|
-
const
|
|
49951
|
-
if (
|
|
49952
|
-
if (
|
|
49953
|
-
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);
|
|
49954
50292
|
}
|
|
49955
50293
|
|
|
49956
50294
|
// src/utils/db.ts
|
|
@@ -49985,7 +50323,7 @@ function createPromptAdapter() {
|
|
|
49985
50323
|
init_esm_shims();
|
|
49986
50324
|
import { existsSync as existsSync4 } from "fs";
|
|
49987
50325
|
import { readdir } from "fs/promises";
|
|
49988
|
-
import { resolve as resolve5, join as
|
|
50326
|
+
import { resolve as resolve5, join as join11, extname as extname3 } from "path";
|
|
49989
50327
|
import { pathToFileURL as pathToFileURL2 } from "url";
|
|
49990
50328
|
var RESOLVER_EXTENSIONS = /* @__PURE__ */ new Set([".ts", ".mjs", ".js"]);
|
|
49991
50329
|
function isProgrammaticFieldDefinition(v2) {
|
|
@@ -49994,7 +50332,7 @@ function isProgrammaticFieldDefinition(v2) {
|
|
|
49994
50332
|
async function walkTsFiles(dir) {
|
|
49995
50333
|
const out = [];
|
|
49996
50334
|
for (const entry of await readdir(dir, { withFileTypes: true })) {
|
|
49997
|
-
const full =
|
|
50335
|
+
const full = join11(dir, entry.name);
|
|
49998
50336
|
if (entry.isDirectory()) {
|
|
49999
50337
|
out.push(...await walkTsFiles(full));
|
|
50000
50338
|
} else if (RESOLVER_EXTENSIONS.has(extname3(entry.name))) {
|
|
@@ -50057,7 +50395,7 @@ async function runDev(options, deps) {
|
|
|
50057
50395
|
const needsSeed = !await db.tableExists("users");
|
|
50058
50396
|
const bootstrapRegistry = await parseAllSchemas(cwd, config3);
|
|
50059
50397
|
await generateDrizzleConfig(config3, manguitoDir);
|
|
50060
|
-
await writeFile8(
|
|
50398
|
+
await writeFile8(join12(manguitoDir, "schema.ts"), generateSchemaFile(bootstrapRegistry), "utf8");
|
|
50061
50399
|
await runDevMigration(drizzleConfigPath);
|
|
50062
50400
|
printSuccess(needsSeed ? "Schema tables created" : "Schema tables up to date");
|
|
50063
50401
|
if (needsSeed) {
|
|
@@ -50103,7 +50441,7 @@ async function runDev(options, deps) {
|
|
|
50103
50441
|
);
|
|
50104
50442
|
await generateSchemaRegistry(registry2, manguitoDir);
|
|
50105
50443
|
await generateRoutes2(registry2, manguitoDir);
|
|
50106
|
-
await generateForms(registry2,
|
|
50444
|
+
await generateForms(registry2, join12(manguitoDir, "forms"));
|
|
50107
50445
|
await generateNav(registry2, manguitoDir);
|
|
50108
50446
|
const resolverMap = await loadProgrammaticResolvers(cwd, config3.programmatic.dir);
|
|
50109
50447
|
const adapter = createCmsApp({
|
|
@@ -50237,10 +50575,10 @@ async function onSchemaFileChange(args) {
|
|
|
50237
50575
|
return;
|
|
50238
50576
|
}
|
|
50239
50577
|
await generateDrizzleConfig(config3, manguitoDir);
|
|
50240
|
-
await writeFile8(
|
|
50578
|
+
await writeFile8(join12(manguitoDir, "schema.ts"), generateSchemaFile(registry2), "utf8");
|
|
50241
50579
|
await generateSchemaRegistry(registry2, manguitoDir);
|
|
50242
50580
|
await generateRoutes2(registry2, manguitoDir);
|
|
50243
|
-
await generateForms(registry2,
|
|
50581
|
+
await generateForms(registry2, join12(manguitoDir, "forms"));
|
|
50244
50582
|
await generateNav(registry2, manguitoDir);
|
|
50245
50583
|
try {
|
|
50246
50584
|
await runDevMigration(drizzleConfigPath);
|
|
@@ -50305,7 +50643,7 @@ async function parseAllSchemas(cwd, config3) {
|
|
|
50305
50643
|
return buildSchemaRegistry(parsedSchemas, routesResult.value, rolesResult.value);
|
|
50306
50644
|
}
|
|
50307
50645
|
function resolveAdminRoot2(cwd) {
|
|
50308
|
-
const cwdRequire = createRequire2(
|
|
50646
|
+
const cwdRequire = createRequire2(join12(cwd, "package.json"));
|
|
50309
50647
|
const adminPkgJson = cwdRequire.resolve("@bobbykim/manguito-cms-admin/package.json");
|
|
50310
50648
|
return dirname2(adminPkgJson);
|
|
50311
50649
|
}
|
|
@@ -50443,7 +50781,7 @@ async function runStart(options, deps) {
|
|
|
50443
50781
|
|
|
50444
50782
|
// src/commands/migrate.ts
|
|
50445
50783
|
init_esm_shims();
|
|
50446
|
-
import { resolve as resolve8, join as
|
|
50784
|
+
import { resolve as resolve8, join as join13 } from "path";
|
|
50447
50785
|
import { readFile as readFile2 } from "fs/promises";
|
|
50448
50786
|
function registerMigrate(program2) {
|
|
50449
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) => {
|
|
@@ -50532,7 +50870,7 @@ async function runMigrate(options, deps) {
|
|
|
50532
50870
|
const generatedDir = resolve8(cwd, "dist/generated");
|
|
50533
50871
|
await generateDrizzleConfig(config3, generatedDir);
|
|
50534
50872
|
const newFileNames = await generateMigration(deps.configPath, migrationsFolder);
|
|
50535
|
-
const newFilePaths = newFileNames.map((f) =>
|
|
50873
|
+
const newFilePaths = newFileNames.map((f) => join13(migrationsFolder, f));
|
|
50536
50874
|
printSuccess(
|
|
50537
50875
|
newFileNames.length === 0 ? "No new migration files generated" : `Generated ${newFileNames.length} migration file${newFileNames.length !== 1 ? "s" : ""}: ${newFileNames.join(", ")}`
|
|
50538
50876
|
);
|
|
@@ -50960,6 +51298,333 @@ async function runUsersDemote(options, deps) {
|
|
|
50960
51298
|
printSuccess(`${email3} demoted to ${targetRole.name}.`);
|
|
50961
51299
|
}
|
|
50962
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
|
+
|
|
50963
51628
|
// src/index.ts
|
|
50964
51629
|
var require2 = createRequire3(import.meta.url);
|
|
50965
51630
|
var { version: version2 } = require2("../package.json");
|
|
@@ -50971,6 +51636,7 @@ registerMigrate(program);
|
|
|
50971
51636
|
registerValidate(program);
|
|
50972
51637
|
registerCreateSuperuser(program);
|
|
50973
51638
|
registerUsers(program);
|
|
51639
|
+
registerVersion(program);
|
|
50974
51640
|
program.parse();
|
|
50975
51641
|
/*! Bundled license information:
|
|
50976
51642
|
|