@kontent-ai/delivery-sdk 16.4.3 → 16.4.4

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.
Files changed (83) hide show
  1. package/.npmignore +15 -15
  2. package/LICENSE.md +9 -9
  3. package/dist/bundles/kontent-delivery.umd.js +5077 -4620
  4. package/dist/bundles/kontent-delivery.umd.js.map +1 -1
  5. package/dist/bundles/kontent-delivery.umd.min.js +1 -1
  6. package/dist/bundles/kontent-delivery.umd.min.js.map +1 -1
  7. package/dist/bundles/report.json +1 -1
  8. package/dist/bundles/report.min.json +1 -1
  9. package/dist/bundles/stats.json +7195 -5946
  10. package/dist/bundles/stats.min.json +11923 -10797
  11. package/dist/cjs/sdk-info.generated.js +1 -1
  12. package/dist/es6/sdk-info.generated.js +1 -1
  13. package/dist/esnext/sdk-info.generated.js +1 -1
  14. package/lib/client/delivery-client.factory.ts +9 -9
  15. package/lib/client/delivery-client.ts +163 -163
  16. package/lib/client/idelivery-client.interface.ts +110 -110
  17. package/lib/client/index.ts +3 -3
  18. package/lib/config/delivery-configs.ts +98 -98
  19. package/lib/config/index.ts +1 -1
  20. package/lib/contracts/contracts.ts +265 -265
  21. package/lib/contracts/index.ts +1 -1
  22. package/lib/elements/element-models.ts +89 -89
  23. package/lib/elements/element-resolver.ts +3 -3
  24. package/lib/elements/element-type.ts +16 -16
  25. package/lib/elements/elements.ts +70 -70
  26. package/lib/elements/index.ts +4 -4
  27. package/lib/images/image-url-transformation-builder.factory.ts +5 -5
  28. package/lib/images/image-url-transformation-builder.ts +181 -181
  29. package/lib/images/image.models.ts +4 -4
  30. package/lib/images/index.ts +3 -3
  31. package/lib/index.ts +12 -12
  32. package/lib/mappers/element.mapper.ts +504 -504
  33. package/lib/mappers/generic-element.mapper.ts +20 -20
  34. package/lib/mappers/index.ts +8 -8
  35. package/lib/mappers/item.mapper.ts +181 -181
  36. package/lib/mappers/language.mapper.ts +24 -24
  37. package/lib/mappers/sync.mapper.ts +32 -32
  38. package/lib/mappers/taxonomy.mapper.ts +77 -77
  39. package/lib/mappers/type.mapper.ts +76 -76
  40. package/lib/mappers/used-in.mapper.ts +20 -20
  41. package/lib/models/common/base-responses.ts +13 -13
  42. package/lib/models/common/common-models.ts +118 -118
  43. package/lib/models/common/filters.ts +280 -280
  44. package/lib/models/common/headers.ts +5 -5
  45. package/lib/models/common/index.ts +7 -7
  46. package/lib/models/common/pagination.class.ts +7 -7
  47. package/lib/models/common/parameters.ts +189 -189
  48. package/lib/models/common/sort-order.ts +1 -1
  49. package/lib/models/content-type-models.ts +42 -42
  50. package/lib/models/element-models.ts +51 -51
  51. package/lib/models/index.ts +9 -9
  52. package/lib/models/item-models.ts +192 -192
  53. package/lib/models/language-models.ts +17 -17
  54. package/lib/models/responses.ts +137 -137
  55. package/lib/models/sync-models.ts +18 -18
  56. package/lib/models/taxonomy-models.ts +25 -25
  57. package/lib/query/common/base-item-listing-query.class.ts +274 -274
  58. package/lib/query/common/base-listing-query.class.ts +95 -95
  59. package/lib/query/common/base-query.class.ts +148 -148
  60. package/lib/query/element/element-query.class.ts +45 -45
  61. package/lib/query/index.ts +13 -13
  62. package/lib/query/item/multiple-items-query.class.ts +183 -183
  63. package/lib/query/item/single-item-query.class.ts +106 -106
  64. package/lib/query/items-feed/items-feed-query.class.ts +191 -191
  65. package/lib/query/language/languages-query.class.ts +91 -91
  66. package/lib/query/sync/initialize-sync-query.class.ts +83 -83
  67. package/lib/query/sync/sync-changes-query.class.ts +56 -56
  68. package/lib/query/taxonomy/taxonomies-query.class.ts +82 -82
  69. package/lib/query/taxonomy/taxonomy-query.class.ts +50 -50
  70. package/lib/query/type/multiple-type-query.class.ts +95 -95
  71. package/lib/query/type/single-type-query.class.ts +45 -45
  72. package/lib/query/used-in/used-in-query.class.ts +126 -126
  73. package/lib/sdk-info.generated.ts +1 -1
  74. package/lib/services/base-delivery-query.service.ts +375 -375
  75. package/lib/services/delivery-query.service.ts +336 -336
  76. package/lib/services/index.ts +2 -2
  77. package/lib/services/mapping.service.ts +223 -223
  78. package/lib/utilities/codename.helper.ts +10 -10
  79. package/lib/utilities/delivery-url.helper.ts +11 -11
  80. package/lib/utilities/enum.helper.ts +38 -38
  81. package/lib/utilities/index.ts +3 -3
  82. package/package.json +96 -96
  83. package/readme.md +531 -531
