effect 4.0.0-beta.50 → 4.0.0-beta.51
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/BigDecimal.d.ts.map +1 -1
- package/dist/BigDecimal.js +18 -14
- package/dist/BigDecimal.js.map +1 -1
- package/dist/BigInt.d.ts.map +1 -1
- package/dist/BigInt.js +4 -4
- package/dist/BigInt.js.map +1 -1
- package/dist/Brand.d.ts +2 -4
- package/dist/Brand.d.ts.map +1 -1
- package/dist/Brand.js.map +1 -1
- package/dist/Duration.js +1 -1
- package/dist/Duration.js.map +1 -1
- package/dist/Schema.d.ts +77 -9
- package/dist/Schema.d.ts.map +1 -1
- package/dist/Schema.js +37 -7
- package/dist/Schema.js.map +1 -1
- package/dist/SchemaAST.d.ts +6 -0
- package/dist/SchemaAST.d.ts.map +1 -1
- package/dist/SchemaAST.js +216 -229
- package/dist/SchemaAST.js.map +1 -1
- package/dist/SchemaGetter.d.ts +3 -5
- package/dist/SchemaGetter.d.ts.map +1 -1
- package/dist/SchemaGetter.js +3 -2
- package/dist/SchemaGetter.js.map +1 -1
- package/dist/SchemaIssue.d.ts.map +1 -1
- package/dist/SchemaIssue.js +29 -11
- package/dist/SchemaIssue.js.map +1 -1
- package/dist/SchemaParser.js +14 -2
- package/dist/SchemaParser.js.map +1 -1
- package/dist/internal/effect.js +142 -65
- package/dist/internal/effect.js.map +1 -1
- package/dist/unstable/cluster/Runners.d.ts.map +1 -1
- package/dist/unstable/cluster/Runners.js +3 -2
- package/dist/unstable/cluster/Runners.js.map +1 -1
- package/dist/unstable/cluster/SqlMessageStorage.d.ts.map +1 -1
- package/dist/unstable/cluster/SqlMessageStorage.js +1 -0
- package/dist/unstable/cluster/SqlMessageStorage.js.map +1 -1
- package/dist/unstable/cluster/SqlRunnerStorage.d.ts.map +1 -1
- package/dist/unstable/cluster/SqlRunnerStorage.js +6 -6
- package/dist/unstable/cluster/SqlRunnerStorage.js.map +1 -1
- package/dist/unstable/eventlog/SqlEventJournal.d.ts.map +1 -1
- package/dist/unstable/eventlog/SqlEventJournal.js +9 -8
- package/dist/unstable/eventlog/SqlEventJournal.js.map +1 -1
- package/dist/unstable/eventlog/SqlEventLogServerEncrypted.d.ts.map +1 -1
- package/dist/unstable/eventlog/SqlEventLogServerEncrypted.js +6 -5
- package/dist/unstable/eventlog/SqlEventLogServerEncrypted.js.map +1 -1
- package/dist/unstable/eventlog/SqlEventLogServerUnencrypted.d.ts.map +1 -1
- package/dist/unstable/eventlog/SqlEventLogServerUnencrypted.js +6 -5
- package/dist/unstable/eventlog/SqlEventLogServerUnencrypted.js.map +1 -1
- package/dist/unstable/httpapi/OpenApi.d.ts +1 -10
- package/dist/unstable/httpapi/OpenApi.d.ts.map +1 -1
- package/dist/unstable/httpapi/OpenApi.js +2 -11
- package/dist/unstable/httpapi/OpenApi.js.map +1 -1
- package/dist/unstable/observability/OtlpMetrics.js +1 -1
- package/dist/unstable/observability/OtlpMetrics.js.map +1 -1
- package/dist/unstable/observability/internal/protobuf.js +4 -4
- package/dist/unstable/observability/internal/protobuf.js.map +1 -1
- package/dist/unstable/rpc/RpcSerialization.d.ts +11 -0
- package/dist/unstable/rpc/RpcSerialization.d.ts.map +1 -1
- package/dist/unstable/rpc/RpcSerialization.js +14 -9
- package/dist/unstable/rpc/RpcSerialization.js.map +1 -1
- package/package.json +1 -1
- package/src/BigDecimal.ts +20 -16
- package/src/BigInt.ts +4 -4
- package/src/Brand.ts +2 -4
- package/src/Duration.ts +1 -1
- package/src/Schema.ts +87 -11
- package/src/SchemaAST.ts +315 -267
- package/src/SchemaGetter.ts +4 -6
- package/src/SchemaIssue.ts +28 -15
- package/src/SchemaParser.ts +8 -2
- package/src/internal/effect.ts +196 -69
- package/src/unstable/cluster/Runners.ts +8 -5
- package/src/unstable/cluster/SqlMessageStorage.ts +1 -0
- package/src/unstable/cluster/SqlRunnerStorage.ts +12 -6
- package/src/unstable/eventlog/SqlEventJournal.ts +10 -2
- package/src/unstable/eventlog/SqlEventLogServerEncrypted.ts +8 -3
- package/src/unstable/eventlog/SqlEventLogServerUnencrypted.ts +9 -3
- package/src/unstable/httpapi/OpenApi.ts +2 -14
- package/src/unstable/observability/OtlpMetrics.ts +1 -1
- package/src/unstable/observability/internal/protobuf.ts +4 -4
- package/src/unstable/rpc/RpcSerialization.ts +41 -36
package/src/SchemaGetter.ts
CHANGED
|
@@ -483,7 +483,8 @@ export function onSome<T, E, R = never>(
|
|
|
483
483
|
* - `undefined` or `true` — value is valid, passes through.
|
|
484
484
|
* - `false` or a `string` — value is invalid, fails with an `Issue`.
|
|
485
485
|
* - An `Issue` object — fails with that issue directly.
|
|
486
|
-
* - `{ path,
|
|
486
|
+
* - `{ path, issue }` — fails with a nested path issue (`issue` may be a
|
|
487
|
+
* message string or a full {@link Issue.Issue}).
|
|
487
488
|
* - Does not transform the value — input and output types are the same.
|
|
488
489
|
*
|
|
489
490
|
* **Example** (Effectful validation)
|
|
@@ -505,17 +506,14 @@ export function onSome<T, E, R = never>(
|
|
|
505
506
|
*/
|
|
506
507
|
export function checkEffect<T, R = never>(
|
|
507
508
|
f: (input: T, options: AST.ParseOptions) => Effect.Effect<
|
|
508
|
-
undefined | boolean |
|
|
509
|
-
readonly path: ReadonlyArray<PropertyKey>
|
|
510
|
-
readonly message: string
|
|
511
|
-
},
|
|
509
|
+
undefined | boolean | Schema.FilterIssue,
|
|
512
510
|
never,
|
|
513
511
|
R
|
|
514
512
|
>
|
|
515
513
|
): Getter<T, T, R> {
|
|
516
514
|
return onSome((t, options) => {
|
|
517
515
|
return f(t, options).pipe(Effect.flatMapEager((out) => {
|
|
518
|
-
const issue = Issue.
|
|
516
|
+
const issue = Issue.makeSingle(t, out)
|
|
519
517
|
return issue ?
|
|
520
518
|
Effect.fail(issue) :
|
|
521
519
|
Effect.succeed(Option.some(t))
|
package/src/SchemaIssue.ts
CHANGED
|
@@ -79,6 +79,7 @@
|
|
|
79
79
|
* @since 4.0.0
|
|
80
80
|
*/
|
|
81
81
|
import type { StandardSchemaV1 } from "@standard-schema/spec"
|
|
82
|
+
import * as Arr from "./Array.ts"
|
|
82
83
|
import { format, formatPath, type Formatter as FormatterI } from "./Formatter.ts"
|
|
83
84
|
import * as InternalAnnotations from "./internal/schema/annotations.ts"
|
|
84
85
|
import * as Option from "./Option.ts"
|
|
@@ -867,30 +868,42 @@ export function getActual(issue: Issue): Option.Option<unknown> {
|
|
|
867
868
|
}
|
|
868
869
|
}
|
|
869
870
|
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
out: undefined | boolean | string | Issue | {
|
|
874
|
-
readonly path: ReadonlyArray<PropertyKey>
|
|
875
|
-
readonly message: string
|
|
871
|
+
function makeFilterIssue(input: unknown, entry: Schema.FilterIssue): Issue {
|
|
872
|
+
if (isIssue(entry)) {
|
|
873
|
+
return entry
|
|
876
874
|
}
|
|
877
|
-
) {
|
|
878
|
-
|
|
879
|
-
return out
|
|
875
|
+
if (typeof entry === "string") {
|
|
876
|
+
return new InvalidValue(Option.some(input), { message: entry })
|
|
880
877
|
}
|
|
878
|
+
const inner = typeof entry.issue === "string"
|
|
879
|
+
? new InvalidValue(Option.some(input), { message: entry.issue })
|
|
880
|
+
: entry.issue
|
|
881
|
+
return new Pointer(entry.path, inner)
|
|
882
|
+
}
|
|
883
|
+
|
|
884
|
+
/** @internal */
|
|
885
|
+
export function makeSingle(input: unknown, out: undefined | boolean | Schema.FilterIssue): Issue | undefined {
|
|
881
886
|
if (out === undefined) {
|
|
882
887
|
return undefined
|
|
883
888
|
}
|
|
884
889
|
if (typeof out === "boolean") {
|
|
885
890
|
return out ? undefined : new InvalidValue(Option.some(input))
|
|
886
891
|
}
|
|
887
|
-
|
|
888
|
-
|
|
892
|
+
return makeFilterIssue(input, out)
|
|
893
|
+
}
|
|
894
|
+
|
|
895
|
+
/** @internal */
|
|
896
|
+
export function make(input: unknown, ast: AST.AST, out: Schema.FilterOutput): Issue | undefined {
|
|
897
|
+
if (Array.isArray(out)) {
|
|
898
|
+
if (Arr.isReadonlyArrayNonEmpty(out)) {
|
|
899
|
+
if (out.length === 1) {
|
|
900
|
+
return makeFilterIssue(input, out[0])
|
|
901
|
+
}
|
|
902
|
+
return new Composite(ast, Option.some(input), Arr.map(out, (entry) => makeFilterIssue(input, entry)))
|
|
903
|
+
}
|
|
904
|
+
return undefined
|
|
889
905
|
}
|
|
890
|
-
return
|
|
891
|
-
out.path,
|
|
892
|
-
new InvalidValue(Option.some(input), { message: out.message })
|
|
893
|
-
)
|
|
906
|
+
return makeSingle(input, out as undefined | boolean | Schema.FilterIssue)
|
|
894
907
|
}
|
|
895
908
|
|
|
896
909
|
/**
|
package/src/SchemaParser.ts
CHANGED
|
@@ -417,16 +417,22 @@ export interface Parser {
|
|
|
417
417
|
const recur = memoize(
|
|
418
418
|
(ast: AST.AST): Parser => {
|
|
419
419
|
let parser: Parser
|
|
420
|
+
const astOptions = InternalAnnotations.resolve(ast)?.["parseOptions"]
|
|
420
421
|
if (!ast.context && !ast.encoding && !ast.checks) {
|
|
421
422
|
return (ou, options) => {
|
|
422
423
|
parser ??= ast.getParser(recur)
|
|
423
|
-
|
|
424
|
+
if (astOptions) {
|
|
425
|
+
options = { ...options, ...astOptions }
|
|
426
|
+
}
|
|
427
|
+
return parser(ou, options)
|
|
424
428
|
}
|
|
425
429
|
}
|
|
426
430
|
const isStructural = AST.isArrays(ast) || AST.isObjects(ast) ||
|
|
427
431
|
(AST.isDeclaration(ast) && ast.typeParameters.length > 0)
|
|
428
432
|
return (ou, options) => {
|
|
429
|
-
|
|
433
|
+
if (astOptions) {
|
|
434
|
+
options = { ...options, ...astOptions }
|
|
435
|
+
}
|
|
430
436
|
const encoding = ast.encoding
|
|
431
437
|
let srou: Effect.Effect<Option.Option<unknown>, Issue.Issue, unknown> | undefined
|
|
432
438
|
if (encoding) {
|
package/src/internal/effect.ts
CHANGED
|
@@ -58,7 +58,6 @@ import {
|
|
|
58
58
|
contA,
|
|
59
59
|
contAll,
|
|
60
60
|
contE,
|
|
61
|
-
Die,
|
|
62
61
|
evaluate,
|
|
63
62
|
exitDie,
|
|
64
63
|
exitFail,
|
|
@@ -4457,72 +4456,8 @@ export const forEach: {
|
|
|
4457
4456
|
const out: Array<B> | undefined = options?.discard
|
|
4458
4457
|
? undefined
|
|
4459
4458
|
: new Array(length)
|
|
4460
|
-
|
|
4461
|
-
|
|
4462
|
-
|
|
4463
|
-
return callback((resume) => {
|
|
4464
|
-
const fibers = new Set<Fiber.Fiber<unknown, unknown>>()
|
|
4465
|
-
const failures: Array<Cause.Reason<E>> = []
|
|
4466
|
-
let failed = false
|
|
4467
|
-
let inProgress = 0
|
|
4468
|
-
let doneCount = 0
|
|
4469
|
-
let pumping = false
|
|
4470
|
-
let interrupted = false
|
|
4471
|
-
function pump() {
|
|
4472
|
-
pumping = true
|
|
4473
|
-
while (inProgress < concurrency && index < length) {
|
|
4474
|
-
const currentIndex = index
|
|
4475
|
-
const item = items[currentIndex]
|
|
4476
|
-
index++
|
|
4477
|
-
inProgress++
|
|
4478
|
-
try {
|
|
4479
|
-
const child = forkUnsafe(parent, f(item, currentIndex), true, true, "inherit")
|
|
4480
|
-
fibers.add(child)
|
|
4481
|
-
child.addObserver((exit) => {
|
|
4482
|
-
if (interrupted) {
|
|
4483
|
-
return
|
|
4484
|
-
}
|
|
4485
|
-
fibers.delete(child)
|
|
4486
|
-
if (exit._tag === "Failure") {
|
|
4487
|
-
if (!failed) {
|
|
4488
|
-
failed = true
|
|
4489
|
-
length = index
|
|
4490
|
-
failures.push(...exit.cause.reasons)
|
|
4491
|
-
fibers.forEach((fiber) => fiber.interruptUnsafe(parent.id, annotations))
|
|
4492
|
-
} else {
|
|
4493
|
-
for (const f of exit.cause.reasons) {
|
|
4494
|
-
if (f._tag === "Interrupt") continue
|
|
4495
|
-
failures.push(f)
|
|
4496
|
-
}
|
|
4497
|
-
}
|
|
4498
|
-
} else if (out !== undefined) {
|
|
4499
|
-
out[currentIndex] = exit.value
|
|
4500
|
-
}
|
|
4501
|
-
doneCount++
|
|
4502
|
-
inProgress--
|
|
4503
|
-
if (doneCount === length) {
|
|
4504
|
-
resume(failures.length > 0 ? exitFailCause(causeFromReasons(failures)) : succeed(out))
|
|
4505
|
-
} else if (!pumping && !failed && inProgress < concurrency) {
|
|
4506
|
-
pump()
|
|
4507
|
-
}
|
|
4508
|
-
})
|
|
4509
|
-
} catch (err) {
|
|
4510
|
-
failed = true
|
|
4511
|
-
length = index
|
|
4512
|
-
failures.push(new Die(err))
|
|
4513
|
-
fibers.forEach((fiber) => fiber.interruptUnsafe(parent.id, annotations))
|
|
4514
|
-
}
|
|
4515
|
-
}
|
|
4516
|
-
pumping = false
|
|
4517
|
-
}
|
|
4518
|
-
pump()
|
|
4519
|
-
|
|
4520
|
-
return suspend(() => {
|
|
4521
|
-
interrupted = true
|
|
4522
|
-
index = length
|
|
4523
|
-
return fiberInterruptAll(fibers)
|
|
4524
|
-
})
|
|
4525
|
-
})
|
|
4459
|
+
const eff = forEachConcurrent({ f, out }, items, { concurrency })
|
|
4460
|
+
return eff ? as(eff, out as any) : succeed(out as any)
|
|
4526
4461
|
}))
|
|
4527
4462
|
|
|
4528
4463
|
const forEachSequential = <A, B, E, R>(
|
|
@@ -4550,6 +4485,188 @@ const forEachSequential = <A, B, E, R>(
|
|
|
4550
4485
|
)
|
|
4551
4486
|
})
|
|
4552
4487
|
|
|
4488
|
+
const iterateEagerImpl = <S, A, X, E, R, E2>(options: {
|
|
4489
|
+
readonly onItem: (state: S, item: A, index: number) => Effect.Effect<X, E, R>
|
|
4490
|
+
readonly step: (state: NoInfer<S>, item: A, exit: Exit.Exit<X, E>, index: number) => Exit.Exit<void, E2> | void
|
|
4491
|
+
}): (
|
|
4492
|
+
initialState: S,
|
|
4493
|
+
items: ReadonlyArray<A>,
|
|
4494
|
+
options?: {
|
|
4495
|
+
readonly concurrency?: number | undefined
|
|
4496
|
+
readonly start?: number | undefined
|
|
4497
|
+
readonly end?: number | undefined
|
|
4498
|
+
}
|
|
4499
|
+
) => Effect.Effect<void, E | E2, R> | undefined => {
|
|
4500
|
+
const onItem = options.onItem
|
|
4501
|
+
const step = options.step
|
|
4502
|
+
|
|
4503
|
+
return (
|
|
4504
|
+
state: S,
|
|
4505
|
+
items: ReadonlyArray<A>,
|
|
4506
|
+
opts: {
|
|
4507
|
+
readonly concurrency?: number | undefined
|
|
4508
|
+
readonly start?: number | undefined
|
|
4509
|
+
readonly end?: number | undefined
|
|
4510
|
+
} | undefined
|
|
4511
|
+
): Effect.Effect<void, E | E2, R> | undefined => {
|
|
4512
|
+
let index = opts?.start ?? 0
|
|
4513
|
+
const end = opts?.end ?? items.length
|
|
4514
|
+
const concurrency = opts?.concurrency ?? 1
|
|
4515
|
+
let done = false
|
|
4516
|
+
let parentFiber: Fiber.Fiber<any, any> | undefined
|
|
4517
|
+
let fibers: Set<Fiber.Fiber<any, any>> | undefined
|
|
4518
|
+
let resume: ((effect: Effect.Effect<void, E | E2, R>) => void) | undefined
|
|
4519
|
+
let interrupted = false
|
|
4520
|
+
let terminal: Exit.Exit<void, E | E2> | void
|
|
4521
|
+
let effect: Effect.Effect<X, E, R> | undefined
|
|
4522
|
+
|
|
4523
|
+
const go = (): Effect.Effect<void, E | E2, R> | undefined => {
|
|
4524
|
+
let paused = false
|
|
4525
|
+
for (; !terminal && index < end; index++) {
|
|
4526
|
+
const item = items[index]
|
|
4527
|
+
const eff = effect ?? onItem(state, item, index)
|
|
4528
|
+
|
|
4529
|
+
// fast case (already an exit)
|
|
4530
|
+
if (effectIsExit(eff)) {
|
|
4531
|
+
terminal = step(state, item, eff, index)
|
|
4532
|
+
if (terminal) break
|
|
4533
|
+
|
|
4534
|
+
// Use flatMap for concurrency of 1
|
|
4535
|
+
} else if (concurrency === 1) {
|
|
4536
|
+
return flatMap(exit(eff), (exit) => {
|
|
4537
|
+
terminal = step(state, item, exit, index)
|
|
4538
|
+
index++
|
|
4539
|
+
return terminal ?? go() ?? void_
|
|
4540
|
+
})
|
|
4541
|
+
|
|
4542
|
+
// We have an effect, so enter "async" mode
|
|
4543
|
+
} else if (!parentFiber) {
|
|
4544
|
+
return callback((cb) => {
|
|
4545
|
+
parentFiber = getCurrentFiber()!
|
|
4546
|
+
effect = eff
|
|
4547
|
+
resume = cb
|
|
4548
|
+
const result = go()
|
|
4549
|
+
if (result) return cb(result)
|
|
4550
|
+
return suspend(() => {
|
|
4551
|
+
terminal = exitVoid
|
|
4552
|
+
interrupted = true
|
|
4553
|
+
return fibers ? fiberInterruptAll(fibers) : void_
|
|
4554
|
+
})
|
|
4555
|
+
})
|
|
4556
|
+
|
|
4557
|
+
// Fork the effect with concurrency > 1
|
|
4558
|
+
} else {
|
|
4559
|
+
// Clear the temporary effect from capturing the parentFiber
|
|
4560
|
+
effect = undefined
|
|
4561
|
+
|
|
4562
|
+
const fiber = forkUnsafe(parentFiber, eff, true, true, "inherit")
|
|
4563
|
+
if (fiber._exit) {
|
|
4564
|
+
terminal = step(state, item, fiber._exit, index)
|
|
4565
|
+
if (terminal) break
|
|
4566
|
+
continue
|
|
4567
|
+
}
|
|
4568
|
+
|
|
4569
|
+
// Add the fiber to the Set
|
|
4570
|
+
if (fibers) fibers.add(fiber)
|
|
4571
|
+
else fibers = new Set([fiber])
|
|
4572
|
+
|
|
4573
|
+
const currentIndex = index
|
|
4574
|
+
fiber.addObserver((exit) => {
|
|
4575
|
+
fibers!.delete(fiber)
|
|
4576
|
+
if (terminal) {
|
|
4577
|
+
if (!interrupted && exit._tag === "Failure") {
|
|
4578
|
+
for (const reason of exit.cause.reasons) {
|
|
4579
|
+
if (reason._tag === "Interrupt") continue
|
|
4580
|
+
else if (terminal._tag === "Failure") {
|
|
4581
|
+
;(terminal.cause.reasons as Array<any>).push(reason)
|
|
4582
|
+
} else {
|
|
4583
|
+
terminal = exitFailCause(causeFromReasons([reason]))
|
|
4584
|
+
}
|
|
4585
|
+
}
|
|
4586
|
+
}
|
|
4587
|
+
} else {
|
|
4588
|
+
const result = step(state, item, exit, currentIndex)
|
|
4589
|
+
if (result) {
|
|
4590
|
+
terminal = result._tag === "Failure"
|
|
4591
|
+
? exitFailCause(causeFromReasons(result.cause.reasons.slice()))
|
|
4592
|
+
: result
|
|
4593
|
+
go()
|
|
4594
|
+
}
|
|
4595
|
+
}
|
|
4596
|
+
|
|
4597
|
+
if (paused) {
|
|
4598
|
+
const eff = go()
|
|
4599
|
+
if (eff) resume!(eff)
|
|
4600
|
+
} else if (done && fibers!.size === 0) {
|
|
4601
|
+
resume!(terminal ?? void_)
|
|
4602
|
+
}
|
|
4603
|
+
})
|
|
4604
|
+
|
|
4605
|
+
// Check if we have reached the concurrency limit
|
|
4606
|
+
if (fibers.size < concurrency) continue
|
|
4607
|
+
paused = true
|
|
4608
|
+
index++
|
|
4609
|
+
return
|
|
4610
|
+
}
|
|
4611
|
+
}
|
|
4612
|
+
|
|
4613
|
+
done = true
|
|
4614
|
+
|
|
4615
|
+
if (terminal) {
|
|
4616
|
+
if (fibers && fibers.size > 0) {
|
|
4617
|
+
const annotations = fiberStackAnnotations(parentFiber!)
|
|
4618
|
+
fibers.forEach((f) => f.interruptUnsafe(parentFiber!.id, annotations))
|
|
4619
|
+
return
|
|
4620
|
+
}
|
|
4621
|
+
if (resume || terminal._tag === "Failure") {
|
|
4622
|
+
return terminal
|
|
4623
|
+
}
|
|
4624
|
+
} else if (resume) {
|
|
4625
|
+
if (!fibers) {
|
|
4626
|
+
return exitVoid
|
|
4627
|
+
} else if (fibers.size === 0) {
|
|
4628
|
+
resume(void_)
|
|
4629
|
+
}
|
|
4630
|
+
}
|
|
4631
|
+
}
|
|
4632
|
+
|
|
4633
|
+
return go()
|
|
4634
|
+
}
|
|
4635
|
+
}
|
|
4636
|
+
|
|
4637
|
+
/** @internal */
|
|
4638
|
+
export const iterateEager = <S, A>(): <X, E, R, E2>(options: {
|
|
4639
|
+
readonly onItem: (state: S, item: A, index: number) => Effect.Effect<X, E, R>
|
|
4640
|
+
readonly step: (state: NoInfer<S>, item: A, exit: Exit.Exit<X, E>, index: number) => Exit.Exit<void, E2> | void
|
|
4641
|
+
}) => (
|
|
4642
|
+
initialState: S,
|
|
4643
|
+
items: ReadonlyArray<A>,
|
|
4644
|
+
options?: {
|
|
4645
|
+
readonly concurrency?: number | undefined
|
|
4646
|
+
readonly start?: number | undefined
|
|
4647
|
+
readonly end?: number | undefined
|
|
4648
|
+
}
|
|
4649
|
+
) => Effect.Effect<void, E | E2, R> | undefined => iterateEagerImpl
|
|
4650
|
+
|
|
4651
|
+
const forEachConcurrent = iterateEagerImpl({
|
|
4652
|
+
onItem(
|
|
4653
|
+
state: {
|
|
4654
|
+
readonly f: (a: any, i: number) => Effect.Effect<any, any, any>
|
|
4655
|
+
readonly out: Array<any> | undefined
|
|
4656
|
+
},
|
|
4657
|
+
item,
|
|
4658
|
+
index
|
|
4659
|
+
) {
|
|
4660
|
+
return state.f(item, index)
|
|
4661
|
+
},
|
|
4662
|
+
step(state, _, exit, index) {
|
|
4663
|
+
if (exit._tag === "Failure") return exit
|
|
4664
|
+
else if (state.out) {
|
|
4665
|
+
state.out[index] = exit.value
|
|
4666
|
+
}
|
|
4667
|
+
}
|
|
4668
|
+
})
|
|
4669
|
+
|
|
4553
4670
|
/* @internal */
|
|
4554
4671
|
export const filterOrElse: {
|
|
4555
4672
|
<A, C, E2, R2, B extends A>(
|
|
@@ -4862,7 +4979,7 @@ export const forkUnsafe = <FA, FE, A, E, R>(
|
|
|
4862
4979
|
immediate = false,
|
|
4863
4980
|
daemon = false,
|
|
4864
4981
|
uninterruptible: boolean | "inherit" = false
|
|
4865
|
-
):
|
|
4982
|
+
): FiberImpl<A, E> => {
|
|
4866
4983
|
const interruptible = uninterruptible === "inherit" ? parent.interruptible : !uninterruptible
|
|
4867
4984
|
const child = new FiberImpl<A, E>(parent.context, interruptible)
|
|
4868
4985
|
if (immediate) {
|
|
@@ -5332,7 +5449,7 @@ export const makeSpanUnsafe = <XA, XE>(
|
|
|
5332
5449
|
parent,
|
|
5333
5450
|
annotations: options?.annotations ?? Context.empty(),
|
|
5334
5451
|
links,
|
|
5335
|
-
startTime: timingEnabled ? clock.currentTimeNanosUnsafe() :
|
|
5452
|
+
startTime: timingEnabled ? clock.currentTimeNanosUnsafe() : BigInt(0),
|
|
5336
5453
|
kind: options?.kind ?? "internal",
|
|
5337
5454
|
root: options?.root ?? Option.isNone(parent),
|
|
5338
5455
|
sampled: options?.sampled ??
|
|
@@ -6022,6 +6139,7 @@ const prettyLoggerTty = (options: {
|
|
|
6022
6139
|
return loggerMake<unknown, void>(
|
|
6023
6140
|
({ cause, date, fiber, logLevel, message: message_ }) => {
|
|
6024
6141
|
const console = fiber.getRef(ConsoleRef)
|
|
6142
|
+
// oxlint-disable-next-line no-console
|
|
6025
6143
|
const log = fiber.getRef(LogToStderr) ? console.error : console.log
|
|
6026
6144
|
|
|
6027
6145
|
const message = Array.isArray(message_) ? message_.slice() : [message_]
|
|
@@ -6047,6 +6165,7 @@ const prettyLoggerTty = (options: {
|
|
|
6047
6165
|
}
|
|
6048
6166
|
|
|
6049
6167
|
log(firstLine)
|
|
6168
|
+
// oxlint-disable-next-line no-console
|
|
6050
6169
|
if (!processIsBun) console.group()
|
|
6051
6170
|
|
|
6052
6171
|
if (cause.reasons.length > 0) {
|
|
@@ -6064,6 +6183,7 @@ const prettyLoggerTty = (options: {
|
|
|
6064
6183
|
log(color(`${key}:`, colors.bold, colors.white), redact(value))
|
|
6065
6184
|
}
|
|
6066
6185
|
|
|
6186
|
+
// oxlint-disable-next-line no-console
|
|
6067
6187
|
if (!processIsBun) console.groupEnd()
|
|
6068
6188
|
}
|
|
6069
6189
|
)
|
|
@@ -6110,14 +6230,17 @@ const prettyLoggerBrowser = (options: {
|
|
|
6110
6230
|
}
|
|
6111
6231
|
}
|
|
6112
6232
|
|
|
6233
|
+
// oxlint-disable-next-line no-console
|
|
6113
6234
|
console.groupCollapsed(firstLine, ...firstParams)
|
|
6114
6235
|
|
|
6115
6236
|
if (cause.reasons.length > 0) {
|
|
6237
|
+
// oxlint-disable-next-line no-console
|
|
6116
6238
|
console.error(causePretty(cause))
|
|
6117
6239
|
}
|
|
6118
6240
|
|
|
6119
6241
|
if (messageIndex < message.length) {
|
|
6120
6242
|
for (; messageIndex < message.length; messageIndex++) {
|
|
6243
|
+
// oxlint-disable-next-line no-console
|
|
6121
6244
|
console.log(redact(message[messageIndex]))
|
|
6122
6245
|
}
|
|
6123
6246
|
}
|
|
@@ -6126,12 +6249,15 @@ const prettyLoggerBrowser = (options: {
|
|
|
6126
6249
|
for (const [key, value] of Object.entries(annotations)) {
|
|
6127
6250
|
const redacted = redact(value)
|
|
6128
6251
|
if (options.colors) {
|
|
6252
|
+
// oxlint-disable-next-line no-console
|
|
6129
6253
|
console.log(`%c${key}:`, "color:gray", redacted)
|
|
6130
6254
|
} else {
|
|
6255
|
+
// oxlint-disable-next-line no-console
|
|
6131
6256
|
console.log(`${key}:`, redacted)
|
|
6132
6257
|
}
|
|
6133
6258
|
}
|
|
6134
6259
|
|
|
6260
|
+
// oxlint-disable-next-line no-console
|
|
6135
6261
|
console.groupEnd()
|
|
6136
6262
|
}
|
|
6137
6263
|
)
|
|
@@ -6154,6 +6280,7 @@ export const defaultLogger = loggerMake<unknown, void>(({ cause, date, fiber, lo
|
|
|
6154
6280
|
message_.push(annotations)
|
|
6155
6281
|
}
|
|
6156
6282
|
const console = fiber.getRef(ConsoleRef)
|
|
6283
|
+
// oxlint-disable-next-line no-console
|
|
6157
6284
|
const log = fiber.getRef(LogToStderr) ? console.error : console.log
|
|
6158
6285
|
log(`[${defaultDateFormat(date)}] ${logLevel.toUpperCase()} (#${fiber.id})${spanString}:`, ...message_)
|
|
6159
6286
|
})
|
|
@@ -589,11 +589,14 @@ export const makeRpc: Effect.Effect<
|
|
|
589
589
|
return Effect.void
|
|
590
590
|
}
|
|
591
591
|
const envelope = message.envelope
|
|
592
|
-
|
|
593
|
-
Effect.
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
592
|
+
const encode: Effect.Effect<Envelope.AckChunk | Envelope.Interrupt | Envelope.PartialRequest> =
|
|
593
|
+
message._tag === "OutgoingRequest" ? Effect.orDie(Message.serializeRequest(message)) : Effect.succeed(envelope)
|
|
594
|
+
return Effect.flatMap(encode, (envelope) =>
|
|
595
|
+
RcMap.get(clients, address.value).pipe(
|
|
596
|
+
Effect.flatMap((client) => client.Notify({ envelope })),
|
|
597
|
+
Effect.scoped,
|
|
598
|
+
Effect.ignore
|
|
599
|
+
))
|
|
597
600
|
},
|
|
598
601
|
onRunnerUnavailable: (address) => RcMap.invalidate(clients, address)
|
|
599
602
|
})
|
|
@@ -536,7 +536,8 @@ export const make = Effect.fnUntraced(function*(options: {
|
|
|
536
536
|
shardIds.length > 0 ?
|
|
537
537
|
Effect.andThen(refreshShards(address, shardIds)) :
|
|
538
538
|
Effect.as([]),
|
|
539
|
-
PersistenceError.refail
|
|
539
|
+
PersistenceError.refail,
|
|
540
|
+
withTracerDisabled
|
|
540
541
|
),
|
|
541
542
|
|
|
542
543
|
release: sql.onDialectOrElse({
|
|
@@ -544,7 +545,8 @@ export const make = Effect.fnUntraced(function*(options: {
|
|
|
544
545
|
if (disableAdvisoryLocks) {
|
|
545
546
|
return (address: string, shardId: string) =>
|
|
546
547
|
sql`DELETE FROM ${locksTableSql} WHERE address = ${address} AND shard_id = ${shardId}`.pipe(
|
|
547
|
-
PersistenceError.refail
|
|
548
|
+
PersistenceError.refail,
|
|
549
|
+
withTracerDisabled
|
|
548
550
|
)
|
|
549
551
|
}
|
|
550
552
|
return Effect.fnUntraced(
|
|
@@ -564,14 +566,16 @@ export const make = Effect.fnUntraced(function*(options: {
|
|
|
564
566
|
},
|
|
565
567
|
Effect.onError(() => lockConn!.rebuildUnsafe()),
|
|
566
568
|
Effect.asVoid,
|
|
567
|
-
PersistenceError.refail
|
|
569
|
+
PersistenceError.refail,
|
|
570
|
+
withTracerDisabled
|
|
568
571
|
)
|
|
569
572
|
},
|
|
570
573
|
mysql: () => {
|
|
571
574
|
if (disableAdvisoryLocks) {
|
|
572
575
|
return (address: string, shardId: string) =>
|
|
573
576
|
sql`DELETE FROM ${locksTableSql} WHERE address = ${address} AND shard_id = ${shardId}`.pipe(
|
|
574
|
-
PersistenceError.refail
|
|
577
|
+
PersistenceError.refail,
|
|
578
|
+
withTracerDisabled
|
|
575
579
|
)
|
|
576
580
|
}
|
|
577
581
|
return Effect.fnUntraced(
|
|
@@ -589,12 +593,14 @@ export const make = Effect.fnUntraced(function*(options: {
|
|
|
589
593
|
},
|
|
590
594
|
Effect.onError(() => lockConn!.rebuildUnsafe()),
|
|
591
595
|
Effect.asVoid,
|
|
592
|
-
PersistenceError.refail
|
|
596
|
+
PersistenceError.refail,
|
|
597
|
+
withTracerDisabled
|
|
593
598
|
)
|
|
594
599
|
},
|
|
595
600
|
orElse: () => (address, shardId) =>
|
|
596
601
|
sql`DELETE FROM ${locksTableSql} WHERE address = ${address} AND shard_id = ${shardId}`.pipe(
|
|
597
|
-
PersistenceError.refail
|
|
602
|
+
PersistenceError.refail,
|
|
603
|
+
withTracerDisabled
|
|
598
604
|
)
|
|
599
605
|
}),
|
|
600
606
|
|
|
@@ -71,7 +71,7 @@ export const make = (options?: {
|
|
|
71
71
|
payload BLOB NOT NULL,
|
|
72
72
|
timestamp INTEGER NOT NULL
|
|
73
73
|
)`
|
|
74
|
-
})
|
|
74
|
+
}).pipe(withTracerDisabled)
|
|
75
75
|
|
|
76
76
|
yield* sql.onDialectOrElse({
|
|
77
77
|
pg: () =>
|
|
@@ -106,7 +106,7 @@ export const make = (options?: {
|
|
|
106
106
|
sequence INT NOT NULL,
|
|
107
107
|
PRIMARY KEY (remote_id, entry_id)
|
|
108
108
|
)`
|
|
109
|
-
})
|
|
109
|
+
}).pipe(withTracerDisabled)
|
|
110
110
|
|
|
111
111
|
const decodeEntryRows = Schema.decodeUnknownEffect(EntryRowArray)
|
|
112
112
|
const toEntries = (rows: ReadonlyArray<EntryRow>): ReadonlyArray<EventJournal.Entry> => rows.map(toEntry)
|
|
@@ -193,6 +193,7 @@ export const make = (options?: {
|
|
|
193
193
|
|
|
194
194
|
return EventJournal.EventJournal.of({
|
|
195
195
|
entries: sql`SELECT * FROM ${entryTableSql} ORDER BY timestamp ASC`.pipe(
|
|
196
|
+
withTracerDisabled,
|
|
196
197
|
Effect.flatMap(decodeEntryRows),
|
|
197
198
|
Effect.map(toEntries),
|
|
198
199
|
Effect.mapError((cause) => new EventJournal.EventJournalError({ cause, method: "entries" }))
|
|
@@ -210,10 +211,12 @@ export const make = (options?: {
|
|
|
210
211
|
yield* PubSub.publish(pubsub, entry)
|
|
211
212
|
return value
|
|
212
213
|
},
|
|
214
|
+
withTracerDisabled,
|
|
213
215
|
Effect.mapError((cause) => new EventJournal.EventJournalError({ cause, method: "write" }))
|
|
214
216
|
),
|
|
215
217
|
writeFromRemote: (options) =>
|
|
216
218
|
writeFromRemote(options).pipe(
|
|
219
|
+
withTracerDisabled,
|
|
217
220
|
Effect.catchIf(
|
|
218
221
|
(e) => e._tag !== "EventJournalError",
|
|
219
222
|
(cause) => Effect.fail(new EventJournal.EventJournalError({ cause, method: "writeFromRemote" }))
|
|
@@ -232,6 +235,7 @@ export const make = (options?: {
|
|
|
232
235
|
)
|
|
233
236
|
return yield* f(entries)
|
|
234
237
|
},
|
|
238
|
+
withTracerDisabled,
|
|
235
239
|
Effect.mapError((cause) => new EventJournal.EventJournalError({ cause, method: "withRemoteUncommited" }))
|
|
236
240
|
),
|
|
237
241
|
nextRemoteSequence: (remoteId) =>
|
|
@@ -242,6 +246,7 @@ export const make = (options?: {
|
|
|
242
246
|
if (value === null || value === undefined) return 0
|
|
243
247
|
return Number(value) + 1
|
|
244
248
|
}),
|
|
249
|
+
withTracerDisabled,
|
|
245
250
|
Effect.mapError((cause) => new EventJournal.EventJournalError({ cause, method: "nextRemoteSequence" }))
|
|
246
251
|
),
|
|
247
252
|
changes: PubSub.subscribe(pubsub),
|
|
@@ -249,6 +254,7 @@ export const make = (options?: {
|
|
|
249
254
|
yield* sql`DROP TABLE ${entryTableSql}`
|
|
250
255
|
yield* sql`DROP TABLE ${remotesTableSql}`
|
|
251
256
|
}).pipe(
|
|
257
|
+
withTracerDisabled,
|
|
252
258
|
Effect.mapError((cause) => new EventJournal.EventJournalError({ cause, method: "destroy" }))
|
|
253
259
|
),
|
|
254
260
|
withLock(_storeId) {
|
|
@@ -305,3 +311,5 @@ const RemoteRow = Schema.Struct({
|
|
|
305
311
|
})
|
|
306
312
|
|
|
307
313
|
const RemoteRowArray = Schema.Array(RemoteRow)
|
|
314
|
+
|
|
315
|
+
const withTracerDisabled = Effect.withTracerEnabled(false)
|
|
@@ -148,7 +148,7 @@ export const makeStorage = (options?: {
|
|
|
148
148
|
PubSub.shutdown
|
|
149
149
|
)
|
|
150
150
|
return { pubsub, table } as const
|
|
151
|
-
}),
|
|
151
|
+
}, withTracerDisabled),
|
|
152
152
|
idleTimeToLive: "5 minutes"
|
|
153
153
|
})
|
|
154
154
|
|
|
@@ -182,6 +182,7 @@ export const makeStorage = (options?: {
|
|
|
182
182
|
)
|
|
183
183
|
},
|
|
184
184
|
sql.withTransaction,
|
|
185
|
+
withTracerDisabled,
|
|
185
186
|
Effect.orDie
|
|
186
187
|
),
|
|
187
188
|
write: Effect.fnUntraced(
|
|
@@ -228,7 +229,8 @@ export const makeStorage = (options?: {
|
|
|
228
229
|
return allEntries
|
|
229
230
|
},
|
|
230
231
|
Effect.orDie,
|
|
231
|
-
Effect.scoped
|
|
232
|
+
Effect.scoped,
|
|
233
|
+
withTracerDisabled
|
|
232
234
|
),
|
|
233
235
|
changes: Effect.fnUntraced(
|
|
234
236
|
function*(publicKey, storeId, startSequence) {
|
|
@@ -243,10 +245,11 @@ export const makeStorage = (options?: {
|
|
|
243
245
|
return Stream.fromArray(initial).pipe(Stream.concat(Stream.fromSubscription(subscription)))
|
|
244
246
|
},
|
|
245
247
|
Effect.orDie,
|
|
248
|
+
withTracerDisabled,
|
|
246
249
|
Stream.unwrap
|
|
247
250
|
)
|
|
248
251
|
})
|
|
249
|
-
})
|
|
252
|
+
}).pipe(withTracerDisabled)
|
|
250
253
|
|
|
251
254
|
const EncryptedRemoteEntrySql = Schema.Struct({
|
|
252
255
|
sequence: Schema.Number,
|
|
@@ -314,3 +317,5 @@ const makeEncryptedScopeKey = (
|
|
|
314
317
|
publicKey: string,
|
|
315
318
|
storeId: string
|
|
316
319
|
): string => `${publicKey}/${storeId}`
|
|
320
|
+
|
|
321
|
+
const withTracerDisabled = Effect.withTracerEnabled(false)
|