@shi-corp/sdk-data-gateway
Version:
SDK client used to interface with the SHI Data Gateway service.
178 lines (177 loc) • 10.7 kB
JavaScript
import * as __typia_transform__assertGuard from "typia/lib/internal/_assertGuard.js";
import * as __typia_transform__accessExpressionAsString from "typia/lib/internal/_accessExpressionAsString.js";
import { AzureIdentityAuthenticationProvider } from "@microsoft/kiota-authentication-azure";
import { FetchRequestAdapter } from "@microsoft/kiota-http-fetchlibrary";
import { assert, assertGuardEquals } from 'typia';
import { createDataGatewayClient } from "./sdk/dataGatewayClient.js";
export function dataGatewayClientFactory(credential, baseUrl, scopeList) {
(() => { const _io0 = input => true; const _ao0 = (input, _path, _exceptionable = true) => true; const __is = input => "object" === typeof input && null !== input && false === Array.isArray(input) && _io0(input); let _errorFactory; return (input, errorFactory) => {
if (false === __is(input)) {
_errorFactory = errorFactory;
((input, _path, _exceptionable = true) => ("object" === typeof input && null !== input && false === Array.isArray(input) || __typia_transform__assertGuard._assertGuard(true, {
method: "assert",
path: _path + "",
expected: "TokenCredential",
value: input
}, _errorFactory)) && _ao0(input, _path + "", true) || __typia_transform__assertGuard._assertGuard(true, {
method: "assert",
path: _path + "",
expected: "TokenCredential",
value: input
}, _errorFactory))(input, "$input", true);
}
return input;
}; })()(credential);
(() => { const _io0 = (input, _exceptionable = true) => "string" === typeof input.hash && "string" === typeof input.host && "string" === typeof input.hostname && "string" === typeof input.href && "string" === typeof input.origin && "string" === typeof input.password && "string" === typeof input.pathname && "string" === typeof input.port && "string" === typeof input.protocol && "string" === typeof input.search && ("object" === typeof input.searchParams && null !== input.searchParams && _io1(input.searchParams, true && _exceptionable)) && "string" === typeof input.username && (12 === Object.keys(input).length || Object.keys(input).every(key => {
if (["hash", "host", "hostname", "href", "origin", "password", "pathname", "port", "protocol", "search", "searchParams", "username"].some(prop => key === prop))
return true;
const value = input[key];
if (undefined === value)
return true;
return false;
})); const _io1 = (input, _exceptionable = true) => "number" === typeof input.size && (1 === Object.keys(input).length || Object.keys(input).every(key => {
if (["size"].some(prop => key === prop))
return true;
const value = input[key];
if (undefined === value)
return true;
return false;
})); const _ao0 = (input, _path, _exceptionable = true) => ("string" === typeof input.hash || __typia_transform__assertGuard._assertGuard(_exceptionable, {
method: "assertGuardEquals",
path: _path + ".hash",
expected: "string",
value: input.hash
}, _errorFactory)) && ("string" === typeof input.host || __typia_transform__assertGuard._assertGuard(_exceptionable, {
method: "assertGuardEquals",
path: _path + ".host",
expected: "string",
value: input.host
}, _errorFactory)) && ("string" === typeof input.hostname || __typia_transform__assertGuard._assertGuard(_exceptionable, {
method: "assertGuardEquals",
path: _path + ".hostname",
expected: "string",
value: input.hostname
}, _errorFactory)) && ("string" === typeof input.href || __typia_transform__assertGuard._assertGuard(_exceptionable, {
method: "assertGuardEquals",
path: _path + ".href",
expected: "string",
value: input.href
}, _errorFactory)) && ("string" === typeof input.origin || __typia_transform__assertGuard._assertGuard(_exceptionable, {
method: "assertGuardEquals",
path: _path + ".origin",
expected: "string",
value: input.origin
}, _errorFactory)) && ("string" === typeof input.password || __typia_transform__assertGuard._assertGuard(_exceptionable, {
method: "assertGuardEquals",
path: _path + ".password",
expected: "string",
value: input.password
}, _errorFactory)) && ("string" === typeof input.pathname || __typia_transform__assertGuard._assertGuard(_exceptionable, {
method: "assertGuardEquals",
path: _path + ".pathname",
expected: "string",
value: input.pathname
}, _errorFactory)) && ("string" === typeof input.port || __typia_transform__assertGuard._assertGuard(_exceptionable, {
method: "assertGuardEquals",
path: _path + ".port",
expected: "string",
value: input.port
}, _errorFactory)) && ("string" === typeof input.protocol || __typia_transform__assertGuard._assertGuard(_exceptionable, {
method: "assertGuardEquals",
path: _path + ".protocol",
expected: "string",
value: input.protocol
}, _errorFactory)) && ("string" === typeof input.search || __typia_transform__assertGuard._assertGuard(_exceptionable, {
method: "assertGuardEquals",
path: _path + ".search",
expected: "string",
value: input.search
}, _errorFactory)) && (("object" === typeof input.searchParams && null !== input.searchParams || __typia_transform__assertGuard._assertGuard(_exceptionable, {
method: "assertGuardEquals",
path: _path + ".searchParams",
expected: "URLSearchParams",
value: input.searchParams
}, _errorFactory)) && _ao1(input.searchParams, _path + ".searchParams", true && _exceptionable) || __typia_transform__assertGuard._assertGuard(_exceptionable, {
method: "assertGuardEquals",
path: _path + ".searchParams",
expected: "URLSearchParams",
value: input.searchParams
}, _errorFactory)) && ("string" === typeof input.username || __typia_transform__assertGuard._assertGuard(_exceptionable, {
method: "assertGuardEquals",
path: _path + ".username",
expected: "string",
value: input.username
}, _errorFactory)) && (12 === Object.keys(input).length || (false === _exceptionable || Object.keys(input).every(key => {
if (["hash", "host", "hostname", "href", "origin", "password", "pathname", "port", "protocol", "search", "searchParams", "username"].some(prop => key === prop))
return true;
const value = input[key];
if (undefined === value)
return true;
return __typia_transform__assertGuard._assertGuard(_exceptionable, {
method: "assertGuardEquals",
path: _path + __typia_transform__accessExpressionAsString._accessExpressionAsString(key),
expected: "undefined",
value: value
}, _errorFactory);
}))); const _ao1 = (input, _path, _exceptionable = true) => ("number" === typeof input.size || __typia_transform__assertGuard._assertGuard(_exceptionable, {
method: "assertGuardEquals",
path: _path + ".size",
expected: "number",
value: input.size
}, _errorFactory)) && (1 === Object.keys(input).length || (false === _exceptionable || Object.keys(input).every(key => {
if (["size"].some(prop => key === prop))
return true;
const value = input[key];
if (undefined === value)
return true;
return __typia_transform__assertGuard._assertGuard(_exceptionable, {
method: "assertGuardEquals",
path: _path + __typia_transform__accessExpressionAsString._accessExpressionAsString(key),
expected: "undefined",
value: value
}, _errorFactory);
}))); const __is = (input, _exceptionable = true) => undefined === input || "object" === typeof input && null !== input && _io0(input, true); let _errorFactory; return (input, errorFactory) => {
if (false === __is(input)) {
_errorFactory = errorFactory;
((input, _path, _exceptionable = true) => undefined === input || ("object" === typeof input && null !== input || __typia_transform__assertGuard._assertGuard(true, {
method: "assertGuardEquals",
path: _path + "",
expected: "(URL | undefined)",
value: input
}, _errorFactory)) && _ao0(input, _path + "", true) || __typia_transform__assertGuard._assertGuard(true, {
method: "assertGuardEquals",
path: _path + "",
expected: "(URL | undefined)",
value: input
}, _errorFactory))(input, "$input", true);
}
}; })()(baseUrl);
(() => { const __is = (input, _exceptionable = true) => undefined === input || Array.isArray(input) && input.every((elem, _index1) => "string" === typeof elem); let _errorFactory; return (input, errorFactory) => {
if (false === __is(input)) {
_errorFactory = errorFactory;
((input, _path, _exceptionable = true) => undefined === input || (Array.isArray(input) || __typia_transform__assertGuard._assertGuard(true, {
method: "assertGuardEquals",
path: _path + "",
expected: "(Array<string> | undefined)",
value: input
}, _errorFactory)) && input.every((elem, _index2) => "string" === typeof elem || __typia_transform__assertGuard._assertGuard(true, {
method: "assertGuardEquals",
path: _path + "[" + _index2 + "]",
expected: "string",
value: elem
}, _errorFactory)) || __typia_transform__assertGuard._assertGuard(true, {
method: "assertGuardEquals",
path: _path + "",
expected: "(Array<string> | undefined)",
value: input
}, _errorFactory))(input, "$input", true);
}
}; })()(scopeList);
const allowedHostList = new Set([baseUrl?.host ?? 'api.shilab.com']);
const authProvider = new AzureIdentityAuthenticationProvider(credential, scopeList ?? ['4c40281b-a305-4aaf-90a4-d5bbee6eb8ed/.default'], void 0, allowedHostList);
const dataGatewayAdapter = new FetchRequestAdapter(authProvider);
if (baseUrl) {
dataGatewayAdapter.baseUrl = baseUrl.href.endsWith('/') ? baseUrl.href.substring(0, baseUrl.href.length - 1) : baseUrl.href;
}
return createDataGatewayClient(dataGatewayAdapter);
}