@livestore/utils 0.0.41-dev.0 → 0.0.41-dev.2
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/.tsbuildinfo.json +1 -1
- package/dist/effect/Effect.d.ts +6 -6
- package/dist/effect/Effect.d.ts.map +1 -1
- package/dist/effect/Effect.js.map +1 -1
- package/dist/effect/Error.d.ts +1 -1
- package/dist/effect/ServiceContext.d.ts +13 -13
- package/dist/effect/ServiceContext.d.ts.map +1 -1
- package/dist/effect/ServiceContext.js.map +1 -1
- package/package.json +6 -6
- package/src/effect/Effect.ts +6 -6
- package/src/effect/ServiceContext.ts +18 -18
package/dist/effect/Effect.d.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import type { Context } from 'effect';
|
|
2
2
|
import { Effect } from 'effect';
|
|
3
3
|
export * from 'effect/Effect';
|
|
4
|
-
export declare const log: <A>(message: A, ...rest: any[]) => Effect.Effect<
|
|
5
|
-
export declare const logWarn: <A>(message: A, ...rest: any[]) => Effect.Effect<
|
|
6
|
-
export declare const logError: <A>(message: A, ...rest: any[]) => Effect.Effect<
|
|
4
|
+
export declare const log: <A>(message: A, ...rest: any[]) => Effect.Effect<void>;
|
|
5
|
+
export declare const logWarn: <A>(message: A, ...rest: any[]) => Effect.Effect<void>;
|
|
6
|
+
export declare const logError: <A>(message: A, ...rest: any[]) => Effect.Effect<void>;
|
|
7
7
|
/** Logs both on errors and defects */
|
|
8
|
-
export declare const tapCauseLogPretty: <R, E, A>(eff: Effect.Effect<
|
|
9
|
-
export declare const tapSync: <A>(tapFn: (a: A) => unknown) => <R, E>(eff: Effect.Effect<
|
|
10
|
-
export declare const debugLogEnv: (msg?: string) => Effect.Effect<
|
|
8
|
+
export declare const tapCauseLogPretty: <R, E, A>(eff: Effect.Effect<A, E, R>) => Effect.Effect<A, E, R>;
|
|
9
|
+
export declare const tapSync: <A>(tapFn: (a: A) => unknown) => <R, E>(eff: Effect.Effect<A, E, R>) => Effect.Effect<A, E, R>;
|
|
10
|
+
export declare const debugLogEnv: (msg?: string) => Effect.Effect<Context.Context<never>>;
|
|
11
11
|
//# sourceMappingURL=Effect.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Effect.d.ts","sourceRoot":"","sources":["../../src/effect/Effect.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,QAAQ,CAAA;AACrC,OAAO,EAAS,MAAM,EAAQ,MAAM,QAAQ,CAAA;AAI5C,cAAc,eAAe,CAAA;AAE7B,eAAO,MAAM,GAAG,2BAA4B,GAAG,EAAE,KAAG,aAAa,CAAC,
|
|
1
|
+
{"version":3,"file":"Effect.d.ts","sourceRoot":"","sources":["../../src/effect/Effect.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,QAAQ,CAAA;AACrC,OAAO,EAAS,MAAM,EAAQ,MAAM,QAAQ,CAAA;AAI5C,cAAc,eAAe,CAAA;AAE7B,eAAO,MAAM,GAAG,2BAA4B,GAAG,EAAE,KAAG,aAAa,CAAC,IAAI,CAGlE,CAAA;AAEJ,eAAO,MAAM,OAAO,2BAA4B,GAAG,EAAE,KAAG,aAAa,CAAC,IAAI,CAGtE,CAAA;AAEJ,eAAO,MAAM,QAAQ,2BAA4B,GAAG,EAAE,KAAG,aAAa,CAAC,IAAI,CAGvE,CAAA;AAEJ,sCAAsC;AACtC,eAAO,MAAM,iBAAiB,kEAU1B,CAAA;AAEJ,eAAO,MAAM,OAAO,uBACG,OAAO,kEAEyB,CAAA;AAEvD,eAAO,MAAM,WAAW,SAAU,MAAM,KAAG,aAAa,CAAC,eAAe,CAAC,KAAK,CAAC,CAI5E,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Effect.js","sourceRoot":"","sources":["../../src/effect/Effect.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,EAAE,MAAM,EA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,GAAG,CAAC,EAAE,CAAC;QACjC,OAAO,MAAM,CAAC,IAAI,CAAA;IACpB,CAAC;IAED,MAAM,UAAU,GACd,OAAO,MAAM,KAAK,WAAW,CAAC,CAAC,CAAC,oBAAoB,CAAC,CAAC,CAAC,gBAAgB,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,gBAAgB,CAAA;IAEnH,OAAO,QAAQ,CAAC,YAAY,UAAU,EAAE,EAAE,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAA;AAC9D,CAAC,CAAC,CAAA;AAEJ,MAAM,CAAC,MAAM,OAAO,GAClB,CAAI,KAAwB,EAAE,EAAE,CAChC,CAAO,GAA2B,EAA0B,EAAE,CAC5D,MAAM,CAAC,GAAG,CAAC,GAAG,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAA;AAEvD,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,GAAY,EAAyC,EAAE,CACjF,IAAI,CACF,MAAM,CAAC,OAAO,EAAS,EACvB,MAAM,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,GAAG,IAAI,aAAa,EAAE,GAAG,CAAC,CAAC,CACpD,CAAA"}
|
package/dist/effect/Error.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
declare const UnknownError_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").Equals<
|
|
1
|
+
declare const UnknownError_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").Equals<A, {}> extends true ? void : { readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }) => import("effect/Cause").YieldableError & {
|
|
2
2
|
readonly _tag: "UnknownError";
|
|
3
3
|
} & Readonly<A>;
|
|
4
4
|
export declare class UnknownError extends UnknownError_base<{
|
|
@@ -1,37 +1,37 @@
|
|
|
1
1
|
import type { Runtime } from 'effect';
|
|
2
2
|
import { Effect, Exit, Layer } from 'effect';
|
|
3
3
|
export interface MainLayer<Ctx> {
|
|
4
|
-
layer: Layer.Layer<
|
|
5
|
-
close: Effect.Effect<
|
|
4
|
+
layer: Layer.Layer<Ctx>;
|
|
5
|
+
close: Effect.Effect<void>;
|
|
6
6
|
}
|
|
7
|
-
export declare const unsafeMainLayer: <Ctx>(original: Layer.Layer<
|
|
8
|
-
export declare const make: <TStaticData, Ctx>(staticData: TStaticData, runtime: Runtime.Runtime<Ctx>, close?: Effect.Effect<
|
|
7
|
+
export declare const unsafeMainLayer: <Ctx>(original: Layer.Layer<Ctx, never, never>) => MainLayer<Ctx>;
|
|
8
|
+
export declare const make: <TStaticData, Ctx>(staticData: TStaticData, runtime: Runtime.Runtime<Ctx>, close?: Effect.Effect<void>) => ServiceContext<Ctx, TStaticData>;
|
|
9
9
|
export interface ServiceContext<Ctx, TStaticData> {
|
|
10
|
-
readonly provide: <E, A>(self: Effect.Effect<
|
|
10
|
+
readonly provide: <E, A>(self: Effect.Effect<A, E, Ctx>) => Effect.Effect<A, E>;
|
|
11
11
|
/**
|
|
12
12
|
* Fire and Forget. Errors are logged however.
|
|
13
13
|
*/
|
|
14
|
-
readonly runWithErrorLog: <E, A>(self: Effect.Effect<
|
|
15
|
-
readonly runSync: <E, A>(self: Effect.Effect<
|
|
14
|
+
readonly runWithErrorLog: <E, A>(self: Effect.Effect<A, E, Ctx>) => AbortCallback;
|
|
15
|
+
readonly runSync: <E, A>(self: Effect.Effect<A, E, Ctx>) => A;
|
|
16
16
|
/**
|
|
17
17
|
* Fire and Forget. A promise that never fails nor returns any value.
|
|
18
18
|
* Errors are logged however.
|
|
19
19
|
*/
|
|
20
|
-
readonly runPromiseWithErrorLog: <E, A>(self: Effect.Effect<
|
|
20
|
+
readonly runPromiseWithErrorLog: <E, A>(self: Effect.Effect<A, E, Ctx>) => Promise<A | undefined>;
|
|
21
21
|
/**
|
|
22
22
|
* A Promise that never fails, the Resolved value is an Exit result that can be either Success or Failed
|
|
23
23
|
*/
|
|
24
|
-
readonly runPromiseExit: <E, A>(self: Effect.Effect<
|
|
25
|
-
readonly runPromise: <E, A>(self: Effect.Effect<
|
|
24
|
+
readonly runPromiseExit: <E, A>(self: Effect.Effect<A, E, Ctx>) => Promise<Exit.Exit<A, E>>;
|
|
25
|
+
readonly runPromise: <E, A>(self: Effect.Effect<A, E, Ctx>) => Promise<A>;
|
|
26
26
|
readonly withRuntime: (fn: (runtime: Runtime.Runtime<Ctx>) => void) => void;
|
|
27
27
|
/** Closes the ServiceContext and closing all its layers */
|
|
28
|
-
readonly close: Effect.Effect<
|
|
28
|
+
readonly close: Effect.Effect<void>;
|
|
29
29
|
readonly closePromise: () => Promise<void>;
|
|
30
30
|
readonly staticData: TStaticData;
|
|
31
31
|
}
|
|
32
32
|
export type AbortCallback = () => void;
|
|
33
|
-
export declare const runWithErrorLog: <E, A>(self: Effect.Effect<
|
|
34
|
-
export declare const runPromiseWithErrorLog: <E, A>(self: Effect.Effect<
|
|
33
|
+
export declare const runWithErrorLog: <E, A>(self: Effect.Effect<A, E, never>) => () => void;
|
|
34
|
+
export declare const runPromiseWithErrorLog: <E, A>(self: Effect.Effect<A, E, never>) => Promise<A | undefined>;
|
|
35
35
|
export declare const MissingContext: Effect.Effect<never, never, never>;
|
|
36
36
|
export declare const empty: <Ctx, TStaticData>() => ServiceContext<Ctx, TStaticData>;
|
|
37
37
|
//# sourceMappingURL=ServiceContext.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ServiceContext.d.ts","sourceRoot":"","sources":["../../src/effect/ServiceContext.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,QAAQ,CAAA;AACrC,OAAO,EAAS,MAAM,EAAE,IAAI,EAAS,KAAK,EAAe,MAAM,QAAQ,CAAA;AAEvE,MAAM,WAAW,SAAS,CA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
|
3
|
-
"version": "0.0.41-dev.
|
|
3
|
+
"version": "0.0.41-dev.2",
|
|
4
4
|
"sideEffects": false,
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
@@ -31,17 +31,17 @@
|
|
|
31
31
|
}
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
34
|
-
"@effect/opentelemetry": "^0.
|
|
35
|
-
"@effect/schema": "0.
|
|
34
|
+
"@effect/opentelemetry": "^0.31.8",
|
|
35
|
+
"@effect/schema": "0.62.8",
|
|
36
36
|
"@opentelemetry/api": "^1.7.0",
|
|
37
37
|
"date-fns": "^3.3.1",
|
|
38
|
-
"effect": "2.
|
|
38
|
+
"effect": "2.3.7",
|
|
39
39
|
"otel-websocket-exporter": "^0.0.27",
|
|
40
40
|
"pretty-bytes": "^6.1.1"
|
|
41
41
|
},
|
|
42
42
|
"devDependencies": {
|
|
43
|
-
"@types/node": "^20.11.
|
|
44
|
-
"@types/web": "^0.0.
|
|
43
|
+
"@types/node": "^20.11.19",
|
|
44
|
+
"@types/web": "^0.0.139"
|
|
45
45
|
},
|
|
46
46
|
"publishConfig": {
|
|
47
47
|
"access": "public"
|
package/src/effect/Effect.ts
CHANGED
|
@@ -5,23 +5,23 @@ import { isNonEmptyString } from '../index.js'
|
|
|
5
5
|
|
|
6
6
|
export * from 'effect/Effect'
|
|
7
7
|
|
|
8
|
-
export const log = <A>(message: A, ...rest: any[]): Effect.Effect<
|
|
8
|
+
export const log = <A>(message: A, ...rest: any[]): Effect.Effect<void> =>
|
|
9
9
|
Effect.sync(() => {
|
|
10
10
|
console.log(message, ...rest)
|
|
11
11
|
})
|
|
12
12
|
|
|
13
|
-
export const logWarn = <A>(message: A, ...rest: any[]): Effect.Effect<
|
|
13
|
+
export const logWarn = <A>(message: A, ...rest: any[]): Effect.Effect<void> =>
|
|
14
14
|
Effect.sync(() => {
|
|
15
15
|
console.warn(message, ...rest)
|
|
16
16
|
})
|
|
17
17
|
|
|
18
|
-
export const logError = <A>(message: A, ...rest: any[]): Effect.Effect<
|
|
18
|
+
export const logError = <A>(message: A, ...rest: any[]): Effect.Effect<void> =>
|
|
19
19
|
Effect.sync(() => {
|
|
20
20
|
console.error(message, ...rest)
|
|
21
21
|
})
|
|
22
22
|
|
|
23
23
|
/** Logs both on errors and defects */
|
|
24
|
-
export const tapCauseLogPretty = <R, E, A>(eff: Effect.Effect<
|
|
24
|
+
export const tapCauseLogPretty = <R, E, A>(eff: Effect.Effect<A, E, R>): Effect.Effect<A, E, R> =>
|
|
25
25
|
Effect.tapErrorCause(eff, (err) => {
|
|
26
26
|
if (Cause.isInterruptedOnly(err)) {
|
|
27
27
|
return Effect.unit
|
|
@@ -35,10 +35,10 @@ export const tapCauseLogPretty = <R, E, A>(eff: Effect.Effect<R, E, A>): Effect.
|
|
|
35
35
|
|
|
36
36
|
export const tapSync =
|
|
37
37
|
<A>(tapFn: (a: A) => unknown) =>
|
|
38
|
-
<R, E>(eff: Effect.Effect<
|
|
38
|
+
<R, E>(eff: Effect.Effect<A, E, R>): Effect.Effect<A, E, R> =>
|
|
39
39
|
Effect.tap(eff, (a) => Effect.sync(() => tapFn(a)))
|
|
40
40
|
|
|
41
|
-
export const debugLogEnv = (msg?: string): Effect.Effect<
|
|
41
|
+
export const debugLogEnv = (msg?: string): Effect.Effect<Context.Context<never>> =>
|
|
42
42
|
pipe(
|
|
43
43
|
Effect.context<never>(),
|
|
44
44
|
Effect.tap((env) => log(msg ?? 'debugLogEnv', env)),
|
|
@@ -2,11 +2,11 @@ import type { Runtime } from 'effect'
|
|
|
2
2
|
import { Cause, Effect, Exit, Fiber, Layer, pipe, Scope } from 'effect'
|
|
3
3
|
|
|
4
4
|
export interface MainLayer<Ctx> {
|
|
5
|
-
layer: Layer.Layer<
|
|
6
|
-
close: Effect.Effect<
|
|
5
|
+
layer: Layer.Layer<Ctx>
|
|
6
|
+
close: Effect.Effect<void>
|
|
7
7
|
}
|
|
8
8
|
|
|
9
|
-
export const unsafeMainLayer = <Ctx>(original: Layer.Layer<
|
|
9
|
+
export const unsafeMainLayer = <Ctx>(original: Layer.Layer<Ctx>): MainLayer<Ctx> => {
|
|
10
10
|
const scope = Effect.runSync(Scope.make())
|
|
11
11
|
const layer = pipe(
|
|
12
12
|
original,
|
|
@@ -21,16 +21,16 @@ export const unsafeMainLayer = <Ctx>(original: Layer.Layer<never, never, Ctx>):
|
|
|
21
21
|
export const make = <TStaticData, Ctx>(
|
|
22
22
|
staticData: TStaticData,
|
|
23
23
|
runtime: Runtime.Runtime<Ctx>,
|
|
24
|
-
close: Effect.Effect<
|
|
24
|
+
close: Effect.Effect<void> = Effect.dieMessage('close not implemented'),
|
|
25
25
|
): ServiceContext<Ctx, TStaticData> => {
|
|
26
26
|
return {
|
|
27
27
|
provide: (self) => Effect.provide(runtime)(self),
|
|
28
|
-
runWithErrorLog: <E, A>(self: Effect.Effect<
|
|
29
|
-
runSync: <E, A>(self: Effect.Effect<
|
|
30
|
-
runPromiseWithErrorLog: <E, A>(self: Effect.Effect<
|
|
28
|
+
runWithErrorLog: <E, A>(self: Effect.Effect<A, E, Ctx>) => runWithErrorLog(Effect.provide(runtime)(self)),
|
|
29
|
+
runSync: <E, A>(self: Effect.Effect<A, E, Ctx>) => Effect.runSync(Effect.provide(runtime)(self)),
|
|
30
|
+
runPromiseWithErrorLog: <E, A>(self: Effect.Effect<A, E, Ctx>) =>
|
|
31
31
|
runPromiseWithErrorLog(Effect.provide(runtime)(self)),
|
|
32
|
-
runPromiseExit: <E, A>(self: Effect.Effect<
|
|
33
|
-
runPromise: <E, A>(self: Effect.Effect<
|
|
32
|
+
runPromiseExit: <E, A>(self: Effect.Effect<A, E, Ctx>) => Effect.runPromiseExit(Effect.provide(runtime)(self)),
|
|
33
|
+
runPromise: <E, A>(self: Effect.Effect<A, E, Ctx>) => Effect.runPromise(Effect.provide(runtime)(self)),
|
|
34
34
|
withRuntime: (fn) => fn(runtime),
|
|
35
35
|
close: close,
|
|
36
36
|
closePromise: () => Effect.runPromise(close),
|
|
@@ -39,38 +39,38 @@ export const make = <TStaticData, Ctx>(
|
|
|
39
39
|
}
|
|
40
40
|
|
|
41
41
|
export interface ServiceContext<Ctx, TStaticData> {
|
|
42
|
-
readonly provide: <E, A>(self: Effect.Effect<
|
|
42
|
+
readonly provide: <E, A>(self: Effect.Effect<A, E, Ctx>) => Effect.Effect<A, E>
|
|
43
43
|
|
|
44
44
|
/**
|
|
45
45
|
* Fire and Forget. Errors are logged however.
|
|
46
46
|
*/
|
|
47
|
-
readonly runWithErrorLog: <E, A>(self: Effect.Effect<
|
|
47
|
+
readonly runWithErrorLog: <E, A>(self: Effect.Effect<A, E, Ctx>) => AbortCallback
|
|
48
48
|
|
|
49
|
-
readonly runSync: <E, A>(self: Effect.Effect<
|
|
49
|
+
readonly runSync: <E, A>(self: Effect.Effect<A, E, Ctx>) => A
|
|
50
50
|
|
|
51
51
|
/**
|
|
52
52
|
* Fire and Forget. A promise that never fails nor returns any value.
|
|
53
53
|
* Errors are logged however.
|
|
54
54
|
*/
|
|
55
|
-
readonly runPromiseWithErrorLog: <E, A>(self: Effect.Effect<
|
|
55
|
+
readonly runPromiseWithErrorLog: <E, A>(self: Effect.Effect<A, E, Ctx>) => Promise<A | undefined>
|
|
56
56
|
|
|
57
57
|
/**
|
|
58
58
|
* A Promise that never fails, the Resolved value is an Exit result that can be either Success or Failed
|
|
59
59
|
*/
|
|
60
|
-
readonly runPromiseExit: <E, A>(self: Effect.Effect<
|
|
61
|
-
readonly runPromise: <E, A>(self: Effect.Effect<
|
|
60
|
+
readonly runPromiseExit: <E, A>(self: Effect.Effect<A, E, Ctx>) => Promise<Exit.Exit<A, E>>
|
|
61
|
+
readonly runPromise: <E, A>(self: Effect.Effect<A, E, Ctx>) => Promise<A>
|
|
62
62
|
|
|
63
63
|
readonly withRuntime: (fn: (runtime: Runtime.Runtime<Ctx>) => void) => void
|
|
64
64
|
|
|
65
65
|
/** Closes the ServiceContext and closing all its layers */
|
|
66
|
-
readonly close: Effect.Effect<
|
|
66
|
+
readonly close: Effect.Effect<void>
|
|
67
67
|
readonly closePromise: () => Promise<void>
|
|
68
68
|
readonly staticData: TStaticData
|
|
69
69
|
}
|
|
70
70
|
|
|
71
71
|
export type AbortCallback = () => void
|
|
72
72
|
|
|
73
|
-
export const runWithErrorLog = <E, A>(self: Effect.Effect<
|
|
73
|
+
export const runWithErrorLog = <E, A>(self: Effect.Effect<A, E>) => {
|
|
74
74
|
const fiber = Effect.runFork(self)
|
|
75
75
|
fiber.addObserver((ex) => {
|
|
76
76
|
if (ex._tag === 'Failure' && Cause.isInterruptedOnly(ex.cause) === false) {
|
|
@@ -82,7 +82,7 @@ export const runWithErrorLog = <E, A>(self: Effect.Effect<never, E, A>) => {
|
|
|
82
82
|
}
|
|
83
83
|
}
|
|
84
84
|
|
|
85
|
-
export const runPromiseWithErrorLog = <E, A>(self: Effect.Effect<
|
|
85
|
+
export const runPromiseWithErrorLog = <E, A>(self: Effect.Effect<A, E>) =>
|
|
86
86
|
Effect.runPromiseExit(self).then((ex) => {
|
|
87
87
|
if (ex._tag === 'Failure') {
|
|
88
88
|
console.error(Cause.pretty(ex.cause))
|