@chaibuilder/sdk 4.0.0-beta.4 → 4.0.0-beta.41
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 +72 -50
- package/dist/{2SSKDMRQ-Difo_1pg.js → 2SSKDMRQ-CdpXONNF.js} +3 -3
- package/dist/{2SSKDMRQ-CopJgtZb.cjs → 2SSKDMRQ-Dq_oq6gn.cjs} +1 -1
- package/dist/{AP7HFJJL-BPuPBqj4.js → AP7HFJJL-CZb0rAxI.js} +1 -1
- package/dist/{AP7HFJJL-DYxDgaOs.cjs → AP7HFJJL-Do14BULM.cjs} +1 -1
- package/dist/{IconPicker-B2-oriq2.js → IconPicker-CvZSjXc6.js} +2 -2
- package/dist/{IconPicker-C0oycHbs.cjs → IconPicker-DUN9bxmQ.cjs} +1 -1
- package/dist/STRINGS-BExFecZW.js +8 -0
- package/dist/STRINGS-FNnfjF5H.cjs +1 -0
- package/dist/{WDYDFRGG-DbejaRPK.cjs → WDYDFRGG-DfczfcZ8.cjs} +1 -1
- package/dist/{WDYDFRGG-KK8pkcW1.js → WDYDFRGG-Dxa2zFdt.js} +4 -4
- package/dist/{actions-registery-y_ENc8zj.js → actions-registery-CMKfEXxX.js} +3397 -3202
- package/dist/actions-registery-CqhNZFV3.cjs +481 -0
- package/dist/actions.cjs +1 -1
- package/dist/actions.d.ts +0 -158
- package/dist/actions.js +3 -3
- package/dist/{active-in-another-tab-DkR2HWI4.js → active-in-another-tab-BREv3Xj8.js} +5 -5
- package/dist/{active-in-another-tab-Cu_ASKtx.cjs → active-in-another-tab-C9o276yY.cjs} +1 -1
- package/dist/{add-new-language-page-CBY0RR6q.js → add-new-language-page-C4PSVDV5.js} +4 -4
- package/dist/{add-new-language-page-BXuwluuU.cjs → add-new-language-page-jHLJjrl1.cjs} +1 -1
- package/dist/{add-new-page-C_PzKby8.cjs → add-new-page-BPPMxBYi.cjs} +1 -1
- package/dist/add-new-page-DomZuT16.js +31 -0
- package/dist/{ai-panel-content--YM01Aly.js → ai-panel-content-CsmUoTCg.js} +6 -6
- package/dist/{ai-panel-content-rRmJdH7L.cjs → ai-panel-content-DlS51Qef.cjs} +1 -1
- package/dist/ai-panel-default-lang-BRVlAMMU.js +317 -0
- package/dist/ai-panel-default-lang-DVKDEnbe.cjs +3 -0
- package/dist/ai-panel-other-lang-B-2xJz2W.cjs +1 -0
- package/dist/ai-panel-other-lang-BPVS6lO_.js +132 -0
- package/dist/{ai-prompt-input-DueQYNf-.js → ai-prompt-input-B0FMhaLB.js} +30 -34
- package/dist/{ai-prompt-input-N9PcYCFa.cjs → ai-prompt-input-CY2pBPzO.cjs} +1 -1
- package/dist/{ai-translation-prompt-B36F3d7K.js → ai-translation-prompt-6LlaU9LO.js} +2 -2
- package/dist/{ai-translation-prompt-IAdWMNZb.cjs → ai-translation-prompt-BwhKmgC3.cjs} +1 -1
- package/dist/apply-binding-BuwI_Uf5.cjs +41 -0
- package/dist/apply-binding-RQRSIe56.js +942 -0
- package/dist/change-password-modal-BlSTfit6.js +137 -0
- package/dist/change-password-modal-wbCcGfDM.cjs +1 -0
- package/dist/{code-display-DloSPyPr.cjs → code-display-BR-gij5j.cjs} +1 -1
- package/dist/{code-display-Ck81Id9K.js → code-display-DdWcOQ_i.js} +1 -1
- package/dist/code-editor-BC_saYAw.cjs +1 -0
- package/dist/code-editor-Be5VT6om.js +57 -0
- package/dist/{continue-editing-in-this-client-DmGFLHXw.cjs → continue-editing-in-this-client-Bs_3q1hH.cjs} +1 -1
- package/dist/{continue-editing-in-this-client-Dm9cCj7K.js → continue-editing-in-this-client-Z1rBUPU8.js} +3 -3
- package/dist/core-czmLeR0h.cjs +1 -0
- package/dist/core-nSRy3D7z.js +54 -0
- package/dist/core.cjs +1 -1
- package/dist/core.d.ts +285 -103
- package/dist/core.js +71 -42
- package/dist/{css-import-modal-9P_0uNa4.js → css-import-modal-DMZRgpy0.js} +8 -8
- package/dist/{css-import-modal-Rh1QAVxo.cjs → css-import-modal-QaTHJ7CT.cjs} +1 -1
- package/dist/delete-page-BoP3I06P.js +84 -0
- package/dist/delete-page-CjXYHAsS.cjs +1 -0
- package/dist/{design-token-usage-MNYsFlPG.js → design-token-usage-DFanW2r-.js} +26 -26
- package/dist/{design-token-usage-CXglXgcJ.cjs → design-token-usage-kEPgi-3C.cjs} +1 -1
- package/dist/{digital-asset-manager-CqCWBO0s.js → digital-asset-manager-BbI7Ye34.js} +6 -6
- package/dist/digital-asset-manager-N8tcW28y.cjs +1 -0
- package/dist/{duplicate-page-DzZByALW.cjs → duplicate-page-B-4nFU4j.cjs} +1 -1
- package/dist/{duplicate-page-BknLfqr0.js → duplicate-page-C6y7FdRQ.js} +7 -7
- package/dist/{dynamic-page-selector-WA007Sni.cjs → dynamic-page-selector-Cq4U-49i.cjs} +1 -1
- package/dist/{dynamic-page-selector-DoW7OyUB.js → dynamic-page-selector-DQCWphi0.js} +16 -16
- package/dist/fonts/bungee/Bungee-Regular.woff2 +0 -0
- package/dist/fonts/dm_sans/dm-sans-variable.woff2 +0 -0
- package/dist/fonts/geist/Geist-VariableFont_wght.ttf +0 -0
- package/dist/fonts/geist/Geist-VariableFont_wght.woff2 +0 -0
- package/dist/fonts/geist/geist-variable.woff2 +0 -0
- package/dist/fonts/geist-mono/GeistMono-VariableFont_wght.woff2 +0 -0
- package/dist/fonts/inter/inter-latin.woff2 +0 -0
- package/dist/fonts/inter/inter-variable.woff2 +1449 -0
- package/dist/fonts/lato/lato-variable.woff2 +0 -0
- package/dist/fonts/lavishly_yours/lavishly-yours.woff2 +11 -0
- package/dist/fonts/merriweather/merriweather-variable.woff2 +11 -0
- package/dist/fonts/montserrat/montserrat-variable.woff2 +0 -0
- package/dist/fonts/nunito_sans/nunito-sans-variable.woff2 +11 -0
- package/dist/fonts/open_sans/open-sans-variable.woff2 +0 -0
- package/dist/fonts/oswald/oswald-variable.woff2 +0 -0
- package/dist/fonts/playfair_display/playfair-display-variable.woff2 +11 -0
- package/dist/fonts/poppins/poppins-variable.woff2 +0 -0
- package/dist/fonts/raleway/raleway-variable.woff2 +0 -0
- package/dist/fonts/roboto/roboto-variable.woff2 +11 -0
- package/dist/fonts/source_sans_3/source-sans-3-variable.woff2 +11 -0
- package/dist/fonts/ubuntu/ubuntu-variable.woff2 +0 -0
- package/dist/fonts-B3UYxuJI.js +25 -0
- package/dist/fonts-D5fTqvSS.cjs +1 -0
- package/dist/{get-chai-builder-tailwind-config-BFePCEIS.cjs → get-chai-builder-tailwind-config-7CxFxEYL.cjs} +1 -1
- package/dist/{get-chai-builder-tailwind-config-BXf_xLHk.js → get-chai-builder-tailwind-config-DC4sDOYK.js} +5 -5
- package/dist/{get-chai-builder-theme-BApShjRz.cjs → get-chai-builder-theme-B5RkBTsB.cjs} +1 -1
- package/dist/{get-chai-builder-theme-DDVRJQ6Z.js → get-chai-builder-theme-BpuwSLeS.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-CqwaVxO2.cjs → image-editor-565A0NpE.cjs} +1 -1
- package/dist/{image-editor-CQnNtak2.js → image-editor-Dz_HQ0I8.js} +1 -1
- package/dist/index-3pEi7VzS.cjs +5 -0
- package/dist/index-C3CV1lXL.cjs +160 -0
- package/dist/index-CDVuf3C1.js +5118 -0
- package/dist/{index-rAcNbjk_.js → index-wBr2Ml98.js} +6152 -6102
- package/dist/{json-diff-viewer-CLuUHiPU.cjs → json-diff-viewer-CMYFM6D6.cjs} +7 -7
- package/dist/{json-diff-viewer-CMvGUvJ2.js → json-diff-viewer-DG7a5-2B.js} +87 -85
- package/dist/{lang-panel-CnwTb05j.js → lang-panel-BvGiJJ8s.js} +26 -26
- package/dist/lang-panel-D97iJH-l.cjs +1 -0
- package/dist/library-blocks/bento/agency-showcase/agency-showcase.html +175 -0
- package/dist/library-blocks/bento/agency-showcase/agency-showcase.webp +0 -0
- package/dist/library-blocks/bento/creative-portfolio/creative-portfolio.html +116 -0
- package/dist/library-blocks/bento/creative-portfolio/creative-portfolio.webp +0 -0
- package/dist/library-blocks/bento/product-features/product-features.html +159 -0
- package/dist/library-blocks/bento/product-features/product-features.webp +0 -0
- package/dist/library-blocks/bento/saas-dashboard/saas-dashboard.html +182 -0
- package/dist/library-blocks/bento/saas-dashboard/saas-dashboard.webp +0 -0
- package/dist/library-blocks/bento/startup-metrics/startup-metrics.html +170 -0
- package/dist/library-blocks/bento/startup-metrics/startup-metrics.webp +0 -0
- package/dist/library-blocks/blocks-list.json +149 -0
- package/dist/library-blocks/feature/agency-services/agency-services.html +194 -0
- package/dist/library-blocks/feature/agency-services/agency-services.webp +0 -0
- package/dist/library-blocks/feature/consulting-firm/consulting-firm.html +219 -0
- package/dist/library-blocks/feature/consulting-firm/consulting-firm.webp +0 -0
- package/dist/library-blocks/feature/design-studio/design-studio.html +190 -0
- package/dist/library-blocks/feature/design-studio/design-studio.webp +0 -0
- package/dist/library-blocks/feature/freelancer-toolkit/freelancer-toolkit.html +195 -0
- package/dist/library-blocks/feature/freelancer-toolkit/freelancer-toolkit.webp +0 -0
- package/dist/library-blocks/feature/marketing-agency/marketing-agency.html +212 -0
- package/dist/library-blocks/feature/marketing-agency/marketing-agency.webp +0 -0
- package/dist/library-blocks/footer/creative-agency/creative-agency.html +64 -0
- package/dist/library-blocks/footer/creative-agency/creative-agency.webp +0 -0
- package/dist/library-blocks/footer/minimal-portfolio/minimal-portfolio.html +106 -0
- package/dist/library-blocks/footer/minimal-portfolio/minimal-portfolio.webp +0 -0
- package/dist/library-blocks/footer/saas-startup/saas-startup.html +117 -0
- package/dist/library-blocks/footer/saas-startup/saas-startup.webp +0 -0
- package/dist/library-blocks/hero/creative-agency/creative-agency.html +117 -0
- package/dist/library-blocks/hero/creative-agency/creative-agency.webp +0 -0
- package/dist/library-blocks/hero/developer-focused/developer-focused.html +124 -0
- package/dist/library-blocks/hero/developer-focused/developer-focused.webp +0 -0
- package/dist/library-blocks/hero/minimal-saas/minimal-saas.html +98 -0
- package/dist/library-blocks/hero/minimal-saas/minimal-saas.webp +0 -0
- package/dist/library-blocks/hero/portfolio-showcase/portfolio-showcase.html +148 -0
- package/dist/library-blocks/hero/portfolio-showcase/portfolio-showcase.webp +0 -0
- package/dist/library-blocks/hero/startup-landing/startup-landing.html +130 -0
- package/dist/library-blocks/hero/startup-landing/startup-landing.webp +0 -0
- package/dist/library-blocks/navbar/creative-agency/creative-agency.html +139 -0
- package/dist/library-blocks/navbar/creative-agency/creative-agency.webp +0 -0
- package/dist/library-blocks/navbar/minimal-portfolio/minimal-portfolio.html +164 -0
- package/dist/library-blocks/navbar/minimal-portfolio/minimal-portfolio.webp +0 -0
- package/dist/library-blocks/navbar/saas-startup/saas-startup.html +129 -0
- package/dist/library-blocks/navbar/saas-startup/saas-startup.webp +0 -0
- package/dist/manage-design-tokens-4Gu6TMKZ.js +446 -0
- package/dist/manage-design-tokens-Do9Kptp3.cjs +1 -0
- package/dist/manage-design-tokens-modal-Btbdgoun.cjs +1 -0
- package/dist/manage-design-tokens-modal-CkyFE8NW.js +161 -0
- package/dist/{mark-as-template-DBLshWb5.js → mark-as-template-Djhnj93U.js} +11 -11
- package/dist/{mark-as-template-CpWEBJGd.cjs → mark-as-template-QPJ0DqxL.cjs} +1 -1
- package/dist/{nested-path-selector-content-C2sD9dkq.cjs → nested-path-selector-content-BcmSxXxL.cjs} +1 -1
- package/dist/{nested-path-selector-content-6OBJ8LG8.js → nested-path-selector-content-DkPIHcVj.js} +2 -2
- package/dist/{no-language-page-content-CzENgtnu.js → no-language-page-content-DTq-5StU.js} +9 -9
- package/dist/{no-language-page-content-BvPDdccK.cjs → no-language-page-content-ZQz4Kr0-.cjs} +1 -1
- package/dist/{no-language-page-dialog-CbYI2cVg.js → no-language-page-dialog-2rA-YBbC.js} +2 -2
- package/dist/{no-language-page-dialog-CgW4yJBC.cjs → no-language-page-dialog-BsLkwJID.cjs} +1 -1
- package/dist/{page-creator-Cc83uQqw.js → page-creator-Dzpc0_dN.js} +143 -143
- package/dist/page-creator-lcDUpPjh.cjs +1 -0
- package/dist/{page-lock-CT7SmQqp.cjs → page-lock-B2GU-1YM.cjs} +1 -1
- package/dist/{page-lock-BJUkyxdh.js → page-lock-ulFtdOkt.js} +2 -2
- package/dist/{page-locked-dialog-DsEbWRed.js → page-locked-dialog-B9VpkvhN.js} +22 -22
- package/dist/page-locked-dialog-CJ53Z6sQ.cjs +1 -0
- package/dist/page-manager-new-CkoS0B1i.cjs +1 -0
- package/dist/page-manager-new-OoC8W7Yn.js +408 -0
- package/dist/{page-manager-search-and-filter-Bfm0j1gg.cjs → page-manager-search-and-filter-BosoN3wg.cjs} +1 -1
- package/dist/{page-manager-search-and-filter-zq-LfhQ1.js → page-manager-search-and-filter-JfSTGlvp.js} +30 -29
- package/dist/{page-revisions-content-D38G2tJM.js → page-revisions-content-DsFh5itr.js} +133 -122
- package/dist/page-revisions-content-Dtd-t1N3.cjs +1 -0
- package/dist/pages.cjs +1 -1
- package/dist/pages.d.ts +330 -96
- package/dist/pages.js +23 -19
- package/dist/plugin-BSjgGgwo.js +248 -0
- package/dist/plugin-DHpuZZXz.cjs +22 -0
- package/dist/publish-pages-content-C7oS7pkz.cjs +1 -0
- package/dist/{publish-pages-content-CS7f41Ac.js → publish-pages-content-DJc7iu8d.js} +39 -39
- package/dist/{register-chai-top-bar-ESJHs5s-.js → register-chai-top-bar-D6GjnauV.js} +87 -87
- package/dist/register-chai-top-bar-DyW9GPzV.cjs +1 -0
- package/dist/render.cjs +2 -2
- package/dist/render.d.ts +20 -18
- package/dist/render.js +133 -132
- package/dist/{rte-widget-modal-BKNx2wln.cjs → rte-widget-modal-BKQaoxh9.cjs} +1 -1
- package/dist/{rte-widget-modal-D6Zik0Ta.js → rte-widget-modal-BdBYmqgs.js} +10 -10
- package/dist/runtime-client.cjs +1 -0
- package/dist/runtime-client.d.ts +158 -0
- package/dist/runtime-client.js +32 -0
- package/dist/runtime.cjs +11 -1
- package/dist/runtime.d.ts +153 -270
- package/dist/runtime.js +107 -71
- package/dist/{save-to-lib-WwOzbgiF.js → save-to-lib-5nwSdZ9R.js} +153 -147
- package/dist/save-to-lib-D0WdH4lq.cjs +1 -0
- package/dist/sdk.css +1 -1
- package/dist/{selected-block-display-B1SG_UXw.js → selected-block-display-D8ROZHHv.js} +12 -12
- package/dist/{selected-block-display-BOgnQRLF.cjs → selected-block-display-DjYeUPdU.cjs} +1 -1
- package/dist/{seo-panel-BkOgRoWd.js → seo-panel-BbyRNAEo.js} +27 -27
- package/dist/seo-panel-DRjSxmk5.cjs +2 -0
- package/dist/shared-json-ld-BbNLdzCO.cjs +1 -0
- package/dist/{shared-json-ld-uka9TOgA.js → shared-json-ld-EPbpTI9V.js} +88 -88
- package/dist/{slug-input-Cyd6NR6J.cjs → slug-input-CIzxXknM.cjs} +1 -1
- package/dist/{slug-input-DHLmUNrH.js → slug-input-DSbJecNr.js} +8 -8
- package/dist/supabase-actions.cjs +1 -1
- package/dist/supabase-actions.d.ts +45 -0
- package/dist/supabase-actions.js +380 -275
- package/dist/{take-over-request-Ca0X-qyf.js → take-over-request-BOGDk0H4.js} +13 -13
- package/dist/take-over-request-BXntCMdj.cjs +1 -0
- package/dist/{translation-warning-modal-pSZVKcNW.cjs → translation-warning-modal-DhJaOyLo.cjs} +1 -1
- package/dist/{translation-warning-modal-DrpFeI83.js → translation-warning-modal-reVr0L9e.js} +9 -9
- package/dist/types.cjs +1 -0
- package/dist/types.d.ts +756 -0
- package/dist/types.js +1 -0
- package/dist/{unmark-as-template-BMqgelv-.js → unmark-as-template-BM85Y7WK.js} +11 -11
- package/dist/{unmark-as-template-DF1Ms4VN.cjs → unmark-as-template-DOPyeU7R.cjs} +1 -1
- package/dist/unpublish-page-DHfds-1-.js +28 -0
- package/dist/{unpublish-page-Bsq2yEqQ.cjs → unpublish-page-Dz028Bzp.cjs} +1 -1
- package/dist/unpublished-partials-modal-BO5ZZdTw.js +52 -0
- package/dist/unpublished-partials-modal-CMqQa9-m.cjs +1 -0
- package/dist/utils.cjs +1 -1
- package/dist/utils.d.ts +6 -6
- package/dist/utils.js +2 -2
- package/dist/web-blocks.cjs +1 -1
- package/dist/web-blocks.js +360 -351
- package/dist/{web-preview-kres0aG7.cjs → web-preview-5MzixBt5.cjs} +1 -1
- package/dist/{web-preview-D6h1L2nV.js → web-preview-BNjG8s8A.js} +2 -2
- package/package.json +34 -35
- package/dist/actions-registery-JdxhXhT6.cjs +0 -418
- package/dist/add-new-page-DJLJFLAd.js +0 -31
- package/dist/ai-panel-default-lang-BZl0tPYo.js +0 -341
- package/dist/ai-panel-default-lang-D2zhXvKP.cjs +0 -3
- package/dist/ai-panel-other-lang-Bfjk2CYZ.js +0 -162
- package/dist/ai-panel-other-lang-Y4bEKHoG.cjs +0 -1
- package/dist/apply-binding-BvWfJCSZ.js +0 -841
- package/dist/apply-binding-IsUf6UWJ.cjs +0 -1
- package/dist/code-editor-Bb7JumZy.js +0 -51
- package/dist/code-editor-DQB8lAOk.cjs +0 -1
- package/dist/core-Dr7QYemB.js +0 -56
- package/dist/core-Y0lXLwkq.cjs +0 -1
- package/dist/delete-design-token-BG8yHcS5.cjs +0 -1
- package/dist/delete-design-token-COvR4G1S.js +0 -40
- package/dist/delete-page-CNucxe4P.js +0 -71
- package/dist/delete-page-DAvEjHwF.cjs +0 -1
- package/dist/digital-asset-manager-CB5MRBcW.cjs +0 -1
- package/dist/fonts/GeistMonoVF.woff +0 -0
- package/dist/fonts/GeistVF.woff +0 -0
- package/dist/fonts-B-Xt29pe.cjs +0 -1
- package/dist/fonts-DRly3Wzd.js +0 -78
- package/dist/image-compression-DZ9WMmyn.cjs +0 -1
- package/dist/index-B-rSiAp_.cjs +0 -1
- package/dist/index-C0-pgg_p.cjs +0 -5
- package/dist/index-C99FhuF1.cjs +0 -160
- package/dist/index-Dno42B0a.js +0 -4734
- package/dist/index-Dxfyt4d4.js +0 -39
- package/dist/lang-panel-fDCYm5Jm.cjs +0 -1
- package/dist/manage-design-tokens-BsSZE9Vs.js +0 -241
- package/dist/manage-design-tokens-BvH5KTJX.cjs +0 -1
- package/dist/page-creator-g8GqgcKH.cjs +0 -1
- package/dist/page-locked-dialog-Co5b9XIZ.cjs +0 -1
- package/dist/page-manager-new-5rFP5DyQ.js +0 -395
- package/dist/page-manager-new-BOkJImo2.cjs +0 -1
- package/dist/page-revisions-content-ag-MHBGr.cjs +0 -1
- package/dist/plugin-BGlQf0iy.cjs +0 -22
- package/dist/plugin-C-ht41UZ.js +0 -245
- package/dist/publish-pages-content-BiX-GMLw.cjs +0 -1
- package/dist/register-chai-top-bar-BqwKw4uy.cjs +0 -1
- package/dist/save-to-lib-ffjCZYJ5.cjs +0 -1
- package/dist/seo-panel-FjS1UF_y.cjs +0 -2
- package/dist/shared-json-ld-yJkXjENy.cjs +0 -1
- package/dist/take-over-request-CmpJVe9T.cjs +0 -1
- package/dist/theme-panel-footer-BUXIu252.js +0 -26
- package/dist/theme-panel-footer-CKO9YYwZ.cjs +0 -1
- package/dist/unpublish-page-BJ0Bsvt2.js +0 -28
package/dist/supabase-actions.js
CHANGED
|
@@ -1,70 +1,128 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var
|
|
4
|
-
import { g as
|
|
5
|
-
import { isEmpty as
|
|
6
|
-
import
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
constructor(
|
|
10
|
-
this.appId =
|
|
11
|
-
}
|
|
12
|
-
appendUpdatedAtToUrl(
|
|
13
|
-
if (
|
|
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-CMKfEXxX.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
|
+
constructor(t, e, r) {
|
|
10
|
+
this.appId = t, this.userId = e, this.supabase = r;
|
|
11
|
+
}
|
|
12
|
+
appendUpdatedAtToUrl(t, e) {
|
|
13
|
+
if (f(t))
|
|
14
14
|
return "";
|
|
15
|
-
const
|
|
16
|
-
return
|
|
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
|
-
getBufferFromBase64(
|
|
18
|
+
getBufferFromBase64(t) {
|
|
19
19
|
try {
|
|
20
|
-
const e =
|
|
20
|
+
const e = t.split(",")[1] || t;
|
|
21
21
|
return Buffer.from(e, "base64");
|
|
22
22
|
} catch {
|
|
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(
|
|
101
|
+
async uploadImageFile(t, e, r, a) {
|
|
31
102
|
try {
|
|
32
|
-
const s = this.getBufferFromBase64(
|
|
33
|
-
if (!
|
|
34
|
-
throw new Error(`Invalid image format: ${
|
|
35
|
-
const
|
|
36
|
-
|
|
37
|
-
if (o && u.length > 120 * 1024) {
|
|
38
|
-
const O = Math.floor(90 * (122880 / u.length));
|
|
39
|
-
a = await w(s).webp({ quality: O }).resize({ width: Math.min(n.width || 2e3, 2e3) }).toBuffer();
|
|
40
|
-
}
|
|
41
|
-
const d = await w(a).metadata(), m = await w(s).webp({ quality: 70 }).resize({ width: 300 }).toBuffer(), p = t.split("."), h = p.length > 1 ? p.slice(0, -1).join(".") : t, g = `${k(h)}.webp`, _ = `${g}_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:
|
|
109
|
+
A.setContext({ appId: this.appId, userId: this.userId });
|
|
110
|
+
const U = await A.execute({
|
|
111
|
+
file: s.toString("base64"),
|
|
47
112
|
fileName: g,
|
|
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: _,
|
|
56
|
-
contentType: "image/webp",
|
|
57
|
-
folder: x
|
|
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" };
|
|
@@ -73,318 +131,326 @@ class A {
|
|
|
73
131
|
/**
|
|
74
132
|
* Upload an SVG file using UPLOAD_TO_STORAGE action
|
|
75
133
|
*/
|
|
76
|
-
async uploadSvgFile(
|
|
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
|
|
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
|
-
file:
|
|
168
|
+
file: t,
|
|
111
169
|
folderId: e,
|
|
112
|
-
name:
|
|
113
|
-
optimize:
|
|
170
|
+
name: r,
|
|
171
|
+
optimize: a = !0
|
|
114
172
|
}) {
|
|
115
173
|
var s;
|
|
116
174
|
try {
|
|
117
|
-
const
|
|
118
|
-
if ("error" in
|
|
119
|
-
return
|
|
120
|
-
const
|
|
121
|
-
name:
|
|
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);
|
|
176
|
+
if ("error" in c)
|
|
177
|
+
return c;
|
|
178
|
+
const d = {
|
|
179
|
+
name: r,
|
|
122
180
|
app: this.appId,
|
|
123
|
-
url:
|
|
124
|
-
thumbnailUrl:
|
|
125
|
-
size: (s =
|
|
126
|
-
width:
|
|
127
|
-
height:
|
|
128
|
-
format:
|
|
181
|
+
url: c.url,
|
|
182
|
+
thumbnailUrl: c.thumbnailUrl,
|
|
183
|
+
size: (s = c.size) == null ? void 0 : s.toString(),
|
|
184
|
+
width: c.width,
|
|
185
|
+
height: c.height,
|
|
186
|
+
format: c.mimeType.split("/")[1],
|
|
129
187
|
folderId: e,
|
|
130
|
-
type:
|
|
188
|
+
type: c.mimeType.startsWith("image/") ? "image" : "file",
|
|
131
189
|
createdBy: this.userId,
|
|
132
190
|
updatedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
133
|
-
}, { data:
|
|
134
|
-
if (
|
|
135
|
-
throw new Error(`Failed to store asset in database: ${
|
|
191
|
+
}, { data: n, error: l } = await this.supabase.from("app_assets").insert(d).select("*").single();
|
|
192
|
+
if (l)
|
|
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
|
-
async getAsset({ id:
|
|
213
|
+
async getAsset({ id: t }) {
|
|
156
214
|
try {
|
|
157
|
-
const { data: e, error:
|
|
158
|
-
if (
|
|
159
|
-
throw new Error(`Failed to fetch asset: ${
|
|
160
|
-
return
|
|
215
|
+
const { data: e, error: r } = await this.supabase.from("app_assets").select("*").eq("id", t).eq("app", this.appId).single();
|
|
216
|
+
if (r)
|
|
217
|
+
throw new Error(`Failed to fetch asset: ${r.message}`);
|
|
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
|
}
|
|
164
222
|
}
|
|
165
223
|
async getAssets({
|
|
166
|
-
search:
|
|
224
|
+
search: t = "",
|
|
167
225
|
page: e = 1,
|
|
168
|
-
limit:
|
|
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
|
-
|
|
174
|
-
const { data:
|
|
175
|
-
if (
|
|
176
|
-
throw new Error(
|
|
231
|
+
t && (s = s.or(`name.ilike.%${t}%,description.ilike.%${t}%`));
|
|
232
|
+
const { data: i, error: c, count: d } = await s.range(a, a + r - 1);
|
|
233
|
+
if (c)
|
|
234
|
+
throw new Error(c.message);
|
|
177
235
|
return {
|
|
178
|
-
assets:
|
|
179
|
-
total:
|
|
236
|
+
assets: i.map((l) => (I(l, "url", this.appendUpdatedAtToUrl(l.url, l.updatedAt)), I(l, "thsupabaseumbnailUrl", this.appendUpdatedAtToUrl(l.thumbnailUrl || "", l.updatedAt)), l)),
|
|
237
|
+
total: d || 0,
|
|
180
238
|
page: e,
|
|
181
|
-
pageSize:
|
|
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
|
-
async deleteAsset({ id:
|
|
245
|
+
async deleteAsset({ id: t }) {
|
|
188
246
|
try {
|
|
189
|
-
const { data: e, error:
|
|
190
|
-
if (
|
|
191
|
-
throw new Error(`Failed to fetch asset: ${
|
|
247
|
+
const { data: e, error: r } = await this.supabase.from("app_assets").select("*").eq("id", t).eq("app", this.appId).single();
|
|
248
|
+
if (r)
|
|
249
|
+
throw new Error(`Failed to fetch asset: ${r.message}`);
|
|
192
250
|
if (e.url)
|
|
193
251
|
try {
|
|
194
|
-
const
|
|
195
|
-
if (
|
|
196
|
-
const
|
|
197
|
-
if (
|
|
198
|
-
const
|
|
252
|
+
const i = new URL(e.url).pathname.split("/"), c = i.indexOf("dam-assets");
|
|
253
|
+
if (c !== -1) {
|
|
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" };
|
|
214
272
|
}
|
|
215
273
|
}
|
|
216
274
|
async updateAsset({
|
|
217
|
-
id:
|
|
275
|
+
id: t,
|
|
218
276
|
file: e,
|
|
219
|
-
description:
|
|
277
|
+
description: r
|
|
220
278
|
}) {
|
|
221
|
-
var
|
|
279
|
+
var a, s;
|
|
222
280
|
try {
|
|
223
|
-
const { data:
|
|
224
|
-
if (
|
|
225
|
-
throw new Error(`Failed to fetch asset: ${
|
|
226
|
-
const
|
|
227
|
-
if (
|
|
228
|
-
const p = ((
|
|
281
|
+
const { data: i, error: c } = await this.supabase.from("app_assets").select("*").eq("id", t).single();
|
|
282
|
+
if (c)
|
|
283
|
+
throw new Error(`Failed to fetch asset: ${c.message}`);
|
|
284
|
+
const d = {};
|
|
285
|
+
if (r !== void 0 && (d.description = r, d.updatedAt = (/* @__PURE__ */ new Date()).toISOString()), e) {
|
|
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:
|
|
234
|
-
if (
|
|
235
|
-
throw new Error(`Failed to update asset: ${
|
|
236
|
-
return
|
|
237
|
-
|
|
291
|
+
const { data: n, error: l } = await this.supabase.from("app_assets").update(d).eq("id", t).select().single();
|
|
292
|
+
if (l)
|
|
293
|
+
throw new Error(`Failed to update asset: ${l.message}`);
|
|
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
|
|
253
|
-
constructor(
|
|
254
|
-
super(), this.supabase =
|
|
318
|
+
class D extends E {
|
|
319
|
+
constructor(t) {
|
|
320
|
+
super(), this.supabase = t;
|
|
255
321
|
}
|
|
256
322
|
getValidationSchema() {
|
|
257
|
-
return
|
|
323
|
+
return O;
|
|
258
324
|
}
|
|
259
|
-
async execute(
|
|
325
|
+
async execute(t) {
|
|
260
326
|
try {
|
|
261
327
|
if (!this.context)
|
|
262
328
|
return { error: "Context not set", status: 400 };
|
|
263
|
-
const { appId: e, userId:
|
|
264
|
-
if (!
|
|
329
|
+
const { appId: e, userId: r } = this.context;
|
|
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
|
|
277
|
-
constructor(
|
|
278
|
-
super(), this.supabase =
|
|
342
|
+
class G extends E {
|
|
343
|
+
constructor(t) {
|
|
344
|
+
super(), this.supabase = t;
|
|
279
345
|
}
|
|
280
346
|
getValidationSchema() {
|
|
281
|
-
return
|
|
347
|
+
return L;
|
|
282
348
|
}
|
|
283
|
-
async execute(
|
|
349
|
+
async execute(t) {
|
|
284
350
|
try {
|
|
285
351
|
if (!this.context)
|
|
286
352
|
return { error: "Context not set", status: 400 };
|
|
287
|
-
const { appId: e, userId:
|
|
288
|
-
if (!
|
|
353
|
+
const { appId: e, userId: r } = this.context;
|
|
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
|
|
303
|
-
constructor(
|
|
304
|
-
super(), this.supabase =
|
|
368
|
+
class F extends E {
|
|
369
|
+
constructor(t) {
|
|
370
|
+
super(), this.supabase = t;
|
|
305
371
|
}
|
|
306
372
|
getValidationSchema() {
|
|
307
|
-
return
|
|
373
|
+
return N;
|
|
308
374
|
}
|
|
309
|
-
async execute(
|
|
375
|
+
async execute(t) {
|
|
310
376
|
try {
|
|
311
377
|
if (!this.context)
|
|
312
378
|
return { error: "Context not set", status: 400 };
|
|
313
|
-
const { appId: e, userId:
|
|
314
|
-
if (!
|
|
379
|
+
const { appId: e, userId: r } = this.context;
|
|
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
|
|
327
|
-
constructor(
|
|
328
|
-
super(), this.supabase =
|
|
392
|
+
class v extends E {
|
|
393
|
+
constructor(t) {
|
|
394
|
+
super(), this.supabase = t;
|
|
329
395
|
}
|
|
330
396
|
getValidationSchema() {
|
|
331
|
-
return
|
|
397
|
+
return M;
|
|
332
398
|
}
|
|
333
|
-
async execute(
|
|
399
|
+
async execute(t) {
|
|
334
400
|
try {
|
|
335
401
|
if (!this.context)
|
|
336
402
|
return { error: "Context not set", status: 400 };
|
|
337
|
-
const { appId: e, userId:
|
|
338
|
-
if (!
|
|
403
|
+
const { appId: e, userId: r } = this.context;
|
|
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
|
|
353
|
-
constructor(
|
|
354
|
-
super(), this.supabase =
|
|
418
|
+
class $ extends E {
|
|
419
|
+
constructor(t) {
|
|
420
|
+
super(), this.supabase = t;
|
|
355
421
|
}
|
|
356
422
|
getValidationSchema() {
|
|
357
|
-
return
|
|
423
|
+
return B;
|
|
358
424
|
}
|
|
359
|
-
async execute(
|
|
425
|
+
async execute(t) {
|
|
360
426
|
try {
|
|
361
427
|
if (!this.context)
|
|
362
428
|
return { error: "Context not set", status: 400 };
|
|
363
|
-
const { appId: e, userId:
|
|
364
|
-
if (!
|
|
429
|
+
const { appId: e, userId: r } = this.context;
|
|
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
|
|
377
|
-
constructor(
|
|
378
|
-
super(), this.supabase =
|
|
442
|
+
class j extends E {
|
|
443
|
+
constructor(t) {
|
|
444
|
+
super(), this.supabase = t;
|
|
379
445
|
}
|
|
380
446
|
getValidationSchema() {
|
|
381
|
-
return
|
|
447
|
+
return R;
|
|
382
448
|
}
|
|
383
|
-
async execute(
|
|
384
|
-
var e,
|
|
449
|
+
async execute(t) {
|
|
450
|
+
var e, r, a, s, i, c;
|
|
385
451
|
try {
|
|
386
|
-
const { userId:
|
|
387
|
-
return
|
|
452
|
+
const { userId: d } = t, { data: n, error: l } = await this.supabase.auth.admin.getUserById(d);
|
|
453
|
+
return l ? {
|
|
388
454
|
data: {
|
|
389
455
|
id: "unknown",
|
|
390
456
|
email: "unknown@chaibuilder.com",
|
|
@@ -394,10 +460,10 @@ class N extends f {
|
|
|
394
460
|
status: 200
|
|
395
461
|
} : {
|
|
396
462
|
data: {
|
|
397
|
-
id: ((e =
|
|
398
|
-
email: ((
|
|
399
|
-
name: ((s = (
|
|
400
|
-
avatar: ((
|
|
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,49 +480,87 @@ class N extends f {
|
|
|
414
480
|
}
|
|
415
481
|
}
|
|
416
482
|
}
|
|
417
|
-
const
|
|
418
|
-
|
|
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")
|
|
488
|
+
}).refine((u) => u.newPassword === u.confirmPassword, {
|
|
489
|
+
message: "Confirm password does not match",
|
|
490
|
+
path: ["confirmPassword"]
|
|
491
|
+
});
|
|
492
|
+
class V extends E {
|
|
493
|
+
constructor(t) {
|
|
494
|
+
super(), this.supabase = t;
|
|
495
|
+
}
|
|
496
|
+
getValidationSchema() {
|
|
497
|
+
return C;
|
|
498
|
+
}
|
|
499
|
+
async execute(t) {
|
|
500
|
+
try {
|
|
501
|
+
const { email: e, oldPassword: r, newPassword: a } = t, { error: s } = await this.supabase.auth.signInWithPassword({
|
|
502
|
+
email: e,
|
|
503
|
+
password: r
|
|
504
|
+
});
|
|
505
|
+
if (s)
|
|
506
|
+
throw new _("Current password is incorrect", "INVALID_PASSWORD", 400);
|
|
507
|
+
const { error: i } = await this.supabase.auth.updateUser({
|
|
508
|
+
password: a
|
|
509
|
+
});
|
|
510
|
+
if (i)
|
|
511
|
+
throw new _(i.message || "Failed to update password", "UPDATE_FAILED", 400);
|
|
512
|
+
return {
|
|
513
|
+
data: { message: "Password changed successfully" },
|
|
514
|
+
status: 200
|
|
515
|
+
};
|
|
516
|
+
} catch (e) {
|
|
517
|
+
throw e;
|
|
518
|
+
}
|
|
519
|
+
}
|
|
520
|
+
}
|
|
521
|
+
const q = o.object({
|
|
522
|
+
key: o.string()
|
|
419
523
|
// Storage key/path to delete
|
|
420
524
|
});
|
|
421
|
-
class
|
|
525
|
+
class z extends E {
|
|
422
526
|
constructor(e) {
|
|
423
527
|
super();
|
|
424
|
-
|
|
528
|
+
w(this, "bucketName", "dam-assets");
|
|
425
529
|
this.supabase = e;
|
|
426
530
|
}
|
|
427
531
|
getValidationSchema() {
|
|
428
|
-
return
|
|
532
|
+
return q;
|
|
429
533
|
}
|
|
430
534
|
async execute(e) {
|
|
431
535
|
try {
|
|
432
|
-
const { key:
|
|
433
|
-
return
|
|
434
|
-
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}`,
|
|
435
539
|
status: 500
|
|
436
540
|
} : {
|
|
437
541
|
data: { success: !0 },
|
|
438
542
|
status: 200
|
|
439
543
|
};
|
|
440
|
-
} catch (
|
|
441
|
-
return console.error("DELETE_FROM_STORAGE error:",
|
|
442
|
-
error:
|
|
544
|
+
} catch (r) {
|
|
545
|
+
return console.error("DELETE_FROM_STORAGE error:", r), {
|
|
546
|
+
error: r instanceof Error ? r.message : "Unknown error",
|
|
443
547
|
status: 500
|
|
444
548
|
};
|
|
445
549
|
}
|
|
446
550
|
}
|
|
447
551
|
}
|
|
448
|
-
const H =
|
|
449
|
-
file:
|
|
552
|
+
const H = o.object({
|
|
553
|
+
file: o.string(),
|
|
450
554
|
// Base64 string
|
|
451
|
-
fileName:
|
|
452
|
-
contentType:
|
|
453
|
-
folder:
|
|
454
|
-
metadata:
|
|
555
|
+
fileName: o.string(),
|
|
556
|
+
contentType: o.string().optional(),
|
|
557
|
+
folder: o.string().optional(),
|
|
558
|
+
metadata: o.record(o.string(), o.any()).optional()
|
|
455
559
|
});
|
|
456
|
-
class
|
|
560
|
+
class W extends E {
|
|
457
561
|
constructor(e) {
|
|
458
562
|
super();
|
|
459
|
-
|
|
563
|
+
w(this, "bucketName", "dam-assets");
|
|
460
564
|
this.supabase = e;
|
|
461
565
|
}
|
|
462
566
|
getValidationSchema() {
|
|
@@ -466,17 +570,17 @@ class K extends f {
|
|
|
466
570
|
try {
|
|
467
571
|
if (!this.context)
|
|
468
572
|
return { error: "Context not set", status: 400 };
|
|
469
|
-
const { appId:
|
|
470
|
-
let
|
|
471
|
-
if (typeof
|
|
472
|
-
const
|
|
473
|
-
|
|
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");
|
|
474
578
|
} else
|
|
475
|
-
|
|
476
|
-
const
|
|
477
|
-
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",
|
|
478
582
|
upsert: !0,
|
|
479
|
-
...
|
|
583
|
+
...d && { metadata: d }
|
|
480
584
|
});
|
|
481
585
|
if (p)
|
|
482
586
|
return {
|
|
@@ -484,41 +588,42 @@ class K extends f {
|
|
|
484
588
|
status: 500
|
|
485
589
|
};
|
|
486
590
|
const {
|
|
487
|
-
data: { publicUrl:
|
|
488
|
-
} = this.supabase.storage.from(this.bucketName).getPublicUrl(
|
|
591
|
+
data: { publicUrl: m }
|
|
592
|
+
} = this.supabase.storage.from(this.bucketName).getPublicUrl(l);
|
|
489
593
|
return {
|
|
490
594
|
data: {
|
|
491
|
-
url:
|
|
492
|
-
key:
|
|
493
|
-
size:
|
|
494
|
-
metadata:
|
|
595
|
+
url: m,
|
|
596
|
+
key: g.path,
|
|
597
|
+
size: n.length,
|
|
598
|
+
metadata: d
|
|
495
599
|
},
|
|
496
600
|
status: 200
|
|
497
601
|
};
|
|
498
|
-
} catch (
|
|
499
|
-
return console.error("UPLOAD_TO_STORAGE error:",
|
|
500
|
-
error:
|
|
602
|
+
} catch (r) {
|
|
603
|
+
return console.error("UPLOAD_TO_STORAGE error:", r), {
|
|
604
|
+
error: r instanceof Error ? r.message : "Unknown error",
|
|
501
605
|
status: 500
|
|
502
606
|
};
|
|
503
607
|
}
|
|
504
608
|
}
|
|
505
609
|
}
|
|
506
|
-
const
|
|
507
|
-
GET_CHAI_USER: new
|
|
508
|
-
|
|
610
|
+
const Q = (u) => ({
|
|
611
|
+
GET_CHAI_USER: new j(u),
|
|
612
|
+
CHANGE_PASSWORD: new V(u)
|
|
613
|
+
}), Z = (u) => ({
|
|
509
614
|
// Asset management actions
|
|
510
|
-
UPLOAD_ASSET: new
|
|
511
|
-
GET_ASSET: new
|
|
512
|
-
GET_ASSETS: new
|
|
513
|
-
DELETE_ASSET: new
|
|
514
|
-
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),
|
|
515
620
|
// Generic storage actions
|
|
516
|
-
UPLOAD_TO_STORAGE: new
|
|
517
|
-
DELETE_FROM_STORAGE: new
|
|
621
|
+
UPLOAD_TO_STORAGE: new W(u),
|
|
622
|
+
DELETE_FROM_STORAGE: new z(u)
|
|
518
623
|
});
|
|
519
624
|
export {
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
625
|
+
z as DeleteFromStorageAction,
|
|
626
|
+
Q as SupabaseAuthActions,
|
|
627
|
+
Z as SupabaseStorageActions,
|
|
628
|
+
W as UploadToStorageAction
|
|
524
629
|
};
|