@visulima/api-platform 1.0.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.
- package/CHANGELOG.md +15 -0
- package/LICENSE.md +21 -0
- package/README.md +137 -0
- package/dist/chunk-2LATTLUM.mjs +166 -0
- package/dist/chunk-2LATTLUM.mjs.map +1 -0
- package/dist/chunk-4DRV4PCJ.js +51 -0
- package/dist/chunk-4DRV4PCJ.js.map +1 -0
- package/dist/chunk-5VRACIDE.mjs +10 -0
- package/dist/chunk-5VRACIDE.mjs.map +1 -0
- package/dist/chunk-GSWANBU5.mjs +51 -0
- package/dist/chunk-GSWANBU5.mjs.map +1 -0
- package/dist/chunk-J4EBGCNK.mjs +99 -0
- package/dist/chunk-J4EBGCNK.mjs.map +1 -0
- package/dist/chunk-JC4IRQUL.js +10 -0
- package/dist/chunk-JC4IRQUL.js.map +1 -0
- package/dist/chunk-S7GUPAL4.js +166 -0
- package/dist/chunk-S7GUPAL4.js.map +1 -0
- package/dist/chunk-T25VSNTF.js +99 -0
- package/dist/chunk-T25VSNTF.js.map +1 -0
- package/dist/index-3318b0da.d.ts +33 -0
- package/dist/index-browser.d.ts +2 -0
- package/dist/index-browser.js +8 -0
- package/dist/index-browser.js.map +1 -0
- package/dist/index-browser.mjs +8 -0
- package/dist/index-browser.mjs.map +1 -0
- package/dist/index-server.d.ts +87 -0
- package/dist/index-server.js +454 -0
- package/dist/index-server.js.map +1 -0
- package/dist/index-server.mjs +454 -0
- package/dist/index-server.mjs.map +1 -0
- package/dist/next/cli/index.d.ts +11 -0
- package/dist/next/cli/index.js +203 -0
- package/dist/next/cli/index.js.map +1 -0
- package/dist/next/cli/index.mjs +203 -0
- package/dist/next/cli/index.mjs.map +1 -0
- package/dist/next/index-browser.d.ts +4 -0
- package/dist/next/index-browser.js +12 -0
- package/dist/next/index-browser.js.map +1 -0
- package/dist/next/index-browser.mjs +12 -0
- package/dist/next/index-browser.mjs.map +1 -0
- package/dist/next/index-server.d.ts +129 -0
- package/dist/next/index-server.js +76 -0
- package/dist/next/index-server.js.map +1 -0
- package/dist/next/index-server.mjs +76 -0
- package/dist/next/index-server.mjs.map +1 -0
- package/dist/swagger-6ad3b021.d.ts +11 -0
- package/next/cli/package.json +9 -0
- package/next/package.json +10 -0
- package/package.json +207 -0
- package/src/connect/create-node-router.ts +44 -0
- package/src/connect/handler.ts +46 -0
- package/src/connect/middleware/cors-middleware.ts +10 -0
- package/src/connect/middleware/http-header-normalizer.ts +93 -0
- package/src/connect/middleware/rate-limiter-middleware.ts +43 -0
- package/src/connect/middleware/serializers-middleware.ts +121 -0
- package/src/connect/serializers/types.d.ts +1 -0
- package/src/connect/serializers/xml.ts +13 -0
- package/src/connect/serializers/yaml.ts +7 -0
- package/src/error-handler/jsonapi-error-handler.ts +46 -0
- package/src/error-handler/problem-error-handler.ts +44 -0
- package/src/error-handler/types.d.ts +14 -0
- package/src/error-handler/utils.ts +39 -0
- package/src/index-browser.tsx +1 -0
- package/src/index-server.ts +75 -0
- package/src/next/cli/index.ts +2 -0
- package/src/next/cli/list/api-route-file-parser.ts +74 -0
- package/src/next/cli/list/collect-api-route-files.ts +42 -0
- package/src/next/cli/list/list-command.ts +105 -0
- package/src/next/cli/list/routes-render.ts +62 -0
- package/src/next/cli/list/types.d.ts +1 -0
- package/src/next/index-browser.tsx +3 -0
- package/src/next/index-server.ts +6 -0
- package/src/next/routes/api/swagger.ts +23 -0
- package/src/next/routes/pages/swagger/get-static-properties-swagger.ts +32 -0
- package/src/next/routes/pages/swagger/redoc.tsx +35 -0
- package/src/next/routes/pages/swagger/swagger.tsx +39 -0
- package/src/next/webpack/with-open-api.ts +63 -0
- package/src/swagger/extend-swagger-spec.ts +167 -0
- package/src/swagger/swagger-handler.ts +83 -0
- package/src/utils.ts +37 -0
- package/src/zod/date-in-schema.ts +57 -0
- package/src/zod/date-out-schema.ts +41 -0
- package/src/zod/index.ts +9 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
## @visulima/api-platform 1.0.0 (2022-11-15)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Features
|
|
5
|
+
|
|
6
|
+
* added new packages for faster api creation ([#14](https://github.com/visulima/visulima/issues/14)) ([eb64fcf](https://github.com/visulima/visulima/commit/eb64fcf33f2a75ea48262ad6e71f80e159a93972))
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
### Dependencies
|
|
11
|
+
|
|
12
|
+
* **@visulima/connect:** upgraded to 1.2.0
|
|
13
|
+
* **@visulima/jsdoc-open-api:** upgraded to 1.2.0
|
|
14
|
+
* **@visulima/crud:** upgraded to 1.0.0
|
|
15
|
+
* **@visulima/readdir:** upgraded to 1.3.0
|
package/LICENSE.md
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2022 visulima
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
<div align="center">
|
|
2
|
+
<h3>Visulima Api platform</h3>
|
|
3
|
+
<p>
|
|
4
|
+
Visulima api platform is built on top of
|
|
5
|
+
|
|
6
|
+
[OpenAPI (Swagger) specification](https://swagger.io/specification/),
|
|
7
|
+
[node-rate-limiter-flexible](https://github.com/animir/node-rate-limiter-flexible),
|
|
8
|
+
[@visulima/connect](https://github.com/visulima/visulima/tree/main/packages/connect)
|
|
9
|
+
|
|
10
|
+
With a more intuitive API for creating HTTP API endpoints.
|
|
11
|
+
|
|
12
|
+
</p>
|
|
13
|
+
</div>
|
|
14
|
+
|
|
15
|
+
<br />
|
|
16
|
+
|
|
17
|
+
<div align="center">
|
|
18
|
+
|
|
19
|
+
[![typescript-image]][typescript-url] [![npm-image]][npm-url] [![license-image]][license-url]
|
|
20
|
+
|
|
21
|
+
</div>
|
|
22
|
+
|
|
23
|
+
---
|
|
24
|
+
|
|
25
|
+
<div align="center">
|
|
26
|
+
<p>
|
|
27
|
+
<sup>
|
|
28
|
+
Daniel Bannert's open source work is supported by the community on <a href="https://github.com/sponsors/prisis">GitHub Sponsors</a>
|
|
29
|
+
</sup>
|
|
30
|
+
</p>
|
|
31
|
+
</div>
|
|
32
|
+
|
|
33
|
+
---
|
|
34
|
+
|
|
35
|
+
## Features
|
|
36
|
+
|
|
37
|
+
## Installation
|
|
38
|
+
|
|
39
|
+
### Npm
|
|
40
|
+
```sh
|
|
41
|
+
npm install @visulima/api-platform zod
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
#### Installation for Next.js
|
|
45
|
+
|
|
46
|
+
```sh
|
|
47
|
+
npm install @visulima/api-platform zod @visulima/readdir chalk commander
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
### Yarn
|
|
51
|
+
|
|
52
|
+
```sh
|
|
53
|
+
yarn add @visulima/api-platform zod
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
#### Installation for Next.js
|
|
57
|
+
|
|
58
|
+
```sh
|
|
59
|
+
yarn add @visulima/api-platform zod @visulima/readdir chalk commander
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
### Pnpm
|
|
63
|
+
|
|
64
|
+
```sh
|
|
65
|
+
pnpm add @visulima/api-platform zod
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
#### Installation for Next.js
|
|
69
|
+
|
|
70
|
+
```sh
|
|
71
|
+
pnpm add @visulima/api-platform zod @visulima/readdir chalk commander
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
### To use the swagger-ui or the redoc-ui you need to install the following packages:
|
|
75
|
+
|
|
76
|
+
```sh
|
|
77
|
+
npm install swagger-ui-react
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
Or
|
|
81
|
+
|
|
82
|
+
```sh
|
|
83
|
+
npm install redoc
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
## Usage
|
|
88
|
+
|
|
89
|
+
This package has an extended version of the `@visulima/connect` package.
|
|
90
|
+
That means you can use all the features of the `@visulima/connect` package, in addition to the features of this package.
|
|
91
|
+
|
|
92
|
+
```ts
|
|
93
|
+
// pages/api/hello.js
|
|
94
|
+
import type { NextApiRequest, NextApiResponse } from "next";
|
|
95
|
+
import { createNodeRouter } from "@visulima/api-platform";
|
|
96
|
+
import cors from "cors";
|
|
97
|
+
|
|
98
|
+
// Default Req and Res are IncomingMessage and ServerResponse
|
|
99
|
+
// You may want to pass in NextApiRequest and NextApiResponse
|
|
100
|
+
const router = createNodeRouter<NextApiRequest, NextApiResponse>();
|
|
101
|
+
|
|
102
|
+
router
|
|
103
|
+
.get((req, res) => {
|
|
104
|
+
res.send("Hello world");
|
|
105
|
+
});
|
|
106
|
+
|
|
107
|
+
export default router.nodeHandler();
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
## Supported Node.js Versions
|
|
111
|
+
|
|
112
|
+
Libraries in this ecosystem make the best effort to track
|
|
113
|
+
[Node.js’ release schedule](https://github.com/nodejs/release#release-schedule). Here’s [a
|
|
114
|
+
post on why we think this is important](https://medium.com/the-node-js-collection/maintainers-should-consider-following-node-js-release-schedule-ab08ed4de71a).
|
|
115
|
+
|
|
116
|
+
## Contributing
|
|
117
|
+
|
|
118
|
+
If you would like to help take a look at the [list of issues](https://github.com/visulima/visulima/issues) and check our [Contributing](.github/CONTRIBUTING.md) guild.
|
|
119
|
+
|
|
120
|
+
> **Note:** please note that this project is released with a Contributor Code of Conduct. By participating in this project you agree to abide by its terms.
|
|
121
|
+
|
|
122
|
+
## Credits
|
|
123
|
+
|
|
124
|
+
- [Daniel Bannert](https://github.com/prisis)
|
|
125
|
+
- [All Contributors](https://github.com/visulima/visulima/graphs/contributors)
|
|
126
|
+
|
|
127
|
+
## License
|
|
128
|
+
|
|
129
|
+
The visulima api-platform is open-sourced software licensed under the [MIT][license-url]
|
|
130
|
+
|
|
131
|
+
[typescript-image]: https://img.shields.io/badge/Typescript-294E80.svg?style=for-the-badge&logo=typescript
|
|
132
|
+
[typescript-url]: "typescript"
|
|
133
|
+
[license-image]: https://img.shields.io/npm/l/@visulima/api-platform?color=blueviolet&style=for-the-badge
|
|
134
|
+
[license-url]: LICENSE.md "license"
|
|
135
|
+
[npm-image]: https://img.shields.io/npm/v/@visulima/api-platform/alpha.svg?style=for-the-badge&logo=npm
|
|
136
|
+
[npm-url]: https://www.npmjs.com/package/@visulima/api-platform/v/alpha "npm"
|
|
137
|
+
|
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
// src/swagger/swagger-handler.ts
|
|
2
|
+
import { modelsToOpenApi } from "@visulima/crud";
|
|
3
|
+
import debug from "debug";
|
|
4
|
+
import merge from "lodash.merge";
|
|
5
|
+
import { existsSync, readFileSync } from "fs";
|
|
6
|
+
import path from "path";
|
|
7
|
+
|
|
8
|
+
// src/connect/serializers/yaml.ts
|
|
9
|
+
import { stringify } from "yaml";
|
|
10
|
+
var yamlTransformer = (data) => stringify(data, { indent: 2 });
|
|
11
|
+
var yaml_default = yamlTransformer;
|
|
12
|
+
|
|
13
|
+
// src/swagger/extend-swagger-spec.ts
|
|
14
|
+
import { header as headerCase } from "case";
|
|
15
|
+
var extendComponentSchemas = (spec, schemaName, schema) => {
|
|
16
|
+
if (typeof spec.components !== "object") {
|
|
17
|
+
spec.components = {};
|
|
18
|
+
}
|
|
19
|
+
if (typeof spec.components.schemas !== "object") {
|
|
20
|
+
spec.components.schemas = {};
|
|
21
|
+
}
|
|
22
|
+
if (typeof spec.components.schemas[schemaName] === "undefined") {
|
|
23
|
+
spec.components.schemas[schemaName] = schema;
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
var extendComponentExamples = (spec, exampleName, example) => {
|
|
27
|
+
if (typeof spec.components !== "object") {
|
|
28
|
+
spec.components = {};
|
|
29
|
+
}
|
|
30
|
+
if (typeof spec.components.examples !== "object") {
|
|
31
|
+
spec.components.examples = {};
|
|
32
|
+
}
|
|
33
|
+
if (typeof spec.components.examples[exampleName] === "undefined") {
|
|
34
|
+
spec.components.examples[exampleName] = example;
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
function extendSwaggerWithMediaTypeSchema(responseSpec, allowedMediaTypes, pathKey, spec, methodSpec, status) {
|
|
38
|
+
let examples;
|
|
39
|
+
Object.entries(responseSpec.content).forEach(([mediaName, contentSpec]) => {
|
|
40
|
+
if (typeof contentSpec.schema === "object") {
|
|
41
|
+
const { schema } = contentSpec;
|
|
42
|
+
if (mediaName === "application/json" && typeof contentSpec.examples !== "undefined") {
|
|
43
|
+
examples = contentSpec.examples;
|
|
44
|
+
}
|
|
45
|
+
if (typeof schema.$ref !== "undefined") {
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
const schemaIsArray = schema.type === "array";
|
|
49
|
+
Object.entries(allowedMediaTypes || {}).forEach(([mediaType, allowed]) => {
|
|
50
|
+
var _a, _b, _c;
|
|
51
|
+
if (!allowed) {
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
const schemaName = `${headerCase(pathKey.trim().replace("/", ""))}${mediaType === "application/ld+json" ? ".jsonld" : ""}`;
|
|
55
|
+
extendComponentSchemas(spec, schemaName, schema);
|
|
56
|
+
if (typeof ((_c = (_b = (_a = methodSpec == null ? void 0 : methodSpec.responses) == null ? void 0 : _a[status]) == null ? void 0 : _b.content[mediaType]) == null ? void 0 : _c.schema) === "undefined") {
|
|
57
|
+
methodSpec.responses[status].content[mediaType] = { schema: {} };
|
|
58
|
+
}
|
|
59
|
+
methodSpec.responses[status].content[mediaType].schema = schemaIsArray ? {
|
|
60
|
+
type: "array",
|
|
61
|
+
items: {
|
|
62
|
+
$ref: `#/components/schemas/${schemaName}`
|
|
63
|
+
}
|
|
64
|
+
} : {
|
|
65
|
+
$ref: `#/components/schemas/${schemaName}`
|
|
66
|
+
};
|
|
67
|
+
if (typeof methodSpec.produces === "undefined") {
|
|
68
|
+
methodSpec.produces = [];
|
|
69
|
+
}
|
|
70
|
+
methodSpec.produces.push(mediaType);
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
});
|
|
74
|
+
return examples;
|
|
75
|
+
}
|
|
76
|
+
function extendSwaggerWithMediaTypeExamples(responseSpec, allowedMediaTypes, pathKey, spec, examples, methodSpec, status) {
|
|
77
|
+
Object.keys(responseSpec.content).forEach((mediaName) => {
|
|
78
|
+
if (mediaName === "application/json") {
|
|
79
|
+
return;
|
|
80
|
+
}
|
|
81
|
+
Object.entries(allowedMediaTypes || {}).forEach(([mediaType, allowed]) => {
|
|
82
|
+
var _a, _b, _c;
|
|
83
|
+
if (!allowed) {
|
|
84
|
+
return;
|
|
85
|
+
}
|
|
86
|
+
const examplesName = `${headerCase(pathKey.trim().replace("/", ""))}${mediaType === "application/ld+json" ? ".jsonld" : ""}`;
|
|
87
|
+
extendComponentExamples(spec, examplesName, examples);
|
|
88
|
+
if (typeof ((_c = (_b = (_a = methodSpec == null ? void 0 : methodSpec.responses) == null ? void 0 : _a[status]) == null ? void 0 : _b.content[mediaType]) == null ? void 0 : _c.examples) === "undefined") {
|
|
89
|
+
methodSpec.responses[status].content[mediaType] = { examples: {} };
|
|
90
|
+
}
|
|
91
|
+
methodSpec.responses[status].content[mediaType].examples = examples;
|
|
92
|
+
});
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
function extendSwaggerSpec(spec, allowedMediaTypes) {
|
|
96
|
+
if (typeof spec === "object" && typeof spec.paths === "object") {
|
|
97
|
+
Object.entries(spec.paths).forEach(([pathKey, pathSpec]) => {
|
|
98
|
+
Object.values(pathSpec).forEach((methodSpec) => {
|
|
99
|
+
if (typeof methodSpec.responses === "object") {
|
|
100
|
+
Object.entries(methodSpec.responses).forEach(([status, responseSpec]) => {
|
|
101
|
+
if (typeof responseSpec.content === "object") {
|
|
102
|
+
let examples = extendSwaggerWithMediaTypeSchema(responseSpec, allowedMediaTypes, pathKey, spec, methodSpec, status);
|
|
103
|
+
if (typeof examples !== "undefined") {
|
|
104
|
+
extendSwaggerWithMediaTypeExamples(responseSpec, allowedMediaTypes, pathKey, spec, examples, methodSpec, status);
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
});
|
|
110
|
+
});
|
|
111
|
+
}
|
|
112
|
+
return spec;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
// src/swagger/swagger-handler.ts
|
|
116
|
+
var swaggerCrudDebug = debug("visulima:api-platform:swagger:crud:get-static-properties-swagger");
|
|
117
|
+
var swaggerHandler = (options = {}) => {
|
|
118
|
+
const {
|
|
119
|
+
allowedMediaTypes = {
|
|
120
|
+
"application/json": true
|
|
121
|
+
},
|
|
122
|
+
swaggerFilePath,
|
|
123
|
+
crud
|
|
124
|
+
} = options;
|
|
125
|
+
return async (request, response) => {
|
|
126
|
+
const swaggerPath = path.join(process.cwd(), swaggerFilePath || "swagger/swagger.json");
|
|
127
|
+
if (!existsSync(swaggerPath)) {
|
|
128
|
+
throw new Error(`Swagger file not found at ${swaggerPath}. Did you change the output path in "withOpenApi" inside the next.config.js file?`);
|
|
129
|
+
}
|
|
130
|
+
const fileContents = readFileSync(swaggerPath, "utf8");
|
|
131
|
+
let spec = extendSwaggerSpec(JSON.parse(fileContents), allowedMediaTypes);
|
|
132
|
+
let crudSwagger = {};
|
|
133
|
+
if (typeof crud !== "undefined") {
|
|
134
|
+
try {
|
|
135
|
+
const modelsOpenApi = await modelsToOpenApi(crud);
|
|
136
|
+
crudSwagger = {
|
|
137
|
+
components: { schemas: modelsOpenApi.schemas, examples: modelsOpenApi.examples },
|
|
138
|
+
tags: modelsOpenApi.tags,
|
|
139
|
+
paths: modelsOpenApi.paths
|
|
140
|
+
};
|
|
141
|
+
crudSwagger = extendSwaggerSpec(crudSwagger, allowedMediaTypes);
|
|
142
|
+
swaggerCrudDebug(JSON.stringify(crudSwagger, null, 2));
|
|
143
|
+
spec = merge(spec, crudSwagger);
|
|
144
|
+
} catch (error) {
|
|
145
|
+
console.log(error);
|
|
146
|
+
throw new Error("Please install @visulima/crud to use the crud swagger generator.");
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
if (typeof request.headers.accept === "string" && /yaml|yml/.test(request.headers.accept)) {
|
|
150
|
+
response.statusCode = 200;
|
|
151
|
+
response.setHeader("Content-Type", request.headers.accept);
|
|
152
|
+
response.end(yaml_default(spec));
|
|
153
|
+
} else {
|
|
154
|
+
response.statusCode = 200;
|
|
155
|
+
response.setHeader("Content-Type", "application/json");
|
|
156
|
+
response.end(JSON.stringify(spec, null, 2));
|
|
157
|
+
}
|
|
158
|
+
};
|
|
159
|
+
};
|
|
160
|
+
var swagger_handler_default = swaggerHandler;
|
|
161
|
+
|
|
162
|
+
export {
|
|
163
|
+
yaml_default,
|
|
164
|
+
swagger_handler_default
|
|
165
|
+
};
|
|
166
|
+
//# sourceMappingURL=chunk-2LATTLUM.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/swagger/swagger-handler.ts","../src/connect/serializers/yaml.ts","../src/swagger/extend-swagger-spec.ts"],"sourcesContent":["// eslint-disable-next-line unicorn/prevent-abbreviations,import/no-extraneous-dependencies\nimport type { ModelsToOpenApiParameters, SwaggerModelsConfig } from \"@visulima/crud\";\n// eslint-disable-next-line unicorn/prevent-abbreviations,import/no-extraneous-dependencies\nimport { modelsToOpenApi } from \"@visulima/crud\";\nimport debug from \"debug\";\nimport merge from \"lodash.merge\";\nimport { existsSync, readFileSync } from \"node:fs\";\nimport type { IncomingMessage, ServerResponse } from \"node:http\";\nimport path from \"node:path\";\nimport type { OAS3Definition, Tag } from \"swagger-jsdoc\";\n\nimport yamlTransformer from \"../connect/serializers/yaml\";\nimport extendSwaggerSpec from \"./extend-swagger-spec\";\n\n// eslint-disable-next-line testing-library/no-debugging-utils\nconst swaggerCrudDebug = debug(\"visulima:api-platform:swagger:crud:get-static-properties-swagger\");\n\nconst swaggerHandler = (\n options: Partial<{\n allowedMediaTypes: { [key: string]: boolean };\n swaggerFilePath: string;\n crud: Exclude<ModelsToOpenApiParameters, \"swagger\"> & {\n swagger?: {\n models?: SwaggerModelsConfig<string>;\n };\n };\n }> = {},\n) => {\n const {\n allowedMediaTypes = {\n \"application/json\": true,\n },\n swaggerFilePath,\n crud,\n } = options;\n\n return async <Request extends IncomingMessage, Response extends ServerResponse>(request: Request, response: Response) => {\n const swaggerPath = path.join(process.cwd(), swaggerFilePath || \"swagger/swagger.json\");\n\n if (!existsSync(swaggerPath)) {\n throw new Error(`Swagger file not found at ${swaggerPath}. Did you change the output path in \"withOpenApi\" inside the next.config.js file?`);\n }\n\n const fileContents = readFileSync(swaggerPath, \"utf8\");\n\n let spec = extendSwaggerSpec(JSON.parse(fileContents) as OAS3Definition, allowedMediaTypes) as OAS3Definition;\n let crudSwagger: Partial<OAS3Definition> = {};\n\n if (typeof crud !== \"undefined\") {\n try {\n const modelsOpenApi = await modelsToOpenApi(crud);\n\n crudSwagger = {\n components: { schemas: modelsOpenApi.schemas, examples: modelsOpenApi.examples },\n tags: modelsOpenApi.tags as Tag[],\n paths: modelsOpenApi.paths,\n };\n\n crudSwagger = extendSwaggerSpec(crudSwagger, allowedMediaTypes);\n\n swaggerCrudDebug(JSON.stringify(crudSwagger, null, 2));\n\n spec = merge(spec, crudSwagger);\n } catch (error) {\n // eslint-disable-next-line no-console\n console.log(error);\n throw new Error(\"Please install @visulima/crud to use the crud swagger generator.\");\n }\n }\n\n if (typeof request.headers.accept === \"string\" && /yaml|yml/.test(request.headers.accept)) {\n response.statusCode = 200;\n response.setHeader(\"Content-Type\", request.headers.accept);\n response.end(yamlTransformer(spec));\n } else {\n response.statusCode = 200;\n response.setHeader(\"Content-Type\", \"application/json\");\n response.end(JSON.stringify(spec, null, 2));\n }\n };\n};\n\nexport default swaggerHandler;\n","import { stringify } from \"yaml\";\n\nimport type { Serializer } from \"./types\";\n\nconst yamlTransformer: Serializer = (data) => stringify(data, { indent: 2 });\n\nexport default yamlTransformer;\n","import { header as headerCase } from \"case\";\nimport type { OpenAPIV3 } from \"openapi-types\";\nimport type { OAS3Definition, Operation, Responses } from \"swagger-jsdoc\";\n\nconst extendComponentSchemas = (spec: Partial<OAS3Definition>, schemaName: string, schema: OpenAPIV3.SchemaObject) => {\n if (typeof spec.components !== \"object\") {\n // eslint-disable-next-line no-param-reassign\n spec.components = {};\n }\n\n if (typeof spec.components.schemas !== \"object\") {\n // eslint-disable-next-line no-param-reassign\n spec.components.schemas = {};\n }\n\n if (typeof spec.components.schemas[schemaName] === \"undefined\") {\n // eslint-disable-next-line no-param-reassign\n spec.components.schemas[schemaName] = schema;\n }\n};\n\nconst extendComponentExamples = (spec: Partial<OAS3Definition>, exampleName: string, example: OpenAPIV3.SchemaObject) => {\n if (typeof spec.components !== \"object\") {\n // eslint-disable-next-line no-param-reassign\n spec.components = {};\n }\n\n if (typeof spec.components.examples !== \"object\") {\n // eslint-disable-next-line no-param-reassign\n spec.components.examples = {};\n }\n\n if (typeof spec.components.examples[exampleName] === \"undefined\") {\n // eslint-disable-next-line no-param-reassign\n spec.components.examples[exampleName] = example;\n }\n};\n\nfunction extendSwaggerWithMediaTypeSchema(\n responseSpec: OpenAPIV3.ResponseObject,\n allowedMediaTypes: { [p: string]: boolean } | undefined,\n pathKey: string,\n spec: Partial<OAS3Definition>,\n methodSpec: Operation,\n status: string,\n) {\n let examples:\n | {\n [media: string]: OpenAPIV3.ReferenceObject | OpenAPIV3.ExampleObject;\n }\n | undefined;\n\n Object.entries(responseSpec.content as object).forEach(([mediaName, contentSpec]) => {\n if (typeof contentSpec.schema === \"object\") {\n const { schema } = contentSpec;\n\n if (mediaName === \"application/json\" && typeof contentSpec.examples !== \"undefined\") {\n examples = contentSpec.examples;\n }\n\n if (typeof (schema as OpenAPIV3.ReferenceObject).$ref !== \"undefined\") {\n return;\n }\n\n const schemaIsArray = (schema as OpenAPIV3.SchemaObject).type === \"array\";\n\n Object.entries(allowedMediaTypes || {}).forEach(([mediaType, allowed]) => {\n if (!allowed) {\n return;\n }\n\n // eslint-disable-next-line max-len\n const schemaName = `${headerCase(pathKey.trim().replace(\"/\", \"\"))}${mediaType === \"application/ld+json\" ? \".jsonld\" : \"\"}`;\n\n extendComponentSchemas(spec as OAS3Definition, schemaName, schema as OpenAPIV3.SchemaObject);\n\n if (typeof methodSpec?.responses?.[status]?.content[mediaType]?.schema === \"undefined\") {\n // eslint-disable-next-line no-param-reassign\n (methodSpec.responses as Responses)[status].content[mediaType] = { schema: {} };\n }\n\n // eslint-disable-next-line no-param-reassign\n (methodSpec.responses as Responses)[status].content[mediaType].schema = schemaIsArray\n ? {\n type: \"array\",\n items: {\n $ref: `#/components/schemas/${schemaName}`,\n },\n }\n : {\n $ref: `#/components/schemas/${schemaName}`,\n };\n\n if (typeof methodSpec.produces === \"undefined\") {\n // eslint-disable-next-line no-param-reassign\n methodSpec.produces = [];\n }\n\n methodSpec.produces.push(mediaType);\n });\n }\n });\n\n return examples;\n}\n\nfunction extendSwaggerWithMediaTypeExamples(\n responseSpec: OpenAPIV3.ResponseObject,\n allowedMediaTypes: { [p: string]: boolean } | undefined,\n pathKey: string,\n spec: Partial<OAS3Definition>,\n examples: { [p: string]: OpenAPIV3.ReferenceObject | OpenAPIV3.ExampleObject } | undefined,\n methodSpec: Operation,\n status: string,\n) {\n Object.keys(responseSpec.content as object).forEach((mediaName) => {\n if (mediaName === \"application/json\") {\n return;\n }\n\n Object.entries(allowedMediaTypes || {}).forEach(([mediaType, allowed]) => {\n if (!allowed) {\n return;\n }\n\n // eslint-disable-next-line max-len\n const examplesName = `${headerCase(pathKey.trim().replace(\"/\", \"\"))}${mediaType === \"application/ld+json\" ? \".jsonld\" : \"\"}`;\n\n extendComponentExamples(spec as OAS3Definition, examplesName, examples as OpenAPIV3.SchemaObject);\n\n if (typeof methodSpec?.responses?.[status]?.content[mediaType]?.examples === \"undefined\") {\n // eslint-disable-next-line no-param-reassign\n (methodSpec.responses as Responses)[status].content[mediaType] = { examples: {} };\n }\n\n // eslint-disable-next-line no-param-reassign\n (methodSpec.responses as Responses)[status].content[mediaType].examples = examples;\n });\n });\n}\n\n// eslint-disable-next-line radar/cognitive-complexity\nexport default function extendSwaggerSpec(spec: Partial<OAS3Definition>, allowedMediaTypes?: { [key: string]: boolean }): Partial<OAS3Definition> {\n if (typeof spec === \"object\" && typeof spec.paths === \"object\") {\n Object.entries(spec.paths).forEach(([pathKey, pathSpec]) => {\n Object.values(pathSpec).forEach((methodSpec) => {\n if (typeof methodSpec.responses === \"object\") {\n Object.entries<OpenAPIV3.ResponseObject>(methodSpec.responses).forEach(([status, responseSpec]) => {\n if (typeof responseSpec.content === \"object\") {\n let examples:\n | {\n [media: string]: OpenAPIV3.ReferenceObject | OpenAPIV3.ExampleObject;\n }\n | undefined = extendSwaggerWithMediaTypeSchema(responseSpec, allowedMediaTypes, pathKey, spec, methodSpec, status);\n\n if (typeof examples !== \"undefined\") {\n extendSwaggerWithMediaTypeExamples(responseSpec, allowedMediaTypes, pathKey, spec, examples, methodSpec, status);\n }\n }\n });\n }\n });\n });\n }\n\n return spec;\n}\n"],"mappings":"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","names":[]}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }// src/next/routes/pages/swagger/redoc.tsx
|
|
2
|
+
var _head = require('next/head'); var _head2 = _interopRequireDefault(_head);
|
|
3
|
+
var _react = require('react'); var _react2 = _interopRequireDefault(_react);
|
|
4
|
+
var _redoc = require('redoc');
|
|
5
|
+
var RedocApiDocument = (name, swagger = {}) => ({ swaggerData }) => /* @__PURE__ */ _react2.default.createElement(_react2.default.Fragment, null, /* @__PURE__ */ _react2.default.createElement(_head2.default, null, /* @__PURE__ */ _react2.default.createElement("title", null, name), /* @__PURE__ */ _react2.default.createElement("style", null, `
|
|
6
|
+
body {
|
|
7
|
+
background: #fafafa !important;
|
|
8
|
+
}
|
|
9
|
+
`)), /* @__PURE__ */ _react2.default.createElement(_redoc.RedocStandalone, {
|
|
10
|
+
...swagger,
|
|
11
|
+
spec: swaggerData
|
|
12
|
+
}));
|
|
13
|
+
var redoc_default = RedocApiDocument;
|
|
14
|
+
|
|
15
|
+
// src/next/routes/pages/swagger/swagger.tsx
|
|
16
|
+
var _dynamic = require('next/dynamic'); var _dynamic2 = _interopRequireDefault(_dynamic);
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
var SwaggerUI = _dynamic2.default.call(void 0, Promise.resolve().then(() => require("swagger-ui-react")), { ssr: false });
|
|
20
|
+
var SwaggerApiDocument = (name, swagger = {}) => ({ swaggerData }) => /* @__PURE__ */ _react2.default.createElement(_react2.default.Fragment, null, /* @__PURE__ */ _react2.default.createElement(_head2.default, null, /* @__PURE__ */ _react2.default.createElement("title", null, name), /* @__PURE__ */ _react2.default.createElement("style", null, `
|
|
21
|
+
body {
|
|
22
|
+
background: #fafafa !important;
|
|
23
|
+
}
|
|
24
|
+
`)), /* @__PURE__ */ _react2.default.createElement(SwaggerUI, {
|
|
25
|
+
...swagger,
|
|
26
|
+
spec: swaggerData
|
|
27
|
+
}));
|
|
28
|
+
var swagger_default = SwaggerApiDocument;
|
|
29
|
+
|
|
30
|
+
// src/next/routes/pages/swagger/get-static-properties-swagger.ts
|
|
31
|
+
var _debug = require('debug'); var _debug2 = _interopRequireDefault(_debug);
|
|
32
|
+
var swaggerDebug = _debug2.default.call(void 0, "visulima:api-platform:swagger:get-static-properties-swagger");
|
|
33
|
+
var getStaticProps = (swaggerUrl) => async () => {
|
|
34
|
+
const response = await fetch(swaggerUrl);
|
|
35
|
+
const swaggerData = await response.json();
|
|
36
|
+
swaggerDebug(swaggerData);
|
|
37
|
+
return {
|
|
38
|
+
props: {
|
|
39
|
+
swaggerUrl,
|
|
40
|
+
swaggerData: JSON.parse(JSON.stringify(swaggerData))
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
};
|
|
44
|
+
var get_static_properties_swagger_default = getStaticProps;
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
exports.redoc_default = redoc_default; exports.swagger_default = swagger_default; exports.get_static_properties_swagger_default = get_static_properties_swagger_default;
|
|
51
|
+
//# sourceMappingURL=chunk-4DRV4PCJ.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/next/routes/pages/swagger/redoc.tsx","../src/next/routes/pages/swagger/swagger.tsx","../src/next/routes/pages/swagger/get-static-properties-swagger.ts"],"names":["Head","React"],"mappings":";AAGA,OAAO,UAAU;AACjB,OAAO,WAAW;AAIlB,SAAS,uBAAuB;AAKhC,IAAM,mBAI0D,CAAC,MAAM,UAAU,CAAC,MAAM,CAAC,EAAE,YAAY,MAC3F,0DACI,oCAAC,YACG,oCAAC,eAAO,IAAK,GACb,oCAAC,eACI;AAAA;AAAA;AAAA;AAAA,CAKL,CACJ,GAEA,oCAAC;AAAA,EAAiB,GAAG;AAAA,EAAS,MAAM;AAAA,CAAa,CACrD;AAGZ,IAAO,gBAAQ;;;ACjCf,OAAO,aAAa;AAEpB,OAAOA,WAAU;AAEjB,OAAOC,YAAW;AAKlB,IAAM,YAAY,QAIf,OAAO,qBAAqB,EAAE,KAAK,MAAM,CAAC;AAG7C,IAAM,qBAI0D,CAAC,MAAM,UAAU,CAAC,MAAM,CAAC,EAAE,YAAY,MAC3F,gBAAAA,OAAA,cAAAA,OAAA,gBACI,gBAAAA,OAAA,cAACD,OAAA,MACG,gBAAAC,OAAA,cAAC,eAAO,IAAK,GACb,gBAAAA,OAAA,cAAC,eACI;AAAA;AAAA;AAAA;AAAA,CAKL,CACJ,GAEA,gBAAAA,OAAA,cAAC;AAAA,EAAW,GAAG;AAAA,EAAS,MAAM;AAAA,CAAa,CAC/C;AAGZ,IAAO,kBAAQ;;;ACrCf,OAAO,WAAW;AAKlB,IAAM,eAAe,MAAM,6DAA6D;AAGxF,IAAM,iBAEgB,CAAC,eAAe,YAKhC;AAEF,QAAM,WAAW,MAAM,MAAM,UAAU;AACvC,QAAM,cAAc,MAAM,SAAS,KAAK;AAExC,eAAa,WAAW;AAExB,SAAO;AAAA,IACH,OAAO;AAAA,MACH;AAAA,MACA,aAAa,KAAK,MAAM,KAAK,UAAU,WAAW,CAAC;AAAA,IACvD;AAAA,EACJ;AACJ;AAEA,IAAO,wCAAQ","sourcesContent":["// eslint-disable-next-line import/no-extraneous-dependencies\nimport type { InferGetStaticPropsType, NextPage } from \"next\";\n// eslint-disable-next-line import/no-extraneous-dependencies\nimport Head from \"next/head\";\nimport React from \"react\";\n// eslint-disable-next-line import/no-extraneous-dependencies\nimport type { RedocStandaloneProps } from \"redoc\";\n// eslint-disable-next-line import/no-extraneous-dependencies\nimport { RedocStandalone } from \"redoc\";\n\nimport getStaticProps from \"./get-static-properties-swagger\";\n\n// eslint-disable-next-line max-len\nconst RedocApiDocument: (\n name: string,\n swagger?: Exclude<RedocStandaloneProps, \"spec\">,\n // eslint-disable-next-line max-len,unicorn/no-useless-undefined\n) => NextPage<InferGetStaticPropsType<typeof getStaticProps>> = (name, swagger = {}) => ({ swaggerData }: InferGetStaticPropsType<typeof getStaticProps>) => (\n <>\n <Head>\n <title>{name}</title>\n <style>\n {`\nbody {\n background: #fafafa !important;\n}\n`}\n </style>\n </Head>\n {/* eslint-disable-next-line react/jsx-props-no-spreading */}\n <RedocStandalone {...swagger} spec={swaggerData} />\n </>\n);\n\nexport default RedocApiDocument;\n","import type { InferGetStaticPropsType, NextPage } from \"next\";\nimport dynamic from \"next/dynamic\";\n// eslint-disable-next-line import/no-extraneous-dependencies\nimport Head from \"next/head\";\n// eslint-disable-next-line import/no-extraneous-dependencies\nimport React from \"react\";\nimport type { SwaggerUIProps } from \"swagger-ui-react\";\n\nimport getStaticProps from \"./get-static-properties-swagger\";\n// eslint-disable-next-line import/no-extraneous-dependencies\nconst SwaggerUI = dynamic<{\n spec: any;\n // @ts-ignore\n // eslint-disable-next-line import/no-extraneous-dependencies\n}>(import(\"swagger-ui-react\"), { ssr: false });\n\n// eslint-disable-next-line max-len\nconst SwaggerApiDocument: (\n name: string,\n swagger?: Exclude<SwaggerUIProps, \"spec\">,\n // eslint-disable-next-line max-len,unicorn/no-useless-undefined\n) => NextPage<InferGetStaticPropsType<typeof getStaticProps>> = (name, swagger = {}) => ({ swaggerData }: InferGetStaticPropsType<typeof getStaticProps>) => (\n <>\n <Head>\n <title>{name}</title>\n <style>\n {`\nbody {\n background: #fafafa !important;\n}\n`}\n </style>\n </Head>\n {/* eslint-disable-next-line react/jsx-props-no-spreading */}\n <SwaggerUI {...swagger} spec={swaggerData} />\n </>\n);\n\nexport default SwaggerApiDocument;\n","// eslint-disable-next-line unicorn/prevent-abbreviations\nimport debug from \"debug\";\nimport type { GetStaticProps } from \"next\";\nimport type { OAS3Definition } from \"swagger-jsdoc\";\n\n// eslint-disable-next-line testing-library/no-debugging-utils\nconst swaggerDebug = debug(\"visulima:api-platform:swagger:get-static-properties-swagger\");\n\n// eslint-disable-next-line unicorn/consistent-function-scoping\nconst getStaticProps: (\n swaggerUrl: string,\n) => GetStaticProps = (swaggerUrl) => async (): Promise<{\n props: {\n swaggerUrl: string;\n swaggerData: OAS3Definition;\n };\n}> => {\n // eslint-disable-next-line compat/compat\n const response = await fetch(swaggerUrl);\n const swaggerData = await response.json();\n\n swaggerDebug(swaggerData);\n\n return {\n props: {\n swaggerUrl,\n swaggerData: JSON.parse(JSON.stringify(swaggerData)),\n },\n };\n};\n\nexport default getStaticProps;\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
// src/next/routes/pages/swagger/redoc.tsx
|
|
2
|
+
import Head from "next/head";
|
|
3
|
+
import React from "react";
|
|
4
|
+
import { RedocStandalone } from "redoc";
|
|
5
|
+
var RedocApiDocument = (name, swagger = {}) => ({ swaggerData }) => /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(Head, null, /* @__PURE__ */ React.createElement("title", null, name), /* @__PURE__ */ React.createElement("style", null, `
|
|
6
|
+
body {
|
|
7
|
+
background: #fafafa !important;
|
|
8
|
+
}
|
|
9
|
+
`)), /* @__PURE__ */ React.createElement(RedocStandalone, {
|
|
10
|
+
...swagger,
|
|
11
|
+
spec: swaggerData
|
|
12
|
+
}));
|
|
13
|
+
var redoc_default = RedocApiDocument;
|
|
14
|
+
|
|
15
|
+
// src/next/routes/pages/swagger/swagger.tsx
|
|
16
|
+
import dynamic from "next/dynamic";
|
|
17
|
+
import Head2 from "next/head";
|
|
18
|
+
import React2 from "react";
|
|
19
|
+
var SwaggerUI = dynamic(import("swagger-ui-react"), { ssr: false });
|
|
20
|
+
var SwaggerApiDocument = (name, swagger = {}) => ({ swaggerData }) => /* @__PURE__ */ React2.createElement(React2.Fragment, null, /* @__PURE__ */ React2.createElement(Head2, null, /* @__PURE__ */ React2.createElement("title", null, name), /* @__PURE__ */ React2.createElement("style", null, `
|
|
21
|
+
body {
|
|
22
|
+
background: #fafafa !important;
|
|
23
|
+
}
|
|
24
|
+
`)), /* @__PURE__ */ React2.createElement(SwaggerUI, {
|
|
25
|
+
...swagger,
|
|
26
|
+
spec: swaggerData
|
|
27
|
+
}));
|
|
28
|
+
var swagger_default = SwaggerApiDocument;
|
|
29
|
+
|
|
30
|
+
// src/next/routes/pages/swagger/get-static-properties-swagger.ts
|
|
31
|
+
import debug from "debug";
|
|
32
|
+
var swaggerDebug = debug("visulima:api-platform:swagger:get-static-properties-swagger");
|
|
33
|
+
var getStaticProps = (swaggerUrl) => async () => {
|
|
34
|
+
const response = await fetch(swaggerUrl);
|
|
35
|
+
const swaggerData = await response.json();
|
|
36
|
+
swaggerDebug(swaggerData);
|
|
37
|
+
return {
|
|
38
|
+
props: {
|
|
39
|
+
swaggerUrl,
|
|
40
|
+
swaggerData: JSON.parse(JSON.stringify(swaggerData))
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
};
|
|
44
|
+
var get_static_properties_swagger_default = getStaticProps;
|
|
45
|
+
|
|
46
|
+
export {
|
|
47
|
+
redoc_default,
|
|
48
|
+
swagger_default,
|
|
49
|
+
get_static_properties_swagger_default
|
|
50
|
+
};
|
|
51
|
+
//# sourceMappingURL=chunk-GSWANBU5.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/next/routes/pages/swagger/redoc.tsx","../src/next/routes/pages/swagger/swagger.tsx","../src/next/routes/pages/swagger/get-static-properties-swagger.ts"],"sourcesContent":["// eslint-disable-next-line import/no-extraneous-dependencies\nimport type { InferGetStaticPropsType, NextPage } from \"next\";\n// eslint-disable-next-line import/no-extraneous-dependencies\nimport Head from \"next/head\";\nimport React from \"react\";\n// eslint-disable-next-line import/no-extraneous-dependencies\nimport type { RedocStandaloneProps } from \"redoc\";\n// eslint-disable-next-line import/no-extraneous-dependencies\nimport { RedocStandalone } from \"redoc\";\n\nimport getStaticProps from \"./get-static-properties-swagger\";\n\n// eslint-disable-next-line max-len\nconst RedocApiDocument: (\n name: string,\n swagger?: Exclude<RedocStandaloneProps, \"spec\">,\n // eslint-disable-next-line max-len,unicorn/no-useless-undefined\n) => NextPage<InferGetStaticPropsType<typeof getStaticProps>> = (name, swagger = {}) => ({ swaggerData }: InferGetStaticPropsType<typeof getStaticProps>) => (\n <>\n <Head>\n <title>{name}</title>\n <style>\n {`\nbody {\n background: #fafafa !important;\n}\n`}\n </style>\n </Head>\n {/* eslint-disable-next-line react/jsx-props-no-spreading */}\n <RedocStandalone {...swagger} spec={swaggerData} />\n </>\n);\n\nexport default RedocApiDocument;\n","import type { InferGetStaticPropsType, NextPage } from \"next\";\nimport dynamic from \"next/dynamic\";\n// eslint-disable-next-line import/no-extraneous-dependencies\nimport Head from \"next/head\";\n// eslint-disable-next-line import/no-extraneous-dependencies\nimport React from \"react\";\nimport type { SwaggerUIProps } from \"swagger-ui-react\";\n\nimport getStaticProps from \"./get-static-properties-swagger\";\n// eslint-disable-next-line import/no-extraneous-dependencies\nconst SwaggerUI = dynamic<{\n spec: any;\n // @ts-ignore\n // eslint-disable-next-line import/no-extraneous-dependencies\n}>(import(\"swagger-ui-react\"), { ssr: false });\n\n// eslint-disable-next-line max-len\nconst SwaggerApiDocument: (\n name: string,\n swagger?: Exclude<SwaggerUIProps, \"spec\">,\n // eslint-disable-next-line max-len,unicorn/no-useless-undefined\n) => NextPage<InferGetStaticPropsType<typeof getStaticProps>> = (name, swagger = {}) => ({ swaggerData }: InferGetStaticPropsType<typeof getStaticProps>) => (\n <>\n <Head>\n <title>{name}</title>\n <style>\n {`\nbody {\n background: #fafafa !important;\n}\n`}\n </style>\n </Head>\n {/* eslint-disable-next-line react/jsx-props-no-spreading */}\n <SwaggerUI {...swagger} spec={swaggerData} />\n </>\n);\n\nexport default SwaggerApiDocument;\n","// eslint-disable-next-line unicorn/prevent-abbreviations\nimport debug from \"debug\";\nimport type { GetStaticProps } from \"next\";\nimport type { OAS3Definition } from \"swagger-jsdoc\";\n\n// eslint-disable-next-line testing-library/no-debugging-utils\nconst swaggerDebug = debug(\"visulima:api-platform:swagger:get-static-properties-swagger\");\n\n// eslint-disable-next-line unicorn/consistent-function-scoping\nconst getStaticProps: (\n swaggerUrl: string,\n) => GetStaticProps = (swaggerUrl) => async (): Promise<{\n props: {\n swaggerUrl: string;\n swaggerData: OAS3Definition;\n };\n}> => {\n // eslint-disable-next-line compat/compat\n const response = await fetch(swaggerUrl);\n const swaggerData = await response.json();\n\n swaggerDebug(swaggerData);\n\n return {\n props: {\n swaggerUrl,\n swaggerData: JSON.parse(JSON.stringify(swaggerData)),\n },\n };\n};\n\nexport default getStaticProps;\n"],"mappings":";AAGA,OAAO,UAAU;AACjB,OAAO,WAAW;AAIlB,SAAS,uBAAuB;AAKhC,IAAM,mBAI0D,CAAC,MAAM,UAAU,CAAC,MAAM,CAAC,EAAE,YAAY,MAC3F,0DACI,oCAAC,YACG,oCAAC,eAAO,IAAK,GACb,oCAAC,eACI;AAAA;AAAA;AAAA;AAAA,CAKL,CACJ,GAEA,oCAAC;AAAA,EAAiB,GAAG;AAAA,EAAS,MAAM;AAAA,CAAa,CACrD;AAGZ,IAAO,gBAAQ;;;ACjCf,OAAO,aAAa;AAEpB,OAAOA,WAAU;AAEjB,OAAOC,YAAW;AAKlB,IAAM,YAAY,QAIf,OAAO,qBAAqB,EAAE,KAAK,MAAM,CAAC;AAG7C,IAAM,qBAI0D,CAAC,MAAM,UAAU,CAAC,MAAM,CAAC,EAAE,YAAY,MAC3F,gBAAAA,OAAA,cAAAA,OAAA,gBACI,gBAAAA,OAAA,cAACD,OAAA,MACG,gBAAAC,OAAA,cAAC,eAAO,IAAK,GACb,gBAAAA,OAAA,cAAC,eACI;AAAA;AAAA;AAAA;AAAA,CAKL,CACJ,GAEA,gBAAAA,OAAA,cAAC;AAAA,EAAW,GAAG;AAAA,EAAS,MAAM;AAAA,CAAa,CAC/C;AAGZ,IAAO,kBAAQ;;;ACrCf,OAAO,WAAW;AAKlB,IAAM,eAAe,MAAM,6DAA6D;AAGxF,IAAM,iBAEgB,CAAC,eAAe,YAKhC;AAEF,QAAM,WAAW,MAAM,MAAM,UAAU;AACvC,QAAM,cAAc,MAAM,SAAS,KAAK;AAExC,eAAa,WAAW;AAExB,SAAO;AAAA,IACH,OAAO;AAAA,MACH;AAAA,MACA,aAAa,KAAK,MAAM,KAAK,UAAU,WAAW,CAAC;AAAA,IACvD;AAAA,EACJ;AACJ;AAEA,IAAO,wCAAQ;","names":["Head","React"]}
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import {
|
|
2
|
+
__export
|
|
3
|
+
} from "./chunk-5VRACIDE.mjs";
|
|
4
|
+
|
|
5
|
+
// src/zod/index.ts
|
|
6
|
+
var zod_exports = {};
|
|
7
|
+
__export(zod_exports, {
|
|
8
|
+
dateIn: () => dateIn,
|
|
9
|
+
dateOut: () => dateOut
|
|
10
|
+
});
|
|
11
|
+
import { withGetType } from "zod-to-ts";
|
|
12
|
+
|
|
13
|
+
// src/zod/date-in-schema.ts
|
|
14
|
+
import {
|
|
15
|
+
addIssueToContext,
|
|
16
|
+
INVALID,
|
|
17
|
+
ZodIssueCode,
|
|
18
|
+
ZodParsedType,
|
|
19
|
+
ZodType
|
|
20
|
+
} from "zod";
|
|
21
|
+
var zodDateInKind = "ZodDateIn";
|
|
22
|
+
var isoDateRegex = /^\d{4}-\d{2}-\d{2}(T\d{2}:\d{2}:\d{2}(\.\d{3})?)?Z?$/;
|
|
23
|
+
var _ZodDateIn = class extends ZodType {
|
|
24
|
+
_parse(input) {
|
|
25
|
+
const { status, ctx } = this._processInputParams(input);
|
|
26
|
+
if (ctx.parsedType !== ZodParsedType.string) {
|
|
27
|
+
addIssueToContext(ctx, {
|
|
28
|
+
code: ZodIssueCode.invalid_type,
|
|
29
|
+
expected: ZodParsedType.string,
|
|
30
|
+
received: ctx.parsedType
|
|
31
|
+
});
|
|
32
|
+
return INVALID;
|
|
33
|
+
}
|
|
34
|
+
if (!isoDateRegex.test(ctx.data)) {
|
|
35
|
+
addIssueToContext(ctx, {
|
|
36
|
+
code: ZodIssueCode.invalid_string,
|
|
37
|
+
validation: "regex"
|
|
38
|
+
});
|
|
39
|
+
status.dirty();
|
|
40
|
+
}
|
|
41
|
+
const date = new Date(ctx.data);
|
|
42
|
+
if (Number.isNaN(date.getTime())) {
|
|
43
|
+
addIssueToContext(ctx, {
|
|
44
|
+
code: ZodIssueCode.invalid_date
|
|
45
|
+
});
|
|
46
|
+
return INVALID;
|
|
47
|
+
}
|
|
48
|
+
return { status: status.value, value: date };
|
|
49
|
+
}
|
|
50
|
+
};
|
|
51
|
+
var ZodDateIn = _ZodDateIn;
|
|
52
|
+
ZodDateIn.create = () => new _ZodDateIn({
|
|
53
|
+
typeName: zodDateInKind
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
// src/zod/date-out-schema.ts
|
|
57
|
+
import {
|
|
58
|
+
addIssueToContext as addIssueToContext2,
|
|
59
|
+
INVALID as INVALID2,
|
|
60
|
+
ZodIssueCode as ZodIssueCode2,
|
|
61
|
+
ZodParsedType as ZodParsedType2,
|
|
62
|
+
ZodType as ZodType2
|
|
63
|
+
} from "zod";
|
|
64
|
+
var zodDateOutKind = "ZodDateOut";
|
|
65
|
+
var _ZodDateOut = class extends ZodType2 {
|
|
66
|
+
_parse(input) {
|
|
67
|
+
const { status, ctx } = this._processInputParams(input);
|
|
68
|
+
if (ctx.parsedType !== ZodParsedType2.date) {
|
|
69
|
+
addIssueToContext2(ctx, {
|
|
70
|
+
code: ZodIssueCode2.invalid_type,
|
|
71
|
+
expected: ZodParsedType2.date,
|
|
72
|
+
received: ctx.parsedType
|
|
73
|
+
});
|
|
74
|
+
return INVALID2;
|
|
75
|
+
}
|
|
76
|
+
if (Number.isNaN(ctx.data.getTime())) {
|
|
77
|
+
addIssueToContext2(ctx, {
|
|
78
|
+
code: ZodIssueCode2.invalid_date
|
|
79
|
+
});
|
|
80
|
+
return INVALID2;
|
|
81
|
+
}
|
|
82
|
+
return { status: status.value, value: ctx.data.toISOString() };
|
|
83
|
+
}
|
|
84
|
+
};
|
|
85
|
+
var ZodDateOut = _ZodDateOut;
|
|
86
|
+
ZodDateOut.create = () => new _ZodDateOut({
|
|
87
|
+
typeName: zodDateOutKind
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
// src/zod/index.ts
|
|
91
|
+
var dateIn = (...parameters) => withGetType(ZodDateIn.create(...parameters), (ts) => ts.factory.createKeywordTypeNode(ts.SyntaxKind.StringKeyword));
|
|
92
|
+
var dateOut = (...parameters) => withGetType(ZodDateOut.create(...parameters), (ts) => ts.factory.createKeywordTypeNode(ts.SyntaxKind.StringKeyword));
|
|
93
|
+
|
|
94
|
+
export {
|
|
95
|
+
dateIn,
|
|
96
|
+
dateOut,
|
|
97
|
+
zod_exports
|
|
98
|
+
};
|
|
99
|
+
//# sourceMappingURL=chunk-J4EBGCNK.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/zod/index.ts","../src/zod/date-in-schema.ts","../src/zod/date-out-schema.ts"],"sourcesContent":["import { withGetType } from \"zod-to-ts\";\n\nimport { ZodDateIn } from \"./date-in-schema\";\nimport { ZodDateOut } from \"./date-out-schema\";\n\n// eslint-disable-next-line max-len\nexport const dateIn = (...parameters: Parameters<typeof ZodDateIn.create>) => withGetType(ZodDateIn.create(...parameters), (ts) => ts.factory.createKeywordTypeNode(ts.SyntaxKind.StringKeyword));\n// eslint-disable-next-line max-len\nexport const dateOut = (...parameters: Parameters<typeof ZodDateOut.create>) => withGetType(ZodDateOut.create(...parameters), (ts) => ts.factory.createKeywordTypeNode(ts.SyntaxKind.StringKeyword));\n","import type { ParseInput, ParseReturnType, ZodTypeDef } from \"zod\";\nimport {\n addIssueToContext, INVALID, ZodIssueCode, ZodParsedType, ZodType,\n} from \"zod\";\n\nconst zodDateInKind = \"ZodDateIn\";\n\n// simple regex for ISO date, supports the following formats:\n// 2021-01-01T00:00:00.000Z\n// 2021-01-01T00:00:00Z\n// 2021-01-01T00:00:00\n// 2021-01-01\nexport const isoDateRegex = /^\\d{4}-\\d{2}-\\d{2}(T\\d{2}:\\d{2}:\\d{2}(\\.\\d{3})?)?Z?$/;\n\n// eslint-disable-next-line unicorn/prevent-abbreviations\nexport interface ZodDateInDef extends ZodTypeDef {\n typeName: typeof zodDateInKind;\n}\n\nexport class ZodDateIn extends ZodType<Date, ZodDateInDef, string> {\n // eslint-disable-next-line no-underscore-dangle\n _parse(input: ParseInput): ParseReturnType<Date> {\n // eslint-disable-next-line no-underscore-dangle\n const { status, ctx } = this._processInputParams(input);\n if (ctx.parsedType !== ZodParsedType.string) {\n addIssueToContext(ctx, {\n code: ZodIssueCode.invalid_type,\n expected: ZodParsedType.string,\n received: ctx.parsedType,\n });\n return INVALID;\n }\n\n if (!isoDateRegex.test(ctx.data as string)) {\n addIssueToContext(ctx, {\n code: ZodIssueCode.invalid_string,\n validation: \"regex\",\n });\n status.dirty();\n }\n\n const date = new Date(ctx.data);\n\n if (Number.isNaN(date.getTime())) {\n addIssueToContext(ctx, {\n code: ZodIssueCode.invalid_date,\n });\n return INVALID;\n }\n\n return { status: status.value, value: date };\n }\n\n static create = () => new ZodDateIn({\n typeName: zodDateInKind,\n });\n}\n","import type { ParseInput, ParseReturnType, ZodTypeDef } from \"zod\";\nimport {\n addIssueToContext, INVALID, ZodIssueCode, ZodParsedType, ZodType,\n} from \"zod\";\n\nconst zodDateOutKind = \"ZodDateOut\";\n\n// eslint-disable-next-line unicorn/prevent-abbreviations\nexport interface ZodDateOutDef extends ZodTypeDef {\n typeName: typeof zodDateOutKind;\n}\n\nexport class ZodDateOut extends ZodType<string, ZodDateOutDef, Date> {\n // eslint-disable-next-line no-underscore-dangle\n _parse(input: ParseInput): ParseReturnType<string> {\n // eslint-disable-next-line no-underscore-dangle\n const { status, ctx } = this._processInputParams(input);\n\n if (ctx.parsedType !== ZodParsedType.date) {\n addIssueToContext(ctx, {\n code: ZodIssueCode.invalid_type,\n expected: ZodParsedType.date,\n received: ctx.parsedType,\n });\n return INVALID;\n }\n\n if (Number.isNaN(ctx.data.getTime())) {\n addIssueToContext(ctx, {\n code: ZodIssueCode.invalid_date,\n });\n return INVALID;\n }\n\n return { status: status.value, value: (ctx.data as Date).toISOString() };\n }\n\n static create = () => new ZodDateOut({\n typeName: zodDateOutKind,\n });\n}\n"],"mappings":";;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,SAAS,mBAAmB;;;ACC5B;AAAA,EACI;AAAA,EAAmB;AAAA,EAAS;AAAA,EAAc;AAAA,EAAe;AAAA,OACtD;AAEP,IAAM,gBAAgB;AAOf,IAAM,eAAe;AAOrB,IAAM,aAAN,cAAwB,QAAoC;AAAA,EAE/D,OAAO,OAA0C;AAE7C,UAAM,EAAE,QAAQ,IAAI,IAAI,KAAK,oBAAoB,KAAK;AACtD,QAAI,IAAI,eAAe,cAAc,QAAQ;AACzC,wBAAkB,KAAK;AAAA,QACnB,MAAM,aAAa;AAAA,QACnB,UAAU,cAAc;AAAA,QACxB,UAAU,IAAI;AAAA,MAClB,CAAC;AACD,aAAO;AAAA,IACX;AAEA,QAAI,CAAC,aAAa,KAAK,IAAI,IAAc,GAAG;AACxC,wBAAkB,KAAK;AAAA,QACnB,MAAM,aAAa;AAAA,QACnB,YAAY;AAAA,MAChB,CAAC;AACD,aAAO,MAAM;AAAA,IACjB;AAEA,UAAM,OAAO,IAAI,KAAK,IAAI,IAAI;AAE9B,QAAI,OAAO,MAAM,KAAK,QAAQ,CAAC,GAAG;AAC9B,wBAAkB,KAAK;AAAA,QACnB,MAAM,aAAa;AAAA,MACvB,CAAC;AACD,aAAO;AAAA,IACX;AAEA,WAAO,EAAE,QAAQ,OAAO,OAAO,OAAO,KAAK;AAAA,EAC/C;AAKJ;AArCO,IAAM,YAAN;AAAM,UAkCF,SAAS,MAAM,IAAI,WAAU;AAAA,EAChC,UAAU;AACd,CAAC;;;ACtDL;AAAA,EACI,qBAAAA;AAAA,EAAmB,WAAAC;AAAA,EAAS,gBAAAC;AAAA,EAAc,iBAAAC;AAAA,EAAe,WAAAC;AAAA,OACtD;AAEP,IAAM,iBAAiB;AAOhB,IAAM,cAAN,cAAyBA,SAAqC;AAAA,EAEjE,OAAO,OAA4C;AAE/C,UAAM,EAAE,QAAQ,IAAI,IAAI,KAAK,oBAAoB,KAAK;AAEtD,QAAI,IAAI,eAAeD,eAAc,MAAM;AACvC,MAAAH,mBAAkB,KAAK;AAAA,QACnB,MAAME,cAAa;AAAA,QACnB,UAAUC,eAAc;AAAA,QACxB,UAAU,IAAI;AAAA,MAClB,CAAC;AACD,aAAOF;AAAA,IACX;AAEA,QAAI,OAAO,MAAM,IAAI,KAAK,QAAQ,CAAC,GAAG;AAClC,MAAAD,mBAAkB,KAAK;AAAA,QACnB,MAAME,cAAa;AAAA,MACvB,CAAC;AACD,aAAOD;AAAA,IACX;AAEA,WAAO,EAAE,QAAQ,OAAO,OAAO,OAAQ,IAAI,KAAc,YAAY,EAAE;AAAA,EAC3E;AAKJ;AA5BO,IAAM,aAAN;AAAM,WAyBF,SAAS,MAAM,IAAI,YAAW;AAAA,EACjC,UAAU;AACd,CAAC;;;AFjCE,IAAM,SAAS,IAAI,eAAoD,YAAY,UAAU,OAAO,GAAG,UAAU,GAAG,CAAC,OAAO,GAAG,QAAQ,sBAAsB,GAAG,WAAW,aAAa,CAAC;AAEzL,IAAM,UAAU,IAAI,eAAqD,YAAY,WAAW,OAAO,GAAG,UAAU,GAAG,CAAC,OAAO,GAAG,QAAQ,sBAAsB,GAAG,WAAW,aAAa,CAAC;","names":["addIssueToContext","INVALID","ZodIssueCode","ZodParsedType","ZodType"]}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var __defProp = Object.defineProperty;
|
|
2
|
+
var __export = (target, all) => {
|
|
3
|
+
for (var name in all)
|
|
4
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
5
|
+
};
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
exports.__export = __export;
|
|
10
|
+
//# sourceMappingURL=chunk-JC4IRQUL.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":""}
|