@zayne-labs/callapi-plugins 4.0.34 → 4.0.35
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.
|
@@ -9,7 +9,7 @@ declare const fallBackRouteSchemaKey = "@default";
|
|
|
9
9
|
type FallBackRouteSchemaKey = typeof fallBackRouteSchemaKey;
|
|
10
10
|
//#endregion
|
|
11
11
|
//#endregion
|
|
12
|
-
//#region ../callapi/dist/index-
|
|
12
|
+
//#region ../callapi/dist/index-BEp4V3_c.d.ts
|
|
13
13
|
//#region src/types/type-helpers.d.ts
|
|
14
14
|
type AnyString = string & NonNullable<unknown>;
|
|
15
15
|
type AnyNumber = number & NonNullable<unknown>;
|
|
@@ -191,7 +191,7 @@ interface CallApiSchemaConfig {
|
|
|
191
191
|
/**
|
|
192
192
|
* The base url of the schema. By default it's the baseURL of the callApi instance.
|
|
193
193
|
*/
|
|
194
|
-
baseURL?:
|
|
194
|
+
baseURL?: "" | AnyString;
|
|
195
195
|
/**
|
|
196
196
|
* Disables runtime validation for the schema.
|
|
197
197
|
*/
|
|
@@ -199,17 +199,18 @@ interface CallApiSchemaConfig {
|
|
|
199
199
|
/**
|
|
200
200
|
* If `true`, the original input value will be used instead of the transformed/validated output.
|
|
201
201
|
*
|
|
202
|
-
*
|
|
203
|
-
*
|
|
202
|
+
* When true, the original input is returned unchanged after validation, ignoring any schema-level
|
|
203
|
+
* transformations such as type coercion, default values, or field mapping. Only the validation
|
|
204
|
+
* step is executed; the resulting value is discarded in favor of the raw input.
|
|
204
205
|
*/
|
|
205
|
-
|
|
206
|
+
disableRuntimeValidationTransform?: boolean | BooleanObject;
|
|
206
207
|
/**
|
|
207
208
|
* Optional url prefix that will be substituted for the `baseURL` of the schemaConfig at runtime.
|
|
208
209
|
*
|
|
209
|
-
*
|
|
210
|
-
*
|
|
210
|
+
* Enables a short, stable prefix for routes while keeping the full `baseURL` centralized in config.
|
|
211
|
+
* Keeps route definitions concise and shields them from changes to the underlying base URL.
|
|
211
212
|
*/
|
|
212
|
-
prefix?:
|
|
213
|
+
prefix?: "" | AnyString;
|
|
213
214
|
/**
|
|
214
215
|
* Controls the strictness of API route validation.
|
|
215
216
|
*
|
|
@@ -393,7 +394,8 @@ interface URLOptions {
|
|
|
393
394
|
* @description Makes a type partial if the output type of TSchema is not provided or has undefined in the union, otherwise makes it required
|
|
394
395
|
*/
|
|
395
396
|
type MakeSchemaOptionRequiredIfDefined<TSchemaOption extends CallApiSchema[keyof CallApiSchema], TObject> = undefined extends InferSchemaOutput<TSchemaOption, undefined> ? TObject : Required<TObject>;
|
|
396
|
-
type
|
|
397
|
+
type MergePrefixWithRouteKey<TPrefix extends string, TRouteKey extends string> = TRouteKey extends `@${infer TMethod extends RouteKeyMethods}/${infer TRestOfRoutKey}` ? `@${TMethod}/${TPrefix extends `/${infer TPrefixWithoutSlash}` ? TPrefixWithoutSlash : TPrefix}${TRestOfRoutKey}` : `${TPrefix}${TRouteKey}`;
|
|
398
|
+
type ApplyURLBasedConfig<TSchemaConfig extends CallApiSchemaConfig, TSchemaRouteKeys extends string> = TSchemaConfig["prefix"] extends string ? MergePrefixWithRouteKey<TSchemaConfig["prefix"], TSchemaRouteKeys> : TSchemaConfig["baseURL"] extends string ? MergePrefixWithRouteKey<TSchemaConfig["baseURL"], TSchemaRouteKeys> : TSchemaRouteKeys;
|
|
397
399
|
type ApplyStrictConfig<TSchemaConfig extends CallApiSchemaConfig, TSchemaRouteKeys extends string> = TSchemaConfig["strict"] extends true ? TSchemaRouteKeys :
|
|
398
400
|
// eslint-disable-next-line perfectionist/sort-union-types -- Don't sort union types
|
|
399
401
|
TSchemaRouteKeys | Exclude<InitURLOrURLObject, RouteKeyMethodsURLUnion>;
|
|
@@ -466,19 +468,40 @@ type InferAuthOption<TSchema extends CallApiSchema> = MakeSchemaOptionRequiredIf
|
|
|
466
468
|
*
|
|
467
469
|
* @example
|
|
468
470
|
* ```ts
|
|
469
|
-
*
|
|
470
|
-
*
|
|
471
|
-
*
|
|
472
|
-
*
|
|
473
|
-
*
|
|
474
|
-
*
|
|
471
|
+
* // Bearer auth
|
|
472
|
+
* const response = await callMainApi({
|
|
473
|
+
* url: "https://example.com/api/data",
|
|
474
|
+
* auth: "123456",
|
|
475
|
+
* });
|
|
476
|
+
*
|
|
477
|
+
* // Bearer auth
|
|
478
|
+
* const response = await callMainApi({
|
|
479
|
+
* url: "https://example.com/api/data",
|
|
480
|
+
* auth: {
|
|
481
|
+
* type: "Bearer",
|
|
482
|
+
* value: "123456",
|
|
483
|
+
* },
|
|
484
|
+
})
|
|
485
|
+
*
|
|
486
|
+
* // Token auth
|
|
487
|
+
* const response = await callMainApi({
|
|
488
|
+
* url: "https://example.com/api/data",
|
|
489
|
+
* auth: {
|
|
490
|
+
* type: "Token",
|
|
491
|
+
* value: "123456",
|
|
475
492
|
* },
|
|
476
493
|
* });
|
|
477
494
|
*
|
|
495
|
+
* // Basic auth
|
|
478
496
|
* const response = await callMainApi({
|
|
479
497
|
* url: "https://example.com/api/data",
|
|
480
|
-
* auth:
|
|
498
|
+
* auth: {
|
|
499
|
+
* type: "Basic",
|
|
500
|
+
* username: "username",
|
|
501
|
+
* password: "password",
|
|
502
|
+
* },
|
|
481
503
|
* });
|
|
504
|
+
*
|
|
482
505
|
* ```
|
|
483
506
|
*/
|
|
484
507
|
auth?: InferSchemaOutput<TSchema["auth"], AuthOption>;
|
|
@@ -1856,4 +1879,4 @@ declare const loggerPlugin: (options?: LoggerOptions) => {
|
|
|
1856
1879
|
};
|
|
1857
1880
|
//#endregion
|
|
1858
1881
|
export { defaultConsoleObject as n, loggerPlugin as r, LoggerOptions as t };
|
|
1859
|
-
//# sourceMappingURL=index-
|
|
1882
|
+
//# sourceMappingURL=index-2TQj4x49.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-2TQj4x49.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-2TQj4x49.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.35",
|
|
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.35"
|
|
28
28
|
},
|
|
29
29
|
"devDependencies": {
|
|
30
30
|
"@arethetypeswrong/cli": "0.18.2",
|
|
@@ -40,8 +40,8 @@
|
|
|
40
40
|
"size-limit": "12.0.0",
|
|
41
41
|
"tsdown": "0.18.0",
|
|
42
42
|
"typescript": "5.9.3",
|
|
43
|
-
"vitest": "^4.0.
|
|
44
|
-
"@zayne-labs/callapi": "1.11.
|
|
43
|
+
"vitest": "^4.0.16",
|
|
44
|
+
"@zayne-labs/callapi": "1.11.35"
|
|
45
45
|
},
|
|
46
46
|
"publishConfig": {
|
|
47
47
|
"access": "public",
|