@trayio/tray-openapi 2.3.0 → 2.5.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/dist/GenerateHander.test.js +42 -24
- package/dist/GenerateHandler.d.ts +2 -1
- package/dist/GenerateHandler.d.ts.map +1 -1
- package/dist/GenerateHandler.js +27 -3
- package/dist/OpenApiCodecs.d.ts +3 -0
- package/dist/OpenApiCodecs.d.ts.map +1 -0
- package/dist/OpenApiCodecs.js +6 -0
- package/dist/OpenApiSchemaImporter.d.ts +13 -0
- package/dist/OpenApiSchemaImporter.d.ts.map +1 -0
- package/dist/OpenApiSchemaImporter.js +81 -0
- package/dist/OpenApiSchemaImporter.test.d.ts +2 -0
- package/dist/OpenApiSchemaImporter.test.d.ts.map +1 -0
- package/dist/OpenApiSchemaImporter.test.js +21 -0
- package/dist/OpenApiTypeDescriptors.d.ts +59 -0
- package/dist/OpenApiTypeDescriptors.d.ts.map +1 -0
- package/dist/OpenApiTypeDescriptors.js +80 -0
- package/dist/connector/JsonSchemaToTypescriptOptions.d.ts +9 -0
- package/dist/connector/JsonSchemaToTypescriptOptions.d.ts.map +1 -0
- package/dist/connector/JsonSchemaToTypescriptOptions.js +11 -0
- package/dist/connector/input/GenerateInput.d.ts +8 -0
- package/dist/connector/input/GenerateInput.d.ts.map +1 -0
- package/dist/connector/input/GenerateInput.js +8 -0
- package/dist/connector/input/GenerateInput.test.d.ts +2 -0
- package/dist/connector/input/GenerateInput.test.d.ts.map +1 -0
- package/dist/connector/input/GenerateInput.test.js +133 -0
- package/dist/connector/input/ProcessInput.d.ts +4 -0
- package/dist/connector/input/ProcessInput.d.ts.map +1 -0
- package/dist/connector/input/ProcessInput.js +81 -0
- package/dist/connector/input/ProcessInput.test.d.ts +2 -0
- package/dist/connector/input/ProcessInput.test.d.ts.map +1 -0
- package/dist/connector/input/ProcessInput.test.js +227 -0
- package/dist/connector/input/TransformInput.d.ts +4 -0
- package/dist/connector/input/TransformInput.d.ts.map +1 -0
- package/dist/connector/input/TransformInput.js +54 -0
- package/dist/connector/input/TransformInput.test.d.ts +2 -0
- package/dist/connector/input/TransformInput.test.d.ts.map +1 -0
- package/dist/connector/input/TransformInput.test.js +75 -0
- package/dist/single-get-openapi.json +78 -0
- package/dist/templates/connector-template.zip +0 -0
- package/package.json +6 -2
|
@@ -1,13 +1,36 @@
|
|
|
1
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
|
+
};
|
|
2
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
+
const E = __importStar(require("fp-ts/Either"));
|
|
3
27
|
const GenerateHandler_1 = require("./GenerateHandler");
|
|
4
28
|
const getGenerateHandlerInput = (input) => (Object.assign({ connectorNamePascalCase: 'OpenApiTest', operationNamePascalCase: 'GetPhoto', operationNameCamelCase: 'getPhoto', httpMethod: 'get', baseUrl: 'https://jsonplaceholder.typicode.com/', input: [], path: 'photos' }, input));
|
|
5
29
|
describe('GenerateHandler', () => {
|
|
6
30
|
it('it should generate a handler', () => {
|
|
7
31
|
const payload = getGenerateHandlerInput({});
|
|
8
32
|
const generatedHandler = (0, GenerateHandler_1.generateHandler)(payload);
|
|
9
|
-
expect(
|
|
10
|
-
.toEqual(`import { OperationHandlerSetup } from "@trayio/cdk-dsl/connector/operation/OperationHandlerSetup";
|
|
33
|
+
expect(E.right(`import { OperationHandlerSetup } from "@trayio/cdk-dsl/connector/operation/OperationHandlerSetup";
|
|
11
34
|
import { OpenApiTest } from "../OpenApiTest";
|
|
12
35
|
import { GetPhotoInput } from "./input";
|
|
13
36
|
import { GetPhotoOutput } from "./output";
|
|
@@ -20,17 +43,16 @@ describe('GenerateHandler', () => {
|
|
|
20
43
|
handler.usingHttp((http) =>
|
|
21
44
|
http
|
|
22
45
|
.get("https://jsonplaceholder.typicode.com/photos")
|
|
23
|
-
.handleRequest((ctx, input, request) => request
|
|
46
|
+
.handleRequest((ctx, input, request) => request)
|
|
24
47
|
.handleResponse((response) => response.parseWithBodyAsJson())
|
|
25
48
|
)
|
|
26
|
-
);`);
|
|
49
|
+
);`)).toEqual(generatedHandler);
|
|
27
50
|
});
|
|
28
51
|
it('it should generate a handler with a path parameter', () => {
|
|
29
52
|
const input = [{ type: 'string', name: 'photoId', in: 'path' }];
|
|
30
53
|
const payload = getGenerateHandlerInput({ input });
|
|
31
54
|
const generatedHandler = (0, GenerateHandler_1.generateHandler)(payload);
|
|
32
|
-
expect(
|
|
33
|
-
.toEqual(`import { OperationHandlerSetup } from "@trayio/cdk-dsl/connector/operation/OperationHandlerSetup";
|
|
55
|
+
expect(E.right(`import { OperationHandlerSetup } from "@trayio/cdk-dsl/connector/operation/OperationHandlerSetup";
|
|
34
56
|
import { OpenApiTest } from "../OpenApiTest";
|
|
35
57
|
import { GetPhotoInput } from "./input";
|
|
36
58
|
import { GetPhotoOutput } from "./output";
|
|
@@ -43,17 +65,16 @@ describe('GenerateHandler', () => {
|
|
|
43
65
|
handler.usingHttp((http) =>
|
|
44
66
|
http
|
|
45
67
|
.get("https://jsonplaceholder.typicode.com/photos/:photoId")
|
|
46
|
-
.handleRequest((ctx, input, request) => request.addPathParameter("photoId", input.photoId)
|
|
68
|
+
.handleRequest((ctx, input, request) => request.addPathParameter("photoId", input.photoId))
|
|
47
69
|
.handleResponse((response) => response.parseWithBodyAsJson())
|
|
48
70
|
)
|
|
49
|
-
);`);
|
|
71
|
+
);`)).toEqual(generatedHandler);
|
|
50
72
|
});
|
|
51
73
|
it('it should generate a handler with a body input as json', () => {
|
|
52
74
|
const input = [{ type: 'object', name: 'payload', in: 'body' }];
|
|
53
75
|
const payload = getGenerateHandlerInput({ input });
|
|
54
76
|
const generatedHandler = (0, GenerateHandler_1.generateHandler)(payload);
|
|
55
|
-
expect(
|
|
56
|
-
.toEqual(`import { OperationHandlerSetup } from "@trayio/cdk-dsl/connector/operation/OperationHandlerSetup";
|
|
77
|
+
expect(E.right(`import { OperationHandlerSetup } from "@trayio/cdk-dsl/connector/operation/OperationHandlerSetup";
|
|
57
78
|
import { OpenApiTest } from "../OpenApiTest";
|
|
58
79
|
import { GetPhotoInput } from "./input";
|
|
59
80
|
import { GetPhotoOutput } from "./output";
|
|
@@ -66,17 +87,16 @@ describe('GenerateHandler', () => {
|
|
|
66
87
|
handler.usingHttp((http) =>
|
|
67
88
|
http
|
|
68
89
|
.get("https://jsonplaceholder.typicode.com/photos")
|
|
69
|
-
.handleRequest((ctx, input, request) => request.withBodyAsJson(input)
|
|
90
|
+
.handleRequest((ctx, input, request) => request.withBodyAsJson(input))
|
|
70
91
|
.handleResponse((response) => response.parseWithBodyAsJson())
|
|
71
92
|
)
|
|
72
|
-
);`);
|
|
93
|
+
);`)).toEqual(generatedHandler);
|
|
73
94
|
});
|
|
74
95
|
it('it should generate a handler with a query string input', () => {
|
|
75
96
|
const input = [{ type: 'string', name: 'id', in: 'query' }];
|
|
76
97
|
const payload = getGenerateHandlerInput({ input });
|
|
77
98
|
const generatedHandler = (0, GenerateHandler_1.generateHandler)(payload);
|
|
78
|
-
expect(
|
|
79
|
-
.toEqual(`import { OperationHandlerSetup } from "@trayio/cdk-dsl/connector/operation/OperationHandlerSetup";
|
|
99
|
+
expect(E.right(`import { OperationHandlerSetup } from "@trayio/cdk-dsl/connector/operation/OperationHandlerSetup";
|
|
80
100
|
import { OpenApiTest } from "../OpenApiTest";
|
|
81
101
|
import { GetPhotoInput } from "./input";
|
|
82
102
|
import { GetPhotoOutput } from "./output";
|
|
@@ -89,10 +109,10 @@ describe('GenerateHandler', () => {
|
|
|
89
109
|
handler.usingHttp((http) =>
|
|
90
110
|
http
|
|
91
111
|
.get("https://jsonplaceholder.typicode.com/photos")
|
|
92
|
-
.handleRequest((ctx, input, request) => request.addQueryString("id", input.id)
|
|
112
|
+
.handleRequest((ctx, input, request) => request.addQueryString("id", input.id))
|
|
93
113
|
.handleResponse((response) => response.parseWithBodyAsJson())
|
|
94
114
|
)
|
|
95
|
-
);`);
|
|
115
|
+
);`)).toEqual(generatedHandler);
|
|
96
116
|
});
|
|
97
117
|
it('it should generate a handler with a header input', () => {
|
|
98
118
|
const input = [
|
|
@@ -100,8 +120,7 @@ describe('GenerateHandler', () => {
|
|
|
100
120
|
];
|
|
101
121
|
const payload = getGenerateHandlerInput({ input });
|
|
102
122
|
const generatedHandler = (0, GenerateHandler_1.generateHandler)(payload);
|
|
103
|
-
expect(
|
|
104
|
-
.toEqual(`import { OperationHandlerSetup } from "@trayio/cdk-dsl/connector/operation/OperationHandlerSetup";
|
|
123
|
+
expect(E.right(`import { OperationHandlerSetup } from "@trayio/cdk-dsl/connector/operation/OperationHandlerSetup";
|
|
105
124
|
import { OpenApiTest } from "../OpenApiTest";
|
|
106
125
|
import { GetPhotoInput } from "./input";
|
|
107
126
|
import { GetPhotoOutput } from "./output";
|
|
@@ -114,10 +133,10 @@ describe('GenerateHandler', () => {
|
|
|
114
133
|
handler.usingHttp((http) =>
|
|
115
134
|
http
|
|
116
135
|
.get("https://jsonplaceholder.typicode.com/photos")
|
|
117
|
-
.handleRequest((ctx, input, request) => request.addHeader("Content-Type", input.Content-Type)
|
|
136
|
+
.handleRequest((ctx, input, request) => request.addHeader("Content-Type", input.Content-Type))
|
|
118
137
|
.handleResponse((response) => response.parseWithBodyAsJson())
|
|
119
138
|
)
|
|
120
|
-
);`);
|
|
139
|
+
);`)).toEqual(generatedHandler);
|
|
121
140
|
});
|
|
122
141
|
it('it should generate a handler with a query string and path param input', () => {
|
|
123
142
|
const input = [
|
|
@@ -127,8 +146,7 @@ describe('GenerateHandler', () => {
|
|
|
127
146
|
];
|
|
128
147
|
const payload = getGenerateHandlerInput({ input });
|
|
129
148
|
const generatedHandler = (0, GenerateHandler_1.generateHandler)(payload);
|
|
130
|
-
expect(
|
|
131
|
-
.toEqual(`import { OperationHandlerSetup } from "@trayio/cdk-dsl/connector/operation/OperationHandlerSetup";
|
|
149
|
+
expect(E.right(`import { OperationHandlerSetup } from "@trayio/cdk-dsl/connector/operation/OperationHandlerSetup";
|
|
132
150
|
import { OpenApiTest } from "../OpenApiTest";
|
|
133
151
|
import { GetPhotoInput } from "./input";
|
|
134
152
|
import { GetPhotoOutput } from "./output";
|
|
@@ -141,9 +159,9 @@ describe('GenerateHandler', () => {
|
|
|
141
159
|
handler.usingHttp((http) =>
|
|
142
160
|
http
|
|
143
161
|
.get("https://jsonplaceholder.typicode.com/photos/:photoId/:commentId")
|
|
144
|
-
.handleRequest((ctx, input, request) => request.addQueryString("id", input.id).addPathParameter("photoId", input.photoId).addPathParameter("commentId", input.commentId)
|
|
162
|
+
.handleRequest((ctx, input, request) => request.addQueryString("id", input.id).addPathParameter("photoId", input.photoId).addPathParameter("commentId", input.commentId))
|
|
145
163
|
.handleResponse((response) => response.parseWithBodyAsJson())
|
|
146
164
|
)
|
|
147
|
-
);`);
|
|
165
|
+
);`)).toEqual(generatedHandler);
|
|
148
166
|
});
|
|
149
167
|
});
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import * as E from 'fp-ts/Either';
|
|
1
2
|
type InputMethod = 'path' | 'query' | 'body' | 'header';
|
|
2
3
|
type HandlerHttpMethod = 'get' | 'post' | 'put' | 'patch' | 'delete';
|
|
3
4
|
type Input = {
|
|
@@ -14,6 +15,6 @@ export type GenerateHandlerInput = {
|
|
|
14
15
|
path: string;
|
|
15
16
|
input: Input[];
|
|
16
17
|
};
|
|
17
|
-
export declare const generateHandler: ({ connectorNamePascalCase, operationNamePascalCase, operationNameCamelCase, httpMethod, baseUrl, path, input, }: GenerateHandlerInput) => string
|
|
18
|
+
export declare const generateHandler: ({ connectorNamePascalCase, operationNamePascalCase, operationNameCamelCase, httpMethod, baseUrl, path, input, }: GenerateHandlerInput) => E.Either<Error, string>;
|
|
18
19
|
export {};
|
|
19
20
|
//# sourceMappingURL=GenerateHandler.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GenerateHandler.d.ts","sourceRoot":"","sources":["../src/GenerateHandler.ts"],"names":[],"mappings":"AAAA,KAAK,WAAW,GAAG,MAAM,GAAG,OAAO,GAAG,MAAM,GAAG,QAAQ,CAAC;AAExD,KAAK,iBAAiB,GAAG,KAAK,GAAG,MAAM,GAAG,KAAK,GAAG,OAAO,GAAG,QAAQ,CAAC;AAErE,KAAK,KAAK,GAAG;IACZ,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,EAAE,EAAE,WAAW,CAAC;CAChB,CAAC;AAEF,MAAM,MAAM,oBAAoB,GAAG;IAClC,uBAAuB,EAAE,MAAM,CAAC;IAChC,uBAAuB,EAAE,MAAM,CAAC;IAChC,sBAAsB,EAAE,MAAM,CAAC;IAC/B,UAAU,EAAE,iBAAiB,CAAC;IAC9B,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,KAAK,EAAE,CAAC;CACf,CAAC;AAyCF,eAAO,MAAM,eAAe,oHAQzB,oBAAoB,KAAG,
|
|
1
|
+
{"version":3,"file":"GenerateHandler.d.ts","sourceRoot":"","sources":["../src/GenerateHandler.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,cAAc,CAAC;AAElC,KAAK,WAAW,GAAG,MAAM,GAAG,OAAO,GAAG,MAAM,GAAG,QAAQ,CAAC;AAExD,KAAK,iBAAiB,GAAG,KAAK,GAAG,MAAM,GAAG,KAAK,GAAG,OAAO,GAAG,QAAQ,CAAC;AAErE,KAAK,KAAK,GAAG;IACZ,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,EAAE,EAAE,WAAW,CAAC;CAChB,CAAC;AAEF,MAAM,MAAM,oBAAoB,GAAG;IAClC,uBAAuB,EAAE,MAAM,CAAC;IAChC,uBAAuB,EAAE,MAAM,CAAC;IAChC,sBAAsB,EAAE,MAAM,CAAC;IAC/B,UAAU,EAAE,iBAAiB,CAAC;IAC9B,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,KAAK,EAAE,CAAC;CACf,CAAC;AAyCF,eAAO,MAAM,eAAe,oHAQzB,oBAAoB,KAAG,EAAE,MAAM,CAAC,KAAK,EAAE,MAAM,CAoB9C,CAAC"}
|
package/dist/GenerateHandler.js
CHANGED
|
@@ -1,6 +1,30 @@
|
|
|
1
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
|
+
};
|
|
2
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
26
|
exports.generateHandler = void 0;
|
|
27
|
+
const E = __importStar(require("fp-ts/Either"));
|
|
4
28
|
const handleInput = (inputs) => {
|
|
5
29
|
if (!inputs.length) {
|
|
6
30
|
return 'request';
|
|
@@ -32,7 +56,7 @@ const generatePath = (path, inputs) => inputs.reduce((acc, input) => {
|
|
|
32
56
|
}
|
|
33
57
|
return acc;
|
|
34
58
|
}, path);
|
|
35
|
-
const generateHandler = ({ connectorNamePascalCase, operationNamePascalCase, operationNameCamelCase, httpMethod, baseUrl, path, input, }) => `import { OperationHandlerSetup } from "@trayio/cdk-dsl/connector/operation/OperationHandlerSetup";
|
|
59
|
+
const generateHandler = ({ connectorNamePascalCase, operationNamePascalCase, operationNameCamelCase, httpMethod, baseUrl, path, input, }) => E.tryCatch(() => `import { OperationHandlerSetup } from "@trayio/cdk-dsl/connector/operation/OperationHandlerSetup";
|
|
36
60
|
import { ${connectorNamePascalCase} } from "../${connectorNamePascalCase}";
|
|
37
61
|
import { ${operationNamePascalCase}Input } from "./input";
|
|
38
62
|
import { ${operationNamePascalCase}Output } from "./output";
|
|
@@ -45,8 +69,8 @@ const generateHandler = ({ connectorNamePascalCase, operationNamePascalCase, ope
|
|
|
45
69
|
handler.usingHttp((http) =>
|
|
46
70
|
http
|
|
47
71
|
.${httpMethod}("${baseUrl}${generatePath(path, input)}")
|
|
48
|
-
.handleRequest((ctx, input, request) => ${handleInput(input)}
|
|
72
|
+
.handleRequest((ctx, input, request) => ${handleInput(input)})
|
|
49
73
|
.handleResponse((response) => response.parseWithBodyAsJson())
|
|
50
74
|
)
|
|
51
|
-
)
|
|
75
|
+
);`, (error) => new Error(`Failed to generate handler: ${error}`));
|
|
52
76
|
exports.generateHandler = generateHandler;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"OpenApiCodecs.d.ts","sourceRoot":"","sources":["../src/OpenApiCodecs.ts"],"names":[],"mappings":"AACA,OAAO,EACN,aAAa,EAEb,MAAM,0BAA0B,CAAC;AAElC,eAAO,MAAM,gBAAgB,yDAE5B,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.openApiSpecCodec = void 0;
|
|
4
|
+
const TypeCodec_1 = require("@trayio/commons/codec/TypeCodec");
|
|
5
|
+
const OpenApiTypeDescriptors_1 = require("./OpenApiTypeDescriptors");
|
|
6
|
+
exports.openApiSpecCodec = TypeCodec_1.TypeCodec.fromDescriptor(OpenApiTypeDescriptors_1.openApiSpecTypeDescriptor);
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import * as TE from 'fp-ts/TaskEither';
|
|
2
|
+
import { Generator } from '@trayio/generator/generator/Generator';
|
|
3
|
+
export declare class OpenApiSchemaImporter {
|
|
4
|
+
private generator;
|
|
5
|
+
constructor(generator: Generator);
|
|
6
|
+
buildConnector(openApiSpecPath: string, connectorName: string): TE.TaskEither<Error, undefined>;
|
|
7
|
+
private generateOperationFromPath;
|
|
8
|
+
private getOpenApiSpec;
|
|
9
|
+
private generateHandlerFile;
|
|
10
|
+
private generateConnectorDirectory;
|
|
11
|
+
private generateOperationDirectory;
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=OpenApiSchemaImporter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"OpenApiSchemaImporter.d.ts","sourceRoot":"","sources":["../src/OpenApiSchemaImporter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,kBAAkB,CAAC;AAQvC,OAAO,EAAE,SAAS,EAAE,MAAM,uCAAuC,CAAC;AAclE,qBAAa,qBAAqB;IACrB,OAAO,CAAC,SAAS;gBAAT,SAAS,EAAE,SAAS;IAExC,cAAc,CACb,eAAe,EAAE,MAAM,EACvB,aAAa,EAAE,MAAM,GACnB,EAAE,CAAC,UAAU,CAAC,KAAK,EAAE,SAAS,CAAC;IAoClC,OAAO,CAAC,yBAAyB;IA+BjC,OAAO,CAAC,cAAc;IAwBtB,OAAO,CAAC,mBAAmB;IAoC3B,OAAO,CAAC,0BAA0B;IAwBlC,OAAO,CAAC,0BAA0B;CAalC"}
|
|
@@ -0,0 +1,81 @@
|
|
|
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.OpenApiSchemaImporter = void 0;
|
|
27
|
+
const TE = __importStar(require("fp-ts/TaskEither"));
|
|
28
|
+
const E = __importStar(require("fp-ts/Either"));
|
|
29
|
+
const function_1 = require("fp-ts/function");
|
|
30
|
+
const fse = __importStar(require("fs-extra"));
|
|
31
|
+
const Array_1 = require("fp-ts/Array");
|
|
32
|
+
const StringExtensions_1 = require("@trayio/commons/string/StringExtensions");
|
|
33
|
+
const lodash_1 = require("lodash");
|
|
34
|
+
const Task_1 = require("@trayio/commons/task/Task");
|
|
35
|
+
const OpenApiCodecs_1 = require("./OpenApiCodecs");
|
|
36
|
+
const GenerateHandler_1 = require("./GenerateHandler");
|
|
37
|
+
class OpenApiSchemaImporter {
|
|
38
|
+
constructor(generator) {
|
|
39
|
+
this.generator = generator;
|
|
40
|
+
}
|
|
41
|
+
buildConnector(openApiSpecPath, connectorName) {
|
|
42
|
+
return (0, function_1.pipe)(this.generateConnectorDirectory(connectorName), TE.bindTo('connectorPath'), TE.bind('openApiSpec', () => (0, Task_1.createTaskEitherFromEither)(this.getOpenApiSpec(openApiSpecPath))), TE.bind('paths', ({ openApiSpec }) => TE.right(Object.keys(openApiSpec.paths).map((path) => ({
|
|
43
|
+
path,
|
|
44
|
+
routes: Object.keys(openApiSpec.paths[path]).map((route) => ({
|
|
45
|
+
method: route,
|
|
46
|
+
path: openApiSpec.paths[path][route],
|
|
47
|
+
})),
|
|
48
|
+
})))), TE.map(({ openApiSpec, connectorPath, paths }) => (0, Array_1.traverse)(TE.ApplicativeSeq)((path) => (0, Task_1.createTaskEitherFromEither)(this.generateOperationFromPath(path, connectorPath, openApiSpec.servers[0].url, connectorName)))(paths)), TE.map(() => undefined));
|
|
49
|
+
}
|
|
50
|
+
generateOperationFromPath(path, connectorPath, baseUrl, connectorName) {
|
|
51
|
+
return (0, function_1.pipe)((0, Array_1.traverse)(E.Applicative)((route) => (0, function_1.pipe)(this.generateOperationDirectory(connectorPath, route.path.operationId), E.chain((operationPath) => this.generateHandlerFile(operationPath, route.method, baseUrl, path.path, connectorName, route.path.operationId)), E.map(() => undefined)))(path.routes), E.map(() => undefined));
|
|
52
|
+
}
|
|
53
|
+
getOpenApiSpec(openApiSpecPath) {
|
|
54
|
+
return (0, function_1.pipe)(E.tryCatch(() => fse.readFileSync(openApiSpecPath, 'utf-8'), (error) => new Error(`Failed to read OpenAPI spec from path ${openApiSpecPath}: ${error}`)), E.chain((openApiSpec) => E.tryCatch(() => JSON.parse(openApiSpec), (error) => new Error(`Failed to parse OpenAPI spec as JSON from path ${openApiSpecPath}: ${error}`))), E.chain((openApiSpec) => OpenApiCodecs_1.openApiSpecCodec.decode(openApiSpec)));
|
|
55
|
+
}
|
|
56
|
+
generateHandlerFile(operationPath, httpMethod, baseUrl, path, connectorName, operationName) {
|
|
57
|
+
return (0, function_1.pipe)(E.right({
|
|
58
|
+
connectorNamePascalCase: StringExtensions_1.StringExtensions.pascalCase(connectorName),
|
|
59
|
+
operationNameCamelCase: (0, lodash_1.camelCase)(operationName),
|
|
60
|
+
operationNamePascalCase: StringExtensions_1.StringExtensions.pascalCase(operationName),
|
|
61
|
+
httpMethod,
|
|
62
|
+
baseUrl,
|
|
63
|
+
path,
|
|
64
|
+
input: [],
|
|
65
|
+
}), E.chain((parameters) => (0, GenerateHandler_1.generateHandler)(parameters)), E.chain((handler) => E.tryCatch(() => {
|
|
66
|
+
fse.writeFileSync(`${operationPath}/handler.ts`, handler, 'utf-8');
|
|
67
|
+
}, (error) => new Error(`Failed to write handler to file system: ${error}`))), E.map(() => undefined), E.mapLeft((error) => new Error(`Failed to generate handler for operation: ${error}`)));
|
|
68
|
+
}
|
|
69
|
+
generateConnectorDirectory(connectorName) {
|
|
70
|
+
return (0, function_1.pipe)(TE.right({
|
|
71
|
+
connectorNameTitleCase: StringExtensions_1.StringExtensions.titleCase(connectorName),
|
|
72
|
+
connectorNameKebabCase: (0, lodash_1.kebabCase)(connectorName),
|
|
73
|
+
connectorNamePascalCase: StringExtensions_1.StringExtensions.pascalCase(connectorName),
|
|
74
|
+
connectorNameCamelCase: (0, lodash_1.camelCase)(connectorName),
|
|
75
|
+
}), TE.chain((parameters) => this.generator.generate(`${__dirname}/templates/connector-template.zip`, `${process.cwd()}/test`, parameters)), TE.map(() => `${process.cwd()}/test/${(0, lodash_1.kebabCase)(connectorName)}`), TE.mapLeft((error) => new Error(`Failed to generate connector directory: ${error}`)));
|
|
76
|
+
}
|
|
77
|
+
generateOperationDirectory(connectorPath, operationName) {
|
|
78
|
+
return (0, function_1.pipe)(E.tryCatch(() => fse.ensureDirSync(`${connectorPath}/src/${(0, lodash_1.kebabCase)(operationName)}`), (error) => new Error(`Failed to create operation directory: ${error}`)), E.map(() => `${connectorPath}/src/${(0, lodash_1.kebabCase)(operationName)}`));
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
exports.OpenApiSchemaImporter = OpenApiSchemaImporter;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"OpenApiSchemaImporter.test.d.ts","sourceRoot":"","sources":["../src/OpenApiSchemaImporter.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
const NodeFsGenerator_1 = require("@trayio/generator/generator/NodeFsGenerator");
|
|
13
|
+
const OpenApiSchemaImporter_1 = require("./OpenApiSchemaImporter");
|
|
14
|
+
describe('openApiSchemaImporter', () => {
|
|
15
|
+
const generator = new NodeFsGenerator_1.NodeFsGenerator();
|
|
16
|
+
const openApiSchemaImporter = new OpenApiSchemaImporter_1.OpenApiSchemaImporter(generator);
|
|
17
|
+
it('should decode the openApiSpec', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
18
|
+
const schema = yield openApiSchemaImporter.buildConnector(`${__dirname}/single-get-openapi.json`, 'testConnector')();
|
|
19
|
+
expect(schema._tag).toEqual('Right');
|
|
20
|
+
}));
|
|
21
|
+
});
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import * as t from 'io-ts';
|
|
2
|
+
import * as O from 'fp-ts/Option';
|
|
3
|
+
export type Path = {
|
|
4
|
+
description: string;
|
|
5
|
+
tags: string[];
|
|
6
|
+
operationId: string;
|
|
7
|
+
parameters: O.Option<Parameter[]>;
|
|
8
|
+
requestBody: O.Option<RequestBody>;
|
|
9
|
+
};
|
|
10
|
+
export type Parameter = {
|
|
11
|
+
name: string;
|
|
12
|
+
in: string;
|
|
13
|
+
description: string;
|
|
14
|
+
required: boolean;
|
|
15
|
+
schema: {
|
|
16
|
+
type: string;
|
|
17
|
+
format: O.Option<string>;
|
|
18
|
+
};
|
|
19
|
+
};
|
|
20
|
+
export type RequestBody = {
|
|
21
|
+
content: Record<string, MediaType>;
|
|
22
|
+
};
|
|
23
|
+
type MediaType = {
|
|
24
|
+
schema: ArraySchema | ObjectSchema;
|
|
25
|
+
};
|
|
26
|
+
export type OpenApiHttpMethod = 'get' | 'post' | 'put' | 'patch' | 'delete';
|
|
27
|
+
type ArraySchema = {
|
|
28
|
+
type: 'array';
|
|
29
|
+
items: {
|
|
30
|
+
$ref: string;
|
|
31
|
+
};
|
|
32
|
+
};
|
|
33
|
+
type ObjectSchema = {
|
|
34
|
+
type: 'object';
|
|
35
|
+
required?: string[];
|
|
36
|
+
properties: Record<string, PropertySchema>;
|
|
37
|
+
};
|
|
38
|
+
type PropertySchema = {
|
|
39
|
+
type: string;
|
|
40
|
+
} | ArraySchema | ObjectSchema;
|
|
41
|
+
type ComponentSchema = {
|
|
42
|
+
schemas: Record<string, ArraySchema | ObjectSchema>;
|
|
43
|
+
};
|
|
44
|
+
export type OpenAPISchema = {
|
|
45
|
+
openapi: string;
|
|
46
|
+
info: {
|
|
47
|
+
title: string;
|
|
48
|
+
description: string;
|
|
49
|
+
version: string;
|
|
50
|
+
};
|
|
51
|
+
servers: {
|
|
52
|
+
url: string;
|
|
53
|
+
}[];
|
|
54
|
+
paths: Record<string, Partial<Record<OpenApiHttpMethod, Path>>>;
|
|
55
|
+
components: ComponentSchema;
|
|
56
|
+
};
|
|
57
|
+
export declare const openApiSpecTypeDescriptor: t.Type<OpenAPISchema, unknown>;
|
|
58
|
+
export {};
|
|
59
|
+
//# sourceMappingURL=OpenApiTypeDescriptors.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"OpenApiTypeDescriptors.d.ts","sourceRoot":"","sources":["../src/OpenApiTypeDescriptors.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,OAAO,CAAC;AAE3B,OAAO,KAAK,CAAC,MAAM,cAAc,CAAC;AAGlC,MAAM,MAAM,IAAI,GAAG;IAClB,WAAW,EAAE,MAAM,CAAC;IACpB,IAAI,EAAE,MAAM,EAAE,CAAC;IACf,WAAW,EAAE,MAAM,CAAC;IACpB,UAAU,EAAE,CAAC,CAAC,MAAM,CAAC,SAAS,EAAE,CAAC,CAAC;IAClC,WAAW,EAAE,CAAC,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC;CACnC,CAAC;AAEF,MAAM,MAAM,SAAS,GAAG;IACvB,IAAI,EAAE,MAAM,CAAC;IACb,EAAE,EAAE,MAAM,CAAC;IACX,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE,OAAO,CAAC;IAClB,MAAM,EAAE;QACP,IAAI,EAAE,MAAM,CAAC;QACb,MAAM,EAAE,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;KACzB,CAAC;CACF,CAAC;AAEF,MAAM,MAAM,WAAW,GAAG;IACzB,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC;CACnC,CAAC;AAEF,KAAK,SAAS,GAAG;IAChB,MAAM,EAAE,WAAW,GAAG,YAAY,CAAC;CACnC,CAAC;AAEF,MAAM,MAAM,iBAAiB,GAAG,KAAK,GAAG,MAAM,GAAG,KAAK,GAAG,OAAO,GAAG,QAAQ,CAAC;AAE5E,KAAK,WAAW,GAAG;IAClB,IAAI,EAAE,OAAO,CAAC;IACd,KAAK,EAAE;QACN,IAAI,EAAE,MAAM,CAAC;KACb,CAAC;CACF,CAAC;AAEF,KAAK,YAAY,GAAG;IACnB,IAAI,EAAE,QAAQ,CAAC;IACf,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;IACpB,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,cAAc,CAAC,CAAC;CAC3C,CAAC;AAEF,KAAK,cAAc,GAAG;IAAE,IAAI,EAAE,MAAM,CAAA;CAAE,GAAG,WAAW,GAAG,YAAY,CAAC;AAEpE,KAAK,eAAe,GAAG;IAAE,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,WAAW,GAAG,YAAY,CAAC,CAAA;CAAE,CAAC;AAE/E,MAAM,MAAM,aAAa,GAAG;IAC3B,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE;QACL,KAAK,EAAE,MAAM,CAAC;QACd,WAAW,EAAE,MAAM,CAAC;QACpB,OAAO,EAAE,MAAM,CAAC;KAChB,CAAC;IACF,OAAO,EAAE;QACR,GAAG,EAAE,MAAM,CAAC;KACZ,EAAE,CAAC;IACJ,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,MAAM,CAAC,iBAAiB,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC;IAChE,UAAU,EAAE,eAAe,CAAC;CAC5B,CAAC;AAoEF,eAAO,MAAM,yBAAyB,EAAE,CAAC,CAAC,IAAI,CAAC,aAAa,EAAE,OAAO,CAWpE,CAAC"}
|
|
@@ -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.openApiSpecTypeDescriptor = void 0;
|
|
27
|
+
const t = __importStar(require("io-ts"));
|
|
28
|
+
const io_ts_types_1 = require("io-ts-types");
|
|
29
|
+
const TypeCodec_1 = require("@trayio/commons/codec/TypeCodec");
|
|
30
|
+
const openApiSpecPropertySchemaTypeDescriptor = t.type({ type: t.string });
|
|
31
|
+
const openApiSpecObjectSchemaTypeDescriptor = t.type({
|
|
32
|
+
type: t.literal('object'),
|
|
33
|
+
properties: t.record(t.string, openApiSpecPropertySchemaTypeDescriptor),
|
|
34
|
+
});
|
|
35
|
+
const openApiSpecArraySchemaTypeDescriptor = t.type({ type: t.literal('array'), items: t.any });
|
|
36
|
+
const openApiSpecMediaTypeTypeDescriptor = t.type({
|
|
37
|
+
schema: t.union([
|
|
38
|
+
openApiSpecObjectSchemaTypeDescriptor,
|
|
39
|
+
openApiSpecArraySchemaTypeDescriptor,
|
|
40
|
+
]),
|
|
41
|
+
});
|
|
42
|
+
const openApiSpecComponentSchemaTypeDescriptor = t.type({
|
|
43
|
+
schemas: t.record(t.string, t.union([
|
|
44
|
+
openApiSpecObjectSchemaTypeDescriptor,
|
|
45
|
+
openApiSpecArraySchemaTypeDescriptor,
|
|
46
|
+
])),
|
|
47
|
+
});
|
|
48
|
+
const openApiSpecRequestBodyTypeDescriptor = t.type({
|
|
49
|
+
content: t.record(t.string, openApiSpecMediaTypeTypeDescriptor),
|
|
50
|
+
});
|
|
51
|
+
const openApiSpecPathTypeDescriptor = t.type({
|
|
52
|
+
description: t.string,
|
|
53
|
+
tags: t.array(t.string),
|
|
54
|
+
operationId: t.string,
|
|
55
|
+
parameters: (0, io_ts_types_1.optionFromNullable)(t.array(t.type({
|
|
56
|
+
name: t.string,
|
|
57
|
+
in: t.string,
|
|
58
|
+
description: t.string,
|
|
59
|
+
required: t.boolean,
|
|
60
|
+
schema: t.type({
|
|
61
|
+
type: t.string,
|
|
62
|
+
format: (0, io_ts_types_1.optionFromNullable)(t.string),
|
|
63
|
+
}),
|
|
64
|
+
}))),
|
|
65
|
+
requestBody: (0, io_ts_types_1.optionFromNullable)(openApiSpecRequestBodyTypeDescriptor),
|
|
66
|
+
});
|
|
67
|
+
const httpKeys = t.keyof({
|
|
68
|
+
get: null,
|
|
69
|
+
post: null,
|
|
70
|
+
put: null,
|
|
71
|
+
patch: null,
|
|
72
|
+
delete: null,
|
|
73
|
+
});
|
|
74
|
+
exports.openApiSpecTypeDescriptor = t.type({
|
|
75
|
+
openapi: t.string,
|
|
76
|
+
info: t.type({ title: t.string, description: t.string, version: t.string }),
|
|
77
|
+
servers: t.array(t.type({ url: t.string })),
|
|
78
|
+
paths: t.record(t.string, TypeCodec_1.TypeCodec.partialRecord(httpKeys, openApiSpecPathTypeDescriptor)),
|
|
79
|
+
components: openApiSpecComponentSchemaTypeDescriptor,
|
|
80
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"JsonSchemaToTypescriptOptions.d.ts","sourceRoot":"","sources":["../../src/connector/JsonSchemaToTypescriptOptions.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,6BAA6B;;;;;;;CAOzC,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.JsonSchemaToTypescriptOptions = void 0;
|
|
4
|
+
exports.JsonSchemaToTypescriptOptions = {
|
|
5
|
+
bannerComment: '',
|
|
6
|
+
format: true,
|
|
7
|
+
style: {
|
|
8
|
+
singleQuote: true,
|
|
9
|
+
useTabs: true,
|
|
10
|
+
},
|
|
11
|
+
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { JSONSchema4 } from 'json-schema';
|
|
2
|
+
import * as TE from 'fp-ts/TaskEither';
|
|
3
|
+
export type GenerateInputParams = {
|
|
4
|
+
operationNameCamelCase: string;
|
|
5
|
+
parameters: JSONSchema4;
|
|
6
|
+
};
|
|
7
|
+
export declare const generateInput: ({ operationNameCamelCase, parameters, }: GenerateInputParams) => TE.TaskEither<Error, string>;
|
|
8
|
+
//# sourceMappingURL=GenerateInput.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"GenerateInput.d.ts","sourceRoot":"","sources":["../../../src/connector/input/GenerateInput.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAE1C,OAAO,KAAK,EAAE,MAAM,kBAAkB,CAAC;AAGvC,MAAM,MAAM,mBAAmB,GAAG;IACjC,sBAAsB,EAAE,MAAM,CAAC;IAC/B,UAAU,EAAE,WAAW,CAAC;CACxB,CAAC;AAEF,eAAO,MAAM,aAAa,4CAGvB,mBAAmB,KAAG,GAAG,UAAU,CAAC,KAAK,EAAE,MAAM,CASlD,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.generateInput = void 0;
|
|
4
|
+
const json_schema_to_typescript_1 = require("json-schema-to-typescript");
|
|
5
|
+
const TaskEither_1 = require("fp-ts/TaskEither");
|
|
6
|
+
const JsonSchemaToTypescriptOptions_1 = require("../JsonSchemaToTypescriptOptions");
|
|
7
|
+
const generateInput = ({ operationNameCamelCase, parameters, }) => (0, TaskEither_1.tryCatch)(() => (0, json_schema_to_typescript_1.compile)(parameters, `${operationNameCamelCase}Input`, JsonSchemaToTypescriptOptions_1.JsonSchemaToTypescriptOptions), (reason) => new Error(`${reason}`));
|
|
8
|
+
exports.generateInput = generateInput;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"GenerateInput.test.d.ts","sourceRoot":"","sources":["../../../src/connector/input/GenerateInput.test.ts"],"names":[],"mappings":""}
|