effect 4.0.0-beta.41 → 4.0.0-beta.42
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/Effect.d.ts +19 -63
- package/dist/Effect.d.ts.map +1 -1
- package/dist/Effect.js +24 -65
- package/dist/Effect.js.map +1 -1
- package/dist/MutableList.d.ts.map +1 -1
- package/dist/MutableList.js +3 -0
- package/dist/MutableList.js.map +1 -1
- package/dist/Number.d.ts.map +1 -1
- package/dist/Number.js +12 -3
- package/dist/Number.js.map +1 -1
- package/dist/SchemaRepresentation.d.ts.map +1 -1
- package/dist/SchemaRepresentation.js +16 -14
- package/dist/SchemaRepresentation.js.map +1 -1
- package/dist/TxChunk.d.ts +39 -39
- 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 +9 -9
- package/dist/TxDeferred.d.ts.map +1 -1
- package/dist/TxDeferred.js +2 -2
- package/dist/TxDeferred.js.map +1 -1
- package/dist/TxHashMap.d.ts +59 -59
- package/dist/TxHashMap.d.ts.map +1 -1
- package/dist/TxHashMap.js +8 -8
- 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 +7 -7
- package/dist/TxHashSet.js.map +1 -1
- package/dist/TxPriorityQueue.d.ts +23 -23
- package/dist/TxPriorityQueue.d.ts.map +1 -1
- package/dist/TxPriorityQueue.js +4 -4
- package/dist/TxPriorityQueue.js.map +1 -1
- package/dist/TxPubSub.d.ts +14 -14
- package/dist/TxPubSub.d.ts.map +1 -1
- package/dist/TxPubSub.js +12 -12
- package/dist/TxPubSub.js.map +1 -1
- package/dist/TxQueue.d.ts +33 -33
- package/dist/TxQueue.d.ts.map +1 -1
- package/dist/TxQueue.js +29 -44
- package/dist/TxQueue.js.map +1 -1
- package/dist/TxReentrantLock.d.ts +10 -33
- package/dist/TxReentrantLock.d.ts.map +1 -1
- package/dist/TxReentrantLock.js +14 -37
- package/dist/TxReentrantLock.js.map +1 -1
- package/dist/TxRef.d.ts +36 -42
- package/dist/TxRef.d.ts.map +1 -1
- package/dist/TxRef.js +16 -25
- 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 +10 -10
- package/dist/TxSemaphore.js.map +1 -1
- package/dist/TxSubscriptionRef.d.ts +14 -14
- package/dist/TxSubscriptionRef.d.ts.map +1 -1
- package/dist/TxSubscriptionRef.js +5 -5
- package/dist/TxSubscriptionRef.js.map +1 -1
- package/dist/index.d.ts +3 -3
- package/dist/index.js +3 -3
- package/dist/unstable/ai/OpenAiStructuredOutput.js +3 -0
- package/dist/unstable/ai/OpenAiStructuredOutput.js.map +1 -1
- package/dist/unstable/cli/internal/command.d.ts.map +1 -1
- package/dist/unstable/cli/internal/command.js +12 -1
- package/dist/unstable/cli/internal/command.js.map +1 -1
- package/dist/unstable/cluster/SqlMessageStorage.d.ts.map +1 -1
- package/dist/unstable/cluster/SqlMessageStorage.js +1 -4
- package/dist/unstable/cluster/SqlMessageStorage.js.map +1 -1
- package/dist/unstable/socket/Socket.d.ts +1 -1
- package/dist/unstable/socket/Socket.d.ts.map +1 -1
- package/dist/unstable/socket/Socket.js +1 -1
- package/dist/unstable/socket/Socket.js.map +1 -1
- package/package.json +1 -1
- package/src/Effect.ts +24 -75
- package/src/MutableList.ts +3 -0
- package/src/Number.ts +13 -3
- package/src/SchemaRepresentation.ts +8 -6
- package/src/TxChunk.ts +53 -62
- package/src/TxDeferred.ts +14 -17
- package/src/TxHashMap.ts +91 -101
- package/src/TxHashSet.ts +68 -70
- package/src/TxPriorityQueue.ts +34 -38
- package/src/TxPubSub.ts +30 -32
- package/src/TxQueue.ts +70 -84
- package/src/TxReentrantLock.ts +30 -54
- package/src/TxRef.ts +53 -65
- package/src/TxSemaphore.ts +23 -24
- package/src/TxSubscriptionRef.ts +25 -27
- package/src/index.ts +3 -3
- package/src/unstable/ai/OpenAiStructuredOutput.ts +3 -0
- package/src/unstable/cli/internal/command.ts +16 -1
- package/src/unstable/cluster/SqlMessageStorage.ts +0 -4
- package/src/unstable/socket/Socket.ts +1 -1
package/src/TxSubscriptionRef.ts
CHANGED
|
@@ -92,7 +92,7 @@ const TxSubscriptionRefProto: Omit<TxSubscriptionRef<any>, typeof TypeId | "ref"
|
|
|
92
92
|
* @since 4.0.0
|
|
93
93
|
* @category constructors
|
|
94
94
|
*/
|
|
95
|
-
export const make = <A>(value: A): Effect.Effect<TxSubscriptionRef<A
|
|
95
|
+
export const make = <A>(value: A): Effect.Effect<TxSubscriptionRef<A>> =>
|
|
96
96
|
Effect.gen(function*() {
|
|
97
97
|
const ref = yield* TxRef.make(value)
|
|
98
98
|
const pubsub = yield* TxPubSub.unbounded<A>()
|
|
@@ -101,7 +101,7 @@ export const make = <A>(value: A): Effect.Effect<TxSubscriptionRef<A>, never, Ef
|
|
|
101
101
|
self.ref = ref
|
|
102
102
|
self.pubsub = pubsub
|
|
103
103
|
return self
|
|
104
|
-
})
|
|
104
|
+
}).pipe(Effect.tx)
|
|
105
105
|
|
|
106
106
|
// =============================================================================
|
|
107
107
|
// Getters
|
|
@@ -124,7 +124,7 @@ export const make = <A>(value: A): Effect.Effect<TxSubscriptionRef<A>, never, Ef
|
|
|
124
124
|
* @since 4.0.0
|
|
125
125
|
* @category getters
|
|
126
126
|
*/
|
|
127
|
-
export const get = <A>(self: TxSubscriptionRef<A>): Effect.Effect<A
|
|
127
|
+
export const get = <A>(self: TxSubscriptionRef<A>): Effect.Effect<A> => TxRef.get(self.ref)
|
|
128
128
|
|
|
129
129
|
// =============================================================================
|
|
130
130
|
// Mutations
|
|
@@ -173,7 +173,7 @@ export const modify: {
|
|
|
173
173
|
* @since 4.0.0
|
|
174
174
|
* @category mutations
|
|
175
175
|
*/
|
|
176
|
-
<A, B>(f: (current: A) => [returnValue: B, newValue: A]): (self: TxSubscriptionRef<A>) => Effect.Effect<B
|
|
176
|
+
<A, B>(f: (current: A) => [returnValue: B, newValue: A]): (self: TxSubscriptionRef<A>) => Effect.Effect<B>
|
|
177
177
|
// =============================================================================
|
|
178
178
|
// Mutations
|
|
179
179
|
// =============================================================================
|
|
@@ -200,20 +200,20 @@ export const modify: {
|
|
|
200
200
|
<A, B>(
|
|
201
201
|
self: TxSubscriptionRef<A>,
|
|
202
202
|
f: (current: A) => [returnValue: B, newValue: A]
|
|
203
|
-
): Effect.Effect<B
|
|
203
|
+
): Effect.Effect<B>
|
|
204
204
|
} = dual(
|
|
205
205
|
2,
|
|
206
206
|
<A, B>(
|
|
207
207
|
self: TxSubscriptionRef<A>,
|
|
208
208
|
f: (current: A) => [returnValue: B, newValue: A]
|
|
209
|
-
): Effect.Effect<B
|
|
209
|
+
): Effect.Effect<B> =>
|
|
210
210
|
Effect.gen(function*() {
|
|
211
211
|
const current = yield* TxRef.get(self.ref)
|
|
212
212
|
const [returnValue, newValue] = f(current)
|
|
213
213
|
yield* TxRef.set(self.ref, newValue)
|
|
214
214
|
yield* TxPubSub.publish(self.pubsub, newValue)
|
|
215
215
|
return returnValue
|
|
216
|
-
})
|
|
216
|
+
}).pipe(Effect.tx)
|
|
217
217
|
)
|
|
218
218
|
|
|
219
219
|
/**
|
|
@@ -251,7 +251,7 @@ export const set: {
|
|
|
251
251
|
* @since 4.0.0
|
|
252
252
|
* @category mutations
|
|
253
253
|
*/
|
|
254
|
-
<A>(value: A): (self: TxSubscriptionRef<A>) => Effect.Effect<void
|
|
254
|
+
<A>(value: A): (self: TxSubscriptionRef<A>) => Effect.Effect<void>
|
|
255
255
|
/**
|
|
256
256
|
* Sets the value of the TxSubscriptionRef and publishes the new value to all subscribers.
|
|
257
257
|
*
|
|
@@ -269,11 +269,10 @@ export const set: {
|
|
|
269
269
|
* @since 4.0.0
|
|
270
270
|
* @category mutations
|
|
271
271
|
*/
|
|
272
|
-
<A>(self: TxSubscriptionRef<A>, value: A): Effect.Effect<void
|
|
272
|
+
<A>(self: TxSubscriptionRef<A>, value: A): Effect.Effect<void>
|
|
273
273
|
} = dual(
|
|
274
274
|
2,
|
|
275
|
-
<A>(self: TxSubscriptionRef<A>, value: A): Effect.Effect<void
|
|
276
|
-
modify(self, () => [void 0, value])
|
|
275
|
+
<A>(self: TxSubscriptionRef<A>, value: A): Effect.Effect<void> => modify(self, () => [void 0, value])
|
|
277
276
|
)
|
|
278
277
|
|
|
279
278
|
/**
|
|
@@ -313,7 +312,7 @@ export const update: {
|
|
|
313
312
|
* @since 4.0.0
|
|
314
313
|
* @category mutations
|
|
315
314
|
*/
|
|
316
|
-
<A>(f: (current: A) => A): (self: TxSubscriptionRef<A>) => Effect.Effect<void
|
|
315
|
+
<A>(f: (current: A) => A): (self: TxSubscriptionRef<A>) => Effect.Effect<void>
|
|
317
316
|
/**
|
|
318
317
|
* Updates the value of the TxSubscriptionRef using a function and publishes the new
|
|
319
318
|
* value to all subscribers.
|
|
@@ -332,10 +331,10 @@ export const update: {
|
|
|
332
331
|
* @since 4.0.0
|
|
333
332
|
* @category mutations
|
|
334
333
|
*/
|
|
335
|
-
<A>(self: TxSubscriptionRef<A>, f: (current: A) => A): Effect.Effect<void
|
|
334
|
+
<A>(self: TxSubscriptionRef<A>, f: (current: A) => A): Effect.Effect<void>
|
|
336
335
|
} = dual(
|
|
337
336
|
2,
|
|
338
|
-
<A>(self: TxSubscriptionRef<A>, f: (current: A) => A): Effect.Effect<void
|
|
337
|
+
<A>(self: TxSubscriptionRef<A>, f: (current: A) => A): Effect.Effect<void> =>
|
|
339
338
|
modify(self, (current) => [void 0, f(current)])
|
|
340
339
|
)
|
|
341
340
|
|
|
@@ -378,7 +377,7 @@ export const getAndSet: {
|
|
|
378
377
|
* @since 4.0.0
|
|
379
378
|
* @category mutations
|
|
380
379
|
*/
|
|
381
|
-
<A>(value: A): (self: TxSubscriptionRef<A>) => Effect.Effect<A
|
|
380
|
+
<A>(value: A): (self: TxSubscriptionRef<A>) => Effect.Effect<A>
|
|
382
381
|
/**
|
|
383
382
|
* Gets the current value and sets a new value atomically. Publishes the new value
|
|
384
383
|
* to all subscribers.
|
|
@@ -398,11 +397,10 @@ export const getAndSet: {
|
|
|
398
397
|
* @since 4.0.0
|
|
399
398
|
* @category mutations
|
|
400
399
|
*/
|
|
401
|
-
<A>(self: TxSubscriptionRef<A>, value: A): Effect.Effect<A
|
|
400
|
+
<A>(self: TxSubscriptionRef<A>, value: A): Effect.Effect<A>
|
|
402
401
|
} = dual(
|
|
403
402
|
2,
|
|
404
|
-
<A>(self: TxSubscriptionRef<A>, value: A): Effect.Effect<A
|
|
405
|
-
modify(self, (current) => [current, value])
|
|
403
|
+
<A>(self: TxSubscriptionRef<A>, value: A): Effect.Effect<A> => modify(self, (current) => [current, value])
|
|
406
404
|
)
|
|
407
405
|
|
|
408
406
|
/**
|
|
@@ -444,7 +442,7 @@ export const getAndUpdate: {
|
|
|
444
442
|
* @since 4.0.0
|
|
445
443
|
* @category mutations
|
|
446
444
|
*/
|
|
447
|
-
<A>(f: (current: A) => A): (self: TxSubscriptionRef<A>) => Effect.Effect<A
|
|
445
|
+
<A>(f: (current: A) => A): (self: TxSubscriptionRef<A>) => Effect.Effect<A>
|
|
448
446
|
/**
|
|
449
447
|
* Gets the current value and updates it using a function atomically. Publishes
|
|
450
448
|
* the new value to all subscribers.
|
|
@@ -464,10 +462,10 @@ export const getAndUpdate: {
|
|
|
464
462
|
* @since 4.0.0
|
|
465
463
|
* @category mutations
|
|
466
464
|
*/
|
|
467
|
-
<A>(self: TxSubscriptionRef<A>, f: (current: A) => A): Effect.Effect<A
|
|
465
|
+
<A>(self: TxSubscriptionRef<A>, f: (current: A) => A): Effect.Effect<A>
|
|
468
466
|
} = dual(
|
|
469
467
|
2,
|
|
470
|
-
<A>(self: TxSubscriptionRef<A>, f: (current: A) => A): Effect.Effect<A
|
|
468
|
+
<A>(self: TxSubscriptionRef<A>, f: (current: A) => A): Effect.Effect<A> =>
|
|
471
469
|
modify(self, (current) => [current, f(current)])
|
|
472
470
|
)
|
|
473
471
|
|
|
@@ -508,7 +506,7 @@ export const updateAndGet: {
|
|
|
508
506
|
* @since 4.0.0
|
|
509
507
|
* @category mutations
|
|
510
508
|
*/
|
|
511
|
-
<A>(f: (current: A) => A): (self: TxSubscriptionRef<A>) => Effect.Effect<A
|
|
509
|
+
<A>(f: (current: A) => A): (self: TxSubscriptionRef<A>) => Effect.Effect<A>
|
|
512
510
|
/**
|
|
513
511
|
* Updates the value using a function and returns the new value. Publishes the
|
|
514
512
|
* new value to all subscribers.
|
|
@@ -527,10 +525,10 @@ export const updateAndGet: {
|
|
|
527
525
|
* @since 4.0.0
|
|
528
526
|
* @category mutations
|
|
529
527
|
*/
|
|
530
|
-
<A>(self: TxSubscriptionRef<A>, f: (current: A) => A): Effect.Effect<A
|
|
528
|
+
<A>(self: TxSubscriptionRef<A>, f: (current: A) => A): Effect.Effect<A>
|
|
531
529
|
} = dual(
|
|
532
530
|
2,
|
|
533
|
-
<A>(self: TxSubscriptionRef<A>, f: (current: A) => A): Effect.Effect<A
|
|
531
|
+
<A>(self: TxSubscriptionRef<A>, f: (current: A) => A): Effect.Effect<A> =>
|
|
534
532
|
modify(self, (current) => {
|
|
535
533
|
const newValue = f(current)
|
|
536
534
|
return [newValue, newValue]
|
|
@@ -573,7 +571,7 @@ export const changes = <A>(
|
|
|
573
571
|
self: TxSubscriptionRef<A>
|
|
574
572
|
): Effect.Effect<TxQueue.TxQueue<A>, never, Scope.Scope> =>
|
|
575
573
|
Effect.acquireRelease(
|
|
576
|
-
Effect.
|
|
574
|
+
Effect.tx(
|
|
577
575
|
Effect.gen(function*() {
|
|
578
576
|
const sub = yield* TxPubSub.acquireSubscriber(self.pubsub)
|
|
579
577
|
const current = yield* TxRef.get(self.ref)
|
|
@@ -581,7 +579,7 @@ export const changes = <A>(
|
|
|
581
579
|
return sub
|
|
582
580
|
})
|
|
583
581
|
),
|
|
584
|
-
(queue) => Effect.
|
|
582
|
+
(queue) => Effect.tx(TxPubSub.releaseSubscriber(self.pubsub, queue))
|
|
585
583
|
)
|
|
586
584
|
|
|
587
585
|
/**
|
|
@@ -611,7 +609,7 @@ export const changesStream = <A>(self: TxSubscriptionRef<A>): Stream.Stream<A, n
|
|
|
611
609
|
Stream.unwrap(
|
|
612
610
|
Effect.map(
|
|
613
611
|
changes(self),
|
|
614
|
-
(sub) => Stream.fromEffectRepeat(Effect.
|
|
612
|
+
(sub) => Stream.fromEffectRepeat(Effect.tx(TxQueue.take(sub)))
|
|
615
613
|
)
|
|
616
614
|
)
|
|
617
615
|
|
package/src/index.ts
CHANGED
|
@@ -4039,7 +4039,7 @@ export * as Tuple from "./Tuple.ts"
|
|
|
4039
4039
|
*
|
|
4040
4040
|
* Accessed values are tracked by the transaction in order to detect conflicts and to track changes.
|
|
4041
4041
|
* A transaction will retry whenever a conflict is detected or whenever the transaction explicitly
|
|
4042
|
-
* calls `Effect.
|
|
4042
|
+
* calls `Effect.txRetry` and any of the accessed TxChunk values change.
|
|
4043
4043
|
*
|
|
4044
4044
|
* @since 4.0.0
|
|
4045
4045
|
*/
|
|
@@ -4089,7 +4089,7 @@ export * as TxPubSub from "./TxPubSub.ts"
|
|
|
4089
4089
|
*
|
|
4090
4090
|
* Accessed values are tracked by the transaction in order to detect conflicts and to track changes.
|
|
4091
4091
|
* A transaction will retry whenever a conflict is detected or whenever the transaction explicitly
|
|
4092
|
-
* calls `Effect.
|
|
4092
|
+
* calls `Effect.txRetry` and any of the accessed TxQueue values change.
|
|
4093
4093
|
*
|
|
4094
4094
|
* @since 4.0.0
|
|
4095
4095
|
*/
|
|
@@ -4110,7 +4110,7 @@ export * as TxReentrantLock from "./TxReentrantLock.ts"
|
|
|
4110
4110
|
*
|
|
4111
4111
|
* Accessed values are tracked by the transaction in order to detect conflicts and in order to
|
|
4112
4112
|
* track changes, a transaction will retry whenever a conflict is detected or whenever the
|
|
4113
|
-
* transaction explicitely calls to `Effect.
|
|
4113
|
+
* transaction explicitely calls to `Effect.txRetry` and any of the accessed TxRef values
|
|
4114
4114
|
* change.
|
|
4115
4115
|
*
|
|
4116
4116
|
* @since 4.0.0
|
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
import * as Arr from "../../../Array.ts"
|
|
9
9
|
import * as Effect from "../../../Effect.ts"
|
|
10
10
|
import { YieldableProto } from "../../../internal/core.ts"
|
|
11
|
+
import * as Option from "../../../Option.ts"
|
|
11
12
|
import { pipeArguments } from "../../../Pipeable.ts"
|
|
12
13
|
import * as Predicate from "../../../Predicate.ts"
|
|
13
14
|
import * as ServiceMap from "../../../ServiceMap.ts"
|
|
@@ -228,11 +229,25 @@ export const toFlagDoc = (single: Param.Single<typeof Param.flagKind, unknown>):
|
|
|
228
229
|
name: single.name,
|
|
229
230
|
aliases: formattedAliases,
|
|
230
231
|
type: single.typeName ?? Primitive.getTypeName(single.primitiveType),
|
|
231
|
-
description: single.description,
|
|
232
|
+
description: appendChoiceKeys(single.description, Primitive.getChoiceKeys(single.primitiveType)),
|
|
232
233
|
required: single.primitiveType._tag !== "Boolean"
|
|
233
234
|
}
|
|
234
235
|
}
|
|
235
236
|
|
|
237
|
+
const appendChoiceKeys = (
|
|
238
|
+
description: Option.Option<string>,
|
|
239
|
+
choiceKeys: ReadonlyArray<string> | undefined
|
|
240
|
+
): Option.Option<string> => {
|
|
241
|
+
if (choiceKeys === undefined || choiceKeys.length === 0) {
|
|
242
|
+
return description
|
|
243
|
+
}
|
|
244
|
+
const choiceSuffix = `(choices: ${choiceKeys.join(", ")})`
|
|
245
|
+
return Option.match(description, {
|
|
246
|
+
onNone: () => Option.some(choiceSuffix),
|
|
247
|
+
onSome: (value) => Option.some(`${value} ${choiceSuffix}`)
|
|
248
|
+
})
|
|
249
|
+
}
|
|
250
|
+
|
|
236
251
|
/**
|
|
237
252
|
* Creates a parser for a given config. Used as the default for both `parse`
|
|
238
253
|
* and `parseContext`, and also by `withSharedFlags` to avoid constructing a
|
|
@@ -596,10 +596,6 @@ export const make: (options?: {
|
|
|
596
596
|
|
|
597
597
|
withTransaction: (effect) =>
|
|
598
598
|
sql.withTransaction(effect).pipe(
|
|
599
|
-
Effect.retry({
|
|
600
|
-
while: (e) => isSqlError(e) && e.isRetryable,
|
|
601
|
-
times: 5
|
|
602
|
-
}),
|
|
603
599
|
Effect.catchIf(isSqlError, Effect.die)
|
|
604
600
|
)
|
|
605
601
|
})
|
|
@@ -392,7 +392,7 @@ export const makeChannel = <IE = never>(): Channel.Channel<
|
|
|
392
392
|
/**
|
|
393
393
|
* @since 4.0.0
|
|
394
394
|
*/
|
|
395
|
-
export const defaultCloseCodeIsError = (
|
|
395
|
+
export const defaultCloseCodeIsError = (_code: number) => true
|
|
396
396
|
|
|
397
397
|
/**
|
|
398
398
|
* @since 4.0.0
|