@loomcore/api 0.0.45 → 0.0.47
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.
|
@@ -416,7 +416,6 @@ export class GenericApiService {
|
|
|
416
416
|
const preparedEntity = _.clone(entity);
|
|
417
417
|
console.log(`in prepareEntity, pluralResourceName is ${this.pluralResourceName}`);
|
|
418
418
|
console.log(`before stripping system properties, preparedEntity is ${JSON.stringify(preparedEntity)}`);
|
|
419
|
-
console.log(`modelSpec is present = ${this.modelSpec !== undefined}`);
|
|
420
419
|
console.log(`allowId is ${allowId}`);
|
|
421
420
|
this.stripSenderProvidedSystemProperties(userContext, preparedEntity, allowId);
|
|
422
421
|
console.log(`after stripping system properties, preparedEntity is ${JSON.stringify(preparedEntity)}`);
|
|
@@ -6,5 +6,5 @@ export declare class MultiTenantApiService<T extends IEntity> extends GenericApi
|
|
|
6
6
|
constructor(db: Db, pluralResourceName: string, singularResourceName: string, modelSpec?: IModelSpec);
|
|
7
7
|
protected prepareQuery(userContext: IUserContext, query: any): any;
|
|
8
8
|
protected prepareQueryOptions(userContext: IUserContext, queryOptions: IQueryOptions): IQueryOptions;
|
|
9
|
-
protected prepareEntity(userContext: IUserContext, entity: T, isCreate: boolean): Promise<T | Partial<T>>;
|
|
9
|
+
protected prepareEntity(userContext: IUserContext, entity: T, isCreate: boolean, allowId?: boolean): Promise<T | Partial<T>>;
|
|
10
10
|
}
|
|
@@ -28,14 +28,14 @@ export class MultiTenantApiService extends GenericApiService {
|
|
|
28
28
|
}
|
|
29
29
|
return this.tenantDecorator.applyTenantToQueryOptions(userContext, queryOptions, this.pluralResourceName);
|
|
30
30
|
}
|
|
31
|
-
async prepareEntity(userContext, entity, isCreate) {
|
|
31
|
+
async prepareEntity(userContext, entity, isCreate, allowId = false) {
|
|
32
32
|
if (!config?.app?.isMultiTenant) {
|
|
33
|
-
return super.prepareEntity(userContext, entity, isCreate);
|
|
33
|
+
return super.prepareEntity(userContext, entity, isCreate, allowId);
|
|
34
34
|
}
|
|
35
35
|
if (!userContext || !userContext._orgId) {
|
|
36
36
|
throw new BadRequestError('A valid userContext was not provided to MultiTenantApiService.prepareEntity');
|
|
37
37
|
}
|
|
38
|
-
const preparedEntity = await super.prepareEntity(userContext, entity, isCreate);
|
|
38
|
+
const preparedEntity = await super.prepareEntity(userContext, entity, isCreate, allowId);
|
|
39
39
|
const orgIdField = this.tenantDecorator.getOrgIdField();
|
|
40
40
|
preparedEntity[orgIdField] = userContext._orgId;
|
|
41
41
|
return preparedEntity;
|