@redocly/portal-plugin-async-api 1.0.201 → 1.0.203
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 +23 -0
- package/lib/.tsbuildinfo +1 -1
- package/lib/config.d.ts +2 -98
- package/lib/config.js +1 -13
- package/lib/config.js.map +1 -1
- package/lib/plugin.js +10 -9
- package/lib/plugin.js.map +1 -1
- package/lib/styles.js +21 -616
- package/lib/styles.js.map +1 -1
- package/lib/template.d.ts +1 -1
- package/lib/template.js +16 -9
- package/lib/template.js.map +1 -1
- package/package.json +5 -5
- package/src/config.ts +1 -14
- package/src/plugin.ts +16 -8
- package/src/styles.tsx +21 -616
- package/src/template.tsx +18 -34
package/lib/template.js
CHANGED
|
@@ -1,32 +1,39 @@
|
|
|
1
1
|
import AsyncApiComponent from '@asyncapi/react-component';
|
|
2
2
|
import React from 'react';
|
|
3
3
|
import styled from 'styled-components';
|
|
4
|
-
// @ts-ignore
|
|
5
4
|
import { Breadcrumbs as ThemeBreadcrumbs } from '@redocly/theme';
|
|
6
|
-
import '@asyncapi/react-component/lib/styles/fiori.css';
|
|
7
5
|
// @ts-ignore has no exported member error
|
|
8
6
|
import { usePageSharedData } from '@portal/hooks';
|
|
7
|
+
import '@asyncapi/react-component/styles/default.css';
|
|
9
8
|
import { StylesProvider } from './styles.js';
|
|
10
9
|
function AsyncApiDocs({ pageProps }) {
|
|
11
10
|
const { settings = {} } = pageProps;
|
|
12
11
|
const asyncApiDefinition = usePageSharedData('AsyncApiDefinition');
|
|
13
|
-
const { schemaId,
|
|
12
|
+
const { schemaId, hideOperations, hideErrors, hideInfo, hideMessages, hideSchemas, hideServers } = settings;
|
|
14
13
|
const componentConfig = {
|
|
15
14
|
schemaID: schemaId,
|
|
16
|
-
showErrors: !hideErrors,
|
|
17
15
|
show: {
|
|
16
|
+
errors: !hideErrors,
|
|
18
17
|
info: !hideInfo,
|
|
19
|
-
|
|
18
|
+
operations: !hideOperations,
|
|
20
19
|
servers: !hideServers,
|
|
21
20
|
messages: !hideMessages,
|
|
22
21
|
schemas: !hideSchemas,
|
|
22
|
+
sidebar: false,
|
|
23
23
|
},
|
|
24
24
|
expand: {
|
|
25
|
-
|
|
26
|
-
channels: expandChannels,
|
|
27
|
-
messages: expandMessages,
|
|
28
|
-
servers: expandServers,
|
|
25
|
+
messageExamples: false,
|
|
29
26
|
},
|
|
27
|
+
sidebar: {
|
|
28
|
+
showServers: 'byDefault',
|
|
29
|
+
showOperations: 'byDefault',
|
|
30
|
+
},
|
|
31
|
+
publishLabel: 'PUBLISHER',
|
|
32
|
+
subscribeLabel: 'SUBSCRIBER',
|
|
33
|
+
sendLabel: 'SEND',
|
|
34
|
+
receiveLabel: 'RECEIVE',
|
|
35
|
+
requestLabel: 'REQUEST',
|
|
36
|
+
replyLabel: 'REPLY',
|
|
30
37
|
};
|
|
31
38
|
return (React.createElement(StylesProvider, null,
|
|
32
39
|
React.createElement(Breadcrumbs, null),
|
package/lib/template.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"template.js","sourceRoot":"","sources":["../src/template.tsx"],"names":[],"mappings":"AAAA,OAAO,iBAAiB,MAAM,2BAA2B,CAAC;AAC1D,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,MAAM,MAAM,mBAAmB,CAAC;AACvC,
|
|
1
|
+
{"version":3,"file":"template.js","sourceRoot":"","sources":["../src/template.tsx"],"names":[],"mappings":"AAAA,OAAO,iBAAiB,MAAM,2BAA2B,CAAC;AAC1D,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,MAAM,MAAM,mBAAmB,CAAC;AACvC,OAAO,EAAE,WAAW,IAAI,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAMjE,0CAA0C;AAC1C,OAAO,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAElD,OAAO,8CAA8C,CAAC;AACtD,OAAO,EAAE,cAAc,EAAE,M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"version": "1.0.
|
|
3
|
+
"version": "1.0.203",
|
|
4
4
|
"description": "Async API plugin for @redocly/portal",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
@@ -26,16 +26,16 @@
|
|
|
26
26
|
"typescript": "5.2.2"
|
|
27
27
|
},
|
|
28
28
|
"dependencies": {
|
|
29
|
-
"@asyncapi/
|
|
30
|
-
"@asyncapi/react-component": "^0.
|
|
29
|
+
"@asyncapi/parser": "^3.0.14",
|
|
30
|
+
"@asyncapi/react-component": "^2.0.0",
|
|
31
31
|
"json-schema-to-ts": "^2.9.1",
|
|
32
32
|
"styled-components": "^5.3.11"
|
|
33
33
|
},
|
|
34
34
|
"peerDependencies": {
|
|
35
35
|
"react": "^18.0.0",
|
|
36
36
|
"react-dom": "^18.0.0",
|
|
37
|
-
"@redocly/realm": "0.
|
|
38
|
-
"@redocly/theme": "0.37.
|
|
37
|
+
"@redocly/realm": "0.86.0",
|
|
38
|
+
"@redocly/theme": "0.37.3"
|
|
39
39
|
},
|
|
40
40
|
"peerDependenciesMeta": {
|
|
41
41
|
"@redocly/realm": {
|
package/src/config.ts
CHANGED
|
@@ -1,28 +1,15 @@
|
|
|
1
1
|
import type { FromSchema } from 'json-schema-to-ts';
|
|
2
2
|
|
|
3
|
-
const expandSectionSchema = {
|
|
4
|
-
type: 'object',
|
|
5
|
-
properties: {
|
|
6
|
-
root: { type: 'boolean' },
|
|
7
|
-
elements: { type: 'boolean' },
|
|
8
|
-
},
|
|
9
|
-
additionalProperties: false,
|
|
10
|
-
} as const;
|
|
11
|
-
|
|
12
3
|
const asyncApiDocsSchema = {
|
|
13
4
|
type: 'object',
|
|
14
5
|
properties: {
|
|
15
6
|
schemaId: { type: 'string' },
|
|
16
7
|
hideErrors: { type: 'boolean' },
|
|
17
8
|
hideInfo: { type: 'boolean' },
|
|
18
|
-
|
|
9
|
+
hideOperations: { type: 'boolean' },
|
|
19
10
|
hideServers: { type: 'boolean' },
|
|
20
11
|
hideMessages: { type: 'boolean' },
|
|
21
12
|
hideSchemas: { type: 'boolean' },
|
|
22
|
-
expandChannels: expandSectionSchema,
|
|
23
|
-
expandServers: expandSectionSchema,
|
|
24
|
-
expandMessages: expandSectionSchema,
|
|
25
|
-
expandSchemas: expandSectionSchema,
|
|
26
13
|
},
|
|
27
14
|
additionalProperties: false,
|
|
28
15
|
} as const;
|
package/src/plugin.ts
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import path from 'path';
|
|
2
1
|
// FIXME: think of a way to make these imports shorter?
|
|
3
2
|
import { REDOCLY_ROUTE_RBAC } from '@redocly/realm/dist/shared/constants.js';
|
|
4
3
|
import { withPathPrefix } from '@redocly/realm/dist/shared/urls.js';
|
|
5
|
-
import
|
|
4
|
+
import { fromFile, Parser } from '@asyncapi/parser';
|
|
6
5
|
import { Feature } from '@redocly/realm/dist/server/entitlements/entitlements.types.js';
|
|
7
6
|
|
|
8
7
|
import type { PageStaticData } from '@redocly/realm/dist/shared/types';
|
|
@@ -17,6 +16,8 @@ const ASYNCAPI_TEMPLATE_ID = 'asyncapi-docs';
|
|
|
17
16
|
const ASYNCAPI_SHARED_DATA_PREFIX = 'asyncapi-docs-';
|
|
18
17
|
|
|
19
18
|
export default async function asyncAPIDocsPlugin(): Promise<PluginInstance> {
|
|
19
|
+
const parser = new Parser();
|
|
20
|
+
|
|
20
21
|
return {
|
|
21
22
|
id: Feature.Asyncapi,
|
|
22
23
|
processContent: async (contentProvider, actions) => {
|
|
@@ -31,17 +32,24 @@ export default async function asyncAPIDocsPlugin(): Promise<PluginInstance> {
|
|
|
31
32
|
const definitions = loadDefinitions();
|
|
32
33
|
const currentScriptLocation = process.cwd();
|
|
33
34
|
|
|
34
|
-
for (const [relativePath
|
|
35
|
+
for (const [relativePath] of definitions) {
|
|
35
36
|
const pageSlug = contentProvider.slugFromRelativePath(relativePath);
|
|
36
37
|
|
|
37
38
|
const sharedDataKey = `${ASYNCAPI_SHARED_DATA_PREFIX}${relativePath}`;
|
|
38
39
|
try {
|
|
40
|
+
const absolutePath = contentProvider.getFsAbsolutePath(relativePath);
|
|
39
41
|
const fsRelativePath = contentProvider.getFsRelativePath(relativePath);
|
|
40
|
-
const
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
42
|
+
const { document, diagnostics } = await fromFile(parser, absolutePath).parse();
|
|
43
|
+
|
|
44
|
+
diagnostics
|
|
45
|
+
.filter((d) => d.severity === 0)
|
|
46
|
+
.forEach(({ message, path }) =>
|
|
47
|
+
console.error(
|
|
48
|
+
`Cannot parse AsyncAPI schema: ${message} in '${fsRelativePath}:${path.join('.')}'`,
|
|
49
|
+
),
|
|
50
|
+
);
|
|
51
|
+
|
|
52
|
+
await actions.createSharedData(sharedDataKey, document?.json() ?? {});
|
|
45
53
|
|
|
46
54
|
const route = {
|
|
47
55
|
slug: pageSlug,
|