@simitgroup/simpleapp-generator 1.6.6-p-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 (90) 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 +14 -24
  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.map +1 -1
  41. package/dist/framework.js +2 -4
  42. package/dist/framework.js.map +1 -1
  43. package/dist/generate.js +17 -2
  44. package/dist/generate.js.map +1 -1
  45. package/dist/processors/jsonschemabuilder.js +14 -12
  46. package/dist/processors/jsonschemabuilder.js.map +1 -1
  47. package/dist/type.d.ts +39 -5
  48. package/dist/type.d.ts.map +1 -1
  49. package/dist/type.js.map +1 -1
  50. package/package.json +1 -1
  51. package/src/buildinschemas/autoincreament.ts +35 -33
  52. package/src/buildinschemas/branch.ts +47 -47
  53. package/src/buildinschemas/changehistories.ts +31 -30
  54. package/src/buildinschemas/customfield.ts +14 -24
  55. package/src/buildinschemas/docnoformat.ts +54 -43
  56. package/src/buildinschemas/documentevent.ts +42 -33
  57. package/src/buildinschemas/keyvaluepair.ts +25 -25
  58. package/src/buildinschemas/organization.ts +54 -50
  59. package/src/buildinschemas/permission.ts +34 -25
  60. package/src/buildinschemas/systemmessage.ts +39 -38
  61. package/src/buildinschemas/tenant.ts +46 -45
  62. package/src/buildinschemas/user.ts +64 -60
  63. package/src/buildinschemas/webhook.ts +62 -61
  64. package/src/framework.ts +2 -4
  65. package/src/generate.ts +17 -1
  66. package/src/processors/jsonschemabuilder.ts +6 -4
  67. package/src/type.ts +271 -215
  68. package/templates/basic/miniAppJsSdk/resource-bridge.service.ts.eta +9 -7
  69. package/templates/basic/miniAppStreamlitSdk/resource-bridge.service.ts.eta +22 -7
  70. package/templates/basic/nuxt/jsonschema.ts.eta +7 -0
  71. package/templates/basic/nuxt/resource-bridge.editable.service.ts.eta +40 -0
  72. package/templates/basic/nuxt/resource-bridge.service.ts.eta +24 -21
  73. package/templates/basic/nuxt/simpleapp.generate.client.ts.eta +27 -9
  74. package/templates/miniAppJsSdk/src/services/bridge-resource-accessor.service.ts.eta +2 -2
  75. package/templates/miniAppStreamlitSdk/simtrain_eco_mini_app_streamlit_sdk/sdk.py.eta +5 -2
  76. package/templates/nuxt/components/simpleApp/SimpleAppForm.vue.eta +4 -3
  77. package/templates/nuxt/components/simpleApp/SimpleAppInputTable.vue.eta +0 -1
  78. package/templates/nuxt/plugins/18.simpleapp-custom-field-store.ts.eta +9 -3
  79. package/templates/nuxt/plugins/20.simpleapp-userstore.ts.eta +316 -341
  80. package/templates/nuxt/simpleapp/generate/clients/SimpleAppClient.ts.eta +32 -22
  81. package/templates/nuxt/simpleapp/generate/jsonSchemas/index.ts.eta +11 -0
  82. package/templates/nuxt/simpleapp/generate/miniApp/bridge/constants/common.constant.ts.eta +1 -0
  83. package/templates/nuxt/simpleapp/generate/miniApp/bridge/constants/resource.constant.ts.eta +2 -2
  84. package/templates/nuxt/simpleapp/generate/miniApp/bridge/services/bridge-resource-accessor.service.ts.eta +4 -4
  85. package/templates/nuxt/simpleapp/generate/miniApp/bridge/services/bridge.service.ts.eta +20 -1
  86. package/templates/nuxt/simpleapp/generate/miniApp/bridge/types/bridge.type.ts.eta +9 -0
  87. package/templates/nuxt/simpleapp/generate/miniApp/bridge/types/resource-mapper.type.ts.eta +2 -2
  88. package/templates/project/build.sh.eta +0 -5
  89. package/templates/nest/src/simpleapp/apischemas/customfield.ts.eta +0 -21
  90. package/templates/nuxt/simpleapp/generate/clients/SimpleAppCustomFieldClient.ts.eta +0 -188
@@ -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
+ }
@@ -12,18 +12,18 @@
12
12
 
13
13
  const pascalName = upperFirstCase(it.resourceName);
14
14
  const apiName = it.typename.toUpperCase() + 'Api';
15
- const typeActionName = pascalName + 'Actions';
15
+ const typeActionName = 'MiniApp' + pascalName + 'Actions';
16
16
 
