@chaibuilder/pages 0.1.15 → 0.1.17
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/{B4MFY5CR-B3BX-4Z5.js → B4MFY5CR-B1LiRXyX.js} +1 -1
- package/dist/B4MFY5CR-m7W6jLyZ.cjs +1200 -0
- package/dist/{HO4MOOFI-BYkfnhhc.js → HO4MOOFI-BoB6vpqY.js} +2 -2
- package/dist/HO4MOOFI-D9R_K0Re.cjs +1 -0
- package/dist/HUY7CZI3-BRZ5qwB3.cjs +1 -0
- package/dist/{HUY7CZI3-DOIW2MPF.js → HUY7CZI3-Cj4icxzC.js} +2 -2
- package/dist/{ChaiBuilderPages-Blnid_U8.js → index-BD0oij-u.js} +3566 -3521
- package/dist/index-DPXLTEu-.cjs +2 -0
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +83 -1
- package/dist/index.js +12 -10
- package/dist/server.cjs +1 -1
- package/dist/server.d.ts +9 -0
- package/dist/server.js +92 -77
- package/package.json +8 -4
- package/dist/B4MFY5CR-BORsrcGw.cjs +0 -1200
- package/dist/ChaiBuilderPages-CaShr_yk.cjs +0 -2
- package/dist/HO4MOOFI-Csb2PXFS.cjs +0 -1
- package/dist/HUY7CZI3-vNTBR-fr.cjs +0 -1
package/dist/server.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var p=Object.defineProperty;var y=(i,a,e)=>a in i?p(i,a,{enumerable:!0,configurable:!0,writable:!0,value:e}):i[a]=e;var l=(i,a,e)=>y(i,typeof a!="symbol"?a+"":a,e);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const u=require("lodash-es"),h={},k=(i,a)=>{h[i]={key:i,...a,hasSlug:!0}},b=(i,a)=>{h[i]={key:i,...a,hasSlug:!1}},g=()=>Object.values(h),s=i=>h[i];let _=async(i,a=!1,e=!1)=>({lang:i,isDraft:a,inBuilder:e});const C=i=>_=i,d=async(i,a,e)=>await _(i,a,e),S=(i,a)=>{({...a})},P={ab:"Abkhazian",aa:"Afar",af:"Afrikaans",ak:"Akan",sq:"Albanian",am:"Amharic",ar:"Arabic",an:"Aragonese",hy:"Armenian",as:"Assamese",av:"Avaric",ae:"Avestan",ay:"Aymara",az:"Azerbaijani",bm:"Bambara",ba:"Bashkir",eu:"Basque",be:"Belarusian",bn:"Bengali",bh:"Bihari",bi:"Bislama",bs:"Bosnian",br:"Breton",bg:"Bulgarian",my:"Burmese",ca:"Catalan",ch:"Chamorro",ce:"Chechen",ny:"Chichewa",zh:"Chinese","zh-Hans":"Chinese (Simplified)","zh-Hant":"Chinese (Traditional)",cv:"Chuvash",kw:"Cornish",co:"Corsican",cr:"Cree",hr:"Croatian",cs:"Czech",da:"Danish",dv:"Maldivian",nl:"Dutch",dz:"Dzongkha",en:"English",eo:"Esperanto",et:"Estonian",ee:"Ewe",fo:"Faroese",fj:"Fijian",fi:"Finnish",fr:"French",ff:"Fula, Pular",gl:"Galician",gd:"Gaelic (Scottish)",gv:"Manx",ka:"Georgian",de:"German",el:"Greek",kl:"Kalaallisut",gn:"Guarani",gu:"Gujarati",ht:"Haitian Creole",ha:"Hausa",he:"Hebrew",hz:"Herero",hi:"Hindi",ho:"Hiri Motu",hu:"Hungarian",is:"Icelandic",io:"Ido",ig:"Igbo",id:"Indonesian",ia:"Interlingua",ie:"Interlingue",iu:"Inuktitut",ik:"Inupiak",ga:"Irish",it:"Italian",ja:"Japanese",jv:"Javanese",kn:"Kannada",kr:"Kanuri",ks:"Kashmiri",kk:"Kazakh",km:"Khmer",ki:"Kikuyu",rw:"Kinyarwanda",rn:"Kirundi",ky:"Kyrgyz",kv:"Komi",kg:"Kongo",ko:"Korean",ku:"Kurdish",kj:"Kwanyama",lo:"Lao",la:"Latin",lv:"Latvian",li:"Limburgish",ln:"Lingala",lt:"Lithuanian",lu:"Luga-Katanga",lg:"Luganda, Ganda",lb:"Luxembourgish",mk:"Macedonian",mg:"Malagasy",ms:"Malay",ml:"Malayalam",mt:"Maltese",mi:"Maori",mr:"Marathi",mh:"Marshallese",mo:"Moldavian",mn:"Mongolian",na:"Nauru",nv:"Navajo",ng:"Ndonga",nd:"Northern Ndebele",ne:"Nepali",no:"Norwegian",nb:"Norwegian bokmål",nn:"Norwegian nynorsk",ii:"Sichuan Yi",oc:"Occitan",oj:"Ojibwe",cu:"Old Church Slavonic",or:"Oriya",om:"Oromo",os:"Ossetian",pi:"Pāli",ps:"Pashto, Pushto",fa:"Persian (Farsi)",pl:"Polish",pt:"Portuguese",pa:"Punjabi (Eastern)",qu:"Quechua",rm:"Romansh",ro:"Romanian",ru:"Russian",se:"Sami",sm:"Samoan",sg:"Sango",sa:"Sanskrit",sr:"Serbian",sh:"Serbo-Croatian",st:"Sesotho",tn:"Setswana",sn:"Shona",sd:"Sindhi",si:"Sinhalese",ss:"Swati",sk:"Slovak",sl:"Slovenian",so:"Somali",nr:"Southern Ndebele",es:"Spanish",su:"Sundanese",sw:"Swahili (Kiswahili)",sv:"Swedish",tl:"Tagalog",ty:"Tahitian",tg:"Tajik",ta:"Tamil",tt:"Tatar",te:"Telugu",th:"Thai",bo:"Tibetan",ti:"Tigrinya",to:"Tonga",ts:"Tsonga",tr:"Turkish",tk:"Turkmen",tw:"Twi",ug:"Uyghur",uk:"Ukrainian",ur:"Urdu",uz:"Uzbek",ve:"Venda",vi:"Vietnamese",vo:"Volapük",wa:"Wallon",cy:"Welsh",wo:"Wolof",fy:"Western Frisian",xh:"Xhosa",yi:"Yiddish",yo:"Yoruba",za:"Zhuang, Chuang",zu:"Zulu"},w="https://api.chaibuilder.com";class f{async verifyTokenAndGetUser(a){return console.log(a),{id:"mock-chai-user",name:"Mock Chai User",email:"mock-chai-user@chaibuilder.com"}}async isUserActive(a){return console.log("isUserActive",a),!0}async getUserPermissions(a){return console.log("getUserPermissions",a),["add_block","delete_block","save_as_template","edit_block","move_block","edit_theme","save_page","edit_styles","import_html","add_page","edit_page","edit_slug","delete_page","publish_page","unpublish_page","add_partial","edit_partial","delete_partial","publish_partial","unpublish_partial","edit_seo","restore_revision","delete_revision","publish_theme","add_library_block","add_library_template","edit_library_block","edit_library_template","delete_library_block","delete_library_template","add_media","edit_media","delete_media"]}async getUserInfo(a){return console.log("getUserInfo",a),{id:"mock-chai-user",email:"mock-chai-user@chaibuilder.com",name:"Mock Chai User",avatar:"https://i.pravatar.cc/300"}}}class A{constructor(a="",e=w){this.apiKey=a,this.apiUrl=e}async handleAction(a,e=""){return await(await fetch(`${this.apiUrl}/v1/api/chai`,{cache:"no-store",method:"POST",body:JSON.stringify(a),headers:{"x-chai-api-key":this.apiKey,...e?{"x-chai-user":e}:{}}})).json()}async handleUpload(a,e=""){return console.log("handleUpload",typeof a.get("file")),await(await fetch(`${this.apiUrl}/v1/api/chai`,{method:"POST",body:a,headers:{"x-chai-api-key":this.apiKey,"x-chai-upload":"true",...e?{"x-chai-user":e}:{}}})).json()}}class v{constructor(a){l(this,"fallbackLang","");l(this,"currentLang","");l(this,"draftMode",!1);l(this,"userMgmt",new f);this.backend=a,this._registerPageTypes()}_registerPageTypes(){k("page",{name:"Static Page",icon:'<svg stroke="currentColor" fill="currentColor" stroke-width="0" viewBox="0 0 24 24" height="1em" width="1em" xmlns="http://www.w3.org/2000/svg"><path d="M5 8V20H19V8H5ZM5 6H19V4H5V6ZM20 22H4C3.44772 22 3 21.5523 3 21V3C3 2.44772 3.44772 2 4 2H20C20.5523 2 21 2.44772 21 3V21C21 21.5523 20.5523 22 20 22ZM7 10H11V14H7V10ZM7 16H17V18H7V16ZM13 11H17V13H13V11Z"></path></svg>'}),b("global",{name:"Global Block",helpText:"A global block can be reused in multiple pages.",icon:'<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-globe w-4 h-4 text-slate-500 stroke-[1]"><circle cx="12" cy="12" r="10"></circle><path d="M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20"></path><path d="M2 12h20"></path></svg>'})}setUserManagement(a){this.userMgmt=a}setFallbackLang(a){this.fallbackLang=a}getFallbackLang(){return this.fallbackLang}setCurrentLang(a){this.currentLang=a}getCurrentLang(){return this.currentLang}setDraftMode(a){this.draftMode=a}isDraftMode(){return this.draftMode}async handleUpload(a,e=""){return await this.backend.handleUpload(a,e)}async handle(a,e){switch(a.action){case"CHECK_USER_STATUS":return this.userMgmt.isUserActive(e);case"GET_PERMISSIONS":return this.userMgmt.getUserPermissions(e);case"GET_CHAI_USER":return this.userMgmt.getUserInfo(e)}if(a.action==="GET_BUILDER_PAGE_DATA"){const t=await d(a.data.lang,!0,!0),r=s(a.data.pageType);return r?{...r.dataProvider?await r.dataProvider({},a.data.lang,!0,!0):{},global:t}:{global:t}}if(a.action==="GET_PAGE_TYPES")return Promise.all(g().map(async t=>({key:t.key,helpText:t.helpText??"",icon:t.icon??"",dynamicSegments:t.dynamicSegments??"",dynamicSlug:t.dynamicSlug??"",hasSlug:t.hasSlug??!0,name:typeof t.name=="function"?await t.name():t.name})));if(a.action==="SEARCH_PAGE_TYPE_ITEMS"){const t=s(a.data.pageType);return t?t.search?await t.search(a.data.query):this.backend.handleAction(a):{error:"Page type not found"}}const n=await this.backend.handleAction(a,e);return this.emit(a.action,n),n}emit(a,e){var r,o,c;if(!["CREATE_PAGE","UPDATE_PAGE","DELETE_PAGE"].includes(a))return;const n=u.get(e,"page");if(!n)return;const t=s(n.pageType);if(t)switch(a){case"CREATE_PAGE":return(r=t.onCreate)==null?void 0:r.call(t,n);case"UPDATE_PAGE":return(o=t.onUpdate)==null?void 0:o.call(t,n);case"DELETE_PAGE":return(c=t.onDelete)==null?void 0:c.call(t,n)}}setLanguageFromSlug(a){const e=u.first(a||[""]);Object.keys(P).includes(e)?this.setCurrentLang(e):this.setCurrentLang("")}async resolveLink(a,e){const n=s(a);if(!n)return"/not-found";const t=this.isDraftMode(),r=this.getCurrentLang();return n.resolveLink?await n.resolveLink(e,t,r):await this.backend.handleAction({action:"GET_LINK",data:{pageType:a,id:e,draft:t,lang:r}})}async getPageBySlug(a){const e=this.isDraftMode(),n={};return g().forEach(t=>{u.has(t,"dynamicSegments")&&t.dynamicSegments&&(n[t.key]=t.dynamicSegments)}),await this.backend.handleAction({action:"GET_PAGE_META",data:{slug:a,draft:e,dynamicSegments:n}})}async getFullPage(a){const e=this.isDraftMode(),n=this.getCurrentLang();return await this.backend.handleAction({action:"GET_PAGE",data:{id:a,lang:n,draft:e,mergePartials:!0}})}async getSiteSettings(){const a=this.isDraftMode();return await this.backend.handleAction({action:"GET_WEBSITE_SETTINGS",data:{draft:a}})}async getPageData(a,e){var m;const n=this.isDraftMode(),t=this.getCurrentLang(),r=s(a),[o,c]=await Promise.all([this.getGlobalData(),((m=r==null?void 0:r.dataProvider)==null?void 0:m.call(r,e,t,n))||Promise.resolve({})]);return r?{...c,global:o}:{global:o}}async getGlobalData(){const a=this.getCurrentLang();return await d(a,this.isDraftMode())}async request(a){return await this.backend.handleAction(a)}}exports.ChaiBuilderPages=v;exports.ChaiBuilderPagesBackend=A;exports.ChaiBuilderPagesUserManagement=f;exports.getChaiGlobalData=d;exports.getChaiPageType=s;exports.getChaiPageTypes=g;exports.registerChaiGlobalDataProvider=C;exports.registerChaiPageType=k;exports.registerChaiPartialType=b;exports.registerChaiTaxonomy=S;
|
package/dist/server.d.ts
CHANGED
|
@@ -22,6 +22,7 @@ export declare class ChaiBuilderPages implements ChaiBuilderPagesInterface {
|
|
|
22
22
|
getCurrentLang(): string;
|
|
23
23
|
setDraftMode(draft: boolean): void;
|
|
24
24
|
isDraftMode(): boolean;
|
|
25
|
+
handleUpload(formData: FormData, chaiUser?: string): Promise<any>;
|
|
25
26
|
handle(body: {
|
|
26
27
|
action: string;
|
|
27
28
|
data: Record<string, any>;
|
|
@@ -44,10 +45,12 @@ export declare class ChaiBuilderPagesBackend implements ChaiBuilderPagesBackendI
|
|
|
44
45
|
private apiUrl;
|
|
45
46
|
constructor(apiKey?: string, apiUrl?: string);
|
|
46
47
|
handleAction(body: any, chaiUser?: string): Promise<any>;
|
|
48
|
+
handleUpload(formData: FormData, chaiUser?: string): Promise<any>;
|
|
47
49
|
}
|
|
48
50
|
|
|
49
51
|
export declare interface ChaiBuilderPagesBackendInterface {
|
|
50
52
|
handleAction(body: any, chaiUser?: string): Promise<any>;
|
|
53
|
+
handleUpload(formData: FormData, chaiUser?: string): Promise<any>;
|
|
51
54
|
}
|
|
52
55
|
|
|
53
56
|
export declare interface ChaiBuilderPagesInterface {
|
|
@@ -125,6 +128,12 @@ export declare type ChaiBuilderUserInfo = {
|
|
|
125
128
|
avatar?: string;
|
|
126
129
|
};
|
|
127
130
|
|
|
131
|
+
export declare type ChaiWebsiteSetting = {
|
|
132
|
+
fallbackLang: string;
|
|
133
|
+
languages: string[];
|
|
134
|
+
theme: Record<"fontFamily" | "borderRadius" | "colors", any>;
|
|
135
|
+
};
|
|
136
|
+
|
|
128
137
|
export declare const getChaiGlobalData: (lang: string, isDraft?: boolean, inBuilder?: boolean) => Promise<any>;
|
|
129
138
|
|
|
130
139
|
export declare const getChaiPageType: (key: keyof typeof PAGE_TYPES) => ChaiBuilderPageType;
|
package/dist/server.js
CHANGED
|
@@ -1,8 +1,20 @@
|
|
|
1
1
|
var k = Object.defineProperty;
|
|
2
|
-
var b = (i, a,
|
|
3
|
-
var o = (i, a,
|
|
4
|
-
import { get as _, first as f, has as
|
|
5
|
-
const
|
|
2
|
+
var b = (i, a, e) => a in i ? k(i, a, { enumerable: !0, configurable: !0, writable: !0, value: e }) : i[a] = e;
|
|
3
|
+
var o = (i, a, e) => b(i, typeof a != "symbol" ? a + "" : a, e);
|
|
4
|
+
import { get as _, first as f, has as p } from "lodash-es";
|
|
5
|
+
const h = {}, S = (i, a) => {
|
|
6
|
+
h[i] = { key: i, ...a, hasSlug: !0 };
|
|
7
|
+
}, w = (i, a) => {
|
|
8
|
+
h[i] = { key: i, ...a, hasSlug: !1 };
|
|
9
|
+
}, g = () => Object.values(h), l = (i) => h[i];
|
|
10
|
+
let m = async (i, a = !1, e = !1) => ({
|
|
11
|
+
lang: i,
|
|
12
|
+
isDraft: a,
|
|
13
|
+
inBuilder: e
|
|
14
|
+
});
|
|
15
|
+
const P = (i) => m = i, d = async (i, a, e) => await m(i, a, e), M = (i, a) => {
|
|
16
|
+
({ ...a });
|
|
17
|
+
}, A = {
|
|
6
18
|
ab: "Abkhazian",
|
|
7
19
|
aa: "Afar",
|
|
8
20
|
af: "Afrikaans",
|
|
@@ -190,20 +202,8 @@ const A = {
|
|
|
190
202
|
yo: "Yoruba",
|
|
191
203
|
za: "Zhuang, Chuang",
|
|
192
204
|
zu: "Zulu"
|
|
193
|
-
},
|
|
194
|
-
|
|
195
|
-
}, E = (i, a) => {
|
|
196
|
-
h[i] = { key: i, ...a, hasSlug: !1 };
|
|
197
|
-
}, g = () => Object.values(h), l = (i) => h[i];
|
|
198
|
-
let m = async (i, a = !1, t = !1) => ({
|
|
199
|
-
lang: i,
|
|
200
|
-
isDraft: a,
|
|
201
|
-
inBuilder: t
|
|
202
|
-
});
|
|
203
|
-
const y = (i) => m = i, d = async (i, a, t) => await m(i, a, t), M = (i, a) => {
|
|
204
|
-
({ ...a });
|
|
205
|
-
}, p = "https://api.chaibuilder.com";
|
|
206
|
-
class v {
|
|
205
|
+
}, y = "https://api.chaibuilder.com";
|
|
206
|
+
class E {
|
|
207
207
|
async verifyTokenAndGetUser(a) {
|
|
208
208
|
return console.log(a), {
|
|
209
209
|
id: "mock-chai-user",
|
|
@@ -261,17 +261,29 @@ class v {
|
|
|
261
261
|
}
|
|
262
262
|
}
|
|
263
263
|
class T {
|
|
264
|
-
constructor(a = "",
|
|
265
|
-
this.apiKey = a, this.apiUrl =
|
|
264
|
+
constructor(a = "", e = y) {
|
|
265
|
+
this.apiKey = a, this.apiUrl = e;
|
|
266
266
|
}
|
|
267
|
-
async handleAction(a,
|
|
267
|
+
async handleAction(a, e = "") {
|
|
268
268
|
return await (await fetch(`${this.apiUrl}/v1/api/chai`, {
|
|
269
269
|
cache: "no-store",
|
|
270
270
|
method: "POST",
|
|
271
271
|
body: JSON.stringify(a),
|
|
272
272
|
headers: {
|
|
273
273
|
"x-chai-api-key": this.apiKey,
|
|
274
|
-
...
|
|
274
|
+
...e ? { "x-chai-user": e } : {}
|
|
275
|
+
}
|
|
276
|
+
})).json();
|
|
277
|
+
}
|
|
278
|
+
async handleUpload(a, e = "") {
|
|
279
|
+
return console.log("handleUpload", typeof a.get("file")), await (await fetch(`${this.apiUrl}/v1/api/chai`, {
|
|
280
|
+
method: "POST",
|
|
281
|
+
body: a,
|
|
282
|
+
headers: {
|
|
283
|
+
// "Content-Type": "multipart/form-data",
|
|
284
|
+
"x-chai-api-key": this.apiKey,
|
|
285
|
+
"x-chai-upload": "true",
|
|
286
|
+
...e ? { "x-chai-user": e } : {}
|
|
275
287
|
}
|
|
276
288
|
})).json();
|
|
277
289
|
}
|
|
@@ -281,14 +293,14 @@ class G {
|
|
|
281
293
|
o(this, "fallbackLang", "");
|
|
282
294
|
o(this, "currentLang", "");
|
|
283
295
|
o(this, "draftMode", !1);
|
|
284
|
-
o(this, "userMgmt", new
|
|
296
|
+
o(this, "userMgmt", new E());
|
|
285
297
|
this.backend = a, this._registerPageTypes();
|
|
286
298
|
}
|
|
287
299
|
_registerPageTypes() {
|
|
288
|
-
|
|
300
|
+
S("page", {
|
|
289
301
|
name: "Static Page",
|
|
290
302
|
icon: '<svg stroke="currentColor" fill="currentColor" stroke-width="0" viewBox="0 0 24 24" height="1em" width="1em" xmlns="http://www.w3.org/2000/svg"><path d="M5 8V20H19V8H5ZM5 6H19V4H5V6ZM20 22H4C3.44772 22 3 21.5523 3 21V3C3 2.44772 3.44772 2 4 2H20C20.5523 2 21 2.44772 21 3V21C21 21.5523 20.5523 22 20 22ZM7 10H11V14H7V10ZM7 16H17V18H7V16ZM13 11H17V13H13V11Z"></path></svg>'
|
|
291
|
-
}),
|
|
303
|
+
}), w("global", {
|
|
292
304
|
name: "Global Block",
|
|
293
305
|
helpText: "A global block can be reused in multiple pages.",
|
|
294
306
|
icon: '<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-globe w-4 h-4 text-slate-500 stroke-[1]"><circle cx="12" cy="12" r="10"></circle><path d="M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20"></path><path d="M2 12h20"></path></svg>'
|
|
@@ -315,95 +327,98 @@ class G {
|
|
|
315
327
|
isDraftMode() {
|
|
316
328
|
return this.draftMode;
|
|
317
329
|
}
|
|
318
|
-
async
|
|
330
|
+
async handleUpload(a, e = "") {
|
|
331
|
+
return await this.backend.handleUpload(a, e);
|
|
332
|
+
}
|
|
333
|
+
async handle(a, e) {
|
|
319
334
|
switch (a.action) {
|
|
320
335
|
case "CHECK_USER_STATUS":
|
|
321
|
-
return this.userMgmt.isUserActive(
|
|
336
|
+
return this.userMgmt.isUserActive(e);
|
|
322
337
|
case "GET_PERMISSIONS":
|
|
323
|
-
return this.userMgmt.getUserPermissions(
|
|
338
|
+
return this.userMgmt.getUserPermissions(e);
|
|
324
339
|
case "GET_CHAI_USER":
|
|
325
|
-
return this.userMgmt.getUserInfo(
|
|
340
|
+
return this.userMgmt.getUserInfo(e);
|
|
326
341
|
}
|
|
327
342
|
if (a.action === "GET_BUILDER_PAGE_DATA") {
|
|
328
|
-
const
|
|
343
|
+
const t = await d(a.data.lang, !0, !0), s = l(
|
|
329
344
|
a.data.pageType
|
|
330
345
|
);
|
|
331
|
-
return
|
|
332
|
-
...
|
|
333
|
-
global:
|
|
334
|
-
} : { global:
|
|
346
|
+
return s ? {
|
|
347
|
+
...s.dataProvider ? await s.dataProvider({}, a.data.lang, !0, !0) : {},
|
|
348
|
+
global: t
|
|
349
|
+
} : { global: t };
|
|
335
350
|
}
|
|
336
351
|
if (a.action === "GET_PAGE_TYPES")
|
|
337
352
|
return Promise.all(
|
|
338
|
-
g().map(async (
|
|
339
|
-
key:
|
|
340
|
-
helpText:
|
|
341
|
-
icon:
|
|
342
|
-
dynamicSegments:
|
|
343
|
-
dynamicSlug:
|
|
344
|
-
hasSlug:
|
|
345
|
-
name: typeof
|
|
353
|
+
g().map(async (t) => ({
|
|
354
|
+
key: t.key,
|
|
355
|
+
helpText: t.helpText ?? "",
|
|
356
|
+
icon: t.icon ?? "",
|
|
357
|
+
dynamicSegments: t.dynamicSegments ?? "",
|
|
358
|
+
dynamicSlug: t.dynamicSlug ?? "",
|
|
359
|
+
hasSlug: t.hasSlug ?? !0,
|
|
360
|
+
name: typeof t.name == "function" ? await t.name() : t.name
|
|
346
361
|
}))
|
|
347
362
|
);
|
|
348
363
|
if (a.action === "SEARCH_PAGE_TYPE_ITEMS") {
|
|
349
|
-
const
|
|
364
|
+
const t = l(
|
|
350
365
|
a.data.pageType
|
|
351
366
|
);
|
|
352
|
-
return
|
|
367
|
+
return t ? t.search ? await t.search(a.data.query) : this.backend.handleAction(a) : { error: "Page type not found" };
|
|
353
368
|
}
|
|
354
|
-
const n = await this.backend.handleAction(a,
|
|
369
|
+
const n = await this.backend.handleAction(a, e);
|
|
355
370
|
return this.emit(a.action, n), n;
|
|
356
371
|
}
|
|
357
|
-
emit(a,
|
|
358
|
-
var
|
|
372
|
+
emit(a, e) {
|
|
373
|
+
var s, r, c;
|
|
359
374
|
if (!["CREATE_PAGE", "UPDATE_PAGE", "DELETE_PAGE"].includes(a)) return;
|
|
360
|
-
const n = _(
|
|
375
|
+
const n = _(e, "page");
|
|
361
376
|
if (!n) return;
|
|
362
|
-
const
|
|
363
|
-
if (
|
|
377
|
+
const t = l(n.pageType);
|
|
378
|
+
if (t)
|
|
364
379
|
switch (a) {
|
|
365
380
|
case "CREATE_PAGE":
|
|
366
|
-
return (
|
|
381
|
+
return (s = t.onCreate) == null ? void 0 : s.call(t, n);
|
|
367
382
|
case "UPDATE_PAGE":
|
|
368
|
-
return (
|
|
383
|
+
return (r = t.onUpdate) == null ? void 0 : r.call(t, n);
|
|
369
384
|
case "DELETE_PAGE":
|
|
370
|
-
return (c =
|
|
385
|
+
return (c = t.onDelete) == null ? void 0 : c.call(t, n);
|
|
371
386
|
}
|
|
372
387
|
}
|
|
373
388
|
// APIS
|
|
374
389
|
setLanguageFromSlug(a) {
|
|
375
|
-
const
|
|
376
|
-
Object.keys(A).includes(
|
|
390
|
+
const e = f(a || [""]);
|
|
391
|
+
Object.keys(A).includes(e) ? this.setCurrentLang(e) : this.setCurrentLang("");
|
|
377
392
|
}
|
|
378
|
-
async resolveLink(a,
|
|
393
|
+
async resolveLink(a, e) {
|
|
379
394
|
const n = l(a);
|
|
380
395
|
if (!n)
|
|
381
396
|
return "/not-found";
|
|
382
|
-
const
|
|
383
|
-
return n.resolveLink ? await n.resolveLink(
|
|
397
|
+
const t = this.isDraftMode(), s = this.getCurrentLang();
|
|
398
|
+
return n.resolveLink ? await n.resolveLink(e, t, s) : await this.backend.handleAction({
|
|
384
399
|
action: "GET_LINK",
|
|
385
400
|
data: {
|
|
386
401
|
pageType: a,
|
|
387
|
-
id:
|
|
388
|
-
draft:
|
|
389
|
-
lang:
|
|
402
|
+
id: e,
|
|
403
|
+
draft: t,
|
|
404
|
+
lang: s
|
|
390
405
|
}
|
|
391
406
|
});
|
|
392
407
|
}
|
|
393
408
|
async getPageBySlug(a) {
|
|
394
|
-
const
|
|
395
|
-
return g().forEach((
|
|
396
|
-
|
|
409
|
+
const e = this.isDraftMode(), n = {};
|
|
410
|
+
return g().forEach((t) => {
|
|
411
|
+
p(t, "dynamicSegments") && t.dynamicSegments && (n[t.key] = t.dynamicSegments);
|
|
397
412
|
}), await this.backend.handleAction({
|
|
398
413
|
action: "GET_PAGE_META",
|
|
399
|
-
data: { slug: a, draft:
|
|
414
|
+
data: { slug: a, draft: e, dynamicSegments: n }
|
|
400
415
|
});
|
|
401
416
|
}
|
|
402
417
|
async getFullPage(a) {
|
|
403
|
-
const
|
|
418
|
+
const e = this.isDraftMode(), n = this.getCurrentLang();
|
|
404
419
|
return await this.backend.handleAction({
|
|
405
420
|
action: "GET_PAGE",
|
|
406
|
-
data: { id: a, lang: n, draft:
|
|
421
|
+
data: { id: a, lang: n, draft: e, mergePartials: !0 }
|
|
407
422
|
});
|
|
408
423
|
}
|
|
409
424
|
async getSiteSettings() {
|
|
@@ -413,16 +428,16 @@ class G {
|
|
|
413
428
|
data: { draft: a }
|
|
414
429
|
});
|
|
415
430
|
}
|
|
416
|
-
async getPageData(a,
|
|
431
|
+
async getPageData(a, e) {
|
|
417
432
|
var u;
|
|
418
|
-
const n = this.isDraftMode(),
|
|
433
|
+
const n = this.isDraftMode(), t = this.getCurrentLang(), s = l(a), [r, c] = await Promise.all([
|
|
419
434
|
this.getGlobalData(),
|
|
420
|
-
((u =
|
|
435
|
+
((u = s == null ? void 0 : s.dataProvider) == null ? void 0 : u.call(s, e, t, n)) || Promise.resolve({})
|
|
421
436
|
]);
|
|
422
|
-
return
|
|
437
|
+
return s ? {
|
|
423
438
|
...c,
|
|
424
|
-
global:
|
|
425
|
-
} : { global:
|
|
439
|
+
global: r
|
|
440
|
+
} : { global: r };
|
|
426
441
|
}
|
|
427
442
|
async getGlobalData() {
|
|
428
443
|
const a = this.getCurrentLang();
|
|
@@ -435,12 +450,12 @@ class G {
|
|
|
435
450
|
export {
|
|
436
451
|
G as ChaiBuilderPages,
|
|
437
452
|
T as ChaiBuilderPagesBackend,
|
|
438
|
-
|
|
453
|
+
E as ChaiBuilderPagesUserManagement,
|
|
439
454
|
d as getChaiGlobalData,
|
|
440
455
|
l as getChaiPageType,
|
|
441
456
|
g as getChaiPageTypes,
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
457
|
+
P as registerChaiGlobalDataProvider,
|
|
458
|
+
S as registerChaiPageType,
|
|
459
|
+
w as registerChaiPartialType,
|
|
445
460
|
M as registerChaiTaxonomy
|
|
446
461
|
};
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"author": "Suraj Air",
|
|
4
4
|
"license": "Private",
|
|
5
5
|
"homepage": "https://chaibuilder.com",
|
|
6
|
-
"version": "0.1.
|
|
6
|
+
"version": "0.1.17",
|
|
7
7
|
"type": "module",
|
|
8
8
|
"files": [
|
|
9
9
|
"dist"
|
|
@@ -59,7 +59,7 @@
|
|
|
59
59
|
"test": "vitest"
|
|
60
60
|
},
|
|
61
61
|
"peerDependencies": {
|
|
62
|
-
"@chaibuilder/sdk": "2.0.
|
|
62
|
+
"@chaibuilder/sdk": "2.0.12",
|
|
63
63
|
"@types/react": "*",
|
|
64
64
|
"@types/react-dom": "*",
|
|
65
65
|
"react": "^18.0 || ^19.0",
|
|
@@ -77,22 +77,26 @@
|
|
|
77
77
|
}
|
|
78
78
|
},
|
|
79
79
|
"dependencies": {
|
|
80
|
-
"@chaibuilder/runtime": "2.0.
|
|
81
|
-
"@chaibuilder/sdk": "2.0.
|
|
80
|
+
"@chaibuilder/runtime": "2.0.6",
|
|
81
|
+
"@chaibuilder/sdk": "2.0.12",
|
|
82
82
|
"@mhsdesign/jit-browser-tailwindcss": "^0.4.2",
|
|
83
83
|
"@tailwindcss/aspect-ratio": "^0.4.2",
|
|
84
84
|
"@tailwindcss/forms": "^0.5.10",
|
|
85
85
|
"@tailwindcss/typography": "^0.5.16",
|
|
86
86
|
"@tanstack/react-query": "^5.64.2",
|
|
87
|
+
"@types/express-fileupload": "^1.5.1",
|
|
87
88
|
"canvas-confetti": "^1.9.3",
|
|
88
89
|
"cssnano": "^7.0.6",
|
|
89
90
|
"date-fns": "^4.1.0",
|
|
91
|
+
"express-fileupload": "^1.5.1",
|
|
90
92
|
"framer-motion": "^12.0.3",
|
|
91
93
|
"fs": "0.0.1-security",
|
|
92
94
|
"jotai": "2.12.1",
|
|
93
95
|
"lodash-es": "^4.17.21",
|
|
94
96
|
"lucide-react": "^0.474.0",
|
|
95
97
|
"path": "^0.12.7",
|
|
98
|
+
"react-dropzone": "^14.3.8",
|
|
99
|
+
"react-image-crop": "^11.0.7",
|
|
96
100
|
"sonner": "^2.0.1",
|
|
97
101
|
"tailwind-merge": "^2.6.0",
|
|
98
102
|
"tailwindcss-animate": "^1.0.7",
|