@simitgroup/simpleapp-generator 1.6.6-o-alpha → 1.6.6-q-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 (101) hide show
  1. package/dist/buildinschemas/autoincreament.d.ts.map +1 -1
  2. package/dist/buildinschemas/autoincreament.js +17 -14
  3. package/dist/buildinschemas/autoincreament.js.map +1 -1
  4. package/dist/buildinschemas/branch.d.ts.map +1 -1
  5. package/dist/buildinschemas/branch.js +25 -24
  6. package/dist/buildinschemas/branch.js.map +1 -1
  7. package/dist/buildinschemas/changehistories.d.ts.map +1 -1
  8. package/dist/buildinschemas/changehistories.js +10 -9
  9. package/dist/buildinschemas/changehistories.js.map +1 -1
  10. package/dist/buildinschemas/customfield.d.ts.map +1 -1
  11. package/dist/buildinschemas/customfield.js +16 -15
  12. package/dist/buildinschemas/customfield.js.map +1 -1
  13. package/dist/buildinschemas/docnoformat.d.ts.map +1 -1
  14. package/dist/buildinschemas/docnoformat.js +34 -23
  15. package/dist/buildinschemas/docnoformat.js.map +1 -1
  16. package/dist/buildinschemas/documentevent.d.ts.map +1 -1
  17. package/dist/buildinschemas/documentevent.js +36 -26
  18. package/dist/buildinschemas/documentevent.js.map +1 -1
  19. package/dist/buildinschemas/keyvaluepair.d.ts.map +1 -1
  20. package/dist/buildinschemas/keyvaluepair.js +7 -6
  21. package/dist/buildinschemas/keyvaluepair.js.map +1 -1
  22. package/dist/buildinschemas/organization.d.ts.map +1 -1
  23. package/dist/buildinschemas/organization.js +34 -30
  24. package/dist/buildinschemas/organization.js.map +1 -1
  25. package/dist/buildinschemas/permission.d.ts.map +1 -1
  26. package/dist/buildinschemas/permission.js +16 -7
  27. package/dist/buildinschemas/permission.js.map +1 -1
  28. package/dist/buildinschemas/systemmessage.d.ts.map +1 -1
  29. package/dist/buildinschemas/systemmessage.js +35 -32
  30. package/dist/buildinschemas/systemmessage.js.map +1 -1
  31. package/dist/buildinschemas/tenant.d.ts.map +1 -1
  32. package/dist/buildinschemas/tenant.js +17 -16
  33. package/dist/buildinschemas/tenant.js.map +1 -1
  34. package/dist/buildinschemas/user.d.ts.map +1 -1
  35. package/dist/buildinschemas/user.js +34 -31
  36. package/dist/buildinschemas/user.js.map +1 -1
  37. package/dist/buildinschemas/webhook.d.ts.map +1 -1
  38. package/dist/buildinschemas/webhook.js +24 -23
  39. package/dist/buildinschemas/webhook.js.map +1 -1
  40. package/dist/framework.d.ts +2 -0
  41. package/dist/framework.d.ts.map +1 -1
  42. package/dist/framework.js +92 -57
  43. package/dist/framework.js.map +1 -1
  44. package/dist/generate.d.ts.map +1 -1
  45. package/dist/generate.js +175 -34
  46. package/dist/generate.js.map +1 -1
  47. package/dist/index.js +30 -12
  48. package/dist/index.js.map +1 -1
  49. package/dist/processors/jsonschemabuilder.js +14 -12
  50. package/dist/processors/jsonschemabuilder.js.map +1 -1
  51. package/dist/type.d.ts +44 -5
  52. package/dist/type.d.ts.map +1 -1
  53. package/dist/type.js.map +1 -1
  54. package/package.json +1 -1
  55. package/src/buildinschemas/autoincreament.ts +35 -33
  56. package/src/buildinschemas/branch.ts +47 -47
  57. package/src/buildinschemas/changehistories.ts +31 -30
  58. package/src/buildinschemas/customfield.ts +17 -16
  59. package/src/buildinschemas/docnoformat.ts +54 -43
  60. package/src/buildinschemas/documentevent.ts +42 -33
  61. package/src/buildinschemas/keyvaluepair.ts +25 -25
  62. package/src/buildinschemas/organization.ts +54 -50
  63. package/src/buildinschemas/permission.ts +34 -25
  64. package/src/buildinschemas/systemmessage.ts +39 -38
  65. package/src/buildinschemas/tenant.ts +46 -45
  66. package/src/buildinschemas/user.ts +64 -60
  67. package/src/buildinschemas/webhook.ts +62 -61
  68. package/src/framework.ts +307 -251
  69. package/src/generate.ts +608 -434
  70. package/src/index.ts +136 -118
  71. package/src/processors/jsonschemabuilder.ts +6 -4
  72. package/src/type.ts +287 -226
  73. package/templates/basic/miniAppJsSdk/resource-bridge.service.ts.eta +119 -0
  74. package/templates/basic/miniAppStreamlitSdk/resource-bridge.service.ts.eta +228 -0
  75. package/templates/basic/nuxt/jsonschema.ts.eta +7 -0
  76. package/templates/basic/nuxt/resource-bridge.editable.service.ts.eta +40 -0
  77. package/templates/basic/nuxt/resource-bridge.service.ts.eta +165 -0
  78. package/templates/basic/nuxt/simpleapp.generate.client.ts.eta +27 -9
  79. package/templates/miniAppJsSdk/src/index.ts.eta +28 -0
  80. package/templates/miniAppJsSdk/src/services/bridge-resource-accessor.service.ts.eta +70 -0
  81. package/templates/miniAppJsSdk/src/services/bridge.service.ts.eta +91 -0
  82. package/templates/miniAppJsSdk/src/types/service.type.ts.eta +22 -0
  83. package/templates/miniAppStreamlitSdk/simtrain_eco_mini_app_streamlit_sdk/sdk.py.eta +76 -0
  84. package/templates/nest/src/simpleapp/generate/jsonschemas/index.ts.eta +11 -0
  85. package/templates/nest/src/simpleapp/types/customfield.ts.eta +14 -0
  86. package/templates/nuxt/components/simpleApp/SimpleAppForm.vue.eta +3 -3
  87. package/templates/nuxt/components/simpleApp/SimpleAppInputTable.vue.eta +0 -1
  88. package/templates/nuxt/plugins/18.simpleapp-custom-field-store.ts.eta +9 -3
  89. package/templates/nuxt/plugins/20.simpleapp-userstore.ts.eta +316 -341
  90. package/templates/nuxt/simpleapp/generate/clients/SimpleAppClient.ts.eta +32 -21
  91. package/templates/nuxt/simpleapp/generate/jsonSchemas/index.ts.eta +11 -0
  92. package/templates/nuxt/simpleapp/generate/miniApp/bridge/constants/common.constant.ts.eta +16 -0
  93. package/templates/nuxt/simpleapp/generate/miniApp/bridge/constants/resource.constant.ts.eta +46 -0
  94. package/templates/nuxt/simpleapp/generate/miniApp/bridge/services/bridge-resource-accessor.service.ts.eta +63 -0
  95. package/templates/nuxt/simpleapp/generate/miniApp/bridge/services/bridge.service.ts.eta +129 -0
  96. package/templates/nuxt/simpleapp/generate/miniApp/bridge/types/bridge.type.ts.eta +81 -0
  97. package/templates/nuxt/simpleapp/generate/miniApp/bridge/types/resource-mapper.type.ts.eta +55 -0
  98. package/templates/nuxt/types/others.ts.eta +74 -65
  99. package/templates/nuxt/types/schema.ts.eta +225 -188
  100. package/templates/project/build.sh.eta +4 -0
  101. package/templates/nuxt/simpleapp/generate/clients/SimpleAppCustomFieldClient.ts.eta +0 -191
