effect-app 0.152.0
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/.eslintrc.cjs +11 -0
- package/.prettierignore +6 -0
- package/CHANGELOG.md +4106 -0
- package/_cjs/Config/SecretURL.cjs +58 -0
- package/_cjs/Config/SecretURL.cjs.map +1 -0
- package/_cjs/Config/internal/configSecretURL.cjs +88 -0
- package/_cjs/Config/internal/configSecretURL.cjs.map +1 -0
- package/_cjs/Inputify.type.cjs +6 -0
- package/_cjs/Inputify.type.cjs.map +1 -0
- package/_cjs/Operations.cjs +76 -0
- package/_cjs/Operations.cjs.map +1 -0
- package/_cjs/Pure.cjs +201 -0
- package/_cjs/Pure.cjs.map +1 -0
- package/_cjs/Request.cjs +76 -0
- package/_cjs/Request.cjs.map +1 -0
- package/_cjs/Widen.type.cjs +6 -0
- package/_cjs/Widen.type.cjs.map +1 -0
- package/_cjs/_ext/date.cjs +64 -0
- package/_cjs/_ext/date.cjs.map +1 -0
- package/_cjs/_ext/misc.cjs +121 -0
- package/_cjs/_ext/misc.cjs.map +1 -0
- package/_cjs/_global.cjs +24 -0
- package/_cjs/_global.cjs.map +1 -0
- package/_cjs/_global.ext.cjs +5 -0
- package/_cjs/_global.ext.cjs.map +1 -0
- package/_cjs/_global.schema.cjs +4 -0
- package/_cjs/_global.schema.cjs.map +1 -0
- package/_cjs/client/QueryResult.cjs +116 -0
- package/_cjs/client/QueryResult.cjs.map +1 -0
- package/_cjs/client/clientFor.cjs +159 -0
- package/_cjs/client/clientFor.cjs.map +1 -0
- package/_cjs/client/config.cjs +21 -0
- package/_cjs/client/config.cjs.map +1 -0
- package/_cjs/client/errors.cjs +116 -0
- package/_cjs/client/errors.cjs.map +1 -0
- package/_cjs/client/fetch.cjs +178 -0
- package/_cjs/client/fetch.cjs.map +1 -0
- package/_cjs/client.cjs +61 -0
- package/_cjs/client.cjs.map +1 -0
- package/_cjs/faker.cjs +31 -0
- package/_cjs/faker.cjs.map +1 -0
- package/_cjs/ids.cjs +24 -0
- package/_cjs/ids.cjs.map +1 -0
- package/_cjs/index.cjs +27 -0
- package/_cjs/index.cjs.map +1 -0
- package/_cjs/refinements.cjs +97 -0
- package/_cjs/refinements.cjs.map +1 -0
- package/_cjs/schema.cjs +50 -0
- package/_cjs/schema.cjs.map +1 -0
- package/_cjs/schema.test.cjs +9 -0
- package/_cjs/schema.test.cjs.map +1 -0
- package/_cjs/service.cjs +97 -0
- package/_cjs/service.cjs.map +1 -0
- package/_cjs/utils.cjs +17 -0
- package/_cjs/utils.cjs.map +1 -0
- package/_src/Config/SecretURL.ts +103 -0
- package/_src/Config/internal/configSecretURL.ts +85 -0
- package/_src/Inputify.type.ts +13 -0
- package/_src/Operations.ts +70 -0
- package/_src/Pure.ts +525 -0
- package/_src/Request.ts +106 -0
- package/_src/Widen.type.ts +28 -0
- package/_src/_ext/date.ts +84 -0
- package/_src/_ext/misc.ts +161 -0
- package/_src/_global/stm.ts.bak +35 -0
- package/_src/_global.ext.ts +3 -0
- package/_src/_global.schema.ts +106 -0
- package/_src/_global.ts +119 -0
- package/_src/client/QueryResult.ts +120 -0
- package/_src/client/clientFor.ts +260 -0
- package/_src/client/config.ts +13 -0
- package/_src/client/errors.ts +129 -0
- package/_src/client/fetch.ts +253 -0
- package/_src/client.ts +7 -0
- package/_src/faker.ts +32 -0
- package/_src/ids.ts +35 -0
- package/_src/index.ts +4 -0
- package/_src/refinements.ts +92 -0
- package/_src/schema/_schema.ts.bak +208 -0
- package/_src/schema/api/date.ts.bak +78 -0
- package/_src/schema/api.ts.bak +20 -0
- package/_src/schema/overrides.ts.bak +76 -0
- package/_src/schema/shared.ts.bak +334 -0
- package/_src/schema.test.ts +3 -0
- package/_src/schema.ts +37 -0
- package/_src/service.ts +119 -0
- package/_src/utils.ts +1 -0
- package/dist/Config/SecretURL.d.ts +82 -0
- package/dist/Config/SecretURL.d.ts.map +1 -0
- package/dist/Config/SecretURL.js +49 -0
- package/dist/Config/internal/configSecretURL.d.ts +24 -0
- package/dist/Config/internal/configSecretURL.d.ts.map +1 -0
- package/dist/Config/internal/configSecretURL.js +75 -0
- package/dist/Inputify.type.d.ts +10 -0
- package/dist/Inputify.type.d.ts.map +1 -0
- package/dist/Inputify.type.js +2 -0
- package/dist/Operations.d.ts +170 -0
- package/dist/Operations.d.ts.map +1 -0
- package/dist/Operations.js +87 -0
- package/dist/Pure.d.ts +169 -0
- package/dist/Pure.d.ts.map +1 -0
- package/dist/Pure.js +167 -0
- package/dist/Request.d.ts +49 -0
- package/dist/Request.d.ts.map +1 -0
- package/dist/Request.js +58 -0
- package/dist/Widen.type.d.ts +19 -0
- package/dist/Widen.type.d.ts.map +1 -0
- package/dist/Widen.type.js +2 -0
- package/dist/_ext/date.d.ts +71 -0
- package/dist/_ext/date.d.ts.map +1 -0
- package/dist/_ext/date.js +58 -0
- package/dist/_ext/misc.d.ts +77 -0
- package/dist/_ext/misc.d.ts.map +1 -0
- package/dist/_ext/misc.js +98 -0
- package/dist/_global.d.ts +70 -0
- package/dist/_global.d.ts.map +1 -0
- package/dist/_global.ext.d.ts +3 -0
- package/dist/_global.ext.d.ts.map +1 -0
- package/dist/_global.ext.js +4 -0
- package/dist/_global.js +76 -0
- package/dist/_global.schema.d.ts +6 -0
- package/dist/_global.schema.d.ts.map +1 -0
- package/dist/_global.schema.js +6 -0
- package/dist/client/QueryResult.d.ts +85 -0
- package/dist/client/QueryResult.d.ts.map +1 -0
- package/dist/client/QueryResult.js +85 -0
- package/dist/client/clientFor.d.ts +44 -0
- package/dist/client/clientFor.d.ts.map +1 -0
- package/dist/client/clientFor.js +144 -0
- package/dist/client/config.d.ts +14 -0
- package/dist/client/config.d.ts.map +1 -0
- package/dist/client/config.js +11 -0
- package/dist/client/errors.d.ts +206 -0
- package/dist/client/errors.d.ts.map +1 -0
- package/dist/client/errors.js +130 -0
- package/dist/client/fetch.d.ts +61 -0
- package/dist/client/fetch.d.ts.map +1 -0
- package/dist/client/fetch.js +127 -0
- package/dist/client.d.ts +6 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/client.js +7 -0
- package/dist/faker.d.ts +7 -0
- package/dist/faker.d.ts.map +1 -0
- package/dist/faker.js +24 -0
- package/dist/ids.d.ts +32 -0
- package/dist/ids.d.ts.map +1 -0
- package/dist/ids.js +17 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +4 -0
- package/dist/refinements.d.ts +57 -0
- package/dist/refinements.d.ts.map +1 -0
- package/dist/refinements.js +85 -0
- package/dist/schema.d.ts +7 -0
- package/dist/schema.d.ts.map +1 -0
- package/dist/schema.js +22 -0
- package/dist/schema.test.d.ts.map +1 -0
- package/dist/service.d.ts +47 -0
- package/dist/service.d.ts.map +1 -0
- package/dist/service.js +83 -0
- package/dist/utils.d.ts +2 -0
- package/dist/utils.d.ts.map +1 -0
- package/dist/utils.js +2 -0
- package/package.json +315 -0
- package/tsconfig.json +114 -0
- package/tsconfig.json.bak +47 -0
- package/tsplus.config.json +7 -0
- package/vitest.config.ts +5 -0
- package/wallaby.cjs +1 -0
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import {
|
|
2
|
+
addDays,
|
|
3
|
+
addHours,
|
|
4
|
+
addMinutes,
|
|
5
|
+
addMonths,
|
|
6
|
+
addSeconds,
|
|
7
|
+
addWeeks,
|
|
8
|
+
addYears,
|
|
9
|
+
subDays,
|
|
10
|
+
subHours,
|
|
11
|
+
subMinutes,
|
|
12
|
+
subMonths,
|
|
13
|
+
subSeconds,
|
|
14
|
+
subWeeks,
|
|
15
|
+
subYears
|
|
16
|
+
} from "date-fns"
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* @tsplus fluent Date addDays
|
|
20
|
+
*/
|
|
21
|
+
export const DateAddDays: (date: Date, amount: number) => Date = addDays
|
|
22
|
+
/**
|
|
23
|
+
* @tsplus fluent Date subDays
|
|
24
|
+
*/
|
|
25
|
+
export const DateSubDays: (date: Date, amount: number) => Date = subDays
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* @tsplus fluent Date addHours
|
|
29
|
+
*/
|
|
30
|
+
export const DateAddHours: (date: Date, amount: number) => Date = addHours
|
|
31
|
+
/**
|
|
32
|
+
* @tsplus fluent Date subHours
|
|
33
|
+
*/
|
|
34
|
+
export const DateSubHours: (date: Date, amount: number) => Date = subHours
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* @tsplus fluent Date addMinutes
|
|
38
|
+
*/
|
|
39
|
+
export const DateAddMinutes: (date: Date, amount: number) => Date = addMinutes
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* @tsplus fluent Date subMinutes
|
|
43
|
+
*/
|
|
44
|
+
export const DateSubMinutes: (date: Date, amount: number) => Date = subMinutes
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* @tsplus fluent Date addSeconds
|
|
48
|
+
*/
|
|
49
|
+
export const DateAddSeconds: (date: Date, amount: number) => Date = addSeconds
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* @tsplus fluent Date subSeconds
|
|
53
|
+
*/
|
|
54
|
+
export const DateSubSeconds: (date: Date, amount: number) => Date = subSeconds
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* @tsplus fluent Date addYears
|
|
58
|
+
*/
|
|
59
|
+
export const DateAddYears: (date: Date, amount: number) => Date = addYears
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* @tsplus fluent Date subYears
|
|
63
|
+
*/
|
|
64
|
+
export const DateSubYears: (date: Date, amount: number) => Date = subYears
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* @tsplus fluent Date addMonths
|
|
68
|
+
*/
|
|
69
|
+
export const DateAddMonths: (date: Date, amount: number) => Date = addMonths
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* @tsplus fluent Date subMonths
|
|
73
|
+
*/
|
|
74
|
+
export const DateSubMonths: (date: Date, amount: number) => Date = subMonths
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* @tsplus fluent Date addWeeks
|
|
78
|
+
*/
|
|
79
|
+
export const DateAddWeeks: (date: Date, amount: number) => Date = addWeeks
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* @tsplus fluent Date subWeeks
|
|
83
|
+
*/
|
|
84
|
+
export const DateSubWeeks: (date: Date, amount: number) => Date = subWeeks
|
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
import * as Either from "effect/Either"
|
|
2
|
+
import type { Option } from "effect/Option"
|
|
3
|
+
|
|
4
|
+
export type _R<T extends Effect<any, any, any>> = [T] extends [
|
|
5
|
+
Effect<any, any, infer R>
|
|
6
|
+
] ? R
|
|
7
|
+
: never
|
|
8
|
+
|
|
9
|
+
export type _E<T extends Effect<any, any, any>> = [T] extends [
|
|
10
|
+
Effect<any, infer E, any>
|
|
11
|
+
] ? E
|
|
12
|
+
: never
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* @tsplus fluent effect/data/Option encaseInEffect
|
|
16
|
+
*/
|
|
17
|
+
export function encaseMaybeInEffect_<E, A>(
|
|
18
|
+
o: Option<A>,
|
|
19
|
+
onError: LazyArg<E>
|
|
20
|
+
): Effect<A, E> {
|
|
21
|
+
return o.match({ onNone: () => Effect.fail(onError()), onSome: Effect.succeed })
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* @tsplus fluent effect/data/Option encaseInEither
|
|
26
|
+
*/
|
|
27
|
+
export function encaseMaybeEither_<E, A>(
|
|
28
|
+
o: Option<A>,
|
|
29
|
+
onError: LazyArg<E>
|
|
30
|
+
): Either.Either<E, A> {
|
|
31
|
+
return o.match({ onNone: () => Either.left(onError()), onSome: Either.right })
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* @tsplus getter effect/io/Effect toNullable
|
|
36
|
+
*/
|
|
37
|
+
export function toNullable<R, E, A>(
|
|
38
|
+
self: Effect<Option<A>, E, R>
|
|
39
|
+
) {
|
|
40
|
+
return self.map((_) => _.getOrNull)
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* @tsplus fluent effect/io/Effect scope
|
|
45
|
+
*/
|
|
46
|
+
export function scope<R, E, A, R2, E2, A2>(
|
|
47
|
+
scopedEffect: Effect<A, E, R | Scope>,
|
|
48
|
+
effect: Effect<A2, E2, R2>
|
|
49
|
+
): Effect<A2, E | E2, Exclude<R | R2, Scope>> {
|
|
50
|
+
return scopedEffect.zipRight(effect).scoped
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* @tsplus fluent effect/io/Effect flatMapScoped
|
|
55
|
+
*/
|
|
56
|
+
export function flatMapScoped<R, E, A, R2, E2, A2>(
|
|
57
|
+
scopedEffect: Effect<A, E, R | Scope>,
|
|
58
|
+
effect: (a: A) => Effect<A2, E2, R2>
|
|
59
|
+
): Effect<A2, E | E2, Exclude<R | R2, Scope>> {
|
|
60
|
+
return scopedEffect.flatMap(effect).scoped
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
// /**
|
|
64
|
+
// * @tsplus fluent effect/io/Effect withScoped
|
|
65
|
+
// */
|
|
66
|
+
// export function withScoped<R, E, A, R2, E2, A2>(
|
|
67
|
+
// effect: Effect<R2, E2, A2>,
|
|
68
|
+
// scopedEffect: Effect<R | Scope, E, A>
|
|
69
|
+
// ): Effect<Exclude<R | R2, Scope>, E | E2, A2> {
|
|
70
|
+
// return scopedEffect.zipRight(effect).scoped
|
|
71
|
+
// }
|
|
72
|
+
|
|
73
|
+
// /**
|
|
74
|
+
// * @tsplus fluent effect/io/Effect withScoped
|
|
75
|
+
// */
|
|
76
|
+
// export function withScopedFlatMap<R, E, A, R2, E2, A2>(
|
|
77
|
+
// effect: (a: A) => Effect<R2, E2, A2>,
|
|
78
|
+
// scopedEffect: Effect<R | Scope, E, A>
|
|
79
|
+
// ): Effect<Exclude<R | R2, Scope>, E | E2, A2> {
|
|
80
|
+
// return scopedEffect.flatMap(effect).scoped
|
|
81
|
+
// }
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* Recovers from all errors.
|
|
85
|
+
*
|
|
86
|
+
* @tsplus static effect/io/Effect.Ops catchAllMap
|
|
87
|
+
* @tsplus pipeable effect/io/Effect catchAllMap
|
|
88
|
+
*/
|
|
89
|
+
export function catchAllMap<E, A2>(f: (e: E) => A2) {
|
|
90
|
+
return <R, A>(self: Effect<A, E, R>): Effect<A2 | A, never, R> => self.catchAll((err) => Effect.sync(() => f(err)))
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* Annotates each log in this effect with the specified log annotations.
|
|
95
|
+
* @tsplus static effect/io/Effect.Ops annotateLogs
|
|
96
|
+
*/
|
|
97
|
+
export function annotateLogs(kvps: Record<string, string>) {
|
|
98
|
+
return <R, E, A>(effect: Effect<A, E, R>): Effect<A, E, R> =>
|
|
99
|
+
FiberRef
|
|
100
|
+
.currentLogAnnotations
|
|
101
|
+
.get
|
|
102
|
+
.flatMap((annotations) =>
|
|
103
|
+
Effect.suspend(() =>
|
|
104
|
+
pipe(
|
|
105
|
+
effect,
|
|
106
|
+
FiberRef.currentLogAnnotations.locally(
|
|
107
|
+
HashMap.fromIterable([...annotations, ...kvps.$$.entries])
|
|
108
|
+
)
|
|
109
|
+
)
|
|
110
|
+
)
|
|
111
|
+
)
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
/**
|
|
115
|
+
* Annotates each log in this scope with the specified log annotation.
|
|
116
|
+
*
|
|
117
|
+
* @tsplus static effect/io/Effect.Ops annotateLogscoped
|
|
118
|
+
*/
|
|
119
|
+
export function annotateLogscoped(key: string, value: string) {
|
|
120
|
+
return FiberRef
|
|
121
|
+
.currentLogAnnotations
|
|
122
|
+
.get
|
|
123
|
+
.flatMap((annotations) =>
|
|
124
|
+
Effect.suspend(() => FiberRef.currentLogAnnotations.locallyScoped(annotations.set(key, value)))
|
|
125
|
+
)
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
/**
|
|
129
|
+
* Annotates each log in this scope with the specified log annotations.
|
|
130
|
+
*
|
|
131
|
+
* @tsplus static effect/io/Effect.Ops annotateLogsScoped
|
|
132
|
+
*/
|
|
133
|
+
export function annotateLogsScoped(kvps: Record<string, string>) {
|
|
134
|
+
return FiberRef
|
|
135
|
+
.currentLogAnnotations
|
|
136
|
+
.get
|
|
137
|
+
.flatMap((annotations) =>
|
|
138
|
+
Effect.suspend(() =>
|
|
139
|
+
FiberRef.currentLogAnnotations.locallyScoped(HashMap.fromIterable([...annotations, ...kvps.$$.entries]))
|
|
140
|
+
)
|
|
141
|
+
)
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
/**
|
|
145
|
+
* @tsplus fluent function flow
|
|
146
|
+
*/
|
|
147
|
+
export function flow<Args extends readonly any[], B, C>(f: (...args: Args) => B, g: (b: B) => C): (...args: Args) => C {
|
|
148
|
+
return (...args) => g(f(...args))
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
/** @tsplus fluent effect/platform/Http/Client request */
|
|
152
|
+
export const client: {
|
|
153
|
+
<A, B, C, R, E>(
|
|
154
|
+
client: HttpClient<A, B, C>,
|
|
155
|
+
req: Effect<ClientRequest, E, R>
|
|
156
|
+
): Effect<C, B | E, A | R>
|
|
157
|
+
<A, B, C>(client: HttpClient<A, B, C>, req: ClientRequest): Effect<C, B, A>
|
|
158
|
+
} = (client: HttpClient<any, any, any>, req: Effect<ClientRequest, any, any> | ClientRequest) =>
|
|
159
|
+
Effect.isEffect(req)
|
|
160
|
+
? req.flatMap(client)
|
|
161
|
+
: client(req)
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
|
|
2
|
+
/**
|
|
3
|
+
* @tsplus global
|
|
4
|
+
*/
|
|
5
|
+
import { TSemaphore } from "effect/TSemaphore"
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* @tsplus global
|
|
9
|
+
*/
|
|
10
|
+
import { TRef } from "effect/TRef"
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* @tsplus global
|
|
14
|
+
*/
|
|
15
|
+
import { STM } from "effect/STM"
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* @tsplus global
|
|
19
|
+
*/
|
|
20
|
+
import { Stream } from "effect/Stream"
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* @tsplus global
|
|
24
|
+
*/
|
|
25
|
+
import { Channel } from "effect/Channel"
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* @tsplus global
|
|
29
|
+
*/
|
|
30
|
+
import { Sink } from "effect/Sink"
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* @tsplus global
|
|
34
|
+
*/
|
|
35
|
+
import { SubscriptionRef } from "effect/SubscriptionRef"
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
/* eslint-disable unused-imports/no-unused-imports */
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @tsplus global
|
|
5
|
+
*/
|
|
6
|
+
import {
|
|
7
|
+
annotate,
|
|
8
|
+
array,
|
|
9
|
+
boolean,
|
|
10
|
+
Class,
|
|
11
|
+
Date,
|
|
12
|
+
Email,
|
|
13
|
+
ExtendedClass,
|
|
14
|
+
ExtendedTaggedClass,
|
|
15
|
+
FromClass,
|
|
16
|
+
inputDate,
|
|
17
|
+
literal,
|
|
18
|
+
nonEmptyArray,
|
|
19
|
+
NonEmptyString,
|
|
20
|
+
NonEmptyString255,
|
|
21
|
+
NonEmptyString2k,
|
|
22
|
+
NonEmptyString50,
|
|
23
|
+
NonEmptyString64k,
|
|
24
|
+
NonNegativeDecimal,
|
|
25
|
+
NonNegativeInt,
|
|
26
|
+
NonNegativeNumber,
|
|
27
|
+
nullable,
|
|
28
|
+
number,
|
|
29
|
+
ParseResult,
|
|
30
|
+
PhoneNumber,
|
|
31
|
+
PositiveDecimal,
|
|
32
|
+
PositiveInt,
|
|
33
|
+
PositiveNumber,
|
|
34
|
+
readonlyMap,
|
|
35
|
+
readonlySet,
|
|
36
|
+
Schema,
|
|
37
|
+
string,
|
|
38
|
+
StringId,
|
|
39
|
+
struct,
|
|
40
|
+
TaggedClass,
|
|
41
|
+
union,
|
|
42
|
+
UnionBrand,
|
|
43
|
+
unknown,
|
|
44
|
+
useClassFeaturesForSchema,
|
|
45
|
+
useClassNameForSchema,
|
|
46
|
+
void_ as Void
|
|
47
|
+
} from "effect-app/schema"
|
|
48
|
+
|
|
49
|
+
// nonEmptyArray,
|
|
50
|
+
// arbitrary,
|
|
51
|
+
// array,
|
|
52
|
+
// bool,
|
|
53
|
+
// Class,
|
|
54
|
+
// ClassFrom,
|
|
55
|
+
// condemnCustom,
|
|
56
|
+
// ConstructorInputApi,
|
|
57
|
+
// date,
|
|
58
|
+
// defaultProp,
|
|
59
|
+
// Email,
|
|
60
|
+
// Encoder,
|
|
61
|
+
// enhanceClassUnion,
|
|
62
|
+
// enhanceUnion,
|
|
63
|
+
// ExtendedClass,
|
|
64
|
+
// fakerArb,
|
|
65
|
+
// field,
|
|
66
|
+
// FieldsClass,
|
|
67
|
+
// From,
|
|
68
|
+
// FromApi,
|
|
69
|
+
// FromClass,
|
|
70
|
+
// inputDate,
|
|
71
|
+
// json,
|
|
72
|
+
// literal,
|
|
73
|
+
// literalNumber,
|
|
74
|
+
// named,
|
|
75
|
+
// nonEmptyArray,
|
|
76
|
+
// NonEmptyString255,
|
|
77
|
+
// NonEmptyString2k,
|
|
78
|
+
// NonEmptyString50,
|
|
79
|
+
// NonEmptyString64k,
|
|
80
|
+
// nullable,
|
|
81
|
+
// number,
|
|
82
|
+
// NumberAsInt,
|
|
83
|
+
// OpaqueSchema,
|
|
84
|
+
// optProp,
|
|
85
|
+
// Parser,
|
|
86
|
+
// PositiveDecimal,
|
|
87
|
+
// PositiveInt,
|
|
88
|
+
// PositiveNumber,
|
|
89
|
+
// PositiveNumberAsInt,
|
|
90
|
+
// propFrom,
|
|
91
|
+
// smartClassUnion,
|
|
92
|
+
// string,
|
|
93
|
+
// StringId,
|
|
94
|
+
// struct,
|
|
95
|
+
// To,
|
|
96
|
+
// union,
|
|
97
|
+
// UnionBrand,
|
|
98
|
+
// unknown,
|
|
99
|
+
// unsafe,
|
|
100
|
+
// useClassConstructorForSchema,
|
|
101
|
+
// useClassFeaturesForSchema,
|
|
102
|
+
// useClassNameForSchema,
|
|
103
|
+
// // unsafe,
|
|
104
|
+
// UUID,
|
|
105
|
+
// Void,
|
|
106
|
+
// withDefaults
|
package/_src/_global.ts
ADDED
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
/* eslint-disable unused-imports/no-unused-imports */
|
|
2
|
+
// /**
|
|
3
|
+
// * @tsplus global
|
|
4
|
+
// */
|
|
5
|
+
// import { Predicate } from "@effect-app/core/Function"
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* @tsplus global
|
|
9
|
+
*/
|
|
10
|
+
import { Runtime } from "effect/Runtime"
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* @tsplus global
|
|
14
|
+
*/
|
|
15
|
+
import { Config } from "effect/Config"
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* @tsplus global
|
|
19
|
+
*/
|
|
20
|
+
import { SecretURL } from "effect-app/Config/SecretURL"
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* @tsplus global
|
|
24
|
+
*/
|
|
25
|
+
import { Secret } from "effect/Secret"
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* @tsplus global
|
|
29
|
+
*/
|
|
30
|
+
import { ConfigError } from "effect/ConfigError"
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* @tsplus global
|
|
34
|
+
*/
|
|
35
|
+
import { ConfigProvider } from "effect/ConfigProvider"
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* @tsplus global
|
|
39
|
+
*/
|
|
40
|
+
import { Cache, CacheStats, ConsumerCache, EntryStats } from "effect/Cache"
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* @tsplus global
|
|
44
|
+
*/
|
|
45
|
+
import { Request } from "effect/Request"
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* @tsplus global
|
|
49
|
+
*/
|
|
50
|
+
import { ClientRequest } from "@effect/platform/Http/ClientRequest"
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* @tsplus global
|
|
54
|
+
*/
|
|
55
|
+
import { EffectCache, EffectRequest, HttpClient } from "effect-app/Request"
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* @tsplus global
|
|
59
|
+
*/
|
|
60
|
+
import { RequestResolver } from "effect/RequestResolver"
|
|
61
|
+
|
|
62
|
+
/* eslint-disable unused-imports/no-unused-imports */
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* @tsplus global
|
|
66
|
+
*/
|
|
67
|
+
import { Pure, PureEnv, PureEnvEnv } from "effect-app/Pure"
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* @tsplus global
|
|
71
|
+
*/
|
|
72
|
+
import { exhaustiveMatch, exhaustiveMatch_, spread, spreadS } from "effect-app/utils"
|
|
73
|
+
/**
|
|
74
|
+
* @tsplus global
|
|
75
|
+
*/
|
|
76
|
+
import {
|
|
77
|
+
// Cause,
|
|
78
|
+
// Chunk,
|
|
79
|
+
// Effect,
|
|
80
|
+
// EffectMaybe as EffectMaybe,
|
|
81
|
+
// Either,
|
|
82
|
+
// Equivalence,
|
|
83
|
+
// Exit,
|
|
84
|
+
// Fiber,
|
|
85
|
+
Fnc,
|
|
86
|
+
// Has,
|
|
87
|
+
// Layer,
|
|
88
|
+
Lens,
|
|
89
|
+
// Managed,
|
|
90
|
+
// Maybe,
|
|
91
|
+
NonEmptySet,
|
|
92
|
+
// Ord,
|
|
93
|
+
// Queue,
|
|
94
|
+
Record,
|
|
95
|
+
// Ref,
|
|
96
|
+
ReadonlySet,
|
|
97
|
+
// Schedule,
|
|
98
|
+
S,
|
|
99
|
+
// Semaphore,
|
|
100
|
+
Utils
|
|
101
|
+
// XPure,
|
|
102
|
+
} from "effect-app"
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* @tsplus global
|
|
106
|
+
*/
|
|
107
|
+
import { assignTag, ServiceTagged, TagClass, TagClassMake } from "effect-app/service"
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* @tsplus global
|
|
111
|
+
*/
|
|
112
|
+
import { match, Pattern } from "ts-pattern"
|
|
113
|
+
|
|
114
|
+
import "@effect-app/core/_global"
|
|
115
|
+
import "@effect-app/core/Prelude"
|
|
116
|
+
import "@effect-app/schema/_global"
|
|
117
|
+
|
|
118
|
+
import "./_global.ext.js"
|
|
119
|
+
import "./refinements.js"
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
// TODO: Convert to effect/core
|
|
2
|
+
|
|
3
|
+
/* eslint-disable @typescript-eslint/ban-types */
|
|
4
|
+
import * as Either from "effect/Either"
|
|
5
|
+
|
|
6
|
+
export class Initial extends Data.TaggedClass("Initial")<{}> {}
|
|
7
|
+
|
|
8
|
+
export class Loading extends Data.TaggedClass("Loading")<{}> {}
|
|
9
|
+
|
|
10
|
+
export class Refreshing<E, A> extends Data.TaggedClass("Refreshing")<{
|
|
11
|
+
readonly current: Either.Either<E, A>
|
|
12
|
+
readonly previous: Option<A>
|
|
13
|
+
}> {
|
|
14
|
+
static succeed<A, E = never>(a: A) {
|
|
15
|
+
return new Refreshing<E, A>({ current: Either.right(a), previous: Option.none() })
|
|
16
|
+
}
|
|
17
|
+
static fail<E, A = never>(e: E, previous?: A) {
|
|
18
|
+
return new Refreshing<E, A>({
|
|
19
|
+
current: Either.left(e),
|
|
20
|
+
previous: previous === undefined ? Option.none() : Option.some(previous)
|
|
21
|
+
})
|
|
22
|
+
}
|
|
23
|
+
static fromDone<E, A>(d: Done<E, A>) {
|
|
24
|
+
return new Refreshing(d)
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export class Done<E, A> extends Data.TaggedClass("Done")<{
|
|
29
|
+
readonly current: Either.Either<E, A>
|
|
30
|
+
readonly previous: Option<A>
|
|
31
|
+
}> {
|
|
32
|
+
static succeed<A, E = never>(this: void, a: A) {
|
|
33
|
+
return new Done<E, A>({ current: Either.right(a), previous: Option.none() })
|
|
34
|
+
}
|
|
35
|
+
static fail<E, A = never>(this: void, e: E, previous?: A) {
|
|
36
|
+
return new Done<E, A>({
|
|
37
|
+
current: Either.left(e),
|
|
38
|
+
previous: previous === undefined ? Option.none() : Option.some(previous)
|
|
39
|
+
})
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
static refresh<E, A>(d: Done<E, A>) {
|
|
43
|
+
return new Refreshing(d)
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* @tsplus type QueryResult
|
|
49
|
+
*/
|
|
50
|
+
export type QueryResult<E, A> = Initial | Loading | Refreshing<E, A> | Done<E, A>
|
|
51
|
+
|
|
52
|
+
type Result<E, A> = Omit<Done<E, A>, "current"> | Omit<Refreshing<E, A>, "current">
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* @tsplus fluent QueryResult isSuccess
|
|
56
|
+
*/
|
|
57
|
+
export function isSuccess<E, A>(
|
|
58
|
+
qr: QueryResult<E, A>
|
|
59
|
+
): qr is Result<E, A> & { current: Either.Right<E, A> } {
|
|
60
|
+
return qr.hasValue() && qr.current.isRight()
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* @tsplus fluent QueryResult hasValue
|
|
65
|
+
*/
|
|
66
|
+
export function hasValue<E, A>(
|
|
67
|
+
qr: QueryResult<E, A>
|
|
68
|
+
): qr is Done<E, A> | Refreshing<E, A> {
|
|
69
|
+
return qr.isDone() || qr.isRefreshing()
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* @tsplus fluent QueryResult isRefreshing
|
|
74
|
+
*/
|
|
75
|
+
export function isRefreshing<E, A>(
|
|
76
|
+
qr: QueryResult<E, A>
|
|
77
|
+
): qr is Refreshing<E, A> {
|
|
78
|
+
return qr._tag === "Refreshing"
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* @tsplus fluent QueryResult isDone
|
|
83
|
+
*/
|
|
84
|
+
export function isDone<E, A>(
|
|
85
|
+
qr: QueryResult<E, A>
|
|
86
|
+
): qr is Done<E, A> {
|
|
87
|
+
return qr._tag === "Done"
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* @tsplus fluent QueryResult isInitializing
|
|
92
|
+
*/
|
|
93
|
+
export function isInitializing<E, A>(
|
|
94
|
+
qr: QueryResult<E, A>
|
|
95
|
+
): qr is Initial | Loading {
|
|
96
|
+
return qr._tag === "Initial" || qr._tag === "Loading"
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* @tsplus fluent QueryResult isFailed
|
|
101
|
+
*/
|
|
102
|
+
export function isFailed<E, A>(
|
|
103
|
+
qr: QueryResult<E, A>
|
|
104
|
+
): qr is Result<E, A> & { current: Either.Left<E, A> } {
|
|
105
|
+
return qr.hasValue() && qr.current.isLeft()
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
export type ResultTuple<Result> = readonly [result: Result, refresh: () => void]
|
|
109
|
+
export type QueryResultTuple<E, A> = ResultTuple<QueryResult<E, A>>
|
|
110
|
+
|
|
111
|
+
export const { fail, succeed } = Done
|
|
112
|
+
|
|
113
|
+
/**
|
|
114
|
+
* @tsplus getter effect/io/Effect asQueryResult
|
|
115
|
+
*/
|
|
116
|
+
export function queryResult<R, E, A>(
|
|
117
|
+
self: Effect<A, E, R>
|
|
118
|
+
): Effect<QueryResult<E, A>, never, R> {
|
|
119
|
+
return self.match({ onFailure: fail, onSuccess: succeed })
|
|
120
|
+
}
|