@loomcore/api 0.0.41 → 0.0.42

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 !== '_orgId') {
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
  }
@@ -409,7 +411,8 @@ export class GenericApiService {
409
411
  const preparedEntity = _.clone(entity);
410
412
  console.log(`in prepareEntity, pluralResourceName is ${this.pluralResourceName}`);
411
413
  console.log(`before stripping system properties, preparedEntity is ${JSON.stringify(preparedEntity)}`);
412
- console.log(`modelSpec is ${JSON.stringify(this.modelSpec)}`);
414
+ console.log(`modelSpec is present = ${this.modelSpec !== undefined}`);
415
+ console.log(`allowId is ${allowId}`);
413
416
  this.stripSenderProvidedSystemProperties(userContext, preparedEntity, allowId);
414
417
  console.log(`after stripping system properties, preparedEntity is ${JSON.stringify(preparedEntity)}`);
415
418
  if (this.modelSpec?.isAuditable) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@loomcore/api",
3
- "version": "0.0.41",
3
+ "version": "0.0.42",
4
4
  "private": false,
5
5
  "description": "Loom Core Api - An opinionated Node.js api using Typescript, Express, and MongoDb",
6
6
  "scripts": {