@configura/web-api 2.1.0-alpha.3 → 2.1.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.
@@ -32,7 +32,7 @@ export interface DtoApplicationAreasResponse {
32
32
  applicationAreas: Array<DtoApplicationArea>;
33
33
  uuid: string;
34
34
  }
35
- /** AuthorizeResponse */
35
+ /** AuthorizeResponse - The response to an authorize request. It contains an endpoint, a session token and an API session. The endpoint is the URL to access the API. The secret token is used to validate each request to the API. The API session contains information about the user's catalogue access. */
36
36
  export interface DtoAuthorizeResponse {
37
37
  endpoint: string;
38
38
  secretToken: string;
@@ -466,7 +466,7 @@ export interface DtoProductResponse {
466
466
  uuid: string;
467
467
  notes?: Array<DtoNote>;
468
468
  }
469
- /** RefreshSessionTokenResponse */
469
+ /** RefreshSessionTokenResponse - The response to a refresh session token request. It contains a new API session. */
470
470
  export interface DtoRefreshSessionTokenResponse {
471
471
  apiSession: DtoCatalogueAPISession;
472
472
  }
@@ -9,29 +9,14 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
9
9
  step((generator = generator.apply(thisArg, _arguments || [])).next());
10
10
  });
11
11
  };
12
- export const dtoExportFormatNames = [
13
- "glb",
14
- "gltf",
15
- "fbx",
16
- "dwg",
17
- "cmdrw",
18
- "cmfav",
19
- "cmsym",
20
- ];
21
- export const dtoExportStatusStatusNames = [
22
- "pending",
23
- "running",
24
- "finished",
25
- "failed",
26
- ];
12
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
13
+ // @ts-ignore
14
+ import packageInfo from "../package.json";
15
+ export const dtoExportFormatNames = ["glb", "gltf", "fbx", "dwg", "cmdrw", "cmfav", "cmsym"];
16
+ export const dtoExportStatusStatusNames = ["pending", "running", "finished", "failed"];
27
17
  export const dtoNoteSeverityNames = ["Information", "Critical", "Warning"];
28
18
  export const dtoRenderFormatNames = ["jpg", "png"];
29
- export const dtoRenderStatusStatusNames = [
30
- "pending",
31
- "running",
32
- "finished",
33
- "failed",
34
- ];
19
+ export const dtoRenderStatusStatusNames = ["pending", "running", "finished", "failed"];
35
20
  export const dtoSyncGroupMethodsNames = ["pull", "push", "twoWay"];
36
21
  export class DtoAPIError extends Error {
37
22
  }
@@ -50,9 +35,7 @@ export class CatalogueAPI {
50
35
  }
51
36
  }
52
37
  hasFeature(feature) {
53
- return (this.auth !== undefined &&
54
- this.auth.apiSession.features !== undefined &&
55
- this.auth.apiSession.features.indexOf(feature) > -1);
38
+ return this.auth !== undefined && this.auth.apiSession.features !== undefined && this.auth.apiSession.features.indexOf(feature) > -1;
56
39
  }
