@scalar/oas-utils 0.2.140 → 0.2.141

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.
Files changed (280) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/dist/entities/cookie/cookie.js +14 -13
  3. package/dist/entities/cookie/cookie.js.map +7 -0
  4. package/dist/entities/cookie/index.d.ts +1 -1
  5. package/dist/entities/cookie/index.d.ts.map +1 -1
  6. package/dist/entities/cookie/index.js +5 -1
  7. package/dist/entities/cookie/index.js.map +7 -0
  8. package/dist/entities/environment/environment.js +10 -9
  9. package/dist/entities/environment/environment.js.map +7 -0
  10. package/dist/entities/environment/index.d.ts +1 -1
  11. package/dist/entities/environment/index.d.ts.map +1 -1
  12. package/dist/entities/environment/index.js +5 -1
  13. package/dist/entities/environment/index.js.map +7 -0
  14. package/dist/entities/hotkeys/hotkeys.js +109 -116
  15. package/dist/entities/hotkeys/hotkeys.js.map +7 -0
  16. package/dist/entities/hotkeys/index.d.ts +1 -1
  17. package/dist/entities/hotkeys/index.d.ts.map +1 -1
  18. package/dist/entities/hotkeys/index.js +6 -1
  19. package/dist/entities/hotkeys/index.js.map +7 -0
  20. package/dist/entities/shared/index.d.ts +1 -1
  21. package/dist/entities/shared/index.d.ts.map +1 -1
  22. package/dist/entities/shared/index.js +7 -1
  23. package/dist/entities/shared/index.js.map +7 -0
  24. package/dist/entities/shared/utility.js +9 -12
  25. package/dist/entities/shared/utility.js.map +7 -0
  26. package/dist/entities/spec/collection.d.ts.map +1 -1
  27. package/dist/entities/spec/collection.js +91 -94
  28. package/dist/entities/spec/collection.js.map +7 -0
  29. package/dist/entities/spec/index.d.ts +8 -8
  30. package/dist/entities/spec/index.d.ts.map +1 -1
  31. package/dist/entities/spec/index.js +59 -9
  32. package/dist/entities/spec/index.js.map +7 -0
  33. package/dist/entities/spec/operation.d.ts +1 -1
  34. package/dist/entities/spec/operation.d.ts.map +1 -1
  35. package/dist/entities/spec/operation.js +5 -8
  36. package/dist/entities/spec/operation.js.map +7 -0
  37. package/dist/entities/spec/operation.test.js +43 -0
  38. package/dist/entities/spec/operation.test.js.map +7 -0
  39. package/dist/entities/spec/parameters.d.ts +1 -1
  40. package/dist/entities/spec/parameters.d.ts.map +1 -1
  41. package/dist/entities/spec/parameters.js +40 -38
  42. package/dist/entities/spec/parameters.js.map +7 -0
  43. package/dist/entities/spec/parameters.test.js +71 -0
  44. package/dist/entities/spec/parameters.test.js.map +7 -0
  45. package/dist/entities/spec/request-example.test.js +637 -0
  46. package/dist/entities/spec/request-example.test.js.map +7 -0
  47. package/dist/entities/spec/request-examples.d.ts +3 -3
  48. package/dist/entities/spec/request-examples.d.ts.map +1 -1
  49. package/dist/entities/spec/request-examples.js +323 -338
  50. package/dist/entities/spec/request-examples.js.map +7 -0
  51. package/dist/entities/spec/requests.d.ts +6 -8
  52. package/dist/entities/spec/requests.d.ts.map +1 -1
  53. package/dist/entities/spec/requests.js +80 -101
  54. package/dist/entities/spec/requests.js.map +7 -0
  55. package/dist/entities/spec/server.js +47 -63
  56. package/dist/entities/spec/server.js.map +7 -0
  57. package/dist/entities/spec/server.test.js +120 -0
  58. package/dist/entities/spec/server.test.js.map +7 -0
  59. package/dist/entities/spec/spec-objects.d.ts.map +1 -1
  60. package/dist/entities/spec/spec-objects.js +77 -121
  61. package/dist/entities/spec/spec-objects.js.map +7 -0
  62. package/dist/entities/spec/spec-objects.test.js +205 -0
  63. package/dist/entities/spec/spec-objects.test.js.map +7 -0
  64. package/dist/entities/spec/x-scalar-environments.js +21 -18
  65. package/dist/entities/spec/x-scalar-environments.js.map +7 -0
  66. package/dist/entities/spec/x-scalar-environments.test.js +11 -0
  67. package/dist/entities/spec/x-scalar-environments.test.js.map +7 -0
  68. package/dist/entities/spec/x-scalar-secrets.js +8 -6
  69. package/dist/entities/spec/x-scalar-secrets.js.map +7 -0
  70. package/dist/entities/spec/x-scalar-secrets.test.js +11 -0
  71. package/dist/entities/spec/x-scalar-secrets.test.js.map +7 -0
  72. package/dist/entities/workspace/index.d.ts +1 -1
  73. package/dist/entities/workspace/index.d.ts.map +1 -1
  74. package/dist/entities/workspace/index.js +7 -1
  75. package/dist/entities/workspace/index.js.map +7 -0
  76. package/dist/entities/workspace/workspace.js +46 -50
  77. package/dist/entities/workspace/workspace.js.map +7 -0
  78. package/dist/helpers/create-hash.js +15 -18
  79. package/dist/helpers/create-hash.js.map +7 -0
  80. package/dist/helpers/ensure-protocol.js +9 -10
  81. package/dist/helpers/ensure-protocol.js.map +7 -0
  82. package/dist/helpers/ensure-protocol.test.js +70 -0
  83. package/dist/helpers/ensure-protocol.test.js.map +7 -0
  84. package/dist/helpers/fetch-document.js +24 -32
  85. package/dist/helpers/fetch-document.js.map +7 -0
  86. package/dist/helpers/fetch-document.test.js +63 -0
  87. package/dist/helpers/fetch-document.test.js.map +7 -0
  88. package/dist/helpers/fetch-with-proxy-fallback.js +20 -28
  89. package/dist/helpers/fetch-with-proxy-fallback.js.map +7 -0
  90. package/dist/helpers/find-variables.d.ts +1 -1
  91. package/dist/helpers/find-variables.d.ts.map +1 -1
  92. package/dist/helpers/find-variables.js +6 -8
  93. package/dist/helpers/find-variables.js.map +7 -0
  94. package/dist/helpers/find-variables.test.js +20 -0
  95. package/dist/helpers/find-variables.test.js.map +7 -0
  96. package/dist/helpers/http-methods.d.ts +1 -1
  97. package/dist/helpers/http-methods.d.ts.map +1 -1
  98. package/dist/helpers/http-methods.js +60 -66
  99. package/dist/helpers/http-methods.js.map +7 -0
  100. package/dist/helpers/http-status-codes.js +319 -317
  101. package/dist/helpers/http-status-codes.js.map +7 -0
  102. package/dist/helpers/index.d.ts +27 -27
  103. package/dist/helpers/index.d.ts.map +1 -1
  104. package/dist/helpers/index.js +73 -27
  105. package/dist/helpers/index.js.map +7 -0
  106. package/dist/helpers/is-defined.js +5 -14
  107. package/dist/helpers/is-defined.js.map +7 -0
  108. package/dist/helpers/is-defined.test.js +37 -0
  109. package/dist/helpers/is-defined.test.js.map +7 -0
  110. package/dist/helpers/is-local-url.js +11 -16
  111. package/dist/helpers/is-local-url.js.map +7 -0
  112. package/dist/helpers/is-local-url.test.js +40 -0
  113. package/dist/helpers/is-local-url.test.js.map +7 -0
  114. package/dist/helpers/is-valid-url.js +9 -18
  115. package/dist/helpers/is-valid-url.js.map +7 -0
  116. package/dist/helpers/is-valid-url.test.js +17 -0
  117. package/dist/helpers/is-valid-url.test.js.map +7 -0
  118. package/dist/helpers/iterate-title.js +11 -15
  119. package/dist/helpers/iterate-title.js.map +7 -0
  120. package/dist/helpers/json2xml.js +40 -47
  121. package/dist/helpers/json2xml.js.map +7 -0
  122. package/dist/helpers/json2xml.test.js +19 -0
  123. package/dist/helpers/json2xml.test.js.map +7 -0
  124. package/dist/helpers/local-storage.js +13 -15
  125. package/dist/helpers/local-storage.js.map +7 -0
  126. package/dist/helpers/make-url-absolute.js +11 -17
  127. package/dist/helpers/make-url-absolute.js.map +7 -0
  128. package/dist/helpers/make-url-absolute.test.js +61 -0
  129. package/dist/helpers/make-url-absolute.test.js.map +7 -0
  130. package/dist/helpers/merge-urls.js +50 -75
  131. package/dist/helpers/merge-urls.js.map +7 -0
  132. package/dist/helpers/merge-urls.test.js +339 -0
  133. package/dist/helpers/merge-urls.test.js.map +7 -0
  134. package/dist/helpers/normalize-mime-type-object.js +21 -31
  135. package/dist/helpers/normalize-mime-type-object.js.map +7 -0
  136. package/dist/helpers/normalize-mime-type-object.test.js +53 -0
  137. package/dist/helpers/normalize-mime-type-object.test.js.map +7 -0
  138. package/dist/helpers/normalize-mime-type.js +8 -18
  139. package/dist/helpers/normalize-mime-type.js.map +7 -0
  140. package/dist/helpers/normalize-mime-type.test.js +33 -0
  141. package/dist/helpers/normalize-mime-type.test.js.map +7 -0
  142. package/dist/helpers/object.js +12 -18
  143. package/dist/helpers/object.js.map +7 -0
  144. package/dist/helpers/omit-undefined-values.js +17 -19
  145. package/dist/helpers/omit-undefined-values.js.map +7 -0
  146. package/dist/helpers/omit-undefined-values.test.js +89 -0
  147. package/dist/helpers/omit-undefined-values.test.js.map +7 -0
  148. package/dist/helpers/parse.js +71 -83
  149. package/dist/helpers/parse.js.map +7 -0
  150. package/dist/helpers/parse.test.js +45 -0
  151. package/dist/helpers/parse.test.js.map +7 -0
  152. package/dist/helpers/pretty-print-json.js +31 -35
  153. package/dist/helpers/pretty-print-json.js.map +7 -0
  154. package/dist/helpers/pretty-print-json.test.js +28 -0
  155. package/dist/helpers/pretty-print-json.test.js.map +7 -0
  156. package/dist/helpers/redirect-to-proxy.js +46 -83
  157. package/dist/helpers/redirect-to-proxy.js.map +7 -0
  158. package/dist/helpers/redirect-to-proxy.test.js +54 -0
  159. package/dist/helpers/redirect-to-proxy.test.js.map +7 -0
  160. package/dist/helpers/regex-helpers.js +11 -9
  161. package/dist/helpers/regex-helpers.js.map +7 -0
  162. package/dist/helpers/regex-helpers.test.js +154 -0
  163. package/dist/helpers/regex-helpers.test.js.map +7 -0
  164. package/dist/helpers/replace-variables.js +13 -16
  165. package/dist/helpers/replace-variables.js.map +7 -0
  166. package/dist/helpers/replace-variables.test.js +30 -0
  167. package/dist/helpers/replace-variables.test.js.map +7 -0
  168. package/dist/helpers/schema-model.js +15 -14
  169. package/dist/helpers/schema-model.js.map +7 -0
  170. package/dist/helpers/security/get-schemes.d.ts +1 -1
  171. package/dist/helpers/security/get-schemes.d.ts.map +1 -1
  172. package/dist/helpers/security/get-schemes.js +7 -9
  173. package/dist/helpers/security/get-schemes.js.map +7 -0
  174. package/dist/helpers/security/get-schemes.test.js +71 -0
  175. package/dist/helpers/security/get-schemes.test.js.map +7 -0
  176. package/dist/helpers/security/has-token.js +18 -19
  177. package/dist/helpers/security/has-token.js.map +7 -0
  178. package/dist/helpers/security/has-token.test.js +157 -0
  179. package/dist/helpers/security/has-token.test.js.map +7 -0
  180. package/dist/helpers/security/index.d.ts +2 -2
  181. package/dist/helpers/security/index.d.ts.map +1 -1
  182. package/dist/helpers/security/index.js +7 -2
  183. package/dist/helpers/security/index.js.map +7 -0
  184. package/dist/helpers/should-ignore-entity.d.ts +2 -2
  185. package/dist/helpers/should-ignore-entity.d.ts.map +1 -1
  186. package/dist/helpers/should-ignore-entity.js +5 -6
  187. package/dist/helpers/should-ignore-entity.js.map +7 -0
  188. package/dist/helpers/ssr-state.js +6 -6
  189. package/dist/helpers/ssr-state.js.map +7 -0
  190. package/dist/helpers/string.js +6 -18
  191. package/dist/helpers/string.js.map +7 -0
  192. package/dist/migrations/data-version.js +7 -17
  193. package/dist/migrations/data-version.js.map +7 -0
  194. package/dist/migrations/generate-types.js +56 -0
  195. package/dist/migrations/generate-types.js.map +7 -0
  196. package/dist/migrations/index.d.ts +3 -3
  197. package/dist/migrations/index.d.ts.map +1 -1
  198. package/dist/migrations/index.js +10 -3
  199. package/dist/migrations/index.js.map +7 -0
  200. package/dist/migrations/local-storage.d.ts +1 -1
  201. package/dist/migrations/local-storage.d.ts.map +1 -1
  202. package/dist/migrations/local-storage.js +27 -32
  203. package/dist/migrations/local-storage.js.map +7 -0
  204. package/dist/migrations/migrator.d.ts +1 -1
  205. package/dist/migrations/migrator.d.ts.map +1 -1
  206. package/dist/migrations/migrator.js +51 -58
  207. package/dist/migrations/migrator.js.map +7 -0
  208. package/dist/migrations/semver.js +23 -25
  209. package/dist/migrations/semver.js.map +7 -0
  210. package/dist/migrations/semver.test.js +21 -0
  211. package/dist/migrations/semver.test.js.map +7 -0
  212. package/dist/migrations/v-0.0.0/types.generated.js +1 -0
  213. package/dist/migrations/v-0.0.0/types.generated.js.map +7 -0
  214. package/dist/migrations/v-2.1.0/migration.d.ts +2 -2
  215. package/dist/migrations/v-2.1.0/migration.d.ts.map +1 -1
  216. package/dist/migrations/v-2.1.0/migration.js +256 -273
  217. package/dist/migrations/v-2.1.0/migration.js.map +7 -0
  218. package/dist/migrations/v-2.1.0/types.generated.js +1 -0
  219. package/dist/migrations/v-2.1.0/types.generated.js.map +7 -0
  220. package/dist/migrations/v-2.2.0/migration.d.ts +2 -2
  221. package/dist/migrations/v-2.2.0/migration.d.ts.map +1 -1
  222. package/dist/migrations/v-2.2.0/migration.js +95 -100
  223. package/dist/migrations/v-2.2.0/migration.js.map +7 -0
  224. package/dist/migrations/v-2.2.0/types.generated.js +1 -0
  225. package/dist/migrations/v-2.2.0/types.generated.js.map +7 -0
  226. package/dist/migrations/v-2.3.0/migration.d.ts +2 -2
  227. package/dist/migrations/v-2.3.0/migration.d.ts.map +1 -1
  228. package/dist/migrations/v-2.3.0/migration.js +47 -46
  229. package/dist/migrations/v-2.3.0/migration.js.map +7 -0
  230. package/dist/migrations/v-2.3.0/types.generated.js +1 -0
  231. package/dist/migrations/v-2.3.0/types.generated.js.map +7 -0
  232. package/dist/migrations/v-2.4.0/migration.d.ts +2 -2
  233. package/dist/migrations/v-2.4.0/migration.d.ts.map +1 -1
  234. package/dist/migrations/v-2.4.0/migration.js +24 -26
  235. package/dist/migrations/v-2.4.0/migration.js.map +7 -0
  236. package/dist/migrations/v-2.4.0/migration.test.js +90 -0
  237. package/dist/migrations/v-2.4.0/migration.test.js.map +7 -0
  238. package/dist/migrations/v-2.4.0/types.generated.js +1 -0
  239. package/dist/migrations/v-2.4.0/types.generated.js.map +7 -0
  240. package/dist/migrations/v-2.5.0/migration.d.ts +2 -2
  241. package/dist/migrations/v-2.5.0/migration.d.ts.map +1 -1
  242. package/dist/migrations/v-2.5.0/migration.js +135 -119
  243. package/dist/migrations/v-2.5.0/migration.js.map +7 -0
  244. package/dist/migrations/v-2.5.0/migration.test.js +108 -0
  245. package/dist/migrations/v-2.5.0/migration.test.js.map +7 -0
  246. package/dist/migrations/v-2.5.0/types.generated.d.ts +8 -8
  247. package/dist/migrations/v-2.5.0/types.generated.d.ts.map +1 -1
  248. package/dist/migrations/v-2.5.0/types.generated.js +1 -0
  249. package/dist/migrations/v-2.5.0/types.generated.js.map +7 -0
  250. package/dist/spec-getters/get-example-from-schema.js +206 -268
  251. package/dist/spec-getters/get-example-from-schema.js.map +7 -0
  252. package/dist/spec-getters/get-example-from-schema.test.js +1092 -0
  253. package/dist/spec-getters/get-example-from-schema.test.js.map +7 -0
  254. package/dist/spec-getters/get-parameters-from-operation.js +22 -42
  255. package/dist/spec-getters/get-parameters-from-operation.js.map +7 -0
  256. package/dist/spec-getters/get-parameters-from-operation.test.js +178 -0
  257. package/dist/spec-getters/get-parameters-from-operation.test.js.map +7 -0
  258. package/dist/spec-getters/get-request-body-from-operation.js +110 -162
  259. package/dist/spec-getters/get-request-body-from-operation.js.map +7 -0
  260. package/dist/spec-getters/get-request-body-from-operation.test.js +289 -0
  261. package/dist/spec-getters/get-request-body-from-operation.test.js.map +7 -0
  262. package/dist/spec-getters/get-server-variable-examples.d.ts +1 -1
  263. package/dist/spec-getters/get-server-variable-examples.d.ts.map +1 -1
  264. package/dist/spec-getters/get-server-variable-examples.js +12 -11
  265. package/dist/spec-getters/get-server-variable-examples.js.map +7 -0
  266. package/dist/spec-getters/index.d.ts +4 -4
  267. package/dist/spec-getters/index.d.ts.map +1 -1
  268. package/dist/spec-getters/index.js +11 -4
  269. package/dist/spec-getters/index.js.map +7 -0
  270. package/dist/transforms/import-spec.d.ts +6 -6
  271. package/dist/transforms/import-spec.d.ts.map +1 -1
  272. package/dist/transforms/import-spec.js +313 -425
  273. package/dist/transforms/import-spec.js.map +7 -0
  274. package/dist/transforms/import-spec.test.js +1124 -0
  275. package/dist/transforms/import-spec.test.js.map +7 -0
  276. package/dist/transforms/index.d.ts +1 -1
  277. package/dist/transforms/index.d.ts.map +1 -1
  278. package/dist/transforms/index.js +7 -1
  279. package/dist/transforms/index.js.map +7 -0
  280. package/package.json +9 -10
