UNPKG

@updatedev/js

Version:

Update JavaScript SDK

63 lines 2.4 kB
"use strict"; var __defProp = Object.defineProperty; var __getOwnPropDesc = Object.getOwnPropertyDescriptor; var __getOwnPropNames = Object.getOwnPropertyNames; var __hasOwnProp = Object.prototype.hasOwnProperty; var __export = (target, all) => { for (var name in all) __defProp(target, name, { get: all[name], enumerable: true }); }; var __copyProps = (to, from, except, desc) => { if (from && typeof from === "object" || typeof from === "function") { for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); } return to; }; var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); var Update_exports = {}; __export(Update_exports, { UpdateClient: () => UpdateClient }); module.exports = __toCommonJS(Update_exports); var import_internal = require("./types/internal"); var import_UpdateBilling = require("./UpdateBilling"); var import_UpdateEntitlements = require("./UpdateEntitlements"); var import_request = require("./utils/request"); class UpdateClient { constructor(apiKey, options) { this.apiKey = apiKey; var _a; const billingEnvironment = this.getEnvironment(options); const requestClient = new import_request.RequestClient({ baseUrl: (_a = options == null ? void 0 : options.apiUrl) != null ? _a : "https://api.update.dev/v1", headers: { [import_internal.ENVIRONMENT_HEADER]: billingEnvironment, [import_internal.API_KEY_HEADER]: this.apiKey }, getAuthorizationToken: options.getSessionToken }); this.billing = new import_UpdateBilling.UpdateBillingClient({ requestClient, hasSessionToken: options.getSessionToken !== void 0 }); this.entitlements = new import_UpdateEntitlements.UpdateEntitlements({ requestClient, hasSessionToken: options.getSessionToken !== void 0 }); } getEnvironment(options) { if (options.environment) { if (options.environment === "live") return "live"; if (options.environment === "test") return "test"; throw new Error("Invalid environment"); } return "test"; } } // Annotate the CommonJS export names for ESM import in node: 0 && (module.exports = { UpdateClient }); //# sourceMappingURL=Update.js.map