UNPKG

@finos/legend-server-marketplace

Version:
41 lines 2.23 kB
/** * Copyright (c) 2020-present, Goldman Sachs * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ import { AbstractServerClient } from '@finos/legend-shared'; export class MarketplaceServerClient extends AbstractServerClient { subscriptionUrl; constructor(config) { super({ baseUrl: config.serverUrl, networkClientOptions: { // NOTE: with the way we setup this server, we allow any (*) origin for CORS // so here we have to explicit omit credentials // See https://fetch.spec.whatwg.org/#concept-request-credentials-mode credentials: 'omit', }, }); this.subscriptionUrl = config.subscriptionUrl; } // ------------------------------------------- Vendors ------------------------------------------- _vendors = () => `${this.baseUrl}/v1/vendors`; getVendors = () => this.get(this._vendors()); getVendorsByCategory = async (category, limit) => (await this.get(`${this.baseUrl}/v1/vendor/category?category=${category}&limit=${limit}`)).results; // ------------------------------------------- Search- ------------------------------------------- _search = () => `${this.baseUrl}/v1/search`; semanticSearch = async (query, vendorName, limit) => (await this.get(`${this._search()}/semantic/catalog?query=${query}&vendor_name=${vendorName}&limit=${limit}`)).results; // ------------------------------------------- Subscriptions ----------------------------------------- getSubscriptions = async (user) => (await this.get(`${this.subscriptionUrl}/v1/service/subscription/${user}`)).subscription_feeds; } //# sourceMappingURL=MarketplaceServerClient.js.map