@trayio/commons 5.34.0 → 5.35.0-unstable.fd7158a
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/base64/Base64.d.ts +5 -10
- package/dist/base64/Base64.d.ts.map +1 -1
- package/dist/base64/Base64.js +8 -40
- package/dist/base64/Base64.unit.test.js +4 -27
- package/dist/buffer/BufferExtensions.d.ts +4 -4
- package/dist/buffer/BufferExtensions.d.ts.map +1 -1
- package/dist/buffer/BufferExtensions.js +25 -38
- package/dist/buffer/BufferExtensions.unit.test.js +22 -45
- package/dist/callsite/CallSite.js +17 -7
- package/dist/codec/CamelCasePropertyNameCodec.d.ts +2 -2
- package/dist/codec/CamelCasePropertyNameCodec.d.ts.map +1 -1
- package/dist/codec/CamelCasePropertyNameCodec.js +2 -25
- package/dist/codec/Codec.abstract.test.d.ts +2 -2
- package/dist/codec/Codec.abstract.test.d.ts.map +1 -1
- package/dist/codec/Codec.abstract.test.js +5 -31
- package/dist/codec/Codec.d.ts +2 -2
- package/dist/codec/Codec.d.ts.map +1 -1
- package/dist/codec/CompositeCodec.d.ts +2 -2
- package/dist/codec/CompositeCodec.d.ts.map +1 -1
- package/dist/codec/CompositeCodec.js +2 -26
- package/dist/codec/PartialRedactionCodec.d.ts +2 -2
- package/dist/codec/PartialRedactionCodec.d.ts.map +1 -1
- package/dist/codec/PartialRedactionCodec.js +2 -25
- package/dist/codec/RemoveNullValuesCodec.d.ts +2 -2
- package/dist/codec/RemoveNullValuesCodec.d.ts.map +1 -1
- package/dist/codec/RemoveNullValuesCodec.js +2 -25
- package/dist/codec/RemoveTopLevelTagCodec.d.ts +2 -2
- package/dist/codec/RemoveTopLevelTagCodec.d.ts.map +1 -1
- package/dist/codec/RemoveTopLevelTagCodec.js +2 -25
- package/dist/codec/SensitiveRemoveTagAndRedactCodec.d.ts +2 -2
- package/dist/codec/SensitiveRemoveTagAndRedactCodec.d.ts.map +1 -1
- package/dist/codec/SensitiveRemoveTagAndRedactCodec.js +2 -25
- package/dist/codec/SensitiveRemoveTagAndRedactCodec.unit.test.js +15 -38
- package/dist/codec/SnakeCasePropertyNameCodec.d.ts +2 -2
- package/dist/codec/SnakeCasePropertyNameCodec.d.ts.map +1 -1
- package/dist/codec/SnakeCasePropertyNameCodec.js +2 -25
- package/dist/codec/TypeCodec.d.ts +24 -8
- package/dist/codec/TypeCodec.d.ts.map +1 -1
- package/dist/codec/TypeCodec.js +40 -48
- package/dist/codec/TypeCodec.unit.test.js +12 -38
- package/dist/dynamicschema/DynamicSchema.d.ts +6 -12
- package/dist/dynamicschema/DynamicSchema.d.ts.map +1 -1
- package/dist/dynamicschema/DynamicSchema.js +18 -41
- package/dist/dynamicschema/DynamicSchema.unit.test.js +51 -75
- package/dist/dynamictype/DynamicType.d.ts +17 -20
- package/dist/dynamictype/DynamicType.d.ts.map +1 -1
- package/dist/dynamictype/DynamicType.js +48 -35
- package/dist/effect/EffectExtensions.d.ts +29 -0
- package/dist/effect/EffectExtensions.d.ts.map +1 -0
- package/dist/effect/EffectExtensions.js +30 -0
- package/dist/effect/EffectExtensions.unit.test.d.ts +2 -0
- package/dist/effect/EffectExtensions.unit.test.d.ts.map +1 -0
- package/dist/effect/EffectExtensions.unit.test.js +59 -0
- package/dist/effect/Interop.d.ts +53 -0
- package/dist/effect/Interop.d.ts.map +1 -0
- package/dist/effect/Interop.js +56 -0
- package/dist/effect/Interop.unit.test.d.ts +2 -0
- package/dist/effect/Interop.unit.test.d.ts.map +1 -0
- package/dist/effect/Interop.unit.test.js +134 -0
- package/dist/effect/SchemaExtensions.d.ts +11 -0
- package/dist/effect/SchemaExtensions.d.ts.map +1 -0
- package/dist/effect/SchemaExtensions.js +7 -0
- package/dist/effect/SchemaExtensions.unit.test.d.ts +2 -0
- package/dist/effect/SchemaExtensions.unit.test.d.ts.map +1 -0
- package/dist/effect/SchemaExtensions.unit.test.js +29 -0
- package/dist/file/FakeFileStorage.d.ts +8 -8
- package/dist/file/FakeFileStorage.d.ts.map +1 -1
- package/dist/file/FakeFileStorage.js +16 -40
- package/dist/file/File.d.ts +10 -14
- package/dist/file/File.d.ts.map +1 -1
- package/dist/file/File.js +31 -24
- package/dist/file/FileStorage.abstract.test.d.ts.map +1 -1
- package/dist/file/FileStorage.abstract.test.js +18 -41
- package/dist/file/NodeFsFileStorage.d.ts +9 -11
- package/dist/file/NodeFsFileStorage.d.ts.map +1 -1
- package/dist/file/NodeFsFileStorage.integration.test.js +21 -45
- package/dist/file/NodeFsFileStorage.js +37 -29
- package/dist/http/Http.d.ts +11 -13
- package/dist/http/Http.d.ts.map +1 -1
- package/dist/http/Http.js +30 -22
- package/dist/http/Http.unit.test.js +3 -26
- package/dist/http/HttpClient.abstract.test.d.ts.map +1 -1
- package/dist/http/HttpClient.abstract.test.js +104 -108
- package/dist/http/HttpClient.d.ts +2 -2
- package/dist/http/HttpClient.d.ts.map +1 -1
- package/dist/http/HttpController.d.ts +2 -3
- package/dist/http/HttpController.d.ts.map +1 -1
- package/dist/http/HttpSchemas.d.ts +13 -0
- package/dist/http/HttpSchemas.d.ts.map +1 -0
- package/dist/http/HttpSchemas.js +23 -0
- package/dist/http/MultipartHttpRequestBody.integration.test.js +31 -20
- package/dist/http/MultipartHttpRequestBody.unit.test.js +70 -53
- package/dist/record/Record.d.ts +3 -3
- package/dist/record/Record.d.ts.map +1 -1
- package/dist/record/Record.js +9 -30
- package/dist/result/Result.d.ts +3 -3
- package/dist/result/Result.d.ts.map +1 -1
- package/dist/result/Result.js +9 -26
- package/dist/schema/DateFromUnixTime.d.ts +4 -0
- package/dist/schema/DateFromUnixTime.d.ts.map +1 -0
- package/dist/schema/DateFromUnixTime.js +10 -0
- package/dist/schema/DateFromUnixTime.unit.test.d.ts +2 -0
- package/dist/schema/DateFromUnixTime.unit.test.d.ts.map +1 -0
- package/dist/schema/DateFromUnixTime.unit.test.js +11 -0
- package/dist/schema/JsonSchemaIntrospector.js +17 -7
- package/dist/sensitive/Sensitive.d.ts +7 -3
- package/dist/sensitive/Sensitive.d.ts.map +1 -1
- package/dist/sensitive/Sensitive.js +23 -39
- package/dist/sensitive/Sensitive.unit.test.d.ts +4 -4
- package/dist/sensitive/Sensitive.unit.test.d.ts.map +1 -1
- package/dist/sensitive/Sensitive.unit.test.js +20 -46
- package/dist/serialization/FormUrlEncodedSerialization.d.ts +2 -2
- package/dist/serialization/FormUrlEncodedSerialization.d.ts.map +1 -1
- package/dist/serialization/FormUrlEncodedSerialization.js +5 -28
- package/dist/serialization/JsonSerialization.d.ts +2 -2
- package/dist/serialization/JsonSerialization.d.ts.map +1 -1
- package/dist/serialization/JsonSerialization.js +5 -28
- package/dist/serialization/Serialization.abstract.test.d.ts.map +1 -1
- package/dist/serialization/Serialization.abstract.test.js +6 -32
- package/dist/serialization/Serialization.d.ts +2 -2
- package/dist/serialization/Serialization.d.ts.map +1 -1
- package/dist/try/Try.d.ts +2 -2
- package/dist/try/Try.d.ts.map +1 -1
- package/dist/try/Try.js +2 -32
- package/dist/uuid/Uuid.d.ts +11 -10
- package/dist/uuid/Uuid.d.ts.map +1 -1
- package/dist/uuid/Uuid.js +13 -39
- package/dist/uuid/Uuid.unit.test.js +4 -27
- package/dist/zod/SchemaParser.abstract.test.d.ts.map +1 -1
- package/dist/zod/SchemaParser.abstract.test.js +6 -31
- package/dist/zod/SchemaParser.d.ts +2 -2
- package/dist/zod/SchemaParser.d.ts.map +1 -1
- package/dist/zod/ZodSchemaParser.d.ts +3 -4
- package/dist/zod/ZodSchemaParser.d.ts.map +1 -1
- package/dist/zod/ZodSchemaParser.js +4 -28
- package/dist/zod/ZodSchemaParser.unit.test.js +2 -25
- package/package.json +3 -8
- package/dist/http/HttpTypeDescriptors.d.ts +0 -11
- package/dist/http/HttpTypeDescriptors.d.ts.map +0 -1
- package/dist/http/HttpTypeDescriptors.js +0 -59
- package/dist/task/Task.d.ts +0 -19
- package/dist/task/Task.d.ts.map +0 -1
- package/dist/task/Task.js +0 -74
- package/dist/task/Task.unit.test.d.ts +0 -2
- package/dist/task/Task.unit.test.d.ts.map +0 -1
- package/dist/task/Task.unit.test.js +0 -46
|
@@ -1,29 +1,6 @@
|
|
|
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
|
-
};
|
|
25
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
const
|
|
3
|
+
const effect_1 = require("effect");
|
|
27
4
|
const Http_1 = require("./Http");
|
|
28
5
|
describe('HttpHeaders', () => {
|
|
29
6
|
it('should convert headers to DynamicObject', () => {
|
|
@@ -162,7 +139,7 @@ describe('HttpHeaders', () => {
|
|
|
162
139
|
authorization: 'bearer 1234',
|
|
163
140
|
};
|
|
164
141
|
const result = Http_1.HttpHeaders.extractBearerToken(headers);
|
|
165
|
-
expect(result).toEqual(
|
|
142
|
+
expect(result).toEqual(effect_1.Option.some('1234'));
|
|
166
143
|
});
|
|
167
144
|
it('should extract bearer token from headers when headers are capitalized', () => {
|
|
168
145
|
const headers = {
|
|
@@ -171,6 +148,6 @@ describe('HttpHeaders', () => {
|
|
|
171
148
|
Authorization: 'Bearer 1234',
|
|
172
149
|
};
|
|
173
150
|
const result = Http_1.HttpHeaders.extractBearerToken(headers);
|
|
174
|
-
expect(result).toEqual(
|
|
151
|
+
expect(result).toEqual(effect_1.Option.some('1234'));
|
|
175
152
|
});
|
|
176
153
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"HttpClient.abstract.test.d.ts","sourceRoot":"","sources":["../../src/http/HttpClient.abstract.test.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"HttpClient.abstract.test.d.ts","sourceRoot":"","sources":["../../src/http/HttpClient.abstract.test.ts"],"names":[],"mappings":"AAeA,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAO1C,wBAAgB,cAAc,CAAC,UAAU,EAAE,UAAU,QAm0BpD"}
|
|
@@ -1,45 +1,16 @@
|
|
|
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
|
-
};
|
|
25
2
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
4
|
};
|
|
28
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
-
exports.httpClientTest =
|
|
30
|
-
const
|
|
31
|
-
const O = __importStar(require("fp-ts/Option"));
|
|
6
|
+
exports.httpClientTest = httpClientTest;
|
|
7
|
+
const effect_1 = require("effect");
|
|
32
8
|
const stream_1 = require("stream");
|
|
33
9
|
const selfsigned_1 = __importDefault(require("selfsigned"));
|
|
34
|
-
const function_1 = require("fp-ts/function");
|
|
35
|
-
const t = __importStar(require("io-ts"));
|
|
36
|
-
const td = __importStar(require("io-ts-types"));
|
|
37
10
|
const http_1 = require("http");
|
|
38
11
|
const https_1 = require("https");
|
|
39
12
|
const util_1 = require("util");
|
|
40
|
-
const TE = __importStar(require("fp-ts/TaskEither"));
|
|
41
13
|
const formidable_1 = __importDefault(require("formidable"));
|
|
42
|
-
const Task_1 = require("../task/Task");
|
|
43
14
|
const JsonSerialization_1 = require("../serialization/JsonSerialization");
|
|
44
15
|
const TypeCodec_1 = require("../codec/TypeCodec");
|
|
45
16
|
const Http_1 = require("./Http");
|
|
@@ -51,12 +22,12 @@ function httpClientTest(httpClient) {
|
|
|
51
22
|
const serialization = new JsonSerialization_1.JsonSerialization();
|
|
52
23
|
const formUrlEncodedSerialization = new FormUrlEncodedSerialization_1.FormUrlEncodedSerialization();
|
|
53
24
|
const fileStorage = new NodeFsFileStorage_1.NodeFsFileStorage();
|
|
54
|
-
const testErrorResponseCodec = TypeCodec_1.TypeCodec.
|
|
55
|
-
message:
|
|
25
|
+
const testErrorResponseCodec = TypeCodec_1.TypeCodec.fromSchema(effect_1.Schema.Struct({
|
|
26
|
+
message: effect_1.Schema.String,
|
|
56
27
|
}));
|
|
57
|
-
const testResponseCodec = TypeCodec_1.TypeCodec.
|
|
58
|
-
strField:
|
|
59
|
-
intField:
|
|
28
|
+
const testResponseCodec = TypeCodec_1.TypeCodec.fromSchema(effect_1.Schema.Struct({
|
|
29
|
+
strField: effect_1.Schema.String,
|
|
30
|
+
intField: effect_1.Schema.Number,
|
|
60
31
|
}));
|
|
61
32
|
const testInputFormUrlEncoded = {
|
|
62
33
|
x: 1,
|
|
@@ -64,26 +35,29 @@ function httpClientTest(httpClient) {
|
|
|
64
35
|
arr2: [1, [2], 3],
|
|
65
36
|
users: [{ username: 'tray' }],
|
|
66
37
|
};
|
|
67
|
-
const testInputFormUrlEncodedCodec = TypeCodec_1.TypeCodec.
|
|
68
|
-
x:
|
|
69
|
-
arr:
|
|
70
|
-
arr2:
|
|
71
|
-
users:
|
|
72
|
-
username:
|
|
73
|
-
})),
|
|
38
|
+
const testInputFormUrlEncodedCodec = TypeCodec_1.TypeCodec.fromSchema(effect_1.Schema.Struct({
|
|
39
|
+
x: effect_1.Schema.NumberFromString,
|
|
40
|
+
arr: effect_1.Schema.mutable(effect_1.Schema.Array(effect_1.Schema.NumberFromString)),
|
|
41
|
+
arr2: effect_1.Schema.mutable(effect_1.Schema.Array(effect_1.Schema.Union(effect_1.Schema.NumberFromString, effect_1.Schema.mutable(effect_1.Schema.Array(effect_1.Schema.NumberFromString))))),
|
|
42
|
+
users: effect_1.Schema.mutable(effect_1.Schema.Array(effect_1.Schema.Struct({
|
|
43
|
+
username: effect_1.Schema.String,
|
|
44
|
+
}))),
|
|
74
45
|
}));
|
|
75
|
-
const testMultiPartBodyTypeCodec = TypeCodec_1.TypeCodec.
|
|
76
|
-
fields:
|
|
77
|
-
files:
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
46
|
+
const testMultiPartBodyTypeCodec = TypeCodec_1.TypeCodec.fromSchema(effect_1.Schema.Struct({
|
|
47
|
+
fields: effect_1.Schema.Record({ key: effect_1.Schema.String, value: effect_1.Schema.String }),
|
|
48
|
+
files: effect_1.Schema.Record({
|
|
49
|
+
key: effect_1.Schema.String,
|
|
50
|
+
value: effect_1.Schema.Struct({
|
|
51
|
+
reference: File_1.fileDescriptorSchema,
|
|
52
|
+
content: effect_1.Schema.Any,
|
|
53
|
+
}),
|
|
54
|
+
}),
|
|
81
55
|
}));
|
|
82
|
-
const testInputCodec = TypeCodec_1.TypeCodec.
|
|
83
|
-
inputField:
|
|
56
|
+
const testInputCodec = TypeCodec_1.TypeCodec.fromSchema(effect_1.Schema.Struct({
|
|
57
|
+
inputField: effect_1.Schema.Number,
|
|
84
58
|
}));
|
|
85
59
|
function sendHttpResponse(httpResponse, response, responseCodec) {
|
|
86
|
-
const serializedResponse = (0,
|
|
60
|
+
const serializedResponse = (0, effect_1.pipe)(effect_1.Either.right(responseCodec.encode(response)), effect_1.Either.map((encodedResponse) => serialization.serialize(encodedResponse)), effect_1.Either.getOrElse(() => (new util_1.TextEncoder().encode('Error serializing value').buffer)));
|
|
87
61
|
httpResponse.end(Buffer.from(serializedResponse));
|
|
88
62
|
}
|
|
89
63
|
async function processHttpRequest(requestCodec, responseCodec, httpRequest, httpResponse, process, isMultiPartBody = false) {
|
|
@@ -102,7 +76,7 @@ function httpClientTest(httpClient) {
|
|
|
102
76
|
fields: flattenFields(fields),
|
|
103
77
|
files: flattenFiles(files),
|
|
104
78
|
};
|
|
105
|
-
const response = (0,
|
|
79
|
+
const response = (0, effect_1.pipe)(requestCodec.decode(input), effect_1.Either.map(process), effect_1.Either.map((result) => new util_1.TextEncoder().encode(JSON.stringify(responseCodec.encode(result))).buffer), effect_1.Either.getOrElse(() => new util_1.TextEncoder().encode('Error serializing value').buffer));
|
|
106
80
|
httpResponse.end(Buffer.from(response));
|
|
107
81
|
}
|
|
108
82
|
const body = [];
|
|
@@ -114,7 +88,7 @@ function httpClientTest(httpClient) {
|
|
|
114
88
|
const requestSerializer = httpRequest.headers['content-type'] === Http_1.HttpContentType.FormUrlEncoded
|
|
115
89
|
? formUrlEncodedSerialization
|
|
116
90
|
: serialization;
|
|
117
|
-
const response = (0,
|
|
91
|
+
const response = (0, effect_1.pipe)(requestSerializer.deserialize(BufferExtensions_1.BufferExtensions.bufferToArrayBuffer(buffer)), effect_1.Either.flatMap((encodedRequest) => requestCodec.decode(encodedRequest)), effect_1.Either.map(process), effect_1.Either.map((result) => responseCodec.encode(result)), effect_1.Either.map((encodedResult) => serialization.serialize(encodedResult)), effect_1.Either.getOrElse((error) => new util_1.TextEncoder().encode(error.message).buffer));
|
|
118
92
|
httpResponse.end(Buffer.from(response));
|
|
119
93
|
});
|
|
120
94
|
}
|
|
@@ -181,7 +155,8 @@ function httpClientTest(httpClient) {
|
|
|
181
155
|
sendHttpResponse(res, response, testResponseCodec);
|
|
182
156
|
}
|
|
183
157
|
else if (req.method === 'GET') {
|
|
184
|
-
|
|
158
|
+
// Effect's encode validates the value; an undefined strField would throw and the request would never be answered.
|
|
159
|
+
const customHeader = req.headers['x-custom-header'] ?? '';
|
|
185
160
|
res.writeHead(200, { [Http_1.HttpHeader.ContentType]: Http_1.HttpContentType.Json });
|
|
186
161
|
const response = {
|
|
187
162
|
strField: customHeader,
|
|
@@ -218,6 +193,8 @@ function httpClientTest(httpClient) {
|
|
|
218
193
|
const httpsServerUrl = `https://${host}:${httpsPort}`;
|
|
219
194
|
// Generate self-signed certificates for Https server, override type as it didn't include client certs
|
|
220
195
|
const certs = selfsigned_1.default.generate([], {
|
|
196
|
+
// 2048 bits: OpenSSL 3 (Node 17+) rejects smaller keys with "ee key too small"
|
|
197
|
+
keySize: 2048,
|
|
221
198
|
clientCertificate: true,
|
|
222
199
|
clientCertificateCN: 'client',
|
|
223
200
|
extensions: [{ name: 'basicConstraints', cA: true }],
|
|
@@ -260,74 +237,85 @@ function httpClientTest(httpClient) {
|
|
|
260
237
|
});
|
|
261
238
|
});
|
|
262
239
|
test('should send a GET request', async () => {
|
|
263
|
-
const response = await httpClient.execute(Http_1.HttpMethod.Get, baseUrl, Http_1.HttpRequest.create({
|
|
240
|
+
const response = await effect_1.Effect.runPromise(effect_1.Effect.either(httpClient.execute(Http_1.HttpMethod.Get, baseUrl, Http_1.HttpRequest.create({
|
|
264
241
|
headers: { 'x-custom-header': 'customVal' },
|
|
265
242
|
pathParams: {},
|
|
266
243
|
queryString: {},
|
|
267
244
|
body: BufferExtensions_1.BufferExtensions.arrayBufferToReadable(new ArrayBuffer(0)),
|
|
268
|
-
}))
|
|
245
|
+
}))));
|
|
269
246
|
const testValue = {
|
|
270
247
|
strField: 'customVal',
|
|
271
248
|
intField: 123,
|
|
272
249
|
};
|
|
273
|
-
const result = (0,
|
|
274
|
-
|
|
275
|
-
|
|
250
|
+
const result = (0, effect_1.pipe)(response, effect_1.Effect.flatMap((httpResponse) => BufferExtensions_1.BufferExtensions.readableToArrayBuffer(httpResponse.body)), effect_1.Effect.match({
|
|
251
|
+
onFailure: (error) => effect_1.Either.left(error),
|
|
252
|
+
onSuccess: (buffer) => (0, effect_1.pipe)(serialization.deserialize(buffer), effect_1.Either.flatMap((encoded) => testResponseCodec.decode(encoded))),
|
|
253
|
+
}));
|
|
254
|
+
const resultE = await effect_1.Effect.runPromise(result);
|
|
255
|
+
expect(resultE).toStrictEqual(effect_1.Either.right(testValue));
|
|
276
256
|
});
|
|
277
257
|
test('should preserve header casing when headerOption preserveCasing is true', async () => {
|
|
278
|
-
const response = await httpClient.execute(Http_1.HttpMethod.Get, baseUrl, Http_1.HttpRequest.create({
|
|
258
|
+
const response = await effect_1.Effect.runPromise(effect_1.Effect.either(httpClient.execute(Http_1.HttpMethod.Get, baseUrl, Http_1.HttpRequest.create({
|
|
279
259
|
headers: { 'Upper-Cased-Header': 'CasedValue' },
|
|
280
260
|
pathParams: {},
|
|
281
261
|
queryString: {},
|
|
282
262
|
body: BufferExtensions_1.BufferExtensions.arrayBufferToReadable(new ArrayBuffer(0)),
|
|
283
|
-
headerOptions:
|
|
284
|
-
|
|
263
|
+
headerOptions: effect_1.Option.some({
|
|
264
|
+
preserveHeaderCasing: effect_1.Option.some(true),
|
|
265
|
+
}),
|
|
266
|
+
}))));
|
|
285
267
|
const testValue = {
|
|
286
268
|
strField: 'CasedValue',
|
|
287
269
|
intField: 123,
|
|
288
270
|
};
|
|
289
|
-
const result = (0,
|
|
290
|
-
|
|
291
|
-
|
|
271
|
+
const result = (0, effect_1.pipe)(response, effect_1.Effect.flatMap((httpResponse) => BufferExtensions_1.BufferExtensions.readableToArrayBuffer(httpResponse.body)), effect_1.Effect.match({
|
|
272
|
+
onFailure: (error) => effect_1.Either.left(error),
|
|
273
|
+
onSuccess: (buffer) => (0, effect_1.pipe)(serialization.deserialize(buffer), effect_1.Either.flatMap((encoded) => testResponseCodec.decode(encoded))),
|
|
274
|
+
}));
|
|
275
|
+
const resultE = await effect_1.Effect.runPromise(result);
|
|
276
|
+
expect(resultE).toStrictEqual(effect_1.Either.right(testValue));
|
|
292
277
|
});
|
|
293
278
|
test('should send a GET request with an empty header', async () => {
|
|
294
|
-
const response = await httpClient.execute(Http_1.HttpMethod.Get, baseUrl, Http_1.HttpRequest.create({
|
|
279
|
+
const response = await effect_1.Effect.runPromise(effect_1.Effect.either(httpClient.execute(Http_1.HttpMethod.Get, baseUrl, Http_1.HttpRequest.create({
|
|
295
280
|
headers: { '': '' },
|
|
296
281
|
pathParams: {},
|
|
297
282
|
queryString: {},
|
|
298
283
|
body: BufferExtensions_1.BufferExtensions.arrayBufferToReadable(new ArrayBuffer(0)),
|
|
299
|
-
}))
|
|
300
|
-
if (
|
|
284
|
+
}))));
|
|
285
|
+
if (effect_1.Either.isLeft(response)) {
|
|
301
286
|
throw new Error('Got left expected right');
|
|
302
287
|
}
|
|
303
288
|
expect(response.right.statusCode).toEqual(200);
|
|
304
289
|
});
|
|
305
290
|
test('should send a GET request with a certificate', async () => {
|
|
306
|
-
const response = await httpClient.execute(Http_1.HttpMethod.Get, httpsServerUrl, Http_1.HttpRequest.create({
|
|
291
|
+
const response = await effect_1.Effect.runPromise(effect_1.Effect.either(httpClient.execute(Http_1.HttpMethod.Get, httpsServerUrl, Http_1.HttpRequest.create({
|
|
307
292
|
headers: { 'x-custom-header': 'customVal' },
|
|
308
293
|
pathParams: {},
|
|
309
294
|
queryString: {},
|
|
310
295
|
body: BufferExtensions_1.BufferExtensions.arrayBufferToReadable(new ArrayBuffer(0)),
|
|
311
|
-
agent:
|
|
312
|
-
certificate:
|
|
296
|
+
agent: effect_1.Option.some({
|
|
297
|
+
certificate: effect_1.Option.some({
|
|
313
298
|
key: certs.clientprivate,
|
|
314
299
|
cert: certs.clientcert,
|
|
315
300
|
}),
|
|
316
301
|
}),
|
|
317
|
-
}))
|
|
302
|
+
}))));
|
|
318
303
|
const testValue = {
|
|
319
304
|
strField: 'customVal',
|
|
320
305
|
intField: 123,
|
|
321
306
|
};
|
|
322
|
-
const result = (0,
|
|
323
|
-
|
|
324
|
-
|
|
307
|
+
const result = (0, effect_1.pipe)(response, effect_1.Effect.flatMap((httpResponse) => BufferExtensions_1.BufferExtensions.readableToArrayBuffer(httpResponse.body)), effect_1.Effect.match({
|
|
308
|
+
onFailure: (error) => effect_1.Either.left(error),
|
|
309
|
+
onSuccess: (buffer) => (0, effect_1.pipe)(serialization.deserialize(buffer), effect_1.Either.flatMap((encoded) => testResponseCodec.decode(encoded))),
|
|
310
|
+
}));
|
|
311
|
+
const resultE = await effect_1.Effect.runPromise(result);
|
|
312
|
+
expect(resultE).toStrictEqual(effect_1.Either.right(testValue));
|
|
325
313
|
});
|
|
326
314
|
test('should send a POST request', async () => {
|
|
327
315
|
const testInput = {
|
|
328
316
|
inputField: 321,
|
|
329
317
|
};
|
|
330
|
-
const response = await (
|
|
318
|
+
const response = await effect_1.Effect.runPromise(effect_1.Effect.either((0, effect_1.pipe)(effect_1.Either.right(testInputCodec.encode(testInput)), effect_1.Effect.map((encoded) => serialization.serialize(encoded)), effect_1.Effect.flatMap((serializedInput) => httpClient.execute(Http_1.HttpMethod.Post, baseUrl, Http_1.HttpRequest.create({
|
|
331
319
|
headers: {
|
|
332
320
|
'x-custom-header': 'customVal',
|
|
333
321
|
[Http_1.HttpHeader.ContentType]: Http_1.HttpContentType.Json,
|
|
@@ -335,34 +323,37 @@ function httpClientTest(httpClient) {
|
|
|
335
323
|
pathParams: {},
|
|
336
324
|
queryString: {},
|
|
337
325
|
body: BufferExtensions_1.BufferExtensions.arrayBufferToReadable(serializedInput),
|
|
338
|
-
}))))
|
|
326
|
+
}))))));
|
|
339
327
|
const testValue = {
|
|
340
328
|
strField: 'customVal',
|
|
341
329
|
intField: 321,
|
|
342
330
|
};
|
|
343
|
-
const result = (0,
|
|
344
|
-
|
|
345
|
-
|
|
331
|
+
const result = (0, effect_1.pipe)(response, effect_1.Effect.flatMap((httpResponse) => BufferExtensions_1.BufferExtensions.readableToArrayBuffer(httpResponse.body)), effect_1.Effect.match({
|
|
332
|
+
onFailure: (error) => effect_1.Either.left(error),
|
|
333
|
+
onSuccess: (buffer) => (0, effect_1.pipe)(serialization.deserialize(buffer), effect_1.Either.flatMap((encoded) => testResponseCodec.decode(encoded))),
|
|
334
|
+
}));
|
|
335
|
+
const resultE = await effect_1.Effect.runPromise(result);
|
|
336
|
+
expect(resultE).toStrictEqual(effect_1.Either.right(testValue));
|
|
346
337
|
});
|
|
347
338
|
test('should send a POST request with multipart body', async () => {
|
|
348
|
-
await fileStorage.delete('file1')
|
|
349
|
-
await fileStorage.delete('file2')
|
|
350
|
-
const file1 = await fileStorage.write({
|
|
339
|
+
await effect_1.Effect.runPromise(effect_1.Effect.either(fileStorage.delete('file1')));
|
|
340
|
+
await effect_1.Effect.runPromise(effect_1.Effect.either(fileStorage.delete('file2')));
|
|
341
|
+
const file1 = await effect_1.Effect.runPromise(effect_1.Effect.either(fileStorage.write({
|
|
351
342
|
reference: {
|
|
352
343
|
_tag: 'FileDescriptor',
|
|
353
344
|
key: 'file1',
|
|
354
345
|
metadata: { name: 'file1' },
|
|
355
346
|
},
|
|
356
347
|
content: stream_1.Readable.from('file 1 content'),
|
|
357
|
-
})
|
|
358
|
-
const file2 = await fileStorage.write({
|
|
348
|
+
})));
|
|
349
|
+
const file2 = await effect_1.Effect.runPromise(effect_1.Effect.either(fileStorage.write({
|
|
359
350
|
reference: {
|
|
360
351
|
_tag: 'FileDescriptor',
|
|
361
352
|
key: 'file2',
|
|
362
353
|
metadata: { name: 'file2' },
|
|
363
354
|
},
|
|
364
355
|
content: stream_1.Readable.from('file 2 content'),
|
|
365
|
-
})
|
|
356
|
+
})));
|
|
366
357
|
if (file1._tag === 'Left') {
|
|
367
358
|
throw file1.left;
|
|
368
359
|
}
|
|
@@ -385,7 +376,7 @@ function httpClientTest(httpClient) {
|
|
|
385
376
|
},
|
|
386
377
|
},
|
|
387
378
|
};
|
|
388
|
-
const response = await httpClient.execute(Http_1.HttpMethod.Post, baseUrl, Http_1.HttpRequest.create({
|
|
379
|
+
const response = await effect_1.Effect.runPromise(effect_1.Effect.either(httpClient.execute(Http_1.HttpMethod.Post, baseUrl, Http_1.HttpRequest.create({
|
|
389
380
|
headers: {
|
|
390
381
|
'x-custom-header': 'customVal',
|
|
391
382
|
'content-type': Http_1.HttpContentType.MultipartRequestBody,
|
|
@@ -393,10 +384,13 @@ function httpClientTest(httpClient) {
|
|
|
393
384
|
pathParams: {},
|
|
394
385
|
queryString: {},
|
|
395
386
|
body: testInput,
|
|
396
|
-
}))
|
|
397
|
-
const result = (0,
|
|
398
|
-
|
|
399
|
-
|
|
387
|
+
}))));
|
|
388
|
+
const result = (0, effect_1.pipe)(response, effect_1.Effect.flatMap((httpResponse) => BufferExtensions_1.BufferExtensions.readableToArrayBuffer(httpResponse.body)), effect_1.Effect.match({
|
|
389
|
+
onFailure: (error) => effect_1.Either.left(error),
|
|
390
|
+
onSuccess: (buffer) => (0, effect_1.pipe)(serialization.deserialize(buffer), effect_1.Either.flatMap((encoded) => testMultiPartBodyTypeCodec.decode(encoded))),
|
|
391
|
+
}));
|
|
392
|
+
const resultE = await effect_1.Effect.runPromise(result);
|
|
393
|
+
expect(resultE).toEqual(effect_1.Either.right(expect.objectContaining({
|
|
400
394
|
fields: testInput.fields,
|
|
401
395
|
files: expect.objectContaining({
|
|
402
396
|
file1: expect.objectContaining({
|
|
@@ -417,56 +411,58 @@ function httpClientTest(httpClient) {
|
|
|
417
411
|
})));
|
|
418
412
|
});
|
|
419
413
|
test('should send a POST request with a formUrlEncoded body', async () => {
|
|
420
|
-
const response = await (
|
|
414
|
+
const response = await effect_1.Effect.runPromise(effect_1.Effect.either((0, effect_1.pipe)(effect_1.Either.right(testInputFormUrlEncodedCodec.encode(testInputFormUrlEncoded)), effect_1.Effect.map((encoded) => formUrlEncodedSerialization.serialize(encoded)), effect_1.Effect.flatMap((serializedInput) => httpClient.execute(Http_1.HttpMethod.Post, baseUrl, Http_1.HttpRequest.create({
|
|
421
415
|
headers: {
|
|
422
416
|
[Http_1.HttpHeader.ContentType]: Http_1.HttpContentType.FormUrlEncoded,
|
|
423
417
|
},
|
|
424
418
|
pathParams: {},
|
|
425
419
|
queryString: {},
|
|
426
420
|
body: BufferExtensions_1.BufferExtensions.arrayBufferToReadable(serializedInput),
|
|
427
|
-
}))))
|
|
421
|
+
}))))));
|
|
428
422
|
const testValue = {
|
|
429
423
|
strField: 'customVal',
|
|
430
424
|
intField: 1,
|
|
431
425
|
};
|
|
432
|
-
const result = (0,
|
|
433
|
-
|
|
434
|
-
|
|
426
|
+
const result = (0, effect_1.pipe)(response, effect_1.Effect.flatMap((httpResponse) => BufferExtensions_1.BufferExtensions.readableToArrayBuffer(httpResponse.body)), effect_1.Effect.match({
|
|
427
|
+
onFailure: (error) => effect_1.Either.left(error),
|
|
428
|
+
onSuccess: (buffer) => (0, effect_1.pipe)(serialization.deserialize(buffer), effect_1.Either.flatMap((encoded) => testResponseCodec.decode(encoded))),
|
|
429
|
+
}));
|
|
430
|
+
const resultE = await effect_1.Effect.runPromise(result);
|
|
431
|
+
expect(resultE).toStrictEqual(effect_1.Either.right(testValue));
|
|
435
432
|
});
|
|
436
433
|
test('should parse an internal error response', async () => {
|
|
437
|
-
const response = await httpClient.execute(Http_1.HttpMethod.Get, baseUrl, Http_1.HttpRequest.create({
|
|
434
|
+
const response = await effect_1.Effect.runPromise(effect_1.Effect.either(httpClient.execute(Http_1.HttpMethod.Get, baseUrl, Http_1.HttpRequest.create({
|
|
438
435
|
headers: { error: '500' },
|
|
439
436
|
pathParams: {},
|
|
440
437
|
queryString: {},
|
|
441
438
|
body: BufferExtensions_1.BufferExtensions.arrayBufferToReadable(new ArrayBuffer(0)),
|
|
442
|
-
}))
|
|
439
|
+
}))));
|
|
443
440
|
const testErrorResponse = {
|
|
444
441
|
message: 'some error message 500',
|
|
445
442
|
};
|
|
446
|
-
if (
|
|
443
|
+
if (effect_1.Either.isLeft(response)) {
|
|
447
444
|
throw response.left;
|
|
448
445
|
}
|
|
449
|
-
const responseBodyE = await BufferExtensions_1.BufferExtensions.readableToArrayBuffer(response.right.body)
|
|
446
|
+
const responseBodyE = await effect_1.Effect.runPromise(effect_1.Effect.either(BufferExtensions_1.BufferExtensions.readableToArrayBuffer(response.right.body)));
|
|
450
447
|
expect(response.right.statusCode).toStrictEqual(500);
|
|
451
|
-
expect(responseBodyE).toStrictEqual(
|
|
448
|
+
expect(responseBodyE).toStrictEqual(effect_1.Either.right(serialization.serialize(testErrorResponseCodec.encode(testErrorResponse))));
|
|
452
449
|
});
|
|
453
450
|
test('should parse a not found error response', async () => {
|
|
454
|
-
const response = await httpClient.execute(Http_1.HttpMethod.Get, baseUrl, Http_1.HttpRequest.create({
|
|
451
|
+
const response = await effect_1.Effect.runPromise(effect_1.Effect.either(httpClient.execute(Http_1.HttpMethod.Get, baseUrl, Http_1.HttpRequest.create({
|
|
455
452
|
headers: { error: '404' },
|
|
456
453
|
pathParams: {},
|
|
457
454
|
queryString: {},
|
|
458
455
|
body: BufferExtensions_1.BufferExtensions.arrayBufferToReadable(new ArrayBuffer(0)),
|
|
459
|
-
}))
|
|
456
|
+
}))));
|
|
460
457
|
const testErrorResponse = {
|
|
461
458
|
message: 'some error message 404',
|
|
462
459
|
};
|
|
463
|
-
if (
|
|
460
|
+
if (effect_1.Either.isLeft(response)) {
|
|
464
461
|
throw response.left;
|
|
465
462
|
}
|
|
466
|
-
const responseBodyE = await BufferExtensions_1.BufferExtensions.readableToArrayBuffer(response.right.body)
|
|
463
|
+
const responseBodyE = await effect_1.Effect.runPromise(effect_1.Effect.either(BufferExtensions_1.BufferExtensions.readableToArrayBuffer(response.right.body)));
|
|
467
464
|
expect(response.right.statusCode).toStrictEqual(404);
|
|
468
|
-
expect(responseBodyE).toStrictEqual(
|
|
465
|
+
expect(responseBodyE).toStrictEqual(effect_1.Either.right(serialization.serialize(testErrorResponseCodec.encode(testErrorResponse))));
|
|
469
466
|
});
|
|
470
467
|
});
|
|
471
468
|
}
|
|
472
|
-
exports.httpClientTest = httpClientTest;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Effect } from 'effect';
|
|
2
2
|
import { HttpMethod, HttpRequest, HttpResponse } from './Http';
|
|
3
3
|
export interface HttpClient {
|
|
4
|
-
execute(method: HttpMethod, url: string, request: HttpRequest):
|
|
4
|
+
execute(method: HttpMethod, url: string, request: HttpRequest): Effect.Effect<HttpResponse, Error>;
|
|
5
5
|
}
|
|
6
6
|
//# sourceMappingURL=HttpClient.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"HttpClient.d.ts","sourceRoot":"","sources":["../../src/http/HttpClient.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"HttpClient.d.ts","sourceRoot":"","sources":["../../src/http/HttpClient.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChC,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAC;AAE/D,MAAM,WAAW,UAAU;IAC1B,OAAO,CACN,MAAM,EAAE,UAAU,EAClB,GAAG,EAAE,MAAM,EACX,OAAO,EAAE,WAAW,GAClB,MAAM,CAAC,MAAM,CAAC,YAAY,EAAE,KAAK,CAAC,CAAC;CACtC"}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import
|
|
2
|
-
import * as O from 'fp-ts/Option';
|
|
1
|
+
import { Effect, Option } from 'effect';
|
|
3
2
|
import { HttpMethod, HttpRequest, HttpResponse } from './Http';
|
|
4
3
|
import { Logging } from '../logging/Logging';
|
|
5
4
|
export interface HttpController {
|
|
@@ -8,6 +7,6 @@ export interface HttpController {
|
|
|
8
7
|
export interface HttpEndpoint {
|
|
9
8
|
path: string;
|
|
10
9
|
method: HttpMethod;
|
|
11
|
-
execute: (logger:
|
|
10
|
+
execute: (logger: Option.Option<Logging>) => (request: HttpRequest) => Effect.Effect<HttpResponse>;
|
|
12
11
|
}
|
|
13
12
|
//# sourceMappingURL=HttpController.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"HttpController.d.ts","sourceRoot":"","sources":["../../src/http/HttpController.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"HttpController.d.ts","sourceRoot":"","sources":["../../src/http/HttpController.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AACxC,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAC;AAC/D,OAAO,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAE7C,MAAM,WAAW,cAAc;IAC9B,YAAY,EAAE,MAAM,aAAa,CAAC,YAAY,CAAC,CAAC;CAChD;AAED,MAAM,WAAW,YAAY;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,UAAU,CAAC;IACnB,OAAO,EAAE,CACR,MAAM,EAAE,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,KAC1B,CAAC,OAAO,EAAE,WAAW,KAAK,MAAM,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC;CAC3D"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { Schema } from 'effect';
|
|
2
|
+
import { HttpAgent, HttpCertificate, HttpContentType, HttpHeaders, HttpMethod, HttpQueryString, HttpQueryStringSingleValue, HttpQueryStringValue } from './Http';
|
|
3
|
+
export declare const httpMethodSchema: Schema.Schema<HttpMethod>;
|
|
4
|
+
export declare const httpContentTypeSchema: Schema.Schema<HttpContentType>;
|
|
5
|
+
export declare const httpQueryStringSingleValueSchema: Schema.Schema<HttpQueryStringSingleValue>;
|
|
6
|
+
export declare const httpQueryStringValueSchema: Schema.Schema<HttpQueryStringValue>;
|
|
7
|
+
export declare const httpQueryStringSchema: Schema.Schema<HttpQueryString>;
|
|
8
|
+
export declare const httpHeadersSchema: Schema.Schema<HttpHeaders>;
|
|
9
|
+
export declare const httpCertificateSchema: Schema.Schema<HttpCertificate>;
|
|
10
|
+
export declare const httpAgentSchema: Schema.Schema<HttpAgent, {
|
|
11
|
+
readonly certificate: HttpCertificate | null | undefined;
|
|
12
|
+
}>;
|
|
13
|
+
//# sourceMappingURL=HttpSchemas.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"HttpSchemas.d.ts","sourceRoot":"","sources":["../../src/http/HttpSchemas.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChC,OAAO,EACN,SAAS,EACT,eAAe,EACf,eAAe,EACf,WAAW,EACX,UAAU,EACV,eAAe,EACf,0BAA0B,EAC1B,oBAAoB,EACpB,MAAM,QAAQ,CAAC;AAEhB,eAAO,MAAM,gBAAgB,EAAE,MAAM,CAAC,MAAM,CAAC,UAAU,CAEZ,CAAC;AAE5C,eAAO,MAAM,qBAAqB,EAAE,MAAM,CAAC,MAAM,CAAC,eAAe,CACY,CAAC;AAE9E,eAAO,MAAM,gCAAgC,EAAE,MAAM,CAAC,MAAM,CAAC,0BAA0B,CAGpF,CAAC;AAEJ,eAAO,MAAM,0BAA0B,EAAE,MAAM,CAAC,MAAM,CAAC,oBAAoB,CAIrB,CAAC;AAEvD,eAAO,MAAM,qBAAqB,EAAE,MAAM,CAAC,MAAM,CAAC,eAAe,CAGhB,CAAC;AAElD,eAAO,MAAM,iBAAiB,EAAE,MAAM,CAAC,MAAM,CAAC,WAAW,CAQb,CAAC;AAE7C,eAAO,MAAM,qBAAqB,EAAE,MAAM,CAAC,MAAM,CAAC,eAAe,CAMhB,CAAC;AAElD,eAAO,MAAM,eAAe,EAAE,MAAM,CAAC,MAAM,CAC1C,SAAS,EACT;IAAE,QAAQ,CAAC,WAAW,EAAE,eAAe,GAAG,IAAI,GAAG,SAAS,CAAA;CAAE,CAKnB,CAAC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.httpAgentSchema = exports.httpCertificateSchema = exports.httpHeadersSchema = exports.httpQueryStringSchema = exports.httpQueryStringValueSchema = exports.httpQueryStringSingleValueSchema = exports.httpContentTypeSchema = exports.httpMethodSchema = void 0;
|
|
4
|
+
const effect_1 = require("effect");
|
|
5
|
+
const Http_1 = require("./Http");
|
|
6
|
+
exports.httpMethodSchema = effect_1.Schema.Enums(Http_1.HttpMethod).annotations({ identifier: 'HttpMethod' });
|
|
7
|
+
exports.httpContentTypeSchema = effect_1.Schema.Enums(Http_1.HttpContentType).annotations({ identifier: 'HttpContentType' });
|
|
8
|
+
exports.httpQueryStringSingleValueSchema = effect_1.Schema.Union(effect_1.Schema.String, effect_1.Schema.Number, effect_1.Schema.Boolean).annotations({
|
|
9
|
+
identifier: 'HttpQueryStringSingleValue',
|
|
10
|
+
});
|
|
11
|
+
exports.httpQueryStringValueSchema = effect_1.Schema.Union(exports.httpQueryStringSingleValueSchema, effect_1.Schema.mutable(effect_1.Schema.Array(exports.httpQueryStringSingleValueSchema))).annotations({ identifier: 'HttpQueryStringValue' });
|
|
12
|
+
exports.httpQueryStringSchema = effect_1.Schema.mutable(effect_1.Schema.Record({ key: effect_1.Schema.String, value: exports.httpQueryStringValueSchema })).annotations({ identifier: 'HttpQueryString' });
|
|
13
|
+
exports.httpHeadersSchema = effect_1.Schema.mutable(effect_1.Schema.Record({
|
|
14
|
+
key: effect_1.Schema.String,
|
|
15
|
+
value: effect_1.Schema.Union(effect_1.Schema.String, effect_1.Schema.mutable(effect_1.Schema.Array(effect_1.Schema.String))),
|
|
16
|
+
})).annotations({ identifier: 'HttpHeaders' });
|
|
17
|
+
exports.httpCertificateSchema = effect_1.Schema.mutable(effect_1.Schema.Struct({
|
|
18
|
+
cert: effect_1.Schema.String,
|
|
19
|
+
key: effect_1.Schema.String,
|
|
20
|
+
})).annotations({ identifier: 'HttpCertificate' });
|
|
21
|
+
exports.httpAgentSchema = effect_1.Schema.mutable(effect_1.Schema.Struct({
|
|
22
|
+
certificate: effect_1.Schema.OptionFromNullishOr(exports.httpCertificateSchema, null),
|
|
23
|
+
})).annotations({ identifier: 'HttpAgent' });
|