@effect-app/infra 0.104.3 → 0.105.0
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 +20 -0
- package/_cjs/RequestContext.cjs +12 -12
- package/_cjs/RequestContext.cjs.map +1 -1
- package/_cjs/api/codec.cjs +2 -2
- package/_cjs/api/codec.cjs.map +1 -1
- package/_cjs/api/express/makeOpenApiSpecs.cjs +2 -2
- package/_cjs/api/express/makeOpenApiSpecs.cjs.map +1 -1
- package/_cjs/api/express/schema/jwt.cjs +11 -11
- package/_cjs/api/express/schema/jwt.cjs.map +1 -1
- package/_cjs/api/express/schema/routing.cjs +4 -4
- package/_cjs/api/express/schema/routing.cjs.map +1 -1
- package/_cjs/services/QueueMaker/memQueue.cjs +2 -2
- package/_cjs/services/QueueMaker/memQueue.cjs.map +1 -1
- package/_cjs/services/QueueMaker/sbqueue.cjs +9 -8
- package/_cjs/services/QueueMaker/sbqueue.cjs.map +1 -1
- package/_cjs/services/QueueMaker/service.cjs +2 -2
- package/_cjs/services/QueueMaker/service.cjs.map +1 -1
- package/_cjs/services/RepositoryBase.cjs.map +1 -1
- package/_cjs/services/simpledb/memdb.cjs +2 -2
- package/_cjs/services/simpledb/memdb.cjs.map +1 -1
- package/_cjs/services/simpledb/redisdb.cjs +6 -6
- package/_cjs/services/simpledb/redisdb.cjs.map +1 -1
- package/_cjs/services/simpledb/shared.cjs +9 -9
- package/_cjs/services/simpledb/shared.cjs.map +1 -1
- package/_src/RequestContext.ts +17 -17
- package/_src/api/app.ts.bak +12 -12
- package/_src/api/codec.ts +5 -5
- package/_src/api/express/makeOpenApiSpecs.ts +3 -3
- package/_src/api/express/routing.ts.bak +2 -2
- package/_src/api/express/schema/jwt.ts +13 -13
- package/_src/api/express/schema/routing.ts +12 -12
- package/_src/services/QueueMaker/memQueue.ts +2 -2
- package/_src/services/QueueMaker/sbqueue.ts +3 -2
- package/_src/services/QueueMaker/service.ts +2 -2
- package/_src/services/RepositoryBase.ts +8 -8
- package/_src/services/simpledb/memdb.ts +2 -2
- package/_src/services/simpledb/redisdb.ts +6 -6
- package/_src/services/simpledb/shared.ts +11 -11
- package/dist/RequestContext.d.ts +39 -39
- package/dist/RequestContext.d.ts.map +1 -1
- package/dist/RequestContext.js +12 -12
- package/dist/api/codec.d.ts +3 -3
- package/dist/api/codec.d.ts.map +1 -1
- package/dist/api/codec.js +3 -3
- package/dist/api/express/makeOpenApiSpecs.d.ts +1 -1
- package/dist/api/express/makeOpenApiSpecs.js +4 -4
- package/dist/api/express/schema/jwt.d.ts +4 -4
- package/dist/api/express/schema/jwt.d.ts.map +1 -1
- package/dist/api/express/schema/jwt.js +12 -12
- package/dist/api/express/schema/routing.d.ts +8 -8
- package/dist/api/express/schema/routing.d.ts.map +1 -1
- package/dist/api/express/schema/routing.js +5 -5
- package/dist/services/QueueMaker/memQueue.js +3 -3
- package/dist/services/QueueMaker/sbqueue.d.ts.map +1 -1
- package/dist/services/QueueMaker/sbqueue.js +10 -9
- package/dist/services/QueueMaker/service.d.ts +3 -3
- package/dist/services/QueueMaker/service.js +3 -3
- package/dist/services/RepositoryBase.d.ts +2 -2
- package/dist/services/RepositoryBase.d.ts.map +1 -1
- package/dist/services/RepositoryBase.js +1 -1
- package/dist/services/simpledb/memdb.d.ts +4 -4
- package/dist/services/simpledb/memdb.d.ts.map +1 -1
- package/dist/services/simpledb/memdb.js +3 -3
- package/dist/services/simpledb/redisdb.d.ts +9 -9
- package/dist/services/simpledb/redisdb.d.ts.map +1 -1
- package/dist/services/simpledb/redisdb.js +7 -7
- package/dist/services/simpledb/shared.d.ts +13 -13
- package/dist/services/simpledb/shared.d.ts.map +1 -1
- package/dist/services/simpledb/shared.js +10 -10
- package/package.json +6 -6
|
@@ -10,7 +10,7 @@ var tsplus_module_2 = _interopRequireWildcard(require("@effect-app/core/Effect")
|
|
|
10
10
|
var tsplus_module_3 = _interopRequireWildcard(require("effect/Option"));
|
|
11
11
|
var _Function = require("@effect-app/core/Function");
|
|
12
12
|
var _redisClient = require("@effect-app/infra-adapters/redis-client");
|
|
13
|
-
var
|
|
13
|
+
var S = _interopRequireWildcard(require("@effect-app/schema"));
|
|
14
14
|
var _shared = require("./shared.cjs");
|
|
15
15
|
var simpledb = _interopRequireWildcard(require("./simpledb.cjs"));
|
|
16
16
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
@@ -27,7 +27,7 @@ function createContext() {
|
|
|
27
27
|
save: simpledb.store(find, store, lockRedisRecord, type)
|
|
28
28
|
};
|
|
29
29
|
function find(id) {
|
|
30
|
-
return tsplus_module_1.orDie(tsplus_module_2.flatMapOption(tsplus_module_1.flatMap(_redisClient.RedisClient, _ => _.hmgetAll(getKey(id))), v => tsplus_module_1.mapError(tsplus_module_1.map((0, _Function.pipe)(RedisSerializedDBRecord.Parser,
|
|
30
|
+
return tsplus_module_1.orDie(tsplus_module_2.flatMapOption(tsplus_module_1.flatMap(_redisClient.RedisClient, _ => _.hmgetAll(getKey(id))), v => tsplus_module_1.mapError(tsplus_module_1.map((0, _Function.pipe)(RedisSerializedDBRecord.Parser, S.condemnFail)(v), ({
|
|
31
31
|
data,
|
|
32
32
|
version
|
|
33
33
|
}) => ({
|
|
@@ -124,10 +124,10 @@ function createContext() {
|
|
|
124
124
|
})));
|
|
125
125
|
}
|
|
126
126
|
}
|
|
127
|
-
class RedisSerializedDBRecord extends
|
|
128
|
-
version:
|
|
129
|
-
timestamp:
|
|
130
|
-
data:
|
|
127
|
+
class RedisSerializedDBRecord extends S.Class()({
|
|
128
|
+
version: S.string,
|
|
129
|
+
timestamp: S.date,
|
|
130
|
+
data: S.string
|
|
131
131
|
}) {}
|
|
132
132
|
exports.RedisSerializedDBRecord = RedisSerializedDBRecord;
|
|
133
133
|
//# sourceMappingURL=redisdb.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"redisdb.cjs","names":["_Function","require","_redisClient","
|
|
1
|
+
{"version":3,"file":"redisdb.cjs","names":["_Function","require","_redisClient","S","_interopRequireWildcard","_shared","simpledb","_getRequireWildcardCache","e","WeakMap","r","t","__esModule","default","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","prototype","hasOwnProperty","call","i","set","ttl","createContext","type","encode","decode","schemaVersion","makeIndexKey","getData","flow","_","tsplus_module_1","map","JSON","stringify","find","findByIndex","getIdx","save","store","lockRedisRecord","id","orDie","tsplus_module_2","flatMapOption","flatMap","RedisClient","hmgetAll","getKey","v","mapError","pipe","RedisSerializedDBRecord","Parser","condemnFail","data","version","parse","ConnectionException","Error","toString","record","currentVersion","tsplus_module_3","getOrElse","cv","parseInt","match","onNone","scoped","zipRight","lockIndex","zipRightOption","getIndex","fail","hmSetRec","timestamp","Date","setIndex","onSome","index","setIdx","lockRedisIdx","hget","getIdxKey","key","hset","lockKey","getIdxLockKey","acquireRelease","mapBoth","lock","tryPromise","onFailure","err","CouldNotAquireDbLockException","onSuccess","release","unlock","l","getLockKey","getRecordName","getIndexName","doc","val","enc","Encoder","client","uninterruptible","async","res","hmset","sync","Class","string","date","exports"],"sources":["../../../_src/services/simpledb/redisdb.ts"],"sourcesContent":[null],"mappings":";;;;;;;;;;AAEA,IAAAA,SAAA,GAAAC,OAAA;AACA,IAAAC,YAAA,GAAAD,OAAA;AACA,IAAAE,CAAA,GAAAC,uBAAA,CAAAH,OAAA;AAGA,IAAAI,OAAA,GAAAJ,OAAA;AACA,IAAAK,QAAA,GAAAF,uBAAA,CAAAH,OAAA;AAAyC,SAAAM,yBAAAC,CAAA,6BAAAC,OAAA,mBAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAF,wBAAA,YAAAA,CAAAC,CAAA,WAAAA,CAAA,GAAAG,CAAA,GAAAD,CAAA,KAAAF,CAAA;AAAA,SAAAJ,wBAAAI,CAAA,EAAAE,CA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AAC/E,IAAI,EAAEyD,KAAK,CAACuB,GAAG,CAAC,IAAIvB,KAAK,CAACK,GAAG,EAAE;IAChF;EACF,CAAC;EAED,SAASV,QAAQA,CAACU,GAAW,EAAEmB,GAA4B;IACzD,MAAMC,GAAG,GAAGrD,uBAAuB,CAACsD,OAAO,CAACF,GAAG,CAAC;IAChD,OAAOzE,eAAA,CAAAc,OAAA,CAAAC,wBAAW,EAAS,CAAC;MAAE6D;IAAM,CAAE,KAAI5E,eAAA,CAAA6E,eAAA,CACxC7E,eAAA,CAAA8E,KAAA,CAC4CC,GAAG,IAAI;MAC/CH,MAAM,CAACI,KAAK,CACV1B,GAAG,EACH,SAAS,EACToB,GAAG,CAACjD,OAAO,EACX,WAAW,EACXiD,GAAG,CAAC7B,SAAS,EACb,MAAM,EACN6B,GAAG,CAAClD,IAAI,EACPuC,GAAG,IACFA,GAAG,GACCgB,GAAG,CAAC,IAAIpD,2BAAmB,CAACoC,GAAG,CAAC,CAAC,GACjCgB,GAAG,CAAC/E,eAAA,CAAAiF,IAAA,OAAO,KAAK,CAAC,CAAC,CAAC,CAC1B;IACH,CAAC,CAAC,CACc,CACnB;EACH;AACF;AAEM,MAAO5D,uBAAwB,SAAQxD,CAAC,CAACqH,KAAK,EAA2B,CAAC;EAC9EzD,OAAO,EAAE5D,CAAC,CAACsH,MAAM;EACjBtC,SAAS,EAAEhF,CAAC,CAACuH,IAAI;EACjB5D,IAAI,EAAE3D,CAAC,CAACsH;CACT,CAAC;AAAGE,OAAA,CAAAhE,uBAAA,GAAAA,uBAAA"}
|
|
@@ -11,7 +11,7 @@ exports.makeSerialisedDBRecord = makeSerialisedDBRecord;
|
|
|
11
11
|
var tsplus_module_1 = _interopRequireWildcard(require("effect/Data"));
|
|
12
12
|
var tsplus_module_2 = _interopRequireWildcard(require("effect/Option"));
|
|
13
13
|
var tsplus_module_3 = _interopRequireWildcard(require("effect/Effect"));
|
|
14
|
-
var
|
|
14
|
+
var S = _interopRequireWildcard(require("@effect-app/schema"));
|
|
15
15
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
16
16
|
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
17
17
|
class CouldNotAquireDbLockException extends tsplus_module_1.TaggedError("CouldNotAquireDbLockException") {
|
|
@@ -45,18 +45,18 @@ class ConnectionException extends tsplus_module_1.TaggedError("ConnectionExcepti
|
|
|
45
45
|
}
|
|
46
46
|
}
|
|
47
47
|
exports.ConnectionException = ConnectionException;
|
|
48
|
-
class SerializedDBRecord extends
|
|
49
|
-
version:
|
|
50
|
-
timestamp:
|
|
51
|
-
data:
|
|
48
|
+
class SerializedDBRecord extends S.Class()({
|
|
49
|
+
version: S.string,
|
|
50
|
+
timestamp: S.date,
|
|
51
|
+
data: S.string
|
|
52
52
|
}) {}
|
|
53
53
|
// unknown -> string -> SDB?
|
|
54
54
|
exports.SerializedDBRecord = SerializedDBRecord;
|
|
55
55
|
function makeSerialisedDBRecord(s) {
|
|
56
|
-
return
|
|
57
|
-
version:
|
|
58
|
-
timestamp:
|
|
59
|
-
data:
|
|
56
|
+
return S.struct({
|
|
57
|
+
version: S.number,
|
|
58
|
+
timestamp: S.date,
|
|
59
|
+
data: s
|
|
60
60
|
});
|
|
61
61
|
}
|
|
62
62
|
function getIndexName(type, id) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shared.cjs","names":["
|
|
1
|
+
{"version":3,"file":"shared.cjs","names":["S","_interopRequireWildcard","require","_getRequireWildcardCache","e","WeakMap","r","t","__esModule","default","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","prototype","hasOwnProperty","call","i","set","CouldNotAquireDbLockException","tsplus_module_1","TaggedError","constructor","type","id","error","message","exports","OptimisticLockException","ConnectionException","cause","_errorTag","SerializedDBRecord","Class","version","string","timestamp","date","data","makeSerialisedDBRecord","s","struct","number","getIndexName","getRecordName","makeMap","map","Map","find","k","tsplus_module_3","sync","tsplus_module_2","fromNullable","Symbol","iterator","v"],"sources":["../../../_src/services/simpledb/shared.ts"],"sourcesContent":[null],"mappings":";;;;;;;;;;;;;AAAA,IAAAA,CAAA,GAAAC,uBAAA,CAAAC,OAAA;AAAuC,SAAAC,yBAAAC,CAAA,6BAAAC,OAAA,mBAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAF,wBAAA,YAAAA,CAAAC,CAAA,WAAAA,CAAA,GAAAG,CAAA,GAAAD,CAAA,KAAAF,CAAA;AAAA,SAAAH,wBAAAG,CAAA,EAAAE,CAAA,SAAAA,CAAA,IAAAF,CAAA,IAAAA,CAAA,CAAAI,UAAA,SAAAJ,CAAA,eAAAA,CAAA,uBAAAA,CAAA,yBAAAA,CAAA,WAAAK,OAAA,EAAAL,CAAA,QAAAG,CAAA,GAAAJ,wBAAA,CAAAG,CAAA,OAAAC,CAAA,IAAAA,CAAA,CAAAG,GAAA,CAAAN,CAAA,UAAAG,CAAA,CAAAI,GAAA,CAAAP,CAAA,OAAAQ,CAAA,KAAAC,SAAA,UAAAC,CAAA,GAAAC,MAAA,CAAAC,cAAA,IAAAD,MAAA,CAAAE,wBAAA,WAAAC,CAAA,IAAAd,CAAA,oBAAAc,CAAA,IAAAH,MAAA,CAAAI,SAAA,CAAAC,cAAA,CAAAC,IAAA,CAAAjB,CAAA,EAAAc,CAAA,SAAAI,CAAA,GAAAR,CAAA,GAAAC,MAAA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vC,CAAC,CAACwC,MAAM;EACjBC,SAAS,EAAEzC,CAAC,CAAC0C,IAAI;EACjBC,IAAI,EAAE3C,CAAC,CAACwC;CACT,CAAC;AAEF;AAAAR,OAAA,CAAAK,kBAAA,GAAAA,kBAAA;AACM,SAAUO,sBAAsBA,CAACC,CAAY;EACjD,OAAO7C,CAAC,CAAC8C,MAAM,CAAC;IACdP,OAAO,EAAEvC,CAAC,CAAC+C,MAAM;IACjBN,SAAS,EAAEzC,CAAC,CAAC0C,IAAI;IACjBC,IAAI,EAAEE;GACP,CAAC;AACJ;AAYM,SAAUG,YAAYA,CAACpB,IAAY,EAAEC,EAAU;EACnD,OAAO,GAAGD,IAAI,QAAQC,EAAE,EAAE;AAC5B;AAEM,SAAUoB,aAAaA,CAACrB,IAAY,EAAEC,EAAU;EACpD,OAAO,GAAGD,IAAI,MAAMC,EAAE,EAAE;AAC1B;AAEM,SAAUqB,OAAOA,CAAA;EACrB,MAAMC,GAAG,GAAG,IAAIC,GAAG,EAAW;EAC9B,OAAO;IACLC,IAAI,EAAGC,CAAO,IAAKC,eAAA,CAAAC,IAAA,OAAOC,eAAA,CAAAC,YAAA,CAAoBP,GAAG,CAACxC,GAAG,CAAC2C,CAAC,CAAC,CAAC,CAAC;IAC1D,CAACK,MAAM,CAACC,QAAQ,GAAG,MAAMT,GAAG,CAACQ,MAAM,CAACC,QAAQ,CAAC,EAAE;IAC/CrC,GAAG,EAAEA,CAAC+B,CAAO,EAAEO,CAAI,KACjBN,eAAA,CAAAC,IAAA,CAAY,MAAK;MACfL,GAAG,CAAC5B,GAAG,CAAC+B,CAAC,EAAEO,CAAC,CAAC;IACf,CAAC;GACkB;AACzB"}
|
package/_src/RequestContext.ts
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import { RequestId, UserProfileId } from "@effect-app/prelude/ids"
|
|
2
2
|
|
|
3
3
|
@useClassFeaturesForSchema
|
|
4
|
-
export class RequestContextParent extends
|
|
4
|
+
export class RequestContextParent extends ExtendedClass<
|
|
5
5
|
RequestContextParent,
|
|
6
6
|
RequestContextParent.ConstructorInput,
|
|
7
|
-
RequestContextParent.
|
|
8
|
-
RequestContextParent.
|
|
7
|
+
RequestContextParent.From,
|
|
8
|
+
RequestContextParent.Fields
|
|
9
9
|
>()({
|
|
10
10
|
_tag: literal("RequestContext"),
|
|
11
11
|
id: RequestId,
|
|
12
12
|
name: ReasonableString,
|
|
13
|
-
userProfile:
|
|
13
|
+
userProfile: struct({ sub: UserProfileId }).optional,
|
|
14
14
|
locale: literal("en", "de"),
|
|
15
15
|
createdAt: date.withDefault
|
|
16
16
|
}) {}
|
|
@@ -20,11 +20,11 @@ export class RequestContextParent extends MNModel<
|
|
|
20
20
|
* @tsplus companion RequestContext.Ops
|
|
21
21
|
*/
|
|
22
22
|
@useClassFeaturesForSchema
|
|
23
|
-
export class RequestContext extends
|
|
23
|
+
export class RequestContext extends ExtendedClass<
|
|
24
24
|
RequestContext,
|
|
25
25
|
RequestContext.ConstructorInput,
|
|
26
|
-
RequestContext.
|
|
27
|
-
RequestContext.
|
|
26
|
+
RequestContext.From,
|
|
27
|
+
RequestContext.Fields
|
|
28
28
|
>()({
|
|
29
29
|
...RequestContextParent.omit("id"),
|
|
30
30
|
id: RequestId.withDefault,
|
|
@@ -61,23 +61,23 @@ export class RequestContext extends MNModel<
|
|
|
61
61
|
/* eslint-disable */
|
|
62
62
|
export namespace RequestContextParent {
|
|
63
63
|
/**
|
|
64
|
-
* @tsplus type RequestContextParent.
|
|
65
|
-
* @tsplus companion RequestContextParent.
|
|
64
|
+
* @tsplus type RequestContextParent.From
|
|
65
|
+
* @tsplus companion RequestContextParent.From/Ops
|
|
66
66
|
*/
|
|
67
|
-
export class
|
|
67
|
+
export class From extends FromClass<typeof RequestContextParent>() {}
|
|
68
68
|
export interface ConstructorInput
|
|
69
|
-
extends
|
|
70
|
-
export interface
|
|
69
|
+
extends ConstructorInputApi<typeof RequestContextParent> {}
|
|
70
|
+
export interface Fields extends FieldsClass<typeof RequestContextParent> {}
|
|
71
71
|
}
|
|
72
72
|
export namespace RequestContext {
|
|
73
73
|
/**
|
|
74
|
-
* @tsplus type RequestContext.
|
|
75
|
-
* @tsplus companion RequestContext.
|
|
74
|
+
* @tsplus type RequestContext.From
|
|
75
|
+
* @tsplus companion RequestContext.From/Ops
|
|
76
76
|
*/
|
|
77
|
-
export class
|
|
77
|
+
export class From extends FromClass<typeof RequestContext>() {}
|
|
78
78
|
export interface ConstructorInput
|
|
79
|
-
extends
|
|
80
|
-
export interface
|
|
79
|
+
extends ConstructorInputApi<typeof RequestContext> {}
|
|
80
|
+
export interface Fields extends FieldsClass<typeof RequestContext> {}
|
|
81
81
|
}
|
|
82
82
|
/* eslint-enable */
|
|
83
83
|
//
|
package/_src/api/app.ts.bak
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
2
2
|
import { flow } from "@effect-app/core/Function"
|
|
3
|
-
import * as
|
|
3
|
+
import * as S from "@effect-app/schema"
|
|
4
4
|
|
|
5
5
|
import { NotFoundError, UnauthorizedError } from "./errors.js"
|
|
6
6
|
|
|
7
7
|
export function handle<
|
|
8
8
|
TModule extends Record<
|
|
9
9
|
string,
|
|
10
|
-
any // {
|
|
10
|
+
any // { Class: S.SchemaAny; new (...args: any[]): any } | S.SchemaAny
|
|
11
11
|
>
|
|
12
12
|
>(
|
|
13
13
|
_: TModule & { ResponseOpenApi?: any },
|
|
@@ -15,27 +15,27 @@ export function handle<
|
|
|
15
15
|
): <R, E>(
|
|
16
16
|
h: (
|
|
17
17
|
r: InstanceType<
|
|
18
|
-
|
|
18
|
+
S.GetRequest<TModule> extends { new(...args: any[]): any } ? S.GetRequest<TModule>
|
|
19
19
|
: never
|
|
20
20
|
>
|
|
21
|
-
) => Effect<R, E,
|
|
21
|
+
) => Effect<R, E, S.To<Extr<S.GetResponse<TModule>>>>
|
|
22
22
|
) => {
|
|
23
23
|
h: typeof h
|
|
24
|
-
Request:
|
|
25
|
-
Response:
|
|
24
|
+
Request: S.GetRequest<TModule>
|
|
25
|
+
Response: S.GetResponse<TModule>
|
|
26
26
|
ResponseOpenApi: any
|
|
27
27
|
} {
|
|
28
28
|
// TODO: Prevent over providing // no strict/shrink yet.
|
|
29
|
-
const Request =
|
|
30
|
-
const Response =
|
|
29
|
+
const Request = S.extractRequest(_)
|
|
30
|
+
const Response = S.extractResponse(_)
|
|
31
31
|
|
|
32
32
|
return <R, E>(
|
|
33
33
|
h: (
|
|
34
34
|
r: InstanceType<
|
|
35
|
-
|
|
35
|
+
S.GetRequest<TModule> extends { new(...args: any[]): any } ? S.GetRequest<TModule>
|
|
36
36
|
: never
|
|
37
37
|
>
|
|
38
|
-
) => Effect<R, E,
|
|
38
|
+
) => Effect<R, E, S.To<Extr<S.GetResponse<TModule>>>>
|
|
39
39
|
) => ({
|
|
40
40
|
adaptResponse,
|
|
41
41
|
h,
|
|
@@ -45,8 +45,8 @@ export function handle<
|
|
|
45
45
|
} as any)
|
|
46
46
|
}
|
|
47
47
|
|
|
48
|
-
type Extr<T> = T extends {
|
|
49
|
-
: T extends
|
|
48
|
+
type Extr<T> = T extends { Class: S.SchemaAny } ? T["Class"]
|
|
49
|
+
: T extends S.SchemaAny ? T
|
|
50
50
|
: never
|
|
51
51
|
|
|
52
52
|
export function accessM_<T, UserId, Err>(
|
package/_src/api/codec.ts
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as S from "@effect-app/schema"
|
|
2
2
|
import { Encoder, Parser } from "@effect-app/schema"
|
|
3
3
|
|
|
4
4
|
export function makeCodec<
|
|
5
|
-
|
|
5
|
+
To extends { id: Id },
|
|
6
6
|
ConstructorInput,
|
|
7
|
-
|
|
7
|
+
From,
|
|
8
8
|
Api,
|
|
9
9
|
Id
|
|
10
|
-
>(self:
|
|
11
|
-
const decode =
|
|
10
|
+
>(self: S.Schema<unknown, To, ConstructorInput, From, Api>) {
|
|
11
|
+
const decode = S.condemnDie(Parser.for(self))
|
|
12
12
|
// TODO: strict
|
|
13
13
|
const encode = Encoder.for(self)
|
|
14
14
|
return [decode, encode] as const
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/* eslint-disable @typescript-eslint/ban-types */
|
|
2
2
|
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
3
|
-
import * as
|
|
3
|
+
import * as S from "@effect-app/schema"
|
|
4
4
|
import { Encoder, extractSchema } from "@effect-app/schema"
|
|
5
5
|
import type express from "express"
|
|
6
6
|
|
|
@@ -106,7 +106,7 @@ export function makeRequestHandler<
|
|
|
106
106
|
h?: (req: express.Request, res: express.Response) => Layer<R2, SupportedErrors, PR>
|
|
107
107
|
) {
|
|
108
108
|
const { Request, Response } = handle
|
|
109
|
-
const res = Response ? extractSchema(Response as any) :
|
|
109
|
+
const res = Response ? extractSchema(Response as any) : S.Void
|
|
110
110
|
const encodeResponse = handle.adaptResponse
|
|
111
111
|
? (req: ReqA) => Encoder.for(handle.adaptResponse(req))
|
|
112
112
|
: () => Encoder.for(res)
|
|
@@ -2,36 +2,36 @@
|
|
|
2
2
|
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
3
3
|
/* eslint-disable @typescript-eslint/ban-types */
|
|
4
4
|
import { pipe } from "@effect-app/core/Function"
|
|
5
|
-
import * as
|
|
5
|
+
import * as S from "@effect-app/schema"
|
|
6
6
|
import { These as Th } from "@effect-app/schema"
|
|
7
7
|
import { jwtDecode } from "jwt-decode"
|
|
8
8
|
|
|
9
|
-
export const jwtIdentifier =
|
|
9
|
+
export const jwtIdentifier = S.makeAnnotation<{}>()
|
|
10
10
|
|
|
11
|
-
export const jwtFromString:
|
|
12
|
-
//
|
|
13
|
-
|
|
11
|
+
export const jwtFromString: S.Schema<string, unknown, unknown, string, {}> = pipe(
|
|
12
|
+
// S.identity((u): u is string => typeof u === "string"),
|
|
13
|
+
S.identity((u): u is string => {
|
|
14
14
|
throw new Error("Cannot id JWT: " + u)
|
|
15
15
|
}),
|
|
16
|
-
|
|
17
|
-
//
|
|
16
|
+
S.constructor((n) => Th.succeed(n)),
|
|
17
|
+
// S.arbitrary((_) => {
|
|
18
18
|
// throw new Error("Cannot arb JWT")
|
|
19
19
|
// }), // TODO
|
|
20
|
-
//
|
|
20
|
+
// S.encoder((_) => {
|
|
21
21
|
// throw new Error("can't encode")
|
|
22
22
|
// }),
|
|
23
|
-
|
|
23
|
+
S.parser((p: any) => {
|
|
24
24
|
try {
|
|
25
25
|
return Th.succeed(
|
|
26
26
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
27
27
|
jwtDecode(p)
|
|
28
28
|
)
|
|
29
29
|
} catch (err) {
|
|
30
|
-
return Th.fail(
|
|
30
|
+
return Th.fail(S.leafE(S.parseStringE(p))) // "not a JWT: " + err as anyw
|
|
31
31
|
}
|
|
32
32
|
}),
|
|
33
|
-
|
|
34
|
-
|
|
33
|
+
S.mapApi(() => ({})),
|
|
34
|
+
S.annotate(jwtIdentifier, {})
|
|
35
35
|
)
|
|
36
36
|
|
|
37
|
-
export const jwt =
|
|
37
|
+
export const jwt = S.string[">>>"](jwtFromString)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/* eslint-disable @typescript-eslint/ban-types */
|
|
2
2
|
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
3
|
-
import * as
|
|
3
|
+
import * as S from "@effect-app/schema"
|
|
4
4
|
import type { Methods } from "@effect-app/schema"
|
|
5
5
|
|
|
6
6
|
import type { JSONSchema, ParameterLocation, SubSchema } from "@effect-app/infra-adapters/Openapi/atlas-plutus"
|
|
@@ -15,14 +15,14 @@ export type Request<
|
|
|
15
15
|
BodyA,
|
|
16
16
|
HeaderA,
|
|
17
17
|
ReqA extends PathA & QueryA & BodyA
|
|
18
|
-
> =
|
|
18
|
+
> = S.ReqResSchemed<unknown, ReqA> & {
|
|
19
19
|
method: Methods.Rest
|
|
20
20
|
path: string
|
|
21
|
-
Cookie?:
|
|
22
|
-
Path?:
|
|
23
|
-
Body?:
|
|
24
|
-
Query?:
|
|
25
|
-
Headers?:
|
|
21
|
+
Cookie?: S.ReqRes<Record<string, string>, CookieA>
|
|
22
|
+
Path?: S.ReqRes<Record<string, string>, PathA>
|
|
23
|
+
Body?: S.ReqRes<unknown, BodyA>
|
|
24
|
+
Query?: S.ReqRes<Record<string, string>, QueryA>
|
|
25
|
+
Headers?: S.ReqRes<Record<string, string>, HeaderA>
|
|
26
26
|
Tag: Tag<M, M>
|
|
27
27
|
}
|
|
28
28
|
|
|
@@ -37,7 +37,7 @@ export interface RouteRequestHandler<
|
|
|
37
37
|
ResA
|
|
38
38
|
> {
|
|
39
39
|
Request: Request<M, PathA, CookieA, QueryA, BodyA, HeaderA, ReqA>
|
|
40
|
-
Response?:
|
|
40
|
+
Response?: S.ReqRes<unknown, ResA> | S.ReqResSchemed<unknown, ResA>
|
|
41
41
|
ResponseOpenApi?: any
|
|
42
42
|
}
|
|
43
43
|
|
|
@@ -123,10 +123,10 @@ export function makeFromSchema<ResA>(
|
|
|
123
123
|
e: RouteDescriptor<any, any, any, any, any, any, ResA, any>
|
|
124
124
|
) {
|
|
125
125
|
const jsonSchema_ = OpenApi.for
|
|
126
|
-
const jsonSchema = <E, A>(r:
|
|
126
|
+
const jsonSchema = <E, A>(r: S.ReqRes<E, A>) => jsonSchema_(r)
|
|
127
127
|
const { Request: Req, Response: Res_, ResponseOpenApi } = e.handler
|
|
128
128
|
const r = ResponseOpenApi ?? Res_
|
|
129
|
-
const Res = r ?
|
|
129
|
+
const Res = r ? S.extractSchema(r) : S.Void
|
|
130
130
|
// TODO EffectOption.fromNullable(Req.Headers).flatMapOpt(jsonSchema)
|
|
131
131
|
// TODO: use the path vs body etc serialisation also in the Client.
|
|
132
132
|
const makeReqQuerySchema = Effect(Option.fromNullable(Req.Query)).flatMap((_) =>
|
|
@@ -182,7 +182,7 @@ export function makeFromSchema<ResA>(
|
|
|
182
182
|
|
|
183
183
|
return Effect
|
|
184
184
|
.all({
|
|
185
|
-
req: jsonSchema(Req.
|
|
185
|
+
req: jsonSchema(Req.Class),
|
|
186
186
|
reqQuery: makeReqQuerySchema,
|
|
187
187
|
reqHeaders: makeReqHeadersSchema,
|
|
188
188
|
reqBody: makeReqBodySchema,
|
|
@@ -192,7 +192,7 @@ export function makeFromSchema<ResA>(
|
|
|
192
192
|
})
|
|
193
193
|
.map((_) => {
|
|
194
194
|
// console.log("$$$ REQ", _.req)
|
|
195
|
-
const isEmpty = !e.handler.Response || e.handler.Response ===
|
|
195
|
+
const isEmpty = !e.handler.Response || e.handler.Response === S.Void
|
|
196
196
|
return {
|
|
197
197
|
path: e.path,
|
|
198
198
|
method: e.method.toLowerCase(),
|
|
@@ -28,9 +28,9 @@ export function makeMemQueue<
|
|
|
28
28
|
const qDrain = yield* $(mem.getOrCreateQueue(queueDrainName))
|
|
29
29
|
const rcc = yield* $(RequestContextContainer)
|
|
30
30
|
|
|
31
|
-
const wireSchema =
|
|
31
|
+
const wireSchema = struct({ body: schema, meta: QueueMeta })
|
|
32
32
|
const encoder = wireSchema.Encoder
|
|
33
|
-
const drainW =
|
|
33
|
+
const drainW = struct({ body: drainSchema, meta: QueueMeta })
|
|
34
34
|
const parseDrain = drainW.parseCondemnDie
|
|
35
35
|
|
|
36
36
|
return {
|
|
@@ -10,6 +10,7 @@ import type {} from "@azure/service-bus"
|
|
|
10
10
|
import { captureException } from "@effect-app/infra/errorReporter"
|
|
11
11
|
import { RequestContext } from "@effect-app/infra/RequestContext"
|
|
12
12
|
import { RequestId } from "@effect-app/prelude/ids"
|
|
13
|
+
import { struct } from "@effect-app/schema"
|
|
13
14
|
import { Tracer } from "effect"
|
|
14
15
|
import { RequestContextContainer } from "../RequestContextContainer.js"
|
|
15
16
|
import { reportNonInterruptedFailure, reportNonInterruptedFailureCause } from "./errors.js"
|
|
@@ -31,12 +32,12 @@ export function makeServiceBusQueue<
|
|
|
31
32
|
drainSchema: Schema.Schema<unknown, DrainEvt, any, any, any>,
|
|
32
33
|
makeHandleEvent: Effect<DrainR, never, (ks: DrainEvt) => Effect<never, DrainE, void>>
|
|
33
34
|
) {
|
|
34
|
-
const wireSchema =
|
|
35
|
+
const wireSchema = struct({
|
|
35
36
|
body: schema,
|
|
36
37
|
meta: QueueMeta
|
|
37
38
|
})
|
|
38
39
|
const encoder = wireSchema.Encoder
|
|
39
|
-
const drainW =
|
|
40
|
+
const drainW = struct({ body: drainSchema, meta: QueueMeta })
|
|
40
41
|
const parseDrain = drainW.parseCondemnDie
|
|
41
42
|
|
|
42
43
|
return Effect.gen(function*($) {
|
|
@@ -15,9 +15,9 @@ export interface QueueBase<RContext, Evt> {
|
|
|
15
15
|
export interface QueueMakerOps {}
|
|
16
16
|
export const QueueMaker: QueueMakerOps = {}
|
|
17
17
|
|
|
18
|
-
export const QueueMeta =
|
|
18
|
+
export const QueueMeta = struct({
|
|
19
19
|
requestContext: RequestContext,
|
|
20
|
-
span:
|
|
20
|
+
span: struct({
|
|
21
21
|
spanId: string,
|
|
22
22
|
traceId: string,
|
|
23
23
|
sampled: bool.optional
|
|
@@ -85,17 +85,17 @@ export function makeRepo<
|
|
|
85
85
|
T extends { id: string },
|
|
86
86
|
ConstructorInput,
|
|
87
87
|
Api,
|
|
88
|
-
|
|
88
|
+
From extends { id: string }
|
|
89
89
|
>(
|
|
90
90
|
name: ItemType,
|
|
91
|
-
schema: Schema.Schema<unknown, T, ConstructorInput,
|
|
92
|
-
mapFrom: (pm: Omit<PM, "_etag">) =>
|
|
93
|
-
mapTo: (e:
|
|
91
|
+
schema: Schema.Schema<unknown, T, ConstructorInput, From, Api>,
|
|
92
|
+
mapFrom: (pm: Omit<PM, "_etag">) => From,
|
|
93
|
+
mapTo: (e: From, etag: string | undefined) => PM
|
|
94
94
|
) => {
|
|
95
95
|
const where = makeWhere<PM>()
|
|
96
96
|
|
|
97
97
|
function mapToPersistenceModel(
|
|
98
|
-
e:
|
|
98
|
+
e: From,
|
|
99
99
|
getEtag: (id: string) => string | undefined
|
|
100
100
|
): PM {
|
|
101
101
|
return mapTo(e, getEtag(e.id))
|
|
@@ -104,7 +104,7 @@ export function makeRepo<
|
|
|
104
104
|
function mapReverse(
|
|
105
105
|
{ _etag, ...e }: PM,
|
|
106
106
|
setEtag: (id: string, eTag: string | undefined) => void
|
|
107
|
-
):
|
|
107
|
+
): From {
|
|
108
108
|
setEtag(e.id, _etag)
|
|
109
109
|
return mapFrom(e)
|
|
110
110
|
}
|
|
@@ -159,7 +159,7 @@ export function makeRepo<
|
|
|
159
159
|
return findE(id).flatMapOpt(EParserFor(schema).condemnDie)
|
|
160
160
|
}
|
|
161
161
|
|
|
162
|
-
const saveAllE = (a: Iterable<
|
|
162
|
+
const saveAllE = (a: Iterable<From>) =>
|
|
163
163
|
Effect(a.toNonEmptyArray)
|
|
164
164
|
.flatMapOpt((a) =>
|
|
165
165
|
Do(($) => {
|
|
@@ -495,7 +495,7 @@ export const RepositoryDefaultImpl = <Service>() => {
|
|
|
495
495
|
}
|
|
496
496
|
|
|
497
497
|
// @useClassFeaturesForSchema
|
|
498
|
-
// export class Shop extends
|
|
498
|
+
// export class Shop extends Class<Shop>()({ id: string }) {}
|
|
499
499
|
|
|
500
500
|
// /**
|
|
501
501
|
// * @tsplus type ShopRepo
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { flow } from "@effect-app/core/Function"
|
|
2
|
-
import * as
|
|
2
|
+
import * as S from "@effect-app/schema"
|
|
3
3
|
|
|
4
4
|
import type { CachedRecord, DBRecord } from "./shared.js"
|
|
5
5
|
import { getRecordName, makeMap, SerializedDBRecord } from "./shared.js"
|
|
@@ -10,7 +10,7 @@ import type { Version } from "./simpledb.js"
|
|
|
10
10
|
// Do not try this at home.
|
|
11
11
|
const storage = makeMap<string, string>()
|
|
12
12
|
|
|
13
|
-
const parseSDB = SerializedDBRecord.Parser >=
|
|
13
|
+
const parseSDB = SerializedDBRecord.Parser >= S.condemnFail
|
|
14
14
|
|
|
15
15
|
export function createContext<TKey extends string, EA, A extends DBRecord<TKey>>() {
|
|
16
16
|
return <REncode, RDecode, EDecode>(
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
import { flow, pipe } from "@effect-app/core/Function"
|
|
4
4
|
import { RedisClient } from "@effect-app/infra-adapters/redis-client"
|
|
5
|
-
import * as
|
|
5
|
+
import * as S from "@effect-app/schema"
|
|
6
6
|
import type { Lock } from "redlock"
|
|
7
7
|
import type { CachedRecord, DBRecord, Index } from "./shared.js"
|
|
8
8
|
import { ConnectionException, CouldNotAquireDbLockException, getIndexName, getRecordName } from "./shared.js"
|
|
@@ -31,7 +31,7 @@ export function createContext<TKey extends string, EA, A extends DBRecord<TKey>>
|
|
|
31
31
|
.flatMapOpt((v) =>
|
|
32
32
|
pipe(
|
|
33
33
|
RedisSerializedDBRecord.Parser,
|
|
34
|
-
|
|
34
|
+
S.condemnFail
|
|
35
35
|
)(v)
|
|
36
36
|
.map(({ data, version }) => ({
|
|
37
37
|
data: JSON.parse(data) as EA,
|
|
@@ -188,8 +188,8 @@ export function createContext<TKey extends string, EA, A extends DBRecord<TKey>>
|
|
|
188
188
|
}
|
|
189
189
|
}
|
|
190
190
|
|
|
191
|
-
export class RedisSerializedDBRecord extends
|
|
192
|
-
version:
|
|
193
|
-
timestamp:
|
|
194
|
-
data:
|
|
191
|
+
export class RedisSerializedDBRecord extends S.Class<RedisSerializedDBRecord>()({
|
|
192
|
+
version: S.string,
|
|
193
|
+
timestamp: S.date,
|
|
194
|
+
data: S.string
|
|
195
195
|
}) {}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as S from "@effect-app/schema"
|
|
2
2
|
import type { SchemaAny } from "@effect-app/schema"
|
|
3
3
|
|
|
4
4
|
export class CouldNotAquireDbLockException
|
|
@@ -28,18 +28,18 @@ export interface DBRecord<TKey extends string> {
|
|
|
28
28
|
id: TKey
|
|
29
29
|
}
|
|
30
30
|
|
|
31
|
-
export class SerializedDBRecord extends
|
|
32
|
-
version:
|
|
33
|
-
timestamp:
|
|
34
|
-
data:
|
|
31
|
+
export class SerializedDBRecord extends S.Class<SerializedDBRecord>()({
|
|
32
|
+
version: S.string,
|
|
33
|
+
timestamp: S.date,
|
|
34
|
+
data: S.string
|
|
35
35
|
}) {}
|
|
36
36
|
|
|
37
37
|
// unknown -> string -> SDB?
|
|
38
38
|
export function makeSerialisedDBRecord(s: SchemaAny) {
|
|
39
|
-
return
|
|
40
|
-
version:
|
|
41
|
-
timestamp:
|
|
42
|
-
data:
|
|
39
|
+
return S.struct({
|
|
40
|
+
version: S.number,
|
|
41
|
+
timestamp: S.date,
|
|
42
|
+
data: s
|
|
43
43
|
})
|
|
44
44
|
}
|
|
45
45
|
|
|
@@ -80,7 +80,7 @@ export interface EffectMap<TKey, T> {
|
|
|
80
80
|
}
|
|
81
81
|
|
|
82
82
|
// export function encodeOnlyWhenStrictMatch<A, E>(
|
|
83
|
-
// encode:
|
|
83
|
+
// encode: S.HasEncoder<A, E>["encode_"],
|
|
84
84
|
// v: A
|
|
85
85
|
// ) {
|
|
86
86
|
// const e1 = Sync.run(encode(v, "strict"))
|
|
@@ -98,7 +98,7 @@ export interface EffectMap<TKey, T> {
|
|
|
98
98
|
// }
|
|
99
99
|
|
|
100
100
|
// export function decodeOnlyWhenStrictMatch<A, E>(
|
|
101
|
-
// decode:
|
|
101
|
+
// decode: S.HasDecoder<A, E>["decode_"],
|
|
102
102
|
// u: unknown
|
|
103
103
|
// ) {
|
|
104
104
|
// return pipe(
|