@asyncapi/react-component 1.0.0-next.50 → 1.0.0-next.52

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (74) hide show
  1. package/browser/index.js +6 -30
  2. package/browser/index.js.LICENSE.txt +1 -1
  3. package/browser/standalone/index.js +6 -30
  4. package/browser/standalone/index.js.LICENSE.txt +1 -1
  5. package/browser/standalone/without-parser.js +3 -9
  6. package/browser/standalone/without-parser.js.LICENSE.txt +1 -1
  7. package/browser/without-parser.js +3 -9
  8. package/browser/without-parser.js.LICENSE.txt +1 -1
  9. package/lib/cjs/components/Bindings.js +7 -6
  10. package/lib/cjs/components/Bindings.js.map +1 -1
  11. package/lib/cjs/components/Schema.js +2 -2
  12. package/lib/cjs/components/Schema.js.map +1 -1
  13. package/lib/cjs/components/Tags.js +1 -1
  14. package/lib/cjs/components/Tags.js.map +1 -1
  15. package/lib/cjs/containers/AsyncApi/AsyncApi.js +21 -11
  16. package/lib/cjs/containers/AsyncApi/AsyncApi.js.map +1 -1
  17. package/lib/cjs/containers/AsyncApi/Standalone.js +1 -1
  18. package/lib/cjs/containers/Messages/Messages.js +8 -7
  19. package/lib/cjs/containers/Messages/Messages.js.map +1 -1
  20. package/lib/cjs/containers/Operations/Operation.js +26 -12
  21. package/lib/cjs/containers/Operations/Operation.js.map +1 -1
  22. package/lib/cjs/containers/Operations/Operations.js +11 -7
  23. package/lib/cjs/containers/Operations/Operations.js.map +1 -1
  24. package/lib/cjs/containers/Schemas/Schemas.js +8 -7
  25. package/lib/cjs/containers/Schemas/Schemas.js.map +1 -1
  26. package/lib/cjs/containers/Servers/Servers.js +6 -4
  27. package/lib/cjs/containers/Servers/Servers.js.map +1 -1
  28. package/lib/cjs/helpers/parser.js +1 -1
  29. package/lib/cjs/helpers/parser.js.map +1 -1
  30. package/lib/cjs/helpers/schema.js +36 -21
  31. package/lib/cjs/helpers/schema.js.map +1 -1
  32. package/lib/esm/components/Bindings.js +7 -6
  33. package/lib/esm/components/Bindings.js.map +1 -1
  34. package/lib/esm/components/Schema.js +2 -2
  35. package/lib/esm/components/Schema.js.map +1 -1
  36. package/lib/esm/components/Tags.js +1 -1
  37. package/lib/esm/components/Tags.js.map +1 -1
  38. package/lib/esm/containers/AsyncApi/AsyncApi.js +21 -11
  39. package/lib/esm/containers/AsyncApi/AsyncApi.js.map +1 -1
  40. package/lib/esm/containers/AsyncApi/Standalone.js +1 -1
  41. package/lib/esm/containers/Messages/Messages.js +8 -7
  42. package/lib/esm/containers/Messages/Messages.js.map +1 -1
  43. package/lib/esm/containers/Operations/Operation.js +26 -12
  44. package/lib/esm/containers/Operations/Operation.js.map +1 -1
  45. package/lib/esm/containers/Operations/Operations.js +11 -7
  46. package/lib/esm/containers/Operations/Operations.js.map +1 -1
  47. package/lib/esm/containers/Schemas/Schemas.js +8 -7
  48. package/lib/esm/containers/Schemas/Schemas.js.map +1 -1
  49. package/lib/esm/containers/Servers/Servers.js +6 -4
  50. package/lib/esm/containers/Servers/Servers.js.map +1 -1
  51. package/lib/esm/helpers/parser.js +1 -1
  52. package/lib/esm/helpers/parser.js.map +1 -1
  53. package/lib/esm/helpers/schema.js +36 -21
  54. package/lib/esm/helpers/schema.js.map +1 -1
  55. package/lib/types/components/Bindings.d.ts +2 -1
  56. package/lib/types/components/Bindings.d.ts.map +1 -1
  57. package/lib/types/components/Tags.d.ts +2 -2
  58. package/lib/types/components/Tags.d.ts.map +1 -1
  59. package/lib/types/containers/AsyncApi/AsyncApi.d.ts +2 -2
  60. package/lib/types/containers/AsyncApi/AsyncApi.d.ts.map +1 -1
  61. package/lib/types/containers/AsyncApi/Standalone.d.ts +2 -2
  62. package/lib/types/containers/AsyncApi/Standalone.d.ts.map +1 -1
  63. package/lib/types/containers/Messages/Messages.d.ts.map +1 -1
  64. package/lib/types/containers/Operations/Operation.d.ts.map +1 -1
  65. package/lib/types/containers/Operations/Operations.d.ts.map +1 -1
  66. package/lib/types/containers/Schemas/Schemas.d.ts.map +1 -1
  67. package/lib/types/containers/Servers/Servers.d.ts.map +1 -1
  68. package/lib/types/helpers/parser.d.ts.map +1 -1
  69. package/lib/types/helpers/schema.d.ts.map +1 -1
  70. package/lib/types/types.d.ts +2 -2
  71. package/lib/types/types.d.ts.map +1 -1
  72. package/package.json +3 -3
  73. package/styles/default.css +60 -42
  74. package/styles/default.min.css +1 -1
@@ -68,7 +68,7 @@ OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
68
68
  PERFORMANCE OF THIS SOFTWARE.
69
69
  ***************************************************************************** */
70
70
 
71
- /*! @license DOMPurify 2.3.6 | (c) Cure53 and other contributors | Released under the Apache license 2.0 and Mozilla Public License 2.0 | github.com/cure53/DOMPurify/blob/2.3.6/LICENSE */
71
+ /*! @license DOMPurify 2.4.7 | (c) Cure53 and other contributors | Released under the Apache license 2.0 and Mozilla Public License 2.0 | github.com/cure53/DOMPurify/blob/2.4.7/LICENSE */
72
72
 
73
73
  /*! https://mths.be/punycode v1.4.0 by @mathias */
74
74
 
@@ -9,16 +9,17 @@ var Schema_1 = require("./Schema");
9
9
  var helpers_1 = require("../helpers");
