@simitgroup/simpleapp-generator 1.6.7-m-alpha → 2.0.0-a-alpha
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/ReleaseNote.md +7 -0
- package/dist/buildinschemas/autoincreament.js +1 -1
- package/dist/buildinschemas/branch.d.ts.map +1 -1
- package/dist/buildinschemas/branch.js +2 -0
- package/dist/buildinschemas/branch.js.map +1 -1
- package/dist/buildinschemas/docnoformat.js +1 -1
- package/dist/buildinschemas/docnoformat.js.map +1 -1
- package/dist/buildinschemas/documentevent.js +1 -1
- package/dist/buildinschemas/documentnoformat.d.ts +3 -0
- package/dist/buildinschemas/documentnoformat.d.ts.map +1 -0
- package/dist/buildinschemas/documentnoformat.js +58 -0
- package/dist/buildinschemas/documentnoformat.js.map +1 -0
- package/dist/buildinschemas/index.d.ts +0 -5
- package/dist/buildinschemas/index.d.ts.map +1 -1
- package/dist/buildinschemas/index.js +5 -11
- package/dist/buildinschemas/index.js.map +1 -1
- package/dist/buildinschemas/organization.d.ts.map +1 -1
- package/dist/buildinschemas/organization.js +3 -19
- package/dist/buildinschemas/organization.js.map +1 -1
- package/dist/buildinschemas/user.d.ts.map +1 -1
- package/dist/buildinschemas/user.js +5 -2
- package/dist/buildinschemas/user.js.map +1 -1
- package/dist/generate.d.ts.map +1 -1
- package/dist/generate.js +118 -23
- package/dist/generate.js.map +1 -1
- package/dist/type.d.ts +6 -0
- package/dist/type.d.ts.map +1 -1
- package/dist/type.js.map +1 -1
- package/package.json +1 -1
- package/src/buildinschemas/{autoincreament.ts → autoincreament.ts.backup} +1 -1
- package/src/buildinschemas/branch.ts +2 -0
- package/src/buildinschemas/{documentevent.ts → documentevent.ts.backup} +1 -1
- package/src/buildinschemas/{docnoformat.ts → documentnoformat.ts.backup} +3 -3
- package/src/buildinschemas/index.ts +4 -5
- package/src/buildinschemas/organization.ts +3 -19
- package/src/buildinschemas/user.ts +5 -2
- package/src/generate.ts +128 -28
- package/src/type.ts +6 -1
- package/templates/basic/nest/api.controller.ts.eta +153 -0
- package/templates/basic/nest/api.module.ts.eta +32 -0
- package/templates/basic/nest/api.resolver.ts.eta +94 -0
- package/templates/basic/nest/api.schema.ts.eta +20 -0
- package/templates/basic/nest/api.service.ts.eta +85 -0
- package/templates/basic/nest/controller.ts.eta +18 -119
- package/templates/basic/nest/default.ts.eta +16 -10
- package/templates/basic/nest/enum.ts.eta +16 -0
- package/templates/basic/nest/model.ts.eta +6 -28
- package/templates/basic/nest/module.ts.eta +25 -0
- package/templates/basic/nest/resolver.ts.eta +12 -56
- package/templates/basic/nest/schema.ts.eta +133 -0
- package/templates/basic/nest/service.ts.eta +82 -73
- package/templates/basic/nest/service.ts.eta-backup +50 -0
- package/templates/basic/nuxt/default.ts.eta +10 -8
- package/templates/basic/nuxt/pages.[id].vue.eta +2 -2
- package/templates/basic/nuxt/pages.form.vue.eta +2 -2
- package/templates/basic/nuxt/pages.viewer.vue.eta +2 -2
- package/templates/basic/nuxt/simpleapp.doc.ts.eta +1 -1
- package/templates/basic/nuxt/simpleapp.generate.client.ts.eta +7 -5
- package/templates/nest/src/app.module.ts._eta +53 -67
- package/templates/nest/src/main.ts._eta +1 -1
- package/templates/nest/src/simple-app/.core/features/auth/api-key/api-key.service.ts.eta +29 -0
- package/templates/nest/src/simple-app/.core/features/auth/api-key/api-key.type.ts.eta +5 -0
- package/templates/nest/src/simple-app/.core/features/auth/api-key/validators/interface.ts.eta +7 -0
- package/templates/nest/src/simple-app/.core/features/auth/api-key/validators/mini-api-key.validator.ts.eta +30 -0
- package/templates/nest/src/simple-app/.core/features/auth/api-key/validators/static-api-key.validator.ts.eta +27 -0
- package/templates/nest/src/simple-app/.core/features/auth/auth.module.ts.eta +9 -0
- package/templates/nest/src/{simpleapp/generate/commons/roles → simple-app/.core/features/auth/role-guard}/roles.enum.ts.eta +7 -7
- package/templates/nest/src/{simpleapp/generate/commons/roles → simple-app/.core/features/auth/role-guard}/roles.guard.ts.eta +1 -1
- package/templates/nest/src/simple-app/.core/features/auto-increament/auto-increament.model.ts.eta +10 -0
- package/templates/nest/src/simple-app/.core/features/auto-increament/auto-increament.module.ts.eta +18 -0
- package/templates/nest/src/simple-app/.core/features/auto-increament/auto-increament.schema.ts.eta +119 -0
- package/templates/nest/src/simple-app/.core/features/auto-increament/auto-increament.service.ts.eta +65 -0
- package/templates/nest/src/simple-app/.core/features/cron/base/cron.base.ts.eta +13 -0
- package/templates/nest/src/simple-app/.core/features/cron/cron-system/cron-system.module.ts.eta +17 -0
- package/templates/nest/src/simple-app/.core/features/cron/cron-system/cron-system.service.ts.eta +37 -0
- package/templates/nest/src/simple-app/.core/features/cron/cron-system/schemas/index.ts.eta +2 -0
- package/templates/nest/src/simple-app/.core/features/cron/cron.module.ts.eta +10 -0
- package/templates/nest/src/simple-app/.core/features/document-no-format/document-no-format.controller.ts.eta +31 -0
- package/templates/nest/src/simple-app/.core/features/document-no-format/document-no-format.model.ts.eta +15 -0
- package/templates/nest/src/simple-app/.core/features/document-no-format/document-no-format.module.ts.eta +12 -0
- package/templates/nest/src/simple-app/.core/features/document-no-format/document-no-format.schema.ts.eta +162 -0
- package/templates/nest/src/simple-app/.core/features/document-no-format/document-no-format.service.ts.eta +189 -0
- package/templates/nest/src/simple-app/.core/features/event/event.module.ts.eta +9 -0
- package/templates/nest/src/simple-app/.core/features/event/event.type.ts.eta +23 -0
- package/templates/nest/src/simple-app/.core/features/event/interface/event-after-create.interface.ts.eta +5 -0
- package/templates/nest/src/simple-app/.core/features/event/interface/event-after-delete.interface.ts.eta +5 -0
- package/templates/nest/src/simple-app/.core/features/event/interface/event-after-set-status.interface.ts.eta +5 -0
- package/templates/nest/src/simple-app/.core/features/event/interface/event-after-update.interface.ts.eta +5 -0
- package/templates/nest/src/simple-app/.core/features/event/interface/event-before-create.interface.ts.eta +5 -0
- package/templates/nest/src/simple-app/.core/features/event/interface/event-before-delete.interface.ts.eta +5 -0
- package/templates/nest/src/simple-app/.core/features/event/interface/event-before-set-status.interface.ts.eta +5 -0
- package/templates/nest/src/simple-app/.core/features/event/interface/event-before-update.interface.ts.eta +5 -0
- package/templates/nest/src/simple-app/.core/features/event/interface/index.ts.eta +8 -0
- package/templates/nest/src/simple-app/.core/features/foreign-key/foreign-key.module.ts.eta +16 -0
- package/templates/nest/src/simple-app/.core/features/log/log.module.ts.eta +20 -0
- package/templates/nest/src/simple-app/.core/features/log/log.service.ts.eta +68 -0
- package/templates/nest/src/simple-app/.core/features/log/schemas/api-event.schema.ts.eta +57 -0
- package/templates/nest/src/simple-app/.core/features/log/schemas/document-event.schema.ts.eta +87 -0
- package/templates/nest/src/simple-app/.core/features/log/schemas/index.ts.eta +2 -0
- package/templates/nest/src/simple-app/.core/features/maintenance/db-update/1.00.00/index.ts._eta +39 -0
- package/templates/nest/src/simple-app/.core/features/maintenance/db-update/index.ts._eta +8 -0
- package/templates/nest/src/simple-app/.core/features/maintenance/maintenance.controller.ts.eta +84 -0
- package/templates/nest/src/simple-app/.core/features/maintenance/maintenance.module.ts.eta +19 -0
- package/templates/nest/src/simple-app/.core/features/maintenance/maintenance.service.ts.eta +86 -0
- package/templates/nest/src/simple-app/.core/features/maintenance/schemas/db-update.ts.eta +17 -0
- package/templates/nest/src/simple-app/.core/features/maintenance/schemas/environment.ts.eta +23 -0
- package/templates/nest/src/{simpleapp/generate/workflow/formschema → simple-app/.core/features/maintenance/schemas}/index.ts.eta +3 -2
- package/templates/nest/src/simple-app/.core/features/mini-app/developer-portal/developer-portal-bridge.service.ts.eta.eta +31 -0
- package/templates/nest/src/simple-app/.core/features/mini-app/developer-portal/developer-portal-env-development.service.ts.eta +124 -0
- package/templates/nest/src/simple-app/.core/features/mini-app/developer-portal/developer-portal-env-production.service.ts.eta +50 -0
- package/templates/nest/src/simple-app/.core/features/mini-app/developer-portal/developer-portal.controller.ts.eta +41 -0
- package/templates/nest/src/simple-app/.core/features/mini-app/developer-portal/developer-portal.schema.ts.eta +18 -0
- package/templates/nest/src/simple-app/.core/features/mini-app/developer-portal/developer-portal.service.ts.eta +94 -0
- package/templates/nest/src/simple-app/.core/features/mini-app/developer-portal/dto/developer-portal-create-app.dto.ts.eta +22 -0
- package/templates/nest/src/simple-app/.core/features/mini-app/developer-portal/dto/developer-portal-publish-app.dto.ts.eta +0 -0
- package/templates/nest/src/simple-app/.core/features/mini-app/dto/imports.ts.eta +2 -0
- package/templates/nest/src/simple-app/.core/features/mini-app/dto/index.ts.eta +2 -0
- package/templates/nest/src/simple-app/.core/features/mini-app/dto/mini-app.ts.eta +55 -0
- package/templates/nest/src/simple-app/.core/features/mini-app/mini-app-manager/mini-app-manager-bridge.service.ts.eta +162 -0
- package/templates/nest/src/simple-app/.core/features/mini-app/mini-app-manager/mini-app-manager-env-development.service.ts.eta +140 -0
- package/templates/nest/src/simple-app/.core/features/mini-app/mini-app-manager/mini-app-manager-env-production.service.ts.eta +125 -0
- package/templates/nest/src/simple-app/.core/features/mini-app/mini-app-manager/mini-app-manager-policy.service.ts.eta +43 -0
- package/templates/nest/src/simple-app/.core/features/mini-app/mini-app-manager/mini-app-manager.controller.ts.eta +81 -0
- package/templates/nest/src/simple-app/.core/features/mini-app/mini-app-manager/mini-app-manager.enum.ts.eta +5 -0
- package/templates/nest/src/simple-app/.core/features/mini-app/mini-app-manager/mini-app-manager.error.ts.eta +24 -0
- package/templates/nest/src/simple-app/.core/features/mini-app/mini-app-manager/mini-app-manager.processor.ts.eta +309 -0
- package/templates/nest/src/simple-app/.core/features/mini-app/mini-app-manager/mini-app-manager.service.ts.eta +346 -0
- package/templates/nest/src/simple-app/.core/features/mini-app/mini-app-scope/mini-app-scope.decorator.ts.eta +5 -0
- package/templates/nest/src/simple-app/.core/features/mini-app/mini-app-scope/mini-app-scope.guard.ts.eta +43 -0
- package/templates/nest/src/simple-app/.core/features/mini-app/mini-app-scope/mini-app-scope.service.ts.eta +101 -0
- package/templates/nest/src/simple-app/.core/features/mini-app/mini-app.module.ts.eta +24 -0
- package/templates/nest/src/simple-app/.core/features/mini-app/types/miniApp.ts.eta +23 -0
- package/templates/nest/src/simple-app/.core/features/mini-app/utils/mini-app.util.ts.eta +26 -0
- package/templates/nest/src/simple-app/.core/features/policy/policy.module.ts.eta +12 -0
- package/templates/nest/src/simple-app/.core/features/policy/policy.service.ts.eta +45 -0
- package/templates/nest/src/{simpleapp/profile/profile.controller.ts._eta → simple-app/.core/features/profile/profile.controller.ts.eta} +37 -83
- package/templates/nest/src/simple-app/.core/features/profile/profile.module.ts.eta +22 -0
- package/templates/nest/src/simple-app/.core/features/profile/profile.schema.ts.eta +165 -0
- package/templates/nest/src/{simpleapp/profile/profile.service.ts._eta → simple-app/.core/features/profile/profile.service.ts.eta} +36 -48
- package/templates/nest/src/simple-app/.core/features/queue/queue-base/queue-base.consumer.ts.eta +196 -0
- package/templates/nest/src/simple-app/.core/features/queue/queue-base/queue-base.producer.ts.eta +147 -0
- package/templates/nest/src/simple-app/.core/features/queue/queue-user-context/queue-user-context.service.ts.eta +35 -0
- package/templates/nest/src/simple-app/.core/features/queue/queue.module.ts.eta +24 -0
- package/templates/nest/src/simple-app/.core/features/queue/queue.type.ts.eta +75 -0
- package/templates/nest/src/simple-app/.core/features/simple-app-core-features.module.ts.eta +51 -0
- package/templates/nest/src/{simpleapp/generate/commons/robotuser.service.ts.eta → simple-app/.core/features/user-context/robot-user.service.ts.eta} +27 -16
- package/templates/nest/src/simple-app/.core/features/user-context/user-context.module.ts.eta +24 -0
- package/templates/nest/src/simple-app/.core/features/user-context/user-context.type.ts.eta +15 -0
- package/templates/nest/src/{simpleapp/generate/commons → simple-app/.core/features/user-context}/user.context.ts.eta +469 -449
- package/templates/nest/src/{simpleapp/generate/commons/runwebhook.service.ts.eta → simple-app/.core/features/webhook/run-webhook.service.ts.eta} +7 -11
- package/templates/nest/src/simple-app/.core/features/webhook/schemas/index.ts.eta +2 -0
- package/templates/nest/src/simple-app/.core/features/webhook/schemas/webhook-log.schema.ts.eta +116 -0
- package/templates/nest/src/simple-app/.core/features/webhook/schemas/webhook.schema.ts.eta +177 -0
- package/templates/nest/src/simple-app/.core/features/webhook/webhook.module.ts.eta +20 -0
- package/templates/nest/src/{simpleapp/generate/controllers/simpleapp.controller.ts.eta → simple-app/.core/framework/base/simple-app.controller.ts.eta} +13 -35
- package/templates/nest/src/{simpleapp/generate/processors/simpleapp.processor.ts.eta → simple-app/.core/framework/base/simple-app.service.ts.eta} +242 -139
- package/templates/nest/src/simple-app/.core/framework/custom-exception.ts.eta +26 -0
- package/templates/nest/src/simple-app/.core/framework/framework.module.ts.eta +12 -0
- package/templates/nest/src/simple-app/.core/framework/schemas/index.ts.eta +3 -0
- package/templates/nest/src/simple-app/.core/framework/schemas/others.schema.ts.eta +153 -0
- package/templates/nest/src/simple-app/.core/framework/schemas/simple-app.schema.ts.eta +172 -0
- package/templates/nest/src/{simpleapp/generate/commons/interceptors/response.interceptor.ts.eta → simple-app/.core/framework/simple-app.interceptor.ts.eta} +12 -22
- package/templates/nest/src/{simpleapp/generate/commons/middlewares/tenant.middleware.ts.eta → simple-app/.core/framework/simple-app.middleware.ts.eta} +39 -15
- package/templates/nest/src/simple-app/.core/readme.md.eta +3 -0
- package/templates/nest/src/simple-app/.core/resources/core-resources.module.ts.eta +38 -0
- package/templates/nest/src/simple-app/.core/simple-app-core.module.ts.eta +18 -0
- package/templates/nest/src/simple-app/.core/utils/dayjs.ts.eta +47 -0
- package/templates/nest/src/simple-app/.core/utils/locale-tool.ts.eta +11 -0
- package/templates/nest/src/simple-app/.core/utils/string-utils.ts.eta +1 -0
- package/templates/nest/src/simple-app/.resources/readme.md.eta +3 -0
- package/templates/nest/src/simple-app/.resources/resources.module.ts.eta +36 -0
- package/templates/nest/src/simple-app/apis/readme.md.eta +9 -0
- package/templates/nest/src/simple-app/apis/resource-api.module.ts.eta +37 -0
- package/templates/nest/src/simple-app/events/branch-event/branch-event.module.ts._eta +20 -0
- package/templates/nest/src/simple-app/events/branch-event/branch-event.service.ts._eta +43 -0
- package/templates/nest/src/simple-app/events/branch-event/branch-event.type.ts._eta +7 -0
- package/templates/nest/src/simple-app/events/events.module.ts._eta +17 -0
- package/templates/nest/src/simple-app/events/organization-event/organization-event.module.ts._eta +13 -0
- package/templates/nest/src/simple-app/events/organization-event/organization-event.service.ts._eta +52 -0
- package/templates/nest/src/simple-app/events/organization-event/organization-event.type.ts._eta +1 -0
- package/templates/nest/src/simple-app/events/permission-event/permission-event.module.ts.eta +11 -0
- package/templates/nest/src/simple-app/events/permission-event/permission-event.service.ts.eta +33 -0
- package/templates/nest/src/simple-app/events/permission-event/permission-event.type.ts.eta +1 -0
- package/templates/nest/src/simple-app/events/readme.md.eta +76 -0
- package/templates/nest/src/simple-app/events/tenant-event/tenant-event.module.ts_eta +12 -0
- package/templates/nest/src/simple-app/events/tenant-event/tenant-event.service.ts_eta +30 -0
- package/templates/nest/src/simple-app/events/tenant-event/tenant-event.type.ts_eta +1 -0
- package/templates/nest/src/{simpleapp/additional.module.ts._eta → simple-app/features/features.module.ts._eta} +8 -7
- package/templates/nest/src/{printapi/printapi.module.ts.eta → simple-app/features/print/print.module.ts.eta} +4 -4
- package/templates/nest/src/{printapi/printapi.service.ts.eta → simple-app/features/print/print.service.ts.eta} +7 -7
- package/templates/nest/src/simple-app/features/readme.md._eta +6 -0
- package/templates/nest/src/simple-app/simple-app.module.ts.eta +32 -0
- package/templates/nuxt/.env._eta +2 -0
- package/templates/nuxt/app.vue.eta +15 -7
- package/templates/nuxt/components/header/HeaderSelectBranch.vue.eta +2 -1
- package/templates/nuxt/components/image/ImageAvatar.vue._eta +63 -0
- package/templates/nuxt/components/image/ImageOrganization.vue._eta +77 -0
- package/templates/nuxt/components/simpleApp/SimpleAppForm.vue.eta +1 -1
- package/templates/nuxt/components/simpleApp/SimpleAppFormToolBar.vue._eta +95 -20
- package/templates/nuxt/components/user/UserButtonCreateTenant.vue._eta +20 -21
- package/templates/nuxt/components/user/UserTenantPicker.vue._eta +1 -1
- package/templates/nuxt/composables/docformat.generate.ts.eta +4 -2
- package/templates/nuxt/enums/enums.generate.ts.eta +1 -1
- package/templates/nuxt/middleware/30.acl.global.ts.eta +6 -6
- package/templates/nuxt/nuxt.config.ts._eta +1 -0
- package/templates/nuxt/pages/login.vue._eta +21 -15
- package/templates/nuxt/pages/profile.vue._eta +24 -32
- package/templates/nuxt/plugins/20.simpleapp-userstore.ts.eta +31 -24
- package/templates/nuxt/plugins/50.simpleapp-client.ts.eta +2 -2
- package/templates/nuxt/providers/my-provider.ts.eta +5 -6
- package/templates/nuxt/simpleapp/generate/clients/SimpleAppClient.ts.eta +1 -0
- package/templates/nuxt/simpleapp/generate/defaults/index.ts.eta +1 -1
- package/templates/nuxt/simpleapp/generate/types/index.ts.eta +1 -1
- package/templates/nuxt/types/schema.ts.eta +1 -0
- package/templates/nuxt/types/user.ts.eta +39 -38
- package/templates/project/build.sh.eta +2 -2
- package/templates/basic/nest/apischema.ts.eta +0 -96
- package/templates/basic/nest/processor.ts.eta +0 -86
- package/templates/nest/src/cloudapi/cloudapi.module.ts._eta +0 -15
- package/templates/nest/src/cloudapi/cloudapi.service.ts._eta +0 -15
- package/templates/nest/src/enums/enums.generate.ts.eta +0 -23
- package/templates/nest/src/simpleapp/apischemas/index.ts._eta +0 -85
- package/templates/nest/src/simpleapp/generate/apischemas/index.ts.eta +0 -15
- package/templates/nest/src/simpleapp/generate/apischemas/simpleapp.apischema.ts.eta +0 -62
- package/templates/nest/src/simpleapp/generate/commons/audittrail.service.ts.eta +0 -52
- package/templates/nest/src/simpleapp/generate/commons/customkeycloa.guard.ts.eta +0 -45
- package/templates/nest/src/simpleapp/generate/commons/docnogenerator.service.ts.eta +0 -129
- package/templates/nest/src/simpleapp/generate/commons/providers/workflow.provider.ts.etax +0 -87
- package/templates/nest/src/simpleapp/generate/jsonschemas/index.ts.eta +0 -11
- package/templates/nest/src/simpleapp/generate/models/apievent.model.ts.eta +0 -27
- package/templates/nest/src/simpleapp/generate/processors/autoinc.processor.ts.eta +0 -88
- package/templates/nest/src/simpleapp/generate/processors/branch.processor.ts.eta +0 -110
- package/templates/nest/src/simpleapp/generate/processors/docno.processor.ts.eta +0 -77
- package/templates/nest/src/simpleapp/generate/processors/org.processor.ts.eta +0 -110
- package/templates/nest/src/simpleapp/generate/processors/perm.processor.ts.eta +0 -71
- package/templates/nest/src/simpleapp/generate/processors/sysmsg.processor.ts.eta +0 -49
- package/templates/nest/src/simpleapp/generate/processors/tenant.processor.ts.eta +0 -52
- package/templates/nest/src/simpleapp/generate/processors/webhooklog.processor.ts.eta +0 -45
- package/templates/nest/src/simpleapp/generate/types/index.ts.eta +0 -7
- package/templates/nest/src/simpleapp/generate/types/schema.type.ts.eta +0 -193
- package/templates/nest/src/simpleapp/generate/types/simpleapp.type.ts.eta +0 -299
- package/templates/nest/src/simpleapp/generate/types/workflow.type.ts.eta +0 -15
- package/templates/nest/src/simpleapp/generate/workflow/formschema/SimpleApproveReject.ts.eta +0 -8
- package/templates/nest/src/simpleapp/generate/workflow/workflow.apischema.ts.eta +0 -136
- package/templates/nest/src/simpleapp/generate/workflow/workflow.config.ts.eta +0 -79
- package/templates/nest/src/simpleapp/generate/workflow/workflow.controller.ts.eta +0 -414
- package/templates/nest/src/simpleapp/generate/workflow/workflow.delegate.ts.eta +0 -201
- package/templates/nest/src/simpleapp/generate/workflow/workflow.service.ts.eta +0 -641
- package/templates/nest/src/simpleapp/generate/workflow/workflow.type.ts.eta +0 -98
- package/templates/nest/src/simpleapp/generate/workflow/workflow.userservice.ts.eta +0 -83
- package/templates/nest/src/simpleapp/profile/profile.apischema.ts._eta +0 -95
- package/templates/nest/src/simpleapp/resolvers/readme.md.eta +0 -1
- package/templates/nest/src/simpleapp/services/autoinc.service.ts.etaxx +0 -59
- package/templates/nest/src/simpleapp/services/branch.service.ts.etaxxx +0 -83
- package/templates/nest/src/simpleapp/services/docno.service.ts.etaxxx +0 -59
- package/templates/nest/src/simpleapp/services/org.service.ts.etaxxx +0 -37
- package/templates/nest/src/simpleapp/services/perm.service.ts.etaxxx +0 -56
- package/templates/nest/src/simpleapp/services/sysmsg.service.ts._etaxxx +0 -43
- package/templates/nest/src/simpleapp/services/tenant.service.ts.etaxxx +0 -38
- package/templates/nest/src/simpleapp/services/user.service.ts.eta.old +0 -118
- package/templates/nest/src/simpleapp/services/userresolver.service.ts._eta +0 -67
- package/templates/nest/src/simpleapp/services/webhook.service.ts._eta +0 -37
- package/templates/nest/src/simpleapp/simpleapp.module.ts.eta +0 -80
- package/templates/nest/src/simpleapp/types/index.ts._eta +0 -45
- package/templates/nest/src/simpleapp/webhooks/branch.ts._eta +0 -44
- package/templates/nest/src/simpleapp/webhooks/index.ts._eta +0 -21
- package/templates/nest/src/simpleapp/workflows/bpmn/readme.md._eta +0 -1
- package/templates/nest/src/simpleapp/workflows/listeners/simpleapp.listener.ts.eta +0 -31
- package/templates/nest/src/simpleapp/workflows/readme.md._eta +0 -1
- package/templates/nuxt/components/image/ImageAvatar.vue.eta +0 -56
- package/templates/nuxt/components/image/ImageOrganization.vue.eta +0 -66
- /package/src/buildinschemas/{webhook.ts → webhook.ts.backup} +0 -0
- /package/src/buildinschemas/{webhooklog.ts → webhooklog.ts.backup} +0 -0
- /package/templates/basic/nest/{type.ts.eta → type.ts.eta-backup} +0 -0
- /package/templates/nest/src/{simpleapp/generate/commons/customkeycloak.guard.ts.eta → simple-app/.core/features/auth/keycloak/keycloak.guard.ts.eta} +0 -0
- /package/templates/nest/src/{simpleapp/generate/commons/roles → simple-app/.core/features/auth/role-guard}/roles.decorator.ts.eta +0 -0
- /package/templates/nest/src/{simpleapp/generate/commons/roles → simple-app/.core/features/auth/role-guard}/roles.group.ts.eta +0 -0
- /package/templates/nest/src/{simpleapp/generate/commons/dicts/documents.ts.eta → simple-app/.core/features/document-no-format/document.dict.ts.eta} +0 -0
- /package/templates/nest/src/{simpleapp/generate/commons/dicts/foreignkeys.ts.eta → simple-app/.core/features/foreign-key/foreignkeys.dict.ts.eta} +0 -0
- /package/templates/nest/src/{simpleapp/profile/profile.types.ts.eta → simple-app/.core/features/profile/profile.types.ts.eta-backup} +0 -0
- /package/templates/nest/src/{simpleapp/generate/commons/decorators → simple-app/.core/features/user-context}/appuser.decorator.ts.eta +0 -0
- /package/templates/nest/src/{simpleapp/generate/commons/exceptions/SimpleAppExceptionFilter.ts.eta → simple-app/.core/framework/exception-filter.ts.eta} +0 -0
- /package/templates/nest/src/{simpleapp/generate/commons → simple-app/.core/utils}/encryption.static.ts.eta +0 -0
- /package/templates/nest/src/{simpleapp → simple-app}/.gitignore.eta +0 -0
- /package/templates/nest/src/{printapi → simple-app/features/print}/api/.gitignore.eta +0 -0
- /package/templates/nest/src/{printapi → simple-app/features/print}/api/.npmignore.eta +0 -0
- /package/templates/nest/src/{printapi → simple-app/features/print}/api/.openapi-generator/FILES.eta +0 -0
- /package/templates/nest/src/{printapi → simple-app/features/print}/api/.openapi-generator/VERSION.eta +0 -0
- /package/templates/nest/src/{printapi → simple-app/features/print}/api/.openapi-generator-ignore.eta +0 -0
- /package/templates/nest/src/{printapi → simple-app/features/print}/api/api.ts.eta +0 -0
- /package/templates/nest/src/{printapi → simple-app/features/print}/api/base.ts.eta +0 -0
- /package/templates/nest/src/{printapi → simple-app/features/print}/api/common.ts.eta +0 -0
- /package/templates/nest/src/{printapi → simple-app/features/print}/api/configuration.ts.eta +0 -0
- /package/templates/nest/src/{printapi → simple-app/features/print}/api/git_push.sh.eta +0 -0
- /package/templates/nest/src/{printapi → simple-app/features/print}/api/index.ts.eta +0 -0
- /package/templates/nest/src/{printapi → simple-app/features/print}/api/openapitools.json.eta +0 -0
- /package/templates/project/{sharelibs → share-libs}/hello.ts._eta +0 -0
- /package/templates/project/{sharelibs → share-libs}/index.ts.eta +0 -0
- /package/templates/project/{sharelibs → share-libs}/money.ts.eta +0 -0
- /package/templates/project/{sharelibs → share-libs}/validate.ts.eta +0 -0
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { Injectable } from '@nestjs/common';
|
|
2
|
+
import _ from 'lodash';
|
|
3
|
+
import { MiniAppStatusEnum } from 'src/simple-app/.core/resources/mini-app/mini-app.enum';
|
|
4
|
+
import { PolicyService } from 'src/simple-app/.core/features/policy/policy.service';
|
|
5
|
+
import { Role } from 'src/simple-app/.core/features/auth/role-guard/roles.enum';
|
|
6
|
+
import { UserContext } from 'src/simple-app/.core/features/user-context/user.context';
|
|
7
|
+
import { MiniApp } from '../dto';
|
|
8
|
+
|
|
9
|
+
@Injectable()
|
|
10
|
+
export class MiniAppManagerPolicyService {
|
|
11
|
+
readonly _RELEASED_STATUSES = [MiniAppStatusEnum.PUBLISHED];
|
|
12
|
+
|
|
13
|
+
constructor(private readonly policyService: PolicyService) {}
|
|
14
|
+
|
|
15
|
+
canInstall(appUser: UserContext) {
|
|
16
|
+
return this.policyService.can(appUser, Role.MiniAppInstallation_create);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
canUninstall(appUser: UserContext) {
|
|
20
|
+
return this.policyService.can(appUser, Role.MiniAppInstallation_update);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
canUpdateSetting(appUser: UserContext) {
|
|
24
|
+
return this.policyService.can(appUser, Role.MiniAppInstallation_update);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
hasFeature(appUser: UserContext) {
|
|
28
|
+
return this.policyService.hasFeature(appUser, 'miniApp');
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
hasRequiredPlan(appUser: UserContext, miniApp: MiniApp) {
|
|
32
|
+
const currentPlan = appUser.getPackage();
|
|
33
|
+
const requiredPlans = miniApp.access.requiredPlans ?? [];
|
|
34
|
+
|
|
35
|
+
if (_.isEmpty(requiredPlans)) return true;
|
|
36
|
+
|
|
37
|
+
return requiredPlans.includes(currentPlan);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
isMiniAppRealeased(status: MiniAppStatusEnum) {
|
|
41
|
+
return this._RELEASED_STATUSES.includes(status);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { Body, Controller, Get, Param, Post, Put } from '@nestjs/common';
|
|
2
|
+
import { ApiTags, ApiBody, ApiResponse, ApiOperation } from '@nestjs/swagger';
|
|
3
|
+
|
|
4
|
+
import { AppUser } from 'src/simple-app/.core/features/user-context/appuser.decorator';
|
|
5
|
+
import { Roles } from 'src/simple-app/.core/features/auth/role-guard/roles.decorator';
|
|
6
|
+
import { Role } from 'src/simple-app/.core/features/auth/role-guard/roles.enum';
|
|
7
|
+
import { UserContext } from 'src/simple-app/.core/features/user-context/user.context';
|
|
8
|
+
|
|
9
|
+
import * as schemas from '../dto';
|
|
10
|
+
import { MiniAppManagerBridgeService } from './mini-app-manager-bridge.service';
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
@ApiTags('MINIAPPMANAGER')
|
|
14
|
+
@Controller('mini-app-manager')
|
|
15
|
+
export class MiniAppManagerController {
|
|
16
|
+
constructor(private readonly service: MiniAppManagerBridgeService) {}
|
|
17
|
+
|
|
18
|
+
@Put('mini-apps/:miniAppCode/install')
|
|
19
|
+
@Roles(Role.SuperAdmin, Role.SuperUser, Role.User)
|
|
20
|
+
@ApiResponse({ status: 200, description: 'Install a miniApp', type: schemas.MiniAppInstallation })
|
|
21
|
+
@ApiOperation({ operationId: 'runInstallMiniApp' })
|
|
22
|
+
async installMiniApp(@AppUser() appUser: UserContext, @Param('miniAppCode') miniAppCode: string) {
|
|
23
|
+
const res = await this.service.runInstallMiniApp(appUser, miniAppCode);
|
|
24
|
+
return res;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
@Put('mini-apps/:miniAppCode/uninstall')
|
|
28
|
+
@Roles(Role.SuperAdmin, Role.SuperUser, Role.User)
|
|
29
|
+
@ApiResponse({ status: 200, description: 'Uninstall a miniApp', type: schemas.MiniAppInstallation })
|
|
30
|
+
@ApiOperation({ operationId: 'runUninstallMiniApp' })
|
|
31
|
+
async uninstallMiniApp(@AppUser() appUser: UserContext, @Param('miniAppCode') miniAppCode: string) {
|
|
32
|
+
const res = await this.service.runUninstallMiniApp(appUser, miniAppCode);
|
|
33
|
+
return res;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
@Put('mini-apps/:miniAppCode/update-setting')
|
|
37
|
+
@Roles(Role.SuperAdmin, Role.SuperUser, Role.User)
|
|
38
|
+
@ApiBody({ description: 'Request Body', type: schemas.DynamicParam })
|
|
39
|
+
@ApiResponse({ status: 200, description: 'Update miniApp setting', type: schemas.MiniAppInstallation })
|
|
40
|
+
@ApiOperation({ operationId: 'runUpdateMiniAppSetting' })
|
|
41
|
+
async updateMiniAppSetting(@AppUser() appUser: UserContext, @Body() data: schemas.DynamicParam, @Param('miniAppCode') miniAppCode: string) {
|
|
42
|
+
const res = await this.service.runUpdateMiniAppSetting(appUser, miniAppCode, data);
|
|
43
|
+
return res;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
@Get('installed-mini-apps')
|
|
47
|
+
@Roles(Role.SuperAdmin, Role.SuperUser, Role.User)
|
|
48
|
+
@ApiResponse({ status: 200, description: 'Get installed miniApps', type: schemas.InstalledMiniAppDetail })
|
|
49
|
+
@ApiOperation({ operationId: 'runGetInstalledMiniApps' })
|
|
50
|
+
async getInstalledMiniApps(@AppUser() appUser: UserContext) {
|
|
51
|
+
const res = await this.service.runGetInstalledMiniApps(appUser);
|
|
52
|
+
return res;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
@Get('categorized-mini-apps')
|
|
56
|
+
@Roles(Role.SuperAdmin, Role.SuperUser, Role.User)
|
|
57
|
+
@ApiResponse({ status: 200, description: 'Get categorized miniApps', type: schemas.CategorizedMiniAppDetail })
|
|
58
|
+
@ApiOperation({ operationId: 'runGetCategorizedMiniApps' })
|
|
59
|
+
async getCategorizedMiniApps(@AppUser() appUser: UserContext) {
|
|
60
|
+
const res = await this.service.runGetCategorizedMiniApps(appUser);
|
|
61
|
+
return res;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
@Get('mini-apps/:miniAppCode')
|
|
65
|
+
@Roles(Role.SuperAdmin, Role.SuperUser, Role.User)
|
|
66
|
+
@ApiResponse({ status: 200, description: 'Get miniApp detail', type: schemas.MiniAppDetail })
|
|
67
|
+
@ApiOperation({ operationId: 'runGetMiniAppDetail' })
|
|
68
|
+
async getMiniAppDetail(@AppUser() appUser: UserContext, @Param('miniAppCode') miniAppCode: string) {
|
|
69
|
+
const res = await this.service.runGetMiniAppDetail(appUser, miniAppCode);
|
|
70
|
+
return res;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
@Post('system-default-mini-apps-migration')
|
|
74
|
+
@Roles(Role.Everyone)
|
|
75
|
+
@ApiResponse({ status: 200, description: 'Migrate system default miniApp.', type: [schemas.MiniApp] })
|
|
76
|
+
@ApiOperation({ operationId: 'runSystemDefaultMiniAppMigration' })
|
|
77
|
+
async systemDefaultMiniAppMigration(@AppUser() appUser: UserContext) {
|
|
78
|
+
const res = await this.service.runSystemDefaultMiniAppMigration(appUser);
|
|
79
|
+
return res;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
export class MiniAppError {
|
|
2
|
+
static readonly ERR = {
|
|
3
|
+
NO_FEATURE: "Mini App isn't available in your current plan. Upgrade to unlock this feature.",
|
|
4
|
+
NOT_FOUND: 'Mini App not found.',
|
|
5
|
+
NOT_RELEASED: 'Mini App not yet released. Current Status: {status}.',
|
|
6
|
+
INSTALLATION_NOT_FOUND: 'Mini App is not installed.',
|
|
7
|
+
ALREADY_INSTALLED: 'Mini App is already installed.',
|
|
8
|
+
NOT_INSTALLED: 'Mini App is not yet installed.',
|
|
9
|
+
PLAN_REQUIRED: '"{miniAppName}" requires a higher-tier plan: [{requiredPlans}]. Please upgrade to unlock this feature.',
|
|
10
|
+
PRIVATE_APP: "This is private app, you don't have permission to perform this action",
|
|
11
|
+
UNKNOWN_ENV: 'Unknown Env',
|
|
12
|
+
MINI_APP_CODE_DUPLICATE: 'Duplicated Mini App code',
|
|
13
|
+
UNDEFINED_DEMO_COMPANY: 'Undefined Demo Company',
|
|
14
|
+
INVALID_CODE_EMPTY: 'Code Empty',
|
|
15
|
+
INVALID_CODE_SUFFIX: 'Code name must not end with "_dev".',
|
|
16
|
+
INVALID_CODE_PATTERN: 'Code name must contain only letters, numbers, and underscores.',
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
static format(message: string, replacements?: Record<string, string>) {
|
|
20
|
+
if (!replacements) return message;
|
|
21
|
+
|
|
22
|
+
return Object.entries(replacements).reduce((msg, [key, value]) => msg.replace(`{${key}}`, value), message);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
@@ -0,0 +1,309 @@
|
|
|
1
|
+
import { UserContext } from 'src/simple-app/.core/features/user-context/user.context';
|
|
2
|
+
import { MiniAppService } from 'src/simple-app/.core/resources/mini-app/mini-app.service';
|
|
3
|
+
import { MiniAppInstallationService } from 'src/simple-app/.core/resources/mini-app-installation/mini-app-installation.service';
|
|
4
|
+
import { MiniAppManagerPolicyService } from './mini-app-manager-policy.service';
|
|
5
|
+
import _ from 'lodash';
|
|
6
|
+
import { BadRequestException, NotFoundException } from '@nestjs/common';
|
|
7
|
+
import { MiniAppError } from './mini-app-manager.error';
|
|
8
|
+
import { MiniAppEnvEnum, MiniAppStatusEnum } from 'src/simple-app/.core/resources/mini-app/mini-app.enum';
|
|
9
|
+
import { DynamicParam,MiniApp,MiniAppInstallation, CategorizedMiniAppDetail, InstalledMiniAppDetail, MiniAppDetail } from '../dto';
|
|
10
|
+
import { InjectModel } from '@nestjs/mongoose';
|
|
11
|
+
import { Model } from 'mongoose';
|
|
12
|
+
|
|
13
|
+
export abstract class MiniAppManagerProcessor {
|
|
14
|
+
constructor(
|
|
15
|
+
protected readonly miniAppService: MiniAppService,
|
|
16
|
+
protected readonly miniAppInstallationService: MiniAppInstallationService,
|
|
17
|
+
protected readonly policyService: MiniAppManagerPolicyService,
|
|
18
|
+
@InjectModel('MiniApp')
|
|
19
|
+
private miniAppDoc: Model<MiniApp>,
|
|
20
|
+
) {}
|
|
21
|
+
|
|
22
|
+
// ========================================= Abstract =========================================
|
|
23
|
+
|
|
24
|
+
abstract runGetInstalledMiniApps(appUser: UserContext): Promise<InstalledMiniAppDetail>;
|
|
25
|
+
abstract runGetMiniAppDetail(appUser: UserContext, miniApp: MiniApp): Promise<MiniAppDetail>;
|
|
26
|
+
abstract runGetCategorizedMiniApps(appUser: UserContext): Promise<CategorizedMiniAppDetail>;
|
|
27
|
+
abstract runInstallMiniApp(appUser: UserContext, miniApp: MiniApp): Promise<MiniAppInstallation>;
|
|
28
|
+
abstract runUninstallMiniApp(appUser: UserContext, miniApp: MiniApp): Promise<MiniAppInstallation>;
|
|
29
|
+
abstract runUpdateMiniAppSetting(appUser: UserContext, miniApp: MiniApp, data: DynamicParam): Promise<MiniAppInstallation>;
|
|
30
|
+
|
|
31
|
+
// ========================================== Action ==========================================
|
|
32
|
+
|
|
33
|
+
protected async findInstalledMiniAppsDetail(appUser: UserContext) {
|
|
34
|
+
const permissions = this.resolveMiniAppPermissions(appUser);
|
|
35
|
+
const { miniAppInstallations, installedMiniAppIdArr } = await this.findInstalledMiniAppIds(appUser);
|
|
36
|
+
const miniApps = await this.miniAppService.search(appUser, {
|
|
37
|
+
_id: { $in: installedMiniAppIdArr },
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
const installedMiniApps = miniAppInstallations
|
|
41
|
+
.map((installation) => {
|
|
42
|
+
const miniApp = miniApps.find((miniApp) => miniApp._id === installation.miniApp._id);
|
|
43
|
+
if (!miniApp) {
|
|
44
|
+
return null;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
return this.formatMiniAppDetail(appUser, miniApp, installation);
|
|
48
|
+
})
|
|
49
|
+
.filter(Boolean);
|
|
50
|
+
|
|
51
|
+
return { installedMiniApps: installedMiniApps, permissions };
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
protected async findMiniAppDetail(appUser: UserContext, miniApp: MiniApp) {
|
|
55
|
+
const miniAppInstallation = await this.findMiniAppInstallation(appUser, miniApp.code);
|
|
56
|
+
return this.formatMiniAppDetail(appUser, miniApp, miniAppInstallation);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
protected categorizedMiniApps(appUser: UserContext, miniApps: MiniApp[]): CategorizedMiniAppDetail {
|
|
60
|
+
const result = {
|
|
61
|
+
upcomingMiniApps: [],
|
|
62
|
+
availableMiniApps: [],
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
miniApps.forEach((miniApp) => {
|
|
66
|
+
if (miniApp.status === MiniAppStatusEnum.UPCOMING) {
|
|
67
|
+
result.upcomingMiniApps.push(this.formatMiniAppDetail(appUser, miniApp));
|
|
68
|
+
} else {
|
|
69
|
+
if (miniApp.access.visibility === 'private') {
|
|
70
|
+
if (!(miniApp.access.allowEmails ?? []).includes(appUser.getEmail())) {
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
result.availableMiniApps.push(this.formatMiniAppDetail(appUser, miniApp));
|
|
76
|
+
}
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
return result;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
protected async install(appUser: UserContext, miniApp: MiniApp) {
|
|
83
|
+
const miniAppInstallation = await this.findMiniAppInstallation(appUser, miniApp.code);
|
|
84
|
+
if (!miniAppInstallation) {
|
|
85
|
+
// Not Found Installation Record, Create New One
|
|
86
|
+
return await this.createMiniAppInstallation(appUser, miniApp);
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
if (miniAppInstallation.isActive) {
|
|
90
|
+
// Found Installation Record, And It Is Activated
|
|
91
|
+
const msg = MiniAppError.format(MiniAppError.ERR.ALREADY_INSTALLED);
|
|
92
|
+
throw new BadRequestException(msg);
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
// Found Installation Record, And It Is Deactive, Reactivate It
|
|
96
|
+
return await this.reactivateInstalledMiniApp(appUser, miniAppInstallation);
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
protected async uninstall(appUser: UserContext, miniApp: MiniApp) {
|
|
100
|
+
const miniAppInstallation = await this.findIsMiniAppInstalledOrFail(appUser, miniApp.code);
|
|
101
|
+
return await this.deactiveInstalledMiniApp(appUser, miniAppInstallation);
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
protected async updateSetting(appUser: UserContext, miniApp: MiniApp, data: DynamicParam) {
|
|
105
|
+
const miniAppInstallation = await this.findIsMiniAppInstalledOrFail(appUser, miniApp.code);
|
|
106
|
+
return await this.setMiniAppInstallationSetting(appUser, miniAppInstallation, data);
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
// ========================================== Finder ==========================================
|
|
110
|
+
|
|
111
|
+
protected async findMiniAppInstallation(appUser: UserContext, miniAppCode: string): Promise<MiniAppInstallation | undefined> {
|
|
112
|
+
const miniAppInstallations = await this.miniAppInstallationService.search(appUser, {
|
|
113
|
+
'miniApp.code': miniAppCode,
|
|
114
|
+
});
|
|
115
|
+
|
|
116
|
+
return miniAppInstallations?.[0];
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
protected async findMiniAppInstallations(appUser: UserContext) {
|
|
120
|
+
const miniAppInstallations = await this.miniAppInstallationService.search(
|
|
121
|
+
appUser,
|
|
122
|
+
{
|
|
123
|
+
isActive: true,
|
|
124
|
+
},
|
|
125
|
+
undefined,
|
|
126
|
+
{
|
|
127
|
+
seqNo: 1,
|
|
128
|
+
},
|
|
129
|
+
);
|
|
130
|
+
|
|
131
|
+
return miniAppInstallations;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
protected async findMiniAppInstallationOrFail(appUser: UserContext, miniAppCode: string) {
|
|
135
|
+
const miniAppInstallation = await this.findMiniAppInstallation(appUser, miniAppCode);
|
|
136
|
+
if (!miniAppInstallation) {
|
|
137
|
+
const msg = MiniAppError.format(MiniAppError.ERR.NOT_INSTALLED);
|
|
138
|
+
throw new NotFoundException(msg);
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
return miniAppInstallation;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
protected async findIsMiniAppInstalledOrFail(appUser: UserContext, miniAppCode: string) {
|
|
145
|
+
const miniAppInstallation = await this.findMiniAppInstallationOrFail(appUser, miniAppCode);
|
|
146
|
+
if (!miniAppInstallation.isActive) {
|
|
147
|
+
// Already inactive, previously already uninstall
|
|
148
|
+
const msg = MiniAppError.format(MiniAppError.ERR.NOT_INSTALLED);
|
|
149
|
+
throw new NotFoundException(msg);
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
return miniAppInstallation;
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
protected async findInstalledMiniAppIds(appUser: UserContext) {
|
|
156
|
+
const miniAppInstallations = await this.findMiniAppInstallations(appUser);
|
|
157
|
+
const installedMiniAppIdArr = miniAppInstallations.map((inst) => inst.miniApp._id);
|
|
158
|
+
|
|
159
|
+
return {
|
|
160
|
+
miniAppInstallations,
|
|
161
|
+
installedMiniAppIdArr,
|
|
162
|
+
};
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
// ========================================== Assert ==========================================
|
|
166
|
+
|
|
167
|
+
protected assertHasMiniAppFeature(appUser: UserContext) {
|
|
168
|
+
if (!this.policyService.hasFeature(appUser)) {
|
|
169
|
+
const msg = MiniAppError.format(MiniAppError.ERR.NO_FEATURE);
|
|
170
|
+
throw new BadRequestException(msg);
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
protected assertIsMiniAppReleased(miniApp: MiniApp) {
|
|
175
|
+
if (!this.policyService.isMiniAppRealeased(miniApp.status as MiniAppStatusEnum)) {
|
|
176
|
+
const msg = MiniAppError.format(MiniAppError.ERR.NOT_RELEASED, { status: miniApp.status });
|
|
177
|
+
throw new BadRequestException(msg);
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
protected assertHasRequiredPlan(appUser: UserContext, miniApp: MiniApp) {
|
|
182
|
+
if (!this.policyService.hasRequiredPlan(appUser, miniApp)) {
|
|
183
|
+
const msg = MiniAppError.format(MiniAppError.ERR.PLAN_REQUIRED, { miniAppName: miniApp.name, requiredPlans: miniApp.access.requiredPlans.join(', ') });
|
|
184
|
+
throw new BadRequestException(msg);
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
protected assertPrivateAppPermission(appUser: UserContext, miniApp: MiniApp) {
|
|
189
|
+
if (miniApp.access.visibility === 'private') {
|
|
190
|
+
if (!(miniApp.access.allowEmails ?? []).includes(appUser.getEmail())) {
|
|
191
|
+
const msg = MiniAppError.format(MiniAppError.ERR.PRIVATE_APP);
|
|
192
|
+
throw new BadRequestException(msg);
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
protected async assertMiniAppCodeUnique(appUser: UserContext, miniAppCode: string) {
|
|
198
|
+
const miniApp = await this.miniAppDoc.findOne({
|
|
199
|
+
code: miniAppCode,
|
|
200
|
+
});
|
|
201
|
+
|
|
202
|
+
if (miniApp) {
|
|
203
|
+
const msg = MiniAppError.format(MiniAppError.ERR.MINI_APP_CODE_DUPLICATE);
|
|
204
|
+
throw new BadRequestException(msg);
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
protected assertMiniAppCodePattern(miniAppCode: string) {
|
|
209
|
+
if (_.isEmpty(miniAppCode)) {
|
|
210
|
+
const msg = MiniAppError.format(MiniAppError.ERR.INVALID_CODE_EMPTY);
|
|
211
|
+
throw new BadRequestException(msg);
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
if (miniAppCode.endsWith('_dev')) {
|
|
215
|
+
const msg = MiniAppError.format(MiniAppError.ERR.INVALID_CODE_SUFFIX);
|
|
216
|
+
throw new BadRequestException(msg);
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
const validPattern = /^[a-zA-Z0-9_]+$/;
|
|
220
|
+
if (!validPattern.test(miniAppCode)) {
|
|
221
|
+
const msg = MiniAppError.format(MiniAppError.ERR.INVALID_CODE_PATTERN);
|
|
222
|
+
throw new BadRequestException(msg);
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
// ===================================== Update Collection ====================================
|
|
227
|
+
|
|
228
|
+
protected async createMiniAppInstallation(appUser: UserContext, miniApp: MiniApp) {
|
|
229
|
+
return await this.miniAppInstallationService.create(appUser, {
|
|
230
|
+
apiKey: crypto.randomUUID(),
|
|
231
|
+
isActive: true,
|
|
232
|
+
miniApp: {
|
|
233
|
+
_id: miniApp._id,
|
|
234
|
+
code: miniApp.code,
|
|
235
|
+
label: miniApp.name,
|
|
236
|
+
env: miniApp.env,
|
|
237
|
+
developerPortalAppId: miniApp.developerPortal.appId,
|
|
238
|
+
},
|
|
239
|
+
miniApiUser: this.buildMiniApiUserPayload(appUser),
|
|
240
|
+
settings: {},
|
|
241
|
+
});
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
protected async setMiniAppInstallationActiveStatus(appUser: UserContext, miniAppInstallation: MiniAppInstallation, isActive: boolean) {
|
|
245
|
+
return await this.miniAppInstallationService.findIdThenPatch(appUser, miniAppInstallation._id, {
|
|
246
|
+
isActive,
|
|
247
|
+
} as MiniAppInstallation);
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
protected async setMiniAppInstallationSetting(appUser: UserContext, miniAppInstallation: MiniAppInstallation, data: DynamicParam) {
|
|
251
|
+
return await this.miniAppInstallationService.findIdThenPatch(appUser, miniAppInstallation._id, {
|
|
252
|
+
settings: data,
|
|
253
|
+
} as MiniAppInstallation);
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
// ========================================== Format ==========================================
|
|
257
|
+
|
|
258
|
+
protected formatMiniAppDetail(appUser: UserContext, miniApp: MiniApp, installation?: MiniAppInstallation) {
|
|
259
|
+
const enabled = miniApp.integration.enabled;
|
|
260
|
+
if (!enabled.customField) {
|
|
261
|
+
miniApp.integration.customField = undefined;
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
if (!enabled.customPage) {
|
|
265
|
+
miniApp.integration.customPage = undefined;
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
// @ts-expect-error Got toObject() function
|
|
269
|
+
const miniAppObj = miniApp.toObject();
|
|
270
|
+
|
|
271
|
+
return {
|
|
272
|
+
...miniAppObj,
|
|
273
|
+
hasRequiredPlan: this.policyService.hasRequiredPlan(appUser, miniApp),
|
|
274
|
+
// @ts-expect-error Got toObject() function
|
|
275
|
+
miniAppInstallation: installation ? installation.toObject() : undefined,
|
|
276
|
+
};
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
// =========================================== Other ==========================================
|
|
280
|
+
|
|
281
|
+
protected async reactivateInstalledMiniApp(appUser: UserContext, miniAppInstallation: MiniAppInstallation) {
|
|
282
|
+
return await this.miniAppInstallationService.findIdThenPatch(appUser, miniAppInstallation._id, {
|
|
283
|
+
isActive: true,
|
|
284
|
+
miniApiUser: this.buildMiniApiUserPayload(appUser),
|
|
285
|
+
} as MiniAppInstallation);
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
protected async deactiveInstalledMiniApp(appUser: UserContext, miniAppInstallation: MiniAppInstallation) {
|
|
289
|
+
return this.setMiniAppInstallationActiveStatus(appUser, miniAppInstallation, false);
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
protected resolveMiniAppPermissions(appUser: UserContext) {
|
|
293
|
+
return {
|
|
294
|
+
hasMiniAppFeature: this.policyService.hasFeature(appUser),
|
|
295
|
+
canInstall: this.policyService.canInstall(appUser),
|
|
296
|
+
canUninstall: this.policyService.canUninstall(appUser),
|
|
297
|
+
canUpdateSetting: this.policyService.canUpdateSetting(appUser),
|
|
298
|
+
};
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
protected buildMiniApiUserPayload(appUser: UserContext) {
|
|
302
|
+
return {
|
|
303
|
+
_id: appUser.getId(),
|
|
304
|
+
uid: appUser.getUid(),
|
|
305
|
+
name: appUser.getFullname(),
|
|
306
|
+
email: appUser.getEmail(),
|
|
307
|
+
};
|
|
308
|
+
}
|
|
309
|
+
}
|