effect 4.0.0-beta.17 → 4.0.0-beta.19
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/dist/Array.d.ts +127 -299
- package/dist/Array.d.ts.map +1 -1
- package/dist/Array.js +102 -62
- package/dist/Array.js.map +1 -1
- package/dist/Cache.d.ts.map +1 -1
- package/dist/Cache.js +5 -4
- package/dist/Cache.js.map +1 -1
- package/dist/Channel.d.ts +97 -11
- package/dist/Channel.d.ts.map +1 -1
- package/dist/Channel.js +72 -29
- package/dist/Channel.js.map +1 -1
- package/dist/Chunk.d.ts +54 -247
- package/dist/Chunk.d.ts.map +1 -1
- package/dist/Chunk.js +36 -67
- package/dist/Chunk.js.map +1 -1
- package/dist/Effect.d.ts +337 -437
- package/dist/Effect.d.ts.map +1 -1
- package/dist/Effect.js +118 -134
- package/dist/Effect.js.map +1 -1
- package/dist/Filter.d.ts +0 -33
- package/dist/Filter.d.ts.map +1 -1
- package/dist/Filter.js +0 -13
- package/dist/Filter.js.map +1 -1
- package/dist/HashMap.d.ts +15 -14
- package/dist/HashMap.d.ts.map +1 -1
- package/dist/HashMap.js +4 -4
- package/dist/HashMap.js.map +1 -1
- package/dist/Iterable.d.ts +40 -39
- package/dist/Iterable.d.ts.map +1 -1
- package/dist/Iterable.js +94 -22
- package/dist/Iterable.js.map +1 -1
- package/dist/Option.d.ts +22 -15
- package/dist/Option.d.ts.map +1 -1
- package/dist/Option.js +14 -7
- package/dist/Option.js.map +1 -1
- package/dist/Pull.d.ts.map +1 -1
- package/dist/Pull.js +1 -1
- package/dist/Pull.js.map +1 -1
- package/dist/Record.d.ts +24 -120
- package/dist/Record.d.ts.map +1 -1
- package/dist/Record.js +21 -41
- package/dist/Record.js.map +1 -1
- package/dist/Sink.d.ts +11 -11
- package/dist/Sink.d.ts.map +1 -1
- package/dist/Sink.js +53 -6
- package/dist/Sink.js.map +1 -1
- package/dist/Stream.d.ts +198 -386
- package/dist/Stream.d.ts.map +1 -1
- package/dist/Stream.js +103 -59
- package/dist/Stream.js.map +1 -1
- package/dist/Trie.d.ts +18 -17
- package/dist/Trie.d.ts.map +1 -1
- package/dist/Trie.js +5 -5
- package/dist/Trie.js.map +1 -1
- package/dist/TxChunk.d.ts +37 -37
- package/dist/TxChunk.d.ts.map +1 -1
- package/dist/TxChunk.js +3 -3
- package/dist/TxChunk.js.map +1 -1
- package/dist/TxDeferred.d.ts +328 -0
- package/dist/TxDeferred.d.ts.map +1 -0
- package/dist/TxDeferred.js +196 -0
- package/dist/TxDeferred.js.map +1 -0
- package/dist/TxHashMap.d.ts +84 -83
- package/dist/TxHashMap.d.ts.map +1 -1
- package/dist/TxHashMap.js +24 -24
- package/dist/TxHashMap.js.map +1 -1
- package/dist/TxHashSet.d.ts +35 -35
- package/dist/TxHashSet.d.ts.map +1 -1
- package/dist/TxHashSet.js +14 -14
- package/dist/TxHashSet.js.map +1 -1
- package/dist/TxPriorityQueue.d.ts +609 -0
- package/dist/TxPriorityQueue.d.ts.map +1 -0
- package/dist/TxPriorityQueue.js +415 -0
- package/dist/TxPriorityQueue.js.map +1 -0
- package/dist/TxPubSub.d.ts +585 -0
- package/dist/TxPubSub.d.ts.map +1 -0
- package/dist/TxPubSub.js +521 -0
- package/dist/TxPubSub.js.map +1 -0
- package/dist/TxQueue.d.ts +32 -32
- package/dist/TxQueue.d.ts.map +1 -1
- package/dist/TxQueue.js +26 -26
- package/dist/TxQueue.js.map +1 -1
- package/dist/TxReentrantLock.d.ts +523 -0
- package/dist/TxReentrantLock.d.ts.map +1 -0
- package/dist/TxReentrantLock.js +504 -0
- package/dist/TxReentrantLock.js.map +1 -0
- package/dist/TxRef.d.ts +34 -34
- package/dist/TxRef.d.ts.map +1 -1
- package/dist/TxRef.js +21 -14
- package/dist/TxRef.js.map +1 -1
- package/dist/TxSemaphore.d.ts +8 -8
- package/dist/TxSemaphore.d.ts.map +1 -1
- package/dist/TxSemaphore.js +7 -7
- package/dist/TxSemaphore.js.map +1 -1
- package/dist/TxSubscriptionRef.d.ts +508 -0
- package/dist/TxSubscriptionRef.d.ts.map +1 -0
- package/dist/TxSubscriptionRef.js +293 -0
- package/dist/TxSubscriptionRef.js.map +1 -0
- package/dist/index.d.ts +40 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +40 -0
- package/dist/index.js.map +1 -1
- package/dist/internal/effect.js +99 -42
- package/dist/internal/effect.js.map +1 -1
- package/dist/internal/hashMap.js +3 -2
- package/dist/internal/hashMap.js.map +1 -1
- package/dist/internal/trie.js +5 -4
- package/dist/internal/trie.js.map +1 -1
- package/dist/unstable/ai/Tool.d.ts.map +1 -1
- package/dist/unstable/ai/Tool.js +0 -9
- package/dist/unstable/ai/Tool.js.map +1 -1
- package/dist/unstable/cli/Command.d.ts +1 -1
- package/dist/unstable/cli/Command.d.ts.map +1 -1
- package/dist/unstable/cli/Command.js +1 -1
- package/dist/unstable/cli/Command.js.map +1 -1
- package/dist/unstable/cluster/K8sHttpClient.js +4 -4
- package/dist/unstable/cluster/K8sHttpClient.js.map +1 -1
- package/dist/unstable/cluster/Sharding.js +1 -1
- package/dist/unstable/cluster/Sharding.js.map +1 -1
- package/dist/unstable/encoding/Sse.js +1 -1
- package/dist/unstable/encoding/Sse.js.map +1 -1
- package/dist/unstable/rpc/RpcServer.d.ts.map +1 -1
- package/dist/unstable/rpc/RpcServer.js +1 -2
- package/dist/unstable/rpc/RpcServer.js.map +1 -1
- package/dist/unstable/socket/Socket.d.ts.map +1 -1
- package/dist/unstable/socket/Socket.js +3 -3
- package/dist/unstable/socket/Socket.js.map +1 -1
- package/package.json +1 -1
- package/src/Array.ts +190 -342
- package/src/Cache.ts +6 -5
- package/src/Channel.ts +506 -102
- package/src/Chunk.ts +81 -268
- package/src/Effect.ts +437 -518
- package/src/Filter.ts +0 -57
- package/src/HashMap.ts +15 -14
- package/src/Iterable.ts +105 -50
- package/src/Option.ts +30 -20
- package/src/Pull.ts +1 -1
- package/src/Record.ts +43 -152
- package/src/Sink.ts +75 -23
- package/src/Stream.ts +442 -502
- package/src/Trie.ts +18 -17
- package/src/TxChunk.ts +72 -53
- package/src/TxDeferred.ts +394 -0
- package/src/TxHashMap.ts +332 -285
- package/src/TxHashSet.ts +111 -116
- package/src/TxPriorityQueue.ts +767 -0
- package/src/TxPubSub.ts +789 -0
- package/src/TxQueue.ts +241 -251
- package/src/TxReentrantLock.ts +753 -0
- package/src/TxRef.ts +50 -38
- package/src/TxSemaphore.ts +29 -32
- package/src/TxSubscriptionRef.ts +639 -0
- package/src/index.ts +45 -0
- package/src/internal/effect.ts +368 -163
- package/src/internal/hashMap.ts +7 -5
- package/src/internal/trie.ts +16 -9
- package/src/unstable/ai/Tool.ts +0 -9
- package/src/unstable/cli/Command.ts +6 -4
- package/src/unstable/cluster/K8sHttpClient.ts +4 -4
- package/src/unstable/cluster/Sharding.ts +1 -1
- package/src/unstable/encoding/Sse.ts +1 -1
- package/src/unstable/rpc/RpcServer.ts +1 -7
- package/src/unstable/socket/Socket.ts +9 -11
package/src/internal/hashMap.ts
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
5
|
import * as Equal_ from "../Equal.ts"
|
|
6
|
+
import type * as Filter from "../Filter.ts"
|
|
6
7
|
import { format } from "../Formatter.ts"
|
|
7
8
|
import { dual, pipe } from "../Function.ts"
|
|
8
9
|
import * as Hash from "../Hash.ts"
|
|
@@ -12,6 +13,7 @@ import * as Option from "../Option.ts"
|
|
|
12
13
|
import type { Pipeable } from "../Pipeable.ts"
|
|
13
14
|
import { pipeArguments } from "../Pipeable.ts"
|
|
14
15
|
import { hasProperty } from "../Predicate.ts"
|
|
16
|
+
import * as Result from "../Result.ts"
|
|
15
17
|
import type { NoInfer } from "../Types.ts"
|
|
16
18
|
|
|
17
19
|
/** @internal */
|
|
@@ -1255,14 +1257,14 @@ export const compact = <K, A>(self: HashMap<K, Option.Option<A>>): HashMap<K, A>
|
|
|
1255
1257
|
|
|
1256
1258
|
/** @internal */
|
|
1257
1259
|
export const filterMap = dual<
|
|
1258
|
-
<A, K, B>(f:
|
|
1259
|
-
<K, A, B>(self: HashMap<K, A>, f:
|
|
1260
|
-
>(2, <K, A, B>(self: HashMap<K, A>, f:
|
|
1260
|
+
<A, K, B, X>(f: Filter.Filter<A, B, X, [key: K]>) => (self: HashMap<K, A>) => HashMap<K, B>,
|
|
1261
|
+
<K, A, B, X>(self: HashMap<K, A>, f: Filter.Filter<A, B, X, [key: K]>) => HashMap<K, B>
|
|
1262
|
+
>(2, <K, A, B, X>(self: HashMap<K, A>, f: Filter.Filter<A, B, X, [key: K]>): HashMap<K, B> => {
|
|
1261
1263
|
let result = empty<K, B>()
|
|
1262
1264
|
for (const [key, value] of self) {
|
|
1263
1265
|
const mapped = f(value, key)
|
|
1264
|
-
if (
|
|
1265
|
-
result = set(result, key, mapped.
|
|
1266
|
+
if (Result.isSuccess(mapped)) {
|
|
1267
|
+
result = set(result, key, mapped.success)
|
|
1266
1268
|
}
|
|
1267
1269
|
}
|
|
1268
1270
|
return result
|
package/src/internal/trie.ts
CHANGED
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
import * as Equal from "../Equal.ts"
|
|
2
|
+
import type * as Filter from "../Filter.ts"
|
|
2
3
|
import { format } from "../Formatter.ts"
|
|
3
|
-
import { dual,
|
|
4
|
+
import { dual, pipe } from "../Function.ts"
|
|
4
5
|
import * as Hash from "../Hash.ts"
|
|
5
6
|
import { NodeInspectSymbol, toJson } from "../Inspectable.ts"
|
|
6
7
|
import * as Option from "../Option.ts"
|
|
7
8
|
import type * as Ordering from "../Ordering.ts"
|
|
8
9
|
import { pipeArguments } from "../Pipeable.ts"
|
|
9
10
|
import { hasProperty } from "../Predicate.ts"
|
|
11
|
+
import * as Result from "../Result.ts"
|
|
10
12
|
import type * as TR from "../Trie.ts"
|
|
11
13
|
import type { NoInfer } from "../Types.ts"
|
|
12
14
|
|
|
@@ -309,22 +311,27 @@ export const filter: {
|
|
|
309
311
|
|
|
310
312
|
/** @internal */
|
|
311
313
|
export const filterMap = dual<
|
|
312
|
-
<A, B>(
|
|
313
|
-
f:
|
|
314
|
+
<A, B, X>(
|
|
315
|
+
f: Filter.Filter<A, B, X, [key: string]>
|
|
314
316
|
) => (self: TR.Trie<A>) => TR.Trie<B>,
|
|
315
|
-
<A, B>(self: TR.Trie<A>, f:
|
|
316
|
-
>(2, (self,
|
|
317
|
+
<A, B, X>(self: TR.Trie<A>, f: Filter.Filter<A, B, X, [key: string]>) => TR.Trie<B>
|
|
318
|
+
>(2, <A, B, X>(self: TR.Trie<A>, f: Filter.Filter<A, B, X, [key: string]>): TR.Trie<B> =>
|
|
317
319
|
reduce(
|
|
318
320
|
self,
|
|
319
|
-
empty(),
|
|
321
|
+
empty<B>(),
|
|
320
322
|
(trie, value, key) => {
|
|
321
|
-
const
|
|
322
|
-
return
|
|
323
|
+
const result = f(value, key)
|
|
324
|
+
return Result.isSuccess(result) ? insert(trie, key, result.success) : trie
|
|
323
325
|
}
|
|
324
326
|
))
|
|
325
327
|
|
|
326
328
|
/** @internal */
|
|
327
|
-
export const compact = <A>(self: TR.Trie<Option.Option<A>>) =>
|
|
329
|
+
export const compact = <A>(self: TR.Trie<Option.Option<A>>) =>
|
|
330
|
+
reduce(
|
|
331
|
+
self,
|
|
332
|
+
empty<A>(),
|
|
333
|
+
(trie, option, key) => Option.isSome(option) ? insert(trie, key, option.value) : trie
|
|
334
|
+
)
|
|
328
335
|
|
|
329
336
|
/** @internal */
|
|
330
337
|
export const forEach = dual<
|
package/src/unstable/ai/Tool.ts
CHANGED
|
@@ -1622,15 +1622,6 @@ export const getJsonSchema = <Tool extends Any>(tool: Tool, options?: {
|
|
|
1622
1622
|
export const getJsonSchemaFromSchema = <S extends Schema.Top>(schema: S, options?: {
|
|
1623
1623
|
readonly transformer?: CodecTransformer
|
|
1624
1624
|
}): JsonSchema.JsonSchema => {
|
|
1625
|
-
const props = AST.isObjects(schema.ast) ? schema.ast.propertySignatures : []
|
|
1626
|
-
if (props.length === 0) {
|
|
1627
|
-
return {
|
|
1628
|
-
type: "object",
|
|
1629
|
-
properties: {},
|
|
1630
|
-
required: [],
|
|
1631
|
-
additionalProperties: false
|
|
1632
|
-
}
|
|
1633
|
-
}
|
|
1634
1625
|
if (Predicate.isNotUndefined(options?.transformer)) {
|
|
1635
1626
|
return options.transformer(schema).jsonSchema
|
|
1636
1627
|
}
|
|
@@ -994,8 +994,10 @@ export const withGlobalFlags: {
|
|
|
994
994
|
)
|
|
995
995
|
|
|
996
996
|
// Type extractors for subcommand arrays - T[number] gives union of all elements
|
|
997
|
-
type ExtractGlobalFlagContext<T extends ReadonlyArray<GlobalFlag.GlobalFlag<any>>> = T[number] extends
|
|
998
|
-
GlobalFlag.Setting<infer Id, any> ? GlobalFlag.Setting.Identifier<Id>
|
|
997
|
+
type ExtractGlobalFlagContext<T extends ReadonlyArray<GlobalFlag.GlobalFlag<any>>> = T[number] extends infer F
|
|
998
|
+
? F extends GlobalFlag.Setting<infer Id, any> ? GlobalFlag.Setting.Identifier<Id>
|
|
999
|
+
: never
|
|
1000
|
+
: never
|
|
999
1001
|
type ExtractSubcommand<T> = T extends Command<any, any, any, any> ? T
|
|
1000
1002
|
: T extends Command.SubcommandGroup<infer Commands> ? Commands[number]
|
|
1001
1003
|
: never
|
|
@@ -1847,14 +1849,14 @@ export const runWith = <const Name extends string, Input, E, R>(
|
|
|
1847
1849
|
// 9. Run command handler with composed context
|
|
1848
1850
|
yield* Effect.provideServices(program, services)
|
|
1849
1851
|
},
|
|
1850
|
-
Effect.
|
|
1852
|
+
Effect.catchFilter(
|
|
1851
1853
|
((error: any) =>
|
|
1852
1854
|
CliError.isCliError(error) && error._tag === "ShowHelp"
|
|
1853
1855
|
? Result.succeed(error)
|
|
1854
1856
|
: Result.fail(error)) as any,
|
|
1855
1857
|
(error: any) => showHelp(command, error.commandPath)
|
|
1856
1858
|
),
|
|
1857
|
-
Effect.
|
|
1859
|
+
Effect.catchFilter(
|
|
1858
1860
|
(e) =>
|
|
1859
1861
|
Terminal.isQuitError(e)
|
|
1860
1862
|
? Result.succeed(e)
|
|
@@ -121,7 +121,7 @@ export const makeCreatePod = Effect.gen(function*() {
|
|
|
121
121
|
while: (e) => e._tag === "SchemaError",
|
|
122
122
|
schedule: Schedule.spaced("1 seconds")
|
|
123
123
|
}),
|
|
124
|
-
Effect.
|
|
124
|
+
Effect.catchFilter(
|
|
125
125
|
(err) =>
|
|
126
126
|
HttpClientError.isHttpClientError(err) && err.reason._tag === "StatusCodeError" &&
|
|
127
127
|
err.reason.response.status === 404
|
|
@@ -133,7 +133,7 @@ export const makeCreatePod = Effect.gen(function*() {
|
|
|
133
133
|
)
|
|
134
134
|
const isPodFound = readPodRaw.pipe(
|
|
135
135
|
Effect.as(true),
|
|
136
|
-
Effect.
|
|
136
|
+
Effect.catchFilter(
|
|
137
137
|
(err) =>
|
|
138
138
|
HttpClientError.isHttpClientError(err) && err.reason._tag === "StatusCodeError" &&
|
|
139
139
|
err.reason.response.status === 404
|
|
@@ -145,7 +145,7 @@ export const makeCreatePod = Effect.gen(function*() {
|
|
|
145
145
|
const createPod = HttpClientRequest.post(`/v1/namespaces/${namespace}/pods`).pipe(
|
|
146
146
|
HttpClientRequest.bodyJsonUnsafe(spec),
|
|
147
147
|
client.execute,
|
|
148
|
-
Effect.
|
|
148
|
+
Effect.catchFilter(
|
|
149
149
|
(err) =>
|
|
150
150
|
HttpClientError.isHttpClientError(err) && err.reason._tag === "StatusCodeError" &&
|
|
151
151
|
err.reason.response.status === 409
|
|
@@ -159,7 +159,7 @@ export const makeCreatePod = Effect.gen(function*() {
|
|
|
159
159
|
const deletePod = HttpClientRequest.delete(`/v1/namespaces/${namespace}/pods/${name}`).pipe(
|
|
160
160
|
client.execute,
|
|
161
161
|
Effect.flatMap((res) => res.json),
|
|
162
|
-
Effect.
|
|
162
|
+
Effect.catchFilter(
|
|
163
163
|
(err) =>
|
|
164
164
|
HttpClientError.isHttpClientError(err) && err.reason._tag === "StatusCodeError" &&
|
|
165
165
|
err.reason.response.status === 404
|
|
@@ -812,7 +812,7 @@ const make = Effect.gen(function*() {
|
|
|
812
812
|
void,
|
|
813
813
|
MailboxFull | AlreadyProcessingMessage | PersistenceError
|
|
814
814
|
> {
|
|
815
|
-
return Effect.
|
|
815
|
+
return Effect.catchFilter(
|
|
816
816
|
Effect.suspend(() => {
|
|
817
817
|
const address = message.envelope.address
|
|
818
818
|
const isPersisted = ServiceMap.get(message.rpc.annotations, Persisted)
|
|
@@ -311,7 +311,7 @@ export const encode = <IE, Done>(): Channel.Channel<
|
|
|
311
311
|
let done = false
|
|
312
312
|
const pull = upstream.pipe(
|
|
313
313
|
Effect.map(Arr.map(encoder.write)),
|
|
314
|
-
Effect.
|
|
314
|
+
Effect.catchFilter(Retry.filter as any, (retry: any) => {
|
|
315
315
|
done = true
|
|
316
316
|
return Effect.succeed(Arr.of(encoder.write(retry)))
|
|
317
317
|
}),
|
|
@@ -15,7 +15,6 @@ import type * as Option from "../../Option.ts"
|
|
|
15
15
|
import * as Predicate from "../../Predicate.ts"
|
|
16
16
|
import * as Pull from "../../Pull.ts"
|
|
17
17
|
import * as Queue from "../../Queue.ts"
|
|
18
|
-
import * as Result from "../../Result.ts"
|
|
19
18
|
import * as Schedule from "../../Schedule.ts"
|
|
20
19
|
import * as Schema from "../../Schema.ts"
|
|
21
20
|
import * as Scope from "../../Scope.ts"
|
|
@@ -1362,12 +1361,7 @@ const makeSocketProtocol: Effect.Effect<
|
|
|
1362
1361
|
return writeRaw(parser.encode(ResponseDefectEncoded(cause))!)
|
|
1363
1362
|
}
|
|
1364
1363
|
}).pipe(
|
|
1365
|
-
Effect.
|
|
1366
|
-
((
|
|
1367
|
-
error: any
|
|
1368
|
-
) => (error.reason._tag === "SocketCloseError" ? Result.succeed(error.reason) : Result.fail(error))) as any,
|
|
1369
|
-
(_: any) => Effect.void
|
|
1370
|
-
),
|
|
1364
|
+
Effect.catchReason("SocketError", "SocketCloseError", (_) => Effect.void),
|
|
1371
1365
|
Effect.orDie
|
|
1372
1366
|
)
|
|
1373
1367
|
}
|
|
@@ -281,7 +281,7 @@ export const toChannelMap = <IE, A>(
|
|
|
281
281
|
return writeChunk
|
|
282
282
|
}),
|
|
283
283
|
Effect.forever({ disableYield: true }),
|
|
284
|
-
Effect.
|
|
284
|
+
Effect.catchCauseFilter(
|
|
285
285
|
Pull.filterNoDone,
|
|
286
286
|
(cause) => Queue.failCause(queue, cause)
|
|
287
287
|
),
|
|
@@ -545,11 +545,10 @@ export const fromWebSocket = <RO>(
|
|
|
545
545
|
currentWS = ws
|
|
546
546
|
latch.openUnsafe()
|
|
547
547
|
if (opts?.onOpen) yield* opts.onOpen
|
|
548
|
-
return yield*
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
)
|
|
548
|
+
return yield* Effect.catchFilter(
|
|
549
|
+
FiberSet.join(fiberSet),
|
|
550
|
+
SocketCloseError.filterClean((_) => !closeCodeIsError(_)),
|
|
551
|
+
() => Effect.void
|
|
553
552
|
)
|
|
554
553
|
})).pipe(
|
|
555
554
|
Effect.updateServices((input: ServiceMap.ServiceMap<R>) => ServiceMap.merge(acquireContext, input)),
|
|
@@ -693,11 +692,10 @@ export const fromTransformStream = <R>(acquire: Effect.Effect<InputTransformStre
|
|
|
693
692
|
yield* latch.open
|
|
694
693
|
if (opts?.onOpen) yield* opts.onOpen
|
|
695
694
|
|
|
696
|
-
return yield*
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
)
|
|
695
|
+
return yield* Effect.catchFilter(
|
|
696
|
+
FiberSet.join(fiberSet),
|
|
697
|
+
SocketCloseError.filterClean((_) => !closeCodeIsError(_)),
|
|
698
|
+
() => Effect.void
|
|
701
699
|
)
|
|
702
700
|
})).pipe(
|
|
703
701
|
(_) => _,
|