@scalar/workspace-store 0.25.2 → 0.25.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (55) hide show
  1. package/CHANGELOG.md +7 -0
  2. package/README.md +0 -46
  3. package/dist/client.d.ts +4 -33
  4. package/dist/client.d.ts.map +1 -1
  5. package/dist/client.js +20 -65
  6. package/dist/client.js.map +2 -2
  7. package/dist/helpers/get-fetch.d.ts +10 -0
  8. package/dist/helpers/get-fetch.d.ts.map +1 -0
  9. package/dist/helpers/get-fetch.js +11 -0
  10. package/dist/helpers/get-fetch.js.map +7 -0
  11. package/dist/mutators/operation.d.ts.map +1 -1
  12. package/dist/mutators/operation.js +9 -14
  13. package/dist/mutators/operation.js.map +2 -2
  14. package/dist/navigation/get-navigation-options.d.ts +3 -2
  15. package/dist/navigation/get-navigation-options.d.ts.map +1 -1
  16. package/dist/navigation/get-navigation-options.js +14 -18
  17. package/dist/navigation/get-navigation-options.js.map +2 -2
  18. package/dist/navigation/helpers/traverse-document.d.ts +2 -2
  19. package/dist/navigation/helpers/traverse-document.d.ts.map +1 -1
  20. package/dist/navigation/helpers/traverse-document.js +2 -2
  21. package/dist/navigation/helpers/traverse-document.js.map +2 -2
  22. package/dist/persistence/index.d.ts +1 -7
  23. package/dist/persistence/index.d.ts.map +1 -1
  24. package/dist/persistence/index.js +3 -25
  25. package/dist/persistence/index.js.map +2 -2
  26. package/dist/plugins/client/persistence.d.ts.map +1 -1
  27. package/dist/plugins/client/persistence.js +0 -6
  28. package/dist/plugins/client/persistence.js.map +2 -2
  29. package/dist/schemas/inmemory-workspace.d.ts +4 -1492
  30. package/dist/schemas/inmemory-workspace.d.ts.map +1 -1
  31. package/dist/schemas/inmemory-workspace.js +0 -2
  32. package/dist/schemas/inmemory-workspace.js.map +2 -2
  33. package/dist/schemas/workspace-specification/index.d.ts +5 -1491
  34. package/dist/schemas/workspace-specification/index.d.ts.map +1 -1
  35. package/dist/schemas/workspace-specification/index.js +0 -2
  36. package/dist/schemas/workspace-specification/index.js.map +2 -2
  37. package/dist/schemas/workspace.d.ts +9 -9
  38. package/dist/schemas/workspace.d.ts.map +1 -1
  39. package/dist/schemas/workspace.js +14 -8
  40. package/dist/schemas/workspace.js.map +2 -2
  41. package/dist/server.d.ts +3 -2
  42. package/dist/server.d.ts.map +1 -1
  43. package/dist/server.js +2 -2
  44. package/dist/server.js.map +2 -2
  45. package/dist/workspace-plugin.d.ts +0 -4
  46. package/dist/workspace-plugin.d.ts.map +1 -1
  47. package/package.json +3 -3
  48. package/dist/preprocessing/server.d.ts +0 -23
  49. package/dist/preprocessing/server.d.ts.map +0 -1
  50. package/dist/preprocessing/server.js +0 -84
  51. package/dist/preprocessing/server.js.map +0 -7
  52. package/dist/schemas/workspace-specification/config.d.ts +0 -1520
  53. package/dist/schemas/workspace-specification/config.d.ts.map +0 -1
  54. package/dist/schemas/workspace-specification/config.js +0 -11
  55. package/dist/schemas/workspace-specification/config.js.map +0 -7
package/CHANGELOG.md CHANGED
@@ -1,5 +1,12 @@
1
1
  # @scalar/workspace-store
2
2
 
