@scalar/types 0.2.5 → 0.2.7

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 CHANGED
@@ -1,5 +1,19 @@
1
1
  # @scalar/types
2
2
 
3
+ ## 0.2.7
4
+
5
+ ### Patch Changes
6
+
7
+ - ad2e3e6: feat: new onBeforeRequest hook to modify the request
8
+
9
+ ## 0.2.6
10
+
11
+ ### Patch Changes
12
+
13
+ - 2d7f995: refactor: use more common straight apostrophe ' instead of the real apostrophe ’
14
+ - Updated dependencies [2d7f995]
15
+ - @scalar/openapi-types@0.3.5
16
+
3
17
  ## 0.2.5
4
18
 
5
19
  ### Patch Changes
@@ -1,8 +1,43 @@
1
1
  import { z } from 'zod';
2
+ export declare const HooksSchema: z.ZodObject<{
3
+ onBeforeRequest: z.ZodOptional<z.ZodFunction<z.ZodTuple<[z.ZodObject<{
4
+ request: z.ZodType<Request, z.ZodTypeDef, Request>;
5
+ }, "strip", z.ZodTypeAny, {
6
+ request: Request;
7
+ }, {
8
+ request: Request;
9
+ }>], z.ZodUnknown>, z.ZodUnion<[z.ZodVoid, z.ZodPromise<z.ZodVoid>]>>>;
10
+ onResponseReceived: z.ZodOptional<z.ZodFunction<z.ZodTuple<[z.ZodObject<{
11
+ response: z.ZodType<Response, z.ZodTypeDef, Response>;
12
+ operation: z.ZodRecord<z.ZodString, z.ZodAny>;
13
+ }, "strip", z.ZodTypeAny, {
14
+ response: Response;
15
+ operation: Record<string, any>;
16
+ }, {
17
+ response: Response;
18
+ operation: Record<string, any>;
19
+ }>], z.ZodUnknown>, z.ZodUnion<[z.ZodVoid, z.ZodPromise<z.ZodVoid>]>>>;
20
+ }, "strip", z.ZodTypeAny, {
21
+ onBeforeRequest?: ((args_0: {
22
+ request: Request;
23
+ }, ...args: unknown[]) => void | Promise<void>) | undefined;
24
+ onResponseReceived?: ((args_0: {
25
+ response: Response;
26
+ operation: Record<string, any>;
27
+ }, ...args: unknown[]) => void | Promise<void>) | undefined;
28
+ }, {
29
+ onBeforeRequest?: ((args_0: {
30
+ request: Request;
31
+ }, ...args: unknown[]) => void | Promise<void>) | undefined;
32
+ onResponseReceived?: ((args_0: {
33
+ response: Response;
34
+ operation: Record<string, any>;
35
+ }, ...args: unknown[]) => void | Promise<void>) | undefined;
36
+ }>;
2
37
  export declare const ApiClientPluginSchema: z.ZodFunction<z.ZodTuple<[], z.ZodUnknown>, z.ZodObject<{
3
38
  name: z.ZodString;
4
- views: z.ZodObject<{
5
- 'request.section': z.ZodArray<z.ZodObject<{
39
+ views: z.ZodOptional<z.ZodObject<{
40
+ 'request.section': z.ZodOptional<z.ZodArray<z.ZodObject<{
6
41
  title: z.ZodOptional<z.ZodString>;
7
42
  component: z.ZodUnknown;
8
43
  props: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
@@ -14,8 +49,8 @@ export declare const ApiClientPluginSchema: z.ZodFunction<z.ZodTuple<[], z.ZodUn
14
49
  title?: string | undefined;
15
50
  component?: unknown;
16
51
  props?: Record<string, any> | undefined;
17
- }>, "many">;
18
- 'response.section': z.ZodArray<z.ZodObject<{
52
+ }>, "many">>;
53
+ 'response.section': z.ZodOptional<z.ZodArray<z.ZodObject<{
19
54
  title: z.ZodOptional<z.ZodString>;
20
55
  component: z.ZodUnknown;
21
56
  props: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
@@ -27,33 +62,39 @@ export declare const ApiClientPluginSchema: z.ZodFunction<z.ZodTuple<[], z.ZodUn
27
62
  title?: string | undefined;
28
63
  component?: unknown;
29
64
  props?: Record<string, any> | undefined;
30
- }>, "many">;
65
+ }>, "many">>;
31
66
  }, "strip", z.ZodTypeAny, {
32
- 'request.section': {
67
+ 'request.section'?: {
33
68
  title?: string | undefined;
34
69
  component?: unknown;
35
70
  props?: Record<string, any> | undefined;
36
- }[];
37
- 'response.section': {
71
+ }[] | undefined;
72
+ 'response.section'?: {
38
73
  title?: string | undefined;
39
74
  component?: unknown;
40
75
  props?: Record<string, any> | undefined;
41
- }[];
76
+ }[] | undefined;
42
77
  }, {
43
- 'request.section': {
78
+ 'request.section'?: {
44
79
  title?: string | undefined;
45
80
  component?: unknown;
46
81
  props?: Record<string, any> | undefined;
47
- }[];
48
- 'response.section': {
82
+ }[] | undefined;
83
+ 'response.section'?: {
49
84
  title?: string | undefined;
50
85
  component?: unknown;
51
86
  props?: Record<string, any> | undefined;
52
- }[];
53
- }>;
54
- hooks: z.ZodObject<{
55
- onBeforeRequest: z.ZodFunction<z.ZodTuple<[], z.ZodUnknown>, z.ZodUnion<[z.ZodVoid, z.ZodPromise<z.ZodVoid>]>>;
56
- onResponseReceived: z.ZodFunction<z.ZodTuple<[z.ZodObject<{
87
+ }[] | undefined;
88
+ }>>;
89
+ hooks: z.ZodOptional<z.ZodObject<{
90
+ onBeforeRequest: z.ZodOptional<z.ZodFunction<z.ZodTuple<[z.ZodObject<{
91
+ request: z.ZodType<Request, z.ZodTypeDef, Request>;
92
+ }, "strip", z.ZodTypeAny, {
93
+ request: Request;
94
+ }, {
95
+ request: Request;
96
+ }>], z.ZodUnknown>, z.ZodUnion<[z.ZodVoid, z.ZodPromise<z.ZodVoid>]>>>;
97
+ onResponseReceived: z.ZodOptional<z.ZodFunction<z.ZodTuple<[z.ZodObject<{
57
98
  response: z.ZodType<Response, z.ZodTypeDef, Response>;
58
99
  operation: z.ZodRecord<z.ZodString, z.ZodAny>;
59
100
  }, "strip", z.ZodTypeAny, {
@@ -62,62 +103,70 @@ export declare const ApiClientPluginSchema: z.ZodFunction<z.ZodTuple<[], z.ZodUn
62
103
  }, {
63
104
  response: Response;
64
105
  operation: Record<string, any>;
65
- }>], z.ZodUnknown>, z.ZodUnion<[z.ZodVoid, z.ZodPromise<z.ZodVoid>]>>;
106
+ }>], z.ZodUnknown>, z.ZodUnion<[z.ZodVoid, z.ZodPromise<z.ZodVoid>]>>>;
66
107
  }, "strip", z.ZodTypeAny, {
67
- onBeforeRequest: (...args: unknown[]) => void | Promise<void>;
68
- onResponseReceived: (args_0: {
108
+ onBeforeRequest?: ((args_0: {
109
+ request: Request;
110
+ }, ...args: unknown[]) => void | Promise<void>) | undefined;
111
+ onResponseReceived?: ((args_0: {
69
112
  response: Response;
70
113
  operation: Record<string, any>;
71
- }, ...args: unknown[]) => void | Promise<void>;
114
+ }, ...args: unknown[]) => void | Promise<void>) | undefined;
72
115
  }, {
73
- onBeforeRequest: (...args: unknown[]) => void | Promise<void>;
74
- onResponseReceived: (args_0: {
116
+ onBeforeRequest?: ((args_0: {
117
+ request: Request;
118
+ }, ...args: unknown[]) => void | Promise<void>) | undefined;
119
+ onResponseReceived?: ((args_0: {
75
120
  response: Response;
76
121
  operation: Record<string, any>;
77
- }, ...args: unknown[]) => void | Promise<void>;
78
- }>;
122
+ }, ...args: unknown[]) => void | Promise<void>) | undefined;
123
+ }>>;
79
124
  }, "strip", z.ZodTypeAny, {
80
125
  name: string;
81
- views: {
82
- 'request.section': {
126
+ views?: {
127
+ 'request.section'?: {
83
128
  title?: string | undefined;
84
129
  component?: unknown;
85
130
  props?: Record<string, any> | undefined;
86
- }[];
87
- 'response.section': {
131
+ }[] | undefined;
132
+ 'response.section'?: {
88
133
  title?: string | undefined;
89
134
  component?: unknown;
90
135
  props?: Record<string, any> | undefined;
91
- }[];
92
- };
93
- hooks: {
94
- onBeforeRequest: (...args: unknown[]) => void | Promise<void>;
95
- onResponseReceived: (args_0: {
136
+ }[] | undefined;
137
+ } | undefined;
138
+ hooks?: {
139
+ onBeforeRequest?: ((args_0: {
140
+ request: Request;
141
+ }, ...args: unknown[]) => void | Promise<void>) | undefined;
142
+ onResponseReceived?: ((args_0: {
96
143
  response: Response;
97
144
  operation: Record<string, any>;
98
- }, ...args: unknown[]) => void | Promise<void>;
99
- };
145
+ }, ...args: unknown[]) => void | Promise<void>) | undefined;
146
+ } | undefined;
100
147
  }, {
101
148
  name: string;
102
- views: {
103
- 'request.section': {
149
+ views?: {
150
+ 'request.section'?: {
104
151
  title?: string | undefined;
105
152
  component?: unknown;
106
153
  props?: Record<string, any> | undefined;
107
- }[];
108
- 'response.section': {
154
+ }[] | undefined;
155
+ 'response.section'?: {
109
156
  title?: string | undefined;
110
157
  component?: unknown;
111
158
  props?: Record<string, any> | undefined;
112
- }[];
113
- };
114
- hooks: {
115
- onBeforeRequest: (...args: unknown[]) => void | Promise<void>;
116
- onResponseReceived: (args_0: {
159
+ }[] | undefined;
160
+ } | undefined;
161
+ hooks?: {
162
+ onBeforeRequest?: ((args_0: {
163
+ request: Request;
164
+ }, ...args: unknown[]) => void | Promise<void>) | undefined;
165
+ onResponseReceived?: ((args_0: {
117
166
  response: Response;
118
167
  operation: Record<string, any>;
119
- }, ...args: unknown[]) => void | Promise<void>;
120
- };
168
+ }, ...args: unknown[]) => void | Promise<void>) | undefined;
169
+ } | undefined;
121
170
  }>>;
