@simitgroup/simpleapp-generator 1.0.32 → 1.0.35

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 (281) hide show
  1. package/.vscode/settings.json +3 -0
  2. package/README.md +185 -16
  3. package/buildinschemas copy/autoincreament.autoinc.jsonschema.json +39 -0
  4. package/buildinschemas copy/branch.branch.jsonschema.json +41 -0
  5. package/buildinschemas copy/docnoformat.docno.jsonschema.json +41 -0
  6. package/buildinschemas copy/organization.org.jsonschema.json +50 -0
  7. package/buildinschemas copy/permission.perm.jsonschema.json +23 -0
  8. package/buildinschemas copy/permission.perm.jsonschema.try.json +25 -0
  9. package/buildinschemas copy/tenant.tenant.jsonschema.json +21 -0
  10. package/buildinschemas copy/tenant.tenant.jsonschema.try.json +27 -0
  11. package/buildinschemas copy/user.user.jsonschema.json +31 -0
  12. package/dist/buildinschemas/autoincreament.d.ts +3 -0
  13. package/dist/buildinschemas/autoincreament.d.ts.map +1 -0
  14. package/dist/buildinschemas/autoincreament.js +36 -0
  15. package/dist/buildinschemas/autoincreament.js.map +1 -0
  16. package/dist/buildinschemas/branch.d.ts +3 -0
  17. package/dist/buildinschemas/branch.d.ts.map +1 -0
  18. package/dist/buildinschemas/branch.js +41 -0
  19. package/dist/buildinschemas/branch.js.map +1 -0
  20. package/dist/buildinschemas/docnoformat.d.ts +3 -0
  21. package/dist/buildinschemas/docnoformat.d.ts.map +1 -0
  22. package/dist/buildinschemas/docnoformat.js +60 -0
  23. package/dist/buildinschemas/docnoformat.js.map +1 -0
  24. package/dist/buildinschemas/index.d.ts +8 -0
  25. package/dist/buildinschemas/index.d.ts.map +1 -0
  26. package/dist/buildinschemas/index.js +18 -0
  27. package/dist/buildinschemas/index.js.map +1 -0
  28. package/dist/buildinschemas/organization.d.ts +3 -0
  29. package/dist/buildinschemas/organization.d.ts.map +1 -0
  30. package/dist/buildinschemas/organization.js +34 -0
  31. package/dist/buildinschemas/organization.js.map +1 -0
  32. package/dist/buildinschemas/permission.d.ts +3 -0
  33. package/dist/buildinschemas/permission.d.ts.map +1 -0
  34. package/dist/buildinschemas/permission.js +34 -0
  35. package/dist/buildinschemas/permission.js.map +1 -0
  36. package/dist/buildinschemas/tenant.d.ts +3 -0
  37. package/dist/buildinschemas/tenant.d.ts.map +1 -0
  38. package/dist/buildinschemas/tenant.js +41 -0
  39. package/dist/buildinschemas/tenant.js.map +1 -0
  40. package/dist/buildinschemas/user.d.ts +3 -0
  41. package/dist/buildinschemas/user.d.ts.map +1 -0
  42. package/dist/buildinschemas/user.js +31 -0
  43. package/dist/buildinschemas/user.js.map +1 -0
  44. package/dist/constant.d.ts +4 -0
  45. package/dist/constant.d.ts.map +1 -0
  46. package/dist/constant.js +2 -1
  47. package/dist/constant.js.map +1 -1
  48. package/dist/framework.d.ts +10 -0
  49. package/dist/framework.d.ts.map +1 -0
  50. package/dist/framework.js +120 -68
  51. package/dist/framework.js.map +1 -1
  52. package/dist/generate-allow-changebackend.js +305 -0
  53. package/dist/generate-allow-changebackend.js.map +1 -0
  54. package/dist/generate.d.ts +2 -0
  55. package/dist/generate.d.ts.map +1 -0
  56. package/dist/generate.js +310 -230
  57. package/dist/generate.js.map +1 -1
  58. package/dist/index.d.ts +3 -0
  59. package/dist/index.d.ts.map +1 -0
  60. package/dist/index.js +84 -20
  61. package/dist/index.js.map +1 -1
  62. package/dist/libs.d.ts +2 -0
  63. package/dist/libs.d.ts.map +1 -0
  64. package/dist/processors/groupsbuilder.js +2 -0
  65. package/dist/processors/groupsbuilder.js.map +1 -0
  66. package/dist/processors/jsonschemabuilder.d.ts +4 -0
  67. package/dist/processors/jsonschemabuilder.d.ts.map +1 -0
  68. package/dist/processors/jsonschemabuilder.js +146 -172
  69. package/dist/processors/jsonschemabuilder.js.map +1 -1
  70. package/dist/schematype/baseschema.js +25 -0
  71. package/dist/schematype/baseschema.js.map +1 -0
  72. package/dist/schematype/default.js +2 -0
  73. package/dist/schematype/default.js.map +1 -0
  74. package/dist/schematype/index.js +12 -0
  75. package/dist/schematype/index.js.map +1 -0
  76. package/dist/schematype/primarymasterdata.js +38 -0
  77. package/dist/schematype/primarymasterdata.js.map +1 -0
  78. package/dist/schematype/simple.js +24 -0
  79. package/dist/schematype/simple.js.map +1 -0
  80. package/dist/schematype/simplemasterdata.js +31 -0
  81. package/dist/schematype/simplemasterdata.js.map +1 -0
  82. package/dist/schematype/transaction.js +74 -0
  83. package/dist/schematype/transaction.js.map +1 -0
  84. package/dist/storage.d.ts +3 -0
  85. package/dist/storage.d.ts.map +1 -0
  86. package/dist/storage.js +2 -2
  87. package/dist/storage.js.map +1 -1
  88. package/dist/type.d.ts +164 -0
  89. package/dist/type.d.ts.map +1 -0
  90. package/dist/type.js +16 -1
  91. package/dist/type.js.map +1 -1
  92. package/dist/validation.d.ts +1 -0
  93. package/dist/validation.d.ts.map +1 -0
  94. package/documentation/designconcept.bpmn +349 -0
  95. package/documentation/documentation.png +0 -0
  96. package/documentation/infra.drawio +141 -0
  97. package/documentation/infra.png +0 -0
  98. package/documentation/management.drawio +57 -0
  99. package/documentation/stack.drawio +106 -0
  100. package/package.json +3 -1
  101. package/src/buildinschemas/autoincreament.ts +34 -0
  102. package/src/buildinschemas/branch.ts +39 -0
  103. package/src/buildinschemas/docnoformat.ts +58 -0
  104. package/src/buildinschemas/index.ts +7 -0
  105. package/src/buildinschemas/organization.ts +31 -0
  106. package/src/buildinschemas/permission.ts +31 -0
  107. package/src/buildinschemas/tenant.ts +38 -0
  108. package/src/buildinschemas/user.ts +28 -0
  109. package/src/constant.ts +2 -1
  110. package/src/framework.ts +126 -67
  111. package/src/generate.ts +327 -266
  112. package/src/generate.ts.backup +339 -0
  113. package/src/index.ts +93 -18
  114. package/src/processors/jsonschemabuilder.ts +199 -226
  115. package/src/processors/jsonschemabuilder.ts-old +383 -0
  116. package/src/storage.ts +1 -1
  117. package/src/type.ts +94 -27
  118. package/templates/basic/nest/controller.ts.eta +255 -0
  119. package/templates/basic/nest/default.ts.eta +42 -0
  120. package/templates/basic/{model.eta → nest/model.ts.eta} +18 -5
  121. package/templates/basic/nest/processor.ts.eta +129 -0
  122. package/templates/basic/nest/service.ts.eta +64 -0
  123. package/templates/basic/{type.eta → nest/type.ts.eta} +3 -3
  124. package/templates/basic/nuxt/default.ts.eta +42 -0
  125. package/templates/basic/{pageindex.vue.eta → nuxt/pages.crud.vue.eta} +85 -22
  126. package/templates/basic/nuxt/simpleapp.doc.ts.eta +11 -0
  127. package/templates/basic/nuxt/simpleapp.generate.client.ts.eta +212 -0
  128. package/templates/nest/.env.eta +31 -0
  129. package/templates/nest/.gitignore.eta +40 -0
  130. package/templates/nest/src/app.controller.ts.eta +19 -0
  131. package/templates/nest/src/app.module.ts.eta +77 -0
  132. package/templates/nest/src/app.service.ts.eta +9 -0
  133. package/templates/nest/src/main.ts.eta +58 -0
  134. package/templates/nest/src/simpleapp/generate/apischemas/index.ts.eta +16 -0
  135. package/templates/nest/src/simpleapp/generate/commons/decorators/appuser.decorator.ts.eta +8 -0
  136. package/templates/nest/src/simpleapp/generate/commons/dicts/foreignkeys.ts.eta +1 -0
  137. package/templates/nest/src/simpleapp/generate/commons/docnogenerator.service.ts.eta +101 -0
  138. package/templates/nest/src/simpleapp/generate/commons/exceptions/SimpleAppExceptionFilter.ts.eta +39 -0
  139. package/templates/nest/src/simpleapp/generate/commons/interceptors/response.interceptor.ts.eta +38 -0
  140. package/templates/nest/src/simpleapp/generate/commons/middlewares/tenant.middleware.ts.eta +88 -0
  141. package/templates/nest/{Workflow.eta → src/simpleapp/generate/commons/providers/workflow.provider.ts.etax} +20 -14
  142. package/templates/nest/src/simpleapp/generate/commons/roles/roles.decorator.ts.eta +6 -0
  143. package/templates/nest/src/simpleapp/generate/commons/roles/roles.enum.ts.eta +28 -0
  144. package/templates/nest/src/simpleapp/generate/commons/roles/roles.group.ts.eta +10 -0
  145. package/templates/nest/src/simpleapp/generate/commons/roles/roles.guard.ts.eta +34 -0
  146. package/templates/nest/src/simpleapp/generate/commons/user.context.ts.eta +391 -0
  147. package/templates/nest/src/simpleapp/generate/controllers/simpleapp.controller.ts.eta +71 -0
  148. package/templates/nest/src/simpleapp/generate/models/perm.model.ts.eta +53 -0
  149. package/templates/nest/src/simpleapp/generate/models/tenant.model.ts.eta +45 -0
  150. package/templates/nest/src/simpleapp/generate/models/user.model.ts.eta +57 -0
  151. package/templates/nest/src/simpleapp/generate/processors/simpleapp.processor.ts.eta +624 -0
  152. package/templates/nest/src/simpleapp/generate/types/index.ts.eta +19 -0
  153. package/templates/nest/src/simpleapp/profile/profile.apischema.ts.eta +74 -0
  154. package/templates/nest/src/simpleapp/profile/profile.controller.ts.eta +110 -0
  155. package/templates/nest/src/simpleapp/profile/profile.service.ts.eta +195 -0
  156. package/templates/nest/src/simpleapp/profile/profile.types.ts.eta +18 -0
  157. package/templates/nest/src/simpleapp/services/autoinc.service.ts.eta +89 -0
  158. package/templates/nest/src/simpleapp/services/branch.service.ts.eta +66 -0
  159. package/templates/nest/src/simpleapp/services/docno.service.ts.eta +93 -0
  160. package/templates/nest/src/simpleapp/services/org.service.ts.eta +67 -0
  161. package/templates/nest/src/simpleapp/services/perm.service.ts.eta +102 -0
  162. package/templates/nest/src/simpleapp/services/tenant.service.ts.eta +69 -0
  163. package/templates/nest/src/simpleapp/services/user.service.ts.eta +66 -0
  164. package/templates/nest/src/simpleapp/simpleapp.module.ts.eta +43 -0
  165. package/templates/nuxt/.env.eta +21 -0
  166. package/templates/nuxt/.gitignore.eta +28 -0
  167. package/templates/nuxt/app.vue.eta +5 -2
  168. package/templates/nuxt/assets/css/tailwind.css.eta +35 -0
  169. package/templates/nuxt/components/CrudNestedDoc.vue.eta +164 -0
  170. package/templates/nuxt/components/CrudSimple.vue.eta +179 -0
  171. package/templates/nuxt/{components.debugdocdata.vue.eta → components/DebugDocumentData.vue.eta} +4 -1
  172. package/templates/nuxt/{components.eventmonitor.vue.eta → components/EventMonitor.vue.eta} +27 -27
  173. package/templates/nuxt/components/Invitation.vue.eta +50 -0
  174. package/templates/nuxt/components/Menus.vue.eta +58 -0
  175. package/templates/nuxt/components/PermissionInfo.vue.eta +92 -0
  176. package/templates/nuxt/components/SimpleAppAutocomplete.vue.eta +131 -0
  177. package/templates/nuxt/components/SimpleAppAutocompletemulti.vue.eta +73 -0
  178. package/templates/nuxt/components/SimpleAppCalendar.vue.eta +55 -0
  179. package/templates/nuxt/components/SimpleAppCheckbox.vue.eta +29 -0
  180. package/templates/nuxt/components/SimpleAppChip.vue.eta +28 -0
  181. package/templates/nuxt/components/SimpleAppColor.vue.eta +41 -0
  182. package/templates/nuxt/components/SimpleAppDatatable.vue.eta +20 -0
  183. package/templates/nuxt/components/SimpleAppDocumentNo.vue.eta +90 -0
  184. package/templates/nuxt/components/SimpleAppDynamicInput.vue.eta +29 -0
  185. package/templates/nuxt/components/SimpleAppEditor.vue.eta +31 -0
  186. package/templates/nuxt/components/SimpleAppForm.vue.eta +131 -0
  187. package/templates/nuxt/components/SimpleAppInputTable.vue.eta +104 -0
  188. package/templates/nuxt/components/SimpleAppList.vue.eta +38 -0
  189. package/templates/nuxt/components/SimpleAppListmulti.vue.eta +41 -0
  190. package/templates/nuxt/components/SimpleAppNumber.vue.eta +32 -0
  191. package/templates/nuxt/components/SimpleAppPassword.vue.eta +41 -0
  192. package/templates/nuxt/components/SimpleAppRadio.vue.eta +42 -0
  193. package/templates/nuxt/components/SimpleAppRating.vue.eta +41 -0
  194. package/templates/nuxt/components/SimpleAppSelect.vue.eta +38 -0
  195. package/templates/nuxt/components/SimpleAppSelectmulti.vue.eta +39 -0
  196. package/templates/nuxt/components/SimpleAppSlider.vue.eta +42 -0
  197. package/templates/nuxt/components/SimpleAppSwitch.vue.eta +30 -0
  198. package/templates/nuxt/components/SimpleAppText.vue.eta +50 -0
  199. package/templates/nuxt/components/SimpleAppTextarea.vue.eta +30 -0
  200. package/templates/nuxt/components/SimpleAppValue.vue.eta +86 -0
  201. package/templates/nuxt/components/SimpleFieldContainer.vue.eta +102 -0
  202. package/templates/nuxt/components/XorgPicker.vue.eta +66 -0
  203. package/templates/nuxt/components/helper.ts.eta +90 -0
  204. package/templates/nuxt/components/type.ts.eta +32 -0
  205. package/templates/nuxt/composables/docformat.generate.ts.eta +5 -0
  206. package/templates/nuxt/{composables.getautocomplete.ts.eta → composables/getAutocomplete.generate.ts.eta} +4 -5
  207. package/templates/nuxt/{composables.getmenus.ts.eta → composables/getMenus.generate.ts.eta} +22 -7
  208. package/templates/nuxt/composables/getOpenApi.generate.ts.eta +6 -0
  209. package/templates/nuxt/composables/getTenant.generate.ts.eta +4 -0
  210. package/templates/nuxt/composables/getUserStore.generate.ts.eta +22 -0
  211. package/templates/nuxt/composables/logout.generate.ts.eta +22 -0
  212. package/templates/nuxt/composables/roles.generate.ts.eta +48 -0
  213. package/templates/nuxt/composables/stringHelper.generate.ts.eta +5 -0
  214. package/templates/nuxt/{layouts.default.vue.eta → layouts/default.vue.eta} +2 -0
  215. package/templates/nuxt/middleware/10.acl.global.ts.eta +38 -0
  216. package/templates/nuxt/nuxt.config.ts.eta +12 -2
  217. package/templates/nuxt/pages/[xorg]/branch/index.vue.eta +102 -0
  218. package/templates/nuxt/pages/[xorg]/docnoformat/[id].vue.eta +17 -0
  219. package/templates/nuxt/pages/[xorg]/docnoformat/index.vue.eta +269 -0
  220. package/templates/nuxt/pages/[xorg]/index.vue.eta +36 -0
  221. package/templates/nuxt/pages/[xorg]/organization/index.vue.eta +148 -0
  222. package/templates/nuxt/pages/[xorg]/permission/index.vue.eta +280 -0
  223. package/templates/nuxt/pages/[xorg]/tenant/index.vue.eta +93 -0
  224. package/templates/nuxt/pages/[xorg]/user/index.vue.eta +468 -0
  225. package/templates/nuxt/pages/index.vue.eta +191 -0
  226. package/templates/nuxt/pages/login.vue.eta +21 -0
  227. package/templates/nuxt/plugins/10.simpleapp-event.ts.eta +53 -0
  228. package/templates/nuxt/plugins/20.simpleapp-userstore.ts.eta +155 -0
  229. package/templates/nuxt/plugins/50.simpleapp-client.ts.eta +23 -0
  230. package/templates/nuxt/{server.api.ts.eta → server/api/[xorg]/[...].ts.eta} +5 -2
  231. package/templates/nuxt/server/api/auth/[...].ts.eta +68 -0
  232. package/templates/nuxt/{server.api.auth.logout.ts.eta → server/api/auth/logout.ts.eta} +1 -3
  233. package/templates/nuxt/server/api/profile/[...].ts.eta +150 -0
  234. package/templates/nuxt/server/api/profile/index.ts.eta +103 -0
  235. package/templates/nuxt/simpleapp/generate/clients/SimpleAppClient.ts.eta +187 -0
  236. package/templates/nuxt/simpleapp/generate/commons/documents.ts.eta +6 -0
  237. package/templates/nuxt/simpleapp/generate/commons/events.ts.eta +5 -0
  238. package/templates/nuxt/simpleapp/generate/commons/groups.ts.eta +11 -0
  239. package/templates/nuxt/simpleapp/generate/commons/roles.ts.eta +21 -0
  240. package/templates/nuxt/types/index.ts.eta +65 -0
  241. package/templates/project/README.md +11 -0
  242. package/templates/project/build.sh.eta +17 -0
  243. package/templates/project/config.json.eta +2 -0
  244. package/templates/project/generate.ts.eta +10 -0
  245. package/templates/project/schemas/category.ts.eta +26 -0
  246. package/templates/project/schemas/index.ts.eta +5 -0
  247. package/templates/project/schemas/product.ts.eta +59 -0
  248. package/templates/project/shares/hello.ts.eta +1 -0
  249. package/templates/project/shares/index.ts.eta +2 -0
  250. package/tsconfig.json +9 -2
  251. package/tsconfig.tsbuildinfo +1 -0
  252. package/definations/category.cat.jsonschema.json +0 -55
  253. package/definations/level.lvl.jsonschema.json +0 -48
  254. package/definations/product.prd.jsonschema.json +0 -46
  255. package/templates/basic/controller.eta +0 -152
  256. package/templates/basic/module.eta +0 -22
  257. package/templates/basic/service.eta +0 -62
  258. package/templates/basic/simpleappclient.eta +0 -120
  259. package/templates/nest/SimpleAppController.eta +0 -69
  260. package/templates/nest/SimpleAppService.eta +0 -366
  261. package/templates/nest/TenantMiddleware.eta +0 -34
  262. package/templates/nest/UserProvider.eta +0 -127
  263. package/templates/nest/app.controller.eta +0 -12
  264. package/templates/nest/app.module.eta +0 -64
  265. package/templates/nest/app.service.eta +0 -8
  266. package/templates/nest/inputvalidation-exception.eta +0 -6
  267. package/templates/nest/nest.env.eta +0 -28
  268. package/templates/nest/nest.main.eta +0 -31
  269. package/templates/nuxt/components.crudsimple.vue.eta +0 -124
  270. package/templates/nuxt/components.menus.vue.eta +0 -35
  271. package/templates/nuxt/env.eta +0 -17
  272. package/templates/nuxt/pages.[xorg].index.vue.eta +0 -20
  273. package/templates/nuxt/pages.index.vue.eta +0 -72
  274. package/templates/nuxt/pages.login.vue.eta +0 -20
  275. package/templates/nuxt/plugins.simpleapp.ts.eta +0 -88
  276. package/templates/nuxt/server.api.auth[...].ts.eta +0 -233
  277. package/templates/nuxt/tailwind.css.eta +0 -49
  278. /package/templates/basic/{apischema.eta → nest/apischema.ts.eta} +0 -0
  279. /package/templates/basic/{jsonschema.eta → nest/jsonschema.ts.eta} +0 -0
  280. /package/templates/basic/{pageindexwithid.vue.eta → nuxt/pages.[id].vue.eta} +0 -0
  281. /package/templates/nest/{oauth2-redirect.eta → public_html/oauth2-redirect.html.eta} +0 -0
