@trayio/commons 5.35.0-unstable.fd7158a → 6.0.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/base64/Base64.d.ts +10 -5
- package/dist/base64/Base64.d.ts.map +1 -1
- package/dist/base64/Base64.js +40 -8
- package/dist/base64/Base64.unit.test.js +27 -4
- package/dist/buffer/BufferExtensions.d.ts +4 -4
- package/dist/buffer/BufferExtensions.d.ts.map +1 -1
- package/dist/buffer/BufferExtensions.js +38 -25
- package/dist/buffer/BufferExtensions.unit.test.js +45 -22
- package/dist/callsite/CallSite.js +7 -17
- package/dist/codec/CamelCasePropertyNameCodec.d.ts +2 -2
- package/dist/codec/CamelCasePropertyNameCodec.d.ts.map +1 -1
- package/dist/codec/CamelCasePropertyNameCodec.js +25 -2
- 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 +31 -5
- 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 +26 -2
- package/dist/codec/PartialRedactionCodec.d.ts +2 -2
- package/dist/codec/PartialRedactionCodec.d.ts.map +1 -1
- package/dist/codec/PartialRedactionCodec.js +25 -2
- package/dist/codec/RemoveNullValuesCodec.d.ts +2 -2
- package/dist/codec/RemoveNullValuesCodec.d.ts.map +1 -1
- package/dist/codec/RemoveNullValuesCodec.js +25 -2
- package/dist/codec/RemoveTopLevelTagCodec.d.ts +2 -2
- package/dist/codec/RemoveTopLevelTagCodec.d.ts.map +1 -1
- package/dist/codec/RemoveTopLevelTagCodec.js +25 -2
- package/dist/codec/SensitiveRemoveTagAndRedactCodec.d.ts +2 -2
- package/dist/codec/SensitiveRemoveTagAndRedactCodec.d.ts.map +1 -1
- package/dist/codec/SensitiveRemoveTagAndRedactCodec.js +25 -2
- package/dist/codec/SensitiveRemoveTagAndRedactCodec.unit.test.js +38 -15
- package/dist/codec/SnakeCasePropertyNameCodec.d.ts +2 -2
- package/dist/codec/SnakeCasePropertyNameCodec.d.ts.map +1 -1
- package/dist/codec/SnakeCasePropertyNameCodec.js +25 -2
- package/dist/codec/TypeCodec.d.ts +8 -24
- package/dist/codec/TypeCodec.d.ts.map +1 -1
- package/dist/codec/TypeCodec.js +48 -40
- package/dist/codec/TypeCodec.unit.test.js +38 -12
- package/dist/dynamicschema/DynamicSchema.d.ts +12 -6
- package/dist/dynamicschema/DynamicSchema.d.ts.map +1 -1
- package/dist/dynamicschema/DynamicSchema.js +41 -18
- package/dist/dynamicschema/DynamicSchema.unit.test.js +75 -51
- package/dist/dynamictype/DynamicType.d.ts +20 -17
- package/dist/dynamictype/DynamicType.d.ts.map +1 -1
- package/dist/dynamictype/DynamicType.js +35 -48
- package/dist/file/FakeFileStorage.d.ts +8 -8
- package/dist/file/FakeFileStorage.d.ts.map +1 -1
- package/dist/file/FakeFileStorage.js +40 -16
- package/dist/file/File.d.ts +14 -10
- package/dist/file/File.d.ts.map +1 -1
- package/dist/file/File.js +24 -31
- package/dist/file/FileStorage.abstract.test.d.ts.map +1 -1
- package/dist/file/FileStorage.abstract.test.js +41 -18
- package/dist/file/NodeFsFileStorage.d.ts +11 -9
- package/dist/file/NodeFsFileStorage.d.ts.map +1 -1
- package/dist/file/NodeFsFileStorage.integration.test.js +45 -21
- package/dist/file/NodeFsFileStorage.js +29 -37
- package/dist/http/Http.d.ts +13 -11
- package/dist/http/Http.d.ts.map +1 -1
- package/dist/http/Http.js +22 -30
- package/dist/http/Http.unit.test.js +26 -3
- package/dist/http/HttpClient.abstract.test.d.ts.map +1 -1
- package/dist/http/HttpClient.abstract.test.js +108 -104
- package/dist/http/HttpClient.d.ts +2 -2
- package/dist/http/HttpClient.d.ts.map +1 -1
- package/dist/http/HttpController.d.ts +3 -2
- package/dist/http/HttpController.d.ts.map +1 -1
- package/dist/http/HttpTypeDescriptors.d.ts +11 -0
- package/dist/http/HttpTypeDescriptors.d.ts.map +1 -0
- package/dist/http/HttpTypeDescriptors.js +59 -0
- package/dist/http/MultipartHttpRequestBody.integration.test.js +20 -31
- package/dist/http/MultipartHttpRequestBody.unit.test.js +53 -70
- package/dist/record/Record.d.ts +3 -3
- package/dist/record/Record.d.ts.map +1 -1
- package/dist/record/Record.js +30 -9
- package/dist/result/Result.d.ts +3 -3
- package/dist/result/Result.d.ts.map +1 -1
- package/dist/result/Result.js +26 -9
- package/dist/schema/JsonSchemaIntrospector.js +7 -17
- package/dist/sensitive/Sensitive.d.ts +3 -7
- package/dist/sensitive/Sensitive.d.ts.map +1 -1
- package/dist/sensitive/Sensitive.js +39 -23
- 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 +46 -20
- package/dist/serialization/FormUrlEncodedSerialization.d.ts +2 -2
- package/dist/serialization/FormUrlEncodedSerialization.d.ts.map +1 -1
- package/dist/serialization/FormUrlEncodedSerialization.js +28 -5
- package/dist/serialization/JsonSerialization.d.ts +2 -2
- package/dist/serialization/JsonSerialization.d.ts.map +1 -1
- package/dist/serialization/JsonSerialization.js +28 -5
- package/dist/serialization/Serialization.abstract.test.d.ts.map +1 -1
- package/dist/serialization/Serialization.abstract.test.js +32 -6
- package/dist/serialization/Serialization.d.ts +2 -2
- package/dist/serialization/Serialization.d.ts.map +1 -1
- package/dist/task/Task.d.ts +19 -0
- package/dist/task/Task.d.ts.map +1 -0
- package/dist/task/Task.js +74 -0
- package/dist/task/Task.unit.test.d.ts +2 -0
- package/dist/task/Task.unit.test.d.ts.map +1 -0
- package/dist/task/Task.unit.test.js +46 -0
- package/dist/try/Try.d.ts +2 -2
- package/dist/try/Try.d.ts.map +1 -1
- package/dist/try/Try.js +32 -2
- package/dist/uuid/Uuid.d.ts +10 -11
- package/dist/uuid/Uuid.d.ts.map +1 -1
- package/dist/uuid/Uuid.js +39 -13
- package/dist/uuid/Uuid.unit.test.js +27 -4
- package/dist/zod/SchemaParser.abstract.test.d.ts.map +1 -1
- package/dist/zod/SchemaParser.abstract.test.js +31 -6
- package/dist/zod/SchemaParser.d.ts +2 -2
- package/dist/zod/SchemaParser.d.ts.map +1 -1
- package/dist/zod/ZodSchemaParser.d.ts +4 -3
- package/dist/zod/ZodSchemaParser.d.ts.map +1 -1
- package/dist/zod/ZodSchemaParser.js +28 -4
- package/dist/zod/ZodSchemaParser.unit.test.js +25 -2
- package/package.json +9 -4
- package/dist/effect/EffectExtensions.d.ts +0 -29
- package/dist/effect/EffectExtensions.d.ts.map +0 -1
- package/dist/effect/EffectExtensions.js +0 -30
- package/dist/effect/EffectExtensions.unit.test.d.ts +0 -2
- package/dist/effect/EffectExtensions.unit.test.d.ts.map +0 -1
- package/dist/effect/EffectExtensions.unit.test.js +0 -59
- package/dist/effect/Interop.d.ts +0 -53
- package/dist/effect/Interop.d.ts.map +0 -1
- package/dist/effect/Interop.js +0 -56
- package/dist/effect/Interop.unit.test.d.ts +0 -2
- package/dist/effect/Interop.unit.test.d.ts.map +0 -1
- package/dist/effect/Interop.unit.test.js +0 -134
- package/dist/effect/SchemaExtensions.d.ts +0 -11
- package/dist/effect/SchemaExtensions.d.ts.map +0 -1
- package/dist/effect/SchemaExtensions.js +0 -7
- package/dist/effect/SchemaExtensions.unit.test.d.ts +0 -2
- package/dist/effect/SchemaExtensions.unit.test.d.ts.map +0 -1
- package/dist/effect/SchemaExtensions.unit.test.js +0 -29
- package/dist/http/HttpSchemas.d.ts +0 -13
- package/dist/http/HttpSchemas.d.ts.map +0 -1
- package/dist/http/HttpSchemas.js +0 -23
- package/dist/schema/DateFromUnixTime.d.ts +0 -4
- package/dist/schema/DateFromUnixTime.d.ts.map +0 -1
- package/dist/schema/DateFromUnixTime.js +0 -10
- package/dist/schema/DateFromUnixTime.unit.test.d.ts +0 -2
- package/dist/schema/DateFromUnixTime.unit.test.d.ts.map +0 -1
- package/dist/schema/DateFromUnixTime.unit.test.js +0 -11
package/dist/effect/Interop.js
DELETED
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.codecFromIoTs = exports.schemaFromIoTs = exports.toTaskEither = exports.fromTaskEither = exports.toTask = exports.fromTask = exports.toFpEither = exports.fromFpEither = exports.toFpOption = exports.fromFpOption = void 0;
|
|
4
|
-
const effect_1 = require("effect");
|
|
5
|
-
const fromFpOption = (option) => option._tag === 'Some' ? effect_1.Option.some(option.value) : effect_1.Option.none();
|
|
6
|
-
exports.fromFpOption = fromFpOption;
|
|
7
|
-
const toFpOption = (option) => effect_1.Option.match(option, {
|
|
8
|
-
onNone: () => ({ _tag: 'None' }),
|
|
9
|
-
onSome: (value) => ({ _tag: 'Some', value }),
|
|
10
|
-
});
|
|
11
|
-
exports.toFpOption = toFpOption;
|
|
12
|
-
const fromFpEither = (either) => either._tag === 'Right'
|
|
13
|
-
? effect_1.Either.right(either.right)
|
|
14
|
-
: effect_1.Either.left(either.left);
|
|
15
|
-
exports.fromFpEither = fromFpEither;
|
|
16
|
-
const toFpEither = (either) => effect_1.Either.match(either, {
|
|
17
|
-
onLeft: (left) => ({ _tag: 'Left', left }),
|
|
18
|
-
onRight: (right) => ({ _tag: 'Right', right }),
|
|
19
|
-
});
|
|
20
|
-
exports.toFpEither = toFpEither;
|
|
21
|
-
const fromTask = (task) => effect_1.Effect.promise(task);
|
|
22
|
-
exports.fromTask = fromTask;
|
|
23
|
-
const toTask = (effect) => () => effect_1.Effect.runPromise(effect);
|
|
24
|
-
exports.toTask = toTask;
|
|
25
|
-
const fromTaskEither = (taskEither) => effect_1.Effect.flatMap(effect_1.Effect.promise(taskEither), exports.fromFpEither);
|
|
26
|
-
exports.fromTaskEither = fromTaskEither;
|
|
27
|
-
const toTaskEither = (effect) => () => effect_1.Effect.runPromise(effect_1.Effect.either(effect)).then(exports.toFpEither);
|
|
28
|
-
exports.toTaskEither = toTaskEither;
|
|
29
|
-
const formatIoTsErrors = (errors) => errors
|
|
30
|
-
.map((error) => {
|
|
31
|
-
const path = error.context
|
|
32
|
-
.map((c) => c.key)
|
|
33
|
-
.filter((key) => key !== '')
|
|
34
|
-
.join('.');
|
|
35
|
-
const message = error.message ?? `Invalid value ${JSON.stringify(error.value)}`;
|
|
36
|
-
return path ? `${path}: ${message}` : message;
|
|
37
|
-
})
|
|
38
|
-
.join(', ');
|
|
39
|
-
/** An Effect Schema that decodes and encodes through an existing io-ts type. */
|
|
40
|
-
const schemaFromIoTs = (type) => effect_1.Schema.transformOrFail(effect_1.Schema.Unknown, effect_1.Schema.declare((u) => type.is(u), {
|
|
41
|
-
identifier: type.name,
|
|
42
|
-
}), {
|
|
43
|
-
strict: true,
|
|
44
|
-
decode: (input, _options, ast) => effect_1.Either.match((0, exports.fromFpEither)(type.decode(input)), {
|
|
45
|
-
onLeft: (errors) => effect_1.ParseResult.fail(new effect_1.ParseResult.Type(ast, input, formatIoTsErrors(errors))),
|
|
46
|
-
onRight: (value) => effect_1.ParseResult.succeed(value),
|
|
47
|
-
}),
|
|
48
|
-
encode: (value) => effect_1.ParseResult.succeed(type.encode(value)),
|
|
49
|
-
}).annotations({ identifier: type.name });
|
|
50
|
-
exports.schemaFromIoTs = schemaFromIoTs;
|
|
51
|
-
/** A Codec backed by an existing io-ts type. */
|
|
52
|
-
const codecFromIoTs = (type) => ({
|
|
53
|
-
encode: (value) => type.encode(value),
|
|
54
|
-
decode: (value) => effect_1.Either.mapLeft((0, exports.fromFpEither)(type.decode(value)), (errors) => new Error(formatIoTsErrors(errors))),
|
|
55
|
-
});
|
|
56
|
-
exports.codecFromIoTs = codecFromIoTs;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Interop.unit.test.d.ts","sourceRoot":"","sources":["../../src/effect/Interop.unit.test.ts"],"names":[],"mappings":""}
|
|
@@ -1,134 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const effect_1 = require("effect");
|
|
4
|
-
const Interop_1 = require("./Interop");
|
|
5
|
-
const isPerson = (u) => typeof u === 'object' &&
|
|
6
|
-
u !== null &&
|
|
7
|
-
typeof u.name === 'string' &&
|
|
8
|
-
typeof u.age === 'number';
|
|
9
|
-
/** Behaves like `t.type({ name: t.string, age: t.number }, 'Person')`, including io-ts' error shape. */
|
|
10
|
-
const personType = {
|
|
11
|
-
name: 'Person',
|
|
12
|
-
is: isPerson,
|
|
13
|
-
decode: (u) => isPerson(u)
|
|
14
|
-
? { _tag: 'Right', right: u }
|
|
15
|
-
: {
|
|
16
|
-
_tag: 'Left',
|
|
17
|
-
left: [
|
|
18
|
-
{
|
|
19
|
-
value: u,
|
|
20
|
-
context: [{ key: '' }, { key: 'age' }],
|
|
21
|
-
message: 'expected a number',
|
|
22
|
-
},
|
|
23
|
-
{ value: u, context: [{ key: '' }, { key: 'name' }] },
|
|
24
|
-
],
|
|
25
|
-
},
|
|
26
|
-
encode: (person) => ({ ...person, encoded: true }),
|
|
27
|
-
};
|
|
28
|
-
describe('Interop', () => {
|
|
29
|
-
describe('Option', () => {
|
|
30
|
-
it('converts fp-ts Some and None to Effect options', () => {
|
|
31
|
-
expect((0, Interop_1.fromFpOption)({ _tag: 'Some', value: 1 })).toEqual(effect_1.Option.some(1));
|
|
32
|
-
expect((0, Interop_1.fromFpOption)({ _tag: 'None' })).toEqual(effect_1.Option.none());
|
|
33
|
-
});
|
|
34
|
-
it('converts Effect options to plain fp-ts shapes', () => {
|
|
35
|
-
expect((0, Interop_1.toFpOption)(effect_1.Option.some(1))).toStrictEqual({
|
|
36
|
-
_tag: 'Some',
|
|
37
|
-
value: 1,
|
|
38
|
-
});
|
|
39
|
-
expect((0, Interop_1.toFpOption)(effect_1.Option.none())).toStrictEqual({ _tag: 'None' });
|
|
40
|
-
});
|
|
41
|
-
it('round trips', () => {
|
|
42
|
-
expect((0, Interop_1.toFpOption)((0, Interop_1.fromFpOption)({ _tag: 'Some', value: 'x' }))).toStrictEqual({ _tag: 'Some', value: 'x' });
|
|
43
|
-
});
|
|
44
|
-
});
|
|
45
|
-
describe('Either', () => {
|
|
46
|
-
it('converts fp-ts Right and Left, swapping the type parameter order', () => {
|
|
47
|
-
expect((0, Interop_1.fromFpEither)({ _tag: 'Right', right: 1 })).toEqual(effect_1.Either.right(1));
|
|
48
|
-
expect((0, Interop_1.fromFpEither)({ _tag: 'Left', left: 'boom' })).toEqual(effect_1.Either.left('boom'));
|
|
49
|
-
});
|
|
50
|
-
it('converts Effect eithers to plain fp-ts shapes', () => {
|
|
51
|
-
expect((0, Interop_1.toFpEither)(effect_1.Either.right(1))).toStrictEqual({
|
|
52
|
-
_tag: 'Right',
|
|
53
|
-
right: 1,
|
|
54
|
-
});
|
|
55
|
-
expect((0, Interop_1.toFpEither)(effect_1.Either.left('boom'))).toStrictEqual({
|
|
56
|
-
_tag: 'Left',
|
|
57
|
-
left: 'boom',
|
|
58
|
-
});
|
|
59
|
-
});
|
|
60
|
-
});
|
|
61
|
-
describe('Task and TaskEither', () => {
|
|
62
|
-
it('runs an fp-ts Task as an effect', async () => {
|
|
63
|
-
expect(await effect_1.Effect.runPromise((0, Interop_1.fromTask)(async () => 42))).toEqual(42);
|
|
64
|
-
});
|
|
65
|
-
it('exposes an effect as an fp-ts Task', async () => {
|
|
66
|
-
expect(await (0, Interop_1.toTask)(effect_1.Effect.succeed(42))()).toEqual(42);
|
|
67
|
-
});
|
|
68
|
-
it('lifts a TaskEither success and failure into the effect channels', async () => {
|
|
69
|
-
const success = { _tag: 'Right', right: 1 };
|
|
70
|
-
const failure = { _tag: 'Left', left: 'boom' };
|
|
71
|
-
expect(await effect_1.Effect.runPromise(effect_1.Effect.either((0, Interop_1.fromTaskEither)(async () => success)))).toEqual(effect_1.Either.right(1));
|
|
72
|
-
expect(await effect_1.Effect.runPromise(effect_1.Effect.either((0, Interop_1.fromTaskEither)(async () => failure)))).toEqual(effect_1.Either.left('boom'));
|
|
73
|
-
});
|
|
74
|
-
it('exposes an effect as a TaskEither that never rejects on typed failures', async () => {
|
|
75
|
-
expect(await (0, Interop_1.toTaskEither)(effect_1.Effect.succeed(1))()).toStrictEqual({
|
|
76
|
-
_tag: 'Right',
|
|
77
|
-
right: 1,
|
|
78
|
-
});
|
|
79
|
-
expect(await (0, Interop_1.toTaskEither)(effect_1.Effect.fail('boom'))()).toStrictEqual({
|
|
80
|
-
_tag: 'Left',
|
|
81
|
-
left: 'boom',
|
|
82
|
-
});
|
|
83
|
-
});
|
|
84
|
-
});
|
|
85
|
-
describe('schemaFromIoTs', () => {
|
|
86
|
-
const schema = (0, Interop_1.schemaFromIoTs)(personType);
|
|
87
|
-
const decode = effect_1.Schema.decodeUnknownEither(schema);
|
|
88
|
-
it('decodes through the io-ts type', () => {
|
|
89
|
-
expect(decode({ name: 'Ada', age: 36 })).toEqual(effect_1.Either.right({ name: 'Ada', age: 36 }));
|
|
90
|
-
});
|
|
91
|
-
it('reports io-ts errors as a parse error with the io-ts-reporters style message', () => {
|
|
92
|
-
const result = decode({ name: 'Ada' });
|
|
93
|
-
expect(effect_1.Either.isLeft(result)).toBe(true);
|
|
94
|
-
const message = effect_1.Either.match(result, {
|
|
95
|
-
onLeft: (error) => error.message,
|
|
96
|
-
onRight: () => '',
|
|
97
|
-
});
|
|
98
|
-
expect(message).toContain('age: expected a number');
|
|
99
|
-
expect(message).toContain('name: Invalid value {"name":"Ada"}');
|
|
100
|
-
});
|
|
101
|
-
it('encodes through the io-ts type', () => {
|
|
102
|
-
expect(effect_1.Schema.encodeSync(schema)({ name: 'Ada', age: 36 })).toEqual({
|
|
103
|
-
name: 'Ada',
|
|
104
|
-
age: 36,
|
|
105
|
-
encoded: true,
|
|
106
|
-
});
|
|
107
|
-
});
|
|
108
|
-
it('carries the io-ts name as its identifier', () => {
|
|
109
|
-
expect(String(schema.ast)).toEqual('Person');
|
|
110
|
-
});
|
|
111
|
-
});
|
|
112
|
-
describe('codecFromIoTs', () => {
|
|
113
|
-
const codec = (0, Interop_1.codecFromIoTs)(personType);
|
|
114
|
-
it('decodes valid values', () => {
|
|
115
|
-
expect(codec.decode({ name: 'Ada', age: 36 })).toEqual(effect_1.Either.right({ name: 'Ada', age: 36 }));
|
|
116
|
-
});
|
|
117
|
-
it('decodes invalid values to an Error with every io-ts issue', () => {
|
|
118
|
-
const result = codec.decode(null);
|
|
119
|
-
expect(effect_1.Either.isLeft(result)).toBe(true);
|
|
120
|
-
const message = effect_1.Either.match(result, {
|
|
121
|
-
onLeft: (error) => error.message,
|
|
122
|
-
onRight: () => '',
|
|
123
|
-
});
|
|
124
|
-
expect(message).toEqual('age: expected a number, name: Invalid value null');
|
|
125
|
-
});
|
|
126
|
-
it('encodes through the io-ts type', () => {
|
|
127
|
-
expect(codec.encode({ name: 'Ada', age: 36 })).toEqual({
|
|
128
|
-
name: 'Ada',
|
|
129
|
-
age: 36,
|
|
130
|
-
encoded: true,
|
|
131
|
-
});
|
|
132
|
-
});
|
|
133
|
-
});
|
|
134
|
-
});
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { Schema } from 'effect';
|
|
2
|
-
export interface SchemaExtensionsInterface {
|
|
3
|
-
/**
|
|
4
|
-
* A human readable name for a schema: its identifier annotation when present (set with
|
|
5
|
-
* `.annotations({ identifier })`), otherwise its title, otherwise the rendered AST.
|
|
6
|
-
* Replaces reading `.name` off an io-ts type.
|
|
7
|
-
*/
|
|
8
|
-
nameOf: (schema: Schema.Schema.All) => string;
|
|
9
|
-
}
|
|
10
|
-
export declare const SchemaExtensions: SchemaExtensionsInterface;
|
|
11
|
-
//# sourceMappingURL=SchemaExtensions.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"SchemaExtensions.d.ts","sourceRoot":"","sources":["../../src/effect/SchemaExtensions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAU,MAAM,EAAa,MAAM,QAAQ,CAAC;AAEnD,MAAM,WAAW,yBAAyB;IACzC;;;;OAIG;IACH,MAAM,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,CAAC,GAAG,KAAK,MAAM,CAAC;CAC9C;AAED,eAAO,MAAM,gBAAgB,EAAE,yBAQ9B,CAAC"}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.SchemaExtensions = void 0;
|
|
4
|
-
const effect_1 = require("effect");
|
|
5
|
-
exports.SchemaExtensions = {
|
|
6
|
-
nameOf: (schema) => effect_1.Option.getOrElse(effect_1.Option.orElse(effect_1.SchemaAST.getIdentifierAnnotation(schema.ast), () => effect_1.SchemaAST.getTitleAnnotation(schema.ast)), () => String(schema.ast)),
|
|
7
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"SchemaExtensions.unit.test.d.ts","sourceRoot":"","sources":["../../src/effect/SchemaExtensions.unit.test.ts"],"names":[],"mappings":""}
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const effect_1 = require("effect");
|
|
4
|
-
const SchemaExtensions_1 = require("./SchemaExtensions");
|
|
5
|
-
describe('SchemaExtensions.nameOf', () => {
|
|
6
|
-
it('returns the identifier annotation when present', () => {
|
|
7
|
-
const schema = effect_1.Schema.Struct({ id: effect_1.Schema.String }).annotations({
|
|
8
|
-
identifier: 'Thing',
|
|
9
|
-
title: 'A thing',
|
|
10
|
-
});
|
|
11
|
-
expect(SchemaExtensions_1.SchemaExtensions.nameOf(schema)).toEqual('Thing');
|
|
12
|
-
});
|
|
13
|
-
it('falls back to the title annotation when there is no identifier', () => {
|
|
14
|
-
const schema = effect_1.Schema.Struct({ id: effect_1.Schema.String }).annotations({
|
|
15
|
-
title: 'A thing',
|
|
16
|
-
});
|
|
17
|
-
expect(SchemaExtensions_1.SchemaExtensions.nameOf(schema)).toEqual('A thing');
|
|
18
|
-
});
|
|
19
|
-
it('falls back to the rendered AST when there are no annotations', () => {
|
|
20
|
-
expect(SchemaExtensions_1.SchemaExtensions.nameOf(effect_1.Schema.Struct({ id: effect_1.Schema.String }))).toEqual('{ readonly id: string }');
|
|
21
|
-
expect(SchemaExtensions_1.SchemaExtensions.nameOf(effect_1.Schema.String)).toEqual('string');
|
|
22
|
-
});
|
|
23
|
-
it('reads the identifier through a transformation', () => {
|
|
24
|
-
const schema = effect_1.Schema.OptionFromNullishOr(effect_1.Schema.String, null).annotations({
|
|
25
|
-
identifier: 'MaybeString',
|
|
26
|
-
});
|
|
27
|
-
expect(SchemaExtensions_1.SchemaExtensions.nameOf(schema)).toEqual('MaybeString');
|
|
28
|
-
});
|
|
29
|
-
});
|
|
@@ -1,13 +0,0 @@
|
|
|
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
|
|
@@ -1 +0,0 @@
|
|
|
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"}
|
package/dist/http/HttpSchemas.js
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
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' });
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import { Schema } from 'effect';
|
|
2
|
-
/** Seconds since the Unix epoch on the wire, a Date in memory. Replaces io-ts-types' `DateFromUnixTime`. */
|
|
3
|
-
export declare const DateFromUnixTime: Schema.transform<typeof Schema.Number, typeof Schema.DateFromSelf>;
|
|
4
|
-
//# sourceMappingURL=DateFromUnixTime.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"DateFromUnixTime.d.ts","sourceRoot":"","sources":["../../src/schema/DateFromUnixTime.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAEhC,4GAA4G;AAC5G,eAAO,MAAM,gBAAgB,oEAQoB,CAAC"}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.DateFromUnixTime = void 0;
|
|
4
|
-
const effect_1 = require("effect");
|
|
5
|
-
/** Seconds since the Unix epoch on the wire, a Date in memory. Replaces io-ts-types' `DateFromUnixTime`. */
|
|
6
|
-
exports.DateFromUnixTime = effect_1.Schema.transform(effect_1.Schema.Number, effect_1.Schema.DateFromSelf, {
|
|
7
|
-
strict: true,
|
|
8
|
-
decode: (seconds) => new Date(seconds * 1000),
|
|
9
|
-
encode: (date) => Math.floor(date.getTime() / 1000),
|
|
10
|
-
}).annotations({ identifier: 'DateFromUnixTime' });
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"DateFromUnixTime.unit.test.d.ts","sourceRoot":"","sources":["../../src/schema/DateFromUnixTime.unit.test.ts"],"names":[],"mappings":""}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const effect_1 = require("effect");
|
|
4
|
-
const DateFromUnixTime_1 = require("./DateFromUnixTime");
|
|
5
|
-
describe('DateFromUnixTime', () => {
|
|
6
|
-
it('decodes seconds to a Date and encodes back to whole seconds', () => {
|
|
7
|
-
const decoded = effect_1.Schema.decodeUnknownSync(DateFromUnixTime_1.DateFromUnixTime)(1700000000);
|
|
8
|
-
expect(decoded.toISOString()).toBe('2023-11-14T22:13:20.000Z');
|
|
9
|
-
expect(effect_1.Schema.encodeSync(DateFromUnixTime_1.DateFromUnixTime)(new Date(1700000000500))).toBe(1700000000);
|
|
10
|
-
});
|
|
11
|
-
});
|