122
171
  export type ApiClientPlugin = z.infer<typeof ApiClientPluginSchema>;
123
172
  //# sourceMappingURL=api-client-plugin.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"api-client-plugin.d.ts","sourceRoot":"","sources":["../../src/api-client/api-client-plugin.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AA4BvB,eAAO,MAAM,qBAAqB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAMjC,CAAA;AAED,MAAM,MAAM,eAAe,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,qBAAqB,CAAC,CAAA"}
1
+ {"version":3,"file":"api-client-plugin.d.ts","sourceRoot":"","sources":["../../src/api-client/api-client-plugin.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAcvB,eAAO,MAAM,WAAW;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAiBtB,CAAA;AAEF,eAAO,MAAM,qBAAqB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAMjC,CAAA;AAED,MAAM,MAAM,eAAe,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,qBAAqB,CAAC,CAAA"}
@@ -6,27 +6,28 @@ const SectionViewSchema = z.object({
6
6
  props: z.record(z.any()).optional()
7
7
  });
8
8
  const ViewsSchema = z.object({
9
- "request.section": z.array(SectionViewSchema),
10
- "response.section": z.array(SectionViewSchema)
9
+ "request.section": z.array(SectionViewSchema).optional(),
10
+ "response.section": z.array(SectionViewSchema).optional()
11
11
  });
12
12
  const HooksSchema = z.object({
13
- onBeforeRequest: z.function().returns(z.union([z.void(), z.promise(z.void())])),
13
+ onBeforeRequest: z.function().args(z.object({ request: z.instanceof(Request) })).returns(z.union([z.void(), z.promise(z.void())])).optional(),
14
14
  onResponseReceived: z.function().args(
15
15
  z.object({
16
16
  response: z.instanceof(Response),
17
17
  // Ideally, we'd have the Operation type here, but we don't.
18
18
  operation: z.record(z.any())
19
19
  })
20
- ).returns(z.union([z.void(), z.promise(z.void())]))
20
+ ).returns(z.union([z.void(), z.promise(z.void())])).optional()
21
21
  });