@@ -0,0 +1,70 @@
1
+ /**
2
+ * This file was automatically generated by simpleapp generator. Every
3
+ * MODIFICATION OVERRIDE BY GENERATEOR
4
+ * last change 2025-06-18
5
+ * Author: --
6
+ */
7
+
8
+ <%
9
+ const upperFirstCase = (value) => {
10
+ return value.charAt(0).toUpperCase() + value.slice(1);
11
+ }
12
+
13
+ const camelToKebab = (value) => {
14
+ return value.replace(/([a-z])([A-Z])/g, "$1-$2").toLowerCase();
15
+ }
16
+
17
+ const getMiniAppInfo = (module) => {
18
+ const config = module.schema['x-simpleapp-config'];
19
+ const resourceName = config?.resourceName ?? config.documentName;
20
+
21
+ const pascalName = upperFirstCase(resourceName);
22
+ const kebabName = camelToKebab(resourceName);
23
+
24
+ const miniAppWhitelistApis = config?.miniApp?.whitelist || {};
25
+ const hasMiniAppWhitelistedApi = Object.keys(miniAppWhitelistApis).length > 0;
26
+
27
+ return {
28
+ resourceName,
29
+ pascalName,
30
+ kebabName,
31
+ hasMiniAppWhitelistedApi,
32
+ miniAppWhitelistApis,
33
+ }
34
+ }
35
+ %>
36
+
37
+ import { MiniAppResourceMap } from "../types/resource-mapper.type";
38
+ import { MiniAppBridgeService } from "./bridge.service";
39
+
40
+ <% for (let i = 0; i < it.modules.length; i++) { %>
41
+ <%
42
+ const { pascalName, kebabName, hasMiniAppWhitelistedApi } = getMiniAppInfo(it.modules[i]);
43
+ %>
44
+ <% if(hasMiniAppWhitelistedApi) { %>
45
+ import { MiniApp<%= pascalName %>BridgeService } from "../services/resources/<%= kebabName %>-bridge.service";
46
+ <% } %>
47
+ <% } %>
48
+
49
+ export class MiniAppBridgeResourceAccessor {
50
+ protected bridge: MiniAppBridgeService;
51
+ protected instances: Partial<MiniAppResourceMap> = {};
52
+
53
+ constructor() {
54
+ this.bridge = new MiniAppBridgeService();
55
+ }
56
+
57
+ <% for (let i = 0; i < it.modules.length; i++) { %>
58
+ <%
59
+ const { resourceName, pascalName, kebabName, hasMiniAppWhitelistedApi } = getMiniAppInfo(it.modules[i]);
60
+ %>
61
+ <% if(hasMiniAppWhitelistedApi) { %>
62
+ get <%= resourceName %>() {
63
+ if (!this.instances.<%= resourceName %>) {
64
+ this.instances.<%= resourceName %> = new MiniApp<%= pascalName %>BridgeService(this.bridge);
65
+ }
66
+ return this.instances.<%= resourceName %>;
67
+ }
68
+ <% } %>
69
+ <% } %>
70
+ }
@@ -0,0 +1,91 @@
1
+ /**
2
+ * This file was automatically generated by simpleapp generator. Every
3
+ * MODIFICATION OVERRIDE BY GENERATEOR
4
+ * last change 2025-06-18
5
+ * Author: --
6
+ */
7
+
8
+ import { MINI_APP_BRIDGE_MESSAGES } from '../constants/common.constant';
9
+ import {
10
+ MiniAppBridgeMessageApi,
11
+ MiniAppBridgeMessageApiResponse,
12
+ MiniAppBridgeMessageOpenOnScreenResourceForm
13
+ } from '../types/bridge.type';
14
+ import {
15
+ MiniAppResourceServiceApiParam,
16
+ MiniAppResourceServiceOpenOnScreenResourceFormParam
17
+ } from '../types/service.type';
18
+
19
+ export class MiniAppBridgeService {
20
+ private pendingRequests: Record<
21
+ string,
22
+ { resolve: (data: any) => void; reject: (err: any) => void }
23
+ > = {};
24
+
25
+ constructor() {
26
+ if (typeof window !== 'undefined') {
27
+ window.addEventListener('message', (event) => {
28
+ const message: MiniAppBridgeMessageApiResponse<any> = event.data;
29
+
30
+ if (
31
+ message.type === MINI_APP_BRIDGE_MESSAGES.API_RESPONSE &&
32
+ message.requestId
33
+ ) {
34
+ const handler = this.pendingRequests[message.requestId];
35
+ if (!handler) return;
36
+
37
+ if (message.success) {
38
+ handler.resolve(message.data);
39
+ } else {
40
+ handler.reject(message.error);
41
+ }
42
+
43
+ delete this.pendingRequests[message.requestId];
44
+ }
45
+ });
46
+ }
47
+ }
48
+
49
+ async callApi(
50
+ resource: string,
51
+ action: string,
52
+ params: MiniAppResourceServiceApiParam = {}
53
+ ) {
54
+ const requestId = crypto.randomUUID();
55
+
56
+ // TODO: Type
57
+ const requestMessage: MiniAppBridgeMessageApi<any> = {
58
+ type: MINI_APP_BRIDGE_MESSAGES.API,
59
+ requestId,
60
+ params: {
61
+ resource: { name: resource, id: params.id },
62
+ action,
63
+ query: params.query,
64
+ body: params.body,
65
+ queryParams: params.queryParams,
66
+ }
67
+ };
68
+
69
+ const promise = new Promise<any>((resolve, reject) => {
70
+ this.pendingRequests[requestId] = { resolve, reject };
71
+ });
72
+
73
+ window.parent.postMessage(requestMessage, '*');
74
+ return promise;
75
+ }
76
+
77
+ openOnScreenResourceForm(
78
+ resource: string,
79
+ params: MiniAppResourceServiceOpenOnScreenResourceFormParam = {}
80
+ ) {
81
+ const message: MiniAppBridgeMessageOpenOnScreenResourceForm = {
82
+ type: MINI_APP_BRIDGE_MESSAGES.OPEN_ON_SCREEN_RESOURCE_FORM,
83
+ params: {
84
+ resource: { name: resource, id: params.id },
85
+ data: params.data
86
+ }
87
+ };
88
+
89
+ window.parent.postMessage(message, '*');
90
+ }
91
+ }
@@ -0,0 +1,22 @@
1
+ /**
2
+ * This file was automatically generated by simpleapp generator. Every
3
+ * MODIFICATION OVERRIDE BY GENERATEOR
4
+ * last change 2025-06-18
5
+ * Author: --
6
+ */
7
+
8
+ export type MiniAppResourceServiceApiParam = {
9
+ id?: string;
10
+ queryParams?: {
11
+ [key: string]: any;
12
+ };
13
+ query?: string;
14
+ // TODO: Type
15
+ body?: any;
16
+ };
17
+
18
+ export type MiniAppResourceServiceOpenOnScreenResourceFormParam = {
19
+ id?: string;
20
+ // TODO: Type
21
+ data?: any;
22
+ };
@@ -0,0 +1,76 @@
1
+ <%
2
+ const upperFirstCase = (value) => {
3
+ return value.charAt(0).toUpperCase() + value.slice(1);
4
+ }
5
+
6
+ const camelToKebab = (value) => {
7
+ return value.replace(/([a-z])([A-Z])/g, "$1-$2").toLowerCase();
8
+ }
9
+
10
+ const camelToSnake = (value) => {
11
+ return value.replace(/([a-z])([A-Z])/g, "$1_$2").toLowerCase();
12
+ }
13
+
14
+ const getMiniAppInfo = (module) => {
15
+ const config = module.schema['x-simpleapp-config'];
16
+ const resourceName = config?.resourceName ?? config.documentName;
17
+
18
+ const pascalName = upperFirstCase(resourceName);
19
+ const kebabName = camelToKebab(resourceName);
20
+ const snakeName = camelToSnake(resourceName);
21
+
22
+ const miniAppWhitelistApis = config?.miniApp?.whitelist || {};
23
+ const hasMiniAppWhitelistedApi = Object.keys(miniAppWhitelistApis).length > 0;
24
+
25
+ return {
26
+ resourceName,
27
+ pascalName,
28
+ kebabName,
29
+ snakeName,
30
+ hasMiniAppWhitelistedApi,
31
+ miniAppWhitelistApis,
32
+ }
33
+ }
34
+ %>
35
+
36
+ from .services.ui import UI
37
+ from .services.current import Current
38
+ from .services.resources.student import Student
39
+ from .services.init_message_bridge import InitMessageBridge
40
+ from .services.helper import Helper as SimtrainSdkHelper
41
+
42
+ # ========================== Import Resource ==========================
43
+
44
+ <% for (let i = 0; i < it.modules.length; i++) { %>
45
+ <%
46
+ const { resourceName, pascalName, kebabName, snakeName, hasMiniAppWhitelistedApi } = getMiniAppInfo(it.modules[i]);
47
+ %>
48
+ <% if(hasMiniAppWhitelistedApi) { %>
49
+
50
+ from .services.resources.<%= snakeName %> import <%= pascalName %>
51
+
52
+ <% } %>
53
+ <% } %>
54
+
55
+
56
+ class SimtrainEcoMiniAppStreamlitSdk:
57
+ def __init__(self):
58
+ InitMessageBridge()
59
+
60
+ self.ui = UI()
61
+
62
+ self.current = Current()
63
+
64
+ self.helper = SimtrainSdkHelper
65
+
66
+ # ========================== Import Resource ==========================
67
+
68
+ <% for (let i = 0; i < it.modules.length; i++) { %>
69
+ <%
70
+ const { resourceName, pascalName, kebabName, hasMiniAppWhitelistedApi } = getMiniAppInfo(it.modules[i]);
71
+ %>
72
+ <% if(hasMiniAppWhitelistedApi) { %>
73
+
74
+ self.<%= resourceName %> = <%= pascalName %>()
75
+ <% } %>
76
+ <% } %>
@@ -0,0 +1,11 @@
1
+ /**
2
+ * This file was automatically generated by simpleapp generator. Every
3
+ * MODIFICATION OVERRIDE BY GENERATEOR
4
+ * last change 2024-02-23
5
+ * Author: Ks Tan
6
+ */
7
+
8
+ <%for(let i=0; i<it.modules.length;i++){ %>
9
+ <% const d = it.modules[i] %>
10
+ export * from './<%= d['doctype']%>.jsonschema'
11
+ <%}%>
@@ -0,0 +1,14 @@
1
+ /**
2
+ * This file was automatically generated by simpleapp generator. Every
3
+ * MODIFICATION OVERRIDE BY GENERATEOR
4
+ * last change 2024-02-23
5
+ * Author: Ks Tan
6
+ */
7
+
8
+ import { Customfield } from '../generate/types';
9
+
10
+ export type CompleteCustomFieldResource = {
11
+ resourceName: string;
12
+
13
+ data?: Customfield;
14
+ };
@@ -2,8 +2,8 @@
2
2
  <form class="simpleapp-form" @submit.prevent="true">
