UNPKG

@openfga/sdk

Version:

JavaScript and Node.js SDK for OpenFGA

47 lines (46 loc) 1.62 kB
"use strict"; /** * JavaScript and Node.js SDK for OpenFGA * * API version: 1.x * Website: https://openfga.dev * Documentation: https://openfga.dev/docs * Support: https://openfga.dev/community * License: [Apache-2.0](https://github.com/openfga/js-sdk/blob/main/LICENSE) * * NOTE: This file was auto generated by OpenAPI Generator (https://openapi-generator.tech). DO NOT EDIT. */ Object.defineProperty(exports, "__esModule", { value: true }); exports.isWellFormedUlidString = exports.isWellFormedUriString = exports.assertParamExists = void 0; const errors_1 = require("./errors"); /** * * @throws { FgaRequiredParamError } * @export */ const assertParamExists = function (functionName, paramName, paramValue) { if (paramValue === null || paramValue === undefined) { throw new errors_1.FgaRequiredParamError(functionName, paramName, `Required parameter ${paramName} was null or undefined when calling ${functionName}.`); } }; exports.assertParamExists = assertParamExists; /** * * @export */ const isWellFormedUriString = (uri) => { try { const uriResult = new URL(uri); return ((uriResult.toString() === uri || uriResult.toString() === `${uri}/`) && (uriResult.protocol === "https:" || uriResult.protocol === "http:")); } catch (err) { return false; } }; exports.isWellFormedUriString = isWellFormedUriString; const isWellFormedUlidString = (ulid) => { const regex = /^[0-7][0-9A-HJKMNP-TV-Z]{25}$/; return !!(typeof ulid === "string" && ulid.match(regex)?.length); }; exports.isWellFormedUlidString = isWellFormedUlidString;