@@ -1,77 +1,77 @@
1
- import { Contracts } from '../contracts';
2
- import { ITaxonomyGroup, ITaxonomySystemAttributes, ITaxonomyTerms } from '../models';
3
-
4
- export class TaxonomyMapper<TaxonomyCodenames extends string> {
5
- mapTaxonomy(
6
- taxonomySystem: Contracts.ITaxonomySystemAttributesContract,
7
- taxonomyTerms: Contracts.ITaxonomyTermsContract[]
8
- ): ITaxonomyGroup<TaxonomyCodenames> {
9
- if (!taxonomySystem) {
10
- throw Error(`Cannot map taxonomy due to missing 'system' property`);
11
- }
12
-
13
- if (!taxonomyTerms) {
14
- throw Error(`Cannot map taxonomy due to missing 'terms' property`);
15
- }
16
-
17
- if (!Array.isArray(taxonomyTerms)) {
18
- throw Error(`Cannot map terms because no terms array was provided`);
19
- }
20
-
21
- const mappedSystemAttributes: ITaxonomySystemAttributes<TaxonomyCodenames> = {
22
- name: taxonomySystem.name,
23
- codename: taxonomySystem.codename as TaxonomyCodenames,
24
- id: taxonomySystem.id,
25
- lastModified: taxonomySystem.last_modified
26
- };
27
-
28
- const mappedTerms: ITaxonomyTerms[] = this.mapTaxonomyTerms(taxonomyTerms);
29
-
30
- return {
31
- system: mappedSystemAttributes,
32
- terms: mappedTerms
33
- };
34
- }
35
-
36
- mapTaxonomies(taxonomies: Contracts.ITaxonomyGroupContract[]): ITaxonomyGroup<TaxonomyCodenames>[] {
37
- if (!taxonomies) {
38
- throw Error(`Cannot map taxonomy due to missing 'taxonomies' property`);
39
- }
40
-
41
- if (!Array.isArray(taxonomies)) {
42
- throw Error(`Cannot map taxonomies because the 'taxonomies' property is not an array `);
43
- }
44
-
45
- const mappedTaxonomies: ITaxonomyGroup<TaxonomyCodenames>[] = [];
46
-
47
- taxonomies.forEach((taxonomy) => {
48
- mappedTaxonomies.push(this.mapTaxonomy(taxonomy.system, taxonomy.terms));
49
- });
50
-
51
- return mappedTaxonomies;
52
- }
53
-
54
- /**
55
- * Recursively map array of taxonomy terms
56
- * @param termsArray Terms array to map
57
- */
58
- private mapTaxonomyTerms(termsArray: Contracts.ITaxonomyTermsContract[]): ITaxonomyTerms[] {
59
- if (termsArray.length === 0) {
60
- return [];
61
- }
62
-
63
- const mappedTermsArray: ITaxonomyTerms[] = [];
64
-
65
- termsArray.forEach((terms) => {
66
- const mappedTerms: ITaxonomyTerms = {
67
- codename: terms.codename,
68
- name: terms.name,
69
- terms: this.mapTaxonomyTerms(terms.terms)
70
- };
71
-
72
- mappedTermsArray.push(mappedTerms);
73
- });
74
-
75
- return mappedTermsArray;
76
- }
77
- }
1
+ import { Contracts } from '../contracts';
2
+ import { ITaxonomyGroup, ITaxonomySystemAttributes, ITaxonomyTerms } from '../models';
3
+
4
+ export class TaxonomyMapper<TaxonomyCodenames extends string> {
5
+ mapTaxonomy(
6
+ taxonomySystem: Contracts.ITaxonomySystemAttributesContract,
7
+ taxonomyTerms: Contracts.ITaxonomyTermsContract[]
8
+ ): ITaxonomyGroup<TaxonomyCodenames> {
9
+ if (!taxonomySystem) {
10
+ throw Error(`Cannot map taxonomy due to missing 'system' property`);
11
+ }
12
+
13
+ if (!taxonomyTerms) {
14
+ throw Error(`Cannot map taxonomy due to missing 'terms' property`);
15
+ }
16
+
17
+ if (!Array.isArray(taxonomyTerms)) {
18
+ throw Error(`Cannot map terms because no terms array was provided`);
19
+ }
20
+
21
+ const mappedSystemAttributes: ITaxonomySystemAttributes<TaxonomyCodenames> = {
22
+ name: taxonomySystem.name,
23
+ codename: taxonomySystem.codename as TaxonomyCodenames,
24
+ id: taxonomySystem.id,
25
+ lastModified: taxonomySystem.last_modified
26
+ };
27
+
28
+ const mappedTerms: ITaxonomyTerms[] = this.mapTaxonomyTerms(taxonomyTerms);
29
+
30
+ return {
31
+ system: mappedSystemAttributes,
32
+ terms: mappedTerms
33
+ };
34
+ }
35
+
36
+ mapTaxonomies(taxonomies: Contracts.ITaxonomyGroupContract[]): ITaxonomyGroup<TaxonomyCodenames>[] {
37
+ if (!taxonomies) {
38
+ throw Error(`Cannot map taxonomy due to missing 'taxonomies' property`);
39
+ }
40
+
41
+ if (!Array.isArray(taxonomies)) {
42
+ throw Error(`Cannot map taxonomies because the 'taxonomies' property is not an array `);
43
+ }
44
+
45
+ const mappedTaxonomies: ITaxonomyGroup<TaxonomyCodenames>[] = [];
46
+
47
+ taxonomies.forEach((taxonomy) => {
48
+ mappedTaxonomies.push(this.mapTaxonomy(taxonomy.system, taxonomy.terms));
49
+ });
50
+
51
+ return mappedTaxonomies;
52
+ }
53
+
54
+ /**
55
+ * Recursively map array of taxonomy terms
56
+ * @param termsArray Terms array to map
57
+ */
58
+ private mapTaxonomyTerms(termsArray: Contracts.ITaxonomyTermsContract[]): ITaxonomyTerms[] {
59
+ if (termsArray.length === 0) {
60
+ return [];
61
+ }
62
+
63
+ const mappedTermsArray: ITaxonomyTerms[] = [];
64
+
65
+ termsArray.forEach((terms) => {
66
+ const mappedTerms: ITaxonomyTerms = {
67
+ codename: terms.codename,
68
+ name: terms.name,
69
+ terms: this.mapTaxonomyTerms(terms.terms)
70
+ };
71
+
72
+ mappedTermsArray.push(mappedTerms);
73
+ });
74
+
75
+ return mappedTermsArray;
76
+ }
77
+ }
@@ -1,76 +1,76 @@
1
- import { Contracts } from '../contracts';
2
- import { IContentType, IContentTypeSystemAttributes, IGenericElement } from '../models';
3
-
4
- export class TypeMapper<TContentTypeCodenames extends string> {
5
- mapSingleType(response: Contracts.IViewContentTypeContract): IContentType<TContentTypeCodenames> {
6
- return this.mapType(response);
7
- }
8
-
9
- mapMultipleTypes(response: Contracts.IListContentTypeContract): IContentType<TContentTypeCodenames>[] {
10
- return response.types.map((type) => {
11
- return this.mapType(type);
12
- });
13
- }
14
-
15
- private mapType(type: Contracts.IContentTypeContract): IContentType<TContentTypeCodenames> {
16
- if (!type) {
17
- throw Error(`Cannot map type`);
18
- }
19
-
20
- if (!type.elements) {
21
- throw Error(`Cannot map type elements`);
22
- }
23
-
24
- const system: IContentTypeSystemAttributes<TContentTypeCodenames> = {
25
- codename: type.system.codename as TContentTypeCodenames,
26
- id: type.system.id,
27
- name: type.system.name,
28
- lastModified: type.system.last_modified
29
- };
30
-
31
- const elements: IGenericElement[] = [];
32
-
33
- const elementNames = Object.getOwnPropertyNames(type.elements);
34
- elementNames.forEach((elementName: string) => {
35
- const typeElement = type.elements[elementName];
36
-
37
- if (!typeElement) {
38
- throw Error(`Cannot find element '${elementName}' on type '${type.system.codename}'`);
39
- }
40
-
41
- // use json property as a codename of the type element
42
- const elementCodename = elementName;
43
-
44
- // extra properties for certain element types
45
- const options: Contracts.IElementOptionContract[] = [];
46
-
47
- // some elements can contain options
48
- const rawOptions = typeElement.options;
49
- if (rawOptions) {
50
- if (!Array.isArray(rawOptions)) {
51
- throw Error(`Content type 'options' property has to be an array`);
52
- }
53
-
54
- rawOptions.forEach((rawOption) => {
55
- options.push({
56
- codename: rawOption.codename,
57
- name: rawOption.name
58
- });
59
- });
60
- }
61
-
62
- elements.push({
63
- codename: elementCodename,
64
- taxonomyGroup: typeElement.taxonomy_group,
65
- options: options,
66
- name: typeElement.name,
67
- type: typeElement.type
68
- });
69
- });
70
-
71
- return {
72
- elements: elements,
73
- system: system
74
- };
75
- }
76
- }
1
+ import { Contracts } from '../contracts';
2
+ import { IContentType, IContentTypeSystemAttributes, IGenericElement } from '../models';
3
+
4
+ export class TypeMapper<TContentTypeCodenames extends string> {
5
+ mapSingleType(response: Contracts.IViewContentTypeContract): IContentType<TContentTypeCodenames> {
6
+ return this.mapType(response);
7
+ }
8
+
9
+ mapMultipleTypes(response: Contracts.IListContentTypeContract): IContentType<TContentTypeCodenames>[] {
10
+ return response.types.map((type) => {
11
+ return this.mapType(type);
12
+ });
13
+ }
14
+
15
+ private mapType(type: Contracts.IContentTypeContract): IContentType<TContentTypeCodenames> {
16
+ if (!type) {
17
+ throw Error(`Cannot map type`);
18
+ }
19
+
20
+ if (!type.elements) {
21
+ throw Error(`Cannot map type elements`);
22
+ }
23
+
24
+ const system: IContentTypeSystemAttributes<TContentTypeCodenames> = {
25
+ codename: type.system.codename as TContentTypeCodenames,
26
+ id: type.system.id,
27
+ name: type.system.name,
28
+ lastModified: type.system.last_modified
29
+ };
30
+
31
+ const elements: IGenericElement[] = [];
32
+
33
+ const elementNames = Object.getOwnPropertyNames(type.elements);
34
+ elementNames.forEach((elementName: string) => {
35
+ const typeElement = type.elements[elementName];
36
+
37
+ if (!typeElement) {
38
+ throw Error(`Cannot find element '${elementName}' on type '${type.system.codename}'`);
39
+ }
40
+
41
+ // use json property as a codename of the type element
42
+ const elementCodename = elementName;
43
+
44
+ // extra properties for certain element types
45
+ const options: Contracts.IElementOptionContract[] = [];
46
+
47
+ // some elements can contain options
48
+ const rawOptions = typeElement.options;
49
+ if (rawOptions) {
50
+ if (!Array.isArray(rawOptions)) {
51
+ throw Error(`Content type 'options' property has to be an array`);
52
+ }
53
+
54
+ rawOptions.forEach((rawOption) => {
55
+ options.push({
56
+ codename: rawOption.codename,
57
+ name: rawOption.name
58
+ });
59
+ });
60
+ }
61
+
62
+ elements.push({
63
+ codename: elementCodename,
64
+ taxonomyGroup: typeElement.taxonomy_group,
65
+ options: options,
66
+ name: typeElement.name,
67
+ type: typeElement.type
68
+ });
69
+ });
70
+
71
+ return {
72
+ elements: elements,
73
+ system: system
74
+ };
75
+ }
76
+ }
@@ -1,20 +1,20 @@
1
- import { Contracts } from '../contracts';
2
- import { ClientTypes, IUsedInItemRecord } from '../models';
3
-
4
- export class UsedInMapper<TClientTypes extends ClientTypes> {
5
- mapUsedInItem(response: Contracts.IUsedInItemContract): IUsedInItemRecord<TClientTypes> {
6
- return {
7
- system: {
8
- id: response.system.id,
9
- name: response.system.name,
10
- codename: response.system.codename,
11
- language: response.system.language,
12
- type: response.system.type,
13
- collection: response.system.collection,
14
- workflow: response.system.workflow,
15
- workflowStep: response.system.workflow_step,
16
- lastModified: response.system.last_modified
17
- }
18
- };
19
- }
20
- }
1
+ import { Contracts } from '../contracts';
2
+ import { ClientTypes, IUsedInItemRecord } from '../models';
3
+
4
+ export class UsedInMapper<TClientTypes extends ClientTypes> {
5
+ mapUsedInItem(response: Contracts.IUsedInItemContract): IUsedInItemRecord<TClientTypes> {
6
+ return {
7
+ system: {
8
+ id: response.system.id,
9
+ name: response.system.name,
10
+ codename: response.system.codename,
11
+ language: response.system.language,
12
+ type: response.system.type,
13
+ collection: response.system.collection,
14
+ workflow: response.system.workflow,
15
+ workflowStep: response.system.workflow_step,
16
+ lastModified: response.system.last_modified
17
+ }
18
+ };
19
+ }
20
+ }
@@ -1,13 +1,13 @@
1
- import { IResponse } from '@kontent-ai/core-sdk';
2
-
3
- export interface IDeliveryNetworkResponse<TData, TContract> {
4
- data: TData;
5
- response: IResponse<TContract>;
6
- xContinuationToken?: string;
7
- hasStaleContent: boolean;
8
- }
9
-
10
- export interface IGroupedNetworkResponse<TData> {
11
- data: TData;
12
- responses: IDeliveryNetworkResponse<any, any>[];
13
- }
1
+ import { IResponse } from '@kontent-ai/core-sdk';
2
+
3
+ export interface IDeliveryNetworkResponse<TData, TContract> {
4
+ data: TData;
5
+ response: IResponse<TContract>;
6
+ xContinuationToken?: string;
7
+ hasStaleContent: boolean;
8
+ }
9
+
10
+ export interface IGroupedNetworkResponse<TData> {
11
+ data: TData;
12
+ responses: IDeliveryNetworkResponse<any, any>[];
13
+ }
@@ -1,118 +1,118 @@
1
- import { IHeader, IHttpCancelRequestToken, IQueryParameter } from '@kontent-ai/core-sdk';
2
- import { IDeliveryNetworkResponse } from './base-responses';
3
- import { IPagination } from './pagination.class';
4
-
5
- export type LinkedItemsReferenceHandler = 'map' | 'ignore';
6
-
7
- export interface IProxyUrlData {
8
- action: string;
9
- domain: string;
10
- queryParameters: IQueryParameter[];
11
- queryString: string;
12
- queryConfig: IQueryConfig;
13
- environmentId: string;
14
- }
15
-
16
- export interface ISDKInfo {
17
- /**
18
- * Name of SDK
19
- */
20
- name: string;
21
- /**
22
- * Version SDK
23
- */
24
- version: string;
25
- /**
26
- * Host of SDK
27
- */
28
- host: string;
29
- }
30
-
31
- export interface IKontentResponse {}
32
-
33
- export interface IKontentListWithHeaderResponse extends IKontentResponse {
34
- items: any[];
35
- }
36
-
37
- export interface IKontentListResponse extends IKontentResponse {
38
- pagination?: IPagination;
39
- items: any[];
40
- }
41
-
42
- export interface IKontentListAllResponse extends IKontentResponse {
43
- responses: any[];
44
- items: any[];
45
- }
46
-
47
- export interface IListAllQueryConfig<TResponse extends IKontentListResponse, TContract> {
48
- /**
49
- * Number of pages to get. If not set, all available pages are fetched.
50
- */
51
- pages?: number;
52
-
53
- /**
54
- * Delay between each HTTP requests
55
- */
56
- delayBetweenRequests?: number;
57
-
58
- /**
59
- * Executed when a list response is loaded
60
- */
61
- responseFetched?: (
62
- response: IDeliveryNetworkResponse<TResponse, TContract>,
63
- nextPageUrl?: string,
64
- continuationToken?: string
65
- ) => void;
66
- }
67
-
68
- export interface IQueryConfig {
69
- /**
70
- * Indicates if query should use preview mode. Overrides default configuration
71
- */
72
- usePreviewMode?: boolean;
73
-
74
- /**
75
- * Indicates if query should use secured delivery API mode. Overrides default configuration
76
- */
77
- useSecuredMode?: boolean;
78
-
79
- /**
80
- * If the requested content has changed since the last request, the header determines whether
81
- * to wait while fetching content. This can be useful when retrieving changed content
82
- * in reaction to a webhook call. By default, when the header is not set, the API
83
- * serves old content (if cached by the CDN) while it's fetching the new content
84
- * to minimize wait time.
85
- */
86
- waitForLoadingNewContent?: boolean;
87
-
88
- /**
89
- * Extra headers added to request
90
- */
91
- customHeaders?: IHeader[];
92
-
93
- /**
94
- * Cancel token
95
- */
96
- cancelToken?: IHttpCancelRequestToken<any>;
97
- }
98
-
99
- export interface IDeliveryErrorRaw {
100
- message: string;
101
- request_id: string | null;
102
- error_code: number;
103
- specific_code: number;
104
- }
105
-
106
- export class DeliveryError {
107
- public message: string;
108
- public requestId: string | null;
109
- public errorCode: number;
110
- public specificCode: number;
111
-
112
- constructor(data: { message: string; requestId: string | null; errorCode: number; specificCode: number }) {
113
- this.message = data.message;
114
- this.requestId = data.requestId;
115
- this.errorCode = data.errorCode;
116
- this.specificCode = data.specificCode;
117
- }
118
- }
1
+ import { IHeader, IHttpCancelRequestToken, IQueryParameter } from '@kontent-ai/core-sdk';
2
+ import { IDeliveryNetworkResponse } from './base-responses';
3
+ import { IPagination } from './pagination.class';
4
+
5
+ export type LinkedItemsReferenceHandler = 'map' | 'ignore';
6
+
7
+ export interface IProxyUrlData {
8
+ action: string;
9
+ domain: string;
10
+ queryParameters: IQueryParameter[];
11
+ queryString: string;
12
+ queryConfig: IQueryConfig;
13
+ environmentId: string;
14
+ }
15
+
16
+ export interface ISDKInfo {
17
+ /**
18
+ * Name of SDK
19
+ */
20
+ name: string;
21
+ /**
22
+ * Version SDK
23
+ */
24
+ version: string;
25
+ /**
26
+ * Host of SDK
27
+ */
28
+ host: string;
29
+ }
30
+
31
+ export interface IKontentResponse {}
32
+
33
+ export interface IKontentListWithHeaderResponse extends IKontentResponse {
34
+ items: any[];
35
+ }
36
+
37
+ export interface IKontentListResponse extends IKontentResponse {
38
+ pagination?: IPagination;
39
+ items: any[];
40
+ }
41
+
42
+ export interface IKontentListAllResponse extends IKontentResponse {
43
+ responses: any[];
44
+ items: any[];
45
+ }
46
+
47
+ export interface IListAllQueryConfig<TResponse extends IKontentListResponse, TContract> {
48
+ /**
49
+ * Number of pages to get. If not set, all available pages are fetched.
50
+ */
51
+ pages?: number;
52
+
53
+ /**
54
+ * Delay between each HTTP requests
55
+ */
56
+ delayBetweenRequests?: number;
57
+
58
+ /**
59
+ * Executed when a list response is loaded
60
+ */
61
+ responseFetched?: (
62
+ response: IDeliveryNetworkResponse<TResponse, TContract>,
63
+ nextPageUrl?: string,
64
+ continuationToken?: string
65
+ ) => void;
66
+ }
67
+
68
+ export interface IQueryConfig {
69
+ /**
70
+ * Indicates if query should use preview mode. Overrides default configuration
71
+ */
72
+ usePreviewMode?: boolean;
73
+
74
+ /**
75
+ * Indicates if query should use secured delivery API mode. Overrides default configuration
76
+ */
77
+ useSecuredMode?: boolean;
78
+
79
+ /**
80
+ * If the requested content has changed since the last request, the header determines whether
81
+ * to wait while fetching content. This can be useful when retrieving changed content
82
+ * in reaction to a webhook call. By default, when the header is not set, the API
83
+ * serves old content (if cached by the CDN) while it's fetching the new content
84
+ * to minimize wait time.
85
+ */
86
+ waitForLoadingNewContent?: boolean;
87
+
88
+ /**
89
+ * Extra headers added to request
90
+ */
91
+ customHeaders?: IHeader[];
92
+
93
+ /**
94
+ * Cancel token
95
+ */
96
+ cancelToken?: IHttpCancelRequestToken<any>;
97
+ }
98
+
99
+ export interface IDeliveryErrorRaw {
100
+ message: string;
101
+ request_id: string | null;
102
+ error_code: number;
103
+ specific_code: number;
104
+ }
105
+
106
+ export class DeliveryError {
107
+ public message: string;
108
+ public requestId: string | null;
109
+ public errorCode: number;
110
+ public specificCode: number;
111
+
112
+ constructor(data: { message: string; requestId: string | null; errorCode: number; specificCode: number }) {
113
+ this.message = data.message;
114
+ this.requestId = data.requestId;
115
+ this.errorCode = data.errorCode;
116
+ this.specificCode = data.specificCode;
117
+ }
118
+ }