@scalar/types 0.7.6 → 0.8.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/CHANGELOG.md +6 -0
- package/dist/api-reference/api-client-configuration.d.ts +1 -1
- package/dist/api-reference/api-client-plugin.d.ts +2 -2
- package/dist/api-reference/api-client-plugin.js +1 -1
- package/dist/api-reference/api-reference-configuration.d.ts +27 -0
- package/dist/api-reference/api-reference-configuration.d.ts.map +1 -1
- package/dist/api-reference/api-reference-configuration.js +8 -2
- package/dist/api-reference/base-configuration.d.ts +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -107,7 +107,7 @@ export declare const apiClientConfigurationSchema: z.ZodObject<{
|
|
|
107
107
|
}, z.core.$strip>>;
|
|
108
108
|
hooks: z.ZodOptional<z.ZodObject<{
|
|
109
109
|
onBeforeRequest: z.ZodOptional<z.ZodFunction<z.ZodTuple<readonly [z.ZodObject<{
|
|
110
|
-
request: z.
|
|
110
|
+
request: z.ZodAny;
|
|
111
111
|
}, z.core.$strip>], null>, z.core.$ZodFunctionOut>>;
|
|
112
112
|
onResponseReceived: z.ZodOptional<z.ZodFunction<z.ZodTuple<readonly [z.ZodObject<{
|
|
113
113
|
response: z.ZodCustom<Response, Response>;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
export declare const hooksSchema: z.ZodObject<{
|
|
3
3
|
onBeforeRequest: z.ZodOptional<z.ZodFunction<z.ZodTuple<readonly [z.ZodObject<{
|
|
4
|
-
request: z.
|
|
4
|
+
request: z.ZodAny;
|
|
5
5
|
}, z.core.$strip>], null>, z.core.$ZodFunctionOut>>;
|
|
6
6
|
onResponseReceived: z.ZodOptional<z.ZodFunction<z.ZodTuple<readonly [z.ZodObject<{
|
|
7
7
|
response: z.ZodCustom<Response, Response>;
|
|
@@ -27,7 +27,7 @@ export declare const apiClientPluginSchema: z.ZodFunction<z.ZodTuple<readonly []
|
|
|
27
27
|
}, z.core.$strip>>;
|
|
28
28
|
hooks: z.ZodOptional<z.ZodObject<{
|
|
29
29
|
onBeforeRequest: z.ZodOptional<z.ZodFunction<z.ZodTuple<readonly [z.ZodObject<{
|
|
30
|
-
request: z.
|
|
30
|
+
request: z.ZodAny;
|
|
31
31
|
}, z.core.$strip>], null>, z.core.$ZodFunctionOut>>;
|
|
32
32
|
onResponseReceived: z.ZodOptional<z.ZodFunction<z.ZodTuple<readonly [z.ZodObject<{
|
|
33
33
|
response: z.ZodCustom<Response, Response>;
|
|
@@ -12,7 +12,7 @@ const viewsSchema = z.object({
|
|
|
12
12
|
export const hooksSchema = z.object({
|
|
13
13
|
onBeforeRequest: z
|
|
14
14
|
.function({
|
|
15
|
-
input: [z.object({ request: z.
|
|
15
|
+
input: [z.object({ request: z.any() })],
|
|
16
16
|
// Why no output? https://github.com/scalar/scalar/pull/7047
|
|
17
17
|
// output: z.union([z.void(), z.promise(z.void())]),
|
|
18
18
|
})
|
|
@@ -167,6 +167,8 @@ export declare const apiReferenceConfigurationSchema: z.ZodObject<{
|
|
|
167
167
|
onLoaded: z.ZodType<((slug: string) => Promise<void> | void) | undefined>;
|
|
168
168
|
onBeforeRequest: z.ZodType<((a: {
|
|
169
169
|
request: Request;
|
|
170
|
+
requestBuilder: any;
|
|
171
|
+
envVariables: Record<string, string>;
|
|
170
172
|
}) => Promise<void> | void) | undefined>;
|
|
171
173
|
onShowMore: z.ZodType<((a: string) => Promise<void> | void) | undefined>;
|
|
172
174
|
onSidebarClick: z.ZodType<((a: string) => Promise<void> | void) | undefined>;
|
|
@@ -235,6 +237,31 @@ export type ApiReferenceConfiguration = ApiReferenceConfigurationRaw & {
|
|
|
235
237
|
* Use the type `ApiReferenceConfigurationWithSource` instead.
|
|
236
238
|
*/
|
|
237
239
|
content?: SourceConfiguration['content'];
|
|
240
|
+
/**
|
|
241
|
+
* Fired before the outbound request is built and sent. Mutate the **request builder** so the eventual fetch call
|
|
242
|
+
* reflects your changes (method, path, headers, body, and related fields).
|
|
243
|
+
*
|
|
244
|
+
* **Experimental:** The builder matches {@link https://github.com/scalar/scalar/blob/main/packages/workspace-store/src/request-example/builder/request-factory.ts RequestFactory}
|
|
245
|
+
* (`import type { RequestFactory } from '@scalar/workspace-store/request-example'`). That shape is still experimental and may change in minor releases.
|
|
246
|
+
*
|
|
247
|
+
* @param input - Hook argument from the integration layer.
|
|
248
|
+
* @param input.request - **Deprecated** when treated as a fetch API `Request`. Prefer thinking of this value as the
|
|
249
|
+
* mutable builder ({@link https://github.com/scalar/scalar/blob/main/packages/workspace-store/src/request-example/builder/request-factory.ts RequestFactory}).
|
|
250
|
+
* Some call sites only pass this property.
|
|
251
|
+
* @param input.requestBuilder - The same builder when exposed under this name; **prefer** mutating this when your integration provides it.
|
|
252
|
+
* @returns void or a promise that resolves when the hook finishes
|
|
253
|
+
* @example
|
|
254
|
+
* ```ts
|
|
255
|
+
* onBeforeRequest: ({ request: builder }) => {
|
|
256
|
+
* builder.headers.set('Authorization', 'Bearer <token>')
|
|
257
|
+
* }
|
|
258
|
+
* ```
|
|
259
|
+
*/
|
|
260
|
+
onBeforeRequest?: (input: {
|
|
261
|
+
request: Request;
|
|
262
|
+
requestBuilder: any;
|
|
263
|
+
envVariables: Record<string, string>;
|
|
264
|
+
}) => void | Promise<void> | undefined;
|
|
238
265
|
};
|
|
239
266
|
/** Migrate the configuration through a transform */
|
|
240
267
|
/** Configuration for the Api Reference */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"api-reference-configuration.d.ts","sourceRoot":"","sources":["../../src/api-reference/api-reference-configuration.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAIrC,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,gCAAgC,CAAA;AAEjF,OAAO,EAAE,KAAK,mBAAmB,EAA6B,MAAM,wBAAwB,CAAA;AAK5F;;;;;;;;;GASG;A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OAGG;IACH,OAAO,CAAC,EAAE,mBAAmB,CAAC,SAAS,CAAC,CAAA;IACxC;;;;;;;;;;;;;;;;;;;OAmBG;IACH,eAAe,CAAC,EAAE,CAAC,KAAK,EAAE;QACxB,OAAO,EAAE,OAAO,CAAA;QAChB,cAAc,EAAE,GAAG,CAAA;QACnB,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;KACrC,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,GAAG,SAAS,CAAA;CACvC,CAAA;AAED,oDAAoD;AAGpD,0CAA0C;AAC1C,eAAO,MAAM,yCAAyC,EAAE,OAAO,CAC7D,IAAI,CAAC,yBAAyB,EAAE,KAAK,GAAG,SAAS,CAAC,GAAG,mBAAmB,CAgExE,CAAA;AAEF;;GAEG;AACH,MAAM,MAAM,mCAAmC,GAAG,IAAI,CACpD,CAAC,CAAC,KAAK,CAAC,OAAO,yCAAyC,CAAC,EAEzD,OAAO,GAAG,MAAM,GAAG,gBAAgB,GAAG,aAAa,CACpD,GAAG;IACF,cAAc,CAAC,EAAE,2BAA2B,CAAA;CAC7C,CAAA;AAED;;;GAGG;AACH,MAAM,MAAM,4CAA4C,GAAG,mCAAmC,GAAG;IAC/F,OAAO,EAAE,mBAAmB,EAAE,CAAA;CAC/B,CAAA;AAED,gDAAgD;AAChD,MAAM,MAAM,4BAA4B,GACpC,OAAO,CAAC,mCAAmC,CAAC,GAC5C,OAAO,CAAC,4CAA4C,CAAC,GACrD,OAAO,CAAC,mCAAmC,CAAC,EAAE,GAC9C,OAAO,CAAC,4CAA4C,CAAC,EAAE,CAAA;AAE3D,uEAAuE;AACvE,eAAO,MAAM,0BAA0B,GACrC,QAAQ,4BAA4B,KACnC,MAAM,IAAI,OAAO,CAAC,4CAA4C,CACkC,CAAA"}
|
|
@@ -137,10 +137,16 @@ export const apiReferenceConfigurationSchema = baseConfigurationSchema.extend({
|
|
|
137
137
|
.optional(),
|
|
138
138
|
/** Callback fired when the reference is fully loaded */
|
|
139
139
|
onLoaded: z.function().optional(),
|
|
140
|
-
/**
|
|
140
|
+
/** Fired before the outbound request is built; callback receives a mutable request builder (RequestFactory). Experimental API. */
|
|
141
141
|
onBeforeRequest: z
|
|
142
142
|
.function({
|
|
143
|
-
input: [
|
|
143
|
+
input: [
|
|
144
|
+
z.object({
|
|
145
|
+
request: z.instanceof(Request),
|
|
146
|
+
requestBuilder: z.unknown(),
|
|
147
|
+
envVariables: z.record(z.string(), z.string()),
|
|
148
|
+
}),
|
|
149
|
+
],
|
|
144
150
|
// Why no output? https://github.com/scalar/scalar/pull/7047
|
|
145
151
|
// output: z.union([z.void(), z.promise(z.void())]),
|
|
146
152
|
})
|
|
@@ -120,7 +120,7 @@ export declare const baseConfigurationSchema: z.ZodObject<{
|
|
|
120
120
|
}, z.core.$strip>>;
|
|
121
121
|
hooks: z.ZodOptional<z.ZodObject<{
|
|
122
122
|
onBeforeRequest: z.ZodOptional<z.ZodFunction<z.ZodTuple<readonly [z.ZodObject<{
|
|
123
|
-
request: z.
|
|
123
|
+
request: z.ZodAny;
|
|
124
124
|
}, z.core.$strip>], null>, z.core.$ZodFunctionOut>>;
|
|
125
125
|
onResponseReceived: z.ZodOptional<z.ZodFunction<z.ZodTuple<readonly [z.ZodObject<{
|
|
126
126
|
response: z.ZodCustom<Response, Response>;
|