@zayne-labs/callapi-plugins 4.0.40 → 4.0.42
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.
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { AnyFunction } from "@zayne-labs/toolkit-type-helpers";
|
|
2
2
|
|
|
3
|
-
//#region ../callapi/dist/index-
|
|
3
|
+
//#region ../callapi/dist/index-UfuQFNcf.d.ts
|
|
4
4
|
//#region src/constants/common.d.ts
|
|
5
5
|
declare const fetchSpecificKeys: readonly (keyof RequestInit | "duplex")[];
|
|
6
6
|
//#endregion
|
|
@@ -679,40 +679,41 @@ interface CallApiSchemaConfig {
|
|
|
679
679
|
*/
|
|
680
680
|
strict?: boolean;
|
|
681
681
|
}
|
|
682
|
+
type CallApiSchemaType<TInput> = StandardSchemaV1<TInput | undefined> | ((value: TInput) => Awaitable<TInput | undefined>);
|
|
682
683
|
interface CallApiSchema {
|
|
683
|
-
auth?:
|
|
684
|
+
auth?: CallApiSchemaType<AuthOption>;
|
|
684
685
|
/**
|
|
685
686
|
* The schema to use for validating the request body.
|
|
686
687
|
*/
|
|
687
|
-
body?:
|
|
688
|
+
body?: CallApiSchemaType<Body>;
|
|
688
689
|
/**
|
|
689
690
|
* The schema to use for validating the response data.
|
|
690
691
|
*/
|
|
691
|
-
data?:
|
|
692
|
+
data?: CallApiSchemaType<unknown>;
|
|
692
693
|
/**
|
|
693
694
|
* The schema to use for validating the response error data.
|
|
694
695
|
*/
|
|
695
|
-
errorData?:
|
|
696
|
+
errorData?: CallApiSchemaType<unknown>;
|
|
696
697
|
/**
|
|
697
698
|
* The schema to use for validating the request headers.
|
|
698
699
|
*/
|
|
699
|
-
headers?:
|
|
700
|
+
headers?: CallApiSchemaType<HeadersOption>;
|
|
700
701
|
/**
|
|
701
702
|
* The schema to use for validating the meta option.
|
|
702
703
|
*/
|
|
703
|
-
meta?:
|
|
704
|
+
meta?: CallApiSchemaType<GlobalMeta>;
|
|
704
705
|
/**
|
|
705
706
|
* The schema to use for validating the request method.
|
|
706
707
|
*/
|
|
707
|
-
method?:
|
|
708
|
+
method?: CallApiSchemaType<MethodUnion>;
|
|
708
709
|
/**
|
|
709
710
|
* The schema to use for validating the request url parameters.
|
|
710
711
|
*/
|
|
711
|
-
params?:
|
|
712
|
+
params?: CallApiSchemaType<Params>;
|
|
712
713
|
/**
|
|
713
714
|
* The schema to use for validating the request url queries.
|
|
714
715
|
*/
|
|
715
|
-
query?:
|
|
716
|
+
query?: CallApiSchemaType<Query>;
|
|
716
717
|
}
|
|
717
718
|
declare const routeKeyMethods: readonly ["delete", "get", "patch", "post", "put"];
|
|
718
719
|
type RouteKeyMethods = (typeof routeKeyMethods)[number];
|
|
@@ -731,7 +732,7 @@ type AllowedQueryParamValues = UnmaskType<boolean | number | string>;
|
|
|
731
732
|
type RecordStyleParams = UnmaskType<Record<string, AllowedQueryParamValues>>;
|
|
732
733
|
type TupleStyleParams = UnmaskType<AllowedQueryParamValues[]>;
|
|
733
734
|
type Params = UnmaskType<RecordStyleParams | TupleStyleParams>;
|
|
734
|
-
type Query = UnmaskType<Record<string, AllowedQueryParamValues
|
|
735
|
+
type Query = UnmaskType<Record<string, AllowedQueryParamValues> | URLSearchParams>;
|
|
735
736
|
type InitURLOrURLObject = AnyString | RouteKeyMethodsURLUnion | URL;
|
|
736
737
|
interface URLOptions {
|
|
737
738
|
/**
|
|
@@ -857,8 +858,8 @@ type ApplyStrictConfig<TSchemaConfig extends CallApiSchemaConfig, TSchemaRouteKe
|
|
|
857
858
|
// eslint-disable-next-line perfectionist/sort-union-types -- Don't sort union types
|
|
858
859
|
TSchemaRouteKeys | Exclude<InitURLOrURLObject, RouteKeyMethodsURLUnion>;
|
|
859
860
|
type ApplySchemaConfiguration<TSchemaConfig extends CallApiSchemaConfig, TSchemaRouteKeys extends string> = ApplyStrictConfig<TSchemaConfig, ApplyURLBasedConfig<TSchemaConfig, TSchemaRouteKeys>>;
|
|
860
|
-
type
|
|
861
|
-
type InferInitURL<TBaseSchemaRoutes extends BaseCallApiSchemaRoutes, TSchemaConfig extends CallApiSchemaConfig> = keyof TBaseSchemaRoutes extends never ? InitURLOrURLObject :
|
|
861
|
+
type InferAllMainRouteKeys<TBaseSchemaRoutes extends BaseCallApiSchemaRoutes, TSchemaConfig extends CallApiSchemaConfig> = ApplySchemaConfiguration<TSchemaConfig, Exclude<Extract<keyof TBaseSchemaRoutes, string>, FallBackRouteSchemaKey>>;
|
|
862
|
+
type InferInitURL<TBaseSchemaRoutes extends BaseCallApiSchemaRoutes, TSchemaConfig extends CallApiSchemaConfig> = keyof TBaseSchemaRoutes extends never ? InitURLOrURLObject : InferAllMainRouteKeys<TBaseSchemaRoutes, TSchemaConfig>;
|
|
862
863
|
type GetCurrentRouteSchema<TBaseSchemaRoutes extends BaseCallApiSchemaRoutes, TCurrentRouteSchemaKey extends string, TComputedFallBackRouteSchema = TBaseSchemaRoutes[FallBackRouteSchemaKey], TComputedCurrentRouteSchema = TBaseSchemaRoutes[TCurrentRouteSchemaKey], TComputedRouteSchema extends CallApiSchema = NonNullable<Omit<TComputedFallBackRouteSchema, keyof TComputedCurrentRouteSchema> & TComputedCurrentRouteSchema>> = TComputedRouteSchema extends CallApiSchema ? Writeable<TComputedRouteSchema, "deep"> : CallApiSchema;
|
|
863
864
|
type JsonPrimitive = boolean | number | string | null | undefined;
|
|
864
865
|
type SerializableObject = Record<PropertyKey, unknown>;
|
|
@@ -992,11 +993,11 @@ type ResultModeOption<TErrorData, TResultMode extends ResultModeType> = TErrorDa
|
|
|
992
993
|
} : {
|
|
993
994
|
resultMode?: TResultMode;
|
|
994
995
|
};
|
|
995
|
-
type
|
|
996
|
-
type ThrowOnErrorType<TErrorData, TThrowOnError extends
|
|
996
|
+
type ThrowOnErrorBoolean = boolean;
|
|
997
|
+
type ThrowOnErrorType<TErrorData, TThrowOnError extends ThrowOnErrorBoolean> = TThrowOnError | ((context: ErrorContext<{
|
|
997
998
|
ErrorData: TErrorData;
|
|
998
999
|
}>) => TThrowOnError);
|
|
999
|
-
type ThrowOnErrorOption<TErrorData, TThrowOnError extends
|
|
1000
|
+
type ThrowOnErrorOption<TErrorData, TThrowOnError extends ThrowOnErrorBoolean> = TErrorData extends false ? {
|
|
1000
1001
|
throwOnError: true;
|
|
1001
1002
|
} : TErrorData extends false | undefined ? {
|
|
1002
1003
|
throwOnError?: true;
|
|
@@ -1086,7 +1087,7 @@ type ValidationErrorDetails = {
|
|
|
1086
1087
|
*
|
|
1087
1088
|
* It's either the name the schema for which validation failed, or the name of the schema config option that led to the validation error.
|
|
1088
1089
|
*/
|
|
1089
|
-
issueCause: "unknown" | `schemaConfig-(${SafeExtract<keyof CallApiSchemaConfig, "strict">})` | keyof CallApiSchema;
|
|
1090
|
+
issueCause: "toFormData" | "toQueryString" | "unknown" | `schemaConfig-(${SafeExtract<keyof CallApiSchemaConfig, "strict">})` | keyof CallApiSchema;
|
|
1090
1091
|
/**
|
|
1091
1092
|
* The issues that caused the validation error.
|
|
1092
1093
|
*/
|
|
@@ -1144,9 +1145,9 @@ type CallApiRequestOptions = {
|
|
|
1144
1145
|
method?: MethodUnion;
|
|
1145
1146
|
} & Pick<ModifiedRequestInit, FetchSpecificKeysUnion>;
|
|
1146
1147
|
type CallApiRequestOptionsForHooks = Omit<CallApiRequestOptions, "headers"> & {
|
|
1147
|
-
headers: Record<
|
|
1148
|
+
headers: Record<"Authorization" | "Content-Type" | CommonRequestHeaders, string | undefined>;
|
|
1148
1149
|
};
|
|
1149
|
-
type SharedExtraOptions<TCallApiContext extends CallApiContext = DefaultCallApiContext, TData = DefaultDataType, TErrorData = DefaultDataType, TResultMode extends ResultModeType = ResultModeType, TThrowOnError extends
|
|
1150
|
+
type SharedExtraOptions<TCallApiContext extends CallApiContext = DefaultCallApiContext, TData = DefaultDataType, TErrorData = DefaultDataType, TResultMode extends ResultModeType = ResultModeType, TThrowOnError extends ThrowOnErrorBoolean = DefaultThrowOnError, TResponseType extends ResponseTypeType = ResponseTypeType, TPluginArray extends CallApiPlugin[] = DefaultPluginArray, TComputedMergedPluginExtraOptions = Partial<InferPluginExtraOptions<TPluginArray> & InferSchemaOutput<TCallApiContext["InferredExtraOptions"], TCallApiContext["InferredExtraOptions"]>>, TComputedCallApiContext extends CallApiContext = OverrideCallApiContext<TCallApiContext, {
|
|
1150
1151
|
Data: TData;
|
|
1151
1152
|
ErrorData: TErrorData;
|
|
1152
1153
|
InferredExtraOptions: TComputedMergedPluginExtraOptions;
|
|
@@ -1172,7 +1173,7 @@ type SharedExtraOptions<TCallApiContext extends CallApiContext = DefaultCallApiC
|
|
|
1172
1173
|
* ```ts
|
|
1173
1174
|
* // Custom form data serialization
|
|
1174
1175
|
* bodySerializer: (data) => {
|
|
1175
|
-
* const formData = new
|
|
1176
|
+
* const formData = new FormData();
|
|
1176
1177
|
* Object.entries(data).forEach(([key, value]) => {
|
|
1177
1178
|
* formData.append(key, String(value));
|
|
1178
1179
|
* });
|
|
@@ -1334,20 +1335,20 @@ type SharedExtraOptions<TCallApiContext extends CallApiContext = DefaultCallApiC
|
|
|
1334
1335
|
*
|
|
1335
1336
|
* @example
|
|
1336
1337
|
* ```ts
|
|
1337
|
-
* responseParser: (
|
|
1338
|
-
* return JSON.parse(
|
|
1338
|
+
* responseParser: (text) => {
|
|
1339
|
+
* return JSON.parse(text);
|
|
1339
1340
|
* }
|
|
1340
1341
|
*
|
|
1341
1342
|
* // Parse XML responses
|
|
1342
|
-
* responseParser: (
|
|
1343
|
+
* responseParser: (text) => {
|
|
1343
1344
|
* const parser = new DOMParser();
|
|
1344
|
-
* const doc = parser.parseFromString(
|
|
1345
|
+
* const doc = parser.parseFromString(text, "text/xml");
|
|
1345
1346
|
* return xmlToObject(doc);
|
|
1346
1347
|
* }
|
|
1347
1348
|
*
|
|
1348
1349
|
* // Parse CSV responses
|
|
1349
|
-
* responseParser: (
|
|
1350
|
-
* const lines =
|
|
1350
|
+
* responseParser: (text) => {
|
|
1351
|
+
* const lines = text.split('\n');
|
|
1351
1352
|
* const headers = lines[0].split(',');
|
|
1352
1353
|
* const data = lines.slice(1).map(line => {
|
|
1353
1354
|
* const values = line.split(',');
|
|
@@ -1361,7 +1362,7 @@ type SharedExtraOptions<TCallApiContext extends CallApiContext = DefaultCallApiC
|
|
|
1361
1362
|
*
|
|
1362
1363
|
* ```
|
|
1363
1364
|
*/
|
|
1364
|
-
responseParser?:
|
|
1365
|
+
responseParser?: ResponseParser<TData>;
|
|
1365
1366
|
/**
|
|
1366
1367
|
* Expected response type, determines how the response body is parsed.
|
|
1367
1368
|
*
|
|
@@ -1398,58 +1399,23 @@ type SharedExtraOptions<TCallApiContext extends CallApiContext = DefaultCallApiC
|
|
|
1398
1399
|
*/
|
|
1399
1400
|
responseType?: TResponseType;
|
|
1400
1401
|
/**
|
|
1401
|
-
*
|
|
1402
|
+
* Dictates how CallApi processes and returns the final result
|
|
1402
1403
|
*
|
|
1403
|
-
|
|
1404
|
-
|
|
1405
|
-
|
|
1404
|
+
- **"all"** (default): Returns `{ data, error, response }`. Standard lifecycle.
|
|
1405
|
+
- **"onlyData"**: Returns only the data from the response.
|
|
1406
|
+
- **"onlyResponse"**: Returns only the `Response` object.
|
|
1407
|
+
- **"fetchApi"**: Also returns only the `Response` object, but also skips parsing of the response body internally and data/errorData schema validation.
|
|
1408
|
+
- **"withoutResponse"**: Returns `{ data, error }`. Standard lifecycle, but omits the `response` property.
|
|
1406
1409
|
*
|
|
1407
|
-
* When combined with throwOnError: true, null/error variants are automatically removed:
|
|
1408
|
-
* - **"all" + throwOnError: true**: Returns { data, error: null, response } (error property is null, throws instead)
|
|
1409
|
-
* - **"onlyData" + throwOnError: true**: Returns data (never null, throws on error)
|
|
1410
1410
|
*
|
|
1411
|
-
*
|
|
1411
|
+
* **Note:**
|
|
1412
|
+
* By default, simplified modes (`"onlyData"`, `"onlyResponse"`, `"fetchApi"`) do not throw errors.
|
|
1413
|
+
* Success/failure should be handled via hooks or by checking the return value (e.g., `if (data)` or `if (response?.ok)`).
|
|
1414
|
+
* To force an exception instead, set `throwOnError: true`.
|
|
1412
1415
|
*
|
|
1413
|
-
* @example
|
|
1414
|
-
* ```ts
|
|
1415
|
-
* // Complete result with all information (default)
|
|
1416
|
-
* const { data, error, response } = await callApi("/users", { resultMode: "all" });
|
|
1417
|
-
* if (error) {
|
|
1418
|
-
* console.error("Request failed:", error);
|
|
1419
|
-
* } else {
|
|
1420
|
-
* console.log("Users:", data);
|
|
1421
|
-
* }
|
|
1422
1416
|
*
|
|
1423
|
-
*
|
|
1424
|
-
* try {
|
|
1425
|
-
* const { data, response } = await callApi("/users", {
|
|
1426
|
-
* resultMode: "all",
|
|
1427
|
-
* throwOnError: true
|
|
1428
|
-
* });
|
|
1429
|
-
* console.log("Users:", data); // data is never null here
|
|
1430
|
-
* } catch (error) {
|
|
1431
|
-
* console.error("Request failed:", error);
|
|
1432
|
-
* }
|
|
1433
|
-
*
|
|
1434
|
-
* // Only data, returns null on errors
|
|
1435
|
-
* const users = await callApi("/users", { resultMode: "onlyData" });
|
|
1436
|
-
* if (users) {
|
|
1437
|
-
* console.log("Users:", users);
|
|
1438
|
-
* } else {
|
|
1439
|
-
* console.log("Request failed");
|
|
1440
|
-
* }
|
|
1417
|
+
* @default "all"
|
|
1441
1418
|
*
|
|
1442
|
-
* // Only data, throws on errors (throwOnError removes null from type)
|
|
1443
|
-
* try {
|
|
1444
|
-
* const users = await callApi("/users", {
|
|
1445
|
-
* resultMode: "onlyData",
|
|
1446
|
-
* throwOnError: true
|
|
1447
|
-
* });
|
|
1448
|
-
* console.log("Users:", users); // users is never null here
|
|
1449
|
-
* } catch (error) {
|
|
1450
|
-
* console.error("Request failed:", error);
|
|
1451
|
-
* }
|
|
1452
|
-
* ```
|
|
1453
1419
|
*/
|
|
1454
1420
|
resultMode?: TResultMode;
|
|
1455
1421
|
/**
|
|
@@ -1522,7 +1488,7 @@ type SharedExtraOptions<TCallApiContext extends CallApiContext = DefaultCallApiC
|
|
|
1522
1488
|
*/
|
|
1523
1489
|
timeout?: number;
|
|
1524
1490
|
};
|
|
1525
|
-
type BaseCallApiExtraOptions<TBaseCallApiContext extends CallApiContext = DefaultCallApiContext, TBaseData = DefaultDataType, TBaseErrorData = DefaultDataType, TBaseResultMode extends ResultModeType = ResultModeType, TBaseThrowOnError extends
|
|
1491
|
+
type BaseCallApiExtraOptions<TBaseCallApiContext extends CallApiContext = DefaultCallApiContext, TBaseData = DefaultDataType, TBaseErrorData = DefaultDataType, TBaseResultMode extends ResultModeType = ResultModeType, TBaseThrowOnError extends ThrowOnErrorBoolean = DefaultThrowOnError, TBaseResponseType extends ResponseTypeType = ResponseTypeType, TBasePluginArray extends CallApiPlugin[] = DefaultPluginArray, TBaseSchemaAndConfig extends BaseCallApiSchemaAndConfig = BaseCallApiSchemaAndConfig> = SharedExtraOptions<TBaseCallApiContext, TBaseData, TBaseErrorData, TBaseResultMode, TBaseThrowOnError, TBaseResponseType, TBasePluginArray> & {
|
|
1526
1492
|
/**
|
|
1527
1493
|
* Array of base CallApi plugins to extend library functionality.
|
|
1528
1494
|
*
|
|
@@ -1633,7 +1599,7 @@ type GetExtendSchemaConfigContext<TBaseSchemaConfig extends CallApiSchemaConfig>
|
|
|
1633
1599
|
type InferExtendPluginContext<TBasePluginArray extends CallApiPlugin[]> = {
|
|
1634
1600
|
basePlugins: TBasePluginArray;
|
|
1635
1601
|
};
|
|
1636
|
-
type CallApiExtraOptions<TCallApiContext extends CallApiContext = DefaultCallApiContext, TData = DefaultDataType, TErrorData = DefaultDataType, TResultMode extends ResultModeType = ResultModeType, TThrowOnError extends
|
|
1602
|
+
type CallApiExtraOptions<TCallApiContext extends CallApiContext = DefaultCallApiContext, TData = DefaultDataType, TErrorData = DefaultDataType, TResultMode extends ResultModeType = ResultModeType, TThrowOnError extends ThrowOnErrorBoolean = DefaultThrowOnError, TResponseType extends ResponseTypeType = ResponseTypeType, TBasePluginArray extends CallApiPlugin[] = DefaultPluginArray, TPluginArray extends CallApiPlugin[] = DefaultPluginArray, TBaseSchemaRoutes extends BaseCallApiSchemaRoutes = BaseCallApiSchemaRoutes, TSchema extends CallApiSchema = CallApiSchema, TBaseSchemaConfig extends CallApiSchemaConfig = CallApiSchemaConfig, TSchemaConfig extends CallApiSchemaConfig = CallApiSchemaConfig, TCurrentRouteSchemaKey extends string = string> = SharedExtraOptions<TCallApiContext, TData, TErrorData, TResultMode, TThrowOnError, TResponseType, TPluginArray> & {
|
|
1637
1603
|
/**
|
|
1638
1604
|
* Array of instance-specific CallApi plugins or a function to configure plugins.
|
|
1639
1605
|
*
|
|
@@ -1667,20 +1633,20 @@ type InstanceContext = {
|
|
|
1667
1633
|
options: CallApiExtraOptions;
|
|
1668
1634
|
request: CallApiRequestOptions;
|
|
1669
1635
|
};
|
|
1670
|
-
type BaseCallApiConfig<TBaseCallApiContext extends CallApiContext = DefaultCallApiContext, TBaseData = DefaultDataType, TBaseErrorData = DefaultDataType, TBaseResultMode extends ResultModeType = ResultModeType, TBaseThrowOnError extends
|
|
1671
|
-
type CallApiConfig<TCallApiContext extends CallApiContext = DefaultCallApiContext, TData = DefaultDataType, TErrorData = DefaultDataType, TResultMode extends ResultModeType = ResultModeType, TThrowOnError extends
|
|
1636
|
+
type BaseCallApiConfig<TBaseCallApiContext extends CallApiContext = DefaultCallApiContext, TBaseData = DefaultDataType, TBaseErrorData = DefaultDataType, TBaseResultMode extends ResultModeType = ResultModeType, TBaseThrowOnError extends ThrowOnErrorBoolean = DefaultThrowOnError, TBaseResponseType extends ResponseTypeType = ResponseTypeType, TBaseSchemaAndConfig extends BaseCallApiSchemaAndConfig = BaseCallApiSchemaAndConfig, TBasePluginArray extends CallApiPlugin[] = DefaultPluginArray, TComputedBaseConfig = BaseCallApiExtraOptions<TBaseCallApiContext, TBaseData, TBaseErrorData, TBaseResultMode, TBaseThrowOnError, TBaseResponseType, TBasePluginArray, TBaseSchemaAndConfig>> = (CallApiRequestOptions & TComputedBaseConfig) | ((context: InstanceContext) => CallApiRequestOptions & TComputedBaseConfig);
|
|
1637
|
+
type CallApiConfig<TCallApiContext extends CallApiContext = DefaultCallApiContext, TData = DefaultDataType, TErrorData = DefaultDataType, TResultMode extends ResultModeType = ResultModeType, TThrowOnError extends ThrowOnErrorBoolean = DefaultThrowOnError, TResponseType extends ResponseTypeType = ResponseTypeType, TBaseSchemaRoutes extends BaseCallApiSchemaRoutes = BaseCallApiSchemaRoutes, TSchema extends CallApiSchema = CallApiSchema, TBaseSchemaConfig extends CallApiSchemaConfig = CallApiSchemaConfig, TSchemaConfig extends CallApiSchemaConfig = CallApiSchemaConfig, TInitURL extends InitURLOrURLObject = InitURLOrURLObject, TCurrentRouteSchemaKey extends string = string, TBasePluginArray extends CallApiPlugin[] = DefaultPluginArray, TPluginArray extends CallApiPlugin[] = DefaultPluginArray> = InferExtraOptions<TSchema, TBaseSchemaRoutes, TCurrentRouteSchemaKey, TCallApiContext> & InferRequestOptions<TSchema, TInitURL> & Omit<CallApiExtraOptions<TCallApiContext, TData, TErrorData, TResultMode, TThrowOnError, TResponseType, TBasePluginArray, TPluginArray, TBaseSchemaRoutes, TSchema, TBaseSchemaConfig, TSchemaConfig, TCurrentRouteSchemaKey>, keyof InferExtraOptions<CallApiSchema, BaseCallApiSchemaRoutes, string, CallApiContext>> & Omit<CallApiRequestOptions, keyof InferRequestOptions<CallApiSchema, string>>;
|
|
1672
1638
|
//#endregion
|
|
1673
1639
|
//#region src/result.d.ts
|
|
1674
|
-
type
|
|
1675
|
-
declare const getResponseType: <
|
|
1640
|
+
type ResponseParser<TData> = (text: string) => Awaitable<TData>;
|
|
1641
|
+
declare const getResponseType: <TData>(response: Response, responseParser: ResponseParser<TData>) => {
|
|
1676
1642
|
arrayBuffer: () => Promise<ArrayBuffer>;
|
|
1677
1643
|
blob: () => Promise<Blob>;
|
|
1678
1644
|
formData: () => Promise<FormData>;
|
|
1679
|
-
json: () => Promise<
|
|
1645
|
+
json: () => Promise<TData>;
|
|
1680
1646
|
stream: () => ReadableStream<Uint8Array<ArrayBuffer>> | null;
|
|
1681
1647
|
text: () => Promise<string>;
|
|
1682
1648
|
};
|
|
1683
|
-
type InitResponseTypeMap<
|
|
1649
|
+
type InitResponseTypeMap<TData = unknown> = ReturnType<typeof getResponseType<TData>>;
|
|
1684
1650
|
type ResponseTypeUnion = keyof InitResponseTypeMap;
|
|
1685
1651
|
type ResponseTypePlaceholder = null;
|
|
1686
1652
|
type ResponseTypeType = ResponseTypePlaceholder | ResponseTypeUnion;
|
|
@@ -1722,8 +1688,10 @@ type CallApiResultErrorVariant<TErrorData> = {
|
|
|
1722
1688
|
response: Response | null;
|
|
1723
1689
|
};
|
|
1724
1690
|
type CallApiResultSuccessOrErrorVariant<TData, TError> = CallApiResultErrorVariant<TError> | CallApiResultSuccessVariant<TData>;
|
|
1725
|
-
type
|
|
1691
|
+
type GetCallApiResult<TThrowOnError extends ThrowOnErrorBoolean, TResultWithException extends CallApiResultSuccessVariant<unknown>, TResultWithoutException extends CallApiResultSuccessOrErrorVariant<unknown, unknown>> = TThrowOnError extends true ? TResultWithException : TResultWithoutException;
|
|
1692
|
+
type ResultModeMap<TData = DefaultDataType, TErrorData = DefaultDataType, TThrowOnError extends ThrowOnErrorBoolean = DefaultThrowOnError, TComputedResult extends GetCallApiResult<TThrowOnError, CallApiResultSuccessVariant<TData>, CallApiResultSuccessOrErrorVariant<TData, TErrorData>> = GetCallApiResult<TThrowOnError, CallApiResultSuccessVariant<TData>, CallApiResultSuccessOrErrorVariant<TData, TErrorData>>> = UnmaskType<{
|
|
1726
1693
|
all: TComputedResult;
|
|
1694
|
+
fetchApi: TComputedResult["response"];
|
|
1727
1695
|
onlyData: TComputedResult["data"];
|
|
1728
1696
|
onlyResponse: TComputedResult["response"];
|
|
1729
1697
|
withoutResponse: Prettify<DistributiveOmit<TComputedResult, "response">>;
|
|
@@ -1761,7 +1729,7 @@ interface CallApiPlugin<TCallApiContext extends CallApiContext = DefaultCallApiC
|
|
|
1761
1729
|
/**
|
|
1762
1730
|
* Hooks for the plugin
|
|
1763
1731
|
*/
|
|
1764
|
-
hooks?: PluginHooks<TCallApiContext> | ((context: PluginSetupContext<TCallApiContext>) => Awaitable<PluginHooks<TCallApiContext>>);
|
|
1732
|
+
hooks?: PluginHooks<TCallApiContext> | ((context: PluginSetupContext<TCallApiContext>) => Awaitable<PluginHooks<TCallApiContext>> | Awaitable<void>);
|
|
1765
1733
|
/**
|
|
1766
1734
|
* A unique id for the plugin
|
|
1767
1735
|
*/
|
|
@@ -1769,7 +1737,7 @@ interface CallApiPlugin<TCallApiContext extends CallApiContext = DefaultCallApiC
|
|
|
1769
1737
|
/**
|
|
1770
1738
|
* Middlewares that for the plugin
|
|
1771
1739
|
*/
|
|
1772
|
-
middlewares?: PluginMiddlewares<TCallApiContext> | ((context: PluginSetupContext<TCallApiContext>) => Awaitable<PluginMiddlewares<TCallApiContext>>);
|
|
1740
|
+
middlewares?: PluginMiddlewares<TCallApiContext> | ((context: PluginSetupContext<TCallApiContext>) => Awaitable<PluginMiddlewares<TCallApiContext>> | Awaitable<void>);
|
|
1773
1741
|
/**
|
|
1774
1742
|
* A name for the plugin
|
|
1775
1743
|
*/
|
|
@@ -1924,4 +1892,4 @@ declare const loggerPlugin: (options?: LoggerOptions) => {
|
|
|
1924
1892
|
};
|
|
1925
1893
|
//#endregion
|
|
1926
1894
|
export { defaultConsoleObject as n, loggerPlugin as r, LoggerOptions as t };
|
|
1927
|
-
//# sourceMappingURL=index-
|
|
1895
|
+
//# sourceMappingURL=index-C01h-7d8.d.ts.map
|
package/dist/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { n as defaultConsoleObject, r as loggerPlugin, t as LoggerOptions } from "./index-
|
|
1
|
+
import { n as defaultConsoleObject, r as loggerPlugin, t as LoggerOptions } from "./index-C01h-7d8.js";
|
|
2
2
|
export { LoggerOptions, defaultConsoleObject, loggerPlugin };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { n as defaultConsoleObject, r as loggerPlugin, t as LoggerOptions } from "../../index-
|
|
1
|
+
import { n as defaultConsoleObject, r as loggerPlugin, t as LoggerOptions } from "../../index-C01h-7d8.js";
|
|
2
2
|
export { LoggerOptions, defaultConsoleObject, loggerPlugin };
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zayne-labs/callapi-plugins",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "4.0.
|
|
4
|
+
"version": "4.0.42",
|
|
5
5
|
"description": "A collection of plugins for callapi",
|
|
6
6
|
"author": "Ryan Zayne",
|
|
7
7
|
"license": "MIT",
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
"peerDependencies": {
|
|
25
25
|
"@zayne-labs/toolkit-type-helpers": ">=0.11.17",
|
|
26
26
|
"consola": "3.x.x",
|
|
27
|
-
"@zayne-labs/callapi": "1.11.
|
|
27
|
+
"@zayne-labs/callapi": "1.11.42"
|
|
28
28
|
},
|
|
29
29
|
"devDependencies": {
|
|
30
30
|
"@arethetypeswrong/cli": "0.18.2",
|
|
@@ -41,7 +41,7 @@
|
|
|
41
41
|
"tsdown": "0.19.0-beta.3",
|
|
42
42
|
"typescript": "5.9.3",
|
|
43
43
|
"vitest": "^4.0.16",
|
|
44
|
-
"@zayne-labs/callapi": "1.11.
|
|
44
|
+
"@zayne-labs/callapi": "1.11.42"
|
|
45
45
|
},
|
|
46
46
|
"publishConfig": {
|
|
47
47
|
"access": "public",
|