@solidxai/core 0.1.9-beta.6 → 0.1.9-beta.7
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.
- package/dist/helpers/field-crud-managers/ManyToManyRelationFieldCrudManager.js +5 -5
- package/dist/helpers/field-crud-managers/ManyToManyRelationFieldCrudManager.js.map +1 -1
- package/dist/helpers/field-crud-managers/ManyToOneRelationFieldCrudManager.d.ts.map +1 -1
- package/dist/helpers/field-crud-managers/ManyToOneRelationFieldCrudManager.js +2 -2
- package/dist/helpers/field-crud-managers/ManyToOneRelationFieldCrudManager.js.map +1 -1
- package/dist/helpers/field-crud-managers/OneToManyRelationFieldCrudManager.js +5 -5
- package/dist/helpers/field-crud-managers/OneToManyRelationFieldCrudManager.js.map +1 -1
- package/dist/helpers/module-metadata-helper.service.js +3 -3
- package/dist/helpers/module-metadata-helper.service.js.map +1 -1
- package/dist/helpers/string.helper.d.ts +1 -0
- package/dist/helpers/string.helper.d.ts.map +1 -1
- package/dist/helpers/string.helper.js +4 -1
- package/dist/helpers/string.helper.js.map +1 -1
- package/dist/repository/chatter-message-details.repository.d.ts.map +1 -1
- package/dist/repository/chatter-message-details.repository.js +7 -6
- package/dist/repository/chatter-message-details.repository.js.map +1 -1
- package/dist/repository/chatter-message.repository.d.ts.map +1 -1
- package/dist/repository/chatter-message.repository.js +4 -4
- package/dist/repository/chatter-message.repository.js.map +1 -1
- package/dist/repository/solid-base.repository.js +2 -2
- package/dist/repository/solid-base.repository.js.map +1 -1
- package/dist/seeders/module-test-data.service.js +4 -4
- package/dist/seeders/module-test-data.service.js.map +1 -1
- package/dist/services/chatter-message.service.d.ts.map +1 -1
- package/dist/services/chatter-message.service.js +7 -7
- package/dist/services/chatter-message.service.js.map +1 -1
- package/dist/services/computed-fields/entity/sequence-num-computed-field-provider.d.ts.map +1 -1
- package/dist/services/computed-fields/entity/sequence-num-computed-field-provider.js +2 -2
- package/dist/services/computed-fields/entity/sequence-num-computed-field-provider.js.map +1 -1
- package/dist/services/crud-helper.service.d.ts.map +1 -1
- package/dist/services/crud-helper.service.js +9 -9
- package/dist/services/crud-helper.service.js.map +1 -1
- package/dist/services/export-transaction.service.d.ts.map +1 -1
- package/dist/services/export-transaction.service.js +4 -3
- package/dist/services/export-transaction.service.js.map +1 -1
- package/dist/services/field-metadata.service.d.ts.map +1 -1
- package/dist/services/field-metadata.service.js +7 -7
- package/dist/services/field-metadata.service.js.map +1 -1
- package/dist/services/fixtures.service.js +2 -2
- package/dist/services/fixtures.service.js.map +1 -1
- package/dist/services/genai/mcp-handlers/mcp-handler-factory.service.d.ts.map +1 -1
- package/dist/services/genai/mcp-handlers/mcp-handler-factory.service.js +2 -2
- package/dist/services/genai/mcp-handlers/mcp-handler-factory.service.js.map +1 -1
- package/dist/services/import-transaction.service.d.ts.map +1 -1
- package/dist/services/import-transaction.service.js +2 -2
- package/dist/services/import-transaction.service.js.map +1 -1
- package/dist/services/menu-item-metadata.service.js +2 -2
- package/dist/services/menu-item-metadata.service.js.map +1 -1
- package/dist/services/model-metadata.service.d.ts.map +1 -1
- package/dist/services/model-metadata.service.js +11 -10
- package/dist/services/model-metadata.service.js.map +1 -1
- package/dist/services/module-metadata.service.d.ts.map +1 -1
- package/dist/services/module-metadata.service.js +2 -2
- package/dist/services/module-metadata.service.js.map +1 -1
- package/dist/services/queues/publisher-factory.service.d.ts.map +1 -1
- package/dist/services/queues/publisher-factory.service.js +2 -2
- package/dist/services/queues/publisher-factory.service.js.map +1 -1
- package/dist/services/selection-providers/pseudo-foreign-key-selection-provider.service.js +3 -3
- package/dist/services/selection-providers/pseudo-foreign-key-selection-provider.service.js.map +1 -1
- package/dist/services/solid-introspect.service.js +2 -2
- package/dist/services/solid-introspect.service.js.map +1 -1
- package/dist/services/view-metadata.service.d.ts.map +1 -1
- package/dist/services/view-metadata.service.js +2 -2
- package/dist/services/view-metadata.service.js.map +1 -1
- package/dist/subscribers/computed-entity-field.subscriber.js +6 -6
- package/dist/subscribers/computed-entity-field.subscriber.js.map +1 -1
- package/package.json +1 -2
- package/src/helpers/field-crud-managers/ManyToManyRelationFieldCrudManager.ts +1 -1
- package/src/helpers/field-crud-managers/ManyToOneRelationFieldCrudManager.ts +1 -2
- package/src/helpers/field-crud-managers/OneToManyRelationFieldCrudManager.ts +1 -1
- package/src/helpers/module-metadata-helper.service.ts +3 -3
- package/src/helpers/string.helper.ts +3 -0
- package/src/repository/chatter-message-details.repository.ts +4 -3
- package/src/repository/chatter-message.repository.ts +4 -4
- package/src/repository/solid-base.repository.ts +2 -2
- package/src/seeders/module-test-data.service.ts +1 -1
- package/src/services/chatter-message.service.ts +1 -3
- package/src/services/computed-fields/entity/sequence-num-computed-field-provider.ts +1 -2
- package/src/services/crud-helper.service.ts +1 -4
- package/src/services/export-transaction.service.ts +3 -4
- package/src/services/field-metadata.service.ts +1 -4
- package/src/services/fixtures.service.ts +1 -1
- package/src/services/genai/mcp-handlers/mcp-handler-factory.service.ts +1 -2
- package/src/services/import-transaction.service.ts +1 -1
- package/src/services/menu-item-metadata.service.ts +2 -2
- package/src/services/model-metadata.service.ts +10 -12
- package/src/services/module-metadata.service.ts +1 -2
- package/src/services/queues/publisher-factory.service.ts +1 -2
- package/src/services/selection-providers/pseudo-foreign-key-selection-provider.service.ts +1 -1
- package/src/services/solid-introspect.service.ts +1 -1
- package/src/services/view-metadata.service.ts +1 -5
- package/src/subscribers/computed-entity-field.subscriber.ts +6 -6
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"view-metadata.service.js","sourceRoot":"","sources":["../../src/services/view-metadata.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,2CAA6F;AAC7F,uCAAyC;AACzC,6CAAsD;AACtD,iDAAwD;AACxD,qCAAwC;AAGxC,oEAAkE;AAClE,6DAAoD;AACpD,4FAAuF;AACvF,8DAA2D;AAC3D,uFAAmF;AACnF,qFAAiF;AAIjF,uEAAkE;AAClE,6EAAuE;AACvE,yEAAoE;AACp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AC7B,iDAAsB;QAChB,oDAAuB;QAEjC,uBAAa;QAEtB,iDAAsB;QAMD,mDAAuB;QACd,0DAA0B;QACnD,gBAAS;GAjBpB,mBAAmB,CAkb/B","sourcesContent":["import { BadRequestException, forwardRef, Inject, Injectable, Logger } from '@nestjs/common';\nimport { ModuleRef } from \"@nestjs/core\";\nimport { InjectEntityManager } from '@nestjs/typeorm';\nimport { CRUDService } from 'src/services/crud.service';\nimport { EntityManager } from 'typeorm';\n\n\nimport { classify } from '@angular-devkit/core/src/utils/strings';\nimport { Locale } from 'src/entities/locale.entity';\nimport { ModelMetadataHelperService } from 'src/helpers/model-metadata-helper.service';\nimport { SolidRegistry } from 'src/helpers/solid-registry';\nimport { ModelMetadataRepository } from 'src/repository/model-metadata.repository';\nimport { ViewMetadataRepository } from 'src/repository/view-metadata.repository';\nimport { UpdateViewMetadataDto } from '../dtos/update-view-metadata.dto';\nimport { FieldMetadata } from '../entities/field-metadata.entity';\nimport { ViewMetadata } from '../entities/view-metadata.entity';\nimport { ActionMetadataService } from './action-metadata.service';\nimport { MenuItemMetadataService } from './menu-item-metadata.service';\nimport { SolidIntrospectService } from './solid-introspect.service';\nimport { UserViewMetadataService } from './user-view-metadata.service';\nimport { MenuItemMetadata } from 'src/entities/menu-item-metadata.entity';\n\n@Injectable()\nexport class ViewMetadataService extends CRUDService<ViewMetadata> {\n constructor(\n readonly actionMetadataService: ActionMetadataService,\n readonly menuItemMetadataService: MenuItemMetadataService,\n readonly introspectService: SolidIntrospectService,\n readonly userViewMetadataService: UserViewMetadataService,\n @InjectEntityManager()\n readonly entityManager: EntityManager,\n // @InjectRepository(ViewMetadata, 'default')\n readonly repo: ViewMetadataRepository,\n // @InjectRepository(FieldMetadata)\n // private readonly fieldMetadataRepo: Repository<FieldMetadata>,\n // @InjectRepository(ModelMetadata)\n // private readonly modelMetadataRepo: Repository<ModelMetadata>,\n @Inject(forwardRef(() => ModelMetadataRepository))\n private readonly modelMetadataRepo: ModelMetadataRepository,\n private readonly modelMetadataHelperService: ModelMetadataHelperService,\n readonly moduleRef: ModuleRef\n ) {\n super(entityManager, repo, 'viewMetadata', 'solid-core', moduleRef);\n }\n\n private readonly logger = new Logger(ViewMetadataService.name);\n\n //for locales \n private async getEntityRecordsInAllLocales(\n modelName: string,\n id: string,\n defaultEntityLocaleIdFromQuery?: string\n ): Promise<{ records: any[], defaultEntityLocaleId: string | null }> {\n const solidRegistry = await this.moduleRef.get(SolidRegistry, { strict: false });\n // const currentEntityTarget = solidRegistry.getEntityTarget(this.entityManager, classify(modelName));\n const currentEntityRepository = this.entityManager.getRepository(classify(modelName));\n\n // Case 1: Creating a new record with no defaultEntityLocaleId to clone\n if (id === 'new' && !defaultEntityLocaleIdFromQuery) {\n this.logger.debug(`Creating new record without cloning from any defaultEntityLocaleId.`);\n return { records: [], defaultEntityLocaleId: null };\n }\n\n // Case 2: Creating a new record and cloning from an existing defaultEntityLocaleId\n if (id === 'new' && defaultEntityLocaleIdFromQuery) {\n this.logger.debug(`Creating new record by cloning translations from defaultEntityLocaleId: ${defaultEntityLocaleIdFromQuery}`);\n\n const records = await currentEntityRepository.find({\n where: [\n { defaultEntityLocaleId: defaultEntityLocaleIdFromQuery },\n { id: defaultEntityLocaleIdFromQuery }\n ]\n });\n\n this.logger.debug(`Found ${records.length} cloned records for new entity.`);\n return { records, defaultEntityLocaleId: defaultEntityLocaleIdFromQuery };\n }\n\n // Case 3: Editing an existing entity\n const entityRecord = await currentEntityRepository.findOne({ where: { id } });\n\n if (!entityRecord) {\n this.logger.warn(`No entity found for id ${id}`);\n return { records: [], defaultEntityLocaleId: null };\n }\n\n const defaultLocale = await this.entityManager.getRepository(Locale).findOne({ where: { isDefault: true } });\n\n let defaultEntityLocaleId: string;\n if (entityRecord.localeName === defaultLocale?.locale) {\n defaultEntityLocaleId = entityRecord.id;\n this.logger.debug(`Editing default locale record with id ${defaultEntityLocaleId}`);\n } else {\n defaultEntityLocaleId = entityRecord.defaultEntityLocaleId;\n this.logger.debug(`Editing non-default locale record. DefaultEntityLocaleId: ${defaultEntityLocaleId}`);\n }\n\n const records = await currentEntityRepository.find({\n where: [\n { defaultEntityLocaleId: defaultEntityLocaleId },\n { id: defaultEntityLocaleId }\n ]\n });\n\n this.logger.debug(`Found ${records.length} records in all locales for existing entity.`);\n\n return { records, defaultEntityLocaleId };\n }\n\n // START: Custom Service Methods\n async getLayout(query, activeUser) {\n let { modelName, moduleName, viewType, id, populate, menuItemId, menuItemName, actionId, actionName } = query;\n\n\n // 1. Fetch the action based on actionId.\n const solidRequestContext = {\n activeUser: activeUser\n }\n const actionQuery = {\n populate: [\"view\"]\n }\n let action = null;\n if (actionId) {\n action = await this.actionMetadataService.findOne(actionId, actionQuery, solidRequestContext);\n }\n\n // 2. Fetch the menu based on menuItemId.\n const menuItemQuery = {\n populate: ['action', 'action.model', 'module']\n }\n let menuItem: MenuItemMetadata = null;\n if (menuItemId) {\n menuItem = await this.menuItemMetadataService.findOne(menuItemId, menuItemQuery, solidRequestContext);\n }\n\n let viewModes = [];\n const menuItemModelId = menuItem?.action?.model?.id;\n const menuItemModuleId = menuItem?.module?.id;\n if (menuItemModelId && menuItemModuleId) {\n const actionQb = await this.actionMetadataService.repo.createSecurityRuleAwareQueryBuilder('action');\n const actionsForViewModes = await actionQb\n .leftJoinAndSelect('action.model', 'model')\n .leftJoinAndSelect('action.module', 'module')\n .leftJoinAndSelect('action.view', 'view')\n .where('model.id = :modelId', { modelId: menuItemModelId })\n .andWhere('module.id = :moduleId', { moduleId: menuItemModuleId })\n .andWhere('view.type IN (:...viewTypes)', { viewTypes: ['card', 'list', 'kanban', 'tree'] })\n .getMany();\n\n viewModes = actionsForViewModes.map(actionItem => ({\n type: actionItem.view?.type ?? '',\n menuItemId: menuItem.id,\n menuItemName: menuItem.displayName,\n actionId: actionItem.id ?? '',\n actionName: actionItem.displayName ?? '',\n }));\n }\n\n\n const viewId = action?.view?.id\n // 3. Fetch the view based on module, model & view name.\n const entity = await this.repo.findOne({\n where: {\n model: { singularName: modelName },\n module: { name: moduleName },\n ...(actionId && viewId ? { id: action.view.id } : { type: viewType })\n },\n relations: {\n model: {\n userKeyField: true,\n },\n module: true,\n }\n });\n\n if (!entity) {\n throw new BadRequestException(`Unable to identify view for module: ${moduleName}, model: ${modelName} and viewType: ${viewType}`);\n }\n if (!activeUser?.sub) {\n throw new BadRequestException(`Unable to identify user for module: ${moduleName}, model: ${modelName} and viewType: ${viewType}`);\n }\n\n // 4. add action and menuItem to Entity which is our solid View\n if (actionId) {\n delete action.view;\n entity['action'] = action\n }\n if (menuItemId) {\n entity['menu'] = menuItem\n }\n\n // 5. See if we have a user specific layout for this view.\n const userLayout = await this.userViewMetadataService.repo.findOne({\n where: {\n user: { id: activeUser?.sub },\n viewMetadata: { id: entity.id },\n },\n });\n // Based on where we found the layout we are converting it from string to json.\n if (userLayout) {\n entity.layout = JSON.parse(userLayout.layout);\n } else {\n entity.layout = JSON.parse(entity.layout);\n }\n\n\n // 6. We are resolving the create & edit actions if specified in the layout.\n if (entity?.layout?.attrs?.createAction) {\n const actionName: string = entity.layout.attrs.createAction;\n entity.layout.attrs.createAction = await this.actionMetadataService.findOneByUserKey(actionName)\n }\n if (entity?.layout?.attrs?.editAction) {\n const actionName: string = entity.layout.attrs.editAction;\n entity.layout.attrs.editAction = await this.actionMetadataService.findOneByUserKey(actionName)\n }\n\n // 7. For form views we need to fetch the workflow field metadata if specified.\n let workflowFieldName = null;\n let workflowField = null;\n if (viewType === 'form') {\n workflowFieldName = entity.layout?.attrs?.workflowField;\n }\n\n // 8. Create an easy to use map of field metadata, rather than sending an array of fields it becomes easier to use in the frontend.\n const fields = await this.modelMetadataHelperService.loadFieldHierarchy(modelName);\n const fieldsMap = new Map<string, FieldMetadata>();\n for (let i = 0; i < fields.length; i++) {\n const field = fields[i];\n\n // We need to identify the workflowField metadata if specified. \n if (workflowFieldName && field.name === workflowFieldName) {\n workflowField = field;\n }\n\n // For fields of type relation & relationType many-to-one\n // We fetch metadata regarding the relationCoModelSingularName\n if (field.type === 'relation') {\n const relationModel = await this.modelMetadataRepo.find({\n where: {\n singularName: field.relationCoModelSingularName\n },\n relations: {\n userKeyField: true\n }\n });\n\n if (relationModel) {\n field['relationModel'] = relationModel[0];\n }\n }\n if (!fieldsMap.has(field.name)) {\n fieldsMap.set(field.name, field);\n }\n }\n\n // 9. Use the resolved workflowField to populate workflow specific metadata.\n // Check if we were able to resolve an actual workflowField.\n let solidFormViewWorkflowData = [];\n if (viewType === 'form' && workflowField) {\n // check for type of workflow field. \n // for workflowFields of type selectionStatic we simply return the key/values from field metadata AS-IS\n if (workflowField.type === 'selectionStatic') {\n solidFormViewWorkflowData = workflowField.selectionStaticValues.map(item => {\n const [value, label] = item.split(\":\");\n return { label, value };\n });\n }\n // for workflowFields of type relation.many-to-one we need to query the co-model, and return data in key/value format.\n if (workflowField.type === 'relation' && workflowField.relationType === 'many-to-one') {\n const comodelCrudService = this.introspectService.getCRUDService(workflowField.relationCoModelSingularName);\n const data = await comodelCrudService.find({ limit: 100, offset: 0, });\n const records = data.records ?? [];\n const workflowFieldMetadata = fieldsMap.get(workflowFieldName);\n const workflowFielUserkey = workflowFieldMetadata['relationModel']['userKeyField']['name'];\n\n // iterate over the comodel records extracting the label & value. \n solidFormViewWorkflowData = records.map(item => ({ 'label': item[workflowFielUserkey], 'value': item['id'] }))\n }\n }\n\n // 10. If this model supports internationalisation, we need to load the locales applicable with the id of an actual record for each locale if present.\n // This is the shape of locales that will be returned \n /**\n * [\n * {locale: 'en', displayName: 'English', isDefault: 'yes', defaultEntityLocaleId: '', entityId: '1'}, \n * {locale: 'en-IN', displayName: 'English (India)', isDefault: 'no', defaultEntityLocaleId: '1', entityId: '2'}, \n * {locale: 'en-SG', displayName: 'English (Singapore)', isDefault: 'no', defaultEntityLocaleId: '', entityId: '3'}, \n * {locale: 'fr', displayName: 'French', isDefault: 'no', defaultEntityLocaleId: '', entityId: ''}\n * ]\n */\n\n const applicableLocales: any = []\n // if (entity.model.internationalisation) {\n // const allLocales = await this.entityManager.getRepository(Locale).find({});\n\n // if (id === 'new') {\n // allLocales.forEach(locale => {\n // applicableLocales.push({\n // locale: locale.locale,\n // displayName: locale.displayName,\n // isDefault: locale.isDefault ? 'yes' : 'no',\n // defaultEntityLocaleId: null,\n // entityId: null\n // });\n // });\n // }\n // else {\n // const defaultLocale = allLocales.find(locale => locale.isDefault);\n // this.logger.debug(`Default locale is: ${defaultLocale.locale}`);\n\n // // Get hold of the repository for the current model\n // const solidRegistry = await this.moduleRef.get(SolidRegistry, { strict: false });\n // const currentEntityTarget = solidRegistry.getEntityTarget(this.entityManager, classify(modelName));\n // const currentEntityRepository = this.entityManager.getRepository(currentEntityTarget);\n\n // // We are in edit mode, the id that is being edited could be a record tagged with the default locale or it could be tagged with a non-default locale.\n // const entityRecord = await currentEntityRepository.findOne({\n // where: {\n // id: id,\n // }\n // });\n // if(entityRecord){\n // // Resolve the default entity locale id....\n // let defaultEntityLocaleId = null;\n // if (entityRecord.localeName === defaultLocale.locale) {\n // defaultEntityLocaleId = entityRecord.id;\n // this.logger.debug(`You are editing a record tagged with the default locale: ${entityRecord.localeName}.`);\n // }\n // else {\n // defaultEntityLocaleId = entityRecord.defaultEntityLocaleId;\n // this.logger.debug(`You are editing a record tagged with the non-default locale: ${entityRecord.localeName}. `);\n // }\n // this.logger.debug(`Identified default Entity Locale Id: ${defaultEntityLocaleId}`);\n\n // // Now we query for all records in the same model matching the defaultEntityLocaleId\n // // Get all records mathcing the defaultEntityLocaleId or where the id is same as the defaultEntityLocaleId\n // const entityRecordsInAllLocales = await currentEntityRepository.find({\n // where: [\n // { defaultEntityLocaleId: defaultEntityLocaleId },\n // { id: defaultEntityLocaleId }\n // ],\n // });\n // this.logger.debug(`Found ${entityRecordsInAllLocales.length} records in all locales for the defaultEntityLocaleId: ${defaultEntityLocaleId}`);\n\n // // Loop over all locales and populate the applicableLocales array\n // for (const locale of allLocales) {\n // // Find the record in the entityRecordsInAllLocales that matches the current locale\n // const matchingRecord = entityRecordsInAllLocales.find(record => record.localeName === locale.locale);\n\n // applicableLocales.push({\n // locale: locale.locale,\n // displayName: locale.displayName,\n // isDefault: locale.isDefault ? 'yes' : 'no',\n // defaultEntityLocaleId: defaultEntityLocaleId,\n // entityId: (matchingRecord ? matchingRecord.id : null)\n // });\n // }\n // }else{\n // this.logger.warn(`No record found for id: ${id} in model: ${modelName}. Cannot determine applicable locales.`);\n // }\n // }\n // }\n if (entity.model.internationalisation) {\n const defaultEntityLocaleIdFromQuery = query?.defaultEntityLocaleId;\n const { records: entityRecordsInAllLocales, defaultEntityLocaleId } =\n await this.getEntityRecordsInAllLocales(modelName, id, defaultEntityLocaleIdFromQuery);\n const allLocales = await this.entityManager.getRepository(Locale).find({});\n for (const locale of allLocales) {\n const matchingRecord = entityRecordsInAllLocales.find(record => record.localeName === locale.locale);\n applicableLocales.push({\n locale: locale.locale,\n displayName: locale.displayName,\n isDefault: locale.isDefault ? 'yes' : 'no',\n defaultEntityLocaleId: defaultEntityLocaleId,\n entityId: matchingRecord ? matchingRecord.id : null\n });\n }\n }\n\n const r = {\n 'solidView': entity,\n 'solidFieldsMetadata': Object.fromEntries(fieldsMap),\n 'solidFormViewWorkflowData': solidFormViewWorkflowData,\n 'applicableLocales': applicableLocales,\n 'viewModes': viewModes\n }\n\n return r;\n }\n\n private async loadFieldHierarchy(modelName: any) {\n const model = await this.modelMetadataRepo.findOne({\n where: {\n singularName: modelName,\n },\n relations: {\n fields: true,\n parentModel: {\n fields: true,\n }\n }\n });\n const fields = [];\n if (model) {\n // Add the fields of the current model\n fields.push(...model.fields);\n\n // Add the fields of the parent model\n if (model.parentModel) {\n fields.push(...model.parentModel.fields);\n }\n }\n return fields;\n }\n\n async findOneByUserKey(name: string, relations = {}) {\n const entity = await this.repo.findOne({\n where: {\n name: name,\n },\n relations: relations,\n });\n return entity;\n }\n\n async upsert(updateSolidViewDto: UpdateViewMetadataDto) {\n // First check if module already exists using name\n const existingSolidView = await this.findOneByUserKey(updateSolidViewDto.name);\n\n // if found\n if (existingSolidView) {\n const updatedSolidViewDto = { ...existingSolidView, ...updateSolidViewDto };\n return this.repo.save(updatedSolidViewDto);\n }\n // if not found - create new \n else {\n const viewData = this.repo.create(updateSolidViewDto);\n return this.repo.save(viewData);\n }\n }\n\n async createIfNotPresent(updateSolidViewDto: UpdateViewMetadataDto) {\n // First check if module already exists using name\n const existingSolidView = await this.findOneByUserKey(updateSolidViewDto.name);\n\n // if found\n if (existingSolidView) {\n }\n // if not found - create new \n else {\n const viewData = this.repo.create(updateSolidViewDto);\n return this.repo.save(viewData);\n }\n }\n\n // END: Custom Service Methods\n\n}\n"]}
|
|
1
|
+
{"version":3,"file":"view-metadata.service.js","sourceRoot":"","sources":["../../src/services/view-metadata.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,2CAA6F;AAC7F,uCAAyC;AACzC,6CAAsD;AACtD,iDAAwD;AACxD,qCAAwC;AAExC,4DAAoD;AACpD,6DAAoD;AACpD,4FAAuF;AACvF,8DAA2D;AAC3D,uFAAmF;AACnF,qFAAiF;AAIjF,uEAAkE;AAClE,6EAAuE;AACvE,yEAAoE;AACpE,6EAAuE;AAIhE,IAAM,mBAAmB,2BAAzB,MAAM,mBAAoB,SAAQ,0BAAyB;IAChE,YACW,qBAA4C,EAC5C,uBAAgD,EAChD,iBAAyC,EACzC,uBAAgD,EAEzD,aAAqC,EAE5B,IAA4B,EAMrC,iBAA2D,EAC1C,0BAAsD,EAC9D,SAAoB;QAE7B,KAAK,CAAC,aAAa,EAAE,IAAI,EAAE,cAAc,EAAE,YAAY,EAAE,SAAS,CAAC,CAAC;QAjB3D,0BAAqB,GAArB,qBAAqB,CAAuB;QAC5C,4BAAuB,GAAvB,uBAAuB,CAAyB;QAChD,sBAAiB,GAAjB,iBAAiB,CAAwB;QACzC,4BAAuB,GAAvB,uBAAuB,CAAyB;QAEhD,kBAAa,GAAb,aAAa,CAAe;QAE5B,SAAI,GAAJ,IAAI,CAAwB;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AM,CAAC,kBAAkB,CAAC,CAAC;YACtD,OAAO,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QAClC,CAAC;IACH,CAAC;IAED,KAAK,CAAC,kBAAkB,CAAC,kBAAyC;QAEhE,MAAM,iBAAiB,GAAG,MAAM,IAAI,CAAC,gBAAgB,CAAC,kBAAkB,CAAC,IAAI,CAAC,CAAC;QAG/E,IAAI,iBAAiB,EAAE,CAAC;QACxB,CAAC;aAEI,CAAC;YACJ,MAAM,QAAQ,GAAG,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,kBAAkB,CAAC,CAAC;YACtD,OAAO,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QAClC,CAAC;IACH,CAAC;CAIF,CAAA;AA/aY,kDAAmB;8BAAnB,mBAAmB;IAD/B,IAAA,mBAAU,GAAE;IAOR,WAAA,IAAA,6BAAmB,GAAE,CAAA;IAQrB,WAAA,IAAA,eAAM,EAAC,IAAA,mBAAU,EAAC,GAAG,EAAE,CAAC,mDAAuB,CAAC,CAAC,CAAA;qCAZlB,+CAAqB;QACnB,oDAAuB;QAC7B,iDAAsB;QAChB,oDAAuB;QAEjC,uBAAa;QAEtB,iDAAsB;QAMD,mDAAuB;QACd,0DAA0B;QACnD,gBAAS;GAjBpB,mBAAmB,CA+a/B","sourcesContent":["import { BadRequestException, forwardRef, Inject, Injectable, Logger } from '@nestjs/common';\nimport { ModuleRef } from \"@nestjs/core\";\nimport { InjectEntityManager } from '@nestjs/typeorm';\nimport { CRUDService } from 'src/services/crud.service';\nimport { EntityManager } from 'typeorm';\n\nimport { classify } from '../helpers/string.helper';\nimport { Locale } from 'src/entities/locale.entity';\nimport { ModelMetadataHelperService } from 'src/helpers/model-metadata-helper.service';\nimport { SolidRegistry } from 'src/helpers/solid-registry';\nimport { ModelMetadataRepository } from 'src/repository/model-metadata.repository';\nimport { ViewMetadataRepository } from 'src/repository/view-metadata.repository';\nimport { UpdateViewMetadataDto } from '../dtos/update-view-metadata.dto';\nimport { FieldMetadata } from '../entities/field-metadata.entity';\nimport { ViewMetadata } from '../entities/view-metadata.entity';\nimport { ActionMetadataService } from './action-metadata.service';\nimport { MenuItemMetadataService } from './menu-item-metadata.service';\nimport { SolidIntrospectService } from './solid-introspect.service';\nimport { UserViewMetadataService } from './user-view-metadata.service';\nimport { MenuItemMetadata } from 'src/entities/menu-item-metadata.entity';\n\n@Injectable()\nexport class ViewMetadataService extends CRUDService<ViewMetadata> {\n constructor(\n readonly actionMetadataService: ActionMetadataService,\n readonly menuItemMetadataService: MenuItemMetadataService,\n readonly introspectService: SolidIntrospectService,\n readonly userViewMetadataService: UserViewMetadataService,\n @InjectEntityManager()\n readonly entityManager: EntityManager,\n // @InjectRepository(ViewMetadata, 'default')\n readonly repo: ViewMetadataRepository,\n // @InjectRepository(FieldMetadata)\n // private readonly fieldMetadataRepo: Repository<FieldMetadata>,\n // @InjectRepository(ModelMetadata)\n // private readonly modelMetadataRepo: Repository<ModelMetadata>,\n @Inject(forwardRef(() => ModelMetadataRepository))\n private readonly modelMetadataRepo: ModelMetadataRepository,\n private readonly modelMetadataHelperService: ModelMetadataHelperService,\n readonly moduleRef: ModuleRef\n ) {\n super(entityManager, repo, 'viewMetadata', 'solid-core', moduleRef);\n }\n\n private readonly logger = new Logger(ViewMetadataService.name);\n\n //for locales \n private async getEntityRecordsInAllLocales(\n modelName: string,\n id: string,\n defaultEntityLocaleIdFromQuery?: string\n ): Promise<{ records: any[], defaultEntityLocaleId: string | null }> {\n const solidRegistry = await this.moduleRef.get(SolidRegistry, { strict: false });\n // const currentEntityTarget = solidRegistry.getEntityTarget(this.entityManager, classify(modelName));\n const currentEntityRepository = this.entityManager.getRepository(classify(modelName));\n\n // Case 1: Creating a new record with no defaultEntityLocaleId to clone\n if (id === 'new' && !defaultEntityLocaleIdFromQuery) {\n this.logger.debug(`Creating new record without cloning from any defaultEntityLocaleId.`);\n return { records: [], defaultEntityLocaleId: null };\n }\n\n // Case 2: Creating a new record and cloning from an existing defaultEntityLocaleId\n if (id === 'new' && defaultEntityLocaleIdFromQuery) {\n this.logger.debug(`Creating new record by cloning translations from defaultEntityLocaleId: ${defaultEntityLocaleIdFromQuery}`);\n\n const records = await currentEntityRepository.find({\n where: [\n { defaultEntityLocaleId: defaultEntityLocaleIdFromQuery },\n { id: defaultEntityLocaleIdFromQuery }\n ]\n });\n\n this.logger.debug(`Found ${records.length} cloned records for new entity.`);\n return { records, defaultEntityLocaleId: defaultEntityLocaleIdFromQuery };\n }\n\n // Case 3: Editing an existing entity\n const entityRecord = await currentEntityRepository.findOne({ where: { id } });\n\n if (!entityRecord) {\n this.logger.warn(`No entity found for id ${id}`);\n return { records: [], defaultEntityLocaleId: null };\n }\n\n const defaultLocale = await this.entityManager.getRepository(Locale).findOne({ where: { isDefault: true } });\n\n let defaultEntityLocaleId: string;\n if (entityRecord.localeName === defaultLocale?.locale) {\n defaultEntityLocaleId = entityRecord.id;\n this.logger.debug(`Editing default locale record with id ${defaultEntityLocaleId}`);\n } else {\n defaultEntityLocaleId = entityRecord.defaultEntityLocaleId;\n this.logger.debug(`Editing non-default locale record. DefaultEntityLocaleId: ${defaultEntityLocaleId}`);\n }\n\n const records = await currentEntityRepository.find({\n where: [\n { defaultEntityLocaleId: defaultEntityLocaleId },\n { id: defaultEntityLocaleId }\n ]\n });\n\n this.logger.debug(`Found ${records.length} records in all locales for existing entity.`);\n\n return { records, defaultEntityLocaleId };\n }\n\n // START: Custom Service Methods\n async getLayout(query, activeUser) {\n let { modelName, moduleName, viewType, id, populate, menuItemId, menuItemName, actionId, actionName } = query;\n\n // 1. Fetch the action based on actionId.\n const solidRequestContext = {\n activeUser: activeUser\n }\n const actionQuery = {\n populate: [\"view\"]\n }\n let action = null;\n if (actionId) {\n action = await this.actionMetadataService.findOne(actionId, actionQuery, solidRequestContext);\n }\n\n // 2. Fetch the menu based on menuItemId.\n const menuItemQuery = {\n populate: ['action', 'action.model', 'module']\n }\n let menuItem: MenuItemMetadata = null;\n if (menuItemId) {\n menuItem = await this.menuItemMetadataService.findOne(menuItemId, menuItemQuery, solidRequestContext);\n }\n\n let viewModes = [];\n const menuItemModelId = menuItem?.action?.model?.id;\n const menuItemModuleId = menuItem?.module?.id;\n if (menuItemModelId && menuItemModuleId) {\n const actionQb = await this.actionMetadataService.repo.createSecurityRuleAwareQueryBuilder('action');\n const actionsForViewModes = await actionQb\n .leftJoinAndSelect('action.model', 'model')\n .leftJoinAndSelect('action.module', 'module')\n .leftJoinAndSelect('action.view', 'view')\n .where('model.id = :modelId', { modelId: menuItemModelId })\n .andWhere('module.id = :moduleId', { moduleId: menuItemModuleId })\n .andWhere('view.type IN (:...viewTypes)', { viewTypes: ['card', 'list', 'kanban', 'tree'] })\n .getMany();\n\n viewModes = actionsForViewModes.map(actionItem => ({\n type: actionItem.view?.type ?? '',\n menuItemId: menuItem.id,\n menuItemName: menuItem.displayName,\n actionId: actionItem.id ?? '',\n actionName: actionItem.displayName ?? '',\n }));\n }\n\n const viewId = action?.view?.id\n // 3. Fetch the view based on module, model & view name.\n const entity = await this.repo.findOne({\n where: {\n model: { singularName: modelName },\n module: { name: moduleName },\n ...(actionId && viewId ? { id: action.view.id } : { type: viewType })\n },\n relations: {\n model: {\n userKeyField: true,\n },\n module: true,\n }\n });\n\n if (!entity) {\n throw new BadRequestException(`Unable to identify view for module: ${moduleName}, model: ${modelName} and viewType: ${viewType}`);\n }\n if (!activeUser?.sub) {\n throw new BadRequestException(`Unable to identify user for module: ${moduleName}, model: ${modelName} and viewType: ${viewType}`);\n }\n\n // 4. add action and menuItem to Entity which is our solid View\n if (actionId) {\n delete action.view;\n entity['action'] = action\n }\n if (menuItemId) {\n entity['menu'] = menuItem\n }\n\n // 5. See if we have a user specific layout for this view.\n const userLayout = await this.userViewMetadataService.repo.findOne({\n where: {\n user: { id: activeUser?.sub },\n viewMetadata: { id: entity.id },\n },\n });\n // Based on where we found the layout we are converting it from string to json.\n if (userLayout) {\n entity.layout = JSON.parse(userLayout.layout);\n } else {\n entity.layout = JSON.parse(entity.layout);\n }\n\n // 6. We are resolving the create & edit actions if specified in the layout.\n if (entity?.layout?.attrs?.createAction) {\n const actionName: string = entity.layout.attrs.createAction;\n entity.layout.attrs.createAction = await this.actionMetadataService.findOneByUserKey(actionName)\n }\n if (entity?.layout?.attrs?.editAction) {\n const actionName: string = entity.layout.attrs.editAction;\n entity.layout.attrs.editAction = await this.actionMetadataService.findOneByUserKey(actionName)\n }\n\n // 7. For form views we need to fetch the workflow field metadata if specified.\n let workflowFieldName = null;\n let workflowField = null;\n if (viewType === 'form') {\n workflowFieldName = entity.layout?.attrs?.workflowField;\n }\n\n // 8. Create an easy to use map of field metadata, rather than sending an array of fields it becomes easier to use in the frontend.\n const fields = await this.modelMetadataHelperService.loadFieldHierarchy(modelName);\n const fieldsMap = new Map<string, FieldMetadata>();\n for (let i = 0; i < fields.length; i++) {\n const field = fields[i];\n\n // We need to identify the workflowField metadata if specified. \n if (workflowFieldName && field.name === workflowFieldName) {\n workflowField = field;\n }\n\n // For fields of type relation & relationType many-to-one\n // We fetch metadata regarding the relationCoModelSingularName\n if (field.type === 'relation') {\n const relationModel = await this.modelMetadataRepo.find({\n where: {\n singularName: field.relationCoModelSingularName\n },\n relations: {\n userKeyField: true\n }\n });\n\n if (relationModel) {\n field['relationModel'] = relationModel[0];\n }\n }\n if (!fieldsMap.has(field.name)) {\n fieldsMap.set(field.name, field);\n }\n }\n\n // 9. Use the resolved workflowField to populate workflow specific metadata.\n // Check if we were able to resolve an actual workflowField.\n let solidFormViewWorkflowData = [];\n if (viewType === 'form' && workflowField) {\n // check for type of workflow field. \n // for workflowFields of type selectionStatic we simply return the key/values from field metadata AS-IS\n if (workflowField.type === 'selectionStatic') {\n solidFormViewWorkflowData = workflowField.selectionStaticValues.map(item => {\n const [value, label] = item.split(\":\");\n return { label, value };\n });\n }\n // for workflowFields of type relation.many-to-one we need to query the co-model, and return data in key/value format.\n if (workflowField.type === 'relation' && workflowField.relationType === 'many-to-one') {\n const comodelCrudService = this.introspectService.getCRUDService(workflowField.relationCoModelSingularName);\n const data = await comodelCrudService.find({ limit: 100, offset: 0, });\n const records = data.records ?? [];\n const workflowFieldMetadata = fieldsMap.get(workflowFieldName);\n const workflowFielUserkey = workflowFieldMetadata['relationModel']['userKeyField']['name'];\n\n // iterate over the comodel records extracting the label & value. \n solidFormViewWorkflowData = records.map(item => ({ 'label': item[workflowFielUserkey], 'value': item['id'] }))\n }\n }\n\n // 10. If this model supports internationalisation, we need to load the locales applicable with the id of an actual record for each locale if present.\n // This is the shape of locales that will be returned \n /**\n * [\n * {locale: 'en', displayName: 'English', isDefault: 'yes', defaultEntityLocaleId: '', entityId: '1'}, \n * {locale: 'en-IN', displayName: 'English (India)', isDefault: 'no', defaultEntityLocaleId: '1', entityId: '2'}, \n * {locale: 'en-SG', displayName: 'English (Singapore)', isDefault: 'no', defaultEntityLocaleId: '', entityId: '3'}, \n * {locale: 'fr', displayName: 'French', isDefault: 'no', defaultEntityLocaleId: '', entityId: ''}\n * ]\n */\n\n const applicableLocales: any = []\n // if (entity.model.internationalisation) {\n // const allLocales = await this.entityManager.getRepository(Locale).find({});\n\n // if (id === 'new') {\n // allLocales.forEach(locale => {\n // applicableLocales.push({\n // locale: locale.locale,\n // displayName: locale.displayName,\n // isDefault: locale.isDefault ? 'yes' : 'no',\n // defaultEntityLocaleId: null,\n // entityId: null\n // });\n // });\n // }\n // else {\n // const defaultLocale = allLocales.find(locale => locale.isDefault);\n // this.logger.debug(`Default locale is: ${defaultLocale.locale}`);\n\n // // Get hold of the repository for the current model\n // const solidRegistry = await this.moduleRef.get(SolidRegistry, { strict: false });\n // const currentEntityTarget = solidRegistry.getEntityTarget(this.entityManager, classify(modelName));\n // const currentEntityRepository = this.entityManager.getRepository(currentEntityTarget);\n\n // // We are in edit mode, the id that is being edited could be a record tagged with the default locale or it could be tagged with a non-default locale.\n // const entityRecord = await currentEntityRepository.findOne({\n // where: {\n // id: id,\n // }\n // });\n // if(entityRecord){\n // // Resolve the default entity locale id....\n // let defaultEntityLocaleId = null;\n // if (entityRecord.localeName === defaultLocale.locale) {\n // defaultEntityLocaleId = entityRecord.id;\n // this.logger.debug(`You are editing a record tagged with the default locale: ${entityRecord.localeName}.`);\n // }\n // else {\n // defaultEntityLocaleId = entityRecord.defaultEntityLocaleId;\n // this.logger.debug(`You are editing a record tagged with the non-default locale: ${entityRecord.localeName}. `);\n // }\n // this.logger.debug(`Identified default Entity Locale Id: ${defaultEntityLocaleId}`);\n\n // // Now we query for all records in the same model matching the defaultEntityLocaleId\n // // Get all records mathcing the defaultEntityLocaleId or where the id is same as the defaultEntityLocaleId\n // const entityRecordsInAllLocales = await currentEntityRepository.find({\n // where: [\n // { defaultEntityLocaleId: defaultEntityLocaleId },\n // { id: defaultEntityLocaleId }\n // ],\n // });\n // this.logger.debug(`Found ${entityRecordsInAllLocales.length} records in all locales for the defaultEntityLocaleId: ${defaultEntityLocaleId}`);\n\n // // Loop over all locales and populate the applicableLocales array\n // for (const locale of allLocales) {\n // // Find the record in the entityRecordsInAllLocales that matches the current locale\n // const matchingRecord = entityRecordsInAllLocales.find(record => record.localeName === locale.locale);\n\n // applicableLocales.push({\n // locale: locale.locale,\n // displayName: locale.displayName,\n // isDefault: locale.isDefault ? 'yes' : 'no',\n // defaultEntityLocaleId: defaultEntityLocaleId,\n // entityId: (matchingRecord ? matchingRecord.id : null)\n // });\n // }\n // }else{\n // this.logger.warn(`No record found for id: ${id} in model: ${modelName}. Cannot determine applicable locales.`);\n // }\n // }\n // }\n if (entity.model.internationalisation) {\n const defaultEntityLocaleIdFromQuery = query?.defaultEntityLocaleId;\n const { records: entityRecordsInAllLocales, defaultEntityLocaleId } =\n await this.getEntityRecordsInAllLocales(modelName, id, defaultEntityLocaleIdFromQuery);\n const allLocales = await this.entityManager.getRepository(Locale).find({});\n for (const locale of allLocales) {\n const matchingRecord = entityRecordsInAllLocales.find(record => record.localeName === locale.locale);\n applicableLocales.push({\n locale: locale.locale,\n displayName: locale.displayName,\n isDefault: locale.isDefault ? 'yes' : 'no',\n defaultEntityLocaleId: defaultEntityLocaleId,\n entityId: matchingRecord ? matchingRecord.id : null\n });\n }\n }\n\n const r = {\n 'solidView': entity,\n 'solidFieldsMetadata': Object.fromEntries(fieldsMap),\n 'solidFormViewWorkflowData': solidFormViewWorkflowData,\n 'applicableLocales': applicableLocales,\n 'viewModes': viewModes\n }\n\n return r;\n }\n\n private async loadFieldHierarchy(modelName: any) {\n const model = await this.modelMetadataRepo.findOne({\n where: {\n singularName: modelName,\n },\n relations: {\n fields: true,\n parentModel: {\n fields: true,\n }\n }\n });\n const fields = [];\n if (model) {\n // Add the fields of the current model\n fields.push(...model.fields);\n\n // Add the fields of the parent model\n if (model.parentModel) {\n fields.push(...model.parentModel.fields);\n }\n }\n return fields;\n }\n\n async findOneByUserKey(name: string, relations = {}) {\n const entity = await this.repo.findOne({\n where: {\n name: name,\n },\n relations: relations,\n });\n return entity;\n }\n\n async upsert(updateSolidViewDto: UpdateViewMetadataDto) {\n // First check if module already exists using name\n const existingSolidView = await this.findOneByUserKey(updateSolidViewDto.name);\n\n // if found\n if (existingSolidView) {\n const updatedSolidViewDto = { ...existingSolidView, ...updateSolidViewDto };\n return this.repo.save(updatedSolidViewDto);\n }\n // if not found - create new \n else {\n const viewData = this.repo.create(updateSolidViewDto);\n return this.repo.save(viewData);\n }\n }\n\n async createIfNotPresent(updateSolidViewDto: UpdateViewMetadataDto) {\n // First check if module already exists using name\n const existingSolidView = await this.findOneByUserKey(updateSolidViewDto.name);\n\n // if found\n if (existingSolidView) {\n }\n // if not found - create new \n else {\n const viewData = this.repo.create(updateSolidViewDto);\n return this.repo.save(viewData);\n }\n }\n\n // END: Custom Service Methods\n\n}\n"]}
|
|
@@ -13,7 +13,7 @@ var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
|
13
13
|
};
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
15
|
exports.ComputedEntityFieldSubscriber = void 0;
|
|
16
|
-
const
|
|
16
|
+
const lodash_1 = require("lodash");
|
|
17
17
|
const common_1 = require("@nestjs/common");
|
|
18
18
|
const create_field_metadata_dto_1 = require("../dtos/create-field-metadata.dto");
|
|
19
19
|
const solid_registry_1 = require("../helpers/solid-registry");
|
|
@@ -29,27 +29,27 @@ let ComputedEntityFieldSubscriber = class ComputedEntityFieldSubscriber {
|
|
|
29
29
|
this.dataSource.subscribers.push(this);
|
|
30
30
|
}
|
|
31
31
|
async beforeInsert(event) {
|
|
32
|
-
const modelName = (0,
|
|
32
|
+
const modelName = (0, lodash_1.camelCase)(event.metadata?.name ?? event.entity?.constructor?.name ?? '');
|
|
33
33
|
const eventContext = this.sanitizeEventContext(event, 'beforeInsert');
|
|
34
34
|
await this.handleComputedFieldEvaluation(event.entity, create_field_metadata_dto_1.ComputedFieldTriggerOperation.beforeInsert, modelName, eventContext);
|
|
35
35
|
}
|
|
36
36
|
async beforeUpdate(event) {
|
|
37
|
-
const modelName = (0,
|
|
37
|
+
const modelName = (0, lodash_1.camelCase)(event.metadata?.name ?? event.entity?.constructor?.name ?? '');
|
|
38
38
|
const eventContext = this.sanitizeEventContext(event, 'beforeUpdate');
|
|
39
39
|
await this.handleComputedFieldEvaluation(event.entity, create_field_metadata_dto_1.ComputedFieldTriggerOperation.beforeUpdate, modelName, eventContext);
|
|
40
40
|
}
|
|
41
41
|
afterInsert(event) {
|
|
42
|
-
const modelName = (0,
|
|
42
|
+
const modelName = (0, lodash_1.camelCase)(event.metadata?.name ?? event.entity?.constructor?.name ?? '');
|
|
43
43
|
const eventContext = this.sanitizeEventContext(event, 'afterInsert');
|
|
44
44
|
this.handleComputedFieldEvaluationJob(event.entity, create_field_metadata_dto_1.ComputedFieldTriggerOperation.afterInsert, modelName, eventContext);
|
|
45
45
|
}
|
|
46
46
|
afterUpdate(event) {
|
|
47
|
-
const modelName = (0,
|
|
47
|
+
const modelName = (0, lodash_1.camelCase)(event.metadata?.name ?? event.entity?.constructor?.name ?? event.databaseEntity?.constructor?.name ?? '');
|
|
48
48
|
const eventContext = this.sanitizeEventContext(event, 'afterUpdate');
|
|
49
49
|
this.handleComputedFieldEvaluationJob(event.entity, create_field_metadata_dto_1.ComputedFieldTriggerOperation.afterUpdate, modelName, eventContext);
|
|
50
50
|
}
|
|
51
51
|
afterRemove(event) {
|
|
52
|
-
const modelName = (0,
|
|
52
|
+
const modelName = (0, lodash_1.camelCase)(event.metadata?.name ?? event.entity?.constructor?.name ?? event.databaseEntity?.constructor?.name ?? '');
|
|
53
53
|
const eventContext = this.sanitizeEventContext(event, 'afterRemove');
|
|
54
54
|
this.handleComputedFieldEvaluationJob(event.databaseEntity, create_field_metadata_dto_1.ComputedFieldTriggerOperation.afterRemove, modelName, eventContext);
|
|
55
55
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"computed-entity-field.subscriber.js","sourceRoot":"","sources":["../../src/subscribers/computed-entity-field.subscriber.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,oEAAkE;AAElE,2CAA6G;AAE7G,iFAAmF;AACnF,8DAAuG;AAEvG,4FAAiF;AAU1E,IAAM,6BAA6B,GAAnC,MAAM,6BAA6B;IAGtC,YAGqB,aAA4B,EAE7C,gBAAmF;QAFlE,kBAAa,GAAb,aAAa,CAAe;QAE5B,qBAAgB,GAAhB,gBAAgB,CAAkD;QAPtE,WAAM,GAAG,IAAI,eAAM,CAAC,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC;IAW5D,CAAC;IAED,gBAAgB,CAAC,UAAsB;QACnC,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;QAC7B,IAAI,CAAC,UAAU,CAAC,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAC3C,CAAC;IAED,KAAK,CAAC,YAAY,CAAC,KAAuB;QACtC,MAAM,SAAS,GAAG,IAAA,kBAAQ,EAAC,KAAK,CAAC,QAAQ,EAAE,IAA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AG,CAAC,CAAC,CAAM,EAAE,EAAE,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC;QACnF,CAAC;QACD,IAAI,KAAK,CAAC,MAAM;YAAE,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC,MAAM,CAAC;QAC7C,IAAI,gBAAgB,IAAI,KAAK,IAAI,KAAK,CAAC,cAAc,EAAE,CAAC;YACpD,IAAI,CAAC,cAAc,GAAG,KAAK,CAAC,cAAc,CAAC;QAC/C,CAAC;QACD,OAAO,IAAI,CAAC;IAChB,CAAC;CAEJ,CAAA;AArLY,sEAA6B;wCAA7B,6BAA6B;IAFzC,IAAA,mBAAU,EAAC,EAAE,KAAK,EAAE,cAAK,CAAC,SAAS,EAAE,CAAC;IAS9B,WAAA,IAAA,eAAM,EAAC,IAAA,mBAAU,EAAC,GAAG,EAAE,CAAC,4CAAgB,CAAC,CAAC,CAAA;qCADX,8BAAa;QAEV,4CAAgB;GAR9C,6BAA6B,CAqLzC","sourcesContent":["import { camelize } from \"@angular-devkit/core/src/utils/strings\";\nimport { Delete } from \"@aws-sdk/client-s3\";\nimport { forwardRef, Inject, Injectable, InternalServerErrorException, Logger, Scope } from \"@nestjs/common\";\nimport { model } from \"mongoose\";\nimport { ComputedFieldTriggerOperation } from \"src/dtos/create-field-metadata.dto\";\nimport { ComputedFieldMetadata, SolidRegistry, TypeOrmEventContext } from \"src/helpers/solid-registry\";\nimport { IEntityPreComputeFieldProvider } from \"src/interfaces\";\nimport { PublisherFactory } from \"src/services/queues/publisher-factory.service\";\nimport { DataSource, EntitySubscriberInterface, InsertEvent, RemoveEvent, UpdateEvent } from \"typeorm\";\n\n// Create an interface i.e ComputedFieldEvaluationPayload which has same fields as the ComputedFieldMetadata and an additional field for the database entity\nexport interface ComputedFieldEvaluationPayload extends ComputedFieldMetadata {\n databaseEntity: any;\n}\n\n@Injectable({ scope: Scope.TRANSIENT })\n// @EventSubscriber()\nexport class ComputedEntityFieldSubscriber implements EntitySubscriberInterface {\n private readonly logger = new Logger(this.constructor.name);\n private dataSource: DataSource;\n constructor(\n // @InjectDataSource()\n // private readonly dataSource: DataSource,\n private readonly solidRegistry: SolidRegistry,\n @Inject(forwardRef(() => PublisherFactory))\n private readonly publisherFactory: PublisherFactory<ComputedFieldEvaluationPayload>\n // private readonly computedFieldPublisher: ComputedFieldEvaluationPublisherDatabase,\n ) {\n // this.dataSource.subscribers.push(this);\n }\n\n bindToDataSource(dataSource: DataSource) {\n this.dataSource = dataSource;\n this.dataSource.subscribers.push(this);\n }\n\n async beforeInsert(event: InsertEvent<any>): Promise<any> {\n const modelName = camelize(event.metadata?.name ?? event.entity?.constructor?.name ?? '');\n const eventContext = this.sanitizeEventContext(event, 'beforeInsert');\n await this.handleComputedFieldEvaluation(event.entity, ComputedFieldTriggerOperation.beforeInsert, modelName, eventContext);\n }\n\n async beforeUpdate(event: UpdateEvent<any>): Promise<any> {\n const modelName = camelize(event.metadata?.name ?? event.entity?.constructor?.name ?? '');\n const eventContext = this.sanitizeEventContext(event, 'beforeUpdate');\n // await this.handleComputedFieldEvaluation(event.databaseEntity, ComputedFieldTriggerOperation.beforeUpdate, modelName, eventContext);\n await this.handleComputedFieldEvaluation(event.entity, ComputedFieldTriggerOperation.beforeUpdate, modelName, eventContext);\n }\n\n afterInsert(event: InsertEvent<any>) {\n const modelName = camelize(event.metadata?.name ?? event.entity?.constructor?.name ?? '');\n const eventContext = this.sanitizeEventContext(event, 'afterInsert');\n this.handleComputedFieldEvaluationJob(event.entity, ComputedFieldTriggerOperation.afterInsert, modelName, eventContext);\n }\n\n afterUpdate(event: UpdateEvent<any>) {\n const modelName = camelize(event.metadata?.name ?? event.entity?.constructor?.name ?? event.databaseEntity?.constructor?.name ?? '');\n const eventContext = this.sanitizeEventContext(event, 'afterUpdate');\n // this.handleComputedFieldEvaluationJob(event.databaseEntity, ComputedFieldTriggerOperation.afterUpdate, modelName, eventContext);\n this.handleComputedFieldEvaluationJob(event.entity, ComputedFieldTriggerOperation.afterUpdate, modelName, eventContext);\n }\n\n afterRemove(event: RemoveEvent<any>) {\n const modelName = camelize(event.metadata?.name ?? event.entity?.constructor?.name ?? event.databaseEntity?.constructor?.name ?? '');\n const eventContext = this.sanitizeEventContext(event, 'afterRemove');\n this.handleComputedFieldEvaluationJob(event.databaseEntity, ComputedFieldTriggerOperation.afterRemove, modelName, eventContext);\n }\n\n //FIXME: Need to add support for beforeRemove, beforeSoftRemove, afterSoftRemove, beforeRecover, afterRecover\n\n private async handleComputedFieldEvaluation(entity: any, currentOperation: ComputedFieldTriggerOperation, modelName: string, eventContext?: TypeOrmEventContext): Promise<void> {\n if (!entity) {\n return;\n }\n const computedFieldsTobeEvaluated = this.getComputedFieldsForEvaluation(\n this.solidRegistry.getComputedFieldMetadata(),\n currentOperation,\n modelName\n );\n //TODO: We can add a feature i.e dependsOn, where we can check if the computed field depends on other computed fields and evaluate them first\n for (const computedField of computedFieldsTobeEvaluated) {\n await this.evaluateComputedField(this.attachContext(computedField, eventContext), entity, currentOperation);\n }\n }\n\n private handleComputedFieldEvaluationJob(entity: any, currentOperation: ComputedFieldTriggerOperation, modelName: string, eventContext?: TypeOrmEventContext) {\n if (!entity) {\n return;\n }\n const computedFieldsTobeEvaluated = this.getComputedFieldsForEvaluation(\n this.solidRegistry.getComputedFieldMetadata(),\n currentOperation,\n modelName\n );\n //TODO: We can add a feature i.e dependsOn, where we can check if the computed field depends on other computed fields and evaluate them first\n for (const computedField of computedFieldsTobeEvaluated) {\n this.enqueueComputedFieldEvaluationJob(this.attachContext(computedField, eventContext), entity, eventContext);\n }\n }\n\n // Based on the current model name and current operation, identify all the computed providers that need to be evaluated\n // Pass the database entity and the context to the provider of type IEntityComputedFieldProvider\n private getComputedFieldsForEvaluation(computedFieldMetadata: ComputedFieldMetadata[] = [], currentOperation: ComputedFieldTriggerOperation, currentModelName: string) {\n return computedFieldMetadata.filter(\n (computedField) => computedField.computedFieldTriggerConfig.some(\n (trigger) => trigger.operations.includes(currentOperation) &&\n trigger.modelName === currentModelName\n )\n );\n }\n\n private async evaluateComputedField(computedFieldMetadata: ComputedFieldMetadata<any>, entity: any, currentOperation: ComputedFieldTriggerOperation) {\n // Skip pre-compute on insert when the payload already supplies the target field value.\n if (this.shouldSkipPreComputeOnInsert(computedFieldMetadata, entity, currentOperation)) {\n return;\n }\n const computedValue = await this.preComputeValue(computedFieldMetadata, entity);\n if (computedValue) {\n entity[computedFieldMetadata.fieldName] = computedValue; //TODO: This line here is just for backward compatibility, once the pre compute interface is change to return void, we will get rid of it.\n }\n }\n\n private shouldSkipPreComputeOnInsert(computedFieldMetadata: ComputedFieldMetadata<any>, entity: any, currentOperation: ComputedFieldTriggerOperation): boolean {\n if (currentOperation !== ComputedFieldTriggerOperation.beforeInsert) {\n return false;\n }\n if (!entity) {\n return false;\n }\n const fieldName = computedFieldMetadata.fieldName;\n if (!fieldName) {\n return false;\n }\n const hasValue = Object.prototype.hasOwnProperty.call(entity, fieldName) && entity[fieldName] !== undefined && entity[fieldName] !== null;\n return hasValue;\n }\n\n private async preComputeValue(computedFieldMetadata: ComputedFieldMetadata<any>, entity: any) {\n try {\n const provider = this.solidRegistry.getComputedFieldProvider(computedFieldMetadata.computedFieldValueProviderName);\n // Get the instance of the provider and assert it is of type IEntityComputedFieldProvider\n const providerInstance = provider.instance as IEntityPreComputeFieldProvider<any, any, any>; // IEntityComputedFieldProvider\n const computedValue = await providerInstance.preComputeValue(entity, computedFieldMetadata); //FIXME There should some way to check/assert if the provider actually has a postComputeAndSaveValue\n return computedValue; //TODO: This line here is just for backward compatibility, once the pre compute interface is change to return void, we will get rid of it.\n } catch (error) {\n throw new InternalServerErrorException(`Error evaluating computed field ${computedFieldMetadata.fieldName} for model ${computedFieldMetadata.modelName} for triggered entity ${entity.constructor.name}: ${error.message}`);\n }\n }\n\n private enqueueComputedFieldEvaluationJob(computedField: ComputedFieldMetadata<any>, databaseEntity: any, eventContext?: any) {\n const payload = {\n ...computedField,\n databaseEntity,\n // eventContext,\n };\n this.publisherFactory.publish({ payload }, 'ComputedFieldEvaluationPublisher')\n // this.computedFieldPublisher.publish({\n // payload\n // });\n }\n\n private attachContext<T extends ComputedFieldMetadata<any>>(computedField: T, eventContext?: any): T {\n if (!eventContext) return computedField;\n return {\n ...computedField,\n computedFieldValueProviderCtxt: {\n ...(computedField.computedFieldValueProviderCtxt || {}),\n },\n eventContext,\n };\n }\n\n private sanitizeEventContext(event: InsertEvent<any> | UpdateEvent<any> | RemoveEvent<any>, eventType: string): TypeOrmEventContext {\n if (!event) return undefined;\n const base: TypeOrmEventContext = {\n metadataName: event.metadata?.name,\n eventType: eventType,\n };\n if (\"entityId\" in event && event.entityId) {\n base.entityId = event.entityId;\n } else if (event.entity && (event.entity as any).id != null) {\n base.entityId = (event.entity as any).id;\n } else if (\"databaseEntity\" in event && (event.databaseEntity as any)?.id != null) {\n base.entityId = (event.databaseEntity as any).id;\n }\n if (\"updatedColumns\" in event && event.updatedColumns) {\n base.updatedColumns = event.updatedColumns.map((c: any) => c.propertyName);\n }\n if (\"updatedRelations\" in event && event.updatedRelations) {\n base.updatedRelations = event.updatedRelations.map((r: any) => r.propertyName);\n }\n if (event.entity) base.entity = event.entity;\n if (\"databaseEntity\" in event && event.databaseEntity) {\n base.databaseEntity = event.databaseEntity;\n }\n return base;\n }\n\n}\n"]}
|
|
1
|
+
{"version":3,"file":"computed-entity-field.subscriber.js","sourceRoot":"","sources":["../../src/subscribers/computed-entity-field.subscriber.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,mCAAmC;AAEnC,2CAA6G;AAE7G,iFAAmF;AACnF,8DAAuG;AAEvG,4FAAiF;AAU1E,IAAM,6BAA6B,GAAnC,MAAM,6BAA6B;IAGtC,YAGqB,aAA4B,EAE7C,gBAAmF;QAFlE,kBAAa,GAAb,aAAa,CAAe;QAE5B,qBAAgB,GAAhB,gBAAgB,CAAkD;QAPtE,WAAM,GAAG,IAAI,eAAM,CAAC,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,CAA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AC;YACpD,IAAI,CAAC,cAAc,GAAG,KAAK,CAAC,cAAc,CAAC,GAAG,CAAC,CAAC,CAAM,EAAE,EAAE,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC;QAC/E,CAAC;QACD,IAAI,kBAAkB,IAAI,KAAK,IAAI,KAAK,CAAC,gBAAgB,EAAE,CAAC;YACxD,IAAI,CAAC,gBAAgB,GAAG,KAAK,CAAC,gBAAgB,CAAC,GAAG,CAAC,CAAC,CAAM,EAAE,EAAE,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC;QACnF,CAAC;QACD,IAAI,KAAK,CAAC,MAAM;YAAE,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC,MAAM,CAAC;QAC7C,IAAI,gBAAgB,IAAI,KAAK,IAAI,KAAK,CAAC,cAAc,EAAE,CAAC;YACpD,IAAI,CAAC,cAAc,GAAG,KAAK,CAAC,cAAc,CAAC;QAC/C,CAAC;QACD,OAAO,IAAI,CAAC;IAChB,CAAC;CAEJ,CAAA;AArLY,sEAA6B;wCAA7B,6BAA6B;IAFzC,IAAA,mBAAU,EAAC,EAAE,KAAK,EAAE,cAAK,CAAC,SAAS,EAAE,CAAC;IAS9B,WAAA,IAAA,eAAM,EAAC,IAAA,mBAAU,EAAC,GAAG,EAAE,CAAC,4CAAgB,CAAC,CAAC,CAAA;qCADX,8BAAa;QAEV,4CAAgB;GAR9C,6BAA6B,CAqLzC","sourcesContent":["import { camelCase } from 'lodash';\nimport { Delete } from \"@aws-sdk/client-s3\";\nimport { forwardRef, Inject, Injectable, InternalServerErrorException, Logger, Scope } from \"@nestjs/common\";\nimport { model } from \"mongoose\";\nimport { ComputedFieldTriggerOperation } from \"src/dtos/create-field-metadata.dto\";\nimport { ComputedFieldMetadata, SolidRegistry, TypeOrmEventContext } from \"src/helpers/solid-registry\";\nimport { IEntityPreComputeFieldProvider } from \"src/interfaces\";\nimport { PublisherFactory } from \"src/services/queues/publisher-factory.service\";\nimport { DataSource, EntitySubscriberInterface, InsertEvent, RemoveEvent, UpdateEvent } from \"typeorm\";\n\n// Create an interface i.e ComputedFieldEvaluationPayload which has same fields as the ComputedFieldMetadata and an additional field for the database entity\nexport interface ComputedFieldEvaluationPayload extends ComputedFieldMetadata {\n databaseEntity: any;\n}\n\n@Injectable({ scope: Scope.TRANSIENT })\n// @EventSubscriber()\nexport class ComputedEntityFieldSubscriber implements EntitySubscriberInterface {\n private readonly logger = new Logger(this.constructor.name);\n private dataSource: DataSource;\n constructor(\n // @InjectDataSource()\n // private readonly dataSource: DataSource,\n private readonly solidRegistry: SolidRegistry,\n @Inject(forwardRef(() => PublisherFactory))\n private readonly publisherFactory: PublisherFactory<ComputedFieldEvaluationPayload>\n // private readonly computedFieldPublisher: ComputedFieldEvaluationPublisherDatabase,\n ) {\n // this.dataSource.subscribers.push(this);\n }\n\n bindToDataSource(dataSource: DataSource) {\n this.dataSource = dataSource;\n this.dataSource.subscribers.push(this);\n }\n\n async beforeInsert(event: InsertEvent<any>): Promise<any> {\n const modelName = camelCase(event.metadata?.name ?? event.entity?.constructor?.name ?? '');\n const eventContext = this.sanitizeEventContext(event, 'beforeInsert');\n await this.handleComputedFieldEvaluation(event.entity, ComputedFieldTriggerOperation.beforeInsert, modelName, eventContext);\n }\n\n async beforeUpdate(event: UpdateEvent<any>): Promise<any> {\n const modelName = camelCase(event.metadata?.name ?? event.entity?.constructor?.name ?? '');\n const eventContext = this.sanitizeEventContext(event, 'beforeUpdate');\n // await this.handleComputedFieldEvaluation(event.databaseEntity, ComputedFieldTriggerOperation.beforeUpdate, modelName, eventContext);\n await this.handleComputedFieldEvaluation(event.entity, ComputedFieldTriggerOperation.beforeUpdate, modelName, eventContext);\n }\n\n afterInsert(event: InsertEvent<any>) {\n const modelName = camelCase(event.metadata?.name ?? event.entity?.constructor?.name ?? '');\n const eventContext = this.sanitizeEventContext(event, 'afterInsert');\n this.handleComputedFieldEvaluationJob(event.entity, ComputedFieldTriggerOperation.afterInsert, modelName, eventContext);\n }\n\n afterUpdate(event: UpdateEvent<any>) {\n const modelName = camelCase(event.metadata?.name ?? event.entity?.constructor?.name ?? event.databaseEntity?.constructor?.name ?? '');\n const eventContext = this.sanitizeEventContext(event, 'afterUpdate');\n // this.handleComputedFieldEvaluationJob(event.databaseEntity, ComputedFieldTriggerOperation.afterUpdate, modelName, eventContext);\n this.handleComputedFieldEvaluationJob(event.entity, ComputedFieldTriggerOperation.afterUpdate, modelName, eventContext);\n }\n\n afterRemove(event: RemoveEvent<any>) {\n const modelName = camelCase(event.metadata?.name ?? event.entity?.constructor?.name ?? event.databaseEntity?.constructor?.name ?? '');\n const eventContext = this.sanitizeEventContext(event, 'afterRemove');\n this.handleComputedFieldEvaluationJob(event.databaseEntity, ComputedFieldTriggerOperation.afterRemove, modelName, eventContext);\n }\n\n //FIXME: Need to add support for beforeRemove, beforeSoftRemove, afterSoftRemove, beforeRecover, afterRecover\n\n private async handleComputedFieldEvaluation(entity: any, currentOperation: ComputedFieldTriggerOperation, modelName: string, eventContext?: TypeOrmEventContext): Promise<void> {\n if (!entity) {\n return;\n }\n const computedFieldsTobeEvaluated = this.getComputedFieldsForEvaluation(\n this.solidRegistry.getComputedFieldMetadata(),\n currentOperation,\n modelName\n );\n //TODO: We can add a feature i.e dependsOn, where we can check if the computed field depends on other computed fields and evaluate them first\n for (const computedField of computedFieldsTobeEvaluated) {\n await this.evaluateComputedField(this.attachContext(computedField, eventContext), entity, currentOperation);\n }\n }\n\n private handleComputedFieldEvaluationJob(entity: any, currentOperation: ComputedFieldTriggerOperation, modelName: string, eventContext?: TypeOrmEventContext) {\n if (!entity) {\n return;\n }\n const computedFieldsTobeEvaluated = this.getComputedFieldsForEvaluation(\n this.solidRegistry.getComputedFieldMetadata(),\n currentOperation,\n modelName\n );\n //TODO: We can add a feature i.e dependsOn, where we can check if the computed field depends on other computed fields and evaluate them first\n for (const computedField of computedFieldsTobeEvaluated) {\n this.enqueueComputedFieldEvaluationJob(this.attachContext(computedField, eventContext), entity, eventContext);\n }\n }\n\n // Based on the current model name and current operation, identify all the computed providers that need to be evaluated\n // Pass the database entity and the context to the provider of type IEntityComputedFieldProvider\n private getComputedFieldsForEvaluation(computedFieldMetadata: ComputedFieldMetadata[] = [], currentOperation: ComputedFieldTriggerOperation, currentModelName: string) {\n return computedFieldMetadata.filter(\n (computedField) => computedField.computedFieldTriggerConfig.some(\n (trigger) => trigger.operations.includes(currentOperation) &&\n trigger.modelName === currentModelName\n )\n );\n }\n\n private async evaluateComputedField(computedFieldMetadata: ComputedFieldMetadata<any>, entity: any, currentOperation: ComputedFieldTriggerOperation) {\n // Skip pre-compute on insert when the payload already supplies the target field value.\n if (this.shouldSkipPreComputeOnInsert(computedFieldMetadata, entity, currentOperation)) {\n return;\n }\n const computedValue = await this.preComputeValue(computedFieldMetadata, entity);\n if (computedValue) {\n entity[computedFieldMetadata.fieldName] = computedValue; //TODO: This line here is just for backward compatibility, once the pre compute interface is change to return void, we will get rid of it.\n }\n }\n\n private shouldSkipPreComputeOnInsert(computedFieldMetadata: ComputedFieldMetadata<any>, entity: any, currentOperation: ComputedFieldTriggerOperation): boolean {\n if (currentOperation !== ComputedFieldTriggerOperation.beforeInsert) {\n return false;\n }\n if (!entity) {\n return false;\n }\n const fieldName = computedFieldMetadata.fieldName;\n if (!fieldName) {\n return false;\n }\n const hasValue = Object.prototype.hasOwnProperty.call(entity, fieldName) && entity[fieldName] !== undefined && entity[fieldName] !== null;\n return hasValue;\n }\n\n private async preComputeValue(computedFieldMetadata: ComputedFieldMetadata<any>, entity: any) {\n try {\n const provider = this.solidRegistry.getComputedFieldProvider(computedFieldMetadata.computedFieldValueProviderName);\n // Get the instance of the provider and assert it is of type IEntityComputedFieldProvider\n const providerInstance = provider.instance as IEntityPreComputeFieldProvider<any, any, any>; // IEntityComputedFieldProvider\n const computedValue = await providerInstance.preComputeValue(entity, computedFieldMetadata); //FIXME There should some way to check/assert if the provider actually has a postComputeAndSaveValue\n return computedValue; //TODO: This line here is just for backward compatibility, once the pre compute interface is change to return void, we will get rid of it.\n } catch (error) {\n throw new InternalServerErrorException(`Error evaluating computed field ${computedFieldMetadata.fieldName} for model ${computedFieldMetadata.modelName} for triggered entity ${entity.constructor.name}: ${error.message}`);\n }\n }\n\n private enqueueComputedFieldEvaluationJob(computedField: ComputedFieldMetadata<any>, databaseEntity: any, eventContext?: any) {\n const payload = {\n ...computedField,\n databaseEntity,\n // eventContext,\n };\n this.publisherFactory.publish({ payload }, 'ComputedFieldEvaluationPublisher')\n // this.computedFieldPublisher.publish({\n // payload\n // });\n }\n\n private attachContext<T extends ComputedFieldMetadata<any>>(computedField: T, eventContext?: any): T {\n if (!eventContext) return computedField;\n return {\n ...computedField,\n computedFieldValueProviderCtxt: {\n ...(computedField.computedFieldValueProviderCtxt || {}),\n },\n eventContext,\n };\n }\n\n private sanitizeEventContext(event: InsertEvent<any> | UpdateEvent<any> | RemoveEvent<any>, eventType: string): TypeOrmEventContext {\n if (!event) return undefined;\n const base: TypeOrmEventContext = {\n metadataName: event.metadata?.name,\n eventType: eventType,\n };\n if (\"entityId\" in event && event.entityId) {\n base.entityId = event.entityId;\n } else if (event.entity && (event.entity as any).id != null) {\n base.entityId = (event.entity as any).id;\n } else if (\"databaseEntity\" in event && (event.databaseEntity as any)?.id != null) {\n base.entityId = (event.databaseEntity as any).id;\n }\n if (\"updatedColumns\" in event && event.updatedColumns) {\n base.updatedColumns = event.updatedColumns.map((c: any) => c.propertyName);\n }\n if (\"updatedRelations\" in event && event.updatedRelations) {\n base.updatedRelations = event.updatedRelations.map((r: any) => r.propertyName);\n }\n if (event.entity) base.entity = event.entity;\n if (\"databaseEntity\" in event && event.databaseEntity) {\n base.databaseEntity = event.databaseEntity;\n }\n return base;\n }\n\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@solidxai/core",
|
|
3
|
-
"version": "0.1.9-beta.
|
|
3
|
+
"version": "0.1.9-beta.7",
|
|
4
4
|
"description": "This module is a NestJS module containing all the required core providers required by a Solid application",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -30,7 +30,6 @@
|
|
|
30
30
|
"author": "Oswald Rodrigues <oswald@logicloop.io>",
|
|
31
31
|
"license": "ISC",
|
|
32
32
|
"dependencies": {
|
|
33
|
-
"@angular-devkit/core": "^18.0.3",
|
|
34
33
|
"@aws-sdk/client-s3": "^3.637.0",
|
|
35
34
|
"@aws-sdk/client-textract": "^3.873.0",
|
|
36
35
|
"@aws-sdk/s3-request-presigner": "^3.828.0",
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { classify } from
|
|
1
|
+
import { classify } from '../string.helper';
|
|
2
2
|
import { Logger } from "@nestjs/common";
|
|
3
3
|
import { isEmpty, isEnum, isNotEmpty } from "class-validator";
|
|
4
4
|
import { RelationFieldsCommand } from "src/dtos/create-field-metadata.dto";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { classify } from
|
|
1
|
+
import { classify } from '../string.helper';
|
|
2
2
|
import { BadRequestException } from "@nestjs/common";
|
|
3
3
|
import { isEmpty, isNotEmpty, isString } from "class-validator";
|
|
4
4
|
import { FieldCrudManager, ValidationError } from "src/interfaces";
|
|
@@ -87,7 +87,6 @@ export class ManyToOneRelationFieldCrudManager implements FieldCrudManager {
|
|
|
87
87
|
}
|
|
88
88
|
}
|
|
89
89
|
|
|
90
|
-
|
|
91
90
|
return dto;
|
|
92
91
|
}
|
|
93
92
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { classify } from
|
|
1
|
+
import { classify } from '../string.helper';
|
|
2
2
|
import { Logger } from "@nestjs/common";
|
|
3
3
|
import { isEmpty, isEnum, isInt, isNotEmpty } from "class-validator";
|
|
4
4
|
import { RelationFieldsCommand } from "src/dtos/create-field-metadata.dto";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { kebabCase } from 'lodash';
|
|
2
2
|
import { Injectable, Logger } from "@nestjs/common";
|
|
3
3
|
import * as fs from 'fs/promises'; // Use the Promise-based version of fs for async/await
|
|
4
4
|
import * as path from 'path'; // To handle file paths
|
|
@@ -41,7 +41,7 @@ export class ModuleMetadataHelperService {
|
|
|
41
41
|
if (!moduleName) {
|
|
42
42
|
return '';
|
|
43
43
|
}
|
|
44
|
-
const dashModuleName =
|
|
44
|
+
const dashModuleName = kebabCase(moduleName);
|
|
45
45
|
const folderPath = path.resolve(process.cwd(), 'module-metadata', dashModuleName);
|
|
46
46
|
const filePath = path.join(folderPath, `${dashModuleName}-metadata.json`);
|
|
47
47
|
// Check if filePath exists
|
|
@@ -62,7 +62,7 @@ export class ModuleMetadataHelperService {
|
|
|
62
62
|
return '';
|
|
63
63
|
}
|
|
64
64
|
|
|
65
|
-
const dashModuleName =
|
|
65
|
+
const dashModuleName = kebabCase(moduleName);
|
|
66
66
|
|
|
67
67
|
const folderPath = path.resolve(
|
|
68
68
|
process.cwd(),
|
|
@@ -4,7 +4,8 @@ import {
|
|
|
4
4
|
QueryRunner,
|
|
5
5
|
SelectQueryBuilder,
|
|
6
6
|
} from 'typeorm';
|
|
7
|
-
import {
|
|
7
|
+
import { upperFirst, camelCase } from 'lodash';
|
|
8
|
+
import { classify } from '../helpers/string.helper';
|
|
8
9
|
|
|
9
10
|
import { ChatterMessageDetails } from 'src/entities/chatter-message-details.entity';
|
|
10
11
|
import { ActiveUserData } from 'src/interfaces/active-user-data.interface';
|
|
@@ -80,7 +81,7 @@ export class ChatterMessageDetailsRepository extends SolidBaseRepository<Chatter
|
|
|
80
81
|
const entityName = classify(coModelName); // "client" -> "Client"
|
|
81
82
|
const meta = this.dataSource.getMetadata(entityName); // throws if not registered
|
|
82
83
|
// const table = meta.tablePath; // schema-qualified
|
|
83
|
-
const coAlias =
|
|
84
|
+
const coAlias = camelCase(meta.name); // stable alias, e.g., "client"
|
|
84
85
|
|
|
85
86
|
// LEFT JOIN "<schema>"."<table>" "<coAlias>"
|
|
86
87
|
// ON "<coAlias>"."id" = "message"."co_model_entity_id"
|
|
@@ -103,7 +104,7 @@ export class ChatterMessageDetailsRepository extends SolidBaseRepository<Chatter
|
|
|
103
104
|
const coModelName = get(requestFilter, this.CO_MODEL_NAME_PATH);
|
|
104
105
|
if (!coModelName) return [undefined, undefined];
|
|
105
106
|
|
|
106
|
-
const alias =
|
|
107
|
+
const alias = camelCase(coModelName);
|
|
107
108
|
return [coModelName, alias];
|
|
108
109
|
}
|
|
109
110
|
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { camelize, classify } from "@angular-devkit/core/src/utils/strings";
|
|
2
1
|
import { Injectable } from "@nestjs/common";
|
|
3
2
|
import { ChatterMessage } from "src/entities/chatter-message.entity";
|
|
4
3
|
import { ActiveUserData } from "src/interfaces/active-user-data.interface";
|
|
@@ -6,7 +5,8 @@ import { RequestContextService } from "src/services/request-context.service";
|
|
|
6
5
|
import { DataSource, QueryRunner, SelectQueryBuilder } from "typeorm";
|
|
7
6
|
import { SecurityRuleRepository } from "./security-rule.repository";
|
|
8
7
|
import { SolidBaseRepository } from "./solid-base.repository";
|
|
9
|
-
import {get} from
|
|
8
|
+
import { get, camelCase } from 'lodash';
|
|
9
|
+
import { classify } from '../helpers/string.helper';
|
|
10
10
|
|
|
11
11
|
@Injectable()
|
|
12
12
|
export class ChatterMessageRepository extends SolidBaseRepository<ChatterMessage> {
|
|
@@ -44,7 +44,7 @@ export class ChatterMessageRepository extends SolidBaseRepository<ChatterMessage
|
|
|
44
44
|
// const Target = resolveEntityFromCoModelName(coModelName); // your mapping
|
|
45
45
|
const entityName = classify(coModelName)
|
|
46
46
|
const meta = this.dataSource.getMetadata(entityName);
|
|
47
|
-
const alias =
|
|
47
|
+
const alias = camelCase(meta.name);
|
|
48
48
|
qb.leftJoin(
|
|
49
49
|
entityName,
|
|
50
50
|
alias,
|
|
@@ -63,7 +63,7 @@ export class ChatterMessageRepository extends SolidBaseRepository<ChatterMessage
|
|
|
63
63
|
|
|
64
64
|
const coModelName = get(requestFilter, this.CO_MODEL_NAME_PATH);
|
|
65
65
|
if (!coModelName) return [undefined, undefined];
|
|
66
|
-
const alias =
|
|
66
|
+
const alias = camelCase(coModelName);
|
|
67
67
|
return [coModelName, alias];
|
|
68
68
|
}
|
|
69
69
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { camelCase } from 'lodash';
|
|
2
2
|
import { Logger } from '@nestjs/common';
|
|
3
3
|
import { CommonEntity } from 'src/entities/common.entity';
|
|
4
4
|
import { ModelMetadata } from 'src/entities/model-metadata.entity';
|
|
@@ -33,7 +33,7 @@ export class SolidBaseRepository<T extends CommonEntity> extends Repository<T> {
|
|
|
33
33
|
}
|
|
34
34
|
|
|
35
35
|
modelSingularName(): string {
|
|
36
|
-
return
|
|
36
|
+
return camelCase(this.metadata.name);
|
|
37
37
|
}
|
|
38
38
|
|
|
39
39
|
async findOneByUserKey(userKeyValue: string | number): Promise<T | null> {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Injectable, Logger } from '@nestjs/common';
|
|
2
2
|
import { DiscoveryService, ModuleRef } from '@nestjs/core';
|
|
3
3
|
import { getDataSourceToken } from '@nestjs/typeorm';
|
|
4
|
-
import { classify } from '
|
|
4
|
+
import { classify } from '../helpers/string.helper';
|
|
5
5
|
import { DataSource, EntityManager } from 'typeorm';
|
|
6
6
|
import * as fs from 'fs';
|
|
7
7
|
import * as path from 'path';
|
|
@@ -4,7 +4,7 @@ import { ModuleRef } from "@nestjs/core";
|
|
|
4
4
|
import { InjectEntityManager } from '@nestjs/typeorm';
|
|
5
5
|
import { Brackets, EntityManager, EntityMetadata } from 'typeorm';
|
|
6
6
|
|
|
7
|
-
import { classify } from '
|
|
7
|
+
import { classify } from '../helpers/string.helper';
|
|
8
8
|
import { CHATTER_MESSAGE_SUBTYPE, CHATTER_MESSAGE_TYPE } from 'src/constants/chatter-message.constants';
|
|
9
9
|
import { PostChatterMessageDto } from 'src/dtos/post-chatter-message.dto';
|
|
10
10
|
import { ModelMetadataHelperService } from 'src/helpers/model-metadata-helper.service';
|
|
@@ -228,7 +228,6 @@ export class ChatterMessageService extends CRUDService<ChatterMessage> {
|
|
|
228
228
|
}
|
|
229
229
|
}
|
|
230
230
|
|
|
231
|
-
|
|
232
231
|
const allChangedFields = [
|
|
233
232
|
...changedNonRelationFields.map(field => ({
|
|
234
233
|
field,
|
|
@@ -413,7 +412,6 @@ export class ChatterMessageService extends CRUDService<ChatterMessage> {
|
|
|
413
412
|
}
|
|
414
413
|
}
|
|
415
414
|
|
|
416
|
-
|
|
417
415
|
return value.toString();
|
|
418
416
|
}
|
|
419
417
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { classify } from
|
|
1
|
+
import { classify } from '../../../helpers/string.helper';
|
|
2
2
|
import { Injectable } from "@nestjs/common";
|
|
3
3
|
import { InjectDataSource } from "@nestjs/typeorm";
|
|
4
4
|
import { ComputedFieldTriggerOperation } from "src/dtos/create-field-metadata.dto";
|
|
@@ -9,7 +9,6 @@ import { ComputedFieldMetadata } from "src/helpers/solid-registry";
|
|
|
9
9
|
import { IEntityPostComputeFieldProvider } from "src/interfaces";
|
|
10
10
|
import { DataSource, EntityManager } from "typeorm";
|
|
11
11
|
|
|
12
|
-
|
|
13
12
|
export interface SequenceNumComputedFieldContext {
|
|
14
13
|
sequenceName: string;
|
|
15
14
|
/**
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Brackets, SelectQueryBuilder, WhereExpressionBuilder } from "typeorm";
|
|
2
2
|
import { BasicFilterDto } from "../dtos/basic-filters.dto";
|
|
3
|
-
import { classify } from
|
|
3
|
+
import { classify } from '../helpers/string.helper';
|
|
4
4
|
import { ActiveUserData } from "src/interfaces/active-user-data.interface";
|
|
5
5
|
import { SolidRegistry } from "src/helpers/solid-registry";
|
|
6
6
|
import { BadRequestException, Logger } from "@nestjs/common";
|
|
@@ -287,7 +287,6 @@ export class CrudHelperService {
|
|
|
287
287
|
}
|
|
288
288
|
}
|
|
289
289
|
|
|
290
|
-
|
|
291
290
|
if (showSoftDeleted === 'inclusive') {
|
|
292
291
|
qb.withDeleted();
|
|
293
292
|
}
|
|
@@ -744,6 +743,4 @@ export class CrudHelperService {
|
|
|
744
743
|
return matchingPermssions.length > 0
|
|
745
744
|
}
|
|
746
745
|
|
|
747
|
-
|
|
748
|
-
|
|
749
746
|
}
|
|
@@ -5,8 +5,8 @@ import { EntityManager } from 'typeorm';
|
|
|
5
5
|
|
|
6
6
|
import { CRUDService } from 'src/services/crud.service';
|
|
7
7
|
|
|
8
|
-
|
|
9
|
-
import { classify
|
|
8
|
+
import { kebabCase } from 'lodash';
|
|
9
|
+
import { classify } from '../helpers/string.helper';
|
|
10
10
|
import { InstanceWrapper } from '@nestjs/core/injector/instance-wrapper';
|
|
11
11
|
import { validate } from 'class-validator';
|
|
12
12
|
import { BasicFilterDto } from 'src/dtos/basic-filters.dto';
|
|
@@ -196,7 +196,7 @@ export class ExportTransactionService extends CRUDService<ExportTransaction> {
|
|
|
196
196
|
|
|
197
197
|
private getFileName(templateName: string, exportTransactionUUID: string, fileFormat: string): string {
|
|
198
198
|
const extension = (fileFormat === ExportFormat.EXCEL) ? 'xlsx' : 'csv';
|
|
199
|
-
return `${
|
|
199
|
+
return `${kebabCase(templateName)}-${exportTransactionUUID}.${extension}`;
|
|
200
200
|
}
|
|
201
201
|
|
|
202
202
|
private getMimeType(fileFormat: string): string {
|
|
@@ -237,7 +237,6 @@ export class ExportTransactionService extends CRUDService<ExportTransaction> {
|
|
|
237
237
|
}
|
|
238
238
|
}
|
|
239
239
|
|
|
240
|
-
|
|
241
240
|
return async (chunkIndex: number, chunkSize: number) => {
|
|
242
241
|
const offset = chunkIndex * chunkSize;
|
|
243
242
|
const recordFilterDto: BasicFilterDto = {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { classify } from '
|
|
1
|
+
import { classify } from '../helpers/string.helper';
|
|
2
2
|
import { Injectable, Logger, NotFoundException, OnApplicationBootstrap } from '@nestjs/common';
|
|
3
3
|
import { InjectDataSource } from '@nestjs/typeorm';
|
|
4
4
|
import * as fs from 'fs/promises'; // Use the Promise-based version of fs for async/await
|
|
@@ -21,7 +21,6 @@ import { MediaStorageProviderMetadataRepository } from 'src/repository/media-sto
|
|
|
21
21
|
import { S3FileService } from './file';
|
|
22
22
|
import { MediaStorageProviderMetadata } from 'src/entities/media-storage-provider-metadata.entity';
|
|
23
23
|
|
|
24
|
-
|
|
25
24
|
@Injectable()
|
|
26
25
|
export class FieldMetadataService implements OnApplicationBootstrap {
|
|
27
26
|
constructor(
|
|
@@ -806,7 +805,6 @@ export class FieldMetadataService implements OnApplicationBootstrap {
|
|
|
806
805
|
"columnName"
|
|
807
806
|
];
|
|
808
807
|
|
|
809
|
-
|
|
810
808
|
case SolidFieldType.json:
|
|
811
809
|
return [
|
|
812
810
|
"name",
|
|
@@ -1194,7 +1192,6 @@ export class FieldMetadataService implements OnApplicationBootstrap {
|
|
|
1194
1192
|
const parsedFormValues = typeof formValues === 'string' ? qs.parse(formValues, { allowDots: true }) : formValues;
|
|
1195
1193
|
selectionDynamicProviderCtxt['formValues'] = parsedFormValues;
|
|
1196
1194
|
|
|
1197
|
-
|
|
1198
1195
|
// 3. get hold of the provider instance from the SolidRegistry
|
|
1199
1196
|
const selectionProviderInstance = this.solidRegistry.getSelectionProviderInstance(selectionDynamicProvider);
|
|
1200
1197
|
if (!selectionProviderInstance) {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Injectable, Logger } from "@nestjs/common";
|
|
2
2
|
import { SolidIntrospectService } from "./solid-introspect.service";
|
|
3
3
|
import { ModuleMetadataHelperService } from "src/helpers/module-metadata-helper.service";
|
|
4
|
-
import { classify } from
|
|
4
|
+
import { classify } from '../helpers/string.helper';
|
|
5
5
|
|
|
6
6
|
interface ScenarioFixture {
|
|
7
7
|
name: string;
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import { Injectable, Logger } from '@nestjs/common';
|
|
2
2
|
|
|
3
|
-
import { classify } from '
|
|
3
|
+
import { classify } from '../../../helpers/string.helper';
|
|
4
4
|
import { IMcpToolResponseHandler } from 'src/interfaces';
|
|
5
5
|
import { SolidIntrospectService } from '../../solid-introspect.service';
|
|
6
6
|
|
|
7
|
-
|
|
8
7
|
@Injectable()
|
|
9
8
|
export class McpHandlerFactory {
|
|
10
9
|
private readonly logger = new Logger(McpHandlerFactory.name);
|
|
@@ -6,7 +6,6 @@ import { EntityManager } from 'typeorm';
|
|
|
6
6
|
import { CRUDService } from 'src/services/crud.service';
|
|
7
7
|
|
|
8
8
|
|
|
9
|
-
import { classify } from '@angular-devkit/core/src/utils/strings';
|
|
10
9
|
import { HttpService } from '@nestjs/axios';
|
|
11
10
|
import { ERROR_MESSAGES } from 'src/constants/error-messages';
|
|
12
11
|
import { RelationFieldsCommand, RelationType, SolidFieldType } from 'src/dtos/create-field-metadata.dto';
|
|
@@ -27,6 +26,7 @@ import { ModelMetadataHelperService } from 'src/helpers/model-metadata-helper.se
|
|
|
27
26
|
import { getUserExcludedFields } from 'src/helpers/user-helper';
|
|
28
27
|
import { ActiveUserData } from 'src/interfaces/active-user-data.interface';
|
|
29
28
|
import {upperFirst, camelCase} from 'lodash';
|
|
29
|
+
import { classify } from '../helpers/string.helper';
|
|
30
30
|
|
|
31
31
|
interface ImportTemplateFileInfo {
|
|
32
32
|
stream: NodeJS.ReadableStream;
|