moonflower 0.9.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/.eslintrc.js +26 -0
- package/.prettierrc.js +7 -0
- package/README.md +383 -0
- package/cli/cli.ts +59 -0
- package/cli/entry.cjs +3 -0
- package/cli/prettyprint.ts +16 -0
- package/dist/cli/cli.d.ts +2 -0
- package/dist/cli/cli.d.ts.map +1 -0
- package/dist/cli/cli.js +79 -0
- package/dist/cli/prettyprint.d.ts +4 -0
- package/dist/cli/prettyprint.d.ts.map +1 -0
- package/dist/cli/prettyprint.js +18 -0
- package/dist/src/errors/BaseHttpError.d.ts +13 -0
- package/dist/src/errors/BaseHttpError.d.ts.map +1 -0
- package/dist/src/errors/BaseHttpError.js +13 -0
- package/dist/src/errors/HttpErrorHandler.d.ts +3 -0
- package/dist/src/errors/HttpErrorHandler.d.ts.map +1 -0
- package/dist/src/errors/HttpErrorHandler.js +23 -0
- package/dist/src/errors/UserFacingErrors.d.ts +11 -0
- package/dist/src/errors/UserFacingErrors.d.ts.map +1 -0
- package/dist/src/errors/UserFacingErrors.js +23 -0
- package/dist/src/hooks/authentication/useAuth.d.ts +3 -0
- package/dist/src/hooks/authentication/useAuth.d.ts.map +1 -0
- package/dist/src/hooks/authentication/useAuth.js +7 -0
- package/dist/src/hooks/authentication/useOptionalAuth.d.ts +3 -0
- package/dist/src/hooks/authentication/useOptionalAuth.d.ts.map +1 -0
- package/dist/src/hooks/authentication/useOptionalAuth.js +16 -0
- package/dist/src/hooks/useApiEndpoint.d.ts +8 -0
- package/dist/src/hooks/useApiEndpoint.d.ts.map +1 -0
- package/dist/src/hooks/useApiEndpoint.js +7 -0
- package/dist/src/hooks/useApiHeader/index.d.ts +2 -0
- package/dist/src/hooks/useApiHeader/index.d.ts.map +1 -0
- package/dist/src/hooks/useApiHeader/index.js +17 -0
- package/dist/src/hooks/useApiHeader/useApiHeader.d.ts +3 -0
- package/dist/src/hooks/useApiHeader/useApiHeader.d.ts.map +1 -0
- package/dist/src/hooks/useApiHeader/useApiHeader.js +6 -0
- package/dist/src/hooks/useApiHeader/useApiHeader.spec.data.d.ts +2 -0
- package/dist/src/hooks/useApiHeader/useApiHeader.spec.data.d.ts.map +1 -0
- package/dist/src/hooks/useApiHeader/useApiHeader.spec.data.js +22 -0
- package/dist/src/hooks/useCookieParams.d.ts +9 -0
- package/dist/src/hooks/useCookieParams.d.ts.map +1 -0
- package/dist/src/hooks/useCookieParams.js +50 -0
- package/dist/src/hooks/useExposeApiModel/index.d.ts +2 -0
- package/dist/src/hooks/useExposeApiModel/index.d.ts.map +1 -0
- package/dist/src/hooks/useExposeApiModel/index.js +17 -0
- package/dist/src/hooks/useExposeApiModel/useExposeApiModel.d.ts +3 -0
- package/dist/src/hooks/useExposeApiModel/useExposeApiModel.d.ts.map +1 -0
- package/dist/src/hooks/useExposeApiModel/useExposeApiModel.js +9 -0
- package/dist/src/hooks/useExposeApiModel/useExposeApiModel.spec.data.d.ts +2 -0
- package/dist/src/hooks/useExposeApiModel/useExposeApiModel.spec.data.d.ts.map +1 -0
- package/dist/src/hooks/useExposeApiModel/useExposeApiModel.spec.data.js +16 -0
- package/dist/src/hooks/useHeaderParams.d.ts +12 -0
- package/dist/src/hooks/useHeaderParams.d.ts.map +1 -0
- package/dist/src/hooks/useHeaderParams.js +52 -0
- package/dist/src/hooks/usePathParams.d.ts +22 -0
- package/dist/src/hooks/usePathParams.d.ts.map +1 -0
- package/dist/src/hooks/usePathParams.js +46 -0
- package/dist/src/hooks/useQueryParams.d.ts +9 -0
- package/dist/src/hooks/useQueryParams.d.ts.map +1 -0
- package/dist/src/hooks/useQueryParams.js +50 -0
- package/dist/src/hooks/useRequestBody.d.ts +9 -0
- package/dist/src/hooks/useRequestBody.d.ts.map +1 -0
- package/dist/src/hooks/useRequestBody.js +59 -0
- package/dist/src/hooks/useRequestRawBody.d.ts +7 -0
- package/dist/src/hooks/useRequestRawBody.d.ts.map +1 -0
- package/dist/src/hooks/useRequestRawBody.js +34 -0
- package/dist/src/index.d.ts +18 -0
- package/dist/src/index.d.ts.map +1 -0
- package/dist/src/index.js +33 -0
- package/dist/src/openapi/analyzerModule/analyzerModule.d.ts +18 -0
- package/dist/src/openapi/analyzerModule/analyzerModule.d.ts.map +1 -0
- package/dist/src/openapi/analyzerModule/analyzerModule.js +192 -0
- package/dist/src/openapi/analyzerModule/nodeParsers.d.ts +19 -0
- package/dist/src/openapi/analyzerModule/nodeParsers.d.ts.map +1 -0
- package/dist/src/openapi/analyzerModule/nodeParsers.js +521 -0
- package/dist/src/openapi/analyzerModule/parseEndpoint.d.ts +4 -0
- package/dist/src/openapi/analyzerModule/parseEndpoint.d.ts.map +1 -0
- package/dist/src/openapi/analyzerModule/parseEndpoint.js +246 -0
- package/dist/src/openapi/analyzerModule/parseExposedModels.d.ts +5 -0
- package/dist/src/openapi/analyzerModule/parseExposedModels.d.ts.map +1 -0
- package/dist/src/openapi/analyzerModule/parseExposedModels.js +32 -0
- package/dist/src/openapi/analyzerModule/test/openApiAnalyzer.spec.data.d.ts +2 -0
- package/dist/src/openapi/analyzerModule/test/openApiAnalyzer.spec.data.d.ts.map +1 -0
- package/dist/src/openapi/analyzerModule/test/openApiAnalyzer.spec.data.js +400 -0
- package/dist/src/openapi/analyzerModule/types.d.ts +53 -0
- package/dist/src/openapi/analyzerModule/types.d.ts.map +1 -0
- package/dist/src/openapi/analyzerModule/types.js +2 -0
- package/dist/src/openapi/discoveryModule/discoverImports/discoverImports.d.ts +8 -0
- package/dist/src/openapi/discoveryModule/discoverImports/discoverImports.d.ts.map +1 -0
- package/dist/src/openapi/discoveryModule/discoverImports/discoverImports.js +33 -0
- package/dist/src/openapi/discoveryModule/discoverRouterFiles/data/testRouterA.spec.data.d.ts +4 -0
- package/dist/src/openapi/discoveryModule/discoverRouterFiles/data/testRouterA.spec.data.d.ts.map +1 -0
- package/dist/src/openapi/discoveryModule/discoverRouterFiles/data/testRouterA.spec.data.js +8 -0
- package/dist/src/openapi/discoveryModule/discoverRouterFiles/data/testRouterB.spec.data.d.ts +4 -0
- package/dist/src/openapi/discoveryModule/discoverRouterFiles/data/testRouterB.spec.data.d.ts.map +1 -0
- package/dist/src/openapi/discoveryModule/discoverRouterFiles/data/testRouterB.spec.data.js +8 -0
- package/dist/src/openapi/discoveryModule/discoverRouterFiles/discoverRouterFiles.d.ts +17 -0
- package/dist/src/openapi/discoveryModule/discoverRouterFiles/discoverRouterFiles.d.ts.map +1 -0
- package/dist/src/openapi/discoveryModule/discoverRouterFiles/discoverRouterFiles.js +80 -0
- package/dist/src/openapi/discoveryModule/discoverRouters/discoverRouters.d.ts +6 -0
- package/dist/src/openapi/discoveryModule/discoverRouters/discoverRouters.d.ts.map +1 -0
- package/dist/src/openapi/discoveryModule/discoverRouters/discoverRouters.js +31 -0
- package/dist/src/openapi/discoveryModule/discoverRouters/discoverRouters.spec.data.d.ts +5 -0
- package/dist/src/openapi/discoveryModule/discoverRouters/discoverRouters.spec.data.d.ts.map +1 -0
- package/dist/src/openapi/discoveryModule/discoverRouters/discoverRouters.spec.data.js +38 -0
- package/dist/src/openapi/discoveryModule/index.d.ts +3 -0
- package/dist/src/openapi/discoveryModule/index.d.ts.map +1 -0
- package/dist/src/openapi/discoveryModule/index.js +18 -0
- package/dist/src/openapi/generatorModule/generateComponentSchemas.d.ts +4 -0
- package/dist/src/openapi/generatorModule/generateComponentSchemas.d.ts.map +1 -0
- package/dist/src/openapi/generatorModule/generateComponentSchemas.js +12 -0
- package/dist/src/openapi/generatorModule/generatePaths.d.ts +10 -0
- package/dist/src/openapi/generatorModule/generatePaths.d.ts.map +1 -0
- package/dist/src/openapi/generatorModule/generatePaths.js +116 -0
- package/dist/src/openapi/generatorModule/generatorModule.d.ts +16 -0
- package/dist/src/openapi/generatorModule/generatorModule.d.ts.map +1 -0
- package/dist/src/openapi/generatorModule/generatorModule.js +18 -0
- package/dist/src/openapi/generatorModule/getSchema.d.ts +36 -0
- package/dist/src/openapi/generatorModule/getSchema.d.ts.map +1 -0
- package/dist/src/openapi/generatorModule/getSchema.js +133 -0
- package/dist/src/openapi/generatorModule/index.d.ts +5 -0
- package/dist/src/openapi/generatorModule/index.d.ts.map +1 -0
- package/dist/src/openapi/generatorModule/index.js +20 -0
- package/dist/src/openapi/generatorModule/test/openApiGenerator.spec.data.d.ts +515 -0
- package/dist/src/openapi/generatorModule/test/openApiGenerator.spec.data.d.ts.map +1 -0
- package/dist/src/openapi/generatorModule/test/openApiGenerator.spec.data.js +1119 -0
- package/dist/src/openapi/initOpenApiEngine.d.ts +4 -0
- package/dist/src/openapi/initOpenApiEngine.d.ts.map +1 -0
- package/dist/src/openapi/initOpenApiEngine.js +14 -0
- package/dist/src/openapi/manager/OpenApiManager.d.ts +67 -0
- package/dist/src/openapi/manager/OpenApiManager.d.ts.map +1 -0
- package/dist/src/openapi/manager/OpenApiManager.js +86 -0
- package/dist/src/openapi/router/OpenApiRouter.d.ts +4 -0
- package/dist/src/openapi/router/OpenApiRouter.d.ts.map +1 -0
- package/dist/src/openapi/router/OpenApiRouter.js +11 -0
- package/dist/src/openapi/types.d.ts +81 -0
- package/dist/src/openapi/types.d.ts.map +1 -0
- package/dist/src/openapi/types.js +2 -0
- package/dist/src/router/Router.d.ts +23 -0
- package/dist/src/router/Router.d.ts.map +1 -0
- package/dist/src/router/Router.js +81 -0
- package/dist/src/router/responseValueToJson.d.ts +2 -0
- package/dist/src/router/responseValueToJson.d.ts.map +1 -0
- package/dist/src/router/responseValueToJson.js +10 -0
- package/dist/src/setupTests.d.ts +1 -0
- package/dist/src/setupTests.d.ts.map +1 -0
- package/dist/src/setupTests.js +3 -0
- package/dist/src/test/TestAppRouter.d.ts +8 -0
- package/dist/src/test/TestAppRouter.d.ts.map +1 -0
- package/dist/src/test/TestAppRouter.js +58 -0
- package/dist/src/test/app.d.ts +3 -0
- package/dist/src/test/app.d.ts.map +1 -0
- package/dist/src/test/app.js +41 -0
- package/dist/src/utils/TypeUtils.d.ts +22 -0
- package/dist/src/utils/TypeUtils.d.ts.map +1 -0
- package/dist/src/utils/TypeUtils.js +2 -0
- package/dist/src/utils/fromZodSchema.d.ts +2 -0
- package/dist/src/utils/fromZodSchema.d.ts.map +1 -0
- package/dist/src/utils/fromZodSchema.js +6 -0
- package/dist/src/utils/loadTestData.d.ts +2 -0
- package/dist/src/utils/loadTestData.d.ts.map +1 -0
- package/dist/src/utils/loadTestData.js +39 -0
- package/dist/src/utils/mockContext.d.ts +20 -0
- package/dist/src/utils/mockContext.d.ts.map +1 -0
- package/dist/src/utils/mockContext.js +85 -0
- package/dist/src/utils/nameOf.d.ts +5 -0
- package/dist/src/utils/nameOf.d.ts.map +1 -0
- package/dist/src/utils/nameOf.js +7 -0
- package/dist/src/utils/object.d.ts +7 -0
- package/dist/src/utils/object.d.ts.map +1 -0
- package/dist/src/utils/object.js +21 -0
- package/dist/src/utils/printers.d.ts +6 -0
- package/dist/src/utils/printers.d.ts.map +1 -0
- package/dist/src/utils/printers.js +76 -0
- package/dist/src/utils/validationMessages.d.ts +18 -0
- package/dist/src/utils/validationMessages.d.ts.map +1 -0
- package/dist/src/utils/validationMessages.js +43 -0
- package/dist/src/validators/BuiltInValidators.d.ts +61 -0
- package/dist/src/validators/BuiltInValidators.d.ts.map +1 -0
- package/dist/src/validators/BuiltInValidators.js +66 -0
- package/dist/src/validators/InternalParamWrappers.d.ts +5 -0
- package/dist/src/validators/InternalParamWrappers.d.ts.map +1 -0
- package/dist/src/validators/InternalParamWrappers.js +5 -0
- package/dist/src/validators/ParamWrappers.d.ts +11 -0
- package/dist/src/validators/ParamWrappers.d.ts.map +1 -0
- package/dist/src/validators/ParamWrappers.js +9 -0
- package/dist/src/validators/types.d.ts +18 -0
- package/dist/src/validators/types.d.ts.map +1 -0
- package/dist/src/validators/types.js +2 -0
- package/dist/tsconfig.build.tsbuildinfo +1 -0
- package/package.json +59 -0
- package/src/errors/BaseHttpError.ts +16 -0
- package/src/errors/HttpErrorHandler.ts +20 -0
- package/src/errors/UserFacingErrors.ts +39 -0
- package/src/hooks/authentication/useAuth.ts +8 -0
- package/src/hooks/authentication/useOptionalAuth.ts +17 -0
- package/src/hooks/useApiEndpoint.spec.ts +11 -0
- package/src/hooks/useApiEndpoint.ts +10 -0
- package/src/hooks/useApiHeader/index.ts +1 -0
- package/src/hooks/useApiHeader/useApiHeader.spec.data.ts +22 -0
- package/src/hooks/useApiHeader/useApiHeader.spec.ts +34 -0
- package/src/hooks/useApiHeader/useApiHeader.ts +6 -0
- package/src/hooks/useCookieParams.spec.ts +174 -0
- package/src/hooks/useCookieParams.ts +73 -0
- package/src/hooks/useExposeApiModel/index.ts +1 -0
- package/src/hooks/useExposeApiModel/useExposeApiModel.spec.data.ts +48 -0
- package/src/hooks/useExposeApiModel/useExposeApiModel.spec.ts +388 -0
- package/src/hooks/useExposeApiModel/useExposeApiModel.ts +9 -0
- package/src/hooks/useHeaderParams.spec.ts +186 -0
- package/src/hooks/useHeaderParams.ts +83 -0
- package/src/hooks/usePathParams.spec.ts +161 -0
- package/src/hooks/usePathParams.ts +89 -0
- package/src/hooks/useQueryParams.spec.ts +224 -0
- package/src/hooks/useQueryParams.ts +73 -0
- package/src/hooks/useRequestBody.spec.ts +215 -0
- package/src/hooks/useRequestBody.ts +94 -0
- package/src/hooks/useRequestRawBody.spec.ts +154 -0
- package/src/hooks/useRequestRawBody.ts +56 -0
- package/src/index.ts +17 -0
- package/src/openapi/analyzerModule/analyzerModule.ts +228 -0
- package/src/openapi/analyzerModule/nodeParsers.ts +648 -0
- package/src/openapi/analyzerModule/parseEndpoint.ts +305 -0
- package/src/openapi/analyzerModule/parseExposedModels.ts +34 -0
- package/src/openapi/analyzerModule/test/openApiAnalyzer.spec.data.ts +521 -0
- package/src/openapi/analyzerModule/test/openApiAnalyzer.spec.ts +1043 -0
- package/src/openapi/analyzerModule/types.ts +72 -0
- package/src/openapi/discoveryModule/discoverImports/discoverImports.ts +43 -0
- package/src/openapi/discoveryModule/discoverRouterFiles/data/testRouterA.spec.data.ts +7 -0
- package/src/openapi/discoveryModule/discoverRouterFiles/data/testRouterB.spec.data.ts +7 -0
- package/src/openapi/discoveryModule/discoverRouterFiles/discoverRouterFiles.spec.ts +36 -0
- package/src/openapi/discoveryModule/discoverRouterFiles/discoverRouterFiles.ts +80 -0
- package/src/openapi/discoveryModule/discoverRouters/discoverRouters.spec.data.ts +42 -0
- package/src/openapi/discoveryModule/discoverRouters/discoverRouters.spec.ts +18 -0
- package/src/openapi/discoveryModule/discoverRouters/discoverRouters.ts +39 -0
- package/src/openapi/discoveryModule/index.ts +2 -0
- package/src/openapi/generatorModule/generateComponentSchemas.ts +12 -0
- package/src/openapi/generatorModule/generatePaths.ts +138 -0
- package/src/openapi/generatorModule/generatorModule.ts +17 -0
- package/src/openapi/generatorModule/getSchema.ts +169 -0
- package/src/openapi/generatorModule/index.ts +4 -0
- package/src/openapi/generatorModule/test/openApiGenerator.spec.data.ts +1119 -0
- package/src/openapi/generatorModule/test/openApiGenerator.spec.ts +783 -0
- package/src/openapi/initOpenApiEngine.ts +20 -0
- package/src/openapi/manager/OpenApiManager.ts +153 -0
- package/src/openapi/router/OpenApiRouter.ts +11 -0
- package/src/openapi/types.ts +86 -0
- package/src/router/Router.ts +123 -0
- package/src/router/responseValueToJson.ts +6 -0
- package/src/setupTests.ts +3 -0
- package/src/test/TestAppRouter.ts +76 -0
- package/src/test/app.spec.ts +130 -0
- package/src/test/app.ts +43 -0
- package/src/utils/TypeUtils.ts +51 -0
- package/src/utils/loadTestData.ts +15 -0
- package/src/utils/mockContext.ts +86 -0
- package/src/utils/nameOf.ts +7 -0
- package/src/utils/object.spec.ts +27 -0
- package/src/utils/object.ts +17 -0
- package/src/utils/printers.spec.ts +103 -0
- package/src/utils/printers.ts +49 -0
- package/src/utils/validationMessages.ts +65 -0
- package/src/validators/BuiltInValidators.ts +64 -0
- package/src/validators/InternalParamWrappers.ts +14 -0
- package/src/validators/ParamWrappers.ts +22 -0
- package/src/validators/types.ts +35 -0
- package/tsconfig.build.json +15 -0
- package/tsconfig.json +29 -0
- package/vite.config.ts +16 -0
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
export type ShapeOfType = ShapeOfProperty | ShapeOfStringLiteral | ShapeOfNumberLiteral | ShapeOfUnion | ShapeOfUnionEntry | ShapeOfRecord | ShapeOfArray | ShapeOfRef | ShapeOfTuple | ShapeOfTupleEntry;
|
|
2
|
+
export type ShapeOfProperty = {
|
|
3
|
+
role: 'property';
|
|
4
|
+
identifier: string;
|
|
5
|
+
shape: string | ShapeOfType[];
|
|
6
|
+
optional: boolean;
|
|
7
|
+
};
|
|
8
|
+
export type ShapeOfStringLiteral = {
|
|
9
|
+
role: 'literal_string';
|
|
10
|
+
shape: string;
|
|
11
|
+
optional: boolean;
|
|
12
|
+
};
|
|
13
|
+
export type ShapeOfNumberLiteral = {
|
|
14
|
+
role: 'literal_number';
|
|
15
|
+
shape: string;
|
|
16
|
+
optional: boolean;
|
|
17
|
+
};
|
|
18
|
+
export type ShapeOfUnion = {
|
|
19
|
+
role: 'union';
|
|
20
|
+
shape: ShapeOfUnionEntry[];
|
|
21
|
+
optional: boolean;
|
|
22
|
+
};
|
|
23
|
+
export type ShapeOfUnionEntry = {
|
|
24
|
+
role: 'union_entry';
|
|
25
|
+
shape: string | ShapeOfType[];
|
|
26
|
+
optional: boolean;
|
|
27
|
+
};
|
|
28
|
+
export type ShapeOfRecord = {
|
|
29
|
+
role: 'record';
|
|
30
|
+
shape: string | ShapeOfType[];
|
|
31
|
+
optional: boolean;
|
|
32
|
+
};
|
|
33
|
+
export type ShapeOfArray = {
|
|
34
|
+
role: 'array';
|
|
35
|
+
shape: string | ShapeOfType[];
|
|
36
|
+
optional: boolean;
|
|
37
|
+
};
|
|
38
|
+
export type ShapeOfRef = {
|
|
39
|
+
role: 'ref';
|
|
40
|
+
shape: string;
|
|
41
|
+
optional: boolean;
|
|
42
|
+
};
|
|
43
|
+
export type ShapeOfTuple = {
|
|
44
|
+
role: 'tuple';
|
|
45
|
+
shape: ShapeOfTupleEntry[];
|
|
46
|
+
optional: boolean;
|
|
47
|
+
};
|
|
48
|
+
export type ShapeOfTupleEntry = {
|
|
49
|
+
role: 'tuple_entry';
|
|
50
|
+
shape: string | ShapeOfType[];
|
|
51
|
+
optional: boolean;
|
|
52
|
+
};
|
|
53
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/openapi/analyzerModule/types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,WAAW,GACpB,eAAe,GACf,oBAAoB,GACpB,oBAAoB,GACpB,YAAY,GACZ,iBAAiB,GACjB,aAAa,GACb,YAAY,GACZ,UAAU,GACV,YAAY,GACZ,iBAAiB,CAAA;AAEpB,MAAM,MAAM,eAAe,GAAG;IAC7B,IAAI,EAAE,UAAU,CAAA;IAChB,UAAU,EAAE,MAAM,CAAA;IAClB,KAAK,EAAE,MAAM,GAAG,WAAW,EAAE,CAAA;IAC7B,QAAQ,EAAE,OAAO,CAAA;CACjB,CAAA;AAED,MAAM,MAAM,oBAAoB,GAAG;IAClC,IAAI,EAAE,gBAAgB,CAAA;IACtB,KAAK,EAAE,MAAM,CAAA;IACb,QAAQ,EAAE,OAAO,CAAA;CACjB,CAAA;AAED,MAAM,MAAM,oBAAoB,GAAG;IAClC,IAAI,EAAE,gBAAgB,CAAA;IACtB,KAAK,EAAE,MAAM,CAAA;IACb,QAAQ,EAAE,OAAO,CAAA;CACjB,CAAA;AAED,MAAM,MAAM,YAAY,GAAG;IAC1B,IAAI,EAAE,OAAO,CAAA;IACb,KAAK,EAAE,iBAAiB,EAAE,CAAA;IAC1B,QAAQ,EAAE,OAAO,CAAA;CACjB,CAAA;AAED,MAAM,MAAM,iBAAiB,GAAG;IAC/B,IAAI,EAAE,aAAa,CAAA;IACnB,KAAK,EAAE,MAAM,GAAG,WAAW,EAAE,CAAA;IAC7B,QAAQ,EAAE,OAAO,CAAA;CACjB,CAAA;AAED,MAAM,MAAM,aAAa,GAAG;IAC3B,IAAI,EAAE,QAAQ,CAAA;IACd,KAAK,EAAE,MAAM,GAAG,WAAW,EAAE,CAAA;IAC7B,QAAQ,EAAE,OAAO,CAAA;CACjB,CAAA;AAED,MAAM,MAAM,YAAY,GAAG;IAC1B,IAAI,EAAE,OAAO,CAAA;IACb,KAAK,EAAE,MAAM,GAAG,WAAW,EAAE,CAAA;IAC7B,QAAQ,EAAE,OAAO,CAAA;CACjB,CAAA;AAED,MAAM,MAAM,UAAU,GAAG;IACxB,IAAI,EAAE,KAAK,CAAA;IACX,KAAK,EAAE,MAAM,CAAA;IACb,QAAQ,EAAE,OAAO,CAAA;CACjB,CAAA;AAED,MAAM,MAAM,YAAY,GAAG;IAC1B,IAAI,EAAE,OAAO,CAAA;IACb,KAAK,EAAE,iBAAiB,EAAE,CAAA;IAC1B,QAAQ,EAAE,OAAO,CAAA;CACjB,CAAA;AAED,MAAM,MAAM,iBAAiB,GAAG;IAC/B,IAAI,EAAE,aAAa,CAAA;IACnB,KAAK,EAAE,MAAM,GAAG,WAAW,EAAE,CAAA;IAC7B,QAAQ,EAAE,OAAO,CAAA;CACjB,CAAA"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { SourceFile } from 'ts-morph';
|
|
2
|
+
type Props = {
|
|
3
|
+
sourceFile: SourceFile;
|
|
4
|
+
originalName: string;
|
|
5
|
+
};
|
|
6
|
+
export declare const discoverImportedName: ({ sourceFile, originalName }: Props) => string | null;
|
|
7
|
+
export {};
|
|
8
|
+
//# sourceMappingURL=discoverImports.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"discoverImports.d.ts","sourceRoot":"","sources":["../../../../../src/openapi/discoveryModule/discoverImports/discoverImports.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAc,MAAM,UAAU,CAAA;AAEjD,KAAK,KAAK,GAAG;IACZ,UAAU,EAAE,UAAU,CAAA;IACtB,YAAY,EAAE,MAAM,CAAA;CACpB,CAAA;AAED,eAAO,MAAM,oBAAoB,iCAAkC,KAAK,KAAG,MAAM,GAAG,IAmCnF,CAAA"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.discoverImportedName = void 0;
|
|
4
|
+
const ts_morph_1 = require("ts-morph");
|
|
5
|
+
const discoverImportedName = ({ sourceFile, originalName }) => {
|
|
6
|
+
const importDeclarations = sourceFile.getDescendantsOfKind(ts_morph_1.SyntaxKind.ImportDeclaration);
|
|
7
|
+
const discoveredName = importDeclarations
|
|
8
|
+
.filter((declaration) => {
|
|
9
|
+
const importPathNode = declaration.getLastChildByKind(ts_morph_1.SyntaxKind.StringLiteral);
|
|
10
|
+
if (!importPathNode) {
|
|
11
|
+
return false;
|
|
12
|
+
}
|
|
13
|
+
const importPath = importPathNode.getText();
|
|
14
|
+
return (/moonflower/.test(importPath) ||
|
|
15
|
+
process.env.NODE_ENV === 'test' ||
|
|
16
|
+
process.env.NODE_ENV === 'development');
|
|
17
|
+
})
|
|
18
|
+
.map((declaration) => {
|
|
19
|
+
const routerImport = declaration
|
|
20
|
+
.getDescendantsOfKind(ts_morph_1.SyntaxKind.ImportSpecifier)
|
|
21
|
+
.filter((i) => { var _a; return ((_a = i.getFirstChildByKind(ts_morph_1.SyntaxKind.Identifier)) === null || _a === void 0 ? void 0 : _a.getText()) === originalName; })[0];
|
|
22
|
+
if (!routerImport) {
|
|
23
|
+
return null;
|
|
24
|
+
}
|
|
25
|
+
return routerImport.getLastChildByKindOrThrow(ts_morph_1.SyntaxKind.Identifier).getText();
|
|
26
|
+
})
|
|
27
|
+
.filter((declaration) => declaration !== null)[0];
|
|
28
|
+
if (!discoveredName) {
|
|
29
|
+
return null;
|
|
30
|
+
}
|
|
31
|
+
return discoveredName;
|
|
32
|
+
};
|
|
33
|
+
exports.discoverImportedName = discoverImportedName;
|
package/dist/src/openapi/discoveryModule/discoverRouterFiles/data/testRouterA.spec.data.d.ts.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"testRouterA.spec.data.d.ts","sourceRoot":"","sources":["../../../../../../src/openapi/discoveryModule/discoverRouterFiles/data/testRouterA.spec.data.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,2BAA2B,CAAA;AAElD,eAAO,MAAM,MAAM,kEAAe,CAAA"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.router = void 0;
|
|
4
|
+
const Router_1 = require("../../../../router/Router");
|
|
5
|
+
exports.router = new Router_1.Router();
|
|
6
|
+
exports.router.get('/api-a', () => {
|
|
7
|
+
return 'test-data';
|
|
8
|
+
});
|
package/dist/src/openapi/discoveryModule/discoverRouterFiles/data/testRouterB.spec.data.d.ts.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"testRouterB.spec.data.d.ts","sourceRoot":"","sources":["../../../../../../src/openapi/discoveryModule/discoverRouterFiles/data/testRouterB.spec.data.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,2BAA2B,CAAA;AAElD,eAAO,MAAM,MAAM,kEAAe,CAAA"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.router = void 0;
|
|
4
|
+
const Router_1 = require("../../../../router/Router");
|
|
5
|
+
exports.router = new Router_1.Router();
|
|
6
|
+
exports.router.get('/api-b', () => {
|
|
7
|
+
return 'test-data';
|
|
8
|
+
});
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export type DiscoveredSourceFile = ReturnType<typeof discoverRouterFiles>['discoveredRouterFiles'][number];
|
|
2
|
+
export declare const discoverRouterFiles: ({ targetPath, tsConfigPath, excludedFiles, }: {
|
|
3
|
+
targetPath: string;
|
|
4
|
+
tsConfigPath: string;
|
|
5
|
+
excludedFiles?: (string | RegExp)[] | undefined;
|
|
6
|
+
}) => {
|
|
7
|
+
discoveredRouterFiles: {
|
|
8
|
+
fileName: string;
|
|
9
|
+
sourceFile: import("ts-morph").SourceFile;
|
|
10
|
+
routers: {
|
|
11
|
+
named: string[];
|
|
12
|
+
anonymous: import("ts-morph").CallExpression<import("@ts-morph/common/lib/typescript").CallExpression>[];
|
|
13
|
+
};
|
|
14
|
+
}[];
|
|
15
|
+
discoveredSourceFiles: import("ts-morph").SourceFile[];
|
|
16
|
+
};
|
|
17
|
+
//# sourceMappingURL=discoverRouterFiles.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"discoverRouterFiles.d.ts","sourceRoot":"","sources":["../../../../../src/openapi/discoveryModule/discoverRouterFiles/discoverRouterFiles.ts"],"names":[],"mappings":"AAMA,MAAM,MAAM,oBAAoB,GAAG,UAAU,CAAC,OAAO,mBAAmB,CAAC,CAAC,uBAAuB,CAAC,CAAC,MAAM,CAAC,CAAA;AAE1G,eAAO,MAAM,mBAAmB;gBAKnB,MAAM;kBACJ,MAAM;;;;;;;;;;;;CAiEpB,CAAA"}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
+
exports.discoverRouterFiles = void 0;
|
|
27
|
+
const fs = __importStar(require("fs"));
|
|
28
|
+
const path = __importStar(require("path"));
|
|
29
|
+
const ts_morph_1 = require("ts-morph");
|
|
30
|
+
const discoverRouters_1 = require("../discoverRouters/discoverRouters");
|
|
31
|
+
const discoverRouterFiles = ({ targetPath, tsConfigPath, excludedFiles, }) => {
|
|
32
|
+
if (!fs.existsSync(targetPath)) {
|
|
33
|
+
return { discoveredRouterFiles: [], discoveredSourceFiles: [] };
|
|
34
|
+
}
|
|
35
|
+
const usersExcludedFiles = (excludedFiles !== null && excludedFiles !== void 0 ? excludedFiles : []).map((value) => typeof value === 'string' ? new RegExp(`${value}`) : value);
|
|
36
|
+
const excludedPrefixes = [/^node_modules/, /^\./, /^dist/].concat(usersExcludedFiles !== null && usersExcludedFiles !== void 0 ? usersExcludedFiles : []);
|
|
37
|
+
const files = fs.readdirSync(targetPath, { recursive: true }).filter((filePath) => {
|
|
38
|
+
if (typeof filePath !== 'string') {
|
|
39
|
+
return false;
|
|
40
|
+
}
|
|
41
|
+
if (excludedPrefixes.some((p) => p.test(filePath))) {
|
|
42
|
+
return false;
|
|
43
|
+
}
|
|
44
|
+
if (!filePath.endsWith('.ts')) {
|
|
45
|
+
return false;
|
|
46
|
+
}
|
|
47
|
+
return true;
|
|
48
|
+
});
|
|
49
|
+
const project = new ts_morph_1.Project({
|
|
50
|
+
tsConfigFilePath: tsConfigPath,
|
|
51
|
+
});
|
|
52
|
+
const allSourceFiles = files
|
|
53
|
+
.map((fileName) => {
|
|
54
|
+
const filePath = path.resolve(targetPath, fileName);
|
|
55
|
+
return {
|
|
56
|
+
fileName,
|
|
57
|
+
sourceFile: project.getSourceFile(filePath),
|
|
58
|
+
};
|
|
59
|
+
})
|
|
60
|
+
.filter((file) => !!file.sourceFile);
|
|
61
|
+
const routersInFiles = allSourceFiles
|
|
62
|
+
.map((file) => {
|
|
63
|
+
const { fileName, sourceFile } = file;
|
|
64
|
+
const routers = (0, discoverRouters_1.discoverRouters)(sourceFile);
|
|
65
|
+
if (routers.named.length === 0 && routers.anonymous.length === 0) {
|
|
66
|
+
return null;
|
|
67
|
+
}
|
|
68
|
+
return {
|
|
69
|
+
fileName,
|
|
70
|
+
sourceFile,
|
|
71
|
+
routers,
|
|
72
|
+
};
|
|
73
|
+
})
|
|
74
|
+
.filter((file) => file !== null);
|
|
75
|
+
return {
|
|
76
|
+
discoveredRouterFiles: routersInFiles,
|
|
77
|
+
discoveredSourceFiles: allSourceFiles.map((file) => file.sourceFile),
|
|
78
|
+
};
|
|
79
|
+
};
|
|
80
|
+
exports.discoverRouterFiles = discoverRouterFiles;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { SourceFile } from 'ts-morph';
|
|
2
|
+
export declare const discoverRouters: (sourceFile: SourceFile) => {
|
|
3
|
+
named: string[];
|
|
4
|
+
anonymous: import("ts-morph").CallExpression<import("@ts-morph/common/lib/typescript").CallExpression>[];
|
|
5
|
+
};
|
|
6
|
+
//# sourceMappingURL=discoverRouters.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"discoverRouters.d.ts","sourceRoot":"","sources":["../../../../../src/openapi/discoveryModule/discoverRouters/discoverRouters.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAc,MAAM,UAAU,CAAA;AAMjD,eAAO,MAAM,eAAe,eAAgB,UAAU;;;CAgCrD,CAAA"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.discoverRouters = void 0;
|
|
4
|
+
const ts_morph_1 = require("ts-morph");
|
|
5
|
+
const Router_1 = require("../../../router/Router");
|
|
6
|
+
const nameOf_1 = require("../../../utils/nameOf");
|
|
7
|
+
const discoverImports_1 = require("../discoverImports/discoverImports");
|
|
8
|
+
const discoverRouters = (sourceFile) => {
|
|
9
|
+
const routerClassName = (0, discoverImports_1.discoverImportedName)({
|
|
10
|
+
sourceFile,
|
|
11
|
+
originalName: (0, nameOf_1.nameOf)(Router_1.Router),
|
|
12
|
+
});
|
|
13
|
+
if (!routerClassName) {
|
|
14
|
+
return { named: [], anonymous: [] };
|
|
15
|
+
}
|
|
16
|
+
const routers = sourceFile
|
|
17
|
+
.getDescendantsOfKind(ts_morph_1.SyntaxKind.NewExpression)
|
|
18
|
+
.filter((exp) => exp.getFirstChildByKindOrThrow(ts_morph_1.SyntaxKind.Identifier).getText() === routerClassName);
|
|
19
|
+
const namedRouters = routers.filter((node) => !!node.getFirstAncestorByKind(ts_morph_1.SyntaxKind.VariableDeclaration));
|
|
20
|
+
const anonymousRouters = routers.filter((node) => !!node.getFirstAncestorByKind(ts_morph_1.SyntaxKind.ExportAssignment));
|
|
21
|
+
return {
|
|
22
|
+
named: namedRouters.map((node) => node
|
|
23
|
+
.getFirstAncestorByKindOrThrow(ts_morph_1.SyntaxKind.VariableDeclaration)
|
|
24
|
+
.getFirstChildByKindOrThrow(ts_morph_1.SyntaxKind.Identifier)
|
|
25
|
+
.getText()),
|
|
26
|
+
anonymous: anonymousRouters.map((node) => node
|
|
27
|
+
.getFirstAncestorByKindOrThrow(ts_morph_1.SyntaxKind.ExportAssignment)
|
|
28
|
+
.getFirstChildByKindOrThrow(ts_morph_1.SyntaxKind.CallExpression)),
|
|
29
|
+
};
|
|
30
|
+
};
|
|
31
|
+
exports.discoverRouters = discoverRouters;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/// <reference types="koa" />
|
|
2
|
+
import { Router as RenamedRouter } from '../../../router/Router';
|
|
3
|
+
declare const _default: RenamedRouter<import("koa").DefaultState, import("koa").DefaultContext>;
|
|
4
|
+
export default _default;
|
|
5
|
+
//# sourceMappingURL=discoverRouters.spec.data.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"discoverRouters.spec.data.d.ts","sourceRoot":"","sources":["../../../../../src/openapi/discoveryModule/discoverRouters/discoverRouters.spec.data.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,MAAM,IAAI,aAAa,EAAE,MAAM,wBAAwB,CAAA;;AAqBhE,wBASG"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const Router_1 = require("../../../router/Router");
|
|
4
|
+
const namedRouterVariable = new Router_1.Router();
|
|
5
|
+
namedRouterVariable.get('/api', () => {
|
|
6
|
+
return 'test-data';
|
|
7
|
+
});
|
|
8
|
+
const anotherRouterVariable = new Router_1.Router()
|
|
9
|
+
.use((_, next) => next())
|
|
10
|
+
.with(() => {
|
|
11
|
+
const user = { id: '123' };
|
|
12
|
+
return {
|
|
13
|
+
user,
|
|
14
|
+
};
|
|
15
|
+
});
|
|
16
|
+
anotherRouterVariable.get('/api', () => {
|
|
17
|
+
return 'more-test-data';
|
|
18
|
+
});
|
|
19
|
+
exports.default = new Router_1.Router()
|
|
20
|
+
.get('/anonapi', () => {
|
|
21
|
+
return 'otherdata';
|
|
22
|
+
})
|
|
23
|
+
.get('/anonapitwo', () => {
|
|
24
|
+
return 'otherdata';
|
|
25
|
+
})
|
|
26
|
+
.get('/anonapithree', () => {
|
|
27
|
+
return 'otherdata';
|
|
28
|
+
});
|
|
29
|
+
class Router {
|
|
30
|
+
constructor() {
|
|
31
|
+
this.value = 'foo';
|
|
32
|
+
}
|
|
33
|
+
setValue(val) {
|
|
34
|
+
this.value = val;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
const unrelatedObject = new Router();
|
|
38
|
+
unrelatedObject.setValue('bar');
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/openapi/discoveryModule/index.ts"],"names":[],"mappings":"AAAA,cAAc,2CAA2C,CAAA;AACzD,cAAc,mCAAmC,CAAA"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./discoverRouterFiles/discoverRouterFiles"), exports);
|
|
18
|
+
__exportStar(require("./discoverRouters/discoverRouters"), exports);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generateComponentSchemas.d.ts","sourceRoot":"","sources":["../../../../src/openapi/generatorModule/generateComponentSchemas.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAA;AAC3C,OAAO,EAAa,UAAU,EAAE,MAAM,aAAa,CAAA;AAEnD,eAAO,MAAM,wBAAwB,WAAY,gBAAgB,EAAE,+BAOlE,CAAA"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.generateComponentSchemas = void 0;
|
|
4
|
+
const getSchema_1 = require("./getSchema");
|
|
5
|
+
const generateComponentSchemas = (models) => {
|
|
6
|
+
const schemas = {};
|
|
7
|
+
models.forEach((model) => {
|
|
8
|
+
schemas[model.name] = (0, getSchema_1.getSchema)(model.shape);
|
|
9
|
+
});
|
|
10
|
+
return schemas;
|
|
11
|
+
};
|
|
12
|
+
exports.generateComponentSchemas = generateComponentSchemas;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { ApiDocsPreferences } from '../manager/OpenApiManager';
|
|
2
|
+
import { EndpointData, PathDefinition } from '../types';
|
|
3
|
+
export declare const generatePaths: (endpoints: EndpointData[], preferences: ApiDocsPreferences) => Record<string, {
|
|
4
|
+
get?: PathDefinition | undefined;
|
|
5
|
+
post?: PathDefinition | undefined;
|
|
6
|
+
put?: PathDefinition | undefined;
|
|
7
|
+
patch?: PathDefinition | undefined;
|
|
8
|
+
delete?: PathDefinition | undefined;
|
|
9
|
+
}>;
|
|
10
|
+
//# sourceMappingURL=generatePaths.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generatePaths.d.ts","sourceRoot":"","sources":["../../../../src/openapi/generatorModule/generatePaths.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAA;AAC9D,OAAO,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,UAAU,CAAA;AAGvD,eAAO,MAAM,aAAa,cAAe,YAAY,EAAE,eAAe,kBAAkB;;;;;;EAoIvF,CAAA"}
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.generatePaths = void 0;
|
|
4
|
+
const getSchema_1 = require("./getSchema");
|
|
5
|
+
const generatePaths = (endpoints, preferences) => {
|
|
6
|
+
const paths = {};
|
|
7
|
+
const { allowOptionalPathParams } = preferences;
|
|
8
|
+
endpoints.forEach((endpoint) => {
|
|
9
|
+
var _a;
|
|
10
|
+
const path = endpoint.path
|
|
11
|
+
.split('/')
|
|
12
|
+
.map((param) => {
|
|
13
|
+
if (param.startsWith(':')) {
|
|
14
|
+
return `{${param.substring(1).replace('?', '')}}`;
|
|
15
|
+
}
|
|
16
|
+
return param;
|
|
17
|
+
})
|
|
18
|
+
.join('/');
|
|
19
|
+
const pathParams = endpoint.requestPathParams.map((param) => {
|
|
20
|
+
var _a;
|
|
21
|
+
return ({
|
|
22
|
+
name: param.identifier,
|
|
23
|
+
in: 'path',
|
|
24
|
+
description: param.optional && !allowOptionalPathParams
|
|
25
|
+
? `(Optional parameter) ${param.description}`
|
|
26
|
+
: (_a = param.description) !== null && _a !== void 0 ? _a : '',
|
|
27
|
+
required: !allowOptionalPathParams || !param.optional,
|
|
28
|
+
schema: (0, getSchema_1.getSchema)(param.signature),
|
|
29
|
+
});
|
|
30
|
+
});
|
|
31
|
+
const queryParams = endpoint.requestQuery.map((param) => {
|
|
32
|
+
var _a;
|
|
33
|
+
return ({
|
|
34
|
+
name: param.identifier,
|
|
35
|
+
in: 'query',
|
|
36
|
+
description: (_a = param.description) !== null && _a !== void 0 ? _a : '',
|
|
37
|
+
required: !param.optional,
|
|
38
|
+
schema: (0, getSchema_1.getSchema)(param.signature),
|
|
39
|
+
});
|
|
40
|
+
});
|
|
41
|
+
const headerParams = endpoint.requestHeaders.map((param) => {
|
|
42
|
+
var _a;
|
|
43
|
+
return ({
|
|
44
|
+
name: param.identifier,
|
|
45
|
+
in: 'header',
|
|
46
|
+
description: (_a = param.description) !== null && _a !== void 0 ? _a : '',
|
|
47
|
+
required: !param.optional,
|
|
48
|
+
schema: (0, getSchema_1.getSchema)(param.signature),
|
|
49
|
+
});
|
|
50
|
+
});
|
|
51
|
+
const acceptedBodyTypes = {};
|
|
52
|
+
if (endpoint.rawBody) {
|
|
53
|
+
acceptedBodyTypes['text/plain'] = {
|
|
54
|
+
schema: (0, getSchema_1.getSchema)(endpoint.rawBody.signature),
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
if (endpoint.objectBody.length > 0) {
|
|
58
|
+
const properties = {};
|
|
59
|
+
endpoint.objectBody.forEach((prop) => {
|
|
60
|
+
properties[prop.identifier] = (0, getSchema_1.getSchema)(prop.signature);
|
|
61
|
+
});
|
|
62
|
+
const required = endpoint.objectBody.filter((prop) => !prop.optional).map((prop) => prop.identifier);
|
|
63
|
+
const content = {
|
|
64
|
+
schema: {
|
|
65
|
+
type: 'object',
|
|
66
|
+
properties,
|
|
67
|
+
required: required.length > 0 ? required : undefined,
|
|
68
|
+
},
|
|
69
|
+
};
|
|
70
|
+
acceptedBodyTypes['application/json'] = content;
|
|
71
|
+
acceptedBodyTypes['application/x-www-form-urlencoded'] = content;
|
|
72
|
+
}
|
|
73
|
+
const requestsWithBody = ['POST', 'PATCH', 'PUT'];
|
|
74
|
+
const requestBody = requestsWithBody.includes(endpoint.method) && Object.keys(acceptedBodyTypes).length > 0
|
|
75
|
+
? { content: acceptedBodyTypes }
|
|
76
|
+
: undefined;
|
|
77
|
+
const responses = {};
|
|
78
|
+
endpoint.responses.forEach((response) => {
|
|
79
|
+
var _a, _b, _c;
|
|
80
|
+
const status = String(response.status);
|
|
81
|
+
const existingSchemas = (_c = (_b = (_a = responses[status]) === null || _a === void 0 ? void 0 : _a['content']) === null || _b === void 0 ? void 0 : _b['application/json']['schema']['oneOf']) !== null && _c !== void 0 ? _c : [];
|
|
82
|
+
const responseSchema = (0, getSchema_1.getSchema)(response.signature);
|
|
83
|
+
const content = (() => {
|
|
84
|
+
if ('type' in responseSchema && (responseSchema.type === 'void' || responseSchema.type === 'null')) {
|
|
85
|
+
return undefined;
|
|
86
|
+
}
|
|
87
|
+
return {
|
|
88
|
+
'application/json': {
|
|
89
|
+
schema: {
|
|
90
|
+
oneOf: [...existingSchemas, (0, getSchema_1.getSchema)(response.signature)],
|
|
91
|
+
},
|
|
92
|
+
},
|
|
93
|
+
};
|
|
94
|
+
})();
|
|
95
|
+
responses[status] = {
|
|
96
|
+
description: response.description || '',
|
|
97
|
+
content,
|
|
98
|
+
};
|
|
99
|
+
});
|
|
100
|
+
const definition = {
|
|
101
|
+
operationId: endpoint.name,
|
|
102
|
+
summary: endpoint.summary,
|
|
103
|
+
description: (_a = endpoint.description) !== null && _a !== void 0 ? _a : '',
|
|
104
|
+
parameters: []
|
|
105
|
+
.concat(pathParams)
|
|
106
|
+
.concat(queryParams)
|
|
107
|
+
.concat(headerParams),
|
|
108
|
+
requestBody: requestBody,
|
|
109
|
+
responses: responses,
|
|
110
|
+
tags: endpoint.tags,
|
|
111
|
+
};
|
|
112
|
+
paths[path] = Object.assign(Object.assign({}, paths[path]), { [endpoint.method.toLowerCase()]: definition });
|
|
113
|
+
});
|
|
114
|
+
return paths;
|
|
115
|
+
};
|
|
116
|
+
exports.generatePaths = generatePaths;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { OpenApiManager } from '../manager/OpenApiManager';
|
|
2
|
+
export declare const generateOpenApiSpec: (manager: OpenApiManager) => {
|
|
3
|
+
openapi: "3.1.0";
|
|
4
|
+
info: import("../manager/OpenApiManager").ApiDocsHeader;
|
|
5
|
+
paths: Record<string, {
|
|
6
|
+
get?: import("../types").PathDefinition | undefined;
|
|
7
|
+
post?: import("../types").PathDefinition | undefined;
|
|
8
|
+
put?: import("../types").PathDefinition | undefined;
|
|
9
|
+
patch?: import("../types").PathDefinition | undefined;
|
|
10
|
+
delete?: import("../types").PathDefinition | undefined;
|
|
11
|
+
}>;
|
|
12
|
+
components: {
|
|
13
|
+
schemas: Record<string, import("./getSchema").SchemaType>;
|
|
14
|
+
};
|
|
15
|
+
};
|
|
16
|
+
//# sourceMappingURL=generatorModule.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generatorModule.d.ts","sourceRoot":"","sources":["../../../../src/openapi/generatorModule/generatorModule.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAA;AAI1D,eAAO,MAAM,mBAAmB,YAAa,cAAc;;;;;;;;;;;;;CAY1D,CAAA"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.generateOpenApiSpec = void 0;
|
|
4
|
+
const generateComponentSchemas_1 = require("./generateComponentSchemas");
|
|
5
|
+
const generatePaths_1 = require("./generatePaths");
|
|
6
|
+
const generateOpenApiSpec = (manager) => {
|
|
7
|
+
const header = manager.getHeader();
|
|
8
|
+
const endpoints = manager.getEndpoints();
|
|
9
|
+
return {
|
|
10
|
+
openapi: '3.1.0',
|
|
11
|
+
info: header,
|
|
12
|
+
paths: (0, generatePaths_1.generatePaths)(endpoints, manager.getPreferences()),
|
|
13
|
+
components: {
|
|
14
|
+
schemas: (0, generateComponentSchemas_1.generateComponentSchemas)(manager.getExposedModels()),
|
|
15
|
+
},
|
|
16
|
+
};
|
|
17
|
+
};
|
|
18
|
+
exports.generateOpenApiSpec = generateOpenApiSpec;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { ShapeOfType } from '../../openapi/analyzerModule/types';
|
|
2
|
+
export type SchemaType = {
|
|
3
|
+
type: string;
|
|
4
|
+
} | {
|
|
5
|
+
type: string;
|
|
6
|
+
properties: Record<string, SchemaType>;
|
|
7
|
+
required: string[];
|
|
8
|
+
} | {
|
|
9
|
+
oneOf: SchemaType[];
|
|
10
|
+
} | {
|
|
11
|
+
allOf: SchemaType[];
|
|
12
|
+
} | {
|
|
13
|
+
type: 'array';
|
|
14
|
+
items: SchemaType;
|
|
15
|
+
} | {
|
|
16
|
+
type: 'array';
|
|
17
|
+
items: SchemaType;
|
|
18
|
+
minItems: number;
|
|
19
|
+
maxItems: number;
|
|
20
|
+
} | {
|
|
21
|
+
type: 'object';
|
|
22
|
+
additionalProperties: SchemaType;
|
|
23
|
+
} | {
|
|
24
|
+
type: 'string';
|
|
25
|
+
enum: string[];
|
|
26
|
+
} | {
|
|
27
|
+
type: 'string';
|
|
28
|
+
format: string;
|
|
29
|
+
} | {
|
|
30
|
+
type: 'number';
|
|
31
|
+
enum: string[];
|
|
32
|
+
} | {
|
|
33
|
+
$ref: string;
|
|
34
|
+
};
|
|
35
|
+
export declare const getSchema: (shape: string | ShapeOfType[]) => SchemaType;
|
|
36
|
+
//# sourceMappingURL=getSchema.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getSchema.d.ts","sourceRoot":"","sources":["../../../../src/openapi/generatorModule/getSchema.ts"],"names":[],"mappings":"AAAA,OAAO,EAON,WAAW,EAEX,MAAM,oCAAoC,CAAA;AAE3C,MAAM,MAAM,UAAU,GACnB;IAAE,IAAI,EAAE,MAAM,CAAA;CAAE,GAChB;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC;IAAC,QAAQ,EAAE,MAAM,EAAE,CAAA;CAAE,GAC5E;IAAE,KAAK,EAAE,UAAU,EAAE,CAAA;CAAE,GACvB;IAAE,KAAK,EAAE,UAAU,EAAE,CAAA;CAAE,GACvB;IAAE,IAAI,EAAE,OAAO,CAAC;IAAC,KAAK,EAAE,UAAU,CAAA;CAAE,GACpC;IAAE,IAAI,EAAE,OAAO,CAAC;IAAC,KAAK,EAAE,UAAU,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAA;CAAE,GACxE;IAAE,IAAI,EAAE,QAAQ,CAAC;IAAC,oBAAoB,EAAE,UAAU,CAAA;CAAE,GACpD;IAAE,IAAI,EAAE,QAAQ,CAAC;IAAC,IAAI,EAAE,MAAM,EAAE,CAAA;CAAE,GAClC;IAAE,IAAI,EAAE,QAAQ,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,GAClC;IAAE,IAAI,EAAE,QAAQ,CAAC;IAAC,IAAI,EAAE,MAAM,EAAE,CAAA;CAAE,GAClC;IAAE,IAAI,EAAE,MAAM,CAAA;CAAE,CAAA;AAEnB,eAAO,MAAM,SAAS,UAAW,MAAM,GAAG,WAAW,EAAE,KAAG,UA4HzD,CAAA"}
|