@loomcore/api 0.0.46 → 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.
|
@@ -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;
|