@chaibuilder/pages 0.1.16 → 0.1.18
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-m7W6jLyZ.cjs → B4MFY5CR-Cy21w94o.cjs} +1 -1
- package/dist/{B4MFY5CR-B1LiRXyX.js → B4MFY5CR-JuKLBe8Q.js} +1 -1
- package/dist/{HO4MOOFI-D9R_K0Re.cjs → HO4MOOFI-CQ0y87Qr.cjs} +1 -1
- package/dist/{HO4MOOFI-BoB6vpqY.js → HO4MOOFI-sdcsvWJW.js} +2 -2
- package/dist/{HUY7CZI3-Cj4icxzC.js → HUY7CZI3-DDw0mu7q.js} +2 -2
- package/dist/{HUY7CZI3-BRZ5qwB3.cjs → HUY7CZI3-DxA4DG99.cjs} +1 -1
- package/dist/{index-BD0oij-u.js → index-Ch7IAe-z.js} +216 -215
- package/dist/{index-DPXLTEu-.cjs → index-Cof7sJuu.cjs} +2 -2
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +0 -2
- package/dist/index.js +1 -1
- package/dist/server.cjs +1 -1
- package/dist/server.d.ts +11 -5
- package/dist/server.js +73 -66
- package/package.json +4 -4
package/dist/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("./index-
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("./index-Cof7sJuu.cjs");exports.PermissionChecker=e.PermissionChecker;exports.default=e.ChaiBuilderPages;exports.registerChaiPanel=e.registerChaiPanel;exports.useChaiUserInfo=e.useChaiUserInfo;exports.useCurrentPage=e.useCurrentPage;exports.useFetch=e.useFetch;exports.useFetchUpload=e.useFetchUpload;exports.useLanguagePages=e.useLanguagePages;exports.useUserPermissions=e.useUserRoleAndPermissions;exports.useWebsitePages=e.useWebsitePages;exports.useWebsiteSetting=e.useWebsiteSetting;
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { X as a, W as r, Y as u, a5 as i, Z as t, a3 as g, a4 as n, _ as o, a2 as P, a0 as h, a1 as C } from "./index-
|
|
1
|
+
import { X as a, W as r, Y as u, a5 as i, Z as t, a3 as g, a4 as n, _ as o, a2 as P, a0 as h, a1 as C } from "./index-Ch7IAe-z.js";
|
|
2
2
|
export {
|
|
3
3
|
a as PermissionChecker,
|
|
4
4
|
r as default,
|
package/dist/server.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var f=Object.defineProperty;var y=(i,a,e)=>a in i?f(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"),c={},k=(i,a)=>{c[i]={key:i,...a,hasSlug:!0}},b=(i,a)=>{c[i]={key:i,...a,hasSlug:!1}},g=()=>Object.values(c),s=i=>c[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 p{async verifyTokenAndGetUser(a){return{id:"mock-chai-user",name:"Mock Chai User",email:"mock-chai-user@chaibuilder.com"}}async isUserActive(a){return!0}async getUserRoleAndPermissions(a){return{role:"admin",permissions:["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{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 E{constructor(a){l(this,"fallbackLang","");l(this,"currentLang","");l(this,"draftMode",!1);l(this,"userMgmt",new p);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_ROLE_AND_PERMISSIONS":return this.userMgmt.getUserRoleAndPermissions(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,h;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(h=t.onDelete)==null?void 0:h.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,h]=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?{...h,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=E;exports.ChaiBuilderPagesBackend=A;exports.ChaiBuilderPagesUserManagement=p;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
|
@@ -73,14 +73,17 @@ export declare interface ChaiBuilderPagesInterface {
|
|
|
73
73
|
}
|
|
74
74
|
|
|
75
75
|
export declare class ChaiBuilderPagesUserManagement implements ChaiBuilderPagesUserManagementInterface {
|
|
76
|
-
verifyTokenAndGetUser(
|
|
76
|
+
verifyTokenAndGetUser(_token: string): Promise<{
|
|
77
77
|
id: string;
|
|
78
78
|
name: string;
|
|
79
79
|
email: string;
|
|
80
80
|
}>;
|
|
81
|
-
isUserActive(
|
|
82
|
-
|
|
83
|
-
|
|
81
|
+
isUserActive(_userId: string): Promise<boolean>;
|
|
82
|
+
getUserRoleAndPermissions(_userId: string): Promise<{
|
|
83
|
+
role: string;
|
|
84
|
+
permissions: string[];
|
|
85
|
+
}>;
|
|
86
|
+
getUserInfo(_userId: string): Promise<{
|
|
84
87
|
id: string;
|
|
85
88
|
email: string;
|
|
86
89
|
name: string;
|
|
@@ -90,7 +93,10 @@ export declare class ChaiBuilderPagesUserManagement implements ChaiBuilderPagesU
|
|
|
90
93
|
|
|
91
94
|
export declare interface ChaiBuilderPagesUserManagementInterface {
|
|
92
95
|
isUserActive(chaiUserId: string): Promise<boolean>;
|
|
93
|
-
|
|
96
|
+
getUserRoleAndPermissions(chaiUserId: string): Promise<{
|
|
97
|
+
role: string;
|
|
98
|
+
permissions: string[];
|
|
99
|
+
}>;
|
|
94
100
|
verifyTokenAndGetUser(token: string): Promise<{
|
|
95
101
|
id: string;
|
|
96
102
|
name: string;
|
package/dist/server.js
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
var k = Object.defineProperty;
|
|
2
|
-
var
|
|
3
|
-
var o = (i, a, e) =>
|
|
4
|
-
import { get as
|
|
2
|
+
var _ = (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) => _(i, typeof a != "symbol" ? a + "" : a, e);
|
|
4
|
+
import { get as b, first as f, has as p } from "lodash-es";
|
|
5
5
|
const h = {}, S = (i, a) => {
|
|
6
6
|
h[i] = { key: i, ...a, hasSlug: !0 };
|
|
7
7
|
}, w = (i, a) => {
|
|
8
8
|
h[i] = { key: i, ...a, hasSlug: !1 };
|
|
9
|
-
},
|
|
9
|
+
}, d = () => Object.values(h), l = (i) => h[i];
|
|
10
10
|
let m = async (i, a = !1, e = !1) => ({
|
|
11
11
|
lang: i,
|
|
12
12
|
isDraft: a,
|
|
13
13
|
inBuilder: e
|
|
14
14
|
});
|
|
15
|
-
const P = (i) => m = i,
|
|
15
|
+
const P = (i) => m = i, g = async (i, a, e) => await m(i, a, e), M = (i, a) => {
|
|
16
16
|
({ ...a });
|
|
17
17
|
}, A = {
|
|
18
18
|
ab: "Abkhazian",
|
|
@@ -204,55 +204,62 @@ const P = (i) => m = i, d = async (i, a, e) => await m(i, a, e), M = (i, a) => {
|
|
|
204
204
|
zu: "Zulu"
|
|
205
205
|
}, y = "https://api.chaibuilder.com";
|
|
206
206
|
class E {
|
|
207
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
207
208
|
async verifyTokenAndGetUser(a) {
|
|
208
|
-
return
|
|
209
|
+
return {
|
|
209
210
|
id: "mock-chai-user",
|
|
210
211
|
name: "Mock Chai User",
|
|
211
212
|
email: "mock-chai-user@chaibuilder.com"
|
|
212
213
|
};
|
|
213
214
|
}
|
|
215
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
214
216
|
async isUserActive(a) {
|
|
215
|
-
return
|
|
217
|
+
return !0;
|
|
216
218
|
}
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
"
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
219
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
220
|
+
async getUserRoleAndPermissions(a) {
|
|
221
|
+
return {
|
|
222
|
+
role: "admin",
|
|
223
|
+
permissions: [
|
|
224
|
+
"add_block",
|
|
225
|
+
"delete_block",
|
|
226
|
+
"save_as_template",
|
|
227
|
+
"edit_block",
|
|
228
|
+
"move_block",
|
|
229
|
+
"edit_theme",
|
|
230
|
+
"save_page",
|
|
231
|
+
"edit_styles",
|
|
232
|
+
"import_html",
|
|
233
|
+
"add_page",
|
|
234
|
+
"edit_page",
|
|
235
|
+
"edit_slug",
|
|
236
|
+
"delete_page",
|
|
237
|
+
"publish_page",
|
|
238
|
+
"unpublish_page",
|
|
239
|
+
"add_partial",
|
|
240
|
+
"edit_partial",
|
|
241
|
+
"delete_partial",
|
|
242
|
+
"publish_partial",
|
|
243
|
+
"unpublish_partial",
|
|
244
|
+
"edit_seo",
|
|
245
|
+
"restore_revision",
|
|
246
|
+
"delete_revision",
|
|
247
|
+
"publish_theme",
|
|
248
|
+
"add_library_block",
|
|
249
|
+
"add_library_template",
|
|
250
|
+
"edit_library_block",
|
|
251
|
+
"edit_library_template",
|
|
252
|
+
"delete_library_block",
|
|
253
|
+
"delete_library_template",
|
|
254
|
+
"add_media",
|
|
255
|
+
"edit_media",
|
|
256
|
+
"delete_media"
|
|
257
|
+
]
|
|
258
|
+
};
|
|
253
259
|
}
|
|
260
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
254
261
|
async getUserInfo(a) {
|
|
255
|
-
return
|
|
262
|
+
return {
|
|
256
263
|
id: "mock-chai-user",
|
|
257
264
|
email: "mock-chai-user@chaibuilder.com",
|
|
258
265
|
name: "Mock Chai User",
|
|
@@ -334,23 +341,23 @@ class G {
|
|
|
334
341
|
switch (a.action) {
|
|
335
342
|
case "CHECK_USER_STATUS":
|
|
336
343
|
return this.userMgmt.isUserActive(e);
|
|
337
|
-
case "
|
|
338
|
-
return this.userMgmt.
|
|
344
|
+
case "GET_ROLE_AND_PERMISSIONS":
|
|
345
|
+
return this.userMgmt.getUserRoleAndPermissions(e);
|
|
339
346
|
case "GET_CHAI_USER":
|
|
340
347
|
return this.userMgmt.getUserInfo(e);
|
|
341
348
|
}
|
|
342
349
|
if (a.action === "GET_BUILDER_PAGE_DATA") {
|
|
343
|
-
const t = await
|
|
350
|
+
const t = await g(a.data.lang, !0, !0), r = l(
|
|
344
351
|
a.data.pageType
|
|
345
352
|
);
|
|
346
|
-
return
|
|
347
|
-
...
|
|
353
|
+
return r ? {
|
|
354
|
+
...r.dataProvider ? await r.dataProvider({}, a.data.lang, !0, !0) : {},
|
|
348
355
|
global: t
|
|
349
356
|
} : { global: t };
|
|
350
357
|
}
|
|
351
358
|
if (a.action === "GET_PAGE_TYPES")
|
|
352
359
|
return Promise.all(
|
|
353
|
-
|
|
360
|
+
d().map(async (t) => ({
|
|
354
361
|
key: t.key,
|
|
355
362
|
helpText: t.helpText ?? "",
|
|
356
363
|
icon: t.icon ?? "",
|
|
@@ -370,17 +377,17 @@ class G {
|
|
|
370
377
|
return this.emit(a.action, n), n;
|
|
371
378
|
}
|
|
372
379
|
emit(a, e) {
|
|
373
|
-
var
|
|
380
|
+
var r, s, c;
|
|
374
381
|
if (!["CREATE_PAGE", "UPDATE_PAGE", "DELETE_PAGE"].includes(a)) return;
|
|
375
|
-
const n =
|
|
382
|
+
const n = b(e, "page");
|
|
376
383
|
if (!n) return;
|
|
377
384
|
const t = l(n.pageType);
|
|
378
385
|
if (t)
|
|
379
386
|
switch (a) {
|
|
380
387
|
case "CREATE_PAGE":
|
|
381
|
-
return (
|
|
388
|
+
return (r = t.onCreate) == null ? void 0 : r.call(t, n);
|
|
382
389
|
case "UPDATE_PAGE":
|
|
383
|
-
return (
|
|
390
|
+
return (s = t.onUpdate) == null ? void 0 : s.call(t, n);
|
|
384
391
|
case "DELETE_PAGE":
|
|
385
392
|
return (c = t.onDelete) == null ? void 0 : c.call(t, n);
|
|
386
393
|
}
|
|
@@ -394,20 +401,20 @@ class G {
|
|
|
394
401
|
const n = l(a);
|
|
395
402
|
if (!n)
|
|
396
403
|
return "/not-found";
|
|
397
|
-
const t = this.isDraftMode(),
|
|
398
|
-
return n.resolveLink ? await n.resolveLink(e, t,
|
|
404
|
+
const t = this.isDraftMode(), r = this.getCurrentLang();
|
|
405
|
+
return n.resolveLink ? await n.resolveLink(e, t, r) : await this.backend.handleAction({
|
|
399
406
|
action: "GET_LINK",
|
|
400
407
|
data: {
|
|
401
408
|
pageType: a,
|
|
402
409
|
id: e,
|
|
403
410
|
draft: t,
|
|
404
|
-
lang:
|
|
411
|
+
lang: r
|
|
405
412
|
}
|
|
406
413
|
});
|
|
407
414
|
}
|
|
408
415
|
async getPageBySlug(a) {
|
|
409
416
|
const e = this.isDraftMode(), n = {};
|
|
410
|
-
return
|
|
417
|
+
return d().forEach((t) => {
|
|
411
418
|
p(t, "dynamicSegments") && t.dynamicSegments && (n[t.key] = t.dynamicSegments);
|
|
412
419
|
}), await this.backend.handleAction({
|
|
413
420
|
action: "GET_PAGE_META",
|
|
@@ -430,18 +437,18 @@ class G {
|
|
|
430
437
|
}
|
|
431
438
|
async getPageData(a, e) {
|
|
432
439
|
var u;
|
|
433
|
-
const n = this.isDraftMode(), t = this.getCurrentLang(),
|
|
440
|
+
const n = this.isDraftMode(), t = this.getCurrentLang(), r = l(a), [s, c] = await Promise.all([
|
|
434
441
|
this.getGlobalData(),
|
|
435
|
-
((u =
|
|
442
|
+
((u = r == null ? void 0 : r.dataProvider) == null ? void 0 : u.call(r, e, t, n)) || Promise.resolve({})
|
|
436
443
|
]);
|
|
437
|
-
return
|
|
444
|
+
return r ? {
|
|
438
445
|
...c,
|
|
439
|
-
global:
|
|
440
|
-
} : { global:
|
|
446
|
+
global: s
|
|
447
|
+
} : { global: s };
|
|
441
448
|
}
|
|
442
449
|
async getGlobalData() {
|
|
443
450
|
const a = this.getCurrentLang();
|
|
444
|
-
return await
|
|
451
|
+
return await g(a, this.isDraftMode());
|
|
445
452
|
}
|
|
446
453
|
async request(a) {
|
|
447
454
|
return await this.backend.handleAction(a);
|
|
@@ -451,9 +458,9 @@ export {
|
|
|
451
458
|
G as ChaiBuilderPages,
|
|
452
459
|
T as ChaiBuilderPagesBackend,
|
|
453
460
|
E as ChaiBuilderPagesUserManagement,
|
|
454
|
-
|
|
461
|
+
g as getChaiGlobalData,
|
|
455
462
|
l as getChaiPageType,
|
|
456
|
-
|
|
463
|
+
d as getChaiPageTypes,
|
|
457
464
|
P as registerChaiGlobalDataProvider,
|
|
458
465
|
S as registerChaiPageType,
|
|
459
466
|
w as registerChaiPartialType,
|
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.18",
|
|
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,8 +77,8 @@
|
|
|
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",
|