@nextblock-cms/cortex 0.13.5 → 0.13.7
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.
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { tool as
|
|
2
|
-
import { createCortexDatabaseAgentTools as
|
|
3
|
-
import { createCortexCustomBlockTools as
|
|
4
|
-
import { editorDocumentFromHtml as
|
|
1
|
+
import { tool as S } from "ai";
|
|
2
|
+
import { createCortexDatabaseAgentTools as an } from "./ai-global-agent-db-tools.es.js";
|
|
3
|
+
import { createCortexCustomBlockTools as sn } from "./ai-global-agent-custom-block-tools.es.js";
|
|
4
|
+
import { editorDocumentFromHtml as pt } from "./editor-document-from-html.es.js";
|
|
5
5
|
import "./zod-config.es.js";
|
|
6
6
|
import { z as i } from "zod";
|
|
7
|
-
const
|
|
7
|
+
const K = [
|
|
8
8
|
"text",
|
|
9
9
|
"heading",
|
|
10
10
|
"image",
|
|
@@ -19,7 +19,7 @@ const G = [
|
|
|
19
19
|
"cart",
|
|
20
20
|
"checkout",
|
|
21
21
|
"product_details"
|
|
22
|
-
],
|
|
22
|
+
], ln = 1e4, cn = {
|
|
23
23
|
arabic: "ar",
|
|
24
24
|
chinese: "zh",
|
|
25
25
|
dutch: "nl",
|
|
@@ -34,40 +34,40 @@ const G = [
|
|
|
34
34
|
portuguese: "pt",
|
|
35
35
|
russian: "ru",
|
|
36
36
|
spanish: "es"
|
|
37
|
-
},
|
|
37
|
+
}, mt = i.string().trim().min(1).max(2048).refine(
|
|
38
38
|
(e) => e.startsWith("/") || e.startsWith("#") || e.startsWith("http://") || e.startsWith("https://") || e.startsWith("mailto:") || e.startsWith("tel:"),
|
|
39
39
|
"URL must be a relative path, hash link, http(s) URL, mailto URL, or tel URL."
|
|
40
|
-
),
|
|
40
|
+
), Xe = i.strictObject({
|
|
41
41
|
label: i.string().trim().min(1).max(120),
|
|
42
42
|
target: i.enum(["_self", "_blank"]).optional(),
|
|
43
|
-
url:
|
|
44
|
-
}),
|
|
45
|
-
children: i.array(
|
|
46
|
-
}),
|
|
43
|
+
url: mt
|
|
44
|
+
}), gt = Xe.extend({
|
|
45
|
+
children: i.array(Xe).max(20).optional()
|
|
46
|
+
}), un = i.strictObject({
|
|
47
47
|
label: i.string().trim().min(1).max(120).optional(),
|
|
48
|
-
url:
|
|
48
|
+
url: mt.optional()
|
|
49
49
|
}).refine((e) => !!(e.label || e.url), {
|
|
50
50
|
message: "Navigation item match requires label or url."
|
|
51
51
|
}), de = i.strictObject({
|
|
52
|
-
items: i.array(
|
|
52
|
+
items: i.array(gt).min(1).max(30),
|
|
53
53
|
languageCode: i.string().trim().min(2).max(80).default("en").describe('Locale code or language name, for example "en", "fr", "English", or "French".'),
|
|
54
|
-
match:
|
|
54
|
+
match: un.optional().describe('For mode "update", identifies the existing navigation item to update.'),
|
|
55
55
|
mode: i.enum(["append", "replace", "update"]).default("append")
|
|
56
56
|
}), pe = i.strictObject({
|
|
57
57
|
copyright: i.record(i.string().trim().min(2).max(12), i.string().trim().min(1).max(500)).optional(),
|
|
58
58
|
languageCode: i.string().trim().min(2).max(80).default("en").describe('Locale code or language name, for example "en", "fr", "English", or "French".'),
|
|
59
|
-
links: i.array(
|
|
60
|
-
}),
|
|
59
|
+
links: i.array(gt).min(1).max(30).optional()
|
|
60
|
+
}), je = i.strictObject({
|
|
61
61
|
limit: i.number().int().min(1).max(8).default(4),
|
|
62
62
|
query: i.string().trim().min(2).max(300)
|
|
63
|
-
}),
|
|
63
|
+
}), ft = i.object({
|
|
64
64
|
currency: i.string().trim().min(3).max(3).optional().describe(
|
|
65
65
|
"Optional currency code for currency-specific monetary reports (e.g., USD, CAD). Do not set this for plain order-status counts unless the user asks for a currency."
|
|
66
66
|
),
|
|
67
67
|
query: i.string().describe("The analytical question about orders, products, or revenue."),
|
|
68
68
|
reportType: i.enum(["revenue", "orders", "products", "general"]).optional().default("general").describe("The focus area of the statistical report."),
|
|
69
69
|
timeRange: i.enum(["today", "this_month", "last_7_days", "last_30_days", "last_month", "last_90_days", "all_time"]).optional().default("all_time").describe("The time period for the report. Use all_time for current order-status counts unless the user names a specific period.")
|
|
70
|
-
}),
|
|
70
|
+
}), ht = i.strictObject({
|
|
71
71
|
contentType: i.enum(["page", "post", "product"]),
|
|
72
72
|
currentEditor: i.strictObject({
|
|
73
73
|
blockId: i.union([i.number().int().positive(), i.string().trim().min(1).max(120)]).nullable().optional(),
|
|
@@ -79,7 +79,7 @@ const G = [
|
|
|
79
79
|
slug: i.string().trim().min(1).max(300).nullable().optional(),
|
|
80
80
|
title: i.string().trim().min(1).max(300).nullable().optional(),
|
|
81
81
|
translationGroupId: i.string().trim().min(1).max(120).nullable().optional()
|
|
82
|
-
}),
|
|
82
|
+
}), yt = i.strictObject({
|
|
83
83
|
includeBlockContent: i.boolean().default(!1),
|
|
84
84
|
includeBlocks: i.boolean().default(!0)
|
|
85
85
|
}), me = i.strictObject({
|
|
@@ -101,30 +101,30 @@ const G = [
|
|
|
101
101
|
}).partial()
|
|
102
102
|
}), ge = i.strictObject({
|
|
103
103
|
blockId: i.number().int().positive(),
|
|
104
|
-
blockType: i.enum(
|
|
104
|
+
blockType: i.enum(K).optional(),
|
|
105
105
|
content: i.record(i.string(), i.unknown())
|
|
106
106
|
}), fe = i.strictObject({
|
|
107
107
|
blockIndex: i.number().int().min(0),
|
|
108
|
-
blockType: i.enum(
|
|
108
|
+
blockType: i.enum(K).optional(),
|
|
109
109
|
columnIndex: i.number().int().min(0),
|
|
110
110
|
content: i.record(i.string(), i.unknown()),
|
|
111
111
|
parentBlockId: i.number().int().positive()
|
|
112
|
-
}),
|
|
113
|
-
contentType:
|
|
112
|
+
}), dn = i.enum(["page", "post", "product"]), H = i.strictObject({
|
|
113
|
+
contentType: dn.optional(),
|
|
114
114
|
entityId: i.union([i.number().int().positive(), i.string().trim().min(1).max(120)]).optional(),
|
|
115
115
|
slug: i.string().trim().min(1).max(300).optional(),
|
|
116
116
|
title: i.string().trim().min(1).max(300).optional()
|
|
117
117
|
}), Q = i.strictObject({
|
|
118
|
-
blockType: i.enum(
|
|
118
|
+
blockType: i.enum(K),
|
|
119
119
|
content: i.record(i.string(), i.unknown()),
|
|
120
120
|
order: i.number().int().min(0).optional()
|
|
121
|
-
}), he =
|
|
121
|
+
}), he = H.extend({
|
|
122
122
|
images: i.array(i.string().trim().min(1).max(2048)).min(1).max(12).describe(
|
|
123
123
|
"External https image URLs (imported into the media library automatically) and/or existing media library ids. The first entry is the feature image (pages/posts) or the main product image (products)."
|
|
124
124
|
)
|
|
125
|
-
}), ye =
|
|
125
|
+
}), ye = H.extend({
|
|
126
126
|
anchorBlockId: i.number().int().positive().optional(),
|
|
127
|
-
anchorBlockType: i.enum(
|
|
127
|
+
anchorBlockType: i.enum(K).optional(),
|
|
128
128
|
block: Q,
|
|
129
129
|
position: i.enum(["before", "after", "start", "end"]).default("end")
|
|
130
130
|
}), _e = i.strictObject({
|
|
@@ -190,13 +190,13 @@ const G = [
|
|
|
190
190
|
trial_requires_payment_method: i.boolean().default(!1),
|
|
191
191
|
translationGroupId: i.string().trim().min(1).max(120).optional(),
|
|
192
192
|
upc: i.string().max(120).nullable().optional()
|
|
193
|
-
}), we =
|
|
193
|
+
}), we = H.extend({
|
|
194
194
|
currencyCode: i.string().trim().min(3).max(3).optional(),
|
|
195
195
|
endsAt: i.string().max(80).nullable().optional(),
|
|
196
196
|
field: i.string().trim().min(1).max(120),
|
|
197
197
|
startsAt: i.string().max(80).nullable().optional(),
|
|
198
198
|
value: i.unknown()
|
|
199
|
-
}),
|
|
199
|
+
}), _t = H, Ie = H, bt = i.discriminatedUnion("tool", [
|
|
200
200
|
i.strictObject({ input: _e, tool: i.literal("create_cms_page") }),
|
|
201
201
|
i.strictObject({ input: be, tool: i.literal("create_cms_post") }),
|
|
202
202
|
i.strictObject({ input: ke, tool: i.literal("create_cms_product") }),
|
|
@@ -209,7 +209,7 @@ const G = [
|
|
|
209
209
|
i.strictObject({ input: de, tool: i.literal("update_navigation_bar") }),
|
|
210
210
|
i.strictObject({ input: fe, tool: i.literal("update_section_column_block") }),
|
|
211
211
|
i.strictObject({ input: he, tool: i.literal("set_content_images") })
|
|
212
|
-
]),
|
|
212
|
+
]), pn = i.union([
|
|
213
213
|
_e.extend({ tool: i.literal("create_cms_page") }).transform(({ tool: e, ...t }) => ({ input: t, tool: e })),
|
|
214
214
|
be.extend({ tool: i.literal("create_cms_post") }).transform(({ tool: e, ...t }) => ({ input: t, tool: e })),
|
|
215
215
|
ke.extend({ tool: i.literal("create_cms_product") }).transform(({ tool: e, ...t }) => ({ input: t, tool: e })),
|
|
@@ -222,21 +222,21 @@ const G = [
|
|
|
222
222
|
de.extend({ tool: i.literal("update_navigation_bar") }).transform(({ tool: e, ...t }) => ({ input: t, tool: e })),
|
|
223
223
|
fe.extend({ tool: i.literal("update_section_column_block") }).transform(({ tool: e, ...t }) => ({ input: t, tool: e })),
|
|
224
224
|
he.extend({ tool: i.literal("set_content_images") }).transform(({ tool: e, ...t }) => ({ input: t, tool: e }))
|
|
225
|
-
]),
|
|
226
|
-
const n =
|
|
225
|
+
]), mn = i.string().transform((e, t) => {
|
|
226
|
+
const n = _n(e);
|
|
227
227
|
return n.success ? n.action : (t.addIssue({
|
|
228
228
|
code: "custom",
|
|
229
229
|
message: n.message
|
|
230
230
|
}), i.NEVER);
|
|
231
|
-
}),
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
]),
|
|
236
|
-
actions: i.array(
|
|
231
|
+
}), gn = i.union([
|
|
232
|
+
bt,
|
|
233
|
+
pn,
|
|
234
|
+
mn
|
|
235
|
+
]), kt = i.strictObject({
|
|
236
|
+
actions: i.array(gn).min(1).max(8),
|
|
237
237
|
summary: i.string().trim().min(1).max(500).optional()
|
|
238
238
|
});
|
|
239
|
-
function
|
|
239
|
+
function fn(e) {
|
|
240
240
|
const t = [];
|
|
241
241
|
let n = "", r = 0, o = null, a = !1;
|
|
242
242
|
for (const s of e) {
|
|
@@ -264,7 +264,7 @@ function gn(e) {
|
|
|
264
264
|
}
|
|
265
265
|
return n.trim() && t.push(n.trim()), t;
|
|
266
266
|
}
|
|
267
|
-
function
|
|
267
|
+
function Qe(e) {
|
|
268
268
|
let t = "";
|
|
269
269
|
for (let n = 0; n < e.length; n++) {
|
|
270
270
|
const r = e[n];
|
|
@@ -291,24 +291,24 @@ function Xe(e) {
|
|
|
291
291
|
}
|
|
292
292
|
return t.replace(/\bTrue\b/g, "true").replace(/\bFalse\b/g, "false").replace(/\bNone\b/g, "null");
|
|
293
293
|
}
|
|
294
|
-
function
|
|
294
|
+
function hn(e) {
|
|
295
295
|
const t = e.trim();
|
|
296
|
-
return t.startsWith("'") && t.endsWith("'") || t.startsWith('"') && t.endsWith('"') || t.startsWith("[") || t.startsWith("{") ? JSON.parse(
|
|
296
|
+
return t.startsWith("'") && t.endsWith("'") || t.startsWith('"') && t.endsWith('"') || t.startsWith("[") || t.startsWith("{") ? JSON.parse(Qe(t)) : /^-?\d+(?:\.\d+)?$/.test(t) ? Number(t) : t === "true" || t === "True" ? !0 : t === "false" || t === "False" ? !1 : t === "null" || t === "None" ? null : t;
|
|
297
297
|
}
|
|
298
|
-
function
|
|
298
|
+
function yn(e) {
|
|
299
299
|
const t = {};
|
|
300
|
-
for (const n of
|
|
300
|
+
for (const n of fn(e)) {
|
|
301
301
|
const r = n.indexOf("=");
|
|
302
302
|
if (r <= 0)
|
|
303
303
|
throw new Error(`Expected key=value argument, received "${n}".`);
|
|
304
304
|
const o = n.slice(0, r).trim();
|
|
305
305
|
if (!/^[A-Za-z_][A-Za-z0-9_]*$/.test(o))
|
|
306
306
|
throw new Error(`Invalid argument name "${o}".`);
|
|
307
|
-
t[o] =
|
|
307
|
+
t[o] = hn(n.slice(r + 1));
|
|
308
308
|
}
|
|
309
309
|
return t;
|
|
310
310
|
}
|
|
311
|
-
function
|
|
311
|
+
function _n(e) {
|
|
312
312
|
const n = e.trim().match(/^([a-z_]+)\(([\s\S]*)\)$/);
|
|
313
313
|
if (!n)
|
|
314
314
|
return {
|
|
@@ -318,14 +318,14 @@ function yn(e) {
|
|
|
318
318
|
const r = n[1];
|
|
319
319
|
let o;
|
|
320
320
|
try {
|
|
321
|
-
o =
|
|
321
|
+
o = yn(n[2]);
|
|
322
322
|
} catch (l) {
|
|
323
323
|
return {
|
|
324
324
|
message: l instanceof Error ? l.message : "Could not parse action-plan command arguments.",
|
|
325
325
|
success: !1
|
|
326
326
|
};
|
|
327
327
|
}
|
|
328
|
-
const a = { input: o, tool: r }, s =
|
|
328
|
+
const a = { input: o, tool: r }, s = bt.safeParse(a);
|
|
329
329
|
return s.success ? {
|
|
330
330
|
action: s.data,
|
|
331
331
|
success: !0
|
|
@@ -334,14 +334,14 @@ function yn(e) {
|
|
|
334
334
|
success: !1
|
|
335
335
|
};
|
|
336
336
|
}
|
|
337
|
-
function
|
|
337
|
+
function bn(e) {
|
|
338
338
|
return e.normalize("NFD").replace(/[\u0300-\u036f]/g, "").toLowerCase().replace(/\s+/g, " ").trim();
|
|
339
339
|
}
|
|
340
340
|
function ne(e, t) {
|
|
341
341
|
return t.some((n) => e.includes(n));
|
|
342
342
|
}
|
|
343
|
-
function
|
|
344
|
-
const t =
|
|
343
|
+
function so(e) {
|
|
344
|
+
const t = bn(e), n = ne(t, ["add ", "insert ", "put ", "create "]), r = ne(t, [
|
|
345
345
|
"title",
|
|
346
346
|
"heading",
|
|
347
347
|
"description",
|
|
@@ -385,12 +385,12 @@ function ao(e) {
|
|
|
385
385
|
summary: "Add visible title and description copy above the forms on the English and French Contact pages."
|
|
386
386
|
};
|
|
387
387
|
}
|
|
388
|
-
const
|
|
388
|
+
const kn = i.enum(K), Ze = i.object({
|
|
389
389
|
direction: i.string().optional(),
|
|
390
390
|
stops: i.array(i.object({ color: i.string(), position: i.number() })),
|
|
391
391
|
type: i.enum(["linear", "radial"])
|
|
392
|
-
}),
|
|
393
|
-
gradient:
|
|
392
|
+
}), wn = i.object({
|
|
393
|
+
gradient: Ze.optional(),
|
|
394
394
|
image: i.object({
|
|
395
395
|
alt_text: i.string().optional(),
|
|
396
396
|
blur_data_url: i.string().optional(),
|
|
@@ -399,7 +399,7 @@ const bn = i.enum(G), Qe = i.object({
|
|
|
399
399
|
media_id: i.string().optional(),
|
|
400
400
|
object_key: i.string().optional(),
|
|
401
401
|
overlay: i.object({
|
|
402
|
-
gradient:
|
|
402
|
+
gradient: Ze,
|
|
403
403
|
type: i.literal("gradient")
|
|
404
404
|
}).optional(),
|
|
405
405
|
position: i.enum(["center", "top", "bottom", "left", "right"]),
|
|
@@ -411,13 +411,13 @@ const bn = i.enum(G), Qe = i.object({
|
|
|
411
411
|
solid_color: i.string().optional(),
|
|
412
412
|
theme: i.enum(["primary", "secondary", "muted", "accent", "destructive"]).optional(),
|
|
413
413
|
type: i.enum(["none", "theme", "solid", "gradient", "image"])
|
|
414
|
-
}),
|
|
415
|
-
block_type:
|
|
414
|
+
}), In = i.object({
|
|
415
|
+
block_type: kn,
|
|
416
416
|
content: i.record(i.string(), i.any()),
|
|
417
417
|
temp_id: i.string().optional()
|
|
418
|
-
}),
|
|
419
|
-
background:
|
|
420
|
-
column_blocks: i.array(i.array(
|
|
418
|
+
}), Tn = i.object({
|
|
419
|
+
background: wn,
|
|
420
|
+
column_blocks: i.array(i.array(In)),
|
|
421
421
|
column_gap: i.enum(["none", "sm", "md", "lg", "xl"]),
|
|
422
422
|
container_type: i.enum(["full-width", "container", "container-sm", "container-lg", "container-xl"]),
|
|
423
423
|
padding: i.object({
|
|
@@ -430,7 +430,7 @@ const bn = i.enum(G), Qe = i.object({
|
|
|
430
430
|
tablet: i.union([i.literal(1), i.literal(2), i.literal(3)])
|
|
431
431
|
}),
|
|
432
432
|
vertical_alignment: i.enum(["start", "center", "end", "stretch"]).optional()
|
|
433
|
-
}),
|
|
433
|
+
}), xn = {
|
|
434
434
|
button: i.object({
|
|
435
435
|
position: i.enum(["left", "center", "right"]).optional(),
|
|
436
436
|
size: i.enum(["default", "sm", "lg", "full"]).optional(),
|
|
@@ -488,7 +488,7 @@ const bn = i.enum(G), Qe = i.object({
|
|
|
488
488
|
title: i.string().optional(),
|
|
489
489
|
type: i.enum(["latest", "category"]).default("latest")
|
|
490
490
|
}),
|
|
491
|
-
section:
|
|
491
|
+
section: Tn,
|
|
492
492
|
testimonial: i.object({
|
|
493
493
|
author_name: i.string().min(1),
|
|
494
494
|
author_title: i.string().optional(),
|
|
@@ -505,17 +505,17 @@ const bn = i.enum(G), Qe = i.object({
|
|
|
505
505
|
url: i.string()
|
|
506
506
|
})
|
|
507
507
|
};
|
|
508
|
-
function xn(e) {
|
|
509
|
-
return G.includes(e);
|
|
510
|
-
}
|
|
511
508
|
function Cn(e) {
|
|
509
|
+
return K.includes(e);
|
|
510
|
+
}
|
|
511
|
+
function Sn(e) {
|
|
512
512
|
return typeof e?.validateBlockContent == "function" ? e.validateBlockContent : null;
|
|
513
513
|
}
|
|
514
514
|
function vn(e, t, n) {
|
|
515
|
-
const r =
|
|
515
|
+
const r = Sn(n);
|
|
516
516
|
if (r)
|
|
517
517
|
return r(e, t);
|
|
518
|
-
const o =
|
|
518
|
+
const o = xn[e].safeParse(t);
|
|
519
519
|
return o.success ? { errors: [], isValid: !0, warnings: [] } : {
|
|
520
520
|
errors: o.error.issues.map((a) => {
|
|
521
521
|
const s = a.path.join(".");
|
|
@@ -525,13 +525,13 @@ function vn(e, t, n) {
|
|
|
525
525
|
warnings: []
|
|
526
526
|
};
|
|
527
527
|
}
|
|
528
|
-
function
|
|
528
|
+
function et() {
|
|
529
529
|
return i.object({
|
|
530
530
|
content: i.array(i.any()).optional(),
|
|
531
531
|
type: i.literal("doc")
|
|
532
532
|
});
|
|
533
533
|
}
|
|
534
|
-
function
|
|
534
|
+
function Le() {
|
|
535
535
|
try {
|
|
536
536
|
const { revalidatePath: e } = require("next/cache");
|
|
537
537
|
return e;
|
|
@@ -539,12 +539,12 @@ function je() {
|
|
|
539
539
|
return null;
|
|
540
540
|
}
|
|
541
541
|
}
|
|
542
|
-
function
|
|
542
|
+
function C(e) {
|
|
543
543
|
if (!e?.supabase)
|
|
544
544
|
throw new Error("A Supabase service client is required to execute Cortex AI global tools.");
|
|
545
545
|
return e.supabase;
|
|
546
546
|
}
|
|
547
|
-
function
|
|
547
|
+
function En(e, t, n) {
|
|
548
548
|
let r;
|
|
549
549
|
const o = new Promise((a) => {
|
|
550
550
|
r = setTimeout(() => a(n()), t);
|
|
@@ -556,38 +556,38 @@ function Sn(e, t, n) {
|
|
|
556
556
|
o
|
|
557
557
|
]);
|
|
558
558
|
}
|
|
559
|
-
function
|
|
560
|
-
const t =
|
|
559
|
+
function V(e) {
|
|
560
|
+
const t = ht.safeParse(e?.pageContext);
|
|
561
561
|
if (!t.success)
|
|
562
562
|
throw new Error(
|
|
563
563
|
"No current CMS page context is available. Open a page, post, or product edit screen before using this editing tool."
|
|
564
564
|
);
|
|
565
565
|
return t.data;
|
|
566
566
|
}
|
|
567
|
-
function
|
|
567
|
+
function Be(e) {
|
|
568
568
|
const t = typeof e.entityId == "number" ? e.entityId : Number.parseInt(e.entityId, 10);
|
|
569
569
|
if (!Number.isInteger(t) || t <= 0)
|
|
570
570
|
throw new Error(`Current ${e.contentType} id must be a positive integer.`);
|
|
571
571
|
return t;
|
|
572
572
|
}
|
|
573
|
-
function
|
|
573
|
+
function wt(e) {
|
|
574
574
|
const t = String(e.entityId || "").trim();
|
|
575
575
|
if (!t)
|
|
576
576
|
throw new Error(`Current ${e.contentType} id is missing.`);
|
|
577
577
|
return t;
|
|
578
578
|
}
|
|
579
579
|
function Te(e) {
|
|
580
|
-
return e.contentType === "product" ?
|
|
580
|
+
return e.contentType === "product" ? wt(e) : Be(e);
|
|
581
581
|
}
|
|
582
|
-
const
|
|
582
|
+
const $n = /^https?:\/\//i, An = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
|
|
583
583
|
async function Z(e, t, n) {
|
|
584
584
|
if (typeof e != "string")
|
|
585
585
|
return null;
|
|
586
586
|
const r = e.trim();
|
|
587
587
|
if (!r)
|
|
588
588
|
return null;
|
|
589
|
-
if (
|
|
590
|
-
if (
|
|
589
|
+
if (!$n.test(r)) {
|
|
590
|
+
if (An.test(r))
|
|
591
591
|
return r;
|
|
592
592
|
throw new Error(
|
|
593
593
|
`"${r}" is not a usable image reference — provide an https:// image URL or a media library id.`
|
|
@@ -603,7 +603,7 @@ async function Z(e, t, n) {
|
|
|
603
603
|
throw new Error(`I could not import the image from that URL: ${a.error}`);
|
|
604
604
|
return a.id;
|
|
605
605
|
}
|
|
606
|
-
async function
|
|
606
|
+
async function It(e, t, n) {
|
|
607
607
|
const r = [];
|
|
608
608
|
for (let o = 0; o < e.length; o += 1) {
|
|
609
609
|
const a = await Z(
|
|
@@ -615,7 +615,7 @@ async function wt(e, t, n) {
|
|
|
615
615
|
}
|
|
616
616
|
return r;
|
|
617
617
|
}
|
|
618
|
-
async function
|
|
618
|
+
async function Pn(e) {
|
|
619
619
|
const t = [...new Set(e.mediaIds)], { error: n } = await e.supabase.from("product_media").delete().eq("product_id", e.productId);
|
|
620
620
|
if (n)
|
|
621
621
|
throw new Error(
|
|
@@ -634,54 +634,75 @@ async function An(e) {
|
|
|
634
634
|
}
|
|
635
635
|
return t;
|
|
636
636
|
}
|
|
637
|
-
function
|
|
637
|
+
async function xe(e) {
|
|
638
|
+
if (!e.productId)
|
|
639
|
+
return !1;
|
|
640
|
+
const { data: t, error: n } = await e.supabase.from("product_drafts").select("id, blocks, meta").eq("product_id", e.productId).maybeSingle();
|
|
641
|
+
if (n || !t)
|
|
642
|
+
return !1;
|
|
643
|
+
const r = e.patch({
|
|
644
|
+
blocks: Array.isArray(t.blocks) ? z(t.blocks) : [],
|
|
645
|
+
meta: $(t.meta) ? z(t.meta) : {}
|
|
646
|
+
}), o = { updated_at: (/* @__PURE__ */ new Date()).toISOString() };
|
|
647
|
+
if (r.blocks && (o.blocks = r.blocks), r.meta && (o.meta = r.meta), Object.keys(o).length === 1)
|
|
648
|
+
return !1;
|
|
649
|
+
const { error: a } = await e.supabase.from("product_drafts").update(o).eq("id", t.id);
|
|
650
|
+
if (a)
|
|
651
|
+
throw new Error(
|
|
652
|
+
`The product was updated, but its open draft could not be kept in sync: ${_(
|
|
653
|
+
a
|
|
654
|
+
)}. Publishing that draft would undo this change — publish or discard it in the product editor first.`
|
|
655
|
+
);
|
|
656
|
+
return !0;
|
|
657
|
+
}
|
|
658
|
+
function Tt(e) {
|
|
638
659
|
return typeof e == "string" ? e.trim().replace(/^\/+|\/+$/g, "") : "";
|
|
639
660
|
}
|
|
640
|
-
function
|
|
641
|
-
const n =
|
|
661
|
+
function Nn(e, t) {
|
|
662
|
+
const n = Tt(t ?? e.slug);
|
|
642
663
|
return n ? e.contentType === "page" ? n === "home" ? "/" : `/${n}` : e.contentType === "post" ? `/article/${n}` : `/product/${n}` : null;
|
|
643
664
|
}
|
|
644
|
-
function
|
|
665
|
+
function Un(e) {
|
|
645
666
|
const t = String(e.entityId);
|
|
646
667
|
return e.contentType === "page" ? `/cms/pages/${t}/edit` : e.contentType === "post" ? `/cms/posts/${t}/edit` : `/cms/products/${t}/edit`;
|
|
647
668
|
}
|
|
648
669
|
function U(e, t, n) {
|
|
649
|
-
const r = e?.revalidatePath ??
|
|
670
|
+
const r = e?.revalidatePath ?? Le();
|
|
650
671
|
if (!r)
|
|
651
672
|
return;
|
|
652
|
-
r(
|
|
653
|
-
const o =
|
|
673
|
+
r(Un(t));
|
|
674
|
+
const o = Nn(t, n);
|
|
654
675
|
o && r(o), t.contentType === "page" && o !== "/" && r("/"), t.contentType === "product" && r("/cms/products");
|
|
655
676
|
}
|
|
656
|
-
function
|
|
657
|
-
const t = e?.revalidatePath ??
|
|
677
|
+
function xt(e) {
|
|
678
|
+
const t = e?.revalidatePath ?? Le();
|
|
658
679
|
t && (t("/", "layout"), t("/cms/navigation"));
|
|
659
680
|
}
|
|
660
681
|
function _(e) {
|
|
661
682
|
return e ? typeof e == "object" && "message" in e ? String(e.message || "Unknown database error.") : String(e) : "Unknown database error.";
|
|
662
683
|
}
|
|
663
|
-
async function
|
|
684
|
+
async function On() {
|
|
664
685
|
return import("./ai-global-agent-ecommerce.es.js");
|
|
665
686
|
}
|
|
666
|
-
function
|
|
667
|
-
return e === null || typeof e != "object" ? JSON.stringify(e) : Array.isArray(e) ? `[${e.map((t) =>
|
|
687
|
+
function Ee(e) {
|
|
688
|
+
return e === null || typeof e != "object" ? JSON.stringify(e) : Array.isArray(e) ? `[${e.map((t) => Ee(t)).join(",")}]` : `{${Object.keys(e).filter((t) => t !== "temp_id").sort().map((t) => `${JSON.stringify(t)}:${Ee(e[t])}`).join(",")}}`;
|
|
668
689
|
}
|
|
669
|
-
function
|
|
690
|
+
function Fn(e) {
|
|
670
691
|
let t = 2166136261;
|
|
671
|
-
const n =
|
|
692
|
+
const n = Ee(e);
|
|
672
693
|
for (let r = 0; r < n.length; r++)
|
|
673
694
|
t ^= n.charCodeAt(r), t = Math.imul(t, 16777619);
|
|
674
695
|
return (t >>> 0).toString(16).padStart(8, "0");
|
|
675
696
|
}
|
|
676
|
-
function
|
|
697
|
+
function $e(e) {
|
|
677
698
|
return e.replace(/\s+/g, " ").trim().toUpperCase();
|
|
678
699
|
}
|
|
679
|
-
function
|
|
680
|
-
return `${
|
|
700
|
+
function jn(e, t, n) {
|
|
701
|
+
return `${$e(`CONFIRM ${e} ${t}`)} #${Fn(n)}`;
|
|
681
702
|
}
|
|
682
|
-
function
|
|
703
|
+
function Ct(e) {
|
|
683
704
|
return {
|
|
684
|
-
confirmationPhrase:
|
|
705
|
+
confirmationPhrase: jn(
|
|
685
706
|
e.action,
|
|
686
707
|
e.subject,
|
|
687
708
|
e.payload
|
|
@@ -703,16 +724,16 @@ function M(e, t) {
|
|
|
703
724
|
function N(e, t, n = `${t}s`) {
|
|
704
725
|
return `${e} ${e === 1 ? t : n}`;
|
|
705
726
|
}
|
|
706
|
-
function
|
|
727
|
+
function Ln(e, t) {
|
|
707
728
|
const n = O(t, "summary");
|
|
708
729
|
if (n)
|
|
709
730
|
return n;
|
|
710
|
-
const r = O(t, "title"), o = O(t, "slug"), a = O(t, "status"), s = O(t, "contentType"), l = O(t, "field"), u = O(t, "mode"), d = O(t, "languageCode"), c = M(t, "blockCount"),
|
|
731
|
+
const r = O(t, "title"), o = O(t, "slug"), a = O(t, "status"), s = O(t, "contentType"), l = O(t, "field"), u = O(t, "mode"), d = O(t, "languageCode"), c = M(t, "blockCount"), m = M(t, "itemCount"), h = M(t, "affectedCount");
|
|
711
732
|
if (e === "create_cms_page" || e === "create_cms_post")
|
|
712
733
|
return `Create ${a || "draft"} ${e === "create_cms_page" ? "page" : "post"} "${r || o || "Untitled"}"${o ? ` at slug "${o}"` : ""}${c !== null ? ` with ${N(c, "content block")}` : ""}.`;
|
|
713
734
|
if (e === "create_cms_product") {
|
|
714
|
-
const
|
|
715
|
-
|
|
735
|
+
const p = M(t, "imageCount"), g = M(t, "blockCount"), f = [
|
|
736
|
+
p ? N(p, "image") : null,
|
|
716
737
|
g ? N(g, "description block") : M(t, "descriptionLength") ? "a full description" : null
|
|
717
738
|
].filter(Boolean);
|
|
718
739
|
return `Create ${a || "draft"} product "${r || o || "Untitled"}"${o ? ` at slug "${o}"` : ""}${f.length ? ` with ${f.join(" and ")}` : ""}.`;
|
|
@@ -720,35 +741,35 @@ function jn(e, t) {
|
|
|
720
741
|
if (e === "update_cms_item_field")
|
|
721
742
|
return `Update ${l || "one field"} on the ${s || "CMS item"} "${r || o || "selected item"}".`;
|
|
722
743
|
if (e === "update_navigation_bar")
|
|
723
|
-
return `${u === "append" ? "Add" : u === "update" ? "Update" : "Replace"} ${
|
|
744
|
+
return `${u === "append" ? "Add" : u === "update" ? "Update" : "Replace"} ${m !== null ? N(m, "navigation item") : "navigation items"} in the ${d || "selected"} header navigation.`;
|
|
724
745
|
if (e === "update_footer") {
|
|
725
|
-
const
|
|
726
|
-
return `Update the ${d || "selected"} footer${
|
|
746
|
+
const p = M(t, "linkCount");
|
|
747
|
+
return `Update the ${d || "selected"} footer${p !== null ? ` with ${N(p, "link")}` : ""}.`;
|
|
727
748
|
}
|
|
728
749
|
return e === "update_content_block" ? `Update the selected ${O(t, "blockType") || "content"} block.` : e === "insert_content_block" ? `Insert ${O(t, "blockType") || "content"} block on the ${s || "CMS item"} "${r || o || "selected item"}".` : e === "update_section_column_block" ? `Update the selected nested ${O(t, "nestedBlockType") || "section"} block.` : e === "delete_cms_item" || e === "prepare_delete_cms_item" ? `Delete ${h !== null ? N(h, s || "CMS item") : `the selected ${s || "CMS item"}`}${r || o ? ` for "${r || o}"` : ""}.` : "Complete the requested CMS change.";
|
|
729
750
|
}
|
|
730
751
|
function P(e) {
|
|
731
752
|
if (e.context?.skipConfirmation)
|
|
732
753
|
return null;
|
|
733
|
-
const t =
|
|
754
|
+
const t = Ct(e), n = $e(e.context?.latestUserMessage || ""), r = $e(t.confirmationPhrase);
|
|
734
755
|
return n.includes(r) ? null : t;
|
|
735
756
|
}
|
|
736
|
-
function
|
|
757
|
+
function Re(e) {
|
|
737
758
|
const t = e?.actorUserId;
|
|
738
759
|
if (!t)
|
|
739
760
|
throw new Error("A confirmed CMS mutation requires an authenticated admin actor.");
|
|
740
761
|
return t;
|
|
741
762
|
}
|
|
742
|
-
function
|
|
763
|
+
function qe() {
|
|
743
764
|
return globalThis.crypto?.randomUUID?.() || `id-${Date.now()}-${Math.random().toString(36).slice(2)}`;
|
|
744
765
|
}
|
|
745
766
|
function R(e) {
|
|
746
767
|
return e.toLowerCase().trim().replace(/\s+/g, "-").replace(/[^a-z0-9-]/g, "").replace(/-+/g, "-").replace(/^-|-$/g, "").slice(0, 300);
|
|
747
768
|
}
|
|
748
|
-
function
|
|
769
|
+
function Me(e) {
|
|
749
770
|
return (e || "USD").trim().toUpperCase();
|
|
750
771
|
}
|
|
751
|
-
const
|
|
772
|
+
const Bn = /* @__PURE__ */ new Set([
|
|
752
773
|
"BIF",
|
|
753
774
|
"CLP",
|
|
754
775
|
"DJF",
|
|
@@ -766,18 +787,18 @@ const Ln = /* @__PURE__ */ new Set([
|
|
|
766
787
|
"XOF",
|
|
767
788
|
"XPF"
|
|
768
789
|
]);
|
|
769
|
-
function
|
|
770
|
-
return
|
|
790
|
+
function Rn(e) {
|
|
791
|
+
return Bn.has(Me(e)) ? 0 : 2;
|
|
771
792
|
}
|
|
772
|
-
function
|
|
773
|
-
return Math.round(e * 10 **
|
|
793
|
+
function St(e, t) {
|
|
794
|
+
return Math.round(e * 10 ** Rn(t));
|
|
774
795
|
}
|
|
775
|
-
function
|
|
796
|
+
function qn(e, t) {
|
|
776
797
|
return !e || typeof e != "object" || Array.isArray(e) ? {} : Object.entries(e).reduce(
|
|
777
798
|
(n, [r, o]) => {
|
|
778
799
|
if (typeof o == "number" && Number.isFinite(o) && o >= 0) {
|
|
779
|
-
const a =
|
|
780
|
-
n[a] =
|
|
800
|
+
const a = Me(r || t);
|
|
801
|
+
n[a] = St(o, a);
|
|
781
802
|
}
|
|
782
803
|
return n;
|
|
783
804
|
},
|
|
@@ -785,35 +806,35 @@ function Rn(e, t) {
|
|
|
785
806
|
);
|
|
786
807
|
}
|
|
787
808
|
function ee(e, t) {
|
|
788
|
-
if (
|
|
809
|
+
if (!$(e))
|
|
789
810
|
throw new Error(`${t} content must be a JSON object.`);
|
|
790
811
|
return JSON.parse(JSON.stringify(e));
|
|
791
812
|
}
|
|
792
|
-
function
|
|
813
|
+
function z(e) {
|
|
793
814
|
return JSON.parse(JSON.stringify(e));
|
|
794
815
|
}
|
|
795
|
-
function
|
|
816
|
+
function $(e) {
|
|
796
817
|
return !!(e && typeof e == "object" && !Array.isArray(e));
|
|
797
818
|
}
|
|
798
|
-
function
|
|
799
|
-
const n =
|
|
819
|
+
function Ae(e, t) {
|
|
820
|
+
const n = z(e);
|
|
800
821
|
for (const [r, o] of Object.entries(t))
|
|
801
822
|
if (o !== void 0) {
|
|
802
|
-
if (
|
|
803
|
-
n[r] =
|
|
823
|
+
if ($(o) && $(n[r])) {
|
|
824
|
+
n[r] = Ae(n[r], o);
|
|
804
825
|
continue;
|
|
805
826
|
}
|
|
806
|
-
n[r] =
|
|
827
|
+
n[r] = z(o);
|
|
807
828
|
}
|
|
808
829
|
return n;
|
|
809
830
|
}
|
|
810
831
|
function vt(e, t) {
|
|
811
832
|
if (t.contentType === "product") {
|
|
812
|
-
if (String(e.product_id ?? "") !== String(
|
|
833
|
+
if (String(e.product_id ?? "") !== String(wt(t)))
|
|
813
834
|
throw new Error(`Block ${e.id} does not belong to the current product being edited.`);
|
|
814
835
|
return;
|
|
815
836
|
}
|
|
816
|
-
const n =
|
|
837
|
+
const n = Be(t);
|
|
817
838
|
if ((t.contentType === "page" ? Number(e.page_id) : Number(e.post_id)) !== n)
|
|
818
839
|
throw new Error(
|
|
819
840
|
`Block ${e.id} does not belong to the current ${t.contentType} being edited.`
|
|
@@ -821,11 +842,11 @@ function vt(e, t) {
|
|
|
821
842
|
}
|
|
822
843
|
function ae(e, t) {
|
|
823
844
|
const n = typeof e == "string" ? e : "";
|
|
824
|
-
if (!
|
|
845
|
+
if (!Cn(n))
|
|
825
846
|
throw new Error(`${t} has unsupported block type "${n || "unknown"}".`);
|
|
826
847
|
return n;
|
|
827
848
|
}
|
|
828
|
-
function
|
|
849
|
+
function Et(e, t, n) {
|
|
829
850
|
if (e && e !== t)
|
|
830
851
|
throw new Error(
|
|
831
852
|
`${n} is a "${t}" block. Refusing to update it as "${e}".`
|
|
@@ -838,22 +859,22 @@ function D(e, t, n, r) {
|
|
|
838
859
|
`${n} content is invalid for block type "${e}": ${o.errors.join("; ")}`
|
|
839
860
|
);
|
|
840
861
|
}
|
|
841
|
-
function
|
|
862
|
+
function $t(e) {
|
|
842
863
|
return e === "section";
|
|
843
864
|
}
|
|
844
|
-
function
|
|
865
|
+
function Mn(e) {
|
|
845
866
|
return typeof e.html_content == "string" ? "text" : typeof e.text == "string" && typeof e.url == "string" ? "button" : typeof e.text_content == "string" ? "heading" : "media_id" in e || "object_key" in e || "external_url" in e ? "image" : typeof e.quote == "string" && typeof e.author_name == "string" ? "testimonial" : typeof e.url == "string" && ("controls" in e || "autoplay" in e || "title" in e) ? "video_embed" : Array.isArray(e.fields) || typeof e.recipient_email == "string" ? "form" : "postsPerPage" in e || "showPagination" in e ? "posts_grid" : typeof e.productId == "string" ? "featured_product" : "limit" in e && "type" in e ? "product_grid" : null;
|
|
846
867
|
}
|
|
847
868
|
function se(e) {
|
|
848
869
|
return `ai-${e}-${Date.now()}-${Math.random().toString(36).slice(2, 8)}`;
|
|
849
870
|
}
|
|
850
|
-
function
|
|
851
|
-
if (
|
|
871
|
+
function Pe(e, t, n) {
|
|
872
|
+
if (!$(e))
|
|
852
873
|
throw new Error(`${t} must be a JSON object.`);
|
|
853
874
|
const r = e.block_type ?? e.blockType, o = ae(r, t);
|
|
854
|
-
if (
|
|
875
|
+
if ($t(o))
|
|
855
876
|
throw new Error(`${t} cannot be a nested ${o} block.`);
|
|
856
|
-
const a =
|
|
877
|
+
const a = Ut(
|
|
857
878
|
o,
|
|
858
879
|
ee(e.content, t),
|
|
859
880
|
t,
|
|
@@ -865,22 +886,22 @@ function Ae(e, t, n) {
|
|
|
865
886
|
temp_id: l
|
|
866
887
|
};
|
|
867
888
|
}
|
|
868
|
-
function
|
|
889
|
+
function Dn(e, t) {
|
|
869
890
|
const n = [];
|
|
870
|
-
if ("append_block" in e && n.push(
|
|
891
|
+
if ("append_block" in e && n.push(Pe(e.append_block, "Nested block to append", t)), "append_blocks" in e) {
|
|
871
892
|
const r = e.append_blocks;
|
|
872
893
|
if (!Array.isArray(r))
|
|
873
894
|
throw new Error("append_blocks must be an array of nested block objects.");
|
|
874
895
|
r.forEach((o, a) => {
|
|
875
|
-
n.push(
|
|
896
|
+
n.push(Pe(o, `Nested block to append ${a}`, t));
|
|
876
897
|
});
|
|
877
898
|
}
|
|
878
899
|
return n;
|
|
879
900
|
}
|
|
880
|
-
function
|
|
901
|
+
function zn(e, t) {
|
|
881
902
|
if ("append_block" in e || "append_blocks" in e || "background" in e || "column_blocks" in e || "column_gap" in e || "container_type" in e || "padding" in e || "responsive_columns" in e || "vertical_alignment" in e)
|
|
882
903
|
return null;
|
|
883
|
-
const n =
|
|
904
|
+
const n = Mn(e);
|
|
884
905
|
if (!n)
|
|
885
906
|
return null;
|
|
886
907
|
const r = ee(e, `Nested ${n} block`);
|
|
@@ -890,7 +911,7 @@ function Dn(e, t) {
|
|
|
890
911
|
temp_id: se(n)
|
|
891
912
|
};
|
|
892
913
|
}
|
|
893
|
-
function
|
|
914
|
+
function Gn(e, t) {
|
|
894
915
|
const n = e.append_column_index ?? e.column_index;
|
|
895
916
|
if (n === void 0)
|
|
896
917
|
return 0;
|
|
@@ -902,14 +923,14 @@ function zn(e, t) {
|
|
|
902
923
|
);
|
|
903
924
|
return n;
|
|
904
925
|
}
|
|
905
|
-
function
|
|
906
|
-
if (
|
|
907
|
-
return
|
|
908
|
-
const o = { ...n }, a =
|
|
926
|
+
function Kn(e, t, n, r) {
|
|
927
|
+
if (!$t(e))
|
|
928
|
+
return Ae(t, n);
|
|
929
|
+
const o = { ...n }, a = Dn(o, r), s = zn(o, r);
|
|
909
930
|
s && a.push(s), delete o.append_block, delete o.append_blocks, delete o.append_column_index, delete o.column_index;
|
|
910
|
-
const l =
|
|
931
|
+
const l = Ae(t, o);
|
|
911
932
|
if (a.length > 0) {
|
|
912
|
-
const u = Array.isArray(t.column_blocks) ?
|
|
933
|
+
const u = Array.isArray(t.column_blocks) ? z(t.column_blocks) : [], d = Gn(n, u.length), c = u.length > 0 ? u : [[]];
|
|
913
934
|
for (; c.length <= d; )
|
|
914
935
|
c.push([]);
|
|
915
936
|
c[d] = [
|
|
@@ -919,7 +940,7 @@ function Gn(e, t, n, r) {
|
|
|
919
940
|
}
|
|
920
941
|
return l;
|
|
921
942
|
}
|
|
922
|
-
function
|
|
943
|
+
function Hn(e, t) {
|
|
923
944
|
return {
|
|
924
945
|
blockType: e.block_type,
|
|
925
946
|
content: t ? e.content : void 0,
|
|
@@ -930,28 +951,28 @@ function Kn(e, t) {
|
|
|
930
951
|
postId: e.post_id
|
|
931
952
|
};
|
|
932
953
|
}
|
|
933
|
-
function
|
|
954
|
+
function G(e) {
|
|
934
955
|
return typeof e == "string" ? e.trim().toLowerCase() : "";
|
|
935
956
|
}
|
|
936
|
-
function
|
|
957
|
+
function tt(e) {
|
|
937
958
|
return typeof e == "string" ? e.trim().toLowerCase() : "";
|
|
938
959
|
}
|
|
939
|
-
function
|
|
960
|
+
function At(e) {
|
|
940
961
|
return e.reduce((t, n) => t + 1 + (n.children?.length || 0), 0);
|
|
941
962
|
}
|
|
942
963
|
function ie(e) {
|
|
943
964
|
return typeof e == "string" ? e.trim().toLowerCase().normalize("NFD").replace(/[\u0300-\u036f]/g, "") : "";
|
|
944
965
|
}
|
|
945
|
-
async function
|
|
946
|
-
const n = t.trim(), r = ie(n), o =
|
|
966
|
+
async function J(e, t) {
|
|
967
|
+
const n = t.trim(), r = ie(n), o = cn[r], { data: a, error: s } = await e.from("languages").select("id, code, name, is_active");
|
|
947
968
|
if (s)
|
|
948
969
|
throw new Error(`Failed to load language "${t}": ${_(s)}`);
|
|
949
970
|
const u = (Array.isArray(a) ? a : []).filter((c) => c.is_active !== !1), d = u.find((c) => {
|
|
950
|
-
const
|
|
951
|
-
return
|
|
971
|
+
const m = ie(c.code), h = ie(c.name);
|
|
972
|
+
return m === r || m === o || h === r;
|
|
952
973
|
});
|
|
953
974
|
if (!d?.id || !d?.code) {
|
|
954
|
-
const c = u.map((
|
|
975
|
+
const c = u.map((m) => m.code).filter(Boolean).join(", ");
|
|
955
976
|
throw new Error(
|
|
956
977
|
`Language "${t}" was not found.${c ? ` Available languages: ${c}.` : ""}`
|
|
957
978
|
);
|
|
@@ -961,9 +982,9 @@ async function V(e, t) {
|
|
|
961
982
|
id: Number(d.id)
|
|
962
983
|
};
|
|
963
984
|
}
|
|
964
|
-
async function
|
|
985
|
+
async function Ce(e, t) {
|
|
965
986
|
if (t)
|
|
966
|
-
return
|
|
987
|
+
return J(e, t);
|
|
967
988
|
const { data: n, error: r } = await e.from("languages").select("id, code, name, is_active, is_default");
|
|
968
989
|
if (r)
|
|
969
990
|
throw new Error(`Failed to load active languages: ${_(r)}`);
|
|
@@ -977,18 +998,18 @@ async function xe(e, t) {
|
|
|
977
998
|
id: Number(a.id)
|
|
978
999
|
};
|
|
979
1000
|
}
|
|
980
|
-
async function
|
|
1001
|
+
async function nt(e) {
|
|
981
1002
|
try {
|
|
982
1003
|
const { data: t, error: n } = await e.from("currencies").select("code, is_default, is_active").eq("is_active", !0);
|
|
983
1004
|
if (n)
|
|
984
1005
|
return "USD";
|
|
985
1006
|
const r = Array.isArray(t) ? t : [], o = r.find((a) => a.is_default) || r[0];
|
|
986
|
-
return
|
|
1007
|
+
return Me(o?.code || "USD");
|
|
987
1008
|
} catch {
|
|
988
1009
|
return "USD";
|
|
989
1010
|
}
|
|
990
1011
|
}
|
|
991
|
-
async function
|
|
1012
|
+
async function Vn(e) {
|
|
992
1013
|
const t = e.contentType === "page" ? "pages" : e.contentType === "post" ? "posts" : "products";
|
|
993
1014
|
let n = "id", r = e.entityId;
|
|
994
1015
|
if (r === void 0 && e.slug && (n = "slug", r = e.slug), r === void 0 && e.title && (n = "title", r = e.title), r === void 0)
|
|
@@ -1004,14 +1025,14 @@ async function Hn(e) {
|
|
|
1004
1025
|
return s[0];
|
|
1005
1026
|
}
|
|
1006
1027
|
async function te(e, t) {
|
|
1007
|
-
const n =
|
|
1028
|
+
const n = ht.safeParse(t?.pageContext).success ? t?.pageContext : null, r = e.contentType || n?.contentType;
|
|
1008
1029
|
if (!r)
|
|
1009
1030
|
throw new Error("Target contentType is required when no current CMS edit context exists.");
|
|
1010
|
-
const o = e.entityId !== void 0 || !!e.slug || !!e.title, a = e.entityId ?? (o ? void 0 : n?.entityId), s = e.slug ?? (o ? void 0 : n?.slug ?? void 0), l = e.title ?? (o ? void 0 : n?.title ?? void 0), u = await
|
|
1031
|
+
const o = e.entityId !== void 0 || !!e.slug || !!e.title, a = e.entityId ?? (o ? void 0 : n?.entityId), s = e.slug ?? (o ? void 0 : n?.slug ?? void 0), l = e.title ?? (o ? void 0 : n?.title ?? void 0), u = await Vn({
|
|
1011
1032
|
contentType: r,
|
|
1012
1033
|
entityId: a,
|
|
1013
1034
|
slug: a === void 0 && s || void 0,
|
|
1014
|
-
supabase:
|
|
1035
|
+
supabase: C(t),
|
|
1015
1036
|
title: a === void 0 && !s && l || void 0
|
|
1016
1037
|
});
|
|
1017
1038
|
return {
|
|
@@ -1020,7 +1041,7 @@ async function te(e, t) {
|
|
|
1020
1041
|
};
|
|
1021
1042
|
}
|
|
1022
1043
|
async function le(e) {
|
|
1023
|
-
const t = await
|
|
1044
|
+
const t = await Wn({
|
|
1024
1045
|
item: e.item,
|
|
1025
1046
|
languageId: e.languageId,
|
|
1026
1047
|
menuKey: e.menuKey,
|
|
@@ -1039,15 +1060,15 @@ async function le(e) {
|
|
|
1039
1060
|
throw new Error(`Failed to insert ${e.menuKey} navigation item: ${_(o)}`);
|
|
1040
1061
|
return Number(r.id);
|
|
1041
1062
|
}
|
|
1042
|
-
function
|
|
1063
|
+
function Jn(e) {
|
|
1043
1064
|
const t = e.trim();
|
|
1044
1065
|
if (!t.startsWith("/") || t.startsWith("//"))
|
|
1045
1066
|
return null;
|
|
1046
1067
|
const n = t.split("?")[0]?.split("#")[0] || "", r = n === "/" ? "home" : n.replace(/^\/+|\/+$/g, "");
|
|
1047
1068
|
return r && !r.includes("/") ? r : null;
|
|
1048
1069
|
}
|
|
1049
|
-
async function
|
|
1050
|
-
const t =
|
|
1070
|
+
async function Wn(e) {
|
|
1071
|
+
const t = Jn(e.item.url);
|
|
1051
1072
|
if (!t)
|
|
1052
1073
|
return null;
|
|
1053
1074
|
const { data: n, error: r } = await e.supabase.from("pages").select("id, slug, translation_group_id, language_id").eq("slug", t).eq("language_id", e.languageId);
|
|
@@ -1056,7 +1077,7 @@ async function Jn(e) {
|
|
|
1056
1077
|
const o = Array.isArray(n) ? n[0] : n;
|
|
1057
1078
|
if (!o?.id)
|
|
1058
1079
|
return null;
|
|
1059
|
-
let a =
|
|
1080
|
+
let a = qe();
|
|
1060
1081
|
if (o.translation_group_id) {
|
|
1061
1082
|
const { data: s, error: l } = await e.supabase.from("pages").select("id").eq("translation_group_id", o.translation_group_id);
|
|
1062
1083
|
if (l)
|
|
@@ -1070,22 +1091,22 @@ async function Jn(e) {
|
|
|
1070
1091
|
throw new Error(
|
|
1071
1092
|
`Failed to inspect related navigation translations: ${_(c)}`
|
|
1072
1093
|
);
|
|
1073
|
-
const
|
|
1074
|
-
|
|
1094
|
+
const m = (Array.isArray(d) ? d : []).find((h) => h.translation_group_id && u.has(String(h.page_id)));
|
|
1095
|
+
m?.translation_group_id && (a = m.translation_group_id);
|
|
1075
1096
|
}
|
|
1076
1097
|
return {
|
|
1077
1098
|
navigationTranslationGroupId: a,
|
|
1078
1099
|
pageId: Number(o.id)
|
|
1079
1100
|
};
|
|
1080
1101
|
}
|
|
1081
|
-
async function
|
|
1082
|
-
const t = await
|
|
1102
|
+
async function Pt(e) {
|
|
1103
|
+
const t = await J(e.supabase, e.languageCode), { data: n, error: r } = await e.supabase.from("navigation_items").select("id, parent_id").eq("menu_key", e.menuKey).eq("language_id", t.id);
|
|
1083
1104
|
if (r)
|
|
1084
1105
|
throw new Error(
|
|
1085
1106
|
`Failed to inspect existing ${e.menuKey} navigation items: ${_(r)}`
|
|
1086
1107
|
);
|
|
1087
|
-
const o = Array.isArray(n) ? n : [], a = o.filter((d) => d.parent_id == null).length, s =
|
|
1088
|
-
|
|
1108
|
+
const o = Array.isArray(n) ? n : [], a = o.filter((d) => d.parent_id == null).length, s = At(e.items);
|
|
1109
|
+
Nt({
|
|
1089
1110
|
existingItemCount: o.length,
|
|
1090
1111
|
existingTopLevelCount: a,
|
|
1091
1112
|
languageCode: t.code,
|
|
@@ -1097,7 +1118,7 @@ async function At(e) {
|
|
|
1097
1118
|
throw new Error(`Failed to clear ${e.menuKey} navigation items: ${_(l)}`);
|
|
1098
1119
|
let u = 0;
|
|
1099
1120
|
for (const [d, c] of e.items.entries()) {
|
|
1100
|
-
const
|
|
1121
|
+
const m = await le({
|
|
1101
1122
|
item: c,
|
|
1102
1123
|
languageId: t.id,
|
|
1103
1124
|
menuKey: e.menuKey,
|
|
@@ -1105,13 +1126,13 @@ async function At(e) {
|
|
|
1105
1126
|
supabase: e.supabase
|
|
1106
1127
|
});
|
|
1107
1128
|
u++;
|
|
1108
|
-
for (const [h,
|
|
1129
|
+
for (const [h, p] of (c.children ?? []).entries())
|
|
1109
1130
|
await le({
|
|
1110
|
-
item:
|
|
1131
|
+
item: p,
|
|
1111
1132
|
languageId: t.id,
|
|
1112
1133
|
menuKey: e.menuKey,
|
|
1113
1134
|
order: h,
|
|
1114
|
-
parentId:
|
|
1135
|
+
parentId: m,
|
|
1115
1136
|
supabase: e.supabase
|
|
1116
1137
|
}), u++;
|
|
1117
1138
|
}
|
|
@@ -1123,38 +1144,38 @@ async function At(e) {
|
|
|
1123
1144
|
updatedCount: 0
|
|
1124
1145
|
};
|
|
1125
1146
|
}
|
|
1126
|
-
function
|
|
1147
|
+
function Nt(e) {
|
|
1127
1148
|
if (!(e.existingItemCount === 0 || e.replacementItemCount >= e.existingItemCount))
|
|
1128
1149
|
throw new Error(
|
|
1129
1150
|
`Refusing destructive ${e.menuKey} navigation replacement for ${e.languageCode}: existing menu has ${e.existingItemCount} items (${e.existingTopLevelCount} top-level), but the replacement only contains ${e.replacementItemCount}. Use mode "update" for renaming or changing a single link, or provide the full menu.`
|
|
1130
1151
|
);
|
|
1131
1152
|
}
|
|
1132
|
-
async function
|
|
1133
|
-
const t = await
|
|
1153
|
+
async function Yn(e) {
|
|
1154
|
+
const t = await J(e.supabase, e.languageCode), { data: n, error: r } = await e.supabase.from("navigation_items").select("id, parent_id").eq("menu_key", e.menuKey).eq("language_id", t.id);
|
|
1134
1155
|
if (r)
|
|
1135
1156
|
throw new Error(
|
|
1136
1157
|
`Failed to inspect existing ${e.menuKey} navigation items: ${_(r)}`
|
|
1137
1158
|
);
|
|
1138
1159
|
const o = Array.isArray(n) ? n : [];
|
|
1139
|
-
|
|
1160
|
+
Nt({
|
|
1140
1161
|
existingItemCount: o.length,
|
|
1141
1162
|
existingTopLevelCount: o.filter((a) => a.parent_id == null).length,
|
|
1142
1163
|
languageCode: t.code,
|
|
1143
1164
|
menuKey: e.menuKey,
|
|
1144
|
-
replacementItemCount:
|
|
1165
|
+
replacementItemCount: At(e.items)
|
|
1145
1166
|
});
|
|
1146
1167
|
}
|
|
1147
|
-
async function
|
|
1168
|
+
async function Xn(e) {
|
|
1148
1169
|
if (e.items.length !== 1)
|
|
1149
1170
|
throw new Error('mode "update" requires exactly one navigation item.');
|
|
1150
|
-
const t = await
|
|
1171
|
+
const t = await J(e.supabase, e.languageCode), n = e.items[0], r = G(e.match?.url) || G(n.url), o = tt(e.match?.label), { data: a, error: s } = await e.supabase.from("navigation_items").select("id, label, url, parent_id, order").eq("menu_key", e.menuKey).eq("language_id", t.id);
|
|
1151
1172
|
if (s)
|
|
1152
1173
|
throw new Error(
|
|
1153
1174
|
`Failed to load existing ${e.menuKey} navigation items: ${_(s)}`
|
|
1154
1175
|
);
|
|
1155
1176
|
const u = (Array.isArray(a) ? a : []).find((c) => {
|
|
1156
|
-
const
|
|
1157
|
-
return !!(r &&
|
|
1177
|
+
const m = G(c.url), h = tt(c.label);
|
|
1178
|
+
return !!(r && m === r || o && h === o);
|
|
1158
1179
|
});
|
|
1159
1180
|
if (!u?.id)
|
|
1160
1181
|
throw new Error(
|
|
@@ -1174,20 +1195,20 @@ async function Yn(e) {
|
|
|
1174
1195
|
updatedCount: 1
|
|
1175
1196
|
};
|
|
1176
1197
|
}
|
|
1177
|
-
async function
|
|
1178
|
-
const t = await
|
|
1198
|
+
async function Qn(e) {
|
|
1199
|
+
const t = await J(e.supabase, e.languageCode), { data: n, error: r } = await e.supabase.from("navigation_items").select("id, url, parent_id, order").eq("menu_key", e.menuKey).eq("language_id", t.id);
|
|
1179
1200
|
if (r)
|
|
1180
1201
|
throw new Error(
|
|
1181
1202
|
`Failed to load existing ${e.menuKey} navigation items: ${_(r)}`
|
|
1182
1203
|
);
|
|
1183
1204
|
let o = 0, a = 0;
|
|
1184
1205
|
const s = Array.isArray(n) ? n : [], l = new Set(
|
|
1185
|
-
s.map((c) =>
|
|
1206
|
+
s.map((c) => G(c.url)).filter(Boolean)
|
|
1186
1207
|
), u = s.filter((c) => c.parent_id == null).map((c) => Number(c.order)).filter(Number.isFinite);
|
|
1187
1208
|
let d = u.length > 0 ? Math.max(...u) + 1 : s.length;
|
|
1188
1209
|
for (const c of e.items) {
|
|
1189
|
-
const
|
|
1190
|
-
if (
|
|
1210
|
+
const m = G(c.url);
|
|
1211
|
+
if (m && l.has(m)) {
|
|
1191
1212
|
a++;
|
|
1192
1213
|
continue;
|
|
1193
1214
|
}
|
|
@@ -1198,10 +1219,10 @@ async function Xn(e) {
|
|
|
1198
1219
|
order: d,
|
|
1199
1220
|
supabase: e.supabase
|
|
1200
1221
|
});
|
|
1201
|
-
o++, d++,
|
|
1202
|
-
let
|
|
1222
|
+
o++, d++, m && l.add(m);
|
|
1223
|
+
let p = 0;
|
|
1203
1224
|
for (const g of c.children ?? []) {
|
|
1204
|
-
const f =
|
|
1225
|
+
const f = G(g.url);
|
|
1205
1226
|
if (f && l.has(f)) {
|
|
1206
1227
|
a++;
|
|
1207
1228
|
continue;
|
|
@@ -1210,10 +1231,10 @@ async function Xn(e) {
|
|
|
1210
1231
|
item: g,
|
|
1211
1232
|
languageId: t.id,
|
|
1212
1233
|
menuKey: e.menuKey,
|
|
1213
|
-
order:
|
|
1234
|
+
order: p,
|
|
1214
1235
|
parentId: h,
|
|
1215
1236
|
supabase: e.supabase
|
|
1216
|
-
}), o++,
|
|
1237
|
+
}), o++, p++, f && l.add(f);
|
|
1217
1238
|
}
|
|
1218
1239
|
}
|
|
1219
1240
|
return {
|
|
@@ -1224,76 +1245,76 @@ async function Xn(e) {
|
|
|
1224
1245
|
updatedCount: 0
|
|
1225
1246
|
};
|
|
1226
1247
|
}
|
|
1227
|
-
function
|
|
1248
|
+
function v(e) {
|
|
1228
1249
|
return typeof e == "string" && e.trim() ? e.trim() : "";
|
|
1229
1250
|
}
|
|
1230
|
-
function
|
|
1251
|
+
function Zn(e) {
|
|
1231
1252
|
return e.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """).replace(/'/g, "'");
|
|
1232
1253
|
}
|
|
1233
|
-
function
|
|
1234
|
-
const t =
|
|
1254
|
+
function er(e) {
|
|
1255
|
+
const t = v(e.field_type ?? e.fieldType ?? e.type ?? e.input_type).toLowerCase().replace(/\s+/g, "_"), n = v(e.label ?? e.name ?? e.placeholder).toLowerCase();
|
|
1235
1256
|
return ["email", "textarea", "select", "radio", "checkbox", "text"].includes(t) ? t : n.includes("email") ? "email" : n.includes("message") || n.includes("comment") || n.includes("details") ? "textarea" : "text";
|
|
1236
1257
|
}
|
|
1237
|
-
function
|
|
1258
|
+
function tr(e) {
|
|
1238
1259
|
return (Array.isArray(e) && e.length > 0 ? e : [
|
|
1239
1260
|
{ field_type: "text", is_required: !0, label: "Name", placeholder: "Your name" },
|
|
1240
1261
|
{ field_type: "email", is_required: !0, label: "Email", placeholder: "you@example.com" },
|
|
1241
1262
|
{ field_type: "textarea", is_required: !0, label: "Message", placeholder: "How can we help?" }
|
|
1242
1263
|
]).map((n, r) => {
|
|
1243
|
-
const o =
|
|
1264
|
+
const o = $(n) ? n : {}, a = v(o.label ?? o.name) || (r === 0 ? "Name" : r === 1 ? "Email" : "Message"), s = er({ ...o, label: a }), l = o.is_required ?? o.isRequired ?? o.required;
|
|
1244
1265
|
return {
|
|
1245
1266
|
field_type: s,
|
|
1246
1267
|
is_required: typeof l == "boolean" ? l : !0,
|
|
1247
1268
|
label: a,
|
|
1248
1269
|
options: Array.isArray(o.options) ? o.options : void 0,
|
|
1249
|
-
placeholder:
|
|
1250
|
-
temp_id:
|
|
1270
|
+
placeholder: v(o.placeholder) || void 0,
|
|
1271
|
+
temp_id: v(o.temp_id ?? o.tempId ?? o.id) || `field-${r + 1}`
|
|
1251
1272
|
};
|
|
1252
1273
|
});
|
|
1253
1274
|
}
|
|
1254
|
-
const
|
|
1275
|
+
const nr = /* @__PURE__ */ new Set(["none", "sm", "md", "lg", "xl"]), rt = /* @__PURE__ */ new Set(["none", "sm", "md", "lg", "xl"]), rr = /* @__PURE__ */ new Set([
|
|
1255
1276
|
"full-width",
|
|
1256
1277
|
"container",
|
|
1257
1278
|
"container-sm",
|
|
1258
1279
|
"container-lg",
|
|
1259
1280
|
"container-xl"
|
|
1260
|
-
]),
|
|
1261
|
-
function
|
|
1281
|
+
]), or = /* @__PURE__ */ new Set(["start", "center", "end", "stretch"]), ir = /* @__PURE__ */ new Set(["none", "theme", "solid", "gradient", "image"]), ar = /* @__PURE__ */ new Set(["primary", "secondary", "muted", "accent", "destructive"]), sr = /* @__PURE__ */ new Set(["center", "top", "bottom", "left", "right"]);
|
|
1282
|
+
function lr(e) {
|
|
1262
1283
|
return typeof e == "string" && /^https?:\/\//i.test(e.trim());
|
|
1263
1284
|
}
|
|
1264
1285
|
function B(e, t, n) {
|
|
1265
1286
|
return typeof e == "string" && t.has(e) ? e : n;
|
|
1266
1287
|
}
|
|
1267
|
-
function
|
|
1288
|
+
function cr(e) {
|
|
1268
1289
|
return Number.isFinite(e) ? Math.min(4, Math.max(1, Math.round(e))) : 1;
|
|
1269
1290
|
}
|
|
1270
|
-
function
|
|
1291
|
+
function ur(e) {
|
|
1271
1292
|
const t = [
|
|
1272
1293
|
{ color: "#1e3a8a", position: 0 },
|
|
1273
1294
|
{ color: "#3b82f6", position: 100 }
|
|
1274
1295
|
];
|
|
1275
|
-
if (
|
|
1296
|
+
if (!$(e))
|
|
1276
1297
|
return { direction: "to bottom right", stops: t, type: "linear" };
|
|
1277
1298
|
const n = e.type === "radial" ? "radial" : "linear", r = Array.isArray(e.stops) && e.stops.length >= 2 ? e.stops : t;
|
|
1278
1299
|
return { direction: typeof e.direction == "string" && e.direction.trim() ? e.direction : n === "radial" ? "circle at center" : "to bottom right", stops: r, type: n };
|
|
1279
1300
|
}
|
|
1280
|
-
function
|
|
1281
|
-
if (
|
|
1301
|
+
function dr(e) {
|
|
1302
|
+
if (!$(e))
|
|
1282
1303
|
return { type: "none" };
|
|
1283
|
-
const t = B(e.type,
|
|
1304
|
+
const t = B(e.type, ir, "none"), n = typeof e.min_height == "string" && e.min_height.trim() ? { min_height: e.min_height } : {};
|
|
1284
1305
|
if (t === "theme")
|
|
1285
|
-
return { theme: B(e.theme,
|
|
1306
|
+
return { theme: B(e.theme, ar, "muted"), type: t, ...n };
|
|
1286
1307
|
if (t === "solid")
|
|
1287
1308
|
return typeof e.solid_color == "string" && e.solid_color.trim() ? { solid_color: e.solid_color, type: t, ...n } : { type: "none" };
|
|
1288
1309
|
if (t === "gradient")
|
|
1289
|
-
return { gradient:
|
|
1310
|
+
return { gradient: ur(e.gradient), type: t, ...n };
|
|
1290
1311
|
if (t === "image") {
|
|
1291
|
-
const r =
|
|
1312
|
+
const r = $(e.image) ? e.image : null, o = r && lr(r.external_url) ? r.external_url.trim() : null, a = !!(r && typeof r.media_id == "string" && r.media_id.trim() && typeof r.object_key == "string" && r.object_key.trim());
|
|
1292
1313
|
return r && (o || a) ? {
|
|
1293
1314
|
image: {
|
|
1294
1315
|
...r,
|
|
1295
1316
|
...o ? { external_url: o } : {},
|
|
1296
|
-
position: B(r.position,
|
|
1317
|
+
position: B(r.position, sr, "center"),
|
|
1297
1318
|
size: r.size === "contain" ? "contain" : "cover"
|
|
1298
1319
|
},
|
|
1299
1320
|
type: t,
|
|
@@ -1302,45 +1323,45 @@ function ur(e) {
|
|
|
1302
1323
|
}
|
|
1303
1324
|
return { type: "none", ...n };
|
|
1304
1325
|
}
|
|
1305
|
-
function
|
|
1326
|
+
function pr(e, t, n) {
|
|
1306
1327
|
const r = e.is_hero === !0;
|
|
1307
1328
|
let o = Array.isArray(e.column_blocks) ? e.column_blocks : [];
|
|
1308
|
-
o.length > 0 && o.every((f) =>
|
|
1329
|
+
o.length > 0 && o.every((f) => $(f) && !Array.isArray(f)) && (o = [o]);
|
|
1309
1330
|
const a = o.map((f, k) => (Array.isArray(f) ? f : []).map(
|
|
1310
|
-
(w, b) =>
|
|
1311
|
-
)), s = a.length > 0 ? a : [[]], l =
|
|
1331
|
+
(w, b) => Pe(w, `${t} column ${k} block ${b}`, n)
|
|
1332
|
+
)), s = a.length > 0 ? a : [[]], l = cr(s.length), u = $(e.responsive_columns) ? e.responsive_columns : {}, d = Number(u.tablet), c = Number(u.mobile), m = Number.isFinite(d) ? Math.min(3, Math.max(1, Math.min(l, d))) : Math.min(3, l), h = Number.isFinite(c) ? Math.min(2, Math.max(1, c)) : 1, p = $(e.padding) ? e.padding : {}, g = {
|
|
1312
1333
|
...e,
|
|
1313
|
-
background:
|
|
1334
|
+
background: dr(e.background),
|
|
1314
1335
|
column_blocks: s,
|
|
1315
|
-
column_gap: B(e.column_gap,
|
|
1316
|
-
container_type: B(e.container_type,
|
|
1336
|
+
column_gap: B(e.column_gap, nr, "lg"),
|
|
1337
|
+
container_type: B(e.container_type, rr, "container"),
|
|
1317
1338
|
padding: {
|
|
1318
|
-
bottom: B(
|
|
1319
|
-
top: B(
|
|
1339
|
+
bottom: B(p.bottom, rt, "xl"),
|
|
1340
|
+
top: B(p.top, rt, "xl")
|
|
1320
1341
|
},
|
|
1321
|
-
responsive_columns: { desktop: l, mobile: h, tablet:
|
|
1342
|
+
responsive_columns: { desktop: l, mobile: h, tablet: m },
|
|
1322
1343
|
vertical_alignment: B(
|
|
1323
1344
|
e.vertical_alignment,
|
|
1324
|
-
|
|
1345
|
+
or,
|
|
1325
1346
|
r ? "center" : "start"
|
|
1326
1347
|
)
|
|
1327
1348
|
};
|
|
1328
1349
|
return g.slider === !0 && !(Array.isArray(g.slides) && g.slides.length > 0) && (g.slider = !1), g;
|
|
1329
1350
|
}
|
|
1330
|
-
function
|
|
1351
|
+
function Ut(e, t, n, r) {
|
|
1331
1352
|
if (e === "section") {
|
|
1332
|
-
const a =
|
|
1353
|
+
const a = pr(t, n, r);
|
|
1333
1354
|
return D(e, a, n, r), a;
|
|
1334
1355
|
}
|
|
1335
|
-
const o =
|
|
1336
|
-
if (e === "heading" && (o.text_content =
|
|
1337
|
-
const a =
|
|
1338
|
-
a && (o.html_content = /<\/?[a-z][\s\S]*>/i.test(a) ? a : `<p>${
|
|
1356
|
+
const o = z(t);
|
|
1357
|
+
if (e === "heading" && (o.text_content = v(o.text_content) || v(o.text) || v(o.title) || v(o.heading) || "Untitled", o.level = typeof o.level == "number" ? o.level : 1), e === "text") {
|
|
1358
|
+
const a = v(o.html_content) || v(o.html) || v(o.content) || v(o.text);
|
|
1359
|
+
a && (o.html_content = /<\/?[a-z][\s\S]*>/i.test(a) ? a : `<p>${Zn(a)}</p>`);
|
|
1339
1360
|
}
|
|
1340
|
-
return e === "button" && (o.text =
|
|
1361
|
+
return e === "button" && (o.text = v(o.text) || v(o.label) || v(o.title) || "Learn More", o.url = v(o.url) || v(o.href) || v(o.link) || "#"), e === "form" && (o.fields = tr(o.fields), o.submit_button_text = v(o.submit_button_text ?? o.submitButtonText ?? o.button_text) || "Send Message", o.success_message = v(o.success_message ?? o.successMessage) || "Thanks for reaching out. We will reply as soon as possible."), D(e, o, n, r), o;
|
|
1341
1362
|
}
|
|
1342
1363
|
function ce(e, t, n) {
|
|
1343
|
-
const r =
|
|
1364
|
+
const r = Ut(
|
|
1344
1365
|
e.blockType,
|
|
1345
1366
|
ee(e.content, `Block ${t}`),
|
|
1346
1367
|
`Block ${t}`,
|
|
@@ -1352,7 +1373,7 @@ function ce(e, t, n) {
|
|
|
1352
1373
|
order: e.order ?? t
|
|
1353
1374
|
};
|
|
1354
1375
|
}
|
|
1355
|
-
function
|
|
1376
|
+
function mr(e, t = "Contact Us", n) {
|
|
1356
1377
|
return [
|
|
1357
1378
|
ce(
|
|
1358
1379
|
{
|
|
@@ -1427,10 +1448,10 @@ function pr(e, t = "Contact Us", n) {
|
|
|
1427
1448
|
)
|
|
1428
1449
|
];
|
|
1429
1450
|
}
|
|
1430
|
-
function
|
|
1431
|
-
return (!e || e.length === 0) && t ?
|
|
1451
|
+
function Se(e, t, n, r) {
|
|
1452
|
+
return (!e || e.length === 0) && t ? mr(t, n, r) : (e || []).map((o, a) => ce(o, a, r));
|
|
1432
1453
|
}
|
|
1433
|
-
async function
|
|
1454
|
+
async function De(e) {
|
|
1434
1455
|
const t = e.contentType === "page" ? "pages" : e.contentType === "post" ? "posts" : "products", { data: n, error: r } = await e.supabase.from(t).select("id, title, slug, language_id").eq("slug", e.slug).eq("language_id", e.languageId);
|
|
1435
1456
|
if (r)
|
|
1436
1457
|
throw new Error(`Failed to check ${e.contentType} slug uniqueness: ${_(r)}`);
|
|
@@ -1443,7 +1464,7 @@ async function Me(e) {
|
|
|
1443
1464
|
message: `A ${e.contentType} with slug "${e.slug}" already exists for this language.`
|
|
1444
1465
|
} : null;
|
|
1445
1466
|
}
|
|
1446
|
-
async function
|
|
1467
|
+
async function ze(e) {
|
|
1447
1468
|
if (!e.suppliedTranslationGroupId)
|
|
1448
1469
|
return {
|
|
1449
1470
|
translationGroupId: void 0
|
|
@@ -1479,7 +1500,7 @@ async function De(e) {
|
|
|
1479
1500
|
translationGroupId: e.suppliedTranslationGroupId
|
|
1480
1501
|
};
|
|
1481
1502
|
}
|
|
1482
|
-
async function
|
|
1503
|
+
async function Ge(e) {
|
|
1483
1504
|
if (e.blocks.length === 0)
|
|
1484
1505
|
return [];
|
|
1485
1506
|
const t = e.blocks.map((o, a) => ({
|
|
@@ -1495,19 +1516,19 @@ async function ze(e) {
|
|
|
1495
1516
|
throw new Error(`Failed to insert ${e.contentType} blocks: ${_(r)}`);
|
|
1496
1517
|
return ve(e.blocks, e.supabase), Array.isArray(n) ? n : [];
|
|
1497
1518
|
}
|
|
1498
|
-
async function
|
|
1519
|
+
async function Ke(e) {
|
|
1499
1520
|
const t = e.contentType === "page" ? "pages" : e.contentType === "post" ? "posts" : "products";
|
|
1500
1521
|
await e.supabase.from(t).delete().eq("id", e.itemId);
|
|
1501
1522
|
}
|
|
1502
|
-
function
|
|
1523
|
+
function He(e, t) {
|
|
1503
1524
|
return e === "page" ? `/cms/pages/${t}/edit` : e === "post" ? `/cms/posts/${t}/edit` : `/cms/products/${t}/edit`;
|
|
1504
1525
|
}
|
|
1505
|
-
function
|
|
1526
|
+
function ot(e) {
|
|
1506
1527
|
return e === "page" ? "/cms/pages" : e === "post" ? "/cms/posts" : "/cms/products";
|
|
1507
1528
|
}
|
|
1508
|
-
async function
|
|
1509
|
-
const n = de.parse(e), r =
|
|
1510
|
-
n.mode === "replace" && await
|
|
1529
|
+
async function Ot(e, t) {
|
|
1530
|
+
const n = de.parse(e), r = C(t);
|
|
1531
|
+
n.mode === "replace" && await Yn({
|
|
1511
1532
|
items: n.items,
|
|
1512
1533
|
languageCode: n.languageCode,
|
|
1513
1534
|
menuKey: "HEADER",
|
|
@@ -1527,35 +1548,35 @@ async function Ut(e, t) {
|
|
|
1527
1548
|
});
|
|
1528
1549
|
if (o)
|
|
1529
1550
|
return o;
|
|
1530
|
-
const a = n.mode === "update" ? await
|
|
1551
|
+
const a = n.mode === "update" ? await Xn({
|
|
1531
1552
|
items: n.items,
|
|
1532
1553
|
languageCode: n.languageCode,
|
|
1533
1554
|
match: n.match,
|
|
1534
1555
|
menuKey: "HEADER",
|
|
1535
1556
|
supabase: r
|
|
1536
|
-
}) : n.mode === "append" ? await
|
|
1557
|
+
}) : n.mode === "append" ? await Qn({
|
|
1537
1558
|
items: n.items,
|
|
1538
1559
|
languageCode: n.languageCode,
|
|
1539
1560
|
menuKey: "HEADER",
|
|
1540
1561
|
supabase: r
|
|
1541
|
-
}) : await
|
|
1562
|
+
}) : await Pt({
|
|
1542
1563
|
items: n.items,
|
|
1543
1564
|
languageCode: n.languageCode,
|
|
1544
1565
|
menuKey: "HEADER",
|
|
1545
1566
|
supabase: r
|
|
1546
1567
|
});
|
|
1547
|
-
return
|
|
1568
|
+
return xt(t), {
|
|
1548
1569
|
...a,
|
|
1549
1570
|
mutationExecuted: !0,
|
|
1550
1571
|
mode: n.mode,
|
|
1551
1572
|
success: !0
|
|
1552
1573
|
};
|
|
1553
1574
|
}
|
|
1554
|
-
async function
|
|
1575
|
+
async function Ft(e, t) {
|
|
1555
1576
|
const n = pe.parse(e);
|
|
1556
1577
|
if (!n.links?.length && !n.copyright)
|
|
1557
1578
|
throw new Error("update_footer requires links or copyright.");
|
|
1558
|
-
const r =
|
|
1579
|
+
const r = C(t), o = P({
|
|
1559
1580
|
action: "UPDATE FOOTER",
|
|
1560
1581
|
context: t,
|
|
1561
1582
|
payload: { input: n, tool: "update_footer" },
|
|
@@ -1570,7 +1591,7 @@ async function Ot(e, t) {
|
|
|
1570
1591
|
if (o)
|
|
1571
1592
|
return o;
|
|
1572
1593
|
let a = null;
|
|
1573
|
-
if (n.links?.length && (a = await
|
|
1594
|
+
if (n.links?.length && (a = await Pt({
|
|
1574
1595
|
items: n.links,
|
|
1575
1596
|
languageCode: n.languageCode,
|
|
1576
1597
|
menuKey: "FOOTER",
|
|
@@ -1583,27 +1604,27 @@ async function Ot(e, t) {
|
|
|
1583
1604
|
if (s)
|
|
1584
1605
|
throw new Error(`Failed to update footer copyright: ${_(s)}`);
|
|
1585
1606
|
}
|
|
1586
|
-
return
|
|
1607
|
+
return xt(t), {
|
|
1587
1608
|
copyrightUpdated: !!n.copyright,
|
|
1588
1609
|
footerNavigation: a,
|
|
1589
1610
|
mutationExecuted: !0,
|
|
1590
1611
|
success: !0
|
|
1591
1612
|
};
|
|
1592
1613
|
}
|
|
1593
|
-
function
|
|
1614
|
+
function jt(e) {
|
|
1594
1615
|
return typeof e == "string" ? e.toLowerCase() : "";
|
|
1595
1616
|
}
|
|
1596
|
-
function
|
|
1597
|
-
const n = t.map(
|
|
1617
|
+
function gr(e, t) {
|
|
1618
|
+
const n = t.map(jt).join(" ");
|
|
1598
1619
|
return e.reduce((r, o) => r + (n.includes(o) ? 1 : 0), 0);
|
|
1599
1620
|
}
|
|
1600
|
-
function
|
|
1621
|
+
function it(e, t) {
|
|
1601
1622
|
return (e.find(
|
|
1602
|
-
(n) => t.some((r) =>
|
|
1623
|
+
(n) => t.some((r) => jt(n).includes(r))
|
|
1603
1624
|
) || e.find((n) => n.trim().length > 0) || "No excerpt available.").slice(0, 500);
|
|
1604
1625
|
}
|
|
1605
|
-
async function
|
|
1606
|
-
const n =
|
|
1626
|
+
async function fr(e, t) {
|
|
1627
|
+
const n = je.parse(e), r = C(t), o = n.query.toLowerCase().split(/\s+/).map((c) => c.trim()).filter(Boolean), [a, s] = await Promise.all([
|
|
1607
1628
|
r.from("posts").select("id, title, slug, excerpt, subtitle, meta_description, status, updated_at").eq("status", "published").limit(100),
|
|
1608
1629
|
r.from("pages").select("id, title, slug, meta_description, status, updated_at").eq("status", "published").limit(100)
|
|
1609
1630
|
]);
|
|
@@ -1612,7 +1633,7 @@ async function gr(e, t) {
|
|
|
1612
1633
|
if (s.error)
|
|
1613
1634
|
throw new Error(`Failed to search documentation pages: ${_(s.error)}`);
|
|
1614
1635
|
const l = (a.data ?? []).map((c) => ({
|
|
1615
|
-
excerpt:
|
|
1636
|
+
excerpt: it(
|
|
1616
1637
|
[c.excerpt, c.subtitle, c.meta_description, c.slug].filter(Boolean),
|
|
1617
1638
|
o
|
|
1618
1639
|
),
|
|
@@ -1620,14 +1641,14 @@ async function gr(e, t) {
|
|
|
1620
1641
|
title: c.title,
|
|
1621
1642
|
url: `/article/${c.slug}`
|
|
1622
1643
|
})), u = (s.data ?? []).map((c) => ({
|
|
1623
|
-
excerpt:
|
|
1644
|
+
excerpt: it([c.meta_description, c.slug].filter(Boolean), o),
|
|
1624
1645
|
source: "page",
|
|
1625
1646
|
title: c.title,
|
|
1626
1647
|
url: c.slug === "home" ? "/" : `/${c.slug}`
|
|
1627
1648
|
})), d = [...l, ...u].map((c) => ({
|
|
1628
1649
|
...c,
|
|
1629
|
-
score:
|
|
1630
|
-
})).filter((c) => c.score > 0).sort((c,
|
|
1650
|
+
score: gr(o, [c.title, c.excerpt, c.url])
|
|
1651
|
+
})).filter((c) => c.score > 0).sort((c, m) => m.score - c.score).slice(0, n.limit).map((c) => ({
|
|
1631
1652
|
excerpt: c.excerpt,
|
|
1632
1653
|
source: c.source,
|
|
1633
1654
|
title: c.title,
|
|
@@ -1639,10 +1660,10 @@ async function gr(e, t) {
|
|
|
1639
1660
|
success: !0
|
|
1640
1661
|
};
|
|
1641
1662
|
}
|
|
1642
|
-
async function
|
|
1643
|
-
const r =
|
|
1644
|
-
return
|
|
1645
|
-
|
|
1663
|
+
async function hr(e, t, n = ln) {
|
|
1664
|
+
const r = je.safeParse(e), o = r.success ? r.data.query : "";
|
|
1665
|
+
return En(
|
|
1666
|
+
fr(e, t),
|
|
1646
1667
|
n,
|
|
1647
1668
|
() => ({
|
|
1648
1669
|
message: "Documentation search took too long to respond. Please try again or ask a more specific question.",
|
|
@@ -1653,7 +1674,7 @@ async function fr(e, t, n = sn) {
|
|
|
1653
1674
|
})
|
|
1654
1675
|
);
|
|
1655
1676
|
}
|
|
1656
|
-
const
|
|
1677
|
+
const yr = [
|
|
1657
1678
|
"pending",
|
|
1658
1679
|
"trial",
|
|
1659
1680
|
"paid",
|
|
@@ -1661,7 +1682,7 @@ const hr = [
|
|
|
1661
1682
|
"cancelled",
|
|
1662
1683
|
"refunded",
|
|
1663
1684
|
"failed"
|
|
1664
|
-
],
|
|
1685
|
+
], _r = {
|
|
1665
1686
|
awaiting: "pending",
|
|
1666
1687
|
canceled: "cancelled",
|
|
1667
1688
|
cancelled: "cancelled",
|
|
@@ -1678,34 +1699,34 @@ const hr = [
|
|
|
1678
1699
|
trial: "trial",
|
|
1679
1700
|
trials: "trial"
|
|
1680
1701
|
};
|
|
1681
|
-
function
|
|
1702
|
+
function br(e) {
|
|
1682
1703
|
return String(e ?? "unknown").trim().toLowerCase() || "unknown";
|
|
1683
1704
|
}
|
|
1684
|
-
function
|
|
1705
|
+
function at(e) {
|
|
1685
1706
|
const t = Object.fromEntries(
|
|
1686
|
-
|
|
1707
|
+
yr.map((n) => [n, 0])
|
|
1687
1708
|
);
|
|
1688
1709
|
for (const n of e) {
|
|
1689
|
-
const r =
|
|
1710
|
+
const r = br(n.status);
|
|
1690
1711
|
t[r] = (t[r] ?? 0) + 1;
|
|
1691
1712
|
}
|
|
1692
1713
|
return t;
|
|
1693
1714
|
}
|
|
1694
|
-
function
|
|
1715
|
+
function kr(e) {
|
|
1695
1716
|
const n = e.toLowerCase().replace(/[^a-z0-9_]+/g, " ").split(/\s+/).filter(Boolean);
|
|
1696
1717
|
for (const r of n) {
|
|
1697
|
-
const o =
|
|
1718
|
+
const o = _r[r];
|
|
1698
1719
|
if (o)
|
|
1699
1720
|
return o;
|
|
1700
1721
|
}
|
|
1701
1722
|
return null;
|
|
1702
1723
|
}
|
|
1703
|
-
function
|
|
1724
|
+
function X(e) {
|
|
1704
1725
|
const t = Number(e);
|
|
1705
1726
|
return Number.isFinite(t) ? t : 0;
|
|
1706
1727
|
}
|
|
1707
|
-
async function
|
|
1708
|
-
const n =
|
|
1728
|
+
async function wr(e, t) {
|
|
1729
|
+
const n = ft.parse(e), r = C(t), o = /* @__PURE__ */ new Date();
|
|
1709
1730
|
let a = null, s = null;
|
|
1710
1731
|
switch (n.timeRange) {
|
|
1711
1732
|
case "today":
|
|
@@ -1730,9 +1751,9 @@ async function kr(e, t) {
|
|
|
1730
1751
|
a = null;
|
|
1731
1752
|
break;
|
|
1732
1753
|
}
|
|
1733
|
-
const l = n.currency?.toUpperCase(), u =
|
|
1754
|
+
const l = n.currency?.toUpperCase(), u = kr(n.query), d = r.from("orders").select("id, status, total, currency, created_at, paid_at");
|
|
1734
1755
|
l && d.eq("currency", l), a && d.gte("created_at", a.toISOString()), s && d.lte("created_at", s.toISOString());
|
|
1735
|
-
const
|
|
1756
|
+
const m = n.reportType === "products" || n.reportType === "revenue" || n.reportType === "general" ? r.from("order_items").select(`
|
|
1736
1757
|
quantity,
|
|
1737
1758
|
price_at_purchase,
|
|
1738
1759
|
products!inner (
|
|
@@ -1747,17 +1768,17 @@ async function kr(e, t) {
|
|
|
1747
1768
|
currency
|
|
1748
1769
|
)
|
|
1749
1770
|
`).eq("orders.status", "paid") : null;
|
|
1750
|
-
|
|
1751
|
-
const
|
|
1752
|
-
|
|
1771
|
+
m && (l && m.eq("orders.currency", l), a && m.gte("orders.paid_at", a.toISOString()), s && m.lte("orders.paid_at", s.toISOString()));
|
|
1772
|
+
const p = n.timeRange !== "all_time" && (n.reportType === "orders" || u) ? r.from("orders").select("id, status, currency") : null;
|
|
1773
|
+
p && l && p.eq("currency", l);
|
|
1753
1774
|
const [
|
|
1754
1775
|
{ data: g, error: f },
|
|
1755
1776
|
{ data: k, error: y },
|
|
1756
1777
|
w
|
|
1757
1778
|
] = await Promise.all([
|
|
1758
1779
|
d,
|
|
1759
|
-
|
|
1760
|
-
|
|
1780
|
+
m ?? Promise.resolve({ data: [], error: null }),
|
|
1781
|
+
p ?? Promise.resolve({ data: null, error: null })
|
|
1761
1782
|
]);
|
|
1762
1783
|
if (f)
|
|
1763
1784
|
throw new Error(`Failed to fetch ecommerce stats: ${_(f)}`);
|
|
@@ -1765,65 +1786,65 @@ async function kr(e, t) {
|
|
|
1765
1786
|
throw new Error(`Failed to fetch ecommerce stats: ${_(y)}`);
|
|
1766
1787
|
if (w.error)
|
|
1767
1788
|
throw new Error(`Failed to fetch ecommerce stats: ${_(w.error)}`);
|
|
1768
|
-
const b = Array.isArray(g) ? g : [],
|
|
1769
|
-
for (const
|
|
1770
|
-
const
|
|
1771
|
-
q[j] = (q[j] ?? 0) +
|
|
1789
|
+
const b = Array.isArray(g) ? g : [], I = Array.isArray(k) ? k : [], x = at(b), E = Array.isArray(w.data) ? w.data : null, L = E ? at(E) : null, q = {};
|
|
1790
|
+
for (const T of I) {
|
|
1791
|
+
const A = Array.isArray(T.orders) ? T.orders[0] : T.orders, j = String(A?.currency || l || "unknown").toUpperCase();
|
|
1792
|
+
q[j] = (q[j] ?? 0) + X(T.quantity) * X(T.price_at_purchase) / 100;
|
|
1772
1793
|
}
|
|
1773
|
-
const
|
|
1794
|
+
const W = {
|
|
1774
1795
|
currency: l ?? null,
|
|
1775
1796
|
currencyFiltered: !!l,
|
|
1776
|
-
orderStatusCounts:
|
|
1777
|
-
paidOrderCount:
|
|
1797
|
+
orderStatusCounts: x,
|
|
1798
|
+
paidOrderCount: x.paid ?? 0,
|
|
1778
1799
|
query: n.query,
|
|
1779
1800
|
reportType: n.reportType,
|
|
1780
1801
|
revenueByCurrency: q,
|
|
1781
1802
|
timeRange: n.timeRange,
|
|
1782
1803
|
totalOrders: b.length,
|
|
1783
1804
|
totalRevenue: Object.values(q).reduce(
|
|
1784
|
-
(
|
|
1805
|
+
(T, A) => T + A,
|
|
1785
1806
|
0
|
|
1786
1807
|
)
|
|
1787
1808
|
};
|
|
1788
|
-
if (L && (
|
|
1789
|
-
allTimeCount: L?.[u] ??
|
|
1790
|
-
count:
|
|
1809
|
+
if (L && (W.allTimeOrderStatusCounts = L), u && (W.matchingOrderStatus = {
|
|
1810
|
+
allTimeCount: L?.[u] ?? x[u] ?? 0,
|
|
1811
|
+
count: x[u] ?? 0,
|
|
1791
1812
|
status: u,
|
|
1792
1813
|
timeRange: n.timeRange
|
|
1793
1814
|
}), n.reportType === "products" || n.reportType === "revenue" || n.reportType === "general") {
|
|
1794
|
-
const
|
|
1795
|
-
for (const
|
|
1796
|
-
const j = Array.isArray(
|
|
1815
|
+
const T = {};
|
|
1816
|
+
for (const A of I) {
|
|
1817
|
+
const j = Array.isArray(A.products) ? A.products[0] : A.products;
|
|
1797
1818
|
if (!j?.id)
|
|
1798
1819
|
continue;
|
|
1799
|
-
const
|
|
1800
|
-
|
|
1801
|
-
id:
|
|
1820
|
+
const Y = j.id;
|
|
1821
|
+
T[Y] || (T[Y] = {
|
|
1822
|
+
id: Y,
|
|
1802
1823
|
quantity: 0,
|
|
1803
1824
|
revenue: 0,
|
|
1804
1825
|
title: j.title,
|
|
1805
1826
|
type: j.product_type
|
|
1806
|
-
}),
|
|
1827
|
+
}), T[Y].quantity += X(A.quantity), T[Y].revenue += X(A.quantity) * X(A.price_at_purchase) / 100;
|
|
1807
1828
|
}
|
|
1808
|
-
|
|
1829
|
+
W.topProducts = Object.values(T).sort((A, j) => j.revenue - A.revenue).slice(0, 10);
|
|
1809
1830
|
}
|
|
1810
1831
|
return {
|
|
1811
|
-
report:
|
|
1832
|
+
report: W,
|
|
1812
1833
|
success: !0
|
|
1813
1834
|
};
|
|
1814
1835
|
}
|
|
1815
|
-
async function
|
|
1816
|
-
const n =
|
|
1836
|
+
async function Ir(e, t) {
|
|
1837
|
+
const n = yt.parse(e), r = C(t), o = V(t), a = Te(o), s = o.contentType === "page" ? "pages" : o.contentType === "post" ? "posts" : "products", { data: l, error: u } = await r.from(s).select("*").eq("id", a).single();
|
|
1817
1838
|
if (u || !l)
|
|
1818
1839
|
throw new Error(
|
|
1819
1840
|
`Failed to read current ${o.contentType}: ${_(u)}`
|
|
1820
1841
|
);
|
|
1821
1842
|
let d = [];
|
|
1822
1843
|
if (n.includeBlocks) {
|
|
1823
|
-
const c = o.contentType === "page" ? "page_id" : o.contentType === "post" ? "post_id" : "product_id", { data:
|
|
1844
|
+
const c = o.contentType === "page" ? "page_id" : o.contentType === "post" ? "post_id" : "product_id", { data: m, error: h } = await r.from("blocks").select("id, page_id, post_id, product_id, language_id, block_type, content, order").eq(c, a);
|
|
1824
1845
|
if (h)
|
|
1825
1846
|
throw new Error(`Failed to read current ${o.contentType} blocks: ${_(h)}`);
|
|
1826
|
-
d = (Array.isArray(
|
|
1847
|
+
d = (Array.isArray(m) ? m : []).slice().sort((p, g) => Number(p.order) - Number(g.order)).map((p) => Hn(p, n.includeBlockContent));
|
|
1827
1848
|
}
|
|
1828
1849
|
return {
|
|
1829
1850
|
blocks: d,
|
|
@@ -1832,7 +1853,7 @@ async function wr(e, t) {
|
|
|
1832
1853
|
success: !0
|
|
1833
1854
|
};
|
|
1834
1855
|
}
|
|
1835
|
-
const
|
|
1856
|
+
const Lt = /* @__PURE__ */ new Set([
|
|
1836
1857
|
"feature_image_id",
|
|
1837
1858
|
"language_id",
|
|
1838
1859
|
"meta_description",
|
|
@@ -1840,7 +1861,7 @@ const jt = /* @__PURE__ */ new Set([
|
|
|
1840
1861
|
"slug",
|
|
1841
1862
|
"status",
|
|
1842
1863
|
"title"
|
|
1843
|
-
]),
|
|
1864
|
+
]), Bt = /* @__PURE__ */ new Set([
|
|
1844
1865
|
"excerpt",
|
|
1845
1866
|
"feature_image_id",
|
|
1846
1867
|
"label",
|
|
@@ -1852,7 +1873,7 @@ const jt = /* @__PURE__ */ new Set([
|
|
|
1852
1873
|
"status",
|
|
1853
1874
|
"subtitle",
|
|
1854
1875
|
"title"
|
|
1855
|
-
]),
|
|
1876
|
+
]), Tr = /* @__PURE__ */ new Set([
|
|
1856
1877
|
"description_json",
|
|
1857
1878
|
"language_id",
|
|
1858
1879
|
"meta_description",
|
|
@@ -1861,7 +1882,7 @@ const jt = /* @__PURE__ */ new Set([
|
|
|
1861
1882
|
"slug",
|
|
1862
1883
|
"status",
|
|
1863
1884
|
"title"
|
|
1864
|
-
]),
|
|
1885
|
+
]), xr = /* @__PURE__ */ new Set([
|
|
1865
1886
|
"excerpt",
|
|
1866
1887
|
"feature_image_id",
|
|
1867
1888
|
"label",
|
|
@@ -1871,13 +1892,13 @@ const jt = /* @__PURE__ */ new Set([
|
|
|
1871
1892
|
"short_description",
|
|
1872
1893
|
"subtitle"
|
|
1873
1894
|
]);
|
|
1874
|
-
function
|
|
1875
|
-
return e === "page" ?
|
|
1895
|
+
function Cr(e) {
|
|
1896
|
+
return e === "page" ? Lt : e === "post" ? Bt : Tr;
|
|
1876
1897
|
}
|
|
1877
|
-
function
|
|
1878
|
-
return
|
|
1898
|
+
function Rt(e, t) {
|
|
1899
|
+
return xr.has(e) && t === "" ? null : t;
|
|
1879
1900
|
}
|
|
1880
|
-
function
|
|
1901
|
+
function Ne(e, t) {
|
|
1881
1902
|
if (typeof t != "string")
|
|
1882
1903
|
return;
|
|
1883
1904
|
const n = e === "product" ? ["active", "archived", "draft"] : ["archived", "draft", "published"];
|
|
@@ -1886,20 +1907,20 @@ function Pe(e, t) {
|
|
|
1886
1907
|
`Status "${t}" is not valid for ${e}. Allowed statuses: ${n.join(", ")}.`
|
|
1887
1908
|
);
|
|
1888
1909
|
}
|
|
1889
|
-
function
|
|
1890
|
-
const n =
|
|
1910
|
+
function Sr(e, t) {
|
|
1911
|
+
const n = Cr(t.contentType), r = {};
|
|
1891
1912
|
for (const [o, a] of Object.entries(e))
|
|
1892
1913
|
if (a !== void 0) {
|
|
1893
1914
|
if (!n.has(o))
|
|
1894
1915
|
throw new Error(
|
|
1895
1916
|
`Field "${o}" cannot be updated for ${t.contentType} content.`
|
|
1896
1917
|
);
|
|
1897
|
-
o === "status" &&
|
|
1918
|
+
o === "status" && Ne(t.contentType, a), r[o] = Rt(o, a);
|
|
1898
1919
|
}
|
|
1899
1920
|
return r;
|
|
1900
1921
|
}
|
|
1901
|
-
async function
|
|
1902
|
-
const n = me.parse(e), r =
|
|
1922
|
+
async function qt(e, t) {
|
|
1923
|
+
const n = me.parse(e), r = C(t), o = V(t), a = Te(o), s = Sr(n.fields, o), l = Object.keys(s);
|
|
1903
1924
|
if (l.length === 0)
|
|
1904
1925
|
throw new Error("update_current_cms_fields requires at least one supported field.");
|
|
1905
1926
|
const u = P({
|
|
@@ -1927,13 +1948,13 @@ async function Rt(e, t) {
|
|
|
1927
1948
|
t,
|
|
1928
1949
|
typeof o.title == "string" ? o.title : void 0
|
|
1929
1950
|
));
|
|
1930
|
-
const d = o.contentType === "page" ? "pages" : o.contentType === "post" ? "posts" : "products", { data: c, error:
|
|
1951
|
+
const d = o.contentType === "page" ? "pages" : o.contentType === "post" ? "posts" : "products", { data: c, error: m } = await r.from(d).update({
|
|
1931
1952
|
...s,
|
|
1932
1953
|
updated_at: (/* @__PURE__ */ new Date()).toISOString()
|
|
1933
1954
|
}).eq("id", a).select("id, language_id, slug, status, title").single();
|
|
1934
|
-
if (
|
|
1955
|
+
if (m || !c)
|
|
1935
1956
|
throw new Error(
|
|
1936
|
-
`Failed to update current ${o.contentType}: ${_(
|
|
1957
|
+
`Failed to update current ${o.contentType}: ${_(m)}`
|
|
1937
1958
|
);
|
|
1938
1959
|
return U(t, o, c.slug), {
|
|
1939
1960
|
contentType: o.contentType,
|
|
@@ -1944,14 +1965,14 @@ async function Rt(e, t) {
|
|
|
1944
1965
|
updatedFields: l
|
|
1945
1966
|
};
|
|
1946
1967
|
}
|
|
1947
|
-
async function
|
|
1948
|
-
const n = ge.parse(e), r =
|
|
1968
|
+
async function Mt(e, t) {
|
|
1969
|
+
const n = ge.parse(e), r = C(t), o = V(t), { data: a, error: s } = await r.from("blocks").select("id, page_id, post_id, product_id, language_id, block_type, content, order").eq("id", n.blockId).single();
|
|
1949
1970
|
if (s || !a)
|
|
1950
1971
|
throw new Error(`Failed to read block ${n.blockId}: ${_(s)}`);
|
|
1951
1972
|
vt(a, o);
|
|
1952
1973
|
const l = ae(a.block_type, `Block ${n.blockId}`);
|
|
1953
|
-
|
|
1954
|
-
const u = ee(a.content, `Block ${n.blockId}`), d =
|
|
1974
|
+
Et(n.blockType, l, `Block ${n.blockId}`);
|
|
1975
|
+
const u = ee(a.content, `Block ${n.blockId}`), d = Kn(
|
|
1955
1976
|
l,
|
|
1956
1977
|
u,
|
|
1957
1978
|
n.content,
|
|
@@ -1977,27 +1998,35 @@ async function qt(e, t) {
|
|
|
1977
1998
|
});
|
|
1978
1999
|
if (c)
|
|
1979
2000
|
return c;
|
|
1980
|
-
const { data:
|
|
2001
|
+
const { data: m, error: h } = await r.from("blocks").update({
|
|
1981
2002
|
content: d,
|
|
1982
2003
|
updated_at: (/* @__PURE__ */ new Date()).toISOString()
|
|
1983
2004
|
}).eq("id", n.blockId).select("id, block_type, order").single();
|
|
1984
|
-
if (h || !
|
|
2005
|
+
if (h || !m)
|
|
1985
2006
|
throw new Error(`Failed to update block ${n.blockId}: ${_(h)}`);
|
|
1986
|
-
return
|
|
1987
|
-
|
|
1988
|
-
|
|
2007
|
+
return await xe({
|
|
2008
|
+
patch: ({ blocks: p }) => ({
|
|
2009
|
+
blocks: p.map(
|
|
2010
|
+
(g) => String(g?.id) === String(n.blockId) ? { ...g, content: d } : g
|
|
2011
|
+
)
|
|
2012
|
+
}),
|
|
2013
|
+
productId: a.product_id,
|
|
2014
|
+
supabase: r
|
|
2015
|
+
}), ve([{ content: d }], r), U(t, o), {
|
|
2016
|
+
blockId: m.id,
|
|
2017
|
+
blockType: m.block_type,
|
|
1989
2018
|
contentUpdated: !0,
|
|
1990
2019
|
mutationExecuted: !0,
|
|
1991
2020
|
success: !0
|
|
1992
2021
|
};
|
|
1993
2022
|
}
|
|
1994
|
-
async function
|
|
1995
|
-
const n = ye.parse(e), r =
|
|
1996
|
-
const { data: b, error:
|
|
1997
|
-
if (
|
|
1998
|
-
throw new Error(`Failed to read ${o.contentType} blocks: ${_(
|
|
2023
|
+
async function Dt(e, t) {
|
|
2024
|
+
const n = ye.parse(e), r = C(t), o = await te(n, t), a = o.contentType === "product" ? o.item.id : Number(o.item.id), s = o.contentType === "page" ? "page_id" : o.contentType === "post" ? "post_id" : "product_id", l = async () => {
|
|
2025
|
+
const { data: b, error: I } = await r.from("blocks").select("id, page_id, post_id, product_id, language_id, block_type, content, order").eq(s, a);
|
|
2026
|
+
if (I)
|
|
2027
|
+
throw new Error(`Failed to read ${o.contentType} blocks: ${_(I)}`);
|
|
1999
2028
|
return (Array.isArray(b) ? b : []).sort(
|
|
2000
|
-
(
|
|
2029
|
+
(x, E) => Number(x.order) - Number(E.order)
|
|
2001
2030
|
);
|
|
2002
2031
|
}, u = (b) => {
|
|
2003
2032
|
if (n.position === "start")
|
|
@@ -2006,26 +2035,26 @@ async function Mt(e, t) {
|
|
|
2006
2035
|
const E = b.map((L) => Number(L.order)).filter(Number.isFinite);
|
|
2007
2036
|
return E.length > 0 ? Math.max(...E) + 1 : 0;
|
|
2008
2037
|
}
|
|
2009
|
-
const
|
|
2010
|
-
if (!
|
|
2038
|
+
const I = n.anchorBlockId ? b.find((E) => Number(E.id) === n.anchorBlockId) : n.anchorBlockType ? b.find((E) => E.block_type === n.anchorBlockType) : null;
|
|
2039
|
+
if (!I)
|
|
2011
2040
|
throw new Error(
|
|
2012
2041
|
n.anchorBlockType ? `Could not find a ${n.anchorBlockType} block to insert ${n.position}.` : `Could not find block ${n.anchorBlockId} to insert ${n.position}.`
|
|
2013
2042
|
);
|
|
2014
|
-
const
|
|
2015
|
-
return n.position === "before" ?
|
|
2016
|
-
}, d = ce(n.block, 0, t), c = await l(),
|
|
2043
|
+
const x = Number(I.order);
|
|
2044
|
+
return n.position === "before" ? x : x + 1;
|
|
2045
|
+
}, d = ce(n.block, 0, t), c = await l(), m = u(c), h = {
|
|
2017
2046
|
contentType: o.contentType,
|
|
2018
2047
|
entityId: o.item.id,
|
|
2019
2048
|
languageId: o.item.language_id,
|
|
2020
2049
|
slug: o.item.slug,
|
|
2021
2050
|
title: o.item.title,
|
|
2022
2051
|
translationGroupId: o.item.translation_group_id
|
|
2023
|
-
},
|
|
2052
|
+
}, p = P({
|
|
2024
2053
|
action: "INSERT CONTENT BLOCK",
|
|
2025
2054
|
context: t,
|
|
2026
2055
|
payload: {
|
|
2027
2056
|
block: d,
|
|
2028
|
-
order:
|
|
2057
|
+
order: m,
|
|
2029
2058
|
target: {
|
|
2030
2059
|
contentType: o.contentType,
|
|
2031
2060
|
id: o.item.id,
|
|
@@ -2046,16 +2075,16 @@ async function Mt(e, t) {
|
|
|
2046
2075
|
},
|
|
2047
2076
|
subject: `${d.block_type} block on ${o.contentType} ${o.item.id}`
|
|
2048
2077
|
});
|
|
2049
|
-
if (
|
|
2050
|
-
return
|
|
2051
|
-
const g = await l(), f = u(g), k = g.filter((b) => Number(b.order) >= f).sort((b,
|
|
2078
|
+
if (p)
|
|
2079
|
+
return p;
|
|
2080
|
+
const g = await l(), f = u(g), k = g.filter((b) => Number(b.order) >= f).sort((b, I) => Number(I.order) - Number(b.order));
|
|
2052
2081
|
for (const b of k) {
|
|
2053
|
-
const { error:
|
|
2082
|
+
const { error: I } = await r.from("blocks").update({
|
|
2054
2083
|
order: Number(b.order) + 1,
|
|
2055
2084
|
updated_at: (/* @__PURE__ */ new Date()).toISOString()
|
|
2056
2085
|
}).eq("id", b.id);
|
|
2057
|
-
if (
|
|
2058
|
-
throw new Error(`Failed to shift block ${b.id}: ${_(
|
|
2086
|
+
if (I)
|
|
2087
|
+
throw new Error(`Failed to shift block ${b.id}: ${_(I)}`);
|
|
2059
2088
|
}
|
|
2060
2089
|
const { data: y, error: w } = await r.from("blocks").insert({
|
|
2061
2090
|
block_type: d.block_type,
|
|
@@ -2068,7 +2097,27 @@ async function Mt(e, t) {
|
|
|
2068
2097
|
}).select("id, block_type, order").single();
|
|
2069
2098
|
if (w || !y)
|
|
2070
2099
|
throw new Error(`Failed to insert content block: ${_(w)}`);
|
|
2071
|
-
return
|
|
2100
|
+
return o.contentType === "product" && await xe({
|
|
2101
|
+
patch: ({ blocks: b }) => ({
|
|
2102
|
+
blocks: [
|
|
2103
|
+
...b.map(
|
|
2104
|
+
(I) => Number(I?.order) >= f ? { ...I, order: Number(I.order) + 1 } : I
|
|
2105
|
+
),
|
|
2106
|
+
{
|
|
2107
|
+
block_type: d.block_type,
|
|
2108
|
+
content: d.content,
|
|
2109
|
+
id: y.id,
|
|
2110
|
+
language_id: o.item.language_id,
|
|
2111
|
+
order: f,
|
|
2112
|
+
page_id: null,
|
|
2113
|
+
post_id: null,
|
|
2114
|
+
product_id: a
|
|
2115
|
+
}
|
|
2116
|
+
].sort((I, x) => Number(I.order) - Number(x.order))
|
|
2117
|
+
}),
|
|
2118
|
+
productId: a,
|
|
2119
|
+
supabase: r
|
|
2120
|
+
}), ve([d], r), U(t, h), {
|
|
2072
2121
|
blockId: y.id,
|
|
2073
2122
|
blockType: y.block_type,
|
|
2074
2123
|
contentType: o.contentType,
|
|
@@ -2078,8 +2127,8 @@ async function Mt(e, t) {
|
|
|
2078
2127
|
success: !0
|
|
2079
2128
|
};
|
|
2080
2129
|
}
|
|
2081
|
-
async function
|
|
2082
|
-
const n = fe.parse(e), r =
|
|
2130
|
+
async function zt(e, t) {
|
|
2131
|
+
const n = fe.parse(e), r = C(t), o = V(t), { data: a, error: s } = await r.from("blocks").select("id, page_id, post_id, product_id, language_id, block_type, content, order").eq("id", n.parentBlockId).single();
|
|
2083
2132
|
if (s || !a)
|
|
2084
2133
|
throw new Error(
|
|
2085
2134
|
`Failed to read parent block ${n.parentBlockId}: ${_(s)}`
|
|
@@ -2108,34 +2157,34 @@ async function Dt(e, t) {
|
|
|
2108
2157
|
throw new Error(
|
|
2109
2158
|
`Nested block was not found at column ${n.columnIndex}, index ${n.blockIndex}.`
|
|
2110
2159
|
);
|
|
2111
|
-
const
|
|
2160
|
+
const m = ae(
|
|
2112
2161
|
c.block_type,
|
|
2113
2162
|
`Nested block ${n.columnIndex}:${n.blockIndex}`
|
|
2114
2163
|
);
|
|
2115
|
-
|
|
2164
|
+
Et(
|
|
2116
2165
|
n.blockType,
|
|
2117
|
-
|
|
2166
|
+
m,
|
|
2118
2167
|
`Nested block ${n.columnIndex}:${n.blockIndex}`
|
|
2119
2168
|
), D(
|
|
2120
|
-
|
|
2169
|
+
m,
|
|
2121
2170
|
n.content,
|
|
2122
2171
|
`Nested block ${n.columnIndex}:${n.blockIndex}`,
|
|
2123
2172
|
t
|
|
2124
2173
|
);
|
|
2125
2174
|
const h = u.column_blocks.map(
|
|
2126
2175
|
(y, w) => w === n.columnIndex ? y.map(
|
|
2127
|
-
(b,
|
|
2176
|
+
(b, I) => I === n.blockIndex ? {
|
|
2128
2177
|
...b,
|
|
2129
2178
|
content: n.content
|
|
2130
2179
|
} : b
|
|
2131
2180
|
) : y
|
|
2132
|
-
),
|
|
2181
|
+
), p = {
|
|
2133
2182
|
...u,
|
|
2134
2183
|
column_blocks: h
|
|
2135
2184
|
};
|
|
2136
2185
|
D(
|
|
2137
2186
|
l,
|
|
2138
|
-
|
|
2187
|
+
p,
|
|
2139
2188
|
`Updated parent block ${n.parentBlockId}`,
|
|
2140
2189
|
t
|
|
2141
2190
|
);
|
|
@@ -2146,41 +2195,49 @@ async function Dt(e, t) {
|
|
|
2146
2195
|
blockIndex: n.blockIndex,
|
|
2147
2196
|
columnIndex: n.columnIndex,
|
|
2148
2197
|
content: n.content,
|
|
2149
|
-
nestedBlockType:
|
|
2198
|
+
nestedBlockType: m,
|
|
2150
2199
|
parentBlockId: n.parentBlockId,
|
|
2151
2200
|
tool: "update_section_column_block"
|
|
2152
2201
|
},
|
|
2153
2202
|
preview: {
|
|
2154
2203
|
blockIndex: n.blockIndex,
|
|
2155
2204
|
columnIndex: n.columnIndex,
|
|
2156
|
-
nestedBlockType:
|
|
2205
|
+
nestedBlockType: m,
|
|
2157
2206
|
parentBlockId: n.parentBlockId,
|
|
2158
2207
|
parentBlockType: l
|
|
2159
2208
|
},
|
|
2160
|
-
subject: `${
|
|
2209
|
+
subject: `${m} nested block ${n.columnIndex}:${n.blockIndex}`
|
|
2161
2210
|
});
|
|
2162
2211
|
if (g)
|
|
2163
2212
|
return g;
|
|
2164
2213
|
const { data: f, error: k } = await r.from("blocks").update({
|
|
2165
|
-
content:
|
|
2214
|
+
content: p,
|
|
2166
2215
|
updated_at: (/* @__PURE__ */ new Date()).toISOString()
|
|
2167
2216
|
}).eq("id", n.parentBlockId).select("id, block_type").single();
|
|
2168
2217
|
if (k || !f)
|
|
2169
2218
|
throw new Error(
|
|
2170
2219
|
`Failed to update parent block ${n.parentBlockId}: ${_(k)}`
|
|
2171
2220
|
);
|
|
2172
|
-
return
|
|
2221
|
+
return await xe({
|
|
2222
|
+
patch: ({ blocks: y }) => ({
|
|
2223
|
+
blocks: y.map(
|
|
2224
|
+
(w) => String(w?.id) === String(n.parentBlockId) ? { ...w, content: p } : w
|
|
2225
|
+
)
|
|
2226
|
+
}),
|
|
2227
|
+
productId: a.product_id,
|
|
2228
|
+
supabase: r
|
|
2229
|
+
}), U(t, o), {
|
|
2173
2230
|
blockIndex: n.blockIndex,
|
|
2174
2231
|
columnIndex: n.columnIndex,
|
|
2175
2232
|
mutationExecuted: !0,
|
|
2176
|
-
nestedBlockType:
|
|
2233
|
+
nestedBlockType: m,
|
|
2177
2234
|
parentBlockId: f.id,
|
|
2178
2235
|
parentBlockType: f.block_type,
|
|
2179
2236
|
success: !0
|
|
2180
2237
|
};
|
|
2181
2238
|
}
|
|
2182
|
-
async function
|
|
2183
|
-
const n = _e.parse(e), r =
|
|
2239
|
+
async function Ve(e, t) {
|
|
2240
|
+
const n = _e.parse(e), r = C(t), o = Re(t), a = await Ce(r, n.languageCode), s = R(n.slug || n.title), l = Se(n.blocks, n.contactEmail, n.title, t), u = await De({
|
|
2184
2241
|
contentType: "page",
|
|
2185
2242
|
languageId: a.id,
|
|
2186
2243
|
slug: s,
|
|
@@ -2188,7 +2245,7 @@ async function He(e, t) {
|
|
|
2188
2245
|
});
|
|
2189
2246
|
if (u)
|
|
2190
2247
|
return u;
|
|
2191
|
-
const d = await
|
|
2248
|
+
const d = await ze({
|
|
2192
2249
|
contentType: "page",
|
|
2193
2250
|
languageCode: a.code,
|
|
2194
2251
|
languageId: a.id,
|
|
@@ -2210,7 +2267,7 @@ async function He(e, t) {
|
|
|
2210
2267
|
translation_group_id: d.translationGroupId
|
|
2211
2268
|
},
|
|
2212
2269
|
tool: "create_cms_page"
|
|
2213
|
-
},
|
|
2270
|
+
}, m = P({
|
|
2214
2271
|
action: "CREATE PAGE",
|
|
2215
2272
|
context: t,
|
|
2216
2273
|
payload: c,
|
|
@@ -2224,22 +2281,22 @@ async function He(e, t) {
|
|
|
2224
2281
|
},
|
|
2225
2282
|
subject: s
|
|
2226
2283
|
});
|
|
2227
|
-
if (
|
|
2228
|
-
return
|
|
2229
|
-
const h = d.translationGroupId ||
|
|
2284
|
+
if (m)
|
|
2285
|
+
return m;
|
|
2286
|
+
const h = d.translationGroupId || qe(), p = await Z(
|
|
2230
2287
|
c.item.feature_image_id,
|
|
2231
2288
|
t,
|
|
2232
2289
|
n.title
|
|
2233
2290
|
), { data: g, error: f } = await r.from("pages").insert({
|
|
2234
2291
|
...c.item,
|
|
2235
2292
|
author_id: o,
|
|
2236
|
-
feature_image_id:
|
|
2293
|
+
feature_image_id: p,
|
|
2237
2294
|
translation_group_id: h
|
|
2238
2295
|
}).select("id, language_id, slug, status, title, translation_group_id").single();
|
|
2239
2296
|
if (f || !g?.id)
|
|
2240
2297
|
throw new Error(`Failed to create page: ${_(f)}`);
|
|
2241
2298
|
try {
|
|
2242
|
-
await
|
|
2299
|
+
await Ge({
|
|
2243
2300
|
blocks: l,
|
|
2244
2301
|
contentType: "page",
|
|
2245
2302
|
itemId: Number(g.id),
|
|
@@ -2247,7 +2304,7 @@ async function He(e, t) {
|
|
|
2247
2304
|
supabase: r
|
|
2248
2305
|
});
|
|
2249
2306
|
} catch (k) {
|
|
2250
|
-
throw await
|
|
2307
|
+
throw await Ke({ contentType: "page", itemId: Number(g.id), supabase: r }), k;
|
|
2251
2308
|
}
|
|
2252
2309
|
return U(
|
|
2253
2310
|
t,
|
|
@@ -2256,7 +2313,7 @@ async function He(e, t) {
|
|
|
2256
2313
|
), t?.revalidatePath?.("/cms/pages"), {
|
|
2257
2314
|
blockCount: l.length,
|
|
2258
2315
|
contentType: "page",
|
|
2259
|
-
editPath:
|
|
2316
|
+
editPath: He("page", g.id),
|
|
2260
2317
|
entityId: g.id,
|
|
2261
2318
|
mutationExecuted: !0,
|
|
2262
2319
|
slug: s,
|
|
@@ -2265,8 +2322,8 @@ async function He(e, t) {
|
|
|
2265
2322
|
translationGroupId: g.translation_group_id
|
|
2266
2323
|
};
|
|
2267
2324
|
}
|
|
2268
|
-
async function
|
|
2269
|
-
const n = be.parse(e), r =
|
|
2325
|
+
async function Je(e, t) {
|
|
2326
|
+
const n = be.parse(e), r = C(t), o = Re(t), a = await Ce(r, n.languageCode), s = R(n.slug || n.title), l = Se(n.blocks, void 0, void 0, t), u = await De({
|
|
2270
2327
|
contentType: "post",
|
|
2271
2328
|
languageId: a.id,
|
|
2272
2329
|
slug: s,
|
|
@@ -2274,7 +2331,7 @@ async function Ve(e, t) {
|
|
|
2274
2331
|
});
|
|
2275
2332
|
if (u)
|
|
2276
2333
|
return u;
|
|
2277
|
-
const d = await
|
|
2334
|
+
const d = await ze({
|
|
2278
2335
|
contentType: "post",
|
|
2279
2336
|
languageCode: a.code,
|
|
2280
2337
|
languageId: a.id,
|
|
@@ -2283,7 +2340,7 @@ async function Ve(e, t) {
|
|
|
2283
2340
|
});
|
|
2284
2341
|
if (d.result)
|
|
2285
2342
|
return d.result;
|
|
2286
|
-
const c = n.published_at && !Number.isNaN(new Date(n.published_at).getTime()) ? new Date(n.published_at).toISOString() : n.published_at ?? null,
|
|
2343
|
+
const c = n.published_at && !Number.isNaN(new Date(n.published_at).getTime()) ? new Date(n.published_at).toISOString() : n.published_at ?? null, m = {
|
|
2287
2344
|
blocks: l,
|
|
2288
2345
|
item: {
|
|
2289
2346
|
excerpt: n.excerpt ?? null,
|
|
@@ -2303,7 +2360,7 @@ async function Ve(e, t) {
|
|
|
2303
2360
|
}, h = P({
|
|
2304
2361
|
action: "CREATE POST",
|
|
2305
2362
|
context: t,
|
|
2306
|
-
payload:
|
|
2363
|
+
payload: m,
|
|
2307
2364
|
preview: {
|
|
2308
2365
|
blockCount: l.length,
|
|
2309
2366
|
languageCode: a.code,
|
|
@@ -2316,20 +2373,20 @@ async function Ve(e, t) {
|
|
|
2316
2373
|
});
|
|
2317
2374
|
if (h)
|
|
2318
2375
|
return h;
|
|
2319
|
-
const
|
|
2320
|
-
|
|
2376
|
+
const p = d.translationGroupId || qe(), g = await Z(
|
|
2377
|
+
m.item.feature_image_id,
|
|
2321
2378
|
t,
|
|
2322
2379
|
n.title
|
|
2323
2380
|
), { data: f, error: k } = await r.from("posts").insert({
|
|
2324
|
-
...
|
|
2381
|
+
...m.item,
|
|
2325
2382
|
author_id: o,
|
|
2326
2383
|
feature_image_id: g,
|
|
2327
|
-
translation_group_id:
|
|
2384
|
+
translation_group_id: p
|
|
2328
2385
|
}).select("id, language_id, slug, status, title, translation_group_id").single();
|
|
2329
2386
|
if (k || !f?.id)
|
|
2330
2387
|
throw new Error(`Failed to create post: ${_(k)}`);
|
|
2331
2388
|
try {
|
|
2332
|
-
await
|
|
2389
|
+
await Ge({
|
|
2333
2390
|
blocks: l,
|
|
2334
2391
|
contentType: "post",
|
|
2335
2392
|
itemId: Number(f.id),
|
|
@@ -2337,7 +2394,7 @@ async function Ve(e, t) {
|
|
|
2337
2394
|
supabase: r
|
|
2338
2395
|
});
|
|
2339
2396
|
} catch (y) {
|
|
2340
|
-
throw await
|
|
2397
|
+
throw await Ke({ contentType: "post", itemId: Number(f.id), supabase: r }), y;
|
|
2341
2398
|
}
|
|
2342
2399
|
return U(
|
|
2343
2400
|
t,
|
|
@@ -2346,7 +2403,7 @@ async function Ve(e, t) {
|
|
|
2346
2403
|
), t?.revalidatePath?.("/cms/posts"), t?.revalidatePath?.("/articles"), {
|
|
2347
2404
|
blockCount: l.length,
|
|
2348
2405
|
contentType: "post",
|
|
2349
|
-
editPath:
|
|
2406
|
+
editPath: He("post", f.id),
|
|
2350
2407
|
entityId: f.id,
|
|
2351
2408
|
mutationExecuted: !0,
|
|
2352
2409
|
slug: s,
|
|
@@ -2358,15 +2415,15 @@ async function Ve(e, t) {
|
|
|
2358
2415
|
function vr(e, t) {
|
|
2359
2416
|
return (t || R(e) || "product").replace(/-/g, "").slice(0, 24).toUpperCase();
|
|
2360
2417
|
}
|
|
2361
|
-
function
|
|
2418
|
+
function Gt(e) {
|
|
2362
2419
|
if (e == null)
|
|
2363
2420
|
return;
|
|
2364
2421
|
if (typeof e == "string")
|
|
2365
|
-
return
|
|
2366
|
-
const t = Array.isArray(e) ? { content: e, type: "doc" } :
|
|
2422
|
+
return pt(e) ?? void 0;
|
|
2423
|
+
const t = Array.isArray(e) ? { content: e, type: "doc" } : $(e) && e.type !== "doc" && Array.isArray(e.content) ? { ...e, type: "doc" } : e, n = et().safeParse(t);
|
|
2367
2424
|
if (!n.success) {
|
|
2368
|
-
if (
|
|
2369
|
-
const r =
|
|
2425
|
+
if ($(e) && typeof e.type == "string") {
|
|
2426
|
+
const r = et().safeParse({
|
|
2370
2427
|
content: [e],
|
|
2371
2428
|
type: "doc"
|
|
2372
2429
|
});
|
|
@@ -2379,15 +2436,15 @@ function zt(e) {
|
|
|
2379
2436
|
}
|
|
2380
2437
|
return n.data;
|
|
2381
2438
|
}
|
|
2382
|
-
function
|
|
2383
|
-
const t = (o) => !!(o && Array.isArray(o.content) && o.content.length > 0), n =
|
|
2439
|
+
function Er(e) {
|
|
2440
|
+
const t = (o) => !!(o && Array.isArray(o.content) && o.content.length > 0), n = Gt(e.description_json);
|
|
2384
2441
|
if (t(n))
|
|
2385
2442
|
return n;
|
|
2386
|
-
const r = e.description_html ?
|
|
2443
|
+
const r = e.description_html ? pt(e.description_html) : null;
|
|
2387
2444
|
return t(r) ? r : void 0;
|
|
2388
2445
|
}
|
|
2389
|
-
async function
|
|
2390
|
-
const n = ke.parse(e), r =
|
|
2446
|
+
async function Kt(e, t) {
|
|
2447
|
+
const n = ke.parse(e), r = C(t), o = await Ce(r, n.languageCode), a = R(n.slug || n.title), s = Se(n.blocks, void 0, void 0, t), l = await De({
|
|
2391
2448
|
contentType: "product",
|
|
2392
2449
|
languageId: o.id,
|
|
2393
2450
|
slug: a,
|
|
@@ -2395,7 +2452,7 @@ async function Gt(e, t) {
|
|
|
2395
2452
|
});
|
|
2396
2453
|
if (l)
|
|
2397
2454
|
return l;
|
|
2398
|
-
const u = await
|
|
2455
|
+
const u = await ze({
|
|
2399
2456
|
contentType: "product",
|
|
2400
2457
|
languageCode: o.code,
|
|
2401
2458
|
languageId: o.id,
|
|
@@ -2404,8 +2461,8 @@ async function Gt(e, t) {
|
|
|
2404
2461
|
});
|
|
2405
2462
|
if (u.result)
|
|
2406
2463
|
return u.result;
|
|
2407
|
-
const { createProduct: d, productSchema: c } = await
|
|
2408
|
-
description_json:
|
|
2464
|
+
const { createProduct: d, productSchema: c } = await On(), h = n.product_type === "digital" && n.payment_provider === "freemius" ? n.trial_period_days : 0, p = c.parse({
|
|
2465
|
+
description_json: Er(n),
|
|
2409
2466
|
freemius_plan_id: n.freemius_plan_id || "",
|
|
2410
2467
|
freemius_product_id: n.freemius_product_id || "",
|
|
2411
2468
|
is_taxable: n.is_taxable,
|
|
@@ -2434,18 +2491,18 @@ async function Gt(e, t) {
|
|
|
2434
2491
|
}), g = n.images ?? [], f = P({
|
|
2435
2492
|
action: "CREATE PRODUCT",
|
|
2436
2493
|
context: t,
|
|
2437
|
-
payload: { blocks: s, images: g, item:
|
|
2494
|
+
payload: { blocks: s, images: g, item: p, tool: "create_cms_product" },
|
|
2438
2495
|
preview: {
|
|
2439
2496
|
blockCount: s.length,
|
|
2440
|
-
descriptionLength:
|
|
2497
|
+
descriptionLength: p.description_json ? JSON.stringify(p.description_json).length : 0,
|
|
2441
2498
|
imageCount: g.length,
|
|
2442
2499
|
languageCode: o.code,
|
|
2443
|
-
price:
|
|
2444
|
-
sku:
|
|
2500
|
+
price: p.price,
|
|
2501
|
+
sku: p.sku,
|
|
2445
2502
|
slug: a,
|
|
2446
|
-
status:
|
|
2447
|
-
stock:
|
|
2448
|
-
title:
|
|
2503
|
+
status: p.status,
|
|
2504
|
+
stock: p.stock,
|
|
2505
|
+
title: p.title,
|
|
2449
2506
|
translationGroupId: u.translationGroupId
|
|
2450
2507
|
},
|
|
2451
2508
|
subject: a
|
|
@@ -2455,20 +2512,20 @@ async function Gt(e, t) {
|
|
|
2455
2512
|
let k = [], y = null;
|
|
2456
2513
|
if (g.length > 0)
|
|
2457
2514
|
try {
|
|
2458
|
-
if (k = [...new Set(await
|
|
2515
|
+
if (k = [...new Set(await It(g, t, n.title))], k.length === 0)
|
|
2459
2516
|
throw new Error("None of the provided images could be resolved to a media item.");
|
|
2460
2517
|
} catch (b) {
|
|
2461
2518
|
y = b instanceof Error ? b.message : String(b);
|
|
2462
2519
|
}
|
|
2463
2520
|
const w = await d(r, {
|
|
2464
|
-
...
|
|
2521
|
+
...p,
|
|
2465
2522
|
// First entry is the main product image; the rest become the gallery in order.
|
|
2466
2523
|
product_media: k.map((b) => ({ media_id: b }))
|
|
2467
2524
|
});
|
|
2468
2525
|
if (!w?.id)
|
|
2469
2526
|
throw new Error("Failed to create product.");
|
|
2470
2527
|
try {
|
|
2471
|
-
await
|
|
2528
|
+
await Ge({
|
|
2472
2529
|
blocks: s,
|
|
2473
2530
|
contentType: "product",
|
|
2474
2531
|
itemId: w.id,
|
|
@@ -2476,7 +2533,7 @@ async function Gt(e, t) {
|
|
|
2476
2533
|
supabase: r
|
|
2477
2534
|
});
|
|
2478
2535
|
} catch (b) {
|
|
2479
|
-
throw await
|
|
2536
|
+
throw await Ke({ contentType: "product", itemId: w.id, supabase: r }), b;
|
|
2480
2537
|
}
|
|
2481
2538
|
return U(
|
|
2482
2539
|
t,
|
|
@@ -2485,7 +2542,7 @@ async function Gt(e, t) {
|
|
|
2485
2542
|
), t?.revalidatePath?.("/cms/products"), {
|
|
2486
2543
|
blockCount: s.length,
|
|
2487
2544
|
contentType: "product",
|
|
2488
|
-
editPath:
|
|
2545
|
+
editPath: He("product", w.id),
|
|
2489
2546
|
entityId: w.id,
|
|
2490
2547
|
imageCount: k.length,
|
|
2491
2548
|
...y ? { imageError: y } : {},
|
|
@@ -2496,32 +2553,32 @@ async function Gt(e, t) {
|
|
|
2496
2553
|
translationGroupId: w.translation_group_id
|
|
2497
2554
|
};
|
|
2498
2555
|
}
|
|
2499
|
-
function
|
|
2556
|
+
function We(e) {
|
|
2500
2557
|
return e.trim().replace(/[\s-]+/g, "_").toLowerCase();
|
|
2501
2558
|
}
|
|
2502
|
-
function
|
|
2503
|
-
const n = typeof t == "string" ?
|
|
2559
|
+
function $r(e, t) {
|
|
2560
|
+
const n = typeof t == "string" ? We(t) : t;
|
|
2504
2561
|
return e === "product" ? n === "public" || n === "publish" || n === "published" ? "active" : n : n === "public" || n === "active" || n === "publish" ? "published" : n;
|
|
2505
2562
|
}
|
|
2506
|
-
function
|
|
2507
|
-
const t =
|
|
2563
|
+
function Ar(e) {
|
|
2564
|
+
const t = We(e.field);
|
|
2508
2565
|
return !!(e.startsAt || e.endsAt || t.includes("start") || t.includes("end") || t.includes("schedule") || t.includes("special_date"));
|
|
2509
2566
|
}
|
|
2510
|
-
async function
|
|
2567
|
+
async function Pr(e, t, n) {
|
|
2511
2568
|
if (e === "price" || e === "sale_price") {
|
|
2512
2569
|
if (t == null)
|
|
2513
2570
|
return { [e]: null };
|
|
2514
|
-
const r = await
|
|
2515
|
-
return { [e]:
|
|
2571
|
+
const r = await nt(n);
|
|
2572
|
+
return { [e]: St(Number(t), r) };
|
|
2516
2573
|
}
|
|
2517
2574
|
if (e === "prices" || e === "sale_prices") {
|
|
2518
|
-
const r = await
|
|
2519
|
-
return { [e]:
|
|
2575
|
+
const r = await nt(n);
|
|
2576
|
+
return { [e]: qn(t, r) };
|
|
2520
2577
|
}
|
|
2521
|
-
return e === "description_json" ? { description_json:
|
|
2578
|
+
return e === "description_json" ? { description_json: Gt(t) } : { [e]: t };
|
|
2522
2579
|
}
|
|
2523
|
-
function
|
|
2524
|
-
const n =
|
|
2580
|
+
function Nr(e, t) {
|
|
2581
|
+
const n = We(e.field), r = n === "status" ? $r(t.contentType, e.value) : e.value, a = {
|
|
2525
2582
|
description: "description_json",
|
|
2526
2583
|
feature_image: "feature_image_id",
|
|
2527
2584
|
feature_image_id: "feature_image_id",
|
|
@@ -2541,12 +2598,12 @@ function Pr(e, t) {
|
|
|
2541
2598
|
type: "product_type"
|
|
2542
2599
|
}[n] || n;
|
|
2543
2600
|
if (t.contentType !== "product") {
|
|
2544
|
-
if (!(t.contentType === "page" ?
|
|
2601
|
+
if (!(t.contentType === "page" ? Lt : Bt).has(a))
|
|
2545
2602
|
throw new Error(`Field "${e.field}" cannot be updated for ${t.contentType}.`);
|
|
2546
|
-
return a === "status" &&
|
|
2603
|
+
return a === "status" && Ne(t.contentType, r), {
|
|
2547
2604
|
field: a,
|
|
2548
2605
|
payload: {
|
|
2549
|
-
[a]:
|
|
2606
|
+
[a]: Rt(a, r)
|
|
2550
2607
|
}
|
|
2551
2608
|
};
|
|
2552
2609
|
}
|
|
@@ -2575,7 +2632,7 @@ function Pr(e, t) {
|
|
|
2575
2632
|
"upc"
|
|
2576
2633
|
])).has(a))
|
|
2577
2634
|
throw new Error(`Field "${e.field}" cannot be updated for product.`);
|
|
2578
|
-
if (a === "status" &&
|
|
2635
|
+
if (a === "status" && Ne("product", r), (a === "price" || a === "sale_price") && r !== null && (typeof r != "number" || r < 0))
|
|
2579
2636
|
throw new Error(`${a} must be a non-negative number or null.`);
|
|
2580
2637
|
if (a === "stock" && (!Number.isInteger(r) || Number(r) < 0))
|
|
2581
2638
|
throw new Error("stock must be a non-negative integer.");
|
|
@@ -2590,22 +2647,22 @@ function Pr(e, t) {
|
|
|
2590
2647
|
}
|
|
2591
2648
|
};
|
|
2592
2649
|
}
|
|
2593
|
-
async function
|
|
2650
|
+
async function Ht(e, t) {
|
|
2594
2651
|
const n = we.parse(e);
|
|
2595
|
-
if (
|
|
2652
|
+
if (Ar(n))
|
|
2596
2653
|
return {
|
|
2597
2654
|
message: "Scheduled product specials are not supported by the current product schema yet. I can set or clear sale_price now, but not start/end dates.",
|
|
2598
2655
|
mutationExecuted: !1,
|
|
2599
2656
|
success: !1,
|
|
2600
2657
|
unsupported: !0
|
|
2601
2658
|
};
|
|
2602
|
-
const r = await te(n, t), o =
|
|
2659
|
+
const r = await te(n, t), o = Nr(n, r), a = o.field;
|
|
2603
2660
|
let s = o.payload;
|
|
2604
2661
|
if (a === "language_id" && typeof s.language_id == "string") {
|
|
2605
|
-
const
|
|
2662
|
+
const m = await J(C(t), s.language_id);
|
|
2606
2663
|
s = {
|
|
2607
2664
|
...s,
|
|
2608
|
-
language_id:
|
|
2665
|
+
language_id: m.id
|
|
2609
2666
|
};
|
|
2610
2667
|
}
|
|
2611
2668
|
const l = P({
|
|
@@ -2631,28 +2688,28 @@ async function Kt(e, t) {
|
|
|
2631
2688
|
if (l)
|
|
2632
2689
|
return l;
|
|
2633
2690
|
if (r.contentType === "product") {
|
|
2634
|
-
const
|
|
2691
|
+
const m = C(t), h = await Pr(a, s[a], m), { data: p, error: g } = await m.from("products").update({
|
|
2635
2692
|
...h,
|
|
2636
2693
|
updated_at: (/* @__PURE__ */ new Date()).toISOString()
|
|
2637
2694
|
}).eq("id", r.item.id).select("id, language_id, slug, status, title").single();
|
|
2638
|
-
if (g || !
|
|
2695
|
+
if (g || !p)
|
|
2639
2696
|
throw new Error(`Failed to update product: ${_(g)}`);
|
|
2640
2697
|
return U(
|
|
2641
2698
|
t,
|
|
2642
2699
|
{
|
|
2643
2700
|
contentType: "product",
|
|
2644
|
-
entityId: String(
|
|
2645
|
-
languageId:
|
|
2646
|
-
slug:
|
|
2647
|
-
title:
|
|
2701
|
+
entityId: String(p.id),
|
|
2702
|
+
languageId: p.language_id,
|
|
2703
|
+
slug: p.slug,
|
|
2704
|
+
title: p.title
|
|
2648
2705
|
},
|
|
2649
|
-
|
|
2706
|
+
p.slug
|
|
2650
2707
|
), {
|
|
2651
2708
|
contentType: "product",
|
|
2652
|
-
entityId:
|
|
2709
|
+
entityId: p.id,
|
|
2653
2710
|
field: a,
|
|
2654
2711
|
mutationExecuted: !0,
|
|
2655
|
-
slug:
|
|
2712
|
+
slug: p.slug,
|
|
2656
2713
|
success: !0,
|
|
2657
2714
|
updatedFields: [a]
|
|
2658
2715
|
};
|
|
@@ -2665,7 +2722,7 @@ async function Kt(e, t) {
|
|
|
2665
2722
|
typeof r.item.title == "string" ? r.item.title : void 0
|
|
2666
2723
|
)
|
|
2667
2724
|
});
|
|
2668
|
-
const u = r.contentType === "page" ? "pages" : "posts", { data: d, error: c } = await
|
|
2725
|
+
const u = r.contentType === "page" ? "pages" : "posts", { data: d, error: c } = await C(t).from(u).update({
|
|
2669
2726
|
...s,
|
|
2670
2727
|
updated_at: (/* @__PURE__ */ new Date()).toISOString()
|
|
2671
2728
|
}).eq("id", r.item.id).select("id, language_id, slug, status, title").single();
|
|
@@ -2691,40 +2748,40 @@ async function Kt(e, t) {
|
|
|
2691
2748
|
updatedFields: [a]
|
|
2692
2749
|
};
|
|
2693
2750
|
}
|
|
2694
|
-
async function
|
|
2695
|
-
const n =
|
|
2751
|
+
async function Vt(e, t) {
|
|
2752
|
+
const n = _t.parse(e), r = await te(n, t);
|
|
2696
2753
|
if (r.contentType === "product")
|
|
2697
2754
|
return {
|
|
2698
2755
|
affectedCount: 1,
|
|
2699
|
-
collectionPath:
|
|
2756
|
+
collectionPath: ot("product"),
|
|
2700
2757
|
contentType: "product",
|
|
2701
2758
|
item: r.item,
|
|
2702
2759
|
navigationLinkCount: 0,
|
|
2703
2760
|
publicPaths: r.item.slug ? [`/product/${r.item.slug}`] : [],
|
|
2704
2761
|
targetIds: [r.item.id]
|
|
2705
2762
|
};
|
|
2706
|
-
const o = r.contentType === "page" ? "pages" : "posts", { data: a, error: s } = await
|
|
2763
|
+
const o = r.contentType === "page" ? "pages" : "posts", { data: a, error: s } = await C(t).from(o).select("id, slug, title, translation_group_id").eq("translation_group_id", r.item.translation_group_id);
|
|
2707
2764
|
if (s)
|
|
2708
2765
|
throw new Error(`Failed to inspect related ${r.contentType}s: ${_(s)}`);
|
|
2709
2766
|
const l = Array.isArray(a) ? a : [], u = l.map(
|
|
2710
|
-
(
|
|
2711
|
-
).filter(Boolean), d = new Set(u), { data: c, error:
|
|
2712
|
-
if (
|
|
2713
|
-
throw new Error(`Failed to inspect related navigation links: ${_(
|
|
2767
|
+
(p) => r.contentType === "page" ? p.slug === "home" ? "/" : `/${p.slug}` : `/article/${p.slug}`
|
|
2768
|
+
).filter(Boolean), d = new Set(u), { data: c, error: m } = await C(t).from("navigation_items").select("id, url");
|
|
2769
|
+
if (m)
|
|
2770
|
+
throw new Error(`Failed to inspect related navigation links: ${_(m)}`);
|
|
2714
2771
|
const h = (Array.isArray(c) ? c : []).filter(
|
|
2715
|
-
(
|
|
2772
|
+
(p) => d.has(p.url)
|
|
2716
2773
|
).length;
|
|
2717
2774
|
return {
|
|
2718
2775
|
affectedCount: l.length,
|
|
2719
|
-
collectionPath:
|
|
2776
|
+
collectionPath: ot(r.contentType),
|
|
2720
2777
|
contentType: r.contentType,
|
|
2721
2778
|
item: r.item,
|
|
2722
2779
|
navigationLinkCount: h,
|
|
2723
2780
|
publicPaths: u,
|
|
2724
|
-
targetIds: l.map((
|
|
2781
|
+
targetIds: l.map((p) => p.id)
|
|
2725
2782
|
};
|
|
2726
2783
|
}
|
|
2727
|
-
function
|
|
2784
|
+
function Jt(e) {
|
|
2728
2785
|
const t = e.item.title || e.item.slug || "selected item", n = e.item.slug ? ` (${e.item.slug})` : "";
|
|
2729
2786
|
if (e.contentType === "product")
|
|
2730
2787
|
return `Delete product "${t}"${n}.`;
|
|
@@ -2734,10 +2791,10 @@ function Vt(e) {
|
|
|
2734
2791
|
].filter(Boolean);
|
|
2735
2792
|
return `Delete ${e.contentType} "${t}"${n}, including ${r.join(" and ")}.`;
|
|
2736
2793
|
}
|
|
2737
|
-
async function
|
|
2738
|
-
const n = await
|
|
2794
|
+
async function Ur(e, t) {
|
|
2795
|
+
const n = await Vt(e, t);
|
|
2739
2796
|
return {
|
|
2740
|
-
...
|
|
2797
|
+
...Ct({
|
|
2741
2798
|
action: `DELETE ${n.contentType}`,
|
|
2742
2799
|
payload: {
|
|
2743
2800
|
affectedCount: n.affectedCount,
|
|
@@ -2752,7 +2809,7 @@ async function Nr(e, t) {
|
|
|
2752
2809
|
navigationLinkCount: n.navigationLinkCount,
|
|
2753
2810
|
publicPaths: n.publicPaths,
|
|
2754
2811
|
slug: n.item.slug,
|
|
2755
|
-
summary:
|
|
2812
|
+
summary: Jt(n),
|
|
2756
2813
|
title: n.item.title
|
|
2757
2814
|
},
|
|
2758
2815
|
subject: `${n.item.id} ${n.item.slug || ""}`
|
|
@@ -2760,8 +2817,8 @@ async function Nr(e, t) {
|
|
|
2760
2817
|
preparedDelete: !0
|
|
2761
2818
|
};
|
|
2762
2819
|
}
|
|
2763
|
-
async function
|
|
2764
|
-
const n = Ie.parse(e), r = await
|
|
2820
|
+
async function Wt(e, t) {
|
|
2821
|
+
const n = Ie.parse(e), r = await Vt(n, t), o = P({
|
|
2765
2822
|
action: `DELETE ${r.contentType}`,
|
|
2766
2823
|
context: t,
|
|
2767
2824
|
payload: {
|
|
@@ -2777,14 +2834,14 @@ async function Jt(e, t) {
|
|
|
2777
2834
|
navigationLinkCount: r.navigationLinkCount,
|
|
2778
2835
|
publicPaths: r.publicPaths,
|
|
2779
2836
|
slug: r.item.slug,
|
|
2780
|
-
summary:
|
|
2837
|
+
summary: Jt(r),
|
|
2781
2838
|
title: r.item.title
|
|
2782
2839
|
},
|
|
2783
2840
|
subject: `${r.item.id} ${r.item.slug || ""}`
|
|
2784
2841
|
});
|
|
2785
2842
|
if (o)
|
|
2786
2843
|
return o;
|
|
2787
|
-
const a =
|
|
2844
|
+
const a = C(t);
|
|
2788
2845
|
if (r.contentType === "product") {
|
|
2789
2846
|
const { error: l } = await a.from("products").delete().eq("id", r.item.id);
|
|
2790
2847
|
if (l)
|
|
@@ -2796,7 +2853,7 @@ async function Jt(e, t) {
|
|
|
2796
2853
|
if (u)
|
|
2797
2854
|
throw new Error(`Failed to delete ${r.contentType}: ${_(u)}`);
|
|
2798
2855
|
}
|
|
2799
|
-
const s = t?.revalidatePath ??
|
|
2856
|
+
const s = t?.revalidatePath ?? Le();
|
|
2800
2857
|
return s && (s(r.collectionPath), s("/cms/navigation"), r.publicPaths.forEach((l) => s(l))), {
|
|
2801
2858
|
affectedCount: r.affectedCount,
|
|
2802
2859
|
collectionPath: r.collectionPath,
|
|
@@ -2806,35 +2863,35 @@ async function Jt(e, t) {
|
|
|
2806
2863
|
success: !0
|
|
2807
2864
|
};
|
|
2808
2865
|
}
|
|
2809
|
-
async function
|
|
2866
|
+
async function st(e, t) {
|
|
2810
2867
|
switch (e.tool) {
|
|
2811
2868
|
case "create_cms_page":
|
|
2812
|
-
return He(e.input, t);
|
|
2813
|
-
case "create_cms_post":
|
|
2814
2869
|
return Ve(e.input, t);
|
|
2870
|
+
case "create_cms_post":
|
|
2871
|
+
return Je(e.input, t);
|
|
2815
2872
|
case "create_cms_product":
|
|
2816
|
-
return
|
|
2873
|
+
return Kt(e.input, t);
|
|
2817
2874
|
case "delete_cms_item":
|
|
2818
|
-
return
|
|
2875
|
+
return Wt(e.input, t);
|
|
2819
2876
|
case "update_cms_item_field":
|
|
2820
|
-
return
|
|
2877
|
+
return Ht(e.input, t);
|
|
2821
2878
|
case "update_content_block":
|
|
2822
|
-
return qt(e.input, t);
|
|
2823
|
-
case "insert_content_block":
|
|
2824
2879
|
return Mt(e.input, t);
|
|
2880
|
+
case "insert_content_block":
|
|
2881
|
+
return Dt(e.input, t);
|
|
2825
2882
|
case "update_current_cms_fields":
|
|
2826
|
-
return
|
|
2883
|
+
return qt(e.input, t);
|
|
2827
2884
|
case "update_footer":
|
|
2828
|
-
return
|
|
2885
|
+
return Ft(e.input, t);
|
|
2829
2886
|
case "update_navigation_bar":
|
|
2830
|
-
return
|
|
2887
|
+
return Ot(e.input, t);
|
|
2831
2888
|
case "update_section_column_block":
|
|
2832
|
-
return
|
|
2889
|
+
return zt(e.input, t);
|
|
2833
2890
|
case "set_content_images":
|
|
2834
|
-
return
|
|
2891
|
+
return on(e.input, t);
|
|
2835
2892
|
}
|
|
2836
2893
|
}
|
|
2837
|
-
function
|
|
2894
|
+
function Or(e, t) {
|
|
2838
2895
|
if (e.tool !== "create_cms_page" && e.tool !== "create_cms_post" && e.tool !== "create_cms_product" || e.input.translationGroupId || !e.input.languageCode)
|
|
2839
2896
|
return e;
|
|
2840
2897
|
const n = t[e.tool];
|
|
@@ -2846,10 +2903,10 @@ function Ur(e, t) {
|
|
|
2846
2903
|
}
|
|
2847
2904
|
} : e;
|
|
2848
2905
|
}
|
|
2849
|
-
function
|
|
2906
|
+
function lt(e) {
|
|
2850
2907
|
return e === "create_cms_page" ? "page" : e === "create_cms_post" ? "post" : "product";
|
|
2851
2908
|
}
|
|
2852
|
-
function
|
|
2909
|
+
function Fr(e, t, n) {
|
|
2853
2910
|
if (e.tool !== "set_content_images")
|
|
2854
2911
|
return e;
|
|
2855
2912
|
const r = e.input;
|
|
@@ -2867,47 +2924,47 @@ function Or(e, t, n) {
|
|
|
2867
2924
|
}
|
|
2868
2925
|
} : e;
|
|
2869
2926
|
}
|
|
2870
|
-
async function
|
|
2871
|
-
const n =
|
|
2927
|
+
async function jr(e, t) {
|
|
2928
|
+
const n = kt.parse(e), r = new Set(
|
|
2872
2929
|
n.actions.filter(
|
|
2873
|
-
(
|
|
2874
|
-
).map((
|
|
2875
|
-
const g =
|
|
2876
|
-
return `${
|
|
2930
|
+
(p) => p.tool === "create_cms_page" || p.tool === "create_cms_post" || p.tool === "create_cms_product"
|
|
2931
|
+
).map((p) => {
|
|
2932
|
+
const g = p.input;
|
|
2933
|
+
return `${lt(p.tool)}:${R(g.slug || g.title || "")}`;
|
|
2877
2934
|
})
|
|
2878
|
-
), o = (
|
|
2879
|
-
if (
|
|
2935
|
+
), o = (p) => {
|
|
2936
|
+
if (p.tool !== "set_content_images")
|
|
2880
2937
|
return !1;
|
|
2881
|
-
const g =
|
|
2938
|
+
const g = p.input;
|
|
2882
2939
|
return g.slug ? r.has(
|
|
2883
2940
|
`${g.contentType || "product"}:${R(g.slug)}`
|
|
2884
2941
|
) : r.size > 0;
|
|
2885
2942
|
};
|
|
2886
2943
|
if (!t?.skipConfirmation) {
|
|
2887
|
-
const
|
|
2944
|
+
const p = [];
|
|
2888
2945
|
for (const k of n.actions) {
|
|
2889
2946
|
if (o(k)) {
|
|
2890
2947
|
const w = k.input;
|
|
2891
|
-
|
|
2948
|
+
p.push(
|
|
2892
2949
|
`Set ${N(w.images.length, "image")} on the ${w.slug ? `"${w.slug}"` : "new"} item created in this plan.`
|
|
2893
2950
|
);
|
|
2894
2951
|
continue;
|
|
2895
2952
|
}
|
|
2896
|
-
const y = await
|
|
2953
|
+
const y = await st(k, {
|
|
2897
2954
|
...t,
|
|
2898
2955
|
latestUserMessage: null
|
|
2899
2956
|
});
|
|
2900
2957
|
if (!y || typeof y != "object")
|
|
2901
2958
|
return {
|
|
2902
|
-
message: `Could not prepare action ${
|
|
2959
|
+
message: `Could not prepare action ${p.length + 1}.`,
|
|
2903
2960
|
mutationExecuted: !1,
|
|
2904
2961
|
success: !1
|
|
2905
2962
|
};
|
|
2906
2963
|
if (y.success === !1 || y.unsupported === !0)
|
|
2907
2964
|
return y;
|
|
2908
|
-
y.requiresConfirmation === !0 && y.preview ?
|
|
2909
|
-
|
|
2910
|
-
) :
|
|
2965
|
+
y.requiresConfirmation === !0 && y.preview ? p.push(
|
|
2966
|
+
Ln(k.tool, y.preview)
|
|
2967
|
+
) : p.push(`Run ${k.tool.replace(/_/g, " ")}.`);
|
|
2911
2968
|
}
|
|
2912
2969
|
const g = n.summary || `Complete ${N(n.actions.length, "CMS action")}.`, f = P({
|
|
2913
2970
|
action: "EXECUTE CMS ACTION PLAN",
|
|
@@ -2915,7 +2972,7 @@ async function Fr(e, t) {
|
|
|
2915
2972
|
payload: { actions: n.actions, tool: "execute_cms_action_plan" },
|
|
2916
2973
|
preview: {
|
|
2917
2974
|
actionCount: n.actions.length,
|
|
2918
|
-
actionSummaries:
|
|
2975
|
+
actionSummaries: p,
|
|
2919
2976
|
summary: g
|
|
2920
2977
|
},
|
|
2921
2978
|
subject: `${n.actions.length} actions`
|
|
@@ -2928,29 +2985,29 @@ async function Fr(e, t) {
|
|
|
2928
2985
|
skipConfirmation: !0
|
|
2929
2986
|
}, s = [];
|
|
2930
2987
|
let l = !1, u = null, d = null;
|
|
2931
|
-
const c = {},
|
|
2988
|
+
const c = {}, m = /* @__PURE__ */ new Map();
|
|
2932
2989
|
let h = null;
|
|
2933
|
-
for (const [
|
|
2934
|
-
const f =
|
|
2935
|
-
|
|
2936
|
-
|
|
2990
|
+
for (const [p, g] of n.actions.entries()) {
|
|
2991
|
+
const f = Fr(
|
|
2992
|
+
Or(g, c),
|
|
2993
|
+
m,
|
|
2937
2994
|
h
|
|
2938
|
-
), k = await
|
|
2995
|
+
), k = await st(f, a);
|
|
2939
2996
|
if (s.push({ output: k, tool: f.tool }), k && typeof k == "object") {
|
|
2940
2997
|
const y = k;
|
|
2941
2998
|
if (y.mutationExecuted === !0 && (l = !0), !u && typeof y.editPath == "string" && (u = y.editPath), typeof y.redirectPath == "string" && (d = y.redirectPath), (f.tool === "create_cms_page" || f.tool === "create_cms_post" || f.tool === "create_cms_product") && (typeof y.translationGroupId == "string" && (c[f.tool] = y.translationGroupId), y.entityId !== void 0 && y.entityId !== null)) {
|
|
2942
|
-
const w =
|
|
2999
|
+
const w = lt(f.tool), b = {
|
|
2943
3000
|
contentType: w,
|
|
2944
3001
|
entityId: y.entityId
|
|
2945
3002
|
};
|
|
2946
|
-
h = b, typeof y.slug == "string" &&
|
|
3003
|
+
h = b, typeof y.slug == "string" && m.set(`${w}:${y.slug}`, b);
|
|
2947
3004
|
}
|
|
2948
3005
|
if (y.success === !1 || y.unsupported === !0)
|
|
2949
3006
|
return {
|
|
2950
3007
|
actionCount: n.actions.length,
|
|
2951
|
-
failedActionIndex:
|
|
3008
|
+
failedActionIndex: p,
|
|
2952
3009
|
failedTool: f.tool,
|
|
2953
|
-
message: typeof y.message == "string" ? y.message : `Action ${
|
|
3010
|
+
message: typeof y.message == "string" ? y.message : `Action ${p + 1} failed.`,
|
|
2954
3011
|
mutationExecuted: l,
|
|
2955
3012
|
results: s,
|
|
2956
3013
|
success: !1,
|
|
@@ -2969,11 +3026,11 @@ async function Fr(e, t) {
|
|
|
2969
3026
|
summary: n.summary ?? null
|
|
2970
3027
|
};
|
|
2971
3028
|
}
|
|
2972
|
-
const
|
|
3029
|
+
const Yt = i.strictObject({
|
|
2973
3030
|
maxChars: i.number().int().min(500).max(2e4).default(8e3).describe("Maximum characters of readable body text to return."),
|
|
2974
3031
|
url: i.string().trim().min(1).max(2048).refine((e) => /^https?:\/\//i.test(e), "URL must start with http:// or https://.")
|
|
2975
|
-
}),
|
|
2976
|
-
function
|
|
3032
|
+
}), Lr = 12e3, ct = 2e6;
|
|
3033
|
+
function ut(e) {
|
|
2977
3034
|
const t = e.trim().toLowerCase().replace(/\.$/, "").replace(/^\[|\]$/g, "");
|
|
2978
3035
|
if (!t || t === "localhost" || t.endsWith(".localhost") || t.endsWith(".local") || t.endsWith(".internal") || t === "metadata.google.internal" || t === "0.0.0.0" || t === "::1" || t.startsWith("fe80:") || t.startsWith("fc") || t.startsWith("fd"))
|
|
2979
3036
|
return !0;
|
|
@@ -2988,14 +3045,14 @@ function ct(e) {
|
|
|
2988
3045
|
function re(e) {
|
|
2989
3046
|
return e.replace(/<[^>]+>/g, " ").replace(/ /gi, " ").replace(/&/gi, "&").replace(/</gi, "<").replace(/>/gi, ">").replace(/"/gi, '"').replace(/'/gi, "'").replace(/\s+/g, " ").trim();
|
|
2990
3047
|
}
|
|
2991
|
-
function
|
|
3048
|
+
function Br(e) {
|
|
2992
3049
|
return e.trim().replace(/&/gi, "&").replace(/&/g, "&").replace(/"/gi, '"').replace(/'/g, "'");
|
|
2993
3050
|
}
|
|
2994
|
-
const
|
|
3051
|
+
const Xt = /\.(avif|gif|jpe?g|png|webp)(?:[?#]|$)/i, Qt = /(?:^|[/_-])(?:sprite|icon|favicon|logo|placeholder|pixel|spacer|blank|avatar|badge|flag|loader|spinner|1x1|transparent|watermark|payment|visa|mastercard|paypal|amex|social|share|facebook|twitter|instagram|youtube|pinterest|linkedin)(?:[/_.-]|$)/i;
|
|
2995
3052
|
function ue(e, t) {
|
|
2996
3053
|
if (typeof e != "string")
|
|
2997
3054
|
return null;
|
|
2998
|
-
const n =
|
|
3055
|
+
const n = Br(e);
|
|
2999
3056
|
if (!n || n.startsWith("data:"))
|
|
3000
3057
|
return null;
|
|
3001
3058
|
try {
|
|
@@ -3005,7 +3062,7 @@ function ue(e, t) {
|
|
|
3005
3062
|
return null;
|
|
3006
3063
|
}
|
|
3007
3064
|
}
|
|
3008
|
-
function
|
|
3065
|
+
function Rr(e) {
|
|
3009
3066
|
let t = null;
|
|
3010
3067
|
for (const n of e.split(",")) {
|
|
3011
3068
|
const r = n.trim().split(/\s+/), o = r[0];
|
|
@@ -3022,7 +3079,7 @@ function F(e, t) {
|
|
|
3022
3079
|
);
|
|
3023
3080
|
return n ? n[1] ?? n[2] ?? n[3] ?? null : null;
|
|
3024
3081
|
}
|
|
3025
|
-
function
|
|
3082
|
+
function qr(e, t) {
|
|
3026
3083
|
const n = [], r = [], o = (l, u) => {
|
|
3027
3084
|
if (typeof l == "string") {
|
|
3028
3085
|
const d = ue(l, t);
|
|
@@ -3039,16 +3096,16 @@ function Rr(e, t) {
|
|
|
3039
3096
|
if (u > 8 || !l || typeof l != "object")
|
|
3040
3097
|
return;
|
|
3041
3098
|
if (Array.isArray(l)) {
|
|
3042
|
-
for (const
|
|
3043
|
-
a(
|
|
3099
|
+
for (const p of l)
|
|
3100
|
+
a(p, u + 1);
|
|
3044
3101
|
return;
|
|
3045
3102
|
}
|
|
3046
|
-
const d = l, c = d["@type"], h = (Array.isArray(c) ? c : [c]).filter((
|
|
3047
|
-
(
|
|
3103
|
+
const d = l, c = d["@type"], h = (Array.isArray(c) ? c : [c]).filter((p) => typeof p == "string").map((p) => p.toLowerCase()).some(
|
|
3104
|
+
(p) => p === "product" || p === "productgroup" || p === "itempage"
|
|
3048
3105
|
);
|
|
3049
3106
|
"image" in d && o(d.image, h ? n : r);
|
|
3050
|
-
for (const
|
|
3051
|
-
a(
|
|
3107
|
+
for (const p of Object.values(d))
|
|
3108
|
+
a(p, u + 1);
|
|
3052
3109
|
}, s = e.matchAll(
|
|
3053
3110
|
/<script\b[^>]*type\s*=\s*["']application\/ld\+json["'][^>]*>([\s\S]*?)<\/script>/gi
|
|
3054
3111
|
);
|
|
@@ -3062,8 +3119,8 @@ function Rr(e, t) {
|
|
|
3062
3119
|
}
|
|
3063
3120
|
return [...n, ...r];
|
|
3064
3121
|
}
|
|
3065
|
-
const
|
|
3066
|
-
function
|
|
3122
|
+
const Zt = /(?:^|[/_-])(?:thumbnails?|thumbs?|small|mini)(?:[/_.-]|$)/i;
|
|
3123
|
+
function en(e) {
|
|
3067
3124
|
try {
|
|
3068
3125
|
const { pathname: t } = new URL(e);
|
|
3069
3126
|
return decodeURIComponent(t.slice(t.lastIndexOf("/") + 1)).toLowerCase() || null;
|
|
@@ -3071,68 +3128,68 @@ function Zt(e) {
|
|
|
3071
3128
|
return null;
|
|
3072
3129
|
}
|
|
3073
3130
|
}
|
|
3074
|
-
function
|
|
3131
|
+
function Mr(e, t) {
|
|
3075
3132
|
const n = /* @__PURE__ */ new Map();
|
|
3076
3133
|
for (const r of e.matchAll(/<a\b[^>]*>/gi)) {
|
|
3077
3134
|
const o = ue(F(r[0], "href"), t);
|
|
3078
|
-
if (!o || !
|
|
3135
|
+
if (!o || !Xt.test(o) || Zt.test(o) || Qt.test(o))
|
|
3079
3136
|
continue;
|
|
3080
|
-
const a =
|
|
3137
|
+
const a = en(o);
|
|
3081
3138
|
a && !n.has(a) && n.set(a, o);
|
|
3082
3139
|
}
|
|
3083
3140
|
return n;
|
|
3084
3141
|
}
|
|
3085
|
-
function
|
|
3086
|
-
const n = [...
|
|
3142
|
+
function Dr(e, t) {
|
|
3143
|
+
const n = [...qr(e, t)], r = [
|
|
3087
3144
|
/<meta\b[^>]*\b(?:property|name)\s*=\s*["'](?:og:image:secure_url|og:image:url|og:image)["'][^>]*>/gi,
|
|
3088
3145
|
/<meta\b[^>]*\b(?:property|name)\s*=\s*["'](?:twitter:image:src|twitter:image)["'][^>]*>/gi,
|
|
3089
3146
|
/<meta\b[^>]*\bitemprop\s*=\s*["']image["'][^>]*>/gi,
|
|
3090
3147
|
/<link\b[^>]*\brel\s*=\s*["']image_src["'][^>]*>/gi
|
|
3091
3148
|
];
|
|
3092
3149
|
for (const c of r)
|
|
3093
|
-
for (const
|
|
3094
|
-
const h =
|
|
3150
|
+
for (const m of e.matchAll(c)) {
|
|
3151
|
+
const h = m[0], p = ue(
|
|
3095
3152
|
F(h, "content") || F(h, "href"),
|
|
3096
3153
|
t
|
|
3097
3154
|
);
|
|
3098
|
-
|
|
3155
|
+
p && n.push(p);
|
|
3099
3156
|
}
|
|
3100
3157
|
const o = [];
|
|
3101
3158
|
for (const c of e.matchAll(/<img\b[^>]*>/gi)) {
|
|
3102
|
-
const
|
|
3103
|
-
h ?
|
|
3104
|
-
F(
|
|
3105
|
-
F(
|
|
3106
|
-
F(
|
|
3107
|
-
F(
|
|
3108
|
-
F(
|
|
3159
|
+
const m = c[0], h = F(m, "srcset") || F(m, "data-srcset"), p = [
|
|
3160
|
+
h ? Rr(h) : null,
|
|
3161
|
+
F(m, "src"),
|
|
3162
|
+
F(m, "data-src"),
|
|
3163
|
+
F(m, "data-original"),
|
|
3164
|
+
F(m, "data-lazy-src"),
|
|
3165
|
+
F(m, "data-image")
|
|
3109
3166
|
];
|
|
3110
3167
|
let g = null;
|
|
3111
|
-
for (const k of
|
|
3168
|
+
for (const k of p)
|
|
3112
3169
|
if (g = ue(k, t), g)
|
|
3113
3170
|
break;
|
|
3114
|
-
if (!g ||
|
|
3171
|
+
if (!g || Qt.test(g))
|
|
3115
3172
|
continue;
|
|
3116
|
-
const f = Number(F(
|
|
3173
|
+
const f = Number(F(m, "width"));
|
|
3117
3174
|
Number.isFinite(f) && f > 0 && f < 200 || o.push(g);
|
|
3118
3175
|
}
|
|
3119
|
-
const a = (c) =>
|
|
3176
|
+
const a = (c) => Xt.test(c);
|
|
3120
3177
|
n.push(...o.filter(a), ...o.filter((c) => !a(c)));
|
|
3121
|
-
const s =
|
|
3122
|
-
if (!
|
|
3178
|
+
const s = Mr(e, t), l = (c) => {
|
|
3179
|
+
if (!Zt.test(c))
|
|
3123
3180
|
return c;
|
|
3124
|
-
const
|
|
3125
|
-
return
|
|
3181
|
+
const m = en(c);
|
|
3182
|
+
return m && s.get(m) || c;
|
|
3126
3183
|
}, u = /* @__PURE__ */ new Set(), d = [];
|
|
3127
3184
|
for (const c of n) {
|
|
3128
|
-
const
|
|
3129
|
-
if (!u.has(
|
|
3185
|
+
const m = l(c);
|
|
3186
|
+
if (!u.has(m) && (u.add(m), d.push(m), d.length >= 12))
|
|
3130
3187
|
break;
|
|
3131
3188
|
}
|
|
3132
3189
|
return { images: d, mainImage: d[0] ?? null };
|
|
3133
3190
|
}
|
|
3134
|
-
function
|
|
3135
|
-
const r = e.replace(/<script\b[\s\S]*?<\/script>/gi, " ").replace(/<style\b[\s\S]*?<\/style>/gi, " ").replace(/<noscript\b[\s\S]*?<\/noscript>/gi, " ").replace(/<svg\b[\s\S]*?<\/svg>/gi, " "), { images: o, mainImage: a } =
|
|
3191
|
+
function zr(e, t, n) {
|
|
3192
|
+
const r = e.replace(/<script\b[\s\S]*?<\/script>/gi, " ").replace(/<style\b[\s\S]*?<\/style>/gi, " ").replace(/<noscript\b[\s\S]*?<\/noscript>/gi, " ").replace(/<svg\b[\s\S]*?<\/svg>/gi, " "), { images: o, mainImage: a } = Dr(e, n), s = e.match(/<title\b[^>]*>([\s\S]*?)<\/title>/i), l = e.match(/<meta[^>]+name=["']description["'][^>]*content=["']([^"']*)["'][^>]*>/i) || e.match(/<meta[^>]+content=["']([^"']*)["'][^>]*name=["']description["'][^>]*>/i), u = [...r.matchAll(/<h([1-3])\b[^>]*>([\s\S]*?)<\/h\1>/gi)].map((m) => re(m[2])).filter(Boolean).slice(0, 40), d = r.match(/<body\b[^>]*>([\s\S]*?)<\/body>/i), c = re(d?.[1] ?? r);
|
|
3136
3193
|
return {
|
|
3137
3194
|
description: l ? re(l[1]) : "",
|
|
3138
3195
|
headings: u,
|
|
@@ -3143,8 +3200,8 @@ function Dr(e, t, n) {
|
|
|
3143
3200
|
truncated: c.length > t
|
|
3144
3201
|
};
|
|
3145
3202
|
}
|
|
3146
|
-
async function
|
|
3147
|
-
const t =
|
|
3203
|
+
async function Gr(e) {
|
|
3204
|
+
const t = Yt.parse(e);
|
|
3148
3205
|
let n;
|
|
3149
3206
|
try {
|
|
3150
3207
|
n = new URL(t.url);
|
|
@@ -3153,13 +3210,13 @@ async function zr(e) {
|
|
|
3153
3210
|
}
|
|
3154
3211
|
if (n.protocol !== "http:" && n.protocol !== "https:")
|
|
3155
3212
|
return { message: "Only http and https URLs can be fetched.", success: !1, url: t.url };
|
|
3156
|
-
if (
|
|
3213
|
+
if (ut(n.hostname))
|
|
3157
3214
|
return {
|
|
3158
3215
|
message: "Refusing to fetch a local, private, or internal address.",
|
|
3159
3216
|
success: !1,
|
|
3160
3217
|
url: t.url
|
|
3161
3218
|
};
|
|
3162
|
-
const r = new AbortController(), o = setTimeout(() => r.abort(),
|
|
3219
|
+
const r = new AbortController(), o = setTimeout(() => r.abort(), Lr);
|
|
3163
3220
|
try {
|
|
3164
3221
|
const a = await fetch(n.toString(), {
|
|
3165
3222
|
headers: {
|
|
@@ -3178,7 +3235,7 @@ async function zr(e) {
|
|
|
3178
3235
|
};
|
|
3179
3236
|
const s = a.url || n.toString();
|
|
3180
3237
|
try {
|
|
3181
|
-
if (
|
|
3238
|
+
if (ut(new URL(s).hostname))
|
|
3182
3239
|
return {
|
|
3183
3240
|
message: "The URL redirected to a blocked internal address.",
|
|
3184
3241
|
success: !1,
|
|
@@ -3194,7 +3251,7 @@ async function zr(e) {
|
|
|
3194
3251
|
success: !1,
|
|
3195
3252
|
url: t.url
|
|
3196
3253
|
};
|
|
3197
|
-
const u = await a.text(), d = u.length >
|
|
3254
|
+
const u = await a.text(), d = u.length > ct ? u.slice(0, ct) : u, c = zr(d, t.maxChars, s);
|
|
3198
3255
|
return !c.text && !c.title ? { message: "The URL returned no readable text content.", success: !1, url: t.url } : {
|
|
3199
3256
|
description: c.description,
|
|
3200
3257
|
finalUrl: s,
|
|
@@ -3221,12 +3278,12 @@ async function zr(e) {
|
|
|
3221
3278
|
clearTimeout(o);
|
|
3222
3279
|
}
|
|
3223
3280
|
}
|
|
3224
|
-
const
|
|
3281
|
+
const tn = i.strictObject({
|
|
3225
3282
|
count: i.number().int().min(1).max(15).default(6),
|
|
3226
3283
|
orientation: i.enum(["landscape", "portrait", "square"]).optional().describe("Preferred image orientation. Use landscape for hero/section backgrounds."),
|
|
3227
3284
|
query: i.string().trim().min(2).max(200).describe('What the photos should depict, e.g. "herbal supplements".')
|
|
3228
|
-
}),
|
|
3229
|
-
async function
|
|
3285
|
+
}), Kr = 12e3;
|
|
3286
|
+
async function Ye(e) {
|
|
3230
3287
|
let t = null, n = null;
|
|
3231
3288
|
if (e)
|
|
3232
3289
|
try {
|
|
@@ -3234,8 +3291,8 @@ async function We(e) {
|
|
|
3234
3291
|
if (!c)
|
|
3235
3292
|
return null;
|
|
3236
3293
|
try {
|
|
3237
|
-
const
|
|
3238
|
-
return typeof
|
|
3294
|
+
const m = s(c);
|
|
3295
|
+
return typeof m == "string" && m.trim() ? m.trim() : null;
|
|
3239
3296
|
} catch {
|
|
3240
3297
|
return null;
|
|
3241
3298
|
}
|
|
@@ -3247,10 +3304,10 @@ async function We(e) {
|
|
|
3247
3304
|
const r = [];
|
|
3248
3305
|
return t && r.push({ apiKey: t, provider: "pexels" }), n && r.push({ apiKey: n, provider: "unsplash" }), r;
|
|
3249
3306
|
}
|
|
3250
|
-
async function
|
|
3251
|
-
return (await
|
|
3307
|
+
async function lo(e) {
|
|
3308
|
+
return (await Ye(e))[0] ?? null;
|
|
3252
3309
|
}
|
|
3253
|
-
async function
|
|
3310
|
+
async function Hr(e) {
|
|
3254
3311
|
if (e)
|
|
3255
3312
|
try {
|
|
3256
3313
|
const { CORTEX_AI_UNSPLASH_APP_NAME_SETTING_KEY: t } = await import("./ai-config.es.js"), { data: n } = await e.from("site_settings").select("value").eq("key", t).maybeSingle(), r = n?.value;
|
|
@@ -3260,8 +3317,8 @@ async function Kr(e) {
|
|
|
3260
3317
|
}
|
|
3261
3318
|
return process.env.UNSPLASH_APP_NAME?.trim() || null;
|
|
3262
3319
|
}
|
|
3263
|
-
async function
|
|
3264
|
-
const n = new AbortController(), r = setTimeout(() => n.abort(),
|
|
3320
|
+
async function dt(e, t) {
|
|
3321
|
+
const n = new AbortController(), r = setTimeout(() => n.abort(), Kr);
|
|
3265
3322
|
try {
|
|
3266
3323
|
const o = await fetch(e, { headers: t, signal: n.signal });
|
|
3267
3324
|
if (!o.ok)
|
|
@@ -3275,30 +3332,30 @@ function oe(e) {
|
|
|
3275
3332
|
const t = Number(e);
|
|
3276
3333
|
return Number.isFinite(t) && t > 0 ? t : null;
|
|
3277
3334
|
}
|
|
3278
|
-
function
|
|
3279
|
-
if (
|
|
3335
|
+
function Ue(e, t) {
|
|
3336
|
+
if (!$(e))
|
|
3280
3337
|
return;
|
|
3281
3338
|
const n = (r) => {
|
|
3282
|
-
|
|
3339
|
+
$(r) && r.provider === "unsplash" && typeof r.downloadLocation == "string" && r.downloadLocation.trim() && t.add(r.downloadLocation.trim());
|
|
3283
3340
|
};
|
|
3284
|
-
if (n(e.attribution),
|
|
3341
|
+
if (n(e.attribution), $(e.background) && $(e.background.image) && n(e.background.image.attribution), Array.isArray(e.column_blocks)) {
|
|
3285
3342
|
for (const r of e.column_blocks)
|
|
3286
3343
|
if (Array.isArray(r))
|
|
3287
3344
|
for (const o of r)
|
|
3288
|
-
|
|
3345
|
+
$(o) && Ue(o.content, t);
|
|
3289
3346
|
}
|
|
3290
3347
|
if (Array.isArray(e.slides))
|
|
3291
3348
|
for (const r of e.slides)
|
|
3292
|
-
|
|
3349
|
+
Ue(r, t);
|
|
3293
3350
|
}
|
|
3294
3351
|
async function ve(e, t) {
|
|
3295
3352
|
try {
|
|
3296
3353
|
const n = /* @__PURE__ */ new Set();
|
|
3297
3354
|
for (const a of e)
|
|
3298
|
-
|
|
3355
|
+
Ue(a?.content, n);
|
|
3299
3356
|
if (n.size === 0)
|
|
3300
3357
|
return;
|
|
3301
|
-
const o = (await
|
|
3358
|
+
const o = (await Ye(t)).find((a) => a.provider === "unsplash");
|
|
3302
3359
|
if (!o)
|
|
3303
3360
|
return;
|
|
3304
3361
|
await Promise.all(
|
|
@@ -3312,13 +3369,13 @@ async function ve(e, t) {
|
|
|
3312
3369
|
} catch {
|
|
3313
3370
|
}
|
|
3314
3371
|
}
|
|
3315
|
-
async function
|
|
3372
|
+
async function Vr(e, t, n) {
|
|
3316
3373
|
const r = new URLSearchParams({
|
|
3317
3374
|
per_page: String(t.count),
|
|
3318
3375
|
query: t.query
|
|
3319
3376
|
});
|
|
3320
3377
|
if (t.orientation && r.set("orientation", t.orientation), e.provider === "pexels") {
|
|
3321
|
-
const a = await
|
|
3378
|
+
const a = await dt(
|
|
3322
3379
|
`https://api.pexels.com/v1/search?${r.toString()}`,
|
|
3323
3380
|
{ Authorization: e.apiKey }
|
|
3324
3381
|
);
|
|
@@ -3339,7 +3396,7 @@ async function Hr(e, t, n) {
|
|
|
3339
3396
|
};
|
|
3340
3397
|
}).filter((s) => typeof s.url == "string");
|
|
3341
3398
|
}
|
|
3342
|
-
const o = await
|
|
3399
|
+
const o = await dt(
|
|
3343
3400
|
`https://api.unsplash.com/search/photos?${r.toString()}`,
|
|
3344
3401
|
{ Authorization: `Client-ID ${e.apiKey}` }
|
|
3345
3402
|
);
|
|
@@ -3364,20 +3421,20 @@ async function Hr(e, t, n) {
|
|
|
3364
3421
|
};
|
|
3365
3422
|
}).filter((a) => typeof a.url == "string");
|
|
3366
3423
|
}
|
|
3367
|
-
async function
|
|
3368
|
-
const n =
|
|
3424
|
+
async function Jr(e, t) {
|
|
3425
|
+
const n = tn.parse(e), r = await Ye(t?.supabase);
|
|
3369
3426
|
if (r.length === 0)
|
|
3370
3427
|
return {
|
|
3371
3428
|
message: "No stock photo provider is configured. Add a free Pexels or Unsplash API key in /cms/settings/cortex-ai (or set PEXELS_API_KEY / UNSPLASH_ACCESS_KEY).",
|
|
3372
3429
|
photos: [],
|
|
3373
3430
|
success: !1
|
|
3374
3431
|
};
|
|
3375
|
-
const o = r.some((l) => l.provider === "unsplash") ? await
|
|
3432
|
+
const o = r.some((l) => l.provider === "unsplash") ? await Hr(t?.supabase) : null, a = [];
|
|
3376
3433
|
let s = null;
|
|
3377
3434
|
for (const l of r) {
|
|
3378
3435
|
a.push(l.provider);
|
|
3379
3436
|
try {
|
|
3380
|
-
const u = await
|
|
3437
|
+
const u = await Vr(l, n, o);
|
|
3381
3438
|
if (u.length > 0)
|
|
3382
3439
|
return {
|
|
3383
3440
|
attemptedProviders: a,
|
|
@@ -3398,7 +3455,7 @@ async function Vr(e, t) {
|
|
|
3398
3455
|
success: !1
|
|
3399
3456
|
};
|
|
3400
3457
|
}
|
|
3401
|
-
const
|
|
3458
|
+
const nn = H.extend({
|
|
3402
3459
|
blocks: i.array(Q).min(1).max(20),
|
|
3403
3460
|
meta: i.strictObject({
|
|
3404
3461
|
meta_description: i.string().max(500).nullable().optional(),
|
|
@@ -3407,7 +3464,7 @@ const tn = K.extend({
|
|
|
3407
3464
|
status: i.enum(["draft", "published", "archived"]).optional(),
|
|
3408
3465
|
title: i.string().trim().min(1).max(300).optional()
|
|
3409
3466
|
}).partial().optional()
|
|
3410
|
-
}),
|
|
3467
|
+
}), Wr = [
|
|
3411
3468
|
"custom_canonical",
|
|
3412
3469
|
"excerpt",
|
|
3413
3470
|
"feature_image_id",
|
|
@@ -3422,20 +3479,20 @@ const tn = K.extend({
|
|
|
3422
3479
|
"title",
|
|
3423
3480
|
"translation_group_id"
|
|
3424
3481
|
];
|
|
3425
|
-
function
|
|
3482
|
+
function Yr(e) {
|
|
3426
3483
|
const t = {};
|
|
3427
|
-
for (const n of
|
|
3484
|
+
for (const n of Wr)
|
|
3428
3485
|
n in e && e[n] !== void 0 && (t[n] = e[n]);
|
|
3429
3486
|
return t;
|
|
3430
3487
|
}
|
|
3431
|
-
function
|
|
3488
|
+
function Xr(e, t) {
|
|
3432
3489
|
if (!t)
|
|
3433
3490
|
return null;
|
|
3434
3491
|
const n = e === "page" ? t === "home" ? "/" : `/${t}` : `/article/${t}`;
|
|
3435
3492
|
return `/api/draft/start?path=${encodeURIComponent(n)}`;
|
|
3436
3493
|
}
|
|
3437
|
-
async function
|
|
3438
|
-
const n =
|
|
3494
|
+
async function Qr(e, t) {
|
|
3495
|
+
const n = nn.parse(e), r = C(t), o = Re(t), a = await te(n, t);
|
|
3439
3496
|
if (a.contentType === "product")
|
|
3440
3497
|
throw new Error(
|
|
3441
3498
|
"rewrite_page_draft supports pages and posts only. Products use description_json, not page blocks."
|
|
@@ -3446,26 +3503,26 @@ async function Xr(e, t) {
|
|
|
3446
3503
|
const u = Number(a.item.language_id);
|
|
3447
3504
|
if (!Number.isInteger(u) || u <= 0)
|
|
3448
3505
|
throw new Error("The target page/post is missing a language id.");
|
|
3449
|
-
const c =
|
|
3450
|
-
block_type:
|
|
3451
|
-
content:
|
|
3506
|
+
const c = Se(n.blocks, void 0, void 0, t).map((x, E) => ({
|
|
3507
|
+
block_type: x.block_type,
|
|
3508
|
+
content: x.content,
|
|
3452
3509
|
language_id: u,
|
|
3453
3510
|
order: E,
|
|
3454
3511
|
page_id: s === "page" ? l : null,
|
|
3455
3512
|
post_id: s === "post" ? l : null,
|
|
3456
3513
|
product_id: null
|
|
3457
|
-
})),
|
|
3514
|
+
})), m = Yr(a.item);
|
|
3458
3515
|
if (n.meta)
|
|
3459
|
-
for (const [
|
|
3460
|
-
E !== void 0 && (
|
|
3461
|
-
const h =
|
|
3462
|
-
typeof
|
|
3463
|
-
),
|
|
3516
|
+
for (const [x, E] of Object.entries(n.meta))
|
|
3517
|
+
E !== void 0 && (m[x] = E);
|
|
3518
|
+
const h = Tt(
|
|
3519
|
+
typeof m.slug == "string" ? m.slug : a.item.slug
|
|
3520
|
+
), p = typeof m.title == "string" && m.title.trim() ? m.title : String(a.item.title || h || "Untitled"), g = s === "page" ? `/cms/pages/${l}/edit` : `/cms/posts/${l}/edit`, f = Xr(s, h), y = P({
|
|
3464
3521
|
action: "REWRITE DRAFT",
|
|
3465
3522
|
context: t,
|
|
3466
3523
|
payload: {
|
|
3467
3524
|
blocks: c,
|
|
3468
|
-
meta:
|
|
3525
|
+
meta: m,
|
|
3469
3526
|
parent_id: l,
|
|
3470
3527
|
parent_type: s,
|
|
3471
3528
|
tool: "rewrite_page_draft"
|
|
@@ -3474,11 +3531,11 @@ async function Xr(e, t) {
|
|
|
3474
3531
|
blockCount: c.length,
|
|
3475
3532
|
contentType: s,
|
|
3476
3533
|
slug: h,
|
|
3477
|
-
summary: `Stage a Live Draft that replaces the ${s} "${
|
|
3534
|
+
summary: `Stage a Live Draft that replaces the ${s} "${p}" with ${N(
|
|
3478
3535
|
c.length,
|
|
3479
3536
|
"new block"
|
|
3480
3537
|
)}. Nothing goes live until you review the draft and click Publish (which also saves a revision snapshot).`,
|
|
3481
|
-
title:
|
|
3538
|
+
title: p
|
|
3482
3539
|
},
|
|
3483
3540
|
subject: `${s}-${l}`
|
|
3484
3541
|
});
|
|
@@ -3487,16 +3544,16 @@ async function Xr(e, t) {
|
|
|
3487
3544
|
const w = Number(a.item.version) || 1, { error: b } = await r.from("content_drafts").delete().eq("parent_type", s).eq("parent_id", l);
|
|
3488
3545
|
if (b)
|
|
3489
3546
|
throw new Error(`Failed to clear the existing draft: ${_(b)}`);
|
|
3490
|
-
const { error:
|
|
3547
|
+
const { error: I } = await r.from("content_drafts").insert({
|
|
3491
3548
|
author_id: o,
|
|
3492
3549
|
base_version: w,
|
|
3493
3550
|
blocks: c,
|
|
3494
|
-
meta:
|
|
3551
|
+
meta: m,
|
|
3495
3552
|
parent_id: l,
|
|
3496
3553
|
parent_type: s
|
|
3497
3554
|
});
|
|
3498
|
-
if (
|
|
3499
|
-
throw new Error(`Failed to save the draft: ${_(
|
|
3555
|
+
if (I)
|
|
3556
|
+
throw new Error(`Failed to save the draft: ${_(I)}`);
|
|
3500
3557
|
return ve(c, r), U(
|
|
3501
3558
|
t,
|
|
3502
3559
|
{ contentType: s, entityId: l, slug: h },
|
|
@@ -3511,10 +3568,10 @@ async function Xr(e, t) {
|
|
|
3511
3568
|
mutationExecuted: !0,
|
|
3512
3569
|
slug: h,
|
|
3513
3570
|
success: !0,
|
|
3514
|
-
title:
|
|
3571
|
+
title: p
|
|
3515
3572
|
};
|
|
3516
3573
|
}
|
|
3517
|
-
const
|
|
3574
|
+
const Zr = /* @__PURE__ */ new Set([
|
|
3518
3575
|
"alt_text",
|
|
3519
3576
|
"author_name",
|
|
3520
3577
|
"author_title",
|
|
@@ -3529,7 +3586,7 @@ const Qr = /* @__PURE__ */ new Set([
|
|
|
3529
3586
|
"text_content",
|
|
3530
3587
|
"title"
|
|
3531
3588
|
]);
|
|
3532
|
-
function
|
|
3589
|
+
function Oe(e, t, n) {
|
|
3533
3590
|
if (!e)
|
|
3534
3591
|
return e;
|
|
3535
3592
|
if (Object.prototype.hasOwnProperty.call(t, e))
|
|
@@ -3542,50 +3599,50 @@ function Ue(e, t, n) {
|
|
|
3542
3599
|
a && o.includes(a) && (o = o.split(a).join(s));
|
|
3543
3600
|
return o;
|
|
3544
3601
|
}
|
|
3545
|
-
function
|
|
3602
|
+
function Fe(e, t, n) {
|
|
3546
3603
|
if (Array.isArray(e))
|
|
3547
|
-
return e.map((r) =>
|
|
3604
|
+
return e.map((r) => Fe(r, t, n));
|
|
3548
3605
|
if (e && typeof e == "object") {
|
|
3549
3606
|
const r = {};
|
|
3550
3607
|
for (const [o, a] of Object.entries(e))
|
|
3551
|
-
typeof a == "string" &&
|
|
3608
|
+
typeof a == "string" && Zr.has(o) ? r[o] = Oe(a, t, n) : a && typeof a == "object" ? r[o] = Fe(a, t, n) : r[o] = a;
|
|
3552
3609
|
return r;
|
|
3553
3610
|
}
|
|
3554
3611
|
return e;
|
|
3555
3612
|
}
|
|
3556
|
-
const
|
|
3613
|
+
const rn = i.strictObject({
|
|
3557
3614
|
targetLanguageCode: i.string().trim().min(2).max(80).describe('Target language code or name, e.g. "fr" or "French".'),
|
|
3558
3615
|
title: i.string().trim().min(1).max(300).optional().describe("Translated page title (defaults to translating the source title)."),
|
|
3559
3616
|
translations: i.record(i.string(), i.string()).describe(
|
|
3560
3617
|
'Map of every visible source string to its translation, e.g. { "Explore Our Products": "Explorez nos produits" }. Include headings, paragraph text, button labels, image alt text, captions, and form labels.'
|
|
3561
3618
|
)
|
|
3562
3619
|
});
|
|
3563
|
-
async function
|
|
3564
|
-
const n =
|
|
3620
|
+
async function eo(e, t) {
|
|
3621
|
+
const n = rn.parse(e), r = V(t);
|
|
3565
3622
|
if (r.contentType === "product")
|
|
3566
3623
|
throw new Error("translate_page supports pages and posts only.");
|
|
3567
|
-
const o =
|
|
3624
|
+
const o = C(t), a = Be(r), s = r.contentType === "page" ? "pages" : "posts", l = r.contentType === "page" ? "page_id" : "post_id", { data: u, error: d } = await o.from(s).select("*").eq("id", a).single();
|
|
3568
3625
|
if (d || !u)
|
|
3569
3626
|
throw new Error(
|
|
3570
3627
|
`Could not read the source ${r.contentType} to translate: ${_(d)}`
|
|
3571
3628
|
);
|
|
3572
|
-
const { data: c, error:
|
|
3573
|
-
if (
|
|
3574
|
-
throw new Error(`Could not read the source blocks: ${_(
|
|
3575
|
-
const h = (Array.isArray(c) ? c : []).slice().sort((
|
|
3629
|
+
const { data: c, error: m } = await o.from("blocks").select("id, block_type, content, order").eq(l, a);
|
|
3630
|
+
if (m)
|
|
3631
|
+
throw new Error(`Could not read the source blocks: ${_(m)}`);
|
|
3632
|
+
const h = (Array.isArray(c) ? c : []).slice().sort((T, A) => Number(T.order) - Number(A.order));
|
|
3576
3633
|
if (h.length === 0)
|
|
3577
3634
|
throw new Error(`The source ${r.contentType} has no content blocks to translate.`);
|
|
3578
|
-
const
|
|
3579
|
-
blockType:
|
|
3580
|
-
content:
|
|
3581
|
-
order:
|
|
3582
|
-
})), k = await
|
|
3635
|
+
const p = n.translations || {}, g = Object.entries(p).filter(([T]) => !!T).sort((T, A) => A[0].length - T[0].length), f = h.map((T, A) => ({
|
|
3636
|
+
blockType: T.block_type,
|
|
3637
|
+
content: Fe(z(T.content), p, g),
|
|
3638
|
+
order: A
|
|
3639
|
+
})), k = await Ce(o, n.targetLanguageCode), y = String(u.title || ""), w = n.title || Oe(y, p, g) || y || "Untitled", b = (T) => typeof T == "string" && T.trim() ? Oe(T, p, g) : void 0, I = R(w) || u.slug || "translated-page", x = {
|
|
3583
3640
|
blocks: f,
|
|
3584
3641
|
feature_image_id: u.feature_image_id ?? void 0,
|
|
3585
3642
|
languageCode: k.code,
|
|
3586
3643
|
meta_description: b(u.meta_description),
|
|
3587
3644
|
meta_title: b(u.meta_title),
|
|
3588
|
-
slug:
|
|
3645
|
+
slug: I,
|
|
3589
3646
|
// Publish the translation immediately so it goes live the moment the owner
|
|
3590
3647
|
// confirms — the localized homepage/page is then reachable and the public
|
|
3591
3648
|
// language switcher can find it (drafts are filtered out of public lookups).
|
|
@@ -3593,7 +3650,7 @@ async function Zr(e, t) {
|
|
|
3593
3650
|
title: w,
|
|
3594
3651
|
translationGroupId: u.translation_group_id || void 0
|
|
3595
3652
|
}, E = r.contentType === "post" ? {
|
|
3596
|
-
...
|
|
3653
|
+
...x,
|
|
3597
3654
|
excerpt: b(u.excerpt),
|
|
3598
3655
|
label: b(u.label),
|
|
3599
3656
|
// Inherit the source post's publish date (or "now" if it has none) so a
|
|
@@ -3601,7 +3658,7 @@ async function Zr(e, t) {
|
|
|
3601
3658
|
// instead of jumping to the top with a null published_at.
|
|
3602
3659
|
published_at: u.published_at ?? (/* @__PURE__ */ new Date()).toISOString(),
|
|
3603
3660
|
subtitle: b(u.subtitle)
|
|
3604
|
-
} :
|
|
3661
|
+
} : x, L = P({
|
|
3605
3662
|
action: "TRANSLATE",
|
|
3606
3663
|
context: t,
|
|
3607
3664
|
payload: { createInput: E, sourceId: u.id, tool: "translate_page" },
|
|
@@ -3609,9 +3666,9 @@ async function Zr(e, t) {
|
|
|
3609
3666
|
blockCount: f.length,
|
|
3610
3667
|
contentType: r.contentType,
|
|
3611
3668
|
languageCode: k.code,
|
|
3612
|
-
slug:
|
|
3613
|
-
status:
|
|
3614
|
-
summary: `Publish a ${k.code.toUpperCase()} translation of "${y}" — it goes live immediately, linked to the original ${r.contentType}, at /${
|
|
3669
|
+
slug: x.slug,
|
|
3670
|
+
status: x.status,
|
|
3671
|
+
summary: `Publish a ${k.code.toUpperCase()} translation of "${y}" — it goes live immediately, linked to the original ${r.contentType}, at /${x.slug} with ${N(
|
|
3615
3672
|
f.length,
|
|
3616
3673
|
"translated block"
|
|
3617
3674
|
)}.`,
|
|
@@ -3622,10 +3679,10 @@ async function Zr(e, t) {
|
|
|
3622
3679
|
if (L)
|
|
3623
3680
|
return L;
|
|
3624
3681
|
const q = { ...t, skipConfirmation: !0 };
|
|
3625
|
-
return { ...r.contentType === "post" ? await
|
|
3682
|
+
return { ...r.contentType === "post" ? await Je(E, q) : await Ve(E, q), isTranslation: !0, languageCode: k.code };
|
|
3626
3683
|
}
|
|
3627
|
-
async function
|
|
3628
|
-
const n = he.parse(e), r = n.entityId !== void 0 || !!n.slug || !!n.title, o =
|
|
3684
|
+
async function on(e, t) {
|
|
3685
|
+
const n = he.parse(e), r = n.entityId !== void 0 || !!n.slug || !!n.title, o = C(t);
|
|
3629
3686
|
let a, s;
|
|
3630
3687
|
if (r) {
|
|
3631
3688
|
const g = await te(
|
|
@@ -3644,7 +3701,7 @@ async function rn(e, t) {
|
|
|
3644
3701
|
title: typeof f.title == "string" ? f.title : ""
|
|
3645
3702
|
};
|
|
3646
3703
|
} else
|
|
3647
|
-
a =
|
|
3704
|
+
a = V(t), s = Te(a);
|
|
3648
3705
|
const l = a.title || a.slug || "current item", u = a.contentType === "product", d = P({
|
|
3649
3706
|
action: "SET IMAGES",
|
|
3650
3707
|
context: t,
|
|
@@ -3668,7 +3725,7 @@ async function rn(e, t) {
|
|
|
3668
3725
|
});
|
|
3669
3726
|
if (d)
|
|
3670
3727
|
return d;
|
|
3671
|
-
const c = await
|
|
3728
|
+
const c = await It(n.images, t, l);
|
|
3672
3729
|
if (c.length === 0)
|
|
3673
3730
|
throw new Error("None of the provided images could be resolved to a media item.");
|
|
3674
3731
|
if (u) {
|
|
@@ -3677,12 +3734,24 @@ async function rn(e, t) {
|
|
|
3677
3734
|
throw new Error(
|
|
3678
3735
|
`Could not load the product to set images: ${_(f)}`
|
|
3679
3736
|
);
|
|
3680
|
-
const k = await
|
|
3737
|
+
const k = await Pn({
|
|
3681
3738
|
mediaIds: c,
|
|
3682
3739
|
productId: s,
|
|
3683
3740
|
supabase: o
|
|
3684
3741
|
});
|
|
3685
|
-
return
|
|
3742
|
+
return await xe({
|
|
3743
|
+
patch: ({ meta: y }) => Array.isArray(y.product_media) ? {
|
|
3744
|
+
meta: {
|
|
3745
|
+
...y,
|
|
3746
|
+
product_media: k.map((w, b) => ({
|
|
3747
|
+
media_id: w,
|
|
3748
|
+
sort_order: b
|
|
3749
|
+
}))
|
|
3750
|
+
}
|
|
3751
|
+
} : {},
|
|
3752
|
+
productId: s,
|
|
3753
|
+
supabase: o
|
|
3754
|
+
}), U(
|
|
3686
3755
|
t,
|
|
3687
3756
|
{
|
|
3688
3757
|
contentType: "product",
|
|
@@ -3701,12 +3770,12 @@ async function rn(e, t) {
|
|
|
3701
3770
|
success: !0
|
|
3702
3771
|
};
|
|
3703
3772
|
}
|
|
3704
|
-
const
|
|
3773
|
+
const m = a.contentType === "page" ? "pages" : "posts", { data: h, error: p } = await o.from(m).update({
|
|
3705
3774
|
feature_image_id: c[0],
|
|
3706
3775
|
updated_at: (/* @__PURE__ */ new Date()).toISOString()
|
|
3707
3776
|
}).eq("id", s).select("id, language_id, slug, status, title").single();
|
|
3708
|
-
if (
|
|
3709
|
-
throw new Error(`Failed to set the feature image: ${_(
|
|
3777
|
+
if (p || !h)
|
|
3778
|
+
throw new Error(`Failed to set the feature image: ${_(p)}`);
|
|
3710
3779
|
return U(t, a, h.slug), {
|
|
3711
3780
|
contentType: a.contentType,
|
|
3712
3781
|
entityId: s,
|
|
@@ -3717,184 +3786,184 @@ async function rn(e, t) {
|
|
|
3717
3786
|
success: !0
|
|
3718
3787
|
};
|
|
3719
3788
|
}
|
|
3720
|
-
function
|
|
3789
|
+
function co(e) {
|
|
3721
3790
|
return {
|
|
3722
|
-
...on(e),
|
|
3723
3791
|
...an(e),
|
|
3724
|
-
|
|
3792
|
+
...sn(e),
|
|
3793
|
+
fetch_ecommerce_stats: S({
|
|
3725
3794
|
description: "Fetch quantitative ecommerce statistics and reports from the database. Use this to answer questions about revenue, order counts, order status counts such as pending or trial, and top-selling products over a time range. This tool is read-only and does not require confirmation.",
|
|
3726
|
-
execute: (t) =>
|
|
3727
|
-
inputSchema:
|
|
3795
|
+
execute: (t) => wr(t, e),
|
|
3796
|
+
inputSchema: ft,
|
|
3728
3797
|
strict: !0
|
|
3729
3798
|
}),
|
|
3730
|
-
read_current_cms_item:
|
|
3799
|
+
read_current_cms_item: S({
|
|
3731
3800
|
description: "Read the CMS item currently being edited. Requires pageContext and returns page/post/product metadata plus page/post block summaries or content.",
|
|
3732
|
-
execute: (t) =>
|
|
3733
|
-
inputSchema:
|
|
3801
|
+
execute: (t) => Ir(t, e),
|
|
3802
|
+
inputSchema: yt,
|
|
3734
3803
|
strict: !0
|
|
3735
3804
|
}),
|
|
3736
|
-
search_documentation:
|
|
3805
|
+
search_documentation: S({
|
|
3737
3806
|
description: "Search the NextBlock documentation database and return concise source snippets for factual CMS guidance.",
|
|
3738
|
-
execute: (t) =>
|
|
3739
|
-
inputSchema:
|
|
3807
|
+
execute: (t) => hr(t, e),
|
|
3808
|
+
inputSchema: je,
|
|
3740
3809
|
strict: !0
|
|
3741
3810
|
}),
|
|
3742
|
-
fetch_url_content:
|
|
3811
|
+
fetch_url_content: S({
|
|
3743
3812
|
description: "Fetch an external web page and return its title, meta description, headings, body text, AND its images: `mainImage` (the page's subject image — schema.org Product image, else og:image, else the best in-body <img>) plus a ranked `images` list, all as absolute URLs. Read-only, no confirmation. Use this first whenever the user references an external URL to copy, adapt, clone, or draw inspiration from. To reuse the source page's image, pass `mainImage` straight into create_cms_product `images` or a page/post `feature_image_id` — it is imported into the media library automatically. Never invent an image URL: if `mainImage` is null, the page had none.",
|
|
3744
|
-
execute: (t) =>
|
|
3745
|
-
inputSchema:
|
|
3813
|
+
execute: (t) => Gr(t),
|
|
3814
|
+
inputSchema: Yt,
|
|
3746
3815
|
strict: !0
|
|
3747
3816
|
}),
|
|
3748
|
-
search_stock_photos:
|
|
3817
|
+
search_stock_photos: S({
|
|
3749
3818
|
description: "Find relevant, free, high-quality stock photos (Unsplash/Pexels) for page imagery. Returns a list of photos each with a direct image `url`, `width`, `height`, `alt`, and `photographer`. Read-only, zero cost. Use the returned `url` directly as an image block's external_url or a section image background's image.external_url when building or revamping pages, so layouts show real photos instantly. Set orientation \"landscape\" for hero/section backgrounds.",
|
|
3750
|
-
execute: (t) =>
|
|
3751
|
-
inputSchema:
|
|
3819
|
+
execute: (t) => Jr(t, e),
|
|
3820
|
+
inputSchema: tn,
|
|
3752
3821
|
strict: !0
|
|
3753
3822
|
}),
|
|
3754
|
-
rewrite_page_draft:
|
|
3823
|
+
rewrite_page_draft: S({
|
|
3755
3824
|
description: 'Replace ALL blocks of an existing page or post with a brand-new set of blocks, staged as a Live Draft (content_drafts) that the user previews before publishing. Use this for whole-page redesigns/rewrites such as "rewrite my home page with 5 sections". Provide the complete new list of top-level blocks in `blocks` (usually section blocks for a landing/home page, each with nested heading/text/button blocks). Nothing goes live until the user publishes the draft, and publishing auto-creates a revision snapshot so the change is reversible. Mutating: first returns a confirmation phrase; only stages the draft after the user replies with the exact phrase.',
|
|
3756
|
-
execute: (t) =>
|
|
3757
|
-
inputSchema:
|
|
3825
|
+
execute: (t) => Qr(t, e),
|
|
3826
|
+
inputSchema: nn,
|
|
3758
3827
|
strict: !0
|
|
3759
3828
|
}),
|
|
3760
|
-
translate_page:
|
|
3829
|
+
translate_page: S({
|
|
3761
3830
|
description: 'Translate the CURRENT page or post into another language. This copies the source page\'s entire structure, layout, and images automatically and links the new page to the original as a translation — you ONLY supply the text translations. Provide targetLanguageCode (e.g. "fr") and a `translations` map of every visible source string to its translation (headings, paragraph text, button labels, image alt text, captions, form labels). Do NOT rebuild the layout or call search_stock_photos for a translation. Requires an open page/post. Mutating: first returns a confirmation phrase; only creates the translation after exact confirmation.',
|
|
3762
|
-
execute: (t) =>
|
|
3763
|
-
inputSchema:
|
|
3831
|
+
execute: (t) => eo(t, e),
|
|
3832
|
+
inputSchema: rn,
|
|
3764
3833
|
strict: !0
|
|
3765
3834
|
}),
|
|
3766
|
-
set_content_images:
|
|
3835
|
+
set_content_images: S({
|
|
3767
3836
|
description: "Set the feature image for a page or post, or the image gallery for a product. Pass `images`: a list of image URLs (e.g. `mainImage` from fetch_url_content or `url` values from search_stock_photos) and/or existing media library IDs. External URLs are imported into the media library automatically — NEVER put an image URL directly into feature_image_id. The FIRST image becomes the feature image (pages/posts) or the main product image (products); for a product the remaining images become its gallery in order (this REPLACES the product's current images). Targets the currently open page/post/product by default; to target any other item (for example a product you just created from the dashboard) pass contentType plus slug, entityId, or title — no open editor needed. Mutating: first returns a confirmation phrase; only applies after exact confirmation.",
|
|
3768
|
-
execute: (t) =>
|
|
3837
|
+
execute: (t) => on(t, e),
|
|
3769
3838
|
inputSchema: he,
|
|
3770
3839
|
strict: !0
|
|
3771
3840
|
}),
|
|
3772
|
-
create_cms_page:
|
|
3841
|
+
create_cms_page: S({
|
|
3773
3842
|
description: "Create a new CMS page with metadata and optional validated page blocks. Mutating: first returns a confirmation phrase; only executes after the user replies with the exact phrase. For translations, pass translationGroupId from the source page/post/product context so the new language is linked to the same backend translation group. For contact pages, provide contactEmail or a form block with recipient_email and fields.",
|
|
3774
|
-
execute: (t) =>
|
|
3843
|
+
execute: (t) => Ve(t, e),
|
|
3775
3844
|
inputSchema: _e,
|
|
3776
3845
|
strict: !0
|
|
3777
3846
|
}),
|
|
3778
|
-
create_cms_post:
|
|
3847
|
+
create_cms_post: S({
|
|
3779
3848
|
description: "Create a new CMS post with metadata and optional validated post blocks. Mutating: first returns a confirmation phrase; only executes after the user replies with the exact phrase. For translations, pass translationGroupId from the source post context so the new language is linked to the same backend translation group.",
|
|
3780
|
-
execute: (t) =>
|
|
3849
|
+
execute: (t) => Je(t, e),
|
|
3781
3850
|
inputSchema: be,
|
|
3782
3851
|
strict: !0
|
|
3783
3852
|
}),
|
|
3784
|
-
create_cms_product:
|
|
3853
|
+
create_cms_product: S({
|
|
3785
3854
|
description: "Create a new draft-capable product, complete with its images and its body copy in ONE call. Pass `images` to set the main product image and gallery (external https URLs are imported into the media library automatically — use `mainImage` from fetch_url_content to reuse a source page's photo). Pass `blocks` to build the product's \"Product Description Blocks\" — the SAME block vocabulary and section-based design rules as create_cms_page, rendered on the public product page. This is the richest product body and is what you should produce whenever the user asks to copy or write real product content. Also pass `short_description` for the one-line summary shown on product cards. `description_html` is a plain-HTML fallback body used only when no blocks are supplied. Defaults missing fields safely: physical Stripe product, generated SKU, price 0, stock 0, taxable, draft. `price` is in major units (25 = $25.00). For translations, pass translationGroupId from the source product context. Mutating: first returns a confirmation phrase; only executes after exact confirmation.",
|
|
3786
|
-
execute: (t) =>
|
|
3855
|
+
execute: (t) => Kt(t, e),
|
|
3787
3856
|
inputSchema: ke,
|
|
3788
3857
|
strict: !0
|
|
3789
3858
|
}),
|
|
3790
|
-
delete_cms_item:
|
|
3859
|
+
delete_cms_item: S({
|
|
3791
3860
|
description: "Delete a resolved page, post, or product after exact confirmation. Pages/posts delete all translations in the translation group and related navigation links. Mutating: refuses unless the latest user message includes the exact confirmation phrase.",
|
|
3792
|
-
execute: (t) =>
|
|
3861
|
+
execute: (t) => Wt(t, e),
|
|
3793
3862
|
inputSchema: Ie,
|
|
3794
3863
|
strict: !0
|
|
3795
3864
|
}),
|
|
3796
|
-
prepare_delete_cms_item:
|
|
3865
|
+
prepare_delete_cms_item: S({
|
|
3797
3866
|
description: "Inspect the page, post, or product that would be deleted and return the exact confirmation phrase. This tool does not mutate data.",
|
|
3798
|
-
execute: (t) =>
|
|
3799
|
-
inputSchema:
|
|
3867
|
+
execute: (t) => Ur(t, e),
|
|
3868
|
+
inputSchema: _t,
|
|
3800
3869
|
strict: !0
|
|
3801
3870
|
}),
|
|
3802
|
-
update_footer:
|
|
3871
|
+
update_footer: S({
|
|
3803
3872
|
description: "Replace the public footer links and/or footer copyright settings for a locale. Use links for footer navigation and copyright for locale text templates. Mutating: first returns a confirmation phrase; only executes after exact confirmation.",
|
|
3804
|
-
execute: (t) =>
|
|
3873
|
+
execute: (t) => Ft(t, e),
|
|
3805
3874
|
inputSchema: pe,
|
|
3806
3875
|
strict: !0
|
|
3807
3876
|
}),
|
|
3808
|
-
update_content_block:
|
|
3877
|
+
update_content_block: S({
|
|
3809
3878
|
description: 'Update the JSON content of an existing top-level page/post block that belongs to the current CMS edit context. Content is merged with the existing block before validation. For section blocks, add nested blocks with content.append_block or content.append_blocks using objects like { block_type: "button", content: { text: "Contact Us", url: "/contact" } }; existing column_blocks and layout fields are preserved. Mutating: first returns a confirmation phrase; only executes after exact confirmation.',
|
|
3810
|
-
execute: (t) =>
|
|
3879
|
+
execute: (t) => Mt(t, e),
|
|
3811
3880
|
inputSchema: ge,
|
|
3812
3881
|
strict: !0
|
|
3813
3882
|
}),
|
|
3814
|
-
insert_content_block:
|
|
3883
|
+
insert_content_block: S({
|
|
3815
3884
|
description: 'Insert a new validated top-level page/post block before or after an existing block, or at the start/end. Use this for visible content additions like adding a rich text title and paragraph above a form. For "above the form", use position "before" with anchorBlockType "form" and blockType "text" containing html_content. Mutating: first returns a confirmation phrase; only executes after exact confirmation.',
|
|
3816
|
-
execute: (t) =>
|
|
3885
|
+
execute: (t) => Dt(t, e),
|
|
3817
3886
|
inputSchema: ye,
|
|
3818
3887
|
strict: !0
|
|
3819
3888
|
}),
|
|
3820
|
-
update_current_cms_fields:
|
|
3889
|
+
update_current_cms_fields: S({
|
|
3821
3890
|
description: "Update validated metadata fields on the current page, post, or product. For products, description_json must be a valid NextBlock editor document JSON object. Mutating: first returns a confirmation phrase; only executes after exact confirmation.",
|
|
3822
|
-
execute: (t) =>
|
|
3891
|
+
execute: (t) => qt(t, e),
|
|
3823
3892
|
inputSchema: me,
|
|
3824
3893
|
strict: !0
|
|
3825
3894
|
}),
|
|
3826
|
-
update_cms_item_field:
|
|
3895
|
+
update_cms_item_field: S({
|
|
3827
3896
|
description: "Update one field on a page, post, or product, resolving by current edit context, id, slug, or exact title. Use this for requests like changing price, stock, title, slug, status, sale_price, or meta fields. Interpret public as published for pages/posts and active for products. Scheduled sale date ranges are not supported and will be refused without mutation. Mutating: first returns a confirmation phrase; only executes after exact confirmation.",
|
|
3828
|
-
execute: (t) =>
|
|
3897
|
+
execute: (t) => Ht(t, e),
|
|
3829
3898
|
inputSchema: we,
|
|
3830
3899
|
strict: !0
|
|
3831
3900
|
}),
|
|
3832
|
-
update_navigation_bar:
|
|
3901
|
+
update_navigation_bar: S({
|
|
3833
3902
|
description: 'Update the public header navigation bar for a locale. Use mode "append" when adding links while preserving existing navigation. Use mode "update" when renaming or changing an existing single link. Use mode "replace" only when the user asks to rebuild the complete header and you provide the full menu; destructive partial replacements are refused. Mutating: first returns a confirmation phrase; only executes after exact confirmation.',
|
|
3834
|
-
execute: (t) =>
|
|
3903
|
+
execute: (t) => Ot(t, e),
|
|
3835
3904
|
inputSchema: de,
|
|
3836
3905
|
strict: !0
|
|
3837
3906
|
}),
|
|
3838
|
-
update_section_column_block:
|
|
3907
|
+
update_section_column_block: S({
|
|
3839
3908
|
description: "Update the content of one existing nested block inside a section block that belongs to the current CMS edit context. This tool must not change the nested block type. To add a new nested block, update the parent section with update_content_block and preserve existing column_blocks. Mutating: first returns a confirmation phrase; only executes after exact confirmation.",
|
|
3840
|
-
execute: (t) =>
|
|
3909
|
+
execute: (t) => zt(t, e),
|
|
3841
3910
|
inputSchema: fe,
|
|
3842
3911
|
strict: !0
|
|
3843
3912
|
}),
|
|
3844
|
-
execute_cms_action_plan:
|
|
3913
|
+
execute_cms_action_plan: S({
|
|
3845
3914
|
description: "Execute multiple CMS mutations as one confirmed plan. Use this whenever the user asks for more than one change in the same prompt, such as creating a page and adding a navigation link. First returns one combined confirmation preview and Confirm button; after confirmation, runs each action in order and stops on the first failure.",
|
|
3846
|
-
execute: (t) =>
|
|
3847
|
-
inputSchema:
|
|
3915
|
+
execute: (t) => jr(t, e),
|
|
3916
|
+
inputSchema: kt,
|
|
3848
3917
|
strict: !0
|
|
3849
3918
|
})
|
|
3850
3919
|
};
|
|
3851
3920
|
}
|
|
3852
3921
|
export {
|
|
3853
|
-
|
|
3854
|
-
|
|
3855
|
-
|
|
3922
|
+
K as availableCortexAiBlockTypes,
|
|
3923
|
+
so as buildVisibleContactIntroActionPlan,
|
|
3924
|
+
ht as cortexAiPageContextSchema,
|
|
3856
3925
|
_e as createCmsPageInputSchema,
|
|
3857
3926
|
be as createCmsPostInputSchema,
|
|
3858
3927
|
ke as createCmsProductInputSchema,
|
|
3859
|
-
|
|
3928
|
+
co as createCortexGlobalAgentTools,
|
|
3860
3929
|
Ie as deleteCmsItemInputSchema,
|
|
3861
|
-
|
|
3862
|
-
|
|
3863
|
-
|
|
3864
|
-
|
|
3865
|
-
|
|
3866
|
-
|
|
3867
|
-
|
|
3868
|
-
|
|
3869
|
-
|
|
3870
|
-
|
|
3871
|
-
|
|
3872
|
-
|
|
3873
|
-
|
|
3874
|
-
|
|
3875
|
-
|
|
3876
|
-
|
|
3877
|
-
|
|
3878
|
-
|
|
3879
|
-
|
|
3880
|
-
|
|
3881
|
-
|
|
3882
|
-
|
|
3883
|
-
|
|
3884
|
-
|
|
3885
|
-
|
|
3930
|
+
jr as executeCmsActionPlan,
|
|
3931
|
+
kt as executeCmsActionPlanInputSchema,
|
|
3932
|
+
Ve as executeCreateCmsPage,
|
|
3933
|
+
Je as executeCreateCmsPost,
|
|
3934
|
+
Kt as executeCreateCmsProduct,
|
|
3935
|
+
Wt as executeDeleteCmsItem,
|
|
3936
|
+
wr as executeFetchEcommerceStats,
|
|
3937
|
+
Gr as executeFetchUrlContent,
|
|
3938
|
+
Dt as executeInsertContentBlock,
|
|
3939
|
+
Ur as executePrepareDeleteCmsItem,
|
|
3940
|
+
Ir as executeReadCurrentCmsItem,
|
|
3941
|
+
Qr as executeRewritePageDraft,
|
|
3942
|
+
fr as executeSearchDocumentation,
|
|
3943
|
+
hr as executeSearchDocumentationWithTimeout,
|
|
3944
|
+
Jr as executeSearchStockPhotos,
|
|
3945
|
+
on as executeSetContentImages,
|
|
3946
|
+
eo as executeTranslatePage,
|
|
3947
|
+
Ht as executeUpdateCmsItemField,
|
|
3948
|
+
Mt as executeUpdateContentBlock,
|
|
3949
|
+
qt as executeUpdateCurrentCmsFields,
|
|
3950
|
+
Ft as executeUpdateFooter,
|
|
3951
|
+
Ot as executeUpdateNavigationBar,
|
|
3952
|
+
zt as executeUpdateSectionColumnBlock,
|
|
3953
|
+
ft as fetchEcommerceStatsInputSchema,
|
|
3954
|
+
Yt as fetchUrlContentInputSchema,
|
|
3886
3955
|
ye as insertContentBlockInputSchema,
|
|
3887
3956
|
ve as maybeTriggerStockPhotoDownloads,
|
|
3888
|
-
|
|
3889
|
-
|
|
3890
|
-
|
|
3891
|
-
|
|
3892
|
-
|
|
3893
|
-
|
|
3894
|
-
|
|
3895
|
-
|
|
3957
|
+
gt as navigationItemInputSchema,
|
|
3958
|
+
_t as prepareDeleteCmsItemInputSchema,
|
|
3959
|
+
yt as readCurrentCmsItemInputSchema,
|
|
3960
|
+
lo as resolveCortexAiStockPhotoProvider,
|
|
3961
|
+
Ye as resolveCortexAiStockPhotoProviders,
|
|
3962
|
+
nn as rewritePageDraftInputSchema,
|
|
3963
|
+
je as searchDocumentationInputSchema,
|
|
3964
|
+
tn as searchStockPhotosInputSchema,
|
|
3896
3965
|
he as setContentImagesInputSchema,
|
|
3897
|
-
|
|
3966
|
+
rn as translatePageInputSchema,
|
|
3898
3967
|
we as updateCmsItemFieldInputSchema,
|
|
3899
3968
|
ge as updateContentBlockInputSchema,
|
|
3900
3969
|
me as updateCurrentCmsFieldsInputSchema,
|