@pronto-tools-and-more/pronto 12.24.0 → 12.25.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/App/App.js +4 -1
- package/src/parts/Config/Config.js +3 -0
- package/src/parts/CreateServer/CreateServer.js +2 -0
- package/src/parts/GraphQlQueryCollection/GraphQlQueryCollection.js +227 -0
- package/src/parts/GraphQlQueryCollections/GraphQlQueryCollections.js +227 -0
- package/src/parts/HandleApi/HandleApi.js +23 -9
- package/src/parts/HandleApiArticle/HandleApiArticle.js +18 -19
- package/src/parts/HandleApiAuthors/HandleApiAuthors.js +32 -31
- package/src/parts/HandleApiCategories/HandleApiCategories.js +32 -31
- package/src/parts/HandleApiCollection/HandleApiCollection.js +53 -0
- package/src/parts/HandleApiCollections/HandleApiCollections.js +49 -0
- package/src/parts/HandleApiDossier/HandleApiDossier.js +60 -59
- package/src/parts/HandleApiDossiers/HandleApiDossiers.js +32 -31
- package/src/parts/HandleApiIndex/HandleApiIndex.js +1 -0
- package/src/parts/HandleApiIssues/HandleApiIssues.js +32 -31
- 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.25.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.25.0",
|
21
|
+
"@pronto-tools-and-more/files": "12.25.0",
|
22
|
+
"@pronto-tools-and-more/network-process": "12.25.0",
|
23
|
+
"@pronto-tools-and-more/sass-compiler": "12.25.0",
|
24
|
+
"@pronto-tools-and-more/components-renderer": "12.25.0",
|
25
|
+
"@pronto-tools-and-more/components": "12.25.0",
|
26
|
+
"@pronto-tools-and-more/schema-process": "12.25.0",
|
27
|
+
"@pronto-tools-and-more/diff-process": "12.25.0",
|
28
|
+
"@pronto-tools-and-more/type-checker": "12.25.0",
|
29
|
+
"@pronto-tools-and-more/custom-js-functions": "12.25.0",
|
30
30
|
"execa": "^9.5.2",
|
31
31
|
"express": "^4.21.2"
|
32
32
|
},
|
package/src/parts/App/App.js
CHANGED
@@ -14,6 +14,7 @@ import * as ProxyPath from "../ProxyPath/ProxyPath.js";
|
|
14
14
|
export const create = ({
|
15
15
|
root,
|
16
16
|
appId,
|
17
|
+
releaseAppId,
|
17
18
|
baseUrl,
|
18
19
|
rootSassFile,
|
19
20
|
contentUrl,
|
@@ -29,6 +30,7 @@ export const create = ({
|
|
29
30
|
resourceDynamicUrlsInViewsJson,
|
30
31
|
injectCustomJs,
|
31
32
|
shimConfigLoader,
|
33
|
+
apiUrl,
|
32
34
|
}) => {
|
33
35
|
const app = express();
|
34
36
|
const storeFrontPath = join(root, "src", "default", "storefront");
|
@@ -90,7 +92,8 @@ export const create = ({
|
|
90
92
|
injectCustomJs,
|
91
93
|
})
|
92
94
|
);
|
93
|
-
app.use("/api", HandleApi.handleApi({ appId }));
|
95
|
+
app.use("/api", HandleApi.handleApi({ appId, apiUrl }));
|
96
|
+
app.use("/prod-api", HandleApi.handleApi({ appId: releaseAppId, apiUrl }));
|
94
97
|
app.use("*", HandleCss.handleCss(storeFrontPath, rootSassFile));
|
95
98
|
app.use(express.static(FilesPath.filesPath));
|
96
99
|
app.use(express.static(storeFrontPath));
|
@@ -117,3 +117,6 @@ export const resourceDynamicUrlsInViewsJson =
|
|
117
117
|
export const injectCustomJs = config.injectCustomJs || false;
|
118
118
|
|
119
119
|
export const shimConfigLoader = config.shimConfigLoader || false;
|
120
|
+
|
121
|
+
export const apiUrl =
|
122
|
+
process.env.API_URL || "https://catalog.purplemanager.com/graphql";
|
@@ -28,6 +28,8 @@ export const createServer = async (root, errorColor) => {
|
|
28
28
|
resourceDynamicUrlsInViewsJson: Config.resourceDynamicUrlsInViewsJson,
|
29
29
|
injectCustomJs: Config.injectCustomJs,
|
30
30
|
shimConfigLoader: Config.shimConfigLoader,
|
31
|
+
releaseAppId: Config.releaseAppId,
|
32
|
+
apiUrl: Config.apiUrl,
|
31
33
|
});
|
32
34
|
const server = http.createServer(app);
|
33
35
|
const webSocketServer = new ws.WebSocketServer({
|
@@ -0,0 +1,227 @@
|
|
1
|
+
export const top = `query CatalogCollections($appInfo: AppInfo!, $deviceInfo: DeviceInfo!, $authorization: Authorization!, $filter: CollectionFilter, $sort: [CollectionComparator!], $first: Int, $after: String, $includeElements: Boolean!, $elementsFirst: Int, $elementsAfter: 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
|
+
collectionsConnection(
|
8
|
+
filter: $filter
|
9
|
+
sort: $sort
|
10
|
+
first: $first
|
11
|
+
after: $after
|
12
|
+
) {
|
13
|
+
pageInfo {
|
14
|
+
hasNextPage
|
15
|
+
endCursor
|
16
|
+
}
|
17
|
+
edges {
|
18
|
+
node {
|
19
|
+
id
|
20
|
+
name
|
21
|
+
properties {
|
22
|
+
key
|
23
|
+
value
|
24
|
+
}
|
25
|
+
elementsConnection(first: $elementsFirst, after: $elementsAfter) @include(if: $includeElements) {
|
26
|
+
pageInfo {
|
27
|
+
hasNextPage
|
28
|
+
endCursor
|
29
|
+
}
|
30
|
+
edges {
|
31
|
+
node {
|
32
|
+
__typename
|
33
|
+
... on ContentElement {
|
34
|
+
id
|
35
|
+
sortIndex
|
36
|
+
content {
|
37
|
+
...ContentFragment
|
38
|
+
...IssueFragment
|
39
|
+
...PostFragment
|
40
|
+
...BundleFragment
|
41
|
+
}
|
42
|
+
}
|
43
|
+
}
|
44
|
+
}
|
45
|
+
}
|
46
|
+
}
|
47
|
+
}
|
48
|
+
}
|
49
|
+
}
|
50
|
+
}
|
51
|
+
|
52
|
+
fragment ContentFragment on Content {
|
53
|
+
__typename
|
54
|
+
id
|
55
|
+
version
|
56
|
+
name
|
57
|
+
description
|
58
|
+
index
|
59
|
+
alias
|
60
|
+
externalId
|
61
|
+
publicationDate
|
62
|
+
unpublishDate
|
63
|
+
lastModified
|
64
|
+
access
|
65
|
+
productId
|
66
|
+
purchaseData {
|
67
|
+
purchased
|
68
|
+
purchasedBy
|
69
|
+
}
|
70
|
+
publication {
|
71
|
+
id
|
72
|
+
}
|
73
|
+
properties(filter: $propertyFilter) {
|
74
|
+
key
|
75
|
+
value
|
76
|
+
}
|
77
|
+
seoMetadata @include(if: $includeContentSeoMetadata) {
|
78
|
+
key
|
79
|
+
value
|
80
|
+
}
|
81
|
+
thumbnails {
|
82
|
+
kind
|
83
|
+
url
|
84
|
+
properties {
|
85
|
+
key
|
86
|
+
value
|
87
|
+
}
|
88
|
+
}
|
89
|
+
categories
|
90
|
+
tags
|
91
|
+
}
|
92
|
+
|
93
|
+
fragment IssueFragment on Issue {
|
94
|
+
contentLength
|
95
|
+
numberOfPages
|
96
|
+
previewContentLength
|
97
|
+
resources @include(if: $includeResources) {
|
98
|
+
id
|
99
|
+
url
|
100
|
+
type
|
101
|
+
contentLength
|
102
|
+
properties {
|
103
|
+
key
|
104
|
+
value
|
105
|
+
type
|
106
|
+
}
|
107
|
+
}
|
108
|
+
}
|
109
|
+
|
110
|
+
fragment PostFragment on Post {
|
111
|
+
postType
|
112
|
+
bundleId
|
113
|
+
bundles {
|
114
|
+
id
|
115
|
+
bundleType
|
116
|
+
}
|
117
|
+
taxonomies {
|
118
|
+
...TaxonomySummaryFragment
|
119
|
+
}
|
120
|
+
authors {
|
121
|
+
name
|
122
|
+
email
|
123
|
+
}
|
124
|
+
bundleId
|
125
|
+
content @include(if: $includeBlocks) {
|
126
|
+
...ContentBlockFragment
|
127
|
+
}
|
128
|
+
previewContentBlocks @include(if: $includeBlocks) {
|
129
|
+
...ContentBlockFragment
|
130
|
+
}
|
131
|
+
contentHtml @include(if: $includeHtml)
|
132
|
+
previewContentHtml @include(if: $includeHtml)
|
133
|
+
resources @include(if: $includeResources) {
|
134
|
+
id
|
135
|
+
url
|
136
|
+
type
|
137
|
+
contentLength
|
138
|
+
properties {
|
139
|
+
key
|
140
|
+
value
|
141
|
+
type
|
142
|
+
}
|
143
|
+
}
|
144
|
+
}
|
145
|
+
|
146
|
+
fragment ContentBlockFragment on ContentBlock {
|
147
|
+
id
|
148
|
+
type
|
149
|
+
parentId
|
150
|
+
children
|
151
|
+
sequence
|
152
|
+
html
|
153
|
+
level
|
154
|
+
properties {
|
155
|
+
key
|
156
|
+
value
|
157
|
+
type
|
158
|
+
}
|
159
|
+
}
|
160
|
+
|
161
|
+
fragment BundleFragment on Bundle {
|
162
|
+
bundleType
|
163
|
+
taxonomies {
|
164
|
+
...TaxonomySummaryFragment
|
165
|
+
}
|
166
|
+
authors {
|
167
|
+
name
|
168
|
+
email
|
169
|
+
}
|
170
|
+
contents @include(if: $includeBundledContent) {
|
171
|
+
id
|
172
|
+
content {
|
173
|
+
...ContentFragment
|
174
|
+
...PostFragment
|
175
|
+
}
|
176
|
+
}
|
177
|
+
}
|
178
|
+
|
179
|
+
fragment TaxonomySummaryFragment on Taxonomy {
|
180
|
+
id
|
181
|
+
internalId
|
182
|
+
name
|
183
|
+
type
|
184
|
+
parentId
|
185
|
+
seoMetadata @include(if: $includeContentSeoMetadata) {
|
186
|
+
key
|
187
|
+
value
|
188
|
+
}
|
189
|
+
properties {
|
190
|
+
key
|
191
|
+
value
|
192
|
+
}
|
193
|
+
}`;
|
194
|
+
|
195
|
+
export const bottom = {
|
196
|
+
filter: {
|
197
|
+
name: {
|
198
|
+
value: "",
|
199
|
+
},
|
200
|
+
},
|
201
|
+
first: 24,
|
202
|
+
includeElements: true,
|
203
|
+
elementsFirst: 100,
|
204
|
+
includeBlocks: false,
|
205
|
+
includeHtml: false,
|
206
|
+
includeResources: false,
|
207
|
+
includeBundledContent: false,
|
208
|
+
includeContentSeoMetadata: false,
|
209
|
+
appInfo: {
|
210
|
+
appId: "",
|
211
|
+
appVersion: "1.0-SNAPSHOT",
|
212
|
+
preview: true,
|
213
|
+
},
|
214
|
+
deviceInfo: {
|
215
|
+
deviceId: "editor-preview",
|
216
|
+
deviceModel: "web",
|
217
|
+
locale: "de_DE",
|
218
|
+
smallestScreenWidthDp: 0,
|
219
|
+
deviceOs: "web",
|
220
|
+
platform: "WEB",
|
221
|
+
},
|
222
|
+
authorization: {
|
223
|
+
subscriptionCodes: [],
|
224
|
+
},
|
225
|
+
};
|
226
|
+
|
227
|
+
export const queryName = "CatalogCollections";
|
@@ -0,0 +1,227 @@
|
|
1
|
+
export const top = `query CatalogCollections($appInfo: AppInfo!, $deviceInfo: DeviceInfo!, $authorization: Authorization!, $filter: CollectionFilter, $sort: [CollectionComparator!], $first: Int, $after: String, $includeElements: Boolean!, $elementsFirst: Int, $elementsAfter: 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
|
+
collectionsConnection(
|
8
|
+
filter: $filter
|
9
|
+
sort: $sort
|
10
|
+
first: $first
|
11
|
+
after: $after
|
12
|
+
) {
|
13
|
+
pageInfo {
|
14
|
+
hasNextPage
|
15
|
+
endCursor
|
16
|
+
}
|
17
|
+
edges {
|
18
|
+
node {
|
19
|
+
id
|
20
|
+
name
|
21
|
+
properties {
|
22
|
+
key
|
23
|
+
value
|
24
|
+
}
|
25
|
+
elementsConnection(first: $elementsFirst, after: $elementsAfter) @include(if: $includeElements) {
|
26
|
+
pageInfo {
|
27
|
+
hasNextPage
|
28
|
+
endCursor
|
29
|
+
}
|
30
|
+
edges {
|
31
|
+
node {
|
32
|
+
__typename
|
33
|
+
... on ContentElement {
|
34
|
+
id
|
35
|
+
sortIndex
|
36
|
+
content {
|
37
|
+
...ContentFragment
|
38
|
+
...IssueFragment
|
39
|
+
...PostFragment
|
40
|
+
...BundleFragment
|
41
|
+
}
|
42
|
+
}
|
43
|
+
}
|
44
|
+
}
|
45
|
+
}
|
46
|
+
}
|
47
|
+
}
|
48
|
+
}
|
49
|
+
}
|
50
|
+
}
|
51
|
+
|
52
|
+
fragment ContentFragment on Content {
|
53
|
+
__typename
|
54
|
+
id
|
55
|
+
version
|
56
|
+
name
|
57
|
+
description
|
58
|
+
index
|
59
|
+
alias
|
60
|
+
externalId
|
61
|
+
publicationDate
|
62
|
+
unpublishDate
|
63
|
+
lastModified
|
64
|
+
access
|
65
|
+
productId
|
66
|
+
purchaseData {
|
67
|
+
purchased
|
68
|
+
purchasedBy
|
69
|
+
}
|
70
|
+
publication {
|
71
|
+
id
|
72
|
+
}
|
73
|
+
properties(filter: $propertyFilter) {
|
74
|
+
key
|
75
|
+
value
|
76
|
+
}
|
77
|
+
seoMetadata @include(if: $includeContentSeoMetadata) {
|
78
|
+
key
|
79
|
+
value
|
80
|
+
}
|
81
|
+
thumbnails {
|
82
|
+
kind
|
83
|
+
url
|
84
|
+
properties {
|
85
|
+
key
|
86
|
+
value
|
87
|
+
}
|
88
|
+
}
|
89
|
+
categories
|
90
|
+
tags
|
91
|
+
}
|
92
|
+
|
93
|
+
fragment IssueFragment on Issue {
|
94
|
+
contentLength
|
95
|
+
numberOfPages
|
96
|
+
previewContentLength
|
97
|
+
resources @include(if: $includeResources) {
|
98
|
+
id
|
99
|
+
url
|
100
|
+
type
|
101
|
+
contentLength
|
102
|
+
properties {
|
103
|
+
key
|
104
|
+
value
|
105
|
+
type
|
106
|
+
}
|
107
|
+
}
|
108
|
+
}
|
109
|
+
|
110
|
+
fragment PostFragment on Post {
|
111
|
+
postType
|
112
|
+
bundleId
|
113
|
+
bundles {
|
114
|
+
id
|
115
|
+
bundleType
|
116
|
+
}
|
117
|
+
taxonomies {
|
118
|
+
...TaxonomySummaryFragment
|
119
|
+
}
|
120
|
+
authors {
|
121
|
+
name
|
122
|
+
email
|
123
|
+
}
|
124
|
+
bundleId
|
125
|
+
content @include(if: $includeBlocks) {
|
126
|
+
...ContentBlockFragment
|
127
|
+
}
|
128
|
+
previewContentBlocks @include(if: $includeBlocks) {
|
129
|
+
...ContentBlockFragment
|
130
|
+
}
|
131
|
+
contentHtml @include(if: $includeHtml)
|
132
|
+
previewContentHtml @include(if: $includeHtml)
|
133
|
+
resources @include(if: $includeResources) {
|
134
|
+
id
|
135
|
+
url
|
136
|
+
type
|
137
|
+
contentLength
|
138
|
+
properties {
|
139
|
+
key
|
140
|
+
value
|
141
|
+
type
|
142
|
+
}
|
143
|
+
}
|
144
|
+
}
|
145
|
+
|
146
|
+
fragment ContentBlockFragment on ContentBlock {
|
147
|
+
id
|
148
|
+
type
|
149
|
+
parentId
|
150
|
+
children
|
151
|
+
sequence
|
152
|
+
html
|
153
|
+
level
|
154
|
+
properties {
|
155
|
+
key
|
156
|
+
value
|
157
|
+
type
|
158
|
+
}
|
159
|
+
}
|
160
|
+
|
161
|
+
fragment BundleFragment on Bundle {
|
162
|
+
bundleType
|
163
|
+
taxonomies {
|
164
|
+
...TaxonomySummaryFragment
|
165
|
+
}
|
166
|
+
authors {
|
167
|
+
name
|
168
|
+
email
|
169
|
+
}
|
170
|
+
contents @include(if: $includeBundledContent) {
|
171
|
+
id
|
172
|
+
content {
|
173
|
+
...ContentFragment
|
174
|
+
...PostFragment
|
175
|
+
}
|
176
|
+
}
|
177
|
+
}
|
178
|
+
|
179
|
+
fragment TaxonomySummaryFragment on Taxonomy {
|
180
|
+
id
|
181
|
+
internalId
|
182
|
+
name
|
183
|
+
type
|
184
|
+
parentId
|
185
|
+
seoMetadata @include(if: $includeContentSeoMetadata) {
|
186
|
+
key
|
187
|
+
value
|
188
|
+
}
|
189
|
+
properties {
|
190
|
+
key
|
191
|
+
value
|
192
|
+
}
|
193
|
+
}`;
|
194
|
+
|
195
|
+
export const bottom = {
|
196
|
+
filter: {
|
197
|
+
name: {
|
198
|
+
value: "",
|
199
|
+
},
|
200
|
+
},
|
201
|
+
first: 24,
|
202
|
+
includeElements: false,
|
203
|
+
elementsFirst: 100,
|
204
|
+
includeBlocks: false,
|
205
|
+
includeHtml: false,
|
206
|
+
includeResources: false,
|
207
|
+
includeBundledContent: false,
|
208
|
+
includeContentSeoMetadata: false,
|
209
|
+
appInfo: {
|
210
|
+
appId: "",
|
211
|
+
appVersion: "1.0-SNAPSHOT",
|
212
|
+
preview: true,
|
213
|
+
},
|
214
|
+
deviceInfo: {
|
215
|
+
deviceId: "editor-preview",
|
216
|
+
deviceModel: "web",
|
217
|
+
locale: "de_DE",
|
218
|
+
smallestScreenWidthDp: 0,
|
219
|
+
deviceOs: "web",
|
220
|
+
platform: "WEB",
|
221
|
+
},
|
222
|
+
authorization: {
|
223
|
+
subscriptionCodes: [],
|
224
|
+
},
|
225
|
+
};
|
226
|
+
|
227
|
+
export const queryName = "CatalogCollections";
|
@@ -1,34 +1,48 @@
|
|
1
|
+
import * as HandleApiArticle from "../HandleApiArticle/HandleApiArticle.js";
|
2
|
+
import * as HandleApiAuthors from "../HandleApiAuthors/HandleApiAuthors.js";
|
1
3
|
import * as HandleCategories from "../HandleApiCategories/HandleApiCategories.js";
|
4
|
+
import * as HandleApiCollection from "../HandleApiCollection/HandleApiCollection.js";
|
2
5
|
import * as HandleApiDossier from "../HandleApiDossier/HandleApiDossier.js";
|
3
6
|
import * as HandleDossiers from "../HandleApiDossiers/HandleApiDossiers.js";
|
4
7
|
import * as HandleApiIndex from "../HandleApiIndex/HandleApiIndex.js";
|
5
8
|
import * as HandleApiIssues from "../HandleApiIssues/HandleApiIssues.js";
|
6
|
-
import * as
|
7
|
-
import * as HandleApiArticle from "../HandleApiArticle/HandleApiArticle.js";
|
9
|
+
import * as HandleApiCollections from "../HandleApiCollections/HandleApiCollections.js";
|
8
10
|
|
9
11
|
export const handleApi =
|
10
|
-
({ appId }) =>
|
12
|
+
({ appId, apiUrl }) =>
|
11
13
|
(req, res) => {
|
12
14
|
if (req.url === "/") {
|
13
15
|
return HandleApiIndex.handleIndex(req, res);
|
14
16
|
}
|
15
17
|
if (req.url === "/categories") {
|
16
|
-
return HandleCategories.handleCategories(appId)(req, res);
|
18
|
+
return HandleCategories.handleCategories({ appId, apiUrl })(req, res);
|
17
19
|
}
|
18
20
|
if (req.url === "/dossiers") {
|
19
|
-
return HandleDossiers.handleDossiers(appId)(req, res);
|
21
|
+
return HandleDossiers.handleDossiers({ appId, apiUrl })(req, res);
|
20
22
|
}
|
21
23
|
if (req.url.startsWith("/dossiers")) {
|
22
|
-
return HandleApiDossier.handleDossier(appId)(req, res);
|
24
|
+
return HandleApiDossier.handleDossier({ appId, apiUrl })(req, res);
|
23
25
|
}
|
24
26
|
if (req.url === "/issues") {
|
25
|
-
return HandleApiIssues.handleIssues(appId)(req, res);
|
27
|
+
return HandleApiIssues.handleIssues({ appId, apiUrl })(req, res);
|
26
28
|
}
|
27
29
|
if (req.url === "/authors") {
|
28
|
-
return HandleApiAuthors.handleAuthors(appId)(req, res);
|
30
|
+
return HandleApiAuthors.handleAuthors({ appId, apiUrl })(req, res);
|
29
31
|
}
|
30
32
|
if (req.url.startsWith("/articles")) {
|
31
|
-
return HandleApiArticle.handleApiArticle(appId)(req, res);
|
33
|
+
return HandleApiArticle.handleApiArticle({ appId, apiUrl })(req, res);
|
34
|
+
}
|
35
|
+
if (req.url === "/collections" || req.url === "/collections/") {
|
36
|
+
return HandleApiCollections.handleApiCollections({ appId, apiUrl })(
|
37
|
+
req,
|
38
|
+
res
|
39
|
+
);
|
40
|
+
}
|
41
|
+
if (req.url.startsWith("/collections")) {
|
42
|
+
return HandleApiCollection.handleApiCollection({ appId, apiUrl })(
|
43
|
+
req,
|
44
|
+
res
|
45
|
+
);
|
32
46
|
}
|
33
47
|
res.statusCode = 404;
|
34
48
|
return res.end("not found");
|
@@ -1,8 +1,7 @@
|
|
1
1
|
import * as GraphQlQueryPathSegments from "../GraphQlQueryPathSegments/GraphQlQueryPathSegments.js";
|
2
2
|
import * as GraphQlQueryContent from "../GraphQlQueryContent/GraphQlQueryContent.js";
|
3
3
|
|
4
|
-
const getPostIds = async (appId, slug) => {
|
5
|
-
const url = `https://catalog.purplemanager.com/graphql`;
|
4
|
+
const getPostIds = async ({ appId, apiUrl, slug }) => {
|
6
5
|
const realBottom = {
|
7
6
|
...GraphQlQueryPathSegments.bottom,
|
8
7
|
appInfo: {
|
@@ -11,7 +10,7 @@ const getPostIds = async (appId, slug) => {
|
|
11
10
|
},
|
12
11
|
pathSegments: [slug],
|
13
12
|
};
|
14
|
-
const response = await fetch(
|
13
|
+
const response = await fetch(apiUrl, {
|
15
14
|
method: "POST",
|
16
15
|
headers: {
|
17
16
|
Accept: "application/json",
|
@@ -42,8 +41,7 @@ const getPostIds = async (appId, slug) => {
|
|
42
41
|
return realData;
|
43
42
|
};
|
44
43
|
|
45
|
-
const getContent = async (appId, postId) => {
|
46
|
-
const url = `https://catalog.purplemanager.com/graphql`;
|
44
|
+
const getContent = async ({ appId, apiUrl, postId }) => {
|
47
45
|
const realBottom = {
|
48
46
|
...GraphQlQueryContent.bottom,
|
49
47
|
appInfo: {
|
@@ -56,7 +54,7 @@ const getContent = async (appId, postId) => {
|
|
56
54
|
},
|
57
55
|
},
|
58
56
|
};
|
59
|
-
const response = await fetch(
|
57
|
+
const response = await fetch(apiUrl, {
|
60
58
|
method: "POST",
|
61
59
|
headers: {
|
62
60
|
Accept: "application/json",
|
@@ -84,17 +82,18 @@ const getContent = async (appId, postId) => {
|
|
84
82
|
return realData;
|
85
83
|
};
|
86
84
|
|
87
|
-
export const handleApiArticle =
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
85
|
+
export const handleApiArticle =
|
86
|
+
({ appId, apiUrl }) =>
|
87
|
+
async (req, res, next) => {
|
88
|
+
const articleSlug = req.url.slice("/articles/".length);
|
89
|
+
const postIds = await getPostIds({ appId, apiUrl, slug: articleSlug });
|
90
|
+
if (postIds.length === 0) {
|
91
|
+
res.setHeader("content-type", "application/json");
|
92
|
+
res.end(JSON.stringify("Not found", null, 2));
|
93
|
+
return;
|
94
|
+
}
|
95
|
+
const postId = postIds[0];
|
96
|
+
const content = await getContent({ appId, apiUrl, postId });
|
92
97
|
res.setHeader("content-type", "application/json");
|
93
|
-
res.end(JSON.stringify(
|
94
|
-
|
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
|
-
};
|
98
|
+
res.end(JSON.stringify(content, null, 2));
|
99
|
+
};
|
@@ -1,34 +1,35 @@
|
|
1
1
|
import * as GraphQlQueryAuthors from "../GraphQlQueryAuthors/GraphQlQueryAuthors.js";
|
2
2
|
|
3
|
-
export const handleAuthors =
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
const result = await response.json();
|
25
|
-
// @ts-ignore
|
26
|
-
const realData = result.data.catalog.taxonomiesConnection.edges
|
27
|
-
.map((edge) => edge.node)
|
28
|
-
.map((node) => {
|
29
|
-
const { __typename, ...rest } = node;
|
30
|
-
return rest;
|
3
|
+
export const handleAuthors =
|
4
|
+
({ appId, apiUrl }) =>
|
5
|
+
async (req, res, next) => {
|
6
|
+
const realBottom = {
|
7
|
+
...GraphQlQueryAuthors.bottom,
|
8
|
+
appInfo: {
|
9
|
+
...GraphQlQueryAuthors.bottom.appInfo,
|
10
|
+
appId,
|
11
|
+
},
|
12
|
+
};
|
13
|
+
const response = await fetch(apiUrl, {
|
14
|
+
method: "POST",
|
15
|
+
headers: {
|
16
|
+
Accept: "application/json",
|
17
|
+
"Content-Type": "application/json",
|
18
|
+
},
|
19
|
+
body: JSON.stringify({
|
20
|
+
operationName: "CatalogContentsQuery",
|
21
|
+
query: GraphQlQueryAuthors.top,
|
22
|
+
variables: realBottom,
|
23
|
+
}),
|
31
24
|
});
|
32
|
-
|
33
|
-
|
34
|
-
|
25
|
+
const result = await response.json();
|
26
|
+
// @ts-ignore
|
27
|
+
const realData = result.data.catalog.taxonomiesConnection.edges
|
28
|
+
.map((edge) => edge.node)
|
29
|
+
.map((node) => {
|
30
|
+
const { __typename, ...rest } = node;
|
31
|
+
return rest;
|
32
|
+
});
|
33
|
+
res.setHeader("content-type", "application/json");
|
34
|
+
res.end(JSON.stringify(realData, null, 2));
|
35
|
+
};
|
@@ -1,34 +1,35 @@
|
|
1
1
|
import * as GraphQlQueryCategories from "../GraphQlQueryCategories/GraphQlQueryCategories.js";
|
2
2
|
|
3
|
-
export const handleCategories =
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
const result = await response.json();
|
25
|
-
// @ts-ignore
|
26
|
-
const realData = result.data.catalog.taxonomiesConnection.edges
|
27
|
-
.map((edge) => edge.node)
|
28
|
-
.map((node) => {
|
29
|
-
const { __typename, ...rest } = node;
|
30
|
-
return rest;
|
3
|
+
export const handleCategories =
|
4
|
+
({ appId, apiUrl }) =>
|
5
|
+
async (req, res, next) => {
|
6
|
+
const realBottom = {
|
7
|
+
...GraphQlQueryCategories.bottom,
|
8
|
+
appInfo: {
|
9
|
+
...GraphQlQueryCategories.bottom.appInfo,
|
10
|
+
appId,
|
11
|
+
},
|
12
|
+
};
|
13
|
+
const response = await fetch(apiUrl, {
|
14
|
+
method: "POST",
|
15
|
+
headers: {
|
16
|
+
Accept: "application/json",
|
17
|
+
"Content-Type": "application/json",
|
18
|
+
},
|
19
|
+
body: JSON.stringify({
|
20
|
+
operationName: "CatalogContentsQuery",
|
21
|
+
query: GraphQlQueryCategories.top,
|
22
|
+
variables: realBottom,
|
23
|
+
}),
|
31
24
|
});
|
32
|
-
|
33
|
-
|
34
|
-
|
25
|
+
const result = await response.json();
|
26
|
+
// @ts-ignore
|
27
|
+
const realData = result.data.catalog.taxonomiesConnection.edges
|
28
|
+
.map((edge) => edge.node)
|
29
|
+
.map((node) => {
|
30
|
+
const { __typename, ...rest } = node;
|
31
|
+
return rest;
|
32
|
+
});
|
33
|
+
res.setHeader("content-type", "application/json");
|
34
|
+
res.end(JSON.stringify(realData, null, 2));
|
35
|
+
};
|
@@ -0,0 +1,53 @@
|
|
1
|
+
import * as GraphQlQueryCollection from "../GraphQlQueryCollection/GraphQlQueryCollection.js";
|
2
|
+
|
3
|
+
const getCollections = async ({ appId, apiUrl, name }) => {
|
4
|
+
const realBottom = {
|
5
|
+
...GraphQlQueryCollection.bottom,
|
6
|
+
appInfo: {
|
7
|
+
...GraphQlQueryCollection.bottom.appInfo,
|
8
|
+
appId,
|
9
|
+
},
|
10
|
+
filter: {
|
11
|
+
name: {
|
12
|
+
value: name,
|
13
|
+
},
|
14
|
+
},
|
15
|
+
};
|
16
|
+
const response = await fetch(apiUrl, {
|
17
|
+
method: "POST",
|
18
|
+
headers: {
|
19
|
+
Accept: "application/json",
|
20
|
+
"Content-Type": "application/json",
|
21
|
+
},
|
22
|
+
body: JSON.stringify({
|
23
|
+
operationName: GraphQlQueryCollection.queryName,
|
24
|
+
query: GraphQlQueryCollection.top,
|
25
|
+
variables: realBottom,
|
26
|
+
}),
|
27
|
+
});
|
28
|
+
const result = await response.json();
|
29
|
+
// @ts-ignore
|
30
|
+
if (result && result.error) {
|
31
|
+
// @ts-ignore
|
32
|
+
throw new Error(`api error: ${result.error}`);
|
33
|
+
}
|
34
|
+
// @ts-ignore
|
35
|
+
const realData = result.data.catalog.collectionsConnection.edges
|
36
|
+
.map((edge) => {
|
37
|
+
return edge.node;
|
38
|
+
})
|
39
|
+
.map((match) => {
|
40
|
+
const { __typename, ...rest } = match;
|
41
|
+
return rest;
|
42
|
+
});
|
43
|
+
return realData;
|
44
|
+
};
|
45
|
+
|
46
|
+
export const handleApiCollection =
|
47
|
+
({ appId, apiUrl }) =>
|
48
|
+
async (req, res, next) => {
|
49
|
+
const name = req.url.slice("/collections/".length);
|
50
|
+
const content = await getCollections({ appId, apiUrl, name });
|
51
|
+
res.setHeader("content-type", "application/json");
|
52
|
+
res.end(JSON.stringify(content, null, 2));
|
53
|
+
};
|
@@ -0,0 +1,49 @@
|
|
1
|
+
import * as GraphQlQueryCollections from "../GraphQlQueryCollections/GraphQlQueryCollections.js";
|
2
|
+
|
3
|
+
const getCollections = async ({ appId, apiUrl }) => {
|
4
|
+
const realBottom = {
|
5
|
+
...GraphQlQueryCollections.bottom,
|
6
|
+
appInfo: {
|
7
|
+
...GraphQlQueryCollections.bottom.appInfo,
|
8
|
+
appId,
|
9
|
+
},
|
10
|
+
filter: {},
|
11
|
+
};
|
12
|
+
const response = await fetch(apiUrl, {
|
13
|
+
method: "POST",
|
14
|
+
headers: {
|
15
|
+
Accept: "application/json",
|
16
|
+
"Content-Type": "application/json",
|
17
|
+
},
|
18
|
+
body: JSON.stringify({
|
19
|
+
operationName: GraphQlQueryCollections.queryName,
|
20
|
+
query: GraphQlQueryCollections.top,
|
21
|
+
variables: realBottom,
|
22
|
+
}),
|
23
|
+
});
|
24
|
+
const result = await response.json();
|
25
|
+
// @ts-ignore
|
26
|
+
if (result && result.error) {
|
27
|
+
// @ts-ignore
|
28
|
+
throw new Error(`api error: ${result.error}`);
|
29
|
+
}
|
30
|
+
// @ts-ignore
|
31
|
+
const realData = result.data.catalog.collectionsConnection.edges
|
32
|
+
.map((edge) => {
|
33
|
+
return edge.node;
|
34
|
+
})
|
35
|
+
.map((match) => {
|
36
|
+
const { __typename, ...rest } = match;
|
37
|
+
return rest;
|
38
|
+
});
|
39
|
+
return realData;
|
40
|
+
};
|
41
|
+
|
42
|
+
export const handleApiCollections =
|
43
|
+
({ appId, apiUrl }) =>
|
44
|
+
async (req, res, next) => {
|
45
|
+
const content = await getCollections({ appId, apiUrl });
|
46
|
+
console.log({ content });
|
47
|
+
res.setHeader("content-type", "application/json");
|
48
|
+
res.end(JSON.stringify(content, null, 2));
|
49
|
+
};
|
@@ -36,68 +36,69 @@ const getBundleId = async ({ appId, reqUrl }) => {
|
|
36
36
|
return id;
|
37
37
|
};
|
38
38
|
|
39
|
-
export const handleDossier =
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
});
|
44
|
-
if (!bundleId) {
|
45
|
-
res.statusCode = 404;
|
46
|
-
res.end("Not found");
|
47
|
-
return;
|
48
|
-
}
|
49
|
-
const url = `https://catalog.purplemanager.com/graphql`;
|
50
|
-
const realBottom = {
|
51
|
-
...GraphQlQueryDossier.bottom1,
|
52
|
-
appInfo: {
|
53
|
-
...GraphQlQueryDossier.bottom1.appInfo,
|
39
|
+
export const handleDossier =
|
40
|
+
({ appId, apiUrl }) =>
|
41
|
+
async (req, res, next) => {
|
42
|
+
const bundleId = await getBundleId({
|
54
43
|
appId,
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
44
|
+
reqUrl: req.url,
|
45
|
+
});
|
46
|
+
if (!bundleId) {
|
47
|
+
res.statusCode = 404;
|
48
|
+
res.end("Not found");
|
49
|
+
return;
|
50
|
+
}
|
51
|
+
const realBottom = {
|
52
|
+
...GraphQlQueryDossier.bottom1,
|
53
|
+
appInfo: {
|
54
|
+
...GraphQlQueryDossier.bottom1.appInfo,
|
55
|
+
appId,
|
56
|
+
},
|
57
|
+
filter: {
|
58
|
+
AND: [
|
59
|
+
{
|
60
|
+
postType: {
|
61
|
+
value: "post",
|
62
|
+
},
|
61
63
|
},
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
64
|
+
{
|
65
|
+
contentType: {
|
66
|
+
value: "POST",
|
67
|
+
},
|
66
68
|
},
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
69
|
+
{
|
70
|
+
AND: [
|
71
|
+
{
|
72
|
+
bundleId: {
|
73
|
+
value: bundleId,
|
74
|
+
},
|
73
75
|
},
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
}
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
}),
|
91
|
-
});
|
92
|
-
const result = await response.json();
|
93
|
-
// @ts-ignore
|
94
|
-
const realData = result.data.catalog.contentsConnection.edges
|
95
|
-
.map((edge) => edge.content)
|
96
|
-
.map((node) => {
|
97
|
-
const { __typename, ...rest } = node;
|
98
|
-
return rest;
|
76
|
+
],
|
77
|
+
},
|
78
|
+
],
|
79
|
+
},
|
80
|
+
};
|
81
|
+
const response = await fetch(apiUrl, {
|
82
|
+
method: "POST",
|
83
|
+
headers: {
|
84
|
+
Accept: "application/json",
|
85
|
+
"Content-Type": "application/json",
|
86
|
+
},
|
87
|
+
body: JSON.stringify({
|
88
|
+
operationName: "CatalogContentsQuery",
|
89
|
+
query: GraphQlQueryDossier.top1,
|
90
|
+
variables: realBottom,
|
91
|
+
}),
|
99
92
|
});
|
93
|
+
const result = await response.json();
|
94
|
+
// @ts-ignore
|
95
|
+
const realData = result.data.catalog.contentsConnection.edges
|
96
|
+
.map((edge) => edge.content)
|
97
|
+
.map((node) => {
|
98
|
+
const { __typename, ...rest } = node;
|
99
|
+
return rest;
|
100
|
+
});
|
100
101
|
|
101
|
-
|
102
|
-
|
103
|
-
};
|
102
|
+
res.setHeader("content-type", "application/json");
|
103
|
+
res.send(JSON.stringify(realData, null, 2));
|
104
|
+
};
|
@@ -1,35 +1,36 @@
|
|
1
1
|
import * as GraphQlQueryDossiers from "../GraphQlQueryDossiers/GraphQlQueryDossiers.js";
|
2
2
|
|
3
|
-
export const handleDossiers =
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
const result = await response.json();
|
25
|
-
// @ts-ignore
|
26
|
-
const realData = result.data.catalog.contentsConnection.edges
|
27
|
-
.map((edge) => edge.content)
|
28
|
-
.map((node) => {
|
29
|
-
const { __typename, ...rest } = node;
|
30
|
-
return rest;
|
3
|
+
export const handleDossiers =
|
4
|
+
({ appId, apiUrl }) =>
|
5
|
+
async (req, res, next) => {
|
6
|
+
const realBottom = {
|
7
|
+
...GraphQlQueryDossiers.bottom,
|
8
|
+
appInfo: {
|
9
|
+
...GraphQlQueryDossiers.bottom.appInfo,
|
10
|
+
appId,
|
11
|
+
},
|
12
|
+
};
|
13
|
+
const response = await fetch(apiUrl, {
|
14
|
+
method: "POST",
|
15
|
+
headers: {
|
16
|
+
Accept: "application/json",
|
17
|
+
"Content-Type": "application/json",
|
18
|
+
},
|
19
|
+
body: JSON.stringify({
|
20
|
+
operationName: "CatalogContentsQuery",
|
21
|
+
query: GraphQlQueryDossiers.top,
|
22
|
+
variables: realBottom,
|
23
|
+
}),
|
31
24
|
});
|
25
|
+
const result = await response.json();
|
26
|
+
// @ts-ignore
|
27
|
+
const realData = result.data.catalog.contentsConnection.edges
|
28
|
+
.map((edge) => edge.content)
|
29
|
+
.map((node) => {
|
30
|
+
const { __typename, ...rest } = node;
|
31
|
+
return rest;
|
32
|
+
});
|
32
33
|
|
33
|
-
|
34
|
-
|
35
|
-
};
|
34
|
+
res.setHeader("content-type", "application/json");
|
35
|
+
res.send(JSON.stringify(realData, null, 2));
|
36
|
+
};
|
@@ -13,6 +13,7 @@ export const handleIndex = async (req, res, next) => {
|
|
13
13
|
<li><a href="/api/categories">Categories</a></li>
|
14
14
|
<li><a href="/api/articles">Articles</a></li>
|
15
15
|
<li><a href="/api/authors">Authors</a></li>
|
16
|
+
<li><a href="/api/collections">Collections</a></li>
|
16
17
|
</ul>
|
17
18
|
</body>
|
18
19
|
</html>
|
@@ -1,34 +1,35 @@
|
|
1
1
|
import * as GraphQlQueryIssues from "../GraphQlQueryIssues/GraphQlQueryIssues.js";
|
2
2
|
|
3
|
-
export const handleIssues =
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
const result = await response.json();
|
25
|
-
// @ts-ignore
|
26
|
-
const realData = result.data.catalog.contentsConnection.edges
|
27
|
-
.map((edge) => edge.content)
|
28
|
-
.map((node) => {
|
29
|
-
const { __typename, ...rest } = node;
|
30
|
-
return rest;
|
3
|
+
export const handleIssues =
|
4
|
+
({ appId, apiUrl }) =>
|
5
|
+
async (req, res, next) => {
|
6
|
+
const realBottom = {
|
7
|
+
...GraphQlQueryIssues.bottom,
|
8
|
+
appInfo: {
|
9
|
+
...GraphQlQueryIssues.bottom.appInfo,
|
10
|
+
appId,
|
11
|
+
},
|
12
|
+
};
|
13
|
+
const response = await fetch(apiUrl, {
|
14
|
+
method: "POST",
|
15
|
+
headers: {
|
16
|
+
Accept: "application/json",
|
17
|
+
"Content-Type": "application/json",
|
18
|
+
},
|
19
|
+
body: JSON.stringify({
|
20
|
+
operationName: "CatalogContentsQuery",
|
21
|
+
query: GraphQlQueryIssues.top,
|
22
|
+
variables: realBottom,
|
23
|
+
}),
|
31
24
|
});
|
32
|
-
|
33
|
-
|
34
|
-
|
25
|
+
const result = await response.json();
|
26
|
+
// @ts-ignore
|
27
|
+
const realData = result.data.catalog.contentsConnection.edges
|
28
|
+
.map((edge) => edge.content)
|
29
|
+
.map((node) => {
|
30
|
+
const { __typename, ...rest } = node;
|
31
|
+
return rest;
|
32
|
+
});
|
33
|
+
res.setHeader("content-type", "application/json");
|
34
|
+
res.send(JSON.stringify(realData, null, 2));
|
35
|
+
};
|
@@ -1 +1 @@
|
|
1
|
-
export const version = '12.
|
1
|
+
export const version = '12.25.0'
|