22
22
  const ApiClientPluginSchema = z.function().returns(
23
23
  z.object({
24
24
  name: z.string(),
25
- views: ViewsSchema,
26
- hooks: HooksSchema
25
+ views: ViewsSchema.optional(),
26
+ hooks: HooksSchema.optional()
27
27
  })
28
28
  );
29
29
  export {
30
- ApiClientPluginSchema
30
+ ApiClientPluginSchema,
31
+ HooksSchema
31
32
  };
32
33
  //# sourceMappingURL=api-client-plugin.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/api-client/api-client-plugin.ts"],
4
- "sourcesContent": ["import { z } from 'zod'\n\nconst SectionViewSchema = z.object({\n title: z.string().optional(),\n // Since this is meant to be a Vue component, we'll use unknown\n component: z.unknown(),\n props: z.record(z.any()).optional(),\n})\n\nconst ViewsSchema = z.object({\n 'request.section': z.array(SectionViewSchema),\n 'response.section': z.array(SectionViewSchema),\n})\n\nconst HooksSchema = z.object({\n onBeforeRequest: z.function().returns(z.union([z.void(), z.promise(z.void())])),\n onResponseReceived: z\n .function()\n .args(\n z.object({\n response: z.instanceof(Response),\n // Ideally, we'd have the Operation type here, but we don't.\n operation: z.record(z.any()),\n }),\n )\n .returns(z.union([z.void(), z.promise(z.void())])),\n})\n\nexport const ApiClientPluginSchema = z.function().returns(\n z.object({\n name: z.string(),\n views: ViewsSchema,\n hooks: HooksSchema,\n }),\n)\n\nexport type ApiClientPlugin = z.infer<typeof ApiClientPluginSchema>\n"],
5
- "mappings": "AAAA,SAAS,SAAS;AAElB,MAAM,oBAAoB,EAAE,OAAO;AAAA,EACjC,OAAO,EAAE,OAAO,EAAE,SAAS;AAAA;AAAA,EAE3B,WAAW,EAAE,QAAQ;AAAA,EACrB,OAAO,EAAE,OAAO,EAAE,IAAI,CAAC,EAAE,SAAS;AACpC,CAAC;AAED,MAAM,cAAc,EAAE,OAAO;AAAA,EAC3B,mBAAmB,EAAE,MAAM,iBAAiB;AAAA,EAC5C,oBAAoB,EAAE,MAAM,iBAAiB;AAC/C,CAAC;AAED,MAAM,cAAc,EAAE,OAAO;AAAA,EAC3B,iBAAiB,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,CAAC,EAAE,KAAK,GAAG,EAAE,QAAQ,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC;AAAA,EAC9E,oBAAoB,EACjB,SAAS,EACT;AAAA,IACC,EAAE,OAAO;AAAA,MACP,UAAU,EAAE,WAAW,QAAQ;AAAA;AAAA,MAE/B,WAAW,EAAE,OAAO,EAAE,IAAI,CAAC;AAAA,IAC7B,CAAC;AAAA,EACH,EACC,QAAQ,EAAE,MAAM,CAAC,EAAE,KAAK,GAAG,EAAE,QAAQ,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC;AACrD,CAAC;AAEM,MAAM,wBAAwB,EAAE,SAAS,EAAE;AAAA,EAChD,EAAE,OAAO;AAAA,IACP,MAAM,EAAE,OAAO;AAAA,IACf,OAAO;AAAA,IACP,OAAO;AAAA,EACT,CAAC;AACH;",
4
+ "sourcesContent": ["import { z } from 'zod'\n\nconst SectionViewSchema = z.object({\n title: z.string().optional(),\n // Since this is meant to be a Vue component, we'll use unknown\n component: z.unknown(),\n props: z.record(z.any()).optional(),\n})\n\nconst ViewsSchema = z.object({\n 'request.section': z.array(SectionViewSchema).optional(),\n 'response.section': z.array(SectionViewSchema).optional(),\n})\n\nexport const HooksSchema = z.object({\n onBeforeRequest: z\n .function()\n .args(z.object({ request: z.instanceof(Request) }))\n .returns(z.union([z.void(), z.promise(z.void())]))\n .optional(),\n onResponseReceived: z\n .function()\n .args(\n z.object({\n response: z.instanceof(Response),\n // Ideally, we'd have the Operation type here, but we don't.\n operation: z.record(z.any()),\n }),\n )\n .returns(z.union([z.void(), z.promise(z.void())]))\n .optional(),\n})\n\nexport const ApiClientPluginSchema = z.function().returns(\n z.object({\n name: z.string(),\n views: ViewsSchema.optional(),\n hooks: HooksSchema.optional(),\n }),\n)\n\nexport type ApiClientPlugin = z.infer<typeof ApiClientPluginSchema>\n"],
5
+ "mappings": "AAAA,SAAS,SAAS;AAElB,MAAM,oBAAoB,EAAE,OAAO;AAAA,EACjC,OAAO,EAAE,OAAO,EAAE,SAAS;AAAA;AAAA,EAE3B,WAAW,EAAE,QAAQ;AAAA,EACrB,OAAO,EAAE,OAAO,EAAE,IAAI,CAAC,EAAE,SAAS;AACpC,CAAC;AAED,MAAM,cAAc,EAAE,OAAO;AAAA,EAC3B,mBAAmB,EAAE,MAAM,iBAAiB,EAAE,SAAS;AAAA,EACvD,oBAAoB,EAAE,MAAM,iBAAiB,EAAE,SAAS;AAC1D,CAAC;AAEM,MAAM,cAAc,EAAE,OAAO;AAAA,EAClC,iBAAiB,EACd,SAAS,EACT,KAAK,EAAE,OAAO,EAAE,SAAS,EAAE,WAAW,OAAO,EAAE,CAAC,CAAC,EACjD,QAAQ,EAAE,MAAM,CAAC,EAAE,KAAK,GAAG,EAAE,QAAQ,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC,EAChD,SAAS;AAAA,EACZ,oBAAoB,EACjB,SAAS,EACT;AAAA,IACC,EAAE,OAAO;AAAA,MACP,UAAU,EAAE,WAAW,QAAQ;AAAA;AAAA,MAE/B,WAAW,EAAE,OAAO,EAAE,IAAI,CAAC;AAAA,IAC7B,CAAC;AAAA,EACH,EACC,QAAQ,EAAE,MAAM,CAAC,EAAE,KAAK,GAAG,EAAE,QAAQ,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC,EAChD,SAAS;AACd,CAAC;AAEM,MAAM,wBAAwB,EAAE,SAAS,EAAE;AAAA,EAChD,EAAE,OAAO;AAAA,IACP,MAAM,EAAE,OAAO;AAAA,IACf,OAAO,YAAY,SAAS;AAAA,IAC5B,OAAO,YAAY,SAAS;AAAA,EAC9B,CAAC;AACH;",
6
6
  "names": []
