@effect-app/infra 0.25.8 → 0.25.9
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/CHANGELOG.md +11 -0
- package/_cjs/api/defaultErrorHandler.cjs +11 -16
- package/_cjs/api/defaultErrorHandler.cjs.map +1 -1
- package/_src/api/defaultErrorHandler.ts +12 -29
- package/dist/api/defaultErrorHandler.d.ts +2 -2
- package/dist/api/defaultErrorHandler.d.ts.map +1 -1
- package/dist/api/defaultErrorHandler.js +12 -17
- package/dist/services/simpledb/cosmosdb.d.ts +2 -2
- package/dist/services/simpledb/diskdb.d.ts +2 -2
- package/dist/services/simpledb/memdb.d.ts +2 -2
- package/dist/services/simpledb/mongodb.d.ts +2 -2
- package/dist/services/simpledb/redisdb.d.ts +2 -2
- package/dist/services/simpledb/simpledb.d.ts +3 -3
- package/package.json +5 -5
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,16 @@
|
|
|
1
1
|
# @effect-app/infra
|
|
2
2
|
|
|
3
|
+
## 0.25.9
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 8da4c8fc: Add match and improve error handling
|
|
8
|
+
- Updated dependencies [8da4c8fc]
|
|
9
|
+
- @effect-app/core@0.23.1
|
|
10
|
+
- @effect-app/infra-adapters@0.20.5
|
|
11
|
+
- @effect-app/prelude@0.21.5
|
|
12
|
+
- @effect-app/schema@0.18.4
|
|
13
|
+
|
|
3
14
|
## 0.25.8
|
|
4
15
|
|
|
5
16
|
### Patch Changes
|
|
@@ -14,29 +14,24 @@ var _reportError = require("./reportError.cjs");
|
|
|
14
14
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
15
15
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
16
16
|
function defaultBasicErrorHandler(_req, res, _requestContext, r2) {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
}))
|
|
17
|
+
const sendError = code => body => tsplus_module_1.sync(() => res.status(code).send(body));
|
|
18
|
+
return tsplus_module_4.untraced(() => tsplus_module_1.catchAll(tsplus_module_1.catchTag(tsplus_module_1.tapErrorCause(r2, cause => tsplus_module_2.isFailure(cause) ? (0, _reportError.logRequestError)(cause) : tsplus_module_3.unit), "ValidationError", err => sendError(400)(err.errors))
|
|
20
19
|
// final catch all; expecting never so that unhandled known errors will show up
|
|
21
20
|
, err => tsplus_module_1.flatMap(tsplus_module_1.map(tsplus_module_1.logError("Program error, compiler probably silenced, got an unsupported Error in Error Channel of Effect" + err), () => err), tsplus_module_1.die)));
|
|
22
21
|
}
|
|
23
22
|
const optimisticConcurrencySchedule = tsplus_module_5.intersect(tsplus_module_5.recurWhile(a => a._tag === "OptimisticConcurrencyException"))(tsplus_module_5.once());
|
|
24
23
|
function defaultErrorHandler(req, res, _, r2) {
|
|
25
24
|
const r3 = req.method === "PATCH" ? tsplus_module_1.retry(r2, optimisticConcurrencySchedule) : r2;
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
res.status(403).send(err);
|
|
34
|
-
})), "InvalidStateError", err => tsplus_module_1.sync(() => {
|
|
35
|
-
res.status(422).send(err);
|
|
36
|
-
})), "OptimisticConcurrencyException", err => tsplus_module_1.sync(() => {
|
|
25
|
+
const sendError = code => body => tsplus_module_1.sync(() => res.status(code).send(body));
|
|
26
|
+
return tsplus_module_4.untraced(() => tsplus_module_1.catchAll(tsplus_module_1.catchTags(tsplus_module_1.tapErrorCause(r3, cause => tsplus_module_2.isFailure(cause) ? (0, _reportError.logRequestError)(cause) : tsplus_module_3.unit), {
|
|
27
|
+
"ValidationError": err => sendError(400)(err.errors),
|
|
28
|
+
"NotFoundError": sendError(404),
|
|
29
|
+
"NotLoggedInError": sendError(401),
|
|
30
|
+
"UnauthorizedError": sendError(403),
|
|
31
|
+
"InvalidStateError": sendError(422),
|
|
37
32
|
// 412 or 409.. https://stackoverflow.com/questions/19122088/which-http-status-code-to-use-to-reject-a-put-due-to-optimistic-locking-failure
|
|
38
|
-
|
|
39
|
-
})
|
|
33
|
+
"OptimisticConcurrencyException": sendError(412)
|
|
34
|
+
})
|
|
40
35
|
// final catch all; expecting never so that unhandled known errors will show up
|
|
41
36
|
, err => tsplus_module_1.flatMap(tsplus_module_1.map(tsplus_module_1.logError("Program error, compiler probably silenced, got an unsupported Error in Error Channel of Effect" + err), () => err), tsplus_module_1.die)));
|
|
42
37
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"defaultErrorHandler.cjs","mappings":";;;;;;;;;;;;AAUA;AAAkD;AAAA;AAE5C,SAAUA,wBAAwB,CACtCC,IAAqB,EACrBC,GAAqB,EACrBC,eAA+B,EAC/BC,EAAoC;EAEpC,
|
|
1
|
+
{"version":3,"file":"defaultErrorHandler.cjs","mappings":";;;;;;;;;;;;AAUA;AAAkD;AAAA;AAE5C,SAAUA,wBAAwB,CACtCC,IAAqB,EACrBC,GAAqB,EACrBC,eAA+B,EAC/BC,EAAoC;EAEpC,MAAMC,SAAS,GAAIC,IAAY,IA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,CAAC,GAAG,CAAC;IACnC;IACA,gCAAgC,EAAEA,SAAS,CAAC,GAAG;GAChD;EACD;EAAA,EACWU,GAAU,IACnBP,qEACE,gGAAgG,GAAGO,GAAG,CACvG,EACM,MAAMA,GAAc,CAAC,sBACN,CACvB,CACJ;AACH","names":["defaultBasicErrorHandler","_req","res","_requestContext","r2","sendError","code","body","tsplus_module_1","status","send","tsplus_module_4","cause","tsplus_module_2","tsplus_module_3","err","errors","optimisticConcurrencySchedule","tsplus_module_5","a","_tag","defaultErrorHandler","req","_","r3","method"],"sourceRoot":"","sources":["../../_src/api/defaultErrorHandler.ts"],"sourcesContent":[null]}
|
|
@@ -16,13 +16,11 @@ export function defaultBasicErrorHandler<R>(
|
|
|
16
16
|
_requestContext: RequestContext,
|
|
17
17
|
r2: Effect<R, ValidationError, void>
|
|
18
18
|
) {
|
|
19
|
+
const sendError = (code: number) => (body: unknown) => Effect(res.status(code).send(body))
|
|
19
20
|
return Debug.untraced(() =>
|
|
20
21
|
r2
|
|
21
22
|
.tapErrorCause(cause => cause.isFailure() ? logRequestError(cause) : Effect.unit)
|
|
22
|
-
.catchTag("ValidationError", err =>
|
|
23
|
-
Effect.sync(() => {
|
|
24
|
-
res.status(400).send(err.errors)
|
|
25
|
-
}))
|
|
23
|
+
.catchTag("ValidationError", err => sendError(400)(err.errors))
|
|
26
24
|
// final catch all; expecting never so that unhandled known errors will show up
|
|
27
25
|
.catchAll((err: never) =>
|
|
28
26
|
Effect.logError(
|
|
@@ -46,34 +44,19 @@ export function defaultErrorHandler<R>(
|
|
|
46
44
|
const r3 = req.method === "PATCH"
|
|
47
45
|
? r2.retry(optimisticConcurrencySchedule)
|
|
48
46
|
: r2
|
|
47
|
+
const sendError = (code: number) => (body: unknown) => Effect(res.status(code).send(body))
|
|
49
48
|
return Debug.untraced(() =>
|
|
50
49
|
r3
|
|
51
50
|
.tapErrorCause(cause => cause.isFailure() ? logRequestError(cause) : Effect.unit)
|
|
52
|
-
.
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
Effect.sync(() => {
|
|
62
|
-
res.status(401).send(err)
|
|
63
|
-
}))
|
|
64
|
-
.catchTag("UnauthorizedError", err =>
|
|
65
|
-
Effect.sync(() => {
|
|
66
|
-
res.status(403).send(err)
|
|
67
|
-
}))
|
|
68
|
-
.catchTag("InvalidStateError", err =>
|
|
69
|
-
Effect.sync(() => {
|
|
70
|
-
res.status(422).send(err)
|
|
71
|
-
}))
|
|
72
|
-
.catchTag("OptimisticConcurrencyException", err =>
|
|
73
|
-
Effect.sync(() => {
|
|
74
|
-
// 412 or 409.. https://stackoverflow.com/questions/19122088/which-http-status-code-to-use-to-reject-a-put-due-to-optimistic-locking-failure
|
|
75
|
-
res.status(412).send(err)
|
|
76
|
-
}))
|
|
51
|
+
.catchTags({
|
|
52
|
+
"ValidationError": err => sendError(400)(err.errors),
|
|
53
|
+
"NotFoundError": sendError(404),
|
|
54
|
+
"NotLoggedInError": sendError(401),
|
|
55
|
+
"UnauthorizedError": sendError(403),
|
|
56
|
+
"InvalidStateError": sendError(422),
|
|
57
|
+
// 412 or 409.. https://stackoverflow.com/questions/19122088/which-http-status-code-to-use-to-reject-a-put-due-to-optimistic-locking-failure
|
|
58
|
+
"OptimisticConcurrencyException": sendError(412)
|
|
59
|
+
})
|
|
77
60
|
// final catch all; expecting never so that unhandled known errors will show up
|
|
78
61
|
.catchAll((err: never) =>
|
|
79
62
|
Effect.logError(
|
|
@@ -2,7 +2,7 @@ import { Effect } from "@effect/io/Effect";
|
|
|
2
2
|
import type express from "express";
|
|
3
3
|
import type { InvalidStateError, NotFoundError, NotLoggedInError, OptimisticConcurrencyException, UnauthorizedError, ValidationError } from "../errors.js";
|
|
4
4
|
import type { RequestContext } from "../RequestContext.js";
|
|
5
|
-
export declare function defaultBasicErrorHandler<R>(_req: express.Request, res: express.Response, _requestContext: RequestContext, r2: Effect<R, ValidationError, void>): import("@effect/io/Effect").Effect<RequestContext | R, never, void
|
|
6
|
-
export declare function defaultErrorHandler<R>(req: express.Request, res: express.Response, _: RequestContext, r2: Effect<R, SupportedErrors, void>): import("@effect/io/Effect").Effect<RequestContext | R, never, void
|
|
5
|
+
export declare function defaultBasicErrorHandler<R>(_req: express.Request, res: express.Response, _requestContext: RequestContext, r2: Effect<R, ValidationError, void>): import("@effect/io/Effect").Effect<RequestContext | R, never, void | express.Response<any, Record<string, any>>>;
|
|
6
|
+
export declare function defaultErrorHandler<R>(req: express.Request, res: express.Response, _: RequestContext, r2: Effect<R, SupportedErrors, void>): import("@effect/io/Effect").Effect<RequestContext | R, never, void | express.Response<any, Record<string, any>>>;
|
|
7
7
|
export type SupportedErrors = ValidationError | NotFoundError | NotLoggedInError | UnauthorizedError | InvalidStateError | OptimisticConcurrencyException;
|
|
8
8
|
//# sourceMappingURL=defaultErrorHandler.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"defaultErrorHandler.d.ts","sourceRoot":"","sources":["../../_src/api/defaultErrorHandler.ts"],"names":[],"mappings":";AAAA,OAAO,KAAK,OAAO,MAAM,SAAS,CAAA;AAClC,OAAO,KAAK,EACV,iBAAiB,EACjB,aAAa,EACb,gBAAgB,EAChB,8BAA8B,EAC9B,iBAAiB,EACjB,eAAe,EAChB,MAAM,cAAc,CAAA;AACrB,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAA;AAG1D,wBAAgB,wBAAwB,CAAC,CAAC,EACxC,IAAI,EAAE,OAAO,CAAC,OAAO,EACrB,GAAG,EAAE,OAAO,CAAC,QAAQ,EACrB,eAAe,EAAE,cAAc,EAC/B,EAAE,EAAE,MAAM,CAAC,CAAC,EAAE,eAAe,EAAE,IAAI,CAAC,
|
|
1
|
+
{"version":3,"file":"defaultErrorHandler.d.ts","sourceRoot":"","sources":["../../_src/api/defaultErrorHandler.ts"],"names":[],"mappings":";AAAA,OAAO,KAAK,OAAO,MAAM,SAAS,CAAA;AAClC,OAAO,KAAK,EACV,iBAAiB,EACjB,aAAa,EACb,gBAAgB,EAChB,8BAA8B,EAC9B,iBAAiB,EACjB,eAAe,EAChB,MAAM,cAAc,CAAA;AACrB,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAA;AAG1D,wBAAgB,wBAAwB,CAAC,CAAC,EACxC,IAAI,EAAE,OAAO,CAAC,OAAO,EACrB,GAAG,EAAE,OAAO,CAAC,QAAQ,EACrB,eAAe,EAAE,cAAc,EAC/B,EAAE,EAAE,MAAM,CAAC,CAAC,EAAE,eAAe,EAAE,IAAI,CAAC,oHAgBrC;AAKD,wBAAgB,mBAAmB,CAAC,CAAC,EACnC,GAAG,EAAE,OAAO,CAAC,OAAO,EACpB,GAAG,EAAE,OAAO,CAAC,QAAQ,EACrB,CAAC,EAAE,cAAc,EACjB,EAAE,EAAE,MAAM,CAAC,CAAC,EAAE,eAAe,EAAE,IAAI,CAAC,oHA2BrC;AAED,MAAM,MAAM,eAAe,GACvB,eAAe,GACf,aAAa,GACb,gBAAgB,GAChB,iBAAiB,GACjB,iBAAiB,GACjB,8BAA8B,CAAA"}
|
|
@@ -5,9 +5,8 @@ import * as tsplus_module_4 from "@effect/io/Debug";
|
|
|
5
5
|
import * as tsplus_module_5 from "@effect/io/Schedule";
|
|
6
6
|
import { logRequestError } from "./reportError.js";
|
|
7
7
|
export function defaultBasicErrorHandler(_req, res, _requestContext, r2) {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
}))
|
|
8
|
+
const sendError = (code) => (body) => tsplus_module_1.sync(() => res.status(code).send(body));
|
|
9
|
+
return tsplus_module_4.untraced(() => tsplus_module_1.catchAll(tsplus_module_1.catchTag(tsplus_module_1.tapErrorCause(r2, cause => tsplus_module_2.isFailure(cause) ? logRequestError(cause) : tsplus_module_3.unit), "ValidationError", err => sendError(400)(err.errors))
|
|
11
10
|
// final catch all; expecting never so that unhandled known errors will show up
|
|
12
11
|
, (err) => tsplus_module_1.flatMap(tsplus_module_1.map(tsplus_module_1.logError("Program error, compiler probably silenced, got an unsupported Error in Error Channel of Effect" + err), () => err), tsplus_module_1.die)));
|
|
13
12
|
}
|
|
@@ -16,21 +15,17 @@ export function defaultErrorHandler(req, res, _, r2) {
|
|
|
16
15
|
const r3 = req.method === "PATCH"
|
|
17
16
|
? tsplus_module_1.retry(r2, optimisticConcurrencySchedule)
|
|
18
17
|
: r2;
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
res.status(403).send(err);
|
|
27
|
-
})), "InvalidStateError", err => tsplus_module_1.sync(() => {
|
|
28
|
-
res.status(422).send(err);
|
|
29
|
-
})), "OptimisticConcurrencyException", err => tsplus_module_1.sync(() => {
|
|
18
|
+
const sendError = (code) => (body) => tsplus_module_1.sync(() => res.status(code).send(body));
|
|
19
|
+
return tsplus_module_4.untraced(() => tsplus_module_1.catchAll(tsplus_module_1.catchTags(tsplus_module_1.tapErrorCause(r3, cause => tsplus_module_2.isFailure(cause) ? logRequestError(cause) : tsplus_module_3.unit), {
|
|
20
|
+
"ValidationError": err => sendError(400)(err.errors),
|
|
21
|
+
"NotFoundError": sendError(404),
|
|
22
|
+
"NotLoggedInError": sendError(401),
|
|
23
|
+
"UnauthorizedError": sendError(403),
|
|
24
|
+
"InvalidStateError": sendError(422),
|
|
30
25
|
// 412 or 409.. https://stackoverflow.com/questions/19122088/which-http-status-code-to-use-to-reject-a-put-due-to-optimistic-locking-failure
|
|
31
|
-
|
|
32
|
-
})
|
|
26
|
+
"OptimisticConcurrencyException": sendError(412)
|
|
27
|
+
})
|
|
33
28
|
// final catch all; expecting never so that unhandled known errors will show up
|
|
34
29
|
, (err) => tsplus_module_1.flatMap(tsplus_module_1.map(tsplus_module_1.logError("Program error, compiler probably silenced, got an unsupported Error in Error Channel of Effect" + err), () => err), tsplus_module_1.die)));
|
|
35
30
|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LENBQUMsR0FBRyxDQUFDO1FBQ2xDLG1CQUFtQixFQUFFLFNBQVMsQ0FBQyxHQUFHLENBQUM7UUFDbkMsbUJBQW1CLEVBQUUsU0FBUyxDQUFDLEdBQUcsQ0FBQztRQUNuQyw0SUFBNEk7UUFDNUksZ0NBQWdDLEVBQUUsU0FBUyxDQUFDLEdBQUcsQ0FBQztLQUNqRCxDQUFDO0lBQ0YsK0VBQStFO01BQ3JFLENBQUMsR0FBVSxFQUFFLEVBQUUsQ0FDdkIsd0JBQUEsb0JBQUEseUJBQ0UsZ0dBQWdHLEdBQUcsR0FBRyxDQUN2RyxFQUNNLEdBQUcsRUFBRSxDQUFDLEdBQWMsQ0FBQyxzQkFDTixDQUN2QixDQUNKLENBQUE7QUFDSCxDQUFDIn0=
|
|
@@ -6,8 +6,8 @@ import type { DBRecord } from "./shared.js";
|
|
|
6
6
|
import { OptimisticLockException } from "./shared.js";
|
|
7
7
|
import * as simpledb from "./simpledb.js";
|
|
8
8
|
export declare function createContext<TKey extends string, EA, A extends DBRecord<TKey>>(): <REncode, RDecode, EDecode>(type: string, encode: (record: A) => import("@effect/io/Effect").Effect<REncode, never, EA>, decode: (d: EA) => import("@effect/io/Effect").Effect<RDecode, EDecode, A>, indexes: IndexingPolicy) => import("@effect/io/Effect").Effect<Cosmos.CosmosClient, unknown, {
|
|
9
|
-
find: (id: string) => import("@effect/io/Effect").Effect<Cosmos.CosmosClient | simpledb.RecordCache
|
|
9
|
+
find: (id: string) => import("@effect/io/Effect").Effect<RDecode | Cosmos.CosmosClient | simpledb.RecordCache, unknown, import("@fp-ts/core/Option").Option<A>>;
|
|
10
10
|
findBy: (parameters: Record<string, string>) => import("@effect/io/Effect").Effect<Cosmos.CosmosClient, unknown, import("@fp-ts/core/Option").Option<any>>;
|
|
11
|
-
save: (record: A) => import("@effect/io/Effect").Effect<Cosmos.CosmosClient | simpledb.RecordCache
|
|
11
|
+
save: (record: A) => import("@effect/io/Effect").Effect<REncode | Cosmos.CosmosClient | simpledb.RecordCache, OptimisticLockException, A>;
|
|
12
12
|
}>;
|
|
13
13
|
//# sourceMappingURL=cosmosdb.d.ts.map
|
|
@@ -4,9 +4,9 @@ import type { DBRecord, Index } from "./shared.js";
|
|
|
4
4
|
import { CouldNotAquireDbLockException } from "./shared.js";
|
|
5
5
|
import * as simpledb from "./simpledb.js";
|
|
6
6
|
export declare function createContext<TKey extends string, EA, A extends DBRecord<TKey>>(): <REncode, RDecode, EDecode>(type: string, encode: (record: A) => import("@effect/io/Effect").Effect<REncode, never, EA>, decode: (d: EA) => import("@effect/io/Effect").Effect<RDecode, EDecode, A>, schemaVersion: string, makeIndexKey: (r: A) => Index, dir?: string) => {
|
|
7
|
-
find: (id: string) => import("@effect/io/Effect").Effect<simpledb.RecordCache
|
|
7
|
+
find: (id: string) => import("@effect/io/Effect").Effect<RDecode | simpledb.RecordCache, simpledb.InvalidStateError, import("@fp-ts/core/Option").Option<A>>;
|
|
8
8
|
findByIndex: (index: Index) => import("@effect/io/Effect").Effect<never, never, import("@fp-ts/core/Option").Option<TKey & {}>>;
|
|
9
|
-
save: (record: A) => import("@effect/io/Effect").Effect<simpledb.RecordCache
|
|
9
|
+
save: (record: A) => import("@effect/io/Effect").Effect<REncode | simpledb.RecordCache, CouldNotAquireDbLockException | import("./shared.js").OptimisticLockException | simpledb.InvalidStateError, A>;
|
|
10
10
|
};
|
|
11
11
|
export declare function initialise(dir: string): void;
|
|
12
12
|
//# sourceMappingURL=diskdb.d.ts.map
|
|
@@ -5,8 +5,8 @@ import * as MO from "@effect-app/schema";
|
|
|
5
5
|
import type { DBRecord } from "./shared.js";
|
|
6
6
|
import * as simpledb from "./simpledb.js";
|
|
7
7
|
export declare function createContext<TKey extends string, EA, A extends DBRecord<TKey>>(): <REncode, RDecode, EDecode>(type: string, encode: (record: A) => import("@effect/io/Effect").Effect<REncode, never, EA>, decode: (d: EA) => import("@effect/io/Effect").Effect<RDecode, EDecode, A>) => {
|
|
8
|
-
find: (id: string) => import("@effect/io/Effect").Effect<simpledb.RecordCache
|
|
8
|
+
find: (id: string) => import("@effect/io/Effect").Effect<RDecode | simpledb.RecordCache, MO.CondemnException | simpledb.InvalidStateError, import("@fp-ts/core/Option").Option<A>>;
|
|
9
9
|
findBy: <V extends Partial<A>>(keys: V, eq: import("@fp-ts/core/typeclass/Equivalence").Equivalence<V>) => import("@effect/io/Effect").Effect<RDecode, MO.CondemnException, import("@fp-ts/core/Option").Option<A & {}>>;
|
|
10
|
-
save: (record: A) => import("@effect/io/Effect").Effect<simpledb.RecordCache
|
|
10
|
+
save: (record: A) => import("@effect/io/Effect").Effect<REncode | simpledb.RecordCache, MO.CondemnException | import("./shared.js").OptimisticLockException | simpledb.InvalidStateError, A>;
|
|
11
11
|
};
|
|
12
12
|
//# sourceMappingURL=memdb.d.ts.map
|
|
@@ -6,8 +6,8 @@ import type { DBRecord } from "./shared.js";
|
|
|
6
6
|
import { OptimisticLockException } from "./shared.js";
|
|
7
7
|
import * as simpledb from "./simpledb.js";
|
|
8
8
|
export declare function createContext<TKey extends string, EA, A extends DBRecord<TKey>>(): <REncode, RDecode, EDecode>(type: string, encode: (record: A) => import("@effect/io/Effect").Effect<REncode, never, EA>, decode: (d: EA) => import("@effect/io/Effect").Effect<RDecode, EDecode, A>, indexes: IndexDescription[]) => import("@effect/io/Effect").Effect<Mongo.MongoClient, unknown, {
|
|
9
|
-
find: (id: string) => import("@effect/io/Effect").Effect<
|
|
9
|
+
find: (id: string) => import("@effect/io/Effect").Effect<RDecode | Mongo.MongoClient | simpledb.RecordCache, unknown, import("@fp-ts/core/Option").Option<A>>;
|
|
10
10
|
findBy: (keys: Record<string, string>) => import("@effect/io/Effect").Effect<Mongo.MongoClient, unknown, import("@fp-ts/core/Option").Option<TKey>>;
|
|
11
|
-
save: (record: A) => import("@effect/io/Effect").Effect<
|
|
11
|
+
save: (record: A) => import("@effect/io/Effect").Effect<REncode | Mongo.MongoClient | simpledb.RecordCache, OptimisticLockException, A>;
|
|
12
12
|
}>;
|
|
13
13
|
//# sourceMappingURL=mongodb.d.ts.map
|
|
@@ -6,9 +6,9 @@ import type { DBRecord, Index } from "./shared.js";
|
|
|
6
6
|
import { CouldNotAquireDbLockException } from "./shared.js";
|
|
7
7
|
import * as simpledb from "./simpledb.js";
|
|
8
8
|
export declare function createContext<TKey extends string, EA, A extends DBRecord<TKey>>(): <REncode, RDecode, EDecode>(type: string, encode: (record: A) => import("@effect/io/Effect").Effect<REncode, never, EA>, decode: (d: EA) => import("@effect/io/Effect").Effect<RDecode, EDecode, A>, schemaVersion: string, makeIndexKey: (r: A) => Index) => {
|
|
9
|
-
find: (id: string) => import("@effect/io/Effect").Effect<RED.RedisClient | simpledb.RecordCache
|
|
9
|
+
find: (id: string) => import("@effect/io/Effect").Effect<RDecode | RED.RedisClient | simpledb.RecordCache, simpledb.InvalidStateError, import("@fp-ts/core/Option").Option<A>>;
|
|
10
10
|
findByIndex: (index: Index) => import("@effect/io/Effect").Effect<RED.RedisClient, RED.ConnectionException, import("@fp-ts/core/Option").Option<TKey>>;
|
|
11
|
-
save: (record: A) => import("@effect/io/Effect").Effect<RED.RedisClient | simpledb.RecordCache
|
|
11
|
+
save: (record: A) => import("@effect/io/Effect").Effect<REncode | RED.RedisClient | simpledb.RecordCache, CouldNotAquireDbLockException | import("./shared.js").OptimisticLockException | simpledb.InvalidStateError, A>;
|
|
12
12
|
};
|
|
13
13
|
declare const RedisSerializedDBRecord_base: MO.Model<RedisSerializedDBRecord, MO.SchemaProperties<{
|
|
14
14
|
version: MO.Property<MO.SchemaDefaultSchema<unknown, string, string, string, {}>, "required", import("@fp-ts/core/Option").None, import("@fp-ts/core/Option").None>;
|
|
@@ -17,7 +17,7 @@ export interface RecordCache extends ReturnType<typeof makeLiveRecordCache> {
|
|
|
17
17
|
}
|
|
18
18
|
export declare const RecordCache: import("@effect/data/Context").Tag<RecordCache>;
|
|
19
19
|
export declare const LiveRecordCache: import("@effect/io/Layer").Layer<never, never, RecordCache>;
|
|
20
|
-
export declare function find<R, RDecode, EDecode, E, EA, A>(tryRead: (id: string) => Effect<R, E, Option<CachedRecord<EA>>>, decode: (d: EA) => Effect<RDecode, EDecode, A>, type: string): (id: string) => import("@effect/io/Effect").Effect<
|
|
21
|
-
export declare function storeDirectly<R, E, TKey extends string, A extends DBRecord<TKey>>(save: (r: A, version: Option<Version>) => Effect<R, E, CachedRecord<A>>, type: string): (record: A) => import("@effect/io/Effect").Effect<
|
|
22
|
-
export declare function store<R, E, R2, E2, TKey extends string, EA, A extends DBRecord<TKey>>(tryRead: (id: string) => Effect<R, E, Option<CachedRecord<EA>>>, save: (r: A, version: Option<Version>) => Effect<R, E, CachedRecord<A>>, lock: (id: string) => Effect<R2 | Scope, E2, unknown>, type: string): (record: A) => import("@effect/io/Effect").Effect<
|
|
20
|
+
export declare function find<R, RDecode, EDecode, E, EA, A>(tryRead: (id: string) => Effect<R, E, Option<CachedRecord<EA>>>, decode: (d: EA) => Effect<RDecode, EDecode, A>, type: string): (id: string) => import("@effect/io/Effect").Effect<R | RDecode | RecordCache, E | InvalidStateError, import("@fp-ts/core/Option").Option<A>>;
|
|
21
|
+
export declare function storeDirectly<R, E, TKey extends string, A extends DBRecord<TKey>>(save: (r: A, version: Option<Version>) => Effect<R, E, CachedRecord<A>>, type: string): (record: A) => import("@effect/io/Effect").Effect<R | RecordCache, E, A>;
|
|
22
|
+
export declare function store<R, E, R2, E2, TKey extends string, EA, A extends DBRecord<TKey>>(tryRead: (id: string) => Effect<R, E, Option<CachedRecord<EA>>>, save: (r: A, version: Option<Version>) => Effect<R, E, CachedRecord<A>>, lock: (id: string) => Effect<R2 | Scope, E2, unknown>, type: string): (record: A) => import("@effect/io/Effect").Effect<R | RecordCache | Exclude<R2, import("@effect/io/Scope").Scope>, E | E2 | OptimisticLockException | InvalidStateError, A>;
|
|
23
23
|
//# sourceMappingURL=simpledb.d.ts.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@effect-app/infra",
|
|
3
|
-
"version": "0.25.
|
|
3
|
+
"version": "0.25.9",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"dependencies": {
|
|
@@ -20,10 +20,10 @@
|
|
|
20
20
|
"proper-lockfile": "^4.1.2",
|
|
21
21
|
"pure-rand": "^6.0.0",
|
|
22
22
|
"redlock": "^4.2.0",
|
|
23
|
-
"@effect-app/prelude": "0.21.
|
|
24
|
-
"@effect-app/core": "0.23.
|
|
25
|
-
"@effect-app/
|
|
26
|
-
"@effect-app/
|
|
23
|
+
"@effect-app/prelude": "0.21.5",
|
|
24
|
+
"@effect-app/core": "0.23.1",
|
|
25
|
+
"@effect-app/schema": "0.18.4",
|
|
26
|
+
"@effect-app/infra-adapters": "0.20.5"
|
|
27
27
|
},
|
|
28
28
|
"devDependencies": {
|
|
29
29
|
"@babel/cli": "^7.20.7",
|