@solidxai/core 0.1.11-beta.0 → 0.1.11-beta.1
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/repository/scheduled-job.repository.d.ts +3 -0
- package/dist/repository/scheduled-job.repository.d.ts.map +1 -1
- package/dist/repository/scheduled-job.repository.js +60 -0
- package/dist/repository/scheduled-job.repository.js.map +1 -1
- package/dist/seeders/module-metadata-seeder.service.d.ts +32 -1
- package/dist/seeders/module-metadata-seeder.service.d.ts.map +1 -1
- package/dist/seeders/module-metadata-seeder.service.js +1011 -230
- package/dist/seeders/module-metadata-seeder.service.js.map +1 -1
- package/dist/services/action-metadata.service.d.ts +7 -0
- package/dist/services/action-metadata.service.d.ts.map +1 -1
- package/dist/services/action-metadata.service.js +76 -3
- package/dist/services/action-metadata.service.js.map +1 -1
- package/dist/services/role-metadata.service.d.ts +4 -0
- package/dist/services/role-metadata.service.d.ts.map +1 -1
- package/dist/services/role-metadata.service.js +72 -31
- package/dist/services/role-metadata.service.js.map +1 -1
- package/dist/services/view-metadata.service.d.ts +6 -0
- package/dist/services/view-metadata.service.d.ts.map +1 -1
- package/dist/services/view-metadata.service.js +66 -1
- package/dist/services/view-metadata.service.js.map +1 -1
- package/dist-tests/api/authenticate.spec.js +119 -0
- package/dist-tests/api/authenticate.spec.js.map +1 -0
- package/dist-tests/api/crud-service.findOne.cityMaster.spec.js +97 -0
- package/dist-tests/api/crud-service.findOne.cityMaster.spec.js.map +1 -0
- package/dist-tests/api/ping.spec.js +21 -0
- package/dist-tests/api/ping.spec.js.map +1 -0
- package/dist-tests/helpers/auth.js +41 -0
- package/dist-tests/helpers/auth.js.map +1 -0
- package/dist-tests/helpers/env.js +11 -0
- package/dist-tests/helpers/env.js.map +1 -0
- package/docs/agent-hub-grooming.md +301 -0
- package/docs/dashboards/AGENTIC_DASHBOARD_IMPLEMENTATION_PLAN.md +438 -0
- package/docs/dashboards/dashboard-curl-smoke-tests.txt +146 -0
- package/docs/dashboards/delete-legacy-dashboard-metadata.sql +172 -0
- package/docs/datasource-introspection-ddl-analysis.md +326 -0
- package/docs/datasource-introspection-implementation-plan.md +306 -0
- package/docs/grouping-enhancements.md +89 -0
- package/docs/java-spring/README.md +3 -0
- package/docs/java-spring/solid-core-module-deep-dive-report.md +1317 -0
- package/docs/module-package-import-handoff.md +691 -0
- package/docs/seed-changes.md +65 -0
- package/docs/test-data-workflow.md +200 -0
- package/docs/type-declaration-import-issue.md +24 -0
- package/package.json +1 -1
- package/src/repository/scheduled-job.repository.ts +73 -0
- package/src/seeders/module-metadata-seeder.service.ts +1223 -262
- package/src/services/action-metadata.service.ts +87 -2
- package/src/services/role-metadata.service.ts +86 -47
- package/src/services/view-metadata.service.ts +79 -1
- package/.claude/settings.local.json +0 -15
- package/src/services/1.js +0 -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;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,sBAA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,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;AAhcY,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,CAgc/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 const collectionViewTypes = ['card', 'list', 'kanban', 'tree'];\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: collectionViewTypes })\n .getMany();\n\n const canonicalActionsByViewType = new Map();\n for (const actionItem of actionsForViewModes) {\n const resolvedViewType = actionItem.view?.type;\n if (!resolvedViewType || canonicalActionsByViewType.has(resolvedViewType)) {\n continue;\n }\n canonicalActionsByViewType.set(resolvedViewType, actionItem);\n }\n\n if (action?.view?.type && collectionViewTypes.includes(action.view.type) && action?.id) {\n canonicalActionsByViewType.set(action.view.type, action);\n }\n\n viewModes = collectionViewTypes\n .map((resolvedViewType) => canonicalActionsByViewType.get(resolvedViewType))\n .filter(Boolean)\n .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"]}
|
|
1
|
+
{"version":3,"file":"view-metadata.service.js","sourceRoot":"","sources":["../../src/services/view-metadata.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,2CAA6F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0B;QACnD,gBAAS;GArFpB,mBAAmB,CA8gB/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 private readonly comparableFields = [\n 'name',\n 'displayName',\n 'type',\n 'context',\n 'layout',\n 'module',\n 'model',\n ] as const;\n private readonly relationCompareFields = new Set(['module', 'model']);\n private readonly jsonCompareFields = new Set(['layout', 'context']);\n\n private normalizeJsonFieldValue(value: any): any {\n if (typeof value === 'string') {\n const trimmedValue = value.trim();\n if (\n (trimmedValue.startsWith('{') && trimmedValue.endsWith('}')) ||\n (trimmedValue.startsWith('[') && trimmedValue.endsWith(']'))\n ) {\n try {\n return this.normalizeJsonFieldValue(JSON.parse(trimmedValue));\n } catch {\n return value;\n }\n }\n return value;\n }\n\n if (Array.isArray(value)) {\n return value.map((item) => this.normalizeJsonFieldValue(item));\n }\n\n if (value && typeof value === 'object') {\n return Object.keys(value)\n .sort()\n .reduce((result, key) => {\n result[key] = this.normalizeJsonFieldValue(value[key]);\n return result;\n }, {} as Record<string, any>);\n }\n\n return value;\n }\n\n private getCanonicalJsonFieldString(value: any): string {\n return JSON.stringify(this.normalizeJsonFieldValue(value) ?? null);\n }\n\n private hasChanges(existingSolidView: ViewMetadata, updateSolidViewDto: UpdateViewMetadataDto): boolean {\n return this.comparableFields.some((key) => {\n const value = (updateSolidViewDto as any)[key];\n if (typeof value === 'undefined') {\n return false;\n }\n\n if (this.relationCompareFields.has(key)) {\n const relationValue = value as any;\n return (existingSolidView as any)[key]?.id !== relationValue?.id;\n }\n\n if (this.jsonCompareFields.has(key)) {\n return this.getCanonicalJsonFieldString((existingSolidView as any)[key]) !== this.getCanonicalJsonFieldString(value);\n }\n\n return (existingSolidView as any)[key] !== value;\n });\n }\n\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 const collectionViewTypes = ['card', 'list', 'kanban', 'tree'];\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: collectionViewTypes })\n .getMany();\n\n const canonicalActionsByViewType = new Map();\n for (const actionItem of actionsForViewModes) {\n const resolvedViewType = actionItem.view?.type;\n if (!resolvedViewType || canonicalActionsByViewType.has(resolvedViewType)) {\n continue;\n }\n canonicalActionsByViewType.set(resolvedViewType, actionItem);\n }\n\n if (action?.view?.type && collectionViewTypes.includes(action.view.type) && action?.id) {\n canonicalActionsByViewType.set(action.view.type, action);\n }\n\n viewModes = collectionViewTypes\n .map((resolvedViewType) => canonicalActionsByViewType.get(resolvedViewType))\n .filter(Boolean)\n .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 module: true,\n model: true,\n });\n\n // if found\n if (existingSolidView) {\n const hasChanges = this.hasChanges(existingSolidView, updateSolidViewDto);\n\n if (!hasChanges) {\n this.logger.debug(`Skipping view upsert for ${updateSolidViewDto.name}; no changes detected.`);\n return existingSolidView;\n }\n\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"]}
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const test_1 = require("@playwright/test");
|
|
4
|
+
const env_1 = require("../helpers/env");
|
|
5
|
+
const baseURL = process.env.API_BASE_URL ?? "http://localhost:3000";
|
|
6
|
+
const TEST_USER_EMAIL = (0, env_1.getRequiredEnv)("TEST_USER_EMAIL");
|
|
7
|
+
const TEST_USER_PASSWORD = (0, env_1.getRequiredEnv)("TEST_USER_PASSWORD");
|
|
8
|
+
function base64UrlDecode(input) {
|
|
9
|
+
const normalized = input.replace(/-/g, "+").replace(/_/g, "/");
|
|
10
|
+
const padded = normalized.length % 4 === 0
|
|
11
|
+
? normalized
|
|
12
|
+
: normalized.padEnd(normalized.length + (4 - (normalized.length % 4)), "=");
|
|
13
|
+
return Buffer.from(padded, "base64").toString("utf-8");
|
|
14
|
+
}
|
|
15
|
+
function validateJwt(token) {
|
|
16
|
+
const parts = token.split(".");
|
|
17
|
+
if (parts.length !== 3) {
|
|
18
|
+
throw new Error("JWT must have three dot-separated parts.");
|
|
19
|
+
}
|
|
20
|
+
const headerJson = JSON.parse(base64UrlDecode(parts[0]));
|
|
21
|
+
const payloadJson = JSON.parse(base64UrlDecode(parts[1]));
|
|
22
|
+
if (!headerJson || typeof headerJson !== "object") {
|
|
23
|
+
throw new Error("JWT header must be a JSON object.");
|
|
24
|
+
}
|
|
25
|
+
if (!payloadJson || typeof payloadJson !== "object") {
|
|
26
|
+
throw new Error("JWT payload must be a JSON object.");
|
|
27
|
+
}
|
|
28
|
+
if (typeof payloadJson.exp !== "number") {
|
|
29
|
+
throw new Error("JWT payload.exp must be a number.");
|
|
30
|
+
}
|
|
31
|
+
return payloadJson;
|
|
32
|
+
}
|
|
33
|
+
(0, test_1.test)("API: authenticate succeeds with valid credentials", async () => {
|
|
34
|
+
const api = await test_1.request.newContext({
|
|
35
|
+
baseURL,
|
|
36
|
+
extraHTTPHeaders: {
|
|
37
|
+
accept: "*/*",
|
|
38
|
+
"content-type": "application/json",
|
|
39
|
+
},
|
|
40
|
+
});
|
|
41
|
+
try {
|
|
42
|
+
const res = await api.post("/api/iam/authenticate", {
|
|
43
|
+
data: {
|
|
44
|
+
email: TEST_USER_EMAIL,
|
|
45
|
+
username: "",
|
|
46
|
+
password: TEST_USER_PASSWORD,
|
|
47
|
+
},
|
|
48
|
+
});
|
|
49
|
+
(0, test_1.expect)(res.status()).toBe(200);
|
|
50
|
+
const json = await res.json();
|
|
51
|
+
(0, test_1.expect)(json.statusCode).toBe(200);
|
|
52
|
+
(0, test_1.expect)(Array.isArray(json.message)).toBe(true);
|
|
53
|
+
(0, test_1.expect)(json.message.length).toBe(0);
|
|
54
|
+
(0, test_1.expect)(json.error).toBe("");
|
|
55
|
+
const user = json.data?.user;
|
|
56
|
+
(0, test_1.expect)(user, "Expected data.user to be an object.").toBeTruthy();
|
|
57
|
+
(0, test_1.expect)(typeof user).toBe("object");
|
|
58
|
+
const email = user?.email;
|
|
59
|
+
(0, test_1.expect)(typeof email).toBe("string");
|
|
60
|
+
if (email === TEST_USER_EMAIL) {
|
|
61
|
+
(0, test_1.expect)(email).toBe(TEST_USER_EMAIL);
|
|
62
|
+
}
|
|
63
|
+
else {
|
|
64
|
+
(0, test_1.expect)(email.length).toBeGreaterThan(0);
|
|
65
|
+
}
|
|
66
|
+
(0, test_1.expect)(typeof user?.mobile).toBe("string");
|
|
67
|
+
(0, test_1.expect)(typeof user?.username).toBe("string");
|
|
68
|
+
(0, test_1.expect)(typeof user?.forcePasswordChange).toBe("boolean");
|
|
69
|
+
(0, test_1.expect)(typeof user?.id).toBe("number");
|
|
70
|
+
const roles = user?.roles;
|
|
71
|
+
(0, test_1.expect)(Array.isArray(roles)).toBe(true);
|
|
72
|
+
if (Array.isArray(roles)) {
|
|
73
|
+
(0, test_1.expect)(roles.every((role) => typeof role === "string")).toBe(true);
|
|
74
|
+
(0, test_1.expect)(roles).toContain("Admin");
|
|
75
|
+
}
|
|
76
|
+
const accessToken = json.data?.accessToken;
|
|
77
|
+
const refreshToken = json.data?.refreshToken;
|
|
78
|
+
(0, test_1.expect)(typeof accessToken).toBe("string");
|
|
79
|
+
(0, test_1.expect)(typeof refreshToken).toBe("string");
|
|
80
|
+
const accessPayload = validateJwt(accessToken);
|
|
81
|
+
const refreshPayload = validateJwt(refreshToken);
|
|
82
|
+
(0, test_1.expect)(typeof accessPayload.exp).toBe("number");
|
|
83
|
+
(0, test_1.expect)(typeof refreshPayload.exp).toBe("number");
|
|
84
|
+
}
|
|
85
|
+
finally {
|
|
86
|
+
await api.dispose();
|
|
87
|
+
}
|
|
88
|
+
});
|
|
89
|
+
(0, test_1.test)("API: authenticate fails with wrong password", async () => {
|
|
90
|
+
const api = await test_1.request.newContext({
|
|
91
|
+
baseURL,
|
|
92
|
+
extraHTTPHeaders: {
|
|
93
|
+
accept: "*/*",
|
|
94
|
+
"content-type": "application/json",
|
|
95
|
+
},
|
|
96
|
+
});
|
|
97
|
+
try {
|
|
98
|
+
const res = await api.post("/api/iam/authenticate", {
|
|
99
|
+
data: {
|
|
100
|
+
email: TEST_USER_EMAIL,
|
|
101
|
+
username: "",
|
|
102
|
+
password: `${TEST_USER_PASSWORD}__wrong`,
|
|
103
|
+
},
|
|
104
|
+
});
|
|
105
|
+
(0, test_1.expect)(res.status()).toBe(401);
|
|
106
|
+
const json = await res.json();
|
|
107
|
+
(0, test_1.expect)(json.statusCode).toBe(401);
|
|
108
|
+
(0, test_1.expect)(json.statusCodeMessage).toBe("Unauthorized");
|
|
109
|
+
(0, test_1.expect)(json.message).toBe("Invalid credentials");
|
|
110
|
+
(0, test_1.expect)(json.error).toBe("Invalid credentials");
|
|
111
|
+
(0, test_1.expect)(json.data?.statusCode).toBe(401);
|
|
112
|
+
(0, test_1.expect)(json.data?.error).toBe("Unauthorized");
|
|
113
|
+
(0, test_1.expect)(json.data?.message).toBe("Invalid credentials");
|
|
114
|
+
}
|
|
115
|
+
finally {
|
|
116
|
+
await api.dispose();
|
|
117
|
+
}
|
|
118
|
+
});
|
|
119
|
+
//# sourceMappingURL=authenticate.spec.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"authenticate.spec.js","sourceRoot":"","sources":["../../tests/api/authenticate.spec.ts"],"names":[],"mappings":";;AAAA,2CAAyD;AACzD,wCAAgD;AAOhD,MAAM,OAAO,GAAG,OAAO,CAAC,GAAG,CAAC,YAAY,IAAI,uBAAuB,CAAC;AACpE,MAAM,eAAe,GAAG,IAAA,oBAAc,EAAC,iBAAiB,CAAC,CAAC;AAC1D,MAAM,kBAAkB,GAAG,IAAA,oBAAc,EAAC,oBAAoB,CAAC,CAAC;AAEhE,SAAS,eAAe,CAAC,KAAa;IACpC,MAAM,UAAU,GAAG,KAAK,CAAC,OAAO,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC,OAAO,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC;IAC/D,MAAM,MAAM,GACV,UAAU,CAAC,MAAM,GAAG,CAAC,KAAK,CAAC;QACzB,CAAC,CAAC,UAAU;QACZ,CAAC,CAAC,UAAU,C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CAAC,qBAAqB,CAAC,CAAC;QACjD,IAAA,aAAM,EAAC,IAAI,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,qBAAqB,CAAC,CAAC;QAC/C,IAAA,aAAM,EAAC,IAAI,CAAC,IAAI,EAAE,UAAU,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QACxC,IAAA,aAAM,EAAC,IAAI,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC;QAC9C,IAAA,aAAM,EAAC,IAAI,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC,IAAI,CAAC,qBAAqB,CAAC,CAAC;IACzD,CAAC;YAAS,CAAC;QACT,MAAM,GAAG,CAAC,OAAO,EAAE,CAAC;IACtB,CAAC;AACH,CAAC,CAAC,CAAC","sourcesContent":["import { expect, request, test } from \"@playwright/test\";\nimport { getRequiredEnv } from \"../helpers/env\";\n\ntype JwtPayload = {\n exp?: number;\n [key: string]: unknown;\n};\n\nconst baseURL = process.env.API_BASE_URL ?? \"http://localhost:3000\";\nconst TEST_USER_EMAIL = getRequiredEnv(\"TEST_USER_EMAIL\");\nconst TEST_USER_PASSWORD = getRequiredEnv(\"TEST_USER_PASSWORD\");\n\nfunction base64UrlDecode(input: string): string {\n const normalized = input.replace(/-/g, \"+\").replace(/_/g, \"/\");\n const padded =\n normalized.length % 4 === 0\n ? normalized\n : normalized.padEnd(\n normalized.length + (4 - (normalized.length % 4)),\n \"=\"\n );\n return Buffer.from(padded, \"base64\").toString(\"utf-8\");\n}\n\nfunction validateJwt(token: string): JwtPayload {\n const parts = token.split(\".\");\n if (parts.length !== 3) {\n throw new Error(\"JWT must have three dot-separated parts.\");\n }\n\n const headerJson = JSON.parse(base64UrlDecode(parts[0]));\n const payloadJson = JSON.parse(base64UrlDecode(parts[1]));\n\n if (!headerJson || typeof headerJson !== \"object\") {\n throw new Error(\"JWT header must be a JSON object.\");\n }\n\n if (!payloadJson || typeof payloadJson !== \"object\") {\n throw new Error(\"JWT payload must be a JSON object.\");\n }\n\n if (typeof payloadJson.exp !== \"number\") {\n throw new Error(\"JWT payload.exp must be a number.\");\n }\n\n return payloadJson as JwtPayload;\n}\n\ntest(\"API: authenticate succeeds with valid credentials\", async () => {\n const api = await request.newContext({\n baseURL,\n extraHTTPHeaders: {\n accept: \"*/*\",\n \"content-type\": \"application/json\",\n },\n });\n\n try {\n const res = await api.post(\"/api/iam/authenticate\", {\n data: {\n email: TEST_USER_EMAIL,\n username: \"\",\n password: TEST_USER_PASSWORD,\n },\n });\n\n expect(res.status()).toBe(200);\n const json = await res.json();\n\n expect(json.statusCode).toBe(200);\n expect(Array.isArray(json.message)).toBe(true);\n expect(json.message.length).toBe(0);\n expect(json.error).toBe(\"\");\n\n const user = json.data?.user as Record<string, unknown> | undefined;\n expect(user, \"Expected data.user to be an object.\").toBeTruthy();\n expect(typeof user).toBe(\"object\");\n\n const email = user?.email;\n expect(typeof email).toBe(\"string\");\n if (email === TEST_USER_EMAIL) {\n expect(email).toBe(TEST_USER_EMAIL);\n } else {\n // If your API returns a fixed system email, replace this with an exact match.\n expect((email as string).length).toBeGreaterThan(0);\n }\n\n expect(typeof user?.mobile).toBe(\"string\");\n expect(typeof user?.username).toBe(\"string\");\n expect(typeof user?.forcePasswordChange).toBe(\"boolean\");\n expect(typeof user?.id).toBe(\"number\");\n\n const roles = user?.roles;\n expect(Array.isArray(roles)).toBe(true);\n if (Array.isArray(roles)) {\n expect(roles.every((role) => typeof role === \"string\")).toBe(true);\n expect(roles).toContain(\"Admin\");\n }\n\n const accessToken = json.data?.accessToken;\n const refreshToken = json.data?.refreshToken;\n expect(typeof accessToken).toBe(\"string\");\n expect(typeof refreshToken).toBe(\"string\");\n\n const accessPayload = validateJwt(accessToken as string);\n const refreshPayload = validateJwt(refreshToken as string);\n\n expect(typeof accessPayload.exp).toBe(\"number\");\n expect(typeof refreshPayload.exp).toBe(\"number\");\n } finally {\n await api.dispose();\n }\n});\n\ntest(\"API: authenticate fails with wrong password\", async () => {\n const api = await request.newContext({\n baseURL,\n extraHTTPHeaders: {\n accept: \"*/*\",\n \"content-type\": \"application/json\",\n },\n });\n\n try {\n const res = await api.post(\"/api/iam/authenticate\", {\n data: {\n email: TEST_USER_EMAIL,\n username: \"\",\n password: `${TEST_USER_PASSWORD}__wrong`,\n },\n });\n\n expect(res.status()).toBe(401);\n const json = await res.json();\n\n expect(json.statusCode).toBe(401);\n expect(json.statusCodeMessage).toBe(\"Unauthorized\");\n expect(json.message).toBe(\"Invalid credentials\");\n expect(json.error).toBe(\"Invalid credentials\");\n expect(json.data?.statusCode).toBe(401);\n expect(json.data?.error).toBe(\"Unauthorized\");\n expect(json.data?.message).toBe(\"Invalid credentials\");\n } finally {\n await api.dispose();\n }\n});\n"]}
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const test_1 = require("@playwright/test");
|
|
4
|
+
const auth_1 = require("../helpers/auth");
|
|
5
|
+
const baseURL = process.env.API_BASE_URL ?? "http://localhost:3000";
|
|
6
|
+
async function getCityByName(name) {
|
|
7
|
+
const api = await test_1.request.newContext({
|
|
8
|
+
baseURL,
|
|
9
|
+
extraHTTPHeaders: await (0, auth_1.getAuthHeaders)(baseURL),
|
|
10
|
+
});
|
|
11
|
+
try {
|
|
12
|
+
const res = await api.get(`/api/city-master?filters[name][$eq]=${encodeURIComponent(name)}&limit=1&offset=0`);
|
|
13
|
+
(0, test_1.expect)(res.status()).toBe(200);
|
|
14
|
+
const json = await res.json();
|
|
15
|
+
const record = json?.data?.records?.[0];
|
|
16
|
+
(0, test_1.expect)(record, `Expected city '${name}' in testData`).toBeTruthy();
|
|
17
|
+
(0, test_1.expect)(record.id, "Expected record to have id").toBeTruthy();
|
|
18
|
+
return record;
|
|
19
|
+
}
|
|
20
|
+
finally {
|
|
21
|
+
await api.dispose();
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
test_1.test.describe("CRUDService.findOne (cityMaster)", () => {
|
|
25
|
+
(0, test_1.test)("returns a city by id", async () => {
|
|
26
|
+
const city = await getCityByName("Mumbai");
|
|
27
|
+
const api = await test_1.request.newContext({
|
|
28
|
+
baseURL,
|
|
29
|
+
extraHTTPHeaders: await (0, auth_1.getAuthHeaders)(baseURL),
|
|
30
|
+
});
|
|
31
|
+
try {
|
|
32
|
+
const res = await api.get(`/api/city-master/${city.id}`);
|
|
33
|
+
(0, test_1.expect)(res.status()).toBe(200);
|
|
34
|
+
const json = await res.json();
|
|
35
|
+
(0, test_1.expect)(json?.data?.id).toBe(city.id);
|
|
36
|
+
(0, test_1.expect)(json?.data?.name).toBe("Mumbai");
|
|
37
|
+
(0, test_1.expect)(json?.data?.description).toBe("Mumbai city");
|
|
38
|
+
}
|
|
39
|
+
finally {
|
|
40
|
+
await api.dispose();
|
|
41
|
+
}
|
|
42
|
+
});
|
|
43
|
+
(0, test_1.test)("supports fields[] selection", async () => {
|
|
44
|
+
const city = await getCityByName("Pune");
|
|
45
|
+
const api = await test_1.request.newContext({
|
|
46
|
+
baseURL,
|
|
47
|
+
extraHTTPHeaders: await (0, auth_1.getAuthHeaders)(baseURL),
|
|
48
|
+
});
|
|
49
|
+
try {
|
|
50
|
+
const res = await api.get(`/api/city-master/${city.id}?fields[]=id&fields[]=name`);
|
|
51
|
+
(0, test_1.expect)(res.status()).toBe(200);
|
|
52
|
+
const json = await res.json();
|
|
53
|
+
(0, test_1.expect)(json?.data?.id).toBe(city.id);
|
|
54
|
+
(0, test_1.expect)(json?.data?.name).toBe("Pune");
|
|
55
|
+
(0, test_1.expect)(json?.data?.description).toBeUndefined();
|
|
56
|
+
(0, test_1.expect)(json?.data?.state).toBeUndefined();
|
|
57
|
+
}
|
|
58
|
+
finally {
|
|
59
|
+
await api.dispose();
|
|
60
|
+
}
|
|
61
|
+
});
|
|
62
|
+
(0, test_1.test)("supports populate=state", async () => {
|
|
63
|
+
const city = await getCityByName("Bengaluru");
|
|
64
|
+
const api = await test_1.request.newContext({
|
|
65
|
+
baseURL,
|
|
66
|
+
extraHTTPHeaders: await (0, auth_1.getAuthHeaders)(baseURL),
|
|
67
|
+
});
|
|
68
|
+
try {
|
|
69
|
+
const res = await api.get(`/api/city-master/${city.id}?populate=state`);
|
|
70
|
+
(0, test_1.expect)(res.status()).toBe(200);
|
|
71
|
+
const json = await res.json();
|
|
72
|
+
(0, test_1.expect)(json?.data?.name).toBe("Bengaluru");
|
|
73
|
+
(0, test_1.expect)(json?.data?.state).toBeTruthy();
|
|
74
|
+
(0, test_1.expect)(json?.data?.state?.name).toBe("Karnataka");
|
|
75
|
+
}
|
|
76
|
+
finally {
|
|
77
|
+
await api.dispose();
|
|
78
|
+
}
|
|
79
|
+
});
|
|
80
|
+
(0, test_1.test)("returns 404 for missing id", async () => {
|
|
81
|
+
const api = await test_1.request.newContext({
|
|
82
|
+
baseURL,
|
|
83
|
+
extraHTTPHeaders: await (0, auth_1.getAuthHeaders)(baseURL),
|
|
84
|
+
});
|
|
85
|
+
try {
|
|
86
|
+
const res = await api.get(`/api/city-master/99999999`);
|
|
87
|
+
(0, test_1.expect)(res.status()).toBe(404);
|
|
88
|
+
const json = await res.json();
|
|
89
|
+
(0, test_1.expect)(String(json?.message)).toContain("cityMaster");
|
|
90
|
+
(0, test_1.expect)(String(json?.message)).toContain("not found");
|
|
91
|
+
}
|
|
92
|
+
finally {
|
|
93
|
+
await api.dispose();
|
|
94
|
+
}
|
|
95
|
+
});
|
|
96
|
+
});
|
|
97
|
+
//# sourceMappingURL=crud-service.findOne.cityMaster.spec.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"crud-service.findOne.cityMaster.spec.js","sourceRoot":"","sources":["../../tests/api/crud-service.findOne.cityMaster.spec.ts"],"names":[],"mappings":";;AAAA,2CAAyD;AACzD,0CAAiD;AAEjD,MAAM,OAAO,GAAG,OAAO,CAAC,GAAG,CAAC,YAAY,IAAI,uBAAuB,C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E,CAAC;QACtB,CAAC;IACH,CAAC,CAAC,CAAC;IAEH,IAAA,WAAI,EAAC,4BAA4B,EAAE,KAAK,IAAI,EAAE;QAC5C,MAAM,GAAG,GAAG,MAAM,cAAO,CAAC,UAAU,CAAC;YACnC,OAAO;YACP,gBAAgB,EAAE,MAAM,IAAA,qBAAc,EAAC,OAAO,CAAC;SAChD,CAAC,CAAC;QACH,IAAI,CAAC;YACH,MAAM,GAAG,GAAG,MAAM,GAAG,CAAC,GAAG,CAAC,2BAA2B,CAAC,CAAC;YACvD,IAAA,aAAM,EAAC,GAAG,CAAC,MAAM,EAAE,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;YAE/B,MAAM,IAAI,GAAG,MAAM,GAAG,CAAC,IAAI,EAAE,CAAC;YAC9B,IAAA,aAAM,EAAC,MAAM,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC,CAAC,SAAS,CAAC,YAAY,CAAC,CAAC;YACtD,IAAA,aAAM,EAAC,MAAM,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC,CAAC,SAAS,CAAC,WAAW,CAAC,CAAC;QACvD,CAAC;gBAAS,CAAC;YACT,MAAM,GAAG,CAAC,OAAO,EAAE,CAAC;QACtB,CAAC;IACH,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["import { expect, request, test } from \"@playwright/test\";\nimport { getAuthHeaders } from \"../helpers/auth\";\n\nconst baseURL = process.env.API_BASE_URL ?? \"http://localhost:3000\";\n\nasync function getCityByName(name: string) {\n const api = await request.newContext({\n baseURL,\n extraHTTPHeaders: await getAuthHeaders(baseURL),\n });\n try {\n const res = await api.get(\n `/api/city-master?filters[name][$eq]=${encodeURIComponent(name)}&limit=1&offset=0`\n );\n expect(res.status()).toBe(200);\n const json = await res.json();\n\n const record = json?.data?.records?.[0];\n expect(record, `Expected city '${name}' in testData`).toBeTruthy();\n expect(record.id, \"Expected record to have id\").toBeTruthy();\n\n return record;\n } finally {\n await api.dispose();\n }\n}\n\ntest.describe(\"CRUDService.findOne (cityMaster)\", () => {\n test(\"returns a city by id\", async () => {\n const city = await getCityByName(\"Mumbai\");\n\n const api = await request.newContext({\n baseURL,\n extraHTTPHeaders: await getAuthHeaders(baseURL),\n });\n try {\n const res = await api.get(`/api/city-master/${city.id}`);\n expect(res.status()).toBe(200);\n\n const json = await res.json();\n expect(json?.data?.id).toBe(city.id);\n expect(json?.data?.name).toBe(\"Mumbai\");\n expect(json?.data?.description).toBe(\"Mumbai city\");\n } finally {\n await api.dispose();\n }\n });\n\n test(\"supports fields[] selection\", async () => {\n const city = await getCityByName(\"Pune\");\n\n const api = await request.newContext({\n baseURL,\n extraHTTPHeaders: await getAuthHeaders(baseURL),\n });\n try {\n const res = await api.get(\n `/api/city-master/${city.id}?fields[]=id&fields[]=name`\n );\n expect(res.status()).toBe(200);\n\n const json = await res.json();\n expect(json?.data?.id).toBe(city.id);\n expect(json?.data?.name).toBe(\"Pune\");\n expect(json?.data?.description).toBeUndefined();\n expect(json?.data?.state).toBeUndefined();\n } finally {\n await api.dispose();\n }\n });\n\n test(\"supports populate=state\", async () => {\n const city = await getCityByName(\"Bengaluru\");\n\n const api = await request.newContext({\n baseURL,\n extraHTTPHeaders: await getAuthHeaders(baseURL),\n });\n try {\n const res = await api.get(`/api/city-master/${city.id}?populate=state`);\n expect(res.status()).toBe(200);\n\n const json = await res.json();\n expect(json?.data?.name).toBe(\"Bengaluru\");\n expect(json?.data?.state).toBeTruthy();\n expect(json?.data?.state?.name).toBe(\"Karnataka\");\n } finally {\n await api.dispose();\n }\n });\n\n test(\"returns 404 for missing id\", async () => {\n const api = await request.newContext({\n baseURL,\n extraHTTPHeaders: await getAuthHeaders(baseURL),\n });\n try {\n const res = await api.get(`/api/city-master/99999999`);\n expect(res.status()).toBe(404);\n\n const json = await res.json();\n expect(String(json?.message)).toContain(\"cityMaster\");\n expect(String(json?.message)).toContain(\"not found\");\n } finally {\n await api.dispose();\n }\n });\n});\n"]}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const test_1 = require("@playwright/test");
|
|
4
|
+
(0, test_1.test)("GET /api/ping returns pong", async () => {
|
|
5
|
+
const baseURL = process.env.BASE_URL || "http://localhost:3000";
|
|
6
|
+
if (!baseURL) {
|
|
7
|
+
throw new Error("baseURL is not configured. Set API_BASE_URL or use the default.");
|
|
8
|
+
}
|
|
9
|
+
const api = await test_1.request.newContext({ baseURL });
|
|
10
|
+
const res = await api.get("/api/ping");
|
|
11
|
+
(0, test_1.expect)(res.status()).toBe(200);
|
|
12
|
+
const body = await res.json();
|
|
13
|
+
(0, test_1.expect)(body).toEqual({
|
|
14
|
+
statusCode: 200,
|
|
15
|
+
message: [],
|
|
16
|
+
error: "",
|
|
17
|
+
data: { pong: "v1.0.2" },
|
|
18
|
+
});
|
|
19
|
+
await api.dispose();
|
|
20
|
+
});
|
|
21
|
+
//# sourceMappingURL=ping.spec.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ping.spec.js","sourceRoot":"","sources":["../../tests/api/ping.spec.ts"],"names":[],"mappings":";;AAAA,2CAAyD;AAEzD,IAAA,WAAI,EAAC,4BAA4B,EAAE,KAAK,IAAI,EAAE;IAC5C,MAAM,OAAO,GAAG,OAAO,CAAC,GAAG,CAAC,QAAQ,IAAI,uBAAuB,CAAC;IAChE,IAAI,CAAC,OAAO,EAAE,CAAC;QACb,MAAM,IAAI,KAAK,CAAC,iEAAiE,CAAC,CAAC;IACrF,CAAC;IACD,MAAM,GAAG,GAAG,MAAM,cAAO,CAAC,UAAU,CAAC,EAAE,OAAO,EAAE,CAAC,CAAC;IAElD,MAAM,GAAG,GAAG,MAAM,GAAG,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC;IAEvC,IAAA,aAAM,EAAC,GAAG,CAAC,MAAM,EAAE,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IAE/B,MAAM,IAAI,GAAG,MAAM,GAAG,CAAC,IAAI,EAAE,CAAC;IAC9B,IAAA,aAAM,EAAC,IAAI,CAAC,CAAC,OAAO,CAAC;QACnB,UAAU,EAAE,GAAG;QACf,OAAO,EAAE,EAAE;QACX,KAAK,EAAE,EAAE;QACT,IAAI,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;KACzB,CAAC,CAAC;IAEH,MAAM,GAAG,CAAC,OAAO,EAAE,CAAC;AACtB,CAAC,CAAC,CAAC","sourcesContent":["import { expect, request, test } from \"@playwright/test\";\n\ntest(\"GET /api/ping returns pong\", async () => {\n const baseURL = process.env.BASE_URL || \"http://localhost:3000\";\n if (!baseURL) {\n throw new Error(\"baseURL is not configured. Set API_BASE_URL or use the default.\");\n }\n const api = await request.newContext({ baseURL });\n\n const res = await api.get(\"/api/ping\");\n\n expect(res.status()).toBe(200);\n\n const body = await res.json();\n expect(body).toEqual({\n statusCode: 200,\n message: [],\n error: \"\",\n data: { pong: \"v1.0.2\" },\n });\n\n await api.dispose();\n});\n"]}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getAccessToken = getAccessToken;
|
|
4
|
+
exports.getAuthHeaders = getAuthHeaders;
|
|
5
|
+
const test_1 = require("@playwright/test");
|
|
6
|
+
const env_1 = require("./env");
|
|
7
|
+
async function getAccessToken(baseURL) {
|
|
8
|
+
const TEST_USER_EMAIL = (0, env_1.getRequiredEnv)("TEST_USER_EMAIL");
|
|
9
|
+
const TEST_USER_PASSWORD = (0, env_1.getRequiredEnv)("TEST_USER_PASSWORD");
|
|
10
|
+
const api = await test_1.request.newContext({
|
|
11
|
+
baseURL,
|
|
12
|
+
extraHTTPHeaders: {
|
|
13
|
+
accept: "*/*",
|
|
14
|
+
"content-type": "application/json",
|
|
15
|
+
},
|
|
16
|
+
});
|
|
17
|
+
try {
|
|
18
|
+
const res = await api.post("/api/iam/authenticate", {
|
|
19
|
+
data: {
|
|
20
|
+
email: TEST_USER_EMAIL,
|
|
21
|
+
username: "",
|
|
22
|
+
password: TEST_USER_PASSWORD,
|
|
23
|
+
},
|
|
24
|
+
});
|
|
25
|
+
(0, test_1.expect)(res.status()).toBe(200);
|
|
26
|
+
const json = await res.json();
|
|
27
|
+
const token = json?.data?.accessToken;
|
|
28
|
+
(0, test_1.expect)(token, "Expected access token from authenticate endpoint.").toBeTruthy();
|
|
29
|
+
return token;
|
|
30
|
+
}
|
|
31
|
+
finally {
|
|
32
|
+
await api.dispose();
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
async function getAuthHeaders(baseURL) {
|
|
36
|
+
const token = await getAccessToken(baseURL);
|
|
37
|
+
return {
|
|
38
|
+
authorization: `Bearer ${token}`,
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
//# sourceMappingURL=auth.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auth.js","sourceRoot":"","sources":["../../tests/helpers/auth.ts"],"names":[],"mappings":";;AAGA,wCA6BC;AAED,wCAKC;AAvCD,2CAAmD;AACnD,+BAAuC;AAEhC,KAAK,UAAU,cAAc,CAAC,OAAe;IAClD,MAAM,eAAe,GAAG,IAAA,oBAAc,EAAC,iBAAiB,CAAC,CAAC;IAC1D,MAAM,kBAAkB,GAAG,IAAA,oBAAc,EAAC,oBAAoB,CAAC,CAAC;IAEhE,MAAM,GAAG,GAAG,MAAM,cAAO,CAAC,UAAU,CAAC;QACnC,OAAO;QACP,gBAAgB,EAAE;YAChB,MAAM,EAAE,KAAK;YACb,cAAc,EAAE,kBAAkB;SACnC;KACF,CAAC,CAAC;IAEH,IAAI,CAAC;QACH,MAAM,GAAG,GAAG,MAAM,GAAG,CAAC,IAAI,CAAC,uBAAuB,EAAE;YAClD,IAAI,EAAE;gBACJ,KAAK,EAAE,eAAe;gBACtB,QAAQ,EAAE,EAAE;gBACZ,QAAQ,EAAE,kBAAkB;aAC7B;SACF,CAAC,CAAC;QAEH,IAAA,aAAM,EAAC,GAAG,CAAC,MAAM,EAAE,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QAC/B,MAAM,IAAI,GAAG,MAAM,GAAG,CAAC,IAAI,EAAE,CAAC;QAC9B,MAAM,KAAK,GAAG,IAAI,EAAE,IAAI,EAAE,WAAiC,CAAC;QAC5D,IAAA,aAAM,EAAC,KAAK,EAAE,mDAAmD,CAAC,CAAC,UAAU,EAAE,CAAC;QAChF,OAAO,KAAe,CAAC;IACzB,CAAC;YAAS,CAAC;QACT,MAAM,GAAG,CAAC,OAAO,EAAE,CAAC;IACtB,CAAC;AACH,CAAC;AAEM,KAAK,UAAU,cAAc,CAAC,OAAe;IAClD,MAAM,KAAK,GAAG,MAAM,cAAc,CAAC,OAAO,CAAC,CAAC;IAC5C,OAAO;QACL,aAAa,EAAE,UAAU,KAAK,EAAE;KACjC,CAAC;AACJ,CAAC","sourcesContent":["import { expect, request } from \"@playwright/test\";\nimport { getRequiredEnv } from \"./env\";\n\nexport async function getAccessToken(baseURL: string) {\n const TEST_USER_EMAIL = getRequiredEnv(\"TEST_USER_EMAIL\");\n const TEST_USER_PASSWORD = getRequiredEnv(\"TEST_USER_PASSWORD\");\n\n const api = await request.newContext({\n baseURL,\n extraHTTPHeaders: {\n accept: \"*/*\",\n \"content-type\": \"application/json\",\n },\n });\n\n try {\n const res = await api.post(\"/api/iam/authenticate\", {\n data: {\n email: TEST_USER_EMAIL,\n username: \"\",\n password: TEST_USER_PASSWORD,\n },\n });\n\n expect(res.status()).toBe(200);\n const json = await res.json();\n const token = json?.data?.accessToken as string | undefined;\n expect(token, \"Expected access token from authenticate endpoint.\").toBeTruthy();\n return token as string;\n } finally {\n await api.dispose();\n }\n}\n\nexport async function getAuthHeaders(baseURL: string) {\n const token = await getAccessToken(baseURL);\n return {\n authorization: `Bearer ${token}`,\n };\n}\n"]}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getRequiredEnv = getRequiredEnv;
|
|
4
|
+
function getRequiredEnv(name) {
|
|
5
|
+
const value = process.env[name];
|
|
6
|
+
if (!value) {
|
|
7
|
+
throw new Error(`Missing required env var: ${name}`);
|
|
8
|
+
}
|
|
9
|
+
return value;
|
|
10
|
+
}
|
|
11
|
+
//# sourceMappingURL=env.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"env.js","sourceRoot":"","sources":["../../tests/helpers/env.ts"],"names":[],"mappings":";;AAAA,wCAMC;AAND,SAAgB,cAAc,CAAC,IAAY;IACzC,MAAM,KAAK,GAAG,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;IAChC,IAAI,CAAC,KAAK,EAAE,CAAC;QACX,MAAM,IAAI,KAAK,CAAC,6BAA6B,IAAI,EAAE,CAAC,CAAC;IACvD,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC","sourcesContent":["export function getRequiredEnv(name: string): string {\n const value = process.env[name];\n if (!value) {\n throw new Error(`Missing required env var: ${name}`);\n }\n return value;\n}\n"]}
|