@trayio/cdk-dsl 3.14.1-unstable → 3.16.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/README.md
CHANGED
|
@@ -858,16 +858,6 @@ export const myOperationHandler =
|
|
|
858
858
|
);
|
|
859
859
|
```
|
|
860
860
|
|
|
861
|
-
### How to enable / disable raw http operation.
|
|
862
|
-
|
|
863
|
-
By default, all the connectors come with a Raw Http Operation. You can disable it by updating the config in the connector.json
|
|
864
|
-
|
|
865
|
-
```typescript
|
|
866
|
-
{
|
|
867
|
-
"rawHttp": {
|
|
868
|
-
"enabled": false
|
|
869
|
-
}
|
|
870
|
-
}
|
|
871
861
|
## Error Handling
|
|
872
862
|
|
|
873
863
|
You could use `withErrorHandling()` on the `response` to display custom error messages to the users.
|
|
@@ -897,3 +887,32 @@ handler.usingHttp((http) =>
|
|
|
897
887
|
)
|
|
898
888
|
);
|
|
899
889
|
```
|
|
890
|
+
|
|
891
|
+
### JSON Error Handling
|
|
892
|
+
|
|
893
|
+
You can decode a error body that uses the JSON content type and access the body inside of an error handling function. To enrich the errors that can are surfaced to the user.
|
|
894
|
+
|
|
895
|
+
```typescript
|
|
896
|
+
handler.withGlobalConfiguration(globalConfigHttp).usingHttp((http) =>
|
|
897
|
+
http
|
|
898
|
+
.get("/user/repos")
|
|
899
|
+
.handleRequest((ctx, input, request) => request.withoutBody())
|
|
900
|
+
.handleResponse((ctx, input, response) =>
|
|
901
|
+
response
|
|
902
|
+
.withJsonErrorHandling<{ message: string }>((body) =>
|
|
903
|
+
OperationHandlerResult.failure(
|
|
904
|
+
OperationHandlerError.apiError(
|
|
905
|
+
`API returned an error: ${
|
|
906
|
+
body.message
|
|
907
|
+
}, status code: ${response.getStatusCode()}`,
|
|
908
|
+
{
|
|
909
|
+
statusCode: response.getStatusCode(),
|
|
910
|
+
}
|
|
911
|
+
)
|
|
912
|
+
)
|
|
913
|
+
)
|
|
914
|
+
.parseWithBodyAsJson()
|
|
915
|
+
)
|
|
916
|
+
)
|
|
917
|
+
);
|
|
918
|
+
```
|
|
@@ -34,16 +34,17 @@ export declare class HttpOperationRequest {
|
|
|
34
34
|
constructor(path: string, method: HttpMethod, request: HttpRequest, contentType: O.Option<HttpContentType>, body: HttpOperationBody);
|
|
35
35
|
}
|
|
36
36
|
export type HttpOperationRequestHandler<AUTH extends OperationHandlerAuth<unknown, unknown>, IN> = (ctx: OperationHandlerContext<AUTH>, input: IN, request: HttpOperationRequestBuilder) => HttpOperationRequest;
|
|
37
|
-
export type HttpOperationResponseErrorHandling<OUT> = () => OperationHandlerResult<OUT>;
|
|
38
37
|
export type HttpOperationResponseParser<BODY, OUT> = (body: BODY) => OperationHandlerResult<OUT>;
|
|
39
|
-
export declare class HttpOperationResponseBuilder<OUT> {
|
|
38
|
+
export declare class HttpOperationResponseBuilder<ERROR, OUT> {
|
|
40
39
|
private response;
|
|
41
40
|
private errorHandling;
|
|
42
|
-
|
|
41
|
+
private errorContentType;
|
|
42
|
+
constructor(response: HttpResponse, errorHandling: HttpOperationResponseParser<ERROR, OUT>, errorContentType: O.Option<HttpContentType>);
|
|
43
43
|
getStatusCode(): number;
|
|
44
44
|
getHeader(name: string): HttpHeaderValue | undefined;
|
|
45
45
|
getHeaders(): HttpHeaders;
|
|
46
|
-
withErrorHandling(errorHandling:
|
|
46
|
+
withErrorHandling(errorHandling: HttpOperationResponseParser<undefined, OUT>): HttpOperationResponseBuilder<undefined, OUT>;
|
|
47
|
+
withJsonErrorHandling<T extends DynamicType>(errorHandling: HttpOperationResponseParser<T, OUT>): HttpOperationResponseBuilder<T, OUT>;
|
|
47
48
|
parseWithoutBody(responseParser: HttpOperationResponseParser<undefined, OUT>): HttpOperationResponse<OUT>;
|
|
48
49
|
parseWithBodyAsText(responseParser: HttpOperationResponseParser<string, OUT>): HttpOperationResponse<OUT>;
|
|
49
50
|
parseWithBodyAsJson<T extends DynamicType>(responseParser?: HttpOperationResponseParser<T, OUT>): HttpOperationResponse<OUT>;
|
|
@@ -51,12 +52,13 @@ export declare class HttpOperationResponseBuilder<OUT> {
|
|
|
51
52
|
}
|
|
52
53
|
export declare class HttpOperationResponse<OUT> {
|
|
53
54
|
readonly response: HttpResponse;
|
|
54
|
-
readonly errorHandling:
|
|
55
|
+
readonly errorHandling: HttpOperationResponseParser<any, OUT>;
|
|
55
56
|
readonly contentType: O.Option<HttpContentType>;
|
|
56
57
|
readonly responseParser: HttpOperationResponseParser<any, OUT>;
|
|
57
|
-
|
|
58
|
+
readonly errorContentType: O.Option<HttpContentType>;
|
|
59
|
+
constructor(response: HttpResponse, errorHandling: HttpOperationResponseParser<any, OUT>, errorContentType: O.Option<HttpContentType>, contentType: O.Option<HttpContentType>, responseParser: HttpOperationResponseParser<any, OUT>);
|
|
58
60
|
}
|
|
59
|
-
export type HttpOperationResponseHandler<AUTH extends OperationHandlerAuth<unknown, unknown>, IN, OUT> = (ctx: OperationHandlerContext<AUTH>, input: IN, response: HttpOperationResponseBuilder<OUT>) => HttpOperationResponse<OUT>;
|
|
61
|
+
export type HttpOperationResponseHandler<AUTH extends OperationHandlerAuth<unknown, unknown>, IN, OUT> = (ctx: OperationHandlerContext<AUTH>, input: IN, response: HttpOperationResponseBuilder<any, OUT>) => HttpOperationResponse<OUT>;
|
|
60
62
|
export declare class HttpOperationHandler<AUTH extends OperationHandlerAuth<unknown, unknown>, IN, OUT> {
|
|
61
63
|
readonly _tag: 'HttpOperationHandler';
|
|
62
64
|
readonly request: HttpOperationRequestBuilder;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"HttpOperationHandler.d.ts","sourceRoot":"","sources":["../../../src/connector/operation/HttpOperationHandler.ts"],"names":[],"mappings":"AAAA,OAAO,EAEN,eAAe,EACf,UAAU,EACV,WAAW,EACX,eAAe,EACf,YAAY,EACZ,WAAW,EACX,MAAM,2BAA2B,CAAC;AACnC,OAAO,EACN,aAAa,EACb,WAAW,EACX,MAAM,yCAAyC,CAAC;AAIjD,OA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,EAAE,MAAM,GAAG,2BAA2B;IAI3D,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,eAAe,GAAG,2BAA2B;CAS5E;AAED,qBAAa,oBAAoB;IAChC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,MAAM,EAAE,UAAU,CAAC;IAC5B,QAAQ,CAAC,OAAO,EAAE,WAAW,CAAC;IAC9B,QAAQ,CAAC,WAAW,EAAE,CAAC,CAAC,MAAM,CAAC,eAAe,CAAC,CAAC;IAChD,QAAQ,CAAC,IAAI,EAAE,iBAAiB,CAAC;gBAGhC,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,UAAU,EAClB,OAAO,EAAE,WAAW,EACpB,WAAW,EAAE,CAAC,CAAC,MAAM,CAAC,eAAe,CAAC,EACtC,IAAI,EAAE,iBAAiB;CAQxB;AAED,MAAM,MAAM,2BAA2B,CACtC,IAAI,SAAS,oBAAoB,CAAC,OAAO,EAAE,OAAO,CAAC,EACnD,EAAE,IACC,CACH,GAAG,EAAE,uBAAuB,CAAC,IAAI,CAAC,EAClC,KAAK,EAAE,EAAE,EACT,OAAO,EAAE,2BAA2B,KAChC,oBAAoB,CAAC;AAE1B,MAAM,MAAM,
|
|
1
|
+
{"version":3,"file":"HttpOperationHandler.d.ts","sourceRoot":"","sources":["../../../src/connector/operation/HttpOperationHandler.ts"],"names":[],"mappings":"AAAA,OAAO,EAEN,eAAe,EACf,UAAU,EACV,WAAW,EACX,eAAe,EACf,YAAY,EACZ,WAAW,EACX,MAAM,2BAA2B,CAAC;AACnC,OAAO,EACN,aAAa,EACb,WAAW,EACX,MAAM,yCAAyC,CAAC;AAIjD,OAAO,KAAK,CAAC,MAAM,cAAc,CAAC;AAClC,OAAO,EACN,oBAAoB,EACpB,uBAAuB,EACvB,sBAAsB,EACtB,aAAa,EACb,MAAM,oBAAoB,CAAC;AAiB5B,MAAM,MAAM,0BAA0B,GAAG;IACxC,MAAM,EAAE,MA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C,OAAO,EAAE,OAAO,CAAC,EACnD,EAAE,EACF,GAAG;IAEH,OAAO,CAAC,OAAO,CAA8B;gBAEjC,OAAO,EAAE,2BAA2B;IAIhD,aAAa,CACZ,cAAc,EAAE,2BAA2B,CAAC,IAAI,EAAE,EAAE,CAAC,GACnD,yCAAyC,CAAC,IAAI,EAAE,EAAE,EAAE,GAAG,CAAC;CAM3D;AAED,qBAAa,iCAAiC,CAC7C,IAAI,SAAS,oBAAoB,CAAC,OAAO,EAAE,OAAO,CAAC,EACnD,EAAE,EACF,GAAG;IAEH,GAAG,CAAC,IAAI,EAAE,MAAM,GAAG,wCAAwC,CAAC,IAAI,EAAE,EAAE,EAAE,GAAG,CAAC;IAM1E,IAAI,CAAC,IAAI,EAAE,MAAM,GAAG,wCAAwC,CAAC,IAAI,EAAE,EAAE,EAAE,GAAG,CAAC;IAM3E,GAAG,CAAC,IAAI,EAAE,MAAM,GAAG,wCAAwC,CAAC,IAAI,EAAE,EAAE,EAAE,GAAG,CAAC;IAM1E,KAAK,CAAC,IAAI,EAAE,MAAM,GAAG,wCAAwC,CAAC,IAAI,EAAE,EAAE,EAAE,GAAG,CAAC;IAM5E,MAAM,CACL,IAAI,EAAE,MAAM,GACV,wCAAwC,CAAC,IAAI,EAAE,EAAE,EAAE,GAAG,CAAC;IAM1D,OAAO,CAAC,cAAc;CAatB;AAED,MAAM,MAAM,yBAAyB,CACpC,IAAI,SAAS,oBAAoB,CAAC,OAAO,EAAE,OAAO,CAAC,EACnD,EAAE,EACF,GAAG,IACA,CACH,IAAI,EAAE,iCAAiC,CAAC,IAAI,EAAE,EAAE,EAAE,GAAG,CAAC,KAClD,oBAAoB,CAAC,IAAI,EAAE,EAAE,EAAE,GAAG,CAAC,CAAC"}
|
|
@@ -132,9 +132,11 @@ exports.HttpOperationRequest = HttpOperationRequest;
|
|
|
132
132
|
class HttpOperationResponseBuilder {
|
|
133
133
|
response;
|
|
134
134
|
errorHandling;
|
|
135
|
-
|
|
135
|
+
errorContentType;
|
|
136
|
+
constructor(response, errorHandling, errorContentType) {
|
|
136
137
|
this.response = response;
|
|
137
138
|
this.errorHandling = errorHandling;
|
|
139
|
+
this.errorContentType = errorContentType;
|
|
138
140
|
}
|
|
139
141
|
getStatusCode() {
|
|
140
142
|
return this.response.statusCode;
|
|
@@ -146,19 +148,22 @@ class HttpOperationResponseBuilder {
|
|
|
146
148
|
return this.response.headers;
|
|
147
149
|
}
|
|
148
150
|
withErrorHandling(errorHandling) {
|
|
149
|
-
return new HttpOperationResponseBuilder(this.response, errorHandling);
|
|
151
|
+
return new HttpOperationResponseBuilder(this.response, errorHandling, O.none);
|
|
152
|
+
}
|
|
153
|
+
withJsonErrorHandling(errorHandling) {
|
|
154
|
+
return new HttpOperationResponseBuilder(this.response, errorHandling, O.some(Http_1.HttpContentType.Json));
|
|
150
155
|
}
|
|
151
156
|
parseWithoutBody(responseParser) {
|
|
152
|
-
return new HttpOperationResponse(this.response, this.errorHandling, O.none, responseParser);
|
|
157
|
+
return new HttpOperationResponse(this.response, this.errorHandling, this.errorContentType, O.none, responseParser);
|
|
153
158
|
}
|
|
154
159
|
parseWithBodyAsText(responseParser) {
|
|
155
|
-
return new HttpOperationResponse(this.response, this.errorHandling, O.some(Http_1.HttpContentType.Text), responseParser);
|
|
160
|
+
return new HttpOperationResponse(this.response, this.errorHandling, this.errorContentType, O.some(Http_1.HttpContentType.Text), responseParser);
|
|
156
161
|
}
|
|
157
162
|
parseWithBodyAsJson(responseParser = (body) => OperationHandler_1.OperationHandlerResult.success(body)) {
|
|
158
|
-
return new HttpOperationResponse(this.response, this.errorHandling, O.some(Http_1.HttpContentType.Json), responseParser);
|
|
163
|
+
return new HttpOperationResponse(this.response, this.errorHandling, this.errorContentType, O.some(Http_1.HttpContentType.Json), responseParser);
|
|
159
164
|
}
|
|
160
165
|
parseWithBodyAsFile(responseParser) {
|
|
161
|
-
return new HttpOperationResponse(this.response, this.errorHandling, O.some(Http_1.HttpContentType.OctetStream), responseParser);
|
|
166
|
+
return new HttpOperationResponse(this.response, this.errorHandling, this.errorContentType, O.some(Http_1.HttpContentType.OctetStream), responseParser);
|
|
162
167
|
}
|
|
163
168
|
}
|
|
164
169
|
exports.HttpOperationResponseBuilder = HttpOperationResponseBuilder;
|
|
@@ -167,7 +172,9 @@ class HttpOperationResponse {
|
|
|
167
172
|
errorHandling;
|
|
168
173
|
contentType;
|
|
169
174
|
responseParser;
|
|
170
|
-
|
|
175
|
+
errorContentType;
|
|
176
|
+
constructor(response, errorHandling, errorContentType, contentType, responseParser) {
|
|
177
|
+
this.errorContentType = errorContentType;
|
|
171
178
|
this.response = response;
|
|
172
179
|
this.errorHandling = errorHandling;
|
|
173
180
|
this.contentType = contentType;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@trayio/cdk-dsl",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.16.0",
|
|
4
4
|
"description": "A DSL for connector development",
|
|
5
5
|
"exports": {
|
|
6
6
|
"./*": "./dist/*.js"
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
"access": "public"
|
|
15
15
|
},
|
|
16
16
|
"dependencies": {
|
|
17
|
-
"@trayio/commons": "3.
|
|
17
|
+
"@trayio/commons": "3.16.0"
|
|
18
18
|
},
|
|
19
19
|
"typesVersions": {
|
|
20
20
|
"*": {
|