effect-app 4.0.0-beta.33 → 4.0.0-beta.331
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 +1628 -0
- package/dist/Array.d.ts +2 -1
- package/dist/Array.d.ts.map +1 -1
- package/dist/Array.js +4 -4
- package/dist/Chunk.d.ts.map +1 -1
- package/dist/Config/SecretURL.d.ts +3 -1
- package/dist/Config/SecretURL.d.ts.map +1 -1
- package/dist/Config/SecretURL.js +3 -6
- package/dist/Config/internal/configSecretURL.d.ts.map +1 -1
- package/dist/Config/internal/configSecretURL.js +2 -2
- package/dist/Config.d.ts +2 -0
- package/dist/Config.d.ts.map +1 -0
- package/dist/Config.js +8 -0
- package/dist/ConfigProvider.d.ts +2 -0
- package/dist/ConfigProvider.d.ts.map +1 -0
- package/dist/ConfigProvider.js +6 -0
- package/dist/{ServiceMap.d.ts → Context.d.ts} +18 -20
- package/dist/Context.d.ts.map +1 -0
- package/dist/Context.js +67 -0
- package/dist/DataDependencies.d.ts +136 -0
- package/dist/DataDependencies.d.ts.map +1 -0
- package/dist/DataDependencies.js +112 -0
- package/dist/Effect.d.ts +10 -9
- package/dist/Effect.d.ts.map +1 -1
- package/dist/Effect.js +6 -9
- 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.map +1 -1
- package/dist/Layer.d.ts +10 -6
- package/dist/Layer.d.ts.map +1 -1
- package/dist/Layer.js +3 -2
- package/dist/Model/Repository/Registry.d.ts +22 -0
- package/dist/Model/Repository/Registry.d.ts.map +1 -0
- package/dist/Model/Repository/Registry.js +18 -0
- package/dist/Model/Repository/dependency.d.ts +6 -0
- package/dist/Model/Repository/dependency.d.ts.map +1 -0
- package/dist/Model/Repository/dependency.js +29 -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 +124 -0
- package/dist/Model/Repository/internal/internal.d.ts +68 -0
- package/dist/Model/Repository/internal/internal.d.ts.map +1 -0
- package/dist/Model/Repository/internal/internal.js +611 -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 +71 -0
- package/dist/Model/Repository/makeRepo.d.ts.map +1 -0
- package/dist/Model/Repository/makeRepo.js +30 -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 +72 -0
- package/dist/Model/Repository/validation.d.ts.map +1 -0
- package/dist/Model/Repository/validation.js +39 -0
- package/dist/Model/Repository.d.ts +8 -0
- package/dist/Model/Repository.d.ts.map +1 -0
- package/dist/Model/Repository.js +8 -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 +94 -0
- package/dist/Model/filter/types/path/eager.d.ts.map +1 -0
- package/dist/Model/filter/types/path/eager.js +36 -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 +630 -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 +132 -0
- package/dist/Model/query/new-kid-interpreter.d.ts.map +1 -0
- package/dist/Model/query/new-kid-interpreter.js +370 -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 +6 -0
- package/dist/Model.d.ts.map +1 -0
- package/dist/Model.js +6 -0
- package/dist/NonEmptySet.d.ts +3 -1
- package/dist/NonEmptySet.d.ts.map +1 -1
- package/dist/NonEmptySet.js +2 -2
- package/dist/Option.d.ts +1 -0
- package/dist/Option.d.ts.map +1 -1
- package/dist/Option.js +3 -1
- package/dist/Pure.d.ts +7 -5
- package/dist/Pure.d.ts.map +1 -1
- package/dist/Pure.js +7 -4
- package/dist/QueueMaker.d.ts +11 -0
- package/dist/QueueMaker.d.ts.map +1 -0
- package/dist/QueueMaker.js +11 -0
- package/dist/RequestContext.d.ts +87 -0
- package/dist/RequestContext.d.ts.map +1 -0
- package/dist/RequestContext.js +45 -0
- package/dist/RequestScopedDependencies.d.ts +21 -0
- package/dist/RequestScopedDependencies.d.ts.map +1 -0
- package/dist/RequestScopedDependencies.js +16 -0
- package/dist/Schema/Class.d.ts +200 -20
- package/dist/Schema/Class.d.ts.map +1 -1
- package/dist/Schema/Class.js +268 -17
- package/dist/Schema/FastCheck.d.ts.map +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 +117 -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 -5
- package/dist/Schema/brand.d.ts.map +1 -1
- package/dist/Schema/brand.js +3 -1
- package/dist/Schema/email.d.ts.map +1 -1
- package/dist/Schema/email.js +12 -6
- package/dist/Schema/ext.d.ts +335 -61
- package/dist/Schema/ext.d.ts.map +1 -1
- package/dist/Schema/ext.js +388 -63
- package/dist/Schema/moreStrings.d.ts +82 -36
- package/dist/Schema/moreStrings.d.ts.map +1 -1
- package/dist/Schema/moreStrings.js +90 -53
- package/dist/Schema/numbers.d.ts +33 -21
- package/dist/Schema/numbers.d.ts.map +1 -1
- package/dist/Schema/numbers.js +65 -12
- package/dist/Schema/phoneNumber.d.ts.map +1 -1
- package/dist/Schema/phoneNumber.js +11 -7
- package/dist/Schema/schema.d.ts +1 -1
- package/dist/Schema/schema.d.ts.map +1 -1
- package/dist/Schema/schema.js +2 -2
- package/dist/Schema/strings.d.ts +18 -4
- package/dist/Schema/strings.d.ts.map +1 -1
- package/dist/Schema/strings.js +1 -5
- package/dist/Schema.d.ts +225 -7
- package/dist/Schema.d.ts.map +1 -1
- package/dist/Schema.js +193 -26
- package/dist/SchemaAST.d.ts +2 -0
- package/dist/SchemaAST.d.ts.map +1 -0
- package/dist/SchemaAST.js +2 -0
- package/dist/Set.d.ts +4 -1
- package/dist/Set.d.ts.map +1 -1
- package/dist/Set.js +3 -2
- package/dist/Store.d.ts +215 -0
- package/dist/Store.d.ts.map +1 -0
- package/dist/Store.js +113 -0
- package/dist/_ext/Array.d.ts +1 -1
- package/dist/_ext/Array.d.ts.map +1 -1
- package/dist/_ext/Array.js +4 -2
- package/dist/_ext/misc.d.ts +4 -1
- package/dist/_ext/misc.d.ts.map +1 -1
- package/dist/_ext/misc.js +4 -2
- package/dist/_ext/ord.ext.d.ts +2 -1
- package/dist/_ext/ord.ext.d.ts.map +1 -1
- package/dist/_ext/ord.ext.js +2 -2
- package/dist/builtin.d.ts +2 -14
- package/dist/builtin.d.ts.map +1 -1
- package/dist/builtin.js +1 -1
- package/dist/client/InvalidationKeys.d.ts +30 -0
- package/dist/client/InvalidationKeys.d.ts.map +1 -0
- package/dist/client/InvalidationKeys.js +37 -0
- package/dist/client/apiClientFactory.d.ts +19 -31
- package/dist/client/apiClientFactory.d.ts.map +1 -1
- package/dist/client/apiClientFactory.js +157 -39
- package/dist/client/clientFor.d.ts +54 -18
- package/dist/client/clientFor.d.ts.map +1 -1
- package/dist/client/clientFor.js +9 -1
- package/dist/client/errors.d.ts +82 -27
- package/dist/client/errors.d.ts.map +1 -1
- package/dist/client/errors.js +75 -19
- package/dist/client/makeClient.d.ts +490 -34
- package/dist/client/makeClient.d.ts.map +1 -1
- package/dist/client/makeClient.js +62 -30
- package/dist/client.d.ts +2 -0
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +3 -1
- package/dist/faker.d.ts.map +1 -1
- package/dist/http/Request.d.ts +1 -1
- package/dist/http/Request.d.ts.map +1 -1
- package/dist/http/Request.js +2 -2
- package/dist/ids.d.ts +32 -14
- package/dist/ids.d.ts.map +1 -1
- package/dist/ids.js +38 -6
- package/dist/index.d.ts +6 -7
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +8 -8
- package/dist/middleware.d.ts +13 -7
- package/dist/middleware.d.ts.map +1 -1
- package/dist/middleware.js +14 -8
- package/dist/rpc/Invalidation.d.ts +1124 -0
- package/dist/rpc/Invalidation.d.ts.map +1 -0
- package/dist/rpc/Invalidation.js +178 -0
- package/dist/rpc/MiddlewareMaker.d.ts +11 -7
- package/dist/rpc/MiddlewareMaker.d.ts.map +1 -1
- package/dist/rpc/MiddlewareMaker.js +59 -38
- package/dist/rpc/RpcContextMap.d.ts +3 -3
- package/dist/rpc/RpcContextMap.d.ts.map +1 -1
- package/dist/rpc/RpcContextMap.js +4 -4
- package/dist/rpc/RpcMiddleware.d.ts +14 -10
- package/dist/rpc/RpcMiddleware.d.ts.map +1 -1
- package/dist/rpc/RpcMiddleware.js +1 -1
- package/dist/rpc.d.ts +1 -1
- 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 +20 -0
- package/dist/setupRequest.d.ts.map +1 -0
- package/dist/setupRequest.js +72 -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 +1 -1
- package/dist/transform.d.ts.map +1 -1
- package/dist/transform.js +4 -5
- package/dist/utils/effectify.d.ts +1 -1
- package/dist/utils/effectify.d.ts.map +1 -1
- package/dist/utils/effectify.js +2 -2
- package/dist/utils/extend.d.ts.map +1 -1
- package/dist/utils/gen.d.ts +4 -4
- package/dist/utils/gen.d.ts.map +1 -1
- package/dist/utils/logLevel.d.ts +2 -2
- package/dist/utils/logLevel.d.ts.map +1 -1
- package/dist/utils/logger.d.ts +4 -3
- package/dist/utils/logger.d.ts.map +1 -1
- package/dist/utils/logger.js +4 -4
- package/dist/utils.d.ts +34 -39
- package/dist/utils.d.ts.map +1 -1
- package/dist/utils.js +33 -37
- package/dist/validation/validators.d.ts.map +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 +27 -251
- package/src/Array.ts +5 -5
- package/src/Chunk.ts +3 -3
- package/src/Config/SecretURL.ts +6 -3
- package/src/Config/internal/configSecretURL.ts +2 -2
- package/src/Config.ts +7 -0
- package/src/ConfigProvider.ts +5 -0
- package/src/{ServiceMap.ts → Context.ts} +56 -63
- package/src/DataDependencies.ts +171 -0
- package/src/Effect.ts +15 -17
- package/src/Emailer.ts +51 -0
- package/src/Inputify.type.ts +1 -1
- package/src/Layer.ts +11 -7
- package/src/Model/Repository/Registry.ts +35 -0
- package/src/Model/Repository/dependency.ts +32 -0
- package/src/Model/Repository/ext.ts +374 -0
- package/src/Model/Repository/internal/internal.ts +988 -0
- package/src/Model/Repository/legacy.ts +29 -0
- package/src/Model/Repository/makeRepo.ts +168 -0
- package/src/Model/Repository/service.ts +676 -0
- package/src/Model/Repository/validation.ts +38 -0
- package/src/Model/Repository.ts +7 -0
- package/src/Model/dsl.ts +129 -0
- package/src/Model/filter/filterApi.ts +78 -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 +329 -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 +3092 -0
- package/src/Model/query/new-kid-interpreter.ts +532 -0
- package/src/Model/query.ts +13 -0
- package/src/Model.ts +5 -0
- package/src/NonEmptySet.ts +6 -4
- package/src/Option.ts +2 -0
- package/src/Pure.ts +10 -7
- package/src/QueueMaker.ts +11 -0
- package/src/RequestContext.ts +48 -0
- package/src/RequestScopedDependencies.ts +45 -0
- package/src/Schema/Class.ts +648 -60
- package/src/Schema/SchemaParser.ts +12 -0
- package/src/Schema/SpecialJsonSchema.ts +137 -0
- package/src/Schema/SpecialOpenApi.ts +130 -0
- package/src/Schema/brand.ts +24 -9
- package/src/Schema/email.ts +14 -7
- package/src/Schema/ext.ts +508 -102
- package/src/Schema/moreStrings.ts +217 -86
- package/src/Schema/numbers.ts +107 -28
- package/src/Schema/phoneNumber.ts +13 -9
- package/src/Schema/schema.ts +1 -1
- package/src/Schema/strings.ts +23 -14
- package/src/Schema.ts +403 -46
- package/src/SchemaAST.ts +1 -0
- package/src/Set.ts +6 -2
- package/src/Store.ts +325 -0
- package/src/_ext/Array.ts +4 -2
- package/src/_ext/misc.ts +4 -1
- package/src/_ext/ord.ext.ts +2 -1
- package/src/builtin-json.d.ts +24 -0
- package/src/builtin.ts +16 -21
- package/src/client/InvalidationKeys.ts +55 -0
- package/src/client/apiClientFactory.ts +301 -141
- package/src/client/clientFor.ts +107 -34
- package/src/client/errors.ts +100 -29
- package/src/client/makeClient.ts +594 -80
- package/src/client.ts +6 -4
- package/src/http/Request.ts +3 -3
- package/src/http.ts +1 -1
- package/src/ids.ts +45 -7
- package/src/index.ts +20 -23
- package/src/middleware.ts +13 -9
- package/src/rpc/Invalidation.ts +278 -0
- package/src/rpc/MiddlewareMaker.ts +88 -80
- package/src/rpc/README.md +2 -2
- package/src/rpc/RpcContextMap.ts +7 -6
- package/src/rpc/RpcMiddleware.ts +19 -13
- package/src/rpc.ts +4 -4
- package/src/runtime.ts +57 -0
- package/src/setupRequest.ts +138 -0
- package/src/toast.ts +54 -0
- package/src/transform.ts +4 -4
- 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 +85 -158
- package/src/validation.ts +2 -2
- package/src/withToast.ts +133 -0
- package/test/dist/rpc.test.d.ts.map +1 -1
- package/test/dist/rpcMiddlewareContext.test.d.ts.map +1 -0
- package/test/dist/secretURL.test.d.ts.map +1 -0
- package/test/dist/special.test.d.ts.map +1 -0
- package/test/moreStrings.test.ts +55 -10
- package/test/rpc.test.ts +38 -10
- package/test/rpcMiddlewareContext.test.ts +63 -0
- package/test/schema.test.ts +505 -26
- package/test/secretURL.test.ts +160 -0
- package/test/special.test.ts +1261 -0
- package/test/utils.test.ts +7 -7
- package/tsconfig.base.json +6 -5
- package/tsconfig.json +9 -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.map +0 -1
- package/dist/ServiceMap.js +0 -91
- package/eslint.config.mjs +0 -26
- package/src/Operations.ts +0 -55
- package/tsconfig.json.bak +0 -12
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import * as S from "../../Schema.ts"
|
|
2
|
+
import { NonNegativeInt } from "../../Schema.ts"
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Represents a single validation error when decoding a repository item.
|
|
6
|
+
* Contains full context for debugging: the stored data and the decode error.
|
|
7
|
+
*/
|
|
8
|
+
export class ValidationError extends S.Opaque<ValidationError>()(S.Struct({
|
|
9
|
+
/** the id of the item that failed validation */
|
|
10
|
+
id: S.Unknown,
|
|
11
|
+
/**
|
|
12
|
+
* the data as returned by the store: `defaultValues` merged, `jitM` applied
|
|
13
|
+
* to the raw JSON document, and JSON decoded to the Encoded shape
|
|
14
|
+
*/
|
|
15
|
+
rawData: S.Unknown,
|
|
16
|
+
/**
|
|
17
|
+
* @deprecated identical to {@link rawData}. `jitM` now runs inside the store,
|
|
18
|
+
* before the JSON→Encoded decode, so the repository never sees the document
|
|
19
|
+
* as it was before the migration.
|
|
20
|
+
*/
|
|
21
|
+
jitMResult: S.Unknown,
|
|
22
|
+
/** the S.SchemaError from schema decode */
|
|
23
|
+
error: S.Unknown
|
|
24
|
+
})) {}
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Result of validating a sample of repository items.
|
|
28
|
+
*/
|
|
29
|
+
export class ValidationResult extends S.Opaque<ValidationResult>()(S.Struct({
|
|
30
|
+
/** total number of items in the repository */
|
|
31
|
+
total: NonNegativeInt,
|
|
32
|
+
/** number of items that were sampled for validation */
|
|
33
|
+
sampled: NonNegativeInt,
|
|
34
|
+
/** number of items that passed validation */
|
|
35
|
+
valid: NonNegativeInt,
|
|
36
|
+
/** list of validation errors with full context */
|
|
37
|
+
errors: S.Array(ValidationError)
|
|
38
|
+
})) {}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export { repositoryDependency } from "./Repository/dependency.ts"
|
|
2
|
+
export * from "./Repository/ext.ts"
|
|
3
|
+
export * from "./Repository/legacy.ts"
|
|
4
|
+
export { makeRepo } from "./Repository/makeRepo.ts"
|
|
5
|
+
export * from "./Repository/Registry.ts"
|
|
6
|
+
export * from "./Repository/service.ts"
|
|
7
|
+
export * from "./Repository/validation.ts"
|
package/src/Model/dsl.ts
ADDED
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
2
|
+
import type { NonEmptyReadonlyArray } from "../Array.ts"
|
|
3
|
+
import { toNonEmptyArray } from "../Array.ts"
|
|
4
|
+
import * as Effect from "../Effect.ts"
|
|
5
|
+
import { type FixEnv, get, logMany, type Pure, type PureEnvEnv, type PureLogT, set } from "../Pure.ts"
|
|
6
|
+
|
|
7
|
+
export interface PureDSL<S, S2, W> {
|
|
8
|
+
get: Pure<never, S, S, never, never, S>
|
|
9
|
+
set: (s: S2) => Pure<never, S2, S2, never, never, void>
|
|
10
|
+
log: (...w: W[]) => PureLogT<W>
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export const AnyPureDSL: PureDSL<any, any, any> = {
|
|
14
|
+
get: get(),
|
|
15
|
+
set: set as any,
|
|
16
|
+
log: (...evt: any[]) => logMany(evt)
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
const anyDSL = makeDSL<any, any, any>()
|
|
20
|
+
|
|
21
|
+
export type AllDSL<T, Evt> =
|
|
22
|
+
& (<R, A, E, S1 extends T, S2 extends T>(
|
|
23
|
+
pure: (dsl: PureDSL<S1[], S2[], Evt>) => Effect.Effect<A, E, R>
|
|
24
|
+
) => Effect.Effect<A, E, FixEnv<R, Evt, S1[], S2[]>>)
|
|
25
|
+
& AllDSLExt<T, Evt>
|
|
26
|
+
|
|
27
|
+
export interface AllDSLExt<T, Evt> {
|
|
28
|
+
modify: <R, E, A, S1 extends T, S2 extends T>(
|
|
29
|
+
pure: (items: readonly S1[], dsl: PureDSL<readonly S1[], readonly S2[], Evt>) => Effect.Effect<A, E, R>
|
|
30
|
+
) => Effect.Effect<A, E, FixEnv<R, Evt, readonly S1[], readonly S2[]>>
|
|
31
|
+
update: <R, E, S1 extends T, S2 extends T>(
|
|
32
|
+
pure: (items: readonly S1[], log: (...evt: Evt[]) => PureLogT<Evt>) => Effect.Effect<readonly S2[], E, R>
|
|
33
|
+
) => Effect.Effect<readonly S2[], E, FixEnv<R, Evt, readonly S1[], readonly S2[]>>
|
|
34
|
+
updateWith: <S1 extends T, S2 extends T>(
|
|
35
|
+
upd: (item: readonly S1[]) => readonly S2[]
|
|
36
|
+
) => Effect.Effect<readonly S2[], never, PureEnvEnv<Evt, readonly S1[], readonly S2[]>>
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export function makeAllDSL<T, Evt>() {
|
|
40
|
+
const dsl: AllDSL<T, Evt> = anyDSL
|
|
41
|
+
return dsl
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export type OneDSL<T, Evt> =
|
|
45
|
+
& (<R, A, E, S1 extends T, S2 extends T>(
|
|
46
|
+
pure: (dsl: PureDSL<S1, S2, Evt>) => Effect.Effect<A, E, R>
|
|
47
|
+
) => Effect.Effect<A, E, FixEnv<R, Evt, S1, S2>>)
|
|
48
|
+
& OneDSLExt<T, Evt>
|
|
49
|
+
|
|
50
|
+
export interface OneDSLExt<T, Evt> {
|
|
51
|
+
modify: <R, E, A, S1 extends T, S2 extends T>(
|
|
52
|
+
pure: (items: S1, dsl: PureDSL<S1, S2, Evt>) => Effect.Effect<A, E, R>
|
|
53
|
+
) => Effect.Effect<A, E, FixEnv<R, Evt, S1, S2> | PureEnvEnv<Evt, S1, S1>>
|
|
54
|
+
update: <R, E, S1 extends T, S2 extends T>(
|
|
55
|
+
pure: (items: S1, log: (...evt: Evt[]) => PureLogT<Evt>) => Effect.Effect<S2, E, R>
|
|
56
|
+
) => Effect.Effect<S2, E, FixEnv<R, Evt, S1, S2>>
|
|
57
|
+
updateWith: <S1 extends T, S2 extends T>(
|
|
58
|
+
upd: (item: S1) => S2
|
|
59
|
+
) => Effect.Effect<S2, never, PureEnvEnv<Evt, S1, S2>>
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
export function makeOneDSL<T, Evt>(): OneDSL<T, Evt> {
|
|
63
|
+
return anyDSL
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
export function makeDSL<S1, S2, Evt>() {
|
|
67
|
+
const dsl: PureDSL<S1, S2, Evt> = AnyPureDSL
|
|
68
|
+
|
|
69
|
+
function modify<
|
|
70
|
+
R,
|
|
71
|
+
E,
|
|
72
|
+
A
|
|
73
|
+
>(
|
|
74
|
+
pure: (
|
|
75
|
+
items: S1,
|
|
76
|
+
dsl: PureDSL<S1, S2, Evt>
|
|
77
|
+
) => Effect.Effect<A, E, R>
|
|
78
|
+
): Effect.Effect<A, E, FixEnv<R, Evt, S1, S2>> {
|
|
79
|
+
return dsl.get.pipe(Effect.flatMap((items) => pure(items, dsl))) as any
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
function update<
|
|
83
|
+
R,
|
|
84
|
+
E
|
|
85
|
+
>(
|
|
86
|
+
pure: (
|
|
87
|
+
items: S1,
|
|
88
|
+
log: (...evt: Evt[]) => PureLogT<Evt>
|
|
89
|
+
) => Effect.Effect<S2, E, R>
|
|
90
|
+
): Effect.Effect<S2, E, FixEnv<R, Evt, S1, S2>> {
|
|
91
|
+
return dsl.get.pipe(Effect.flatMap((items) => pure(items, dsl.log).pipe(Effect.tap(dsl.set)))) as any
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
function withDSL<
|
|
95
|
+
R,
|
|
96
|
+
A,
|
|
97
|
+
E
|
|
98
|
+
>(
|
|
99
|
+
pure: (dsl: PureDSL<S1, S2, Evt>) => Effect.Effect<A, E, R>
|
|
100
|
+
): Effect.Effect<A, E, FixEnv<R, Evt, S1, S2>> {
|
|
101
|
+
return pure(AnyPureDSL) as any
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
function updateWith(upd: (item: S1) => S2) {
|
|
105
|
+
return update((_: S1) => Effect.sync(() => upd(_)))
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
return Object.assign(
|
|
109
|
+
withDSL,
|
|
110
|
+
{
|
|
111
|
+
modify,
|
|
112
|
+
update,
|
|
113
|
+
updateWith
|
|
114
|
+
}
|
|
115
|
+
)
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
export interface DSLExt<S1, S2, Evt> extends ReturnType<typeof makeDSL<S1, S2, Evt>> {}
|
|
119
|
+
|
|
120
|
+
export function ifAny<T, R, E, A>(fn: (items: NonEmptyReadonlyArray<T>) => Effect.Effect<A, E, R>) {
|
|
121
|
+
return (items: Iterable<T>) => Effect.flatMapOption(Effect.sync(() => toNonEmptyArray([...items])), fn)
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
export function ifAny_<T, R, E, A>(
|
|
125
|
+
items: Iterable<T>,
|
|
126
|
+
fn: (items: NonEmptyReadonlyArray<T>) => Effect.Effect<A, E, R>
|
|
127
|
+
) {
|
|
128
|
+
return Effect.flatMapOption(Effect.sync(() => toNonEmptyArray([...items])), fn)
|
|
129
|
+
}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { type RelationDirection } from "../query.ts"
|
|
2
|
+
|
|
3
|
+
export type InOps =
|
|
4
|
+
| "in"
|
|
5
|
+
| "notIn"
|
|
6
|
+
|
|
7
|
+
export type OtherOps =
|
|
8
|
+
| "endsWith"
|
|
9
|
+
| "startsWith"
|
|
10
|
+
| "notEndsWith"
|
|
11
|
+
| "notStartsWith"
|
|
12
|
+
| "contains"
|
|
13
|
+
| "notContains"
|
|
14
|
+
| "includes"
|
|
15
|
+
| "notIncludes"
|
|
16
|
+
| "includes-any"
|
|
17
|
+
| "notIncludes-any"
|
|
18
|
+
| "includes-all"
|
|
19
|
+
| "notIncludes-all"
|
|
20
|
+
| "hasKey"
|
|
21
|
+
| "notHasKey"
|
|
22
|
+
| "hasValue"
|
|
23
|
+
| "notHasValue"
|
|
24
|
+
| "hasKeyValue"
|
|
25
|
+
| "notHasKeyValue"
|
|
26
|
+
| "hasKey-any"
|
|
27
|
+
| "notHasKey-any"
|
|
28
|
+
| "hasKey-all"
|
|
29
|
+
| "notHasKey-all"
|
|
30
|
+
| "hasValue-any"
|
|
31
|
+
| "notHasValue-any"
|
|
32
|
+
| "hasValue-all"
|
|
33
|
+
| "notHasValue-all"
|
|
34
|
+
| "hasKeyValue-any"
|
|
35
|
+
| "notHasKeyValue-any"
|
|
36
|
+
| "hasKeyValue-all"
|
|
37
|
+
| "notHasKeyValue-all"
|
|
38
|
+
| "eq"
|
|
39
|
+
| "neq"
|
|
40
|
+
| "gt"
|
|
41
|
+
| "gte"
|
|
42
|
+
| "lt"
|
|
43
|
+
| "lte"
|
|
44
|
+
|
|
45
|
+
export type Ops = OtherOps | InOps
|
|
46
|
+
|
|
47
|
+
export type FilterScopes = {
|
|
48
|
+
t: "or-scope"
|
|
49
|
+
result: readonly FilterResult[]
|
|
50
|
+
relation: RelationDirection
|
|
51
|
+
} | {
|
|
52
|
+
t: "and-scope"
|
|
53
|
+
result: readonly FilterResult[]
|
|
54
|
+
relation: RelationDirection
|
|
55
|
+
} | {
|
|
56
|
+
t: "where-scope"
|
|
57
|
+
result: readonly FilterResult[]
|
|
58
|
+
relation: RelationDirection
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
export type FilterR = {
|
|
62
|
+
op: Ops
|
|
63
|
+
|
|
64
|
+
path: string
|
|
65
|
+
value: unknown
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
export type FilterResult =
|
|
69
|
+
| {
|
|
70
|
+
t: "where"
|
|
71
|
+
} & FilterR
|
|
72
|
+
| {
|
|
73
|
+
t: "or"
|
|
74
|
+
} & FilterR
|
|
75
|
+
| {
|
|
76
|
+
t: "and"
|
|
77
|
+
} & FilterR
|
|
78
|
+
| FilterScopes
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import type { FieldValues, InternalFieldName } from "./fields.ts"
|
|
2
|
+
import type { BrowserNativeObject, IsAny, LiteralUnion, Merge } from "./utils.ts"
|
|
3
|
+
import type { RegisterOptions, ValidateResult } from "./validator.ts"
|
|
4
|
+
|
|
5
|
+
export type Message = string
|
|
6
|
+
|
|
7
|
+
export type MultipleFieldErrors =
|
|
8
|
+
& {
|
|
9
|
+
[K in keyof RegisterOptions]?: ValidateResult
|
|
10
|
+
}
|
|
11
|
+
& {
|
|
12
|
+
[key: string]: ValidateResult
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export type FieldError = {
|
|
16
|
+
type: LiteralUnion<keyof RegisterOptions, string>
|
|
17
|
+
root?: FieldError
|
|
18
|
+
// ref?: Ref
|
|
19
|
+
types?: MultipleFieldErrors
|
|
20
|
+
message?: Message
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export type ErrorOption = {
|
|
24
|
+
message?: Message
|
|
25
|
+
type?: LiteralUnion<keyof RegisterOptions, string>
|
|
26
|
+
types?: MultipleFieldErrors
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export type DeepRequired<T> = T extends BrowserNativeObject | Blob ? T
|
|
30
|
+
: {
|
|
31
|
+
[K in keyof T]-?: NonNullable<DeepRequired<T[K]>>
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export type FieldErrorsImpl<T extends FieldValues = FieldValues> = {
|
|
35
|
+
[K in keyof T]?: T[K] extends BrowserNativeObject | Blob ? FieldError
|
|
36
|
+
: T[K] extends object ? Merge<FieldError, FieldErrorsImpl<T[K]>>
|
|
37
|
+
: FieldError
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export type FieldErrors<T extends FieldValues = FieldValues> = Partial<
|
|
41
|
+
FieldValues extends IsAny<FieldValues> ? any
|
|
42
|
+
: FieldErrorsImpl<DeepRequired<T>>
|
|
43
|
+
>
|
|
44
|
+
|
|
45
|
+
export type InternalFieldErrors = Partial<
|
|
46
|
+
Record<InternalFieldName, FieldError>
|
|
47
|
+
>
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import type { IsFlatObject } from "./utils.ts"
|
|
2
|
+
import type { RegisterOptions } from "./validator.ts"
|
|
3
|
+
|
|
4
|
+
export type InternalFieldName = string
|
|
5
|
+
|
|
6
|
+
export type FieldName<TFieldValues extends FieldValues> = IsFlatObject<TFieldValues> extends true
|
|
7
|
+
? Extract<keyof TFieldValues, string>
|
|
8
|
+
: string
|
|
9
|
+
|
|
10
|
+
// export type CustomElement<TFieldValues extends FieldValues> = {
|
|
11
|
+
// name: FieldName<TFieldValues>
|
|
12
|
+
// type?: string
|
|
13
|
+
// value?: any
|
|
14
|
+
// disabled?: boolean
|
|
15
|
+
// checked?: boolean
|
|
16
|
+
// options?: HTMLOptionsCollection
|
|
17
|
+
// files?: FileList | null
|
|
18
|
+
// focus?: Noop
|
|
19
|
+
// }
|
|
20
|
+
|
|
21
|
+
export type FieldValue<TFieldValues extends FieldValues> = TFieldValues[InternalFieldName]
|
|
22
|
+
|
|
23
|
+
export type FieldValues = Record<string, any>
|
|
24
|
+
|
|
25
|
+
export type NativeFieldValue =
|
|
26
|
+
| string
|
|
27
|
+
| number
|
|
28
|
+
| boolean
|
|
29
|
+
| null
|
|
30
|
+
| undefined
|
|
31
|
+
| unknown[]
|
|
32
|
+
|
|
33
|
+
// export type FieldElement<TFieldValues extends FieldValues = FieldValues> =
|
|
34
|
+
// | HTMLInputElement
|
|
35
|
+
// | HTMLSelectElement
|
|
36
|
+
// | HTMLTextAreaElement
|
|
37
|
+
// | CustomElement<TFieldValues>
|
|
38
|
+
|
|
39
|
+
// export type Ref = FieldElement
|
|
40
|
+
|
|
41
|
+
export type Field = {
|
|
42
|
+
_f: {
|
|
43
|
+
// ref: Ref
|
|
44
|
+
name: InternalFieldName
|
|
45
|
+
// refs?: HTMLInputElement[]
|
|
46
|
+
mount?: boolean
|
|
47
|
+
} & RegisterOptions
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export type FieldRefs = Partial<Record<InternalFieldName, Field>>
|