@simitgroup/simpleapp-generator 1.6.7-o-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 +4 -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 -69
- 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/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/environment.ts.eta +23 -0
- package/templates/nest/src/{simpleapp/maintenance/apischemas → simple-app/.core/features/maintenance/schemas}/index.ts.eta +1 -1
- 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} +239 -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} +28 -26
- 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/formschema/index.ts.eta +0 -7
- 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/maintenance/apischemas/environment.ts.eta +0 -11
- package/templates/nest/src/simpleapp/maintenance/maintenance.controller.ts.eta +0 -72
- package/templates/nest/src/simpleapp/maintenance/maintenance.service.ts.eta +0 -88
- package/templates/nest/src/simpleapp/maintenance/models/environment.model.ts.eta +0 -16
- 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 -85
- 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/maintenance/dbupdate → simple-app/.core/features/maintenance/db-update}/1.00.00/index.ts._eta +0 -0
- /package/templates/nest/src/{simpleapp/maintenance/dbupdate → simple-app/.core/features/maintenance/db-update}/index.ts._eta +0 -0
- /package/templates/nest/src/{simpleapp/maintenance/apischemas/dbupdate.ts.eta → simple-app/.core/features/maintenance/schemas/db-update.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,94 @@
|
|
|
1
|
+
import { Injectable } from '@nestjs/common';
|
|
2
|
+
import { Branch, Miniapp, Miniappinstallation } from 'src/simpleapp/generate/types';
|
|
3
|
+
import _ from 'lodash';
|
|
4
|
+
import { InjectModel } from '@nestjs/mongoose';
|
|
5
|
+
import { Model } from 'mongoose';
|
|
6
|
+
import { UserContext } from 'src/simpleapp/generate/commons/user.context';
|
|
7
|
+
import { MiniappEnvEnum } from 'src/enums/enums.generate';
|
|
8
|
+
|
|
9
|
+
@Injectable()
|
|
10
|
+
export class DeveloperPortalService {
|
|
11
|
+
constructor(
|
|
12
|
+
@InjectModel('Miniapp')
|
|
13
|
+
protected miniAppDoc: Model<Miniapp>,
|
|
14
|
+
|
|
15
|
+
@InjectModel('Miniappinstallation')
|
|
16
|
+
protected miniAppInstallationDoc: Model<Miniappinstallation>,
|
|
17
|
+
|
|
18
|
+
@InjectModel('Branch')
|
|
19
|
+
protected branchDoc: Model<Branch>,
|
|
20
|
+
) {}
|
|
21
|
+
|
|
22
|
+
async getDemoCompany(developerPortalAppId: string) {
|
|
23
|
+
// Only dev got development.demoXOrg field
|
|
24
|
+
const miniApp = await this.miniAppDoc.findOne({
|
|
25
|
+
'developerPortal.appId': developerPortalAppId,
|
|
26
|
+
env: MiniappEnvEnum.DEV,
|
|
27
|
+
});
|
|
28
|
+
if (miniApp && !_.isEmpty(miniApp?.development?.demoXOrg)) {
|
|
29
|
+
return miniApp.development.demoXOrg;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
return process.env.DEMO_COMPANY_XORG;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
async getInstalledMiniAppXOrgs(appUser: UserContext, developerPortalAppId: string) {
|
|
36
|
+
const demoXOrg = await this.getDemoCompany(developerPortalAppId);
|
|
37
|
+
|
|
38
|
+
// Only get env === prod one
|
|
39
|
+
const miniAppInstallations = await this.miniAppInstallationDoc.find({
|
|
40
|
+
'miniApp.developerPortalAppId': developerPortalAppId,
|
|
41
|
+
'miniApp.env': MiniappEnvEnum.PROD,
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
if (!miniAppInstallations || _.isEmpty(miniAppInstallations)) {
|
|
45
|
+
return {
|
|
46
|
+
demoXOrg,
|
|
47
|
+
installedXOrgs: [],
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
// Step 1: Extract unique composite keys for branch lookup
|
|
52
|
+
const branchKeyList = miniAppInstallations.map((install) => ({
|
|
53
|
+
tenantId: install.tenantId,
|
|
54
|
+
orgId: install.orgId,
|
|
55
|
+
branchId: install.branchId,
|
|
56
|
+
}));
|
|
57
|
+
|
|
58
|
+
// Step 2: Build $or filter for batch querying branches
|
|
59
|
+
const branchFilter = {
|
|
60
|
+
$or: branchKeyList.map(({ tenantId, orgId, branchId }) => ({
|
|
61
|
+
tenantId,
|
|
62
|
+
orgId,
|
|
63
|
+
branchId,
|
|
64
|
+
})),
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
// Step 3: Run one query to get all branches
|
|
68
|
+
const allBranches = await this.branchDoc.find(branchFilter);
|
|
69
|
+
|
|
70
|
+
// Step 4: Build a lookup map: `${tenantId}-${orgId}-${branchId}` → branch
|
|
71
|
+
const branchMap = new Map<string, Branch>();
|
|
72
|
+
for (const branch of allBranches) {
|
|
73
|
+
const key = `${branch.tenantId}-${branch.orgId}-${branch.branchId}`;
|
|
74
|
+
branchMap.set(key, branch);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
// Step 5: Compose result
|
|
78
|
+
const installedXOrgs = miniAppInstallations.map((install) => {
|
|
79
|
+
const key = `${install.tenantId}-${install.orgId}-${install.branchId}`;
|
|
80
|
+
const branch = branchMap.get(key);
|
|
81
|
+
|
|
82
|
+
return {
|
|
83
|
+
branchCode: branch?.branchCode,
|
|
84
|
+
branchName: branch?.branchName,
|
|
85
|
+
xOrg: appUser.generateXOrg(install.tenantId, install.orgId, install.branchId),
|
|
86
|
+
};
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
return {
|
|
90
|
+
demoXOrg,
|
|
91
|
+
installedXOrgs,
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { Field, ObjectType } from '@nestjs/graphql';
|
|
2
|
+
import { ApiProperty } from '@nestjs/swagger';
|
|
3
|
+
import { MiniappAuthor } from 'src/simpleapp/generate/apischemas';
|
|
4
|
+
|
|
5
|
+
@ObjectType()
|
|
6
|
+
export class DeveloperPortalCreateAppDto {
|
|
7
|
+
@Field()
|
|
8
|
+
@ApiProperty({ type: 'string', required: true, default: '' })
|
|
9
|
+
code: string;
|
|
10
|
+
|
|
11
|
+
@Field()
|
|
12
|
+
@ApiProperty({ type: 'string', required: true, default: '' })
|
|
13
|
+
name: string;
|
|
14
|
+
|
|
15
|
+
@Field()
|
|
16
|
+
@ApiProperty({ type: 'string', required: true, default: '' })
|
|
17
|
+
version: string;
|
|
18
|
+
|
|
19
|
+
@Field()
|
|
20
|
+
@ApiProperty({ type: MiniappAuthor, required: true, default: '' })
|
|
21
|
+
author: MiniappAuthor;
|
|
22
|
+
}
|
|
File without changes
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { Field, ObjectType } from '@nestjs/graphql';
|
|
2
|
+
import { ApiProperty } from '@nestjs/swagger';
|
|
3
|
+
import { MiniApp, MiniAppInstallation } from './imports';
|
|
4
|
+
|
|
5
|
+
@ObjectType()
|
|
6
|
+
export class MiniAppDetailPermission {
|
|
7
|
+
@Field()
|
|
8
|
+
@ApiProperty({ type: 'boolean', required: true, default: false })
|
|
9
|
+
hasMiniAppFeature: boolean;
|
|
10
|
+
|
|
11
|
+
@Field()
|
|
12
|
+
@ApiProperty({ type: 'boolean', required: true, default: false })
|
|
13
|
+
canInstall: boolean;
|
|
14
|
+
|
|
15
|
+
@Field()
|
|
16
|
+
@ApiProperty({ type: 'boolean', required: true, default: false })
|
|
17
|
+
canUninstall: boolean;
|
|
18
|
+
|
|
19
|
+
@Field()
|
|
20
|
+
@ApiProperty({ type: 'boolean', required: true, default: false })
|
|
21
|
+
canUpdateSetting: boolean;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
@ObjectType()
|
|
25
|
+
export class MiniAppDetail extends MiniApp {
|
|
26
|
+
@Field(() => MiniAppInstallation)
|
|
27
|
+
@ApiProperty({ type: () => MiniAppInstallation, required: false })
|
|
28
|
+
miniAppInstallation?: MiniAppInstallation;
|
|
29
|
+
|
|
30
|
+
@Field()
|
|
31
|
+
@ApiProperty({ type: 'boolean' })
|
|
32
|
+
hasRequiredPlan: boolean;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
@ObjectType()
|
|
36
|
+
export class CategorizedMiniAppDetail {
|
|
37
|
+
@Field(() => [MiniAppDetail])
|
|
38
|
+
@ApiProperty({ type: () => [MiniAppDetail] })
|
|
39
|
+
upcomingMiniApps: MiniAppDetail[];
|
|
40
|
+
|
|
41
|
+
@Field(() => [MiniAppDetail])
|
|
42
|
+
@ApiProperty({ type: () => [MiniAppDetail] })
|
|
43
|
+
availableMiniApps: MiniAppDetail[];
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
@ObjectType()
|
|
47
|
+
export class InstalledMiniAppDetail {
|
|
48
|
+
@Field(() => MiniAppDetailPermission)
|
|
49
|
+
@ApiProperty({ type: () => MiniAppDetailPermission, required: true })
|
|
50
|
+
permissions: MiniAppDetailPermission;
|
|
51
|
+
|
|
52
|
+
@Field(() => [MiniAppDetail])
|
|
53
|
+
@ApiProperty({ type: () => [MiniAppDetail] })
|
|
54
|
+
installedMiniApps: MiniAppDetail[];
|
|
55
|
+
}
|
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
import { BadRequestException, Injectable, NotFoundException } from '@nestjs/common';
|
|
2
|
+
import { UserContext } from 'src/simple-app/.core/features/user-context/user.context';
|
|
3
|
+
import _ from 'lodash';
|
|
4
|
+
import { InjectModel } from '@nestjs/mongoose';
|
|
5
|
+
import { Model } from 'mongoose';
|
|
6
|
+
import { MiniApp , DynamicParam, MiniAppInstallation} from '../dto';
|
|
7
|
+
import { MiniAppError } from './mini-app-manager.error';
|
|
8
|
+
import { MiniAppManagerEnvEnum } from './mini-app-manager.enum';
|
|
9
|
+
import { MiniAppManagerEnvDevelopmentService } from './mini-app-manager-env-development.service';
|
|
10
|
+
import { MiniAppManagerEnvProductionService } from './mini-app-manager-env-production.service';
|
|
11
|
+
import { getEnvironment } from '../utils/mini-app.util';
|
|
12
|
+
// import { DEFAULT_MINI_APPS } from 'src/data/miniApps';
|
|
13
|
+
|
|
14
|
+
@Injectable()
|
|
15
|
+
export class MiniAppManagerBridgeService {
|
|
16
|
+
constructor(
|
|
17
|
+
private readonly devService: MiniAppManagerEnvDevelopmentService,
|
|
18
|
+
private readonly prodService: MiniAppManagerEnvProductionService,
|
|
19
|
+
|
|
20
|
+
@InjectModel('MiniApp') private readonly miniAppModel: Model<MiniApp>,
|
|
21
|
+
@InjectModel('MiniAppInstallation') private miniAppInstallationModel: Model<MiniAppInstallation>,
|
|
22
|
+
) {}
|
|
23
|
+
|
|
24
|
+
private readonly serviceMap: Record<MiniAppManagerEnvEnum, MiniAppManagerEnvDevelopmentService | MiniAppManagerEnvProductionService> = {
|
|
25
|
+
[MiniAppManagerEnvEnum.DEV]: this.devService,
|
|
26
|
+
[MiniAppManagerEnvEnum.PROD]: this.prodService,
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
private async findMiniAppOrFail(appUser: UserContext, miniAppCode: string) {
|
|
30
|
+
const miniApp = await this.miniAppModel.findOne({
|
|
31
|
+
code: miniAppCode,
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
if (_.isEmpty(miniApp)) {
|
|
35
|
+
const msg = MiniAppError.format(MiniAppError.ERR.NOT_FOUND);
|
|
36
|
+
throw new NotFoundException(msg);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
return miniApp;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
private async resolveContext(appUser: UserContext) {
|
|
43
|
+
const env = getEnvironment(appUser);
|
|
44
|
+
|
|
45
|
+
const service = this.getService(env);
|
|
46
|
+
|
|
47
|
+
return {
|
|
48
|
+
env,
|
|
49
|
+
service,
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
private async resolveContextWithApp(appUser: UserContext, miniAppCode: string) {
|
|
54
|
+
const env = getEnvironment(appUser);
|
|
55
|
+
const miniApp = await this.findMiniAppOrFail(appUser, miniAppCode);
|
|
56
|
+
|
|
57
|
+
const service = this.getService(env);
|
|
58
|
+
|
|
59
|
+
return {
|
|
60
|
+
miniApp,
|
|
61
|
+
env,
|
|
62
|
+
service,
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
private getService(env: MiniAppManagerEnvEnum): MiniAppManagerEnvDevelopmentService | MiniAppManagerEnvProductionService {
|
|
67
|
+
const service = this.serviceMap[env];
|
|
68
|
+
if (!service) {
|
|
69
|
+
const msg = MiniAppError.format(MiniAppError.ERR.UNKNOWN_ENV);
|
|
70
|
+
throw new BadRequestException(msg);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
return service;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
async runGetInstalledMiniApps(appUser: UserContext) {
|
|
77
|
+
const { service } = await this.resolveContext(appUser);
|
|
78
|
+
return await service.runGetInstalledMiniApps(appUser);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
async runGetCategorizedMiniApps(appUser: UserContext) {
|
|
82
|
+
const { service } = await this.resolveContext(appUser);
|
|
83
|
+
return await service.runGetCategorizedMiniApps(appUser);
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
async runGetMiniAppDetail(appUser: UserContext, miniAppCode: string) {
|
|
87
|
+
const { miniApp, service } = await this.resolveContextWithApp(appUser, miniAppCode);
|
|
88
|
+
return await service.runGetMiniAppDetail(appUser, miniApp);
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
async runInstallMiniApp(appUser: UserContext, miniAppCode: string) {
|
|
92
|
+
const { miniApp, service } = await this.resolveContextWithApp(appUser, miniAppCode);
|
|
93
|
+
return await service.runInstallMiniApp(appUser, miniApp);
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
async runUninstallMiniApp(appUser: UserContext, miniAppCode: string) {
|
|
97
|
+
const { miniApp, service } = await this.resolveContextWithApp(appUser, miniAppCode);
|
|
98
|
+
return await service.runUninstallMiniApp(appUser, miniApp);
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
async runUpdateMiniAppSetting(appUser: UserContext, miniAppCode: string, data: DynamicParam) {
|
|
102
|
+
const { miniApp, service } = await this.resolveContextWithApp(appUser, miniAppCode);
|
|
103
|
+
return await service.runUpdateMiniAppSetting(appUser, miniApp, data);
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
async runSystemDefaultMiniAppMigration(appUser: UserContext) {
|
|
107
|
+
// Step 1: Normalize codes with underscores
|
|
108
|
+
// const renameMap: Record<string, string> = {
|
|
109
|
+
// 'simbiz-accounting': 'simbiz_accounting',
|
|
110
|
+
// 'e-invoice': 'e_invoice',
|
|
111
|
+
// };
|
|
112
|
+
|
|
113
|
+
// for (const [oldCode, newCode] of Object.entries(renameMap)) {
|
|
114
|
+
// await this.miniAppModel.updateOne({ code: oldCode }, { $set: { code: newCode } });
|
|
115
|
+
// }
|
|
116
|
+
|
|
117
|
+
// // Step 2: Remove unused mini apps
|
|
118
|
+
// const allowedCodes = ['simbiz_accounting', 'e_invoice', 'webhook', 'mcplus'];
|
|
119
|
+
// await this.miniAppModel.deleteMany({ code: { $nin: allowedCodes } });
|
|
120
|
+
|
|
121
|
+
// // Step 3: Update default data for each mini app
|
|
122
|
+
// const defaultMap: Record<string, any> = {
|
|
123
|
+
// simbiz_accounting: DEFAULT_MINI_APPS.simbizAccounting,
|
|
124
|
+
// e_invoice: DEFAULT_MINI_APPS.eInvoice,
|
|
125
|
+
// webhook: DEFAULT_MINI_APPS.webhook,
|
|
126
|
+
// mcplus: DEFAULT_MINI_APPS.mcplus,
|
|
127
|
+
// };
|
|
128
|
+
|
|
129
|
+
// for (const [code, defaults] of Object.entries(defaultMap)) {
|
|
130
|
+
// await this.miniAppModel.updateOne({ code }, defaults);
|
|
131
|
+
// }
|
|
132
|
+
|
|
133
|
+
// // Step 4: Fix mini app installations
|
|
134
|
+
// const savePromises = [];
|
|
135
|
+
// const miniAppInstallations = await this.miniAppInstallationModel.find();
|
|
136
|
+
|
|
137
|
+
// for (const installation of miniAppInstallations) {
|
|
138
|
+
// if (installation.miniApp.code === 'simbiz-accounting') {
|
|
139
|
+
// installation.miniApp.code = 'simbiz_accounting';
|
|
140
|
+
// installation.miniApp.developerPortalAppId = DEFAULT_MINI_APPS.simbizAccounting.developerPortal.appId;
|
|
141
|
+
// } else if (installation.miniApp.code === 'e-invoice') {
|
|
142
|
+
// installation.miniApp.code = 'e_invoice';
|
|
143
|
+
// installation.miniApp.developerPortalAppId = DEFAULT_MINI_APPS.eInvoice.developerPortal.appId;
|
|
144
|
+
// } else if (installation.miniApp.code === 'webhook') {
|
|
145
|
+
// installation.miniApp.code = 'webhook';
|
|
146
|
+
// installation.miniApp.developerPortalAppId = DEFAULT_MINI_APPS.webhook.developerPortal.appId;
|
|
147
|
+
// } else if (installation.miniApp.code === 'mcplus') {
|
|
148
|
+
// installation.miniApp.code = 'mcplus';
|
|
149
|
+
// installation.miniApp.developerPortalAppId = DEFAULT_MINI_APPS.mcplus.developerPortal.appId;
|
|
150
|
+
// }
|
|
151
|
+
|
|
152
|
+
// installation.miniApp.env = 'prod';
|
|
153
|
+
// installation.markModified('miniApp');
|
|
154
|
+
|
|
155
|
+
// savePromises.push(installation.save());
|
|
156
|
+
// }
|
|
157
|
+
|
|
158
|
+
// await Promise.all(savePromises);
|
|
159
|
+
|
|
160
|
+
return await this.miniAppModel.find();
|
|
161
|
+
}
|
|
162
|
+
}
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
import { BadRequestException, Injectable } from '@nestjs/common';
|
|
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 { UserContext } from 'src/simple-app/.core/features/user-context/user.context';
|
|
6
|
+
import { MiniAppManagerProcessor } from './mini-app-manager.processor';
|
|
7
|
+
import { DynamicParam,MiniApp ,CategorizedMiniAppDetail, InstalledMiniAppDetail, MiniAppDetail } from '../dto';
|
|
8
|
+
import { MiniAppEnvEnum, MiniAppStatusEnum } from 'src/simple-app/.core/resources/mini-app/mini-app.enum';
|
|
9
|
+
import { Model } from 'mongoose';
|
|
10
|
+
import { MiniAppManagerEnvEnum } from './mini-app-manager.enum';
|
|
11
|
+
import _ from 'lodash';
|
|
12
|
+
|
|
13
|
+
@Injectable()
|
|
14
|
+
export class MiniAppManagerEnvDevelopmentService extends MiniAppManagerProcessor {
|
|
15
|
+
constructor(miniAppService: MiniAppService, miniAppInstallationService: MiniAppInstallationService, policyService: MiniAppManagerPolicyService, miniAppDoc: Model<MiniApp>) {
|
|
16
|
+
super(miniAppService, miniAppInstallationService, policyService, miniAppDoc);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
async runGetInstalledMiniApps(appUser: UserContext): Promise<InstalledMiniAppDetail> {
|
|
20
|
+
return await this.findInstalledMiniAppsDetail(appUser);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
async runGetCategorizedMiniApps(appUser: UserContext): Promise<CategorizedMiniAppDetail> {
|
|
24
|
+
const { installedMiniAppIdArr } = await this.findInstalledMiniAppIds(appUser);
|
|
25
|
+
|
|
26
|
+
const filter = {
|
|
27
|
+
_id: { $nin: installedMiniAppIdArr },
|
|
28
|
+
env: MiniAppEnvEnum.DEV,
|
|
29
|
+
status: {
|
|
30
|
+
$in: [MiniAppStatusEnum.DRAFT],
|
|
31
|
+
},
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
const miniApps = await this.miniAppService.search(appUser, filter);
|
|
35
|
+
return this.categorizedMiniApps(appUser, miniApps);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
async runGetMiniAppDetail(appUser: UserContext, miniApp: MiniApp): Promise<MiniAppDetail> {
|
|
39
|
+
this.assertEnvironment(appUser, miniApp);
|
|
40
|
+
this.assertPrivateAppPermission(appUser, miniApp);
|
|
41
|
+
|
|
42
|
+
return await this.findMiniAppDetail(appUser, miniApp);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
async runInstallMiniApp(appUser: UserContext, miniApp: MiniApp) {
|
|
46
|
+
this.assertEnvironment(appUser, miniApp);
|
|
47
|
+
this.assertHasMiniAppFeature(appUser);
|
|
48
|
+
this.assertPrivateAppPermission(appUser, miniApp);
|
|
49
|
+
this.assertHasRequiredPlan(appUser, miniApp);
|
|
50
|
+
// this.assertIsMiniAppReleased(miniApp);
|
|
51
|
+
|
|
52
|
+
return await this.install(appUser, miniApp);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
async runUninstallMiniApp(appUser: UserContext, miniApp: MiniApp) {
|
|
56
|
+
this.assertHasMiniAppFeature(appUser);
|
|
57
|
+
|
|
58
|
+
return await this.uninstall(appUser, miniApp);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
async runUpdateMiniAppSetting(appUser: UserContext, miniApp: MiniApp, data: DynamicParam) {
|
|
62
|
+
this.assertHasMiniAppFeature(appUser);
|
|
63
|
+
this.assertHasRequiredPlan(appUser, miniApp);
|
|
64
|
+
// this.assertIsMiniAppReleased(miniApp);
|
|
65
|
+
|
|
66
|
+
return await this.updateSetting(appUser, miniApp, data);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
async createMiniApp(appUser: UserContext, developerPortalAppId: string, dto: MiniApp) {
|
|
70
|
+
// Validate Original Code Instead Of Processed One, Because Will Check End With ('_dev')
|
|
71
|
+
this.assertMiniAppCodePattern(dto.code);
|
|
72
|
+
|
|
73
|
+
const env = MiniAppManagerEnvEnum.DEV;
|
|
74
|
+
const miniAppCode = dto.code + '_dev';
|
|
75
|
+
await this.assertMiniAppCodeUnique(appUser, miniAppCode);
|
|
76
|
+
|
|
77
|
+
const payload: MiniApp = {
|
|
78
|
+
code: miniAppCode,
|
|
79
|
+
name: dto.name,
|
|
80
|
+
env: env,
|
|
81
|
+
version: dto.version,
|
|
82
|
+
description: '',
|
|
83
|
+
logo: '',
|
|
84
|
+
tags: dto.tags,
|
|
85
|
+
pricing: 0,
|
|
86
|
+
status: MiniAppStatusEnum.DRAFT,
|
|
87
|
+
author: dto.author,
|
|
88
|
+
access: {
|
|
89
|
+
visibility: 'private',
|
|
90
|
+
allowEmails: [dto.author.email],
|
|
91
|
+
requiredPlans: [],
|
|
92
|
+
},
|
|
93
|
+
developerPortal: {
|
|
94
|
+
appId: developerPortalAppId,
|
|
95
|
+
},
|
|
96
|
+
intro: {
|
|
97
|
+
description: '',
|
|
98
|
+
previewImages: [],
|
|
99
|
+
features: [],
|
|
100
|
+
},
|
|
101
|
+
integration: {
|
|
102
|
+
enabled: {
|
|
103
|
+
miniApi: false,
|
|
104
|
+
customField: false,
|
|
105
|
+
customPage: false,
|
|
106
|
+
},
|
|
107
|
+
},
|
|
108
|
+
};
|
|
109
|
+
|
|
110
|
+
return await this.miniAppService.create(appUser, payload);
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
async updateMiniApp(appUser: UserContext, miniApp: MiniApp, dto: MiniApp) {
|
|
114
|
+
const payload = {
|
|
115
|
+
...miniApp,
|
|
116
|
+
name: dto.name,
|
|
117
|
+
version: dto.version,
|
|
118
|
+
description: dto.description,
|
|
119
|
+
logo: dto.logo,
|
|
120
|
+
tags: dto.tags,
|
|
121
|
+
pricing: dto.pricing,
|
|
122
|
+
author: dto.author,
|
|
123
|
+
access: {
|
|
124
|
+
visibility: 'private',
|
|
125
|
+
allowEmails: [dto.author.email],
|
|
126
|
+
requiredPlans: [],
|
|
127
|
+
},
|
|
128
|
+
intro: dto.intro,
|
|
129
|
+
integration: dto.integration,
|
|
130
|
+
};
|
|
131
|
+
|
|
132
|
+
return await this.miniAppService.findIdThenUpdate(appUser, miniApp._id, payload);
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
protected assertEnvironment(appUser: UserContext, miniApp: MiniApp) {
|
|
136
|
+
if (miniApp.env !== MiniAppManagerEnvEnum.DEV) {
|
|
137
|
+
throw new BadRequestException('Cannot process production app in dev env');
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
}
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
import { BadRequestException, Injectable } from '@nestjs/common';
|
|
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 { UserContext } from 'src/simple-app/.core/features/user-context/user.context';
|
|
6
|
+
import { MiniAppManagerProcessor } from './mini-app-manager.processor';
|
|
7
|
+
import { DynamicParam,MiniApp ,CategorizedMiniAppDetail, InstalledMiniAppDetail, MiniAppDetail } from '../dto';
|
|
8
|
+
import { MiniAppEnvEnum, MiniAppStatusEnum } from 'src/simple-app/.core/resources/mini-app/mini-app.enum';
|
|
9
|
+
import { Model } from 'mongoose';
|
|
10
|
+
import { MiniAppManagerEnvEnum } from './mini-app-manager.enum';
|
|
11
|
+
import _ from 'lodash';
|
|
12
|
+
|
|
13
|
+
@Injectable()
|
|
14
|
+
export class MiniAppManagerEnvProductionService extends MiniAppManagerProcessor {
|
|
15
|
+
constructor(miniAppService: MiniAppService, miniAppInstallationService: MiniAppInstallationService, policyService: MiniAppManagerPolicyService, miniAppDoc: Model<MiniApp>) {
|
|
16
|
+
super(miniAppService, miniAppInstallationService, policyService, miniAppDoc);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
async runGetInstalledMiniApps(appUser: UserContext): Promise<InstalledMiniAppDetail> {
|
|
20
|
+
return await this.findInstalledMiniAppsDetail(appUser);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
async runGetCategorizedMiniApps(appUser: UserContext): Promise<CategorizedMiniAppDetail> {
|
|
24
|
+
const { installedMiniAppIdArr } = await this.findInstalledMiniAppIds(appUser);
|
|
25
|
+
|
|
26
|
+
const filter = {
|
|
27
|
+
_id: { $nin: installedMiniAppIdArr },
|
|
28
|
+
env: MiniAppEnvEnum.PROD,
|
|
29
|
+
status: {
|
|
30
|
+
$in: [MiniAppStatusEnum.PUBLISHED, MiniAppStatusEnum.UPCOMING, MiniAppStatusEnum.BETA],
|
|
31
|
+
},
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
const miniApps = await this.miniAppService.search(appUser, filter);
|
|
35
|
+
return this.categorizedMiniApps(appUser, miniApps);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
async runGetMiniAppDetail(appUser: UserContext, miniApp: MiniApp): Promise<MiniAppDetail> {
|
|
39
|
+
this.assertEnvironment(appUser, miniApp);
|
|
40
|
+
this.assertPrivateAppPermission(appUser, miniApp);
|
|
41
|
+
|
|
42
|
+
return await this.findMiniAppDetail(appUser, miniApp);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
async runInstallMiniApp(appUser: UserContext, miniApp: MiniApp) {
|
|
46
|
+
this.assertEnvironment(appUser, miniApp);
|
|
47
|
+
this.assertHasMiniAppFeature(appUser);
|
|
48
|
+
this.assertPrivateAppPermission(appUser, miniApp);
|
|
49
|
+
this.assertHasRequiredPlan(appUser, miniApp);
|
|
50
|
+
this.assertIsMiniAppReleased(miniApp);
|
|
51
|
+
|
|
52
|
+
return await this.install(appUser, miniApp);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
async runUninstallMiniApp(appUser: UserContext, miniApp: MiniApp) {
|
|
56
|
+
this.assertHasMiniAppFeature(appUser);
|
|
57
|
+
|
|
58
|
+
return await this.uninstall(appUser, miniApp);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
async runUpdateMiniAppSetting(appUser: UserContext, miniApp: MiniApp, data: DynamicParam) {
|
|
62
|
+
this.assertHasMiniAppFeature(appUser);
|
|
63
|
+
this.assertHasRequiredPlan(appUser, miniApp);
|
|
64
|
+
this.assertIsMiniAppReleased(miniApp);
|
|
65
|
+
|
|
66
|
+
return await this.updateSetting(appUser, miniApp, data);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
async createMiniApp(appUser: UserContext, developerPortalAppId: string, dto: MiniApp) {
|
|
70
|
+
this.assertMiniAppCodePattern(dto.code);
|
|
71
|
+
await this.assertMiniAppCodeUnique(appUser, dto.code);
|
|
72
|
+
|
|
73
|
+
const env = MiniAppManagerEnvEnum.PROD;
|
|
74
|
+
const payload = {
|
|
75
|
+
code: dto.code,
|
|
76
|
+
name: dto.name,
|
|
77
|
+
env: env,
|
|
78
|
+
version: dto.version,
|
|
79
|
+
description: dto.description,
|
|
80
|
+
logo: dto.logo,
|
|
81
|
+
tags: dto.tags,
|
|
82
|
+
pricing: 0,
|
|
83
|
+
status: MiniAppStatusEnum.PUBLISHED,
|
|
84
|
+
author: dto.author,
|
|
85
|
+
access: dto.access,
|
|
86
|
+
developerPortal: {
|
|
87
|
+
appId: developerPortalAppId,
|
|
88
|
+
},
|
|
89
|
+
intro: dto.intro,
|
|
90
|
+
integration: dto.integration,
|
|
91
|
+
};
|
|
92
|
+
|
|
93
|
+
return await this.miniAppService.create(appUser, payload);
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
async updateMiniApp(appUser: UserContext, miniApp: MiniApp, dto: MiniApp) {
|
|
97
|
+
const payload = {
|
|
98
|
+
...miniApp,
|
|
99
|
+
name: dto.name,
|
|
100
|
+
version: dto.version,
|
|
101
|
+
description: dto.description,
|
|
102
|
+
logo: dto.logo,
|
|
103
|
+
tags: dto.tags,
|
|
104
|
+
pricing: dto.pricing,
|
|
105
|
+
author: dto.author,
|
|
106
|
+
access: dto.access,
|
|
107
|
+
intro: dto.intro,
|
|
108
|
+
integration: dto.integration,
|
|
109
|
+
};
|
|
110
|
+
|
|
111
|
+
return await this.miniAppService.findIdThenUpdate(appUser, miniApp._id, payload);
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
protected assertEnvironment(appUser: UserContext, miniApp: MiniApp) {
|
|
115
|
+
if (miniApp.env !== MiniAppManagerEnvEnum.PROD) {
|
|
116
|
+
if (!_.isEmpty(miniApp?.development?.demoXOrg)) {
|
|
117
|
+
if (miniApp.development.demoXOrg === appUser.getXOrg()) {
|
|
118
|
+
return true;
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
throw new BadRequestException('Cannot process dev app in prod env');
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
}
|
|
@@ -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
|
+
}
|