@scalar/workspace-store 0.52.0 → 0.53.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 +19 -0
- package/dist/channel-example/build-connection-url.d.ts.map +1 -1
- package/dist/channel-example/build-connection-url.js +11 -8
- package/dist/channel-example/get-all-channel-messages.d.ts +10 -0
- package/dist/channel-example/get-all-channel-messages.d.ts.map +1 -0
- package/dist/channel-example/get-all-channel-messages.js +16 -0
- package/dist/channel-example/get-asyncapi-security-requirements.d.ts +7 -0
- package/dist/channel-example/get-asyncapi-security-requirements.d.ts.map +1 -0
- package/dist/channel-example/get-asyncapi-security-requirements.js +76 -0
- package/dist/channel-example/get-channel-connection-context.d.ts +16 -0
- package/dist/channel-example/get-channel-connection-context.d.ts.map +1 -0
- package/dist/channel-example/get-channel-connection-context.js +120 -0
- package/dist/channel-example/get-channel-connection-security.d.ts +8 -0
- package/dist/channel-example/get-channel-connection-security.d.ts.map +1 -0
- package/dist/channel-example/get-channel-connection-security.js +20 -0
- package/dist/channel-example/get-channel-operations.d.ts +11 -0
- package/dist/channel-example/get-channel-operations.d.ts.map +1 -0
- package/dist/channel-example/get-channel-operations.js +20 -0
- package/dist/channel-example/get-channel-parameters.d.ts +14 -0
- package/dist/channel-example/get-channel-parameters.d.ts.map +1 -0
- package/dist/channel-example/get-channel-parameters.js +59 -0
- package/dist/channel-example/index.d.ts +15 -0
- package/dist/channel-example/index.d.ts.map +1 -1
- package/dist/channel-example/index.js +9 -0
- package/dist/channel-example/resolve-channel.d.ts +11 -0
- package/dist/channel-example/resolve-channel.d.ts.map +1 -0
- package/dist/channel-example/resolve-channel.js +13 -0
- package/dist/channel-example/resolve-operation-channel.d.ts +11 -0
- package/dist/channel-example/resolve-operation-channel.d.ts.map +1 -0
- package/dist/channel-example/resolve-operation-channel.js +39 -0
- package/dist/channel-example/resolve-operation-with-traits.d.ts +6 -0
- package/dist/channel-example/resolve-operation-with-traits.d.ts.map +1 -0
- package/dist/channel-example/resolve-operation-with-traits.js +41 -0
- package/dist/channel-example/servers.d.ts.map +1 -1
- package/dist/channel-example/servers.js +23 -0
- package/dist/channel-example/types.d.ts +41 -0
- package/dist/channel-example/types.d.ts.map +1 -0
- package/dist/channel-example/types.js +1 -0
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +8 -8
- package/dist/entities/auth/schema.d.ts +1184 -59
- package/dist/entities/auth/schema.d.ts.map +1 -1
- package/dist/helpers/get-name-from-ref.d.ts +15 -0
- package/dist/helpers/get-name-from-ref.d.ts.map +1 -0
- package/dist/helpers/get-name-from-ref.js +37 -0
- package/dist/navigation/get-navigation-options.d.ts +2 -2
- package/dist/navigation/get-navigation-options.d.ts.map +1 -1
- package/dist/navigation/get-navigation-options.js +26 -3
- package/dist/navigation/helpers/traverse-asyncapi-document.d.ts +23 -0
- package/dist/navigation/helpers/traverse-asyncapi-document.d.ts.map +1 -0
- package/dist/navigation/helpers/traverse-asyncapi-document.js +479 -0
- package/dist/navigation/helpers/traverse-description.d.ts +4 -3
- package/dist/navigation/helpers/traverse-description.d.ts.map +1 -1
- package/dist/navigation/helpers/traverse-description.js +2 -2
- package/dist/navigation/helpers/traverse-document.d.ts.map +1 -1
- package/dist/navigation/helpers/traverse-document.js +3 -3
- package/dist/navigation/index.d.ts +1 -0
- package/dist/navigation/index.d.ts.map +1 -1
- package/dist/navigation/index.js +1 -0
- package/dist/navigation/types.d.ts +3 -0
- package/dist/navigation/types.d.ts.map +1 -1
- package/dist/schemas/navigation.d.ts +113 -4
- package/dist/schemas/navigation.d.ts.map +1 -1
- package/dist/schemas/navigation.js +22 -0
- package/dist/schemas/reference-config/index.d.ts +233 -8
- package/dist/schemas/reference-config/index.d.ts.map +1 -1
- package/dist/schemas/reference-config/settings.d.ts +233 -8
- package/dist/schemas/reference-config/settings.d.ts.map +1 -1
- package/dist/schemas/v3.1/openapi/index.d.ts.map +1 -1
- package/dist/schemas/v3.1/openapi/index.js +59 -17
- package/dist/schemas/v3.1/strict/openapi-document.d.ts +9446 -1571
- package/dist/schemas/v3.1/strict/openapi-document.d.ts.map +1 -1
- package/dist/schemas/v3.1/strict/openapi-document.js +4 -1
- package/dist/schemas/v3.1/strict/ref-definitions.d.ts +3 -0
- package/dist/schemas/v3.1/strict/ref-definitions.d.ts.map +1 -1
- package/dist/schemas/v3.1/strict/ref-definitions.js +3 -0
- package/dist/schemas/v3.1/strict/schema.d.ts +259 -26
- package/dist/schemas/v3.1/strict/schema.d.ts.map +1 -1
- package/dist/schemas/v3.1/strict/schema.js +37 -28
- package/package.json +7 -7
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,24 @@
|
|
|
1
1
|
# @scalar/workspace-store
|
|
2
2
|
|
|
3
|
+
## 0.53.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [#9340](https://github.com/scalar/scalar/pull/9340): feat: add getChannelConnectionContext for AsyncAPI WebSocket channels
|
|
8
|
+
|
|
9
|
+
Add channel connection context helpers that resolve channel, messages, parameters, servers, security, and connection URL for WebSocket client UI.
|
|
10
|
+
|
|
11
|
+
- [#9372](https://github.com/scalar/scalar/pull/9372): Render AsyncAPI `components.schemas` as Models, listed in the sidebar and content just like OpenAPI schemas
|
|
12
|
+
- [#9331](https://github.com/scalar/scalar/pull/9331): feat: generate AsyncAPI sidebar navigation on document ingest
|
|
13
|
+
|
|
14
|
+
Add `TraversedAsyncApiChannel`, `TraversedAsyncApiOperation`, and `TraversedAsyncApiMessage` navigation entry types, plus `traverseAsyncApiDocument` wired into the AsyncAPI ingest path. Navigation is structured as channel → operation → message, with messages resolved per operation (all channel messages by default, or filtered via `operation.messages`).
|
|
15
|
+
|
|
16
|
+
### Patch Changes
|
|
17
|
+
|
|
18
|
+
- [#9255](https://github.com/scalar/scalar/pull/9255): Surface the Introduction entry and any headings extracted from `info.description` of AsyncAPI documents in the sidebar, mirroring how OpenAPI documents are handled.
|
|
19
|
+
- [#9309](https://github.com/scalar/scalar/pull/9309): feat: add `modelsSectionLabel` configuration (`'Models' | 'Schemas' | string`) to use OpenAPI-style Schemas terminology in the sidebar, content, and search.
|
|
20
|
+
- [#9383](https://github.com/scalar/scalar/pull/9383): fix: preserve multi-type schema arrays when coercing schemas with validation keywords
|
|
21
|
+
|
|
3
22
|
## 0.52.0
|
|
4
23
|
|
|
5
24
|
### Minor Changes
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"build-connection-url.d.ts","sourceRoot":"","sources":["../../src/channel-example/build-connection-url.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EACV,qBAAqB,EACrB,uBAAuB,EACvB,oBAAoB,EACpB,uBAAuB,EACxB,MAAM,4BAA4B,CAAA;AAInC,2FAA2F;AAC3F,eAAO,MAAM,4BAA4B,wBAAyB,CAAA;AAElE,MAAM,MAAM,yBAAyB,GAAG,CAAC,OAAO,4BAA4B,CAAC,CAAC,MAAM,CAAC,CAAA;AAErF,MAAM,MAAM,uBAAuB,GAAG;IACpC,MAAM,EAAE,oBAAoB,CAAA;IAC5B,OAAO,EAAE,qBAAqB,CAAA;IAC9B,SAAS,CAAC,EAAE,uBAAuB,GAAG,IAAI,CAAA;IAC1C,cAAc,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IACvC,eAAe,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IACxC,oBAAoB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,MAAM,KAAK,MAAM,GAAG,IAAI,CAAC,CAAA;CACjF,CAAA;AAQD;;GAEG;AACH,eAAO,MAAM,0BAA0B,GAAI,QAAQ,oBAAoB,GAAG,IAAI,KAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAYrG,CAAA;AAoBD,yEAAyE;AACzE,eAAO,MAAM,wBAAwB,GAAI,UAAU,MAAM,KAAG,MAAuC,CAAA;AAEnG,eAAO,MAAM,mBAAmB,GAAI,UAAU,MAAM,KAAG,QAAQ,IAAI,yBAC0B,CAAA;AAE7F;;GAEG;AACH,eAAO,MAAM,0BAA0B,GACrC,QAAQ,oBAAoB,EAC5B,uBAAuB,uBAAuB,CAAC,sBAAsB,CAAC,KACrE,MAYF,CAAA;AAaD,0FAA0F;AAC1F,eAAO,MAAM,eAAe,GAC1B,SAAS,qBAAqB,EAC9B,YAAY,uBAAuB,GAAG,IAAI,KACzC,uBAAuB,GAAG,SAa5B,CAAA;
|
|
1
|
+
{"version":3,"file":"build-connection-url.d.ts","sourceRoot":"","sources":["../../src/channel-example/build-connection-url.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EACV,qBAAqB,EACrB,uBAAuB,EACvB,oBAAoB,EACpB,uBAAuB,EACxB,MAAM,4BAA4B,CAAA;AAInC,2FAA2F;AAC3F,eAAO,MAAM,4BAA4B,wBAAyB,CAAA;AAElE,MAAM,MAAM,yBAAyB,GAAG,CAAC,OAAO,4BAA4B,CAAC,CAAC,MAAM,CAAC,CAAA;AAErF,MAAM,MAAM,uBAAuB,GAAG;IACpC,MAAM,EAAE,oBAAoB,CAAA;IAC5B,OAAO,EAAE,qBAAqB,CAAA;IAC9B,SAAS,CAAC,EAAE,uBAAuB,GAAG,IAAI,CAAA;IAC1C,cAAc,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IACvC,eAAe,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IACxC,oBAAoB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,MAAM,KAAK,MAAM,GAAG,IAAI,CAAC,CAAA;CACjF,CAAA;AAQD;;GAEG;AACH,eAAO,MAAM,0BAA0B,GAAI,QAAQ,oBAAoB,GAAG,IAAI,KAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAYrG,CAAA;AAoBD,yEAAyE;AACzE,eAAO,MAAM,wBAAwB,GAAI,UAAU,MAAM,KAAG,MAAuC,CAAA;AAEnG,eAAO,MAAM,mBAAmB,GAAI,UAAU,MAAM,KAAG,QAAQ,IAAI,yBAC0B,CAAA;AAE7F;;GAEG;AACH,eAAO,MAAM,0BAA0B,GACrC,QAAQ,oBAAoB,EAC5B,uBAAuB,uBAAuB,CAAC,sBAAsB,CAAC,KACrE,MAYF,CAAA;AAaD,0FAA0F;AAC1F,eAAO,MAAM,eAAe,GAC1B,SAAS,qBAAqB,EAC9B,YAAY,uBAAuB,GAAG,IAAI,KACzC,uBAAuB,GAAG,SAa5B,CAAA;AA0FD;;;GAGG;AACH,eAAO,MAAM,kBAAkB,GAC7B,WAAW,uBAAuB,GAAG,SAAS,EAC9C,kBAAkB,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,KACvC,eAoBF,CAAA;AAED;;;;;;;;;GASG;AACH,eAAO,MAAM,kBAAkB,GAAI,wFAOhC,uBAAuB,KAAG,MAkB5B,CAAA"}
|
|
@@ -92,16 +92,18 @@ const mergeWsQuerySchemas = (channelQuery, operationQuery) => {
|
|
|
92
92
|
if (!operationSchema) {
|
|
93
93
|
return channelQuery;
|
|
94
94
|
}
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
95
|
+
// `properties` only exists on the object-schema branch of the Schema Object union,
|
|
96
|
+
// so reach it through an `in` check rather than assuming it is present.
|
|
97
|
+
const channelProperties = 'properties' in channelSchema ? channelSchema.properties : undefined;
|
|
98
|
+
const operationProperties = 'properties' in operationSchema ? operationSchema.properties : undefined;
|
|
99
|
+
// Merge via Object.assign so the result is an intersection of the two schemas rather than a
|
|
100
|
+
// distributed union of every Schema Object variant, which keeps it assignable to the query type.
|
|
101
|
+
return Object.assign({}, channelSchema, operationSchema, {
|
|
100
102
|
properties: {
|
|
101
103
|
...channelProperties,
|
|
102
104
|
...operationProperties,
|
|
103
105
|
},
|
|
104
|
-
};
|
|
106
|
+
});
|
|
105
107
|
};
|
|
106
108
|
const getDefaultValueFromPropertySchema = (propertySchema) => {
|
|
107
109
|
if (propertySchema === true || propertySchema === false || !isObject(propertySchema)) {
|
|
@@ -139,8 +141,9 @@ const appendQueryValue = (params, key, value) => {
|
|
|
139
141
|
export const buildWsQueryParams = (wsBinding, queryParameters) => {
|
|
140
142
|
const params = new URLSearchParams();
|
|
141
143
|
const querySchema = resolveWsQuerySchema(wsBinding?.query);
|
|
142
|
-
|
|
143
|
-
|
|
144
|
+
const properties = querySchema && 'properties' in querySchema ? querySchema.properties : undefined;
|
|
145
|
+
if (isObject(properties)) {
|
|
146
|
+
for (const [name, propertySchema] of Object.entries(properties)) {
|
|
144
147
|
const defaultValue = getDefaultValueFromPropertySchema(propertySchema);
|
|
145
148
|
appendQueryValue(params, name, defaultValue);
|
|
146
149
|
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { AsyncApiChannelObject, AsyncApiDocument, AsyncApiMessageObject } from '@scalar/types/asyncapi/3.1';
|
|
2
|
+
export type ChannelMessageEntry = {
|
|
3
|
+
name: string;
|
|
4
|
+
message: AsyncApiMessageObject;
|
|
5
|
+
};
|
|
6
|
+
/**
|
|
7
|
+
* Resolves every message defined on a channel (AsyncAPI data store for payloads).
|
|
8
|
+
*/
|
|
9
|
+
export declare const getAllChannelMessages: (_document: AsyncApiDocument, channel: AsyncApiChannelObject) => ChannelMessageEntry[];
|
|
10
|
+
//# sourceMappingURL=get-all-channel-messages.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-all-channel-messages.d.ts","sourceRoot":"","sources":["../../src/channel-example/get-all-channel-messages.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,qBAAqB,EAAE,gBAAgB,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAA;AAIhH,MAAM,MAAM,mBAAmB,GAAG;IAChC,IAAI,EAAE,MAAM,CAAA;IACZ,OAAO,EAAE,qBAAqB,CAAA;CAC/B,CAAA;AAED;;GAEG;AACH,eAAO,MAAM,qBAAqB,GAChC,WAAW,gBAAgB,EAC3B,SAAS,qBAAqB,KAC7B,mBAAmB,EAWrB,CAAA"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { objectEntries } from '@scalar/helpers/object/object-entries';
|
|
2
|
+
import { getResolvedRef } from '../helpers/get-resolved-ref.js';
|
|
3
|
+
/**
|
|
4
|
+
* Resolves every message defined on a channel (AsyncAPI data store for payloads).
|
|
5
|
+
*/
|
|
6
|
+
export const getAllChannelMessages = (_document, channel) => {
|
|
7
|
+
if (!channel.messages) {
|
|
8
|
+
return [];
|
|
9
|
+
}
|
|
10
|
+
return objectEntries(channel.messages)
|
|
11
|
+
.map(([name, messageRef]) => {
|
|
12
|
+
const message = getResolvedRef(messageRef);
|
|
13
|
+
return { name, message };
|
|
14
|
+
})
|
|
15
|
+
.filter((entry) => entry.message != null);
|
|
16
|
+
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { AsyncApiDocument, AsyncApiOperationObject, AsyncApiServerObject } from '@scalar/types/asyncapi/3.1';
|
|
2
|
+
import type { SecurityRequirementObject } from '../schemas/v3.1/strict/security-requirement.js';
|
|
3
|
+
/**
|
|
4
|
+
* Converts AsyncAPI security arrays (operation, traits, server) into OpenAPI-style requirement objects.
|
|
5
|
+
*/
|
|
6
|
+
export declare const getAsyncApiSecurityRequirements: (document: AsyncApiDocument, operation?: AsyncApiOperationObject | null, server?: AsyncApiServerObject | null) => SecurityRequirementObject[];
|
|
7
|
+
//# sourceMappingURL=get-asyncapi-security-requirements.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-asyncapi-security-requirements.d.ts","sourceRoot":"","sources":["../../src/channel-example/get-asyncapi-security-requirements.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,gBAAgB,EAChB,uBAAuB,EAEvB,oBAAoB,EACrB,MAAM,4BAA4B,CAAA;AAInC,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,4CAA4C,CAAA;AA6E3F;;GAEG;AACH,eAAO,MAAM,+BAA+B,GAC1C,UAAU,gBAAgB,EAC1B,YAAY,uBAAuB,GAAG,IAAI,EAC1C,SAAS,oBAAoB,GAAG,IAAI,KACnC,yBAAyB,EAqB3B,CAAA"}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { isObjectEqual } from '@scalar/helpers/object/is-object-equal';
|
|
2
|
+
import { getNameFromRef } from '../helpers/get-name-from-ref.js';
|
|
3
|
+
import { getResolvedRef } from '../helpers/get-resolved-ref.js';
|
|
4
|
+
const getSecuritySchemeNameFromRef = (ref) => getNameFromRef(ref, ['components', 'securitySchemes']);
|
|
5
|
+
/** Strips requirement-only `scopes` so inline entries can match component scheme definitions. */
|
|
6
|
+
const getSecuritySchemeDefinition = (entry) => {
|
|
7
|
+
const resolved = getResolvedRef(entry);
|
|
8
|
+
if (resolved == null) {
|
|
9
|
+
return undefined;
|
|
10
|
+
}
|
|
11
|
+
if (!('scopes' in resolved)) {
|
|
12
|
+
return resolved;
|
|
13
|
+
}
|
|
14
|
+
const { scopes: _scopes, ...scheme } = resolved;
|
|
15
|
+
return scheme;
|
|
16
|
+
};
|
|
17
|
+
const getSecuritySchemeName = (document, entry) => {
|
|
18
|
+
if ('$ref' in entry) {
|
|
19
|
+
const nameFromRef = getSecuritySchemeNameFromRef(entry.$ref);
|
|
20
|
+
if (nameFromRef) {
|
|
21
|
+
return nameFromRef;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
const resolvedDefinition = getSecuritySchemeDefinition(entry);
|
|
25
|
+
if (resolvedDefinition == null) {
|
|
26
|
+
return undefined;
|
|
27
|
+
}
|
|
28
|
+
const components = document.components ? getResolvedRef(document.components) : undefined;
|
|
29
|
+
if (components?.securitySchemes) {
|
|
30
|
+
for (const [name, schemeRef] of Object.entries(components.securitySchemes)) {
|
|
31
|
+
const scheme = getResolvedRef(schemeRef);
|
|
32
|
+
if (scheme === resolvedDefinition || isObjectEqual(scheme, resolvedDefinition)) {
|
|
33
|
+
return name;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
return undefined;
|
|
38
|
+
};
|
|
39
|
+
const securityEntryToRequirement = (document, entry) => {
|
|
40
|
+
const schemeName = getSecuritySchemeName(document, entry);
|
|
41
|
+
if (!schemeName) {
|
|
42
|
+
return undefined;
|
|
43
|
+
}
|
|
44
|
+
const resolved = getResolvedRef(entry);
|
|
45
|
+
const scopes = resolved != null && 'scopes' in resolved && Array.isArray(resolved.scopes) ? [...resolved.scopes] : [];
|
|
46
|
+
return { [schemeName]: scopes };
|
|
47
|
+
};
|
|
48
|
+
const collectSecurityRequirements = (document, security) => {
|
|
49
|
+
if (!security?.length) {
|
|
50
|
+
return [];
|
|
51
|
+
}
|
|
52
|
+
return security
|
|
53
|
+
.map((entry) => securityEntryToRequirement(document, entry))
|
|
54
|
+
.filter((requirement) => requirement != null);
|
|
55
|
+
};
|
|
56
|
+
/**
|
|
57
|
+
* Converts AsyncAPI security arrays (operation, traits, server) into OpenAPI-style requirement objects.
|
|
58
|
+
*/
|
|
59
|
+
export const getAsyncApiSecurityRequirements = (document, operation, server) => {
|
|
60
|
+
const operationRequirements = collectSecurityRequirements(document, operation?.security);
|
|
61
|
+
const serverRequirements = collectSecurityRequirements(document, server?.security);
|
|
62
|
+
const combined = operationRequirements.length === 0
|
|
63
|
+
? serverRequirements
|
|
64
|
+
: serverRequirements.length === 0
|
|
65
|
+
? operationRequirements
|
|
66
|
+
: [...operationRequirements, ...serverRequirements];
|
|
67
|
+
const seen = new Set();
|
|
68
|
+
return combined.filter((requirement) => {
|
|
69
|
+
const key = JSON.stringify(requirement);
|
|
70
|
+
if (seen.has(key)) {
|
|
71
|
+
return false;
|
|
72
|
+
}
|
|
73
|
+
seen.add(key);
|
|
74
|
+
return true;
|
|
75
|
+
});
|
|
76
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { AuthenticationConfiguration } from '@scalar/types/api-reference';
|
|
2
|
+
import type { BuildChannelConnectionContext, ChannelConnectionMeta } from '../channel-example/types.js';
|
|
3
|
+
import type { WorkspaceStore } from '../client.js';
|
|
4
|
+
import type { Result } from '../request-example/types.js';
|
|
5
|
+
import type { WorkspaceDocument } from '../schemas/workspace.js';
|
|
6
|
+
/**
|
|
7
|
+
* Builds context for testing a WebSocket channel (Postman-style): one connection per channel,
|
|
8
|
+
* with AsyncAPI messages, servers, and parameters as the data store.
|
|
9
|
+
*/
|
|
10
|
+
export declare const getChannelConnectionContext: (workspaceStore: WorkspaceStore, documentName: string, channelConnectionMeta: ChannelConnectionMeta, options?: Partial<{
|
|
11
|
+
pathParameters: Record<string, string>;
|
|
12
|
+
queryParameters: Record<string, string>;
|
|
13
|
+
authentication: AuthenticationConfiguration;
|
|
14
|
+
fallbackDocument: WorkspaceDocument | null;
|
|
15
|
+
}>) => Result<BuildChannelConnectionContext>;
|
|
16
|
+
//# sourceMappingURL=get-channel-connection-context.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-channel-connection-context.d.ts","sourceRoot":"","sources":["../../src/channel-example/get-channel-connection-context.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,6BAA6B,CAAA;AAS9E,OAAO,KAAK,EAAE,6BAA6B,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAA;AACnG,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,UAAU,CAAA;AAQ9C,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAA;AAGrD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAA;AAK5D;;;GAGG;AACH,eAAO,MAAM,2BAA2B,GACtC,gBAAgB,cAAc,EAC9B,cAAc,MAAM,EACpB,uBAAuB,qBAAqB,EAC5C,UAAS,OAAO,CAAC;IACf,cAAc,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IACtC,eAAe,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IACvC,cAAc,EAAE,2BAA2B,CAAA;IAC3C,gBAAgB,EAAE,iBAAiB,GAAG,IAAI,CAAA;CAC3C,CAAM,KACN,MAAM,CAAC,6BAA6B,CAwItC,CAAA"}
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
import { buildConnectionUrl } from '../channel-example/build-connection-url.js';
|
|
2
|
+
import { getAllChannelMessages } from '../channel-example/get-all-channel-messages.js';
|
|
3
|
+
import { getChannelConnectionSecurityRequirements } from '../channel-example/get-channel-connection-security.js';
|
|
4
|
+
import { getChannelOperations } from '../channel-example/get-channel-operations.js';
|
|
5
|
+
import { getChannelParameters } from '../channel-example/get-channel-parameters.js';
|
|
6
|
+
import { resolveChannel } from '../channel-example/resolve-channel.js';
|
|
7
|
+
import { getAsyncApiServers, getSelectedAsyncApiServer } from '../channel-example/servers.js';
|
|
8
|
+
import { getResolvedRef } from '../helpers/get-resolved-ref.js';
|
|
9
|
+
import { getEnvironmentVariables } from '../request-example/builder/helpers/get-environment-variables.js';
|
|
10
|
+
import { getActiveEnvironment } from '../request-example/context/environment.js';
|
|
11
|
+
import { getSecuritySchemes } from '../request-example/context/security/get-security-schemes.js';
|
|
12
|
+
import { getSelectedSecurity } from '../request-example/context/security/get-selected-security.js';
|
|
13
|
+
import { mergeSecurity } from '../request-example/context/security/merge-security.js';
|
|
14
|
+
import { isAsyncApiDocument } from '../schemas/type-guards.js';
|
|
15
|
+
/** Uses channel name as the auth path key for AsyncAPI channel connections. */
|
|
16
|
+
const ASYNCAPI_CHANNEL_AUTH_METHOD = 'get';
|
|
17
|
+
/**
|
|
18
|
+
* Builds context for testing a WebSocket channel (Postman-style): one connection per channel,
|
|
19
|
+
* with AsyncAPI messages, servers, and parameters as the data store.
|
|
20
|
+
*/
|
|
21
|
+
export const getChannelConnectionContext = (workspaceStore, documentName, channelConnectionMeta, options = {}) => {
|
|
22
|
+
const { channelName } = channelConnectionMeta;
|
|
23
|
+
const document = workspaceStore.workspace.documents[documentName] ?? options.fallbackDocument ?? undefined;
|
|
24
|
+
if (!document) {
|
|
25
|
+
return {
|
|
26
|
+
ok: false,
|
|
27
|
+
error: `Document ${documentName} not found`,
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
if (!isAsyncApiDocument(document)) {
|
|
31
|
+
return {
|
|
32
|
+
ok: false,
|
|
33
|
+
error: `Document ${documentName} is not an AsyncAPI document`,
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
const resolvedChannel = resolveChannel(document, channelName);
|
|
37
|
+
if (!resolvedChannel) {
|
|
38
|
+
return {
|
|
39
|
+
ok: false,
|
|
40
|
+
error: `Channel ${channelName} not found`,
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
const { channel, channelAddress } = resolvedChannel;
|
|
44
|
+
const environment = getActiveEnvironment(workspaceStore, document);
|
|
45
|
+
const environmentVariables = getEnvironmentVariables(environment.environment);
|
|
46
|
+
const channelOperations = getChannelOperations(document, channelName);
|
|
47
|
+
const parameters = getChannelParameters(channel, null, {
|
|
48
|
+
path: options.pathParameters,
|
|
49
|
+
query: options.queryParameters,
|
|
50
|
+
});
|
|
51
|
+
const servers = getAsyncApiServers(document, {
|
|
52
|
+
channel,
|
|
53
|
+
operation: null,
|
|
54
|
+
pathParameters: parameters.path,
|
|
55
|
+
queryParameters: parameters.query,
|
|
56
|
+
environmentVariables,
|
|
57
|
+
});
|
|
58
|
+
const selectedServer = getSelectedAsyncApiServer(document, servers, null);
|
|
59
|
+
const serverForUrl = selectedServer?.server ?? servers[0]?.server;
|
|
60
|
+
if (!serverForUrl) {
|
|
61
|
+
return {
|
|
62
|
+
ok: false,
|
|
63
|
+
error: `No WebSocket servers available for channel ${channelName}`,
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
const connectionUrl = selectedServer?.connectionUrl ??
|
|
67
|
+
buildConnectionUrl({
|
|
68
|
+
server: serverForUrl,
|
|
69
|
+
channel,
|
|
70
|
+
operation: null,
|
|
71
|
+
pathParameters: parameters.path,
|
|
72
|
+
queryParameters: parameters.query,
|
|
73
|
+
environmentVariables,
|
|
74
|
+
});
|
|
75
|
+
const messages = getAllChannelMessages(document, channel);
|
|
76
|
+
const selectedMessage = messages[0] ?? null;
|
|
77
|
+
const documentSelectedSecurity = workspaceStore.auth.getAuthSelectedSchemas({
|
|
78
|
+
type: 'document',
|
|
79
|
+
documentName,
|
|
80
|
+
});
|
|
81
|
+
const channelSelectedSecurity = workspaceStore.auth.getAuthSelectedSchemas({
|
|
82
|
+
type: 'operation',
|
|
83
|
+
documentName,
|
|
84
|
+
path: channelName,
|
|
85
|
+
method: ASYNCAPI_CHANNEL_AUTH_METHOD,
|
|
86
|
+
});
|
|
87
|
+
const components = document.components ? getResolvedRef(document.components) : undefined;
|
|
88
|
+
const securitySchemes = mergeSecurity((components?.securitySchemes ?? {}), options.authentication?.securitySchemes ?? {}, workspaceStore.auth, documentName);
|
|
89
|
+
const securityRequirements = getChannelConnectionSecurityRequirements(document, channel, selectedServer?.server ?? null, channelOperations);
|
|
90
|
+
const selectedSecurity = getSelectedSecurity(documentSelectedSecurity, channelSelectedSecurity, securityRequirements, securitySchemes, options.authentication?.preferredSecurityScheme);
|
|
91
|
+
const selectedSecuritySchemes = getSecuritySchemes(securitySchemes, selectedSecurity.selectedSchemes[selectedSecurity.selectedIndex] ?? {});
|
|
92
|
+
const authMeta = channelSelectedSecurity
|
|
93
|
+
? { type: 'operation', path: channelName, method: ASYNCAPI_CHANNEL_AUTH_METHOD }
|
|
94
|
+
: { type: 'document' };
|
|
95
|
+
return {
|
|
96
|
+
ok: true,
|
|
97
|
+
data: {
|
|
98
|
+
channel,
|
|
99
|
+
channelName,
|
|
100
|
+
channelAddress,
|
|
101
|
+
operations: channelOperations,
|
|
102
|
+
messages,
|
|
103
|
+
selectedMessage,
|
|
104
|
+
servers: {
|
|
105
|
+
list: servers,
|
|
106
|
+
selected: selectedServer,
|
|
107
|
+
},
|
|
108
|
+
connectionUrl,
|
|
109
|
+
parameters,
|
|
110
|
+
security: {
|
|
111
|
+
schemes: securitySchemes,
|
|
112
|
+
requirements: securityRequirements,
|
|
113
|
+
selected: selectedSecurity,
|
|
114
|
+
selectedSchemes: selectedSecuritySchemes,
|
|
115
|
+
meta: authMeta,
|
|
116
|
+
},
|
|
117
|
+
environment,
|
|
118
|
+
},
|
|
119
|
+
};
|
|
120
|
+
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { AsyncApiChannelObject, AsyncApiDocument, AsyncApiServerObject } from '@scalar/types/asyncapi/3.1';
|
|
2
|
+
import type { SecurityRequirementObject } from '../schemas/v3.1/strict/security-requirement.js';
|
|
3
|
+
import type { ChannelOperationSummary } from './get-channel-operations.js';
|
|
4
|
+
/**
|
|
5
|
+
* Merges security requirements from the selected server and all operations on a channel.
|
|
6
|
+
*/
|
|
7
|
+
export declare const getChannelConnectionSecurityRequirements: (document: AsyncApiDocument, _channel: AsyncApiChannelObject, server: AsyncApiServerObject | null, channelOperations: ChannelOperationSummary[]) => SecurityRequirementObject[];
|
|
8
|
+
//# sourceMappingURL=get-channel-connection-security.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-channel-connection-security.d.ts","sourceRoot":"","sources":["../../src/channel-example/get-channel-connection-security.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,gBAAgB,EAAE,oBAAoB,EAAE,MAAM,4BAA4B,CAAA;AAG/G,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,4CAA4C,CAAA;AAE3F,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,0BAA0B,CAAA;AAevE;;GAEG;AACH,eAAO,MAAM,wCAAwC,GACnD,UAAU,gBAAgB,EAC1B,UAAU,qBAAqB,EAC/B,QAAQ,oBAAoB,GAAG,IAAI,EACnC,mBAAmB,uBAAuB,EAAE,KAC3C,yBAAyB,EAQ3B,CAAA"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { getAsyncApiSecurityRequirements } from '../channel-example/get-asyncapi-security-requirements.js';
|
|
2
|
+
const dedupeRequirements = (requirements) => {
|
|
3
|
+
const seen = new Set();
|
|
4
|
+
return requirements.filter((requirement) => {
|
|
5
|
+
const key = JSON.stringify(requirement);
|
|
6
|
+
if (seen.has(key)) {
|
|
7
|
+
return false;
|
|
8
|
+
}
|
|
9
|
+
seen.add(key);
|
|
10
|
+
return true;
|
|
11
|
+
});
|
|
12
|
+
};
|
|
13
|
+
/**
|
|
14
|
+
* Merges security requirements from the selected server and all operations on a channel.
|
|
15
|
+
*/
|
|
16
|
+
export const getChannelConnectionSecurityRequirements = (document, _channel, server, channelOperations) => {
|
|
17
|
+
const serverRequirements = getAsyncApiSecurityRequirements(document, null, server);
|
|
18
|
+
const operationRequirements = channelOperations.flatMap(({ operation }) => getAsyncApiSecurityRequirements(document, operation, null));
|
|
19
|
+
return dedupeRequirements([...serverRequirements, ...operationRequirements]);
|
|
20
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { AsyncApiDocument, AsyncApiOperationObject } from '@scalar/types/asyncapi/3.1';
|
|
2
|
+
export type ChannelOperationSummary = {
|
|
3
|
+
operationName: string;
|
|
4
|
+
operation: AsyncApiOperationObject;
|
|
5
|
+
action: 'send' | 'receive';
|
|
6
|
+
};
|
|
7
|
+
/**
|
|
8
|
+
* Lists AsyncAPI operations that target a given channel (for reference in the channel connection UI).
|
|
9
|
+
*/
|
|
10
|
+
export declare const getChannelOperations: (document: AsyncApiDocument, channelName: string) => ChannelOperationSummary[];
|
|
11
|
+
//# sourceMappingURL=get-channel-operations.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-channel-operations.d.ts","sourceRoot":"","sources":["../../src/channel-example/get-channel-operations.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,uBAAuB,EAAE,MAAM,4BAA4B,CAAA;AAO3F,MAAM,MAAM,uBAAuB,GAAG;IACpC,aAAa,EAAE,MAAM,CAAA;IACrB,SAAS,EAAE,uBAAuB,CAAA;IAClC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAA;CAC3B,CAAA;AAED;;GAEG;AACH,eAAO,MAAM,oBAAoB,GAAI,UAAU,gBAAgB,EAAE,aAAa,MAAM,KAAG,uBAAuB,EAgB7G,CAAA"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { getResolvedRef } from '../helpers/get-resolved-ref.js';
|
|
2
|
+
import { resolveOperationChannel } from './resolve-operation-channel.js';
|
|
3
|
+
import { resolveOperationWithTraits } from './resolve-operation-with-traits.js';
|
|
4
|
+
/**
|
|
5
|
+
* Lists AsyncAPI operations that target a given channel (for reference in the channel connection UI).
|
|
6
|
+
*/
|
|
7
|
+
export const getChannelOperations = (document, channelName) => {
|
|
8
|
+
const operations = document.operations ?? {};
|
|
9
|
+
return Object.entries(operations)
|
|
10
|
+
.map(([operationName, operationRef]) => {
|
|
11
|
+
const operation = resolveOperationWithTraits(getResolvedRef(operationRef));
|
|
12
|
+
const resolved = resolveOperationChannel(document, operation);
|
|
13
|
+
if (resolved?.channelName !== channelName) {
|
|
14
|
+
return undefined;
|
|
15
|
+
}
|
|
16
|
+
const action = operation.action === 'send' ? 'send' : 'receive';
|
|
17
|
+
return { operationName, operation, action };
|
|
18
|
+
})
|
|
19
|
+
.filter((entry) => entry != null);
|
|
20
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { AsyncApiChannelObject, AsyncApiOperationObject, AsyncApiParameterObject } from '@scalar/types/asyncapi/3.1';
|
|
2
|
+
export type ChannelParametersContext = {
|
|
3
|
+
/** Resolved channel parameter definitions keyed by name. */
|
|
4
|
+
definitions: Record<string, AsyncApiParameterObject>;
|
|
5
|
+
/** Values substituted into the channel address path segments. */
|
|
6
|
+
path: Record<string, string>;
|
|
7
|
+
/** Values substituted into WebSocket handshake query parameters. */
|
|
8
|
+
query: Record<string, string>;
|
|
9
|
+
};
|
|
10
|
+
/**
|
|
11
|
+
* Builds default path and query parameter values from channel definitions and ws bindings.
|
|
12
|
+
*/
|
|
13
|
+
export declare const getChannelParameters: (channel: AsyncApiChannelObject, operation?: AsyncApiOperationObject | null, overrides?: Partial<Pick<ChannelParametersContext, "path" | "query">>) => ChannelParametersContext;
|
|
14
|
+
//# sourceMappingURL=get-channel-parameters.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-channel-parameters.d.ts","sourceRoot":"","sources":["../../src/channel-example/get-channel-parameters.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,qBAAqB,EACrB,uBAAuB,EACvB,uBAAuB,EACxB,MAAM,4BAA4B,CAAA;AAKnC,MAAM,MAAM,wBAAwB,GAAG;IACrC,4DAA4D;IAC5D,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,uBAAuB,CAAC,CAAA;IACpD,iEAAiE;IACjE,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IAC5B,oEAAoE;IACpE,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;CAC9B,CAAA;AA+BD;;GAEG;AACH,eAAO,MAAM,oBAAoB,GAC/B,SAAS,qBAAqB,EAC9B,YAAY,uBAAuB,GAAG,IAAI,EAC1C,YAAW,OAAO,CAAC,IAAI,CAAC,wBAAwB,EAAE,MAAM,GAAG,OAAO,CAAC,CAAM,KACxE,wBAgCF,CAAA"}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { objectEntries } from '@scalar/helpers/object/object-entries';
|
|
2
|
+
import { findVariables } from '@scalar/helpers/regex/find-variables';
|
|
3
|
+
import { buildWsQueryParams, mergeWsBindings } from '../channel-example/build-connection-url.js';
|
|
4
|
+
import { getResolvedRef } from '../helpers/get-resolved-ref.js';
|
|
5
|
+
const getPathParameterNames = (address) => {
|
|
6
|
+
if (address == null || address === '') {
|
|
7
|
+
return [];
|
|
8
|
+
}
|
|
9
|
+
const names = [];
|
|
10
|
+
for (const name of findVariables(address, { includePath: true, includeEnv: false })) {
|
|
11
|
+
if (name && !names.includes(name)) {
|
|
12
|
+
names.push(name);
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
return names;
|
|
16
|
+
};
|
|
17
|
+
const getDefaultParameterValue = (parameter) => {
|
|
18
|
+
if (parameter.default != null) {
|
|
19
|
+
return String(parameter.default);
|
|
20
|
+
}
|
|
21
|
+
if (parameter.examples?.[0] != null) {
|
|
22
|
+
return String(parameter.examples[0]);
|
|
23
|
+
}
|
|
24
|
+
if (parameter.enum?.[0] != null) {
|
|
25
|
+
return String(parameter.enum[0]);
|
|
26
|
+
}
|
|
27
|
+
return '';
|
|
28
|
+
};
|
|
29
|
+
/**
|
|
30
|
+
* Builds default path and query parameter values from channel definitions and ws bindings.
|
|
31
|
+
*/
|
|
32
|
+
export const getChannelParameters = (channel, operation, overrides = {}) => {
|
|
33
|
+
const definitions = {};
|
|
34
|
+
if (channel.parameters) {
|
|
35
|
+
for (const [name, parameterRef] of objectEntries(channel.parameters)) {
|
|
36
|
+
definitions[name] = getResolvedRef(parameterRef);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
const path = { ...overrides.path };
|
|
40
|
+
for (const name of getPathParameterNames(channel.address)) {
|
|
41
|
+
if (path[name] == null) {
|
|
42
|
+
const parameter = definitions[name];
|
|
43
|
+
path[name] = parameter ? getDefaultParameterValue(parameter) : '';
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
const query = { ...overrides.query };
|
|
47
|
+
const wsBinding = mergeWsBindings(channel, operation);
|
|
48
|
+
const defaultQueryParams = buildWsQueryParams(wsBinding);
|
|
49
|
+
defaultQueryParams.forEach((value, key) => {
|
|
50
|
+
if (query[key] == null) {
|
|
51
|
+
query[key] = value;
|
|
52
|
+
}
|
|
53
|
+
});
|
|
54
|
+
return {
|
|
55
|
+
definitions,
|
|
56
|
+
path,
|
|
57
|
+
query,
|
|
58
|
+
};
|
|
59
|
+
};
|
|
@@ -1,5 +1,20 @@
|
|
|
1
1
|
export type { AsyncApiWebSocketProtocol, BuildConnectionUrlInput } from './build-connection-url.js';
|
|
2
2
|
export { ASYNCAPI_WEBSOCKET_PROTOCOLS, buildAsyncApiServerBaseUrl, buildConnectionUrl, buildWsQueryParams, getAsyncApiServerVariables, getUrlSchemeFromProtocol, isWebSocketProtocol, mergeWsBindings, } from './build-connection-url.js';
|
|
3
|
+
export type { ChannelMessageEntry } from './get-all-channel-messages.js';
|
|
4
|
+
export { getAllChannelMessages } from './get-all-channel-messages.js';
|
|
5
|
+
export { getAsyncApiSecurityRequirements } from './get-asyncapi-security-requirements.js';
|
|
6
|
+
export { getChannelConnectionContext } from './get-channel-connection-context.js';
|
|
7
|
+
export { getChannelConnectionSecurityRequirements } from './get-channel-connection-security.js';
|
|
8
|
+
export type { ChannelOperationSummary } from './get-channel-operations.js';
|
|
9
|
+
export { getChannelOperations } from './get-channel-operations.js';
|
|
10
|
+
export type { ChannelParametersContext } from './get-channel-parameters.js';
|
|
11
|
+
export { getChannelParameters } from './get-channel-parameters.js';
|
|
12
|
+
export type { ResolvedChannel } from './resolve-channel.js';
|
|
13
|
+
export { resolveChannel } from './resolve-channel.js';
|
|
14
|
+
export type { ResolvedOperationChannel } from './resolve-operation-channel.js';
|
|
15
|
+
export { resolveOperationChannel } from './resolve-operation-channel.js';
|
|
16
|
+
export { resolveOperationWithTraits } from './resolve-operation-with-traits.js';
|
|
3
17
|
export type { AsyncApiServerEntry, AsyncApiServerListOptions } from './servers.js';
|
|
4
18
|
export { getAsyncApiServers, getSelectedAsyncApiServer } from './servers.js';
|
|
19
|
+
export type { BuildChannelConnectionContext, ChannelConnectionMeta } from './types.js';
|
|
5
20
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/channel-example/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,yBAAyB,EAAE,uBAAuB,EAAE,MAAM,wBAAwB,CAAA;AAChG,OAAO,EACL,4BAA4B,EAC5B,0BAA0B,EAC1B,kBAAkB,EAClB,kBAAkB,EAClB,0BAA0B,EAC1B,wBAAwB,EACxB,mBAAmB,EACnB,eAAe,GAChB,MAAM,wBAAwB,CAAA;AAC/B,YAAY,EAAE,mBAAmB,EAAE,yBAAyB,EAAE,MAAM,WAAW,CAAA;AAC/E,OAAO,EAAE,kBAAkB,EAAE,yBAAyB,EAAE,MAAM,WAAW,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/channel-example/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,yBAAyB,EAAE,uBAAuB,EAAE,MAAM,wBAAwB,CAAA;AAChG,OAAO,EACL,4BAA4B,EAC5B,0BAA0B,EAC1B,kBAAkB,EAClB,kBAAkB,EAClB,0BAA0B,EAC1B,wBAAwB,EACxB,mBAAmB,EACnB,eAAe,GAChB,MAAM,wBAAwB,CAAA;AAC/B,YAAY,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAA;AACrE,OAAO,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAA;AAClE,OAAO,EAAE,+BAA+B,EAAE,MAAM,sCAAsC,CAAA;AACtF,OAAO,EAAE,2BAA2B,EAAE,MAAM,kCAAkC,CAAA;AAC9E,OAAO,EAAE,wCAAwC,EAAE,MAAM,mCAAmC,CAAA;AAC5F,YAAY,EAAE,uBAAuB,EAAE,MAAM,0BAA0B,CAAA;AACvE,OAAO,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAA;AAC/D,YAAY,EAAE,wBAAwB,EAAE,MAAM,0BAA0B,CAAA;AACxE,OAAO,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAA;AAC/D,YAAY,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAA;AACxD,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAA;AAClD,YAAY,EAAE,wBAAwB,EAAE,MAAM,6BAA6B,CAAA;AAC3E,OAAO,EAAE,uBAAuB,EAAE,MAAM,6BAA6B,CAAA;AACrE,OAAO,EAAE,0BAA0B,EAAE,MAAM,iCAAiC,CAAA;AAC5E,YAAY,EAAE,mBAAmB,EAAE,yBAAyB,EAAE,MAAM,WAAW,CAAA;AAC/E,OAAO,EAAE,kBAAkB,EAAE,yBAAyB,EAAE,MAAM,WAAW,CAAA;AACzE,YAAY,EAAE,6BAA6B,EAAE,qBAAqB,EAAE,MAAM,SAAS,CAAA"}
|
|
@@ -1,2 +1,11 @@
|
|
|
1
1
|
export { ASYNCAPI_WEBSOCKET_PROTOCOLS, buildAsyncApiServerBaseUrl, buildConnectionUrl, buildWsQueryParams, getAsyncApiServerVariables, getUrlSchemeFromProtocol, isWebSocketProtocol, mergeWsBindings, } from './build-connection-url.js';
|
|
2
|
+
export { getAllChannelMessages } from './get-all-channel-messages.js';
|
|
3
|
+
export { getAsyncApiSecurityRequirements } from './get-asyncapi-security-requirements.js';
|
|
4
|
+
export { getChannelConnectionContext } from './get-channel-connection-context.js';
|
|
5
|
+
export { getChannelConnectionSecurityRequirements } from './get-channel-connection-security.js';
|
|
6
|
+
export { getChannelOperations } from './get-channel-operations.js';
|
|
7
|
+
export { getChannelParameters } from './get-channel-parameters.js';
|
|
8
|
+
export { resolveChannel } from './resolve-channel.js';
|
|
9
|
+
export { resolveOperationChannel } from './resolve-operation-channel.js';
|
|
10
|
+
export { resolveOperationWithTraits } from './resolve-operation-with-traits.js';
|
|
2
11
|
export { getAsyncApiServers, getSelectedAsyncApiServer } from './servers.js';
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { AsyncApiChannelObject, AsyncApiDocument } from '@scalar/types/asyncapi/3.1';
|
|
2
|
+
export type ResolvedChannel = {
|
|
3
|
+
channelName: string;
|
|
4
|
+
channel: AsyncApiChannelObject;
|
|
5
|
+
channelAddress: string;
|
|
6
|
+
};
|
|
7
|
+
/**
|
|
8
|
+
* Resolves a channel by its key in `document.channels`.
|
|
9
|
+
*/
|
|
10
|
+
export declare const resolveChannel: (document: AsyncApiDocument, channelName: string) => ResolvedChannel | undefined;
|
|
11
|
+
//# sourceMappingURL=resolve-channel.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resolve-channel.d.ts","sourceRoot":"","sources":["../../src/channel-example/resolve-channel.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAA;AAIzF,MAAM,MAAM,eAAe,GAAG;IAC5B,WAAW,EAAE,MAAM,CAAA;IACnB,OAAO,EAAE,qBAAqB,CAAA;IAC9B,cAAc,EAAE,MAAM,CAAA;CACvB,CAAA;AAED;;GAEG;AACH,eAAO,MAAM,cAAc,GAAI,UAAU,gBAAgB,EAAE,aAAa,MAAM,KAAG,eAAe,GAAG,SAWlG,CAAA"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { getResolvedRef } from '../helpers/get-resolved-ref.js';
|
|
2
|
+
/**
|
|
3
|
+
* Resolves a channel by its key in `document.channels`.
|
|
4
|
+
*/
|
|
5
|
+
export const resolveChannel = (document, channelName) => {
|
|
6
|
+
const channelNode = document.channels?.[channelName];
|
|
7
|
+
if (!channelNode) {
|
|
8
|
+
return undefined;
|
|
9
|
+
}
|
|
10
|
+
const channel = getResolvedRef(channelNode);
|
|
11
|
+
const channelAddress = typeof channel.address === 'string' && channel.address.length > 0 ? channel.address : channelName;
|
|
12
|
+
return { channelName, channel, channelAddress };
|
|
13
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { AsyncApiChannelObject, AsyncApiDocument, AsyncApiOperationObject } from '@scalar/types/asyncapi/3.1';
|
|
2
|
+
export type ResolvedOperationChannel = {
|
|
3
|
+
channelName: string;
|
|
4
|
+
channel: AsyncApiChannelObject;
|
|
5
|
+
channelAddress: string;
|
|
6
|
+
};
|
|
7
|
+
/**
|
|
8
|
+
* Resolves an operation's channel reference to a channel name, object, and display address.
|
|
9
|
+
*/
|
|
10
|
+
export declare const resolveOperationChannel: (document: AsyncApiDocument, operation: AsyncApiOperationObject) => ResolvedOperationChannel | undefined;
|
|
11
|
+
//# sourceMappingURL=resolve-operation-channel.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resolve-operation-channel.d.ts","sourceRoot":"","sources":["../../src/channel-example/resolve-operation-channel.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,gBAAgB,EAAE,uBAAuB,EAAE,MAAM,4BAA4B,CAAA;AAKlH,MAAM,MAAM,wBAAwB,GAAG;IACrC,WAAW,EAAE,MAAM,CAAA;IACnB,OAAO,EAAE,qBAAqB,CAAA;IAC9B,cAAc,EAAE,MAAM,CAAA;CACvB,CAAA;AAmBD;;GAEG;AACH,eAAO,MAAM,uBAAuB,GAClC,UAAU,gBAAgB,EAC1B,WAAW,uBAAuB,KACjC,wBAAwB,GAAG,SA8B7B,CAAA"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { getNameFromRef } from '../helpers/get-name-from-ref.js';
|
|
2
|
+
import { getResolvedRef } from '../helpers/get-resolved-ref.js';
|
|
3
|
+
const getChannelNameFromRef = (ref) => getNameFromRef(ref, ['channels']);
|
|
4
|
+
const findChannelName = (document, channel) => {
|
|
5
|
+
if (!document.channels) {
|
|
6
|
+
return undefined;
|
|
7
|
+
}
|
|
8
|
+
for (const [channelName, channelNode] of Object.entries(document.channels)) {
|
|
9
|
+
const resolved = getResolvedRef(channelNode);
|
|
10
|
+
if (resolved === channel) {
|
|
11
|
+
return channelName;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
return undefined;
|
|
15
|
+
};
|
|
16
|
+
/**
|
|
17
|
+
* Resolves an operation's channel reference to a channel name, object, and display address.
|
|
18
|
+
*/
|
|
19
|
+
export const resolveOperationChannel = (document, operation) => {
|
|
20
|
+
const channelNode = operation.channel;
|
|
21
|
+
if (!channelNode) {
|
|
22
|
+
return undefined;
|
|
23
|
+
}
|
|
24
|
+
const channelNameFromRef = '$ref' in channelNode ? getChannelNameFromRef(channelNode.$ref) : undefined;
|
|
25
|
+
if (channelNameFromRef && document.channels?.[channelNameFromRef]) {
|
|
26
|
+
const channel = getResolvedRef(document.channels[channelNameFromRef]);
|
|
27
|
+
const channelAddress = typeof channel.address === 'string' && channel.address.length > 0 ? channel.address : channelNameFromRef;
|
|
28
|
+
return { channelName: channelNameFromRef, channel, channelAddress };
|
|
29
|
+
}
|
|
30
|
+
const channel = getResolvedRef(channelNode);
|
|
31
|
+
const channelName = channelNameFromRef ??
|
|
32
|
+
findChannelName(document, channel) ??
|
|
33
|
+
(typeof channel.address === 'string' && channel.address.length > 0 ? channel.address : undefined);
|
|
34
|
+
if (!channelName) {
|
|
35
|
+
return undefined;
|
|
36
|
+
}
|
|
37
|
+
const channelAddress = typeof channel.address === 'string' && channel.address.length > 0 ? channel.address : channelName;
|
|
38
|
+
return { channelName, channel, channelAddress };
|
|
39
|
+
};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { AsyncApiOperationObject } from '@scalar/types/asyncapi/3.1';
|
|
2
|
+
/**
|
|
3
|
+
* Merges operation traits into a single operation view, while keeping operation fields highest priority.
|
|
4
|
+
*/
|
|
5
|
+
export declare const resolveOperationWithTraits: (operation: AsyncApiOperationObject) => AsyncApiOperationObject;
|
|
6
|
+
//# sourceMappingURL=resolve-operation-with-traits.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resolve-operation-with-traits.d.ts","sourceRoot":"","sources":["../../src/channel-example/resolve-operation-with-traits.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,4BAA4B,CAAA;AAYzE;;GAEG;AACH,eAAO,MAAM,0BAA0B,GAAI,WAAW,uBAAuB,KAAG,uBAuC/E,CAAA"}
|