@@ -0,0 +1,71 @@
1
+ import { securitySchemeSchema } from "@scalar/types/entities";
2
+ import { describe, it, expect } from "vitest";
3
+ import { getSchemes } from "./get-schemes.js";
4
+ describe("getSchemes", () => {
5
+ const mockSecuritySchemes = {
6
+ "auth1-uid": securitySchemeSchema.parse({
7
+ uid: "auth1-uid",
8
+ type: "http",
9
+ scheme: "bearer"
10
+ }),
11
+ "auth2-uid": securitySchemeSchema.parse({
12
+ uid: "auth2-uid",
13
+ type: "apiKey",
14
+ in: "header"
15
+ }),
16
+ "auth3-uid": securitySchemeSchema.parse({
17
+ uid: "auth3-uid",
18
+ type: "oauth2",
19
+ flows: {}
20
+ })
21
+ };
22
+ it("should return empty array for empty input", () => {
23
+ const result = getSchemes([], mockSecuritySchemes);
24
+ expect(result).toEqual([]);
25
+ });
26
+ it("should handle single-level array of UIDs", () => {
27
+ const result = getSchemes(
28
+ ["auth1-uid", "auth2-uid"],
29
+ mockSecuritySchemes
30
+ );
31
+ expect(result).toHaveLength(2);
32
+ expect(result).toEqual([mockSecuritySchemes["auth1-uid"], mockSecuritySchemes["auth2-uid"]]);
33
+ });
34
+ it("should handle nested arrays of UIDs", () => {
35
+ const result = getSchemes(
36
+ [["auth1-uid"], ["auth2-uid", "auth3-uid"]],
37
+ mockSecuritySchemes
38
+ );
39
+ expect(result).toHaveLength(3);
40
+ expect(result).toEqual([
41
+ mockSecuritySchemes["auth1-uid"],
42
+ mockSecuritySchemes["auth2-uid"],
43
+ mockSecuritySchemes["auth3-uid"]
44
+ ]);
45
+ });
46
+ it("should deduplicate UIDs", () => {
47
+ const result = getSchemes(
48
+ [
49
+ ["auth1-uid", "auth1-uid"],
50
+ ["auth1-uid", "auth2-uid"]
51
+ ],
52
+ mockSecuritySchemes
53
+ );
54
+ expect(result).toHaveLength(2);
55
+ expect(result).toEqual([mockSecuritySchemes["auth1-uid"], mockSecuritySchemes["auth2-uid"]]);
56
+ });
57
+ it("should filter out undefined schemes", () => {
58
+ const result = getSchemes(
59
+ ["auth1-uid", "nonexistent-uid", "auth2-uid"],
60
+ mockSecuritySchemes
61
+ );
62
+ expect(result).toHaveLength(2);
63
+ expect(result).toEqual([mockSecuritySchemes["auth1-uid"], mockSecuritySchemes["auth2-uid"]]);
64
+ });
65
+ it("should handle empty nested arrays", () => {
66
+ const result = getSchemes([[], ["auth1-uid"], []], mockSecuritySchemes);
67
+ expect(result).toHaveLength(1);
68
+ expect(result).toEqual([mockSecuritySchemes["auth1-uid"]]);
69
+ });
70
+ });
71
+ //# sourceMappingURL=get-schemes.test.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/helpers/security/get-schemes.test.ts"],
4
+ "sourcesContent": ["import { securitySchemeSchema, type SecurityScheme } from '@scalar/types/entities'\nimport { describe, it, expect } from 'vitest'\n\nimport { getSchemes } from './get-schemes'\nimport type { Operation } from '@/entities/spec/operation'\n\ndescribe('getSchemes', () => {\n // Setup some mock security schemes for testing\n const mockSecuritySchemes: Record<string, SecurityScheme> = {\n 'auth1-uid': securitySchemeSchema.parse({\n uid: 'auth1-uid',\n type: 'http',\n scheme: 'bearer',\n }),\n 'auth2-uid': securitySchemeSchema.parse({\n uid: 'auth2-uid',\n type: 'apiKey',\n in: 'header',\n }),\n 'auth3-uid': securitySchemeSchema.parse({\n uid: 'auth3-uid',\n type: 'oauth2',\n flows: {},\n }),\n }\n\n it('should return empty array for empty input', () => {\n const result = getSchemes([], mockSecuritySchemes)\n expect(result).toEqual([])\n })\n\n it('should handle single-level array of UIDs', () => {\n const result = getSchemes(\n ['auth1-uid', 'auth2-uid'] as Operation['selectedSecuritySchemeUids'],\n mockSecuritySchemes,\n )\n expect(result).toHaveLength(2)\n expect(result).toEqual([mockSecuritySchemes['auth1-uid'], mockSecuritySchemes['auth2-uid']])\n })\n\n it('should handle nested arrays of UIDs', () => {\n const result = getSchemes(\n [['auth1-uid'], ['auth2-uid', 'auth3-uid']] as Operation['selectedSecuritySchemeUids'],\n mockSecuritySchemes,\n )\n expect(result).toHaveLength(3)\n expect(result).toEqual([\n mockSecuritySchemes['auth1-uid'],\n mockSecuritySchemes['auth2-uid'],\n mockSecuritySchemes['auth3-uid'],\n ])\n })\n\n it('should deduplicate UIDs', () => {\n const result = getSchemes(\n [\n ['auth1-uid', 'auth1-uid'],\n ['auth1-uid', 'auth2-uid'],\n ] as Operation['selectedSecuritySchemeUids'],\n mockSecuritySchemes,\n )\n expect(result).toHaveLength(2)\n expect(result).toEqual([mockSecuritySchemes['auth1-uid'], mockSecuritySchemes['auth2-uid']])\n })\n\n it('should filter out undefined schemes', () => {\n const result = getSchemes(\n ['auth1-uid', 'nonexistent-uid', 'auth2-uid'] as Operation['selectedSecuritySchemeUids'],\n mockSecuritySchemes,\n )\n expect(result).toHaveLength(2)\n expect(result).toEqual([mockSecuritySchemes['auth1-uid'], mockSecuritySchemes['auth2-uid']])\n })\n\n it('should handle empty nested arrays', () => {\n const result = getSchemes([[], ['auth1-uid'], []] as Operation['selectedSecuritySchemeUids'], mockSecuritySchemes)\n expect(result).toHaveLength(1)\n expect(result).toEqual([mockSecuritySchemes['auth1-uid']])\n })\n})\n"],
5
+ "mappings": "AAAA,SAAS,4BAAiD;AAC1D,SAAS,UAAU,IAAI,cAAc;AAErC,SAAS,kBAAkB;AAG3B,SAAS,cAAc,MAAM;AAE3B,QAAM,sBAAsD;AAAA,IAC1D,aAAa,qBAAqB,MAAM;AAAA,MACtC,KAAK;AAAA,MACL,MAAM;AAAA,MACN,QAAQ;AAAA,IACV,CAAC;AAAA,IACD,aAAa,qBAAqB,MAAM;AAAA,MACtC,KAAK;AAAA,MACL,MAAM;AAAA,MACN,IAAI;AAAA,IACN,CAAC;AAAA,IACD,aAAa,qBAAqB,MAAM;AAAA,MACtC,KAAK;AAAA,MACL,MAAM;AAAA,MACN,OAAO,CAAC;AAAA,IACV,CAAC;AAAA,EACH;AAEA,KAAG,6CAA6C,MAAM;AACpD,UAAM,SAAS,WAAW,CAAC,GAAG,mBAAmB;AACjD,WAAO,MAAM,EAAE,QAAQ,CAAC,CAAC;AAAA,EAC3B,CAAC;AAED,KAAG,4CAA4C,MAAM;AACnD,UAAM,SAAS;AAAA,MACb,CAAC,aAAa,WAAW;AAAA,MACzB;AAAA,IACF;AACA,WAAO,MAAM,EAAE,aAAa,CAAC;AAC7B,WAAO,MAAM,EAAE,QAAQ,CAA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on the scheme type */
2
1
  const hasToken = (scheme) => {
3
- // ApiKey
4
- if (scheme.type === 'apiKey') {
5
- return Boolean(scheme.value);
6
- }
7
- // Http
8
- if (scheme.type === 'http') {
9
- return Boolean((scheme.scheme === 'bearer' && scheme.token) || (scheme.scheme === 'basic' && scheme.username && scheme.password));
10
- }
11
- // OAuth2 just check for A token
12
- if (scheme.type === 'oauth2') {
13
- return Boolean(scheme.flows.authorizationCode?.token ||
14
- scheme.flows.clientCredentials?.token ||
15
- scheme.flows.password?.token ||
16
- scheme.flows.implicit?.token);
17
- }
18
- return false;
2
+ if (scheme.type === "apiKey") {
3
+ return Boolean(scheme.value);
4
+ }
5
+ if (scheme.type === "http") {
6
+ return Boolean(
7
+ scheme.scheme === "bearer" && scheme.token || scheme.scheme === "basic" && scheme.username && scheme.password
8
+ );
9
+ }
10
+ if (scheme.type === "oauth2") {
11
+ return Boolean(
12
+ scheme.flows.authorizationCode?.token || scheme.flows.clientCredentials?.token || scheme.flows.password?.token || scheme.flows.implicit?.token
13
+ );
14
+ }
15
+ return false;
19
16
  };
