UNPKG

@settlemint/sdk-portal

Version:

Portal API client module for SettleMint SDK, providing access to smart contract portal services and APIs

58 lines (57 loc) 2.35 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); // src/portal.ts var portal_exports = {}; __export(portal_exports, { ClientOptionsSchema: () => ClientOptionsSchema, createPortalClient: () => createPortalClient, readFragment: () => import_gql2.readFragment }); module.exports = __toCommonJS(portal_exports); var import_runtime = require("@settlemint/sdk-utils/runtime"); var import_validation = require("@settlemint/sdk-utils/validation"); var import_gql = require("gql.tada"); var import_graphql_request = require("graphql-request"); var import_zod = require("zod"); var import_gql2 = require("gql.tada"); var ClientOptionsSchema = import_zod.z.object({ instance: import_validation.UrlOrPathSchema, accessToken: import_validation.ApplicationAccessTokenSchema, cache: import_zod.z.enum(["default", "force-cache", "no-cache", "no-store", "only-if-cached", "reload"]).optional() }); function createPortalClient(options, clientOptions) { (0, import_runtime.ensureServer)(); const validatedOptions = (0, import_validation.validate)(ClientOptionsSchema, options); const graphql = (0, import_gql.initGraphQLTada)(); const fullUrl = new URL(validatedOptions.instance).toString(); return { client: new import_graphql_request.GraphQLClient(fullUrl, { ...clientOptions, headers: { ...clientOptions?.headers ?? {}, "x-auth-token": validatedOptions.accessToken } }), graphql }; } // Annotate the CommonJS export names for ESM import in node: 0 && (module.exports = { ClientOptionsSchema, createPortalClient, readFragment }); //# sourceMappingURL=portal.cjs.map