@flowerforce/flowerbase 1.5.0 → 1.5.1-beta.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.
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/features/triggers/utils.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,aAAa,EAAW,QAAQ,EAAE,MAAM,aAAa,CAAA;AAqC9D;;;;;;;GAOG;AACH,eAAO,MAAM,YAAY,GAAU,gBAAuB,KAAG,OAAO,CAAC,QAAQ,CAkB5E,CAAA;
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/features/triggers/utils.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,aAAa,EAAW,QAAQ,EAAE,MAAM,aAAa,CAAA;AAqC9D;;;;;;;GAOG;AACH,eAAO,MAAM,YAAY,GAAU,gBAAuB,KAAG,OAAO,CAAC,QAAQ,CAkB5E,CAAA;AA6YD,eAAO,MAAM,gBAAgB;0EAzX1B,aAAa;yEA8Tb,aAAa;+EAnSb,aAAa;CAkWf,CAAA"}
|
|
@@ -377,10 +377,11 @@ const handleAuthenticationTrigger = (_a) => __awaiter(void 0, [_a], void 0, func
|
|
|
377
377
|
*/
|
|
378
378
|
const handleDataBaseTrigger = (_a) => __awaiter(void 0, [_a], void 0, function* ({ config, triggerHandler, functionsList, services, app }) {
|
|
379
379
|
const { database, collection: collectionName, operation_types = [], match = {}, project = {} } = config;
|
|
380
|
+
const operationsNormalized = operation_types.map((op) => op.toLowerCase());
|
|
380
381
|
const collection = app.mongo.client.db(database).collection(collectionName);
|
|
381
382
|
const pipeline = [
|
|
382
383
|
{
|
|
383
|
-
$match: Object.assign({ operationType: { $in:
|
|
384
|
+
$match: Object.assign({ operationType: { $in: operationsNormalized } }, match)
|
|
384
385
|
},
|
|
385
386
|
Object.keys(project).length
|
|
386
387
|
? {
|
|
@@ -389,7 +390,12 @@ const handleDataBaseTrigger = (_a) => __awaiter(void 0, [_a], void 0, function*
|
|
|
389
390
|
: undefined
|
|
390
391
|
].filter(Boolean);
|
|
391
392
|
const changeStream = collection.watch(pipeline, {
|
|
392
|
-
fullDocument:
|
|
393
|
+
fullDocument: (() => {
|
|
394
|
+
if (!config.full_document)
|
|
395
|
+
return undefined;
|
|
396
|
+
const requiresLookup = operationsNormalized.some((op) => op === 'update' || op === 'replace');
|
|
397
|
+
return requiresLookup ? 'updateLookup' : 'whenAvailable';
|
|
398
|
+
})(),
|
|
393
399
|
fullDocumentBeforeChange: config.full_document_before_change
|
|
394
400
|
? 'whenAvailable'
|
|
395
401
|
: undefined
|
package/package.json
CHANGED
|
@@ -415,11 +415,13 @@ const handleDataBaseTrigger = async ({
|
|
|
415
415
|
project = {}
|
|
416
416
|
} = config
|
|
417
417
|
|
|
418
|
+
const operationsNormalized = operation_types.map((op: string) => op.toLowerCase())
|
|
419
|
+
|
|
418
420
|
const collection = app.mongo.client.db(database).collection(collectionName)
|
|
419
421
|
const pipeline = [
|
|
420
422
|
{
|
|
421
423
|
$match: {
|
|
422
|
-
operationType: { $in:
|
|
424
|
+
operationType: { $in: operationsNormalized },
|
|
423
425
|
...match
|
|
424
426
|
}
|
|
425
427
|
},
|
|
@@ -430,7 +432,11 @@ const handleDataBaseTrigger = async ({
|
|
|
430
432
|
: undefined
|
|
431
433
|
].filter(Boolean) as Parameters<typeof collection.watch>[0]
|
|
432
434
|
const changeStream = collection.watch(pipeline, {
|
|
433
|
-
fullDocument:
|
|
435
|
+
fullDocument: (() => {
|
|
436
|
+
if (!config.full_document) return undefined
|
|
437
|
+
const requiresLookup = operationsNormalized.some((op) => op === 'update' || op === 'replace')
|
|
438
|
+
return requiresLookup ? 'updateLookup' : 'whenAvailable'
|
|
439
|
+
})(),
|
|
434
440
|
fullDocumentBeforeChange: config.full_document_before_change
|
|
435
441
|
? 'whenAvailable'
|
|
436
442
|
: undefined
|