20
-
21
- export { hasToken };
17
+ export {
18
+ hasToken
19
+ };
20
+ //# sourceMappingURL=has-token.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/helpers/security/has-token.ts"],
4
+ "sourcesContent": ["import type { SecurityScheme } from '@scalar/types/entities'\n\n/** Pass in a security scheme and it will return true if it has a token or value depending on the scheme type */\nexport const hasToken = (scheme: SecurityScheme): Boolean => {\n // ApiKey\n if (scheme.type === 'apiKey') {\n return Boolean(scheme.value)\n }\n\n // Http\n if (scheme.type === 'http') {\n return Boolean(\n (scheme.scheme === 'bearer' && scheme.token) || (scheme.scheme === 'basic' && scheme.username && scheme.password),\n )\n }\n\n // OAuth2 just check for A token\n if (scheme.type === 'oauth2') {\n return Boolean(\n scheme.flows.authorizationCode?.token ||\n scheme.flows.clientCredentials?.token ||\n scheme.flows.password?.token ||\n scheme.flows.implicit?.token,\n )\n }\n\n return false\n}\n"],
5
+ "mappings": "AAGO,MAAM,WAAW,CAAC,WAAoC;AAE3D,MAAI,OAAO,SAAS,UAAU;AAC5B,WAAO,QAAQ,OAAO,KAAK;AAAA,EAC7B;AAGA,MAAI,OAAO,SAAS,QAAQ;AAC1B,WAAO;AAAA,MACJ,OAAO,WAAW,YAAY,OAAO,SAAW,OAAO,WAAW,WAAW,OAAO,YAAY,OAAO;AAAA,IAC1G;AAAA,EACF;AAGA,MAAI,OAAO,SAAS,UAAU;AAC5B,WAAO;AAAA,MACL,OAAO,MAAM,mBAAmB,SAC9B,OAAO,MAAM,mBAAmB,SAChC,OAAO,MAAM,UAAU,SACvB,OAAO,MAAM,UAAU;AAAA,IAC3B;AAAA,EACF;AAEA,SAAO;AACT;",
6
+ "names": []
7
+ }
@@ -0,0 +1,157 @@
1
+ import { securitySchemeSchema } from "@scalar/types/entities";
2
+ import { describe, it, expect } from "vitest";
3
+ import { hasToken } from "./has-token.js";
4
+ describe("hasToken", () => {
5
+ describe("apiKey scheme", () => {
6
+ it("returns true when value is present", () => {
7
+ const scheme = securitySchemeSchema.parse({
8
+ type: "apiKey",
9
+ value: "my-api-key",
10
+ in: "header",
11
+ name: "x-api-key"
12
+ });
13
+ expect(hasToken(scheme)).toBe(true);
14
+ });
15
+ it("returns false when value is empty", () => {
16
+ const scheme = securitySchemeSchema.parse({
17
+ type: "apiKey",
18
+ value: "",
19
+ in: "header",
20
+ name: "x-api-key"
21
+ });
22
+ expect(hasToken(scheme)).toBe(false);
23
+ });
24
+ });
25
+ describe("http scheme", () => {
26
+ describe("bearer", () => {
27
+ it("returns true when token is present", () => {
28
+ const scheme = securitySchemeSchema.parse({
29
+ type: "http",
30
+ scheme: "bearer",
31
+ token: "my-bearer-token"
32
+ });
33
+ expect(hasToken(scheme)).toBe(true);
34
+ });
35
+ it("returns false when token is empty", () => {
36
+ const scheme = securitySchemeSchema.parse({
37
+ type: "http",
38
+ scheme: "bearer",
39
+ token: ""
40
+ });
41
+ expect(hasToken(scheme)).toBe(false);
42
+ });
43
+ });
44
+ describe("basic", () => {
45
+ it("returns true when both username and password are present", () => {
46
+ const scheme = securitySchemeSchema.parse({
47
+ type: "http",
48
+ scheme: "basic",
49
+ username: "user",
50
+ password: "pass"
51
+ });
52
+ expect(hasToken(scheme)).toBe(true);
53
+ });
54
+ it("returns false when username is missing", () => {
55
+ const scheme = securitySchemeSchema.parse({
56
+ type: "http",
57
+ scheme: "basic",
58
+ username: "",
59
+ password: "pass"
60
+ });
61
+ expect(hasToken(scheme)).toBe(false);
62
+ });
63
+ it("returns false when password is missing", () => {
64
+ const scheme = securitySchemeSchema.parse({
65
+ type: "http",
66
+ scheme: "basic",
67
+ username: "user",
68
+ password: ""
69
+ });
70
+ expect(hasToken(scheme)).toBe(false);
71
+ });
72
+ });
73
+ });
74
+ describe("oauth2 scheme", () => {
75
+ it("returns true when authorization code flow has token", () => {
76
+ const scheme = securitySchemeSchema.parse({
77
+ type: "oauth2",
78
+ flows: {
79
+ authorizationCode: {
80
+ token: "auth-code-token",
81
+ authorizationUrl: "https://auth.example.com",
82
+ tokenUrl: "https://token.example.com",
83
+ scopes: {}
84
+ }
85
+ }
86
+ });
87
+ expect(hasToken(scheme)).toBe(true);
88
+ });
89
+ it("returns true when client credentials flow has token", () => {
90
+ const scheme = securitySchemeSchema.parse({
91
+ type: "oauth2",
92
+ flows: {
93
+ clientCredentials: {
94
+ token: "client-creds-token",
95
+ tokenUrl: "https://token.example.com",
96
+ scopes: {}
97
+ }
98
+ }
99
+ });
100
+ expect(hasToken(scheme)).toBe(true);
101
+ });
102
+ it("returns true when password flow has token", () => {
103
+ const scheme = securitySchemeSchema.parse({
104
+ type: "oauth2",
105
+ flows: {
106
+ password: {
107
+ token: "password-token",
108
+ tokenUrl: "https://token.example.com",
109
+ scopes: {}
110
+ }
111
+ }
112
+ });
113
+ expect(hasToken(scheme)).toBe(true);
114
+ });
115
+ it("returns true when implicit flow has token", () => {
116
+ const scheme = securitySchemeSchema.parse({
117
+ type: "oauth2",
118
+ flows: {
119
+ implicit: {
120
+ token: "implicit-token",
121
+ authorizationUrl: "https://auth.example.com",
122
+ scopes: {}
123
+ }
124
+ }
125
+ });
126
+ expect(hasToken(scheme)).toBe(true);
127
+ });
128
+ it("returns false when no flows have tokens", () => {
129
+ const scheme = securitySchemeSchema.parse({
130
+ type: "oauth2",
131
+ flows: {
132
+ authorizationCode: {
133
+ token: "",
134
+ authorizationUrl: "https://auth.example.com",
135
+ tokenUrl: "https://token.example.com",
136
+ scopes: {}
137
+ },
138
+ clientCredentials: {
139
+ token: "",
140
+ tokenUrl: "https://token.example.com",
141
+ scopes: {}
142
+ }
143
+ }
144
+ });
145
+ expect(hasToken(scheme)).toBe(false);
146
+ });
147
+ });
148
+ describe("unknown scheme type", () => {
149
+ it("returns false for unknown scheme types", () => {
150
+ const scheme = {
151
+ type: "unknown"
152
+ };
153
+ expect(hasToken(scheme)).toBe(false);
154
+ });
155
+ });
156
+ });
157
+ //# sourceMappingURL=has-token.test.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/helpers/security/has-token.test.ts"],
4
+ "sourcesContent": ["import { securitySchemeSchema } from '@scalar/types/entities'\nimport { describe, it, expect } from 'vitest'\n\nimport { hasToken } from './has-token'\n\ndescribe('hasToken', () => {\n describe('apiKey scheme', () => {\n it('returns true when value is present', () => {\n const scheme = securitySchemeSchema.parse({\n type: 'apiKey',\n value: 'my-api-key',\n in: 'header',\n name: 'x-api-key',\n })\n expect(hasToken(scheme)).toBe(true)\n })\n\n it('returns false when value is empty', () => {\n const scheme = securitySchemeSchema.parse({\n type: 'apiKey',\n value: '',\n in: 'header',\n name: 'x-api-key',\n })\n expect(hasToken(scheme)).toBe(false)\n })\n })\n\n describe('http scheme', () => {\n describe('bearer', () => {\n it('returns true when token is present', () => {\n const scheme = securitySchemeSchema.parse({\n type: 'http',\n scheme: 'bearer',\n token: 'my-bearer-token',\n })\n expect(hasToken(scheme)).toBe(true)\n })\n\n it('returns false when token is empty', () => {\n const scheme = securitySchemeSchema.parse({\n type: 'http',\n scheme: 'bearer',\n token: '',\n })\n expect(hasToken(scheme)).toBe(false)\n })\n })\n\n describe('basic', () => {\n it('returns true when both username and password are present', () => {\n const scheme = securitySchemeSchema.parse({\n type: 'http',\n scheme: 'basic',\n username: 'user',\n password: 'pass',\n })\n expect(hasToken(scheme)).toBe(true)\n })\n\n it('returns false when username is missing', () => {\n const scheme = securitySchemeSchema.parse({\n type: 'http',\n scheme: 'basic',\n username: '',\n password: 'pass',\n })\n expect(hasToken(scheme)).toBe(false)\n })\n\n it('returns false when password is missing', () => {\n const scheme = securitySchemeSchema.parse({\n type: 'http',\n scheme: 'basic',\n username: 'user',\n password: '',\n })\n expect(hasToken(scheme)).toBe(false)\n })\n })\n })\n\n describe('oauth2 scheme', () => {\n it('returns true when authorization code flow has token', () => {\n const scheme = securitySchemeSchema.parse({\n type: 'oauth2',\n flows: {\n authorizationCode: {\n token: 'auth-code-token',\n authorizationUrl: 'https://auth.example.com',\n tokenUrl: 'https://token.example.com',\n scopes: {},\n },\n },\n })\n expect(hasToken(scheme)).toBe(true)\n })\n\n it('returns true when client credentials flow has token', () => {\n const scheme = securitySchemeSchema.parse({\n type: 'oauth2',\n flows: {\n clientCredentials: {\n token: 'client-creds-token',\n tokenUrl: 'https://token.example.com',\n scopes: {},\n },\n },\n })\n expect(hasToken(scheme)).toBe(true)\n })\n\n it('returns true when password flow has token', () => {\n const scheme = securitySchemeSchema.parse({\n type: 'oauth2',\n flows: {\n password: {\n token: 'password-token',\n tokenUrl: 'https://token.example.com',\n scopes: {},\n },\n },\n })\n expect(hasToken(scheme)).toBe(true)\n })\n\n it('returns true when implicit flow has token', () => {\n const scheme = securitySchemeSchema.parse({\n type: 'oauth2',\n flows: {\n implicit: {\n token: 'implicit-token',\n authorizationUrl: 'https://auth.example.com',\n scopes: {},\n },\n },\n })\n expect(hasToken(scheme)).toBe(true)\n })\n\n it('returns false when no flows have tokens', () => {\n const scheme = securitySchemeSchema.parse({\n type: 'oauth2',\n flows: {\n authorizationCode: {\n token: '',\n authorizationUrl: 'https://auth.example.com',\n tokenUrl: 'https://token.example.com',\n scopes: {},\n },\n clientCredentials: {\n token: '',\n tokenUrl: 'https://token.example.com',\n scopes: {},\n },\n },\n })\n expect(hasToken(scheme)).toBe(false)\n })\n })\n\n describe('unknown scheme type', () => {\n it('returns false for unknown scheme types', () => {\n // Note: For unknown types, we can't use parse as it would fail validation\n // This is testing the edge case of an invalid type\n const scheme = {\n type: 'unknown',\n } as any\n expect(hasToken(scheme)).toBe(false)\n })\n })\n})\n"],
5
+ "mappings": "AAAA,SAAS,4BAA4B;AACrC,SAAS,UAAU,IAAI,cAAc;AAErC,SAAS,gBAAgB;AAEzB,SAAS,YAAY,MAAM;AACzB,WAAS,iBAAiB,MAAM;AAC9B,OAAG,sCAAsC,MAAM;AAC7C,YAAM,SAAS,qBAAqB,MAAM;AAAA,QACxC,MAAM;AAAA,QACN,OAAO;AAAA,QACP,IAAI;AAAA,QACJ,MAAM;AAAA,MACR,CAAC;AACD,aAAO,SAAS,MAAM,CAAC,EAAE,KAAK,IAAI;AAAA,IACpC,CAAC;AAED,OAAG,qCAAqC,MAAM;AAC5C,YAAM,SAAS,qBAAqB,MAAM;AAAA,QACxC,MAAM;AAAA,QACN,OAAO;AAAA,QACP,IAAI;AAAA,QACJ,MAAM;AAAA,MACR,CAAC;AACD,aAAO,SAAS,MAAM,CAAC,EAAE,KAAK,KAAK;AAAA,IACrC,CAAC;AAAA,EACH,CAAC;AAED,WAAS,eAAe,MAAM;AAC5B,aAAS,UAAU,MAAM;AACvB,SAAG,sCAAsC,MAAM;AAC7C,cAAM,SAAS,qBAAqB,MAAM;AAAA,UACxC,MAAM;AAAA,UACN,QAAQ;AAAA,UACR,OAAO;AAAA,QACT,CAAC;AACD,eAAO,SAAS,MAAM,CAAC,EAAE,KAAK,IAAI;AAAA,MACpC,CAAC;AAED,SAAG,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,OAAG,0CAA0C,MAAM;AAGjD,YAAM,SAAS;AAAA,QACb,MAAM;AAAA,MACR;AACA,aAAO,SAAS,MAAM,CAAC,EAAE,KAAK,KAAK;AAAA,IACrC,CAAC;AAAA,EACH,CAAC;AACH,CAAC;",
6
+ "names": []
7
+ }
@@ -1,3 +1,3 @@
1
- export { getSchemes } from './get-schemes.ts';
2
- export { hasToken } from './has-token.ts';
1
+ export { getSchemes } from './get-schemes.js';
2
+ export { hasToken } from './has-token.js';
3
3
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/helpers/security/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAA;AAC7C,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/helpers/security/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAA;AAC1C,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAA"}
@@ -1,2 +1,7 @@
1
- export { getSchemes } from './get-schemes.js';
2
- export { hasToken } from './has-token.js';
1
+ import { getSchemes } from "./get-schemes.js";
2
+ import { hasToken } from "./has-token.js";
3
+ export {
4
+ getSchemes,
5
+ hasToken
6
+ };
7
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/helpers/security/index.ts"],
4
+ "sourcesContent": ["export { getSchemes } from './get-schemes'\nexport { hasToken } from './has-token'\n"],
5
+ "mappings": "AAAA,SAAS,kBAAkB;AAC3B,SAAS,gBAAgB;",
6
+ "names": []
7
+ }
@@ -1,6 +1,6 @@
1
1
  import type { Webhook } from '@scalar/types/legacy';
