@pronto-tools-and-more/pronto 12.23.0 → 12.24.0
Sign up to get free protection for your applications and to get access to all the features.
- package/package.json +11 -11
- package/src/parts/GraphQlQueryContent/GraphQlQueryContent.js +198 -0
- package/src/parts/GraphQlQueryPathSegments/GraphQlQueryPathSegments.js +59 -0
- package/src/parts/HandleApi/HandleApi.js +4 -0
- package/src/parts/HandleApiArticle/HandleApiArticle.js +100 -0
- package/src/parts/Version/Version.js +1 -1
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@pronto-tools-and-more/pronto",
|
3
|
-
"version": "12.
|
3
|
+
"version": "12.24.0",
|
4
4
|
"description": "",
|
5
5
|
"main": "src/main.js",
|
6
6
|
"type": "module",
|
@@ -17,16 +17,16 @@
|
|
17
17
|
"@lvce-editor/ipc": "^13.7.0",
|
18
18
|
"@lvce-editor/json-rpc": "^5.4.0",
|
19
19
|
"@lvce-editor/verror": "^1.6.0",
|
20
|
-
"@pronto-tools-and-more/file-watcher": "12.
|
21
|
-
"@pronto-tools-and-more/files": "12.
|
22
|
-
"@pronto-tools-and-more/network-process": "12.
|
23
|
-
"@pronto-tools-and-more/sass-compiler": "12.
|
24
|
-
"@pronto-tools-and-more/components-renderer": "12.
|
25
|
-
"@pronto-tools-and-more/components": "12.
|
26
|
-
"@pronto-tools-and-more/schema-process": "12.
|
27
|
-
"@pronto-tools-and-more/diff-process": "12.
|
28
|
-
"@pronto-tools-and-more/type-checker": "12.
|
29
|
-
"@pronto-tools-and-more/custom-js-functions": "12.
|
20
|
+
"@pronto-tools-and-more/file-watcher": "12.24.0",
|
21
|
+
"@pronto-tools-and-more/files": "12.24.0",
|
22
|
+
"@pronto-tools-and-more/network-process": "12.24.0",
|
23
|
+
"@pronto-tools-and-more/sass-compiler": "12.24.0",
|
24
|
+
"@pronto-tools-and-more/components-renderer": "12.24.0",
|
25
|
+
"@pronto-tools-and-more/components": "12.24.0",
|
26
|
+
"@pronto-tools-and-more/schema-process": "12.24.0",
|
27
|
+
"@pronto-tools-and-more/diff-process": "12.24.0",
|
28
|
+
"@pronto-tools-and-more/type-checker": "12.24.0",
|
29
|
+
"@pronto-tools-and-more/custom-js-functions": "12.24.0",
|
30
30
|
"execa": "^9.5.2",
|
31
31
|
"express": "^4.21.2"
|
32
32
|
},
|
@@ -0,0 +1,198 @@
|
|
1
|
+
export const top = `query CatalogContentsQuery($appInfo: AppInfo!, $deviceInfo: DeviceInfo!, $authorization: Authorization!, $filter: ContentFilter, $sort: [ContentComparator!], $first: Int, $after: String, $includeBundledContent: Boolean!, $includeResources: Boolean!, $includeBlocks: Boolean!, $includeHtml: Boolean!, $includeContentSeoMetadata: Boolean!, $propertyFilter: PropertyFilter) {
|
2
|
+
catalog(
|
3
|
+
appInfo: $appInfo
|
4
|
+
deviceInfo: $deviceInfo
|
5
|
+
authorization: $authorization
|
6
|
+
) {
|
7
|
+
contentsConnection(filter: $filter, sort: $sort, first: $first, after: $after) {
|
8
|
+
pageInfo {
|
9
|
+
hasNextPage
|
10
|
+
endCursor
|
11
|
+
}
|
12
|
+
edges {
|
13
|
+
content: node {
|
14
|
+
__typename
|
15
|
+
...ContentFragment
|
16
|
+
...PostFragment
|
17
|
+
...IssueFragment
|
18
|
+
...BundleFragment
|
19
|
+
}
|
20
|
+
}
|
21
|
+
}
|
22
|
+
}
|
23
|
+
}
|
24
|
+
|
25
|
+
fragment ContentFragment on Content {
|
26
|
+
__typename
|
27
|
+
id
|
28
|
+
version
|
29
|
+
name
|
30
|
+
description
|
31
|
+
index
|
32
|
+
alias
|
33
|
+
externalId
|
34
|
+
publicationDate
|
35
|
+
unpublishDate
|
36
|
+
lastModified
|
37
|
+
access
|
38
|
+
productId
|
39
|
+
purchaseData {
|
40
|
+
purchased
|
41
|
+
purchasedBy
|
42
|
+
}
|
43
|
+
publication {
|
44
|
+
id
|
45
|
+
}
|
46
|
+
properties(filter: $propertyFilter) {
|
47
|
+
key
|
48
|
+
value
|
49
|
+
}
|
50
|
+
seoMetadata @include(if: $includeContentSeoMetadata) {
|
51
|
+
key
|
52
|
+
value
|
53
|
+
}
|
54
|
+
thumbnails {
|
55
|
+
kind
|
56
|
+
url
|
57
|
+
properties {
|
58
|
+
key
|
59
|
+
value
|
60
|
+
}
|
61
|
+
}
|
62
|
+
categories
|
63
|
+
tags
|
64
|
+
}
|
65
|
+
|
66
|
+
fragment PostFragment on Post {
|
67
|
+
postType
|
68
|
+
bundleId
|
69
|
+
bundles {
|
70
|
+
id
|
71
|
+
bundleType
|
72
|
+
}
|
73
|
+
taxonomies {
|
74
|
+
...TaxonomySummaryFragment
|
75
|
+
}
|
76
|
+
authors {
|
77
|
+
name
|
78
|
+
email
|
79
|
+
}
|
80
|
+
bundleId
|
81
|
+
content @include(if: $includeBlocks) {
|
82
|
+
...ContentBlockFragment
|
83
|
+
}
|
84
|
+
previewContentBlocks @include(if: $includeBlocks) {
|
85
|
+
...ContentBlockFragment
|
86
|
+
}
|
87
|
+
contentHtml @include(if: $includeHtml)
|
88
|
+
previewContentHtml @include(if: $includeHtml)
|
89
|
+
resources @include(if: $includeResources) {
|
90
|
+
id
|
91
|
+
url
|
92
|
+
type
|
93
|
+
contentLength
|
94
|
+
properties {
|
95
|
+
key
|
96
|
+
value
|
97
|
+
type
|
98
|
+
}
|
99
|
+
}
|
100
|
+
}
|
101
|
+
|
102
|
+
fragment ContentBlockFragment on ContentBlock {
|
103
|
+
id
|
104
|
+
type
|
105
|
+
parentId
|
106
|
+
children
|
107
|
+
sequence
|
108
|
+
html
|
109
|
+
level
|
110
|
+
properties {
|
111
|
+
key
|
112
|
+
value
|
113
|
+
type
|
114
|
+
}
|
115
|
+
}
|
116
|
+
|
117
|
+
fragment BundleFragment on Bundle {
|
118
|
+
bundleType
|
119
|
+
taxonomies {
|
120
|
+
...TaxonomySummaryFragment
|
121
|
+
}
|
122
|
+
authors {
|
123
|
+
name
|
124
|
+
email
|
125
|
+
}
|
126
|
+
contents @include(if: $includeBundledContent) {
|
127
|
+
id
|
128
|
+
content {
|
129
|
+
...ContentFragment
|
130
|
+
...PostFragment
|
131
|
+
}
|
132
|
+
}
|
133
|
+
}
|
134
|
+
|
135
|
+
fragment IssueFragment on Issue {
|
136
|
+
contentLength
|
137
|
+
numberOfPages
|
138
|
+
previewContentLength
|
139
|
+
resources @include(if: $includeResources) {
|
140
|
+
id
|
141
|
+
url
|
142
|
+
type
|
143
|
+
contentLength
|
144
|
+
properties {
|
145
|
+
key
|
146
|
+
value
|
147
|
+
type
|
148
|
+
}
|
149
|
+
}
|
150
|
+
}
|
151
|
+
|
152
|
+
fragment TaxonomySummaryFragment on Taxonomy {
|
153
|
+
id
|
154
|
+
internalId
|
155
|
+
name
|
156
|
+
type
|
157
|
+
parentId
|
158
|
+
seoMetadata @include(if: $includeContentSeoMetadata) {
|
159
|
+
key
|
160
|
+
value
|
161
|
+
}
|
162
|
+
properties {
|
163
|
+
key
|
164
|
+
value
|
165
|
+
}
|
166
|
+
}`;
|
167
|
+
|
168
|
+
export const bottom = {
|
169
|
+
filter: {
|
170
|
+
id: {
|
171
|
+
value: "",
|
172
|
+
},
|
173
|
+
},
|
174
|
+
first: 1,
|
175
|
+
includeBlocks: true,
|
176
|
+
includeHtml: true,
|
177
|
+
includeResources: true,
|
178
|
+
includeBundledContent: false,
|
179
|
+
includeContentSeoMetadata: false,
|
180
|
+
appInfo: {
|
181
|
+
appId: "",
|
182
|
+
appVersion: "1.0-SNAPSHOT",
|
183
|
+
preview: true,
|
184
|
+
},
|
185
|
+
deviceInfo: {
|
186
|
+
deviceId: "editor-preview",
|
187
|
+
deviceModel: "web",
|
188
|
+
locale: "de_DE",
|
189
|
+
smallestScreenWidthDp: 0,
|
190
|
+
deviceOs: "web",
|
191
|
+
platform: "WEB",
|
192
|
+
},
|
193
|
+
authorization: {
|
194
|
+
subscriptionCodes: [],
|
195
|
+
},
|
196
|
+
};
|
197
|
+
|
198
|
+
export const queryName = "CatalogContentsQuery";
|
@@ -0,0 +1,59 @@
|
|
1
|
+
export const top = `query LookupPathSegmentsQuery($appInfo: AppInfo!, $deviceInfo: DeviceInfo!, $authorization: Authorization!, $pathSegments: [String!]!) {
|
2
|
+
catalog(
|
3
|
+
appInfo: $appInfo
|
4
|
+
deviceInfo: $deviceInfo
|
5
|
+
authorization: $authorization
|
6
|
+
) {
|
7
|
+
lookupPathSegments(pathSegments: $pathSegments) {
|
8
|
+
identifier
|
9
|
+
matches {
|
10
|
+
__typename
|
11
|
+
... on ContentMatch {
|
12
|
+
id
|
13
|
+
contentType
|
14
|
+
postType
|
15
|
+
}
|
16
|
+
... on TaxonomyMatch {
|
17
|
+
id
|
18
|
+
identifier
|
19
|
+
parentIdentifier
|
20
|
+
name
|
21
|
+
taxonomyType
|
22
|
+
}
|
23
|
+
... on CollectionMatch {
|
24
|
+
id
|
25
|
+
name
|
26
|
+
}
|
27
|
+
... on RedirectMatch {
|
28
|
+
id
|
29
|
+
identifier
|
30
|
+
redirectType
|
31
|
+
target
|
32
|
+
statusCode
|
33
|
+
}
|
34
|
+
}
|
35
|
+
}
|
36
|
+
}
|
37
|
+
}`;
|
38
|
+
|
39
|
+
export const bottom = {
|
40
|
+
pathSegments: [],
|
41
|
+
appInfo: {
|
42
|
+
appId: "",
|
43
|
+
appVersion: "1.0-SNAPSHOT",
|
44
|
+
preview: true,
|
45
|
+
},
|
46
|
+
deviceInfo: {
|
47
|
+
deviceId: "editor-preview",
|
48
|
+
deviceModel: "web",
|
49
|
+
locale: "de_DE",
|
50
|
+
smallestScreenWidthDp: 0,
|
51
|
+
deviceOs: "web",
|
52
|
+
platform: "WEB",
|
53
|
+
},
|
54
|
+
authorization: {
|
55
|
+
subscriptionCodes: [],
|
56
|
+
},
|
57
|
+
};
|
58
|
+
|
59
|
+
export const queryName = "LookupPathSegmentsQuery";
|
@@ -4,6 +4,7 @@ import * as HandleDossiers from "../HandleApiDossiers/HandleApiDossiers.js";
|
|
4
4
|
import * as HandleApiIndex from "../HandleApiIndex/HandleApiIndex.js";
|
5
5
|
import * as HandleApiIssues from "../HandleApiIssues/HandleApiIssues.js";
|
6
6
|
import * as HandleApiAuthors from "../HandleApiAuthors/HandleApiAuthors.js";
|
7
|
+
import * as HandleApiArticle from "../HandleApiArticle/HandleApiArticle.js";
|
7
8
|
|
8
9
|
export const handleApi =
|
9
10
|
({ appId }) =>
|
@@ -26,6 +27,9 @@ export const handleApi =
|
|
26
27
|
if (req.url === "/authors") {
|
27
28
|
return HandleApiAuthors.handleAuthors(appId)(req, res);
|
28
29
|
}
|
30
|
+
if (req.url.startsWith("/articles")) {
|
31
|
+
return HandleApiArticle.handleApiArticle(appId)(req, res);
|
32
|
+
}
|
29
33
|
res.statusCode = 404;
|
30
34
|
return res.end("not found");
|
31
35
|
};
|
@@ -0,0 +1,100 @@
|
|
1
|
+
import * as GraphQlQueryPathSegments from "../GraphQlQueryPathSegments/GraphQlQueryPathSegments.js";
|
2
|
+
import * as GraphQlQueryContent from "../GraphQlQueryContent/GraphQlQueryContent.js";
|
3
|
+
|
4
|
+
const getPostIds = async (appId, slug) => {
|
5
|
+
const url = `https://catalog.purplemanager.com/graphql`;
|
6
|
+
const realBottom = {
|
7
|
+
...GraphQlQueryPathSegments.bottom,
|
8
|
+
appInfo: {
|
9
|
+
...GraphQlQueryPathSegments.bottom.appInfo,
|
10
|
+
appId,
|
11
|
+
},
|
12
|
+
pathSegments: [slug],
|
13
|
+
};
|
14
|
+
const response = await fetch(url, {
|
15
|
+
method: "POST",
|
16
|
+
headers: {
|
17
|
+
Accept: "application/json",
|
18
|
+
"Content-Type": "application/json",
|
19
|
+
},
|
20
|
+
body: JSON.stringify({
|
21
|
+
operationName: GraphQlQueryPathSegments.queryName,
|
22
|
+
query: GraphQlQueryPathSegments.top,
|
23
|
+
variables: realBottom,
|
24
|
+
}),
|
25
|
+
});
|
26
|
+
const result = await response.json();
|
27
|
+
// @ts-ignore
|
28
|
+
if (result && result.error) {
|
29
|
+
// @ts-ignore
|
30
|
+
throw new Error(`api error: ${result.error}`);
|
31
|
+
}
|
32
|
+
// @ts-ignore
|
33
|
+
const realData = result.data.catalog.lookupPathSegments
|
34
|
+
.flatMap((item) => item.matches)
|
35
|
+
.map((match) => {
|
36
|
+
const { __typename, ...rest } = match;
|
37
|
+
return rest;
|
38
|
+
})
|
39
|
+
.map((match) => {
|
40
|
+
return match.id;
|
41
|
+
});
|
42
|
+
return realData;
|
43
|
+
};
|
44
|
+
|
45
|
+
const getContent = async (appId, postId) => {
|
46
|
+
const url = `https://catalog.purplemanager.com/graphql`;
|
47
|
+
const realBottom = {
|
48
|
+
...GraphQlQueryContent.bottom,
|
49
|
+
appInfo: {
|
50
|
+
...GraphQlQueryContent.bottom.appInfo,
|
51
|
+
appId,
|
52
|
+
},
|
53
|
+
filter: {
|
54
|
+
id: {
|
55
|
+
value: postId,
|
56
|
+
},
|
57
|
+
},
|
58
|
+
};
|
59
|
+
const response = await fetch(url, {
|
60
|
+
method: "POST",
|
61
|
+
headers: {
|
62
|
+
Accept: "application/json",
|
63
|
+
"Content-Type": "application/json",
|
64
|
+
},
|
65
|
+
body: JSON.stringify({
|
66
|
+
operationName: GraphQlQueryContent.queryName,
|
67
|
+
query: GraphQlQueryContent.top,
|
68
|
+
variables: realBottom,
|
69
|
+
}),
|
70
|
+
});
|
71
|
+
const result = await response.json();
|
72
|
+
// @ts-ignore
|
73
|
+
if (result && result.error) {
|
74
|
+
// @ts-ignore
|
75
|
+
throw new Error(`api error: ${result.error}`);
|
76
|
+
}
|
77
|
+
// @ts-ignore
|
78
|
+
const realData = result.data.catalog.contentsConnection.edges
|
79
|
+
.map((edge) => edge.content)
|
80
|
+
.map((match) => {
|
81
|
+
const { __typename, ...rest } = match;
|
82
|
+
return rest;
|
83
|
+
});
|
84
|
+
return realData;
|
85
|
+
};
|
86
|
+
|
87
|
+
export const handleApiArticle = (appId) => async (req, res, next) => {
|
88
|
+
const articleSlug = req.url.slice("/articles/".length);
|
89
|
+
console.log({ articleSlug });
|
90
|
+
const postIds = await getPostIds(appId, articleSlug);
|
91
|
+
if (postIds.length === 0) {
|
92
|
+
res.setHeader("content-type", "application/json");
|
93
|
+
res.end(JSON.stringify("Not found", null, 2));
|
94
|
+
return;
|
95
|
+
}
|
96
|
+
const postId = postIds[0];
|
97
|
+
const content = await getContent(appId, postId);
|
98
|
+
res.setHeader("content-type", "application/json");
|
99
|
+
res.end(JSON.stringify(content, null, 2));
|
100
|
+
};
|
@@ -1 +1 @@
|
|
1
|
-
export const version = '12.
|
1
|
+
export const version = '12.24.0'
|