@brightsideoy/kama 0.1.0-alpha.60 → 0.1.0-alpha.61
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/assets/{index-DpvSN1ER.js → index-C421HToM.js} +1 -1
- package/dist/index.html +1 -1
- package/dist/index.js +380 -342
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -140,66 +140,66 @@ function T(e) {
|
|
|
140
140
|
}
|
|
141
141
|
return !1;
|
|
142
142
|
}
|
|
143
|
-
var E = (e) => (S(e) || w(e)) && !!e.anchor, D = Symbol("break visit"),
|
|
144
|
-
function
|
|
145
|
-
let n =
|
|
146
|
-
y(e) ?
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
function
|
|
150
|
-
let i =
|
|
151
|
-
if (T(i) || x(i)) return
|
|
143
|
+
var E = (e) => (S(e) || w(e)) && !!e.anchor, D = Symbol("break visit"), O = Symbol("skip children"), k = Symbol("remove node");
|
|
144
|
+
function A(e, t) {
|
|
145
|
+
let n = ne(t);
|
|
146
|
+
y(e) ? j(null, e.contents, n, Object.freeze([e])) === k && (e.contents = null) : j(null, e, n, Object.freeze([]));
|
|
147
|
+
}
|
|
148
|
+
A.BREAK = D, A.SKIP = O, A.REMOVE = k;
|
|
149
|
+
function j(e, t, n, r) {
|
|
150
|
+
let i = re(e, t, n, r);
|
|
151
|
+
if (T(i) || x(i)) return M(e, r, i), j(e, i, n, r);
|
|
152
152
|
if (typeof i != "symbol") {
|
|
153
153
|
if (w(t)) {
|
|
154
154
|
r = Object.freeze(r.concat(t));
|
|
155
155
|
for (let e = 0; e < t.items.length; ++e) {
|
|
156
|
-
let i =
|
|
156
|
+
let i = j(e, t.items[e], n, r);
|
|
157
157
|
if (typeof i == "number") e = i - 1;
|
|
158
158
|
else if (i === D) return D;
|
|
159
|
-
else i ===
|
|
159
|
+
else i === k && (t.items.splice(e, 1), --e);
|
|
160
160
|
}
|
|
161
161
|
} else if (x(t)) {
|
|
162
162
|
r = Object.freeze(r.concat(t));
|
|
163
|
-
let e =
|
|
163
|
+
let e = j("key", t.key, n, r);
|
|
164
164
|
if (e === D) return D;
|
|
165
|
-
e ===
|
|
166
|
-
let i =
|
|
165
|
+
e === k && (t.key = null);
|
|
166
|
+
let i = j("value", t.value, n, r);
|
|
167
167
|
if (i === D) return D;
|
|
168
|
-
i ===
|
|
168
|
+
i === k && (t.value = null);
|
|
169
169
|
}
|
|
170
170
|
}
|
|
171
171
|
return i;
|
|
172
172
|
}
|
|
173
|
-
async function
|
|
174
|
-
let n =
|
|
175
|
-
y(e) ? await
|
|
173
|
+
async function ee(e, t) {
|
|
174
|
+
let n = ne(t);
|
|
175
|
+
y(e) ? await te(null, e.contents, n, Object.freeze([e])) === k && (e.contents = null) : await te(null, e, n, Object.freeze([]));
|
|
176
176
|
}
|
|
177
|
-
|
|
178
|
-
async function
|
|
179
|
-
let i = await
|
|
180
|
-
if (T(i) || x(i)) return
|
|
177
|
+
ee.BREAK = D, ee.SKIP = O, ee.REMOVE = k;
|
|
178
|
+
async function te(e, t, n, r) {
|
|
179
|
+
let i = await re(e, t, n, r);
|
|
180
|
+
if (T(i) || x(i)) return M(e, r, i), te(e, i, n, r);
|
|
181
181
|
if (typeof i != "symbol") {
|
|
182
182
|
if (w(t)) {
|
|
183
183
|
r = Object.freeze(r.concat(t));
|
|
184
184
|
for (let e = 0; e < t.items.length; ++e) {
|
|
185
|
-
let i = await
|
|
185
|
+
let i = await te(e, t.items[e], n, r);
|
|
186
186
|
if (typeof i == "number") e = i - 1;
|
|
187
187
|
else if (i === D) return D;
|
|
188
|
-
else i ===
|
|
188
|
+
else i === k && (t.items.splice(e, 1), --e);
|
|
189
189
|
}
|
|
190
190
|
} else if (x(t)) {
|
|
191
191
|
r = Object.freeze(r.concat(t));
|
|
192
|
-
let e = await
|
|
192
|
+
let e = await te("key", t.key, n, r);
|
|
193
193
|
if (e === D) return D;
|
|
194
|
-
e ===
|
|
195
|
-
let i = await
|
|
194
|
+
e === k && (t.key = null);
|
|
195
|
+
let i = await te("value", t.value, n, r);
|
|
196
196
|
if (i === D) return D;
|
|
197
|
-
i ===
|
|
197
|
+
i === k && (t.value = null);
|
|
198
198
|
}
|
|
199
199
|
}
|
|
200
200
|
return i;
|
|
201
201
|
}
|
|
202
|
-
function
|
|
202
|
+
function ne(e) {
|
|
203
203
|
return typeof e == "object" && (e.Collection || e.Node || e.Value) ? Object.assign({
|
|
204
204
|
Alias: e.Node,
|
|
205
205
|
Map: e.Node,
|
|
@@ -214,7 +214,7 @@ function re(e) {
|
|
|
214
214
|
Seq: e.Collection
|
|
215
215
|
}, e) : e;
|
|
216
216
|
}
|
|
217
|
-
function
|
|
217
|
+
function re(e, t, n, r) {
|
|
218
218
|
if (typeof n == "function") return n(e, t, r);
|
|
219
219
|
if (b(t)) return n.Map?.(e, t, r);
|
|
220
220
|
if (C(t)) return n.Seq?.(e, t, r);
|
|
@@ -222,7 +222,7 @@ function ie(e, t, n, r) {
|
|
|
222
222
|
if (S(t)) return n.Scalar?.(e, t, r);
|
|
223
223
|
if (v(t)) return n.Alias?.(e, t, r);
|
|
224
224
|
}
|
|
225
|
-
function
|
|
225
|
+
function M(e, t, n) {
|
|
226
226
|
let r = t[t.length - 1];
|
|
227
227
|
if (w(r)) r.items[e] = n;
|
|
228
228
|
else if (x(r)) e === "key" ? r.key = n : r.value = n;
|
|
@@ -234,14 +234,14 @@ function j(e, t, n) {
|
|
|
234
234
|
}
|
|
235
235
|
//#endregion
|
|
236
236
|
//#region node_modules/yaml/browser/dist/doc/directives.js
|
|
237
|
-
var
|
|
237
|
+
var ie = {
|
|
238
238
|
"!": "%21",
|
|
239
239
|
",": "%2C",
|
|
240
240
|
"[": "%5B",
|
|
241
241
|
"]": "%5D",
|
|
242
242
|
"{": "%7B",
|
|
243
243
|
"}": "%7D"
|
|
244
|
-
},
|
|
244
|
+
}, ae = (e) => e.replace(/[!,[\]{}]/g, (e) => ie[e]), oe = class e {
|
|
245
245
|
constructor(t, n) {
|
|
246
246
|
this.docStart = null, this.docEnd = !1, this.yaml = Object.assign({}, e.defaultYaml, t), this.tags = Object.assign({}, e.defaultTags, n);
|
|
247
247
|
}
|
|
@@ -304,14 +304,14 @@ var ae = {
|
|
|
304
304
|
return n === "!" ? e : (t(`Could not resolve tag: ${e}`), null);
|
|
305
305
|
}
|
|
306
306
|
tagString(e) {
|
|
307
|
-
for (let [t, n] of Object.entries(this.tags)) if (e.startsWith(n)) return t +
|
|
307
|
+
for (let [t, n] of Object.entries(this.tags)) if (e.startsWith(n)) return t + ae(e.substring(n.length));
|
|
308
308
|
return e[0] === "!" ? e : `!<${e}>`;
|
|
309
309
|
}
|
|
310
310
|
toString(e) {
|
|
311
311
|
let t = this.yaml.explicit ? [`%YAML ${this.yaml.version || "1.2"}`] : [], n = Object.entries(this.tags), r;
|
|
312
312
|
if (e && n.length > 0 && T(e.contents)) {
|
|
313
313
|
let t = {};
|
|
314
|
-
|
|
314
|
+
A(e.contents, (e, n) => {
|
|
315
315
|
T(n) && n.tag && (t[n.tag] = !0);
|
|
316
316
|
}), r = Object.keys(t);
|
|
317
317
|
} else r = [];
|
|
@@ -319,37 +319,37 @@ var ae = {
|
|
|
319
319
|
return t.join("\n");
|
|
320
320
|
}
|
|
321
321
|
};
|
|
322
|
-
|
|
322
|
+
oe.defaultYaml = {
|
|
323
323
|
explicit: !1,
|
|
324
324
|
version: "1.2"
|
|
325
|
-
},
|
|
325
|
+
}, oe.defaultTags = { "!!": "tag:yaml.org,2002:" };
|
|
326
326
|
//#endregion
|
|
327
327
|
//#region node_modules/yaml/browser/dist/doc/anchors.js
|
|
328
|
-
function
|
|
328
|
+
function se(e) {
|
|
329
329
|
if (/[\x00-\x19\s,[\]{}]/.test(e)) {
|
|
330
330
|
let t = `Anchor must not contain whitespace or control characters: ${JSON.stringify(e)}`;
|
|
331
331
|
throw Error(t);
|
|
332
332
|
}
|
|
333
333
|
return !0;
|
|
334
334
|
}
|
|
335
|
-
function
|
|
335
|
+
function ce(e) {
|
|
336
336
|
let t = /* @__PURE__ */ new Set();
|
|
337
|
-
return
|
|
337
|
+
return A(e, { Value(e, n) {
|
|
338
338
|
n.anchor && t.add(n.anchor);
|
|
339
339
|
} }), t;
|
|
340
340
|
}
|
|
341
|
-
function
|
|
341
|
+
function N(e, t) {
|
|
342
342
|
for (let n = 1;; ++n) {
|
|
343
343
|
let r = `${e}${n}`;
|
|
344
344
|
if (!t.has(r)) return r;
|
|
345
345
|
}
|
|
346
346
|
}
|
|
347
|
-
function
|
|
347
|
+
function le(e, t) {
|
|
348
348
|
let n = [], r = /* @__PURE__ */ new Map(), i = null;
|
|
349
349
|
return {
|
|
350
350
|
onAnchor: (r) => {
|
|
351
|
-
n.push(r), i ??=
|
|
352
|
-
let a =
|
|
351
|
+
n.push(r), i ??= ce(e);
|
|
352
|
+
let a = N(t, i);
|
|
353
353
|
return i.add(a), a;
|
|
354
354
|
},
|
|
355
355
|
setAnchors: () => {
|
|
@@ -367,22 +367,22 @@ function ue(e, t) {
|
|
|
367
367
|
}
|
|
368
368
|
//#endregion
|
|
369
369
|
//#region node_modules/yaml/browser/dist/doc/applyReviver.js
|
|
370
|
-
function
|
|
370
|
+
function P(e, t, n, r) {
|
|
371
371
|
if (r && typeof r == "object") {
|
|
372
372
|
if (Array.isArray(r)) for (let t = 0, n = r.length; t < n; ++t) {
|
|
373
|
-
let n = r[t], i =
|
|
373
|
+
let n = r[t], i = P(e, r, String(t), n);
|
|
374
374
|
i === void 0 ? delete r[t] : i !== n && (r[t] = i);
|
|
375
375
|
}
|
|
376
376
|
else if (r instanceof Map) for (let t of Array.from(r.keys())) {
|
|
377
|
-
let n = r.get(t), i =
|
|
377
|
+
let n = r.get(t), i = P(e, r, t, n);
|
|
378
378
|
i === void 0 ? r.delete(t) : i !== n && r.set(t, i);
|
|
379
379
|
}
|
|
380
380
|
else if (r instanceof Set) for (let t of Array.from(r)) {
|
|
381
|
-
let n =
|
|
381
|
+
let n = P(e, r, t, t);
|
|
382
382
|
n === void 0 ? r.delete(t) : n !== t && (r.delete(t), r.add(n));
|
|
383
383
|
}
|
|
384
384
|
else for (let [t, n] of Object.entries(r)) {
|
|
385
|
-
let i =
|
|
385
|
+
let i = P(e, r, t, n);
|
|
386
386
|
i === void 0 ? delete r[t] : i !== n && (r[t] = i);
|
|
387
387
|
}
|
|
388
388
|
}
|
|
@@ -390,8 +390,8 @@ function N(e, t, n, r) {
|
|
|
390
390
|
}
|
|
391
391
|
//#endregion
|
|
392
392
|
//#region node_modules/yaml/browser/dist/nodes/toJS.js
|
|
393
|
-
function
|
|
394
|
-
if (Array.isArray(e)) return e.map((e, t) =>
|
|
393
|
+
function F(e, t, n) {
|
|
394
|
+
if (Array.isArray(e)) return e.map((e, t) => F(e, String(t), n));
|
|
395
395
|
if (e && typeof e.toJSON == "function") {
|
|
396
396
|
if (!n || !E(e)) return e.toJSON(t, n);
|
|
397
397
|
let r = {
|
|
@@ -409,7 +409,7 @@ function P(e, t, n) {
|
|
|
409
409
|
}
|
|
410
410
|
//#endregion
|
|
411
411
|
//#region node_modules/yaml/browser/dist/nodes/Node.js
|
|
412
|
-
var
|
|
412
|
+
var ue = class {
|
|
413
413
|
constructor(e) {
|
|
414
414
|
Object.defineProperty(this, _, { value: e });
|
|
415
415
|
}
|
|
@@ -426,11 +426,11 @@ var de = class {
|
|
|
426
426
|
mapAsMap: t === !0,
|
|
427
427
|
mapKeyWarned: !1,
|
|
428
428
|
maxAliasCount: typeof n == "number" ? n : 100
|
|
429
|
-
}, o =
|
|
429
|
+
}, o = F(this, "", a);
|
|
430
430
|
if (typeof r == "function") for (let { count: e, res: t } of a.anchors.values()) r(t, e);
|
|
431
|
-
return typeof i == "function" ?
|
|
431
|
+
return typeof i == "function" ? P(i, { "": o }, "", o) : o;
|
|
432
432
|
}
|
|
433
|
-
},
|
|
433
|
+
}, de = class extends ue {
|
|
434
434
|
constructor(e) {
|
|
435
435
|
super(d), this.source = e, Object.defineProperty(this, "tag", { set() {
|
|
436
436
|
throw Error("Alias nodes cannot have tags");
|
|
@@ -439,7 +439,7 @@ var de = class {
|
|
|
439
439
|
resolve(e, t) {
|
|
440
440
|
if (t?.maxAliasCount === 0) throw ReferenceError("Alias resolution is disabled");
|
|
441
441
|
let n;
|
|
442
|
-
t?.aliasResolveCache ? n = t.aliasResolveCache : (n = [],
|
|
442
|
+
t?.aliasResolveCache ? n = t.aliasResolveCache : (n = [], A(e, { Node: (e, t) => {
|
|
443
443
|
(v(t) || E(t)) && n.push(t);
|
|
444
444
|
} }), t && (t.aliasResolveCache = n));
|
|
445
445
|
let r;
|
|
@@ -458,14 +458,14 @@ var de = class {
|
|
|
458
458
|
}
|
|
459
459
|
let o = n.get(a);
|
|
460
460
|
/* istanbul ignore if */
|
|
461
|
-
if (o ||= (
|
|
462
|
-
if (i >= 0 && (o.count += 1, o.aliasCount === 0 && (o.aliasCount =
|
|
461
|
+
if (o ||= (F(a, null, t), n.get(a)), o?.res === void 0) throw ReferenceError("This should not happen: Alias anchor was not resolved?");
|
|
462
|
+
if (i >= 0 && (o.count += 1, o.aliasCount === 0 && (o.aliasCount = fe(r, a, n)), o.count * o.aliasCount > i)) throw ReferenceError("Excessive alias count indicates a resource exhaustion attack");
|
|
463
463
|
return o.res;
|
|
464
464
|
}
|
|
465
465
|
toString(e, t, n) {
|
|
466
466
|
let r = `*${this.source}`;
|
|
467
467
|
if (e) {
|
|
468
|
-
if (
|
|
468
|
+
if (se(this.source), e.options.verifyAliasOrder && !e.anchors.has(this.source)) {
|
|
469
469
|
let e = `Unresolved alias (the anchor must be set before the alias): ${this.source}`;
|
|
470
470
|
throw Error(e);
|
|
471
471
|
}
|
|
@@ -474,7 +474,7 @@ var de = class {
|
|
|
474
474
|
return r;
|
|
475
475
|
}
|
|
476
476
|
};
|
|
477
|
-
function
|
|
477
|
+
function fe(e, t, n) {
|
|
478
478
|
if (v(t)) {
|
|
479
479
|
let r = t.resolve(e), i = n && r && n.get(r);
|
|
480
480
|
return i ? i.count * i.aliasCount : 0;
|
|
@@ -482,35 +482,35 @@ function pe(e, t, n) {
|
|
|
482
482
|
if (w(t)) {
|
|
483
483
|
let r = 0;
|
|
484
484
|
for (let i of t.items) {
|
|
485
|
-
let t =
|
|
485
|
+
let t = fe(e, i, n);
|
|
486
486
|
t > r && (r = t);
|
|
487
487
|
}
|
|
488
488
|
return r;
|
|
489
489
|
}
|
|
490
490
|
if (x(t)) {
|
|
491
|
-
let r =
|
|
491
|
+
let r = fe(e, t.key, n), i = fe(e, t.value, n);
|
|
492
492
|
return Math.max(r, i);
|
|
493
493
|
}
|
|
494
494
|
return 1;
|
|
495
495
|
}
|
|
496
496
|
//#endregion
|
|
497
497
|
//#region node_modules/yaml/browser/dist/nodes/Scalar.js
|
|
498
|
-
var
|
|
498
|
+
var pe = (e) => !e || typeof e != "function" && typeof e != "object", I = class extends ue {
|
|
499
499
|
constructor(e) {
|
|
500
500
|
super(h), this.value = e;
|
|
501
501
|
}
|
|
502
502
|
toJSON(e, t) {
|
|
503
|
-
return t?.keep ? this.value :
|
|
503
|
+
return t?.keep ? this.value : F(this.value, e, t);
|
|
504
504
|
}
|
|
505
505
|
toString() {
|
|
506
506
|
return String(this.value);
|
|
507
507
|
}
|
|
508
508
|
};
|
|
509
|
-
|
|
509
|
+
I.BLOCK_FOLDED = "BLOCK_FOLDED", I.BLOCK_LITERAL = "BLOCK_LITERAL", I.PLAIN = "PLAIN", I.QUOTE_DOUBLE = "QUOTE_DOUBLE", I.QUOTE_SINGLE = "QUOTE_SINGLE";
|
|
510
510
|
//#endregion
|
|
511
511
|
//#region node_modules/yaml/browser/dist/doc/createNode.js
|
|
512
|
-
var
|
|
513
|
-
function
|
|
512
|
+
var me = "tag:yaml.org,2002:";
|
|
513
|
+
function he(e, t, n) {
|
|
514
514
|
if (t) {
|
|
515
515
|
let e = n.filter((e) => e.tag === t), r = e.find((e) => !e.format) ?? e[0];
|
|
516
516
|
if (!r) throw Error(`Tag ${t} not found`);
|
|
@@ -518,7 +518,7 @@ function ge(e, t, n) {
|
|
|
518
518
|
}
|
|
519
519
|
return n.find((t) => t.identify?.(e) && !t.format);
|
|
520
520
|
}
|
|
521
|
-
function
|
|
521
|
+
function ge(e, t, n) {
|
|
522
522
|
if (y(e) && (e = e.contents), T(e)) return e;
|
|
523
523
|
if (x(e)) {
|
|
524
524
|
let t = n.schema[p].createNode?.(n.schema, null, n);
|
|
@@ -527,28 +527,28 @@ function _e(e, t, n) {
|
|
|
527
527
|
(e instanceof String || e instanceof Number || e instanceof Boolean || typeof BigInt < "u" && e instanceof BigInt) && (e = e.valueOf());
|
|
528
528
|
let { aliasDuplicateObjects: r, onAnchor: i, onTagObj: a, schema: o, sourceObjects: s } = n, c;
|
|
529
529
|
if (r && e && typeof e == "object") {
|
|
530
|
-
if (c = s.get(e), c) return c.anchor ?? (c.anchor = i(e)), new
|
|
530
|
+
if (c = s.get(e), c) return c.anchor ?? (c.anchor = i(e)), new de(c.anchor);
|
|
531
531
|
c = {
|
|
532
532
|
anchor: null,
|
|
533
533
|
node: null
|
|
534
534
|
}, s.set(e, c);
|
|
535
535
|
}
|
|
536
|
-
t?.startsWith("!!") && (t =
|
|
537
|
-
let l =
|
|
536
|
+
t?.startsWith("!!") && (t = me + t.slice(2));
|
|
537
|
+
let l = he(e, t, o.tags);
|
|
538
538
|
if (!l) {
|
|
539
539
|
if (e && typeof e.toJSON == "function" && (e = e.toJSON()), !e || typeof e != "object") {
|
|
540
|
-
let t = new
|
|
540
|
+
let t = new I(e);
|
|
541
541
|
return c && (c.node = t), t;
|
|
542
542
|
}
|
|
543
543
|
l = e instanceof Map ? o[p] : Symbol.iterator in Object(e) ? o[g] : o[p];
|
|
544
544
|
}
|
|
545
545
|
a && (a(l), delete n.onTagObj);
|
|
546
|
-
let u = l?.createNode ? l.createNode(n.schema, e, n) : typeof l?.nodeClass?.from == "function" ? l.nodeClass.from(n.schema, e, n) : new
|
|
546
|
+
let u = l?.createNode ? l.createNode(n.schema, e, n) : typeof l?.nodeClass?.from == "function" ? l.nodeClass.from(n.schema, e, n) : new I(e);
|
|
547
547
|
return t ? u.tag = t : l.default || (u.tag = l.tag), c && (c.node = u), u;
|
|
548
548
|
}
|
|
549
549
|
//#endregion
|
|
550
550
|
//#region node_modules/yaml/browser/dist/nodes/Collection.js
|
|
551
|
-
function
|
|
551
|
+
function _e(e, t, n) {
|
|
552
552
|
let r = n;
|
|
553
553
|
for (let e = t.length - 1; e >= 0; --e) {
|
|
554
554
|
let n = t[e];
|
|
@@ -557,7 +557,7 @@ function ve(e, t, n) {
|
|
|
557
557
|
e[n] = r, r = e;
|
|
558
558
|
} else r = /* @__PURE__ */ new Map([[n, r]]);
|
|
559
559
|
}
|
|
560
|
-
return
|
|
560
|
+
return ge(r, void 0, {
|
|
561
561
|
aliasDuplicateObjects: !1,
|
|
562
562
|
keepUndefined: !1,
|
|
563
563
|
onAnchor: () => {
|
|
@@ -567,7 +567,7 @@ function ve(e, t, n) {
|
|
|
567
567
|
sourceObjects: /* @__PURE__ */ new Map()
|
|
568
568
|
});
|
|
569
569
|
}
|
|
570
|
-
var
|
|
570
|
+
var ve = (e) => e == null || typeof e == "object" && !!e[Symbol.iterator]().next().done, ye = class extends ue {
|
|
571
571
|
constructor(e, t) {
|
|
572
572
|
super(e), Object.defineProperty(this, "schema", {
|
|
573
573
|
value: t,
|
|
@@ -581,11 +581,11 @@ var ye = (e) => e == null || typeof e == "object" && !!e[Symbol.iterator]().next
|
|
|
581
581
|
return e && (t.schema = e), t.items = t.items.map((t) => T(t) || x(t) ? t.clone(e) : t), this.range && (t.range = this.range.slice()), t;
|
|
582
582
|
}
|
|
583
583
|
addIn(e, t) {
|
|
584
|
-
if (
|
|
584
|
+
if (ve(e)) this.add(t);
|
|
585
585
|
else {
|
|
586
586
|
let [n, ...r] = e, i = this.get(n, !0);
|
|
587
587
|
if (w(i)) i.addIn(r, t);
|
|
588
|
-
else if (i === void 0 && this.schema) this.set(n,
|
|
588
|
+
else if (i === void 0 && this.schema) this.set(n, _e(this.schema, r, t));
|
|
589
589
|
else throw Error(`Expected YAML collection at ${n}. Remaining path: ${r}`);
|
|
590
590
|
}
|
|
591
591
|
}
|
|
@@ -619,15 +619,15 @@ var ye = (e) => e == null || typeof e == "object" && !!e[Symbol.iterator]().next
|
|
|
619
619
|
else {
|
|
620
620
|
let e = this.get(n, !0);
|
|
621
621
|
if (w(e)) e.setIn(r, t);
|
|
622
|
-
else if (e === void 0 && this.schema) this.set(n,
|
|
622
|
+
else if (e === void 0 && this.schema) this.set(n, _e(this.schema, r, t));
|
|
623
623
|
else throw Error(`Expected YAML collection at ${n}. Remaining path: ${r}`);
|
|
624
624
|
}
|
|
625
625
|
}
|
|
626
|
-
},
|
|
627
|
-
function
|
|
626
|
+
}, be = (e) => e.replace(/^(?!$)(?: $)?/gm, "#");
|
|
627
|
+
function L(e, t) {
|
|
628
628
|
return /^\n+$/.test(e) ? e.substring(1) : t ? e.replace(/^(?! *$)/gm, t) : e;
|
|
629
629
|
}
|
|
630
|
-
var
|
|
630
|
+
var xe = (e, t, n) => e.endsWith("\n") ? L(n, t) : n.includes("\n") ? "\n" + L(n, t) : (e.endsWith(" ") ? "" : " ") + n, Se = "flow", Ce = "block", we = "quoted";
|
|
631
631
|
function Te(e, t, n = "flow", { indentAtStart: r, lineWidth: i = 80, minContentWidth: a = 20, onFold: o, onOverflow: s } = {}) {
|
|
632
632
|
if (!i || i < 0) return e;
|
|
633
633
|
i < a && (a = 0);
|
|
@@ -781,7 +781,7 @@ try {
|
|
|
781
781
|
function Pe({ comment: e, type: t, value: n }, r, i, a) {
|
|
782
782
|
let { blockQuote: o, commentString: s, lineWidth: c } = r.options;
|
|
783
783
|
if (!o || /\n[\t ]+$/.test(n)) return Me(n, r);
|
|
784
|
-
let l = r.indent || (r.forceBlockIndent || Oe(n) ? " " : ""), u = o === "literal" ? !0 : o === "folded" || t ===
|
|
784
|
+
let l = r.indent || (r.forceBlockIndent || Oe(n) ? " " : ""), u = o === "literal" ? !0 : o === "folded" || t === I.BLOCK_FOLDED ? !1 : t === I.BLOCK_LITERAL || !ke(n, c, l.length);
|
|
785
785
|
if (!n) return u ? "|\n" : ">\n";
|
|
786
786
|
let d, f;
|
|
787
787
|
for (f = n.length; f > 0; --f) {
|
|
@@ -802,7 +802,7 @@ function Pe({ comment: e, type: t, value: n }, r, i, a) {
|
|
|
802
802
|
let y = (h ? l ? "2" : "1" : "") + d;
|
|
803
803
|
if (e && (y += " " + s(e.replace(/ ?[\r\n]+/g, " ")), i && i()), !u) {
|
|
804
804
|
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 = De(r, !0);
|
|
805
|
-
o !== "folded" && t !==
|
|
805
|
+
o !== "folded" && t !== I.BLOCK_FOLDED && (a.onOverflow = () => {
|
|
806
806
|
i = !0;
|
|
807
807
|
});
|
|
808
808
|
let s = Te(`${v}${e}${p}`, l, Ce, a);
|
|
@@ -814,7 +814,7 @@ function Fe(e, t, n, r) {
|
|
|
814
814
|
let { type: i, value: a } = e, { actualString: o, implicitKey: s, indent: c, indentStep: l, inFlow: u } = t;
|
|
815
815
|
if (s && a.includes("\n") || u && /[[\]{},]/.test(a)) return Me(a, t);
|
|
816
816
|
if (/^[\n\t ,[\]{}#&*!|>'"%@`]|^[?-]$|^[?-][ \t]|[\n:][ \t]|[ \t]\n|[\n\t ]#|[\n\t :]$/.test(a)) return s || u || !a.includes("\n") ? Me(a, t) : Pe(e, t, n, r);
|
|
817
|
-
if (!s && !u && i !==
|
|
817
|
+
if (!s && !u && i !== I.PLAIN && a.includes("\n")) return Pe(e, t, n, r);
|
|
818
818
|
if (Oe(a)) {
|
|
819
819
|
if (c === "") return t.forceBlockIndent = !0, Pe(e, t, n, r);
|
|
820
820
|
if (s && c === l) return Me(a, t);
|
|
@@ -828,14 +828,14 @@ function Fe(e, t, n, r) {
|
|
|
828
828
|
}
|
|
829
829
|
function Ie(e, t, n, r) {
|
|
830
830
|
let { implicitKey: i, inFlow: a } = t, o = typeof e.value == "string" ? e : Object.assign({}, e, { value: String(e.value) }), { type: s } = e;
|
|
831
|
-
s !==
|
|
831
|
+
s !== I.QUOTE_DOUBLE && /[\x00-\x08\x0b-\x1f\x7f-\x9f\u{D800}-\u{DFFF}]/u.test(o.value) && (s = I.QUOTE_DOUBLE);
|
|
832
832
|
let c = (e) => {
|
|
833
833
|
switch (e) {
|
|
834
|
-
case
|
|
835
|
-
case
|
|
836
|
-
case
|
|
837
|
-
case
|
|
838
|
-
case
|
|
834
|
+
case I.BLOCK_FOLDED:
|
|
835
|
+
case I.BLOCK_LITERAL: return i || a ? Me(o.value, t) : Pe(o, t, n, r);
|
|
836
|
+
case I.QUOTE_DOUBLE: return Ae(o.value, t);
|
|
837
|
+
case I.QUOTE_SINGLE: return je(o.value, t);
|
|
838
|
+
case I.PLAIN: return Fe(o, t, n, r);
|
|
839
839
|
default: return null;
|
|
840
840
|
}
|
|
841
841
|
}, l = c(s);
|
|
@@ -850,7 +850,7 @@ function Ie(e, t, n, r) {
|
|
|
850
850
|
function Le(e, t) {
|
|
851
851
|
let n = Object.assign({
|
|
852
852
|
blockQuote: !0,
|
|
853
|
-
commentString:
|
|
853
|
+
commentString: be,
|
|
854
854
|
defaultKeyType: null,
|
|
855
855
|
defaultStringType: "PLAIN",
|
|
856
856
|
directives: null,
|
|
@@ -911,7 +911,7 @@ function Re(e, t) {
|
|
|
911
911
|
function ze(e, t, { anchors: n, doc: r }) {
|
|
912
912
|
if (!r.directives) return "";
|
|
913
913
|
let i = [], a = (S(e) || w(e)) && e.anchor;
|
|
914
|
-
a &&
|
|
914
|
+
a && se(a) && (n.add(a), i.push(`&${a}`));
|
|
915
915
|
let o = e.tag ?? (t.default ? null : t.tag);
|
|
916
916
|
return o && i.push(r.directives.tagString(o)), i.join(" ");
|
|
917
917
|
}
|
|
@@ -937,7 +937,7 @@ function Ve({ key: e, value: t }, n, r, i) {
|
|
|
937
937
|
if (f) throw Error("With simple keys, key nodes cannot have comments");
|
|
938
938
|
if (w(e) || !T(e) && typeof e == "object") throw Error("With simple keys, collection cannot be used as a key value");
|
|
939
939
|
}
|
|
940
|
-
let p = !d && (!e || f && t == null && !n.inFlow || w(e) || (S(e) ? e.type ===
|
|
940
|
+
let p = !d && (!e || f && t == null && !n.inFlow || w(e) || (S(e) ? e.type === I.BLOCK_FOLDED || e.type === I.BLOCK_LITERAL : typeof e == "object"));
|
|
941
941
|
n = Object.assign({}, n, {
|
|
942
942
|
allNullValues: !1,
|
|
943
943
|
implicitKey: !p && (d || !a),
|
|
@@ -950,15 +950,15 @@ function Ve({ key: e, value: t }, n, r, i) {
|
|
|
950
950
|
}
|
|
951
951
|
if (n.inFlow) {
|
|
952
952
|
if (a || t == null) return m && r && r(), g === "" ? "?" : p ? `? ${g}` : g;
|
|
953
|
-
} else if (a && !d || t == null && p) return g = `? ${g}`, f && !m ? g +=
|
|
954
|
-
m && (f = null), p ? (f && (g +=
|
|
953
|
+
} else if (a && !d || t == null && p) return g = `? ${g}`, f && !m ? g += xe(g, n.indent, l(f)) : h && i && i(), g;
|
|
954
|
+
m && (f = null), p ? (f && (g += xe(g, n.indent, l(f))), g = `? ${g}\n${s}:`) : (g = `${g}:`, f && (g += xe(g, n.indent, l(f))));
|
|
955
955
|
let _, v, y;
|
|
956
956
|
T(t) ? (_ = !!t.spaceBefore, v = t.commentBefore, y = t.comment) : (_ = !1, v = null, y = null, t && typeof t == "object" && (t = o.createNode(t))), n.implicitKey = !1, !p && !f && S(t) && (n.indentAtStart = g.length + 1), h = !1, !u && c.length >= 2 && !n.inFlow && !p && C(t) && !t.flow && !t.tag && !t.anchor && (n.indent = n.indent.substring(2));
|
|
957
957
|
let b = !1, x = Be(t, n, () => b = !0, () => h = !0), E = " ";
|
|
958
958
|
if (f || _ || v) {
|
|
959
959
|
if (E = _ ? "\n" : "", v) {
|
|
960
960
|
let e = l(v);
|
|
961
|
-
E += `\n${
|
|
961
|
+
E += `\n${L(e, n.indent)}`;
|
|
962
962
|
}
|
|
963
963
|
x === "" && !n.inFlow ? E === "\n" && y && (E = "\n\n") : E += `\n${n.indent}`;
|
|
964
964
|
} else if (!p && w(t)) {
|
|
@@ -972,7 +972,7 @@ function Ve({ key: e, value: t }, n, r, i) {
|
|
|
972
972
|
t || (E = `\n${n.indent}`);
|
|
973
973
|
}
|
|
974
974
|
} else (x === "" || x[0] === "\n") && (E = "");
|
|
975
|
-
return g += E + x, n.inFlow ? b && r && r() : y && !b ? g +=
|
|
975
|
+
return g += E + x, n.inFlow ? b && r && r() : y && !b ? g += xe(g, n.indent, l(y)) : h && i && i(), g;
|
|
976
976
|
}
|
|
977
977
|
//#endregion
|
|
978
978
|
//#region node_modules/yaml/browser/dist/log.js
|
|
@@ -986,9 +986,9 @@ var Ue = "<<", R = {
|
|
|
986
986
|
default: "key",
|
|
987
987
|
tag: "tag:yaml.org,2002:merge",
|
|
988
988
|
test: /^<<$/,
|
|
989
|
-
resolve: () => Object.assign(new
|
|
989
|
+
resolve: () => Object.assign(new I(Symbol(Ue)), { addToJSMap: Ge }),
|
|
990
990
|
stringify: () => Ue
|
|
991
|
-
}, We = (e, t) => (R.identify(t) || S(t) && (!t.type || t.type ===
|
|
991
|
+
}, We = (e, t) => (R.identify(t) || S(t) && (!t.type || t.type === I.PLAIN) && R.identify(t.value)) && e?.doc.schema.tags.some((e) => e.tag === R.tag && e.default);
|
|
992
992
|
function Ge(e, t, n) {
|
|
993
993
|
let r = qe(e, n);
|
|
994
994
|
if (C(r)) for (let n of r.items) Ke(e, t, n);
|
|
@@ -1016,11 +1016,11 @@ function Je(e, t, { key: n, value: r }) {
|
|
|
1016
1016
|
if (T(n) && n.addToJSMap) n.addToJSMap(e, t, r);
|
|
1017
1017
|
else if (We(e, n)) Ge(e, t, r);
|
|
1018
1018
|
else {
|
|
1019
|
-
let i =
|
|
1020
|
-
if (t instanceof Map) t.set(i,
|
|
1019
|
+
let i = F(n, "", e);
|
|
1020
|
+
if (t instanceof Map) t.set(i, F(r, i, e));
|
|
1021
1021
|
else if (t instanceof Set) t.add(i);
|
|
1022
1022
|
else {
|
|
1023
|
-
let a = Ye(n, i, e), o =
|
|
1023
|
+
let a = Ye(n, i, e), o = F(r, a, e);
|
|
1024
1024
|
a in t ? Object.defineProperty(t, a, {
|
|
1025
1025
|
value: o,
|
|
1026
1026
|
writable: !0,
|
|
@@ -1051,7 +1051,7 @@ function Ye(e, t, n) {
|
|
|
1051
1051
|
//#endregion
|
|
1052
1052
|
//#region node_modules/yaml/browser/dist/nodes/Pair.js
|
|
1053
1053
|
function Xe(e, t, n) {
|
|
1054
|
-
return new z(
|
|
1054
|
+
return new z(ge(e, void 0, n), ge(t, void 0, n));
|
|
1055
1055
|
}
|
|
1056
1056
|
var z = class e {
|
|
1057
1057
|
constructor(e, t = null) {
|
|
@@ -1087,7 +1087,7 @@ function Qe({ comment: e, items: t }, n, { blockItemPrefix: r, flowChars: i, ite
|
|
|
1087
1087
|
}
|
|
1088
1088
|
d = !1;
|
|
1089
1089
|
let s = Be(i, u, () => o = null, () => d = !0);
|
|
1090
|
-
o && (s +=
|
|
1090
|
+
o && (s += xe(s, a, l(o))), d && o && (d = !1), f.push(r + s);
|
|
1091
1091
|
}
|
|
1092
1092
|
let p;
|
|
1093
1093
|
if (f.length === 0) p = i.start + i.end;
|
|
@@ -1098,7 +1098,7 @@ function Qe({ comment: e, items: t }, n, { blockItemPrefix: r, flowChars: i, ite
|
|
|
1098
1098
|
p += t ? `\n${c}${t}` : "\n";
|
|
1099
1099
|
}
|
|
1100
1100
|
}
|
|
1101
|
-
return e ? (p += "\n" +
|
|
1101
|
+
return e ? (p += "\n" + L(l(e), c), s && s()) : d && o && o(), p;
|
|
1102
1102
|
}
|
|
1103
1103
|
function $e({ items: e }, t, { flowChars: n, itemIndent: r }) {
|
|
1104
1104
|
let { indent: i, indentStep: a, flowCollectionPadding: o, options: { commentString: s } } = t;
|
|
@@ -1119,7 +1119,7 @@ function $e({ items: e }, t, { flowChars: n, itemIndent: r }) {
|
|
|
1119
1119
|
}
|
|
1120
1120
|
a && (l = !0);
|
|
1121
1121
|
let o = Be(i, c, () => a = null);
|
|
1122
|
-
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 +=
|
|
1122
|
+
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 += xe(o, r, s(a))), d.push(o), u = d.length;
|
|
1123
1123
|
}
|
|
1124
1124
|
let { start: f, end: p } = n;
|
|
1125
1125
|
if (d.length === 0) return f + p;
|
|
@@ -1136,7 +1136,7 @@ function $e({ items: e }, t, { flowChars: n, itemIndent: r }) {
|
|
|
1136
1136
|
}
|
|
1137
1137
|
function et({ indent: e, options: { commentString: t } }, n, r, i) {
|
|
1138
1138
|
if (r && i && (r = r.replace(/^\n+/, "")), r) {
|
|
1139
|
-
let i =
|
|
1139
|
+
let i = L(t(r), e);
|
|
1140
1140
|
n.push(i.trimStart());
|
|
1141
1141
|
}
|
|
1142
1142
|
}
|
|
@@ -1146,7 +1146,7 @@ function tt(e, t) {
|
|
|
1146
1146
|
let n = S(t) ? t.value : t;
|
|
1147
1147
|
for (let r of e) if (x(r) && (r.key === t || r.key === n || S(r.key) && r.key.value === n)) return r;
|
|
1148
1148
|
}
|
|
1149
|
-
var B = class extends
|
|
1149
|
+
var B = class extends ye {
|
|
1150
1150
|
static get tagName() {
|
|
1151
1151
|
return "tag:yaml.org,2002:map";
|
|
1152
1152
|
}
|
|
@@ -1169,7 +1169,7 @@ var B = class extends be {
|
|
|
1169
1169
|
let r = tt(this.items, n.key), i = this.schema?.sortMapEntries;
|
|
1170
1170
|
if (r) {
|
|
1171
1171
|
if (!t) throw Error(`Key ${n.key} already set`);
|
|
1172
|
-
S(r.value) &&
|
|
1172
|
+
S(r.value) && pe(n.value) ? r.value.value = n.value : r.value = n.value;
|
|
1173
1173
|
} else if (i) {
|
|
1174
1174
|
let e = this.items.findIndex((e) => i(n, e) < 0);
|
|
1175
1175
|
e === -1 ? this.items.push(n) : this.items.splice(e, 0, n);
|
|
@@ -1218,7 +1218,7 @@ var B = class extends be {
|
|
|
1218
1218
|
return b(e) || t("Expected a mapping for this tag"), e;
|
|
1219
1219
|
},
|
|
1220
1220
|
createNode: (e, t, n) => B.from(e, t, n)
|
|
1221
|
-
}, V = class extends
|
|
1221
|
+
}, V = class extends ye {
|
|
1222
1222
|
static get tagName() {
|
|
1223
1223
|
return "tag:yaml.org,2002:seq";
|
|
1224
1224
|
}
|
|
@@ -1246,13 +1246,13 @@ var B = class extends be {
|
|
|
1246
1246
|
let n = rt(e);
|
|
1247
1247
|
if (typeof n != "number") throw Error(`Expected a valid index, not ${e}.`);
|
|
1248
1248
|
let r = this.items[n];
|
|
1249
|
-
S(r) &&
|
|
1249
|
+
S(r) && pe(t) ? r.value = t : this.items[n] = t;
|
|
1250
1250
|
}
|
|
1251
1251
|
toJSON(e, t) {
|
|
1252
1252
|
let n = [];
|
|
1253
1253
|
t?.onCreate && t.onCreate(n);
|
|
1254
1254
|
let r = 0;
|
|
1255
|
-
for (let e of this.items) n.push(
|
|
1255
|
+
for (let e of this.items) n.push(F(e, String(r++), t));
|
|
1256
1256
|
return n;
|
|
1257
1257
|
}
|
|
1258
1258
|
toString(e, t, n) {
|
|
@@ -1276,7 +1276,7 @@ var B = class extends be {
|
|
|
1276
1276
|
let n = t instanceof Set ? a : String(e++);
|
|
1277
1277
|
a = r.call(t, n, a);
|
|
1278
1278
|
}
|
|
1279
|
-
i.items.push(
|
|
1279
|
+
i.items.push(ge(a, void 0, n));
|
|
1280
1280
|
}
|
|
1281
1281
|
}
|
|
1282
1282
|
return i;
|
|
@@ -1307,18 +1307,18 @@ var it = {
|
|
|
1307
1307
|
}
|
|
1308
1308
|
}, ot = {
|
|
1309
1309
|
identify: (e) => e == null,
|
|
1310
|
-
createNode: () => new
|
|
1310
|
+
createNode: () => new I(null),
|
|
1311
1311
|
default: !0,
|
|
1312
1312
|
tag: "tag:yaml.org,2002:null",
|
|
1313
1313
|
test: /^(?:~|[Nn]ull|NULL)?$/,
|
|
1314
|
-
resolve: () => new
|
|
1314
|
+
resolve: () => new I(null),
|
|
1315
1315
|
stringify: ({ source: e }, t) => typeof e == "string" && ot.test.test(e) ? e : t.options.nullStr
|
|
1316
1316
|
}, st = {
|
|
1317
1317
|
identify: (e) => typeof e == "boolean",
|
|
1318
1318
|
default: !0,
|
|
1319
1319
|
tag: "tag:yaml.org,2002:bool",
|
|
1320
1320
|
test: /^(?:[Tt]rue|TRUE|[Ff]alse|FALSE)$/,
|
|
1321
|
-
resolve: (e) => new
|
|
1321
|
+
resolve: (e) => new I(e[0] === "t" || e[0] === "T"),
|
|
1322
1322
|
stringify({ source: e, value: t }, n) {
|
|
1323
1323
|
return e && st.test.test(e) && t === (e[0] === "t" || e[0] === "T") ? e : t ? n.options.trueStr : n.options.falseStr;
|
|
1324
1324
|
}
|
|
@@ -1364,7 +1364,7 @@ var ct = {
|
|
|
1364
1364
|
tag: "tag:yaml.org,2002:float",
|
|
1365
1365
|
test: /^[-+]?(?:\.[0-9]+|[0-9]+\.[0-9]*)$/,
|
|
1366
1366
|
resolve(e) {
|
|
1367
|
-
let t = new
|
|
1367
|
+
let t = new I(parseFloat(e)), n = e.indexOf(".");
|
|
1368
1368
|
return n !== -1 && e[e.length - 1] === "0" && (t.minFractionDigits = e.length - n - 1), t;
|
|
1369
1369
|
},
|
|
1370
1370
|
stringify: H
|
|
@@ -1424,7 +1424,7 @@ var yt = ({ value: e }) => JSON.stringify(e), bt = [
|
|
|
1424
1424
|
},
|
|
1425
1425
|
{
|
|
1426
1426
|
identify: (e) => e == null,
|
|
1427
|
-
createNode: () => new
|
|
1427
|
+
createNode: () => new I(null),
|
|
1428
1428
|
default: !0,
|
|
1429
1429
|
tag: "tag:yaml.org,2002:null",
|
|
1430
1430
|
test: /^null$/,
|
|
@@ -1482,10 +1482,10 @@ var yt = ({ value: e }) => JSON.stringify(e), bt = [
|
|
|
1482
1482
|
for (let t = 0; t < o.length; ++t) e += String.fromCharCode(o[t]);
|
|
1483
1483
|
s = btoa(e);
|
|
1484
1484
|
} else throw Error("This environment does not support writing binary tags; either Buffer or btoa is required");
|
|
1485
|
-
if (t ??=
|
|
1485
|
+
if (t ??= I.BLOCK_LITERAL, t !== I.QUOTE_DOUBLE) {
|
|
1486
1486
|
let e = Math.max(r.options.lineWidth - r.indent.length, r.options.minContentWidth), n = Math.ceil(s.length / e), i = Array(n);
|
|
1487
1487
|
for (let t = 0, r = 0; t < n; ++t, r += e) i[t] = s.substr(r, e);
|
|
1488
|
-
s = i.join(t ===
|
|
1488
|
+
s = i.join(t === I.BLOCK_LITERAL ? "\n" : " ");
|
|
1489
1489
|
}
|
|
1490
1490
|
return Ie({
|
|
1491
1491
|
comment: e,
|
|
@@ -1502,7 +1502,7 @@ function Ct(e, t) {
|
|
|
1502
1502
|
if (!x(r)) {
|
|
1503
1503
|
if (b(r)) {
|
|
1504
1504
|
r.items.length > 1 && t("Each pair must have its own sequence indicator");
|
|
1505
|
-
let e = r.items[0] || new z(new
|
|
1505
|
+
let e = r.items[0] || new z(new I(null));
|
|
1506
1506
|
if (r.commentBefore && (e.key.commentBefore = e.key.commentBefore ? `${r.commentBefore}\n${e.key.commentBefore}` : r.commentBefore), r.comment) {
|
|
1507
1507
|
let t = e.value ?? e.key;
|
|
1508
1508
|
t.comment = t.comment ? `${r.comment}\n${t.comment}` : r.comment;
|
|
@@ -1550,7 +1550,7 @@ var Tt = {
|
|
|
1550
1550
|
t?.onCreate && t.onCreate(n);
|
|
1551
1551
|
for (let e of this.items) {
|
|
1552
1552
|
let r, i;
|
|
1553
|
-
if (x(e) ? (r =
|
|
1553
|
+
if (x(e) ? (r = F(e.key, "", t), i = F(e.value, r, t)) : r = F(e, "", t), n.has(r)) throw Error("Ordered maps must not include duplicate keys");
|
|
1554
1554
|
n.set(r, i);
|
|
1555
1555
|
}
|
|
1556
1556
|
return n;
|
|
@@ -1584,14 +1584,14 @@ var kt = {
|
|
|
1584
1584
|
default: !0,
|
|
1585
1585
|
tag: "tag:yaml.org,2002:bool",
|
|
1586
1586
|
test: /^(?:Y|y|[Yy]es|YES|[Tt]rue|TRUE|[Oo]n|ON)$/,
|
|
1587
|
-
resolve: () => new
|
|
1587
|
+
resolve: () => new I(!0),
|
|
1588
1588
|
stringify: Ot
|
|
1589
1589
|
}, At = {
|
|
1590
1590
|
identify: (e) => e === !1,
|
|
1591
1591
|
default: !0,
|
|
1592
1592
|
tag: "tag:yaml.org,2002:bool",
|
|
1593
1593
|
test: /^(?:N|n|[Nn]o|NO|[Ff]alse|FALSE|[Oo]ff|OFF)$/,
|
|
1594
|
-
resolve: () => new
|
|
1594
|
+
resolve: () => new I(!1),
|
|
1595
1595
|
stringify: Ot
|
|
1596
1596
|
}, jt = {
|
|
1597
1597
|
identify: (e) => typeof e == "number",
|
|
@@ -1617,7 +1617,7 @@ var kt = {
|
|
|
1617
1617
|
tag: "tag:yaml.org,2002:float",
|
|
1618
1618
|
test: /^[-+]?(?:[0-9][0-9_]*)?\.[0-9_]*$/,
|
|
1619
1619
|
resolve(e) {
|
|
1620
|
-
let t = new
|
|
1620
|
+
let t = new I(parseFloat(e.replace(/_/g, ""))), n = e.indexOf(".");
|
|
1621
1621
|
if (n !== -1) {
|
|
1622
1622
|
let r = e.substring(n + 1).replace(/_/g, "");
|
|
1623
1623
|
r[r.length - 1] === "0" && (t.minFractionDigits = r.length);
|
|
@@ -1882,28 +1882,28 @@ function tn(e, t) {
|
|
|
1882
1882
|
if (e.commentBefore) {
|
|
1883
1883
|
n.length !== 1 && n.unshift("");
|
|
1884
1884
|
let t = a(e.commentBefore);
|
|
1885
|
-
n.unshift(
|
|
1885
|
+
n.unshift(L(t, ""));
|
|
1886
1886
|
}
|
|
1887
1887
|
let o = !1, s = null;
|
|
1888
1888
|
if (e.contents) {
|
|
1889
1889
|
if (T(e.contents)) {
|
|
1890
1890
|
if (e.contents.spaceBefore && r && n.push(""), e.contents.commentBefore) {
|
|
1891
1891
|
let t = a(e.contents.commentBefore);
|
|
1892
|
-
n.push(
|
|
1892
|
+
n.push(L(t, ""));
|
|
1893
1893
|
}
|
|
1894
1894
|
i.forceBlockIndent = !!e.comment, s = e.contents.comment;
|
|
1895
1895
|
}
|
|
1896
1896
|
let t = s ? void 0 : () => o = !0, c = Be(e.contents, i, () => s = null, t);
|
|
1897
|
-
s && (c +=
|
|
1897
|
+
s && (c += xe(c, "", a(s))), (c[0] === "|" || c[0] === ">") && n[n.length - 1] === "---" ? n[n.length - 1] = `--- ${c}` : n.push(c);
|
|
1898
1898
|
} else n.push(Be(e.contents, i));
|
|
1899
1899
|
if (e.directives?.docEnd) {
|
|
1900
1900
|
if (e.comment) {
|
|
1901
1901
|
let t = a(e.comment);
|
|
1902
|
-
t.includes("\n") ? (n.push("..."), n.push(
|
|
1902
|
+
t.includes("\n") ? (n.push("..."), n.push(L(t, ""))) : n.push(`... ${t}`);
|
|
1903
1903
|
} else n.push("...");
|
|
1904
1904
|
} else {
|
|
1905
1905
|
let t = e.comment;
|
|
1906
|
-
t && o && (t = t.replace(/^\n+/, "")), t && ((!o || s) && n[n.length - 1] !== "" && n.push(""), n.push(
|
|
1906
|
+
t && o && (t = t.replace(/^\n+/, "")), t && ((!o || s) && n[n.length - 1] !== "" && n.push(""), n.push(L(a(t), "")));
|
|
1907
1907
|
}
|
|
1908
1908
|
return n.join("\n") + "\n";
|
|
1909
1909
|
}
|
|
@@ -1926,7 +1926,7 @@ var nn = class e {
|
|
|
1926
1926
|
}, n);
|
|
1927
1927
|
this.options = i;
|
|
1928
1928
|
let { version: a } = i;
|
|
1929
|
-
n?._directives ? (this.directives = n._directives.atDocument(), this.directives.yaml.explicit && (a = this.directives.yaml.version)) : this.directives = new
|
|
1929
|
+
n?._directives ? (this.directives = n._directives.atDocument(), this.directives.yaml.explicit && (a = this.directives.yaml.version)) : this.directives = new oe({ version: a }), this.setSchema(a, n), this.contents = e === void 0 ? null : this.createNode(e, r, n);
|
|
1930
1930
|
}
|
|
1931
1931
|
clone() {
|
|
1932
1932
|
let t = Object.create(e.prototype, { [_]: { value: f } });
|
|
@@ -1940,10 +1940,10 @@ var nn = class e {
|
|
|
1940
1940
|
}
|
|
1941
1941
|
createAlias(e, t) {
|
|
1942
1942
|
if (!e.anchor) {
|
|
1943
|
-
let n =
|
|
1944
|
-
e.anchor = !t || n.has(t) ?
|
|
1943
|
+
let n = ce(this);
|
|
1944
|
+
e.anchor = !t || n.has(t) ? N(t || "a", n) : t;
|
|
1945
1945
|
}
|
|
1946
|
-
return new
|
|
1946
|
+
return new de(e.anchor);
|
|
1947
1947
|
}
|
|
1948
1948
|
createNode(e, t, n) {
|
|
1949
1949
|
let r;
|
|
@@ -1952,7 +1952,7 @@ var nn = class e {
|
|
|
1952
1952
|
let e = t.filter((e) => typeof e == "number" || e instanceof String || e instanceof Number).map(String);
|
|
1953
1953
|
e.length > 0 && (t = t.concat(e)), r = t;
|
|
1954
1954
|
} else n === void 0 && t && (n = t, t = void 0);
|
|
1955
|
-
let { aliasDuplicateObjects: i, anchorPrefix: a, flow: o, keepUndefined: s, onTagObj: c, tag: l } = n ?? {}, { onAnchor: u, setAnchors: d, sourceObjects: f } =
|
|
1955
|
+
let { aliasDuplicateObjects: i, anchorPrefix: a, flow: o, keepUndefined: s, onTagObj: c, tag: l } = n ?? {}, { onAnchor: u, setAnchors: d, sourceObjects: f } = le(this, a || "a"), p = {
|
|
1956
1956
|
aliasDuplicateObjects: i ?? !0,
|
|
1957
1957
|
keepUndefined: s ?? !1,
|
|
1958
1958
|
onAnchor: u,
|
|
@@ -1960,7 +1960,7 @@ var nn = class e {
|
|
|
1960
1960
|
replacer: r,
|
|
1961
1961
|
schema: this.schema,
|
|
1962
1962
|
sourceObjects: f
|
|
1963
|
-
}, m =
|
|
1963
|
+
}, m = ge(e, l, p);
|
|
1964
1964
|
return o && w(m) && (m.flow = !0), d(), m;
|
|
1965
1965
|
}
|
|
1966
1966
|
createPair(e, t, n = {}) {
|
|
@@ -1970,39 +1970,39 @@ var nn = class e {
|
|
|
1970
1970
|
return rn(this.contents) ? this.contents.delete(e) : !1;
|
|
1971
1971
|
}
|
|
1972
1972
|
deleteIn(e) {
|
|
1973
|
-
return
|
|
1973
|
+
return ve(e) ? this.contents != null && (this.contents = null, !0) : rn(this.contents) ? this.contents.deleteIn(e) : !1;
|
|
1974
1974
|
}
|
|
1975
1975
|
get(e, t) {
|
|
1976
1976
|
return w(this.contents) ? this.contents.get(e, t) : void 0;
|
|
1977
1977
|
}
|
|
1978
1978
|
getIn(e, t) {
|
|
1979
|
-
return
|
|
1979
|
+
return ve(e) ? !t && S(this.contents) ? this.contents.value : this.contents : w(this.contents) ? this.contents.getIn(e, t) : void 0;
|
|
1980
1980
|
}
|
|
1981
1981
|
has(e) {
|
|
1982
1982
|
return w(this.contents) ? this.contents.has(e) : !1;
|
|
1983
1983
|
}
|
|
1984
1984
|
hasIn(e) {
|
|
1985
|
-
return
|
|
1985
|
+
return ve(e) ? this.contents !== void 0 : w(this.contents) ? this.contents.hasIn(e) : !1;
|
|
1986
1986
|
}
|
|
1987
1987
|
set(e, t) {
|
|
1988
|
-
this.contents == null ? this.contents =
|
|
1988
|
+
this.contents == null ? this.contents = _e(this.schema, [e], t) : rn(this.contents) && this.contents.set(e, t);
|
|
1989
1989
|
}
|
|
1990
1990
|
setIn(e, t) {
|
|
1991
|
-
|
|
1991
|
+
ve(e) ? this.contents = t : this.contents == null ? this.contents = _e(this.schema, Array.from(e), t) : rn(this.contents) && this.contents.setIn(e, t);
|
|
1992
1992
|
}
|
|
1993
1993
|
setSchema(e, t = {}) {
|
|
1994
1994
|
typeof e == "number" && (e = String(e));
|
|
1995
1995
|
let n;
|
|
1996
1996
|
switch (e) {
|
|
1997
1997
|
case "1.1":
|
|
1998
|
-
this.directives ? this.directives.yaml.version = "1.1" : this.directives = new
|
|
1998
|
+
this.directives ? this.directives.yaml.version = "1.1" : this.directives = new oe({ version: "1.1" }), n = {
|
|
1999
1999
|
resolveKnownTags: !1,
|
|
2000
2000
|
schema: "yaml-1.1"
|
|
2001
2001
|
};
|
|
2002
2002
|
break;
|
|
2003
2003
|
case "1.2":
|
|
2004
2004
|
case "next":
|
|
2005
|
-
this.directives ? this.directives.yaml.version = e : this.directives = new
|
|
2005
|
+
this.directives ? this.directives.yaml.version = e : this.directives = new oe({ version: e }), n = {
|
|
2006
2006
|
resolveKnownTags: !0,
|
|
2007
2007
|
schema: "core"
|
|
2008
2008
|
};
|
|
@@ -2027,9 +2027,9 @@ var nn = class e {
|
|
|
2027
2027
|
mapAsMap: n === !0,
|
|
2028
2028
|
mapKeyWarned: !1,
|
|
2029
2029
|
maxAliasCount: typeof r == "number" ? r : 100
|
|
2030
|
-
}, s =
|
|
2030
|
+
}, s = F(this.contents, t ?? "", o);
|
|
2031
2031
|
if (typeof i == "function") for (let { count: e, res: t } of o.anchors.values()) i(t, e);
|
|
2032
|
-
return typeof a == "function" ?
|
|
2032
|
+
return typeof a == "function" ? P(a, { "": s }, "", s) : s;
|
|
2033
2033
|
}
|
|
2034
2034
|
toJSON(e, t) {
|
|
2035
2035
|
return this.toJS({
|
|
@@ -2418,7 +2418,7 @@ function xn(e, t, n, r, i) {
|
|
|
2418
2418
|
if (r?.collection === s) t.schema.tags.push(Object.assign({}, r, { default: !1 })), c = r;
|
|
2419
2419
|
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), bn(e, t, n, i, o);
|
|
2420
2420
|
}
|
|
2421
|
-
let l = bn(e, t, n, i, o, c), u = c.resolve?.(l, (e) => i(a, "TAG_RESOLVE_FAILED", e), t.options) ?? l, d = T(u) ? u : new
|
|
2421
|
+
let l = bn(e, t, n, i, o, c), u = c.resolve?.(l, (e) => i(a, "TAG_RESOLVE_FAILED", e), t.options) ?? l, d = T(u) ? u : new I(u);
|
|
2422
2422
|
return d.range = l.range, d.tag = o, c?.format && (d.format = c.format), d;
|
|
2423
2423
|
}
|
|
2424
2424
|
//#endregion
|
|
@@ -2435,7 +2435,7 @@ function Sn(e, t, n) {
|
|
|
2435
2435
|
r
|
|
2436
2436
|
]
|
|
2437
2437
|
};
|
|
2438
|
-
let a = i.mode === ">" ?
|
|
2438
|
+
let a = i.mode === ">" ? I.BLOCK_FOLDED : I.BLOCK_LITERAL, o = t.source ? wn(t.source) : [], s = o.length;
|
|
2439
2439
|
for (let e = o.length - 1; e >= 0; --e) {
|
|
2440
2440
|
let t = o[e][1];
|
|
2441
2441
|
if (t === "" || t === "\r") s = e;
|
|
@@ -2476,7 +2476,7 @@ function Sn(e, t, n) {
|
|
|
2476
2476
|
let e = `Block scalar lines must not be less indented than their ${i.indent ? "explicit indentation indicator" : "first line"}`;
|
|
2477
2477
|
n(l - r.length - (s ? 2 : 1), "BAD_INDENT", e), t = "";
|
|
2478
2478
|
}
|
|
2479
|
-
a ===
|
|
2479
|
+
a === I.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);
|
|
2480
2480
|
}
|
|
2481
2481
|
switch (i.chomp) {
|
|
2482
2482
|
case "-": break;
|
|
@@ -2552,13 +2552,13 @@ function Tn(e, t, n) {
|
|
|
2552
2552
|
let { offset: r, type: i, source: a, end: o } = e, s, c, l = (e, t, i) => n(r + e, t, i);
|
|
2553
2553
|
switch (i) {
|
|
2554
2554
|
case "scalar":
|
|
2555
|
-
s =
|
|
2555
|
+
s = I.PLAIN, c = En(a, l);
|
|
2556
2556
|
break;
|
|
2557
2557
|
case "single-quoted-scalar":
|
|
2558
|
-
s =
|
|
2558
|
+
s = I.QUOTE_SINGLE, c = Dn(a, l);
|
|
2559
2559
|
break;
|
|
2560
2560
|
case "double-quoted-scalar":
|
|
2561
|
-
s =
|
|
2561
|
+
s = I.QUOTE_DOUBLE, c = kn(a, l);
|
|
2562
2562
|
break;
|
|
2563
2563
|
/* istanbul ignore next should not happen */
|
|
2564
2564
|
default: return n(e, "UNEXPECTED_TOKEN", `Expected a flow scalar value, but found: ${i}`), {
|
|
@@ -2697,10 +2697,10 @@ function Nn(e, t, n, r) {
|
|
|
2697
2697
|
let u;
|
|
2698
2698
|
try {
|
|
2699
2699
|
let a = l.resolve(i, (e) => r(n ?? t, "TAG_RESOLVE_FAILED", e), e.options);
|
|
2700
|
-
u = S(a) ? a : new
|
|
2700
|
+
u = S(a) ? a : new I(a);
|
|
2701
2701
|
} catch (e) {
|
|
2702
2702
|
let a = e instanceof Error ? e.message : String(e);
|
|
2703
|
-
r(n ?? t, "TAG_RESOLVE_FAILED", a), u = new
|
|
2703
|
+
r(n ?? t, "TAG_RESOLVE_FAILED", a), u = new I(i);
|
|
2704
2704
|
}
|
|
2705
2705
|
return u.range = s, u.source = i, a && (u.type = a), c && (u.tag = c), l.format && (u.format = l.format), o && (u.comment = o), u;
|
|
2706
2706
|
}
|
|
@@ -2787,7 +2787,7 @@ function zn(e, t, n, r, { spaceBefore: i, comment: a, anchor: o, tag: s, end: c
|
|
|
2787
2787
|
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;
|
|
2788
2788
|
}
|
|
2789
2789
|
function Bn({ options: e }, { offset: t, source: n, end: r }, i) {
|
|
2790
|
-
let a = new
|
|
2790
|
+
let a = new de(n.substring(1));
|
|
2791
2791
|
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);
|
|
2792
2792
|
let o = t + n.length, s = gn(r, o, e.strict, i);
|
|
2793
2793
|
return a.range = [
|
|
@@ -2853,7 +2853,7 @@ var Wn = class {
|
|
|
2853
2853
|
this.doc = null, this.atDirectives = !1, this.prelude = [], this.errors = [], this.warnings = [], this.onError = (e, t, n, r) => {
|
|
2854
2854
|
let i = Hn(e);
|
|
2855
2855
|
r ? this.warnings.push(new sn(i, t, n)) : this.errors.push(new on(i, t, n));
|
|
2856
|
-
}, this.directives = new
|
|
2856
|
+
}, this.directives = new oe({ version: e.version || "1.2" }), this.options = e;
|
|
2857
2857
|
}
|
|
2858
2858
|
decorate(e, t) {
|
|
2859
2859
|
let { comment: n, afterEmptyLine: r } = Un(this.prelude);
|
|
@@ -4367,7 +4367,7 @@ function Or(e, t, n) {
|
|
|
4367
4367
|
//#endregion
|
|
4368
4368
|
//#region node_modules/yaml/browser/index.js
|
|
4369
4369
|
var kr = /* @__PURE__ */ a({
|
|
4370
|
-
Alias: () =>
|
|
4370
|
+
Alias: () => de,
|
|
4371
4371
|
CST: () => ar,
|
|
4372
4372
|
Composer: () => Wn,
|
|
4373
4373
|
Document: () => nn,
|
|
@@ -4375,7 +4375,7 @@ var kr = /* @__PURE__ */ a({
|
|
|
4375
4375
|
LineCounter: () => gr,
|
|
4376
4376
|
Pair: () => z,
|
|
4377
4377
|
Parser: () => Cr,
|
|
4378
|
-
Scalar: () =>
|
|
4378
|
+
Scalar: () => I,
|
|
4379
4379
|
Schema: () => en,
|
|
4380
4380
|
YAMLError: () => an,
|
|
4381
4381
|
YAMLMap: () => B,
|
|
@@ -4394,8 +4394,8 @@ var kr = /* @__PURE__ */ a({
|
|
|
4394
4394
|
parseAllDocuments: () => Tr,
|
|
4395
4395
|
parseDocument: () => Er,
|
|
4396
4396
|
stringify: () => Or,
|
|
4397
|
-
visit: () =>
|
|
4398
|
-
visitAsync: () =>
|
|
4397
|
+
visit: () => A,
|
|
4398
|
+
visitAsync: () => ee
|
|
4399
4399
|
}), Ar = {
|
|
4400
4400
|
rawNodes: {
|
|
4401
4401
|
address: {
|
|
@@ -7362,7 +7362,7 @@ function ui(e) {
|
|
|
7362
7362
|
D[e] = J(D[e] || {}, t);
|
|
7363
7363
|
});
|
|
7364
7364
|
});
|
|
7365
|
-
let
|
|
7365
|
+
let O = p ? {
|
|
7366
7366
|
...p,
|
|
7367
7367
|
fields: D
|
|
7368
7368
|
} : null;
|
|
@@ -7376,7 +7376,7 @@ function ui(e) {
|
|
|
7376
7376
|
nodeTemplate: u || null,
|
|
7377
7377
|
treeTemplate: d || null,
|
|
7378
7378
|
channelTemplate: E,
|
|
7379
|
-
userTemplate:
|
|
7379
|
+
userTemplate: O
|
|
7380
7380
|
};
|
|
7381
7381
|
}
|
|
7382
7382
|
//#endregion
|
|
@@ -7391,29 +7391,34 @@ var Y = class {
|
|
|
7391
7391
|
dispatch(e, t) {
|
|
7392
7392
|
!this.zoneId || !this.apiToken || (e.executionCtx && typeof e.executionCtx.waitUntil == "function" ? e.executionCtx.waitUntil(t) : t.catch((e) => console.warn("[CacheManager Warn]:", e)));
|
|
7393
7393
|
}
|
|
7394
|
-
purgeAndWarmSlug(e, t) {
|
|
7395
|
-
let
|
|
7394
|
+
purgeAndWarmSlug(e, t, n = []) {
|
|
7395
|
+
let r = (async () => {
|
|
7396
7396
|
try {
|
|
7397
|
-
let e = t.replace(/^\/+|\/+$/g, ""),
|
|
7398
|
-
|
|
7399
|
-
|
|
7397
|
+
let e = t.replace(/^\/+|\/+$/g, ""), r = e === "home" || !e ? this.frontendUrl : `${this.frontendUrl}/${e}`, i = [r, `${r}/`];
|
|
7398
|
+
for (let e of n) {
|
|
7399
|
+
if (!e) continue;
|
|
7400
|
+
let t = e.startsWith("/") ? e : `/${e}`;
|
|
7401
|
+
i.push(`${this.frontendUrl}${t}`);
|
|
7402
|
+
}
|
|
7403
|
+
console.log(`[CacheManager] Purging ${i.length} edge URLs for: ${e}`);
|
|
7404
|
+
let a = await fetch(`https://api.cloudflare.com/client/v4/zones/${this.zoneId}/purge_cache`, {
|
|
7400
7405
|
method: "POST",
|
|
7401
7406
|
headers: {
|
|
7402
7407
|
Authorization: `Bearer ${this.apiToken}`,
|
|
7403
7408
|
"Content-Type": "application/json"
|
|
7404
7409
|
},
|
|
7405
|
-
body: JSON.stringify({ files:
|
|
7410
|
+
body: JSON.stringify({ files: i })
|
|
7406
7411
|
});
|
|
7407
|
-
if (!
|
|
7408
|
-
console.error(`[CacheManager] Purge failed: ${await
|
|
7412
|
+
if (!a.ok) {
|
|
7413
|
+
console.error(`[CacheManager] Purge failed: ${await a.text()}`);
|
|
7409
7414
|
return;
|
|
7410
7415
|
}
|
|
7411
|
-
fetch(
|
|
7416
|
+
fetch(r, { headers: { "X-Cache-Warmer": "true" } }).catch(() => {});
|
|
7412
7417
|
} catch (e) {
|
|
7413
7418
|
console.error("[CacheManager] Critical error during slug purge:", e);
|
|
7414
7419
|
}
|
|
7415
7420
|
})();
|
|
7416
|
-
this.dispatch(e,
|
|
7421
|
+
this.dispatch(e, r);
|
|
7417
7422
|
}
|
|
7418
7423
|
purgeGlobalCache(e) {
|
|
7419
7424
|
let t = (async () => {
|
|
@@ -7438,12 +7443,12 @@ var Y = class {
|
|
|
7438
7443
|
})();
|
|
7439
7444
|
this.dispatch(e, t);
|
|
7440
7445
|
}
|
|
7441
|
-
purgeSmart(e, t, n, r) {
|
|
7442
|
-
let
|
|
7446
|
+
purgeSmart(e, t, n, r, i = []) {
|
|
7447
|
+
let a = (async () => {
|
|
7443
7448
|
let e = r;
|
|
7444
|
-
!e && n && (e = (await t.prepare("SELECT slug FROM content_nodes WHERE id = ?").get(n))?.slug), e && (await t.prepare("SELECT 1 FROM tree_nodes WHERE contentId = ? LIMIT 1").get(n) ? await this.purgeGlobalCacheDirect() : await this.purgeAndWarmSlugDirect(e));
|
|
7449
|
+
!e && n && (e = (await t.prepare("SELECT slug FROM content_nodes WHERE id = ?").get(n))?.slug), e && (await t.prepare("SELECT 1 FROM tree_nodes WHERE contentId = ? LIMIT 1").get(n) ? await this.purgeGlobalCacheDirect() : await this.purgeAndWarmSlugDirect(e, i));
|
|
7445
7450
|
})();
|
|
7446
|
-
this.dispatch(e,
|
|
7451
|
+
this.dispatch(e, a);
|
|
7447
7452
|
}
|
|
7448
7453
|
async purgeGlobalCacheDirect() {
|
|
7449
7454
|
try {
|
|
@@ -7457,17 +7462,22 @@ var Y = class {
|
|
|
7457
7462
|
}), fetch(this.frontendUrl, { headers: { "X-Cache-Warmer": "true" } }).catch(() => {});
|
|
7458
7463
|
} catch {}
|
|
7459
7464
|
}
|
|
7460
|
-
async purgeAndWarmSlugDirect(e) {
|
|
7465
|
+
async purgeAndWarmSlugDirect(e, t = []) {
|
|
7461
7466
|
try {
|
|
7462
|
-
let
|
|
7467
|
+
let n = e.replace(/^\/+|\/+$/g, ""), r = n === "home" || !n ? this.frontendUrl : `${this.frontendUrl}/${n}`, i = [r, `${r}/`];
|
|
7468
|
+
for (let e of t) {
|
|
7469
|
+
if (!e) continue;
|
|
7470
|
+
let t = e.startsWith("/") ? e : `/${e}`;
|
|
7471
|
+
i.push(`${this.frontendUrl}${t}`);
|
|
7472
|
+
}
|
|
7463
7473
|
await fetch(`https://api.cloudflare.com/client/v4/zones/${this.zoneId}/purge_cache`, {
|
|
7464
7474
|
method: "POST",
|
|
7465
7475
|
headers: {
|
|
7466
7476
|
Authorization: `Bearer ${this.apiToken}`,
|
|
7467
7477
|
"Content-Type": "application/json"
|
|
7468
7478
|
},
|
|
7469
|
-
body: JSON.stringify({ files:
|
|
7470
|
-
}), fetch(
|
|
7479
|
+
body: JSON.stringify({ files: i })
|
|
7480
|
+
}), fetch(r, { headers: { "X-Cache-Warmer": "true" } }).catch(() => {});
|
|
7471
7481
|
} catch {}
|
|
7472
7482
|
}
|
|
7473
7483
|
}, X = new e();
|
|
@@ -7488,18 +7498,25 @@ async function fi(e, t, n = []) {
|
|
|
7488
7498
|
if (typeof r.bind == "function") return r.bind(...n).run();
|
|
7489
7499
|
if (typeof r.run == "function") return r.run(...n);
|
|
7490
7500
|
}
|
|
7491
|
-
function pi(e) {
|
|
7492
|
-
|
|
7501
|
+
async function pi(e, t) {
|
|
7502
|
+
try {
|
|
7503
|
+
return (await di(e, "\n SELECT DISTINCT a.url\n FROM node_assets na\n JOIN assets a ON na.assetId = a.id\n WHERE na.nodeId = ? AND a.url IS NOT NULL AND a.url != ''\n ", [t])).map((e) => e.url).filter(Boolean);
|
|
7504
|
+
} catch {
|
|
7505
|
+
return [];
|
|
7506
|
+
}
|
|
7493
7507
|
}
|
|
7494
7508
|
function mi(e) {
|
|
7495
|
-
return
|
|
7509
|
+
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;
|
|
7496
7510
|
}
|
|
7497
7511
|
function hi(e) {
|
|
7512
|
+
return +(e === !0 || e === 1 || e === "1" || e === "true");
|
|
7513
|
+
}
|
|
7514
|
+
function gi(e) {
|
|
7498
7515
|
if (e == null || e === "null" || e === "" || typeof e == "string" && e.startsWith("draft-")) return null;
|
|
7499
7516
|
let t = Number(e);
|
|
7500
7517
|
return isNaN(t) ? null : t;
|
|
7501
7518
|
}
|
|
7502
|
-
function
|
|
7519
|
+
function _i(e) {
|
|
7503
7520
|
let t = { ...e };
|
|
7504
7521
|
for (let e of [
|
|
7505
7522
|
"id",
|
|
@@ -7528,10 +7545,10 @@ function gi(e) {
|
|
|
7528
7545
|
]) delete t[e];
|
|
7529
7546
|
return t;
|
|
7530
7547
|
}
|
|
7531
|
-
function
|
|
7532
|
-
return e ? typeof e == "string" ? (e.startsWith("ast_") && t.add(e), t) : Array.isArray(e) ? (e.forEach((e) =>
|
|
7548
|
+
function vi(e, t = /* @__PURE__ */ new Set()) {
|
|
7549
|
+
return e ? typeof e == "string" ? (e.startsWith("ast_") && t.add(e), t) : Array.isArray(e) ? (e.forEach((e) => vi(e, t)), t) : (typeof e == "object" && Object.values(e).forEach((e) => vi(e, t)), t) : t;
|
|
7533
7550
|
}
|
|
7534
|
-
async function
|
|
7551
|
+
async function yi(e, t, n) {
|
|
7535
7552
|
for (let r of n) {
|
|
7536
7553
|
let n = (await di(e, "\n SELECT id, storageKeyPrivate, isSystemVariant, parentAssetId, filename\n FROM assets WHERE id = ?\n ", [r]))[0];
|
|
7537
7554
|
if (!n || (await di(e, "SELECT 1 FROM node_assets WHERE assetId = ? LIMIT 1", [n.id])).length > 0) continue;
|
|
@@ -7550,7 +7567,7 @@ async function vi(e, t, n) {
|
|
|
7550
7567
|
await fi(e, `DELETE FROM node_assets WHERE assetId IN (${o})`, a), await fi(e, `DELETE FROM assets WHERE id IN (${o})`, a);
|
|
7551
7568
|
}
|
|
7552
7569
|
}
|
|
7553
|
-
async function
|
|
7570
|
+
async function bi(e, t, n) {
|
|
7554
7571
|
let r = {}, i = null;
|
|
7555
7572
|
if (t) {
|
|
7556
7573
|
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\n FROM tree_nodes t\n INNER JOIN content_nodes c ON t.contentId = c.id\n WHERE t.id = ?\n UNION ALL\n SELECT t.id, t.parentId, c.draftDataJson, c.dataJson, ap.level + 1\n FROM tree_nodes t\n INNER JOIN content_nodes c ON t.contentId = c.id\n INNER JOIN ancestor_path ap ON t.id = ap.parentId\n )\n SELECT draftDataJson, dataJson FROM ancestor_path ORDER BY level ASC\n ").all(t), a = Array.isArray(n) ? n : n?.results || [];
|
|
@@ -7602,11 +7619,11 @@ X.get("/", async (e) => {
|
|
|
7602
7619
|
if (s) try {
|
|
7603
7620
|
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 = ui(e.env?.BUNDLED_DEFINITIONS).nodes?.[i.contentType] || {}, l = n.layoutId || null;
|
|
7604
7621
|
if (a) {
|
|
7605
|
-
let { resolvedLayoutId: e, inheritedFields: r } = await
|
|
7622
|
+
let { resolvedLayoutId: e, inheritedFields: r } = await bi(t, a.parentId, a.treeId);
|
|
7606
7623
|
(l === "inherit" || !l) && (l = e || c.defaultLayout || null);
|
|
7607
7624
|
for (let [e, t] of Object.entries(r)) (n[e] === void 0 || n[e] === null || n[e] === "") && t !== void 0 && (n[e] = t);
|
|
7608
7625
|
} else (l === "inherit" || !l) && (l = c.defaultLayout || null);
|
|
7609
|
-
let u = await si(t,
|
|
7626
|
+
let u = await si(t, _i(n));
|
|
7610
7627
|
Object.assign(o, u), o.resolvedLayoutId = l;
|
|
7611
7628
|
} catch {}
|
|
7612
7629
|
let c = await t.prepare("SELECT channelId FROM node_channels WHERE nodeId = ?").all(r);
|
|
@@ -7694,7 +7711,7 @@ X.get("/", async (e) => {
|
|
|
7694
7711
|
`).all(...T), a = Array.isArray(i) ? i : a?.results || [];
|
|
7695
7712
|
for (let e of a) D[e.nodeId] || (D[e.nodeId] = []), D[e.nodeId].includes(e.label) || D[e.nodeId].push(e.label);
|
|
7696
7713
|
}
|
|
7697
|
-
let
|
|
7714
|
+
let O = await Promise.all(w.map(async (e) => {
|
|
7698
7715
|
let n = (e.status === "draft" || !e.status) && !!e.publishedAt, r = {
|
|
7699
7716
|
id: e.id,
|
|
7700
7717
|
title: e.title,
|
|
@@ -7716,40 +7733,46 @@ X.get("/", async (e) => {
|
|
|
7716
7733
|
assetCount: e.assetCount || 0
|
|
7717
7734
|
}, i = e.draftDataJson || e.dataJson;
|
|
7718
7735
|
if (i) try {
|
|
7719
|
-
let e = typeof i == "string" ? JSON.parse(i) : i, n = await si(t,
|
|
7736
|
+
let e = typeof i == "string" ? JSON.parse(i) : i, n = await si(t, _i(e));
|
|
7720
7737
|
Object.assign(r, n);
|
|
7721
7738
|
} catch {}
|
|
7722
7739
|
return r;
|
|
7723
7740
|
}));
|
|
7724
7741
|
return e.json({
|
|
7725
|
-
items:
|
|
7742
|
+
items: O,
|
|
7726
7743
|
total: v,
|
|
7727
|
-
hasMore: p +
|
|
7744
|
+
hasMore: p + O.length < v,
|
|
7728
7745
|
offset: p,
|
|
7729
7746
|
limit: f
|
|
7730
7747
|
});
|
|
7731
7748
|
}), X.post("/", async (e) => {
|
|
7732
|
-
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, ..._ } = r, v =
|
|
7749
|
+
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, ..._ } = r, v = _i(_), { cleanedData: y, assetRefs: b } = ii(v), x = hi(d === void 0 ? f === void 0 ? p : f : d), S = c || "en", C = l || u || "page", w = e.get("user")?.id || null, T = a, E = /* @__PURE__ */ new Set();
|
|
7733
7750
|
if (a) {
|
|
7734
7751
|
let n = await t.prepare("SELECT title, slug, contentType, language, draftDataJson, dataJson, publishedAt, status FROM content_nodes WHERE id = ?").get(a), r = n?.draftDataJson || n?.dataJson || "{}";
|
|
7735
7752
|
try {
|
|
7736
|
-
|
|
7753
|
+
vi(typeof r == "string" ? JSON.parse(r) : r, E);
|
|
7737
7754
|
} catch {}
|
|
7738
7755
|
if (m !== void 0) {
|
|
7739
7756
|
let e = await t.prepare("SELECT dataJson FROM content_blocks WHERE contentId = ? AND isDraft = 1").all(a);
|
|
7740
7757
|
(Array.isArray(e) ? e : e?.results || []).forEach((e) => {
|
|
7741
7758
|
try {
|
|
7742
|
-
|
|
7759
|
+
vi(typeof e.dataJson == "string" ? JSON.parse(e.dataJson) : e.dataJson, E);
|
|
7743
7760
|
} catch {}
|
|
7744
7761
|
});
|
|
7745
7762
|
}
|
|
7746
|
-
if (m === void 0 && o === void 0 && s === void 0 && h === void 0 && g === void 0 && Object.keys(v).length === 0)
|
|
7747
|
-
|
|
7748
|
-
|
|
7749
|
-
|
|
7750
|
-
|
|
7763
|
+
if (m === void 0 && o === void 0 && s === void 0 && h === void 0 && g === void 0 && Object.keys(v).length === 0) {
|
|
7764
|
+
if (await t.prepare("\n UPDATE content_nodes \n SET isHidden = ?, \n updatedById = ?, \n updatedAt = CURRENT_TIMESTAMP\n WHERE id = ?\n ").run(x, w, a), await q(e).clear(), n?.status === "published") {
|
|
7765
|
+
let r = await pi(t, a);
|
|
7766
|
+
new Y(e.env).purgeSmart(e, t, a, n.slug, r);
|
|
7767
|
+
}
|
|
7768
|
+
return e.json({
|
|
7769
|
+
success: !0,
|
|
7770
|
+
id: a,
|
|
7771
|
+
status: n?.status || "published"
|
|
7772
|
+
});
|
|
7773
|
+
}
|
|
7751
7774
|
{
|
|
7752
|
-
let e = o === void 0 ? n?.title || "Untitled" : o, r = s === void 0 ? n?.slug ?? null :
|
|
7775
|
+
let e = o === void 0 ? n?.title || "Untitled" : o, r = s === void 0 ? n?.slug ?? null : mi(s), i = C || n?.contentType || "page", c = S || n?.language || "en", l = n?.draftDataJson || n?.dataJson || "{}", u = {};
|
|
7753
7776
|
try {
|
|
7754
7777
|
u = JSON.parse(l);
|
|
7755
7778
|
} catch {}
|
|
@@ -7760,7 +7783,7 @@ X.get("/", async (e) => {
|
|
|
7760
7783
|
await t.prepare("\n UPDATE content_nodes \n SET title = ?, \n slug = ?, \n language = ?,\n contentType = ?, \n isHidden = ?, \n status = 'draft', \n draftDataJson = ?, \n updatedById = ?, \n updatedAt = CURRENT_TIMESTAMP\n WHERE id = ?\n ").run(e, r, c, i, x, d, w, a);
|
|
7761
7784
|
}
|
|
7762
7785
|
} else {
|
|
7763
|
-
let e = o || "Untitled", n =
|
|
7786
|
+
let e = o || "Untitled", n = mi(s), r = JSON.stringify(y), i = await t.prepare("\n INSERT INTO content_nodes (contentType, title, slug, language, isHidden, status, draftDataJson, dataJson, createdById, updatedById)\n VALUES (?, ?, ?, ?, ?, 'draft', ?, NULL, ?, ?)\n ").run(C, e, n, S, x, r, w, w);
|
|
7764
7787
|
T = Number(i.lastInsertRowid);
|
|
7765
7788
|
}
|
|
7766
7789
|
if (h !== void 0 && Array.isArray(h) && T) {
|
|
@@ -7778,7 +7801,7 @@ X.get("/", async (e) => {
|
|
|
7778
7801
|
let i = Number(t.treeId) || t.treeId;
|
|
7779
7802
|
if (!e.has(i)) {
|
|
7780
7803
|
e.add(i);
|
|
7781
|
-
let a =
|
|
7804
|
+
let a = gi(t.parentId ?? t._draftParentId ?? null), o = typeof t.sortOrder == "number" ? t.sortOrder : 0;
|
|
7782
7805
|
n.push("(?, ?, ?, ?)"), r.push(i, T, a, o);
|
|
7783
7806
|
}
|
|
7784
7807
|
}
|
|
@@ -7809,7 +7832,7 @@ X.get("/", async (e) => {
|
|
|
7809
7832
|
let n = [...b, ...D];
|
|
7810
7833
|
await ai(t, T, n);
|
|
7811
7834
|
let r = new Set(n.map((e) => e.assetId)), i = new Set([...E].filter((e) => !r.has(e)));
|
|
7812
|
-
i.size > 0 && await
|
|
7835
|
+
i.size > 0 && await yi(t, ri(e.env), i);
|
|
7813
7836
|
}
|
|
7814
7837
|
return await q(e).clear(), e.json({
|
|
7815
7838
|
success: !0,
|
|
@@ -7841,7 +7864,9 @@ X.get("/", async (e) => {
|
|
|
7841
7864
|
},
|
|
7842
7865
|
blocks: l
|
|
7843
7866
|
};
|
|
7844
|
-
|
|
7867
|
+
await t.prepare("\n INSERT INTO node_revisions (nodeId, version, snapshotJson, createdById)\n VALUES (?, ?, ?, ?)\n ").run(i, u, JSON.stringify(d), a), await q(e).clear();
|
|
7868
|
+
let f = await pi(t, i);
|
|
7869
|
+
return new Y(e.env).purgeSmart(e, t, i, o.slug, f), e.json({
|
|
7845
7870
|
success: !0,
|
|
7846
7871
|
id: i,
|
|
7847
7872
|
status: "published",
|
|
@@ -7852,7 +7877,11 @@ X.get("/", async (e) => {
|
|
|
7852
7877
|
let t = e.get("db"), n = e.req.query("id");
|
|
7853
7878
|
if (!n) return e.json({ error: "Node ID required" }, 400);
|
|
7854
7879
|
let r = Number(n), i = await t.prepare("SELECT slug, status FROM content_nodes WHERE id = ?").get(r);
|
|
7855
|
-
|
|
7880
|
+
if (await t.prepare("UPDATE content_nodes SET deletedAt = CURRENT_TIMESTAMP WHERE id = ?").run(r), await q(e).clear(), i && i.status === "published") {
|
|
7881
|
+
let n = await pi(t, r);
|
|
7882
|
+
new Y(e.env).purgeSmart(e, t, r, i.slug, n);
|
|
7883
|
+
}
|
|
7884
|
+
return e.json({
|
|
7856
7885
|
success: !0,
|
|
7857
7886
|
deletedNodeId: r
|
|
7858
7887
|
});
|
|
@@ -7860,23 +7889,27 @@ X.get("/", async (e) => {
|
|
|
7860
7889
|
let t = e.get("db"), n = await e.req.json(), r = Number(n.id);
|
|
7861
7890
|
if (!r) return e.json({ error: "Node ID required" }, 400);
|
|
7862
7891
|
let i = await t.prepare("SELECT slug, status FROM content_nodes WHERE id = ?").get(r);
|
|
7863
|
-
|
|
7892
|
+
if (await t.prepare("UPDATE content_nodes SET deletedAt = NULL WHERE id = ?").run(r), await q(e).clear(), i && i.status === "published") {
|
|
7893
|
+
let n = await pi(t, r);
|
|
7894
|
+
new Y(e.env).purgeSmart(e, t, r, i.slug, n);
|
|
7895
|
+
}
|
|
7896
|
+
return e.json({
|
|
7864
7897
|
success: !0,
|
|
7865
7898
|
restoredNodeId: r
|
|
7866
7899
|
});
|
|
7867
7900
|
}), X.delete("/purge", async (e) => {
|
|
7868
7901
|
let t = e.get("db"), n = e.req.query("id");
|
|
7869
7902
|
if (!n) return e.json({ error: "Node ID required" }, 400);
|
|
7870
|
-
let r = Number(n), i = await t.prepare("SELECT slug, status FROM content_nodes WHERE id = ?").get(r);
|
|
7871
|
-
return await t.prepare("DELETE FROM node_channels WHERE nodeId = ?").run(r), await t.prepare("DELETE FROM tree_nodes WHERE contentId = ?").run(r), await t.prepare("DELETE FROM content_blocks WHERE contentId = ?").run(r), await t.prepare("DELETE FROM node_revisions WHERE nodeId = ?").run(r), await t.prepare("DELETE FROM node_assets WHERE nodeId = ?").run(r), await t.prepare("DELETE FROM content_nodes WHERE id = ?").run(r), await q(e).clear(), i && i.status === "published" && new Y(e.env).purgeSmart(e, t, r, i.slug), e.json({
|
|
7903
|
+
let r = Number(n), i = await t.prepare("SELECT slug, status FROM content_nodes WHERE id = ?").get(r), a = await pi(t, r);
|
|
7904
|
+
return await t.prepare("DELETE FROM node_channels WHERE nodeId = ?").run(r), await t.prepare("DELETE FROM tree_nodes WHERE contentId = ?").run(r), await t.prepare("DELETE FROM content_blocks WHERE contentId = ?").run(r), await t.prepare("DELETE FROM node_revisions WHERE nodeId = ?").run(r), await t.prepare("DELETE FROM node_assets WHERE nodeId = ?").run(r), await t.prepare("DELETE FROM content_nodes WHERE id = ?").run(r), await q(e).clear(), i && i.status === "published" && new Y(e.env).purgeSmart(e, t, r, i.slug, a), e.json({
|
|
7872
7905
|
success: !0,
|
|
7873
7906
|
purgedNodeId: r
|
|
7874
7907
|
});
|
|
7875
7908
|
});
|
|
7876
7909
|
//#endregion
|
|
7877
7910
|
//#region server/routes/admin/trees.ts
|
|
7878
|
-
var
|
|
7879
|
-
function
|
|
7911
|
+
var xi = new e();
|
|
7912
|
+
function Si(e, t = null) {
|
|
7880
7913
|
let n = [];
|
|
7881
7914
|
for (let r = 0; r < e.length; r++) {
|
|
7882
7915
|
let i = e[r];
|
|
@@ -7889,20 +7922,20 @@ function xi(e, t = null) {
|
|
|
7889
7922
|
id: a,
|
|
7890
7923
|
parentId: t,
|
|
7891
7924
|
sortOrder: r
|
|
7892
|
-
}), i.children && Array.isArray(i.children) && i.children.length > 0 && n.push(...
|
|
7925
|
+
}), i.children && Array.isArray(i.children) && i.children.length > 0 && n.push(...Si(i.children, a));
|
|
7893
7926
|
}
|
|
7894
7927
|
}
|
|
7895
7928
|
return n;
|
|
7896
7929
|
}
|
|
7897
|
-
function
|
|
7930
|
+
function Ci(e) {
|
|
7898
7931
|
if (e == null || e === "null" || e === "" || typeof e == "string" && e.startsWith("draft-")) return null;
|
|
7899
7932
|
let t = Number(e);
|
|
7900
7933
|
return isNaN(t) ? null : t;
|
|
7901
7934
|
}
|
|
7902
|
-
function
|
|
7935
|
+
function wi(e) {
|
|
7903
7936
|
return +(e === !0 || e === 1 || e === "1" || e === "true");
|
|
7904
7937
|
}
|
|
7905
|
-
|
|
7938
|
+
xi.get("/tree.json", async (e) => {
|
|
7906
7939
|
try {
|
|
7907
7940
|
let t = e.get("db"), n = e.req.query("treeId") || "main-nav", r = e.req.query("preview") === "true", i = 1;
|
|
7908
7941
|
if (isNaN(Number(n))) {
|
|
@@ -7951,7 +7984,7 @@ bi.get("/tree.json", async (e) => {
|
|
|
7951
7984
|
} catch (t) {
|
|
7952
7985
|
return console.error("[CMS Tree API] GET Error:", t), e.json({ error: t.message || "Failed to fetch tree" }, 500);
|
|
7953
7986
|
}
|
|
7954
|
-
}),
|
|
7987
|
+
}), xi.post("/tree.json", async (e) => {
|
|
7955
7988
|
try {
|
|
7956
7989
|
let t = e.get("db"), n = await e.req.json(), r = n.treeId ? String(n.treeId).trim() : "main-nav", i = q(e), a = new Y(e.env), o = 1;
|
|
7957
7990
|
if (isNaN(Number(r))) {
|
|
@@ -7963,7 +7996,7 @@ bi.get("/tree.json", async (e) => {
|
|
|
7963
7996
|
}
|
|
7964
7997
|
} else o = Number(r);
|
|
7965
7998
|
if (n.tree && Array.isArray(n.tree)) {
|
|
7966
|
-
let r =
|
|
7999
|
+
let r = Si(n.tree, null);
|
|
7967
8000
|
if (r.length > 0) for (let e = 0; e < r.length; e += 50) {
|
|
7968
8001
|
let n = r.slice(e, e + 50), i = n.map((e) => e.id), a = i.map(() => "?").join(","), s = "UPDATE tree_nodes SET \n";
|
|
7969
8002
|
s += "parentId = CASE id \n", n.forEach(() => {
|
|
@@ -7980,9 +8013,9 @@ bi.get("/tree.json", async (e) => {
|
|
|
7980
8013
|
}
|
|
7981
8014
|
return await i.clear(), a.purgeGlobalCache(e), e.json({ success: !0 });
|
|
7982
8015
|
}
|
|
7983
|
-
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 =
|
|
8016
|
+
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 = wi(n.isHidden === void 0 ? m.isHidden === void 0 ? m.hidden : m.isHidden : n.isHidden);
|
|
7984
8017
|
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;
|
|
7985
|
-
let g =
|
|
8018
|
+
let g = Ci(u), _ = e.get("user")?.id || null;
|
|
7986
8019
|
if (s === "create") {
|
|
7987
8020
|
let r = m.slug || n.slug || c, s = r ? String(r).toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/(^-|-$)/g, "") : null;
|
|
7988
8021
|
if (s) {
|
|
@@ -8068,7 +8101,7 @@ bi.get("/tree.json", async (e) => {
|
|
|
8068
8101
|
details: t.message
|
|
8069
8102
|
}, 500);
|
|
8070
8103
|
}
|
|
8071
|
-
}),
|
|
8104
|
+
}), xi.get("/trees.json", async (e) => {
|
|
8072
8105
|
try {
|
|
8073
8106
|
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) => {
|
|
8074
8107
|
let n = Number(t.treeId), r = Number(t.channelId);
|
|
@@ -8097,7 +8130,7 @@ bi.get("/tree.json", async (e) => {
|
|
|
8097
8130
|
} catch {
|
|
8098
8131
|
return e.json([]);
|
|
8099
8132
|
}
|
|
8100
|
-
}),
|
|
8133
|
+
}), xi.post("/trees.json", async (e) => {
|
|
8101
8134
|
try {
|
|
8102
8135
|
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 };
|
|
8103
8136
|
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({
|
|
@@ -8136,7 +8169,7 @@ bi.get("/tree.json", async (e) => {
|
|
|
8136
8169
|
} catch (t) {
|
|
8137
8170
|
return console.error("[API Trees] Error saving tree:", t), e.json({ error: t.message || "Failed to save tree" }, 500);
|
|
8138
8171
|
}
|
|
8139
|
-
}),
|
|
8172
|
+
}), xi.delete("/trees.json", async (e) => {
|
|
8140
8173
|
let t = e.get("db"), n = e.req.query("id");
|
|
8141
8174
|
if (!n) return e.json({ error: "Tree ID required" }, 400);
|
|
8142
8175
|
let r = Number(n);
|
|
@@ -8151,8 +8184,8 @@ bi.get("/tree.json", async (e) => {
|
|
|
8151
8184
|
});
|
|
8152
8185
|
//#endregion
|
|
8153
8186
|
//#region server/routes/admin/channels.ts
|
|
8154
|
-
var
|
|
8155
|
-
|
|
8187
|
+
var Ti = new e();
|
|
8188
|
+
Ti.get("/", async (e) => {
|
|
8156
8189
|
try {
|
|
8157
8190
|
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").all(), a = ((Array.isArray(i) ? i : i?.results || []) || []).reduce((e, t) => {
|
|
8158
8191
|
e[t.channelId] || (e[t.channelId] = []);
|
|
@@ -8218,7 +8251,7 @@ wi.get("/", async (e) => {
|
|
|
8218
8251
|
error: t.message
|
|
8219
8252
|
}, 500);
|
|
8220
8253
|
}
|
|
8221
|
-
}),
|
|
8254
|
+
}), Ti.post("/", async (e) => {
|
|
8222
8255
|
try {
|
|
8223
8256
|
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 = "website", domain: c = "localhost", baseUrl: l = "http://localhost:4321", defaultLanguage: u = "en", 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 = Array.isArray(f) ? f : [], S = JSON.stringify(v || {}), C = e.get("user")?.id || m || p || null;
|
|
8224
8257
|
if (await t.prepare("SELECT id FROM channels WHERE key = ? AND id != ? LIMIT 1").get(y, i ?? -1)) return e.json({
|
|
@@ -8255,7 +8288,7 @@ wi.get("/", async (e) => {
|
|
|
8255
8288
|
details: t.message
|
|
8256
8289
|
}, 500);
|
|
8257
8290
|
}
|
|
8258
|
-
}),
|
|
8291
|
+
}), Ti.delete("/", async (e) => {
|
|
8259
8292
|
let t = e.get("db"), n = e.req.query("id");
|
|
8260
8293
|
if (!n) return e.json({ error: "Channel ID required" }, 400);
|
|
8261
8294
|
let r = Number(n);
|
|
@@ -8273,9 +8306,9 @@ wi.get("/", async (e) => {
|
|
|
8273
8306
|
});
|
|
8274
8307
|
//#endregion
|
|
8275
8308
|
//#region server/routes/admin/schemas.ts
|
|
8276
|
-
var
|
|
8309
|
+
var Ei = new e(), Di = null, Oi = (e) => {
|
|
8277
8310
|
try {
|
|
8278
|
-
if (!
|
|
8311
|
+
if (!Di) {
|
|
8279
8312
|
let t = li(e.env?.BUNDLED_DEFINITIONS || Ar), n = t.userTemplate || {
|
|
8280
8313
|
id: "userTemplate",
|
|
8281
8314
|
label: "User Account",
|
|
@@ -8312,7 +8345,7 @@ var Ti = new e(), Ei = null, Di = (e) => {
|
|
|
8312
8345
|
}
|
|
8313
8346
|
}
|
|
8314
8347
|
};
|
|
8315
|
-
|
|
8348
|
+
Di = {
|
|
8316
8349
|
channelTemplate: t.channelTemplate || null,
|
|
8317
8350
|
treeTemplate: t.treeTemplate || null,
|
|
8318
8351
|
userTemplate: n,
|
|
@@ -8324,7 +8357,7 @@ var Ti = new e(), Ei = null, Di = (e) => {
|
|
|
8324
8357
|
blockLayouts: t.blockLayouts || {}
|
|
8325
8358
|
};
|
|
8326
8359
|
}
|
|
8327
|
-
return e.json(
|
|
8360
|
+
return e.json(Di, 200, { "Cache-Control": "public, max-age=300, stale-while-revalidate=86400" });
|
|
8328
8361
|
} catch (t) {
|
|
8329
8362
|
return console.error("[CMS API] Error loading schemas:", t), e.json({
|
|
8330
8363
|
error: "Failed to load schemas",
|
|
@@ -8332,10 +8365,10 @@ var Ti = new e(), Ei = null, Di = (e) => {
|
|
|
8332
8365
|
}, 500);
|
|
8333
8366
|
}
|
|
8334
8367
|
};
|
|
8335
|
-
|
|
8368
|
+
Ei.get("/", Oi), Ei.get("/schemas.json", Oi);
|
|
8336
8369
|
//#endregion
|
|
8337
8370
|
//#region server/routes/admin/validation.ts
|
|
8338
|
-
var
|
|
8371
|
+
var ki = new e(), Ai = {
|
|
8339
8372
|
node: "content_nodes",
|
|
8340
8373
|
nodes: "content_nodes",
|
|
8341
8374
|
content_node: "content_nodes",
|
|
@@ -8347,7 +8380,7 @@ var Oi = new e(), ki = {
|
|
|
8347
8380
|
user: "users",
|
|
8348
8381
|
users: "users",
|
|
8349
8382
|
user_account: "user_accounts"
|
|
8350
|
-
},
|
|
8383
|
+
}, ji = {
|
|
8351
8384
|
content_nodes: [
|
|
8352
8385
|
"id",
|
|
8353
8386
|
"title",
|
|
@@ -8404,11 +8437,11 @@ var Oi = new e(), ki = {
|
|
|
8404
8437
|
"createdAt"
|
|
8405
8438
|
]
|
|
8406
8439
|
};
|
|
8407
|
-
|
|
8440
|
+
ki.post("/validate-unique", async (e) => {
|
|
8408
8441
|
try {
|
|
8409
8442
|
let t = e.get("db"), { entityType: n, field: r, value: i, excludeId: a } = await e.req.json();
|
|
8410
8443
|
if (!r || i == null || String(i).trim() === "") return e.json({ isUnique: !0 });
|
|
8411
|
-
let o =
|
|
8444
|
+
let o = Ai[n] || "content_nodes", s = r.replace(/[^a-zA-Z0-9_]/g, ""), c = (ji[o] || ji.content_nodes).includes(s), l = -1;
|
|
8412
8445
|
if (a != null && String(a).trim() !== "") {
|
|
8413
8446
|
let e = Number(a);
|
|
8414
8447
|
l = isNaN(e) ? String(a) : e;
|
|
@@ -8420,7 +8453,7 @@ Oi.post("/validate-unique", async (e) => {
|
|
|
8420
8453
|
} catch (t) {
|
|
8421
8454
|
return console.error("[API Validation] Error validating global uniqueness:", t), e.json({ error: "Failed to validate uniqueness" }, 500);
|
|
8422
8455
|
}
|
|
8423
|
-
}),
|
|
8456
|
+
}), ki.post("/validate-unique-sibling", async (e) => {
|
|
8424
8457
|
try {
|
|
8425
8458
|
let t = e.get("db"), { slug: n, treeId: r, parentId: i, excludeTreeNodeId: a } = await e.req.json();
|
|
8426
8459
|
if (!n || !String(n).trim() || !r) return e.json({ isUnique: !0 });
|
|
@@ -8447,8 +8480,8 @@ Oi.post("/validate-unique", async (e) => {
|
|
|
8447
8480
|
});
|
|
8448
8481
|
//#endregion
|
|
8449
8482
|
//#region server/routes/admin/stats.ts
|
|
8450
|
-
var
|
|
8451
|
-
|
|
8483
|
+
var Mi = new e();
|
|
8484
|
+
Mi.get("/", async (e) => {
|
|
8452
8485
|
try {
|
|
8453
8486
|
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) => ({
|
|
8454
8487
|
...e,
|
|
@@ -8504,22 +8537,27 @@ async function Q(e, t, n = []) {
|
|
|
8504
8537
|
}
|
|
8505
8538
|
return [];
|
|
8506
8539
|
}
|
|
8507
|
-
async function
|
|
8540
|
+
async function Ni(e, t, n = []) {
|
|
8508
8541
|
let r = e.prepare(t);
|
|
8509
8542
|
if (typeof r.bind == "function") return await r.bind(...n).run();
|
|
8510
8543
|
if (typeof r.run == "function") return await r.run(...n);
|
|
8511
8544
|
}
|
|
8512
|
-
function
|
|
8545
|
+
function Pi(e, t, n) {
|
|
8513
8546
|
let r = e || (t ? `/media/${t}` : "");
|
|
8514
8547
|
return r && n && r.startsWith(`https://${n}/`) && !r.includes("/media/") && (r = r.replace(`https://${n}/`, `https://${n}/media/`)), r;
|
|
8515
8548
|
}
|
|
8516
|
-
async function
|
|
8517
|
-
let r = new Y(e.env), i = await Q(t, "\n SELECT
|
|
8549
|
+
async function Fi(e, t, n) {
|
|
8550
|
+
let r = new Y(e.env), i = await Q(t, "\n SELECT cdnUrl, storageKeyPrivate\n FROM assets\n WHERE id = ? OR parentAssetId = ?\n ", [n, n]), a = [];
|
|
8551
|
+
for (let t of i) {
|
|
8552
|
+
let n = Pi(t.cdnUrl, t.storageKeyPrivate, e.env?.CDN_DOMAIN);
|
|
8553
|
+
n && a.push(n);
|
|
8554
|
+
}
|
|
8555
|
+
let o = await Q(t, "\n SELECT DISTINCT cn.id, cn.slug, cn.status\n FROM node_assets na\n INNER JOIN content_nodes cn ON na.nodeId = cn.id\n LEFT JOIN assets crop ON na.assetId = crop.id\n WHERE cn.status = 'published' AND (\n na.assetId = ?\n OR crop.parentAssetId = ?\n OR crop.id = (SELECT parentAssetId FROM assets WHERE id = ?)\n )\n ", [
|
|
8518
8556
|
n,
|
|
8519
8557
|
n,
|
|
8520
8558
|
n
|
|
8521
8559
|
]);
|
|
8522
|
-
if (
|
|
8560
|
+
if (o.length !== 0) for (let n of o) n.id && r.purgeSmart(e, t, n.id, n.slug, a);
|
|
8523
8561
|
}
|
|
8524
8562
|
Z.get("/", async (e) => {
|
|
8525
8563
|
try {
|
|
@@ -8588,7 +8626,7 @@ Z.get("/", async (e) => {
|
|
|
8588
8626
|
...JSON.parse(t.dataJson || "{}")
|
|
8589
8627
|
};
|
|
8590
8628
|
} catch {}
|
|
8591
|
-
let r =
|
|
8629
|
+
let r = Pi(t.cdnUrl, t.storageKeyPrivate, e.env?.CDN_DOMAIN);
|
|
8592
8630
|
return {
|
|
8593
8631
|
id: t.id,
|
|
8594
8632
|
filename: t.filename || "Untitled Asset",
|
|
@@ -8631,7 +8669,7 @@ Z.get("/", async (e) => {
|
|
|
8631
8669
|
let y = e.env.CDN_DOMAIN, b = v.replace(/^\//, ""), x = y ? `https://${y}/media/${b}` : `/media/${b}`, S = i.type || "application/octet-stream", C = i.size || 0, w = e.get("userId"), T = typeof w == "string" && w.trim().length > 0 ? w : null;
|
|
8632
8670
|
T && (await Q(t, "SELECT id FROM users WHERE id = ?", [T])).length === 0 && (T = null);
|
|
8633
8671
|
let E = +!!h;
|
|
8634
|
-
await
|
|
8672
|
+
await Ni(t, "\n INSERT INTO assets (id, filename, mimeType, sizeBytes, storageKeyPrivate, cdnUrl, createdById, isSystemVariant, parentAssetId, cropCoordinatesJson)\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)\n ", [
|
|
8635
8673
|
p,
|
|
8636
8674
|
i.name,
|
|
8637
8675
|
S,
|
|
@@ -8646,7 +8684,7 @@ Z.get("/", async (e) => {
|
|
|
8646
8684
|
let D = x;
|
|
8647
8685
|
if (s) {
|
|
8648
8686
|
let n = await Q(t, "SELECT cdnUrl, storageKeyPrivate FROM assets WHERE id = ?", [s]);
|
|
8649
|
-
n.length > 0 && (D =
|
|
8687
|
+
n.length > 0 && (D = Pi(n[0].cdnUrl, n[0].storageKeyPrivate, y)), await Fi(e, t, s);
|
|
8650
8688
|
}
|
|
8651
8689
|
return e.json({
|
|
8652
8690
|
id: p,
|
|
@@ -8688,7 +8726,7 @@ Z.get("/", async (e) => {
|
|
|
8688
8726
|
...JSON.parse(i.dataJson || "{}")
|
|
8689
8727
|
};
|
|
8690
8728
|
} catch {}
|
|
8691
|
-
let l =
|
|
8729
|
+
let l = Pi(i.cdnUrl, i.storageKeyPrivate, e.env?.CDN_DOMAIN);
|
|
8692
8730
|
return e.json({
|
|
8693
8731
|
id: i.id,
|
|
8694
8732
|
filename: i.filename,
|
|
@@ -8715,7 +8753,7 @@ Z.get("/", async (e) => {
|
|
|
8715
8753
|
createdAt: t.createdAt,
|
|
8716
8754
|
parentAssetId: t.parentAssetId || i.id,
|
|
8717
8755
|
cropCoordinates: n,
|
|
8718
|
-
url:
|
|
8756
|
+
url: Pi(t.cdnUrl, t.storageKeyPrivate, e.env?.CDN_DOMAIN),
|
|
8719
8757
|
originalUrl: l
|
|
8720
8758
|
};
|
|
8721
8759
|
})
|
|
@@ -8731,23 +8769,23 @@ Z.get("/", async (e) => {
|
|
|
8731
8769
|
try {
|
|
8732
8770
|
o = JSON.parse(a.dataJson || "{}");
|
|
8733
8771
|
} catch {}
|
|
8734
|
-
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
|
|
8772
|
+
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 Ni(t, "UPDATE assets SET filename = ?, dataJson = ?, updatedAt = CURRENT_TIMESTAMP WHERE id = ?", [
|
|
8735
8773
|
r.filename === void 0 ? a.filename : r.filename,
|
|
8736
8774
|
JSON.stringify(o),
|
|
8737
8775
|
n
|
|
8738
|
-
]), await
|
|
8776
|
+
]), await Fi(e, t, n), e.json({ success: !0 });
|
|
8739
8777
|
} catch (t) {
|
|
8740
8778
|
return console.error("❌ [Asset Update Error]:", t), e.json({ error: "Failed to update asset" }, 500);
|
|
8741
8779
|
}
|
|
8742
8780
|
}), Z.delete("/:id", async (e) => {
|
|
8743
8781
|
try {
|
|
8744
8782
|
let t = u(e), n = e.req.param("id"), r = (await Q(t, "SELECT id, filename, isSystemVariant FROM assets WHERE id = ?", [n]))[0];
|
|
8745
|
-
return r ? (r.isSystemVariant ? await
|
|
8783
|
+
return r ? (await Fi(e, t, n), r.isSystemVariant ? await Ni(t, "UPDATE assets SET deletedAt = CURRENT_TIMESTAMP WHERE id = ?", [n]) : await Ni(t, "UPDATE assets\n SET deletedAt = CURRENT_TIMESTAMP\n WHERE id = ? OR parentAssetId = ? OR (isSystemVariant = 1 AND (filename LIKE ? OR filename LIKE ?))", [
|
|
8746
8784
|
n,
|
|
8747
8785
|
n,
|
|
8748
8786
|
`crop_%${r.filename ? r.filename.replace(/\.[^/.]+$/, "") : ""}%`,
|
|
8749
8787
|
`%${n}%`
|
|
8750
|
-
]),
|
|
8788
|
+
]), e.json({
|
|
8751
8789
|
success: !0,
|
|
8752
8790
|
id: n,
|
|
8753
8791
|
trashed: !0
|
|
@@ -8763,12 +8801,12 @@ Z.get("/", async (e) => {
|
|
|
8763
8801
|
let t = u(e), n = await e.req.json(), r = n.id || n.assetId;
|
|
8764
8802
|
if (!r) return e.json({ error: "Asset ID required" }, 400);
|
|
8765
8803
|
let i = (await Q(t, "SELECT id, filename FROM assets WHERE id = ?", [r]))[0];
|
|
8766
|
-
return i ? (await
|
|
8804
|
+
return i ? (await Ni(t, "UPDATE assets \n SET deletedAt = NULL \n WHERE id = ? OR parentAssetId = ? OR (isSystemVariant = 1 AND (filename LIKE ? OR filename LIKE ?))", [
|
|
8767
8805
|
r,
|
|
8768
8806
|
r,
|
|
8769
8807
|
`crop_%${i.filename ? i.filename.replace(/\.[^/.]+$/, "") : ""}%`,
|
|
8770
8808
|
`%${r}%`
|
|
8771
|
-
]), await
|
|
8809
|
+
]), await Fi(e, t, r), e.json({
|
|
8772
8810
|
success: !0,
|
|
8773
8811
|
id: r,
|
|
8774
8812
|
restored: !0
|
|
@@ -8783,7 +8821,7 @@ Z.get("/", async (e) => {
|
|
|
8783
8821
|
try {
|
|
8784
8822
|
let t = u(e), n = ri(e.env), r = e.req.param("id"), i = (await Q(t, "SELECT id, filename, storageKeyPrivate, isSystemVariant FROM assets WHERE id = ?", [r]))[0];
|
|
8785
8823
|
if (!i) return e.json({ error: "Asset not found" }, 404);
|
|
8786
|
-
await
|
|
8824
|
+
await Fi(e, t, r);
|
|
8787
8825
|
let a = [i];
|
|
8788
8826
|
i.isSystemVariant || (a = [i, ...await Q(t, "SELECT id, storageKeyPrivate FROM assets \n WHERE parentAssetId = ? OR (isSystemVariant = 1 AND (filename LIKE ? OR filename LIKE ?))", [
|
|
8789
8827
|
r,
|
|
@@ -8799,7 +8837,7 @@ Z.get("/", async (e) => {
|
|
|
8799
8837
|
}
|
|
8800
8838
|
}
|
|
8801
8839
|
let s = o.map(() => "?").join(",");
|
|
8802
|
-
return await
|
|
8840
|
+
return await Ni(t, `DELETE FROM node_assets WHERE assetId IN (${s})`, o), await Ni(t, `DELETE FROM assets WHERE id IN (${s})`, o), e.json({
|
|
8803
8841
|
success: !0,
|
|
8804
8842
|
id: r,
|
|
8805
8843
|
purged: !0,
|
|
@@ -8815,8 +8853,8 @@ Z.get("/", async (e) => {
|
|
|
8815
8853
|
});
|
|
8816
8854
|
//#endregion
|
|
8817
8855
|
//#region server/routes/public/node.ts
|
|
8818
|
-
var
|
|
8819
|
-
function
|
|
8856
|
+
var Ii = new e();
|
|
8857
|
+
function Li(e, t) {
|
|
8820
8858
|
let n = /* @__PURE__ */ new Date();
|
|
8821
8859
|
if (e && String(e).trim() !== "") {
|
|
8822
8860
|
let t = new Date(e);
|
|
@@ -8828,7 +8866,7 @@ function Ii(e, t) {
|
|
|
8828
8866
|
}
|
|
8829
8867
|
return !0;
|
|
8830
8868
|
}
|
|
8831
|
-
async function
|
|
8869
|
+
async function Ri(e, t) {
|
|
8832
8870
|
if (!t || typeof t != "object") return t;
|
|
8833
8871
|
let n = { ...t };
|
|
8834
8872
|
for (let [t, r] of Object.entries(n)) if (typeof r == "string" && r.startsWith("ast_")) try {
|
|
@@ -8849,10 +8887,10 @@ async function Li(e, t) {
|
|
|
8849
8887
|
};
|
|
8850
8888
|
}
|
|
8851
8889
|
} catch {}
|
|
8852
|
-
else typeof r == "object" && r && !Array.isArray(r) && !r.url && (n[t] = await
|
|
8890
|
+
else typeof r == "object" && r && !Array.isArray(r) && !r.url && (n[t] = await Ri(e, r));
|
|
8853
8891
|
return n;
|
|
8854
8892
|
}
|
|
8855
|
-
async function
|
|
8893
|
+
async function zi(e, t, n) {
|
|
8856
8894
|
let r = t.filter((e) => e.componentId === "content-feed" || e.componentId === "article-list");
|
|
8857
8895
|
for (let t of r) {
|
|
8858
8896
|
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];
|
|
@@ -8868,7 +8906,7 @@ async function Ri(e, t, n) {
|
|
|
8868
8906
|
if (e.dataJson) try {
|
|
8869
8907
|
t = typeof e.dataJson == "string" ? JSON.parse(e.dataJson) : e.dataJson;
|
|
8870
8908
|
} catch {}
|
|
8871
|
-
return
|
|
8909
|
+
return Li(t.startShowingAt, t.stopShowingAt) ? {
|
|
8872
8910
|
id: e.id,
|
|
8873
8911
|
title: e.title,
|
|
8874
8912
|
slug: e.slug,
|
|
@@ -8885,7 +8923,7 @@ async function Ri(e, t, n) {
|
|
|
8885
8923
|
}
|
|
8886
8924
|
}
|
|
8887
8925
|
}
|
|
8888
|
-
async function
|
|
8926
|
+
async function Bi(e, t, n, r, i = !1) {
|
|
8889
8927
|
if (!t) return { blocks: [] };
|
|
8890
8928
|
let a = 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\n FROM tree_nodes t\n INNER JOIN content_nodes c ON t.contentId = c.id\n WHERE t.id = ? OR c.id = ?\n UNION ALL\n SELECT t.id, t.contentId, c.title, c.slug, t.parentId, ap.level + 1\n FROM tree_nodes t\n INNER JOIN content_nodes c ON t.contentId = c.id\n INNER JOIN ancestor_path ap ON t.id = ap.parentId\n )\n SELECT * FROM ancestor_path ORDER BY level ASC\n ").all(t, t), o = Array.isArray(a) ? a : a?.results || [];
|
|
8891
8929
|
if (!o || o.length === 0) return { blocks: [] };
|
|
@@ -8915,10 +8953,10 @@ async function zi(e, t, n, r, i = !1) {
|
|
|
8915
8953
|
try {
|
|
8916
8954
|
o = (typeof t.dataJson == "string" ? JSON.parse(t.dataJson) : t.dataJson) || {};
|
|
8917
8955
|
} catch {}
|
|
8918
|
-
let s = o.hidden === !0 || o.hidden === 1 || o.hidden === "1" || o.hidden === "true", l =
|
|
8956
|
+
let s = o.hidden === !0 || o.hidden === 1 || o.hidden === "1" || o.hidden === "true", l = Li(o.startShowingAt, o.stopShowingAt);
|
|
8919
8957
|
if (!i && (s || !l)) continue;
|
|
8920
|
-
let u = t.elementType || t.componentId || "text-block", d = r.blocks?.[u]?.fields || r.elements?.[u]?.fields || r.components?.[u]?.fields || {}, f = String(o.blockId || o._instanceId || o.id || t.blockId || t.id), p =
|
|
8921
|
-
p = await si(e, p), p = await
|
|
8958
|
+
let u = t.elementType || t.componentId || "text-block", d = r.blocks?.[u]?.fields || r.elements?.[u]?.fields || r.components?.[u]?.fields || {}, f = String(o.blockId || o._instanceId || o.id || t.blockId || t.id), p = Vi(o, d);
|
|
8959
|
+
p = await si(e, p), p = await Ri(e, p), p = Hi(p), p.blockId = f;
|
|
8922
8960
|
let m = t.region || n;
|
|
8923
8961
|
c[m] || (c[m] = []), c[m].push({
|
|
8924
8962
|
instanceId: t.id,
|
|
@@ -8937,7 +8975,7 @@ async function zi(e, t, n, r, i = !1) {
|
|
|
8937
8975
|
}
|
|
8938
8976
|
return { blocks: [] };
|
|
8939
8977
|
}
|
|
8940
|
-
function
|
|
8978
|
+
function Vi(e, t = {}) {
|
|
8941
8979
|
let n = {};
|
|
8942
8980
|
for (let [r, i] of Object.entries(e)) {
|
|
8943
8981
|
if (r.endsWith("_meta") || r === "disabledRegions" || r === "hidden" || r === "is_hidden" || r === "isHidden" || r === "status" || r === "startShowingAt" || r === "stopShowingAt" || r === "slug" || r === "title" || r === "id" || r.startsWith("_")) continue;
|
|
@@ -8946,14 +8984,14 @@ function Bi(e, t = {}) {
|
|
|
8946
8984
|
}
|
|
8947
8985
|
return n;
|
|
8948
8986
|
}
|
|
8949
|
-
function
|
|
8950
|
-
if (Array.isArray(e)) return e.map(
|
|
8987
|
+
function Hi(e) {
|
|
8988
|
+
if (Array.isArray(e)) return e.map(Hi);
|
|
8951
8989
|
if (!e || typeof e != "object") return e;
|
|
8952
8990
|
if (typeof e.id == "string" && e.id.startsWith("ast_") && typeof e.url == "string") {
|
|
8953
8991
|
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 ? {
|
|
8954
8992
|
...t,
|
|
8955
8993
|
...t.crops?.[r] || {}
|
|
8956
|
-
} : t, a = Object.fromEntries(Object.entries(n).filter(([, t]) => t?.id !== e.id).map(([t, n]) => [t,
|
|
8994
|
+
} : t, a = Object.fromEntries(Object.entries(n).filter(([, t]) => t?.id !== e.id).map(([t, n]) => [t, Hi({
|
|
8957
8995
|
...n,
|
|
8958
8996
|
title: n?.title ?? e.title ?? "",
|
|
8959
8997
|
alt: n?.alt ?? e.alt ?? "",
|
|
@@ -8967,9 +9005,9 @@ function Vi(e) {
|
|
|
8967
9005
|
...Object.keys(a).length > 0 ? { variants: a } : {}
|
|
8968
9006
|
};
|
|
8969
9007
|
}
|
|
8970
|
-
return Object.fromEntries(Object.entries(e).map(([e, t]) => [e,
|
|
9008
|
+
return Object.fromEntries(Object.entries(e).map(([e, t]) => [e, Hi(t)]));
|
|
8971
9009
|
}
|
|
8972
|
-
async function
|
|
9010
|
+
async function Ui(e, t) {
|
|
8973
9011
|
if (typeof t == "string") {
|
|
8974
9012
|
if (!t.includes("#node:") && !t.includes("data-node-id") && !t.includes("#asset:") && !t.includes("data-asset-id")) return t;
|
|
8975
9013
|
let n = /* @__PURE__ */ new Set();
|
|
@@ -8986,7 +9024,7 @@ async function Hi(e, t) {
|
|
|
8986
9024
|
let t = n[1], r = t.match(/data-node-id=["']([^"']+)["']/i), i = t.match(/data-tree-id=["']([^"']+)["']/i);
|
|
8987
9025
|
if (!r || !i) continue;
|
|
8988
9026
|
let a = await e.prepare("SELECT id as treeNodeId FROM tree_nodes WHERE contentId = ? AND treeId = ? LIMIT 1").get(r[1], i[1]);
|
|
8989
|
-
a?.treeNodeId && u.set(`${r[1]}:${i[1]}`, await
|
|
9027
|
+
a?.treeNodeId && u.set(`${r[1]}:${i[1]}`, await Ki(e, String(a.treeNodeId), i[1]));
|
|
8990
9028
|
}
|
|
8991
9029
|
return t.replace(d, (e, t) => {
|
|
8992
9030
|
let n = t.match(/data-node-id=["']([^"']+)["']/i), r = t.match(/data-asset-id=["']([^"']+)["']/i), i = t.match(/href=["']([^"']+)["']/i);
|
|
@@ -9001,18 +9039,18 @@ async function Hi(e, t) {
|
|
|
9001
9039
|
return i ? `<a${t.replace(/href=["'][^"']*["']/i, `href="${g || "/"}"`)}>` : e;
|
|
9002
9040
|
});
|
|
9003
9041
|
}
|
|
9004
|
-
if (Array.isArray(t)) return Promise.all(t.map((t) =>
|
|
9042
|
+
if (Array.isArray(t)) return Promise.all(t.map((t) => Ui(e, t)));
|
|
9005
9043
|
if (t && typeof t == "object") {
|
|
9006
9044
|
if (typeof t.href == "string" && (t.href.startsWith("#node:") || t.href.startsWith("#asset:"))) return {
|
|
9007
9045
|
...t,
|
|
9008
|
-
href: await
|
|
9046
|
+
href: await Wi(e, t)
|
|
9009
9047
|
};
|
|
9010
|
-
let n = await Promise.all(Object.entries(t).map(async ([t, n]) => [t, await
|
|
9048
|
+
let n = await Promise.all(Object.entries(t).map(async ([t, n]) => [t, await Ui(e, n)]));
|
|
9011
9049
|
return Object.fromEntries(n);
|
|
9012
9050
|
}
|
|
9013
9051
|
return t;
|
|
9014
9052
|
}
|
|
9015
|
-
async function
|
|
9053
|
+
async function Wi(e, t) {
|
|
9016
9054
|
let n = t.href.match(/^#node:(.+)$/), r = t.href.match(/^#asset:(.+)$/);
|
|
9017
9055
|
if (r) {
|
|
9018
9056
|
let t = await e.prepare("SELECT cdnUrl, storageKeyPrivate FROM assets WHERE id = ?").get(r[1]);
|
|
@@ -9023,14 +9061,14 @@ async function Ui(e, t) {
|
|
|
9023
9061
|
if (t.treeId) {
|
|
9024
9062
|
let n = await e.prepare("SELECT id as treeNodeId FROM tree_nodes WHERE contentId = ? AND treeId = ? LIMIT 1").get(i, t.treeId);
|
|
9025
9063
|
if (n?.treeNodeId) {
|
|
9026
|
-
let r = await
|
|
9064
|
+
let r = await Ki(e, String(n.treeNodeId), String(t.treeId));
|
|
9027
9065
|
if (r) return r;
|
|
9028
9066
|
}
|
|
9029
9067
|
}
|
|
9030
9068
|
let a = await e.prepare("SELECT slug FROM content_nodes WHERE id = ?").get(i);
|
|
9031
9069
|
return a?.slug ? `/${String(a.slug).replace(/^\/+|\/+$/g, "")}` : "#";
|
|
9032
9070
|
}
|
|
9033
|
-
function
|
|
9071
|
+
function Gi(e) {
|
|
9034
9072
|
let t = e.socialImage;
|
|
9035
9073
|
if (!t || typeof t != "object") return null;
|
|
9036
9074
|
let n = (e, t) => {
|
|
@@ -9061,7 +9099,7 @@ function Wi(e) {
|
|
|
9061
9099
|
])
|
|
9062
9100
|
};
|
|
9063
9101
|
}
|
|
9064
|
-
async function
|
|
9102
|
+
async function Ki(e, t, n) {
|
|
9065
9103
|
if (!t) return "";
|
|
9066
9104
|
let r = await e.prepare("\n WITH RECURSIVE ancestor_path(id, parentId, slug, level) AS (\n SELECT t.id, t.parentId, c.slug, 0\n FROM tree_nodes t\n INNER JOIN content_nodes c ON t.contentId = c.id\n WHERE t.id = ? AND t.treeId = ?\n UNION ALL\n SELECT t.id, t.parentId, c.slug, ap.level + 1\n FROM tree_nodes t\n INNER JOIN content_nodes c ON t.contentId = c.id\n INNER JOIN ancestor_path ap ON t.id = ap.parentId\n WHERE t.treeId = ?\n )\n SELECT slug FROM ancestor_path ORDER BY level DESC\n ").all(t, n, n), i = Array.isArray(r) ? r : r?.results || [], a = [];
|
|
9067
9105
|
for (let e of i) {
|
|
@@ -9070,7 +9108,7 @@ async function Gi(e, t, n) {
|
|
|
9070
9108
|
}
|
|
9071
9109
|
return "/" + a.join("/");
|
|
9072
9110
|
}
|
|
9073
|
-
async function
|
|
9111
|
+
async function qi(e, t, n, r, i) {
|
|
9074
9112
|
let a = {}, o = null;
|
|
9075
9113
|
if (t) {
|
|
9076
9114
|
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\n FROM tree_nodes t\n INNER JOIN content_nodes c ON t.contentId = c.id\n WHERE t.id = ? OR c.id = ?\n UNION ALL\n SELECT t.id, t.contentId, c.title, c.slug, t.parentId, ap.level + 1\n FROM tree_nodes t\n INNER JOIN content_nodes c ON t.contentId = c.id\n INNER JOIN ancestor_path ap ON t.id = ap.parentId\n )\n SELECT c.dataJson, c.draftDataJson \n FROM ancestor_path ap\n INNER JOIN content_nodes c ON ap.contentId = c.id\n ORDER BY ap.level ASC\n ").all(t, t), i = Array.isArray(n) ? n : n?.results || [], s = /* @__PURE__ */ new Set([
|
|
@@ -9108,7 +9146,7 @@ async function Ki(e, t, n, r, i) {
|
|
|
9108
9146
|
inheritedFields: a
|
|
9109
9147
|
};
|
|
9110
9148
|
}
|
|
9111
|
-
|
|
9149
|
+
Ii.get("/*", async (e) => {
|
|
9112
9150
|
try {
|
|
9113
9151
|
let t = e.get("db"), n = new URL(e.req.url).pathname.match(/\/node\/(.+)$/), r = (n ? n[1] : "home").replace(/^\/+|\/+$/g, ""), i = e.req.query("channelId") || e.req.query("channel") || "1", a = e.req.query("lang") || "en", o = e.req.query("preview") === "true", s = isNaN(Number(i)) ? await t.prepare("SELECT * FROM channels WHERE key = ?").get(i) : await t.prepare("SELECT * FROM channels WHERE id = ?").get(Number(i));
|
|
9114
9152
|
if (!s) return e.json({ error: `Channel '${i}' not found` }, 404);
|
|
@@ -9130,7 +9168,7 @@ Fi.get("/*", async (e) => {
|
|
|
9130
9168
|
WHERE cn.slug = ? ${l === null ? "" : "AND nc.channelId = ?"}
|
|
9131
9169
|
`, o = l === null ? [n] : [n, l], s = await t.prepare(a).all(...o), c = Array.isArray(s) ? s : s?.results || [];
|
|
9132
9170
|
if (c.length > 0) for (let e of c) {
|
|
9133
|
-
let n = (await
|
|
9171
|
+
let n = (await Ki(t, e.treeNodeId, e.treeId)).replace(/^\/+|\/+$/g, ""), r = i.replace(/^\/+|\/+$/g, "");
|
|
9134
9172
|
if (n === r || r === "home" && (n === "" || n === "home")) {
|
|
9135
9173
|
h = e, g = e;
|
|
9136
9174
|
break;
|
|
@@ -9148,7 +9186,7 @@ Fi.get("/*", async (e) => {
|
|
|
9148
9186
|
LIMIT 1
|
|
9149
9187
|
`).get(...e);
|
|
9150
9188
|
}
|
|
9151
|
-
let v = g?.treeId || _ || "main-nav", y = g?.parentId || null, b = g?.treeNodeId ? await
|
|
9189
|
+
let v = g?.treeId || _ || "main-nav", y = g?.parentId || null, b = g?.treeNodeId ? await Ki(t, g.treeNodeId, v) : `/${(h.slug || "").replace(/^\/+|\/+$/g, "")}`, x = {
|
|
9152
9190
|
id: h.id,
|
|
9153
9191
|
title: h.title,
|
|
9154
9192
|
slug: h.slug,
|
|
@@ -9161,28 +9199,28 @@ Fi.get("/*", async (e) => {
|
|
|
9161
9199
|
C.tabs && Object.values(C.tabs).forEach((e) => {
|
|
9162
9200
|
Object.assign(w, e.fields || {});
|
|
9163
9201
|
});
|
|
9164
|
-
let T = {}, E = null, D = null,
|
|
9165
|
-
if (
|
|
9166
|
-
|
|
9202
|
+
let T = {}, E = null, D = null, O = !1, k = {}, A = o && h.draftDataJson ? h.draftDataJson : h.dataJson || h.draftDataJson;
|
|
9203
|
+
if (A) try {
|
|
9204
|
+
k = typeof A == "string" ? JSON.parse(A) : A;
|
|
9167
9205
|
} catch {}
|
|
9168
|
-
|
|
9169
|
-
let
|
|
9170
|
-
for (let [e, t] of Object.entries(
|
|
9171
|
-
let
|
|
9172
|
-
|
|
9173
|
-
let
|
|
9174
|
-
delete
|
|
9175
|
-
let
|
|
9176
|
-
if (!o && (
|
|
9177
|
-
let
|
|
9206
|
+
k.disabledRegions && (T = k.disabledRegions), O = k.hidden === !0 || k.hidden === 1 || k.hidden === "1" || k.hidden === "true", E = k.startShowingAt || null, D = k.stopShowingAt || null;
|
|
9207
|
+
let j = k.layoutId, ee = j && j !== "inherit", { resolvedLayoutId: te, inheritedFields: ne } = await qi(t, y, v, o, w), re = ee ? j : te || C.defaultLayout || null;
|
|
9208
|
+
for (let [e, t] of Object.entries(ne)) (k[e] === void 0 || k[e] === null || k[e] === "" || k[e] === "inherit") && t !== void 0 && (k[e] = t);
|
|
9209
|
+
let M = await si(t, Vi(k, w));
|
|
9210
|
+
M = await Ri(t, M), M = Hi(M), M = await Ui(t, M);
|
|
9211
|
+
let ie = Gi(M);
|
|
9212
|
+
delete M.socialImage, delete M.fbImage, delete M.xImage, delete M.whatsappImage, ie && (M.socialImages = ie), x.slug = h.slug, x.title = h.title, Object.assign(x, M), x.layoutId = re;
|
|
9213
|
+
let ae = !!h.isHidden || O, oe = !Li(E, D);
|
|
9214
|
+
if (!o && (ae || oe)) return e.json({ error: "Node is hidden or outside its scheduled publishing window" }, 404);
|
|
9215
|
+
let se = [];
|
|
9178
9216
|
if (g?.treeNodeId) {
|
|
9179
9217
|
let e = await t.prepare("\n 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\n FROM tree_nodes t\n INNER JOIN content_nodes c ON t.contentId = c.id\n WHERE t.parentId = ? AND t.treeId = ?\n ORDER BY t.sortOrder ASC\n ").all(g.treeNodeId, v), n = Array.isArray(e) ? e : e?.results || [], r = x.path === "/" ? "" : x.path;
|
|
9180
|
-
|
|
9218
|
+
se = n.map((e) => {
|
|
9181
9219
|
let t = {}, n = o && e.draftDataJson ? e.draftDataJson : e.dataJson;
|
|
9182
9220
|
try {
|
|
9183
9221
|
t = (typeof n == "string" ? JSON.parse(n) : n) || {};
|
|
9184
9222
|
} catch {}
|
|
9185
|
-
let i = !!e.isHidden || t.hidden === !0 || t.hidden === 1 || t.hidden === "1", a =
|
|
9223
|
+
let i = !!e.isHidden || t.hidden === !0 || t.hidden === 1 || t.hidden === "1", a = Li(t.startShowingAt, t.stopShowingAt), s = (e.slug || "").replace(/^\/+|\/+$/g, "");
|
|
9186
9224
|
return !o && (i || !a) ? null : {
|
|
9187
9225
|
treeNodeId: e.treeNodeId,
|
|
9188
9226
|
id: e.id,
|
|
@@ -9194,28 +9232,28 @@ Fi.get("/*", async (e) => {
|
|
|
9194
9232
|
};
|
|
9195
9233
|
}).filter(Boolean);
|
|
9196
9234
|
}
|
|
9197
|
-
x.children =
|
|
9198
|
-
let
|
|
9199
|
-
|
|
9200
|
-
let
|
|
9201
|
-
for (let e of
|
|
9235
|
+
x.children = se;
|
|
9236
|
+
let ce = +!!o, N = await t.prepare("\n SELECT * FROM content_blocks \n WHERE contentId = ? AND isDraft = ? \n ORDER BY sortOrder ASC\n ").all(h.id, ce), le = Array.isArray(N) ? N : N?.results || [];
|
|
9237
|
+
le.length === 0 && !o && (N = await t.prepare("\n SELECT * FROM content_blocks \n WHERE contentId = ?\n ORDER BY sortOrder ASC\n ").all(h.id), le = Array.isArray(N) ? N : N?.results || []);
|
|
9238
|
+
let P = {}, F = {};
|
|
9239
|
+
for (let e of le) {
|
|
9202
9240
|
let n = e.region || "main";
|
|
9203
|
-
|
|
9241
|
+
P[n] || (P[n] = [], F[n] = { isInherited: !1 });
|
|
9204
9242
|
let r = {};
|
|
9205
9243
|
try {
|
|
9206
9244
|
r = (typeof e.dataJson == "string" ? JSON.parse(e.dataJson) : e.dataJson) || {};
|
|
9207
9245
|
} catch {}
|
|
9208
|
-
let i = r.hidden === !0 || r.hidden === 1 || r.hidden === "1" || r.hidden === "true", a =
|
|
9246
|
+
let i = r.hidden === !0 || r.hidden === 1 || r.hidden === "1" || r.hidden === "true", a = Li(r.startShowingAt, r.stopShowingAt);
|
|
9209
9247
|
if (!o && (i || !a)) continue;
|
|
9210
|
-
let s = e.elementType || e.componentId || "text-block", c = p.blocks?.[s]?.fields || p.elements?.[s]?.fields || p.components?.[s]?.fields || {}, l = String(r.blockId || r._instanceId || r.id || e.blockId || e.id), u =
|
|
9211
|
-
u = await si(t, u), u =
|
|
9248
|
+
let s = e.elementType || e.componentId || "text-block", c = p.blocks?.[s]?.fields || p.elements?.[s]?.fields || p.components?.[s]?.fields || {}, l = String(r.blockId || r._instanceId || r.id || e.blockId || e.id), u = Vi(r, c);
|
|
9249
|
+
u = await si(t, u), u = Hi(u), u = await Ui(t, u), u.blockId = l, P[n].push({
|
|
9212
9250
|
instanceId: e.id,
|
|
9213
9251
|
blockId: l,
|
|
9214
9252
|
componentId: s,
|
|
9215
9253
|
data: u
|
|
9216
9254
|
});
|
|
9217
9255
|
}
|
|
9218
|
-
let
|
|
9256
|
+
let ue = {
|
|
9219
9257
|
header: {
|
|
9220
9258
|
label: "Header",
|
|
9221
9259
|
inherit: "parent"
|
|
@@ -9224,33 +9262,33 @@ Fi.get("/*", async (e) => {
|
|
|
9224
9262
|
label: "Footer",
|
|
9225
9263
|
inherit: "parent"
|
|
9226
9264
|
},
|
|
9227
|
-
...(
|
|
9265
|
+
...(re ? p.nodeLayouts?.[re] || p.layouts?.[re] : null)?.regions || { main: { label: "Content" } }
|
|
9228
9266
|
};
|
|
9229
|
-
for (let [e, n] of Object.entries(
|
|
9230
|
-
let r =
|
|
9231
|
-
if (
|
|
9232
|
-
let n = await
|
|
9233
|
-
if (n.blocks.length > 0 && (
|
|
9267
|
+
for (let [e, n] of Object.entries(ue)) {
|
|
9268
|
+
let r = P[e] && P[e].length > 0, i = !!T[e];
|
|
9269
|
+
if (P[e] || (P[e] = [], F[e] = { isInherited: !1 }), (n?.inherit === "parent" || n?.inherit === !0 || n?.inherit === "true" || e === "header" || e === "footer") && !r && !i && y) {
|
|
9270
|
+
let n = await Bi(t, y, e, p, o);
|
|
9271
|
+
if (n.blocks.length > 0 && (P[e] = n.blocks, F[e] = {
|
|
9234
9272
|
isInherited: !0,
|
|
9235
9273
|
inheritedFromId: n.inheritedFromId,
|
|
9236
9274
|
inheritedFromTitle: n.inheritedFromTitle
|
|
9237
|
-
}, n.subRegions)) for (let [t, r] of Object.entries(n.subRegions)) t !== e && (
|
|
9275
|
+
}, n.subRegions)) for (let [t, r] of Object.entries(n.subRegions)) t !== e && (P[t] = r, F[t] = {
|
|
9238
9276
|
isInherited: !0,
|
|
9239
9277
|
inheritedFromId: n.inheritedFromId,
|
|
9240
9278
|
inheritedFromTitle: n.inheritedFromTitle
|
|
9241
9279
|
});
|
|
9242
9280
|
}
|
|
9243
9281
|
}
|
|
9244
|
-
for (let e of Object.keys(
|
|
9245
|
-
let
|
|
9282
|
+
for (let e of Object.keys(P)) await zi(t, P[e], l);
|
|
9283
|
+
let de = {
|
|
9246
9284
|
channelId: l || u,
|
|
9247
9285
|
treeId: v,
|
|
9248
9286
|
language: x.language,
|
|
9249
9287
|
node: x,
|
|
9250
|
-
content:
|
|
9251
|
-
regionMeta:
|
|
9288
|
+
content: P,
|
|
9289
|
+
regionMeta: F
|
|
9252
9290
|
};
|
|
9253
|
-
return o || (await d.set(f,
|
|
9291
|
+
return o || (await d.set(f, de, 300), e.header("X-Cache", "MISS")), e.json(de);
|
|
9254
9292
|
} catch (t) {
|
|
9255
9293
|
return console.error("[CMS Public API] Error fetching node by path:", t), e.json({
|
|
9256
9294
|
error: "Failed to fetch JSON payload",
|
|
@@ -9260,8 +9298,8 @@ Fi.get("/*", async (e) => {
|
|
|
9260
9298
|
});
|
|
9261
9299
|
//#endregion
|
|
9262
9300
|
//#region server/routes/public/tree.ts
|
|
9263
|
-
var
|
|
9264
|
-
function
|
|
9301
|
+
var Ji = new e();
|
|
9302
|
+
function Yi(e, t) {
|
|
9265
9303
|
let n = /* @__PURE__ */ new Date();
|
|
9266
9304
|
if (e && String(e).trim() !== "") {
|
|
9267
9305
|
let t = new Date(e);
|
|
@@ -9273,7 +9311,7 @@ function Ji(e, t) {
|
|
|
9273
9311
|
}
|
|
9274
9312
|
return !0;
|
|
9275
9313
|
}
|
|
9276
|
-
|
|
9314
|
+
Ji.get("/:treeParam", async (e) => {
|
|
9277
9315
|
try {
|
|
9278
9316
|
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";
|
|
9279
9317
|
if (r && r !== "default" && r !== "all") {
|
|
@@ -9312,7 +9350,7 @@ qi.get("/:treeParam", async (e) => {
|
|
|
9312
9350
|
if (r) try {
|
|
9313
9351
|
n = typeof r == "string" ? JSON.parse(r) : r, delete n._isTreeDraft, delete n._draftParentId, delete n.isNew, delete n.hidden, delete n.is_hidden, delete n.isHidden, delete n.status;
|
|
9314
9352
|
} catch {}
|
|
9315
|
-
let a = !i && (e.status === "draft" || e.status === "new"), o = !!e.isHidden || a || n.hidden === !0 || n.hidden === 1 || n.hidden === "1" || n.hidden === "true", s =
|
|
9353
|
+
let a = !i && (e.status === "draft" || e.status === "new"), o = !!e.isHidden || a || n.hidden === !0 || n.hidden === 1 || n.hidden === "1" || n.hidden === "true", s = Yi(n.startShowingAt, n.stopShowingAt), c = (e.slug || "").replace(/^\/+|\/+$/g, ""), l = c === "home" || c === "homee" ? "/" : `${t}/${c}`.replace(/\/+/g, "/"), u = {
|
|
9316
9354
|
id: e.id,
|
|
9317
9355
|
treeNodeId: e.treeNodeId,
|
|
9318
9356
|
parentId: e.parentId || null,
|
|
@@ -9347,8 +9385,8 @@ qi.get("/:treeParam", async (e) => {
|
|
|
9347
9385
|
});
|
|
9348
9386
|
//#endregion
|
|
9349
9387
|
//#region server/routes/public/assets.ts
|
|
9350
|
-
var
|
|
9351
|
-
function
|
|
9388
|
+
var Xi = new e();
|
|
9389
|
+
function Zi(e, t) {
|
|
9352
9390
|
if (t === "webp") return "image/webp";
|
|
9353
9391
|
if (t === "avif") return "image/avif";
|
|
9354
9392
|
if (t === "jpeg" || t === "jpg") return "image/jpeg";
|
|
@@ -9356,7 +9394,7 @@ function Xi(e, t) {
|
|
|
9356
9394
|
let n = e.toLowerCase();
|
|
9357
9395
|
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";
|
|
9358
9396
|
}
|
|
9359
|
-
|
|
9397
|
+
Xi.get("/*", async (e) => {
|
|
9360
9398
|
let t = e.req.path.replace(/^\/media\//, "").replace(/^\//, "");
|
|
9361
9399
|
if (!t) return e.text("Asset key missing", 400);
|
|
9362
9400
|
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("Via")?.includes("image-resizing") || e.req.header("User-Agent")?.includes("Cloudflare-ImgRen");
|
|
@@ -9402,7 +9440,7 @@ Yi.get("/*", async (e) => {
|
|
|
9402
9440
|
if (!s) {
|
|
9403
9441
|
let n = u(g);
|
|
9404
9442
|
return e.body(n, 200, {
|
|
9405
|
-
"Content-Type":
|
|
9443
|
+
"Content-Type": Zi(t),
|
|
9406
9444
|
"Cache-Control": "public, max-age=86400"
|
|
9407
9445
|
});
|
|
9408
9446
|
}
|
|
@@ -9410,7 +9448,7 @@ Yi.get("/*", async (e) => {
|
|
|
9410
9448
|
if (l(b)) {
|
|
9411
9449
|
let n = u(b);
|
|
9412
9450
|
return e.body(n, 200, {
|
|
9413
|
-
"Content-Type":
|
|
9451
|
+
"Content-Type": Zi(t, v),
|
|
9414
9452
|
"Cache-Control": "public, max-age=31536000, immutable",
|
|
9415
9453
|
"X-Local-Cache": "HIT"
|
|
9416
9454
|
});
|
|
@@ -9423,14 +9461,14 @@ Yi.get("/*", async (e) => {
|
|
|
9423
9461
|
typeof n == "number" && (a.width = n), typeof c == "number" && (a.height = c), (a.width || a.height) && (a.fit = "cover", i = i.resize(a)), v === "webp" ? i = i.webp({ quality: typeof _ == "number" ? _ : 80 }) : v === "avif" ? i = i.avif({ quality: typeof _ == "number" ? _ : 70 }) : v === "jpeg" || v === "jpg" ? i = i.jpeg({ quality: typeof _ == "number" ? _ : 80 }) : v === "png" && (i = i.png({ quality: typeof _ == "number" ? _ : 80 }));
|
|
9424
9462
|
let o = await i.toBuffer();
|
|
9425
9463
|
return d(m(b), { recursive: !0 }), f(b, o), e.body(o, 200, {
|
|
9426
|
-
"Content-Type":
|
|
9464
|
+
"Content-Type": Zi(t, v),
|
|
9427
9465
|
"Cache-Control": "public, max-age=31536000, immutable",
|
|
9428
9466
|
"X-Local-Cache": "MISS"
|
|
9429
9467
|
});
|
|
9430
9468
|
} catch {
|
|
9431
9469
|
let n = u(g);
|
|
9432
9470
|
return e.body(n, 200, {
|
|
9433
|
-
"Content-Type":
|
|
9471
|
+
"Content-Type": Zi(t),
|
|
9434
9472
|
"Cache-Control": "public, max-age=86400"
|
|
9435
9473
|
});
|
|
9436
9474
|
}
|
|
@@ -9441,8 +9479,8 @@ Yi.get("/*", async (e) => {
|
|
|
9441
9479
|
});
|
|
9442
9480
|
//#endregion
|
|
9443
9481
|
//#region server/routes/public/paths.ts
|
|
9444
|
-
var
|
|
9445
|
-
function
|
|
9482
|
+
var Qi = new e();
|
|
9483
|
+
function $i(e, t) {
|
|
9446
9484
|
let n = /* @__PURE__ */ new Date();
|
|
9447
9485
|
if (e && String(e).trim() !== "") {
|
|
9448
9486
|
let t = new Date(e);
|
|
@@ -9454,7 +9492,7 @@ function Qi(e, t) {
|
|
|
9454
9492
|
}
|
|
9455
9493
|
return !0;
|
|
9456
9494
|
}
|
|
9457
|
-
|
|
9495
|
+
Qi.get("/", async (e) => {
|
|
9458
9496
|
try {
|
|
9459
9497
|
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 ").all(), n = Array.isArray(t) ? t : t?.results || [], r = [];
|
|
9460
9498
|
function i(e = null, t = "") {
|
|
@@ -9467,7 +9505,7 @@ Zi.get("/", async (e) => {
|
|
|
9467
9505
|
if (e.dataJson) try {
|
|
9468
9506
|
n = typeof e.dataJson == "string" ? JSON.parse(e.dataJson) : e.dataJson;
|
|
9469
9507
|
} catch {}
|
|
9470
|
-
let a = e.status === "published" || e.status === "active", o =
|
|
9508
|
+
let a = e.status === "published" || e.status === "active", o = $i(n.startShowingAt, n.stopShowingAt);
|
|
9471
9509
|
if (!a || !o) continue;
|
|
9472
9510
|
let s = (e.slug || "").replace(/^\/+|\/+$/g, ""), c = s === "home" || s === "homee" ? "/" : `${t}/${s}`.replace(/\/+/g, "/");
|
|
9473
9511
|
e.nodeType !== "external-link" && r.push(c);
|
|
@@ -9484,7 +9522,7 @@ Zi.get("/", async (e) => {
|
|
|
9484
9522
|
});
|
|
9485
9523
|
//#endregion
|
|
9486
9524
|
//#region server/index.ts
|
|
9487
|
-
var $ = new e(),
|
|
9525
|
+
var $ = new e(), ea = !1;
|
|
9488
9526
|
$.use("*", o()), $.use("/media/*", o({
|
|
9489
9527
|
origin: "*",
|
|
9490
9528
|
allowMethods: [
|
|
@@ -9505,13 +9543,13 @@ $.use("*", o()), $.use("/media/*", o({
|
|
|
9505
9543
|
let n = new URL(e.req.url), r = (e.req.header("host") || n.hostname).split(":")[0];
|
|
9506
9544
|
e.set("currentDomain", r);
|
|
9507
9545
|
let i = u(e);
|
|
9508
|
-
if (e.set("db", i),
|
|
9509
|
-
await Pr(i),
|
|
9546
|
+
if (e.set("db", i), !ea) try {
|
|
9547
|
+
await Pr(i), ea = !0;
|
|
9510
9548
|
} catch (e) {
|
|
9511
9549
|
console.error("❌ [CMS Server] Failed to initialize system tables on cold start:", e);
|
|
9512
9550
|
}
|
|
9513
9551
|
await t();
|
|
9514
|
-
}), $.route("/media",
|
|
9552
|
+
}), $.route("/media", Xi), $.use("/media/*", Lr()), $.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", Mi), $.route("/api/cms/stats.json", Mi), $.route("/api/cms", xi), $.route("/api/cms/channels", Ti), $.route("/api/cms/channels.json", Ti), $.route("/api/cms/schemas", Ei), $.route("/api/cms/schemas.json", Ei), $.route("/api/cms", ki), $.route("/api/admin/assets", Z), $.route("/api/v1/node", Ii), $.route("/api/v1/page", Ii), $.route("/api/v1/tree", Ji), $.route("/api/v1/all-paths", Qi), $.get("*", async (e) => {
|
|
9515
9553
|
if (e.env?.ASSETS) {
|
|
9516
9554
|
let t = await e.env.ASSETS.fetch(e.req.raw);
|
|
9517
9555
|
if (t.status === 404) {
|