@scalar/oas-utils 0.6.46 → 0.6.47

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,29 @@
1
1
  # @scalar/oas-utils
2
2
 
3
+ ## 0.6.47
4
+
5
+ ### Patch Changes
6
+
7
+ - [#8248](https://github.com/scalar/scalar/pull/8248): fix: local storage migration script
8
+ - [#8248](https://github.com/scalar/scalar/pull/8248): fix: remove unnecessary property truncation in example generation
9
+ - [#8248](https://github.com/scalar/scalar/pull/8248): chore: map themeId to slug and add default operation to drafts
10
+
11
+ #### Updated Dependencies
12
+
13
+ - **@scalar/workspace-store@0.34.3**
14
+ - [#8248](https://github.com/scalar/scalar/pull/8248): fix: local storage migration script
15
+ - [#8248](https://github.com/scalar/scalar/pull/8248): feat: nest description headings in the sidebar
16
+ - [#8248](https://github.com/scalar/scalar/pull/8248): chore: map themeId to slug and add default operation to drafts
17
+
18
+ - **@scalar/helpers@0.2.16**
19
+ - [#8248](https://github.com/scalar/scalar/pull/8248): fix: local storage migration script
20
+
21
+ - **@scalar/json-magic@0.11.5**
22
+
23
+ - **@scalar/object-utils@1.2.30**
24
+
25
+ - **@scalar/types@0.6.7**
26
+
3
27
  ## 0.6.46
4
28
 
5
29
  ### Patch Changes
@@ -1,5 +1,5 @@
1
1
  export { DATA_VERSION, DATA_VERSION_LS_LEY } from './data-version.js';
2
- export { clearLegacyLocalStorage, migrateLocalStorageToIndexDb, shouldMigrateToIndexDb, transformLegacyDataToWorkspace, } from './migrate-to-indexdb.js';
2
+ export { migrateLocalStorageToIndexDb, shouldMigrateToIndexDb, transformLegacyDataToWorkspace, } from './migrate-to-indexdb.js';
3
3
  export { migrator } from './migrator.js';
4
4
  export { semverLessThan } from './semver.js';
5
5
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/migrations/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAA;AAClE,OAAO,EACL,uBAAuB,EACvB,4BAA4B,EAC5B,sBAAsB,EACtB,8BAA8B,GAC/B,MAAM,sBAAsB,CAAA;AAC7B,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAA;AACrC,OAAO,EAAE,cAAc,EAAE,MAAM,UAAU,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/migrations/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAA;AAClE,OAAO,EACL,4BAA4B,EAC5B,sBAAsB,EACtB,8BAA8B,GAC/B,MAAM,sBAAsB,CAAA;AAC7B,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAA;AACrC,OAAO,EAAE,cAAc,EAAE,MAAM,UAAU,CAAA"}
@@ -1,6 +1,5 @@
1
1
  import { DATA_VERSION, DATA_VERSION_LS_LEY } from "./data-version.js";
2
2
  import {
3
- clearLegacyLocalStorage,
4
3
  migrateLocalStorageToIndexDb,
5
4
  shouldMigrateToIndexDb,
6
5
  transformLegacyDataToWorkspace
@@ -10,7 +9,6 @@ import { semverLessThan } from "./semver.js";
10
9
  export {
11
10
  DATA_VERSION,
12
11
  DATA_VERSION_LS_LEY,
13
- clearLegacyLocalStorage,
14
12
  migrateLocalStorageToIndexDb,
15
13
  migrator,
16
14
  semverLessThan,
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/migrations/index.ts"],
4
- "sourcesContent": ["export { DATA_VERSION, DATA_VERSION_LS_LEY } from './data-version'\nexport {\n clearLegacyLocalStorage,\n migrateLocalStorageToIndexDb,\n shouldMigrateToIndexDb,\n transformLegacyDataToWorkspace,\n} from './migrate-to-indexdb'\nexport { migrator } from './migrator'\nexport { semverLessThan } from './semver'\n"],
5
- "mappings": "AAAA,SAAS,cAAc,2BAA2B;AAClD;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,gBAAgB;AACzB,SAAS,sBAAsB;",
4
+ "sourcesContent": ["export { DATA_VERSION, DATA_VERSION_LS_LEY } from './data-version'\nexport {\n migrateLocalStorageToIndexDb,\n shouldMigrateToIndexDb,\n transformLegacyDataToWorkspace,\n} from './migrate-to-indexdb'\nexport { migrator } from './migrator'\nexport { semverLessThan } from './semver'\n"],
5
+ "mappings": "AAAA,SAAS,cAAc,2BAA2B;AAClD;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,gBAAgB;AACzB,SAAS,sBAAsB;",
6
6
  "names": []
7
7
  }
@@ -48,13 +48,4 @@ export declare const transformLegacyDataToWorkspace: (legacyData: {
48
48
  name: string;
49
49
  workspace: InMemoryWorkspace;
50
50
  }[]>;
51
- /**
52
- * Clears legacy localStorage data after successful migration.
53
- *
54
- * NOT called automatically - old data is preserved as a safety net for rollback.
55
- * Call only after migration succeeds and a grace period passes (e.g., 30 days).
56
- *
57
- * To rollback: clear IndexedDB and reload - migration will run again automatically.
58
- */
59
- export declare const clearLegacyLocalStorage: () => void;
60
51
  //# sourceMappingURL=migrate-to-indexdb.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"migrate-to-indexdb.d.ts","sourceRoot":"","sources":["../../src/migrations/migrate-to-indexdb.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,+BAA+B,EAAE,MAAM,qCAAqC,CAAA;AAOrF,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,oDAAoD,CAAA;AAmB3F,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,sCAAsC,CAAA;AAEnE;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,4BAA4B,qBA2CxC,CAAA;AAED;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,sBAAsB,GACjC,sBAAsB,OAAO,CAAC,UAAU,CAAC,OAAO,+BAA+B,CAAC,CAAC,CAAC,WAAW,CAAC,KAC7F,OAAO,CAAC,OAAO,CAiBjB,CAAA;AAED;;;;;;;;;;GAUG;AACH,eAAO,MAAM,8BAA8B,GAAU,YAAY;IAC/D,MAAM,EAAE,OAAO,CAAC,WAAW,CAAC,CAAA;IAC5B,OAAO,EAAE,OAAO,CAAC,YAAY,CAAC,CAAA;CAC/B;;;;IAyFE,CAAA;AA2nBH;;;;;;;GAOG;AACH,eAAO,MAAM,uBAAuB,QAAO,IAmB1C,CAAA"}
1
+ {"version":3,"file":"migrate-to-indexdb.d.ts","sourceRoot":"","sources":["../../src/migrations/migrate-to-indexdb.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,+BAA+B,EAAE,MAAM,qCAAqC,CAAA;AAOrF,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,oDAAoD,CAAA;AAoB3F,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,sCAAsC,CAAA;AAInE;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,4BAA4B,qBA2CxC,CAAA;AAED;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,sBAAsB,GACjC,sBAAsB,OAAO,CAAC,UAAU,CAAC,OAAO,+BAA+B,CAAC,CAAC,CAAC,WAAW,CAAC,KAC7F,OAAO,CAAC,OAAO,CAiBjB,CAAA;AAED;;;;;;;;;;GAUG;AACH,eAAO,MAAM,8BAA8B,GAAU,YAAY;IAC/D,MAAM,EAAE,OAAO,CAAC,WAAW,CAAC,CAAA;IAC5B,OAAO,EAAE,OAAO,CAAC,YAAY,CAAC,CAAA;CAC/B;;;;IAmIE,CAAA"}
@@ -2,6 +2,8 @@ import { CONTENT_TYPES } from "@scalar/helpers/consts/content-types";
2
2
  import { extractConfigSecrets, removeSecretFields } from "@scalar/helpers/general/extract-config-secrets";
3
3
  import { circularToRefs } from "@scalar/helpers/object/circular-to-refs";
4
4
  import { objectEntries } from "@scalar/helpers/object/object-entries";
5
+ import { extractServerFromPath } from "@scalar/helpers/url/extract-server-from-path";
6
+ import { presets } from "@scalar/themes";
5
7
  import { createWorkspaceStore } from "@scalar/workspace-store/client";
6
8
  import { AuthSchema } from "@scalar/workspace-store/entities/auth";
7
9
  import { createWorkspaceStorePersistence } from "@scalar/workspace-store/persistence";
@@ -14,8 +16,9 @@ import {
14
16
  OpenAPIDocumentSchema
15
17
  } from "@scalar/workspace-store/schemas/v3.1/strict/openapi-document";
16
18
  import { ColorModeSchema } from "@scalar/workspace-store/schemas/workspace";
17
- import { DATA_VERSION_LS_LEY } from "../migrations/data-version.js";
19
+ import GithubSlugger from "github-slugger";
18
20
  import { migrator } from "../migrations/migrator.js";
21
+ const DRAFTS_DOCUMENT_NAME = "drafts";
19
22
  const migrateLocalStorageToIndexDb = async () => {
20
23
  const { close, workspace: workspacePersistence } = await createWorkspaceStorePersistence();
21
24
  try {
@@ -61,16 +64,18 @@ const shouldMigrateToIndexDb = async (workspacePersistence) => {
61
64
  const transformLegacyDataToWorkspace = async (legacyData) => await Promise.all(
62
65
  legacyData.arrays.workspaces.map(async (workspace) => {
63
66
  const workspaceAuth = {};
67
+ const documentSlugger = new GithubSlugger();
64
68
  const documents = workspace.collections.flatMap((uid) => {
65
69
  const collection = legacyData.records.collections[uid];
66
70
  if (!collection) {
67
71
  return [];
68
72
  }
69
- const documentName = collection.info?.title || collection.uid;
73
+ const documentName = collection.info?.title || "api";
70
74
  const { document, auth } = transformCollectionToDocument(documentName, collection, legacyData.records);
71
75
  const normalizedName = documentName === "Drafts" ? "drafts" : documentName;
72
- workspaceAuth[normalizedName] = auth;
73
- return { name: normalizedName, document };
76
+ const uniqueName = documentSlugger.slug(normalizedName, false);
77
+ workspaceAuth[uniqueName] = auth;
78
+ return { name: uniqueName, document };
74
79
  });
75
80
  const meta = {};
76
81
  const extensions = {};
@@ -95,7 +100,7 @@ const transformLegacyDataToWorkspace = async (legacyData) => await Promise.all(
95
100
  meta["x-scalar-active-proxy"] = workspace.proxyUrl;
96
101
  }
97
102
  if (workspace.themeId) {
98
- meta["x-scalar-theme"] = workspace.themeId;
103
+ meta["x-scalar-theme"] = transformThemeIdToSlug(workspace.themeId);
99
104
  }
100
105
  if (localStorage.getItem("colorMode")) {
101
106
  meta["x-scalar-color-mode"] = coerceValue(ColorModeSchema, localStorage.getItem("colorMode"));
@@ -111,6 +116,32 @@ const transformLegacyDataToWorkspace = async (legacyData) => await Promise.all(
111
116
  });
112
117
  })
113
118
  );
119
+ if (!(DRAFTS_DOCUMENT_NAME in store.workspace.documents)) {
120
+ await store.addDocument({
121
+ name: DRAFTS_DOCUMENT_NAME,
122
+ document: {
123
+ openapi: "3.1.0",
124
+ info: {
125
+ title: "Drafts",
126
+ version: "1.0.0"
127
+ },
128
+ paths: {
129
+ "/": {
130
+ get: {}
131
+ }
132
+ },
133
+ "x-scalar-icon": "interface-edit-tool-pencil"
134
+ }
135
+ });
136
+ }
137
+ const drafts = store.workspace.documents[DRAFTS_DOCUMENT_NAME];
138
+ if (drafts) {
139
+ drafts.paths ??= {};
140
+ drafts.paths["/"] ??= {};
141
+ drafts.paths["/"]["get"] ??= {};
142
+ }
143
+ store.buildSidebar(DRAFTS_DOCUMENT_NAME);
144
+ await store.saveDocument(DRAFTS_DOCUMENT_NAME);
114
145
  store.auth.load(workspaceAuth);
115
146
  objectEntries(extensions).forEach(([key, value]) => {
116
147
  store.update(key, value);
@@ -123,6 +154,12 @@ const transformLegacyDataToWorkspace = async (legacyData) => await Promise.all(
123
154
  };
124
155
  })
125
156
  );
157
+ const transformThemeIdToSlug = (themeId) => {
158
+ if (themeId === "none") {
159
+ return themeId;
160
+ }
161
+ return presets[themeId]?.slug ?? "default";
162
+ };
126
163
  const transformLegacyEnvironments = (environments) => {
127
164
  const entries = Object.entries(environments || {});
128
165
  if (entries.length === 0) {
@@ -143,6 +180,7 @@ const transformLegacyEnvironments = (environments) => {
143
180
  };
144
181
  const transformRequestsToPaths = (collection, dataRecords) => {
145
182
  const paths = /* @__PURE__ */ Object.create(null);
183
+ const extractedServers = [];
146
184
  for (const requestUid of collection.requests || []) {
147
185
  const request = dataRecords.requests[requestUid];
148
186
  if (!request) {
@@ -161,8 +199,23 @@ const transformRequestsToPaths = (collection, dataRecords) => {
161
199
  requestBody,
162
200
  ...rest
163
201
  } = request;
164
- if (!paths[path]) {
165
- paths[path] = {};
202
+ let normalizedPath = path || "/";
203
+ const extractedServerUrl = extractServerFromPath(normalizedPath);
204
+ if (extractedServerUrl?.length === 2) {
205
+ const [serverUrl, remainingPath] = extractedServerUrl;
206
+ extractedServers.push({ url: serverUrl });
207
+ normalizedPath = remainingPath;
208
+ if (!normalizedPath) {
209
+ normalizedPath = "/";
210
+ } else if (normalizedPath.startsWith("//")) {
211
+ normalizedPath = normalizedPath.slice(1);
212
+ }
213
+ }
214
+ if (!normalizedPath.startsWith("/")) {
215
+ normalizedPath = `/${normalizedPath}`;
216
+ }
217
+ if (!paths[normalizedPath]) {
218
+ paths[normalizedPath] = {};
166
219
  }
167
220
  const partialOperation = {
168
221
  ...rest
@@ -189,9 +242,12 @@ const transformRequestsToPaths = (collection, dataRecords) => {
189
242
  return [rest2];
190
243
  });
191
244
  }
192
- paths[path][method] = partialOperation;
245
+ const pathItem = paths[normalizedPath];
246
+ if (pathItem) {
247
+ pathItem[method] = partialOperation;
248
+ }
193
249
  }
194
- return paths;
250
+ return { paths, extractedServers };
195
251
  };
196
252
  const PARAM_TYPE_TO_IN = {
197
253
  path: "path",
@@ -199,6 +255,16 @@ const PARAM_TYPE_TO_IN = {
199
255
  headers: "header",
200
256
  cookies: "cookie"
201
257
  };
258
+ const ensureUniqueExampleName = (baseName, usedNames) => {
259
+ let uniqueName = baseName;
260
+ let counter = 2;
261
+ while (usedNames.has(uniqueName)) {
262
+ uniqueName = `${baseName} #${counter}`;
263
+ counter++;
264
+ }
265
+ usedNames.add(uniqueName);
266
+ return uniqueName;
267
+ };
202
268
  const mergeExamplesIntoParameters = (parameters, requestExamples) => {
203
269
  const paramEntries = /* @__PURE__ */ new Map();
204
270
  for (const param of parameters) {
@@ -234,8 +300,10 @@ const mergeExamplesIntoParameters = (parameters, requestExamples) => {
234
300
  });
235
301
  }
236
302
  const paramTypes = Object.keys(PARAM_TYPE_TO_IN);
303
+ const usedExampleNames = /* @__PURE__ */ new Set();
237
304
  for (const requestExample of requestExamples) {
238
- const exampleName = requestExample.name || "Example";
305
+ const baseName = requestExample.name || "Example";
306
+ const exampleName = ensureUniqueExampleName(baseName, usedExampleNames);
239
307
  for (const paramType of paramTypes) {
240
308
  const inValue = PARAM_TYPE_TO_IN[paramType];
241
309
  const items = requestExample.parameters?.[paramType] || [];
@@ -315,12 +383,14 @@ const extractBodyExample = (body) => {
315
383
  const mergeExamplesIntoRequestBody = (requestBody, requestExamples) => {
316
384
  const groupedByContentType = /* @__PURE__ */ new Map();
317
385
  const selectedContentTypes = {};
386
+ const usedExampleNames = /* @__PURE__ */ new Set();
318
387
  for (const example of requestExamples) {
319
388
  const extracted = extractBodyExample(example.body);
320
389
  if (!extracted) {
321
390
  continue;
322
391
  }
323
- const name = example.name || "Example";
392
+ const baseName = example.name || "Example";
393
+ const name = ensureUniqueExampleName(baseName, usedExampleNames);
324
394
  const group = groupedByContentType.get(extracted.contentType);
325
395
  if (group) {
326
396
  group[name] = { value: extracted.value };
@@ -383,21 +453,31 @@ const transformLegacyTags = (collection, dataRecords) => {
383
453
  const transformCollectionToDocument = (documentName, collection, dataRecords) => {
384
454
  const selectedServerUrl = collection.selectedServerUid && dataRecords.servers[collection.selectedServerUid] ? dataRecords.servers[collection.selectedServerUid]?.url : void 0;
385
455
  const { tags, tagGroups } = transformLegacyTags(collection, dataRecords);
386
- const paths = transformRequestsToPaths(collection, dataRecords);
456
+ const { paths, extractedServers } = transformRequestsToPaths(collection, dataRecords);
457
+ const existingServers = collection.servers.flatMap((uid) => {
458
+ const server = dataRecords.servers[uid];
459
+ if (!server) {
460
+ return [];
461
+ }
462
+ const { uid: _, ...rest } = server;
463
+ return [rest];
464
+ });
465
+ const allServers = [...existingServers, ...extractedServers];
466
+ const seenUrls = /* @__PURE__ */ new Set();
467
+ const deduplicatedServers = allServers.filter((server) => {
468
+ if (seenUrls.has(server.url)) {
469
+ return false;
470
+ }
471
+ seenUrls.add(server.url);
472
+ return true;
473
+ });
387
474
  const document = {
388
475
  openapi: collection.openapi || "3.1.0",
389
476
  info: collection.info || {
390
477
  title: documentName,
391
478
  version: "1.0"
392
479
  },
393
- servers: collection.servers.flatMap((uid) => {
394
- const server = dataRecords.servers[uid];
395
- if (!server) {
396
- return [];
397
- }
398
- const { uid: _, ...rest } = server;
399
- return [rest];
400
- }),
480
+ servers: deduplicatedServers,
401
481
  paths,
402
482
  /**
403
483
  * Preserve all component types from the collection and merge with transformed security schemes.
@@ -450,7 +530,6 @@ const transformCollectionToDocument = (documentName, collection, dataRecords) =>
450
530
  tags,
451
531
  webhooks: collection.webhooks,
452
532
  externalDocs: collection.externalDocs,
453
- "x-scalar-original-document-hash": "",
454
533
  // Preserve scalar extensions
455
534
  "x-scalar-icon": collection["x-scalar-icon"],
456
535
  // Convert legacy record-based environment variables to the new array format
@@ -513,26 +592,7 @@ const transformCollectionToDocument = (documentName, collection, dataRecords) =>
513
592
  })
514
593
  };
515
594
  };
516
- const clearLegacyLocalStorage = () => {
517
- const keysToRemove = [
518
- "collection",
519
- "cookie",
520
- "environment",
521
- "requestExample",
522
- "request",
523
- "securityScheme",
524
- "server",
525
- "tag",
526
- "workspace",
527
- DATA_VERSION_LS_LEY
528
- ];
529
- keysToRemove.forEach((key) => {
530
- localStorage.removeItem(key);
531
- });
532
- console.info("\u{1F9F9} Cleared legacy localStorage data");
533
- };
534
595
  export {
535
- clearLegacyLocalStorage,
536
596
  migrateLocalStorageToIndexDb,
537
597
  shouldMigrateToIndexDb,
538
598
  transformLegacyDataToWorkspace
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/migrations/migrate-to-indexdb.ts"],
4
- "sourcesContent": ["import { CONTENT_TYPES } from '@scalar/helpers/consts/content-types'\nimport { extractConfigSecrets, removeSecretFields } from '@scalar/helpers/general/extract-config-secrets'\nimport { circularToRefs } from '@scalar/helpers/object/circular-to-refs'\nimport { objectEntries } from '@scalar/helpers/object/object-entries'\nimport type { Oauth2Flow } from '@scalar/types/entities'\nimport { createWorkspaceStore } from '@scalar/workspace-store/client'\nimport { type Auth, AuthSchema } from '@scalar/workspace-store/entities/auth'\nimport { createWorkspaceStorePersistence } from '@scalar/workspace-store/persistence'\nimport {\n type XScalarEnvironments,\n xScalarEnvironmentSchema,\n} from '@scalar/workspace-store/schemas/extensions/document/x-scalar-environments'\nimport { xScalarCookieSchema } from '@scalar/workspace-store/schemas/extensions/general/x-scalar-cookies'\nimport type { XTagGroup } from '@scalar/workspace-store/schemas/extensions/tag'\nimport type { InMemoryWorkspace } from '@scalar/workspace-store/schemas/inmemory-workspace'\nimport { coerceValue } from '@scalar/workspace-store/schemas/typebox-coerce'\nimport {\n OpenAPIDocumentSchema,\n type OpenApiDocument,\n type OperationObject,\n type ParameterObject,\n type ParameterWithContentObject,\n type ParameterWithSchemaObject,\n type PathItemObject,\n type RequestBodyObject,\n type TagObject,\n} from '@scalar/workspace-store/schemas/v3.1/strict/openapi-document'\nimport type { WorkspaceDocument, WorkspaceExtensions, WorkspaceMeta } from '@scalar/workspace-store/schemas/workspace'\nimport { ColorModeSchema } from '@scalar/workspace-store/schemas/workspace'\n\nimport type { RequestParameter } from '@/entities/spec/parameters'\nimport { DATA_VERSION_LS_LEY } from '@/migrations/data-version'\nimport { migrator } from '@/migrations/migrator'\nimport type { v_2_5_0 } from '@/migrations/v-2.5.0/types.generated'\n\n/**\n * Migrates localStorage data to IndexedDB workspace structure.\n *\n * Called early in app initialization (app-state.ts) before workspace data loads.\n * Idempotent and non-destructive - runs when legacy data exists but IndexedDB is empty.\n *\n * Flow:\n * 1. Check if migration needed (has legacy data + IndexedDB is empty)\n * 2. Run existing migrations to get latest data structure\n * 3. Transform to new workspace format\n * 4. Save to IndexedDB\n *\n * Old data is preserved for rollback. Typically completes in < 1 second.\n */\nexport const migrateLocalStorageToIndexDb = async () => {\n const { close, workspace: workspacePersistence } = await createWorkspaceStorePersistence()\n\n try {\n const shouldMigrate = await shouldMigrateToIndexDb(workspacePersistence)\n\n if (!shouldMigrate) {\n console.info('\u2139\uFE0F No migration needed - IndexedDB already has workspaces or no legacy data exists')\n return\n }\n\n console.info('\uD83D\uDE80 Starting migration from localStorage to IndexedDB...')\n\n // Step 1: Run existing migrations to get latest data structure\n const legacyData = migrator()\n\n console.info(\n `\uD83D\uDCE6 Found legacy data: ${legacyData.arrays.workspaces.length} workspace(s), ${legacyData.arrays.collections.length} collection(s)`,\n )\n\n // Step 2: Transform to new workspace structure\n const workspaces = await transformLegacyDataToWorkspace(legacyData)\n\n // Step 3: Save to IndexedDB\n await Promise.all(\n workspaces.map((workspace) =>\n workspacePersistence.setItem(\n { namespace: 'local', slug: workspace.slug },\n {\n name: workspace.name,\n workspace: workspace.workspace,\n teamUid: 'local',\n },\n ),\n ),\n )\n\n console.info(`\u2705 Successfully migrated ${workspaces.length} workspace(s) to IndexedDB`)\n } catch (error) {\n console.error('\u274C Migration failed:', error)\n } finally {\n close()\n }\n}\n\n/**\n * Checks if migration is needed by verifying IndexedDB state and presence of legacy data.\n *\n * Migration is needed when:\n * 1. Legacy data exists in localStorage (workspace, collection, or request keys)\n * 2. AND IndexedDB has no workspaces yet\n *\n * This approach is more reliable than using a flag because:\n * - If IndexedDB is cleared, migration will run again automatically\n * - No risk of flag getting out of sync with actual data state\n * - Handles edge cases like partial migrations or database corruption\n */\nexport const shouldMigrateToIndexDb = async (\n workspacePersistence: Awaited<ReturnType<typeof createWorkspaceStorePersistence>>['workspace'],\n): Promise<boolean> => {\n // Check if there is any old data in localStorage\n const hasLegacyData =\n localStorage.getItem('workspace') !== null ||\n localStorage.getItem('collection') !== null ||\n localStorage.getItem('request') !== null\n\n if (!hasLegacyData) {\n return false\n }\n\n // Check if IndexedDB already has workspaces\n const existingWorkspaces = await workspacePersistence.getAll()\n const hasIndexDbData = existingWorkspaces.length > 0\n\n // Only migrate if we have legacy data but no IndexedDB data\n return !hasIndexDbData\n}\n\n/**\n * Transforms legacy localStorage data into IndexedDB workspace structure.\n *\n * Transformations:\n * - Collections \u2192 Documents (collections were OpenAPI specs)\n * - Environments \u2192 x-scalar-environments in meta\n * - Cookies \u2192 x-scalar-cookies in meta\n * - Workspace properties \u2192 meta extensions (activeEnvironmentId, proxyUrl, themeId)\n *\n * Creates a default workspace if none exist. Falls back to collection uid if info.title is missing.\n */\nexport const transformLegacyDataToWorkspace = async (legacyData: {\n arrays: v_2_5_0['DataArray']\n records: v_2_5_0['DataRecord']\n}) =>\n await Promise.all(\n legacyData.arrays.workspaces.map(async (workspace) => {\n /** Grab auth from the collections */\n const workspaceAuth: InMemoryWorkspace['auth'] = {}\n\n /** Each collection becomes a document in the new system and grab the auth as well */\n const documents: { name: string; document: OpenApiDocument }[] = workspace.collections.flatMap((uid) => {\n const collection = legacyData.records.collections[uid]\n if (!collection) {\n return []\n }\n\n const documentName = collection.info?.title || collection.uid\n const { document, auth } = transformCollectionToDocument(documentName, collection, legacyData.records)\n\n // Normalize document name to match the store (lowercase \"Drafts\" \u2192 \"drafts\")\n const normalizedName = documentName === 'Drafts' ? 'drafts' : documentName\n workspaceAuth[normalizedName] = auth\n\n return { name: normalizedName, document }\n })\n\n const meta: WorkspaceMeta = {}\n const extensions: WorkspaceExtensions = {}\n\n // Add environment\n const environmentEntries = Object.entries(workspace.environments)\n if (environmentEntries.length > 0) {\n extensions['x-scalar-environments'] = {\n default: coerceValue(xScalarEnvironmentSchema, {\n variables: environmentEntries.map(([name, value]) => ({\n name,\n value,\n })),\n }),\n }\n }\n\n // Add cookies to meta\n if (workspace.cookies.length > 0) {\n extensions['x-scalar-cookies'] = workspace.cookies.flatMap((uid) => {\n const cookie = legacyData.records.cookies[uid]\n return cookie ? coerceValue(xScalarCookieSchema, cookie) : []\n })\n }\n\n // Add proxy URL if present\n if (workspace.proxyUrl) {\n meta['x-scalar-active-proxy'] = workspace.proxyUrl\n }\n\n // Add theme if present\n if (workspace.themeId) {\n meta['x-scalar-theme'] = workspace.themeId\n }\n\n // Set color mode\n if (localStorage.getItem('colorMode')) {\n meta['x-scalar-color-mode'] = coerceValue(ColorModeSchema, localStorage.getItem('colorMode'))\n }\n\n const store = createWorkspaceStore({\n meta,\n })\n\n await Promise.all(\n documents.map(async ({ name, document }) => {\n await store.addDocument({\n name,\n document,\n })\n }),\n )\n\n // Load the auth into the store\n store.auth.load(workspaceAuth)\n\n // Load the extensions into the store\n objectEntries(extensions).forEach(([key, value]) => {\n store.update(key, value)\n })\n\n return {\n slug: workspace.uid.toString(), // Convert to string to convert it to a simple string type\n name: workspace.name || 'Untitled Workspace',\n workspace: store.exportWorkspace(),\n }\n }),\n )\n\n/**\n * Converts legacy environment variables from record format to the new array format.\n *\n * Legacy format: { variables: { API_URL: 'https://...', API_KEY: 'secret' } }\n * New format: { variables: [{ name: 'API_URL', value: 'https://...' }, { name: 'API_KEY', value: 'secret' }] }\n */\nconst transformLegacyEnvironments = (\n environments: v_2_5_0['Collection']['x-scalar-environments'],\n): XScalarEnvironments | undefined => {\n const entries = Object.entries(environments || {})\n if (entries.length === 0) {\n return undefined\n }\n\n return Object.fromEntries(\n entries.map(([envName, env]) => [\n envName,\n coerceValue(xScalarEnvironmentSchema, {\n color: env.color,\n variables: Object.entries(env.variables || {}).map(([name, value]) => ({\n name,\n value: typeof value === 'string' ? value : value.default || '',\n })),\n }),\n ]),\n )\n}\n\n/**\n * Transforms legacy requests and request examples into OpenAPI paths.\n *\n * Each request becomes an operation in the paths object.\n * Request examples are merged into parameter examples and request body examples.\n */\nconst transformRequestsToPaths = (\n collection: v_2_5_0['Collection'],\n dataRecords: v_2_5_0['DataRecord'],\n): Record<string, PathItemObject> => {\n const paths = Object.create(null) as Record<string, PathItemObject>\n\n for (const requestUid of collection.requests || []) {\n const request = dataRecords.requests[requestUid]\n if (!request) {\n continue\n }\n\n const {\n path,\n method,\n uid: _uid,\n type: _type,\n selectedServerUid: _selectedServerUid,\n examples,\n servers,\n selectedSecuritySchemeUids: _selectedSecuritySchemeUids,\n parameters = [],\n requestBody,\n ...rest\n } = request\n\n // Initialize path object if it doesn't exist\n if (!paths[path]) {\n paths[path] = {}\n }\n\n /** Start building the OAS operation object */\n const partialOperation: OperationObject = {\n ...rest,\n }\n\n // Get request examples for this request\n const requestExamples = (examples || []).flatMap((exampleUid) => {\n const example = dataRecords.requestExamples[exampleUid]\n return example ? [example] : []\n })\n\n // Merge examples into parameters\n const mergedParameters = mergeExamplesIntoParameters(parameters, requestExamples)\n if (mergedParameters.length > 0) {\n partialOperation.parameters = mergedParameters\n }\n\n // Merge examples into request body\n const mergedRequestBody = mergeExamplesIntoRequestBody(requestBody, requestExamples)\n if (mergedRequestBody) {\n partialOperation.requestBody = mergedRequestBody\n }\n\n // Add server overrides if present\n if (servers && servers.length > 0) {\n partialOperation.servers = servers.flatMap((serverUid) => {\n const server = dataRecords.servers[serverUid]\n if (!server) {\n return []\n }\n const { uid: _, ...rest } = server\n return [rest]\n })\n }\n\n paths[path][method] = partialOperation\n }\n\n return paths\n}\n\n/**\n * The legacy data model uses plural \"headers\"/\"cookies\" for parameter categories,\n * but OpenAPI uses singular \"header\"/\"cookie\" for the `in` field. This mapping\n * normalizes the legacy names to their OpenAPI equivalents.\n */\nconst PARAM_TYPE_TO_IN: Record<string, string> = {\n path: 'path',\n query: 'query',\n headers: 'header',\n cookies: 'cookie',\n}\n\n/**\n * Merges request example values into OpenAPI parameter objects.\n *\n * In the legacy data model, parameter values live on individual RequestExample\n * objects (one per \"example\" tab in the UI). OpenAPI instead stores examples\n * directly on each Parameter object via the `examples` map.\n */\nconst mergeExamplesIntoParameters = (\n parameters: RequestParameter[],\n requestExamples: v_2_5_0['RequestExample'][],\n): ParameterObject[] => {\n /**\n * We track parameters and their collected examples together in a single map\n * keyed by `{in}:{name}` (e.g. \"query:page\") to avoid a second lookup pass.\n */\n const paramEntries = new Map<\n string,\n { param: ParameterObject; examples: Record<string, { value: string; 'x-disabled': boolean }> }\n >()\n\n // Seed with the operation's existing parameters so they are preserved even if\n // no request example references them.\n for (const param of parameters) {\n // Build a type-safe ParameterObject by explicitly mapping properties\n // The old RequestParameter type uses z.unknown() for schema/content/examples,\n // but these values come from validated OpenAPI documents and are already in the correct format.\n // We use type assertions (via unknown) to bridge from the old loose types to the new strict types.\n // This is safe because the data has already been validated by the Zod schema.\n\n // Build either ParameterWithSchemaObject or ParameterWithContentObject\n let paramObject: ParameterObject\n\n // Param with Content Type\n if (param.content && typeof param.content === 'object') {\n paramObject = {\n name: param.name,\n in: param.in,\n required: param.required ?? param.in === 'path',\n deprecated: param.deprecated ?? false,\n content: param.content as ParameterWithContentObject['content'],\n ...(param.description && { description: param.description }),\n } satisfies ParameterWithContentObject\n }\n\n // Param with Schema Type\n else {\n paramObject = {\n name: param.name,\n in: param.in,\n required: param.required ?? param.in === 'path',\n deprecated: param.deprecated ?? false,\n ...(param.description && { description: param.description }),\n ...(param.schema ? { schema: param.schema as ParameterWithSchemaObject['schema'] } : {}),\n ...(param.style && { style: param.style }),\n ...(param.explode !== undefined && { explode: param.explode }),\n ...(param.example !== undefined && { example: param.example }),\n ...(param.examples &&\n typeof param.examples === 'object' && {\n examples: param.examples as ParameterWithSchemaObject['examples'],\n }),\n } satisfies ParameterWithSchemaObject\n }\n\n paramEntries.set(`${param.in}:${param.name}`, {\n param: paramObject,\n examples: {},\n })\n }\n\n const paramTypes = Object.keys(PARAM_TYPE_TO_IN)\n\n for (const requestExample of requestExamples) {\n const exampleName = requestExample.name || 'Example'\n\n for (const paramType of paramTypes) {\n const inValue = PARAM_TYPE_TO_IN[paramType]\n const items = requestExample.parameters?.[paramType as keyof typeof requestExample.parameters] || []\n\n for (const item of items) {\n const key = `${inValue}:${item.key}`\n\n // Lets not save any params without a key\n if (!item.key) {\n continue\n }\n\n const lowerKey = item.key.toLowerCase()\n\n /**\n * Lazily create a parameter stub when one does not already exist\n * Path parameters are always required per the OpenAPI spec\n *\n * We do not add Accept: *\\/*\n * We do not add any Content-Type headers that are auto added in the client\n */\n if (\n !paramEntries.has(key) &&\n (lowerKey !== 'content-type' || !CONTENT_TYPES[item.value as keyof typeof CONTENT_TYPES]) &&\n (lowerKey !== 'accept' || item.value !== '*/*')\n ) {\n paramEntries.set(key, {\n param: {\n name: item.key,\n in: (inValue as ParameterObject['in']) ?? 'query',\n required: inValue === 'path',\n deprecated: false,\n schema: { type: 'string' },\n },\n examples: {},\n })\n }\n\n // We have skipped the content-type or accept headers above\n const param = paramEntries.get(key)\n if (!param) {\n continue\n }\n\n param.examples[exampleName] = {\n value: item.value,\n 'x-disabled': !item.enabled,\n }\n }\n }\n }\n\n // Build the final parameter list, only attaching `examples` when there are any\n return Array.from(paramEntries.values()).map(({ param, examples }) => {\n if (Object.keys(examples).length > 0) {\n ;(param as ParameterWithSchemaObject).examples = examples\n }\n return param\n })\n}\n\n/** Maps legacy raw body encoding names (e.g. \"json\", \"xml\") to their corresponding MIME content types */\nconst RAW_ENCODING_TO_CONTENT_TYPE: Record<string, string> = {\n json: 'application/json',\n xml: 'application/xml',\n yaml: 'application/yaml',\n edn: 'application/edn',\n text: 'text/plain',\n html: 'text/html',\n javascript: 'application/javascript',\n}\n\n/**\n * Extracts the content type and example value from a single request example body.\n *\n * The legacy data model stored body content in one of three shapes:\n * - `raw` \u2014 text-based body with an encoding hint (json, xml, etc.)\n * - `formData` \u2014 key/value pairs with either multipart or URL-encoded encoding\n * - `binary` \u2014 file upload with no inline content\n */\nconst extractBodyExample = (\n body: v_2_5_0['RequestExample']['body'],\n): { contentType: string; value: unknown } | undefined => {\n if (!body?.activeBody) {\n return undefined\n }\n\n // Raw text body \u2014 resolve the short encoding name to a full MIME type\n if (body.activeBody === 'raw' && body.raw) {\n return {\n contentType: RAW_ENCODING_TO_CONTENT_TYPE[body.raw.encoding] || 'text/plain',\n value: body.raw.value,\n }\n }\n\n // Form data \u2014 distinguish between multipart (file uploads) and URL-encoded\n if (body.activeBody === 'formData' && body.formData) {\n return {\n contentType: body.formData.encoding === 'form-data' ? 'multipart/form-data' : 'application/x-www-form-urlencoded',\n value: body.formData.value.flatMap((param) =>\n param.key\n ? {\n name: param.key,\n value: param.value,\n isDisabled: !param.enabled,\n }\n : [],\n ),\n }\n }\n\n // Binary uploads have no inline content to migrate\n if (body.activeBody === 'binary') {\n return { contentType: 'binary', value: {} }\n }\n\n return undefined\n}\n\n/**\n * Merges request examples into request body examples.\n *\n * The v2.5.0 data model stored request examples separately from the\n * operation's requestBody. In the new model, examples live directly inside\n * `requestBody.content[contentType].examples`. This function bridges the two\n * by grouping examples by content type in a single pass and writing them into\n * the requestBody structure.\n *\n * Returns the original requestBody unchanged when no examples have body content.\n */\nconst mergeExamplesIntoRequestBody = (\n requestBody: RequestBodyObject,\n requestExamples: v_2_5_0['RequestExample'][],\n): RequestBodyObject => {\n /**\n * Single pass: extract each example body and bucket it by content type.\n * Using a plain object as the inner value (instead of a nested Map) avoids\n * a second conversion step when assigning to the result.\n */\n const groupedByContentType = new Map<string, Record<string, { value: unknown }>>()\n\n /** We track the selected content type for each example */\n const selectedContentTypes = {} as Record<string, string>\n\n for (const example of requestExamples) {\n const extracted = extractBodyExample(example.body)\n if (!extracted) {\n continue\n }\n\n const name = example.name || 'Example'\n const group = groupedByContentType.get(extracted.contentType)\n\n if (group) {\n group[name] = { value: extracted.value }\n } else {\n groupedByContentType.set(extracted.contentType, { [name]: { value: extracted.value } })\n }\n\n selectedContentTypes[name] = extracted.contentType\n }\n\n // Nothing to merge \u2014 return early so we do not mutate the requestBody\n if (groupedByContentType.size === 0) {\n return requestBody\n }\n\n // Ensure the requestBody and its content map exist before writing\n const result = requestBody ?? {}\n result.content ??= {}\n\n for (const [contentType, examples] of groupedByContentType) {\n result.content[contentType] ??= {}\n result.content[contentType].examples = examples\n }\n\n // Add the x-scalar-selected-content-type mapping\n if (Object.keys(selectedContentTypes).length > 0) {\n result['x-scalar-selected-content-type'] = selectedContentTypes\n }\n\n return result\n}\n\n/**\n * Transforms legacy tags into OpenAPI tags and tag groups.\n *\n * Legacy structure:\n * - Tags can have children (nested tags)\n * - Top-level parent tags become tag groups\n * - Child tags and standalone tags become regular tags\n */\nconst transformLegacyTags = (\n collection: v_2_5_0['Collection'],\n dataRecords: v_2_5_0['DataRecord'],\n): { tags: TagObject[]; tagGroups: Array<{ name: string; tags: string[] }> } => {\n const tags: TagObject[] = []\n const tagGroups: XTagGroup[] = []\n\n /**\n * Identifies which tags are top-level (appear in collection.children).\n * Top-level parent tags become tag groups, others become regular tags.\n */\n const topLevelTagUids = new Set(collection.children.filter((uid) => dataRecords.tags[uid] !== undefined))\n\n /**\n * Identifies which tags have children.\n * Only top-level parent tags become tag groups.\n */\n const parentTagUids = new Set(\n collection.tags.filter((uid) => {\n const tag = dataRecords.tags[uid]\n return tag?.children && tag.children.length > 0\n }),\n )\n\n /**\n * Process each tag to create either a tag group or a regular tag.\n */\n for (const tagUid of collection.tags) {\n const tag = dataRecords.tags[tagUid]\n if (!tag) {\n continue\n }\n\n const isTopLevelParent = topLevelTagUids.has(tagUid) && parentTagUids.has(tagUid)\n\n if (isTopLevelParent) {\n /**\n * Top-level parent tags become tag groups.\n * Resolve child tag names, filtering out any missing children.\n */\n const childTagNames = tag.children\n .map((childUid) => dataRecords.tags[childUid]?.name)\n .filter((name): name is string => name !== undefined)\n\n if (childTagNames.length > 0) {\n tagGroups.push({\n name: tag.name,\n tags: childTagNames,\n })\n }\n } else {\n /**\n * All other tags (child tags and standalone tags) become regular tags.\n * Preserve optional fields from the legacy tag.\n */\n const tagObject: TagObject = { name: tag.name }\n\n if (tag.description) {\n tagObject.description = tag.description\n }\n if (tag.externalDocs) {\n tagObject.externalDocs = tag.externalDocs\n }\n\n tags.push(tagObject)\n }\n }\n\n return { tags, tagGroups }\n}\n\n/** Transforms a collection and everything it includes into a WorkspaceDocument + auth */\nconst transformCollectionToDocument = (\n documentName: string,\n collection: v_2_5_0['Collection'],\n dataRecords: v_2_5_0['DataRecord'],\n): { document: WorkspaceDocument; auth: Auth } => {\n // Resolve selectedServerUid \u2192 server URL for x-scalar-selected-server\n const selectedServerUrl =\n collection.selectedServerUid && dataRecords.servers[collection.selectedServerUid]\n ? dataRecords.servers[collection.selectedServerUid]?.url\n : undefined\n\n // Transform tags: separate parent tags (groups) from child tags\n const { tags, tagGroups } = transformLegacyTags(collection, dataRecords)\n\n // Transform requests into paths\n const paths = transformRequestsToPaths(collection, dataRecords)\n\n const document: Record<string, unknown> = {\n openapi: collection.openapi || '3.1.0',\n info: collection.info || {\n title: documentName,\n version: '1.0',\n },\n servers: collection.servers.flatMap((uid) => {\n const server = dataRecords.servers[uid]\n if (!server) {\n return []\n }\n\n const { uid: _, ...rest } = server\n return [rest]\n }),\n paths,\n /**\n * Preserve all component types from the collection and merge with transformed security schemes.\n * OpenAPI components object supports: schemas, responses, parameters, examples,\n * requestBodies, headers, securitySchemes, links, callbacks, pathItems\n */\n components: {\n // Preserve existing components from the collection (schemas, responses, parameters, etc.)\n ...(collection.components || {}),\n // Merge security schemes (transformed from UIDs) with any existing security schemes\n securitySchemes: {\n ...((collection.components as Record<string, unknown>)?.securitySchemes || {}),\n ...collection.securitySchemes.reduce((acc, uid) => {\n const securityScheme = dataRecords.securitySchemes[uid]\n if (!securityScheme) {\n return acc\n }\n\n const { uid: _uid, nameKey: _nameKey, ...publicSecurityScheme } = removeSecretFields(securityScheme)\n\n // Clean the flows\n if (securityScheme.type === 'oauth2') {\n const selectedScopes = new Set<string>()\n\n return {\n ...acc,\n [securityScheme.nameKey]: {\n ...publicSecurityScheme,\n flows: objectEntries(securityScheme.flows).reduce(\n (acc, [key, flow]) => {\n if (!flow) {\n return acc\n }\n\n // Store any selected scopes from the config\n if ('selectedScopes' in flow && Array.isArray(flow.selectedScopes)) {\n flow.selectedScopes?.forEach((scope) => selectedScopes.add(scope))\n }\n\n acc[key] = removeSecretFields(flow) as Oauth2Flow\n return acc\n },\n {} as Record<string, Oauth2Flow>,\n ),\n 'x-default-scopes': Array.from(selectedScopes),\n },\n }\n }\n\n return {\n ...acc,\n [securityScheme.nameKey]: publicSecurityScheme,\n }\n }, {}),\n },\n },\n security: collection.security || [],\n tags,\n webhooks: collection.webhooks,\n externalDocs: collection.externalDocs,\n 'x-scalar-original-document-hash': '',\n\n // Preserve scalar extensions\n 'x-scalar-icon': collection['x-scalar-icon'],\n\n // Convert legacy record-based environment variables to the new array format\n 'x-scalar-environments': transformLegacyEnvironments(collection['x-scalar-environments']),\n\n // useCollectionSecurity \u2192 x-scalar-set-operation-security\n 'x-scalar-set-operation-security': collection.useCollectionSecurity ?? false,\n }\n\n // Add x-tagGroups if there are any parent tags\n if (tagGroups.length > 0) {\n document['x-tagGroups'] = tagGroups\n }\n\n // x-scalar-active-environment \u2192 x-scalar-client-config-active-environment\n if (collection['x-scalar-active-environment']) {\n document['x-scalar-client-config-active-environment'] = collection['x-scalar-active-environment']\n }\n\n // selectedServerUid \u2192 x-scalar-selected-server (resolved to URL)\n if (selectedServerUrl) {\n document['x-scalar-selected-server'] = selectedServerUrl\n }\n\n // documentUrl \u2192 x-scalar-original-source-url\n if (collection.documentUrl) {\n document['x-scalar-original-source-url'] = collection.documentUrl\n }\n\n // Break any circular JS object references before coercion.\n // The legacy client dereferenced $refs inline, creating circular object graphs\n // that would cause JSON serialization and schema validation to fail.\n const safeDocument = circularToRefs(document, {\n '$ref-value': '',\n '$global': false,\n 'summary': 'This ref was re-created from a circular schema reference',\n })\n\n return {\n document: coerceValue(OpenAPIDocumentSchema, safeDocument),\n auth: coerceValue(AuthSchema, {\n secrets: collection.securitySchemes.reduce((acc, uid) => {\n const securityScheme = dataRecords.securitySchemes[uid]\n if (!securityScheme) {\n return acc\n }\n\n // Oauth 2\n if (securityScheme.type === 'oauth2') {\n return {\n ...acc,\n [securityScheme.nameKey]: {\n type: securityScheme.type,\n ...objectEntries(securityScheme.flows).reduce(\n (acc, [key, flow]) => {\n if (!flow) {\n return acc\n }\n\n acc[key] = extractConfigSecrets(flow)\n return acc\n },\n {} as Record<string, Record<string, string>>,\n ),\n },\n }\n }\n\n // The rest\n return {\n ...acc,\n [securityScheme.nameKey]: {\n type: securityScheme.type,\n ...extractConfigSecrets(securityScheme),\n },\n }\n }, {}),\n selected: {},\n }),\n }\n}\n\n/**\n * Clears legacy localStorage data after successful migration.\n *\n * NOT called automatically - old data is preserved as a safety net for rollback.\n * Call only after migration succeeds and a grace period passes (e.g., 30 days).\n *\n * To rollback: clear IndexedDB and reload - migration will run again automatically.\n */\nexport const clearLegacyLocalStorage = (): void => {\n const keysToRemove = [\n 'collection',\n 'cookie',\n 'environment',\n 'requestExample',\n 'request',\n 'securityScheme',\n 'server',\n 'tag',\n 'workspace',\n DATA_VERSION_LS_LEY,\n ]\n\n keysToRemove.forEach((key) => {\n localStorage.removeItem(key)\n })\n\n console.info('\uD83E\uDDF9 Cleared legacy localStorage data')\n}\n"],
5
- "mappings": "AAAA,SAAS,qBAAqB;AAC9B,SAAS,sBAAsB,0BAA0B;AACzD,SAAS,sBAAsB;AAC/B,SAAS,qBAAqB;AAE9B,SAAS,4BAA4B;AACrC,SAAoB,kBAAkB;AACtC,SAAS,uCAAuC;AAChD;AAAA,EAEE;AAAA,OACK;AACP,SAAS,2BAA2B;AAGpC,SAAS,mBAAmB;AAC5B;AAAA,EACE;AAAA,OASK;AAEP,SAAS,uBAAuB;AAGhC,SAAS,2BAA2B;AACpC,SAAS,gBAAgB;AAiBlB,MAAM,+BAA+B,YAAY;AACtD,QAAM,EAAE,OAAO,WAAW,qBAAqB,IAAI,MAAM,gCAAgC;AAEzF,MAAI;AACF,UAAM,gBAAgB,MAAM,uBAAuB,oBAAoB;AAEvE,QAAI,CAAC,eAAe;AAClB,cAAQ,KAAK,+FAAqF;AAClG;AAAA,IACF;AAEA,YAAQ,KAAK,gEAAyD;AAGtE,UAAM,aAAa,SAAS;AAE5B,YAAQ;AAAA,MACN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AEA,kBAAAA,KAAI,GAAG,IAAI,qBAAqB,IAAI;AACpC,yBAAOA;AAAA,gBACT;AAAA,gBACA,CAAC;AAAA,cACH;AAAA,YACF;AAAA,UACF;AAAA,QACF;AAGA,eAAO;AAAA,UACL,GAAG;AAAA,UACH,CAAC,eAAe,OAAO,GAAG;AAAA,YACxB,MAAM,eAAe;AAAA,YACrB,GAAG,qBAAqB,cAAc;AAAA,UACxC;AAAA,QACF;AAAA,MACF,GAAG,CAAC,CAAC;AAAA,MACL,UAAU,CAAC;AAAA,IACb,CAAC;AAAA,EACH;AACF;AAUO,MAAM,0BAA0B,MAAY;AACjD,QAAM,eAAe;AAAA,IACnB;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF;AAEA,eAAa,QAAQ,CAAC,QAAQ;AAC5B,iBAAa,WAAW,GAAG;AAAA,EAC7B,CAAC;AAED,UAAQ,KAAK,4CAAqC;AACpD;",
4
+ "sourcesContent": ["import { CONTENT_TYPES } from '@scalar/helpers/consts/content-types'\nimport { extractConfigSecrets, removeSecretFields } from '@scalar/helpers/general/extract-config-secrets'\nimport { circularToRefs } from '@scalar/helpers/object/circular-to-refs'\nimport { objectEntries } from '@scalar/helpers/object/object-entries'\nimport { extractServerFromPath } from '@scalar/helpers/url/extract-server-from-path'\nimport { type ThemeId, presets } from '@scalar/themes'\nimport type { Oauth2Flow } from '@scalar/types/entities'\nimport { createWorkspaceStore } from '@scalar/workspace-store/client'\nimport { type Auth, AuthSchema } from '@scalar/workspace-store/entities/auth'\nimport { createWorkspaceStorePersistence } from '@scalar/workspace-store/persistence'\nimport {\n type XScalarEnvironments,\n xScalarEnvironmentSchema,\n} from '@scalar/workspace-store/schemas/extensions/document/x-scalar-environments'\nimport { xScalarCookieSchema } from '@scalar/workspace-store/schemas/extensions/general/x-scalar-cookies'\nimport type { XTagGroup } from '@scalar/workspace-store/schemas/extensions/tag'\nimport type { InMemoryWorkspace } from '@scalar/workspace-store/schemas/inmemory-workspace'\nimport { coerceValue } from '@scalar/workspace-store/schemas/typebox-coerce'\nimport {\n OpenAPIDocumentSchema,\n type OpenApiDocument,\n type OperationObject,\n type ParameterObject,\n type ParameterWithContentObject,\n type ParameterWithSchemaObject,\n type PathItemObject,\n type RequestBodyObject,\n type ServerObject,\n type TagObject,\n} from '@scalar/workspace-store/schemas/v3.1/strict/openapi-document'\nimport type { WorkspaceDocument, WorkspaceExtensions, WorkspaceMeta } from '@scalar/workspace-store/schemas/workspace'\nimport { ColorModeSchema } from '@scalar/workspace-store/schemas/workspace'\nimport GithubSlugger from 'github-slugger'\n\nimport type { RequestParameter } from '@/entities/spec/parameters'\nimport { migrator } from '@/migrations/migrator'\nimport type { v_2_5_0 } from '@/migrations/v-2.5.0/types.generated'\n\nconst DRAFTS_DOCUMENT_NAME = 'drafts'\n\n/**\n * Migrates localStorage data to IndexedDB workspace structure.\n *\n * Called early in app initialization (app-state.ts) before workspace data loads.\n * Idempotent and non-destructive - runs when legacy data exists but IndexedDB is empty.\n *\n * Flow:\n * 1. Check if migration needed (has legacy data + IndexedDB is empty)\n * 2. Run existing migrations to get latest data structure\n * 3. Transform to new workspace format\n * 4. Save to IndexedDB\n *\n * Old data is preserved for rollback. Typically completes in < 1 second.\n */\nexport const migrateLocalStorageToIndexDb = async () => {\n const { close, workspace: workspacePersistence } = await createWorkspaceStorePersistence()\n\n try {\n const shouldMigrate = await shouldMigrateToIndexDb(workspacePersistence)\n\n if (!shouldMigrate) {\n console.info('\u2139\uFE0F No migration needed - IndexedDB already has workspaces or no legacy data exists')\n return\n }\n\n console.info('\uD83D\uDE80 Starting migration from localStorage to IndexedDB...')\n\n // Step 1: Run existing migrations to get latest data structure\n const legacyData = migrator()\n\n console.info(\n `\uD83D\uDCE6 Found legacy data: ${legacyData.arrays.workspaces.length} workspace(s), ${legacyData.arrays.collections.length} collection(s)`,\n )\n\n // Step 2: Transform to new workspace structure\n const workspaces = await transformLegacyDataToWorkspace(legacyData)\n\n // Step 3: Save to IndexedDB\n await Promise.all(\n workspaces.map((workspace) =>\n workspacePersistence.setItem(\n { namespace: 'local', slug: workspace.slug },\n {\n name: workspace.name,\n workspace: workspace.workspace,\n teamUid: 'local',\n },\n ),\n ),\n )\n\n console.info(`\u2705 Successfully migrated ${workspaces.length} workspace(s) to IndexedDB`)\n } catch (error) {\n console.error('\u274C Migration failed:', error)\n } finally {\n close()\n }\n}\n\n/**\n * Checks if migration is needed by verifying IndexedDB state and presence of legacy data.\n *\n * Migration is needed when:\n * 1. Legacy data exists in localStorage (workspace, collection, or request keys)\n * 2. AND IndexedDB has no workspaces yet\n *\n * This approach is more reliable than using a flag because:\n * - If IndexedDB is cleared, migration will run again automatically\n * - No risk of flag getting out of sync with actual data state\n * - Handles edge cases like partial migrations or database corruption\n */\nexport const shouldMigrateToIndexDb = async (\n workspacePersistence: Awaited<ReturnType<typeof createWorkspaceStorePersistence>>['workspace'],\n): Promise<boolean> => {\n // Check if there is any old data in localStorage\n const hasLegacyData =\n localStorage.getItem('workspace') !== null ||\n localStorage.getItem('collection') !== null ||\n localStorage.getItem('request') !== null\n\n if (!hasLegacyData) {\n return false\n }\n\n // Check if IndexedDB already has workspaces\n const existingWorkspaces = await workspacePersistence.getAll()\n const hasIndexDbData = existingWorkspaces.length > 0\n\n // Only migrate if we have legacy data but no IndexedDB data\n return !hasIndexDbData\n}\n\n/**\n * Transforms legacy localStorage data into IndexedDB workspace structure.\n *\n * Transformations:\n * - Collections \u2192 Documents (collections were OpenAPI specs)\n * - Environments \u2192 x-scalar-environments in meta\n * - Cookies \u2192 x-scalar-cookies in meta\n * - Workspace properties \u2192 meta extensions (activeEnvironmentId, proxyUrl, themeId)\n *\n * Creates a default workspace if none exist. Falls back to collection uid if info.title is missing.\n */\nexport const transformLegacyDataToWorkspace = async (legacyData: {\n arrays: v_2_5_0['DataArray']\n records: v_2_5_0['DataRecord']\n}) =>\n await Promise.all(\n legacyData.arrays.workspaces.map(async (workspace) => {\n /** Grab auth from the collections */\n const workspaceAuth: InMemoryWorkspace['auth'] = {}\n\n /** Create a slugger instance per workspace to handle duplicate document names */\n const documentSlugger = new GithubSlugger()\n\n /** Each collection becomes a document in the new system and grab the auth as well */\n const documents: { name: string; document: OpenApiDocument }[] = workspace.collections.flatMap((uid) => {\n const collection = legacyData.records.collections[uid]\n if (!collection) {\n return []\n }\n\n const documentName = collection.info?.title || 'api'\n const { document, auth } = transformCollectionToDocument(documentName, collection, legacyData.records)\n\n // Normalize document name to match the store (lowercase \"Drafts\" \u2192 \"drafts\")\n const normalizedName = documentName === 'Drafts' ? 'drafts' : documentName\n\n // Use GitHubSlugger to ensure unique document names\n const uniqueName = documentSlugger.slug(normalizedName, false)\n\n workspaceAuth[uniqueName] = auth\n\n return { name: uniqueName, document }\n })\n\n const meta: WorkspaceMeta = {}\n const extensions: WorkspaceExtensions = {}\n\n // Add environment\n const environmentEntries = Object.entries(workspace.environments)\n if (environmentEntries.length > 0) {\n extensions['x-scalar-environments'] = {\n default: coerceValue(xScalarEnvironmentSchema, {\n variables: environmentEntries.map(([name, value]) => ({\n name,\n value,\n })),\n }),\n }\n }\n\n // Add cookies to meta\n if (workspace.cookies.length > 0) {\n extensions['x-scalar-cookies'] = workspace.cookies.flatMap((uid) => {\n const cookie = legacyData.records.cookies[uid]\n return cookie ? coerceValue(xScalarCookieSchema, cookie) : []\n })\n }\n\n // Add proxy URL if present\n if (workspace.proxyUrl) {\n meta['x-scalar-active-proxy'] = workspace.proxyUrl\n }\n\n // Add theme if present\n if (workspace.themeId) {\n // We use theme slugs on the new system so we need to transform the id to the slug\n meta['x-scalar-theme'] = transformThemeIdToSlug(workspace.themeId)\n }\n\n // Set color mode\n if (localStorage.getItem('colorMode')) {\n meta['x-scalar-color-mode'] = coerceValue(ColorModeSchema, localStorage.getItem('colorMode'))\n }\n\n const store = createWorkspaceStore({\n meta,\n })\n\n await Promise.all(\n documents.map(async ({ name, document }) => {\n await store.addDocument({\n name,\n document,\n })\n // Note: we are breaking the relationship between the document and the originial source url\n }),\n )\n\n // Try to always set the drafts / route\n if (!(DRAFTS_DOCUMENT_NAME in store.workspace.documents)) {\n await store.addDocument({\n name: DRAFTS_DOCUMENT_NAME,\n document: {\n openapi: '3.1.0',\n info: {\n title: 'Drafts',\n version: '1.0.0',\n },\n paths: {\n '/': {\n get: {},\n },\n },\n 'x-scalar-icon': 'interface-edit-tool-pencil',\n },\n })\n }\n\n const drafts = store.workspace.documents[DRAFTS_DOCUMENT_NAME]\n\n if (drafts) {\n // Make sure the drafts document has a GET / route cuz that's the first route we navigate the user to\n drafts.paths ??= {}\n drafts.paths['/'] ??= {}\n drafts.paths['/']['get'] ??= {}\n }\n\n store.buildSidebar(DRAFTS_DOCUMENT_NAME)\n // save the document to the store so we don't see the document as dirty\n await store.saveDocument(DRAFTS_DOCUMENT_NAME)\n\n // Load the auth into the store\n store.auth.load(workspaceAuth)\n\n // Load the extensions into the store\n objectEntries(extensions).forEach(([key, value]) => {\n store.update(key, value)\n })\n\n return {\n slug: workspace.uid.toString(), // Convert to string to convert it to a simple string type\n name: workspace.name || 'Untitled Workspace',\n workspace: store.exportWorkspace(),\n }\n }),\n )\n\n/**\n * Converts a ThemeId to its corresponding theme slug.\n * If the themeId is 'none', return it as is.\n * Otherwise, look up the slug in the presets object.\n */\nconst transformThemeIdToSlug = (themeId: ThemeId): string => {\n if (themeId === 'none') {\n return themeId\n }\n return presets[themeId]?.slug ?? 'default'\n}\n\n/**\n * Converts legacy environment variables from record format to the new array format.\n *\n * Legacy format: { variables: { API_URL: 'https://...', API_KEY: 'secret' } }\n * New format: { variables: [{ name: 'API_URL', value: 'https://...' }, { name: 'API_KEY', value: 'secret' }] }\n */\nconst transformLegacyEnvironments = (\n environments: v_2_5_0['Collection']['x-scalar-environments'],\n): XScalarEnvironments | undefined => {\n const entries = Object.entries(environments || {})\n if (entries.length === 0) {\n return undefined\n }\n\n return Object.fromEntries(\n entries.map(([envName, env]) => [\n envName,\n coerceValue(xScalarEnvironmentSchema, {\n color: env.color,\n variables: Object.entries(env.variables || {}).map(([name, value]) => ({\n name,\n value: typeof value === 'string' ? value : value.default || '',\n })),\n }),\n ]),\n )\n}\n\n/**\n * Transforms legacy requests and request examples into OpenAPI paths.\n *\n * Each request becomes an operation in the paths object.\n * Request examples are merged into parameter examples and request body examples.\n *\n * Also extracts servers from paths that contain full URLs (e.g., \"https://api.example.com/users\")\n * and returns them separately for deduplication at the document level.\n */\nconst transformRequestsToPaths = (\n collection: v_2_5_0['Collection'],\n dataRecords: v_2_5_0['DataRecord'],\n): { paths: Record<string, PathItemObject>; extractedServers: ServerObject[] } => {\n const paths = Object.create(null) as Record<string, PathItemObject>\n const extractedServers: ServerObject[] = []\n\n for (const requestUid of collection.requests || []) {\n const request = dataRecords.requests[requestUid]\n if (!request) {\n continue\n }\n\n const {\n path,\n method,\n uid: _uid,\n type: _type,\n selectedServerUid: _selectedServerUid,\n examples,\n servers,\n selectedSecuritySchemeUids: _selectedSecuritySchemeUids,\n parameters = [],\n requestBody,\n ...rest\n } = request\n\n let normalizedPath = path || '/'\n\n /**\n * Extract server from path if it contains a full URL.\n * This handles legacy data where users may have entered full URLs as paths.\n */\n const extractedServerUrl = extractServerFromPath(normalizedPath)\n if (extractedServerUrl?.length === 2) {\n const [serverUrl, remainingPath] = extractedServerUrl\n extractedServers.push({ url: serverUrl })\n normalizedPath = remainingPath\n\n /**\n * Handle edge case where the path after server is empty or just \"/\"\n * Example: \"https://api.example.com\" \u2192 \"\" \u2192 \"/\"\n */\n if (!normalizedPath) {\n normalizedPath = '/'\n }\n // Handle double slashes from malformed URLs like \"https://api.example.com//users\"\n else if (normalizedPath.startsWith('//')) {\n normalizedPath = normalizedPath.slice(1)\n }\n }\n\n // Normalize relative paths to start with a leading slash. OpenAPI paths must start with \"/\" per the spec\n if (!normalizedPath.startsWith('/')) {\n normalizedPath = `/${normalizedPath}`\n }\n\n // Initialize path object if it doesn't exist\n if (!paths[normalizedPath]) {\n paths[normalizedPath] = {}\n }\n\n /** Start building the OAS operation object */\n const partialOperation: OperationObject = {\n ...rest,\n }\n\n // Get request examples for this request\n const requestExamples = (examples || []).flatMap((exampleUid) => {\n const example = dataRecords.requestExamples[exampleUid]\n return example ? [example] : []\n })\n\n // Merge examples into parameters\n const mergedParameters = mergeExamplesIntoParameters(parameters, requestExamples)\n if (mergedParameters.length > 0) {\n partialOperation.parameters = mergedParameters\n }\n\n // Merge examples into request body\n const mergedRequestBody = mergeExamplesIntoRequestBody(requestBody, requestExamples)\n if (mergedRequestBody) {\n partialOperation.requestBody = mergedRequestBody\n }\n\n // Add server overrides if present\n if (servers && servers.length > 0) {\n partialOperation.servers = servers.flatMap((serverUid) => {\n const server = dataRecords.servers[serverUid]\n if (!server) {\n return []\n }\n const { uid: _, ...rest } = server\n return [rest]\n })\n }\n\n const pathItem = paths[normalizedPath]\n if (pathItem) {\n pathItem[method] = partialOperation\n }\n }\n\n return { paths, extractedServers }\n}\n\n/**\n * The legacy data model uses plural \"headers\"/\"cookies\" for parameter categories,\n * but OpenAPI uses singular \"header\"/\"cookie\" for the `in` field. This mapping\n * normalizes the legacy names to their OpenAPI equivalents.\n */\nconst PARAM_TYPE_TO_IN: Record<string, string> = {\n path: 'path',\n query: 'query',\n headers: 'header',\n cookies: 'cookie',\n}\n\n/**\n * Ensures unique example names by appending #2, #3, etc. when duplicates are found.\n * Does not use slugification - preserves the original name with a numeric suffix.\n */\nconst ensureUniqueExampleName = (baseName: string, usedNames: Set<string>): string => {\n let uniqueName = baseName\n let counter = 2\n\n while (usedNames.has(uniqueName)) {\n uniqueName = `${baseName} #${counter}`\n counter++\n }\n\n usedNames.add(uniqueName)\n return uniqueName\n}\n\n/**\n * Merges request example values into OpenAPI parameter objects.\n *\n * In the legacy data model, parameter values live on individual RequestExample\n * objects (one per \"example\" tab in the UI). OpenAPI instead stores examples\n * directly on each Parameter object via the `examples` map.\n */\nconst mergeExamplesIntoParameters = (\n parameters: RequestParameter[],\n requestExamples: v_2_5_0['RequestExample'][],\n): ParameterObject[] => {\n /**\n * We track parameters and their collected examples together in a single map\n * keyed by `{in}:{name}` (e.g. \"query:page\") to avoid a second lookup pass.\n */\n const paramEntries = new Map<\n string,\n { param: ParameterObject; examples: Record<string, { value: string; 'x-disabled': boolean }> }\n >()\n\n // Seed with the operation's existing parameters so they are preserved even if\n // no request example references them.\n for (const param of parameters) {\n // Build a type-safe ParameterObject by explicitly mapping properties\n // The old RequestParameter type uses z.unknown() for schema/content/examples,\n // but these values come from validated OpenAPI documents and are already in the correct format.\n // We use type assertions (via unknown) to bridge from the old loose types to the new strict types.\n // This is safe because the data has already been validated by the Zod schema.\n\n // Build either ParameterWithSchemaObject or ParameterWithContentObject\n let paramObject: ParameterObject\n\n // Param with Content Type\n if (param.content && typeof param.content === 'object') {\n paramObject = {\n name: param.name,\n in: param.in,\n required: param.required ?? param.in === 'path',\n deprecated: param.deprecated ?? false,\n content: param.content as ParameterWithContentObject['content'],\n ...(param.description && { description: param.description }),\n } satisfies ParameterWithContentObject\n }\n\n // Param with Schema Type\n else {\n paramObject = {\n name: param.name,\n in: param.in,\n required: param.required ?? param.in === 'path',\n deprecated: param.deprecated ?? false,\n ...(param.description && { description: param.description }),\n ...(param.schema ? { schema: param.schema as ParameterWithSchemaObject['schema'] } : {}),\n ...(param.style && { style: param.style }),\n ...(param.explode !== undefined && { explode: param.explode }),\n ...(param.example !== undefined && { example: param.example }),\n ...(param.examples &&\n typeof param.examples === 'object' && {\n examples: param.examples as ParameterWithSchemaObject['examples'],\n }),\n } satisfies ParameterWithSchemaObject\n }\n\n paramEntries.set(`${param.in}:${param.name}`, {\n param: paramObject,\n examples: {},\n })\n }\n\n const paramTypes = Object.keys(PARAM_TYPE_TO_IN)\n const usedExampleNames = new Set<string>()\n\n for (const requestExample of requestExamples) {\n const baseName = requestExample.name || 'Example'\n const exampleName = ensureUniqueExampleName(baseName, usedExampleNames)\n\n for (const paramType of paramTypes) {\n const inValue = PARAM_TYPE_TO_IN[paramType]\n const items = requestExample.parameters?.[paramType as keyof typeof requestExample.parameters] || []\n\n for (const item of items) {\n const key = `${inValue}:${item.key}`\n\n // Lets not save any params without a key\n if (!item.key) {\n continue\n }\n\n const lowerKey = item.key.toLowerCase()\n\n /**\n * Lazily create a parameter stub when one does not already exist\n * Path parameters are always required per the OpenAPI spec\n *\n * We do not add Accept: *\\/*\n * We do not add any Content-Type headers that are auto added in the client\n */\n if (\n !paramEntries.has(key) &&\n (lowerKey !== 'content-type' || !CONTENT_TYPES[item.value as keyof typeof CONTENT_TYPES]) &&\n (lowerKey !== 'accept' || item.value !== '*/*')\n ) {\n paramEntries.set(key, {\n param: {\n name: item.key,\n in: (inValue as ParameterObject['in']) ?? 'query',\n required: inValue === 'path',\n deprecated: false,\n schema: { type: 'string' },\n },\n examples: {},\n })\n }\n\n // We have skipped the content-type or accept headers above\n const param = paramEntries.get(key)\n if (!param) {\n continue\n }\n\n param.examples[exampleName] = {\n value: item.value,\n 'x-disabled': !item.enabled,\n }\n }\n }\n }\n\n // Build the final parameter list, only attaching `examples` when there are any\n return Array.from(paramEntries.values()).map(({ param, examples }) => {\n if (Object.keys(examples).length > 0) {\n ;(param as ParameterWithSchemaObject).examples = examples\n }\n return param\n })\n}\n\n/** Maps legacy raw body encoding names (e.g. \"json\", \"xml\") to their corresponding MIME content types */\nconst RAW_ENCODING_TO_CONTENT_TYPE: Record<string, string> = {\n json: 'application/json',\n xml: 'application/xml',\n yaml: 'application/yaml',\n edn: 'application/edn',\n text: 'text/plain',\n html: 'text/html',\n javascript: 'application/javascript',\n}\n\n/**\n * Extracts the content type and example value from a single request example body.\n *\n * The legacy data model stored body content in one of three shapes:\n * - `raw` \u2014 text-based body with an encoding hint (json, xml, etc.)\n * - `formData` \u2014 key/value pairs with either multipart or URL-encoded encoding\n * - `binary` \u2014 file upload with no inline content\n */\nconst extractBodyExample = (\n body: v_2_5_0['RequestExample']['body'],\n): { contentType: string; value: unknown } | undefined => {\n if (!body?.activeBody) {\n return undefined\n }\n\n // Raw text body \u2014 resolve the short encoding name to a full MIME type\n if (body.activeBody === 'raw' && body.raw) {\n return {\n contentType: RAW_ENCODING_TO_CONTENT_TYPE[body.raw.encoding] || 'text/plain',\n value: body.raw.value,\n }\n }\n\n // Form data \u2014 distinguish between multipart (file uploads) and URL-encoded\n if (body.activeBody === 'formData' && body.formData) {\n return {\n contentType: body.formData.encoding === 'form-data' ? 'multipart/form-data' : 'application/x-www-form-urlencoded',\n value: body.formData.value.flatMap((param) =>\n param.key\n ? {\n name: param.key,\n value: param.value,\n isDisabled: !param.enabled,\n }\n : [],\n ),\n }\n }\n\n // Binary uploads have no inline content to migrate\n if (body.activeBody === 'binary') {\n return { contentType: 'binary', value: {} }\n }\n\n return undefined\n}\n\n/**\n * Merges request examples into request body examples.\n *\n * The v2.5.0 data model stored request examples separately from the\n * operation's requestBody. In the new model, examples live directly inside\n * `requestBody.content[contentType].examples`. This function bridges the two\n * by grouping examples by content type in a single pass and writing them into\n * the requestBody structure.\n *\n * Returns the original requestBody unchanged when no examples have body content.\n */\nconst mergeExamplesIntoRequestBody = (\n requestBody: RequestBodyObject,\n requestExamples: v_2_5_0['RequestExample'][],\n): RequestBodyObject => {\n /**\n * Single pass: extract each example body and bucket it by content type.\n * Using a plain object as the inner value (instead of a nested Map) avoids\n * a second conversion step when assigning to the result.\n */\n const groupedByContentType = new Map<string, Record<string, { value: unknown }>>()\n\n /** We track the selected content type for each example */\n const selectedContentTypes = {} as Record<string, string>\n\n const usedExampleNames = new Set<string>()\n\n for (const example of requestExamples) {\n const extracted = extractBodyExample(example.body)\n if (!extracted) {\n continue\n }\n\n const baseName = example.name || 'Example'\n const name = ensureUniqueExampleName(baseName, usedExampleNames)\n const group = groupedByContentType.get(extracted.contentType)\n\n if (group) {\n group[name] = { value: extracted.value }\n } else {\n groupedByContentType.set(extracted.contentType, { [name]: { value: extracted.value } })\n }\n\n selectedContentTypes[name] = extracted.contentType\n }\n\n // Nothing to merge \u2014 return early so we do not mutate the requestBody\n if (groupedByContentType.size === 0) {\n return requestBody\n }\n\n // Ensure the requestBody and its content map exist before writing\n const result = requestBody ?? {}\n result.content ??= {}\n\n for (const [contentType, examples] of groupedByContentType) {\n result.content[contentType] ??= {}\n result.content[contentType].examples = examples\n }\n\n // Add the x-scalar-selected-content-type mapping\n if (Object.keys(selectedContentTypes).length > 0) {\n result['x-scalar-selected-content-type'] = selectedContentTypes\n }\n\n return result\n}\n\n/**\n * Transforms legacy tags into OpenAPI tags and tag groups.\n *\n * Legacy structure:\n * - Tags can have children (nested tags)\n * - Top-level parent tags become tag groups\n * - Child tags and standalone tags become regular tags\n */\nconst transformLegacyTags = (\n collection: v_2_5_0['Collection'],\n dataRecords: v_2_5_0['DataRecord'],\n): { tags: TagObject[]; tagGroups: Array<{ name: string; tags: string[] }> } => {\n const tags: TagObject[] = []\n const tagGroups: XTagGroup[] = []\n\n /**\n * Identifies which tags are top-level (appear in collection.children).\n * Top-level parent tags become tag groups, others become regular tags.\n */\n const topLevelTagUids = new Set(collection.children.filter((uid) => dataRecords.tags[uid] !== undefined))\n\n /**\n * Identifies which tags have children.\n * Only top-level parent tags become tag groups.\n */\n const parentTagUids = new Set(\n collection.tags.filter((uid) => {\n const tag = dataRecords.tags[uid]\n return tag?.children && tag.children.length > 0\n }),\n )\n\n /**\n * Process each tag to create either a tag group or a regular tag.\n */\n for (const tagUid of collection.tags) {\n const tag = dataRecords.tags[tagUid]\n if (!tag) {\n continue\n }\n\n const isTopLevelParent = topLevelTagUids.has(tagUid) && parentTagUids.has(tagUid)\n\n if (isTopLevelParent) {\n /**\n * Top-level parent tags become tag groups.\n * Resolve child tag names, filtering out any missing children.\n */\n const childTagNames = tag.children\n .map((childUid) => dataRecords.tags[childUid]?.name)\n .filter((name): name is string => name !== undefined)\n\n if (childTagNames.length > 0) {\n tagGroups.push({\n name: tag.name,\n tags: childTagNames,\n })\n }\n } else {\n /**\n * All other tags (child tags and standalone tags) become regular tags.\n * Preserve optional fields from the legacy tag.\n */\n const tagObject: TagObject = { name: tag.name }\n\n if (tag.description) {\n tagObject.description = tag.description\n }\n if (tag.externalDocs) {\n tagObject.externalDocs = tag.externalDocs\n }\n\n tags.push(tagObject)\n }\n }\n\n return { tags, tagGroups }\n}\n\n/** Transforms a collection and everything it includes into a WorkspaceDocument + auth */\nconst transformCollectionToDocument = (\n documentName: string,\n collection: v_2_5_0['Collection'],\n dataRecords: v_2_5_0['DataRecord'],\n): { document: WorkspaceDocument; auth: Auth } => {\n // Resolve selectedServerUid \u2192 server URL for x-scalar-selected-server\n const selectedServerUrl =\n collection.selectedServerUid && dataRecords.servers[collection.selectedServerUid]\n ? dataRecords.servers[collection.selectedServerUid]?.url\n : undefined\n\n // Transform tags: separate parent tags (groups) from child tags\n const { tags, tagGroups } = transformLegacyTags(collection, dataRecords)\n\n // Transform requests into paths and extract servers from full URLs\n const { paths, extractedServers } = transformRequestsToPaths(collection, dataRecords)\n\n /**\n * Merge and deduplicate servers:\n * 1. Start with existing collection servers\n * 2. Add extracted servers from paths\n * 3. Deduplicate by URL (keep first occurrence)\n */\n const existingServers = collection.servers.flatMap((uid) => {\n const server = dataRecords.servers[uid]\n if (!server) {\n return []\n }\n\n const { uid: _, ...rest } = server\n return [rest]\n })\n\n const allServers = [...existingServers, ...extractedServers]\n const seenUrls = new Set<string>()\n const deduplicatedServers = allServers.filter((server) => {\n if (seenUrls.has(server.url)) {\n return false\n }\n seenUrls.add(server.url)\n return true\n })\n\n const document: Record<string, unknown> = {\n openapi: collection.openapi || '3.1.0',\n info: collection.info || {\n title: documentName,\n version: '1.0',\n },\n servers: deduplicatedServers,\n paths,\n /**\n * Preserve all component types from the collection and merge with transformed security schemes.\n * OpenAPI components object supports: schemas, responses, parameters, examples,\n * requestBodies, headers, securitySchemes, links, callbacks, pathItems\n */\n components: {\n // Preserve existing components from the collection (schemas, responses, parameters, etc.)\n ...(collection.components || {}),\n // Merge security schemes (transformed from UIDs) with any existing security schemes\n securitySchemes: {\n ...((collection.components as Record<string, unknown>)?.securitySchemes || {}),\n ...collection.securitySchemes.reduce((acc, uid) => {\n const securityScheme = dataRecords.securitySchemes[uid]\n if (!securityScheme) {\n return acc\n }\n\n const { uid: _uid, nameKey: _nameKey, ...publicSecurityScheme } = removeSecretFields(securityScheme)\n\n // Clean the flows\n if (securityScheme.type === 'oauth2') {\n const selectedScopes = new Set<string>()\n\n return {\n ...acc,\n [securityScheme.nameKey]: {\n ...publicSecurityScheme,\n flows: objectEntries(securityScheme.flows).reduce(\n (acc, [key, flow]) => {\n if (!flow) {\n return acc\n }\n\n // Store any selected scopes from the config\n if ('selectedScopes' in flow && Array.isArray(flow.selectedScopes)) {\n flow.selectedScopes?.forEach((scope) => selectedScopes.add(scope))\n }\n\n acc[key] = removeSecretFields(flow) as Oauth2Flow\n return acc\n },\n {} as Record<string, Oauth2Flow>,\n ),\n 'x-default-scopes': Array.from(selectedScopes),\n },\n }\n }\n\n return {\n ...acc,\n [securityScheme.nameKey]: publicSecurityScheme,\n }\n }, {}),\n },\n },\n security: collection.security || [],\n tags,\n webhooks: collection.webhooks,\n externalDocs: collection.externalDocs,\n\n // Preserve scalar extensions\n 'x-scalar-icon': collection['x-scalar-icon'],\n\n // Convert legacy record-based environment variables to the new array format\n 'x-scalar-environments': transformLegacyEnvironments(collection['x-scalar-environments']),\n\n // useCollectionSecurity \u2192 x-scalar-set-operation-security\n 'x-scalar-set-operation-security': collection.useCollectionSecurity ?? false,\n }\n\n // Add x-tagGroups if there are any parent tags\n if (tagGroups.length > 0) {\n document['x-tagGroups'] = tagGroups\n }\n\n // x-scalar-active-environment \u2192 x-scalar-client-config-active-environment\n if (collection['x-scalar-active-environment']) {\n document['x-scalar-client-config-active-environment'] = collection['x-scalar-active-environment']\n }\n\n // selectedServerUid \u2192 x-scalar-selected-server (resolved to URL)\n if (selectedServerUrl) {\n document['x-scalar-selected-server'] = selectedServerUrl\n }\n\n // documentUrl \u2192 x-scalar-original-source-url\n if (collection.documentUrl) {\n document['x-scalar-original-source-url'] = collection.documentUrl\n }\n\n // Break any circular JS object references before coercion.\n // The legacy client dereferenced $refs inline, creating circular object graphs\n // that would cause JSON serialization and schema validation to fail.\n const safeDocument = circularToRefs(document, {\n '$ref-value': '',\n '$global': false,\n 'summary': 'This ref was re-created from a circular schema reference',\n })\n\n return {\n document: coerceValue(OpenAPIDocumentSchema, safeDocument),\n auth: coerceValue(AuthSchema, {\n secrets: collection.securitySchemes.reduce((acc, uid) => {\n const securityScheme = dataRecords.securitySchemes[uid]\n if (!securityScheme) {\n return acc\n }\n\n // Oauth 2\n if (securityScheme.type === 'oauth2') {\n return {\n ...acc,\n [securityScheme.nameKey]: {\n type: securityScheme.type,\n ...objectEntries(securityScheme.flows).reduce(\n (acc, [key, flow]) => {\n if (!flow) {\n return acc\n }\n\n acc[key] = extractConfigSecrets(flow)\n return acc\n },\n {} as Record<string, Record<string, string>>,\n ),\n },\n }\n }\n\n // The rest\n return {\n ...acc,\n [securityScheme.nameKey]: {\n type: securityScheme.type,\n ...extractConfigSecrets(securityScheme),\n },\n }\n }, {}),\n selected: {},\n }),\n }\n}\n"],
5
+ "mappings": "AAAA,SAAS,qBAAqB;AAC9B,SAAS,sBAAsB,0BAA0B;AACzD,SAAS,sBAAsB;AAC/B,SAAS,qBAAqB;AAC9B,SAAS,6BAA6B;AACtC,SAAuB,eAAe;AAEtC,SAAS,4BAA4B;AACrC,SAAoB,kBAAkB;AACtC,SAAS,uCAAuC;AAChD;AAAA,EAEE;AAAA,OACK;AACP,SAAS,2BAA2B;AAGpC,SAAS,mBAAmB;AAC5B;AAAA,EACE;AAAA,OAUK;AAEP,SAAS,uBAAuB;AAChC,OAAO,mBAAmB;AAG1B,SAAS,gBAAgB;AAGzB,MAAM,uBAAuB;AAgBtB,MAAM,+BAA+B,YAAY;AACtD,QAAM,EAAE,OAAO,WAAW,qBAAqB,IAAI,MAAM,gCAAgC;AAEzF,MAAI;AACF,UAAM,gBAAgB,MAAM,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"acc"]
7
7
  }
@@ -1 +1 @@
1
- {"version":3,"file":"get-example-from-schema.d.ts","sourceRoot":"","sources":["../../src/spec-getters/get-example-from-schema.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAA;AA4bxD;;;;;;;;;;;;;;;;GAgBG;AACH,eAAO,MAAM,oBAAoB,GAC/B,QAAQ,WAAW,CAAC,YAAY,EAChC,UAAU;IACR,+CAA+C;IAC/C,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,4CAA4C;IAC5C,GAAG,CAAC,EAAE,OAAO,CAAA;IACb,uDAAuD;IACvD,IAAI,CAAC,EAAE,MAAM,GAAG,OAAO,CAAA;IACvB,iEAAiE;IACjE,SAAS,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IACnC,qDAAqD;IACrD,8BAA8B,CAAC,EAAE,OAAO,CAAA;CACzC,EACD,OAAO,OAAO,CAAC;IACb,KAAK,EAAE,MAAM,CAAA;IACb,YAAY,EAAE,WAAW,CAAC,YAAY,CAAA;IACtC,IAAI,EAAE,MAAM,CAAA;IACZ,IAAI,EAAE,OAAO,CAAC,MAAM,CAAC,CAAA;CACtB,CAAC,KACD,GAyJF,CAAA"}
1
+ {"version":3,"file":"get-example-from-schema.d.ts","sourceRoot":"","sources":["../../src/spec-getters/get-example-from-schema.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAA;AAkbxD;;;;;;;;;;;;;;;;GAgBG;AACH,eAAO,MAAM,oBAAoB,GAC/B,QAAQ,WAAW,CAAC,YAAY,EAChC,UAAU;IACR,+CAA+C;IAC/C,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,4CAA4C;IAC5C,GAAG,CAAC,EAAE,OAAO,CAAA;IACb,uDAAuD;IACvD,IAAI,CAAC,EAAE,MAAM,GAAG,OAAO,CAAA;IACvB,iEAAiE;IACjE,SAAS,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IACnC,qDAAqD;IACrD,8BAA8B,CAAC,EAAE,OAAO,CAAA;CACzC,EACD,OAAO,OAAO,CAAC;IACb,KAAK,EAAE,MAAM,CAAA;IACb,YAAY,EAAE,WAAW,CAAC,YAAY,CAAA;IACtC,IAAI,EAAE,MAAM,CAAA;IACZ,IAAI,EAAE,OAAO,CAAC,MAAM,CAAC,CAAA;CACtB,CAAC,KACD,GAyJF,CAAA"}
@@ -3,7 +3,6 @@ import { getRaw } from "@scalar/json-magic/magic-proxy";
3
3
  import { getResolvedRef } from "@scalar/workspace-store/helpers/get-resolved-ref";
4
4
  import { unpackOverridesProxy } from "@scalar/workspace-store/helpers/overrides-proxy";
5
5
  const MAX_LEVELS_DEEP = 10;
6
- const MAX_PROPERTIES = 10;
7
6
  const DEFAULT_ADDITIONAL_PROPERTIES_NAME = "additionalProperty";
8
7
  const currentISOString = (/* @__PURE__ */ new Date()).toISOString();
9
8
  const currentDateString = currentISOString.split("T")[0];
@@ -102,7 +101,7 @@ const handleObjectSchema = (schema, options, level, seen) => {
102
101
  const response = {};
103
102
  if ("properties" in schema && schema.properties) {
104
103
  const propertyNames = Object.keys(schema.properties);
105
- const limit = level > 3 ? Math.min(MAX_PROPERTIES, propertyNames.length) : propertyNames.length;
104
+ const limit = propertyNames.length;
106
105
  for (let i = 0; i < limit; i++) {
107
106
  const propertyName = propertyNames[i];
108
107
  const propertySchema = getResolvedRef(schema.properties[propertyName]);
@@ -120,9 +119,6 @@ const handleObjectSchema = (schema, options, level, seen) => {
120
119
  response[propertyXmlName ?? propertyName] = value;
121
120
  }
122
121
  }
123
- if (level > 3 && propertyNames.length > MAX_PROPERTIES) {
124
- response["..."] = "[Additional Properties Truncated]";
125
- }
126
122
  }
127
123
  if ("patternProperties" in schema && schema.patternProperties) {
128
124
  for (const pattern of Object.keys(schema.patternProperties)) {
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/spec-getters/get-example-from-schema.ts"],
4
- "sourcesContent": ["import { isDefined } from '@scalar/helpers/array/is-defined'\nimport { getRaw } from '@scalar/json-magic/magic-proxy'\nimport type { OpenAPIV3_1 } from '@scalar/openapi-types'\nimport { getResolvedRef } from '@scalar/workspace-store/helpers/get-resolved-ref'\nimport { unpackOverridesProxy } from '@scalar/workspace-store/helpers/overrides-proxy'\n\n/** Maximum recursion depth to prevent infinite loops in circular references */\nconst MAX_LEVELS_DEEP = 10\n\n/**\n * Maximum properties to include after level 3 to prevent exponential growth\n * in deeply nested object structures\n */\nconst MAX_PROPERTIES = 10\n\n/** Default name used for additional properties when no custom name is provided */\nconst DEFAULT_ADDITIONAL_PROPERTIES_NAME = 'additionalProperty'\n\n/**\n * Pre-computed date/time values to avoid expensive Date operations on every call.\n * These are calculated once at module load time for better performance.\n */\nconst currentISOString = new Date().toISOString()\nconst currentDateString = currentISOString.split('T')[0]!\nconst currentTimeString = currentISOString.split('T')[1]!.split('.')[0]!\n\n/**\n * Mapping of OpenAPI string formats to example values.\n * Used to generate realistic examples for different string formats.\n */\nconst genericExampleValues: Record<string, string> = {\n 'date-time': currentISOString,\n 'date': currentDateString,\n 'email': 'hello@example.com',\n 'hostname': 'example.com',\n // https://tools.ietf.org/html/rfc6531#section-3.3\n 'idn-email': 'jane.doe@example.com',\n // https://tools.ietf.org/html/rfc5890#section-2.3.2.3\n 'idn-hostname': 'example.com',\n 'ipv4': '127.0.0.1',\n 'ipv6': '51d4:7fab:bfbf:b7d7:b2cb:d4b4:3dad:d998',\n 'iri-reference': '/entitiy/1',\n // https://tools.ietf.org/html/rfc3987\n 'iri': 'https://example.com/entity/123',\n 'json-pointer': '/nested/objects',\n 'password': 'super-secret',\n 'regex': '/[a-z]/',\n // https://tools.ietf.org/html/draft-handrews-relative-json-pointer-01\n 'relative-json-pointer': '1/nested/objects',\n // full-time in https://tools.ietf.org/html/rfc3339#section-5.6\n 'time': currentTimeString,\n // either a URI or relative-reference https://tools.ietf.org/html/rfc3986#section-4.1\n 'uri-reference': '../folder',\n 'uri-template': 'https://example.com/{id}',\n 'uri': 'https://example.com',\n 'uuid': '123e4567-e89b-12d3-a456-426614174000',\n 'object-id': '6592008029c8c3e4dc76256c',\n}\n\n/**\n * Generate example values for string types based on their format.\n * Special handling for binary format which returns a File object.\n */\nconst guessFromFormat = (\n schema: OpenAPIV3_1.SchemaObject,\n makeUpRandomData: boolean = false,\n fallback: string = '',\n): string | File => {\n // Handle binary format specially - return a File object\n if ('type' in schema && schema.type === 'string' && 'format' in schema && schema.format === 'binary') {\n return new File([''], 'filename')\n }\n\n // Return format-specific example if we have one and are making up data\n if (makeUpRandomData && 'format' in schema && schema.format) {\n return genericExampleValues[schema.format] ?? fallback\n }\n\n return fallback\n}\n\n/**\n * WeakMap cache for memoizing resolved example results.\n * Uses the resolved schema object as the key for efficient lookups.\n */\nconst resultCache = new WeakMap<object, unknown>()\n\n/** Cache required property names per parent schema for O(1) membership checks */\nconst requiredNamesCache = new WeakMap<object, ReadonlySet<string>>()\n\n/**\n * Retrieves the set of required property names from a schema.\n * Caches the result in a WeakMap for efficient lookups.\n */\nconst getRequiredNames = (parentSchema: OpenAPIV3_1.SchemaObject | undefined): ReadonlySet<string> | undefined => {\n if (!parentSchema) {\n return undefined\n }\n\n const cached = requiredNamesCache.get(parentSchema)\n if (cached) {\n return cached\n }\n\n if ('required' in parentSchema) {\n const required = parentSchema.required\n if (Array.isArray(required) && required.length > 0) {\n const set = new Set<string>(required)\n requiredNamesCache.set(parentSchema, set)\n return set\n }\n }\n\n return undefined\n}\n\n/**\n * Cache the result for a schema if it is an object type.\n * Primitive values are not cached to avoid unnecessary WeakMap operations.\n */\nconst cache = (schema: OpenAPIV3_1.SchemaObject, result: unknown) => {\n if (typeof result !== 'object' || result === null) {\n return result\n }\n resultCache.set(getRaw(unpackOverridesProxy(schema)), result)\n return result\n}\n\n/**\n * Check if a schema uses composition keywords (allOf, oneOf, anyOf).\n * These require special handling for merging or selecting schemas.\n */\nconst isComposed = (schema: OpenAPIV3_1.SchemaObject): boolean => !!(schema.allOf || schema.oneOf || schema.anyOf)\n\n/**\n * Determine if a property should be omitted based on the options.\n * Properties are omitted if they are not required and the option is enabled.\n */\nconst shouldOmitProperty = (\n schema: OpenAPIV3_1.SchemaObject,\n parentSchema: OpenAPIV3_1.SchemaObject | undefined,\n propertyName: string | undefined,\n options: { omitEmptyAndOptionalProperties?: boolean } | undefined,\n): boolean => {\n if (options?.omitEmptyAndOptionalProperties !== true) {\n return false\n }\n\n // Never omit container types (objects/arrays) or composed schemas\n const isContainer = ('type' in schema && (schema.type === 'object' || schema.type === 'array')) || isComposed(schema)\n if (isContainer) {\n return false\n }\n\n // Do not omit if explicit example-like values are present\n if (\n ('examples' in schema && Array.isArray(schema.examples) && schema.examples.length > 0) ||\n ('example' in schema && schema.example !== undefined) ||\n ('default' in schema && schema.default !== undefined) ||\n ('const' in schema && schema.const !== undefined) ||\n ('enum' in schema && Array.isArray(schema.enum) && schema.enum.length > 0)\n ) {\n return false\n }\n\n // Check if the property is required\n const name = propertyName ?? schema.title ?? ''\n const requiredNames = getRequiredNames(parentSchema)\n const isRequired = requiredNames ? requiredNames.has(name) : false\n\n return !isRequired\n}\n\n/**\n * Merge two example values with predictable semantics.\n * Arrays are concatenated, objects are merged, otherwise the new value wins.\n */\nconst mergeExamples = (baseValue: unknown, newValue: unknown): unknown => {\n if (Array.isArray(baseValue) && Array.isArray(newValue)) {\n return [...baseValue, ...newValue]\n }\n if (baseValue && typeof baseValue === 'object' && newValue && typeof newValue === 'object') {\n return { ...(baseValue as Record<string, unknown>), ...(newValue as Record<string, unknown>) }\n }\n return newValue\n}\n\n/**\n * Build an example for an object schema, including properties, patternProperties,\n * additionalProperties, and composition (allOf/oneOf/anyOf) merging.\n */\nconst handleObjectSchema = (\n schema: OpenAPIV3_1.SchemaObject,\n options: Parameters<typeof getExampleFromSchema>[1],\n level: number,\n seen: WeakSet<object>,\n): unknown => {\n const response: Record<string, unknown> = {}\n\n if ('properties' in schema && schema.properties) {\n const propertyNames = Object.keys(schema.properties)\n const limit = level > 3 ? Math.min(MAX_PROPERTIES, propertyNames.length) : propertyNames.length\n\n for (let i = 0; i < limit; i++) {\n const propertyName = propertyNames[i]!\n const propertySchema = getResolvedRef(schema.properties[propertyName])\n if (!propertySchema) {\n continue\n }\n\n const propertyXmlName = options?.xml && 'xml' in propertySchema ? propertySchema.xml?.name : undefined\n const value = getExampleFromSchema(propertySchema, options, {\n level: level + 1,\n parentSchema: schema,\n name: propertyName,\n seen,\n })\n\n if (typeof value !== 'undefined') {\n response[propertyXmlName ?? propertyName] = value\n }\n }\n\n if (level > 3 && propertyNames.length > MAX_PROPERTIES) {\n response['...'] = '[Additional Properties Truncated]'\n }\n }\n\n if ('patternProperties' in schema && schema.patternProperties) {\n for (const pattern of Object.keys(schema.patternProperties)) {\n const propertySchema = getResolvedRef(schema.patternProperties[pattern])\n if (!propertySchema) {\n continue\n }\n response[pattern] = getExampleFromSchema(propertySchema, options, {\n level: level + 1,\n parentSchema: schema,\n name: pattern,\n seen,\n })\n }\n }\n\n if (\n 'additionalProperties' in schema &&\n schema.additionalProperties !== undefined &&\n schema.additionalProperties !== false\n ) {\n const additional = getResolvedRef(schema.additionalProperties)\n const isAnyType =\n schema.additionalProperties === true ||\n (typeof schema.additionalProperties === 'object' && Object.keys(schema.additionalProperties).length === 0)\n\n const additionalName =\n typeof additional === 'object' &&\n 'x-additionalPropertiesName' in additional &&\n typeof additional['x-additionalPropertiesName'] === 'string' &&\n additional['x-additionalPropertiesName'].trim().length > 0\n ? additional['x-additionalPropertiesName'].trim()\n : DEFAULT_ADDITIONAL_PROPERTIES_NAME\n\n response[additionalName] = isAnyType\n ? 'anything'\n : typeof additional === 'object'\n ? getExampleFromSchema(additional, options, {\n level: level + 1,\n seen,\n })\n : 'anything'\n }\n\n // onOf\n if (schema.oneOf?.[0]) {\n Object.assign(\n response,\n getExampleFromSchema(getResolvedRef(schema.oneOf[0]), options, {\n level: level + 1,\n seen,\n }),\n )\n }\n // anyOf\n else if (schema.anyOf?.[0]) {\n Object.assign(\n response,\n getExampleFromSchema(getResolvedRef(schema.anyOf[0]), options, {\n level: level + 1,\n seen,\n }),\n )\n }\n // allOf\n else if (Array.isArray(schema.allOf) && schema.allOf.length > 0) {\n let merged: unknown = response\n for (const item of schema.allOf) {\n const ex = getExampleFromSchema(getResolvedRef(item), options, {\n level: level + 1,\n parentSchema: schema,\n seen,\n })\n merged = mergeExamples(merged, ex)\n }\n if (merged && typeof merged === 'object') {\n Object.assign(response, merged as Record<string, unknown>)\n }\n }\n\n if (options?.xml && 'xml' in schema && schema.xml?.name && level === 0) {\n const wrapped: Record<string, unknown> = {}\n wrapped[schema.xml.name] = response\n return cache(schema, wrapped)\n }\n\n return cache(schema, response)\n}\n\n/** Build an example for an array schema, including items, allOf, oneOf/anyOf, and XML wrapping */\nconst handleArraySchema = (\n schema: OpenAPIV3_1.SchemaObject,\n options: Parameters<typeof getExampleFromSchema>[1],\n level: number,\n seen: WeakSet<object>,\n) => {\n const items = 'items' in schema ? getResolvedRef(schema.items) : undefined\n const itemsXmlTagName = items && typeof items === 'object' && 'xml' in items ? items.xml?.name : undefined\n const wrapItems = !!(options?.xml && 'xml' in schema && schema.xml?.wrapped && itemsXmlTagName)\n\n if (schema.example !== undefined) {\n return cache(schema, wrapItems ? { [itemsXmlTagName as string]: schema.example } : schema.example)\n }\n\n if (items && typeof items === 'object') {\n if (Array.isArray(items.allOf) && items.allOf.length > 0) {\n const allOf = items.allOf.filter(isDefined)\n const first = getResolvedRef(allOf[0])\n\n if (first && typeof first === 'object' && 'type' in first && first.type === 'object') {\n const combined: OpenAPIV3_1.SchemaObject = { type: 'object', allOf }\n const merged = getExampleFromSchema(combined, options, {\n level: level + 1,\n parentSchema: schema,\n seen,\n })\n return cache(schema, wrapItems ? [{ [itemsXmlTagName as string]: merged }] : [merged])\n }\n\n const examples = allOf\n .map((s: any) =>\n getExampleFromSchema(getResolvedRef(s), options, {\n level: level + 1,\n parentSchema: schema,\n seen,\n }),\n )\n .filter(isDefined)\n return cache(\n schema,\n wrapItems ? (examples as unknown[]).map((e) => ({ [itemsXmlTagName as string]: e })) : examples,\n )\n }\n\n const union = items.anyOf || items.oneOf\n if (union && union.length > 0) {\n const first = union[0] as OpenAPIV3_1.SchemaObject\n const ex = getExampleFromSchema(getResolvedRef(first), options, {\n level: level + 1,\n parentSchema: schema,\n seen,\n })\n return cache(schema, wrapItems ? [{ [itemsXmlTagName as string]: ex }] : [ex])\n }\n }\n\n const isObject =\n items && typeof items === 'object' && (('type' in items && items.type === 'object') || 'properties' in items)\n const isArray =\n items && typeof items === 'object' && (('type' in items && items.type === 'array') || 'items' in items)\n\n if (items && typeof items === 'object' && (('type' in items && items.type) || isObject || isArray)) {\n const ex = getExampleFromSchema(items as OpenAPIV3_1.SchemaObject, options, {\n level: level + 1,\n seen,\n })\n return cache(schema, wrapItems ? [{ [itemsXmlTagName as string]: ex }] : [ex])\n }\n\n return cache(schema, [])\n}\n\n/** Return primitive example value for single-type schemas, or undefined if not primitive */\nconst getPrimitiveValue = (\n schema: OpenAPIV3_1.SchemaObject,\n makeUpRandomData: boolean,\n emptyString: string | undefined,\n) => {\n if ('type' in schema && schema.type && !Array.isArray(schema.type)) {\n switch (schema.type) {\n case 'string':\n return guessFromFormat(schema, makeUpRandomData, emptyString ?? '')\n case 'boolean':\n return true\n case 'integer':\n return 'minimum' in schema && typeof schema.minimum === 'number' ? schema.minimum : 1\n case 'number':\n return 'minimum' in schema && typeof schema.minimum === 'number' ? schema.minimum : 1\n case 'array':\n return []\n default:\n return undefined\n }\n }\n return undefined\n}\n\n/** Return primitive example value for union-type schemas (type: string[]) */\nconst getUnionPrimitiveValue = (\n schema: OpenAPIV3_1.SchemaObject,\n makeUpRandomData: boolean,\n emptyString: string | undefined,\n) => {\n if ('type' in schema && Array.isArray(schema.type)) {\n if (schema.type.includes('null')) {\n return null\n }\n\n const first = schema.type[0]\n if (first) {\n switch (first) {\n case 'string':\n return guessFromFormat(schema, makeUpRandomData, emptyString ?? '')\n case 'boolean':\n return true\n case 'integer':\n return 'minimum' in schema && typeof schema.minimum === 'number' ? schema.minimum : 1\n case 'number':\n return 'minimum' in schema && typeof schema.minimum === 'number' ? schema.minimum : 1\n case 'null':\n return null\n default:\n return undefined\n }\n }\n }\n return undefined\n}\n\n/**\n * Generate an example value from a given OpenAPI SchemaObject.\n *\n * This function recursively processes OpenAPI schemas to create realistic example data.\n * It handles all OpenAPI schema types including primitives, objects, arrays, and\n * composition schemas (allOf, oneOf, anyOf).\n * Uses a tonne of caching for maximum performance.\n *\n * @param schema - The OpenAPI SchemaObject to generate an example from.\n * @param options - Options to customize example generation.\n * @param level - The current recursion depth.\n * @param parentSchema - The parent schema, if any.\n * @param name - The name of the property being processed.\n * @returns An example value for the given schema.\n *\n * @deprecated Use the one from `@scalar/api-client/v2/blocks/operation-code-sample` instead.\n */\nexport const getExampleFromSchema = (\n schema: OpenAPIV3_1.SchemaObject,\n options?: {\n /** Fallback string for empty string values. */\n emptyString?: string\n /** Whether to use XML tag names as keys. */\n xml?: boolean\n /** Whether to show read-only/write-only properties. */\n mode?: 'read' | 'write'\n /** Dynamic variables which can replace values via x-variable. */\n variables?: Record<string, unknown>\n /** Whether to omit empty and optional properties. */\n omitEmptyAndOptionalProperties?: boolean\n },\n args?: Partial<{\n level: number\n parentSchema: OpenAPIV3_1.SchemaObject\n name: string\n seen: WeakSet<object>\n }>,\n): any => {\n const { level = 0, parentSchema, name, seen = new WeakSet() } = args ?? {}\n\n // Resolve any $ref references to get the actual schema\n const _schema = getResolvedRef(schema)\n if (!isDefined(_schema)) {\n return undefined\n }\n\n // Unpack from all proxies to get the raw schema object for cycle detection\n const targetValue = getRaw(unpackOverridesProxy(_schema))\n if (seen.has(targetValue)) {\n return undefined\n }\n seen.add(targetValue)\n\n // Check cache first for performance - avoid recomputing the same schema\n if (resultCache.has(targetValue)) {\n seen.delete(targetValue)\n return resultCache.get(targetValue)\n }\n\n // Prevent infinite recursion in circular references\n if (level > MAX_LEVELS_DEEP) {\n seen.delete(targetValue)\n return '[Max Depth Exceeded]'\n }\n\n // Determine if we should generate realistic example data\n const makeUpRandomData = !!options?.emptyString\n\n // Early exits for schemas that should not be included (deprecated, readOnly, writeOnly, omitEmptyAndOptionalProperties)\n if (\n _schema.deprecated ||\n (options?.mode === 'write' && _schema.readOnly) ||\n (options?.mode === 'read' && _schema.writeOnly) ||\n shouldOmitProperty(_schema, parentSchema, name, options)\n ) {\n seen.delete(targetValue)\n return undefined\n }\n\n // Handle custom variables (x-variable extension)\n if ('x-variable' in _schema && _schema['x-variable']) {\n const value = options?.variables?.[_schema['x-variable']]\n if (value !== undefined) {\n // Type coercion for numeric types\n if ('type' in _schema && (_schema.type === 'number' || _schema.type === 'integer')) {\n seen.delete(targetValue)\n return cache(_schema, Number(value))\n }\n seen.delete(targetValue)\n return cache(_schema, value)\n }\n }\n\n // Priority order: examples > example > default > const > enum\n if (Array.isArray(_schema.examples) && _schema.examples.length > 0) {\n seen.delete(targetValue)\n return cache(_schema, _schema.examples[0])\n }\n if (_schema.example !== undefined) {\n seen.delete(targetValue)\n return cache(_schema, _schema.example)\n }\n if (_schema.default !== undefined) {\n seen.delete(targetValue)\n return cache(_schema, _schema.default)\n }\n if (_schema.const !== undefined) {\n seen.delete(targetValue)\n return cache(_schema, _schema.const)\n }\n if (Array.isArray(_schema.enum) && _schema.enum.length > 0) {\n seen.delete(targetValue)\n return cache(_schema, _schema.enum[0])\n }\n\n // Handle object types - check for properties to identify objects\n if ('properties' in _schema || ('type' in _schema && _schema.type === 'object')) {\n const result = handleObjectSchema(_schema, options, level, seen)\n seen.delete(targetValue)\n return result\n }\n\n // Handle array types\n if (('type' in _schema && _schema.type === 'array') || 'items' in _schema) {\n const result = handleArraySchema(_schema, options, level, seen)\n seen.delete(targetValue)\n return result\n }\n\n // Handle primitive types without allocating temporary objects\n const primitive = getPrimitiveValue(_schema, makeUpRandomData, options?.emptyString)\n if (primitive !== undefined) {\n seen.delete(targetValue)\n return cache(_schema, primitive)\n }\n\n // Handle composition schemas (oneOf, anyOf) at root level\n const discriminate = _schema.oneOf || _schema.anyOf\n if (Array.isArray(discriminate) && discriminate.length > 0) {\n // Find the first non-null type without allocating intermediate arrays\n for (const item of discriminate) {\n const resolved = getResolvedRef(item)\n if (resolved && (!('type' in resolved) || resolved.type !== 'null')) {\n seen.delete(targetValue)\n return cache(\n _schema,\n getExampleFromSchema(resolved, options, {\n level: level + 1,\n seen,\n }),\n )\n }\n }\n seen.delete(targetValue)\n return cache(_schema, null)\n }\n\n // Handle allOf at root level (non-object/array schemas)\n if (Array.isArray(_schema.allOf) && _schema.allOf.length > 0) {\n let merged: unknown = undefined\n const items = _schema.allOf\n for (const item of items) {\n const ex = getExampleFromSchema(item as OpenAPIV3_1.SchemaObject, options, {\n level: level + 1,\n parentSchema: _schema,\n seen,\n })\n if (merged === undefined) {\n merged = ex\n } else if (merged && typeof merged === 'object' && ex && typeof ex === 'object') {\n merged = mergeExamples(merged, ex)\n } else if (ex !== undefined) {\n // Prefer the latest defined primitive value\n merged = ex\n }\n }\n seen.delete(targetValue)\n return cache(_schema, merged ?? null)\n }\n\n // Handle union types (array of types)\n const unionPrimitive = getUnionPrimitiveValue(_schema, makeUpRandomData, options?.emptyString)\n if (unionPrimitive !== undefined) {\n seen.delete(targetValue)\n return cache(_schema, unionPrimitive)\n }\n\n // Default fallback\n seen.delete(targetValue)\n return cache(_schema, null)\n}\n"],
5
- "mappings": "AAAA,SAAS,iBAAiB;AAC1B,SAAS,cAAc;AAEvB,SAAS,sBAAsB;AAC/B,SAAS,4BAA4B;AAGrC,MAAM,kBAAkB;AAMxB,MAAM,iBAAiB;AAGvB,MAAM,qCAAqC;AAM3C,MAAM,oBAAmB,oBAAI,KAAK,GAAE,YAAY;AAChD,MAAM,oBAAoB,iBAAiB,MAAM,GAAG,EAAE,CAAC;AACvD,MAAM,oBAAoB,iBAAiB,MAAM,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AAC/E,iBAAS,cAAc,QAAQ,EAAE;AAAA,MACnC,WAAW,OAAO,QAAW;AAE3B,iBAAS;AAAA,MACX;AAAA,IACF;AACA,SAAK,OAAO,WAAW;AACvB,WAAO,MAAM,SAAS,UAAU,IAAI;AAAA,EACtC;AAGA,QAAM,iBAAiB,uBAAuB,SAAS,kBAAkB,SAAS,WAAW;AAC7F,MAAI,mBAAmB,QAAW;AAChC,SAAK,OAAO,WAAW;AACvB,WAAO,MAAM,SAAS,cAAc;AAAA,EACtC;AAGA,OAAK,OAAO,WAAW;AACvB,SAAO,MAAM,SAAS,IAAI;AAC5B;",
4
+ "sourcesContent": ["import { isDefined } from '@scalar/helpers/array/is-defined'\nimport { getRaw } from '@scalar/json-magic/magic-proxy'\nimport type { OpenAPIV3_1 } from '@scalar/openapi-types'\nimport { getResolvedRef } from '@scalar/workspace-store/helpers/get-resolved-ref'\nimport { unpackOverridesProxy } from '@scalar/workspace-store/helpers/overrides-proxy'\n\n/** Maximum recursion depth to prevent infinite loops in circular references */\nconst MAX_LEVELS_DEEP = 10\n\n/** Default name used for additional properties when no custom name is provided */\nconst DEFAULT_ADDITIONAL_PROPERTIES_NAME = 'additionalProperty'\n\n/**\n * Pre-computed date/time values to avoid expensive Date operations on every call.\n * These are calculated once at module load time for better performance.\n */\nconst currentISOString = new Date().toISOString()\nconst currentDateString = currentISOString.split('T')[0]!\nconst currentTimeString = currentISOString.split('T')[1]!.split('.')[0]!\n\n/**\n * Mapping of OpenAPI string formats to example values.\n * Used to generate realistic examples for different string formats.\n */\nconst genericExampleValues: Record<string, string> = {\n 'date-time': currentISOString,\n 'date': currentDateString,\n 'email': 'hello@example.com',\n 'hostname': 'example.com',\n // https://tools.ietf.org/html/rfc6531#section-3.3\n 'idn-email': 'jane.doe@example.com',\n // https://tools.ietf.org/html/rfc5890#section-2.3.2.3\n 'idn-hostname': 'example.com',\n 'ipv4': '127.0.0.1',\n 'ipv6': '51d4:7fab:bfbf:b7d7:b2cb:d4b4:3dad:d998',\n 'iri-reference': '/entitiy/1',\n // https://tools.ietf.org/html/rfc3987\n 'iri': 'https://example.com/entity/123',\n 'json-pointer': '/nested/objects',\n 'password': 'super-secret',\n 'regex': '/[a-z]/',\n // https://tools.ietf.org/html/draft-handrews-relative-json-pointer-01\n 'relative-json-pointer': '1/nested/objects',\n // full-time in https://tools.ietf.org/html/rfc3339#section-5.6\n 'time': currentTimeString,\n // either a URI or relative-reference https://tools.ietf.org/html/rfc3986#section-4.1\n 'uri-reference': '../folder',\n 'uri-template': 'https://example.com/{id}',\n 'uri': 'https://example.com',\n 'uuid': '123e4567-e89b-12d3-a456-426614174000',\n 'object-id': '6592008029c8c3e4dc76256c',\n}\n\n/**\n * Generate example values for string types based on their format.\n * Special handling for binary format which returns a File object.\n */\nconst guessFromFormat = (\n schema: OpenAPIV3_1.SchemaObject,\n makeUpRandomData: boolean = false,\n fallback: string = '',\n): string | File => {\n // Handle binary format specially - return a File object\n if ('type' in schema && schema.type === 'string' && 'format' in schema && schema.format === 'binary') {\n return new File([''], 'filename')\n }\n\n // Return format-specific example if we have one and are making up data\n if (makeUpRandomData && 'format' in schema && schema.format) {\n return genericExampleValues[schema.format] ?? fallback\n }\n\n return fallback\n}\n\n/**\n * WeakMap cache for memoizing resolved example results.\n * Uses the resolved schema object as the key for efficient lookups.\n */\nconst resultCache = new WeakMap<object, unknown>()\n\n/** Cache required property names per parent schema for O(1) membership checks */\nconst requiredNamesCache = new WeakMap<object, ReadonlySet<string>>()\n\n/**\n * Retrieves the set of required property names from a schema.\n * Caches the result in a WeakMap for efficient lookups.\n */\nconst getRequiredNames = (parentSchema: OpenAPIV3_1.SchemaObject | undefined): ReadonlySet<string> | undefined => {\n if (!parentSchema) {\n return undefined\n }\n\n const cached = requiredNamesCache.get(parentSchema)\n if (cached) {\n return cached\n }\n\n if ('required' in parentSchema) {\n const required = parentSchema.required\n if (Array.isArray(required) && required.length > 0) {\n const set = new Set<string>(required)\n requiredNamesCache.set(parentSchema, set)\n return set\n }\n }\n\n return undefined\n}\n\n/**\n * Cache the result for a schema if it is an object type.\n * Primitive values are not cached to avoid unnecessary WeakMap operations.\n */\nconst cache = (schema: OpenAPIV3_1.SchemaObject, result: unknown) => {\n if (typeof result !== 'object' || result === null) {\n return result\n }\n resultCache.set(getRaw(unpackOverridesProxy(schema)), result)\n return result\n}\n\n/**\n * Check if a schema uses composition keywords (allOf, oneOf, anyOf).\n * These require special handling for merging or selecting schemas.\n */\nconst isComposed = (schema: OpenAPIV3_1.SchemaObject): boolean => !!(schema.allOf || schema.oneOf || schema.anyOf)\n\n/**\n * Determine if a property should be omitted based on the options.\n * Properties are omitted if they are not required and the option is enabled.\n */\nconst shouldOmitProperty = (\n schema: OpenAPIV3_1.SchemaObject,\n parentSchema: OpenAPIV3_1.SchemaObject | undefined,\n propertyName: string | undefined,\n options: { omitEmptyAndOptionalProperties?: boolean } | undefined,\n): boolean => {\n if (options?.omitEmptyAndOptionalProperties !== true) {\n return false\n }\n\n // Never omit container types (objects/arrays) or composed schemas\n const isContainer = ('type' in schema && (schema.type === 'object' || schema.type === 'array')) || isComposed(schema)\n if (isContainer) {\n return false\n }\n\n // Do not omit if explicit example-like values are present\n if (\n ('examples' in schema && Array.isArray(schema.examples) && schema.examples.length > 0) ||\n ('example' in schema && schema.example !== undefined) ||\n ('default' in schema && schema.default !== undefined) ||\n ('const' in schema && schema.const !== undefined) ||\n ('enum' in schema && Array.isArray(schema.enum) && schema.enum.length > 0)\n ) {\n return false\n }\n\n // Check if the property is required\n const name = propertyName ?? schema.title ?? ''\n const requiredNames = getRequiredNames(parentSchema)\n const isRequired = requiredNames ? requiredNames.has(name) : false\n\n return !isRequired\n}\n\n/**\n * Merge two example values with predictable semantics.\n * Arrays are concatenated, objects are merged, otherwise the new value wins.\n */\nconst mergeExamples = (baseValue: unknown, newValue: unknown): unknown => {\n if (Array.isArray(baseValue) && Array.isArray(newValue)) {\n return [...baseValue, ...newValue]\n }\n if (baseValue && typeof baseValue === 'object' && newValue && typeof newValue === 'object') {\n return { ...(baseValue as Record<string, unknown>), ...(newValue as Record<string, unknown>) }\n }\n return newValue\n}\n\n/**\n * Build an example for an object schema, including properties, patternProperties,\n * additionalProperties, and composition (allOf/oneOf/anyOf) merging.\n */\nconst handleObjectSchema = (\n schema: OpenAPIV3_1.SchemaObject,\n options: Parameters<typeof getExampleFromSchema>[1],\n level: number,\n seen: WeakSet<object>,\n): unknown => {\n const response: Record<string, unknown> = {}\n\n if ('properties' in schema && schema.properties) {\n const propertyNames = Object.keys(schema.properties)\n const limit = propertyNames.length\n\n for (let i = 0; i < limit; i++) {\n const propertyName = propertyNames[i]!\n const propertySchema = getResolvedRef(schema.properties[propertyName])\n if (!propertySchema) {\n continue\n }\n\n const propertyXmlName = options?.xml && 'xml' in propertySchema ? propertySchema.xml?.name : undefined\n const value = getExampleFromSchema(propertySchema, options, {\n level: level + 1,\n parentSchema: schema,\n name: propertyName,\n seen,\n })\n\n if (typeof value !== 'undefined') {\n response[propertyXmlName ?? propertyName] = value\n }\n }\n }\n\n if ('patternProperties' in schema && schema.patternProperties) {\n for (const pattern of Object.keys(schema.patternProperties)) {\n const propertySchema = getResolvedRef(schema.patternProperties[pattern])\n if (!propertySchema) {\n continue\n }\n response[pattern] = getExampleFromSchema(propertySchema, options, {\n level: level + 1,\n parentSchema: schema,\n name: pattern,\n seen,\n })\n }\n }\n\n if (\n 'additionalProperties' in schema &&\n schema.additionalProperties !== undefined &&\n schema.additionalProperties !== false\n ) {\n const additional = getResolvedRef(schema.additionalProperties)\n const isAnyType =\n schema.additionalProperties === true ||\n (typeof schema.additionalProperties === 'object' && Object.keys(schema.additionalProperties).length === 0)\n\n const additionalName =\n typeof additional === 'object' &&\n 'x-additionalPropertiesName' in additional &&\n typeof additional['x-additionalPropertiesName'] === 'string' &&\n additional['x-additionalPropertiesName'].trim().length > 0\n ? additional['x-additionalPropertiesName'].trim()\n : DEFAULT_ADDITIONAL_PROPERTIES_NAME\n\n response[additionalName] = isAnyType\n ? 'anything'\n : typeof additional === 'object'\n ? getExampleFromSchema(additional, options, {\n level: level + 1,\n seen,\n })\n : 'anything'\n }\n\n // onOf\n if (schema.oneOf?.[0]) {\n Object.assign(\n response,\n getExampleFromSchema(getResolvedRef(schema.oneOf[0]), options, {\n level: level + 1,\n seen,\n }),\n )\n }\n // anyOf\n else if (schema.anyOf?.[0]) {\n Object.assign(\n response,\n getExampleFromSchema(getResolvedRef(schema.anyOf[0]), options, {\n level: level + 1,\n seen,\n }),\n )\n }\n // allOf\n else if (Array.isArray(schema.allOf) && schema.allOf.length > 0) {\n let merged: unknown = response\n for (const item of schema.allOf) {\n const ex = getExampleFromSchema(getResolvedRef(item), options, {\n level: level + 1,\n parentSchema: schema,\n seen,\n })\n merged = mergeExamples(merged, ex)\n }\n if (merged && typeof merged === 'object') {\n Object.assign(response, merged as Record<string, unknown>)\n }\n }\n\n if (options?.xml && 'xml' in schema && schema.xml?.name && level === 0) {\n const wrapped: Record<string, unknown> = {}\n wrapped[schema.xml.name] = response\n return cache(schema, wrapped)\n }\n\n return cache(schema, response)\n}\n\n/** Build an example for an array schema, including items, allOf, oneOf/anyOf, and XML wrapping */\nconst handleArraySchema = (\n schema: OpenAPIV3_1.SchemaObject,\n options: Parameters<typeof getExampleFromSchema>[1],\n level: number,\n seen: WeakSet<object>,\n) => {\n const items = 'items' in schema ? getResolvedRef(schema.items) : undefined\n const itemsXmlTagName = items && typeof items === 'object' && 'xml' in items ? items.xml?.name : undefined\n const wrapItems = !!(options?.xml && 'xml' in schema && schema.xml?.wrapped && itemsXmlTagName)\n\n if (schema.example !== undefined) {\n return cache(schema, wrapItems ? { [itemsXmlTagName as string]: schema.example } : schema.example)\n }\n\n if (items && typeof items === 'object') {\n if (Array.isArray(items.allOf) && items.allOf.length > 0) {\n const allOf = items.allOf.filter(isDefined)\n const first = getResolvedRef(allOf[0])\n\n if (first && typeof first === 'object' && 'type' in first && first.type === 'object') {\n const combined: OpenAPIV3_1.SchemaObject = { type: 'object', allOf }\n const merged = getExampleFromSchema(combined, options, {\n level: level + 1,\n parentSchema: schema,\n seen,\n })\n return cache(schema, wrapItems ? [{ [itemsXmlTagName as string]: merged }] : [merged])\n }\n\n const examples = allOf\n .map((s: any) =>\n getExampleFromSchema(getResolvedRef(s), options, {\n level: level + 1,\n parentSchema: schema,\n seen,\n }),\n )\n .filter(isDefined)\n return cache(\n schema,\n wrapItems ? (examples as unknown[]).map((e) => ({ [itemsXmlTagName as string]: e })) : examples,\n )\n }\n\n const union = items.anyOf || items.oneOf\n if (union && union.length > 0) {\n const first = union[0] as OpenAPIV3_1.SchemaObject\n const ex = getExampleFromSchema(getResolvedRef(first), options, {\n level: level + 1,\n parentSchema: schema,\n seen,\n })\n return cache(schema, wrapItems ? [{ [itemsXmlTagName as string]: ex }] : [ex])\n }\n }\n\n const isObject =\n items && typeof items === 'object' && (('type' in items && items.type === 'object') || 'properties' in items)\n const isArray =\n items && typeof items === 'object' && (('type' in items && items.type === 'array') || 'items' in items)\n\n if (items && typeof items === 'object' && (('type' in items && items.type) || isObject || isArray)) {\n const ex = getExampleFromSchema(items as OpenAPIV3_1.SchemaObject, options, {\n level: level + 1,\n seen,\n })\n return cache(schema, wrapItems ? [{ [itemsXmlTagName as string]: ex }] : [ex])\n }\n\n return cache(schema, [])\n}\n\n/** Return primitive example value for single-type schemas, or undefined if not primitive */\nconst getPrimitiveValue = (\n schema: OpenAPIV3_1.SchemaObject,\n makeUpRandomData: boolean,\n emptyString: string | undefined,\n) => {\n if ('type' in schema && schema.type && !Array.isArray(schema.type)) {\n switch (schema.type) {\n case 'string':\n return guessFromFormat(schema, makeUpRandomData, emptyString ?? '')\n case 'boolean':\n return true\n case 'integer':\n return 'minimum' in schema && typeof schema.minimum === 'number' ? schema.minimum : 1\n case 'number':\n return 'minimum' in schema && typeof schema.minimum === 'number' ? schema.minimum : 1\n case 'array':\n return []\n default:\n return undefined\n }\n }\n return undefined\n}\n\n/** Return primitive example value for union-type schemas (type: string[]) */\nconst getUnionPrimitiveValue = (\n schema: OpenAPIV3_1.SchemaObject,\n makeUpRandomData: boolean,\n emptyString: string | undefined,\n) => {\n if ('type' in schema && Array.isArray(schema.type)) {\n if (schema.type.includes('null')) {\n return null\n }\n\n const first = schema.type[0]\n if (first) {\n switch (first) {\n case 'string':\n return guessFromFormat(schema, makeUpRandomData, emptyString ?? '')\n case 'boolean':\n return true\n case 'integer':\n return 'minimum' in schema && typeof schema.minimum === 'number' ? schema.minimum : 1\n case 'number':\n return 'minimum' in schema && typeof schema.minimum === 'number' ? schema.minimum : 1\n case 'null':\n return null\n default:\n return undefined\n }\n }\n }\n return undefined\n}\n\n/**\n * Generate an example value from a given OpenAPI SchemaObject.\n *\n * This function recursively processes OpenAPI schemas to create realistic example data.\n * It handles all OpenAPI schema types including primitives, objects, arrays, and\n * composition schemas (allOf, oneOf, anyOf).\n * Uses a tonne of caching for maximum performance.\n *\n * @param schema - The OpenAPI SchemaObject to generate an example from.\n * @param options - Options to customize example generation.\n * @param level - The current recursion depth.\n * @param parentSchema - The parent schema, if any.\n * @param name - The name of the property being processed.\n * @returns An example value for the given schema.\n *\n * @deprecated Use the one from `@scalar/api-client/v2/blocks/operation-code-sample` instead.\n */\nexport const getExampleFromSchema = (\n schema: OpenAPIV3_1.SchemaObject,\n options?: {\n /** Fallback string for empty string values. */\n emptyString?: string\n /** Whether to use XML tag names as keys. */\n xml?: boolean\n /** Whether to show read-only/write-only properties. */\n mode?: 'read' | 'write'\n /** Dynamic variables which can replace values via x-variable. */\n variables?: Record<string, unknown>\n /** Whether to omit empty and optional properties. */\n omitEmptyAndOptionalProperties?: boolean\n },\n args?: Partial<{\n level: number\n parentSchema: OpenAPIV3_1.SchemaObject\n name: string\n seen: WeakSet<object>\n }>,\n): any => {\n const { level = 0, parentSchema, name, seen = new WeakSet() } = args ?? {}\n\n // Resolve any $ref references to get the actual schema\n const _schema = getResolvedRef(schema)\n if (!isDefined(_schema)) {\n return undefined\n }\n\n // Unpack from all proxies to get the raw schema object for cycle detection\n const targetValue = getRaw(unpackOverridesProxy(_schema))\n if (seen.has(targetValue)) {\n return undefined\n }\n seen.add(targetValue)\n\n // Check cache first for performance - avoid recomputing the same schema\n if (resultCache.has(targetValue)) {\n seen.delete(targetValue)\n return resultCache.get(targetValue)\n }\n\n // Prevent infinite recursion in circular references\n if (level > MAX_LEVELS_DEEP) {\n seen.delete(targetValue)\n return '[Max Depth Exceeded]'\n }\n\n // Determine if we should generate realistic example data\n const makeUpRandomData = !!options?.emptyString\n\n // Early exits for schemas that should not be included (deprecated, readOnly, writeOnly, omitEmptyAndOptionalProperties)\n if (\n _schema.deprecated ||\n (options?.mode === 'write' && _schema.readOnly) ||\n (options?.mode === 'read' && _schema.writeOnly) ||\n shouldOmitProperty(_schema, parentSchema, name, options)\n ) {\n seen.delete(targetValue)\n return undefined\n }\n\n // Handle custom variables (x-variable extension)\n if ('x-variable' in _schema && _schema['x-variable']) {\n const value = options?.variables?.[_schema['x-variable']]\n if (value !== undefined) {\n // Type coercion for numeric types\n if ('type' in _schema && (_schema.type === 'number' || _schema.type === 'integer')) {\n seen.delete(targetValue)\n return cache(_schema, Number(value))\n }\n seen.delete(targetValue)\n return cache(_schema, value)\n }\n }\n\n // Priority order: examples > example > default > const > enum\n if (Array.isArray(_schema.examples) && _schema.examples.length > 0) {\n seen.delete(targetValue)\n return cache(_schema, _schema.examples[0])\n }\n if (_schema.example !== undefined) {\n seen.delete(targetValue)\n return cache(_schema, _schema.example)\n }\n if (_schema.default !== undefined) {\n seen.delete(targetValue)\n return cache(_schema, _schema.default)\n }\n if (_schema.const !== undefined) {\n seen.delete(targetValue)\n return cache(_schema, _schema.const)\n }\n if (Array.isArray(_schema.enum) && _schema.enum.length > 0) {\n seen.delete(targetValue)\n return cache(_schema, _schema.enum[0])\n }\n\n // Handle object types - check for properties to identify objects\n if ('properties' in _schema || ('type' in _schema && _schema.type === 'object')) {\n const result = handleObjectSchema(_schema, options, level, seen)\n seen.delete(targetValue)\n return result\n }\n\n // Handle array types\n if (('type' in _schema && _schema.type === 'array') || 'items' in _schema) {\n const result = handleArraySchema(_schema, options, level, seen)\n seen.delete(targetValue)\n return result\n }\n\n // Handle primitive types without allocating temporary objects\n const primitive = getPrimitiveValue(_schema, makeUpRandomData, options?.emptyString)\n if (primitive !== undefined) {\n seen.delete(targetValue)\n return cache(_schema, primitive)\n }\n\n // Handle composition schemas (oneOf, anyOf) at root level\n const discriminate = _schema.oneOf || _schema.anyOf\n if (Array.isArray(discriminate) && discriminate.length > 0) {\n // Find the first non-null type without allocating intermediate arrays\n for (const item of discriminate) {\n const resolved = getResolvedRef(item)\n if (resolved && (!('type' in resolved) || resolved.type !== 'null')) {\n seen.delete(targetValue)\n return cache(\n _schema,\n getExampleFromSchema(resolved, options, {\n level: level + 1,\n seen,\n }),\n )\n }\n }\n seen.delete(targetValue)\n return cache(_schema, null)\n }\n\n // Handle allOf at root level (non-object/array schemas)\n if (Array.isArray(_schema.allOf) && _schema.allOf.length > 0) {\n let merged: unknown = undefined\n const items = _schema.allOf\n for (const item of items) {\n const ex = getExampleFromSchema(item as OpenAPIV3_1.SchemaObject, options, {\n level: level + 1,\n parentSchema: _schema,\n seen,\n })\n if (merged === undefined) {\n merged = ex\n } else if (merged && typeof merged === 'object' && ex && typeof ex === 'object') {\n merged = mergeExamples(merged, ex)\n } else if (ex !== undefined) {\n // Prefer the latest defined primitive value\n merged = ex\n }\n }\n seen.delete(targetValue)\n return cache(_schema, merged ?? null)\n }\n\n // Handle union types (array of types)\n const unionPrimitive = getUnionPrimitiveValue(_schema, makeUpRandomData, options?.emptyString)\n if (unionPrimitive !== undefined) {\n seen.delete(targetValue)\n return cache(_schema, unionPrimitive)\n }\n\n // Default fallback\n seen.delete(targetValue)\n return cache(_schema, null)\n}\n"],
5
+ "mappings": "AAAA,SAAS,iBAAiB;AAC1B,SAAS,cAAc;AAEvB,SAAS,sBAAsB;AAC/B,SAAS,4BAA4B;AAGrC,MAAM,kBAAkB;AAGxB,MAAM,qC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,UAAU;AAC/E,iBAAS,cAAc,QAAQ,EAAE;AAAA,MACnC,WAAW,OAAO,QAAW;AAE3B,iBAAS;AAAA,MACX;AAAA,IACF;AACA,SAAK,OAAO,WAAW;AACvB,WAAO,MAAM,SAAS,UAAU,IAAI;AAAA,EACtC;AAGA,QAAM,iBAAiB,uBAAuB,SAAS,kBAAkB,SAAS,WAAW;AAC7F,MAAI,mBAAmB,QAAW;AAChC,SAAK,OAAO,WAAW;AACvB,WAAO,MAAM,SAAS,cAAc;AAAA,EACtC;AAGA,OAAK,OAAO,WAAW;AACvB,SAAO,MAAM,SAAS,IAAI;AAC5B;",
6
6
  "names": []
7
7
  }
package/package.json CHANGED
@@ -16,7 +16,7 @@
16
16
  "specification",
17
17
  "yaml"
18
18
  ],
19
- "version": "0.6.46",
19
+ "version": "0.6.47",
20
20
  "engines": {
21
21
  "node": ">=20"
22
22
  },
@@ -86,17 +86,18 @@
86
86
  ],
87
87
  "dependencies": {
88
88
  "flatted": "^3.3.3",
89
+ "github-slugger": "2.0.0",
89
90
  "type-fest": "^5.3.1",
90
91
  "vue": "^3.5.26",
91
92
  "yaml": "^2.8.0",
92
93
  "zod": "^4.3.5",
93
- "@scalar/helpers": "0.2.15",
94
- "@scalar/json-magic": "0.11.4",
95
- "@scalar/object-utils": "1.2.29",
94
+ "@scalar/openapi-types": "0.5.3",
95
+ "@scalar/helpers": "0.2.16",
96
+ "@scalar/object-utils": "1.2.30",
97
+ "@scalar/json-magic": "0.11.5",
96
98
  "@scalar/themes": "0.14.0",
97
- "@scalar/types": "0.6.6",
98
- "@scalar/workspace-store": "0.34.2",
99
- "@scalar/openapi-types": "0.5.3"
99
+ "@scalar/workspace-store": "0.34.3",
100
+ "@scalar/types": "0.6.7"
100
101
  },
101
102
  "devDependencies": {
102
103
  "@types/node": "^22.19.3",
@@ -104,9 +105,9 @@
104
105
  "vite": "^7.3.1",
105
106
  "vitest": "4.0.16",
106
107
  "zod-to-ts": "github:amritk/zod-to-ts#build",
107
- "@scalar/build-tooling": "0.4.1",
108
+ "@scalar/openapi-parser": "0.24.14",
108
109
  "@scalar/openapi-types": "0.5.3",
109
- "@scalar/openapi-parser": "0.24.13"
110
+ "@scalar/build-tooling": "0.4.1"
110
111
  },
111
112
  "scripts": {
112
113
  "build": "scalar-build-esbuild",