@zayne-labs/callapi-plugins 4.0.32 → 4.0.34

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-BDKB03qO.d.ts
12
+ //#region ../callapi/dist/index-YnlEWnbR.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>;
@@ -46,14 +46,13 @@ type CommonContentTypes = "application/epub+zip" | "application/gzip" | "applica
46
46
  //#region src/auth.d.ts
47
47
  type PossibleAuthValue = Awaitable<string | null | undefined>;
48
48
  type PossibleAuthValueOrGetter = PossibleAuthValue | (() => PossibleAuthValue);
49
- type BearerOrTokenAuth = {
50
- type?: "Bearer";
51
- bearer?: PossibleAuthValueOrGetter;
52
- token?: never;
53
- } | {
54
- type?: "Token";
55
- bearer?: never;
56
- token?: PossibleAuthValueOrGetter;
49
+ type BearerAuth = {
50
+ type: "Bearer";
51
+ value: PossibleAuthValueOrGetter;
52
+ };
53
+ type TokenAuth = {
54
+ type: "Token";
55
+ value: PossibleAuthValueOrGetter;
57
56
  };
58
57
  type BasicAuth = {
59
58
  type: "Basic";
@@ -80,7 +79,7 @@ type CustomAuth = {
80
79
  prefix: PossibleAuthValueOrGetter;
81
80
  value: PossibleAuthValueOrGetter;
82
81
  };
83
- type Auth = PossibleAuthValueOrGetter | BearerOrTokenAuth | BasicAuth | CustomAuth;
82
+ type AuthOption = PossibleAuthValueOrGetter | BearerAuth | TokenAuth | BasicAuth | CustomAuth;
84
83
  //#endregion
85
84
  //#region src/stream.d.ts
86
85
  type StreamProgressEvent = {
@@ -107,99 +106,80 @@ type StreamProgressEvent = {
107
106
  * The Standard Schema interface.
108
107
  * @see https://github.com/standard-schema/standard-schema
109
108
  */
110
- interface StandardSchemaV1<Input = unknown, Output = Input> {
111
- /**
112
- * The Standard Schema properties.
113
- */
114
- readonly "~standard": StandardSchemaV1.Props<Input, Output>;
109
+ /** The Standard Typed interface. This is a base type extended by other specs. */
110
+ interface StandardTypedV1<Input = unknown, Output = Input> {
111
+ /** The Standard properties. */
112
+ readonly "~standard": StandardTypedV1.Props<Input, Output>;
115
113
  }
116
- declare namespace StandardSchemaV1 {
117
- /**
118
- * The Standard Schema properties interface.
119
- */
114
+ declare namespace StandardTypedV1 {
115
+ /** The Standard Typed properties interface. */
120
116
  interface Props<Input = unknown, Output = Input> {
121
- /**
122
- * Inferred types associated with the schema.
123
- */
117
+ /** Inferred types associated with the schema. */
124
118
  readonly types?: Types<Input, Output> | undefined;
125
- /**
126
- * Validates unknown input values.
127
- */
128
- readonly validate: (value: unknown) => Promise<Result<Output>> | Result<Output>;
129
- /**
130
- * The vendor name of the schema library.
131
- */
119
+ /** The vendor name of the schema library. */
132
120
  readonly vendor: string;
133
- /**
134
- * The version number of the standard.
135
- */
121
+ /** The version number of the standard. */
136
122
  readonly version: 1;
137
123
  }
138
- /**
139
- * The result interface of the validate function.
140
- */
124
+ /** The Standard Typed types interface. */
125
+ interface Types<Input = unknown, Output = Input> {
126
+ /** The input type of the schema. */
127
+ readonly input: Input;
128
+ /** The output type of the schema. */
129
+ readonly output: Output;
130
+ }
131
+ /** Infers the input type of a Standard Typed. */
132
+ type InferInput<Schema extends StandardTypedV1> = NonNullable<Schema["~standard"]["types"]>["input"];
133
+ /** Infers the output type of a Standard Typed. */
134
+ type InferOutput<Schema extends StandardTypedV1> = NonNullable<Schema["~standard"]["types"]>["output"];
135
+ }
136
+ /** The Standard Schema interface. */
137
+ interface StandardSchemaV1<Input = unknown, Output = Input> {
138
+ /** The Standard Schema properties. */
139
+ readonly "~standard": StandardSchemaV1.Props<Input, Output>;
140
+ }
141
+ declare namespace StandardSchemaV1 {
142
+ /** The Standard Schema properties interface. */
143
+ interface Props<Input = unknown, Output = Input> extends StandardTypedV1.Props<Input, Output> {
144
+ /** Validates unknown input values. */
145
+ readonly validate: (value: unknown, options?: StandardSchemaV1.Options) => Promise<Result<Output>> | Result<Output>;
146
+ }
147
+ /** The result interface of the validate function. */
141
148
  type Result<Output> = FailureResult | SuccessResult<Output>;
142
- /**
143
- * The result interface if validation succeeds.
144
- */
149
+ /** The result interface if validation succeeds. */
145
150
  interface SuccessResult<Output> {
146
- /**
147
- * The non-existent issues.
148
- */
151
+ /** A falsy value for `issues` indicates success. */
149
152
  readonly issues?: undefined;
150
- /**
151
- * The typed output value.
152
- */
153
+ /** The typed output value. */
153
154
  readonly value: Output;
154
155
  }
155
- /**
156
- * The result interface if validation fails.
157
- */
156
+ interface Options {
157
+ /** Explicit support for additional vendor-specific parameters, if needed. */
158
+ readonly libraryOptions?: Record<string, unknown> | undefined;
159
+ }
160
+ /** The result interface if validation fails. */
158
161
  interface FailureResult {
159
- /**
160
- * The issues of failed validation.
161
- */
162
+ /** The issues of failed validation. */
162
163
  readonly issues: readonly Issue[];
163
164
  }
164
- /**
165
- * The issue interface of the failure output.
166
- */
165
+ /** The issue interface of the failure output. */
167
166
  interface Issue {
168
- /**
169
- * The error message of the issue.
170
- */
167
+ /** The error message of the issue. */
171
168
  readonly message: string;
172
- /**
173
- * The path of the issue, if any.
174
- */
169
+ /** The path of the issue, if any. */
175
170
  readonly path?: ReadonlyArray<PathSegment | PropertyKey> | undefined;
176
171
  }
177
- /**
178
- * The path segment interface of the issue.
179
- */
172
+ /** The path segment interface of the issue. */
180
173
  interface PathSegment {
181
- /**
182
- * The key representing a path segment.
183
- */
174
+ /** The key representing a path segment. */
184
175
  readonly key: PropertyKey;
185
176
  }
186
- /**
187
- * The Standard Schema types interface.
188
- */
189
- interface Types<Input = unknown, Output = Input> {
190
- /** The input type of the schema. */
191
- readonly input: Input;
192
- /** The output type of the schema. */
193
- readonly output: Output;
194
- }
195
- /**
196
- * Infers the input type of a Standard Schema.
197
- */
198
- type InferInput<Schema extends StandardSchemaV1> = NonNullable<Schema["~standard"]["types"]>["input"];
199
- /**
200
- * Infers the output type of a Standard Schema.
201
- */
202
- type InferOutput<Schema extends StandardSchemaV1> = NonNullable<Schema["~standard"]["types"]>["output"];
177
+ /** The Standard types interface. */
178
+ type Types<Input = unknown, Output = Input> = StandardTypedV1.Types<Input, Output>;
179
+ /** Infers the input type of a Standard. */
180
+ type InferInput<Schema extends StandardTypedV1> = StandardTypedV1.InferInput<Schema>;
181
+ /** Infers the output type of a Standard. */
182
+ type InferOutput<Schema extends StandardTypedV1> = StandardTypedV1.InferOutput<Schema>;
203
183
  }
204
184
  //#endregion
205
185
  //#region src/validation.d.ts
@@ -244,6 +224,7 @@ interface CallApiSchemaConfig {
244
224
  strict?: boolean;
245
225
  }
246
226
  interface CallApiSchema {
227
+ auth?: StandardSchemaV1<AuthOption | undefined> | ((auth: AuthOption) => Awaitable<AuthOption | undefined>);
247
228
  /**
248
229
  * The schema to use for validating the request body.
249
230
  */
@@ -475,6 +456,33 @@ type InferMetaOption<TSchema extends CallApiSchema, TCallApiContext extends Call
475
456
  */
476
457
  meta?: InferSchemaOutput<TSchema["meta"], TCallApiContext["Meta"]>;
477
458
  }>;
459
+ type InferAuthOption<TSchema extends CallApiSchema> = MakeSchemaOptionRequiredIfDefined<TSchema["auth"], {
460
+ /**
461
+ * Automatically add an Authorization header value.
462
+ *
463
+ * Supports multiple authentication patterns:
464
+ * - String: Direct authorization header value
465
+ * - Auth object: Structured authentication configuration
466
+ *
467
+ * @example
468
+ * ```ts
469
+ * const callMainApi = callApi.create({
470
+ * baseURL: "https://main-api.com",
471
+ * onRequest: ({ options }) => {
472
+ * if (options.auth) {
473
+ * options.headers.Authorization = options.auth;
474
+ * }
475
+ * },
476
+ * });
477
+ *
478
+ * const response = await callMainApi({
479
+ * url: "https://example.com/api/data",
480
+ * auth: "Bearer 123456",
481
+ * });
482
+ * ```
483
+ */
484
+ auth?: InferSchemaOutput<TSchema["auth"], AuthOption>;
485
+ }>;
478
486
  type InferQueryOption<TSchema extends CallApiSchema> = MakeSchemaOptionRequiredIfDefined<TSchema["query"], {
479
487
  /**
480
488
  * Parameters to be appended to the URL (i.e: /:id)
@@ -496,7 +504,7 @@ type InferParamsOption<TSchema extends CallApiSchema, TBaseSchemaRoutes extends
496
504
  */
497
505
  params?: InferSchemaOutput<TSchema["params"], InferParamsFromRoute<TCurrentRouteSchemaKey>>;
498
506
  }>;
499
- type InferExtraOptions<TSchema extends CallApiSchema, TBaseSchemaRoutes extends BaseCallApiSchemaRoutes, TCurrentRouteSchemaKey extends string, TCallApiContext extends CallApiContext> = InferMetaOption<TSchema, TCallApiContext> & InferParamsOption<TSchema, TBaseSchemaRoutes, TCurrentRouteSchemaKey> & InferQueryOption<TSchema>;
507
+ type InferExtraOptions<TSchema extends CallApiSchema, TBaseSchemaRoutes extends BaseCallApiSchemaRoutes, TCurrentRouteSchemaKey extends string, TCallApiContext extends CallApiContext> = InferAuthOption<TSchema> & InferMetaOption<TSchema, TCallApiContext> & InferParamsOption<TSchema, TBaseSchemaRoutes, TCurrentRouteSchemaKey> & InferQueryOption<TSchema>;
500
508
  type InferPluginExtraOptions<TPluginArray extends CallApiPlugin[]> = UnionToIntersection<TPluginArray extends Array<infer TPlugin> ? TPlugin extends CallApiPlugin ? TPlugin["defineExtraOptions"] extends AnyFunction$1<infer TReturnedSchema> ? InferSchemaOutput<TReturnedSchema> : never : never : never>;
501
509
  type ResultModeOption<TErrorData, TResultMode extends ResultModeType> = TErrorData extends false ? {
502
510
  resultMode: "onlyData";
@@ -1204,7 +1212,7 @@ type SharedExtraOptions<TCallApiContext extends CallApiContext = DefaultCallApiC
1204
1212
  *
1205
1213
  * ```
1206
1214
  */
1207
- auth?: Auth;
1215
+ auth?: AuthOption;
1208
1216
  /**
1209
1217
  * Custom function to serialize request body objects into strings.
1210
1218
  *
@@ -1848,4 +1856,4 @@ declare const loggerPlugin: (options?: LoggerOptions) => {
1848
1856
  };
1849
1857
  //#endregion
1850
1858
  export { defaultConsoleObject as n, loggerPlugin as r, LoggerOptions as t };
1851
- //# sourceMappingURL=index-Do3FVEkv.d.ts.map
1859
+ //# sourceMappingURL=index-BuFffnAC.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-Do3FVEkv.js";
1
+ import { n as defaultConsoleObject, r as loggerPlugin, t as LoggerOptions } from "./index-BuFffnAC.js";
2
2
  export { LoggerOptions, defaultConsoleObject, loggerPlugin };
@@ -1,2 +1,2 @@
1
- import { n as defaultConsoleObject, r as loggerPlugin, t as LoggerOptions } from "../../index-Do3FVEkv.js";
1
+ import { n as defaultConsoleObject, r as loggerPlugin, t as LoggerOptions } from "../../index-BuFffnAC.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.32",
4
+ "version": "4.0.34",
5
5
  "description": "A collection of plugins for callapi",
6
6
  "author": "Ryan Zayne",
7
7
  "license": "MIT",
@@ -24,24 +24,24 @@
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.32"
27
+ "@zayne-labs/callapi": "1.11.34"
28
28
  },
29
29
  "devDependencies": {
30
30
  "@arethetypeswrong/cli": "0.18.2",
31
31
  "@size-limit/esbuild-why": "12.0.0",
32
32
  "@size-limit/preset-small-lib": "12.0.0",
33
33
  "@total-typescript/ts-reset": "0.6.1",
34
- "@zayne-labs/toolkit-type-helpers": "^0.12.15",
34
+ "@zayne-labs/toolkit-type-helpers": "^0.12.16",
35
35
  "@zayne-labs/tsconfig": "0.11.5",
36
36
  "concurrently": "^9.2.1",
37
37
  "consola": "3.4.2",
38
38
  "cross-env": "^10.1.0",
39
- "publint": "^0.3.15",
39
+ "publint": "^0.3.16",
40
40
  "size-limit": "12.0.0",
41
- "tsdown": "0.17.0",
41
+ "tsdown": "0.18.0",
42
42
  "typescript": "5.9.3",
43
43
  "vitest": "^4.0.15",
44
- "@zayne-labs/callapi": "1.11.32"
44
+ "@zayne-labs/callapi": "1.11.34"
45
45
  },
46
46
  "publishConfig": {
47
47
  "access": "public",