effect 4.0.0-beta.105 → 4.0.0-beta.106
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/Config.js +3 -3
- package/dist/Config.js.map +1 -1
- package/dist/ConfigProvider.d.ts +35 -3
- package/dist/ConfigProvider.d.ts.map +1 -1
- package/dist/ConfigProvider.js +41 -8
- package/dist/ConfigProvider.js.map +1 -1
- package/dist/Fiber.d.ts +1 -1
- package/dist/Fiber.d.ts.map +1 -1
- package/dist/Function.d.ts +26 -0
- package/dist/Function.d.ts.map +1 -1
- package/dist/Function.js +36 -0
- package/dist/Function.js.map +1 -1
- package/dist/JsonSchema.d.ts.map +1 -1
- package/dist/JsonSchema.js +34 -17
- package/dist/JsonSchema.js.map +1 -1
- package/dist/Schema.d.ts +32 -84
- package/dist/Schema.d.ts.map +1 -1
- package/dist/Schema.js +58 -54
- package/dist/Schema.js.map +1 -1
- package/dist/SchemaAST.d.ts +2 -17
- package/dist/SchemaAST.d.ts.map +1 -1
- package/dist/SchemaAST.js +39 -28
- package/dist/SchemaAST.js.map +1 -1
- package/dist/SchemaRepresentation.d.ts +15 -3
- package/dist/SchemaRepresentation.d.ts.map +1 -1
- package/dist/SchemaRepresentation.js +8 -2
- package/dist/SchemaRepresentation.js.map +1 -1
- package/dist/ScopedRef.d.ts.map +1 -1
- package/dist/ScopedRef.js +1 -1
- package/dist/ScopedRef.js.map +1 -1
- package/dist/TxQueue.js +1 -1
- package/dist/TxQueue.js.map +1 -1
- package/dist/internal/effect.js +2 -4
- package/dist/internal/effect.js.map +1 -1
- package/dist/internal/executionPlan.js +3 -2
- package/dist/internal/executionPlan.js.map +1 -1
- package/dist/internal/rcRef.js +18 -13
- package/dist/internal/rcRef.js.map +1 -1
- package/dist/internal/schema/fromJsonSchemaDocument.js +10 -6
- package/dist/internal/schema/fromJsonSchemaDocument.js.map +1 -1
- package/dist/internal/schema/toArbitrary.d.ts +1 -4
- package/dist/internal/schema/toArbitrary.d.ts.map +1 -1
- package/dist/internal/schema/toArbitrary.js +0 -74
- package/dist/internal/schema/toArbitrary.js.map +1 -1
- package/dist/internal/schema/toJsonSchemaDocument.js +18 -4
- package/dist/internal/schema/toJsonSchemaDocument.js.map +1 -1
- package/dist/internal/schema/toRepresentation.js +45 -43
- package/dist/internal/schema/toRepresentation.js.map +1 -1
- package/dist/testing/TestSchema.js +2 -2
- package/dist/testing/TestSchema.js.map +1 -1
- package/dist/unstable/ai/McpSchema.d.ts +110 -110
- package/dist/unstable/ai/McpSchema.d.ts.map +1 -1
- package/dist/unstable/ai/McpServer.d.ts.map +1 -1
- package/dist/unstable/ai/McpServer.js +23 -11
- package/dist/unstable/ai/McpServer.js.map +1 -1
- package/dist/unstable/ai/Prompt.d.ts +4 -3
- package/dist/unstable/ai/Prompt.d.ts.map +1 -1
- package/dist/unstable/ai/Prompt.js +38 -13
- package/dist/unstable/ai/Prompt.js.map +1 -1
- package/dist/unstable/cluster/Entity.d.ts +2 -2
- package/dist/unstable/cluster/Entity.d.ts.map +1 -1
- package/dist/unstable/cluster/Entity.js.map +1 -1
- package/dist/unstable/cluster/EntityProxy.d.ts +3 -3
- package/dist/unstable/cluster/EntityProxy.d.ts.map +1 -1
- package/dist/unstable/cluster/EntityProxy.js +4 -3
- package/dist/unstable/cluster/EntityProxy.js.map +1 -1
- package/dist/unstable/cluster/Sharding.d.ts +2 -2
- package/dist/unstable/cluster/Sharding.d.ts.map +1 -1
- package/dist/unstable/cluster/Sharding.js +14 -5
- package/dist/unstable/cluster/Sharding.js.map +1 -1
- package/dist/unstable/eventlog/EventLogEncryption.d.ts +6 -5
- package/dist/unstable/eventlog/EventLogEncryption.d.ts.map +1 -1
- package/dist/unstable/eventlog/EventLogEncryption.js +14 -12
- package/dist/unstable/eventlog/EventLogEncryption.js.map +1 -1
- package/dist/unstable/eventlog/EventLogMessage.d.ts +3 -3
- package/dist/unstable/eventlog/EventLogMessage.d.ts.map +1 -1
- package/dist/unstable/eventlog/EventLogMessage.js +2 -3
- package/dist/unstable/eventlog/EventLogMessage.js.map +1 -1
- package/dist/unstable/eventlog/EventLogRemote.js +4 -4
- package/dist/unstable/eventlog/EventLogRemote.js.map +1 -1
- package/dist/unstable/eventlog/EventLogServerEncrypted.js +3 -2
- package/dist/unstable/eventlog/EventLogServerEncrypted.js.map +1 -1
- package/dist/unstable/http/HttpServerRequest.d.ts.map +1 -1
- package/dist/unstable/http/HttpServerRequest.js +7 -1
- package/dist/unstable/http/HttpServerRequest.js.map +1 -1
- package/dist/unstable/http/MultipartParser/internal/multipart.d.ts.map +1 -1
- package/dist/unstable/http/MultipartParser/internal/multipart.js +18 -6
- package/dist/unstable/http/MultipartParser/internal/multipart.js.map +1 -1
- package/dist/unstable/httpapi/OpenApi.d.ts.map +1 -1
- package/dist/unstable/httpapi/OpenApi.js +1 -1
- package/dist/unstable/httpapi/OpenApi.js.map +1 -1
- package/dist/unstable/rpc/RpcClient.d.ts.map +1 -1
- package/dist/unstable/rpc/RpcClient.js +5 -0
- package/dist/unstable/rpc/RpcClient.js.map +1 -1
- package/dist/unstable/sql/SqlResolver.d.ts.map +1 -1
- package/dist/unstable/sql/SqlResolver.js +20 -16
- package/dist/unstable/sql/SqlResolver.js.map +1 -1
- package/dist/unstable/workers/Worker.d.ts.map +1 -1
- package/dist/unstable/workers/Worker.js +11 -12
- package/dist/unstable/workers/Worker.js.map +1 -1
- package/package.json +1 -1
- package/src/Config.ts +3 -3
- package/src/ConfigProvider.ts +43 -8
- package/src/Fiber.ts +1 -1
- package/src/Function.ts +37 -0
- package/src/JsonSchema.ts +43 -42
- package/src/Schema.ts +68 -146
- package/src/SchemaAST.ts +50 -30
- package/src/SchemaRepresentation.ts +15 -3
- package/src/ScopedRef.ts +3 -1
- package/src/TxQueue.ts +1 -1
- package/src/internal/effect.ts +3 -6
- package/src/internal/executionPlan.ts +3 -2
- package/src/internal/rcRef.ts +24 -16
- package/src/internal/schema/fromJsonSchemaDocument.ts +19 -14
- package/src/internal/schema/toArbitrary.ts +0 -72
- package/src/internal/schema/toJsonSchemaDocument.ts +24 -4
- package/src/internal/schema/toRepresentation.ts +66 -48
- package/src/testing/TestSchema.ts +2 -2
- package/src/unstable/ai/McpServer.ts +23 -11
- package/src/unstable/ai/Prompt.ts +37 -15
- package/src/unstable/cluster/Entity.ts +7 -2
- package/src/unstable/cluster/EntityProxy.ts +12 -5
- package/src/unstable/cluster/Sharding.ts +29 -17
- package/src/unstable/eventlog/EventLogEncryption.ts +15 -16
- package/src/unstable/eventlog/EventLogMessage.ts +2 -3
- package/src/unstable/eventlog/EventLogRemote.ts +4 -4
- package/src/unstable/eventlog/EventLogServerEncrypted.ts +2 -2
- package/src/unstable/http/HttpServerRequest.ts +8 -3
- package/src/unstable/http/MultipartParser/internal/multipart.ts +19 -6
- package/src/unstable/httpapi/OpenApi.ts +4 -1
- package/src/unstable/rpc/RpcClient.ts +5 -0
- package/src/unstable/sql/SqlResolver.ts +28 -20
- package/src/unstable/workers/Worker.ts +13 -14
package/dist/Schema.js
CHANGED
|
@@ -55,7 +55,6 @@ import * as SchemaIssue from "./SchemaIssue.js";
|
|
|
55
55
|
import * as SchemaParser from "./SchemaParser.js";
|
|
56
56
|
import * as SchemaTransformation from "./SchemaTransformation.js";
|
|
57
57
|
import * as Struct_ from "./Struct.js";
|
|
58
|
-
import * as FastCheck from "./testing/FastCheck.js";
|
|
59
58
|
const TypeId = InternalSchema.TypeId;
|
|
60
59
|
/**
|
|
61
60
|
* Creates a schema for a **parametric** type (a generic container such as
|
|
@@ -1475,7 +1474,12 @@ export const requiredKey = /*#__PURE__*/Struct_.lambda(self => self.schema);
|
|
|
1475
1474
|
* @category combinators
|
|
1476
1475
|
* @since 3.10.0
|
|
1477
1476
|
*/
|
|
1478
|
-
export const optional = /*#__PURE__*/Struct_.lambda(self =>
|
|
1477
|
+
export const optional = /*#__PURE__*/Struct_.lambda(self => {
|
|
1478
|
+
const schema = UndefinedOr(self);
|
|
1479
|
+
return make(SchemaAST.optional(self.ast), {
|
|
1480
|
+
schema
|
|
1481
|
+
});
|
|
1482
|
+
});
|
|
1479
1483
|
/**
|
|
1480
1484
|
* Reverses `optional` and returns the inner schema.
|
|
1481
1485
|
*
|
|
@@ -2665,7 +2669,7 @@ export function decodeTo(to, transformation) {
|
|
|
2665
2669
|
* ```
|
|
2666
2670
|
*
|
|
2667
2671
|
* @category transforming
|
|
2668
|
-
* @since
|
|
2672
|
+
* @since 4.0.0
|
|
2669
2673
|
*/
|
|
2670
2674
|
export function decode(transformation) {
|
|
2671
2675
|
return self => {
|
|
@@ -2701,7 +2705,7 @@ export function encodeTo(to, transformation) {
|
|
|
2701
2705
|
* ```
|
|
2702
2706
|
*
|
|
2703
2707
|
* @category transforming
|
|
2704
|
-
* @since
|
|
2708
|
+
* @since 4.0.0
|
|
2705
2709
|
*/
|
|
2706
2710
|
export function encode(transformation) {
|
|
2707
2711
|
return self => {
|
|
@@ -9212,35 +9216,41 @@ export const TaggedError = identifier => {
|
|
|
9212
9216
|
};
|
|
9213
9217
|
};
|
|
9214
9218
|
/**
|
|
9215
|
-
*
|
|
9216
|
-
*
|
|
9219
|
+
* Returns an {@link Arbitrary} factory derived from a schema. The generated
|
|
9220
|
+
* values satisfy the schema and use its decoded `Type`.
|
|
9221
|
+
*
|
|
9222
|
+
* **When to use**
|
|
9223
|
+
*
|
|
9224
|
+
* Use when you need a fast-check generator for values accepted by a schema.
|
|
9217
9225
|
*
|
|
9218
9226
|
* **Details**
|
|
9219
9227
|
*
|
|
9220
|
-
*
|
|
9221
|
-
*
|
|
9222
|
-
*
|
|
9223
|
-
*
|
|
9228
|
+
* Constraints refine base generators; candidates add weighted sources while
|
|
9229
|
+
* filters still validate every value. Recursive schemas use terminal branches
|
|
9230
|
+
* and fail when no finite terminal path exists. The result is memoized so
|
|
9231
|
+
* repeated calls with the same schema are cheap.
|
|
9232
|
+
*
|
|
9233
|
+
* **Example** (Generating arbitrary values)
|
|
9234
|
+
*
|
|
9235
|
+
* ```ts import.meta.vitest
|
|
9236
|
+
* import { Schema } from "effect"
|
|
9237
|
+
* import * as FastCheck from "fast-check"
|
|
9238
|
+
*
|
|
9239
|
+
* const makePersonArbitrary = Schema.toArbitrary(
|
|
9240
|
+
* Schema.Struct({ name: Schema.String, age: Schema.Number })
|
|
9241
|
+
* )
|
|
9242
|
+
*
|
|
9243
|
+
* const PersonArbitrary = makePersonArbitrary(FastCheck)
|
|
9244
|
+
* FastCheck.sample(PersonArbitrary, 1)
|
|
9245
|
+
* ```
|
|
9224
9246
|
*
|
|
9225
9247
|
* @category generators
|
|
9226
9248
|
* @since 4.0.0
|
|
9227
9249
|
*/
|
|
9228
|
-
export function
|
|
9250
|
+
export function toArbitrary(schema) {
|
|
9229
9251
|
const lawc = InternalArbitrary.memoized(schema.ast);
|
|
9230
9252
|
return fc => lawc(fc, {});
|
|
9231
9253
|
}
|
|
9232
|
-
export function toArbitrary(schema, options) {
|
|
9233
|
-
if (options?.report === true) {
|
|
9234
|
-
const lawc = InternalArbitrary.memoized(schema.ast);
|
|
9235
|
-
const report = InternalArbitrary.makeReport();
|
|
9236
|
-
InternalArbitrary.collectReport(schema.ast, report);
|
|
9237
|
-
return {
|
|
9238
|
-
value: lawc(FastCheck, {}),
|
|
9239
|
-
report: InternalArbitrary.toReport(report)
|
|
9240
|
-
};
|
|
9241
|
-
}
|
|
9242
|
-
return toArbitraryLazy(schema)(FastCheck);
|
|
9243
|
-
}
|
|
9244
9254
|
// -----------------------------------------------------------------------------
|
|
9245
9255
|
// Formatter
|
|
9246
9256
|
// -----------------------------------------------------------------------------
|
|
@@ -9488,7 +9498,7 @@ export function toRepresentation(schema) {
|
|
|
9488
9498
|
* @since 4.0.0
|
|
9489
9499
|
*/
|
|
9490
9500
|
export function toJsonSchemaDocument(schema, options) {
|
|
9491
|
-
const document = InternalToRepresentation.toRepresentation(toCodecJsonAST(schema.ast));
|
|
9501
|
+
const document = InternalToRepresentation.toRepresentation(toCodecJsonAST(schema.ast), InternalToJsonSchemaDocument.toRepresentationOptions);
|
|
9492
9502
|
return InternalToJsonSchemaDocument.toJsonSchemaDocument(document, options);
|
|
9493
9503
|
}
|
|
9494
9504
|
/**
|
|
@@ -9511,14 +9521,13 @@ export function toCodecJson(schema) {
|
|
|
9511
9521
|
schema
|
|
9512
9522
|
});
|
|
9513
9523
|
}
|
|
9514
|
-
|
|
9515
|
-
|
|
9524
|
+
/** @internal */
|
|
9525
|
+
export const toCodecJsonAST = /*#__PURE__*/SchemaAST.applyToSelfOrLastLinkEncodingIdempotent(ast => {
|
|
9526
|
+
const out = toCodecJsonASTStep(ast, toCodecJsonAST);
|
|
9516
9527
|
const context = ast.context;
|
|
9517
9528
|
if (out === ast || context === undefined) return out;
|
|
9518
9529
|
return SchemaAST.replaceContextLastLink(out, withoutConstructorDefault(context));
|
|
9519
9530
|
});
|
|
9520
|
-
/** @internal */
|
|
9521
|
-
export const toCodecJsonAST = /*#__PURE__*/memoize(toCodecJsonASTBase);
|
|
9522
9531
|
function withoutConstructorDefault(context) {
|
|
9523
9532
|
return context.constructorDefault === undefined ? context : new SchemaAST.Context(context.isOptional, context.isMutable, undefined, context.annotations);
|
|
9524
9533
|
}
|
|
@@ -9562,7 +9571,7 @@ const toCodecJsonReorder = /*#__PURE__*/makeReorder(ast => {
|
|
|
9562
9571
|
return 1;
|
|
9563
9572
|
}
|
|
9564
9573
|
});
|
|
9565
|
-
function
|
|
9574
|
+
function toCodecJsonASTStep(ast, recur) {
|
|
9566
9575
|
switch (ast._tag) {
|
|
9567
9576
|
case "Declaration":
|
|
9568
9577
|
{
|
|
@@ -9615,13 +9624,13 @@ function toCodecJsonBase(ast, recur) {
|
|
|
9615
9624
|
* @since 4.0.0
|
|
9616
9625
|
*/
|
|
9617
9626
|
export function toCodecIso(schema) {
|
|
9618
|
-
return make(
|
|
9627
|
+
return make(toCodecIsoAST(SchemaAST.toType(schema.ast)));
|
|
9619
9628
|
}
|
|
9620
|
-
const
|
|
9621
|
-
const out =
|
|
9629
|
+
const toCodecIsoAST = /*#__PURE__*/memoize(ast => {
|
|
9630
|
+
const out = toCodecIsoASTStep(ast, toCodecIsoAST);
|
|
9622
9631
|
return out !== ast && ast.context !== undefined ? SchemaAST.replaceContextLastLink(out, withoutConstructorDefault(ast.context)) : out;
|
|
9623
9632
|
});
|
|
9624
|
-
function
|
|
9633
|
+
function toCodecIsoASTStep(ast, recur) {
|
|
9625
9634
|
switch (ast._tag) {
|
|
9626
9635
|
case "Declaration":
|
|
9627
9636
|
{
|
|
@@ -9654,7 +9663,7 @@ function toCodecIsoBase(ast, recur) {
|
|
|
9654
9663
|
* @since 4.0.0
|
|
9655
9664
|
*/
|
|
9656
9665
|
export function toCodecStringTree(schema) {
|
|
9657
|
-
return make(
|
|
9666
|
+
return make(toCodecStringTreeAST(schema.ast), {
|
|
9658
9667
|
schema
|
|
9659
9668
|
});
|
|
9660
9669
|
}
|
|
@@ -9677,7 +9686,7 @@ export function toCodecStringTree(schema) {
|
|
|
9677
9686
|
* @since 4.0.0
|
|
9678
9687
|
*/
|
|
9679
9688
|
export function toCodecArrayFromSingle(schema) {
|
|
9680
|
-
return make(
|
|
9689
|
+
return make(toCodecArrayFromSingleAST(schema.ast));
|
|
9681
9690
|
}
|
|
9682
9691
|
/**
|
|
9683
9692
|
* Derives an XML encoder from a codec.
|
|
@@ -9801,7 +9810,7 @@ const toStringTreeReorder = /*#__PURE__*/makeReorder(ast => {
|
|
|
9801
9810
|
return 1;
|
|
9802
9811
|
}
|
|
9803
9812
|
});
|
|
9804
|
-
function
|
|
9813
|
+
function toCodecStringTreeASTStep(ast, recur, onMissingAnnotation) {
|
|
9805
9814
|
switch (ast._tag) {
|
|
9806
9815
|
case "Declaration":
|
|
9807
9816
|
{
|
|
@@ -9854,13 +9863,10 @@ function serializerTree(ast, recur, onMissingAnnotation) {
|
|
|
9854
9863
|
}
|
|
9855
9864
|
const nullToString = /*#__PURE__*/new SchemaAST.Link(/*#__PURE__*/new SchemaAST.Literal("null"), /*#__PURE__*/new SchemaTransformation.Transformation(/*#__PURE__*/SchemaGetter.transform(() => null), /*#__PURE__*/SchemaGetter.transform(() => "null")));
|
|
9856
9865
|
const booleanToString = /*#__PURE__*/new SchemaAST.Link(/*#__PURE__*/new SchemaAST.Union([/*#__PURE__*/new SchemaAST.Literal("true"), /*#__PURE__*/new SchemaAST.Literal("false")], "anyOf"), /*#__PURE__*/new SchemaTransformation.Transformation(/*#__PURE__*/SchemaGetter.transform(s => s === "true"), /*#__PURE__*/SchemaGetter.String()));
|
|
9857
|
-
const
|
|
9858
|
-
const
|
|
9859
|
-
const
|
|
9860
|
-
|
|
9861
|
-
return ast;
|
|
9862
|
-
}
|
|
9863
|
-
const out = serializerTree(ast, serializerStringTree, ast => {
|
|
9866
|
+
const arrayFromSingleTransformation = /*#__PURE__*/new SchemaTransformation.Transformation(/*#__PURE__*/SchemaGetter.transform(input => typeof input === "string" ? [input] : input), /*#__PURE__*/SchemaGetter.passthrough());
|
|
9867
|
+
const isCodecArrayFromSingleLink = link => link.transformation === arrayFromSingleTransformation;
|
|
9868
|
+
const toCodecStringTreeAST = /*#__PURE__*/SchemaAST.applyToSelfOrLastLinkEncodingIdempotent(ast => {
|
|
9869
|
+
const out = toCodecStringTreeASTStep(ast, toCodecStringTreeAST, ast => {
|
|
9864
9870
|
throw new globalThis.Error("Missing structural codec for StringTree", {
|
|
9865
9871
|
cause: ast
|
|
9866
9872
|
});
|
|
@@ -9869,24 +9875,22 @@ const serializerStringTree = /*#__PURE__*/SchemaAST.applyToSelfOrLastLinkEncodin
|
|
|
9869
9875
|
return SchemaAST.replaceContextLastLink(out, withoutConstructorDefault(ast.context));
|
|
9870
9876
|
}
|
|
9871
9877
|
return out;
|
|
9878
|
+
}, {
|
|
9879
|
+
stopAt: isCodecArrayFromSingleLink
|
|
9872
9880
|
});
|
|
9873
9881
|
const toArrayFromSingleInputElement = ast => SchemaAST.isOptional(ast) ? SchemaAST.optionalKey(SchemaAST.unknown) : SchemaAST.unknown;
|
|
9874
|
-
const
|
|
9875
|
-
const
|
|
9876
|
-
if (isSerializerArrayFromSingle(ast)) {
|
|
9877
|
-
return ast;
|
|
9878
|
-
}
|
|
9879
|
-
const out = onSerializerArrayFromSingle(ast);
|
|
9882
|
+
const toCodecArrayFromSingleAST = /*#__PURE__*/SchemaAST.applyToSelfOrLastLinkEncodingIdempotent(ast => {
|
|
9883
|
+
const out = toCodecArrayFromSingleASTStep(ast);
|
|
9880
9884
|
if (SchemaAST.isArrays(out)) {
|
|
9881
|
-
const ensure = SchemaAST.decodeTo(new SchemaAST.Union([new SchemaAST.Arrays(out.isMutable, out.elements.map(toArrayFromSingleInputElement), out.rest.map(toArrayFromSingleInputElement)), SchemaAST.string], "anyOf",
|
|
9882
|
-
[SERIALIZER_ENSURE_ARRAY]: true
|
|
9883
|
-
}), out, arrayFromSingleTransformation);
|
|
9885
|
+
const ensure = SchemaAST.decodeTo(new SchemaAST.Union([new SchemaAST.Arrays(out.isMutable, out.elements.map(toArrayFromSingleInputElement), out.rest.map(toArrayFromSingleInputElement)), SchemaAST.string], "anyOf"), out, arrayFromSingleTransformation);
|
|
9884
9886
|
return SchemaAST.isOptional(ast) ? SchemaAST.optionalKey(ensure) : ensure;
|
|
9885
9887
|
}
|
|
9886
9888
|
return out;
|
|
9889
|
+
}, {
|
|
9890
|
+
stopAt: isCodecArrayFromSingleLink
|
|
9887
9891
|
});
|
|
9888
|
-
function
|
|
9889
|
-
return ast._tag === "Declaration" || ast._tag === "Arrays" || ast._tag === "Objects" || ast._tag === "Union" || ast._tag === "Suspend" ? ast.recur(
|
|
9892
|
+
function toCodecArrayFromSingleASTStep(ast) {
|
|
9893
|
+
return ast._tag === "Declaration" || ast._tag === "Arrays" || ast._tag === "Objects" || ast._tag === "Union" || ast._tag === "Suspend" ? ast.recur(toCodecArrayFromSingleAST) : ast;
|
|
9890
9894
|
}
|
|
9891
9895
|
/**
|
|
9892
9896
|
* Reviver for persisted `isGreaterThanDate` checks.
|