@asyncapi/react-component 1.0.0-next.44 → 1.0.0-next.45
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/browser/index.js +2 -2
- package/browser/standalone/index.js +2 -2
- package/browser/standalone/without-parser.js +7 -7
- package/browser/without-parser.js +2 -2
- package/lib/cjs/components/CollapseButton.js +6 -2
- package/lib/cjs/components/CollapseButton.js.map +1 -1
- package/lib/cjs/config/config.js.map +1 -1
- package/lib/cjs/config/default.js +2 -1
- package/lib/cjs/config/default.js.map +1 -1
- package/lib/cjs/containers/AsyncApi/Layout.js +10 -10
- package/lib/cjs/containers/AsyncApi/Layout.js.map +1 -1
- package/lib/cjs/containers/Sidebar/Sidebar.js +153 -127
- package/lib/cjs/containers/Sidebar/Sidebar.js.map +1 -1
- package/lib/cjs/helpers/specification.js +17 -0
- package/lib/cjs/helpers/specification.js.map +1 -1
- package/lib/esm/components/CollapseButton.js +5 -1
- package/lib/esm/components/CollapseButton.js.map +1 -1
- package/lib/esm/config/config.js.map +1 -1
- package/lib/esm/config/default.js +2 -1
- package/lib/esm/config/default.js.map +1 -1
- package/lib/esm/containers/AsyncApi/Layout.js +10 -10
- package/lib/esm/containers/AsyncApi/Layout.js.map +1 -1
- package/lib/esm/containers/Sidebar/Sidebar.js +152 -123
- package/lib/esm/containers/Sidebar/Sidebar.js.map +1 -1
- package/lib/esm/helpers/specification.js +17 -0
- package/lib/esm/helpers/specification.js.map +1 -1
- package/lib/types/components/CollapseButton.d.ts.map +1 -1
- package/lib/types/config/config.d.ts +1 -0
- package/lib/types/config/config.d.ts.map +1 -1
- package/lib/types/config/default.d.ts.map +1 -1
- package/lib/types/containers/AsyncApi/Layout.d.ts.map +1 -1
- package/lib/types/containers/Sidebar/Sidebar.d.ts +1 -9
- package/lib/types/containers/Sidebar/Sidebar.d.ts.map +1 -1
- package/lib/types/helpers/specification.d.ts +3 -0
- package/lib/types/helpers/specification.d.ts.map +1 -1
- package/package.json +1 -2
|
@@ -61,6 +61,23 @@ var SpecificationHelpers = (function () {
|
|
|
61
61
|
});
|
|
62
62
|
return Array.from(tags.values());
|
|
63
63
|
};
|
|
64
|
+
SpecificationHelpers.serversTags = function (spec) {
|
|
65
|
+
var tags = {};
|
|
66
|
+
Object.entries(spec.servers()).forEach(function (_a) {
|
|
67
|
+
var _ = _a[0], server = _a[1];
|
|
68
|
+
if (server.hasTags()) {
|
|
69
|
+
server.tags().forEach(function (tag) {
|
|
70
|
+
if (tags[tag.name()]) {
|
|
71
|
+
tags[tag.name()] = [tags[tag.name()], _];
|
|
72
|
+
}
|
|
73
|
+
else {
|
|
74
|
+
tags[tag.name()] = _;
|
|
75
|
+
}
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
});
|
|
79
|
+
return tags;
|
|
80
|
+
};
|
|
64
81
|
return SpecificationHelpers;
|
|
65
82
|
}());
|
|
66
83
|
exports.SpecificationHelpers = SpecificationHelpers;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"specification.js","sourceRoot":"","sources":["../../../src/helpers/specification.ts"],"names":[],"mappings":";;;;;;AAEA,kFAAyE;AAEzE;IAAA;
|
|
1
|
+
{"version":3,"file":"specification.js","sourceRoot":"","sources":["../../../src/helpers/specification.ts"],"names":[],"mappings":";;;;;;AAEA,kFAAyE;AAEzE;IAAA;IAgGA,CAAC;IA5FQ,uCAAkB,GAAzB,UAA0B,MAAW;QACnC,IAAI,CAAC,MAAM,EAAE;YACX,OAAO,SAAS,CAAC;SAClB;QAGD,IAAI,MAAM,CAAC,WAAW,IAAI,MAAM,CAAC,WAAW,CAAC,IAAI,KAAK,kBAAkB,EAAE;YACxE,OAAO,MAA0B,CAAC;SACnC;QAID,IACE,OAAO,MAAM,CAAC,OAAO,KAAK,UAAU;YACpC,MAAM,CAAC,KAAK;YACZ,MAAM,CAAC,KAAK,CAAC,QAAQ,EACrB;YACA,OAAO,MAA0B,CAAC;SACnC;QAGD,IAAI,OAAO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,CAAC,CAAC;qBAC1C;yBAAM;wBACL,IAAI,CAAC,GAAG,CAAC,IAAI,EAAE,CAAC,GAAG,CAAC,CAAC;qBACtB;gBACH,CAAC,CAAC,CAAC;aACJ;QACH,CAAC,CAAC,CAAC;QACH,OAAO,IAAI,CAAC;IACd,CAAC;IACH,2BAAC;AAAD,CAAC,AAhGD,IAgGC;AAhGY,oDAAoB","sourcesContent":["import { AsyncAPIDocument, Tag } from '@asyncapi/parser';\n// @ts-ignore\nimport AsyncAPIDocumentModel from '@asyncapi/parser/lib/models/asyncapi';\n\nexport class SpecificationHelpers {\n /**\n * Returns parsed AsyncAPI specification.\n */\n static retrieveParsedSpec(schema: any): AsyncAPIDocument | undefined {\n if (!schema) {\n return undefined;\n }\n\n // check if schema is an instance of AsyncAPIDocument (model from AsyncAPI Parser)\n if (schema.constructor && schema.constructor.name === 'AsyncAPIDocument') {\n return schema as AsyncAPIDocument;\n }\n\n // then check if schema is an instance of AsyncAPIDocument (model from AsyncAPI Parser)\n // this check is used for security in case of code mangling (unification)\n if (\n typeof schema.version === 'function' &&\n schema._json &&\n schema._json.asyncapi\n ) {\n return schema as AsyncAPIDocument;\n }\n\n // check if input is a string and try parse it\n if (typeof schema === 'string') {\n try {\n schema = JSON.parse(schema);\n } catch (e) {\n return undefined;\n }\n }\n\n // at the end check if schema is a parsed JS object (as output from AsyncAPI Parser)\n if (typeof schema === 'object' && schema['x-parser-spec-parsed'] === true) {\n // if schema is stringified by `AsyncAPIDocument.stringify` function\n if (schema['x-parser-spec-stringified'] === true) {\n return AsyncAPIDocumentModel.parse(schema);\n }\n return new AsyncAPIDocumentModel(schema);\n }\n\n return undefined;\n }\n\n /**\n * Check if given schema have one of the specified tags.\n */\n static containTags(schema: any, tags: Tag | Tag[]): boolean {\n const tagsToCheck =\n typeof schema.tags === 'function' ? schema.tags() : undefined;\n if (tagsToCheck === undefined || !Array.isArray(tagsToCheck)) {\n return false;\n }\n tags = Array.isArray(tags) ? tags : [tags];\n return tagsToCheck.some((tag: Tag) =>\n (tags as Tag[]).some(t => t.name() === tag.name()),\n );\n }\n\n /**\n * Return all tags from operations\n */\n static operationsTags(spec: AsyncAPIDocument) {\n const tags = new Map<string, Tag>();\n Object.entries(spec.channels()).forEach(([_, channel]) => {\n const publish = channel.publish();\n if (publish && publish.hasTags()) {\n publish.tags().forEach(tag => tags.set(tag.name(), tag));\n }\n const subscribe = channel.subscribe();\n if (subscribe && subscribe.hasTags()) {\n subscribe.tags().forEach(tag => tags.set(tag.name(), tag));\n }\n });\n return Array.from(tags.values());\n }\n\n /**\n * Return all tags from servers\n */\n static serversTags(spec: AsyncAPIDocument) {\n const tags = {} as { string: string[] };\n Object.entries(spec.servers()).forEach(([_, server]) => {\n if (server.hasTags()) {\n server.tags().forEach(tag => {\n if (tags[tag.name()]) {\n tags[tag.name()] = [tags[tag.name()], _];\n } else {\n tags[tag.name()] = _;\n }\n });\n }\n });\n return tags;\n }\n}\n"]}
|
|
@@ -21,7 +21,11 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
21
21
|
return t;
|
|
22
22
|
};
|
|
23
23
|
import React from 'react';
|
|
24
|
-
|
|
24
|
+
var HiChevronRight = function (props) {
|
|
25
|
+
if (props === void 0) { props = {}; }
|
|
26
|
+
return (React.createElement("svg", __assign({ stroke: "currentColor", fill: "currentColor", strokeWidth: "0", viewBox: "0 0 20 20", height: "1em", width: "1em", xmlns: "http://www.w3.org/2000/svg" }, props),
|
|
27
|
+
React.createElement("path", { fillRule: "evenodd", d: "M7.293 14.707a1 1 0 010-1.414L10.586 10 7.293 6.707a1 1 0 011.414-1.414l4 4a1 1 0 010 1.414l-4 4a1 1 0 01-1.414 0z", clipRule: "evenodd" })));
|
|
28
|
+
};
|
|
25
29
|
export var CollapseButton = function (_a) {
|
|
26
30
|
var chevronProps = _a.chevronProps, _b = _a.expanded, expanded = _b === void 0 ? false : _b, children = _a.children, rest = __rest(_a, ["chevronProps", "expanded", "children"]);
|
|
27
31
|
return (React.createElement("button", __assign({}, rest, { className: "focus:outline-none ".concat(rest.className), type: "button" }),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CollapseButton.js","sourceRoot":"","sources":["../../../src/components/CollapseButton.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAAA,OAAO,KAA8C,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"CollapseButton.js","sourceRoot":"","sources":["../../../src/components/CollapseButton.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAAA,OAAO,KAA8C,MAAM,OAAO,CAAC;AAOnE,IAAM,cAAc,GAAG,UAAC,KAAqC;IAArC,sBAAA,EAAA,UAAqC;IAAK,OAAA,CAEhE,sCACE,MAAM,EAAC,cAAc,EACrB,IAAI,EAAC,cAAc,EACnB,WAAW,EAAC,GAAG,EACf,OAAO,EAAC,WAAW,EACnB,MAAM,EAAC,KAAK,EACZ,KAAK,EAAC,KAAK,EACX,KAAK,EAAC,4BAA4B,IAC9B,KAAK;QAET,8BACE,QAAQ,EAAC,SAAS,EAClB,CAAC,EAAC,oHAAoH,EACtH,QAAQ,EAAC,SAAS,GAClB,CACE,CACP;AAlBiE,CAkBjE,CAAC;AAEF,MAAM,CAAC,IAAM,cAAc,GAAmC,UAAC,EAK9D;IAJC,IAAA,YAAY,kBAAA,EACZ,gBAAgB,EAAhB,QAAQ,mBAAG,KAAK,KAAA,EAChB,QAAQ,cAAA,EACL,IAAI,cAJsD,wCAK9D,CADQ;IACH,OAAA,CACJ,2CACM,IAAI,IACR,SAAS,EAAE,6BAAsB,IAAI,CAAC,SAAS,CAAE,EACjD,IAAI,EAAC,QAAQ;QAEb,6BAAK,SAAS,EAAC,cAAc,IAAE,QAAQ,CAAO;QAC9C,oBAAC,cAAc,eACT,YAAY,IAChB,SAAS,EAAE,kIACT,QAAQ,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,EAAE,cAC1B,CAAA,YAAY,aAAZ,YAAY,uBAAZ,YAAY,CAAE,SAAS,KAAI,EAAE,CAAE,IACnC,CACK,CACV,CAAA;CAAA,CAAC","sourcesContent":["import React, { ButtonHTMLAttributes, SVGAttributes } from 'react';\n\ninterface Props extends ButtonHTMLAttributes<HTMLButtonElement> {\n chevronProps?: SVGAttributes<SVGElement>;\n expanded?: boolean;\n}\n\nconst HiChevronRight = (props: SVGAttributes<SVGElement> = {}) => (\n // Copied from https://icon-sets.iconify.design/heroicons-solid/chevron-right/\n <svg\n stroke=\"currentColor\"\n fill=\"currentColor\"\n strokeWidth=\"0\"\n viewBox=\"0 0 20 20\"\n height=\"1em\"\n width=\"1em\"\n xmlns=\"http://www.w3.org/2000/svg\"\n {...props}\n >\n <path\n fillRule=\"evenodd\"\n d=\"M7.293 14.707a1 1 0 010-1.414L10.586 10 7.293 6.707a1 1 0 011.414-1.414l4 4a1 1 0 010 1.414l-4 4a1 1 0 01-1.414 0z\"\n clipRule=\"evenodd\"\n />\n </svg>\n);\n\nexport const CollapseButton: React.FunctionComponent<Props> = ({\n chevronProps,\n expanded = false,\n children,\n ...rest\n}) => (\n <button\n {...rest}\n className={`focus:outline-none ${rest.className}`}\n type=\"button\"\n >\n <div className=\"inline-block\">{children}</div>\n <HiChevronRight\n {...chevronProps}\n className={`inline-block align-baseline cursor-pointer ml-0.5 -mb-1 w-5 h-5 transform transition-transform duration-150 ease-linear ${\n expanded ? '-rotate-90' : ''\n } ${chevronProps?.className || ''}`}\n />\n </button>\n);\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.js","sourceRoot":"","sources":["../../../src/config/config.ts"],"names":[],"mappings":"","sourcesContent":["export interface ConfigInterface {\n schemaID?: string;\n show?: ShowConfig;\n expand?: ExpandConfig;\n sidebar?: SideBarConfig;\n parserOptions?: any;\n publishLabel?: string;\n subscribeLabel?: string;\n}\n\nexport interface ShowConfig {\n sidebar?: boolean;\n info?: boolean;\n servers?: boolean;\n operations?: boolean;\n messages?: boolean;\n schemas?: boolean;\n errors?: boolean;\n}\n\nexport interface ExpandConfig {\n messageExamples?: boolean;\n}\n\nexport interface SideBarConfig {\n showOperations?: 'byDefault' | 'bySpecTags' | 'byOperationsTags';\n}\n"]}
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../../../src/config/config.ts"],"names":[],"mappings":"","sourcesContent":["export interface ConfigInterface {\n schemaID?: string;\n show?: ShowConfig;\n expand?: ExpandConfig;\n sidebar?: SideBarConfig;\n parserOptions?: any;\n publishLabel?: string;\n subscribeLabel?: string;\n}\n\nexport interface ShowConfig {\n sidebar?: boolean;\n info?: boolean;\n servers?: boolean;\n operations?: boolean;\n messages?: boolean;\n schemas?: boolean;\n errors?: boolean;\n}\n\nexport interface ExpandConfig {\n messageExamples?: boolean;\n}\n\nexport interface SideBarConfig {\n showServers?: 'byDefault' | 'bySpecTags' | 'byServersTags';\n showOperations?: 'byDefault' | 'bySpecTags' | 'byOperationsTags';\n}\n"]}
|
|
@@ -14,7 +14,8 @@ export var defaultConfig = {
|
|
|
14
14
|
messageExamples: false,
|
|
15
15
|
},
|
|
16
16
|
sidebar: {
|
|
17
|
-
|
|
17
|
+
showServers: 'byDefault',
|
|
18
|
+
showOperations: 'byDefault',
|
|
18
19
|
},
|
|
19
20
|
publishLabel: PUBLISH_LABEL_DEFAULT_TEXT,
|
|
20
21
|
subscribeLabel: SUBSCRIBE_LABEL_DEFAULT_TEXT,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"default.js","sourceRoot":"","sources":["../../../src/config/default.ts"],"names":[],"mappings":"AACA,OAAO,EACL,0BAA0B,EAC1B,4BAA4B,GAC7B,MAAM,cAAc,CAAC;AAEtB,MAAM,CAAC,IAAM,aAAa,GAAoB;IAC5C,QAAQ,EAAE,EAAE;IACZ,IAAI,EAAE;QACJ,OAAO,EAAE,KAAK;QACd,IAAI,EAAE,IAAI;QACV,OAAO,EAAE,IAAI;QACb,UAAU,EAAE,IAAI;QAChB,QAAQ,EAAE,IAAI;QACd,OAAO,EAAE,IAAI;QACb,MAAM,EAAE,IAAI;KACb;IACD,MAAM,EAAE;QACN,eAAe,EAAE,KAAK;KACvB;IACD,OAAO,EAAE;QACP,cAAc,EAAE,
|
|
1
|
+
{"version":3,"file":"default.js","sourceRoot":"","sources":["../../../src/config/default.ts"],"names":[],"mappings":"AACA,OAAO,EACL,0BAA0B,EAC1B,4BAA4B,GAC7B,MAAM,cAAc,CAAC;AAEtB,MAAM,CAAC,IAAM,aAAa,GAAoB;IAC5C,QAAQ,EAAE,EAAE;IACZ,IAAI,EAAE;QACJ,OAAO,EAAE,KAAK;QACd,IAAI,EAAE,IAAI;QACV,OAAO,EAAE,IAAI;QACb,UAAU,EAAE,IAAI;QAChB,QAAQ,EAAE,IAAI;QACd,OAAO,EAAE,IAAI;QACb,MAAM,EAAE,IAAI;KACb;IACD,MAAM,EAAE;QACN,eAAe,EAAE,KAAK;KACvB;IACD,OAAO,EAAE;QACP,WAAW,EAAE,WAAW;QACxB,cAAc,EAAE,WAAW;KAC5B;IACD,YAAY,EAAE,0BAA0B;IACxC,cAAc,EAAE,4BAA4B;CAC7C,CAAC","sourcesContent":["import { ConfigInterface } from './config';\nimport {\n PUBLISH_LABEL_DEFAULT_TEXT,\n SUBSCRIBE_LABEL_DEFAULT_TEXT,\n} from '../constants';\n\nexport const defaultConfig: ConfigInterface = {\n schemaID: '',\n show: {\n sidebar: false,\n info: true,\n servers: true,\n operations: true,\n messages: true,\n schemas: true,\n errors: true,\n },\n expand: {\n messageExamples: false,\n },\n sidebar: {\n showServers: 'byDefault',\n showOperations: 'byDefault',\n },\n publishLabel: PUBLISH_LABEL_DEFAULT_TEXT,\n subscribeLabel: SUBSCRIBE_LABEL_DEFAULT_TEXT,\n};\n"]}
|
|
@@ -9,9 +9,8 @@ import { Schemas } from '../Schemas/Schemas';
|
|
|
9
9
|
import { Error } from '../Error/Error';
|
|
10
10
|
import { SpecificationContext, ConfigContext } from '../../contexts';
|
|
11
11
|
var AsyncApiLayout = function (_a) {
|
|
12
|
-
var
|
|
13
|
-
var
|
|
14
|
-
var _k = useState('container:xl'), observerClassName = _k[0], setObserverClassName = _k[1];
|
|
12
|
+
var asyncapi = _a.asyncapi, config = _a.config, _b = _a.error, error = _b === void 0 ? null : _b;
|
|
13
|
+
var _c = useState('container:xl'), observerClassName = _c[0], setObserverClassName = _c[1];
|
|
15
14
|
var ref = useResizeObserver({
|
|
16
15
|
onResize: function (_a) {
|
|
17
16
|
var width = _a.width;
|
|
@@ -26,19 +25,20 @@ var AsyncApiLayout = function (_a) {
|
|
|
26
25
|
});
|
|
27
26
|
},
|
|
28
27
|
}).ref;
|
|
28
|
+
var configShow = config.show || {};
|
|
29
29
|
return (React.createElement(ConfigContext.Provider, { value: config },
|
|
30
30
|
React.createElement(SpecificationContext.Provider, { value: asyncapi },
|
|
31
31
|
React.createElement("section", { className: "aui-root" },
|
|
32
32
|
React.createElement("div", { className: "".concat(observerClassName, " relative md:flex bg-white leading-normal"), id: config.schemaID || undefined, ref: ref },
|
|
33
|
-
|
|
33
|
+
configShow.sidebar && React.createElement(Sidebar, null),
|
|
34
34
|
React.createElement("div", { className: "panel--center relative py-8 flex-1" },
|
|
35
35
|
React.createElement("div", { className: "relative z-10" },
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
36
|
+
configShow.errors && error && React.createElement(Error, { error: error }),
|
|
37
|
+
configShow.info && React.createElement(Info, null),
|
|
38
|
+
configShow.servers && React.createElement(Servers, null),
|
|
39
|
+
configShow.operations && React.createElement(Operations, null),
|
|
40
|
+
configShow.messages && React.createElement(Messages, null),
|
|
41
|
+
configShow.schemas && React.createElement(Schemas, null)),
|
|
42
42
|
React.createElement("div", { className: "panel--right absolute top-0 right-0 h-full bg-gray-800" })))))));
|
|
43
43
|
};
|
|
44
44
|
export default AsyncApiLayout;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Layout.js","sourceRoot":"","sources":["../../../../src/containers/AsyncApi/Layout.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAExC,OAAO,iBAAiB,MAAM,qBAAqB,CAAC;AAEpD,OAAO,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAC7C,OAAO,EAAE,IAAI,EAAE,MAAM,cAAc,CAAC;AACpC,OAAO,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAC7C,OAAO,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AACtD,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAChD,OAAO,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAC7C,OAAO,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;AAGvC,OAAO,EAAE,oBAAoB,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AASrE,IAAM,cAAc,GAAmC,UAAC,EAIvD
|
|
1
|
+
{"version":3,"file":"Layout.js","sourceRoot":"","sources":["../../../../src/containers/AsyncApi/Layout.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAExC,OAAO,iBAAiB,MAAM,qBAAqB,CAAC;AAEpD,OAAO,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAC7C,OAAO,EAAE,IAAI,EAAE,MAAM,cAAc,CAAC;AACpC,OAAO,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAC7C,OAAO,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AACtD,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAChD,OAAO,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAC7C,OAAO,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;AAGvC,OAAO,EAAE,oBAAoB,EAAE,aAAa,EAAE,MAAM,gBAAg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,OAAG;4BAC3B,UAAU,CAAC,OAAO,IAAI,oBAAC,OAAO,OAAG;4BACjC,UAAU,CAAC,UAAU,IAAI,oBAAC,UAAU,OAAG;4BACvC,UAAU,CAAC,QAAQ,IAAI,oBAAC,QAAQ,OAAG;4BACnC,UAAU,CAAC,OAAO,IAAI,oBAAC,OAAO,OAAG,CAC9B;wBACN,6BAAK,SAAS,EAAC,wDAAwD,GAAG,CACtE,CACF,CACE,CACoB,CACT,CAC1B,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,cAAc,CAAC","sourcesContent":["import React, { useState } from 'react';\nimport { AsyncAPIDocument } from '@asyncapi/parser';\nimport useResizeObserver from 'use-resize-observer';\n\nimport { Sidebar } from '../Sidebar/Sidebar';\nimport { Info } from '../Info/Info';\nimport { Servers } from '../Servers/Servers';\nimport { Operations } from '../Operations/Operations';\nimport { Messages } from '../Messages/Messages';\nimport { Schemas } from '../Schemas/Schemas';\nimport { Error } from '../Error/Error';\n\nimport { ConfigInterface } from '../../config';\nimport { SpecificationContext, ConfigContext } from '../../contexts';\nimport { ErrorObject } from '../../types';\n\ninterface Props {\n asyncapi: AsyncAPIDocument;\n config: ConfigInterface;\n error?: ErrorObject;\n}\n\nconst AsyncApiLayout: React.FunctionComponent<Props> = ({\n asyncapi,\n config,\n error = null,\n}) => {\n const [observerClassName, setObserverClassName] = useState('container:xl');\n\n const { ref } = useResizeObserver<HTMLDivElement>({\n onResize: ({ width }) => {\n requestAnimationFrame(() => {\n if (width === undefined) {\n return;\n }\n\n const possibleClassName =\n width <= 1280 ? 'container:xl' : 'container:base';\n if (possibleClassName !== observerClassName) {\n setObserverClassName(possibleClassName);\n }\n });\n },\n });\n\n const configShow = config.show || {};\n return (\n <ConfigContext.Provider value={config}>\n <SpecificationContext.Provider value={asyncapi}>\n <section className=\"aui-root\">\n <div\n className={`${observerClassName} relative md:flex bg-white leading-normal`}\n id={config.schemaID || undefined}\n ref={ref}\n >\n {configShow.sidebar && <Sidebar />}\n <div className=\"panel--center relative py-8 flex-1\">\n <div className=\"relative z-10\">\n {configShow.errors && error && <Error error={error} />}\n {configShow.info && <Info />}\n {configShow.servers && <Servers />}\n {configShow.operations && <Operations />}\n {configShow.messages && <Messages />}\n {configShow.schemas && <Schemas />}\n </div>\n <div className=\"panel--right absolute top-0 right-0 h-full bg-gray-800\" />\n </div>\n </div>\n </section>\n </SpecificationContext.Provider>\n </ConfigContext.Provider>\n );\n};\n\nexport default AsyncApiLayout;\n"]}
|
|
@@ -1,28 +1,20 @@
|
|
|
1
1
|
import React, { useState, useContext } from 'react';
|
|
2
2
|
import { CollapseButton } from '../../components';
|
|
3
3
|
import { useConfig, useSpec } from '../../contexts';
|
|
4
|
-
import { SpecificationHelpers } from '../../helpers';
|
|
5
4
|
import { PUBLISH_LABEL_DEFAULT_TEXT, SUBSCRIBE_LABEL_DEFAULT_TEXT, } from '../../constants';
|
|
6
5
|
var SidebarContext = React.createContext({
|
|
7
6
|
setShowSidebar: function (value) { return value; },
|
|
8
7
|
});
|
|
9
|
-
export var Sidebar = function (
|
|
10
|
-
var
|
|
11
|
-
var _b = useState(false), showSidebar = _b[0], setShowSidebar = _b[1];
|
|
12
|
-
var showOperations = (config === null || config === void 0 ? void 0 : config.showOperations) || 'byDefault';
|
|
8
|
+
export var Sidebar = function () {
|
|
9
|
+
var _a = useState(false), showSidebar = _a[0], setShowSidebar = _a[1];
|
|
13
10
|
var asyncapi = useSpec();
|
|
14
11
|
var info = asyncapi.info();
|
|
15
12
|
var logo = info.ext('x-logo');
|
|
16
13
|
var components = asyncapi.hasComponents() && asyncapi.components();
|
|
17
14
|
var messages = components && components.messages();
|
|
18
15
|
var schemas = components && components.schemas();
|
|
19
|
-
var
|
|
20
|
-
|
|
21
|
-
Operations = OperationsByRootTags;
|
|
22
|
-
}
|
|
23
|
-
else if (showOperations === 'byOperationsTags') {
|
|
24
|
-
Operations = OperationsByOperationsTags;
|
|
25
|
-
}
|
|
16
|
+
var hasOperations = asyncapi.hasChannels() &&
|
|
17
|
+
Object.values(asyncapi.channels()).some(function (channel) { return channel.hasPublish() || channel.hasSubscribe(); });
|
|
26
18
|
var messagesList = messages && Object.keys(messages).length > 0 && (React.createElement("li", { className: "mb-3 mt-9" },
|
|
27
19
|
React.createElement("a", { className: "text-xs uppercase text-gray-700 mt-10 mb-4 font-thin hover:text-gray-900", href: "#messages", onClick: function () { return setShowSidebar(false); } }, "Messages"),
|
|
28
20
|
React.createElement("ul", { className: "text-sm mt-2" }, Object.entries(messages).map(function (_a) {
|
|
@@ -52,119 +44,174 @@ export var Sidebar = function (_a) {
|
|
|
52
44
|
React.createElement("ul", { className: "text-sm mt-10 relative" },
|
|
53
45
|
React.createElement("li", { className: "mb-3" },
|
|
54
46
|
React.createElement("a", { className: "text-gray-700 no-underline hover:text-gray-900", href: "#introduction", onClick: function () { return setShowSidebar(false); } }, "Introduction")),
|
|
55
|
-
asyncapi.hasServers() && (React.createElement("li", { className: "mb-3" },
|
|
56
|
-
React.createElement("a", { className: "text-gray-700
|
|
57
|
-
|
|
47
|
+
asyncapi.hasServers() && (React.createElement("li", { className: "mb-3 mt-9" },
|
|
48
|
+
React.createElement("a", { className: "text-xs uppercase text-gray-700 mt-10 mb-4 font-thin hover:text-gray-900", href: "#servers", onClick: function () { return setShowSidebar(false); } }, "Servers"),
|
|
49
|
+
React.createElement(ServersList, null))),
|
|
50
|
+
hasOperations && (React.createElement(React.Fragment, null,
|
|
58
51
|
React.createElement("li", { className: "mb-3 mt-9" },
|
|
59
52
|
React.createElement("a", { className: "text-xs uppercase text-gray-700 mt-10 mb-4 font-thin hover:text-gray-900", href: "#operations", onClick: function () { return setShowSidebar(false); } }, "Operations"),
|
|
60
|
-
React.createElement(
|
|
53
|
+
React.createElement(OperationsList, null)),
|
|
61
54
|
messagesList,
|
|
62
55
|
schemasList))))))));
|
|
63
56
|
};
|
|
64
|
-
|
|
65
|
-
var
|
|
66
|
-
var
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
57
|
+
function filterObjectsByTags(tags, objects) {
|
|
58
|
+
var taggedObjects = new Set();
|
|
59
|
+
var tagged = new Map();
|
|
60
|
+
tags.forEach(function (tag) {
|
|
61
|
+
var taggedForTag = [];
|
|
62
|
+
objects.forEach(function (obj) {
|
|
63
|
+
var object = obj.object;
|
|
64
|
+
if (typeof object.tags !== 'function') {
|
|
65
|
+
return;
|
|
66
|
+
}
|
|
67
|
+
var objectTags = (object.tags() || []).map(function (t) { return t.name(); });
|
|
68
|
+
var hasTag = objectTags.includes(tag);
|
|
69
|
+
if (hasTag) {
|
|
70
|
+
taggedForTag.push(obj);
|
|
71
|
+
taggedObjects.add(obj);
|
|
72
|
+
}
|
|
73
|
+
});
|
|
74
|
+
tagged.set(tag, taggedForTag);
|
|
75
|
+
});
|
|
76
|
+
var untagged = [];
|
|
77
|
+
objects.forEach(function (obj) {
|
|
78
|
+
if (!taggedObjects.has(obj)) {
|
|
79
|
+
untagged.push(obj);
|
|
75
80
|
}
|
|
76
81
|
});
|
|
77
|
-
return
|
|
78
|
-
}
|
|
79
|
-
|
|
82
|
+
return { tagged: tagged, untagged: untagged };
|
|
83
|
+
}
|
|
84
|
+
var ServersList = function () {
|
|
85
|
+
var sidebarConfig = useConfig().sidebar;
|
|
80
86
|
var asyncapi = useSpec();
|
|
81
|
-
var
|
|
82
|
-
var
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
87
|
+
var servers = asyncapi.servers();
|
|
88
|
+
var showServers = (sidebarConfig === null || sidebarConfig === void 0 ? void 0 : sidebarConfig.showServers) || 'byDefault';
|
|
89
|
+
if (showServers === 'byDefault') {
|
|
90
|
+
return (React.createElement("ul", { className: "text-sm mt-2" }, Object.keys(servers).map(function (serverName) { return (React.createElement(ServerItem, { serverName: serverName, key: serverName })); })));
|
|
91
|
+
}
|
|
92
|
+
var specTagNames;
|
|
93
|
+
if (showServers === 'bySpecTags') {
|
|
94
|
+
specTagNames = (asyncapi.tags() || []).map(function (tag) { return tag.name(); });
|
|
95
|
+
}
|
|
96
|
+
else {
|
|
97
|
+
var serverTagNamesSet_1 = new Set();
|
|
98
|
+
Object.values(servers).forEach(function (server) {
|
|
99
|
+
if (typeof server.tags !== 'function') {
|
|
100
|
+
return;
|
|
94
101
|
}
|
|
102
|
+
server.tags().forEach(function (t) { return serverTagNamesSet_1.add(t.name()); });
|
|
103
|
+
});
|
|
104
|
+
specTagNames = Array.from(serverTagNamesSet_1);
|
|
105
|
+
}
|
|
106
|
+
var serializedServers = Object.entries(servers).map(function (_a) {
|
|
107
|
+
var serverName = _a[0], server = _a[1];
|
|
108
|
+
return ({
|
|
109
|
+
name: serverName,
|
|
110
|
+
object: server,
|
|
111
|
+
data: {},
|
|
95
112
|
});
|
|
96
|
-
return operationsList;
|
|
97
|
-
};
|
|
98
|
-
var untaggedOperations = [];
|
|
99
|
-
Object.entries(channels).forEach(function (_a) {
|
|
100
|
-
var channelName = _a[0], channel = _a[1];
|
|
101
|
-
if (channel.hasPublish() &&
|
|
102
|
-
(!channel.publish().hasTags() ||
|
|
103
|
-
!SpecificationHelpers.containTags(channel.publish(), tags))) {
|
|
104
|
-
untaggedOperations.push(React.createElement(OperationsPubItem, { channelName: channelName, key: "pub-".concat(channelName) }));
|
|
105
|
-
}
|
|
106
|
-
if (channel.hasSubscribe() &&
|
|
107
|
-
(!channel.subscribe().hasTags() ||
|
|
108
|
-
!SpecificationHelpers.containTags(channel.subscribe(), tags))) {
|
|
109
|
-
untaggedOperations.push(React.createElement(OperationsSubItem, { channelName: channelName, key: "sub-".concat(channelName) }));
|
|
110
|
-
}
|
|
111
113
|
});
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
114
|
+
var _a = filterObjectsByTags(specTagNames, serializedServers), tagged = _a.tagged, untagged = _a.untagged;
|
|
115
|
+
return (React.createElement("ul", { className: "text-sm mt-2" },
|
|
116
|
+
Array.from(tagged.entries()).map(function (_a) {
|
|
117
|
+
var tag = _a[0], taggedServers = _a[1];
|
|
118
|
+
return (React.createElement("li", { key: tag },
|
|
119
|
+
React.createElement(ItemsByTagItem, { tagName: tag }, taggedServers.map(function (_a) {
|
|
120
|
+
var serverName = _a.name;
|
|
121
|
+
return (React.createElement(ServerItem, { serverName: serverName, key: serverName }));
|
|
122
|
+
}))));
|
|
123
|
+
}),
|
|
124
|
+
untagged.length > 0 ? (React.createElement("li", null,
|
|
125
|
+
React.createElement(ItemsByTagItem, { tagName: "Untagged" }, untagged.map(function (_a) {
|
|
126
|
+
var serverName = _a.name;
|
|
127
|
+
return (React.createElement(ServerItem, { serverName: serverName, key: serverName }));
|
|
128
|
+
})))) : null));
|
|
122
129
|
};
|
|
123
|
-
|
|
130
|
+
var OperationsList = function () {
|
|
131
|
+
var sidebarConfig = useConfig().sidebar;
|
|
124
132
|
var asyncapi = useSpec();
|
|
125
133
|
var channels = asyncapi.channels();
|
|
126
|
-
var
|
|
127
|
-
var
|
|
128
|
-
var operationsList = [];
|
|
129
|
-
Object.entries(channels).forEach(function (_a) {
|
|
130
|
-
var channelName = _a[0], channel = _a[1];
|
|
131
|
-
if (channel.hasPublish() &&
|
|
132
|
-
SpecificationHelpers.containTags(channel.publish(), tag)) {
|
|
133
|
-
operationsList.push(React.createElement(OperationsPubItem, { channelName: channelName, key: "pub-".concat(channelName) }));
|
|
134
|
-
}
|
|
135
|
-
if (channel.hasSubscribe() &&
|
|
136
|
-
SpecificationHelpers.containTags(channel.subscribe(), tag)) {
|
|
137
|
-
operationsList.push(React.createElement(OperationsSubItem, { channelName: channelName, key: "sub-".concat(channelName) }));
|
|
138
|
-
}
|
|
139
|
-
});
|
|
140
|
-
return operationsList;
|
|
141
|
-
};
|
|
142
|
-
var untaggedOperations = [];
|
|
134
|
+
var showOperations = (sidebarConfig === null || sidebarConfig === void 0 ? void 0 : sidebarConfig.showOperations) || 'byDefault';
|
|
135
|
+
var operations = [];
|
|
143
136
|
Object.entries(channels).forEach(function (_a) {
|
|
144
137
|
var channelName = _a[0], channel = _a[1];
|
|
145
|
-
if (channel.hasPublish()
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
138
|
+
if (channel.hasPublish()) {
|
|
139
|
+
operations.push({
|
|
140
|
+
name: "publish-".concat(channelName),
|
|
141
|
+
object: channel.publish(),
|
|
142
|
+
data: { channelName: channelName, kind: 'publish' },
|
|
143
|
+
});
|
|
149
144
|
}
|
|
150
|
-
if (channel.hasSubscribe()
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
145
|
+
if (channel.hasSubscribe()) {
|
|
146
|
+
operations.push({
|
|
147
|
+
name: "subscribe-".concat(channelName),
|
|
148
|
+
object: channel.subscribe(),
|
|
149
|
+
data: { channelName: channelName, kind: 'subscribe' },
|
|
150
|
+
});
|
|
154
151
|
}
|
|
155
152
|
});
|
|
156
|
-
|
|
157
|
-
React.createElement("ul",
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
153
|
+
if (showOperations === 'byDefault') {
|
|
154
|
+
return (React.createElement("ul", { className: "text-sm mt-2" }, operations.map(function (_a) {
|
|
155
|
+
var name = _a.name, _b = _a.data, channelName = _b.channelName, kind = _b.kind;
|
|
156
|
+
return (React.createElement(OperationItem, { channelName: channelName, kind: kind, key: name }));
|
|
157
|
+
})));
|
|
158
|
+
}
|
|
159
|
+
var operationTagNames;
|
|
160
|
+
if (showOperations === 'bySpecTags') {
|
|
161
|
+
operationTagNames = (asyncapi.tags() || []).map(function (tag) { return tag.name(); });
|
|
162
|
+
}
|
|
163
|
+
else {
|
|
164
|
+
var operationTagNamesSet_1 = new Set();
|
|
165
|
+
Object.values(operations).forEach(function (_a) {
|
|
166
|
+
var object = _a.object;
|
|
167
|
+
if (typeof object.tags !== 'function') {
|
|
168
|
+
return;
|
|
169
|
+
}
|
|
170
|
+
object.tags().forEach(function (t) { return operationTagNamesSet_1.add(t.name()); });
|
|
171
|
+
});
|
|
172
|
+
operationTagNames = Array.from(operationTagNamesSet_1);
|
|
173
|
+
}
|
|
174
|
+
var _a = filterObjectsByTags(operationTagNames, operations), tagged = _a.tagged, untagged = _a.untagged;
|
|
175
|
+
return (React.createElement("ul", { className: "text-sm mt-2" },
|
|
176
|
+
Array.from(tagged.entries()).map(function (_a) {
|
|
177
|
+
var tag = _a[0], taggedOperations = _a[1];
|
|
178
|
+
return (React.createElement("li", { key: tag },
|
|
179
|
+
React.createElement(ItemsByTagItem, { tagName: tag }, taggedOperations.map(function (_a) {
|
|
180
|
+
var name = _a.name, _b = _a.data, kind = _b.kind, channelName = _b.channelName;
|
|
181
|
+
return (React.createElement(OperationItem, { channelName: channelName, kind: kind, key: name }));
|
|
182
|
+
}))));
|
|
183
|
+
}),
|
|
184
|
+
untagged.length > 0 ? (React.createElement("li", null,
|
|
185
|
+
React.createElement(ItemsByTagItem, { tagName: "Untagged" }, untagged.map(function (_a) {
|
|
186
|
+
var name = _a.name, _b = _a.data, kind = _b.kind, channelName = _b.channelName;
|
|
187
|
+
return (React.createElement(OperationItem, { channelName: channelName, kind: kind, key: name }));
|
|
188
|
+
})))) : null));
|
|
166
189
|
};
|
|
167
|
-
var
|
|
190
|
+
var OperationItem = function (_a) {
|
|
191
|
+
var channelName = _a.channelName, kind = _a.kind;
|
|
192
|
+
var config = useConfig();
|
|
193
|
+
var setShowSidebar = useContext(SidebarContext).setShowSidebar;
|
|
194
|
+
var isPublish = kind === 'publish';
|
|
195
|
+
var label = '';
|
|
196
|
+
if (isPublish) {
|
|
197
|
+
label = config.publishLabel || PUBLISH_LABEL_DEFAULT_TEXT;
|
|
198
|
+
}
|
|
199
|
+
else {
|
|
200
|
+
label = config.subscribeLabel || SUBSCRIBE_LABEL_DEFAULT_TEXT;
|
|
201
|
+
}
|
|
202
|
+
return (React.createElement("li", null,
|
|
203
|
+
React.createElement("a", { className: "flex no-underline text-gray-700 mb-2 hover:text-gray-900", href: "#operation-".concat(kind, "-").concat(channelName), onClick: function () { return setShowSidebar(false); } },
|
|
204
|
+
React.createElement("span", { className: "".concat(isPublish ? 'bg-blue-600' : 'bg-green-600', " font-bold h-6 no-underline text-white uppercase p-1 mr-2 rounded text-xs"), title: isPublish ? 'Publish' : 'Subscribe' }, label),
|
|
205
|
+
React.createElement("span", { className: "break-all inline-block" }, channelName))));
|
|
206
|
+
};
|
|
207
|
+
var ServerItem = function (_a) {
|
|
208
|
+
var serverName = _a.serverName;
|
|
209
|
+
var setShowSidebar = useContext(SidebarContext).setShowSidebar;
|
|
210
|
+
return (React.createElement("li", null,
|
|
211
|
+
React.createElement("a", { className: "flex no-underline text-gray-700 mb-2 hover:text-gray-900", href: "#server-".concat(serverName), onClick: function () { return setShowSidebar(false); } },
|
|
212
|
+
React.createElement("span", { className: "break-all inline-block" }, serverName))));
|
|
213
|
+
};
|
|
214
|
+
var ItemsByTagItem = function (_a) {
|
|
168
215
|
var tagName = _a.tagName, children = _a.children;
|
|
169
216
|
var _b = useState(false), expand = _b[0], setExpand = _b[1];
|
|
170
217
|
return (React.createElement("div", null,
|
|
@@ -174,22 +221,4 @@ var OperationsByTagItem = function (_a) {
|
|
|
174
221
|
React.createElement("span", { className: "text-sm inline-block mt-1 font-extralight" }, tagName)),
|
|
175
222
|
React.createElement("ul", { className: "".concat(expand ? 'block' : 'hidden', " text-sm mt-2 font-light") }, children)));
|
|
176
223
|
};
|
|
177
|
-
var OperationsPubItem = function (_a) {
|
|
178
|
-
var channelName = _a.channelName;
|
|
179
|
-
var config = useConfig();
|
|
180
|
-
var setShowSidebar = useContext(SidebarContext).setShowSidebar;
|
|
181
|
-
return (React.createElement("li", null,
|
|
182
|
-
React.createElement("a", { className: "flex no-underline text-gray-700 mb-2 hover:text-gray-900", href: "#operation-publish-".concat(channelName), onClick: function () { return setShowSidebar(false); } },
|
|
183
|
-
React.createElement("span", { className: "bg-blue-600 font-bold h-6 no-underline text-white uppercase p-1 mr-2 rounded text-xs", title: "Publish" }, config.publishLabel || PUBLISH_LABEL_DEFAULT_TEXT),
|
|
184
|
-
React.createElement("span", { className: "break-all inline-block" }, channelName))));
|
|
185
|
-
};
|
|
186
|
-
var OperationsSubItem = function (_a) {
|
|
187
|
-
var channelName = _a.channelName;
|
|
188
|
-
var config = useConfig();
|
|
189
|
-
var setShowSidebar = useContext(SidebarContext).setShowSidebar;
|
|
190
|
-
return (React.createElement("li", null,
|
|
191
|
-
React.createElement("a", { className: "flex no-underline text-gray-700 mb-2 hover:text-gray-900", href: "#operation-subscribe-".concat(channelName), onClick: function () { return setShowSidebar(false); } },
|
|
192
|
-
React.createElement("span", { className: "bg-green-600 font-bold h-6 no-underline text-white uppercase p-1 mr-2 rounded text-xs", title: "Subscribe" }, config.subscribeLabel || SUBSCRIBE_LABEL_DEFAULT_TEXT),
|
|
193
|
-
React.createElement("span", { className: "break-all inline-block" }, channelName))));
|
|
194
|
-
};
|
|
195
224
|
//# sourceMappingURL=Sidebar.js.map
|