@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,83 +1,83 @@
1
- import { Contracts } from '../../contracts';
2
- import { IDeliveryClientConfig } from '../../config';
3
- import {
4
- ClientTypes,
5
- Filters,
6
- IDeliveryNetworkResponse,
7
- ILanguagesQueryConfig,
8
- ISyncInitQueryConfig,
9
- Parameters,
10
- Responses
11
- } from '../../models';
12
- import { QueryService } from '../../services';
13
- import { BaseQuery } from '../common/base-query.class';
14
-
15
- export class InitializeSyncQuery<TClientTypes extends ClientTypes> extends BaseQuery<
16
- TClientTypes,
17
- Responses.IInitializeSyncResponse,
18
- ISyncInitQueryConfig,
19
- Contracts.IInitializeSyncContract
20
- > {
21
- protected readonly endpoint: string = 'sync/init';
22
-
23
- protected _queryConfig: ILanguagesQueryConfig = {};
24
-
25
- constructor(protected config: IDeliveryClientConfig, protected queryService: QueryService<TClientTypes>) {
26
- super(config, queryService);
27
- }
28
-
29
- /**
30
- * Gets only item of given type
31
- * @param type Codename of type to get
32
- */
33
- type(type: string): this {
34
- this.parameters.push(new Filters.TypeFilter(type));
35
- return this;
36
- }
37
-
38
- /**
39
- * Gets only item from given collection
40
- * @param collection Codename of collection to get
41
- */
42
- collection(collection: string): this {
43
- this.parameters.push(new Filters.CollectionFilter(collection));
44
- return this;
45
- }
46
-
47
- /**
48
- * Language codename
49
- * @param languageCodename Codename of the language
50
- */
51
- languageParameter(languageCodename: string): this {
52
- this.parameters.push(new Parameters.LanguageParameter(languageCodename));
53
- return this;
54
- }
55
-
56
- toPromise(): Promise<
57
- IDeliveryNetworkResponse<Responses.IInitializeSyncResponse, Contracts.IInitializeSyncContract>
58
- > {
59
- console.warn(
60
- `Sync Api v1 is deprecated. Please use the new Sync Api v2. https://kontent.ai/learn/docs/apis/openapi/sync-api-v2/`
61
- );
62
- return this.queryService.initializeSync(this.getUrl(), this._queryConfig ?? {});
63
- }
64
-
65
- getUrl(): string {
66
- const action = '/' + this.endpoint;
67
-
68
- return super.resolveUrlInternal(action);
69
- }
70
-
71
- /**
72
- * Used to configure query
73
- * @param queryConfig Query configuration
74
- */
75
- queryConfig(queryConfig: ISyncInitQueryConfig): this {
76
- this._queryConfig = queryConfig;
77
- return this;
78
- }
79
-
80
- map(json: any): Responses.IInitializeSyncResponse {
81
- return this.queryService.mappingService.initializeContentSync(json);
82
- }
83
- }
1
+ import { Contracts } from '../../contracts';
2
+ import { IDeliveryClientConfig } from '../../config';
3
+ import {
4
+ ClientTypes,
5
+ Filters,
6
+ IDeliveryNetworkResponse,
7
+ ILanguagesQueryConfig,
8
+ ISyncInitQueryConfig,
9
+ Parameters,
10
+ Responses
11
+ } from '../../models';
12
+ import { QueryService } from '../../services';
13
+ import { BaseQuery } from '../common/base-query.class';
14
+
15
+ export class InitializeSyncQuery<TClientTypes extends ClientTypes> extends BaseQuery<
16
+ TClientTypes,
17
+ Responses.IInitializeSyncResponse,
18
+ ISyncInitQueryConfig,
19
+ Contracts.IInitializeSyncContract
20
+ > {
21
+ protected readonly endpoint: string = 'sync/init';
22
+
23
+ protected _queryConfig: ILanguagesQueryConfig = {};
24
+
25
+ constructor(protected config: IDeliveryClientConfig, protected queryService: QueryService<TClientTypes>) {
26
+ super(config, queryService);
27
+ }
28
+
29
+ /**
30
+ * Gets only item of given type
31
+ * @param type Codename of type to get
32
+ */
33
+ type(type: string): this {
34
+ this.parameters.push(new Filters.TypeFilter(type));
35
+ return this;
36
+ }
37
+
38
+ /**
39
+ * Gets only item from given collection
40
+ * @param collection Codename of collection to get
41
+ */
42
+ collection(collection: string): this {
43
+ this.parameters.push(new Filters.CollectionFilter(collection));
44
+ return this;
45
+ }
46
+
47
+ /**
48
+ * Language codename
49
+ * @param languageCodename Codename of the language
50
+ */
51
+ languageParameter(languageCodename: string): this {
52
+ this.parameters.push(new Parameters.LanguageParameter(languageCodename));
53
+ return this;
54
+ }
55
+
56
+ toPromise(): Promise<
57
+ IDeliveryNetworkResponse<Responses.IInitializeSyncResponse, Contracts.IInitializeSyncContract>
58
+ > {
59
+ console.warn(
60
+ `Sync Api v1 is deprecated. Please use the new Sync Api v2. https://kontent.ai/learn/docs/apis/openapi/sync-api-v2/`
61
+ );
62
+ return this.queryService.initializeSync(this.getUrl(), this._queryConfig ?? {});
63
+ }
64
+
65
+ getUrl(): string {
66
+ const action = '/' + this.endpoint;
67
+
68
+ return super.resolveUrlInternal(action);
69
+ }
70
+
71
+ /**
72
+ * Used to configure query
73
+ * @param queryConfig Query configuration
74
+ */
75
+ queryConfig(queryConfig: ISyncInitQueryConfig): this {
76
+ this._queryConfig = queryConfig;
77
+ return this;
78
+ }
79
+
80
+ map(json: any): Responses.IInitializeSyncResponse {
81
+ return this.queryService.mappingService.initializeContentSync(json);
82
+ }
83
+ }
@@ -1,56 +1,56 @@
1
- import { Contracts } from '../../contracts';
2
- import { IDeliveryClientConfig } from '../../config';
3
- import { IItemQueryConfig, IDeliveryNetworkResponse, Responses, ClientTypes, IContentItemDelta } from '../../models';
4
- import { QueryService } from '../../services';
5
- import { BaseListingQuery } from '../common/base-listing-query.class';
6
-
7
- export class SyncChangesQuery<TClientTypes extends ClientTypes> extends BaseListingQuery<
8
- TClientTypes,
9
- IContentItemDelta,
10
- Responses.ISyncChangesResponse,
11
- Responses.ISyncChangesAllResponse,
12
- IItemQueryConfig,
13
- Contracts.ISyncChangesContract
14
- > {
15
- protected _queryConfig: IItemQueryConfig = {};
16
-
17
- private readonly action: string = '/sync';
18
-
19
- constructor(protected config: IDeliveryClientConfig, protected queryService: QueryService<TClientTypes>) {
20
- super(config, queryService);
21
- }
22
-
23
- toPromise(): Promise<IDeliveryNetworkResponse<Responses.ISyncChangesResponse, Contracts.ISyncChangesContract>> {
24
- console.warn(
25
- `Sync Api v1 is deprecated. Please use the new Sync Api v2. https://kontent.ai/learn/docs/apis/openapi/sync-api-v2/`
26
- );
27
- return this.queryService.syncChanges(this.getUrl(), this._queryConfig ?? {});
28
- }
29
-
30
- getUrl(): string {
31
- return super.resolveUrlInternal(this.action);
32
- }
33
-
34
- /**
35
- * Used to configure query
36
- * @param queryConfig Query configuration
37
- */
38
- queryConfig(queryConfig: IItemQueryConfig): this {
39
- this._queryConfig = queryConfig;
40
- return this;
41
- }
42
-
43
- map(json: any): Responses.ISyncChangesResponse {
44
- return this.queryService.mappingService.syncChanges(json);
45
- }
46
-
47
- protected allResponseFactory(
48
- items: IContentItemDelta[],
49
- responses: IDeliveryNetworkResponse<Responses.ISyncChangesResponse, Contracts.ISyncChangesContract>[]
50
- ): Responses.ISyncChangesAllResponse {
51
- return {
52
- items: items,
53
- responses: responses
54
- };
55
- }
56
- }
1
+ import { Contracts } from '../../contracts';
2
+ import { IDeliveryClientConfig } from '../../config';
3
+ import { IItemQueryConfig, IDeliveryNetworkResponse, Responses, ClientTypes, IContentItemDelta } from '../../models';
4
+ import { QueryService } from '../../services';
5
+ import { BaseListingQuery } from '../common/base-listing-query.class';
6
+
7
+ export class SyncChangesQuery<TClientTypes extends ClientTypes> extends BaseListingQuery<
8
+ TClientTypes,
9
+ IContentItemDelta,
10
+ Responses.ISyncChangesResponse,
11
+ Responses.ISyncChangesAllResponse,
12
+ IItemQueryConfig,
13
+ Contracts.ISyncChangesContract
14
+ > {
15
+ protected _queryConfig: IItemQueryConfig = {};
16
+
17
+ private readonly action: string = '/sync';
18
+
19
+ constructor(protected config: IDeliveryClientConfig, protected queryService: QueryService<TClientTypes>) {
20
+ super(config, queryService);
21
+ }
22
+
23
+ toPromise(): Promise<IDeliveryNetworkResponse<Responses.ISyncChangesResponse, Contracts.ISyncChangesContract>> {
24
+ console.warn(
25
+ `Sync Api v1 is deprecated. Please use the new Sync Api v2. https://kontent.ai/learn/docs/apis/openapi/sync-api-v2/`
26
+ );
27
+ return this.queryService.syncChanges(this.getUrl(), this._queryConfig ?? {});
28
+ }
29
+
30
+ getUrl(): string {
31
+ return super.resolveUrlInternal(this.action);
32
+ }
33
+
34
+ /**
35
+ * Used to configure query
36
+ * @param queryConfig Query configuration
37
+ */
38
+ queryConfig(queryConfig: IItemQueryConfig): this {
39
+ this._queryConfig = queryConfig;
40
+ return this;
41
+ }
42
+
43
+ map(json: any): Responses.ISyncChangesResponse {
44
+ return this.queryService.mappingService.syncChanges(json);
45
+ }
46
+
47
+ protected allResponseFactory(
48
+ items: IContentItemDelta[],
49
+ responses: IDeliveryNetworkResponse<Responses.ISyncChangesResponse, Contracts.ISyncChangesContract>[]
50
+ ): Responses.ISyncChangesAllResponse {
51
+ return {
52
+ items: items,
53
+ responses: responses
54
+ };
55
+ }
56
+ }
@@ -1,82 +1,82 @@
1
- import { Contracts } from '../../contracts';
2
- import { IDeliveryClientConfig } from '../../config';
3
- import {
4
- ClientTypes,
5
- IDeliveryNetworkResponse,
6
- ITaxonomyGroup,
7
- ITaxonomyQueryConfig,
8
- Parameters,
9
- Responses
10
- } from '../../models';
11
- import { QueryService } from '../../services';
12
- import { BaseListingQuery } from '../common/base-listing-query.class';
13
-
14
- export class TaxonomiesQuery<TClientTypes extends ClientTypes> extends BaseListingQuery<
15
- TClientTypes,
16
- ITaxonomyGroup<TClientTypes['taxonomyCodenames']>,
17
- Responses.IListTaxonomiesResponse<TClientTypes['taxonomyCodenames']>,
18
- Responses.IListTaxonomiesAllResponse<TClientTypes['taxonomyCodenames']>,
19
- ITaxonomyQueryConfig,
20
- Contracts.IListTaxonomyGroupsContract
21
- > {
22
- /**
23
- * Taxonomies endpoint URL action
24
- */
25
- protected readonly taxonomiesEndpoint: string = 'taxonomies';
26
-
27
- protected _queryConfig: ITaxonomyQueryConfig = {};
28
-
29
- constructor(protected config: IDeliveryClientConfig, protected queryService: QueryService<TClientTypes>) {
30
- super(config, queryService);
31
- }
32
-
33
- /**
34
- * Limits the number of taxonomies returned by query
35
- * @param limit Number of taxonomies to load
36
- */
37
- limitParameter(limit: number): this {
38
- this.parameters.push(new Parameters.LimitParameter(limit));
39
- return this;
40
- }
41
-
42
- /**
43
- * Skips the selected number of taxonomies
44
- * @param skip Number of taxonomies to skip
45
- */
46
- skipParameter(skip: number): this {
47
- this.parameters.push(new Parameters.SkipParameter(skip));
48
- return this;
49
- }
50
-
51
- toPromise(): Promise<
52
- IDeliveryNetworkResponse<
53
- Responses.IListTaxonomiesResponse<TClientTypes['taxonomyCodenames']>,
54
- Contracts.IListTaxonomyGroupsContract
55
- >
56
- > {
57
- return this.queryService.getTaxonomies(this.getUrl(), this._queryConfig ?? {});
58
- }
59
-
60
- getUrl(): string {
61
- const action = '/' + this.taxonomiesEndpoint;
62
-
63
- return super.resolveUrlInternal(action);
64
- }
65
-
66
- map(json: any): Responses.IListTaxonomiesResponse<TClientTypes['taxonomyCodenames']> {
67
- return this.queryService.mappingService.listTaxonomiesResponse(json);
68
- }
69
-
70
- protected allResponseFactory(
71
- items: ITaxonomyGroup<TClientTypes['taxonomyCodenames']>[],
72
- responses: IDeliveryNetworkResponse<
73
- Responses.IListTaxonomiesResponse<TClientTypes['taxonomyCodenames']>,
74
- Contracts.IListTaxonomyGroupsContract
75
- >[]
76
- ): Responses.IListTaxonomiesAllResponse<TClientTypes['taxonomyCodenames']> {
77
- return {
78
- items: items,
79
- responses: responses
80
- };
81
- }
82
- }
1
+ import { Contracts } from '../../contracts';
2
+ import { IDeliveryClientConfig } from '../../config';
3
+ import {
4
+ ClientTypes,
5
+ IDeliveryNetworkResponse,
6
+ ITaxonomyGroup,
7
+ ITaxonomyQueryConfig,
8
+ Parameters,
9
+ Responses
10
+ } from '../../models';
11
+ import { QueryService } from '../../services';
12
+ import { BaseListingQuery } from '../common/base-listing-query.class';
13
+
14
+ export class TaxonomiesQuery<TClientTypes extends ClientTypes> extends BaseListingQuery<
15
+ TClientTypes,
16
+ ITaxonomyGroup<TClientTypes['taxonomyCodenames']>,
17
+ Responses.IListTaxonomiesResponse<TClientTypes['taxonomyCodenames']>,
18
+ Responses.IListTaxonomiesAllResponse<TClientTypes['taxonomyCodenames']>,
19
+ ITaxonomyQueryConfig,
20
+ Contracts.IListTaxonomyGroupsContract
21
+ > {
22
+ /**
23
+ * Taxonomies endpoint URL action
24
+ */
25
+ protected readonly taxonomiesEndpoint: string = 'taxonomies';
26
+
27
+ protected _queryConfig: ITaxonomyQueryConfig = {};
28
+
29
+ constructor(protected config: IDeliveryClientConfig, protected queryService: QueryService<TClientTypes>) {
30
+ super(config, queryService);
31
+ }
32
+
33
+ /**
34
+ * Limits the number of taxonomies returned by query
35
+ * @param limit Number of taxonomies to load
36
+ */
37
+ limitParameter(limit: number): this {
38
+ this.parameters.push(new Parameters.LimitParameter(limit));
39
+ return this;
40
+ }
41
+
42
+ /**
43
+ * Skips the selected number of taxonomies
44
+ * @param skip Number of taxonomies to skip
45
+ */
46
+ skipParameter(skip: number): this {
47
+ this.parameters.push(new Parameters.SkipParameter(skip));
48
+ return this;
49
+ }
50
+
51
+ toPromise(): Promise<
52
+ IDeliveryNetworkResponse<
53
+ Responses.IListTaxonomiesResponse<TClientTypes['taxonomyCodenames']>,
54
+ Contracts.IListTaxonomyGroupsContract
55
+ >
56
+ > {
57
+ return this.queryService.getTaxonomies(this.getUrl(), this._queryConfig ?? {});
58
+ }
59
+
60
+ getUrl(): string {
61
+ const action = '/' + this.taxonomiesEndpoint;
62
+
63
+ return super.resolveUrlInternal(action);
64
+ }
65
+
66
+ map(json: any): Responses.IListTaxonomiesResponse<TClientTypes['taxonomyCodenames']> {
67
+ return this.queryService.mappingService.listTaxonomiesResponse(json);
68
+ }
69
+
70
+ protected allResponseFactory(
71
+ items: ITaxonomyGroup<TClientTypes['taxonomyCodenames']>[],
72
+ responses: IDeliveryNetworkResponse<
73
+ Responses.IListTaxonomiesResponse<TClientTypes['taxonomyCodenames']>,
74
+ Contracts.IListTaxonomyGroupsContract
75
+ >[]
76
+ ): Responses.IListTaxonomiesAllResponse<TClientTypes['taxonomyCodenames']> {
77
+ return {
78
+ items: items,
79
+ responses: responses
80
+ };
81
+ }
82
+ }
@@ -1,50 +1,50 @@
1
- import { Contracts } from '../../contracts';
2
- import { IDeliveryClientConfig } from '../../config';
3
- import { ClientTypes, IDeliveryNetworkResponse, ITaxonomyQueryConfig, Responses } from '../../models';
4
- import { QueryService } from '../../services';
5
- import { BaseQuery } from '../common/base-query.class';
6
-
7
- export class TaxonomyQuery<TClientTypes extends ClientTypes> extends BaseQuery<
8
- TClientTypes,
9
- Responses.IViewTaxonomyResponse<TClientTypes['taxonomyCodenames']>,
10
- ITaxonomyQueryConfig,
11
- Contracts.IViewTaxonomyGroupContract
12
- > {
13
- /**
14
- * Taxonomies endpoint URL action
15
- */
16
- protected readonly taxonomiesEndpoint: string = 'taxonomies';
17
-
18
- protected _queryConfig: ITaxonomyQueryConfig = {};
19
-
20
- constructor(
21
- protected config: IDeliveryClientConfig,
22
- protected queryService: QueryService<TClientTypes>,
23
- private taxonomyCodename: string
24
- ) {
25
- super(config, queryService);
26
-
27
- if (!taxonomyCodename) {
28
- throw Error(`Cannot create taxonomy query without codename of the taxonomy`);
29
- }
30
- }
31
-
32
- toPromise(): Promise<
33
- IDeliveryNetworkResponse<
34
- Responses.IViewTaxonomyResponse<TClientTypes['taxonomyCodenames']>,
35
- Contracts.IViewTaxonomyGroupContract
36
- >
37
- > {
38
- return this.queryService.getTaxonomy(this.getUrl(), this._queryConfig ?? {});
39
- }
40
-
41
- getUrl(): string {
42
- const action = '/' + this.taxonomiesEndpoint + '/' + this.taxonomyCodename;
43
-
44
- return super.resolveUrlInternal(action);
45
- }
46
-
47
- map(json: any): Responses.IViewTaxonomyResponse<TClientTypes['taxonomyCodenames']> {
48
- return this.queryService.mappingService.viewTaxonomyResponse(json);
49
- }
50
- }
1
+ import { Contracts } from '../../contracts';
2
+ import { IDeliveryClientConfig } from '../../config';
3
+ import { ClientTypes, IDeliveryNetworkResponse, ITaxonomyQueryConfig, Responses } from '../../models';
4
+ import { QueryService } from '../../services';
5
+ import { BaseQuery } from '../common/base-query.class';
6
+
7
+ export class TaxonomyQuery<TClientTypes extends ClientTypes> extends BaseQuery<
8
+ TClientTypes,
9
+ Responses.IViewTaxonomyResponse<TClientTypes['taxonomyCodenames']>,
10
+ ITaxonomyQueryConfig,
11
+ Contracts.IViewTaxonomyGroupContract
12
+ > {
13
+ /**
14
+ * Taxonomies endpoint URL action
15
+ */
16
+ protected readonly taxonomiesEndpoint: string = 'taxonomies';
17
+
18
+ protected _queryConfig: ITaxonomyQueryConfig = {};
19
+
20
+ constructor(
21
+ protected config: IDeliveryClientConfig,
22
+ protected queryService: QueryService<TClientTypes>,
23
+ private taxonomyCodename: string
24
+ ) {
25
+ super(config, queryService);
26
+
27
+ if (!taxonomyCodename) {
28
+ throw Error(`Cannot create taxonomy query without codename of the taxonomy`);
29
+ }
30
+ }
31
+
32
+ toPromise(): Promise<
33
+ IDeliveryNetworkResponse<
34
+ Responses.IViewTaxonomyResponse<TClientTypes['taxonomyCodenames']>,
35
+ Contracts.IViewTaxonomyGroupContract
36
+ >
37
+ > {
38
+ return this.queryService.getTaxonomy(this.getUrl(), this._queryConfig ?? {});
39
+ }
40
+
41
+ getUrl(): string {
42
+ const action = '/' + this.taxonomiesEndpoint + '/' + this.taxonomyCodename;
43
+
44
+ return super.resolveUrlInternal(action);
45
+ }
46
+
47
+ map(json: any): Responses.IViewTaxonomyResponse<TClientTypes['taxonomyCodenames']> {
48
+ return this.queryService.mappingService.viewTaxonomyResponse(json);
49
+ }
50
+ }