@backstage/plugin-api-docs 0.10.4-next.1 → 0.11.0-next.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +35 -0
- package/README.md +5 -2
- package/alpha/package.json +7 -0
- package/dist/alpha.d.ts +9 -0
- package/dist/alpha.esm.js +169 -0
- package/dist/alpha.esm.js.map +1 -0
- package/dist/esm/ApiDefinitionCard-504c2432.esm.js +47 -0
- package/dist/esm/ApiDefinitionCard-504c2432.esm.js.map +1 -0
- package/dist/esm/ApiDefinitionWidget-798ee85f.esm.js +116 -0
- package/dist/esm/ApiDefinitionWidget-798ee85f.esm.js.map +1 -0
- package/dist/esm/ApiExplorerPage-ce544a95.esm.js +60 -0
- package/dist/esm/ApiExplorerPage-ce544a95.esm.js.map +1 -0
- package/dist/esm/ApiTypeTitle-cc79a2f3.esm.js +27 -0
- package/dist/esm/ApiTypeTitle-cc79a2f3.esm.js.map +1 -0
- package/dist/esm/ProvidedApisCard-e92fbd29.esm.js +256 -0
- package/dist/esm/ProvidedApisCard-e92fbd29.esm.js.map +1 -0
- package/dist/esm/ProvidingComponentsCard-5b679445.esm.js +70 -0
- package/dist/esm/ProvidingComponentsCard-5b679445.esm.js.map +1 -0
- package/dist/esm/{index-3c5f9414.esm.js → index-435dfc01.esm.js} +4 -8
- package/dist/esm/index-435dfc01.esm.js.map +1 -0
- package/dist/esm/{index-3d17238a.esm.js → index-5f0727eb.esm.js} +9 -11
- package/dist/esm/index-5f0727eb.esm.js.map +1 -0
- package/dist/esm/index-6f21bd2e.esm.js +11 -0
- package/dist/esm/index-6f21bd2e.esm.js.map +1 -0
- package/dist/esm/index-c969ed3d.esm.js +7 -0
- package/dist/esm/index-c969ed3d.esm.js.map +1 -0
- package/dist/index.esm.js +29 -539
- package/dist/index.esm.js.map +1 -1
- package/package.json +31 -17
- package/dist/esm/index-1081c12a.esm.js +0 -16
- package/dist/esm/index-1081c12a.esm.js.map +0 -1
- package/dist/esm/index-3c5f9414.esm.js.map +0 -1
- package/dist/esm/index-3d17238a.esm.js.map +0 -1
- package/dist/esm/index-ca71e2a1.esm.js +0 -16
- package/dist/esm/index-ca71e2a1.esm.js.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,40 @@
|
|
|
1
1
|
# @backstage/plugin-api-docs
|
|
2
2
|
|
|
3
|
+
## 0.11.0-next.3
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 172a717: Migrate the `api-docs` to the new frontend system. It is experimental and available via alpha subpath.
|
|
8
|
+
|
|
9
|
+
### Patch Changes
|
|
10
|
+
|
|
11
|
+
- 874e8cf: Updated README to list AsyncApi v3 as supported
|
|
12
|
+
- Updated dependencies
|
|
13
|
+
- @backstage/plugin-catalog@1.17.0-next.3
|
|
14
|
+
- @backstage/core-components@0.14.0-next.2
|
|
15
|
+
- @backstage/plugin-catalog-react@1.10.0-next.3
|
|
16
|
+
- @backstage/catalog-model@1.4.4-next.0
|
|
17
|
+
- @backstage/core-compat-api@0.2.0-next.3
|
|
18
|
+
- @backstage/core-plugin-api@1.9.0-next.1
|
|
19
|
+
- @backstage/frontend-plugin-api@0.6.0-next.3
|
|
20
|
+
- @backstage/plugin-catalog-common@1.0.21-next.0
|
|
21
|
+
- @backstage/plugin-permission-react@0.4.20-next.1
|
|
22
|
+
|
|
23
|
+
## 0.10.4-next.2
|
|
24
|
+
|
|
25
|
+
### Patch Changes
|
|
26
|
+
|
|
27
|
+
- 9aac2b0: Use `--cwd` as the first `yarn` argument
|
|
28
|
+
- 8fe56a8: Widen `@types/react` dependency range to include version 18.
|
|
29
|
+
- Updated dependencies
|
|
30
|
+
- @backstage/core-components@0.14.0-next.1
|
|
31
|
+
- @backstage/plugin-catalog@1.17.0-next.2
|
|
32
|
+
- @backstage/core-plugin-api@1.9.0-next.1
|
|
33
|
+
- @backstage/plugin-catalog-react@1.10.0-next.2
|
|
34
|
+
- @backstage/plugin-permission-react@0.4.20-next.1
|
|
35
|
+
- @backstage/catalog-model@1.4.4-next.0
|
|
36
|
+
- @backstage/plugin-catalog-common@1.0.21-next.0
|
|
37
|
+
|
|
3
38
|
## 0.10.4-next.1
|
|
4
39
|
|
|
5
40
|
### Patch Changes
|
package/README.md
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
# API Documentation
|
|
2
2
|
|
|
3
|
+
> Disclaimer:
|
|
4
|
+
> If you are looking for documentation on the experimental new frontend system support, please go [here](./README-alpha.md).
|
|
5
|
+
|
|
3
6
|
This is an extension for the catalog plugin that provides components to discover and display API entities.
|
|
4
7
|
APIs define the interface between components, see the [system model](https://backstage.io/docs/features/software-catalog/system-model) for details.
|
|
5
8
|
They are defined in machine readable formats and provide a human readable documentation.
|
|
@@ -13,7 +16,7 @@ The plugin provides a standalone list of APIs, as well as an integration into th
|
|
|
13
16
|
Right now, the following API formats are supported:
|
|
14
17
|
|
|
15
18
|
- [OpenAPI](https://swagger.io/specification/) 2 & 3
|
|
16
|
-
- [AsyncAPI](https://www.asyncapi.com/docs/reference/specification/latest)
|
|
19
|
+
- [AsyncAPI](https://www.asyncapi.com/docs/reference/specification/latest) 2 & 3
|
|
17
20
|
- [GraphQL](https://graphql.org/learn/schema/)
|
|
18
21
|
|
|
19
22
|
Other formats are displayed as plain text, but this can easily be extended.
|
|
@@ -29,7 +32,7 @@ To link that a component provides or consumes an API, see the [`providesApis`](h
|
|
|
29
32
|
|
|
30
33
|
```bash
|
|
31
34
|
# From your Backstage root directory
|
|
32
|
-
yarn
|
|
35
|
+
yarn --cwd packages/app add @backstage/plugin-api-docs
|
|
33
36
|
```
|
|
34
37
|
|
|
35
38
|
2. Add the `ApiExplorerPage` extension to the app:
|
package/dist/alpha.d.ts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import * as _backstage_frontend_plugin_api from '@backstage/frontend-plugin-api';
|
|
2
|
+
|
|
3
|
+
declare const _default: _backstage_frontend_plugin_api.BackstagePlugin<{
|
|
4
|
+
root: _backstage_frontend_plugin_api.RouteRef<undefined>;
|
|
5
|
+
}, {
|
|
6
|
+
registerApi: _backstage_frontend_plugin_api.ExternalRouteRef<undefined, true>;
|
|
7
|
+
}>;
|
|
8
|
+
|
|
9
|
+
export { _default as default };
|
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Grid } from '@material-ui/core';
|
|
3
|
+
import { createNavItemExtension, createApiExtension, createApiFactory, createPageExtension, createSchemaFromZod, createPlugin } from '@backstage/frontend-plugin-api';
|
|
4
|
+
import { convertLegacyRouteRef, compatWrapper } from '@backstage/core-compat-api';
|
|
5
|
+
import { useApp } from '@backstage/core-plugin-api';
|
|
6
|
+
import { createEntityCardExtension, createEntityContentExtension } from '@backstage/plugin-catalog-react/alpha';
|
|
7
|
+
import { RELATION_HAS_PART, parseEntityRef } from '@backstage/catalog-model';
|
|
8
|
+
import '@backstage/plugin-catalog-react';
|
|
9
|
+
import '@material-ui/lab';
|
|
10
|
+
import { r as rootRoute, a as apiDocsConfigRef, b as registerComponentRouteRef, d as defaultDefinitionWidgets } from './esm/ApiDefinitionWidget-798ee85f.esm.js';
|
|
11
|
+
import '@backstage/core-components';
|
|
12
|
+
import '@material-ui/core/Typography';
|
|
13
|
+
import '@material-ui/core/styles';
|
|
14
|
+
|
|
15
|
+
function ApiIcon() {
|
|
16
|
+
const app = useApp();
|
|
17
|
+
const KindApiSystemIcon = app.getSystemIcon("kind:api");
|
|
18
|
+
return /* @__PURE__ */ React.createElement(KindApiSystemIcon, null);
|
|
19
|
+
}
|
|
20
|
+
const apiDocsNavItem = createNavItemExtension({
|
|
21
|
+
title: "APIs",
|
|
22
|
+
routeRef: convertLegacyRouteRef(rootRoute),
|
|
23
|
+
icon: () => compatWrapper(/* @__PURE__ */ React.createElement(ApiIcon, null))
|
|
24
|
+
});
|
|
25
|
+
const apiDocsConfigApi = createApiExtension({
|
|
26
|
+
factory: createApiFactory({
|
|
27
|
+
api: apiDocsConfigRef,
|
|
28
|
+
deps: {},
|
|
29
|
+
factory: () => {
|
|
30
|
+
const definitionWidgets = defaultDefinitionWidgets();
|
|
31
|
+
return {
|
|
32
|
+
getApiDefinitionWidget: (apiEntity) => {
|
|
33
|
+
return definitionWidgets.find((d) => d.type === apiEntity.spec.type);
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
})
|
|
38
|
+
});
|
|
39
|
+
const apiDocsExplorerPage = createPageExtension({
|
|
40
|
+
defaultPath: "/api-docs",
|
|
41
|
+
routeRef: convertLegacyRouteRef(rootRoute),
|
|
42
|
+
// Mapping DefaultApiExplorerPageProps to config
|
|
43
|
+
configSchema: createSchemaFromZod(
|
|
44
|
+
(z) => z.object({
|
|
45
|
+
path: z.string().default("/api-docs"),
|
|
46
|
+
initiallySelectedFilter: z.enum(["owned", "starred", "all"]).optional()
|
|
47
|
+
// Ommiting columns and actions for now as their types are too complex to map to zod
|
|
48
|
+
})
|
|
49
|
+
),
|
|
50
|
+
loader: ({ config }) => import('./esm/index-435dfc01.esm.js').then(
|
|
51
|
+
(m) => compatWrapper(
|
|
52
|
+
/* @__PURE__ */ React.createElement(
|
|
53
|
+
m.ApiExplorerIndexPage,
|
|
54
|
+
{
|
|
55
|
+
initiallySelectedFilter: config.initiallySelectedFilter
|
|
56
|
+
}
|
|
57
|
+
)
|
|
58
|
+
)
|
|
59
|
+
)
|
|
60
|
+
});
|
|
61
|
+
const apiDocsHasApisEntityCard = createEntityCardExtension({
|
|
62
|
+
name: "has-apis",
|
|
63
|
+
// Ommiting configSchema for now
|
|
64
|
+
// We are skipping variants and columns are too complex to map to zod
|
|
65
|
+
// See: https://github.com/backstage/backstage/pull/22619#discussion_r1477333252
|
|
66
|
+
filter: (entity) => {
|
|
67
|
+
var _a;
|
|
68
|
+
return entity.kind === "Component" && ((_a = entity.relations) == null ? void 0 : _a.some(
|
|
69
|
+
({ type, targetRef }) => type.toLocaleLowerCase("en-US") === RELATION_HAS_PART && parseEntityRef(targetRef).kind === "API"
|
|
70
|
+
));
|
|
71
|
+
},
|
|
72
|
+
loader: () => import('./esm/index-5f0727eb.esm.js').then(
|
|
73
|
+
(m) => compatWrapper(/* @__PURE__ */ React.createElement(m.HasApisCard, null))
|
|
74
|
+
)
|
|
75
|
+
});
|
|
76
|
+
const apiDocsDefinitionEntityCard = createEntityCardExtension({
|
|
77
|
+
name: "definition",
|
|
78
|
+
filter: "kind:api",
|
|
79
|
+
loader: () => import('./esm/index-6f21bd2e.esm.js').then(
|
|
80
|
+
(m) => compatWrapper(/* @__PURE__ */ React.createElement(m.ApiDefinitionCard, null))
|
|
81
|
+
)
|
|
82
|
+
});
|
|
83
|
+
const apiDocsConsumedApisEntityCard = createEntityCardExtension({
|
|
84
|
+
name: "consumed-apis",
|
|
85
|
+
// Ommiting configSchema for now
|
|
86
|
+
// We are skipping variants and columns are too complex to map to zod
|
|
87
|
+
// See: https://github.com/backstage/backstage/pull/22619#discussion_r1477333252
|
|
88
|
+
filter: "kind:component",
|
|
89
|
+
loader: () => import('./esm/index-5f0727eb.esm.js').then(
|
|
90
|
+
(m) => compatWrapper(/* @__PURE__ */ React.createElement(m.ConsumedApisCard, null))
|
|
91
|
+
)
|
|
92
|
+
});
|
|
93
|
+
const apiDocsProvidedApisEntityCard = createEntityCardExtension({
|
|
94
|
+
name: "provided-apis",
|
|
95
|
+
// Ommiting configSchema for now
|
|
96
|
+
// We are skipping variants and columns are too complex to map to zod
|
|
97
|
+
// See: https://github.com/backstage/backstage/pull/22619#discussion_r1477333252
|
|
98
|
+
filter: "kind:component",
|
|
99
|
+
loader: () => import('./esm/index-5f0727eb.esm.js').then(
|
|
100
|
+
(m) => compatWrapper(/* @__PURE__ */ React.createElement(m.ProvidedApisCard, null))
|
|
101
|
+
)
|
|
102
|
+
});
|
|
103
|
+
const apiDocsConsumingComponentsEntityCard = createEntityCardExtension({
|
|
104
|
+
name: "consuming-components",
|
|
105
|
+
// Ommiting configSchema for now
|
|
106
|
+
// We are skipping variants
|
|
107
|
+
// See: https://github.com/backstage/backstage/pull/22619#discussion_r1477333252
|
|
108
|
+
filter: "kind:api",
|
|
109
|
+
loader: () => import('./esm/index-c969ed3d.esm.js').then(
|
|
110
|
+
(m) => compatWrapper(/* @__PURE__ */ React.createElement(m.ConsumingComponentsCard, null))
|
|
111
|
+
)
|
|
112
|
+
});
|
|
113
|
+
const apiDocsProvidingComponentsEntityCard = createEntityCardExtension({
|
|
114
|
+
name: "providing-components",
|
|
115
|
+
// Ommiting configSchema for now
|
|
116
|
+
// We are skipping variants
|
|
117
|
+
// See: https://github.com/backstage/backstage/pull/22619#discussion_r1477333252
|
|
118
|
+
filter: "kind:api",
|
|
119
|
+
loader: () => import('./esm/index-c969ed3d.esm.js').then(
|
|
120
|
+
(m) => compatWrapper(/* @__PURE__ */ React.createElement(m.ProvidingComponentsCard, null))
|
|
121
|
+
)
|
|
122
|
+
});
|
|
123
|
+
const apiDocsDefinitionEntityContent = createEntityContentExtension({
|
|
124
|
+
name: "definition",
|
|
125
|
+
defaultPath: "/defintion",
|
|
126
|
+
defaultTitle: "Definition",
|
|
127
|
+
filter: "kind:api",
|
|
128
|
+
loader: async () => import('./esm/index-6f21bd2e.esm.js').then(
|
|
129
|
+
(m) => compatWrapper(
|
|
130
|
+
/* @__PURE__ */ React.createElement(Grid, { container: true, spacing: 3 }, /* @__PURE__ */ React.createElement(Grid, { item: true, xs: 12 }, /* @__PURE__ */ React.createElement(m.ApiDefinitionCard, null)))
|
|
131
|
+
)
|
|
132
|
+
)
|
|
133
|
+
});
|
|
134
|
+
const apiDocsApisEntityContent = createEntityContentExtension({
|
|
135
|
+
name: "apis",
|
|
136
|
+
defaultPath: "/apis",
|
|
137
|
+
defaultTitle: "APIs",
|
|
138
|
+
filter: "kind:component",
|
|
139
|
+
loader: async () => import('./esm/index-5f0727eb.esm.js').then(
|
|
140
|
+
(m) => compatWrapper(
|
|
141
|
+
/* @__PURE__ */ React.createElement(Grid, { container: true, spacing: 3, alignItems: "stretch" }, /* @__PURE__ */ React.createElement(Grid, { item: true, xs: 12 }, /* @__PURE__ */ React.createElement(m.ProvidedApisCard, null)), /* @__PURE__ */ React.createElement(Grid, { item: true, xs: 12 }, /* @__PURE__ */ React.createElement(m.ConsumedApisCard, null)))
|
|
142
|
+
)
|
|
143
|
+
)
|
|
144
|
+
});
|
|
145
|
+
var alpha = createPlugin({
|
|
146
|
+
id: "api-docs",
|
|
147
|
+
routes: {
|
|
148
|
+
root: convertLegacyRouteRef(rootRoute)
|
|
149
|
+
},
|
|
150
|
+
externalRoutes: {
|
|
151
|
+
registerApi: convertLegacyRouteRef(registerComponentRouteRef)
|
|
152
|
+
},
|
|
153
|
+
extensions: [
|
|
154
|
+
apiDocsNavItem,
|
|
155
|
+
apiDocsConfigApi,
|
|
156
|
+
apiDocsExplorerPage,
|
|
157
|
+
apiDocsHasApisEntityCard,
|
|
158
|
+
apiDocsDefinitionEntityCard,
|
|
159
|
+
apiDocsProvidedApisEntityCard,
|
|
160
|
+
apiDocsConsumedApisEntityCard,
|
|
161
|
+
apiDocsConsumingComponentsEntityCard,
|
|
162
|
+
apiDocsProvidingComponentsEntityCard,
|
|
163
|
+
apiDocsDefinitionEntityContent,
|
|
164
|
+
apiDocsApisEntityContent
|
|
165
|
+
]
|
|
166
|
+
});
|
|
167
|
+
|
|
168
|
+
export { alpha as default };
|
|
169
|
+
//# sourceMappingURL=alpha.esm.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"alpha.esm.js","sources":["../src/alpha.tsx"],"sourcesContent":["/*\n * Copyright 2024 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport React from 'react';\nimport { Grid } from '@material-ui/core';\n\nimport {\n createApiExtension,\n createApiFactory,\n createNavItemExtension,\n createPageExtension,\n createPlugin,\n createSchemaFromZod,\n} from '@backstage/frontend-plugin-api';\n\nimport {\n compatWrapper,\n convertLegacyRouteRef,\n} from '@backstage/core-compat-api';\nimport { useApp } from '@backstage/core-plugin-api';\n\nimport {\n createEntityCardExtension,\n createEntityContentExtension,\n} from '@backstage/plugin-catalog-react/alpha';\nimport {\n ApiEntity,\n parseEntityRef,\n RELATION_HAS_PART,\n} from '@backstage/catalog-model';\n\nimport { defaultDefinitionWidgets } from './components/ApiDefinitionCard';\nimport { rootRoute, registerComponentRouteRef } from './routes';\nimport { apiDocsConfigRef } from './config';\n\nfunction ApiIcon() {\n const app = useApp();\n const KindApiSystemIcon = app.getSystemIcon('kind:api')!;\n return <KindApiSystemIcon />;\n}\n\nconst apiDocsNavItem = createNavItemExtension({\n title: 'APIs',\n routeRef: convertLegacyRouteRef(rootRoute),\n icon: () => compatWrapper(<ApiIcon />),\n});\n\nconst apiDocsConfigApi = createApiExtension({\n factory: createApiFactory({\n api: apiDocsConfigRef,\n deps: {},\n factory: () => {\n const definitionWidgets = defaultDefinitionWidgets();\n return {\n getApiDefinitionWidget: (apiEntity: ApiEntity) => {\n return definitionWidgets.find(d => d.type === apiEntity.spec.type);\n },\n };\n },\n }),\n});\n\nconst apiDocsExplorerPage = createPageExtension({\n defaultPath: '/api-docs',\n routeRef: convertLegacyRouteRef(rootRoute),\n // Mapping DefaultApiExplorerPageProps to config\n configSchema: createSchemaFromZod(z =>\n z.object({\n path: z.string().default('/api-docs'),\n initiallySelectedFilter: z.enum(['owned', 'starred', 'all']).optional(),\n // Ommiting columns and actions for now as their types are too complex to map to zod\n }),\n ),\n loader: ({ config }) =>\n import('./components/ApiExplorerPage').then(m =>\n compatWrapper(\n <m.ApiExplorerIndexPage\n initiallySelectedFilter={config.initiallySelectedFilter}\n />,\n ),\n ),\n});\n\nconst apiDocsHasApisEntityCard = createEntityCardExtension({\n name: 'has-apis',\n // Ommiting configSchema for now\n // We are skipping variants and columns are too complex to map to zod\n // See: https://github.com/backstage/backstage/pull/22619#discussion_r1477333252\n filter: entity => {\n return (\n entity.kind === 'Component' &&\n entity.relations?.some(\n ({ type, targetRef }) =>\n type.toLocaleLowerCase('en-US') === RELATION_HAS_PART &&\n parseEntityRef(targetRef).kind === 'API',\n )!!\n );\n },\n loader: () =>\n import('./components/ApisCards').then(m =>\n compatWrapper(<m.HasApisCard />),\n ),\n});\n\nconst apiDocsDefinitionEntityCard = createEntityCardExtension({\n name: 'definition',\n filter: 'kind:api',\n loader: () =>\n import('./components/ApiDefinitionCard').then(m =>\n compatWrapper(<m.ApiDefinitionCard />),\n ),\n});\n\nconst apiDocsConsumedApisEntityCard = createEntityCardExtension({\n name: 'consumed-apis',\n // Ommiting configSchema for now\n // We are skipping variants and columns are too complex to map to zod\n // See: https://github.com/backstage/backstage/pull/22619#discussion_r1477333252\n filter: 'kind:component',\n loader: () =>\n import('./components/ApisCards').then(m =>\n compatWrapper(<m.ConsumedApisCard />),\n ),\n});\n\nconst apiDocsProvidedApisEntityCard = createEntityCardExtension({\n name: 'provided-apis',\n // Ommiting configSchema for now\n // We are skipping variants and columns are too complex to map to zod\n // See: https://github.com/backstage/backstage/pull/22619#discussion_r1477333252\n filter: 'kind:component',\n loader: () =>\n import('./components/ApisCards').then(m =>\n compatWrapper(<m.ProvidedApisCard />),\n ),\n});\n\nconst apiDocsConsumingComponentsEntityCard = createEntityCardExtension({\n name: 'consuming-components',\n // Ommiting configSchema for now\n // We are skipping variants\n // See: https://github.com/backstage/backstage/pull/22619#discussion_r1477333252\n filter: 'kind:api',\n loader: () =>\n import('./components/ComponentsCards').then(m =>\n compatWrapper(<m.ConsumingComponentsCard />),\n ),\n});\n\nconst apiDocsProvidingComponentsEntityCard = createEntityCardExtension({\n name: 'providing-components',\n // Ommiting configSchema for now\n // We are skipping variants\n // See: https://github.com/backstage/backstage/pull/22619#discussion_r1477333252\n filter: 'kind:api',\n loader: () =>\n import('./components/ComponentsCards').then(m =>\n compatWrapper(<m.ProvidingComponentsCard />),\n ),\n});\n\nconst apiDocsDefinitionEntityContent = createEntityContentExtension({\n name: 'definition',\n defaultPath: '/defintion',\n defaultTitle: 'Definition',\n filter: 'kind:api',\n loader: async () =>\n import('./components/ApiDefinitionCard').then(m =>\n compatWrapper(\n <Grid container spacing={3}>\n <Grid item xs={12}>\n <m.ApiDefinitionCard />\n </Grid>\n </Grid>,\n ),\n ),\n});\n\nconst apiDocsApisEntityContent = createEntityContentExtension({\n name: 'apis',\n defaultPath: '/apis',\n defaultTitle: 'APIs',\n filter: 'kind:component',\n loader: async () =>\n import('./components/ApisCards').then(m =>\n compatWrapper(\n <Grid container spacing={3} alignItems=\"stretch\">\n <Grid item xs={12}>\n <m.ProvidedApisCard />\n </Grid>\n <Grid item xs={12}>\n <m.ConsumedApisCard />\n </Grid>\n </Grid>,\n ),\n ),\n});\n\nexport default createPlugin({\n id: 'api-docs',\n routes: {\n root: convertLegacyRouteRef(rootRoute),\n },\n externalRoutes: {\n registerApi: convertLegacyRouteRef(registerComponentRouteRef),\n },\n extensions: [\n apiDocsNavItem,\n apiDocsConfigApi,\n apiDocsExplorerPage,\n apiDocsHasApisEntityCard,\n apiDocsDefinitionEntityCard,\n apiDocsProvidedApisEntityCard,\n apiDocsConsumedApisEntityCard,\n apiDocsConsumingComponentsEntityCard,\n apiDocsProvidingComponentsEntityCard,\n apiDocsDefinitionEntityContent,\n apiDocsApisEntityContent,\n ],\n});\n"],"names":[],"mappings":";;;;;;;;;;;;;;AAgDA,SAAS,OAAU,GAAA;AACjB,EAAA,MAAM,MAAM,MAAO,EAAA,CAAA;AACnB,EAAM,MAAA,iBAAA,GAAoB,GAAI,CAAA,aAAA,CAAc,UAAU,CAAA,CAAA;AACtD,EAAA,2CAAQ,iBAAkB,EAAA,IAAA,CAAA,CA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AAA,UAAA;AAAA,EACJ,MAAQ,EAAA;AAAA,IACN,IAAA,EAAM,sBAAsB,SAAS,CAAA;AAAA,GACvC;AAAA,EACA,cAAgB,EAAA;AAAA,IACd,WAAA,EAAa,sBAAsB,yBAAyB,CAAA;AAAA,GAC9D;AAAA,EACA,UAAY,EAAA;AAAA,IACV,cAAA;AAAA,IACA,gBAAA;AAAA,IACA,mBAAA;AAAA,IACA,wBAAA;AAAA,IACA,2BAAA;AAAA,IACA,6BAAA;AAAA,IACA,6BAAA;AAAA,IACA,oCAAA;AAAA,IACA,oCAAA;AAAA,IACA,8BAAA;AAAA,IACA,wBAAA;AAAA,GACF;AACF,CAAC,CAAA;;;;"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { useEntity } from '@backstage/plugin-catalog-react';
|
|
2
|
+
import { Alert } from '@material-ui/lab';
|
|
3
|
+
import React from 'react';
|
|
4
|
+
import { a as apiDocsConfigRef } from './ApiDefinitionWidget-798ee85f.esm.js';
|
|
5
|
+
import { P as PlainApiDefinitionWidget } from './ApiTypeTitle-cc79a2f3.esm.js';
|
|
6
|
+
import { TabbedCard, CardTab } from '@backstage/core-components';
|
|
7
|
+
import { useApi } from '@backstage/core-plugin-api';
|
|
8
|
+
|
|
9
|
+
const ApiDefinitionCard = () => {
|
|
10
|
+
var _a;
|
|
11
|
+
const { entity } = useEntity();
|
|
12
|
+
const config = useApi(apiDocsConfigRef);
|
|
13
|
+
const { getApiDefinitionWidget } = config;
|
|
14
|
+
if (!entity) {
|
|
15
|
+
return /* @__PURE__ */ React.createElement(Alert, { severity: "error" }, "Could not fetch the API");
|
|
16
|
+
}
|
|
17
|
+
const definitionWidget = getApiDefinitionWidget(entity);
|
|
18
|
+
const entityTitle = (_a = entity.metadata.title) != null ? _a : entity.metadata.name;
|
|
19
|
+
if (definitionWidget) {
|
|
20
|
+
return /* @__PURE__ */ React.createElement(TabbedCard, { title: entityTitle }, /* @__PURE__ */ React.createElement(CardTab, { label: definitionWidget.title, key: "widget" }, definitionWidget.component(entity.spec.definition)), /* @__PURE__ */ React.createElement(CardTab, { label: "Raw", key: "raw" }, /* @__PURE__ */ React.createElement(
|
|
21
|
+
PlainApiDefinitionWidget,
|
|
22
|
+
{
|
|
23
|
+
definition: entity.spec.definition,
|
|
24
|
+
language: definitionWidget.rawLanguage || entity.spec.type
|
|
25
|
+
}
|
|
26
|
+
)));
|
|
27
|
+
}
|
|
28
|
+
return /* @__PURE__ */ React.createElement(
|
|
29
|
+
TabbedCard,
|
|
30
|
+
{
|
|
31
|
+
title: entityTitle,
|
|
32
|
+
children: [
|
|
33
|
+
// Has to be an array, otherwise typescript doesn't like that this has only a single child
|
|
34
|
+
/* @__PURE__ */ React.createElement(CardTab, { label: entity.spec.type, key: "raw" }, /* @__PURE__ */ React.createElement(
|
|
35
|
+
PlainApiDefinitionWidget,
|
|
36
|
+
{
|
|
37
|
+
definition: entity.spec.definition,
|
|
38
|
+
language: entity.spec.type
|
|
39
|
+
}
|
|
40
|
+
))
|
|
41
|
+
]
|
|
42
|
+
}
|
|
43
|
+
);
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
export { ApiDefinitionCard as A };
|
|
47
|
+
//# sourceMappingURL=ApiDefinitionCard-504c2432.esm.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ApiDefinitionCard-504c2432.esm.js","sources":["../../src/components/ApiDefinitionCard/ApiDefinitionCard.tsx"],"sourcesContent":["/*\n * Copyright 2020 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { ApiEntity } from '@backstage/catalog-model';\nimport { useEntity } from '@backstage/plugin-catalog-react';\nimport { Alert } from '@material-ui/lab';\nimport React from 'react';\nimport { apiDocsConfigRef } from '../../config';\nimport { PlainApiDefinitionWidget } from '../PlainApiDefinitionWidget';\n\nimport { CardTab, TabbedCard } from '@backstage/core-components';\nimport { useApi } from '@backstage/core-plugin-api';\n\n/** @public */\nexport const ApiDefinitionCard = () => {\n const { entity } = useEntity<ApiEntity>();\n const config = useApi(apiDocsConfigRef);\n const { getApiDefinitionWidget } = config;\n\n if (!entity) {\n return <Alert severity=\"error\">Could not fetch the API</Alert>;\n }\n\n const definitionWidget = getApiDefinitionWidget(entity);\n const entityTitle = entity.metadata.title ?? entity.metadata.name;\n\n if (definitionWidget) {\n return (\n <TabbedCard title={entityTitle}>\n <CardTab label={definitionWidget.title} key=\"widget\">\n {definitionWidget.component(entity.spec.definition)}\n </CardTab>\n <CardTab label=\"Raw\" key=\"raw\">\n <PlainApiDefinitionWidget\n definition={entity.spec.definition}\n language={definitionWidget.rawLanguage || entity.spec.type}\n />\n </CardTab>\n </TabbedCard>\n );\n }\n\n return (\n <TabbedCard\n title={entityTitle}\n children={[\n // Has to be an array, otherwise typescript doesn't like that this has only a single child\n <CardTab label={entity.spec.type} key=\"raw\">\n <PlainApiDefinitionWidget\n definition={entity.spec.definition}\n language={entity.spec.type}\n />\n </CardTab>,\n ]}\n />\n );\n};\n"],"names":[],"mappings":";;;;;;;;AA2BO,MAAM,oBAAoB,MAAM;AA3BvC,EAAA,IAAA,EAAA,CAAA;AA4BE,EAAM,MAAA,EAAE,MAAO,EAAA,GAAI,SAAqB,EAAA,CAAA;AACxC,EAAM,MAAA,MAAA,GAAS,OAAO,gBAAgB,CAAA,CAAA;AACtC,EAAM,MAAA,EAAE,wBAA2B,GAAA,MAAA,CAAA;AAEnC,EAAA,IAAI,CAAC,MAAQ,EAAA;AACX,IAAA,uBAAQ,KAAA,CAAA,aAAA,CAAA,KAAA,EAAA,EAAM,QAAS,EAAA,OAAA,EAAA,EAAQ,yB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;AAEJ;;;;"}
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
import { createRouteRef, createExternalRouteRef, createApiRef } from '@backstage/core-plugin-api';
|
|
2
|
+
import React, { Suspense } from 'react';
|
|
3
|
+
import { Progress, CodeSnippet } from '@backstage/core-components';
|
|
4
|
+
import { useTheme } from '@material-ui/core/styles';
|
|
5
|
+
|
|
6
|
+
const rootRoute = createRouteRef({
|
|
7
|
+
id: "api-docs"
|
|
8
|
+
});
|
|
9
|
+
const registerComponentRouteRef = createExternalRouteRef({
|
|
10
|
+
id: "register-component",
|
|
11
|
+
optional: true
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
const apiDocsConfigRef = createApiRef({
|
|
15
|
+
id: "plugin.api-docs.config"
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
const LazyAsyncApiDefinition = React.lazy(
|
|
19
|
+
() => import('./AsyncApiDefinition-ffed9c50.esm.js').then((m) => ({
|
|
20
|
+
default: m.AsyncApiDefinition
|
|
21
|
+
}))
|
|
22
|
+
);
|
|
23
|
+
const AsyncApiDefinitionWidget = (props) => {
|
|
24
|
+
return /* @__PURE__ */ React.createElement(Suspense, { fallback: /* @__PURE__ */ React.createElement(Progress, null) }, /* @__PURE__ */ React.createElement(LazyAsyncApiDefinition, { ...props }));
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
const LazyGraphQlDefinition = React.lazy(
|
|
28
|
+
() => import('./GraphQlDefinition-49cc2c3b.esm.js').then((m) => ({
|
|
29
|
+
default: m.GraphQlDefinition
|
|
30
|
+
}))
|
|
31
|
+
);
|
|
32
|
+
const GraphQlDefinitionWidget = (props) => {
|
|
33
|
+
return /* @__PURE__ */ React.createElement(Suspense, { fallback: /* @__PURE__ */ React.createElement(Progress, null) }, /* @__PURE__ */ React.createElement(LazyGraphQlDefinition, { ...props }));
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
const LazyOpenApiDefinition = React.lazy(
|
|
37
|
+
() => import('./OpenApiDefinition-20ae2e8c.esm.js').then((m) => ({
|
|
38
|
+
default: m.OpenApiDefinition
|
|
39
|
+
}))
|
|
40
|
+
);
|
|
41
|
+
const OpenApiDefinitionWidget = (props) => {
|
|
42
|
+
var _a;
|
|
43
|
+
const validSubmitMethods = (_a = props.supportedSubmitMethods) == null ? void 0 : _a.map(
|
|
44
|
+
(method) => method.toLocaleLowerCase()
|
|
45
|
+
);
|
|
46
|
+
return /* @__PURE__ */ React.createElement(Suspense, { fallback: /* @__PURE__ */ React.createElement(Progress, null) }, /* @__PURE__ */ React.createElement(
|
|
47
|
+
LazyOpenApiDefinition,
|
|
48
|
+
{
|
|
49
|
+
...props,
|
|
50
|
+
supportedSubmitMethods: validSubmitMethods
|
|
51
|
+
}
|
|
52
|
+
));
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
const GrpcApiDefinitionWidget = (props) => {
|
|
56
|
+
const theme = useTheme();
|
|
57
|
+
return /* @__PURE__ */ React.createElement(
|
|
58
|
+
CodeSnippet,
|
|
59
|
+
{
|
|
60
|
+
customStyle: { backgroundColor: theme.palette.background.default },
|
|
61
|
+
text: props.definition,
|
|
62
|
+
language: "protobuf",
|
|
63
|
+
showCopyCodeButton: true
|
|
64
|
+
}
|
|
65
|
+
);
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
const TrpcApiDefinitionWidget = (props) => {
|
|
69
|
+
const { definition } = props;
|
|
70
|
+
const theme = useTheme();
|
|
71
|
+
return /* @__PURE__ */ React.createElement(
|
|
72
|
+
CodeSnippet,
|
|
73
|
+
{
|
|
74
|
+
customStyle: { backgroundColor: theme.palette.background.default },
|
|
75
|
+
text: definition,
|
|
76
|
+
language: "typescript",
|
|
77
|
+
showCopyCodeButton: true
|
|
78
|
+
}
|
|
79
|
+
);
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
function defaultDefinitionWidgets() {
|
|
83
|
+
return [
|
|
84
|
+
{
|
|
85
|
+
type: "openapi",
|
|
86
|
+
title: "OpenAPI",
|
|
87
|
+
rawLanguage: "yaml",
|
|
88
|
+
component: (definition) => /* @__PURE__ */ React.createElement(OpenApiDefinitionWidget, { definition })
|
|
89
|
+
},
|
|
90
|
+
{
|
|
91
|
+
type: "asyncapi",
|
|
92
|
+
title: "AsyncAPI",
|
|
93
|
+
rawLanguage: "yaml",
|
|
94
|
+
component: (definition) => /* @__PURE__ */ React.createElement(AsyncApiDefinitionWidget, { definition })
|
|
95
|
+
},
|
|
96
|
+
{
|
|
97
|
+
type: "graphql",
|
|
98
|
+
title: "GraphQL",
|
|
99
|
+
rawLanguage: "graphql",
|
|
100
|
+
component: (definition) => /* @__PURE__ */ React.createElement(GraphQlDefinitionWidget, { definition })
|
|
101
|
+
},
|
|
102
|
+
{
|
|
103
|
+
type: "grpc",
|
|
104
|
+
title: "gRPC",
|
|
105
|
+
component: (definition) => /* @__PURE__ */ React.createElement(GrpcApiDefinitionWidget, { definition })
|
|
106
|
+
},
|
|
107
|
+
{
|
|
108
|
+
type: "trpc",
|
|
109
|
+
title: "tRPC",
|
|
110
|
+
component: (definition) => /* @__PURE__ */ React.createElement(TrpcApiDefinitionWidget, { definition })
|
|
111
|
+
}
|
|
112
|
+
];
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
export { AsyncApiDefinitionWidget as A, GraphQlDefinitionWidget as G, OpenApiDefinitionWidget as O, TrpcApiDefinitionWidget as T, apiDocsConfigRef as a, registerComponentRouteRef as b, defaultDefinitionWidgets as d, rootRoute as r };
|
|
116
|
+
//# sourceMappingURL=ApiDefinitionWidget-798ee85f.esm.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ApiDefinitionWidget-798ee85f.esm.js","sources":["../../src/routes.ts","../../src/config.ts","../../src/components/AsyncApiDefinitionWidget/AsyncApiDefinitionWidget.tsx","../../src/components/GraphQlDefinitionWidget/GraphQlDefinitionWidget.tsx","../../src/components/OpenApiDefinitionWidget/OpenApiDefinitionWidget.tsx","../../src/components/GrpcApiDefinitionWidget/GrpcApiDefinitionWidget.tsx","../../src/components/TrpcDefinitionWidget/TrpcApiDefinitionWidget.tsx","../../src/components/ApiDefinitionCard/ApiDefinitionWidget.tsx"],"sourcesContent":["/*\n * Copyright 2020 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {\n createExternalRouteRef,\n createRouteRef,\n} from '@backstage/core-plugin-api';\n\nexport const rootRoute = createRouteRef({\n id: 'api-docs',\n});\n\nexport const registerComponentRouteRef = createExternalRouteRef({\n id: 'register-component',\n optional: true,\n});\n","/*\n * Copyright 2020 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { ApiEntity } from '@backstage/catalog-model';\nimport { ApiDefinitionWidget } from './components/ApiDefinitionCard/ApiDefinitionWidget';\nimport { createApiRef } from '@backstage/core-plugin-api';\n\n/** @public */\nexport const apiDocsConfigRef = createApiRef<ApiDocsConfig>({\n id: 'plugin.api-docs.config',\n});\n\n/** @public */\nexport interface ApiDocsConfig {\n getApiDefinitionWidget: (\n apiEntity: ApiEntity,\n ) => ApiDefinitionWidget | undefined;\n}\n","/*\n * Copyright 2020 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { Progress } from '@backstage/core-components';\nimport React, { Suspense } from 'react';\n\n// The asyncapi component and related CSS has a significant size, only load it\n// if the element is actually used.\nconst LazyAsyncApiDefinition = React.lazy(() =>\n import('./AsyncApiDefinition').then(m => ({\n default: m.AsyncApiDefinition,\n })),\n);\n\n/** @public */\nexport type AsyncApiDefinitionWidgetProps = {\n definition: string;\n};\n\n/** @public */\nexport const AsyncApiDefinitionWidget = (\n props: AsyncApiDefinitionWidgetProps,\n) => {\n return (\n <Suspense fallback={<Progress />}>\n <LazyAsyncApiDefinition {...props} />\n </Suspense>\n );\n};\n","/*\n * Copyright 2020 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { Progress } from '@backstage/core-components';\nimport React, { Suspense } from 'react';\n\n// The graphql component, graphql and related CSS has a significant size, only\n// load it if the element is actually used.\nconst LazyGraphQlDefinition = React.lazy(() =>\n import('./GraphQlDefinition').then(m => ({\n default: m.GraphQlDefinition,\n })),\n);\n\n/** @public */\nexport type GraphQlDefinitionWidgetProps = {\n definition: string;\n};\n\n/** @public */\nexport const GraphQlDefinitionWidget = (\n props: GraphQlDefinitionWidgetProps,\n) => {\n return (\n <Suspense fallback={<Progress />}>\n <LazyGraphQlDefinition {...props} />\n </Suspense>\n );\n};\n","/*\n * Copyright 2020 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { Progress } from '@backstage/core-components';\nimport React, { Suspense } from 'react';\n\n// The swagger-ui component and related CSS has a significant size, only load it\n// if the element is actually used.\nconst LazyOpenApiDefinition = React.lazy(() =>\n import('./OpenApiDefinition').then(m => ({\n default: m.OpenApiDefinition,\n })),\n);\n\n/** @public */\nexport type OpenApiDefinitionWidgetProps = {\n definition: string;\n requestInterceptor?: (req: any) => any | Promise<any>;\n supportedSubmitMethods?: string[];\n};\n\n/** @public */\nexport const OpenApiDefinitionWidget = (\n props: OpenApiDefinitionWidgetProps,\n) => {\n const validSubmitMethods = props.supportedSubmitMethods?.map(method =>\n method.toLocaleLowerCase(),\n );\n return (\n <Suspense fallback={<Progress />}>\n <LazyOpenApiDefinition\n {...props}\n supportedSubmitMethods={validSubmitMethods}\n />\n </Suspense>\n );\n};\n","/*\n * Copyright 2020 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport React from 'react';\nimport { CodeSnippet } from '@backstage/core-components';\nimport { useTheme } from '@material-ui/core/styles';\n\n/** @public */\nexport type GrpcApiDefinitionWidgetProps = {\n definition: string;\n};\n\n/** @public */\nexport const GrpcApiDefinitionWidget = (\n props: GrpcApiDefinitionWidgetProps,\n) => {\n const theme = useTheme();\n return (\n <CodeSnippet\n customStyle={{ backgroundColor: theme.palette.background.default }}\n text={props.definition}\n language=\"protobuf\"\n showCopyCodeButton\n />\n );\n};\n","/*\n * Copyright 2023 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport React from 'react';\nimport { CodeSnippet } from '@backstage/core-components';\nimport { useTheme } from '@material-ui/core/styles';\n\n/** @public */\nexport type TrpcApiDefinitionWidgetProps = {\n definition: string;\n};\n\n/** @public */\nexport const TrpcApiDefinitionWidget = (\n props: TrpcApiDefinitionWidgetProps,\n) => {\n const { definition } = props;\n const theme = useTheme();\n return (\n <CodeSnippet\n customStyle={{ backgroundColor: theme.palette.background.default }}\n text={definition}\n language=\"typescript\"\n showCopyCodeButton\n />\n );\n};\n","/*\n * Copyright 2020 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport React from 'react';\nimport { AsyncApiDefinitionWidget } from '../AsyncApiDefinitionWidget';\nimport { GraphQlDefinitionWidget } from '../GraphQlDefinitionWidget';\nimport { OpenApiDefinitionWidget } from '../OpenApiDefinitionWidget';\nimport { GrpcApiDefinitionWidget } from '../GrpcApiDefinitionWidget';\nimport { TrpcApiDefinitionWidget } from '../TrpcDefinitionWidget';\n\n/** @public */\nexport type ApiDefinitionWidget = {\n type: string;\n title: string;\n component: (definition: string) => React.ReactElement;\n rawLanguage?: string;\n};\n\n/** @public */\nexport function defaultDefinitionWidgets(): ApiDefinitionWidget[] {\n return [\n {\n type: 'openapi',\n title: 'OpenAPI',\n rawLanguage: 'yaml',\n component: definition => (\n <OpenApiDefinitionWidget definition={definition} />\n ),\n },\n {\n type: 'asyncapi',\n title: 'AsyncAPI',\n rawLanguage: 'yaml',\n component: definition => (\n <AsyncApiDefinitionWidget definition={definition} />\n ),\n },\n {\n type: 'graphql',\n title: 'GraphQL',\n rawLanguage: 'graphql',\n component: definition => (\n <GraphQlDefinitionWidget definition={definition} />\n ),\n },\n {\n type: 'grpc',\n title: 'gRPC',\n component: definition => (\n <GrpcApiDefinitionWidget definition={definition} />\n ),\n },\n {\n type: 'trpc',\n title: 'tRPC',\n component: definition => (\n <TrpcApiDefinitionWidget definition={definition} />\n ),\n },\n ];\n}\n"],"names":[],"mappings":";;;;;AAqBO,MAAM,YAAY,cAAe,CAAA;AAAA,EACtC,EAAI,EAAA,UAAA;AACN,CAAC,EAAA;AAEM,MAAM,4BAA4B,sBAAuB,CAAA;AAAA,EAC9D,EAAI,EAAA,oBAAA;AAAA,EACJ,QAAU,EAAA,IAAA;AACZ,CAAC;;ACPM,MAAM,mBAAmB,YAA4B,CAAA;AAAA,EAC1D,EAAI,EAAA,wBAAA;AACN,CAAC;;ACFD,MAAM,yBAAyB,KAAM,CAAA,IAAA;AAAA,EAAK,MACxC,OAAO,sCAAsB,CAAA,CAAE,KAAK,CAAM,CAAA,MAAA;AAAA,IACxC,SAAS,CAAE,CAAA,kBAAA;AAAA,GACX,CAAA,CAAA;AACJ,CAAA,CAAA;AAQa,MAAA,wBAAA,GAA2B,CACtC,KACG,KAAA;AACH,EACE,uBAAA,KAAA,CAAA,aAAA,CAAC,QAAS,EAAA,EAAA,QAAA,kBAAW,KAAA,CAAA,aAAA,CAAA,QAAA,E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AAA,CAAA,aAAA,CAAA,wBAAA,EAAA,EAAyB,UAAwB,EAAA,CAAA;AAAA,KAEtD;AAAA,IACA;AAAA,MACE,IAAM,EAAA,SAAA;AAAA,MACN,KAAO,EAAA,SAAA;AAAA,MACP,WAAa,EAAA,SAAA;AAAA,MACb,SAAW,EAAA,CAAA,UAAA,qBACR,KAAA,CAAA,aAAA,CAAA,uBAAA,EAAA,EAAwB,UAAwB,EAAA,CAAA;AAAA,KAErD;AAAA,IACA;AAAA,MACE,IAAM,EAAA,MAAA;AAAA,MACN,KAAO,EAAA,MAAA;AAAA,MACP,SAAW,EAAA,CAAA,UAAA,qBACR,KAAA,CAAA,aAAA,CAAA,uBAAA,EAAA,EAAwB,UAAwB,EAAA,CAAA;AAAA,KAErD;AAAA,IACA;AAAA,MACE,IAAM,EAAA,MAAA;AAAA,MACN,KAAO,EAAA,MAAA;AAAA,MACP,SAAW,EAAA,CAAA,UAAA,qBACR,KAAA,CAAA,aAAA,CAAA,uBAAA,EAAA,EAAwB,UAAwB,EAAA,CAAA;AAAA,KAErD;AAAA,GACF,CAAA;AACF;;;;"}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { useOutlet } from 'react-router-dom';
|
|
3
|
+
import { PageWithHeader, Content, ContentHeader, CreateButton, SupportButton } from '@backstage/core-components';
|
|
4
|
+
import { useApi, configApiRef, useRouteRef } from '@backstage/core-plugin-api';
|
|
5
|
+
import { CatalogTable } from '@backstage/plugin-catalog';
|
|
6
|
+
import { EntityListProvider, CatalogFilterLayout, EntityKindPicker, EntityTypePicker, UserListPicker, EntityOwnerPicker, EntityLifecyclePicker, EntityTagPicker } from '@backstage/plugin-catalog-react';
|
|
7
|
+
import { b as registerComponentRouteRef } from './ApiDefinitionWidget-798ee85f.esm.js';
|
|
8
|
+
import { usePermission } from '@backstage/plugin-permission-react';
|
|
9
|
+
import { catalogEntityCreatePermission } from '@backstage/plugin-catalog-common/alpha';
|
|
10
|
+
|
|
11
|
+
const defaultColumns = [
|
|
12
|
+
CatalogTable.columns.createTitleColumn({ hidden: true }),
|
|
13
|
+
CatalogTable.columns.createNameColumn({ defaultKind: "API" }),
|
|
14
|
+
CatalogTable.columns.createSystemColumn(),
|
|
15
|
+
CatalogTable.columns.createOwnerColumn(),
|
|
16
|
+
CatalogTable.columns.createSpecTypeColumn(),
|
|
17
|
+
CatalogTable.columns.createSpecLifecycleColumn(),
|
|
18
|
+
CatalogTable.columns.createMetadataDescriptionColumn(),
|
|
19
|
+
CatalogTable.columns.createTagsColumn()
|
|
20
|
+
];
|
|
21
|
+
const DefaultApiExplorerPage = (props) => {
|
|
22
|
+
var _a;
|
|
23
|
+
const { initiallySelectedFilter = "all", columns, actions } = props;
|
|
24
|
+
const configApi = useApi(configApiRef);
|
|
25
|
+
const generatedSubtitle = `${(_a = configApi.getOptionalString("organization.name")) != null ? _a : "Backstage"} API Explorer`;
|
|
26
|
+
const registerComponentLink = useRouteRef(registerComponentRouteRef);
|
|
27
|
+
const { allowed } = usePermission({
|
|
28
|
+
permission: catalogEntityCreatePermission
|
|
29
|
+
});
|
|
30
|
+
return /* @__PURE__ */ React.createElement(
|
|
31
|
+
PageWithHeader,
|
|
32
|
+
{
|
|
33
|
+
themeId: "apis",
|
|
34
|
+
title: "APIs",
|
|
35
|
+
subtitle: generatedSubtitle,
|
|
36
|
+
pageTitleOverride: "APIs"
|
|
37
|
+
},
|
|
38
|
+
/* @__PURE__ */ React.createElement(Content, null, /* @__PURE__ */ React.createElement(ContentHeader, { title: "" }, allowed && /* @__PURE__ */ React.createElement(
|
|
39
|
+
CreateButton,
|
|
40
|
+
{
|
|
41
|
+
title: "Register Existing API",
|
|
42
|
+
to: registerComponentLink == null ? void 0 : registerComponentLink()
|
|
43
|
+
}
|
|
44
|
+
), /* @__PURE__ */ React.createElement(SupportButton, null, "All your APIs")), /* @__PURE__ */ React.createElement(EntityListProvider, null, /* @__PURE__ */ React.createElement(CatalogFilterLayout, null, /* @__PURE__ */ React.createElement(CatalogFilterLayout.Filters, null, /* @__PURE__ */ React.createElement(EntityKindPicker, { initialFilter: "api", hidden: true }), /* @__PURE__ */ React.createElement(EntityTypePicker, null), /* @__PURE__ */ React.createElement(UserListPicker, { initialFilter: initiallySelectedFilter }), /* @__PURE__ */ React.createElement(EntityOwnerPicker, null), /* @__PURE__ */ React.createElement(EntityLifecyclePicker, null), /* @__PURE__ */ React.createElement(EntityTagPicker, null)), /* @__PURE__ */ React.createElement(CatalogFilterLayout.Content, null, /* @__PURE__ */ React.createElement(
|
|
45
|
+
CatalogTable,
|
|
46
|
+
{
|
|
47
|
+
columns: columns || defaultColumns,
|
|
48
|
+
actions
|
|
49
|
+
}
|
|
50
|
+
)))))
|
|
51
|
+
);
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
const ApiExplorerPage = (props) => {
|
|
55
|
+
const outlet = useOutlet();
|
|
56
|
+
return outlet || /* @__PURE__ */ React.createElement(DefaultApiExplorerPage, { ...props });
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
export { ApiExplorerPage as A, DefaultApiExplorerPage as D };
|
|
60
|
+
//# sourceMappingURL=ApiExplorerPage-ce544a95.esm.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ApiExplorerPage-ce544a95.esm.js","sources":["../../src/components/ApiExplorerPage/DefaultApiExplorerPage.tsx","../../src/components/ApiExplorerPage/ApiExplorerPage.tsx"],"sourcesContent":["/*\n * Copyright 2021 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {\n Content,\n ContentHeader,\n CreateButton,\n PageWithHeader,\n SupportButton,\n TableColumn,\n TableProps,\n} from '@backstage/core-components';\nimport { configApiRef, useApi, useRouteRef } from '@backstage/core-plugin-api';\nimport { CatalogTable, CatalogTableRow } from '@backstage/plugin-catalog';\nimport {\n EntityKindPicker,\n EntityLifecyclePicker,\n EntityListProvider,\n EntityOwnerPicker,\n EntityTagPicker,\n EntityTypePicker,\n UserListFilterKind,\n UserListPicker,\n CatalogFilterLayout,\n} from '@backstage/plugin-catalog-react';\nimport React from 'react';\nimport { registerComponentRouteRef } from '../../routes';\nimport { usePermission } from '@backstage/plugin-permission-react';\nimport { catalogEntityCreatePermission } from '@backstage/plugin-catalog-common/alpha';\n\nconst defaultColumns: TableColumn<CatalogTableRow>[] = [\n CatalogTable.columns.createTitleColumn({ hidden: true }),\n CatalogTable.columns.createNameColumn({ defaultKind: 'API' }),\n CatalogTable.columns.createSystemColumn(),\n CatalogTable.columns.createOwnerColumn(),\n CatalogTable.columns.createSpecTypeColumn(),\n CatalogTable.columns.createSpecLifecycleColumn(),\n CatalogTable.columns.createMetadataDescriptionColumn(),\n CatalogTable.columns.createTagsColumn(),\n];\n\n/**\n * DefaultApiExplorerPageProps\n * @public\n */\nexport type DefaultApiExplorerPageProps = {\n initiallySelectedFilter?: UserListFilterKind;\n columns?: TableColumn<CatalogTableRow>[];\n actions?: TableProps<CatalogTableRow>['actions'];\n};\n\n/**\n * DefaultApiExplorerPage\n * @public\n */\nexport const DefaultApiExplorerPage = (props: DefaultApiExplorerPageProps) => {\n const { initiallySelectedFilter = 'all', columns, actions } = props;\n\n const configApi = useApi(configApiRef);\n const generatedSubtitle = `${\n configApi.getOptionalString('organization.name') ?? 'Backstage'\n } API Explorer`;\n const registerComponentLink = useRouteRef(registerComponentRouteRef);\n const { allowed } = usePermission({\n permission: catalogEntityCreatePermission,\n });\n\n return (\n <PageWithHeader\n themeId=\"apis\"\n title=\"APIs\"\n subtitle={generatedSubtitle}\n pageTitleOverride=\"APIs\"\n >\n <Content>\n <ContentHeader title=\"\">\n {allowed && (\n <CreateButton\n title=\"Register Existing API\"\n to={registerComponentLink?.()}\n />\n )}\n <SupportButton>All your APIs</SupportButton>\n </ContentHeader>\n <EntityListProvider>\n <CatalogFilterLayout>\n <CatalogFilterLayout.Filters>\n <EntityKindPicker initialFilter=\"api\" hidden />\n <EntityTypePicker />\n <UserListPicker initialFilter={initiallySelectedFilter} />\n <EntityOwnerPicker />\n <EntityLifecyclePicker />\n <EntityTagPicker />\n </CatalogFilterLayout.Filters>\n <CatalogFilterLayout.Content>\n <CatalogTable\n columns={columns || defaultColumns}\n actions={actions}\n />\n </CatalogFilterLayout.Content>\n </CatalogFilterLayout>\n </EntityListProvider>\n </Content>\n </PageWithHeader>\n );\n};\n","/*\n * Copyright 2021 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport React from 'react';\nimport { useOutlet } from 'react-router-dom';\nimport {\n DefaultApiExplorerPage,\n DefaultApiExplorerPageProps,\n} from './DefaultApiExplorerPage';\n\n/**\n * ApiExplorerPage\n * @public\n */\nexport const ApiExplorerPage = (props: DefaultApiExplorerPageProps) => {\n const outlet = useOutlet();\n\n return outlet || <DefaultApiExplorerPage {...props} />;\n};\n"],"names":[],"mappings":";;;;;;;;;;AA2CA,MAAM,cAAiD,GAAA;AAAA,EACrD,aAAa,OAAQ,CAAA,iBAAA,CAAkB,EAAE,MAAA,EAAQ,MAAM,CAAA;AAAA,EACvD,aAAa,OAAQ,CAAA,gBAAA,CAAiB,EAAE,WAAA,EAAa,OAAO,CAAA;AAAA,EAC5D,YAAA,CAAa,QAAQ,kBAAmB,EAAA;AAAA,EAC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AAA,OAAA;AAAA,uBAGP,KAAA,CAAA,aAAA,CAAA,aAAA,EAAA,IAAA,EAAc,eAAa,CAC9B,CAAA,sCACC,kBACC,EAAA,IAAA,kBAAA,KAAA,CAAA,aAAA,CAAC,2CACE,KAAA,CAAA,aAAA,CAAA,mBAAA,CAAoB,SAApB,IACC,kBAAA,KAAA,CAAA,aAAA,CAAC,oBAAiB,aAAc,EAAA,KAAA,EAAM,QAAM,IAAC,EAAA,CAAA,kBAC5C,KAAA,CAAA,aAAA,CAAA,gBAAA,EAAA,IAAiB,mBACjB,KAAA,CAAA,aAAA,CAAA,cAAA,EAAA,EAAe,eAAe,uBAAyB,EAAA,CAAA,sCACvD,iBAAkB,EAAA,IAAA,CAAA,sCAClB,qBAAsB,EAAA,IAAA,CAAA,sCACtB,eAAgB,EAAA,IAAA,CACnB,mBACC,KAAA,CAAA,aAAA,CAAA,mBAAA,CAAoB,SAApB,IACC,kBAAA,KAAA,CAAA,aAAA;AAAA,MAAC,YAAA;AAAA,MAAA;AAAA,QACC,SAAS,OAAW,IAAA,cAAA;AAAA,QACpB,OAAA;AAAA,OAAA;AAAA,KAEJ,CACF,CACF,CACF,CAAA;AAAA,GACF,CAAA;AAEJ;;AC3Fa,MAAA,eAAA,GAAkB,CAAC,KAAuC,KAAA;AACrE,EAAA,MAAM,SAAS,SAAU,EAAA,CAAA;AAEzB,EAAA,OAAO,MAAU,oBAAA,KAAA,CAAA,aAAA,CAAC,sBAAwB,EAAA,EAAA,GAAG,KAAO,EAAA,CAAA,CAAA;AACtD;;;;"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { CodeSnippet } from '@backstage/core-components';
|
|
3
|
+
import Typography from '@material-ui/core/Typography';
|
|
4
|
+
import { a as apiDocsConfigRef } from './ApiDefinitionWidget-798ee85f.esm.js';
|
|
5
|
+
import { useApi } from '@backstage/core-plugin-api';
|
|
6
|
+
|
|
7
|
+
const PlainApiDefinitionWidget = (props) => {
|
|
8
|
+
return /* @__PURE__ */ React.createElement(
|
|
9
|
+
CodeSnippet,
|
|
10
|
+
{
|
|
11
|
+
text: props.definition,
|
|
12
|
+
language: props.language,
|
|
13
|
+
showCopyCodeButton: true
|
|
14
|
+
}
|
|
15
|
+
);
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
const ApiTypeTitle = (props) => {
|
|
19
|
+
const { apiEntity } = props;
|
|
20
|
+
const config = useApi(apiDocsConfigRef);
|
|
21
|
+
const definition = config.getApiDefinitionWidget(apiEntity);
|
|
22
|
+
const type = definition ? definition.title : apiEntity.spec.type;
|
|
23
|
+
return /* @__PURE__ */ React.createElement(Typography, { component: "span" }, type);
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
export { ApiTypeTitle as A, PlainApiDefinitionWidget as P };
|
|
27
|
+
//# sourceMappingURL=ApiTypeTitle-cc79a2f3.esm.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ApiTypeTitle-cc79a2f3.esm.js","sources":["../../src/components/PlainApiDefinitionWidget/PlainApiDefinitionWidget.tsx","../../src/components/ApiDefinitionCard/ApiTypeTitle.tsx"],"sourcesContent":["/*\n * Copyright 2020 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport React from 'react';\nimport { CodeSnippet } from '@backstage/core-components';\n\n/** @public */\nexport type PlainApiDefinitionWidgetProps = {\n definition: any;\n language: string;\n};\n\n/** @public */\nexport const PlainApiDefinitionWidget = (\n props: PlainApiDefinitionWidgetProps,\n) => {\n return (\n <CodeSnippet\n text={props.definition}\n language={props.language}\n showCopyCodeButton\n />\n );\n};\n","/*\n * Copyright 2020 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { ApiEntity } from '@backstage/catalog-model';\nimport Typography from '@material-ui/core/Typography';\nimport React from 'react';\nimport { apiDocsConfigRef } from '../../config';\nimport { useApi } from '@backstage/core-plugin-api';\n\n/**\n * @public\n */\nexport const ApiTypeTitle = (props: { apiEntity: ApiEntity }) => {\n const { apiEntity } = props;\n const config = useApi(apiDocsConfigRef);\n const definition = config.getApiDefinitionWidget(apiEntity);\n const type = definition ? definition.title : apiEntity.spec.type;\n\n return <Typography component=\"span\">{type}</Typography>;\n};\n"],"names":[],"mappings":";;;;;;AA0Ba,MAAA,wBAAA,GAA2B,CACtC,KACG,KAAA;AACH,EACE,uBAAA,KAAA,CAAA,aAAA;AAAA,IAAC,WAAA;AAAA,IAAA;AAAA,MACC,MAAM,KAAM,CAAA,UAAA;AAAA,MACZ,UAAU,KAAM,CAAA,QAAA;AAAA,MAChB,kBAAkB,EAAA,IAAA;AAAA,KAAA;AAAA,GACpB,CAAA;AAEJ;;ACXa,MAAA,YAAA,GAAe,CAAC,KAAoC,KAAA;AAC/D,EAAM,MAAA,EAAE,WAAc,GAAA,KAAA,CAAA;AACtB,EAAM,MAAA,MAAA,GAAS,OAAO,gBAAgB,CAAA,CAAA;AACtC,EAAM,MAAA,UAAA,GAAa,MAAO,CAAA,sBAAA,CAAuB,SAAS,CAAA,CAAA;AAC1D,EAAA,MAAM,IAAO,GAAA,UAAA,GAAa,UAAW,CAAA,KAAA,GAAQ,UAAU,IAAK,CAAA,IAAA,CAAA;AAE5D,EAAA,uBAAQ,KAAA,CAAA,aAAA,CAAA,UAAA,EAAA,EAAW,SAAU,EAAA,MAAA,EAAA,EAAQ,IAAK,CAAA,CAAA;AAC5C;;;;"}
|