UNPKG

@platform/cell.client

Version:

A strongly typed HTTP client for operating with a CellOS service end-point.

59 lines (58 loc) 2.26 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var tslib_1 = require("tslib"); var common_1 = require("../common"); var HttpClient_1 = require("../HttpClient"); var Client = (function () { function Client() { } Client.http = function (input) { return Client.Http.create(input); }; Client.type = function (input) { var args = typeof input === 'object' ? input : { http: input }; var cache = args.cache, events$ = args.events$; var http = HttpClient_1.HttpClient.isClient(args.http) ? args.http : HttpClient_1.HttpClient.create(args.http); var fetch = common_1.TypeSystem.fetcher.fromClient(http); var api = { http: http, fetch: fetch, defs: function (ns) { return tslib_1.__awaiter(this, void 0, void 0, function () { return tslib_1.__generator(this, function (_a) { switch (_a.label) { case 0: return [4, common_1.TypeSystem.client(http).load(ns)]; case 1: return [2, (_a.sent()).defs]; } }); }); }, typescript: function (ns) { return tslib_1.__awaiter(this, void 0, void 0, function () { var defs; return tslib_1.__generator(this, function (_a) { switch (_a.label) { case 0: return [4, api.defs(ns)]; case 1: defs = _a.sent(); return [2, common_1.TypeSystem.Client.typescript(defs)]; } }); }); }, sheet: function (ns) { return common_1.TypeSystem.Sheet.load({ ns: ns, fetch: fetch, cache: cache, events$: events$ }); }, }; return api; }; Client.sheet = function (ns, options) { return Client.type(options).sheet(ns); }; Client.Http = HttpClient_1.HttpClient; Client.Type = common_1.TypeSystem; return Client; }()); exports.Client = Client;