10
10
  var Bindings = function (_a) {
11
11
  var _b = _a.name, name = _b === void 0 ? 'Binding specific information' : _b, bindings = _a.bindings;
12
- if (!bindings || !Object.keys(bindings).length) {
12
+ if (!bindings || bindings.isEmpty()) {
13
13
  return null;
14
14
  }
15
- var renderedBindings = Object.entries(bindings).map(function (_a) {
16
- var bindingName = _a[0], binding = _a[1];
17
- var schema = helpers_1.SchemaHelpers.jsonToSchema(binding);
15
+ var renderedBindings = bindings.all().map(function (binding) {
16
+ var bindingValue = binding.value();
17
+ var schema = helpers_1.SchemaHelpers.jsonToSchema(bindingValue);
18
+ var protocol = binding.protocol();
18
19
  var schemaName = (react_1.default.createElement("div", { className: "inline-block text-sm" },
19
20
  react_1.default.createElement("span", null, name),
20
- react_1.default.createElement("span", { className: "bg-teal-500 font-bold no-underline text-white uppercase rounded mx-2 px-2 py-1 text-xs" }, bindingName)));
21
- return (schema && (react_1.default.createElement(Schema_1.Schema, { schemaName: schemaName, schema: schema, key: bindingName, onlyTitle: true })));
21
+ react_1.default.createElement("span", { className: "bg-teal-500 font-bold no-underline text-white uppercase rounded mx-2 px-2 py-1 text-xs" }, protocol)));
22
+ return (schema !== undefined && (react_1.default.createElement(Schema_1.Schema, { schemaName: schemaName, schema: schema, key: protocol, onlyTitle: true })));
22
23
  });
23
24
  return react_1.default.createElement(react_1.default.Fragment, null, renderedBindings);
24
25
  };
@@ -1 +1 @@
1
- {"version":3,"file":"Bindings.js","sourceRoot":"","sources":["../../../src/components/Bindings.tsx"],"names":[],"mappings":";;;;;;AAAA,gDAA0B;AAE1B,mCAAkC;AAElC,sCAA2C;AAOpC,IAAM,QAAQ,GAAmC,UAAC,EAGxD;QAFC,YAAqC,EAArC,IAAI,mBAAG,8BAA8B,KAAA,EACrC,QAAQ,cAAA;IAER,IAAI,CAAC,QAAQ,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,MAAM,EAAE;QAC9C,OAAO,IAAI,CAAC;KACb;IAED,IAAM,gBAAgB,GAAG,MAAM,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,GAAG,CACnD,UAAC,EAAsB;YAArB,WAAW,QAAA,EAAE,OAAO,QAAA;QACpB,IAAM,MAAM,GAAG,uBAAa,CAAC,YAAY,CAAC,OAAO,CAAC,CAAC;QACnD,IAAM,UAAU,GAAG,CACjB,uCAAK,SAAS,EAAC,sBAAsB;YACnC,4CAAO,IAAI,CAAQ;YACnB,wCAAM,SAAS,EAAC,wFAAwF,IACrG,WAAW,CACP,CACH,CACP,CAAC;QACF,OAAO,CACL,MAAM,IAAI,CACR,8BAAC,eAAM,IACL,UAAU,EAAE,UAAU,EACtB,MAAM,EAAE,MAAM,EACd,GAAG,EAAE,WAAW,EAChB,SAAS,EAAE,IAAI,GACf,CACH,CACF,CAAC;IACJ,CAAC,CACF,CAAC;IACF,OAAO,8DAAG,gBAAgB,CAAI,CAAC;AACjC,CAAC,CAAC;AAhCW,QAAA,QAAQ,YAgCnB","sourcesContent":["import React from 'react';\n\nimport { Schema } from './Schema';\n\nimport { SchemaHelpers } from '../helpers';\n\ninterface Props {\n name?: string;\n bindings: any;\n}\n\nexport const Bindings: React.FunctionComponent<Props> = ({\n name = 'Binding specific information',\n bindings,\n}) => {\n if (!bindings || !Object.keys(bindings).length) {\n return null;\n }\n\n const renderedBindings = Object.entries(bindings).map(\n ([bindingName, binding]) => {\n const schema = SchemaHelpers.jsonToSchema(binding);\n const schemaName = (\n <div className=\"inline-block text-sm\">\n <span>{name}</span>\n <span className=\"bg-teal-500 font-bold no-underline text-white uppercase rounded mx-2 px-2 py-1 text-xs\">\n {bindingName}\n </span>\n </div>\n );\n return (\n schema && (\n <Schema\n schemaName={schemaName}\n schema={schema}\n key={bindingName}\n onlyTitle={true}\n />\n )\n );\n },\n );\n return <>{renderedBindings}</>;\n};\n"]}
1
+ {"version":3,"file":"Bindings.js","sourceRoot":"","sources":["../../../src/components/Bindings.tsx"],"names":[],"mappings":";;;;;;AAAA,gDAA0B;AAC1B,mCAAkC;AAClC,sCAA2C;AAQpC,IAAM,QAAQ,GAAmC,UAAC,EAGxD;QAFC,YAAqC,EAArC,IAAI,mBAAG,8BAA8B,KAAA,EACrC,QAAQ,cAAA;IAER,IAAI,CAAC,QAAQ,IAAI,QAAQ,CAAC,OAAO,EAAE,EAAE;QACnC,OAAO,IAAI,CAAC;KACb;IAED,IAAM,gBAAgB,GAAG,QAAQ,CAAC,GAAG,EAAE,CAAC,GAAG,CAAC,UAAA,OAAO;QACjD,IAAM,YAAY,GAAG,OAAO,CAAC,KAAK,EAAE,CAAC;QACrC,IAAM,MAAM,GAAG,uBAAa,CAAC,YAAY,CAAC,YAAY,CAAC,CAAC;QACxD,IAAM,QAAQ,GAAG,OAAO,CAAC,QAAQ,EAAE,CAAC;QACpC,IAAM,UAAU,GAAG,CACjB,uCAAK,SAAS,EAAC,sBAAsB;YACnC,4CAAO,IAAI,CAAQ;YACnB,wCAAM,SAAS,EAAC,wFAAwF,IACrG,QAAQ,CACJ,CACH,CACP,CAAC;QACF,OAAO,CACL,MAAM,KAAK,SAAS,IAAI,CACtB,8BAAC,eAAM,IACL,UAAU,EAAE,UAAU,EACtB,MAAM,EAAE,MAAM,EACd,GAAG,EAAE,QAAQ,EACb,SAAS,EAAE,IAAI,GACf,CACH,CACF,CAAC;IACJ,CAAC,CAAC,CAAC;IAEH,OAAO,8DAAG,gBAAgB,CAAI,CAAC;AACjC,CAAC,CAAC;AAjCW,QAAA,QAAQ,YAiCnB","sourcesContent":["import React from 'react';\nimport { Schema } from './Schema';\nimport { SchemaHelpers } from '../helpers';\nimport { BindingsInterface } from '@asyncapi/parser';\n\ninterface Props {\n name?: string;\n bindings: BindingsInterface;\n}\n\nexport const Bindings: React.FunctionComponent<Props> = ({\n name = 'Binding specific information',\n bindings,\n}) => {\n if (!bindings || bindings.isEmpty()) {\n return null;\n }\n\n const renderedBindings = bindings.all().map(binding => {\n const bindingValue = binding.value();\n const schema = SchemaHelpers.jsonToSchema(bindingValue);\n const protocol = binding.protocol();\n const schemaName = (\n <div className=\"inline-block text-sm\">\n <span>{name}</span>\n <span className=\"bg-teal-500 font-bold no-underline text-white uppercase rounded mx-2 px-2 py-1 text-xs\">\n {protocol}\n </span>\n </div>\n );\n return (\n schema !== undefined && (\n <Schema\n schemaName={schemaName}\n schema={schema}\n key={protocol}\n onlyTitle={true}\n />\n )\n );\n });\n\n return <>{renderedBindings}</>;\n};\n"]}
@@ -151,8 +151,8 @@ var Schema = function (_a) {
151
151
  exports.Schema = Schema;
152
152
  var SchemaProperties = function (_a) {
153
153
  var schema = _a.schema;
154
- var properties = schema.properties() || {};
155
- if (!Object.keys(properties)) {
154
+ var properties = schema.properties();
155
+ if (properties === undefined || !Object.keys(properties)) {
156
156
  return null;
157
157
  }
158
158
  var required = schema.required() || [];
@@ -1 +1 @@
1
- {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,CAAC,OAAO,CAAC,EAAE;QACjD,OAAO,IAAI,CAAC;KACb;IACD,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC,EAAE;QAClC,OAAO,IAAI,CAAC;KACb;IAED,IAAM,eAAe,GAAG,MAAM,CAAC,eAAe,EAAS,CAAC;IACxD,IAAI,eAAe,KAAK,IAAI,IAAI,eAAe,KAAK,SAAS,EAAE;QAC7D,OAAO,CACL,qCAAG,SAAS,EAAC,4BAA4B,oCAErC,CACL,CAAC;KACH;IACD,IAAI,eAAe,KAAK,KAAK,EAAE;QAC7B,OAAO,CACL,qCAAG,SAAS,EAAC,4BAA4B;;YAClB,oDAAoB;wBACvC,CACL,CAAC;KACH;IACD,OAAO,8BAAC,cAAM,IAAC,UAAU,EAAC,mBAAmB,EAAC,MAAM,EAAE,eAAe,GAAI,CAAC;AAC5E,CAAC,CAAC","sourcesContent":["import React, { useState, useEffect, useContext } from 'react';\nimport { SchemaInterface } from '@asyncapi/parser';\n\nimport { Href, CollapseButton, Markdown, Extensions } from './index';\nimport { SchemaHelpers } from '../helpers';\n\ninterface Props {\n schemaName?: React.ReactNode;\n schema?: SchemaInterface;\n required?: boolean;\n isPatternProperty?: boolean;\n isProperty?: boolean;\n isCircular?: boolean;\n dependentRequired?: string[];\n expanded?: boolean;\n onlyTitle?: boolean;\n}\n\nconst SchemaContext = React.createContext({\n reverse: false,\n deepExpanded: false,\n});\n\nexport const Schema: React.FunctionComponent<Props> = ({\n schemaName,\n schema,\n required = false,\n isPatternProperty = false,\n isProperty = false,\n isCircular = false,\n dependentRequired,\n expanded: propExpanded = false,\n onlyTitle = false,\n}) => {\n const { reverse, deepExpanded } = useContext(SchemaContext);\n const [expanded, setExpanded] = useState(propExpanded);\n const [deepExpand, setDeepExpand] = useState(false);\n\n useEffect(() => {\n setDeepExpand(deepExpanded);\n }, [deepExpanded, setDeepExpand]);\n\n useEffect(() => {\n setExpanded(deepExpand);\n }, [deepExpand, setExpanded]);\n\n if (\n !schema ||\n (typeof schemaName === 'string' &&\n (schemaName?.startsWith('x-parser-') ||\n schemaName?.startsWith('x-schema-private-')))\n ) {\n return null;\n }\n\n const dependentSchemas = SchemaHelpers.getDependentSchemas(schema);\n\n const constraints = SchemaHelpers.humanizeConstraints(schema);\n const externalDocs = schema.externalDocs();\n\n const rawValueExt = schema.extensions().get(SchemaHelpers.extRawValue);\n const rawValue = rawValueExt?.value() === true;\n\n const parameterLocationExt = schema\n .extensions()\n .get(SchemaHelpers.extParameterLocation);\n const parameterLocation = parameterLocationExt?.value() === true;\n\n const schemaType = SchemaHelpers.toSchemaType(schema);\n const isExpandable = SchemaHelpers.isExpandable(schema) || dependentSchemas;\n\n isCircular = isCircular || schema.isCircular() || false;\n const uid = schema.$id();\n const styledSchemaName = isProperty ? 'italic' : '';\n const renderedSchemaName =\n typeof schemaName === 'string' ? (\n <span className={`break-anywhere text-sm ${styledSchemaName}`}>\n {schemaName}\n </span>\n ) : (\n schemaName\n );\n\n return (\n <SchemaContext.Provider\n value={{ reverse: !reverse, deepExpanded: deepExpand }}\n >\n <div>\n <div className=\"flex py-2\">\n <div className={`${onlyTitle ? '' : 'min-w-1/4'} mr-2`}>\n {isExpandable && !isCircular ? (\n <>\n <CollapseButton\n onClick={() => setExpanded(prev => !prev)}\n expanded={expanded}\n >\n {renderedSchemaName}\n </CollapseButton>\n <button\n type=\"button\"\n onClick={() => setDeepExpand(prev => !prev)}\n className=\"ml-1 text-sm text-gray-500\"\n >\n {deepExpand ? 'Collapse all' : 'Expand all'}\n </button>\n </>\n ) : (\n <span\n className={`break-anywhere text-sm ${\n isProperty ? 'italic' : ''\n }`}\n >\n {schemaName}\n </span>\n )}\n {isPatternProperty && (\n <div className=\"text-gray-500 text-xs italic\">\n (pattern property)\n </div>\n )}\n {required && <div className=\"text-red-600 text-xs\">required</div>}\n {dependentRequired && (\n <>\n <div className=\"text-gray-500 text-xs\">\n required when defined:\n </div>\n <div className=\"text-red-600 text-xs\">\n {dependentRequired.join(', ')}\n </div>\n </>\n )}\n {schema.deprecated() && (\n <div className=\"text-red-600 text-xs\">deprecated</div>\n )}\n {schema.writeOnly() && (\n <div className=\"text-gray-500 text-xs\">write-only</div>\n )}\n {schema.readOnly() && (\n <div className=\"text-gray-500 text-xs\">read-only</div>\n )}\n </div>\n {rawValue ? (\n <div>\n <div className=\"text-sm\">\n {SchemaHelpers.prettifyValue(schema.const(), false)}\n </div>\n </div>\n ) : (\n <div>\n <div>\n <div className=\"capitalize text-sm text-teal-500 font-bold inline-block mr-2\">\n {isCircular ? `${schemaType} [CIRCULAR]` : schemaType}\n </div>\n <div className=\"inline-block\">\n {schema.format() && (\n <span className=\"bg-yellow-600 font-bold no-underline text-white rounded lowercase mr-2 p-1 text-xs\">\n format: {schema.format()}\n </span>\n )}\n\n {/* related to string */}\n {schema.pattern() !== undefined && (\n <span className=\"bg-yellow-600 font-bold no-underline text-white rounded mr-2 p-1 text-xs\">\n must match: {schema.pattern()}\n </span>\n )}\n {schema.contentMediaType() !== undefined && (\n <span className=\"bg-yellow-600 font-bold no-underline text-white rounded lowercase mr-2 p-1 text-xs\">\n media type: {schema.contentMediaType()}\n </span>\n )}\n {schema.contentEncoding() !== undefined && (\n <span className=\"bg-yellow-600 font-bold no-underline text-white rounded lowercase mr-2 p-1 text-xs\">\n encoding: {schema.contentEncoding()}\n </span>\n )}\n\n {/* constraints */}\n {!!constraints.length &&\n constraints.map(c => (\n <span\n className=\"bg-purple-600 font-bold no-underline text-white rounded lowercase mr-2 p-1 text-xs\"\n key={c}\n >\n {c}\n </span>\n ))}\n\n {uid && !uid.startsWith('<anonymous-') && (\n <span className=\"border text-orange-600 rounded mr-2 p-1 text-xs\">\n uid: {uid}\n </span>\n )}\n </div>\n\n {schema.description() !== undefined && (\n <div>\n <Markdown>{schema.description()}</Markdown>\n </div>\n )}\n\n {schema.default() !== undefined && (\n <div className=\"text-xs\">\n Default value:\n <span className=\"border inline-block text-orange-600 rounded ml-1 py-0 px-2\">\n {SchemaHelpers.prettifyValue(schema.default())}\n </span>\n </div>\n )}\n {schema.const() !== undefined && (\n <div className=\"text-xs\">\n Const:\n <span className=\"border inline-block text-orange-600 rounded ml-1 py-0 px-2\">\n {SchemaHelpers.prettifyValue(schema.const())}\n </span>\n </div>\n )}\n {schema.enum() && (\n <ul className=\"text-xs\">\n Allowed values:{' '}\n {schema.enum()?.map((e, idx) => (\n <li\n key={idx}\n className=\"border inline-block text-orange-600 rounded ml-1 py-0 px-2\"\n >\n <span>{SchemaHelpers.prettifyValue(e)}</span>\n </li>\n ))}\n </ul>\n )}\n {parameterLocation && (\n <div className=\"text-xs\">\n Parameter location:{' '}\n <span className=\"border text-orange-600 rounded mr-2 p-1 text-xs\">\n {parameterLocation}\n </span>\n </div>\n )}\n {externalDocs && (\n <span className=\"border border-solid border-orange-300 hover:bg-orange-300 hover:text-orange-600 text-orange-500 font-bold no-underline text-xs uppercase rounded px-2 py-0\">\n <Href\n href={externalDocs.url()}\n title={externalDocs.description() || ''}\n >\n Documentation\n </Href>\n </span>\n )}\n {schema.examples() && (\n <ul className=\"text-xs\">\n Examples values:{' '}\n {schema.examples()?.map((e, idx) => (\n <li\n key={idx}\n className=\"border inline-block text-orange-600 rounded ml-1 py-0 px-2 break-all\"\n >\n <span>{SchemaHelpers.prettifyValue(e)}</span>\n </li>\n ))}\n </ul>\n )}\n </div>\n </div>\n )}\n </div>\n\n {isCircular || !isExpandable ? null : (\n <div\n className={`rounded p-4 py-2 border bg-gray-100 ${\n reverse ? 'bg-gray-200' : ''\n } ${expanded ? 'block' : 'hidden'}`}\n >\n <SchemaProperties schema={schema} />\n <SchemaItems schema={schema} />\n\n {schema.oneOf() &&\n schema\n .oneOf()\n ?.map((s, idx) => (\n <Schema\n key={idx}\n schema={s}\n schemaName={idx === 0 ? 'Adheres to:' : 'Or to:'}\n />\n ))}\n {schema.anyOf() &&\n schema\n .anyOf()\n ?.map((s, idx) => (\n <Schema\n key={idx}\n schema={s}\n schemaName={idx === 0 ? 'Can adhere to:' : 'Or to:'}\n />\n ))}\n {schema.allOf() &&\n schema\n .allOf()\n ?.map((s, idx) => (\n <Schema\n key={idx}\n schema={s}\n schemaName={idx === 0 ? 'Consists of:' : 'And with:'}\n />\n ))}\n {schema.not() && (\n <Schema schema={schema.not()} schemaName=\"Cannot adhere to:\" />\n )}\n\n {schema.propertyNames() && (\n <Schema\n schema={schema.propertyNames()}\n schemaName=\"Property names must adhere to:\"\n />\n )}\n {schema.contains() && (\n <Schema\n schema={schema.contains()}\n schemaName=\"Array must contain at least one of:\"\n />\n )}\n\n {schema.if() && (\n <Schema schema={schema.if()} schemaName=\"If schema adheres to:\" />\n )}\n {schema.then() && (\n <Schema\n schema={schema.then()}\n schemaName=\"Then must adhere to:\"\n />\n )}\n {schema.else() && (\n <Schema schema={schema.else()} schemaName=\"Otherwise:\" />\n )}\n\n {dependentSchemas && (\n <Schema\n schema={dependentSchemas}\n schemaName=\"Dependent schemas:\"\n />\n )}\n\n <Extensions item={schema} />\n\n <AdditionalProperties schema={schema} />\n <AdditionalItems schema={schema} />\n </div>\n )}\n </div>\n </SchemaContext.Provider>\n );\n};\n\ninterface SchemaPropertiesProps {\n schema: SchemaInterface;\n}\n\nconst SchemaProperties: React.FunctionComponent<SchemaPropertiesProps> = ({\n schema,\n}) => {\n const properties = schema.properties() || {};\n if (!Object.keys(properties)) {\n return null;\n }\n\n const required = schema.required() || [];\n const patternProperties = schema.patternProperties();\n\n return (\n <>\n {Object.entries(properties).map(([propertyName, property]) => (\n <Schema\n schema={property}\n schemaName={propertyName}\n required={required.includes(propertyName)}\n isProperty={true}\n isCircular={property.isCircular()}\n dependentRequired={SchemaHelpers.getDependentRequired(\n propertyName,\n schema,\n )}\n key={propertyName}\n />\n ))}\n {Object.entries(patternProperties || {}).map(\n ([propertyName, property]) => (\n <Schema\n schema={property}\n schemaName={propertyName}\n isPatternProperty={true}\n isProperty={true}\n isCircular={property.isCircular()}\n key={propertyName}\n />\n ),\n )}\n </>\n );\n};\n\ninterface AdditionalPropertiesProps {\n schema: SchemaInterface;\n}\n\nconst AdditionalProperties: React.FunctionComponent<AdditionalPropertiesProps> = ({\n schema,\n}) => {\n if (\n schema\n .extensions()\n .get(SchemaHelpers.extRenderAdditionalInfo)\n ?.value() === false\n ) {\n return null;\n }\n\n const type = schema.type();\n if (type === undefined || !type.includes('object')) {\n return null;\n }\n\n const additionalProperties = schema.additionalProperties();\n if (additionalProperties === true || additionalProperties === undefined) {\n return (\n <p className=\"mt-2 text-xs text-gray-700\">\n Additional properties are allowed.\n </p>\n );\n }\n if (additionalProperties === false) {\n return (\n <p className=\"mt-2 text-xs text-gray-700\">\n Additional properties are <strong>NOT</strong> allowed.\n </p>\n );\n }\n return (\n <Schema schemaName=\"Additional properties:\" schema={additionalProperties} />\n );\n};\n\ninterface SchemaItemsProps {\n schema: SchemaInterface;\n}\n\nconst SchemaItems: React.FunctionComponent<SchemaItemsProps> = ({ schema }) => {\n const type = schema.type();\n if (type === undefined || !type.includes('array')) {\n return null;\n }\n const items = schema.items();\n\n // object in items\n if (\n items &&\n !Array.isArray(items) &&\n Object.keys(items.properties() || {}).length\n ) {\n return <SchemaProperties schema={items} />;\n } else if (Array.isArray(items)) {\n return (\n <>\n {items.map((item, idx) => (\n <Schema schema={item} schemaName={`${idx + 1} item:`} key={idx} />\n ))}\n </>\n );\n }\n return <Schema schema={items} schemaName=\"Items:\" />;\n};\n\ninterface AdditionalItemsProps {\n schema: SchemaInterface;\n}\n\nconst AdditionalItems: React.FunctionComponent<AdditionalItemsProps> = ({\n schema,\n}) => {\n if (\n schema\n .extensions()\n .get(SchemaHelpers.extRenderAdditionalInfo)\n ?.value() === false\n ) {\n return null;\n }\n\n const type = schema.type();\n if (type === undefined || !type.includes('array')) {\n return null;\n }\n if (!Array.isArray(schema.items())) {\n return null;\n }\n\n const additionalItems = schema.additionalItems() as any;\n if (additionalItems === true || additionalItems === undefined) {\n return (\n <p className=\"mt-2 text-xs text-gray-700\">\n Additional items are allowed.\n </p>\n );\n }\n if (additionalItems === false) {\n return (\n <p className=\"mt-2 text-xs text-gray-700\">\n Additional items are <strong>NOT</strong> allowed.\n </p>\n );\n }\n return <Schema schemaName=\"Additional items:\" schema={additionalItems} />;\n};\n"]}
1
+ {"version":3,"file":"Schema.js","sourceRoot":"","sources":["../../../src/components/Schema.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,6CAA+D;AAG/D,iCAAqE;AACrE,sCAA2C;AAc3C,IAAM,aAAa,GAAG,eAAK,CAAC,aAAa,CAAC;IACxC,OAAO,EAAE,KAAK;IACd,YAAY,EAAE,KAAK;CACpB,CAAC,CAAC;AAEI,IAAM,MAAM,GAAmC,UAAC,EAUtD;;QATC,UAAU,gBAAA,EACV,MAAM,YAAA,EACN,gBAAgB,EAAhB,QAAQ,mBAAG,KAAK,KAAA,EAChB,yBAAyB,EAAzB,iBAAiB,mBAAG,KAAK,KAAA,EACzB,kBAAkB,EAAlB,UAAU,mBAAG,KAAK,KAAA,EAClB,kBAAkB,EAAlB,UAAU,mBAAG,KAAK,KAAA,EAClB,iBAAiB,uBAAA,EACjB,gBAA8B,EAApB,YAAY,mBAAG,KAAK,KAAA,EAC9B,iBAAiB,EAAjB,SAAS,mBAAG,KAAK,KAAA;IAEX,IAAA,KAA4B,IAAA,kBAAU,EAAC,aAAa,CAAC,EAAnD,OAAO,aAAA,EAAE,YAAY,kBAA8B,CAAC;IACtD,IAAA,KAA0B,IAAA,gBAAQ,EAAC,YAAY,CAAC,EAA/C,QAAQ,QAAA,EAAE,WAAW,QAA0B,CAAC;IACjD,IAAA,KAA8B,IAAA,gBAAQ,EAAC,KAAK,CAAC,EAA5C,UAAU,QAAA,EAAE,aAAa,QAAmB,CAAC;IAEpD,IAAA,iBAAS,EAAC;QACR,aAAa,CAAC,YAAY,CAAC,CAAC;IAC9B,CAAC,EAAE,CAAC,YAAY,EAAE,aAAa,CAAC,CAAC,CAAC;IAElC,IAAA,i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,0CACzC,KAAK,EAAE,MAAK,KAAK,EACrB;QACA,OAAO,IAAI,CAAC;KACb;IAED,IAAM,IAAI,GAAG,MAAM,CAAC,IAAI,EAAE,CAAC;IAC3B,IAAI,IAAI,KAAK,SAAS,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,EAAE;QACjD,OAAO,IAAI,CAAC;KACb;IACD,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC,EAAE;QAClC,OAAO,IAAI,CAAC;KACb;IAED,IAAM,eAAe,GAAG,MAAM,CAAC,eAAe,EAAS,CAAC;IACxD,IAAI,eAAe,KAAK,IAAI,IAAI,eAAe,KAAK,SAAS,EAAE;QAC7D,OAAO,CACL,qCAAG,SAAS,EAAC,4BAA4B,oCAErC,CACL,CAAC;KACH;IACD,IAAI,eAAe,KAAK,KAAK,EAAE;QAC7B,OAAO,CACL,qCAAG,SAAS,EAAC,4BAA4B;;YAClB,oDAAoB;wBACvC,CACL,CAAC;KACH;IACD,OAAO,8BAAC,cAAM,IAAC,UAAU,EAAC,mBAAmB,EAAC,MAAM,EAAE,eAAe,GAAI,CAAC;AAC5E,CAAC,CAAC","sourcesContent":["import React, { useState, useEffect, useContext } from 'react';\nimport { SchemaInterface } from '@asyncapi/parser';\n\nimport { Href, CollapseButton, Markdown, Extensions } from './index';\nimport { SchemaHelpers } from '../helpers';\n\ninterface Props {\n schemaName?: React.ReactNode;\n schema?: SchemaInterface;\n required?: boolean;\n isPatternProperty?: boolean;\n isProperty?: boolean;\n isCircular?: boolean;\n dependentRequired?: string[];\n expanded?: boolean;\n onlyTitle?: boolean;\n}\n\nconst SchemaContext = React.createContext({\n reverse: false,\n deepExpanded: false,\n});\n\nexport const Schema: React.FunctionComponent<Props> = ({\n schemaName,\n schema,\n required = false,\n isPatternProperty = false,\n isProperty = false,\n isCircular = false,\n dependentRequired,\n expanded: propExpanded = false,\n onlyTitle = false,\n}) => {\n const { reverse, deepExpanded } = useContext(SchemaContext);\n const [expanded, setExpanded] = useState(propExpanded);\n const [deepExpand, setDeepExpand] = useState(false);\n\n useEffect(() => {\n setDeepExpand(deepExpanded);\n }, [deepExpanded, setDeepExpand]);\n\n useEffect(() => {\n setExpanded(deepExpand);\n }, [deepExpand, setExpanded]);\n\n if (\n !schema ||\n (typeof schemaName === 'string' &&\n (schemaName?.startsWith('x-parser-') ||\n schemaName?.startsWith('x-schema-private-')))\n ) {\n return null;\n }\n\n const dependentSchemas = SchemaHelpers.getDependentSchemas(schema);\n\n const constraints = SchemaHelpers.humanizeConstraints(schema);\n const externalDocs = schema.externalDocs();\n\n const rawValueExt = schema.extensions().get(SchemaHelpers.extRawValue);\n const rawValue = rawValueExt?.value() === true;\n\n const parameterLocationExt = schema\n .extensions()\n .get(SchemaHelpers.extParameterLocation);\n const parameterLocation = parameterLocationExt?.value() === true;\n\n const schemaType = SchemaHelpers.toSchemaType(schema);\n const isExpandable = SchemaHelpers.isExpandable(schema) || dependentSchemas;\n\n isCircular = isCircular || schema.isCircular() || false;\n const uid = schema.$id();\n const styledSchemaName = isProperty ? 'italic' : '';\n const renderedSchemaName =\n typeof schemaName === 'string' ? (\n <span className={`break-anywhere text-sm ${styledSchemaName}`}>\n {schemaName}\n </span>\n ) : (\n schemaName\n );\n\n return (\n <SchemaContext.Provider\n value={{ reverse: !reverse, deepExpanded: deepExpand }}\n >\n <div>\n <div className=\"flex py-2\">\n <div className={`${onlyTitle ? '' : 'min-w-1/4'} mr-2`}>\n {isExpandable && !isCircular ? (\n <>\n <CollapseButton\n onClick={() => setExpanded(prev => !prev)}\n expanded={expanded}\n >\n {renderedSchemaName}\n </CollapseButton>\n <button\n type=\"button\"\n onClick={() => setDeepExpand(prev => !prev)}\n className=\"ml-1 text-sm text-gray-500\"\n >\n {deepExpand ? 'Collapse all' : 'Expand all'}\n </button>\n </>\n ) : (\n <span\n className={`break-anywhere text-sm ${\n isProperty ? 'italic' : ''\n }`}\n >\n {schemaName}\n </span>\n )}\n {isPatternProperty && (\n <div className=\"text-gray-500 text-xs italic\">\n (pattern property)\n </div>\n )}\n {required && <div className=\"text-red-600 text-xs\">required</div>}\n {dependentRequired && (\n <>\n <div className=\"text-gray-500 text-xs\">\n required when defined:\n </div>\n <div className=\"text-red-600 text-xs\">\n {dependentRequired.join(', ')}\n </div>\n </>\n )}\n {schema.deprecated() && (\n <div className=\"text-red-600 text-xs\">deprecated</div>\n )}\n {schema.writeOnly() && (\n <div className=\"text-gray-500 text-xs\">write-only</div>\n )}\n {schema.readOnly() && (\n <div className=\"text-gray-500 text-xs\">read-only</div>\n )}\n </div>\n {rawValue ? (\n <div>\n <div className=\"text-sm\">\n {SchemaHelpers.prettifyValue(schema.const(), false)}\n </div>\n </div>\n ) : (\n <div>\n <div>\n <div className=\"capitalize text-sm text-teal-500 font-bold inline-block mr-2\">\n {isCircular ? `${schemaType} [CIRCULAR]` : schemaType}\n </div>\n <div className=\"inline-block\">\n {schema.format() && (\n <span className=\"bg-yellow-600 font-bold no-underline text-white rounded lowercase mr-2 p-1 text-xs\">\n format: {schema.format()}\n </span>\n )}\n\n {/* related to string */}\n {schema.pattern() !== undefined && (\n <span className=\"bg-yellow-600 font-bold no-underline text-white rounded mr-2 p-1 text-xs\">\n must match: {schema.pattern()}\n </span>\n )}\n {schema.contentMediaType() !== undefined && (\n <span className=\"bg-yellow-600 font-bold no-underline text-white rounded lowercase mr-2 p-1 text-xs\">\n media type: {schema.contentMediaType()}\n </span>\n )}\n {schema.contentEncoding() !== undefined && (\n <span className=\"bg-yellow-600 font-bold no-underline text-white rounded lowercase mr-2 p-1 text-xs\">\n encoding: {schema.contentEncoding()}\n </span>\n )}\n\n {/* constraints */}\n {!!constraints.length &&\n constraints.map(c => (\n <span\n className=\"bg-purple-600 font-bold no-underline text-white rounded lowercase mr-2 p-1 text-xs\"\n key={c}\n >\n {c}\n </span>\n ))}\n\n {uid && !uid.startsWith('<anonymous-') && (\n <span className=\"border text-orange-600 rounded mr-2 p-1 text-xs\">\n uid: {uid}\n </span>\n )}\n </div>\n\n {schema.description() !== undefined && (\n <div>\n <Markdown>{schema.description()}</Markdown>\n </div>\n )}\n\n {schema.default() !== undefined && (\n <div className=\"text-xs\">\n Default value:\n <span className=\"border inline-block text-orange-600 rounded ml-1 py-0 px-2\">\n {SchemaHelpers.prettifyValue(schema.default())}\n </span>\n </div>\n )}\n {schema.const() !== undefined && (\n <div className=\"text-xs\">\n Const:\n <span className=\"border inline-block text-orange-600 rounded ml-1 py-0 px-2\">\n {SchemaHelpers.prettifyValue(schema.const())}\n </span>\n </div>\n )}\n {schema.enum() && (\n <ul className=\"text-xs\">\n Allowed values:{' '}\n {schema.enum()?.map((e, idx) => (\n <li\n key={idx}\n className=\"border inline-block text-orange-600 rounded ml-1 py-0 px-2\"\n >\n <span>{SchemaHelpers.prettifyValue(e)}</span>\n </li>\n ))}\n </ul>\n )}\n {parameterLocation && (\n <div className=\"text-xs\">\n Parameter location:{' '}\n <span className=\"border text-orange-600 rounded mr-2 p-1 text-xs\">\n {parameterLocation}\n </span>\n </div>\n )}\n {externalDocs && (\n <span className=\"border border-solid border-orange-300 hover:bg-orange-300 hover:text-orange-600 text-orange-500 font-bold no-underline text-xs uppercase rounded px-2 py-0\">\n <Href\n href={externalDocs.url()}\n title={externalDocs.description() || ''}\n >\n Documentation\n </Href>\n </span>\n )}\n {schema.examples() && (\n <ul className=\"text-xs\">\n Examples values:{' '}\n {schema.examples()?.map((e, idx) => (\n <li\n key={idx}\n className=\"border inline-block text-orange-600 rounded ml-1 py-0 px-2 break-all\"\n >\n <span>{SchemaHelpers.prettifyValue(e)}</span>\n </li>\n ))}\n </ul>\n )}\n </div>\n </div>\n )}\n </div>\n\n {isCircular || !isExpandable ? null : (\n <div\n className={`rounded p-4 py-2 border bg-gray-100 ${\n reverse ? 'bg-gray-200' : ''\n } ${expanded ? 'block' : 'hidden'}`}\n >\n <SchemaProperties schema={schema} />\n <SchemaItems schema={schema} />\n\n {schema.oneOf() &&\n schema\n .oneOf()\n ?.map((s, idx) => (\n <Schema\n key={idx}\n schema={s}\n schemaName={idx === 0 ? 'Adheres to:' : 'Or to:'}\n />\n ))}\n {schema.anyOf() &&\n schema\n .anyOf()\n ?.map((s, idx) => (\n <Schema\n key={idx}\n schema={s}\n schemaName={idx === 0 ? 'Can adhere to:' : 'Or to:'}\n />\n ))}\n {schema.allOf() &&\n schema\n .allOf()\n ?.map((s, idx) => (\n <Schema\n key={idx}\n schema={s}\n schemaName={idx === 0 ? 'Consists of:' : 'And with:'}\n />\n ))}\n {schema.not() && (\n <Schema schema={schema.not()} schemaName=\"Cannot adhere to:\" />\n )}\n\n {schema.propertyNames() && (\n <Schema\n schema={schema.propertyNames()}\n schemaName=\"Property names must adhere to:\"\n />\n )}\n {schema.contains() && (\n <Schema\n schema={schema.contains()}\n schemaName=\"Array must contain at least one of:\"\n />\n )}\n\n {schema.if() && (\n <Schema schema={schema.if()} schemaName=\"If schema adheres to:\" />\n )}\n {schema.then() && (\n <Schema\n schema={schema.then()}\n schemaName=\"Then must adhere to:\"\n />\n )}\n {schema.else() && (\n <Schema schema={schema.else()} schemaName=\"Otherwise:\" />\n )}\n\n {dependentSchemas && (\n <Schema\n schema={dependentSchemas}\n schemaName=\"Dependent schemas:\"\n />\n )}\n\n <Extensions item={schema} />\n\n <AdditionalProperties schema={schema} />\n <AdditionalItems schema={schema} />\n </div>\n )}\n </div>\n </SchemaContext.Provider>\n );\n};\n\ninterface SchemaPropertiesProps {\n schema: SchemaInterface;\n}\n\nconst SchemaProperties: React.FunctionComponent<SchemaPropertiesProps> = ({\n schema,\n}) => {\n const properties = schema.properties();\n if (properties === undefined || !Object.keys(properties)) {\n return null;\n }\n\n const required = schema.required() || [];\n const patternProperties = schema.patternProperties();\n\n return (\n <>\n {Object.entries(properties).map(([propertyName, property]) => (\n <Schema\n schema={property}\n schemaName={propertyName}\n required={required.includes(propertyName)}\n isProperty={true}\n isCircular={property.isCircular()}\n dependentRequired={SchemaHelpers.getDependentRequired(\n propertyName,\n schema,\n )}\n key={propertyName}\n />\n ))}\n {Object.entries(patternProperties || {}).map(\n ([propertyName, property]) => (\n <Schema\n schema={property}\n schemaName={propertyName}\n isPatternProperty={true}\n isProperty={true}\n isCircular={property.isCircular()}\n key={propertyName}\n />\n ),\n )}\n </>\n );\n};\n\ninterface AdditionalPropertiesProps {\n schema: SchemaInterface;\n}\n\nconst AdditionalProperties: React.FunctionComponent<AdditionalPropertiesProps> = ({\n schema,\n}) => {\n if (\n schema\n .extensions()\n .get(SchemaHelpers.extRenderAdditionalInfo)\n ?.value() === false\n ) {\n return null;\n }\n\n const type = schema.type();\n if (type === undefined || !type.includes('object')) {\n return null;\n }\n\n const additionalProperties = schema.additionalProperties();\n if (additionalProperties === true || additionalProperties === undefined) {\n return (\n <p className=\"mt-2 text-xs text-gray-700\">\n Additional properties are allowed.\n </p>\n );\n }\n if (additionalProperties === false) {\n return (\n <p className=\"mt-2 text-xs text-gray-700\">\n Additional properties are <strong>NOT</strong> allowed.\n </p>\n );\n }\n return (\n <Schema schemaName=\"Additional properties:\" schema={additionalProperties} />\n );\n};\n\ninterface SchemaItemsProps {\n schema: SchemaInterface;\n}\n\nconst SchemaItems: React.FunctionComponent<SchemaItemsProps> = ({ schema }) => {\n const type = schema.type();\n if (type === undefined || !type.includes('array')) {\n return null;\n }\n const items = schema.items();\n\n // object in items\n if (\n items &&\n !Array.isArray(items) &&\n Object.keys(items.properties() || {}).length\n ) {\n return <SchemaProperties schema={items} />;\n } else if (Array.isArray(items)) {\n return (\n <>\n {items.map((item, idx) => (\n <Schema schema={item} schemaName={`${idx + 1} item:`} key={idx} />\n ))}\n </>\n );\n }\n return <Schema schema={items} schemaName=\"Items:\" />;\n};\n\ninterface AdditionalItemsProps {\n schema: SchemaInterface;\n}\n\nconst AdditionalItems: React.FunctionComponent<AdditionalItemsProps> = ({\n schema,\n}) => {\n if (\n schema\n .extensions()\n .get(SchemaHelpers.extRenderAdditionalInfo)\n ?.value() === false\n ) {\n return null;\n }\n\n const type = schema.type();\n if (type === undefined || !type.includes('array')) {\n return null;\n }\n if (!Array.isArray(schema.items())) {\n return null;\n }\n\n const additionalItems = schema.additionalItems() as any;\n if (additionalItems === true || additionalItems === undefined) {\n return (\n <p className=\"mt-2 text-xs text-gray-700\">\n Additional items are allowed.\n </p>\n );\n }\n if (additionalItems === false) {\n return (\n <p className=\"mt-2 text-xs text-gray-700\">\n Additional items are <strong>NOT</strong> allowed.\n </p>\n );\n }\n return <Schema schemaName=\"Additional items:\" schema={additionalItems} />;\n};\n"]}
@@ -11,7 +11,7 @@ var Tags = function (_a) {
11
11
  if (!tags || !tags.length) {
12
12
  return null;
13
13
  }
14
- return (react_1.default.createElement("ul", { className: "flex flex-wrap leading-normal" }, tags.map(function (tag) { return (react_1.default.createElement("li", { className: "inline-block mt-2 mr-2", key: tag.name() },
14
+ return (react_1.default.createElement("ul", { className: "flex flex-wrap leading-normal" }, tags.all().map(function (tag) { return (react_1.default.createElement("li", { className: "inline-block mt-2 mr-2", key: tag.name() },
15
15
  react_1.default.createElement(Tag_1.Tag, { tag: tag }))); })));
16
16
  };
17
17
  exports.Tags = Tags;
@@ -1 +1 @@
1
- {"version":3,"file":"Tags.js","sourceRoot":"","sources":["../../../src/components/Tags.tsx"],"names":[],"mappings":";;;;;;AAAA,gDAA0B;AAG1B,6BAA4B;AAMrB,IAAM,IAAI,GAAmC,UAAC,EAAQ;QAAN,IAAI,UAAA;IACzD,IAAI,CAAC,IAAI,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE;QACzB,OAAO,IAAI,CAAC;KACb;IAED,OAAO,CACL,sCAAI,SAAS,EAAC,+BAA+B,IAC1C,IAAI,CAAC,GAAG,CAAC,UAAA,GAAG,IAAI,OAAA,CACf,sCAAI,SAAS,EAAC,wBAAwB,EAAC,GAAG,EAAE,GAAG,CAAC,IAAI,EAAE;QACpD,8BAAC,SAAG,IAAC,GAAG,EAAE,GAAG,GAAI,CACd,CACN,EAJgB,CAIhB,CAAC,CACC,CACN,CAAC;AACJ,CAAC,CAAC;AAdW,QAAA,IAAI,QAcf","sourcesContent":["import React from 'react';\nimport { TagInterface } from '@asyncapi/parser';\n\nimport { Tag } from './Tag';\n\ninterface Props {\n tags?: TagInterface[];\n}\n\nexport const Tags: React.FunctionComponent<Props> = ({ tags }) => {\n if (!tags || !tags.length) {\n return null;\n }\n\n return (\n <ul className=\"flex flex-wrap leading-normal\">\n {tags.map(tag => (\n <li className=\"inline-block mt-2 mr-2\" key={tag.name()}>\n <Tag tag={tag} />\n </li>\n ))}\n </ul>\n );\n};\n"]}
1
+ {"version":3,"file":"Tags.js","sourceRoot":"","sources":["../../../src/components/Tags.tsx"],"names":[],"mappings":";;;;;;AAAA,gDAA0B;AAG1B,6BAA4B;AAMrB,IAAM,IAAI,GAAmC,UAAC,EAAQ;QAAN,IAAI,UAAA;IACzD,IAAI,CAAC,IAAI,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE;QACzB,OAAO,IAAI,CAAC;KACb;IAED,OAAO,CACL,sCAAI,SAAS,EAAC,+BAA+B,IAC1C,IAAI,CAAC,GAAG,EAAE,CAAC,GAAG,CAAC,UAAA,GAAG,IAAI,OAAA,CACrB,sCAAI,SAAS,EAAC,wBAAwB,EAAC,GAAG,EAAE,GAAG,CAAC,IAAI,EAAE;QACpD,8BAAC,SAAG,IAAC,GAAG,EAAE,GAAG,GAAI,CACd,CACN,EAJsB,CAItB,CAAC,CACC,CACN,CAAC;AACJ,CAAC,CAAC;AAdW,QAAA,IAAI,QAcf","sourcesContent":["import React from 'react';\nimport { TagsInterface } from '@asyncapi/parser';\n\nimport { Tag } from './Tag';\n\ninterface Props {\n tags?: TagsInterface;\n}\n\nexport const Tags: React.FunctionComponent<Props> = ({ tags }) => {\n if (!tags || !tags.length) {\n return null;\n }\n\n return (\n <ul className=\"flex flex-wrap leading-normal\">\n {tags.all().map(tag => (\n <li className=\"inline-block mt-2 mr-2\" key={tag.name()}>\n <Tag tag={tag} />\n </li>\n ))}\n </ul>\n );\n};\n"]}
@@ -52,7 +52,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
52
52
  function verb(n) { return function (v) { return step([n, v]); }; }
53
53
  function step(op) {
54
54
  if (f) throw new TypeError("Generator is already executing.");
55
- while (_) try {
55
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
56
56
  if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
57
57
  if (y = 0, t) op = [op[0] & 2, t.value];
58
58
  switch (op[0]) {
@@ -95,11 +95,16 @@ var AsyncApiComponent = (function (_super) {
95
95
  return __awaiter(this, void 0, void 0, function () {
96
96
  var _a, schema, config;
97
97
  return __generator(this, function (_b) {
98
- if (this.props.schema) {
99
- _a = this.props, schema = _a.schema, config = _a.config;
100
- this.parseSchema(schema, config && config.parserOptions);
98
+ switch (_b.label) {
99
+ case 0:
100
+ if (!this.props.schema) return [3, 2];
101
+ _a = this.props, schema = _a.schema, config = _a.config;
102
+ return [4, this.parseSchema(schema, config === null || config === void 0 ? void 0 : config.parserOptions)];
103
+ case 1:
104
+ _b.sent();
105
+ _b.label = 2;
106
+ case 2: return [2];
101
107
  }
102
- return [2];
103
108
  });
104
109
  });
105
110
  };
@@ -107,13 +112,18 @@ var AsyncApiComponent = (function (_super) {
107
112
  return __awaiter(this, void 0, void 0, function () {
108
113
  var oldSchema, newSchema, config;
109
114
  return __generator(this, function (_a) {
110
- oldSchema = prevProps.schema;
111
- newSchema = this.props.schema;
112
- if (oldSchema !== newSchema) {
113
- config = this.props.config;
114
- this.parseSchema(newSchema, config && config.parserOptions);
115
+ switch (_a.label) {
116
+ case 0:
117
+ oldSchema = prevProps.schema;
118
+ newSchema = this.props.schema;
119
+ if (!(oldSchema !== newSchema)) return [3, 2];
120
+ config = this.props.config;
121
+ return [4, this.parseSchema(newSchema, config === null || config === void 0 ? void 0 : config.parserOptions)];
122
+ case 1:
123
+ _a.sent();
124
+ _a.label = 2;
125
+ case 2: return [2];
115
126
  }
116
- return [2];
117
127
  });
118
128
  });
119
129
  };
@@ -1 +1 @@
1
- {"version":3,"file":"AsyncApi.js","sourceRoot":"","sources":["../../../../src/containers/AsyncApi/AsyncApi.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,6CAAyC;AAGzC,4DAA8C;AAE9C,qCAIqB;AAErB,yCAA6D;AAY7D;IAAgC,qCAAuC;IAMrE,2BAAY,KAAoB;QAAhC,YACE,kBAAM,KAAK,CAAC,SACb;QAPD,WAAK,GAAkB;YACrB,QAAQ,EAAE,SAAS;YACnB,KAAK,EAAE,SAAS;SACjB,CAAC;;IAIF,CAAC;IAEK,6CAAiB,GAAvB;;;;gBACE,IAAI,IAAI,CAAC,KAAK,CAAC,MAAM,EAAE;oBACf,KAAqB,IAAI,CAAC,KAAK,EAA7B,MAAM,YAAA,EAAE,MAAM,YAAA,CAAgB;oBACtC,IAAI,CAAC,WAAW,CAAC,MAAM,EAAE,MAAM,IAAI,MAAM,CAAC,aAAa,CAAC,CAAC;iBAC1D;;;;KACF;IAEK,8CAAkB,GAAxB,UAAyB,SAAwB;;;;gBACzC,SAAS,GAAG,SAAS,CAAC,MAAM,CAAC;gBAC7B,SAAS,GAAG,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC;gBAEpC,IAAI,SAAS,KAAK,SAAS,EAAE;oBACnB,MAAM,GAAK,IAAI,CAAC,KAAK,OAAf,CAAgB;oBAC9B,IAAI,CAAC,WAAW,CAAC,SAAS,EAAE,MAAM,IAAI,MAAM,CAAC,aAAa,CAAC,CAAC;iBAC7D;;;;KACF;IAED,kCAAM,GAAN;QACQ,IAAA,KAAqB,IAAI,CAAC,KAAK,EAA7B,MAAM,YAAA,EAAE,MAAM,YAAe,CAAC;QAChC,IAAA,KAAsB,IAAI,CAAC,KAAK,EAA9B,QAAQ,cAAA,EAAE,KAAK,WAAe,CAAC;QAEvC,OAAO,CACL,8BAAC,oBAAkB,IACjB,MAAM,EAAE,QAAQ,IAAI,MAAM,EAC1B,MAAM,EAAE,MAAM,EACd,KAAK,EAAE,KAAK,GACZ,CACH,CAAC;IACJ,CAAC;IAEa,uCAAW,GAAzB,UAA0B,MAAmB,EAAE,aAAmB;;;;;;wBAC1D,UAAU,GAAG,8BAAoB,CAAC,kBAAkB,CAAC,MAAM,CAAC,CAAC;wBACnE,IAAI,UAAU,EAAE;4BACd,IAAI,CAAC,QAAQ,CAAC;gCACZ,QAAQ,EAAE,UAAU;6BACrB,CAAC,CAAC;4BACH,WAAO;yBACR;6BAEG,IAAA,iCAAyB,EAAC,MAAM,CAAC,EAAjC,cAAiC;wBACb,WAAM,gBAAM,CAAC,YAAY,CAAC,MAAM,EAAE,aAAa,CAAC,EAAA;;wBAAhE,aAAa,GAAG,SAAgD;wBACtE,IAAI,CAAC,QAAQ,CAAC;4BACZ,QAAQ,EAAE,aAAa,CAAC,QAAQ;4BAChC,KAAK,EAAE,aAAa,CAAC,KAAK;yBAC3B,CAAC,CAAC;wBACH,WAAO;4BAGM,WAAM,gBAAM,CAAC,KAAK,CAAC,MAAM,EAAE,aAAa,CAAC,EAAA;;wBAAlD,MAAM,GAAG,SAAyC;wBACxD,IAAI,CAAC,QAAQ,CAAC;4BACZ,QAAQ,EAAE,MAAM,CAAC,QAAQ;4BACzB,KAAK,EAAE,MAAM,CAAC,KAAK;yBACpB,CAAC,CAAC;;;;;KACJ;IACH,wBAAC;AAAD,CAAC,AAhED,CAAgC,iBAAS,GAgExC;AAED,kBAAe,iBAAiB,CAAC","sourcesContent":["import React, { Component } from 'react';\nimport { AsyncAPIDocumentInterface } from '@asyncapi/parser';\n\nimport AsyncApiStandalone from './Standalone';\n\nimport {\n isFetchingSchemaInterface,\n ErrorObject,\n PropsSchema,\n} from '../../types';\nimport { ConfigInterface } from '../../config';\nimport { SpecificationHelpers, Parser } from '../../helpers';\n\nexport interface AsyncApiProps {\n schema: PropsSchema;\n config?: Partial<ConfigInterface>;\n}\n\ninterface AsyncAPIState {\n asyncapi?: AsyncAPIDocumentInterface;\n error?: ErrorObject;\n}\n\nclass AsyncApiComponent extends Component<AsyncApiProps, AsyncAPIState> {\n state: AsyncAPIState = {\n asyncapi: undefined,\n error: undefined,\n };\n\n constructor(props: AsyncApiProps) {\n super(props);\n }\n\n async componentDidMount() {\n if (this.props.schema) {\n const { schema, config } = this.props;\n this.parseSchema(schema, config && config.parserOptions);\n }\n }\n\n async componentDidUpdate(prevProps: AsyncApiProps) {\n const oldSchema = prevProps.schema;\n const newSchema = this.props.schema;\n\n if (oldSchema !== newSchema) {\n const { config } = this.props;\n this.parseSchema(newSchema, config && config.parserOptions);\n }\n }\n\n render() {\n const { schema, config } = this.props;\n const { asyncapi, error } = this.state;\n\n return (\n <AsyncApiStandalone\n schema={asyncapi || schema}\n config={config}\n error={error}\n />\n );\n }\n\n private async parseSchema(schema: PropsSchema, parserOptions?: any) {\n const parsedSpec = SpecificationHelpers.retrieveParsedSpec(schema);\n if (parsedSpec) {\n this.setState({\n asyncapi: parsedSpec,\n });\n return;\n }\n\n if (isFetchingSchemaInterface(schema)) {\n const parsedFromUrl = await Parser.parseFromUrl(schema, parserOptions);\n this.setState({\n asyncapi: parsedFromUrl.asyncapi,\n error: parsedFromUrl.error,\n });\n return;\n }\n\n const parsed = await Parser.parse(schema, parserOptions);\n this.setState({\n asyncapi: parsed.asyncapi,\n error: parsed.error,\n });\n }\n}\n\nexport default AsyncApiComponent;\n"]}
1
+ {"version":3,"file":"AsyncApi.js","sourceRoot":"","sources":["../../../../src/containers/AsyncApi/AsyncApi.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,6CAAyC;AAGzC,4DAA8C;AAE9C,qCAIqB;AAEr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AE,aAAmB;;;;;;wBAC1D,UAAU,GAAG,8BAAoB,CAAC,kBAAkB,CAAC,MAAM,CAAC,CAAC;wBACnE,IAAI,UAAU,EAAE;4BACd,IAAI,CAAC,QAAQ,CAAC;gCACZ,QAAQ,EAAE,UAAU;6BACrB,CAAC,CAAC;4BACH,WAAO;yBACR;6BAEG,IAAA,iCAAyB,EAAC,MAAM,CAAC,EAAjC,cAAiC;wBACb,WAAM,gBAAM,CAAC,YAAY,CAAC,MAAM,EAAE,aAAa,CAAC,EAAA;;wBAAhE,aAAa,GAAG,SAAgD;wBACtE,IAAI,CAAC,QAAQ,CAAC;4BACZ,QAAQ,EAAE,aAAa,CAAC,QAAQ;4BAChC,KAAK,EAAE,aAAa,CAAC,KAAK;yBAC3B,CAAC,CAAC;wBACH,WAAO;4BAGM,WAAM,gBAAM,CAAC,KAAK,CAAC,MAAM,EAAE,aAAa,CAAC,EAAA;;wBAAlD,MAAM,GAAG,SAAyC;wBACxD,IAAI,CAAC,QAAQ,CAAC;4BACZ,QAAQ,EAAE,MAAM,CAAC,QAAQ;4BACzB,KAAK,EAAE,MAAM,CAAC,KAAK;yBACpB,CAAC,CAAC;;;;;KACJ;IACH,wBAAC;AAAD,CAAC,AAhED,CAAgC,iBAAS,GAgExC;AAED,kBAAe,iBAAiB,CAAC","sourcesContent":["import React, { Component } from 'react';\nimport { AsyncAPIDocumentInterface } from '@asyncapi/parser';\n\nimport AsyncApiStandalone from './Standalone';\n\nimport {\n isFetchingSchemaInterface,\n ErrorObject,\n PropsSchema,\n} from '../../types';\nimport { ConfigInterface } from '../../config';\nimport { SpecificationHelpers, Parser } from '../../helpers';\n\nexport interface AsyncApiProps {\n schema: PropsSchema;\n config?: Partial<ConfigInterface>;\n}\n\ninterface AsyncAPIState {\n asyncapi?: AsyncAPIDocumentInterface;\n error?: ErrorObject;\n}\n\nclass AsyncApiComponent extends Component<AsyncApiProps, AsyncAPIState> {\n state: AsyncAPIState = {\n asyncapi: undefined,\n error: undefined,\n };\n\n constructor(props: AsyncApiProps) {\n super(props);\n }\n\n async componentDidMount() {\n if (this.props.schema) {\n const { schema, config } = this.props;\n await this.parseSchema(schema, config?.parserOptions);\n }\n }\n\n async componentDidUpdate(prevProps: AsyncApiProps) {\n const oldSchema = prevProps.schema;\n const newSchema = this.props.schema;\n\n if (oldSchema !== newSchema) {\n const { config } = this.props;\n await this.parseSchema(newSchema, config?.parserOptions);\n }\n }\n\n render() {\n const { schema, config } = this.props;\n const { asyncapi, error } = this.state;\n\n return (\n <AsyncApiStandalone\n schema={asyncapi || schema}\n config={config}\n error={error}\n />\n );\n }\n\n private async parseSchema(schema: PropsSchema, parserOptions?: any) {\n const parsedSpec = SpecificationHelpers.retrieveParsedSpec(schema);\n if (parsedSpec) {\n this.setState({\n asyncapi: parsedSpec,\n });\n return;\n }\n\n if (isFetchingSchemaInterface(schema)) {\n const parsedFromUrl = await Parser.parseFromUrl(schema, parserOptions);\n this.setState({\n asyncapi: parsedFromUrl.asyncapi,\n error: parsedFromUrl.error,\n });\n return;\n }\n\n const parsed = await Parser.parse(schema, parserOptions);\n this.setState({\n asyncapi: parsed.asyncapi,\n error: parsed.error,\n });\n }\n}\n\nexport default AsyncApiComponent;\n"]}
@@ -63,7 +63,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
63
63
  function verb(n) { return function (v) { return step([n, v]); }; }
64
64
  function step(op) {
65
65
  if (f) throw new TypeError("Generator is already executing.");
66
- while (_) try {
66
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
67
67
  if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
68
68
  if (y = 0, t) op = [op[0] & 2, t.value];
69
69
  switch (op[0]) {
@@ -12,17 +12,18 @@ var constants_1 = require("../../constants");
12
12
  var Messages = function () {
13
13
  var asyncapi = (0, contexts_1.useSpec)();
14
14
  var config = (0, contexts_1.useConfig)();
15
- var messages = !asyncapi.components().isEmpty() && asyncapi.components().messages();
16
- if (!messages || Object.keys(messages).length === 0) {
15
+ var messages = !asyncapi.components().isEmpty() &&
16
+ asyncapi
17
+ .components()
18
+ .messages()
19
+ .all();
20
+ if (!messages || messages.length === 0) {
17
21
  return null;
18
22
  }
19
23
  return (react_1.default.createElement("section", { id: "".concat(helpers_1.CommonHelpers.getIdentifier('messages', config)), className: "mt-16" },
20
24
  react_1.default.createElement("h2", { className: "2xl:w-7/12 text-3xl font-light mb-4 px-8" }, constants_1.MESSAGES_TEXT),
21
- react_1.default.createElement("ul", null, Object.entries(messages).map(function (_a, idx) {
22
- var messageName = _a[0], message = _a[1];
23
- return (react_1.default.createElement("li", { className: "mb-4", key: messageName, id: helpers_1.CommonHelpers.getIdentifier("message-".concat(messageName), config) },
24
- react_1.default.createElement(Message_1.Message, { messageName: messageName, message: message, index: idx + 1, key: messageName })));
25
- }))));
25
+ react_1.default.createElement("ul", null, messages.map(function (message, idx) { return (react_1.default.createElement("li", { className: "mb-4", key: message.id(), id: helpers_1.CommonHelpers.getIdentifier("message-".concat(message.id()), config) },
26
+ react_1.default.createElement(Message_1.Message, { messageName: message.id(), message: message, index: idx + 1, key: message.id() }))); }))));
26
27
  };
27
28
  exports.Messages = Messages;
28
29
  //# sourceMappingURL=Messages.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Messages.js","sourceRoot":"","sources":["../../../../src/containers/Messages/Messages.tsx"],"names":[],"mappings":";;;;;;AAAA,gDAA0B;AAE1B,qCAAoC;AAEpC,2CAAoD;AACpD,yCAA8C;AAC9C,6CAAgD;AAEzC,IAAM,QAAQ,GAA4B;IAC/C,IAAM,QAAQ,GAAG,IAAA,kBAAO,GAAE,CAAC;IAC3B,IAAM,MAAM,GAAG,IAAA,oBAAS,GAAE,CAAC;IAC3B,IAAM,QAAQ,GACZ,CAAC,QAAQ,CAAC,UAAU,EAAE,CAAC,OAAO,EAAE,IAAI,QAAQ,CAAC,UAAU,EAAE,CAAC,QAAQ,EAAE,CAAC;IAEvE,IAAI,CAAC,QAAQ,IAAI,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,MAAM,KAAK,CAAC,EAAE;QACnD,OAAO,IAAI,CAAC;KACb;IAED,OAAO,CACL,2CACE,EAAE,EAAE,UAAG,uBAAa,CAAC,aAAa,CAAC,UAAU,EAAE,MAAM,CAAC,CAAE,EACxD,SAAS,EAAC,OAAO;QAEjB,sCAAI,SAAS,EAAC,0CAA0C,IACrD,yBAAa,CACX;QACL,0CACG,MAAM,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,GAAG,CAAC,UAAC,EAAsB,EAAE,GAAG;gBAA1B,WAAW,QAAA,EAAE,OAAO,QAAA;YAAW,OAAA,CAC7D,sCACE,SAAS,EAAC,MAAM,EAChB,GAAG,EAAE,WAAW,EAChB,EAAE,EAAE,uBAAa,CAAC,aAAa,CAAC,kBAAW,WAAW,CAAE,EAAE,MAAM,CAAC;gBAEjE,8BAAC,iBAAO,IACN,WAAW,EAAE,WAAW,EACxB,OAAO,EAAE,OAAO,EAChB,KAAK,EAAE,GAAG,GAAG,CAAC,EACd,GAAG,EAAE,WAAW,GAChB,CACC,CACN;QAb8D,CAa9D,CAAC,CACC,CACG,CACX,CAAC;AACJ,CAAC,CAAC;AApCW,QAAA,QAAQ,YAoCnB","sourcesContent":["import React from 'react';\n\nimport { Message } from './Message';\n\nimport { useConfig, useSpec } from '../../contexts';\nimport { CommonHelpers } from '../../helpers';\nimport { MESSAGES_TEXT } from '../../constants';\n\nexport const Messages: React.FunctionComponent = () => {\n const asyncapi = useSpec();\n const config = useConfig();\n const messages =\n !asyncapi.components().isEmpty() && asyncapi.components().messages();\n\n if (!messages || Object.keys(messages).length === 0) {\n return null;\n }\n\n return (\n <section\n id={`${CommonHelpers.getIdentifier('messages', config)}`}\n className=\"mt-16\"\n >\n <h2 className=\"2xl:w-7/12 text-3xl font-light mb-4 px-8\">\n {MESSAGES_TEXT}\n </h2>\n <ul>\n {Object.entries(messages).map(([messageName, message], idx) => (\n <li\n className=\"mb-4\"\n key={messageName}\n id={CommonHelpers.getIdentifier(`message-${messageName}`, config)}\n >\n <Message\n messageName={messageName}\n message={message}\n index={idx + 1}\n key={messageName}\n />\n </li>\n ))}\n </ul>\n </section>\n );\n};\n"]}
1
+ {"version":3,"file":"Messages.js","sourceRoot":"","sources":["../../../../src/containers/Messages/Messages.tsx"],"names":[],"mappings":";;;;;;AAAA,gDAA0B;AAE1B,qCAAoC;AAEpC,2CAAoD;AACpD,yCAA8C;AAC9C,6CAAgD;AAEzC,IAAM,QAAQ,GAA4B;IAC/C,IAAM,QAAQ,GAAG,IAAA,kBAAO,GAAE,CAAC;IAC3B,IAAM,MAAM,GAAG,IAAA,oBAAS,GAAE,CAAC;IAC3B,IAAM,QAAQ,GACZ,CAAC,QAAQ,CAAC,UAAU,EAAE,CAAC,OAAO,EAAE;QAChC,QAAQ;aACL,UAAU,EAAE;aACZ,QAAQ,EAAE;aACV,GAAG,EAAE,CAAC;IAEX,IAAI,CAAC,QAAQ,IAAI,QAAQ,CAAC,MAAM,KAAK,CAAC,EAAE;QACtC,OAAO,IAAI,CAAC;KACb;IAED,OAAO,CACL,2CACE,EAAE,EAAE,UAAG,uBAAa,CAAC,aAAa,CAAC,UAAU,EAAE,MAAM,CAAC,CAAE,EACxD,SAAS,EAAC,OAAO;QAEjB,sCAAI,SAAS,EAAC,0CAA0C,IACrD,yBAAa,CACX;QACL,0CACG,QAAQ,CAAC,GAAG,CAAC,UAAC,OAAO,EAAE,GAAG,IAAK,OAAA,CAC9B,sCACE,SAAS,EAAC,MAAM,EAChB,GAAG,EAAE,OAAO,CAAC,EAAE,EAAE,EACjB,EAAE,EAAE,uBAAa,CAAC,aAAa,CAAC,kBAAW,OAAO,CAAC,EAAE,EAAE,CAAE,EAAE,MAAM,CAAC;YAElE,8BAAC,iBAAO,IACN,WAAW,EAAE,OAAO,CAAC,EAAE,EAAE,EACzB,OAAO,EAAE,OAAO,EAChB,KAAK,EAAE,GAAG,GAAG,CAAC,EACd,GAAG,EAAE,OAAO,CAAC,EAAE,EAAE,GACjB,CACC,CACN,EAb+B,CAa/B,CAAC,CACC,CACG,CACX,CAAC;AACJ,CAAC,CAAC;AAxCW,QAAA,QAAQ,YAwCnB","sourcesContent":["import React from 'react';\n\nimport { Message } from './Message';\n\nimport { useConfig, useSpec } from '../../contexts';\nimport { CommonHelpers } from '../../helpers';\nimport { MESSAGES_TEXT } from '../../constants';\n\nexport const Messages: React.FunctionComponent = () => {\n const asyncapi = useSpec();\n const config = useConfig();\n const messages =\n !asyncapi.components().isEmpty() &&\n asyncapi\n .components()\n .messages()\n .all();\n\n if (!messages || messages.length === 0) {\n return null;\n }\n\n return (\n <section\n id={`${CommonHelpers.getIdentifier('messages', config)}`}\n className=\"mt-16\"\n >\n <h2 className=\"2xl:w-7/12 text-3xl font-light mb-4 px-8\">\n {MESSAGES_TEXT}\n </h2>\n <ul>\n {messages.map((message, idx) => (\n <li\n className=\"mb-4\"\n key={message.id()}\n id={CommonHelpers.getIdentifier(`message-${message.id()}`, config)}\n >\n <Message\n messageName={message.id()}\n message={message}\n index={idx + 1}\n key={message.id()}\n />\n </li>\n ))}\n </ul>\n </section>\n );\n};\n"]}
@@ -29,7 +29,7 @@ var Operation = function (props) {
29
29
  if (!operation || !channel) {
30
30
  return null;
31
31
  }
32
- var servers = typeof channel.servers === 'function' && channel.servers();
32
+ var servers = typeof channel.servers === 'function' && channel.servers().all();
33
33
  var security = typeof operation.security === 'function' && operation.security();
34
34
  var parameters = channel.parameters() !== undefined
35
35
  ? helpers_1.SchemaHelpers.parametersToSchema(channel.parameters())
@@ -40,8 +40,8 @@ var Operation = function (props) {
40
40
  servers && servers.length > 0 ? (react_1.default.createElement("div", { className: "mt-2 text-sm" },
41
41
  react_1.default.createElement("p", null, "Available only on servers:"),
42
42
  react_1.default.createElement("ul", { className: "flex flex-wrap leading-normal" }, servers.map(function (server) { return (react_1.default.createElement("li", { className: "inline-block mt-2 mr-2", key: server.id() },
43
- react_1.default.createElement("a", { href: "#".concat(helpers_1.CommonHelpers.getIdentifier('server-' + server, config)), className: "border border-solid border-blue-300 hover:bg-blue-300 hover:text-blue-600 text-blue-500 font-bold no-underline text-xs rounded px-3 py-1 cursor-pointer" },
44
- react_1.default.createElement("span", { className: "underline" }, server)))); })))) : null,
43
+ react_1.default.createElement("a", { href: "#".concat(helpers_1.CommonHelpers.getIdentifier('server-' + server.id(), config)), className: "border border-solid border-blue-300 hover:bg-blue-300 hover:text-blue-600 text-blue-500 font-bold no-underline text-xs rounded px-3 py-1 cursor-pointer" },
44
+ react_1.default.createElement("span", { className: "underline" }, server.id())))); })))) : null,
45
45
  parameters && (react_1.default.createElement("div", { className: "mt-2", id: helpers_1.CommonHelpers.getIdentifier("operation-".concat(type, "-").concat(channelName, "-parameters"), config) },
46
46
  react_1.default.createElement(components_1.Schema, { schemaName: "Parameters", schema: parameters, expanded: true }))),
47
47
  security && (react_1.default.createElement("div", { className: "mt-2", id: helpers_1.CommonHelpers.getIdentifier("operation-".concat(type, "-").concat(channelName, "-security"), config) },
@@ -59,27 +59,41 @@ var Operation = function (props) {
59
59
  "Accepts ",
60
60
  react_1.default.createElement("strong", null, "one of"),
61
61
  " the following messages:"),
62
- react_1.default.createElement("ul", null, operation.messages().map(function (msg, idx) { return (react_1.default.createElement("li", { className: "mt-4", key: idx },
62
+ react_1.default.createElement("ul", null, operation
63
+ .messages()
64
+ .all()
65
+ .map(function (msg, idx) { return (react_1.default.createElement("li", { className: "mt-4", key: idx },
63
66
  react_1.default.createElement(Message_1.Message, { message: msg, index: idx, showExamples: true }))); })))) : (react_1.default.createElement("div", { className: "mt-2" },
64
67
  react_1.default.createElement("p", { className: "px-8" }, "Accepts the following message:"),
65
68
  react_1.default.createElement("div", { className: "mt-2" },
66
- react_1.default.createElement(Message_1.Message, { message: operation.messages()[0], showExamples: true })))))));
69
+ react_1.default.createElement(Message_1.Message, { message: operation.messages().all()[0], showExamples: true })))))));
67
70
  };
68
71
  exports.Operation = Operation;
69
- var OperationInfo = function (_a) {
70
- var _b = _a.type, type = _b === void 0 ? types_1.PayloadType.PUBLISH : _b, operation = _a.operation, channelName = _a.channelName, channel = _a.channel;
72
+ function getTypeInformation(_a) {
73
+ var _b, _c;
74
+ var _d = _a.type, type = _d === void 0 ? types_1.PayloadType.PUBLISH : _d, config = _a.config;
75
+ if (type === types_1.PayloadType.SUBSCRIBE) {
76
+ return {
77
+ borderColor: 'border-green-600 text-green-600',
78
+ typeLabel: (_b = config.subscribeLabel) !== null && _b !== void 0 ? _b : constants_1.SUBSCRIBE_LABEL_DEFAULT_TEXT,
79
+ };
80
+ }
81
+ return {
82
+ borderColor: 'border-blue-600 text-blue-500',
83
+ typeLabel: (_c = config.publishLabel) !== null && _c !== void 0 ? _c : constants_1.PUBLISH_LABEL_DEFAULT_TEXT,
84
+ };
85
+ }
86
+ var OperationInfo = function (props) {
87
+ var _a = props.type, type = _a === void 0 ? types_1.PayloadType.PUBLISH : _a, operation = props.operation, channelName = props.channelName, channel = props.channel;
71
88
  var config = (0, contexts_1.useConfig)();
72
89
  var operationSummary = operation.summary();
73
90
  var externalDocs = operation.externalDocs();
74
91
  var operationId = operation.id();
92
+ var _b = getTypeInformation({ type: type, config: config }), borderColor = _b.borderColor, typeLabel = _b.typeLabel;
75
93
  return (react_1.default.createElement(react_1.default.Fragment, null,
76
94
  react_1.default.createElement("div", { className: "mb-4" },
77
95
  react_1.default.createElement("h3", null,
78
- react_1.default.createElement("span", { className: "font-mono border uppercase p-1 rounded mr-2 ".concat(type === types_1.PayloadType.PUBLISH
79
- ? 'border-blue-600 text-blue-500'
80
- : 'border-green-600 text-green-600'), title: type }, type === types_1.PayloadType.PUBLISH
81
- ? config.publishLabel || constants_1.PUBLISH_LABEL_DEFAULT_TEXT
82
- : config.subscribeLabel || constants_1.SUBSCRIBE_LABEL_DEFAULT_TEXT),
96
+ react_1.default.createElement("span", { className: "font-mono border uppercase p-1 rounded mr-2 ".concat(borderColor), title: type }, typeLabel),
83
97
  ' ',
84
98
  react_1.default.createElement("span", { className: "font-mono text-base" }, channelName))),
85
99
  channel.hasDescription() && (react_1.default.createElement("div", { className: "mt-2" },
@@ -1 +1 @@
1
- {"version":3,"file":"Operation.js","sourceRoot":"","sources":["../../../../src/containers/Operations/Operation.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,gDAA0B;AAG1B,+CAA8C;AAC9C,gDAA+C;AAC/C,+CAO0B;AAE1B,2CAA2C;AAC3C,yCAA6D;AAC7D,6CAIyB;AACzB,qCAA0C;AASnC,IAAM,SAAS,GAAmC,UAAA,KAAK;IAC5D,IAAM,MAAM,GAAG,IAAA,oBAAS,GAAE,CAAC;IACnB,IAAA,KAAgE,KAAK,KAA3C,EAA1B,IAAI,mBAAG,mBAAW,CAAC,OAAO,KAAA,EAAE,SAAS,GAA2B,KAAK,UAAhC,EAAE,WAAW,GAAc,KAAK,YAAnB,EAAE,OAAO,GAAK,KAAK,QAAV,CAAW;IAE9E,IAAI,CAAC,SAAS,IAAI,CAAC,OAAO,EAAE;QAC1B,OAAO,IAAI,CAAC;KACb;IAGD,IAAM,OAAO,GAAG,OAAO,OAAO,CAAC,OAAO,KAAK,UAAU,IAAI,OAAO,CAAC,OAAO,EAAE,CAAC;IAE3E,IAAM,QAAQ,GACZ,OAAO,SAAS,CAAC,QAAQ,KAAK,UAAU,IAAI,SAAS,CAAC,QAAQ,EAAE,CAAC;IACnE,IAAM,UAAU,GACd,OAAO,CAAC,UAAU,EAAE,KAAK,SAAS;QAChC,CAAC,CAAC,uBAAa,CAAC,kBAAkB,CAAC,OAAO,CAAC,UAAU,EAAE,CAAC;QACxD,CAAC,CAAC,SAAS,CAAC;IAEhB,OAAO,CACL;QACE,uCAAK,SAAS,EAAC,yBAAyB;YACtC,8BAAC,qBAAa,eAAK,KAAK,EAAI;YAE3B,OAAO,IAAI,OAAO,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,CAC/B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,IACzD,YAAY,IAAI,CACf,sCAAI,SAAS,EAAC,cAAc;YAC1B,8BAAC,iBAAI,IACH,SAAS,EAAC,4JAA4J,EACtK,IAAI,EAAE,YAAY,CAAC,GAAG,EAAE;gBAExB,4CAAO,sCAA0B,CAAQ,CACpC,CACJ,CACN,CACE,CACN;QAEA,WAAW,IAAI,CACd,uCAAK,SAAS,EAAC,2CAA2C;YACxD,uCAAK,SAAS,EAAC,uBAAuB;;gBAEpC,wCAAM,SAAS,EAAC,uDAAuD,IACpE,WAAW,CACP,CACH,CACF,CACP,CACA,CACJ,CAAC;AACJ,CAAC,CAAC;AAxEW,QAAA,aAAa,iBAwExB","sourcesContent":["import React from 'react';\nimport { ChannelInterface, OperationInterface } from '@asyncapi/parser';\n\nimport { Message } from '../Messages/Message';\nimport { Security } from '../Servers/Security';\nimport {\n Href,\n Markdown,\n Schema,\n Bindings,\n Tags,\n Extensions,\n} from '../../components';\n\nimport { useConfig } from '../../contexts';\nimport { CommonHelpers, SchemaHelpers } from '../../helpers';\nimport {\n EXTERAL_DOCUMENTATION_TEXT,\n PUBLISH_LABEL_DEFAULT_TEXT,\n SUBSCRIBE_LABEL_DEFAULT_TEXT,\n} from '../../constants';\nimport { PayloadType } from '../../types';\n\ninterface Props {\n type: PayloadType;\n operation: OperationInterface;\n channelName: string;\n channel: ChannelInterface;\n}\n\nexport const Operation: React.FunctionComponent<Props> = props => {\n const config = useConfig();\n const { type = PayloadType.PUBLISH, operation, channelName, channel } = props;\n\n if (!operation || !channel) {\n return null;\n }\n\n // check typeof as fallback for older version than `2.2.0`\n const servers = typeof channel.servers === 'function' && channel.servers();\n // check typeof as fallback for older version than `2.4.0`\n const security =\n typeof operation.security === 'function' && operation.security();\n const parameters =\n channel.parameters() !== undefined\n ? SchemaHelpers.parametersToSchema(channel.parameters())\n : undefined;\n\n return (\n <div>\n <div className=\"panel-item--center px-8\">\n <OperationInfo {...props} />\n\n {servers && servers.length > 0 ? (\n <div className=\"mt-2 text-sm\">\n <p>Available only on servers:</p>\n <ul className=\"flex flex-wrap leading-normal\">\n {servers.map(server => (\n <li className=\"inline-block mt-2 mr-2\" key={server.id()}>\n <a\n href={`#${CommonHelpers.getIdentifier(\n 'server-' + server,\n config,\n )}`}\n className=\"border border-solid border-blue-300 hover:bg-blue-300 hover:text-blue-600 text-blue-500 font-bold no-underline text-xs rounded px-3 py-1 cursor-pointer\"\n >\n <span className=\"underline\">{server}</span>\n </a>\n </li>\n ))}\n </ul>\n </div>\n ) : null}\n\n {parameters && (\n <div\n className=\"mt-2\"\n id={CommonHelpers.getIdentifier(\n `operation-${type}-${channelName}-parameters`,\n config,\n )}\n >\n <Schema\n schemaName=\"Parameters\"\n schema={parameters}\n expanded={true}\n />\n </div>\n )}\n\n {security && (\n <div\n className=\"mt-2\"\n id={CommonHelpers.getIdentifier(\n `operation-${type}-${channelName}-security`,\n config,\n )}\n >\n <Security\n security={security}\n header=\"Additional security requirements\"\n />\n </div>\n )}\n\n {channel.bindings() && (\n <div className=\"mt-2\">\n <Bindings\n name=\"Channel specific information\"\n bindings={channel.bindings()}\n />\n </div>\n )}\n\n <Extensions name=\"Channel Extensions\" item={channel} />\n\n {operation.bindings() && (\n <div className=\"mt-2\">\n <Bindings\n name=\"Operation specific information\"\n bindings={operation.bindings()}\n />\n </div>\n )}\n\n <Extensions name=\"Operation Extensions\" item={operation} />\n\n {operation.tags() && (\n <div className=\"mt-2\">\n <Tags tags={operation.tags()} />\n </div>\n )}\n </div>\n\n <div\n className=\"w-full mt-4\"\n id={CommonHelpers.getIdentifier(\n `operation-${type}-${channelName}-message`,\n config,\n )}\n >\n {operation.messages().length > 1 ? (\n <div className=\"mt-2\">\n <p className=\"px-8\">\n Accepts <strong>one of</strong> the following messages:\n </p>\n <ul>\n {operation.messages().map((msg, idx) => (\n <li className=\"mt-4\" key={idx}>\n <Message message={msg} index={idx} showExamples={true} />\n </li>\n ))}\n </ul>\n </div>\n ) : (\n <div className=\"mt-2\">\n <p className=\"px-8\">Accepts the following message:</p>\n <div className=\"mt-2\">\n <Message message={operation.messages()[0]} showExamples={true} />\n </div>\n </div>\n )}\n </div>\n </div>\n );\n};\n\nexport const OperationInfo: React.FunctionComponent<Props> = ({\n type = PayloadType.PUBLISH,\n operation,\n channelName,\n channel,\n}) => {\n const config = useConfig();\n const operationSummary = operation.summary();\n const externalDocs = operation.externalDocs();\n const operationId = operation.id();\n\n return (\n <>\n <div className=\"mb-4\">\n <h3>\n <span\n className={`font-mono border uppercase p-1 rounded mr-2 ${\n type === PayloadType.PUBLISH\n ? 'border-blue-600 text-blue-500'\n : 'border-green-600 text-green-600'\n }`}\n title={type}\n >\n {type === PayloadType.PUBLISH\n ? config.publishLabel || PUBLISH_LABEL_DEFAULT_TEXT\n : config.subscribeLabel || SUBSCRIBE_LABEL_DEFAULT_TEXT}\n </span>{' '}\n <span className=\"font-mono text-base\">{channelName}</span>\n </h3>\n </div>\n\n {channel.hasDescription() && (\n <div className=\"mt-2\">\n <Markdown>{channel.description()}</Markdown>\n </div>\n )}\n {operationSummary && (\n <p className=\"text-gray-600 text-sm mt-2\">{operationSummary}</p>\n )}\n {operation.hasDescription() && (\n <div className=\"mt-2\">\n <Markdown>{operation.description()}</Markdown>\n </div>\n )}\n\n {externalDocs && (\n <ul className=\"leading-normal mt-2 mb-4 space-x-2 space-y-2\">\n {externalDocs && (\n <li className=\"inline-block\">\n <Href\n className=\"border border-solid border-orange-300 hover:bg-orange-300 hover:text-orange-600 text-orange-500 font-bold no-underline text-xs uppercase rounded px-3 py-1\"\n href={externalDocs.url()}\n >\n <span>{EXTERAL_DOCUMENTATION_TEXT}</span>\n </Href>\n </li>\n )}\n </ul>\n )}\n\n {operationId && (\n <div className=\"border bg-gray-100 rounded px-4 py-2 mt-2\">\n <div className=\"text-sm text-gray-700\">\n Operation ID\n <span className=\"border text-orange-600 rounded text-xs ml-2 py-0 px-2\">\n {operationId}\n </span>\n </div>\n </div>\n )}\n </>\n );\n};\n"]}
1
+ {"version":3,"file":"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AAO,CAAC,WAAW,EAAE,CAAY,CACxC,CACP;QACA,gBAAgB,IAAI,CACnB,qCAAG,SAAS,EAAC,4BAA4B,IAAE,gBAAgB,CAAK,CACjE;QACA,SAAS,CAAC,cAAc,EAAE,IAAI,CAC7B,uCAAK,SAAS,EAAC,MAAM;YACnB,8BAAC,qBAAQ,QAAE,SAAS,CAAC,WAAW,EAAE,CAAY,CAC1C,CACP;QAEA,YAAY,IAAI,CACf,sCAAI,SAAS,EAAC,8CAA8C,IACzD,YAAY,IAAI,CACf,sCAAI,SAAS,EAAC,cAAc;YAC1B,8BAAC,iBAAI,IACH,SAAS,EAAC,4JAA4J,EACtK,IAAI,EAAE,YAAY,CAAC,GAAG,EAAE;gBAExB,4CAAO,sCAA0B,CAAQ,CACpC,CACJ,CACN,CACE,CACN;QAEA,WAAW,IAAI,CACd,uCAAK,SAAS,EAAC,2CAA2C;YACxD,uCAAK,SAAS,EAAC,uBAAuB;;gBAEpC,wCAAM,SAAS,EAAC,uDAAuD,IACpE,WAAW,CACP,CACH,CACF,CACP,CACA,CACJ,CAAC;AACJ,CAAC,CAAC;AA/DW,QAAA,aAAa,iBA+DxB","sourcesContent":["import React from 'react';\nimport { ChannelInterface, OperationInterface } from '@asyncapi/parser';\n\nimport { Message } from '../Messages/Message';\nimport { Security } from '../Servers/Security';\nimport {\n Href,\n Markdown,\n Schema,\n Bindings,\n Tags,\n Extensions,\n} from '../../components';\n\nimport { useConfig } from '../../contexts';\nimport { CommonHelpers, SchemaHelpers } from '../../helpers';\nimport {\n EXTERAL_DOCUMENTATION_TEXT,\n PUBLISH_LABEL_DEFAULT_TEXT,\n SUBSCRIBE_LABEL_DEFAULT_TEXT,\n} from '../../constants';\nimport { PayloadType } from '../../types';\nimport { ConfigInterface } from '../../config/config';\ninterface Props {\n type: PayloadType;\n operation: OperationInterface;\n channelName: string;\n channel: ChannelInterface;\n}\n\nexport const Operation: React.FunctionComponent<Props> = props => {\n const config = useConfig();\n const { type = PayloadType.PUBLISH, operation, channelName, channel } = props;\n\n if (!operation || !channel) {\n return null;\n }\n\n // check typeof as fallback for older version than `2.2.0`\n const servers =\n typeof channel.servers === 'function' && channel.servers().all();\n // check typeof as fallback for older version than `2.4.0`\n const security =\n typeof operation.security === 'function' && operation.security();\n const parameters =\n channel.parameters() !== undefined\n ? SchemaHelpers.parametersToSchema(channel.parameters())\n : undefined;\n\n return (\n <div>\n <div className=\"panel-item--center px-8\">\n <OperationInfo {...props} />\n\n {servers && servers.length > 0 ? (\n <div className=\"mt-2 text-sm\">\n <p>Available only on servers:</p>\n <ul className=\"flex flex-wrap leading-normal\">\n {servers.map(server => (\n <li className=\"inline-block mt-2 mr-2\" key={server.id()}>\n <a\n href={`#${CommonHelpers.getIdentifier(\n 'server-' + server.id(),\n config,\n )}`}\n className=\"border border-solid border-blue-300 hover:bg-blue-300 hover:text-blue-600 text-blue-500 font-bold no-underline text-xs rounded px-3 py-1 cursor-pointer\"\n >\n <span className=\"underline\">{server.id()}</span>\n </a>\n </li>\n ))}\n </ul>\n </div>\n ) : null}\n\n {parameters && (\n <div\n className=\"mt-2\"\n id={CommonHelpers.getIdentifier(\n `operation-${type}-${channelName}-parameters`,\n config,\n )}\n >\n <Schema\n schemaName=\"Parameters\"\n schema={parameters}\n expanded={true}\n />\n </div>\n )}\n\n {security && (\n <div\n className=\"mt-2\"\n id={CommonHelpers.getIdentifier(\n `operation-${type}-${channelName}-security`,\n config,\n )}\n >\n <Security\n security={security}\n header=\"Additional security requirements\"\n />\n </div>\n )}\n\n {channel.bindings() && (\n <div className=\"mt-2\">\n <Bindings\n name=\"Channel specific information\"\n bindings={channel.bindings()}\n />\n </div>\n )}\n\n <Extensions name=\"Channel Extensions\" item={channel} />\n\n {operation.bindings() && (\n <div className=\"mt-2\">\n <Bindings\n name=\"Operation specific information\"\n bindings={operation.bindings()}\n />\n </div>\n )}\n\n <Extensions name=\"Operation Extensions\" item={operation} />\n\n {operation.tags() && (\n <div className=\"mt-2\">\n <Tags tags={operation.tags()} />\n </div>\n )}\n </div>\n\n <div\n className=\"w-full mt-4\"\n id={CommonHelpers.getIdentifier(\n `operation-${type}-${channelName}-message`,\n config,\n )}\n >\n {operation.messages().length > 1 ? (\n <div className=\"mt-2\">\n <p className=\"px-8\">\n Accepts <strong>one of</strong> the following messages:\n </p>\n <ul>\n {operation\n .messages()\n .all()\n .map((msg, idx) => (\n <li className=\"mt-4\" key={idx}>\n <Message message={msg} index={idx} showExamples={true} />\n </li>\n ))}\n </ul>\n </div>\n ) : (\n <div className=\"mt-2\">\n <p className=\"px-8\">Accepts the following message:</p>\n <div className=\"mt-2\">\n <Message\n message={operation.messages().all()[0]}\n showExamples={true}\n />\n </div>\n </div>\n )}\n </div>\n </div>\n );\n};\n\nfunction getTypeInformation({\n type = PayloadType.PUBLISH,\n config,\n}: {\n type: PayloadType;\n config: ConfigInterface;\n}): { borderColor: string; typeLabel: string } {\n if (type === PayloadType.SUBSCRIBE) {\n return {\n borderColor: 'border-green-600 text-green-600',\n typeLabel: config.subscribeLabel ?? SUBSCRIBE_LABEL_DEFAULT_TEXT,\n };\n }\n // type === PayloadType.PUBLISH\n return {\n borderColor: 'border-blue-600 text-blue-500',\n typeLabel: config.publishLabel ?? PUBLISH_LABEL_DEFAULT_TEXT,\n };\n}\n\nexport const OperationInfo: React.FunctionComponent<Props> = props => {\n const { type = PayloadType.PUBLISH, operation, channelName, channel } = props;\n const config = useConfig();\n const operationSummary = operation.summary();\n const externalDocs = operation.externalDocs();\n const operationId = operation.id();\n const { borderColor, typeLabel } = getTypeInformation({ type, config });\n\n return (\n <>\n <div className=\"mb-4\">\n <h3>\n <span\n className={`font-mono border uppercase p-1 rounded mr-2 ${borderColor}`}\n title={type}\n >\n {typeLabel}\n </span>{' '}\n <span className=\"font-mono text-base\">{channelName}</span>\n </h3>\n </div>\n\n {channel.hasDescription() && (\n <div className=\"mt-2\">\n <Markdown>{channel.description()}</Markdown>\n </div>\n )}\n {operationSummary && (\n <p className=\"text-gray-600 text-sm mt-2\">{operationSummary}</p>\n )}\n {operation.hasDescription() && (\n <div className=\"mt-2\">\n <Markdown>{operation.description()}</Markdown>\n </div>\n )}\n\n {externalDocs && (\n <ul className=\"leading-normal mt-2 mb-4 space-x-2 space-y-2\">\n {externalDocs && (\n <li className=\"inline-block\">\n <Href\n className=\"border border-solid border-orange-300 hover:bg-orange-300 hover:text-orange-600 text-orange-500 font-bold no-underline text-xs uppercase rounded px-3 py-1\"\n href={externalDocs.url()}\n >\n <span>{EXTERAL_DOCUMENTATION_TEXT}</span>\n </Href>\n </li>\n )}\n </ul>\n )}\n\n {operationId && (\n <div className=\"border bg-gray-100 rounded px-4 py-2 mt-2\">\n <div className=\"text-sm text-gray-700\">\n Operation ID\n <span className=\"border text-orange-600 rounded text-xs ml-2 py-0 px-2\">\n {operationId}\n </span>\n </div>\n </div>\n )}\n </>\n );\n};\n"]}
@@ -11,21 +11,25 @@ var helpers_1 = require("../../helpers");
11
11
  var constants_1 = require("../../constants");
12
12
  var types_1 = require("../../types");
13
13
  var Operations = function () {
14
- var operations = (0, contexts_1.useSpec)().operations();
14
+ var operations = (0, contexts_1.useSpec)()
15
+ .operations()
16
+ .all();
15
17
  var config = (0, contexts_1.useConfig)();
16
18
  if (!Object.keys(operations).length) {
17
19
  return null;
18
20
  }
19
21
  var operationsList = [];
20
- Object.entries(operations).forEach(function (_a) {
21
- var operationName = _a[0], operation = _a[1];
22
+ operations.forEach(function (operation) {
23
+ var _a;
24
+ var channel = operation.channels().all()[0];
25
+ var channelAddress = (_a = channel === null || channel === void 0 ? void 0 : channel.address()) !== null && _a !== void 0 ? _a : '';
22
26
  if (operation.isSend()) {
23
- operationsList.push(react_1.default.createElement("li", { className: "mb-12", key: "pub-".concat(operationName), id: helpers_1.CommonHelpers.getIdentifier("operation-".concat(types_1.PayloadType.PUBLISH, "-").concat(operationName), config) },
24
- react_1.default.createElement(Operation_1.Operation, { type: types_1.PayloadType.PUBLISH, operation: operation, channelName: operationName, channel: operation.channels()[0] })));
27
+ operationsList.push(react_1.default.createElement("li", { className: "mb-12", key: "pub-".concat(operation.id()), id: helpers_1.CommonHelpers.getIdentifier("operation-".concat(types_1.PayloadType.PUBLISH, "-").concat(operation.id()), config) },
28
+ react_1.default.createElement(Operation_1.Operation, { type: types_1.PayloadType.PUBLISH, operation: operation, channelName: channelAddress, channel: channel })));
25
29
  }
26
30
  if (operation.isReceive()) {
27
- operationsList.push(react_1.default.createElement("li", { className: "mb-12", key: "sub-".concat(operationName), id: helpers_1.CommonHelpers.getIdentifier("operation-".concat(types_1.PayloadType.SUBSCRIBE, "-").concat(operationName), config) },
28
- react_1.default.createElement(Operation_1.Operation, { type: types_1.PayloadType.SUBSCRIBE, operation: operation, channelName: operationName, channel: operation.channels()[0] })));
31
+ operationsList.push(react_1.default.createElement("li", { className: "mb-12", key: "sub-".concat(operation.id()), id: helpers_1.CommonHelpers.getIdentifier("operation-".concat(types_1.PayloadType.SUBSCRIBE, "-").concat(operation.id()), config) },
32
+ react_1.default.createElement(Operation_1.Operation, { type: types_1.PayloadType.SUBSCRIBE, operation: operation, channelName: channelAddress, channel: channel })));
29
33
  }
30
34
  });
31
35
  return (react_1.default.createElement("section", { id: "".concat(helpers_1.CommonHelpers.getIdentifier('operations', config)), className: "mt-16" },
@@ -1 +1 @@
1
- {"version":3,"file":"Operations.js","sourceRoot":"","sources":["../../../../src/containers/Operations/Operations.tsx"],"names":[],"mappings":";;;;;;AAAA,gDAA0B;AAE1B,yCAAwC;AACxC,2CAAoD;AACpD,yCAA8C;AAC9C,6CAAkD;AAClD,qCAA0C;AAEnC,IAAM,UAAU,GAA4B;IACjD,IAAM,UAAU,GAAG,IAAA,kBAAO,GAAE,CAAC,UAAU,EAAE,CAAC;IAC1C,IAAM,MAAM,GAAG,IAAA,oBAAS,GAAE,CAAC;IAE3B,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,MAAM,EAAE;QACnC,OAAO,IAAI,CAAC;KACb;IAED,IAAM,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ACX,CAAC;AACJ,CAAC,CAAC;AA7DW,QAAA,UAAU,cA6DrB","sourcesContent":["import React from 'react';\n\nimport { Operation } from './Operation';\nimport { useConfig, useSpec } from '../../contexts';\nimport { CommonHelpers } from '../../helpers';\nimport { OPERATIONS_TEXT } from '../../constants';\nimport { PayloadType } from '../../types';\n\nexport const Operations: React.FunctionComponent = () => {\n const operations = useSpec().operations();\n const config = useConfig();\n\n if (!Object.keys(operations).length) {\n return null;\n }\n\n const operationsList: React.ReactNodeArray = [];\n Object.entries(operations).forEach(([operationName, operation]) => {\n if (operation.isSend()) {\n operationsList.push(\n <li\n className=\"mb-12\"\n key={`pub-${operationName}`}\n id={CommonHelpers.getIdentifier(\n `operation-${PayloadType.PUBLISH}-${operationName}`,\n config,\n )}\n >\n <Operation\n type={PayloadType.PUBLISH}\n operation={operation}\n channelName={operationName}\n channel={operation.channels()[0]}\n />\n </li>,\n );\n }\n if (operation.isReceive()) {\n operationsList.push(\n <li\n className=\"mb-12\"\n key={`sub-${operationName}`}\n id={CommonHelpers.getIdentifier(\n `operation-${PayloadType.SUBSCRIBE}-${operationName}`,\n config,\n )}\n >\n <Operation\n type={PayloadType.SUBSCRIBE}\n operation={operation}\n channelName={operationName}\n channel={operation.channels()[0]}\n />\n </li>,\n );\n }\n });\n\n return (\n <section\n id={`${CommonHelpers.getIdentifier('operations', config)}`}\n className=\"mt-16\"\n >\n <h2 className=\"2xl:w-7/12 text-3xl font-light mb-4 px-8\">\n {OPERATIONS_TEXT}\n </h2>\n <ul>{operationsList}</ul>\n </section>\n );\n};\n"]}
1
+ {"version":3,"file":"Operations.js","sourceRoot":"","sources":["../../../../src/containers/Operations/Operations.tsx"],"names":[],"mappings":";;;;;;AAAA,gDAA0B;AAE1B,yCAAwC;AACxC,2CAAoD;AACpD,yCAA8C;AAC9C,6CAAkD;AAClD,qCAA0C;AAEnC,IAAM,UAAU,GAA4B;IACjD,IAAM,UAAU,GAAG,IAAA,kBAAO,GAAE;SACzB,UAAU,EA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SAAS,EACpB,WAAW,EAAE,cAAc,EAC3B,OAAO,EAAE,OAAO,GAChB,CACC,CACN,CAAC;SACH;IACH,CAAC,CAAC,CAAC;IAEH,OAAO,CACL,2CACE,EAAE,EAAE,UAAG,uBAAa,CAAC,aAAa,CAAC,YAAY,EAAE,MAAM,CAAC,CAAE,EAC1D,SAAS,EAAC,OAAO;QAEjB,sCAAI,SAAS,EAAC,0CAA0C,IACrD,2BAAe,CACb;QACL,0CAAK,cAAc,CAAM,CACjB,CACX,CAAC;AACJ,CAAC,CAAC;AAjEW,QAAA,UAAU,cAiErB","sourcesContent":["import React from 'react';\n\nimport { Operation } from './Operation';\nimport { useConfig, useSpec } from '../../contexts';\nimport { CommonHelpers } from '../../helpers';\nimport { OPERATIONS_TEXT } from '../../constants';\nimport { PayloadType } from '../../types';\n\nexport const Operations: React.FunctionComponent = () => {\n const operations = useSpec()\n .operations()\n .all();\n const config = useConfig();\n\n if (!Object.keys(operations).length) {\n return null;\n }\n\n const operationsList: React.ReactNodeArray = [];\n operations.forEach(operation => {\n const channel = operation.channels().all()[0];\n const channelAddress = channel?.address() ?? '';\n if (operation.isSend()) {\n operationsList.push(\n <li\n className=\"mb-12\"\n key={`pub-${operation.id()}`}\n id={CommonHelpers.getIdentifier(\n `operation-${PayloadType.PUBLISH}-${operation.id()}`,\n config,\n )}\n >\n <Operation\n type={PayloadType.PUBLISH}\n operation={operation}\n channelName={channelAddress}\n channel={channel}\n />\n </li>,\n );\n }\n if (operation.isReceive()) {\n operationsList.push(\n <li\n className=\"mb-12\"\n key={`sub-${operation.id()}`}\n id={CommonHelpers.getIdentifier(\n `operation-${PayloadType.SUBSCRIBE}-${operation.id()}`,\n config,\n )}\n >\n <Operation\n type={PayloadType.SUBSCRIBE}\n operation={operation}\n channelName={channelAddress}\n channel={channel}\n />\n </li>,\n );\n }\n });\n\n return (\n <section\n id={`${CommonHelpers.getIdentifier('operations', config)}`}\n className=\"mt-16\"\n >\n <h2 className=\"2xl:w-7/12 text-3xl font-light mb-4 px-8\">\n {OPERATIONS_TEXT}\n </h2>\n <ul>{operationsList}</ul>\n </section>\n );\n};\n"]}
@@ -12,17 +12,18 @@ var constants_1 = require("../../constants");
12
12
  var Schemas = function () {
13
13
  var asyncapi = (0, contexts_1.useSpec)();
14
14
  var config = (0, contexts_1.useConfig)();
15
- var schemas = !asyncapi.components().isEmpty() && asyncapi.components().schemas();
16
- if (!schemas || Object.keys(schemas).length === 0) {
15
+ var schemas = !asyncapi.components().isEmpty() &&
16
+ asyncapi
17
+ .components()
18
+ .schemas()
19
+ .all();
20
+ if (!schemas || schemas.length === 0) {
17
21
  return null;
18
22
  }
19
23
  return (react_1.default.createElement("section", { id: "".concat(helpers_1.CommonHelpers.getIdentifier('schemas', config)), className: "mt-16" },
20
24
  react_1.default.createElement("h2", { className: "2xl:w-7/12 text-3xl font-light mb-4 px-8" }, constants_1.SCHEMAS_TEXT),
21
- react_1.default.createElement("ul", null, Object.entries(schemas).map(function (_a) {
22
- var schemaName = _a[0], schema = _a[1];
23
- return (react_1.default.createElement("li", { className: "mb-4", key: schemaName, id: helpers_1.CommonHelpers.getIdentifier("schema-".concat(schemaName), config) },
24
- react_1.default.createElement(Schema_1.Schema, { schemaName: schemaName, schema: schema })));
25
- }))));
25
+ react_1.default.createElement("ul", null, schemas.map(function (schema) { return (react_1.default.createElement("li", { className: "mb-4", key: schema.id(), id: helpers_1.CommonHelpers.getIdentifier("schema-".concat(schema.id()), config) },
26
+ react_1.default.createElement(Schema_1.Schema, { schemaName: schema.id(), schema: schema }))); }))));
26
27
  };
27
28
  exports.Schemas = Schemas;
28
29
  //# sourceMappingURL=Schemas.js.map