7
7
  }
@@ -1,2 +1,2 @@
1
- export { type ApiClientPlugin, ApiClientPluginSchema } from './api-client-plugin.js';
1
+ export { type ApiClientPlugin, ApiClientPluginSchema, HooksSchema } from './api-client-plugin.js';
2
2
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/api-client/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,eAAe,EAAE,qBAAqB,EAAE,MAAM,qBAAqB,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/api-client/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,eAAe,EAAE,qBAAqB,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAA"}
@@ -1,5 +1,6 @@
1
- import { ApiClientPluginSchema } from "./api-client-plugin.js";
1
+ import { ApiClientPluginSchema, HooksSchema } from "./api-client-plugin.js";
2
2
  export {
3
- ApiClientPluginSchema
3
+ ApiClientPluginSchema,
4
+ HooksSchema
4
5
  };
5
6
  //# sourceMappingURL=index.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/api-client/index.ts"],
4
- "sourcesContent": ["export { type ApiClientPlugin, ApiClientPluginSchema } from './api-client-plugin'\n"],
5
- "mappings": "AAAA,SAA+B,6BAA6B;",
4
+ "sourcesContent": ["export { type ApiClientPlugin, ApiClientPluginSchema, HooksSchema } from './api-client-plugin'\n"],
5
+ "mappings": "AAAA,SAA+B,uBAAuB,mBAAmB;",
6
6
  "names": []
7
7
  }