3
+ ## 0.25.3
4
+
5
+ ### Patch Changes
6
+
7
+ - [#7850](https://github.com/scalar/scalar/pull/7850): fix: remove unused workspace config
8
+ - [#7868](https://github.com/scalar/scalar/pull/7868): fix: updating path with a variable in it
9
+
3
10
  ## 0.25.2
4
11
 
5
12
  ### Patch Changes
package/README.md CHANGED
@@ -239,52 +239,6 @@ await store.addDocument({
239
239
  console.log(store.workspace.documents.default)
240
240
  ```
241
241
 
242
- #### Configuration
243
-
244
- You can pass configuration object to the workspace store which is going to be applied to all the documents
245
-
246
- ```ts
247
- const store = createWorkspaceStore({
248
- config: {
249
- "x-scalar-reference-config": {
250
- features: {
251
- showModels: true,
252
- },
253
- appearance: {
254
- layout: 'modern'
255
- },
256
- }
257
- }
258
- })
259
- ```
260
-
261
- You can override specific document configuration when you add the document to the store
262
-
263
- ```ts
264
- await store.addDocument({
265
- name: 'example',
266
- document: {
267
- openapi: '3.0.0',
268
- info: { title: 'Example API', version: '1.0.0' },
269
- paths: {},
270
- },
271
- config: {
272
- features: {
273
- showModels: false,
274
- },
275
- }
276
- })
277
- ```
278
-
279
- To get the active document configuration you can use config getter
280
-
281
- ```ts
282
- // Get the configuration for the active document
283
- console.log(store.config['x-scalar-reference-config'].features.showModels)
284
- ```
285
-
286
- When no configuration is provided it will return the default configuration
287
-
288
242
  #### Document Persistence and Export
289
243
 
290
244
  The workspace store provides several methods for managing document persistence and exporting:
package/dist/client.d.ts CHANGED
@@ -1,12 +1,11 @@
1
1
  import { type Difference, merge } from '@scalar/json-magic/diff';
2
- import type { PartialDeep, RequiredDeep } from 'type-fest';
2
+ import type { PartialDeep } from 'type-fest';
3
+ import type { NavigationOptions } from './navigation/get-navigation-options.js';
3
4
  import type { InMemoryWorkspace } from './schemas/inmemory-workspace.js';
4
5
  import { type OpenApiDocument } from './schemas/v3.1/strict/openapi-document.js';
5
6
  import type { Workspace, WorkspaceDocumentMeta, WorkspaceExtensions, WorkspaceMeta } from './schemas/workspace.js';
6
7
  import type { WorkspaceSpecification } from './schemas/workspace-specification/index.js';
7
- import type { Config, DocumentConfiguration } from './schemas/workspace-specification/config.js';
8
8
  import type { WorkspacePlugin } from './workspace-plugin.js';
9
- declare const defaultConfig: RequiredDeep<Config>;
10
9
  /**
11
10
  * Input type for workspace document metadata and configuration.
12
11
  * This type defines the required and optional fields for initializing a document in the workspace.
@@ -16,8 +15,6 @@ type WorkspaceDocumentMetaInput = {
16
15
  meta?: WorkspaceDocumentMeta;
17
16
  /** Required unique identifier for the document */
18
17
  name: string;
19
- /** Optional configuration options */
20
- config?: DocumentConfiguration;
21
18
  /** Overrides for the document */
22
19
  overrides?: PartialDeep<OpenApiDocument>;
23
20
  /** Optional custom fetch implementation to use when retrieving the document. By default the global fetch implementation will be used */
@@ -49,8 +46,6 @@ export type WorkspaceDocumentInput = UrlDoc | ObjectDoc;
49
46
  type WorkspaceProps = {
50
47
  /** Optional metadata for the workspace including theme, active document, etc */
51
48
  meta?: WorkspaceMeta;
52
- /** Workspace configuration */
53
- config?: PartialDeep<Config>;
54
49
  /** Fetch function for retrieving documents */
55
50
  fetch?: WorkspaceDocumentInput['fetch'];
56
51
  /** A list of all registered plugins for the current workspace */
@@ -136,7 +131,7 @@ export type WorkspaceStore = {
136
131
  * }
137
132
  * })
138
133
  */
139
- addDocument(input: WorkspaceDocumentInput): Promise<boolean>;
134
+ addDocument(input: WorkspaceDocumentInput, navigationOptions?: NavigationOptions): Promise<boolean>;
140
135
  /**
141
136
  * Deletes a document from the workspace and all associated data.
142
137
  *
@@ -166,30 +161,6 @@ export type WorkspaceStore = {
166
161
  * ['api', 'petstore'].forEach(name => store.deleteDocument(name))
167
162
  */
168
163
  deleteDocument(documentName: string): void;
169
- /**
170
- * Returns the merged configuration for the active document.
171
- *
172
- * This getter merges configurations in the following order of precedence:
173
- * 1. Document-specific configuration (highest priority)
174
- * 2. Workspace-level configuration
175
- * 3. Default configuration (lowest priority)
176
- *
177
- * The active document is determined by the workspace's activeDocument extension,
178
- * falling back to the first document if none is specified.
179
- */
180
- readonly config: typeof defaultConfig;
181
- /**
182
- * Returns the merged configuration for a specific document.
183
- *
184
- * This method merges configurations in the following order of precedence:
185
- * 1. Document-specific configuration (highest priority)
186
- * 2. Workspace-level configuration
187
- * 3. Default configuration (lowest priority)
188
- *
189
- * @param documentName - The name of the document to get the configuration for
190
- * @returns The merged configuration for the specified document
191
- */
192
- getDocumentConfiguration(documentName: string): typeof defaultConfig;
193
164
  /**
194
165
  * Exports the specified document in the requested format.
195
166
  *
@@ -369,7 +340,7 @@ export type WorkspaceStore = {
369
340
  * @param workspaceProps - Configuration object for the workspace
370
341
  * @param workspaceProps.meta - Optional metadata for the workspace
371
342
  * @param workspaceProps.documents - Optional record of documents to initialize the workspace with
372
- * Documents that require asynchronous loading must be added using `addDocument` after the store is created
343
+ * Documents that require asynchronous loading must be added using `1` after the store is created
373
344
  * this allows atomic awaiting and does not block page load for the store initialization
374
345
  * @returns An object containing methods and getters for managing the workspace
375
346
  */
@@ -1 +1 @@
1
- {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,KAAK,UAAU,EAAe,KAAK,EAAE,MAAM,yBAAyB,CAAA;AAK7E,OAAO,KAAK,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,WAAW,CAAA;AAsB1D,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAA;AAGrE,OAAO,EAEL,KAAK,eAAe,EACrB,MAAM,wCAAwC,CAAA;AAC/C,OAAO,KAAK,EAAE,SAAS,EAAE,qBAAqB,EAAE,mBAAmB,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAA;AAC/G,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,mCAAmC,CAAA;AAC/E,OAAO,KAAK,EAAE,MAAM,EAAE,qBAAqB,EAAE,MAAM,0CAA0C,CAAA;AAC7F,OAAO,KAAK,EAAE,eAAe,EAA6B,MAAM,oBAAoB,CAAA;AASpF,QAAA,MAAM,aAAa,EAAE,YAAY,CAAC,MAAM,CAEvC,CAAA;AAED;;;GAGG;AACH,KAAK,0BAA0B,GAAG;IAChC,wEAAwE;IACxE,IAAI,CAAC,EAAE,qBAAqB,CAAA;IAC5B,kDAAkD;IAClD,IAAI,EAAE,MAAM,CAAA;IACZ,qCAAqC;IACrC,MAAM,CAAC,EAAE,qBAAqB,CAAA;IAC9B,iCAAiC;IACjC,SAAS,CAAC,EAAE,WAAW,CAAC,eAAe,CAAC,CAAA;IACxC,wIAAwI;IACxI,KAAK,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,GAAG,GAAG,GAAG,UAAU,CAAC,OAAO,EAAE,IAAI,CAAC,EAAE,WAAW,KAAK,OAAO,CAAC,QAAQ,CAAC,CAAA;CAC5F,CAAA;AAED;;;GAGG;AACH,MAAM,MAAM,MAAM,GAAG;IACnB,6C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"./helpers/apply-selective-updates.js";
13
13
  import { deepClone } from "./helpers/deep-clone.js";
14
14
  import { createDetectChangesProxy } from "./helpers/detect-changes-proxy.js";
15
15
  import { isObject, safeAssign } from "./helpers/general.js";
16
+ import { getFetch } from "./helpers/get-fetch.js";
16
17
  import { getValueByPath } from "./helpers/json-path-utils.js";
17
18
  import { mergeObjects } from "./helpers/merge-object.js";
18
19
  import { createOverridesProxy, unpackOverridesProxy } from "./helpers/overrides-proxy.js";
@@ -25,16 +26,11 @@ import {
25
26
  refsEverywhere,
26
27
  restoreOriginalRefs
27
28
  } from "./plugins/bundler/index.js";
28
- import { getServersFromDocument } from "./preprocessing/server.js";
29
29
  import { extensions } from "./schemas/extensions.js";
30
- import { defaultReferenceConfig } from "./schemas/reference-config/index.js";
31
30
  import { coerceValue } from "./schemas/typebox-coerce.js";
32
31
  import {
33
32
  OpenAPIDocumentSchema as OpenAPIDocumentSchemaStrict
34
33
  } from "./schemas/v3.1/strict/openapi-document.js";
35
- const defaultConfig = {
36
- "x-scalar-reference-config": defaultReferenceConfig
37
- };
38
34
  function loadDocument(workspaceDocument) {
39
35
  if ("url" in workspaceDocument) {
40
36
  return fetchUrls({ fetch: workspaceDocument.fetch }).exec(workspaceDocument.url);
@@ -127,7 +123,7 @@ const createWorkspaceStore = (workspaceProps) => {
127
123
  }
128
124
  )
129
125
  );
130
- const { originalDocuments, intermediateDocuments, overrides, documentConfigs } = createDetectChangesProxy(
126
+ const { originalDocuments, intermediateDocuments, overrides } = createDetectChangesProxy(
131
127
  {
132
128
  /**
133
129
  * Holds the original, unmodified documents as they were initially loaded into the workspace.
@@ -150,13 +146,6 @@ const createWorkspaceStore = (workspaceProps) => {
150
146
  * - The current in-memory (possibly unsaved) workspace document (`workspace.documents`)
151
147
  */
152
148
  intermediateDocuments: {},
153
- /**
154
- * A map of document configurations keyed by document name.
155
- * This stores the configuration options for each document in the workspace,
156
- * allowing for document-specific settings like navigation options, appearance,
157
- * and other reference configuration.
158
- */
159
- documentConfigs: {},
160
149
  /**
161
150
  * Stores per-document overrides for OpenAPI documents.
162
151
  * This object is used to override specific fields of a document
@@ -197,14 +186,6 @@ const createWorkspaceStore = (workspaceProps) => {
197
186
  };
198
187
  fireWorkspaceChange(event);
199
188
  }
200
- if (type === "documentConfigs") {
201
- const event = {
202
- type,
203
- documentName,
204
- value: unpackProxyObject(documentConfigs[documentName] ?? {})
205
- };
206
- fireWorkspaceChange(event);
207
- }
208
189
  if (type === "overrides") {
209
190
  const event = {
210
191
  type,
@@ -248,24 +229,13 @@ const createWorkspaceStore = (workspaceProps) => {
248
229
  const excludedDiffs = applySelectiveUpdates(intermediateDocument, updatedWithOriginalRefs);
249
230
  return excludedDiffs;
250
231
  }
251
- const processDocument = (input, options) => {
252
- const servers = getServersFromDocument(options["x-scalar-reference-config"]?.settings?.servers ?? input.servers, {
253
- baseServerUrl: options["x-scalar-reference-config"]?.settings?.baseServerUrl,
254
- documentUrl: options.documentSource
255
- });
256
- if (servers.length) {
257
- input.servers = servers.map((it) => ({ url: it.url, description: it.description, variables: it.variables }));
258
- }
259
- return input;
260
- };
261
- async function addInMemoryDocument(input) {
232
+ async function addInMemoryDocument(input, navigationOptions) {
262
233
  const { name, meta } = input;
263
234
  const clonedRawInputDocument = measureSync("deepClone", () => deepClone(input.document));
264
235
  measureSync("initialize", () => {
265
236
  if (input.initialize !== false) {
266
237
  originalDocuments[name] = deepClone(clonedRawInputDocument);
267
238
  intermediateDocuments[name] = deepClone(clonedRawInputDocument);
268
- documentConfigs[name] = input.config ?? {};
269
239
  overrides[name] = input.overrides ?? {};
270
240
  extraDocumentConfigurations[name] = { fetch: input.fetch };
271
241
  }
@@ -319,23 +289,20 @@ const createWorkspaceStore = (workspaceProps) => {
319
289
  );
320
290
  }
321
291
  if (strictDocument[extensions.document.navigation] === void 0) {
322
- const navigation = createNavigation(name, strictDocument, input.config);
292
+ const navigation = createNavigation(name, strictDocument, navigationOptions);
323
293
  strictDocument[extensions.document.navigation] = navigation;
324
- processDocument(getRaw(strictDocument), {
325
- ...documentConfigs[name] ?? {},
326
- documentSource: input.documentSource
327
- });
328
294
  }
329
295
  workspace.documents[name] = createOverridesProxy(createMagicProxy(getRaw(strictDocument)), {
330
296
  overrides: unpackProxyObject(overrides[name])
331
297
  });
332
298
  }
333
- async function addDocument(input) {
299
+ async function addDocument(input, navigationOptions) {
334
300
  const { name, meta } = input;
335
- const resolve = await measureAsync(
336
- "loadDocument",
337
- async () => await loadDocument({ ...input, fetch: input.fetch ?? workspaceProps?.fetch })
338
- );
301
+ const fetch = getFetch({
302
+ fetch: input.fetch ?? workspaceProps?.fetch,
303
+ proxyUrl: workspace["x-scalar-active-proxy"]
304
+ });
305
+ const resolve = await measureAsync("loadDocument", async () => await loadDocument({ ...input, fetch }));
339
306
  return await measureAsync("addDocument", async () => {
340
307
  if (!resolve.ok) {
341
308
  console.error(`Failed to fetch document '${name}': request was not successful`);
@@ -363,12 +330,15 @@ const createWorkspaceStore = (workspaceProps) => {
363
330
  };
364
331
  return false;
365
332
  }
366
- await addInMemoryDocument({
367
- ...input,
368
- document: resolve.data,
369
- documentSource: getDocumentSource(input),
370
- documentHash: generateHash(resolve.raw)
371
- });
333
+ await addInMemoryDocument(
334
+ {
335
+ ...input,
336
+ document: resolve.data,
337
+ documentSource: getDocumentSource(input),
338
+ documentHash: generateHash(resolve.raw)
339
+ },
340
+ navigationOptions
341
+ );
372
342
  return true;
373
343
  });
374
344
  }
@@ -378,17 +348,10 @@ const createWorkspaceStore = (workspaceProps) => {
378
348
  console.error(`Document '${documentName}' does not exist in the workspace.`);
379
349
  return false;
380
350
  }
381
- const navigation = createNavigation(documentName, document, getDocumentConfiguration(documentName));
351
+ const navigation = createNavigation(documentName, document);
382
352
  document[extensions.document.navigation] = navigation;
383
353
  return true;
384
354
  };
385
- const getDocumentConfiguration = (name) => {
386
- return mergeObjects(
387
- mergeObjects(deepClone(defaultConfig), workspaceProps?.config ?? {}, true),
388
- documentConfigs[name] ?? {},
389
- true
390
- );
391
- };
392
355
  const visitedNodesCache = /* @__PURE__ */ new Set();
393
356
  return {
394
357
  get workspace() {
@@ -455,7 +418,6 @@ const createWorkspaceStore = (workspaceProps) => {
455
418
  delete workspace.documents[documentName];
456
419
  delete originalDocuments[documentName];
457
420
  delete intermediateDocuments[documentName];
458
- delete documentConfigs[documentName];
459
421
  delete overrides[documentName];
460
422
  delete extraDocumentConfigurations[documentName];
461
423
  const remainingDocuments = Object.keys(workspace.documents);
@@ -468,10 +430,6 @@ const createWorkspaceStore = (workspaceProps) => {
468
430
  documentName
469
431
  });
470
432
  },
471
- get config() {
472
- return getDocumentConfiguration(getActiveDocumentName());
473
- },
474
- getDocumentConfiguration,
475
433
  exportDocument,
476
434
  exportActiveDocument: (format, minify) => exportDocument(getActiveDocumentName(), format, minify),
477
435
  buildSidebar,
@@ -506,7 +464,6 @@ const createWorkspaceStore = (workspaceProps) => {
506
464
  )
507
465
  },
508
466
  meta: unpackProxyObject(meta) ?? {},
509
- documentConfigs: unpackProxyObject(documentConfigs),
510
467
  originalDocuments: unpackProxyObject(originalDocuments),
511
468
  intermediateDocuments: unpackProxyObject(intermediateDocuments),
512
469
  overrides: unpackProxyObject(overrides)
@@ -526,7 +483,6 @@ const createWorkspaceStore = (workspaceProps) => {
526
483
  );
527
484
  safeAssign(originalDocuments, input.originalDocuments);
528
485
  safeAssign(intermediateDocuments, input.intermediateDocuments);
529
- safeAssign(documentConfigs, input.documentConfigs);
530
486
  safeAssign(overrides, input.overrides);
531
487
  safeAssign(workspace, input.meta);
532
488
  },
@@ -571,7 +527,6 @@ const createWorkspaceStore = (workspaceProps) => {
571
527
  };
572
528
  }
573
529
  const newDocumentOrigin = resolve.data;
574
- documentConfigs[name] = input.config ?? {};
575
530
  overrides[name] = input.overrides ?? {};
576
531
  extraDocumentConfigurations[name] = { fetch: input.fetch };
577
532
  const changelogAA = diff(originalDocument, newDocumentOrigin);