@brightsideoy/kama 0.1.0-alpha.124 → 0.1.0-alpha.126
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js
CHANGED
|
@@ -253,22 +253,22 @@ function oe(e, t) {
|
|
|
253
253
|
}
|
|
254
254
|
//#endregion
|
|
255
255
|
//#region node_modules/yaml/browser/dist/doc/applyReviver.js
|
|
256
|
-
function
|
|
256
|
+
function M(e, t, n, r) {
|
|
257
257
|
if (r && typeof r == "object") {
|
|
258
258
|
if (Array.isArray(r)) for (let t = 0, n = r.length; t < n; ++t) {
|
|
259
|
-
let n = r[t], i =
|
|
259
|
+
let n = r[t], i = M(e, r, String(t), n);
|
|
260
260
|
i === void 0 ? delete r[t] : i !== n && (r[t] = i);
|
|
261
261
|
}
|
|
262
262
|
else if (r instanceof Map) for (let t of Array.from(r.keys())) {
|
|
263
|
-
let n = r.get(t), i =
|
|
263
|
+
let n = r.get(t), i = M(e, r, t, n);
|
|
264
264
|
i === void 0 ? r.delete(t) : i !== n && r.set(t, i);
|
|
265
265
|
}
|
|
266
266
|
else if (r instanceof Set) for (let t of Array.from(r)) {
|
|
267
|
-
let n =
|
|
267
|
+
let n = M(e, r, t, t);
|
|
268
268
|
n === void 0 ? r.delete(t) : n !== t && (r.delete(t), r.add(n));
|
|
269
269
|
}
|
|
270
270
|
else for (let [t, n] of Object.entries(r)) {
|
|
271
|
-
let i =
|
|
271
|
+
let i = M(e, r, t, n);
|
|
272
272
|
i === void 0 ? delete r[t] : i !== n && (r[t] = i);
|
|
273
273
|
}
|
|
274
274
|
}
|
|
@@ -276,8 +276,8 @@ function se(e, t, n, r) {
|
|
|
276
276
|
}
|
|
277
277
|
//#endregion
|
|
278
278
|
//#region node_modules/yaml/browser/dist/nodes/toJS.js
|
|
279
|
-
function
|
|
280
|
-
if (Array.isArray(e)) return e.map((e, t) =>
|
|
279
|
+
function N(e, t, n) {
|
|
280
|
+
if (Array.isArray(e)) return e.map((e, t) => N(e, String(t), n));
|
|
281
281
|
if (e && typeof e.toJSON == "function") {
|
|
282
282
|
if (!n || !x(e)) return e.toJSON(t, n);
|
|
283
283
|
let r = {
|
|
@@ -295,7 +295,7 @@ function M(e, t, n) {
|
|
|
295
295
|
}
|
|
296
296
|
//#endregion
|
|
297
297
|
//#region node_modules/yaml/browser/dist/nodes/Node.js
|
|
298
|
-
var
|
|
298
|
+
var se = class {
|
|
299
299
|
constructor(e) {
|
|
300
300
|
Object.defineProperty(this, f, { value: e });
|
|
301
301
|
}
|
|
@@ -312,11 +312,11 @@ var ce = class {
|
|
|
312
312
|
mapAsMap: t === !0,
|
|
313
313
|
mapKeyWarned: !1,
|
|
314
314
|
maxAliasCount: typeof n == "number" ? n : 100
|
|
315
|
-
}, o =
|
|
315
|
+
}, o = N(this, "", a);
|
|
316
316
|
if (typeof r == "function") for (let { count: e, res: t } of a.anchors.values()) r(t, e);
|
|
317
|
-
return typeof i == "function" ?
|
|
317
|
+
return typeof i == "function" ? M(i, { "": o }, "", o) : o;
|
|
318
318
|
}
|
|
319
|
-
},
|
|
319
|
+
}, P = class extends se {
|
|
320
320
|
constructor(e) {
|
|
321
321
|
super(o), this.source = e, Object.defineProperty(this, "tag", { set() {
|
|
322
322
|
throw Error("Alias nodes cannot have tags");
|
|
@@ -344,8 +344,8 @@ var ce = class {
|
|
|
344
344
|
}
|
|
345
345
|
let o = n.get(a);
|
|
346
346
|
/* istanbul ignore if */
|
|
347
|
-
if (o ||= (
|
|
348
|
-
if (i >= 0 && (o.count += 1, o.aliasCount === 0 && (o.aliasCount =
|
|
347
|
+
if (o ||= (N(a, null, t), n.get(a)), o?.res === void 0) throw ReferenceError("This should not happen: Alias anchor was not resolved?");
|
|
348
|
+
if (i >= 0 && (o.count += 1, o.aliasCount === 0 && (o.aliasCount = ce(r, a, n)), o.count * o.aliasCount > i)) throw ReferenceError("Excessive alias count indicates a resource exhaustion attack");
|
|
349
349
|
return o.res;
|
|
350
350
|
}
|
|
351
351
|
toString(e, t, n) {
|
|
@@ -360,7 +360,7 @@ var ce = class {
|
|
|
360
360
|
return r;
|
|
361
361
|
}
|
|
362
362
|
};
|
|
363
|
-
function
|
|
363
|
+
function ce(e, t, n) {
|
|
364
364
|
if (p(t)) {
|
|
365
365
|
let r = t.resolve(e), i = n && r && n.get(r);
|
|
366
366
|
return i ? i.count * i.aliasCount : 0;
|
|
@@ -368,35 +368,35 @@ function le(e, t, n) {
|
|
|
368
368
|
if (y(t)) {
|
|
369
369
|
let r = 0;
|
|
370
370
|
for (let i of t.items) {
|
|
371
|
-
let t =
|
|
371
|
+
let t = ce(e, i, n);
|
|
372
372
|
t > r && (r = t);
|
|
373
373
|
}
|
|
374
374
|
return r;
|
|
375
375
|
}
|
|
376
376
|
if (g(t)) {
|
|
377
|
-
let r =
|
|
377
|
+
let r = ce(e, t.key, n), i = ce(e, t.value, n);
|
|
378
378
|
return Math.max(r, i);
|
|
379
379
|
}
|
|
380
380
|
return 1;
|
|
381
381
|
}
|
|
382
382
|
//#endregion
|
|
383
383
|
//#region node_modules/yaml/browser/dist/nodes/Scalar.js
|
|
384
|
-
var
|
|
384
|
+
var le = (e) => !e || typeof e != "function" && typeof e != "object", F = class extends se {
|
|
385
385
|
constructor(e) {
|
|
386
386
|
super(u), this.value = e;
|
|
387
387
|
}
|
|
388
388
|
toJSON(e, t) {
|
|
389
|
-
return t?.keep ? this.value :
|
|
389
|
+
return t?.keep ? this.value : N(this.value, e, t);
|
|
390
390
|
}
|
|
391
391
|
toString() {
|
|
392
392
|
return String(this.value);
|
|
393
393
|
}
|
|
394
394
|
};
|
|
395
|
-
|
|
395
|
+
F.BLOCK_FOLDED = "BLOCK_FOLDED", F.BLOCK_LITERAL = "BLOCK_LITERAL", F.PLAIN = "PLAIN", F.QUOTE_DOUBLE = "QUOTE_DOUBLE", F.QUOTE_SINGLE = "QUOTE_SINGLE";
|
|
396
396
|
//#endregion
|
|
397
397
|
//#region node_modules/yaml/browser/dist/doc/createNode.js
|
|
398
|
-
var
|
|
399
|
-
function
|
|
398
|
+
var ue = "tag:yaml.org,2002:";
|
|
399
|
+
function de(e, t, n) {
|
|
400
400
|
if (t) {
|
|
401
401
|
let e = n.filter((e) => e.tag === t), r = e.find((e) => !e.format) ?? e[0];
|
|
402
402
|
if (!r) throw Error(`Tag ${t} not found`);
|
|
@@ -404,7 +404,7 @@ function fe(e, t, n) {
|
|
|
404
404
|
}
|
|
405
405
|
return n.find((t) => t.identify?.(e) && !t.format);
|
|
406
406
|
}
|
|
407
|
-
function
|
|
407
|
+
function fe(e, t, n) {
|
|
408
408
|
if (m(e) && (e = e.contents), b(e)) return e;
|
|
409
409
|
if (g(e)) {
|
|
410
410
|
let t = n.schema[c].createNode?.(n.schema, null, n);
|
|
@@ -413,28 +413,28 @@ function pe(e, t, n) {
|
|
|
413
413
|
(e instanceof String || e instanceof Number || e instanceof Boolean || typeof BigInt < "u" && e instanceof BigInt) && (e = e.valueOf());
|
|
414
414
|
let { aliasDuplicateObjects: r, onAnchor: i, onTagObj: a, schema: o, sourceObjects: s } = n, l;
|
|
415
415
|
if (r && e && typeof e == "object") {
|
|
416
|
-
if (l = s.get(e), l) return l.anchor ?? (l.anchor = i(e)), new
|
|
416
|
+
if (l = s.get(e), l) return l.anchor ?? (l.anchor = i(e)), new P(l.anchor);
|
|
417
417
|
l = {
|
|
418
418
|
anchor: null,
|
|
419
419
|
node: null
|
|
420
420
|
}, s.set(e, l);
|
|
421
421
|
}
|
|
422
|
-
t?.startsWith("!!") && (t =
|
|
423
|
-
let u =
|
|
422
|
+
t?.startsWith("!!") && (t = ue + t.slice(2));
|
|
423
|
+
let u = de(e, t, o.tags);
|
|
424
424
|
if (!u) {
|
|
425
425
|
if (e && typeof e.toJSON == "function" && (e = e.toJSON()), !e || typeof e != "object") {
|
|
426
|
-
let t = new
|
|
426
|
+
let t = new F(e);
|
|
427
427
|
return l && (l.node = t), t;
|
|
428
428
|
}
|
|
429
429
|
u = e instanceof Map ? o[c] : Symbol.iterator in Object(e) ? o[d] : o[c];
|
|
430
430
|
}
|
|
431
431
|
a && (a(u), delete n.onTagObj);
|
|
432
|
-
let f = u?.createNode ? u.createNode(n.schema, e, n) : typeof u?.nodeClass?.from == "function" ? u.nodeClass.from(n.schema, e, n) : new
|
|
432
|
+
let f = u?.createNode ? u.createNode(n.schema, e, n) : typeof u?.nodeClass?.from == "function" ? u.nodeClass.from(n.schema, e, n) : new F(e);
|
|
433
433
|
return t ? f.tag = t : u.default || (f.tag = u.tag), l && (l.node = f), f;
|
|
434
434
|
}
|
|
435
435
|
//#endregion
|
|
436
436
|
//#region node_modules/yaml/browser/dist/nodes/Collection.js
|
|
437
|
-
function
|
|
437
|
+
function pe(e, t, n) {
|
|
438
438
|
let r = n;
|
|
439
439
|
for (let e = t.length - 1; e >= 0; --e) {
|
|
440
440
|
let n = t[e];
|
|
@@ -443,7 +443,7 @@ function me(e, t, n) {
|
|
|
443
443
|
e[n] = r, r = e;
|
|
444
444
|
} else r = /* @__PURE__ */ new Map([[n, r]]);
|
|
445
445
|
}
|
|
446
|
-
return
|
|
446
|
+
return fe(r, void 0, {
|
|
447
447
|
aliasDuplicateObjects: !1,
|
|
448
448
|
keepUndefined: !1,
|
|
449
449
|
onAnchor: () => {
|
|
@@ -453,7 +453,7 @@ function me(e, t, n) {
|
|
|
453
453
|
sourceObjects: /* @__PURE__ */ new Map()
|
|
454
454
|
});
|
|
455
455
|
}
|
|
456
|
-
var
|
|
456
|
+
var me = (e) => e == null || typeof e == "object" && !!e[Symbol.iterator]().next().done, I = class extends se {
|
|
457
457
|
constructor(e, t) {
|
|
458
458
|
super(e), Object.defineProperty(this, "schema", {
|
|
459
459
|
value: t,
|
|
@@ -467,11 +467,11 @@ var he = (e) => e == null || typeof e == "object" && !!e[Symbol.iterator]().next
|
|
|
467
467
|
return e && (t.schema = e), t.items = t.items.map((t) => b(t) || g(t) ? t.clone(e) : t), this.range && (t.range = this.range.slice()), t;
|
|
468
468
|
}
|
|
469
469
|
addIn(e, t) {
|
|
470
|
-
if (
|
|
470
|
+
if (me(e)) this.add(t);
|
|
471
471
|
else {
|
|
472
472
|
let [n, ...r] = e, i = this.get(n, !0);
|
|
473
473
|
if (y(i)) i.addIn(r, t);
|
|
474
|
-
else if (i === void 0 && this.schema) this.set(n,
|
|
474
|
+
else if (i === void 0 && this.schema) this.set(n, pe(this.schema, r, t));
|
|
475
475
|
else throw Error(`Expected YAML collection at ${n}. Remaining path: ${r}`);
|
|
476
476
|
}
|
|
477
477
|
}
|
|
@@ -505,16 +505,16 @@ var he = (e) => e == null || typeof e == "object" && !!e[Symbol.iterator]().next
|
|
|
505
505
|
else {
|
|
506
506
|
let e = this.get(n, !0);
|
|
507
507
|
if (y(e)) e.setIn(r, t);
|
|
508
|
-
else if (e === void 0 && this.schema) this.set(n,
|
|
508
|
+
else if (e === void 0 && this.schema) this.set(n, pe(this.schema, r, t));
|
|
509
509
|
else throw Error(`Expected YAML collection at ${n}. Remaining path: ${r}`);
|
|
510
510
|
}
|
|
511
511
|
}
|
|
512
|
-
},
|
|
513
|
-
function
|
|
512
|
+
}, he = (e) => e.replace(/^(?!$)(?: $)?/gm, "#");
|
|
513
|
+
function L(e, t) {
|
|
514
514
|
return /^\n+$/.test(e) ? e.substring(1) : t ? e.replace(/^(?! *$)/gm, t) : e;
|
|
515
515
|
}
|
|
516
|
-
var
|
|
517
|
-
function
|
|
516
|
+
var R = (e, t, n) => e.endsWith("\n") ? L(n, t) : n.includes("\n") ? "\n" + L(n, t) : (e.endsWith(" ") ? "" : " ") + n, ge = "flow", _e = "block", ve = "quoted";
|
|
517
|
+
function ye(e, t, n = "flow", { indentAtStart: r, lineWidth: i = 80, minContentWidth: a = 20, onFold: o, onOverflow: s } = {}) {
|
|
518
518
|
if (!i || i < 0) return e;
|
|
519
519
|
i < a && (a = 0);
|
|
520
520
|
let c = Math.max(1 + a, 1 + i - t.length);
|
|
@@ -522,7 +522,7 @@ function be(e, t, n = "flow", { indentAtStart: r, lineWidth: i = 80, minContentW
|
|
|
522
522
|
let l = [], u = {}, d = i - t.length;
|
|
523
523
|
typeof r == "number" && (r > i - Math.max(2, a) ? l.push(0) : d = i - r);
|
|
524
524
|
let f, p, m = !1, h = -1, g = -1, _ = -1;
|
|
525
|
-
n === "block" && (h =
|
|
525
|
+
n === "block" && (h = z(e, h, t.length), h !== -1 && (d = h + c));
|
|
526
526
|
for (let r; r = e[h += 1];) {
|
|
527
527
|
if (n === "quoted" && r === "\\") {
|
|
528
528
|
switch (g = h, e[h + 1]) {
|
|
@@ -539,7 +539,7 @@ function be(e, t, n = "flow", { indentAtStart: r, lineWidth: i = 80, minContentW
|
|
|
539
539
|
}
|
|
540
540
|
_ = h;
|
|
541
541
|
}
|
|
542
|
-
if (r === "\n") n === "block" && (h =
|
|
542
|
+
if (r === "\n") n === "block" && (h = z(e, h, t.length)), d = h + t.length + c, f = void 0;
|
|
543
543
|
else {
|
|
544
544
|
if (r === " " && p && p !== " " && p !== "\n" && p !== " ") {
|
|
545
545
|
let t = e[h + 1];
|
|
@@ -566,7 +566,7 @@ function be(e, t, n = "flow", { indentAtStart: r, lineWidth: i = 80, minContentW
|
|
|
566
566
|
}
|
|
567
567
|
return v;
|
|
568
568
|
}
|
|
569
|
-
function
|
|
569
|
+
function z(e, t, n) {
|
|
570
570
|
let r = t, i = t + 1, a = e[i];
|
|
571
571
|
for (; a === " " || a === " ";) if (t < i + n) a = e[++t];
|
|
572
572
|
else {
|
|
@@ -579,12 +579,12 @@ function R(e, t, n) {
|
|
|
579
579
|
}
|
|
580
580
|
//#endregion
|
|
581
581
|
//#region node_modules/yaml/browser/dist/stringify/stringifyString.js
|
|
582
|
-
var
|
|
582
|
+
var B = (e, t) => ({
|
|
583
583
|
indentAtStart: t ? e.indent.length : e.indentAtStart,
|
|
584
584
|
lineWidth: e.options.lineWidth,
|
|
585
585
|
minContentWidth: e.options.minContentWidth
|
|
586
|
-
}),
|
|
587
|
-
function
|
|
586
|
+
}), be = (e) => /^(%|---|\.\.\.)/m.test(e);
|
|
587
|
+
function xe(e, t, n) {
|
|
588
588
|
if (!t || t < 0) return !1;
|
|
589
589
|
let r = t - n, i = e.length;
|
|
590
590
|
if (i <= r) return !1;
|
|
@@ -594,10 +594,10 @@ function Se(e, t, n) {
|
|
|
594
594
|
}
|
|
595
595
|
return !0;
|
|
596
596
|
}
|
|
597
|
-
function
|
|
597
|
+
function Se(e, t) {
|
|
598
598
|
let n = JSON.stringify(e);
|
|
599
599
|
if (t.options.doubleQuotedAsJSON) return n;
|
|
600
|
-
let { implicitKey: r } = t, i = t.options.doubleQuotedMinMultiLineLength, a = t.indent || (
|
|
600
|
+
let { implicitKey: r } = t, i = t.options.doubleQuotedMinMultiLineLength, a = t.indent || (be(e) ? " " : ""), o = "", s = 0;
|
|
601
601
|
for (let e = 0, t = n[e]; t; t = n[++e]) if (t === " " && n[e + 1] === "\\" && n[e + 2] === "n" && (o += n.slice(s, e) + "\\ ", e += 1, s = e, t = "\\"), t === "\\") switch (n[e + 1]) {
|
|
602
602
|
case "u":
|
|
603
603
|
{
|
|
@@ -642,32 +642,32 @@ function Ce(e, t) {
|
|
|
642
642
|
break;
|
|
643
643
|
default: e += 1;
|
|
644
644
|
}
|
|
645
|
-
return o = s ? o + n.slice(s) : n, r ? o :
|
|
645
|
+
return o = s ? o + n.slice(s) : n, r ? o : ye(o, a, ve, B(t, !1));
|
|
646
646
|
}
|
|
647
|
-
function
|
|
648
|
-
if (t.options.singleQuote === !1 || t.implicitKey && e.includes("\n") || /[ \t]\n|\n[ \t]/.test(e)) return
|
|
649
|
-
let n = t.indent || (
|
|
650
|
-
return t.implicitKey ? r :
|
|
647
|
+
function Ce(e, t) {
|
|
648
|
+
if (t.options.singleQuote === !1 || t.implicitKey && e.includes("\n") || /[ \t]\n|\n[ \t]/.test(e)) return Se(e, t);
|
|
649
|
+
let n = t.indent || (be(e) ? " " : ""), r = "'" + e.replace(/'/g, "''").replace(/\n+/g, `$&\n${n}`) + "'";
|
|
650
|
+
return t.implicitKey ? r : ye(r, n, ge, B(t, !1));
|
|
651
651
|
}
|
|
652
|
-
function
|
|
652
|
+
function we(e, t) {
|
|
653
653
|
let { singleQuote: n } = t.options, r;
|
|
654
|
-
if (n === !1) r =
|
|
654
|
+
if (n === !1) r = Se;
|
|
655
655
|
else {
|
|
656
656
|
let t = e.includes("\""), i = e.includes("'");
|
|
657
|
-
r = t && !i ?
|
|
657
|
+
r = t && !i ? Ce : i && !t ? Se : n ? Ce : Se;
|
|
658
658
|
}
|
|
659
659
|
return r(e, t);
|
|
660
660
|
}
|
|
661
|
-
var
|
|
661
|
+
var Te;
|
|
662
662
|
try {
|
|
663
|
-
|
|
663
|
+
Te = /* @__PURE__ */ RegExp("(^|(?<!\n))\n+(?!\n|$)", "g");
|
|
664
664
|
} catch {
|
|
665
|
-
|
|
665
|
+
Te = /\n+(?!\n|$)/g;
|
|
666
666
|
}
|
|
667
|
-
function
|
|
667
|
+
function Ee({ comment: e, type: t, value: n }, r, i, a) {
|
|
668
668
|
let { blockQuote: o, commentString: s, lineWidth: c } = r.options;
|
|
669
|
-
if (!o || /\n[\t ]+$/.test(n)) return
|
|
670
|
-
let l = r.indent || (r.forceBlockIndent ||
|
|
669
|
+
if (!o || /\n[\t ]+$/.test(n)) return we(n, r);
|
|
670
|
+
let l = r.indent || (r.forceBlockIndent || be(n) ? " " : ""), u = o === "literal" ? !0 : o === "folded" || t === F.BLOCK_FOLDED ? !1 : t === F.BLOCK_LITERAL || !xe(n, c, l.length);
|
|
671
671
|
if (!n) return u ? "|\n" : ">\n";
|
|
672
672
|
let d, f;
|
|
673
673
|
for (f = n.length; f > 0; --f) {
|
|
@@ -675,7 +675,7 @@ function De({ comment: e, type: t, value: n }, r, i, a) {
|
|
|
675
675
|
if (e !== "\n" && e !== " " && e !== " ") break;
|
|
676
676
|
}
|
|
677
677
|
let p = n.substring(f), m = p.indexOf("\n");
|
|
678
|
-
m === -1 ? d = "-" : n === p || m !== p.length - 1 ? (d = "+", a && a()) : d = "", p &&= (n = n.slice(0, -p.length), p[p.length - 1] === "\n" && (p = p.slice(0, -1)), p.replace(
|
|
678
|
+
m === -1 ? d = "-" : n === p || m !== p.length - 1 ? (d = "+", a && a()) : d = "", p &&= (n = n.slice(0, -p.length), p[p.length - 1] === "\n" && (p = p.slice(0, -1)), p.replace(Te, `$&${l}`));
|
|
679
679
|
let h = !1, g, _ = -1;
|
|
680
680
|
for (g = 0; g < n.length; ++g) {
|
|
681
681
|
let e = n[g];
|
|
@@ -687,41 +687,41 @@ function De({ comment: e, type: t, value: n }, r, i, a) {
|
|
|
687
687
|
v &&= (n = n.substring(v.length), v.replace(/\n+/g, `$&${l}`));
|
|
688
688
|
let y = (h ? l ? "2" : "1" : "") + d;
|
|
689
689
|
if (e && (y += " " + s(e.replace(/ ?[\r\n]+/g, " ")), i && i()), !u) {
|
|
690
|
-
let e = n.replace(/\n+/g, "\n$&").replace(/(?:^|\n)([\t ].*)(?:([\n\t ]*)\n(?![\n\t ]))?/g, "$1$2").replace(/\n+/g, `$&${l}`), i = !1, a =
|
|
691
|
-
o !== "folded" && t !==
|
|
690
|
+
let e = n.replace(/\n+/g, "\n$&").replace(/(?:^|\n)([\t ].*)(?:([\n\t ]*)\n(?![\n\t ]))?/g, "$1$2").replace(/\n+/g, `$&${l}`), i = !1, a = B(r, !0);
|
|
691
|
+
o !== "folded" && t !== F.BLOCK_FOLDED && (a.onOverflow = () => {
|
|
692
692
|
i = !0;
|
|
693
693
|
});
|
|
694
|
-
let s =
|
|
694
|
+
let s = ye(`${v}${e}${p}`, l, _e, a);
|
|
695
695
|
if (!i) return `>${y}\n${l}${s}`;
|
|
696
696
|
}
|
|
697
697
|
return n = n.replace(/\n+/g, `$&${l}`), `|${y}\n${l}${v}${n}${p}`;
|
|
698
698
|
}
|
|
699
|
-
function
|
|
699
|
+
function De(e, t, n, r) {
|
|
700
700
|
let { type: i, value: a } = e, { actualString: o, implicitKey: s, indent: c, indentStep: l, inFlow: u } = t;
|
|
701
|
-
if (s && a.includes("\n") || u && /[[\]{},]/.test(a)) return
|
|
702
|
-
if (/^[\n\t ,[\]{}#&*!|>'"%@`]|^[?-]$|^[?-][ \t]|[\n:][ \t]|[ \t]\n|[\n\t ]#|[\n\t :]$/.test(a)) return s || u || !a.includes("\n") ?
|
|
703
|
-
if (!s && !u && i !==
|
|
704
|
-
if (
|
|
705
|
-
if (c === "") return t.forceBlockIndent = !0,
|
|
706
|
-
if (s && c === l) return
|
|
701
|
+
if (s && a.includes("\n") || u && /[[\]{},]/.test(a)) return we(a, t);
|
|
702
|
+
if (/^[\n\t ,[\]{}#&*!|>'"%@`]|^[?-]$|^[?-][ \t]|[\n:][ \t]|[ \t]\n|[\n\t ]#|[\n\t :]$/.test(a)) return s || u || !a.includes("\n") ? we(a, t) : Ee(e, t, n, r);
|
|
703
|
+
if (!s && !u && i !== F.PLAIN && a.includes("\n")) return Ee(e, t, n, r);
|
|
704
|
+
if (be(a)) {
|
|
705
|
+
if (c === "") return t.forceBlockIndent = !0, Ee(e, t, n, r);
|
|
706
|
+
if (s && c === l) return we(a, t);
|
|
707
707
|
}
|
|
708
708
|
let d = a.replace(/\n+/g, `$&\n${c}`);
|
|
709
709
|
if (o) {
|
|
710
710
|
let e = (e) => e.default && e.tag !== "tag:yaml.org,2002:str" && e.test?.test(d), { compat: n, tags: r } = t.doc.schema;
|
|
711
|
-
if (r.some(e) || n?.some(e)) return
|
|
711
|
+
if (r.some(e) || n?.some(e)) return we(a, t);
|
|
712
712
|
}
|
|
713
|
-
return s ? d :
|
|
713
|
+
return s ? d : ye(d, c, ge, B(t, !1));
|
|
714
714
|
}
|
|
715
|
-
function
|
|
715
|
+
function Oe(e, t, n, r) {
|
|
716
716
|
let { implicitKey: i, inFlow: a } = t, o = typeof e.value == "string" ? e : Object.assign({}, e, { value: String(e.value) }), { type: s } = e;
|
|
717
|
-
s !==
|
|
717
|
+
s !== F.QUOTE_DOUBLE && /[\x00-\x08\x0b-\x1f\x7f-\x9f\u{D800}-\u{DFFF}]/u.test(o.value) && (s = F.QUOTE_DOUBLE);
|
|
718
718
|
let c = (e) => {
|
|
719
719
|
switch (e) {
|
|
720
|
-
case
|
|
721
|
-
case
|
|
722
|
-
case
|
|
723
|
-
case
|
|
724
|
-
case
|
|
720
|
+
case F.BLOCK_FOLDED:
|
|
721
|
+
case F.BLOCK_LITERAL: return i || a ? we(o.value, t) : Ee(o, t, n, r);
|
|
722
|
+
case F.QUOTE_DOUBLE: return Se(o.value, t);
|
|
723
|
+
case F.QUOTE_SINGLE: return Ce(o.value, t);
|
|
724
|
+
case F.PLAIN: return De(o, t, n, r);
|
|
725
725
|
default: return null;
|
|
726
726
|
}
|
|
727
727
|
}, l = c(s);
|
|
@@ -733,10 +733,10 @@ function ke(e, t, n, r) {
|
|
|
733
733
|
}
|
|
734
734
|
//#endregion
|
|
735
735
|
//#region node_modules/yaml/browser/dist/stringify/stringify.js
|
|
736
|
-
function
|
|
736
|
+
function ke(e, t) {
|
|
737
737
|
let n = Object.assign({
|
|
738
738
|
blockQuote: !0,
|
|
739
|
-
commentString:
|
|
739
|
+
commentString: he,
|
|
740
740
|
defaultKeyType: null,
|
|
741
741
|
defaultStringType: "PLAIN",
|
|
742
742
|
directives: null,
|
|
@@ -773,7 +773,7 @@ function Ae(e, t) {
|
|
|
773
773
|
options: n
|
|
774
774
|
};
|
|
775
775
|
}
|
|
776
|
-
function
|
|
776
|
+
function Ae(e, t) {
|
|
777
777
|
if (t.tag) {
|
|
778
778
|
let n = e.filter((e) => e.tag === t.tag);
|
|
779
779
|
if (n.length > 0) return n.find((e) => e.format === t.format) ?? n[0];
|
|
@@ -794,14 +794,14 @@ function je(e, t) {
|
|
|
794
794
|
}
|
|
795
795
|
return n;
|
|
796
796
|
}
|
|
797
|
-
function
|
|
797
|
+
function je(e, t, { anchors: n, doc: r }) {
|
|
798
798
|
if (!r.directives) return "";
|
|
799
799
|
let i = [], a = (_(e) || y(e)) && e.anchor;
|
|
800
800
|
a && j(a) && (n.add(a), i.push(`&${a}`));
|
|
801
801
|
let o = e.tag ?? (t.default ? null : t.tag);
|
|
802
802
|
return o && i.push(r.directives.tagString(o)), i.join(" ");
|
|
803
803
|
}
|
|
804
|
-
function
|
|
804
|
+
function Me(e, t, n, r) {
|
|
805
805
|
if (g(e)) return e.toString(t, n, r);
|
|
806
806
|
if (p(e)) {
|
|
807
807
|
if (t.doc.directives) return e.toString(t);
|
|
@@ -809,42 +809,42 @@ function Ne(e, t, n, r) {
|
|
|
809
809
|
t.resolvedAliases ? t.resolvedAliases.add(e) : t.resolvedAliases = /* @__PURE__ */ new Set([e]), e = e.resolve(t.doc);
|
|
810
810
|
}
|
|
811
811
|
let i, a = b(e) ? e : t.doc.createNode(e, { onTagObj: (e) => i = e });
|
|
812
|
-
i ??=
|
|
813
|
-
let o =
|
|
812
|
+
i ??= Ae(t.doc.schema.tags, a);
|
|
813
|
+
let o = je(a, i, t);
|
|
814
814
|
o.length > 0 && (t.indentAtStart = (t.indentAtStart ?? 0) + o.length + 1);
|
|
815
|
-
let s = typeof i.stringify == "function" ? i.stringify(a, t, n, r) : _(a) ?
|
|
815
|
+
let s = typeof i.stringify == "function" ? i.stringify(a, t, n, r) : _(a) ? Oe(a, t, n, r) : a.toString(t, n, r);
|
|
816
816
|
return o ? _(a) || s[0] === "{" || s[0] === "[" ? `${o} ${s}` : `${o}\n${t.indent}${s}` : s;
|
|
817
817
|
}
|
|
818
818
|
//#endregion
|
|
819
819
|
//#region node_modules/yaml/browser/dist/stringify/stringifyPair.js
|
|
820
|
-
function
|
|
820
|
+
function Ne({ key: e, value: t }, n, r, i) {
|
|
821
821
|
let { allNullValues: a, doc: o, indent: s, indentStep: c, options: { commentString: l, indentSeq: u, simpleKeys: d } } = n, f = b(e) && e.comment || null;
|
|
822
822
|
if (d) {
|
|
823
823
|
if (f) throw Error("With simple keys, key nodes cannot have comments");
|
|
824
824
|
if (y(e) || !b(e) && typeof e == "object") throw Error("With simple keys, collection cannot be used as a key value");
|
|
825
825
|
}
|
|
826
|
-
let p = !d && (!e || f && t == null && !n.inFlow || y(e) || (_(e) ? e.type ===
|
|
826
|
+
let p = !d && (!e || f && t == null && !n.inFlow || y(e) || (_(e) ? e.type === F.BLOCK_FOLDED || e.type === F.BLOCK_LITERAL : typeof e == "object"));
|
|
827
827
|
n = Object.assign({}, n, {
|
|
828
828
|
allNullValues: !1,
|
|
829
829
|
implicitKey: !p && (d || !a),
|
|
830
830
|
indent: s + c
|
|
831
831
|
});
|
|
832
|
-
let m = !1, h = !1, g =
|
|
832
|
+
let m = !1, h = !1, g = Me(e, n, () => m = !0, () => h = !0);
|
|
833
833
|
if (!p && !n.inFlow && g.length > 1024) {
|
|
834
834
|
if (d) throw Error("With simple keys, single line scalar must not span more than 1024 characters");
|
|
835
835
|
p = !0;
|
|
836
836
|
}
|
|
837
837
|
if (n.inFlow) {
|
|
838
838
|
if (a || t == null) return m && r && r(), g === "" ? "?" : p ? `? ${g}` : g;
|
|
839
|
-
} else if (a && !d || t == null && p) return g = `? ${g}`, f && !m ? g +=
|
|
840
|
-
m && (f = null), p ? (f && (g +=
|
|
839
|
+
} else if (a && !d || t == null && p) return g = `? ${g}`, f && !m ? g += R(g, n.indent, l(f)) : h && i && i(), g;
|
|
840
|
+
m && (f = null), p ? (f && (g += R(g, n.indent, l(f))), g = `? ${g}\n${s}:`) : (g = `${g}:`, f && (g += R(g, n.indent, l(f))));
|
|
841
841
|
let x, S, C;
|
|
842
842
|
b(t) ? (x = !!t.spaceBefore, S = t.commentBefore, C = t.comment) : (x = !1, S = null, C = null, t && typeof t == "object" && (t = o.createNode(t))), n.implicitKey = !1, !p && !f && _(t) && (n.indentAtStart = g.length + 1), h = !1, !u && c.length >= 2 && !n.inFlow && !p && v(t) && !t.flow && !t.tag && !t.anchor && (n.indent = n.indent.substring(2));
|
|
843
|
-
let w = !1, T =
|
|
843
|
+
let w = !1, T = Me(t, n, () => w = !0, () => h = !0), E = " ";
|
|
844
844
|
if (f || x || S) {
|
|
845
845
|
if (E = x ? "\n" : "", S) {
|
|
846
846
|
let e = l(S);
|
|
847
|
-
E += `\n${
|
|
847
|
+
E += `\n${L(e, n.indent)}`;
|
|
848
848
|
}
|
|
849
849
|
T === "" && !n.inFlow ? E === "\n" && C && (E = "\n\n") : E += `\n${n.indent}`;
|
|
850
850
|
} else if (!p && y(t)) {
|
|
@@ -858,23 +858,23 @@ function Pe({ key: e, value: t }, n, r, i) {
|
|
|
858
858
|
t || (E = `\n${n.indent}`);
|
|
859
859
|
}
|
|
860
860
|
} else (T === "" || T[0] === "\n") && (E = "");
|
|
861
|
-
return g += E + T, n.inFlow ? w && r && r() : C && !w ? g +=
|
|
861
|
+
return g += E + T, n.inFlow ? w && r && r() : C && !w ? g += R(g, n.indent, l(C)) : h && i && i(), g;
|
|
862
862
|
}
|
|
863
863
|
//#endregion
|
|
864
864
|
//#region node_modules/yaml/browser/dist/log.js
|
|
865
|
-
function
|
|
865
|
+
function Pe(e, t) {
|
|
866
866
|
(e === "debug" || e === "warn") && console.warn(t);
|
|
867
867
|
}
|
|
868
868
|
//#endregion
|
|
869
869
|
//#region node_modules/yaml/browser/dist/schema/yaml-1.1/merge.js
|
|
870
|
-
var
|
|
871
|
-
identify: (e) => e ===
|
|
870
|
+
var Fe = "<<", Ie = {
|
|
871
|
+
identify: (e) => e === Fe || typeof e == "symbol" && e.description === Fe,
|
|
872
872
|
default: "key",
|
|
873
873
|
tag: "tag:yaml.org,2002:merge",
|
|
874
874
|
test: /^<<$/,
|
|
875
|
-
resolve: () => Object.assign(new
|
|
876
|
-
stringify: () =>
|
|
877
|
-
}, Le = (e, t) => (
|
|
875
|
+
resolve: () => Object.assign(new F(Symbol(Fe)), { addToJSMap: Re }),
|
|
876
|
+
stringify: () => Fe
|
|
877
|
+
}, Le = (e, t) => (Ie.identify(t) || _(t) && (!t.type || t.type === F.PLAIN) && Ie.identify(t.value)) && e?.doc.schema.tags.some((e) => e.tag === Ie.tag && e.default);
|
|
878
878
|
function Re(e, t, n) {
|
|
879
879
|
let r = Be(e, n);
|
|
880
880
|
if (v(r)) for (let n of r.items) ze(e, t, n);
|
|
@@ -902,11 +902,11 @@ function Ve(e, t, { key: n, value: r }) {
|
|
|
902
902
|
if (b(n) && n.addToJSMap) n.addToJSMap(e, t, r);
|
|
903
903
|
else if (Le(e, n)) Re(e, t, r);
|
|
904
904
|
else {
|
|
905
|
-
let i =
|
|
906
|
-
if (t instanceof Map) t.set(i,
|
|
905
|
+
let i = N(n, "", e);
|
|
906
|
+
if (t instanceof Map) t.set(i, N(r, i, e));
|
|
907
907
|
else if (t instanceof Set) t.add(i);
|
|
908
908
|
else {
|
|
909
|
-
let a = He(n, i, e), o =
|
|
909
|
+
let a = He(n, i, e), o = N(r, a, e);
|
|
910
910
|
a in t ? Object.defineProperty(t, a, {
|
|
911
911
|
value: o,
|
|
912
912
|
writable: !0,
|
|
@@ -921,14 +921,14 @@ function He(e, t, n) {
|
|
|
921
921
|
if (t === null) return "";
|
|
922
922
|
if (typeof t != "object") return String(t);
|
|
923
923
|
if (b(e) && n?.doc) {
|
|
924
|
-
let t =
|
|
924
|
+
let t = ke(n.doc, {});
|
|
925
925
|
t.anchors = /* @__PURE__ */ new Set();
|
|
926
926
|
for (let e of n.anchors.keys()) t.anchors.add(e.anchor);
|
|
927
927
|
t.inFlow = !0, t.inStringifyKey = !0;
|
|
928
928
|
let r = e.toString(t);
|
|
929
929
|
if (!n.mapKeyWarned) {
|
|
930
930
|
let e = JSON.stringify(r);
|
|
931
|
-
e.length > 40 && (e = e.substring(0, 36) + "...\""),
|
|
931
|
+
e.length > 40 && (e = e.substring(0, 36) + "...\""), Pe(n.doc.options.logLevel, `Keys with collection values will be stringified due to JS Object restrictions: ${e}. Set mapAsMap: true to use object keys.`), n.mapKeyWarned = !0;
|
|
932
932
|
}
|
|
933
933
|
return r;
|
|
934
934
|
}
|
|
@@ -937,7 +937,7 @@ function He(e, t, n) {
|
|
|
937
937
|
//#endregion
|
|
938
938
|
//#region node_modules/yaml/browser/dist/nodes/Pair.js
|
|
939
939
|
function Ue(e, t, n) {
|
|
940
|
-
return new V(
|
|
940
|
+
return new V(fe(e, void 0, n), fe(t, void 0, n));
|
|
941
941
|
}
|
|
942
942
|
var V = class e {
|
|
943
943
|
constructor(e, t = null) {
|
|
@@ -951,7 +951,7 @@ var V = class e {
|
|
|
951
951
|
return Ve(t, t?.mapAsMap ? /* @__PURE__ */ new Map() : {}, this);
|
|
952
952
|
}
|
|
953
953
|
toString(e, t, n) {
|
|
954
|
-
return e?.doc ?
|
|
954
|
+
return e?.doc ? Ne(this, e, t, n) : JSON.stringify(this);
|
|
955
955
|
}
|
|
956
956
|
};
|
|
957
957
|
//#endregion
|
|
@@ -972,8 +972,8 @@ function Ge({ comment: e, items: t }, n, { blockItemPrefix: r, flowChars: i, ite
|
|
|
972
972
|
e && (!d && e.spaceBefore && f.push(""), qe(n, f, e.commentBefore, d));
|
|
973
973
|
}
|
|
974
974
|
d = !1;
|
|
975
|
-
let s =
|
|
976
|
-
o && (s +=
|
|
975
|
+
let s = Me(i, u, () => o = null, () => d = !0);
|
|
976
|
+
o && (s += R(s, a, l(o))), d && o && (d = !1), f.push(r + s);
|
|
977
977
|
}
|
|
978
978
|
let p;
|
|
979
979
|
if (f.length === 0) p = i.start + i.end;
|
|
@@ -984,7 +984,7 @@ function Ge({ comment: e, items: t }, n, { blockItemPrefix: r, flowChars: i, ite
|
|
|
984
984
|
p += t ? `\n${c}${t}` : "\n";
|
|
985
985
|
}
|
|
986
986
|
}
|
|
987
|
-
return e ? (p += "\n" +
|
|
987
|
+
return e ? (p += "\n" + L(l(e), c), s && s()) : d && o && o(), p;
|
|
988
988
|
}
|
|
989
989
|
function Ke({ items: e }, t, { flowChars: n, itemIndent: r }) {
|
|
990
990
|
let { indent: i, indentStep: a, flowCollectionPadding: o, options: { commentString: s } } = t;
|
|
@@ -1004,8 +1004,8 @@ function Ke({ items: e }, t, { flowChars: n, itemIndent: r }) {
|
|
|
1004
1004
|
n ? (n.comment && (a = n.comment), n.commentBefore && (l = !0)) : i.value == null && e?.comment && (a = e.comment);
|
|
1005
1005
|
}
|
|
1006
1006
|
a && (l = !0);
|
|
1007
|
-
let o =
|
|
1008
|
-
l ||= d.length > u || o.includes("\n"), n < e.length - 1 ? o += "," : t.options.trailingComma && (t.options.lineWidth > 0 && (l ||= d.reduce((e, t) => e + t.length + 2, 2) + (o.length + 2) > t.options.lineWidth), l && (o += ",")), a && (o +=
|
|
1007
|
+
let o = Me(i, c, () => a = null);
|
|
1008
|
+
l ||= d.length > u || o.includes("\n"), n < e.length - 1 ? o += "," : t.options.trailingComma && (t.options.lineWidth > 0 && (l ||= d.reduce((e, t) => e + t.length + 2, 2) + (o.length + 2) > t.options.lineWidth), l && (o += ",")), a && (o += R(o, r, s(a))), d.push(o), u = d.length;
|
|
1009
1009
|
}
|
|
1010
1010
|
let { start: f, end: p } = n;
|
|
1011
1011
|
if (d.length === 0) return f + p;
|
|
@@ -1022,7 +1022,7 @@ function Ke({ items: e }, t, { flowChars: n, itemIndent: r }) {
|
|
|
1022
1022
|
}
|
|
1023
1023
|
function qe({ indent: e, options: { commentString: t } }, n, r, i) {
|
|
1024
1024
|
if (r && i && (r = r.replace(/^\n+/, "")), r) {
|
|
1025
|
-
let i =
|
|
1025
|
+
let i = L(t(r), e);
|
|
1026
1026
|
n.push(i.trimStart());
|
|
1027
1027
|
}
|
|
1028
1028
|
}
|
|
@@ -1032,7 +1032,7 @@ function Je(e, t) {
|
|
|
1032
1032
|
let n = _(t) ? t.value : t;
|
|
1033
1033
|
for (let r of e) if (g(r) && (r.key === t || r.key === n || _(r.key) && r.key.value === n)) return r;
|
|
1034
1034
|
}
|
|
1035
|
-
var H = class extends
|
|
1035
|
+
var H = class extends I {
|
|
1036
1036
|
static get tagName() {
|
|
1037
1037
|
return "tag:yaml.org,2002:map";
|
|
1038
1038
|
}
|
|
@@ -1055,7 +1055,7 @@ var H = class extends F {
|
|
|
1055
1055
|
let r = Je(this.items, n.key), i = this.schema?.sortMapEntries;
|
|
1056
1056
|
if (r) {
|
|
1057
1057
|
if (!t) throw Error(`Key ${n.key} already set`);
|
|
1058
|
-
_(r.value) &&
|
|
1058
|
+
_(r.value) && le(n.value) ? r.value.value = n.value : r.value = n.value;
|
|
1059
1059
|
} else if (i) {
|
|
1060
1060
|
let e = this.items.findIndex((e) => i(n, e) < 0);
|
|
1061
1061
|
e === -1 ? this.items.push(n) : this.items.splice(e, 0, n);
|
|
@@ -1104,7 +1104,7 @@ var H = class extends F {
|
|
|
1104
1104
|
return h(e) || t("Expected a mapping for this tag"), e;
|
|
1105
1105
|
},
|
|
1106
1106
|
createNode: (e, t, n) => H.from(e, t, n)
|
|
1107
|
-
}, Xe = class extends
|
|
1107
|
+
}, Xe = class extends I {
|
|
1108
1108
|
static get tagName() {
|
|
1109
1109
|
return "tag:yaml.org,2002:seq";
|
|
1110
1110
|
}
|
|
@@ -1132,13 +1132,13 @@ var H = class extends F {
|
|
|
1132
1132
|
let n = Ze(e);
|
|
1133
1133
|
if (typeof n != "number") throw Error(`Expected a valid index, not ${e}.`);
|
|
1134
1134
|
let r = this.items[n];
|
|
1135
|
-
_(r) &&
|
|
1135
|
+
_(r) && le(t) ? r.value = t : this.items[n] = t;
|
|
1136
1136
|
}
|
|
1137
1137
|
toJSON(e, t) {
|
|
1138
1138
|
let n = [];
|
|
1139
1139
|
t?.onCreate && t.onCreate(n);
|
|
1140
1140
|
let r = 0;
|
|
1141
|
-
for (let e of this.items) n.push(
|
|
1141
|
+
for (let e of this.items) n.push(N(e, String(r++), t));
|
|
1142
1142
|
return n;
|
|
1143
1143
|
}
|
|
1144
1144
|
toString(e, t, n) {
|
|
@@ -1162,7 +1162,7 @@ var H = class extends F {
|
|
|
1162
1162
|
let n = t instanceof Set ? a : String(e++);
|
|
1163
1163
|
a = r.call(t, n, a);
|
|
1164
1164
|
}
|
|
1165
|
-
i.items.push(
|
|
1165
|
+
i.items.push(fe(a, void 0, n));
|
|
1166
1166
|
}
|
|
1167
1167
|
}
|
|
1168
1168
|
return i;
|
|
@@ -1189,22 +1189,22 @@ var Qe = {
|
|
|
1189
1189
|
tag: "tag:yaml.org,2002:str",
|
|
1190
1190
|
resolve: (e) => e,
|
|
1191
1191
|
stringify(e, t, n, r) {
|
|
1192
|
-
return t = Object.assign({ actualString: !0 }, t),
|
|
1192
|
+
return t = Object.assign({ actualString: !0 }, t), Oe(e, t, n, r);
|
|
1193
1193
|
}
|
|
1194
1194
|
}, et = {
|
|
1195
1195
|
identify: (e) => e == null,
|
|
1196
|
-
createNode: () => new
|
|
1196
|
+
createNode: () => new F(null),
|
|
1197
1197
|
default: !0,
|
|
1198
1198
|
tag: "tag:yaml.org,2002:null",
|
|
1199
1199
|
test: /^(?:~|[Nn]ull|NULL)?$/,
|
|
1200
|
-
resolve: () => new
|
|
1200
|
+
resolve: () => new F(null),
|
|
1201
1201
|
stringify: ({ source: e }, t) => typeof e == "string" && et.test.test(e) ? e : t.options.nullStr
|
|
1202
1202
|
}, tt = {
|
|
1203
1203
|
identify: (e) => typeof e == "boolean",
|
|
1204
1204
|
default: !0,
|
|
1205
1205
|
tag: "tag:yaml.org,2002:bool",
|
|
1206
1206
|
test: /^(?:[Tt]rue|TRUE|[Ff]alse|FALSE)$/,
|
|
1207
|
-
resolve: (e) => new
|
|
1207
|
+
resolve: (e) => new F(e[0] === "t" || e[0] === "T"),
|
|
1208
1208
|
stringify({ source: e, value: t }, n) {
|
|
1209
1209
|
return e && tt.test.test(e) && t === (e[0] === "t" || e[0] === "T") ? e : t ? n.options.trueStr : n.options.falseStr;
|
|
1210
1210
|
}
|
|
@@ -1250,7 +1250,7 @@ var nt = {
|
|
|
1250
1250
|
tag: "tag:yaml.org,2002:float",
|
|
1251
1251
|
test: /^[-+]?(?:\.[0-9]+|[0-9]+\.[0-9]*)$/,
|
|
1252
1252
|
resolve(e) {
|
|
1253
|
-
let t = new
|
|
1253
|
+
let t = new F(parseFloat(e)), n = e.indexOf(".");
|
|
1254
1254
|
return n !== -1 && e[e.length - 1] === "0" && (t.minFractionDigits = e.length - n - 1), t;
|
|
1255
1255
|
},
|
|
1256
1256
|
stringify: U
|
|
@@ -1310,7 +1310,7 @@ var pt = ({ value: e }) => JSON.stringify(e), mt = [
|
|
|
1310
1310
|
},
|
|
1311
1311
|
{
|
|
1312
1312
|
identify: (e) => e == null,
|
|
1313
|
-
createNode: () => new
|
|
1313
|
+
createNode: () => new F(null),
|
|
1314
1314
|
default: !0,
|
|
1315
1315
|
tag: "tag:yaml.org,2002:null",
|
|
1316
1316
|
test: /^null$/,
|
|
@@ -1368,12 +1368,12 @@ var pt = ({ value: e }) => JSON.stringify(e), mt = [
|
|
|
1368
1368
|
for (let t = 0; t < o.length; ++t) e += String.fromCharCode(o[t]);
|
|
1369
1369
|
s = btoa(e);
|
|
1370
1370
|
} else throw Error("This environment does not support writing binary tags; either Buffer or btoa is required");
|
|
1371
|
-
if (t ??=
|
|
1371
|
+
if (t ??= F.BLOCK_LITERAL, t !== F.QUOTE_DOUBLE) {
|
|
1372
1372
|
let e = Math.max(r.options.lineWidth - r.indent.length, r.options.minContentWidth), n = Math.ceil(s.length / e), i = Array(n);
|
|
1373
1373
|
for (let t = 0, r = 0; t < n; ++t, r += e) i[t] = s.substr(r, e);
|
|
1374
|
-
s = i.join(t ===
|
|
1374
|
+
s = i.join(t === F.BLOCK_LITERAL ? "\n" : " ");
|
|
1375
1375
|
}
|
|
1376
|
-
return
|
|
1376
|
+
return Oe({
|
|
1377
1377
|
comment: e,
|
|
1378
1378
|
type: t,
|
|
1379
1379
|
value: s
|
|
@@ -1388,7 +1388,7 @@ function _t(e, t) {
|
|
|
1388
1388
|
if (!g(r)) {
|
|
1389
1389
|
if (h(r)) {
|
|
1390
1390
|
r.items.length > 1 && t("Each pair must have its own sequence indicator");
|
|
1391
|
-
let e = r.items[0] || new V(new
|
|
1391
|
+
let e = r.items[0] || new V(new F(null));
|
|
1392
1392
|
if (r.commentBefore && (e.key.commentBefore = e.key.commentBefore ? `${r.commentBefore}\n${e.key.commentBefore}` : r.commentBefore), r.comment) {
|
|
1393
1393
|
let t = e.value ?? e.key;
|
|
1394
1394
|
t.comment = t.comment ? `${r.comment}\n${t.comment}` : r.comment;
|
|
@@ -1436,7 +1436,7 @@ var yt = {
|
|
|
1436
1436
|
t?.onCreate && t.onCreate(n);
|
|
1437
1437
|
for (let e of this.items) {
|
|
1438
1438
|
let r, i;
|
|
1439
|
-
if (g(e) ? (r =
|
|
1439
|
+
if (g(e) ? (r = N(e.key, "", t), i = N(e.value, r, t)) : r = N(e, "", t), n.has(r)) throw Error("Ordered maps must not include duplicate keys");
|
|
1440
1440
|
n.set(r, i);
|
|
1441
1441
|
}
|
|
1442
1442
|
return n;
|
|
@@ -1470,14 +1470,14 @@ var Ct = {
|
|
|
1470
1470
|
default: !0,
|
|
1471
1471
|
tag: "tag:yaml.org,2002:bool",
|
|
1472
1472
|
test: /^(?:Y|y|[Yy]es|YES|[Tt]rue|TRUE|[Oo]n|ON)$/,
|
|
1473
|
-
resolve: () => new
|
|
1473
|
+
resolve: () => new F(!0),
|
|
1474
1474
|
stringify: St
|
|
1475
1475
|
}, wt = {
|
|
1476
1476
|
identify: (e) => e === !1,
|
|
1477
1477
|
default: !0,
|
|
1478
1478
|
tag: "tag:yaml.org,2002:bool",
|
|
1479
1479
|
test: /^(?:N|n|[Nn]o|NO|[Ff]alse|FALSE|[Oo]ff|OFF)$/,
|
|
1480
|
-
resolve: () => new
|
|
1480
|
+
resolve: () => new F(!1),
|
|
1481
1481
|
stringify: St
|
|
1482
1482
|
}, Tt = {
|
|
1483
1483
|
identify: (e) => typeof e == "number",
|
|
@@ -1503,7 +1503,7 @@ var Ct = {
|
|
|
1503
1503
|
tag: "tag:yaml.org,2002:float",
|
|
1504
1504
|
test: /^[-+]?(?:[0-9][0-9_]*)?\.[0-9_]*$/,
|
|
1505
1505
|
resolve(e) {
|
|
1506
|
-
let t = new
|
|
1506
|
+
let t = new F(parseFloat(e.replace(/_/g, ""))), n = e.indexOf(".");
|
|
1507
1507
|
if (n !== -1) {
|
|
1508
1508
|
let r = e.substring(n + 1).replace(/_/g, "");
|
|
1509
1509
|
r[r.length - 1] === "0" && (t.minFractionDigits = r.length);
|
|
@@ -1678,7 +1678,7 @@ var zt = {
|
|
|
1678
1678
|
Et,
|
|
1679
1679
|
Dt,
|
|
1680
1680
|
gt,
|
|
1681
|
-
|
|
1681
|
+
Ie,
|
|
1682
1682
|
xt,
|
|
1683
1683
|
yt,
|
|
1684
1684
|
It,
|
|
@@ -1707,7 +1707,7 @@ var zt = {
|
|
|
1707
1707
|
intOct: ct,
|
|
1708
1708
|
intTime: zt,
|
|
1709
1709
|
map: Ye,
|
|
1710
|
-
merge:
|
|
1710
|
+
merge: Ie,
|
|
1711
1711
|
null: et,
|
|
1712
1712
|
omap: xt,
|
|
1713
1713
|
pairs: yt,
|
|
@@ -1716,7 +1716,7 @@ var zt = {
|
|
|
1716
1716
|
timestamp: Vt
|
|
1717
1717
|
}, Gt = {
|
|
1718
1718
|
"tag:yaml.org,2002:binary": gt,
|
|
1719
|
-
"tag:yaml.org,2002:merge":
|
|
1719
|
+
"tag:yaml.org,2002:merge": Ie,
|
|
1720
1720
|
"tag:yaml.org,2002:omap": xt,
|
|
1721
1721
|
"tag:yaml.org,2002:pairs": yt,
|
|
1722
1722
|
"tag:yaml.org,2002:set": It,
|
|
@@ -1724,7 +1724,7 @@ var zt = {
|
|
|
1724
1724
|
};
|
|
1725
1725
|
function Kt(e, t, n) {
|
|
1726
1726
|
let r = Ut.get(t);
|
|
1727
|
-
if (r && !e) return n && !r.includes(
|
|
1727
|
+
if (r && !e) return n && !r.includes(Ie) ? r.concat(Ie) : r.slice();
|
|
1728
1728
|
let i = r;
|
|
1729
1729
|
if (!i) {
|
|
1730
1730
|
if (Array.isArray(e)) i = [];
|
|
@@ -1735,7 +1735,7 @@ function Kt(e, t, n) {
|
|
|
1735
1735
|
}
|
|
1736
1736
|
if (Array.isArray(e)) for (let t of e) i = i.concat(t);
|
|
1737
1737
|
else typeof e == "function" && (i = e(i.slice()));
|
|
1738
|
-
return n && (i = i.concat(
|
|
1738
|
+
return n && (i = i.concat(Ie)), i.reduce((e, t) => {
|
|
1739
1739
|
let n = typeof t == "string" ? Wt[t] : t;
|
|
1740
1740
|
if (!n) {
|
|
1741
1741
|
let e = JSON.stringify(t), n = Object.keys(Wt).map((e) => JSON.stringify(e)).join(", ");
|
|
@@ -1764,32 +1764,32 @@ function Yt(e, t) {
|
|
|
1764
1764
|
t ? (n.push(t), r = !0) : e.directives.docStart && (r = !0);
|
|
1765
1765
|
}
|
|
1766
1766
|
r && n.push("---");
|
|
1767
|
-
let i =
|
|
1767
|
+
let i = ke(e, t), { commentString: a } = i.options;
|
|
1768
1768
|
if (e.commentBefore) {
|
|
1769
1769
|
n.length !== 1 && n.unshift("");
|
|
1770
1770
|
let t = a(e.commentBefore);
|
|
1771
|
-
n.unshift(
|
|
1771
|
+
n.unshift(L(t, ""));
|
|
1772
1772
|
}
|
|
1773
1773
|
let o = !1, s = null;
|
|
1774
1774
|
if (e.contents) {
|
|
1775
1775
|
if (b(e.contents)) {
|
|
1776
1776
|
if (e.contents.spaceBefore && r && n.push(""), e.contents.commentBefore) {
|
|
1777
1777
|
let t = a(e.contents.commentBefore);
|
|
1778
|
-
n.push(
|
|
1778
|
+
n.push(L(t, ""));
|
|
1779
1779
|
}
|
|
1780
1780
|
i.forceBlockIndent = !!e.comment, s = e.contents.comment;
|
|
1781
1781
|
}
|
|
1782
|
-
let t = s ? void 0 : () => o = !0, c =
|
|
1783
|
-
s && (c +=
|
|
1784
|
-
} else n.push(
|
|
1782
|
+
let t = s ? void 0 : () => o = !0, c = Me(e.contents, i, () => s = null, t);
|
|
1783
|
+
s && (c += R(c, "", a(s))), (c[0] === "|" || c[0] === ">") && n[n.length - 1] === "---" ? n[n.length - 1] = `--- ${c}` : n.push(c);
|
|
1784
|
+
} else n.push(Me(e.contents, i));
|
|
1785
1785
|
if (e.directives?.docEnd) {
|
|
1786
1786
|
if (e.comment) {
|
|
1787
1787
|
let t = a(e.comment);
|
|
1788
|
-
t.includes("\n") ? (n.push("..."), n.push(
|
|
1788
|
+
t.includes("\n") ? (n.push("..."), n.push(L(t, ""))) : n.push(`... ${t}`);
|
|
1789
1789
|
} else n.push("...");
|
|
1790
1790
|
} else {
|
|
1791
1791
|
let t = e.comment;
|
|
1792
|
-
t && o && (t = t.replace(/^\n+/, "")), t && ((!o || s) && n[n.length - 1] !== "" && n.push(""), n.push(
|
|
1792
|
+
t && o && (t = t.replace(/^\n+/, "")), t && ((!o || s) && n[n.length - 1] !== "" && n.push(""), n.push(L(a(t), "")));
|
|
1793
1793
|
}
|
|
1794
1794
|
return n.join("\n") + "\n";
|
|
1795
1795
|
}
|
|
@@ -1829,7 +1829,7 @@ var Xt = class e {
|
|
|
1829
1829
|
let n = ie(this);
|
|
1830
1830
|
e.anchor = !t || n.has(t) ? ae(t || "a", n) : t;
|
|
1831
1831
|
}
|
|
1832
|
-
return new
|
|
1832
|
+
return new P(e.anchor);
|
|
1833
1833
|
}
|
|
1834
1834
|
createNode(e, t, n) {
|
|
1835
1835
|
let r;
|
|
@@ -1846,7 +1846,7 @@ var Xt = class e {
|
|
|
1846
1846
|
replacer: r,
|
|
1847
1847
|
schema: this.schema,
|
|
1848
1848
|
sourceObjects: f
|
|
1849
|
-
}, m =
|
|
1849
|
+
}, m = fe(e, l, p);
|
|
1850
1850
|
return o && y(m) && (m.flow = !0), d(), m;
|
|
1851
1851
|
}
|
|
1852
1852
|
createPair(e, t, n = {}) {
|
|
@@ -1856,25 +1856,25 @@ var Xt = class e {
|
|
|
1856
1856
|
return Zt(this.contents) ? this.contents.delete(e) : !1;
|
|
1857
1857
|
}
|
|
1858
1858
|
deleteIn(e) {
|
|
1859
|
-
return
|
|
1859
|
+
return me(e) ? this.contents != null && (this.contents = null, !0) : Zt(this.contents) ? this.contents.deleteIn(e) : !1;
|
|
1860
1860
|
}
|
|
1861
1861
|
get(e, t) {
|
|
1862
1862
|
return y(this.contents) ? this.contents.get(e, t) : void 0;
|
|
1863
1863
|
}
|
|
1864
1864
|
getIn(e, t) {
|
|
1865
|
-
return
|
|
1865
|
+
return me(e) ? !t && _(this.contents) ? this.contents.value : this.contents : y(this.contents) ? this.contents.getIn(e, t) : void 0;
|
|
1866
1866
|
}
|
|
1867
1867
|
has(e) {
|
|
1868
1868
|
return y(this.contents) ? this.contents.has(e) : !1;
|
|
1869
1869
|
}
|
|
1870
1870
|
hasIn(e) {
|
|
1871
|
-
return
|
|
1871
|
+
return me(e) ? this.contents !== void 0 : y(this.contents) ? this.contents.hasIn(e) : !1;
|
|
1872
1872
|
}
|
|
1873
1873
|
set(e, t) {
|
|
1874
|
-
this.contents == null ? this.contents =
|
|
1874
|
+
this.contents == null ? this.contents = pe(this.schema, [e], t) : Zt(this.contents) && this.contents.set(e, t);
|
|
1875
1875
|
}
|
|
1876
1876
|
setIn(e, t) {
|
|
1877
|
-
|
|
1877
|
+
me(e) ? this.contents = t : this.contents == null ? this.contents = pe(this.schema, Array.from(e), t) : Zt(this.contents) && this.contents.setIn(e, t);
|
|
1878
1878
|
}
|
|
1879
1879
|
setSchema(e, t = {}) {
|
|
1880
1880
|
typeof e == "number" && (e = String(e));
|
|
@@ -1913,9 +1913,9 @@ var Xt = class e {
|
|
|
1913
1913
|
mapAsMap: n === !0,
|
|
1914
1914
|
mapKeyWarned: !1,
|
|
1915
1915
|
maxAliasCount: typeof r == "number" ? r : 100
|
|
1916
|
-
}, s =
|
|
1916
|
+
}, s = N(this.contents, t ?? "", o);
|
|
1917
1917
|
if (typeof i == "function") for (let { count: e, res: t } of o.anchors.values()) i(t, e);
|
|
1918
|
-
return typeof a == "function" ?
|
|
1918
|
+
return typeof a == "function" ? M(a, { "": s }, "", s) : s;
|
|
1919
1919
|
}
|
|
1920
1920
|
toJSON(e, t) {
|
|
1921
1921
|
return this.toJS({
|
|
@@ -2304,7 +2304,7 @@ function hn(e, t, n, r, i) {
|
|
|
2304
2304
|
if (r?.collection === s) t.schema.tags.push(Object.assign({}, r, { default: !1 })), c = r;
|
|
2305
2305
|
else return r ? i(a, "BAD_COLLECTION_TYPE", `${r.tag} used for ${s} collection, but expects ${r.collection ?? "scalar"}`, !0) : i(a, "TAG_RESOLVE_FAILED", `Unresolved tag: ${o}`, !0), mn(e, t, n, i, o);
|
|
2306
2306
|
}
|
|
2307
|
-
let l = mn(e, t, n, i, o, c), u = c.resolve?.(l, (e) => i(a, "TAG_RESOLVE_FAILED", e), t.options) ?? l, d = b(u) ? u : new
|
|
2307
|
+
let l = mn(e, t, n, i, o, c), u = c.resolve?.(l, (e) => i(a, "TAG_RESOLVE_FAILED", e), t.options) ?? l, d = b(u) ? u : new F(u);
|
|
2308
2308
|
return d.range = l.range, d.tag = o, c?.format && (d.format = c.format), d;
|
|
2309
2309
|
}
|
|
2310
2310
|
//#endregion
|
|
@@ -2321,7 +2321,7 @@ function gn(e, t, n) {
|
|
|
2321
2321
|
r
|
|
2322
2322
|
]
|
|
2323
2323
|
};
|
|
2324
|
-
let a = i.mode === ">" ?
|
|
2324
|
+
let a = i.mode === ">" ? F.BLOCK_FOLDED : F.BLOCK_LITERAL, o = t.source ? vn(t.source) : [], s = o.length;
|
|
2325
2325
|
for (let e = o.length - 1; e >= 0; --e) {
|
|
2326
2326
|
let t = o[e][1];
|
|
2327
2327
|
if (t === "" || t === "\r") s = e;
|
|
@@ -2362,7 +2362,7 @@ function gn(e, t, n) {
|
|
|
2362
2362
|
let e = `Block scalar lines must not be less indented than their ${i.indent ? "explicit indentation indicator" : "first line"}`;
|
|
2363
2363
|
n(l - r.length - (s ? 2 : 1), "BAD_INDENT", e), t = "";
|
|
2364
2364
|
}
|
|
2365
|
-
a ===
|
|
2365
|
+
a === F.BLOCK_LITERAL ? (d += f + t.slice(c) + r, f = "\n") : t.length > c || r[0] === " " ? (f === " " ? f = "\n" : !p && f === "\n" && (f = "\n\n"), d += f + t.slice(c) + r, f = "\n", p = !0) : r === "" ? f === "\n" ? d += "\n" : f = "\n" : (d += f + r, f = " ", p = !1);
|
|
2366
2366
|
}
|
|
2367
2367
|
switch (i.chomp) {
|
|
2368
2368
|
case "-": break;
|
|
@@ -2438,13 +2438,13 @@ function yn(e, t, n) {
|
|
|
2438
2438
|
let { offset: r, type: i, source: a, end: o } = e, s, c, l = (e, t, i) => n(r + e, t, i);
|
|
2439
2439
|
switch (i) {
|
|
2440
2440
|
case "scalar":
|
|
2441
|
-
s =
|
|
2441
|
+
s = F.PLAIN, c = bn(a, l);
|
|
2442
2442
|
break;
|
|
2443
2443
|
case "single-quoted-scalar":
|
|
2444
|
-
s =
|
|
2444
|
+
s = F.QUOTE_SINGLE, c = xn(a, l);
|
|
2445
2445
|
break;
|
|
2446
2446
|
case "double-quoted-scalar":
|
|
2447
|
-
s =
|
|
2447
|
+
s = F.QUOTE_DOUBLE, c = Cn(a, l);
|
|
2448
2448
|
break;
|
|
2449
2449
|
/* istanbul ignore next should not happen */
|
|
2450
2450
|
default: return n(e, "UNEXPECTED_TOKEN", `Expected a flow scalar value, but found: ${i}`), {
|
|
@@ -2583,10 +2583,10 @@ function Dn(e, t, n, r) {
|
|
|
2583
2583
|
let d;
|
|
2584
2584
|
try {
|
|
2585
2585
|
let a = l.resolve(i, (e) => r(n ?? t, "TAG_RESOLVE_FAILED", e), e.options);
|
|
2586
|
-
d = _(a) ? a : new
|
|
2586
|
+
d = _(a) ? a : new F(a);
|
|
2587
2587
|
} catch (e) {
|
|
2588
2588
|
let a = e instanceof Error ? e.message : String(e);
|
|
2589
|
-
r(n ?? t, "TAG_RESOLVE_FAILED", a), d = new
|
|
2589
|
+
r(n ?? t, "TAG_RESOLVE_FAILED", a), d = new F(i);
|
|
2590
2590
|
}
|
|
2591
2591
|
return d.range = s, d.source = i, a && (d.type = a), c && (d.tag = c), l.format && (d.format = l.format), o && (d.comment = o), d;
|
|
2592
2592
|
}
|
|
@@ -2673,7 +2673,7 @@ function Nn(e, t, n, r, { spaceBefore: i, comment: a, anchor: o, tag: s, end: c
|
|
|
2673
2673
|
return o && (u.anchor = o.source.substring(1), u.anchor === "" && l(o, "BAD_ALIAS", "Anchor cannot be an empty string")), i && (u.spaceBefore = !0), a && (u.comment = a, u.range[2] = c), u;
|
|
2674
2674
|
}
|
|
2675
2675
|
function Pn({ options: e }, { offset: t, source: n, end: r }, i) {
|
|
2676
|
-
let a = new
|
|
2676
|
+
let a = new P(n.substring(1));
|
|
2677
2677
|
a.source === "" && i(t, "BAD_ALIAS", "Alias cannot be an empty string"), a.source.endsWith(":") && i(t + n.length - 1, "BAD_ALIAS", "Alias ending in : is ambiguous", !0);
|
|
2678
2678
|
let o = t + n.length, s = un(r, o, e.strict, i);
|
|
2679
2679
|
return a.range = [
|
|
@@ -2847,7 +2847,7 @@ function zn(e, t = !0, n) {
|
|
|
2847
2847
|
return null;
|
|
2848
2848
|
}
|
|
2849
2849
|
function Bn(e, t) {
|
|
2850
|
-
let { implicitKey: n = !1, indent: r, inFlow: i = !1, offset: a = -1, type: o = "PLAIN" } = t, s =
|
|
2850
|
+
let { implicitKey: n = !1, indent: r, inFlow: i = !1, offset: a = -1, type: o = "PLAIN" } = t, s = Oe({
|
|
2851
2851
|
type: o,
|
|
2852
2852
|
value: e
|
|
2853
2853
|
}, {
|
|
@@ -2926,7 +2926,7 @@ function Vn(e, t, n = {}) {
|
|
|
2926
2926
|
}
|
|
2927
2927
|
default: o = "PLAIN";
|
|
2928
2928
|
}
|
|
2929
|
-
let c =
|
|
2929
|
+
let c = Oe({
|
|
2930
2930
|
type: o,
|
|
2931
2931
|
value: t
|
|
2932
2932
|
}, {
|
|
@@ -4232,7 +4232,7 @@ function Sr(e, t, n) {
|
|
|
4232
4232
|
typeof t == "function" ? r = t : n === void 0 && t && typeof t == "object" && (n = t);
|
|
4233
4233
|
let i = xr(e, n);
|
|
4234
4234
|
if (!i) return null;
|
|
4235
|
-
if (i.warnings.forEach((e) =>
|
|
4235
|
+
if (i.warnings.forEach((e) => Pe(i.options.logLevel, e)), i.errors.length > 0) {
|
|
4236
4236
|
if (i.options.logLevel !== "silent") throw i.errors[0];
|
|
4237
4237
|
i.errors = [];
|
|
4238
4238
|
}
|
|
@@ -4253,7 +4253,7 @@ function Cr(e, t, n) {
|
|
|
4253
4253
|
//#endregion
|
|
4254
4254
|
//#region node_modules/yaml/browser/index.js
|
|
4255
4255
|
var wr = /* @__PURE__ */ a({
|
|
4256
|
-
Alias: () =>
|
|
4256
|
+
Alias: () => P,
|
|
4257
4257
|
CST: () => $n,
|
|
4258
4258
|
Composer: () => Rn,
|
|
4259
4259
|
Document: () => Xt,
|
|
@@ -4261,7 +4261,7 @@ var wr = /* @__PURE__ */ a({
|
|
|
4261
4261
|
LineCounter: () => ur,
|
|
4262
4262
|
Pair: () => V,
|
|
4263
4263
|
Parser: () => vr,
|
|
4264
|
-
Scalar: () =>
|
|
4264
|
+
Scalar: () => F,
|
|
4265
4265
|
Schema: () => Jt,
|
|
4266
4266
|
YAMLError: () => Qt,
|
|
4267
4267
|
YAMLMap: () => H,
|
|
@@ -5656,166 +5656,24 @@ function J(e) {
|
|
|
5656
5656
|
return t === "none" || t === "off" || t === "false" ? new oi() : e?.env?.CMS_CACHE_KV ? new ai(e.env.CMS_CACHE_KV) : t === "lru" ? (si ||= new ii(), si) : new oi();
|
|
5657
5657
|
}
|
|
5658
5658
|
//#endregion
|
|
5659
|
-
//#region server/storage/provider.ts
|
|
5660
|
-
function ci(e) {
|
|
5661
|
-
let t = e.split(".").pop()?.toLowerCase() || "bin";
|
|
5662
|
-
return t = t.replace(/[^a-z0-9]/g, ""), [
|
|
5663
|
-
"php",
|
|
5664
|
-
"exe",
|
|
5665
|
-
"sh",
|
|
5666
|
-
"bat",
|
|
5667
|
-
"cmd",
|
|
5668
|
-
"html",
|
|
5669
|
-
"htm",
|
|
5670
|
-
"js",
|
|
5671
|
-
"mjs",
|
|
5672
|
-
"cjs"
|
|
5673
|
-
].includes(t) ? "bin" : t;
|
|
5674
|
-
}
|
|
5675
|
-
var li = class {
|
|
5676
|
-
bucket;
|
|
5677
|
-
publicDomain;
|
|
5678
|
-
constructor(e, t) {
|
|
5679
|
-
this.bucket = e, this.publicDomain = t;
|
|
5680
|
-
}
|
|
5681
|
-
async upload(e, t = "uploads") {
|
|
5682
|
-
let n = ci(e.name), r = `${t}/${crypto.randomUUID().replace(/-/g, "")}.${n}`;
|
|
5683
|
-
return await this.bucket.put(r, e.stream(), { httpMetadata: { contentType: e.type } }), {
|
|
5684
|
-
key: r,
|
|
5685
|
-
url: `/media/${r.replace(/^\//, "")}`
|
|
5686
|
-
};
|
|
5687
|
-
}
|
|
5688
|
-
async delete(e) {
|
|
5689
|
-
await this.bucket.delete(e);
|
|
5690
|
-
}
|
|
5691
|
-
}, ui = class {
|
|
5692
|
-
customStoragePath;
|
|
5693
|
-
constructor(e) {
|
|
5694
|
-
this.customStoragePath = e;
|
|
5695
|
-
}
|
|
5696
|
-
async upload(e, t = "uploads") {
|
|
5697
|
-
let n = await import(
|
|
5698
|
-
/* @vite-ignore */
|
|
5699
|
-
"node:path"
|
|
5700
|
-
), r = await import(
|
|
5701
|
-
/* @vite-ignore */
|
|
5702
|
-
"node:fs"
|
|
5703
|
-
), i = await import(
|
|
5704
|
-
/* @vite-ignore */
|
|
5705
|
-
"node:fs/promises"
|
|
5706
|
-
), { pipeline: a } = await import(
|
|
5707
|
-
/* @vite-ignore */
|
|
5708
|
-
"node:stream/promises"
|
|
5709
|
-
), o = ci(e.name), s = `${t}/${crypto.randomUUID().replace(/-/g, "")}.${o}`, c = this.customStoragePath || "./public/media", l = n.resolve(process.cwd(), c), u = n.join(l, s);
|
|
5710
|
-
await i.mkdir(n.dirname(u), { recursive: !0 });
|
|
5711
|
-
let d = r.createWriteStream(u);
|
|
5712
|
-
return await a(e.stream(), d), {
|
|
5713
|
-
key: s,
|
|
5714
|
-
url: `/media/${s}`
|
|
5715
|
-
};
|
|
5716
|
-
}
|
|
5717
|
-
async delete(e) {
|
|
5718
|
-
let t = await import(
|
|
5719
|
-
/* @vite-ignore */
|
|
5720
|
-
"node:path"
|
|
5721
|
-
), n = await import(
|
|
5722
|
-
/* @vite-ignore */
|
|
5723
|
-
"node:fs/promises"
|
|
5724
|
-
), r = this.customStoragePath || "./public/media", i = t.resolve(process.cwd(), r), a = t.join(i, e);
|
|
5725
|
-
try {
|
|
5726
|
-
await n.unlink(a);
|
|
5727
|
-
} catch (e) {
|
|
5728
|
-
if (e.code !== "ENOENT") throw e;
|
|
5729
|
-
}
|
|
5730
|
-
}
|
|
5731
|
-
};
|
|
5732
|
-
function di(e) {
|
|
5733
|
-
if (e.MEDIA_BUCKET) {
|
|
5734
|
-
let t = e.CDN_DOMAIN || "cdn.yourdomain.com";
|
|
5735
|
-
return new li(e.MEDIA_BUCKET, t);
|
|
5736
|
-
}
|
|
5737
|
-
return new ui(e.LOCAL_MEDIA_PATH);
|
|
5738
|
-
}
|
|
5739
|
-
//#endregion
|
|
5740
|
-
//#region server/utils/node-assets-interceptor.ts
|
|
5741
|
-
function fi(e) {
|
|
5742
|
-
if (!e || typeof e != "object") return {
|
|
5743
|
-
cleanedData: e,
|
|
5744
|
-
assetRefs: []
|
|
5745
|
-
};
|
|
5746
|
-
let t = [], n = (e) => e ? typeof e == "string" && e.startsWith("ast_") ? e : typeof e == "object" && typeof e.id == "string" && e.id.startsWith("ast_") ? e.id : null : null, r = (e, i) => {
|
|
5747
|
-
if (!e || typeof e != "object") return e;
|
|
5748
|
-
if (Array.isArray(e)) return e.map((e, a) => {
|
|
5749
|
-
let o = n(e);
|
|
5750
|
-
if (o && (t.push({
|
|
5751
|
-
assetId: o,
|
|
5752
|
-
fieldKey: i,
|
|
5753
|
-
sortOrder: a
|
|
5754
|
-
}), typeof e == "object" && e && e.variants && typeof e.variants == "object")) for (let [r, o] of Object.entries(e.variants)) {
|
|
5755
|
-
let e = n(o);
|
|
5756
|
-
e && t.push({
|
|
5757
|
-
assetId: e,
|
|
5758
|
-
fieldKey: `${i}[${a}].variants.${r}`,
|
|
5759
|
-
sortOrder: a
|
|
5760
|
-
});
|
|
5761
|
-
}
|
|
5762
|
-
return typeof e == "object" && e ? r(e, `${i}[${a}]`) : e;
|
|
5763
|
-
});
|
|
5764
|
-
let a = {};
|
|
5765
|
-
for (let o of Object.keys(e)) {
|
|
5766
|
-
let s = e[o], c = i ? `${i}.${o}` : o, l = n(s);
|
|
5767
|
-
if (l) {
|
|
5768
|
-
if (t.push({
|
|
5769
|
-
assetId: l,
|
|
5770
|
-
fieldKey: c,
|
|
5771
|
-
sortOrder: 0
|
|
5772
|
-
}), typeof s == "object" && s && s.variants && typeof s.variants == "object") for (let [e, r] of Object.entries(s.variants)) {
|
|
5773
|
-
let i = n(r);
|
|
5774
|
-
i && t.push({
|
|
5775
|
-
assetId: i,
|
|
5776
|
-
fieldKey: `${c}.variants.${e}`,
|
|
5777
|
-
sortOrder: 0
|
|
5778
|
-
});
|
|
5779
|
-
}
|
|
5780
|
-
a[o] = typeof s == "object" && s ? {
|
|
5781
|
-
id: l,
|
|
5782
|
-
url: s.url || "",
|
|
5783
|
-
originalUrl: s.originalUrl || s.url || "",
|
|
5784
|
-
parentAssetId: s.parentAssetId || null,
|
|
5785
|
-
cropCoordinates: s.cropCoordinates || null,
|
|
5786
|
-
variants: s.variants || void 0,
|
|
5787
|
-
metadataOverrides: s.metadataOverrides || void 0,
|
|
5788
|
-
filename: s.filename || void 0,
|
|
5789
|
-
mimeType: s.mimeType || void 0
|
|
5790
|
-
} : l;
|
|
5791
|
-
} else a[o] = Array.isArray(s) || s && typeof s == "object" ? r(s, c) : s;
|
|
5792
|
-
}
|
|
5793
|
-
return a;
|
|
5794
|
-
};
|
|
5795
|
-
return {
|
|
5796
|
-
cleanedData: r(e, ""),
|
|
5797
|
-
assetRefs: t
|
|
5798
|
-
};
|
|
5799
|
-
}
|
|
5800
|
-
//#endregion
|
|
5801
5659
|
//#region server/utils/asset-hydrator.ts
|
|
5802
|
-
function
|
|
5660
|
+
function ci(e) {
|
|
5803
5661
|
if (!e) return null;
|
|
5804
5662
|
if (typeof e == "string" && e.startsWith("ast_")) return e;
|
|
5805
5663
|
if (typeof e == "object" && e) {
|
|
5806
5664
|
if (typeof e.id == "string" && e.id.startsWith("ast_")) return e.id;
|
|
5807
|
-
if (typeof e.id == "object") return
|
|
5665
|
+
if (typeof e.id == "object") return ci(e.id);
|
|
5808
5666
|
}
|
|
5809
5667
|
return null;
|
|
5810
5668
|
}
|
|
5811
|
-
async function
|
|
5669
|
+
async function li(e, t) {
|
|
5812
5670
|
if (!t || typeof t != "object" || !JSON.stringify(t).includes("ast_")) return t;
|
|
5813
5671
|
let n = /* @__PURE__ */ new Set(), r = (e) => {
|
|
5814
5672
|
if (!e) return;
|
|
5815
|
-
let t =
|
|
5673
|
+
let t = ci(e);
|
|
5816
5674
|
if (t) {
|
|
5817
5675
|
if (n.add(t), typeof e == "object" && e.parentAssetId) {
|
|
5818
|
-
let t =
|
|
5676
|
+
let t = ci(e.parentAssetId);
|
|
5819
5677
|
t && n.add(t);
|
|
5820
5678
|
}
|
|
5821
5679
|
} else Array.isArray(e) ? e.forEach(r) : typeof e == "object" && Object.values(e).forEach(r);
|
|
@@ -5851,7 +5709,7 @@ async function mi(e, t) {
|
|
|
5851
5709
|
}
|
|
5852
5710
|
let s = /* @__PURE__ */ new Map();
|
|
5853
5711
|
for (let e of o) {
|
|
5854
|
-
let t =
|
|
5712
|
+
let t = ci(e.parentAssetId) || i.find((t) => e.filename.includes(t));
|
|
5855
5713
|
if (!t) continue;
|
|
5856
5714
|
let n = e.filename.match(/^crop_([a-z0-9]+)_/i), r = n ? n[1] : "standard", a = null;
|
|
5857
5715
|
if (e.cropCoordinatesJson) try {
|
|
@@ -5886,7 +5744,7 @@ async function mi(e, t) {
|
|
|
5886
5744
|
id: e.id,
|
|
5887
5745
|
url: t,
|
|
5888
5746
|
originalUrl: n,
|
|
5889
|
-
parentAssetId:
|
|
5747
|
+
parentAssetId: ci(e.parentAssetId) || null,
|
|
5890
5748
|
cropCoordinates: r,
|
|
5891
5749
|
variants: i && Object.keys(i).length > 0 ? i : void 0,
|
|
5892
5750
|
filename: e.filename,
|
|
@@ -5898,7 +5756,7 @@ async function mi(e, t) {
|
|
|
5898
5756
|
}
|
|
5899
5757
|
let l = (e) => {
|
|
5900
5758
|
if (!e) return e;
|
|
5901
|
-
let t =
|
|
5759
|
+
let t = ci(e);
|
|
5902
5760
|
if (t) {
|
|
5903
5761
|
let n = c.get(t) || {
|
|
5904
5762
|
id: t,
|
|
@@ -5908,7 +5766,7 @@ async function mi(e, t) {
|
|
|
5908
5766
|
return {
|
|
5909
5767
|
...n,
|
|
5910
5768
|
id: t,
|
|
5911
|
-
parentAssetId: n.parentAssetId ?
|
|
5769
|
+
parentAssetId: n.parentAssetId ? ci(n.parentAssetId) : null,
|
|
5912
5770
|
url: typeof e == "object" && e.url && !e.url.startsWith("blob:") ? e.url : n.url,
|
|
5913
5771
|
originalUrl: typeof e == "object" && e.originalUrl && !e.originalUrl.startsWith("blob:") ? e.originalUrl : n.originalUrl,
|
|
5914
5772
|
cropCoordinates: i || n.cropCoordinates || null,
|
|
@@ -6103,7 +5961,7 @@ function Z(e, t) {
|
|
|
6103
5961
|
e.executionCtx && typeof e.executionCtx.waitUntil == "function" && e.executionCtx.waitUntil(n);
|
|
6104
5962
|
} catch {}
|
|
6105
5963
|
}
|
|
6106
|
-
async function
|
|
5964
|
+
async function ui(e, t, n = []) {
|
|
6107
5965
|
let r = e.prepare(t);
|
|
6108
5966
|
if (typeof r.bind == "function") {
|
|
6109
5967
|
let e = await r.bind(...n).all();
|
|
@@ -6115,23 +5973,23 @@ async function hi(e, t, n = []) {
|
|
|
6115
5973
|
}
|
|
6116
5974
|
return [];
|
|
6117
5975
|
}
|
|
6118
|
-
async function
|
|
5976
|
+
async function di(e, t, n = []) {
|
|
6119
5977
|
let r = e.prepare(t);
|
|
6120
5978
|
if (typeof r.bind == "function") return r.bind(...n).run();
|
|
6121
5979
|
if (typeof r.run == "function") return r.run(...n);
|
|
6122
5980
|
}
|
|
6123
|
-
function
|
|
5981
|
+
function fi(e) {
|
|
6124
5982
|
return !e || !e.trim() ? null : e.normalize("NFD").replace(/[\u0300-\u036f]/g, "").toLowerCase().trim().replace(/[^a-z0-9\s-]/g, "").replace(/[\s-]+/g, "-").replace(/^-+|-+$/g, "") || null;
|
|
6125
5983
|
}
|
|
6126
|
-
function
|
|
5984
|
+
function pi(e) {
|
|
6127
5985
|
return +(e === !0 || e === 1 || e === "1" || e === "true");
|
|
6128
5986
|
}
|
|
6129
|
-
function
|
|
5987
|
+
function mi(e) {
|
|
6130
5988
|
if (e == null || e === "null" || e === "" || typeof e == "string" && e.startsWith("draft-")) return null;
|
|
6131
5989
|
let t = Number(e);
|
|
6132
5990
|
return isNaN(t) ? null : t;
|
|
6133
5991
|
}
|
|
6134
|
-
function
|
|
5992
|
+
function hi(e) {
|
|
6135
5993
|
let t = { ...e };
|
|
6136
5994
|
for (let e of [
|
|
6137
5995
|
"id",
|
|
@@ -6161,26 +6019,7 @@ function bi(e) {
|
|
|
6161
6019
|
]) e === "id" && typeof t[e] == "string" && t[e].startsWith("ast_") || delete t[e];
|
|
6162
6020
|
return t;
|
|
6163
6021
|
}
|
|
6164
|
-
async function
|
|
6165
|
-
for (let r of n) {
|
|
6166
|
-
let n = (await hi(e, "SELECT id, storageKeyPrivate, isSystemVariant, parentAssetId, filename FROM assets WHERE id = ?", [r]))[0];
|
|
6167
|
-
if (!n || (await hi(e, "SELECT 1 FROM node_assets WHERE assetId = ? LIMIT 1", [n.id])).length > 0) continue;
|
|
6168
|
-
let i = [n];
|
|
6169
|
-
if (!n.isSystemVariant) {
|
|
6170
|
-
let t = await hi(e, "\n SELECT id, storageKeyPrivate, isSystemVariant, parentAssetId, filename FROM assets\n WHERE parentAssetId = ? OR (isSystemVariant = 1 AND filename LIKE ?)\n ", [n.id, `crop_%${String(n.filename || "").replace(/\.[^/.]+$/, "")}%`]), r = t.map((e) => e.id);
|
|
6171
|
-
if (r.length > 0 && (await hi(e, `SELECT DISTINCT assetId FROM node_assets WHERE assetId IN (${r.map(() => "?").join(",")})`, r)).length > 0) continue;
|
|
6172
|
-
i = [n, ...t];
|
|
6173
|
-
}
|
|
6174
|
-
for (let e of i) if (e.storageKeyPrivate) try {
|
|
6175
|
-
await t.delete(e.storageKeyPrivate);
|
|
6176
|
-
} catch (t) {
|
|
6177
|
-
console.warn(`[Asset Cleanup] Failed to delete ${e.storageKeyPrivate}:`, t);
|
|
6178
|
-
}
|
|
6179
|
-
let a = i.map((e) => e.id), o = a.map(() => "?").join(",");
|
|
6180
|
-
await gi(e, `DELETE FROM node_assets WHERE assetId IN (${o})`, a), await gi(e, `DELETE FROM assets WHERE id IN (${o})`, a);
|
|
6181
|
-
}
|
|
6182
|
-
}
|
|
6183
|
-
async function Si(e, t, n) {
|
|
6022
|
+
async function gi(e, t, n) {
|
|
6184
6023
|
let r = {}, i = null;
|
|
6185
6024
|
if (t) {
|
|
6186
6025
|
let n = await e.prepare("\n WITH RECURSIVE ancestor_path(id, parentId, draftDataJson, dataJson, level) AS (\n SELECT t.id, t.parentId, c.draftDataJson, c.dataJson, 0 FROM tree_nodes t\n INNER JOIN content_nodes c ON t.contentId = c.id WHERE t.id = ?\n UNION ALL\n SELECT t.id, t.parentId, c.draftDataJson, c.dataJson, ap.level + 1 FROM tree_nodes t\n INNER JOIN content_nodes c ON t.contentId = c.id INNER JOIN ancestor_path ap ON t.id = ap.parentId\n ) SELECT draftDataJson, dataJson FROM ancestor_path ORDER BY level ASC\n ").all(t), a = Array.isArray(n) ? n : n?.results || [], o = /* @__PURE__ */ new Set([
|
|
@@ -6219,7 +6058,7 @@ async function Si(e, t, n) {
|
|
|
6219
6058
|
};
|
|
6220
6059
|
}
|
|
6221
6060
|
X.get("/", async (e) => {
|
|
6222
|
-
let t = e.get("db"), n = e.req.query("id"), r = e.req.query("type"), i = e.req.query("search") || e.req.query("q"), a = e.req.query("channelId"), o = e.req.query("trashed") === "true", s = e.req.query("assetId"), c = e.req.query("sort") || "updatedAt", l = (e.req.query("order") || "DESC").toUpperCase() === "ASC" ? "ASC" : "DESC", u =
|
|
6061
|
+
let t = e.get("db"), n = e.req.query("id"), r = e.req.query("type"), i = e.req.query("search") || e.req.query("q"), a = e.req.query("channelId"), o = e.req.query("trashed") === "true", s = e.req.query("assetId"), c = e.req.query("sort") || "updatedAt", l = (e.req.query("order") || "DESC").toUpperCase() === "ASC" ? "ASC" : "DESC", u = Math.max(1, Math.min(100, parseInt(e.req.query("limit") || "50", 10))), d = Math.max(0, parseInt(e.req.query("offset") || "0", 10));
|
|
6223
6062
|
if (n) {
|
|
6224
6063
|
let r = Number(n);
|
|
6225
6064
|
if (isNaN(r)) return e.json({ error: "Invalid Node ID" }, 400);
|
|
@@ -6243,7 +6082,7 @@ X.get("/", async (e) => {
|
|
|
6243
6082
|
updatedAt: i.updatedAt
|
|
6244
6083
|
}, s = i.draftDataJson || i.dataJson;
|
|
6245
6084
|
if (s) try {
|
|
6246
|
-
let n = typeof s == "string" ? JSON.parse(s) : s, a = await t.prepare("SELECT id as treeNodeId, treeId, parentId FROM tree_nodes WHERE contentId = ? LIMIT 1").get(r), c = jr(e.env?.BUNDLED_DEFINITIONS).nodes?.[i.contentType] || {}, l =
|
|
6085
|
+
let n = typeof s == "string" ? JSON.parse(s) : s, a = await t.prepare("SELECT id as treeNodeId, treeId, parentId FROM tree_nodes WHERE contentId = ? LIMIT 1").get(r), c = jr(e.env?.BUNDLED_DEFINITIONS).nodes?.[i.contentType] || {}, l = hi(n), u = l.layoutId || null, d = !1, f = null;
|
|
6247
6086
|
if (c) {
|
|
6248
6087
|
let e = (e) => {
|
|
6249
6088
|
e && (d = !0, e.options && Array.isArray(e.options) && (f = e.options.map((e) => typeof e == "object" ? e.value || e.id : e)));
|
|
@@ -6253,11 +6092,11 @@ X.get("/", async (e) => {
|
|
|
6253
6092
|
if (d && f && f.length === 1 && f[0] !== "inherit") u = f[0];
|
|
6254
6093
|
else if (!d && c.defaultLayout) u = c.defaultLayout;
|
|
6255
6094
|
else if (a) {
|
|
6256
|
-
let { resolvedLayoutId: e, inheritedFields: n } = await
|
|
6095
|
+
let { resolvedLayoutId: e, inheritedFields: n } = await gi(t, a.parentId, a.treeId);
|
|
6257
6096
|
(u === "inherit" || !u) && (u = e && (!f || f.includes(e) || f.includes("inherit")) ? e : c.defaultLayout || null);
|
|
6258
6097
|
for (let [e, t] of Object.entries(n)) (l[e] === void 0 || l[e] === null || l[e] === "" || l[e] === "inherit") && (l[e] = t);
|
|
6259
6098
|
} else (u === "inherit" || !u) && (u = c.defaultLayout || null);
|
|
6260
|
-
let p = await
|
|
6099
|
+
let p = await li(t, l);
|
|
6261
6100
|
Object.assign(o, p), c.hasCanvas && (o.resolvedLayoutId = u);
|
|
6262
6101
|
} catch {}
|
|
6263
6102
|
let c = await t.prepare("SELECT channelId FROM node_channels WHERE nodeId = ?").all(r);
|
|
@@ -6267,7 +6106,7 @@ X.get("/", async (e) => {
|
|
|
6267
6106
|
let u = await t.prepare("SELECT * FROM content_blocks WHERE contentId = ? AND isDraft = 1 ORDER BY sortOrder ASC").all(r), d = Array.isArray(u) ? u : u?.results || [], f = await Promise.all(d.map(async (e) => {
|
|
6268
6107
|
let n = {};
|
|
6269
6108
|
try {
|
|
6270
|
-
n = typeof e.dataJson == "string" ? JSON.parse(e.dataJson || "{}") : e.dataJson || {}, n && typeof n == "object" && (n = await
|
|
6109
|
+
n = typeof e.dataJson == "string" ? JSON.parse(e.dataJson || "{}") : e.dataJson || {}, n && typeof n == "object" && (n = await li(t, n));
|
|
6271
6110
|
} catch {
|
|
6272
6111
|
n = {};
|
|
6273
6112
|
}
|
|
@@ -6285,43 +6124,40 @@ X.get("/", async (e) => {
|
|
|
6285
6124
|
blocks: f
|
|
6286
6125
|
});
|
|
6287
6126
|
}
|
|
6288
|
-
let
|
|
6289
|
-
if (a && a !== "all" && (
|
|
6127
|
+
let f = [], p = [o ? "(cn.deletedAt IS NOT NULL AND cn.deletedAt != '')" : "(cn.deletedAt IS NULL OR cn.deletedAt = '')"];
|
|
6128
|
+
if (a && a !== "all" && (p.push("EXISTS (SELECT 1 FROM node_channels nc WHERE nc.nodeId = cn.id AND nc.channelId = ?)"), f.push(Number(a) || a)), s && (p.push("EXISTS (SELECT 1 FROM node_assets na_f JOIN assets a_f ON a_f.id = na_f.assetId WHERE na_f.nodeId = cn.id AND (na_f.assetId = ? OR a_f.parentAssetId = ? OR a_f.id = (SELECT parentAssetId FROM assets WHERE id = ?)))"), f.push(s, s, s)), r && r !== "all") {
|
|
6290
6129
|
let e = r.split(",").map((e) => e.trim()).filter(Boolean);
|
|
6291
|
-
e.length > 0 && (
|
|
6130
|
+
e.length > 0 && (p.push(`cn.contentType IN (${e.map(() => "?").join(",")})`), f.push(...e));
|
|
6292
6131
|
}
|
|
6293
6132
|
if (i && i.trim()) {
|
|
6294
|
-
|
|
6133
|
+
p.push("(cn.title LIKE ? OR cn.slug LIKE ?)");
|
|
6295
6134
|
let e = `%${i.trim()}%`;
|
|
6296
|
-
|
|
6135
|
+
f.push(e, e);
|
|
6297
6136
|
}
|
|
6298
|
-
let
|
|
6137
|
+
let m = `WHERE ${p.join(" AND ")}`, h = await t.prepare(`SELECT COUNT(*) as total FROM content_nodes cn ${m}`).get(...f), g = h ? h.total : 0, _ = "cn.updatedAt", v = {
|
|
6299
6138
|
createdAt: "cn.createdAt",
|
|
6300
6139
|
updatedAt: "cn.updatedAt",
|
|
6301
6140
|
title: "LOWER(cn.title)",
|
|
6302
6141
|
slug: "LOWER(cn.slug)",
|
|
6303
|
-
contentType: "LOWER(cn.contentType)"
|
|
6304
|
-
language: "LOWER(cn.language)",
|
|
6305
|
-
status: "LOWER(cn.status)",
|
|
6306
|
-
isHidden: "cn.isHidden"
|
|
6142
|
+
contentType: "LOWER(cn.contentType)"
|
|
6307
6143
|
};
|
|
6308
|
-
|
|
6309
|
-
let
|
|
6310
|
-
WITH filtered_nodes AS (SELECT cn.* FROM content_nodes cn ${
|
|
6311
|
-
SELECT fn.*, COUNT(na.assetId) as assetCount FROM filtered_nodes fn LEFT JOIN node_assets na ON fn.id = na.nodeId GROUP BY fn.id ORDER BY ${
|
|
6312
|
-
`,
|
|
6313
|
-
if (
|
|
6314
|
-
let e =
|
|
6144
|
+
v[c] && (_ = v[c]);
|
|
6145
|
+
let y = `
|
|
6146
|
+
WITH filtered_nodes AS (SELECT cn.* FROM content_nodes cn ${m} ORDER BY ${_} ${l} LIMIT ? OFFSET ?)
|
|
6147
|
+
SELECT fn.*, COUNT(na.assetId) as assetCount FROM filtered_nodes fn LEFT JOIN node_assets na ON fn.id = na.nodeId GROUP BY fn.id ORDER BY ${_.replace("cn.", "fn.")} ${l}
|
|
6148
|
+
`, b = await t.prepare(y).all(...f, u, d), x = Array.isArray(b) ? b : b?.results || [], S = x.map((e) => e.id), C = {}, w = {};
|
|
6149
|
+
if (S.length > 0) {
|
|
6150
|
+
let e = S.map(() => "?").join(","), n = await t.prepare(`SELECT nc.nodeId, c.label FROM node_channels nc JOIN channels c ON nc.channelId = c.id WHERE nc.nodeId IN (${e})`).all(...S);
|
|
6315
6151
|
(Array.isArray(n) ? n : n?.results || []).forEach((e) => {
|
|
6316
|
-
|
|
6152
|
+
C[e.nodeId] || (C[e.nodeId] = []), C[e.nodeId].push(e.label);
|
|
6317
6153
|
});
|
|
6318
|
-
let r = await t.prepare(`SELECT tn.contentId as nodeId, t.label FROM tree_nodes tn JOIN trees t ON tn.treeId = t.id WHERE tn.contentId IN (${e})`).all(...
|
|
6154
|
+
let r = await t.prepare(`SELECT tn.contentId as nodeId, t.label FROM tree_nodes tn JOIN trees t ON tn.treeId = t.id WHERE tn.contentId IN (${e})`).all(...S);
|
|
6319
6155
|
(Array.isArray(r) ? r : r?.results || []).forEach((e) => {
|
|
6320
|
-
|
|
6156
|
+
w[e.nodeId] || (w[e.nodeId] = []), w[e.nodeId].includes(e.label) || w[e.nodeId].push(e.label);
|
|
6321
6157
|
});
|
|
6322
6158
|
}
|
|
6323
|
-
let
|
|
6324
|
-
let
|
|
6159
|
+
let T = await Promise.all(x.map(async (e) => {
|
|
6160
|
+
let t = (e.status === "draft" || !e.status) && !!e.publishedAt, n = {
|
|
6325
6161
|
id: e.id,
|
|
6326
6162
|
title: e.title,
|
|
6327
6163
|
slug: e.slug,
|
|
@@ -6331,41 +6167,39 @@ X.get("/", async (e) => {
|
|
|
6331
6167
|
isHidden: !!e.isHidden,
|
|
6332
6168
|
status: e.status || "draft",
|
|
6333
6169
|
publishedAt: e.publishedAt || null,
|
|
6334
|
-
hasUnpublishedChanges:
|
|
6170
|
+
hasUnpublishedChanges: t,
|
|
6335
6171
|
deletedAt: e.deletedAt || null,
|
|
6336
|
-
createdById: e.createdById || null,
|
|
6337
|
-
updatedById: e.updatedById || null,
|
|
6338
6172
|
createdAt: e.createdAt,
|
|
6339
6173
|
updatedAt: e.updatedAt,
|
|
6340
|
-
channelNames:
|
|
6341
|
-
treeNames:
|
|
6174
|
+
channelNames: C[e.id] || [],
|
|
6175
|
+
treeNames: w[e.id] || [],
|
|
6342
6176
|
assetCount: e.assetCount || 0
|
|
6343
|
-
},
|
|
6344
|
-
if (
|
|
6345
|
-
let e = typeof
|
|
6346
|
-
|
|
6177
|
+
}, r = e.draftDataJson || e.dataJson;
|
|
6178
|
+
if (r) try {
|
|
6179
|
+
let e = typeof r == "string" ? JSON.parse(r) : r;
|
|
6180
|
+
n.image = e.image || e.coverImage || null;
|
|
6347
6181
|
} catch {}
|
|
6348
|
-
return
|
|
6182
|
+
return n;
|
|
6349
6183
|
}));
|
|
6350
6184
|
return e.json({
|
|
6351
|
-
items:
|
|
6352
|
-
total:
|
|
6353
|
-
hasMore:
|
|
6354
|
-
offset:
|
|
6355
|
-
limit:
|
|
6185
|
+
items: T,
|
|
6186
|
+
total: g,
|
|
6187
|
+
hasMore: d + T.length < g,
|
|
6188
|
+
offset: d,
|
|
6189
|
+
limit: u
|
|
6356
6190
|
});
|
|
6357
6191
|
}), X.post("/", async (e) => {
|
|
6358
|
-
let t = e.get("db"), n = await e.req.json(), r = n.node || n.activeNode || n, i = r.id || n.id, a = i != null && i !== "" && !isNaN(Number(i)) ? Number(i) : null, { title: o, slug: s, language: c, nodeType: l, contentType: u, isHidden: d, hidden: f, is_hidden: p, blocks: m, channels: h, trees: g, attachedAssets: _, ...v } = r,
|
|
6192
|
+
let t = e.get("db"), n = await e.req.json(), r = n.node || n.activeNode || n, i = r.id || n.id, a = i != null && i !== "" && !isNaN(Number(i)) ? Number(i) : null, { title: o, slug: s, language: c, nodeType: l, contentType: u, isHidden: d, hidden: f, is_hidden: p, blocks: m, channels: h, trees: g, attachedAssets: _, ...v } = r, y = hi(v), b = pi(d === void 0 ? f === void 0 ? p : f : d), x = c || "en", S = l || u || "page", C = e.get("user")?.id || null, w = a, T = [];
|
|
6359
6193
|
if (a) {
|
|
6360
6194
|
let e = await t.prepare("SELECT assetId FROM node_assets WHERE nodeId = ?").all(a);
|
|
6361
6195
|
T = (Array.isArray(e) ? e : e?.results || []).map((e) => e.assetId);
|
|
6362
6196
|
}
|
|
6363
|
-
let E = s === void 0 ? null :
|
|
6197
|
+
let E = s === void 0 ? null : fi(s);
|
|
6364
6198
|
if (E) {
|
|
6365
6199
|
let n = !1, r = [];
|
|
6366
6200
|
if (g !== void 0 && Array.isArray(g) && g.length > 0) for (let e of g) r.push({
|
|
6367
6201
|
treeId: Number(e.treeId),
|
|
6368
|
-
parentId:
|
|
6202
|
+
parentId: mi(e.parentId ?? e._draftParentId ?? null)
|
|
6369
6203
|
});
|
|
6370
6204
|
else if (a) {
|
|
6371
6205
|
let e = await t.prepare("SELECT treeId, parentId FROM tree_nodes WHERE contentId = ?").all(a), n = Array.isArray(e) ? e : e?.results || [];
|
|
@@ -6397,7 +6231,7 @@ X.get("/", async (e) => {
|
|
|
6397
6231
|
c = JSON.parse(e?.draftDataJson || "{}");
|
|
6398
6232
|
} catch {}
|
|
6399
6233
|
let l = {
|
|
6400
|
-
...
|
|
6234
|
+
...hi(c),
|
|
6401
6235
|
...y,
|
|
6402
6236
|
nodeType: i,
|
|
6403
6237
|
contentType: i
|
|
@@ -6429,17 +6263,17 @@ X.get("/", async (e) => {
|
|
|
6429
6263
|
params: [w]
|
|
6430
6264
|
});
|
|
6431
6265
|
let e = [...new Set(h.map((e) => typeof e == "object" && e ? e.id || e.channelId : e))].filter((e) => e && e !== "all").map((e) => Number(e) || e);
|
|
6432
|
-
|
|
6433
|
-
let
|
|
6266
|
+
for (let t = 0; t < e.length; t += 40) {
|
|
6267
|
+
let n = e.slice(t, t + 40), r = n.map(() => "(?, ?)").join(", "), i = n.flatMap((e) => [w, e]);
|
|
6434
6268
|
D.push({
|
|
6435
|
-
sql: `INSERT OR IGNORE INTO node_channels (nodeId, channelId) VALUES ${
|
|
6436
|
-
params:
|
|
6269
|
+
sql: `INSERT OR IGNORE INTO node_channels (nodeId, channelId) VALUES ${r}`,
|
|
6270
|
+
params: i
|
|
6437
6271
|
});
|
|
6438
6272
|
}
|
|
6439
6273
|
}
|
|
6440
6274
|
if (g !== void 0 && Array.isArray(g) && g.length > 0 && w) for (let e of g) {
|
|
6441
6275
|
if (!e || !e.treeId) continue;
|
|
6442
|
-
let n = Number(e.treeId) || e.treeId, r =
|
|
6276
|
+
let n = Number(e.treeId) || e.treeId, r = mi(e.parentId ?? e._draftParentId ?? null), i = typeof e.sortOrder == "number" ? e.sortOrder : 0, a = await t.prepare("SELECT id FROM tree_nodes WHERE treeId = ? AND contentId = ?").get(n, w);
|
|
6443
6277
|
a ? D.push({
|
|
6444
6278
|
sql: "UPDATE tree_nodes SET parentId = ?, sortOrder = ? WHERE id = ?",
|
|
6445
6279
|
params: [
|
|
@@ -6462,37 +6296,42 @@ X.get("/", async (e) => {
|
|
|
6462
6296
|
sql: "DELETE FROM content_blocks WHERE contentId = ? AND isDraft = 1",
|
|
6463
6297
|
params: [w]
|
|
6464
6298
|
});
|
|
6465
|
-
let e =
|
|
6466
|
-
|
|
6467
|
-
let
|
|
6468
|
-
|
|
6469
|
-
|
|
6470
|
-
|
|
6299
|
+
for (let e = 0; e < m.length; e += 15) {
|
|
6300
|
+
let t = m.slice(e, e + 15), n = [], r = [];
|
|
6301
|
+
for (let i = 0; i < t.length; i++) {
|
|
6302
|
+
let a = t[i], o = String(a.blockId || a.data?.blockId || a.instanceId || a.id || `block-${Date.now()}`), s = {
|
|
6303
|
+
...a.data || {},
|
|
6304
|
+
blockId: o
|
|
6305
|
+
};
|
|
6306
|
+
delete s._instanceId, n.push("(?, ?, ?, ?, ?, 1)"), r.push(w, e + i, a.componentId || a.elementType || "text-block", JSON.stringify(s), a.region || "content");
|
|
6307
|
+
}
|
|
6308
|
+
n.length > 0 && D.push({
|
|
6309
|
+
sql: `INSERT INTO content_blocks (contentId, sortOrder, elementType, dataJson, region, isDraft) VALUES ${n.join(", ")}`,
|
|
6310
|
+
params: r
|
|
6471
6311
|
});
|
|
6472
|
-
e.push("(?, ?, ?, ?, ?, 1)"), t.push(w, n, r.componentId || r.elementType || "text-block", JSON.stringify(a), r.region || "content");
|
|
6473
6312
|
}
|
|
6474
|
-
e.length > 0 && D.push({
|
|
6475
|
-
sql: `INSERT INTO content_blocks (contentId, sortOrder, elementType, dataJson, region, isDraft) VALUES ${e.join(", ")}`,
|
|
6476
|
-
params: t
|
|
6477
|
-
});
|
|
6478
6313
|
}
|
|
6479
6314
|
let O = /* @__PURE__ */ new Set();
|
|
6480
6315
|
if (w && Array.isArray(_)) {
|
|
6481
6316
|
let e = [...new Set(_)].filter((e) => typeof e == "string" && e.startsWith("ast_"));
|
|
6482
|
-
|
|
6317
|
+
O = new Set(e), D.push({
|
|
6483
6318
|
sql: "DELETE FROM node_assets WHERE nodeId = ?",
|
|
6484
6319
|
params: [w]
|
|
6485
|
-
})
|
|
6486
|
-
|
|
6320
|
+
});
|
|
6321
|
+
let t = Array.from(e);
|
|
6322
|
+
for (let e = 0; e < t.length; e += 40) {
|
|
6323
|
+
let n = t.slice(e, e + 40), r = n.map(() => "(?, ?)").join(", "), i = n.flatMap((e) => [w, e]);
|
|
6487
6324
|
D.push({
|
|
6488
|
-
sql: `INSERT OR IGNORE INTO node_assets (nodeId, assetId) VALUES ${
|
|
6489
|
-
params:
|
|
6325
|
+
sql: `INSERT OR IGNORE INTO node_assets (nodeId, assetId) VALUES ${r}`,
|
|
6326
|
+
params: i
|
|
6490
6327
|
});
|
|
6491
6328
|
}
|
|
6492
6329
|
}
|
|
6493
6330
|
if (D.length > 0 && await t.batch(D), w && Array.isArray(_)) {
|
|
6494
6331
|
let n = new Set([...T].filter((e) => !O.has(e)));
|
|
6495
|
-
n.size > 0 && Z(e,
|
|
6332
|
+
n.size > 0 && Z(e, async () => {
|
|
6333
|
+
for (let e of n) (await ui(t, "SELECT 1 FROM node_assets WHERE assetId = ? LIMIT 1", [e])).length > 0 || await di(t, "DELETE FROM assets WHERE id = ?", [e]);
|
|
6334
|
+
});
|
|
6496
6335
|
}
|
|
6497
6336
|
return Z(e, J(e).clear()), e.json({
|
|
6498
6337
|
success: !0,
|
|
@@ -6504,64 +6343,46 @@ X.get("/", async (e) => {
|
|
|
6504
6343
|
if (!r || isNaN(Number(r))) return e.json({ error: "Node ID required for publishing" }, 400);
|
|
6505
6344
|
let i = Number(r), a = e.get("user")?.id || null, o = await t.prepare("SELECT * FROM content_nodes WHERE id = ?").get(i);
|
|
6506
6345
|
if (!o) return e.json({ error: "Node not found" }, 404);
|
|
6507
|
-
let s = {};
|
|
6508
|
-
|
|
6509
|
-
s = JSON.parse(o.publishedDataJson || "{}");
|
|
6510
|
-
} catch {}
|
|
6511
|
-
let c = {};
|
|
6512
|
-
try {
|
|
6513
|
-
c = JSON.parse(o.draftDataJson || "{}");
|
|
6514
|
-
} catch {}
|
|
6515
|
-
let l = (s.title ?? o.title ?? "").trim(), u = (c.title ?? n.title ?? o.title ?? "").trim(), d = (s.slug ?? o.slug ?? "").trim(), f = (c.slug ?? n.slug ?? o.slug ?? "").trim(), p = l !== "" && u !== "" && l !== u || d !== "" && f !== "" && d !== f, m = {
|
|
6516
|
-
...c,
|
|
6517
|
-
nodeType: o.contentType,
|
|
6518
|
-
contentType: o.contentType
|
|
6519
|
-
}, h = JSON.stringify(m), g = [];
|
|
6520
|
-
g.push({
|
|
6346
|
+
let s = o.publishedDataJson || "{}", c = !s.includes(`"slug":"${o.slug}"`) || !s.includes(`"title":"${o.title}"`), l = o.draftDataJson || o.dataJson || "{}", u = [];
|
|
6347
|
+
u.push({
|
|
6521
6348
|
sql: "UPDATE content_nodes SET publishedDataJson = ?, dataJson = ?, publishedAt = CURRENT_TIMESTAMP, status = 'published', updatedById = ?, updatedAt = CURRENT_TIMESTAMP WHERE id = ?",
|
|
6522
6349
|
params: [
|
|
6523
|
-
|
|
6524
|
-
|
|
6350
|
+
l,
|
|
6351
|
+
l,
|
|
6525
6352
|
a,
|
|
6526
6353
|
i
|
|
6527
6354
|
]
|
|
6528
|
-
}),
|
|
6355
|
+
}), u.push({
|
|
6529
6356
|
sql: "DELETE FROM content_blocks WHERE contentId = ? AND isDraft = 0",
|
|
6530
6357
|
params: [i]
|
|
6358
|
+
}), u.push({
|
|
6359
|
+
sql: "INSERT INTO content_blocks (contentId, sortOrder, elementType, dataJson, region, isDraft) \n SELECT contentId, sortOrder, elementType, dataJson, region, 0 \n FROM content_blocks \n WHERE contentId = ? AND isDraft = 1",
|
|
6360
|
+
params: [i]
|
|
6531
6361
|
});
|
|
6532
|
-
let
|
|
6533
|
-
|
|
6534
|
-
let e = [], t = [];
|
|
6535
|
-
for (let n of v) e.push("(?, ?, ?, ?, ?, 0)"), t.push(i, n.sortOrder, n.elementType, n.dataJson, n.region || "content");
|
|
6536
|
-
g.push({
|
|
6537
|
-
sql: `INSERT INTO content_blocks (contentId, sortOrder, elementType, dataJson, region, isDraft) VALUES ${e.join(", ")}`,
|
|
6538
|
-
params: t
|
|
6539
|
-
});
|
|
6540
|
-
}
|
|
6541
|
-
let y = ((await t.prepare("SELECT COUNT(*) as count FROM node_revisions WHERE nodeId = ?").get(i))?.count || 0) + 1, b = {
|
|
6542
|
-
version: y,
|
|
6362
|
+
let d = await t.prepare("SELECT * FROM content_blocks WHERE contentId = ? AND isDraft = 1 ORDER BY sortOrder ASC").all(i), f = Array.isArray(d) ? d : d?.results || [], p = ((await t.prepare("SELECT COUNT(*) as count FROM node_revisions WHERE nodeId = ?").get(i))?.count || 0) + 1, m = {
|
|
6363
|
+
version: p,
|
|
6543
6364
|
publishedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
6544
6365
|
node: {
|
|
6545
6366
|
...o,
|
|
6546
6367
|
contentType: o.contentType,
|
|
6547
|
-
dataJson:
|
|
6368
|
+
dataJson: l
|
|
6548
6369
|
},
|
|
6549
|
-
blocks:
|
|
6370
|
+
blocks: f
|
|
6550
6371
|
};
|
|
6551
|
-
return
|
|
6372
|
+
return u.push({
|
|
6552
6373
|
sql: "INSERT INTO node_revisions (nodeId, version, snapshotJson, createdById) VALUES (?, ?, ?, ?)",
|
|
6553
6374
|
params: [
|
|
6554
6375
|
i,
|
|
6555
|
-
|
|
6556
|
-
JSON.stringify(
|
|
6376
|
+
p,
|
|
6377
|
+
JSON.stringify(m),
|
|
6557
6378
|
a
|
|
6558
6379
|
]
|
|
6559
|
-
}), await t.batch(
|
|
6380
|
+
}), await t.batch(u), Z(e, new Y(e.env).purgeNode(e, t, i, c)), Z(e, J(e).clear()), e.json({
|
|
6560
6381
|
success: !0,
|
|
6561
6382
|
id: i,
|
|
6562
6383
|
status: "published",
|
|
6563
|
-
version:
|
|
6564
|
-
publishedAt:
|
|
6384
|
+
version: p,
|
|
6385
|
+
publishedAt: m.publishedAt
|
|
6565
6386
|
});
|
|
6566
6387
|
}), X.get("/revisions", async (e) => {
|
|
6567
6388
|
let t = e.get("db"), n = Number(e.req.query("id"));
|
|
@@ -6583,7 +6404,7 @@ X.get("/", async (e) => {
|
|
|
6583
6404
|
return e.json({ error: "Failed to parse snapshot" }, 500);
|
|
6584
6405
|
}
|
|
6585
6406
|
let o = typeof a.node?.dataJson == "string" ? JSON.parse(a.node.dataJson) : a.node?.dataJson || {};
|
|
6586
|
-
o = await
|
|
6407
|
+
o = await li(t, hi(o));
|
|
6587
6408
|
let s = {
|
|
6588
6409
|
...a.node,
|
|
6589
6410
|
...o,
|
|
@@ -6591,7 +6412,7 @@ X.get("/", async (e) => {
|
|
|
6591
6412
|
contentType: a.node?.contentType || a.node?.nodeType
|
|
6592
6413
|
}, c = a.blocks || [], l = await Promise.all(c.map(async (e) => {
|
|
6593
6414
|
let n = typeof e.dataJson == "string" ? JSON.parse(e.dataJson || "{}") : e.dataJson || {};
|
|
6594
|
-
n = await
|
|
6415
|
+
n = await li(t, n);
|
|
6595
6416
|
let r = n.blockId || n._instanceId || (n.id && !String(n.id).startsWith("ast_") ? n.id : null) || e.instanceId || String(e.id), i = { ...n };
|
|
6596
6417
|
return delete i._instanceId, {
|
|
6597
6418
|
instanceId: String(r),
|
|
@@ -6658,8 +6479,8 @@ X.get("/", async (e) => {
|
|
|
6658
6479
|
});
|
|
6659
6480
|
//#endregion
|
|
6660
6481
|
//#region server/routes/admin/trees.ts
|
|
6661
|
-
var
|
|
6662
|
-
function
|
|
6482
|
+
var _i = new n();
|
|
6483
|
+
function vi(e, t = null) {
|
|
6663
6484
|
let n = [];
|
|
6664
6485
|
for (let r = 0; r < e.length; r++) {
|
|
6665
6486
|
let i = e[r];
|
|
@@ -6671,19 +6492,19 @@ function wi(e, t = null) {
|
|
|
6671
6492
|
id: o,
|
|
6672
6493
|
parentId: t,
|
|
6673
6494
|
sortOrder: r
|
|
6674
|
-
}), i.children && Array.isArray(i.children) && i.children.length > 0 && n.push(...
|
|
6495
|
+
}), i.children && Array.isArray(i.children) && i.children.length > 0 && n.push(...vi(i.children, o)));
|
|
6675
6496
|
}
|
|
6676
6497
|
return n;
|
|
6677
6498
|
}
|
|
6678
|
-
function
|
|
6499
|
+
function yi(e) {
|
|
6679
6500
|
if (e == null || e === "null" || e === "" || typeof e == "string" && e.startsWith("draft-")) return null;
|
|
6680
6501
|
let t = Number(e);
|
|
6681
6502
|
return isNaN(t) ? null : t;
|
|
6682
6503
|
}
|
|
6683
|
-
function
|
|
6504
|
+
function bi(e) {
|
|
6684
6505
|
return +(e === !0 || e === 1 || e === "1" || e === "true");
|
|
6685
6506
|
}
|
|
6686
|
-
|
|
6507
|
+
_i.get("/tree.json", async (e) => {
|
|
6687
6508
|
try {
|
|
6688
6509
|
let t = e.get("db"), n = e.req.query("treeId") || "main-nav", r = e.req.query("preview") === "true", i = 1;
|
|
6689
6510
|
if (isNaN(Number(n))) {
|
|
@@ -6733,7 +6554,7 @@ Ci.get("/tree.json", async (e) => {
|
|
|
6733
6554
|
} catch (t) {
|
|
6734
6555
|
return console.error("[CMS Tree API] GET Error:", t), e.json({ error: t.message || "Failed to fetch tree" }, 500);
|
|
6735
6556
|
}
|
|
6736
|
-
}),
|
|
6557
|
+
}), _i.post("/tree.json", async (e) => {
|
|
6737
6558
|
try {
|
|
6738
6559
|
let t = e.get("db"), n = await e.req.json(), r = n.treeId ? String(n.treeId).trim() : "main-nav", i = J(e), a = new Y(e.env), o = 1;
|
|
6739
6560
|
if (isNaN(Number(r))) {
|
|
@@ -6745,7 +6566,7 @@ Ci.get("/tree.json", async (e) => {
|
|
|
6745
6566
|
}
|
|
6746
6567
|
} else o = Number(r);
|
|
6747
6568
|
if (n.tree && Array.isArray(n.tree)) {
|
|
6748
|
-
let r =
|
|
6569
|
+
let r = vi(n.tree, null);
|
|
6749
6570
|
if (r.length > 0) for (let e = 0; e < r.length; e += 15) {
|
|
6750
6571
|
let n = r.slice(e, e + 15), i = n.map((e) => e.id), a = i.map(() => "?").join(","), s = "UPDATE tree_nodes SET \n";
|
|
6751
6572
|
s += "parentId = CASE id \n", n.forEach(() => {
|
|
@@ -6765,9 +6586,9 @@ Ci.get("/tree.json", async (e) => {
|
|
|
6765
6586
|
reorderedCount: r.length
|
|
6766
6587
|
});
|
|
6767
6588
|
}
|
|
6768
|
-
let { action: s, title: c, nodeType: l, parentId: u, contentId: d, nodeData: f = {}, pageData: p = {} } = n, m = Object.keys(f).length > 0 ? { ...f } : { ...p }, h =
|
|
6589
|
+
let { action: s, title: c, nodeType: l, parentId: u, contentId: d, nodeData: f = {}, pageData: p = {} } = n, m = Object.keys(f).length > 0 ? { ...f } : { ...p }, h = bi(n.isHidden === void 0 ? m.isHidden === void 0 ? m.hidden : m.isHidden : n.isHidden);
|
|
6769
6590
|
delete m._isTreeDraft, delete m._draftParentId, delete m.isNew, delete m.nodeType, delete m.contentType, delete m.title, delete m.slug, delete m.hidden, delete m.is_hidden, delete m.isHidden, delete m.status;
|
|
6770
|
-
let g =
|
|
6591
|
+
let g = yi(u), _ = e.get("user")?.id || null;
|
|
6771
6592
|
if (s === "create") {
|
|
6772
6593
|
let r = m.slug || n.slug || c, s = r ? String(r).toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/(^-|-$)/g, "") : null;
|
|
6773
6594
|
if (s) {
|
|
@@ -6856,7 +6677,7 @@ Ci.get("/tree.json", async (e) => {
|
|
|
6856
6677
|
details: t.message
|
|
6857
6678
|
}, 500);
|
|
6858
6679
|
}
|
|
6859
|
-
}),
|
|
6680
|
+
}), _i.get("/trees.json", async (e) => {
|
|
6860
6681
|
try {
|
|
6861
6682
|
let t = e.get("db"), n = await t.prepare("SELECT * FROM trees ORDER BY LOWER(label) ASC").all(), r = Array.isArray(n) ? n : n?.results || [], i = await t.prepare("SELECT channelId, treeId FROM channel_trees").all(), a = (Array.isArray(i) ? i : i?.results || []).reduce((e, t) => {
|
|
6862
6683
|
let n = Number(t.treeId), r = Number(t.channelId);
|
|
@@ -6886,7 +6707,7 @@ Ci.get("/tree.json", async (e) => {
|
|
|
6886
6707
|
} catch {
|
|
6887
6708
|
return e.json([]);
|
|
6888
6709
|
}
|
|
6889
|
-
}),
|
|
6710
|
+
}), _i.post("/trees.json", async (e) => {
|
|
6890
6711
|
try {
|
|
6891
6712
|
let t = e.get("db"), n = await e.req.json(), r = n.id, i = r != null && r !== "" && !isNaN(Number(r)) ? Number(r) : null, a = `tree-${Date.now().toString(36)}`, o = (n.key || n.slug || a).toLowerCase().replace(/[^a-z0-9_-]/g, "-"), s = n.label?.trim() || o, c = n.treeType !== void 0 && n.treeType !== null ? n.treeType : n.type ?? "site", l = n.channelId !== void 0 && n.channelId !== null && Number(n.channelId) || null, u = +(n.isHidden === !0 || n.isHidden === 1 || n.isHidden === "true"), d = e.get("user")?.id || null, f = { ...n };
|
|
6892
6713
|
if (delete f.id, delete f.key, delete f.label, delete f.treeType, delete f.type, delete f.channelId, delete f.channels, delete f.isHidden, delete f.createdById, delete f.updatedById, delete f.createdAt, delete f.updatedAt, await t.prepare("SELECT id FROM trees WHERE key = ? AND id != ? LIMIT 1").get(o, i ?? -1)) return e.json({
|
|
@@ -6925,7 +6746,7 @@ Ci.get("/tree.json", async (e) => {
|
|
|
6925
6746
|
} catch (t) {
|
|
6926
6747
|
return console.error("[API Trees] Error saving tree:", t), e.json({ error: t.message || "Failed to save tree" }, 500);
|
|
6927
6748
|
}
|
|
6928
|
-
}),
|
|
6749
|
+
}), _i.delete("/trees.json", async (e) => {
|
|
6929
6750
|
let t = e.get("db"), n = e.req.query("id");
|
|
6930
6751
|
if (!n) return e.json({ error: "Tree ID required" }, 400);
|
|
6931
6752
|
let r = Number(n);
|
|
@@ -6940,8 +6761,8 @@ Ci.get("/tree.json", async (e) => {
|
|
|
6940
6761
|
});
|
|
6941
6762
|
//#endregion
|
|
6942
6763
|
//#region server/routes/admin/channels.ts
|
|
6943
|
-
var
|
|
6944
|
-
|
|
6764
|
+
var xi = new n();
|
|
6765
|
+
xi.get("/", async (e) => {
|
|
6945
6766
|
try {
|
|
6946
6767
|
let t = e.get("db"), n = await t.prepare("SELECT * FROM channels ORDER BY id ASC").all(), r = Array.isArray(n) ? n : n?.results || [], i = await t.prepare("SELECT channelId, treeId, key, metaJson FROM channel_trees ORDER BY rowid ASC").all(), a = ((Array.isArray(i) ? i : i?.results || []) || []).reduce((e, t) => {
|
|
6947
6768
|
e[t.channelId] || (e[t.channelId] = []);
|
|
@@ -7009,7 +6830,7 @@ Di.get("/", async (e) => {
|
|
|
7009
6830
|
error: t.message
|
|
7010
6831
|
}, 500);
|
|
7011
6832
|
}
|
|
7012
|
-
}),
|
|
6833
|
+
}), xi.post("/", async (e) => {
|
|
7013
6834
|
try {
|
|
7014
6835
|
let t = e.get("db"), n = await e.req.json(), r = n.id, i = r != null && r !== "" && !isNaN(Number(r)) ? Number(r) : null, { key: a, label: o, channelType: s, domain: c, baseUrl: l, defaultLanguage: u, isHidden: d = !1, trees: f = [], createdById: p = null, updatedById: m = null, id: h, createdAt: g, updatedAt: _, ...v } = n, y = a?.trim() || "main", b = o?.trim() || "Untitled Channel", x = s ?? "website", S = c ?? "localhost", C = l ?? "http://localhost:4321", w = u ?? "en", T = JSON.stringify(v || {}), E = e.get("user")?.id || m || p, D = E === void 0 ? null : E;
|
|
7015
6836
|
if (await t.prepare("SELECT id FROM channels WHERE key = ? AND id != ? LIMIT 1").get(y, i ?? -1)) return e.json({
|
|
@@ -7049,7 +6870,7 @@ Di.get("/", async (e) => {
|
|
|
7049
6870
|
details: t.message
|
|
7050
6871
|
}, 500);
|
|
7051
6872
|
}
|
|
7052
|
-
}),
|
|
6873
|
+
}), xi.delete("/", async (e) => {
|
|
7053
6874
|
let t = e.get("db"), n = e.req.query("id");
|
|
7054
6875
|
if (!n) return e.json({ error: "Channel ID required" }, 400);
|
|
7055
6876
|
let r = Number(n);
|
|
@@ -7067,7 +6888,7 @@ Di.get("/", async (e) => {
|
|
|
7067
6888
|
});
|
|
7068
6889
|
//#endregion
|
|
7069
6890
|
//#region server/db/bundled-definitions.ts
|
|
7070
|
-
var
|
|
6891
|
+
var Si = {
|
|
7071
6892
|
nodes: {
|
|
7072
6893
|
address: {
|
|
7073
6894
|
id: "address",
|
|
@@ -11774,11 +11595,11 @@ var Oi = {
|
|
|
11774
11595
|
treeTemplate: null,
|
|
11775
11596
|
channelTemplate: null,
|
|
11776
11597
|
userTemplate: null
|
|
11777
|
-
},
|
|
11598
|
+
}, Ci = new n(), wi = null, Ti = (e) => {
|
|
11778
11599
|
try {
|
|
11779
11600
|
let t = process.env.NODE_ENV !== "production";
|
|
11780
|
-
if (!
|
|
11781
|
-
let t = e.env?.BUNDLED_DEFINITIONS ||
|
|
11601
|
+
if (!wi || t) {
|
|
11602
|
+
let t = e.env?.BUNDLED_DEFINITIONS || Si || {}, n = jr(t) || {}, r = e.get("schemas") || {}, i = r.rawChannels || {}, a = r.rawNodes || {}, o = r.rawTrees || {}, s = r.rawBlocks || {}, c = r.rawNodeLayouts || {}, l = r.rawBlockLayouts || {}, u = t.rawChannels || t.channels || n.channels || {}, d = t.rawNodes || t.nodes || n.nodes || {}, f = t.rawTrees || t.trees || n.trees || {}, p = t.rawBlocks || t.blocks || n.blocks || {}, m = t.rawNodeLayouts || t.nodeLayouts || n.nodeLayouts || {}, h = t.rawBlockLayouts || t.blockLayouts || n.blockLayouts || {}, g = Object.keys(i).length > 0 ? i : u, _ = Object.keys(a).length > 0 ? a : d, v = Object.keys(o).length > 0 ? o : f, y = Object.keys(s).length > 0 ? s : p, b = Object.keys(c).length > 0 ? c : m, x = Object.keys(l).length > 0 ? l : h, S = n.userTemplate || {
|
|
11782
11603
|
id: "userTemplate",
|
|
11783
11604
|
label: "User Account",
|
|
11784
11605
|
fields: {
|
|
@@ -11814,7 +11635,7 @@ var Oi = {
|
|
|
11814
11635
|
}
|
|
11815
11636
|
}
|
|
11816
11637
|
}, C = Object.keys(g)[0];
|
|
11817
|
-
|
|
11638
|
+
wi = {
|
|
11818
11639
|
channelTemplate: n.channelTemplate || (C ? g[C] : null),
|
|
11819
11640
|
treeTemplate: n.treeTemplate || null,
|
|
11820
11641
|
userTemplate: S,
|
|
@@ -11829,7 +11650,7 @@ var Oi = {
|
|
|
11829
11650
|
blockLayouts: x
|
|
11830
11651
|
};
|
|
11831
11652
|
}
|
|
11832
|
-
return e.json(
|
|
11653
|
+
return e.json(wi, 200, { "Cache-Control": "no-cache, no-store, must-revalidate" });
|
|
11833
11654
|
} catch (t) {
|
|
11834
11655
|
return console.error("[CMS API] Error loading schemas:", t), e.json({
|
|
11835
11656
|
error: "Failed to load schemas",
|
|
@@ -11837,10 +11658,10 @@ var Oi = {
|
|
|
11837
11658
|
}, 500);
|
|
11838
11659
|
}
|
|
11839
11660
|
};
|
|
11840
|
-
|
|
11661
|
+
Ci.get("/", Ti), Ci.get("/schemas.json", Ti);
|
|
11841
11662
|
//#endregion
|
|
11842
11663
|
//#region server/routes/admin/validation.ts
|
|
11843
|
-
var
|
|
11664
|
+
var Ei = new n(), Di = {
|
|
11844
11665
|
node: "content_nodes",
|
|
11845
11666
|
nodes: "content_nodes",
|
|
11846
11667
|
content_node: "content_nodes",
|
|
@@ -11852,7 +11673,7 @@ var Mi = new n(), Ni = {
|
|
|
11852
11673
|
user: "users",
|
|
11853
11674
|
users: "users",
|
|
11854
11675
|
user_account: "user_accounts"
|
|
11855
|
-
},
|
|
11676
|
+
}, Oi = {
|
|
11856
11677
|
content_nodes: [
|
|
11857
11678
|
"id",
|
|
11858
11679
|
"title",
|
|
@@ -11909,11 +11730,11 @@ var Mi = new n(), Ni = {
|
|
|
11909
11730
|
"createdAt"
|
|
11910
11731
|
]
|
|
11911
11732
|
};
|
|
11912
|
-
|
|
11733
|
+
Ei.post("/validate-unique", async (e) => {
|
|
11913
11734
|
try {
|
|
11914
11735
|
let t = e.get("db"), { entityType: n, field: r, value: i, excludeId: a } = await e.req.json();
|
|
11915
11736
|
if (!r || i == null || String(i).trim() === "") return e.json({ isUnique: !0 });
|
|
11916
|
-
let o =
|
|
11737
|
+
let o = Di[n] || "content_nodes", s = r.replace(/[^a-zA-Z0-9_]/g, ""), c = (Oi[o] || Oi.content_nodes).includes(s), l = -1;
|
|
11917
11738
|
if (a != null && String(a).trim() !== "") {
|
|
11918
11739
|
let e = Number(a);
|
|
11919
11740
|
l = isNaN(e) ? String(a) : e;
|
|
@@ -11925,7 +11746,7 @@ Mi.post("/validate-unique", async (e) => {
|
|
|
11925
11746
|
} catch (t) {
|
|
11926
11747
|
return console.error("[API Validation] Error validating global uniqueness:", t), e.json({ error: "Failed to validate uniqueness" }, 500);
|
|
11927
11748
|
}
|
|
11928
|
-
}),
|
|
11749
|
+
}), Ei.post("/validate-unique-sibling", async (e) => {
|
|
11929
11750
|
try {
|
|
11930
11751
|
let t = e.get("db"), { slug: n, treeId: r, parentId: i, excludeTreeNodeId: a } = await e.req.json();
|
|
11931
11752
|
if (!n || !String(n).trim() || !r) return e.json({ isUnique: !0 });
|
|
@@ -11953,8 +11774,8 @@ Mi.post("/validate-unique", async (e) => {
|
|
|
11953
11774
|
});
|
|
11954
11775
|
//#endregion
|
|
11955
11776
|
//#region server/routes/admin/stats.ts
|
|
11956
|
-
var
|
|
11957
|
-
|
|
11777
|
+
var ki = new n();
|
|
11778
|
+
ki.get("/", async (e) => {
|
|
11958
11779
|
try {
|
|
11959
11780
|
let t = e.get("db"), n = await t.prepare("\n SELECT \n COUNT(*) as total,\n SUM(CASE WHEN isHidden = 0 THEN 1 ELSE 0 END) as published,\n SUM(CASE WHEN isHidden = 1 THEN 1 ELSE 0 END) as hidden\n FROM content_nodes\n ").get(), r = Number(n?.total) || 0, i = Number(n?.published) || 0, a = Number(n?.hidden) || 0, o = await t.prepare("\n SELECT \n (SELECT COUNT(*) FROM channels) as totalChannels,\n (SELECT COUNT(*) FROM trees) as totalTrees,\n (SELECT COUNT(*) FROM users) as totalUsers\n ").get(), s = await t.prepare("\n SELECT contentType as type, COUNT(*) as count \n FROM content_nodes \n GROUP BY contentType \n ORDER BY count DESC\n ").all(), c = Array.isArray(s) ? s : s?.results || [], l = await t.prepare("\n SELECT id, title, slug, contentType, isHidden, status, updatedAt \n FROM content_nodes \n ORDER BY updatedAt DESC \n LIMIT 5\n ").all(), u = (Array.isArray(l) ? l : l?.results || []).map((e) => ({
|
|
11960
11781
|
...e,
|
|
@@ -11996,8 +11817,89 @@ Fi.get("/", async (e) => {
|
|
|
11996
11817
|
}
|
|
11997
11818
|
});
|
|
11998
11819
|
//#endregion
|
|
11820
|
+
//#region server/storage/provider.ts
|
|
11821
|
+
function Ai(e) {
|
|
11822
|
+
let t = e.split(".").pop()?.toLowerCase() || "bin";
|
|
11823
|
+
return t = t.replace(/[^a-z0-9]/g, ""), [
|
|
11824
|
+
"php",
|
|
11825
|
+
"exe",
|
|
11826
|
+
"sh",
|
|
11827
|
+
"bat",
|
|
11828
|
+
"cmd",
|
|
11829
|
+
"html",
|
|
11830
|
+
"htm",
|
|
11831
|
+
"js",
|
|
11832
|
+
"mjs",
|
|
11833
|
+
"cjs"
|
|
11834
|
+
].includes(t) ? "bin" : t;
|
|
11835
|
+
}
|
|
11836
|
+
var ji = class {
|
|
11837
|
+
bucket;
|
|
11838
|
+
publicDomain;
|
|
11839
|
+
constructor(e, t) {
|
|
11840
|
+
this.bucket = e, this.publicDomain = t;
|
|
11841
|
+
}
|
|
11842
|
+
async upload(e, t = "uploads") {
|
|
11843
|
+
let n = Ai(e.name), r = `${t}/${crypto.randomUUID().replace(/-/g, "")}.${n}`;
|
|
11844
|
+
return await this.bucket.put(r, e.stream(), { httpMetadata: { contentType: e.type } }), {
|
|
11845
|
+
key: r,
|
|
11846
|
+
url: `/media/${r.replace(/^\//, "")}`
|
|
11847
|
+
};
|
|
11848
|
+
}
|
|
11849
|
+
async delete(e) {
|
|
11850
|
+
await this.bucket.delete(e);
|
|
11851
|
+
}
|
|
11852
|
+
}, Mi = class {
|
|
11853
|
+
customStoragePath;
|
|
11854
|
+
constructor(e) {
|
|
11855
|
+
this.customStoragePath = e;
|
|
11856
|
+
}
|
|
11857
|
+
async upload(e, t = "uploads") {
|
|
11858
|
+
let n = await import(
|
|
11859
|
+
/* @vite-ignore */
|
|
11860
|
+
"node:path"
|
|
11861
|
+
), r = await import(
|
|
11862
|
+
/* @vite-ignore */
|
|
11863
|
+
"node:fs"
|
|
11864
|
+
), i = await import(
|
|
11865
|
+
/* @vite-ignore */
|
|
11866
|
+
"node:fs/promises"
|
|
11867
|
+
), { pipeline: a } = await import(
|
|
11868
|
+
/* @vite-ignore */
|
|
11869
|
+
"node:stream/promises"
|
|
11870
|
+
), o = Ai(e.name), s = `${t}/${crypto.randomUUID().replace(/-/g, "")}.${o}`, c = this.customStoragePath || "./public/media", l = n.resolve(process.cwd(), c), u = n.join(l, s);
|
|
11871
|
+
await i.mkdir(n.dirname(u), { recursive: !0 });
|
|
11872
|
+
let d = r.createWriteStream(u);
|
|
11873
|
+
return await a(e.stream(), d), {
|
|
11874
|
+
key: s,
|
|
11875
|
+
url: `/media/${s}`
|
|
11876
|
+
};
|
|
11877
|
+
}
|
|
11878
|
+
async delete(e) {
|
|
11879
|
+
let t = await import(
|
|
11880
|
+
/* @vite-ignore */
|
|
11881
|
+
"node:path"
|
|
11882
|
+
), n = await import(
|
|
11883
|
+
/* @vite-ignore */
|
|
11884
|
+
"node:fs/promises"
|
|
11885
|
+
), r = this.customStoragePath || "./public/media", i = t.resolve(process.cwd(), r), a = t.join(i, e);
|
|
11886
|
+
try {
|
|
11887
|
+
await n.unlink(a);
|
|
11888
|
+
} catch (e) {
|
|
11889
|
+
if (e.code !== "ENOENT") throw e;
|
|
11890
|
+
}
|
|
11891
|
+
}
|
|
11892
|
+
};
|
|
11893
|
+
function Ni(e) {
|
|
11894
|
+
if (e.MEDIA_BUCKET) {
|
|
11895
|
+
let t = e.CDN_DOMAIN || "cdn.yourdomain.com";
|
|
11896
|
+
return new ji(e.MEDIA_BUCKET, t);
|
|
11897
|
+
}
|
|
11898
|
+
return new Mi(e.LOCAL_MEDIA_PATH);
|
|
11899
|
+
}
|
|
11900
|
+
//#endregion
|
|
11999
11901
|
//#region server/routes/admin/assets.ts
|
|
12000
|
-
var
|
|
11902
|
+
var Pi = new n();
|
|
12001
11903
|
async function Q(e, t, n = []) {
|
|
12002
11904
|
let r = e.prepare(t);
|
|
12003
11905
|
if (typeof r.bind == "function") {
|
|
@@ -12010,19 +11912,19 @@ async function Q(e, t, n = []) {
|
|
|
12010
11912
|
}
|
|
12011
11913
|
return [];
|
|
12012
11914
|
}
|
|
12013
|
-
async function
|
|
11915
|
+
async function Fi(e, t, n = []) {
|
|
12014
11916
|
let r = e.prepare(t);
|
|
12015
11917
|
if (typeof r.bind == "function") return await r.bind(...n).run();
|
|
12016
11918
|
if (typeof r.run == "function") return await r.run(...n);
|
|
12017
11919
|
}
|
|
12018
|
-
function
|
|
11920
|
+
function Ii(e, t) {
|
|
12019
11921
|
let n = e || (t ? `/media/${t}` : "");
|
|
12020
11922
|
try {
|
|
12021
11923
|
n.startsWith("http") && (n = new URL(n).pathname);
|
|
12022
11924
|
} catch {}
|
|
12023
11925
|
return n.startsWith("/media/") || (n = `/media/${n.replace(/^\/+/, "")}`), n;
|
|
12024
11926
|
}
|
|
12025
|
-
|
|
11927
|
+
Pi.get("/", async (e) => {
|
|
12026
11928
|
try {
|
|
12027
11929
|
let t = Rr(e), { search: n = "", type: r = "all", page: i = "1", limit: a = "24", sort: o = "createdAt", order: s = "DESC", nodeId: c, channelId: l, trashed: u } = e.req.query(), d = Math.max(1, parseInt(i, 10) || 1), f = Math.max(1, Math.min(100, parseInt(a, 10) || 24)), p = (d - 1) * f, m = {
|
|
12028
11930
|
createdAt: "a.createdAt",
|
|
@@ -12089,7 +11991,7 @@ Ii.get("/", async (e) => {
|
|
|
12089
11991
|
...JSON.parse(e.dataJson || "{}")
|
|
12090
11992
|
};
|
|
12091
11993
|
} catch {}
|
|
12092
|
-
let n =
|
|
11994
|
+
let n = Ii(e.cdnUrl, e.storageKeyPrivate);
|
|
12093
11995
|
return {
|
|
12094
11996
|
id: e.id,
|
|
12095
11997
|
filename: e.filename || "Untitled Asset",
|
|
@@ -12113,9 +12015,9 @@ Ii.get("/", async (e) => {
|
|
|
12113
12015
|
details: t.message || String(t)
|
|
12114
12016
|
}, 500);
|
|
12115
12017
|
}
|
|
12116
|
-
}),
|
|
12018
|
+
}), Pi.post("/upload", async (e) => {
|
|
12117
12019
|
try {
|
|
12118
|
-
let t = Rr(e), n =
|
|
12020
|
+
let t = Rr(e), n = Ni(e.env), r = await e.req.parseBody(), i = r.file, a = r.isVariant === "true" || r.isVariant === "1" || r.temporary === "true", o = r.parentAssetId || r.parentAsset, s = typeof o == "string" && o.trim().length > 0 ? o.trim() : null;
|
|
12119
12021
|
s && (await Q(t, "SELECT id FROM assets WHERE id = ?", [s])).length === 0 && (s = null);
|
|
12120
12022
|
let c = r.cropCoordinates, l = null, u = null;
|
|
12121
12023
|
if (c) {
|
|
@@ -12132,7 +12034,7 @@ Ii.get("/", async (e) => {
|
|
|
12132
12034
|
let v = `/media/${_.replace(/^\//, "")}`, y = i.type || "application/octet-stream", b = i.size || 0, x = e.get("userId"), S = typeof x == "string" && x.trim().length > 0 ? x : null;
|
|
12133
12035
|
S && (await Q(t, "SELECT id FROM users WHERE id = ?", [S])).length === 0 && (S = null);
|
|
12134
12036
|
let C = +!!m;
|
|
12135
|
-
await
|
|
12037
|
+
await Fi(t, "\n INSERT INTO assets (id, filename, mimeType, sizeBytes, storageKeyPrivate, cdnUrl, createdById, isSystemVariant, parentAssetId, cropCoordinatesJson)\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)\n ", [
|
|
12136
12038
|
f,
|
|
12137
12039
|
i.name,
|
|
12138
12040
|
y,
|
|
@@ -12147,7 +12049,7 @@ Ii.get("/", async (e) => {
|
|
|
12147
12049
|
let w = v;
|
|
12148
12050
|
if (s) {
|
|
12149
12051
|
let n = await Q(t, "SELECT cdnUrl, storageKeyPrivate FROM assets WHERE id = ?", [s]);
|
|
12150
|
-
n.length > 0 && (w =
|
|
12052
|
+
n.length > 0 && (w = Ii(n[0].cdnUrl, n[0].storageKeyPrivate)), new Y(e.env).purgeAsset(e, t, s);
|
|
12151
12053
|
}
|
|
12152
12054
|
return e.json({
|
|
12153
12055
|
id: f,
|
|
@@ -12166,7 +12068,7 @@ Ii.get("/", async (e) => {
|
|
|
12166
12068
|
details: t.message || String(t)
|
|
12167
12069
|
}, 500);
|
|
12168
12070
|
}
|
|
12169
|
-
}),
|
|
12071
|
+
}), Pi.get("/:id/details", async (e) => {
|
|
12170
12072
|
try {
|
|
12171
12073
|
let t = Rr(e), n = e.req.param("id"), r = await Q(t, "SELECT * FROM assets WHERE id = ?", [n]);
|
|
12172
12074
|
if (!r || r.length === 0) return e.json({ error: "Asset not found" }, 404);
|
|
@@ -12189,7 +12091,7 @@ Ii.get("/", async (e) => {
|
|
|
12189
12091
|
...JSON.parse(i.dataJson || "{}")
|
|
12190
12092
|
};
|
|
12191
12093
|
} catch {}
|
|
12192
|
-
let l =
|
|
12094
|
+
let l = Ii(i.cdnUrl, i.storageKeyPrivate);
|
|
12193
12095
|
return e.json({
|
|
12194
12096
|
id: i.id,
|
|
12195
12097
|
filename: i.filename,
|
|
@@ -12216,7 +12118,7 @@ Ii.get("/", async (e) => {
|
|
|
12216
12118
|
createdAt: e.createdAt,
|
|
12217
12119
|
parentAssetId: e.parentAssetId || i.id,
|
|
12218
12120
|
cropCoordinates: t,
|
|
12219
|
-
url:
|
|
12121
|
+
url: Ii(e.cdnUrl, e.storageKeyPrivate),
|
|
12220
12122
|
originalUrl: l
|
|
12221
12123
|
};
|
|
12222
12124
|
})
|
|
@@ -12224,7 +12126,7 @@ Ii.get("/", async (e) => {
|
|
|
12224
12126
|
} catch (t) {
|
|
12225
12127
|
return console.error("❌ [Asset Details Error]:", t), e.json({ error: "Failed to load details" }, 500);
|
|
12226
12128
|
}
|
|
12227
|
-
}),
|
|
12129
|
+
}), Pi.put("/:id", async (e) => {
|
|
12228
12130
|
try {
|
|
12229
12131
|
let t = Rr(e), n = e.req.param("id"), r = await e.req.json(), i = await Q(t, "SELECT filename, dataJson FROM assets WHERE id = ?", [n]);
|
|
12230
12132
|
if (!i || i.length === 0) return e.json({ error: "Asset not found" }, 404);
|
|
@@ -12232,7 +12134,7 @@ Ii.get("/", async (e) => {
|
|
|
12232
12134
|
try {
|
|
12233
12135
|
o = JSON.parse(a.dataJson || "{}");
|
|
12234
12136
|
} catch {}
|
|
12235
|
-
return r.title !== void 0 && (o.title = r.title), r.alt !== void 0 && (o.alt = r.alt), r.description !== void 0 && (o.description = r.description), await
|
|
12137
|
+
return r.title !== void 0 && (o.title = r.title), r.alt !== void 0 && (o.alt = r.alt), r.description !== void 0 && (o.description = r.description), await Fi(t, "UPDATE assets SET filename = ?, dataJson = ?, updatedAt = CURRENT_TIMESTAMP WHERE id = ?", [
|
|
12236
12138
|
r.filename === void 0 ? a.filename : r.filename,
|
|
12237
12139
|
JSON.stringify(o),
|
|
12238
12140
|
n
|
|
@@ -12240,10 +12142,10 @@ Ii.get("/", async (e) => {
|
|
|
12240
12142
|
} catch (t) {
|
|
12241
12143
|
return console.error("❌ [Asset Update Error]:", t), e.json({ error: "Failed to update asset" }, 500);
|
|
12242
12144
|
}
|
|
12243
|
-
}),
|
|
12145
|
+
}), Pi.delete("/:id", async (e) => {
|
|
12244
12146
|
try {
|
|
12245
12147
|
let t = Rr(e), n = e.req.param("id"), r = (await Q(t, "SELECT id, filename, isSystemVariant FROM assets WHERE id = ?", [n]))[0];
|
|
12246
|
-
return r ? (new Y(e.env).purgeAsset(e, t, n), r.isSystemVariant ? await
|
|
12148
|
+
return r ? (new Y(e.env).purgeAsset(e, t, n), r.isSystemVariant ? await Fi(t, "UPDATE assets SET deletedAt = CURRENT_TIMESTAMP WHERE id = ?", [n]) : await Fi(t, "UPDATE assets\n SET deletedAt = CURRENT_TIMESTAMP\n WHERE id = ? OR parentAssetId = ? OR (isSystemVariant = 1 AND (filename LIKE ? OR filename LIKE ?))", [
|
|
12247
12149
|
n,
|
|
12248
12150
|
n,
|
|
12249
12151
|
`crop_%${r.filename ? r.filename.replace(/\.[^/.]+$/, "") : ""}%`,
|
|
@@ -12259,12 +12161,12 @@ Ii.get("/", async (e) => {
|
|
|
12259
12161
|
details: t.message || String(t)
|
|
12260
12162
|
}, 500);
|
|
12261
12163
|
}
|
|
12262
|
-
}),
|
|
12164
|
+
}), Pi.post("/restore", async (e) => {
|
|
12263
12165
|
try {
|
|
12264
12166
|
let t = Rr(e), n = await e.req.json(), r = n.id || n.assetId;
|
|
12265
12167
|
if (!r) return e.json({ error: "Asset ID required" }, 400);
|
|
12266
12168
|
let i = (await Q(t, "SELECT id, filename FROM assets WHERE id = ?", [r]))[0];
|
|
12267
|
-
return i ? (await
|
|
12169
|
+
return i ? (await Fi(t, "UPDATE assets \n SET deletedAt = NULL \n WHERE id = ? OR parentAssetId = ? OR (isSystemVariant = 1 AND (filename LIKE ? OR filename LIKE ?))", [
|
|
12268
12170
|
r,
|
|
12269
12171
|
r,
|
|
12270
12172
|
`crop_%${i.filename ? i.filename.replace(/\.[^/.]+$/, "") : ""}%`,
|
|
@@ -12280,9 +12182,9 @@ Ii.get("/", async (e) => {
|
|
|
12280
12182
|
details: t.message
|
|
12281
12183
|
}, 500);
|
|
12282
12184
|
}
|
|
12283
|
-
}),
|
|
12185
|
+
}), Pi.delete("/purge/:id", async (e) => {
|
|
12284
12186
|
try {
|
|
12285
|
-
let t = Rr(e), n =
|
|
12187
|
+
let t = Rr(e), n = Ni(e.env), r = e.req.param("id"), i = (await Q(t, "SELECT id, filename, storageKeyPrivate, isSystemVariant FROM assets WHERE id = ?", [r]))[0];
|
|
12286
12188
|
if (!i) return e.json({ error: "Asset not found" }, 404);
|
|
12287
12189
|
new Y(e.env).purgeAsset(e, t, r);
|
|
12288
12190
|
let a = [i];
|
|
@@ -12300,7 +12202,7 @@ Ii.get("/", async (e) => {
|
|
|
12300
12202
|
}
|
|
12301
12203
|
}
|
|
12302
12204
|
let s = o.map(() => "?").join(",");
|
|
12303
|
-
return await
|
|
12205
|
+
return await Fi(t, `DELETE FROM node_assets WHERE assetId IN (${s})`, o), await Fi(t, `DELETE FROM assets WHERE id IN (${s})`, o), e.json({
|
|
12304
12206
|
success: !0,
|
|
12305
12207
|
id: r,
|
|
12306
12208
|
purged: !0,
|
|
@@ -12316,14 +12218,14 @@ Ii.get("/", async (e) => {
|
|
|
12316
12218
|
});
|
|
12317
12219
|
//#endregion
|
|
12318
12220
|
//#region server/routes/public/node.ts
|
|
12319
|
-
var
|
|
12320
|
-
function
|
|
12221
|
+
var Li = new n();
|
|
12222
|
+
function Ri(e, t) {
|
|
12321
12223
|
let n = Promise.resolve(t).catch((e) => console.error("[Background Task Error]:", e));
|
|
12322
12224
|
try {
|
|
12323
12225
|
e.executionCtx && typeof e.executionCtx.waitUntil == "function" && e.executionCtx.waitUntil(n);
|
|
12324
12226
|
} catch {}
|
|
12325
12227
|
}
|
|
12326
|
-
function
|
|
12228
|
+
function zi() {
|
|
12327
12229
|
return {
|
|
12328
12230
|
fullPath: /* @__PURE__ */ new Map(),
|
|
12329
12231
|
treeEdges: /* @__PURE__ */ new Map(),
|
|
@@ -12331,15 +12233,15 @@ function Vi() {
|
|
|
12331
12233
|
assetUrls: /* @__PURE__ */ new Map()
|
|
12332
12234
|
};
|
|
12333
12235
|
}
|
|
12334
|
-
function
|
|
12236
|
+
function Bi(...e) {
|
|
12335
12237
|
return e.map((e) => String(e ?? "")).join(":");
|
|
12336
12238
|
}
|
|
12337
|
-
function
|
|
12239
|
+
function Vi(e) {
|
|
12338
12240
|
if (!e || String(e).trim() === "") return null;
|
|
12339
12241
|
let t = new Date(e.includes("T") ? e : e.replace(" ", "T") + "Z");
|
|
12340
12242
|
return isNaN(t.getTime()) ? e : t.toISOString();
|
|
12341
12243
|
}
|
|
12342
|
-
function
|
|
12244
|
+
function Hi(e, t) {
|
|
12343
12245
|
let n = Date.now();
|
|
12344
12246
|
if (e && String(e).trim() !== "") {
|
|
12345
12247
|
let t = Date.parse(e);
|
|
@@ -12351,7 +12253,7 @@ function Wi(e, t) {
|
|
|
12351
12253
|
}
|
|
12352
12254
|
return !0;
|
|
12353
12255
|
}
|
|
12354
|
-
async function
|
|
12256
|
+
async function Ui(e, t, n) {
|
|
12355
12257
|
let r = t.filter((e) => e.componentId === "content-feed" || e.componentId === "article-list");
|
|
12356
12258
|
await Promise.all(r.map(async (t) => {
|
|
12357
12259
|
let r = t.data || {}, i = r.nodeType || "article", a = Number(r.limit) || 12, o = r.sortBy || "updatedAt", s = "FROM content_nodes WHERE contentType = ? AND isHidden = 0 AND (status = 'published' OR status IS NULL)", c = [i];
|
|
@@ -12365,13 +12267,13 @@ async function Gi(e, t, n) {
|
|
|
12365
12267
|
if (e.dataJson) try {
|
|
12366
12268
|
t = typeof e.dataJson == "string" ? JSON.parse(e.dataJson) : e.dataJson;
|
|
12367
12269
|
} catch {}
|
|
12368
|
-
return
|
|
12270
|
+
return Hi(t.startShowingAt, t.stopShowingAt) ? {
|
|
12369
12271
|
id: e.id,
|
|
12370
12272
|
title: e.title,
|
|
12371
12273
|
slug: e.slug,
|
|
12372
12274
|
language: e.language || "en",
|
|
12373
|
-
createdAt:
|
|
12374
|
-
updatedAt:
|
|
12275
|
+
createdAt: Vi(e.createdAt),
|
|
12276
|
+
updatedAt: Vi(e.updatedAt),
|
|
12375
12277
|
excerpt: t.excerpt || "",
|
|
12376
12278
|
image: t.image || t.coverImage || null,
|
|
12377
12279
|
author: t.author || null
|
|
@@ -12382,7 +12284,7 @@ async function Gi(e, t, n) {
|
|
|
12382
12284
|
}
|
|
12383
12285
|
}));
|
|
12384
12286
|
}
|
|
12385
|
-
async function
|
|
12287
|
+
async function Wi(e, t, n, r, i = !1, a) {
|
|
12386
12288
|
if (!t) return { blocks: [] };
|
|
12387
12289
|
let o = await e.prepare("\n WITH RECURSIVE ancestor_path(id, contentId, title, slug, parentId, level) AS (\n SELECT t.id, t.contentId, c.title, c.slug, t.parentId, 0 FROM tree_nodes t INNER JOIN content_nodes c ON t.contentId = c.id WHERE t.id = ? OR c.id = ?\n UNION ALL\n SELECT t.id, t.contentId, c.title, c.slug, t.parentId, ap.level + 1 FROM tree_nodes t INNER JOIN content_nodes c ON t.contentId = c.id INNER JOIN ancestor_path ap ON t.id = ap.parentId\n ) SELECT * FROM ancestor_path ORDER BY level ASC\n ").all(t, t), s = Array.isArray(o) ? o : o?.results || [];
|
|
12388
12290
|
if (!s || s.length === 0) return { blocks: [] };
|
|
@@ -12423,10 +12325,10 @@ async function Ki(e, t, n, r, i = !1, a) {
|
|
|
12423
12325
|
try {
|
|
12424
12326
|
a = (typeof t.dataJson == "string" ? JSON.parse(t.dataJson) : t.dataJson) || {};
|
|
12425
12327
|
} catch {}
|
|
12426
|
-
let o = a.hidden === !0 || a.hidden === 1 || a.hidden === "1" || a.hidden === "true", s =
|
|
12328
|
+
let o = a.hidden === !0 || a.hidden === 1 || a.hidden === "1" || a.hidden === "true", s = Hi(a.startShowingAt, a.stopShowingAt);
|
|
12427
12329
|
if (!i && (o || !s)) return null;
|
|
12428
|
-
let c = t.elementType || t.componentId || "text-block", l = r.blocks?.[c]?.fields || r.elements?.[c]?.fields || r.components?.[c]?.fields || {}, u = String(a.blockId || a._instanceId || (a.id && !String(a.id).startsWith("ast_") ? a.id : null) || t.blockId || t.id), d =
|
|
12429
|
-
return d = await
|
|
12330
|
+
let c = t.elementType || t.componentId || "text-block", l = r.blocks?.[c]?.fields || r.elements?.[c]?.fields || r.components?.[c]?.fields || {}, u = String(a.blockId || a._instanceId || (a.id && !String(a.id).startsWith("ast_") ? a.id : null) || t.blockId || t.id), d = Gi(a, l);
|
|
12331
|
+
return d = await li(e, d), d = Ki(d), d.blockId = u, {
|
|
12430
12332
|
region: t.region || n,
|
|
12431
12333
|
block: {
|
|
12432
12334
|
instanceId: t.id,
|
|
@@ -12446,7 +12348,7 @@ async function Ki(e, t, n, r, i = !1, a) {
|
|
|
12446
12348
|
}
|
|
12447
12349
|
return { blocks: [] };
|
|
12448
12350
|
}
|
|
12449
|
-
function
|
|
12351
|
+
function Gi(e, t = {}) {
|
|
12450
12352
|
let n = {};
|
|
12451
12353
|
for (let [r, i] of Object.entries(e)) {
|
|
12452
12354
|
if (r === "id" && typeof i == "string" && i.startsWith("ast_")) {
|
|
@@ -12457,14 +12359,14 @@ function qi(e, t = {}) {
|
|
|
12457
12359
|
}
|
|
12458
12360
|
return n;
|
|
12459
12361
|
}
|
|
12460
|
-
function
|
|
12461
|
-
if (Array.isArray(e)) return e.map(
|
|
12362
|
+
function Ki(e) {
|
|
12363
|
+
if (Array.isArray(e)) return e.map(Ki);
|
|
12462
12364
|
if (!e || typeof e != "object") return e;
|
|
12463
12365
|
if (typeof e.id == "string" && e.id.startsWith("ast_") && typeof e.url == "string") {
|
|
12464
12366
|
let t = e.metadataOverrides || {}, n = e.variants && typeof e.variants == "object" ? e.variants : {}, r = Object.entries(n).find(([, t]) => t?.id === e.id)?.[0], i = r ? {
|
|
12465
12367
|
...t,
|
|
12466
12368
|
...t.crops?.[r] || {}
|
|
12467
|
-
} : t, a = Object.fromEntries(Object.entries(n).filter(([, t]) => t?.id !== e.id).map(([t, n]) => [t,
|
|
12369
|
+
} : t, a = Object.fromEntries(Object.entries(n).filter(([, t]) => t?.id !== e.id).map(([t, n]) => [t, Ki({
|
|
12468
12370
|
...n,
|
|
12469
12371
|
title: n?.title ?? e.title ?? "",
|
|
12470
12372
|
alt: n?.alt ?? e.alt ?? "",
|
|
@@ -12478,9 +12380,9 @@ function Ji(e) {
|
|
|
12478
12380
|
...Object.keys(a).length > 0 ? { variants: a } : {}
|
|
12479
12381
|
};
|
|
12480
12382
|
}
|
|
12481
|
-
return Object.fromEntries(Object.entries(e).map(([e, t]) => [e,
|
|
12383
|
+
return Object.fromEntries(Object.entries(e).map(([e, t]) => [e, Ki(t)]));
|
|
12482
12384
|
}
|
|
12483
|
-
async function
|
|
12385
|
+
async function qi(e, t, n) {
|
|
12484
12386
|
if (!t) return t;
|
|
12485
12387
|
if (typeof t == "string") {
|
|
12486
12388
|
if (!t.includes("#node:") && !t.includes("data-node-id") && !t.includes("#asset:") && !t.includes("data-asset-id")) return t;
|
|
@@ -12499,9 +12401,9 @@ async function Yi(e, t, n) {
|
|
|
12499
12401
|
return await Promise.all(Array.from(t.matchAll(d)).map(async (t) => {
|
|
12500
12402
|
let i = t[1], a = r(i, "data-node-id"), o = r(i, "data-tree-id");
|
|
12501
12403
|
if (!a || !o) return;
|
|
12502
|
-
let s = await
|
|
12404
|
+
let s = await Yi(e, a, o, n);
|
|
12503
12405
|
if (s?.treeNodeId) {
|
|
12504
|
-
let t = await
|
|
12406
|
+
let t = await $i(e, String(s.treeNodeId), o, n);
|
|
12505
12407
|
u.set(`${a}:${o}`, t);
|
|
12506
12408
|
}
|
|
12507
12409
|
})), t.replace(d, (e, t) => {
|
|
@@ -12521,41 +12423,41 @@ async function Yi(e, t, n) {
|
|
|
12521
12423
|
return /href\s*=/.test(h) || (h += ` href="${m || "/"}"`), `<a ${h}>`;
|
|
12522
12424
|
});
|
|
12523
12425
|
}
|
|
12524
|
-
if (Array.isArray(t)) return Promise.all(t.map((t) =>
|
|
12426
|
+
if (Array.isArray(t)) return Promise.all(t.map((t) => qi(e, t, n)));
|
|
12525
12427
|
if (typeof t == "object") {
|
|
12526
12428
|
let r = JSON.stringify(t);
|
|
12527
12429
|
if (!r.includes("#node:") && !r.includes("data-node-id") && !r.includes("#asset:") && !r.includes("data-asset-id")) return t;
|
|
12528
12430
|
if (typeof t.href == "string" && (t.href.startsWith("#node:") || t.href.startsWith("#asset:"))) return {
|
|
12529
12431
|
...t,
|
|
12530
|
-
href: await
|
|
12432
|
+
href: await Ji(e, t, n)
|
|
12531
12433
|
};
|
|
12532
|
-
let i = await Promise.all(Object.entries(t).map(async ([t, r]) => [t, await
|
|
12434
|
+
let i = await Promise.all(Object.entries(t).map(async ([t, r]) => [t, await qi(e, r, n)]));
|
|
12533
12435
|
return Object.fromEntries(i);
|
|
12534
12436
|
}
|
|
12535
12437
|
return t;
|
|
12536
12438
|
}
|
|
12537
|
-
async function
|
|
12439
|
+
async function Ji(e, t, n) {
|
|
12538
12440
|
let r = t.href.match(/^#node:(.+)$/), i = t.href.match(/^#asset:(.+)$/);
|
|
12539
|
-
if (i) return
|
|
12441
|
+
if (i) return Zi(e, i[1], n);
|
|
12540
12442
|
if (!r) return t.href;
|
|
12541
12443
|
let a = r[1];
|
|
12542
12444
|
if (t.treeId) {
|
|
12543
|
-
let r = await
|
|
12445
|
+
let r = await Yi(e, a, String(t.treeId), n);
|
|
12544
12446
|
if (r?.treeNodeId) {
|
|
12545
|
-
let i = await
|
|
12447
|
+
let i = await $i(e, String(r.treeNodeId), String(t.treeId), n);
|
|
12546
12448
|
if (i) return i;
|
|
12547
12449
|
}
|
|
12548
12450
|
}
|
|
12549
|
-
let o = await
|
|
12451
|
+
let o = await Xi(e, a, n);
|
|
12550
12452
|
return o === void 0 ? "#" : `/${o}`;
|
|
12551
12453
|
}
|
|
12552
|
-
async function
|
|
12553
|
-
let i =
|
|
12454
|
+
async function Yi(e, t, n, r) {
|
|
12455
|
+
let i = Bi(t, n);
|
|
12554
12456
|
if (r.treeEdges.has(i)) return r.treeEdges.get(i);
|
|
12555
12457
|
let a = e.prepare("SELECT id as treeNodeId FROM tree_nodes WHERE contentId = ? AND treeId = ? LIMIT 1").get(t, n);
|
|
12556
12458
|
return r.treeEdges.set(i, Promise.resolve(a)), a;
|
|
12557
12459
|
}
|
|
12558
|
-
async function
|
|
12460
|
+
async function Xi(e, t, n) {
|
|
12559
12461
|
let r = String(t);
|
|
12560
12462
|
if (n.nodeSlugs.has(r)) return n.nodeSlugs.get(r);
|
|
12561
12463
|
let i = (async () => {
|
|
@@ -12564,7 +12466,7 @@ async function Qi(e, t, n) {
|
|
|
12564
12466
|
})();
|
|
12565
12467
|
return n.nodeSlugs.set(r, i), i;
|
|
12566
12468
|
}
|
|
12567
|
-
async function
|
|
12469
|
+
async function Zi(e, t, n) {
|
|
12568
12470
|
let r = String(t);
|
|
12569
12471
|
if (n.assetUrls.has(r)) return n.assetUrls.get(r);
|
|
12570
12472
|
let i = (async () => {
|
|
@@ -12573,7 +12475,7 @@ async function $i(e, t, n) {
|
|
|
12573
12475
|
})();
|
|
12574
12476
|
return n.assetUrls.set(r, i), i;
|
|
12575
12477
|
}
|
|
12576
|
-
function
|
|
12478
|
+
function Qi(e) {
|
|
12577
12479
|
let t = e.socialImage;
|
|
12578
12480
|
if (!t || typeof t != "object") return null;
|
|
12579
12481
|
let n = (e, t) => {
|
|
@@ -12604,9 +12506,9 @@ function ea(e) {
|
|
|
12604
12506
|
])
|
|
12605
12507
|
};
|
|
12606
12508
|
}
|
|
12607
|
-
async function
|
|
12509
|
+
async function $i(e, t, n, r) {
|
|
12608
12510
|
if (!t) return "";
|
|
12609
|
-
let i =
|
|
12511
|
+
let i = Bi(t, n);
|
|
12610
12512
|
if (r && r.fullPath.has(i)) return r.fullPath.get(i);
|
|
12611
12513
|
let a = (async () => {
|
|
12612
12514
|
let r = await e.prepare("\n WITH RECURSIVE ancestor_path(id, parentId, slug, level) AS (\n SELECT t.id, t.parentId, c.slug, 0 FROM tree_nodes t INNER JOIN content_nodes c ON t.contentId = c.id WHERE t.id = ? AND t.treeId = ?\n UNION ALL\n SELECT t.id, t.parentId, c.slug, ap.level + 1 FROM tree_nodes t INNER JOIN content_nodes c ON t.contentId = c.id INNER JOIN ancestor_path ap ON t.id = ap.parentId WHERE t.treeId = ?\n ) SELECT slug FROM ancestor_path ORDER BY level DESC\n ").all(t, n, n), i = Array.isArray(r) ? r : r?.results || [], a = [];
|
|
@@ -12618,7 +12520,7 @@ async function ta(e, t, n, r) {
|
|
|
12618
12520
|
})();
|
|
12619
12521
|
return r && r.fullPath.set(i, a), a;
|
|
12620
12522
|
}
|
|
12621
|
-
async function
|
|
12523
|
+
async function ea(e, t, n, r, i) {
|
|
12622
12524
|
let a = {}, o = null;
|
|
12623
12525
|
if (t) {
|
|
12624
12526
|
let n = await e.prepare("\n WITH RECURSIVE ancestor_path(id, contentId, title, slug, parentId, level) AS (\n SELECT t.id, t.contentId, c.title, c.slug, t.parentId, 0 FROM tree_nodes t INNER JOIN content_nodes c ON t.contentId = c.id WHERE t.id = ? OR c.id = ?\n UNION ALL\n SELECT t.id, t.contentId, c.title, c.slug, t.parentId, ap.level + 1 FROM tree_nodes t INNER JOIN content_nodes c ON t.contentId = c.id INNER JOIN ancestor_path ap ON t.id = ap.parentId\n ) SELECT c.dataJson, c.draftDataJson FROM ancestor_path ap INNER JOIN content_nodes c ON ap.contentId = c.id ORDER BY ap.level ASC\n ").all(t, t), i = Array.isArray(n) ? n : n?.results || [], s = /* @__PURE__ */ new Set([
|
|
@@ -12656,13 +12558,13 @@ async function na(e, t, n, r, i) {
|
|
|
12656
12558
|
inheritedFields: a
|
|
12657
12559
|
};
|
|
12658
12560
|
}
|
|
12659
|
-
function
|
|
12561
|
+
function ta(e) {
|
|
12660
12562
|
let t = Number(e?.env?.CMS_NODE_CACHE_TTL);
|
|
12661
12563
|
return Number.isFinite(t) && t >= 60 ? Math.floor(t) : 300;
|
|
12662
12564
|
}
|
|
12663
|
-
|
|
12565
|
+
Li.get("/*", async (e) => {
|
|
12664
12566
|
try {
|
|
12665
|
-
let t = e.get("db"), n =
|
|
12567
|
+
let t = e.get("db"), n = zi(), r = new URL(e.req.url).pathname.match(/\/node\/(.+)$/), i = (r ? r[1] : "home").replace(/^\/+|\/+$/g, ""), a = e.req.query("channelId") || e.req.query("channel") || "1", o = e.req.query("lang") || "en", s = e.req.query("preview") === "true", c = isNaN(Number(a)) ? await t.prepare("SELECT * FROM channels WHERE key = ?").get(a) : await t.prepare("SELECT * FROM channels WHERE id = ?").get(Number(a));
|
|
12666
12568
|
if (!c) return e.json({ error: `Channel '${a}' not found` }, 404);
|
|
12667
12569
|
let l = c.status === "disabled" || c.status === "inactive" || c.isEnabled === 0 || c.isEnabled === !1;
|
|
12668
12570
|
if (!s && l) return e.json({ error: `Channel '${c.key || a}' is currently inactive` }, 404);
|
|
@@ -12681,7 +12583,7 @@ zi.get("/*", async (e) => {
|
|
|
12681
12583
|
if (E.length > 0) {
|
|
12682
12584
|
let e = await Promise.all(E.map(async (e) => ({
|
|
12683
12585
|
candidate: e,
|
|
12684
|
-
calculatedPath: await
|
|
12586
|
+
calculatedPath: await $i(t, String(e.treeNodeId), String(e.treeId), n)
|
|
12685
12587
|
}))), r = S.replace(/^\/+|\/+$/g, "");
|
|
12686
12588
|
for (let { candidate: t, calculatedPath: n } of e) {
|
|
12687
12589
|
let e = n.replace(/^\/+|\/+$/g, "");
|
|
@@ -12696,7 +12598,7 @@ zi.get("/*", async (e) => {
|
|
|
12696
12598
|
let e = y ? [_.id, y] : [_.id];
|
|
12697
12599
|
v = await t.prepare(`SELECT id as treeNodeId, treeId, parentId FROM tree_nodes WHERE contentId = ? ${y ? "AND treeId = ?" : ""} LIMIT 1`).get(...e);
|
|
12698
12600
|
}
|
|
12699
|
-
let D = v?.treeId || y || "main-nav", O = v?.parentId || null, ee = v?.treeNodeId ? await
|
|
12601
|
+
let D = v?.treeId || y || "main-nav", O = v?.parentId || null, ee = v?.treeNodeId ? await $i(t, String(v.treeNodeId), String(D), n) : `/${(_.slug || "").replace(/^\/+|\/+$/g, "")}`, k = {}, te = s && _.draftDataJson ? _.draftDataJson : _.dataJson || _.draftDataJson;
|
|
12700
12602
|
if (te) try {
|
|
12701
12603
|
k = typeof te == "string" ? JSON.parse(te) : te;
|
|
12702
12604
|
} catch {}
|
|
@@ -12704,44 +12606,44 @@ zi.get("/*", async (e) => {
|
|
|
12704
12606
|
A.tabs && Object.values(A.tabs).forEach((e) => {
|
|
12705
12607
|
Object.assign(j, e.fields || {});
|
|
12706
12608
|
});
|
|
12707
|
-
let ie = +!!s, [ae, oe,
|
|
12708
|
-
|
|
12609
|
+
let ie = +!!s, [ae, oe, M] = await Promise.all([
|
|
12610
|
+
ea(t, O, D, s, j),
|
|
12709
12611
|
v?.treeNodeId ? t.prepare("SELECT t.id as treeNodeId, t.contentId as id, c.title, c.slug, c.language, c.contentType as nodeType, c.isHidden, c.dataJson, c.draftDataJson FROM tree_nodes t INNER JOIN content_nodes c ON t.contentId = c.id WHERE t.parentId = ? AND t.treeId = ? ORDER BY t.sortOrder ASC").all(v.treeNodeId, D) : Promise.resolve([]),
|
|
12710
12612
|
t.prepare("SELECT * FROM content_blocks WHERE contentId = ? AND isDraft = ? ORDER BY sortOrder ASC").all(_.id, ie)
|
|
12711
|
-
]), { resolvedLayoutId:
|
|
12613
|
+
]), { resolvedLayoutId: N, inheritedFields: se } = ae, P = {
|
|
12712
12614
|
id: _.id,
|
|
12713
12615
|
title: _.title,
|
|
12714
12616
|
slug: _.slug,
|
|
12715
12617
|
path: ee === "" ? "/" : ee,
|
|
12716
12618
|
nodeType: ne,
|
|
12717
|
-
createdAt:
|
|
12718
|
-
updatedAt:
|
|
12719
|
-
publishedAt:
|
|
12720
|
-
},
|
|
12721
|
-
j.layoutId && (
|
|
12722
|
-
let
|
|
12723
|
-
if (
|
|
12724
|
-
else if (!
|
|
12619
|
+
createdAt: Vi(_.createdAt),
|
|
12620
|
+
updatedAt: Vi(_.updatedAt),
|
|
12621
|
+
publishedAt: Vi(k.publishedAt || _.createdAt)
|
|
12622
|
+
}, ce = k.disabledRegions || {}, le = k.hidden === !0 || k.hidden === 1 || k.hidden === "1" || k.hidden === "true", F = k.startShowingAt || null, ue = k.stopShowingAt || null, de = Gi(k, j), fe = de.layoutId || null, pe = fe && fe !== "inherit", me = !1, I = null;
|
|
12623
|
+
j.layoutId && (me = !0, j.layoutId.options && Array.isArray(j.layoutId.options) && (I = j.layoutId.options.map((e) => typeof e == "object" ? e.value || e.id : e)));
|
|
12624
|
+
let he = null;
|
|
12625
|
+
if (me && I && I.length === 1 && I[0] !== "inherit") he = I[0];
|
|
12626
|
+
else if (!me && A.defaultLayout) he = A.defaultLayout;
|
|
12725
12627
|
else {
|
|
12726
|
-
let e =
|
|
12727
|
-
|
|
12728
|
-
}
|
|
12729
|
-
for (let [e, t] of Object.entries(
|
|
12730
|
-
let
|
|
12731
|
-
|
|
12732
|
-
let
|
|
12733
|
-
delete
|
|
12734
|
-
let
|
|
12735
|
-
if (!s && (
|
|
12736
|
-
let
|
|
12628
|
+
let e = pe ? fe : N;
|
|
12629
|
+
he = e && e !== "inherit" && (!I || I.includes(e) || I.includes("inherit")) ? e : A.defaultLayout || null;
|
|
12630
|
+
}
|
|
12631
|
+
for (let [e, t] of Object.entries(se)) j[e] && (de[e] === void 0 || de[e] === null || de[e] === "" || de[e] === "inherit") && t !== void 0 && (de[e] = t);
|
|
12632
|
+
let L = await li(t, de);
|
|
12633
|
+
L = Ki(L), L = await qi(t, L, n);
|
|
12634
|
+
let R = Qi(L);
|
|
12635
|
+
delete L.socialImage, delete L.fbImage, delete L.xImage, delete L.whatsappImage, R && (L.socialImages = R), delete L.id, delete L.title, delete L.slug, delete L.language, delete L.contentType, delete L.nodeType, delete L.createdAt, delete L.updatedAt, delete L.publishedAt, delete L.channelId, delete L.treeId, delete L.path, L.iconName === "" && (L.iconName = null), Object.assign(P, L), A.hasCanvas && (P.layoutId = he);
|
|
12636
|
+
let ge = Number(_.isHidden) === 1 || le, _e = !Hi(F, ue);
|
|
12637
|
+
if (!s && (ge || _e)) return e.json({ error: "Node is hidden or outside its scheduled publishing window" }, 404);
|
|
12638
|
+
let ve = [];
|
|
12737
12639
|
if (v?.treeNodeId) {
|
|
12738
|
-
let e = Array.isArray(oe) ? oe : oe?.results || [], t =
|
|
12739
|
-
|
|
12640
|
+
let e = Array.isArray(oe) ? oe : oe?.results || [], t = P.path === "/" ? "" : P.path;
|
|
12641
|
+
ve = e.map((e) => {
|
|
12740
12642
|
let n = {}, r = s && e.draftDataJson ? e.draftDataJson : e.dataJson;
|
|
12741
12643
|
try {
|
|
12742
12644
|
n = (typeof r == "string" ? JSON.parse(r) : r) || {};
|
|
12743
12645
|
} catch {}
|
|
12744
|
-
let i = Number(e.isHidden) === 1 || n.hidden === !0 || n.hidden === 1 || n.hidden === "1", a =
|
|
12646
|
+
let i = Number(e.isHidden) === 1 || n.hidden === !0 || n.hidden === 1 || n.hidden === "1", a = Hi(n.startShowingAt, n.stopShowingAt), o = (e.slug || "").replace(/^\/+|\/+$/g, "");
|
|
12745
12647
|
return !s && (i || !a) ? null : {
|
|
12746
12648
|
treeNodeId: e.treeNodeId,
|
|
12747
12649
|
id: e.id,
|
|
@@ -12753,21 +12655,21 @@ zi.get("/*", async (e) => {
|
|
|
12753
12655
|
};
|
|
12754
12656
|
}).filter(Boolean);
|
|
12755
12657
|
}
|
|
12756
|
-
|
|
12757
|
-
let
|
|
12758
|
-
if (
|
|
12658
|
+
P.children = ve;
|
|
12659
|
+
let ye = Array.isArray(M) ? M : M?.results || [];
|
|
12660
|
+
if (ye.length === 0 && !s) {
|
|
12759
12661
|
let e = await t.prepare("SELECT * FROM content_blocks WHERE contentId = ? ORDER BY sortOrder ASC").all(_.id);
|
|
12760
|
-
|
|
12662
|
+
ye = Array.isArray(e) ? e : e?.results || [];
|
|
12761
12663
|
}
|
|
12762
|
-
let
|
|
12664
|
+
let z = {}, B = {}, be = await Promise.all(ye.map(async (e) => {
|
|
12763
12665
|
let r = e.region || "main", i = {};
|
|
12764
12666
|
try {
|
|
12765
12667
|
i = (typeof e.dataJson == "string" ? JSON.parse(e.dataJson) : e.dataJson) || {};
|
|
12766
12668
|
} catch {}
|
|
12767
|
-
let a = i.hidden === !0 || i.hidden === 1 || i.hidden === "1" || i.hidden === "true", o =
|
|
12669
|
+
let a = i.hidden === !0 || i.hidden === 1 || i.hidden === "1" || i.hidden === "true", o = Hi(i.startShowingAt, i.stopShowingAt);
|
|
12768
12670
|
if (!s && (a || !o)) return null;
|
|
12769
|
-
let c = e.elementType || e.componentId || "text-block", l = h.blocks?.[c]?.fields || h.elements?.[c]?.fields || h.components?.[c]?.fields || {}, u = String(i.blockId || i._instanceId || (i.id && !String(i.id).startsWith("ast_") ? i.id : null) || e.blockId || e.id), d =
|
|
12770
|
-
return d = await
|
|
12671
|
+
let c = e.elementType || e.componentId || "text-block", l = h.blocks?.[c]?.fields || h.elements?.[c]?.fields || h.components?.[c]?.fields || {}, u = String(i.blockId || i._instanceId || (i.id && !String(i.id).startsWith("ast_") ? i.id : null) || e.blockId || e.id), d = Gi(i, l);
|
|
12672
|
+
return d = await li(t, d), d = Ki(d), d = await qi(t, d, n), d.blockId = u, {
|
|
12771
12673
|
region: r,
|
|
12772
12674
|
block: {
|
|
12773
12675
|
instanceId: e.id,
|
|
@@ -12777,8 +12679,8 @@ zi.get("/*", async (e) => {
|
|
|
12777
12679
|
}
|
|
12778
12680
|
};
|
|
12779
12681
|
}));
|
|
12780
|
-
for (let e of
|
|
12781
|
-
let
|
|
12682
|
+
for (let e of be) e && (z[e.region] || (z[e.region] = [], B[e.region] = { isInherited: !1 }), z[e.region].push(e.block));
|
|
12683
|
+
let xe = {
|
|
12782
12684
|
header: {
|
|
12783
12685
|
label: "Header",
|
|
12784
12686
|
inherit: "parent"
|
|
@@ -12787,33 +12689,33 @@ zi.get("/*", async (e) => {
|
|
|
12787
12689
|
label: "Footer",
|
|
12788
12690
|
inherit: "parent"
|
|
12789
12691
|
},
|
|
12790
|
-
...(
|
|
12692
|
+
...(he ? h.nodeLayouts?.[he] || h.layouts?.[he] : null)?.regions || { main: { label: "Content" } }
|
|
12791
12693
|
};
|
|
12792
|
-
for (let [e, r] of Object.entries(
|
|
12793
|
-
let i =
|
|
12794
|
-
if (
|
|
12795
|
-
let r = await
|
|
12796
|
-
if (r.blocks.length > 0 && (
|
|
12694
|
+
for (let [e, r] of Object.entries(xe)) {
|
|
12695
|
+
let i = z[e] && z[e].length > 0, a = !!ce[e];
|
|
12696
|
+
if (z[e] || (z[e] = [], B[e] = { isInherited: !1 }), (r?.inherit === "parent" || r?.inherit === !0 || r?.inherit === "true" || e === "header" || e === "footer") && !i && !a && O) {
|
|
12697
|
+
let r = await Wi(t, O, e, h, s, n);
|
|
12698
|
+
if (r.blocks.length > 0 && (z[e] = r.blocks, B[e] = {
|
|
12797
12699
|
isInherited: !0,
|
|
12798
12700
|
inheritedFromId: r.inheritedFromId,
|
|
12799
12701
|
inheritedFromTitle: r.inheritedFromTitle
|
|
12800
|
-
}, r.subRegions)) for (let [t, n] of Object.entries(r.subRegions)) t !== e && (
|
|
12702
|
+
}, r.subRegions)) for (let [t, n] of Object.entries(r.subRegions)) t !== e && (z[t] = n, B[t] = {
|
|
12801
12703
|
isInherited: !0,
|
|
12802
12704
|
inheritedFromId: r.inheritedFromId,
|
|
12803
12705
|
inheritedFromTitle: r.inheritedFromTitle
|
|
12804
12706
|
});
|
|
12805
12707
|
}
|
|
12806
12708
|
}
|
|
12807
|
-
await Promise.all(Object.keys(
|
|
12808
|
-
let
|
|
12709
|
+
await Promise.all(Object.keys(z).map((e) => Ui(t, z[e], u)));
|
|
12710
|
+
let Se = {
|
|
12809
12711
|
channelId: u || d,
|
|
12810
12712
|
treeId: D,
|
|
12811
12713
|
language: _.language || o || "en",
|
|
12812
|
-
node:
|
|
12813
|
-
content:
|
|
12814
|
-
regionMeta:
|
|
12714
|
+
node: P,
|
|
12715
|
+
content: z,
|
|
12716
|
+
regionMeta: B
|
|
12815
12717
|
};
|
|
12816
|
-
return !s && !m ? (e.header("X-Cache", "MISS"),
|
|
12718
|
+
return !s && !m ? (e.header("X-Cache", "MISS"), Ri(e, f.set(p, Se, ta(e)))) : e.header("Cache-Control", "no-store, no-cache, must-revalidate"), e.json(Se);
|
|
12817
12719
|
} catch (t) {
|
|
12818
12720
|
console.error("[CMS Public API] Error fetching node by path:", t);
|
|
12819
12721
|
let n = e.env?.ENVIRONMENT === "development";
|
|
@@ -12825,14 +12727,14 @@ zi.get("/*", async (e) => {
|
|
|
12825
12727
|
});
|
|
12826
12728
|
//#endregion
|
|
12827
12729
|
//#region server/routes/public/tree.ts
|
|
12828
|
-
var
|
|
12829
|
-
function
|
|
12730
|
+
var na = new n();
|
|
12731
|
+
function ra(e, t) {
|
|
12830
12732
|
let n = Promise.resolve(t).catch((e) => console.error("[Background Task Error]:", e));
|
|
12831
12733
|
try {
|
|
12832
12734
|
e.executionCtx && typeof e.executionCtx.waitUntil == "function" && e.executionCtx.waitUntil(n);
|
|
12833
12735
|
} catch {}
|
|
12834
12736
|
}
|
|
12835
|
-
function
|
|
12737
|
+
function ia(e, t) {
|
|
12836
12738
|
let n = /* @__PURE__ */ new Date();
|
|
12837
12739
|
if (e && String(e).trim() !== "") {
|
|
12838
12740
|
let t = new Date(e);
|
|
@@ -12844,7 +12746,7 @@ function oa(e, t) {
|
|
|
12844
12746
|
}
|
|
12845
12747
|
return !0;
|
|
12846
12748
|
}
|
|
12847
|
-
|
|
12749
|
+
na.get("/:treeParam", async (e) => {
|
|
12848
12750
|
try {
|
|
12849
12751
|
let t = e.get("db"), n = e.req.param("treeParam"), r = e.req.query("channelId") || e.req.query("channel") || "default", i = e.req.query("preview") === "true";
|
|
12850
12752
|
if (r && r !== "default" && r !== "all") {
|
|
@@ -12922,7 +12824,7 @@ ia.get("/:treeParam", async (e) => {
|
|
|
12922
12824
|
"isHidden",
|
|
12923
12825
|
"status"
|
|
12924
12826
|
].includes(e) || (r[e] = t);
|
|
12925
|
-
let a = !i && (e.status === "draft" || e.status === "new"), o = Number(e.isHidden) === 1 || a || n.hidden === !0 || n.hidden === 1 || n.hidden === "1" || n.hidden === "true", s =
|
|
12827
|
+
let a = !i && (e.status === "draft" || e.status === "new"), o = Number(e.isHidden) === 1 || a || n.hidden === !0 || n.hidden === 1 || n.hidden === "1" || n.hidden === "true", s = ia(n.startShowingAt, n.stopShowingAt), c = (e.slug || "").replace(/^\/+|\/+$/g, ""), l = (!e.parentId || e.parentId === "null" || e.parentId === "") && (c === "home" || c === "homee") ? "/" : `${t}/${c}`.replace(/\/+/g, "/"), u = {
|
|
12926
12828
|
id: e.id,
|
|
12927
12829
|
treeNodeId: e.treeNodeId,
|
|
12928
12830
|
parentId: e.parentId || null,
|
|
@@ -12947,7 +12849,7 @@ ia.get("/:treeParam", async (e) => {
|
|
|
12947
12849
|
...m,
|
|
12948
12850
|
items: _(null)
|
|
12949
12851
|
};
|
|
12950
|
-
return !i && !s ? (e.header("X-Cache", "MISS"),
|
|
12852
|
+
return !i && !s ? (e.header("X-Cache", "MISS"), ra(e, a.set(o, v, 300))) : e.header("Cache-Control", "no-store, no-cache, must-revalidate"), e.json(v);
|
|
12951
12853
|
} catch (t) {
|
|
12952
12854
|
return console.error("[CMS Public Tree API] Error:", t), e.json({
|
|
12953
12855
|
error: "Failed to fetch public tree",
|
|
@@ -12957,8 +12859,8 @@ ia.get("/:treeParam", async (e) => {
|
|
|
12957
12859
|
});
|
|
12958
12860
|
//#endregion
|
|
12959
12861
|
//#region server/routes/public/assets.ts
|
|
12960
|
-
var
|
|
12961
|
-
function
|
|
12862
|
+
var aa = new n();
|
|
12863
|
+
function oa(e, t) {
|
|
12962
12864
|
if (t === "webp") return "image/webp";
|
|
12963
12865
|
if (t === "avif") return "image/avif";
|
|
12964
12866
|
if (t === "jpeg" || t === "jpg") return "image/jpeg";
|
|
@@ -12966,7 +12868,7 @@ function ca(e, t) {
|
|
|
12966
12868
|
let n = e.toLowerCase();
|
|
12967
12869
|
return n.endsWith(".jpg") || n.endsWith(".jpeg") ? "image/jpeg" : n.endsWith(".png") ? "image/png" : n.endsWith(".webp") ? "image/webp" : n.endsWith(".gif") ? "image/gif" : n.endsWith(".svg") ? "image/svg+xml" : n.endsWith(".pdf") ? "application/pdf" : n.endsWith(".mp4") ? "video/mp4" : n.endsWith(".webm") ? "video/webm" : "application/octet-stream";
|
|
12968
12870
|
}
|
|
12969
|
-
|
|
12871
|
+
aa.get("/*", async (e) => {
|
|
12970
12872
|
let t = e.req.path.replace(/^\/media\//, "").replace(/^\//, "");
|
|
12971
12873
|
if (!t) return e.text("Asset key missing", 400);
|
|
12972
12874
|
let n = e.env?.MEDIA_BUCKET, { w: r, h: i, q: a, f: o } = e.req.query(), s = !!(r || i || a || o), c = e.req.header("Accept") || "", l = "";
|
|
@@ -12983,7 +12885,7 @@ sa.get("/*", async (e) => {
|
|
|
12983
12885
|
}
|
|
12984
12886
|
let p = e.req.header("Via")?.includes("image-resizing") || e.req.header("User-Agent")?.includes("Cloudflare-ImgRen"), m = new URL(e.req.url), h = e.env?.CDN_DOMAIN || m.hostname;
|
|
12985
12887
|
if (n) {
|
|
12986
|
-
let l =
|
|
12888
|
+
let l = oa(t), u = l.startsWith("image/") && !l.includes("svg");
|
|
12987
12889
|
if (s && u && h && !p) {
|
|
12988
12890
|
let e = r ? parseInt(r, 10) : void 0, n = i ? parseInt(i, 10) : void 0, s = a ? parseInt(a, 10) : 85, l = o || "auto", u = `https://${h}/media/${t}`;
|
|
12989
12891
|
try {
|
|
@@ -13026,7 +12928,7 @@ sa.get("/*", async (e) => {
|
|
|
13026
12928
|
if (!s) {
|
|
13027
12929
|
let n = _(C);
|
|
13028
12930
|
return e.body(n, 200, {
|
|
13029
|
-
"Content-Type":
|
|
12931
|
+
"Content-Type": oa(t),
|
|
13030
12932
|
"Cache-Control": "public, max-age=86400"
|
|
13031
12933
|
});
|
|
13032
12934
|
}
|
|
@@ -13034,7 +12936,7 @@ sa.get("/*", async (e) => {
|
|
|
13034
12936
|
if (g(f)) {
|
|
13035
12937
|
let n = _(f);
|
|
13036
12938
|
return e.body(n, 200, {
|
|
13037
|
-
"Content-Type":
|
|
12939
|
+
"Content-Type": oa(t, u),
|
|
13038
12940
|
"Cache-Control": "public, max-age=31536000, immutable",
|
|
13039
12941
|
"X-Local-Cache": "HIT"
|
|
13040
12942
|
});
|
|
@@ -13047,14 +12949,14 @@ sa.get("/*", async (e) => {
|
|
|
13047
12949
|
typeof n == "number" && (a.width = n), typeof o == "number" && (a.height = o), (a.width || a.height) && (a.fit = "cover", i = i.resize(a)), u === "webp" ? i = i.webp({ quality: typeof c == "number" ? c : 80 }) : u === "avif" ? i = i.avif({ quality: typeof c == "number" ? c : 70 }) : u === "jpeg" || u === "jpg" ? i = i.jpeg({ quality: typeof c == "number" ? c : 80 }) : u === "png" && (i = i.png({ quality: typeof c == "number" ? c : 80 }));
|
|
13048
12950
|
let s = await i.toBuffer();
|
|
13049
12951
|
return v(x(f), { recursive: !0 }), y(f, s), e.body(s, 200, {
|
|
13050
|
-
"Content-Type":
|
|
12952
|
+
"Content-Type": oa(t, u),
|
|
13051
12953
|
"Cache-Control": "public, max-age=31536000, immutable",
|
|
13052
12954
|
"X-Local-Cache": "MISS"
|
|
13053
12955
|
});
|
|
13054
12956
|
} catch {
|
|
13055
12957
|
let n = _(C);
|
|
13056
12958
|
return e.body(n, 200, {
|
|
13057
|
-
"Content-Type":
|
|
12959
|
+
"Content-Type": oa(t),
|
|
13058
12960
|
"Cache-Control": "public, max-age=86400"
|
|
13059
12961
|
});
|
|
13060
12962
|
}
|
|
@@ -13065,8 +12967,8 @@ sa.get("/*", async (e) => {
|
|
|
13065
12967
|
});
|
|
13066
12968
|
//#endregion
|
|
13067
12969
|
//#region server/routes/public/paths.ts
|
|
13068
|
-
var
|
|
13069
|
-
function
|
|
12970
|
+
var sa = new n();
|
|
12971
|
+
function ca(e, t) {
|
|
13070
12972
|
let n = /* @__PURE__ */ new Date();
|
|
13071
12973
|
if (e && String(e).trim() !== "") {
|
|
13072
12974
|
let t = new Date(e);
|
|
@@ -13078,7 +12980,7 @@ function ua(e, t) {
|
|
|
13078
12980
|
}
|
|
13079
12981
|
return !0;
|
|
13080
12982
|
}
|
|
13081
|
-
|
|
12983
|
+
sa.get("/", async (e) => {
|
|
13082
12984
|
try {
|
|
13083
12985
|
let t = await e.get("db").prepare("\n SELECT\n t.id as treeNodeId,\n t.parentId,\n c.slug,\n c.contentType as nodeType,\n c.status,\n c.dataJson\n FROM tree_nodes t\n INNER JOIN content_nodes c ON t.contentId = c.id\n WHERE (c.deletedAt IS NULL OR c.deletedAt = '')\n ORDER BY t.sortOrder ASC\n ").all(), n = Array.isArray(t) ? t : t?.results || [], r = [], i = /* @__PURE__ */ new Map();
|
|
13084
12986
|
for (let e of n) {
|
|
@@ -13102,7 +13004,7 @@ la.get("/", async (e) => {
|
|
|
13102
13004
|
function o(e = null, t = "") {
|
|
13103
13005
|
let n = e == null || e === "" || e === "null" ? "__ROOT__" : String(e), s = i.get(n) || [];
|
|
13104
13006
|
for (let e of s) {
|
|
13105
|
-
let n = a.get(String(e.treeNodeId)) || {}, i = e.status === "published" || e.status === "active", s =
|
|
13007
|
+
let n = a.get(String(e.treeNodeId)) || {}, i = e.status === "published" || e.status === "active", s = ca(n.startShowingAt, n.stopShowingAt);
|
|
13106
13008
|
if (!i || !s) continue;
|
|
13107
13009
|
let c = (e.slug || "").replace(/^\/+|\/+$/g, ""), l = c === "home" || c === "homee" ? "/" : `${t}/${c}`.replace(/\/+/g, "/");
|
|
13108
13010
|
e.nodeType !== "external-link" && r.push(l);
|
|
@@ -13119,7 +13021,7 @@ la.get("/", async (e) => {
|
|
|
13119
13021
|
});
|
|
13120
13022
|
//#endregion
|
|
13121
13023
|
//#region server/index.ts
|
|
13122
|
-
var
|
|
13024
|
+
var la = Mr(), $ = new n(), ua = !1;
|
|
13123
13025
|
$.use("*", Pr()), $.use("/media/*", Pr({
|
|
13124
13026
|
origin: "*",
|
|
13125
13027
|
allowMethods: [
|
|
@@ -13137,18 +13039,18 @@ $.use("*", Pr()), $.use("/media/*", Pr({
|
|
|
13137
13039
|
await t(), e.header("Cache-Control", "public, max-age=31536000, immutable"), e.header("Access-Control-Allow-Origin", "*");
|
|
13138
13040
|
}), $.use("*", async (e, t) => {
|
|
13139
13041
|
if (e.req.path.startsWith("/media/")) return t();
|
|
13140
|
-
let n =
|
|
13042
|
+
let n = la;
|
|
13141
13043
|
e.env?.BUNDLED_DEFINITIONS && (e.env.BUNDLED_DEFINITIONS._isCompiled || (e.env.BUNDLED_DEFINITIONS = Mr(e.env.BUNDLED_DEFINITIONS), e.env.BUNDLED_DEFINITIONS._isCompiled = !0), n = e.env.BUNDLED_DEFINITIONS), e.set("schemas", n);
|
|
13142
13044
|
let r = new URL(e.req.url), i = (e.req.header("host") || r.hostname).split(":")[0];
|
|
13143
13045
|
e.set("currentDomain", i);
|
|
13144
13046
|
let a = Rr(e);
|
|
13145
|
-
if (e.set("db", a), !
|
|
13146
|
-
await Hr(a, n),
|
|
13047
|
+
if (e.set("db", a), !ua) try {
|
|
13048
|
+
await Hr(a, n), ua = !0;
|
|
13147
13049
|
} catch (e) {
|
|
13148
13050
|
console.error("❌ [CMS Server] Failed to initialize system tables on cold start:", e);
|
|
13149
13051
|
}
|
|
13150
13052
|
await t();
|
|
13151
|
-
}), $.route("/media",
|
|
13053
|
+
}), $.route("/media", aa), $.use("/media/*", Wr()), $.route("/api/cms/nodes", X), $.route("/api/cms/nodes.json", X), $.route("/api/cms/formcsv", X), $.route("/api/cms/formcsv.json", X), $.route("/api/cms/stats", ki), $.route("/api/cms/stats.json", ki), $.route("/api/cms", _i), $.route("/api/cms/channels", xi), $.route("/api/cms/channels.json", xi), $.route("/api/cms/schemas", Ci), $.route("/api/cms/schemas.json", Ci), $.route("/api/admin/schemas", Ci), $.route("/api/cms", Ei), $.route("/api/admin/assets", Pi), $.route("/api/v1/node", Li), $.route("/api/v1/page", Li), $.route("/api/v1/tree", na), $.route("/api/v1/all-paths", sa), $.get("*", async (e) => {
|
|
13152
13054
|
if (e.env?.ASSETS) {
|
|
13153
13055
|
let t = await e.env.ASSETS.fetch(e.req.raw);
|
|
13154
13056
|
if (t.status === 404) {
|