@effect-app/infra 0.24.3 → 0.25.1
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/_ext/Array.cjs +2 -3
- package/_cjs/_ext/Array.cjs.map +1 -1
- package/_cjs/api/codec.cjs +1 -1
- package/_cjs/api/codec.cjs.map +1 -1
- package/_cjs/api/defaultErrorHandler.cjs +17 -18
- package/_cjs/api/defaultErrorHandler.cjs.map +1 -1
- package/_cjs/api/express/makeJsonSchema.cjs +4 -4
- package/_cjs/api/express/makeJsonSchema.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/requestHandler.cjs +45 -45
- package/_cjs/api/express/schema/requestHandler.cjs.map +1 -1
- package/_cjs/api/express/schema/routing.cjs +19 -19
- package/_cjs/api/express/schema/routing.cjs.map +1 -1
- package/_cjs/api/reportError.cjs +2 -2
- package/_cjs/api/reportError.cjs.map +1 -1
- package/_cjs/api/routing.cjs +54 -54
- package/_cjs/api/routing.cjs.map +1 -1
- package/_cjs/api/setupRequest.cjs +2 -2
- package/_cjs/api/setupRequest.cjs.map +1 -1
- package/_cjs/api/writeDocs.cjs +6 -6
- package/_cjs/api/writeDocs.cjs.map +1 -1
- package/_cjs/errorReporter.cjs +4 -4
- package/_cjs/errorReporter.cjs.map +1 -1
- package/_cjs/instrument.cjs +1 -1
- package/_cjs/instrument.cjs.map +1 -1
- package/_cjs/rateLimit.cjs +8 -8
- package/_cjs/rateLimit.cjs.map +1 -1
- package/_cjs/services/Emailer/Sendgrid.cjs +7 -8
- package/_cjs/services/Emailer/Sendgrid.cjs.map +1 -1
- package/_cjs/services/Emailer/fake.cjs +4 -5
- package/_cjs/services/Emailer/fake.cjs.map +1 -1
- package/_cjs/services/Operations/live.cjs +10 -10
- package/_cjs/services/Operations/live.cjs.map +1 -1
- package/_cjs/services/Operations/service.cjs +3 -3
- package/_cjs/services/Operations/service.cjs.map +1 -1
- package/_cjs/services/QueueMaker/errors.cjs +3 -3
- package/_cjs/services/QueueMaker/errors.cjs.map +1 -1
- package/_cjs/services/QueueMaker/memQueue.cjs +10 -11
- package/_cjs/services/QueueMaker/memQueue.cjs.map +1 -1
- package/_cjs/services/QueueMaker/sbqueue.cjs +5 -5
- package/_cjs/services/QueueMaker/sbqueue.cjs.map +1 -1
- package/_cjs/services/Repository.cjs +21 -21
- package/_cjs/services/Repository.cjs.map +1 -1
- package/_cjs/services/Store/Cosmos.cjs +42 -42
- package/_cjs/services/Store/Cosmos.cjs.map +1 -1
- package/_cjs/services/Store/Disk.cjs +20 -21
- package/_cjs/services/Store/Disk.cjs.map +1 -1
- package/_cjs/services/Store/Memory.cjs +24 -24
- package/_cjs/services/Store/Memory.cjs.map +1 -1
- package/_cjs/services/Store/Redis.cjs +14 -15
- package/_cjs/services/Store/Redis.cjs.map +1 -1
- package/_cjs/services/Store/codeFilter.test.cjs +5 -5
- package/_cjs/services/Store/codeFilter.test.cjs.map +1 -1
- package/_cjs/services/Store/index.cjs +4 -4
- package/_cjs/services/Store/index.cjs.map +1 -1
- package/_cjs/services/Store/utils.cjs +4 -4
- package/_cjs/services/Store/utils.cjs.map +1 -1
- package/_cjs/services/simpledb/cosmosdb.cjs +19 -19
- package/_cjs/services/simpledb/cosmosdb.cjs.map +1 -1
- package/_cjs/services/simpledb/diskdb.cjs +18 -18
- package/_cjs/services/simpledb/diskdb.cjs.map +1 -1
- package/_cjs/services/simpledb/memdb.cjs +9 -9
- package/_cjs/services/simpledb/memdb.cjs.map +1 -1
- package/_cjs/services/simpledb/mongodb.cjs +16 -16
- package/_cjs/services/simpledb/mongodb.cjs.map +1 -1
- package/_cjs/services/simpledb/redisdb.cjs +20 -20
- package/_cjs/services/simpledb/redisdb.cjs.map +1 -1
- package/_cjs/services/simpledb/simpledb.cjs +9 -9
- package/_cjs/services/simpledb/simpledb.cjs.map +1 -1
- package/_src/RequestContext.ts +2 -2
- package/_src/api/reportError.ts +2 -2
- package/_src/rateLimit.ts +4 -4
- package/_src/services/QueueMaker/errors.ts +1 -1
- package/dist/RequestContext.d.ts +2 -2
- package/dist/_ext/Array.js +3 -4
- package/dist/api/codec.js +2 -2
- package/dist/api/defaultErrorHandler.js +18 -18
- package/dist/api/express/makeJsonSchema.js +5 -5
- package/dist/api/express/makeOpenApiSpecs.d.ts +1 -1
- package/dist/api/express/makeOpenApiSpecs.js +2 -2
- package/dist/api/express/schema/requestHandler.js +41 -41
- package/dist/api/express/schema/routing.js +20 -20
- package/dist/api/reportError.d.ts +2 -2
- package/dist/api/reportError.d.ts.map +1 -1
- package/dist/api/reportError.js +4 -4
- package/dist/api/routing.d.ts +1 -1
- package/dist/api/routing.d.ts.map +1 -1
- package/dist/api/routing.js +63 -63
- package/dist/api/setupRequest.js +3 -3
- package/dist/api/writeDocs.js +7 -7
- package/dist/errorReporter.js +3 -3
- package/dist/instrument.js +2 -2
- package/dist/rateLimit.d.ts +3 -3
- package/dist/rateLimit.js +9 -9
- package/dist/services/Emailer/Sendgrid.js +8 -9
- package/dist/services/Emailer/fake.js +5 -6
- package/dist/services/Operations/live.js +12 -12
- package/dist/services/Operations/service.js +4 -4
- package/dist/services/QueueMaker/errors.d.ts +1 -1
- package/dist/services/QueueMaker/errors.d.ts.map +1 -1
- package/dist/services/QueueMaker/errors.js +4 -4
- package/dist/services/QueueMaker/memQueue.js +10 -10
- package/dist/services/QueueMaker/sbqueue.js +5 -5
- package/dist/services/Repository.d.ts +14 -14
- package/dist/services/Repository.js +15 -15
- package/dist/services/Store/Cosmos.js +44 -44
- package/dist/services/Store/Disk.js +22 -23
- package/dist/services/Store/Memory.js +26 -26
- package/dist/services/Store/Redis.js +15 -16
- package/dist/services/Store/index.js +5 -5
- package/dist/services/Store/utils.js +5 -5
- package/dist/services/simpledb/cosmosdb.js +19 -19
- package/dist/services/simpledb/diskdb.js +15 -15
- package/dist/services/simpledb/memdb.js +10 -10
- package/dist/services/simpledb/mongodb.js +15 -15
- package/dist/services/simpledb/redisdb.js +17 -17
- package/dist/services/simpledb/simpledb.js +12 -12
- package/package.json +8 -8
|
@@ -24,7 +24,7 @@ const Operations = tsplus_module_1.Tag();
|
|
|
24
24
|
*/
|
|
25
25
|
exports.Operations = Operations;
|
|
26
26
|
function forkOperation_1(self) {
|
|
27
|
-
return tsplus_module_5.untraced(() => tsplus_module_4.serviceWithEffect(Operations, Operations => tsplus_module_4.flatMap(scope => tsplus_module_4.tap(() => tsplus_module_3.forkDaemonReportRequestUnexpected(tsplus_module_2.use(
|
|
27
|
+
return tsplus_module_5.untraced(() => tsplus_module_4.serviceWithEffect(Operations, Operations => tsplus_module_4.flatMap(tsplus_module_2.make(), scope => tsplus_module_4.tap(tsplus_module_2.extend(Operations.register, scope), () => tsplus_module_3.forkDaemonReportRequestUnexpected(tsplus_module_2.use(self, scope))))));
|
|
28
28
|
}
|
|
29
29
|
/**
|
|
30
30
|
* @tsplus getter function forkOperation
|
|
@@ -36,12 +36,12 @@ function forkOperationFunction(fnc) {
|
|
|
36
36
|
* @tsplus static effect/io/Effect.Ops forkOperation
|
|
37
37
|
*/
|
|
38
38
|
function forkOperation2(self) {
|
|
39
|
-
return tsplus_module_5.untraced(restore => tsplus_module_4.serviceWithEffect(Operations, Operations => tsplus_module_4.flatMap(scope => tsplus_module_4.tap(id => tsplus_module_3.forkDaemonReportRequestUnexpected(tsplus_module_2.use(
|
|
39
|
+
return tsplus_module_5.untraced(restore => tsplus_module_4.serviceWithEffect(Operations, Operations => tsplus_module_4.flatMap(tsplus_module_2.make(), scope => tsplus_module_4.tap(tsplus_module_2.extend(Operations.register, scope), id => tsplus_module_3.forkDaemonReportRequestUnexpected(tsplus_module_2.use(restore(self)(id), scope))))));
|
|
40
40
|
}
|
|
41
41
|
/**
|
|
42
42
|
* @tsplus static effect/io/Effect.Ops forkOperationWithEffect
|
|
43
43
|
*/
|
|
44
44
|
function forkOperationWithEffect(self, fnc) {
|
|
45
|
-
return tsplus_module_5.untraced(restore => tsplus_module_4.serviceWithEffect(Operations, Operations => tsplus_module_4.flatMap(scope => tsplus_module_4.tap(
|
|
45
|
+
return tsplus_module_5.untraced(restore => tsplus_module_4.serviceWithEffect(Operations, Operations => tsplus_module_4.flatMap(tsplus_module_2.make(), scope => tsplus_module_4.tap(tsplus_module_4.tap(tsplus_module_2.extend(Operations.register, scope), opId => tsplus_module_3.forkDaemonReportRequestUnexpected(tsplus_module_2.use(restore(self)(opId), scope))), opId => tsplus_module_2.extend(tsplus_module_4.forkScoped(tsplus_module_4.interruptible(restore(fnc)(opId))), scope)))));
|
|
46
46
|
}
|
|
47
47
|
//# sourceMappingURL=service.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"service.cjs","mappings":";;;;;;;;;;;;;;;;MAoBgBA,aAAa;AAAA;AAlBtB,MAAMC,YAAY,GAAGC,MAAM,CAAC,cAAc,CAAC;AAAA;AAa3C,MAAMC,UAAU,GAAkBC,mBAAG,EAAc;AAE1D;;;AAAA;AAGA,yBAAuCC,IAAqB;EAC1D,OAAOC,yBAAe,MACpBC,4CAAU,EACRJ,UAAU,IACRI,
|
|
1
|
+
{"version":3,"file":"service.cjs","mappings":";;;;;;;;;;;;;;;;MAoBgBA,aAAa;AAAA;AAlBtB,MAAMC,YAAY,GAAGC,MAAM,CAAC,cAAc,CAAC;AAAA;AAa3C,MAAMC,UAAU,GAAkBC,mBAAG,EAAc;AAE1D;;;AAAA;AAGA,yBAAuCC,IAAqB;EAC1D,OAAOC,yBAAe,MACpBC,4CAAU,EACRJ,UAAU,IACRI,8CAAY,EACDC,KAAK,IACZD,qDAAU,CAACE,QAAQ,EAAQD,KAAK,CAAC,EAC1B,MAAKE,kDAACC,wBAAI,EAAKH,KAAK,CAAC,CAAkC,CAAC,CAChE,CACN,CACF;AACH;AAEA;;;AAGM,SAAUI,qBAAqB,CAAeC,GAAkC;EACpF,OAAQC,GAAQ,IAAKR,yBAAe,MAAKS,gBAACF,GAAG,CAACC,GAAG,CAAC,CAAc,CAAC;AACnE;AAEA;;;AAGM,SAAUE,cAAc,CAAUX,IAA4C;EAClF,OAAOC,yBAAeW,OAAO,IAC3BV,4CAAU,EACRJ,UAAU,IACRI,8CAAY,EACDC,KAAK,IACZD,qDAAU,CAACE,QAAQ,EAAQD,KAAK,CAAC,EAC1BU,EAAE,IAAGR,kDAACC,2BAAO,CAACN,IAAI,CAAC,CAACa,EAAE,CAAC,EAAKV,KAAK,CAAC,CAAkC,CAAC,CAC7E,CACN,CACF;AACH;AAEA;;;AAGM,SAAUW,uBAAuB,CACrCd,IAA0C,EAC1CQ,GAA4C;EAE5C,OAAOP,yBAAeW,OAAO,IAC3BV,4CAAU,EACRJ,UAAU,IACRI,8CAAY,EACDC,KAAK,IACZD,yEAAU,CAACE,QAAQ,EAAQD,KAAK,CAAC,EAC1BY,IAAI,IAAGV,kDAACC,2BAAO,CAACN,IAAI,CAAC,CAACe,IAAI,CAAC,EAAKZ,KAAK,CAAC,CAAkC,CAAC,EACzEY,IAAI,IAAIT,uFAAO,CAACE,GAAG,CAAC,CAACO,IAAI,CAAC,IAAiCZ,KAAK,CAAC,CAAC,CAC1E,CACN,CACF;AACH","names":["forkOperation","OperationsId","Symbol","Operations","tsplus_module_1","self","tsplus_module_5","tsplus_module_4","scope","register","tsplus_module_3","tsplus_module_2","forkOperationFunction","fnc","inp","forkOperation_1","forkOperation2","restore","id","forkOperationWithEffect","opId"],"sourceRoot":"","sources":["../../../_src/services/Operations/service.ts"],"sourcesContent":[null]}
|
|
@@ -42,13 +42,13 @@ const reportQueueError = (cause, context) => tsplus_module_1.serviceWithEffect(t
|
|
|
42
42
|
*/
|
|
43
43
|
exports.reportQueueError = reportQueueError;
|
|
44
44
|
function forkDaemonReportQueue(self) {
|
|
45
|
-
return tsplus_module_1.daemonChildren(tsplus_module_1.fork(tsplus_module_1.tapErrorCause(reportQueueError)
|
|
45
|
+
return tsplus_module_1.daemonChildren(tsplus_module_1.fork(tsplus_module_1.tapErrorCause(self, reportQueueError)));
|
|
46
46
|
}
|
|
47
47
|
const reportFatalQueueError = (0, _errorReporter.reportError)(cause => new FatalQueueException(cause));
|
|
48
48
|
exports.reportFatalQueueError = reportFatalQueueError;
|
|
49
49
|
function reportFailure(name) {
|
|
50
|
-
return self => tsplus_module_1.tap(exit => exit._tag === "Failure" ? reportFatalQueueError(exit.cause, {
|
|
50
|
+
return self => tsplus_module_1.tap(tsplus_module_1.exit(self), exit => exit._tag === "Failure" ? reportFatalQueueError(exit.cause, {
|
|
51
51
|
name
|
|
52
|
-
}) : tsplus_module_3.unit)
|
|
52
|
+
}) : tsplus_module_3.unit);
|
|
53
53
|
}
|
|
54
54
|
//# sourceMappingURL=errors.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.cjs","mappings":";;;;;;;;;;;;AAAA;AACA;AAAyD;AAAA;AAGnD,MAAOA,gBAAoB,SAAQC,sBAAiB;EACxDC,YAAYC,KAAe;IACzB,KAAK,CAACA,KAAK,EAAE,SAAS,CAAC;EACzB;;AACD;AAEK,MAAOC,mBAAuB,SAAQH,sBAAiB;EAC3DC,YAAYC,KAAe;IACzB,KAAK,CAACA,KAAK,EAAE,SAAS,CAAC;EACzB;;AACD;AAED,MAAME,iBAAiB,GAAG,8BAAW,EAACF,KAAK,IAAI,IAAIH,gBAAgB,CAACG,KAAK,CAAC,CAAC;AAEpE,MAAMG,gBAAgB,GAAG,
|
|
1
|
+
{"version":3,"file":"errors.cjs","mappings":";;;;;;;;;;;;AAAA;AACA;AAAyD;AAAA;AAGnD,MAAOA,gBAAoB,SAAQC,sBAAiB;EACxDC,YAAYC,KAAe;IACzB,KAAK,CAACA,KAAK,EAAE,SAAS,CAAC;EACzB;;AACD;AAEK,MAAOC,mBAAuB,SAAQH,sBAAiB;EAC3DC,YAAYC,KAAe;IACzB,KAAK,CAACA,KAAK,EAAE,SAAS,CAAC;EACzB;;AACD;AAED,MAAME,iBAAiB,GAAG,8BAAW,EAACF,KAAK,IAAI,IAAIH,gBAAgB,CAACG,KAAK,CAAC,CAAC;AAEpE,MAAMG,gBAAgB,GAAG,CAAIH,KAAe,EAAEI,OAA6C,KAChGC,uDAAoCC,cAAc,IAChDD,2BAAOH,iBAAiB,CAACF,KAAK,EAAE;EAAEM,cAAc;EAAE,GAAGF;AAAO,CAAE,CAAC,CAAC,CACjE;AAEH;;;;;;;;;AAAA;AASM,SAAUG,qBAAqB,CAAUC,IAAqB;EAClE,2DAAOH,kCAAI,EAAeF,gBAAgB,CAAC;AAC7C;AAEO,MAAMM,qBAAqB,GAAG,8BAAW,EAC9CT,KAAK,IAAI,IAAIC,mBAAmB,CAACD,KAAK,CAAC,CACxC;AAAA;AAEK,SAAUU,aAAa,CAACC,IAAY;EACxC,OAAiBH,IAAqB,IACpCH,6CAAI,GAAUO,IAAI,IAChBA,IAAI,CAACC,IAAI,KAAK,SAAS,GACnBJ,qBAAqB,CAACG,IAAI,CAACZ,KAAK,EAAE;IAAEW;EAAI,CAAE,CAAC,GAC5CG,oBAAY,CAChB;AACL","names":["MessageException","CauseException","constructor","cause","FatalQueueException","reportQueueError_","reportQueueError","context","tsplus_module_1","requestContext","forkDaemonReportQueue","self","reportFatalQueueError","reportFailure","name","exit","_tag","tsplus_module_3"],"sourceRoot":"","sources":["../../../_src/services/QueueMaker/errors.ts"],"sourcesContent":[null]}
|
|
@@ -35,30 +35,29 @@ function makeMemQueue(queueName, queueDrainName, encoder, makeHandleEvent, provi
|
|
|
35
35
|
const requestContext = yield* $(tsplus_module_1.service(tsplus_module_2.tag));
|
|
36
36
|
return yield* $(tsplus_module_4.forkDaemonReportQueue(tsplus_module_3.ext_forEach(messages, m => tsplus_module_1.asUnit(
|
|
37
37
|
// we JSON encode, because that is what the wire also does, and it reveals holes in e.g unknown encoders (Date->String)
|
|
38
|
-
tsplus_module_1.flatMap(
|
|
38
|
+
tsplus_module_1.flatMap(tsplus_module_1.sync(() => JSON.stringify(encoder({
|
|
39
39
|
body: m,
|
|
40
40
|
meta: requestContext
|
|
41
41
|
})))
|
|
42
42
|
// .tap((msg) => info("Publishing Mem Message: " + utils.inspect(msg)))
|
|
43
|
-
)))));
|
|
43
|
+
, _ => q.offer(_))))));
|
|
44
44
|
}),
|
|
45
|
-
|
|
46
45
|
drain: tsplus_module_1.gen(function* ($) {
|
|
47
46
|
const handleEvent = yield* $(makeHandleEvent);
|
|
48
47
|
const processMessage = msg =>
|
|
49
48
|
// we JSON parse, because that is what the wire also does, and it reveals holes in e.g unknown encoders (Date->String)
|
|
50
|
-
tsplus_module_1.flatMap(({
|
|
49
|
+
tsplus_module_1.flatMap(tsplus_module_1.orDie(tsplus_module_1.flatMap(tsplus_module_1.sync(() => JSON.parse(msg)), parseDrain)), ({
|
|
51
50
|
body,
|
|
52
51
|
meta
|
|
53
52
|
}) => provideContext(tsplus_module_2.RequestContext.inherit(meta, {
|
|
54
53
|
id: body.id,
|
|
55
54
|
locale: "en",
|
|
56
55
|
name: tsplus_module_7.ReasonableString(body._tag)
|
|
57
|
-
}))(tsplus_module_1.zipRight(
|
|
56
|
+
}))(tsplus_module_1.zipRight(tsplus_module_1.tap(tsplus_module_6.logAnnotates({
|
|
58
57
|
body: tsplus_module_5.RecordPretty(tsplus_module_5.object$(body)),
|
|
59
58
|
meta: tsplus_module_5.RecordPretty(tsplus_module_5.object$(meta))
|
|
60
|
-
})(tsplus_module_1.logDebug(`$$ [${queueDrainName}] Processing incoming message`))
|
|
61
|
-
return yield* $(tsplus_module_1.forkScoped(tsplus_module_9.setupReq3((0, _errors2.reportFailure)("drain")(tsplus_module_1.forever(tsplus_module_1.flatMap(x => tsplus_module_1.flatMap(
|
|
59
|
+
})(tsplus_module_1.logDebug(`$$ [${queueDrainName}] Processing incoming message`)), () => _Memory.restoreFromRequestContext), silence(handleEvent(body)))));
|
|
60
|
+
return yield* $(tsplus_module_1.forkScoped(tsplus_module_9.setupReq3((0, _errors2.reportFailure)("drain")(tsplus_module_1.forever(tsplus_module_1.flatMap(qReply.take(), x => tsplus_module_1.flatMap(tsplus_module_1.fork(tsplus_module_1.uninterruptible(processMessage(x))), _ => tsplus_module_8.join(_))))), "Queue.ReceiveMessage")));
|
|
62
61
|
})
|
|
63
62
|
};
|
|
64
63
|
});
|
|
@@ -66,9 +65,9 @@ function makeMemQueue(queueName, queueDrainName, encoder, makeHandleEvent, provi
|
|
|
66
65
|
// We want the Queue to continue processing even on errors per messages
|
|
67
66
|
// must make sure that the errors are processed/handled beforehand.
|
|
68
67
|
function silence(inp) {
|
|
69
|
-
return tsplus_module_1.flatMap(result => tsplus_module_1.gen(function* ($) {
|
|
68
|
+
return tsplus_module_1.flatMap(tsplus_module_1.exit(inp), result => tsplus_module_1.gen(function* ($) {
|
|
70
69
|
const requestContext = yield* $(tsplus_module_1.service(tsplus_module_2.tag));
|
|
71
|
-
return yield* $(tsplus_module_12.match(cause => {
|
|
70
|
+
return yield* $(tsplus_module_12.match(result, cause => {
|
|
72
71
|
if (tsplus_module_10.isInterrupted(cause)) {
|
|
73
72
|
return tsplus_module_1.failCause(cause);
|
|
74
73
|
}
|
|
@@ -76,7 +75,7 @@ function silence(inp) {
|
|
|
76
75
|
requestContext
|
|
77
76
|
});
|
|
78
77
|
return tsplus_module_11.unit;
|
|
79
|
-
}, () => tsplus_module_11.unit)
|
|
80
|
-
}))
|
|
78
|
+
}, () => tsplus_module_11.unit));
|
|
79
|
+
}));
|
|
81
80
|
}
|
|
82
81
|
//# sourceMappingURL=memQueue.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"memQueue.cjs","mappings":";;;;;;;;;;;;;;;;;;;AAAA;AAGA;AACA;AAA6D;AAAA;AAG7D;;;AAGM,SAAUA,YAAY,CAC1BC,SAAiB,EACjBC,cAAsB,EACtBC,OAAyD,EACzDC,eAAwF,EACxFC,cAEuC,EACvCC,UAGmF;EAEnF,OAAOC,oBAAW,WAAUC,CAAC;I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,GAAG,OAAOR,CAAC,8CAA2B;IAC1D,OAAO,OAAOA,CAAC,CACbsC,6BAAM,EACJC,KAAK,IAAG;MACN,IAAIC,oCAAK,CAAgB,EAAE;QACzB,iCAAQD,KAAsB;;MAEhC,6BAAgB,EAACA,KAAK,EAAE;QAAE/B;MAAc,CAAE,CAAC;MAC3C;IACF,CAAC,EACD,MAAKiC,qBAAY,CAClB,CACF;EACH,CAAC,CAAC,CACH;AACH","names":["makeMemQueue","queueName","queueDrainName","encoder","makeHandleEvent","provideContext","parseDrain","tsplus_module_1","$","mem","MemQueue","q","getOrCreateQueue","qReply","publish","messages","requestContext","tsplus_module_3","m","JSON","stringify","body","meta","_","offer","drain","handleEvent","processMessage","msg","parse","RequestContext","inherit","id","locale","name","tsplus_module_7","_tag","tsplus_module_6","restoreFromRequestContext","silence","tsplus_module_9","take","x","tsplus_module_8","inp","result","tsplus_module_12","cause","tsplus_module_10","tsplus_module_11"],"sourceRoot":"","sources":["../../../_src/services/QueueMaker/memQueue.ts"],"sourcesContent":[null]}
|
|
@@ -33,22 +33,22 @@ function makeServiceBusQueue(_queueName, queueDrainName, encoder, makeHandleEven
|
|
|
33
33
|
const handleEvent = yield* $(makeHandleEvent);
|
|
34
34
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
35
35
|
function processMessage(messageBody) {
|
|
36
|
-
return tsplus_module_1.asUnit(tsplus_module_1.orDie(tsplus_module_6.setupReq3(tsplus_module_1.flatMap(({
|
|
36
|
+
return tsplus_module_1.asUnit(tsplus_module_1.orDie(tsplus_module_6.setupReq3(tsplus_module_1.flatMap(tsplus_module_1.tapErrorCause(tsplus_module_1.orDie(tsplus_module_1.flatMap(tsplus_module_1.sync(() => JSON.parse(messageBody)), x => parseDrain(x))), report), ({
|
|
37
37
|
body,
|
|
38
38
|
meta
|
|
39
39
|
}) => provideContext(tsplus_module_7.RequestContext.inherit(meta, {
|
|
40
40
|
id: body.id,
|
|
41
41
|
locale: "en",
|
|
42
42
|
name: tsplus_module_5.ReasonableString(body._tag)
|
|
43
|
-
}))(tsplus_module_1.tapErrorCause(
|
|
43
|
+
}))(tsplus_module_1.tapErrorCause(tsplus_module_1.zipRight(tsplus_module_1.tap(tsplus_module_4.logAnnotates({
|
|
44
44
|
body: tsplus_module_3.RecordPretty(tsplus_module_3.object$(body)),
|
|
45
45
|
meta: tsplus_module_3.RecordPretty(tsplus_module_3.object$(meta))
|
|
46
|
-
})(tsplus_module_1.logDebug(`$$ [${queueDrainName}] Processing incoming message`))
|
|
46
|
+
})(tsplus_module_1.logDebug(`$$ [${queueDrainName}] Processing incoming message`)), () => _Memory.restoreFromRequestContext), handleEvent(body)), report))), "Queue.ReceiveMessage")));
|
|
47
47
|
}
|
|
48
|
-
return yield* $(tsplus_module_1.provideSomeLayer(
|
|
48
|
+
return yield* $(tsplus_module_1.provideSomeLayer((0, _ServiceBus.subscribe)({
|
|
49
49
|
processMessage: x => tsplus_module_1.uninterruptible(processMessage(x.body)),
|
|
50
50
|
processError: err => tsplus_module_1.sync(() => (0, _errorReporter.captureException)(err.error))
|
|
51
|
-
})));
|
|
51
|
+
}), receiverLayer));
|
|
52
52
|
}),
|
|
53
53
|
publish: (...messages) => tsplus_module_1.gen(function* ($) {
|
|
54
54
|
const requestContext = yield* $(tsplus_module_1.service(tsplus_module_7.tag));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sbqueue.cjs","mappings":";;;;;;;;;;;;;;;;AAAA;AASA;AAGA;AACA;AAA8C;AAAA;AAG9C;;;AAGM,SAAUA,mBAAmB,CAQjCC,UAAkB,EAClBC,cAAsB,EACtBC,OAAyD,EACzDC,eAAwF,EACxFC,cAEuC,EACvCC,UAGmF;EAEnF,OAAOC,oBAAW,WAAUC,CAAC;IAC3B,MAAMC,CAAC,GAAG,OAAOD,CAAC,yBAACE,kBAAM,EAAQ;IACjC,MAAMC,QAAQ,GAAG,OAAOH,CAAC,yBAACI,oBAAQ,EAAQ;IAC1C,MAAMC,aAA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UC,CAAC;IAC3B,MAAMgC,cAAc,GAAG,OAAOhC,CAAC,8CAA2B;IAC1D,OAAO,6BAAgB,EAAC0C,KAAK,EAAE;MAAEV;IAAc,CAAE,CAAC;EACpD,CAAC,CAAC;AACJ","names":["makeServiceBusQueue","_queueName","queueDrainName","encoder","makeHandleEvent","provideContext","parseDrain","tsplus_module_1","$","s","Sender","receiver","Receiver","receiverLayer","tsplus_module_2","drain","handleEvent","processMessage","messageBody","tsplus_module_6","JSON","parse","x","report","body","meta","RequestContext","inherit","id","locale","name","tsplus_module_5","_tag","tsplus_module_4","restoreFromRequestContext","processError","err","error","publish","messages","requestContext","sendMessages","map","stringify","messageId","contentType","makeServiceBusLayers","url","queueName","tsplus_module_9","cause"],"sourceRoot":"","sources":["../../../_src/services/QueueMaker/sbqueue.ts"],"sourcesContent":[null]}
|
|
@@ -74,25 +74,25 @@ const AnyPureDSL = {
|
|
|
74
74
|
*/
|
|
75
75
|
exports.AnyPureDSL = AnyPureDSL;
|
|
76
76
|
function get_1(self, id) {
|
|
77
|
-
return tsplus_module_3.flatMap(_ => tsplus_module_2.encaseMaybeInEffect_(_, () => new _errors.NotFoundError(self.itemType, id)))
|
|
77
|
+
return tsplus_module_3.flatMap(self.find(id), _ => tsplus_module_2.encaseMaybeInEffect_(_, () => new _errors.NotFoundError(self.itemType, id)));
|
|
78
78
|
}
|
|
79
79
|
/**
|
|
80
80
|
* @tsplus fluent Repository filter
|
|
81
81
|
*/
|
|
82
82
|
function filter(self, filter) {
|
|
83
|
-
return tsplus_module_3.map(_ => tsplus_module_4.filter(filter)
|
|
83
|
+
return tsplus_module_3.map(self.all, _ => tsplus_module_4.filter(_, filter));
|
|
84
84
|
}
|
|
85
85
|
/**
|
|
86
86
|
* @tsplus fluent Repository filterAll
|
|
87
87
|
*/
|
|
88
88
|
function filterAll(self, map) {
|
|
89
|
-
return tsplus_module_3.map(
|
|
89
|
+
return tsplus_module_3.map(self.all, map);
|
|
90
90
|
}
|
|
91
91
|
/**
|
|
92
92
|
* @tsplus fluent Repository collect
|
|
93
93
|
*/
|
|
94
94
|
function collect(self, collect) {
|
|
95
|
-
return tsplus_module_3.map(_ => tsplus_module_4.filterMap(collect)(_))
|
|
95
|
+
return tsplus_module_3.map(self.all, _ => tsplus_module_4.filterMap(collect)(_));
|
|
96
96
|
}
|
|
97
97
|
/**
|
|
98
98
|
* @tsplus getter Repository log
|
|
@@ -106,10 +106,10 @@ function log(_) {
|
|
|
106
106
|
*/
|
|
107
107
|
function projectEffect_1(self, map) {
|
|
108
108
|
// TODO: a projection that gets sent to the db instead.
|
|
109
|
-
return tsplus_module_3.flatMap(f => tsplus_module_3.map(
|
|
109
|
+
return tsplus_module_3.flatMap(map, f => tsplus_module_3.map(f.filter ? self.utils.filter(f.filter, {
|
|
110
110
|
limit: f.limit,
|
|
111
111
|
skip: f.skip
|
|
112
|
-
}) : self.utils.all)
|
|
112
|
+
}) : self.utils.all, _ => f.collect ? tsplus_module_4.filterMap(f.collect)(_) : _));
|
|
113
113
|
}
|
|
114
114
|
/**
|
|
115
115
|
* TODO: project inside the db.
|
|
@@ -124,12 +124,12 @@ function project(self, map) {
|
|
|
124
124
|
function queryEffect_1(self,
|
|
125
125
|
// TODO: think about collectPM, collectE, and collect(Parsed)
|
|
126
126
|
map) {
|
|
127
|
-
return tsplus_module_3.flatMap(f => tsplus_module_3.map(
|
|
128
|
-
set
|
|
129
|
-
}) => items.map(_ => self.utils.mapReverse(_, set)))(tsplus_module_3.service(_Store.ContextMap)))(f.filter ? self.utils.filter(f.filter, {
|
|
127
|
+
return tsplus_module_3.flatMap(map, f => tsplus_module_3.map(tsplus_module_3.map(tsplus_module_3.flatMap(f.filter ? self.utils.filter(f.filter, {
|
|
130
128
|
limit: f.limit,
|
|
131
129
|
skip: f.skip
|
|
132
|
-
}) : self.utils.all)
|
|
130
|
+
}) : self.utils.all, items => tsplus_module_3.map(tsplus_module_3.service(_Store.ContextMap), ({
|
|
131
|
+
set
|
|
132
|
+
}) => items.map(_ => self.utils.mapReverse(_, set)))), _ => _.map(_ => self.utils.parse(_))), _ => f.collect ? tsplus_module_4.filterMap(f.collect)(_) : _));
|
|
133
133
|
}
|
|
134
134
|
/**
|
|
135
135
|
* @tsplus fluent Repository queryOneEffect
|
|
@@ -137,11 +137,11 @@ map) {
|
|
|
137
137
|
function queryOneEffect_1(self,
|
|
138
138
|
// TODO: think about collectPM, collectE, and collect(Parsed)
|
|
139
139
|
map) {
|
|
140
|
-
return tsplus_module_3.flatMap(f => tsplus_module_3.flatMap(
|
|
141
|
-
set
|
|
142
|
-
}) => items.map(_ => self.utils.mapReverse(_, set)))(tsplus_module_3.service(_Store.ContextMap)))(f.filter ? self.utils.filter(f.filter, {
|
|
140
|
+
return tsplus_module_3.flatMap(map, f => tsplus_module_3.flatMap(tsplus_module_3.map(tsplus_module_3.flatMap(f.filter ? self.utils.filter(f.filter, {
|
|
143
141
|
limit: 1
|
|
144
|
-
}) : self.utils.all)
|
|
142
|
+
}) : self.utils.all, items => tsplus_module_3.map(tsplus_module_3.service(_Store.ContextMap), ({
|
|
143
|
+
set
|
|
144
|
+
}) => items.map(_ => self.utils.mapReverse(_, set)))), _ => _.map(_ => self.utils.parse(_))), _ => tsplus_module_3.map(tsplus_module_2.encaseMaybeInEffect_(tsplus_module_5.ChunkToNonEmptyReadonlyArray(f.collect ? tsplus_module_4.filterMap(f.collect)(_) : _), () => new _errors.NotFoundError(self.itemType, JSON.stringify(f.filter))), _ => _[0])));
|
|
145
145
|
}
|
|
146
146
|
/**
|
|
147
147
|
* @tsplus fluent Repository query
|
|
@@ -165,7 +165,7 @@ map) {
|
|
|
165
165
|
function queryAndSavePureEffect_1(self,
|
|
166
166
|
// TODO: think about collectPM, collectE, and collect(Parsed)
|
|
167
167
|
map) {
|
|
168
|
-
return pure => tsplus_module_6.untraced(restore => tsplus_module_3.flatMap(restore(_ => saveManyWithPure_1(self, _, pure)))
|
|
168
|
+
return pure => tsplus_module_6.untraced(restore => tsplus_module_3.flatMap(queryEffect_1(self, map), restore(_ => saveManyWithPure_1(self, _, pure))));
|
|
169
169
|
}
|
|
170
170
|
/**
|
|
171
171
|
* @tsplus fluent Repository queryAndSavePure
|
|
@@ -185,7 +185,7 @@ function saveManyWithPure(self) {
|
|
|
185
185
|
* @tsplus fluent Repository byIdAndSaveWithPure
|
|
186
186
|
*/
|
|
187
187
|
function byIdAndSaveWithPure_1(self, id) {
|
|
188
|
-
return pure => tsplus_module_3.flatMap(item => saveWithPure_1(self, item, pure))
|
|
188
|
+
return pure => tsplus_module_3.flatMap(get_1(self, id), item => saveWithPure_1(self, item, pure));
|
|
189
189
|
}
|
|
190
190
|
/**
|
|
191
191
|
* NOTE: it's not as composable, only useful when the request is simple, and only this part needs request args.
|
|
@@ -204,10 +204,10 @@ function saveManyWithPure_1(self, items, pure) {
|
|
|
204
204
|
* @tsplus fluent Repository saveWithPure_
|
|
205
205
|
*/
|
|
206
206
|
function saveWithPure_1(self, item, pure) {
|
|
207
|
-
return saveAllWithEffectInt(self, tsplus_module_3.map(([item, events, a]) => [[item], events, a])
|
|
207
|
+
return saveAllWithEffectInt(self, tsplus_module_3.map(tsplus_module_1.runTerm(pure, item), ([item, events, a]) => [[item], events, a]));
|
|
208
208
|
}
|
|
209
209
|
function saveAllWithEffectInt(self, gen) {
|
|
210
|
-
return tsplus_module_6.untraced(restore => tsplus_module_3.flatMap(([items, events, a]) => tsplus_module_3.map(
|
|
210
|
+
return tsplus_module_6.untraced(restore => tsplus_module_3.flatMap(gen, ([items, events, a]) => tsplus_module_3.map(restore(() => self.saveAndPublish(items, events))(), () => a)));
|
|
211
211
|
}
|
|
212
212
|
/**
|
|
213
213
|
* @tsplus fluent Repository queryAndSavePureEffectBatched
|
|
@@ -215,7 +215,7 @@ function saveAllWithEffectInt(self, gen) {
|
|
|
215
215
|
function queryAndSavePureEffectBatched_1(self,
|
|
216
216
|
// TODO: think about collectPM, collectE, and collect(Parsed)
|
|
217
217
|
map, batchSize = 100) {
|
|
218
|
-
return pure => tsplus_module_3.flatMap(_ => saveManyWithPureBatched_1(self, _, pure, batchSize))
|
|
218
|
+
return pure => tsplus_module_3.flatMap(queryEffect_1(self, map), _ => saveManyWithPureBatched_1(self, _, pure, batchSize));
|
|
219
219
|
}
|
|
220
220
|
/**
|
|
221
221
|
* @tsplus fluent Repository queryAndSavePureBatched
|
|
@@ -260,10 +260,10 @@ function makeOneDSL() {
|
|
|
260
260
|
function makeDSL() {
|
|
261
261
|
const dsl = AnyPureDSL;
|
|
262
262
|
function modify(pure) {
|
|
263
|
-
return tsplus_module_3.flatMap(items => pure(items, dsl))
|
|
263
|
+
return tsplus_module_3.flatMap(dsl.get, items => pure(items, dsl));
|
|
264
264
|
}
|
|
265
265
|
function update(pure) {
|
|
266
|
-
return tsplus_module_3.flatMap(items => tsplus_module_3.tap(
|
|
266
|
+
return tsplus_module_3.flatMap(dsl.get, items => tsplus_module_3.tap(pure(items, dsl.log), dsl.set));
|
|
267
267
|
}
|
|
268
268
|
function withDSL(pure) {
|
|
269
269
|
return pure(AnyPureDSL);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Repository.cjs","mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAMA;AAEA;AAAiD;AAAA;MA8CjCA,GAAG;AAAA;MAuEHC,aAAa;AAAA;MAyCbC,WAAW;AAAA;MA8BXC,cAAc;AAAA;MAuEdC,sBAAsB;AAAA;MAwDtBC,mBAAmB;AAAA;MA+BnBC,iBAAiB;AAAA;MAyBjBC,aAAa;AAAA;MAgDbC,6BAA6B;AAAA;MAwD7BC,wBAAwB;AAAA;AAtbjC,MAAMC,UAAU,GAA2B;EAChDV,GAAG,EAAEW,qBAAU;EACfC,GAAG,qBAAU;EACbC,GAAG,EAAE,CAAC,GAAGC,GAAU,KAAKH,wBAAaG,GAAG;CACzC;AAED;;;AAAA;AAGA,eAOEC,IAA0C,EAC1CC,EAAM;EAEN,OAAOC,
|
|
1
|
+
{"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AAEiD,EAAwD;EAC7G,OAAOC,2GAAOlD,KAAK,EAAiB,EAAYiD,EAAE,CAAC;AACrD;AAEA;;;AAGM,SAAUG,IAAI,CAOlBxE,IAA0C;EAE1C,OAAO,CAAC,GAAGoB,KAAuB,KAAKpB,IAAI,CAAC+C,cAAc,CAAC3B,KAAK,CAAC;AACnE;AAEA;;;AAGM,SAAUqD,cAAc,CAO5BzE,IAA0C;EAE1C,OAAQ4C,MAAqB,IAAK,CAAC,GAAGxB,KAAuB,KAAKpB,IAAI,CAAC+C,cAAc,CAAC3B,KAAK,EAAEwB,MAAM,CAAC;AACtG","names":["get","projectEffect","queryEffect","queryOneEffect","queryAndSavePureEffect","byIdAndSaveWithPure","saveManyWithPure_","saveWithPure_","queryAndSavePureEffectBatched","saveManyWithPureBatched_","AnyPureDSL","tsplus_module_1","set","log","evt","self","id","tsplus_module_3","find","_","tsplus_module_2","NotFoundError","itemType","filter","all","tsplus_module_4","filterAll","map","collect","f","utils","limit","skip","project","projectEffect_1","items","ContextMap","mapReverse","parse","JSON","stringify","query","queryEffect_1","queryOne","queryOneEffect_1","pure","tsplus_module_6","restore","saveManyWithPure_1","queryAndSavePure","queryAndSavePureEffect_1","saveManyWithPure","item","saveWithPure_1","handleByIdAndSaveWithPure","req","ctx","byIdAndSaveWithPure_1","saveAllWithEffectInt","events","a","gen","saveAndPublish","batchSize","saveManyWithPureBatched_1","queryAndSavePureBatched","queryAndSavePureEffectBatched_1","saveManyWithPureBatched","tsplus_module_7","batch","anyDSL","makeDSL","makeAllDSL","dsl","updateWithOne","upd","update","updateWith","makeOneDSL","modify","withDSL","Object","assign","ifAny","fn","tsplus_module_8","ifAny_","save","saveWithEvents"],"sourceRoot":"","sources":["../../_src/services/Repository.ts"],"sourcesContent":[null]}
|
|
@@ -49,10 +49,10 @@ function makeCosmosStore({
|
|
|
49
49
|
const bulk = container.items.bulk.bind(container.items);
|
|
50
50
|
const execBatch = container.items.batch.bind(container.items);
|
|
51
51
|
const importedMarkerId = containerId;
|
|
52
|
-
const bulkSet = items => tsplus_module_1.logAnnotate(
|
|
52
|
+
const bulkSet = items => tsplus_module_1.logAnnotate(tsplus_module_5.instr(tsplus_module_1.gen(function* ($) {
|
|
53
53
|
// TODO: disable batching if need atomicity
|
|
54
54
|
// we delay and batch to keep low amount of RUs
|
|
55
|
-
const b = [...items].map(x => [x, tsplus_module_2.match(() => ({
|
|
55
|
+
const b = [...items].map(x => [x, tsplus_module_2.match(tsplus_module_2.fromNullable(x._etag), () => ({
|
|
56
56
|
operationType: "Create",
|
|
57
57
|
resourceBody: {
|
|
58
58
|
...(0, tsplus_module_6.omit)(x, "_etag"),
|
|
@@ -68,9 +68,9 @@ function makeCosmosStore({
|
|
|
68
68
|
},
|
|
69
69
|
ifMatch: eTag,
|
|
70
70
|
partitionKey: config?.partitionValue(x)
|
|
71
|
-
}))
|
|
71
|
+
}))]);
|
|
72
72
|
const batches = tsplus_module_3.chunk_(b, config?.maxBulkSize ?? 10).toReadonlyArray();
|
|
73
|
-
const batchResult = yield* $(tsplus_module_4.ext_forEach(batches.map((x, i) => [i, x]), ([i, batch]) => tsplus_module_1.flatMap(responses => tsplus_module_1.gen(function* ($) {
|
|
73
|
+
const batchResult = yield* $(tsplus_module_4.ext_forEach(batches.map((x, i) => [i, x]), ([i, batch]) => tsplus_module_1.flatMap(tsplus_module_1.delay(tsplus_module_1.promise(() => bulk(batch.map(([, op]) => op))), tsplus_module_3.millis_(i === 0 ? 0 : 1100)), responses => tsplus_module_1.gen(function* ($) {
|
|
74
74
|
const r = responses.find(x => x.statusCode === 412);
|
|
75
75
|
if (r) {
|
|
76
76
|
return yield* $(tsplus_module_1.fail(new _errors.OptimisticConcurrencyException(name, JSON.stringify(r.resourceBody?.["id"]))));
|
|
@@ -84,12 +84,12 @@ function makeCosmosStore({
|
|
|
84
84
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
85
85
|
_etag: responses[i].eTag
|
|
86
86
|
}));
|
|
87
|
-
}))
|
|
87
|
+
}))));
|
|
88
88
|
return batchResult.toReadonlyArray().flat();
|
|
89
|
-
}), "cosmos.bulkSet"));
|
|
89
|
+
}), "cosmos.bulkSet"), "cosmos.db", containerId);
|
|
90
90
|
const batchSet = items => {
|
|
91
|
-
return tsplus_module_1.logAnnotate(
|
|
92
|
-
const batch = [...items].map(x => [x, tsplus_module_2.match(() => ({
|
|
91
|
+
return tsplus_module_1.logAnnotate(tsplus_module_5.instr(tsplus_module_1.suspendSucceed(() => {
|
|
92
|
+
const batch = [...items].map(x => [x, tsplus_module_2.match(tsplus_module_2.fromNullable(x._etag), () => ({
|
|
93
93
|
operationType: "Create",
|
|
94
94
|
resourceBody: {
|
|
95
95
|
...(0, tsplus_module_6.omit)(x, "_etag"),
|
|
@@ -103,9 +103,9 @@ function makeCosmosStore({
|
|
|
103
103
|
_partitionKey: config?.partitionValue(x)
|
|
104
104
|
},
|
|
105
105
|
ifMatch: eTag
|
|
106
|
-
}))
|
|
106
|
+
}))]);
|
|
107
107
|
const ex = batch.map(([, c]) => c);
|
|
108
|
-
return tsplus_module_1.flatMap(x => tsplus_module_1.gen(function* ($) {
|
|
108
|
+
return tsplus_module_1.flatMap(tsplus_module_1.promise(() => execBatch(ex, ex[0]?.resourceBody._partitionKey)), x => tsplus_module_1.gen(function* ($) {
|
|
109
109
|
const result = x.result ?? [];
|
|
110
110
|
const firstFailed = result.find(x => x.statusCode > 299 || x.statusCode < 200);
|
|
111
111
|
if (firstFailed) {
|
|
@@ -119,20 +119,22 @@ function makeCosmosStore({
|
|
|
119
119
|
...e,
|
|
120
120
|
_etag: result[i]?.eTag
|
|
121
121
|
}));
|
|
122
|
-
}))
|
|
123
|
-
}), "cosmos.batchSet"));
|
|
122
|
+
}));
|
|
123
|
+
}), "cosmos.batchSet"), "cosmos.db", containerId);
|
|
124
124
|
};
|
|
125
125
|
const s = {
|
|
126
|
-
all: tsplus_module_1.logAnnotate(
|
|
127
|
-
resources
|
|
128
|
-
}) => tsplus_module_3.ext_itToChunk(resources))))(tsplus_module_1.tap(q => logQuery(q))(tsplus_module_1.sync(() => ({
|
|
126
|
+
all: tsplus_module_1.logAnnotate(tsplus_module_5.instr(tsplus_module_1.flatMap(tsplus_module_1.tap(tsplus_module_1.sync(() => ({
|
|
129
127
|
query: `SELECT * FROM ${name} f WHERE f.id != @id`,
|
|
130
128
|
parameters: [{
|
|
131
129
|
name: "@id",
|
|
132
130
|
value: importedMarkerId
|
|
133
131
|
}]
|
|
134
|
-
})))),
|
|
135
|
-
|
|
132
|
+
})), q => logQuery(q)), q => tsplus_module_1.promise(() => container.items.query(q).fetchAll().then(({
|
|
133
|
+
resources
|
|
134
|
+
}) => tsplus_module_3.ext_itToChunk(resources)))), "cosmos.all"), "cosmos.db", containerId),
|
|
135
|
+
filterJoinSelect: (filter, cursor) => tsplus_module_1.logAnnotate(tsplus_module_5.instr(tsplus_module_1.map(tsplus_module_4.ext_forEach(filter.keys, k => tsplus_module_1.flatMap(tsplus_module_1.tap(tsplus_module_1.sync(() => buildFilterJoinSelectCosmosQuery(filter, k, name, cursor?.skip, cursor?.limit)), q => logQuery(q)), q => tsplus_module_1.promise(() => container.items.query(q).fetchAll().then(({
|
|
136
|
+
resources
|
|
137
|
+
}) => tsplus_module_3.ext_itToChunk(resources))))), a => {
|
|
136
138
|
const v = a.flatMap(_ => _).map(x => tsplus_module_6.spread(x, ({
|
|
137
139
|
r,
|
|
138
140
|
...rest
|
|
@@ -141,42 +143,29 @@ function makeCosmosStore({
|
|
|
141
143
|
...r
|
|
142
144
|
})));
|
|
143
145
|
return tsplus_module_7.fromIterable(v);
|
|
144
|
-
})
|
|
145
|
-
resources
|
|
146
|
-
}) => tsplus_module_3.ext_itToChunk(resources))))(tsplus_module_1.tap(q => logQuery(q))(tsplus_module_1.sync(() => buildFilterJoinSelectCosmosQuery(filter, k, name, cursor?.skip, cursor?.limit)))))), "cosmos.filterJoinSelect")),
|
|
146
|
+
}), "cosmos.filterJoinSelect"), "cosmos.db", containerId),
|
|
147
147
|
/**
|
|
148
148
|
* May return duplicate results for "join_find", when matching more than once.
|
|
149
149
|
*/
|
|
150
150
|
filter: (filter, cursor) => {
|
|
151
151
|
const skip = cursor?.skip;
|
|
152
152
|
const limit = cursor?.limit;
|
|
153
|
-
return tsplus_module_1.logAnnotate(
|
|
153
|
+
return tsplus_module_1.logAnnotate(tsplus_module_5.instr(filter.type === "join_find"
|
|
154
154
|
// This is a problem if one of the multiple joined arrays can be empty!
|
|
155
155
|
// https://stackoverflow.com/questions/60320780/azure-cosmosdb-sql-join-not-returning-results-when-the-child-contains-empty-arra
|
|
156
156
|
// so we use multiple queries instead.
|
|
157
|
-
? tsplus_module_1.map(
|
|
157
|
+
? tsplus_module_1.map(tsplus_module_4.ext_forEach(filter.keys, k => tsplus_module_1.flatMap(tsplus_module_1.tap(tsplus_module_1.sync(() => buildFindJoinCosmosQuery(filter, k, name, skip, limit)), q => logQuery(q)), q => tsplus_module_1.promise(() => container.items.query(q).fetchAll().then(({
|
|
158
158
|
resources
|
|
159
|
-
}) => tsplus_module_3.ext_itToChunk(resources))))
|
|
159
|
+
}) => tsplus_module_3.ext_itToChunk(resources))))), _ => _.flatMap(_ => _)) : tsplus_module_1.flatMap(tsplus_module_1.tap(tsplus_module_1.sync(() => buildCosmosQuery(filter, name, importedMarkerId, skip, limit)), q => logQuery(q)), q => tsplus_module_1.promise(() => container.items.query(q).fetchAll().then(({
|
|
160
160
|
resources
|
|
161
|
-
}) => tsplus_module_3.ext_itToChunk(resources.map(_ => _.f)))))
|
|
161
|
+
}) => tsplus_module_3.ext_itToChunk(resources.map(_ => _.f))))), "cosmos.filter"), "cosmos.db", containerId);
|
|
162
162
|
},
|
|
163
|
-
find: id => tsplus_module_1.logAnnotate(
|
|
163
|
+
find: id => tsplus_module_1.logAnnotate(tsplus_module_5.instr(tsplus_module_1.promise(() => container.item(id, config?.partitionValue({
|
|
164
164
|
id
|
|
165
165
|
})).read().then(({
|
|
166
166
|
resource
|
|
167
|
-
}) => tsplus_module_2.fromNullable(resource))), "cosmos.find")),
|
|
168
|
-
set: e => tsplus_module_1.logAnnotate(
|
|
169
|
-
if (x.statusCode === 412) {
|
|
170
|
-
return tsplus_module_1.fail(new _errors.OptimisticConcurrencyException(name, e.id));
|
|
171
|
-
}
|
|
172
|
-
if (x.statusCode > 299 || x.statusCode < 200) {
|
|
173
|
-
return tsplus_module_1.die(new CosmosDbOperationError("not able to update record: " + x.statusCode));
|
|
174
|
-
}
|
|
175
|
-
return tsplus_module_1.sync(() => ({
|
|
176
|
-
...e,
|
|
177
|
-
_etag: x.etag
|
|
178
|
-
}));
|
|
179
|
-
})(tsplus_module_2.match(() => tsplus_module_1.promise(() => container.items.create({
|
|
167
|
+
}) => tsplus_module_2.fromNullable(resource))), "cosmos.find"), "cosmos.db", containerId),
|
|
168
|
+
set: e => tsplus_module_1.logAnnotate(tsplus_module_5.instr(tsplus_module_1.flatMap(tsplus_module_2.match(tsplus_module_2.fromNullable(e._etag), () => tsplus_module_1.promise(() => container.items.create({
|
|
180
169
|
...e,
|
|
181
170
|
_partitionKey: config?.partitionValue(e)
|
|
182
171
|
})), eTag => tsplus_module_1.promise(() => container.item(e.id, config?.partitionValue(e)).replace({
|
|
@@ -187,10 +176,21 @@ function makeCosmosStore({
|
|
|
187
176
|
type: "IfMatch",
|
|
188
177
|
condition: eTag
|
|
189
178
|
}
|
|
190
|
-
})))
|
|
179
|
+
}))), x => {
|
|
180
|
+
if (x.statusCode === 412) {
|
|
181
|
+
return tsplus_module_1.fail(new _errors.OptimisticConcurrencyException(name, e.id));
|
|
182
|
+
}
|
|
183
|
+
if (x.statusCode > 299 || x.statusCode < 200) {
|
|
184
|
+
return tsplus_module_1.die(new CosmosDbOperationError("not able to update record: " + x.statusCode));
|
|
185
|
+
}
|
|
186
|
+
return tsplus_module_1.sync(() => ({
|
|
187
|
+
...e,
|
|
188
|
+
_etag: x.etag
|
|
189
|
+
}));
|
|
190
|
+
}), "cosmos.set"), "cosmos.db", containerId),
|
|
191
191
|
batchSet,
|
|
192
192
|
bulkSet,
|
|
193
|
-
remove: e => tsplus_module_1.logAnnotate(
|
|
193
|
+
remove: e => tsplus_module_1.logAnnotate(tsplus_module_5.instr(tsplus_module_1.promise(() => container.item(e.id, config?.partitionValue(e)).delete()), "cosmos.remove"), "cosmos.db", containerId)
|
|
194
194
|
};
|
|
195
195
|
// handle mock data
|
|
196
196
|
const marker = yield* $(tsplus_module_1.promise(() => container.item(importedMarkerId, importedMarkerId).read().then(({
|
|
@@ -200,7 +200,7 @@ function makeCosmosStore({
|
|
|
200
200
|
console.log("Creating mock data for " + name);
|
|
201
201
|
if (seed) {
|
|
202
202
|
const m = yield* $(seed);
|
|
203
|
-
yield* $(tsplus_module_8.flatMapOption(tsplus_module_1.sync(() => tsplus_module_3.toNonEmptyArray([...m.values()])), a => tsplus_module_1.delay(
|
|
203
|
+
yield* $(tsplus_module_8.flatMapOption(tsplus_module_1.sync(() => tsplus_module_3.toNonEmptyArray([...m.values()])), a => tsplus_module_1.delay(tsplus_module_1.orDie(s.bulkSet(a)), tsplus_module_3.millis_(1100))));
|
|
204
204
|
}
|
|
205
205
|
// Mark as imported
|
|
206
206
|
yield* $(tsplus_module_1.promise(() => container.items.create({
|
|
@@ -314,6 +314,6 @@ class CosmosDbOperationError {
|
|
|
314
314
|
}
|
|
315
315
|
}
|
|
316
316
|
function CosmosStoreLive(config) {
|
|
317
|
-
return
|
|
317
|
+
return tsplus_module_1.toLayer(tsplus_module_1.flatMap(tsplus_module_1.config(config), makeCosmosStore), _service.StoreMaker);
|
|
318
318
|
}
|
|
319
319
|
//# sourceMappingURL=Cosmos.cjs.map
|