@effect-app/infra 0.36.2 → 0.37.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 +6 -0
- package/_cjs/RequestContext.cjs +0 -7
- package/_cjs/RequestContext.cjs.map +1 -1
- package/_cjs/api/reportError.cjs +8 -9
- package/_cjs/api/reportError.cjs.map +1 -1
- package/_cjs/api/routing.cjs +34 -34
- package/_cjs/api/routing.cjs.map +1 -1
- package/_cjs/api/setupRequest.cjs +8 -8
- package/_cjs/api/setupRequest.cjs.map +1 -1
- package/_cjs/services/QueueMaker/errors.cjs +9 -10
- package/_cjs/services/QueueMaker/errors.cjs.map +1 -1
- package/_cjs/services/QueueMaker/memQueue.cjs +16 -15
- package/_cjs/services/QueueMaker/memQueue.cjs.map +1 -1
- package/_cjs/services/QueueMaker/sbqueue.cjs +8 -7
- package/_cjs/services/QueueMaker/sbqueue.cjs.map +1 -1
- package/_cjs/services/RequestContextContainer.cjs +60 -0
- package/_cjs/services/RequestContextContainer.cjs.map +1 -0
- package/_cjs/services/Store/Memory.cjs +35 -36
- package/_cjs/services/Store/Memory.cjs.map +1 -1
- package/_src/RequestContext.ts +0 -5
- package/_src/api/reportError.ts +3 -3
- package/_src/api/routing.ts +2 -1
- package/_src/api/setupRequest.ts +3 -2
- package/_src/services/QueueMaker/errors.ts +4 -3
- package/_src/services/QueueMaker/memQueue.ts +3 -2
- package/_src/services/QueueMaker/sbqueue.ts +3 -2
- package/_src/services/QueueMaker/service.ts +2 -2
- package/_src/services/RequestContextContainer.ts +41 -0
- package/_src/services/Store/Memory.ts +2 -2
- package/dist/RequestContext.d.ts +0 -5
- package/dist/RequestContext.d.ts.map +1 -1
- package/dist/RequestContext.js +1 -6
- package/dist/api/defaultErrorHandler.d.ts +2 -2
- package/dist/api/defaultErrorHandler.d.ts.map +1 -1
- package/dist/api/reportError.d.ts +5 -5
- package/dist/api/reportError.d.ts.map +1 -1
- package/dist/api/reportError.js +9 -10
- package/dist/api/routing.d.ts.map +1 -1
- package/dist/api/routing.js +28 -28
- package/dist/api/setupRequest.d.ts +3 -2
- package/dist/api/setupRequest.d.ts.map +1 -1
- package/dist/api/setupRequest.js +7 -7
- package/dist/services/Operations/service.d.ts +4 -4
- package/dist/services/Operations/service.d.ts.map +1 -1
- package/dist/services/QueueMaker/errors.d.ts +0 -1
- package/dist/services/QueueMaker/errors.d.ts.map +1 -1
- package/dist/services/QueueMaker/errors.js +10 -12
- package/dist/services/QueueMaker/memQueue.d.ts +3 -2
- package/dist/services/QueueMaker/memQueue.d.ts.map +1 -1
- package/dist/services/QueueMaker/memQueue.js +13 -13
- package/dist/services/QueueMaker/sbqueue.d.ts +3 -2
- package/dist/services/QueueMaker/sbqueue.d.ts.map +1 -1
- package/dist/services/QueueMaker/sbqueue.js +7 -7
- package/dist/services/QueueMaker/service.d.ts +2 -2
- package/dist/services/QueueMaker/service.d.ts.map +1 -1
- package/dist/services/RequestContextContainer.d.ts +29 -0
- package/dist/services/RequestContextContainer.d.ts.map +1 -0
- package/dist/services/RequestContextContainer.js +51 -0
- package/dist/services/Store/Memory.d.ts +2 -2
- package/dist/services/Store/Memory.d.ts.map +1 -1
- package/dist/services/Store/Memory.js +37 -38
- package/package.json +12 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"memQueue.cjs","names":["_memQueue","require","_Memory","_errors2","_getRequireWildcardCache","nodeInterop","WeakMap","cacheBabelInterop","cacheNodeInterop","_interopRequireWildcard","obj","__esModule","default","cache","has","get","newObj","hasPropertyDescriptor","Object","defineProperty","getOwnPropertyDescriptor","key","prototype","hasOwnProperty","call","desc","set","makeMemQueue","queueName","queueDrainName","encoder","makeHandleEvent","provideContext","parseDrain","tsplus_module_1","gen","$","mem","service","MemQueue","q","getOrCreateQueue","qDrain","publish","messages","requestContext","
|
|
1
|
+
{"version":3,"file":"memQueue.cjs","names":["_memQueue","require","_RequestContext","_RequestContextContainer","_Memory","_errors2","_getRequireWildcardCache","nodeInterop","WeakMap","cacheBabelInterop","cacheNodeInterop","_interopRequireWildcard","obj","__esModule","default","cache","has","get","newObj","hasPropertyDescriptor","Object","defineProperty","getOwnPropertyDescriptor","key","prototype","hasOwnProperty","call","desc","set","makeMemQueue","queueName","queueDrainName","encoder","makeHandleEvent","provideContext","parseDrain","tsplus_module_1","gen","$","mem","service","MemQueue","q","getOrCreateQueue","qDrain","publish","messages","requestContext","RequestContextContainer","tsplus_module_3","forkDaemonReportQueue","tsplus_module_2","ext_forEach","m","asUnit","flatMap","sync","JSON","stringify","body","meta","_","offer","drain","handleEvent","silenceAndReportError","reportNonInterruptedFailure","name","processMessage","msg","orDie","parse","RequestContext","inherit","id","locale","tsplus_module_6","ReasonableString","_tag","zipRight","tap","tsplus_module_5","logAnnotates","tsplus_module_4","RecordPretty","object$","logDebug","restoreFromRequestContext","forkScoped","forever","take","x","fork","uninterruptible","tsplus_module_7","join"],"sources":["../../../_src/services/QueueMaker/memQueue.ts"],"sourcesContent":[null],"mappings":";;;;;;;;;;;;;AAAA,IAAAA,SAAA,GAAAC,OAAA;AACA,IAAAC,eAAA,GAAAD,OAAA;AAEA,IAAAE,wBAAA,GAAAF,OAAA;AACA,IAAAG,OAAA,GAAAH,OAAA;AACA,IAAAI,QAAA,GAAAJ,OAAA;AAAyD,SAAAK,yBAAAC,WAAA,eAAAC,OAAA,kCAAAC,iBAAA,OAAAD,OAAA,QAAAE,gBAAA,OAAAF,OAAA,YAAAF,wBAAA,YAAAA,CAAAC,WAAA,WAAAA,WAAA,GAAAG,gBAAA,GAAAD,iBAAA,KAAAF,WAAA;AAAA,SAAAI,wBAAAC,GAAA,EAAAL,WAAA,SAAAA,WAAA,IAAAK,GAAA,IAAAA,GAAA,CAAAC,UAAA,WAAAD,GAAA,QAAAA,GAAA,oBAAAA,GAAA,wBAAAA,GAAA,4BAAAE,OAAA,EAAAF,GAAA,UAAAG,KAAA,GAAAT,wBAAA,CAAAC,WAAA,OAAAQ,KAAA,I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AA,CAAA4C,GAAA,CAESC,eAAA,CAAAC,YAAA,CAAoB;UAAEvB,IAAI,EAAAwB,eAAA,CAAAC,YAAA,CAAAD,eAAA,CAAAE,OAAA,CAAE1B,IAAI,EAAU;UAAEC,IAAI,EAAAuB,eAAA,CAAAC,YAAA,CAAAD,eAAA,CAAAE,OAAA,CAAEzB,IAAI;QAAU,CAAE,CAAC,CAF5ExB,eAAA,CAAAkD,QAAA,CACY,OAAOvD,cAAc,+BAA+B,CAAC,GAE1D,MAAMwD,iCAAyB,CAAC,EAC3BvB,WAAW,CAACL,IAAI,CAAC,CAAC,EAU3B,CACJ;QACL,OAAO,OAAOrB,CAAC,CAAAF,eAAA,CAAAoD,UAAA,CAAApD,eAAA,CAAAqD,OAAA,CAKJxB,qBAAqB,CAJ9B7B,eAAA,CAAAmB,OAAA,CAAAX,MAAM,CAAC8C,IAAI,EAAE,EACFC,CAAC,IAAIvD,eAAA,CAAAmB,OAAA,CAAAnB,eAAA,CAAAwD,IAAA,CAAAxD,eAAA,CAAAyD,eAAA,CAAAzB,cAAc,CAACuB,CAAC,CAAC,IAA8B9B,CAAC,IAAGiC,eAAA,CAAAC,IAAA,CAAClC,CAAC,CAAK,CAAC;QACzE;QACA;QAAA,C,GAIH;MACH,CAAC;KAC+B;EACpC,CAAC,CAAC;AACJ"}
|
|
@@ -10,11 +10,12 @@ var tsplus_module_2 = _interopRequireWildcard(require("@effect-app/core/Tag"));
|
|
|
10
10
|
var tsplus_module_3 = _interopRequireWildcard(require("@effect-app/prelude/utils"));
|
|
11
11
|
var tsplus_module_4 = _interopRequireWildcard(require("@effect-app/prelude/_ext/misc"));
|
|
12
12
|
var tsplus_module_5 = _interopRequireWildcard(require("@effect-app/prelude/schema"));
|
|
13
|
-
var tsplus_module_6 = _interopRequireWildcard(require("@effect-app/infra/
|
|
14
|
-
var tsplus_module_7 = _interopRequireWildcard(require("@effect
|
|
15
|
-
var tsplus_module_8 = _interopRequireWildcard(require("@effect/io/Layer"));
|
|
13
|
+
var tsplus_module_6 = _interopRequireWildcard(require("@effect-app/infra/services/QueueMaker/errors"));
|
|
14
|
+
var tsplus_module_7 = _interopRequireWildcard(require("@effect/io/Layer"));
|
|
16
15
|
var _ServiceBus = require("@effect-app/infra-adapters/ServiceBus");
|
|
17
16
|
var _errorReporter = require("@effect-app/infra/errorReporter");
|
|
17
|
+
var _RequestContext = require("@effect-app/infra/RequestContext");
|
|
18
|
+
var _RequestContextContainer = require("../RequestContextContainer.cjs");
|
|
18
19
|
var _Memory = require("../Store/Memory.cjs");
|
|
19
20
|
var _errors2 = require("./errors.cjs");
|
|
20
21
|
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); }
|
|
@@ -41,7 +42,7 @@ function makeServiceBusQueue(_queueName, queueDrainName, encoder, makeHandleEven
|
|
|
41
42
|
return tsplus_module_1.tapErrorCause(tsplus_module_1.flatMap(tsplus_module_1.orDie(tsplus_module_1.flatMap(tsplus_module_1.sync(() => JSON.parse(messageBody)), x => parseDrain(x))), ({
|
|
42
43
|
body,
|
|
43
44
|
meta
|
|
44
|
-
}) => provideContext(
|
|
45
|
+
}) => provideContext(_RequestContext.RequestContext.inherit(meta, {
|
|
45
46
|
id: body.id,
|
|
46
47
|
locale: "en",
|
|
47
48
|
name: tsplus_module_5.ReasonableString(body._tag)
|
|
@@ -58,8 +59,8 @@ function makeServiceBusQueue(_queueName, queueDrainName, encoder, makeHandleEven
|
|
|
58
59
|
}), receiverLayer));
|
|
59
60
|
}),
|
|
60
61
|
publish: (...messages) => tsplus_module_1.gen(function* ($) {
|
|
61
|
-
const requestContext = yield* $(
|
|
62
|
-
return yield* $(
|
|
62
|
+
const requestContext = yield* $(_RequestContextContainer.RequestContextContainer.get);
|
|
63
|
+
return yield* $(tsplus_module_6.forkDaemonReportQueue(tsplus_module_1.promise(() => s.sendMessages(messages.map(x => ({
|
|
63
64
|
body: JSON.stringify(encoder({
|
|
64
65
|
body: x,
|
|
65
66
|
meta: requestContext
|
|
@@ -75,6 +76,6 @@ function makeServiceBusQueue(_queueName, queueDrainName, encoder, makeHandleEven
|
|
|
75
76
|
* @tsplus static QueueMaker.Ops makeServiceBusLayers
|
|
76
77
|
*/
|
|
77
78
|
function makeServiceBusLayers(url, queueName, queueDrainName) {
|
|
78
|
-
return
|
|
79
|
+
return tsplus_module_7.provide(tsplus_module_7.merge((0, _ServiceBus.LiveSender)(queueName))((0, _ServiceBus.LiveReceiver)(queueDrainName)))((0, _ServiceBus.LiveServiceBusClient)(url));
|
|
79
80
|
}
|
|
80
81
|
//# sourceMappingURL=sbqueue.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sbqueue.cjs","names":["_ServiceBus","require","_errorReporter","_Memory","_errors2","_getRequireWildcardCache","nodeInterop","WeakMap","cacheBabelInterop","cacheNodeInterop","_interopRequireWildcard","obj","__esModule","default","cache","has","get","newObj","hasPropertyDescriptor","Object","defineProperty","getOwnPropertyDescriptor","key","prototype","hasOwnProperty","call","desc","set","makeServiceBusQueue","_queueName","queueDrainName","encoder","makeHandleEvent","provideContext","parseDrain","tsplus_module_1","gen","$","s","service","Sender","receiver","Receiver","receiverLayer","tsplus_module_2","makeLayer","silenceAndReportError","reportNonInterruptedFailure","name","reportError","reportNonInterruptedFailureCause","drain","handleEvent","processMessage","messageBody","tapErrorCause","flatMap","orDie","sync","JSON","parse","x","body","meta","RequestContext","inherit","id","locale","tsplus_module_5","ReasonableString","_tag","zipRight","tap","tsplus_module_4","logAnnotates","tsplus_module_3","RecordPretty","object$","logDebug","restoreFromRequestContext","provideSomeLayer","subscribe","uninterruptible","_","done","processError","err","captureException","error","publish","messages","requestContext","
|
|
1
|
+
{"version":3,"file":"sbqueue.cjs","names":["_ServiceBus","require","_errorReporter","_RequestContext","_RequestContextContainer","_Memory","_errors2","_getRequireWildcardCache","nodeInterop","WeakMap","cacheBabelInterop","cacheNodeInterop","_interopRequireWildcard","obj","__esModule","default","cache","has","get","newObj","hasPropertyDescriptor","Object","defineProperty","getOwnPropertyDescriptor","key","prototype","hasOwnProperty","call","desc","set","makeServiceBusQueue","_queueName","queueDrainName","encoder","makeHandleEvent","provideContext","parseDrain","tsplus_module_1","gen","$","s","service","Sender","receiver","Receiver","receiverLayer","tsplus_module_2","makeLayer","silenceAndReportError","reportNonInterruptedFailure","name","reportError","reportNonInterruptedFailureCause","drain","handleEvent","processMessage","messageBody","tapErrorCause","flatMap","orDie","sync","JSON","parse","x","body","meta","RequestContext","inherit","id","locale","tsplus_module_5","ReasonableString","_tag","zipRight","tap","tsplus_module_4","logAnnotates","tsplus_module_3","RecordPretty","object$","logDebug","restoreFromRequestContext","provideSomeLayer","subscribe","uninterruptible","_","done","processError","err","captureException","error","publish","messages","requestContext","RequestContextContainer","tsplus_module_6","forkDaemonReportQueue","promise","sendMessages","map","stringify","messageId","contentType","makeServiceBusLayers","url","queueName","tsplus_module_7","provide","merge","LiveSender","LiveReceiver","LiveServiceBusClient"],"sources":["../../../_src/services/QueueMaker/sbqueue.ts"],"sourcesContent":[null],"mappings":";;;;;;;;;;;;;;AAAA,IAAAA,WAAA,GAAAC,OAAA;AASA,IAAAC,cAAA,GAAAD,OAAA;AACA,IAAAE,eAAA,GAAAF,OAAA;AAEA,IAAAG,wBAAA,GAAAH,OAAA;AACA,IAAAI,OAAA,GAAAJ,OAAA;AACA,IAAAK,QAAA,GAAAL,OAAA;AAA2F,SAAAM,yBAAAC,WAAA,eAAAC,OAAA,kCAAAC,iBAAA,OAAAD,OAAA,QAAAE,gBAAA,OAAAF,OAAA,YAAAF,wBAAA,YAAAA,CAAAC,WAAA,WAAAA,WAAA,GAAAG,gBAAA,GAAAD,iBAAA,KAAAF,WAAA;AAAA,SAAAI,wBAAAC,GAAA,EAAAL,WAAA,SAAAA,WAAA,IAAAK,GA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A;;;AAGM,SAAUC,oBAAoBA,CAACC,GAAW,EAAEC,SAAiB,EAAEzE,cAAsB;EACzF,OAAA0E,eAAA,CAAAC,OAAA,CACKD,eAAA,CAAAE,KAAA,CAAgC,IAAAC,sBAAU,EAACJ,SAAS,CAAC,EAApD,IAAAK,wBAAY,EAAC9E,cAAc,CAAC,EAAyB,CADpD,IAAA+E,gCAAoB,EAACP,GAAG,CAAC;AAElC"}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.RequestContextContainerImpl = exports.RequestContextContainer = void 0;
|
|
7
|
+
exports.live = live;
|
|
8
|
+
var tsplus_module_1 = _interopRequireWildcard(require("@effect-app/prelude/service"));
|
|
9
|
+
var tsplus_module_2 = _interopRequireWildcard(require("@effect/io/Effect"));
|
|
10
|
+
var tsplus_module_3 = _interopRequireWildcard(require("@effect/data/Option"));
|
|
11
|
+
var tsplus_module_4 = _interopRequireWildcard(require("@effect-app/core/Option"));
|
|
12
|
+
var tsplus_module_5 = _interopRequireWildcard(require("@effect/data/Context"));
|
|
13
|
+
var tsplus_module_6 = _interopRequireWildcard(require("@effect/io/Ref"));
|
|
14
|
+
var _RequestContext = require("../RequestContext.cjs");
|
|
15
|
+
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); }
|
|
16
|
+
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; }
|
|
17
|
+
var __classPrivateFieldSet = void 0 && (void 0).__classPrivateFieldSet || function (receiver, state, value, kind, f) {
|
|
18
|
+
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
19
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
20
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
21
|
+
return kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value), value;
|
|
22
|
+
};
|
|
23
|
+
var __classPrivateFieldGet = void 0 && (void 0).__classPrivateFieldGet || function (receiver, state, kind, f) {
|
|
24
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
25
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
26
|
+
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
27
|
+
};
|
|
28
|
+
var _RequestContextContainerImpl_ref;
|
|
29
|
+
/**
|
|
30
|
+
* @tsplus companion RequestContextContainer.Ops
|
|
31
|
+
*/
|
|
32
|
+
class RequestContextContainer extends tsplus_module_1.TagClass() {
|
|
33
|
+
static get get() {
|
|
34
|
+
return tsplus_module_2.serviceWithEffect(RequestContextContainer, _ => _.requestContext);
|
|
35
|
+
}
|
|
36
|
+
static get getOption() {
|
|
37
|
+
return tsplus_module_2.flatMap(tsplus_module_2.contextWith(_ => tsplus_module_5.getOption(_, RequestContextContainer)), requestContext => tsplus_module_3.isSome(requestContext) ? tsplus_module_2.map(requestContext.value.requestContext, tsplus_module_3.some) : tsplus_module_2.sync(() => tsplus_module_4.none));
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
exports.RequestContextContainer = RequestContextContainer;
|
|
41
|
+
class RequestContextContainerImpl extends RequestContextContainer {
|
|
42
|
+
constructor(inp) {
|
|
43
|
+
super();
|
|
44
|
+
_RequestContextContainerImpl_ref.set(this, void 0);
|
|
45
|
+
this.update = f => tsplus_module_6.getAndUpdate(__classPrivateFieldGet(this, _RequestContextContainerImpl_ref, "f"), f);
|
|
46
|
+
__classPrivateFieldSet(this, _RequestContextContainerImpl_ref, tsplus_module_6.unsafeMake(new _RequestContext.RequestContext(inp)), "f");
|
|
47
|
+
}
|
|
48
|
+
get requestContext() {
|
|
49
|
+
return tsplus_module_6.get(__classPrivateFieldGet(this, _RequestContextContainerImpl_ref, "f"));
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
exports.RequestContextContainerImpl = RequestContextContainerImpl;
|
|
53
|
+
_RequestContextContainerImpl_ref = new WeakMap();
|
|
54
|
+
/**
|
|
55
|
+
* @tsplus static RequestContextContainer.Ops live
|
|
56
|
+
*/
|
|
57
|
+
function live(inp) {
|
|
58
|
+
return new RequestContextContainerImpl(inp);
|
|
59
|
+
}
|
|
60
|
+
//# sourceMappingURL=RequestContextContainer.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RequestContextContainer.cjs","names":["_RequestContext","require","_getRequireWildcardCache","nodeInterop","WeakMap","cacheBabelInterop","cacheNodeInterop","_interopRequireWildcard","obj","__esModule","default","cache","has","get","newObj","hasPropertyDescriptor","Object","defineProperty","getOwnPropertyDescriptor","key","prototype","hasOwnProperty","call","desc","set","RequestContextContainer","tsplus_module_1","TagClass","tsplus_module_2","serviceWithEffect","_","requestContext","getOption","flatMap","contextWith","tsplus_module_5","tsplus_module_3","isSome","map","value","some","sync","tsplus_module_4","none","exports","RequestContextContainerImpl","constructor","inp","_RequestContextContainerImpl_ref","update","f","tsplus_module_6","getAndUpdate","__classPrivateFieldGet","__classPrivateFieldSet","unsafeMake","RequestContext","live"],"sources":["../../_src/services/RequestContextContainer.ts"],"sourcesContent":[null],"mappings":";;;;;;;;;;;;;AAAA,IAAAA,eAAA,GAAAC,OAAA;AAAqD,SAAAC,yBAAAC,WAAA,eAAAC,OAAA,kCAAAC,iBAAA,OAAAD,OAAA,QAAAE,gBAAA,OAAAF,OAAA,YAAAF,wBAAA,YAAAA,CAAAC,WAAA,WAAAA,WAAA,GAAAG,gBAAA,GAAAD,iBAAA,KAAAF,WAAA;AAAA,SAAAI,wBAAAC,GAAA,EAAAL,WAAA,SAAAA,WAAA,IAAAK,GAAA,IAAAA,GAAA,CAAAC,UAAA,WAAAD,GAAA,QAAAA,GAAA,oBAAAA,GAAA,wBAAAA,GAAA,4BAAAE,OAAA,EAAAF,GAAA,UAAAG,KAAA,GAAAT,wBAAA,CAAAC,WAAA,OAAAQ,KAAA,IAAAA,KAAA,CAAAC,GAAA,CAAAJ,GAAA,YAAAG,KAAA,CAAAE,GAAA,CAAAL,GAAA,SAAAM,MAAA,WAAAC,qBAAA,GAAAC,MAAA,CAAAC,cAAA,IAAAD,MAAA,CAAAE,wBAAA,WAAAC,GAAA,IAAAX,GAAA,QAAAW,GAAA,kBAAAH,MAAA,CAAAI,SAAA,CAAAC,cAAA,CAAAC,IAAA,CAAAd,GAAA,EAAAW,GAAA,SAAAI,IAAA,GAAAR,qBAAA,GAAAC,MAAA,CAAAE,wBAAA,CAAAV,GAAA,EAAAW,GAAA,cAAAI,IAAA,KAAAA,IAAA,CAAAV,GAAA,IAAAU,IAAA,CAAAC,GAAA,KAAAR,MAAA,CAAAC,cAAA,CAAAH,MAAA,EAAAK,GAAA,EAAAI,IAAA,YAAAT,MAAA,CAAAK,GAAA,IAAAX,GAAA,CAAAW,GAAA,SAAAL,MAAA,CAAAJ,OAAA,GAAAF,GAAA,MAAAG,KAAA,IAAAA,KAAA,CAAAa,GAAA,C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AoC;EACvD,OAAO,IAAIF,2BAA2B,CAACE,GAAG,CAAC;AAC7C"}
|
|
@@ -12,12 +12,11 @@ var tsplus_module_2 = _interopRequireWildcard(require("@effect-app/core/Chunk"))
|
|
|
12
12
|
var tsplus_module_3 = _interopRequireWildcard(require("@effect/data/Option"));
|
|
13
13
|
var tsplus_module_4 = _interopRequireWildcard(require("@effect-app/core/Array"));
|
|
14
14
|
var tsplus_module_5 = _interopRequireWildcard(require("@effect/io/FiberRef"));
|
|
15
|
-
var tsplus_module_6 = _interopRequireWildcard(require("@effect
|
|
16
|
-
var tsplus_module_7 = _interopRequireWildcard(require("@effect/io/
|
|
17
|
-
var tsplus_module_8 = _interopRequireWildcard(require("@effect/
|
|
18
|
-
var tsplus_module_9 = _interopRequireWildcard(require("@effect-app/core/
|
|
19
|
-
var
|
|
20
|
-
require("../../RequestContext.cjs");
|
|
15
|
+
var tsplus_module_6 = _interopRequireWildcard(require("@effect/io/Effect"));
|
|
16
|
+
var tsplus_module_7 = _interopRequireWildcard(require("@effect/io/Ref"));
|
|
17
|
+
var tsplus_module_8 = _interopRequireWildcard(require("@effect-app/core/_ext/Iterable"));
|
|
18
|
+
var tsplus_module_9 = _interopRequireWildcard(require("@effect-app/core/Tag"));
|
|
19
|
+
var _RequestContextContainer = require("../RequestContextContainer.cjs");
|
|
21
20
|
var _service = require("./service.cjs");
|
|
22
21
|
var _utils = require("./utils.cjs");
|
|
23
22
|
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); }
|
|
@@ -43,69 +42,69 @@ function memFilter(filter, cursor) {
|
|
|
43
42
|
}
|
|
44
43
|
const storeId = tsplus_module_5.unsafeMake("primary");
|
|
45
44
|
exports.storeId = storeId;
|
|
46
|
-
const restoreFromRequestContext =
|
|
45
|
+
const restoreFromRequestContext = tsplus_module_6.flatMap(_RequestContextContainer.RequestContextContainer.get, ctx => tsplus_module_5.set(storeId, ctx.namespace ?? "primary"));
|
|
47
46
|
exports.restoreFromRequestContext = restoreFromRequestContext;
|
|
48
47
|
function makeMemoryStoreInt(name, seed) {
|
|
49
|
-
return
|
|
48
|
+
return tsplus_module_6.gen(function* ($) {
|
|
50
49
|
const updateETag = (0, _utils.makeUpdateETag)(name);
|
|
51
|
-
const items = yield* $(seed ??
|
|
50
|
+
const items = yield* $(seed ?? tsplus_module_6.sync(() => new Map()));
|
|
52
51
|
const makeStore = () => new Map([...items.entries()].map(([id, e]) => [id, (0, _utils.makeETag)(e)]));
|
|
53
|
-
const store =
|
|
54
|
-
const sem =
|
|
52
|
+
const store = tsplus_module_7.unsafeMake(makeStore());
|
|
53
|
+
const sem = tsplus_module_6.unsafeMakeSemaphore(1);
|
|
55
54
|
const withPermit = sem.withPermits(1);
|
|
56
|
-
const values =
|
|
57
|
-
const all =
|
|
58
|
-
const batchSet = items => withPermit(
|
|
55
|
+
const values = tsplus_module_6.map(tsplus_module_7.get(store), s => s.values());
|
|
56
|
+
const all = tsplus_module_6.map(values, tsplus_module_1.fromIterable);
|
|
57
|
+
const batchSet = items => withPermit(tsplus_module_6.map(tsplus_module_6.tap(tsplus_module_8.ext_forEach(items, i => tsplus_module_6.flatMap(s.find(i.id), current => updateETag(i, current))), items => tsplus_module_6.flatMap(tsplus_module_6.map(tsplus_module_7.get(store), m => {
|
|
59
58
|
const mut = m;
|
|
60
59
|
tsplus_module_1.forEach(items, e => mut.set(e.id, e));
|
|
61
60
|
return mut;
|
|
62
|
-
}), _ =>
|
|
61
|
+
}), _ => tsplus_module_7.set(store, _))), _ => tsplus_module_1.toReadonlyArray(_)));
|
|
63
62
|
const s = {
|
|
64
63
|
all,
|
|
65
|
-
find: id =>
|
|
66
|
-
filter: (filter, cursor) =>
|
|
67
|
-
filterJoinSelect: filter =>
|
|
68
|
-
set: e => withPermit(
|
|
64
|
+
find: id => tsplus_module_6.map(tsplus_module_7.get(store), _ => tsplus_module_3.fromNullable(_.get(id))),
|
|
65
|
+
filter: (filter, cursor) => tsplus_module_6.map(all, memFilter(filter, cursor)),
|
|
66
|
+
filterJoinSelect: filter => tsplus_module_6.map(all, c => tsplus_module_1.flatMap(c, (0, _utils.codeFilterJoinSelect)(filter))),
|
|
67
|
+
set: e => withPermit(tsplus_module_6.tap(tsplus_module_6.flatMap(s.find(e.id), current => updateETag(e, current)), e => tsplus_module_6.flatMap(tsplus_module_6.map(tsplus_module_7.get(store), _ => new Map([..._, [e.id, e]])), _ => tsplus_module_7.set(store, _)))),
|
|
69
68
|
batchSet,
|
|
70
69
|
bulkSet: batchSet,
|
|
71
|
-
remove: e => withPermit(
|
|
70
|
+
remove: e => withPermit(tsplus_module_6.flatMap(tsplus_module_6.map(tsplus_module_7.get(store), _ => new Map([..._].filter(([_]) => _ !== e.id))), _ => tsplus_module_7.set(store, _)))
|
|
72
71
|
};
|
|
73
72
|
return s;
|
|
74
73
|
});
|
|
75
74
|
}
|
|
76
75
|
const makeMemoryStore = () => ({
|
|
77
|
-
make: (name, seed, config) =>
|
|
78
|
-
const storesSem =
|
|
76
|
+
make: (name, seed, config) => tsplus_module_6.gen(function* ($) {
|
|
77
|
+
const storesSem = tsplus_module_6.unsafeMakeSemaphore(1);
|
|
79
78
|
const primary = yield* $(makeMemoryStoreInt(name, seed));
|
|
80
79
|
const stores = new Map([["primary", primary]]);
|
|
81
|
-
const getStore = !config?.allowNamespace ?
|
|
80
|
+
const getStore = !config?.allowNamespace ? tsplus_module_6.succeed(primary) : tsplus_module_6.flatMap(tsplus_module_5.get(storeId), namespace => {
|
|
82
81
|
const store = stores.get(namespace);
|
|
83
82
|
if (store) {
|
|
84
|
-
return
|
|
83
|
+
return tsplus_module_6.succeed(store);
|
|
85
84
|
}
|
|
86
85
|
if (!config.allowNamespace(namespace)) {
|
|
87
86
|
throw new Error(`Namespace ${namespace} not allowed!`);
|
|
88
87
|
}
|
|
89
|
-
return storesSem.withPermits(1)(
|
|
88
|
+
return storesSem.withPermits(1)(tsplus_module_6.suspendSucceed(() => {
|
|
90
89
|
const store = stores.get(namespace);
|
|
91
|
-
if (store) return
|
|
92
|
-
return
|
|
90
|
+
if (store) return tsplus_module_6.sync(() => store);
|
|
91
|
+
return tsplus_module_6.tap(makeMemoryStoreInt(name, seed), store => tsplus_module_6.sync(() => stores.set(namespace, store)));
|
|
93
92
|
}));
|
|
94
93
|
});
|
|
95
94
|
const s = {
|
|
96
|
-
all:
|
|
97
|
-
find: (...args) =>
|
|
98
|
-
filter: (...args) =>
|
|
99
|
-
filterJoinSelect: (...args) =>
|
|
100
|
-
set: (...args) =>
|
|
101
|
-
batchSet: (...args) =>
|
|
102
|
-
bulkSet: (...args) =>
|
|
103
|
-
remove: (...args) =>
|
|
95
|
+
all: tsplus_module_6.flatMap(getStore, _ => _.all),
|
|
96
|
+
find: (...args) => tsplus_module_6.flatMap(getStore, _ => _.find(...args)),
|
|
97
|
+
filter: (...args) => tsplus_module_6.flatMap(getStore, _ => _.filter(...args)),
|
|
98
|
+
filterJoinSelect: (...args) => tsplus_module_6.flatMap(getStore, _ => _.filterJoinSelect(...args)),
|
|
99
|
+
set: (...args) => tsplus_module_6.flatMap(getStore, _ => _.set(...args)),
|
|
100
|
+
batchSet: (...args) => tsplus_module_6.flatMap(getStore, _ => _.batchSet(...args)),
|
|
101
|
+
bulkSet: (...args) => tsplus_module_6.flatMap(getStore, _ => _.bulkSet(...args)),
|
|
102
|
+
remove: (...args) => tsplus_module_6.flatMap(getStore, _ => _.remove(...args))
|
|
104
103
|
};
|
|
105
104
|
return s;
|
|
106
105
|
})
|
|
107
106
|
});
|
|
108
107
|
exports.makeMemoryStore = makeMemoryStore;
|
|
109
|
-
const MemoryStoreLive =
|
|
108
|
+
const MemoryStoreLive = tsplus_module_9.makeLayer(_service.StoreMaker, makeMemoryStore());
|
|
110
109
|
exports.MemoryStoreLive = MemoryStoreLive;
|
|
111
110
|
//# sourceMappingURL=Memory.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Memory.cjs","names":["require","_service","_utils","_getRequireWildcardCache","nodeInterop","WeakMap","cacheBabelInterop","cacheNodeInterop","_interopRequireWildcard","obj","__esModule","default","cache","has","get","newObj","hasPropertyDescriptor","Object","defineProperty","getOwnPropertyDescriptor","key","prototype","hasOwnProperty","call","desc","set","memFilter","filter","cursor","c","skip","limit","tsplus_module_3","getOrElse","map","tsplus_module_2","findFirstMap","codeFilter","tsplus_module_1","make","empty","r","filterMap","drop","undefined","take","tsplus_module_4","ext_itToChunk","storeId","tsplus_module_5","unsafeMake","exports","restoreFromRequestContext","
|
|
1
|
+
{"version":3,"file":"Memory.cjs","names":["_RequestContextContainer","require","_service","_utils","_getRequireWildcardCache","nodeInterop","WeakMap","cacheBabelInterop","cacheNodeInterop","_interopRequireWildcard","obj","__esModule","default","cache","has","get","newObj","hasPropertyDescriptor","Object","defineProperty","getOwnPropertyDescriptor","key","prototype","hasOwnProperty","call","desc","set","memFilter","filter","cursor","c","skip","limit","tsplus_module_3","getOrElse","map","tsplus_module_2","findFirstMap","codeFilter","tsplus_module_1","make","empty","r","filterMap","drop","undefined","take","tsplus_module_4","ext_itToChunk","storeId","tsplus_module_5","unsafeMake","exports","restoreFromRequestContext","tsplus_module_6","flatMap","RequestContextContainer","ctx","namespace","makeMemoryStoreInt","name","seed","gen","$","updateETag","makeUpdateETag","items","sync","Map","makeStore","entries","id","e","makeETag","store","tsplus_module_7","sem","unsafeMakeSemaphore","withPermit","withPermits","values","s","all","fromIterable","batchSet","tap","tsplus_module_8","ext_forEach","i","find","current","m","mut","forEach","_","toReadonlyArray","fromNullable","filterJoinSelect","codeFilterJoinSelect","bulkSet","remove","makeMemoryStore","config","storesSem","primary","stores","getStore","allowNamespace","succeed","Error","suspendSucceed","args","MemoryStoreLive","tsplus_module_9","makeLayer","StoreMaker"],"sources":["../../../_src/services/Store/Memory.ts"],"sourcesContent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66,6 @@ export class RequestContext extends MNModel<
|
|
|
66
66
|
/** @ignore @internal @deprecated */
|
|
67
67
|
export type RequestContextConstructor = typeof RequestContext
|
|
68
68
|
|
|
69
|
-
/**
|
|
70
|
-
* @tsplus static RequestContext.Ops Tag
|
|
71
|
-
*/
|
|
72
|
-
export const tag = Tag<RequestContext>()
|
|
73
|
-
|
|
74
69
|
// codegen:start {preset: model}
|
|
75
70
|
//
|
|
76
71
|
/* eslint-disable */
|
package/_src/api/reportError.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { logError, reportError } from "../errorReporter.js"
|
|
2
2
|
import { CauseException } from "../errors.js"
|
|
3
|
-
import {
|
|
3
|
+
import { RequestContextContainer } from "../services/RequestContextContainer.js"
|
|
4
4
|
|
|
5
5
|
export class RequestException<E> extends CauseException<E> {
|
|
6
6
|
constructor(cause: Cause<E>) {
|
|
@@ -11,14 +11,14 @@ export const reportRequestError_ = reportError(cause => new RequestException(cau
|
|
|
11
11
|
|
|
12
12
|
export const reportRequestError = <E>(cause: Cause<E>, context?: Record<string, unknown> | undefined) =>
|
|
13
13
|
Debug.untraced(() =>
|
|
14
|
-
|
|
14
|
+
RequestContextContainer.get.flatMap(requestContext => reportRequestError_(cause, { requestContext, ...context }))
|
|
15
15
|
)
|
|
16
16
|
|
|
17
17
|
export const logRequestError_ = logError(cause => new RequestException(cause))
|
|
18
18
|
|
|
19
19
|
export const logRequestError = <E>(cause: Cause<E>, context?: Record<string, unknown> | undefined) =>
|
|
20
20
|
Debug.untraced(() =>
|
|
21
|
-
|
|
21
|
+
RequestContextContainer.get.flatMap(requestContext => logRequestError_(cause, { requestContext, ...context }))
|
|
22
22
|
)
|
|
23
23
|
|
|
24
24
|
/**
|
package/_src/api/routing.ts
CHANGED
|
@@ -8,6 +8,7 @@ import { pretty } from "@effect-app/prelude/utils"
|
|
|
8
8
|
import type express from "express"
|
|
9
9
|
import type { ValidationError } from "../errors.js"
|
|
10
10
|
import { RequestContext, RequestId } from "../RequestContext.js"
|
|
11
|
+
import { RequestContextContainer, RequestContextContainerImpl } from "../services/RequestContextContainer.js"
|
|
11
12
|
import { restoreFromRequestContext } from "../services/Store/Memory.js"
|
|
12
13
|
import type { SupportedErrors } from "./defaultErrorHandler.js"
|
|
13
14
|
import { defaultBasicErrorHandler } from "./defaultErrorHandler.js"
|
|
@@ -413,7 +414,7 @@ export function makeRequestHandler<
|
|
|
413
414
|
})
|
|
414
415
|
)
|
|
415
416
|
.setupRequestFrom
|
|
416
|
-
.provideService(
|
|
417
|
+
.provideService(RequestContextContainer, new RequestContextContainerImpl(requestContext)) // otherwise external error reporter breaks.
|
|
417
418
|
)
|
|
418
419
|
)
|
|
419
420
|
}
|
package/_src/api/setupRequest.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { RequestContext } from "../RequestContext.js"
|
|
2
|
+
import { RequestContextContainer, RequestContextContainerImpl } from "../services/RequestContextContainer.js"
|
|
2
3
|
|
|
3
4
|
/**
|
|
4
5
|
* @tsplus fluent effect/io/Effect setupRequest
|
|
@@ -21,7 +22,7 @@ export function setupRequest<R, E, A>(self: Effect<R, E, A>, requestContext: Req
|
|
|
21
22
|
* @tsplus getter effect/io/Effect setupRequestFrom
|
|
22
23
|
*/
|
|
23
24
|
export function setupRequestFrom<R, E, A>(self: Effect<R, E, A>) {
|
|
24
|
-
return Debug.untraced(() =>
|
|
25
|
+
return Debug.untraced(() => RequestContextContainer.get.flatMap(requestContext => self.setupRequest(requestContext)))
|
|
25
26
|
}
|
|
26
27
|
|
|
27
28
|
/**
|
|
@@ -31,7 +32,7 @@ export function setupReq3<R, E, A>(self: Effect<R, E, A>, name: string) {
|
|
|
31
32
|
return Debug.untraced(() =>
|
|
32
33
|
self
|
|
33
34
|
.setupRequestFrom
|
|
34
|
-
.provideService(
|
|
35
|
+
.provideService(RequestContextContainer, new RequestContextContainerImpl(makeInternalRequestContext(name)))
|
|
35
36
|
)
|
|
36
37
|
}
|
|
37
38
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { reportError } from "@effect-app/infra/errorReporter"
|
|
2
2
|
import { CauseException } from "@effect-app/infra/errors"
|
|
3
|
-
import {
|
|
3
|
+
import { RequestContextContainer } from "../RequestContextContainer.js"
|
|
4
4
|
|
|
5
5
|
export class MessageException<E> extends CauseException<E> {
|
|
6
6
|
constructor(cause: Cause<E>) {
|
|
@@ -17,8 +17,9 @@ export class FatalQueueException<E> extends CauseException<E> {
|
|
|
17
17
|
const reportQueueError_ = reportError(cause => new MessageException(cause))
|
|
18
18
|
|
|
19
19
|
export const reportQueueError = <E>(cause: Cause<E>, context?: Record<string, unknown> | undefined) =>
|
|
20
|
-
|
|
21
|
-
|
|
20
|
+
RequestContextContainer.getOption.flatMap(requestContext =>
|
|
21
|
+
reportQueueError_(cause, { requestContext: requestContext.value, ...context })
|
|
22
|
+
)
|
|
22
23
|
|
|
23
24
|
/**
|
|
24
25
|
* Forks the effect into a new fiber attached to the global scope. Because the
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { MemQueue } from "@effect-app/infra-adapters/memQueue"
|
|
2
2
|
import { RequestContext } from "@effect-app/infra/RequestContext"
|
|
3
3
|
import type { CustomSchemaException } from "@effect-app/prelude/schema"
|
|
4
|
+
import { RequestContextContainer } from "../RequestContextContainer.js"
|
|
4
5
|
import { restoreFromRequestContext } from "../Store/Memory.js"
|
|
5
6
|
import { reportNonInterruptedFailure } from "./errors.js"
|
|
6
7
|
import type { QueueBase } from "./service.js"
|
|
@@ -22,7 +23,7 @@ export function makeMemQueue<
|
|
|
22
23
|
makeHandleEvent: Effect<DrainR, never, (ks: DrainEvt) => Effect<RContext, DrainE, void>>,
|
|
23
24
|
provideContext: (context: RequestContext) => <R, E, A>(
|
|
24
25
|
eff: Effect<RContext | R, E, A>
|
|
25
|
-
) => Effect<Exclude<R, RContext |
|
|
26
|
+
) => Effect<Exclude<R, RContext | RequestContextContainer>, E, A>,
|
|
26
27
|
parseDrain: (
|
|
27
28
|
a: unknown,
|
|
28
29
|
env?: Parser.ParserEnv | undefined
|
|
@@ -36,7 +37,7 @@ export function makeMemQueue<
|
|
|
36
37
|
return {
|
|
37
38
|
publish: (...messages) =>
|
|
38
39
|
Effect.gen(function*($) {
|
|
39
|
-
const requestContext = yield* $(
|
|
40
|
+
const requestContext = yield* $(RequestContextContainer.get)
|
|
40
41
|
return yield* $(
|
|
41
42
|
messages.forEachEffect(m =>
|
|
42
43
|
// we JSON encode, because that is what the wire also does, and it reveals holes in e.g unknown encoders (Date->String)
|
|
@@ -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 type { CustomSchemaException } from "@effect-app/prelude/schema"
|
|
13
|
+
import { RequestContextContainer } from "../RequestContextContainer.js"
|
|
13
14
|
import { restoreFromRequestContext } from "../Store/Memory.js"
|
|
14
15
|
import { reportNonInterruptedFailure, reportNonInterruptedFailureCause } from "./errors.js"
|
|
15
16
|
import type { QueueBase } from "./service.js"
|
|
@@ -31,7 +32,7 @@ export function makeServiceBusQueue<
|
|
|
31
32
|
makeHandleEvent: Effect<DrainR, never, (ks: DrainEvt) => Effect<RContext, DrainE, void>>,
|
|
32
33
|
provideContext: (context: RequestContext) => <R, E, A>(
|
|
33
34
|
eff: Effect<RContext | R, E, A>
|
|
34
|
-
) => Effect<Exclude<R, RContext |
|
|
35
|
+
) => Effect<Exclude<R, RContext | RequestContextContainer>, E, A>,
|
|
35
36
|
parseDrain: (
|
|
36
37
|
a: unknown,
|
|
37
38
|
env?: Parser.ParserEnv | undefined
|
|
@@ -86,7 +87,7 @@ export function makeServiceBusQueue<
|
|
|
86
87
|
|
|
87
88
|
publish: (...messages) =>
|
|
88
89
|
Effect.gen(function*($) {
|
|
89
|
-
const requestContext = yield* $(
|
|
90
|
+
const requestContext = yield* $(RequestContextContainer.get)
|
|
90
91
|
return yield* $(
|
|
91
92
|
Effect.promise(() =>
|
|
92
93
|
s.sendMessages(
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { RequestContextContainer } from "../RequestContextContainer.js"
|
|
2
2
|
|
|
3
3
|
export interface QueueBase<RContext, Evt> {
|
|
4
4
|
drain: Effect<Scope | RContext, never, void>
|
|
5
5
|
publish: (
|
|
6
6
|
...messages: NonEmptyReadonlyArray<Evt>
|
|
7
|
-
) => Effect<
|
|
7
|
+
) => Effect<RequestContextContainer, never, void>
|
|
8
8
|
}
|
|
9
9
|
|
|
10
10
|
/**
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { RequestContext } from "../RequestContext.js"
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @tsplus companion RequestContextContainer.Ops
|
|
5
|
+
*/
|
|
6
|
+
export abstract class RequestContextContainer extends TagClass<RequestContextContainer>() {
|
|
7
|
+
abstract readonly requestContext: Effect<never, never, RequestContext>
|
|
8
|
+
abstract readonly update: (f: (rc: RequestContext) => RequestContext) => Effect<never, never, void>
|
|
9
|
+
static get get(): Effect<RequestContextContainer, never, RequestContext> {
|
|
10
|
+
return RequestContextContainer.accessWithEffect(_ => _.requestContext)
|
|
11
|
+
}
|
|
12
|
+
static get getOption() {
|
|
13
|
+
return Effect.contextWith((_: Context<never>) => Context.getOption(_, RequestContextContainer))
|
|
14
|
+
.flatMap(requestContext =>
|
|
15
|
+
requestContext.isSome()
|
|
16
|
+
? requestContext.value.requestContext.map(Option.some)
|
|
17
|
+
: Effect(Option.none)
|
|
18
|
+
)
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export class RequestContextContainerImpl extends RequestContextContainer {
|
|
23
|
+
#ref: Ref<RequestContext>
|
|
24
|
+
constructor(inp: RequestContext.ConstructorInput) {
|
|
25
|
+
super()
|
|
26
|
+
this.#ref = Ref.unsafeMake<RequestContext>(new RequestContext(inp))
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
override get requestContext() {
|
|
30
|
+
return this.#ref.get
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
override update = (f: (a: RequestContext) => RequestContext) => this.#ref.getAndUpdate(f)
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* @tsplus static RequestContextContainer.Ops live
|
|
38
|
+
*/
|
|
39
|
+
export function live(inp: RequestContext.ConstructorInput) {
|
|
40
|
+
return new RequestContextContainerImpl(inp)
|
|
41
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
2
2
|
|
|
3
|
-
import {
|
|
3
|
+
import { RequestContextContainer } from "../RequestContextContainer.js"
|
|
4
4
|
import type { Filter, FilterJoinSelect, PersistenceModelType, Store, StoreConfig } from "./service.js"
|
|
5
5
|
import { StoreMaker } from "./service.js"
|
|
6
6
|
import { codeFilter, codeFilterJoinSelect, makeETag, makeUpdateETag } from "./utils.js"
|
|
@@ -24,7 +24,7 @@ export function memFilter<T extends { id: string }>(filter: Filter<T>, cursor?:
|
|
|
24
24
|
}
|
|
25
25
|
|
|
26
26
|
export const storeId = FiberRef.unsafeMake("primary")
|
|
27
|
-
export const restoreFromRequestContext =
|
|
27
|
+
export const restoreFromRequestContext = RequestContextContainer.get.flatMap(ctx =>
|
|
28
28
|
storeId.set(ctx.namespace ?? "primary")
|
|
29
29
|
)
|
|
30
30
|
|
package/dist/RequestContext.d.ts
CHANGED
|
@@ -46,11 +46,6 @@ export declare class RequestContext extends RequestContext_base {
|
|
|
46
46
|
}
|
|
47
47
|
/** @ignore @internal @deprecated */
|
|
48
48
|
export type RequestContextConstructor = typeof RequestContext;
|
|
49
|
-
/**
|
|
50
|
-
* @tsplus static RequestContext.Ops Tag
|
|
51
|
-
* @tsplus location "@effect-app/infra/RequestContext"
|
|
52
|
-
*/
|
|
53
|
-
export declare const tag: import("@effect/data/Context").Tag<RequestContext>;
|
|
54
49
|
export declare namespace RequestContextParent {
|
|
55
50
|
const Encoded_base: import("@effect-app/prelude/schema").EncodedClass<{
|
|
56
51
|
readonly _tag: "RequestContext";
|