2
- import type { Request } from '../entities/spec/requests.ts';
3
- import type { Tag } from '../entities/spec/spec-objects.ts';
2
+ import type { Request } from '../entities/spec/requests.js';
3
+ import type { Tag } from '../entities/spec/spec-objects.js';
4
4
  /**
5
5
  * Check if an entity should be ignored
6
6
  */
@@ -1 +1 @@
1
- {"version":3,"file":"should-ignore-entity.d.ts","sourceRoot":"","sources":["../../src/helpers/should-ignore-entity.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAA;AAEnD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,6BAA6B,CAAA;AAC1D,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,iCAAiC,CAAA;AAE1D;;GAEG;AACH,eAAO,MAAM,kBAAkB,SAEzB,SAAS,GACT,IAAI,CAAC,GAAG,EAAE,YAAY,GAAG,iBAAiB,CAAC,GAC3C,IAAI,CAAC,OAAO,EAAE,YAAY,GAAG,iBAAiB,CAAC,GAC/C,IAAI,CAAC,OAAO,EAAE,YAAY,GAAG,iBAAiB,CAAC,YAGpD,CAAA"}
1
+ {"version":3,"file":"should-ignore-entity.d.ts","sourceRoot":"","sources":["../../src/helpers/should-ignore-entity.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAA;AAEnD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,0BAA0B,CAAA;AACvD,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,8BAA8B,CAAA;AAEvD;;GAEG;AACH,eAAO,MAAM,kBAAkB,SAEzB,SAAS,GACT,IAAI,CAAC,GAAG,EAAE,YAAY,GAAG,iBAAiB,CAAC,GAC3C,IAAI,CAAC,OAAO,EAAE,YAAY,GAAG,iBAAiB,CAAC,GAC/C,IAAI,CAAC,OAAO,EAAE,YAAY,GAAG,iBAAiB,CAAC,YAGpD,CAAA"}
@@ -1,8 +1,7 @@
1
- /**
2
- * Check if an entity should be ignored
3
- */
4
1
  const shouldIgnoreEntity = (data) => {
5
- return data?.['x-internal'] === true || data?.['x-scalar-ignore'] === true;
2
+ return data?.["x-internal"] === true || data?.["x-scalar-ignore"] === true;
6
3
  };
7
-
8
- export { shouldIgnoreEntity };
4
+ export {
5
+ shouldIgnoreEntity
6
+ };
7
+ //# sourceMappingURL=should-ignore-entity.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/helpers/should-ignore-entity.ts"],
4
+ "sourcesContent": ["// TODO: Replace with a Webhook schema from the store (once it exists)\nimport type { Webhook } from '@scalar/types/legacy'\n\nimport type { Request } from '@/entities/spec/requests'\nimport type { Tag } from '@/entities/spec/spec-objects'\n\n/**\n * Check if an entity should be ignored\n */\nexport const shouldIgnoreEntity = (\n data:\n | undefined\n | Pick<Tag, 'x-internal' | 'x-scalar-ignore'>\n | Pick<Request, 'x-internal' | 'x-scalar-ignore'>\n | Pick<Webhook, 'x-internal' | 'x-scalar-ignore'>,\n) => {\n return data?.['x-internal'] === true || data?.['x-scalar-ignore'] === true\n}\n"],
5
+ "mappings": "AASO,MAAM,qBAAqB,CAChC,SAKG;AACH,SAAO,OAAO,YAAY,MAAM,QAAQ,OAAO,iBAAiB,MAAM;AACxE;",
6
+ "names": []
7
+ }
@@ -1,7 +1,7 @@
1
1
  const defaultStateFactory = () => ({});
2
- /**
3
- * This allows us to access the server state in the front-end
4
- */
5
- const ssrState = typeof window !== 'undefined' ? (window.__SCALAR__ ?? defaultStateFactory()) : defaultStateFactory();
6
-
7
- export { defaultStateFactory, ssrState };
2
+ const ssrState = typeof window !== "undefined" ? window.__SCALAR__ ?? defaultStateFactory() : defaultStateFactory();
3
+ export {
4
+ defaultStateFactory,
5
+ ssrState
6
+ };
7
+ //# sourceMappingURL=ssr-state.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/helpers/ssr-state.ts"],
4
+ "sourcesContent": ["import type { ScalarState } from '@scalar/types/legacy'\n\ndeclare global {\n interface Window {\n __SCALAR__: ScalarState\n }\n}\n\nexport const defaultStateFactory = (): ScalarState => ({})\n\n/**\n * This allows us to access the server state in the front-end\n */\nexport const ssrState: ScalarState =\n typeof window !== 'undefined' ? (window.__SCALAR__ ?? defaultStateFactory()) : defaultStateFactory()\n"],
5
+ "mappings": "AAQO,MAAM,sBAAsB,OAAoB,CAAC;AAKjD,MAAM,WACX,OAAO,WAAW,cAAe,OAAO,cAAc,oBAAoB,IAAK,oBAAoB;",
6
+ "names": []
7
+ }
@@ -1,19 +1,7 @@
1
- /**
2
- * A collection of string manipulation helper methods
3
- */
4
- /**
5
- * Converts a camelCase string to Title Words with spaces
6
- *
7
- * @param camelStr - MUST be in camelCase or this might not work
8
- */
9
- const camelToTitleWords = (camelStr) => camelStr
10
- .replace(/([A-Z])/g, (match) => ` ${match}`)
11
- .replace(/^./, (match) => match.toUpperCase())
12
- .trim();
13
- /**
14
- * Capitalize first letter
15
- * You should normally do this in css, only use this if you have to
16
- */
1
+ const camelToTitleWords = (camelStr) => camelStr.replace(/([A-Z])/g, (match) => ` ${match}`).replace(/^./, (match) => match.toUpperCase()).trim();
17
2
  const capitalize = (str) => str[0]?.toUpperCase() + str.slice(1);
