@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.
Files changed (305) hide show
  1. package/ReleaseNote.md +4 -0
  2. package/dist/buildinschemas/autoincreament.js +1 -1
  3. package/dist/buildinschemas/branch.d.ts.map +1 -1
  4. package/dist/buildinschemas/branch.js +2 -0
  5. package/dist/buildinschemas/branch.js.map +1 -1
  6. package/dist/buildinschemas/docnoformat.js +1 -1
  7. package/dist/buildinschemas/docnoformat.js.map +1 -1
  8. package/dist/buildinschemas/documentevent.js +1 -1
  9. package/dist/buildinschemas/documentnoformat.d.ts +3 -0
  10. package/dist/buildinschemas/documentnoformat.d.ts.map +1 -0
  11. package/dist/buildinschemas/documentnoformat.js +58 -0
  12. package/dist/buildinschemas/documentnoformat.js.map +1 -0
  13. package/dist/buildinschemas/index.d.ts +0 -5
  14. package/dist/buildinschemas/index.d.ts.map +1 -1
  15. package/dist/buildinschemas/index.js +5 -11
  16. package/dist/buildinschemas/index.js.map +1 -1
  17. package/dist/buildinschemas/organization.d.ts.map +1 -1
  18. package/dist/buildinschemas/organization.js +3 -19
  19. package/dist/buildinschemas/organization.js.map +1 -1
  20. package/dist/buildinschemas/user.d.ts.map +1 -1
  21. package/dist/buildinschemas/user.js +5 -2
  22. package/dist/buildinschemas/user.js.map +1 -1
  23. package/dist/generate.d.ts.map +1 -1
  24. package/dist/generate.js +118 -23
  25. package/dist/generate.js.map +1 -1
  26. package/dist/type.d.ts +6 -0
  27. package/dist/type.d.ts.map +1 -1
  28. package/dist/type.js.map +1 -1
  29. package/package.json +1 -1
  30. package/src/buildinschemas/{autoincreament.ts → autoincreament.ts.backup} +1 -1
  31. package/src/buildinschemas/branch.ts +2 -0
  32. package/src/buildinschemas/{documentevent.ts → documentevent.ts.backup} +1 -1
  33. package/src/buildinschemas/{docnoformat.ts → documentnoformat.ts.backup} +3 -3
  34. package/src/buildinschemas/index.ts +4 -5
  35. package/src/buildinschemas/organization.ts +3 -19
  36. package/src/buildinschemas/user.ts +5 -2
  37. package/src/generate.ts +128 -28
  38. package/src/type.ts +6 -1
  39. package/templates/basic/nest/api.controller.ts.eta +153 -0
  40. package/templates/basic/nest/api.module.ts.eta +32 -0
  41. package/templates/basic/nest/api.resolver.ts.eta +94 -0
  42. package/templates/basic/nest/api.schema.ts.eta +20 -0
  43. package/templates/basic/nest/api.service.ts.eta +85 -0
  44. package/templates/basic/nest/controller.ts.eta +18 -119
  45. package/templates/basic/nest/default.ts.eta +16 -10
  46. package/templates/basic/nest/enum.ts.eta +16 -0
  47. package/templates/basic/nest/model.ts.eta +6 -28
  48. package/templates/basic/nest/module.ts.eta +25 -0
  49. package/templates/basic/nest/resolver.ts.eta +12 -56
  50. package/templates/basic/nest/schema.ts.eta +133 -0
  51. package/templates/basic/nest/service.ts.eta +82 -73
  52. package/templates/basic/nest/service.ts.eta-backup +50 -0
  53. package/templates/basic/nuxt/default.ts.eta +10 -8
  54. package/templates/basic/nuxt/pages.[id].vue.eta +2 -2
  55. package/templates/basic/nuxt/pages.form.vue.eta +2 -2
  56. package/templates/basic/nuxt/pages.viewer.vue.eta +2 -2
  57. package/templates/basic/nuxt/simpleapp.doc.ts.eta +1 -1
  58. package/templates/basic/nuxt/simpleapp.generate.client.ts.eta +7 -5
  59. package/templates/nest/src/app.module.ts._eta +53 -69
  60. package/templates/nest/src/main.ts._eta +1 -1
  61. package/templates/nest/src/simple-app/.core/features/auth/api-key/api-key.service.ts.eta +29 -0
  62. package/templates/nest/src/simple-app/.core/features/auth/api-key/api-key.type.ts.eta +5 -0
  63. package/templates/nest/src/simple-app/.core/features/auth/api-key/validators/interface.ts.eta +7 -0
  64. package/templates/nest/src/simple-app/.core/features/auth/api-key/validators/mini-api-key.validator.ts.eta +30 -0
  65. package/templates/nest/src/simple-app/.core/features/auth/api-key/validators/static-api-key.validator.ts.eta +27 -0
  66. package/templates/nest/src/simple-app/.core/features/auth/auth.module.ts.eta +9 -0
  67. package/templates/nest/src/{simpleapp/generate/commons/roles → simple-app/.core/features/auth/role-guard}/roles.enum.ts.eta +7 -7
  68. package/templates/nest/src/{simpleapp/generate/commons/roles → simple-app/.core/features/auth/role-guard}/roles.guard.ts.eta +1 -1
  69. package/templates/nest/src/simple-app/.core/features/auto-increament/auto-increament.model.ts.eta +10 -0
  70. package/templates/nest/src/simple-app/.core/features/auto-increament/auto-increament.module.ts.eta +18 -0
  71. package/templates/nest/src/simple-app/.core/features/auto-increament/auto-increament.schema.ts.eta +119 -0
  72. package/templates/nest/src/simple-app/.core/features/auto-increament/auto-increament.service.ts.eta +65 -0
  73. package/templates/nest/src/simple-app/.core/features/cron/base/cron.base.ts.eta +13 -0
  74. package/templates/nest/src/simple-app/.core/features/cron/cron-system/cron-system.module.ts.eta +17 -0
  75. package/templates/nest/src/simple-app/.core/features/cron/cron-system/cron-system.service.ts.eta +37 -0
  76. package/templates/nest/src/simple-app/.core/features/cron/cron-system/schemas/index.ts.eta +2 -0
  77. package/templates/nest/src/simple-app/.core/features/cron/cron.module.ts.eta +10 -0
  78. package/templates/nest/src/simple-app/.core/features/document-no-format/document-no-format.controller.ts.eta +31 -0
  79. package/templates/nest/src/simple-app/.core/features/document-no-format/document-no-format.model.ts.eta +15 -0
  80. package/templates/nest/src/simple-app/.core/features/document-no-format/document-no-format.module.ts.eta +12 -0
  81. package/templates/nest/src/simple-app/.core/features/document-no-format/document-no-format.schema.ts.eta +162 -0
  82. package/templates/nest/src/simple-app/.core/features/document-no-format/document-no-format.service.ts.eta +189 -0
  83. package/templates/nest/src/simple-app/.core/features/event/event.module.ts.eta +9 -0
  84. package/templates/nest/src/simple-app/.core/features/event/event.type.ts.eta +23 -0
  85. package/templates/nest/src/simple-app/.core/features/event/interface/event-after-create.interface.ts.eta +5 -0
  86. package/templates/nest/src/simple-app/.core/features/event/interface/event-after-delete.interface.ts.eta +5 -0
  87. package/templates/nest/src/simple-app/.core/features/event/interface/event-after-set-status.interface.ts.eta +5 -0
  88. package/templates/nest/src/simple-app/.core/features/event/interface/event-after-update.interface.ts.eta +5 -0
  89. package/templates/nest/src/simple-app/.core/features/event/interface/event-before-create.interface.ts.eta +5 -0
  90. package/templates/nest/src/simple-app/.core/features/event/interface/event-before-delete.interface.ts.eta +5 -0
  91. package/templates/nest/src/simple-app/.core/features/event/interface/event-before-set-status.interface.ts.eta +5 -0
  92. package/templates/nest/src/simple-app/.core/features/event/interface/event-before-update.interface.ts.eta +5 -0
  93. package/templates/nest/src/simple-app/.core/features/event/interface/index.ts.eta +8 -0
  94. package/templates/nest/src/simple-app/.core/features/foreign-key/foreign-key.module.ts.eta +16 -0
  95. package/templates/nest/src/simple-app/.core/features/log/log.module.ts.eta +20 -0
  96. package/templates/nest/src/simple-app/.core/features/log/log.service.ts.eta +68 -0
  97. package/templates/nest/src/simple-app/.core/features/log/schemas/api-event.schema.ts.eta +57 -0
  98. package/templates/nest/src/simple-app/.core/features/log/schemas/document-event.schema.ts.eta +87 -0
  99. package/templates/nest/src/simple-app/.core/features/log/schemas/index.ts.eta +2 -0
  100. package/templates/nest/src/simple-app/.core/features/maintenance/maintenance.controller.ts.eta +84 -0
  101. package/templates/nest/src/simple-app/.core/features/maintenance/maintenance.module.ts.eta +19 -0
  102. package/templates/nest/src/simple-app/.core/features/maintenance/maintenance.service.ts.eta +86 -0
  103. package/templates/nest/src/simple-app/.core/features/maintenance/schemas/environment.ts.eta +23 -0
  104. package/templates/nest/src/{simpleapp/maintenance/apischemas → simple-app/.core/features/maintenance/schemas}/index.ts.eta +1 -1
  105. package/templates/nest/src/simple-app/.core/features/mini-app/developer-portal/developer-portal-bridge.service.ts.eta.eta +31 -0
  106. package/templates/nest/src/simple-app/.core/features/mini-app/developer-portal/developer-portal-env-development.service.ts.eta +124 -0
  107. package/templates/nest/src/simple-app/.core/features/mini-app/developer-portal/developer-portal-env-production.service.ts.eta +50 -0
  108. package/templates/nest/src/simple-app/.core/features/mini-app/developer-portal/developer-portal.controller.ts.eta +41 -0
  109. package/templates/nest/src/simple-app/.core/features/mini-app/developer-portal/developer-portal.schema.ts.eta +18 -0
  110. package/templates/nest/src/simple-app/.core/features/mini-app/developer-portal/developer-portal.service.ts.eta +94 -0
  111. package/templates/nest/src/simple-app/.core/features/mini-app/developer-portal/dto/developer-portal-create-app.dto.ts.eta +22 -0
  112. package/templates/nest/src/simple-app/.core/features/mini-app/developer-portal/dto/developer-portal-publish-app.dto.ts.eta +0 -0
  113. package/templates/nest/src/simple-app/.core/features/mini-app/dto/imports.ts.eta +2 -0
  114. package/templates/nest/src/simple-app/.core/features/mini-app/dto/index.ts.eta +2 -0
  115. package/templates/nest/src/simple-app/.core/features/mini-app/dto/mini-app.ts.eta +55 -0
  116. package/templates/nest/src/simple-app/.core/features/mini-app/mini-app-manager/mini-app-manager-bridge.service.ts.eta +162 -0
  117. package/templates/nest/src/simple-app/.core/features/mini-app/mini-app-manager/mini-app-manager-env-development.service.ts.eta +140 -0
  118. package/templates/nest/src/simple-app/.core/features/mini-app/mini-app-manager/mini-app-manager-env-production.service.ts.eta +125 -0
  119. package/templates/nest/src/simple-app/.core/features/mini-app/mini-app-manager/mini-app-manager-policy.service.ts.eta +43 -0
  120. package/templates/nest/src/simple-app/.core/features/mini-app/mini-app-manager/mini-app-manager.controller.ts.eta +81 -0
  121. package/templates/nest/src/simple-app/.core/features/mini-app/mini-app-manager/mini-app-manager.enum.ts.eta +5 -0
  122. package/templates/nest/src/simple-app/.core/features/mini-app/mini-app-manager/mini-app-manager.error.ts.eta +24 -0
  123. package/templates/nest/src/simple-app/.core/features/mini-app/mini-app-manager/mini-app-manager.processor.ts.eta +309 -0
  124. package/templates/nest/src/simple-app/.core/features/mini-app/mini-app-manager/mini-app-manager.service.ts.eta +346 -0
  125. package/templates/nest/src/simple-app/.core/features/mini-app/mini-app-scope/mini-app-scope.decorator.ts.eta +5 -0
  126. package/templates/nest/src/simple-app/.core/features/mini-app/mini-app-scope/mini-app-scope.guard.ts.eta +43 -0
  127. package/templates/nest/src/simple-app/.core/features/mini-app/mini-app-scope/mini-app-scope.service.ts.eta +101 -0
  128. package/templates/nest/src/simple-app/.core/features/mini-app/mini-app.module.ts.eta +24 -0
  129. package/templates/nest/src/simple-app/.core/features/mini-app/types/miniApp.ts.eta +23 -0
  130. package/templates/nest/src/simple-app/.core/features/mini-app/utils/mini-app.util.ts.eta +26 -0
  131. package/templates/nest/src/simple-app/.core/features/policy/policy.module.ts.eta +12 -0
  132. package/templates/nest/src/simple-app/.core/features/policy/policy.service.ts.eta +45 -0
  133. package/templates/nest/src/{simpleapp/profile/profile.controller.ts._eta → simple-app/.core/features/profile/profile.controller.ts.eta} +37 -83
  134. package/templates/nest/src/simple-app/.core/features/profile/profile.module.ts.eta +22 -0
  135. package/templates/nest/src/simple-app/.core/features/profile/profile.schema.ts.eta +165 -0
  136. package/templates/nest/src/{simpleapp/profile/profile.service.ts._eta → simple-app/.core/features/profile/profile.service.ts.eta} +36 -48
  137. package/templates/nest/src/simple-app/.core/features/queue/queue-base/queue-base.consumer.ts.eta +196 -0
  138. package/templates/nest/src/simple-app/.core/features/queue/queue-base/queue-base.producer.ts.eta +147 -0
  139. package/templates/nest/src/simple-app/.core/features/queue/queue-user-context/queue-user-context.service.ts.eta +35 -0
  140. package/templates/nest/src/simple-app/.core/features/queue/queue.module.ts.eta +24 -0
  141. package/templates/nest/src/simple-app/.core/features/queue/queue.type.ts.eta +75 -0
  142. package/templates/nest/src/simple-app/.core/features/simple-app-core-features.module.ts.eta +51 -0
  143. package/templates/nest/src/{simpleapp/generate/commons/robotuser.service.ts.eta → simple-app/.core/features/user-context/robot-user.service.ts.eta} +27 -16
  144. package/templates/nest/src/simple-app/.core/features/user-context/user-context.module.ts.eta +24 -0
  145. package/templates/nest/src/simple-app/.core/features/user-context/user-context.type.ts.eta +15 -0
  146. package/templates/nest/src/{simpleapp/generate/commons → simple-app/.core/features/user-context}/user.context.ts.eta +469 -449
  147. package/templates/nest/src/{simpleapp/generate/commons/runwebhook.service.ts.eta → simple-app/.core/features/webhook/run-webhook.service.ts.eta} +7 -11
  148. package/templates/nest/src/simple-app/.core/features/webhook/schemas/index.ts.eta +2 -0
  149. package/templates/nest/src/simple-app/.core/features/webhook/schemas/webhook-log.schema.ts.eta +116 -0
  150. package/templates/nest/src/simple-app/.core/features/webhook/schemas/webhook.schema.ts.eta +177 -0
  151. package/templates/nest/src/simple-app/.core/features/webhook/webhook.module.ts.eta +20 -0
  152. package/templates/nest/src/{simpleapp/generate/controllers/simpleapp.controller.ts.eta → simple-app/.core/framework/base/simple-app.controller.ts.eta} +13 -35
  153. package/templates/nest/src/{simpleapp/generate/processors/simpleapp.processor.ts.eta → simple-app/.core/framework/base/simple-app.service.ts.eta} +239 -139
  154. package/templates/nest/src/simple-app/.core/framework/custom-exception.ts.eta +26 -0
  155. package/templates/nest/src/simple-app/.core/framework/framework.module.ts.eta +12 -0
  156. package/templates/nest/src/simple-app/.core/framework/schemas/index.ts.eta +3 -0
  157. package/templates/nest/src/simple-app/.core/framework/schemas/others.schema.ts.eta +153 -0
  158. package/templates/nest/src/simple-app/.core/framework/schemas/simple-app.schema.ts.eta +172 -0
  159. package/templates/nest/src/{simpleapp/generate/commons/interceptors/response.interceptor.ts.eta → simple-app/.core/framework/simple-app.interceptor.ts.eta} +12 -22
  160. package/templates/nest/src/{simpleapp/generate/commons/middlewares/tenant.middleware.ts.eta → simple-app/.core/framework/simple-app.middleware.ts.eta} +28 -26
  161. package/templates/nest/src/simple-app/.core/readme.md.eta +3 -0
  162. package/templates/nest/src/simple-app/.core/resources/core-resources.module.ts.eta +38 -0
  163. package/templates/nest/src/simple-app/.core/simple-app-core.module.ts.eta +18 -0
  164. package/templates/nest/src/simple-app/.core/utils/dayjs.ts.eta +47 -0
  165. package/templates/nest/src/simple-app/.core/utils/locale-tool.ts.eta +11 -0
  166. package/templates/nest/src/simple-app/.core/utils/string-utils.ts.eta +1 -0
  167. package/templates/nest/src/simple-app/.resources/readme.md.eta +3 -0
  168. package/templates/nest/src/simple-app/.resources/resources.module.ts.eta +36 -0
  169. package/templates/nest/src/simple-app/apis/readme.md.eta +9 -0
  170. package/templates/nest/src/simple-app/apis/resource-api.module.ts.eta +37 -0
  171. package/templates/nest/src/simple-app/events/branch-event/branch-event.module.ts._eta +20 -0
  172. package/templates/nest/src/simple-app/events/branch-event/branch-event.service.ts._eta +43 -0
  173. package/templates/nest/src/simple-app/events/branch-event/branch-event.type.ts._eta +7 -0
  174. package/templates/nest/src/simple-app/events/events.module.ts._eta +17 -0
  175. package/templates/nest/src/simple-app/events/organization-event/organization-event.module.ts._eta +13 -0
  176. package/templates/nest/src/simple-app/events/organization-event/organization-event.service.ts._eta +52 -0
  177. package/templates/nest/src/simple-app/events/organization-event/organization-event.type.ts._eta +1 -0
  178. package/templates/nest/src/simple-app/events/permission-event/permission-event.module.ts.eta +11 -0
  179. package/templates/nest/src/simple-app/events/permission-event/permission-event.service.ts.eta +33 -0
  180. package/templates/nest/src/simple-app/events/permission-event/permission-event.type.ts.eta +1 -0
  181. package/templates/nest/src/simple-app/events/readme.md.eta +76 -0
  182. package/templates/nest/src/simple-app/events/tenant-event/tenant-event.module.ts_eta +12 -0
  183. package/templates/nest/src/simple-app/events/tenant-event/tenant-event.service.ts_eta +30 -0
  184. package/templates/nest/src/simple-app/events/tenant-event/tenant-event.type.ts_eta +1 -0
  185. package/templates/nest/src/{simpleapp/additional.module.ts._eta → simple-app/features/features.module.ts._eta} +8 -7
  186. package/templates/nest/src/{printapi/printapi.module.ts.eta → simple-app/features/print/print.module.ts.eta} +4 -4
  187. package/templates/nest/src/{printapi/printapi.service.ts.eta → simple-app/features/print/print.service.ts.eta} +7 -7
  188. package/templates/nest/src/simple-app/features/readme.md._eta +6 -0
  189. package/templates/nest/src/simple-app/simple-app.module.ts.eta +32 -0
  190. package/templates/nuxt/.env._eta +2 -0
  191. package/templates/nuxt/app.vue.eta +15 -7
  192. package/templates/nuxt/components/header/HeaderSelectBranch.vue.eta +2 -1
  193. package/templates/nuxt/components/image/ImageAvatar.vue._eta +63 -0
  194. package/templates/nuxt/components/image/ImageOrganization.vue._eta +77 -0
  195. package/templates/nuxt/components/simpleApp/SimpleAppForm.vue.eta +1 -1
  196. package/templates/nuxt/components/simpleApp/SimpleAppFormToolBar.vue._eta +95 -20
  197. package/templates/nuxt/components/user/UserButtonCreateTenant.vue._eta +20 -21
  198. package/templates/nuxt/components/user/UserTenantPicker.vue._eta +1 -1
  199. package/templates/nuxt/composables/docformat.generate.ts.eta +4 -2
  200. package/templates/nuxt/enums/enums.generate.ts.eta +1 -1
  201. package/templates/nuxt/middleware/30.acl.global.ts.eta +6 -6
  202. package/templates/nuxt/nuxt.config.ts._eta +1 -0
  203. package/templates/nuxt/pages/login.vue._eta +21 -15
  204. package/templates/nuxt/pages/profile.vue._eta +24 -32
  205. package/templates/nuxt/plugins/20.simpleapp-userstore.ts.eta +31 -24
  206. package/templates/nuxt/plugins/50.simpleapp-client.ts.eta +2 -2
  207. package/templates/nuxt/providers/my-provider.ts.eta +5 -6
  208. package/templates/nuxt/simpleapp/generate/clients/SimpleAppClient.ts.eta +1 -0
  209. package/templates/nuxt/simpleapp/generate/defaults/index.ts.eta +1 -1
  210. package/templates/nuxt/simpleapp/generate/types/index.ts.eta +1 -1
  211. package/templates/nuxt/types/schema.ts.eta +1 -0
  212. package/templates/nuxt/types/user.ts.eta +39 -38
  213. package/templates/project/build.sh.eta +2 -2
  214. package/templates/basic/nest/apischema.ts.eta +0 -96
  215. package/templates/basic/nest/processor.ts.eta +0 -86
  216. package/templates/nest/src/cloudapi/cloudapi.module.ts._eta +0 -15
  217. package/templates/nest/src/cloudapi/cloudapi.service.ts._eta +0 -15
  218. package/templates/nest/src/enums/enums.generate.ts.eta +0 -23
  219. package/templates/nest/src/simpleapp/apischemas/index.ts._eta +0 -85
  220. package/templates/nest/src/simpleapp/generate/apischemas/index.ts.eta +0 -15
  221. package/templates/nest/src/simpleapp/generate/apischemas/simpleapp.apischema.ts.eta +0 -62
  222. package/templates/nest/src/simpleapp/generate/commons/audittrail.service.ts.eta +0 -52
  223. package/templates/nest/src/simpleapp/generate/commons/customkeycloa.guard.ts.eta +0 -45
  224. package/templates/nest/src/simpleapp/generate/commons/docnogenerator.service.ts.eta +0 -129
  225. package/templates/nest/src/simpleapp/generate/commons/providers/workflow.provider.ts.etax +0 -87
  226. package/templates/nest/src/simpleapp/generate/jsonschemas/index.ts.eta +0 -11
  227. package/templates/nest/src/simpleapp/generate/models/apievent.model.ts.eta +0 -27
  228. package/templates/nest/src/simpleapp/generate/processors/autoinc.processor.ts.eta +0 -88
  229. package/templates/nest/src/simpleapp/generate/processors/branch.processor.ts.eta +0 -110
  230. package/templates/nest/src/simpleapp/generate/processors/docno.processor.ts.eta +0 -77
  231. package/templates/nest/src/simpleapp/generate/processors/org.processor.ts.eta +0 -110
  232. package/templates/nest/src/simpleapp/generate/processors/perm.processor.ts.eta +0 -71
  233. package/templates/nest/src/simpleapp/generate/processors/sysmsg.processor.ts.eta +0 -49
  234. package/templates/nest/src/simpleapp/generate/processors/tenant.processor.ts.eta +0 -52
  235. package/templates/nest/src/simpleapp/generate/processors/webhooklog.processor.ts.eta +0 -45
  236. package/templates/nest/src/simpleapp/generate/types/index.ts.eta +0 -7
  237. package/templates/nest/src/simpleapp/generate/types/schema.type.ts.eta +0 -193
  238. package/templates/nest/src/simpleapp/generate/types/simpleapp.type.ts.eta +0 -299
  239. package/templates/nest/src/simpleapp/generate/types/workflow.type.ts.eta +0 -15
  240. package/templates/nest/src/simpleapp/generate/workflow/formschema/SimpleApproveReject.ts.eta +0 -8
  241. package/templates/nest/src/simpleapp/generate/workflow/formschema/index.ts.eta +0 -7
  242. package/templates/nest/src/simpleapp/generate/workflow/workflow.apischema.ts.eta +0 -136
  243. package/templates/nest/src/simpleapp/generate/workflow/workflow.config.ts.eta +0 -79
  244. package/templates/nest/src/simpleapp/generate/workflow/workflow.controller.ts.eta +0 -414
  245. package/templates/nest/src/simpleapp/generate/workflow/workflow.delegate.ts.eta +0 -201
  246. package/templates/nest/src/simpleapp/generate/workflow/workflow.service.ts.eta +0 -641
  247. package/templates/nest/src/simpleapp/generate/workflow/workflow.type.ts.eta +0 -98
  248. package/templates/nest/src/simpleapp/generate/workflow/workflow.userservice.ts.eta +0 -83
  249. package/templates/nest/src/simpleapp/maintenance/apischemas/environment.ts.eta +0 -11
  250. package/templates/nest/src/simpleapp/maintenance/maintenance.controller.ts.eta +0 -72
  251. package/templates/nest/src/simpleapp/maintenance/maintenance.service.ts.eta +0 -88
  252. package/templates/nest/src/simpleapp/maintenance/models/environment.model.ts.eta +0 -16
  253. package/templates/nest/src/simpleapp/profile/profile.apischema.ts._eta +0 -95
  254. package/templates/nest/src/simpleapp/resolvers/readme.md.eta +0 -1
  255. package/templates/nest/src/simpleapp/services/autoinc.service.ts.etaxx +0 -59
  256. package/templates/nest/src/simpleapp/services/branch.service.ts.etaxxx +0 -83
  257. package/templates/nest/src/simpleapp/services/docno.service.ts.etaxxx +0 -59
  258. package/templates/nest/src/simpleapp/services/org.service.ts.etaxxx +0 -37
  259. package/templates/nest/src/simpleapp/services/perm.service.ts.etaxxx +0 -56
  260. package/templates/nest/src/simpleapp/services/sysmsg.service.ts._etaxxx +0 -43
  261. package/templates/nest/src/simpleapp/services/tenant.service.ts.etaxxx +0 -38
  262. package/templates/nest/src/simpleapp/services/user.service.ts.eta.old +0 -118
  263. package/templates/nest/src/simpleapp/services/userresolver.service.ts._eta +0 -67
  264. package/templates/nest/src/simpleapp/services/webhook.service.ts._eta +0 -37
  265. package/templates/nest/src/simpleapp/simpleapp.module.ts.eta +0 -85
  266. package/templates/nest/src/simpleapp/types/index.ts._eta +0 -45
  267. package/templates/nest/src/simpleapp/webhooks/branch.ts._eta +0 -44
  268. package/templates/nest/src/simpleapp/webhooks/index.ts._eta +0 -21
  269. package/templates/nest/src/simpleapp/workflows/bpmn/readme.md._eta +0 -1
  270. package/templates/nest/src/simpleapp/workflows/listeners/simpleapp.listener.ts.eta +0 -31
  271. package/templates/nest/src/simpleapp/workflows/readme.md._eta +0 -1
  272. package/templates/nuxt/components/image/ImageAvatar.vue.eta +0 -56
  273. package/templates/nuxt/components/image/ImageOrganization.vue.eta +0 -66
  274. /package/src/buildinschemas/{webhook.ts → webhook.ts.backup} +0 -0
  275. /package/src/buildinschemas/{webhooklog.ts → webhooklog.ts.backup} +0 -0
  276. /package/templates/basic/nest/{type.ts.eta → type.ts.eta-backup} +0 -0
  277. /package/templates/nest/src/{simpleapp/generate/commons/customkeycloak.guard.ts.eta → simple-app/.core/features/auth/keycloak/keycloak.guard.ts.eta} +0 -0
  278. /package/templates/nest/src/{simpleapp/generate/commons/roles → simple-app/.core/features/auth/role-guard}/roles.decorator.ts.eta +0 -0
  279. /package/templates/nest/src/{simpleapp/generate/commons/roles → simple-app/.core/features/auth/role-guard}/roles.group.ts.eta +0 -0
  280. /package/templates/nest/src/{simpleapp/generate/commons/dicts/documents.ts.eta → simple-app/.core/features/document-no-format/document.dict.ts.eta} +0 -0
  281. /package/templates/nest/src/{simpleapp/generate/commons/dicts/foreignkeys.ts.eta → simple-app/.core/features/foreign-key/foreignkeys.dict.ts.eta} +0 -0
  282. /package/templates/nest/src/{simpleapp/maintenance/dbupdate → simple-app/.core/features/maintenance/db-update}/1.00.00/index.ts._eta +0 -0
  283. /package/templates/nest/src/{simpleapp/maintenance/dbupdate → simple-app/.core/features/maintenance/db-update}/index.ts._eta +0 -0
  284. /package/templates/nest/src/{simpleapp/maintenance/apischemas/dbupdate.ts.eta → simple-app/.core/features/maintenance/schemas/db-update.ts.eta} +0 -0
  285. /package/templates/nest/src/{simpleapp/profile/profile.types.ts.eta → simple-app/.core/features/profile/profile.types.ts.eta-backup} +0 -0
  286. /package/templates/nest/src/{simpleapp/generate/commons/decorators → simple-app/.core/features/user-context}/appuser.decorator.ts.eta +0 -0
  287. /package/templates/nest/src/{simpleapp/generate/commons/exceptions/SimpleAppExceptionFilter.ts.eta → simple-app/.core/framework/exception-filter.ts.eta} +0 -0
  288. /package/templates/nest/src/{simpleapp/generate/commons → simple-app/.core/utils}/encryption.static.ts.eta +0 -0
  289. /package/templates/nest/src/{simpleapp → simple-app}/.gitignore.eta +0 -0
  290. /package/templates/nest/src/{printapi → simple-app/features/print}/api/.gitignore.eta +0 -0
  291. /package/templates/nest/src/{printapi → simple-app/features/print}/api/.npmignore.eta +0 -0
  292. /package/templates/nest/src/{printapi → simple-app/features/print}/api/.openapi-generator/FILES.eta +0 -0
  293. /package/templates/nest/src/{printapi → simple-app/features/print}/api/.openapi-generator/VERSION.eta +0 -0
  294. /package/templates/nest/src/{printapi → simple-app/features/print}/api/.openapi-generator-ignore.eta +0 -0
  295. /package/templates/nest/src/{printapi → simple-app/features/print}/api/api.ts.eta +0 -0
  296. /package/templates/nest/src/{printapi → simple-app/features/print}/api/base.ts.eta +0 -0
  297. /package/templates/nest/src/{printapi → simple-app/features/print}/api/common.ts.eta +0 -0
  298. /package/templates/nest/src/{printapi → simple-app/features/print}/api/configuration.ts.eta +0 -0
  299. /package/templates/nest/src/{printapi → simple-app/features/print}/api/git_push.sh.eta +0 -0
  300. /package/templates/nest/src/{printapi → simple-app/features/print}/api/index.ts.eta +0 -0
  301. /package/templates/nest/src/{printapi → simple-app/features/print}/api/openapitools.json.eta +0 -0
  302. /package/templates/project/{sharelibs → share-libs}/hello.ts._eta +0 -0
  303. /package/templates/project/{sharelibs → share-libs}/index.ts.eta +0 -0
  304. /package/templates/project/{sharelibs → share-libs}/money.ts.eta +0 -0
  305. /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
+ }
@@ -0,0 +1,2 @@
1
+ export * from '../../../resources/mini-app-installation/mini-app-installation.schema';
2
+ export * from '../../../resources/mini-app/mini-app.schema';
@@ -0,0 +1,2 @@
1
+ export * from './mini-app';
2
+ export * from './imports'
@@ -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
+ }