@pronto-tools-and-more/pronto 12.34.0 → 12.35.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (32) hide show
  1. package/package.json +12 -11
  2. package/src/parts/ApiProcess/ApiProcess.js +32 -0
  3. package/src/parts/ApiProcessPath/ApiProcessPath.js +7 -0
  4. package/src/parts/HandleApi/HandleApi.js +30 -48
  5. package/src/parts/LaunchApiProcess/LaunchApiProcess.js +15 -0
  6. package/src/parts/Version/Version.js +1 -1
  7. package/src/parts/GetPostIds/GetPostIds.js +0 -41
  8. package/src/parts/GraphQlQueryAuthors/GraphQlQueryAuthors.js +0 -66
  9. package/src/parts/GraphQlQueryCategories/GraphQlQueryCategories.js +0 -66
  10. package/src/parts/GraphQlQueryCollection/GraphQlQueryCollection.js +0 -227
  11. package/src/parts/GraphQlQueryCollections/GraphQlQueryCollections.js +0 -227
  12. package/src/parts/GraphQlQueryContent/GraphQlQueryContent.js +0 -198
  13. package/src/parts/GraphQlQueryDossier/GraphQlQueryDossier.js +0 -221
  14. package/src/parts/GraphQlQueryDossiers/GraphQlQueryDossiers.js +0 -201
  15. package/src/parts/GraphQlQueryIssues/GraphQlQueryIssues.js +0 -202
  16. package/src/parts/GraphQlQueryMenus/GraphQlQueryMenus.js +0 -77
  17. package/src/parts/GraphQlQueryPathSegment/GraphQlQueryPathSegment.js +0 -57
  18. package/src/parts/GraphQlQueryPathSegments/GraphQlQueryPathSegments.js +0 -59
  19. package/src/parts/GraphQlQueryTaxonomies/GraphQlQueryTaxonomies.js +0 -66
  20. package/src/parts/HandleApiArticle/HandleApiArticle.js +0 -30
  21. package/src/parts/HandleApiArticleByCategoryId/HandleApiArticleByCategoryId.js +0 -93
  22. package/src/parts/HandleApiAuthors/HandleApiAuthors.js +0 -35
  23. package/src/parts/HandleApiCategories/HandleApiCategories.js +0 -35
  24. package/src/parts/HandleApiCollection/HandleApiCollection.js +0 -59
  25. package/src/parts/HandleApiCollections/HandleApiCollections.js +0 -49
  26. package/src/parts/HandleApiDossier/HandleApiDossier.js +0 -104
  27. package/src/parts/HandleApiDossiers/HandleApiDossiers.js +0 -36
  28. package/src/parts/HandleApiIndex/HandleApiIndex.js +0 -24
  29. package/src/parts/HandleApiIssues/HandleApiIssues.js +0 -35
  30. package/src/parts/HandleApiMenus/HandleApiMenus.js +0 -36
  31. package/src/parts/HandleApiPostByName/HandleApiPostByName.js +0 -54
  32. package/src/parts/HandleTaxonomies/HandleTaxonomies.js +0 -33
