@ruiapp/rapid-configure-tools 0.6.1 → 0.6.3
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/meta-file-generator/generators/model-index-generator.d.ts +28 -0
- package/dist/meta-file-generator/mod.d.ts +4 -0
- package/dist/mod.d.ts +2 -0
- package/dist/mod.js +63 -38
- package/dist/rapid-models-updater/mod.d.ts +2 -0
- package/package.json +3 -3
- package/src/meta-file-generator/generators/model-index-generator.ts +50 -50
- package/src/meta-file-generator/generators/model-types-generator.ts +2 -2
- package/src/meta-file-generator/mod.ts +5 -0
- package/src/mod.ts +3 -0
- package/src/rapid-models-updater/DictionaryEntryUpdater.ts +1 -1
- package/src/rapid-models-updater/DictionaryUpdater.ts +1 -1
- package/src/rapid-models-updater/ModelUpdater.ts +1 -1
- package/src/rapid-models-updater/PageUpdater.ts +1 -1
- package/src/rapid-models-updater/PropertyUpdater.ts +2 -1
- package/src/rapid-models-updater/mod.ts +3 -0
- /package/dist/{rapid-models-updater → utils}/ObjectChangesDetector.d.ts +0 -0
- /package/src/{rapid-models-updater → utils}/ObjectChangesDetector.ts +0 -0
|
@@ -1,4 +1,32 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* 用于生成模型索引文件,将模型定义按照类型分别导出。
|
|
3
3
|
*/
|
|
4
|
+
export interface GenerateConfigurationIndexFileOptions {
|
|
5
|
+
/**
|
|
6
|
+
* Where is the models directory.
|
|
7
|
+
*/
|
|
8
|
+
modelsDir: string;
|
|
9
|
+
/**
|
|
10
|
+
* where we should output the models index file.
|
|
11
|
+
*/
|
|
12
|
+
outputDir: string;
|
|
13
|
+
/**
|
|
14
|
+
* Where is the model type definition file.
|
|
15
|
+
*/
|
|
16
|
+
typeDefFilePath: string;
|
|
17
|
+
/**
|
|
18
|
+
* The directory name of the configuration files.
|
|
19
|
+
*/
|
|
20
|
+
configurationDirName: string;
|
|
21
|
+
/**
|
|
22
|
+
* The model type name in the `configurationDirName`.
|
|
23
|
+
*/
|
|
24
|
+
configurationTypeName: string;
|
|
25
|
+
indexFileName: string;
|
|
26
|
+
extraImports?: string[];
|
|
27
|
+
modelWrapper?: string;
|
|
28
|
+
flattenModelArray?: boolean;
|
|
29
|
+
}
|
|
30
|
+
export declare function generateEntityConfigIndexFile({ modelsDir, outputDir, typeDefFilePath, configurationDirName, configurationTypeName, indexFileName, extraImports, modelWrapper, flattenModelArray, }: GenerateConfigurationIndexFileOptions): void;
|
|
31
|
+
export declare function generateConfigIndexFile({ modelsDir, outputDir, typeDefFilePath, configurationDirName, configurationTypeName, indexFileName, extraImports, modelWrapper, flattenModelArray, }: GenerateConfigurationIndexFileOptions): void;
|
|
4
32
|
export declare function generateModelIndexFiles(declarationsDirectory: string): void;
|
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
export * from "./generators/model-index-generator";
|
|
2
|
+
export * from "./generators/model-codes-generator";
|
|
3
|
+
export * from "./generators/model-types-generator";
|
|
4
|
+
export * from "./generators/model-locales-generator";
|
|
1
5
|
export interface FileGenerateOption {
|
|
2
6
|
declarationsDirectory: string;
|
|
3
7
|
}
|
package/dist/mod.d.ts
CHANGED
|
@@ -2,3 +2,5 @@ export { default as MetaFileGenerator } from "./meta-file-generator/mod";
|
|
|
2
2
|
export * from "./meta-file-generator/mod";
|
|
3
3
|
export { default as RapidModelsUpdater } from "./rapid-models-updater/mod";
|
|
4
4
|
export * from "./rapid-models-updater/mod";
|
|
5
|
+
export * from "./utils/ObjectChangesDetector";
|
|
6
|
+
export * from "./utils/array-utils";
|
package/dist/mod.js
CHANGED
|
@@ -19,8 +19,8 @@ var axios__default = /*#__PURE__*/_interopDefaultLegacy(axios);
|
|
|
19
19
|
/**
|
|
20
20
|
* 用于生成模型索引文件,将模型定义按照类型分别导出。
|
|
21
21
|
*/
|
|
22
|
-
function
|
|
23
|
-
const filesDir = path__default["default"].join(modelsDir,
|
|
22
|
+
function generateEntityConfigIndexFile({ modelsDir, outputDir, typeDefFilePath, configurationDirName, configurationTypeName, indexFileName, extraImports, modelWrapper, flattenModelArray, }) {
|
|
23
|
+
const filesDir = path__default["default"].join(modelsDir, configurationDirName);
|
|
24
24
|
const fileNames = rapidCore.enumFileBaseNamesInDirectory({
|
|
25
25
|
dirPath: filesDir,
|
|
26
26
|
fileNameFilter(fileName) {
|
|
@@ -34,7 +34,7 @@ function generateEntityModelIndexFilesOfTypeDir({ modelsDir, outputDir, typeDefF
|
|
|
34
34
|
};
|
|
35
35
|
});
|
|
36
36
|
const codes = [];
|
|
37
|
-
codes.push(`import type { ${
|
|
37
|
+
codes.push(`import type { ${configurationTypeName} as T${configurationTypeName} } from '${typeDefFilePath}';`);
|
|
38
38
|
lodash.forEach(extraImports, (extraImport) => {
|
|
39
39
|
codes.push(extraImport);
|
|
40
40
|
});
|
|
@@ -43,7 +43,7 @@ function generateEntityModelIndexFilesOfTypeDir({ modelsDir, outputDir, typeDefF
|
|
|
43
43
|
if (fileName.includes(" ")) {
|
|
44
44
|
continue;
|
|
45
45
|
}
|
|
46
|
-
codes.push(`import ${modelName} from '../models/${
|
|
46
|
+
codes.push(`import ${modelName} from '../models/${configurationDirName}/${fileName}';`);
|
|
47
47
|
}
|
|
48
48
|
codes.push("");
|
|
49
49
|
codes.push("const entityDefinitions = [");
|
|
@@ -60,7 +60,7 @@ function generateEntityModelIndexFilesOfTypeDir({ modelsDir, outputDir, typeDefF
|
|
|
60
60
|
}
|
|
61
61
|
}
|
|
62
62
|
codes.push(`];`);
|
|
63
|
-
codes.push(`const configuredEntities:T${
|
|
63
|
+
codes.push(`const configuredEntities:T${configurationTypeName}[] = [`);
|
|
64
64
|
for (const model of models) {
|
|
65
65
|
const { modelName, fileName } = model;
|
|
66
66
|
if (fileName.includes(" ")) {
|
|
@@ -76,10 +76,10 @@ function generateEntityModelIndexFilesOfTypeDir({ modelsDir, outputDir, typeDefF
|
|
|
76
76
|
codes.push(`];`);
|
|
77
77
|
codes.push("export default configuredEntities;");
|
|
78
78
|
codes.push("");
|
|
79
|
-
fs__default["default"].writeFileSync(path__default["default"].join(outputDir,
|
|
79
|
+
fs__default["default"].writeFileSync(path__default["default"].join(outputDir, indexFileName + ".ts"), codes.join("\n"));
|
|
80
80
|
}
|
|
81
|
-
function
|
|
82
|
-
const filesDir = path__default["default"].join(modelsDir,
|
|
81
|
+
function generateConfigIndexFile({ modelsDir, outputDir, typeDefFilePath, configurationDirName, configurationTypeName, indexFileName, extraImports, modelWrapper, flattenModelArray, }) {
|
|
82
|
+
const filesDir = path__default["default"].join(modelsDir, configurationDirName);
|
|
83
83
|
const fileNames = rapidCore.enumFileBaseNamesInDirectory({
|
|
84
84
|
dirPath: filesDir,
|
|
85
85
|
fileNameFilter(fileName) {
|
|
@@ -93,7 +93,7 @@ function generateModelIndexFilesOfTypeDir({ modelsDir, outputDir, typeDefFilePat
|
|
|
93
93
|
};
|
|
94
94
|
});
|
|
95
95
|
const codes = [];
|
|
96
|
-
codes.push(`import type { ${
|
|
96
|
+
codes.push(`import type { ${configurationTypeName} as T${configurationTypeName} } from '${typeDefFilePath}';`);
|
|
97
97
|
lodash.forEach(extraImports, (extraImport) => {
|
|
98
98
|
codes.push(extraImport);
|
|
99
99
|
});
|
|
@@ -102,7 +102,7 @@ function generateModelIndexFilesOfTypeDir({ modelsDir, outputDir, typeDefFilePat
|
|
|
102
102
|
if (fileName.includes(" ")) {
|
|
103
103
|
continue;
|
|
104
104
|
}
|
|
105
|
-
codes.push(`import ${modelName} from '../models/${
|
|
105
|
+
codes.push(`import ${modelName} from '../models/${configurationDirName}/${fileName}';`);
|
|
106
106
|
}
|
|
107
107
|
codes.push("");
|
|
108
108
|
codes.push("export default [");
|
|
@@ -128,65 +128,65 @@ function generateModelIndexFilesOfTypeDir({ modelsDir, outputDir, typeDefFilePat
|
|
|
128
128
|
}
|
|
129
129
|
}
|
|
130
130
|
}
|
|
131
|
-
codes.push(`] as T${
|
|
131
|
+
codes.push(`] as T${configurationTypeName}[];`);
|
|
132
132
|
codes.push("");
|
|
133
|
-
fs__default["default"].writeFileSync(path__default["default"].join(outputDir,
|
|
133
|
+
fs__default["default"].writeFileSync(path__default["default"].join(outputDir, indexFileName + ".ts"), codes.join("\n"));
|
|
134
134
|
}
|
|
135
135
|
function generateModelIndexFiles(declarationsDirectory) {
|
|
136
136
|
const modelsDir = path__default["default"].join(declarationsDirectory, "models");
|
|
137
137
|
const outputDir = path__default["default"].join(declarationsDirectory, "meta");
|
|
138
138
|
const typeDefFilePath = "@ruiapp/rapid-extension";
|
|
139
139
|
rapidCore.ensureDirectoryExists(outputDir);
|
|
140
|
-
|
|
140
|
+
generateEntityConfigIndexFile({
|
|
141
141
|
modelsDir,
|
|
142
142
|
outputDir,
|
|
143
143
|
typeDefFilePath,
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
144
|
+
configurationDirName: "entities",
|
|
145
|
+
configurationTypeName: "RapidEntity",
|
|
146
|
+
indexFileName: "entity-models",
|
|
147
147
|
extraImports: [`import { autoConfigureRapidEntity } from '@ruiapp/rapid-extension';`],
|
|
148
148
|
modelWrapper: "autoConfigureRapidEntity",
|
|
149
149
|
});
|
|
150
|
-
|
|
150
|
+
generateConfigIndexFile({
|
|
151
151
|
modelsDir,
|
|
152
152
|
outputDir,
|
|
153
153
|
typeDefFilePath,
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
154
|
+
configurationDirName: "data-dictionaries",
|
|
155
|
+
configurationTypeName: "RapidDataDictionary",
|
|
156
|
+
indexFileName: "data-dictionary-models",
|
|
157
157
|
});
|
|
158
|
-
|
|
158
|
+
generateConfigIndexFile({
|
|
159
159
|
modelsDir,
|
|
160
160
|
outputDir,
|
|
161
161
|
typeDefFilePath,
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
162
|
+
configurationDirName: "pages",
|
|
163
|
+
configurationTypeName: "RapidPageLoader",
|
|
164
|
+
indexFileName: "page-models",
|
|
165
165
|
});
|
|
166
|
-
|
|
166
|
+
generateConfigIndexFile({
|
|
167
167
|
modelsDir,
|
|
168
168
|
outputDir,
|
|
169
169
|
typeDefFilePath: "@ruiapp/rapid-core",
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
170
|
+
configurationDirName: "server-operations",
|
|
171
|
+
configurationTypeName: "ServerOperation",
|
|
172
|
+
indexFileName: "server-operations",
|
|
173
173
|
});
|
|
174
|
-
|
|
174
|
+
generateConfigIndexFile({
|
|
175
175
|
modelsDir,
|
|
176
176
|
outputDir,
|
|
177
177
|
typeDefFilePath: "@ruiapp/rapid-core",
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
178
|
+
configurationDirName: "entity-watchers",
|
|
179
|
+
configurationTypeName: "EntityWatcherType",
|
|
180
|
+
indexFileName: "entity-watchers",
|
|
181
181
|
flattenModelArray: true,
|
|
182
182
|
});
|
|
183
|
-
|
|
183
|
+
generateConfigIndexFile({
|
|
184
184
|
modelsDir,
|
|
185
185
|
outputDir,
|
|
186
186
|
typeDefFilePath: "@ruiapp/rapid-core",
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
187
|
+
configurationDirName: "cron-jobs",
|
|
188
|
+
configurationTypeName: "CronJobConfiguration",
|
|
189
|
+
indexFileName: "cron-jobs",
|
|
190
190
|
flattenModelArray: false,
|
|
191
191
|
});
|
|
192
192
|
}
|
|
@@ -278,8 +278,8 @@ function convertSdRpdFieldTypeToTypeScriptType(field, entities) {
|
|
|
278
278
|
return `${dataDictionary}[]`;
|
|
279
279
|
case "relation":
|
|
280
280
|
case "relation[]":
|
|
281
|
-
const
|
|
282
|
-
return relation === "one" ? `Partial<${
|
|
281
|
+
const targetType = lodash.find(entities, { singularCode: targetSingularCode })?.code || "any";
|
|
282
|
+
return relation === "one" ? `Partial<${targetType}>` : `Partial<${targetType}>[]`;
|
|
283
283
|
case "file":
|
|
284
284
|
case "image":
|
|
285
285
|
return "FileOrImageFieldType";
|
|
@@ -849,6 +849,7 @@ function newPropertyUpdater(rapidConfigApi) {
|
|
|
849
849
|
"maxLength",
|
|
850
850
|
"relation",
|
|
851
851
|
"targetSingularCode",
|
|
852
|
+
"targetTypeColumnName",
|
|
852
853
|
"targetIdColumnName",
|
|
853
854
|
"selfIdColumnName",
|
|
854
855
|
"linkTableName",
|
|
@@ -1066,5 +1067,29 @@ class RapidModelsUpdater {
|
|
|
1066
1067
|
}
|
|
1067
1068
|
}
|
|
1068
1069
|
|
|
1070
|
+
function arrayToTree(arr, parent, option) {
|
|
1071
|
+
const { parentField = "parent", keyField = "id", childrenField = "children" } = option || {};
|
|
1072
|
+
return arr
|
|
1073
|
+
.filter((item) => {
|
|
1074
|
+
return lodash.get(item, parentField, null) === parent;
|
|
1075
|
+
})
|
|
1076
|
+
.map((child) => {
|
|
1077
|
+
return {
|
|
1078
|
+
...child,
|
|
1079
|
+
[childrenField]: arrayToTree(arr, child[keyField], option),
|
|
1080
|
+
};
|
|
1081
|
+
});
|
|
1082
|
+
}
|
|
1083
|
+
|
|
1084
|
+
exports.AppUpdater = RapidUpdater;
|
|
1069
1085
|
exports.MetaFileGenerator = MetaFileGenerator;
|
|
1070
1086
|
exports.RapidModelsUpdater = RapidModelsUpdater;
|
|
1087
|
+
exports.arrayToTree = arrayToTree;
|
|
1088
|
+
exports.detectChangedFields = detectChangedFields;
|
|
1089
|
+
exports.generateConfigIndexFile = generateConfigIndexFile;
|
|
1090
|
+
exports.generateDictionaryCodes = generateDictionaryCodes;
|
|
1091
|
+
exports.generateEntityConfigIndexFile = generateEntityConfigIndexFile;
|
|
1092
|
+
exports.generateModelCodes = generateModelCodes;
|
|
1093
|
+
exports.generateModelIndexFiles = generateModelIndexFiles;
|
|
1094
|
+
exports.generateSdRpdModelLocales = generateSdRpdModelLocales;
|
|
1095
|
+
exports.generateSdRpdModelTypes = generateSdRpdModelTypes;
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import type { RapidDataDictionary, RapidEntity, RapidPage } from "@ruiapp/rapid-extension";
|
|
2
|
+
export { default as AppUpdater } from "./AppUpdater";
|
|
3
|
+
export * from "./types";
|
|
2
4
|
export interface RapidModelsUpdateOptions {
|
|
3
5
|
appDataDirLocation: string;
|
|
4
6
|
rapidApiUrl: string;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ruiapp/rapid-configure-tools",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.3",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "dist/mod.js",
|
|
6
6
|
"keywords": [],
|
|
@@ -20,8 +20,8 @@
|
|
|
20
20
|
"axios-cookiejar-support": "^4.0.7",
|
|
21
21
|
"lodash": "^4.17.21",
|
|
22
22
|
"tough-cookie": "^4.1.3",
|
|
23
|
-
"@ruiapp/rapid-core": "^0.10.
|
|
24
|
-
"@ruiapp/rapid-extension": "^0.6.
|
|
23
|
+
"@ruiapp/rapid-core": "^0.10.5",
|
|
24
|
+
"@ruiapp/rapid-extension": "^0.6.18"
|
|
25
25
|
},
|
|
26
26
|
"dependencies": {},
|
|
27
27
|
"scripts": {
|
|
@@ -7,7 +7,7 @@ import { forEach } from "lodash";
|
|
|
7
7
|
import path from "path";
|
|
8
8
|
import { ensureDirectoryExists, enumFileBaseNamesInDirectory } from "@ruiapp/rapid-core";
|
|
9
9
|
|
|
10
|
-
interface
|
|
10
|
+
export interface GenerateConfigurationIndexFileOptions {
|
|
11
11
|
/**
|
|
12
12
|
* Where is the models directory.
|
|
13
13
|
*/
|
|
@@ -21,15 +21,15 @@ interface GenerateModelsIndexFileOption {
|
|
|
21
21
|
*/
|
|
22
22
|
typeDefFilePath: string;
|
|
23
23
|
/**
|
|
24
|
-
* The
|
|
24
|
+
* The directory name of the configuration files.
|
|
25
25
|
*/
|
|
26
|
-
|
|
26
|
+
configurationDirName: string;
|
|
27
27
|
/**
|
|
28
|
-
* The model type name in the `
|
|
28
|
+
* The model type name in the `configurationDirName`.
|
|
29
29
|
*/
|
|
30
|
-
|
|
30
|
+
configurationTypeName: string;
|
|
31
31
|
|
|
32
|
-
|
|
32
|
+
indexFileName: string;
|
|
33
33
|
|
|
34
34
|
extraImports?: string[];
|
|
35
35
|
|
|
@@ -38,18 +38,18 @@ interface GenerateModelsIndexFileOption {
|
|
|
38
38
|
flattenModelArray?: boolean;
|
|
39
39
|
}
|
|
40
40
|
|
|
41
|
-
function
|
|
41
|
+
export function generateEntityConfigIndexFile({
|
|
42
42
|
modelsDir,
|
|
43
43
|
outputDir,
|
|
44
44
|
typeDefFilePath,
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
45
|
+
configurationDirName,
|
|
46
|
+
configurationTypeName,
|
|
47
|
+
indexFileName,
|
|
48
48
|
extraImports,
|
|
49
49
|
modelWrapper,
|
|
50
50
|
flattenModelArray,
|
|
51
|
-
}:
|
|
52
|
-
const filesDir = path.join(modelsDir,
|
|
51
|
+
}: GenerateConfigurationIndexFileOptions) {
|
|
52
|
+
const filesDir = path.join(modelsDir, configurationDirName);
|
|
53
53
|
const fileNames = enumFileBaseNamesInDirectory({
|
|
54
54
|
dirPath: filesDir,
|
|
55
55
|
fileNameFilter(fileName) {
|
|
@@ -65,7 +65,7 @@ function generateEntityModelIndexFilesOfTypeDir({
|
|
|
65
65
|
});
|
|
66
66
|
|
|
67
67
|
const codes = [];
|
|
68
|
-
codes.push(`import type { ${
|
|
68
|
+
codes.push(`import type { ${configurationTypeName} as T${configurationTypeName} } from '${typeDefFilePath}';`);
|
|
69
69
|
forEach(extraImports, (extraImport) => {
|
|
70
70
|
codes.push(extraImport);
|
|
71
71
|
});
|
|
@@ -75,7 +75,7 @@ function generateEntityModelIndexFilesOfTypeDir({
|
|
|
75
75
|
if (fileName.includes(" ")) {
|
|
76
76
|
continue;
|
|
77
77
|
}
|
|
78
|
-
codes.push(`import ${modelName} from '../models/${
|
|
78
|
+
codes.push(`import ${modelName} from '../models/${configurationDirName}/${fileName}';`);
|
|
79
79
|
}
|
|
80
80
|
codes.push("");
|
|
81
81
|
|
|
@@ -94,7 +94,7 @@ function generateEntityModelIndexFilesOfTypeDir({
|
|
|
94
94
|
}
|
|
95
95
|
codes.push(`];`);
|
|
96
96
|
|
|
97
|
-
codes.push(`const configuredEntities:T${
|
|
97
|
+
codes.push(`const configuredEntities:T${configurationTypeName}[] = [`);
|
|
98
98
|
|
|
99
99
|
for (const model of models) {
|
|
100
100
|
const { modelName, fileName } = model;
|
|
@@ -112,21 +112,21 @@ function generateEntityModelIndexFilesOfTypeDir({
|
|
|
112
112
|
codes.push("export default configuredEntities;");
|
|
113
113
|
codes.push("");
|
|
114
114
|
|
|
115
|
-
fs.writeFileSync(path.join(outputDir,
|
|
115
|
+
fs.writeFileSync(path.join(outputDir, indexFileName + ".ts"), codes.join("\n"));
|
|
116
116
|
}
|
|
117
117
|
|
|
118
|
-
function
|
|
118
|
+
export function generateConfigIndexFile({
|
|
119
119
|
modelsDir,
|
|
120
120
|
outputDir,
|
|
121
121
|
typeDefFilePath,
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
122
|
+
configurationDirName,
|
|
123
|
+
configurationTypeName,
|
|
124
|
+
indexFileName,
|
|
125
125
|
extraImports,
|
|
126
126
|
modelWrapper,
|
|
127
127
|
flattenModelArray,
|
|
128
|
-
}:
|
|
129
|
-
const filesDir = path.join(modelsDir,
|
|
128
|
+
}: GenerateConfigurationIndexFileOptions) {
|
|
129
|
+
const filesDir = path.join(modelsDir, configurationDirName);
|
|
130
130
|
const fileNames = enumFileBaseNamesInDirectory({
|
|
131
131
|
dirPath: filesDir,
|
|
132
132
|
fileNameFilter(fileName) {
|
|
@@ -142,7 +142,7 @@ function generateModelIndexFilesOfTypeDir({
|
|
|
142
142
|
});
|
|
143
143
|
|
|
144
144
|
const codes = [];
|
|
145
|
-
codes.push(`import type { ${
|
|
145
|
+
codes.push(`import type { ${configurationTypeName} as T${configurationTypeName} } from '${typeDefFilePath}';`);
|
|
146
146
|
forEach(extraImports, (extraImport) => {
|
|
147
147
|
codes.push(extraImport);
|
|
148
148
|
});
|
|
@@ -152,7 +152,7 @@ function generateModelIndexFilesOfTypeDir({
|
|
|
152
152
|
if (fileName.includes(" ")) {
|
|
153
153
|
continue;
|
|
154
154
|
}
|
|
155
|
-
codes.push(`import ${modelName} from '../models/${
|
|
155
|
+
codes.push(`import ${modelName} from '../models/${configurationDirName}/${fileName}';`);
|
|
156
156
|
}
|
|
157
157
|
codes.push("");
|
|
158
158
|
|
|
@@ -177,10 +177,10 @@ function generateModelIndexFilesOfTypeDir({
|
|
|
177
177
|
}
|
|
178
178
|
}
|
|
179
179
|
}
|
|
180
|
-
codes.push(`] as T${
|
|
180
|
+
codes.push(`] as T${configurationTypeName}[];`);
|
|
181
181
|
codes.push("");
|
|
182
182
|
|
|
183
|
-
fs.writeFileSync(path.join(outputDir,
|
|
183
|
+
fs.writeFileSync(path.join(outputDir, indexFileName + ".ts"), codes.join("\n"));
|
|
184
184
|
}
|
|
185
185
|
|
|
186
186
|
export function generateModelIndexFiles(declarationsDirectory: string) {
|
|
@@ -190,60 +190,60 @@ export function generateModelIndexFiles(declarationsDirectory: string) {
|
|
|
190
190
|
|
|
191
191
|
ensureDirectoryExists(outputDir);
|
|
192
192
|
|
|
193
|
-
|
|
193
|
+
generateEntityConfigIndexFile({
|
|
194
194
|
modelsDir,
|
|
195
195
|
outputDir,
|
|
196
196
|
typeDefFilePath,
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
197
|
+
configurationDirName: "entities",
|
|
198
|
+
configurationTypeName: "RapidEntity",
|
|
199
|
+
indexFileName: "entity-models",
|
|
200
200
|
extraImports: [`import { autoConfigureRapidEntity } from '@ruiapp/rapid-extension';`],
|
|
201
201
|
modelWrapper: "autoConfigureRapidEntity",
|
|
202
202
|
});
|
|
203
203
|
|
|
204
|
-
|
|
204
|
+
generateConfigIndexFile({
|
|
205
205
|
modelsDir,
|
|
206
206
|
outputDir,
|
|
207
207
|
typeDefFilePath,
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
208
|
+
configurationDirName: "data-dictionaries",
|
|
209
|
+
configurationTypeName: "RapidDataDictionary",
|
|
210
|
+
indexFileName: "data-dictionary-models",
|
|
211
211
|
});
|
|
212
|
-
|
|
212
|
+
generateConfigIndexFile({
|
|
213
213
|
modelsDir,
|
|
214
214
|
outputDir,
|
|
215
215
|
typeDefFilePath,
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
216
|
+
configurationDirName: "pages",
|
|
217
|
+
configurationTypeName: "RapidPageLoader",
|
|
218
|
+
indexFileName: "page-models",
|
|
219
219
|
});
|
|
220
220
|
|
|
221
|
-
|
|
221
|
+
generateConfigIndexFile({
|
|
222
222
|
modelsDir,
|
|
223
223
|
outputDir,
|
|
224
224
|
typeDefFilePath: "@ruiapp/rapid-core",
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
225
|
+
configurationDirName: "server-operations",
|
|
226
|
+
configurationTypeName: "ServerOperation",
|
|
227
|
+
indexFileName: "server-operations",
|
|
228
228
|
});
|
|
229
229
|
|
|
230
|
-
|
|
230
|
+
generateConfigIndexFile({
|
|
231
231
|
modelsDir,
|
|
232
232
|
outputDir,
|
|
233
233
|
typeDefFilePath: "@ruiapp/rapid-core",
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
234
|
+
configurationDirName: "entity-watchers",
|
|
235
|
+
configurationTypeName: "EntityWatcherType",
|
|
236
|
+
indexFileName: "entity-watchers",
|
|
237
237
|
flattenModelArray: true,
|
|
238
238
|
});
|
|
239
239
|
|
|
240
|
-
|
|
240
|
+
generateConfigIndexFile({
|
|
241
241
|
modelsDir,
|
|
242
242
|
outputDir,
|
|
243
243
|
typeDefFilePath: "@ruiapp/rapid-core",
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
244
|
+
configurationDirName: "cron-jobs",
|
|
245
|
+
configurationTypeName: "CronJobConfiguration",
|
|
246
|
+
indexFileName: "cron-jobs",
|
|
247
247
|
flattenModelArray: false,
|
|
248
248
|
});
|
|
249
249
|
}
|
|
@@ -34,8 +34,8 @@ function convertSdRpdFieldTypeToTypeScriptType(field: RapidField, entities: Rapi
|
|
|
34
34
|
return `${dataDictionary}[]`;
|
|
35
35
|
case "relation":
|
|
36
36
|
case "relation[]":
|
|
37
|
-
const
|
|
38
|
-
return relation === "one" ? `Partial<${
|
|
37
|
+
const targetType = find(entities, { singularCode: targetSingularCode })?.code || "any";
|
|
38
|
+
return relation === "one" ? `Partial<${targetType}>` : `Partial<${targetType}>[]`;
|
|
39
39
|
case "file":
|
|
40
40
|
case "image":
|
|
41
41
|
return "FileOrImageFieldType";
|
|
@@ -4,6 +4,11 @@ import { generateModelCodes, generateDictionaryCodes } from "./generators/model-
|
|
|
4
4
|
import { generateSdRpdModelTypes } from "./generators/model-types-generator";
|
|
5
5
|
import { generateSdRpdModelLocales } from "./generators/model-locales-generator";
|
|
6
6
|
|
|
7
|
+
export * from "./generators/model-index-generator";
|
|
8
|
+
export * from "./generators/model-codes-generator";
|
|
9
|
+
export * from "./generators/model-types-generator";
|
|
10
|
+
export * from "./generators/model-locales-generator";
|
|
11
|
+
|
|
7
12
|
export interface FileGenerateOption {
|
|
8
13
|
declarationsDirectory: string;
|
|
9
14
|
}
|
package/src/mod.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { RapidDataDictionaryEntry } from "@ruiapp/rapid-extension";
|
|
2
2
|
import type { AxiosInstance } from "axios";
|
|
3
|
-
import { detectChangedFields } from "
|
|
3
|
+
import { detectChangedFields } from "../utils/ObjectChangesDetector";
|
|
4
4
|
import type {
|
|
5
5
|
RapidDataDictionaryWithId,
|
|
6
6
|
RapidDataDictionaryEntryWithId,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { RapidDataDictionary } from "@ruiapp/rapid-extension";
|
|
2
2
|
import type { AxiosInstance } from "axios";
|
|
3
3
|
import { pick } from "lodash";
|
|
4
|
-
import { detectChangedFields } from "
|
|
4
|
+
import { detectChangedFields } from "../utils/ObjectChangesDetector";
|
|
5
5
|
import type { RapidDataDictionaryWithId, CreateDataDictionaryInput, IRapidModelUpdater, UpdateDataDictionaryInput } from "./types";
|
|
6
6
|
|
|
7
7
|
export function newDictionaryUpdater(rapidConfigApi: AxiosInstance) {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { RapidEntity } from "@ruiapp/rapid-extension";
|
|
2
2
|
import type { AxiosInstance } from "axios";
|
|
3
3
|
import { omit } from "lodash";
|
|
4
|
-
import { detectChangedFields } from "
|
|
4
|
+
import { detectChangedFields } from "../utils/ObjectChangesDetector";
|
|
5
5
|
import type { RapidModel, CreateRapidModelInput, IRapidModelUpdater, UpdateRapidModelInput } from "./types";
|
|
6
6
|
|
|
7
7
|
export function newModelUpdater(rapidConfigApi: AxiosInstance) {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { FindEntityOptions, RapidPage } from "@ruiapp/rapid-extension";
|
|
2
2
|
import type { AxiosInstance } from "axios";
|
|
3
|
-
import { detectChangedFields } from "
|
|
3
|
+
import { detectChangedFields } from "../utils/ObjectChangesDetector";
|
|
4
4
|
import type { CreateRapidPageInput, IRapidModelUpdater, UpdateRapidPageInput, RapidPageEntity } from "./types";
|
|
5
5
|
|
|
6
6
|
function convertInputToEntity(input: RapidPage) {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { RapidField } from "@ruiapp/rapid-extension";
|
|
2
2
|
import type { AxiosInstance } from "axios";
|
|
3
|
-
import { detectChangedFields } from "
|
|
3
|
+
import { detectChangedFields } from "../utils/ObjectChangesDetector";
|
|
4
4
|
import type { RapidModel, RapidProperty, CreateRapidPropertyInput, IRapidModelUpdater, UpdateRapidPropertyInput } from "./types";
|
|
5
5
|
|
|
6
6
|
export function newPropertyUpdater(rapidConfigApi: AxiosInstance) {
|
|
@@ -49,6 +49,7 @@ export function newPropertyUpdater(rapidConfigApi: AxiosInstance) {
|
|
|
49
49
|
"maxLength",
|
|
50
50
|
"relation",
|
|
51
51
|
"targetSingularCode",
|
|
52
|
+
"targetTypeColumnName",
|
|
52
53
|
"targetIdColumnName",
|
|
53
54
|
"selfIdColumnName",
|
|
54
55
|
"linkTableName",
|
|
@@ -11,6 +11,9 @@ import { newPropertyUpdater } from "./PropertyUpdater";
|
|
|
11
11
|
import type { RapidDataDictionary, RapidEntity, RapidPage } from "@ruiapp/rapid-extension";
|
|
12
12
|
import { newPageUpdater } from "./PageUpdater";
|
|
13
13
|
|
|
14
|
+
export { default as AppUpdater } from "./AppUpdater";
|
|
15
|
+
export * from "./types";
|
|
16
|
+
|
|
14
17
|
export interface RapidModelsUpdateOptions {
|
|
15
18
|
appDataDirLocation: string;
|
|
16
19
|
rapidApiUrl: string;
|
|
File without changes
|
|
File without changes
|