@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,119 @@
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 pascalName = upperFirstCase(it.resourceName);
14
+ const apiName = it.typename.toUpperCase() + 'Api';
15
+ const typeActionName = pascalName + 'Actions';
16
+
17
+ const miniAppWhitelistApis = it.jsonschema['x-simpleapp-config']?.miniApp?.whitelist || {};
18
+ const hasMiniAppWhitelistedApi = Object.keys(miniAppWhitelistApis).length > 0;
19
+ %>
20
+
21
+ import { MiniAppBridgeService } from "../bridge.service";
22
+
23
+ export class MiniApp<%= pascalName %>BridgeService {
24
+ private bridge: MiniAppBridgeService;
25
+
26
+ private resourceName = "<%= it.resourceName %>";
27
+
28
+ constructor(bridge: MiniAppBridgeService) {
29
+ this.bridge = bridge;
30
+ }
31
+
32
+ <% Object.entries(miniAppWhitelistApis).forEach(([action, value]) => { %>
33
+ <% if (value !== true && typeof value !== 'object') { return; } %>
34
+
35
+ <% if(action === 'list') { %>
36
+ async list() {
37
+ return this.bridge.callApi(this.resourceName, "list");
38
+ }
39
+ <% } else if(action === 'detail') { %>
40
+ async detail(id: string) {
41
+ return this.bridge.callApi(this.resourceName, "detail", { id });
42
+ }
43
+ <% } else if(action === 'create') { %>
44
+ async create(data: any) {
45
+ return this.bridge.callApi(this.resourceName, "create", { body: data });
46
+ }
47
+ <% } else if(action === 'update') { %>
48
+ async update(id: string, data: any) {
49
+ return this.bridge.callApi(this.resourceName, "update", { id, body: data });
50
+ }
51
+ <% } else if(action === 'patch') { %>
52
+ async patch(id: string, data: any) {
53
+ return this.bridge.callApi(this.resourceName, "patch", { id, body: data });
54
+ }
55
+ <% } else if(action === 'delete') { %>
56
+ async delete(id: string) {
57
+ return this.bridge.callApi(this.resourceName, "delete", { id });
58
+ }
59
+ <% } else if(action === 'autoComplete') { %>
60
+ async autoComplete(query: string, data: any) {
61
+ return this.bridge.callApi(this.resourceName, "autoComplete", {
62
+ query,
63
+ body: data,
64
+ });
65
+ }
66
+ <% } else if(action === 'current') { %>
67
+ async <%= action %>() {
68
+ return this.bridge.callApi(this.resourceName, "<%= action %>");
69
+ }
70
+ <% } else { %>
71
+ <% const apiSetting = it.apiSettings.find(item => item.action === action); %>
72
+ <% if (apiSetting) { %>
73
+ <% const hasBody = ['post', 'put', 'patch'].includes(apiSetting.method); %>
74
+
75
+ <%
76
+ const paramMatches = apiSetting.entryPoint.match(/:([\w]+)/g) || [];
77
+ const paramNames = paramMatches.map(p => p.replace(':', ''));
78
+
79
+ const args = paramNames.map(name => {
80
+ return `${name}: string`;
81
+ });
82
+
83
+ const output = [];
84
+ const queryParams = [];
85
+
86
+ for (let i = 0; i < paramNames.length; i++) {
87
+ const name = paramNames[i];
88
+ if (name === 'id') {
89
+ output.push(`id: ${name}`);
90
+ } else {
91
+ queryParams.push(`${name}: ${name}`);
92
+ }
93
+ }
94
+
95
+ if (queryParams.length > 0) {
96
+ output.push(`queryParams: {\n ${queryParams.join(',\n ')}\n}`);
97
+ }
98
+
99
+ if (hasBody) {
100
+ args.push('data: any');
101
+ output.push('body: data');
102
+ }
103
+ %>
104
+
105
+ async <%= action %>(<%= args.join(', ') %>) {
106
+ return this.bridge.callApi(this.resourceName, "<%= action %>", {
107
+ <%= output.join(',\n ') %>
108
+ });
109
+ }
110
+ <% } %>
111
+ <% } %>
112
+ <% }) %>
113
+
114
+ openOnScreenForm(id?: string) {
115
+ this.bridge.openOnScreenResourceForm(this.resourceName, {
116
+ id,
117
+ });
118
+ }
119
+ }
@@ -0,0 +1,228 @@
1
+ <%
2
+ const upperFirstCase = (value) => {
3
+ return value.charAt(0).toUpperCase() + value.slice(1);
4
+ }
5
+
6
+ const pascalName = upperFirstCase(it.resourceName);
7
+ const apiName = it.typename.toUpperCase() + 'Api';
8
+ const typeActionName = pascalName + 'Actions';
9
+
10
+ const miniAppWhitelistApis = it.jsonschema['x-simpleapp-config']?.miniApp?.whitelist || {};
11
+ const hasMiniAppWhitelistedApi = Object.keys(miniAppWhitelistApis).length > 0;
12
+ %>
13
+
14
+ from streamlit_javascript import st_javascript
15
+ from ..helper import Helper
16
+ from typing import Optional
17
+ from ..api_option import ApiOption
18
+ from streamlit.components.v1 import html
19
+ import json
20
+
21
+
22
+ class <%= pascalName %>:
23
+ _resource_name = "<%= it.resourceName %>"
24
+
25
+ <% Object.entries(miniAppWhitelistApis).forEach(([action, value]) => { %>
26
+ <% if (value !== true && typeof value !== 'object') { return; } %>
27
+
28
+
29
+ <% if(action === 'list') { %>
30
+
31
+ def <%= action %>(self, options: Optional[ApiOption] = {}):
32
+ action = "<%= action %>"
33
+ request_key = Helper.get_api_key(
34
+ "request", resource=self._resource_name, action=action, options=options
35
+ )
36
+
37
+ st_javascript(
38
+ f"window.parent.callApi('{self._resource_name}', '{action}')",
39
+ key=request_key,
40
+ on_change=lambda: Helper.set_api_response(
41
+ resource=self._resource_name, action=action, options=options
42
+ ),
43
+ )
44
+ <% } else if(action === 'detail') { %>
45
+
46
+ def <%= action %>(self, id: str, options: Optional[ApiOption] = {}):
47
+ action = "<%= action %>"
48
+ request_key = Helper.get_api_key(
49
+ "request", resource=self._resource_name, action=action, options=options
50
+ )
51
+ payload = json.dumps({"id": id})
52
+
53
+ st_javascript(
54
+ f"window.parent.callApi('{self._resource_name}', '{action}', {payload})",
55
+ key=request_key,
56
+ on_change=lambda: Helper.set_api_response(
57
+ resource=self._resource_name, action=action, options=options
58
+ ),
59
+ )
60
+ <% } else if(action === 'create') { %>
61
+
62
+ def <%= action %>(self, data = {}, options: Optional[ApiOption] = {}):
63
+ action = "<%= action %>"
64
+ request_key = Helper.get_api_key(
65
+ "request", resource=self._resource_name, action=action, options=options
66
+ )
67
+ payload = json.dumps({"body": data})
68
+
69
+ st_javascript(
70
+ f"window.parent.callApi('{self._resource_name}', '{action}', {payload})",
71
+ key=request_key,
72
+ on_change=lambda: Helper.set_api_response(
73
+ resource=self._resource_name, action=action, options=options
74
+ ),
75
+ )
76
+ <% } else if(action === 'update') { %>
77
+
78
+ def <%= action %>(self, id: str, data = {}, options: Optional[ApiOption] = {}):
79
+ action = "<%= action %>"
80
+ request_key = Helper.get_api_key(
81
+ "request", resource=self._resource_name, action=action, options=options
82
+ )
83
+ payload = json.dumps({"id": id, "body": data})
84
+
85
+ st_javascript(
86
+ f"window.parent.callApi('{self._resource_name}', '{action}', {payload})",
87
+ key=request_key,
88
+ on_change=lambda: Helper.set_api_response(
89
+ resource=self._resource_name, action=action, options=options
90
+ ),
91
+ )
92
+ <% } else if(action === 'patch') { %>
93
+
94
+ def <%= action %>(self, id: str, data = {}, options: Optional[ApiOption] = {}):
95
+ action = "<%= action %>"
96
+ request_key = Helper.get_api_key(
97
+ "request", resource=self._resource_name, action=action, options=options
98
+ )
99
+ payload = json.dumps({"id": id, "body": data})
100
+
101
+ st_javascript(
102
+ f"window.parent.callApi('{self._resource_name}', '{action}', {payload})",
103
+ key=request_key,
104
+ on_change=lambda: Helper.set_api_response(
105
+ resource=self._resource_name, action=action, options=options
106
+ ),
107
+ )
108
+ <% } else if(action === 'delete') { %>
109
+
110
+ def <%= action %>(self, id: str, options: Optional[ApiOption] = {}):
111
+ action = "<%= action %>"
112
+ request_key = Helper.get_api_key(
113
+ "request", resource=self._resource_name, action=action, options=options
114
+ )
115
+ payload = json.dumps({"id": id})
116
+ st_javascript(
117
+ f"window.parent.callApi('{self._resource_name}', '{action}', {payload})",
118
+ key=request_key,
119
+ on_change=lambda: Helper.set_api_response(
120
+ resource=self._resource_name, action=action, options=options
121
+ ),
122
+ )
123
+ <% } else if(action === 'autoComplete') { %>
124
+
125
+ def <%= action %>(self, query: str, data = {}, options: Optional[ApiOption] = {}):
126
+ action = "<%= action %>"
127
+ request_key = Helper.get_api_key(
128
+ "request", resource=self._resource_name, action=action, options=options
129
+ )
130
+
131
+ payload = json.dumps({"query": query, "body": data})
132
+ st_javascript(
133
+ f"window.parent.callApi('{self._resource_name}', '{action}', {payload})",
134
+ key=request_key,
135
+ on_change=lambda: Helper.set_api_response(
136
+ resource=self._resource_name, action=action, options=options
137
+ ),
138
+ )
139
+ <% } else if(action === 'current') { %>
140
+
141
+ def <%= action %>(self, options: Optional[ApiOption] = {}):
142
+ action = "<%= action %>"
143
+ request_key = Helper.get_api_key(
144
+ "request", resource=self._resource_name, action=action, options=options
145
+ )
146
+
147
+ st_javascript(
148
+ f"window.parent.callApi('{self._resource_name}', '{action}')",
149
+ key=request_key,
150
+ on_change=lambda: Helper.set_api_response(
151
+ resource=self._resource_name, action=action, options=options
152
+ ),
153
+ )
154
+
155
+ <% } else { %>
156
+ <% const apiSetting = it.apiSettings.find(item => item.action === action); %>
157
+ <% if (apiSetting) { %>
158
+ <% const hasBody = ['post', 'put', 'patch'].includes(apiSetting.method); %>
159
+
160
+ <%
161
+ const paramMatches = apiSetting.entryPoint.match(/:([\w]+)/g) || [];
162
+ const paramNames = paramMatches.map(p => p.replace(':', ''));
163
+
164
+ const args = paramNames.map(name => {
165
+ return `${name}: str`;
166
+ });
167
+
168
+
169
+ const output = [];
170
+ const queryParams = [];
171
+
172
+ for (let i = 0; i < paramNames.length; i++) {
173
+ const name = paramNames[i];
174
+ if (name === 'id') {
175
+ output.push(`'id': ${name}`)
176
+ } else {
177
+ queryParams.push(`'${name}': ${name}`)
178
+ }
179
+ }
180
+
181
+ if (queryParams.length > 0) {
182
+ output.push(`'queryParams': { ${queryParams.join(', ')} }`);
183
+ }
184
+
185
+ if (hasBody) {
186
+ args.push('data = {}');
187
+ output.push("'body': data");
188
+ }
189
+
190
+ args.push('options: Optional[ApiOption] = {}')
191
+ %>
192
+
193
+ def <%= action %>(self, <%= args.join(', ') %>):
194
+ action = "<%= action %>"
195
+ request_key = Helper.get_api_key(
196
+ "request", resource=self._resource_name, action=action, options=options
197
+ )
198
+ payload = json.dumps({ <%~ output.join(', ') %> })
199
+
200
+ st_javascript(
201
+ f"window.parent.callApi('{self._resource_name}', '{action}', {payload})",
202
+ key=request_key,
203
+ on_change=lambda: Helper.set_api_response(
204
+ resource=self._resource_name, action=action, options=options
205
+ ),
206
+ )
207
+ <% } %>
208
+ <% } %>
209
+ <% }) %>
210
+
211
+ def response(self, action: str, options: Optional[ApiOption] = {}):
212
+ return Helper.get_api_response(
213
+ resource=self._resource_name, action=action, options=options
214
+ )
215
+
216
+ def openOnScreenForm(self, id: Optional[str] = None):
217
+ id_js = f"'{id}'" if id else "undefined"
218
+
219
+ html(
220
+ f"""
221
+ <script>
222
+ window.parent.openOnScreenResourceForm('{self._resource_name}', {{
223
+ id: {id_js}
224
+ }});
225
+ </script>
226
+ """,
227
+ height=0,
228
+ )
@@ -0,0 +1,7 @@
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
+ export const <%= it.typename%>JsonSchema = <%~ JSON.stringify(it.jsonschema) %>
@@ -0,0 +1,40 @@
1
+ /**
2
+ * This file was automatically generated by simpleapp generator.
3
+ * you may change it, it won't override
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 pascalName = upperFirstCase(it.resourceName);
18
+ const kebabName = camelToKebab(it.resourceName);
19
+ const apiName = it.typename.toUpperCase() + 'Api';
20
+ const typeActionName = 'MiniApp' + pascalName + 'Actions';
21
+
22
+ const miniAppWhitelistApis = it.jsonschema['x-simpleapp-config']?.miniApp?.whitelist || {};
23
+ const hasMiniAppWhitelistedApi = Object.keys(miniAppWhitelistApis).length > 0;
24
+ %>
25
+
26
+ import { MiniApp<%= pascalName %>BridgeService } from "../../../services/resources/<%= kebabName %>-bridge.service";
27
+ import type { <%= typeActionName %> } from "../../../services/resources/<%= kebabName %>-bridge.service";
28
+ import { MiniAppBridgeMessageApi } from "../../../types/bridge.type";
29
+
30
+ export class MiniApp<%= pascalName %>BridgeEditableService extends MiniApp<%= pascalName %>BridgeService {
31
+ <% Object.entries(miniAppWhitelistApis).forEach(([action, value]) => { %>
32
+ <% if (value !== true && typeof value !== 'object') { return; } %>
33
+
34
+ <% if(action === 'current') { %>
35
+ protected override async handleCurrent(message: MiniAppBridgeMessageApi<<%= typeActionName %>>): Promise<any> {
36
+ return {};
37
+ }
38
+ <% } %>
39
+ <% }) %>
40
+ }
@@ -0,0 +1,165 @@
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 pascalName = upperFirstCase(it.resourceName);
14
+ const apiName = it.typename.toUpperCase() + 'Api';
15
+ const typeActionName = 'MiniApp' + pascalName + 'Actions';
16
+
17
+ const miniAppWhitelistApis = it.jsonschema['x-simpleapp-config']?.miniApp?.whitelist || {};
18
+ const hasMiniAppWhitelistedApi = Object.keys(miniAppWhitelistApis).length > 0;
19
+ %>
20
+
21
+ import { <%= apiName %> } from "~/simpleapp/generate/openapi";
22
+ import { MiniAppBridgeMessageApi } from "../../types/bridge.type";
23
+
24
+ const actions = <%~ JSON.stringify(Object.keys(miniAppWhitelistApis), null, 2) %> as const;
25
+
26
+ export type <%= typeActionName %> = (typeof actions)[number];
27
+
28
+ export class MiniApp<%= pascalName %>BridgeService {
29
+ protected api!: <%= apiName %>;
30
+
31
+ constructor() {
32
+ this.api = new <%= apiName %>(getAxiosConfig());
33
+ }
34
+
35
+ async handleApi(message: MiniAppBridgeMessageApi<<%= typeActionName %>>) {
36
+ <% if(hasMiniAppWhitelistedApi) { %>
37
+ const handlers = this.getHandlers();
38
+
39
+ const handler = handlers[message.params.action];
40
+ if (!handler) {
41
+ throw new Error(`ERR_UNKNOWN_ACTION: ${message.params.action}`);
42
+ }
43
+
44
+ return await handler(message);
45
+ <% } else { %>
46
+ throw new Error(`ERR_NOT_SUPPORTED`);
47
+ <% } %>
48
+ }
49
+
50
+ private getHandlers(): Record<
51
+ <%= typeActionName %>,
52
+ (message: MiniAppBridgeMessageApi<<%= typeActionName %>>) => Promise<any>
53
+ > {
54
+ <% if(hasMiniAppWhitelistedApi) { %>
55
+ return {
56
+ <% Object.entries(miniAppWhitelistApis).forEach(([action, value]) => { %>
57
+ <% if (value !== true && typeof value !== 'object') { return; } %>
58
+
59
+ <%
60
+ const handlerName = "handle" + upperFirstCase(action);
61
+ %>
62
+ <%= action %>: this.<%= handlerName %>.bind(this),
63
+ <% }) %>
64
+ };
65
+ <% } else { %>
66
+ throw new Error(`ERR_NOT_SUPPORTED`);
67
+ <% } %>
68
+ }
69
+
70
+ /****************************************** API Action *****************************************/
71
+
72
+ <% Object.entries(miniAppWhitelistApis).forEach(([action, value]) => { %>
73
+ <% if (value !== true && typeof value !== 'object') { return; } %>
74
+
75
+ <% if(action === 'list') { %>
76
+ protected async handleList(message: MiniAppBridgeMessageApi<<%= typeActionName %>>) {
77
+ return (await this.api!.runSearch({})).data;
78
+ }
79
+ <% } else if(action === 'detail') { %>
80
+ protected async handleDetail(message: MiniAppBridgeMessageApi<<%= typeActionName %>>) {
81
+ if (!message.params.resource.id) throw new Error("ERR_MISSING_ID");
82
+ return (await this.api!.runFindOne(message.params.resource.id)).data;
83
+ }
84
+ <% } else if(action === 'create') { %>
85
+ protected async handleCreate(message: MiniAppBridgeMessageApi<<%= typeActionName %>>) {
86
+ if (!message.params.body) throw new Error("ERR_MISSING_BODY");
87
+ return (await this.api!.runCreate(message.params.body as any)).data;
88
+ }
89
+ <% } else if(action === 'update') { %>
90
+ protected async handleUpdate(message: MiniAppBridgeMessageApi<<%= typeActionName %>>) {
91
+ if (!message.params.resource.id) throw new Error("ERR_MISSING_ID");
92
+ if (!message.params.body) throw new Error("ERR_MISSING_BODY");
93
+
94
+ return (
95
+ await this.api!.runUpdate(
96
+ message.params.resource.id,
97
+ // TODO: Type
98
+ message.params.body as any,
99
+ )
100
+ ).data;
101
+ }
102
+ <% } else if(action === 'patch') { %>
103
+ protected async handlePatch(message: MiniAppBridgeMessageApi<<%= typeActionName %>>) {
104
+ if (!message.params.resource.id) throw new Error("ERR_MISSING_ID");
105
+ if (!message.params.body) throw new Error("ERR_MISSING_BODY");
106
+
107
+ return (
108
+ await this.api!.runPatch(
109
+ message.params.resource.id,
110
+ // TODO: Type
111
+ message.params.body as any,
112
+ )
113
+ ).data;
114
+ }
115
+ <% } else if(action === 'delete') { %>
116
+ protected async handleDelete(message: MiniAppBridgeMessageApi<<%= typeActionName %>>) {
117
+ if (!message.params.resource.id) throw new Error("ERR_MISSING_ID");
118
+
119
+ return (await this.api!.runDelete(message.params.resource.id)).data;
120
+ }
121
+ <% } else if(action === 'autoComplete') { %>
122
+ protected async handleAutoComplete(message: MiniAppBridgeMessageApi<<%= typeActionName %>>) {
123
+ return (await this.api!.autoComplete(message.params.query ?? "", {})).data;
124
+ }
125
+ <% } else if(action === 'current') { %>
126
+ protected async handleCurrent(message: MiniAppBridgeMessageApi<<%= typeActionName %>>) {
127
+ return {};
128
+ }
129
+ <% } else { %>
130
+ protected async handle<%= upperFirstCase(action) %>(message: MiniAppBridgeMessageApi<<%= typeActionName %>>) {
131
+ <% const apiSetting = it.apiSettings.find(item => item.action === action); %>
132
+ <% if (apiSetting) { %>
133
+ const queryParams = message.params?.queryParams;
134
+
135
+ <% const hasBody = ['post', 'put', 'patch'].includes(apiSetting.method); %>
136
+ <% if (hasBody) { %>
137
+ if (!message.params.body) throw new Error("ERR_MISSING_BODY");
138
+ <% } %>
139
+ <%
140
+ const paramMatches = apiSetting.entryPoint.match(/:([\w]+)/g) || [];
141
+ const paramNames = paramMatches.map(p => p.replace(':', ''));
142
+ paramNames.forEach(name => {
143
+ if (name === 'id') {
144
+ %>
145
+ if (!message.params.resource.id) throw new Error("ERR_MISSING_ID");
146
+ <% } else { %>
147
+ if (!queryParams?.<%= name %>) throw new Error("ERR_MISSING_QUERY_PARAM: <%= name %>");
148
+ <% }
149
+ });
150
+
151
+ // prepare args for the function call
152
+ const args = paramNames.map(name => (
153
+ name === 'id'
154
+ ? 'message.params.resource.id'
155
+ : `queryParams?.${name}`
156
+ ));
157
+ if (hasBody) args.push('message.params.body');
158
+ %>
159
+
160
+ return (await this.api!.run<%= upperFirstCase(action) %>(<%= args.join(', ') %>)).data;
161
+ <% } %>
162
+ }
163
+ <% } %>
164
+ <% }) %>
165
+ }
@@ -20,8 +20,9 @@ import {AxiosResponse} from 'axios'
20
20
  import * as <%=libs[l].importAs %> from '<%=libs[l].importFrom %>'