@@ -1,93 +0,0 @@
1
- import * as GraphQlQueryContent from "../GraphQlQueryContent/GraphQlQueryContent.js";
2
-
3
- const getContent = async ({ appId, apiUrl, categoryId }) => {
4
- const realBottom = {
5
- ...GraphQlQueryContent.bottom,
6
- appInfo: {
7
- ...GraphQlQueryContent.bottom.appInfo,
8
- appId,
9
- },
10
- filter: {
11
- AND: [
12
- {
13
- contentType: {
14
- value: "POST",
15
- },
16
- },
17
- {
18
- postType: {
19
- value: "post",
20
- },
21
- },
22
- {
23
- taxonomies: {
24
- content: {
25
- value: {
26
- AND: [
27
- {
28
- type: {
29
- value: "category",
30
- },
31
- },
32
- {
33
- OR: [
34
- {
35
- id: {
36
- value: categoryId,
37
- },
38
- },
39
- ],
40
- },
41
- ],
42
- },
43
- },
44
- },
45
- },
46
- {
47
- id: {
48
- value: "^()$",
49
- operation: "REGEX",
50
- negated: true,
51
- },
52
- },
53
- ],
54
- },
55
- };
56
- const response = await fetch(apiUrl, {
57
- method: "POST",
58
- headers: {
59
- Accept: "application/json",
60
- "Content-Type": "application/json",
61
- },
62
- body: JSON.stringify({
63
- operationName: GraphQlQueryContent.queryName,
64
- query: GraphQlQueryContent.top,
65
- variables: realBottom,
66
- }),
67
- });
68
- const result = await response.json();
69
- // @ts-ignore
70
- if (result && result.error) {
71
- // @ts-ignore
72
- throw new Error(`api error: ${result.error}`);
73
- }
74
- // @ts-ignore
75
- const realData = result.data.catalog.contentsConnection.edges
76
- .map((edge) => edge.content)
77
- .map((match) => {
78
- const { __typename, ...rest } = match;
79
- return rest;
80
- });
81
- return realData;
82
- };
83
-
84
- export const handleApiArticleByCategoryId = async ({
85
- appId,
86
- apiUrl,
87
- categoryId,
88
- res,
89
- }) => {
90
- const content = await getContent({ appId, apiUrl, categoryId });
91
- res.setHeader("content-type", "application/json");
92
- res.end(JSON.stringify(content, null, 2));
93
- };
@@ -1,35 +0,0 @@
1
- import * as GraphQlQueryAuthors from "../GraphQlQueryAuthors/GraphQlQueryAuthors.js";
2
-
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
- }),
24
- });
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,35 +0,0 @@
1
- import * as GraphQlQueryCategories from "../GraphQlQueryCategories/GraphQlQueryCategories.js";
2
-
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
- }),
24
- });
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,59 +0,0 @@
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
- if (result && result.errors) {
36
- // @ts-ignore
37
- throw new Error(`api error: ${result.errors[0].message}`);
38
- }
39
- console.log({ result });
40
- // @ts-ignore
41
- const realData = result.data.catalog.collectionsConnection.edges
42
- .map((edge) => {
43
- return edge.node;
44
- })
45
- .map((match) => {
46
- const { __typename, ...rest } = match;
47
- return rest;
48
- });
49
- return realData;
50
- };
51
-
52
- export const handleApiCollection =
53
- ({ appId, apiUrl }) =>
54
- async (req, res, next) => {
55
- const name = req.url.slice("/collections/".length);
56
- const content = await getCollections({ appId, apiUrl, name });
57
- res.setHeader("content-type", "application/json");
58
- res.end(JSON.stringify(content, null, 2));
59
- };
@@ -1,49 +0,0 @@
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
- };
@@ -1,104 +0,0 @@
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 =
40
- ({ appId, apiUrl }) =>
41
- async (req, res, next) => {
42
- const bundleId = await getBundleId({
43
- appId,
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
- },
63
- },
64
- {
65
- contentType: {
66
- value: "POST",
67
- },
68
- },
69
- {
70
- AND: [
71
- {
72
- bundleId: {
73
- value: bundleId,
74
- },
75
- },
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
- }),
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
- });
101
-
102
- res.setHeader("content-type", "application/json");
103
- res.send(JSON.stringify(realData, null, 2));
104
- };
@@ -1,36 +0,0 @@
1
- import * as GraphQlQueryDossiers from "../GraphQlQueryDossiers/GraphQlQueryDossiers.js";
2
-
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
- }),
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
- });
33
-
34
- res.setHeader("content-type", "application/json");
35
- res.send(JSON.stringify(realData, null, 2));
36
- };
@@ -1,24 +0,0 @@
1
- export const handleIndex = async (req, res, next) => {
2
- const html = `<!doctype html>
3
- <html lang="en">
4
- <head>
5
- <meta charset="UTF-8" />
6
- <meta name="viewport" content="width=device-width, initial-scale=1.0" />
7
- <title>Api</title>
8
- </head>
9
- <body>
10
- <ul>
11
- <li><a href="/api/issues">Issues</a></li>
12
- <li><a href="/api/dossiers">Dossiers</a></li>
13
- <li><a href="/api/categories">Categories</a></li>
14
- <li><a href="/api/articles">Articles</a></li>
15
- <li><a href="/api/authors">Authors</a></li>
16
- <li><a href="/api/collections">Collections</a></li>
17
- <li><a href="/api/menus">Menus</a></li>
18
- </ul>
19
- </body>
20
- </html>
21
- `;
22
- res.setHeader("content-type", "text/html");
23
- res.end(html);
24
- };
@@ -1,35 +0,0 @@
1
- import * as GraphQlQueryIssues from "../GraphQlQueryIssues/GraphQlQueryIssues.js";
2
-
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
- }),
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
- });
33
- res.setHeader("content-type", "application/json");
34
- res.send(JSON.stringify(realData, null, 2));
35
- };
@@ -1,36 +0,0 @@
1
- import * as GraphQlQueryMenus from "../GraphQlQueryMenus/GraphQlQueryMenus.js";
2
-
3
- export const handleMenus =
4
- ({ appId, apiUrl }) =>
5
- async (req, res, next) => {
6
- const realBottom = {
7
- ...GraphQlQueryMenus.bottom,
8
- filter: {},
9
- appInfo: {
10
- ...GraphQlQueryMenus.bottom.appInfo,
11
- appId,
12
- },
13
- };
14
- const response = await fetch(apiUrl, {
15
- method: "POST",
16
- headers: {
17
- Accept: "application/json",
18
- "Content-Type": "application/json",
19
- },
20
- body: JSON.stringify({
21
- operationName: GraphQlQueryMenus.queryName,
22
- query: GraphQlQueryMenus.top,
23
- variables: realBottom,
24
- }),
25
- });
26
- const result = await response.json();
27
- // @ts-ignore
28
- const realData = result.data.catalog.menusConnection.edges
29
- .map((edge) => edge.content)
30
- .map((node) => {
31
- const { __typename, ...rest } = node;
32
- return rest;
33
- });
34
- res.setHeader("content-type", "application/json");
35
- res.send(JSON.stringify(realData, null, 2));
36
- };
@@ -1,54 +0,0 @@
1
- import * as GraphQlQueryContent from "../GraphQlQueryContent/GraphQlQueryContent.js";
2
-
3
- const getContent = async ({ appId, apiUrl, postId }) => {
4
- const realBottom = {
5
- ...GraphQlQueryContent.bottom,
6
- appInfo: {
7
- ...GraphQlQueryContent.bottom.appInfo,
8
- appId,
9
- },
10
- filter: {
11
- id: {
12
- value: postId,
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: GraphQlQueryContent.queryName,
24
- query: GraphQlQueryContent.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.contentsConnection.edges
36
- .map((edge) => edge.content)
37
- .map((match) => {
38
- const { __typename, ...rest } = match;
39
- return rest;
40
- });
41
- return realData;
42
- };
43
-
44
- export const handleApiPostByName = async ({ postIds, res, appId, apiUrl }) => {
45
- if (postIds.length === 0) {
46
- res.setHeader("content-type", "application/json");
47
- res.end(JSON.stringify("Not found", null, 2));
48
- return;
49
- }
50
- const postId = postIds[0];
51
- const content = await getContent({ appId, apiUrl, postId });
52
- res.setHeader("content-type", "application/json");
53
- res.end(JSON.stringify(content, null, 2));
54
- };
@@ -1,33 +0,0 @@
1
- import * as GraphQlQueryCategories from "../GraphQlQueryCategories/GraphQlQueryCategories.js";
2
-
3
- export const handleTaxonomies = (appId) => async (req, res, next) => {
4
- const url = `https://catalog.purplemanager.com/graphql`;
5
- const realBottom = {
6
- ...GraphQlQueryCategories.bottom,
7
- appInfo: {
8
- ...GraphQlQueryCategories.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: GraphQlQueryCategories.top,
21
- variables: realBottom,
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;
31
- });
32
- res.end(JSON.stringify(realData, null, 2));
33
- };