effect-app 4.0.0-beta.230 → 4.0.0-beta.232
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 +21 -0
- package/dist/Context.d.ts +2 -3
- package/dist/Context.d.ts.map +1 -1
- package/dist/Context.js +1 -1
- package/dist/Effect.d.ts +1 -1
- package/dist/Effect.d.ts.map +1 -1
- package/dist/Effect.js +2 -3
- package/dist/Layer.d.ts +2 -3
- package/dist/Layer.d.ts.map +1 -1
- package/dist/Layer.js +1 -1
- package/dist/Schema/ext.d.ts +17 -17
- package/dist/Schema/ext.d.ts.map +1 -1
- package/dist/Schema/ext.js +19 -12
- package/dist/client/apiClientFactory.js +2 -2
- package/dist/client/errors.d.ts +1 -1
- package/dist/rpc/Invalidation.d.ts +49 -49
- package/dist/utils/gen.d.ts +5 -5
- package/dist/utils/gen.d.ts.map +1 -1
- package/package.json +2 -2
- package/src/Context.ts +1 -4
- package/src/Effect.ts +1 -2
- package/src/Layer.ts +1 -2
- package/src/Schema/ext.ts +21 -10
- package/src/client/apiClientFactory.ts +1 -1
- package/src/utils/gen.ts +7 -7
- package/test/schema.test.ts +6 -6
package/src/Schema/ext.ts
CHANGED
|
@@ -56,7 +56,6 @@ const concurrencySetting = Effect.runSync(
|
|
|
56
56
|
Config
|
|
57
57
|
.literal("unbounded", "SCHEMA_CONCURRENCY")
|
|
58
58
|
.pipe(Config.orElse(() => Config.number("SCHEMA_CONCURRENCY")), Config.option)
|
|
59
|
-
.asEffect()
|
|
60
59
|
)
|
|
61
60
|
|
|
62
61
|
export const DefaultParseOptions: SchemaAST.ParseOptions = {
|
|
@@ -86,8 +85,8 @@ export const withDefaultParseOptions = <Decode extends DecodeLike>(
|
|
|
86
85
|
// TODO: v4 migration - Date is no longer by default encoded to string.
|
|
87
86
|
|
|
88
87
|
const DateString = S.String.annotate({
|
|
89
|
-
identifier: "
|
|
90
|
-
description: "
|
|
88
|
+
identifier: "DateOrInvalid",
|
|
89
|
+
description: "an ISO 8601 date string that will be decoded as a Date (may be invalid)",
|
|
91
90
|
format: "date-time"
|
|
92
91
|
})
|
|
93
92
|
|
|
@@ -113,13 +112,13 @@ export interface DateFromString extends S.decodeTo<S.Date, S.String> {}
|
|
|
113
112
|
export const DateFromString: DateFromString = DateString.pipe(S.decodeTo(S.Date, SchemaTransformation.dateFromString))
|
|
114
113
|
|
|
115
114
|
/** Like the default Schema `Date` but from String, with default helpers. */
|
|
116
|
-
export const Date =
|
|
115
|
+
export const Date = extendM(DateFromString, (s) => ({
|
|
117
116
|
/**
|
|
118
117
|
* Construction-only default `new Date()`. Applied only when the field is
|
|
119
118
|
* omitted from `.make(...)` input. NOT applied during decode — cannot be
|
|
120
119
|
* used to JIT-migrate database fields. See file-level note.
|
|
121
120
|
*/
|
|
122
|
-
withConstructorDefault:
|
|
121
|
+
withConstructorDefault: s.pipe(S.withConstructorDefault(Effect.sync(() => new global.Date()))),
|
|
123
122
|
/**
|
|
124
123
|
* Decode-time default `new Date()`. **Discouraged for persisted data:** a
|
|
125
124
|
* missing field may be data corruption, not an old-shape document; silently
|
|
@@ -127,17 +126,29 @@ export const Date = Object.assign(DateFromString, {
|
|
|
127
126
|
* preferably versioned migration over a decode-time fallback. See
|
|
128
127
|
* file-level note.
|
|
129
128
|
*/
|
|
130
|
-
withDecodingDefaultType:
|
|
129
|
+
withDecodingDefaultType: s.pipe(S.withDecodingDefaultType(Effect.sync(() => new global.Date())))
|
|
130
|
+
}))
|
|
131
|
+
|
|
132
|
+
const DateValidString = S.String.annotate({
|
|
133
|
+
identifier: "Date",
|
|
134
|
+
description: "a valid ISO 8601 date string that will be decoded as a Date",
|
|
135
|
+
format: "date-time"
|
|
131
136
|
})
|
|
132
137
|
|
|
138
|
+
const DateValidFromString = DateValidString
|
|
139
|
+
.pipe(
|
|
140
|
+
S.decodeTo(S.Date, SchemaTransformation.dateFromString)
|
|
141
|
+
)
|
|
142
|
+
.check(isDateValid())
|
|
143
|
+
|
|
133
144
|
/** Like the default Schema `DateValid` but from String, with default helpers. */
|
|
134
|
-
export const DateValid =
|
|
145
|
+
export const DateValid = extendM(DateValidFromString, (s) => ({
|
|
135
146
|
/**
|
|
136
147
|
* Construction-only default `new Date()`. Applied only when the field is
|
|
137
148
|
* omitted from `.make(...)` input. NOT applied during decode — cannot be
|
|
138
149
|
* used to JIT-migrate database fields. See file-level note.
|
|
139
150
|
*/
|
|
140
|
-
withConstructorDefault:
|
|
151
|
+
withConstructorDefault: s.pipe(S.withConstructorDefault(Effect.sync(() => new global.Date()))),
|
|
141
152
|
/**
|
|
142
153
|
* Decode-time default `new Date()`. **Discouraged for persisted data:** a
|
|
143
154
|
* missing field may be data corruption, not an old-shape document; silently
|
|
@@ -145,8 +156,8 @@ export const DateValid = Object.assign(Date.check(isDateValid()), {
|
|
|
145
156
|
* preferably versioned migration over a decode-time fallback. See
|
|
146
157
|
* file-level note.
|
|
147
158
|
*/
|
|
148
|
-
withDecodingDefaultType:
|
|
149
|
-
})
|
|
159
|
+
withDecodingDefaultType: s.pipe(S.withDecodingDefaultType(Effect.sync(() => new global.Date())))
|
|
160
|
+
}))
|
|
150
161
|
|
|
151
162
|
/** Like the default Schema `Boolean` but with default helpers. */
|
|
152
163
|
export const Boolean = Object.assign(S.Boolean, {
|
|
@@ -65,7 +65,7 @@ export const HttpClientLayer = (config: ApiConfig) =>
|
|
|
65
65
|
HttpClientRequest.setHeaders(config.headers.pipe(Option.getOrElse(() => ({}))))
|
|
66
66
|
),
|
|
67
67
|
HttpClient.mapRequestEffect((req) =>
|
|
68
|
-
Effect.map(RequestName
|
|
68
|
+
Effect.map(RequestName, (ctx) =>
|
|
69
69
|
flow(
|
|
70
70
|
HttpClientRequest.appendUrlParam("action", ctx.requestName),
|
|
71
71
|
HttpClientRequest.appendUrl("/" + ctx.moduleName)
|
package/src/utils/gen.ts
CHANGED
|
@@ -1,24 +1,24 @@
|
|
|
1
|
-
import { type Effect
|
|
1
|
+
import { type Effect } from "effect/Effect"
|
|
2
2
|
|
|
3
3
|
export namespace EffectGenUtils {
|
|
4
4
|
export type Success<EG> = EG extends Effect<infer A, infer _E, infer _R> ? A
|
|
5
5
|
// there could be a case where the generator function does not yield anything, so we need to handle that
|
|
6
6
|
: EG extends (..._: infer _3) => Generator<never, infer A, infer _2> ? A
|
|
7
|
-
//
|
|
8
|
-
: EG extends (..._: infer _3) => Generator<
|
|
7
|
+
// generators yield Effect values
|
|
8
|
+
: EG extends (..._: infer _3) => Generator<Effect<any, infer _E, infer _R>, infer A, infer _2> ? A
|
|
9
9
|
: never
|
|
10
10
|
|
|
11
11
|
export type Error<EG> = EG extends Effect<infer _A, infer E, infer _R> ? E
|
|
12
12
|
// there could be a case where the generator function does not yield anything, so we need to handle that
|
|
13
13
|
: EG extends (..._: infer _3) => Generator<never, infer _A, infer _2> ? never
|
|
14
|
-
//
|
|
15
|
-
: EG extends (..._: infer _3) => Generator<
|
|
14
|
+
// generators yield Effect values
|
|
15
|
+
: EG extends (..._: infer _3) => Generator<Effect<any, infer E, infer _R>, infer _A, infer _2> ? E
|
|
16
16
|
: never
|
|
17
17
|
|
|
18
18
|
export type Context<EG> = EG extends Effect<infer _A, infer _E, infer R> ? R
|
|
19
19
|
// there could be a case where the generator function does not yield anything, so we need to handle that
|
|
20
20
|
: EG extends (..._: infer _3) => Generator<never, infer _A, infer _2> ? never
|
|
21
|
-
//
|
|
22
|
-
: EG extends (..._: infer _3) => Generator<
|
|
21
|
+
// generators yield Effect values
|
|
22
|
+
: EG extends (..._: infer _3) => Generator<Effect<any, infer _E, infer R>, infer _A, infer _2> ? R
|
|
23
23
|
: never
|
|
24
24
|
}
|
package/test/schema.test.ts
CHANGED
|
@@ -461,22 +461,22 @@ describe("JSON Schema", () => {
|
|
|
461
461
|
})
|
|
462
462
|
})
|
|
463
463
|
|
|
464
|
-
test("Date has
|
|
464
|
+
test("Date has identifier DateOrInvalid and ISO 8601 description", () => {
|
|
465
465
|
const doc = S.toJsonSchemaDocument(S.Date)
|
|
466
466
|
expect(doc).toStrictEqual({
|
|
467
467
|
dialect: "draft-2020-12",
|
|
468
|
-
schema: { "$ref": "#/$defs/
|
|
468
|
+
schema: { "$ref": "#/$defs/DateOrInvalid" },
|
|
469
469
|
definitions: {
|
|
470
|
-
|
|
470
|
+
DateOrInvalid: {
|
|
471
471
|
type: "string",
|
|
472
|
-
description: "
|
|
472
|
+
description: "an ISO 8601 date string that will be decoded as a Date (may be invalid)",
|
|
473
473
|
format: "date-time"
|
|
474
474
|
}
|
|
475
475
|
}
|
|
476
476
|
})
|
|
477
477
|
})
|
|
478
478
|
|
|
479
|
-
test("DateValid has
|
|
479
|
+
test("DateValid has identifier Date and ISO 8601 description", () => {
|
|
480
480
|
const doc = S.toJsonSchemaDocument(S.DateValid)
|
|
481
481
|
expect(doc).toStrictEqual({
|
|
482
482
|
dialect: "draft-2020-12",
|
|
@@ -484,7 +484,7 @@ describe("JSON Schema", () => {
|
|
|
484
484
|
definitions: {
|
|
485
485
|
Date: {
|
|
486
486
|
type: "string",
|
|
487
|
-
description: "a
|
|
487
|
+
description: "a valid ISO 8601 date string that will be decoded as a Date",
|
|
488
488
|
format: "date-time"
|
|
489
489
|
}
|
|
490
490
|
}
|