@scalar/oas-utils 0.10.8 → 0.10.10

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 (129) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/dist/entities/cookie/cookie.js +11 -15
  3. package/dist/entities/cookie/index.js +1 -5
  4. package/dist/entities/environment/environment.js +7 -11
  5. package/dist/entities/environment/index.js +1 -5
  6. package/dist/entities/hotkeys/hotkeys.js +116 -111
  7. package/dist/entities/hotkeys/index.js +1 -6
  8. package/dist/entities/shared/index.js +1 -7
  9. package/dist/entities/shared/utility.js +9 -9
  10. package/dist/entities/spec/collection.js +91 -89
  11. package/dist/entities/spec/index.js +10 -59
  12. package/dist/entities/spec/operation.js +6 -6
  13. package/dist/entities/spec/parameters.js +38 -38
  14. package/dist/entities/spec/request-examples.js +421 -331
  15. package/dist/entities/spec/requests.js +102 -84
  16. package/dist/entities/spec/server.js +61 -46
  17. package/dist/entities/spec/spec-objects.js +121 -76
  18. package/dist/entities/spec/x-scalar-environments.js +18 -20
  19. package/dist/entities/spec/x-scalar-secrets.js +6 -8
  20. package/dist/entities/workspace/index.js +1 -7
  21. package/dist/entities/workspace/workspace.js +47 -46
  22. package/dist/helpers/client-plugins.js +13 -13
  23. package/dist/helpers/fetch-document.js +30 -25
  24. package/dist/helpers/fetch-with-proxy-fallback.js +26 -21
  25. package/dist/helpers/index.d.ts +1 -2
  26. package/dist/helpers/index.d.ts.map +1 -1
  27. package/dist/helpers/index.js +80 -119
  28. package/dist/helpers/normalize-mime-type-object.js +19 -18
  29. package/dist/helpers/normalize-mime-type.js +11 -9
  30. package/dist/helpers/operation-stability.js +25 -20
  31. package/dist/helpers/parse.d.ts +0 -4
  32. package/dist/helpers/parse.d.ts.map +1 -1
  33. package/dist/helpers/parse.js +77 -77
  34. package/dist/helpers/schema-model.js +13 -16
  35. package/dist/helpers/security/get-schemes.js +7 -8
  36. package/dist/helpers/security/has-token.js +18 -19
  37. package/dist/helpers/security/index.js +2 -7
  38. package/dist/helpers/servers.js +128 -79
  39. package/dist/helpers/should-ignore-entity.js +4 -5
  40. package/dist/migrations/data-version.js +15 -7
  41. package/dist/migrations/generate-types.js +34 -37
  42. package/dist/migrations/index.js +4 -18
  43. package/dist/migrations/local-storage.js +31 -29
  44. package/dist/migrations/migrate-to-indexdb.js +706 -529
  45. package/dist/migrations/migrator.js +58 -54
  46. package/dist/migrations/semver.js +24 -24
  47. package/dist/migrations/v-0.0.0/types.generated.js +1 -1
  48. package/dist/migrations/v-2.1.0/migration.js +272 -258
  49. package/dist/migrations/v-2.1.0/types.generated.js +1 -1
  50. package/dist/migrations/v-2.2.0/migration.js +99 -96
  51. package/dist/migrations/v-2.2.0/types.generated.js +1 -1
  52. package/dist/migrations/v-2.3.0/migration.js +45 -48
  53. package/dist/migrations/v-2.3.0/types.generated.js +1 -1
  54. package/dist/migrations/v-2.4.0/migration.js +25 -25
  55. package/dist/migrations/v-2.4.0/types.generated.js +1 -1
  56. package/dist/migrations/v-2.5.0/migration.js +122 -139
  57. package/dist/migrations/v-2.5.0/types.generated.js +1 -1
  58. package/dist/spec-getters/get-example-from-schema.js +489 -385
  59. package/dist/spec-getters/get-parameters-from-operation.js +39 -23
  60. package/dist/spec-getters/get-request-body-from-operation.d.ts.map +1 -1
  61. package/dist/spec-getters/get-request-body-from-operation.js +168 -126
  62. package/dist/spec-getters/get-server-variable-examples.js +10 -13
  63. package/dist/spec-getters/index.js +4 -11
  64. package/dist/transforms/import-spec.js +381 -291
  65. package/dist/transforms/index.js +1 -11
  66. package/package.json +15 -19
  67. package/dist/entities/cookie/cookie.js.map +0 -7
  68. package/dist/entities/cookie/index.js.map +0 -7
  69. package/dist/entities/environment/environment.js.map +0 -7
  70. package/dist/entities/environment/index.js.map +0 -7
  71. package/dist/entities/hotkeys/hotkeys.js.map +0 -7
  72. package/dist/entities/hotkeys/index.js.map +0 -7
  73. package/dist/entities/shared/index.js.map +0 -7
  74. package/dist/entities/shared/utility.js.map +0 -7
  75. package/dist/entities/spec/collection.js.map +0 -7
  76. package/dist/entities/spec/index.js.map +0 -7
  77. package/dist/entities/spec/operation.js.map +0 -7
  78. package/dist/entities/spec/parameters.js.map +0 -7
  79. package/dist/entities/spec/request-examples.js.map +0 -7
  80. package/dist/entities/spec/requests.js.map +0 -7
  81. package/dist/entities/spec/server.js.map +0 -7
  82. package/dist/entities/spec/spec-objects.js.map +0 -7
  83. package/dist/entities/spec/x-scalar-environments.js.map +0 -7
  84. package/dist/entities/spec/x-scalar-secrets.js.map +0 -7
  85. package/dist/entities/workspace/index.js.map +0 -7
  86. package/dist/entities/workspace/workspace.js.map +0 -7
  87. package/dist/helpers/client-plugins.js.map +0 -7
  88. package/dist/helpers/fetch-document.js.map +0 -7
  89. package/dist/helpers/fetch-with-proxy-fallback.js.map +0 -7
  90. package/dist/helpers/index.js.map +0 -7
  91. package/dist/helpers/normalize-mime-type-object.js.map +0 -7
  92. package/dist/helpers/normalize-mime-type.js.map +0 -7
  93. package/dist/helpers/operation-stability.js.map +0 -7
  94. package/dist/helpers/parse.js.map +0 -7
  95. package/dist/helpers/pretty-print-json.d.ts +0 -9
  96. package/dist/helpers/pretty-print-json.d.ts.map +0 -1
  97. package/dist/helpers/pretty-print-json.js +0 -38
  98. package/dist/helpers/pretty-print-json.js.map +0 -7
  99. package/dist/helpers/schema-model.js.map +0 -7
  100. package/dist/helpers/security/get-schemes.js.map +0 -7
  101. package/dist/helpers/security/has-token.js.map +0 -7
  102. package/dist/helpers/security/index.js.map +0 -7
  103. package/dist/helpers/servers.js.map +0 -7
  104. package/dist/helpers/should-ignore-entity.js.map +0 -7
  105. package/dist/migrations/data-version.js.map +0 -7
  106. package/dist/migrations/generate-types.js.map +0 -7
  107. package/dist/migrations/index.js.map +0 -7
  108. package/dist/migrations/local-storage.js.map +0 -7
  109. package/dist/migrations/migrate-to-indexdb.js.map +0 -7
  110. package/dist/migrations/migrator.js.map +0 -7
  111. package/dist/migrations/semver.js.map +0 -7
  112. package/dist/migrations/v-0.0.0/types.generated.js.map +0 -7
  113. package/dist/migrations/v-2.1.0/migration.js.map +0 -7
  114. package/dist/migrations/v-2.1.0/types.generated.js.map +0 -7
  115. package/dist/migrations/v-2.2.0/migration.js.map +0 -7
  116. package/dist/migrations/v-2.2.0/types.generated.js.map +0 -7
  117. package/dist/migrations/v-2.3.0/migration.js.map +0 -7
  118. package/dist/migrations/v-2.3.0/types.generated.js.map +0 -7
  119. package/dist/migrations/v-2.4.0/migration.js.map +0 -7
  120. package/dist/migrations/v-2.4.0/types.generated.js.map +0 -7
  121. package/dist/migrations/v-2.5.0/migration.js.map +0 -7
  122. package/dist/migrations/v-2.5.0/types.generated.js.map +0 -7
  123. package/dist/spec-getters/get-example-from-schema.js.map +0 -7
  124. package/dist/spec-getters/get-parameters-from-operation.js.map +0 -7
  125. package/dist/spec-getters/get-request-body-from-operation.js.map +0 -7
  126. package/dist/spec-getters/get-server-variable-examples.js.map +0 -7
  127. package/dist/spec-getters/index.js.map +0 -7
  128. package/dist/transforms/import-spec.js.map +0 -7
  129. package/dist/transforms/index.js.map +0 -7
@@ -1,11 +1 @@
1
- import {
2
- getSlugUid,
3
- importSpecToWorkspace,
4
- parseSchema
5
- } from "./import-spec.js";
6
- export {
7
- getSlugUid,
8
- importSpecToWorkspace,
9
- parseSchema
10
- };
11
- //# sourceMappingURL=index.js.map
1
+ export { getSlugUid, importSpecToWorkspace, parseSchema, } from './import-spec.js';
package/package.json CHANGED
@@ -16,7 +16,7 @@
16
16
  "specification",
17
17
  "yaml"
18
18
  ],
19
- "version": "0.10.8",
19
+ "version": "0.10.10",
20
20
  "engines": {
21
21
  "node": ">=22"
22
22
  },
@@ -91,31 +91,27 @@
91
91
  "vue": "^3.5.26",
92
92
  "yaml": "^2.8.0",
93
93
  "zod": "^4.3.5",
94
- "@scalar/helpers": "0.4.1",
95
- "@scalar/json-magic": "0.12.3",
96
- "@scalar/openapi-types": "0.6.0",
97
- "@scalar/object-utils": "1.3.2",
98
- "@scalar/themes": "0.15.0",
99
- "@scalar/types": "0.7.3",
100
- "@scalar/workspace-store": "0.40.2"
94
+ "@scalar/object-utils": "1.3.3",
95
+ "@scalar/helpers": "0.4.2",
96
+ "@scalar/json-magic": "0.12.4",
97
+ "@scalar/types": "0.7.4",
98
+ "@scalar/workspace-store": "0.40.4",
99
+ "@scalar/themes": "0.15.1",
100
+ "@scalar/openapi-types": "0.6.1"
101
101
  },
102
102
  "devDependencies": {
103
103
  "@types/node": "^24.1.0",
104
104
  "fake-indexeddb": "6.2.3",
105
- "vite": "^7.3.1",
106
- "vitest": "4.0.16",
105
+ "vite": "8.0.0",
106
+ "vitest": "4.1.0",
107
107
  "zod-to-ts": "github:amritk/zod-to-ts#build",
108
- "@scalar/build-tooling": "0.5.0",
109
- "@scalar/openapi-parser": "0.25.4",
110
- "@scalar/openapi-types": "0.6.0"
108
+ "@scalar/openapi-parser": "0.25.6",
109
+ "@scalar/openapi-types": "0.6.1"
111
110
  },
112
111
  "scripts": {
113
- "build": "scalar-build-esbuild",
114
- "lint:check": "eslint .",
115
- "lint:fix": "eslint . --fix",
112
+ "build": "tsc -p tsconfig.build.json && tsc-alias -p tsconfig.build.json",
116
113
  "test": "vitest",
117
- "typegen:migration": "vite-node ./src/migrations/generate-types.ts",
118
- "types:build": "scalar-types-build",
119
- "types:check": "scalar-types-check"
114
+ "typegen:migration": "tsx ./src/migrations/generate-types.ts",
115
+ "types:check": "tsc --noEmit"
120
116
  }