3
3
  <slot name="default" :data="document.getData()" :getField="getField"></slot>
4
4
  <slot name="customField">
5
- <!-- TODO: TS Error -->
6
- <SimpleAppCustomFieldFormSection
5
+ <CustomFieldFormSection
6
+ v-if="document.schema.properties.more"
7
7
  :customFieldJsonSchema="document.schema.properties.more"
8
8
  :data="document.getData().more"
9
9
  :handleGetField="getField"
@@ -23,8 +23,8 @@ import { SimpleAppClient } from "~/simpleapp/generate/clients/SimpleAppClient";
23
23
  import type { JSONSchema7, JSONSchema7Definition } from "json-schema";
24
24
  import * as alldefaults from "~/simpleapp/generate/defaults";
25
25
  import _, { upperFirst } from "lodash";
26
+ import CustomFieldFormSection from "~/simpleapp/generate/features/customField/components/CustomFieldFormSection.vue";
26
27
  const props = defineProps<{
27
-
28
28
  document: SimpleAppClient<any, any>;
29
29
  readonly?: boolean;
30
30
  }>();
@@ -58,7 +58,6 @@ const addNew = () => {
58
58
  if (props.setting.document[`add${field}`]) {
59
59
  props.setting.document[`add${field}`]();
60
60
  } else {
61
- console.log("customfield", modelValue.value);
62
61
  modelValue.value?.push({});
63
62
  }
64
63
  };
