@flowerforce/flowerbase 1.1.2-beta.1 → 1.1.2-beta.2
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/dist/features/functions/controller.d.ts.map +1 -1
- package/dist/features/functions/controller.js +1 -0
- package/dist/services/mongodb-atlas/index.d.ts.map +1 -1
- package/dist/services/mongodb-atlas/index.js +8 -7
- package/package.json +1 -1
- package/src/features/functions/controller.ts +8 -0
- package/src/services/mongodb-atlas/index.ts +10 -7
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"controller.d.ts","sourceRoot":"","sources":["../../../src/features/functions/controller.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAA;AAGhD;;;;;GAKG;AACH,eAAO,MAAM,mBAAmB,EAAE,
|
|
1
|
+
{"version":3,"file":"controller.d.ts","sourceRoot":"","sources":["../../../src/features/functions/controller.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAA;AAGhD;;;;;GAKG;AACH,eAAO,MAAM,mBAAmB,EAAE,kBAkGjC,CAAA"}
|
|
@@ -70,6 +70,7 @@ const functionsController = (app_1, _a) => __awaiter(void 0, [app_1, _a], void 0
|
|
|
70
70
|
const { query, user } = req;
|
|
71
71
|
const { baas_request, stitch_request } = query;
|
|
72
72
|
const config = JSON.parse(Buffer.from(baas_request || stitch_request || '', 'base64').toString('utf8'));
|
|
73
|
+
console.log("🚀 ~ functionsController ~ baas_request:", baas_request, query, Buffer.from(baas_request || stitch_request || '', 'base64'), Buffer.from(baas_request || stitch_request || '', 'base64').toString('utf8'), config);
|
|
73
74
|
const [{ database, collection }] = config.arguments;
|
|
74
75
|
const app = state_1.StateManager.select('app');
|
|
75
76
|
const services = state_1.StateManager.select('services');
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/services/mongodb-atlas/index.ts"],"names":[],"mappings":"AAKA,OAAO,EAAyC,oBAAoB,EAAE,MAAM,SAAS,CAAA;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/services/mongodb-atlas/index.ts"],"names":[],"mappings":"AAKA,OAAO,EAAyC,oBAAoB,EAAE,MAAM,SAAS,CAAA;AAspBrF,QAAA,MAAM,YAAY,EAAE,oBAmBlB,CAAA;AAEF,eAAe,YAAY,CAAA"}
|
|
@@ -292,14 +292,15 @@ const getOperators = (collection, { rules = {}, collName, user, run_as_system })
|
|
|
292
292
|
const { filters, roles } = rules[collName] || {};
|
|
293
293
|
// Apply access filters to initial change stream pipeline
|
|
294
294
|
const formattedQuery = (0, utils_2.getFormattedQuery)(filters, {}, user);
|
|
295
|
+
const firstStep = formattedQuery.length ? {
|
|
296
|
+
$match: {
|
|
297
|
+
$and: formattedQuery
|
|
298
|
+
}
|
|
299
|
+
} : undefined;
|
|
295
300
|
const formattedPipeline = [
|
|
296
|
-
|
|
297
|
-
$match: {
|
|
298
|
-
$and: formattedQuery
|
|
299
|
-
}
|
|
300
|
-
},
|
|
301
|
+
firstStep,
|
|
301
302
|
...pipeline
|
|
302
|
-
];
|
|
303
|
+
].filter(Boolean);
|
|
303
304
|
const result = collection.watch(formattedPipeline, options);
|
|
304
305
|
const originalOn = result.on.bind(result);
|
|
305
306
|
/**
|
|
@@ -348,7 +349,7 @@ const getOperators = (collection, { rules = {}, collName, user, run_as_system })
|
|
|
348
349
|
if (isClient) {
|
|
349
350
|
throw new Error("Aggregate operator from cliente is not implemented! Move it to a function");
|
|
350
351
|
}
|
|
351
|
-
if (run_as_system) {
|
|
352
|
+
if (run_as_system || !isClient) {
|
|
352
353
|
return collection.aggregate(pipeline, options);
|
|
353
354
|
}
|
|
354
355
|
(0, utils_2.checkDenyOperation)(rules, collection.collectionName, model_1.CRUD_OPERATIONS.READ);
|
package/package.json
CHANGED
|
@@ -78,6 +78,14 @@ export const functionsController: FunctionController = async (
|
|
|
78
78
|
const config: Base64Function = JSON.parse(
|
|
79
79
|
Buffer.from(baas_request || stitch_request || '', 'base64').toString('utf8')
|
|
80
80
|
)
|
|
81
|
+
|
|
82
|
+
console.log("🚀 ~ functionsController ~ baas_request:",
|
|
83
|
+
baas_request,
|
|
84
|
+
query,
|
|
85
|
+
Buffer.from(baas_request || stitch_request || '', 'base64'),
|
|
86
|
+
Buffer.from(baas_request || stitch_request || '', 'base64').toString('utf8'),
|
|
87
|
+
config
|
|
88
|
+
)
|
|
81
89
|
const [{ database, collection }] = config.arguments
|
|
82
90
|
const app = StateManager.select('app')
|
|
83
91
|
const services = StateManager.select('services')
|
|
@@ -342,14 +342,17 @@ const getOperators: GetOperatorsFunction = (
|
|
|
342
342
|
|
|
343
343
|
// Apply access filters to initial change stream pipeline
|
|
344
344
|
const formattedQuery = getFormattedQuery(filters, {}, user)
|
|
345
|
+
|
|
346
|
+
const firstStep = formattedQuery.length ? {
|
|
347
|
+
$match: {
|
|
348
|
+
$and: formattedQuery
|
|
349
|
+
}
|
|
350
|
+
} : undefined
|
|
351
|
+
|
|
345
352
|
const formattedPipeline = [
|
|
346
|
-
|
|
347
|
-
$match: {
|
|
348
|
-
$and: formattedQuery
|
|
349
|
-
}
|
|
350
|
-
},
|
|
353
|
+
firstStep,
|
|
351
354
|
...pipeline
|
|
352
|
-
]
|
|
355
|
+
].filter(Boolean) as Document[]
|
|
353
356
|
|
|
354
357
|
const result = collection.watch(formattedPipeline, options)
|
|
355
358
|
const originalOn = result.on.bind(result)
|
|
@@ -426,7 +429,7 @@ const getOperators: GetOperatorsFunction = (
|
|
|
426
429
|
if (isClient) {
|
|
427
430
|
throw new Error("Aggregate operator from cliente is not implemented! Move it to a function")
|
|
428
431
|
}
|
|
429
|
-
if (run_as_system) {
|
|
432
|
+
if (run_as_system || !isClient) {
|
|
430
433
|
return collection.aggregate(pipeline, options)
|
|
431
434
|
}
|
|
432
435
|
checkDenyOperation(rules, collection.collectionName, CRUD_OPERATIONS.READ)
|