@scalar/oas-utils 0.2.102 → 0.2.103

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,15 @@
1
1
  # @scalar/oas-utils
2
2
 
3
+ ## 0.2.103
4
+
5
+ ### Patch Changes
6
+
7
+ - 0f5df68: chore: refactored send request with extensive test suite
8
+ - 937f791: chore: alias request to operation
9
+ - Updated dependencies [a30e7cc]
10
+ - @scalar/types@0.0.31
11
+ - @scalar/themes@0.9.65
12
+
3
13
  ## 0.2.102
4
14
 
5
15
  ### Patch Changes
@@ -8,4 +8,5 @@ export * from './security.js';
8
8
  export * from './x-scalar-environments.js';
9
9
  type FetchRequest = Request;
10
10
  export type { FetchRequest };
11
+ export { type Operation, type OperationPayload, operationSchema, } from './operation.js';
11
12
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/entities/spec/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAA;AAC5B,cAAc,UAAU,CAAA;AACxB,cAAc,YAAY,CAAA;AAC1B,cAAc,oBAAoB,CAAA;AAClC,cAAc,gBAAgB,CAAA;AAC9B,cAAc,cAAc,CAAA;AAC5B,cAAc,YAAY,CAAA;AAC1B,cAAc,yBAAyB,CAAA;AAEvC,KAAK,YAAY,GAAG,OAAO,CAAA;AAC3B,YAAY,EAAE,YAAY,EAAE,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/entities/spec/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAA;AAC5B,cAAc,UAAU,CAAA;AACxB,cAAc,YAAY,CAAA;AAC1B,cAAc,oBAAoB,CAAA;AAClC,cAAc,gBAAgB,CAAA;AAC9B,cAAc,cAAc,CAAA;AAC5B,cAAc,YAAY,CAAA;AAC1B,cAAc,yBAAyB,CAAA;AAEvC,KAAK,YAAY,GAAG,OAAO,CAAA;AAC3B,YAAY,EAAE,YAAY,EAAE,CAAA;AAE5B,OAAO,EACL,KAAK,SAAS,EACd,KAAK,gBAAgB,EACrB,eAAe,GAChB,MAAM,aAAa,CAAA"}
@@ -6,3 +6,4 @@ export { oasContactSchema, oasExternalDocumentationSchema, oasInfoSchema, oasLic
6
6
  export { oasParameterSchema, parameterStyleSchema, parameterTypeSchema } from './parameters.js';
7
7
  export { oasSecurityRequirementSchema, oasSecuritySchemeSchema, pkceOptions, securityApiKeySchema, securityHttpSchema, securityOauthSchema, securityOpenIdSchema, securitySchemeApiKeyIn, securitySchemeSchema } from './security.js';
8
8
  export { xScalarEnvVarSchema, xScalarEnvironmentSchema, xScalarEnvironmentsSchema } from './x-scalar-environments.js';
9
+ export { operationSchema } from './operation.js';
@@ -0,0 +1,243 @@
1
+ /**
2
+ * Aliases Request to Operation which is closer to the spec,
3
+ * also will not conflict with the builtin Request class
4
+ */
5
+ import { type RequestPayload, type Request as RequestType } from './requests.js';
6
+ export type Operation = RequestType;
7
+ export type OperationPayload = RequestPayload;
8
+ export declare const operationSchema: import("zod").ZodObject<import("zod").objectUtil.extendShape<Omit<{
9
+ tags: import("zod").ZodOptional<import("zod").ZodArray<import("zod").ZodString, "many">>;
10
+ summary: import("zod").ZodOptional<import("zod").ZodString>;
11
+ description: import("zod").ZodOptional<import("zod").ZodString>;
12
+ operationId: import("zod").ZodOptional<import("zod").ZodString>;
13
+ security: import("zod").ZodOptional<import("zod").ZodArray<import("zod").ZodRecord<import("zod").ZodString, import("zod").ZodDefault<import("zod").ZodOptional<import("zod").ZodArray<import("zod").ZodString, "many">>>>, "many">>;
14
+ requestBody: import("zod").ZodOptional<import("zod").ZodAny>;
15
+ parameters: import("zod").ZodOptional<import("zod").ZodArray<import("zod").ZodObject<{
16
+ in: import("zod").ZodEnum<["path", "query", "header", "cookie"]>;
17
+ name: import("zod").ZodString;
18
+ description: import("zod").ZodOptional<import("zod").ZodString>;
19
+ required: import("zod").ZodDefault<import("zod").ZodOptional<import("zod").ZodBoolean>>;
20
+ deprecated: import("zod").ZodDefault<import("zod").ZodOptional<import("zod").ZodBoolean>>;
21
+ schema: import("zod").ZodOptional<import("zod").ZodUnknown>;
22
+ content: import("zod").ZodOptional<import("zod").ZodUnknown>;
23
+ style: import("zod").ZodOptional<import("zod").ZodEnum<["matrix", "simple", "form", "label", "spaceDelimited", "pipeDelimited", "deepObject"]>>;
24
+ example: import("zod").ZodOptional<import("zod").ZodUnknown>;
25
+ examples: import("zod").ZodOptional<import("zod").ZodRecord<import("zod").ZodString, import("zod").ZodObject<{
26
+ value: import("zod").ZodUnknown;
27
+ summary: import("zod").ZodOptional<import("zod").ZodString>;
28
+ }, "strip", import("zod").ZodTypeAny, {
29
+ value?: unknown;
30
+ summary?: string | undefined;
31
+ }, {
32
+ value?: unknown;
33
+ summary?: string | undefined;
34
+ }>>>;
35
+ }, "strip", import("zod").ZodTypeAny, {
36
+ required: boolean;
37
+ name: string;
38
+ in: "path" | "query" | "header" | "cookie";
39
+ deprecated: boolean;
40
+ description?: string | undefined;
41
+ example?: unknown;
42
+ schema?: unknown;
43
+ content?: unknown;
44
+ style?: "matrix" | "simple" | "form" | "label" | "spaceDelimited" | "pipeDelimited" | "deepObject" | undefined;
45
+ examples?: Record<string, {
46
+ value?: unknown;
47
+ summary?: string | undefined;
48
+ }> | undefined;
49
+ }, {
50
+ name: string;
51
+ in: "path" | "query" | "header" | "cookie";
52
+ required?: boolean | undefined;
53
+ description?: string | undefined;
54
+ example?: unknown;
55
+ deprecated?: boolean | undefined;
56
+ schema?: unknown;
57
+ content?: unknown;
58
+ style?: "matrix" | "simple" | "form" | "label" | "spaceDelimited" | "pipeDelimited" | "deepObject" | undefined;
59
+ examples?: Record<string, {
60
+ value?: unknown;
61
+ summary?: string | undefined;
62
+ }> | undefined;
63
+ }>, "many">>;
64
+ externalDocs: import("zod").ZodOptional<import("zod").ZodObject<{
65
+ description: import("zod").ZodOptional<import("zod").ZodString>;
66
+ url: import("zod").ZodDefault<import("zod").ZodString>;
67
+ }, "strip", import("zod").ZodTypeAny, {
68
+ url: string;
69
+ description?: string | undefined;
70
+ }, {
71
+ description?: string | undefined;
72
+ url?: string | undefined;
73
+ }>>;
74
+ deprecated: import("zod").ZodOptional<import("zod").ZodBoolean>;
75
+ responses: import("zod").ZodOptional<import("zod").ZodRecord<import("zod").ZodString, import("zod").ZodAny>>;
76
+ 'x-scalar-examples': import("zod").ZodOptional<import("zod").ZodRecord<import("zod").ZodString, import("zod").ZodObject<{
77
+ name: import("zod").ZodOptional<import("zod").ZodString>;
78
+ body: import("zod").ZodOptional<import("zod").ZodObject<{
79
+ encoding: import("zod").ZodEnum<["application/json", "text/plain", "text/html", "application/javascript", "application/xml", "application/yaml", "application/edn", "application/octet-stream", "application/x-www-form-urlencoded", "multipart/form-data", "binary"]>;
80
+ content: import("zod").ZodUnion<[import("zod").ZodRecord<import("zod").ZodString, import("zod").ZodAny>, import("zod").ZodString]>;
81
+ file: import("zod").ZodOptional<import("zod").ZodNullable<import("zod").ZodObject<{
82
+ url: import("zod").ZodString;
83
+ base64: import("zod").ZodOptional<import("zod").ZodString>;
84
+ }, "strip", import("zod").ZodTypeAny, {
85
+ url: string;
86
+ base64?: string | undefined;
87
+ }, {
88
+ url: string;
89
+ base64?: string | undefined;
90
+ }>>>;
91
+ }, "strip", import("zod").ZodTypeAny, {
92
+ content: string | Record<string, any>;
93
+ encoding: "application/json" | "text/plain" | "text/html" | "application/javascript" | "application/xml" | "application/yaml" | "application/edn" | "application/octet-stream" | "application/x-www-form-urlencoded" | "multipart/form-data" | "binary";
94
+ file?: {
95
+ url: string;
96
+ base64?: string | undefined;
97
+ } | null | undefined;
98
+ }, {
99
+ content: string | Record<string, any>;
100
+ encoding: "application/json" | "text/plain" | "text/html" | "application/javascript" | "application/xml" | "application/yaml" | "application/edn" | "application/octet-stream" | "application/x-www-form-urlencoded" | "multipart/form-data" | "binary";
101
+ file?: {
102
+ url: string;
103
+ base64?: string | undefined;
104
+ } | null | undefined;
105
+ }>>;
106
+ parameters: import("zod").ZodObject<{
107
+ path: import("zod").ZodOptional<import("zod").ZodRecord<import("zod").ZodString, import("zod").ZodString>>;
108
+ query: import("zod").ZodOptional<import("zod").ZodRecord<import("zod").ZodString, import("zod").ZodString>>;
109
+ headers: import("zod").ZodOptional<import("zod").ZodRecord<import("zod").ZodString, import("zod").ZodString>>;
110
+ cookies: import("zod").ZodOptional<import("zod").ZodRecord<import("zod").ZodString, import("zod").ZodString>>;
111
+ }, "strip", import("zod").ZodTypeAny, {
112
+ path?: Record<string, string> | undefined;
113
+ cookies?: Record<string, string> | undefined;
114
+ query?: Record<string, string> | undefined;
115
+ headers?: Record<string, string> | undefined;
116
+ }, {
117
+ path?: Record<string, string> | undefined;
118
+ cookies?: Record<string, string> | undefined;
119
+ query?: Record<string, string> | undefined;
120
+ headers?: Record<string, string> | undefined;
121
+ }>;
122
+ }, "strip", import("zod").ZodTypeAny, {
123
+ parameters: {
124
+ path?: Record<string, string> | undefined;
125
+ cookies?: Record<string, string> | undefined;
126
+ query?: Record<string, string> | undefined;
127
+ headers?: Record<string, string> | undefined;
128
+ };
129
+ name?: string | undefined;
130
+ body?: {
131
+ content: string | Record<string, any>;
132
+ encoding: "application/json" | "text/plain" | "text/html" | "application/javascript" | "application/xml" | "application/yaml" | "application/edn" | "application/octet-stream" | "application/x-www-form-urlencoded" | "multipart/form-data" | "binary";
133
+ file?: {
134
+ url: string;
135
+ base64?: string | undefined;
136
+ } | null | undefined;
137
+ } | undefined;
138
+ }, {
139
+ parameters: {
140
+ path?: Record<string, string> | undefined;
141
+ cookies?: Record<string, string> | undefined;
142
+ query?: Record<string, string> | undefined;
143
+ headers?: Record<string, string> | undefined;
144
+ };
145
+ name?: string | undefined;
146
+ body?: {
147
+ content: string | Record<string, any>;
148
+ encoding: "application/json" | "text/plain" | "text/html" | "application/javascript" | "application/xml" | "application/yaml" | "application/edn" | "application/octet-stream" | "application/x-www-form-urlencoded" | "multipart/form-data" | "binary";
149
+ file?: {
150
+ url: string;
151
+ base64?: string | undefined;
152
+ } | null | undefined;
153
+ } | undefined;
154
+ }>>>;
155
+ 'x-internal': import("zod").ZodOptional<import("zod").ZodBoolean>;
156
+ 'x-scalar-ignore': import("zod").ZodOptional<import("zod").ZodBoolean>;
157
+ }, "x-scalar-examples">, {
158
+ type: import("zod").ZodDefault<import("zod").ZodOptional<import("zod").ZodLiteral<"request">>>;
159
+ uid: import("zod").ZodDefault<import("zod").ZodOptional<import("zod").ZodString>>;
160
+ path: import("zod").ZodDefault<import("zod").ZodOptional<import("zod").ZodString>>;
161
+ method: import("zod").ZodDefault<import("zod").ZodEnum<["connect", "delete", "get", "head", "options", "patch", "post", "put", "trace"]>>;
162
+ servers: import("zod").ZodDefault<import("zod").ZodArray<import("zod").ZodDefault<import("zod").ZodOptional<import("zod").ZodString>>, "many">>;
163
+ selectedServerUid: import("zod").ZodDefault<import("zod").ZodString>;
164
+ examples: import("zod").ZodDefault<import("zod").ZodArray<import("zod").ZodDefault<import("zod").ZodOptional<import("zod").ZodString>>, "many">>;
165
+ selectedSecuritySchemeUids: import("zod").ZodDefault<import("zod").ZodArray<import("zod").ZodUnion<[import("zod").ZodDefault<import("zod").ZodOptional<import("zod").ZodString>>, import("zod").ZodArray<import("zod").ZodDefault<import("zod").ZodOptional<import("zod").ZodString>>, "many">]>, "many">>;
166
+ }>, "strip", import("zod").ZodTypeAny, {
167
+ path: string;
168
+ type: "request";
169
+ uid: string;
170
+ selectedSecuritySchemeUids: (string | string[])[];
171
+ selectedServerUid: string;
172
+ servers: string[];
173
+ examples: string[];
174
+ method: "options" | "connect" | "delete" | "get" | "head" | "patch" | "post" | "put" | "trace";
175
+ description?: string | undefined;
176
+ summary?: string | undefined;
177
+ externalDocs?: {
178
+ url: string;
179
+ description?: string | undefined;
180
+ } | undefined;
181
+ 'x-internal'?: boolean | undefined;
182
+ 'x-scalar-ignore'?: boolean | undefined;
183
+ security?: Record<string, string[]>[] | undefined;
184
+ tags?: string[] | undefined;
185
+ deprecated?: boolean | undefined;
186
+ operationId?: string | undefined;
187
+ parameters?: {
188
+ required: boolean;
189
+ name: string;
190
+ in: "path" | "query" | "header" | "cookie";
191
+ deprecated: boolean;
192
+ description?: string | undefined;
193
+ example?: unknown;
194
+ schema?: unknown;
195
+ content?: unknown;
196
+ style?: "matrix" | "simple" | "form" | "label" | "spaceDelimited" | "pipeDelimited" | "deepObject" | undefined;
197
+ examples?: Record<string, {
198
+ value?: unknown;
199
+ summary?: string | undefined;
200
+ }> | undefined;
201
+ }[] | undefined;
202
+ requestBody?: any;
203
+ responses?: Record<string, any> | undefined;
204
+ }, {
205
+ path?: string | undefined;
206
+ type?: "request" | undefined;
207
+ uid?: string | undefined;
208
+ description?: string | undefined;
209
+ summary?: string | undefined;
210
+ externalDocs?: {
211
+ description?: string | undefined;
212
+ url?: string | undefined;
213
+ } | undefined;
214
+ 'x-internal'?: boolean | undefined;
215
+ 'x-scalar-ignore'?: boolean | undefined;
216
+ security?: Record<string, string[] | undefined>[] | undefined;
217
+ selectedSecuritySchemeUids?: (string | (string | undefined)[] | undefined)[] | undefined;
218
+ selectedServerUid?: string | undefined;
219
+ servers?: (string | undefined)[] | undefined;
220
+ tags?: string[] | undefined;
221
+ deprecated?: boolean | undefined;
222
+ examples?: (string | undefined)[] | undefined;
223
+ operationId?: string | undefined;
224
+ parameters?: {
225
+ name: string;
226
+ in: "path" | "query" | "header" | "cookie";
227
+ required?: boolean | undefined;
228
+ description?: string | undefined;
229
+ example?: unknown;
230
+ deprecated?: boolean | undefined;
231
+ schema?: unknown;
232
+ content?: unknown;
233
+ style?: "matrix" | "simple" | "form" | "label" | "spaceDelimited" | "pipeDelimited" | "deepObject" | undefined;
234
+ examples?: Record<string, {
235
+ value?: unknown;
236
+ summary?: string | undefined;
237
+ }> | undefined;
238
+ }[] | undefined;
239
+ requestBody?: any;
240
+ responses?: Record<string, any> | undefined;
241
+ method?: "options" | "connect" | "delete" | "get" | "head" | "patch" | "post" | "put" | "trace" | undefined;
242
+ }>;
243
+ //# sourceMappingURL=operation.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"operation.d.ts","sourceRoot":"","sources":["../../../src/entities/spec/operation.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EACL,KAAK,cAAc,EACnB,KAAK,OAAO,IAAI,WAAW,EAE5B,MAAM,YAAY,CAAA;AAEnB,MAAM,MAAM,SAAS,GAAG,WAAW,CAAA;AACnC,MAAM,MAAM,gBAAgB,GAAG,cAAc,CAAA;AAC7C,eAAO,MAAM,eAAe;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAAgB,CAAA"}
@@ -0,0 +1,9 @@
1
+ import { requestSchema } from './requests.js';
2
+
3
+ /**
4
+ * Aliases Request to Operation which is closer to the spec,
5
+ * also will not conflict with the builtin Request class
6
+ */
7
+ const operationSchema = requestSchema;
8
+
9
+ export { operationSchema };
@@ -586,6 +586,4 @@ export declare const requestSchema: z.ZodObject<z.objectUtil.extendShape<Omit<{
586
586
  }>;
587
587
  export type Request = z.infer<typeof requestSchema>;
588
588
  export type RequestPayload = z.input<typeof requestSchema>;
589
- export type Operation = Request;
590
- export type OperationPayload = RequestPayload;
591
589
  //# sourceMappingURL=requests.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"requests.d.ts","sourceRoot":"","sources":["../../../src/entities/spec/requests.ts"],"names":[],"mappings":"AAKA,OAAO,EAAkB,CAAC,EAAE,MAAM,KAAK,CAAA;AAGvC,OAAO,EAAE,KAAK,cAAc,EAAwB,MAAM,oBAAo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KG;;IAEH,kDAAkD;;IAElD,mHAAmH;;IAEnH;;;;OAIG;;IAEH;;;;;;OAMG;;IAEH;;;;;OAKG;;IAEH;;OAEG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAEH;;OAEG;;;;;;;;;;;;IAGH,uBAAuB;;IAEvB,uBAAuB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAEvB,sBAAsB;;;;;;IAetB,eAAe;;IAEf,qBAAqB;;IAErB,kDAAkD;;IAElD,oCAAoC;;IAEpC,uDAAuD;;IAEvD,+DAA+D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAOlC,CAAA;AAE/B,MAAM,MAAM,OAAO,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,aAAa,CAAC,CAAA;AACnD,MAAM,MAAM,cAAc,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,aAAa,CAAC,CAAA"}
@@ -0,0 +1,3 @@
1
+ /** Ensure URL has a protocol prefix */
2
+ export declare function ensureProtocol(url: string): string;
3
+ //# sourceMappingURL=ensure-protocol.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ensure-protocol.d.ts","sourceRoot":"","sources":["../../src/helpers/ensure-protocol.ts"],"names":[],"mappings":"AAEA,uCAAuC;AACvC,wBAAgB,cAAc,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAMlD"}
@@ -0,0 +1,12 @@
1
+ import { REGEX } from './regexHelpers.js';
2
+
3
+ /** Ensure URL has a protocol prefix */
4
+ function ensureProtocol(url) {
5
+ if (REGEX.PATH.test(url) || REGEX.PROTOCOL.test(url)) {
6
+ return url;
7
+ }
8
+ // Default to http if no protocol is specified
9
+ return `http://${url.replace(/^\//, '')}`;
10
+ }
11
+
12
+ export { ensureProtocol };
@@ -1,6 +1,7 @@
1
1
  export { isDefined } from './is-defined.js';
2
2
  export { shouldIgnoreEntity } from './shouldIgnoreEntity.js';
3
- export * from './concatenateUrlAndPath.js';
3
+ export { combineUrlAndPath, mergeSearchParams, mergeUrls } from './merge-urls.js';
4
+ export { ensureProtocol } from './ensure-protocol.js';
4
5
  export * from './createHash.js';
5
6
  export * from './fetchSpecFromUrl.js';
6
7
  export * from './fetchWithProxyFallback.js';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/helpers/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAA;AACxC,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAA;AACzD,cAAc,yBAAyB,CAAA;AACvC,cAAc,cAAc,CAAA;AAC5B,cAAc,oBAAoB,CAAA;AAClC,cAAc,0BAA0B,CAAA;AACxC,cAAc,iBAAiB,CAAA;AAC/B,cAAc,eAAe,CAAA;AAC7B,cAAc,mBAAmB,CAAA;AACjC,cAAc,cAAc,CAAA;AAC5B,cAAc,cAAc,CAAA;AAC5B,cAAc,gBAAgB,CAAA;AAC9B,cAAc,iBAAiB,CAAA;AAC/B,cAAc,mBAAmB,CAAA;AACjC,cAAc,qBAAqB,CAAA;AACnC,cAAc,2BAA2B,CAAA;AACzC,cAAc,UAAU,CAAA;AACxB,cAAc,SAAS,CAAA;AACvB,cAAc,mBAAmB,CAAA;AACjC,cAAc,mBAAmB,CAAA;AACjC,cAAc,gBAAgB,CAAA;AAC9B,cAAc,oBAAoB,CAAA;AAClC,cAAc,gBAAgB,CAAA;AAC9B,cAAc,YAAY,CAAA;AAC1B,cAAc,UAAU,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/helpers/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAA;AACxC,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAA;AACzD,OAAO,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,SAAS,EAAE,MAAM,cAAc,CAAA;AAC9E,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAA;AAClD,cAAc,cAAc,CAAA;AAC5B,cAAc,oBAAoB,CAAA;AAClC,cAAc,0BAA0B,CAAA;AACxC,cAAc,iBAAiB,CAAA;AAC/B,cAAc,eAAe,CAAA;AAC7B,cAAc,mBAAmB,CAAA;AACjC,cAAc,cAAc,CAAA;AAC5B,cAAc,cAAc,CAAA;AAC5B,cAAc,gBAAgB,CAAA;AAC9B,cAAc,iBAAiB,CAAA;AAC/B,cAAc,mBAAmB,CAAA;AACjC,cAAc,qBAAqB,CAAA;AACnC,cAAc,2BAA2B,CAAA;AACzC,cAAc,UAAU,CAAA;AACxB,cAAc,SAAS,CAAA;AACvB,cAAc,mBAAmB,CAAA;AACjC,cAAc,mBAAmB,CAAA;AACjC,cAAc,gBAAgB,CAAA;AAC9B,cAAc,oBAAoB,CAAA;AAClC,cAAc,gBAAgB,CAAA;AAC9B,cAAc,YAAY,CAAA;AAC1B,cAAc,UAAU,CAAA"}
@@ -1,6 +1,7 @@
1
1
  export { isDefined } from './is-defined.js';
2
2
  export { shouldIgnoreEntity } from './shouldIgnoreEntity.js';
3
- export { concatenateUrlAndPath } from './concatenateUrlAndPath.js';
3
+ export { combineUrlAndPath, mergeSearchParams, mergeUrls } from './merge-urls.js';
4
+ export { ensureProtocol } from './ensure-protocol.js';
4
5
  export { createHash } from './createHash.js';
5
6
  export { fetchSpecFromUrl } from './fetchSpecFromUrl.js';
6
7
  export { fetchWithProxyFallback } from './fetchWithProxyFallback.js';
@@ -0,0 +1,15 @@
1
+ /**
2
+ * Merges multiple URLSearchParams objects, preserving multiple values per param
3
+ * within each source, but later sources overwrite earlier ones completely
4
+ * This should de-dupe our query params while allowing multiple keys for "arrays"
5
+ */
6
+ export declare const mergeSearchParams: (...params: URLSearchParams[]) => URLSearchParams;
7
+ /** Combines a base URL and a path ensuring there's only one slash between them */
8
+ export declare const combineUrlAndPath: (url: string, path: string) => string;
9
+ /**
10
+ * Creates a URL from the path and server
11
+ * also optionally merges query params if you include urlSearchParams
12
+ * This was re-written without using URL to support variables in the scheme
13
+ */
14
+ export declare const mergeUrls: (url: string, path: string, urlParams?: URLSearchParams) => string;
15
+ //# sourceMappingURL=merge-urls.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"merge-urls.d.ts","sourceRoot":"","sources":["../../src/helpers/merge-urls.ts"],"names":[],"mappings":"AAGA;;;;GAIG;AACH,eAAO,MAAM,iBAAiB,cACjB,eAAe,EAAE,KAC3B,eA6BF,CAAA;AAED,kFAAkF;AAClF,eAAO,MAAM,iBAAiB,QAAS,MAAM,QAAQ,MAAM,WAQ1D,CAAA;AAED;;;;GAIG;AACH,eAAO,MAAM,SAAS,QACf,MAAM,QACL,MAAM,cACD,eAAe,WAiC3B,CAAA"}
@@ -0,0 +1,72 @@
1
+ import { ensureProtocol } from './ensure-protocol.js';
2
+ import { isRelativePath } from './redirectToProxy.js';
3
+
4
+ /**
5
+ * Merges multiple URLSearchParams objects, preserving multiple values per param
6
+ * within each source, but later sources overwrite earlier ones completely
7
+ * This should de-dupe our query params while allowing multiple keys for "arrays"
8
+ */
9
+ const mergeSearchParams = (...params) => {
10
+ // We keep a merged record to ensure the next group will overwrite the previous
11
+ const merged = {};
12
+ // Loops over each group and grabs unique keys
13
+ params.forEach((p) => {
14
+ const keys = Array.from(p.keys());
15
+ const uniqueKeys = new Set(keys);
16
+ uniqueKeys.forEach((key) => {
17
+ const values = p.getAll(key);
18
+ const value = values.length > 1 ? values : (values[0] ?? '');
19
+ merged[key] = value;
20
+ });
21
+ });
22
+ const result = new URLSearchParams();
23
+ // We maintain multiple values for each key if they existed
24
+ Object.entries(merged).forEach(([key, value]) => {
25
+ if (Array.isArray(value)) {
26
+ value.forEach((v) => result.append(key, v));
27
+ }
28
+ else {
29
+ result.append(key, value);
30
+ }
31
+ });
32
+ return result;
33
+ };
34
+ /** Combines a base URL and a path ensuring there's only one slash between them */
35
+ const combineUrlAndPath = (url, path) => {
36
+ if (!path || url === path)
37
+ return url.trim();
38
+ // Remove trailing slash from url and leading slash from path
39
+ const cleanBase = url.replace(/\/+$/, '').trim();
40
+ const cleanPath = path.replace(/^\/+/, '').trim();
41
+ return `${cleanBase}/${cleanPath}`;
42
+ };
43
+ /**
44
+ * Creates a URL from the path and server
45
+ * also optionally merges query params if you include urlSearchParams
46
+ * This was re-written without using URL to support variables in the scheme
47
+ */
48
+ const mergeUrls = (url, path, urlParams = new URLSearchParams()) => {
49
+ // Extract and merge all query params
50
+ if (url && (!isRelativePath(url) || typeof window !== 'undefined')) {
51
+ /** Prefix the url with the origin if it is relative */
52
+ const base = isRelativePath(url)
53
+ ? combineUrlAndPath(window.location.origin, url)
54
+ : ensureProtocol(url);
55
+ // Extract search params from base URL if any
56
+ const [baseUrl = '', baseQuery] = base.split('?');
57
+ const baseParams = new URLSearchParams(baseQuery || '');
58
+ // Extract search params from path if any
59
+ const [pathWithoutQuery = '', pathQuery] = path.split('?');
60
+ const pathParams = new URLSearchParams(pathQuery || '');
61
+ // Merge the baseUrl and path
62
+ const mergedUrl = url === path ? baseUrl : combineUrlAndPath(baseUrl, pathWithoutQuery);
63
+ // Merge all search params
64
+ const mergedSearchParams = mergeSearchParams(baseParams, pathParams, urlParams);
65
+ // Build the final URL
66
+ const search = mergedSearchParams.toString();
67
+ return search ? `${mergedUrl}?${search}` : mergedUrl;
68
+ }
69
+ return url;
70
+ };
71
+
72
+ export { combineUrlAndPath, mergeSearchParams, mergeUrls };
@@ -1 +1 @@
1
- {"version":3,"file":"redirectToProxy.d.ts","sourceRoot":"","sources":["../../src/helpers/redirectToProxy.ts"],"names":[],"mappings":"AAEA,gEAAgE;AAChE,wBAAgB,eAAe,CAAC,KAAK,CAAC,EAAE,MAAM,EAAE,GAAG,CAAC,EAAE,MAAM,GAAG,MAAM,CAepE;AAED,wEAAwE;AACxE,eAAO,MAAM,cAAc,QAAS,MAAM,YAazC,CAAA;AAED,uFAAuF;AACvF,wBAAgB,cAAc,CAAC,KAAK,CAAC,EAAE,MAAM,EAAE,GAAG,CAAC,EAAE,MAAM,GAAG,OAAO,CAWpE"}
1
+ {"version":3,"file":"redirectToProxy.d.ts","sourceRoot":"","sources":["../../src/helpers/redirectToProxy.ts"],"names":[],"mappings":"AAIA,gEAAgE;AAChE,wBAAgB,eAAe,CAAC,KAAK,CAAC,EAAE,MAAM,EAAE,GAAG,CAAC,EAAE,MAAM,GAAG,MAAM,CAepE;AAED,wEAAwE;AACxE,eAAO,MAAM,cAAc,QAAS,MAAM,YAkBzC,CAAA;AAED,uFAAuF;AACvF,wBAAgB,cAAc,CAAC,KAAK,CAAC,EAAE,MAAM,EAAE,GAAG,CAAC,EAAE,MAAM,GAAG,OAAO,CAWpE"}
@@ -1,3 +1,4 @@
1
+ import { REGEX } from './regexHelpers.js';
1
2
  import { isLocalUrl } from './isLocalUrl.js';
2
3
 
3
4
  /** Redirects the request to a proxy server with a given URL. */
@@ -19,6 +20,10 @@ const isRelativePath = (url) => {
19
20
  if (url.startsWith('http://') || url.startsWith('https://')) {
20
21
  return false;
21
22
  }
23
+ // Allow other protocols such as file://
24
+ if (REGEX.PROTOCOL.test(url)) {
25
+ return false;
26
+ }
22
27
  // Check if it looks like a domain (contains dots and no spaces)
23
28
  // This catches cases like "galaxy.scalar.com/planets"
24
29
  if (/^[a-zA-Z0-9-]+\.[a-zA-Z0-9-.]+(\/|$)/.test(url)) {
@@ -1,4 +1,6 @@
1
1
  export declare const REGEX: {
2
+ /** Checks if the url starts with a protocol like file:// including {variable}:// */
3
+ readonly PROTOCOL: RegExp;
2
4
  readonly VARIABLES: RegExp;
3
5
  readonly PATH: RegExp;
4
6
  readonly TEMPLATE_VARIABLE: RegExp;
@@ -1 +1 @@
1
- {"version":3,"file":"regexHelpers.d.ts","sourceRoot":"","sources":["../../src/helpers/regexHelpers.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,KAAK;;;;CAIR,CAAA"}
1
+ {"version":3,"file":"regexHelpers.d.ts","sourceRoot":"","sources":["../../src/helpers/regexHelpers.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,KAAK;IAChB,oFAAoF;;;;;CAK5E,CAAA"}
@@ -1,4 +1,6 @@
1
1
  const REGEX = {
2
+ /** Checks if the url starts with a protocol like file:// including {variable}:// */
3
+ PROTOCOL: /^[a-zA-Z{}][a-zA-Z0-9+.{}-]*:\/\//,
2
4
  VARIABLES: /{{((?:[^{}]|{[^{}]*})*)}}/g,
3
5
  PATH: /(?:{)([^{}]+)}(?!})/g,
4
6
  TEMPLATE_VARIABLE: /{{\s*([^}\s]+?)\s*}}|{\s*([^}\s]+?)\s*}|:\b[\w.]+\b/g,
@@ -1 +1 @@
1
- {"version":3,"file":"import-spec.d.ts","sourceRoot":"","sources":["../../src/transforms/import-spec.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,2BAA2B,CAAA;AAC3E,OAAO,EACL,KAAK,UAAU,EACf,KAAK,iBAAiB,EACtB,KAAK,OAAO,EACZ,KAAK,cAAc,EAGnB,KAAK,MAAM,EACX,KAAK,GAAG,EAMT,MAAM,iBAAiB,CAAA;AACxB,OAAO,EAEL,KAAK,cAAc,EAGpB,MAAM,0BAA0B,CAAA;AAWjC,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAA;AACxD,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,sBAAsB,CAAA;AAClE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAA;AAGxD,mFAAmF;AACnF,eAAO,MAAM,WAAW,SAChB,MAAM,GAAG,aAAa;;;IAuC1B;;;OAGG;YAC8C,WAAW,CAAC,QAAQ;;EAGxE,CAAA;AAED,sDAAsD;AACtD,eAAO,MAAM,6BAA6B,yBAClB,0BAA0B,kBAChC;IAAE,uBAAuB,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C7B,UAAU,EACV,SAAiB,GAClB,GAAE,yBAA8B,GAChC,OAAO,CACN;IACE,KAAK,EAAE,KAAK,CAAA;IACZ,UAAU,EAAE,UAAU,CAAA;IACtB,QAAQ,EAAE,OAAO,EAAE,CAAA;IACnB,MAAM,EAAE,WAAW,CAAC,QAAQ,CAAA;IAC5B,QAAQ,EAAE,cAAc,EAAE,CAAA;IAC1B,OAAO,EAAE,MAAM,EAAE,CAAA;IACjB,IAAI,EAAE,GAAG,EAAE,CAAA;IACX,eAAe,EAAE,cAAc,EAAE,CAAA;CAClC,GACD;IAAE,KAAK,EAAE,IAAI,CAAC;IAAC,cAAc,EAAE,MAAM,EAAE,CAAA;CAAE,CAC5C,CA4UA;AAED;;GAEG;AACH,wBAAgB,6BAA6B,CAC3C,OAAO,EAAE,WAAW,CAAC,YAAY,EAAE,GAAG,SAAS,EAC/C,EAAE,aAAa,EAAE,GAAE,IAAI,CAAC,sBAAsB,EAAE,eAAe,CAAM,GACpE,MAAM,EAAE,CA8CV"}
@@ -9,7 +9,7 @@ import { requestSchema } from '../entities/spec/requests.js';
9
9
  import { tagSchema } from '../entities/spec/spec-objects.js';
10
10
  import { createExampleFromRequest } from '../entities/spec/request-examples.js';
11
11
  import { collectionSchema } from '../entities/spec/collection.js';
12
- import { concatenateUrlAndPath } from '../helpers/concatenateUrlAndPath.js';
12
+ import { combineUrlAndPath } from '../helpers/merge-urls.js';
13
13
 
14
14
  /** Takes a string or object and parses it into an openapi spec compliant schema */
15
15
  const parseSchema = async (spec, { shouldLoad = true } = {}) => {
@@ -87,6 +87,13 @@ async function importSpecToWorkspace(spec, { authentication, baseServerURL, docu
87
87
  const servers = getServersFromOpenApiDocument(configuredServers || schema.servers, {
88
88
  baseServerURL,
89
89
  });
90
+ // Fallback to the current window.location.origin if no servers are provided
91
+ if (!servers.length) {
92
+ const fallbackUrl = getFallbackUrl();
93
+ if (fallbackUrl) {
94
+ servers.push(serverSchema.parse({ url: fallbackUrl }));
95
+ }
96
+ }
90
97
  /**
91
98
  * List of all tag strings. For non compliant specs we may need to
92
99
  * add top level tag objects for missing tag objects
@@ -338,12 +345,13 @@ function getServersFromOpenApiDocument(servers, { baseServerURL } = {}) {
338
345
  if (parsedSchema?.url?.startsWith('/')) {
339
346
  // Use the base server URL (if provided)
340
347
  if (baseServerURL) {
341
- parsedSchema.url = concatenateUrlAndPath(baseServerURL?.replace(/\/$/, ''), parsedSchema.url.replace(/^\//, ''));
348
+ parsedSchema.url = combineUrlAndPath(baseServerURL, parsedSchema.url);
342
349
  return parsedSchema;
343
350
  }
344
351
  // Fallback to the current window origin
345
- if (typeof window?.location?.origin === 'string') {
346
- parsedSchema.url = concatenateUrlAndPath(window.location.origin, parsedSchema.url.replace(/^\//, ''));
352
+ const fallbackUrl = getFallbackUrl();
353
+ if (fallbackUrl) {
354
+ parsedSchema.url = combineUrlAndPath(fallbackUrl, parsedSchema.url.replace(/^\//, ''));
347
355
  return parsedSchema;
348
356
  }
349
357
  }
@@ -360,5 +368,17 @@ function getServersFromOpenApiDocument(servers, { baseServerURL } = {}) {
360
368
  })
361
369
  .filter(isDefined);
362
370
  }
371
+ /**
372
+ * Fallback to the current window.location.origin, if available
373
+ */
374
+ function getFallbackUrl() {
375
+ if (typeof window === 'undefined') {
376
+ return undefined;
377
+ }
378
+ if (typeof window?.location?.origin !== 'string') {
379
+ return undefined;
380
+ }
381
+ return window.location.origin;
382
+ }
363
383
 
364
384
  export { getSelectedSecuritySchemeUids, getServersFromOpenApiDocument, importSpecToWorkspace, parseSchema };
package/package.json CHANGED
@@ -16,7 +16,7 @@
16
16
  "specification",
17
17
  "yaml"
18
18
  ],
19
- "version": "0.2.102",
19
+ "version": "0.2.103",
20
20
  "engines": {
21
21
  "node": ">=18"
22
22
  },
@@ -127,9 +127,9 @@
127
127
  "yaml": "^2.4.5",
128
128
  "zod": "^3.23.8",
129
129
  "@scalar/object-utils": "1.1.12",
130
- "@scalar/themes": "0.9.64",
131
130
  "@scalar/openapi-types": "0.1.7",
132
- "@scalar/types": "0.0.30"
131
+ "@scalar/themes": "0.9.65",
132
+ "@scalar/types": "0.0.31"
133
133
  },
134
134
  "devDependencies": {
135
135
  "type-fest": "^4.20.0",
@@ -137,7 +137,7 @@
137
137
  "vitest": "^1.6.0",
138
138
  "zod-to-ts": "github:amritk/zod-to-ts#build",
139
139
  "@scalar/build-tooling": "0.1.12",
140
- "@scalar/openapi-parser": "0.10.4",
140
+ "@scalar/openapi-parser": "0.10.5",
141
141
  "@scalar/openapi-types": "0.1.7"
142
142
  },
143
143
  "scripts": {
@@ -1,5 +0,0 @@
1
- /**
2
- * Make sure the URL and path are concatenated correctly.
3
- */
4
- export declare const concatenateUrlAndPath: (url: string, path?: string) => string;
5
- //# sourceMappingURL=concatenateUrlAndPath.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"concatenateUrlAndPath.d.ts","sourceRoot":"","sources":["../../src/helpers/concatenateUrlAndPath.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,eAAO,MAAM,qBAAqB,QAAS,MAAM,SAAS,MAAM,WAc/D,CAAA"}
@@ -1,17 +0,0 @@
1
- /**
2
- * Make sure the URL and path are concatenated correctly.
3
- */
4
- const concatenateUrlAndPath = (url, path) => {
5
- if (typeof path !== 'string' || !path.length) {
6
- return url;
7
- }
8
- const trimmedUrl = url.trim();
9
- const trimmedPath = path.trim();
10
- const urlWithSlash = trimmedUrl.endsWith('/') ? trimmedUrl : `${trimmedUrl}/`;
11
- const pathWithoutSlash = trimmedPath.startsWith('/')
12
- ? trimmedPath.slice(1)
13
- : trimmedPath;
14
- return [urlWithSlash, pathWithoutSlash].join('');
15
- };
16
-
17
- export { concatenateUrlAndPath };