@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.
- package/dist/buildinschemas/autoincreament.d.ts.map +1 -1
- package/dist/buildinschemas/autoincreament.js +17 -14
- package/dist/buildinschemas/autoincreament.js.map +1 -1
- package/dist/buildinschemas/branch.d.ts.map +1 -1
- package/dist/buildinschemas/branch.js +25 -24
- package/dist/buildinschemas/branch.js.map +1 -1
- package/dist/buildinschemas/changehistories.d.ts.map +1 -1
- package/dist/buildinschemas/changehistories.js +10 -9
- package/dist/buildinschemas/changehistories.js.map +1 -1
- package/dist/buildinschemas/customfield.d.ts.map +1 -1
- package/dist/buildinschemas/customfield.js +16 -15
- package/dist/buildinschemas/customfield.js.map +1 -1
- package/dist/buildinschemas/docnoformat.d.ts.map +1 -1
- package/dist/buildinschemas/docnoformat.js +34 -23
- package/dist/buildinschemas/docnoformat.js.map +1 -1
- package/dist/buildinschemas/documentevent.d.ts.map +1 -1
- package/dist/buildinschemas/documentevent.js +36 -26
- package/dist/buildinschemas/documentevent.js.map +1 -1
- package/dist/buildinschemas/keyvaluepair.d.ts.map +1 -1
- package/dist/buildinschemas/keyvaluepair.js +7 -6
- package/dist/buildinschemas/keyvaluepair.js.map +1 -1
- package/dist/buildinschemas/organization.d.ts.map +1 -1
- package/dist/buildinschemas/organization.js +34 -30
- package/dist/buildinschemas/organization.js.map +1 -1
- package/dist/buildinschemas/permission.d.ts.map +1 -1
- package/dist/buildinschemas/permission.js +16 -7
- package/dist/buildinschemas/permission.js.map +1 -1
- package/dist/buildinschemas/systemmessage.d.ts.map +1 -1
- package/dist/buildinschemas/systemmessage.js +35 -32
- package/dist/buildinschemas/systemmessage.js.map +1 -1
- package/dist/buildinschemas/tenant.d.ts.map +1 -1
- package/dist/buildinschemas/tenant.js +17 -16
- package/dist/buildinschemas/tenant.js.map +1 -1
- package/dist/buildinschemas/user.d.ts.map +1 -1
- package/dist/buildinschemas/user.js +34 -31
- package/dist/buildinschemas/user.js.map +1 -1
- package/dist/buildinschemas/webhook.d.ts.map +1 -1
- package/dist/buildinschemas/webhook.js +24 -23
- package/dist/buildinschemas/webhook.js.map +1 -1
- package/dist/framework.d.ts +2 -0
- package/dist/framework.d.ts.map +1 -1
- package/dist/framework.js +92 -57
- package/dist/framework.js.map +1 -1
- package/dist/generate.d.ts.map +1 -1
- package/dist/generate.js +175 -34
- package/dist/generate.js.map +1 -1
- package/dist/index.js +30 -12
- package/dist/index.js.map +1 -1
- package/dist/processors/jsonschemabuilder.js +14 -12
- package/dist/processors/jsonschemabuilder.js.map +1 -1
- package/dist/type.d.ts +44 -5
- package/dist/type.d.ts.map +1 -1
- package/dist/type.js.map +1 -1
- package/package.json +1 -1
- package/src/buildinschemas/autoincreament.ts +35 -33
- package/src/buildinschemas/branch.ts +47 -47
- package/src/buildinschemas/changehistories.ts +31 -30
- package/src/buildinschemas/customfield.ts +17 -16
- package/src/buildinschemas/docnoformat.ts +54 -43
- package/src/buildinschemas/documentevent.ts +42 -33
- package/src/buildinschemas/keyvaluepair.ts +25 -25
- package/src/buildinschemas/organization.ts +54 -50
- package/src/buildinschemas/permission.ts +34 -25
- package/src/buildinschemas/systemmessage.ts +39 -38
- package/src/buildinschemas/tenant.ts +46 -45
- package/src/buildinschemas/user.ts +64 -60
- package/src/buildinschemas/webhook.ts +62 -61
- package/src/framework.ts +307 -251
- package/src/generate.ts +608 -434
- package/src/index.ts +136 -118
- package/src/processors/jsonschemabuilder.ts +6 -4
- package/src/type.ts +287 -226
- package/templates/basic/miniAppJsSdk/resource-bridge.service.ts.eta +119 -0
- package/templates/basic/miniAppStreamlitSdk/resource-bridge.service.ts.eta +228 -0
- package/templates/basic/nuxt/jsonschema.ts.eta +7 -0
- package/templates/basic/nuxt/resource-bridge.editable.service.ts.eta +40 -0
- package/templates/basic/nuxt/resource-bridge.service.ts.eta +165 -0
- package/templates/basic/nuxt/simpleapp.generate.client.ts.eta +27 -9
- package/templates/miniAppJsSdk/src/index.ts.eta +28 -0
- package/templates/miniAppJsSdk/src/services/bridge-resource-accessor.service.ts.eta +70 -0
- package/templates/miniAppJsSdk/src/services/bridge.service.ts.eta +91 -0
- package/templates/miniAppJsSdk/src/types/service.type.ts.eta +22 -0
- package/templates/miniAppStreamlitSdk/simtrain_eco_mini_app_streamlit_sdk/sdk.py.eta +76 -0
- package/templates/nest/src/simpleapp/generate/jsonschemas/index.ts.eta +11 -0
- package/templates/nest/src/simpleapp/types/customfield.ts.eta +14 -0
- package/templates/nuxt/components/simpleApp/SimpleAppForm.vue.eta +3 -3
- package/templates/nuxt/components/simpleApp/SimpleAppInputTable.vue.eta +0 -1
- package/templates/nuxt/plugins/18.simpleapp-custom-field-store.ts.eta +9 -3
- package/templates/nuxt/plugins/20.simpleapp-userstore.ts.eta +316 -341
- package/templates/nuxt/simpleapp/generate/clients/SimpleAppClient.ts.eta +32 -21
- package/templates/nuxt/simpleapp/generate/jsonSchemas/index.ts.eta +11 -0
- package/templates/nuxt/simpleapp/generate/miniApp/bridge/constants/common.constant.ts.eta +16 -0
- package/templates/nuxt/simpleapp/generate/miniApp/bridge/constants/resource.constant.ts.eta +46 -0
- package/templates/nuxt/simpleapp/generate/miniApp/bridge/services/bridge-resource-accessor.service.ts.eta +63 -0
- package/templates/nuxt/simpleapp/generate/miniApp/bridge/services/bridge.service.ts.eta +129 -0
- package/templates/nuxt/simpleapp/generate/miniApp/bridge/types/bridge.type.ts.eta +81 -0
- package/templates/nuxt/simpleapp/generate/miniApp/bridge/types/resource-mapper.type.ts.eta +55 -0
- package/templates/nuxt/types/others.ts.eta +74 -65
- package/templates/nuxt/types/schema.ts.eta +225 -188
- package/templates/project/build.sh.eta +4 -0
- package/templates/nuxt/simpleapp/generate/clients/SimpleAppCustomFieldClient.ts.eta +0 -191
|
@@ -4,201 +4,238 @@
|
|
|
4
4
|
* last change 2024-02-23
|
|
5
5
|
* Author: Ks Tan
|
|
6
6
|
*/
|
|
7
|
-
import
|
|
7
|
+
import {
|
|
8
|
+
JSONSchema7,
|
|
9
|
+
JSONSchema7Type,
|
|
10
|
+
JSONSchema7Version,
|
|
11
|
+
JSONSchema7TypeName,
|
|
12
|
+
JSONSchema7Definition,
|
|
13
|
+
} from "json-schema";
|
|
8
14
|
export type DocumentStatus = {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
15
|
+
status: string; //'CO', 'V', 'CL', 'D' and etc
|
|
16
|
+
statusName: string;
|
|
17
|
+
readOnly: boolean;
|
|
18
|
+
actions: string[]; //api name ['confirm','revert','close','void' and etc]
|
|
19
|
+
};
|
|
20
|
+
export enum RESTMethods {
|
|
21
|
+
"post" = "post",
|
|
22
|
+
"get" = "get",
|
|
23
|
+
"delete" = "delete",
|
|
24
|
+
"put" = "put",
|
|
25
|
+
"patch" = "patch",
|
|
26
|
+
}
|
|
27
|
+
export type DocumentApi = {
|
|
28
|
+
action: string; //api action name
|
|
29
|
+
entryPoint: string; //api entry point example:':id', ':id/confirm'
|
|
30
|
+
queryPara?: string[]; //what query parameter wish to accept, example: ['description','date']
|
|
31
|
+
requiredRole?: string[]; // what special user role wish to allow for this api, example: ['SuperUser']
|
|
32
|
+
workflowSetting?: { bpmn: string }; //optional property, once define code gen connect the bpmn workflow
|
|
33
|
+
method: RESTMethods;
|
|
34
|
+
schema?: string; //any schema/type name in types & apischemas
|
|
35
|
+
responseType?: string; //any schema/type name for response
|
|
36
|
+
description: string; //description of api
|
|
37
|
+
};
|
|
38
|
+
export enum IsolationType {
|
|
39
|
+
"none" = "none",
|
|
40
|
+
"tenant" = "tenant",
|
|
41
|
+
"org" = "org",
|
|
42
|
+
"branch" = "branch",
|
|
43
|
+
}
|
|
44
|
+
// export type ImportLibs = {"lib":string,"as":string}
|
|
45
|
+
export type Formula = {
|
|
46
|
+
jsonPath: string; //example: "$.subtotal","$.details[*]"
|
|
47
|
+
formula: string; //example "jslib.getDocumentSubTotal(@F{$.details})"
|
|
48
|
+
};
|
|
32
49
|
export type SchemaConfig = {
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
50
|
+
isolationType: string;
|
|
51
|
+
requiredRoles?: string[];
|
|
52
|
+
pageType?: string;
|
|
53
|
+
uniqueKey?: string;
|
|
54
|
+
uniqueKeys?: string[][];
|
|
55
|
+
documentTitle?: string;
|
|
56
|
+
generateDocumentNumber?: boolean;
|
|
57
|
+
docNoPattern?: string;
|
|
58
|
+
documentDate?: string;
|
|
59
|
+
allStatus?: DocumentStatus[];
|
|
60
|
+
additionalApis?: DocumentApi[];
|
|
61
|
+
search?: string[];
|
|
62
|
+
additionalAutoCompleteFields?: string[];
|
|
63
|
+
// libs?:ImportLibs[] // both process class and frontend client class will import same lib
|
|
64
|
+
formulas?: Formula[];
|
|
65
|
+
documentType: string;
|
|
66
|
+
documentName: string;
|
|
67
|
+
collectionName?: string;
|
|
68
|
+
foreignKeys?: MyForeignKey;
|
|
69
|
+
printFormats?: SchemaPrintFormat[];
|
|
70
|
+
};
|
|
54
71
|
|
|
55
72
|
export type SchemaPrintFormat = {
|
|
56
|
-
formatName: string
|
|
57
|
-
formatId: string
|
|
58
|
-
description?: string
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
73
|
+
formatName: string;
|
|
74
|
+
formatId: string;
|
|
75
|
+
description?: string;
|
|
76
|
+
};
|
|
77
|
+
export type MyForeignKey = {
|
|
78
|
+
[collectionname: string]: string[];
|
|
79
|
+
};
|
|
80
|
+
|
|
64
81
|
export type SchemaType = {
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
82
|
+
type: string;
|
|
83
|
+
definitions?: SimpleAppJSONSchema7;
|
|
84
|
+
required?: string[];
|
|
85
|
+
|
|
86
|
+
"x-simpleapp-config": SchemaConfig;
|
|
87
|
+
properties: SchemaFields;
|
|
88
|
+
};
|
|
89
|
+
|
|
90
|
+
export type CustomFieldJsonSchemaMore = {
|
|
91
|
+
more?: CustomFieldJsonSchemaMoreSchema;
|
|
92
|
+
};
|
|
93
|
+
|
|
94
|
+
export type CustomFieldJsonSchemaMoreSchema = SimpleAppJSONSchema7 & {
|
|
95
|
+
properties: CustomFieldJsonSchemaMoreSchemaGroup;
|
|
96
|
+
};
|
|
97
|
+
|
|
98
|
+
export type CustomFieldJsonSchemaMoreSchemaGroup = {
|
|
99
|
+
[key: string]: SimpleAppJSONSchema7Definition;
|
|
100
|
+
};
|
|
101
|
+
|
|
74
102
|
export type SchemaFields = {
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
pattern?: string | undefined;
|
|
129
|
-
|
|
130
|
-
/**
|
|
131
|
-
* @see https://tools.ietf.org/html/draft-handrews-json-schema-validation-01#section-6.4
|
|
132
|
-
*/
|
|
133
|
-
items?: SimpleAppJSONSchema7Definition | SimpleAppJSONSchema7Definition[] | undefined;
|
|
134
|
-
additionalItems?: JSONSchema7Definition | undefined;
|
|
135
|
-
maxItems?: number | undefined;
|
|
136
|
-
minItems?: number | undefined;
|
|
137
|
-
uniqueItems?: boolean | undefined;
|
|
138
|
-
contains?: SimpleAppJSONSchema7Definition | undefined;
|
|
139
|
-
|
|
140
|
-
/**
|
|
141
|
-
* @see https://tools.ietf.org/html/draft-handrews-json-schema-validation-01#section-6.5
|
|
142
|
-
*/
|
|
143
|
-
maxProperties?: number | undefined;
|
|
144
|
-
minProperties?: number | undefined;
|
|
145
|
-
required?: string[] | undefined;
|
|
146
|
-
properties?: {
|
|
147
|
-
[key: string]: SimpleAppJSONSchema7Definition;
|
|
148
|
-
} | undefined;
|
|
149
|
-
patternProperties?: {
|
|
150
|
-
[key: string]: SimpleAppJSONSchema7Definition;
|
|
151
|
-
} | undefined;
|
|
152
|
-
additionalProperties?: SimpleAppJSONSchema7Definition | undefined;
|
|
153
|
-
dependencies?: {
|
|
154
|
-
[key: string]: SimpleAppJSONSchema7Definition | string[];
|
|
155
|
-
} | undefined;
|
|
156
|
-
propertyNames?: SimpleAppJSONSchema7Definition | undefined;
|
|
157
|
-
|
|
158
|
-
/**
|
|
159
|
-
* @see https://tools.ietf.org/html/draft-handrews-json-schema-validation-01#section-6.6
|
|
160
|
-
*/
|
|
161
|
-
if?: SimpleAppJSONSchema7Definition | undefined;
|
|
162
|
-
then?: SimpleAppJSONSchema7Definition | undefined;
|
|
163
|
-
else?: SimpleAppJSONSchema7Definition | undefined;
|
|
164
|
-
|
|
165
|
-
/**
|
|
166
|
-
* @see https://tools.ietf.org/html/draft-handrews-json-schema-validation-01#section-6.7
|
|
167
|
-
*/
|
|
168
|
-
allOf?: SimpleAppJSONSchema7Definition[] | undefined;
|
|
169
|
-
anyOf?: SimpleAppJSONSchema7Definition[] | undefined;
|
|
170
|
-
oneOf?: SimpleAppJSONSchema7Definition[] | undefined;
|
|
171
|
-
not?: SimpleAppJSONSchema7Definition | undefined;
|
|
172
|
-
|
|
173
|
-
/**
|
|
174
|
-
* @see https://tools.ietf.org/html/draft-handrews-json-schema-validation-01#section-7
|
|
175
|
-
*/
|
|
176
|
-
format?: string | undefined;
|
|
177
|
-
|
|
178
|
-
/**
|
|
179
|
-
* @see https://tools.ietf.org/html/draft-handrews-json-schema-validation-01#section-8
|
|
180
|
-
*/
|
|
181
|
-
contentMediaType?: string | undefined;
|
|
182
|
-
contentEncoding?: string | undefined;
|
|
183
|
-
|
|
184
|
-
/**
|
|
185
|
-
* @see https://tools.ietf.org/html/draft-handrews-json-schema-validation-01#section-9
|
|
186
|
-
*/
|
|
187
|
-
definitions?: {
|
|
188
|
-
[key: string]: JSONSchema7Definition;
|
|
189
|
-
} | undefined;
|
|
190
|
-
|
|
191
|
-
/**
|
|
192
|
-
* @see https://tools.ietf.org/html/draft-handrews-json-schema-validation-01#section-10
|
|
193
|
-
*/
|
|
194
|
-
title?: string | undefined;
|
|
195
|
-
description?: string | undefined;
|
|
196
|
-
default?: JSONSchema7Type | undefined;
|
|
197
|
-
readOnly?: boolean | undefined;
|
|
198
|
-
writeOnly?: boolean | undefined;
|
|
199
|
-
examples?: JSONSchema7Type[] | undefined;
|
|
200
|
-
}
|
|
103
|
+
_id: SimpleAppJSONSchema7;
|
|
104
|
+
tenantId: SimpleAppJSONSchema7;
|
|
105
|
+
orgId: SimpleAppJSONSchema7;
|
|
106
|
+
branchId: SimpleAppJSONSchema7;
|
|
107
|
+
created: SimpleAppJSONSchema7;
|
|
108
|
+
updated: SimpleAppJSONSchema7;
|
|
109
|
+
createdBy: SimpleAppJSONSchema7;
|
|
110
|
+
updatedBy: SimpleAppJSONSchema7;
|
|
111
|
+
[key: string]: SimpleAppJSONSchema7 | SimpleAppJSONSchema7[] | undefined;
|
|
112
|
+
} & CustomFieldJsonSchemaMore;
|
|
113
|
+
|
|
114
|
+
// modified from jsonschemas
|
|
115
|
+
export type SimpleAppJSONSchema7Definition = SimpleAppJSONSchema7 | boolean;
|
|
116
|
+
export interface SimpleAppJSONSchema7 {
|
|
117
|
+
inputType?: string;
|
|
118
|
+
"x-foreignkey"?: string;
|
|
119
|
+
$id?: string | undefined;
|
|
120
|
+
$ref?: string | undefined;
|
|
121
|
+
$schema?: JSONSchema7Version | undefined;
|
|
122
|
+
$comment?: string | undefined;
|
|
123
|
+
|
|
124
|
+
/**
|
|
125
|
+
* @see https://datatracker.ietf.org/doc/html/draft-bhutton-json-schema-00#section-8.2.4
|
|
126
|
+
* @see https://datatracker.ietf.org/doc/html/draft-bhutton-json-schema-validation-00#appendix-A
|
|
127
|
+
*/
|
|
128
|
+
$defs?:
|
|
129
|
+
| {
|
|
130
|
+
[key: string]: JSONSchema7Definition;
|
|
131
|
+
}
|
|
132
|
+
| undefined;
|
|
133
|
+
|
|
134
|
+
/**
|
|
135
|
+
* @see https://tools.ietf.org/html/draft-handrews-json-schema-validation-01#section-6.1
|
|
136
|
+
*/
|
|
137
|
+
type?: JSONSchema7TypeName | JSONSchema7TypeName[] | undefined;
|
|
138
|
+
enum?: JSONSchema7Type[] | undefined;
|
|
139
|
+
const?: JSONSchema7Type | undefined;
|
|
140
|
+
|
|
141
|
+
/**
|
|
142
|
+
* @see https://tools.ietf.org/html/draft-handrews-json-schema-validation-01#section-6.2
|
|
143
|
+
*/
|
|
144
|
+
multipleOf?: number | undefined;
|
|
145
|
+
maximum?: number | undefined;
|
|
146
|
+
exclusiveMaximum?: number | undefined;
|
|
147
|
+
minimum?: number | undefined;
|
|
148
|
+
exclusiveMinimum?: number | undefined;
|
|
149
|
+
|
|
150
|
+
/**
|
|
151
|
+
* @see https://tools.ietf.org/html/draft-handrews-json-schema-validation-01#section-6.3
|
|
152
|
+
*/
|
|
153
|
+
maxLength?: number | undefined;
|
|
154
|
+
minLength?: number | undefined;
|
|
155
|
+
pattern?: string | undefined;
|
|
201
156
|
|
|
157
|
+
/**
|
|
158
|
+
* @see https://tools.ietf.org/html/draft-handrews-json-schema-validation-01#section-6.4
|
|
159
|
+
*/
|
|
160
|
+
items?:
|
|
161
|
+
| SimpleAppJSONSchema7Definition
|
|
162
|
+
| SimpleAppJSONSchema7Definition[]
|
|
163
|
+
| undefined;
|
|
164
|
+
additionalItems?: JSONSchema7Definition | undefined;
|
|
165
|
+
maxItems?: number | undefined;
|
|
166
|
+
minItems?: number | undefined;
|
|
167
|
+
uniqueItems?: boolean | undefined;
|
|
168
|
+
contains?: SimpleAppJSONSchema7Definition | undefined;
|
|
169
|
+
|
|
170
|
+
/**
|
|
171
|
+
* @see https://tools.ietf.org/html/draft-handrews-json-schema-validation-01#section-6.5
|
|
172
|
+
*/
|
|
173
|
+
maxProperties?: number | undefined;
|
|
174
|
+
minProperties?: number | undefined;
|
|
175
|
+
required?: string[] | undefined;
|
|
176
|
+
properties?:
|
|
177
|
+
| {
|
|
178
|
+
[key: string]: SimpleAppJSONSchema7Definition;
|
|
179
|
+
}
|
|
180
|
+
| undefined;
|
|
181
|
+
patternProperties?:
|
|
182
|
+
| {
|
|
183
|
+
[key: string]: SimpleAppJSONSchema7Definition;
|
|
184
|
+
}
|
|
185
|
+
| undefined;
|
|
186
|
+
additionalProperties?: SimpleAppJSONSchema7Definition | undefined;
|
|
187
|
+
dependencies?:
|
|
188
|
+
| {
|
|
189
|
+
[key: string]: SimpleAppJSONSchema7Definition | string[];
|
|
190
|
+
}
|
|
191
|
+
| undefined;
|
|
192
|
+
propertyNames?: SimpleAppJSONSchema7Definition | undefined;
|
|
193
|
+
|
|
194
|
+
/**
|
|
195
|
+
* @see https://tools.ietf.org/html/draft-handrews-json-schema-validation-01#section-6.6
|
|
196
|
+
*/
|
|
197
|
+
if?: SimpleAppJSONSchema7Definition | undefined;
|
|
198
|
+
then?: SimpleAppJSONSchema7Definition | undefined;
|
|
199
|
+
else?: SimpleAppJSONSchema7Definition | undefined;
|
|
200
|
+
|
|
201
|
+
/**
|
|
202
|
+
* @see https://tools.ietf.org/html/draft-handrews-json-schema-validation-01#section-6.7
|
|
203
|
+
*/
|
|
204
|
+
allOf?: SimpleAppJSONSchema7Definition[] | undefined;
|
|
205
|
+
anyOf?: SimpleAppJSONSchema7Definition[] | undefined;
|
|
206
|
+
oneOf?: SimpleAppJSONSchema7Definition[] | undefined;
|
|
207
|
+
not?: SimpleAppJSONSchema7Definition | undefined;
|
|
208
|
+
|
|
209
|
+
/**
|
|
210
|
+
* @see https://tools.ietf.org/html/draft-handrews-json-schema-validation-01#section-7
|
|
211
|
+
*/
|
|
212
|
+
format?: string | undefined;
|
|
213
|
+
|
|
214
|
+
/**
|
|
215
|
+
* @see https://tools.ietf.org/html/draft-handrews-json-schema-validation-01#section-8
|
|
216
|
+
*/
|
|
217
|
+
contentMediaType?: string | undefined;
|
|
218
|
+
contentEncoding?: string | undefined;
|
|
219
|
+
|
|
220
|
+
/**
|
|
221
|
+
* @see https://tools.ietf.org/html/draft-handrews-json-schema-validation-01#section-9
|
|
222
|
+
*/
|
|
223
|
+
definitions?:
|
|
224
|
+
| {
|
|
225
|
+
[key: string]: JSONSchema7Definition;
|
|
226
|
+
}
|
|
227
|
+
| undefined;
|
|
228
|
+
|
|
229
|
+
/**
|
|
230
|
+
* @see https://tools.ietf.org/html/draft-handrews-json-schema-validation-01#section-10
|
|
231
|
+
*/
|
|
232
|
+
title?: string | undefined;
|
|
233
|
+
description?: string | undefined;
|
|
234
|
+
default?: JSONSchema7Type | undefined;
|
|
235
|
+
readOnly?: boolean | undefined;
|
|
236
|
+
writeOnly?: boolean | undefined;
|
|
237
|
+
examples?: JSONSchema7Type[] | undefined;
|
|
238
|
+
}
|
|
202
239
|
|
|
203
240
|
// ==================== Start Custom Field ====================
|
|
204
241
|
|
|
@@ -17,6 +17,10 @@ elif [ $type == 'backend' ]; then
|
|
|
17
17
|
elif [ $type == 'updatebackend' ]; then
|
|
18
18
|
simpleapp-generator -c config.json -g updatebackend
|
|
19
19
|
cp -a ./sharelibs backend/src/simpleapp/generate
|
|
20
|
+
elif [ $type == 'updateMiniAppJsSdk' ]; then
|
|
21
|
+
simpleapp-generator -c config.json -g updateMiniAppJsSdk
|
|
22
|
+
elif [ $type == 'updateMiniAppStreamlitSdk' ]; then
|
|
23
|
+
simpleapp-generator -c config.json -g updateMiniAppStreamlitSdk
|
|
20
24
|
fi
|
|
21
25
|
|
|
22
26
|
|
|
@@ -1,191 +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 { isEmpty } from "lodash";
|
|
7
|
-
import {
|
|
8
|
-
CustomFieldItemJsonSchema,
|
|
9
|
-
CustomFieldJsonSchema,
|
|
10
|
-
SimpleAppJSONSchema7,
|
|
11
|
-
} from "~/types";
|
|
12
|
-
|
|
13
|
-
export type CustomFieldMoreDataGroup = {
|
|
14
|
-
[key: string]: CustomFieldMoreDataGroupItem;
|
|
15
|
-
};
|
|
16
|
-
|
|
17
|
-
export type CustomFieldMoreDataGroupItem = {
|
|
18
|
-
[key: string]: any;
|
|
19
|
-
};
|
|
20
|
-
|
|
21
|
-
export class SimpleAppCustomFieldClient {
|
|
22
|
-
private _defaultReturn = {
|
|
23
|
-
schema: {
|
|
24
|
-
type: "object",
|
|
25
|
-
properties: {},
|
|
26
|
-
},
|
|
27
|
-
};
|
|
28
|
-
|
|
29
|
-
constructor() {}
|
|
30
|
-
|
|
31
|
-
processCustomField(collectionName: string) {
|
|
32
|
-
// console.log(collectionName, "trigger processCustomField");
|
|
33
|
-
const { $customFieldStore } = useNuxtApp();
|
|
34
|
-
if (!$customFieldStore.data || isEmpty($customFieldStore.data)) {
|
|
35
|
-
// Not Found Any Custom Field
|
|
36
|
-
return this._defaultReturn;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
const customField = $customFieldStore.findByCollectionName(collectionName);
|
|
40
|
-
if (!customField) {
|
|
41
|
-
// Not Found Custom Field In Current collectionName
|
|
42
|
-
return this._defaultReturn;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
const schema = this._processCustomFieldMoreProperties(
|
|
46
|
-
collectionName,
|
|
47
|
-
customField.form.schema as CustomFieldItemJsonSchema,
|
|
48
|
-
);
|
|
49
|
-
|
|
50
|
-
return { schema };
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
private _processCustomFieldMoreProperties(
|
|
54
|
-
collectionName: string,
|
|
55
|
-
customFieldJsonSchemaString: CustomFieldItemJsonSchema | undefined,
|
|
56
|
-
) {
|
|
57
|
-
const customFieldJsonSchema = this._processCustomFieldProperties(
|
|
58
|
-
customFieldJsonSchemaString,
|
|
59
|
-
);
|
|
60
|
-
const pluginJsonSchema =
|
|
61
|
-
this._processPluginCustomFieldProperties(collectionName);
|
|
62
|
-
return {
|
|
63
|
-
type: "object",
|
|
64
|
-
properties: {
|
|
65
|
-
...customFieldJsonSchema,
|
|
66
|
-
...pluginJsonSchema,
|
|
67
|
-
},
|
|
68
|
-
};
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
private _processPluginCustomFieldProperties(collectionName: string) {
|
|
72
|
-
const schema: CustomFieldJsonSchema["properties"] = {};
|
|
73
|
-
const { $appPluginsStore } = useNuxtApp();
|
|
74
|
-
const pluginForms = $appPluginsStore.getForm(collectionName);
|
|
75
|
-
if (!pluginForms || pluginForms.length <= 0) {
|
|
76
|
-
return schema;
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
for (let i = 0; i < pluginForms.length; i++) {
|
|
80
|
-
const pluginItem = pluginForms[i];
|
|
81
|
-
const { pluginCode, jsonSchema } = pluginItem;
|
|
82
|
-
|
|
83
|
-
schema[pluginCode] = jsonSchema as CustomFieldItemJsonSchema;
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
return schema;
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
private _processCustomFieldProperties(
|
|
90
|
-
customFieldJsonSchemaString: CustomFieldItemJsonSchema | undefined,
|
|
91
|
-
) {
|
|
92
|
-
if (!customFieldJsonSchemaString) {
|
|
93
|
-
return this._defaultReturn;
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
return {
|
|
97
|
-
default: {
|
|
98
|
-
title: "Custom Field",
|
|
99
|
-
...customFieldJsonSchemaString,
|
|
100
|
-
},
|
|
101
|
-
};
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
processCustomFieldData(
|
|
105
|
-
moreSchema: CustomFieldJsonSchema | undefined,
|
|
106
|
-
isNew: boolean,
|
|
107
|
-
resourceData: CustomFieldMoreDataGroup | undefined,
|
|
108
|
-
) {
|
|
109
|
-
const data: Record<string, any> = {};
|
|
110
|
-
if (!moreSchema || !moreSchema?.properties) {
|
|
111
|
-
return data;
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
for (const [groupName, groupItem] of Object.entries(
|
|
115
|
-
moreSchema.properties,
|
|
116
|
-
)) {
|
|
117
|
-
let groupData: Record<string, any> = {};
|
|
118
|
-
if (groupItem.properties) {
|
|
119
|
-
groupData = this._processGroupItemData(
|
|
120
|
-
groupItem.properties,
|
|
121
|
-
isNew,
|
|
122
|
-
resourceData?.[groupName],
|
|
123
|
-
);
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
data[groupName] = groupData;
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
return data;
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
private _processGroupItemData(
|
|
133
|
-
groupItemProp: SimpleAppJSONSchema7 | SimpleAppJSONSchema7[] | undefined,
|
|
134
|
-
isNew: boolean,
|
|
135
|
-
resourceData: CustomFieldMoreDataGroupItem | undefined,
|
|
136
|
-
) {
|
|
137
|
-
const data: Record<string, any> = {};
|
|
138
|
-
|
|
139
|
-
if (!groupItemProp) {
|
|
140
|
-
return data;
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
for (const [fieldName, fieldItem] of Object.entries(groupItemProp)) {
|
|
144
|
-
let value;
|
|
145
|
-
if (isNew) {
|
|
146
|
-
// New Record
|
|
147
|
-
value = this._getFieldDefaultValue(fieldItem);
|
|
148
|
-
} else {
|
|
149
|
-
// Fetch By Id
|
|
150
|
-
if (resourceData?.[fieldName]) {
|
|
151
|
-
// DB got this field
|
|
152
|
-
value = resourceData?.[fieldName];
|
|
153
|
-
} else {
|
|
154
|
-
// DB don't have this field
|
|
155
|
-
value = this._getDefaultValueByType(fieldItem);
|
|
156
|
-
console.log(fieldName, value);
|
|
157
|
-
}
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
data[fieldName] = value;
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
return data;
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
private _getFieldDefaultValue(fieldItem: SimpleAppJSONSchema7) {
|
|
167
|
-
return fieldItem.default !== undefined
|
|
168
|
-
? fieldItem.default
|
|
169
|
-
: this._getDefaultValueByType(fieldItem);
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
private _getDefaultValueByType(fieldItem: SimpleAppJSONSchema7) {
|
|
173
|
-
if (fieldItem.type === "string") {
|
|
174
|
-
return "";
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
if (fieldItem.type === "number") {
|
|
178
|
-
return 0;
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
if (fieldItem.type === "object") {
|
|
182
|
-
return {};
|
|
183
|
-
}
|
|
184
|
-
|
|
185
|
-
if (fieldItem.type === "array") {
|
|
186
|
-
return [];
|
|
187
|
-
}
|
|
188
|
-
|
|
189
|
-
return "";
|
|
190
|
-
}
|
|
191
|
-
}
|