@chaibuilder/sdk 4.0.0-beta.31 → 4.0.0-beta.33
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-gmj-yWTy.js → 2SSKDMRQ-BXAXoR9y.js} +5 -5
- package/dist/{2SSKDMRQ-BksFOLpD.cjs → 2SSKDMRQ-BqOsh3tf.cjs} +1 -1
- package/dist/{AP7HFJJL-kVgc0R61.js → AP7HFJJL-B78LfetW.js} +1 -1
- package/dist/{AP7HFJJL-CO-deD_p.cjs → AP7HFJJL-Cv6sqAAd.cjs} +1 -1
- package/dist/{IconPicker-D_GRfhwS.js → IconPicker-BlO5Pnyu.js} +1 -1
- package/dist/{IconPicker-BJHUCDn4.cjs → IconPicker-D4yq_b-k.cjs} +1 -1
- package/dist/{WDYDFRGG-C9_E3QW0.js → WDYDFRGG-BE7jgVqa.js} +4 -4
- package/dist/{WDYDFRGG-KPpWFul_.cjs → WDYDFRGG-Dz9d3cVW.cjs} +1 -1
- package/dist/{actions-registery-Bj-j1k5i.js → actions-registery-D3-4Yha7.js} +1108 -1061
- package/dist/{actions-registery-Cy1lqUVI.cjs → actions-registery-vPaY-3dZ.cjs} +25 -25
- package/dist/actions.cjs +1 -1
- package/dist/actions.js +2 -2
- package/dist/{active-in-another-tab-1GoKTVcF.js → active-in-another-tab-CA47uafJ.js} +2 -2
- package/dist/{active-in-another-tab-iEd5fZD0.cjs → active-in-another-tab-CNn_R-55.cjs} +1 -1
- package/dist/{add-new-language-page-B3GUvWdP.js → add-new-language-page-B-kPbhFd.js} +3 -3
- package/dist/{add-new-language-page-Cq8R42Ro.cjs → add-new-language-page-QAZbAFQe.cjs} +1 -1
- package/dist/{add-new-page-DiHnECAR.cjs → add-new-page-D4nbAHOp.cjs} +1 -1
- package/dist/add-new-page-Y0d9tHh0.js +31 -0
- package/dist/{ai-panel-content-BPpawv4D.cjs → ai-panel-content-DXbebC-m.cjs} +1 -1
- package/dist/{ai-panel-content-tExD3yhH.js → ai-panel-content-WMOeK5pF.js} +5 -5
- package/dist/{ai-panel-default-lang-DnYLHSaS.js → ai-panel-default-lang-CM_psX_h.js} +7 -7
- package/dist/{ai-panel-default-lang-C6N4wUUF.cjs → ai-panel-default-lang-hmfyAYPM.cjs} +2 -2
- package/dist/{ai-panel-other-lang-D1pCJluY.js → ai-panel-other-lang-BKANRJAb.js} +13 -13
- package/dist/{ai-panel-other-lang-C65lVVtZ.cjs → ai-panel-other-lang-D4GL1b-W.cjs} +1 -1
- package/dist/{ai-prompt-input-Dws5BHhQ.cjs → ai-prompt-input-Dwd0-pcD.cjs} +1 -1
- package/dist/{ai-prompt-input-B2q30bhR.js → ai-prompt-input-mxXtWptn.js} +13 -13
- package/dist/{ai-translation-prompt-DnwG2BmF.cjs → ai-translation-prompt-7M2aEZ1w.cjs} +1 -1
- package/dist/{ai-translation-prompt-Dnn6i_t3.js → ai-translation-prompt-C_Pb7BE4.js} +1 -1
- package/dist/{apply-binding-chfbBKi2.js → apply-binding-BYCW1k2l.js} +1 -1
- package/dist/{apply-binding-9XSrYzAE.cjs → apply-binding-xiigK7eK.cjs} +1 -1
- package/dist/{change-password-modal-LKtYY-8V.cjs → change-password-modal-BYZoefwT.cjs} +1 -1
- package/dist/{change-password-modal-C0MMizgl.js → change-password-modal-Dqf_mleR.js} +5 -5
- package/dist/{code-editor-CWOmKcUc.js → code-editor-1fSEocLK.js} +1 -1
- package/dist/{code-editor-Cim6jQVF.cjs → code-editor-uN7W7KMD.cjs} +1 -1
- package/dist/{continue-editing-in-this-client-oxYWGWON.js → continue-editing-in-this-client-DD7bBhjD.js} +2 -2
- package/dist/{continue-editing-in-this-client-Dd6nKIvX.cjs → continue-editing-in-this-client-DDM65ror.cjs} +1 -1
- package/dist/{core-BWQrViOY.cjs → core-czmLeR0h.cjs} +1 -1
- package/dist/{core-QlWEXm1d.js → core-nSRy3D7z.js} +16 -15
- package/dist/core.cjs +1 -1
- package/dist/core.d.ts +14 -2
- package/dist/core.js +19 -19
- package/dist/{css-import-modal-CXulmaB4.cjs → css-import-modal-BU7bJAaT.cjs} +1 -1
- package/dist/{css-import-modal-6bMTRlCg.js → css-import-modal-pBNRVmGj.js} +1 -1
- package/dist/default-theme-options-DN-3gIjM.cjs +22 -0
- package/dist/{plugin-BSjgGgwo.js → default-theme-options-saBIkWGT.js} +114 -114
- package/dist/{delete-page-D0tdn6VW.cjs → delete-page-8oEYsHPE.cjs} +1 -1
- package/dist/delete-page-B53nkF74.js +71 -0
- package/dist/{design-token-usage-D-hrcKz1.cjs → design-token-usage-Cm9m4AMz.cjs} +1 -1
- package/dist/{design-token-usage-lf7N_uOk.js → design-token-usage-DzWav2ip.js} +14 -14
- package/dist/{digital-asset-manager-DJhRhLGC.js → digital-asset-manager-1yLYGPuf.js} +5 -5
- package/dist/digital-asset-manager-BaTvMY8Q.cjs +1 -0
- package/dist/{duplicate-page-ChSp1TYN.cjs → duplicate-page-C2DZI4U0.cjs} +1 -1
- package/dist/{duplicate-page-CXzYy7vx.js → duplicate-page-DCRVR-kF.js} +6 -6
- package/dist/{dynamic-page-selector-btGtkyyv.cjs → dynamic-page-selector-CZJQnc-Q.cjs} +1 -1
- package/dist/{dynamic-page-selector-r5IR9_7k.js → dynamic-page-selector-DCGWkLVV.js} +12 -12
- package/dist/get-chai-builder-theme-C_qofMh_.cjs +1 -0
- package/dist/{get-chai-builder-theme-BpuwSLeS.js → get-chai-builder-theme-CyOkIlte.js} +1 -1
- package/dist/{image-compression-DsZ1oqpb.js → image-compression-DPFITwOL.js} +2 -2
- package/dist/image-compression-UaU7Bwqe.cjs +1 -0
- package/dist/{image-editor-CilPMtAC.js → image-editor-C0EYZJY_.js} +1 -1
- package/dist/{image-editor-BdW476J8.cjs → image-editor-DkgZrSGr.cjs} +1 -1
- package/dist/{index-DtMksfXx.js → index-BDrc0HJQ.js} +1729 -1680
- package/dist/index-BuXfCtgR.cjs +5 -0
- package/dist/{index-DsQXiNA_.js → index-C7bidKtE.js} +2786 -2752
- package/dist/index-DKjYF53r.cjs +160 -0
- package/dist/{json-diff-viewer-BkrnLb3B.cjs → json-diff-viewer-88jEhq8D.cjs} +1 -1
- package/dist/{json-diff-viewer-D3N3w3Ax.js → json-diff-viewer-wmzIZcuQ.js} +34 -34
- package/dist/{lang-panel-BAaaP4Qc.js → lang-panel--kWBnU_W.js} +7 -7
- package/dist/{lang-panel-BjDRrpwN.cjs → lang-panel-I_ABfjOZ.cjs} +1 -1
- package/dist/manage-design-tokens-CslCEOXU.cjs +1 -0
- package/dist/manage-design-tokens-JdVKj09s.js +445 -0
- package/dist/manage-design-tokens-modal-DA15ou0u.cjs +1 -0
- package/dist/{manage-design-tokens-modal-9qpcb-EC.js → manage-design-tokens-modal-xKxC72Bc.js} +9 -9
- package/dist/{mark-as-template-DNHYNjI9.js → mark-as-template-AbZrkEYl.js} +7 -7
- package/dist/{mark-as-template-IYRjta97.cjs → mark-as-template-ClQjC2p2.cjs} +1 -1
- package/dist/{nested-path-selector-content-Be-pbnVl.js → nested-path-selector-content-B04k-PPB.js} +1 -1
- package/dist/{nested-path-selector-content-CWmPgU-L.cjs → nested-path-selector-content-dFwZaM1r.cjs} +1 -1
- package/dist/{no-language-page-content-C-ltY7bj.js → no-language-page-content-CbUqxuC4.js} +2 -2
- package/dist/{no-language-page-content-8_J6y-cm.cjs → no-language-page-content-pzkWJAg6.cjs} +1 -1
- package/dist/{no-language-page-dialog-D5NXpDHi.js → no-language-page-dialog-AavD_Mmc.js} +2 -2
- package/dist/{no-language-page-dialog-BOZZZzqx.cjs → no-language-page-dialog-DhlOVXUm.cjs} +1 -1
- package/dist/{page-creator-BuHHnqiQ.js → page-creator-2OZveMsR.js} +95 -95
- package/dist/{page-creator-wtbae2U7.cjs → page-creator-DMjnStPf.cjs} +1 -1
- package/dist/{page-lock-pPGlTxj7.js → page-lock-5MwwTWe8.js} +2 -2
- package/dist/{page-lock-DN4iJc-V.cjs → page-lock-B3CpoFTs.cjs} +1 -1
- package/dist/{page-locked-dialog-Bl-ojgIW.js → page-locked-dialog-BhNZC9wZ.js} +13 -13
- package/dist/{page-locked-dialog-B_vdgv24.cjs → page-locked-dialog-ZOvjnxRI.cjs} +1 -1
- package/dist/page-manager-new-BcI-1Dms.cjs +1 -0
- package/dist/{page-manager-new-Bg8H6yrg.js → page-manager-new-l68-Lc9h.js} +85 -88
- package/dist/{page-manager-search-and-filter-CDXunXNd.cjs → page-manager-search-and-filter-BOpne6v-.cjs} +1 -1
- package/dist/{page-manager-search-and-filter-CyfO7O96.js → page-manager-search-and-filter-DJn98D02.js} +31 -30
- package/dist/{page-revisions-content-BKT8S9_g.cjs → page-revisions-content-B00tDCzu.cjs} +1 -1
- package/dist/{page-revisions-content-B-egQgoZ.js → page-revisions-content-Bqp-9bae.js} +23 -23
- package/dist/pages.cjs +1 -1
- package/dist/pages.d.ts +14 -2
- package/dist/pages.js +12 -12
- package/dist/{publish-pages-content-D2B_ScCQ.js → publish-pages-content-CtZLSG6O.js} +68 -75
- package/dist/publish-pages-content-DfYG0biw.cjs +1 -0
- package/dist/render.cjs +1 -1
- package/dist/render.js +5 -5
- package/dist/{rte-widget-modal-c3T09VeO.js → rte-widget-modal-DGEWoQ1b.js} +1 -1
- package/dist/{rte-widget-modal-CC1KcrAT.cjs → rte-widget-modal-DX66uSPv.cjs} +1 -1
- package/dist/runtime.cjs +6 -6
- package/dist/runtime.d.ts +2 -0
- package/dist/runtime.js +36 -35
- package/dist/{save-to-lib-dT1NDd5w.js → save-to-lib-CCxX5ZmQ.js} +26 -26
- package/dist/{save-to-lib-CiM0wiIr.cjs → save-to-lib-DmAjdhzU.cjs} +1 -1
- package/dist/sdk.css +1 -1
- package/dist/{selected-block-display-BgqcPsXI.cjs → selected-block-display-Csce27bR.cjs} +1 -1
- package/dist/{selected-block-display-BQndDPcY.js → selected-block-display-Cv6jBhJD.js} +20 -20
- package/dist/{seo-panel-DXZvGYEM.cjs → seo-panel-BZYXeYzE.cjs} +1 -1
- package/dist/{seo-panel-Z93Zf_bz.js → seo-panel-Ctstjs-d.js} +25 -25
- package/dist/{shared-json-ld-DwvUDGAS.cjs → shared-json-ld-BDWtjHgw.cjs} +1 -1
- package/dist/{shared-json-ld-Ct68RlWD.js → shared-json-ld-BNHGmUBd.js} +45 -45
- package/dist/{slug-input-CAqkFZBq.js → slug-input-Bui1Qmvh.js} +1 -1
- package/dist/{slug-input-Curnt2n3.cjs → slug-input-IAl_jfHr.cjs} +1 -1
- package/dist/supabase-actions.cjs +1 -1
- package/dist/supabase-actions.js +272 -206
- package/dist/{take-over-request-D6y2HcDr.cjs → take-over-request-Bl6jS1cK.cjs} +1 -1
- package/dist/{take-over-request-C6ngP1QR.js → take-over-request-Ceuqyk5K.js} +13 -13
- package/dist/{translation-warning-modal-B876S5yp.cjs → translation-warning-modal-CCmmwz1C.cjs} +1 -1
- package/dist/{translation-warning-modal-kRcfrPgo.js → translation-warning-modal-DA5dt2FA.js} +9 -9
- package/dist/types.d.ts +14 -2
- package/dist/{unmark-as-template-DeeWUTco.js → unmark-as-template-CKVMibvu.js} +13 -13
- package/dist/{unmark-as-template-f1dl_YTz.cjs → unmark-as-template-OEUqo0uc.cjs} +1 -1
- package/dist/unpublish-page-A5qn6E6g.js +28 -0
- package/dist/{unpublish-page-DEPFjGuu.cjs → unpublish-page-C81bYHLI.cjs} +1 -1
- package/dist/{unpublished-partials-modal-Ts5ZhAK9.js → unpublished-partials-modal-FqzTp5el.js} +3 -3
- package/dist/{unpublished-partials-modal-CEFXp1D1.cjs → unpublished-partials-modal-af5uDL7Y.cjs} +1 -1
- package/dist/utils.cjs +1 -1
- package/dist/utils.js +1 -1
- package/dist/web-blocks.cjs +1 -1
- package/dist/web-blocks.js +1 -1
- package/dist/{web-preview-CoT8r96b.js → web-preview-vge6uUSa.js} +1 -1
- package/dist/{web-preview-DTDoIE-c.cjs → web-preview-xtKkQOXy.cjs} +1 -1
- package/package.json +2 -7
- package/dist/add-new-page-C5HlQfzy.js +0 -31
- package/dist/delete-page-LnzR01A8.js +0 -71
- package/dist/digital-asset-manager-eCJHNSjj.cjs +0 -1
- package/dist/get-chai-builder-theme-B5RkBTsB.cjs +0 -1
- package/dist/image-compression-DZ9WMmyn.cjs +0 -1
- package/dist/index-CAhDwfHE.cjs +0 -5
- package/dist/index-mPCp0j2h.cjs +0 -160
- package/dist/manage-design-tokens-BknGNAKE.cjs +0 -1
- package/dist/manage-design-tokens-Co5677WS.js +0 -428
- package/dist/manage-design-tokens-modal-BcgdwEXE.cjs +0 -1
- package/dist/page-manager-new-5W5M9_ue.cjs +0 -1
- package/dist/plugin-DHpuZZXz.cjs +0 -22
- package/dist/publish-pages-content-WJHTVYnx.cjs +0 -1
- package/dist/theme-panel-footer-CGZL2F7R.js +0 -26
- package/dist/theme-panel-footer-IgGj-_OA.cjs +0 -1
- package/dist/unpublish-page-U_79Pwc0.js +0 -28
package/dist/supabase-actions.js
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var
|
|
4
|
-
import { g as
|
|
5
|
-
import { isEmpty as
|
|
6
|
-
import
|
|
7
|
-
|
|
8
|
-
|
|
1
|
+
var k = Object.defineProperty;
|
|
2
|
+
var P = (u, t, e) => t in u ? k(u, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : u[t] = e;
|
|
3
|
+
var w = (u, t, e) => P(u, typeof t != "symbol" ? t + "" : t, e);
|
|
4
|
+
import { g as y, C as E, A as _ } from "./actions-registery-D3-4Yha7.js";
|
|
5
|
+
import { isEmpty as f, kebabCase as x, set as I } from "lodash-es";
|
|
6
|
+
import { z as o } from "zod";
|
|
7
|
+
const h = class h {
|
|
8
|
+
// SOF marker (2) + segment length (2) + precision (1) + height (2) + width (2) = 9 bytes from marker
|
|
9
9
|
constructor(t, e, r) {
|
|
10
10
|
this.appId = t, this.userId = e, this.supabase = r;
|
|
11
11
|
}
|
|
12
12
|
appendUpdatedAtToUrl(t, e) {
|
|
13
|
-
if (
|
|
13
|
+
if (f(t))
|
|
14
14
|
return "";
|
|
15
|
-
const r = new URL(t),
|
|
16
|
-
return r.searchParams.set("t",
|
|
15
|
+
const r = new URL(t), a = new Date(e).getTime();
|
|
16
|
+
return r.searchParams.set("t", a.toString()), `${r.origin}${r.pathname}${r.search}${r.hash}`;
|
|
17
17
|
}
|
|
18
18
|
getBufferFromBase64(t) {
|
|
19
19
|
try {
|
|
@@ -23,48 +23,106 @@ class A {
|
|
|
23
23
|
throw new Error("Invalid base64 string format");
|
|
24
24
|
}
|
|
25
25
|
}
|
|
26
|
+
getMimeType(t) {
|
|
27
|
+
var a;
|
|
28
|
+
const e = ((a = t.split(".").pop()) == null ? void 0 : a.toLowerCase()) || "";
|
|
29
|
+
return {
|
|
30
|
+
jpg: "image/jpeg",
|
|
31
|
+
jpeg: "image/jpeg",
|
|
32
|
+
png: "image/png",
|
|
33
|
+
webp: "image/webp",
|
|
34
|
+
gif: "image/gif",
|
|
35
|
+
tiff: "image/tiff",
|
|
36
|
+
svg: "image/svg+xml"
|
|
37
|
+
}[e] || "application/octet-stream";
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Extract image dimensions from buffer by reading binary headers.
|
|
41
|
+
* Supports PNG, JPEG, GIF, and WebP without external dependencies.
|
|
42
|
+
*/
|
|
43
|
+
getImageDimensions(t) {
|
|
44
|
+
if (t.length >= h.MIN_PNG_LENGTH && t[0] === 137 && t[1] === 80 && t[2] === 78 && t[3] === 71)
|
|
45
|
+
return {
|
|
46
|
+
width: t.readUInt32BE(16),
|
|
47
|
+
height: t.readUInt32BE(20)
|
|
48
|
+
};
|
|
49
|
+
if (t.length >= h.MIN_GIF_LENGTH && t[0] === 71 && t[1] === 73 && t[2] === 70)
|
|
50
|
+
return {
|
|
51
|
+
width: t.readUInt16LE(6),
|
|
52
|
+
height: t.readUInt16LE(8)
|
|
53
|
+
};
|
|
54
|
+
if (t.length >= 12 && t[0] === 82 && t[1] === 73 && t[2] === 70 && t[3] === 70 && t[8] === 87 && t[9] === 69 && t[10] === 66 && t[11] === 80) {
|
|
55
|
+
if (t.length >= h.MIN_WEBP_VP8L_LENGTH && t[12] === 86 && t[13] === 80 && t[14] === 56 && t[15] === 76) {
|
|
56
|
+
const e = t.readUInt32LE(21);
|
|
57
|
+
return {
|
|
58
|
+
width: (e & 16383) + 1,
|
|
59
|
+
height: (e >> 14 & 16383) + 1
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
if (t.length >= h.MIN_WEBP_VP8X_LENGTH && t[12] === 86 && t[13] === 80 && t[14] === 56 && t[15] === 88)
|
|
63
|
+
return {
|
|
64
|
+
width: 1 + (t[24] | t[25] << 8 | t[26] << 16),
|
|
65
|
+
height: 1 + (t[27] | t[28] << 8 | t[29] << 16)
|
|
66
|
+
};
|
|
67
|
+
if (t.length >= h.MIN_WEBP_VP8_LENGTH && t[12] === 86 && t[13] === 80 && t[14] === 56 && t[15] === 32)
|
|
68
|
+
return {
|
|
69
|
+
width: t.readUInt16LE(26) & 16383,
|
|
70
|
+
height: t.readUInt16LE(28) & 16383
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
if (t.length >= 2 && t[0] === 255 && t[1] === 216) {
|
|
74
|
+
let e = 2;
|
|
75
|
+
for (; e < t.length - 1; ) {
|
|
76
|
+
if (t[e] !== 255) {
|
|
77
|
+
e++;
|
|
78
|
+
continue;
|
|
79
|
+
}
|
|
80
|
+
const r = t[e + 1];
|
|
81
|
+
if (r >= 192 && r <= 195 || r >= 197 && r <= 199 || r >= 201 && r <= 203 || r >= 205 && r <= 207) {
|
|
82
|
+
if (e + h.MIN_JPEG_SOF_BYTES_FROM_MARKER <= t.length)
|
|
83
|
+
return {
|
|
84
|
+
width: t.readUInt16BE(e + 7),
|
|
85
|
+
height: t.readUInt16BE(e + 5)
|
|
86
|
+
};
|
|
87
|
+
break;
|
|
88
|
+
}
|
|
89
|
+
if (e + 4 > t.length)
|
|
90
|
+
break;
|
|
91
|
+
const a = t.readUInt16BE(e + 2);
|
|
92
|
+
e += 2 + a;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
return { width: 0, height: 0 };
|
|
96
|
+
}
|
|
26
97
|
/**
|
|
27
98
|
* Upload an image file using UPLOAD_TO_STORAGE action
|
|
28
|
-
*
|
|
99
|
+
* Uploads the image as-is without server-side processing for cross-platform compatibility
|
|
29
100
|
*/
|
|
30
|
-
async uploadImageFile(t, e, r,
|
|
101
|
+
async uploadImageFile(t, e, r, a) {
|
|
31
102
|
try {
|
|
32
|
-
const s = this.getBufferFromBase64(t),
|
|
33
|
-
if (!
|
|
34
|
-
throw new Error(`Invalid image format: ${
|
|
35
|
-
const d =
|
|
36
|
-
|
|
37
|
-
if (o && d.length > 120 * 1024) {
|
|
38
|
-
const O = Math.floor(90 * (122880 / d.length));
|
|
39
|
-
a = await f(s).webp({ quality: O }).resize({ width: Math.min(n.width || 2e3, 2e3) }).toBuffer();
|
|
40
|
-
}
|
|
41
|
-
const l = await f(a).metadata(), m = await f(s).webp({ quality: 70 }).resize({ width: 300 }).toBuffer(), p = r.split("."), h = p.length > 1 ? p.slice(0, -1).join(".") : r, w = `${_(h)}.webp`, D = `${w}_thumbnail.webp`, I = this.appId, x = e ? `${I}/${e}` : I, U = T("UPLOAD_TO_STORAGE");
|
|
42
|
-
if (!U)
|
|
103
|
+
const s = this.getBufferFromBase64(t), i = this.getMimeType(r);
|
|
104
|
+
if (!["image/jpeg", "image/png", "image/webp", "image/gif", "image/tiff"].includes(i))
|
|
105
|
+
throw new Error(`Invalid image format: ${i}`);
|
|
106
|
+
const d = r.split("."), n = d.length > 1 ? d.slice(0, -1).join(".") : r, l = d.length > 1 ? d[d.length - 1].toLowerCase() : "png", g = `${x(n)}.${l}`, p = this.appId, m = e ? `${p}/${e}` : p, A = y("UPLOAD_TO_STORAGE");
|
|
107
|
+
if (!A)
|
|
43
108
|
throw new Error("UPLOAD_TO_STORAGE action not found");
|
|
44
|
-
|
|
45
|
-
const
|
|
46
|
-
file:
|
|
47
|
-
fileName:
|
|
48
|
-
contentType:
|
|
49
|
-
folder:
|
|
50
|
-
});
|
|
51
|
-
if (S.error)
|
|
52
|
-
throw new Error(S.error);
|
|
53
|
-
const E = await U.execute({
|
|
54
|
-
file: m.toString("base64"),
|
|
55
|
-
fileName: D,
|
|
56
|
-
contentType: "image/webp",
|
|
57
|
-
folder: x
|
|
109
|
+
A.setContext({ appId: this.appId, userId: this.userId });
|
|
110
|
+
const U = await A.execute({
|
|
111
|
+
file: s.toString("base64"),
|
|
112
|
+
fileName: g,
|
|
113
|
+
contentType: i,
|
|
114
|
+
folder: m
|
|
58
115
|
});
|
|
59
|
-
if (
|
|
60
|
-
throw new Error(
|
|
116
|
+
if (U.error)
|
|
117
|
+
throw new Error(U.error);
|
|
118
|
+
const { width: T, height: b } = this.getImageDimensions(s);
|
|
61
119
|
return {
|
|
62
|
-
url:
|
|
63
|
-
thumbnailUrl:
|
|
64
|
-
size:
|
|
65
|
-
width:
|
|
66
|
-
height:
|
|
67
|
-
mimeType:
|
|
120
|
+
url: U.data.url,
|
|
121
|
+
thumbnailUrl: U.data.url,
|
|
122
|
+
size: s.length,
|
|
123
|
+
width: T,
|
|
124
|
+
height: b,
|
|
125
|
+
mimeType: i
|
|
68
126
|
};
|
|
69
127
|
} catch (s) {
|
|
70
128
|
return console.error("Upload image error:", s), { error: s instanceof Error ? s.message : "Unknown error" };
|
|
@@ -75,46 +133,46 @@ class A {
|
|
|
75
133
|
*/
|
|
76
134
|
async uploadSvgFile(t, e, r) {
|
|
77
135
|
try {
|
|
78
|
-
const
|
|
79
|
-
let s,
|
|
136
|
+
const a = this.getBufferFromBase64(t);
|
|
137
|
+
let s, i;
|
|
80
138
|
try {
|
|
81
|
-
const
|
|
82
|
-
s =
|
|
139
|
+
const A = a.toString("utf-8"), U = A.match(/\bwidth=["'](\d+)/), T = A.match(/\bheight=["'](\d+)/);
|
|
140
|
+
U && (s = parseInt(U[1], 10)), T && (i = parseInt(T[1], 10));
|
|
83
141
|
} catch {
|
|
84
142
|
}
|
|
85
|
-
const c = r.split("."), d = c.length > 1 ? c.slice(0, -1).join(".") : r,
|
|
143
|
+
const c = r.split("."), d = c.length > 1 ? c.slice(0, -1).join(".") : r, n = `${x(d)}.svg`, l = this.appId, g = e ? `${l}/${e}` : l, p = y("UPLOAD_TO_STORAGE");
|
|
86
144
|
if (!p)
|
|
87
145
|
throw new Error("UPLOAD_TO_STORAGE action not found");
|
|
88
146
|
p.setContext({ appId: this.appId, userId: this.userId });
|
|
89
|
-
const
|
|
90
|
-
file:
|
|
91
|
-
fileName:
|
|
147
|
+
const m = await p.execute({
|
|
148
|
+
file: a.toString("base64"),
|
|
149
|
+
fileName: n,
|
|
92
150
|
contentType: "image/svg+xml",
|
|
93
|
-
folder:
|
|
151
|
+
folder: g
|
|
94
152
|
});
|
|
95
|
-
if (
|
|
96
|
-
throw new Error(
|
|
153
|
+
if (m.error)
|
|
154
|
+
throw new Error(m.error);
|
|
97
155
|
return {
|
|
98
|
-
url:
|
|
99
|
-
thumbnailUrl:
|
|
100
|
-
size:
|
|
156
|
+
url: m.data.url,
|
|
157
|
+
thumbnailUrl: m.data.url,
|
|
158
|
+
size: a.length,
|
|
101
159
|
width: s,
|
|
102
|
-
height:
|
|
160
|
+
height: i,
|
|
103
161
|
mimeType: "image/svg+xml"
|
|
104
162
|
};
|
|
105
|
-
} catch (
|
|
106
|
-
return console.error("SVG upload error:",
|
|
163
|
+
} catch (a) {
|
|
164
|
+
return console.error("SVG upload error:", a), { error: a instanceof Error ? a.message : "Unknown error" };
|
|
107
165
|
}
|
|
108
166
|
}
|
|
109
167
|
async upload({
|
|
110
168
|
file: t,
|
|
111
169
|
folderId: e,
|
|
112
170
|
name: r,
|
|
113
|
-
optimize:
|
|
171
|
+
optimize: a = !0
|
|
114
172
|
}) {
|
|
115
173
|
var s;
|
|
116
174
|
try {
|
|
117
|
-
const c = r.toLowerCase().endsWith(".svg") || t.includes("data:image/svg+xml") ? await this.uploadSvgFile(t, e, r) : await this.uploadImageFile(t, e, r,
|
|
175
|
+
const c = r.toLowerCase().endsWith(".svg") || t.includes("data:image/svg+xml") ? await this.uploadSvgFile(t, e, r) : await this.uploadImageFile(t, e, r, a ?? !0);
|
|
118
176
|
if ("error" in c)
|
|
119
177
|
return c;
|
|
120
178
|
const d = {
|
|
@@ -130,26 +188,26 @@ class A {
|
|
|
130
188
|
type: c.mimeType.startsWith("image/") ? "image" : "file",
|
|
131
189
|
createdBy: this.userId,
|
|
132
190
|
updatedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
133
|
-
}, { data:
|
|
191
|
+
}, { data: n, error: l } = await this.supabase.from("app_assets").insert(d).select("*").single();
|
|
134
192
|
if (l)
|
|
135
193
|
throw new Error(`Failed to store asset in database: ${l.message}`);
|
|
136
194
|
return {
|
|
137
|
-
id:
|
|
138
|
-
name:
|
|
139
|
-
type:
|
|
140
|
-
url: this.appendUpdatedAtToUrl(
|
|
141
|
-
size:
|
|
142
|
-
thumbnailUrl: this.appendUpdatedAtToUrl(
|
|
143
|
-
width:
|
|
144
|
-
height:
|
|
145
|
-
format:
|
|
146
|
-
folderId:
|
|
147
|
-
createdBy:
|
|
148
|
-
createdAt:
|
|
149
|
-
updatedAt:
|
|
195
|
+
id: n.id,
|
|
196
|
+
name: n.name,
|
|
197
|
+
type: n.type,
|
|
198
|
+
url: this.appendUpdatedAtToUrl(n.url, n.updatedAt),
|
|
199
|
+
size: n.size,
|
|
200
|
+
thumbnailUrl: this.appendUpdatedAtToUrl(n.thumbnailUrl || "", n.updatedAt),
|
|
201
|
+
width: n.width,
|
|
202
|
+
height: n.height,
|
|
203
|
+
format: n.format,
|
|
204
|
+
folderId: n.folderId,
|
|
205
|
+
createdBy: n.createdBy || "",
|
|
206
|
+
createdAt: n.createdAt,
|
|
207
|
+
updatedAt: n.updatedAt
|
|
150
208
|
};
|
|
151
|
-
} catch (
|
|
152
|
-
return { error:
|
|
209
|
+
} catch (i) {
|
|
210
|
+
return { error: i instanceof Error ? i.message : "Unknown error occurred" };
|
|
153
211
|
}
|
|
154
212
|
}
|
|
155
213
|
async getAsset({ id: t }) {
|
|
@@ -157,7 +215,7 @@ class A {
|
|
|
157
215
|
const { data: e, error: r } = await this.supabase.from("app_assets").select("*").eq("id", t).eq("app", this.appId).single();
|
|
158
216
|
if (r)
|
|
159
217
|
throw new Error(`Failed to fetch asset: ${r.message}`);
|
|
160
|
-
return
|
|
218
|
+
return I(e, "url", this.appendUpdatedAtToUrl(e.url, e.updatedAt)), I(e, "thumbnailUrl", this.appendUpdatedAtToUrl(e.thumbnailUrl || "", e.updatedAt)), e;
|
|
161
219
|
} catch (e) {
|
|
162
220
|
return { error: e instanceof Error ? e.message : "Unknown error occurred" };
|
|
163
221
|
}
|
|
@@ -168,20 +226,20 @@ class A {
|
|
|
168
226
|
limit: r = 20
|
|
169
227
|
} = {}) {
|
|
170
228
|
try {
|
|
171
|
-
const
|
|
229
|
+
const a = (e - 1) * r;
|
|
172
230
|
let s = this.supabase.from("app_assets").select("*", { count: "exact" }).eq("app", this.appId).order("updatedAt", { ascending: !1 });
|
|
173
231
|
t && (s = s.or(`name.ilike.%${t}%,description.ilike.%${t}%`));
|
|
174
|
-
const { data:
|
|
232
|
+
const { data: i, error: c, count: d } = await s.range(a, a + r - 1);
|
|
175
233
|
if (c)
|
|
176
234
|
throw new Error(c.message);
|
|
177
235
|
return {
|
|
178
|
-
assets:
|
|
236
|
+
assets: i.map((l) => (I(l, "url", this.appendUpdatedAtToUrl(l.url, l.updatedAt)), I(l, "thsupabaseumbnailUrl", this.appendUpdatedAtToUrl(l.thumbnailUrl || "", l.updatedAt)), l)),
|
|
179
237
|
total: d || 0,
|
|
180
238
|
page: e,
|
|
181
239
|
pageSize: r
|
|
182
240
|
};
|
|
183
|
-
} catch (
|
|
184
|
-
throw console.error("Error fetching assets:",
|
|
241
|
+
} catch (a) {
|
|
242
|
+
throw console.error("Error fetching assets:", a), a;
|
|
185
243
|
}
|
|
186
244
|
}
|
|
187
245
|
async deleteAsset({ id: t }) {
|
|
@@ -191,23 +249,23 @@ class A {
|
|
|
191
249
|
throw new Error(`Failed to fetch asset: ${r.message}`);
|
|
192
250
|
if (e.url)
|
|
193
251
|
try {
|
|
194
|
-
const
|
|
252
|
+
const i = new URL(e.url).pathname.split("/"), c = i.indexOf("dam-assets");
|
|
195
253
|
if (c !== -1) {
|
|
196
|
-
const d =
|
|
197
|
-
if (
|
|
198
|
-
const
|
|
254
|
+
const d = i.slice(c + 1).join("/"), n = y("DELETE_FROM_STORAGE");
|
|
255
|
+
if (n && (n.setContext({ appId: this.appId, userId: this.userId }), await n.execute({ key: d })), e.thumbnailUrl && e.thumbnailUrl !== e.url) {
|
|
256
|
+
const g = new URL(e.thumbnailUrl).pathname.split("/"), p = g.indexOf("dam-assets");
|
|
199
257
|
if (p !== -1) {
|
|
200
|
-
const
|
|
201
|
-
|
|
258
|
+
const m = g.slice(p + 1).join("/");
|
|
259
|
+
n && await n.execute({ key: m });
|
|
202
260
|
}
|
|
203
261
|
}
|
|
204
262
|
}
|
|
205
263
|
} catch (s) {
|
|
206
264
|
console.warn("Failed to delete from storage, continuing with database deletion:", s);
|
|
207
265
|
}
|
|
208
|
-
const { error:
|
|
209
|
-
if (
|
|
210
|
-
throw new Error(`Failed to delete asset: ${
|
|
266
|
+
const { error: a } = await this.supabase.from("app_assets").delete().eq("id", t);
|
|
267
|
+
if (a)
|
|
268
|
+
throw new Error(`Failed to delete asset: ${a.message}`);
|
|
211
269
|
return { success: !0 };
|
|
212
270
|
} catch (e) {
|
|
213
271
|
return { error: e instanceof Error ? e.message : "Unknown error occurred" };
|
|
@@ -218,43 +276,51 @@ class A {
|
|
|
218
276
|
file: e,
|
|
219
277
|
description: r
|
|
220
278
|
}) {
|
|
221
|
-
var
|
|
279
|
+
var a, s;
|
|
222
280
|
try {
|
|
223
|
-
const { data:
|
|
281
|
+
const { data: i, error: c } = await this.supabase.from("app_assets").select("*").eq("id", t).single();
|
|
224
282
|
if (c)
|
|
225
283
|
throw new Error(`Failed to fetch asset: ${c.message}`);
|
|
226
284
|
const d = {};
|
|
227
285
|
if (r !== void 0 && (d.description = r, d.updatedAt = (/* @__PURE__ */ new Date()).toISOString()), e) {
|
|
228
|
-
const p = ((
|
|
286
|
+
const p = ((a = i.format) == null ? void 0 : a.toLowerCase()) === "svg" || e.includes("data:image/svg+xml") ? await this.uploadSvgFile(e, i.folderId, i.name) : await this.uploadImageFile(e, i.folderId, i.name, !0);
|
|
229
287
|
if ("error" in p)
|
|
230
288
|
return p;
|
|
231
289
|
d.url = p.url, d.thumbnailUrl = p.thumbnailUrl, d.size = (s = p.size) == null ? void 0 : s.toString(), d.width = p.width, d.height = p.height, d.format = p.mimeType.split("/")[1], d.updatedAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
232
290
|
}
|
|
233
|
-
const { data:
|
|
291
|
+
const { data: n, error: l } = await this.supabase.from("app_assets").update(d).eq("id", t).select().single();
|
|
234
292
|
if (l)
|
|
235
293
|
throw new Error(`Failed to update asset: ${l.message}`);
|
|
236
|
-
return
|
|
237
|
-
|
|
294
|
+
return I(n, "url", this.appendUpdatedAtToUrl(n.url, n.updatedAt)), I(
|
|
295
|
+
n,
|
|
238
296
|
"thumbnailUrl",
|
|
239
|
-
this.appendUpdatedAtToUrl(
|
|
240
|
-
),
|
|
241
|
-
} catch (
|
|
242
|
-
return { error:
|
|
297
|
+
this.appendUpdatedAtToUrl(n.thumbnailUrl || "", n.updatedAt)
|
|
298
|
+
), n;
|
|
299
|
+
} catch (i) {
|
|
300
|
+
return { error: i instanceof Error ? i.message : "Unknown error occurred" };
|
|
243
301
|
}
|
|
244
302
|
}
|
|
245
|
-
}
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
303
|
+
};
|
|
304
|
+
// Minimum buffer length checks per image format for dimension extraction
|
|
305
|
+
w(h, "MIN_PNG_LENGTH", 24), // PNG signature (8) + IHDR chunk header (8) + width (4) + height (4)
|
|
306
|
+
w(h, "MIN_GIF_LENGTH", 10), // GIF signature (6) + width (2) + height (2)
|
|
307
|
+
w(h, "MIN_WEBP_VP8L_LENGTH", 25), // Reads 4 bytes at offset 21: RIFF (12) + VP8L header (4) + flag (1) + 4 bytes read = 21 + 4
|
|
308
|
+
w(h, "MIN_WEBP_VP8X_LENGTH", 30), // Reads 6 bytes at offset 24: RIFF (12) + VP8X header (4) + flags (4) + width/height (3+3) = 24 + 6
|
|
309
|
+
w(h, "MIN_WEBP_VP8_LENGTH", 30), // Reads 4 bytes at offset 26: RIFF (12) + VP8 header (4) + frame tag (3) + start (3) + 4 bytes read = 26 + 4
|
|
310
|
+
w(h, "MIN_JPEG_SOF_BYTES_FROM_MARKER", 9);
|
|
311
|
+
let S = h;
|
|
312
|
+
const O = o.object({
|
|
313
|
+
name: o.string(),
|
|
314
|
+
file: o.string(),
|
|
315
|
+
folderId: o.string().optional().nullable(),
|
|
316
|
+
optimize: o.boolean().optional()
|
|
251
317
|
});
|
|
252
|
-
class
|
|
318
|
+
class D extends E {
|
|
253
319
|
constructor(t) {
|
|
254
320
|
super(), this.supabase = t;
|
|
255
321
|
}
|
|
256
322
|
getValidationSchema() {
|
|
257
|
-
return
|
|
323
|
+
return O;
|
|
258
324
|
}
|
|
259
325
|
async execute(t) {
|
|
260
326
|
try {
|
|
@@ -263,22 +329,22 @@ class v extends g {
|
|
|
263
329
|
const { appId: e, userId: r } = this.context;
|
|
264
330
|
if (!r)
|
|
265
331
|
return { error: "User ID is required", status: 401 };
|
|
266
|
-
const s = await new
|
|
332
|
+
const s = await new S(e, r, this.supabase).upload(t);
|
|
267
333
|
return "error" in s ? { error: s.error, status: 400 } : s;
|
|
268
334
|
} catch (e) {
|
|
269
335
|
return console.error("UPLOAD_ASSET error:", e), { error: e instanceof Error ? e.message : "Unknown error", status: 500 };
|
|
270
336
|
}
|
|
271
337
|
}
|
|
272
338
|
}
|
|
273
|
-
const
|
|
274
|
-
id:
|
|
339
|
+
const L = o.object({
|
|
340
|
+
id: o.string()
|
|
275
341
|
});
|
|
276
|
-
class
|
|
342
|
+
class G extends E {
|
|
277
343
|
constructor(t) {
|
|
278
344
|
super(), this.supabase = t;
|
|
279
345
|
}
|
|
280
346
|
getValidationSchema() {
|
|
281
|
-
return
|
|
347
|
+
return L;
|
|
282
348
|
}
|
|
283
349
|
async execute(t) {
|
|
284
350
|
try {
|
|
@@ -287,24 +353,24 @@ class L extends g {
|
|
|
287
353
|
const { appId: e, userId: r } = this.context;
|
|
288
354
|
if (!r)
|
|
289
355
|
return { error: "User ID is required", status: 401 };
|
|
290
|
-
const s = await new
|
|
356
|
+
const s = await new S(e, r, this.supabase).getAsset(t);
|
|
291
357
|
return "error" in s ? { error: s.error, status: 400 } : s;
|
|
292
358
|
} catch (e) {
|
|
293
359
|
return console.error("GET_ASSET error:", e), { error: e instanceof Error ? e.message : "Unknown error", status: 500 };
|
|
294
360
|
}
|
|
295
361
|
}
|
|
296
362
|
}
|
|
297
|
-
const
|
|
298
|
-
search:
|
|
299
|
-
page:
|
|
300
|
-
limit:
|
|
363
|
+
const N = o.object({
|
|
364
|
+
search: o.string().optional(),
|
|
365
|
+
page: o.number().optional(),
|
|
366
|
+
limit: o.number().optional()
|
|
301
367
|
});
|
|
302
|
-
class
|
|
368
|
+
class F extends E {
|
|
303
369
|
constructor(t) {
|
|
304
370
|
super(), this.supabase = t;
|
|
305
371
|
}
|
|
306
372
|
getValidationSchema() {
|
|
307
|
-
return
|
|
373
|
+
return N;
|
|
308
374
|
}
|
|
309
375
|
async execute(t) {
|
|
310
376
|
try {
|
|
@@ -313,22 +379,22 @@ class j extends g {
|
|
|
313
379
|
const { appId: e, userId: r } = this.context;
|
|
314
380
|
if (!r)
|
|
315
381
|
return { error: "User ID is required", status: 401 };
|
|
316
|
-
const s = await new
|
|
382
|
+
const s = await new S(e, r, this.supabase).getAssets(t);
|
|
317
383
|
return "error" in s ? { error: s.error, status: 400 } : s;
|
|
318
384
|
} catch (e) {
|
|
319
385
|
return console.error("GET_ASSETS error:", e), { error: e instanceof Error ? e.message : "Unknown error", status: 500 };
|
|
320
386
|
}
|
|
321
387
|
}
|
|
322
388
|
}
|
|
323
|
-
const
|
|
324
|
-
id:
|
|
389
|
+
const M = o.object({
|
|
390
|
+
id: o.string()
|
|
325
391
|
});
|
|
326
|
-
class
|
|
392
|
+
class v extends E {
|
|
327
393
|
constructor(t) {
|
|
328
394
|
super(), this.supabase = t;
|
|
329
395
|
}
|
|
330
396
|
getValidationSchema() {
|
|
331
|
-
return
|
|
397
|
+
return M;
|
|
332
398
|
}
|
|
333
399
|
async execute(t) {
|
|
334
400
|
try {
|
|
@@ -337,24 +403,24 @@ class q extends g {
|
|
|
337
403
|
const { appId: e, userId: r } = this.context;
|
|
338
404
|
if (!r)
|
|
339
405
|
return { error: "User ID is required", status: 401 };
|
|
340
|
-
const s = await new
|
|
406
|
+
const s = await new S(e, r, this.supabase).deleteAsset(t);
|
|
341
407
|
return "error" in s ? { error: s.error, status: 400 } : s;
|
|
342
408
|
} catch (e) {
|
|
343
409
|
return console.error("DELETE_ASSET error:", e), { error: e instanceof Error ? e.message : "Unknown error", status: 500 };
|
|
344
410
|
}
|
|
345
411
|
}
|
|
346
412
|
}
|
|
347
|
-
const
|
|
348
|
-
id:
|
|
349
|
-
file:
|
|
350
|
-
description:
|
|
413
|
+
const B = o.object({
|
|
414
|
+
id: o.string(),
|
|
415
|
+
file: o.string().optional(),
|
|
416
|
+
description: o.string().optional()
|
|
351
417
|
});
|
|
352
|
-
class
|
|
418
|
+
class $ extends E {
|
|
353
419
|
constructor(t) {
|
|
354
420
|
super(), this.supabase = t;
|
|
355
421
|
}
|
|
356
422
|
getValidationSchema() {
|
|
357
|
-
return
|
|
423
|
+
return B;
|
|
358
424
|
}
|
|
359
425
|
async execute(t) {
|
|
360
426
|
try {
|
|
@@ -363,27 +429,27 @@ class N extends g {
|
|
|
363
429
|
const { appId: e, userId: r } = this.context;
|
|
364
430
|
if (!r)
|
|
365
431
|
return { error: "User ID is required", status: 401 };
|
|
366
|
-
const s = await new
|
|
432
|
+
const s = await new S(e, r, this.supabase).updateAsset(t);
|
|
367
433
|
return "error" in s ? { error: s.error, status: 400 } : s;
|
|
368
434
|
} catch (e) {
|
|
369
435
|
return console.error("UPDATE_ASSET error:", e), { error: e instanceof Error ? e.message : "Unknown error", status: 500 };
|
|
370
436
|
}
|
|
371
437
|
}
|
|
372
438
|
}
|
|
373
|
-
const
|
|
374
|
-
userId:
|
|
439
|
+
const R = o.object({
|
|
440
|
+
userId: o.string()
|
|
375
441
|
});
|
|
376
|
-
class
|
|
442
|
+
class j extends E {
|
|
377
443
|
constructor(t) {
|
|
378
444
|
super(), this.supabase = t;
|
|
379
445
|
}
|
|
380
446
|
getValidationSchema() {
|
|
381
|
-
return
|
|
447
|
+
return R;
|
|
382
448
|
}
|
|
383
449
|
async execute(t) {
|
|
384
|
-
var e, r,
|
|
450
|
+
var e, r, a, s, i, c;
|
|
385
451
|
try {
|
|
386
|
-
const { userId: d } = t, { data:
|
|
452
|
+
const { userId: d } = t, { data: n, error: l } = await this.supabase.auth.admin.getUserById(d);
|
|
387
453
|
return l ? {
|
|
388
454
|
data: {
|
|
389
455
|
id: "unknown",
|
|
@@ -394,10 +460,10 @@ class V extends g {
|
|
|
394
460
|
status: 200
|
|
395
461
|
} : {
|
|
396
462
|
data: {
|
|
397
|
-
id: ((e =
|
|
398
|
-
email: ((r =
|
|
399
|
-
name: ((s = (
|
|
400
|
-
avatar: ((c = (
|
|
463
|
+
id: ((e = n.user) == null ? void 0 : e.id) || "unknown",
|
|
464
|
+
email: ((r = n.user) == null ? void 0 : r.email) || "unknown@chaibuilder.com",
|
|
465
|
+
name: ((s = (a = n.user) == null ? void 0 : a.user_metadata) == null ? void 0 : s.name) || "Unknown",
|
|
466
|
+
avatar: ((c = (i = n.user) == null ? void 0 : i.user_metadata) == null ? void 0 : c.avatar_url) || ""
|
|
401
467
|
},
|
|
402
468
|
status: 200
|
|
403
469
|
};
|
|
@@ -414,35 +480,35 @@ class V extends g {
|
|
|
414
480
|
}
|
|
415
481
|
}
|
|
416
482
|
}
|
|
417
|
-
const
|
|
418
|
-
email:
|
|
419
|
-
oldPassword:
|
|
420
|
-
newPassword:
|
|
421
|
-
confirmPassword:
|
|
483
|
+
const C = o.object({
|
|
484
|
+
email: o.string().email(),
|
|
485
|
+
oldPassword: o.string().min(1, "Old password is required"),
|
|
486
|
+
newPassword: o.string().min(8, "New password must be at least 8 characters"),
|
|
487
|
+
confirmPassword: o.string().min(1, "Confirm password is required")
|
|
422
488
|
}).refine((u) => u.newPassword === u.confirmPassword, {
|
|
423
489
|
message: "Confirm password does not match",
|
|
424
490
|
path: ["confirmPassword"]
|
|
425
491
|
});
|
|
426
|
-
class
|
|
492
|
+
class V extends E {
|
|
427
493
|
constructor(t) {
|
|
428
494
|
super(), this.supabase = t;
|
|
429
495
|
}
|
|
430
496
|
getValidationSchema() {
|
|
431
|
-
return
|
|
497
|
+
return C;
|
|
432
498
|
}
|
|
433
499
|
async execute(t) {
|
|
434
500
|
try {
|
|
435
|
-
const { email: e, oldPassword: r, newPassword:
|
|
501
|
+
const { email: e, oldPassword: r, newPassword: a } = t, { error: s } = await this.supabase.auth.signInWithPassword({
|
|
436
502
|
email: e,
|
|
437
503
|
password: r
|
|
438
504
|
});
|
|
439
505
|
if (s)
|
|
440
|
-
throw new
|
|
441
|
-
const { error:
|
|
442
|
-
password:
|
|
506
|
+
throw new _("Current password is incorrect", "INVALID_PASSWORD", 400);
|
|
507
|
+
const { error: i } = await this.supabase.auth.updateUser({
|
|
508
|
+
password: a
|
|
443
509
|
});
|
|
444
|
-
if (
|
|
445
|
-
throw new
|
|
510
|
+
if (i)
|
|
511
|
+
throw new _(i.message || "Failed to update password", "UPDATE_FAILED", 400);
|
|
446
512
|
return {
|
|
447
513
|
data: { message: "Password changed successfully" },
|
|
448
514
|
status: 200
|
|
@@ -452,24 +518,24 @@ class H extends g {
|
|
|
452
518
|
}
|
|
453
519
|
}
|
|
454
520
|
}
|
|
455
|
-
const
|
|
456
|
-
key:
|
|
521
|
+
const q = o.object({
|
|
522
|
+
key: o.string()
|
|
457
523
|
// Storage key/path to delete
|
|
458
524
|
});
|
|
459
|
-
class
|
|
525
|
+
class z extends E {
|
|
460
526
|
constructor(e) {
|
|
461
527
|
super();
|
|
462
|
-
|
|
528
|
+
w(this, "bucketName", "dam-assets");
|
|
463
529
|
this.supabase = e;
|
|
464
530
|
}
|
|
465
531
|
getValidationSchema() {
|
|
466
|
-
return
|
|
532
|
+
return q;
|
|
467
533
|
}
|
|
468
534
|
async execute(e) {
|
|
469
535
|
try {
|
|
470
|
-
const { key: r } = e, { error:
|
|
471
|
-
return
|
|
472
|
-
error: `Failed to delete from Supabase Storage: ${
|
|
536
|
+
const { key: r } = e, { error: a } = await this.supabase.storage.from(this.bucketName).remove([r]);
|
|
537
|
+
return a ? {
|
|
538
|
+
error: `Failed to delete from Supabase Storage: ${a.message}`,
|
|
473
539
|
status: 500
|
|
474
540
|
} : {
|
|
475
541
|
data: { success: !0 },
|
|
@@ -483,36 +549,36 @@ class Q extends g {
|
|
|
483
549
|
}
|
|
484
550
|
}
|
|
485
551
|
}
|
|
486
|
-
const
|
|
487
|
-
file:
|
|
552
|
+
const H = o.object({
|
|
553
|
+
file: o.string(),
|
|
488
554
|
// Base64 string
|
|
489
|
-
fileName:
|
|
490
|
-
contentType:
|
|
491
|
-
folder:
|
|
492
|
-
metadata:
|
|
555
|
+
fileName: o.string(),
|
|
556
|
+
contentType: o.string().optional(),
|
|
557
|
+
folder: o.string().optional(),
|
|
558
|
+
metadata: o.record(o.string(), o.any()).optional()
|
|
493
559
|
});
|
|
494
|
-
class
|
|
560
|
+
class W extends E {
|
|
495
561
|
constructor(e) {
|
|
496
562
|
super();
|
|
497
|
-
|
|
563
|
+
w(this, "bucketName", "dam-assets");
|
|
498
564
|
this.supabase = e;
|
|
499
565
|
}
|
|
500
566
|
getValidationSchema() {
|
|
501
|
-
return
|
|
567
|
+
return H;
|
|
502
568
|
}
|
|
503
569
|
async execute(e) {
|
|
504
570
|
try {
|
|
505
571
|
if (!this.context)
|
|
506
572
|
return { error: "Context not set", status: 400 };
|
|
507
|
-
const { appId: r } = this.context, { file:
|
|
508
|
-
let
|
|
509
|
-
if (typeof
|
|
510
|
-
const
|
|
511
|
-
|
|
573
|
+
const { appId: r } = this.context, { file: a, fileName: s, contentType: i, folder: c, metadata: d } = e;
|
|
574
|
+
let n;
|
|
575
|
+
if (typeof a == "string") {
|
|
576
|
+
const A = a.split(",")[1] || a;
|
|
577
|
+
n = Buffer.from(A, "base64");
|
|
512
578
|
} else
|
|
513
|
-
|
|
514
|
-
const l = c ? `${c}/${s}` : `${r}/${s}`, { data:
|
|
515
|
-
contentType:
|
|
579
|
+
n = a;
|
|
580
|
+
const l = c ? `${c}/${s}` : `${r}/${s}`, { data: g, error: p } = await this.supabase.storage.from(this.bucketName).upload(l, n, {
|
|
581
|
+
contentType: i || "application/octet-stream",
|
|
516
582
|
upsert: !0,
|
|
517
583
|
...d && { metadata: d }
|
|
518
584
|
});
|
|
@@ -522,13 +588,13 @@ class X extends g {
|
|
|
522
588
|
status: 500
|
|
523
589
|
};
|
|
524
590
|
const {
|
|
525
|
-
data: { publicUrl:
|
|
591
|
+
data: { publicUrl: m }
|
|
526
592
|
} = this.supabase.storage.from(this.bucketName).getPublicUrl(l);
|
|
527
593
|
return {
|
|
528
594
|
data: {
|
|
529
|
-
url:
|
|
530
|
-
key:
|
|
531
|
-
size:
|
|
595
|
+
url: m,
|
|
596
|
+
key: g.path,
|
|
597
|
+
size: n.length,
|
|
532
598
|
metadata: d
|
|
533
599
|
},
|
|
534
600
|
status: 200
|
|
@@ -541,23 +607,23 @@ class X extends g {
|
|
|
541
607
|
}
|
|
542
608
|
}
|
|
543
609
|
}
|
|
544
|
-
const
|
|
545
|
-
GET_CHAI_USER: new
|
|
546
|
-
CHANGE_PASSWORD: new
|
|
547
|
-
}),
|
|
610
|
+
const Q = (u) => ({
|
|
611
|
+
GET_CHAI_USER: new j(u),
|
|
612
|
+
CHANGE_PASSWORD: new V(u)
|
|
613
|
+
}), Z = (u) => ({
|
|
548
614
|
// Asset management actions
|
|
549
|
-
UPLOAD_ASSET: new
|
|
550
|
-
GET_ASSET: new
|
|
551
|
-
GET_ASSETS: new
|
|
552
|
-
DELETE_ASSET: new
|
|
553
|
-
UPDATE_ASSET: new
|
|
615
|
+
UPLOAD_ASSET: new D(u),
|
|
616
|
+
GET_ASSET: new G(u),
|
|
617
|
+
GET_ASSETS: new F(u),
|
|
618
|
+
DELETE_ASSET: new v(u),
|
|
619
|
+
UPDATE_ASSET: new $(u),
|
|
554
620
|
// Generic storage actions
|
|
555
|
-
UPLOAD_TO_STORAGE: new
|
|
556
|
-
DELETE_FROM_STORAGE: new
|
|
621
|
+
UPLOAD_TO_STORAGE: new W(u),
|
|
622
|
+
DELETE_FROM_STORAGE: new z(u)
|
|
557
623
|
});
|
|
558
624
|
export {
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
625
|
+
z as DeleteFromStorageAction,
|
|
626
|
+
Q as SupabaseAuthActions,
|
|
627
|
+
Z as SupabaseStorageActions,
|
|
628
|
+
W as UploadToStorageAction
|
|
563
629
|
};
|