@postxl/generator 0.38.2 → 0.40.0
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/generator.js +43 -21
- package/dist/generators/enums/types.generator.js +1 -1
- package/dist/generators/indices/businesslogic-actiontypes.generator.js +1 -1
- package/dist/generators/indices/businesslogic-update-module.generator.js +2 -2
- package/dist/generators/indices/businesslogic-update-service.generator.js +1 -1
- package/dist/generators/indices/businesslogic-view-module.generator.js +2 -2
- package/dist/generators/indices/businesslogic-view-service.generator.js +1 -1
- package/dist/generators/indices/{seed-service.generator.d.ts → data-types.generator.d.ts} +2 -2
- package/dist/generators/indices/data-types.generator.js +48 -0
- package/dist/generators/indices/datamock-module.generator.js +11 -11
- package/dist/generators/indices/datamocker.generator.js +1 -1
- package/dist/generators/indices/datamodule.generator.js +34 -52
- package/dist/generators/indices/dataservice.generator.js +202 -9
- package/dist/generators/indices/dispatcher-service.generator.js +20 -10
- package/dist/generators/indices/emptydatabasemigration.generator.d.ts +2 -0
- package/dist/generators/indices/emptydatabasemigration.generator.js +14 -7
- package/dist/generators/indices/importexport-convert-import-functions.generator.d.ts +9 -0
- package/dist/generators/indices/importexport-convert-import-functions.generator.js +528 -0
- package/dist/generators/indices/importexport-exporter-class.generator.d.ts +9 -0
- package/dist/generators/indices/importexport-exporter-class.generator.js +116 -0
- package/dist/generators/indices/importexport-import-service.generator.d.ts +9 -0
- package/dist/generators/indices/importexport-import-service.generator.js +563 -0
- package/dist/generators/indices/{seeddata-type.generator.d.ts → importexport-types.generator.d.ts} +2 -2
- package/dist/generators/indices/importexport-types.generator.js +234 -0
- package/dist/generators/indices/repositories.generator.js +8 -8
- package/dist/generators/indices/seed-migration.generator.js +1 -1
- package/dist/generators/indices/seed-template.generator.js +1 -1
- package/dist/generators/indices/selectors.generator.d.ts +7 -0
- package/dist/generators/indices/selectors.generator.js +82 -0
- package/dist/generators/indices/{seed-template-decoder.generator.d.ts → testdata-service.generator.d.ts} +2 -2
- package/dist/generators/indices/testdata-service.generator.js +71 -0
- package/dist/generators/models/businesslogic-update.generator.js +6 -6
- package/dist/generators/models/businesslogic-view.generator.js +4 -4
- package/dist/generators/models/importexport-decoder.generator.d.ts +23 -0
- package/dist/generators/models/importexport-decoder.generator.js +234 -0
- package/dist/generators/models/react.generator/library.generator.js +4 -0
- package/dist/generators/models/react.generator/modals.generator.js +35 -8
- package/dist/generators/models/repository.generator.js +156 -18
- package/dist/generators/models/route.generator.js +2 -2
- package/dist/generators/models/stub.generator.js +1 -1
- package/dist/generators/models/types.generator.js +1 -1
- package/dist/lib/id-collector.d.ts +43 -0
- package/dist/lib/id-collector.js +53 -0
- package/dist/lib/imports.d.ts +1 -1
- package/dist/lib/meta.d.ts +480 -122
- package/dist/lib/meta.js +187 -74
- package/dist/lib/schema/schema.d.ts +58 -43
- package/dist/lib/schema/types.d.ts +63 -12
- package/dist/lib/schema/types.js +27 -7
- package/dist/lib/utils/string.d.ts +1 -0
- package/dist/lib/utils/string.js +1 -0
- package/dist/prisma/parse.js +4 -4
- package/package.json +2 -2
- package/dist/generators/indices/seed-service.generator.js +0 -356
- package/dist/generators/indices/seed-template-decoder.generator.js +0 -151
- package/dist/generators/indices/seeddata-type.generator.js +0 -42
package/dist/lib/meta.js
CHANGED
|
@@ -34,26 +34,16 @@ function getSchemaMetadata({ config }) {
|
|
|
34
34
|
actions: {
|
|
35
35
|
moduleName: Types.toClassName(`ActionModule`),
|
|
36
36
|
importPath: Types.toPath(`@${config.project}/actions`),
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
dataMockModuleFilePath: Types.toPath(`${config.paths.dataLibPath}data.mock.module`),
|
|
48
|
-
dataServiceFilePath: Types.toPath(`${config.paths.dataLibPath}data.service`),
|
|
49
|
-
repositoryTypeFilePath: Types.toPath(`${config.paths.dataLibPath}repository.type`),
|
|
50
|
-
repositoryTypeName: Types.toTypeName(`Repository`),
|
|
51
|
-
dataMockerFilePath: Types.toPath(`${config.paths.cypressPath}support/data-mocker.class`),
|
|
52
|
-
dataMockerStubImportPath: Types.toPath(`${config.paths.cypressPath}support/stubs`),
|
|
53
|
-
dataMockerStubIndexFilePath: Types.toPath(`${config.paths.cypressPath}support/stubs/index`),
|
|
54
|
-
repositoriesConstFilePath: Types.toPath(`${config.paths.dataLibPath}repositories/repositories`),
|
|
55
|
-
repositoriesIndexFilePath: Types.toPath(`${config.paths.dataLibPath}repositories/index`),
|
|
56
|
-
stubIndexFilePath: Types.toPath(`${config.paths.dataLibPath}stubs/index`),
|
|
37
|
+
actionExecution: {
|
|
38
|
+
filePath: Types.toPath(`@${config.project}/actions/actionExecution.class`),
|
|
39
|
+
interface: Types.toClassName(`IActionExecution`),
|
|
40
|
+
class: Types.toClassName(`ActionExecution`),
|
|
41
|
+
mock: Types.toClassName(`MockActionExecution`),
|
|
42
|
+
},
|
|
43
|
+
dispatcherService: {
|
|
44
|
+
filePath: Types.toPath(`${config.paths.actionsPath}dispatcher.service`),
|
|
45
|
+
class: Types.toClassName(`DispatcherService`),
|
|
46
|
+
},
|
|
57
47
|
},
|
|
58
48
|
businessLogic: {
|
|
59
49
|
moduleName: Types.toClassName(`BusinessLogicModule`),
|
|
@@ -75,31 +65,143 @@ function getSchemaMetadata({ config }) {
|
|
|
75
65
|
moduleFilePath: Types.toPath(`${config.paths.businessLogicPath}update/update.module`),
|
|
76
66
|
serviceClassName: Types.toClassName(`UpdateService`),
|
|
77
67
|
serviceFilePath: Types.toPath(`${config.paths.businessLogicPath}update/update.service`),
|
|
78
|
-
actionTypesFilePath: Types.toPath(`${config.paths.businessLogicPath}update/actions
|
|
68
|
+
actionTypesFilePath: Types.toPath(`${config.paths.businessLogicPath}update/actions`),
|
|
79
69
|
},
|
|
80
70
|
},
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
importPath: Types.toPath(`@${config.project}/
|
|
71
|
+
data: {
|
|
72
|
+
moduleName: Types.toClassName(`DataModule`),
|
|
73
|
+
importPath: Types.toPath(`@${config.project}/data`),
|
|
74
|
+
dataModuleFilePath: Types.toPath(`${config.paths.dataLibPath}data.module`),
|
|
75
|
+
dataMockModuleFilePath: Types.toPath(`${config.paths.dataLibPath}data.mock.module`),
|
|
76
|
+
repository: {
|
|
77
|
+
typeFilePath: Types.toPath(`${config.paths.dataLibPath}repository.type`),
|
|
78
|
+
typeName: Types.toTypeName(`Repository`),
|
|
79
|
+
constFilePath: Types.toPath(`${config.paths.dataLibPath}repositories/repositories`),
|
|
80
|
+
indexFilePath: Types.toPath(`${config.paths.dataLibPath}repositories/index`),
|
|
81
|
+
},
|
|
82
|
+
types: {
|
|
83
|
+
filePath: Types.toPath(`${config.paths.dataLibPath}types`),
|
|
84
|
+
bulkMutation: Types.toTypeName(`BulkMutation`),
|
|
85
|
+
bulkMutationForModel: Types.toTypeName(`BulkMutationForModel`),
|
|
86
|
+
},
|
|
87
|
+
dataService: {
|
|
88
|
+
filePath: Types.toPath(`${config.paths.dataLibPath}data.service`),
|
|
89
|
+
class: Types.toClassName(`DataService`),
|
|
90
|
+
executeBulkMutations: Types.toFunctionName(`executeBulkMutations`),
|
|
91
|
+
executeBulkMutation: Types.toFunctionName(`executeBulkMutation`),
|
|
92
|
+
},
|
|
93
|
+
dataMockerFilePath: Types.toPath(`${config.paths.cypressPath}support/data-mocker.class`),
|
|
94
|
+
dataMockerStubImportPath: Types.toPath(`${config.paths.cypressPath}support/stubs`),
|
|
95
|
+
dataMockerStubIndexFilePath: Types.toPath(`${config.paths.cypressPath}support/stubs/index`),
|
|
96
|
+
stubIndexFilePath: Types.toPath(`${config.paths.dataLibPath}stubs/index`),
|
|
97
|
+
selectorsFilePath: Types.toPath(`${config.paths.cypressPath}support/selectors`),
|
|
98
|
+
testDataServiceFilePath: Types.toPath(`${config.paths.e2eLibPath}test-data.service`),
|
|
99
|
+
dataMockModuleName: Types.toClassName(`DataMockModule`),
|
|
100
|
+
dataMockDataType: Types.toTypeName(`MockData`),
|
|
101
|
+
},
|
|
102
|
+
importExport: {
|
|
103
|
+
importPath: Types.toPath(`@${config.project}/import-export`),
|
|
104
|
+
decoder: {
|
|
105
|
+
indexFilePath: Types.toPath(`${config.paths.importExportPath}decoders/index`),
|
|
106
|
+
fullDecoderFilePath: Types.toPath(`${config.paths.importExportPath}decoders/data.decoder`),
|
|
107
|
+
fullDecoderName: Types.toFunctionName(`excelDataDecoder`),
|
|
108
|
+
fullEncoderFunctionName: Types.toFunctionName(`encodeExcelData`),
|
|
109
|
+
encodedExcelDataTypeName: Types.toTypeName(`EncodedExcelData`),
|
|
110
|
+
decodedPXLModelDataTypeName: Types.toTypeName(`DecodedPXLModelData`),
|
|
111
|
+
},
|
|
112
|
+
exporterClass: {
|
|
113
|
+
filePath: Types.toPath(`${config.paths.importExportPath}exporter.class`),
|
|
114
|
+
name: Types.toClassName(`Exporter`),
|
|
115
|
+
},
|
|
116
|
+
exportService: {
|
|
117
|
+
filePath: Types.toPath(`${config.paths.importExportPath}export.service`),
|
|
118
|
+
name: Types.toClassName(`ExportService`),
|
|
119
|
+
},
|
|
120
|
+
importService: {
|
|
121
|
+
filePath: Types.toPath(`${config.paths.importExportPath}import.service`),
|
|
122
|
+
name: Types.toClassName(`ImportService`),
|
|
123
|
+
sharedName: Types.toVariableName(`importService`),
|
|
124
|
+
},
|
|
125
|
+
converterFunctions: {
|
|
126
|
+
filePath: Types.toPath(`${config.paths.importExportPath}convert-import.functions`),
|
|
127
|
+
importedDataToBulkMutations: Types.toFunctionName(`importToBulkMutations`),
|
|
128
|
+
deltaToBulkMutations: Types.toFunctionName(`deltaToBulkMutations`),
|
|
129
|
+
mockDataToBulkMutations: Types.toFunctionName(`mockDataToBulkMutations`),
|
|
130
|
+
},
|
|
131
|
+
types: {
|
|
132
|
+
filePath: Types.toPath(`${config.paths.importExportPath}types`),
|
|
133
|
+
delta_Model: {
|
|
134
|
+
type: Types.toTypeName(`Delta_Model`),
|
|
135
|
+
create: {
|
|
136
|
+
type: Types.toTypeName(`Delta_Model_Create`),
|
|
137
|
+
discriminant: Types.toDiscriminantName(`create`),
|
|
138
|
+
typeGuard: Types.toFunctionName(`isDelta_Model_Create`),
|
|
139
|
+
},
|
|
140
|
+
update: {
|
|
141
|
+
type: Types.toTypeName(`Delta_Model_Update`),
|
|
142
|
+
discriminant: Types.toDiscriminantName(`update`),
|
|
143
|
+
typeGuard: Types.toFunctionName(`isDelta_Model_Update`),
|
|
144
|
+
},
|
|
145
|
+
delete: {
|
|
146
|
+
type: Types.toTypeName(`Delta_Model_Delete`),
|
|
147
|
+
discriminant: Types.toDiscriminantName(`delete`),
|
|
148
|
+
typeGuard: Types.toFunctionName(`isDelta_Model_Delete`),
|
|
149
|
+
},
|
|
150
|
+
unchanged: {
|
|
151
|
+
type: Types.toTypeName(`Delta_Model_Unchanged`),
|
|
152
|
+
discriminant: Types.toDiscriminantName(`unchanged`),
|
|
153
|
+
typeGuard: Types.toFunctionName(`isDelta_Model_Unchanged`),
|
|
154
|
+
},
|
|
155
|
+
errors: {
|
|
156
|
+
type: Types.toTypeName(`Delta_Model_Errors`),
|
|
157
|
+
discriminant: Types.toDiscriminantName(`errors`),
|
|
158
|
+
typeGuard: Types.toFunctionName(`isDelta_Model_Errors`),
|
|
159
|
+
missingField: {
|
|
160
|
+
type: Types.toTypeName(`Delta_Model_Errors_MissingField`),
|
|
161
|
+
discriminant: Types.toDiscriminantName(`required-field-missing`),
|
|
162
|
+
},
|
|
163
|
+
invalidReference: {
|
|
164
|
+
type: Types.toTypeName(`Delta_Model_Errors_InvalidReference`),
|
|
165
|
+
discriminant: Types.toDiscriminantName(`invalid-reference`),
|
|
166
|
+
},
|
|
167
|
+
nonUnique: {
|
|
168
|
+
type: Types.toTypeName(`Delta_Model_Errors_NonUnique`),
|
|
169
|
+
discriminant: Types.toDiscriminantName(`non-unique`),
|
|
170
|
+
},
|
|
171
|
+
invalidType: {
|
|
172
|
+
type: Types.toTypeName(`Delta_Model_Errors_InvalidType`),
|
|
173
|
+
discriminant: Types.toDiscriminantName(`invalid-type`),
|
|
174
|
+
},
|
|
175
|
+
isRequiredDependency: {
|
|
176
|
+
type: Types.toTypeName(`Delta_Model_Errors_IsRequiredDependency`),
|
|
177
|
+
discriminant: Types.toDiscriminantName(`is-required-dependency`),
|
|
178
|
+
},
|
|
179
|
+
},
|
|
180
|
+
},
|
|
181
|
+
delta: Types.toTypeName(`Delta`),
|
|
182
|
+
delta_Fields: Types.toTypeName(`Delta_Fields`),
|
|
183
|
+
},
|
|
84
184
|
},
|
|
85
185
|
seedData: {
|
|
86
186
|
importPath: Types.toPath(`@${config.project}/seed-data`),
|
|
87
187
|
initialMigrationFilePath: Types.toPath(`${config.paths.seedDataPath}001-base-data/001-seed.migration`),
|
|
88
188
|
templateExcelFilePath: Types.toPath(`${config.paths.seedDataPath}002-excel-example/template.xlsx`),
|
|
89
|
-
templateDecoderFilePath: Types.toPath(`${config.paths.seedDataPath}002-excel-example/template.decoder`),
|
|
90
|
-
templateDecoderName: Types.toFunction(`seedTemplateDecoder`),
|
|
91
189
|
},
|
|
92
190
|
seed: {
|
|
93
|
-
seedDataTypeFilePath: Types.toPath(`${config.paths.seedLibPath}seed-data.type`),
|
|
94
|
-
serviceFilePath: Types.toPath(`${config.paths.seedLibPath}seed.service`),
|
|
95
191
|
serviceClassName: Types.toClassName(`SeedService`),
|
|
96
192
|
importPath: Types.toPath(`@${config.project}/seed`),
|
|
97
193
|
},
|
|
194
|
+
trpc: {
|
|
195
|
+
routesFilePath: Types.toPath(`${config.paths.trpcRoutesFolderPath}index`),
|
|
196
|
+
importPath: Types.toPath(`@${config.project}/trpc`),
|
|
197
|
+
},
|
|
98
198
|
types: {
|
|
99
199
|
indexFilePath: Types.toPath(`${config.paths.modelTypeDefinitionsPath}index`),
|
|
100
200
|
importPath: Types.toPath(`@${config.project}/types`),
|
|
101
201
|
dto: {
|
|
102
202
|
path: Types.toPath(`${config.paths.modelTypeDefinitionsPath}dto.types`),
|
|
203
|
+
genericModel: Types.toTypeName(`GenericModel`),
|
|
204
|
+
idType: Types.toTypeName(`IDType`),
|
|
103
205
|
create: Types.toTypeName(`CreateDTO`),
|
|
104
206
|
update: Types.toTypeName(`UpdateDTO`),
|
|
105
207
|
upsert: Types.toTypeName(`UpsertDTO`),
|
|
@@ -115,34 +217,54 @@ exports.getSchemaMetadata = getSchemaMetadata;
|
|
|
115
217
|
*/
|
|
116
218
|
function getModelMetadata({ model }) {
|
|
117
219
|
const { name, schemaConfig: config } = model;
|
|
118
|
-
const { PascalCase, camelCase, pluralized, uncapitalizedPlural, uncapitalized, capitalizedPlural } = (0, string_1.conjugateNames)(name);
|
|
220
|
+
const { PascalCase, camelCase, pluralized, uncapitalizedPlural, uncapitalized, capitalized, capitalizedPlural } = (0, string_1.conjugateNames)(name);
|
|
119
221
|
return {
|
|
120
222
|
userFriendlyName: PascalCase,
|
|
121
223
|
userFriendlyNamePlural: capitalizedPlural,
|
|
122
224
|
internalSingularName: Types.toVariableName(camelCase),
|
|
225
|
+
internalSingularNameCapitalized: Types.toVariableName(capitalized),
|
|
123
226
|
internalPluralName: Types.toVariableName(uncapitalizedPlural),
|
|
227
|
+
internalPluralNameCapitalized: Types.toVariableName(capitalizedPlural),
|
|
124
228
|
actions: {
|
|
125
229
|
actionScopeConstType: Types.toTypeName(`${camelCase}`),
|
|
126
230
|
},
|
|
127
231
|
data: {
|
|
232
|
+
importPath: Types.toPath(`@${config.project}/data`),
|
|
128
233
|
mockDataPropertyName: Types.toVariableName(`${uncapitalizedPlural}`),
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
234
|
+
repository: {
|
|
235
|
+
fileName: Types.toFileName(`${camelCase}.repository`),
|
|
236
|
+
filePath: Types.toPath(`${config.paths.dataLibPath}repositories/${camelCase}.repository`),
|
|
237
|
+
className: Types.toClassName(`${PascalCase}Repository`),
|
|
238
|
+
decoderFnName: Types.toFunctionName(`to${PascalCase}`),
|
|
239
|
+
getMethodFnName: Types.toFunctionName(`${camelCase}`),
|
|
240
|
+
},
|
|
241
|
+
mockRepository: {
|
|
242
|
+
fileName: Types.toFileName(`${camelCase}.mock.repository`),
|
|
243
|
+
filePath: Types.toPath(`${config.paths.dataLibPath}repositories/mock/${camelCase}.mock.repository`),
|
|
244
|
+
className: Types.toClassName(`Mock${PascalCase}Repository`),
|
|
245
|
+
},
|
|
135
246
|
dataMockerStubFilePath: Types.toPath(`${config.paths.cypressPath}support/stubs/${camelCase}.stub`),
|
|
136
|
-
|
|
137
|
-
stubGenerationFnName: Types.
|
|
138
|
-
|
|
139
|
-
mockRepositoryClassName: Types.toClassName(`Mock${PascalCase}Repository`),
|
|
247
|
+
stubFilePath: Types.toPath(`${config.paths.dataLibPath}stubs/${camelCase}.stub`),
|
|
248
|
+
stubGenerationFnName: Types.toFunctionName(`stub${PascalCase}`),
|
|
249
|
+
defaultStubConstantName: Types.toVariableName(`${camelCase}DefaultStub`),
|
|
140
250
|
dataServiceName: Types.toVariableName(`${uncapitalizedPlural}`),
|
|
141
251
|
dataServiceIdName: Types.toVariableName(`${uncapitalized}`),
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
252
|
+
},
|
|
253
|
+
importExport: {
|
|
254
|
+
exportDataPropertyName: Types.toVariableName(`${capitalizedPlural}`),
|
|
255
|
+
exportDataFullPropertyName: Types.toVariableName(`${uncapitalizedPlural}`),
|
|
256
|
+
exportDataTypeName: Types.toTypeName(`${PascalCase}_Export`),
|
|
257
|
+
exportAddFunctionName: Types.toFunctionName(`add${PascalCase}`),
|
|
258
|
+
tableName: `${pluralized}`,
|
|
259
|
+
delta_Model_Errors: Types.toTypeName(`Delta_Model_${PascalCase}_Errors`),
|
|
260
|
+
decoder: {
|
|
261
|
+
fileName: Types.toFileName(`${camelCase}.decoder`),
|
|
262
|
+
filePath: Types.toPath(`${config.paths.importExportPath}decoders/${camelCase}.decoder`),
|
|
263
|
+
encodedExcelType: Types.toTypeName(`${PascalCase}_EncodedExcelData`),
|
|
264
|
+
tableDecoder: Types.toFunctionName(`${camelCase}ExcelTableDecoder`),
|
|
265
|
+
itemEncoderFunctionName: Types.toFunctionName(`encode${PascalCase}`),
|
|
266
|
+
arrayEncoderFunctionName: Types.toFunctionName(`encode${capitalizedPlural}`),
|
|
267
|
+
decodedModelArrayName: Types.toVariableName(`${uncapitalizedPlural}`),
|
|
146
268
|
},
|
|
147
269
|
},
|
|
148
270
|
businessLogic: {
|
|
@@ -163,14 +285,14 @@ function getModelMetadata({ model }) {
|
|
|
163
285
|
actionName: Types.toVariableName(`Action_${PascalCase}`),
|
|
164
286
|
actionNameModelPart: Types.toVariableName(`${PascalCase}`),
|
|
165
287
|
actionResultName: Types.toVariableName(`ActionResult_${PascalCase}`),
|
|
166
|
-
createActionFunctionNameCreate: Types.
|
|
167
|
-
createActionFunctionNameCreateMany: Types.
|
|
168
|
-
createActionFunctionNameUpdate: Types.
|
|
169
|
-
createActionFunctionNameUpdateMany: Types.
|
|
170
|
-
createActionFunctionNameUpsert: Types.
|
|
171
|
-
createActionFunctionNameUpsertMany: Types.
|
|
172
|
-
createActionFunctionNameDelete: Types.
|
|
173
|
-
createActionFunctionNameDeleteMany: Types.
|
|
288
|
+
createActionFunctionNameCreate: Types.toFunctionName(`createAction${PascalCase}Create`),
|
|
289
|
+
createActionFunctionNameCreateMany: Types.toFunctionName(`createAction${PascalCase}CreateMany`),
|
|
290
|
+
createActionFunctionNameUpdate: Types.toFunctionName(`createAction${PascalCase}Update`),
|
|
291
|
+
createActionFunctionNameUpdateMany: Types.toFunctionName(`createAction${PascalCase}UpdateMany`),
|
|
292
|
+
createActionFunctionNameUpsert: Types.toFunctionName(`createAction${PascalCase}Upsert`),
|
|
293
|
+
createActionFunctionNameUpsertMany: Types.toFunctionName(`createAction${PascalCase}UpsertMany`),
|
|
294
|
+
createActionFunctionNameDelete: Types.toFunctionName(`createAction${PascalCase}Delete`),
|
|
295
|
+
createActionFunctionNameDeleteMany: Types.toFunctionName(`createAction${PascalCase}DeleteMany`),
|
|
174
296
|
},
|
|
175
297
|
dataRepositoryVariableName: Types.toVariableName(`data`),
|
|
176
298
|
},
|
|
@@ -178,22 +300,13 @@ function getModelMetadata({ model }) {
|
|
|
178
300
|
filePath: Types.toPath(`${config.paths.seedDataPath}001-base-data/${uncapitalizedPlural}.seed`),
|
|
179
301
|
constantName: Types.toVariableName(`${uncapitalizedPlural}`),
|
|
180
302
|
importPath: Types.toPath(`@${config.project}/seed`),
|
|
181
|
-
excel: {
|
|
182
|
-
tableName: `${capitalizedPlural}`,
|
|
183
|
-
},
|
|
184
|
-
decoder: {
|
|
185
|
-
schemaName: Types.toVariableName(`${camelCase}Schema`),
|
|
186
|
-
decoderTypeName: Types.toTypeName(`${PascalCase}DecoderType`),
|
|
187
|
-
decoderName: Types.toVariableName(`${camelCase}Decoder`),
|
|
188
|
-
dataName: Types.toVariableName(`${uncapitalizedPlural}`),
|
|
189
|
-
},
|
|
190
303
|
},
|
|
191
304
|
react: {
|
|
192
305
|
folderName: Types.toFolderName(`${PascalCase}`),
|
|
193
306
|
folderPath: Types.toPath(`${config.paths.reactFolderPath}models/${PascalCase}/`),
|
|
194
307
|
context: {
|
|
195
|
-
hookFnName: Types.
|
|
196
|
-
instanceGetterHookFnName: Types.
|
|
308
|
+
hookFnName: Types.toFunctionName(`use${PascalCase}Context`),
|
|
309
|
+
instanceGetterHookFnName: Types.toFunctionName(`use${PascalCase}`),
|
|
197
310
|
},
|
|
198
311
|
components: {
|
|
199
312
|
modals: {
|
|
@@ -221,32 +334,32 @@ function getModelMetadata({ model }) {
|
|
|
221
334
|
importPath: Types.toPath(`@${config.project}${camelCase}.router`),
|
|
222
335
|
getMap: {
|
|
223
336
|
methodName: Types.toVariableName('getMap'),
|
|
224
|
-
reactQueryMethod: Types.
|
|
337
|
+
reactQueryMethod: Types.toFunctionName(`${uncapitalizedPlural}.getMap`),
|
|
225
338
|
},
|
|
226
339
|
create: {
|
|
227
340
|
methodName: Types.toVariableName('create'),
|
|
228
|
-
reactQueryMethod: Types.
|
|
341
|
+
reactQueryMethod: Types.toFunctionName(`${uncapitalizedPlural}.create`),
|
|
229
342
|
},
|
|
230
343
|
update: {
|
|
231
344
|
methodName: Types.toVariableName('update'),
|
|
232
|
-
reactQueryMethod: Types.
|
|
345
|
+
reactQueryMethod: Types.toFunctionName(`${uncapitalizedPlural}.update`),
|
|
233
346
|
},
|
|
234
347
|
delete: {
|
|
235
348
|
methodName: Types.toVariableName('delete'),
|
|
236
|
-
reactQueryMethod: Types.
|
|
349
|
+
reactQueryMethod: Types.toFunctionName(`${uncapitalizedPlural}.delete`),
|
|
237
350
|
},
|
|
238
351
|
},
|
|
239
352
|
types: {
|
|
240
353
|
importPath: Types.toPath(`@${config.project}/types`),
|
|
241
354
|
filePath: Types.toPath(`${config.paths.modelTypeDefinitionsPath}${camelCase}.type`),
|
|
242
355
|
brandedIdType: Types.toTypeName(`${PascalCase}Id`),
|
|
243
|
-
toBrandedIdTypeFnName: Types.
|
|
356
|
+
toBrandedIdTypeFnName: Types.toFunctionName(`to${PascalCase}Id`),
|
|
244
357
|
zodDecoderFnNames: {
|
|
245
|
-
id: Types.
|
|
246
|
-
fromDatabase: Types.
|
|
247
|
-
createObject: Types.
|
|
248
|
-
updateObject: Types.
|
|
249
|
-
upsertObject: Types.
|
|
358
|
+
id: Types.toFunctionName(`${camelCase}IdDecoder`),
|
|
359
|
+
fromDatabase: Types.toFunctionName(`${camelCase}DatabaseDecoder`),
|
|
360
|
+
createObject: Types.toFunctionName(`${camelCase}CreateDecoder`),
|
|
361
|
+
updateObject: Types.toFunctionName(`${camelCase}UpdateDecoder`),
|
|
362
|
+
upsertObject: Types.toFunctionName(`${camelCase}UpsertDecoder`),
|
|
250
363
|
},
|
|
251
364
|
dto: {
|
|
252
365
|
create: Types.toTypeName(`${PascalCase}CreateDTO`),
|
|
@@ -268,8 +381,8 @@ function getFieldMetadata({ field }) {
|
|
|
268
381
|
const PascalCase = (0, string_1.toPascalCase)(field.name);
|
|
269
382
|
return {
|
|
270
383
|
tsFieldName: Types.toVariableName((0, string_1.toCamelCase)(field.name)),
|
|
271
|
-
getByForeignKeyMethodFnName: Types.
|
|
272
|
-
getByForeignKeyIdsMethodFnName: Types.
|
|
384
|
+
getByForeignKeyMethodFnName: Types.toFunctionName(`getItemsFor${PascalCase}`),
|
|
385
|
+
getByForeignKeyIdsMethodFnName: Types.toFunctionName(`getIdsFor${PascalCase}`),
|
|
273
386
|
excelColumnName: (0, string_1.toPascalCase)(field.name),
|
|
274
387
|
};
|
|
275
388
|
// switch (field.kind) {
|
|
@@ -15,14 +15,6 @@ export type SchemaConfig = {
|
|
|
15
15
|
* Indicates whether the generator should be ignored
|
|
16
16
|
*/
|
|
17
17
|
disableGenerators: {
|
|
18
|
-
/**
|
|
19
|
-
* If true, type definitions for models will not be generated.
|
|
20
|
-
*/
|
|
21
|
-
types: boolean;
|
|
22
|
-
/**
|
|
23
|
-
* If true, data module will not be generated.
|
|
24
|
-
*/
|
|
25
|
-
data: boolean;
|
|
26
18
|
/**
|
|
27
19
|
* If true, actions module will not be generated.
|
|
28
20
|
*/
|
|
@@ -31,6 +23,14 @@ export type SchemaConfig = {
|
|
|
31
23
|
* If true, business logic module will not be generated.
|
|
32
24
|
*/
|
|
33
25
|
businessLogic: boolean;
|
|
26
|
+
/**
|
|
27
|
+
* If true, data module will not be generated.
|
|
28
|
+
*/
|
|
29
|
+
data: boolean;
|
|
30
|
+
/**
|
|
31
|
+
* If true, import-export module will not be generated.
|
|
32
|
+
*/
|
|
33
|
+
importExport: boolean;
|
|
34
34
|
/**
|
|
35
35
|
* If true, seed data will not be generated.
|
|
36
36
|
*/
|
|
@@ -43,40 +43,66 @@ export type SchemaConfig = {
|
|
|
43
43
|
* If true, trpc routes will not be generated.
|
|
44
44
|
*/
|
|
45
45
|
trpc: boolean;
|
|
46
|
+
/**
|
|
47
|
+
* If true, type definitions for models will not be generated.
|
|
48
|
+
*/
|
|
49
|
+
types: boolean;
|
|
46
50
|
};
|
|
47
51
|
paths: {
|
|
48
52
|
/**
|
|
49
|
-
* Path to the directory containing
|
|
53
|
+
* Path to the directory containing actions.
|
|
50
54
|
*
|
|
51
55
|
* NOTE: Metadata assumes that project is set up so that certain parts of the code
|
|
52
|
-
* may reference
|
|
56
|
+
* may reference actions using `@project/actions` import.
|
|
53
57
|
*/
|
|
54
|
-
|
|
58
|
+
actionsPath: Types.Path;
|
|
55
59
|
/**
|
|
56
|
-
* Path to the directory containing
|
|
60
|
+
* Path to the directory containing business logic.
|
|
57
61
|
*
|
|
58
62
|
* NOTE: Metadata assumes that project is set up so that certain parts of the code
|
|
59
|
-
* may reference data
|
|
63
|
+
* may reference mock data using `@project/business-logic` import.
|
|
60
64
|
*/
|
|
61
|
-
|
|
65
|
+
businessLogicPath: Types.Path;
|
|
62
66
|
/**
|
|
63
67
|
* Path to the directory containing Cypress project.
|
|
64
68
|
*/
|
|
65
69
|
cypressPath: Types.Path;
|
|
66
70
|
/**
|
|
67
|
-
* Path to the directory containing
|
|
71
|
+
* Path to the directory containing e2e tests.
|
|
72
|
+
*/
|
|
73
|
+
e2eLibPath: Types.Path;
|
|
74
|
+
/**
|
|
75
|
+
* Path to the directory containing data library definitions.
|
|
68
76
|
*
|
|
69
77
|
* NOTE: Metadata assumes that project is set up so that certain parts of the code
|
|
70
|
-
* may reference
|
|
78
|
+
* may reference data library using `@project/data` import.
|
|
71
79
|
*/
|
|
72
|
-
|
|
80
|
+
dataLibPath: Types.Path;
|
|
73
81
|
/**
|
|
74
|
-
* Path to the directory containing
|
|
82
|
+
* Path to the directory containing import-export module.
|
|
75
83
|
*
|
|
76
84
|
* NOTE: Metadata assumes that project is set up so that certain parts of the code
|
|
77
|
-
* may reference
|
|
85
|
+
* may reference import-export using `@project/import-export` import.
|
|
78
86
|
*/
|
|
79
|
-
|
|
87
|
+
importExportPath: Types.Path;
|
|
88
|
+
/**
|
|
89
|
+
* Path to the directory containing Prisma migrations.
|
|
90
|
+
*/
|
|
91
|
+
migrationsFolderPath: Types.Path;
|
|
92
|
+
/**
|
|
93
|
+
* Path to the directory containing model type definitions.
|
|
94
|
+
*
|
|
95
|
+
* NOTE: Metadata assumes that project is set up so that certain parts of the code
|
|
96
|
+
* may reference type definitions using `@project/types` import.
|
|
97
|
+
*/
|
|
98
|
+
modelTypeDefinitionsPath: Types.Path;
|
|
99
|
+
/**
|
|
100
|
+
* Path to the directory containing React components.
|
|
101
|
+
*
|
|
102
|
+
* NOTE: Metadata assumes that the project is set up so that React components
|
|
103
|
+
* may be referenced using `@project/react` import.
|
|
104
|
+
*/
|
|
105
|
+
reactFolderPath: Types.Path;
|
|
80
106
|
/**
|
|
81
107
|
* Path to the directory containing seed module.
|
|
82
108
|
*
|
|
@@ -91,21 +117,10 @@ export type SchemaConfig = {
|
|
|
91
117
|
* may reference mock data using `@project/seed-data` import.
|
|
92
118
|
*/
|
|
93
119
|
seedDataPath: Types.Path;
|
|
94
|
-
/**
|
|
95
|
-
* Path to the directory containing React components.
|
|
96
|
-
*
|
|
97
|
-
* NOTE: Metadata assumes that the project is set up so that React components
|
|
98
|
-
* may be referenced using `@project/react` import.
|
|
99
|
-
*/
|
|
100
|
-
reactFolderPath: Types.Path;
|
|
101
120
|
/**
|
|
102
121
|
* Path to the directory containing trpc routes.
|
|
103
122
|
*/
|
|
104
123
|
trpcRoutesFolderPath: Types.Path;
|
|
105
|
-
/**
|
|
106
|
-
* Path to the directory containing Prisma migrations.
|
|
107
|
-
*/
|
|
108
|
-
migrationsFolderPath: Types.Path;
|
|
109
124
|
};
|
|
110
125
|
/**
|
|
111
126
|
* Whether the generator should overwrite existing files.
|
|
@@ -124,7 +139,7 @@ export type ModelCore = {
|
|
|
124
139
|
/**
|
|
125
140
|
* Name of the model (e.g. Aggregation)
|
|
126
141
|
*/
|
|
127
|
-
name:
|
|
142
|
+
name: Types.ModelName;
|
|
128
143
|
/**
|
|
129
144
|
* Description of the model, ideally providing business background and detailed information
|
|
130
145
|
*/
|
|
@@ -203,7 +218,7 @@ export type FieldCore = {
|
|
|
203
218
|
*
|
|
204
219
|
* Note: The type of the name is narrowed by each field type.
|
|
205
220
|
*/
|
|
206
|
-
name:
|
|
221
|
+
name: Types.FieldName;
|
|
207
222
|
/**
|
|
208
223
|
* Description of the field, ideally providing business background and detailed information
|
|
209
224
|
*/
|
|
@@ -246,7 +261,7 @@ export type FieldScalar = Prettify<Omit<FieldCore, 'name'> & {
|
|
|
246
261
|
/**
|
|
247
262
|
* Name of the field and variable (e.g. name)
|
|
248
263
|
*/
|
|
249
|
-
name:
|
|
264
|
+
name: Types.FieldName;
|
|
250
265
|
/**
|
|
251
266
|
* Name of the scalar TypeScript type, e.g. string
|
|
252
267
|
*/
|
|
@@ -269,7 +284,7 @@ export type FieldId = Prettify<Omit<FieldCore, 'name'> & {
|
|
|
269
284
|
/**
|
|
270
285
|
* Name of the field and variable (e.g. id)
|
|
271
286
|
*/
|
|
272
|
-
name:
|
|
287
|
+
name: Types.FieldName;
|
|
273
288
|
/**
|
|
274
289
|
* Model that this ID field identifies.
|
|
275
290
|
*/
|
|
@@ -299,7 +314,7 @@ export declare const isFieldId: (field: Field) => field is Prettify<Omit<FieldCo
|
|
|
299
314
|
/**
|
|
300
315
|
* Name of the field and variable (e.g. id)
|
|
301
316
|
*/
|
|
302
|
-
name:
|
|
317
|
+
name: Types.FieldName;
|
|
303
318
|
/**
|
|
304
319
|
* Model that this ID field identifies.
|
|
305
320
|
*/
|
|
@@ -329,14 +344,14 @@ export type FieldRelation = Prettify<Omit<FieldCore, 'name'> & {
|
|
|
329
344
|
/**
|
|
330
345
|
* Name of the field and variable (e.g. aggregationId)
|
|
331
346
|
*/
|
|
332
|
-
name:
|
|
347
|
+
name: Types.FieldName;
|
|
333
348
|
/**
|
|
334
349
|
* Name of the field in the related model that references this model (e.g. `aggregation`).
|
|
335
350
|
*
|
|
336
351
|
* NOTE: This does not reference the database column name, but the field name
|
|
337
352
|
* in the model (e.g. not `aggregationId`, but `aggregation`).
|
|
338
353
|
*/
|
|
339
|
-
relatedModelBacklinkFieldName:
|
|
354
|
+
relatedModelBacklinkFieldName: Types.FieldName;
|
|
340
355
|
/**
|
|
341
356
|
* Name of the unbranded TypeScript type of the field, e.g. string
|
|
342
357
|
*
|
|
@@ -359,14 +374,14 @@ export declare const isFieldRelation: (field: Field) => field is Prettify<Omit<F
|
|
|
359
374
|
/**
|
|
360
375
|
* Name of the field and variable (e.g. aggregationId)
|
|
361
376
|
*/
|
|
362
|
-
name:
|
|
377
|
+
name: Types.FieldName;
|
|
363
378
|
/**
|
|
364
379
|
* Name of the field in the related model that references this model (e.g. `aggregation`).
|
|
365
380
|
*
|
|
366
381
|
* NOTE: This does not reference the database column name, but the field name
|
|
367
382
|
* in the model (e.g. not `aggregationId`, but `aggregation`).
|
|
368
383
|
*/
|
|
369
|
-
relatedModelBacklinkFieldName:
|
|
384
|
+
relatedModelBacklinkFieldName: Types.FieldName;
|
|
370
385
|
/**
|
|
371
386
|
* Name of the unbranded TypeScript type of the field, e.g. string
|
|
372
387
|
*
|
|
@@ -389,7 +404,7 @@ export type FieldEnum = Prettify<Omit<FieldCore, 'name'> & {
|
|
|
389
404
|
/**
|
|
390
405
|
* Name of the field and variable (e.g. language)
|
|
391
406
|
*/
|
|
392
|
-
name:
|
|
407
|
+
name: Types.FieldName;
|
|
393
408
|
/**
|
|
394
409
|
* Name of the TypeScript type of the field, e.g. Language
|
|
395
410
|
*/
|
|
@@ -407,7 +422,7 @@ export declare const isFieldEnum: (field: Field) => field is Prettify<Omit<Field
|
|
|
407
422
|
/**
|
|
408
423
|
* Name of the field and variable (e.g. language)
|
|
409
424
|
*/
|
|
410
|
-
name:
|
|
425
|
+
name: Types.FieldName;
|
|
411
426
|
/**
|
|
412
427
|
* Name of the TypeScript type of the field, e.g. Language
|
|
413
428
|
*/
|
|
@@ -421,7 +436,7 @@ export declare const isFieldEnum: (field: Field) => field is Prettify<Omit<Field
|
|
|
421
436
|
* Definition of an enum, consisting of a name and a list of enum members.
|
|
422
437
|
*/
|
|
423
438
|
export type Enum = {
|
|
424
|
-
name:
|
|
439
|
+
name: Types.EnumName;
|
|
425
440
|
/**
|
|
426
441
|
* Description of the enum, ideally providing business background and detailed information
|
|
427
442
|
*/
|