@loomcore/api 0.0.40 → 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
  }
@@ -407,7 +409,12 @@ export class GenericApiService {
407
409
  }
408
410
  async prepareEntity(userContext, entity, isCreate, allowId = false) {
409
411
  const preparedEntity = _.clone(entity);
412
+ console.log(`in prepareEntity, pluralResourceName is ${this.pluralResourceName}`);
413
+ console.log(`before stripping system properties, preparedEntity is ${JSON.stringify(preparedEntity)}`);
414
+ console.log(`modelSpec is present = ${this.modelSpec !== undefined}`);
415
+ console.log(`allowId is ${allowId}`);
410
416
  this.stripSenderProvidedSystemProperties(userContext, preparedEntity, allowId);
417
+ console.log(`after stripping system properties, preparedEntity is ${JSON.stringify(preparedEntity)}`);
411
418
  if (this.modelSpec?.isAuditable) {
412
419
  if (isCreate) {
413
420
  this.auditForCreate(userContext, preparedEntity);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@loomcore/api",
3
- "version": "0.0.40",
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": {