18
-
19
- export { camelToTitleWords, capitalize };
3
+ export {
4
+ camelToTitleWords,
5
+ capitalize
6
+ };
7
+ //# sourceMappingURL=string.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/helpers/string.ts"],
4
+ "sourcesContent": ["/**\n * A collection of string manipulation helper methods\n */\n\n/**\n * Converts a camelCase string to Title Words with spaces\n *\n * @param camelStr - MUST be in camelCase or this might not work\n */\nexport const camelToTitleWords = (camelStr: string) =>\n camelStr\n .replace(/([A-Z])/g, (match) => ` ${match}`)\n .replace(/^./, (match) => match.toUpperCase())\n .trim()\n\n/**\n * Capitalize first letter\n * You should normally do this in css, only use this if you have to\n */\nexport const capitalize = (str: string) => str[0]?.toUpperCase() + str.slice(1)\n"],
5
+ "mappings": "AASO,MAAM,oBAAoB,CAAC,aAChC,SACG,QAAQ,YAAY,CAAC,UAAU,IAAI,KAAK,EAAE,EAC1C,QAAQ,MAAM,CAAC,UAAU,MAAM,YAAY,CAAC,EAC5C,KAAK;AAMH,MAAM,aAAa,CAAC,QAAgB,IAAI,CAAC,GAAG,YAAY,IAAI,IAAI,MAAM,CAAC;",
6
+ "names": []
7
+ }
@@ -1,17 +1,7 @@
1
- /**
2
- * Ensure we update this every migration
3
- *
4
- * previous data versions:
5
- * - undefined
6
- * - 0.0.0
7
- * - 2.1.0 - refactor
8
- * - 2.2.0 - auth compliancy
9
- * - 2.3.0 - environments
10
- * - 2.4.0 - draft collection servers
11
- * - 2.5.0 - accept header
12
- */
13
- const DATA_VERSION = '2.5.0';
14
- /** The localStorage key under which the data version is stored */
15
- const DATA_VERSION_LS_LEY = 'scalar_api_client_data_version';
16
-
17
- export { DATA_VERSION, DATA_VERSION_LS_LEY };
1
+ const DATA_VERSION = "2.5.0";
2
+ const DATA_VERSION_LS_LEY = "scalar_api_client_data_version";
3
+ export {
4
+ DATA_VERSION,
5
+ DATA_VERSION_LS_LEY
6
+ };
7
+ //# sourceMappingURL=data-version.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/migrations/data-version.ts"],
4
+ "sourcesContent": ["/**\n * Ensure we update this every migration\n *\n * previous data versions:\n * - undefined\n * - 0.0.0\n * - 2.1.0 - refactor\n * - 2.2.0 - auth compliancy\n * - 2.3.0 - environments\n * - 2.4.0 - draft collection servers\n * - 2.5.0 - accept header\n */\nexport const DATA_VERSION = '2.5.0'\n\n/** The localStorage key under which the data version is stored */\nexport const DATA_VERSION_LS_LEY = 'scalar_api_client_data_version'\n"],
5
+ "mappings": "AAYO,MAAM,eAAe;AAGrB,MAAM,sBAAsB;",
6
+ "names": []
7
+ }
@@ -0,0 +1,56 @@
1
+ import { writeFile } from "node:fs";
2
+ import { cookieSchema } from "../entities/cookie/cookie.js";
3
+ import { environmentSchema } from "../entities/environment/environment.js";
4
+ import { collectionSchema } from "../entities/spec/collection.js";
5
+ import { requestExampleSchema } from "../entities/spec/request-examples.js";
6
+ import { requestSchema } from "../entities/spec/requests.js";
7
+ import { serverSchema } from "../entities/spec/server.js";
8
+ import { tagSchema } from "../entities/spec/spec-objects.js";
9
+ import { workspaceSchema } from "../entities/workspace/workspace.js";
10
+ import { DATA_VERSION } from "../migrations/data-version.js";
11
+ import { securitySchemeSchema } from "@scalar/types/entities";
12
+ import { createTypeAlias, printNode, zodToTs } from "zod-to-ts";
13
+ console.warn("Make sure the generate types file is updated for the current version");
14
+ console.info("Generating...");
15
+ const entities = [
16
+ { identifier: "Collection", schema: collectionSchema },
17
+ { identifier: "Cookie", schema: cookieSchema },
18
+ { identifier: "Environment", schema: environmentSchema },
19
+ { identifier: "Tag", schema: tagSchema },
20
+ { identifier: "RequestExample", schema: requestExampleSchema },
21
+ { identifier: "Request", schema: requestSchema },
22
+ { identifier: "SecurityScheme", schema: securitySchemeSchema },
23
+ { identifier: "Server", schema: serverSchema },
24
+ { identifier: "Workspace", schema: workspaceSchema }
25
+ ];
26
+ let typeString = entities.reduce(
27
+ (prev, { identifier, schema }) => {
28
+ const { node } = zodToTs(schema, identifier);
29
+ const typeAlias = createTypeAlias(node, identifier);
30
+ const nodeString = " export " + printNode(typeAlias) + "\n\n";
31
+ return prev + nodeString;
32
+ },
33
+ `export namespace v_${DATA_VERSION.replace(/\./g, "_")} {
34
+ `
35
+ );
36
+ typeString += `
37
+ export type DataRecord = {
38
+ collections: Record<string, Collection>
39
+ cookies: Record<string, Cookie>
40
+ environments: Record<string, Environment>
41
+ requestExamples: Record<string, RequestExample>
42
+ requests: Record<string, Request>
43
+ securitySchemes: Record<string, SecurityScheme>
44
+ servers: Record<string, Server>
45
+ tags: Record<string, Tag>
46
+ workspaces: Record<string, Workspace>
47
+ }
48
+ }
49
+ `;
50
+ writeFile(
51
+ __dirname + `/v-${DATA_VERSION}/types.generated.ts`,
52
+ typeString,
53
+ { flag: "w" },
54
+ (err) => err ? console.error(err) : console.log("Generation complete!")
55
+ );
56
+ //# sourceMappingURL=generate-types.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/migrations/generate-types.ts"],
4
+ "sourcesContent": ["import { writeFile } from 'node:fs'\nimport { cookieSchema } from '@/entities/cookie/cookie'\nimport { environmentSchema } from '@/entities/environment/environment'\nimport { collectionSchema } from '@/entities/spec/collection'\nimport { requestExampleSchema } from '@/entities/spec/request-examples'\nimport { requestSchema } from '@/entities/spec/requests'\nimport { serverSchema } from '@/entities/spec/server'\nimport { tagSchema } from '@/entities/spec/spec-objects'\nimport { workspaceSchema } from '@/entities/workspace/workspace'\nimport { DATA_VERSION } from '@/migrations/data-version'\nimport { securitySchemeSchema } from '@scalar/types/entities'\nimport { createTypeAlias, printNode, zodToTs } from 'zod-to-ts'\n\nconsole.warn('Make sure the generate types file is updated for the current version')\nconsole.info('Generating...')\n\nconst entities = [\n { identifier: 'Collection', schema: collectionSchema },\n { identifier: 'Cookie', schema: cookieSchema },\n { identifier: 'Environment', schema: environmentSchema },\n { identifier: 'Tag', schema: tagSchema },\n { identifier: 'RequestExample', schema: requestExampleSchema },\n { identifier: 'Request', schema: requestSchema },\n { identifier: 'SecurityScheme', schema: securitySchemeSchema },\n { identifier: 'Server', schema: serverSchema },\n { identifier: 'Workspace', schema: workspaceSchema },\n]\n\n/**\n * Export the types in a namespace\n * TODO:\n * - go back to typescript compiler api and print pretty types as these ones are optional\n */\nlet typeString = entities.reduce(\n (prev, { identifier, schema }) => {\n const { node } = zodToTs(schema, identifier)\n const typeAlias = createTypeAlias(node, identifier)\n const nodeString = ' export ' + printNode(typeAlias) + '\\n\\n'\n return prev + nodeString\n },\n `export namespace v_${DATA_VERSION.replace(/\\./g, '_')} {\\n`,\n)\n\n// Add all types data object\ntypeString += `\n export type DataRecord = { \n collections: Record<string, Collection>\n cookies: Record<string, Cookie>\n environments: Record<string, Environment>\n requestExamples: Record<string, RequestExample>\n requests: Record<string, Request>\n securitySchemes: Record<string, SecurityScheme>\n servers: Record<string, Server>\n tags: Record<string, Tag>\n workspaces: Record<string, Workspace>\n }\n}\n`\n\n// Write to file\nwriteFile(__dirname + `/v-${DATA_VERSION}/types.generated.ts`, typeString, { flag: 'w' }, (err) =>\n err ? console.error(err) : console.log('Generation complete!'),\n)\n"],
5
+ "mappings": "AAAA,SAAS,iBAAiB;AAC1B,SAAS,oBAAoB;AAC7B,SAAS,yBAAyB;AAClC,SAAS,wBAAwB;AACjC,SAAS,4BAA4B;AACrC,SAAS,qBAAqB;AAC9B,SAAS,oBAAoB;AAC7B,SAAS,iBAAiB;AAC1B,SAAS,uBAAuB;AAChC,SAAS,oBAAoB;AAC7B,SAAS,4BAA4B;AACrC,SAAS,iBAAiB,WAAW,eAAe;AAEpD,QAAQ,KAAK,sEAAsE;AACnF,QAAQ,KAAK,eAAe;AAE5B,MAAM,WAAW;AAAA,EACf,EAAE,YAAY,cAAc,QAAQ,iBAAiB;AAAA,EACrD,EAAE,YAAY,UAAU,QAAQ,aAAa;AAAA,EAC7C,EAAE,YAAY,eAAe,QAAQ,kBAAkB;AAAA,EACvD,EAAE,YAAY,OAAO,QAAQ,UAAU;AAAA,EACvC,EAAE,YAAY,kBAAkB,QAAQ,qBAAqB;AAAA,EAC7D,EAAE,YAAY,WAAW,QAAQ,cAAc;AAAA,EAC/C,EAAE,YAAY,kBAAkB,QAAQ,qBAAqB;AAAA,EAC7D,EAAE,YAAY,UAAU,QAAQ,aAAa;AAAA,EAC7C,EAAE,YAAY,aAAa,QAAQ,gBAAgB;AACrD;AAOA,IAAI,aAAa,SAAS;AAAA,EACxB,CAAC,MAAM,EAAE,YAAY,OAAO,MAAM;AAChC,UAAM,EAAE,KAAK,IAAI,QAAQ,QAAQ,UAAU;AAC3C,UAAM,YAAY,gBAAgB,MAAM,UAAU;AAClD,UAAM,aAAa,cAAc,UAAU,SAAS,IAAI;AACxD,WAAO,OAAO;AAAA,EAChB;AAAA,EACA,sBAAsB,aAAa,QAAQ,OAAO,GAAG,CAAC;AAAA;AACxD;AAGA,cAAc;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAgBd;AAAA,EAAU,YAAY,MAAM,YAAY;AAAA,EAAuB;AAAA,EAAY,EAAE,MAAM,IAAI;AAAA,EAAG,CAAC,QACzF,MAAM,QAAQ,MAAM,GAAG,IAAI,QAAQ,IAAI,sBAAsB;AAC/D;",
6
+ "names": []
7
+ }
@@ -1,4 +1,4 @@
1
- export { DATA_VERSION, DATA_VERSION_LS_LEY } from './data-version.ts';
2
- export { migrator } from './migrator.ts';
3
- export { semverLessThan } from './semver.ts';
1
+ export { DATA_VERSION, DATA_VERSION_LS_LEY } from './data-version.js';
2
+ export { migrator } from './migrator.js';
3
+ export { semverLessThan } from './semver.js';
4
4
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/migrations/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAA;AACrE,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AACxC,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/migrations/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAA;AAClE,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAA;AACrC,OAAO,EAAE,cAAc,EAAE,MAAM,UAAU,CAAA"}
@@ -1,3 +1,10 @@
1
- export { DATA_VERSION, DATA_VERSION_LS_LEY } from './data-version.js';
2
- export { migrator } from './migrator.js';
3
- export { semverLessThan } from './semver.js';
1
+ import { DATA_VERSION, DATA_VERSION_LS_LEY } from "./data-version.js";
2
+ import { migrator } from "./migrator.js";
3
+ import { semverLessThan } from "./semver.js";
4
+ export {
5
+ DATA_VERSION,
6
+ DATA_VERSION_LS_LEY,
7
+ migrator,
8
+ semverLessThan
9
+ };
10
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/migrations/index.ts"],
4
+ "sourcesContent": ["export { DATA_VERSION, DATA_VERSION_LS_LEY } from './data-version'\nexport { migrator } from './migrator'\nexport { semverLessThan } from './semver'\n"],
5
+ "mappings": "AAAA,SAAS,cAAc,2BAA2B;AAClD,SAAS,gBAAgB;AACzB,SAAS,sBAAsB;",
6
+ "names": []
7
+ }
@@ -1,4 +1,4 @@
1
- import type { LS_KEYS } from '../helpers/local-storage.ts';
1
+ import type { LS_KEYS } from '../helpers/local-storage.js';
2
2
  /**
3
3
  * Supports pre-flatted local storage
4
4
  */
@@ -1 +1 @@
1
- {"version":3,"file":"local-storage.d.ts","sourceRoot":"","sources":["../../src/migrations/local-storage.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,4BAA4B,CAAA;AAKzD;;GAEG;AACH,eAAO,MAAM,iBAAiB,UAAW,CAAC,OAAO,OAAO,EAAE,MAAM,OAAO,OAAO,CAAC,KAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAKvG,CAAA;AAED,oDAAoD;AACpD,eAAO,MAAM,sBAAsB,QAAO,MAyBzC,CAAA"}
1
+ {"version":3,"file":"local-storage.d.ts","sourceRoot":"","sources":["../../src/migrations/local-storage.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAA;AAKtD;;GAEG;AACH,eAAO,MAAM,iBAAiB,UAAW,CAAC,OAAO,OAAO,EAAE,MAAM,OAAO,OAAO,CAAC,KAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAKvG,CAAA;AAED,oDAAoD;AACpD,eAAO,MAAM,sBAAsB,QAAO,MAyBzC,CAAA"}