17
- const miniAppWhitelistApis = it.jsonschema['x-simpleapp-config']?.miniApp?.whitelist || [];
18
- const hasMiniAppWhitelistedApi = miniAppWhitelistApis.length > 0;
17
+ const miniAppWhitelistApis = it.jsonschema['x-simpleapp-config']?.miniApp?.whitelist || {};
18
+ const hasMiniAppWhitelistedApi = Object.keys(miniAppWhitelistApis).length > 0;
19
19
  %>
20
20
 
21
21
  import { <%= apiName %> } from "~/simpleapp/generate/openapi";
22
22
  import { MiniAppBridgeMessageApi } from "../../types/bridge.type";
23
23
 
24
- const actions = <%~ JSON.stringify(miniAppWhitelistApis, null, 2) %> as const;
24
+ const actions = <%~ JSON.stringify(Object.keys(miniAppWhitelistApis), null, 2) %> as const;
25
25
 
26
- type <%= typeActionName %> = (typeof actions)[number];
26
+ export type <%= typeActionName %> = (typeof actions)[number];
27
27
 
28
28
  export class MiniApp<%= pascalName %>BridgeService {
29
29
  protected api!: <%= apiName %>;
@@ -53,13 +53,14 @@ export class MiniApp<%= pascalName %>BridgeService {
53
53
  > {
54
54
  <% if(hasMiniAppWhitelistedApi) { %>
55
55
  return {
56
- <% for (let i = 0; i < miniAppWhitelistApis.length; i++) { %>
56
+ <% Object.entries(miniAppWhitelistApis).forEach(([action, value]) => { %>
57
+ <% if (value !== true && typeof value !== 'object') { return; } %>
58
+
57
59
  <%
58
- const action = miniAppWhitelistApis[i];
59
60
  const handlerName = "handle" + upperFirstCase(action);
60
61
  %>
61
62
  <%= action %>: this.<%= handlerName %>.bind(this),
62
- <% } %>
63
+ <% }) %>
63
64
  };
64
65
  <% } else { %>
65
66
  throw new Error(`ERR_NOT_SUPPORTED`);
@@ -68,27 +69,25 @@ export class MiniApp<%= pascalName %>BridgeService {
68
69
 
69
70
  /****************************************** API Action *****************************************/
70
71
 
71
- <% for (let i = 0; i < miniAppWhitelistApis.length; i++) { %>
72
- <%
73
- const action = miniAppWhitelistApis[i];
74
- %>
72
+ <% Object.entries(miniAppWhitelistApis).forEach(([action, value]) => { %>
73
+ <% if (value !== true && typeof value !== 'object') { return; } %>
75
74
 
76
75
  <% if(action === 'list') { %>
77
- private async handleList(message: MiniAppBridgeMessageApi<<%= typeActionName %>>) {
76
+ protected async handleList(message: MiniAppBridgeMessageApi<<%= typeActionName %>>) {
78
77
  return (await this.api!.runSearch({})).data;
79
78
  }
80
79
  <% } else if(action === 'detail') { %>
81
- private async handleDetail(message: MiniAppBridgeMessageApi<<%= typeActionName %>>) {
80
+ protected async handleDetail(message: MiniAppBridgeMessageApi<<%= typeActionName %>>) {
82
81
  if (!message.params.resource.id) throw new Error("ERR_MISSING_ID");
83
82
  return (await this.api!.runFindOne(message.params.resource.id)).data;
84
83
  }
85
84
  <% } else if(action === 'create') { %>
86
- private async handleCreate(message: MiniAppBridgeMessageApi<<%= typeActionName %>>) {
85
+ protected async handleCreate(message: MiniAppBridgeMessageApi<<%= typeActionName %>>) {
87
86
  if (!message.params.body) throw new Error("ERR_MISSING_BODY");
88
87
  return (await this.api!.runCreate(message.params.body as any)).data;
89
88
  }
90
89
  <% } else if(action === 'update') { %>
91
- private async handleUpdate(message: MiniAppBridgeMessageApi<<%= typeActionName %>>) {
90
+ protected async handleUpdate(message: MiniAppBridgeMessageApi<<%= typeActionName %>>) {
92
91
  if (!message.params.resource.id) throw new Error("ERR_MISSING_ID");
93
92
  if (!message.params.body) throw new Error("ERR_MISSING_BODY");
94
93
 
@@ -101,7 +100,7 @@ export class MiniApp<%= pascalName %>BridgeService {
101
100
  ).data;
102
101
  }
103
102
  <% } else if(action === 'patch') { %>
104
- private async handlePatch(message: MiniAppBridgeMessageApi<<%= typeActionName %>>) {
103
+ protected async handlePatch(message: MiniAppBridgeMessageApi<<%= typeActionName %>>) {
105
104
  if (!message.params.resource.id) throw new Error("ERR_MISSING_ID");
106
105
  if (!message.params.body) throw new Error("ERR_MISSING_BODY");
107
106
 
@@ -114,17 +113,21 @@ export class MiniApp<%= pascalName %>BridgeService {
114
113
  ).data;
115
114
  }
116
115
  <% } else if(action === 'delete') { %>
117
- private async handleDelete(message: MiniAppBridgeMessageApi<<%= typeActionName %>>) {
116
+ protected async handleDelete(message: MiniAppBridgeMessageApi<<%= typeActionName %>>) {
118
117
  if (!message.params.resource.id) throw new Error("ERR_MISSING_ID");
119
118
 
120
119
  return (await this.api!.runDelete(message.params.resource.id)).data;
121
120
  }
122
121
  <% } else if(action === 'autoComplete') { %>
123
- private async handleAutoComplete(message: MiniAppBridgeMessageApi<<%= typeActionName %>>) {
122
+ protected async handleAutoComplete(message: MiniAppBridgeMessageApi<<%= typeActionName %>>) {
124
123
  return (await this.api!.autoComplete(message.params.query ?? "", {})).data;
125
124
  }
125
+ <% } else if(action === 'current') { %>
126
+ protected async handleCurrent(message: MiniAppBridgeMessageApi<<%= typeActionName %>>) {
127
+ return {};
128
+ }
126
129
  <% } else { %>
127
- private async handle<%= upperFirstCase(action) %>(message: MiniAppBridgeMessageApi<<%= typeActionName %>>) {
130
+ protected async handle<%= upperFirstCase(action) %>(message: MiniAppBridgeMessageApi<<%= typeActionName %>>) {
128
131
  <% const apiSetting = it.apiSettings.find(item => item.action === action); %>
129
132
  <% if (apiSetting) { %>
130
133
  const queryParams = message.params?.queryParams;
@@ -158,5 +161,5 @@ export class MiniApp<%= pascalName %>BridgeService {
158
161
  <% } %>
159
162
  }
160
163
  <% } %>
161
- <% } %>
164
+ <% }) %>
162
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
  }
@@ -21,8 +21,8 @@
21
21
  const pascalName = upperFirstCase(resourceName);
22
22
  const kebabName = camelToKebab(resourceName);
23
23
 
24
- const miniAppWhitelistApis = config?.miniApp?.whitelist || [];
25
- const hasMiniAppWhitelistedApi = miniAppWhitelistApis.length > 0;
24
+ const miniAppWhitelistApis = config?.miniApp?.whitelist || {};
25
+ const hasMiniAppWhitelistedApi = Object.keys(miniAppWhitelistApis).length > 0;
26
26
 
27
27
  return {
28
28
  resourceName,
@@ -19,8 +19,8 @@
19
19
  const kebabName = camelToKebab(resourceName);
20
20
  const snakeName = camelToSnake(resourceName);
21
21
 
22
- const miniAppWhitelistApis = config?.miniApp?.whitelist || [];
23
- const hasMiniAppWhitelistedApi = miniAppWhitelistApis.length > 0;
22
+ const miniAppWhitelistApis = config?.miniApp?.whitelist || {};
23
+ const hasMiniAppWhitelistedApi = Object.keys(miniAppWhitelistApis).length > 0;
24
24
 
25
25
  return {
26
26
  resourceName,
@@ -34,6 +34,7 @@
34
34
  %>
35
35
 
36
36
  from .services.ui import UI
37
+ from .services.current import Current
37
38
  from .services.resources.student import Student
38
39
  from .services.init_message_bridge import InitMessageBridge
39
40
  from .services.helper import Helper as SimtrainSdkHelper
@@ -58,6 +59,8 @@ class SimtrainEcoMiniAppStreamlitSdk:
58
59
 
59
60
  self.ui = UI()
60
61
 
62
+ self.current = Current()
63
+
61
64
  self.helper = SimtrainSdkHelper
62
65
 
63
66
  # ========================== Import Resource ==========================
@@ -2,12 +2,12 @@
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"
10
- /> -->
10
+ />
11
11
  </slot>
12
12
  </form>
13
13
  </template>
@@ -23,6 +23,7 @@ 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
  document: SimpleAppClient<any, any>;
28
29
  readonly?: boolean;
@@ -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
  });