@pronto-tools-and-more/pronto 12.6.0 → 12.8.0

Sign up to get free protection for your applications and to get access to all the features.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pronto-tools-and-more/pronto",
3
- "version": "12.6.0",
3
+ "version": "12.8.0",
4
4
  "description": "",
5
5
  "main": "src/main.js",
6
6
  "type": "module",
@@ -17,16 +17,16 @@
17
17
  "@lvce-editor/ipc": "^12.0.0",
18
18
  "@lvce-editor/json-rpc": "^5.3.0",
19
19
  "@lvce-editor/verror": "^1.6.0",
20
- "@pronto-tools-and-more/file-watcher": "12.6.0",
21
- "@pronto-tools-and-more/files": "12.6.0",
22
- "@pronto-tools-and-more/network-process": "12.6.0",
23
- "@pronto-tools-and-more/sass-compiler": "12.6.0",
24
- "@pronto-tools-and-more/components-renderer": "12.6.0",
25
- "@pronto-tools-and-more/components": "12.6.0",
26
- "@pronto-tools-and-more/schema-process": "12.6.0",
27
- "@pronto-tools-and-more/diff-process": "12.6.0",
28
- "@pronto-tools-and-more/type-checker": "12.6.0",
29
- "@pronto-tools-and-more/custom-js-functions": "12.6.0",
20
+ "@pronto-tools-and-more/file-watcher": "12.8.0",
21
+ "@pronto-tools-and-more/files": "12.8.0",
22
+ "@pronto-tools-and-more/network-process": "12.8.0",
23
+ "@pronto-tools-and-more/sass-compiler": "12.8.0",
24
+ "@pronto-tools-and-more/components-renderer": "12.8.0",
25
+ "@pronto-tools-and-more/components": "12.8.0",
26
+ "@pronto-tools-and-more/schema-process": "12.8.0",
27
+ "@pronto-tools-and-more/diff-process": "12.8.0",
28
+ "@pronto-tools-and-more/type-checker": "12.8.0",
29
+ "@pronto-tools-and-more/custom-js-functions": "12.8.0",
30
30
  "execa": "^9.5.2",
31
31
  "express": "^4.21.2"
32
32
  },
@@ -1,6 +1,7 @@
1
1
  import express from "express";
2
2
  import { join } from "node:path";
3
3
  import * as FilesPath from "../FilesPath/FilesPath.js";
4
+ import * as HandleApi from "../HandleApi/HandleApi.js";
4
5
  import * as HandleConfigLoader from "../HandleConfigLoader/HandleConfigLoader.js";
5
6
  import * as HandleCss from "../HandleCss/HandleCss.js";
6
7
  import * as HandleCustomServer from "../HandleCustomServer/HandleCustomServer.js";
@@ -9,8 +10,6 @@ import * as HandleIndex from "../HandleIndex/HandleIndex.js";
9
10
  import * as HandleMainJs from "../HandleMainJs/HandleMainJs.js";
10
11
  import * as HandleViews from "../HandleViews/HandleViews.js";
11
12
  import * as ProxyPath from "../ProxyPath/ProxyPath.js";
12
- import * as HandleTaxonomies from "../HandleTaxonomies/HandleTaxonomies.js";
13
- import * as HandleCategories from "../HandleCategories/HandleCategories.js";
14
13
 
15
14
  export const create = ({
16
15
  root,
@@ -91,7 +90,7 @@ export const create = ({
91
90
  injectCustomJs,
92
91
  })
93
92
  );
94
- app.get("/api/categories", HandleCategories.handleCategories(appId));
93
+ app.use("/api", HandleApi.handleApi({ appId }));
95
94
  app.use("*", HandleCss.handleCss(storeFrontPath, rootSassFile));
96
95
  app.use(express.static(FilesPath.filesPath));
97
96
  app.use(express.static(storeFrontPath));
@@ -0,0 +1,221 @@
1
+ export const top1 = `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 bottom1 = {
169
+ filter: {
170
+ AND: [
171
+ {
172
+ postType: {
173
+ value: "post",
174
+ },
175
+ },
176
+ {
177
+ contentType: {
178
+ value: "POST",
179
+ },
180
+ },
181
+ {
182
+ AND: [
183
+ {
184
+ bundleId: {
185
+ value: "id",
186
+ },
187
+ },
188
+ ],
189
+ },
190
+ ],
191
+ },
192
+ sort: [
193
+ {
194
+ publicationDate: {
195
+ direction: "DESC",
196
+ },
197
+ },
198
+ ],
199
+ first: 1,
200
+ includeBlocks: false,
201
+ includeHtml: false,
202
+ includeResources: false,
203
+ includeBundledContent: false,
204
+ includeContentSeoMetadata: false,
205
+ appInfo: {
206
+ appId: "",
207
+ appVersion: "1.0-SNAPSHOT",
208
+ preview: true,
209
+ },
210
+ deviceInfo: {
211
+ deviceId: "editor-preview",
212
+ deviceModel: "web",
213
+ locale: "de_DE",
214
+ smallestScreenWidthDp: 0,
215
+ deviceOs: "web",
216
+ platform: "WEB",
217
+ },
218
+ authorization: {
219
+ subscriptionCodes: [],
220
+ },
221
+ };
@@ -0,0 +1,201 @@
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
+ AND: [
171
+ {
172
+ bundleType: {
173
+ value: "DOSSIER",
174
+ },
175
+ },
176
+ ],
177
+ },
178
+ sort: [],
179
+ first: 12,
180
+ includeBlocks: false,
181
+ includeHtml: false,
182
+ includeResources: false,
183
+ includeBundledContent: false,
184
+ includeContentSeoMetadata: false,
185
+ appInfo: {
186
+ appId: "",
187
+ appVersion: "1.0-SNAPSHOT",
188
+ preview: true,
189
+ },
190
+ deviceInfo: {
191
+ deviceId: "editor-preview",
192
+ deviceModel: "web",
193
+ locale: "de_DE",
194
+ smallestScreenWidthDp: 0,
195
+ deviceOs: "web",
196
+ platform: "WEB",
197
+ },
198
+ authorization: {
199
+ subscriptionCodes: [],
200
+ },
201
+ };
@@ -0,0 +1,57 @@
1
+ export const top1 = `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 bottom1 = {
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
+ };
@@ -0,0 +1,19 @@
1
+ import * as HandleCategories from "../HandleApiCategories/HandleApiCategories.js";
2
+ import * as HandleDossiers from "../HandleApiDossiers/HandleApiDossiers.js";
3
+ import * as HandleApiDossier from "../HandleApiDossier/HandleApiDossier.js";
4
+
5
+ export const handleApi =
6
+ ({ appId }) =>
7
+ (req, res) => {
8
+ if (req.url === "/categories") {
9
+ return HandleCategories.handleCategories(appId)(req, res);
10
+ }
11
+ if (req.url === "/dossiers") {
12
+ return HandleDossiers.handleDossiers(appId)(req, res);
13
+ }
14
+ if (req.url.startsWith("/dossiers")) {
15
+ return HandleApiDossier.handleDossier(appId)(req, res);
16
+ }
17
+ res.statusCode = 404;
18
+ return res.end("not found");
19
+ };
@@ -29,5 +29,6 @@ export const handleCategories = (appId) => async (req, res, next) => {
29
29
  const { __typename, ...rest } = node;
30
30
  return rest;
31
31
  });
