@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
@@ -13,10 +13,13 @@ import {
13
13
  NotificationStatus,
14
14
  SchemaType,
15
15
  FormActions,
16
+ DynamicObject,
16
17
  } from "~/types";
17
18
  import { getValidateService } from "~/simpleapp/generate/sharelibs/validate";
18
- import { SimpleAppCustomFieldClient } from "./SimpleAppCustomFieldClient";
19
19
  import { WatchHandle } from "vue";
20
+ import { CustomFieldService } from "../features/customField/services/CustomFieldService";
21
+ import { CustomFieldDataMode } from "../features/customField/types/common";
22
+ import { CustomFieldDataModeEnum } from "../features/customField/enums/common";
20
23
 
21
24
  // import { useToast, } from 'primevue/usetoast';
22
25
  // import type { ToastMessageOptions } from 'primevue/toast';
@@ -50,8 +53,10 @@ export class SimpleAppClient<
50
53
  protected errorlist = ref({});
51
54
  protected completeformula = true;
52
55
  protected axios;
53
- private _customFieldClient = new SimpleAppCustomFieldClient();
56
+
57
+ // FLAG::CUSTOM_FIELD
54
58
  protected _customFieldWatch: WatchHandle | null = null;
59
+ private _customFieldService = new CustomFieldService();
55
60
 
56
61
  constructor(apiobj: TApi, doctype: string, docname: string) {
57
62
  this.docapi = apiobj;
@@ -76,25 +81,29 @@ export class SimpleAppClient<
76
81
  return false;
77
82
  } //if there is readonly attribute in data, will override it at processor and client
78
83
  setData = (data: any) => {
79
- // this.data.value = data;
80
-
81
- // TODO: Will Cause Docno Format Broken
82
- // data.more = this._customFieldClient.formCustomFieldData(
83
- // this.doctype,
84
- // this.schema.properties?.more,
85
- // data.createdBy == "",
86
- // data.more,
87
- // );
88
-
89
84
  Object.assign(this.data.value, data);
90
85
  };
91
86
 
