@pronto-tools-and-more/pronto 12.25.0 → 12.27.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.25.0",
3
+ "version": "12.27.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.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",
20
+ "@pronto-tools-and-more/file-watcher": "12.27.0",
21
+ "@pronto-tools-and-more/files": "12.27.0",
22
+ "@pronto-tools-and-more/network-process": "12.27.0",
23
+ "@pronto-tools-and-more/sass-compiler": "12.27.0",
24
+ "@pronto-tools-and-more/components-renderer": "12.27.0",
25
+ "@pronto-tools-and-more/components": "12.27.0",
26
+ "@pronto-tools-and-more/schema-process": "12.27.0",
27
+ "@pronto-tools-and-more/diff-process": "12.27.0",
28
+ "@pronto-tools-and-more/type-checker": "12.27.0",
29
+ "@pronto-tools-and-more/custom-js-functions": "12.27.0",
30
30
  "execa": "^9.5.2",
31
31
  "express": "^4.21.2"
32
32
  },
@@ -126,6 +126,17 @@ export const build = async () => {
126
126
  )
127
127
  );
128
128
  }
129
+
130
+ if (
131
+ tag &&
132
+ Config.pushToReleaseOnGitTag &&
133
+ existsSync(join(dist, "src", "default", "storefront", "robots.prod.txt"))
134
+ ) {
135
+ await cp(
136
+ join(dist, "src", "default", "storefront", "robots.prod.txt"),
137
+ join(dist, "src", "default", "storefront", "robots.txt")
138
+ );
139
+ }
129
140
  if (Config.validateSchema) {
130
141
  await ValidateAllSchemas.validateAllSchemas();
131
142
  }
@@ -0,0 +1,41 @@
1
+ import * as GraphQlQueryPathSegments from "../GraphQlQueryPathSegments/GraphQlQueryPathSegments.js";
2
+
3
+ export const getPostIds = async ({ appId, apiUrl, slug }) => {
4
+ const realBottom = {
5
+ ...GraphQlQueryPathSegments.bottom,
6
+ appInfo: {
7
+ ...GraphQlQueryPathSegments.bottom.appInfo,
8
+ appId,
9
+ },
10
+ pathSegments: [slug],
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: GraphQlQueryPathSegments.queryName,
20
+ query: GraphQlQueryPathSegments.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.lookupPathSegments
32
+ .flatMap((item) => item.matches)
33
+ .map((match) => {
34
+ const { __typename, ...rest } = match;
35
+ return rest;
36
+ })
37
+ .map((match) => {
38
+ return match.id;
39
+ });
40
+ return realData;
41
+ };
@@ -0,0 +1,77 @@
1
+ export const top = `query MenuQuery($appInfo: AppInfo!, $deviceInfo: DeviceInfo!, $authorization: Authorization!, $filter: MenuFilter, $first: Int, $after: String, $includeItems: Boolean!) {
2
+ catalog(
3
+ appInfo: $appInfo
4
+ deviceInfo: $deviceInfo
5
+ authorization: $authorization
6
+ ) {
7
+ menusConnection(filter: $filter, first: $first, after: $after) {
8
+ edges {
9
+ node {
10
+ id
11
+ name
12
+ properties {
13
+ key
14
+ value
15
+ type
16
+ }
17
+ items @include(if: $includeItems) {
18
+ id
19
+ sortIndex
20
+ parentId
21
+ url
22
+ name
23
+ title
24
+ description
25
+ target
26
+ cssClasses
27
+ properties {
28
+ key
29
+ value
30
+ type
31
+ }
32
+ thumbnails {
33
+ kind
34
+ url
35
+ properties {
36
+ key
37
+ value
38
+ }
39
+ }
40
+ }
41
+ }
42
+ }
43
+ pageInfo {
44
+ hasNextPage
45
+ endCursor
46
+ }
47
+ }
48
+ }
49
+ }`;
50
+
51
+ export const bottom = {
52
+ filter: {
53
+ name: {
54
+ value: "",
55
+ },
56
+ },
57
+ first: 24,
58
+ includeItems: true,
59
+ appInfo: {
60
+ appId: "",
61
+ appVersion: "1.0-SNAPSHOT",
62
+ preview: true,
63
+ },
64
+ deviceInfo: {
65
+ deviceId: "editor-preview",
66
+ deviceModel: "web",
67
+ locale: "de_DE",
68
+ smallestScreenWidthDp: 0,
69
+ deviceOs: "web",
70
+ platform: "WEB",
71
+ },
72
+ authorization: {
73
+ subscriptionCodes: [],
74
+ },
75
+ };
76
+
77
+ export const queryName = "MenuQuery";
@@ -2,11 +2,12 @@ import * as HandleApiArticle from "../HandleApiArticle/HandleApiArticle.js";
2
2
  import * as HandleApiAuthors from "../HandleApiAuthors/HandleApiAuthors.js";
3
3
  import * as HandleCategories from "../HandleApiCategories/HandleApiCategories.js";
4
4
  import * as HandleApiCollection from "../HandleApiCollection/HandleApiCollection.js";
5
+ import * as HandleApiCollections from "../HandleApiCollections/HandleApiCollections.js";
5
6
  import * as HandleApiDossier from "../HandleApiDossier/HandleApiDossier.js";
6
7
  import * as HandleDossiers from "../HandleApiDossiers/HandleApiDossiers.js";
7
8
  import * as HandleApiIndex from "../HandleApiIndex/HandleApiIndex.js";
8
9
  import * as HandleApiIssues from "../HandleApiIssues/HandleApiIssues.js";
9
- import * as HandleApiCollections from "../HandleApiCollections/HandleApiCollections.js";
10
+ import * as HandleApiMenus from "../HandleApiMenus/HandleApiMenus.js";
10
11
 
11
12
  export const handleApi =
12
13
  ({ appId, apiUrl }) =>
@@ -44,6 +45,9 @@ export const handleApi =
44
45
  res
45
46
  );