32
+ res.setHeader("content-type", "application/json");
32
33
  res.end(JSON.stringify(realData, null, 2));
33
34
  };
@@ -0,0 +1,103 @@
1
+ import * as GraphQlQueryPathSegment from "../GraphQlQueryPathSegment/GraphQlQueryPathSegment.js";
2
+ import * as GraphQlQueryDossier from "../GraphQlQueryDossier/GraphQlQueryDossier.js";
3
+
4
+ const getBundleId = async ({ appId, reqUrl }) => {
5
+ const url = `https://catalog.purplemanager.com/graphql`;
6
+ const part = reqUrl.slice("/dossiers".length + 1);
7
+ const realBottom = {
8
+ ...GraphQlQueryPathSegment.bottom1,
9
+ appInfo: {
10
+ ...GraphQlQueryPathSegment.bottom1.appInfo,
11
+ appId,
12
+ },
13
+ pathSegments: [part],
14
+ };
15
+ const response = await fetch(url, {
16
+ method: "POST",
17
+ headers: {
18
+ Accept: "application/json",
19
+ "Content-Type": "application/json",
20
+ },
21
+ body: JSON.stringify({
22
+ operationName: "LookupPathSegmentsQuery",
23
+ query: GraphQlQueryPathSegment.top1,
24
+ variables: realBottom,
25
+ }),
26
+ });
27
+ const result = await response.json();
28
+ // @ts-ignore
29
+ const items = result.data.catalog.lookupPathSegments.flatMap(
30
+ (item) => item.matches
31
+ );
32
+ if (items.length === 0) {
33
+ return "";
34
+ }
35
+ const id = items[0].id;
36
+ return id;
37
+ };
38
+
39
+ export const handleDossier = (appId) => async (req, res, next) => {
40
+ const bundleId = await getBundleId({
41
+ appId,
42
+ reqUrl: req.url,
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,
54
+ appId,
55
+ },
56
+ filter: {
57
+ AND: [
58
+ {
59
+ postType: {
60
+ value: "post",
61
+ },
62
+ },
63
+ {
64
+ contentType: {
65
+ value: "POST",
66
+ },
67
+ },
68
+ {
69
+ AND: [
70
+ {
71
+ bundleId: {
72
+ value: bundleId,
73
+ },
74
+ },
75
+ ],
76
+ },
77
+ ],
78
+ },
79
+ };
80
+ const response = await fetch(url, {
81
+ method: "POST",
82
+ headers: {
83
+ Accept: "application/json",
84
+ "Content-Type": "application/json",
85
+ },
86
+ body: JSON.stringify({
87
+ operationName: "CatalogContentsQuery",
88
+ query: GraphQlQueryDossier.top1,
89
+ variables: realBottom,
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;
99
+ });
100
+
101
+ res.setHeader("content-type", "application/json");
102
+ res.send(JSON.stringify(realData, null, 2));
103
+ };
@@ -0,0 +1,35 @@
1
+ import * as GraphQlQueryDossiers from "../GraphQlQueryDossiers/GraphQlQueryDossiers.js";
2
+
3
+ export const handleDossiers = (appId) => async (req, res, next) => {
4
+ const url = `https://catalog.purplemanager.com/graphql`;
5
+ const realBottom = {
6
+ ...GraphQlQueryDossiers.bottom,
7
+ appInfo: {
8
+ ...GraphQlQueryDossiers.bottom.appInfo,
9
+ appId,
10
+ },
11
+ };
12
+ const response = await fetch(url, {
13
+ method: "POST",
14
+ headers: {
15
+ Accept: "application/json",
16
+ "Content-Type": "application/json",
17
+ },
18
+ body: JSON.stringify({
19
+ operationName: "CatalogContentsQuery",
20
+ query: GraphQlQueryDossiers.top,
21
+ variables: realBottom,
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;
31
+ });
32
+
33
+ res.setHeader("content-type", "application/json");
34
+ res.send(JSON.stringify(realData, null, 2));
35
+ };
@@ -1 +1 @@
1
- export const version = '12.6.0'
1
+ export const version = '12.8.0'