@loomcore/api 0.0.41 → 0.0.43
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.
|
@@ -380,15 +380,17 @@ export class GenericApiService {
|
|
|
380
380
|
return transformedEntity;
|
|
381
381
|
}
|
|
382
382
|
stripSenderProvidedSystemProperties(userContext, doc, allowId = false) {
|
|
383
|
+
console.log(`in stripSenderProvidedSystemProperties, allowId is ${allowId}`);
|
|
383
384
|
const isSystemUser = userContext.user?._id === 'system';
|
|
384
385
|
if (isSystemUser) {
|
|
385
386
|
return;
|
|
386
387
|
}
|
|
388
|
+
const propertiesToIgnore = ['_orgId'];
|
|
389
|
+
if (allowId) {
|
|
390
|
+
propertiesToIgnore.push('_id');
|
|
391
|
+
}
|
|
387
392
|
for (const key in doc) {
|
|
388
|
-
if (Object.prototype.hasOwnProperty.call(doc, key) && key.startsWith('_') && key
|
|
389
|
-
if (allowId && key === '_id') {
|
|
390
|
-
continue;
|
|
391
|
-
}
|
|
393
|
+
if (Object.prototype.hasOwnProperty.call(doc, key) && key.startsWith('_') && !propertiesToIgnore.includes(key)) {
|
|
392
394
|
delete doc[key];
|
|
393
395
|
}
|
|
394
396
|
}
|
|
@@ -403,13 +405,18 @@ export class GenericApiService {
|
|
|
403
405
|
}
|
|
404
406
|
async prepareDataForBatchUpdate(userContext, entities) {
|
|
405
407
|
console.log('--- DIAGNOSTICS: Executing prepareDataForBatchUpdate ---');
|
|
406
|
-
return Promise.all(entities.map(item =>
|
|
408
|
+
return Promise.all(entities.map(item => {
|
|
409
|
+
const allowId = true;
|
|
410
|
+
console.log(`in prepareDataForBatchUpdate, item is ${JSON.stringify(item)}, and allowId is ${allowId}`);
|
|
411
|
+
return this.prepareEntity(userContext, item, false, allowId);
|
|
412
|
+
}));
|
|
407
413
|
}
|
|
408
414
|
async prepareEntity(userContext, entity, isCreate, allowId = false) {
|
|
409
415
|
const preparedEntity = _.clone(entity);
|
|
410
416
|
console.log(`in prepareEntity, pluralResourceName is ${this.pluralResourceName}`);
|
|
411
417
|
console.log(`before stripping system properties, preparedEntity is ${JSON.stringify(preparedEntity)}`);
|
|
412
|
-
console.log(`modelSpec is ${
|
|
418
|
+
console.log(`modelSpec is present = ${this.modelSpec !== undefined}`);
|
|
419
|
+
console.log(`allowId is ${allowId}`);
|
|
413
420
|
this.stripSenderProvidedSystemProperties(userContext, preparedEntity, allowId);
|
|
414
421
|
console.log(`after stripping system properties, preparedEntity is ${JSON.stringify(preparedEntity)}`);
|
|
415
422
|
if (this.modelSpec?.isAuditable) {
|