92
- async processCustomField() {
93
- // const resp = this._customFieldClient.formCustomFieldJsonSchema(
94
- // this.doctype,
95
- // );
96
- // this.schema.properties.more = resp;
97
- // this.setData(this.data.value);
87
+ prepareCustomFieldJsonSchema() {
88
+ const resp = this._customFieldService.prepareCustomFieldJsonSchema(
89
+ this.docname,
90
+ );
91
+ this.schema.properties.more = resp;
92
+ }
93
+
94
+ prepareCustomFieldData<T extends DynamicObject>(
95
+ mode: CustomFieldDataMode,
96
+ data: T,
97
+ ) {
98
+ const customFieldData = this._customFieldService.prepareCustomFieldData(
99
+ this.docname,
100
+ mode,
101
+ this.schema.properties?.more,
102
+ data.more,
103
+ );
104
+
105
+ (data as any).more = customFieldData;
106
+ return data;
98
107
  }
99
108
 
100
109
  async getById(id?: string) {
@@ -103,10 +112,11 @@ export class SimpleAppClient<
103
112
  return await this.docapi
104
113
  .runFindOne(id, this.axios)
105
114
  .then((res: AxiosResponse) => {
106
- // if(this.event){this.event('info:getById',res.data)}
107
- // this.data.value = {} as TData;
108
- // Object.assign(this.data.value, res.data);
109
- this.setData(res.data);
115
+ const dataWithCustomField = this.prepareCustomFieldData(
116
+ CustomFieldDataModeEnum.EXISTING,
117
+ res.data,
118
+ );
119
+ this.setData(dataWithCustomField);
110
120
  this.setWatchChange();
111
121
  setTimeout(() => {
112
122
  this.ready = true;
@@ -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
+ <%}%>
@@ -7,6 +7,7 @@
7
7
 
8
8
  export enum MINI_APP_BRIDGE_MESSAGES {
9
9
  NAVIGATE = "NAVIGATE",
10
+ NAVIGATE_CURRENT_MINI_APP = "NAVIGATE_CURRENT_MINI_APP",
10
11
  OPEN_ON_SCREEN_RESOURCE_FORM = "OPEN_ON_SCREEN_RESOURCE_FORM",
11
12
  API = "API",
12
13
  API_RESPONSE = "API_RESPONSE",
@@ -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,
@@ -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,
@@ -40,7 +40,7 @@ import { MiniAppResourceMap } from "../types/resource-mapper.type";
40
40
  const { pascalName, kebabName, hasMiniAppWhitelistedApi } = getMiniAppInfo(it.modules[i]);
41
41
  %>
42
42
  <% if(hasMiniAppWhitelistedApi) { %>
43
- import { MiniApp<%= pascalName %>BridgeService } from "../services/resources/<%= kebabName %>-bridge.service";
43
+ import { MiniApp<%= pascalName %>BridgeEditableService } from "./editable/resources/<%= kebabName %>-bridge.editable.service";
44
44
  <% } %>
45
45
  <% } %>
46
46
 
@@ -54,7 +54,7 @@ export class MiniAppBridgeResourceAccessor {
54
54
  <% if(hasMiniAppWhitelistedApi) { %>
55
55
  get <%= resourceName %>() {
56
56
  if (!this.instances.<%= resourceName %>) {
57
- this.instances.<%= resourceName %> = new MiniApp<%= pascalName %>BridgeService();
57
+ this.instances.<%= resourceName %> = new MiniApp<%= pascalName %>BridgeEditableService();
58
58
  }
59
59
  return this.instances.<%= resourceName %>;
60
60
  }
@@ -4,11 +4,12 @@
4
4
  * last change 2025-06-18
5
5
  * Author: --
6
6
  */
7
-
7
+
8
8
  import { SimpleAppDocumentType } from "~/types";
9
9
  import {
10
10
  MiniAppBridgeMessageApi,
11
11
  MiniAppBridgeMessageNavigate,
12
+ MiniAppBridgeMessageNavigateCurrentMiniApp,
12
13
  MiniAppBridgeMessageOpenOnScreenResourceForm,
13
14
  } from "../types/bridge.type";
14
15
  import { AxiosError } from "axios";
@@ -24,6 +25,24 @@ export class MiniAppBridgeService extends MiniAppBridgeResourceAccessor {
24
25
  goTo(message.params.target, message.params.id, message.params.query);
25
26
  }
26
27
 
28
+ handleBridgeNavigateCurrentMiniApp(
29
+ message: MiniAppBridgeMessageNavigateCurrentMiniApp,
30
+ pluginCode: string,
31
+ ) {
32
+ const target = message.params.target;
33
+ const { $appPluginsStore } = useNuxtApp();
34
+ let targetUrl = "";
35
+ if (target === "setting") {
36
+ targetUrl = $appPluginsStore.getPluginSettingPath(pluginCode);
37
+ } else {
38
+ targetUrl = $appPluginsStore.getPluginPageUrlPath(pluginCode, "");
39
+ targetUrl = targetUrl.replace(/^\/|\/$/g, "");
40
+ targetUrl = `${targetUrl}/${message.params.target}`;
41
+ }
42
+
43
+ goTo(targetUrl, undefined, message.params.query);
44
+ }
45
+
27
46
  handleBridgeOpenOnScreenResourceForm(
28
47
  message: MiniAppBridgeMessageOpenOnScreenResourceForm,
29
48
  ) {
@@ -16,6 +16,7 @@ export type MiniAppResource = {
16
16
 
17
17
  export type MiniAppBridgeMessage<TAction> =
18
18
  | MiniAppBridgeMessageNavigate
19
+ | MiniAppBridgeMessageNavigateCurrentMiniApp
19
20
  | MiniAppBridgeMessageOpenOnScreenResourceForm
20
21
  | MiniAppBridgeMessageApi<TAction>
21
22
  | MiniAppBridgeMessageInitResponse;
@@ -29,6 +30,14 @@ export type MiniAppBridgeMessageNavigate = {
29
30
  };
30
31
  };
31
32
 
33
+ export type MiniAppBridgeMessageNavigateCurrentMiniApp = {
34
+ type: typeof MINI_APP_BRIDGE_MESSAGES.NAVIGATE_CURRENT_MINI_APP;
35
+ params: {
36
+ target: string;
37
+ query?: string;
38
+ };
39
+ };
40
+
32
41
  export type MiniAppBridgeMessageOpenOnScreenResourceForm = {
33
42
  type: typeof MINI_APP_BRIDGE_MESSAGES.OPEN_ON_SCREEN_RESOURCE_FORM;
34
43
  params: {
@@ -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,11 +19,6 @@ elif [ $type == 'updatebackend' ]; then
19
19
  cp -a ./sharelibs backend/src/simpleapp/generate
20
20
  elif [ $type == 'updateMiniAppJsSdk' ]; then
21
21
  simpleapp-generator -c config.json -g updateMiniAppJsSdk
22
- mkdir -p ./miniAppSdk/js/src/constants
23
- mkdir -p ./miniAppSdk/js/src/types
24
- cp -a ./frontend/simpleapp/generate/miniApp/bridge/constants/* ./miniAppSdk/js/src/constants
25
- cp -a ./frontend/simpleapp/generate/miniApp/bridge/types/* ./miniAppSdk/js/src/types
26
- cp -a miniAppSdk/js/src/* ../sdk/simtrain-eco-js-sdk/src
27
22
  elif [ $type == 'updateMiniAppStreamlitSdk' ]; then
28
23
  simpleapp-generator -c config.json -g updateMiniAppStreamlitSdk
29
24
  fi
@@ -1,21 +0,0 @@
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 { Field, ObjectType } from '@nestjs/graphql';
9
- import { ApiProperty } from '@nestjs/swagger';
10
- import { Customfield } from '../generate/apischemas';
11
-
12
- @ObjectType()
13
- export class CompleteCustomFieldResource {
14
- @Field()
15
- @ApiProperty({ type: 'string', required: true })
16
- resourceName: string;
17
-
18
- @Field(() => Customfield)
19
- @ApiProperty({ type: () => Customfield, required: false })
20
- data: Customfield;
21
- }
@@ -1,188 +0,0 @@
1
- /**
2
- * This file was automatically generated by simpleapp generator. Every
3
- * MODIFICATION OVERRIDE BY GENERATEOR
4
- * last change 2025-06-09
5
- */
6
- import _ from "lodash";
7
- import {
8
- CustomFieldJsonSchemaMoreSchema,
9
- CustomFieldJsonSchemaMoreSchemaGroup,
10
- DynamicObject,
11
- SimpleAppJSONSchema7Definition,
12
- } from "~/types";
13
-
14
- export class SimpleAppCustomFieldClient {
15
- constructor() {}
16
-
17
- formCustomFieldJsonSchema(collectionName: string) {
18
- const customFieldFromDB = this._findCustomFieldSchemaFromDB(collectionName);
19
- const customFieldFromPlugin =
20
- this._findCustomFieldSchemaFromPlugin(collectionName);
21
-
22
- if (customFieldFromDB && !_.isEmpty(customFieldFromDB)) {
23
- }
24
-
25
- const schema: CustomFieldJsonSchemaMoreSchema = {
26
- type: "object",
27
- properties: {
28
- ...customFieldFromDB,
29
- ...customFieldFromPlugin,
30
- },
31
- };
32
-
33
- return schema;
34
- }
35
-
36
- private _findCustomFieldSchemaFromDB(collectionName: string) {
37
- const { $customFieldStore } = useNuxtApp();
38
- if (!$customFieldStore.data || _.isEmpty($customFieldStore.data)) {
39
- return {};
40
- }
41
-
42
- const customField = $customFieldStore.findByCollectionName(collectionName);
43
- if (!customField) {
44
- return {};
45
- }
46
-
47
- const schema: CustomFieldJsonSchemaMoreSchemaGroup = {
48
- default: {
49
- title: "Custom Field",
50
- ...customField.form.schema,
51
- },
52
- };
53
-
54
- return schema;
55
- }
56
-
57
- private _findCustomFieldSchemaFromPlugin(collectionName: string) {
58
- const schema: CustomFieldJsonSchemaMoreSchemaGroup = {};
59
-
60
- const { $appPluginsStore } = useNuxtApp();
61
-
62
- const pluginForms = $appPluginsStore.getForm(collectionName);
63
- if (!pluginForms || pluginForms.length <= 0) {
64
- return schema;
65
- }
66
-
67
- for (let i = 0; i < pluginForms.length; i++) {
68
- const pluginItem = pluginForms[i];
69
- const { pluginCode, jsonSchema } = pluginItem;
70
-
71
- schema[pluginCode] = jsonSchema as SimpleAppJSONSchema7Definition;
72
- }
73
-
74
- return schema;
75
- }
76
-
77
- formCustomFieldData(
78
- collectionName: string,
79
- moreSchema: CustomFieldJsonSchemaMoreSchema | undefined,
80
- isNew: boolean,
81
- resourceData: any | undefined,
82
- ) {
83
- if (!moreSchema || !moreSchema?.properties) {
84
- return resourceData;
85
- }
86
-
87
- if (collectionName !== "religion") {
88
- return resourceData;
89
- }
90
-
91
- const data: DynamicObject = {};
92
-
93
- if (!isNew) {
94
- for (const [groupName, groupItem] of Object.entries(
95
- moreSchema.properties,
96
- )) {
97
- const defaultData = this.generateDefaultData(groupItem);
98
- const mergedData = this.mergeWithDefault(
99
- defaultData,
100
- resourceData?.[groupName],
101
- );
102
-
103
- data[groupName] = mergedData;
104
- }
105
- } else {
106
- for (const [groupName, groupItem] of Object.entries(
107
- moreSchema.properties,
108
- )) {
109
- const defaultData = this.generateDefaultData(groupItem);
110
-
111
- data[groupName] = defaultData;
112
- }
113
- }
114
-
115
- return data;
116
- }
117
-
118
- generateDefaultData(schema: any): any {
119
- if (schema.type === "object") {
120
- const result: any = {};
121
- if (schema?.["x-foreignkey"]) {
122
- return undefined;
123
- }
124
-
125
- const properties = schema.properties || {};
126
- for (const key of Object.keys(properties)) {
127
- result[key] = this.generateDefaultData(properties[key]);
128
- }
129
- return result;
130
- }
131
-
132
- if (schema.type === "array") {
133
- const itemSchema = schema.items;
134
- const minItems = schema.minItems || 0;
135
- const arr = [];
136
- const itemsCount = minItems > 0 ? 1 : 0;
137
- for (let i = 0; i < itemsCount; i++) {
138
- arr.push(this.generateDefaultData(itemSchema));
139
- }
140
- return arr;
141
- }
142
-
143
- if (typeof schema.default !== "undefined") {
144
- return schema.default;
145
- }
146
-
147
- // handle primitive types fallback
148
- switch (schema.type) {
149
- case "string":
150
- return "";
151
- case "number":
152
- case "integer":
153
- return 0;
154
- case "boolean":
155
- return false;
156
- default:
157
- return null;
158
- }
159
- }
160
-
161
- mergeWithDefault(defaultData: any, dbData: any): any {
162
- if (Array.isArray(defaultData)) {
163
- if (Array.isArray(dbData)) {
164
- if (_.isEmpty(dbData)) {
165
- return [];
166
- }
167
- // Merge each item
168
- const mergedArray = dbData.map((dbItem, index) => {
169
- const defaultItem = defaultData[index] ?? defaultData[0]; // use first default if index out of bound
170
- return this.mergeWithDefault(defaultItem, dbItem);
171
- });
172
- return mergedArray;
173
- } else {
174
- // return defaultData;
175
- return [];
176
- }
177
- } else if (typeof defaultData === "object" && defaultData !== null) {
178
- const result: any = {};
179
- for (const key of Object.keys(defaultData)) {
180
- result[key] = this.mergeWithDefault(defaultData[key], dbData?.[key]);
181
- }
182
- return result;
183
- } else {
184
- // primitive value
185
- return typeof dbData !== "undefined" ? dbData : defaultData;
186
- }
187
- }
188
- }