121
117
  }
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../src/entities/cookie/cookie.ts"],
4
- "sourcesContent": ["import { z } from 'zod'\n\nimport { type ENTITY_BRANDS, nanoidSchema } from '@scalar/types/utils'\n\nexport const cookieSchema = z.object({\n uid: nanoidSchema.brand<ENTITY_BRANDS['COOKIE']>(),\n /** Defines the cookie name and its value. A cookie definition begins with a name-value pair. */\n name: z.string().default(''),\n value: z.string().default(''),\n /** Defines the host to which the cookie will be sent. */\n domain: z.string().optional(),\n /** Indicates the path that must exist in the requested URL for the browser to send the Cookie header. */\n path: z.string().optional(),\n})\n\n/**\n * Cookies\n *\n * @see https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Set-Cookie\n */\nexport type Cookie = z.infer<typeof cookieSchema>\n"],
5
- "mappings": "AAAA,SAAS,SAAS;AAElB,SAA6B,oBAAoB;AAE1C,MAAM,eAAe,EAAE,OAAO;AAAA,EACnC,KAAK,aAAa,MAA+B;AAAA;AAAA,EAEjD,MAAM,EAAE,OAAO,EAAE,QAAQ,EAAE;AAAA,EAC3B,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE;AAAA;AAAA,EAE5B,QAAQ,EAAE,OAAO,EAAE,SAAS;AAAA;AAAA,EAE5B,MAAM,EAAE,OAAO,EAAE,SAAS;AAC5B,CAAC;",
6
- "names": []
7
- }
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../src/entities/cookie/index.ts"],
4
- "sourcesContent": ["export { type Cookie, cookieSchema } from './cookie'\n"],
5
- "mappings": "AAAA,SAAsB,oBAAoB;",
6
- "names": []
7
- }
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../src/entities/environment/environment.ts"],
4
- "sourcesContent": ["import type { ENTITY_BRANDS } from '@scalar/types/utils'\nimport { z } from 'zod'\n\nexport const environmentSchema = z.object({\n uid: z.string().brand<ENTITY_BRANDS['ENVIRONMENT']>(),\n name: z.string().optional().default('Default Environment'),\n color: z.string().optional().default('#FFFFFF'),\n value: z.string().default(''),\n isDefault: z.boolean().optional(),\n})\n\n/** Environment */\nexport type Environment = z.infer<typeof environmentSchema>\nexport type EnvironmentPayload = z.input<typeof environmentSchema>\n"],
5
- "mappings": "AACA,SAAS,SAAS;AAEX,MAAM,oBAAoB,EAAE,OAAO;AAAA,EACxC,KAAK,EAAE,OAAO,EAAE,MAAoC;AAAA,EACpD,MAAM,EAAE,OAAO,EAAE,SAAS,EAAE,QAAQ,qBAAqB;AAAA,EACzD,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,QAAQ,SAAS;AAAA,EAC9C,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE;AAAA,EAC5B,WAAW,EAAE,QAAQ,EAAE,SAAS;AAClC,CAAC;",
6
- "names": []
7
- }
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../src/entities/environment/index.ts"],
4
- "sourcesContent": ["export { type Environment, type EnvironmentPayload, environmentSchema } from './environment'\n"],
5
- "mappings": "AAAA,SAAoD,yBAAyB;",
6
- "names": []
7
- }
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../src/entities/hotkeys/hotkeys.ts"],
4
- "sourcesContent": ["/**\n * Array of all of the events that we support\n */\nexport const HOTKEY_EVENT_NAMES = [\n 'addTopNav',\n 'closeModal',\n 'closeTopNav',\n 'createNew',\n 'executeRequest',\n 'focusAddressBar',\n 'focusRequestSearch',\n 'jumpToLastTab',\n 'jumpToTab',\n 'navigateSearchResultsDown',\n 'navigateSearchResultsUp',\n 'navigateTopNavLeft',\n 'navigateTopNavRight',\n 'openCommandPalette',\n 'selectSearchResult',\n 'toggleSidebar',\n] as const\nexport type HotkeyEventName = (typeof HOTKEY_EVENT_NAMES)[number]\n\n/**\n * Array of all of the hotkeys that we support\n *\n * Space is a special case because its actually ' ' but we name it space here and will handle it separately\n * If you need more\n * @see https://developer.mozilla.org/en-US/docs/Web/API/UI_Events/Keyboard_event_key_values\n */\nexport const KEYDOWN_KEYS = [\n 'Space',\n 'Backspace',\n 'Tab',\n 'Enter',\n 'Escape',\n 'ArrowDown',\n 'ArrowLeft',\n 'ArrowRight',\n 'ArrowUp',\n 'End',\n 'Home',\n 'PageDown',\n 'PageUp',\n 'Delete',\n '0',\n '1',\n '2',\n '3',\n '4',\n '5',\n '6',\n '7',\n '8',\n '9',\n 'a',\n 'b',\n 'c',\n 'd',\n 'e',\n 'f',\n 'g',\n 'h',\n 'i',\n 'j',\n 'k',\n 'l',\n 'm',\n 'n',\n 'o',\n 'p',\n 'q',\n 'r',\n 's',\n 't',\n 'u',\n 'v',\n 'w',\n 'x',\n 'y',\n 'z',\n '0',\n '1',\n '2',\n '3',\n '4',\n '5',\n '6',\n '7',\n '8',\n '9',\n '*',\n '+',\n '-',\n '.',\n '/',\n 'F1',\n 'F2',\n 'F3',\n 'F4',\n 'F5',\n 'F6',\n 'F7',\n 'F8',\n 'F9',\n 'F10',\n 'F11',\n 'F12',\n ';',\n '=',\n ',',\n '-',\n '.',\n '/',\n '`',\n '[',\n '\\\\',\n ']',\n '',\n] as const\nexport type KeydownKey = (typeof KEYDOWN_KEYS)[number]\n"],
5
- "mappings": "AAGO,MAAM,qBAAqB;AAAA,EAChC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;AAUO,MAAM,eAAe;AAAA,EAC1B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;",
6
- "names": []
7
- }
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../src/entities/hotkeys/index.ts"],
4
- "sourcesContent": ["export { type HotkeyEventName, type KeydownKey, HOTKEY_EVENT_NAMES, KEYDOWN_KEYS } from './hotkeys'\n"],
5
- "mappings": "AAAA,SAAgD,oBAAoB,oBAAoB;",
6
- "names": []
7
- }
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../src/entities/shared/index.ts"],
4
- "sourcesContent": ["export {\n type SelectedSecuritySchemeUids,\n selectedSecuritySchemeUidSchema,\n} from './utility'\n"],
5
- "mappings": "AAAA;AAAA,EAEE;AAAA,OACK;",
6
- "names": []
7
- }
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../src/entities/shared/utility.ts"],
4
- "sourcesContent": ["import type { ENTITY_BRANDS } from '@scalar/types/utils'\nimport { z } from 'zod'\n\n/** Schema for selectedSecuritySchemeUids */\nexport const selectedSecuritySchemeUidSchema = z\n .union([\n z.string().brand<ENTITY_BRANDS['SECURITY_SCHEME']>(),\n z.string().brand<ENTITY_BRANDS['SECURITY_SCHEME']>().array(),\n ])\n .array()\n .default([])\n\nexport type SelectedSecuritySchemeUids = z.infer<typeof selectedSecuritySchemeUidSchema>\n"],
5
- "mappings": "AACA,SAAS,SAAS;AAGX,MAAM,kCAAkC,EAC5C,MAAM;AAAA,EACL,EAAE,OAAO,EAAE,MAAwC;AAAA,EACnD,EAAE,OAAO,EAAE,MAAwC,EAAE,MAAM;AAC7D,CAAC,EACA,MAAM,EACN,QAAQ,CAAC,CAAC;",
6
- "names": []
7
- }
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../src/entities/spec/collection.ts"],
4
- "sourcesContent": ["import { oasSecurityRequirementSchema } from '@scalar/types/entities'\nimport { type ENTITY_BRANDS, nanoidSchema } from '@scalar/types/utils'\nimport { z } from 'zod'\n\nimport { selectedSecuritySchemeUidSchema } from '@/entities/shared/utility'\nimport { xScalarEnvironmentsSchema } from '@/entities/spec/x-scalar-environments'\nimport { xScalarSecretsSchema } from '@/entities/spec/x-scalar-secrets'\n\nimport { oasExternalDocumentationSchema, oasInfoSchema } from './spec-objects'\n\nconst oasCollectionSchema = z.object({\n /**\n * @deprecated\n * Needs to be remove as it is not a spec property\n */\n 'type': z.literal('collection').optional().default('collection'),\n 'openapi': z\n .union([z.string(), z.literal('3.0.0'), z.literal('3.1.0'), z.literal('4.0.0')])\n .optional()\n .default('3.1.0'),\n 'jsonSchemaDialect': z.string().optional(),\n 'info': oasInfoSchema.catch({\n title: 'API',\n version: '1.0',\n }),\n /**\n * A declaration of which security mechanisms can be used across the API. The list of\n * values includes alternative security requirement objects that can be used. Only\n * one of the security requirement objects need to be satisfied to authorize a request.\n * Individual operations can override this definition. To make security optional, an empty\n * security requirement ({}) can be included in the array.\n */\n 'security': z.array(oasSecurityRequirementSchema).optional().default([]),\n 'externalDocs': oasExternalDocumentationSchema.optional().catch(undefined),\n /** TODO: Type these */\n 'components': z.record(z.string(), z.unknown()).optional(),\n /** TODO: Type these */\n 'webhooks': z.record(z.string(), z.unknown()).optional(),\n /** A custom icon representing the collection */\n 'x-scalar-icon': z.string().optional().default('interface-content-folder'),\n 'x-scalar-active-environment': z.string().optional(),\n 'x-scalar-environments': xScalarEnvironmentsSchema.optional(),\n 'x-scalar-secrets': xScalarSecretsSchema.optional(),\n // These properties will be stripped out and mapped back as id lists\n // servers\n // paths/**\n // servers\n // tags\n // security\n})\n\nconst extendedCollectionSchema = z.object({\n uid: nanoidSchema.brand<ENTITY_BRANDS['COLLECTION']>(),\n /** A list of security schemes UIDs associated with the collection */\n securitySchemes: z.string().array().default([]),\n /** List of currently selected security scheme UIDs, these can be overridden per request */\n selectedSecuritySchemeUids: selectedSecuritySchemeUidSchema,\n /** The currently selected server */\n selectedServerUid: z.string().brand<ENTITY_BRANDS['SERVER']>().optional(),\n /** UIDs which refer to servers on the workspace base */\n servers: z.string().brand<ENTITY_BRANDS['SERVER']>().array().default([]),\n /** Request UIDs associated with a collection */\n requests: z.string().brand<ENTITY_BRANDS['OPERATION']>().array().default([]),\n /** Tag UIDs associated with the collection */\n tags: z.string().brand<ENTITY_BRANDS['TAG']>().array().default([]),\n /** List of requests without tags and top level tag \"folders\" */\n children: z\n .union([z.string().brand<ENTITY_BRANDS['OPERATION']>(), z.string().brand<ENTITY_BRANDS['TAG']>()])\n .array()\n .default([]),\n /**\n * A link to where this document is stored\n *\n * - Used for watch mode\n * - Possibly useful for Git sync down the line\n */\n documentUrl: z.string().optional(),\n /**\n * Enables polling of OpenAPI document urls\n *\n * @remarks Only effective when `documentUrl` is set\n */\n watchMode: z.boolean().optional().default(false),\n /** Keeps track of which integration is associated with the specific collection */\n integration: z.string().nullable().optional(),\n /**\n * Selected authentication will be set at the collection level instead of the request level\n *\n * @default false\n */\n useCollectionSecurity: z.boolean().optional().default(false),\n /**\n * Status of the watcher from above\n *\n * @defaults to idle for all collections, doesn't mean that it can watch for changes\n */\n watchModeStatus: z.enum(['IDLE', 'WATCHING', 'ERROR']).optional().default('IDLE'),\n})\n\nexport const collectionSchema = oasCollectionSchema.merge(extendedCollectionSchema)\nexport type Collection = z.infer<typeof collectionSchema>\nexport type CollectionPayload = z.input<typeof collectionSchema>\n"],
5
- "mappings": "AAAA,SA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iBAAiB,EAAE,OAAO,EAAE,MAAM,EAAE,QAAQ,CAAC,CAAC;AAAA;AAAA,EAE9C,4BAA4B;AAAA;AAAA,EAE5B,mBAAmB,EAAE,OAAO,EAAE,MAA+B,EAAE,SAAS;AAAA;AAAA,EAExE,SAAS,EAAE,OAAO,EAAE,MAA+B,EAAE,MAAM,EAAE,QAAQ,CAAC,CAAC;AAAA;AAAA,EAEvE,UAAU,EAAE,OAAO,EAAE,MAAkC,EAAE,MAAM,EAAE,QAAQ,CAAC,CAAC;AAAA;AAAA,EAE3E,MAAM,EAAE,OAAO,EAAE,MAA4B,EAAE,MAAM,EAAE,QAAQ,CAAC,CAAC;AAAA;AAAA,EAEjE,UAAU,EACP,MAAM,CAAC,EAAE,OAAO,EAAE,MAAkC,GAAG,EAAE,OAAO,EAAE,MAA4B,CAAC,CAAC,EAChG,MAAM,EACN,QAAQ,CAAC,CAAC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOb,aAAa,EAAE,OAAO,EAAE,SAAS;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAMjC,WAAW,EAAE,QAAQ,EAAE,SAAS,EAAE,QAAQ,KAAK;AAAA;AAAA,EAE/C,aAAa,EAAE,OAAO,EAAE,SAAS,EAAE,SAAS;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAM5C,uBAAuB,EAAE,QAAQ,EAAE,SAAS,EAAE,QAAQ,KAAK;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAM3D,iBAAiB,EAAE,KAAK,CAAC,QAAQ,YAAY,OAAO,CAAC,EAAE,SAAS,EAAE,QAAQ,MAAM;AAClF,CAAC;AAEM,MAAM,mBAAmB,oBAAoB,MAAM,wBAAwB;",
6
- "names": []
7
- }
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../src/entities/spec/index.ts"],
4
- "sourcesContent": ["/** Re-exported here for ease of use but we should use the other ones directly */\nexport {\n type Oauth2Flow,\n type Oauth2FlowPayload,\n type SecuritySchemaHttp,\n type SecuritySchemaOpenId,\n type SecurityScheme,\n type SecuritySchemeApiKey,\n type SecuritySchemeOauth2,\n type SecuritySchemeOauth2Payload,\n type SecuritySchemePayload,\n oasSecurityRequirementSchema,\n oasSecuritySchemeSchema,\n pkceOptions,\n securityApiKeySchema,\n securityHttpSchema,\n securityOauthSchema,\n securityOpenIdSchema,\n securitySchemeSchema,\n} from '@scalar/types/entities'\n\nexport { type Collection, type CollectionPayload, collectionSchema } from './collection'\nexport {\n type Operation,\n type OperationPayload,\n operationSchema,\n} from './operation'\nexport { type RequestParameter, type RequestParameterPayload, oasParameterSchema } from './parameters'\nexport {\n type RequestExample,\n type RequestExampleParameter,\n createExampleFromRequest,\n requestExampleParametersSchema,\n requestExampleSchema,\n} from './request-examples'\nexport {\n type Request,\n type RequestEvent,\n type RequestMethod,\n type RequestPayload,\n type ResponseInstance,\n requestSchema,\n} from './requests'\nexport type {\n PostResponseScript,\n PostResponseScripts,\n} from './requests.ts'\nexport { type Server, type ServerPayload, serverSchema } from './server'\nexport {\n type Tag,\n type TagPayload,\n oasContactSchema,\n oasExternalDocumentationSchema,\n oasInfoSchema,\n oasLicenseSchema,\n tagSchema,\n} from './spec-objects'\nexport {\n type XScalarEnvironment,\n type XScalarEnvironments,\n xScalarEnvironmentsSchema,\n} from './x-scalar-environments'\n"],
5
- "mappings": "AACA;AAAA,EAUE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAEP,SAAkD,wBAAwB;AAC1E;AAAA,EAGE;AAAA,OACK;AACP,SAA8D,0BAA0B;AACxF;AAAA,EAGE;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP;AAAA,EAME;AAAA,OACK;AAKP,SAA0C,oBAAoB;AAC9D;AAAA,EAGE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP;AAAA,EAGE;AAAA,OACK;",
6
- "names": []
7
- }
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../src/entities/spec/operation.ts"],
4
- "sourcesContent": ["/**\n * Aliases Request to Operation which is closer to the spec,\n * also will not conflict with the builtin Request class\n */\nimport { type RequestPayload, type Request as RequestType, requestSchema } from './requests'\n\nexport type Operation = RequestType\nexport type OperationPayload = RequestPayload\nexport const operationSchema = requestSchema\n"],
5
- "mappings": "AAIA,SAA2D,qBAAqB;AAIzE,MAAM,kBAAkB;",
6
- "names": []
7
- }
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../src/entities/spec/parameters.ts"],
4
- "sourcesContent": ["import type { OpenAPI, OpenAPIV3_1 } from '@scalar/openapi-types'\nimport { type ZodSchema, z } from 'zod'\n\nimport type { RequestExampleParameter } from './request-examples'\n\nconst parameterTypeSchema = z.enum(['path', 'query', 'header', 'cookie'])\n// not used but kept for consistency\n// export type ParamType = z.infer<typeof parameterTypeSchema>\n\nconst parameterStyleSchema = z.enum([\n 'matrix',\n 'simple',\n 'form',\n 'label',\n 'spaceDelimited',\n 'pipeDelimited',\n 'deepObject',\n])\n// not used but kept for consistency\n// export type ParameterStyle = z.infer<typeof parameterStyleSchema>\n\nexport type ParameterContent = Record<\n string,\n {\n schema?: OpenAPIV3_1.Document\n examples?: Record<string, RequestExampleParameter>\n example?: RequestExampleParameter\n }\n>\n\n/**\n * OpenAPI compliant parameters object\n */\nexport const oasParameterSchema = z.object({\n in: parameterTypeSchema,\n name: z.string(),\n description: z.string().optional(),\n /** Defaulted to false */\n required: z.boolean().optional().default(false),\n /** Defaulted to false */\n deprecated: z.boolean().optional().default(false),\n schema: z.unknown().optional(),\n content: z.unknown().optional(),\n /** Defaulted according to @url https://spec.openapis.org/oas/v3.1.0#parameter-object */\n style: parameterStyleSchema.optional(),\n explode: z.boolean().optional(),\n example: z.unknown().optional(),\n examples: z\n .union([\n z.record(\n z.string(),\n z.object({\n value: z.unknown().optional(),\n summary: z.string().optional(),\n externalValue: z.string().optional(),\n }),\n ),\n z.array(z.unknown()),\n ])\n .optional(),\n}) satisfies ZodSchema<OpenAPI.Parameter>\n\nexport type RequestParameter = z.infer<typeof oasParameterSchema>\nexport type RequestParameterPayload = z.input<typeof oasParameterSchema>\n"],
5
- "mappings": "AACA,SAAyB,SAAS;AAIlC,MAAM,sBAAsB,EAAE,KAAK,CAAC,QAAQ,SAAS,UAAU,QAAQ,CAAC;AAIxE,MAAM,uBAAuB,EAAE,KAAK;AAAA,EAClC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,CAAC;AAgBM,MAAM,qBAAqB,EAAE,OAAO;AAAA,EACzC,IAAI;AAAA,EACJ,MAAM,EAAE,OAAO;AAAA,EACf,aAAa,EAAE,OAAO,EAAE,SAAS;AAAA;AAAA,EAEjC,UAAU,EAAE,QAAQ,EAAE,SAAS,EAAE,QAAQ,KAAK;AAAA;AAAA,EAE9C,YAAY,EAAE,QAAQ,EAAE,SAAS,EAAE,QAAQ,KAAK;AAAA,EAChD,QAAQ,EAAE,QAAQ,EAAE,SAAS;AAAA,EAC7B,SAAS,EAAE,QAAQ,EAAE,SAAS;AAAA;AAAA,EAE9B,OAAO,qBAAqB,SAAS;AAAA,EACrC,SAAS,EAAE,QAAQ,EAAE,SAAS;AAAA,EAC9B,SAAS,EAAE,QAAQ,EAAE,SAAS;AAAA,EAC9B,UAAU,EACP,MAAM;AAAA,IACL,EAAE;AAAA,MACA,EAAE,OAAO;AAAA,MACT,EAAE,OAAO;AAAA,QACP,OAAO,EAAE,QAAQ,EAAE,SAAS;AAAA,QAC5B,SAAS,EAAE,OAAO,EAAE,SAAS;AAAA,QAC7B,eAAe,EAAE,OAAO,EAAE,SAAS;AAAA,MACrC,CAAC;AAAA,IACH;AAAA,IACA,EAAE,MAAM,EAAE,QAAQ,CAAC;AAAA,EACrB,CAAC,EACA,SAAS;AACd,CAAC;",
6
- "names": []
7
- }
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../src/entities/spec/request-examples.ts"],
4
- "sourcesContent": ["import { isDefined } from '@scalar/helpers/array/is-defined'\nimport { objectKeys } from '@scalar/helpers/object/object-keys'\nimport { keysOf } from '@scalar/object-utils/arrays'\nimport { type ENTITY_BRANDS, nanoidSchema } from '@scalar/types/utils'\nimport { z } from 'zod'\n\nimport { schemaModel } from '@/helpers/schema-model'\nimport { getRequestBodyFromOperation } from '@/spec-getters/get-request-body-from-operation'\nimport { getServerVariableExamples } from '@/spec-getters/get-server-variable-examples'\n\nimport type { ParameterContent, RequestParameter } from './parameters'\nimport type { Request } from './requests'\nimport type { Server } from './server'\n\n// ---------------------------------------------------------------------------\n// Example Parameters\n\n/**\n * TODO: Deprecate this.\n *\n * The request schema should be stored in the request and any\n * parameters should be validated against that\n */\nexport const requestExampleParametersSchema = z\n .object({\n key: z.string().default(''),\n value: z.coerce.string().default(''),\n enabled: z.boolean().default(true),\n file: z.any().optional(),\n description: z.string().optional(),\n required: z.boolean().optional(),\n enum: z.array(z.string()).optional(),\n examples: z.array(z.any()).optional(),\n type: z\n .union([\n // 'string'\n z.string(),\n // ['string', 'null']\n z.array(z.string()),\n ])\n .optional(),\n format: z.string().optional(),\n minimum: z.number().optional(),\n maximum: z.number().optional(),\n default: z.any().optional(),\n nullable: z.boolean().optional(),\n })\n // set nullable: to true if type is ['string', 'null']\n .transform((_data) => {\n const data = { ..._data }\n\n // type: ['string', 'null'] -> nullable: true\n if (Array.isArray(data.type) && data.type.includes('null')) {\n data.nullable = true\n }\n\n // Hey, if it's just one value and 'null', we can make it a string and ditch the 'null'.\n if (Array.isArray(data.type) && data.type.length === 2 && data.type.includes('null')) {\n data.type = data.type.find((item) => item !== 'null')\n }\n\n return data\n })\n\n/** Convert the array of parameters to an object keyed by the parameter name */\nexport const parameterArrayToObject = (params: RequestExampleParameter[]) =>\n params.reduce<Record<string, string>>((map, param) => {\n map[param.key] = param.value\n return map\n }, {})\n\n/** Request examples - formerly known as instances - are \"children\" of requests */\nexport type RequestExampleParameter = z.infer<typeof requestExampleParametersSchema>\n\nconst xScalarFileValueSchema = z\n .object({\n url: z.string(),\n base64: z.string().optional(),\n })\n .nullable()\n\n/**\n * When files are required for an example we provide the options\n * to provide a public URL or a base64 encoded string\n */\n// not used but kept for consistency\n// export type XScalarFileValue = z.infer<typeof xScalarFileValueSchema>\n\n/**\n * Schema for the OAS serialization of request example parameters\n *\n * File values can be optionally fetched on import OR inserted as a base64 encoded string\n */\nconst xScalarFormDataValue = z.union([\n z.object({\n type: z.literal('string'),\n value: z.string(),\n }),\n z.object({\n type: z.literal('file'),\n file: xScalarFileValueSchema,\n }),\n])\n\ntype XScalarFormDataValue = z.infer<typeof xScalarFormDataValue>\n\n// ---------------------------------------------------------------------------\n// Example Body\n\n/**\n * Possible encodings for example request bodies when using text formats\n *\n * TODO: This list may not be comprehensive enough\n */\nconst exampleRequestBodyEncoding = ['json', 'text', 'html', 'javascript', 'xml', 'yaml', 'edn'] as const\n\ntype BodyEncoding = (typeof exampleRequestBodyEncoding)[number]\n\nconst exampleBodyMime = [\n 'application/json',\n 'text/plain',\n 'text/html',\n 'application/javascript',\n 'application/xml',\n 'application/yaml',\n 'application/edn',\n 'application/octet-stream',\n 'application/x-www-form-urlencoded',\n 'multipart/form-data',\n /** Used for direct files */\n 'binary',\n] as const\n\ntype BodyMime = (typeof exampleBodyMime)[number]\n\nconst contentMapping: Record<BodyEncoding, BodyMime> = {\n json: 'application/json',\n text: 'text/plain',\n html: 'text/html',\n javascript: 'application/javascript',\n xml: 'application/xml',\n yaml: 'application/yaml',\n edn: 'application/edn',\n} as const\n\n/**\n * TODO: Migrate away from this layout to the format used in the extension\n *\n * If a user changes the encoding of the body we expect the content to change as well\n */\nconst exampleRequestBodySchema = z.object({\n raw: z\n .object({\n encoding: z.enum(exampleRequestBodyEncoding),\n value: z.string().default(''),\n mimeType: z.string().optional(),\n })\n .optional(),\n formData: z\n .object({\n encoding: z.union([z.literal('form-data'), z.literal('urlencoded')]).default('form-data'),\n value: requestExampleParametersSchema.array().default([]),\n })\n .optional(),\n binary: z.instanceof(Blob).optional(),\n activeBody: z.union([z.literal('raw'), z.literal('formData'), z.literal('binary')]).default('raw'),\n})\n\ntype ExampleRequestBody = z.infer<typeof exampleRequestBodySchema>\n\n/** Schema for the OAS serialization of request example bodies */\nconst xScalarExampleBodySchema = z.object({\n encoding: z.enum(exampleBodyMime),\n /**\n * Body content as an object with a separately specified encoding or a simple pre-encoded string value\n *\n * Ideally we would convert any objects into the proper encoding on import\n */\n content: z.union([z.record(z.string(), z.any()), z.string()]),\n /** When the encoding is `binary` this will be used to link to the file */\n file: xScalarFileValueSchema.optional(),\n})\n\ntype XScalarExampleBody = z.infer<typeof xScalarExampleBodySchema>\n\n// ---------------------------------------------------------------------------\n// Example Schema\n\nexport const requestExampleSchema = z.object({\n uid: nanoidSchema.brand<ENTITY_BRANDS['EXAMPLE']>(),\n type: z.literal('requestExample').optional().default('requestExample'),\n requestUid: z.string().brand<ENTITY_BRANDS['OPERATION']>().optional(),\n name: z.string().optional().default('Name'),\n body: exampleRequestBodySchema.optional().default({ activeBody: 'raw' }),\n parameters: z\n .object({\n path: requestExampleParametersSchema.array().default([]),\n query: requestExampleParametersSchema.array().default([]),\n headers: requestExampleParametersSchema.array().default([{ key: 'Accept', value: '*/*', enabled: true }]),\n cookies: requestExampleParametersSchema.array().default([]),\n })\n .optional()\n .default({\n path: [],\n query: [],\n headers: [{ key: 'Accept', value: '*/*', enabled: true }],\n cookies: [],\n }),\n /** TODO: Should this be deprecated? */\n serverVariables: z.record(z.string(), z.array(z.string())).optional(),\n})\n\nexport type RequestExample = z.infer<typeof requestExampleSchema>\n\n/** For OAS serialization we just store the simple key/value pairs */\nconst xScalarExampleParameterSchema = z.record(z.string(), z.string()).optional()\n\n/** Schema for the OAS serialization of request examples */\nexport const xScalarExampleSchema = z.object({\n /** TODO: Should this be required? */\n name: z.string().optional(),\n body: xScalarExampleBodySchema.optional(),\n parameters: z.object({\n path: xScalarExampleParameterSchema,\n query: xScalarExampleParameterSchema,\n headers: xScalarExampleParameterSchema,\n cookies: xScalarExampleParameterSchema,\n }),\n})\n\ntype XScalarExample = z.infer<typeof xScalarExampleSchema>\n\n/**\n * Convert a request example to the xScalar serialized format\n *\n * TODO: The base format should be migrated to align MUCH closer to the serialized format\n */\nexport function convertExampleToXScalar(example: RequestExample) {\n const active = example.body?.activeBody\n\n const xScalarBody: XScalarExampleBody = {\n encoding: 'text/plain',\n content: '',\n }\n\n if (example.body?.activeBody === 'binary') {\n xScalarBody.encoding = 'binary'\n // TODO: Need to allow users to set these properties\n xScalarBody.file = null\n }\n\n if (active === 'formData' && example.body?.[active]) {\n const body = example.body[active]\n xScalarBody.encoding = body.encoding === 'form-data' ? 'multipart/form-data' : 'application/x-www-form-urlencoded'\n\n // TODO: Need to allow users to set these properties\n xScalarBody.content = body.value.reduce<Record<string, XScalarFormDataValue>>((map, param) => {\n /** TODO: We need to ensure only file or value is set */\n map[param.key] = param.file\n ? {\n type: 'file',\n file: null,\n }\n : {\n type: 'string',\n value: param.value,\n }\n return map\n }, {})\n }\n\n if (example.body?.activeBody === 'raw') {\n xScalarBody.encoding = contentMapping[example.body.raw?.encoding ?? 'text'] ?? 'text/plain'\n\n xScalarBody.content = example.body.raw?.value ?? ''\n }\n\n const parameters: XScalarExample['parameters'] = {}\n\n keysOf(example.parameters ?? {}).forEach((key) => {\n if (example.parameters?.[key].length) {\n parameters[key] = parameterArrayToObject(example.parameters[key])\n }\n })\n\n return xScalarExampleSchema.parse({\n /** Only add the body if we have content or the body should be a file */\n body: xScalarBody.content || xScalarBody.encoding === 'binary' ? xScalarBody : undefined,\n parameters,\n })\n}\n\n// ---------------------------------------------------------------------------\n// Example Helpers\n\n/** Create new instance parameter from a request parameter */\nexport function createParamInstance(param: RequestParameter): RequestExampleParameter {\n const schema = param.schema as any\n\n const firstExample = (() => {\n if (param.examples && !Array.isArray(param.examples) && objectKeys(param.examples).length > 0) {\n const exampleValues = Object.entries(param.examples).map(([_, example]) => {\n // returns the external value if it exists\n if (example.externalValue) {\n return example.externalValue\n }\n\n // returns the value if it exists and is defined\n // e.g. { examples: { foo: { value: 'bar' } } } would return ['bar']\n return example.value\n })\n\n // returns the first example as selected value along other examples\n return { value: exampleValues[0], examples: exampleValues }\n }\n\n // param example e.g. { example: 'foo' }\n if (isDefined(param.example)) {\n return { value: param.example }\n }\n\n // param examples e.g. { examples: ['foo', 'bar'] }\n if (Array.isArray(param.examples) && param.examples.length > 0) {\n return { value: param.examples[0] }\n }\n\n // schema example e.g. { example: 'foo' } while being discouraged\n // see https://spec.openapis.org/oas/v3.1.1.html#fixed-fields-20\n if (isDefined(schema?.example)) {\n return { value: schema.example }\n }\n\n // schema examples e.g. { examples: ['foo', 'bar'] }\n if (Array.isArray(schema?.examples) && schema.examples.length > 0) {\n // For boolean type, default to false when using schema examples\n if (schema?.type === 'boolean') {\n return { value: schema.default ?? false }\n }\n return { value: schema.examples[0] }\n }\n\n // content examples e.g. { content: { 'application/json': { examples: { foo: { value: 'bar' } } } } }\n if (param.content) {\n const firstContentType = objectKeys(param.content)[0]\n if (firstContentType) {\n const content = (param.content as ParameterContent)[firstContentType]\n if (content?.examples) {\n const firstExampleKey = Object.keys(content.examples)[0]\n if (firstExampleKey) {\n const example = content.examples[firstExampleKey]\n if (isDefined(example?.value)) {\n return { value: example.value }\n }\n }\n }\n // content example e.g. { example: 'foo' }\n if (isDefined(content?.example)) {\n return { value: content.example }\n }\n }\n }\n\n return null\n })() as null | { value: any; examples?: string[] }\n\n /**\n * TODO:\n * - Need better value defaulting here\n * - Need to handle non-string parameters much better\n * - Need to handle unions/array values for schema\n */\n const value = String(firstExample?.value ?? schema?.default ?? '')\n\n // Handle non-string enums and enums within items for array types\n const parseEnum = (() => {\n if (schema?.enum && schema?.type !== 'string') {\n return schema.enum?.map(String)\n }\n\n if (schema?.items?.enum && schema?.type === 'array') {\n return schema.items.enum.map(String)\n }\n\n return schema?.enum\n })()\n\n // Handle parameter examples\n const examples =\n firstExample?.examples ||\n (schema?.examples && schema?.type !== 'string' ? schema.examples?.map(String) : schema?.examples)\n\n // safe parse the example\n const example = schemaModel(\n {\n ...schema,\n key: param.name,\n value,\n description: param.description,\n required: param.required,\n /** Initialized all required properties to enabled */\n enabled: !!param.required,\n enum: parseEnum,\n examples,\n },\n requestExampleParametersSchema,\n false,\n )\n\n if (!example) {\n console.warn(`Example at ${param.name} is invalid.`)\n return requestExampleParametersSchema.parse({})\n }\n\n return example\n}\n\n/**\n * Create new request example from a request\n * Iterates the name of the example if provided\n */\nexport function createExampleFromRequest(request: Request, name: string, server?: Server): RequestExample {\n // ---------------------------------------------------------------------------\n // Populate all parameters with an example value\n const parameters: Record<'path' | 'cookie' | 'header' | 'query' | 'headers', RequestExampleParameter[]> = {\n path: [],\n query: [],\n cookie: [],\n // deprecated TODO: add zod transform to remove\n header: [],\n headers: [{ key: 'Accept', value: '*/*', enabled: true }],\n }\n\n // Populated the separated params\n request.parameters?.forEach((p) => parameters[p.in].push(createParamInstance(p)))\n\n // TODO: add zod transform to remove header and only support headers\n if (parameters.header.length > 0) {\n parameters.headers = parameters.header\n parameters.header = []\n }\n\n // Get content type header\n const contentTypeHeader = parameters.headers.find((h) => h.key.toLowerCase() === 'content-type')\n\n // ---------------------------------------------------------------------------\n // Handle request body defaulting for various content type encodings\n const body: ExampleRequestBody = {\n activeBody: 'raw',\n }\n\n // If we have a request body or a content type header\n // TODO: we don't even handle path parameters here\n if (request.requestBody || contentTypeHeader?.value) {\n const requestBody = getRequestBodyFromOperation(request)\n const contentType = request.requestBody ? requestBody?.mimeType : contentTypeHeader?.value\n\n // Handle JSON and JSON-like mimetypes\n if (contentType?.includes('/json') || contentType?.endsWith('+json')) {\n body.activeBody = 'raw'\n body.raw = {\n encoding: 'json',\n mimeType: contentType,\n value: requestBody?.text ?? JSON.stringify({}),\n }\n }\n\n if (contentType === 'application/xml') {\n body.activeBody = 'raw'\n body.raw = {\n encoding: 'xml',\n value: requestBody?.text ?? '',\n }\n }\n\n /**\n * TODO: Are we loading example files from somewhere based on the spec?\n * How are we handling the body values\n */\n if (contentType === 'application/octet-stream') {\n body.activeBody = 'binary'\n body.binary = undefined\n }\n\n if (contentType === 'application/x-www-form-urlencoded' || contentType === 'multipart/form-data') {\n body.activeBody = 'formData'\n body.formData = {\n encoding: contentType === 'application/x-www-form-urlencoded' ? 'urlencoded' : 'form-data',\n value: (requestBody?.params || []).map((param) => {\n if (param.value instanceof File) {\n return {\n key: param.name,\n value: 'BINARY',\n file: param.value,\n enabled: true,\n }\n }\n return {\n key: param.name,\n value: param.value || '',\n enabled: true,\n }\n }),\n }\n }\n\n if (contentType?.startsWith('text/')) {\n body.activeBody = 'raw'\n body.raw = {\n encoding: 'text',\n value: requestBody?.text ?? '',\n }\n }\n\n // Add the content-type header if it doesn't exist and if it's not multipart request\n if (requestBody?.mimeType && !contentTypeHeader && !requestBody.mimeType.startsWith('multipart/')) {\n parameters.headers.push({\n key: 'Content-Type',\n value: requestBody.mimeType,\n enabled: true,\n })\n }\n }\n\n const serverVariables = server ? getServerVariableExamples(server) : {}\n\n // safe parse the example\n const example = schemaModel(\n {\n requestUid: request.uid,\n parameters,\n name,\n body,\n serverVariables,\n },\n requestExampleSchema,\n false,\n )\n\n if (!example) {\n console.warn(`Example at ${request.uid} is invalid.`)\n return requestExampleSchema.parse({})\n }\n return example\n}\n"],
5
- "mappings": "AAAA,SAAS,iBAAiB;AAC1B,SAAS,kBAAkB;AAC3B,SAAS,cAAc;AACvB,SAA6B,oBAAoB;AACjD,SAAS,SAAS;AAElB,SAAS,mBAAmB;AAC5B,SAAS,mCAAmC;AAC5C,SAAS,iCAAiC;AAenC,MAAM,iCAAiC,EAC3C,OAAO;AAAA,EACN,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE;AAAA,EAC1B,OAAO,EAAE,OAAO,OAAO,EAAE,QAAQ,EAAE;AAAA,EACnC,SAA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uBAAuB;AAChG,WAAK,aAAa;AAClB,WAAK,WAAW;AAAA,QACd,UAAU,gBAAgB,sCAAsC,eAAe;AAAA,QAC/E,QAAQ,aAAa,UAAU,CAAC,GAAG,IAAI,CAAC,UAAU;AAChD,cAAI,MAAM,iBAAiB,MAAM;AAC/B,mBAAO;AAAA,cACL,KAAK,MAAM;AAAA,cACX,OAAO;AAAA,cACP,MAAM,MAAM;AAAA,cACZ,SAAS;AAAA,YACX;AAAA,UACF;AACA,iBAAO;AAAA,YACL,KAAK,MAAM;AAAA,YACX,OAAO,MAAM,SAAS;AAAA,YACtB,SAAS;AAAA,UACX;AAAA,QACF,CAAC;AAAA,MACH;AAAA,IACF;AAEA,QAAI,aAAa,WAAW,OAAO,GAAG;AACpC,WAAK,aAAa;AAClB,WAAK,MAAM;AAAA,QACT,UAAU;AAAA,QACV,OAAO,aAAa,QAAQ;AAAA,MAC9B;AAAA,IACF;AAGA,QAAI,aAAa,YAAY,CAAC,qBAAqB,CAAC,YAAY,SAAS,WAAW,YAAY,GAAG;AACjG,iBAAW,QAAQ,KAAK;AAAA,QACtB,KAAK;AAAA,QACL,OAAO,YAAY;AAAA,QACnB,SAAS;AAAA,MACX,CAAC;AAAA,IACH;AAAA,EACF;AAEA,QAAM,kBAAkB,SAAS,0BAA0B,MAAM,IAAI,CAAC;AAGtE,QAAM,UAAU;AAAA,IACd;AAAA,MACE,YAAY,QAAQ;AAAA,MACpB;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACF;AAAA,IACA;AAAA,IACA;AAAA,EACF;AAEA,MAAI,CAAC,SAAS;AACZ,YAAQ,KAAK,cAAc,QAAQ,GAAG,cAAc;AACpD,WAAO,qBAAqB,MAAM,CAAC,CAAC;AAAA,EACtC;AACA,SAAO;AACT;",
6
- "names": ["example"]
7
- }
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../src/entities/spec/requests.ts"],
4
- "sourcesContent": ["import {\n type PostResponseSchema,\n XCodeSamplesSchema,\n XPostResponseSchema,\n} from '@scalar/openapi-types/schemas/extensions'\nimport { oasSecurityRequirementSchema } from '@scalar/types/entities'\nimport { XScalarStability } from '@scalar/types/legacy'\nimport { type ENTITY_BRANDS, nanoidSchema } from '@scalar/types/utils'\nimport { type ZodSchema, z } from 'zod'\n\nimport { selectedSecuritySchemeUidSchema } from '@/entities/shared/utility'\n\nimport { oasParameterSchema } from './parameters'\nimport { type RequestExample, xScalarExampleSchema } from './request-examples'\nimport { oasExternalDocumentationSchema } from './spec-objects'\n\nconst requestMethods = ['delete', 'get', 'head', 'options', 'patch', 'post', 'put', 'trace'] as const\n\nexport type RequestMethod = (typeof requestMethods)[number]\n\n/** A single set of populated values for a sent request */\nexport type ResponseInstance = Omit<Response, 'headers'> & {\n /** Store headers as an object to match what we had with axios */\n headers: Record<string, string>\n /** Keys of headers which set cookies */\n cookieHeaderKeys: string[]\n /** Time in ms the request took */\n duration: number\n /** The response status */\n status: number\n /** The response status text */\n statusText: string\n /** The response method */\n method: RequestMethod\n /** The request path */\n path: string\n} & (\n | {\n /** The response data */\n data: string | Blob\n /** The response size in bytes */\n size: number\n }\n | {\n /** A stream reader for a streamable response body */\n reader: ReadableStreamDefaultReader<Uint8Array>\n }\n )\n\n/** A single request/response set to save to the history stack */\nexport type RequestEvent = {\n request: RequestExample\n response: ResponseInstance\n timestamp: number\n}\n\n// TODO: Type body definitions\ntype RequestBody = object\nconst requestBodySchema = z.any() satisfies ZodSchema<RequestBody>\n\n/** Open API Compliant Request Validator */\nconst oasRequestSchema = z.object({\n /**\n * A list of tags for API documentation control. Tags can be used for logical\n * grouping of operations by resources or any other qualifier.\n *\n * These tags are the openapi spec tag names, not uids\n */\n 'tags': z.string().array().optional(),\n /** A short summary of what the operation does. */\n 'summary': z.string().optional(),\n /** A verbose explanation of the operation behavior. CommonMark syntax MAY be used for rich text representation. */\n 'description': z.string().optional(),\n /**\n * Unique string used to identify the operation. The id MUST be unique among all operations described in the API.\n * The operationId value is case-sensitive. Tools and libraries MAY use the operationId to uniquely identify an\n * operation, therefore, it is RECOMMENDED to follow bin common programming naming conventions./\n */\n 'operationId': z.string().optional(),\n /**\n * A declaration of which security mechanisms can be used across the API. The list of\n * values includes alternative security requirement objects that can be used. Only\n * one of the security requirement objects need to be satisfied to authorize a request.\n * Individual operations can override this definition. To make security optional, an empty\n * security requirement ({}) can be included in the array.\n */\n 'security': z.array(oasSecurityRequirementSchema).optional(),\n /**\n * The request body applicable for this operation. The requestBody is fully supported in HTTP methods where the\n * HTTP 1.1 specification [RFC7231] has explicitly defined semantics for request bodies. In other cases where the\n * HTTP spec is vague (such as GET, HEAD and DELETE), requestBody is permitted but does not have well-defined\n * semantics and SHOULD be avoided if possible.\n */\n 'requestBody': requestBodySchema.optional(),\n /**\n * Request parameters\n */\n 'parameters': oasParameterSchema.array().optional(),\n /**\n * External documentation object\n */\n 'externalDocs': oasExternalDocumentationSchema.optional(),\n 'deprecated': z.boolean().optional(),\n /** Response formats */\n 'responses': z.record(z.string(), z.any()).optional(),\n /** Callbacks */\n 'callbacks': z.record(z.string(), z.record(z.string(), z.record(z.string(), z.any()))).optional(),\n /** xScalar examples */\n 'x-scalar-examples': z.record(z.string(), xScalarExampleSchema).optional(),\n /** Hide operations */\n 'x-internal': z.boolean().optional(),\n /** Ignore operations */\n 'x-scalar-ignore': z.boolean().optional(),\n})\n\n/**\n * An OpenAPI extension to indicate the stability of the operation\n *\n * @example\n * ```yaml\n * x-scalar-stability: deprecated\n * ```\n */\nconst ScalarStabilitySchema = z.object({\n 'x-scalar-stability': z\n .enum([XScalarStability.Deprecated, XScalarStability.Experimental, XScalarStability.Stable])\n .optional()\n .catch(undefined),\n})\n\n/**\n * Extended properties added to the spec definition for client usage\n *\n * WARNING: DO NOT ADD PROPERTIES THAT SHARE A NAME WITH OAS OPERATION ENTITIES\n *\n * This object is directly converted to a spec operation during saving\n */\nconst extendedRequestSchema = z.object({\n type: z.literal('request').optional().default('request'),\n uid: nanoidSchema.brand<ENTITY_BRANDS['OPERATION']>(),\n /** Path Key */\n path: z.string().optional().default(''),\n /** Request Method */\n method: z.enum(requestMethods).default('get'),\n /** List of server UIDs specific to the request */\n servers: z.string().brand<ENTITY_BRANDS['SERVER']>().array().default([]),\n /** The currently selected server */\n selectedServerUid: z.string().brand<ENTITY_BRANDS['SERVER']>().optional().nullable().default(null),\n /** List of example UIDs associated with the request */\n examples: z.string().brand<ENTITY_BRANDS['EXAMPLE']>().array().default([]),\n /** List of security scheme UIDs associated with the request */\n selectedSecuritySchemeUids: selectedSecuritySchemeUidSchema,\n})\n\nexport type PostResponseScript = z.infer<typeof PostResponseSchema>\nexport type PostResponseScripts = z.infer<typeof XPostResponseSchema>['x-post-response']\n\n/** Unified request schema for client usage */\nexport const requestSchema = oasRequestSchema\n .omit({ 'x-scalar-examples': true })\n .merge(XCodeSamplesSchema)\n .merge(ScalarStabilitySchema)\n .merge(extendedRequestSchema)\n .merge(XPostResponseSchema)\n\nexport type Request = z.infer<typeof requestSchema>\nexport type RequestPayload = z.input<typeof requestSchema>\n"],
5
- "mappings": "AAAA;AAAA,EAEE;AAAA,EACA;AAAA,OACK;AACP,SAAS,oCAAoC;AAC7C,SAAS,wBAAwB;AACjC,SAA6B,oBAAoB;AACjD,SAAyB,SAAS;AAElC,SAAS,uCAAuC;AAEhD,SAAS,0BAA0B;AACnC,SAA8B,4BAA4B;AAC1D,SAAS,sCAAsC;AAE/C,MAAM,iBAAiB,CAAC,UAAU,OAAO,QAAQ,WAAW,SAAS,QAAQ,OAAO,OAAO;AA0C3F,MAAM,oBAAoB,EAAE,IAAI;AAGhC,MAAM,mBAAmB,EAAE,OAAO;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOhC,QAAQ,EAAE,OAAO,EAAE,MAAM,EAAE,SAAS;AAAA;AAAA,EAEpC,WAAW,EAAE,OAAO,EAAE,SAAS;AAAA;AAAA,EAE/B,eAAe,EAAE,OAAO,EAAE,SAAS;AAAA;AAAA;AAAA;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AAQ,KAAK;AAAA;AAAA,EAE5C,SAAS,EAAE,OAAO,EAAE,MAA+B,EAAE,MAAM,EAAE,QAAQ,CAAC,CAAC;AAAA;AAAA,EAEvE,mBAAmB,EAAE,OAAO,EAAE,MAA+B,EAAE,SAAS,EAAE,SAAS,EAAE,QAAQ,IAAI;AAAA;AAAA,EAEjG,UAAU,EAAE,OAAO,EAAE,MAAgC,EAAE,MAAM,EAAE,QAAQ,CAAC,CAAC;AAAA;AAAA,EAEzE,4BAA4B;AAC9B,CAAC;AAMM,MAAM,gBAAgB,iBAC1B,KAAK,EAAE,qBAAqB,KAAK,CAAC,EAClC,MAAM,kBAAkB,EACxB,MAAM,qBAAqB,EAC3B,MAAM,qBAAqB,EAC3B,MAAM,mBAAmB;",
6
- "names": []
7
- }
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../src/entities/spec/server.ts"],
4
- "sourcesContent": ["import { type ENTITY_BRANDS, nanoidSchema } from '@scalar/types/utils'\nimport { z } from 'zod'\n\n/**\n * Server Variable Object\n *\n * An object representing a Server Variable for server URL template substitution.\n *\n * @see https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.1.md#server-variable-object\n */\nconst oasServerVariableSchema = z.object({\n /**\n * An enumeration of string values to be used if the substitution options are from a limited set. The array MUST NOT be empty.\n */\n enum: z.array(z.string()).optional(),\n /**\n * REQUIRED. The default value to use for substitution, which SHALL be sent if an alternate value is not supplied.\n * Note this behavior is different than the Schema Object's treatment of default values, because in those cases\n * parameter values are optional. If the enum is defined, the value MUST exist in the enum's values.\n */\n default: z.string().optional(),\n /**\n * An optional description for the server variable. CommonMark syntax MAY be used for rich text representation.\n */\n description: z.string().optional(),\n})\n\n/** Extended schema for server variables */\nconst extendedServerVariableSchema = oasServerVariableSchema\n .extend({\n /** The value of the variable */\n value: z.string().optional(),\n })\n .refine((data) => {\n // Set default to the first enum value if invalid\n if (Array.isArray(data.enum) && !data.enum.includes(data.default ?? '') && data.enum.length > 0) {\n data.default = data.enum[0]\n }\n\n if (Array.isArray(data.enum) && data.enum.length === 0) {\n delete data.enum\n }\n\n // Always return true since we've modified the data to be valid\n return true\n })\n\n/**\n * Server Object\n *\n * An object representing a Server.\n *\n * @see https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.1.md#server-object\n */\nconst oasServerSchema = z.object({\n /**\n * REQUIRED. A URL to the target host. This URL supports Server Variables and MAY be relative, to indicate that\n * the host location is relative to the location where the OpenAPI document is being served. Variable substitutions\n * will be made when a variable is named in {brackets}.\n */\n url: z.string(),\n /**\n * An optional string describing the host designated by the URL. CommonMark syntax MAY be used for rich text\n * representation.\n */\n description: z.string().optional(),\n /** A map between a variable name and its value. The value is used for substitution in the server's URL template. */\n variables: z.record(z.string(), extendedServerVariableSchema).optional(),\n})\n\nexport const serverSchema = oasServerSchema.extend({\n uid: nanoidSchema.brand<ENTITY_BRANDS['SERVER']>(),\n})\n\nexport type Server = z.infer<typeof serverSchema>\nexport type ServerPayload = z.input<typeof serverSchema>\n"],
5
- "mappings": "AAAA,SAA6B,oBAAoB;AACjD,SAAS,SAAS;AASlB,MAAM,0BAA0B,EAAE,OAAO;AAAA;AAAA;AAAA;AAAA,EAIvC,MAAM,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,SAAS;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAMnC,SAAS,EAAE,OAAO,EAAE,SAAS;AAAA;AAAA;AAAA;AAAA,EAI7B,aAAa,EAAE,OAAO,EAAE,SAAS;AACnC,CAAC;AAGD,MAAM,+BAA+B,wBAClC,OAAO;AAAA;AAAA,EAEN,OAAO,EAAE,OAAO,EAAE,SAAS;AAC7B,CAAC,EACA,OAAO,CAAC,SAAS;AAEhB,MAAI,MAAM,QAAQ,KAAK,IAAI,KAAK,CAAC,KAAK,KAAK,SAAS,KAAK,WAAW,EAAE,KAAK,KAAK,KAAK,SAAS,GAAG;AAC/F,SAAK,UAAU,KAAK,KAAK,CAAC;AAAA,EAC5B;AAEA,MAAI,MAAM,QAAQ,KAAK,IAAI,KAAK,KAAK,KAAK,WAAW,GAAG;AACtD,WAAO,KAAK;AAAA,EACd;AAGA,SAAO;AACT,CAAC;AASH,MAAM,kBAAkB,EAAE,OAAO;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAM/B,KAAK,EAAE,OAAO;AAAA;AAAA;AAAA;AAAA;AAAA,EAKd,aAAa,EAAE,OAAO,EAAE,SAAS;AAAA;AAAA,EAEjC,WAAW,EAAE,OAAO,EAAE,OAAO,GAAG,4BAA4B,EAAE,SAAS;AACzE,CAAC;AAEM,MAAM,eAAe,gBAAgB,OAAO;AAAA,EACjD,KAAK,aAAa,MAA+B;AACnD,CAAC;",
6
- "names": []
7
- }
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../src/entities/spec/spec-objects.ts"],
4
- "sourcesContent": ["import { omitUndefinedValues } from '@scalar/helpers/object/omit-undefined-values'\nimport { XScalarSdkInstallationSchema } from '@scalar/openapi-types/schemas/extensions'\nimport { type ENTITY_BRANDS, nanoidSchema } from '@scalar/types/utils'\nimport { z } from 'zod'\n\n/**\n * License Object\n *\n * License information for the exposed API.\n *\n * @see https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.1.md#license-object\n */\nexport const oasLicenseSchema = z\n .object({\n /** REQUIRED. The license name used for the API. */\n name: z.string().optional().nullable().catch(null),\n /** An SPDX license expression for the API. The identifier field is mutually exclusive of the url field. */\n identifier: z.string().optional().catch(undefined),\n /**\n * A URI for the license used for the API. This MUST be in the form of a URI. The url field is mutually exclusive of the identifier field.\n */\n url: z.string().url().optional().catch(undefined),\n })\n .transform(omitUndefinedValues)\n\n/**\n * Contact Object\n *\n * Contact information for the exposed API.\n *\n * @see https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.1.md#contact-object\n */\nexport const oasContactSchema = z\n .object({\n /** The identifying name of the contact person/organization. */\n name: z.string().optional(),\n /** The URL pointing to the contact information. This MUST be in the form of a URL. */\n url: z.string().url().optional().catch(undefined),\n /** The email address of the contact person/organization. This MUST be in the form of an email address. */\n email: z.string().optional().catch(undefined),\n })\n .transform(omitUndefinedValues)\n\n/**\n * Info Object\n *\n * The object provides metadata about the API. The metadata MAY be used by the clients if needed,\n * and MAY be presented in editing or documentation generation tools for convenience.\n *\n * @see https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.1.md#info-object\n */\nexport const oasInfoSchema = z\n .object({\n /** REQUIRED. The title of the API. */\n title: z.string().catch('API'),\n /** A short summary of the API. */\n summary: z.string().optional().catch(undefined),\n /** A description of the API. CommonMark syntax MAY be used for rich text representation. */\n description: z.string().optional().catch(undefined),\n /** A URL to the Terms of Service for the API. This MUST be in the form of a URL. */\n termsOfService: z.string().url().optional().catch(undefined),\n /** The contact information for the exposed API. */\n contact: oasContactSchema.optional().catch(undefined),\n /** The license information for the exposed API. */\n license: oasLicenseSchema.optional().catch(undefined),\n /**\n * REQUIRED. The version of the OpenAPI Document (which is distinct from the OpenAPI Specification version or the\n * version of the API being described or the version of the OpenAPI Description).\n */\n version: z.string().catch('1.0'),\n })\n .merge(XScalarSdkInstallationSchema)\n .transform(omitUndefinedValues)\n\n/**\n * External Documentation Object\n *\n * Allows referencing an external resource for extended documentation.\n *\n * @see https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.1.md#external-documentation-object\n */\nexport const oasExternalDocumentationSchema = z\n .object({\n /** A description of the target documentation. CommonMark syntax MAY be used for rich text representation. */\n description: z.string().optional().catch(undefined),\n /** REQUIRED. The URL for the target documentation. This MUST be in the form of a URL. */\n url: z.string(),\n })\n .transform(omitUndefinedValues)\n\n// not used but kept for consistency\n// export type ExternalDocumentation = z.infer<typeof oasExternalDocumentationSchema>\n\nconst xScalarNestedSchema = z\n .object({\n tagName: z.string(),\n })\n .array()\n\n/**\n * Tag Object\n *\n * Adds metadata to a single tag that is used by the Operation Object. It is not mandatory to have a Tag Object per tag\n * defined in the Operation Object instances.\n *\n * @see https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.1.md#tag-object\n */\nconst oasTagSchema = z.object({\n // TODO: Remove\n /**\n * @deprecated Needs to be remove as it is not a spec property\n */\n 'type': z.literal('tag').optional().default('tag'),\n /** REQUIRED. The name of the tag. */\n 'name': z.string(),\n /** A description for the tag. CommonMark syntax MAY be used for rich text representation. */\n 'description': z.string().optional().catch(undefined),\n /** Additional external documentation for this tag. */\n 'externalDocs': oasExternalDocumentationSchema.optional(),\n 'x-scalar-children': xScalarNestedSchema.default([]).optional(),\n /** Hide collections */\n 'x-internal': z.boolean().optional(),\n 'x-scalar-ignore': z.boolean().optional(),\n})\n\nexport const tagSchema = oasTagSchema.extend({\n uid: nanoidSchema.brand<ENTITY_BRANDS['TAG']>(),\n children: z\n .union([z.string().brand<ENTITY_BRANDS['OPERATION']>(), z.string().brand<ENTITY_BRANDS['TAG']>()])\n .array()\n .default([]),\n})\n\nexport type Tag = z.infer<typeof tagSchema>\nexport type TagPayload = z.input<typeof tagSchema>\n"],
5
- "mappings": "AAAA,SAAS,2BAA2B;AACpC,SAAS,oCAAoC;AAC7C,SAA6B,oBAAoB;AACjD,SAAS,SAAS;AASX,MAAM,mBAAmB,EAC7B,OAAO;AAAA;AAAA,EAEN,MAAM,EAAE,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,IAAI;AAAA;AAAA,EAEjD,YAAY,EAAE,OAAO,EAAE,SAAS,EAAE,MAAM,MAAS;AAAA;AAAA;AAAA;AAAA,EAIjD,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,MAAS;AAClD,CAAC,EACA,UAAU,mBAAmB;AASzB,MAAM,mBAAmB,EAC7B,OAAO;AAAA;AAAA,EAEN,MAAM,EAAE,OAAO,EAAE,SAAS;AAAA;AAAA,EAE1B,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,MAAS;AAAA;AAAA,EAEhD,OAAO,EAAE,OAAO,EA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AE,SAAS;AAAA,EACnC,mBAAmB,EAAE,QAAQ,EAAE,SAAS;AAC1C,CAAC;AAEM,MAAM,YAAY,aAAa,OAAO;AAAA,EAC3C,KAAK,aAAa,MAA4B;AAAA,EAC9C,UAAU,EACP,MAAM,CAAC,EAAE,OAAO,EAAE,MAAkC,GAAG,EAAE,OAAO,EAAE,MAA4B,CAAC,CAAC,EAChG,MAAM,EACN,QAAQ,CAAC,CAAC;AACf,CAAC;",
6
- "names": []
7
- }
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../src/entities/spec/x-scalar-environments.ts"],
4
- "sourcesContent": ["import { z } from 'zod'\n\nconst xScalarEnvVarSchema = z.union([\n z.object({\n description: z.string().optional(),\n default: z.string().default(''),\n }),\n z.string(),\n])\n// not used but kept for consistency\n// export type XScalarEnvVar = z.infer<typeof xScalarEnvVarSchema>\n\nconst xScalarEnvironmentSchema = z.object({\n description: z.string().optional(),\n color: z.string().optional(),\n /** A map of variables by name */\n variables: z.record(z.string(), xScalarEnvVarSchema),\n})\n\n/** A map of environments by name */\nexport const xScalarEnvironmentsSchema = z.record(\n /** Name */\n z.string(),\n /** Environment definition */\n xScalarEnvironmentSchema,\n)\n\nexport type XScalarEnvironment = z.infer<typeof xScalarEnvironmentSchema>\nexport type XScalarEnvironments = z.infer<typeof xScalarEnvironmentsSchema>\n"],
5
- "mappings": "AAAA,SAAS,SAAS;AAElB,MAAM,sBAAsB,EAAE,MAAM;AAAA,EAClC,EAAE,OAAO;AAAA,IACP,aAAa,EAAE,OAAO,EAAE,SAAS;AAAA,IACjC,SAAS,EAAE,OAAO,EAAE,QAAQ,EAAE;AAAA,EAChC,CAAC;AAAA,EACD,EAAE,OAAO;AACX,CAAC;AAID,MAAM,2BAA2B,EAAE,OAAO;AAAA,EACxC,aAAa,EAAE,OAAO,EAAE,SAAS;AAAA,EACjC,OAAO,EAAE,OAAO,EAAE,SAAS;AAAA;AAAA,EAE3B,WAAW,EAAE,OAAO,EAAE,OAAO,GAAG,mBAAmB;AACrD,CAAC;AAGM,MAAM,4BAA4B,EAAE;AAAA;AAAA,EAEzC,EAAE,OAAO;AAAA;AAAA,EAET;AACF;",
6
- "names": []
7
- }
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../src/entities/spec/x-scalar-secrets.ts"],
4
- "sourcesContent": ["import { z } from 'zod'\n\nconst xScalarSecretVarSchema = z.object({\n description: z.string().optional(),\n example: z.string().optional(),\n})\n\nexport const xScalarSecretsSchema = z.record(z.string(), xScalarSecretVarSchema)\n// not used but kept for consistency\n// export type XScalarSecrets = z.infer<typeof xScalarSecretsSchema>\n"],
5
- "mappings": "AAAA,SAAS,SAAS;AAElB,MAAM,yBAAyB,EAAE,OAAO;AAAA,EACtC,aAAa,EAAE,OAAO,EAAE,SAAS;AAAA,EACjC,SAAS,EAAE,OAAO,EAAE,SAAS;AAC/B,CAAC;AAEM,MAAM,uBAAuB,EAAE,OAAO,EAAE,OAAO,GAAG,sBAAsB;",
6
- "names": []
7
- }
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../src/entities/workspace/index.ts"],
4
- "sourcesContent": ["export {\n type HotKeyConfig,\n type HotKeyModifiers,\n type Workspace,\n type WorkspacePayload,\n workspaceSchema,\n} from './workspace'\n"],
5
- "mappings": "AAAA;AAAA,EAKE;AAAA,OACK;",
6
- "names": []
7
- }
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../src/entities/workspace/workspace.ts"],
4
- "sourcesContent": ["import { themeIds } from '@scalar/themes'\nimport { type ENTITY_BRANDS, nanoidSchema } from '@scalar/types/utils'\nimport { z } from 'zod'\n\nimport { HOTKEY_EVENT_NAMES, KEYDOWN_KEYS } from '../hotkeys/hotkeys'\n\nconst modifiers = z\n .array(z.union([z.literal('Meta'), z.literal('Control'), z.literal('Shift'), z.literal('Alt'), z.literal('default')]))\n .optional()\n .default(['default'])\n\nexport type HotKeyModifiers = z.infer<typeof modifiers>\n\nconst hotKeys = z.partialRecord(\n z.enum(KEYDOWN_KEYS),\n z.object({\n modifiers: modifiers.optional(),\n event: z.enum(HOTKEY_EVENT_NAMES),\n }),\n)\nexport type HotKeyConfig = z.infer<typeof hotKeys>\n\nconst hotKeyConfigSchema = z\n .object({\n modifiers,\n hotKeys: hotKeys.optional(),\n })\n .optional()\n\nexport const workspaceSchema = z.object({\n uid: nanoidSchema.brand<ENTITY_BRANDS['WORKSPACE']>(),\n name: z.string().default('Default Workspace'),\n /** Workspace description */\n description: z.string().default('Basic Scalar Workspace'),\n /** List of all collection uids in a given workspace */\n collections: z.array(z.string().brand<ENTITY_BRANDS['COLLECTION']>()).default([]),\n /** List of all environment uids in a given workspace, TODO: why is this a record? */\n environments: z.record(z.string(), z.string()).default({}),\n /** Customize hotkeys */\n hotKeyConfig: hotKeyConfigSchema,\n /** Active Environment ID to use for requests */\n activeEnvironmentId: z.string().optional().default('default'),\n /** List of all cookie uids in a given workspace */\n cookies: z.array(z.string().brand<ENTITY_BRANDS['COOKIE']>()).default([]),\n /** Workspace level proxy for all requests to be sent through */\n proxyUrl: z.string().optional(),\n /** Workspace level theme, we might move this to user level later */\n themeId: z.enum(themeIds).optional().default('default').catch('default'),\n /** Currently selected snippet client */\n selectedHttpClient: z\n .object({\n targetKey: z.string(),\n clientKey: z.string(),\n })\n .optional()\n .default({\n targetKey: 'shell',\n clientKey: 'curl',\n }),\n})\n\n/** The base scalar workspace */\nexport type Workspace = z.infer<typeof workspaceSchema>\nexport type WorkspacePayload = z.input<typeof workspaceSchema>\n"],
5
- "mappings": "AAAA,SAAS,gBAAgB;AACzB,SAA6B,oBAAoB;AACjD,SAAS,SAAS;AAElB,SAAS,oBAAoB,oBAAoB;AAEjD,MAAM,YAAY,EACf,MAAM,EAAE,MAAM,CAAC,EAAE,QAAQ,MAAM,GAAG,EAAE,QAAQ,SAAS,GAAG,EAAE,QAAQ,OAAO,GAAG,EAAE,QAAQ,KAAK,GAAG,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;AACL,CAAC;",
6
- "names": []
7
- }
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../src/helpers/client-plugins.ts"],
4
- "sourcesContent": ["import type { ApiReferenceEvents } from '@scalar/workspace-store/events'\nimport type { OperationObject } from '@scalar/workspace-store/schemas/v3.1/strict/operation'\nimport type { DefineComponent } from 'vue'\n\n/** A type representing the hooks that a client plugin can define */\ntype ClientPluginHooks = {\n beforeRequest: (payload: { request: Request }) => { request: Request } | void | Promise<{ request: Request } | void>\n responseReceived: (payload: {\n response: Response\n request: Request\n operation: OperationObject\n }) => void | Promise<void>\n}\n\n/** A vue component which accepts the specified props */\ntype ClientPluginComponent<\n Props extends Record<string, unknown>,\n Emits extends Record<string, (...args: any[]) => void> = {},\n> = {\n component: DefineComponent<Props, {}, {}, {}, {}, {}, {}, Emits>\n additionalProps?: Record<string, unknown>\n}\n\ntype ClientPluginComponents = {\n request: ClientPluginComponent<\n {\n operation: OperationObject\n // We could pre-build the js request and pass it here in the future if needed\n // request: Request\n },\n {\n 'operation:update:extension': (payload: ApiReferenceEvents['operation:update:extension']['payload']) => void\n }\n >\n response: ClientPluginComponent<{\n // response: Response\n // request: Request\n // operation: OperationObject\n }>\n}\n\n/**\n * ClientPlugin is used to extend the API Client with custom hooks and UI components.\n *\n * Example usage:\n *\n * const myPlugin: ClientPlugin = {\n * hooks: {\n * beforeRequest: (request) => {\n * // Modify the request before it is sent\n * request.headers.set('X-Custom-Header', 'foo');\n * return request;\n * },\n * responseReceived: async (response, operation) => {\n * // Handle post-response logic\n * const data = await response.json();\n * console.log('Received:', data, 'for operation:', operation.operationId);\n * }\n * },\n * components: {\n * request: MyRequestComponent, // Custom Vue component for rendering the request section\n * response: MyResponseComponent // Custom Vue component for rendering the response section\n * }\n * }\n */\nexport type ClientPlugin = {\n hooks?: Partial<ClientPluginHooks>\n components?: Partial<ClientPluginComponents>\n}\n\n/**\n * Maps hook names to their expected payload types.\n * This ensures type safety when executing hooks with their corresponding payloads.\n * Derived from the ClientPlugin hooks definition.\n */\ntype HookPayloadMap = {\n [K in keyof ClientPluginHooks]: Parameters<ClientPluginHooks[K]>[0]\n}\n\n/**\n * Execute any hook with type-safe payload handling.\n * The payload type is inferred from the hook name to ensure correct usage.\n */\nexport const executeHook = async <K extends keyof HookPayloadMap>(\n payload: HookPayloadMap[K],\n hookName: K,\n plugins: ClientPlugin[],\n): Promise<HookPayloadMap[K]> => {\n let currentPayload = payload\n\n for (const plugin of plugins) {\n const hook = plugin.hooks?.[hookName]\n if (hook) {\n const modifiedPayload = await hook(currentPayload as any)\n currentPayload = (modifiedPayload ?? currentPayload) as HookPayloadMap[K]\n }\n }\n\n return currentPayload\n}\n"],
5
- "mappings": "AAmFO,MAAM,cAAc,OACzB,SACA,UACA,YAC+B;AAC/B,MAAI,iBAAiB;AAErB,aAAW,UAAU,SAAS;AAC5B,UAAM,OAAO,OAAO,QAAQ,QAAQ;AACpC,QAAI,MAAM;AACR,YAAM,kBAAkB,MAAM,KAAK,cAAqB;AACxD,uBAAkB,mBAAmB;AAAA,IACvC;AAAA,EACF;AAEA,SAAO;AACT;",
6
- "names": []
7
- }
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../src/helpers/fetch-document.ts"],
4
- "sourcesContent": ["import { redirectToProxy } from '@scalar/helpers/url/redirect-to-proxy'\n\nimport { formatJsonOrYamlString } from './parse'\n\n// Doesn't work\nconst OLD_PROXY_URL = 'https://api.scalar.com/request-proxy'\n// Does work\nconst NEW_PROXY_URL = 'https://proxy.scalar.com'\n\n/**\n * Fetches an OpenAPI/Swagger document from a given URL\n *\n * @throws an error if the fetch fails\n */\nexport async function fetchDocument(\n url: string,\n proxyUrl?: string,\n fetcher?: (input: string | URL | globalThis.Request, init?: RequestInit) => Promise<Response>,\n prettyPrint = true,\n): Promise<string> {\n // This replaces the OLD_PROXY_URL with the NEW_PROXY_URL on the fly.\n if (proxyUrl === OLD_PROXY_URL) {\n // biome-ignore lint/style/noParameterAssign: It's ok, let's make an exception here.\n proxyUrl = NEW_PROXY_URL\n }\n\n const response = await (fetcher ? fetcher(url, undefined) : fetch(redirectToProxy(proxyUrl, url)))\n\n // Looks like the request failed\n if (response.status !== 200) {\n console.error(`[fetchDocument] Failed to fetch the OpenAPI document from ${url} (Status: ${response.status})`)\n\n if (!proxyUrl) {\n console.warn(\n `[fetchDocument] Tried to fetch the OpenAPI document from ${url} without a proxy. Are the CORS headers configured to allow cross-domain requests? https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS`,\n )\n }\n\n throw new Error(`Failed to fetch the OpenAPI document from ${url} (Status: ${response.status})`)\n }\n\n // If it's JSON, make it pretty\n if (prettyPrint) {\n return formatJsonOrYamlString(await response.text())\n }\n\n return await response.text()\n}\n"],
5
- "mappings": "AAAA,SAAS,uBAAuB;AAEhC,SAAS,8BAA8B;AAGvC,MAAM,gBAAgB;AAEtB,MAAM,gBAAgB;AAOtB,eAAsB,cACpB,KACA,UACA,SACA,cAAc,MACG;AAEjB,MAAI,aAAa,eAAe;AAE9B,eAAW;AAAA,EACb;AAEA,QAAM,WAAW,OAAO,UAAU,QAAQ,KAAK,MAAS,IAAI,MAAM,gBAAgB,UAAU,GAAG,CAAC;AAGhG,MAAI,SAAS,WAAW,KAAK;AAC3B,YAAQ,MAAM,6DAA6D,GAAG,aAAa,SAAS,MAAM,GAAG;AAE7G,QAAI,CAAC,UAAU;AACb,cAAQ;AAAA,QACN,4DAA4D,GAAG;AAAA,MACjE;AAAA,IACF;AAEA,UAAM,IAAI,MAAM,6CAA6C,GAAG,aAAa,SAAS,MAAM,GAAG;AAAA,EACjG;AAGA,MAAI,aAAa;AACf,WAAO,uBAAuB,MAAM,SAAS,KAAK,CAAC;AAAA,EACrD;AAEA,SAAO,MAAM,SAAS,KAAK;AAC7B;",
6
- "names": []
7
- }
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../src/helpers/fetch-with-proxy-fallback.ts"],
4
- "sourcesContent": ["import { redirectToProxy, shouldUseProxy } from '@scalar/helpers/url/redirect-to-proxy'\n\nexport type FetchWithProxyFallbackOptions = {\n proxyUrl: string | undefined\n /**\n * @see https://developer.mozilla.org/en-US/docs/Web/API/Request/cache\n */\n cache?: RequestInit['cache']\n}\n\n/**\n * Fetches an OpenAPI document with a proxyUrl fallback mechanism.\n *\n * If a proxy is provided and the URL requires it, it will first attempt to fetch using the proxy.\n * If the proxy fetch fails or is not used, it will fall back to a direct fetch.\n */\nexport async function fetchWithProxyFallback(url: string, { proxyUrl, cache }: FetchWithProxyFallbackOptions) {\n const fetchOptions = {\n cache: cache || 'default',\n }\n const shouldTryProxy = shouldUseProxy(proxyUrl, url)\n const initialUrl = shouldTryProxy ? redirectToProxy(proxyUrl, url) : url\n\n try {\n const result = await fetch(initialUrl, fetchOptions)\n\n if (result.ok || !shouldTryProxy) {\n return result\n }\n\n // Retry without proxyUrl if the initial request failed\n return await fetch(url, fetchOptions)\n } catch (error) {\n if (shouldTryProxy) {\n // If proxyUrl failed, try without it\n return await fetch(url, fetchOptions)\n }\n throw error\n }\n}\n"],
5
- "mappings": "AAAA,SAAS,iBAAiB,sBAAsB;AAgBhD,eAAsB,uBAAuB,KAAa,EAAE,UAAU,MAAM,GAAkC;AAC5G,QAAM,eAAe;AAAA,IACnB,OAAO,SAAS;AAAA,EAClB;AACA,QAAM,iBAAiB,eAAe,UAAU,GAAG;AACnD,QAAM,aAAa,iBAAiB,gBAAgB,UAAU,GAAG,IAAI;AAErE,MAAI;AACF,UAAM,SAAS,MAAM,MAAM,YAAY,YAAY;AAEnD,QAAI,OAAO,MAAM,CAAC,gBAAgB;AAChC,aAAO;AAAA,IACT;AAGA,WAAO,MAAM,MAAM,KAAK,YAAY;AAAA,EACtC,SAAS,OAAO;AACd,QAAI,gBAAgB;AAElB,aAAO,MAAM,MAAM,KAAK,YAAY;AAAA,IACtC;AACA,UAAM;AAAA,EACR;AACF;",
6
- "names": []
7
- }
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../src/helpers/index.ts"],
4
- "sourcesContent": ["export {\n /** @deprecated Please use isDefined from \\@scalar/helpers/array/is-defined instead */\n isDefined,\n} from '@scalar/helpers/array/is-defined'\nexport {\n /** @deprecated Please use json2xml from \\@scalar/helpers/file/json2xml instead */\n json2xml,\n} from '@scalar/helpers/file/json2xml'\nexport {\n /** @deprecated Please use canMethodHaveBody from \\@scalar/helpers/http/can-method-have-body instead */\n canMethodHaveBody,\n} from '@scalar/helpers/http/can-method-have-body'\nexport {\n /** @deprecated Please use REQUEST_METHODS from \\@scalar/helpers/http/http-methods instead */\n REQUEST_METHODS,\n /** @deprecated Please use getHttpMethodInfo from \\@scalar/helpers/http/http-info instead */\n getHttpMethodInfo,\n} from '@scalar/helpers/http/http-info'\nexport {\n /** @deprecated Please use HttpStatusCode from \\@scalar/helpers/http/http-status-codes instead */\n type HttpStatusCode,\n /** @deprecated Please use HttpStatusCodes from \\@scalar/helpers/http/http-status-codes instead */\n type HttpStatusCodes,\n /** @deprecated Please use httpStatusCodes from \\@scalar/helpers/http/http-status-codes instead */\n httpStatusCodes,\n} from '@scalar/helpers/http/http-status-codes'\nexport {\n /** @deprecated Please use isHttpMethod from \\@scalar/helpers/http/is-http-method instead */\n isHttpMethod,\n} from '@scalar/helpers/http/is-http-method'\nexport {\n /** @deprecated Please use objectKeys from \\@scalar/helpers/object/object-keys instead */\n objectKeys as getObjectKeys,\n} from '@scalar/helpers/object/object-keys'\nexport {\n /** @deprecated Please use findVariables from \\@scalar/helpers/regex/find-variables instead */\n findVariables,\n} from '@scalar/helpers/regex/find-variables'\nexport {\n /** @deprecated Please use REGEX from \\@scalar/helpers/regex/regex-helpers instead */\n REGEX,\n} from '@scalar/helpers/regex/regex-helpers'\nexport {\n /** @deprecated Please use replaceVariables from \\@scalar/helpers/regex/replace-variables instead */\n replaceVariables,\n} from '@scalar/helpers/regex/replace-variables'\nexport {\n /** @deprecated Please use camelToTitleWords from \\@scalar/helpers/string/camel-to-title instead */\n camelToTitleWords,\n} from '@scalar/helpers/string/camel-to-title'\nexport {\n /** @deprecated Please use capitalize from \\@scalar/helpers/string/capitalize instead */\n capitalize,\n} from '@scalar/helpers/string/capitalize'\n/**\n * @deprecated These helpers are being phased out. Please import directly from @scalar/helpers instead.\n * For example: import { createHash } from '\\@scalar/helpers/string/create-hash'\n */\nexport {\n /** @deprecated Please use createHash from \\@scalar/helpers/string/create-hash instead */\n createHash,\n} from '@scalar/helpers/string/create-hash'\nexport {\n /** @deprecated Please use iterateTitle from \\@scalar/helpers/string/iterate-title instead */\n iterateTitle,\n} from '@scalar/helpers/string/iterate-title'\nexport {\n /** @deprecated Please use ensureProtocol from \\@scalar/helpers/url/ensure-protocol instead */\n ensureProtocol,\n} from '@scalar/helpers/url/ensure-protocol'\nexport {\n /** @deprecated Please use isLocalUrl from \\@scalar/helpers/url/is-local-url instead */\n isLocalUrl,\n} from '@scalar/helpers/url/is-local-url'\nexport {\n /** @deprecated Please use isRelativePath from \\@scalar/helpers/url/is-relative-path instead */\n isRelativePath,\n} from '@scalar/helpers/url/is-relative-path'\nexport {\n /** @deprecated Please use isValidUrl from \\@scalar/helpers/url/is-valid-url instead */\n isValidUrl,\n} from '@scalar/helpers/url/is-valid-url'\nexport {\n /** @deprecated Please use makeUrlAbsolute from \\@scalar/helpers/url/make-url-absolute instead */\n makeUrlAbsolute,\n} from '@scalar/helpers/url/make-url-absolute'\nexport {\n /** @deprecated Please use combineUrlAndPath from \\@scalar/helpers/url/merge-urls instead */\n combineUrlAndPath,\n /** @deprecated Please use mergeSearchParams from \\@scalar/helpers/url/merge-urls instead */\n mergeSearchParams,\n /** @deprecated Please use mergeUrls from \\@scalar/helpers/url/merge-urls instead */\n mergeUrls,\n} from '@scalar/helpers/url/merge-urls'\n\nexport { type ClientPlugin, executeHook } from './client-plugins'\nexport { fetchDocument } from './fetch-document'\nexport { type FetchWithProxyFallbackOptions, fetchWithProxyFallback } from './fetch-with-proxy-fallback'\nexport { normalizeMimeType } from './normalize-mime-type'\nexport { normalizeMimeTypeObject } from './normalize-mime-type-object'\nexport { getOperationStability, getOperationStabilityColor, isOperationDeprecated } from './operation-stability'\nexport { formatJsonOrYamlString, isJsonString, json, parseJsonOrYaml, transformToJson, yaml } from './parse'\nexport { prettyPrintJson, replaceCircularDependencies } from './pretty-print-json'\nexport { schemaModel } from './schema-model'\nexport { getServersFromDocument } from './servers'\nexport { shouldIgnoreEntity } from './should-ignore-entity'\n"],
5
- "mappings": "AAAA;AAAA,EAEE;AAAA,OACK;AACP;AAAA,EAEE;AAAA,OACK;AACP;AAAA,EAEE;AAAA,OACK;AACP;AAAA,EAEE;AAAA,EAEA;AAAA,OACK;AACP;AAAA,EAME;AAAA,OACK;AACP;AAAA,EAEE;AAAA,OACK;AACP;AAAA,EAEgB;AAAA,OACT;AACP;AAAA,EAEE;AAAA,OACK;AACP;AAAA,EAEE;AAAA,OACK;AACP;AAAA,EAEE;AAAA,OACK;AACP;AAAA,EAEE;AAAA,OACK;AACP;AAAA,EAEE;AAAA,OACK;AAKP;AAAA,EAEE;AAAA,OACK;AACP;AAAA,EAEE;AAAA,OACK;AACP;AAAA,EAEE;AAAA,OACK;AACP;AAAA,EAEE;AAAA,OACK;AACP;AAAA,EAEE;AAAA,OACK;AACP;AAAA,EAEE;AAAA,OACK;AACP;AAAA,EAEE;AAAA,OACK;AACP;AAAA,EAEE;AAAA,EAEA;AAAA,EAEA;AAAA,OACK;AAEP,SAA4B,mBAAmB;AAC/C,SAAS,qBAAqB;AAC9B,SAA6C,8BAA8B;AAC3E,SAAS,yBAAyB;AAClC,SAAS,+BAA+B;AACxC,SAAS,uBAAuB,4BAA4B,6BAA6B;AACzF,SAAS,wBAAwB,cAAc,MAAM,iBAAiB,iBAAiB,YAAY;AACnG,SAAS,iBAAiB,mCAAmC;AAC7D,SAAS,mBAAmB;AAC5B,SAAS,8BAA8B;AACvC,SAAS,0BAA0B;",
6
- "names": []
7
- }
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../src/helpers/normalize-mime-type-object.ts"],
4
- "sourcesContent": ["import type { ResponseObject } from '@scalar/workspace-store/schemas/v3.1/strict/openapi-document'\nimport { normalizeMimeType } from './normalize-mime-type'\n\n/**\n * Remove charset from content types\n *\n * Example: `application/json; charset=utf-8` -> `application/json`\n */\nexport function normalizeMimeTypeObject(content?: ResponseObject['content']): ResponseObject['content'] {\n if (!content) {\n return content\n }\n\n const newContent: ResponseObject['content'] = {\n ...content,\n }\n\n Object.entries(newContent).forEach(([key, value]) => {\n const normalizedKey = normalizeMimeType(key)\n if (normalizedKey) {\n newContent[normalizedKey] = value\n }\n })\n\n return newContent\n}\n"],
5
- "mappings": "AACA,SAAS,yBAAyB;AAO3B,SAAS,wBAAwB,SAAgE;AACtG,MAAI,CAAC,SAAS;AACZ,WAAO;AAAA,EACT;AAEA,QAAM,aAAwC;AAAA,IAC5C,GAAG;AAAA,EACL;AAEA,SAAO,QAAQ,UAAU,EAAE,QAAQ,CAAC,CAAC,KAAK,KAAK,MAAM;AACnD,UAAM,gBAAgB,kBAAkB,GAAG;AAC3C,QAAI,eAAe;AACjB,iBAAW,aAAa,IAAI;AAAA,IAC9B;AAAA,EACF,CAAC;AAED,SAAO;AACT;",
6
- "names": []
7
- }
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../src/helpers/normalize-mime-type.ts"],
4
- "sourcesContent": ["import type { ContentType } from '@scalar/types/legacy'\n\n/**\n * Normalizes a MIME type to a standard format.\n *\n * Input: application/problem+json; charset=utf-8\n * Output: application/json\n */\nexport function normalizeMimeType(contentType: undefined): undefined\nexport function normalizeMimeType(contentType: string): ContentType\nexport function normalizeMimeType(contentType: string | undefined): ContentType | undefined {\n if (typeof contentType !== 'string') {\n return undefined\n }\n\n return (\n contentType\n // Remove '; charset=utf-8'\n .replace(/;.*$/, '')\n // Remove 'problem+' but keep vendor-specific vnd and fhir mime types\n .replace(/\\/(?!.*vnd\\.|fhir\\+).*\\+/, '/')\n // Remove whitespace\n .trim() as ContentType\n )\n}\n"],
5
- "mappings": "AAUO,SAAS,kBAAkB,aAA0D;AAC1F,MAAI,OAAO,gBAAgB,UAAU;AACnC,WAAO;AAAA,EACT;AAEA,SACE,YAEG,QAAQ,QAAQ,EAAE,EAElB,QAAQ,4BAA4B,GAAG,EAEvC,KAAK;AAEZ;",
6
- "names": []
7
- }
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../src/helpers/operation-stability.ts"],
4
- "sourcesContent": ["import { XScalarStabilityValues } from '@scalar/openapi-types/schemas/extensions'\n\ntype OperationStability = {\n deprecated?: boolean\n 'x-scalar-stability'?: unknown\n}\n\n/**\n * Returns true if an operation is considered deprecated.\n */\nexport const isOperationDeprecated = (operation: OperationStability): boolean =>\n operation.deprecated || operation['x-scalar-stability'] === XScalarStabilityValues.Deprecated\n\n/**\n * Get operation stability from deprecated or x-scalar-stability\n */\nexport const getOperationStability = (operation: OperationStability): XScalarStabilityValues | undefined =>\n operation.deprecated\n ? XScalarStabilityValues.Deprecated\n : (operation['x-scalar-stability'] as XScalarStabilityValues | undefined)\n\n/**\n * Get Operation stability tailwind color class\n */\nexport const getOperationStabilityColor = (operation: OperationStability): string => {\n switch (getOperationStability(operation)) {\n case XScalarStabilityValues.Deprecated:\n return 'text-red'\n case XScalarStabilityValues.Experimental:\n return 'text-orange'\n case XScalarStabilityValues.Stable:\n return 'text-green'\n default:\n return ''\n }\n}\n"],
5
- "mappings": "AAAA,SAAS,8BAA8B;AAUhC,MAAM,wBAAwB,CAAC,cACpC,UAAU,cAAc,UAAU,oBAAoB,MAAM,uBAAuB;AAK9E,MAAM,wBAAwB,CAAC,cACpC,UAAU,aACN,uBAAuB,aACtB,UAAU,oBAAoB;AAK9B,MAAM,6BAA6B,CAAC,cAA0C;AACnF,UAAQ,sBAAsB,SAAS,GAAG;AAAA,IACxC,KAAK,uBAAuB;AAC1B,aAAO;AAAA,IACT,KAAK,uBAAuB;AAC1B,aAAO;AAAA,IACT,KAAK,uBAAuB;AAC1B,aAAO;AAAA,IACT;AACE,aAAO;AAAA,EACX;AACF;",
6
- "names": []
7
- }
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../src/helpers/parse.ts"],
4
- "sourcesContent": ["import type { UnknownObject } from '@scalar/types/utils'\nimport { parse, stringify } from 'yaml'\n\ntype PrimitiveOrObject = object | string | null | number | boolean | undefined\n\n/** Yaml handling with optional safeparse */\nexport const yaml = {\n /** Parse and throw if the return value is not an object */\n parse: (val: string) => {\n const yamlObject = parse(val, { merge: true, maxAliasCount: 10000 })\n if (typeof yamlObject !== 'object') {\n throw Error('Invalid YAML object')\n }\n return yamlObject as UnknownObject\n },\n /** Parse and return a fallback on failure */\n parseSafe<T extends PrimitiveOrObject>(val: string, fallback: T | ((err: any) => T)): UnknownObject | T {\n try {\n return yaml.parse(val)\n } catch (err: any) {\n return typeof fallback === 'function' ? fallback(err) : fallback\n }\n },\n stringify,\n}\n\n/** JSON handling with optional safeparse */\nexport const json = {\n /** Parse and throw if the return value is not an object */\n parse: (val: string): UnknownObject => {\n const jsonObject = JSON.parse(val)\n if (typeof jsonObject !== 'object') {\n throw Error('Invalid JSON object')\n }\n return jsonObject\n },\n /** Parse and return a fallback on failure */\n parseSafe<T extends PrimitiveOrObject>(val: string, fallback: T | ((err: any) => T)): UnknownObject | T {\n try {\n return json.parse(val)\n } catch (err) {\n return typeof fallback === 'function' ? fallback(err) : fallback\n }\n },\n stringify: (val: object) => JSON.stringify(val),\n}\n\n/**\n * Check if value is a valid JSON string\n */\nexport const isJsonString = (value?: any) => {\n if (typeof value !== 'string') {\n return false\n }\n\n return !!json.parseSafe(value, false)\n}\n\n/**\n * This helper is used to transform the content of the swagger file to JSON, even it was YAML.\n */\nexport const transformToJson = (value: string) => {\n // Try json, then fallback to yaml, then fallback to string\n return JSON.stringify(json.parseSafe(value, yaml.parseSafe(value, value)))\n}\n\n/** Validates a JSON string if provided. Otherwise returns the raw YAML */\nexport function formatJsonOrYamlString(value: string) {\n // If we don't start with a bracket assume yaml\n const trimmed = value.trim()\n if (trimmed[0] !== '{' && trimmed[0] !== '[') {\n return value\n }\n\n try {\n // JSON\n return JSON.stringify(JSON.parse(value), null, 2)\n } catch {\n // YAML\n return value\n }\n}\n\n/** Parse JSON or YAML into an object */\nexport const parseJsonOrYaml = (value: string | UnknownObject): UnknownObject => {\n if (typeof value !== 'string') {\n return value\n }\n\n const jsonObject = json.parseSafe(value, null)\n if (jsonObject) {\n return jsonObject\n }\n\n // Value is probably supposed to be JSON. Throw\n if (value.length > 0 && ['{', '['].includes(value[0] ?? '')) {\n throw Error('Invalid JSON or YAML')\n }\n\n return yaml.parseSafe(value, (err) => {\n throw Error(err)\n })\n}\n"],
5
- "mappings": "AACA,SAAS,OAAO,iBAAiB;AAK1B,MAAM,OAAO;AAAA;AAAA,EAElB,OAAO,CAAC,QAAgB;AACtB,UAAM,aAAa,MAAM,KAAK,EAAE,OAAO,MAAM,eAAe,IAAM,CAAC;AACnE,QAAI,OAAO,eAAe,UAAU;AAClC,YAAM,MAAM,qBAAqB;AAAA,IACnC;AACA,WAAO;AAAA,EACT;AAAA;AAAA,EAEA,UAAuC,KAAa,UAAoD;AACtG,QAAI;AACF,aAAO,KAAK,MAAM,GAAG;AAAA,IACvB,SAAS,KAAU;AACjB,aAAO,OAAO,aAAa,aAAa,SAAS,GAAG,IAAI;AAAA,IAC1D;AAAA,EACF;AAAA,EACA;AACF;AAGO,MAAM,OAAO;AAAA;AAAA,EAElB,OAAO,CAAC,QAA+B;AACrC,UAAM,aAAa,KAAK,MAAM,GAAG;AACjC,QAAI,OAAO,eAAe,UAAU;AAClC,YAAM,MAAM,qBAAqB;AAAA,IACnC;AACA,WAAO;AAAA,EACT;AAAA;AAAA,EAEA,UAAuC,KAAa,UAAoD;AACtG,QAAI;AACF,aAAO,KAAK,MAAM,GAAG;AAAA,IACvB,SAAS,KAAK;AACZ,aAAO,OAAO,aAAa,aAAa,SAAS,GAAG,IAAI;AAAA,IAC1D;AAAA,EACF;AAAA,EACA,WAAW,CAAC,QAAgB,KAAK,UAAU,GAAG;AAChD;AAKO,MAAM,eAAe,CAAC,UAAgB;AAC3C,MAAI,OAAO,UAAU,UAAU;AAC7B,WAAO;AAAA,EACT;AAEA,SAAO,CAAC,CAAC,KAAK,UAAU,OAAO,KAAK;AACtC;AAKO,MAAM,kBAAkB,CAAC,UAAkB;AAEhD,SAAO,KAAK,UAAU,KAAK,UAAU,OAAO,KAAK,UAAU,OAAO,KAAK,CAAC,CAAC;AAC3E;AAGO,SAAS,uBAAuB,OAAe;AAEpD,QAAM,UAAU,MAAM,KAAK;AAC3B,MAAI,QAAQ,CAAC,MAAM,OAAO,QAAQ,CAAC,MAAM,KAAK;AAC5C,WAAO;AAAA,EACT;AAEA,MAAI;AAEF,WAAO,KAAK,UAAU,KAAK,MAAM,KAAK,GAAG,MAAM,CAAC;AAAA,EAClD,QAAQ;AAEN,WAAO;AAAA,EACT;AACF;AAGO,MAAM,kBAAkB,CAAC,UAAiD;AAC/E,MAAI,OAAO,UAAU,UAAU;AAC7B,WAAO;AAAA,EACT;AAEA,QAAM,aAAa,KAAK,UAAU,OAAO,IAAI;AAC7C,MAAI,YAAY;AACd,WAAO;AAAA,EACT;AAGA,MAAI,MAAM,SAAS,KAAK,CAAC,KAAK,GAAG,EAAE,SAAS,MAAM,CAAC,KAAK,EAAE,GAAG;AAC3D,UAAM,MAAM,sBAAsB;AAAA,EACpC;AAEA,SAAO,KAAK,UAAU,OAAO,CAAC,QAAQ;AACpC,UAAM,MAAM,GAAG;AAAA,EACjB,CAAC;AACH;",
6
- "names": []
7
- }
@@ -1,9 +0,0 @@
1
- /**
2
- * Takes JSON and formats it.
3
- */
4
- export declare const prettyPrintJson: (value: string | number | any[] | Record<any, any>) => string;
5
- /**
6
- * JSON.stringify, but with circular dependencies replaced with '[Circular]'
7
- */
8
- export declare function replaceCircularDependencies(content: any): string;
9
- //# sourceMappingURL=pretty-print-json.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"pretty-print-json.d.ts","sourceRoot":"","sources":["../../src/helpers/pretty-print-json.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,eAAO,MAAM,eAAe,GAAI,OAAO,MAAM,GAAG,MAAM,GAAG,GAAG,EAAE,GAAG,MAAM,CAAC,GAAG,EAAE,GAAG,CAAC,KAAG,MAqBnF,CAAA;AAED;;GAEG;AACH,wBAAgB,2BAA2B,CAAC,OAAO,EAAE,GAAG,UAiBvD"}
@@ -1,38 +0,0 @@
1
- import { isJsonString } from "./parse.js";
2
- const prettyPrintJson = (value) => {
3
- if (typeof value === "string") {
4
- if (isJsonString(value)) {
5
- return JSON.stringify(JSON.parse(value), null, 2);
6
- }
7
- return value;
8
- }
9
- if (typeof value === "object") {
10
- try {
11
- return JSON.stringify(value, null, 2);
12
- } catch {
13
- return replaceCircularDependencies(value);
14
- }
15
- }
16
- return value?.toString() ?? "";
17
- };
18
- function replaceCircularDependencies(content) {
19
- const cache = /* @__PURE__ */ new Set();
20
- return JSON.stringify(
21
- content,
22
- (_key, value) => {
23
- if (typeof value === "object" && value !== null) {
24
- if (cache.has(value)) {
25
- return "[Circular]";
26
- }
27
- cache.add(value);
28
- }
29
- return value;
30
- },
31
- 2
32
- );
33
- }
34
- export {
35
- prettyPrintJson,
36
- replaceCircularDependencies
37
- };
38
- //# sourceMappingURL=pretty-print-json.js.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../src/helpers/pretty-print-json.ts"],
4
- "sourcesContent": ["import { isJsonString } from './parse'\n\n/**\n * Takes JSON and formats it.\n */\nexport const prettyPrintJson = (value: string | number | any[] | Record<any, any>): string => {\n if (typeof value === 'string') {\n // JSON string\n if (isJsonString(value)) {\n return JSON.stringify(JSON.parse(value), null, 2)\n }\n\n // Regular string\n return value\n }\n\n // Object\n if (typeof value === 'object') {\n try {\n return JSON.stringify(value, null, 2)\n } catch {\n return replaceCircularDependencies(value)\n }\n }\n\n return value?.toString() ?? ''\n}\n\n/**\n * JSON.stringify, but with circular dependencies replaced with '[Circular]'\n */\nexport function replaceCircularDependencies(content: any) {\n const cache = new Set()\n\n return JSON.stringify(\n content,\n (_key, value) => {\n if (typeof value === 'object' && value !== null) {\n if (cache.has(value)) {\n return '[Circular]'\n }\n\n cache.add(value)\n }\n return value\n },\n 2,\n )\n}\n"],
5
- "mappings": "AAAA,SAAS,oBAAoB;AAKtB,MAAM,kBAAkB,CAAC,UAA8D;AAC5F,MAAI,OAAO,UAAU,UAAU;AAE7B,QAAI,aAAa,KAAK,GAAG;AACvB,aAAO,KAAK,UAAU,KAAK,MAAM,KAAK,GAAG,MAAM,CAAC;AAAA,IAClD;AAGA,WAAO;AAAA,EACT;AAGA,MAAI,OAAO,UAAU,UAAU;AAC7B,QAAI;AACF,aAAO,KAAK,UAAU,OAAO,MAAM,CAAC;AAAA,IACtC,QAAQ;AACN,aAAO,4BAA4B,KAAK;AAAA,IAC1C;AAAA,EACF;AAEA,SAAO,OAAO,SAAS,KAAK;AAC9B;AAKO,SAAS,4BAA4B,SAAc;AACxD,QAAM,QAAQ,oBAAI,IAAI;AAEtB,SAAO,KAAK;AAAA,IACV;AAAA,IACA,CAAC,MAAM,UAAU;AACf,UAAI,OAAO,UAAU,YAAY,UAAU,MAAM;AAC/C,YAAI,MAAM,IAAI,KAAK,GAAG;AACpB,iBAAO;AAAA,QACT;AAEA,cAAM,IAAI,KAAK;AAAA,MACjB;AACA,aAAO;AAAA,IACT;AAAA,IACA;AAAA,EACF;AACF;",
6
- "names": []
7
- }