@scalar/workspace-store 0.58.1 → 0.59.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,15 @@
1
1
  # @scalar/workspace-store
2
2
 
3
+ ## 0.59.0
4
+
5
+ ### Minor Changes
6
+
7
+ - feat: test OpenAPI webhooks from the API reference and API client
8
+
9
+ ### Patch Changes
10
+
11
+ - [#9950](https://github.com/scalar/scalar/pull/9950): Shorten AsyncAPI navigation id segments: `asyncapi-channel` → `channel`, `asyncapi-message` → `message`, and `asyncapi-operation` → `operation`. This makes the generated navigation ids (and the URLs, anchors, and DOM ids derived from them) shorter and consistent, e.g. `.../channel/planetevents/operation/subscribe/message/planetcreated`.
12
+
3
13
  ## 0.58.1
4
14
 
5
15
  ### Patch Changes
@@ -42,15 +42,15 @@ export const getNavigationOptions = (documentName, options) => {
42
42
  parentId: props.parentTag.id,
43
43
  })}/`
44
44
  : `${documentId}/`;
45
- return `${prefixTag}asyncapi-channel/${slugify(props.channelName)}`;
45
+ return `${prefixTag}channel/${slugify(props.channelName)}`;
46
46
  }
47
47
  // -------- Default AsyncAPI message id generation logic --------
48
48
  if (props.type === 'asyncapi-message') {
49
- return `${props.parentId}/asyncapi-message/${slugify(props.messageName)}`;
49
+ return `${props.parentId}/message/${slugify(props.messageName)}`;
50
50
  }
51
51
  // -------- Default AsyncAPI operation id generation logic --------
52
52
  if (props.type === 'asyncapi-operation') {
53
- return `${props.parentId}/asyncapi-operation/${slugify(props.operationName)}`;
53
+ return `${props.parentId}/operation/${slugify(props.operationName)}`;
54
54
  }
55
55
  // -------- Default operation id generation logic --------
56
56
  if (props.type === 'operation') {
@@ -1 +1 @@
1
- {"version":3,"file":"get-request-example-context.d.ts","sourceRoot":"","sources":["../../../src/request-example/context/get-request-example-context.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,6BAA6B,CAAA;AAE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AAG,IAAI,CAAA;KACnB,CAAA;IACD,OAAO,EAAE;QACP,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;KAChC,CAAA;IACD,QAAQ,EAAE;QACR,OAAO,EAAE,qBAAqB,CAAA;QAC9B,YAAY,EAAE,yBAAyB,EAAE,CAAA;QACzC,QAAQ,EAAE,gBAAgB,CAAA;QAC1B,eAAe,EAAE,0BAA0B,EAAE,CAAA;QAC7C,IAAI,EAAE,QAAQ,CAAA;KACf,CAAA;CACF,CAAA;AAED,eAAO,MAAM,wBAAwB,GACnC,gBAAgB,cAAc,EAC9B,cAAc,MAAM,EACpB,oBAAoB,kBAAkB,EACtC,UAAS,OAAO,CAAC;IACf,OAAO,EAAE,YAAY,EAAE,CAAA;IACvB,aAAa,EAAE,MAAM,CAAA;IACrB,MAAM,EAAE,MAAM,CAAA;IACd,UAAU,EAAE,MAAM,CAAA;IAClB,UAAU,EAAE,OAAO,CAAA;IACnB,+CAA+C;IAC/C,cAAc,EAAE,2BAA2B,CAAA;IAC3C;;;;OAIG;IACH,gBAAgB,EAAE,iBAAiB,GAAG,IAAI,CAAA;CAC3C,CAAM,KACN,MAAM,CAAC,0BAA0B,CA6InC,CAAA"}
1
+ {"version":3,"file":"get-request-example-context.d.ts","sourceRoot":"","sources":["../../../src/request-example/context/get-request-example-context.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,6BAA6B,CAAA;AAE9E,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,UAAU,CAAA;AAC9C,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAA;AACvD,OAAO,KAAK,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,UAAU,CAAA;AAGpD,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,iDAAiD,CAAA;AAIjG,OAAO,EAAE,KAAK,MAAM,EAAqB,MAAM,iCAAiC,CAAA;AAIhF,OAAO,EAAE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CAAA;CACF,CAAA;AAED,eAAO,MAAM,wBAAwB,GACnC,gBAAgB,cAAc,EAC9B,cAAc,MAAM,EACpB,oBAAoB,kBAAkB,EACtC,UAAS,OAAO,CAAC;IACf,OAAO,EAAE,YAAY,EAAE,CAAA;IACvB,aAAa,EAAE,MAAM,CAAA;IACrB,MAAM,EAAE,MAAM,CAAA;IACd,UAAU,EAAE,MAAM,CAAA;IAClB,UAAU,EAAE,OAAO,CAAA;IACnB,+CAA+C;IAC/C,cAAc,EAAE,2BAA2B,CAAA;IAC3C;;;;OAIG;IACH,gBAAgB,EAAE,iBAAiB,GAAG,IAAI,CAAA;CAC3C,CAAM,KACN,MAAM,CAAC,0BAA0B,CAkJnC,CAAA"}
@@ -11,7 +11,7 @@ import { mergeSecurity } from '../../request-example/context/security/merge-secu
11
11
  import { getSelectedServer, getServers } from '../../request-example/context/servers.js';
12
12
  import { isOpenApiDocument } from '../../schemas/type-guards.js';
13
13
  export const getRequestExampleContext = (workspaceStore, documentName, requestExampleMeta, options = {}) => {
14
- const { path, method, exampleName } = requestExampleMeta;
14
+ const { path, method, exampleName, isWebhook = false } = requestExampleMeta;
15
15
  const document = workspaceStore.workspace.documents[documentName] ?? options.fallbackDocument ?? undefined;
16
16
  if (!document) {
17
17
  return {
@@ -25,18 +25,18 @@ export const getRequestExampleContext = (workspaceStore, documentName, requestEx
25
25
  error: `Document ${documentName} is not an OpenAPI document`,
26
26
  };
27
27
  }
28
- const pathItem = getResolvedPathItem(document.paths?.[path]);
28
+ const pathItem = getResolvedPathItem(isWebhook ? document.webhooks?.[path] : document.paths?.[path]);
29
29
  if (!pathItem) {
30
30
  return {
31
31
  ok: false,
32
- error: `Path ${path} not found`,
32
+ error: isWebhook ? `Webhook ${path} not found` : `Path ${path} not found`,
33
33
  };
34
34
  }
35
- const resolvedOperation = getResolvedRef(getPathItemOperation(document.paths?.[path], method));
35
+ const resolvedOperation = getResolvedRef(getPathItemOperation(pathItem, method));
36
36
  if (!resolvedOperation) {
37
37
  return {
38
38
  ok: false,
39
- error: `Method ${method} not found on path ${path}`,
39
+ error: isWebhook ? `Method ${method} not found on webhook ${path}` : `Method ${method} not found on path ${path}`,
40
40
  };
41
41
  }
42
42
  // Combine the path item and operation parameters
@@ -53,7 +53,10 @@ export const getRequestExampleContext = (workspaceStore, documentName, requestEx
53
53
  // SERVER CONTEXT
54
54
  //------------------------------------------------------------------------------------------------
55
55
  // Get server context for the request example
56
- const serverList = getServers(options.servers ?? operation.servers ?? document.servers, {
56
+ const configuredServers = isWebhook
57
+ ? (options.servers ?? operation.servers)
58
+ : (options.servers ?? operation.servers ?? document.servers);
59
+ const serverList = getServers(configuredServers, {
57
60
  baseServerUrl: options.baseServerUrl,
58
61
  documentUrl: document['x-scalar-original-source-url'],
59
62
  });
@@ -76,7 +79,9 @@ export const getRequestExampleContext = (workspaceStore, documentName, requestEx
76
79
  const selectedSecurity = getSelectedSecurity(documentSelectedSecurity, operationSelectedSecurity, securityRequirements, securitySchemes, options.authentication?.preferredSecurityScheme);
77
80
  /** The above selected requirements in scheme form */
78
81
  const selectedSecuritySchemes = getSecuritySchemes(securitySchemes, selectedSecurity.selectedSchemes[selectedSecurity.selectedIndex] ?? {});
79
- const serverMeta = operation.servers != null ? { type: 'operation', path: path ?? '', method: method ?? 'get' } : { type: 'document' };
82
+ const serverMeta = !isWebhook && operation.servers != null
83
+ ? { type: 'operation', path: path ?? '', method: method ?? 'get' }
84
+ : { type: 'document' };
80
85
  const authMeta = operationSelectedSecurity !== undefined
81
86
  ? { type: 'operation', path: path ?? '', method: method ?? 'get' }
82
87
  : { type: 'document' };
@@ -6,8 +6,11 @@ import type { HttpMethod } from '@scalar/helpers/http/http-methods';
6
6
  */
7
7
  export type { Result } from '@scalar/helpers/types/result';
8
8
  export type RequestExampleMeta = {
9
+ /** API path, or webhook name when `isWebhook` is true. */
9
10
  path: string;
10
11
  method: HttpMethod;
11
12
  exampleName: string;
13
+ /** Resolve the operation from `document.webhooks` instead of `document.paths`. */
14
+ isWebhook?: boolean;
12
15
  };
13
16
  //# sourceMappingURL=types.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/request-example/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mCAAmC,CAAA;AAEnE;;;;GAIG;AACH,YAAY,EAAE,MAAM,EAAE,MAAM,8BAA8B,CAAA;AAE1D,MAAM,MAAM,kBAAkB,GAAG;IAC/B,IAAI,EAAE,MAAM,CAAA;IACZ,MAAM,EAAE,UAAU,CAAA;IAClB,WAAW,EAAE,MAAM,CAAA;CACpB,CAAA"}
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/request-example/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mCAAmC,CAAA;AAEnE;;;;GAIG;AACH,YAAY,EAAE,MAAM,EAAE,MAAM,8BAA8B,CAAA;AAE1D,MAAM,MAAM,kBAAkB,GAAG;IAC/B,0DAA0D;IAC1D,IAAI,EAAE,MAAM,CAAA;IACZ,MAAM,EAAE,UAAU,CAAA;IAClB,WAAW,EAAE,MAAM,CAAA;IACnB,kFAAkF;IAClF,SAAS,CAAC,EAAE,OAAO,CAAA;CACpB,CAAA"}
package/package.json CHANGED
@@ -16,7 +16,7 @@
16
16
  "openapi",
17
17
  "scalar"
18
18
  ],
19
- "version": "0.58.1",
19
+ "version": "0.59.0",
20
20
  "engines": {
21
21
  "node": ">=22"
22
22
  },
@@ -148,13 +148,13 @@
148
148
  "type-fest": "^5.8.0",
149
149
  "vue": "^3.5.40",
150
150
  "yaml": "^2.9.0",
151
- "@scalar/asyncapi-upgrader": "0.1.7",
152
- "@scalar/helpers": "0.11.1",
153
- "@scalar/json-magic": "0.13.2",
151
+ "@scalar/asyncapi-upgrader": "0.1.8",
152
+ "@scalar/json-magic": "0.13.3",
154
153
  "@scalar/openapi-upgrader": "0.2.15",
155
- "@scalar/schemas": "0.8.3",
156
- "@scalar/snippetz": "0.9.28",
157
- "@scalar/types": "0.18.2",
154
+ "@scalar/schemas": "0.8.4",
155
+ "@scalar/helpers": "0.11.2",
156
+ "@scalar/snippetz": "0.9.29",
157
+ "@scalar/types": "0.18.3",
158
158
  "@scalar/validation": "0.6.3"
159
159
  },
160
160
  "devDependencies": {