46
47
  }
48
+ if (req.url === "/menus" || req.url === "/menus/") {
49
+ return HandleApiMenus.handleMenus({ apiUrl, appId })(req, res);
50
+ }
47
51
  res.statusCode = 404;
48
52
  return res.end("not found");
49
53
  };
@@ -1,99 +1,30 @@
1
- import * as GraphQlQueryPathSegments from "../GraphQlQueryPathSegments/GraphQlQueryPathSegments.js";
2
- import * as GraphQlQueryContent from "../GraphQlQueryContent/GraphQlQueryContent.js";
3
-
4
- const getPostIds = async ({ appId, apiUrl, slug }) => {
5
- const realBottom = {
6
- ...GraphQlQueryPathSegments.bottom,
7
- appInfo: {
8
- ...GraphQlQueryPathSegments.bottom.appInfo,
9
- appId,
10
- },
11
- pathSegments: [slug],
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: GraphQlQueryPathSegments.queryName,
21
- query: GraphQlQueryPathSegments.top,
22
- variables: realBottom,
23
- }),
24
- });
25
- const result = await response.json();
26
- // @ts-ignore
27
- if (result && result.error) {
28
- // @ts-ignore
29
- throw new Error(`api error: ${result.error}`);
30
- }
31
- // @ts-ignore
32
- const realData = result.data.catalog.lookupPathSegments
33
- .flatMap((item) => item.matches)
34
- .map((match) => {
35
- const { __typename, ...rest } = match;
36
- return rest;
37
- })
38
- .map((match) => {
39
- return match.id;
40
- });
41
- return realData;
42
- };
43
-
44
- const getContent = async ({ appId, apiUrl, postId }) => {
45
- const realBottom = {
46
- ...GraphQlQueryContent.bottom,
47
- appInfo: {
48
- ...GraphQlQueryContent.bottom.appInfo,
49
- appId,
50
- },
51
- filter: {
52
- id: {
53
- value: postId,
54
- },
55
- },
56
- };
57
- const response = await fetch(apiUrl, {
58
- method: "POST",
59
- headers: {
60
- Accept: "application/json",
61
- "Content-Type": "application/json",
62
- },
63
- body: JSON.stringify({
64
- operationName: GraphQlQueryContent.queryName,
65
- query: GraphQlQueryContent.top,
66
- variables: realBottom,
67
- }),
68
- });
69
- const result = await response.json();
70
- // @ts-ignore
71
- if (result && result.error) {
72
- // @ts-ignore
73
- throw new Error(`api error: ${result.error}`);
74
- }
75
- // @ts-ignore
76
- const realData = result.data.catalog.contentsConnection.edges
77
- .map((edge) => edge.content)
78
- .map((match) => {
79
- const { __typename, ...rest } = match;
80
- return rest;
81
- });
82
- return realData;
83
- };
1
+ import * as GetPostIds from "../GetPostIds/GetPostIds.js";
2
+ import * as HandleApiPostByName from "../HandleApiPostByName/HandleApiPostByName.js";
3
+ import * as HandleApiArticleByCategoryId from "../HandleApiArticleByCategoryId/HandleApiArticleByCategoryId.js";
84
4
 
85
5
  export const handleApiArticle =
86
6
  ({ appId, apiUrl }) =>
87
7
  async (req, res, next) => {
88
8
  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;
9
+ const url = new URL(req.url, "https://example.com");
10
+ const categoryId = url.searchParams.get("categoryId");
11
+ if (categoryId) {
12
+ return HandleApiArticleByCategoryId.handleApiArticleByCategoryId({
13
+ apiUrl,
14
+ appId,
15
+ categoryId,
16
+ res,
17
+ });
94
18
  }
95
- const postId = postIds[0];
96
- const content = await getContent({ appId, apiUrl, postId });
97
- res.setHeader("content-type", "application/json");
98
- res.end(JSON.stringify(content, null, 2));
19
+ const postIds = await GetPostIds.getPostIds({
20
+ appId,
21
+ apiUrl,
22
+ slug: articleSlug,
23
+ });
24
+ return HandleApiPostByName.handleApiPostByName({
25
+ apiUrl,
26
+ appId,
27
+ postIds,
28
+ res,
29
+ });
99
30
  };
@@ -0,0 +1,93 @@
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
+ };
@@ -32,6 +32,12 @@ const getCollections = async ({ appId, apiUrl, name }) => {
32
32
  throw new Error(`api error: ${result.error}`);
33
33
  }
34
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
35
41
  const realData = result.data.catalog.collectionsConnection.edges
36
42
  .map((edge) => {
37
43
  return edge.node;
@@ -14,6 +14,7 @@ export const handleIndex = async (req, res, next) => {
14
14
  <li><a href="/api/articles">Articles</a></li>
15
15
  <li><a href="/api/authors">Authors</a></li>
16
16
  <li><a href="/api/collections">Collections</a></li>
17
+ <li><a href="/api/menus">Menus</a></li>
17
18
  </ul>
18
19
  </body>
19
20
  </html>
@@ -0,0 +1,36 @@
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
+ };
@@ -0,0 +1,54 @@
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 +1 @@
1
- export const version = '12.25.0'
1
+ export const version = '12.27.0'