@chaibuilder/sdk 0.1.3 → 0.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{AddBlocks-0916e841.cjs → AddBlocks-1f683caa.cjs} +1 -1
- package/dist/{AddBlocks-c195f577.js → AddBlocks-b6a12d50.js} +1 -1
- package/dist/{BrandingOptions-742992b6.cjs → BrandingOptions-02e4ebcf.cjs} +1 -1
- package/dist/{BrandingOptions-766c19c6.js → BrandingOptions-1190723a.js} +1 -1
- package/dist/{CanvasArea-25800a3e.js → CanvasArea-15458836.js} +2 -2
- package/dist/{CanvasArea-e855c4a2.cjs → CanvasArea-f5d27245.cjs} +2 -2
- package/dist/{Layers-a2169d0b.cjs → Layers-06fa708d.cjs} +1 -1
- package/dist/{Layers-f7e792f6.js → Layers-ff4ef9c0.js} +2 -2
- package/dist/{MarkAsGlobalBlock-6bac1842.js → MarkAsGlobalBlock-dea26aa7.js} +1 -1
- package/dist/{MarkAsGlobalBlock-6187e6fd.cjs → MarkAsGlobalBlock-fa0e0543.cjs} +1 -1
- package/dist/{PagesPanel-0827c264.js → PagesPanel-3e9163c4.js} +2 -2
- package/dist/{PagesPanel-5698953d.cjs → PagesPanel-b08e1357.cjs} +1 -1
- package/dist/{ProjectPanel-e577029a.js → ProjectPanel-17c5f131.js} +5 -5
- package/dist/ProjectPanel-f0b94e3f.cjs +1 -0
- package/dist/{Settings-b214f859.js → Settings-6f2e86a9.js} +1 -1
- package/dist/{Settings-bee21026.cjs → Settings-739cff3b.cjs} +1 -1
- package/dist/{SidePanels-03fa10e8.js → SidePanels-96e64da9.js} +2 -2
- package/dist/{SidePanels-934159a4.cjs → SidePanels-ce4d41d5.cjs} +1 -1
- package/dist/{Topbar-9bc8c9cf.js → Topbar-08d10607.js} +1 -1
- package/dist/{Topbar-c083cc2a.cjs → Topbar-b97472fc.cjs} +1 -1
- package/dist/add-page-modal-3275cfb2.cjs +1 -0
- package/dist/{add-page-modal-63858244.js → add-page-modal-bcd9249e.js} +13 -12
- package/dist/core.cjs +1 -1
- package/dist/core.js +1 -1
- package/dist/delete-page-modal-420a17e3.cjs +1 -0
- package/dist/{delete-page-modal-def9012d.js → delete-page-modal-fa7b4272.js} +4 -4
- package/dist/index-133d90a5.cjs +2 -0
- package/dist/{index-390f7bef.js → index-3f65447f.js} +184 -179
- package/dist/{page-viewer-83ce2c70.cjs → page-viewer-139bfb2a.cjs} +1 -1
- package/dist/{page-viewer-41cbb548.js → page-viewer-f1452439.js} +2 -2
- package/dist/{project-general-setting-2c8bed74.cjs → project-general-setting-0d7715b8.cjs} +1 -1
- package/dist/{project-general-setting-0262fe62.js → project-general-setting-e5d14fa6.js} +1 -1
- package/dist/server.cjs +1 -0
- package/dist/server.d.ts +142 -0
- package/dist/server.js +126 -0
- package/dist/single-page-detail-54d7feca.cjs +1 -0
- package/dist/{single-page-detail-924d57fc.js → single-page-detail-74f88ed2.js} +14 -13
- package/dist/useMutation-7d536740.cjs +1 -0
- package/dist/useMutation-97876a40.js +126 -0
- package/dist/usePageActions-ac9ad321.cjs +1 -0
- package/dist/{usePageActions-f86f6f65.js → usePageActions-de3b7515.js} +12 -11
- package/dist/useProjectActions-3b1dbb5e.js +18 -0
- package/dist/useProjectActions-41af0f70.cjs +1 -0
- package/package.json +7 -2
- package/dist/ProjectPanel-a3cb7396.cjs +0 -1
- package/dist/add-page-modal-cb367c9d.cjs +0 -1
- package/dist/delete-page-modal-1e3914e3.cjs +0 -1
- package/dist/index-207f2cbf.cjs +0 -2
- package/dist/index-824a7bd0.js +0 -188
- package/dist/index-ebd86d7f.cjs +0 -2
- package/dist/single-page-detail-cfeae896.cjs +0 -1
- package/dist/usePageActions-3bed2330.cjs +0 -1
- package/dist/useProjectActions-1de05f63.js +0 -17
- package/dist/useProjectActions-5092ed79.cjs +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./jsx-runtime-5c3ac4f7.cjs"),n=require("react"),u=require("@radix-ui/react-icons"),o=require("./popover-7cb9079b.cjs"),c=require("./index-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./jsx-runtime-5c3ac4f7.cjs"),n=require("react"),u=require("@radix-ui/react-icons"),o=require("./popover-7cb9079b.cjs"),c=require("./index-133d90a5.cjs");require("@radix-ui/react-popover");require("./utils-3c452dd0.cjs");require("clsx");require("tailwind-merge");require("i18next");require("react-i18next");require("flagged");require("react-dnd");require("lodash");require("@minoru/react-dnd-treeview");require("./useBuilderProp-5e57d0c8.cjs");require("@radix-ui/react-slot");require("class-variance-authority");require("@radix-ui/react-tooltip");require("@radix-ui/react-toast");require("jotai");require("react-hotkeys-hook");require("flat-to-nested");require("./Class-7d6aadbc.cjs");require("redux-undo");require("@react-hookz/web");require("@chaibuilder/blocks");require("./CONTROLS-031e1de3.cjs");const j=n.lazy(()=>Promise.resolve().then(()=>require("./single-page-detail-54d7feca.cjs"))),m=({pageData:r})=>{const[s,t]=n.useState("CLOSE");return e.jsxRuntimeExports.jsxs(o.Popover,{open:s==="OPEN"||s==="ALERT"||s==="PENDING",onOpenChange:i=>{t(s==="PENDING"?"ALERT":i?"OPEN":"CLOSE")},children:[e.jsxRuntimeExports.jsx(o.PopoverTrigger,{asChild:!0,onClick:i=>{i.stopPropagation(),t("OPEN")},children:e.jsxRuntimeExports.jsx("div",{className:"flex items-center justify-between",children:s==="OPEN"||s==="ALERT"||s==="PENDING"?e.jsxRuntimeExports.jsx(u.ChevronRightIcon,{}):e.jsxRuntimeExports.jsx("div",{className:"hidden hover:text-blue-600 group-hover:flex",children:e.jsxRuntimeExports.jsx(u.GearIcon,{})})})}),e.jsxRuntimeExports.jsx(o.PopoverContent,{side:"right",align:"start",alignOffset:-35,className:"h-screen w-96",children:e.jsxRuntimeExports.jsx(n.Suspense,{fallback:e.jsxRuntimeExports.jsxs("div",{className:"flex w-full animate-pulse flex-col gap-y-3",children:[e.jsxRuntimeExports.jsx("div",{className:"bg-background-300 h-6 w-1/2"}),e.jsxRuntimeExports.jsx("div",{className:"bg-background-300 h-20 w-full"}),e.jsxRuntimeExports.jsx("div",{className:"bg-background-300 h-20 w-full"})]}),children:e.jsxRuntimeExports.jsx(j,{pageData:r,open:s,setOpen:t})})})]})},p=r=>{const[s]=["123"],{data:t}=c.useProject(),i={},x=(t==null?void 0:t.homepage)===r.uuid,l=s===r.uuid,a=()=>i(r);return t?e.jsxRuntimeExports.jsxs("button",{className:`group relative flex w-full cursor-pointer items-center justify-between px-2.5 py-2 ${l?"bg-blue-200 ":""}`,onClick:a,type:"button",children:[e.jsxRuntimeExports.jsxs("div",{className:"flex items-center gap-x-1.5",children:[x?e.jsxRuntimeExports.jsx(u.HomeIcon,{}):e.jsxRuntimeExports.jsx(u.FileTextIcon,{})," ",r.name]}),e.jsxRuntimeExports.jsx(m,{pageData:r})]}):null},d=({pages:r,isLoading:s})=>s?e.jsxRuntimeExports.jsxs("div",{className:"flex animate-pulse flex-col gap-y-1 px-2.5 pt-2",children:[e.jsxRuntimeExports.jsx("div",{className:"bg-background-200 h-7 w-full"}),e.jsxRuntimeExports.jsx("div",{className:"bg-background-200 h-7 w-full"}),e.jsxRuntimeExports.jsx("div",{className:"bg-background-200 h-7 w-full"})]}):r.length===0?e.jsxRuntimeExports.jsx("div",{className:"px-2.5 pb-2 pt-4",children:"No pages"}):e.jsxRuntimeExports.jsx("div",{className:"-mb-2",children:n.Children.toArray(r.map(t=>e.jsxRuntimeExports.jsx(p,{...t})))});exports.default=d;
|
|
@@ -2,7 +2,7 @@ import { j as e } from "./jsx-runtime-944c88e2.js";
|
|
|
2
2
|
import o, { useState as c, Suspense as m } from "react";
|
|
3
3
|
import { HomeIcon as p, FileTextIcon as u, ChevronRightIcon as d, GearIcon as x } from "@radix-ui/react-icons";
|
|
4
4
|
import { P as g, a as h, b as f } from "./popover-f7addcf4.js";
|
|
5
|
-
import { O as j } from "./index-
|
|
5
|
+
import { O as j } from "./index-3f65447f.js";
|
|
6
6
|
import "@radix-ui/react-popover";
|
|
7
7
|
import "./utils-ac68b2c8.js";
|
|
8
8
|
import "clsx";
|
|
@@ -26,7 +26,7 @@ import "redux-undo";
|
|
|
26
26
|
import "@react-hookz/web";
|
|
27
27
|
import "@chaibuilder/blocks";
|
|
28
28
|
import "./CONTROLS-442caee5.js";
|
|
29
|
-
const N = o.lazy(() => import("./single-page-detail-
|
|
29
|
+
const N = o.lazy(() => import("./single-page-detail-74f88ed2.js")), b = ({ pageData: t }) => {
|
|
30
30
|
const [s, r] = c("CLOSE");
|
|
31
31
|
return /* @__PURE__ */ e.jsxs(
|
|
32
32
|
g,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("./jsx-runtime-5c3ac4f7.cjs"),a=require("react"),f=require("./scroll-area-088530b9.cjs"),o=require("@chaibuilder/blocks"),m=require("./form-6eac0287.cjs"),d=require("./index-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("./jsx-runtime-5c3ac4f7.cjs"),a=require("react"),f=require("./scroll-area-088530b9.cjs"),o=require("@chaibuilder/blocks"),m=require("./form-6eac0287.cjs"),d=require("./index-133d90a5.cjs");require("@radix-ui/react-scroll-area");require("./utils-3c452dd0.cjs");require("clsx");require("tailwind-merge");require("@rjsf/core");require("@rjsf/validator-ajv8");require("lodash");require("./link-86c532b5.cjs");require("react-icons-picker");require("react-dom");require("./dialog-170eaad9.cjs");require("@radix-ui/react-dialog");require("@radix-ui/react-icons");require("./ImagesPanel-addb2bf9.cjs");require("./tabs-860e37aa.cjs");require("@radix-ui/react-tabs");require("react-quill");require("react-i18next");require("./useBuilderProp-5e57d0c8.cjs");require("@radix-ui/react-slot");require("class-variance-authority");require("@radix-ui/react-tooltip");require("@radix-ui/react-toast");require("jotai");require("i18next");require("flagged");require("react-dnd");require("@minoru/react-dnd-treeview");require("react-hotkeys-hook");require("flat-to-nested");require("./Class-7d6aadbc.cjs");require("redux-undo");require("@react-hookz/web");require("./CONTROLS-031e1de3.cjs");function g(r){const i=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(r){for(const e in r)if(e!=="default"){const u=Object.getOwnPropertyDescriptor(r,e);Object.defineProperty(i,e,u.get?u:{enumerable:!0,get:()=>r[e]})}}return i.default=r,Object.freeze(i)}const j=g(a),b=({_projectData:r,seany:i})=>{const{data:e,isLoading:u}=d.useProject();j.useEffect(()=>{e&&i(e)},[e,i]);const c=({formData:l},t)=>{i(s=>({...s,[t]:l[t]}))},q={name:o.SingleLineText({title:"Project Name",default:e==null?void 0:e.name}),favicon:o.Image({title:"Favicon",default:e==null?void 0:e.favicon})};return n.jsxRuntimeExports.jsx(f.ScrollArea,{className:"flex h-full select-none flex-col",children:n.jsxRuntimeExports.jsx(m.Form,{properties:q,disabled:u,formData:r,onChange:c})})};exports.default=b;
|
|
@@ -3,7 +3,7 @@ import * as n from "react";
|
|
|
3
3
|
import { S as f } from "./scroll-area-9f64a082.js";
|
|
4
4
|
import { SingleLineText as c, Image as d } from "@chaibuilder/blocks";
|
|
5
5
|
import { F as u } from "./form-5d5c5c9e.js";
|
|
6
|
-
import { O as x } from "./index-
|
|
6
|
+
import { O as x } from "./index-3f65447f.js";
|
|
7
7
|
import "@radix-ui/react-scroll-area";
|
|
8
8
|
import "./utils-ac68b2c8.js";
|
|
9
9
|
import "clsx";
|
package/dist/server.cjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var d=Object.defineProperty;var u=(o,t,e)=>t in o?d(o,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):o[t]=e;var c=(o,t,e)=>(u(o,typeof t!="symbol"?t+"":t,e),e);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const h=require("lodash"),i="https://api.chaibuilder.com";class g{constructor(t,e){c(this,"authToken");c(this,"projectKey");if(!t)throw"Please provide valid auth token.";if(!e)throw"Please provide valid project key.";this.authToken=t,this.projectKey=e}async getPage(t){if(!t)return Promise.reject({data:null,error:{message:"Invalid page uuid"},result:"error"});const e=this.getHeaders(),s=this.getURL("page",{uuid:t}),n={method:"GET",headers:e};return this.fetchAPI(s,n)}async getPages(){const t=this.getHeaders(),e=this.getURL("pages"),r={method:"GET",headers:t};return this.fetchAPI(e,r)}async addPage(t){h.set(t,"project",this.projectKey);const e=JSON.stringify(t),s=this.getHeaders(),r=this.getURL("page"),a={method:"POST",headers:s,body:e};return this.fetchAPI(r,a)}async deletePage(t){if(!t)return Promise.reject({data:null,error:{message:"Invalid page uuid"},result:"error"});const e=this.getHeaders(),s=this.getURL("page",{uuid:t}),n={method:"DELETE",headers:e};return this.fetchAPI(s,n)}async updatePage(t){const e=JSON.stringify(t),s=this.getHeaders(),r=this.getURL("page"),a={method:"PUT",headers:s,body:e};return this.fetchAPI(r,a)}async getProject(){const t=this.getHeaders(),e=this.getURL("project"),r={method:"GET",headers:t};return this.fetchAPI(e,r)}async updateProject(t){t.uuid=this.projectKey,h.set(t,"uuid",this.projectKey);const e=JSON.stringify(t),s=this.getHeaders(),r=this.getURL("project"),a={method:"PUT",headers:s,body:e};return this.fetchAPI(r,a)}getURL(t,e){const s=new URLSearchParams(e).toString();return h.isEmpty(e)?`${i}/v1/${t}`:`${i}/v1/${t}?${s}`}getHeaders(){const t=new Headers;return t.append("x-chai-app-key",this.projectKey),t.append("x-chai-auth-token",this.authToken),t.append("Content-Type","application/json"),t}async fetchAPI(t,e){try{const s=await fetch(t,e).then(r=>r.json());if((s==null?void 0:s.result)==="success")return{data:s==null?void 0:s.data,error:null,result:"success"};throw s==null?void 0:s.error}catch(s){return{data:null,error:s,result:"error"}}}}exports.ChaibuilderBackend=g;
|
package/dist/server.d.ts
ADDED
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
import type { ChaiBlock } from '@chaibuilder/sdk';
|
|
2
|
+
|
|
3
|
+
export declare class ChaibuilderBackend implements ChaibuilderBackendInterface {
|
|
4
|
+
private authToken;
|
|
5
|
+
private readonly projectKey;
|
|
6
|
+
constructor(authToken: string, projectKey: string);
|
|
7
|
+
/**
|
|
8
|
+
*
|
|
9
|
+
* @param uuid
|
|
10
|
+
* @returns Detail Single Page Information
|
|
11
|
+
*/
|
|
12
|
+
getPage(uuid: string): Promise<{
|
|
13
|
+
data: ChaiPage & {
|
|
14
|
+
subPages: ChaiSubPage[];
|
|
15
|
+
};
|
|
16
|
+
error: null;
|
|
17
|
+
result: string;
|
|
18
|
+
}>;
|
|
19
|
+
/**
|
|
20
|
+
*
|
|
21
|
+
* @returns List of all pages
|
|
22
|
+
*/
|
|
23
|
+
getPages(): Promise<{
|
|
24
|
+
data: ChaiPage & {
|
|
25
|
+
subPages: ChaiSubPage[];
|
|
26
|
+
}[];
|
|
27
|
+
error: null;
|
|
28
|
+
result: string;
|
|
29
|
+
}>;
|
|
30
|
+
/**
|
|
31
|
+
*
|
|
32
|
+
* @param page
|
|
33
|
+
* @returns Detail of new page
|
|
34
|
+
*/
|
|
35
|
+
addPage(page: Pick<ChaiPage, "name" | "slug">): Promise<{
|
|
36
|
+
data: ChaiPage;
|
|
37
|
+
error: null;
|
|
38
|
+
result: string;
|
|
39
|
+
}>;
|
|
40
|
+
/**
|
|
41
|
+
*
|
|
42
|
+
* @param uuid
|
|
43
|
+
* @returns Success | Error Message
|
|
44
|
+
*/
|
|
45
|
+
deletePage(uuid: string): Promise<{
|
|
46
|
+
data: null;
|
|
47
|
+
error: null;
|
|
48
|
+
result: string;
|
|
49
|
+
}>;
|
|
50
|
+
/**
|
|
51
|
+
*
|
|
52
|
+
* @param page
|
|
53
|
+
* @returns Update page information or Error response
|
|
54
|
+
*/
|
|
55
|
+
updatePage(page: ChaiPage): Promise<{
|
|
56
|
+
data: ChaiPage;
|
|
57
|
+
error: null;
|
|
58
|
+
result: string;
|
|
59
|
+
}>;
|
|
60
|
+
/**
|
|
61
|
+
*
|
|
62
|
+
* @returns Project detail
|
|
63
|
+
*/
|
|
64
|
+
getProject(): Promise<{
|
|
65
|
+
data: ChaiProject;
|
|
66
|
+
error: null;
|
|
67
|
+
result: string;
|
|
68
|
+
}>;
|
|
69
|
+
/**
|
|
70
|
+
*
|
|
71
|
+
* @param project
|
|
72
|
+
* @returns Updated project detail
|
|
73
|
+
*/
|
|
74
|
+
updateProject(project: Partial<ChaiProject>): Promise<{
|
|
75
|
+
data: ChaiProject;
|
|
76
|
+
error: null;
|
|
77
|
+
result: string;
|
|
78
|
+
}>;
|
|
79
|
+
/**
|
|
80
|
+
*
|
|
81
|
+
* @param endpoint
|
|
82
|
+
* @param queryParam
|
|
83
|
+
* @returns api endpoint with query param
|
|
84
|
+
*/
|
|
85
|
+
private getURL;
|
|
86
|
+
/**
|
|
87
|
+
*
|
|
88
|
+
* @returns headers for api
|
|
89
|
+
*/
|
|
90
|
+
private getHeaders;
|
|
91
|
+
/**
|
|
92
|
+
*
|
|
93
|
+
* @returns Fetch API
|
|
94
|
+
*/
|
|
95
|
+
private fetchAPI;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
export declare interface ChaibuilderBackendInterface {
|
|
99
|
+
getPage(uuid: string): TChaiResponse<ChaiPage & {
|
|
100
|
+
subPages: ChaiSubPage[];
|
|
101
|
+
}>;
|
|
102
|
+
getPages(): TChaiResponse<ChaiPage>;
|
|
103
|
+
addPage(page: Pick<ChaiPage, "name" | "slug">): TChaiResponse<ChaiPage>;
|
|
104
|
+
deletePage(uuid: string): TChaiResponse<null>;
|
|
105
|
+
updatePage(page: ChaiPage): TChaiResponse<ChaiPage>;
|
|
106
|
+
getProject(): TChaiResponse<ChaiProject>;
|
|
107
|
+
updateProject(project: Partial<ChaiProject>): TChaiResponse<ChaiProject>;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
declare type ChaiPage = {
|
|
111
|
+
uuid: string;
|
|
112
|
+
name: string;
|
|
113
|
+
slug: string;
|
|
114
|
+
blocks: ChaiBlock[];
|
|
115
|
+
seoData: object;
|
|
116
|
+
type: "STATIC" | "DYNAMIC" | "SUBPAGE";
|
|
117
|
+
project: string;
|
|
118
|
+
};
|
|
119
|
+
|
|
120
|
+
declare type ChaiProject = {
|
|
121
|
+
uuid: string;
|
|
122
|
+
brandingOptions: Record<string, string | number>;
|
|
123
|
+
favicon: string;
|
|
124
|
+
homepage: string;
|
|
125
|
+
name: string;
|
|
126
|
+
description?: string;
|
|
127
|
+
seoData: object;
|
|
128
|
+
primaryLanguage?: string;
|
|
129
|
+
password?: string;
|
|
130
|
+
languages?: Array<string>;
|
|
131
|
+
user?: string;
|
|
132
|
+
};
|
|
133
|
+
|
|
134
|
+
declare type ChaiSubPage = Pick<ChaiPage, "uuid" | "name" | "blocks" | "type" | "project">;
|
|
135
|
+
|
|
136
|
+
declare type TChaiResponse<T> = Promise<{
|
|
137
|
+
data: T;
|
|
138
|
+
error: null;
|
|
139
|
+
result: string;
|
|
140
|
+
}>;
|
|
141
|
+
|
|
142
|
+
export { }
|
package/dist/server.js
ADDED
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
var d = Object.defineProperty;
|
|
2
|
+
var u = (o, t, e) => t in o ? d(o, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : o[t] = e;
|
|
3
|
+
var a = (o, t, e) => (u(o, typeof t != "symbol" ? t + "" : t, e), e);
|
|
4
|
+
import { set as h, isEmpty as g } from "lodash";
|
|
5
|
+
const i = "https://api.chaibuilder.com";
|
|
6
|
+
class y {
|
|
7
|
+
constructor(t, e) {
|
|
8
|
+
a(this, "authToken");
|
|
9
|
+
a(this, "projectKey");
|
|
10
|
+
if (!t)
|
|
11
|
+
throw "Please provide valid auth token.";
|
|
12
|
+
if (!e)
|
|
13
|
+
throw "Please provide valid project key.";
|
|
14
|
+
this.authToken = t, this.projectKey = e;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
*
|
|
18
|
+
* @param uuid
|
|
19
|
+
* @returns Detail Single Page Information
|
|
20
|
+
*/
|
|
21
|
+
async getPage(t) {
|
|
22
|
+
if (!t)
|
|
23
|
+
return Promise.reject({
|
|
24
|
+
data: null,
|
|
25
|
+
error: { message: "Invalid page uuid" },
|
|
26
|
+
result: "error"
|
|
27
|
+
});
|
|
28
|
+
const e = this.getHeaders(), s = this.getURL("page", { uuid: t }), n = { method: "GET", headers: e };
|
|
29
|
+
return this.fetchAPI(s, n);
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
*
|
|
33
|
+
* @returns List of all pages
|
|
34
|
+
*/
|
|
35
|
+
async getPages() {
|
|
36
|
+
const t = this.getHeaders(), e = this.getURL("pages"), r = { method: "GET", headers: t };
|
|
37
|
+
return this.fetchAPI(e, r);
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
*
|
|
41
|
+
* @param page
|
|
42
|
+
* @returns Detail of new page
|
|
43
|
+
*/
|
|
44
|
+
async addPage(t) {
|
|
45
|
+
h(t, "project", this.projectKey);
|
|
46
|
+
const e = JSON.stringify(t), s = this.getHeaders(), r = this.getURL("page"), c = { method: "POST", headers: s, body: e };
|
|
47
|
+
return this.fetchAPI(r, c);
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
*
|
|
51
|
+
* @param uuid
|
|
52
|
+
* @returns Success | Error Message
|
|
53
|
+
*/
|
|
54
|
+
async deletePage(t) {
|
|
55
|
+
if (!t)
|
|
56
|
+
return Promise.reject({
|
|
57
|
+
data: null,
|
|
58
|
+
error: { message: "Invalid page uuid" },
|
|
59
|
+
result: "error"
|
|
60
|
+
});
|
|
61
|
+
const e = this.getHeaders(), s = this.getURL("page", { uuid: t }), n = { method: "DELETE", headers: e };
|
|
62
|
+
return this.fetchAPI(s, n);
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
*
|
|
66
|
+
* @param page
|
|
67
|
+
* @returns Update page information or Error response
|
|
68
|
+
*/
|
|
69
|
+
async updatePage(t) {
|
|
70
|
+
const e = JSON.stringify(t), s = this.getHeaders(), r = this.getURL("page"), c = { method: "PUT", headers: s, body: e };
|
|
71
|
+
return this.fetchAPI(r, c);
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
*
|
|
75
|
+
* @returns Project detail
|
|
76
|
+
*/
|
|
77
|
+
async getProject() {
|
|
78
|
+
const t = this.getHeaders(), e = this.getURL("project"), r = { method: "GET", headers: t };
|
|
79
|
+
return this.fetchAPI(e, r);
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
*
|
|
83
|
+
* @param project
|
|
84
|
+
* @returns Updated project detail
|
|
85
|
+
*/
|
|
86
|
+
async updateProject(t) {
|
|
87
|
+
t.uuid = this.projectKey, h(t, "uuid", this.projectKey);
|
|
88
|
+
const e = JSON.stringify(t), s = this.getHeaders(), r = this.getURL("project"), c = { method: "PUT", headers: s, body: e };
|
|
89
|
+
return this.fetchAPI(r, c);
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
*
|
|
93
|
+
* @param endpoint
|
|
94
|
+
* @param queryParam
|
|
95
|
+
* @returns api endpoint with query param
|
|
96
|
+
*/
|
|
97
|
+
getURL(t, e) {
|
|
98
|
+
const s = new URLSearchParams(e).toString();
|
|
99
|
+
return g(e) ? `${i}/v1/${t}` : `${i}/v1/${t}?${s}`;
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
*
|
|
103
|
+
* @returns headers for api
|
|
104
|
+
*/
|
|
105
|
+
getHeaders() {
|
|
106
|
+
const t = new Headers();
|
|
107
|
+
return t.append("x-chai-app-key", this.projectKey), t.append("x-chai-auth-token", this.authToken), t.append("Content-Type", "application/json"), t;
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
*
|
|
111
|
+
* @returns Fetch API
|
|
112
|
+
*/
|
|
113
|
+
async fetchAPI(t, e) {
|
|
114
|
+
try {
|
|
115
|
+
const s = await fetch(t, e).then((r) => r.json());
|
|
116
|
+
if ((s == null ? void 0 : s.result) === "success")
|
|
117
|
+
return { data: s == null ? void 0 : s.data, error: null, result: "success" };
|
|
118
|
+
throw s == null ? void 0 : s.error;
|
|
119
|
+
} catch (s) {
|
|
120
|
+
return { data: null, error: s, result: "error" };
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
export {
|
|
125
|
+
y as ChaibuilderBackend
|
|
126
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("./jsx-runtime-5c3ac4f7.cjs"),q=require("react"),c=require("lodash"),H=require("@radix-ui/react-icons"),w=require("./useBuilderProp-5e57d0c8.cjs"),L=require("./scroll-area-088530b9.cjs"),d=require("@chaibuilder/blocks"),z=require("sonner"),p=require("./form-6eac0287.cjs"),N=require("./index-133d90a5.cjs"),b=require("./useProjectActions-41af0f70.cjs");require("@radix-ui/react-slot");require("class-variance-authority");require("./utils-3c452dd0.cjs");require("clsx");require("tailwind-merge");require("@radix-ui/react-tooltip");require("@radix-ui/react-toast");require("jotai");require("@radix-ui/react-scroll-area");require("@rjsf/core");require("@rjsf/validator-ajv8");require("./link-86c532b5.cjs");require("react-icons-picker");require("react-dom");require("./dialog-170eaad9.cjs");require("@radix-ui/react-dialog");require("./ImagesPanel-addb2bf9.cjs");require("./tabs-860e37aa.cjs");require("@radix-ui/react-tabs");require("react-quill");require("react-i18next");require("i18next");require("flagged");require("react-dnd");require("@minoru/react-dnd-treeview");require("react-hotkeys-hook");require("flat-to-nested");require("./Class-7d6aadbc.cjs");require("redux-undo");require("@react-hookz/web");require("./CONTROLS-031e1de3.cjs");require("./useMutation-7d536740.cjs");const _=q.lazy(()=>Promise.resolve().then(()=>require("./delete-page-modal-420a17e3.cjs"))),B=q.lazy(()=>Promise.resolve().then(()=>require("./confirm-alert-4f50caa7.cjs"))),h=n=>{if(!c.isString(n)||!(n.includes("/[")&&n.includes("]")))return!1;const i=/^\[((?:\.{3})?[a-zA-Z0-9_-]+)\]$/,g=/^[a-zA-Z0-9_-]+$/;let e=!0;return n.split("/").forEach(u=>{e&&(u.includes("[[")&&u.includes("]]")?e=/^\[\[\.{3}[a-zA-Z0-9_-]+\]\]$/.test(u):u.includes("[")&&u.includes("]")?e=i.test(u):e=g.test(u))}),e},P=n=>n&&c.isEmpty(n.seoData)?{...n,seoData:{title:"",description:"",image:""}}:n,G=(n,o)=>{const i=!c.isEqual(c.omit(n,["seoData"]),c.omit(o,["seoData"])),g=!c.isEqual(P(o).seoData,P(n).seoData);return i||g},Y=({open:n,setOpen:o,pageData:i})=>{const g=N.useQueryClient(),{data:e}=N.useProject(),u=b.useUpdateProject(),m=b.useUpdateProject("Homepage updated successfully."),[s,y]=q.useState(P(i)),[a,A]=q.useState({isHomePage:(e==null?void 0:e.homepage)===i.uuid}),E=G(s,i);q.useEffect(()=>{const l=!c.isEqual(P(i),s),r=(e==null?void 0:e.homepage)!==i.uuid&&a.isHomePage;o(l||r?"PENDING":"OPEN")},[e,i,s,a,o]);const j=()=>{if(E){if(i.type==="DYNAMIC"&&!h((s==null?void 0:s.slug)||"")){n==="ALERT"&&o("PENDING");return}u.mutate(s,{onSuccess:()=>{g.invalidateQueries({refetchType:"active",queryKey:["pages",e==null?void 0:e.uuid]}),o("CLOSE"),z.toast.success("Page updated successfully.")}})}a.isHomePage&&(e==null?void 0:e.homepage)!==i.uuid&&m.mutate({...e,homepage:i==null?void 0:i.uuid},{onSuccess:()=>o("CLOSE")})},S=({formData:l},r)=>{y(f=>{var C,R;if(!r)return f;const x={[r]:l[r]};return r==="page_name"?x.slug=c.kebabCase((C=l[r])==null?void 0:C.replace(/\d/g,"")):r==="slug"?x.slug=(R=l[r])==null?void 0:R.replace(/\d/g,"").replace(/\s+/g,"").replace("--","-").replace("__","_"):r==="seo_data"&&(x.seo_data={title:l[r].title||"",description:l[r].description||"",image:l[r].image||""}),{...f,...x}})},I=({formData:l},r)=>{A(f=>{const x={[r]:l[r]};return{...f,...x}})},T={page_name:d.SingleLineText({title:"Page Name",default:s.name}),slug:d.SingleLineText({title:"Page Slug",default:s.slug})},v={seo_data:d.Model({title:"",description:"",default:{title:"",description:"",image:""},properties:{title:d.SingleLineText({title:"Meta Title",default:s.name}),description:d.MultilineText({title:"Meta Description",default:s.slug}),image:d.Image({title:"Social Media Image",default:""})}})},M={isHomePage:d.Checkbox({title:"Set as homepage",default:a.isHomePage})};return t.jsxRuntimeExports.jsxs(L.ScrollArea,{className:"flex h-full select-none flex-col",children:[t.jsxRuntimeExports.jsx(B,{open:n==="ALERT",title:"Do yo want to save changes?",onCancel:()=>o("CLOSE"),onConfirm:j,disabled:m.isPending||u.isPending}),t.jsxRuntimeExports.jsx("div",{className:"rounded-md bg-background/30 px-2.5 py-1",children:t.jsxRuntimeExports.jsx("h1",{className:"px-1 font-semibold",children:"Page Details"})}),t.jsxRuntimeExports.jsx("div",{className:"px-2.5 pt-2",children:t.jsxRuntimeExports.jsxs("div",{className:"flex flex-col space-y-2",children:[t.jsxRuntimeExports.jsx(p.Form,{title:"Basic Details",formData:s,properties:T,onChange:S,disabled:u.isPending||m.isPending}),t.jsxRuntimeExports.jsx("div",{className:"h-2 w-full"}),t.jsxRuntimeExports.jsx(p.Form,{title:"SEO Details",formData:s,properties:v,onChange:S,disabled:u.isPending||m.isPending}),(e==null?void 0:e.homepage)!==i.uuid&&i.type==="STATIC"?t.jsxRuntimeExports.jsx(p.Form,{formData:a,properties:M,onChange:I,disabled:u.isPending||m.isPending}):i.type==="STATIC"&&t.jsxRuntimeExports.jsxs("div",{className:"flex items-center gap-x-1 px-1 pt-2 text-xs font-medium text-gray-500",children:[t.jsxRuntimeExports.jsx(H.HomeIcon,{})," This is homepage"," "]}),s.type==="DYNAMIC"&&!h((s==null?void 0:s.slug)||"")&&t.jsxRuntimeExports.jsxs("small",{className:"px-1 text-red-400",children:["Add dynamic ID in page slug Eg: ",t.jsxRuntimeExports.jsx("i",{className:"underline",children:"some-url/[some-id]"})]}),t.jsxRuntimeExports.jsxs("div",{className:"my-2 flex w-full items-center justify-between gap-x-2 px-1",children:[t.jsxRuntimeExports.jsx(w.Button,{className:"w-full",type:"submit",onClick:j,disabled:(e==null?void 0:e.homepage)!==i.uuid&&a.isHomePage?!1:c.isEmpty(s.name)||c.isEmpty(s.slug)||!E||u.isPending||m.isPending||s.type==="DYNAMIC"&&!h((s==null?void 0:s.slug)||""),children:"Save"}),t.jsxRuntimeExports.jsx(_,{pageData:i,projectData:e})]})]})})]})};exports.default=Y;
|
|
@@ -5,10 +5,10 @@ import { HomeIcon as G } from "@radix-ui/react-icons";
|
|
|
5
5
|
import { B as Y } from "./useBuilderProp-81a14920.js";
|
|
6
6
|
import { S as q } from "./scroll-area-9f64a082.js";
|
|
7
7
|
import { SingleLineText as g, Model as X, MultilineText as Z, Image as $, Checkbox as F } from "@chaibuilder/blocks";
|
|
8
|
-
import {
|
|
8
|
+
import { toast as O } from "sonner";
|
|
9
9
|
import { F as h } from "./form-5d5c5c9e.js";
|
|
10
|
-
import { X as Q, O as V } from "./index-
|
|
11
|
-
import { u as y } from "./useProjectActions-
|
|
10
|
+
import { X as Q, O as V } from "./index-3f65447f.js";
|
|
11
|
+
import { u as y } from "./useProjectActions-3b1dbb5e.js";
|
|
12
12
|
import "@radix-ui/react-slot";
|
|
13
13
|
import "class-variance-authority";
|
|
14
14
|
import "./utils-ac68b2c8.js";
|
|
@@ -18,11 +18,11 @@ import "@radix-ui/react-tooltip";
|
|
|
18
18
|
import "@radix-ui/react-toast";
|
|
19
19
|
import "jotai";
|
|
20
20
|
import "@radix-ui/react-scroll-area";
|
|
21
|
-
import "react-dom";
|
|
22
21
|
import "@rjsf/core";
|
|
23
22
|
import "@rjsf/validator-ajv8";
|
|
24
23
|
import "./link-f80a947d.js";
|
|
25
24
|
import "react-icons-picker";
|
|
25
|
+
import "react-dom";
|
|
26
26
|
import "./dialog-3d4e82ed.js";
|
|
27
27
|
import "@radix-ui/react-dialog";
|
|
28
28
|
import "./ImagesPanel-8ccab6d9.js";
|
|
@@ -40,7 +40,8 @@ import "./Class-e34b2337.js";
|
|
|
40
40
|
import "redux-undo";
|
|
41
41
|
import "@react-hookz/web";
|
|
42
42
|
import "./CONTROLS-442caee5.js";
|
|
43
|
-
|
|
43
|
+
import "./useMutation-97876a40.js";
|
|
44
|
+
const K = T.lazy(() => import("./delete-page-modal-fa7b4272.js")), U = T.lazy(() => import("./confirm-alert-f2a47cc7.js")), x = (n) => {
|
|
44
45
|
if (!z(n) || !(n.includes("/[") && n.includes("]")))
|
|
45
46
|
return !1;
|
|
46
47
|
const s = /^\[((?:\.{3})?[a-zA-Z0-9_-]+)\]$/, u = /^[a-zA-Z0-9_-]+$/;
|
|
@@ -54,16 +55,16 @@ const K = T.lazy(() => import("./delete-page-modal-def9012d.js")), U = T.lazy(()
|
|
|
54
55
|
} : n, J = (n, l) => {
|
|
55
56
|
const s = !P(j(n, ["seoData"]), j(l, ["seoData"])), u = !P(f(l).seoData, f(n).seoData);
|
|
56
57
|
return s || u;
|
|
57
|
-
},
|
|
58
|
+
}, qe = ({ open: n, setOpen: l, pageData: s }) => {
|
|
58
59
|
const u = Q(), { data: e } = V(), r = y(), c = y("Homepage updated successfully."), [i, M] = I(f(s)), [d, v] = I({
|
|
59
60
|
isHomePage: (e == null ? void 0 : e.homepage) === s.uuid
|
|
60
|
-
}),
|
|
61
|
+
}), S = J(i, s);
|
|
61
62
|
L(() => {
|
|
62
63
|
const m = !P(f(s), i), o = (e == null ? void 0 : e.homepage) !== s.uuid && d.isHomePage;
|
|
63
64
|
l(m || o ? "PENDING" : "OPEN");
|
|
64
65
|
}, [e, s, i, d, l]);
|
|
65
|
-
const
|
|
66
|
-
if (
|
|
66
|
+
const N = () => {
|
|
67
|
+
if (S) {
|
|
67
68
|
if (s.type === "DYNAMIC" && !x((i == null ? void 0 : i.slug) || "")) {
|
|
68
69
|
n === "ALERT" && l("PENDING");
|
|
69
70
|
return;
|
|
@@ -141,7 +142,7 @@ const K = T.lazy(() => import("./delete-page-modal-def9012d.js")), U = T.lazy(()
|
|
|
141
142
|
open: n === "ALERT",
|
|
142
143
|
title: "Do yo want to save changes?",
|
|
143
144
|
onCancel: () => l("CLOSE"),
|
|
144
|
-
onConfirm:
|
|
145
|
+
onConfirm: N,
|
|
145
146
|
disabled: c.isPending || r.isPending
|
|
146
147
|
}
|
|
147
148
|
),
|
|
@@ -191,8 +192,8 @@ const K = T.lazy(() => import("./delete-page-modal-def9012d.js")), U = T.lazy(()
|
|
|
191
192
|
{
|
|
192
193
|
className: "w-full",
|
|
193
194
|
type: "submit",
|
|
194
|
-
onClick:
|
|
195
|
-
disabled: (e == null ? void 0 : e.homepage) !== s.uuid && d.isHomePage ? !1 : C(i.name) || C(i.slug) || !
|
|
195
|
+
onClick: N,
|
|
196
|
+
disabled: (e == null ? void 0 : e.homepage) !== s.uuid && d.isHomePage ? !1 : C(i.name) || C(i.slug) || !S || r.isPending || c.isPending || i.type === "DYNAMIC" && !x((i == null ? void 0 : i.slug) || ""),
|
|
196
197
|
children: "Save"
|
|
197
198
|
}
|
|
198
199
|
),
|
|
@@ -202,5 +203,5 @@ const K = T.lazy(() => import("./delete-page-modal-def9012d.js")), U = T.lazy(()
|
|
|
202
203
|
] });
|
|
203
204
|
};
|
|
204
205
|
export {
|
|
205
|
-
|
|
206
|
+
qe as default
|
|
206
207
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var M=(i,t,e)=>{if(!t.has(i))throw TypeError("Cannot "+e)};var s=(i,t,e)=>(M(i,t,"read from private field"),e?e.call(i):t.get(i)),c=(i,t,e)=>{if(t.has(i))throw TypeError("Cannot add the same private member more than once");t instanceof WeakSet?t.add(i):t.set(i,e)},l=(i,t,e,r)=>(M(i,t,"write to private field"),r?r.call(i,e):t.set(i,e),e);var p=(i,t,e)=>(M(i,t,"access private method"),e);const w=require("react"),b=require("./index-133d90a5.cjs");function j(i){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(i){for(const e in i)if(e!=="default"){const r=Object.getOwnPropertyDescriptor(i,e);Object.defineProperty(t,e,r.get?r:{enumerable:!0,get:()=>i[e]})}}return t.default=i,Object.freeze(t)}const v=j(w);var a,n,o,u,f,y,O,S,x,k=(x=class extends b.Subscribable{constructor(t,e){super();c(this,f);c(this,O);c(this,a,void 0);c(this,n,void 0);c(this,o,void 0);c(this,u,void 0);l(this,n,void 0),l(this,a,t),this.setOptions(e),this.bindMethods(),p(this,f,y).call(this)}bindMethods(){this.mutate=this.mutate.bind(this),this.reset=this.reset.bind(this)}setOptions(t){var r;const e=this.options;this.options=s(this,a).defaultMutationOptions(t),b.shallowEqualObjects(e,this.options)||s(this,a).getMutationCache().notify({type:"observerOptionsUpdated",mutation:s(this,o),observer:this}),(r=s(this,o))==null||r.setOptions(this.options)}onUnsubscribe(){var t;this.hasListeners()||(t=s(this,o))==null||t.removeObserver(this)}onMutationUpdate(t){p(this,f,y).call(this),p(this,O,S).call(this,t)}getCurrentResult(){return s(this,n)}reset(){l(this,o,void 0),p(this,f,y).call(this),p(this,O,S).call(this)}mutate(t,e){var r;return l(this,u,e),(r=s(this,o))==null||r.removeObserver(this),l(this,o,s(this,a).getMutationCache().build(s(this,a),this.options)),s(this,o).addObserver(this),s(this,o).execute(t)}},a=new WeakMap,n=new WeakMap,o=new WeakMap,u=new WeakMap,f=new WeakSet,y=function(){var e;const t=((e=s(this,o))==null?void 0:e.state)??b.getDefaultState();l(this,n,{...t,isPending:t.status==="pending",isSuccess:t.status==="success",isError:t.status==="error",isIdle:t.status==="idle",mutate:this.mutate,reset:this.reset})},O=new WeakSet,S=function(t){b.notifyManager.batch(()=>{var e,r,h,m,d,g,C,E;s(this,u)&&this.hasListeners()&&((t==null?void 0:t.type)==="success"?((r=(e=s(this,u)).onSuccess)==null||r.call(e,t.data,s(this,n).variables,s(this,n).context),(m=(h=s(this,u)).onSettled)==null||m.call(h,t.data,null,s(this,n).variables,s(this,n).context)):(t==null?void 0:t.type)==="error"&&((g=(d=s(this,u)).onError)==null||g.call(d,t.error,s(this,n).variables,s(this,n).context),(E=(C=s(this,u)).onSettled)==null||E.call(C,void 0,t.error,s(this,n).variables,s(this,n).context))),this.listeners.forEach(R=>{R(s(this,n))})})},x);function q(i,t){const e=b.useQueryClient(t),[r]=v.useState(()=>new k(e,i));v.useEffect(()=>{r.setOptions(i)},[r,i]);const h=v.useSyncExternalStore(v.useCallback(d=>r.subscribe(b.notifyManager.batchCalls(d)),[r]),()=>r.getCurrentResult(),()=>r.getCurrentResult()),m=v.useCallback((d,g)=>{r.mutate(d,g).catch(D)},[r]);if(h.error&&b.shouldThrowError(r.options.throwOnError,[h.error]))throw h.error;return{...h,mutate:m,mutateAsync:h.mutate}}function D(){}exports.useMutation=q;
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
var g = (r, t, e) => {
|
|
2
|
+
if (!t.has(r))
|
|
3
|
+
throw TypeError("Cannot " + e);
|
|
4
|
+
};
|
|
5
|
+
var s = (r, t, e) => (g(r, t, "read from private field"), e ? e.call(r) : t.get(r)), l = (r, t, e) => {
|
|
6
|
+
if (t.has(r))
|
|
7
|
+
throw TypeError("Cannot add the same private member more than once");
|
|
8
|
+
t instanceof WeakSet ? t.add(r) : t.set(r, e);
|
|
9
|
+
}, c = (r, t, e, i) => (g(r, t, "write to private field"), i ? i.call(r, e) : t.set(r, e), e);
|
|
10
|
+
var d = (r, t, e) => (g(r, t, "access private method"), e);
|
|
11
|
+
import * as f from "react";
|
|
12
|
+
import { Z as w, _ as U, $ as k, a0 as E, X as L, a1 as j } from "./index-3f65447f.js";
|
|
13
|
+
var n, h, o, u, p, M, v, y, x, q = (x = class extends w {
|
|
14
|
+
constructor(t, e) {
|
|
15
|
+
super();
|
|
16
|
+
l(this, p);
|
|
17
|
+
l(this, v);
|
|
18
|
+
l(this, n, void 0);
|
|
19
|
+
l(this, h, void 0);
|
|
20
|
+
l(this, o, void 0);
|
|
21
|
+
l(this, u, void 0);
|
|
22
|
+
c(this, h, void 0), c(this, n, t), this.setOptions(e), this.bindMethods(), d(this, p, M).call(this);
|
|
23
|
+
}
|
|
24
|
+
bindMethods() {
|
|
25
|
+
this.mutate = this.mutate.bind(this), this.reset = this.reset.bind(this);
|
|
26
|
+
}
|
|
27
|
+
setOptions(t) {
|
|
28
|
+
var i;
|
|
29
|
+
const e = this.options;
|
|
30
|
+
this.options = s(this, n).defaultMutationOptions(t), U(e, this.options) || s(this, n).getMutationCache().notify({
|
|
31
|
+
type: "observerOptionsUpdated",
|
|
32
|
+
mutation: s(this, o),
|
|
33
|
+
observer: this
|
|
34
|
+
}), (i = s(this, o)) == null || i.setOptions(this.options);
|
|
35
|
+
}
|
|
36
|
+
onUnsubscribe() {
|
|
37
|
+
var t;
|
|
38
|
+
this.hasListeners() || (t = s(this, o)) == null || t.removeObserver(this);
|
|
39
|
+
}
|
|
40
|
+
onMutationUpdate(t) {
|
|
41
|
+
d(this, p, M).call(this), d(this, v, y).call(this, t);
|
|
42
|
+
}
|
|
43
|
+
getCurrentResult() {
|
|
44
|
+
return s(this, h);
|
|
45
|
+
}
|
|
46
|
+
reset() {
|
|
47
|
+
c(this, o, void 0), d(this, p, M).call(this), d(this, v, y).call(this);
|
|
48
|
+
}
|
|
49
|
+
mutate(t, e) {
|
|
50
|
+
var i;
|
|
51
|
+
return c(this, u, e), (i = s(this, o)) == null || i.removeObserver(this), c(this, o, s(this, n).getMutationCache().build(s(this, n), this.options)), s(this, o).addObserver(this), s(this, o).execute(t);
|
|
52
|
+
}
|
|
53
|
+
}, n = new WeakMap(), h = new WeakMap(), o = new WeakMap(), u = new WeakMap(), p = new WeakSet(), M = function() {
|
|
54
|
+
var e;
|
|
55
|
+
const t = ((e = s(this, o)) == null ? void 0 : e.state) ?? k();
|
|
56
|
+
c(this, h, {
|
|
57
|
+
...t,
|
|
58
|
+
isPending: t.status === "pending",
|
|
59
|
+
isSuccess: t.status === "success",
|
|
60
|
+
isError: t.status === "error",
|
|
61
|
+
isIdle: t.status === "idle",
|
|
62
|
+
mutate: this.mutate,
|
|
63
|
+
reset: this.reset
|
|
64
|
+
});
|
|
65
|
+
}, v = new WeakSet(), y = function(t) {
|
|
66
|
+
E.batch(() => {
|
|
67
|
+
var e, i, a, m, b, O, C, S;
|
|
68
|
+
s(this, u) && this.hasListeners() && ((t == null ? void 0 : t.type) === "success" ? ((i = (e = s(this, u)).onSuccess) == null || i.call(
|
|
69
|
+
e,
|
|
70
|
+
t.data,
|
|
71
|
+
s(this, h).variables,
|
|
72
|
+
s(this, h).context
|
|
73
|
+
), (m = (a = s(this, u)).onSettled) == null || m.call(
|
|
74
|
+
a,
|
|
75
|
+
t.data,
|
|
76
|
+
null,
|
|
77
|
+
s(this, h).variables,
|
|
78
|
+
s(this, h).context
|
|
79
|
+
)) : (t == null ? void 0 : t.type) === "error" && ((O = (b = s(this, u)).onError) == null || O.call(
|
|
80
|
+
b,
|
|
81
|
+
t.error,
|
|
82
|
+
s(this, h).variables,
|
|
83
|
+
s(this, h).context
|
|
84
|
+
), (S = (C = s(this, u)).onSettled) == null || S.call(
|
|
85
|
+
C,
|
|
86
|
+
void 0,
|
|
87
|
+
t.error,
|
|
88
|
+
s(this, h).variables,
|
|
89
|
+
s(this, h).context
|
|
90
|
+
))), this.listeners.forEach((R) => {
|
|
91
|
+
R(s(this, h));
|
|
92
|
+
});
|
|
93
|
+
});
|
|
94
|
+
}, x);
|
|
95
|
+
function P(r, t) {
|
|
96
|
+
const e = L(t), [i] = f.useState(
|
|
97
|
+
() => new q(
|
|
98
|
+
e,
|
|
99
|
+
r
|
|
100
|
+
)
|
|
101
|
+
);
|
|
102
|
+
f.useEffect(() => {
|
|
103
|
+
i.setOptions(r);
|
|
104
|
+
}, [i, r]);
|
|
105
|
+
const a = f.useSyncExternalStore(
|
|
106
|
+
f.useCallback(
|
|
107
|
+
(b) => i.subscribe(E.batchCalls(b)),
|
|
108
|
+
[i]
|
|
109
|
+
),
|
|
110
|
+
() => i.getCurrentResult(),
|
|
111
|
+
() => i.getCurrentResult()
|
|
112
|
+
), m = f.useCallback(
|
|
113
|
+
(b, O) => {
|
|
114
|
+
i.mutate(b, O).catch(A);
|
|
115
|
+
},
|
|
116
|
+
[i]
|
|
117
|
+
);
|
|
118
|
+
if (a.error && j(i.options.throwOnError, [a.error]))
|
|
119
|
+
throw a.error;
|
|
120
|
+
return { ...a, mutate: m, mutateAsync: a.mutate };
|
|
121
|
+
}
|
|
122
|
+
function A() {
|
|
123
|
+
}
|
|
124
|
+
export {
|
|
125
|
+
P as u
|
|
126
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";const t=require("./index-133d90a5.cjs"),i=require("./useMutation-7d536740.cjs"),a=require("sonner");require("react-i18next");const c=require("./useBuilderProp-5e57d0c8.cjs"),o=()=>{const[u]=["SAVED"],[e,s]=t.useCurrentPage(),n=t.useBuilderReset();return r=>u==="UNSAVED"?(c.toast({variant:"destructive",title:"Please save unsaved changes"}),!1):e===r.uuid?!1:(n(),setTimeout(()=>{s(r.uuid)},100),!0)},d=()=>{const u=t.useQueryClient(),e=o();return i.useMutation({mutationFn:async s=>fetch("/pages",{method:"POST",body:JSON.stringify(s)}).then(n=>n.json()),onSuccess:s=>{u.invalidateQueries({queryKey:["pages"]}),e({uuid:s.uuid,slug:s.slug}),a.toast.success("Page added successfully.")}})},g=()=>{const u=t.useQueryClient();return i.useMutation({mutationFn:async e=>fetch(`/page?uuid=${e.uuid}`,{method:"DELETE",body:JSON.stringify(e)}),onSuccess:()=>{a.toast.success("Page deleted successfully."),u.invalidateQueries({queryKey:["pages"]})}})};exports.useAddPage=d;exports.useDeletePage=g;
|
|
@@ -1,15 +1,16 @@
|
|
|
1
|
-
import { a2 as
|
|
2
|
-
import { u as
|
|
1
|
+
import { a2 as o, a3 as c, X as r } from "./index-3f65447f.js";
|
|
2
|
+
import { u as n } from "./useMutation-97876a40.js";
|
|
3
|
+
import { toast as i } from "sonner";
|
|
3
4
|
import "react-i18next";
|
|
4
5
|
import { t as d } from "./useBuilderProp-81a14920.js";
|
|
5
6
|
const g = () => {
|
|
6
|
-
const [t] = ["SAVED"], [e, s] =
|
|
7
|
+
const [t] = ["SAVED"], [e, s] = o(), u = c();
|
|
7
8
|
return (a) => t === "UNSAVED" ? (d({ variant: "destructive", title: "Please save unsaved changes" }), !1) : e === a.uuid ? !1 : (u(), setTimeout(() => {
|
|
8
9
|
s(a.uuid);
|
|
9
10
|
}, 100), !0);
|
|
10
|
-
},
|
|
11
|
-
const t =
|
|
12
|
-
return
|
|
11
|
+
}, h = () => {
|
|
12
|
+
const t = r(), e = g();
|
|
13
|
+
return n({
|
|
13
14
|
mutationFn: async (s) => fetch("/pages", {
|
|
14
15
|
method: "POST",
|
|
15
16
|
body: JSON.stringify(s)
|
|
@@ -18,9 +19,9 @@ const g = () => {
|
|
|
18
19
|
t.invalidateQueries({ queryKey: ["pages"] }), e({ uuid: s.uuid, slug: s.slug }), i.success("Page added successfully.");
|
|
19
20
|
}
|
|
20
21
|
});
|
|
21
|
-
},
|
|
22
|
-
const t =
|
|
23
|
-
return
|
|
22
|
+
}, S = () => {
|
|
23
|
+
const t = r();
|
|
24
|
+
return n({
|
|
24
25
|
mutationFn: async (e) => fetch(`/page?uuid=${e.uuid}`, {
|
|
25
26
|
method: "DELETE",
|
|
26
27
|
body: JSON.stringify(e)
|
|
@@ -31,6 +32,6 @@ const g = () => {
|
|
|
31
32
|
});
|
|
32
33
|
};
|
|
33
34
|
export {
|
|
34
|
-
|
|
35
|
-
|
|
35
|
+
S as a,
|
|
36
|
+
h as u
|
|
36
37
|
};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { X as r, Y as u } from "./index-3f65447f.js";
|
|
2
|
+
import { u as a } from "./useMutation-97876a40.js";
|
|
3
|
+
import { toast as c } from "sonner";
|
|
4
|
+
const m = (e = "Project updated successfully.") => {
|
|
5
|
+
const t = r(), s = u();
|
|
6
|
+
return a({
|
|
7
|
+
mutationFn: async (o) => await fetch(`${s}/project`, {
|
|
8
|
+
method: "PUT",
|
|
9
|
+
body: JSON.stringify(o)
|
|
10
|
+
}),
|
|
11
|
+
onSuccess: () => {
|
|
12
|
+
t.invalidateQueries({ queryKey: ["project"] }), c.success(e);
|
|
13
|
+
}
|
|
14
|
+
});
|
|
15
|
+
};
|
|
16
|
+
export {
|
|
17
|
+
m as u
|
|
18
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";const e=require("./index-133d90a5.cjs"),c=require("./useMutation-7d536740.cjs"),o=require("sonner"),n=(t="Project updated successfully.")=>{const s=e.useQueryClient(),r=e.useApiBaseUrl();return c.useMutation({mutationFn:async u=>await fetch(`${r}/project`,{method:"PUT",body:JSON.stringify(u)}),onSuccess:()=>{s.invalidateQueries({queryKey:["project"]}),o.toast.success(t)}})};exports.useUpdateProject=n;
|