@kontent-ai/delivery-sdk 16.4.3 → 16.4.5

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 (113) hide show
  1. package/.npmignore +15 -15
  2. package/LICENSE.md +9 -9
  3. package/dist/bundles/kontent-delivery.umd.js +5076 -4619
  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 +7015 -5766
  10. package/dist/bundles/stats.min.json +11376 -10250
  11. package/dist/cjs/query/element/element-query.class.js +1 -1
  12. package/dist/cjs/query/element/element-query.class.js.map +1 -1
  13. package/dist/cjs/query/item/single-item-query.class.js +1 -1
  14. package/dist/cjs/query/item/single-item-query.class.js.map +1 -1
  15. package/dist/cjs/query/taxonomy/taxonomy-query.class.js +1 -1
  16. package/dist/cjs/query/taxonomy/taxonomy-query.class.js.map +1 -1
  17. package/dist/cjs/query/type/single-type-query.class.js +1 -1
  18. package/dist/cjs/query/type/single-type-query.class.js.map +1 -1
  19. package/dist/cjs/query/used-in/used-in-query.class.js +1 -1
  20. package/dist/cjs/query/used-in/used-in-query.class.js.map +1 -1
  21. package/dist/cjs/sdk-info.generated.js +1 -1
  22. package/dist/es6/query/element/element-query.class.js +1 -1
  23. package/dist/es6/query/element/element-query.class.js.map +1 -1
  24. package/dist/es6/query/item/single-item-query.class.js +1 -1
  25. package/dist/es6/query/item/single-item-query.class.js.map +1 -1
  26. package/dist/es6/query/taxonomy/taxonomy-query.class.js +1 -1
  27. package/dist/es6/query/taxonomy/taxonomy-query.class.js.map +1 -1
  28. package/dist/es6/query/type/single-type-query.class.js +1 -1
  29. package/dist/es6/query/type/single-type-query.class.js.map +1 -1
  30. package/dist/es6/query/used-in/used-in-query.class.js +1 -1
  31. package/dist/es6/query/used-in/used-in-query.class.js.map +1 -1
  32. package/dist/es6/sdk-info.generated.js +1 -1
  33. package/dist/esnext/query/element/element-query.class.js +1 -1
  34. package/dist/esnext/query/element/element-query.class.js.map +1 -1
  35. package/dist/esnext/query/item/single-item-query.class.js +1 -1
  36. package/dist/esnext/query/item/single-item-query.class.js.map +1 -1
  37. package/dist/esnext/query/taxonomy/taxonomy-query.class.js +1 -1
  38. package/dist/esnext/query/taxonomy/taxonomy-query.class.js.map +1 -1
  39. package/dist/esnext/query/type/single-type-query.class.js +1 -1
  40. package/dist/esnext/query/type/single-type-query.class.js.map +1 -1
  41. package/dist/esnext/query/used-in/used-in-query.class.js +1 -1
  42. package/dist/esnext/query/used-in/used-in-query.class.js.map +1 -1
  43. package/dist/esnext/sdk-info.generated.js +1 -1
  44. package/lib/client/delivery-client.factory.ts +9 -9
  45. package/lib/client/delivery-client.ts +163 -163
  46. package/lib/client/idelivery-client.interface.ts +110 -110
  47. package/lib/client/index.ts +3 -3
  48. package/lib/config/delivery-configs.ts +98 -98
  49. package/lib/config/index.ts +1 -1
  50. package/lib/contracts/contracts.ts +265 -265
  51. package/lib/contracts/index.ts +1 -1
  52. package/lib/elements/element-models.ts +89 -89
  53. package/lib/elements/element-resolver.ts +3 -3
  54. package/lib/elements/element-type.ts +16 -16
  55. package/lib/elements/elements.ts +70 -70
  56. package/lib/elements/index.ts +4 -4
  57. package/lib/images/image-url-transformation-builder.factory.ts +5 -5
  58. package/lib/images/image-url-transformation-builder.ts +181 -181
  59. package/lib/images/image.models.ts +4 -4
  60. package/lib/images/index.ts +3 -3
  61. package/lib/index.ts +12 -12
  62. package/lib/mappers/element.mapper.ts +504 -504
  63. package/lib/mappers/generic-element.mapper.ts +20 -20
  64. package/lib/mappers/index.ts +8 -8
  65. package/lib/mappers/item.mapper.ts +181 -181
  66. package/lib/mappers/language.mapper.ts +24 -24
  67. package/lib/mappers/sync.mapper.ts +32 -32
  68. package/lib/mappers/taxonomy.mapper.ts +77 -77
  69. package/lib/mappers/type.mapper.ts +76 -76
  70. package/lib/mappers/used-in.mapper.ts +20 -20
  71. package/lib/models/common/base-responses.ts +13 -13
  72. package/lib/models/common/common-models.ts +118 -118
  73. package/lib/models/common/filters.ts +280 -280
  74. package/lib/models/common/headers.ts +5 -5
  75. package/lib/models/common/index.ts +7 -7
  76. package/lib/models/common/pagination.class.ts +7 -7
  77. package/lib/models/common/parameters.ts +189 -189
  78. package/lib/models/common/sort-order.ts +1 -1
  79. package/lib/models/content-type-models.ts +42 -42
  80. package/lib/models/element-models.ts +51 -51
  81. package/lib/models/index.ts +9 -9
  82. package/lib/models/item-models.ts +192 -192
  83. package/lib/models/language-models.ts +17 -17
  84. package/lib/models/responses.ts +137 -137
  85. package/lib/models/sync-models.ts +18 -18
  86. package/lib/models/taxonomy-models.ts +25 -25
  87. package/lib/query/common/base-item-listing-query.class.ts +274 -274
  88. package/lib/query/common/base-listing-query.class.ts +95 -95
  89. package/lib/query/common/base-query.class.ts +148 -148
  90. package/lib/query/element/element-query.class.ts +47 -45
  91. package/lib/query/index.ts +13 -13
  92. package/lib/query/item/multiple-items-query.class.ts +183 -183
  93. package/lib/query/item/single-item-query.class.ts +106 -106
  94. package/lib/query/items-feed/items-feed-query.class.ts +191 -191
  95. package/lib/query/language/languages-query.class.ts +91 -91
  96. package/lib/query/sync/initialize-sync-query.class.ts +83 -83
  97. package/lib/query/sync/sync-changes-query.class.ts +56 -56
  98. package/lib/query/taxonomy/taxonomies-query.class.ts +82 -82
  99. package/lib/query/taxonomy/taxonomy-query.class.ts +50 -50
  100. package/lib/query/type/multiple-type-query.class.ts +95 -95
  101. package/lib/query/type/single-type-query.class.ts +45 -45
  102. package/lib/query/used-in/used-in-query.class.ts +128 -126
  103. package/lib/sdk-info.generated.ts +1 -1
  104. package/lib/services/base-delivery-query.service.ts +375 -375
  105. package/lib/services/delivery-query.service.ts +336 -336
  106. package/lib/services/index.ts +2 -2
  107. package/lib/services/mapping.service.ts +223 -223
  108. package/lib/utilities/codename.helper.ts +10 -10
  109. package/lib/utilities/delivery-url.helper.ts +11 -11
  110. package/lib/utilities/enum.helper.ts +38 -38
  111. package/lib/utilities/index.ts +3 -3
  112. package/package.json +96 -96
  113. package/readme.md +531 -531