@@ -0,0 +1,53 @@
1
+ // import { Tailwind } from 'primevue/passthrough/tailwind';
2
+ import Tailwind from "primevue/passthrough/tailwind";
3
+
4
+ // const Base64URL = require('@darkwolf/base64url');
5
+
6
+ /**
7
+ * This file was automatically generated by simpleapp generator during initialization.
8
+ * DO NOT MODIFY IT BY HAND.
9
+ * last change 2023-09-09
10
+ * author: Ks Tan
11
+ */
12
+ import { defineNuxtPlugin } from "#app";
13
+ import axios, { Axios, AxiosResponse } from 'axios'
14
+ import PrimeVue from "primevue/config";
15
+ import mitt from 'mitt'
16
+ import ToastService from 'primevue/toastservice';
17
+ import ConfirmationService from 'primevue/confirmationservice';
18
+ import Tooltip from 'primevue/tooltip';
19
+ const emitter = mitt()
20
+
21
+ export default defineNuxtPlugin( async(nuxtApp) => {
22
+ //const { csrf } = useCsrf()
23
+ //axios.defaults.headers.common = {"CSRF-TOKEN": csrf};
24
+ const myaxios = axios.create()
25
+ myaxios.interceptors.response.use((response) => response, (error) => {
26
+ if(error.response.status==401){
27
+
28
+ console.error("axios 401 session expired, redirect to logout page1")
29
+ // const { signOut } = useAuth();
30
+ // signOut({redirect:false});
31
+ // navigateTo('/login')
32
+ logout()
33
+ }else{
34
+ return Promise.reject(error)
35
+ }
36
+ });
37
+ nuxtApp.vueApp.use(PrimeVue, { ripple: true,Tailwind:true, pt: Tailwind});
38
+ nuxtApp.vueApp
39
+ .use(ToastService)
40
+ .use(ConfirmationService)
41
+ .directive('tooltip', Tooltip)
42
+ ;
43
+
44
+
45
+ return {
46
+ provide: {
47
+ event: emitter.emit, // Will emit an event
48
+ listen: emitter.on, // Will register a listener for an event
49
+ axios: myaxios,
50
+ }
51
+ }
52
+ //other components that you need
53
+ });
@@ -0,0 +1,155 @@
1
+ import { defineNuxtPlugin } from "#app";
2
+ import {PROFILEApi} from '../simpleapp/generate/openapi'
3
+ import axios, { Axios, AxiosResponse } from 'axios'
4
+ import _ from 'lodash'
5
+
6
+ export default defineNuxtPlugin( async(nuxtApp) => {
7
+
8
+
9
+ const useUserStore = defineStore('userstore', {
10
+ state: ()=>({
11
+ tenantId:ref(0),
12
+ orgId:ref(0),
13
+ branchId:ref(0),
14
+ branchCode:ref(''),
15
+ branchName:ref(''),
16
+ uid: ref(''),
17
+ email: ref(''),
18
+ fullName: ref(''),
19
+ roles:ref<string[]>([]),
20
+ group:ref(''),
21
+ branches:ref([]),
22
+ invites : ref([]),
23
+ time:ref('')
24
+ }),
25
+
26
+ actions:{
27
+ async loadRemoteUserInfo(){
28
+ console.log('loadRemoteUserInfo')
29
+ const {$axios} = useNuxtApp()
30
+ const route = useRoute();
31
+ let xorg = route.params.xorg
32
+ let apiurl=''
33
+ if(xorg===undefined){
34
+ apiurl = `${useRuntimeConfig().public.APP_URL}/api`
35
+ }else{
36
+ apiurl = `${useRuntimeConfig().public.APP_URL}/api/${xorg}`
37
+ }
38
+
39
+ return await new PROFILEApi(undefined,apiurl,$axios).getProfile().then((res:AxiosResponse)=>{
40
+ if(!res){
41
+ return
42
+ }
43
+ this.tenantId = res.data.tenantId
44
+ this.orgId = res.data.orgId
45
+ this.branchId = res.data.branchId
46
+ this.branchCode = res.data.branchCode
47
+ this.branchName = res.data.branchName
48
+ this.uid = res.data.uid
49
+ this.email = res.data.email
50
+ this.fullName = res.data.fullName
51
+ this.branches = res.data.branches
52
+ this.group = res.data.group
53
+ this.roles = res.data.roles
54
+ this.time = res.data.time
55
+
56
+ this.invites = res.data.invites
57
+
58
+ return Promise.resolve(true)
59
+ // return true
60
+ }).catch((err:any)=>{
61
+ if(err.response.status==401){
62
+ console.error("Unauthorise(plugin-userstore)")
63
+ //logout()
64
+ }else{
65
+ console.error("Unknown error,", err.response)
66
+ }
67
+ })
68
+ },
69
+ getCurrentXorg(){
70
+ const currentxorg:string = String(useRoute().params.xorg)
71
+ return _.find(this.branches,{xorg:currentxorg})
72
+ },
73
+ async decideInvitation(id:string,decision:string){
74
+ const apiurl = `${useRuntimeConfig().public.APP_URL}/api`
75
+ const {$axios} = useNuxtApp()
76
+ console.log("decideInvitation",id,decision)
77
+ const result = await new PROFILEApi(undefined,apiurl,$axios).decideInvitation(id,decision)
78
+
79
+ if(result){
80
+ console.log(result)
81
+ }else{
82
+ console.log(result)
83
+ }
84
+ //().then((res:AxiosResponse)=>{ }
85
+ },
86
+ canPerform(resourcename:string,action:string):boolean{
87
+
88
+ if(
89
+ this.roles.includes('superadmin') ||
90
+ this.roles.includes('tenantowner') ||
91
+ this.roles.includes('superuser')
92
+ ){
93
+ return true
94
+ }else{
95
+ const checkstr= `${resourcename}:${action}`
96
+ // console.log("verify",checkstr)
97
+ return this.roles.includes(checkstr)
98
+ }
99
+ },
100
+ haveAccess(resourcename:string){
101
+ //super admin always full access right
102
+ resourcename = _.upperFirst(resourcename)
103
+ // console.log("have access",resourcename)
104
+ if(
105
+ this.roles.includes('superadmin') ||
106
+ this.roles.includes('tenantowner') ||
107
+ this.roles.includes('superuser')
108
+ ){
109
+ return true
110
+ }
111
+ for(let i=0; i< this.roles.length; i++){
112
+ const role:string = this.roles[i]
113
+ if(role.includes(resourcename)){
114
+ return true
115
+ }
116
+ }
117
+ return false
118
+ },
119
+ getUserInfo(){
120
+ return {
121
+ tenantId : this.tenantId,
122
+ orgId : this.orgId,
123
+ branchId : this.branchId,
124
+ uid : this.uid,
125
+ email : this.email,
126
+ branchCode: this.branchCode,
127
+ branchName: this.branchName,
128
+ fullName : this.fullName,
129
+ branches:this.branches??[],
130
+ invites: this.invites ?? [],
131
+ roles:this.roles,
132
+ group:this.group,
133
+ time:this.time,
134
+
135
+
136
+ }
137
+ }
138
+ }
139
+ })
140
+
141
+ const route = useRoute();
142
+ if(route.path!='/login'){
143
+ await useUserStore().loadRemoteUserInfo()
144
+ }
145
+
146
+ return {
147
+
148
+
149
+ provide: {
150
+ userstore:useUserStore()
151
+ // base64url: Base64URL
152
+ }
153
+ }
154
+
155
+ });
@@ -0,0 +1,23 @@
1
+ /**
2
+ * This file was automatically generated by simpleapp generator during initialization.
3
+ * DO NOT MODIFY IT BY HAND.
4
+ * last change 2023-09-22
5
+ * author: Ks Tan
6
+ */
7
+ import { defineNuxtPlugin } from "#app";
8
+ <% for(let i=0;i<it.modules.length; i++){ %>
9
+ import {<%=it.modules[i].docname%>Doc} from "../simpleapp/docs/<%=it.modules[i].docname%>Doc"
10
+ <%}%>
11
+
12
+ export default defineNuxtPlugin((nuxtApp) => {
13
+
14
+ return {
15
+ provide: {
16
+ <% for(let i=0;i<it.modules.length; i++){ %>
17
+ <%=it.modules[i].docname%>Doc:()=>new <%=it.modules[i].docname%>Doc(),
18
+ <%}%>
19
+ }
20
+ }
21
+
22
+ //other components that you need
23
+ });
@@ -133,8 +133,11 @@ export default defineEventHandler(async (event) => {
133
133
  }
134
134
 
135
135
  // reject(error.data)
136
- reject({ statusMessage: error.response.statusText, statusCode: error.response.status });
137
- // resolve({ status: 'ok' })
136
+ reject({
137
+ statusMessage: error.response.statusText,
138
+ statusCode: error.response.status ,
139
+ data: error.response.data
140
+ }); // resolve({ status: 'ok' })
138
141
  // throw createError({ statusMessage: 'Bad Requests', statusCode: 404 })
139
142
  })
