@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.
- package/.npmignore +15 -15
- package/LICENSE.md +9 -9
- package/dist/bundles/kontent-delivery.umd.js +5076 -4619
- package/dist/bundles/kontent-delivery.umd.js.map +1 -1
- package/dist/bundles/kontent-delivery.umd.min.js +1 -1
- package/dist/bundles/kontent-delivery.umd.min.js.map +1 -1
- package/dist/bundles/report.json +1 -1
- package/dist/bundles/report.min.json +1 -1
- package/dist/bundles/stats.json +7015 -5766
- package/dist/bundles/stats.min.json +11376 -10250
- package/dist/cjs/query/element/element-query.class.js +1 -1
- package/dist/cjs/query/element/element-query.class.js.map +1 -1
- package/dist/cjs/query/item/single-item-query.class.js +1 -1
- package/dist/cjs/query/item/single-item-query.class.js.map +1 -1
- package/dist/cjs/query/taxonomy/taxonomy-query.class.js +1 -1
- package/dist/cjs/query/taxonomy/taxonomy-query.class.js.map +1 -1
- package/dist/cjs/query/type/single-type-query.class.js +1 -1
- package/dist/cjs/query/type/single-type-query.class.js.map +1 -1
- package/dist/cjs/query/used-in/used-in-query.class.js +1 -1
- package/dist/cjs/query/used-in/used-in-query.class.js.map +1 -1
- package/dist/cjs/sdk-info.generated.js +1 -1
- package/dist/es6/query/element/element-query.class.js +1 -1
- package/dist/es6/query/element/element-query.class.js.map +1 -1
- package/dist/es6/query/item/single-item-query.class.js +1 -1
- package/dist/es6/query/item/single-item-query.class.js.map +1 -1
- package/dist/es6/query/taxonomy/taxonomy-query.class.js +1 -1
- package/dist/es6/query/taxonomy/taxonomy-query.class.js.map +1 -1
- package/dist/es6/query/type/single-type-query.class.js +1 -1
- package/dist/es6/query/type/single-type-query.class.js.map +1 -1
- package/dist/es6/query/used-in/used-in-query.class.js +1 -1
- package/dist/es6/query/used-in/used-in-query.class.js.map +1 -1
- package/dist/es6/sdk-info.generated.js +1 -1
- package/dist/esnext/query/element/element-query.class.js +1 -1
- package/dist/esnext/query/element/element-query.class.js.map +1 -1
- package/dist/esnext/query/item/single-item-query.class.js +1 -1
- package/dist/esnext/query/item/single-item-query.class.js.map +1 -1
- package/dist/esnext/query/taxonomy/taxonomy-query.class.js +1 -1
- package/dist/esnext/query/taxonomy/taxonomy-query.class.js.map +1 -1
- package/dist/esnext/query/type/single-type-query.class.js +1 -1
- package/dist/esnext/query/type/single-type-query.class.js.map +1 -1
- package/dist/esnext/query/used-in/used-in-query.class.js +1 -1
- package/dist/esnext/query/used-in/used-in-query.class.js.map +1 -1
- package/dist/esnext/sdk-info.generated.js +1 -1
- package/lib/client/delivery-client.factory.ts +9 -9
- package/lib/client/delivery-client.ts +163 -163
- package/lib/client/idelivery-client.interface.ts +110 -110
- package/lib/client/index.ts +3 -3
- package/lib/config/delivery-configs.ts +98 -98
- package/lib/config/index.ts +1 -1
- package/lib/contracts/contracts.ts +265 -265
- package/lib/contracts/index.ts +1 -1
- package/lib/elements/element-models.ts +89 -89
- package/lib/elements/element-resolver.ts +3 -3
- package/lib/elements/element-type.ts +16 -16
- package/lib/elements/elements.ts +70 -70
- package/lib/elements/index.ts +4 -4
- package/lib/images/image-url-transformation-builder.factory.ts +5 -5
- package/lib/images/image-url-transformation-builder.ts +181 -181
- package/lib/images/image.models.ts +4 -4
- package/lib/images/index.ts +3 -3
- package/lib/index.ts +12 -12
- package/lib/mappers/element.mapper.ts +504 -504
- package/lib/mappers/generic-element.mapper.ts +20 -20
- package/lib/mappers/index.ts +8 -8
- package/lib/mappers/item.mapper.ts +181 -181
- package/lib/mappers/language.mapper.ts +24 -24
- package/lib/mappers/sync.mapper.ts +32 -32
- package/lib/mappers/taxonomy.mapper.ts +77 -77
- package/lib/mappers/type.mapper.ts +76 -76
- package/lib/mappers/used-in.mapper.ts +20 -20
- package/lib/models/common/base-responses.ts +13 -13
- package/lib/models/common/common-models.ts +118 -118
- package/lib/models/common/filters.ts +280 -280
- package/lib/models/common/headers.ts +5 -5
- package/lib/models/common/index.ts +7 -7
- package/lib/models/common/pagination.class.ts +7 -7
- package/lib/models/common/parameters.ts +189 -189
- package/lib/models/common/sort-order.ts +1 -1
- package/lib/models/content-type-models.ts +42 -42
- package/lib/models/element-models.ts +51 -51
- package/lib/models/index.ts +9 -9
- package/lib/models/item-models.ts +192 -192
- package/lib/models/language-models.ts +17 -17
- package/lib/models/responses.ts +137 -137
- package/lib/models/sync-models.ts +18 -18
- package/lib/models/taxonomy-models.ts +25 -25
- package/lib/query/common/base-item-listing-query.class.ts +274 -274
- package/lib/query/common/base-listing-query.class.ts +95 -95
- package/lib/query/common/base-query.class.ts +148 -148
- package/lib/query/element/element-query.class.ts +47 -45
- package/lib/query/index.ts +13 -13
- package/lib/query/item/multiple-items-query.class.ts +183 -183
- package/lib/query/item/single-item-query.class.ts +106 -106
- package/lib/query/items-feed/items-feed-query.class.ts +191 -191
- package/lib/query/language/languages-query.class.ts +91 -91
- package/lib/query/sync/initialize-sync-query.class.ts +83 -83
- package/lib/query/sync/sync-changes-query.class.ts +56 -56
- package/lib/query/taxonomy/taxonomies-query.class.ts +82 -82
- package/lib/query/taxonomy/taxonomy-query.class.ts +50 -50
- package/lib/query/type/multiple-type-query.class.ts +95 -95
- package/lib/query/type/single-type-query.class.ts +45 -45
- package/lib/query/used-in/used-in-query.class.ts +128 -126
- package/lib/sdk-info.generated.ts +1 -1
- package/lib/services/base-delivery-query.service.ts +375 -375
- package/lib/services/delivery-query.service.ts +336 -336
- package/lib/services/index.ts +2 -2
- package/lib/services/mapping.service.ts +223 -223
- package/lib/utilities/codename.helper.ts +10 -10
- package/lib/utilities/delivery-url.helper.ts +11 -11
- package/lib/utilities/enum.helper.ts +38 -38
- package/lib/utilities/index.ts +3 -3
- package/package.json +96 -96
- package/readme.md +531 -531
|
@@ -1,95 +1,95 @@
|
|
|
1
|
-
import { Contracts } from '../../contracts';
|
|
2
|
-
import { IDeliveryClientConfig } from '../../config';
|
|
3
|
-
import {
|
|
4
|
-
ClientTypes,
|
|
5
|
-
IContentType,
|
|
6
|
-
IContentTypeQueryConfig,
|
|
7
|
-
IDeliveryNetworkResponse,
|
|
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 MultipleTypeQuery<TClientTypes extends ClientTypes> extends BaseListingQuery<
|
|
15
|
-
TClientTypes,
|
|
16
|
-
IContentType<TClientTypes['contentTypeCodenames']>,
|
|
17
|
-
Responses.IListContentTypesResponse<TClientTypes['contentTypeCodenames']>,
|
|
18
|
-
Responses.IListContentTypesAllResponse<TClientTypes['contentTypeCodenames']>,
|
|
19
|
-
IContentTypeQueryConfig,
|
|
20
|
-
Contracts.IListContentTypeContract
|
|
21
|
-
> {
|
|
22
|
-
protected _queryConfig: IContentTypeQueryConfig = {};
|
|
23
|
-
|
|
24
|
-
constructor(protected config: IDeliveryClientConfig, protected queryService: QueryService<TClientTypes>) {
|
|
25
|
-
super(config, queryService);
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
/**
|
|
29
|
-
* Used to limit the number of elements returned by query.
|
|
30
|
-
* @param elementCodenames Array of element codenames to fetch
|
|
31
|
-
*/
|
|
32
|
-
elementsParameter(elementCodenames: TClientTypes['elementCodenames'][]): this {
|
|
33
|
-
this.parameters.push(new Parameters.ElementsParameter(elementCodenames));
|
|
34
|
-
return this;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
/**
|
|
38
|
-
* Used to exclude elements returned by query.
|
|
39
|
-
* @param elementCodenames Array of element codenames to exclude
|
|
40
|
-
*/
|
|
41
|
-
excludeElementsParameter(elementCodenames: TClientTypes['elementCodenames'][]): this {
|
|
42
|
-
this.parameters.push(new Parameters.ExcludeElementsParameter(elementCodenames));
|
|
43
|
-
return this;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
/**
|
|
47
|
-
* Limits the number of taxonomies returned by query
|
|
48
|
-
* @param limit Number of taxonomies to load
|
|
49
|
-
*/
|
|
50
|
-
limitParameter(limit: number): this {
|
|
51
|
-
this.parameters.push(new Parameters.LimitParameter(limit));
|
|
52
|
-
return this;
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
/**
|
|
56
|
-
* Skips the selected number of taxonomies
|
|
57
|
-
* @param skip Number of taxonomies to skip
|
|
58
|
-
*/
|
|
59
|
-
skipParameter(skip: number): this {
|
|
60
|
-
this.parameters.push(new Parameters.SkipParameter(skip));
|
|
61
|
-
return this;
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
toPromise(): Promise<
|
|
65
|
-
IDeliveryNetworkResponse<
|
|
66
|
-
Responses.IListContentTypesResponse<TClientTypes['contentTypeCodenames']>,
|
|
67
|
-
Contracts.IListContentTypeContract
|
|
68
|
-
>
|
|
69
|
-
> {
|
|
70
|
-
return this.queryService.getMultipleTypes(this.getUrl(), this._queryConfig ?? {});
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
getUrl(): string {
|
|
74
|
-
const action = '/types';
|
|
75
|
-
|
|
76
|
-
return super.resolveUrlInternal(action);
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
map(json: any): Responses.IListContentTypesResponse<TClientTypes['contentTypeCodenames']> {
|
|
80
|
-
return this.queryService.mappingService.listContentTypesResponse(json);
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
protected allResponseFactory(
|
|
84
|
-
items: IContentType<TClientTypes['contentTypeCodenames']>[],
|
|
85
|
-
responses: IDeliveryNetworkResponse<
|
|
86
|
-
Responses.IListContentTypesResponse<TClientTypes['contentTypeCodenames']>,
|
|
87
|
-
Contracts.IListContentTypeContract
|
|
88
|
-
>[]
|
|
89
|
-
): Responses.IListContentTypesAllResponse<TClientTypes['contentTypeCodenames']> {
|
|
90
|
-
return {
|
|
91
|
-
items: items,
|
|
92
|
-
responses: responses
|
|
93
|
-
};
|
|
94
|
-
}
|
|
95
|
-
}
|
|
1
|
+
import { Contracts } from '../../contracts';
|
|
2
|
+
import { IDeliveryClientConfig } from '../../config';
|
|
3
|
+
import {
|
|
4
|
+
ClientTypes,
|
|
5
|
+
IContentType,
|
|
6
|
+
IContentTypeQueryConfig,
|
|
7
|
+
IDeliveryNetworkResponse,
|
|
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 MultipleTypeQuery<TClientTypes extends ClientTypes> extends BaseListingQuery<
|
|
15
|
+
TClientTypes,
|
|
16
|
+
IContentType<TClientTypes['contentTypeCodenames']>,
|
|
17
|
+
Responses.IListContentTypesResponse<TClientTypes['contentTypeCodenames']>,
|
|
18
|
+
Responses.IListContentTypesAllResponse<TClientTypes['contentTypeCodenames']>,
|
|
19
|
+
IContentTypeQueryConfig,
|
|
20
|
+
Contracts.IListContentTypeContract
|
|
21
|
+
> {
|
|
22
|
+
protected _queryConfig: IContentTypeQueryConfig = {};
|
|
23
|
+
|
|
24
|
+
constructor(protected config: IDeliveryClientConfig, protected queryService: QueryService<TClientTypes>) {
|
|
25
|
+
super(config, queryService);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Used to limit the number of elements returned by query.
|
|
30
|
+
* @param elementCodenames Array of element codenames to fetch
|
|
31
|
+
*/
|
|
32
|
+
elementsParameter(elementCodenames: TClientTypes['elementCodenames'][]): this {
|
|
33
|
+
this.parameters.push(new Parameters.ElementsParameter(elementCodenames));
|
|
34
|
+
return this;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Used to exclude elements returned by query.
|
|
39
|
+
* @param elementCodenames Array of element codenames to exclude
|
|
40
|
+
*/
|
|
41
|
+
excludeElementsParameter(elementCodenames: TClientTypes['elementCodenames'][]): this {
|
|
42
|
+
this.parameters.push(new Parameters.ExcludeElementsParameter(elementCodenames));
|
|
43
|
+
return this;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Limits the number of taxonomies returned by query
|
|
48
|
+
* @param limit Number of taxonomies to load
|
|
49
|
+
*/
|
|
50
|
+
limitParameter(limit: number): this {
|
|
51
|
+
this.parameters.push(new Parameters.LimitParameter(limit));
|
|
52
|
+
return this;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* Skips the selected number of taxonomies
|
|
57
|
+
* @param skip Number of taxonomies to skip
|
|
58
|
+
*/
|
|
59
|
+
skipParameter(skip: number): this {
|
|
60
|
+
this.parameters.push(new Parameters.SkipParameter(skip));
|
|
61
|
+
return this;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
toPromise(): Promise<
|
|
65
|
+
IDeliveryNetworkResponse<
|
|
66
|
+
Responses.IListContentTypesResponse<TClientTypes['contentTypeCodenames']>,
|
|
67
|
+
Contracts.IListContentTypeContract
|
|
68
|
+
>
|
|
69
|
+
> {
|
|
70
|
+
return this.queryService.getMultipleTypes(this.getUrl(), this._queryConfig ?? {});
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
getUrl(): string {
|
|
74
|
+
const action = '/types';
|
|
75
|
+
|
|
76
|
+
return super.resolveUrlInternal(action);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
map(json: any): Responses.IListContentTypesResponse<TClientTypes['contentTypeCodenames']> {
|
|
80
|
+
return this.queryService.mappingService.listContentTypesResponse(json);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
protected allResponseFactory(
|
|
84
|
+
items: IContentType<TClientTypes['contentTypeCodenames']>[],
|
|
85
|
+
responses: IDeliveryNetworkResponse<
|
|
86
|
+
Responses.IListContentTypesResponse<TClientTypes['contentTypeCodenames']>,
|
|
87
|
+
Contracts.IListContentTypeContract
|
|
88
|
+
>[]
|
|
89
|
+
): Responses.IListContentTypesAllResponse<TClientTypes['contentTypeCodenames']> {
|
|
90
|
+
return {
|
|
91
|
+
items: items,
|
|
92
|
+
responses: responses
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
}
|
|
@@ -1,45 +1,45 @@
|
|
|
1
|
-
import { Contracts } from '../../contracts';
|
|
2
|
-
import { IDeliveryClientConfig } from '../../config';
|
|
3
|
-
import { ClientTypes, IContentTypeQueryConfig, IDeliveryNetworkResponse, Responses } from '../../models';
|
|
4
|
-
import { QueryService } from '../../services';
|
|
5
|
-
import { BaseQuery } from '../common/base-query.class';
|
|
6
|
-
|
|
7
|
-
export class SingleTypeQuery<TClientTypes extends ClientTypes> extends BaseQuery<
|
|
8
|
-
TClientTypes,
|
|
9
|
-
Responses.IViewContentTypeResponse<TClientTypes['contentTypeCodenames']>,
|
|
10
|
-
IContentTypeQueryConfig,
|
|
11
|
-
Contracts.IViewContentTypeContract
|
|
12
|
-
> {
|
|
13
|
-
protected _queryConfig: IContentTypeQueryConfig = {};
|
|
14
|
-
|
|
15
|
-
constructor(
|
|
16
|
-
protected config: IDeliveryClientConfig,
|
|
17
|
-
protected queryService: QueryService<TClientTypes>,
|
|
18
|
-
private typeCodename: string
|
|
19
|
-
) {
|
|
20
|
-
super(config, queryService);
|
|
21
|
-
|
|
22
|
-
if (!typeCodename) {
|
|
23
|
-
throw Error(`Cannot create type query without the codename of the type`);
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
toPromise(): Promise<
|
|
28
|
-
IDeliveryNetworkResponse<
|
|
29
|
-
Responses.IViewContentTypeResponse<TClientTypes['contentTypeCodenames']>,
|
|
30
|
-
Contracts.IViewContentTypeContract
|
|
31
|
-
>
|
|
32
|
-
> {
|
|
33
|
-
return this.queryService.getSingleType(this.getUrl(), this._queryConfig ?? {});
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
getUrl(): string {
|
|
37
|
-
const action = '/types/' + this.typeCodename;
|
|
38
|
-
|
|
39
|
-
return super.resolveUrlInternal(action);
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
map(json: any): Responses.IViewContentTypeResponse<TClientTypes['contentTypeCodenames']> {
|
|
43
|
-
return this.queryService.mappingService.viewContentTypeResponse(json);
|
|
44
|
-
}
|
|
45
|
-
}
|
|
1
|
+
import { Contracts } from '../../contracts';
|
|
2
|
+
import { IDeliveryClientConfig } from '../../config';
|
|
3
|
+
import { ClientTypes, IContentTypeQueryConfig, IDeliveryNetworkResponse, Responses } from '../../models';
|
|
4
|
+
import { QueryService } from '../../services';
|
|
5
|
+
import { BaseQuery } from '../common/base-query.class';
|
|
6
|
+
|
|
7
|
+
export class SingleTypeQuery<TClientTypes extends ClientTypes> extends BaseQuery<
|
|
8
|
+
TClientTypes,
|
|
9
|
+
Responses.IViewContentTypeResponse<TClientTypes['contentTypeCodenames']>,
|
|
10
|
+
IContentTypeQueryConfig,
|
|
11
|
+
Contracts.IViewContentTypeContract
|
|
12
|
+
> {
|
|
13
|
+
protected _queryConfig: IContentTypeQueryConfig = {};
|
|
14
|
+
|
|
15
|
+
constructor(
|
|
16
|
+
protected config: IDeliveryClientConfig,
|
|
17
|
+
protected queryService: QueryService<TClientTypes>,
|
|
18
|
+
private typeCodename: string
|
|
19
|
+
) {
|
|
20
|
+
super(config, queryService);
|
|
21
|
+
|
|
22
|
+
if (!typeCodename) {
|
|
23
|
+
throw Error(`Cannot create type query without the codename of the type`);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
toPromise(): Promise<
|
|
28
|
+
IDeliveryNetworkResponse<
|
|
29
|
+
Responses.IViewContentTypeResponse<TClientTypes['contentTypeCodenames']>,
|
|
30
|
+
Contracts.IViewContentTypeContract
|
|
31
|
+
>
|
|
32
|
+
> {
|
|
33
|
+
return this.queryService.getSingleType(this.getUrl(), this._queryConfig ?? {});
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
getUrl(): string {
|
|
37
|
+
const action = '/types/' + encodeURIComponent(this.typeCodename);
|
|
38
|
+
|
|
39
|
+
return super.resolveUrlInternal(action);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
map(json: any): Responses.IViewContentTypeResponse<TClientTypes['contentTypeCodenames']> {
|
|
43
|
+
return this.queryService.mappingService.viewContentTypeResponse(json);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
@@ -1,126 +1,128 @@
|
|
|
1
|
-
import { Contracts } from '../../contracts';
|
|
2
|
-
import { IDeliveryClientConfig } from '../../config';
|
|
3
|
-
import {
|
|
4
|
-
Filters,
|
|
5
|
-
IDeliveryNetworkResponse,
|
|
6
|
-
Parameters,
|
|
7
|
-
Responses,
|
|
8
|
-
IItemFeedQueryConfig,
|
|
9
|
-
ClientTypes,
|
|
10
|
-
IUsedInItemRecord,
|
|
11
|
-
IQueryConfig
|
|
12
|
-
} from '../../models';
|
|
13
|
-
import { QueryService } from '../../services';
|
|
14
|
-
import { BaseListingQuery } from '../common/base-listing-query.class';
|
|
15
|
-
|
|
16
|
-
export type UsedInSetup = {
|
|
17
|
-
readonly entity: 'asset' | 'contentItem';
|
|
18
|
-
readonly codename: string;
|
|
19
|
-
};
|
|
20
|
-
|
|
21
|
-
export class UsedInQuery<TClientTypes extends ClientTypes> extends BaseListingQuery<
|
|
22
|
-
TClientTypes,
|
|
23
|
-
IUsedInItemRecord<TClientTypes>,
|
|
24
|
-
Responses.IUsedInResponse<TClientTypes>,
|
|
25
|
-
Responses.IUsedInAllResponse<TClientTypes>,
|
|
26
|
-
IQueryConfig,
|
|
27
|
-
Contracts.IUsedInItemsContract
|
|
28
|
-
> {
|
|
29
|
-
protected _queryConfig: IQueryConfig = {};
|
|
30
|
-
|
|
31
|
-
constructor(
|
|
32
|
-
protected readonly config: IDeliveryClientConfig,
|
|
33
|
-
protected readonly queryService: QueryService<TClientTypes>,
|
|
34
|
-
protected readonly setup: UsedInSetup
|
|
35
|
-
) {
|
|
36
|
-
super(config, queryService);
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
/**
|
|
40
|
-
* Gets only item of given type
|
|
41
|
-
* @param type Codename of type to get
|
|
42
|
-
*/
|
|
43
|
-
type(type: TClientTypes['contentTypeCodenames']): this {
|
|
44
|
-
this.parameters.push(new Filters.TypeFilter(type));
|
|
45
|
-
return this;
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
/**
|
|
49
|
-
* Gets items of given types (logical or)
|
|
50
|
-
* I.e. get items of either 'Actor' or 'Movie' type
|
|
51
|
-
* @param types Types to get
|
|
52
|
-
*/
|
|
53
|
-
types(types: TClientTypes['contentTypeCodenames'][]): this {
|
|
54
|
-
this.parameters.push(new Filters.TypeFilter(types));
|
|
55
|
-
return this;
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
/**
|
|
59
|
-
* Gets only item from given collection
|
|
60
|
-
* @param collection Codename of collection to get
|
|
61
|
-
*/
|
|
62
|
-
collection(collection: TClientTypes['collectionCodenames']): this {
|
|
63
|
-
this.parameters.push(new Filters.CollectionFilter(collection));
|
|
64
|
-
return this;
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
/**
|
|
68
|
-
* Gets items from given collections (logical or)
|
|
69
|
-
* I.e. get items of either 'default' or 'christmas-campaign' collection
|
|
70
|
-
* @param collections Collections to get
|
|
71
|
-
*/
|
|
72
|
-
collections(collections: TClientTypes['collectionCodenames'][]): this {
|
|
73
|
-
this.parameters.push(new Filters.CollectionFilter(collections));
|
|
74
|
-
return this;
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
/**
|
|
78
|
-
* Language codename
|
|
79
|
-
* @param languageCodename Codename of the language
|
|
80
|
-
*/
|
|
81
|
-
languageParameter(languageCodename: TClientTypes['languageCodenames']): this {
|
|
82
|
-
this.parameters.push(new Parameters.LanguageParameter(languageCodename));
|
|
83
|
-
return this;
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
toPromise(): Promise<
|
|
87
|
-
IDeliveryNetworkResponse<Responses.IUsedInResponse<TClientTypes>, Contracts.IUsedInItemsContract>
|
|
88
|
-
> {
|
|
89
|
-
return this.queryService.getUsedIn(this.getUrl(), this._queryConfig ?? {});
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
getUrl(): string {
|
|
93
|
-
const action = `/${this.setup.entity === 'asset' ? 'assets' : 'items'}/${
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
}
|
|
1
|
+
import { Contracts } from '../../contracts';
|
|
2
|
+
import { IDeliveryClientConfig } from '../../config';
|
|
3
|
+
import {
|
|
4
|
+
Filters,
|
|
5
|
+
IDeliveryNetworkResponse,
|
|
6
|
+
Parameters,
|
|
7
|
+
Responses,
|
|
8
|
+
IItemFeedQueryConfig,
|
|
9
|
+
ClientTypes,
|
|
10
|
+
IUsedInItemRecord,
|
|
11
|
+
IQueryConfig
|
|
12
|
+
} from '../../models';
|
|
13
|
+
import { QueryService } from '../../services';
|
|
14
|
+
import { BaseListingQuery } from '../common/base-listing-query.class';
|
|
15
|
+
|
|
16
|
+
export type UsedInSetup = {
|
|
17
|
+
readonly entity: 'asset' | 'contentItem';
|
|
18
|
+
readonly codename: string;
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
export class UsedInQuery<TClientTypes extends ClientTypes> extends BaseListingQuery<
|
|
22
|
+
TClientTypes,
|
|
23
|
+
IUsedInItemRecord<TClientTypes>,
|
|
24
|
+
Responses.IUsedInResponse<TClientTypes>,
|
|
25
|
+
Responses.IUsedInAllResponse<TClientTypes>,
|
|
26
|
+
IQueryConfig,
|
|
27
|
+
Contracts.IUsedInItemsContract
|
|
28
|
+
> {
|
|
29
|
+
protected _queryConfig: IQueryConfig = {};
|
|
30
|
+
|
|
31
|
+
constructor(
|
|
32
|
+
protected readonly config: IDeliveryClientConfig,
|
|
33
|
+
protected readonly queryService: QueryService<TClientTypes>,
|
|
34
|
+
protected readonly setup: UsedInSetup
|
|
35
|
+
) {
|
|
36
|
+
super(config, queryService);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Gets only item of given type
|
|
41
|
+
* @param type Codename of type to get
|
|
42
|
+
*/
|
|
43
|
+
type(type: TClientTypes['contentTypeCodenames']): this {
|
|
44
|
+
this.parameters.push(new Filters.TypeFilter(type));
|
|
45
|
+
return this;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Gets items of given types (logical or)
|
|
50
|
+
* I.e. get items of either 'Actor' or 'Movie' type
|
|
51
|
+
* @param types Types to get
|
|
52
|
+
*/
|
|
53
|
+
types(types: TClientTypes['contentTypeCodenames'][]): this {
|
|
54
|
+
this.parameters.push(new Filters.TypeFilter(types));
|
|
55
|
+
return this;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* Gets only item from given collection
|
|
60
|
+
* @param collection Codename of collection to get
|
|
61
|
+
*/
|
|
62
|
+
collection(collection: TClientTypes['collectionCodenames']): this {
|
|
63
|
+
this.parameters.push(new Filters.CollectionFilter(collection));
|
|
64
|
+
return this;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* Gets items from given collections (logical or)
|
|
69
|
+
* I.e. get items of either 'default' or 'christmas-campaign' collection
|
|
70
|
+
* @param collections Collections to get
|
|
71
|
+
*/
|
|
72
|
+
collections(collections: TClientTypes['collectionCodenames'][]): this {
|
|
73
|
+
this.parameters.push(new Filters.CollectionFilter(collections));
|
|
74
|
+
return this;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* Language codename
|
|
79
|
+
* @param languageCodename Codename of the language
|
|
80
|
+
*/
|
|
81
|
+
languageParameter(languageCodename: TClientTypes['languageCodenames']): this {
|
|
82
|
+
this.parameters.push(new Parameters.LanguageParameter(languageCodename));
|
|
83
|
+
return this;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
toPromise(): Promise<
|
|
87
|
+
IDeliveryNetworkResponse<Responses.IUsedInResponse<TClientTypes>, Contracts.IUsedInItemsContract>
|
|
88
|
+
> {
|
|
89
|
+
return this.queryService.getUsedIn(this.getUrl(), this._queryConfig ?? {});
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
getUrl(): string {
|
|
93
|
+
const action = `/${this.setup.entity === 'asset' ? 'assets' : 'items'}/${encodeURIComponent(
|
|
94
|
+
this.setup.codename
|
|
95
|
+
)}/used-in`;
|
|
96
|
+
|
|
97
|
+
// add default language is necessary
|
|
98
|
+
this.processDefaultLanguageParameter();
|
|
99
|
+
|
|
100
|
+
//process client level archived item exclusion
|
|
101
|
+
this.processExcludeArchivedItemsParameter();
|
|
102
|
+
|
|
103
|
+
return super.resolveUrlInternal(action);
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
/**
|
|
107
|
+
* Used to configure query
|
|
108
|
+
* @param queryConfig Query configuration
|
|
109
|
+
*/
|
|
110
|
+
queryConfig(queryConfig: IItemFeedQueryConfig): this {
|
|
111
|
+
this._queryConfig = queryConfig;
|
|
112
|
+
return this;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
map(json: any): Responses.IUsedInResponse<TClientTypes> {
|
|
116
|
+
return this.queryService.mappingService.usedInResponse(json);
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
protected allResponseFactory(
|
|
120
|
+
items: IUsedInItemRecord<TClientTypes>[],
|
|
121
|
+
responses: IDeliveryNetworkResponse<Responses.IUsedInResponse<TClientTypes>, Contracts.IUsedInItemsContract>[]
|
|
122
|
+
): Responses.IUsedInAllResponse<TClientTypes> {
|
|
123
|
+
return {
|
|
124
|
+
items: items,
|
|
125
|
+
responses: responses
|
|
126
|
+
};
|
|
127
|
+
}
|
|
128
|
+
}
|