@redocly/asyncapi-docs 1.4.0-next.9 → 1.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var j=exports&&exports.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(exports,"__esModule",{value:!0}),exports.Message=void 0;const o=require("react/jsx-runtime"),h=require("react"),d=j(require("styled-components")),s=require("@redocly/theme"),p=require("jotai"),a=require("@redocly/openapi-docs"),m=require("./common"),v=require("./JsonSchema"),_=require("../utils"),k=require("../hooks"),f=require("../jotai-store/app");exports.Message=(0,h.memo)(({message:e,sectionId:t,id:i,onOneOfChange:y})=>{var c;const r=(0,p.useAtomValue)(f.routingBasePathAtom),n=(0,p.useAtomValue)(f.definitionAtom),{getProtocolLabel:x}=(0,k.useProtocolLabels)(),u=(0,h.useMemo)(()=>{var l;if(!((l=n?.components)===null||l===void 0)&&l.schemas)return{openapi:"3.0.0",info:{version:"1",title:"AsyncAPI",description:""},paths:{},components:{schemas:n.components.schemas}}},[(c=n?.components)===null||c===void 0?void 0:c.schemas]);return(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)(m.Information,{summary:e.summary,description:e.description,externalDocs:e.externalDocs}),e.headers&&(0,o.jsxs)(o.Fragment,{children:[(0,o.jsxs)(g,{children:[(0,o.jsx)(m.LinkToField,{to:(0,s.combineUrls)(r,(0,a.makeDeepLink)(t,`messages&m=${i}/headers`))}),"Headers"]}),(0,o.jsx)(v.JsonSchema,{schema:(0,_.getSchema)(e.headers),schemaResolved:u,slug:(0,s.combineUrls)(r,(0,a.makeDeepLink)(t,`messages&m=${i}&t=headers`))})]}),e.payload&&(0,o.jsxs)(o.Fragment,{children:[(0,o.jsxs)(g,{children:[(0,o.jsx)(m.LinkToField,{to:(0,s.combineUrls)(r,(0,a.makeDeepLink)(t,`messages&m=${i}/payload`))}),x("payload"),e.contentType&&(0,o.jsx)(q,{children:e.contentType})]}),(0,o.jsx)(v.JsonSchema,{onOneOfChange:y,schema:(0,_.getSchema)(e.payload),schemaResolved:u,slug:(0,s.combineUrls)(r,(0,a.makeDeepLink)(t,`messages&m=${i}&t=payload`))})]})]})});const g=(0,d.default)(s.H4)`
|
|
2
2
|
margin: var(--spacing-md) 0 0 0;
|
|
3
3
|
font-size: 18px;
|
|
4
4
|
position: relative;
|
|
5
5
|
:hover {
|
|
6
|
-
${
|
|
6
|
+
${s.LinkIcon} {
|
|
7
7
|
opacity: 1;
|
|
8
8
|
visibility: visible;
|
|
9
9
|
}
|
|
10
10
|
}
|
|
11
|
-
`,
|
|
11
|
+
`,q=d.default.span`
|
|
12
12
|
margin: 0px var(--spacing-xs);
|
|
13
13
|
color: var(--text-color-primary);
|
|
14
14
|
line-height: var(--line-height-lg);
|
|
@@ -1,23 +1,23 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var V=exports&&exports.__createBinding||(Object.create?(function(e,n,o,s){s===void 0&&(s=o);var l=Object.getOwnPropertyDescriptor(n,o);(!l||("get"in l?!n.__esModule:l.writable||l.configurable))&&(l={enumerable:!0,get:function(){return n[o]}}),Object.defineProperty(e,s,l)}):(function(e,n,o,s){s===void 0&&(s=o),e[s]=n[o]})),W=exports&&exports.__setModuleDefault||(Object.create?(function(e,n){Object.defineProperty(e,"default",{enumerable:!0,value:n})}):function(e,n){e.default=n}),D=exports&&exports.__importStar||(function(){var e=function(n){return e=Object.getOwnPropertyNames||function(o){var s=[];for(var l in o)Object.prototype.hasOwnProperty.call(o,l)&&(s[s.length]=l);return s},e(n)};return function(n){if(n&&n.__esModule)return n;var o={};if(n!=null)for(var s=e(n),l=0;l<s.length;l++)s[l]!=="default"&&V(o,n,s[l]);return W(o,n),o}})(),z=exports&&exports.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(exports,"__esModule",{value:!0}),exports.MessageSection=void 0;const i=require("react/jsx-runtime"),h=z(require("styled-components")),k=require("jotai"),F=require("react-router-dom"),d=require("@redocly/openapi-docs"),f=require("@redocly/theme"),r=D(require("react")),H=D(require("openapi-sampler")),K=require("./SamplesPanel"),N=require("./MessageBinding"),U=require("./MessageReferences"),P=require("../jotai-store/app"),G=require("./Message"),T=require("../utils"),I=require("./common"),J=require("../hooks"),Q=3;exports.MessageSection=r.default.memo(({messages:e,id:n})=>{var o;const s=(0,F.useLocation)(),l=(0,r.useMemo)(()=>e.find(t=>(0,d.pathIncludesLink)(s,`m=${t.key}`))||e[0],[e,s]),[c,O]=(0,r.useState)(l),[y,_]=(0,r.useState)(c.value.payload),E=(0,r.useCallback)(t=>{const a=(0,T.modifyPayload)(y,t);a&&_(a)},[]),v=(0,k.useAtomValue)(P.definitionAtom),B=(0,r.useCallback)(()=>{var t;return c.value.examples||[{payload:H.sample(Object.assign({},(0,T.getSchema)(y)),{},!((t=v?.components)===null||t===void 0)&&t.schemas?{components:{schemas:v.components.schemas}}:void 0)}]},[y,c.value.examples,(o=v?.components)===null||o===void 0?void 0:o.schemas]),M=(0,k.useAtomValue)(P.layoutAtom),p=(0,k.useAtomValue)(P.routingBasePathAtom),j=M===f.LayoutVariant.STACKED,m=(0,r.useMemo)(()=>e.map(t=>({label:t.value.title||t.value.name||t.key,value:t.key})),[e]),[b,R]=(0,r.useState)(!1),S=(0,r.useRef)(null),w=(0,J.useTelemetry)();(0,r.useEffect)(()=>{var t;const a=e.find(u=>(0,d.pathIncludesLink)(s,`m=${u.key}`));a&&(O(a),!((t=a?.value)===null||t===void 0)&&t.payload&&_(a.value.payload))},[s,e]);const x=(0,r.useCallback)(({value:t})=>{var a;const u=e.find(g=>g.key===t);u&&(w.sendAsyncapiDocsSwitchMessageClickedMessage({message:u.key}),O(u),!((a=u?.value)===null||a===void 0)&&a.payload&&_(u.value.payload))},[e,w]),q=(0,r.useMemo)(()=>Object.entries(c.value.bindings||{}).map(([t,a])=>({key:t,value:a})),[c.value.bindings]),L=(0,r.useMemo)(()=>(0,f.combineUrls)(p,(0,d.makeDeepLink)(n,`messages&m=${c.key}`)),[n,p,c.key]);(0,r.useEffect)(()=>{if(!S.current)return;const t=()=>{var a;const u=(a=S.current)===null||a===void 0?void 0:a.querySelectorAll('button[role="tab"]'),g=Array.from(u||[]).some(A=>A.offsetWidth<A.scrollWidth);g!==b&&R(g)};return t(),window.addEventListener("resize",t),()=>window.removeEventListener("resize",t)},[b,m]);const $=(0,r.useMemo)(()=>(0,f.combineUrls)(p,(0,d.makeDeepLink)(n,"messages")),[n,p]);return(0,i.jsxs)(X,{"data-component-name":"MessageSection/MessageSection",children:[(0,i.jsx)(d.Row,{layout:M,children:(0,i.jsxs)(d.SamplesMiddlePanel,{isStacked:j,children:[(0,i.jsxs)(Y,{children:[(0,i.jsx)(I.LinkToField,{to:$}),"Messages"]}),e.length>1?(0,i.jsxs)(C,{children:["Accepts ",(0,i.jsx)("span",{children:"one of"})," the following messages:"]}):(0,i.jsx)(C,{children:"Accepts the following message:"})]})}),(0,i.jsxs)(d.Row,{layout:M,children:[(0,i.jsxs)(d.SamplesMiddlePanel,{isStacked:j,children:[(0,i.jsxs)(Z,{children:[(0,i.jsx)(I.LinkToField,{to:L}),m.length>Q||b?(0,i.jsx)(d.Dropdown,{options:m,value:c.key,onChange:x}):(0,i.jsx)(f.Segmented,{ref:S,size:"small",value:c.key,options:m,onChange:x})]}),(0,i.jsx)(G.Message,{message:c.value,sectionId:n,id:c.key,onOneOfChange:E})]}),(0,i.jsxs)(d.OperationSamplesPanel,{isStacked:j,className:"panel-container-response-samples",children:[(0,i.jsx)(K.SamplesPanel,{examples:B()}),!!q.length&&(0,i.jsx)(N.MessageBinding,{binding:q[0],slug:L}),(0,i.jsx)(U.MessageReferences,{messageKey:c.key})]})]})]})});const X=h.default.div`
|
|
2
2
|
padding: var(--spacing-xl) 0 0 0;
|
|
3
|
-
`,
|
|
3
|
+
`,Y=(0,h.default)(f.H4)`
|
|
4
4
|
margin: 0 0 var(--spacing-xs) 0;
|
|
5
5
|
position: relative;
|
|
6
6
|
:hover {
|
|
7
|
-
${
|
|
7
|
+
${f.LinkIcon} {
|
|
8
8
|
opacity: 1;
|
|
9
9
|
visibility: visible;
|
|
10
10
|
}
|
|
11
11
|
}
|
|
12
|
-
`,
|
|
12
|
+
`,C=(0,h.default)(f.Typography)`
|
|
13
13
|
& > span {
|
|
14
14
|
font-weight: var(--font-weight-bold);
|
|
15
15
|
}
|
|
16
16
|
margin: 0 0 var(--spacing-sm) 0;
|
|
17
|
-
`,
|
|
17
|
+
`,Z=h.default.div`
|
|
18
18
|
position: relative;
|
|
19
19
|
:hover {
|
|
20
|
-
${
|
|
20
|
+
${f.LinkIcon} {
|
|
21
21
|
opacity: 1;
|
|
22
22
|
visibility: visible;
|
|
23
23
|
}
|
package/lib/utils/get-schema.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.getSchema=void 0;const o=require("./avro-to-json-schema"),t=e=>e?.schema?(0,o.avroToJsonSchema)(e.schema):e;exports.getSchema=
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.getSchema=void 0;const o=require("./avro-to-json-schema"),t=["application/vnd.apache.avro","application/vnd.apache.avro+json","application/vnd.apache.avro+yaml"];function r(e){return e?t.some(a=>e.startsWith(a)):!1}const c=e=>e?.schema?r(e.schemaFormat)?(0,o.avroToJsonSchema)(e.schema):e.schema:e;exports.getSchema=c;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@redocly/asyncapi-docs",
|
|
3
|
-
"version": "1.4.0
|
|
3
|
+
"version": "1.4.0",
|
|
4
4
|
"description": "Async API docs for Redocly Realm",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"module": "lib/index.js",
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
"@testing-library/react": "16.3.0",
|
|
20
20
|
"@types/jest": "29.5.11",
|
|
21
21
|
"@types/json-schema": "^7.0.15",
|
|
22
|
-
"@types/node": "22.
|
|
22
|
+
"@types/node": "22.18.13",
|
|
23
23
|
"@types/react": "^19.1.4",
|
|
24
24
|
"@types/styled-components": "5.1.34",
|
|
25
25
|
"esbuild-minify-dir": "^0.0.1",
|
|
@@ -39,9 +39,9 @@
|
|
|
39
39
|
"react-router-dom": "^6.21.1",
|
|
40
40
|
"styled-components": "5.3.11",
|
|
41
41
|
"web-vitals": "3.3.1",
|
|
42
|
-
"@redocly/
|
|
43
|
-
"@redocly/
|
|
44
|
-
"@redocly/
|
|
42
|
+
"@redocly/openapi-docs": "3.15.0",
|
|
43
|
+
"@redocly/theme": "0.59.0",
|
|
44
|
+
"@redocly/config": "0.38.0"
|
|
45
45
|
},
|
|
46
46
|
"peerDependencies": {
|
|
47
47
|
"react": "^19.1.0"
|