UNPKG

@goteborgco/open-api-js-client

Version:

Official JavaScript client for the Göteborg & Co GraphQL API

45 lines (44 loc) 1.34 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.Taxonomies = void 0; const Taxonomy_1 = require("../entities/Taxonomy"); const gql_1 = require("../utils/gql"); /** * Taxonomies API for listing available taxonomies * * This class provides type-safe methods for getting an overview of all taxonomy types * in the system. */ class Taxonomies { constructor(client) { this.client = client; } /** * List all available taxonomies * * @param filter Optional filtering options: * - lang: 'en' | 'sv' - Language filter (enum) * @param fields Optional GraphQL fields to return * @returns Array of taxonomy information */ async list(filter = {}, fields) { const defaultFields = ` name description value types `; // Handle lang as an enum value (unquoted) const filterStr = filter.lang ? `{ lang: ${filter.lang} }` : '{}'; const query = (0, gql_1.gql) ` query ListTaxonomies { taxonomies(filter: ${filterStr}) { ${fields || defaultFields} } } `; const response = await this.client.execute(query); return response.taxonomies.map(taxonomy => new Taxonomy_1.Taxonomy(taxonomy)); } } exports.Taxonomies = Taxonomies;