UNPKG

@kontent-ai/delivery-sdk

Version:
83 lines 2.68 kB
import { Filters, Parameters } from '../../models'; import { BaseListingQuery } from '../common/base-listing-query.class'; export class UsedInQuery extends BaseListingQuery { constructor(config, queryService, setup) { super(config, queryService); this.config = config; this.queryService = queryService; this.setup = setup; this._queryConfig = {}; } /** * Gets only item of given type * @param type Codename of type to get */ type(type) { this.parameters.push(new Filters.TypeFilter(type)); return this; } /** * Gets items of given types (logical or) * I.e. get items of either 'Actor' or 'Movie' type * @param types Types to get */ types(types) { this.parameters.push(new Filters.TypeFilter(types)); return this; } /** * Gets only item from given collection * @param collection Codename of collection to get */ collection(collection) { this.parameters.push(new Filters.CollectionFilter(collection)); return this; } /** * Gets items from given collections (logical or) * I.e. get items of either 'default' or 'christmas-campaign' collection * @param collections Collections to get */ collections(collections) { this.parameters.push(new Filters.CollectionFilter(collections)); return this; } /** * Language codename * @param languageCodename Codename of the language */ languageParameter(languageCodename) { this.parameters.push(new Parameters.LanguageParameter(languageCodename)); return this; } toPromise() { var _a; return this.queryService.getUsedIn(this.getUrl(), (_a = this._queryConfig) !== null && _a !== void 0 ? _a : {}); } getUrl() { const action = `/${this.setup.entity === 'asset' ? 'assets' : 'items'}/${this.setup.codename}/used-in`; // add default language is necessary this.processDefaultLanguageParameter(); //process client level archived item exclusion this.processExcludeArchivedItemsParameter(); return super.resolveUrlInternal(action); } /** * Used to configure query * @param queryConfig Query configuration */ queryConfig(queryConfig) { this._queryConfig = queryConfig; return this; } map(json) { return this.queryService.mappingService.usedInResponse(json); } allResponseFactory(items, responses) { return { items: items, responses: responses }; } } //# sourceMappingURL=used-in-query.class.js.map