@trayio/cdk-dsl 2.16.0 → 2.18.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
|
@@ -376,13 +376,15 @@ The previous handler makes a `GET` http request, which is defined by the `http.g
|
|
|
376
376
|
- `withBearerToken(token)`: Adds an `Authorization` header with a `Bearer` token
|
|
377
377
|
- `addQueryString(name, value)`: Adds a query string to the request, the value will be url encoded
|
|
378
378
|
- `withBodyAsJson(body)`: Adds a body to the request that will be sent as json.
|
|
379
|
+
- `withBodyAsFormUrlEncoded(body)`: Adds a body to the request that will be sent as form url encoded body.
|
|
379
380
|
- `withBodyAsText(body)`: Adds a body to the request that will be sent as a plain text.
|
|
380
381
|
- `withBodyAsMultipart(body)`: Accepts a specific object as body which is then sent as a multipart/form-data body in the request. The `body` input for `withBodyAsMultipart` has the following type:
|
|
382
|
+
|
|
381
383
|
```typescript
|
|
382
384
|
type MultipartBody = {
|
|
383
385
|
fields: Record<string, string>;
|
|
384
386
|
files: Record<string, FileReference>;
|
|
385
|
-
}
|
|
387
|
+
};
|
|
386
388
|
```
|
|
387
389
|
|
|
388
390
|
- `withBodyAsFile(FileReference)`: Adds the source file to the request body as binary that will sent to the target server. The FileReference input has the following type:
|
|
@@ -815,7 +817,6 @@ handler.usingHttp((http) =>
|
|
|
815
817
|
.handleResponse((ctx, input, response) => response.parseWithBodyAsJson())
|
|
816
818
|
```
|
|
817
819
|
|
|
818
|
-
|
|
819
820
|
### An example operation sending files in multipart/form-data
|
|
820
821
|
|
|
821
822
|
```typescript
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { HttpContentType, HttpMethod, HttpRequest, HttpHeaderValue, HttpResponse } from '@trayio/commons/http/Http';
|
|
2
|
-
import { DynamicType } from '@trayio/commons/dynamictype/DynamicType';
|
|
2
|
+
import { DynamicObject, DynamicType } from '@trayio/commons/dynamictype/DynamicType';
|
|
3
3
|
import * as O from 'fp-ts/Option';
|
|
4
4
|
import { OperationHandlerAuth, OperationHandlerContext, OperationHandlerResult, FileReference } from './OperationHandler';
|
|
5
5
|
export type HttpOperationMultipartBody = {
|
|
@@ -14,6 +14,7 @@ export declare class HttpOperationRequestBuilder {
|
|
|
14
14
|
constructor(method: HttpMethod, path: string, request: HttpRequest);
|
|
15
15
|
withBodyAsJson<T extends DynamicType>(body: T): HttpOperationRequest;
|
|
16
16
|
withBodyAsText(body: string): HttpOperationRequest;
|
|
17
|
+
withBodyAsFormUrlEncoded<T extends DynamicObject>(body: T): HttpOperationRequest;
|
|
17
18
|
withBodyAsMultipart(body: HttpOperationMultipartBody): HttpOperationRequest;
|
|
18
19
|
withBodyAsFile(file: FileReference): HttpOperationRequest;
|
|
19
20
|
withoutBody(): HttpOperationRequest;
|
|
@@ -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,MAAM,2BAA2B,CAAC;AACnC,OAAO,
|
|
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,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,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC/B,KAAK,EAAE,MAAM,CAAC,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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"}
|
|
@@ -55,6 +55,11 @@ class HttpOperationRequestBuilder {
|
|
|
55
55
|
const requestWithHeader = this.addHeader(Http_1.HttpHeader.ContentType, contentType);
|
|
56
56
|
return new HttpOperationRequest(requestWithHeader.path, requestWithHeader.method, requestWithHeader.request, O.some(contentType), body);
|
|
57
57
|
}
|
|
58
|
+
withBodyAsFormUrlEncoded(body) {
|
|
59
|
+
const contentType = Http_1.HttpContentType.FormUrlEncoded;
|
|
60
|
+
const requestWithHeader = this.addHeader(Http_1.HttpHeader.ContentType, contentType);
|
|
61
|
+
return new HttpOperationRequest(requestWithHeader.path, requestWithHeader.method, requestWithHeader.request, O.some(contentType), body);
|
|
62
|
+
}
|
|
58
63
|
withBodyAsMultipart(body) {
|
|
59
64
|
const contentType = Http_1.HttpContentType.MultipartRequestBody;
|
|
60
65
|
const requestWithHeader = this.addHeader(Http_1.HttpHeader.ContentType, contentType);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@trayio/cdk-dsl",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.18.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": "2.
|
|
17
|
+
"@trayio/commons": "2.18.0"
|
|
18
18
|
},
|
|
19
19
|
"typesVersions": {
|
|
20
20
|
"*": {
|