21
21
  <%}%>
22
22
  <%}%>
23
- // import { JSONSchema7 } from 'json-schema';
24
23
  import * as openapi from '../openapi';
24
+ import { CustomFieldDataModeEnum } from "../features/customField/enums/common";
25
+
25
26
 
26
27
  export type {
27
28
  <%= it.typename%> ,
@@ -57,10 +58,14 @@ export class <%= capitalizeFirstLetter(it.name)%>Client extends SimpleAppClient<
57
58
  const apiobj = getDocumentApi('<%=it.name %>')
58
59
  super(apiobj,'<%= it.doctype %>','<%=it.name %>')
59
60
  this.event=$event
60
- this.listen=$listen
61
- this.setNew();
62
-
63
- this.processCustomField();
61
+ this.listen=$listen
62
+
63
+ <% if(it.customField.isEnable) { %>
64
+ // FLAG::CUSTOM_FIELD
65
+ this.prepareCustomFieldJsonSchema();
66
+ <% } %>
67
+
68
+ this.setNew();
64
69
  }
65
70
 
66
71
  override setWatchChange = ()=>{
@@ -72,13 +77,15 @@ export class <%= capitalizeFirstLetter(it.name)%>Client extends SimpleAppClient<
72
77
  }
73
78
  },{deep:true})