57
40
  fetch(url, options) {
58
41
  return __awaiter(this, void 0, void 0, function* () {
@@ -66,7 +49,7 @@ export class CatalogueAPI {
66
49
  response = yield this._fetch(url, options);
67
50
  body = yield response.text();
68
51
  const parsed = JSON.parse(body);
69
- if ("error" in parsed) {
52
+ if (parsed && typeof parsed === "object" && "error" in parsed) {
70
53
  err = new DtoAPIError(parsed.error);
71
54
  err.body = body;
72
55
  err.status = response.status;
@@ -91,7 +74,7 @@ export class CatalogueAPI {
91
74
  const url = `/v1/access-token/public/${encodeURIComponent(params.accessTokenId)}/authorize`;
92
75
  const options = {
93
76
  method: "POST",
94
- headers: {},
77
+ headers: { "X-SDK-Version": packageInfo.version },
95
78
  };
96
79
  if (this._alternativeReferer) {
97
80
  options.headers["Alternative-Referer"] = this._alternativeReferer;
@@ -107,7 +90,7 @@ export class CatalogueAPI {
107
90
  const url = `/v1/catalogue/${encodeURIComponent(params.lang)}/${encodeURIComponent(params.enterprise)}/${encodeURIComponent(params.prdCat)}/${encodeURIComponent(params.prdCatVersion)}/${encodeURIComponent(params.vendor)}/${encodeURIComponent(params.priceList)}/application-areas`;
108
91
  const options = {
109
92
  method: "GET",
110
- headers: { "X-API-Key": this.auth.secretToken || "" },
93
+ headers: { "X-API-Key": this.auth.secretToken || "", "X-SDK-Version": packageInfo.version },
111
94
  };
112
95
  if (this._alternativeReferer) {
113
96
  options.headers["Alternative-Referer"] = this._alternativeReferer;
@@ -123,7 +106,7 @@ export class CatalogueAPI {
123
106
  const url = `/v1/catalogue/${encodeURIComponent(params.lang)}/${encodeURIComponent(params.enterprise)}/${encodeURIComponent(params.prdCat)}/${encodeURIComponent(params.prdCatVersion)}/${encodeURIComponent(params.vendor)}/${encodeURIComponent(params.priceList)}/export/${encodeURIComponent(params.partNumber)}`;
124
107
  const options = {
125
108
  method: "POST",
126
- headers: { "X-API-Key": this.auth.secretToken || "" },
109
+ headers: { "X-API-Key": this.auth.secretToken || "", "X-SDK-Version": packageInfo.version },
127
110
  body: JSON.stringify(body),
128
111
  };
129
112
  if (this._alternativeReferer) {
@@ -140,7 +123,7 @@ export class CatalogueAPI {
140
123
  const url = `/v1/catalogue/${encodeURIComponent(params.lang)}/${encodeURIComponent(params.enterprise)}/${encodeURIComponent(params.prdCat)}/${encodeURIComponent(params.prdCatVersion)}/${encodeURIComponent(params.vendor)}/${encodeURIComponent(params.priceList)}/price-lists`;
141
124
  const options = {
142
125
  method: "GET",
143
- headers: { "X-API-Key": this.auth.secretToken || "" },
126
+ headers: { "X-API-Key": this.auth.secretToken || "", "X-SDK-Version": packageInfo.version },
144
127
  };
145
128
  if (this._alternativeReferer) {
146
129
  options.headers["Alternative-Referer"] = this._alternativeReferer;
@@ -156,7 +139,7 @@ export class CatalogueAPI {
156
139
  const url = `/v1/catalogue/${encodeURIComponent(params.lang)}/${encodeURIComponent(params.enterprise)}/${encodeURIComponent(params.prdCat)}/${encodeURIComponent(params.prdCatVersion)}/${encodeURIComponent(params.vendor)}/${encodeURIComponent(params.priceList)}/product-v2/${encodeURIComponent(params.partNumber)}`;
157
140
  const options = {
158
141
  method: "GET",
159
- headers: { "X-API-Key": this.auth.secretToken || "" },
142
+ headers: { "X-API-Key": this.auth.secretToken || "", "X-SDK-Version": packageInfo.version },
160
143
  };
161
144
  if (this._alternativeReferer) {
162
145
  options.headers["Alternative-Referer"] = this._alternativeReferer;
@@ -172,7 +155,7 @@ export class CatalogueAPI {
172
155
  const url = `/v1/catalogue/${encodeURIComponent(params.lang)}/${encodeURIComponent(params.enterprise)}/${encodeURIComponent(params.prdCat)}/${encodeURIComponent(params.prdCatVersion)}/${encodeURIComponent(params.vendor)}/${encodeURIComponent(params.priceList)}/product-v3/${encodeURIComponent(params.partNumber)}`;
173
156
  const options = {
174
157
  method: "GET",
175
- headers: { "X-API-Key": this.auth.secretToken || "" },
158
+ headers: { "X-API-Key": this.auth.secretToken || "", "X-SDK-Version": packageInfo.version },
176
159
  };
177
160
  if (this._alternativeReferer) {
178
161
  options.headers["Alternative-Referer"] = this._alternativeReferer;
@@ -188,7 +171,7 @@ export class CatalogueAPI {
188
171
  const url = `/v1/catalogue/${encodeURIComponent(params.lang)}/${encodeURIComponent(params.enterprise)}/${encodeURIComponent(params.prdCat)}/${encodeURIComponent(params.prdCatVersion)}/${encodeURIComponent(params.vendor)}/${encodeURIComponent(params.priceList)}/product/${encodeURIComponent(params.partNumber)}/render`;
189
172
  const options = {
190
173
  method: "POST",
191
- headers: { "X-API-Key": this.auth.secretToken || "" },
174
+ headers: { "X-API-Key": this.auth.secretToken || "", "X-SDK-Version": packageInfo.version },
192
175
  body: JSON.stringify(body),
193
176
  };
194
177
  if (this._alternativeReferer) {
@@ -205,7 +188,7 @@ export class CatalogueAPI {
205
188
  const url = `/v1/catalogue/${encodeURIComponent(params.lang)}/${encodeURIComponent(params.enterprise)}/${encodeURIComponent(params.prdCat)}/${encodeURIComponent(params.prdCatVersion)}/${encodeURIComponent(params.vendor)}/${encodeURIComponent(params.priceList)}/product/${encodeURIComponent(params.partNumber)}/validate`;
206
189
  const options = {
207
190
  method: "POST",
208
- headers: { "X-API-Key": this.auth.secretToken || "" },
191
+ headers: { "X-API-Key": this.auth.secretToken || "", "X-SDK-Version": packageInfo.version },
209
192
  body: JSON.stringify(body),
210
193
  };
211
194
  if (this._alternativeReferer) {
@@ -222,7 +205,7 @@ export class CatalogueAPI {
222
205
  const url = `/v1/catalogue/${encodeURIComponent(params.lang)}/${encodeURIComponent(params.enterprise)}/${encodeURIComponent(params.prdCat)}/${encodeURIComponent(params.prdCatVersion)}/${encodeURIComponent(params.vendor)}/${encodeURIComponent(params.priceList)}/product/${encodeURIComponent(params.partNumber)}/validate-v2`;
223
206
  const options = {
224
207
  method: "POST",
225
- headers: { "X-API-Key": this.auth.secretToken || "" },
208
+ headers: { "X-API-Key": this.auth.secretToken || "", "X-SDK-Version": packageInfo.version },
226
209
  body: JSON.stringify(body),
227
210
  };
228
211
  if (this._alternativeReferer) {
@@ -239,7 +222,7 @@ export class CatalogueAPI {
239
222
  const url = `/v1/catalogue/${encodeURIComponent(params.lang)}/${encodeURIComponent(params.enterprise)}/${encodeURIComponent(params.prdCat)}/${encodeURIComponent(params.prdCatVersion)}/${encodeURIComponent(params.vendor)}/${encodeURIComponent(params.priceList)}/toc`;
240
223
  const options = {
241
224
  method: "GET",
242
- headers: { "X-API-Key": this.auth.secretToken || "" },
225
+ headers: { "X-API-Key": this.auth.secretToken || "", "X-SDK-Version": packageInfo.version },
243
226
  };
244
227
  if (this._alternativeReferer) {
245
228
  options.headers["Alternative-Referer"] = this._alternativeReferer;
@@ -255,7 +238,7 @@ export class CatalogueAPI {
255
238
  const url = `/v1/catalogue/${encodeURIComponent(params.lang)}/${encodeURIComponent(params.enterprise)}/${encodeURIComponent(params.prdCat)}/${encodeURIComponent(params.prdCatVersion)}/${encodeURIComponent(params.vendor)}/${encodeURIComponent(params.priceList)}/toc/flat`;
256
239
  const options = {
257
240
  method: "GET",
258
- headers: { "X-API-Key": this.auth.secretToken || "" },
241
+ headers: { "X-API-Key": this.auth.secretToken || "", "X-SDK-Version": packageInfo.version },
259
242
  };
260
243
  if (this._alternativeReferer) {
261
244
  options.headers["Alternative-Referer"] = this._alternativeReferer;
@@ -271,7 +254,7 @@ export class CatalogueAPI {
271
254
  const url = `/v1/export/${encodeURIComponent(params.uuid)}`;
272
255
  const options = {
273
256
  method: "GET",
274
- headers: { "X-API-Key": this.auth.secretToken || "" },
257
+ headers: { "X-API-Key": this.auth.secretToken || "", "X-SDK-Version": packageInfo.version },
275
258
  };
276
259
  if (this._alternativeReferer) {
277
260
  options.headers["Alternative-Referer"] = this._alternativeReferer;
@@ -287,7 +270,7 @@ export class CatalogueAPI {
287
270
  const url = `/v1/render/${encodeURIComponent(params.uuid)}`;
288
271
  const options = {
289
272
  method: "GET",
290
- headers: { "X-API-Key": this.auth.secretToken || "" },
273
+ headers: { "X-API-Key": this.auth.secretToken || "", "X-SDK-Version": packageInfo.version },
291
274
  };
292
275
  if (this._alternativeReferer) {
293
276
  options.headers["Alternative-Referer"] = this._alternativeReferer;
@@ -303,7 +286,7 @@ export class CatalogueAPI {
303
286
  const url = `/v1/session-token/refresh`;
304
287
  const options = {
305
288
  method: "POST",
306
- headers: { "X-API-Key": this.auth.secretToken || "" },
289
+ headers: { "X-API-Key": this.auth.secretToken || "", "X-SDK-Version": packageInfo.version },
307
290
  };
308
291
  if (this._alternativeReferer) {
309
292
  options.headers["Alternative-Referer"] = this._alternativeReferer;
@@ -29,18 +29,31 @@ export function generateProductConfigurations(api, lang, catalogues, filters, se
29
29
  const productEntries = productRefs.entries();
30
30
  for (const [productIndex, prdRef] of productEntries) {
31
31
  const startTime = performance.now();
32
- const product = yield __await(CfgProduct.make(api, Object.assign(Object.assign({}, catalogueParams), { partNumber: prdRef.partNr }), settings));
33
- const getProductDuration = performance.now() - startTime;
34
- yield yield __await({
35
- applicationAreasResponse,
36
- catalogueCount,
37
- catalogueIndex,
38
- catalogueParams,
39
- getProductDuration,
40
- product,
41
- productCount,
42
- productIndex,
43
- });
32
+ try {
33
+ const product = yield __await(CfgProduct.make(api, Object.assign(Object.assign({}, catalogueParams), { partNumber: prdRef.partNr }), settings));
34
+ const getProductDuration = performance.now() - startTime;
35
+ yield yield __await({
36
+ applicationAreasResponse,
37
+ catalogueCount,
38
+ catalogueIndex,
39
+ catalogueParams,
40
+ getProductDuration,
41
+ product,
42
+ productCount,
43
+ productIndex,
44
+ });
45
+ }
46
+ catch (e) {
47
+ // Product load error, for example missing CmSym files.
48
+ // Safe to continue loading the next product.
49
+ const split = e.message.indexOf(", request ID: ");
50
+ if (split > -1) {
51
+ // The request ID part of the error from the server is mostly just spam and
52
+ // makes it harder to read list of errors, so remove it.
53
+ e.message = e.message.slice(0, split);
54
+ }
55
+ yield yield __await(toError(e));
56
+ }
44
57
  }
45
58
  }
46
59
  catch (e) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@configura/web-api",
3
- "version": "2.1.0-alpha.3",
3
+ "version": "2.1.0",
4
4
  "license": "Apache-2.0",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -23,7 +23,7 @@
23
23
  "access": "public"
24
24
  },
25
25
  "dependencies": {
26
- "@configura/web-utilities": "2.1.0-alpha.3"
26
+ "@configura/web-utilities": "2.1.0"
27
27
  },
28
- "gitHead": "2ef8219ac17b71f67995071c25078424cfeb2f68"
28
+ "gitHead": "caedf95f12d9b911f239c7a976242d166fb33a7c"
29
29
  }