@chaibuilder/sdk 4.0.0-beta.2 → 4.0.0-beta.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{2SSKDMRQ-C4VFVd-q.cjs → 2SSKDMRQ-CopJgtZb.cjs} +1 -1
- package/dist/{2SSKDMRQ-DSnzF_1o.js → 2SSKDMRQ-Difo_1pg.js} +2 -2
- package/dist/{AP7HFJJL-Cxwj01Aq.js → AP7HFJJL-BPuPBqj4.js} +1 -1
- package/dist/{AP7HFJJL-B7YYCY9q.cjs → AP7HFJJL-DYxDgaOs.cjs} +1 -1
- package/dist/{IconPicker-RqVvq6G2.js → IconPicker-B2-oriq2.js} +8 -7
- package/dist/IconPicker-C0oycHbs.cjs +1 -0
- package/dist/{WDYDFRGG-b3T2SQbz.cjs → WDYDFRGG-DbejaRPK.cjs} +1 -1
- package/dist/{WDYDFRGG-C7aSUcjs.js → WDYDFRGG-KK8pkcW1.js} +2 -2
- package/dist/{actions-registery-YnFmU21O.cjs → actions-registery-JdxhXhT6.cjs} +1 -1
- package/dist/{actions-registery-CZ1w0NKa.js → actions-registery-y_ENc8zj.js} +2 -2
- package/dist/actions.cjs +1 -1
- package/dist/actions.js +2 -2
- package/dist/active-in-another-tab-Cu_ASKtx.cjs +1 -0
- package/dist/active-in-another-tab-DkR2HWI4.js +35 -0
- package/dist/add-new-language-page-BXuwluuU.cjs +1 -0
- package/dist/{add-new-language-page-D7NDABl1.js → add-new-language-page-CBY0RR6q.js} +54 -53
- package/dist/{add-new-page-BNfwKjRd.cjs → add-new-page-C_PzKby8.cjs} +1 -1
- package/dist/{add-new-page-B4hc0B-g.js → add-new-page-DJLJFLAd.js} +2 -2
- package/dist/{ai-panel-content-BnbURb7j.js → ai-panel-content--YM01Aly.js} +12 -11
- package/dist/ai-panel-content-rRmJdH7L.cjs +1 -0
- package/dist/{ai-panel-default-lang-oVk4TDeb.js → ai-panel-default-lang-BZl0tPYo.js} +40 -40
- package/dist/{ai-panel-default-lang-3tCHzab5.cjs → ai-panel-default-lang-D2zhXvKP.cjs} +2 -2
- package/dist/{ai-panel-other-lang-DmQ3QMDD.js → ai-panel-other-lang-Bfjk2CYZ.js} +8 -8
- package/dist/{ai-panel-other-lang-BBHCCSen.cjs → ai-panel-other-lang-Y4bEKHoG.cjs} +1 -1
- package/dist/{ai-prompt-input-DaTyfib-.js → ai-prompt-input-DueQYNf-.js} +68 -67
- package/dist/ai-prompt-input-N9PcYCFa.cjs +1 -0
- package/dist/{ai-translation-prompt-DJPe2O-n.js → ai-translation-prompt-B36F3d7K.js} +2 -2
- package/dist/ai-translation-prompt-IAdWMNZb.cjs +1 -0
- package/dist/{apply-binding-6iwlED02.js → apply-binding-BvWfJCSZ.js} +204 -196
- package/dist/apply-binding-IsUf6UWJ.cjs +1 -0
- package/dist/{code-display-BzBq5xSn.js → code-display-Ck81Id9K.js} +1 -1
- package/dist/code-display-DloSPyPr.cjs +1 -0
- package/dist/{code-editor-DWWnphW9.js → code-editor-Bb7JumZy.js} +11 -10
- package/dist/code-editor-DQB8lAOk.cjs +1 -0
- package/dist/{continue-editing-in-this-client-BllU94XG.js → continue-editing-in-this-client-Dm9cCj7K.js} +10 -9
- package/dist/continue-editing-in-this-client-DmGFLHXw.cjs +1 -0
- package/dist/core-Dr7QYemB.js +56 -0
- package/dist/core-Y0lXLwkq.cjs +1 -0
- package/dist/core.cjs +1 -1
- package/dist/core.d.ts +3 -3
- package/dist/core.js +41 -39
- package/dist/{css-import-modal-D72a-16X.js → css-import-modal-9P_0uNa4.js} +4 -3
- package/dist/css-import-modal-Rh1QAVxo.cjs +13 -0
- package/dist/{delete-design-token-D_TLlO3I.cjs → delete-design-token-BG8yHcS5.cjs} +1 -1
- package/dist/{delete-design-token-Cd1ZDtqT.js → delete-design-token-COvR4G1S.js} +1 -1
- package/dist/{delete-page-DC8pzvWW.js → delete-page-CNucxe4P.js} +11 -10
- package/dist/delete-page-DAvEjHwF.cjs +1 -0
- package/dist/design-token-usage-CXglXgcJ.cjs +1 -0
- package/dist/{design-token-usage-DE4XCDdn.js → design-token-usage-MNYsFlPG.js} +14 -13
- package/dist/digital-asset-manager-CB5MRBcW.cjs +1 -0
- package/dist/{digital-asset-manager-C_gL_0YY.js → digital-asset-manager-CqCWBO0s.js} +6 -5
- package/dist/{duplicate-page-BoVhko2q.js → duplicate-page-BknLfqr0.js} +19 -18
- package/dist/duplicate-page-DzZByALW.cjs +1 -0
- package/dist/{dynamic-page-selector-CSndg2-y.js → dynamic-page-selector-DoW7OyUB.js} +15 -14
- package/dist/dynamic-page-selector-WA007Sni.cjs +1 -0
- package/dist/get-chai-builder-tailwind-config-BFePCEIS.cjs +1 -0
- package/dist/{get-chai-builder-tailwind-config-DjoVOuAf.js → get-chai-builder-tailwind-config-BXf_xLHk.js} +5 -5
- package/dist/{get-chai-builder-theme-Dl72X7cz.cjs → get-chai-builder-theme-BApShjRz.cjs} +1 -1
- package/dist/{get-chai-builder-theme-BYtp20KD.js → get-chai-builder-theme-DDVRJQ6Z.js} +1 -1
- package/dist/{image-editor-oypq8asR.js → image-editor-CQnNtak2.js} +1 -1
- package/dist/{image-editor-DTspjj_c.cjs → image-editor-CqwaVxO2.cjs} +1 -1
- package/dist/index-C0-pgg_p.cjs +5 -0
- package/dist/index-C99FhuF1.cjs +160 -0
- package/dist/{index-BDnwJqMw.js → index-Dno42B0a.js} +716 -714
- package/dist/{index-S8ibZk9Q.js → index-rAcNbjk_.js} +3744 -3920
- package/dist/{json-diff-viewer-XX1pgabt.cjs → json-diff-viewer-CLuUHiPU.cjs} +3 -3
- package/dist/{json-diff-viewer-B5dr-Y_L.js → json-diff-viewer-CMvGUvJ2.js} +5 -4
- package/dist/{lang-panel-Cn83SRzd.js → lang-panel-CnwTb05j.js} +15 -14
- package/dist/lang-panel-fDCYm5Jm.cjs +1 -0
- package/dist/{manage-design-tokens-lP4HLS0P.js → manage-design-tokens-BsSZE9Vs.js} +12 -11
- package/dist/manage-design-tokens-BvH5KTJX.cjs +1 -0
- package/dist/mark-as-template-CpWEBJGd.cjs +1 -0
- package/dist/{mark-as-template-jncsjfHm.js → mark-as-template-DBLshWb5.js} +17 -16
- package/dist/{nested-path-selector-content-B-8LqhXI.js → nested-path-selector-content-6OBJ8LG8.js} +24 -23
- package/dist/nested-path-selector-content-C2sD9dkq.cjs +1 -0
- package/dist/no-language-page-content-BvPDdccK.cjs +1 -0
- package/dist/{no-language-page-content-D_zd9Rb0.js → no-language-page-content-CzENgtnu.js} +10 -9
- package/dist/{no-language-page-dialog-C5Ps6YYL.js → no-language-page-dialog-CbYI2cVg.js} +2 -2
- package/dist/{no-language-page-dialog-fXmbQO7L.cjs → no-language-page-dialog-CgW4yJBC.cjs} +1 -1
- package/dist/{page-creator-wCMtlE6Z.js → page-creator-Cc83uQqw.js} +113 -112
- package/dist/page-creator-g8GqgcKH.cjs +1 -0
- package/dist/{page-lock-BPCxfv9J.js → page-lock-BJUkyxdh.js} +2 -2
- package/dist/{page-lock-DweiYy1w.cjs → page-lock-CT7SmQqp.cjs} +1 -1
- package/dist/page-locked-dialog-Co5b9XIZ.cjs +1 -0
- package/dist/{page-locked-dialog-ByGl18_m.js → page-locked-dialog-DsEbWRed.js} +18 -15
- package/dist/{page-manager-new-BWFE-S-O.js → page-manager-new-5rFP5DyQ.js} +30 -29
- package/dist/page-manager-new-BOkJImo2.cjs +1 -0
- package/dist/page-manager-search-and-filter-Bfm0j1gg.cjs +1 -0
- package/dist/{page-manager-search-and-filter-kNJFWJ86.js → page-manager-search-and-filter-zq-LfhQ1.js} +13 -12
- package/dist/{page-revisions-content-Ulr8slUN.js → page-revisions-content-D38G2tJM.js} +34 -31
- package/dist/page-revisions-content-ag-MHBGr.cjs +1 -0
- package/dist/pages.cjs +1 -1
- package/dist/pages.d.ts +22 -23
- package/dist/pages.js +12 -12
- package/dist/{plugin-C6rgJDNQ.cjs → plugin-BGlQf0iy.cjs} +1 -1
- package/dist/{plugin-3ZKK6RXm.js → plugin-C-ht41UZ.js} +1 -1
- package/dist/publish-pages-content-BiX-GMLw.cjs +1 -0
- package/dist/{publish-pages-content-BTPzt_m4.js → publish-pages-content-CS7f41Ac.js} +66 -65
- package/dist/register-chai-top-bar-BqwKw4uy.cjs +1 -0
- package/dist/register-chai-top-bar-ESJHs5s-.js +237 -0
- package/dist/render.cjs +2 -2
- package/dist/render.d.ts +2 -2
- package/dist/render.js +87 -80
- package/dist/rte-widget-modal-BKNx2wln.cjs +1 -0
- package/dist/{rte-widget-modal-Rk_NW3KU.js → rte-widget-modal-D6Zik0Ta.js} +15 -14
- package/dist/runtime.cjs +1 -1
- package/dist/runtime.d.ts +168 -4
- package/dist/runtime.js +68 -38
- package/dist/{save-to-lib-BK3uTFss.js → save-to-lib-WwOzbgiF.js} +39 -38
- package/dist/save-to-lib-ffjCZYJ5.cjs +1 -0
- package/dist/sdk.css +1 -1
- package/dist/{selected-block-display-CU3TwIMA.js → selected-block-display-B1SG_UXw.js} +37 -36
- package/dist/selected-block-display-BOgnQRLF.cjs +16 -0
- package/dist/{seo-panel-jbzxFioc.js → seo-panel-BkOgRoWd.js} +12 -11
- package/dist/seo-panel-FjS1UF_y.cjs +2 -0
- package/dist/{shared-json-ld-BL_dv3_q.js → shared-json-ld-uka9TOgA.js} +68 -67
- package/dist/shared-json-ld-yJkXjENy.cjs +1 -0
- package/dist/slug-input-Cyd6NR6J.cjs +1 -0
- package/dist/{slug-input-1qwKkXhA.js → slug-input-DHLmUNrH.js} +9 -8
- package/dist/supabase-actions.cjs +1 -1
- package/dist/supabase-actions.d.ts +1 -1
- package/dist/supabase-actions.js +1 -1
- package/dist/{take-over-request-DKvKi3mM.js → take-over-request-Ca0X-qyf.js} +17 -16
- package/dist/take-over-request-CmpJVe9T.cjs +1 -0
- package/dist/{theme-panel-footer-DbMDLYGI.js → theme-panel-footer-BUXIu252.js} +11 -10
- package/dist/theme-panel-footer-CKO9YYwZ.cjs +1 -0
- package/dist/{translation-warning-modal-9wTwIy_9.js → translation-warning-modal-DrpFeI83.js} +9 -8
- package/dist/translation-warning-modal-pSZVKcNW.cjs +1 -0
- package/dist/{unmark-as-template-Dulvf7Zw.js → unmark-as-template-BMqgelv-.js} +11 -10
- package/dist/unmark-as-template-DF1Ms4VN.cjs +1 -0
- package/dist/unpublish-page-BJ0Bsvt2.js +28 -0
- package/dist/unpublish-page-Bsq2yEqQ.cjs +1 -0
- package/dist/utils.cjs +1 -1
- package/dist/utils.d.ts +4 -1
- package/dist/utils.js +2 -2
- package/dist/web-blocks.cjs +1 -1
- package/dist/web-blocks.js +5 -5
- package/dist/{web-preview-DXE4Jnf5.js → web-preview-D6h1L2nV.js} +2 -2
- package/dist/web-preview-kres0aG7.cjs +1 -0
- package/package.json +4 -2
- package/dist/IconPicker-C9-ieDWm.cjs +0 -1
- package/dist/active-in-another-tab-Clng6zpY.cjs +0 -1
- package/dist/active-in-another-tab-wb8qolB8.js +0 -34
- package/dist/add-new-language-page-C4BuMTaN.cjs +0 -1
- package/dist/ai-panel-content-DPy2jgKw.cjs +0 -1
- package/dist/ai-prompt-input-b5ty81RB.cjs +0 -1
- package/dist/ai-translation-prompt-c0Q3zkT2.cjs +0 -1
- package/dist/apply-binding-KKp5PnpZ.cjs +0 -1
- package/dist/code-display-Q3_sK_Ta.cjs +0 -1
- package/dist/code-editor-BQZi6-FB.cjs +0 -1
- package/dist/continue-editing-in-this-client-D9HyD4GP.cjs +0 -1
- package/dist/core-BoRDjj4h.cjs +0 -1
- package/dist/core-yvI6kCyw.js +0 -56
- package/dist/css-import-modal-BSMGKA2T.cjs +0 -13
- package/dist/delete-page-ByQwBupJ.cjs +0 -1
- package/dist/design-token-usage-BqZeR1sT.cjs +0 -1
- package/dist/digital-asset-manager-BYLKFEYi.cjs +0 -1
- package/dist/duplicate-page-vdvwLQLo.cjs +0 -1
- package/dist/dynamic-page-selector-DdnbCuQZ.cjs +0 -1
- package/dist/get-chai-builder-tailwind-config-B9rCyiQo.cjs +0 -1
- package/dist/index-CbwxUFy_.cjs +0 -5
- package/dist/index-CnSjWE1P.cjs +0 -160
- package/dist/lang-panel-BPxex-M2.cjs +0 -1
- package/dist/manage-design-tokens-ConiyuPr.cjs +0 -1
- package/dist/mark-as-template-DYRxre1f.cjs +0 -1
- package/dist/nested-path-selector-content-BYtLi7mC.cjs +0 -1
- package/dist/no-language-page-content-DAbLq0gX.cjs +0 -1
- package/dist/page-creator-VWIB2VAs.cjs +0 -1
- package/dist/page-locked-dialog-BlbgvaG2.cjs +0 -1
- package/dist/page-manager-new-D0lGfNnS.cjs +0 -1
- package/dist/page-manager-search-and-filter-DpGMoOII.cjs +0 -1
- package/dist/page-revisions-content-DYxXZqmh.cjs +0 -1
- package/dist/publish-pages-content-D6g8GAsd.cjs +0 -1
- package/dist/rte-widget-modal-DrMzWWjw.cjs +0 -1
- package/dist/save-to-lib-DHHUO12i.cjs +0 -1
- package/dist/selected-block-display-DSFhddPj.cjs +0 -16
- package/dist/seo-panel-Dl0IDV09.cjs +0 -2
- package/dist/shared-json-ld-DPNkqDC1.cjs +0 -1
- package/dist/slug-input-YVLjtTI3.cjs +0 -1
- package/dist/take-over-request-DvMIg_cZ.cjs +0 -1
- package/dist/theme-panel-footer-BMOaPLWc.cjs +0 -1
- package/dist/translation-warning-modal-DjTwz75c.cjs +0 -1
- package/dist/unmark-as-template-CdqIJJER.cjs +0 -1
- package/dist/unpublish-page-BwSVBf0_.cjs +0 -1
- package/dist/unpublish-page-Degu5Cy9.js +0 -27
- package/dist/web-preview-YzKxyXft.cjs +0 -1
|
@@ -1,16 +1,17 @@
|
|
|
1
1
|
import { jsx as e, jsxs as n, Fragment as G } from "react/jsx-runtime";
|
|
2
|
-
import { D as W, d as
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
2
|
+
import { D as W, d as $, e as Y, f as X, L as y, E as U, G as R, H as _, I as M, J as H, K as q, M as V, O as K, n as me, w as L, x as F, y as J, a2 as he, R as ue, U as ge, V as fe, F as pe, W as xe, T as Ne } from "./index-rAcNbjk_.js";
|
|
3
|
+
import { D as be, F as ye, z as j, B as v } from "./register-chai-top-bar-ESJHs5s-.js";
|
|
4
|
+
import { ar as ve, as as we, A as Q, aw as te, aC as Ce, aD as se, aE as re, aF as de, aG as Ae, aH as Se, aI as Pe, l as Te, aJ as De } from "./index-Dno42B0a.js";
|
|
5
|
+
import { useQuery as Ee, useQueryClient as Le } from "@tanstack/react-query";
|
|
6
|
+
import { filter as Fe, find as Je } from "lodash-es";
|
|
7
|
+
import { Info as Oe, Loader as O, Plus as ke, Eye as Ge, Edit as je, Trash as Be } from "lucide-react";
|
|
7
8
|
import { useState as g, useEffect as Z, useMemo as z } from "react";
|
|
8
9
|
import { toast as B } from "sonner";
|
|
9
10
|
const oe = () => {
|
|
10
11
|
const l = ve(), i = we();
|
|
11
|
-
return
|
|
12
|
-
queryKey: [
|
|
13
|
-
queryFn: async () => i(l, { action:
|
|
12
|
+
return Ee({
|
|
13
|
+
queryKey: [Q.GET_GLOBAL_JSONLD_ITEMS],
|
|
14
|
+
queryFn: async () => i(l, { action: Q.GET_GLOBAL_JSONLD_ITEMS })
|
|
14
15
|
});
|
|
15
16
|
}, Ie = ({
|
|
16
17
|
show: l,
|
|
@@ -26,7 +27,7 @@ const oe = () => {
|
|
|
26
27
|
content: "",
|
|
27
28
|
description: "",
|
|
28
29
|
enabledByDefaultForNewPages: !1
|
|
29
|
-
}), [x, S] = g(!1), { data: u } = te(), { mutateAsync:
|
|
30
|
+
}), [x, S] = g(!1), { data: u } = te(), { mutateAsync: A, isPending: p } = Ce(), { mutateAsync: c } = se(), w = Le();
|
|
30
31
|
Z(() => {
|
|
31
32
|
f(a ? {
|
|
32
33
|
name: a.name,
|
|
@@ -53,21 +54,21 @@ const oe = () => {
|
|
|
53
54
|
description: d.description
|
|
54
55
|
};
|
|
55
56
|
a != null && a.primaryPageId && (N.primaryPage = a.primaryPageId);
|
|
56
|
-
const
|
|
57
|
-
u != null && u.id && (
|
|
58
|
-
schemaId:
|
|
57
|
+
const C = await A(N);
|
|
58
|
+
u != null && u.id && (C != null && C.id) && !(a != null && a.primaryPageId) && (await c({
|
|
59
|
+
schemaId: C.id,
|
|
59
60
|
pageId: u.id,
|
|
60
61
|
enabled: !0
|
|
61
62
|
}), w.invalidateQueries({
|
|
62
|
-
queryKey: [
|
|
63
|
+
queryKey: [Q.GET_LANGUAGE_PAGES, u.id]
|
|
63
64
|
})), i();
|
|
64
65
|
};
|
|
65
|
-
return /* @__PURE__ */ n(
|
|
66
|
-
/* @__PURE__ */ e(
|
|
66
|
+
return /* @__PURE__ */ n($, { className: "flex max-w-xl flex-col overflow-y-auto", children: [
|
|
67
|
+
/* @__PURE__ */ e(Y, { children: /* @__PURE__ */ e(X, { children: "Add New Shared JSON-LD Schema" }) }),
|
|
67
68
|
/* @__PURE__ */ n("div", { className: "flex max-h-[75vh] flex-col space-y-2 overflow-y-auto", children: [
|
|
68
|
-
(a == null ? void 0 : a.languageCode) && /* @__PURE__ */ n(
|
|
69
|
-
/* @__PURE__ */ e(
|
|
70
|
-
/* @__PURE__ */ n(
|
|
69
|
+
(a == null ? void 0 : a.languageCode) && /* @__PURE__ */ n(be, { className: "border-blue-200 bg-blue-50", children: [
|
|
70
|
+
/* @__PURE__ */ e(Oe, { className: "h-4 w-4 text-blue-600" }),
|
|
71
|
+
/* @__PURE__ */ n(ye, { className: "text-sm text-blue-800", children: [
|
|
71
72
|
"You are creating a ",
|
|
72
73
|
/* @__PURE__ */ e("span", { className: "font-semibold", children: a.languageCode }),
|
|
73
74
|
" language version of this schema. This will be linked to the default language schema."
|
|
@@ -148,7 +149,7 @@ const oe = () => {
|
|
|
148
149
|
/* @__PURE__ */ e("div", { className: "border-t pt-3", children: /* @__PURE__ */ n("div", { className: "flex items-center justify-end gap-2", children: [
|
|
149
150
|
/* @__PURE__ */ e(v, { disabled: p, variant: "outline", type: "button", size: "sm", onClick: () => i(), children: "Cancel" }),
|
|
150
151
|
/* @__PURE__ */ e(v, { disabled: p, type: "button", size: "sm", onClick: o, children: p ? /* @__PURE__ */ n(G, { children: [
|
|
151
|
-
/* @__PURE__ */ e(
|
|
152
|
+
/* @__PURE__ */ e(O, { className: "h-4 w-4 animate-spin" }),
|
|
152
153
|
" Adding"
|
|
153
154
|
] }) : /* @__PURE__ */ n(G, { children: [
|
|
154
155
|
"Add Schema",
|
|
@@ -163,11 +164,11 @@ const oe = () => {
|
|
|
163
164
|
content: "",
|
|
164
165
|
description: "",
|
|
165
166
|
enabledByDefaultForNewPages: !1
|
|
166
|
-
}), [f, x] = g(!1), [S, u] = g(!1), [
|
|
167
|
+
}), [f, x] = g(!1), [S, u] = g(!1), [A, p] = g(!1), { data: c } = oe(), { mutateAsync: w, isPending: o } = Ae(), { mutateAsync: t } = Se(), { mutateAsync: N } = Pe();
|
|
167
168
|
Z(() => {
|
|
168
169
|
var m, T;
|
|
169
170
|
if (l && c) {
|
|
170
|
-
const b = c.find((
|
|
171
|
+
const b = c.find((E) => E.id === l);
|
|
171
172
|
b && (d({
|
|
172
173
|
name: b.name,
|
|
173
174
|
description: ((m = b.metadata) == null ? void 0 : m.description) || "",
|
|
@@ -176,7 +177,7 @@ const oe = () => {
|
|
|
176
177
|
}), p(!!b.primaryPage));
|
|
177
178
|
}
|
|
178
179
|
}, [l, c]);
|
|
179
|
-
const
|
|
180
|
+
const C = async () => {
|
|
180
181
|
if (!a.name || !a.content) {
|
|
181
182
|
B.error("Please enter a name and content");
|
|
182
183
|
return;
|
|
@@ -207,10 +208,10 @@ const oe = () => {
|
|
|
207
208
|
u(!1);
|
|
208
209
|
}
|
|
209
210
|
};
|
|
210
|
-
return /* @__PURE__ */ n(
|
|
211
|
-
/* @__PURE__ */ e(
|
|
211
|
+
return /* @__PURE__ */ n($, { className: "flex max-w-xl flex-col overflow-y-auto", children: [
|
|
212
|
+
/* @__PURE__ */ e(Y, { children: /* @__PURE__ */ e(X, { children: "Edit Shared JSON-LD Schema" }) }),
|
|
212
213
|
/* @__PURE__ */ n("div", { className: "flex max-h-[75vh] flex-col space-y-2 overflow-y-auto", children: [
|
|
213
|
-
!
|
|
214
|
+
!A && /* @__PURE__ */ n("div", { className: "flex items-center justify-between rounded-lg border border-blue-300 bg-blue-500/10 p-2", children: [
|
|
214
215
|
/* @__PURE__ */ n("div", { children: [
|
|
215
216
|
/* @__PURE__ */ e("div", { className: "text-sm font-medium text-blue-900", children: "Manage Existing Pages" }),
|
|
216
217
|
/* @__PURE__ */ e("div", { className: "text-xs text-blue-700", children: "Add or remove this schema from all existing pages on your site" })
|
|
@@ -258,7 +259,7 @@ const oe = () => {
|
|
|
258
259
|
}
|
|
259
260
|
)
|
|
260
261
|
] }),
|
|
261
|
-
!
|
|
262
|
+
!A && /* @__PURE__ */ n("div", { className: "flex items-center space-x-2", children: [
|
|
262
263
|
/* @__PURE__ */ e(
|
|
263
264
|
"input",
|
|
264
265
|
{
|
|
@@ -276,8 +277,8 @@ const oe = () => {
|
|
|
276
277
|
] }),
|
|
277
278
|
/* @__PURE__ */ e("div", { className: "border-t pt-3", children: /* @__PURE__ */ n("div", { className: "flex items-center justify-end gap-2", children: [
|
|
278
279
|
/* @__PURE__ */ e(v, { disabled: o, variant: "outline", type: "button", size: "sm", onClick: () => i(), children: "Cancel" }),
|
|
279
|
-
/* @__PURE__ */ e(v, { disabled: o, type: "button", size: "sm", onClick:
|
|
280
|
-
/* @__PURE__ */ e(
|
|
280
|
+
/* @__PURE__ */ e(v, { disabled: o, type: "button", size: "sm", onClick: C, children: o ? /* @__PURE__ */ n(G, { children: [
|
|
281
|
+
/* @__PURE__ */ e(O, { className: "h-4 w-4 animate-spin" }),
|
|
281
282
|
" Updating"
|
|
282
283
|
] }) : "Update Schema" })
|
|
283
284
|
] }) })
|
|
@@ -292,7 +293,7 @@ const oe = () => {
|
|
|
292
293
|
] })
|
|
293
294
|
] }),
|
|
294
295
|
/* @__PURE__ */ n(q, { children: [
|
|
295
|
-
/* @__PURE__ */ e(
|
|
296
|
+
/* @__PURE__ */ e(V, { children: "Cancel" }),
|
|
296
297
|
/* @__PURE__ */ e(K, { onClick: I, children: "Add to All" })
|
|
297
298
|
] })
|
|
298
299
|
] }) }),
|
|
@@ -306,15 +307,15 @@ const oe = () => {
|
|
|
306
307
|
] })
|
|
307
308
|
] }),
|
|
308
309
|
/* @__PURE__ */ n(q, { children: [
|
|
309
|
-
/* @__PURE__ */ e(
|
|
310
|
+
/* @__PURE__ */ e(V, { children: "Cancel" }),
|
|
310
311
|
/* @__PURE__ */ e(K, { onClick: P, className: "bg-red-500 hover:bg-red-600", children: "Remove from All" })
|
|
311
312
|
] })
|
|
312
313
|
] }) })
|
|
313
314
|
] });
|
|
314
315
|
};
|
|
315
|
-
function
|
|
316
|
-
const [l, i] = g(!1), [a, d] = g(void 0), [f, x] = g(null), [S, u] = g(null), [
|
|
317
|
-
const h = o ?
|
|
316
|
+
function Xe() {
|
|
317
|
+
const [l, i] = g(!1), [a, d] = g(void 0), [f, x] = g(null), [S, u] = g(null), [A, p] = g(null), { data: c, isLoading: w } = oe(), { selectedLang: o } = me(), { data: t } = te(), { data: N } = Te(), { mutateAsync: C } = De(), { mutateAsync: I } = se(), P = z(() => N == null ? void 0 : N.find((s) => !s.primaryPage && s.lang === ""), [N]), m = z(() => (P == null ? void 0 : P.globalJsonLds) || [], [P]), T = z(() => c ? Fe(c, (r) => r.primaryPage === null && r.lang === "").map((r) => {
|
|
318
|
+
const h = o ? Je(c, (D) => D.primaryPage === r.id && D.lang === o) : null;
|
|
318
319
|
return {
|
|
319
320
|
defaultSchema: r,
|
|
320
321
|
languageVersion: h,
|
|
@@ -322,15 +323,15 @@ function $e() {
|
|
|
322
323
|
displayItem: h || r,
|
|
323
324
|
hasLanguageVersion: !!h
|
|
324
325
|
};
|
|
325
|
-
}) : [], [c, o]), [b,
|
|
326
|
+
}) : [], [c, o]), [b, E] = g([]), k = b.length > 0 ? b : (t == null ? void 0 : t.globalJsonLds) || [];
|
|
326
327
|
Z(() => {
|
|
327
|
-
t != null && t.globalJsonLds &&
|
|
328
|
+
t != null && t.globalJsonLds && E(t.globalJsonLds);
|
|
328
329
|
}, [t == null ? void 0 : t.globalJsonLds]);
|
|
329
330
|
const ie = async (s) => {
|
|
330
331
|
if (!(t != null && t.id)) return;
|
|
331
332
|
p(s);
|
|
332
333
|
const r = k.includes(s), h = r ? k.filter((D) => D !== s) : [...k, s];
|
|
333
|
-
|
|
334
|
+
E(h);
|
|
334
335
|
try {
|
|
335
336
|
await I({
|
|
336
337
|
schemaId: s,
|
|
@@ -338,14 +339,14 @@ function $e() {
|
|
|
338
339
|
enabled: !r
|
|
339
340
|
});
|
|
340
341
|
} catch {
|
|
341
|
-
|
|
342
|
+
E(t.globalJsonLds);
|
|
342
343
|
} finally {
|
|
343
344
|
p(null);
|
|
344
345
|
}
|
|
345
346
|
}, ce = async (s) => {
|
|
346
347
|
p(s);
|
|
347
348
|
try {
|
|
348
|
-
await
|
|
349
|
+
await C(s);
|
|
349
350
|
} finally {
|
|
350
351
|
p(null);
|
|
351
352
|
}
|
|
@@ -356,9 +357,9 @@ function $e() {
|
|
|
356
357
|
/* @__PURE__ */ e("div", { className: "text-xs font-medium", children: "Shared JSON-LD Templates" }),
|
|
357
358
|
/* @__PURE__ */ e("div", { className: "w-full text-xs text-gray-500", children: "Manage reusable JSON-LD schemas that can be applied across multiple pages" })
|
|
358
359
|
] }),
|
|
359
|
-
!o && /* @__PURE__ */ n(
|
|
360
|
+
!o && /* @__PURE__ */ n(L, { delayDuration: 0, children: [
|
|
360
361
|
/* @__PURE__ */ e(
|
|
361
|
-
|
|
362
|
+
F,
|
|
362
363
|
{
|
|
363
364
|
type: "button",
|
|
364
365
|
disabled: w,
|
|
@@ -366,28 +367,28 @@ function $e() {
|
|
|
366
367
|
onClick: (s) => {
|
|
367
368
|
s.stopPropagation(), i(!0);
|
|
368
369
|
},
|
|
369
|
-
children: w ? /* @__PURE__ */ e(
|
|
370
|
+
children: w ? /* @__PURE__ */ e(O, { className: "h-4 w-4 animate-spin" }) : /* @__PURE__ */ e(ke, { className: "h-4 w-4" })
|
|
370
371
|
}
|
|
371
372
|
),
|
|
372
|
-
/* @__PURE__ */ e(
|
|
373
|
+
/* @__PURE__ */ e(J, { children: "Add new schema" })
|
|
373
374
|
] })
|
|
374
375
|
] }),
|
|
375
|
-
/* @__PURE__ */ n(
|
|
376
|
+
/* @__PURE__ */ n(he, { className: "max-h-96 overflow-y-auto", children: [
|
|
376
377
|
/* @__PURE__ */ n("div", { className: "space-y-2", children: [
|
|
377
378
|
(!c || (c == null ? void 0 : c.length) === 0) && !w && /* @__PURE__ */ e("div", { className: "flex items-center justify-center px-2 py-4 text-xs", children: "No shared JSON-LD found" }),
|
|
378
379
|
T.map(({ defaultSchema: s, displayItem: r, hasLanguageVersion: h }) => {
|
|
379
380
|
var ae, le;
|
|
380
381
|
const D = k.includes(r.id), ee = m.includes(s.id), ne = h && o ? ee : D;
|
|
381
382
|
return /* @__PURE__ */ n(
|
|
382
|
-
|
|
383
|
+
ue,
|
|
383
384
|
{
|
|
384
|
-
className: `relative border-gray-300 p-0 shadow-none transition-all ${
|
|
385
|
+
className: `relative border-gray-300 p-0 shadow-none transition-all ${A === r.id ? "pointer-events-none" : ""}`,
|
|
385
386
|
children: [
|
|
386
|
-
|
|
387
|
-
/* @__PURE__ */ e(
|
|
387
|
+
A === r.id && /* @__PURE__ */ e("div", { className: "absolute bottom-0 left-0 right-0 top-0 z-50 flex items-center justify-center rounded-xl bg-white/80", children: /* @__PURE__ */ e(O, { className: "h-5 w-5 animate-spin text-primary" }) }),
|
|
388
|
+
/* @__PURE__ */ e(ge, { className: "p-2", children: /* @__PURE__ */ n("div", { className: "flex items-center justify-between", children: [
|
|
388
389
|
/* @__PURE__ */ n("div", { className: "flex items-center gap-3", children: [
|
|
389
|
-
(h || !o) && /* @__PURE__ */ n(
|
|
390
|
-
/* @__PURE__ */ e(
|
|
390
|
+
(h || !o) && /* @__PURE__ */ n(L, { delayDuration: 0, children: [
|
|
391
|
+
/* @__PURE__ */ e(F, { asChild: !0, children: /* @__PURE__ */ e(
|
|
391
392
|
"input",
|
|
392
393
|
{
|
|
393
394
|
type: "checkbox",
|
|
@@ -397,10 +398,10 @@ function $e() {
|
|
|
397
398
|
className: "h-5 w-5 cursor-pointer rounded focus:outline-none focus:ring-2 focus:ring-primary focus:ring-offset-1"
|
|
398
399
|
}
|
|
399
400
|
) }),
|
|
400
|
-
h && o && /* @__PURE__ */ e(
|
|
401
|
+
h && o && /* @__PURE__ */ e(J, { children: "Using the default language state" })
|
|
401
402
|
] }),
|
|
402
403
|
/* @__PURE__ */ n("div", { children: [
|
|
403
|
-
/* @__PURE__ */ n(
|
|
404
|
+
/* @__PURE__ */ n(fe, { className: "flex items-center gap-2 text-sm leading-none", children: [
|
|
404
405
|
r.name,
|
|
405
406
|
h && o && /* @__PURE__ */ n("span", { className: "text-xs font-normal text-muted-foreground", children: [
|
|
406
407
|
"(",
|
|
@@ -414,8 +415,8 @@ function $e() {
|
|
|
414
415
|
] }),
|
|
415
416
|
/* @__PURE__ */ n("div", { className: "flex items-center gap-2", children: [
|
|
416
417
|
/* @__PURE__ */ e("div", { className: "mx-2 h-6 w-px bg-border" }),
|
|
417
|
-
/* @__PURE__ */ n(
|
|
418
|
-
/* @__PURE__ */ e(
|
|
418
|
+
/* @__PURE__ */ n(L, { delayDuration: 0, children: [
|
|
419
|
+
/* @__PURE__ */ e(F, { asChild: !0, children: /* @__PURE__ */ e(
|
|
419
420
|
v,
|
|
420
421
|
{
|
|
421
422
|
type: "button",
|
|
@@ -426,11 +427,11 @@ function $e() {
|
|
|
426
427
|
children: /* @__PURE__ */ e(Ge, { className: "h-4 w-4" })
|
|
427
428
|
}
|
|
428
429
|
) }),
|
|
429
|
-
/* @__PURE__ */ e(
|
|
430
|
+
/* @__PURE__ */ e(J, { children: "View schema" })
|
|
430
431
|
] }),
|
|
431
432
|
(h || !o) && /* @__PURE__ */ n(G, { children: [
|
|
432
|
-
/* @__PURE__ */ n(
|
|
433
|
-
/* @__PURE__ */ e(
|
|
433
|
+
/* @__PURE__ */ n(L, { delayDuration: 0, children: [
|
|
434
|
+
/* @__PURE__ */ e(F, { asChild: !0, children: /* @__PURE__ */ e(
|
|
434
435
|
v,
|
|
435
436
|
{
|
|
436
437
|
type: "button",
|
|
@@ -441,12 +442,12 @@ function $e() {
|
|
|
441
442
|
children: /* @__PURE__ */ e(je, { className: "h-4 w-4" })
|
|
442
443
|
}
|
|
443
444
|
) }),
|
|
444
|
-
/* @__PURE__ */ e(
|
|
445
|
+
/* @__PURE__ */ e(J, { children: "Edit schema" })
|
|
445
446
|
] }),
|
|
446
447
|
/* @__PURE__ */ n(U, { children: [
|
|
447
|
-
/* @__PURE__ */ n(
|
|
448
|
-
/* @__PURE__ */ e(
|
|
449
|
-
/* @__PURE__ */ e(
|
|
448
|
+
/* @__PURE__ */ n(L, { delayDuration: 0, children: [
|
|
449
|
+
/* @__PURE__ */ e(F, { asChild: !0, children: /* @__PURE__ */ e(pe, { className: "flex h-5 w-5 items-center justify-center rounded-md text-red-500 hover:bg-red-100 hover:text-red-800", children: /* @__PURE__ */ e(Be, { className: "h-4 w-4" }) }) }),
|
|
450
|
+
/* @__PURE__ */ e(J, { children: "Delete schema" })
|
|
450
451
|
] }),
|
|
451
452
|
/* @__PURE__ */ n(R, { children: [
|
|
452
453
|
/* @__PURE__ */ n(_, { children: [
|
|
@@ -459,7 +460,7 @@ function $e() {
|
|
|
459
460
|
] })
|
|
460
461
|
] }),
|
|
461
462
|
/* @__PURE__ */ n(q, { children: [
|
|
462
|
-
/* @__PURE__ */ e(
|
|
463
|
+
/* @__PURE__ */ e(V, { type: "button", children: "Cancel" }),
|
|
463
464
|
/* @__PURE__ */ e(
|
|
464
465
|
K,
|
|
465
466
|
{
|
|
@@ -475,7 +476,7 @@ function $e() {
|
|
|
475
476
|
] })
|
|
476
477
|
] })
|
|
477
478
|
] }) }),
|
|
478
|
-
!h && o && /* @__PURE__ */ e(
|
|
479
|
+
!h && o && /* @__PURE__ */ e(xe, { className: "px-2 pb-2", children: /* @__PURE__ */ n("div", { className: "flex w-full flex-col items-center justify-center rounded-lg border bg-gray-100 py-3", children: [
|
|
479
480
|
/* @__PURE__ */ n("div", { className: "flex items-center gap-2", children: [
|
|
480
481
|
/* @__PURE__ */ n("div", { className: "max-w-xl text-center text-xs text-gray-500", children: [
|
|
481
482
|
"Not available in '",
|
|
@@ -510,7 +511,7 @@ function $e() {
|
|
|
510
511
|
);
|
|
511
512
|
})
|
|
512
513
|
] }),
|
|
513
|
-
w && /* @__PURE__ */ e("div", { className: "flex items-center justify-center p-4", children: /* @__PURE__ */ e(
|
|
514
|
+
w && /* @__PURE__ */ e("div", { className: "flex items-center justify-center p-4", children: /* @__PURE__ */ e(O, { className: "h-5 w-5 animate-spin" }) })
|
|
514
515
|
] }),
|
|
515
516
|
/* @__PURE__ */ e(
|
|
516
517
|
Ie,
|
|
@@ -532,8 +533,8 @@ function $e() {
|
|
|
532
533
|
)
|
|
533
534
|
] });
|
|
534
535
|
}
|
|
535
|
-
const _e = ({ schema: l, onClose: i }) => /* @__PURE__ */ e(W, { open: !!l, onOpenChange: i, children: /* @__PURE__ */ n(
|
|
536
|
-
/* @__PURE__ */ e(
|
|
536
|
+
const _e = ({ schema: l, onClose: i }) => /* @__PURE__ */ e(W, { open: !!l, onOpenChange: i, children: /* @__PURE__ */ n($, { className: "max-w-2xl", children: [
|
|
537
|
+
/* @__PURE__ */ e(Y, { children: /* @__PURE__ */ n(X, { className: "flex items-center gap-2", children: [
|
|
537
538
|
l == null ? void 0 : l.name,
|
|
538
539
|
(l == null ? void 0 : l.lang) && /* @__PURE__ */ n("span", { className: "text-sm font-normal text-muted-foreground", children: [
|
|
539
540
|
"(",
|
|
@@ -549,7 +550,7 @@ const _e = ({ schema: l, onClose: i }) => /* @__PURE__ */ e(W, { open: !!l, onOp
|
|
|
549
550
|
/* @__PURE__ */ n("div", { children: [
|
|
550
551
|
/* @__PURE__ */ e("div", { className: "mb-2 text-xs font-medium text-muted-foreground", children: "JSON-LD Schema" }),
|
|
551
552
|
/* @__PURE__ */ e(
|
|
552
|
-
|
|
553
|
+
Ne,
|
|
553
554
|
{
|
|
554
555
|
value: JSON.stringify(l == null ? void 0 : l.jsonld, null, 2),
|
|
555
556
|
readOnly: !0,
|
|
@@ -561,5 +562,5 @@ const _e = ({ schema: l, onClose: i }) => /* @__PURE__ */ e(W, { open: !!l, onOp
|
|
|
561
562
|
] })
|
|
562
563
|
] }) });
|
|
563
564
|
export {
|
|
564
|
-
|
|
565
|
+
Xe as default
|
|
565
566
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),s=require("./index-C99FhuF1.cjs"),m=require("./register-chai-top-bar-BqwKw4uy.cjs"),c=require("./index-C0-pgg_p.cjs"),q=require("@tanstack/react-query"),I=require("lodash-es"),N=require("lucide-react"),x=require("react"),F=require("sonner"),z=()=>{const t=c.useApiUrl(),d=c.useFetch();return q.useQuery({queryKey:[c.ACTIONS.GET_GLOBAL_JSONLD_ITEMS],queryFn:async()=>d(t,{action:c.ACTIONS.GET_GLOBAL_JSONLD_ITEMS})})},U=({show:t,onClose:d,initialData:n})=>e.jsx(s.Dialog,{open:t,onOpenChange:()=>d(),children:t&&e.jsx(_,{show:t,onClose:d,initialData:n})}),_=({show:t,onClose:d,initialData:n})=>{const[r,j]=x.useState({name:"",content:"",description:"",enabledByDefaultForNewPages:!1}),[b,C]=x.useState(!1),{data:p}=c.useChaiCurrentPage(),{mutateAsync:S,isPending:f}=c.useAddGlobalSchema(),{mutateAsync:u}=c.useTogglePageGlobalSchema(),w=q.useQueryClient();x.useEffect(()=>{j(n?{name:n.name,description:n.description,content:JSON.stringify(n.jsonld,null,2),enabledByDefaultForNewPages:!1}:{name:"",description:"",content:"",enabledByDefaultForNewPages:!1}),C(!1)},[t,n]);const i=async()=>{if(!r.name||!r.content){F.toast.error("Please enter a name and content");return}const l=c.parseJSONWithPlaceholders(r.content);if(!l.isValid){F.toast.error("Invalid JSON-LD content");return}const y={name:r.name,jsonld:l.parsed,addToExistingPages:b,addToNewPages:r.enabledByDefaultForNewPages,description:r.description};n!=null&&n.primaryPageId&&(y.primaryPage=n.primaryPageId);const A=await S(y);p!=null&&p.id&&(A!=null&&A.id)&&!(n!=null&&n.primaryPageId)&&(await u({schemaId:A.id,pageId:p.id,enabled:!0}),w.invalidateQueries({queryKey:[c.ACTIONS.GET_LANGUAGE_PAGES,p.id]})),d()};return e.jsxs(s.DialogContent,{className:"flex max-w-xl flex-col overflow-y-auto",children:[e.jsx(s.DialogHeader,{children:e.jsx(s.DialogTitle,{children:"Add New Shared JSON-LD Schema"})}),e.jsxs("div",{className:"flex max-h-[75vh] flex-col space-y-2 overflow-y-auto",children:[(n==null?void 0:n.languageCode)&&e.jsxs(m.Alert,{className:"border-blue-200 bg-blue-50",children:[e.jsx(N.Info,{className:"h-4 w-4 text-blue-600"}),e.jsxs(m.AlertDescription,{className:"text-sm text-blue-800",children:["You are creating a ",e.jsx("span",{className:"font-semibold",children:n.languageCode})," language version of this schema. This will be linked to the default language schema."]})]}),e.jsxs("div",{children:[e.jsx(s.Label,{htmlFor:"new-name",children:"Schema Name"}),e.jsx(m.Input,{id:"new-name",value:r.name,onChange:l=>j({...r,name:l.target.value}),placeholder:"e.g., Product Schema",className:"text-xs"})]}),e.jsxs("div",{children:[e.jsx(s.Label,{htmlFor:"new-description",children:"Description"}),e.jsx(m.Input,{id:"new-description",value:r.description||"",onChange:l=>j({...r,description:l.target.value}),placeholder:"Brief description of this schema"})]}),e.jsxs("div",{children:[e.jsx(s.Label,{htmlFor:"new-content",children:"JSON-LD Content"}),e.jsx(c.SmartJsonInput,{id:"new-content",value:r.content||"{}",onChange:l=>j({...r,content:l}),placeholder:"Enter JSON-LD markup...",rows:10})]}),!(n!=null&&n.primaryPageId)&&e.jsxs("div",{className:"flex flex-col gap-3 pt-2",children:[e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx("input",{type:"checkbox",id:"add-to-all-existing",checked:b,onChange:l=>C(l.target.checked),className:"h-5 w-5 cursor-pointer rounded focus:outline-none focus:ring-2 focus:ring-primary focus:ring-offset-1"}),e.jsxs(s.Label,{htmlFor:"add-to-all-existing",children:[e.jsx("div",{children:"Add to all existing pages"}),e.jsx("div",{className:"text-xs font-light text-muted-foreground",children:"This schema will be added to all existing pages on your site"})]})]}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx("input",{type:"checkbox",id:"new-enabled",checked:r.enabledByDefaultForNewPages,onChange:l=>j({...r,enabledByDefaultForNewPages:l.target.checked}),className:"h-5 w-5 cursor-pointer rounded focus:outline-none focus:ring-2 focus:ring-primary focus:ring-offset-1"}),e.jsxs(s.Label,{htmlFor:"new-enabled",children:[e.jsx("div",{children:"Enabled by default for new pages"}),e.jsx("div",{className:"text-xs font-light text-muted-foreground",children:"New pages will automatically include this schema"})]})]})]}),e.jsx("div",{className:"border-t pt-3",children:e.jsxs("div",{className:"flex items-center justify-end gap-2",children:[e.jsx(m.Button,{disabled:f,variant:"outline",type:"button",size:"sm",onClick:()=>d(),children:"Cancel"}),e.jsx(m.Button,{disabled:f,type:"button",size:"sm",onClick:i,children:f?e.jsxs(e.Fragment,{children:[e.jsx(N.Loader,{className:"h-4 w-4 animate-spin"})," Adding"]}):e.jsxs(e.Fragment,{children:["Add Schema",(n==null?void 0:n.languageCode)&&` (${n.languageCode})`]})})]})})]})]})},H=({id:t,onClose:d})=>e.jsx(s.Dialog,{open:!!t,onOpenChange:()=>d(),children:t&&e.jsx(Q,{id:t,onClose:d})}),Q=({id:t,onClose:d})=>{const[n,r]=x.useState({name:"",content:"",description:"",enabledByDefaultForNewPages:!1}),[j,b]=x.useState(!1),[C,p]=x.useState(!1),[S,f]=x.useState(!1),{data:u}=z(),{mutateAsync:w,isPending:i}=c.useUpdateGlobalSchema(),{mutateAsync:l}=c.useApplySchemaToAllPages(),{mutateAsync:y}=c.useRemoveSchemaFromAllPages();x.useEffect(()=>{var h,D;if(t&&u){const v=u.find(L=>L.id===t);v&&(r({name:v.name,description:((h=v.metadata)==null?void 0:h.description)||"",content:JSON.stringify(v.jsonld,null,2),enabledByDefaultForNewPages:((D=v.metadata)==null?void 0:D.addToNewPages)||!1}),f(!!v.primaryPage))}},[t,u]);const A=async()=>{if(!n.name||!n.content){F.toast.error("Please enter a name and content");return}const h=c.parseJSONWithPlaceholders(n.content);if(!h.isValid){F.toast.error("Invalid JSON-LD content");return}const D={id:t,name:n.name,jsonld:h.parsed,addToNewPages:n.enabledByDefaultForNewPages,description:n.description};await w(D),d()},O=async()=>{try{await l(t)}finally{b(!1)}},T=async()=>{try{await y(t)}finally{p(!1)}};return e.jsxs(s.DialogContent,{className:"flex max-w-xl flex-col overflow-y-auto",children:[e.jsx(s.DialogHeader,{children:e.jsx(s.DialogTitle,{children:"Edit Shared JSON-LD Schema"})}),e.jsxs("div",{className:"flex max-h-[75vh] flex-col space-y-2 overflow-y-auto",children:[!S&&e.jsxs("div",{className:"flex items-center justify-between rounded-lg border border-blue-300 bg-blue-500/10 p-2",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-sm font-medium text-blue-900",children:"Manage Existing Pages"}),e.jsx("div",{className:"text-xs text-blue-700",children:"Add or remove this schema from all existing pages on your site"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(m.Button,{size:"sm",className:"text-xs",variant:"outline",onClick:()=>b(!0),children:"Add to all existing"}),e.jsx(m.Button,{size:"sm",variant:"ghost",className:"text-xs",onClick:()=>p(!0),children:"Remove from all"})]})]}),e.jsxs("div",{children:[e.jsx(s.Label,{htmlFor:"edit-name",children:"Schema Name"}),e.jsx(m.Input,{id:"edit-name",value:n.name,onChange:h=>r({...n,name:h.target.value}),placeholder:"e.g., Product Schema",className:"text-xs"})]}),e.jsxs("div",{children:[e.jsx(s.Label,{htmlFor:"edit-description",children:"Description"}),e.jsx(m.Input,{id:"edit-description",value:n.description||"",onChange:h=>r({...n,description:h.target.value}),placeholder:"Brief description of this schema"})]}),e.jsxs("div",{children:[e.jsx(s.Label,{htmlFor:"edit-content",children:"JSON-LD Content"}),e.jsx(c.SmartJsonInput,{id:"edit-content",value:n.content||"{}",onChange:h=>r({...n,content:h}),placeholder:"Enter JSON-LD markup...",rows:10})]}),!S&&e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx("input",{type:"checkbox",id:"edit-enabled",checked:n.enabledByDefaultForNewPages,onChange:h=>r({...n,enabledByDefaultForNewPages:h.target.checked}),className:"h-5 w-5 cursor-pointer rounded focus:outline-none focus:ring-2 focus:ring-primary focus:ring-offset-1"}),e.jsxs(s.Label,{htmlFor:"edit-enabled",children:[e.jsx("div",{children:"Enabled by default for new pages"}),e.jsx("div",{className:"text-xs font-light text-muted-foreground",children:"New pages will automatically include this schema"})]})]}),e.jsx("div",{className:"border-t pt-3",children:e.jsxs("div",{className:"flex items-center justify-end gap-2",children:[e.jsx(m.Button,{disabled:i,variant:"outline",type:"button",size:"sm",onClick:()=>d(),children:"Cancel"}),e.jsx(m.Button,{disabled:i,type:"button",size:"sm",onClick:A,children:i?e.jsxs(e.Fragment,{children:[e.jsx(N.Loader,{className:"h-4 w-4 animate-spin"})," Updating"]}):"Update Schema"})]})})]}),e.jsx(s.AlertDialog,{open:j,onOpenChange:b,children:e.jsxs(s.AlertDialogContent,{children:[e.jsxs(s.AlertDialogHeader,{children:[e.jsx(s.AlertDialogTitle,{children:"Add to All Existing Pages?"}),e.jsxs(s.AlertDialogDescription,{children:["This will add the schema ",e.jsx("span",{className:"font-medium",children:n.name})," to all existing pages on your site. This action cannot be undone automatically."]})]}),e.jsxs(s.AlertDialogFooter,{children:[e.jsx(s.AlertDialogCancel,{children:"Cancel"}),e.jsx(s.AlertDialogAction,{onClick:O,children:"Add to All"})]})]})}),e.jsx(s.AlertDialog,{open:C,onOpenChange:p,children:e.jsxs(s.AlertDialogContent,{children:[e.jsxs(s.AlertDialogHeader,{children:[e.jsx(s.AlertDialogTitle,{children:"Remove from All Pages?"}),e.jsxs(s.AlertDialogDescription,{children:["This will remove the schema ",e.jsx("span",{className:"font-medium",children:n.name})," from all existing pages on your site. This action cannot be undone automatically."]})]}),e.jsxs(s.AlertDialogFooter,{children:[e.jsx(s.AlertDialogCancel,{children:"Cancel"}),e.jsx(s.AlertDialogAction,{onClick:T,className:"bg-red-500 hover:bg-red-600",children:"Remove from All"})]})]})})]})};function V(){const[t,d]=x.useState(!1),[n,r]=x.useState(void 0),[j,b]=x.useState(null),[C,p]=x.useState(null),[S,f]=x.useState(null),{data:u,isLoading:w}=z(),{selectedLang:i}=s.useLanguages(),{data:l}=c.useChaiCurrentPage(),{data:y}=c.useLanguagePages(),{mutateAsync:A}=c.useDeleteGlobalSchema(),{mutateAsync:O}=c.useTogglePageGlobalSchema(),T=x.useMemo(()=>y==null?void 0:y.find(a=>!a.primaryPage&&a.lang===""),[y]),h=x.useMemo(()=>(T==null?void 0:T.globalJsonLds)||[],[T]),D=x.useMemo(()=>u?I.filter(u,o=>o.primaryPage===null&&o.lang==="").map(o=>{const g=i?I.find(u,P=>P.primaryPage===o.id&&P.lang===i):null;return{defaultSchema:o,languageVersion:g,displayItem:g||o,hasLanguageVersion:!!g}}):[],[u,i]),[v,L]=x.useState([]),E=v.length>0?v:(l==null?void 0:l.globalJsonLds)||[];x.useEffect(()=>{l!=null&&l.globalJsonLds&&L(l.globalJsonLds)},[l==null?void 0:l.globalJsonLds]);const R=async a=>{if(!(l!=null&&l.id))return;f(a);const o=E.includes(a),g=o?E.filter(P=>P!==a):[...E,a];L(g);try{await O({schemaId:a,pageId:l.id,enabled:!o})}catch{L(l.globalJsonLds)}finally{f(null)}},M=async a=>{f(a);try{await A(a)}finally{f(null)}};return e.jsxs("div",{className:"rounded border bg-muted p-2",children:[e.jsxs("div",{className:"flex items-center justify-between pb-2",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-xs font-medium",children:"Shared JSON-LD Templates"}),e.jsx("div",{className:"w-full text-xs text-gray-500",children:"Manage reusable JSON-LD schemas that can be applied across multiple pages"})]}),!i&&e.jsxs(s.Tooltip,{delayDuration:0,children:[e.jsx(s.TooltipTrigger,{type:"button",disabled:w,className:"rounded-full bg-primary p-1 text-primary-foreground hover:bg-primary/80",onClick:a=>{a.stopPropagation(),d(!0)},children:w?e.jsx(N.Loader,{className:"h-4 w-4 animate-spin"}):e.jsx(N.Plus,{className:"h-4 w-4"})}),e.jsx(s.TooltipContent,{children:"Add new schema"})]})]}),e.jsxs(s.ScrollArea,{className:"max-h-96 overflow-y-auto",children:[e.jsxs("div",{className:"space-y-2",children:[(!u||(u==null?void 0:u.length)===0)&&!w&&e.jsx("div",{className:"flex items-center justify-center px-2 py-4 text-xs",children:"No shared JSON-LD found"}),D.map(({defaultSchema:a,displayItem:o,hasLanguageVersion:g})=>{var B,G;const P=E.includes(o.id),J=h.includes(a.id),k=g&&i?J:P;return e.jsxs(s.Card,{className:`relative border-gray-300 p-0 shadow-none transition-all ${S===o.id?"pointer-events-none":""}`,children:[S===o.id&&e.jsx("div",{className:"absolute bottom-0 left-0 right-0 top-0 z-50 flex items-center justify-center rounded-xl bg-white/80",children:e.jsx(N.Loader,{className:"h-5 w-5 animate-spin text-primary"})}),e.jsx(s.CardHeader,{className:"p-2",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[(g||!i)&&e.jsxs(s.Tooltip,{delayDuration:0,children:[e.jsx(s.TooltipTrigger,{asChild:!0,children:e.jsx("input",{type:"checkbox",checked:k,onChange:()=>R(a.id),disabled:!!(g&&i),className:"h-5 w-5 cursor-pointer rounded focus:outline-none focus:ring-2 focus:ring-primary focus:ring-offset-1"})}),g&&i&&e.jsx(s.TooltipContent,{children:"Using the default language state"})]}),e.jsxs("div",{children:[e.jsxs(s.CardTitle,{className:"flex items-center gap-2 text-sm leading-none",children:[o.name,g&&i&&e.jsxs("span",{className:"text-xs font-normal text-muted-foreground",children:["(",i,")"]}),k&&e.jsx("span",{className:"sr-only text-xs font-normal text-muted-foreground",children:"Enabled"})]}),((B=o==null?void 0:o.metadata)==null?void 0:B.description)&&e.jsx("p",{className:"mt-1 text-xs leading-none text-muted-foreground",children:(G=o==null?void 0:o.metadata)==null?void 0:G.description})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"mx-2 h-6 w-px bg-border"}),e.jsxs(s.Tooltip,{delayDuration:0,children:[e.jsx(s.TooltipTrigger,{asChild:!0,children:e.jsx(m.Button,{type:"button",variant:"ghost",size:"icon",className:"h-5 w-5 p-0",onClick:()=>p(o.id),children:e.jsx(N.Eye,{className:"h-4 w-4"})})}),e.jsx(s.TooltipContent,{children:"View schema"})]}),(g||!i)&&e.jsxs(e.Fragment,{children:[e.jsxs(s.Tooltip,{delayDuration:0,children:[e.jsx(s.TooltipTrigger,{asChild:!0,children:e.jsx(m.Button,{type:"button",variant:"ghost",size:"icon",className:"h-5 w-5 p-0",onClick:()=>b(o.id),children:e.jsx(N.Edit,{className:"h-4 w-4"})})}),e.jsx(s.TooltipContent,{children:"Edit schema"})]}),e.jsxs(s.AlertDialog,{children:[e.jsxs(s.Tooltip,{delayDuration:0,children:[e.jsx(s.TooltipTrigger,{asChild:!0,children:e.jsx(s.AlertDialogTrigger,{className:"flex h-5 w-5 items-center justify-center rounded-md text-red-500 hover:bg-red-100 hover:text-red-800",children:e.jsx(N.Trash,{className:"h-4 w-4"})})}),e.jsx(s.TooltipContent,{children:"Delete schema"})]}),e.jsxs(s.AlertDialogContent,{children:[e.jsxs(s.AlertDialogHeader,{children:[e.jsx(s.AlertDialogTitle,{children:"Delete Schema"}),e.jsxs(s.AlertDialogDescription,{children:["Are you sure you want to delete"," ",e.jsx("span",{className:"font-medium",children:o.name}),"? This action cannot be undone."]})]}),e.jsxs(s.AlertDialogFooter,{children:[e.jsx(s.AlertDialogCancel,{type:"button",children:"Cancel"}),e.jsx(s.AlertDialogAction,{type:"button",onClick:()=>M(o.id),className:"bg-red-500 text-white hover:bg-red-600",children:"Delete"})]})]})]})]})]})]})}),!g&&i&&e.jsx(s.CardContent,{className:"px-2 pb-2",children:e.jsxs("div",{className:"flex w-full flex-col items-center justify-center rounded-lg border bg-gray-100 py-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("div",{className:"max-w-xl text-center text-xs text-gray-500",children:["Not available in '",i,"' language. Default language JSONLD will be used."]}),J&&e.jsx("span",{className:"rounded-full bg-green-100 px-2 py-0.5 text-xs font-medium text-green-700",children:"Enabled in default"})]}),e.jsx(m.Button,{type:"button",size:"sm",variant:"outline",className:"mt-2",onClick:()=>{r({name:a.name,description:a.description||"",jsonld:a.jsonld,languageCode:i,primaryPageId:a.id}),d(!0)},children:"Copy & Edit from default language"})]})})]},a.id)})]}),w&&e.jsx("div",{className:"flex items-center justify-center p-4",children:e.jsx(N.Loader,{className:"h-5 w-5 animate-spin"})})]}),e.jsx(U,{show:t,onClose:()=>{d(!1),r(void 0)},initialData:n}),e.jsx(H,{id:j,onClose:()=>b(null)}),e.jsx(K,{schema:u==null?void 0:u.find(a=>a.id===C),onClose:()=>p(null)})]})}const K=({schema:t,onClose:d})=>e.jsx(s.Dialog,{open:!!t,onOpenChange:d,children:e.jsxs(s.DialogContent,{className:"max-w-2xl",children:[e.jsx(s.DialogHeader,{children:e.jsxs(s.DialogTitle,{className:"flex items-center gap-2",children:[t==null?void 0:t.name,(t==null?void 0:t.lang)&&e.jsxs("span",{className:"text-sm font-normal text-muted-foreground",children:["(",t.lang,")"]})]})}),e.jsxs("div",{className:"space-y-3",children:[(t==null?void 0:t.description)&&e.jsxs("div",{children:[e.jsx("div",{className:"text-xs font-medium text-muted-foreground",children:"Description"}),e.jsx("div",{className:"text-sm",children:t.description})]}),e.jsxs("div",{children:[e.jsx("div",{className:"mb-2 text-xs font-medium text-muted-foreground",children:"JSON-LD Schema"}),e.jsx(s.Textarea,{value:JSON.stringify(t==null?void 0:t.jsonld,null,2),readOnly:!0,className:"font-mono text-xs",rows:15})]})]})]})});exports.default=V;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";const s=require("react/jsx-runtime"),b=require("./register-chai-top-bar-BqwKw4uy.cjs"),u=require("./index-C99FhuF1.cjs"),d=require("react"),j=e=>{if(!e)return{base:e,extension:null};const n=e.lastIndexOf(".");if(n<=0)return{base:e,extension:null};const t=e.substring(n);return{base:e.substring(0,n),extension:t}},x=e=>{if(!e)return e;const{base:n}=j(e);return n};function E(e,n){const t=(e||"").split("/").filter(Boolean);let r="",a=!0;if(n.slug==="/"){const i=t.pop()||"";if(u.LANGUAGES[i])a=!0;else{r=i;const o=t.pop()||"";a=!!u.LANGUAGES[o]}}else if(n.parent)t.length&&(r=t.pop()||"");else if(t.length){r=t.pop()||"";const i=t.pop()||"";a=!!u.LANGUAGES[i]}return{initSlug:r,prefix:a}}const v=e=>e&&x(e),C=(e,n)=>{const t=x(e||"");return!t||t==="/"?`/${n}`:`${t}/${n}`};function A({value:e,onChange:n,placeholder:t,parentSlug:r,onValidationChange:a,disabled:i=!1,fullSlug:o}){const[g,p]=d.useState(e),[l,f]=d.useState(null);d.useEffect(()=>{p(e)},[e]);const h=S=>{const c=S.target.value.replace(/\//g,"").replace(/\s+/g,"-").replace(/[^a-zA-Z0-9-_.]/g,"-").replace(/-+/g,"-").replace(/^-+/,"").toLowerCase(),m=(c.match(/\./g)||[]).length,N=m<=1;m>1?f("Invalid slug. Only one dot (.) is allowed in the slug"):f(null),a&&a(N),p(c),n(c)};return s.jsxs("div",{children:[r&&s.jsx("div",{className:"mb-1 flex items-center",children:s.jsxs("span",{className:"text-xs text-gray-500",children:["Parent: ",s.jsx("span",{className:"font-mono text-gray-900",children:v(r)})]})}),s.jsxs("div",{className:"relative",children:[s.jsx(b.Input,{disabled:i,value:g,onChange:h,placeholder:t,className:l?"border-red-500":""}),l&&s.jsx("div",{className:"mt-1 text-xs text-red-500",children:l})]}),o&&o!=="undefined"&&s.jsx("div",{className:"mt-1 flex items-center",children:s.jsxs("span",{className:"text-xs text-gray-500",children:["Complete Slug: ",s.jsx("span",{className:"font-mono text-gray-900",children:o})]})})]})}exports.SlugInput=A;exports.combineParentChildSlugs=C;exports.parseSlugForEdit=E;exports.removeSlugExtension=x;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { jsxs as i, jsx as o } from "react/jsx-runtime";
|
|
2
|
-
import {
|
|
2
|
+
import { z as v } from "./register-chai-top-bar-ESJHs5s-.js";
|
|
3
|
+
import { a8 as d } from "./index-rAcNbjk_.js";
|
|
3
4
|
import { useState as x, useEffect as C } from "react";
|
|
4
5
|
const y = (e) => {
|
|
5
6
|
if (!e) return { base: e, extension: null };
|
|
@@ -33,11 +34,11 @@ function w(e, n) {
|
|
|
33
34
|
}
|
|
34
35
|
return { initSlug: s, prefix: r };
|
|
35
36
|
}
|
|
36
|
-
const E = (e) => e && g(e),
|
|
37
|
+
const E = (e) => e && g(e), D = (e, n) => {
|
|
37
38
|
const t = g(e || "");
|
|
38
39
|
return !t || t === "/" ? `/${n}` : `${t}/${n}`;
|
|
39
40
|
};
|
|
40
|
-
function
|
|
41
|
+
function G({
|
|
41
42
|
value: e,
|
|
42
43
|
onChange: n,
|
|
43
44
|
placeholder: t,
|
|
@@ -50,8 +51,8 @@ function D({
|
|
|
50
51
|
C(() => {
|
|
51
52
|
u(e);
|
|
52
53
|
}, [e]);
|
|
53
|
-
const
|
|
54
|
-
const p =
|
|
54
|
+
const N = (b) => {
|
|
55
|
+
const p = b.target.value.replace(/\//g, "").replace(/\s+/g, "-").replace(/[^a-zA-Z0-9-_.]/g, "-").replace(/-+/g, "-").replace(/^-+/, "").toLowerCase(), m = (p.match(/\./g) || []).length, S = m <= 1;
|
|
55
56
|
m > 1 ? f("Invalid slug. Only one dot (.) is allowed in the slug") : f(null), r && r(S), u(p), n(p);
|
|
56
57
|
};
|
|
57
58
|
return /* @__PURE__ */ i("div", { children: [
|
|
@@ -65,7 +66,7 @@ function D({
|
|
|
65
66
|
{
|
|
66
67
|
disabled: a,
|
|
67
68
|
value: h,
|
|
68
|
-
onChange:
|
|
69
|
+
onChange: N,
|
|
69
70
|
placeholder: t,
|
|
70
71
|
className: c ? "border-red-500" : ""
|
|
71
72
|
}
|
|
@@ -79,8 +80,8 @@ function D({
|
|
|
79
80
|
] });
|
|
80
81
|
}
|
|
81
82
|
export {
|
|
82
|
-
|
|
83
|
-
|
|
83
|
+
G as S,
|
|
84
|
+
D as c,
|
|
84
85
|
w as p,
|
|
85
86
|
g as r
|
|
86
87
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var O=Object.defineProperty;var D=(l,r,e)=>r in l?O(l,r,{enumerable:!0,configurable:!0,writable:!0,value:e}):l[r]=e;var y=(l,r,e)=>D(l,typeof r!="symbol"?r+"":r,e);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const h=require("./actions-registery-YnFmU21O.cjs"),f=require("lodash-es"),b=require("sharp"),c=require("zod");class A{constructor(r,e,t){this.appId=r,this.userId=e,this.supabase=t}appendUpdatedAtToUrl(r,e){if(f.isEmpty(r))return"";const t=new URL(r),o=new Date(e).getTime();return t.searchParams.set("t",o.toString()),`${t.origin}${t.pathname}${t.search}${t.hash}`}getBufferFromBase64(r){try{const e=r.split(",")[1]||r;return Buffer.from(e,"base64")}catch{throw new Error("Invalid base64 string format")}}async uploadImageFile(r,e,t,o){try{const s=this.getBufferFromBase64(r),n=await b(s).metadata(),i=["jpeg","jpg","png","webp","gif","svg","tiff"];if(!n.format||!i.includes(n.format.toLowerCase()))throw new Error(`Invalid image format: ${n.format||"unknown"}`);const u=o?await b(s).webp({quality:100}).resize({width:Math.min(n.width||2e3,2e3)}).toBuffer():await b(s).webp({quality:100}).toBuffer();let a=u;if(o&&u.length>120*1024){const _=Math.floor(90*(122880/u.length));a=await b(s).webp({quality:_}).resize({width:Math.min(n.width||2e3,2e3)}).toBuffer()}const d=await b(a).metadata(),g=await b(s).webp({quality:70}).resize({width:300}).toBuffer(),p=t.split("."),m=p.length>1?p.slice(0,-1).join("."):t,w=`${f.kebabCase(m)}.webp`,z=`${w}_thumbnail.webp`,T=this.appId,I=e?`${T}/${e}`:T,S=h.getChaiAction("UPLOAD_TO_STORAGE");if(!S)throw new Error("UPLOAD_TO_STORAGE action not found");S.setContext({appId:this.appId,userId:this.userId});const U=await S.execute({file:a.toString("base64"),fileName:w,contentType:"image/webp",folder:I});if(U.error)throw new Error(U.error);const E=await S.execute({file:g.toString("base64"),fileName:z,contentType:"image/webp",folder:I});if(E.error)throw new Error(E.error);return{url:U.data.url,thumbnailUrl:E.data.url,size:d.size||a.length,width:d.width||0,height:d.height||0,mimeType:"image/webp"}}catch(s){return console.error("Upload image error:",s),{error:s instanceof Error?s.message:"Unknown error"}}}async uploadSvgFile(r,e,t){try{const o=this.getBufferFromBase64(r);let s,n;try{const w=await b(o).metadata();s=w.width,n=w.height}catch{}const i=t.split("."),u=i.length>1?i.slice(0,-1).join("."):t,a=`${f.kebabCase(u)}.svg`,d=this.appId,g=e?`${d}/${e}`:d,p=h.getChaiAction("UPLOAD_TO_STORAGE");if(!p)throw new Error("UPLOAD_TO_STORAGE action not found");p.setContext({appId:this.appId,userId:this.userId});const m=await p.execute({file:o.toString("base64"),fileName:a,contentType:"image/svg+xml",folder:g});if(m.error)throw new Error(m.error);return{url:m.data.url,thumbnailUrl:m.data.url,size:o.length,width:s,height:n,mimeType:"image/svg+xml"}}catch(o){return console.error("SVG upload error:",o),{error:o instanceof Error?o.message:"Unknown error"}}}async upload({file:r,folderId:e,name:t,optimize:o=!0}){var s;try{const i=t.toLowerCase().endsWith(".svg")||r.includes("data:image/svg+xml")?await this.uploadSvgFile(r,e,t):await this.uploadImageFile(r,e,t,o??!0);if("error"in i)return i;const u={name:t,app:this.appId,url:i.url,thumbnailUrl:i.thumbnailUrl,size:(s=i.size)==null?void 0:s.toString(),width:i.width,height:i.height,format:i.mimeType.split("/")[1],folderId:e,type:i.mimeType.startsWith("image/")?"image":"file",createdBy:this.userId,updatedAt:new Date().toISOString()},{data:a,error:d}=await this.supabase.from("app_assets").insert(u).select("*").single();if(d)throw new Error(`Failed to store asset in database: ${d.message}`);return{id:a.id,name:a.name,type:a.type,url:this.appendUpdatedAtToUrl(a.url,a.updatedAt),size:a.size,thumbnailUrl:this.appendUpdatedAtToUrl(a.thumbnailUrl||"",a.updatedAt),width:a.width,height:a.height,format:a.format,folderId:a.folderId,createdBy:a.createdBy||"",createdAt:a.createdAt,updatedAt:a.updatedAt}}catch(n){return{error:n instanceof Error?n.message:"Unknown error occurred"}}}async getAsset({id:r}){try{const{data:e,error:t}=await this.supabase.from("app_assets").select("*").eq("id",r).eq("app",this.appId).single();if(t)throw new Error(`Failed to fetch asset: ${t.message}`);return f.set(e,"url",this.appendUpdatedAtToUrl(e.url,e.updatedAt)),f.set(e,"thumbnailUrl",this.appendUpdatedAtToUrl(e.thumbnailUrl||"",e.updatedAt)),e}catch(e){return{error:e instanceof Error?e.message:"Unknown error occurred"}}}async getAssets({search:r="",page:e=1,limit:t=20}={}){try{const o=(e-1)*t;let s=this.supabase.from("app_assets").select("*",{count:"exact"}).eq("app",this.appId).order("updatedAt",{ascending:!1});r&&(s=s.or(`name.ilike.%${r}%,description.ilike.%${r}%`));const{data:n,error:i,count:u}=await s.range(o,o+t-1);if(i)throw new Error(i.message);return{assets:n.map(d=>(f.set(d,"url",this.appendUpdatedAtToUrl(d.url,d.updatedAt)),f.set(d,"thsupabaseumbnailUrl",this.appendUpdatedAtToUrl(d.thumbnailUrl||"",d.updatedAt)),d)),total:u||0,page:e,pageSize:t}}catch(o){throw console.error("Error fetching assets:",o),o}}async deleteAsset({id:r}){try{const{data:e,error:t}=await this.supabase.from("app_assets").select("*").eq("id",r).eq("app",this.appId).single();if(t)throw new Error(`Failed to fetch asset: ${t.message}`);if(e.url)try{const n=new URL(e.url).pathname.split("/"),i=n.indexOf("dam-assets");if(i!==-1){const u=n.slice(i+1).join("/"),a=h.getChaiAction("DELETE_FROM_STORAGE");if(a&&(a.setContext({appId:this.appId,userId:this.userId}),await a.execute({key:u})),e.thumbnailUrl&&e.thumbnailUrl!==e.url){const g=new URL(e.thumbnailUrl).pathname.split("/"),p=g.indexOf("dam-assets");if(p!==-1){const m=g.slice(p+1).join("/");a&&await a.execute({key:m})}}}}catch(s){console.warn("Failed to delete from storage, continuing with database deletion:",s)}const{error:o}=await this.supabase.from("app_assets").delete().eq("id",r);if(o)throw new Error(`Failed to delete asset: ${o.message}`);return{success:!0}}catch(e){return{error:e instanceof Error?e.message:"Unknown error occurred"}}}async updateAsset({id:r,file:e,description:t}){var o,s;try{const{data:n,error:i}=await this.supabase.from("app_assets").select("*").eq("id",r).single();if(i)throw new Error(`Failed to fetch asset: ${i.message}`);const u={};if(t!==void 0&&(u.description=t,u.updatedAt=new Date().toISOString()),e){const p=((o=n.format)==null?void 0:o.toLowerCase())==="svg"||e.includes("data:image/svg+xml")?await this.uploadSvgFile(e,n.folderId,n.name):await this.uploadImageFile(e,n.folderId,n.name,!0);if("error"in p)return p;u.url=p.url,u.thumbnailUrl=p.thumbnailUrl,u.size=(s=p.size)==null?void 0:s.toString(),u.width=p.width,u.height=p.height,u.format=p.mimeType.split("/")[1],u.updatedAt=new Date().toISOString()}const{data:a,error:d}=await this.supabase.from("app_assets").update(u).eq("id",r).select().single();if(d)throw new Error(`Failed to update asset: ${d.message}`);return f.set(a,"url",this.appendUpdatedAtToUrl(a.url,a.updatedAt)),f.set(a,"thumbnailUrl",this.appendUpdatedAtToUrl(a.thumbnailUrl||"",a.updatedAt)),a}catch(n){return{error:n instanceof Error?n.message:"Unknown error occurred"}}}}const C=c.z.object({name:c.z.string(),file:c.z.string(),folderId:c.z.string().optional().nullable(),optimize:c.z.boolean().optional()});class F extends h.ChaiBaseAction{constructor(r){super(),this.supabase=r}getValidationSchema(){return C}async execute(r){try{if(!this.context)return{error:"Context not set",status:400};const{appId:e,userId:t}=this.context;if(!t)return{error:"User ID is required",status:401};const s=await new A(e,t,this.supabase).upload(r);return"error"in s?{error:s.error,status:400}:s}catch(e){return console.error("UPLOAD_ASSET error:",e),{error:e instanceof Error?e.message:"Unknown error",status:500}}}}const B=c.z.object({id:c.z.string()});class v extends h.ChaiBaseAction{constructor(r){super(),this.supabase=r}getValidationSchema(){return B}async execute(r){try{if(!this.context)return{error:"Context not set",status:400};const{appId:e,userId:t}=this.context;if(!t)return{error:"User ID is required",status:401};const s=await new A(e,t,this.supabase).getAsset(r);return"error"in s?{error:s.error,status:400}:s}catch(e){return console.error("GET_ASSET error:",e),{error:e instanceof Error?e.message:"Unknown error",status:500}}}}const $=c.z.object({search:c.z.string().optional(),page:c.z.number().optional(),limit:c.z.number().optional()});class q extends h.ChaiBaseAction{constructor(r){super(),this.supabase=r}getValidationSchema(){return $}async execute(r){try{if(!this.context)return{error:"Context not set",status:400};const{appId:e,userId:t}=this.context;if(!t)return{error:"User ID is required",status:401};const s=await new A(e,t,this.supabase).getAssets(r);return"error"in s?{error:s.error,status:400}:s}catch(e){return console.error("GET_ASSETS error:",e),{error:e instanceof Error?e.message:"Unknown error",status:500}}}}const G=c.z.object({id:c.z.string()});class j extends h.ChaiBaseAction{constructor(r){super(),this.supabase=r}getValidationSchema(){return G}async execute(r){try{if(!this.context)return{error:"Context not set",status:400};const{appId:e,userId:t}=this.context;if(!t)return{error:"User ID is required",status:401};const s=await new A(e,t,this.supabase).deleteAsset(r);return"error"in s?{error:s.error,status:400}:s}catch(e){return console.error("DELETE_ASSET error:",e),{error:e instanceof Error?e.message:"Unknown error",status:500}}}}const L=c.z.object({id:c.z.string(),file:c.z.string().optional(),description:c.z.string().optional()});class P extends h.ChaiBaseAction{constructor(r){super(),this.supabase=r}getValidationSchema(){return L}async execute(r){try{if(!this.context)return{error:"Context not set",status:400};const{appId:e,userId:t}=this.context;if(!t)return{error:"User ID is required",status:401};const s=await new A(e,t,this.supabase).updateAsset(r);return"error"in s?{error:s.error,status:400}:s}catch(e){return console.error("UPDATE_ASSET error:",e),{error:e instanceof Error?e.message:"Unknown error",status:500}}}}const R=c.z.object({userId:c.z.string()});class M extends h.ChaiBaseAction{constructor(r){super(),this.supabase=r}getValidationSchema(){return R}async execute(r){var e,t,o,s,n,i;try{const{userId:u}=r,{data:a,error:d}=await this.supabase.auth.admin.getUserById(u);return d?{data:{id:"unknown",email:"unknown@chaibuilder.com",name:"Unknown",avatar:""},status:200}:{data:{id:((e=a.user)==null?void 0:e.id)||"unknown",email:((t=a.user)==null?void 0:t.email)||"unknown@chaibuilder.com",name:((s=(o=a.user)==null?void 0:o.user_metadata)==null?void 0:s.name)||"Unknown",avatar:((i=(n=a.user)==null?void 0:n.user_metadata)==null?void 0:i.avatar)||""},status:200}}catch{return{data:{id:"unknown",email:"unknown@chaibuilder.com",name:"Unknown",avatar:""},status:200}}}}const N=c.z.object({key:c.z.string()});class x extends h.ChaiBaseAction{constructor(e){super();y(this,"bucketName","dam-assets");this.supabase=e}getValidationSchema(){return N}async execute(e){try{const{key:t}=e,{error:o}=await this.supabase.storage.from(this.bucketName).remove([t]);return o?{error:`Failed to delete from Supabase Storage: ${o.message}`,status:500}:{data:{success:!0},status:200}}catch(t){return console.error("DELETE_FROM_STORAGE error:",t),{error:t instanceof Error?t.message:"Unknown error",status:500}}}}const V=c.z.object({file:c.z.string(),fileName:c.z.string(),contentType:c.z.string().optional(),folder:c.z.string().optional(),metadata:c.z.record(c.z.string(),c.z.any()).optional()});class k extends h.ChaiBaseAction{constructor(e){super();y(this,"bucketName","dam-assets");this.supabase=e}getValidationSchema(){return V}async execute(e){try{if(!this.context)return{error:"Context not set",status:400};const{appId:t}=this.context,{file:o,fileName:s,contentType:n,folder:i,metadata:u}=e;let a;if(typeof o=="string"){const w=o.split(",")[1]||o;a=Buffer.from(w,"base64")}else a=o;const d=i?`${i}/${s}`:`${t}/${s}`,{data:g,error:p}=await this.supabase.storage.from(this.bucketName).upload(d,a,{contentType:n||"application/octet-stream",upsert:!0,...u&&{metadata:u}});if(p)return{error:`Failed to upload to Supabase Storage: ${p.message}`,status:500};const{data:{publicUrl:m}}=this.supabase.storage.from(this.bucketName).getPublicUrl(d);return{data:{url:m,key:g.path,size:a.length,metadata:u},status:200}}catch(t){return console.error("UPLOAD_TO_STORAGE error:",t),{error:t instanceof Error?t.message:"Unknown error",status:500}}}}const W=l=>({GET_CHAI_USER:new M(l)}),H=l=>({UPLOAD_ASSET:new F(l),GET_ASSET:new v(l),GET_ASSETS:new q(l),DELETE_ASSET:new j(l),UPDATE_ASSET:new P(l),UPLOAD_TO_STORAGE:new k(l),DELETE_FROM_STORAGE:new x(l)});exports.DeleteFromStorageAction=x;exports.SupabaseAuthActions=W;exports.SupabaseStorageActions=H;exports.UploadToStorageAction=k;
|
|
1
|
+
"use strict";var O=Object.defineProperty;var D=(l,r,e)=>r in l?O(l,r,{enumerable:!0,configurable:!0,writable:!0,value:e}):l[r]=e;var y=(l,r,e)=>D(l,typeof r!="symbol"?r+"":r,e);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const h=require("./actions-registery-JdxhXhT6.cjs"),f=require("lodash-es"),b=require("sharp"),c=require("zod");class A{constructor(r,e,t){this.appId=r,this.userId=e,this.supabase=t}appendUpdatedAtToUrl(r,e){if(f.isEmpty(r))return"";const t=new URL(r),o=new Date(e).getTime();return t.searchParams.set("t",o.toString()),`${t.origin}${t.pathname}${t.search}${t.hash}`}getBufferFromBase64(r){try{const e=r.split(",")[1]||r;return Buffer.from(e,"base64")}catch{throw new Error("Invalid base64 string format")}}async uploadImageFile(r,e,t,o){try{const s=this.getBufferFromBase64(r),n=await b(s).metadata(),i=["jpeg","jpg","png","webp","gif","svg","tiff"];if(!n.format||!i.includes(n.format.toLowerCase()))throw new Error(`Invalid image format: ${n.format||"unknown"}`);const u=o?await b(s).webp({quality:100}).resize({width:Math.min(n.width||2e3,2e3)}).toBuffer():await b(s).webp({quality:100}).toBuffer();let a=u;if(o&&u.length>120*1024){const _=Math.floor(90*(122880/u.length));a=await b(s).webp({quality:_}).resize({width:Math.min(n.width||2e3,2e3)}).toBuffer()}const d=await b(a).metadata(),g=await b(s).webp({quality:70}).resize({width:300}).toBuffer(),p=t.split("."),m=p.length>1?p.slice(0,-1).join("."):t,w=`${f.kebabCase(m)}.webp`,z=`${w}_thumbnail.webp`,T=this.appId,I=e?`${T}/${e}`:T,S=h.getChaiAction("UPLOAD_TO_STORAGE");if(!S)throw new Error("UPLOAD_TO_STORAGE action not found");S.setContext({appId:this.appId,userId:this.userId});const U=await S.execute({file:a.toString("base64"),fileName:w,contentType:"image/webp",folder:I});if(U.error)throw new Error(U.error);const E=await S.execute({file:g.toString("base64"),fileName:z,contentType:"image/webp",folder:I});if(E.error)throw new Error(E.error);return{url:U.data.url,thumbnailUrl:E.data.url,size:d.size||a.length,width:d.width||0,height:d.height||0,mimeType:"image/webp"}}catch(s){return console.error("Upload image error:",s),{error:s instanceof Error?s.message:"Unknown error"}}}async uploadSvgFile(r,e,t){try{const o=this.getBufferFromBase64(r);let s,n;try{const w=await b(o).metadata();s=w.width,n=w.height}catch{}const i=t.split("."),u=i.length>1?i.slice(0,-1).join("."):t,a=`${f.kebabCase(u)}.svg`,d=this.appId,g=e?`${d}/${e}`:d,p=h.getChaiAction("UPLOAD_TO_STORAGE");if(!p)throw new Error("UPLOAD_TO_STORAGE action not found");p.setContext({appId:this.appId,userId:this.userId});const m=await p.execute({file:o.toString("base64"),fileName:a,contentType:"image/svg+xml",folder:g});if(m.error)throw new Error(m.error);return{url:m.data.url,thumbnailUrl:m.data.url,size:o.length,width:s,height:n,mimeType:"image/svg+xml"}}catch(o){return console.error("SVG upload error:",o),{error:o instanceof Error?o.message:"Unknown error"}}}async upload({file:r,folderId:e,name:t,optimize:o=!0}){var s;try{const i=t.toLowerCase().endsWith(".svg")||r.includes("data:image/svg+xml")?await this.uploadSvgFile(r,e,t):await this.uploadImageFile(r,e,t,o??!0);if("error"in i)return i;const u={name:t,app:this.appId,url:i.url,thumbnailUrl:i.thumbnailUrl,size:(s=i.size)==null?void 0:s.toString(),width:i.width,height:i.height,format:i.mimeType.split("/")[1],folderId:e,type:i.mimeType.startsWith("image/")?"image":"file",createdBy:this.userId,updatedAt:new Date().toISOString()},{data:a,error:d}=await this.supabase.from("app_assets").insert(u).select("*").single();if(d)throw new Error(`Failed to store asset in database: ${d.message}`);return{id:a.id,name:a.name,type:a.type,url:this.appendUpdatedAtToUrl(a.url,a.updatedAt),size:a.size,thumbnailUrl:this.appendUpdatedAtToUrl(a.thumbnailUrl||"",a.updatedAt),width:a.width,height:a.height,format:a.format,folderId:a.folderId,createdBy:a.createdBy||"",createdAt:a.createdAt,updatedAt:a.updatedAt}}catch(n){return{error:n instanceof Error?n.message:"Unknown error occurred"}}}async getAsset({id:r}){try{const{data:e,error:t}=await this.supabase.from("app_assets").select("*").eq("id",r).eq("app",this.appId).single();if(t)throw new Error(`Failed to fetch asset: ${t.message}`);return f.set(e,"url",this.appendUpdatedAtToUrl(e.url,e.updatedAt)),f.set(e,"thumbnailUrl",this.appendUpdatedAtToUrl(e.thumbnailUrl||"",e.updatedAt)),e}catch(e){return{error:e instanceof Error?e.message:"Unknown error occurred"}}}async getAssets({search:r="",page:e=1,limit:t=20}={}){try{const o=(e-1)*t;let s=this.supabase.from("app_assets").select("*",{count:"exact"}).eq("app",this.appId).order("updatedAt",{ascending:!1});r&&(s=s.or(`name.ilike.%${r}%,description.ilike.%${r}%`));const{data:n,error:i,count:u}=await s.range(o,o+t-1);if(i)throw new Error(i.message);return{assets:n.map(d=>(f.set(d,"url",this.appendUpdatedAtToUrl(d.url,d.updatedAt)),f.set(d,"thsupabaseumbnailUrl",this.appendUpdatedAtToUrl(d.thumbnailUrl||"",d.updatedAt)),d)),total:u||0,page:e,pageSize:t}}catch(o){throw console.error("Error fetching assets:",o),o}}async deleteAsset({id:r}){try{const{data:e,error:t}=await this.supabase.from("app_assets").select("*").eq("id",r).eq("app",this.appId).single();if(t)throw new Error(`Failed to fetch asset: ${t.message}`);if(e.url)try{const n=new URL(e.url).pathname.split("/"),i=n.indexOf("dam-assets");if(i!==-1){const u=n.slice(i+1).join("/"),a=h.getChaiAction("DELETE_FROM_STORAGE");if(a&&(a.setContext({appId:this.appId,userId:this.userId}),await a.execute({key:u})),e.thumbnailUrl&&e.thumbnailUrl!==e.url){const g=new URL(e.thumbnailUrl).pathname.split("/"),p=g.indexOf("dam-assets");if(p!==-1){const m=g.slice(p+1).join("/");a&&await a.execute({key:m})}}}}catch(s){console.warn("Failed to delete from storage, continuing with database deletion:",s)}const{error:o}=await this.supabase.from("app_assets").delete().eq("id",r);if(o)throw new Error(`Failed to delete asset: ${o.message}`);return{success:!0}}catch(e){return{error:e instanceof Error?e.message:"Unknown error occurred"}}}async updateAsset({id:r,file:e,description:t}){var o,s;try{const{data:n,error:i}=await this.supabase.from("app_assets").select("*").eq("id",r).single();if(i)throw new Error(`Failed to fetch asset: ${i.message}`);const u={};if(t!==void 0&&(u.description=t,u.updatedAt=new Date().toISOString()),e){const p=((o=n.format)==null?void 0:o.toLowerCase())==="svg"||e.includes("data:image/svg+xml")?await this.uploadSvgFile(e,n.folderId,n.name):await this.uploadImageFile(e,n.folderId,n.name,!0);if("error"in p)return p;u.url=p.url,u.thumbnailUrl=p.thumbnailUrl,u.size=(s=p.size)==null?void 0:s.toString(),u.width=p.width,u.height=p.height,u.format=p.mimeType.split("/")[1],u.updatedAt=new Date().toISOString()}const{data:a,error:d}=await this.supabase.from("app_assets").update(u).eq("id",r).select().single();if(d)throw new Error(`Failed to update asset: ${d.message}`);return f.set(a,"url",this.appendUpdatedAtToUrl(a.url,a.updatedAt)),f.set(a,"thumbnailUrl",this.appendUpdatedAtToUrl(a.thumbnailUrl||"",a.updatedAt)),a}catch(n){return{error:n instanceof Error?n.message:"Unknown error occurred"}}}}const C=c.z.object({name:c.z.string(),file:c.z.string(),folderId:c.z.string().optional().nullable(),optimize:c.z.boolean().optional()});class F extends h.ChaiBaseAction{constructor(r){super(),this.supabase=r}getValidationSchema(){return C}async execute(r){try{if(!this.context)return{error:"Context not set",status:400};const{appId:e,userId:t}=this.context;if(!t)return{error:"User ID is required",status:401};const s=await new A(e,t,this.supabase).upload(r);return"error"in s?{error:s.error,status:400}:s}catch(e){return console.error("UPLOAD_ASSET error:",e),{error:e instanceof Error?e.message:"Unknown error",status:500}}}}const B=c.z.object({id:c.z.string()});class v extends h.ChaiBaseAction{constructor(r){super(),this.supabase=r}getValidationSchema(){return B}async execute(r){try{if(!this.context)return{error:"Context not set",status:400};const{appId:e,userId:t}=this.context;if(!t)return{error:"User ID is required",status:401};const s=await new A(e,t,this.supabase).getAsset(r);return"error"in s?{error:s.error,status:400}:s}catch(e){return console.error("GET_ASSET error:",e),{error:e instanceof Error?e.message:"Unknown error",status:500}}}}const $=c.z.object({search:c.z.string().optional(),page:c.z.number().optional(),limit:c.z.number().optional()});class q extends h.ChaiBaseAction{constructor(r){super(),this.supabase=r}getValidationSchema(){return $}async execute(r){try{if(!this.context)return{error:"Context not set",status:400};const{appId:e,userId:t}=this.context;if(!t)return{error:"User ID is required",status:401};const s=await new A(e,t,this.supabase).getAssets(r);return"error"in s?{error:s.error,status:400}:s}catch(e){return console.error("GET_ASSETS error:",e),{error:e instanceof Error?e.message:"Unknown error",status:500}}}}const G=c.z.object({id:c.z.string()});class j extends h.ChaiBaseAction{constructor(r){super(),this.supabase=r}getValidationSchema(){return G}async execute(r){try{if(!this.context)return{error:"Context not set",status:400};const{appId:e,userId:t}=this.context;if(!t)return{error:"User ID is required",status:401};const s=await new A(e,t,this.supabase).deleteAsset(r);return"error"in s?{error:s.error,status:400}:s}catch(e){return console.error("DELETE_ASSET error:",e),{error:e instanceof Error?e.message:"Unknown error",status:500}}}}const L=c.z.object({id:c.z.string(),file:c.z.string().optional(),description:c.z.string().optional()});class P extends h.ChaiBaseAction{constructor(r){super(),this.supabase=r}getValidationSchema(){return L}async execute(r){try{if(!this.context)return{error:"Context not set",status:400};const{appId:e,userId:t}=this.context;if(!t)return{error:"User ID is required",status:401};const s=await new A(e,t,this.supabase).updateAsset(r);return"error"in s?{error:s.error,status:400}:s}catch(e){return console.error("UPDATE_ASSET error:",e),{error:e instanceof Error?e.message:"Unknown error",status:500}}}}const R=c.z.object({userId:c.z.string()});class M extends h.ChaiBaseAction{constructor(r){super(),this.supabase=r}getValidationSchema(){return R}async execute(r){var e,t,o,s,n,i;try{const{userId:u}=r,{data:a,error:d}=await this.supabase.auth.admin.getUserById(u);return d?{data:{id:"unknown",email:"unknown@chaibuilder.com",name:"Unknown",avatar:""},status:200}:{data:{id:((e=a.user)==null?void 0:e.id)||"unknown",email:((t=a.user)==null?void 0:t.email)||"unknown@chaibuilder.com",name:((s=(o=a.user)==null?void 0:o.user_metadata)==null?void 0:s.name)||"Unknown",avatar:((i=(n=a.user)==null?void 0:n.user_metadata)==null?void 0:i.avatar)||""},status:200}}catch{return{data:{id:"unknown",email:"unknown@chaibuilder.com",name:"Unknown",avatar:""},status:200}}}}const N=c.z.object({key:c.z.string()});class x extends h.ChaiBaseAction{constructor(e){super();y(this,"bucketName","dam-assets");this.supabase=e}getValidationSchema(){return N}async execute(e){try{const{key:t}=e,{error:o}=await this.supabase.storage.from(this.bucketName).remove([t]);return o?{error:`Failed to delete from Supabase Storage: ${o.message}`,status:500}:{data:{success:!0},status:200}}catch(t){return console.error("DELETE_FROM_STORAGE error:",t),{error:t instanceof Error?t.message:"Unknown error",status:500}}}}const V=c.z.object({file:c.z.string(),fileName:c.z.string(),contentType:c.z.string().optional(),folder:c.z.string().optional(),metadata:c.z.record(c.z.string(),c.z.any()).optional()});class k extends h.ChaiBaseAction{constructor(e){super();y(this,"bucketName","dam-assets");this.supabase=e}getValidationSchema(){return V}async execute(e){try{if(!this.context)return{error:"Context not set",status:400};const{appId:t}=this.context,{file:o,fileName:s,contentType:n,folder:i,metadata:u}=e;let a;if(typeof o=="string"){const w=o.split(",")[1]||o;a=Buffer.from(w,"base64")}else a=o;const d=i?`${i}/${s}`:`${t}/${s}`,{data:g,error:p}=await this.supabase.storage.from(this.bucketName).upload(d,a,{contentType:n||"application/octet-stream",upsert:!0,...u&&{metadata:u}});if(p)return{error:`Failed to upload to Supabase Storage: ${p.message}`,status:500};const{data:{publicUrl:m}}=this.supabase.storage.from(this.bucketName).getPublicUrl(d);return{data:{url:m,key:g.path,size:a.length,metadata:u},status:200}}catch(t){return console.error("UPLOAD_TO_STORAGE error:",t),{error:t instanceof Error?t.message:"Unknown error",status:500}}}}const W=l=>({GET_CHAI_USER:new M(l)}),H=l=>({UPLOAD_ASSET:new F(l),GET_ASSET:new v(l),GET_ASSETS:new q(l),DELETE_ASSET:new j(l),UPDATE_ASSET:new P(l),UPLOAD_TO_STORAGE:new k(l),DELETE_FROM_STORAGE:new x(l)});exports.DeleteFromStorageAction=x;exports.SupabaseAuthActions=W;exports.SupabaseStorageActions=H;exports.UploadToStorageAction=k;
|
|
@@ -264,7 +264,7 @@ export declare class UploadToStorageAction extends ChaiBaseAction<UploadToStorag
|
|
|
264
264
|
url: string;
|
|
265
265
|
key: string;
|
|
266
266
|
size: number;
|
|
267
|
-
metadata: Record<string, any
|
|
267
|
+
metadata: Record<string, any> | undefined;
|
|
268
268
|
};
|
|
269
269
|
status: number;
|
|
270
270
|
error?: undefined;
|
package/dist/supabase-actions.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
var D = Object.defineProperty;
|
|
2
2
|
var F = (l, r, e) => r in l ? D(l, r, { enumerable: !0, configurable: !0, writable: !0, value: e }) : l[r] = e;
|
|
3
3
|
var y = (l, r, e) => F(l, typeof r != "symbol" ? r + "" : r, e);
|
|
4
|
-
import { g as T, C as f } from "./actions-registery-
|
|
4
|
+
import { g as T, C as f } from "./actions-registery-y_ENc8zj.js";
|
|
5
5
|
import { isEmpty as $, kebabCase as k, set as b } from "lodash-es";
|
|
6
6
|
import w from "sharp";
|
|
7
7
|
import { z as c } from "zod";
|
|
@@ -1,15 +1,16 @@
|
|
|
1
1
|
import { jsx as a, jsxs as t } from "react/jsx-runtime";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
2
|
+
import { B as m } from "./register-chai-top-bar-ESJHs5s-.js";
|
|
3
|
+
import { Q as N, R as C, U as b, V as v, W as E, X as T } from "./index-rAcNbjk_.js";
|
|
4
|
+
import { ao as w, b as I, a as k, ap as y, B as R, E as d, P as u } from "./index-Dno42B0a.js";
|
|
5
|
+
import { AlertCircle as S, UserIcon as A, Check as P, X as U } from "lucide-react";
|
|
6
|
+
import { useState as _ } from "react";
|
|
7
|
+
import { useTranslation as q } from "react-i18next";
|
|
8
|
+
const V = () => {
|
|
9
|
+
const l = w(), { pageLockMeta: r } = I(), { setPageStatus: c } = k(), { savePageAsync: h } = N(), p = r == null ? void 0 : r.requestingUserId, { data: e, isFetching: f } = y(p || ""), i = f ? "Fetching user..." : (e == null ? void 0 : e.name) || "Current editor", [o, n] = _(!1), x = async () => {
|
|
10
|
+
n(!0), await h(), l(d.CONTINUE_EDITING_IN_THIS_CLIENT, r), c(u.CHECKING), setTimeout(() => n(!1), 2e3);
|
|
10
11
|
}, g = () => {
|
|
11
|
-
n(!0), l(
|
|
12
|
-
}, { t: s } =
|
|
12
|
+
n(!0), l(d.TAKE_OVER_REJECTED, r), c(u.EDITING), setTimeout(() => n(!1), 2e3);
|
|
13
|
+
}, { t: s } = q();
|
|
13
14
|
return /* @__PURE__ */ a(R, { children: /* @__PURE__ */ t(C, { className: "mx-auto w-full max-w-md", children: [
|
|
14
15
|
/* @__PURE__ */ a(b, { className: "space-y-1", children: /* @__PURE__ */ t(v, { className: "flex items-center gap-2 text-xl", children: [
|
|
15
16
|
/* @__PURE__ */ a(S, { className: "h-8 w-8 rounded-md bg-amber-500/20 p-1.5 text-amber-500" }),
|
|
@@ -26,7 +27,7 @@ const H = () => {
|
|
|
26
27
|
alt: e.name,
|
|
27
28
|
className: "h-12 w-12 flex-shrink-0 rounded-full bg-black p-3 text-white"
|
|
28
29
|
}
|
|
29
|
-
) : /* @__PURE__ */ a(
|
|
30
|
+
) : /* @__PURE__ */ a(A, { className: "h-12 w-12 flex-shrink-0 rounded-full bg-black p-3 text-white" }),
|
|
30
31
|
/* @__PURE__ */ t("div", { className: "flex-1 space-y-0", children: [
|
|
31
32
|
/* @__PURE__ */ a("div", { className: "truncate font-medium leading-tight text-black", children: i }),
|
|
32
33
|
(e == null ? void 0 : e.email) && /* @__PURE__ */ a("p", { className: "truncate text-sm leading-tight text-muted-foreground", children: e.email })
|
|
@@ -47,17 +48,17 @@ const H = () => {
|
|
|
47
48
|
] })
|
|
48
49
|
] }),
|
|
49
50
|
/* @__PURE__ */ t(T, { className: "flex gap-2", children: [
|
|
50
|
-
/* @__PURE__ */ t(
|
|
51
|
-
/* @__PURE__ */ a(
|
|
51
|
+
/* @__PURE__ */ t(m, { disabled: o, variant: "default", onClick: x, className: "flex-1 gap-2", children: [
|
|
52
|
+
/* @__PURE__ */ a(P, { className: "h-4 w-4" }),
|
|
52
53
|
s("Accept")
|
|
53
54
|
] }),
|
|
54
|
-
/* @__PURE__ */ t(
|
|
55
|
-
/* @__PURE__ */ a(
|
|
55
|
+
/* @__PURE__ */ t(m, { disabled: o, variant: "outline", onClick: g, className: "flex-1 gap-2", children: [
|
|
56
|
+
/* @__PURE__ */ a(U, { className: "h-4 w-4" }),
|
|
56
57
|
s("Reject")
|
|
57
58
|
] })
|
|
58
59
|
] })
|
|
59
60
|
] }) });
|
|
60
61
|
};
|
|
61
62
|
export {
|
|
62
|
-
|
|
63
|
+
V as default
|
|
63
64
|
};
|