74
79
 
75
- <% if(!['Plugins', 'Plugininstallations', 'Customfield'].includes(capitalizeFirstLetter(it.name))) { %>
80
+
81
+ <% if(it.customField.isEnable) { %>
82
+ // FLAG::CUSTOM_FIELD
76
83
  const { $customFieldStore, $appPluginsStore } = useNuxtApp();
77
84
  if (!this._customFieldWatch) {
78
85
  this._customFieldWatch = watch(
79
86
  [() => $customFieldStore.data, () => $appPluginsStore.installedPlugins],
80
87
  ([newCustomField, newPlugins], [oldCustomField, oldPlugins]) => {
81
- this.processCustomField();
88
+ this.prepareCustomFieldJsonSchema();
82
89
  },
83
90
  { immediate: false, deep: true },
84
91
  );
@@ -88,8 +95,19 @@ export class <%= capitalizeFirstLetter(it.name)%>Client extends SimpleAppClient<
88
95
  }
89
96
 
90
97
  override setNew = ()=>{
91
- const newdata = Default<%= it.typename%>(randomUUID())
92
- this.setData(newdata)
98
+ const defaultData = Default<%= it.typename%>(randomUUID())
99
+
100
+ <% if(it.customField.isEnable) { %>
101
+ // FLAG::CUSTOM_FIELD
102
+ const data = this.prepareCustomFieldData(
103
+ CustomFieldDataModeEnum.DEFAULT,
104
+ defaultData,
105
+ );
106
+ <% } else { %>
107
+ const data = defaultData;
108
+ <% } %>
109
+
110
+ this.setData(data);
93
111
  this.setWatchChange()
94
112
  return true
95
113
  }
@@ -0,0 +1,28 @@
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 { MiniAppBridgeResourceAccessor } from './services/bridge-resource-accessor.service';
10
+ import { MiniAppBridgeMessageNavigate } from './types/bridge.type';
11
+
12
+ export class SimtrainEcoMiniAppJsSdk extends MiniAppBridgeResourceAccessor {
13
+ public ui = {
14
+ navigateTo: (target: string, id?: string, query?: string) => {
15
+ const message: MiniAppBridgeMessageNavigate = {
16
+ type: MINI_APP_BRIDGE_MESSAGES.NAVIGATE,
17
+ params: { target, id, query }
18
+ };
19
+
20
+ window.parent.postMessage(message, '*');
21
+ }
22
+ };
23
+
24
+ constructor() {
25
+ super();
26
+ console.log('Hello from SimtrainEcoMiniAppJsSdk !!!');
27
+ }
28
+ }