effect-app 4.0.0-beta.266 → 4.0.0-beta.268
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 +14 -0
- package/dist/Model/Repository/Registry.d.ts +5 -4
- package/dist/Model/Repository/Registry.d.ts.map +1 -1
- package/dist/Model/Repository/Registry.js +1 -1
- package/dist/Model/Repository/ext.d.ts +3 -3
- package/dist/Model/Repository/legacy.d.ts +6 -6
- package/dist/Model/Repository/legacy.d.ts.map +1 -1
- package/dist/Model/Repository/service.d.ts +30 -30
- package/dist/Model/Repository/service.d.ts.map +1 -1
- package/dist/Model/filter/types.d.ts +4 -4
- package/dist/Schema/Class.js +2 -2
- package/dist/Schema/SpecialOpenApi.js +1 -1
- package/dist/Store.d.ts +11 -11
- package/dist/Store.d.ts.map +1 -1
- package/dist/client/errors.d.ts +35 -4
- package/dist/client/errors.d.ts.map +1 -1
- package/dist/client/errors.js +32 -2
- package/dist/client.d.ts +5 -5
- package/dist/rpc/Invalidation.js +3 -3
- package/dist/utils.d.ts +5 -5
- package/package.json +3 -3
- package/src/Array.ts +2 -2
- package/src/Chunk.ts +3 -3
- package/src/Config/SecretURL.ts +1 -1
- package/src/Config/internal/configSecretURL.ts +1 -1
- package/src/Config.ts +1 -1
- package/src/Effect.ts +3 -3
- package/src/Emailer.ts +4 -4
- package/src/Inputify.type.ts +1 -1
- package/src/Layer.ts +2 -2
- package/src/Model/Repository/Registry.ts +5 -4
- package/src/Model/Repository/ext.ts +11 -11
- package/src/Model/Repository/internal/internal.ts +16 -16
- package/src/Model/Repository/legacy.ts +8 -8
- package/src/Model/Repository/makeRepo.ts +11 -11
- package/src/Model/Repository/service.ts +47 -37
- package/src/Model/Repository/validation.ts +2 -2
- package/src/Model/Repository.ts +6 -6
- package/src/Model/dsl.ts +4 -4
- package/src/Model/filter/filterApi.ts +1 -1
- package/src/Model/filter/types/errors.ts +3 -3
- package/src/Model/filter/types/fields.ts +2 -2
- package/src/Model/filter/types/path/common.ts +1 -1
- package/src/Model/filter/types/path/eager.ts +3 -3
- package/src/Model/filter/types/path/index.ts +2 -2
- package/src/Model/filter/types/validator.ts +3 -3
- package/src/Model/query/dsl.ts +6 -6
- package/src/Model/query/new-kid-interpreter.ts +9 -9
- package/src/Model/query.ts +2 -2
- package/src/Model.ts +4 -4
- package/src/NonEmptySet.ts +3 -3
- package/src/Option.ts +1 -1
- package/src/Pure.ts +2 -2
- package/src/QueueMaker.ts +3 -3
- package/src/RequestContext.ts +4 -4
- package/src/Schema/Class.ts +5 -5
- package/src/Schema/SchemaParser.ts +1 -1
- package/src/Schema/SpecialOpenApi.ts +2 -2
- package/src/Schema/email.ts +2 -2
- package/src/Schema/ext.ts +4 -4
- package/src/Schema/moreStrings.ts +4 -4
- package/src/Schema/numbers.ts +3 -3
- package/src/Schema/phoneNumber.ts +4 -4
- package/src/Schema/strings.ts +2 -2
- package/src/Schema.ts +23 -23
- package/src/Set.ts +1 -1
- package/src/Store.ts +20 -20
- package/src/_ext/Array.ts +1 -1
- package/src/client/InvalidationKeys.ts +3 -3
- package/src/client/apiClientFactory.ts +9 -9
- package/src/client/clientFor.ts +3 -3
- package/src/client/errors.ts +42 -2
- package/src/client/makeClient.ts +4 -4
- package/src/http/Request.ts +2 -2
- package/src/http.ts +1 -1
- package/src/ids.ts +2 -2
- package/src/index.ts +19 -19
- package/src/middleware.ts +1 -1
- package/src/rpc/Invalidation.ts +7 -7
- package/src/rpc/MiddlewareMaker.ts +6 -6
- package/src/rpc/RpcContextMap.ts +2 -2
- package/src/rpc/RpcMiddleware.ts +2 -2
- package/src/rpc.ts +4 -4
- package/src/runtime.ts +4 -4
- package/src/setupRequest.ts +6 -6
- package/src/toast.ts +4 -4
- package/src/transform.ts +1 -1
- package/src/utils/logger.ts +1 -1
- package/src/utils.ts +2 -2
- package/src/validation.ts +2 -2
- package/src/withToast.ts +7 -7
package/src/Schema/numbers.ts
CHANGED
|
@@ -13,9 +13,9 @@ import * as Effect from "effect/Effect"
|
|
|
13
13
|
import * as S from "effect/Schema"
|
|
14
14
|
import type * as SchemaAST from "effect/SchemaAST"
|
|
15
15
|
import type { Simplify } from "effect/Types"
|
|
16
|
-
import { type BrandedSchema, fromBrand, nominal } from "./brand.
|
|
17
|
-
import { withDefaultMake } from "./ext.
|
|
18
|
-
import { type B } from "./schema.
|
|
16
|
+
import { type BrandedSchema, fromBrand, nominal } from "./brand.ts"
|
|
17
|
+
import { withDefaultMake } from "./ext.ts"
|
|
18
|
+
import { type B } from "./schema.ts"
|
|
19
19
|
|
|
20
20
|
export interface PositiveIntBrand
|
|
21
21
|
extends Simplify<B.Brand<"PositiveInt"> & NonNegativeIntBrand & PositiveNumberBrand>
|
|
@@ -2,10 +2,10 @@ import type { Refinement } from "effect-app/Function"
|
|
|
2
2
|
import { isValidPhone } from "effect-app/validation"
|
|
3
3
|
import * as S from "effect/Schema"
|
|
4
4
|
import type { Simplify } from "effect/Types"
|
|
5
|
-
import { withDefaultMake } from "./ext.
|
|
6
|
-
import { Numbers } from "./FastCheck.
|
|
7
|
-
import type { B } from "./schema.
|
|
8
|
-
import type { NonEmptyStringBrand } from "./strings.
|
|
5
|
+
import { withDefaultMake } from "./ext.ts"
|
|
6
|
+
import { Numbers } from "./FastCheck.ts"
|
|
7
|
+
import type { B } from "./schema.ts"
|
|
8
|
+
import type { NonEmptyStringBrand } from "./strings.ts"
|
|
9
9
|
|
|
10
10
|
export interface PhoneNumberBrand extends Simplify<B.Brand<"PhoneNumber"> & NonEmptyStringBrand> {}
|
|
11
11
|
export type PhoneNumber = string & PhoneNumberBrand
|
package/src/Schema/strings.ts
CHANGED
|
@@ -2,8 +2,8 @@ import type * as B from "effect/Brand"
|
|
|
2
2
|
import * as S from "effect/Schema"
|
|
3
3
|
import type * as SchemaAST from "effect/SchemaAST"
|
|
4
4
|
import type { Simplify } from "effect/Types"
|
|
5
|
-
import { type BrandedSchema, fromBrand, nominal } from "./brand.
|
|
6
|
-
import { withDefaultMake } from "./ext.
|
|
5
|
+
import { type BrandedSchema, fromBrand, nominal } from "./brand.ts"
|
|
6
|
+
import { withDefaultMake } from "./ext.ts"
|
|
7
7
|
|
|
8
8
|
export type NonEmptyStringBrand = B.Brand<"NonEmptyString">
|
|
9
9
|
export type NonEmptyString = string & NonEmptyStringBrand
|
package/src/Schema.ts
CHANGED
|
@@ -3,13 +3,13 @@ import * as SchemaAST from "effect/SchemaAST"
|
|
|
3
3
|
import { type Simplify } from "effect/Struct"
|
|
4
4
|
import type * as Tracer from "effect/Tracer"
|
|
5
5
|
import type { RequiredKeys } from "effect/Types"
|
|
6
|
-
import type { NonEmptyReadonlyArray } from "./Array.
|
|
7
|
-
import { fakerArb } from "./faker.
|
|
8
|
-
import { Email as EmailT, type Email as EmailType } from "./Schema/email.
|
|
9
|
-
import { concurrencyUnbounded, withDefaultMake, withDefaultParseOptions } from "./Schema/ext.
|
|
10
|
-
import { PhoneNumber as PhoneNumberT, type PhoneNumber as PhoneNumberType } from "./Schema/phoneNumber.
|
|
11
|
-
import { type AST } from "./Schema/schema.
|
|
12
|
-
import { copy, extendM, type StructuralCopyOrigin } from "./utils.
|
|
6
|
+
import type { NonEmptyReadonlyArray } from "./Array.ts"
|
|
7
|
+
import { fakerArb } from "./faker.ts"
|
|
8
|
+
import { Email as EmailT, type Email as EmailType } from "./Schema/email.ts"
|
|
9
|
+
import { concurrencyUnbounded, withDefaultMake, withDefaultParseOptions } from "./Schema/ext.ts"
|
|
10
|
+
import { PhoneNumber as PhoneNumberT, type PhoneNumber as PhoneNumberType } from "./Schema/phoneNumber.ts"
|
|
11
|
+
import { type AST } from "./Schema/schema.ts"
|
|
12
|
+
import { copy, extendM, type StructuralCopyOrigin } from "./utils.ts"
|
|
13
13
|
|
|
14
14
|
// ---------------------------------------------------------------------------
|
|
15
15
|
// Default helpers — re-exported from effect/Schema
|
|
@@ -109,23 +109,23 @@ export { withDecodingDefaultTypeKey } from "effect/Schema"
|
|
|
109
109
|
|
|
110
110
|
export * from "effect/Schema"
|
|
111
111
|
|
|
112
|
-
export * from "./Schema/Class.
|
|
113
|
-
export { Class, ErrorClass, Opaque, TaggedClass, TaggedErrorClass } from "./Schema/Class.
|
|
112
|
+
export * from "./Schema/Class.ts"
|
|
113
|
+
export { Class, ErrorClass, Opaque, TaggedClass, TaggedErrorClass } from "./Schema/Class.ts"
|
|
114
114
|
|
|
115
|
-
export { fromBrand, nominal } from "./Schema/brand.
|
|
116
|
-
export { Array, Boolean, Date, DateFromString, DateValid, Finite, Literals, NullOr, Number, ReadonlyMap, ReadonlySet } from "./Schema/ext.
|
|
117
|
-
export { Int, NonNegativeInt } from "./Schema/numbers.
|
|
115
|
+
export { fromBrand, nominal } from "./Schema/brand.ts"
|
|
116
|
+
export { Array, Boolean, Date, DateFromString, DateValid, Finite, Literals, NullOr, Number, ReadonlyMap, ReadonlySet } from "./Schema/ext.ts"
|
|
117
|
+
export { Int, NonNegativeInt } from "./Schema/numbers.ts"
|
|
118
118
|
|
|
119
|
-
export * from "./Schema/email.
|
|
120
|
-
export * from "./Schema/ext.
|
|
121
|
-
export * from "./Schema/moreStrings.
|
|
122
|
-
export * from "./Schema/numbers.
|
|
123
|
-
export * from "./Schema/phoneNumber.
|
|
124
|
-
export * from "./Schema/schema.
|
|
125
|
-
export * from "./Schema/SpecialJsonSchema.
|
|
126
|
-
export * from "./Schema/SpecialOpenApi.
|
|
127
|
-
export * from "./Schema/strings.
|
|
128
|
-
export { NonEmptyString } from "./Schema/strings.
|
|
119
|
+
export * from "./Schema/email.ts"
|
|
120
|
+
export * from "./Schema/ext.ts"
|
|
121
|
+
export * from "./Schema/moreStrings.ts"
|
|
122
|
+
export * from "./Schema/numbers.ts"
|
|
123
|
+
export * from "./Schema/phoneNumber.ts"
|
|
124
|
+
export * from "./Schema/schema.ts"
|
|
125
|
+
export * from "./Schema/SpecialJsonSchema.ts"
|
|
126
|
+
export * from "./Schema/SpecialOpenApi.ts"
|
|
127
|
+
export * from "./Schema/strings.ts"
|
|
128
|
+
export { NonEmptyString } from "./Schema/strings.ts"
|
|
129
129
|
|
|
130
130
|
export * as SchemaIssue from "effect/SchemaIssue"
|
|
131
131
|
|
|
@@ -133,7 +133,7 @@ export const decodeEffectConcurrently: typeof S.decodeEffect = withDefaultParseO
|
|
|
133
133
|
export const decodeUnknownEffectConcurrently: typeof S.decodeUnknownEffect = withDefaultParseOptions(
|
|
134
134
|
S.decodeUnknownEffect
|
|
135
135
|
)
|
|
136
|
-
export * as SchemaParser from "./Schema/SchemaParser.
|
|
136
|
+
export * as SchemaParser from "./Schema/SchemaParser.ts"
|
|
137
137
|
|
|
138
138
|
export { Void as Void_ } from "effect/Schema"
|
|
139
139
|
|
package/src/Set.ts
CHANGED
|
@@ -6,7 +6,7 @@ import * as Option from "effect/Option"
|
|
|
6
6
|
import type * as Order from "effect/Order"
|
|
7
7
|
import { not } from "effect/Predicate"
|
|
8
8
|
import type * as Result from "effect/Result"
|
|
9
|
-
import { identity, pipe, type Predicate, type Refinement, tuple } from "./Function.
|
|
9
|
+
import { identity, pipe, type Predicate, type Refinement, tuple } from "./Function.ts"
|
|
10
10
|
|
|
11
11
|
export function find_<A, B extends A>(
|
|
12
12
|
as: ReadonlySet<A>,
|
package/src/Store.ts
CHANGED
|
@@ -2,17 +2,17 @@
|
|
|
2
2
|
import * as Data from "effect/Data"
|
|
3
3
|
import type * as Redacted from "effect/Redacted"
|
|
4
4
|
import * as Semaphore from "effect/Semaphore"
|
|
5
|
-
import type { NonEmptyReadonlyArray } from "./Array.
|
|
6
|
-
import type { OptimisticConcurrencyException } from "./client/errors.
|
|
7
|
-
import * as Context from "./Context.
|
|
8
|
-
import * as Effect from "./Effect.
|
|
9
|
-
import * as Layer from "./Layer.
|
|
10
|
-
import type { FilterResult } from "./Model/filter/filterApi.
|
|
11
|
-
import type { FieldValues } from "./Model/filter/types.
|
|
12
|
-
import type { FieldPath } from "./Model/filter/types/path/index.
|
|
13
|
-
import type { AggregateIrExpression, ComputedProjectionIrExpression, RawQuery } from "./Model/query.
|
|
14
|
-
import type * as Option from "./Option.
|
|
15
|
-
import { NonEmptyString255 } from "./Schema.
|
|
5
|
+
import type { NonEmptyReadonlyArray } from "./Array.ts"
|
|
6
|
+
import type { DatabaseError, OptimisticConcurrencyException } from "./client/errors.ts"
|
|
7
|
+
import * as Context from "./Context.ts"
|
|
8
|
+
import * as Effect from "./Effect.ts"
|
|
9
|
+
import * as Layer from "./Layer.ts"
|
|
10
|
+
import type { FilterResult } from "./Model/filter/filterApi.ts"
|
|
11
|
+
import type { FieldValues } from "./Model/filter/types.ts"
|
|
12
|
+
import type { FieldPath } from "./Model/filter/types/path/index.ts"
|
|
13
|
+
import type { AggregateIrExpression, ComputedProjectionIrExpression, RawQuery } from "./Model/query.ts"
|
|
14
|
+
import type * as Option from "./Option.ts"
|
|
15
|
+
import { NonEmptyString255 } from "./Schema.ts"
|
|
16
16
|
|
|
17
17
|
/**
|
|
18
18
|
* Adapter-neutral unique-key definition for stores that support unique indexes,
|
|
@@ -99,30 +99,30 @@ export interface FilterArgs<Encoded extends FieldValues, U extends keyof Encoded
|
|
|
99
99
|
|
|
100
100
|
export type FilterFunc<Encoded extends FieldValues> = <U extends keyof Encoded = never>(
|
|
101
101
|
args: FilterArgs<Encoded, U>
|
|
102
|
-
) => Effect.Effect<(U extends undefined ? Encoded : Pick<Encoded, U>)[]>
|
|
102
|
+
) => Effect.Effect<(U extends undefined ? Encoded : Pick<Encoded, U>)[], DatabaseError>
|
|
103
103
|
|
|
104
104
|
export interface Store<
|
|
105
105
|
IdKey extends keyof Encoded,
|
|
106
106
|
Encoded extends FieldValues,
|
|
107
107
|
PM extends PersistenceModelType<Encoded> = PersistenceModelType<Encoded>
|
|
108
108
|
> {
|
|
109
|
-
all: Effect.Effect<PM[]>
|
|
109
|
+
all: Effect.Effect<PM[], DatabaseError>
|
|
110
110
|
filter: FilterFunc<Encoded>
|
|
111
|
-
find: (id: Encoded[IdKey]) => Effect.Effect<Option.Option<PM
|
|
112
|
-
set: (e: PM) => Effect.Effect<PM, OptimisticConcurrencyException>
|
|
111
|
+
find: (id: Encoded[IdKey]) => Effect.Effect<Option.Option<PM>, DatabaseError>
|
|
112
|
+
set: (e: PM) => Effect.Effect<PM, OptimisticConcurrencyException | DatabaseError>
|
|
113
113
|
batchSet: (
|
|
114
114
|
items: NonEmptyReadonlyArray<PM>
|
|
115
|
-
) => Effect.Effect<NonEmptyReadonlyArray<PM>, OptimisticConcurrencyException>
|
|
115
|
+
) => Effect.Effect<NonEmptyReadonlyArray<PM>, OptimisticConcurrencyException | DatabaseError>
|
|
116
116
|
bulkSet: (
|
|
117
117
|
items: NonEmptyReadonlyArray<PM>
|
|
118
|
-
) => Effect.Effect<NonEmptyReadonlyArray<PM>, OptimisticConcurrencyException>
|
|
119
|
-
batchRemove: (ids: NonEmptyReadonlyArray<Encoded[IdKey]>, partitionKey?: string) => Effect.Effect<void>
|
|
120
|
-
queryRaw: <Out>(query: RawQuery<Encoded, Out>) => Effect.Effect<readonly Out[]>
|
|
118
|
+
) => Effect.Effect<NonEmptyReadonlyArray<PM>, OptimisticConcurrencyException | DatabaseError>
|
|
119
|
+
batchRemove: (ids: NonEmptyReadonlyArray<Encoded[IdKey]>, partitionKey?: string) => Effect.Effect<void, DatabaseError>
|
|
120
|
+
queryRaw: <Out>(query: RawQuery<Encoded, Out>) => Effect.Effect<readonly Out[], DatabaseError>
|
|
121
121
|
/**
|
|
122
122
|
* Explicitly seed a namespace. Primary is seeded eagerly on initialization.
|
|
123
123
|
* Non-primary namespaces must be seeded explicitly before use.
|
|
124
124
|
*/
|
|
125
|
-
seedNamespace: (namespace: string) => Effect.Effect<void>
|
|
125
|
+
seedNamespace: (namespace: string) => Effect.Effect<void, DatabaseError>
|
|
126
126
|
}
|
|
127
127
|
|
|
128
128
|
export class StoreMaker extends Context.Opaque<StoreMaker, {
|
package/src/_ext/Array.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as Chunk from "effect-app/Chunk"
|
|
2
2
|
import * as Effect from "effect-app/Effect"
|
|
3
3
|
import * as Equal from "effect/Equal"
|
|
4
|
-
import { NotFoundError } from "../client/errors.
|
|
4
|
+
import { NotFoundError } from "../client/errors.ts"
|
|
5
5
|
|
|
6
6
|
function getFirstBy<A, Type extends string>(
|
|
7
7
|
a: Iterable<A>,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as Ref from "effect/Ref"
|
|
2
|
-
import * as Context from "../Context.
|
|
3
|
-
import * as Effect from "../Effect.
|
|
4
|
-
import type { InvalidationKey } from "../rpc/Invalidation.
|
|
2
|
+
import * as Context from "../Context.ts"
|
|
3
|
+
import * as Effect from "../Effect.ts"
|
|
4
|
+
import type { InvalidationKey } from "../rpc/Invalidation.ts"
|
|
5
5
|
|
|
6
6
|
export type { InvalidationKey }
|
|
7
7
|
/** Shape of the per-mutation service that accumulates server-provided invalidation keys. */
|
|
@@ -8,15 +8,15 @@ import * as Schema from "effect/Schema"
|
|
|
8
8
|
import * as Stream from "effect/Stream"
|
|
9
9
|
import * as Struct from "effect/Struct"
|
|
10
10
|
import { Rpc, RpcClient, RpcGroup, RpcSerialization } from "effect/unstable/rpc"
|
|
11
|
-
import * as Config from "../Config.
|
|
12
|
-
import * as Context from "../Context.
|
|
13
|
-
import * as Effect from "../Effect.
|
|
14
|
-
import { HttpClient, HttpClientRequest } from "../http.
|
|
15
|
-
import { Invalidation } from "../rpc.
|
|
16
|
-
import type * as S from "../Schema.
|
|
17
|
-
import { typedKeysOf, typedValuesOf } from "../utils.
|
|
18
|
-
import type { Client, ClientForOptions, ExtractModuleName, RequestsAny } from "./clientFor.
|
|
19
|
-
import { InvalidationKeysFromServer } from "./InvalidationKeys.
|
|
11
|
+
import * as Config from "../Config.ts"
|
|
12
|
+
import * as Context from "../Context.ts"
|
|
13
|
+
import * as Effect from "../Effect.ts"
|
|
14
|
+
import { HttpClient, HttpClientRequest } from "../http.ts"
|
|
15
|
+
import { Invalidation } from "../rpc.ts"
|
|
16
|
+
import type * as S from "../Schema.ts"
|
|
17
|
+
import { typedKeysOf, typedValuesOf } from "../utils.ts"
|
|
18
|
+
import type { Client, ClientForOptions, ExtractModuleName, RequestsAny } from "./clientFor.ts"
|
|
19
|
+
import { InvalidationKeysFromServer } from "./InvalidationKeys.ts"
|
|
20
20
|
|
|
21
21
|
export interface ApiConfig {
|
|
22
22
|
url: string
|
package/src/client/clientFor.ts
CHANGED
|
@@ -5,9 +5,9 @@ import * as Record from "effect/Record"
|
|
|
5
5
|
import type * as Stream from "effect/Stream"
|
|
6
6
|
import type { Path } from "path-parser"
|
|
7
7
|
import qs from "query-string"
|
|
8
|
-
import type * as Effect from "../Effect.
|
|
9
|
-
import type * as S from "../Schema.
|
|
10
|
-
import { type Req } from "./apiClientFactory.
|
|
8
|
+
import type * as Effect from "../Effect.ts"
|
|
9
|
+
import type * as S from "../Schema.ts"
|
|
10
|
+
import { type Req } from "./apiClientFactory.ts"
|
|
11
11
|
|
|
12
12
|
export function makePathWithQuery(
|
|
13
13
|
path: Path,
|
package/src/client/errors.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/** @effect-diagnostics overriddenSchemaConstructor:skip-file */
|
|
2
2
|
import { TaggedErrorClass } from "effect-app/Schema"
|
|
3
3
|
import * as Cause from "effect/Cause"
|
|
4
|
-
import * as S from "../Schema.
|
|
4
|
+
import * as S from "../Schema.ts"
|
|
5
5
|
|
|
6
6
|
export const tryToJson = (error: unknown) => {
|
|
7
7
|
try {
|
|
@@ -157,6 +157,45 @@ export class OptimisticConcurrencyException extends TaggedErrorClass<OptimisticC
|
|
|
157
157
|
}
|
|
158
158
|
}
|
|
159
159
|
|
|
160
|
+
/**
|
|
161
|
+
* Raised by a store adapter when a database operation fails for an
|
|
162
|
+
* infrastructure reason (request timeout, throttle, 5xx, dropped socket, or any
|
|
163
|
+
* non-conflict error). Distinct from `OptimisticConcurrencyException`, which is
|
|
164
|
+
* an expected etag conflict.
|
|
165
|
+
*
|
|
166
|
+
* `transient` is set by the adapter for failures worth retrying (timeout /
|
|
167
|
+
* throttle / 5xx / network). `cause` is the underlying adapter error, carried
|
|
168
|
+
* through a `Defect` schema so it serializes (an `Error` encodes to
|
|
169
|
+
* `{ name, message, cause }`) instead of breaking JSON encoding of the channel.
|
|
170
|
+
*
|
|
171
|
+
* Treated by the api/client/FE machinery like an unexpected (500-class) error.
|
|
172
|
+
*/
|
|
173
|
+
export class DatabaseError extends TaggedErrorClass<DatabaseError>()(
|
|
174
|
+
"DatabaseError",
|
|
175
|
+
{
|
|
176
|
+
message: S.String,
|
|
177
|
+
transient: S.Boolean,
|
|
178
|
+
cause: S.optional(S.Defect())
|
|
179
|
+
}
|
|
180
|
+
) {
|
|
181
|
+
constructor(
|
|
182
|
+
args: { message?: string; transient?: boolean; cause?: unknown },
|
|
183
|
+
disableValidation?: boolean
|
|
184
|
+
) {
|
|
185
|
+
super(
|
|
186
|
+
{
|
|
187
|
+
message: args.message ?? "Database operation failed",
|
|
188
|
+
transient: args.transient ?? false,
|
|
189
|
+
cause: args.cause
|
|
190
|
+
},
|
|
191
|
+
disableValidation as any
|
|
192
|
+
)
|
|
193
|
+
}
|
|
194
|
+
override toString() {
|
|
195
|
+
return `DatabaseError: ${this.message}`
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
|
|
160
199
|
const MutationOnlyErrors = [
|
|
161
200
|
InvalidStateError,
|
|
162
201
|
OptimisticConcurrencyException
|
|
@@ -168,7 +207,8 @@ const GeneralErrors = [
|
|
|
168
207
|
LoginError,
|
|
169
208
|
UnauthorizedError,
|
|
170
209
|
ValidationError,
|
|
171
|
-
ServiceUnavailableError
|
|
210
|
+
ServiceUnavailableError,
|
|
211
|
+
DatabaseError
|
|
172
212
|
] as const
|
|
173
213
|
|
|
174
214
|
export const SupportedErrors = S.Union([
|
package/src/client/makeClient.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import type * as Exit from "effect/Exit"
|
|
2
2
|
import * as SchemaTransformation from "effect/SchemaTransformation"
|
|
3
|
-
import { type GetContextConfig, type RpcContextMap } from "../rpc/RpcContextMap.
|
|
4
|
-
import * as S from "../Schema.
|
|
5
|
-
import { AST } from "../Schema.
|
|
6
|
-
import type { ClientForOptions } from "./clientFor.
|
|
3
|
+
import { type GetContextConfig, type RpcContextMap } from "../rpc/RpcContextMap.ts"
|
|
4
|
+
import * as S from "../Schema.ts"
|
|
5
|
+
import { AST } from "../Schema.ts"
|
|
6
|
+
import type { ClientForOptions } from "./clientFor.ts"
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
9
|
* Minimal structural shape for an rpc-client middleware tag.
|
package/src/http/Request.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as Option from "effect/Option"
|
|
2
2
|
import type { HttpClientResponse } from "effect/unstable/http/HttpClientResponse"
|
|
3
|
-
import * as Effect from "../Effect.
|
|
4
|
-
import { HttpClient, HttpClientError, HttpClientRequest, HttpHeaders } from "./internal/lib.
|
|
3
|
+
import * as Effect from "../Effect.ts"
|
|
4
|
+
import { HttpClient, HttpClientError, HttpClientRequest, HttpHeaders } from "./internal/lib.ts"
|
|
5
5
|
|
|
6
6
|
export interface ResponseWithBody<A> extends Pick<HttpClientResponse, "headers" | "status" | "remoteAddress"> {
|
|
7
7
|
readonly body: A
|
package/src/http.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export * from "./http/internal/lib.
|
|
1
|
+
export * from "./http/internal/lib.ts"
|
package/src/ids.ts
CHANGED
|
@@ -2,8 +2,8 @@ import { brandedStringId, type Codec, NonEmptyString255, StringId, type StringId
|
|
|
2
2
|
import type { B } from "effect-app/Schema/schema"
|
|
3
3
|
import * as Effect from "effect/Effect"
|
|
4
4
|
import type { Simplify } from "effect/Types"
|
|
5
|
-
import * as S from "./Schema.
|
|
6
|
-
import { extendM } from "./utils.
|
|
5
|
+
import * as S from "./Schema.ts"
|
|
6
|
+
import { extendM } from "./utils.ts"
|
|
7
7
|
|
|
8
8
|
export interface RequestIdBrand extends StringIdBrand {
|
|
9
9
|
readonly RequestId: unique symbol
|
package/src/index.ts
CHANGED
|
@@ -1,27 +1,27 @@
|
|
|
1
1
|
// eslint-disable-next-line import/no-unassigned-import
|
|
2
|
-
import "./builtin.
|
|
2
|
+
import "./builtin.ts"
|
|
3
3
|
|
|
4
|
-
export * as Fnc from "./Function.
|
|
5
|
-
export * as Utils from "./utils.
|
|
4
|
+
export * as Fnc from "./Function.ts"
|
|
5
|
+
export * as Utils from "./utils.ts"
|
|
6
6
|
|
|
7
|
-
export * as Array from "./Array.
|
|
8
|
-
export * as Config from "./Config.
|
|
9
|
-
export * as ConfigProvider from "./ConfigProvider.
|
|
10
|
-
export * as Context from "./Context.
|
|
11
|
-
export * as Effect from "./Effect.
|
|
12
|
-
export * as Layer from "./Layer.
|
|
13
|
-
export * as Model from "./Model.
|
|
14
|
-
export * as NonEmptySet from "./NonEmptySet.
|
|
15
|
-
export * as Set from "./Set.
|
|
16
|
-
export * as Store from "./Store.
|
|
7
|
+
export * as Array from "./Array.ts"
|
|
8
|
+
export * as Config from "./Config.ts"
|
|
9
|
+
export * as ConfigProvider from "./ConfigProvider.ts"
|
|
10
|
+
export * as Context from "./Context.ts"
|
|
11
|
+
export * as Effect from "./Effect.ts"
|
|
12
|
+
export * as Layer from "./Layer.ts"
|
|
13
|
+
export * as Model from "./Model.ts"
|
|
14
|
+
export * as NonEmptySet from "./NonEmptySet.ts"
|
|
15
|
+
export * as Set from "./Set.ts"
|
|
16
|
+
export * as Store from "./Store.ts"
|
|
17
17
|
|
|
18
|
-
export { type NonEmptyArray, type NonEmptyReadonlyArray } from "./Array.
|
|
18
|
+
export { type NonEmptyArray, type NonEmptyReadonlyArray } from "./Array.ts"
|
|
19
19
|
|
|
20
20
|
export * from "effect"
|
|
21
21
|
|
|
22
|
-
export type * as Types from "./Types.
|
|
22
|
+
export type * as Types from "./Types.ts"
|
|
23
23
|
|
|
24
|
-
export * as SecretURL from "./Config/SecretURL.
|
|
25
|
-
export * as RpcX from "./rpc.
|
|
26
|
-
export * as S from "./Schema.
|
|
27
|
-
export { copy } from "./utils.
|
|
24
|
+
export * as SecretURL from "./Config/SecretURL.ts"
|
|
25
|
+
export * as RpcX from "./rpc.ts"
|
|
26
|
+
export * as S from "./Schema.ts"
|
|
27
|
+
export { copy } from "./utils.ts"
|
package/src/middleware.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
2
2
|
import * as Context from "effect-app/Context"
|
|
3
|
-
import { RpcMiddleware } from "./rpc.
|
|
3
|
+
import { RpcMiddleware } from "./rpc.ts"
|
|
4
4
|
|
|
5
5
|
export class DevMode extends Context.Reference("DevMode", { defaultValue: () => false }) {}
|
|
6
6
|
|
package/src/rpc/Invalidation.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import * as Ref from "effect/Ref"
|
|
2
2
|
import { Rpc } from "effect/unstable/rpc"
|
|
3
|
-
import { type ClientForOptions, makeQueryKey } from "../client/clientFor.
|
|
4
|
-
import * as Context from "../Context.
|
|
5
|
-
import * as Effect from "../Effect.
|
|
6
|
-
import * as S from "../Schema.
|
|
3
|
+
import { type ClientForOptions, makeQueryKey } from "../client/clientFor.ts"
|
|
4
|
+
import * as Context from "../Context.ts"
|
|
5
|
+
import * as Effect from "../Effect.ts"
|
|
6
|
+
import * as S from "../Schema.ts"
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
9
|
* Shorthand for a handler-derived invalidation key.
|
|
@@ -111,7 +111,7 @@ export type StreamFailureChunk<E> = { readonly _tag: "error"; readonly error: E;
|
|
|
111
111
|
* ```ts
|
|
112
112
|
* import { makeQueryKey } from "effect-app/client"
|
|
113
113
|
* import { Invalidation } from "effect-app/rpc"
|
|
114
|
-
* import * as UserRsc from "../User/index.
|
|
114
|
+
* import * as UserRsc from "../User/index.ts" // separate module to avoid circular deps
|
|
115
115
|
*
|
|
116
116
|
* class UpdateProfile extends Rpc.make("UpdateProfile", { ... })
|
|
117
117
|
* .annotate(Invalidation.Invalidates, [makeQueryKey(UserRsc.GetMe), makeQueryKey(UserRsc.GetProfile)]) {}
|
|
@@ -160,8 +160,8 @@ export interface InvalidationSetService {
|
|
|
160
160
|
* ```ts
|
|
161
161
|
* import * as Effect from "effect/Effect"
|
|
162
162
|
* import { Invalidation } from "effect-app/rpc"
|
|
163
|
-
* import * as CartRsc from "../Cart/queries.
|
|
164
|
-
* import * as UserRsc from "../User/queries.
|
|
163
|
+
* import * as CartRsc from "../Cart/queries.ts"
|
|
164
|
+
* import * as UserRsc from "../User/queries.ts"
|
|
165
165
|
*
|
|
166
166
|
* const handler = Effect.fnUntraced(function*(req: UpdateCartRequest) {
|
|
167
167
|
* const cart = yield* CartRepo.save(req.cart)
|
|
@@ -7,12 +7,12 @@ import type * as Scope from "effect/Scope"
|
|
|
7
7
|
import { type Simplify } from "effect/Types"
|
|
8
8
|
import { Rpc, type RpcGroup, type RpcSchema } from "effect/unstable/rpc"
|
|
9
9
|
import { type HandlersFrom } from "effect/unstable/rpc/RpcGroup"
|
|
10
|
-
import * as Context from "../Context.
|
|
11
|
-
import { PreludeLogger } from "../logger.
|
|
12
|
-
import { type TypeTestId } from "../TypeTest.
|
|
13
|
-
import { type GetContextConfig, type RequestContextMapTagAny, type RpcContextMap } from "./RpcContextMap.
|
|
14
|
-
import { type AddMiddleware, type AnyDynamic, type RpcDynamic, type RpcMiddlewareV4, type TagClassAny } from "./RpcMiddleware.
|
|
15
|
-
import * as RpcMiddlewareX from "./RpcMiddleware.
|
|
10
|
+
import * as Context from "../Context.ts"
|
|
11
|
+
import { PreludeLogger } from "../logger.ts"
|
|
12
|
+
import { type TypeTestId } from "../TypeTest.ts"
|
|
13
|
+
import { type GetContextConfig, type RequestContextMapTagAny, type RpcContextMap } from "./RpcContextMap.ts"
|
|
14
|
+
import { type AddMiddleware, type AnyDynamic, type RpcDynamic, type RpcMiddlewareV4, type TagClassAny } from "./RpcMiddleware.ts"
|
|
15
|
+
import * as RpcMiddlewareX from "./RpcMiddleware.ts"
|
|
16
16
|
|
|
17
17
|
// adapter for effect/rpc v3 middleware provides. (in effect-smol (v4), it's just a Service Identifier, no tags.)
|
|
18
18
|
// hm?
|
package/src/rpc/RpcContextMap.ts
CHANGED
|
@@ -4,8 +4,8 @@
|
|
|
4
4
|
|
|
5
5
|
import type * as S from "effect/Schema"
|
|
6
6
|
import { type AnyWithProps } from "effect/unstable/rpc/Rpc"
|
|
7
|
-
import * as Context from "../Context.
|
|
8
|
-
import { type RpcDynamic } from "./RpcMiddleware.
|
|
7
|
+
import * as Context from "../Context.ts"
|
|
8
|
+
import { type RpcDynamic } from "./RpcMiddleware.ts"
|
|
9
9
|
|
|
10
10
|
type Values<T extends Record<any, any>> = T[keyof T]
|
|
11
11
|
|
package/src/rpc/RpcMiddleware.ts
CHANGED
|
@@ -8,8 +8,8 @@ import type * as Scope from "effect/Scope"
|
|
|
8
8
|
import type * as Stream from "effect/Stream"
|
|
9
9
|
import { type Rpc, RpcMiddleware } from "effect/unstable/rpc"
|
|
10
10
|
import { type TypeId } from "effect/unstable/rpc/RpcMiddleware"
|
|
11
|
-
import type * as Context from "../Context.
|
|
12
|
-
import { type GetEffectContext, type RpcContextMap } from "./RpcContextMap.
|
|
11
|
+
import type * as Context from "../Context.ts"
|
|
12
|
+
import { type GetEffectContext, type RpcContextMap } from "./RpcContextMap.ts"
|
|
13
13
|
|
|
14
14
|
export type RpcMiddlewareV4<Provides, E, Requires> = RpcMiddleware.RpcMiddleware<Provides, E, Requires>
|
|
15
15
|
|
package/src/rpc.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export * as Invalidation from "./rpc/Invalidation.
|
|
2
|
-
export * as MiddlewareMaker from "./rpc/MiddlewareMaker.
|
|
3
|
-
export * as RpcContextMap from "./rpc/RpcContextMap.
|
|
4
|
-
export * as RpcMiddleware from "./rpc/RpcMiddleware.
|
|
1
|
+
export * as Invalidation from "./rpc/Invalidation.ts"
|
|
2
|
+
export * as MiddlewareMaker from "./rpc/MiddlewareMaker.ts"
|
|
3
|
+
export * as RpcContextMap from "./rpc/RpcContextMap.ts"
|
|
4
|
+
export * as RpcMiddleware from "./rpc/RpcMiddleware.ts"
|
package/src/runtime.ts
CHANGED
|
@@ -2,10 +2,10 @@ import * as Exit from "effect/Exit"
|
|
|
2
2
|
import { flow } from "effect/Function"
|
|
3
3
|
import * as Logger from "effect/Logger"
|
|
4
4
|
import * as ManagedRuntime from "effect/ManagedRuntime"
|
|
5
|
-
import { CauseException } from "./client/errors.
|
|
6
|
-
import { type Context } from "./Context.
|
|
7
|
-
import * as Effect from "./Effect.
|
|
8
|
-
import * as Layer from "./Layer.
|
|
5
|
+
import { CauseException } from "./client/errors.ts"
|
|
6
|
+
import { type Context } from "./Context.ts"
|
|
7
|
+
import * as Effect from "./Effect.ts"
|
|
8
|
+
import * as Layer from "./Layer.ts"
|
|
9
9
|
|
|
10
10
|
export const makeAppRuntime = Effect.fnUntraced(function*<A, E>(layer: Layer.Layer<A, E>) {
|
|
11
11
|
const l = layer.pipe(
|
package/src/setupRequest.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import * as Tracer from "effect/Tracer"
|
|
2
2
|
import { SqlClient } from "effect/unstable/sql"
|
|
3
|
-
import * as Effect from "./Effect.
|
|
4
|
-
import * as Layer from "./Layer.
|
|
5
|
-
import * as Option from "./Option.
|
|
6
|
-
import { LocaleRef, RequestContext, spanAttributes } from "./RequestContext.
|
|
7
|
-
import { NonEmptyString255 } from "./Schema.
|
|
8
|
-
import { ContextMapContainer, storeId } from "./Store.
|
|
3
|
+
import * as Effect from "./Effect.ts"
|
|
4
|
+
import * as Layer from "./Layer.ts"
|
|
5
|
+
import * as Option from "./Option.ts"
|
|
6
|
+
import { LocaleRef, RequestContext, spanAttributes } from "./RequestContext.ts"
|
|
7
|
+
import { NonEmptyString255 } from "./Schema.ts"
|
|
8
|
+
import { ContextMapContainer, storeId } from "./Store.ts"
|
|
9
9
|
|
|
10
10
|
const withSqlTransaction = <R, E, A>(self: Effect.Effect<A, E, R>): Effect.Effect<A, E, R> =>
|
|
11
11
|
Effect.serviceOption(SqlClient.SqlClient).pipe(
|
package/src/toast.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import * as Context from "./Context.
|
|
2
|
-
import { accessEffectFn } from "./Context.
|
|
3
|
-
import * as Effect from "./Effect.
|
|
4
|
-
import * as Option from "./Option.
|
|
1
|
+
import * as Context from "./Context.ts"
|
|
2
|
+
import { accessEffectFn } from "./Context.ts"
|
|
3
|
+
import * as Effect from "./Effect.ts"
|
|
4
|
+
import * as Option from "./Option.ts"
|
|
5
5
|
|
|
6
6
|
export type ToastId = string | number
|
|
7
7
|
export type ToastOpts = { id?: ToastId; timeout?: number; groupId?: string; requestId?: string }
|
package/src/transform.ts
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import type { NonEmptyReadonlyArray } from "effect/Array"
|
|
3
3
|
import * as Option from "effect/Option"
|
|
4
4
|
import type { Misc, Union } from "ts-toolbelt"
|
|
5
|
-
import type * as SET from "./Set.
|
|
5
|
+
import type * as SET from "./Set.ts"
|
|
6
6
|
|
|
7
7
|
// type SomeObject = {
|
|
8
8
|
// 0: Option.Option<string>
|
package/src/utils/logger.ts
CHANGED
package/src/utils.ts
CHANGED
|
@@ -10,8 +10,8 @@ import * as Option from "effect/Option"
|
|
|
10
10
|
import { isFunction } from "effect/Predicate"
|
|
11
11
|
import * as Record from "effect/Record"
|
|
12
12
|
import * as Result from "effect/Result"
|
|
13
|
-
import { identity, pipe } from "./Function.
|
|
14
|
-
import type { DeepMutable, Equals, Mutable } from "./Types.
|
|
13
|
+
import { identity, pipe } from "./Function.ts"
|
|
14
|
+
import type { DeepMutable, Equals, Mutable } from "./Types.ts"
|
|
15
15
|
|
|
16
16
|
// codegen:start {preset: barrel, include: ./utils/*.ts, nodir: false }
|
|
17
17
|
export * from "./utils/effectify.ts"
|
package/src/validation.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Predicate } from "./Function.
|
|
1
|
+
import type { Predicate } from "./Function.ts"
|
|
2
2
|
|
|
3
3
|
export const all_ = <T>(v: T, ...a: Predicate<T>[]) => !a.some((x) => !x(v))
|
|
4
4
|
export const all = <T>(...a: Predicate<T>[]) => (v: T) => all_(v, ...a)
|
|
@@ -15,4 +15,4 @@ export const min = (min: number) => {
|
|
|
15
15
|
return (v: { length: number }) => f(v.length)
|
|
16
16
|
}
|
|
17
17
|
|
|
18
|
-
export * from "./validation/validators.
|
|
18
|
+
export * from "./validation/validators.ts"
|
package/src/withToast.ts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import * as Cause from "effect/Cause"
|
|
2
2
|
import * as Fiber from "effect/Fiber"
|
|
3
|
-
import * as Context from "./Context.
|
|
4
|
-
import * as Effect from "./Effect.
|
|
5
|
-
import * as Layer from "./Layer.
|
|
6
|
-
import type * as Option from "./Option.
|
|
7
|
-
import * as S from "./Schema.
|
|
8
|
-
import { CurrentToastId, Toast, type ToastId } from "./toast.
|
|
9
|
-
import { wrapEffect } from "./utils.
|
|
3
|
+
import * as Context from "./Context.ts"
|
|
4
|
+
import * as Effect from "./Effect.ts"
|
|
5
|
+
import * as Layer from "./Layer.ts"
|
|
6
|
+
import type * as Option from "./Option.ts"
|
|
7
|
+
import * as S from "./Schema.ts"
|
|
8
|
+
import { CurrentToastId, Toast, type ToastId } from "./toast.ts"
|
|
9
|
+
import { wrapEffect } from "./utils.ts"
|
|
10
10
|
|
|
11
11
|
export interface ToastOptions<A, E, Args extends ReadonlyArray<unknown>, WaiR, SucR, ErrR> {
|
|
12
12
|
stableToastId?: undefined | string | ((...args: Args) => string | undefined)
|