@@ -1,95 +1,95 @@
1
- import { IDeliveryClientConfig } from '../../config';
2
- import {
3
- continuationTokenHeaderName,
4
- IGroupedNetworkResponse,
5
- IKontentListAllResponse,
6
- IKontentListResponse,
7
- IDeliveryNetworkResponse,
8
- IListAllQueryConfig,
9
- IQueryConfig,
10
- IContentItem,
11
- ClientTypes,
12
- IUsedInItemRecord,
13
- IContentType,
14
- ITaxonomyGroup,
15
- IContentItemDelta,
16
- ILanguage
17
- } from '../../models';
18
- import { QueryService } from '../../services';
19
- import { BaseQuery } from './base-query.class';
20
-
21
- type ListingRecord<TClientTypes extends ClientTypes> =
22
- | IContentItem
23
- | IContentItemDelta
24
- | IUsedInItemRecord<TClientTypes>
25
- | IContentType<TClientTypes['contentTypeCodenames']>
26
- | ILanguage<TClientTypes['languageCodenames']>
27
- | ITaxonomyGroup<TClientTypes['taxonomyCodenames']>;
28
-
29
- export abstract class BaseListingQuery<
30
- TClientTypes extends ClientTypes,
31
- TRecord extends ListingRecord<TClientTypes>,
32
- TResponse extends IKontentListResponse,
33
- TAllResponse extends IKontentListAllResponse,
34
- TQueryConfig extends IQueryConfig,
35
- TContract
36
- > extends BaseQuery<TClientTypes, TResponse, TQueryConfig, TContract> {
37
- constructor(protected config: IDeliveryClientConfig, protected queryService: QueryService<TClientTypes>) {
38
- super(config, queryService);
39
- }
40
-
41
- /**
42
- * Sets continuation token header
43
- */
44
- withContinuationToken(token: string): this {
45
- // remove previous continuation token if there is any
46
- let queryHeaders = this._queryConfig.customHeaders ?? [];
47
- queryHeaders = queryHeaders.filter((m) => m.header !== continuationTokenHeaderName);
48
-
49
- this._queryConfig.customHeaders = queryHeaders;
50
-
51
- this.withHeaders([
52
- {
53
- header: continuationTokenHeaderName,
54
- value: token
55
- }
56
- ]);
57
-
58
- return this;
59
- }
60
-
61
- /**
62
- * Query to get all items. Uses paging data and may execute multiple HTTP requests depending on number of items
63
- */
64
- toAllPromise(
65
- queryAllConfig?: IListAllQueryConfig<TResponse, TContract>
66
- ): Promise<IGroupedNetworkResponse<TAllResponse>> {
67
- return this.queryService.getListAllResponse<TResponse, TAllResponse, TContract>({
68
- page: 1,
69
- listQueryConfig: queryAllConfig,
70
- allResponseFactory: (items, responses) => {
71
- const response = this.allResponseFactory(items, responses);
72
-
73
- return {
74
- data: response,
75
- responses: responses
76
- };
77
- },
78
- getResponse: (nextPageUrl, continuationToken) => {
79
- if (nextPageUrl) {
80
- this.withCustomUrl(nextPageUrl);
81
- }
82
- if (continuationToken) {
83
- this.withContinuationToken(continuationToken);
84
- }
85
-
86
- return this.toPromise();
87
- }
88
- });
89
- }
90
-
91
- protected abstract allResponseFactory(
92
- items: TRecord[],
93
- responses: IDeliveryNetworkResponse<TResponse, TContract>[]
94
- ): TAllResponse;
95
- }
1
+ import { IDeliveryClientConfig } from '../../config';
2
+ import {
3
+ continuationTokenHeaderName,
4
+ IGroupedNetworkResponse,
5
+ IKontentListAllResponse,
6
+ IKontentListResponse,
7
+ IDeliveryNetworkResponse,
8
+ IListAllQueryConfig,
9
+ IQueryConfig,
10
+ IContentItem,
11
+ ClientTypes,
12
+ IUsedInItemRecord,
13
+ IContentType,
14
+ ITaxonomyGroup,
15
+ IContentItemDelta,
16
+ ILanguage
17
+ } from '../../models';
18
+ import { QueryService } from '../../services';
19
+ import { BaseQuery } from './base-query.class';
20
+
21
+ type ListingRecord<TClientTypes extends ClientTypes> =
22
+ | IContentItem
23
+ | IContentItemDelta
24
+ | IUsedInItemRecord<TClientTypes>
25
+ | IContentType<TClientTypes['contentTypeCodenames']>
26
+ | ILanguage<TClientTypes['languageCodenames']>
27
+ | ITaxonomyGroup<TClientTypes['taxonomyCodenames']>;
28
+
29
+ export abstract class BaseListingQuery<
30
+ TClientTypes extends ClientTypes,
31
+ TRecord extends ListingRecord<TClientTypes>,
32
+ TResponse extends IKontentListResponse,
33
+ TAllResponse extends IKontentListAllResponse,
34
+ TQueryConfig extends IQueryConfig,
35
+ TContract
36
+ > extends BaseQuery<TClientTypes, TResponse, TQueryConfig, TContract> {
37
+ constructor(protected config: IDeliveryClientConfig, protected queryService: QueryService<TClientTypes>) {
38
+ super(config, queryService);
39
+ }
40
+
41
+ /**
42
+ * Sets continuation token header
43
+ */
44
+ withContinuationToken(token: string): this {
45
+ // remove previous continuation token if there is any
46
+ let queryHeaders = this._queryConfig.customHeaders ?? [];
47
+ queryHeaders = queryHeaders.filter((m) => m.header !== continuationTokenHeaderName);
48
+
49
+ this._queryConfig.customHeaders = queryHeaders;
50
+
51
+ this.withHeaders([
52
+ {
53
+ header: continuationTokenHeaderName,
54
+ value: token
55
+ }
56
+ ]);
57
+
58
+ return this;
59
+ }
60
+
61
+ /**
62
+ * Query to get all items. Uses paging data and may execute multiple HTTP requests depending on number of items
63
+ */
64
+ toAllPromise(
65
+ queryAllConfig?: IListAllQueryConfig<TResponse, TContract>
66
+ ): Promise<IGroupedNetworkResponse<TAllResponse>> {
67
+ return this.queryService.getListAllResponse<TResponse, TAllResponse, TContract>({
68
+ page: 1,
69
+ listQueryConfig: queryAllConfig,
70
+ allResponseFactory: (items, responses) => {
71
+ const response = this.allResponseFactory(items, responses);
72
+
73
+ return {
74
+ data: response,
75
+ responses: responses
76
+ };
77
+ },
78
+ getResponse: (nextPageUrl, continuationToken) => {
79
+ if (nextPageUrl) {
80
+ this.withCustomUrl(nextPageUrl);
81
+ }
82
+ if (continuationToken) {
83
+ this.withContinuationToken(continuationToken);
84
+ }
85
+
86
+ return this.toPromise();
87
+ }
88
+ });
89
+ }
90
+
91
+ protected abstract allResponseFactory(
92
+ items: TRecord[],
93
+ responses: IDeliveryNetworkResponse<TResponse, TContract>[]
94
+ ): TAllResponse;
95
+ }
@@ -1,148 +1,148 @@
1
- import { IHeader, IQueryParameter } from '@kontent-ai/core-sdk';
2
-
3
- import { IDeliveryClientConfig } from '../../config';
4
- import {
5
- ClientTypes,
6
- Filters,
7
- IDeliveryNetworkResponse,
8
- IKontentResponse,
9
- IQueryConfig,
10
- Parameters
11
- } from '../../models';
12
- import { QueryService } from '../../services';
13
-
14
- export abstract class BaseQuery<
15
- TClientTypes extends ClientTypes,
16
- TResponse extends IKontentResponse,
17
- TQueryConfig extends IQueryConfig,
18
- TContract
19
- > {
20
- protected parameters: IQueryParameter[] = [];
21
- protected customUrl?: string;
22
- protected abstract _queryConfig: TQueryConfig;
23
- constructor(protected config: IDeliveryClientConfig, protected queryService: QueryService<TClientTypes>) {}
24
-
25
- /**
26
- * Gets URL of the query
27
- */
28
- abstract getUrl(): string;
29
-
30
- /**
31
- * Gets promise for query execution
32
- */
33
- abstract toPromise(): Promise<IDeliveryNetworkResponse<TResponse, TContract>>;
34
-
35
- /**
36
- * Maps json data to response
37
- */
38
- abstract map(json: any): TResponse;
39
-
40
- /**
41
- * Adds custom parameter to query
42
- * @param name Name of parameter
43
- * @param value Value of parameter
44
- */
45
- withCustomParameter(name: string, value: string): this {
46
- this.parameters.push(new Parameters.QueryParameter(name, value));
47
- return this;
48
- }
49
-
50
- /**
51
- * Adds parameter to query
52
- * @param name Name of parameter
53
- * @param value Value of parameter
54
- */
55
- withParameter(parameter: IQueryParameter): this {
56
- this.parameters.push(parameter);
57
- return this;
58
- }
59
-
60
- /**
61
- * Adds parameters to query
62
- * @param parameters Array of parameters
63
- */
64
- withParameters(parameters: IQueryParameter[]): this {
65
- this.parameters.push(...parameters);
66
- return this;
67
- }
68
-
69
- /**
70
- * Gets headers used by this query
71
- */
72
- getHeaders(): IHeader[] {
73
- return this.queryService.getHeaders(this._queryConfig, []);
74
- }
75
-
76
- /**
77
- * Sets request headers
78
- */
79
- withHeaders(headers: IHeader[]): this {
80
- const queryHeaders = this._queryConfig.customHeaders ?? [];
81
- queryHeaders.push(...headers);
82
- this._queryConfig.customHeaders = queryHeaders;
83
- return this;
84
- }
85
-
86
- /**
87
- * Sets request header
88
- */
89
- withHeader(header: IHeader): this {
90
- const queryHeaders = this._queryConfig.customHeaders ?? [];
91
- queryHeaders.push(header);
92
- this._queryConfig.customHeaders = queryHeaders;
93
- return this;
94
- }
95
-
96
- /**
97
- * Sets custom URL of request (overrides default URL of the query)
98
- */
99
- withCustomUrl(url: string): this {
100
- this.customUrl = url;
101
- return this;
102
- }
103
-
104
- /**
105
- * Gets all query parameter currently applied to query
106
- */
107
- getParameters(): IQueryParameter[] {
108
- return this.parameters;
109
- }
110
-
111
- /**
112
- * Used to configure query
113
- * @param queryConfig Query configuration
114
- */
115
- queryConfig(queryConfig: TQueryConfig): this {
116
- this._queryConfig = queryConfig;
117
- return this;
118
- }
119
-
120
- protected resolveUrlInternal(action: string): string {
121
- // use custom URL if user specified it
122
- if (this.customUrl) {
123
- return this.customUrl;
124
- }
125
-
126
- // use original url
127
- return this.queryService.getUrl(action, this._queryConfig ?? {}, this.getParameters());
128
- }
129
-
130
- protected processDefaultLanguageParameter(): void {
131
- // add default language if none is specified && default language is specified globally
132
- if (this.config.defaultLanguage) {
133
- const languageParameter = this.getParameters().find((m) =>
134
- m.getParam()?.toLowerCase().includes('language='.toLowerCase())
135
- );
136
- if (!languageParameter) {
137
- // language parameter was not specified in query, use globally defined language
138
- this.parameters.push(new Parameters.LanguageParameter(this.config.defaultLanguage));
139
- }
140
- }
141
- }
142
-
143
- protected processExcludeArchivedItemsParameter(): void {
144
- if (this.config.excludeArchivedItems) {
145
- this.parameters.push(new Filters.NotEqualsFilter('system.workflow_step', 'archived'));
146
- }
147
- }
148
- }
1
+ import { IHeader, IQueryParameter } from '@kontent-ai/core-sdk';
2
+
3
+ import { IDeliveryClientConfig } from '../../config';
4
+ import {
5
+ ClientTypes,
6
+ Filters,
7
+ IDeliveryNetworkResponse,
8
+ IKontentResponse,
9
+ IQueryConfig,
10
+ Parameters
11
+ } from '../../models';
12
+ import { QueryService } from '../../services';
13
+
14
+ export abstract class BaseQuery<
15
+ TClientTypes extends ClientTypes,
16
+ TResponse extends IKontentResponse,
17
+ TQueryConfig extends IQueryConfig,
18
+ TContract
19
+ > {
20
+ protected parameters: IQueryParameter[] = [];
21
+ protected customUrl?: string;
22
+ protected abstract _queryConfig: TQueryConfig;
23
+ constructor(protected config: IDeliveryClientConfig, protected queryService: QueryService<TClientTypes>) {}
24
+
25
+ /**
26
+ * Gets URL of the query
27
+ */
28
+ abstract getUrl(): string;
29
+
30
+ /**
31
+ * Gets promise for query execution
32
+ */
33
+ abstract toPromise(): Promise<IDeliveryNetworkResponse<TResponse, TContract>>;
34
+
35
+ /**
36
+ * Maps json data to response
37
+ */
38
+ abstract map(json: any): TResponse;
39
+
40
+ /**
41
+ * Adds custom parameter to query
42
+ * @param name Name of parameter
43
+ * @param value Value of parameter
44
+ */
45
+ withCustomParameter(name: string, value: string): this {
46
+ this.parameters.push(new Parameters.QueryParameter(name, value));
47
+ return this;
48
+ }
49
+
50
+ /**
51
+ * Adds parameter to query
52
+ * @param name Name of parameter
53
+ * @param value Value of parameter
54
+ */
55
+ withParameter(parameter: IQueryParameter): this {
56
+ this.parameters.push(parameter);
57
+ return this;
58
+ }
59
+
60
+ /**
61
+ * Adds parameters to query
62
+ * @param parameters Array of parameters
63
+ */
64
+ withParameters(parameters: IQueryParameter[]): this {
65
+ this.parameters.push(...parameters);
66
+ return this;
67
+ }
68
+
69
+ /**
70
+ * Gets headers used by this query
71
+ */
72
+ getHeaders(): IHeader[] {
73
+ return this.queryService.getHeaders(this._queryConfig, []);
74
+ }
75
+
76
+ /**
77
+ * Sets request headers
78
+ */
79
+ withHeaders(headers: IHeader[]): this {
80
+ const queryHeaders = this._queryConfig.customHeaders ?? [];
81
+ queryHeaders.push(...headers);
82
+ this._queryConfig.customHeaders = queryHeaders;
83
+ return this;
84
+ }
85
+
86
+ /**
87
+ * Sets request header
88
+ */
89
+ withHeader(header: IHeader): this {
90
+ const queryHeaders = this._queryConfig.customHeaders ?? [];
91
+ queryHeaders.push(header);
92
+ this._queryConfig.customHeaders = queryHeaders;
93
+ return this;
94
+ }
95
+
96
+ /**
97
+ * Sets custom URL of request (overrides default URL of the query)
98
+ */
99
+ withCustomUrl(url: string): this {
100
+ this.customUrl = url;
101
+ return this;
102
+ }
103
+
104
+ /**
105
+ * Gets all query parameter currently applied to query
106
+ */
107
+ getParameters(): IQueryParameter[] {
108
+ return this.parameters;
109
+ }
110
+
111
+ /**
112
+ * Used to configure query
113
+ * @param queryConfig Query configuration
114
+ */
115
+ queryConfig(queryConfig: TQueryConfig): this {
116
+ this._queryConfig = queryConfig;
117
+ return this;
118
+ }
119
+
120
+ protected resolveUrlInternal(action: string): string {
121
+ // use custom URL if user specified it
122
+ if (this.customUrl) {
123
+ return this.customUrl;
124
+ }
125
+
126
+ // use original url
127
+ return this.queryService.getUrl(action, this._queryConfig ?? {}, this.getParameters());
128
+ }
129
+
130
+ protected processDefaultLanguageParameter(): void {
131
+ // add default language if none is specified && default language is specified globally
132
+ if (this.config.defaultLanguage) {
133
+ const languageParameter = this.getParameters().find((m) =>
134
+ m.getParam()?.toLowerCase().includes('language='.toLowerCase())
135
+ );
136
+ if (!languageParameter) {
137
+ // language parameter was not specified in query, use globally defined language
138
+ this.parameters.push(new Parameters.LanguageParameter(this.config.defaultLanguage));
139
+ }
140
+ }
141
+ }
142
+
143
+ protected processExcludeArchivedItemsParameter(): void {
144
+ if (this.config.excludeArchivedItems) {
145
+ this.parameters.push(new Filters.NotEqualsFilter('system.workflow_step', 'archived'));
146
+ }
147
+ }
148
+ }
@@ -1,45 +1,47 @@
1
- import { Contracts } from '../../contracts';
2
- import { IDeliveryClientConfig } from '../../config';
3
- import { Responses, IElementQueryConfig, IDeliveryNetworkResponse, ClientTypes } from '../../models';
4
- import { QueryService } from '../../services';
5
- import { BaseQuery } from '../common/base-query.class';
6
-
7
- export class ElementQuery<TClientTypes extends ClientTypes> extends BaseQuery<
8
- TClientTypes,
9
- Responses.IViewContentTypeElementResponse,
10
- IElementQueryConfig,
11
- Contracts.IViewContentTypeElementContract
12
- > {
13
- protected _queryConfig: IElementQueryConfig = {};
14
-
15
- constructor(
16
- protected config: IDeliveryClientConfig,
17
- protected queryService: QueryService<TClientTypes>,
18
- private typeCodename: string,
19
- private elementCodename: string
20
- ) {
21
- super(config, queryService);
22
-
23
- if (!typeCodename) {
24
- throw Error(`Codename of the type has to be provided`);
25
- }
26
-
27
- if (!elementCodename) {
28
- throw Error(`Codename of the element has to be provided`);
29
- }
30
- }
31
-
32
- toPromise(): Promise<
33
- IDeliveryNetworkResponse<Responses.IViewContentTypeElementResponse, Contracts.IViewContentTypeElementContract>
34
- > {
35
- return this.queryService.getElementAsync(this.getUrl(), this._queryConfig ?? {});
36
- }
37
-
38
- getUrl(): string {
39
- return super.resolveUrlInternal(`/types/${this.typeCodename}/elements/${this.elementCodename}`);
40
- }
41
-
42
- map(json: any): Responses.IViewContentTypeElementResponse {
43
- return this.queryService.mappingService.viewContentTypeElementResponse(json);
44
- }
45
- }
1
+ import { Contracts } from '../../contracts';
2
+ import { IDeliveryClientConfig } from '../../config';
3
+ import { Responses, IElementQueryConfig, IDeliveryNetworkResponse, ClientTypes } from '../../models';
4
+ import { QueryService } from '../../services';
5
+ import { BaseQuery } from '../common/base-query.class';
6
+
7
+ export class ElementQuery<TClientTypes extends ClientTypes> extends BaseQuery<
8
+ TClientTypes,
9
+ Responses.IViewContentTypeElementResponse,
10
+ IElementQueryConfig,
11
+ Contracts.IViewContentTypeElementContract
12
+ > {
13
+ protected _queryConfig: IElementQueryConfig = {};
14
+
15
+ constructor(
16
+ protected config: IDeliveryClientConfig,
17
+ protected queryService: QueryService<TClientTypes>,
18
+ private typeCodename: string,
19
+ private elementCodename: string
20
+ ) {
21
+ super(config, queryService);
22
+
23
+ if (!typeCodename) {
24
+ throw Error(`Codename of the type has to be provided`);
25
+ }
26
+
27
+ if (!elementCodename) {
28
+ throw Error(`Codename of the element has to be provided`);
29
+ }
30
+ }
31
+
32
+ toPromise(): Promise<
33
+ IDeliveryNetworkResponse<Responses.IViewContentTypeElementResponse, Contracts.IViewContentTypeElementContract>
34
+ > {
35
+ return this.queryService.getElementAsync(this.getUrl(), this._queryConfig ?? {});
36
+ }
37
+
38
+ getUrl(): string {
39
+ return super.resolveUrlInternal(
40
+ `/types/${encodeURIComponent(this.typeCodename)}/elements/${encodeURIComponent(this.elementCodename)}`
41
+ );
42
+ }
43
+
44
+ map(json: any): Responses.IViewContentTypeElementResponse {
45
+ return this.queryService.mappingService.viewContentTypeElementResponse(json);
46
+ }
47
+ }
@@ -1,13 +1,13 @@
1
- export * from './common/base-query.class';
2
- export * from './element/element-query.class';
3
- export * from './item/multiple-items-query.class';
4
- export * from './item/single-item-query.class';
5
- export * from './taxonomy/taxonomies-query.class';
6
- export * from './taxonomy/taxonomy-query.class';
7
- export * from './type/multiple-type-query.class';
8
- export * from './type/single-type-query.class';
9
- export * from './items-feed/items-feed-query.class';
10
- export * from './language/languages-query.class';
11
- export * from './sync/initialize-sync-query.class';
12
- export * from './sync/sync-changes-query.class';
13
- export * from './used-in/used-in-query.class';
1
+ export * from './common/base-query.class';
2
+ export * from './element/element-query.class';
3
+ export * from './item/multiple-items-query.class';
4
+ export * from './item/single-item-query.class';
5
+ export * from './taxonomy/taxonomies-query.class';
6
+ export * from './taxonomy/taxonomy-query.class';
7
+ export * from './type/multiple-type-query.class';
8
+ export * from './type/single-type-query.class';
9
+ export * from './items-feed/items-feed-query.class';
10
+ export * from './language/languages-query.class';
11
+ export * from './sync/initialize-sync-query.class';
12
+ export * from './sync/sync-changes-query.class';
13
+ export * from './used-in/used-in-query.class';