@@ -1,7 +1,10 @@
1
1
  import { ShallowRef } from "vue";
2
2
  import { Customfield, CUSTOMFIELDApi } from "~/simpleapp/generate/openapi";
3
3
 
4
- type CustomFieldStoreData = Pick<Customfield, "_id" | "collectionName" | "form">[];
4
+ type CustomFieldStoreData = Pick<
5
+ Customfield,
6
+ "_id" | "collectionName" | "form" | "list"
7
+ >[];
5
8
 
6
9
  type CustomFieldStore = {
7
10
  data: ShallowRef<CustomFieldStoreData>;
@@ -18,14 +21,17 @@ export default defineNuxtPlugin(async (nuxtApp) => {
18
21
  const api = new CUSTOMFIELDApi(config);
19
22
  const resp = await api.runSearch({
20
23
  filter: {},
21
- fields: ["_id", "collectionName", "form"],
24
+ fields: ["_id", "collectionName", "form", "list"],
22
25
  });
23
26
  // setTimeout(() => {
24
27
  this.$patch({ data: resp.data ?? [] });
25
28
  // }, 10000);
26
29
  },
27
30
  findByCollectionName(collectionName: string) {
28
- return this.data.find((item) => item.collectionName === collectionName) ?? null;
31
+ return (
32
+ this.data.find((item) => item.collectionName === collectionName) ??
33
+ null
34
+ );
29
35
  },
30
36
  },
31
37
  });