hanzio 1.1.0 → 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +70 -4
- package/dist/api-wrapper/builders.d.ts +13 -2
- package/dist/api-wrapper/errors.d.ts +1 -0
- package/dist/api-wrapper/headers.d.ts +2 -1
- package/dist/api-wrapper/transport.d.ts +8 -5
- package/dist/api-wrapper/types.d.ts +1 -0
- package/dist/cache/index.d.ts +26 -0
- package/dist/secrets/core.d.ts +47 -0
- package/dist/secrets/deadline.d.ts +6 -0
- package/dist/secrets/environment.d.ts +9 -0
- package/dist/secrets/errors.d.ts +11 -0
- package/dist/secrets/index.d.ts +13 -25
- package/dist/secrets/infisical-cli.d.ts +6 -0
- package/dist/secrets/infisical-config.d.ts +17 -0
- package/dist/secrets/infisical-session.d.ts +4 -0
- package/dist/secrets/infisical.d.ts +8 -13
- package/dist/secrets/loaders.d.ts +5 -12
- package/dist/secrets/vite.d.ts +7 -3
- package/dist/secrets/worker-loader.d.ts +9 -0
- package/dist/secrets/worker.d.ts +3 -0
- package/dist/src/api-wrapper/index.js +152 -122
- package/dist/src/index.js +3173 -2713
- package/dist/src/jwt/index.js +2 -2
- package/dist/src/p-queue/index.js +3 -3
- package/dist/src/secrets/index.js +670 -402
- package/dist/src/secrets/infisical.js +451 -168
- package/dist/src/secrets/loaders.js +467 -174
- package/dist/src/secrets/vite.js +33 -11
- package/dist/src/secrets/worker.js +275 -0
- package/dist/src/sitemap/index.js +1 -1
- package/dist/src/zod/index.js +7 -7
- package/dist/typedswitch/index.d.ts +9 -5
- package/package.json +12 -3
- package/src/api-wrapper/builders.ts +68 -43
- package/src/api-wrapper/create-client.ts +82 -62
- package/src/api-wrapper/errors.ts +10 -0
- package/src/api-wrapper/headers.ts +14 -1
- package/src/api-wrapper/redaction.ts +1 -0
- package/src/api-wrapper/transport.ts +34 -38
- package/src/api-wrapper/types.ts +1 -0
- package/src/cache/index.ts +228 -61
- package/src/secrets/core.ts +348 -0
- package/src/secrets/deadline.ts +69 -0
- package/src/secrets/environment.ts +69 -0
- package/src/secrets/errors.ts +29 -0
- package/src/secrets/index.ts +79 -210
- package/src/secrets/infisical-cli.ts +99 -0
- package/src/secrets/infisical-config.ts +70 -0
- package/src/secrets/infisical-session.ts +42 -0
- package/src/secrets/infisical.ts +214 -66
- package/src/secrets/loaders.ts +24 -48
- package/src/secrets/vite.ts +44 -15
- package/src/secrets/worker-loader.ts +56 -0
- package/src/secrets/worker.ts +4 -0
- package/src/typedswitch/index.ts +80 -69
|
@@ -38,13 +38,16 @@ function hasJsonContentType(headers) {
|
|
|
38
38
|
const ct = getHeader(headers, "content-type") ?? "";
|
|
39
39
|
return ct.includes("application/json");
|
|
40
40
|
}
|
|
41
|
-
function buildFetchBody(body, headers) {
|
|
41
|
+
function buildFetchBody(body, headers, configError) {
|
|
42
42
|
if (body === undefined || body === null)
|
|
43
43
|
return;
|
|
44
44
|
if (body instanceof FormData || body instanceof Blob)
|
|
45
45
|
return body;
|
|
46
46
|
if (hasJsonContentType(headers))
|
|
47
47
|
return JSON.stringify(body);
|
|
48
|
+
if (typeof body === "object" && (Object.getPrototypeOf(body) === Object.prototype || Object.getPrototypeOf(body) === null) && configError) {
|
|
49
|
+
throw configError("Request body is a plain object but Content-Type is not application/json");
|
|
50
|
+
}
|
|
48
51
|
return body;
|
|
49
52
|
}
|
|
50
53
|
function getHeadersAsObject(headers) {
|
|
@@ -339,39 +342,61 @@ var isNetworkError = (e) => e instanceof NetworkError;
|
|
|
339
342
|
var isRequestAbortedError = (e) => e instanceof RequestAbortedError;
|
|
340
343
|
var isConfigError = (e) => e instanceof ConfigError;
|
|
341
344
|
var isActionError = (e) => e instanceof ActionError;
|
|
345
|
+
function isNonRetryableApiError(error) {
|
|
346
|
+
return error instanceof HttpResponseError || error instanceof ResponseValidationError || error instanceof RequestValidationError || error instanceof ConfigError || error instanceof RequestAbortedError;
|
|
347
|
+
}
|
|
342
348
|
// src/api-wrapper/builders.ts
|
|
343
349
|
import { ZodError as ZodError2 } from "zod";
|
|
344
|
-
function
|
|
350
|
+
function formatQueryString(queryParams, doNotEncode) {
|
|
351
|
+
if (Object.keys(queryParams).length === 0)
|
|
352
|
+
return "";
|
|
353
|
+
return doNotEncode ? Object.entries(queryParams).map(([key, value]) => `${key}=${value}`).join("&") : new URLSearchParams(queryParams).toString();
|
|
354
|
+
}
|
|
355
|
+
function buildUrl(options) {
|
|
356
|
+
const {
|
|
357
|
+
endpoint,
|
|
358
|
+
params,
|
|
359
|
+
queryParams,
|
|
360
|
+
baseApiUrls,
|
|
361
|
+
defaultBaseApiUrl,
|
|
362
|
+
url,
|
|
363
|
+
doNotEncodeQueryParams,
|
|
364
|
+
configError
|
|
365
|
+
} = options;
|
|
366
|
+
let finalUrl;
|
|
345
367
|
if (url) {
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
}
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
throw configError(`Unknown base API URL: ${baseUrlKey}`);
|
|
368
|
+
finalUrl = replacePathParams(url, params, configError);
|
|
369
|
+
} else {
|
|
370
|
+
const defaultBaseUrl = defaultBaseApiUrl ?? Object.keys(baseApiUrls)[0];
|
|
371
|
+
if (!defaultBaseUrl) {
|
|
372
|
+
throw configError("At least one base API URL is required");
|
|
373
|
+
}
|
|
374
|
+
const baseUrlKey = endpoint.baseApiUrl ?? defaultBaseUrl;
|
|
375
|
+
const configBaseUrl = baseApiUrls[baseUrlKey];
|
|
376
|
+
if (!configBaseUrl) {
|
|
377
|
+
throw configError(`Unknown base API URL: ${baseUrlKey}`);
|
|
378
|
+
}
|
|
379
|
+
const baseUrl = typeof configBaseUrl === "function" ? configBaseUrl() : configBaseUrl;
|
|
380
|
+
const path = typeof endpoint.path === "function" ? endpoint.path(baseUrl) : endpoint.path;
|
|
381
|
+
finalUrl = `${baseUrl}${replacePathParams(path, params, configError)}`;
|
|
361
382
|
}
|
|
362
|
-
const
|
|
363
|
-
const path = typeof endpoint.path === "function" ? endpoint.path(baseUrl) : endpoint.path;
|
|
364
|
-
const finalUrl = replacePathParams(`${baseUrl}${path}`, params, configError);
|
|
365
|
-
const queryString = new URLSearchParams(buildQueryParamsRaw(endpoint, reqQuery)).toString();
|
|
383
|
+
const queryString = formatQueryString(queryParams, doNotEncodeQueryParams);
|
|
366
384
|
return {
|
|
367
385
|
finalUrl,
|
|
368
386
|
fullUrl: queryString ? `${finalUrl}?${queryString}` : finalUrl
|
|
369
387
|
};
|
|
370
388
|
}
|
|
371
|
-
function
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
389
|
+
function buildPathParams(endpoint, params, ctx) {
|
|
390
|
+
if (!endpoint.reqParamsSchema)
|
|
391
|
+
return params;
|
|
392
|
+
try {
|
|
393
|
+
return endpoint.reqParamsSchema.parse(params);
|
|
394
|
+
} catch (error) {
|
|
395
|
+
if (error instanceof ZodError2) {
|
|
396
|
+
throw new RequestValidationError(error, "params", params, ctx());
|
|
397
|
+
}
|
|
398
|
+
throw error;
|
|
399
|
+
}
|
|
375
400
|
}
|
|
376
401
|
function buildQueryParams(endpoint, query, ctx) {
|
|
377
402
|
const defaultParams = endpoint.reqDefaultQueryParams ?? {};
|
|
@@ -504,8 +529,8 @@ function createActionCache() {
|
|
|
504
529
|
function makeDefineAction() {
|
|
505
530
|
function defineAction(...args) {
|
|
506
531
|
if (args.length === 0) {
|
|
507
|
-
return (
|
|
508
|
-
...
|
|
532
|
+
return (def) => ({
|
|
533
|
+
...def,
|
|
509
534
|
noRuntimeInput: false
|
|
510
535
|
});
|
|
511
536
|
}
|
|
@@ -536,6 +561,7 @@ var SENSITIVE_BODY_KEYS = new Set([
|
|
|
536
561
|
"refresh_token",
|
|
537
562
|
"secret",
|
|
538
563
|
"client_secret",
|
|
564
|
+
"clientsecret",
|
|
539
565
|
"apikey",
|
|
540
566
|
"api_key"
|
|
541
567
|
]);
|
|
@@ -626,16 +652,14 @@ async function validateResponse(schema, data, ctx) {
|
|
|
626
652
|
}
|
|
627
653
|
}
|
|
628
654
|
async function httpRequest(config, ctx) {
|
|
629
|
-
const queryString = config.doNotEncodeQueryParams ? Object.entries(config.queryParams).map(([key, value]) => `${key}=${value}`).join("&") : new URLSearchParams(config.queryParams).toString();
|
|
630
|
-
const fullUrl = queryString ? `${config.url}?${queryString}` : config.url;
|
|
631
655
|
const timeoutController = new AbortController;
|
|
632
656
|
const timeout = config.timeoutMs === undefined ? undefined : setTimeout(() => timeoutController.abort(), config.timeoutMs);
|
|
633
657
|
const signal = mergeSignals(timeoutController.signal, config.userSignal);
|
|
634
658
|
try {
|
|
635
|
-
return await config.fetchFn(fullUrl, {
|
|
659
|
+
return await config.fetchFn(config.fullUrl, {
|
|
636
660
|
method: config.method,
|
|
637
661
|
headers: config.headers,
|
|
638
|
-
body: buildFetchBody(config.body, config.headers),
|
|
662
|
+
body: buildFetchBody(config.body, config.headers, (msg) => new ConfigError(msg, ctx())),
|
|
639
663
|
signal
|
|
640
664
|
});
|
|
641
665
|
} catch (error) {
|
|
@@ -648,6 +672,8 @@ async function httpRequest(config, ctx) {
|
|
|
648
672
|
}
|
|
649
673
|
throw new RequestAbortedError(ctx(), error);
|
|
650
674
|
}
|
|
675
|
+
if (error instanceof ConfigError)
|
|
676
|
+
throw error;
|
|
651
677
|
throw new NetworkError(error instanceof Error ? error.message : String(error), ctx(), error);
|
|
652
678
|
} finally {
|
|
653
679
|
if (timeout)
|
|
@@ -684,35 +710,26 @@ async function readErrorResponse(response) {
|
|
|
684
710
|
};
|
|
685
711
|
}
|
|
686
712
|
function getRetryDelay(params) {
|
|
713
|
+
const maxDelay = params.maxRetryDelayMs ?? 30000;
|
|
687
714
|
const { retryDelay, attempt, response } = params;
|
|
688
715
|
if (response && (response.status === 429 || response.status === 503)) {
|
|
689
716
|
const retryAfter = response.headers.get("retry-after");
|
|
690
717
|
if (retryAfter) {
|
|
691
718
|
const seconds = Number(retryAfter);
|
|
692
|
-
if (Number.isFinite(seconds))
|
|
693
|
-
return seconds * 1000;
|
|
719
|
+
if (Number.isFinite(seconds)) {
|
|
720
|
+
return Math.min(Math.max(0, seconds * 1000), maxDelay);
|
|
721
|
+
}
|
|
694
722
|
const dateMs = Date.parse(retryAfter);
|
|
695
723
|
if (!Number.isNaN(dateMs)) {
|
|
696
|
-
return Math.max(0, dateMs - Date.now());
|
|
724
|
+
return Math.min(Math.max(0, dateMs - Date.now()), maxDelay);
|
|
697
725
|
}
|
|
698
726
|
}
|
|
699
727
|
}
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
return retryDelay;
|
|
728
|
+
const delayMs = typeof retryDelay === "function" ? retryDelay(attempt) : retryDelay;
|
|
729
|
+
return Math.min(delayMs, maxDelay);
|
|
703
730
|
}
|
|
704
731
|
function shouldAttemptRetryOnError(error) {
|
|
705
|
-
|
|
706
|
-
return false;
|
|
707
|
-
if (error instanceof ResponseValidationError)
|
|
708
|
-
return false;
|
|
709
|
-
if (error instanceof RequestValidationError)
|
|
710
|
-
return false;
|
|
711
|
-
if (error instanceof ConfigError)
|
|
712
|
-
return false;
|
|
713
|
-
if (error instanceof RequestAbortedError)
|
|
714
|
-
return false;
|
|
715
|
-
return true;
|
|
732
|
+
return !isNonRetryableApiError(error);
|
|
716
733
|
}
|
|
717
734
|
function shouldAttemptRetryOnHttp(retryCtx) {
|
|
718
735
|
const { error, response } = retryCtx;
|
|
@@ -725,6 +742,7 @@ async function makeRequestWithRetry(args) {
|
|
|
725
742
|
config,
|
|
726
743
|
maxRetries,
|
|
727
744
|
retryDelay,
|
|
745
|
+
maxRetryDelayMs,
|
|
728
746
|
validateFn,
|
|
729
747
|
shouldRetry,
|
|
730
748
|
logger,
|
|
@@ -763,7 +781,8 @@ async function makeRequestWithRetry(args) {
|
|
|
763
781
|
const delayMs = getRetryDelay({
|
|
764
782
|
retryDelay,
|
|
765
783
|
attempt: retryCount,
|
|
766
|
-
response
|
|
784
|
+
response,
|
|
785
|
+
maxRetryDelayMs
|
|
767
786
|
});
|
|
768
787
|
await onRetry?.({
|
|
769
788
|
...retryCtx,
|
|
@@ -778,12 +797,12 @@ async function makeRequestWithRetry(args) {
|
|
|
778
797
|
throw new HttpResponseError(response.status, body, responseHeaders, ctx({ attempt: retryCount }));
|
|
779
798
|
}
|
|
780
799
|
return {
|
|
781
|
-
validatedData: await validateFn(response),
|
|
800
|
+
validatedData: await validateFn(response, retryCount),
|
|
782
801
|
retryCount,
|
|
783
802
|
httpStatus: response.status
|
|
784
803
|
};
|
|
785
804
|
} catch (error) {
|
|
786
|
-
if (error
|
|
805
|
+
if (isNonRetryableApiError(error)) {
|
|
787
806
|
throw error;
|
|
788
807
|
}
|
|
789
808
|
const retryCtx = {
|
|
@@ -800,7 +819,8 @@ async function makeRequestWithRetry(args) {
|
|
|
800
819
|
const delayMs = getRetryDelay({
|
|
801
820
|
retryDelay,
|
|
802
821
|
attempt: retryCount,
|
|
803
|
-
response: undefined
|
|
822
|
+
response: undefined,
|
|
823
|
+
maxRetryDelayMs
|
|
804
824
|
});
|
|
805
825
|
await onRetry?.({
|
|
806
826
|
...retryCtx,
|
|
@@ -814,19 +834,21 @@ async function makeRequestWithRetry(args) {
|
|
|
814
834
|
}
|
|
815
835
|
async function validateAndTransformResponse(endpoint, response, ctx) {
|
|
816
836
|
const responseHeaders = getHeadersAsObject(response.headers);
|
|
837
|
+
const text = await response.text();
|
|
838
|
+
const responseSizeBytes = new TextEncoder().encode(text).length;
|
|
817
839
|
let responseData;
|
|
818
840
|
if (hasJsonContentType(responseHeaders)) {
|
|
819
|
-
const text = await response.text();
|
|
820
841
|
try {
|
|
821
842
|
responseData = text === "" ? undefined : JSON.parse(text);
|
|
822
843
|
} catch (error) {
|
|
823
844
|
throw new ResponseValidationError(makeJsonParseZodError(error, text), text, ctx());
|
|
824
845
|
}
|
|
825
846
|
} else {
|
|
826
|
-
responseData =
|
|
847
|
+
responseData = text;
|
|
827
848
|
}
|
|
828
849
|
const transformedData = endpoint.resFormatter ? endpoint.resFormatter(responseData, responseHeaders) : responseData;
|
|
829
|
-
|
|
850
|
+
const data = await validateResponse(endpoint.resSchema, transformedData, ctx);
|
|
851
|
+
return { data, responseSizeBytes };
|
|
830
852
|
}
|
|
831
853
|
function defaultShouldRetry(ctx) {
|
|
832
854
|
if (ctx.error)
|
|
@@ -845,6 +867,28 @@ function isActionInvokeOptionsOnly(value) {
|
|
|
845
867
|
return false;
|
|
846
868
|
return Object.keys(value).every((k) => k === "signal" || k === "meta");
|
|
847
869
|
}
|
|
870
|
+
function resolveActionInvocation(action, actionName, first, second) {
|
|
871
|
+
if (!action.noRuntimeInput) {
|
|
872
|
+
return { input: first, options: second ?? {} };
|
|
873
|
+
}
|
|
874
|
+
if (first === undefined || first === null) {
|
|
875
|
+
return { input: undefined, options: second ?? {} };
|
|
876
|
+
}
|
|
877
|
+
if (second !== undefined) {
|
|
878
|
+
return { input: undefined, options: second };
|
|
879
|
+
}
|
|
880
|
+
if (isActionInvokeOptionsOnly(first)) {
|
|
881
|
+
return { input: undefined, options: first };
|
|
882
|
+
}
|
|
883
|
+
throw new ConfigError(`Action "${actionName}" does not accept input; pass only optional { signal, meta }`, {
|
|
884
|
+
endpoint: actionName,
|
|
885
|
+
method: "GET",
|
|
886
|
+
url: "",
|
|
887
|
+
attempt: 0,
|
|
888
|
+
maxRetries: 0,
|
|
889
|
+
elapsedMs: 0
|
|
890
|
+
});
|
|
891
|
+
}
|
|
848
892
|
function createApiClientImpl(apiConfig) {
|
|
849
893
|
let actions = {};
|
|
850
894
|
const cache = createActionCache();
|
|
@@ -873,22 +917,12 @@ function createApiClientImpl(apiConfig) {
|
|
|
873
917
|
throw await reportApiError(new ConfigError(`Unknown API endpoint: ${String(endpointKey)}`, ctx()), apiConfig);
|
|
874
918
|
}
|
|
875
919
|
baseContext.method = endpoint.method;
|
|
876
|
-
let
|
|
877
|
-
let fullUrl;
|
|
878
|
-
try {
|
|
879
|
-
const built = buildUrl(endpoint, rawInput.reqParams, rawInput.reqQuery, apiConfig.baseApiUrls, apiConfig.defaultBaseApiUrl, input.url, (msg) => new ConfigError(msg, ctx()));
|
|
880
|
-
finalUrl = built.finalUrl;
|
|
881
|
-
fullUrl = built.fullUrl;
|
|
882
|
-
} catch (e) {
|
|
883
|
-
if (e instanceof ApiError)
|
|
884
|
-
throw await reportApiError(e, apiConfig);
|
|
885
|
-
throw e;
|
|
886
|
-
}
|
|
887
|
-
baseContext.url = fullUrl;
|
|
920
|
+
let pathParams;
|
|
888
921
|
let queryParams;
|
|
889
922
|
let body;
|
|
890
923
|
let headers;
|
|
891
924
|
try {
|
|
925
|
+
pathParams = buildPathParams(endpoint, rawInput.reqParams, ctx);
|
|
892
926
|
queryParams = buildQueryParams(endpoint, rawInput.reqQuery, ctx);
|
|
893
927
|
body = buildRequestBody(endpoint, rawInput.reqBody, ctx);
|
|
894
928
|
headers = buildHeaders(endpoint, rawInput.reqHeaders, apiConfig.defaultHeaders ?? {}, ctx);
|
|
@@ -897,6 +931,25 @@ function createApiClientImpl(apiConfig) {
|
|
|
897
931
|
throw await reportApiError(e, apiConfig);
|
|
898
932
|
throw e;
|
|
899
933
|
}
|
|
934
|
+
let fullUrl;
|
|
935
|
+
try {
|
|
936
|
+
const built = buildUrl({
|
|
937
|
+
endpoint,
|
|
938
|
+
params: pathParams,
|
|
939
|
+
queryParams,
|
|
940
|
+
baseApiUrls: apiConfig.baseApiUrls,
|
|
941
|
+
defaultBaseApiUrl: apiConfig.defaultBaseApiUrl,
|
|
942
|
+
url: input.url,
|
|
943
|
+
doNotEncodeQueryParams: endpoint.doNotEncodeQueryParams,
|
|
944
|
+
configError: (msg) => new ConfigError(msg, ctx())
|
|
945
|
+
});
|
|
946
|
+
fullUrl = built.fullUrl;
|
|
947
|
+
} catch (e) {
|
|
948
|
+
if (e instanceof ApiError)
|
|
949
|
+
throw await reportApiError(e, apiConfig);
|
|
950
|
+
throw e;
|
|
951
|
+
}
|
|
952
|
+
baseContext.url = fullUrl;
|
|
900
953
|
baseContext.requestHeaders = headers;
|
|
901
954
|
baseContext.requestBody = body;
|
|
902
955
|
if (apiConfig.onRequest) {
|
|
@@ -921,11 +974,9 @@ function createApiClientImpl(apiConfig) {
|
|
|
921
974
|
}
|
|
922
975
|
const config = {
|
|
923
976
|
method: endpoint.method,
|
|
924
|
-
|
|
925
|
-
queryParams,
|
|
977
|
+
fullUrl,
|
|
926
978
|
body,
|
|
927
979
|
headers,
|
|
928
|
-
doNotEncodeQueryParams: endpoint.doNotEncodeQueryParams,
|
|
929
980
|
timeoutMs: input.timeoutMs ?? apiConfig.timeoutMs,
|
|
930
981
|
fetchFn: input.fetch ?? apiConfig.fetch ?? fetch,
|
|
931
982
|
userSignal: input.signal
|
|
@@ -935,7 +986,8 @@ function createApiClientImpl(apiConfig) {
|
|
|
935
986
|
config,
|
|
936
987
|
maxRetries,
|
|
937
988
|
retryDelay: apiConfig.retryDelayMs ?? 300,
|
|
938
|
-
|
|
989
|
+
maxRetryDelayMs: apiConfig.maxRetryDelayMs,
|
|
990
|
+
validateFn: (response, attempt) => validateAndTransformResponse(endpoint, response, (over) => ctx({ attempt, ...over })),
|
|
939
991
|
shouldRetry: apiConfig.shouldRetry ?? defaultShouldRetry,
|
|
940
992
|
logger: apiConfig.logger,
|
|
941
993
|
ctx,
|
|
@@ -947,10 +999,10 @@ function createApiClientImpl(apiConfig) {
|
|
|
947
999
|
onRetry: apiConfig.onRetry
|
|
948
1000
|
});
|
|
949
1001
|
const responseTimeMs = elapsed();
|
|
950
|
-
const responseSizeMb =
|
|
1002
|
+
const responseSizeMb = result.validatedData.responseSizeBytes / (1024 * 1024);
|
|
951
1003
|
const requestBodySizeMb = calculateSizeInMb(config.body);
|
|
952
1004
|
return {
|
|
953
|
-
data: result.validatedData,
|
|
1005
|
+
data: result.validatedData.data,
|
|
954
1006
|
requestBodySizeMb,
|
|
955
1007
|
responseSizeMb,
|
|
956
1008
|
responseTimeMs,
|
|
@@ -1006,22 +1058,14 @@ function createApiClientImpl(apiConfig) {
|
|
|
1006
1058
|
throw await reportApiError(wrapped, apiConfig);
|
|
1007
1059
|
}
|
|
1008
1060
|
}
|
|
1061
|
+
async function dispatchAction(name, first, second) {
|
|
1062
|
+
const action = actions[name];
|
|
1063
|
+
const { input, options } = resolveActionInvocation(action, name, first, second);
|
|
1064
|
+
return invokeAction(name, input, options);
|
|
1065
|
+
}
|
|
1009
1066
|
const request = async (key, input, options) => {
|
|
1010
1067
|
if (key in actions) {
|
|
1011
|
-
|
|
1012
|
-
if (action.noRuntimeInput) {
|
|
1013
|
-
if (input === undefined || input === null) {
|
|
1014
|
-
return invokeAction(key, undefined, options ?? {});
|
|
1015
|
-
}
|
|
1016
|
-
if (options !== undefined) {
|
|
1017
|
-
return invokeAction(key, undefined, options);
|
|
1018
|
-
}
|
|
1019
|
-
if (isActionInvokeOptionsOnly(input)) {
|
|
1020
|
-
return invokeAction(key, undefined, input);
|
|
1021
|
-
}
|
|
1022
|
-
return invokeAction(key, undefined, {});
|
|
1023
|
-
}
|
|
1024
|
-
return invokeAction(key, input, options);
|
|
1068
|
+
return dispatchAction(key, input, options);
|
|
1025
1069
|
}
|
|
1026
1070
|
return invokeEndpoint(key, input ?? {});
|
|
1027
1071
|
};
|
|
@@ -1035,22 +1079,7 @@ function createApiClientImpl(apiConfig) {
|
|
|
1035
1079
|
return (input) => invokeEndpoint(prop, input ?? {});
|
|
1036
1080
|
}
|
|
1037
1081
|
if (prop in actions) {
|
|
1038
|
-
|
|
1039
|
-
if (action.noRuntimeInput) {
|
|
1040
|
-
return (first, second) => {
|
|
1041
|
-
if (first === undefined || first === null) {
|
|
1042
|
-
return invokeAction(prop, undefined, second ?? {});
|
|
1043
|
-
}
|
|
1044
|
-
if (second !== undefined) {
|
|
1045
|
-
return invokeAction(prop, undefined, second);
|
|
1046
|
-
}
|
|
1047
|
-
if (isActionInvokeOptionsOnly(first)) {
|
|
1048
|
-
return invokeAction(prop, undefined, first);
|
|
1049
|
-
}
|
|
1050
|
-
return invokeAction(prop, undefined, {});
|
|
1051
|
-
};
|
|
1052
|
-
}
|
|
1053
|
-
return (input, opt) => invokeAction(prop, input, opt);
|
|
1082
|
+
return (first, second) => dispatchAction(prop, first, second);
|
|
1054
1083
|
}
|
|
1055
1084
|
return;
|
|
1056
1085
|
}
|
|
@@ -1079,24 +1108,25 @@ function createApiClientImpl(apiConfig) {
|
|
|
1079
1108
|
}
|
|
1080
1109
|
var createApiClient = (apiConfig) => createApiClientImpl(apiConfig);
|
|
1081
1110
|
export {
|
|
1082
|
-
|
|
1083
|
-
isRequestValidationError,
|
|
1084
|
-
isRequestTimeoutError,
|
|
1085
|
-
isRequestAbortedError,
|
|
1086
|
-
isNetworkError,
|
|
1087
|
-
isHttpResponseError,
|
|
1088
|
-
isConfigError,
|
|
1089
|
-
isApiError,
|
|
1090
|
-
isActionError,
|
|
1091
|
-
defineAction,
|
|
1092
|
-
createApiClient,
|
|
1093
|
-
ResponseValidationError,
|
|
1094
|
-
RequestValidationError,
|
|
1095
|
-
RequestTimeoutError,
|
|
1096
|
-
RequestAbortedError,
|
|
1097
|
-
NetworkError,
|
|
1098
|
-
HttpResponseError,
|
|
1099
|
-
ConfigError,
|
|
1111
|
+
ActionError,
|
|
1100
1112
|
ApiError,
|
|
1101
|
-
|
|
1113
|
+
ConfigError,
|
|
1114
|
+
HttpResponseError,
|
|
1115
|
+
NetworkError,
|
|
1116
|
+
RequestAbortedError,
|
|
1117
|
+
RequestTimeoutError,
|
|
1118
|
+
RequestValidationError,
|
|
1119
|
+
ResponseValidationError,
|
|
1120
|
+
createApiClient,
|
|
1121
|
+
defineAction,
|
|
1122
|
+
isActionError,
|
|
1123
|
+
isApiError,
|
|
1124
|
+
isConfigError,
|
|
1125
|
+
isHttpResponseError,
|
|
1126
|
+
isNetworkError,
|
|
1127
|
+
isNonRetryableApiError,
|
|
1128
|
+
isRequestAbortedError,
|
|
1129
|
+
isRequestTimeoutError,
|
|
1130
|
+
isRequestValidationError,
|
|
1131
|
+
isResponseValidationError
|
|
1102
1132
|
};
|