@brightsideoy/kama 0.1.0-alpha.59 → 0.1.0-alpha.60
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-DYKhCc1h.js → index-DpvSN1ER.js} +1 -1
- package/dist/index.html +1 -1
- package/dist/index.js +472 -401
- 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"), ee = Symbol("skip children"), O = Symbol("remove node");
|
|
144
|
+
function k(e, t) {
|
|
145
|
+
let n = re(t);
|
|
146
|
+
y(e) ? A(null, e.contents, n, Object.freeze([e])) === O && (e.contents = null) : A(null, e, n, Object.freeze([]));
|
|
147
|
+
}
|
|
148
|
+
k.BREAK = D, k.SKIP = ee, k.REMOVE = O;
|
|
149
|
+
function A(e, t, n, r) {
|
|
150
|
+
let i = ie(e, t, n, r);
|
|
151
|
+
if (T(i) || x(i)) return j(e, r, i), A(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 = A(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 === O && (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 = A("key", t.key, n, r);
|
|
164
164
|
if (e === D) return D;
|
|
165
|
-
e ===
|
|
166
|
-
let i =
|
|
165
|
+
e === O && (t.key = null);
|
|
166
|
+
let i = A("value", t.value, n, r);
|
|
167
167
|
if (i === D) return D;
|
|
168
|
-
i ===
|
|
168
|
+
i === O && (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 te(e, t) {
|
|
174
|
+
let n = re(t);
|
|
175
|
+
y(e) ? await ne(null, e.contents, n, Object.freeze([e])) === O && (e.contents = null) : await ne(null, e, n, Object.freeze([]));
|
|
176
176
|
}
|
|
177
|
-
|
|
178
|
-
async function
|
|
179
|
-
let i = await
|
|
180
|
-
if (T(i) || x(i)) return
|
|
177
|
+
te.BREAK = D, te.SKIP = ee, te.REMOVE = O;
|
|
178
|
+
async function ne(e, t, n, r) {
|
|
179
|
+
let i = await ie(e, t, n, r);
|
|
180
|
+
if (T(i) || x(i)) return j(e, r, i), ne(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 ne(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 === O && (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 ne("key", t.key, n, r);
|
|
193
193
|
if (e === D) return D;
|
|
194
|
-
e ===
|
|
195
|
-
let i = await
|
|
194
|
+
e === O && (t.key = null);
|
|
195
|
+
let i = await ne("value", t.value, n, r);
|
|
196
196
|
if (i === D) return D;
|
|
197
|
-
i ===
|
|
197
|
+
i === O && (t.value = null);
|
|
198
198
|
}
|
|
199
199
|
}
|
|
200
200
|
return i;
|
|
201
201
|
}
|
|
202
|
-
function
|
|
202
|
+
function re(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 ne(e) {
|
|
|
214
214
|
Seq: e.Collection
|
|
215
215
|
}, e) : e;
|
|
216
216
|
}
|
|
217
|
-
function
|
|
217
|
+
function ie(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 re(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 j(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 M(e, t, n) {
|
|
|
234
234
|
}
|
|
235
235
|
//#endregion
|
|
236
236
|
//#region node_modules/yaml/browser/dist/doc/directives.js
|
|
237
|
-
var
|
|
237
|
+
var ae = {
|
|
238
238
|
"!": "%21",
|
|
239
239
|
",": "%2C",
|
|
240
240
|
"[": "%5B",
|
|
241
241
|
"]": "%5D",
|
|
242
242
|
"{": "%7B",
|
|
243
243
|
"}": "%7D"
|
|
244
|
-
},
|
|
244
|
+
}, oe = (e) => e.replace(/[!,[\]{}]/g, (e) => ae[e]), se = 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 ie = {
|
|
|
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 + oe(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
|
+
k(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 ie = {
|
|
|
319
319
|
return t.join("\n");
|
|
320
320
|
}
|
|
321
321
|
};
|
|
322
|
-
|
|
322
|
+
se.defaultYaml = {
|
|
323
323
|
explicit: !1,
|
|
324
324
|
version: "1.2"
|
|
325
|
-
},
|
|
325
|
+
}, se.defaultTags = { "!!": "tag:yaml.org,2002:" };
|
|
326
326
|
//#endregion
|
|
327
327
|
//#region node_modules/yaml/browser/dist/doc/anchors.js
|
|
328
|
-
function
|
|
328
|
+
function ce(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 le(e) {
|
|
336
336
|
let t = /* @__PURE__ */ new Set();
|
|
337
|
-
return
|
|
337
|
+
return k(e, { Value(e, n) {
|
|
338
338
|
n.anchor && t.add(n.anchor);
|
|
339
339
|
} }), t;
|
|
340
340
|
}
|
|
341
|
-
function
|
|
341
|
+
function M(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 ue(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 ??= le(e);
|
|
352
|
+
let a = M(t, i);
|
|
353
353
|
return i.add(a), a;
|
|
354
354
|
},
|
|
355
355
|
setAnchors: () => {
|
|
@@ -367,22 +367,22 @@ function le(e, t) {
|
|
|
367
367
|
}
|
|
368
368
|
//#endregion
|
|
369
369
|
//#region node_modules/yaml/browser/dist/doc/applyReviver.js
|
|
370
|
-
function
|
|
370
|
+
function N(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 = N(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 = N(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 = N(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 = N(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 P(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 P(e, t, n) {
|
|
394
|
+
if (Array.isArray(e)) return e.map((e, t) => P(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 F(e, t, n) {
|
|
|
409
409
|
}
|
|
410
410
|
//#endregion
|
|
411
411
|
//#region node_modules/yaml/browser/dist/nodes/Node.js
|
|
412
|
-
var
|
|
412
|
+
var de = class {
|
|
413
413
|
constructor(e) {
|
|
414
414
|
Object.defineProperty(this, _, { value: e });
|
|
415
415
|
}
|
|
@@ -426,11 +426,11 @@ var ue = class {
|
|
|
426
426
|
mapAsMap: t === !0,
|
|
427
427
|
mapKeyWarned: !1,
|
|
428
428
|
maxAliasCount: typeof n == "number" ? n : 100
|
|
429
|
-
}, o =
|
|
429
|
+
}, o = P(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" ? N(i, { "": o }, "", o) : o;
|
|
432
432
|
}
|
|
433
|
-
},
|
|
433
|
+
}, fe = class extends de {
|
|
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 ue = 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 = [], k(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 ue = 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 ||= (P(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 = pe(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 (ce(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 ue = class {
|
|
|
474
474
|
return r;
|
|
475
475
|
}
|
|
476
476
|
};
|
|
477
|
-
function
|
|
477
|
+
function pe(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 fe(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 = pe(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 = pe(e, t.key, n), i = pe(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 me = (e) => !e || typeof e != "function" && typeof e != "object", F = class extends de {
|
|
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 : P(this.value, e, t);
|
|
504
504
|
}
|
|
505
505
|
toString() {
|
|
506
506
|
return String(this.value);
|
|
507
507
|
}
|
|
508
508
|
};
|
|
509
|
-
|
|
509
|
+
F.BLOCK_FOLDED = "BLOCK_FOLDED", F.BLOCK_LITERAL = "BLOCK_LITERAL", F.PLAIN = "PLAIN", F.QUOTE_DOUBLE = "QUOTE_DOUBLE", F.QUOTE_SINGLE = "QUOTE_SINGLE";
|
|
510
510
|
//#endregion
|
|
511
511
|
//#region node_modules/yaml/browser/dist/doc/createNode.js
|
|
512
|
-
var
|
|
513
|
-
function
|
|
512
|
+
var he = "tag:yaml.org,2002:";
|
|
513
|
+
function ge(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 he(e, t, n) {
|
|
|
518
518
|
}
|
|
519
519
|
return n.find((t) => t.identify?.(e) && !t.format);
|
|
520
520
|
}
|
|
521
|
-
function
|
|
521
|
+
function _e(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 ge(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 fe(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 = he + t.slice(2));
|
|
537
|
+
let l = ge(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 F(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 F(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 ve(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 _e(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 _e(r, void 0, {
|
|
561
561
|
aliasDuplicateObjects: !1,
|
|
562
562
|
keepUndefined: !1,
|
|
563
563
|
onAnchor: () => {
|
|
@@ -567,7 +567,7 @@ function _e(e, t, n) {
|
|
|
567
567
|
sourceObjects: /* @__PURE__ */ new Map()
|
|
568
568
|
});
|
|
569
569
|
}
|
|
570
|
-
var
|
|
570
|
+
var ye = (e) => e == null || typeof e == "object" && !!e[Symbol.iterator]().next().done, be = class extends de {
|
|
571
571
|
constructor(e, t) {
|
|
572
572
|
super(e), Object.defineProperty(this, "schema", {
|
|
573
573
|
value: t,
|
|
@@ -581,11 +581,11 @@ var ve = (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 (ye(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, ve(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 ve = (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, ve(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
|
+
}, xe = (e) => e.replace(/^(?!$)(?: $)?/gm, "#");
|
|
627
|
+
function I(e, t) {
|
|
628
628
|
return /^\n+$/.test(e) ? e.substring(1) : t ? e.replace(/^(?! *$)/gm, t) : e;
|
|
629
629
|
}
|
|
630
|
-
var
|
|
630
|
+
var L = (e, t, n) => e.endsWith("\n") ? I(n, t) : n.includes("\n") ? "\n" + I(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 === F.BLOCK_FOLDED ? !1 : t === F.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 !== F.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 !== F.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 !== F.QUOTE_DOUBLE && /[\x00-\x08\x0b-\x1f\x7f-\x9f\u{D800}-\u{DFFF}]/u.test(o.value) && (s = F.QUOTE_DOUBLE);
|
|
832
832
|
let c = (e) => {
|
|
833
833
|
switch (e) {
|
|
834
|
-
case
|
|
835
|
-
case
|
|
836
|
-
case
|
|
837
|
-
case
|
|
838
|
-
case
|
|
834
|
+
case F.BLOCK_FOLDED:
|
|
835
|
+
case F.BLOCK_LITERAL: return i || a ? Me(o.value, t) : Pe(o, t, n, r);
|
|
836
|
+
case F.QUOTE_DOUBLE: return Ae(o.value, t);
|
|
837
|
+
case F.QUOTE_SINGLE: return je(o.value, t);
|
|
838
|
+
case F.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: xe,
|
|
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 && ce(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 === F.BLOCK_FOLDED || e.type === F.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 += L(g, n.indent, l(f)) : h && i && i(), g;
|
|
954
|
+
m && (f = null), p ? (f && (g += L(g, n.indent, l(f))), g = `? ${g}\n${s}:`) : (g = `${g}:`, f && (g += L(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${I(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 += L(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 F(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 === F.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 = P(n, "", e);
|
|
1020
|
+
if (t instanceof Map) t.set(i, P(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 = P(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(_e(e, void 0, n), _e(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 += L(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" + I(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 += L(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 = I(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 be {
|
|
1150
1150
|
static get tagName() {
|
|
1151
1151
|
return "tag:yaml.org,2002:map";
|
|
1152
1152
|
}
|
|
@@ -1169,7 +1169,7 @@ var B = class extends ye {
|
|
|
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) && me(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 ye {
|
|
|
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 be {
|
|
1222
1222
|
static get tagName() {
|
|
1223
1223
|
return "tag:yaml.org,2002:seq";
|
|
1224
1224
|
}
|
|
@@ -1246,13 +1246,13 @@ var B = class extends ye {
|
|
|
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) && me(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(P(e, String(r++), t));
|
|
1256
1256
|
return n;
|
|
1257
1257
|
}
|
|
1258
1258
|
toString(e, t, n) {
|
|
@@ -1276,7 +1276,7 @@ var B = class extends ye {
|
|
|
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(_e(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 F(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 F(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 F(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 F(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 F(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 ??= F.BLOCK_LITERAL, t !== F.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 === F.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 F(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 = P(e.key, "", t), i = P(e.value, r, t)) : r = P(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 F(!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 F(!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 F(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(I(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(I(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 += L(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(I(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(I(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 se({ 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 = le(this);
|
|
1944
|
+
e.anchor = !t || n.has(t) ? M(t || "a", n) : t;
|
|
1945
1945
|
}
|
|
1946
|
-
return new
|
|
1946
|
+
return new fe(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 } = ue(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 = _e(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 ye(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 ye(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 ye(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 = ve(this.schema, [e], t) : rn(this.contents) && this.contents.set(e, t);
|
|
1989
1989
|
}
|
|
1990
1990
|
setIn(e, t) {
|
|
1991
|
-
|
|
1991
|
+
ye(e) ? this.contents = t : this.contents == null ? this.contents = ve(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 se({ 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 se({ 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 = P(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" ? N(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 F(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 === ">" ? F.BLOCK_FOLDED : F.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 === F.BLOCK_LITERAL ? (d += f + t.slice(c) + r, f = "\n") : t.length > c || r[0] === " " ? (f === " " ? f = "\n" : !p && f === "\n" && (f = "\n\n"), d += f + t.slice(c) + r, f = "\n", p = !0) : r === "" ? f === "\n" ? d += "\n" : f = "\n" : (d += f + r, f = " ", p = !1);
|
|
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 = F.PLAIN, c = En(a, l);
|
|
2556
2556
|
break;
|
|
2557
2557
|
case "single-quoted-scalar":
|
|
2558
|
-
s =
|
|
2558
|
+
s = F.QUOTE_SINGLE, c = Dn(a, l);
|
|
2559
2559
|
break;
|
|
2560
2560
|
case "double-quoted-scalar":
|
|
2561
|
-
s =
|
|
2561
|
+
s = F.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 F(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 F(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 fe(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 se({ 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: () => fe,
|
|
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: () => F,
|
|
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: () => k,
|
|
4398
|
+
visitAsync: () => te
|
|
4399
4399
|
}), Ar = {
|
|
4400
4400
|
rawNodes: {
|
|
4401
4401
|
address: {
|
|
@@ -6930,23 +6930,23 @@ async function ai(e, t, n) {
|
|
|
6930
6930
|
}
|
|
6931
6931
|
//#endregion
|
|
6932
6932
|
//#region server/utils/asset-hydrator.ts
|
|
6933
|
-
function
|
|
6933
|
+
function oi(e) {
|
|
6934
6934
|
if (!e) return null;
|
|
6935
6935
|
if (typeof e == "string" && e.startsWith("ast_")) return e;
|
|
6936
6936
|
if (typeof e == "object" && e) {
|
|
6937
6937
|
if (typeof e.id == "string" && e.id.startsWith("ast_")) return e.id;
|
|
6938
|
-
if (typeof e.id == "object") return
|
|
6938
|
+
if (typeof e.id == "object") return oi(e.id);
|
|
6939
6939
|
}
|
|
6940
6940
|
return null;
|
|
6941
6941
|
}
|
|
6942
|
-
async function
|
|
6942
|
+
async function si(e, t) {
|
|
6943
6943
|
if (!t || typeof t != "object") return t;
|
|
6944
6944
|
let n = /* @__PURE__ */ new Set(), r = (e) => {
|
|
6945
6945
|
if (!e) return;
|
|
6946
|
-
let t =
|
|
6946
|
+
let t = oi(e);
|
|
6947
6947
|
if (t) {
|
|
6948
6948
|
if (n.add(t), typeof e == "object" && e.parentAssetId) {
|
|
6949
|
-
let t =
|
|
6949
|
+
let t = oi(e.parentAssetId);
|
|
6950
6950
|
t && n.add(t);
|
|
6951
6951
|
}
|
|
6952
6952
|
} else Array.isArray(e) ? e.forEach(r) : typeof e == "object" && Object.values(e).forEach(r);
|
|
@@ -6975,7 +6975,7 @@ async function oi(e, t) {
|
|
|
6975
6975
|
AND (parentAssetId IN (${i}) OR ${Array.from(n).map(() => "filename LIKE ?").join(" OR ")})
|
|
6976
6976
|
`).all(...Array.from(n), ...Array.from(n).map((e) => `%${e}%`)), c = Array.isArray(s) ? s : s?.results || [], l = /* @__PURE__ */ new Map();
|
|
6977
6977
|
for (let e of c) {
|
|
6978
|
-
let t =
|
|
6978
|
+
let t = oi(e.parentAssetId) || Array.from(n).find((t) => e.filename.includes(t));
|
|
6979
6979
|
if (!t) continue;
|
|
6980
6980
|
let r = e.filename.match(/^crop_([a-z0-9]+)_/i), i = r ? r[1] : "standard", a = null;
|
|
6981
6981
|
if (e.cropCoordinatesJson) try {
|
|
@@ -7010,7 +7010,7 @@ async function oi(e, t) {
|
|
|
7010
7010
|
id: e.id,
|
|
7011
7011
|
url: t,
|
|
7012
7012
|
originalUrl: n,
|
|
7013
|
-
parentAssetId:
|
|
7013
|
+
parentAssetId: oi(e.parentAssetId) || null,
|
|
7014
7014
|
cropCoordinates: r,
|
|
7015
7015
|
variants: i && Object.keys(i).length > 0 ? i : void 0,
|
|
7016
7016
|
filename: e.filename,
|
|
@@ -7022,7 +7022,7 @@ async function oi(e, t) {
|
|
|
7022
7022
|
}
|
|
7023
7023
|
let d = (e) => {
|
|
7024
7024
|
if (!e) return e;
|
|
7025
|
-
let t =
|
|
7025
|
+
let t = oi(e);
|
|
7026
7026
|
if (t) {
|
|
7027
7027
|
let n = u.get(t) || {
|
|
7028
7028
|
id: t,
|
|
@@ -7032,7 +7032,7 @@ async function oi(e, t) {
|
|
|
7032
7032
|
return {
|
|
7033
7033
|
...n,
|
|
7034
7034
|
id: t,
|
|
7035
|
-
parentAssetId: n.parentAssetId ?
|
|
7035
|
+
parentAssetId: n.parentAssetId ? oi(n.parentAssetId) : null,
|
|
7036
7036
|
url: typeof e == "object" && e.url && !e.url.startsWith("blob:") ? e.url : n.url,
|
|
7037
7037
|
originalUrl: typeof e == "object" && e.originalUrl && !e.originalUrl.startsWith("blob:") ? e.originalUrl : n.originalUrl,
|
|
7038
7038
|
cropCoordinates: i || n.cropCoordinates || null,
|
|
@@ -7052,7 +7052,7 @@ async function oi(e, t) {
|
|
|
7052
7052
|
}
|
|
7053
7053
|
//#endregion
|
|
7054
7054
|
//#region src/schemas/definitions.ts
|
|
7055
|
-
function
|
|
7055
|
+
function J(e = {}, t = {}) {
|
|
7056
7056
|
let n = {
|
|
7057
7057
|
...e,
|
|
7058
7058
|
...t
|
|
@@ -7070,7 +7070,7 @@ function Y(e = {}, t = {}) {
|
|
|
7070
7070
|
...t.rules || {}
|
|
7071
7071
|
}, n;
|
|
7072
7072
|
}
|
|
7073
|
-
function
|
|
7073
|
+
function ci() {
|
|
7074
7074
|
if (typeof process > "u" || !process?.versions?.node) return null;
|
|
7075
7075
|
try {
|
|
7076
7076
|
let e = (e) => {
|
|
@@ -7137,12 +7137,12 @@ function si() {
|
|
|
7137
7137
|
return null;
|
|
7138
7138
|
}
|
|
7139
7139
|
}
|
|
7140
|
-
function ci(e) {
|
|
7141
|
-
if (e && (Object.keys(e.rawNodes || {}).length > 0 || Object.keys(e.nodes || {}).length > 0)) return li(e);
|
|
7142
|
-
let t = si();
|
|
7143
|
-
return t && Object.keys(t.rawNodes).length > 0 ? li(t) : li(null);
|
|
7144
|
-
}
|
|
7145
7140
|
function li(e) {
|
|
7141
|
+
if (e && (Object.keys(e.rawNodes || {}).length > 0 || Object.keys(e.nodes || {}).length > 0)) return ui(e);
|
|
7142
|
+
let t = ci();
|
|
7143
|
+
return t && Object.keys(t.rawNodes).length > 0 ? ui(t) : ui(null);
|
|
7144
|
+
}
|
|
7145
|
+
function ui(e) {
|
|
7146
7146
|
if (!e) return {
|
|
7147
7147
|
nodes: {},
|
|
7148
7148
|
trees: {},
|
|
@@ -7162,7 +7162,7 @@ function li(e) {
|
|
|
7162
7162
|
let i = {};
|
|
7163
7163
|
if (!Array.isArray(e)) return typeof e == "object" && e ? (Object.entries(e).forEach(([e, t]) => {
|
|
7164
7164
|
let n = i[e] || m[e] || {};
|
|
7165
|
-
i[e] =
|
|
7165
|
+
i[e] = J(n, t);
|
|
7166
7166
|
}), i) : {};
|
|
7167
7167
|
let a = (e) => {
|
|
7168
7168
|
let a = h[e] || h[`${e}-base`] || {};
|
|
@@ -7175,11 +7175,11 @@ function li(e) {
|
|
|
7175
7175
|
fields: {}
|
|
7176
7176
|
}), Object.entries(s).forEach(([e, r]) => {
|
|
7177
7177
|
let i = n[t].fields[e] || {};
|
|
7178
|
-
n[t].fields[e] =
|
|
7178
|
+
n[t].fields[e] = J(i, r);
|
|
7179
7179
|
});
|
|
7180
7180
|
} else Object.entries(s).forEach(([e, t]) => {
|
|
7181
7181
|
let n = i[e] || {};
|
|
7182
|
-
i[e] =
|
|
7182
|
+
i[e] = J(n, t);
|
|
7183
7183
|
});
|
|
7184
7184
|
};
|
|
7185
7185
|
return e.forEach((e) => {
|
|
@@ -7187,7 +7187,7 @@ function li(e) {
|
|
|
7187
7187
|
if (e.startsWith("fieldSet:")) a(e.replace("fieldSet:", "").trim());
|
|
7188
7188
|
else {
|
|
7189
7189
|
let t = i[e] || m[e] || {};
|
|
7190
|
-
i[e] =
|
|
7190
|
+
i[e] = J(t, {
|
|
7191
7191
|
type: "text",
|
|
7192
7192
|
label: e
|
|
7193
7193
|
});
|
|
@@ -7197,7 +7197,7 @@ function li(e) {
|
|
|
7197
7197
|
if (t === "fieldSet") a(String(n));
|
|
7198
7198
|
else {
|
|
7199
7199
|
let e = i[t] || m[t] || {};
|
|
7200
|
-
i[t] =
|
|
7200
|
+
i[t] = J(e, typeof n == "object" && n ? n : {});
|
|
7201
7201
|
}
|
|
7202
7202
|
}
|
|
7203
7203
|
}), i;
|
|
@@ -7215,7 +7215,7 @@ function li(e) {
|
|
|
7215
7215
|
let s = g(i.fields || i, a, n, t);
|
|
7216
7216
|
Object.entries(s).forEach(([e, t]) => {
|
|
7217
7217
|
let r = n[a].fields[e] || {};
|
|
7218
|
-
n[a].fields[e] =
|
|
7218
|
+
n[a].fields[e] = J(r, t);
|
|
7219
7219
|
});
|
|
7220
7220
|
}
|
|
7221
7221
|
}), n) : (Object.entries(e).forEach(([e, r]) => {
|
|
@@ -7227,7 +7227,7 @@ function li(e) {
|
|
|
7227
7227
|
let o = g(a, e, n, t);
|
|
7228
7228
|
Object.entries(o).forEach(([t, r]) => {
|
|
7229
7229
|
let i = n[e].fields[t] || {};
|
|
7230
|
-
n[e].fields[t] =
|
|
7230
|
+
n[e].fields[t] = J(i, r);
|
|
7231
7231
|
});
|
|
7232
7232
|
}), n);
|
|
7233
7233
|
}, v = {};
|
|
@@ -7245,16 +7245,16 @@ function li(e) {
|
|
|
7245
7245
|
fields: {}
|
|
7246
7246
|
}), Object.entries(o).forEach(([e, r]) => {
|
|
7247
7247
|
let i = n[t].fields[e] || {};
|
|
7248
|
-
n[t].fields[e] =
|
|
7248
|
+
n[t].fields[e] = J(i, r);
|
|
7249
7249
|
});
|
|
7250
7250
|
} else Object.entries(o).forEach(([e, t]) => {
|
|
7251
7251
|
let n = r[e] || m[e] || {};
|
|
7252
|
-
r[e] =
|
|
7252
|
+
r[e] = J(n, t);
|
|
7253
7253
|
});
|
|
7254
7254
|
}), Object.values(n).forEach((e) => {
|
|
7255
7255
|
Object.entries(e.fields).forEach(([e, t]) => {
|
|
7256
7256
|
let n = r[e] || {};
|
|
7257
|
-
r[e] =
|
|
7257
|
+
r[e] = J(n, t);
|
|
7258
7258
|
});
|
|
7259
7259
|
}), Object.keys(n).length === 0 && Object.keys(r).length > 0 && (n.settings = {
|
|
7260
7260
|
label: t.label || "Settings",
|
|
@@ -7277,11 +7277,11 @@ function li(e) {
|
|
|
7277
7277
|
Array.isArray(t.fieldSets) && t.fieldSets.forEach((e) => {
|
|
7278
7278
|
let t = h[e] || {}, i = t.fields || t, a = g(i, "settings", n);
|
|
7279
7279
|
Object.entries(a).forEach(([e, t]) => {
|
|
7280
|
-
r[e] =
|
|
7280
|
+
r[e] = J(r[e] || {}, t);
|
|
7281
7281
|
});
|
|
7282
7282
|
}), Object.values(n).forEach((e) => {
|
|
7283
7283
|
Object.entries(e.fields).forEach(([e, t]) => {
|
|
7284
|
-
r[e] =
|
|
7284
|
+
r[e] = J(r[e] || {}, t);
|
|
7285
7285
|
});
|
|
7286
7286
|
}), y[e] = {
|
|
7287
7287
|
...t,
|
|
@@ -7300,7 +7300,7 @@ function li(e) {
|
|
|
7300
7300
|
Array.isArray(t.fieldSets) && t.fieldSets.forEach((e) => {
|
|
7301
7301
|
let t = h[e] || {}, r = t.fields || t, i = g(r);
|
|
7302
7302
|
Object.entries(i).forEach(([e, t]) => {
|
|
7303
|
-
n[e] =
|
|
7303
|
+
n[e] = J(n[e] || {}, t);
|
|
7304
7304
|
});
|
|
7305
7305
|
}), b[e] = {
|
|
7306
7306
|
...t,
|
|
@@ -7349,7 +7349,7 @@ function li(e) {
|
|
|
7349
7349
|
Array.isArray(f?.fieldSets) && f?.fieldSets.forEach((e) => {
|
|
7350
7350
|
let t = h[e] || {}, n = t.fields || t, r = g(n);
|
|
7351
7351
|
Object.entries(r).forEach(([e, t]) => {
|
|
7352
|
-
T[e] =
|
|
7352
|
+
T[e] = J(T[e] || {}, t);
|
|
7353
7353
|
});
|
|
7354
7354
|
});
|
|
7355
7355
|
let E = f ? {
|
|
@@ -7359,10 +7359,10 @@ function li(e) {
|
|
|
7359
7359
|
Array.isArray(p?.fieldSets) && p?.fieldSets.forEach((e) => {
|
|
7360
7360
|
let t = h[e] || {}, n = t.fields || t, r = g(n);
|
|
7361
7361
|
Object.entries(r).forEach(([e, t]) => {
|
|
7362
|
-
D[e] =
|
|
7362
|
+
D[e] = J(D[e] || {}, t);
|
|
7363
7363
|
});
|
|
7364
7364
|
});
|
|
7365
|
-
let
|
|
7365
|
+
let ee = p ? {
|
|
7366
7366
|
...p,
|
|
7367
7367
|
fields: D
|
|
7368
7368
|
} : null;
|
|
@@ -7376,13 +7376,102 @@ function li(e) {
|
|
|
7376
7376
|
nodeTemplate: u || null,
|
|
7377
7377
|
treeTemplate: d || null,
|
|
7378
7378
|
channelTemplate: E,
|
|
7379
|
-
userTemplate:
|
|
7379
|
+
userTemplate: ee
|
|
7380
7380
|
};
|
|
7381
7381
|
}
|
|
7382
7382
|
//#endregion
|
|
7383
|
-
//#region server/
|
|
7384
|
-
var
|
|
7385
|
-
|
|
7383
|
+
//#region server/services/cache-manager.ts
|
|
7384
|
+
var Y = class {
|
|
7385
|
+
zoneId;
|
|
7386
|
+
apiToken;
|
|
7387
|
+
frontendUrl;
|
|
7388
|
+
constructor(e) {
|
|
7389
|
+
this.zoneId = e.CLOUDFLARE_ZONE_ID, this.apiToken = e.CLOUDFLARE_API_TOKEN, this.frontendUrl = (e.PUBLIC_FRONTEND_URL || "https://kama.t3cloud.eu").replace(/\/+$/, "");
|
|
7390
|
+
}
|
|
7391
|
+
dispatch(e, t) {
|
|
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
|
+
}
|
|
7394
|
+
purgeAndWarmSlug(e, t) {
|
|
7395
|
+
let n = (async () => {
|
|
7396
|
+
try {
|
|
7397
|
+
let e = t.replace(/^\/+|\/+$/g, ""), n = e === "home" || !e ? this.frontendUrl : `${this.frontendUrl}/${e}`, r = [n, `${n}/`];
|
|
7398
|
+
console.log(`[CacheManager] Purging edge cache for: ${r.join(", ")}`);
|
|
7399
|
+
let i = await fetch(`https://api.cloudflare.com/client/v4/zones/${this.zoneId}/purge_cache`, {
|
|
7400
|
+
method: "POST",
|
|
7401
|
+
headers: {
|
|
7402
|
+
Authorization: `Bearer ${this.apiToken}`,
|
|
7403
|
+
"Content-Type": "application/json"
|
|
7404
|
+
},
|
|
7405
|
+
body: JSON.stringify({ files: r })
|
|
7406
|
+
});
|
|
7407
|
+
if (!i.ok) {
|
|
7408
|
+
console.error(`[CacheManager] Purge failed: ${await i.text()}`);
|
|
7409
|
+
return;
|
|
7410
|
+
}
|
|
7411
|
+
fetch(n, { headers: { "X-Cache-Warmer": "true" } }).catch(() => {});
|
|
7412
|
+
} catch (e) {
|
|
7413
|
+
console.error("[CacheManager] Critical error during slug purge:", e);
|
|
7414
|
+
}
|
|
7415
|
+
})();
|
|
7416
|
+
this.dispatch(e, n);
|
|
7417
|
+
}
|
|
7418
|
+
purgeGlobalCache(e) {
|
|
7419
|
+
let t = (async () => {
|
|
7420
|
+
try {
|
|
7421
|
+
console.log("[CacheManager] Purging ENTIRE edge cache.");
|
|
7422
|
+
let e = await fetch(`https://api.cloudflare.com/client/v4/zones/${this.zoneId}/purge_cache`, {
|
|
7423
|
+
method: "POST",
|
|
7424
|
+
headers: {
|
|
7425
|
+
Authorization: `Bearer ${this.apiToken}`,
|
|
7426
|
+
"Content-Type": "application/json"
|
|
7427
|
+
},
|
|
7428
|
+
body: JSON.stringify({ purge_everything: !0 })
|
|
7429
|
+
});
|
|
7430
|
+
if (!e.ok) {
|
|
7431
|
+
console.error(`[CacheManager] Global purge failed: ${await e.text()}`);
|
|
7432
|
+
return;
|
|
7433
|
+
}
|
|
7434
|
+
fetch(this.frontendUrl, { headers: { "X-Cache-Warmer": "true" } }).catch(() => {});
|
|
7435
|
+
} catch (e) {
|
|
7436
|
+
console.error("[CacheManager] Critical error during global purge:", e);
|
|
7437
|
+
}
|
|
7438
|
+
})();
|
|
7439
|
+
this.dispatch(e, t);
|
|
7440
|
+
}
|
|
7441
|
+
purgeSmart(e, t, n, r) {
|
|
7442
|
+
let i = (async () => {
|
|
7443
|
+
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));
|
|
7445
|
+
})();
|
|
7446
|
+
this.dispatch(e, i);
|
|
7447
|
+
}
|
|
7448
|
+
async purgeGlobalCacheDirect() {
|
|
7449
|
+
try {
|
|
7450
|
+
await fetch(`https://api.cloudflare.com/client/v4/zones/${this.zoneId}/purge_cache`, {
|
|
7451
|
+
method: "POST",
|
|
7452
|
+
headers: {
|
|
7453
|
+
Authorization: `Bearer ${this.apiToken}`,
|
|
7454
|
+
"Content-Type": "application/json"
|
|
7455
|
+
},
|
|
7456
|
+
body: JSON.stringify({ purge_everything: !0 })
|
|
7457
|
+
}), fetch(this.frontendUrl, { headers: { "X-Cache-Warmer": "true" } }).catch(() => {});
|
|
7458
|
+
} catch {}
|
|
7459
|
+
}
|
|
7460
|
+
async purgeAndWarmSlugDirect(e) {
|
|
7461
|
+
try {
|
|
7462
|
+
let t = e.replace(/^\/+|\/+$/g, ""), n = t === "home" || !t ? this.frontendUrl : `${this.frontendUrl}/${t}`;
|
|
7463
|
+
await fetch(`https://api.cloudflare.com/client/v4/zones/${this.zoneId}/purge_cache`, {
|
|
7464
|
+
method: "POST",
|
|
7465
|
+
headers: {
|
|
7466
|
+
Authorization: `Bearer ${this.apiToken}`,
|
|
7467
|
+
"Content-Type": "application/json"
|
|
7468
|
+
},
|
|
7469
|
+
body: JSON.stringify({ files: [n, `${n}/`] })
|
|
7470
|
+
}), fetch(n, { headers: { "X-Cache-Warmer": "true" } }).catch(() => {});
|
|
7471
|
+
} catch {}
|
|
7472
|
+
}
|
|
7473
|
+
}, X = new e();
|
|
7474
|
+
async function di(e, t, n = []) {
|
|
7386
7475
|
let r = e.prepare(t);
|
|
7387
7476
|
if (typeof r.bind == "function") {
|
|
7388
7477
|
let e = await r.bind(...n).all();
|
|
@@ -7394,23 +7483,23 @@ async function ui(e, t, n = []) {
|
|
|
7394
7483
|
}
|
|
7395
7484
|
return [];
|
|
7396
7485
|
}
|
|
7397
|
-
async function
|
|
7486
|
+
async function fi(e, t, n = []) {
|
|
7398
7487
|
let r = e.prepare(t);
|
|
7399
7488
|
if (typeof r.bind == "function") return r.bind(...n).run();
|
|
7400
7489
|
if (typeof r.run == "function") return r.run(...n);
|
|
7401
7490
|
}
|
|
7402
|
-
function
|
|
7491
|
+
function pi(e) {
|
|
7403
7492
|
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;
|
|
7404
7493
|
}
|
|
7405
|
-
function
|
|
7494
|
+
function mi(e) {
|
|
7406
7495
|
return +(e === !0 || e === 1 || e === "1" || e === "true");
|
|
7407
7496
|
}
|
|
7408
|
-
function
|
|
7497
|
+
function hi(e) {
|
|
7409
7498
|
if (e == null || e === "null" || e === "" || typeof e == "string" && e.startsWith("draft-")) return null;
|
|
7410
7499
|
let t = Number(e);
|
|
7411
7500
|
return isNaN(t) ? null : t;
|
|
7412
7501
|
}
|
|
7413
|
-
function
|
|
7502
|
+
function gi(e) {
|
|
7414
7503
|
let t = { ...e };
|
|
7415
7504
|
for (let e of [
|
|
7416
7505
|
"id",
|
|
@@ -7439,17 +7528,17 @@ function hi(e) {
|
|
|
7439
7528
|
]) delete t[e];
|
|
7440
7529
|
return t;
|
|
7441
7530
|
}
|
|
7442
|
-
function
|
|
7443
|
-
return e ? typeof e == "string" ? (e.startsWith("ast_") && t.add(e), t) : Array.isArray(e) ? (e.forEach((e) =>
|
|
7531
|
+
function _i(e, t = /* @__PURE__ */ new Set()) {
|
|
7532
|
+
return e ? typeof e == "string" ? (e.startsWith("ast_") && t.add(e), t) : Array.isArray(e) ? (e.forEach((e) => _i(e, t)), t) : (typeof e == "object" && Object.values(e).forEach((e) => _i(e, t)), t) : t;
|
|
7444
7533
|
}
|
|
7445
|
-
async function
|
|
7534
|
+
async function vi(e, t, n) {
|
|
7446
7535
|
for (let r of n) {
|
|
7447
|
-
let n = (await
|
|
7448
|
-
if (!n || (await
|
|
7536
|
+
let n = (await di(e, "\n SELECT id, storageKeyPrivate, isSystemVariant, parentAssetId, filename\n FROM assets WHERE id = ?\n ", [r]))[0];
|
|
7537
|
+
if (!n || (await di(e, "SELECT 1 FROM node_assets WHERE assetId = ? LIMIT 1", [n.id])).length > 0) continue;
|
|
7449
7538
|
let i = [n];
|
|
7450
7539
|
if (!n.isSystemVariant) {
|
|
7451
|
-
let t = await
|
|
7452
|
-
if (r.length > 0 && (await
|
|
7540
|
+
let t = await di(e, "\n SELECT id, storageKeyPrivate, isSystemVariant, parentAssetId, filename\n FROM assets\n WHERE parentAssetId = ? OR (isSystemVariant = 1 AND filename LIKE ?)\n ", [n.id, `crop_%${String(n.filename || "").replace(/\.[^/.]+$/, "")}%`]), r = t.map((e) => e.id);
|
|
7541
|
+
if (r.length > 0 && (await di(e, `SELECT DISTINCT assetId FROM node_assets WHERE assetId IN (${r.map(() => "?").join(",")})`, r)).length > 0) continue;
|
|
7453
7542
|
i = [n, ...t];
|
|
7454
7543
|
}
|
|
7455
7544
|
for (let e of i) if (e.storageKeyPrivate) try {
|
|
@@ -7458,10 +7547,10 @@ async function _i(e, t, n) {
|
|
|
7458
7547
|
console.warn(`[Asset Cleanup] Failed to delete ${e.storageKeyPrivate}:`, t);
|
|
7459
7548
|
}
|
|
7460
7549
|
let a = i.map((e) => e.id), o = a.map(() => "?").join(",");
|
|
7461
|
-
await
|
|
7550
|
+
await fi(e, `DELETE FROM node_assets WHERE assetId IN (${o})`, a), await fi(e, `DELETE FROM assets WHERE id IN (${o})`, a);
|
|
7462
7551
|
}
|
|
7463
7552
|
}
|
|
7464
|
-
async function
|
|
7553
|
+
async function yi(e, t, n) {
|
|
7465
7554
|
let r = {}, i = null;
|
|
7466
7555
|
if (t) {
|
|
7467
7556
|
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 || [];
|
|
@@ -7486,33 +7575,6 @@ async function vi(e, t, n) {
|
|
|
7486
7575
|
inheritedFields: r
|
|
7487
7576
|
};
|
|
7488
7577
|
}
|
|
7489
|
-
async function yi(e, t) {
|
|
7490
|
-
let n = e.CLOUDFLARE_ZONE_ID, r = e.CLOUDFLARE_API_TOKEN, i = e.PUBLIC_FRONTEND_URL || "https://kama.t3cloud.eu";
|
|
7491
|
-
if (!n || !r) {
|
|
7492
|
-
console.warn("[Cache] Skipping purge: Missing CLOUDFLARE_ZONE_ID or CLOUDFLARE_API_TOKEN in environment.");
|
|
7493
|
-
return;
|
|
7494
|
-
}
|
|
7495
|
-
try {
|
|
7496
|
-
let e = t.replace(/^\/+|\/+$/g, ""), a = e === "home" || !e ? i : `${i}/${e}`, o = [a, `${a}/`];
|
|
7497
|
-
console.log(`[Cache] Purging edge cache for: ${o.join(", ")}`);
|
|
7498
|
-
let s = await fetch(`https://api.cloudflare.com/client/v4/zones/${n}/purge_cache`, {
|
|
7499
|
-
method: "POST",
|
|
7500
|
-
headers: {
|
|
7501
|
-
Authorization: `Bearer ${r}`,
|
|
7502
|
-
"Content-Type": "application/json"
|
|
7503
|
-
},
|
|
7504
|
-
body: JSON.stringify({ files: o })
|
|
7505
|
-
});
|
|
7506
|
-
if (!s.ok) {
|
|
7507
|
-
let e = await s.text();
|
|
7508
|
-
console.error(`[Cache] Purge failed: ${e}`);
|
|
7509
|
-
return;
|
|
7510
|
-
}
|
|
7511
|
-
fetch(a, { headers: { "X-Cache-Warmer": "true" } }).catch((e) => console.error(`[Cache] Warming failed for ${a}:`, e));
|
|
7512
|
-
} catch (e) {
|
|
7513
|
-
console.error("[Cache] Critical error during cache purge:", e);
|
|
7514
|
-
}
|
|
7515
|
-
}
|
|
7516
7578
|
X.get("/", async (e) => {
|
|
7517
7579
|
let t = e.get("db"), n = e.req.query("id"), r = e.req.query("type"), i = e.req.query("q") || e.req.query("search"), a = e.req.query("channelId"), o = e.req.query("trashed") === "true", s = e.req.query("assetId"), c = e.req.query("sort") || "updatedAt", l = (e.req.query("order") || "DESC").toUpperCase() === "ASC" ? "ASC" : "DESC", u = e.req.query("limit"), d = e.req.query("offset"), f = Math.max(1, Math.min(100, parseInt(u || "50", 10))), p = Math.max(0, parseInt(d || "0", 10));
|
|
7518
7580
|
if (n) {
|
|
@@ -7538,13 +7600,13 @@ X.get("/", async (e) => {
|
|
|
7538
7600
|
updatedAt: i.updatedAt
|
|
7539
7601
|
}, s = i.draftDataJson || i.dataJson;
|
|
7540
7602
|
if (s) try {
|
|
7541
|
-
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 =
|
|
7603
|
+
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;
|
|
7542
7604
|
if (a) {
|
|
7543
|
-
let { resolvedLayoutId: e, inheritedFields: r } = await
|
|
7605
|
+
let { resolvedLayoutId: e, inheritedFields: r } = await yi(t, a.parentId, a.treeId);
|
|
7544
7606
|
(l === "inherit" || !l) && (l = e || c.defaultLayout || null);
|
|
7545
7607
|
for (let [e, t] of Object.entries(r)) (n[e] === void 0 || n[e] === null || n[e] === "") && t !== void 0 && (n[e] = t);
|
|
7546
7608
|
} else (l === "inherit" || !l) && (l = c.defaultLayout || null);
|
|
7547
|
-
let u = await
|
|
7609
|
+
let u = await si(t, gi(n));
|
|
7548
7610
|
Object.assign(o, u), o.resolvedLayoutId = l;
|
|
7549
7611
|
} catch {}
|
|
7550
7612
|
let c = await t.prepare("SELECT channelId FROM node_channels WHERE nodeId = ?").all(r);
|
|
@@ -7554,7 +7616,7 @@ X.get("/", async (e) => {
|
|
|
7554
7616
|
let u = await t.prepare("\n SELECT * FROM content_blocks \n WHERE contentId = ? AND isDraft = 1 \n ORDER BY sortOrder ASC\n ").all(r), d = Array.isArray(u) ? u : u?.results || [], f = await Promise.all(d.map(async (e) => {
|
|
7555
7617
|
let n = {};
|
|
7556
7618
|
try {
|
|
7557
|
-
n = typeof e.dataJson == "string" ? JSON.parse(e.dataJson || "{}") : e.dataJson || {}, n && typeof n == "object" && (n = await
|
|
7619
|
+
n = typeof e.dataJson == "string" ? JSON.parse(e.dataJson || "{}") : e.dataJson || {}, n && typeof n == "object" && (n = await si(t, n));
|
|
7558
7620
|
} catch {
|
|
7559
7621
|
n = {};
|
|
7560
7622
|
}
|
|
@@ -7629,10 +7691,10 @@ X.get("/", async (e) => {
|
|
|
7629
7691
|
FROM tree_nodes tn
|
|
7630
7692
|
JOIN trees t ON tn.treeId = t.id
|
|
7631
7693
|
WHERE tn.contentId IN (${e})
|
|
7632
|
-
`).all(...T), a = Array.isArray(i) ? i :
|
|
7694
|
+
`).all(...T), a = Array.isArray(i) ? i : a?.results || [];
|
|
7633
7695
|
for (let e of a) D[e.nodeId] || (D[e.nodeId] = []), D[e.nodeId].includes(e.label) || D[e.nodeId].push(e.label);
|
|
7634
7696
|
}
|
|
7635
|
-
let
|
|
7697
|
+
let ee = await Promise.all(w.map(async (e) => {
|
|
7636
7698
|
let n = (e.status === "draft" || !e.status) && !!e.publishedAt, r = {
|
|
7637
7699
|
id: e.id,
|
|
7638
7700
|
title: e.title,
|
|
@@ -7654,40 +7716,40 @@ X.get("/", async (e) => {
|
|
|
7654
7716
|
assetCount: e.assetCount || 0
|
|
7655
7717
|
}, i = e.draftDataJson || e.dataJson;
|
|
7656
7718
|
if (i) try {
|
|
7657
|
-
let e = typeof i == "string" ? JSON.parse(i) : i, n = await
|
|
7719
|
+
let e = typeof i == "string" ? JSON.parse(i) : i, n = await si(t, gi(e));
|
|
7658
7720
|
Object.assign(r, n);
|
|
7659
7721
|
} catch {}
|
|
7660
7722
|
return r;
|
|
7661
7723
|
}));
|
|
7662
7724
|
return e.json({
|
|
7663
|
-
items:
|
|
7725
|
+
items: ee,
|
|
7664
7726
|
total: v,
|
|
7665
|
-
hasMore: p +
|
|
7727
|
+
hasMore: p + ee.length < v,
|
|
7666
7728
|
offset: p,
|
|
7667
7729
|
limit: f
|
|
7668
7730
|
});
|
|
7669
7731
|
}), X.post("/", async (e) => {
|
|
7670
|
-
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 =
|
|
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 = gi(_), { cleanedData: y, assetRefs: b } = ii(v), x = mi(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();
|
|
7671
7733
|
if (a) {
|
|
7672
7734
|
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 || "{}";
|
|
7673
7735
|
try {
|
|
7674
|
-
|
|
7736
|
+
_i(typeof r == "string" ? JSON.parse(r) : r, E);
|
|
7675
7737
|
} catch {}
|
|
7676
7738
|
if (m !== void 0) {
|
|
7677
7739
|
let e = await t.prepare("SELECT dataJson FROM content_blocks WHERE contentId = ? AND isDraft = 1").all(a);
|
|
7678
7740
|
(Array.isArray(e) ? e : e?.results || []).forEach((e) => {
|
|
7679
7741
|
try {
|
|
7680
|
-
|
|
7742
|
+
_i(typeof e.dataJson == "string" ? JSON.parse(e.dataJson) : e.dataJson, E);
|
|
7681
7743
|
} catch {}
|
|
7682
7744
|
});
|
|
7683
7745
|
}
|
|
7684
|
-
if (m === void 0 && o === void 0 && s === void 0 && h === void 0 && g === void 0 && Object.keys(v).length === 0) return 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" &&
|
|
7746
|
+
if (m === void 0 && o === void 0 && s === void 0 && h === void 0 && g === void 0 && Object.keys(v).length === 0) return 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" && new Y(e.env).purgeSmart(e, t, a, n.slug), e.json({
|
|
7685
7747
|
success: !0,
|
|
7686
7748
|
id: a,
|
|
7687
7749
|
status: n?.status || "published"
|
|
7688
7750
|
});
|
|
7689
7751
|
{
|
|
7690
|
-
let e = o === void 0 ? n?.title || "Untitled" : o, r = s === void 0 ? n?.slug ?? null :
|
|
7752
|
+
let e = o === void 0 ? n?.title || "Untitled" : o, r = s === void 0 ? n?.slug ?? null : pi(s), i = C || n?.contentType || "page", c = S || n?.language || "en", l = n?.draftDataJson || n?.dataJson || "{}", u = {};
|
|
7691
7753
|
try {
|
|
7692
7754
|
u = JSON.parse(l);
|
|
7693
7755
|
} catch {}
|
|
@@ -7698,7 +7760,7 @@ X.get("/", async (e) => {
|
|
|
7698
7760
|
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);
|
|
7699
7761
|
}
|
|
7700
7762
|
} else {
|
|
7701
|
-
let e = o || "Untitled", n =
|
|
7763
|
+
let e = o || "Untitled", n = pi(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);
|
|
7702
7764
|
T = Number(i.lastInsertRowid);
|
|
7703
7765
|
}
|
|
7704
7766
|
if (h !== void 0 && Array.isArray(h) && T) {
|
|
@@ -7716,7 +7778,7 @@ X.get("/", async (e) => {
|
|
|
7716
7778
|
let i = Number(t.treeId) || t.treeId;
|
|
7717
7779
|
if (!e.has(i)) {
|
|
7718
7780
|
e.add(i);
|
|
7719
|
-
let a =
|
|
7781
|
+
let a = hi(t.parentId ?? t._draftParentId ?? null), o = typeof t.sortOrder == "number" ? t.sortOrder : 0;
|
|
7720
7782
|
n.push("(?, ?, ?, ?)"), r.push(i, T, a, o);
|
|
7721
7783
|
}
|
|
7722
7784
|
}
|
|
@@ -7747,7 +7809,7 @@ X.get("/", async (e) => {
|
|
|
7747
7809
|
let n = [...b, ...D];
|
|
7748
7810
|
await ai(t, T, n);
|
|
7749
7811
|
let r = new Set(n.map((e) => e.assetId)), i = new Set([...E].filter((e) => !r.has(e)));
|
|
7750
|
-
i.size > 0 && await
|
|
7812
|
+
i.size > 0 && await vi(t, ri(e.env), i);
|
|
7751
7813
|
}
|
|
7752
7814
|
return await q(e).clear(), e.json({
|
|
7753
7815
|
success: !0,
|
|
@@ -7779,7 +7841,7 @@ X.get("/", async (e) => {
|
|
|
7779
7841
|
},
|
|
7780
7842
|
blocks: l
|
|
7781
7843
|
};
|
|
7782
|
-
return 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(),
|
|
7844
|
+
return 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(), new Y(e.env).purgeSmart(e, t, i, o.slug), e.json({
|
|
7783
7845
|
success: !0,
|
|
7784
7846
|
id: i,
|
|
7785
7847
|
status: "published",
|
|
@@ -7790,7 +7852,7 @@ X.get("/", async (e) => {
|
|
|
7790
7852
|
let t = e.get("db"), n = e.req.query("id");
|
|
7791
7853
|
if (!n) return e.json({ error: "Node ID required" }, 400);
|
|
7792
7854
|
let r = Number(n), i = await t.prepare("SELECT slug, status FROM content_nodes WHERE id = ?").get(r);
|
|
7793
|
-
return await t.prepare("UPDATE content_nodes SET deletedAt = CURRENT_TIMESTAMP WHERE id = ?").run(r), await q(e).clear(), i && i.status === "published" &&
|
|
7855
|
+
return await t.prepare("UPDATE content_nodes SET deletedAt = CURRENT_TIMESTAMP WHERE id = ?").run(r), await q(e).clear(), i && i.status === "published" && new Y(e.env).purgeSmart(e, t, r, i.slug), e.json({
|
|
7794
7856
|
success: !0,
|
|
7795
7857
|
deletedNodeId: r
|
|
7796
7858
|
});
|
|
@@ -7798,7 +7860,7 @@ X.get("/", async (e) => {
|
|
|
7798
7860
|
let t = e.get("db"), n = await e.req.json(), r = Number(n.id);
|
|
7799
7861
|
if (!r) return e.json({ error: "Node ID required" }, 400);
|
|
7800
7862
|
let i = await t.prepare("SELECT slug, status FROM content_nodes WHERE id = ?").get(r);
|
|
7801
|
-
return await t.prepare("UPDATE content_nodes SET deletedAt = NULL WHERE id = ?").run(r), await q(e).clear(), i && i.status === "published" &&
|
|
7863
|
+
return await t.prepare("UPDATE content_nodes SET deletedAt = NULL WHERE id = ?").run(r), await q(e).clear(), i && i.status === "published" && new Y(e.env).purgeSmart(e, t, r, i.slug), e.json({
|
|
7802
7864
|
success: !0,
|
|
7803
7865
|
restoredNodeId: r
|
|
7804
7866
|
});
|
|
@@ -7806,7 +7868,7 @@ X.get("/", async (e) => {
|
|
|
7806
7868
|
let t = e.get("db"), n = e.req.query("id");
|
|
7807
7869
|
if (!n) return e.json({ error: "Node ID required" }, 400);
|
|
7808
7870
|
let r = Number(n), i = await t.prepare("SELECT slug, status FROM content_nodes WHERE id = ?").get(r);
|
|
7809
|
-
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" &&
|
|
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({
|
|
7810
7872
|
success: !0,
|
|
7811
7873
|
purgedNodeId: r
|
|
7812
7874
|
});
|
|
@@ -7891,43 +7953,43 @@ bi.get("/tree.json", async (e) => {
|
|
|
7891
7953
|
}
|
|
7892
7954
|
}), bi.post("/tree.json", async (e) => {
|
|
7893
7955
|
try {
|
|
7894
|
-
let t = e.get("db"), n = await e.req.json(), r = n.treeId ? String(n.treeId).trim() : "main-nav", i = q(e), a = 1;
|
|
7956
|
+
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;
|
|
7895
7957
|
if (isNaN(Number(r))) {
|
|
7896
7958
|
let e = await t.prepare("SELECT id FROM trees WHERE key = ?").get(r);
|
|
7897
|
-
if (e && e.id)
|
|
7959
|
+
if (e && e.id) o = Number(e.id);
|
|
7898
7960
|
else {
|
|
7899
7961
|
let e = await t.prepare("SELECT id FROM trees LIMIT 1").get();
|
|
7900
|
-
e && e.id && (
|
|
7962
|
+
e && e.id && (o = Number(e.id));
|
|
7901
7963
|
}
|
|
7902
|
-
} else
|
|
7964
|
+
} else o = Number(r);
|
|
7903
7965
|
if (n.tree && Array.isArray(n.tree)) {
|
|
7904
7966
|
let r = xi(n.tree, null);
|
|
7905
7967
|
if (r.length > 0) for (let e = 0; e < r.length; e += 50) {
|
|
7906
|
-
let n = r.slice(e, e + 50), i = n.map((e) => e.id),
|
|
7968
|
+
let n = r.slice(e, e + 50), i = n.map((e) => e.id), a = i.map(() => "?").join(","), s = "UPDATE tree_nodes SET \n";
|
|
7907
7969
|
s += "parentId = CASE id \n", n.forEach(() => {
|
|
7908
7970
|
s += "WHEN ? THEN ? \n";
|
|
7909
7971
|
}), s += "ELSE parentId END, \n", s += "sortOrder = CASE id \n", n.forEach(() => {
|
|
7910
7972
|
s += "WHEN ? THEN ? \n";
|
|
7911
|
-
}), s += "ELSE sortOrder END \n", s += `WHERE id IN (${
|
|
7973
|
+
}), s += "ELSE sortOrder END \n", s += `WHERE id IN (${a}) AND treeId = ?`;
|
|
7912
7974
|
let c = [];
|
|
7913
7975
|
n.forEach((e) => {
|
|
7914
7976
|
c.push(e.id, e.parentId);
|
|
7915
7977
|
}), n.forEach((e) => {
|
|
7916
7978
|
c.push(e.id, e.sortOrder);
|
|
7917
|
-
}), c.push(...i), c.push(
|
|
7979
|
+
}), c.push(...i), c.push(o), await t.prepare(s).run(...c);
|
|
7918
7980
|
}
|
|
7919
|
-
return await i.clear(), e.json({ success: !0 });
|
|
7920
|
-
}
|
|
7921
|
-
let { action:
|
|
7922
|
-
delete
|
|
7923
|
-
let
|
|
7924
|
-
if (
|
|
7925
|
-
let r =
|
|
7926
|
-
if (
|
|
7927
|
-
let n =
|
|
7928
|
-
|
|
7929
|
-
|
|
7930
|
-
|
|
7981
|
+
return await i.clear(), a.purgeGlobalCache(e), e.json({ success: !0 });
|
|
7982
|
+
}
|
|
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 = Ci(n.isHidden === void 0 ? m.isHidden === void 0 ? m.hidden : m.isHidden : n.isHidden);
|
|
7984
|
+
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 = Si(u), _ = e.get("user")?.id || null;
|
|
7986
|
+
if (s === "create") {
|
|
7987
|
+
let r = m.slug || n.slug || c, s = r ? String(r).toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/(^-|-$)/g, "") : null;
|
|
7988
|
+
if (s) {
|
|
7989
|
+
let n = g === null ? "tn.parentId IS NULL" : "tn.parentId = ?", r = g === null ? [o, s] : [
|
|
7990
|
+
o,
|
|
7991
|
+
g,
|
|
7992
|
+
s
|
|
7931
7993
|
];
|
|
7932
7994
|
if (await t.prepare(`
|
|
7933
7995
|
SELECT 1
|
|
@@ -7939,39 +8001,39 @@ bi.get("/tree.json", async (e) => {
|
|
|
7939
8001
|
AND (cn.deletedAt IS NULL OR cn.deletedAt = '')
|
|
7940
8002
|
LIMIT 1
|
|
7941
8003
|
`).get(...r)) return e.json({
|
|
7942
|
-
error: `The slug '${
|
|
8004
|
+
error: `The slug '${s}' is already in use by another page in this section.`,
|
|
7943
8005
|
field: "slug"
|
|
7944
8006
|
}, 409);
|
|
7945
8007
|
}
|
|
7946
|
-
let
|
|
7947
|
-
await t.prepare("DELETE FROM tree_nodes WHERE treeId = ? AND contentId = ?").run(
|
|
7948
|
-
let
|
|
7949
|
-
n.channels && Array.isArray(n.channels) ?
|
|
7950
|
-
let
|
|
7951
|
-
if (
|
|
7952
|
-
let e =
|
|
8008
|
+
let u = JSON.stringify(m), d = await t.prepare("\n INSERT INTO content_nodes (contentType, title, slug, language, isHidden, status, draftDataJson, dataJson, createdById, updatedById)\n VALUES (?, ?, ?, ?, ?, 'draft', ?, NULL, ?, ?)\n ").run(l || "page", c || "Untitled", s, m.language || n.language || "en", h, u, _, _), f = Number(d.lastInsertRowid);
|
|
8009
|
+
await t.prepare("DELETE FROM tree_nodes WHERE treeId = ? AND contentId = ?").run(o, f);
|
|
8010
|
+
let p = await t.prepare("\n INSERT INTO tree_nodes (treeId, contentId, parentId, sortOrder)\n VALUES (?, ?, ?, 0)\n ").run(o, f, g), v = Number(p.lastInsertRowid), y = [];
|
|
8011
|
+
n.channels && Array.isArray(n.channels) ? y = n.channels : n.channelId && n.channelId !== "all" && (y = [n.channelId]);
|
|
8012
|
+
let b = [...new Set(y)].filter((e) => e && e !== "all").map((e) => Number(e));
|
|
8013
|
+
if (b.length > 0) {
|
|
8014
|
+
let e = b.map(() => "(?, ?)").join(", "), n = b.flatMap((e) => [f, e]);
|
|
7953
8015
|
await t.prepare(`INSERT OR IGNORE INTO node_channels (nodeId, channelId) VALUES ${e}`).run(...n);
|
|
7954
8016
|
}
|
|
7955
|
-
return await i.clear(), e.json({
|
|
8017
|
+
return await i.clear(), a.purgeGlobalCache(e), e.json({
|
|
7956
8018
|
success: !0,
|
|
7957
|
-
id:
|
|
7958
|
-
treeNodeId:
|
|
8019
|
+
id: f,
|
|
8020
|
+
treeNodeId: v,
|
|
7959
8021
|
status: "draft"
|
|
7960
8022
|
}, 201);
|
|
7961
8023
|
}
|
|
7962
|
-
if (
|
|
7963
|
-
if (!
|
|
7964
|
-
let n = await t.prepare("SELECT slug FROM content_nodes WHERE id = ?").get(
|
|
8024
|
+
if (s === "attach") {
|
|
8025
|
+
if (!d) return e.json({ error: "contentId is required for attach" }, 400);
|
|
8026
|
+
let n = await t.prepare("SELECT slug FROM content_nodes WHERE id = ?").get(d);
|
|
7965
8027
|
if (n && n.slug) {
|
|
7966
|
-
let r =
|
|
7967
|
-
|
|
8028
|
+
let r = g === null ? "tn.parentId IS NULL" : "tn.parentId = ?", i = g === null ? [
|
|
8029
|
+
o,
|
|
7968
8030
|
n.slug,
|
|
7969
|
-
|
|
8031
|
+
d
|
|
7970
8032
|
] : [
|
|
7971
|
-
|
|
7972
|
-
|
|
8033
|
+
o,
|
|
8034
|
+
g,
|
|
7973
8035
|
n.slug,
|
|
7974
|
-
|
|
8036
|
+
d
|
|
7975
8037
|
];
|
|
7976
8038
|
if (await t.prepare(`
|
|
7977
8039
|
SELECT 1
|
|
@@ -7988,16 +8050,16 @@ bi.get("/tree.json", async (e) => {
|
|
|
7988
8050
|
field: "slug"
|
|
7989
8051
|
}, 409);
|
|
7990
8052
|
}
|
|
7991
|
-
await t.prepare("DELETE FROM tree_nodes WHERE treeId = ? AND contentId = ?").run(
|
|
7992
|
-
let r = await t.prepare("\n INSERT INTO tree_nodes (treeId, contentId, parentId, sortOrder)\n VALUES (?, ?, ?, 0)\n ").run(
|
|
7993
|
-
return await i.clear(), e.json({
|
|
8053
|
+
await t.prepare("DELETE FROM tree_nodes WHERE treeId = ? AND contentId = ?").run(o, d);
|
|
8054
|
+
let r = await t.prepare("\n INSERT INTO tree_nodes (treeId, contentId, parentId, sortOrder)\n VALUES (?, ?, ?, 0)\n ").run(o, d, g), s = Number(r.lastInsertRowid);
|
|
8055
|
+
return await i.clear(), a.purgeGlobalCache(e), e.json({
|
|
7994
8056
|
success: !0,
|
|
7995
|
-
treeNodeId:
|
|
8057
|
+
treeNodeId: s
|
|
7996
8058
|
});
|
|
7997
8059
|
}
|
|
7998
|
-
if (
|
|
8060
|
+
if (s === "detach") {
|
|
7999
8061
|
let r = n.treeNodeId || n.contentId;
|
|
8000
|
-
return r ? (await t.prepare("\n UPDATE tree_nodes \n SET parentId = (SELECT parentId FROM tree_nodes WHERE (id = ? OR contentId = ?) AND treeId = ?) \n WHERE parentId = ? AND treeId = ?\n ").run(r, r,
|
|
8062
|
+
return r ? (await t.prepare("\n UPDATE tree_nodes \n SET parentId = (SELECT parentId FROM tree_nodes WHERE (id = ? OR contentId = ?) AND treeId = ?) \n WHERE parentId = ? AND treeId = ?\n ").run(r, r, o, r, o), await t.prepare("DELETE FROM tree_nodes WHERE (id = ? OR contentId = ?) AND treeId = ?").run(r, r, o), await i.clear(), a.purgeGlobalCache(e), e.json({ success: !0 })) : e.json({ error: "treeNodeId or contentId required for detach" }, 400);
|
|
8001
8063
|
}
|
|
8002
8064
|
return e.json({ error: "Invalid payload or action" }, 400);
|
|
8003
8065
|
} catch (t) {
|
|
@@ -8060,7 +8122,7 @@ bi.get("/tree.json", async (e) => {
|
|
|
8060
8122
|
await t.prepare(`INSERT OR IGNORE INTO channel_trees (channelId, treeId, key) VALUES ${n}`).run(...r);
|
|
8061
8123
|
}
|
|
8062
8124
|
}
|
|
8063
|
-
return await q(e).clear(), e.json({
|
|
8125
|
+
return await q(e).clear(), new Y(e.env).purgeGlobalCache(e), e.json({
|
|
8064
8126
|
success: !0,
|
|
8065
8127
|
id: p,
|
|
8066
8128
|
key: o,
|
|
@@ -8079,7 +8141,7 @@ bi.get("/tree.json", async (e) => {
|
|
|
8079
8141
|
if (!n) return e.json({ error: "Tree ID required" }, 400);
|
|
8080
8142
|
let r = Number(n);
|
|
8081
8143
|
try {
|
|
8082
|
-
return await t.prepare("DELETE FROM trees WHERE id = ?").run(r), await t.prepare("DELETE FROM channel_trees WHERE treeId = ?").run(r), await t.prepare("DELETE FROM tree_nodes WHERE treeId = ?").run(r), await q(e).clear(), e.json({
|
|
8144
|
+
return await t.prepare("DELETE FROM trees WHERE id = ?").run(r), await t.prepare("DELETE FROM channel_trees WHERE treeId = ?").run(r), await t.prepare("DELETE FROM tree_nodes WHERE treeId = ?").run(r), await q(e).clear(), new Y(e.env).purgeGlobalCache(e), e.json({
|
|
8083
8145
|
success: !0,
|
|
8084
8146
|
deletedTreeId: r
|
|
8085
8147
|
});
|
|
@@ -8114,7 +8176,7 @@ wi.get("/", async (e) => {
|
|
|
8114
8176
|
isHidden: !!e.isHidden,
|
|
8115
8177
|
trees: a[e.id] || []
|
|
8116
8178
|
};
|
|
8117
|
-
}), s = e.env?.BUNDLED_DEFINITIONS, c =
|
|
8179
|
+
}), s = e.env?.BUNDLED_DEFINITIONS, c = ui(s)?.channelTemplate || {
|
|
8118
8180
|
label: "Channel Settings",
|
|
8119
8181
|
fields: {
|
|
8120
8182
|
key: {
|
|
@@ -8183,7 +8245,7 @@ wi.get("/", async (e) => {
|
|
|
8183
8245
|
VALUES ${e}
|
|
8184
8246
|
`).run(...n);
|
|
8185
8247
|
}
|
|
8186
|
-
return await q(e).clear(), e.json({
|
|
8248
|
+
return await q(e).clear(), new Y(e.env).purgeGlobalCache(e), e.json({
|
|
8187
8249
|
success: !0,
|
|
8188
8250
|
id: w
|
|
8189
8251
|
});
|
|
@@ -8198,7 +8260,7 @@ wi.get("/", async (e) => {
|
|
|
8198
8260
|
if (!n) return e.json({ error: "Channel ID required" }, 400);
|
|
8199
8261
|
let r = Number(n);
|
|
8200
8262
|
try {
|
|
8201
|
-
return await t.prepare("DELETE FROM channel_trees WHERE channelId = ?").run(r), await t.prepare("DELETE FROM node_channels WHERE channelId = ?").run(r), await t.prepare("DELETE FROM channels WHERE id = ?").run(r), await q(e).clear(), e.json({
|
|
8263
|
+
return await t.prepare("DELETE FROM channel_trees WHERE channelId = ?").run(r), await t.prepare("DELETE FROM node_channels WHERE channelId = ?").run(r), await t.prepare("DELETE FROM channels WHERE id = ?").run(r), await q(e).clear(), new Y(e.env).purgeGlobalCache(e), e.json({
|
|
8202
8264
|
success: !0,
|
|
8203
8265
|
deletedSiteId: r
|
|
8204
8266
|
});
|
|
@@ -8214,7 +8276,7 @@ wi.get("/", async (e) => {
|
|
|
8214
8276
|
var Ti = new e(), Ei = null, Di = (e) => {
|
|
8215
8277
|
try {
|
|
8216
8278
|
if (!Ei) {
|
|
8217
|
-
let t =
|
|
8279
|
+
let t = li(e.env?.BUNDLED_DEFINITIONS || Ar), n = t.userTemplate || {
|
|
8218
8280
|
id: "userTemplate",
|
|
8219
8281
|
label: "User Account",
|
|
8220
8282
|
fields: {
|
|
@@ -8401,7 +8463,7 @@ ji.get("/", async (e) => {
|
|
|
8401
8463
|
isHidden: !!e.isHidden,
|
|
8402
8464
|
channelNames: e.channelLabels ? e.channelLabels.split(",") : [],
|
|
8403
8465
|
treeNames: e.treeLabels ? e.treeLabels.split(",") : []
|
|
8404
|
-
})), p = e.env?.BUNDLED_DEFINITIONS, m =
|
|
8466
|
+
})), p = e.env?.BUNDLED_DEFINITIONS, m = li(p), h = m.nodes || m.nodeSchemas || {}, g = c.map((e) => {
|
|
8405
8467
|
let t = e.type || "node", n = h[t]?.label || t.charAt(0).toUpperCase() + t.slice(1);
|
|
8406
8468
|
return {
|
|
8407
8469
|
type: t,
|
|
@@ -8451,6 +8513,14 @@ function Ni(e, t, n) {
|
|
|
8451
8513
|
let r = e || (t ? `/media/${t}` : "");
|
|
8452
8514
|
return r && n && r.startsWith(`https://${n}/`) && !r.includes("/media/") && (r = r.replace(`https://${n}/`, `https://${n}/media/`)), r;
|
|
8453
8515
|
}
|
|
8516
|
+
async function Pi(e, t, n) {
|
|
8517
|
+
let r = new Y(e.env), i = 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
|
+
n,
|
|
8519
|
+
n,
|
|
8520
|
+
n
|
|
8521
|
+
]);
|
|
8522
|
+
if (i.length !== 0) for (let n of i) n.id && r.purgeSmart(e, t, n.id, n.slug);
|
|
8523
|
+
}
|
|
8454
8524
|
Z.get("/", async (e) => {
|
|
8455
8525
|
try {
|
|
8456
8526
|
let t = u(e), { search: n = "", type: r = "all", page: i = "1", limit: a = "24", sort: o = "createdAt", order: s = "DESC", nodeId: c, channelId: l, trashed: d } = e.req.query(), f = Math.max(1, parseInt(i, 10) || 1), p = Math.max(1, Math.min(100, parseInt(a, 10) || 24)), m = (f - 1) * p, h = {
|
|
@@ -8575,8 +8645,8 @@ Z.get("/", async (e) => {
|
|
|
8575
8645
|
]);
|
|
8576
8646
|
let D = x;
|
|
8577
8647
|
if (s) {
|
|
8578
|
-
let
|
|
8579
|
-
|
|
8648
|
+
let n = await Q(t, "SELECT cdnUrl, storageKeyPrivate FROM assets WHERE id = ?", [s]);
|
|
8649
|
+
n.length > 0 && (D = Ni(n[0].cdnUrl, n[0].storageKeyPrivate, y)), await Pi(e, t, s);
|
|
8580
8650
|
}
|
|
8581
8651
|
return e.json({
|
|
8582
8652
|
id: p,
|
|
@@ -8665,7 +8735,7 @@ Z.get("/", async (e) => {
|
|
|
8665
8735
|
r.filename === void 0 ? a.filename : r.filename,
|
|
8666
8736
|
JSON.stringify(o),
|
|
8667
8737
|
n
|
|
8668
|
-
]), e.json({ success: !0 });
|
|
8738
|
+
]), await Pi(e, t, n), e.json({ success: !0 });
|
|
8669
8739
|
} catch (t) {
|
|
8670
8740
|
return console.error("❌ [Asset Update Error]:", t), e.json({ error: "Failed to update asset" }, 500);
|
|
8671
8741
|
}
|
|
@@ -8677,7 +8747,7 @@ Z.get("/", async (e) => {
|
|
|
8677
8747
|
n,
|
|
8678
8748
|
`crop_%${r.filename ? r.filename.replace(/\.[^/.]+$/, "") : ""}%`,
|
|
8679
8749
|
`%${n}%`
|
|
8680
|
-
]), e.json({
|
|
8750
|
+
]), await Pi(e, t, n), e.json({
|
|
8681
8751
|
success: !0,
|
|
8682
8752
|
id: n,
|
|
8683
8753
|
trashed: !0
|
|
@@ -8698,7 +8768,7 @@ Z.get("/", async (e) => {
|
|
|
8698
8768
|
r,
|
|
8699
8769
|
`crop_%${i.filename ? i.filename.replace(/\.[^/.]+$/, "") : ""}%`,
|
|
8700
8770
|
`%${r}%`
|
|
8701
|
-
]), e.json({
|
|
8771
|
+
]), await Pi(e, t, r), e.json({
|
|
8702
8772
|
success: !0,
|
|
8703
8773
|
id: r,
|
|
8704
8774
|
restored: !0
|
|
@@ -8713,6 +8783,7 @@ Z.get("/", async (e) => {
|
|
|
8713
8783
|
try {
|
|
8714
8784
|
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];
|
|
8715
8785
|
if (!i) return e.json({ error: "Asset not found" }, 404);
|
|
8786
|
+
await Pi(e, t, r);
|
|
8716
8787
|
let a = [i];
|
|
8717
8788
|
i.isSystemVariant || (a = [i, ...await Q(t, "SELECT id, storageKeyPrivate FROM assets \n WHERE parentAssetId = ? OR (isSystemVariant = 1 AND (filename LIKE ? OR filename LIKE ?))", [
|
|
8718
8789
|
r,
|
|
@@ -8744,8 +8815,8 @@ Z.get("/", async (e) => {
|
|
|
8744
8815
|
});
|
|
8745
8816
|
//#endregion
|
|
8746
8817
|
//#region server/routes/public/node.ts
|
|
8747
|
-
var
|
|
8748
|
-
function
|
|
8818
|
+
var Fi = new e();
|
|
8819
|
+
function Ii(e, t) {
|
|
8749
8820
|
let n = /* @__PURE__ */ new Date();
|
|
8750
8821
|
if (e && String(e).trim() !== "") {
|
|
8751
8822
|
let t = new Date(e);
|
|
@@ -8757,7 +8828,7 @@ function Fi(e, t) {
|
|
|
8757
8828
|
}
|
|
8758
8829
|
return !0;
|
|
8759
8830
|
}
|
|
8760
|
-
async function
|
|
8831
|
+
async function Li(e, t) {
|
|
8761
8832
|
if (!t || typeof t != "object") return t;
|
|
8762
8833
|
let n = { ...t };
|
|
8763
8834
|
for (let [t, r] of Object.entries(n)) if (typeof r == "string" && r.startsWith("ast_")) try {
|
|
@@ -8778,10 +8849,10 @@ async function Ii(e, t) {
|
|
|
8778
8849
|
};
|
|
8779
8850
|
}
|
|
8780
8851
|
} catch {}
|
|
8781
|
-
else typeof r == "object" && r && !Array.isArray(r) && !r.url && (n[t] = await
|
|
8852
|
+
else typeof r == "object" && r && !Array.isArray(r) && !r.url && (n[t] = await Li(e, r));
|
|
8782
8853
|
return n;
|
|
8783
8854
|
}
|
|
8784
|
-
async function
|
|
8855
|
+
async function Ri(e, t, n) {
|
|
8785
8856
|
let r = t.filter((e) => e.componentId === "content-feed" || e.componentId === "article-list");
|
|
8786
8857
|
for (let t of r) {
|
|
8787
8858
|
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];
|
|
@@ -8797,7 +8868,7 @@ async function Li(e, t, n) {
|
|
|
8797
8868
|
if (e.dataJson) try {
|
|
8798
8869
|
t = typeof e.dataJson == "string" ? JSON.parse(e.dataJson) : e.dataJson;
|
|
8799
8870
|
} catch {}
|
|
8800
|
-
return
|
|
8871
|
+
return Ii(t.startShowingAt, t.stopShowingAt) ? {
|
|
8801
8872
|
id: e.id,
|
|
8802
8873
|
title: e.title,
|
|
8803
8874
|
slug: e.slug,
|
|
@@ -8814,7 +8885,7 @@ async function Li(e, t, n) {
|
|
|
8814
8885
|
}
|
|
8815
8886
|
}
|
|
8816
8887
|
}
|
|
8817
|
-
async function
|
|
8888
|
+
async function zi(e, t, n, r, i = !1) {
|
|
8818
8889
|
if (!t) return { blocks: [] };
|
|
8819
8890
|
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 || [];
|
|
8820
8891
|
if (!o || o.length === 0) return { blocks: [] };
|
|
@@ -8844,10 +8915,10 @@ async function Ri(e, t, n, r, i = !1) {
|
|
|
8844
8915
|
try {
|
|
8845
8916
|
o = (typeof t.dataJson == "string" ? JSON.parse(t.dataJson) : t.dataJson) || {};
|
|
8846
8917
|
} catch {}
|
|
8847
|
-
let s = o.hidden === !0 || o.hidden === 1 || o.hidden === "1" || o.hidden === "true", l =
|
|
8918
|
+
let s = o.hidden === !0 || o.hidden === 1 || o.hidden === "1" || o.hidden === "true", l = Ii(o.startShowingAt, o.stopShowingAt);
|
|
8848
8919
|
if (!i && (s || !l)) continue;
|
|
8849
|
-
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 =
|
|
8850
|
-
p = await
|
|
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 = Bi(o, d);
|
|
8921
|
+
p = await si(e, p), p = await Li(e, p), p = Vi(p), p.blockId = f;
|
|
8851
8922
|
let m = t.region || n;
|
|
8852
8923
|
c[m] || (c[m] = []), c[m].push({
|
|
8853
8924
|
instanceId: t.id,
|
|
@@ -8866,7 +8937,7 @@ async function Ri(e, t, n, r, i = !1) {
|
|
|
8866
8937
|
}
|
|
8867
8938
|
return { blocks: [] };
|
|
8868
8939
|
}
|
|
8869
|
-
function
|
|
8940
|
+
function Bi(e, t = {}) {
|
|
8870
8941
|
let n = {};
|
|
8871
8942
|
for (let [r, i] of Object.entries(e)) {
|
|
8872
8943
|
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;
|
|
@@ -8875,14 +8946,14 @@ function zi(e, t = {}) {
|
|
|
8875
8946
|
}
|
|
8876
8947
|
return n;
|
|
8877
8948
|
}
|
|
8878
|
-
function
|
|
8879
|
-
if (Array.isArray(e)) return e.map(
|
|
8949
|
+
function Vi(e) {
|
|
8950
|
+
if (Array.isArray(e)) return e.map(Vi);
|
|
8880
8951
|
if (!e || typeof e != "object") return e;
|
|
8881
8952
|
if (typeof e.id == "string" && e.id.startsWith("ast_") && typeof e.url == "string") {
|
|
8882
8953
|
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 ? {
|
|
8883
8954
|
...t,
|
|
8884
8955
|
...t.crops?.[r] || {}
|
|
8885
|
-
} : t, a = Object.fromEntries(Object.entries(n).filter(([, t]) => t?.id !== e.id).map(([t, n]) => [t,
|
|
8956
|
+
} : t, a = Object.fromEntries(Object.entries(n).filter(([, t]) => t?.id !== e.id).map(([t, n]) => [t, Vi({
|
|
8886
8957
|
...n,
|
|
8887
8958
|
title: n?.title ?? e.title ?? "",
|
|
8888
8959
|
alt: n?.alt ?? e.alt ?? "",
|
|
@@ -8896,9 +8967,9 @@ function Bi(e) {
|
|
|
8896
8967
|
...Object.keys(a).length > 0 ? { variants: a } : {}
|
|
8897
8968
|
};
|
|
8898
8969
|
}
|
|
8899
|
-
return Object.fromEntries(Object.entries(e).map(([e, t]) => [e,
|
|
8970
|
+
return Object.fromEntries(Object.entries(e).map(([e, t]) => [e, Vi(t)]));
|
|
8900
8971
|
}
|
|
8901
|
-
async function
|
|
8972
|
+
async function Hi(e, t) {
|
|
8902
8973
|
if (typeof t == "string") {
|
|
8903
8974
|
if (!t.includes("#node:") && !t.includes("data-node-id") && !t.includes("#asset:") && !t.includes("data-asset-id")) return t;
|
|
8904
8975
|
let n = /* @__PURE__ */ new Set();
|
|
@@ -8915,7 +8986,7 @@ async function Vi(e, t) {
|
|
|
8915
8986
|
let t = n[1], r = t.match(/data-node-id=["']([^"']+)["']/i), i = t.match(/data-tree-id=["']([^"']+)["']/i);
|
|
8916
8987
|
if (!r || !i) continue;
|
|
8917
8988
|
let a = await e.prepare("SELECT id as treeNodeId FROM tree_nodes WHERE contentId = ? AND treeId = ? LIMIT 1").get(r[1], i[1]);
|
|
8918
|
-
a?.treeNodeId && u.set(`${r[1]}:${i[1]}`, await
|
|
8989
|
+
a?.treeNodeId && u.set(`${r[1]}:${i[1]}`, await Gi(e, String(a.treeNodeId), i[1]));
|
|
8919
8990
|
}
|
|
8920
8991
|
return t.replace(d, (e, t) => {
|
|
8921
8992
|
let n = t.match(/data-node-id=["']([^"']+)["']/i), r = t.match(/data-asset-id=["']([^"']+)["']/i), i = t.match(/href=["']([^"']+)["']/i);
|
|
@@ -8930,18 +9001,18 @@ async function Vi(e, t) {
|
|
|
8930
9001
|
return i ? `<a${t.replace(/href=["'][^"']*["']/i, `href="${g || "/"}"`)}>` : e;
|
|
8931
9002
|
});
|
|
8932
9003
|
}
|
|
8933
|
-
if (Array.isArray(t)) return Promise.all(t.map((t) =>
|
|
9004
|
+
if (Array.isArray(t)) return Promise.all(t.map((t) => Hi(e, t)));
|
|
8934
9005
|
if (t && typeof t == "object") {
|
|
8935
9006
|
if (typeof t.href == "string" && (t.href.startsWith("#node:") || t.href.startsWith("#asset:"))) return {
|
|
8936
9007
|
...t,
|
|
8937
|
-
href: await
|
|
9008
|
+
href: await Ui(e, t)
|
|
8938
9009
|
};
|
|
8939
|
-
let n = await Promise.all(Object.entries(t).map(async ([t, n]) => [t, await
|
|
9010
|
+
let n = await Promise.all(Object.entries(t).map(async ([t, n]) => [t, await Hi(e, n)]));
|
|
8940
9011
|
return Object.fromEntries(n);
|
|
8941
9012
|
}
|
|
8942
9013
|
return t;
|
|
8943
9014
|
}
|
|
8944
|
-
async function
|
|
9015
|
+
async function Ui(e, t) {
|
|
8945
9016
|
let n = t.href.match(/^#node:(.+)$/), r = t.href.match(/^#asset:(.+)$/);
|
|
8946
9017
|
if (r) {
|
|
8947
9018
|
let t = await e.prepare("SELECT cdnUrl, storageKeyPrivate FROM assets WHERE id = ?").get(r[1]);
|
|
@@ -8952,14 +9023,14 @@ async function Hi(e, t) {
|
|
|
8952
9023
|
if (t.treeId) {
|
|
8953
9024
|
let n = await e.prepare("SELECT id as treeNodeId FROM tree_nodes WHERE contentId = ? AND treeId = ? LIMIT 1").get(i, t.treeId);
|
|
8954
9025
|
if (n?.treeNodeId) {
|
|
8955
|
-
let r = await
|
|
9026
|
+
let r = await Gi(e, String(n.treeNodeId), String(t.treeId));
|
|
8956
9027
|
if (r) return r;
|
|
8957
9028
|
}
|
|
8958
9029
|
}
|
|
8959
9030
|
let a = await e.prepare("SELECT slug FROM content_nodes WHERE id = ?").get(i);
|
|
8960
9031
|
return a?.slug ? `/${String(a.slug).replace(/^\/+|\/+$/g, "")}` : "#";
|
|
8961
9032
|
}
|
|
8962
|
-
function
|
|
9033
|
+
function Wi(e) {
|
|
8963
9034
|
let t = e.socialImage;
|
|
8964
9035
|
if (!t || typeof t != "object") return null;
|
|
8965
9036
|
let n = (e, t) => {
|
|
@@ -8990,7 +9061,7 @@ function Ui(e) {
|
|
|
8990
9061
|
])
|
|
8991
9062
|
};
|
|
8992
9063
|
}
|
|
8993
|
-
async function
|
|
9064
|
+
async function Gi(e, t, n) {
|
|
8994
9065
|
if (!t) return "";
|
|
8995
9066
|
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 = [];
|
|
8996
9067
|
for (let e of i) {
|
|
@@ -8999,7 +9070,7 @@ async function Wi(e, t, n) {
|
|
|
8999
9070
|
}
|
|
9000
9071
|
return "/" + a.join("/");
|
|
9001
9072
|
}
|
|
9002
|
-
async function
|
|
9073
|
+
async function Ki(e, t, n, r, i) {
|
|
9003
9074
|
let a = {}, o = null;
|
|
9004
9075
|
if (t) {
|
|
9005
9076
|
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([
|
|
@@ -9037,7 +9108,7 @@ async function Gi(e, t, n, r, i) {
|
|
|
9037
9108
|
inheritedFields: a
|
|
9038
9109
|
};
|
|
9039
9110
|
}
|
|
9040
|
-
|
|
9111
|
+
Fi.get("/*", async (e) => {
|
|
9041
9112
|
try {
|
|
9042
9113
|
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));
|
|
9043
9114
|
if (!s) return e.json({ error: `Channel '${i}' not found` }, 404);
|
|
@@ -9048,7 +9119,7 @@ Pi.get("/*", async (e) => {
|
|
|
9048
9119
|
let t = await d.get(f);
|
|
9049
9120
|
if (t) return e.header("X-Cache", "HIT"), e.json(t);
|
|
9050
9121
|
}
|
|
9051
|
-
let p =
|
|
9122
|
+
let p = ui(e.env?.BUNDLED_DEFINITIONS), m = !isNaN(Number(r)) && r.length > 0, h = null, g = null, _ = e.req.query("treeId");
|
|
9052
9123
|
if (m) h = l === null ? await t.prepare("SELECT * FROM content_nodes WHERE id = ?").get(Number(r)) : await t.prepare("\n SELECT cn.* \n FROM content_nodes cn\n INNER JOIN node_channels nc ON cn.id = nc.nodeId\n WHERE cn.id = ? AND nc.channelId = ?\n ").get(Number(r), l);
|
|
9053
9124
|
else {
|
|
9054
9125
|
let e = r.split("/"), n = e[e.length - 1], i = "/" + r.replace(/^\/+|\/+$/g, ""), a = `
|
|
@@ -9059,7 +9130,7 @@ Pi.get("/*", async (e) => {
|
|
|
9059
9130
|
WHERE cn.slug = ? ${l === null ? "" : "AND nc.channelId = ?"}
|
|
9060
9131
|
`, o = l === null ? [n] : [n, l], s = await t.prepare(a).all(...o), c = Array.isArray(s) ? s : s?.results || [];
|
|
9061
9132
|
if (c.length > 0) for (let e of c) {
|
|
9062
|
-
let n = (await
|
|
9133
|
+
let n = (await Gi(t, e.treeNodeId, e.treeId)).replace(/^\/+|\/+$/g, ""), r = i.replace(/^\/+|\/+$/g, "");
|
|
9063
9134
|
if (n === r || r === "home" && (n === "" || n === "home")) {
|
|
9064
9135
|
h = e, g = e;
|
|
9065
9136
|
break;
|
|
@@ -9077,7 +9148,7 @@ Pi.get("/*", async (e) => {
|
|
|
9077
9148
|
LIMIT 1
|
|
9078
9149
|
`).get(...e);
|
|
9079
9150
|
}
|
|
9080
|
-
let v = g?.treeId || _ || "main-nav", y = g?.parentId || null, b = g?.treeNodeId ? await
|
|
9151
|
+
let v = g?.treeId || _ || "main-nav", y = g?.parentId || null, b = g?.treeNodeId ? await Gi(t, g.treeNodeId, v) : `/${(h.slug || "").replace(/^\/+|\/+$/g, "")}`, x = {
|
|
9081
9152
|
id: h.id,
|
|
9082
9153
|
title: h.title,
|
|
9083
9154
|
slug: h.slug,
|
|
@@ -9090,28 +9161,28 @@ Pi.get("/*", async (e) => {
|
|
|
9090
9161
|
C.tabs && Object.values(C.tabs).forEach((e) => {
|
|
9091
9162
|
Object.assign(w, e.fields || {});
|
|
9092
9163
|
});
|
|
9093
|
-
let T = {}, E = null, D = null,
|
|
9094
|
-
if (
|
|
9095
|
-
|
|
9164
|
+
let T = {}, E = null, D = null, ee = !1, O = {}, k = o && h.draftDataJson ? h.draftDataJson : h.dataJson || h.draftDataJson;
|
|
9165
|
+
if (k) try {
|
|
9166
|
+
O = typeof k == "string" ? JSON.parse(k) : k;
|
|
9096
9167
|
} catch {}
|
|
9097
|
-
|
|
9098
|
-
let
|
|
9099
|
-
for (let [e, t] of Object.entries(
|
|
9100
|
-
let
|
|
9101
|
-
|
|
9102
|
-
let
|
|
9103
|
-
delete
|
|
9104
|
-
let
|
|
9105
|
-
if (!o && (
|
|
9106
|
-
let
|
|
9168
|
+
O.disabledRegions && (T = O.disabledRegions), ee = O.hidden === !0 || O.hidden === 1 || O.hidden === "1" || O.hidden === "true", E = O.startShowingAt || null, D = O.stopShowingAt || null;
|
|
9169
|
+
let A = O.layoutId, te = A && A !== "inherit", { resolvedLayoutId: ne, inheritedFields: re } = await Ki(t, y, v, o, w), ie = te ? A : ne || C.defaultLayout || null;
|
|
9170
|
+
for (let [e, t] of Object.entries(re)) (O[e] === void 0 || O[e] === null || O[e] === "" || O[e] === "inherit") && t !== void 0 && (O[e] = t);
|
|
9171
|
+
let j = await si(t, Bi(O, w));
|
|
9172
|
+
j = await Li(t, j), j = Vi(j), j = await Hi(t, j);
|
|
9173
|
+
let ae = Wi(j);
|
|
9174
|
+
delete j.socialImage, delete j.fbImage, delete j.xImage, delete j.whatsappImage, ae && (j.socialImages = ae), x.slug = h.slug, x.title = h.title, Object.assign(x, j), x.layoutId = ie;
|
|
9175
|
+
let oe = !!h.isHidden || ee, se = !Ii(E, D);
|
|
9176
|
+
if (!o && (oe || se)) return e.json({ error: "Node is hidden or outside its scheduled publishing window" }, 404);
|
|
9177
|
+
let ce = [];
|
|
9107
9178
|
if (g?.treeNodeId) {
|
|
9108
9179
|
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;
|
|
9109
|
-
|
|
9180
|
+
ce = n.map((e) => {
|
|
9110
9181
|
let t = {}, n = o && e.draftDataJson ? e.draftDataJson : e.dataJson;
|
|
9111
9182
|
try {
|
|
9112
9183
|
t = (typeof n == "string" ? JSON.parse(n) : n) || {};
|
|
9113
9184
|
} catch {}
|
|
9114
|
-
let i = !!e.isHidden || t.hidden === !0 || t.hidden === 1 || t.hidden === "1", a =
|
|
9185
|
+
let i = !!e.isHidden || t.hidden === !0 || t.hidden === 1 || t.hidden === "1", a = Ii(t.startShowingAt, t.stopShowingAt), s = (e.slug || "").replace(/^\/+|\/+$/g, "");
|
|
9115
9186
|
return !o && (i || !a) ? null : {
|
|
9116
9187
|
treeNodeId: e.treeNodeId,
|
|
9117
9188
|
id: e.id,
|
|
@@ -9123,28 +9194,28 @@ Pi.get("/*", async (e) => {
|
|
|
9123
9194
|
};
|
|
9124
9195
|
}).filter(Boolean);
|
|
9125
9196
|
}
|
|
9126
|
-
x.children =
|
|
9127
|
-
let
|
|
9128
|
-
|
|
9129
|
-
let
|
|
9130
|
-
for (let e of
|
|
9197
|
+
x.children = ce;
|
|
9198
|
+
let le = +!!o, M = await t.prepare("\n SELECT * FROM content_blocks \n WHERE contentId = ? AND isDraft = ? \n ORDER BY sortOrder ASC\n ").all(h.id, le), ue = Array.isArray(M) ? M : M?.results || [];
|
|
9199
|
+
ue.length === 0 && !o && (M = await t.prepare("\n SELECT * FROM content_blocks \n WHERE contentId = ?\n ORDER BY sortOrder ASC\n ").all(h.id), ue = Array.isArray(M) ? M : M?.results || []);
|
|
9200
|
+
let N = {}, P = {};
|
|
9201
|
+
for (let e of ue) {
|
|
9131
9202
|
let n = e.region || "main";
|
|
9132
|
-
|
|
9203
|
+
N[n] || (N[n] = [], P[n] = { isInherited: !1 });
|
|
9133
9204
|
let r = {};
|
|
9134
9205
|
try {
|
|
9135
9206
|
r = (typeof e.dataJson == "string" ? JSON.parse(e.dataJson) : e.dataJson) || {};
|
|
9136
9207
|
} catch {}
|
|
9137
|
-
let i = r.hidden === !0 || r.hidden === 1 || r.hidden === "1" || r.hidden === "true", a =
|
|
9208
|
+
let i = r.hidden === !0 || r.hidden === 1 || r.hidden === "1" || r.hidden === "true", a = Ii(r.startShowingAt, r.stopShowingAt);
|
|
9138
9209
|
if (!o && (i || !a)) continue;
|
|
9139
|
-
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 =
|
|
9140
|
-
u = await
|
|
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 = Bi(r, c);
|
|
9211
|
+
u = await si(t, u), u = Vi(u), u = await Hi(t, u), u.blockId = l, N[n].push({
|
|
9141
9212
|
instanceId: e.id,
|
|
9142
9213
|
blockId: l,
|
|
9143
9214
|
componentId: s,
|
|
9144
9215
|
data: u
|
|
9145
9216
|
});
|
|
9146
9217
|
}
|
|
9147
|
-
let
|
|
9218
|
+
let de = {
|
|
9148
9219
|
header: {
|
|
9149
9220
|
label: "Header",
|
|
9150
9221
|
inherit: "parent"
|
|
@@ -9153,33 +9224,33 @@ Pi.get("/*", async (e) => {
|
|
|
9153
9224
|
label: "Footer",
|
|
9154
9225
|
inherit: "parent"
|
|
9155
9226
|
},
|
|
9156
|
-
...(
|
|
9227
|
+
...(ie ? p.nodeLayouts?.[ie] || p.layouts?.[ie] : null)?.regions || { main: { label: "Content" } }
|
|
9157
9228
|
};
|
|
9158
|
-
for (let [e, n] of Object.entries(
|
|
9159
|
-
let r =
|
|
9160
|
-
if (
|
|
9161
|
-
let n = await
|
|
9162
|
-
if (n.blocks.length > 0 && (
|
|
9229
|
+
for (let [e, n] of Object.entries(de)) {
|
|
9230
|
+
let r = N[e] && N[e].length > 0, i = !!T[e];
|
|
9231
|
+
if (N[e] || (N[e] = [], P[e] = { isInherited: !1 }), (n?.inherit === "parent" || n?.inherit === !0 || n?.inherit === "true" || e === "header" || e === "footer") && !r && !i && y) {
|
|
9232
|
+
let n = await zi(t, y, e, p, o);
|
|
9233
|
+
if (n.blocks.length > 0 && (N[e] = n.blocks, P[e] = {
|
|
9163
9234
|
isInherited: !0,
|
|
9164
9235
|
inheritedFromId: n.inheritedFromId,
|
|
9165
9236
|
inheritedFromTitle: n.inheritedFromTitle
|
|
9166
|
-
}, n.subRegions)) for (let [t, r] of Object.entries(n.subRegions)) t !== e && (
|
|
9237
|
+
}, n.subRegions)) for (let [t, r] of Object.entries(n.subRegions)) t !== e && (N[t] = r, P[t] = {
|
|
9167
9238
|
isInherited: !0,
|
|
9168
9239
|
inheritedFromId: n.inheritedFromId,
|
|
9169
9240
|
inheritedFromTitle: n.inheritedFromTitle
|
|
9170
9241
|
});
|
|
9171
9242
|
}
|
|
9172
9243
|
}
|
|
9173
|
-
for (let e of Object.keys(
|
|
9174
|
-
let
|
|
9244
|
+
for (let e of Object.keys(N)) await Ri(t, N[e], l);
|
|
9245
|
+
let fe = {
|
|
9175
9246
|
channelId: l || u,
|
|
9176
9247
|
treeId: v,
|
|
9177
9248
|
language: x.language,
|
|
9178
9249
|
node: x,
|
|
9179
|
-
content:
|
|
9180
|
-
regionMeta:
|
|
9250
|
+
content: N,
|
|
9251
|
+
regionMeta: P
|
|
9181
9252
|
};
|
|
9182
|
-
return o || (await d.set(f,
|
|
9253
|
+
return o || (await d.set(f, fe, 300), e.header("X-Cache", "MISS")), e.json(fe);
|
|
9183
9254
|
} catch (t) {
|
|
9184
9255
|
return console.error("[CMS Public API] Error fetching node by path:", t), e.json({
|
|
9185
9256
|
error: "Failed to fetch JSON payload",
|
|
@@ -9189,8 +9260,8 @@ Pi.get("/*", async (e) => {
|
|
|
9189
9260
|
});
|
|
9190
9261
|
//#endregion
|
|
9191
9262
|
//#region server/routes/public/tree.ts
|
|
9192
|
-
var
|
|
9193
|
-
function
|
|
9263
|
+
var qi = new e();
|
|
9264
|
+
function Ji(e, t) {
|
|
9194
9265
|
let n = /* @__PURE__ */ new Date();
|
|
9195
9266
|
if (e && String(e).trim() !== "") {
|
|
9196
9267
|
let t = new Date(e);
|
|
@@ -9202,7 +9273,7 @@ function qi(e, t) {
|
|
|
9202
9273
|
}
|
|
9203
9274
|
return !0;
|
|
9204
9275
|
}
|
|
9205
|
-
|
|
9276
|
+
qi.get("/:treeParam", async (e) => {
|
|
9206
9277
|
try {
|
|
9207
9278
|
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";
|
|
9208
9279
|
if (r && r !== "default" && r !== "all") {
|
|
@@ -9221,7 +9292,7 @@ Ki.get("/:treeParam", async (e) => {
|
|
|
9221
9292
|
if (c && c.isHidden && !i) return e.json({ error: `Tree '${n}' is hidden` }, 404);
|
|
9222
9293
|
let l = c?.id || (s ? Number(n) : null), u = {};
|
|
9223
9294
|
if (c && c.dataJson) try {
|
|
9224
|
-
let t = typeof c.dataJson == "string" ? JSON.parse(c.dataJson) : c.dataJson, r = e.env?.BUNDLED_DEFINITIONS, i =
|
|
9295
|
+
let t = typeof c.dataJson == "string" ? JSON.parse(c.dataJson) : c.dataJson, r = e.env?.BUNDLED_DEFINITIONS, i = ui(r), a = (i.trees?.[c.treeType || n] || i.trees?.site || {}).fields || {};
|
|
9225
9296
|
for (let [e, n] of Object.entries(t)) a[e]?.public === !0 && (u[e] = n);
|
|
9226
9297
|
} catch (e) {
|
|
9227
9298
|
console.warn("[CMS Public Tree API] Failed to parse tree dataJson", e);
|
|
@@ -9241,7 +9312,7 @@ Ki.get("/:treeParam", async (e) => {
|
|
|
9241
9312
|
if (r) try {
|
|
9242
9313
|
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;
|
|
9243
9314
|
} catch {}
|
|
9244
|
-
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 =
|
|
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 = Ji(n.startShowingAt, n.stopShowingAt), c = (e.slug || "").replace(/^\/+|\/+$/g, ""), l = c === "home" || c === "homee" ? "/" : `${t}/${c}`.replace(/\/+/g, "/"), u = {
|
|
9245
9316
|
id: e.id,
|
|
9246
9317
|
treeNodeId: e.treeNodeId,
|
|
9247
9318
|
parentId: e.parentId || null,
|
|
@@ -9276,8 +9347,8 @@ Ki.get("/:treeParam", async (e) => {
|
|
|
9276
9347
|
});
|
|
9277
9348
|
//#endregion
|
|
9278
9349
|
//#region server/routes/public/assets.ts
|
|
9279
|
-
var
|
|
9280
|
-
function
|
|
9350
|
+
var Yi = new e();
|
|
9351
|
+
function Xi(e, t) {
|
|
9281
9352
|
if (t === "webp") return "image/webp";
|
|
9282
9353
|
if (t === "avif") return "image/avif";
|
|
9283
9354
|
if (t === "jpeg" || t === "jpg") return "image/jpeg";
|
|
@@ -9285,7 +9356,7 @@ function Yi(e, t) {
|
|
|
9285
9356
|
let n = e.toLowerCase();
|
|
9286
9357
|
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";
|
|
9287
9358
|
}
|
|
9288
|
-
|
|
9359
|
+
Yi.get("/*", async (e) => {
|
|
9289
9360
|
let t = e.req.path.replace(/^\/media\//, "").replace(/^\//, "");
|
|
9290
9361
|
if (!t) return e.text("Asset key missing", 400);
|
|
9291
9362
|
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");
|
|
@@ -9331,7 +9402,7 @@ Ji.get("/*", async (e) => {
|
|
|
9331
9402
|
if (!s) {
|
|
9332
9403
|
let n = u(g);
|
|
9333
9404
|
return e.body(n, 200, {
|
|
9334
|
-
"Content-Type":
|
|
9405
|
+
"Content-Type": Xi(t),
|
|
9335
9406
|
"Cache-Control": "public, max-age=86400"
|
|
9336
9407
|
});
|
|
9337
9408
|
}
|
|
@@ -9339,7 +9410,7 @@ Ji.get("/*", async (e) => {
|
|
|
9339
9410
|
if (l(b)) {
|
|
9340
9411
|
let n = u(b);
|
|
9341
9412
|
return e.body(n, 200, {
|
|
9342
|
-
"Content-Type":
|
|
9413
|
+
"Content-Type": Xi(t, v),
|
|
9343
9414
|
"Cache-Control": "public, max-age=31536000, immutable",
|
|
9344
9415
|
"X-Local-Cache": "HIT"
|
|
9345
9416
|
});
|
|
@@ -9352,14 +9423,14 @@ Ji.get("/*", async (e) => {
|
|
|
9352
9423
|
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 }));
|
|
9353
9424
|
let o = await i.toBuffer();
|
|
9354
9425
|
return d(m(b), { recursive: !0 }), f(b, o), e.body(o, 200, {
|
|
9355
|
-
"Content-Type":
|
|
9426
|
+
"Content-Type": Xi(t, v),
|
|
9356
9427
|
"Cache-Control": "public, max-age=31536000, immutable",
|
|
9357
9428
|
"X-Local-Cache": "MISS"
|
|
9358
9429
|
});
|
|
9359
9430
|
} catch {
|
|
9360
9431
|
let n = u(g);
|
|
9361
9432
|
return e.body(n, 200, {
|
|
9362
|
-
"Content-Type":
|
|
9433
|
+
"Content-Type": Xi(t),
|
|
9363
9434
|
"Cache-Control": "public, max-age=86400"
|
|
9364
9435
|
});
|
|
9365
9436
|
}
|
|
@@ -9370,8 +9441,8 @@ Ji.get("/*", async (e) => {
|
|
|
9370
9441
|
});
|
|
9371
9442
|
//#endregion
|
|
9372
9443
|
//#region server/routes/public/paths.ts
|
|
9373
|
-
var
|
|
9374
|
-
function
|
|
9444
|
+
var Zi = new e();
|
|
9445
|
+
function Qi(e, t) {
|
|
9375
9446
|
let n = /* @__PURE__ */ new Date();
|
|
9376
9447
|
if (e && String(e).trim() !== "") {
|
|
9377
9448
|
let t = new Date(e);
|
|
@@ -9383,7 +9454,7 @@ function Zi(e, t) {
|
|
|
9383
9454
|
}
|
|
9384
9455
|
return !0;
|
|
9385
9456
|
}
|
|
9386
|
-
|
|
9457
|
+
Zi.get("/", async (e) => {
|
|
9387
9458
|
try {
|
|
9388
9459
|
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 = [];
|
|
9389
9460
|
function i(e = null, t = "") {
|
|
@@ -9396,7 +9467,7 @@ Xi.get("/", async (e) => {
|
|
|
9396
9467
|
if (e.dataJson) try {
|
|
9397
9468
|
n = typeof e.dataJson == "string" ? JSON.parse(e.dataJson) : e.dataJson;
|
|
9398
9469
|
} catch {}
|
|
9399
|
-
let a = e.status === "published" || e.status === "active", o =
|
|
9470
|
+
let a = e.status === "published" || e.status === "active", o = Qi(n.startShowingAt, n.stopShowingAt);
|
|
9400
9471
|
if (!a || !o) continue;
|
|
9401
9472
|
let s = (e.slug || "").replace(/^\/+|\/+$/g, ""), c = s === "home" || s === "homee" ? "/" : `${t}/${s}`.replace(/\/+/g, "/");
|
|
9402
9473
|
e.nodeType !== "external-link" && r.push(c);
|
|
@@ -9413,7 +9484,7 @@ Xi.get("/", async (e) => {
|
|
|
9413
9484
|
});
|
|
9414
9485
|
//#endregion
|
|
9415
9486
|
//#region server/index.ts
|
|
9416
|
-
var $ = new e(),
|
|
9487
|
+
var $ = new e(), $i = !1;
|
|
9417
9488
|
$.use("*", o()), $.use("/media/*", o({
|
|
9418
9489
|
origin: "*",
|
|
9419
9490
|
allowMethods: [
|
|
@@ -9434,13 +9505,13 @@ $.use("*", o()), $.use("/media/*", o({
|
|
|
9434
9505
|
let n = new URL(e.req.url), r = (e.req.header("host") || n.hostname).split(":")[0];
|
|
9435
9506
|
e.set("currentDomain", r);
|
|
9436
9507
|
let i = u(e);
|
|
9437
|
-
if (e.set("db", i),
|
|
9438
|
-
await Pr(i),
|
|
9508
|
+
if (e.set("db", i), !$i) try {
|
|
9509
|
+
await Pr(i), $i = !0;
|
|
9439
9510
|
} catch (e) {
|
|
9440
9511
|
console.error("❌ [CMS Server] Failed to initialize system tables on cold start:", e);
|
|
9441
9512
|
}
|
|
9442
9513
|
await t();
|
|
9443
|
-
}), $.route("/media",
|
|
9514
|
+
}), $.route("/media", Yi), $.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", ji), $.route("/api/cms/stats.json", ji), $.route("/api/cms", bi), $.route("/api/cms/channels", wi), $.route("/api/cms/channels.json", wi), $.route("/api/cms/schemas", Ti), $.route("/api/cms/schemas.json", Ti), $.route("/api/cms", Oi), $.route("/api/admin/assets", Z), $.route("/api/v1/node", Fi), $.route("/api/v1/page", Fi), $.route("/api/v1/tree", qi), $.route("/api/v1/all-paths", Zi), $.get("*", async (e) => {
|
|
9444
9515
|
if (e.env?.ASSETS) {
|
|
9445
9516
|
let t = await e.env.ASSETS.fetch(e.req.raw);
|
|
9446
9517
|
if (t.status === 404) {
|