@chaibuilder/pages 0.1.19 → 0.2.0
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-C_Pspicf.js → B4MFY5CR-Pz25m1RK.js} +1 -1
- package/dist/{B4MFY5CR-C5YWEgl9.cjs → B4MFY5CR-hFfovK0_.cjs} +1 -1
- package/dist/{HO4MOOFI-DY2QBu0y.cjs → HO4MOOFI-COdfBQo3.cjs} +1 -1
- package/dist/{HO4MOOFI-Do83nKZJ.js → HO4MOOFI-Cb3CTzDI.js} +2 -2
- package/dist/{HUY7CZI3-BL3e6hkF.cjs → HUY7CZI3-D4BY19cM.cjs} +1 -1
- package/dist/{HUY7CZI3-DGYGXLtV.js → HUY7CZI3-w0XnbOPP.js} +2 -2
- package/dist/index-DSDSpN_B.js +4844 -0
- package/dist/index-DhqrZyDj.cjs +2 -0
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +21 -53
- package/dist/index.js +14 -7
- package/dist/server.cjs +1 -1
- package/dist/server.d.ts +2 -2
- package/dist/server.js +76 -110
- package/package.json +3 -3
- package/dist/index-B8chLUn1.cjs +0 -2
- package/dist/index-filc7Z1g.js +0 -6711
package/dist/server.js
CHANGED
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
var k = Object.defineProperty;
|
|
2
|
-
var
|
|
3
|
-
var o = (
|
|
4
|
-
import { get as
|
|
5
|
-
const h = {},
|
|
6
|
-
h[
|
|
7
|
-
},
|
|
8
|
-
h[
|
|
9
|
-
},
|
|
10
|
-
let m = async (
|
|
11
|
-
lang:
|
|
2
|
+
var f = (t, a, e) => a in t ? k(t, a, { enumerable: !0, configurable: !0, writable: !0, value: e }) : t[a] = e;
|
|
3
|
+
var o = (t, a, e) => f(t, typeof a != "symbol" ? a + "" : a, e);
|
|
4
|
+
import { get as S, first as b, has as w } from "lodash-es";
|
|
5
|
+
const h = {}, A = (t, a) => {
|
|
6
|
+
h[t] = { key: t, ...a, hasSlug: !0 };
|
|
7
|
+
}, E = (t, a) => {
|
|
8
|
+
h[t] = { key: t, ...a, hasSlug: !1 };
|
|
9
|
+
}, g = () => Object.values(h), l = (t) => h[t];
|
|
10
|
+
let m = async (t, a = !1, e = !1) => ({
|
|
11
|
+
lang: t,
|
|
12
12
|
isDraft: a,
|
|
13
13
|
inBuilder: e
|
|
14
14
|
});
|
|
15
|
-
const
|
|
15
|
+
const M = (t) => m = t, d = async (t, a, e) => await m(t, a, e), T = (t, a) => {
|
|
16
16
|
({ ...a });
|
|
17
|
-
},
|
|
17
|
+
}, C = {
|
|
18
18
|
ab: "Abkhazian",
|
|
19
19
|
aa: "Afar",
|
|
20
20
|
af: "Afrikaans",
|
|
@@ -202,8 +202,8 @@ const P = (i) => m = i, g = async (i, a, e) => await m(i, a, e), M = (i, a) => {
|
|
|
202
202
|
yo: "Yoruba",
|
|
203
203
|
za: "Zhuang, Chuang",
|
|
204
204
|
zu: "Zulu"
|
|
205
|
-
},
|
|
206
|
-
class
|
|
205
|
+
}, P = "https://api.chaibuilder.com";
|
|
206
|
+
class y {
|
|
207
207
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
208
208
|
async verifyTokenAndGetUser(a) {
|
|
209
209
|
return {
|
|
@@ -220,55 +220,21 @@ class E {
|
|
|
220
220
|
async getUserRoleAndPermissions(a) {
|
|
221
221
|
return {
|
|
222
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
|
-
]
|
|
223
|
+
permissions: null
|
|
258
224
|
};
|
|
259
225
|
}
|
|
260
226
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
261
227
|
async getUserInfo(a) {
|
|
262
228
|
return {
|
|
263
|
-
id: "mock-chai-
|
|
229
|
+
id: "mock-chai-users",
|
|
264
230
|
email: "mock-chai-user@chaibuilder.com",
|
|
265
231
|
name: "Mock Chai User",
|
|
266
232
|
avatar: "https://i.pravatar.cc/300"
|
|
267
233
|
};
|
|
268
234
|
}
|
|
269
235
|
}
|
|
270
|
-
class
|
|
271
|
-
constructor(a = "", e =
|
|
236
|
+
class G {
|
|
237
|
+
constructor(a = "", e = P) {
|
|
272
238
|
this.apiKey = a, this.apiUrl = e;
|
|
273
239
|
}
|
|
274
240
|
async handleAction(a, e = "") {
|
|
@@ -295,19 +261,19 @@ class T {
|
|
|
295
261
|
})).json();
|
|
296
262
|
}
|
|
297
263
|
}
|
|
298
|
-
class
|
|
264
|
+
class L {
|
|
299
265
|
constructor(a) {
|
|
300
266
|
o(this, "fallbackLang", "");
|
|
301
267
|
o(this, "currentLang", "");
|
|
302
268
|
o(this, "draftMode", !1);
|
|
303
|
-
o(this, "userMgmt", new
|
|
269
|
+
o(this, "userMgmt", new y());
|
|
304
270
|
this.backend = a, this._registerPageTypes();
|
|
305
271
|
}
|
|
306
272
|
_registerPageTypes() {
|
|
307
|
-
|
|
273
|
+
A("page", {
|
|
308
274
|
name: "Static Page",
|
|
309
275
|
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>'
|
|
310
|
-
}),
|
|
276
|
+
}), E("global", {
|
|
311
277
|
name: "Global Block",
|
|
312
278
|
helpText: "A global block can be reused in multiple pages.",
|
|
313
279
|
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>'
|
|
@@ -347,85 +313,85 @@ class G {
|
|
|
347
313
|
return this.userMgmt.getUserInfo(e);
|
|
348
314
|
}
|
|
349
315
|
if (a.action === "GET_BUILDER_PAGE_DATA") {
|
|
350
|
-
const
|
|
316
|
+
const n = await d(a.data.lang, !0, !0), s = l(
|
|
351
317
|
a.data.pageType
|
|
352
318
|
);
|
|
353
|
-
return
|
|
354
|
-
...
|
|
355
|
-
global:
|
|
356
|
-
} : { global:
|
|
319
|
+
return s ? {
|
|
320
|
+
...s.dataProvider ? await s.dataProvider({}, a.data.lang, !0, !0) : {},
|
|
321
|
+
global: n
|
|
322
|
+
} : { global: n };
|
|
357
323
|
}
|
|
358
324
|
if (a.action === "GET_PAGE_TYPES")
|
|
359
325
|
return Promise.all(
|
|
360
|
-
|
|
361
|
-
key:
|
|
362
|
-
helpText:
|
|
363
|
-
icon:
|
|
364
|
-
dynamicSegments:
|
|
365
|
-
dynamicSlug:
|
|
366
|
-
hasSlug:
|
|
367
|
-
name: typeof
|
|
326
|
+
g().map(async (n) => ({
|
|
327
|
+
key: n.key,
|
|
328
|
+
helpText: n.helpText ?? "",
|
|
329
|
+
icon: n.icon ?? "",
|
|
330
|
+
dynamicSegments: n.dynamicSegments ?? "",
|
|
331
|
+
dynamicSlug: n.dynamicSlug ?? "",
|
|
332
|
+
hasSlug: n.hasSlug ?? !0,
|
|
333
|
+
name: typeof n.name == "function" ? await n.name() : n.name
|
|
368
334
|
}))
|
|
369
335
|
);
|
|
370
336
|
if (a.action === "SEARCH_PAGE_TYPE_ITEMS") {
|
|
371
|
-
const
|
|
337
|
+
const n = l(
|
|
372
338
|
a.data.pageType
|
|
373
339
|
);
|
|
374
|
-
return
|
|
340
|
+
return n ? n.search ? await n.search(a.data.query) : this.backend.handleAction(a) : { error: "Page type not found" };
|
|
375
341
|
}
|
|
376
|
-
const
|
|
377
|
-
return this.emit(a.action,
|
|
342
|
+
const i = await this.backend.handleAction(a, e);
|
|
343
|
+
return this.emit(a.action, i), i;
|
|
378
344
|
}
|
|
379
345
|
emit(a, e) {
|
|
380
|
-
var
|
|
346
|
+
var s, r, c;
|
|
381
347
|
if (!["CREATE_PAGE", "UPDATE_PAGE", "DELETE_PAGE"].includes(a)) return;
|
|
382
|
-
const
|
|
383
|
-
if (!
|
|
384
|
-
const
|
|
385
|
-
if (
|
|
348
|
+
const i = S(e, "page");
|
|
349
|
+
if (!i) return;
|
|
350
|
+
const n = l(i.pageType);
|
|
351
|
+
if (n)
|
|
386
352
|
switch (a) {
|
|
387
353
|
case "CREATE_PAGE":
|
|
388
|
-
return (
|
|
354
|
+
return (s = n.onCreate) == null ? void 0 : s.call(n, i);
|
|
389
355
|
case "UPDATE_PAGE":
|
|
390
|
-
return (
|
|
356
|
+
return (r = n.onUpdate) == null ? void 0 : r.call(n, i);
|
|
391
357
|
case "DELETE_PAGE":
|
|
392
|
-
return (c =
|
|
358
|
+
return (c = n.onDelete) == null ? void 0 : c.call(n, i);
|
|
393
359
|
}
|
|
394
360
|
}
|
|
395
361
|
// APIS
|
|
396
362
|
setLanguageFromSlug(a) {
|
|
397
|
-
const e =
|
|
398
|
-
Object.keys(
|
|
363
|
+
const e = b(a || [""]);
|
|
364
|
+
Object.keys(C).includes(e) ? this.setCurrentLang(e) : this.setCurrentLang("");
|
|
399
365
|
}
|
|
400
366
|
async resolveLink(a, e) {
|
|
401
|
-
const
|
|
402
|
-
if (!
|
|
367
|
+
const i = l(a);
|
|
368
|
+
if (!i)
|
|
403
369
|
return "/not-found";
|
|
404
|
-
const
|
|
405
|
-
return
|
|
370
|
+
const n = this.isDraftMode(), s = this.getCurrentLang();
|
|
371
|
+
return i.resolveLink ? await i.resolveLink(e, n, s) : await this.backend.handleAction({
|
|
406
372
|
action: "GET_LINK",
|
|
407
373
|
data: {
|
|
408
374
|
pageType: a,
|
|
409
375
|
id: e,
|
|
410
|
-
draft:
|
|
411
|
-
lang:
|
|
376
|
+
draft: n,
|
|
377
|
+
lang: s
|
|
412
378
|
}
|
|
413
379
|
});
|
|
414
380
|
}
|
|
415
381
|
async getPageBySlug(a) {
|
|
416
|
-
const e = this.isDraftMode(),
|
|
417
|
-
return
|
|
418
|
-
|
|
382
|
+
const e = this.isDraftMode(), i = {};
|
|
383
|
+
return g().forEach((n) => {
|
|
384
|
+
w(n, "dynamicSegments") && n.dynamicSegments && (i[n.key] = n.dynamicSegments);
|
|
419
385
|
}), await this.backend.handleAction({
|
|
420
386
|
action: "GET_PAGE_META",
|
|
421
|
-
data: { slug: a, draft: e, dynamicSegments:
|
|
387
|
+
data: { slug: a, draft: e, dynamicSegments: i }
|
|
422
388
|
});
|
|
423
389
|
}
|
|
424
390
|
async getFullPage(a) {
|
|
425
|
-
const e = this.isDraftMode(),
|
|
391
|
+
const e = this.isDraftMode(), i = this.getCurrentLang();
|
|
426
392
|
return await this.backend.handleAction({
|
|
427
393
|
action: "GET_PAGE",
|
|
428
|
-
data: { id: a, lang:
|
|
394
|
+
data: { id: a, lang: i, draft: e, mergePartials: !0 }
|
|
429
395
|
});
|
|
430
396
|
}
|
|
431
397
|
async getSiteSettings() {
|
|
@@ -437,32 +403,32 @@ class G {
|
|
|
437
403
|
}
|
|
438
404
|
async getPageData(a, e) {
|
|
439
405
|
var u;
|
|
440
|
-
const
|
|
406
|
+
const i = this.isDraftMode(), n = this.getCurrentLang(), s = l(a), [r, c] = await Promise.all([
|
|
441
407
|
this.getGlobalData(),
|
|
442
|
-
((u =
|
|
408
|
+
((u = s == null ? void 0 : s.dataProvider) == null ? void 0 : u.call(s, e, n, i)) || Promise.resolve({})
|
|
443
409
|
]);
|
|
444
|
-
return
|
|
410
|
+
return s ? {
|
|
445
411
|
...c,
|
|
446
|
-
global:
|
|
447
|
-
} : { global:
|
|
412
|
+
global: r
|
|
413
|
+
} : { global: r };
|
|
448
414
|
}
|
|
449
415
|
async getGlobalData() {
|
|
450
416
|
const a = this.getCurrentLang();
|
|
451
|
-
return await
|
|
417
|
+
return await d(a, this.isDraftMode());
|
|
452
418
|
}
|
|
453
419
|
async request(a) {
|
|
454
420
|
return await this.backend.handleAction(a);
|
|
455
421
|
}
|
|
456
422
|
}
|
|
457
423
|
export {
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
424
|
+
L as ChaiBuilderPages,
|
|
425
|
+
G as ChaiBuilderPagesBackend,
|
|
426
|
+
y as ChaiBuilderPagesUserManagement,
|
|
427
|
+
d as getChaiGlobalData,
|
|
462
428
|
l as getChaiPageType,
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
429
|
+
g as getChaiPageTypes,
|
|
430
|
+
M as registerChaiGlobalDataProvider,
|
|
431
|
+
A as registerChaiPageType,
|
|
432
|
+
E as registerChaiPartialType,
|
|
433
|
+
T as registerChaiTaxonomy
|
|
468
434
|
};
|
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.
|
|
6
|
+
"version": "0.2.0",
|
|
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.
|
|
62
|
+
"@chaibuilder/sdk": "2.1.3",
|
|
63
63
|
"@types/react": "*",
|
|
64
64
|
"@types/react-dom": "*",
|
|
65
65
|
"react": "^18.0 || ^19.0",
|
|
@@ -78,7 +78,7 @@
|
|
|
78
78
|
},
|
|
79
79
|
"dependencies": {
|
|
80
80
|
"@chaibuilder/runtime": "2.0.6",
|
|
81
|
-
"@chaibuilder/sdk": "2.
|
|
81
|
+
"@chaibuilder/sdk": "2.1.3",
|
|
82
82
|
"@mhsdesign/jit-browser-tailwindcss": "^0.4.2",
|
|
83
83
|
"@tailwindcss/aspect-ratio": "^0.4.2",
|
|
84
84
|
"@tailwindcss/forms": "^0.5.10",
|