140
143
 
@@ -0,0 +1,68 @@
1
+ import { NuxtAuthHandler } from "#auth";
2
+ import KeycloakProvider from "next-auth/providers/keycloak";
3
+
4
+
5
+ export default NuxtAuthHandler({
6
+ secret: process.env.AUTH_SECRET_KEY,
7
+ jwt: {
8
+ maxAge: 60 * 60 * 24 * 30,
9
+ },
10
+ providers: [
11
+
12
+ // @ts-expect-error
13
+ KeycloakProvider.default({
14
+ clientId: process.env.OAUTH2_CLIENTID ?? "",
15
+ clientSecret: process.env.OAUTH2_CLIENTSECRET ?? "",
16
+ issuer: process.env.OAUTH2_CONFIGURL,
17
+ idToken: true,
18
+ scheme: "oauth2",
19
+ endpoints: {
20
+ authorization: `${process.env.OAUTH2_CONFIGURL}/protocol/openid-connect/auth`,
21
+ userInfo: `${process.env.OAUTH2_CONFIGURL}/protocol/openid-connect/userinfo`,
22
+ token: `${process.env.OAUTH2_CONFIGURL}/protocol/openid-connect/token`,
23
+ logout:
24
+ `${process.env.OAUTH2_CONFIGURL}/protocol/openid-connect/logout?redirect_uri=` +
25
+ encodeURIComponent(String(process.env.APP_URL)),
26
+ },
27
+ // accessTokenUrl: `${process.env.OAUTH2_CONFIGURL}/protocol/openid-connect/token`,
28
+ // requestTokenUrl: `${process.env.OAUTH2_CONFIGURL}/protocol/openid-connect/token`,
29
+ // profileUrl: `${process.env.OAUTH2_CONFIGURL}/protocol/openid-connect/userinfo`,
30
+ token: {
31
+ property: "access_token",
32
+ type: "Bearer",
33
+ name: "Authorization",
34
+ maxAge: 60 * 60 * 24,
35
+ },
36
+ refreshToken: {
37
+ property: "refresh_token",
38
+ maxAge: 60 * 60 * 24 * 30,
39
+ },
40
+ responseType: "code",
41
+ grantType: "authorization_code",
42
+ scope: ["openid", "profile", "email"],
43
+ codeChallengeMethod: "S256",
44
+ redirect: {
45
+ logout: "/",
46
+ callback: "/",
47
+ home: "/",
48
+ },
49
+ }),
50
+ ],
51
+ pages: {
52
+ signIn: "/login",
53
+ },
54
+ callbacks: {
55
+ async jwt({ token, account }) {
56
+ if (account) {
57
+ token.accessToken = account.access_token;
58
+ }
59
+ return token;
60
+ },
61
+ async session({ session , token, user }) {
62
+ const sessiondata:any = {...session}
63
+ sessiondata.accessToken = <string>token.accessToken;
64
+ return sessiondata;
65
+ },
66
+
67
+ },
68
+ });
@@ -2,9 +2,7 @@
2
2
  export default defineEventHandler(async (event) => {
3
3
  const path = `${
4
4
  process.env.OAUTH2_CONFIGURL
5
- }/protocol/openid-connect/logout?redirect_uri=${encodeURIComponent(
6
- process.env.AUTH_ORIGIN ?? ""
7
- )}`;
5
+ }/protocol/openid-connect/logout?redirect_uri=${encodeURIComponent(process.env.AUTH_ORIGIN??'')}`;
8
6
 
9
7
  return {
10
8
  path: path
@@ -0,0 +1,150 @@
1
+
2
+ /**
3
+ * This file was automatically generated by simpleapp generator during initialization.
4
+ * DO NOT MODIFY IT BY HAND.
5
+ * last change 2023-09-09
6
+ * author: Ks Tan
7
+ */
8
+
9
+
10
+ import axios from 'axios';
11
+ import { getServerSession } from '#auth'
12
+ import type { Session } from 'next-auth';
13
+
14
+ export default defineEventHandler(async (event) => {
15
+ type additionalprops = {accessToken?:string}
16
+ let session:any=null
17
+ // console.log("profile api-------------------------")
18
+
19
+ try {
20
+ session = await getServerSession(event)
21
+
22
+ } catch (error) {
23
+ return sendRedirect(event, '/login', 401)
24
+ }
25
+
26
+ return new Promise<any>(async (resolve, reject) => {
27
+ if(!session) {
28
+ //if(!session || !session.accessToken) {
29
+ reject({ statusMessage: 'Unauthorized', statusCode: 401 });
30
+ throw createError({ statusMessage: 'Unauthorized', statusCode: 401 })
31
+ }
32
+ //console.log("------hihi------",event.context.params)
33
+
34
+ const seperateSymbol = '.';
35
+ // const seperateSymbol = '&';
36
+ // const xOrg = event.context.params?.xorg ?? ''
37
+ const documentLink = event.context.params?._ ?? ''
38
+ // const platform = event.context.params?.platform ?? ''
39
+
40
+
41
+ // console.error("event.context???",event.context)
42
+ const accessToken = session?.accessToken;
43
+
44
+ // const allowPlatform = ['report-api', 'cloudapi'];
45
+ // if(!key || !platform || !allowPlatform.includes(platform) || !accessToken) {
46
+ // reject({ statusMessage: 'Unauthorized', statusCode: 401 });
47
+ // // throw createError({ statusMessage: 'Unauthorized', statusCode: 401 })
48
+ // }
49
+
50
+ // let tenantKey = '', organizationKey = '';
51
+ // let xOrg = '';
52
+
53
+ // if(key !== 'system') {
54
+ // [tenantKey, organizationKey] = key.split(seperateSymbol);
55
+ // xOrg = `${tenantKey}/${organizationKey}/`;
56
+ // }
57
+
58
+ // if(key === 'system' && platform == 'cloudapi') {
59
+ // // xOrg = 'MC0wLTA'
60
+ // }
61
+
62
+ let forwardData: any = {};
63
+
64
+ const req = event.node.req;
65
+
66
+ if(req.method == 'POST' || req.method == 'PUT' || req.method == 'PATCH') {
67
+
68
+ forwardData = await readBody(event);
69
+ } else {
70
+ forwardData = getQuery(event);
71
+ }
72
+
73
+ // if(typeof forwardData === "object" && "_branch" in forwardData) {
74
+ // xOrg = xOrg + forwardData._branch;
75
+ // delete forwardData._branch;
76
+ // }
77
+
78
+ const frontEndRes = event.node.res;
79
+ const url = process.env.SIMPLEAPP_BACKEND_URL + `/profile/${documentLink}`;
80
+ // console.warn('backend server-----',req.method,url,forwardData)
81
+ const axiosConfig: any = {
82
+ method: req.method,
83
+ url: url,
84
+ headers: {
85
+ Authorization: `Bearer ${accessToken}`,
86
+ },
87
+ data: forwardData,
88
+ params: forwardData,
89
+ }
90
+
91
+ // if(key === 'system') {
92
+ // axiosConfig.headers["X-Global"] = true;
93
+ // delete axiosConfig.headers["X-Org"];
94
+ // }
95
+
96
+ // if(otherLink.includes('avatar')) {
97
+ // axiosConfig.responseType = 'arraybuffer';
98
+ // // axiosConfig.headers['Acceptable'] = 'text/html,image/avif,image/webp,image/apng';
99
+ // }
100
+
101
+ axios(axiosConfig).then((res) => {
102
+ if (res.headers['content-type'] === 'image/png') {
103
+ // Set the response headers for the image
104
+ frontEndRes.setHeader('Content-Type', 'image/png');
105
+ frontEndRes.setHeader('Content-Disposition', 'inline');
106
+
107
+ // Send the image data as the response body
108
+ frontEndRes.end(Buffer.from(res.data, 'binary'));
109
+ } else {
110
+ // For non-image responses, set the Content-Type header and send the response body
111
+ // setHeader(event, 'Content-type', <string>res.headers['Content-Type']);
112
+
113
+ frontEndRes.statusCode = res.status;
114
+ if(res.statusText) {
115
+ frontEndRes.statusMessage = res.statusText;
116
+ }
117
+
118
+ resolve(res.data);
119
+ }
120
+
121
+ }).catch((error) => {
122
+ // console.log("==============================================================")
123
+ // console.log('@@@@@@@@@@@@@ API error', error)
124
+ // console.log("@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@")
125
+ // console.log('######### response', error.response)
126
+ // console.log('#####################################')
127
+ // console.log(axiosConfig);
128
+ // console.log('#####################################')
129
+
130
+ if (error.response?.status && error.response.status == '401') {
131
+ //return reject({ statusMessage: 'Unauthorized', statusCode: 401 });
132
+ return sendRedirect(event, '/login', 401)
133
+ // throw createError({ statusMessage: 'Unauthorized', statusCode: 401 })
134
+ }
135
+
136
+ // reject(error.data)
137
+ reject({
138
+ statusMessage: error.response.statusText,
139
+ statusCode: error.response.status ,
140
+ data: error.response.data
141
+ }); // resolve({ status: 'ok' })
142
+ // throw createError({ statusMessage: 'Bad Requests', statusCode: 404 })
143
+ })
144
+
145
+ // resolve({
146
+ // status: 'ok'
147
+ // })
148
+ })
149
+
150
+ })
@@ -0,0 +1,103 @@
1
+
2
+ /**
3
+ * This file was automatically generated by simpleapp generator during initialization.
4
+ * DO NOT MODIFY IT BY HAND.
5
+ * last change 2023-09-09
6
+ * author: Ks Tan
7
+ */
8
+
9
+
10
+ import axios from 'axios';
11
+ import { getServerSession } from '#auth'
12
+ import type { Session } from 'next-auth';
13
+
14
+ export default defineEventHandler(async (event) => {
15
+ type additionalprops = {accessToken?:string}
16
+ let session:any=null
17
+ // console.log("profile api-------------------------")
18
+
19
+ try {
20
+ session = await getServerSession(event)
21
+
22
+ } catch (error) {
23
+ return sendRedirect(event, '/login', 401)
24
+ }
25
+
26
+ return new Promise<any>(async (resolve, reject) => {
27
+ if(!session) {
28
+ reject({ statusMessage: 'Unauthorized', statusCode: 401 });
29
+ throw createError({ statusMessage: 'Unauthorized', statusCode: 401 })
30
+ }
31
+ const seperateSymbol = '.';
32
+ const accessToken = session?.accessToken;
33
+
34
+ let forwardData: any = {};
35
+
36
+ const req = event.node.req;
37
+
38
+ if(req.method == 'POST' || req.method == 'PUT' || req.method == 'PATCH') {
39
+
40
+ forwardData = await readBody(event);
41
+ } else {
42
+ forwardData = getQuery(event);
43
+ }
44
+
45
+
46
+ const frontEndRes = event.node.res;
47
+ const url = process.env.SIMPLEAPP_BACKEND_URL + '/profile';
48
+ const axiosConfig: any = {
49
+ method: req.method,
50
+ url: url,
51
+ headers: {
52
+ Authorization: `Bearer ${accessToken}`,
53
+ },
54
+ data: forwardData,
55
+ params: forwardData,
56
+ }
57
+
58
+ axios(axiosConfig).then((res) => {
59
+ if (res.headers['content-type'] === 'image/png') {
60
+ // Set the response headers for the image
61
+ frontEndRes.setHeader('Content-Type', 'image/png');
62
+ frontEndRes.setHeader('Content-Disposition', 'inline');
63
+
64
+ // Send the image data as the response body
65
+ frontEndRes.end(Buffer.from(res.data, 'binary'));
66
+ } else {
67
+ // For non-image responses, set the Content-Type header and send the response body
68
+ // setHeader(event, 'Content-type', <string>res.headers['Content-Type']);
69
+
70
+ frontEndRes.statusCode = res.status;
71
+ if(res.statusText) {
72
+ frontEndRes.statusMessage = res.statusText;
73
+ }
74
+
75
+ resolve(res.data);
76
+ }
77
+
78
+ }).catch((error) => {
79
+
80
+ // console.log('#####################################')
81
+ // console.log(axiosConfig);
82
+ // console.log('#####################################')
83
+ if (error.response?.status && error.response.status == '401') {
84
+ //return reject({ statusMessage: 'Unauthorized', statusCode: 401 });
85
+ return sendRedirect(event, '/login', 401)
86
+ // throw createError({ statusMessage: 'Unauthorized', statusCode: 401 })
87
+ }
88
+
89
+ // reject(error.data)
90
+ reject({
91
+ statusMessage: error.response.statusText,
92
+ statusCode: error.response.status ,
93
+ data: error.response.data
94
+ }); // resolve({ status: 'ok' })
95
+ // throw createError({ statusMessage: 'Bad Requests', statusCode: 404 })
96
+ })
97
+
98
+ // resolve({
99
+ // status: 'ok'
100
+ // })
101
+ })
102
+
103
+ })