@postxl/generator 0.39.0 → 0.40.1
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 +37 -21
- package/dist/generators/indices/businesslogic-update-module.generator.js +1 -1
- package/dist/generators/indices/businesslogic-view-module.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 +7 -7
- package/dist/generators/indices/datamodule.generator.js +13 -34
- package/dist/generators/indices/dataservice.generator.js +201 -8
- package/dist/generators/indices/dispatcher-service.generator.js +14 -5
- 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/{seed-template-decoder.generator.d.ts → importexport-exporter-class.generator.d.ts} +2 -2
- 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 +7 -7
- package/dist/generators/indices/seed-template.generator.js +1 -1
- package/dist/generators/indices/testdata-service.generator.js +5 -4
- package/dist/generators/models/businesslogic-update.generator.js +5 -5
- package/dist/generators/models/businesslogic-view.generator.js +3 -3
- 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/repository.generator.js +50 -21
- package/dist/lib/imports.d.ts +1 -1
- package/dist/lib/meta.d.ts +468 -134
- package/dist/lib/meta.js +187 -80
- package/dist/lib/schema/schema.d.ts +54 -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 +4 -0
- package/dist/prisma/parse.js +4 -4
- package/package.json +1 -1
- package/dist/generators/indices/seed-service.generator.js +0 -354
- 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,31 +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
|
-
dataMockModuleName: Types.toClassName(`DataMockModule`),
|
|
49
|
-
dataMockDataType: Types.toTypeName(`MockData`),
|
|
50
|
-
dataServiceFilePath: Types.toPath(`${config.paths.dataLibPath}data.service`),
|
|
51
|
-
dataServiceClassName: Types.toClassName(`DataService`),
|
|
52
|
-
repositoryTypeFilePath: Types.toPath(`${config.paths.dataLibPath}repository.type`),
|
|
53
|
-
repositoryTypeName: Types.toTypeName(`Repository`),
|
|
54
|
-
dataMockerFilePath: Types.toPath(`${config.paths.cypressPath}support/data-mocker.class`),
|
|
55
|
-
selectorsFilePath: Types.toPath(`${config.paths.cypressPath}support/selectors`),
|
|
56
|
-
testDataServiceFilePath: Types.toPath(`${config.paths.e2eLibPath}test-data.service`),
|
|
57
|
-
dataMockerStubImportPath: Types.toPath(`${config.paths.cypressPath}support/stubs`),
|
|
58
|
-
dataMockerStubIndexFilePath: Types.toPath(`${config.paths.cypressPath}support/stubs/index`),
|
|
59
|
-
repositoriesConstFilePath: Types.toPath(`${config.paths.dataLibPath}repositories/repositories`),
|
|
60
|
-
repositoriesIndexFilePath: Types.toPath(`${config.paths.dataLibPath}repositories/index`),
|
|
61
|
-
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
|
+
},
|
|
62
47
|
},
|
|
63
48
|
businessLogic: {
|
|
64
49
|
moduleName: Types.toClassName(`BusinessLogicModule`),
|
|
@@ -80,32 +65,143 @@ function getSchemaMetadata({ config }) {
|
|
|
80
65
|
moduleFilePath: Types.toPath(`${config.paths.businessLogicPath}update/update.module`),
|
|
81
66
|
serviceClassName: Types.toClassName(`UpdateService`),
|
|
82
67
|
serviceFilePath: Types.toPath(`${config.paths.businessLogicPath}update/update.service`),
|
|
83
|
-
actionTypesFilePath: Types.toPath(`${config.paths.businessLogicPath}update/actions
|
|
68
|
+
actionTypesFilePath: Types.toPath(`${config.paths.businessLogicPath}update/actions`),
|
|
84
69
|
},
|
|
85
70
|
},
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
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
|
+
},
|
|
89
184
|
},
|
|
90
185
|
seedData: {
|
|
91
186
|
importPath: Types.toPath(`@${config.project}/seed-data`),
|
|
92
187
|
initialMigrationFilePath: Types.toPath(`${config.paths.seedDataPath}001-base-data/001-seed.migration`),
|
|
93
188
|
templateExcelFilePath: Types.toPath(`${config.paths.seedDataPath}002-excel-example/template.xlsx`),
|
|
94
|
-
templateDecoderFilePath: Types.toPath(`${config.paths.seedDataPath}002-excel-example/template.decoder`),
|
|
95
|
-
templateDecoderName: Types.toFunction(`seedTemplateDecoder`),
|
|
96
189
|
},
|
|
97
190
|
seed: {
|
|
98
|
-
seedDataTypeFilePath: Types.toPath(`${config.paths.seedLibPath}seed-data.type`),
|
|
99
|
-
serviceFilePath: Types.toPath(`${config.paths.seedLibPath}seed.service`),
|
|
100
191
|
serviceClassName: Types.toClassName(`SeedService`),
|
|
101
192
|
importPath: Types.toPath(`@${config.project}/seed`),
|
|
102
|
-
|
|
193
|
+
},
|
|
194
|
+
trpc: {
|
|
195
|
+
routesFilePath: Types.toPath(`${config.paths.trpcRoutesFolderPath}index`),
|
|
196
|
+
importPath: Types.toPath(`@${config.project}/trpc`),
|
|
103
197
|
},
|
|
104
198
|
types: {
|
|
105
199
|
indexFilePath: Types.toPath(`${config.paths.modelTypeDefinitionsPath}index`),
|
|
106
200
|
importPath: Types.toPath(`@${config.project}/types`),
|
|
107
201
|
dto: {
|
|
108
202
|
path: Types.toPath(`${config.paths.modelTypeDefinitionsPath}dto.types`),
|
|
203
|
+
genericModel: Types.toTypeName(`GenericModel`),
|
|
204
|
+
idType: Types.toTypeName(`IDType`),
|
|
109
205
|
create: Types.toTypeName(`CreateDTO`),
|
|
110
206
|
update: Types.toTypeName(`UpdateDTO`),
|
|
111
207
|
upsert: Types.toTypeName(`UpsertDTO`),
|
|
@@ -121,34 +217,54 @@ exports.getSchemaMetadata = getSchemaMetadata;
|
|
|
121
217
|
*/
|
|
122
218
|
function getModelMetadata({ model }) {
|
|
123
219
|
const { name, schemaConfig: config } = model;
|
|
124
|
-
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);
|
|
125
221
|
return {
|
|
126
222
|
userFriendlyName: PascalCase,
|
|
127
223
|
userFriendlyNamePlural: capitalizedPlural,
|
|
128
224
|
internalSingularName: Types.toVariableName(camelCase),
|
|
225
|
+
internalSingularNameCapitalized: Types.toVariableName(capitalized),
|
|
129
226
|
internalPluralName: Types.toVariableName(uncapitalizedPlural),
|
|
227
|
+
internalPluralNameCapitalized: Types.toVariableName(capitalizedPlural),
|
|
130
228
|
actions: {
|
|
131
229
|
actionScopeConstType: Types.toTypeName(`${camelCase}`),
|
|
132
230
|
},
|
|
133
231
|
data: {
|
|
232
|
+
importPath: Types.toPath(`@${config.project}/data`),
|
|
134
233
|
mockDataPropertyName: Types.toVariableName(`${uncapitalizedPlural}`),
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
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
|
+
},
|
|
141
246
|
dataMockerStubFilePath: Types.toPath(`${config.paths.cypressPath}support/stubs/${camelCase}.stub`),
|
|
142
|
-
|
|
143
|
-
stubGenerationFnName: Types.
|
|
144
|
-
|
|
145
|
-
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`),
|
|
146
250
|
dataServiceName: Types.toVariableName(`${uncapitalizedPlural}`),
|
|
147
251
|
dataServiceIdName: Types.toVariableName(`${uncapitalized}`),
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
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}`),
|
|
152
268
|
},
|
|
153
269
|
},
|
|
154
270
|
businessLogic: {
|
|
@@ -169,14 +285,14 @@ function getModelMetadata({ model }) {
|
|
|
169
285
|
actionName: Types.toVariableName(`Action_${PascalCase}`),
|
|
170
286
|
actionNameModelPart: Types.toVariableName(`${PascalCase}`),
|
|
171
287
|
actionResultName: Types.toVariableName(`ActionResult_${PascalCase}`),
|
|
172
|
-
createActionFunctionNameCreate: Types.
|
|
173
|
-
createActionFunctionNameCreateMany: Types.
|
|
174
|
-
createActionFunctionNameUpdate: Types.
|
|
175
|
-
createActionFunctionNameUpdateMany: Types.
|
|
176
|
-
createActionFunctionNameUpsert: Types.
|
|
177
|
-
createActionFunctionNameUpsertMany: Types.
|
|
178
|
-
createActionFunctionNameDelete: Types.
|
|
179
|
-
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`),
|
|
180
296
|
},
|
|
181
297
|
dataRepositoryVariableName: Types.toVariableName(`data`),
|
|
182
298
|
},
|
|
@@ -184,22 +300,13 @@ function getModelMetadata({ model }) {
|
|
|
184
300
|
filePath: Types.toPath(`${config.paths.seedDataPath}001-base-data/${uncapitalizedPlural}.seed`),
|
|
185
301
|
constantName: Types.toVariableName(`${uncapitalizedPlural}`),
|
|
186
302
|
importPath: Types.toPath(`@${config.project}/seed`),
|
|
187
|
-
excel: {
|
|
188
|
-
tableName: `${capitalizedPlural}`,
|
|
189
|
-
},
|
|
190
|
-
decoder: {
|
|
191
|
-
schemaName: Types.toVariableName(`${camelCase}Schema`),
|
|
192
|
-
decoderTypeName: Types.toTypeName(`${PascalCase}DecoderType`),
|
|
193
|
-
decoderName: Types.toVariableName(`${camelCase}Decoder`),
|
|
194
|
-
dataName: Types.toVariableName(`${uncapitalizedPlural}`),
|
|
195
|
-
},
|
|
196
303
|
},
|
|
197
304
|
react: {
|
|
198
305
|
folderName: Types.toFolderName(`${PascalCase}`),
|
|
199
306
|
folderPath: Types.toPath(`${config.paths.reactFolderPath}models/${PascalCase}/`),
|
|
200
307
|
context: {
|
|
201
|
-
hookFnName: Types.
|
|
202
|
-
instanceGetterHookFnName: Types.
|
|
308
|
+
hookFnName: Types.toFunctionName(`use${PascalCase}Context`),
|
|
309
|
+
instanceGetterHookFnName: Types.toFunctionName(`use${PascalCase}`),
|
|
203
310
|
},
|
|
204
311
|
components: {
|
|
205
312
|
modals: {
|
|
@@ -227,32 +334,32 @@ function getModelMetadata({ model }) {
|
|
|
227
334
|
importPath: Types.toPath(`@${config.project}${camelCase}.router`),
|
|
228
335
|
getMap: {
|
|
229
336
|
methodName: Types.toVariableName('getMap'),
|
|
230
|
-
reactQueryMethod: Types.
|
|
337
|
+
reactQueryMethod: Types.toFunctionName(`${uncapitalizedPlural}.getMap`),
|
|
231
338
|
},
|
|
232
339
|
create: {
|
|
233
340
|
methodName: Types.toVariableName('create'),
|
|
234
|
-
reactQueryMethod: Types.
|
|
341
|
+
reactQueryMethod: Types.toFunctionName(`${uncapitalizedPlural}.create`),
|
|
235
342
|
},
|
|
236
343
|
update: {
|
|
237
344
|
methodName: Types.toVariableName('update'),
|
|
238
|
-
reactQueryMethod: Types.
|
|
345
|
+
reactQueryMethod: Types.toFunctionName(`${uncapitalizedPlural}.update`),
|
|
239
346
|
},
|
|
240
347
|
delete: {
|
|
241
348
|
methodName: Types.toVariableName('delete'),
|
|
242
|
-
reactQueryMethod: Types.
|
|
349
|
+
reactQueryMethod: Types.toFunctionName(`${uncapitalizedPlural}.delete`),
|
|
243
350
|
},
|
|
244
351
|
},
|
|
245
352
|
types: {
|
|
246
353
|
importPath: Types.toPath(`@${config.project}/types`),
|
|
247
354
|
filePath: Types.toPath(`${config.paths.modelTypeDefinitionsPath}${camelCase}.type`),
|
|
248
355
|
brandedIdType: Types.toTypeName(`${PascalCase}Id`),
|
|
249
|
-
toBrandedIdTypeFnName: Types.
|
|
356
|
+
toBrandedIdTypeFnName: Types.toFunctionName(`to${PascalCase}Id`),
|
|
250
357
|
zodDecoderFnNames: {
|
|
251
|
-
id: Types.
|
|
252
|
-
fromDatabase: Types.
|
|
253
|
-
createObject: Types.
|
|
254
|
-
updateObject: Types.
|
|
255
|
-
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`),
|
|
256
363
|
},
|
|
257
364
|
dto: {
|
|
258
365
|
create: Types.toTypeName(`${PascalCase}CreateDTO`),
|
|
@@ -274,8 +381,8 @@ function getFieldMetadata({ field }) {
|
|
|
274
381
|
const PascalCase = (0, string_1.toPascalCase)(field.name);
|
|
275
382
|
return {
|
|
276
383
|
tsFieldName: Types.toVariableName((0, string_1.toCamelCase)(field.name)),
|
|
277
|
-
getByForeignKeyMethodFnName: Types.
|
|
278
|
-
getByForeignKeyIdsMethodFnName: Types.
|
|
384
|
+
getByForeignKeyMethodFnName: Types.toFunctionName(`getItemsFor${PascalCase}`),
|
|
385
|
+
getByForeignKeyIdsMethodFnName: Types.toFunctionName(`getIdsFor${PascalCase}`),
|
|
279
386
|
excelColumnName: (0, string_1.toPascalCase)(field.name),
|
|
280
387
|
};
|
|
281
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,22 +43,26 @@ 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
|
*/
|
|
@@ -68,19 +72,37 @@ export type SchemaConfig = {
|
|
|
68
72
|
*/
|
|
69
73
|
e2eLibPath: Types.Path;
|
|
70
74
|
/**
|
|
71
|
-
* Path to the directory containing
|
|
75
|
+
* Path to the directory containing data library definitions.
|
|
72
76
|
*
|
|
73
77
|
* NOTE: Metadata assumes that project is set up so that certain parts of the code
|
|
74
|
-
* may reference
|
|
78
|
+
* may reference data library using `@project/data` import.
|
|
75
79
|
*/
|
|
76
|
-
|
|
80
|
+
dataLibPath: Types.Path;
|
|
77
81
|
/**
|
|
78
|
-
* Path to the directory containing
|
|
82
|
+
* Path to the directory containing import-export module.
|
|
79
83
|
*
|
|
80
84
|
* NOTE: Metadata assumes that project is set up so that certain parts of the code
|
|
81
|
-
* may reference
|
|
85
|
+
* may reference import-export using `@project/import-export` import.
|
|
82
86
|
*/
|
|
83
|
-
|
|
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;
|
|
84
106
|
/**
|
|
85
107
|
* Path to the directory containing seed module.
|
|
86
108
|
*
|
|
@@ -95,21 +117,10 @@ export type SchemaConfig = {
|
|
|
95
117
|
* may reference mock data using `@project/seed-data` import.
|
|
96
118
|
*/
|
|
97
119
|
seedDataPath: Types.Path;
|
|
98
|
-
/**
|
|
99
|
-
* Path to the directory containing React components.
|
|
100
|
-
*
|
|
101
|
-
* NOTE: Metadata assumes that the project is set up so that React components
|
|
102
|
-
* may be referenced using `@project/react` import.
|
|
103
|
-
*/
|
|
104
|
-
reactFolderPath: Types.Path;
|
|
105
120
|
/**
|
|
106
121
|
* Path to the directory containing trpc routes.
|
|
107
122
|
*/
|
|
108
123
|
trpcRoutesFolderPath: Types.Path;
|
|
109
|
-
/**
|
|
110
|
-
* Path to the directory containing Prisma migrations.
|
|
111
|
-
*/
|
|
112
|
-
migrationsFolderPath: Types.Path;
|
|
113
124
|
};
|
|
114
125
|
/**
|
|
115
126
|
* Whether the generator should overwrite existing files.
|
|
@@ -128,7 +139,7 @@ export type ModelCore = {
|
|
|
128
139
|
/**
|
|
129
140
|
* Name of the model (e.g. Aggregation)
|
|
130
141
|
*/
|
|
131
|
-
name:
|
|
142
|
+
name: Types.ModelName;
|
|
132
143
|
/**
|
|
133
144
|
* Description of the model, ideally providing business background and detailed information
|
|
134
145
|
*/
|
|
@@ -207,7 +218,7 @@ export type FieldCore = {
|
|
|
207
218
|
*
|
|
208
219
|
* Note: The type of the name is narrowed by each field type.
|
|
209
220
|
*/
|
|
210
|
-
name:
|
|
221
|
+
name: Types.FieldName;
|
|
211
222
|
/**
|
|
212
223
|
* Description of the field, ideally providing business background and detailed information
|
|
213
224
|
*/
|
|
@@ -250,7 +261,7 @@ export type FieldScalar = Prettify<Omit<FieldCore, 'name'> & {
|
|
|
250
261
|
/**
|
|
251
262
|
* Name of the field and variable (e.g. name)
|
|
252
263
|
*/
|
|
253
|
-
name:
|
|
264
|
+
name: Types.FieldName;
|
|
254
265
|
/**
|
|
255
266
|
* Name of the scalar TypeScript type, e.g. string
|
|
256
267
|
*/
|
|
@@ -273,7 +284,7 @@ export type FieldId = Prettify<Omit<FieldCore, 'name'> & {
|
|
|
273
284
|
/**
|
|
274
285
|
* Name of the field and variable (e.g. id)
|
|
275
286
|
*/
|
|
276
|
-
name:
|
|
287
|
+
name: Types.FieldName;
|
|
277
288
|
/**
|
|
278
289
|
* Model that this ID field identifies.
|
|
279
290
|
*/
|
|
@@ -303,7 +314,7 @@ export declare const isFieldId: (field: Field) => field is Prettify<Omit<FieldCo
|
|
|
303
314
|
/**
|
|
304
315
|
* Name of the field and variable (e.g. id)
|
|
305
316
|
*/
|
|
306
|
-
name:
|
|
317
|
+
name: Types.FieldName;
|
|
307
318
|
/**
|
|
308
319
|
* Model that this ID field identifies.
|
|
309
320
|
*/
|
|
@@ -333,14 +344,14 @@ export type FieldRelation = Prettify<Omit<FieldCore, 'name'> & {
|
|
|
333
344
|
/**
|
|
334
345
|
* Name of the field and variable (e.g. aggregationId)
|
|
335
346
|
*/
|
|
336
|
-
name:
|
|
347
|
+
name: Types.FieldName;
|
|
337
348
|
/**
|
|
338
349
|
* Name of the field in the related model that references this model (e.g. `aggregation`).
|
|
339
350
|
*
|
|
340
351
|
* NOTE: This does not reference the database column name, but the field name
|
|
341
352
|
* in the model (e.g. not `aggregationId`, but `aggregation`).
|
|
342
353
|
*/
|
|
343
|
-
relatedModelBacklinkFieldName:
|
|
354
|
+
relatedModelBacklinkFieldName: Types.FieldName;
|
|
344
355
|
/**
|
|
345
356
|
* Name of the unbranded TypeScript type of the field, e.g. string
|
|
346
357
|
*
|
|
@@ -363,14 +374,14 @@ export declare const isFieldRelation: (field: Field) => field is Prettify<Omit<F
|
|
|
363
374
|
/**
|
|
364
375
|
* Name of the field and variable (e.g. aggregationId)
|
|
365
376
|
*/
|
|
366
|
-
name:
|
|
377
|
+
name: Types.FieldName;
|
|
367
378
|
/**
|
|
368
379
|
* Name of the field in the related model that references this model (e.g. `aggregation`).
|
|
369
380
|
*
|
|
370
381
|
* NOTE: This does not reference the database column name, but the field name
|
|
371
382
|
* in the model (e.g. not `aggregationId`, but `aggregation`).
|
|
372
383
|
*/
|
|
373
|
-
relatedModelBacklinkFieldName:
|
|
384
|
+
relatedModelBacklinkFieldName: Types.FieldName;
|
|
374
385
|
/**
|
|
375
386
|
* Name of the unbranded TypeScript type of the field, e.g. string
|
|
376
387
|
*
|
|
@@ -393,7 +404,7 @@ export type FieldEnum = Prettify<Omit<FieldCore, 'name'> & {
|
|
|
393
404
|
/**
|
|
394
405
|
* Name of the field and variable (e.g. language)
|
|
395
406
|
*/
|
|
396
|
-
name:
|
|
407
|
+
name: Types.FieldName;
|
|
397
408
|
/**
|
|
398
409
|
* Name of the TypeScript type of the field, e.g. Language
|
|
399
410
|
*/
|
|
@@ -411,7 +422,7 @@ export declare const isFieldEnum: (field: Field) => field is Prettify<Omit<Field
|
|
|
411
422
|
/**
|
|
412
423
|
* Name of the field and variable (e.g. language)
|
|
413
424
|
*/
|
|
414
|
-
name:
|
|
425
|
+
name: Types.FieldName;
|
|
415
426
|
/**
|
|
416
427
|
* Name of the TypeScript type of the field, e.g. Language
|
|
417
428
|
*/
|
|
@@ -425,7 +436,7 @@ export declare const isFieldEnum: (field: Field) => field is Prettify<Omit<Field
|
|
|
425
436
|
* Definition of an enum, consisting of a name and a list of enum members.
|
|
426
437
|
*/
|
|
427
438
|
export type Enum = {
|
|
428
|
-
name:
|
|
439
|
+
name: Types.EnumName;
|
|
429
440
|
/**
|
|
430
441
|
* Description of the enum, ideally providing business background and detailed information
|
|
431
442
|
*/
|