@steedos/service-pages 3.0.10 → 3.0.11-beta.1
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.
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
name: pages_schema
|
|
2
|
+
objectApiName: pages
|
|
3
|
+
isEnabled: true
|
|
4
|
+
script: |-
|
|
5
|
+
const pageId = ctx.input.pageId;
|
|
6
|
+
|
|
7
|
+
if (!pageId) {
|
|
8
|
+
throw new Error("pageId parameter is missing");
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
const pages = await ctx.getObject('pages').find({
|
|
12
|
+
filters: [['name', '=', pageId], "or", ['_id', '=', pageId]],
|
|
13
|
+
top: 1
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
// Fix: Check if a version was actually found to avoid "undefined" errors
|
|
17
|
+
if (!pages || pages.length === 0) {
|
|
18
|
+
// You can return null, an empty object, or throw a specific error depending on your UI needs
|
|
19
|
+
throw new Error("page not found");
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
const filters = [['page', '=', pages[0]._id], ['is_active', '=', true]];
|
|
23
|
+
const pageVersions = await ctx.getObject('page_versions').find({
|
|
24
|
+
filters: filters,
|
|
25
|
+
sort: 'version desc',
|
|
26
|
+
top: 1
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
// Fix: Check if a version was actually found to avoid "undefined" errors
|
|
30
|
+
if (!pageVersions || pageVersions.length === 0) {
|
|
31
|
+
// You can return null, an empty object, or throw a specific error depending on your UI needs
|
|
32
|
+
throw new Error("page has no active version");
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
const pageVersion = pageVersions[0];
|
|
36
|
+
let schema = pageVersion.schema;
|
|
37
|
+
|
|
38
|
+
if (typeof schema === 'string') {
|
|
39
|
+
try {
|
|
40
|
+
schema = JSON.parse(schema);
|
|
41
|
+
} catch (e) {
|
|
42
|
+
throw new Error("Failed to parse schema for page");
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
return {
|
|
47
|
+
"type": "inject",
|
|
48
|
+
"assets": [
|
|
49
|
+
{
|
|
50
|
+
"type": "css",
|
|
51
|
+
"id": "page-css",
|
|
52
|
+
"src": "/api/v6/pages/" + pageId + "/current/tailwind.css",
|
|
53
|
+
"location": "start",
|
|
54
|
+
}
|
|
55
|
+
],
|
|
56
|
+
"body": [schema]
|
|
57
|
+
};
|
|
58
|
+
locked: false
|
package/package.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@steedos/service-pages",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.0.11-beta.1",
|
|
4
4
|
"main": "package.service.js",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"publishConfig": {
|
|
7
7
|
"access": "public"
|
|
8
8
|
},
|
|
9
|
-
"gitHead": "
|
|
9
|
+
"gitHead": "e2a88411eaa992c424ea2221be45af9cec5367b5",
|
|
10
10
|
"dependencies": {
|
|
11
11
|
"clone": "^2.1.2",
|
|
12
12
|
"ejs": "^3.1.8"
|