@chaibuilder/sdk 4.0.0-beta.1 → 4.0.0-beta.3
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/README.md +27 -20
- package/dist/2SSKDMRQ-BnsZi3K3.cjs +1 -0
- package/dist/2SSKDMRQ-CnSDkQcy.js +42 -0
- package/dist/AP7HFJJL-B31839PG.cjs +1228 -0
- package/dist/AP7HFJJL-CymCmW14.js +9214 -0
- package/dist/IconPicker-B1rWC-Ex.js +59 -0
- package/dist/IconPicker-DREyo007.cjs +1 -0
- package/dist/WDYDFRGG-BUVnbAci.js +33 -0
- package/dist/WDYDFRGG-BxhOCHc3.cjs +1 -0
- package/dist/_commonjsHelpers-C6fGbg64.js +6 -0
- package/dist/_commonjsHelpers-DwGv2jUC.cjs +1 -0
- package/dist/actions-registery-CZ1w0NKa.js +15545 -0
- package/dist/actions-registery-YnFmU21O.cjs +418 -0
- package/dist/actions.cjs +1 -0
- package/dist/actions.d.ts +3202 -0
- package/dist/actions.js +216 -0
- package/dist/active-in-another-tab-B47YjQGN.cjs +1 -0
- package/dist/active-in-another-tab-CyjngVA6.js +34 -0
- package/dist/add-new-language-page-88xzrUy8.cjs +1 -0
- package/dist/add-new-language-page-WmlCnytQ.js +401 -0
- package/dist/add-new-page-VW2wAYZp.js +31 -0
- package/dist/add-new-page-soZ8GAkN.cjs +1 -0
- package/dist/ai-panel-content-7zCil042.cjs +1 -0
- package/dist/ai-panel-content-D_o7Q_A-.js +61 -0
- package/dist/ai-panel-default-lang-COYaxNwn.cjs +3 -0
- package/dist/ai-panel-default-lang-DnElspF0.js +341 -0
- package/dist/ai-panel-other-lang-CkynNlAU.cjs +1 -0
- package/dist/ai-panel-other-lang-Dp0E9_Hx.js +162 -0
- package/dist/ai-prompt-input-Bhc0ds7X.js +655 -0
- package/dist/ai-prompt-input-CThbVp0_.cjs +1 -0
- package/dist/ai-translation-prompt-C2kJQFDX.cjs +1 -0
- package/dist/ai-translation-prompt-CZ55HQmo.js +28 -0
- package/dist/apply-binding-6iwlED02.js +833 -0
- package/dist/apply-binding-KKp5PnpZ.cjs +1 -0
- package/dist/code-display-BnqzqzoP.cjs +1 -0
- package/dist/{code-display-337R7Dev.js → code-display-DhD_RBcg.js} +1 -1
- package/dist/code-editor-DRIAnNbb.js +50 -0
- package/dist/code-editor-o3___nu2.cjs +1 -0
- package/dist/common-functions-B3a4xKt_.cjs +1 -0
- package/dist/common-functions-D2lMFR6K.js +13 -0
- package/dist/continue-editing-in-this-client-CS2aQ7yY.js +24 -0
- package/dist/continue-editing-in-this-client-CtMYsk-A.cjs +1 -0
- package/dist/core-BoRDjj4h.cjs +1 -0
- package/dist/core-yvI6kCyw.js +56 -0
- package/dist/core.cjs +1 -1
- package/dist/core.d.ts +51 -383
- package/dist/core.js +39 -106
- package/dist/{css-import-modal-DA2L6kwP.js → css-import-modal-Byg6wV0O.js} +36 -36
- package/dist/css-import-modal-CyqkXWCO.cjs +13 -0
- package/dist/delete-design-token-BRZZiWtQ.js +40 -0
- package/dist/delete-design-token-DkVs1oBf.cjs +1 -0
- package/dist/delete-page-BzyX9TN-.js +70 -0
- package/dist/delete-page-DxX7PFIE.cjs +1 -0
- package/dist/design-token-usage-CAHzEGgJ.cjs +1 -0
- package/dist/design-token-usage-xQs6SlaJ.js +113 -0
- package/dist/digital-asset-manager--uO8Agia.cjs +1 -0
- package/dist/digital-asset-manager-DbtwzxRz.js +876 -0
- package/dist/duplicate-page-BR7Dlo9d.js +133 -0
- package/dist/duplicate-page-CaNAbXwV.cjs +1 -0
- package/dist/dynamic-page-selector-Cb5r_W8s.js +85 -0
- package/dist/dynamic-page-selector-Cxk_gjni.cjs +1 -0
- package/dist/fonts-B-Xt29pe.cjs +1 -0
- package/dist/fonts-DRly3Wzd.js +78 -0
- package/dist/{get-chai-builder-tailwind-config-C6MHaUM0.cjs → get-chai-builder-tailwind-config-B9rCyiQo.cjs} +1 -1
- package/dist/{get-chai-builder-tailwind-config-BqaIvg8p.js → get-chai-builder-tailwind-config-DjoVOuAf.js} +13 -10
- package/dist/{get-chai-builder-theme-D0IsUvK4.js → get-chai-builder-theme-BYtp20KD.js} +4 -4
- package/dist/get-chai-builder-theme-Dl72X7cz.cjs +1 -0
- package/dist/get-seo-defaults-9zHebckY.js +65 -0
- package/dist/get-seo-defaults-Cw7vFt-B.cjs +1 -0
- package/dist/image-compression-DZ9WMmyn.cjs +1 -0
- package/dist/image-compression-DsZ1oqpb.js +37 -0
- package/dist/image-editor-DV8kUKhl.js +108 -0
- package/dist/image-editor-G-K28aTS.cjs +1 -0
- package/dist/index-B-rSiAp_.cjs +1 -0
- package/dist/index-Ct7ElCGK.js +19069 -0
- package/dist/index-DF5DEvqb.cjs +160 -0
- package/dist/index-Dxfyt4d4.js +39 -0
- package/dist/index-WQwzsC7A.cjs +5 -0
- package/dist/index-ZuacEL1j.js +4732 -0
- package/dist/json-diff-viewer-D7z4zNvv.cjs +8 -0
- package/dist/json-diff-viewer-krslPepD.js +258 -0
- package/dist/lang-panel-BwIewMyw.js +215 -0
- package/dist/lang-panel-DT96k1xg.cjs +1 -0
- package/dist/manage-design-tokens-Caz_20VK.js +240 -0
- package/dist/manage-design-tokens-CrmLe7UT.cjs +1 -0
- package/dist/mark-as-template-D295ZQtU.js +156 -0
- package/dist/mark-as-template-W3LmpiqN.cjs +1 -0
- package/dist/models-5gOsRC56.cjs +1 -0
- package/dist/models-D95ZYr_x.js +70 -0
- package/dist/nested-path-selector-content-CKYYK-C5.js +87 -0
- package/dist/nested-path-selector-content-CoS_d3dc.cjs +1 -0
- package/dist/no-language-page-content-BvqRBP6y.js +42 -0
- package/dist/no-language-page-content-DkfeMl90.cjs +1 -0
- package/dist/no-language-page-dialog-BcEoqyQB.cjs +1 -0
- package/dist/no-language-page-dialog-PjNqTUpl.js +10 -0
- package/dist/page-creator-C4gc5NSC.cjs +1 -0
- package/dist/page-creator-DiOITEMw.js +795 -0
- package/dist/page-lock-BdYmCks0.cjs +1 -0
- package/dist/page-lock-Bfbs6RgL.js +30 -0
- package/dist/page-locked-dialog-B1FAtK92.cjs +1 -0
- package/dist/page-locked-dialog-B6MKTRfY.js +133 -0
- package/dist/page-manager-new-CHDueBDk.cjs +1 -0
- package/dist/page-manager-new-CzX22g2n.js +394 -0
- package/dist/page-manager-search-and-filter-CM0UMb6U.js +201 -0
- package/dist/page-manager-search-and-filter-DkkRIH86.cjs +1 -0
- package/dist/page-revisions-content-ChY-4f2V.cjs +1 -0
- package/dist/page-revisions-content-NH9JK4Ey.js +445 -0
- package/dist/pages.cjs +1 -0
- package/dist/pages.d.ts +491 -0
- package/dist/pages.js +27 -0
- package/dist/plugin-3ZKK6RXm.js +245 -0
- package/dist/plugin-C6rgJDNQ.cjs +22 -0
- package/dist/publish-pages-content-D9aixMN5.js +178 -0
- package/dist/publish-pages-content-x-JuSFJ9.cjs +1 -0
- package/dist/register-partial-type-BjtdfKHE.js +36 -0
- package/dist/register-partial-type-ig9fUWIJ.cjs +1 -0
- package/dist/render.cjs +2 -2
- package/dist/render.d.ts +26 -13
- package/dist/render.js +130 -124
- package/dist/rte-widget-modal-BaHIuEjF.cjs +1 -0
- package/dist/rte-widget-modal-DOJEXLIf.js +38 -0
- package/dist/runtime.cjs +1 -1
- package/dist/runtime.d.ts +306 -7
- package/dist/runtime.js +44 -1
- package/dist/save-to-lib-Cgpxw8-g.cjs +1 -0
- package/dist/save-to-lib-eiOc_SSN.js +422 -0
- package/dist/sdk.css +1 -1
- package/dist/selected-block-display-BgRY82CT.cjs +16 -0
- package/dist/selected-block-display-CBFePS19.js +319 -0
- package/dist/seo-panel-C1-iMOR1.js +798 -0
- package/dist/seo-panel-DfAb8U7W.cjs +2 -0
- package/dist/shared-json-ld-B4PxAM_0.js +565 -0
- package/dist/shared-json-ld-DzG398hr.cjs +1 -0
- package/dist/slug-input-AwNJs9im.js +86 -0
- package/dist/slug-input-C_ijLQ_X.cjs +1 -0
- package/dist/supabase-actions.cjs +1 -0
- package/dist/supabase-actions.d.ts +284 -0
- package/dist/supabase-actions.js +524 -0
- package/dist/take-over-request-BNxcjY2j.cjs +1 -0
- package/dist/take-over-request-C4FeDtN_.js +63 -0
- package/dist/theme-panel-footer-Cq9pljro.cjs +1 -0
- package/dist/theme-panel-footer-uBQqSJXm.js +25 -0
- package/dist/translation-warning-modal-B64YqlbI.js +26 -0
- package/dist/translation-warning-modal-BZAcwM2_.cjs +1 -0
- package/dist/unmark-as-template-CZ9sQp_P.js +39 -0
- package/dist/unmark-as-template-EVvk0vmp.cjs +1 -0
- package/dist/unpublish-page-D4VwOlxc.js +27 -0
- package/dist/unpublish-page-bdSmwAVQ.cjs +1 -0
- package/dist/use-page-expand-manager-B6XTvk0E.cjs +1 -0
- package/dist/use-page-expand-manager-Cf4MUEJw.js +85 -0
- package/dist/{tailwind.cjs → utils.cjs} +1 -1
- package/dist/{tailwind.d.ts → utils.d.ts} +12 -11
- package/dist/utils.js +7 -0
- package/dist/web-blocks.cjs +1 -1
- package/dist/web-blocks.d.ts +0 -6
- package/dist/web-blocks.js +248 -241
- package/dist/web-preview-Cio70gk5.cjs +1 -0
- package/dist/web-preview-Djy6WIyj.js +73 -0
- package/package.json +175 -105
- package/dist/IconPicker-CGWn9C4u.cjs +0 -1
- package/dist/IconPicker-QvxJ-4Ez.js +0 -64
- package/dist/apply-binding-DCno1xQL.js +0 -711
- package/dist/apply-binding-DvHNFLQD.cjs +0 -1
- package/dist/code-display-BZ1x7SqI.cjs +0 -1
- package/dist/code-editor-B28LoECM.cjs +0 -1
- package/dist/code-editor-CfG2FhJ-.js +0 -58
- package/dist/common-functions-BGzDsf1z.js +0 -14
- package/dist/common-functions-BZmyleS1.cjs +0 -1
- package/dist/css-import-modal-CENUYvcl.cjs +0 -13
- package/dist/get-chai-builder-theme-Ck_Z4Q-M.cjs +0 -1
- package/dist/index-CaGNHF7f.js +0 -12209
- package/dist/index-Gn6pJt2v.cjs +0 -166
- package/dist/mockServiceWorker.js +0 -307
- package/dist/plugin-B5627hMN.js +0 -195
- package/dist/plugin-UxTRfDum.cjs +0 -22
- package/dist/rte-widget-modal-DL739qeQ.cjs +0 -1
- package/dist/rte-widget-modal-Dte0od04.js +0 -41
- package/dist/tailwind.js +0 -7
- package/dist/tooltip-A4qGk781.cjs +0 -1
- package/dist/tooltip-tLiIOgjq.js +0 -1067
- package/dist/ui.cjs +0 -1
- package/dist/ui.d.ts +0 -415
- package/dist/ui.js +0 -129
- package/dist/vite.svg +0 -1
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import { jsxs as i, jsx as o } from "react/jsx-runtime";
|
|
2
|
+
import { ab as d, I as v } from "./index-Ct7ElCGK.js";
|
|
3
|
+
import { useState as x, useEffect as C } from "react";
|
|
4
|
+
const y = (e) => {
|
|
5
|
+
if (!e) return { base: e, extension: null };
|
|
6
|
+
const n = e.lastIndexOf(".");
|
|
7
|
+
if (n <= 0) return { base: e, extension: null };
|
|
8
|
+
const t = e.substring(n);
|
|
9
|
+
return { base: e.substring(0, n), extension: t };
|
|
10
|
+
}, g = (e) => {
|
|
11
|
+
if (!e) return e;
|
|
12
|
+
const { base: n } = y(e);
|
|
13
|
+
return n;
|
|
14
|
+
};
|
|
15
|
+
function w(e, n) {
|
|
16
|
+
const t = (e || "").split("/").filter(Boolean);
|
|
17
|
+
let s = "", r = !0;
|
|
18
|
+
if (n.slug === "/") {
|
|
19
|
+
const a = t.pop() || "";
|
|
20
|
+
if (d[a])
|
|
21
|
+
r = !0;
|
|
22
|
+
else {
|
|
23
|
+
s = a;
|
|
24
|
+
const l = t.pop() || "";
|
|
25
|
+
r = !!d[l];
|
|
26
|
+
}
|
|
27
|
+
} else if (n.parent)
|
|
28
|
+
t.length && (s = t.pop() || "");
|
|
29
|
+
else if (t.length) {
|
|
30
|
+
s = t.pop() || "";
|
|
31
|
+
const a = t.pop() || "";
|
|
32
|
+
r = !!d[a];
|
|
33
|
+
}
|
|
34
|
+
return { initSlug: s, prefix: r };
|
|
35
|
+
}
|
|
36
|
+
const E = (e) => e && g(e), z = (e, n) => {
|
|
37
|
+
const t = g(e || "");
|
|
38
|
+
return !t || t === "/" ? `/${n}` : `${t}/${n}`;
|
|
39
|
+
};
|
|
40
|
+
function D({
|
|
41
|
+
value: e,
|
|
42
|
+
onChange: n,
|
|
43
|
+
placeholder: t,
|
|
44
|
+
parentSlug: s,
|
|
45
|
+
onValidationChange: r,
|
|
46
|
+
disabled: a = !1,
|
|
47
|
+
fullSlug: l
|
|
48
|
+
}) {
|
|
49
|
+
const [h, u] = x(e), [c, f] = x(null);
|
|
50
|
+
C(() => {
|
|
51
|
+
u(e);
|
|
52
|
+
}, [e]);
|
|
53
|
+
const b = (N) => {
|
|
54
|
+
const p = N.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
|
+
m > 1 ? f("Invalid slug. Only one dot (.) is allowed in the slug") : f(null), r && r(S), u(p), n(p);
|
|
56
|
+
};
|
|
57
|
+
return /* @__PURE__ */ i("div", { children: [
|
|
58
|
+
s && /* @__PURE__ */ o("div", { className: "mb-1 flex items-center", children: /* @__PURE__ */ i("span", { className: "text-xs text-gray-500", children: [
|
|
59
|
+
"Parent: ",
|
|
60
|
+
/* @__PURE__ */ o("span", { className: "font-mono text-gray-900", children: E(s) })
|
|
61
|
+
] }) }),
|
|
62
|
+
/* @__PURE__ */ i("div", { className: "relative", children: [
|
|
63
|
+
/* @__PURE__ */ o(
|
|
64
|
+
v,
|
|
65
|
+
{
|
|
66
|
+
disabled: a,
|
|
67
|
+
value: h,
|
|
68
|
+
onChange: b,
|
|
69
|
+
placeholder: t,
|
|
70
|
+
className: c ? "border-red-500" : ""
|
|
71
|
+
}
|
|
72
|
+
),
|
|
73
|
+
c && /* @__PURE__ */ o("div", { className: "mt-1 text-xs text-red-500", children: c })
|
|
74
|
+
] }),
|
|
75
|
+
l && l !== "undefined" && /* @__PURE__ */ o("div", { className: "mt-1 flex items-center", children: /* @__PURE__ */ i("span", { className: "text-xs text-gray-500", children: [
|
|
76
|
+
"Complete Slug: ",
|
|
77
|
+
/* @__PURE__ */ o("span", { className: "font-mono text-gray-900", children: l })
|
|
78
|
+
] }) })
|
|
79
|
+
] });
|
|
80
|
+
}
|
|
81
|
+
export {
|
|
82
|
+
D as S,
|
|
83
|
+
z as c,
|
|
84
|
+
w as p,
|
|
85
|
+
g as r
|
|
86
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";const s=require("react/jsx-runtime"),i=require("./index-DF5DEvqb.cjs"),d=require("react"),b=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}=b(e);return n};function j(e,n){const t=(e||"").split("/").filter(Boolean);let r="",a=!0;if(n.slug==="/"){const l=t.pop()||"";if(i.LANGUAGES[l])a=!0;else{r=l;const o=t.pop()||"";a=!!i.LANGUAGES[o]}}else if(n.parent)t.length&&(r=t.pop()||"");else if(t.length){r=t.pop()||"";const l=t.pop()||"";a=!!i.LANGUAGES[l]}return{initSlug:r,prefix:a}}const E=e=>e&&x(e),v=(e,n)=>{const t=x(e||"");return!t||t==="/"?`/${n}`:`${t}/${n}`};function C({value:e,onChange:n,placeholder:t,parentSlug:r,onValidationChange:a,disabled:l=!1,fullSlug:o}){const[g,p]=d.useState(e),[c,f]=d.useState(null);d.useEffect(()=>{p(e)},[e]);const h=S=>{const u=S.target.value.replace(/\//g,"").replace(/\s+/g,"-").replace(/[^a-zA-Z0-9-_.]/g,"-").replace(/-+/g,"-").replace(/^-+/,"").toLowerCase(),m=(u.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(u),n(u)};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:E(r)})]})}),s.jsxs("div",{className:"relative",children:[s.jsx(i.Input,{disabled:l,value:g,onChange:h,placeholder:t,className:c?"border-red-500":""}),c&&s.jsx("div",{className:"mt-1 text-xs text-red-500",children:c})]}),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=C;exports.combineParentChildSlugs=v;exports.parseSlugForEdit=j;exports.removeSlugExtension=x;
|
|
@@ -0,0 +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;
|
|
@@ -0,0 +1,284 @@
|
|
|
1
|
+
import { SupabaseClient } from '@supabase/supabase-js';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* ChaiAction Interface
|
|
6
|
+
* Defines the contract for all action handlers
|
|
7
|
+
*/
|
|
8
|
+
declare interface ChaiAction<T = any, K = any> {
|
|
9
|
+
validate(data: T): boolean;
|
|
10
|
+
setContext(context: ChaiActionContext): void;
|
|
11
|
+
execute(data: T): Promise<K>;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Action Context
|
|
16
|
+
* Contains information and repositories needed by actions
|
|
17
|
+
*/
|
|
18
|
+
declare interface ChaiActionContext {
|
|
19
|
+
appId: string;
|
|
20
|
+
userId?: string;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Base Action Class
|
|
25
|
+
* Provides common functionality for all action handlers
|
|
26
|
+
*/
|
|
27
|
+
declare abstract class ChaiBaseAction<T = any, K = any> implements ChaiAction<T, K> {
|
|
28
|
+
protected context: ChaiActionContext | null;
|
|
29
|
+
/**
|
|
30
|
+
* Abstract method to get the validation schema for the action data
|
|
31
|
+
* Each action must implement this to define its own validation rules
|
|
32
|
+
*/
|
|
33
|
+
protected abstract getValidationSchema(): z.ZodType<T>;
|
|
34
|
+
/**
|
|
35
|
+
* Validate the action data using the schema provided by getValidationSchema
|
|
36
|
+
* @param data The data to validate
|
|
37
|
+
* @returns true if the data is valid, false otherwise
|
|
38
|
+
*/
|
|
39
|
+
validate(data: T): boolean;
|
|
40
|
+
/**
|
|
41
|
+
* Get validation errors for the action data
|
|
42
|
+
* This can be useful for debugging or providing more detailed error messages
|
|
43
|
+
* @param data The data to validate
|
|
44
|
+
* @returns An array of validation errors or null if the data is valid
|
|
45
|
+
*/
|
|
46
|
+
getValidationErrors(data: T): string | null;
|
|
47
|
+
/**
|
|
48
|
+
* Set the action context
|
|
49
|
+
* @param context The context to set
|
|
50
|
+
*/
|
|
51
|
+
setContext(context: ChaiActionContext): void;
|
|
52
|
+
/**
|
|
53
|
+
* Abstract method to execute the action
|
|
54
|
+
* Each action must implement this to define its own business logic
|
|
55
|
+
*/
|
|
56
|
+
abstract execute(data: T): Promise<any>;
|
|
57
|
+
/**
|
|
58
|
+
* Helper method to handle common errors in actions
|
|
59
|
+
* @param error The error to handle
|
|
60
|
+
* @throws ActionError with appropriate message and code
|
|
61
|
+
*/
|
|
62
|
+
protected handleError(error: unknown): never;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
declare interface ChaiUser {
|
|
66
|
+
id: string;
|
|
67
|
+
email: string;
|
|
68
|
+
name: string;
|
|
69
|
+
avatar: string;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
declare class DeleteAssetAction extends ChaiBaseAction<DeleteAssetInput> {
|
|
73
|
+
private supabase;
|
|
74
|
+
constructor(supabase: SupabaseClient);
|
|
75
|
+
protected getValidationSchema(): z.ZodObject<{
|
|
76
|
+
id: z.ZodString;
|
|
77
|
+
}, z.core.$strip>;
|
|
78
|
+
execute(data: DeleteAssetInput): Promise<{
|
|
79
|
+
success: boolean;
|
|
80
|
+
} | {
|
|
81
|
+
error: string;
|
|
82
|
+
status: number;
|
|
83
|
+
}>;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
declare type DeleteAssetInput = z.infer<typeof DeleteAssetSchema>;
|
|
87
|
+
|
|
88
|
+
declare const DeleteAssetSchema: z.ZodObject<{
|
|
89
|
+
id: z.ZodString;
|
|
90
|
+
}, z.core.$strip>;
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* DELETE_FROM_STORAGE Action
|
|
94
|
+
* Generic storage delete action using Supabase Storage
|
|
95
|
+
*/
|
|
96
|
+
export declare class DeleteFromStorageAction extends ChaiBaseAction<DeleteFromStorageInput> {
|
|
97
|
+
private supabase;
|
|
98
|
+
private bucketName;
|
|
99
|
+
constructor(supabase: SupabaseClient);
|
|
100
|
+
protected getValidationSchema(): z.ZodObject<{
|
|
101
|
+
key: z.ZodString;
|
|
102
|
+
}, z.core.$strip>;
|
|
103
|
+
execute(data: DeleteFromStorageInput): Promise<{
|
|
104
|
+
error: string;
|
|
105
|
+
status: number;
|
|
106
|
+
data?: undefined;
|
|
107
|
+
} | {
|
|
108
|
+
data: {
|
|
109
|
+
success: boolean;
|
|
110
|
+
};
|
|
111
|
+
status: number;
|
|
112
|
+
error?: undefined;
|
|
113
|
+
}>;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
declare type DeleteFromStorageInput = z.infer<typeof DeleteFromStorageSchema>;
|
|
117
|
+
|
|
118
|
+
declare const DeleteFromStorageSchema: z.ZodObject<{
|
|
119
|
+
key: z.ZodString;
|
|
120
|
+
}, z.core.$strip>;
|
|
121
|
+
|
|
122
|
+
declare class GetAssetAction extends ChaiBaseAction<GetAssetInput> {
|
|
123
|
+
private supabase;
|
|
124
|
+
constructor(supabase: SupabaseClient);
|
|
125
|
+
protected getValidationSchema(): z.ZodObject<{
|
|
126
|
+
id: z.ZodString;
|
|
127
|
+
}, z.core.$strip>;
|
|
128
|
+
execute(data: GetAssetInput): Promise<any>;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
declare type GetAssetInput = z.infer<typeof GetAssetSchema>;
|
|
132
|
+
|
|
133
|
+
declare class GetAssetsAction extends ChaiBaseAction<GetAssetsInput> {
|
|
134
|
+
private supabase;
|
|
135
|
+
constructor(supabase: SupabaseClient);
|
|
136
|
+
protected getValidationSchema(): z.ZodObject<{
|
|
137
|
+
search: z.ZodOptional<z.ZodString>;
|
|
138
|
+
page: z.ZodOptional<z.ZodNumber>;
|
|
139
|
+
limit: z.ZodOptional<z.ZodNumber>;
|
|
140
|
+
}, z.core.$strip>;
|
|
141
|
+
execute(data: GetAssetsInput): Promise<{
|
|
142
|
+
assets: Partial<any>[];
|
|
143
|
+
total: number;
|
|
144
|
+
page: number;
|
|
145
|
+
pageSize: number;
|
|
146
|
+
} | {
|
|
147
|
+
error: string;
|
|
148
|
+
status: number;
|
|
149
|
+
}>;
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
declare const GetAssetSchema: z.ZodObject<{
|
|
153
|
+
id: z.ZodString;
|
|
154
|
+
}, z.core.$strip>;
|
|
155
|
+
|
|
156
|
+
declare type GetAssetsInput = z.infer<typeof GetAssetsSchema>;
|
|
157
|
+
|
|
158
|
+
declare const GetAssetsSchema: z.ZodObject<{
|
|
159
|
+
search: z.ZodOptional<z.ZodString>;
|
|
160
|
+
page: z.ZodOptional<z.ZodNumber>;
|
|
161
|
+
limit: z.ZodOptional<z.ZodNumber>;
|
|
162
|
+
}, z.core.$strip>;
|
|
163
|
+
|
|
164
|
+
/**
|
|
165
|
+
* GET_CHAI_USER Action
|
|
166
|
+
* Fetches user information from Supabase Auth
|
|
167
|
+
*/
|
|
168
|
+
declare class GetChaiUserAction extends ChaiBaseAction<GetChaiUserInput> {
|
|
169
|
+
private supabase;
|
|
170
|
+
constructor(supabase: SupabaseClient);
|
|
171
|
+
protected getValidationSchema(): z.ZodObject<{
|
|
172
|
+
userId: z.ZodString;
|
|
173
|
+
}, z.core.$strip>;
|
|
174
|
+
execute(data: GetChaiUserInput): Promise<{
|
|
175
|
+
data: ChaiUser;
|
|
176
|
+
status: number;
|
|
177
|
+
} | {
|
|
178
|
+
error: string;
|
|
179
|
+
status: number;
|
|
180
|
+
}>;
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
declare type GetChaiUserInput = z.infer<typeof GetChaiUserSchema>;
|
|
184
|
+
|
|
185
|
+
declare const GetChaiUserSchema: z.ZodObject<{
|
|
186
|
+
userId: z.ZodString;
|
|
187
|
+
}, z.core.$strip>;
|
|
188
|
+
|
|
189
|
+
export declare const SupabaseAuthActions: (supabase: SupabaseClient) => {
|
|
190
|
+
GET_CHAI_USER: GetChaiUserAction;
|
|
191
|
+
};
|
|
192
|
+
|
|
193
|
+
export declare const SupabaseStorageActions: (supabase: SupabaseClient) => {
|
|
194
|
+
UPLOAD_ASSET: UploadAssetAction;
|
|
195
|
+
GET_ASSET: GetAssetAction;
|
|
196
|
+
GET_ASSETS: GetAssetsAction;
|
|
197
|
+
DELETE_ASSET: DeleteAssetAction;
|
|
198
|
+
UPDATE_ASSET: UpdateAssetAction;
|
|
199
|
+
UPLOAD_TO_STORAGE: UploadToStorageAction;
|
|
200
|
+
DELETE_FROM_STORAGE: DeleteFromStorageAction;
|
|
201
|
+
};
|
|
202
|
+
|
|
203
|
+
declare class UpdateAssetAction extends ChaiBaseAction<UpdateAssetInput> {
|
|
204
|
+
private supabase;
|
|
205
|
+
constructor(supabase: SupabaseClient);
|
|
206
|
+
protected getValidationSchema(): z.ZodObject<{
|
|
207
|
+
id: z.ZodString;
|
|
208
|
+
file: z.ZodOptional<z.ZodString>;
|
|
209
|
+
description: z.ZodOptional<z.ZodString>;
|
|
210
|
+
}, z.core.$strip>;
|
|
211
|
+
execute(data: UpdateAssetInput): Promise<any>;
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
declare type UpdateAssetInput = z.infer<typeof UpdateAssetSchema>;
|
|
215
|
+
|
|
216
|
+
declare const UpdateAssetSchema: z.ZodObject<{
|
|
217
|
+
id: z.ZodString;
|
|
218
|
+
file: z.ZodOptional<z.ZodString>;
|
|
219
|
+
description: z.ZodOptional<z.ZodString>;
|
|
220
|
+
}, z.core.$strip>;
|
|
221
|
+
|
|
222
|
+
declare class UploadAssetAction extends ChaiBaseAction<UploadAssetInput> {
|
|
223
|
+
private supabase;
|
|
224
|
+
constructor(supabase: SupabaseClient);
|
|
225
|
+
protected getValidationSchema(): z.ZodObject<{
|
|
226
|
+
name: z.ZodString;
|
|
227
|
+
file: z.ZodString;
|
|
228
|
+
folderId: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
229
|
+
optimize: z.ZodOptional<z.ZodBoolean>;
|
|
230
|
+
}, z.core.$strip>;
|
|
231
|
+
execute(data: UploadAssetInput): Promise<any>;
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
declare type UploadAssetInput = z.infer<typeof UploadAssetSchema>;
|
|
235
|
+
|
|
236
|
+
declare const UploadAssetSchema: z.ZodObject<{
|
|
237
|
+
name: z.ZodString;
|
|
238
|
+
file: z.ZodString;
|
|
239
|
+
folderId: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
240
|
+
optimize: z.ZodOptional<z.ZodBoolean>;
|
|
241
|
+
}, z.core.$strip>;
|
|
242
|
+
|
|
243
|
+
/**
|
|
244
|
+
* UPLOAD_TO_STORAGE Action
|
|
245
|
+
* Generic storage upload action using Supabase Storage
|
|
246
|
+
*/
|
|
247
|
+
export declare class UploadToStorageAction extends ChaiBaseAction<UploadToStorageInput> {
|
|
248
|
+
private supabase;
|
|
249
|
+
private bucketName;
|
|
250
|
+
constructor(supabase: SupabaseClient);
|
|
251
|
+
protected getValidationSchema(): z.ZodObject<{
|
|
252
|
+
file: z.ZodString;
|
|
253
|
+
fileName: z.ZodString;
|
|
254
|
+
contentType: z.ZodOptional<z.ZodString>;
|
|
255
|
+
folder: z.ZodOptional<z.ZodString>;
|
|
256
|
+
metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
|
|
257
|
+
}, z.core.$strip>;
|
|
258
|
+
execute(data: UploadToStorageInput): Promise<{
|
|
259
|
+
error: string;
|
|
260
|
+
status: number;
|
|
261
|
+
data?: undefined;
|
|
262
|
+
} | {
|
|
263
|
+
data: {
|
|
264
|
+
url: string;
|
|
265
|
+
key: string;
|
|
266
|
+
size: number;
|
|
267
|
+
metadata: Record<string, any>;
|
|
268
|
+
};
|
|
269
|
+
status: number;
|
|
270
|
+
error?: undefined;
|
|
271
|
+
}>;
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
declare type UploadToStorageInput = z.infer<typeof UploadToStorageSchema>;
|
|
275
|
+
|
|
276
|
+
declare const UploadToStorageSchema: z.ZodObject<{
|
|
277
|
+
file: z.ZodString;
|
|
278
|
+
fileName: z.ZodString;
|
|
279
|
+
contentType: z.ZodOptional<z.ZodString>;
|
|
280
|
+
folder: z.ZodOptional<z.ZodString>;
|
|
281
|
+
metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
|
|
282
|
+
}, z.core.$strip>;
|
|
283
|
+
|
|
284
|
+
export { }
|