@pronto-tools-and-more/api 13.0.1 → 13.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pronto-tools-and-more/api",
3
- "version": "13.0.1",
3
+ "version": "13.2.0",
4
4
  "description": "",
5
5
  "main": "src/main.js",
6
6
  "type": "module",
@@ -0,0 +1,197 @@
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
+ bundleType: {
171
+ value: "ISSUE",
172
+ },
173
+ },
174
+ includeBlocks: false,
175
+ includeHtml: false,
176
+ includeResources: false,
177
+ includeBundledContent: false,
178
+ includeContentSeoMetadata: false,
179
+ appInfo: {
180
+ appId: "",
181
+ appVersion: "1.0-SNAPSHOT",
182
+ preview: true,
183
+ },
184
+ deviceInfo: {
185
+ deviceId: "editor-preview",
186
+ deviceModel: "web",
187
+ locale: "de_DE",
188
+ smallestScreenWidthDp: 0,
189
+ deviceOs: "web",
190
+ platform: "WEB",
191
+ },
192
+ authorization: {
193
+ subscriptionCodes: [],
194
+ },
195
+ };
196
+
197
+ export const queryName = "CatalogContentsQuery";
@@ -10,6 +10,7 @@ import * as HandleApiAuthor from "../HandleApiAuthor/HandleApiAuthor.js";
10
10
  import * as HandleApiAppSettings from "../HandleApiAppSettings/HandleApiAppSettings.js";
11
11
  import * as HandleApiIssues from "../HandleApiIssues/HandleApiIssues.js";
12
12
  import * as HandleApiMenus from "../HandleApiMenus/HandleApiMenus.js";
13
+ import * as HandleApiDigitalIssues from "../HandleApiDigitalIssues/HandleApiDigitalIssues.js";
13
14
 
14
15
  export const handleApi = ({ appId, apiUrl, req }) => {
15
16
  if (req.url === "/") {
@@ -30,6 +31,9 @@ export const handleApi = ({ appId, apiUrl, req }) => {
30
31
  if (req.url === "/issues") {
31
32
  return HandleApiIssues.handleIssues({ appId, apiUrl, req });
32
33
  }
34
+ if (req.url === "/digital-issues") {
35
+ return HandleApiDigitalIssues.handleDigitalIssues({ appId, apiUrl, req });
36
+ }
33
37
  if (req.url === "/authors") {
34
38
  return HandleApiAuthors.handleAuthors({ appId, apiUrl, req });
35
39
  }
@@ -0,0 +1,39 @@
1
+ import * as GraphQlQueryDigitalIssues from "../GraphQlQueryDigitalIssues/GraphQlQueryDigitalIssues.js";
2
+
3
+ export const handleDigitalIssues = async ({ appId, apiUrl, req }) => {
4
+ const realBottom = {
5
+ ...GraphQlQueryDigitalIssues.bottom,
6
+ appInfo: {
7
+ ...GraphQlQueryDigitalIssues.bottom.appInfo,
8
+ appId,
9
+ },
10
+ };
11
+ const response = await fetch(apiUrl, {
12
+ method: "POST",
13
+ headers: {
14
+ Accept: "application/json",
15
+ "Content-Type": "application/json",
16
+ },
17
+ body: JSON.stringify({
18
+ operationName: GraphQlQueryDigitalIssues.queryName,
19
+ query: GraphQlQueryDigitalIssues.top,
20
+ variables: realBottom,
21
+ }),
22
+ });
23
+ const result = await response.json();
24
+ // @ts-ignore
25
+ const realData = result.data.catalog.contentsConnection.edges
26
+ .map((edge) => edge.content)
27
+ .map((node) => {
28
+ const { __typename, ...rest } = node;
29
+ return rest;
30
+ });
31
+
32
+ return {
33
+ status: 200,
34
+ headers: {
35
+ "content-type": "application/json",
36
+ },
37
+ body: JSON.stringify(realData, null, 2),
38
+ };
39
+ };