effect-app 4.0.0-beta.26 → 4.0.0-beta.260
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/CHANGELOG.md +1192 -0
- package/dist/Array.d.ts +3 -2
- package/dist/Array.d.ts.map +1 -1
- package/dist/Array.js +4 -4
- package/dist/Chunk.d.ts +1 -1
- package/dist/Chunk.d.ts.map +1 -1
- package/dist/Config/SecretURL.d.ts +4 -2
- package/dist/Config/SecretURL.d.ts.map +1 -1
- package/dist/Config/SecretURL.js +3 -6
- package/dist/Config/internal/configSecretURL.d.ts +1 -1
- package/dist/Config/internal/configSecretURL.d.ts.map +1 -1
- package/dist/Config/internal/configSecretURL.js +2 -2
- package/dist/Config.d.ts +7 -0
- package/dist/Config.d.ts.map +1 -0
- package/dist/Config.js +6 -0
- package/dist/ConfigProvider.d.ts +39 -0
- package/dist/ConfigProvider.d.ts.map +1 -0
- package/dist/ConfigProvider.js +42 -0
- package/dist/Context.d.ts +42 -0
- package/dist/Context.d.ts.map +1 -0
- package/dist/Context.js +67 -0
- package/dist/Effect.d.ts +13 -12
- package/dist/Effect.d.ts.map +1 -1
- package/dist/Effect.js +5 -8
- package/dist/Emailer.d.ts +51 -0
- package/dist/Emailer.d.ts.map +1 -0
- package/dist/Emailer.js +7 -0
- package/dist/Function.d.ts +1 -1
- package/dist/Function.d.ts.map +1 -1
- package/dist/Inputify.type.d.ts +1 -1
- package/dist/Layer.d.ts +11 -7
- package/dist/Layer.d.ts.map +1 -1
- package/dist/Layer.js +3 -2
- package/dist/Model/Repository/Registry.d.ts +21 -0
- package/dist/Model/Repository/Registry.d.ts.map +1 -0
- package/dist/Model/Repository/Registry.js +18 -0
- package/dist/Model/Repository/ext.d.ts +60 -0
- package/dist/Model/Repository/ext.d.ts.map +1 -0
- package/dist/Model/Repository/ext.js +122 -0
- package/dist/Model/Repository/internal/internal.d.ts +63 -0
- package/dist/Model/Repository/internal/internal.d.ts.map +1 -0
- package/dist/Model/Repository/internal/internal.js +430 -0
- package/dist/Model/Repository/legacy.d.ts +21 -0
- package/dist/Model/Repository/legacy.d.ts.map +1 -0
- package/dist/Model/Repository/legacy.js +2 -0
- package/dist/Model/Repository/makeRepo.d.ts +54 -0
- package/dist/Model/Repository/makeRepo.d.ts.map +1 -0
- package/dist/Model/Repository/makeRepo.js +27 -0
- package/dist/Model/Repository/service.d.ts +121 -0
- package/dist/Model/Repository/service.d.ts.map +1 -0
- package/dist/Model/Repository/service.js +2 -0
- package/dist/Model/Repository/validation.d.ts +58 -0
- package/dist/Model/Repository/validation.d.ts.map +1 -0
- package/dist/Model/Repository/validation.js +32 -0
- package/dist/Model/Repository.d.ts +7 -0
- package/dist/Model/Repository.d.ts.map +1 -0
- package/dist/Model/Repository.js +7 -0
- package/dist/Model/dsl.d.ts +33 -0
- package/dist/Model/dsl.d.ts.map +1 -0
- package/dist/Model/dsl.js +43 -0
- package/dist/Model/filter/filterApi.d.ts +30 -0
- package/dist/Model/filter/filterApi.d.ts.map +1 -0
- package/dist/Model/filter/filterApi.js +2 -0
- package/dist/Model/filter/types/errors.d.ts +29 -0
- package/dist/Model/filter/types/errors.d.ts.map +1 -0
- package/dist/Model/filter/types/errors.js +2 -0
- package/dist/Model/filter/types/fields.d.ts +15 -0
- package/dist/Model/filter/types/fields.d.ts.map +1 -0
- package/dist/Model/filter/types/fields.js +2 -0
- package/dist/Model/filter/types/path/common.d.ts +316 -0
- package/dist/Model/filter/types/path/common.d.ts.map +1 -0
- package/dist/Model/filter/types/path/common.js +2 -0
- package/dist/Model/filter/types/path/eager.d.ts +95 -0
- package/dist/Model/filter/types/path/eager.d.ts.map +1 -0
- package/dist/Model/filter/types/path/eager.js +31 -0
- package/dist/Model/filter/types/path/index.d.ts +4 -0
- package/dist/Model/filter/types/path/index.d.ts.map +1 -0
- package/dist/Model/filter/types/path/index.js +3 -0
- package/dist/Model/filter/types/utils.d.ts +79 -0
- package/dist/Model/filter/types/utils.d.ts.map +1 -0
- package/dist/Model/filter/types/utils.js +2 -0
- package/dist/Model/filter/types/validator.d.ts +30 -0
- package/dist/Model/filter/types/validator.d.ts.map +1 -0
- package/dist/Model/filter/types/validator.js +2 -0
- package/dist/Model/filter/types.d.ts +5 -0
- package/dist/Model/filter/types.d.ts.map +1 -0
- package/dist/Model/filter/types.js +7 -0
- package/dist/Model/query/dsl.d.ts +493 -0
- package/dist/Model/query/dsl.d.ts.map +1 -0
- package/dist/Model/query/dsl.js +376 -0
- package/dist/Model/query/new-kid-interpreter.d.ts +136 -0
- package/dist/Model/query/new-kid-interpreter.d.ts.map +1 -0
- package/dist/Model/query/new-kid-interpreter.js +336 -0
- package/dist/Model/query.d.ts +15 -0
- package/dist/Model/query.d.ts.map +1 -0
- package/dist/Model/query.js +3 -0
- package/dist/Model.d.ts +5 -0
- package/dist/Model.d.ts.map +1 -0
- package/dist/Model.js +5 -0
- package/dist/NonEmptySet.d.ts +4 -2
- package/dist/NonEmptySet.d.ts.map +1 -1
- package/dist/NonEmptySet.js +2 -2
- package/dist/Option.d.ts +2 -1
- package/dist/Option.d.ts.map +1 -1
- package/dist/Option.js +3 -1
- package/dist/Pure.d.ts +8 -6
- package/dist/Pure.d.ts.map +1 -1
- package/dist/Pure.js +17 -14
- package/dist/QueueMaker.d.ts +13 -0
- package/dist/QueueMaker.d.ts.map +1 -0
- package/dist/QueueMaker.js +4 -0
- package/dist/RequestContext.d.ts +91 -0
- package/dist/RequestContext.d.ts.map +1 -0
- package/dist/RequestContext.js +49 -0
- package/dist/Schema/Class.d.ts +66 -20
- package/dist/Schema/Class.d.ts.map +1 -1
- package/dist/Schema/Class.js +192 -27
- package/dist/Schema/FastCheck.d.ts +1 -1
- package/dist/Schema/FastCheck.d.ts.map +1 -1
- package/dist/Schema/Methods.d.ts +1 -1
- package/dist/Schema/SchemaParser.d.ts +5 -0
- package/dist/Schema/SchemaParser.d.ts.map +1 -0
- package/dist/Schema/SchemaParser.js +6 -0
- package/dist/Schema/SpecialJsonSchema.d.ts +34 -0
- package/dist/Schema/SpecialJsonSchema.d.ts.map +1 -0
- package/dist/Schema/SpecialJsonSchema.js +118 -0
- package/dist/Schema/SpecialOpenApi.d.ts +32 -0
- package/dist/Schema/SpecialOpenApi.d.ts.map +1 -0
- package/dist/Schema/SpecialOpenApi.js +123 -0
- package/dist/Schema/brand.d.ts +5 -3
- package/dist/Schema/brand.d.ts.map +1 -1
- package/dist/Schema/brand.js +3 -1
- package/dist/Schema/email.d.ts +1 -1
- package/dist/Schema/email.d.ts.map +1 -1
- package/dist/Schema/email.js +7 -4
- package/dist/Schema/ext.d.ts +339 -56
- package/dist/Schema/ext.d.ts.map +1 -1
- package/dist/Schema/ext.js +358 -53
- package/dist/Schema/moreStrings.d.ts +83 -37
- package/dist/Schema/moreStrings.d.ts.map +1 -1
- package/dist/Schema/moreStrings.js +49 -42
- package/dist/Schema/numbers.d.ts +35 -22
- package/dist/Schema/numbers.d.ts.map +1 -1
- package/dist/Schema/numbers.js +55 -12
- package/dist/Schema/phoneNumber.d.ts +1 -1
- package/dist/Schema/phoneNumber.d.ts.map +1 -1
- package/dist/Schema/phoneNumber.js +6 -3
- package/dist/Schema/schema.d.ts +1 -1
- package/dist/Schema/strings.d.ts +19 -5
- package/dist/Schema/strings.d.ts.map +1 -1
- package/dist/Schema/strings.js +1 -5
- package/dist/Schema.d.ts +214 -8
- package/dist/Schema.d.ts.map +1 -1
- package/dist/Schema.js +190 -11
- package/dist/Set.d.ts +5 -2
- package/dist/Set.d.ts.map +1 -1
- package/dist/Set.js +3 -2
- package/dist/Store.d.ts +170 -0
- package/dist/Store.d.ts.map +1 -0
- package/dist/Store.js +121 -0
- package/dist/TypeTest.d.ts +1 -1
- package/dist/Types.d.ts +1 -1
- package/dist/Widen.type.d.ts +1 -1
- package/dist/_ext/Array.d.ts +2 -2
- package/dist/_ext/Array.d.ts.map +1 -1
- package/dist/_ext/Array.js +4 -2
- package/dist/_ext/date.d.ts +1 -1
- package/dist/_ext/misc.d.ts +5 -2
- package/dist/_ext/misc.d.ts.map +1 -1
- package/dist/_ext/misc.js +4 -2
- package/dist/_ext/ord.ext.d.ts +3 -2
- package/dist/_ext/ord.ext.d.ts.map +1 -1
- package/dist/_ext/ord.ext.js +2 -2
- package/dist/builtin.d.ts +1 -1
- package/dist/builtin.d.ts.map +1 -1
- package/dist/client/InvalidationKeys.d.ts +29 -0
- package/dist/client/InvalidationKeys.d.ts.map +1 -0
- package/dist/client/InvalidationKeys.js +33 -0
- package/dist/client/apiClientFactory.d.ts +20 -32
- package/dist/client/apiClientFactory.d.ts.map +1 -1
- package/dist/client/apiClientFactory.js +104 -34
- package/dist/client/clientFor.d.ts +53 -19
- package/dist/client/clientFor.d.ts.map +1 -1
- package/dist/client/clientFor.js +9 -1
- package/dist/client/errors.d.ts +49 -25
- package/dist/client/errors.d.ts.map +1 -1
- package/dist/client/errors.js +43 -17
- package/dist/client/makeClient.d.ts +495 -33
- package/dist/client/makeClient.d.ts.map +1 -1
- package/dist/client/makeClient.js +66 -24
- package/dist/client.d.ts +6 -5
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +2 -1
- package/dist/faker.d.ts +1 -1
- package/dist/faker.d.ts.map +1 -1
- package/dist/http/Request.d.ts +2 -2
- package/dist/http/Request.d.ts.map +1 -1
- package/dist/http/Request.js +2 -2
- package/dist/http/internal/lib.d.ts +1 -1
- package/dist/http.d.ts +1 -1
- package/dist/ids.d.ts +43 -15
- package/dist/ids.d.ts.map +1 -1
- package/dist/ids.js +30 -5
- package/dist/index.d.ts +7 -8
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +8 -8
- package/dist/logger.d.ts +1 -1
- package/dist/middleware.d.ts +14 -8
- package/dist/middleware.d.ts.map +1 -1
- package/dist/middleware.js +14 -8
- package/dist/rpc/Invalidation.d.ts +420 -0
- package/dist/rpc/Invalidation.d.ts.map +1 -0
- package/dist/rpc/Invalidation.js +168 -0
- package/dist/rpc/MiddlewareMaker.d.ts +12 -8
- package/dist/rpc/MiddlewareMaker.d.ts.map +1 -1
- package/dist/rpc/MiddlewareMaker.js +59 -38
- package/dist/rpc/RpcContextMap.d.ts +4 -4
- package/dist/rpc/RpcContextMap.d.ts.map +1 -1
- package/dist/rpc/RpcContextMap.js +4 -4
- package/dist/rpc/RpcMiddleware.d.ts +15 -11
- package/dist/rpc/RpcMiddleware.d.ts.map +1 -1
- package/dist/rpc/RpcMiddleware.js +1 -1
- package/dist/rpc.d.ts +2 -2
- package/dist/rpc.d.ts.map +1 -1
- package/dist/rpc.js +2 -2
- package/dist/runtime.d.ts +19 -0
- package/dist/runtime.d.ts.map +1 -0
- package/dist/runtime.js +40 -0
- package/dist/setupRequest.d.ts +19 -0
- package/dist/setupRequest.d.ts.map +1 -0
- package/dist/setupRequest.js +69 -0
- package/dist/toast.d.ts +51 -0
- package/dist/toast.d.ts.map +1 -0
- package/dist/toast.js +34 -0
- package/dist/transform.d.ts +2 -2
- package/dist/transform.d.ts.map +1 -1
- package/dist/transform.js +4 -5
- package/dist/utils/effectify.d.ts +2 -2
- package/dist/utils/effectify.d.ts.map +1 -1
- package/dist/utils/effectify.js +2 -2
- package/dist/utils/extend.d.ts +1 -1
- package/dist/utils/extend.d.ts.map +1 -1
- package/dist/utils/gen.d.ts +5 -5
- package/dist/utils/gen.d.ts.map +1 -1
- package/dist/utils/logLevel.d.ts +3 -3
- package/dist/utils/logLevel.d.ts.map +1 -1
- package/dist/utils/logger.d.ts +5 -4
- package/dist/utils/logger.d.ts.map +1 -1
- package/dist/utils/logger.js +4 -4
- package/dist/utils.d.ts +40 -45
- package/dist/utils.d.ts.map +1 -1
- package/dist/utils.js +19 -27
- package/dist/validation/validators.d.ts +1 -1
- package/dist/validation/validators.d.ts.map +1 -1
- package/dist/validation.d.ts +1 -1
- package/dist/validation.d.ts.map +1 -1
- package/dist/withToast.d.ts +30 -0
- package/dist/withToast.d.ts.map +1 -0
- package/dist/withToast.js +64 -0
- package/package.json +20 -245
- package/src/Array.ts +3 -3
- package/src/Config/SecretURL.ts +5 -2
- package/src/Config/internal/configSecretURL.ts +1 -1
- package/src/Config.ts +14 -0
- package/src/ConfigProvider.ts +48 -0
- package/src/{ServiceMap.ts → Context.ts} +56 -63
- package/src/Effect.ts +12 -14
- package/src/Emailer.ts +51 -0
- package/src/Layer.ts +10 -6
- package/src/Model/Repository/Registry.ts +34 -0
- package/src/Model/Repository/ext.ts +375 -0
- package/src/Model/Repository/internal/internal.ts +741 -0
- package/src/Model/Repository/legacy.ts +29 -0
- package/src/Model/Repository/makeRepo.ts +145 -0
- package/src/Model/Repository/service.ts +666 -0
- package/src/Model/Repository/validation.ts +31 -0
- package/src/Model/Repository.ts +6 -0
- package/src/Model/dsl.ts +129 -0
- package/src/Model/filter/filterApi.ts +60 -0
- package/src/Model/filter/types/errors.ts +47 -0
- package/src/Model/filter/types/fields.ts +50 -0
- package/src/Model/filter/types/path/common.ts +404 -0
- package/src/Model/filter/types/path/eager.ts +297 -0
- package/src/Model/filter/types/path/index.ts +4 -0
- package/src/Model/filter/types/utils.ts +128 -0
- package/src/Model/filter/types/validator.ts +46 -0
- package/src/Model/filter/types.ts +6 -0
- package/src/Model/query/dsl.ts +2694 -0
- package/src/Model/query/new-kid-interpreter.ts +484 -0
- package/src/Model/query.ts +13 -0
- package/src/Model.ts +4 -0
- package/src/NonEmptySet.ts +3 -1
- package/src/Option.ts +2 -0
- package/src/Pure.ts +21 -19
- package/src/QueueMaker.ts +19 -0
- package/src/RequestContext.ts +62 -0
- package/src/Schema/Class.ts +274 -68
- package/src/Schema/SchemaParser.ts +12 -0
- package/src/Schema/SpecialJsonSchema.ts +139 -0
- package/src/Schema/SpecialOpenApi.ts +130 -0
- package/src/Schema/brand.ts +22 -2
- package/src/Schema/email.ts +7 -2
- package/src/Schema/ext.ts +443 -88
- package/src/Schema/moreStrings.ts +146 -67
- package/src/Schema/numbers.ts +96 -27
- package/src/Schema/phoneNumber.ts +5 -1
- package/src/Schema/strings.ts +22 -13
- package/src/Schema.ts +374 -10
- package/src/Set.ts +5 -1
- package/src/Store.ts +277 -0
- package/src/_ext/Array.ts +3 -1
- package/src/_ext/misc.ts +4 -1
- package/src/_ext/ord.ext.ts +2 -1
- package/src/client/InvalidationKeys.ts +50 -0
- package/src/client/apiClientFactory.ts +230 -131
- package/src/client/clientFor.ts +102 -31
- package/src/client/errors.ts +52 -26
- package/src/client/makeClient.ts +592 -71
- package/src/client.ts +5 -4
- package/src/http/Request.ts +1 -1
- package/src/ids.ts +32 -5
- package/src/index.ts +7 -10
- package/src/middleware.ts +13 -9
- package/src/rpc/Invalidation.ts +261 -0
- package/src/rpc/MiddlewareMaker.ts +83 -75
- package/src/rpc/README.md +2 -2
- package/src/rpc/RpcContextMap.ts +6 -5
- package/src/rpc/RpcMiddleware.ts +18 -12
- package/src/rpc.ts +1 -1
- package/src/runtime.ts +56 -0
- package/src/setupRequest.ts +134 -0
- package/src/toast.ts +54 -0
- package/src/transform.ts +3 -3
- package/src/utils/effectify.ts +1 -1
- package/src/utils/gen.ts +8 -8
- package/src/utils/logLevel.ts +1 -1
- package/src/utils/logger.ts +4 -3
- package/src/utils.ts +62 -139
- package/src/withToast.ts +133 -0
- package/test/dist/rpc-dynamic-middleware.test.d.ts.map +1 -0
- package/test/dist/rpc.test.d.ts.map +1 -1
- package/test/dist/secretURL.test.d.ts.map +1 -0
- package/test/dist/special.test.d.ts.map +1 -0
- package/test/dist/stream-error.types.d.ts +2 -0
- package/test/dist/stream-error.types.d.ts.map +1 -0
- package/test/dist/stream-error.types.js +27 -0
- package/test/moreStrings.test.ts +1 -1
- package/test/rpc.test.ts +46 -6
- package/test/schema.test.ts +459 -30
- package/test/secretURL.test.ts +160 -0
- package/test/special.test.ts +1026 -0
- package/test/utils.test.ts +7 -7
- package/tsconfig.base.json +6 -5
- package/tsconfig.json +2 -1
- package/tsconfig.json.bak +2 -2
- package/tsconfig.src.json +29 -29
- package/tsconfig.test.json +2 -2
- package/dist/Operations.d.ts +0 -123
- package/dist/Operations.d.ts.map +0 -1
- package/dist/Operations.js +0 -29
- package/dist/ServiceMap.d.ts +0 -44
- package/dist/ServiceMap.d.ts.map +0 -1
- package/dist/ServiceMap.js +0 -91
- package/eslint.config.mjs +0 -26
- package/src/Operations.ts +0 -55
package/src/Schema.ts
CHANGED
|
@@ -1,21 +1,119 @@
|
|
|
1
|
-
import { SchemaAST, type Tracer } from "effect"
|
|
2
1
|
import * as S from "effect/Schema"
|
|
2
|
+
import * as SchemaAST from "effect/SchemaAST"
|
|
3
|
+
import { type Simplify } from "effect/Struct"
|
|
4
|
+
import type * as Tracer from "effect/Tracer"
|
|
5
|
+
import type { RequiredKeys } from "effect/Types"
|
|
3
6
|
import type { NonEmptyReadonlyArray } from "./Array.js"
|
|
4
7
|
import { fakerArb } from "./faker.js"
|
|
5
8
|
import { Email as EmailT, type Email as EmailType } from "./Schema/email.js"
|
|
6
|
-
import { withDefaultMake } from "./Schema/ext.js"
|
|
9
|
+
import { concurrencyUnbounded, withDefaultMake, withDefaultParseOptions } from "./Schema/ext.js"
|
|
7
10
|
import { PhoneNumber as PhoneNumberT, type PhoneNumber as PhoneNumberType } from "./Schema/phoneNumber.js"
|
|
8
|
-
import {
|
|
11
|
+
import { type AST } from "./Schema/schema.js"
|
|
12
|
+
import { copy, extendM, type StructuralCopyOrigin } from "./utils.js"
|
|
13
|
+
|
|
14
|
+
// ---------------------------------------------------------------------------
|
|
15
|
+
// Default helpers — re-exported from effect/Schema
|
|
16
|
+
//
|
|
17
|
+
// The five helpers below are surfaced explicitly so the (important) policy
|
|
18
|
+
// around them lives next to the export. See also the file-level note in
|
|
19
|
+
// `./Schema/ext.ts` and the documented wrappers in
|
|
20
|
+
// `./Schema/ext.ts`, `./Schema/numbers.ts`, `./Schema/moreStrings.ts`,
|
|
21
|
+
// and `./ids.ts`.
|
|
22
|
+
//
|
|
23
|
+
// **Construction-only**: `withConstructorDefault` fills the field when it
|
|
24
|
+
// is omitted from `.make(...)` input. It is NOT applied during decode, so
|
|
25
|
+
// it CANNOT be used to just-in-time migrate database fields. A stored
|
|
26
|
+
// record missing the field will still fail to decode.
|
|
27
|
+
//
|
|
28
|
+
// **`withDecodingDefault*` is discouraged**: a missing field in persisted
|
|
29
|
+
// data is just as likely to be data corruption as it is an old-shape
|
|
30
|
+
// document; silently substituting a default hides the problem and can
|
|
31
|
+
// poison downstream aggregates. Prefer an explicit, preferably versioned
|
|
32
|
+
// migration of database data over shoving missing fields under the rug.
|
|
33
|
+
// ---------------------------------------------------------------------------
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Attach a default value used **only** when constructing a value (e.g. via
|
|
37
|
+
* `.make(...)` or struct constructors) and the field is omitted from input.
|
|
38
|
+
*
|
|
39
|
+
* **Not applied during decode.** Decoding a payload that is missing the
|
|
40
|
+
* field will still raise a parse error. Do **not** rely on this to migrate
|
|
41
|
+
* database fields just-in-time — see the section header above.
|
|
42
|
+
*
|
|
43
|
+
* @see {@link withDecodingDefault} / {@link withDecodingDefaultType} —
|
|
44
|
+
* decode-time variants (discouraged for persisted data; use explicit,
|
|
45
|
+
* versioned migrations instead).
|
|
46
|
+
*/
|
|
47
|
+
export { withConstructorDefault } from "effect/Schema"
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Attach a default value used during decode when the field's `Encoded` value
|
|
51
|
+
* is missing **or** `undefined`. The default is specified as an `Encoded`
|
|
52
|
+
* value and threaded through the schema's decode step.
|
|
53
|
+
*
|
|
54
|
+
* **Discouraged for persisted data.** A missing field in a stored record is
|
|
55
|
+
* just as likely to be data corruption as it is an old-shape document;
|
|
56
|
+
* silently substituting a default hides the problem. Prefer an explicit,
|
|
57
|
+
* preferably versioned migration of database data — see the section header
|
|
58
|
+
* above.
|
|
59
|
+
*
|
|
60
|
+
* @see {@link withDecodingDefaultKey} — key-absent-only variant
|
|
61
|
+
* @see {@link withDecodingDefaultType} — `Type`-side variant
|
|
62
|
+
* @see {@link withConstructorDefault} — for `.make(...)`-time defaults
|
|
63
|
+
*/
|
|
64
|
+
export { withDecodingDefault } from "effect/Schema"
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* Attach a default value used during decode when the field **key is absent**
|
|
68
|
+
* (note: not when present and `undefined`). The default is an `Encoded`
|
|
69
|
+
* value.
|
|
70
|
+
*
|
|
71
|
+
* **Discouraged for persisted data** — same reasoning as
|
|
72
|
+
* {@link withDecodingDefault}. Use explicit, preferably versioned migrations
|
|
73
|
+
* over decode-time fallbacks.
|
|
74
|
+
*
|
|
75
|
+
* @see {@link withDecodingDefault} — value-absent-or-undefined variant
|
|
76
|
+
* @see {@link withDecodingDefaultTypeKey} — `Type`-side variant
|
|
77
|
+
* @see {@link withConstructorDefault} — for `.make(...)`-time defaults
|
|
78
|
+
*/
|
|
79
|
+
export { withDecodingDefaultKey } from "effect/Schema"
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* Attach a default value used during decode when the field is missing **or**
|
|
83
|
+
* `undefined`. The default is specified as a `Type` value (i.e. on the
|
|
84
|
+
* decoded side).
|
|
85
|
+
*
|
|
86
|
+
* **Discouraged for persisted data** — same reasoning as
|
|
87
|
+
* {@link withDecodingDefault}. Use explicit, preferably versioned migrations
|
|
88
|
+
* over decode-time fallbacks.
|
|
89
|
+
*
|
|
90
|
+
* @see {@link withDecodingDefault} — `Encoded`-side variant
|
|
91
|
+
* @see {@link withDecodingDefaultTypeKey} — key-absent-only variant
|
|
92
|
+
* @see {@link withConstructorDefault} — for `.make(...)`-time defaults
|
|
93
|
+
*/
|
|
94
|
+
export { withDecodingDefaultType } from "effect/Schema"
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* Attach a default value used during decode when the field **key is absent**
|
|
98
|
+
* (note: not when present and `undefined`). The default is a `Type` value.
|
|
99
|
+
*
|
|
100
|
+
* **Discouraged for persisted data** — same reasoning as
|
|
101
|
+
* {@link withDecodingDefault}. Use explicit, preferably versioned migrations
|
|
102
|
+
* over decode-time fallbacks.
|
|
103
|
+
*
|
|
104
|
+
* @see {@link withDecodingDefaultKey} — `Encoded`-side variant
|
|
105
|
+
* @see {@link withDecodingDefaultType} — value-absent-or-undefined variant
|
|
106
|
+
* @see {@link withConstructorDefault} — for `.make(...)`-time defaults
|
|
107
|
+
*/
|
|
108
|
+
export { withDecodingDefaultTypeKey } from "effect/Schema"
|
|
9
109
|
|
|
10
110
|
export * from "effect/Schema"
|
|
11
|
-
// v4: TaggedError renamed to TaggedErrorClass
|
|
12
|
-
export { TaggedErrorClass as TaggedError } from "effect/Schema"
|
|
13
111
|
|
|
14
112
|
export * from "./Schema/Class.js"
|
|
15
|
-
export { Class, TaggedClass } from "./Schema/Class.js"
|
|
113
|
+
export { Class, ErrorClass, Opaque, TaggedClass, TaggedErrorClass } from "./Schema/Class.js"
|
|
16
114
|
|
|
17
115
|
export { fromBrand, nominal } from "./Schema/brand.js"
|
|
18
|
-
export { Array, Boolean, Date,
|
|
116
|
+
export { Array, Boolean, Date, DateFromString, DateValid, Finite, Literals, NullOr, Number, ReadonlyMap, ReadonlySet } from "./Schema/ext.js"
|
|
19
117
|
export { Int, NonNegativeInt } from "./Schema/numbers.js"
|
|
20
118
|
|
|
21
119
|
export * from "./Schema/email.js"
|
|
@@ -24,14 +122,217 @@ export * from "./Schema/moreStrings.js"
|
|
|
24
122
|
export * from "./Schema/numbers.js"
|
|
25
123
|
export * from "./Schema/phoneNumber.js"
|
|
26
124
|
export * from "./Schema/schema.js"
|
|
125
|
+
export * from "./Schema/SpecialJsonSchema.js"
|
|
126
|
+
export * from "./Schema/SpecialOpenApi.js"
|
|
27
127
|
export * from "./Schema/strings.js"
|
|
28
128
|
export { NonEmptyString } from "./Schema/strings.js"
|
|
29
129
|
|
|
30
130
|
export * as SchemaIssue from "effect/SchemaIssue"
|
|
31
|
-
|
|
131
|
+
|
|
132
|
+
export const decodeEffectConcurrently: typeof S.decodeEffect = withDefaultParseOptions(S.decodeEffect)
|
|
133
|
+
export const decodeUnknownEffectConcurrently: typeof S.decodeUnknownEffect = withDefaultParseOptions(
|
|
134
|
+
S.decodeUnknownEffect
|
|
135
|
+
)
|
|
136
|
+
export * as SchemaParser from "./Schema/SchemaParser.js"
|
|
32
137
|
|
|
33
138
|
export { Void as Void_ } from "effect/Schema"
|
|
34
139
|
|
|
140
|
+
// ---------------------------------------------------------------------------
|
|
141
|
+
// Struct / NonEmptyArray / Record
|
|
142
|
+
// ---------------------------------------------------------------------------
|
|
143
|
+
|
|
144
|
+
export function Struct<const Fields extends S.Struct.Fields>(
|
|
145
|
+
fields: Fields
|
|
146
|
+
): Struct<Fields> {
|
|
147
|
+
const result = S.Struct(fields).annotate(concurrencyUnbounded)
|
|
148
|
+
const allowVoidMake = (schema: any): any => {
|
|
149
|
+
// Normalize omitted input to an empty object so optional/default-only structs can be constructed with make().
|
|
150
|
+
const origMake: any = schema.make
|
|
151
|
+
const origMakeOption: any = schema.makeOption
|
|
152
|
+
const origMakeEffect: any = schema.makeEffect
|
|
153
|
+
schema.make = function(this: any, input: any, options?: any) {
|
|
154
|
+
return origMake.call(this, input === undefined ? {} : input, options)
|
|
155
|
+
}
|
|
156
|
+
schema.makeOption = function(this: any, input: any, options?: any) {
|
|
157
|
+
return origMakeOption.call(this, input === undefined ? {} : input, options)
|
|
158
|
+
}
|
|
159
|
+
schema.makeEffect = function(this: any, input: any, options?: any) {
|
|
160
|
+
return origMakeEffect.call(this, input === undefined ? {} : input, options)
|
|
161
|
+
}
|
|
162
|
+
return schema
|
|
163
|
+
}
|
|
164
|
+
// eslint-disable-next-line @typescript-eslint/unbound-method, @typescript-eslint/no-unsafe-assignment
|
|
165
|
+
const origMapFields: any = result.mapFields
|
|
166
|
+
// eslint-disable-next-line @typescript-eslint/unbound-method, @typescript-eslint/no-unsafe-assignment
|
|
167
|
+
const origAnnotate: any = result.annotate
|
|
168
|
+
// eslint-disable-next-line @typescript-eslint/unbound-method, @typescript-eslint/no-unsafe-assignment
|
|
169
|
+
const origAnnotateKey: any = result.annotateKey
|
|
170
|
+
|
|
171
|
+
const preserveCopyAndMethods = (schema: any): any => {
|
|
172
|
+
schema.copy = copy
|
|
173
|
+
schema.mapFields = function(this: any, f: any, options?: any) {
|
|
174
|
+
return (result as any).mapFields.call(this, f, options)
|
|
175
|
+
}
|
|
176
|
+
schema.annotate = function(this: any, annotations?: any) {
|
|
177
|
+
return (result as any).annotate.call(this, annotations)
|
|
178
|
+
}
|
|
179
|
+
schema.annotateKey = function(this: any, annotations?: any) {
|
|
180
|
+
return (result as any).annotateKey.call(this, annotations)
|
|
181
|
+
}
|
|
182
|
+
return allowVoidMake(schema)
|
|
183
|
+
}
|
|
184
|
+
;(result as any).mapFields = function(this: any, f: any, options?: any) {
|
|
185
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-call
|
|
186
|
+
const mapped = origMapFields.call(this, f, options).annotate(concurrencyUnbounded)
|
|
187
|
+
return preserveCopyAndMethods(mapped)
|
|
188
|
+
}
|
|
189
|
+
;(result as any).annotate = function(this: any, annotations?: any) {
|
|
190
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-call
|
|
191
|
+
const annotated = origAnnotate.call(this, annotations)
|
|
192
|
+
return preserveCopyAndMethods(annotated)
|
|
193
|
+
}
|
|
194
|
+
;(result as any).annotateKey = function(this: any, annotations?: any) {
|
|
195
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-call
|
|
196
|
+
const annotated = origAnnotateKey.call(this, annotations)
|
|
197
|
+
return preserveCopyAndMethods(annotated)
|
|
198
|
+
}
|
|
199
|
+
;(result as any).copy = copy
|
|
200
|
+
allowVoidMake(result)
|
|
201
|
+
return result as Struct<Fields>
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
export interface Struct<Fields extends S.Struct.Fields> extends
|
|
205
|
+
S.Bottom<
|
|
206
|
+
Struct.Type<Fields>,
|
|
207
|
+
Struct.Encoded<Fields>,
|
|
208
|
+
Struct.DecodingServices<Fields>,
|
|
209
|
+
Struct.EncodingServices<Fields>,
|
|
210
|
+
AST.Objects,
|
|
211
|
+
// Rebuild is what's returned from annotate etc
|
|
212
|
+
Struct<Fields>,
|
|
213
|
+
Struct.MakeIn<Fields>,
|
|
214
|
+
Struct.Iso<Fields>
|
|
215
|
+
>
|
|
216
|
+
{
|
|
217
|
+
/**
|
|
218
|
+
* The field definitions of this struct. Spread them into a new struct to
|
|
219
|
+
* reuse fields across schemas.
|
|
220
|
+
*
|
|
221
|
+
* **Example** (Reusing fields across structs)
|
|
222
|
+
*
|
|
223
|
+
* ```ts
|
|
224
|
+
* import * as Schema from "effect/Schema"
|
|
225
|
+
*
|
|
226
|
+
* const Timestamped = Schema.Struct({
|
|
227
|
+
* createdAt: Schema.Date,
|
|
228
|
+
* updatedAt: Schema.Date
|
|
229
|
+
* })
|
|
230
|
+
*
|
|
231
|
+
* const User = Schema.Struct({
|
|
232
|
+
* ...Timestamped.fields,
|
|
233
|
+
* name: Schema.String,
|
|
234
|
+
* email: Schema.String
|
|
235
|
+
* })
|
|
236
|
+
* ```
|
|
237
|
+
*/
|
|
238
|
+
readonly fields: Fields
|
|
239
|
+
/**
|
|
240
|
+
* Returns a new struct with the fields modified by the provided function.
|
|
241
|
+
*
|
|
242
|
+
* **Options**
|
|
243
|
+
*
|
|
244
|
+
* - `unsafePreserveChecks` - if `true`, keep any `.check(...)` constraints
|
|
245
|
+
* that were attached to the original union. Defaults to `false`.
|
|
246
|
+
*
|
|
247
|
+
* **Warning**: This is an unsafe operation. Since `mapFields`
|
|
248
|
+
* transformations change the schema type, the original refinement functions
|
|
249
|
+
* may no longer be valid or safe to apply to the transformed schema. Only
|
|
250
|
+
* use this option if you have verified that your refinements remain correct
|
|
251
|
+
* after the transformation.
|
|
252
|
+
*/
|
|
253
|
+
mapFields<To extends Struct.Fields>(
|
|
254
|
+
f: (fields: Fields) => To,
|
|
255
|
+
options?: {
|
|
256
|
+
readonly unsafePreserveChecks?: boolean | undefined
|
|
257
|
+
} | undefined
|
|
258
|
+
): Struct<Simplify<Readonly<To>>>
|
|
259
|
+
|
|
260
|
+
// added copy
|
|
261
|
+
readonly copy: StructuralCopyOrigin<Struct.Type<Fields>>
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
export declare namespace Struct {
|
|
265
|
+
export type Fields = S.Struct.Fields
|
|
266
|
+
export type Type<F extends S.Struct.Fields> = S.Struct.Type<F>
|
|
267
|
+
export type Encoded<F extends S.Struct.Fields> = S.Struct.Encoded<F>
|
|
268
|
+
export type DecodingServices<F extends S.Struct.Fields> = S.Struct.DecodingServices<F>
|
|
269
|
+
export type EncodingServices<F extends S.Struct.Fields> = S.Struct.EncodingServices<F>
|
|
270
|
+
// changed; all optional allows void
|
|
271
|
+
export type MakeIn<F extends S.Struct.Fields> = RequiredKeys<S.Struct.MakeIn<F>> extends never
|
|
272
|
+
? void | S.Struct.MakeIn<F>
|
|
273
|
+
: S.Struct.MakeIn<F>
|
|
274
|
+
export type Iso<F extends S.Struct.Fields> = S.Struct.Iso<F>
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
export type StructNestedEncodedError<T> = {
|
|
278
|
+
readonly _tag: "StructNestedEncodedError"
|
|
279
|
+
readonly message: "Expected a Struct schema or a schema with from.Encoded"
|
|
280
|
+
readonly schema: T
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
export type StructNestedEncoded<T> = T extends { fields: infer Fields extends S.Struct.Fields } ? Struct.Encoded<Fields>
|
|
284
|
+
: T extends { readonly from: { readonly Encoded: infer Encoded } } ? Encoded
|
|
285
|
+
: StructNestedEncodedError<T>
|
|
286
|
+
|
|
287
|
+
export function NonEmptyArray<Value extends S.Top>(value: Value): S.NonEmptyArray<Value> {
|
|
288
|
+
return S.NonEmptyArray(value).annotate(concurrencyUnbounded)
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
export function TaggedStruct<const Tag extends SchemaAST.LiteralValue, const Fields extends S.Struct.Fields>(
|
|
292
|
+
value: Tag,
|
|
293
|
+
fields: Fields
|
|
294
|
+
): TaggedStruct<Tag, Fields> {
|
|
295
|
+
return Struct({ _tag: S.tag(value), ...fields }) as any
|
|
296
|
+
}
|
|
297
|
+
export interface TaggedStruct<Tag extends SchemaAST.LiteralValue, Fields extends S.Struct.Fields>
|
|
298
|
+
extends Struct<{ readonly _tag: S.tag<Tag> } & Fields>
|
|
299
|
+
{}
|
|
300
|
+
export declare namespace TaggedStruct {
|
|
301
|
+
export type Fields = S.Struct.Fields
|
|
302
|
+
export type Type<Tag extends SchemaAST.LiteralValue, F extends S.Struct.Fields> = S.Struct.Type<
|
|
303
|
+
{ readonly _tag: S.tag<Tag> } & F
|
|
304
|
+
>
|
|
305
|
+
export type Encoded<Tag extends SchemaAST.LiteralValue, F extends S.Struct.Fields> = S.Struct.Encoded<
|
|
306
|
+
{ readonly _tag: S.tag<Tag> } & F
|
|
307
|
+
>
|
|
308
|
+
export type DecodingServices<Tag extends SchemaAST.LiteralValue, F extends S.Struct.Fields> =
|
|
309
|
+
S.Struct.DecodingServices<
|
|
310
|
+
{ readonly _tag: S.tag<Tag> } & F
|
|
311
|
+
>
|
|
312
|
+
export type EncodingServices<Tag extends SchemaAST.LiteralValue, F extends S.Struct.Fields> =
|
|
313
|
+
S.Struct.EncodingServices<
|
|
314
|
+
{ readonly _tag: S.tag<Tag> } & F
|
|
315
|
+
>
|
|
316
|
+
export type MakeIn<Tag extends SchemaAST.LiteralValue, F extends S.Struct.Fields> = S.Struct.MakeIn<
|
|
317
|
+
{ readonly _tag: S.tag<Tag> } & F
|
|
318
|
+
>
|
|
319
|
+
export type Iso<Tag extends SchemaAST.LiteralValue, F extends S.Struct.Fields> = S.Struct.Iso<
|
|
320
|
+
{ readonly _tag: S.tag<Tag> } & F
|
|
321
|
+
>
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
export function Record<Key extends S.Record.Key, Value extends S.Top>(
|
|
325
|
+
key: Key,
|
|
326
|
+
value: Value
|
|
327
|
+
): S.$Record<Key, Value> {
|
|
328
|
+
return S.Record(key, value).annotate(concurrencyUnbounded)
|
|
329
|
+
}
|
|
330
|
+
export declare namespace Record {
|
|
331
|
+
export type Key = S.Record.Key
|
|
332
|
+
export type Type<K extends S.Record.Key, V extends S.Top> = S.Record.Type<K, V>
|
|
333
|
+
export type Encoded<K extends S.Record.Key, V extends S.Top> = S.Record.Encoded<K, V>
|
|
334
|
+
}
|
|
335
|
+
|
|
35
336
|
export const SpanId = Symbol()
|
|
36
337
|
export type SpanId = typeof SpanId
|
|
37
338
|
|
|
@@ -125,13 +426,76 @@ type TaggedUnionTags<Members extends TaggedUnionMembers> = S.Literals<
|
|
|
125
426
|
}
|
|
126
427
|
>
|
|
127
428
|
|
|
429
|
+
type TaggedPropertyKeys<A, Members extends TaggedUnionMembers> = {
|
|
430
|
+
[K in keyof A & string]: A[K] extends Members[number]["Type"] ? K : never
|
|
431
|
+
}[keyof A & string]
|
|
432
|
+
|
|
433
|
+
type PropertyGuardsFor<
|
|
434
|
+
Members extends TaggedUnionMembers,
|
|
435
|
+
K extends string,
|
|
436
|
+
A
|
|
437
|
+
> =
|
|
438
|
+
& {
|
|
439
|
+
readonly [M in Members[number] as `is${M["Type"]["_tag"]}`]: (
|
|
440
|
+
target: A
|
|
441
|
+
) => target is A & { readonly [P in K]: M["Type"] }
|
|
442
|
+
}
|
|
443
|
+
& {
|
|
444
|
+
readonly isAnyOf: <const Tags extends ReadonlyArray<Members[number]["Type"]["_tag"]>>(
|
|
445
|
+
tags: Tags
|
|
446
|
+
) => (
|
|
447
|
+
target: A
|
|
448
|
+
) => target is A & { readonly [P in K]: Extract<Members[number]["Type"], { readonly _tag: Tags[number] }> }
|
|
449
|
+
}
|
|
450
|
+
|
|
451
|
+
type PropertyGuards<
|
|
452
|
+
Members extends TaggedUnionMembers,
|
|
453
|
+
K extends string
|
|
454
|
+
> =
|
|
455
|
+
& {
|
|
456
|
+
readonly [M in Members[number] as `is${M["Type"]["_tag"]}`]: <
|
|
457
|
+
T extends { readonly [P in K]: Members[number]["Type"] }
|
|
458
|
+
>(target: T) => target is T & { readonly [P in K]: M["Type"] }
|
|
459
|
+
}
|
|
460
|
+
& {
|
|
461
|
+
readonly isAnyOf: <const Tags extends ReadonlyArray<Members[number]["Type"]["_tag"]>>(
|
|
462
|
+
tags: Tags
|
|
463
|
+
) => <T extends { readonly [P in K]: Members[number]["Type"] }>(
|
|
464
|
+
target: T
|
|
465
|
+
) => target is T & { readonly [P in K]: Extract<Members[number]["Type"], { readonly _tag: Tags[number] }> }
|
|
466
|
+
}
|
|
467
|
+
|
|
128
468
|
type TaggedUnionWithTags<Members extends TaggedUnionMembers> = S.toTaggedUnion<"_tag", Members> & {
|
|
129
469
|
readonly tags: TaggedUnionTags<Members>
|
|
470
|
+
readonly generateGuards: <K extends string>(property: K) => PropertyGuards<Members, K>
|
|
471
|
+
readonly generateGuardsFor: <A>() => <K extends TaggedPropertyKeys<A, Members>>(
|
|
472
|
+
property: K
|
|
473
|
+
) => PropertyGuardsFor<Members, K, A>
|
|
130
474
|
}
|
|
131
475
|
|
|
132
476
|
const extendTaggedUnionWithTags = <Members extends TaggedUnionMembers>(
|
|
133
477
|
schema: S.Union<Members>
|
|
134
|
-
): TaggedUnionWithTags<Members> =>
|
|
478
|
+
): TaggedUnionWithTags<Members> =>
|
|
479
|
+
extendM(schema.pipe(S.toTaggedUnion("_tag")), (tagged) => {
|
|
480
|
+
const makeGuards = (property: string) => {
|
|
481
|
+
const result: any = {}
|
|
482
|
+
const guards: Record<string, (u: unknown) => boolean> = tagged.guards
|
|
483
|
+
for (const tag of Object.keys(guards)) {
|
|
484
|
+
const guard = guards[tag]!
|
|
485
|
+
result[`is${tag}`] = (target: any) => guard(target[property])
|
|
486
|
+
}
|
|
487
|
+
result.isAnyOf = (memberTags: Array<string>) => {
|
|
488
|
+
const check = tagged.isAnyOf(memberTags)
|
|
489
|
+
return (target: any) => check(target[property])
|
|
490
|
+
}
|
|
491
|
+
return result
|
|
492
|
+
}
|
|
493
|
+
return {
|
|
494
|
+
tags: tags(schema.members),
|
|
495
|
+
generateGuards: makeGuards,
|
|
496
|
+
generateGuardsFor: () => makeGuards
|
|
497
|
+
}
|
|
498
|
+
})
|
|
135
499
|
|
|
136
500
|
export const ExtendTaggedUnion = <Members extends TaggedUnionMembers>(
|
|
137
501
|
schema: S.Union<Members>
|
|
@@ -139,4 +503,4 @@ export const ExtendTaggedUnion = <Members extends TaggedUnionMembers>(
|
|
|
139
503
|
|
|
140
504
|
export const TaggedUnion = <
|
|
141
505
|
Members extends TaggedUnionMembers
|
|
142
|
-
>(
|
|
506
|
+
>(members: Members): TaggedUnionWithTags<Members> => extendTaggedUnionWithTags(S.Union(members))
|
package/src/Set.ts
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
// ets_tracing: off
|
|
2
2
|
|
|
3
|
-
import
|
|
3
|
+
import * as Array from "effect/Array"
|
|
4
|
+
import type * as Equivalence from "effect/Equivalence"
|
|
5
|
+
import * as Option from "effect/Option"
|
|
6
|
+
import type * as Order from "effect/Order"
|
|
4
7
|
import { not } from "effect/Predicate"
|
|
8
|
+
import type * as Result from "effect/Result"
|
|
5
9
|
import { identity, pipe, type Predicate, type Refinement, tuple } from "./Function.js"
|
|
6
10
|
|
|
7
11
|
export function find_<A, B extends A>(
|