@postxl/generator 0.34.0 → 0.35.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.
Files changed (58) hide show
  1. package/dist/generator.js +40 -22
  2. package/dist/generators/indices/businesslogic-actiontypes.generator.d.ts +9 -0
  3. package/dist/generators/indices/businesslogic-actiontypes.generator.js +39 -0
  4. package/dist/generators/indices/businesslogic-update-index.generator.d.ts +9 -0
  5. package/dist/generators/indices/businesslogic-update-index.generator.js +20 -0
  6. package/dist/generators/indices/businesslogic-update-module.generator.d.ts +9 -0
  7. package/dist/generators/indices/businesslogic-update-module.generator.js +69 -0
  8. package/dist/generators/indices/businesslogic-update-service.generator.d.ts +9 -0
  9. package/dist/generators/indices/businesslogic-update-service.generator.js +34 -0
  10. package/dist/generators/indices/businesslogic-view-index.generator.d.ts +9 -0
  11. package/dist/generators/indices/businesslogic-view-index.generator.js +19 -0
  12. package/dist/generators/indices/{businesslogicindex.generator.d.ts → businesslogic-view-module.generator.d.ts} +2 -2
  13. package/dist/generators/indices/{businesslogicmodule.generator.js → businesslogic-view-module.generator.js} +22 -26
  14. package/dist/generators/indices/{businesslogicservice.generator.d.ts → businesslogic-view-service.generator.d.ts} +1 -1
  15. package/dist/generators/indices/{businesslogicservice.generator.js → businesslogic-view-service.generator.js} +9 -10
  16. package/dist/generators/indices/{datamockmodule.generator.js → datamock-module.generator.js} +8 -16
  17. package/dist/generators/indices/datamocker.generator.js +3 -7
  18. package/dist/generators/indices/datamodule.generator.js +7 -13
  19. package/dist/generators/indices/{businesslogicmodule.generator.d.ts → dispatcher-service.generator.d.ts} +2 -2
  20. package/dist/generators/indices/dispatcher-service.generator.js +81 -0
  21. package/dist/generators/indices/seed-migration.generator.d.ts +9 -0
  22. package/dist/generators/indices/seed-migration.generator.js +35 -0
  23. package/dist/generators/indices/seed-service.generator.d.ts +1 -1
  24. package/dist/generators/indices/seed-service.generator.js +327 -123
  25. package/dist/generators/indices/seed-template-decoder.generator.js +22 -6
  26. package/dist/generators/indices/{seed.generator.d.ts → seeddata-type.generator.d.ts} +2 -2
  27. package/dist/generators/indices/seeddata-type.generator.js +42 -0
  28. package/dist/generators/indices/types.generator.d.ts +1 -1
  29. package/dist/generators/indices/types.generator.js +8 -6
  30. package/dist/generators/models/businesslogic-update.generator.d.ts +10 -0
  31. package/dist/generators/models/businesslogic-update.generator.js +243 -0
  32. package/dist/generators/models/businesslogic-view.generator.d.ts +10 -0
  33. package/dist/generators/models/{businesslogic.generator.js → businesslogic-view.generator.js} +23 -72
  34. package/dist/generators/models/react.generator/modals.generator.js +2 -2
  35. package/dist/generators/models/repository.generator.d.ts +9 -0
  36. package/dist/generators/models/repository.generator.js +420 -131
  37. package/dist/generators/models/route.generator.js +45 -55
  38. package/dist/generators/models/seed.generator.js +6 -2
  39. package/dist/generators/models/types.generator.js +60 -13
  40. package/dist/lib/attributes.d.ts +5 -0
  41. package/dist/lib/imports.d.ts +23 -2
  42. package/dist/lib/imports.js +19 -1
  43. package/dist/lib/meta.d.ts +287 -34
  44. package/dist/lib/meta.js +87 -16
  45. package/dist/lib/schema/schema.d.ts +24 -6
  46. package/dist/lib/schema/types.d.ts +4 -0
  47. package/dist/lib/utils/jsdoc.d.ts +1 -1
  48. package/dist/lib/utils/jsdoc.js +8 -6
  49. package/dist/lib/utils/string.js +2 -1
  50. package/dist/prisma/attributes.js +7 -3
  51. package/dist/prisma/parse.js +25 -5
  52. package/package.json +1 -1
  53. package/dist/generators/indices/businesslogicindex.generator.js +0 -19
  54. package/dist/generators/indices/seed.generator.js +0 -17
  55. package/dist/generators/indices/testdataservice.generator.d.ts +0 -9
  56. package/dist/generators/indices/testdataservice.generator.js +0 -78
  57. package/dist/generators/models/businesslogic.generator.d.ts +0 -9
  58. /package/dist/generators/indices/{datamockmodule.generator.d.ts → datamock-module.generator.d.ts} +0 -0
@@ -4,6 +4,36 @@ import * as Types from './schema/types';
4
4
  * Collection of "global", schema-related values that might be referenced by different generators.
5
5
  */
6
6
  export type SchemaMetaData = {
7
+ actions: {
8
+ /**
9
+ * The name of the Module class
10
+ */
11
+ moduleName: Types.ClassName;
12
+ /**
13
+ * Path that may be used to import from the action module.
14
+ */
15
+ importPath: Types.Path;
16
+ /**
17
+ * Path to the file containing the execution interface definition.
18
+ */
19
+ actionExecutionInterfaceFilePath: Types.Path;
20
+ /**
21
+ * The name of the interface that handles the action execution.
22
+ */
23
+ actionExecutionInterface: Types.ClassName;
24
+ /**
25
+ * The name of the class that handles the action execution.
26
+ */
27
+ actionExecutionClass: Types.ClassName;
28
+ /**
29
+ * The name of the mock for the actionExecution class.
30
+ */
31
+ actionExecutionMock: Types.ClassName;
32
+ /**
33
+ * Path to the file containing the dispatcher service class definition.
34
+ */
35
+ dispatcherServiceFilePath: Types.Path;
36
+ };
7
37
  data: {
8
38
  /**
9
39
  * The name of the Module class
@@ -25,6 +55,14 @@ export type SchemaMetaData = {
25
55
  * Path to the file containing data service class definitions.
26
56
  */
27
57
  dataServiceFilePath: Types.Path;
58
+ /**
59
+ * Path to the file containing the repository type definition.
60
+ */
61
+ repositoryTypeFilePath: Types.Path;
62
+ /**
63
+ * Name of the repository type.
64
+ */
65
+ repositoryTypeName: Types.TypeName;
28
66
  /**
29
67
  * Path to the file containing data mocker class definitions.
30
68
  */
@@ -37,10 +75,6 @@ export type SchemaMetaData = {
37
75
  * Path that may be used to import the data mocker stubs.
38
76
  */
39
77
  dataMockerStubImportPath: Types.Path;
40
- /**
41
- * Path to the file containing test data service definition.
42
- */
43
- testDataServiceFilePath: Types.Path;
44
78
  /**
45
79
  * Path to the file containing the array with all repositories.
46
80
  */
@@ -72,43 +106,107 @@ export type SchemaMetaData = {
72
106
  */
73
107
  moduleFilePath: Types.Path;
74
108
  /**
75
- * The name of the business logic service class.
109
+ * Settings for the view sub-module
76
110
  */
77
- serviceClassName: Types.ClassName;
111
+ view: {
112
+ /**
113
+ * The name of the module class
114
+ */
115
+ moduleName: Types.ClassName;
116
+ /**
117
+ * Path that may be used to import from the view module.
118
+ */
119
+ importPath: Types.Path;
120
+ /**
121
+ * Path to the file containing the view index.
122
+ */
123
+ indexFilePath: Types.Path;
124
+ /**
125
+ * Path to the file containing the view module definition.
126
+ */
127
+ moduleFilePath: Types.Path;
128
+ /**
129
+ * The name of the central view service class, containing all model view services.
130
+ */
131
+ serviceClassName: Types.ClassName;
132
+ /**
133
+ * Path to the file containing the view service class definition.
134
+ */
135
+ serviceFilePath: Types.Path;
136
+ };
78
137
  /**
79
- * Path to the file containing the business logic service class definition.
138
+ * Settings for the update sub-module
80
139
  */
81
- serviceFilePath: Types.Path;
140
+ update: {
141
+ /**
142
+ * The name of the module class
143
+ */
144
+ moduleName: Types.ClassName;
145
+ /**
146
+ * Path that may be used to import from the update module.
147
+ */
148
+ importPath: Types.Path;
149
+ /**
150
+ * Path to the file containing the update index.
151
+ */
152
+ indexFilePath: Types.Path;
153
+ /**
154
+ * Path to the file containing the update module definition.
155
+ */
156
+ moduleFilePath: Types.Path;
157
+ /**
158
+ * The name of the central update service class, containing all model update services.
159
+ */
160
+ serviceClassName: Types.ClassName;
161
+ /**
162
+ * Path to the file containing the update service class definition.
163
+ */
164
+ serviceFilePath: Types.Path;
165
+ /**
166
+ * Path to the file containing the overall action types
167
+ */
168
+ actionTypesFilePath: Types.Path;
169
+ };
82
170
  };
83
- seed: {
171
+ seedData: {
84
172
  /**
85
- * Path to the index file for the seed package.
173
+ * Path that may be used in the import statement.
86
174
  */
87
- indexFilePath: Types.Path;
175
+ importPath: Types.Path;
88
176
  /**
89
- * Path to the SeedService file.
177
+ * Location of the initial seed data migration
90
178
  */
91
- serviceFilePath: Types.Path;
179
+ initialMigrationFilePath: Types.Path;
92
180
  /**
93
181
  * Path to seed Excel template file.
94
182
  */
95
183
  templateExcelFilePath: Types.Path;
96
184
  /**
97
- * Path to template decoder file.
185
+ * Path to template decoder **
98
186
  */
99
187
  templateDecoderFilePath: Types.Path;
100
188
  /**
101
189
  * The name of the template decoder function.
102
190
  */
103
191
  templateDecoderName: Types.Fnction;
192
+ };
193
+ seed: {
104
194
  /**
105
- * Path that may be used in the import statement.
195
+ * Path to the seed data type.
106
196
  */
107
- importPath: Types.Path;
197
+ seedDataTypeFilePath: Types.Path;
198
+ /**
199
+ * Path to the SeedService file.
200
+ */
201
+ serviceFilePath: Types.Path;
202
+ /**
203
+ * The name of the SeedService class.
204
+ */
205
+ serviceClassName: Types.ClassName;
108
206
  /**
109
- * Random seed value to use for seeding faker.
207
+ * Path that may be used in the import statement.
110
208
  */
111
- randomSeed: number;
209
+ importPath: Types.Path;
112
210
  };
113
211
  trpc: {
114
212
  /**
@@ -129,6 +227,27 @@ export type SchemaMetaData = {
129
227
  * Path that may be used to import the type definitions package.
130
228
  */
131
229
  importPath: Types.Path;
230
+ /**
231
+ * Path and type names for the Data Transfer Objects (DTOs).
232
+ */
233
+ dto: {
234
+ /**
235
+ * Path to the file containing DTO type definitions.
236
+ */
237
+ path: Types.Path;
238
+ /**
239
+ * Generic type for a Create DTO.
240
+ */
241
+ create: Types.TypeName;
242
+ /**
243
+ * Generic type for an Update DTO.
244
+ */
245
+ update: Types.TypeName;
246
+ /**
247
+ * Generic type for an Upsert DTO.
248
+ */
249
+ upsert: Types.TypeName;
250
+ };
132
251
  };
133
252
  /**
134
253
  * Path to the directory containing migrations.
@@ -152,12 +271,21 @@ export type ModelMetaData = {
152
271
  /**
153
272
  * A user friendly name
154
273
  *
155
- * NOTE: User friendly name is very generic and meant to be used in log messages, errors -
156
- * and any other places where the user shall read about it!
274
+ * NOTE: User friendly name is very generic and meant to be used in log messages, comments,
275
+ * errors - and any other places where the user shall read about it!
157
276
  * It is not meant to be used for variables, class names, etc. In code, you should
158
277
  * use a more specific name for your purposes (e.g. `reactCreateModalComponentName`).
159
278
  */
160
279
  userFriendlyName: string;
280
+ /**
281
+ * A user friendly name in plural form
282
+ *
283
+ * NOTE: User friendly name is very generic and meant to be used in log messages, comments,
284
+ * errors - and any other places where the user shall read about it!
285
+ * It is not meant to be used for variables, class names, etc. In code, you should
286
+ * use a more specific name for your purposes (e.g. `reactCreateModalComponentName`).
287
+ */
288
+ userFriendlyNamePlural: string;
161
289
  /**
162
290
  * The name of the model in singular form.
163
291
  *
@@ -174,6 +302,15 @@ export type ModelMetaData = {
174
302
  * (e.g. `reactCreateModalComponentName`)
175
303
  */
176
304
  internalPluralName: Types.VariableName;
305
+ /**
306
+ * Properties provided by the `actions` generators.
307
+ */
308
+ actions: {
309
+ /**
310
+ * Each model defines its own action scope as a discriminator for the action execution. (e.g. `aggregation`)
311
+ */
312
+ actionScopeConstType: Types.TypeName;
313
+ };
177
314
  /**
178
315
  * Properties provided by the `data` generators.
179
316
  */
@@ -254,25 +391,106 @@ export type ModelMetaData = {
254
391
  */
255
392
  businessLogic: {
256
393
  /**
257
- * Path that may be used to import definitions of this model.
258
- */
259
- importPath: Types.Path;
260
- /**
261
- * The name by which the model's class is exposed in the businessLogicService/context. (e.g. aggregations)
394
+ * The const type that represents the scope of the business logic service. (e.g. `aggregation`)
395
+ * The scope is typically a model. However, in a more complex business logic, this could also be
396
+ * whatever makes sense to put into a single business logic service - e.g. "approval" (for MCA) or "calculation" (for LA360).
262
397
  */
263
- serviceClassName: Types.ClassName;
398
+ scopeName: Types.VariableName;
264
399
  /**
265
- * The name by which the model's class is exposed in the businessLogicService/context. (e.g. aggregations)
400
+ * Path that may be used to import definitions of this model.
266
401
  */
267
- serviceVariableName: Types.VariableName;
402
+ importPath: Types.Path;
268
403
  /**
269
- * Name of the file containing the service for this model.
404
+ * The definitions for the view service of a model
270
405
  */
271
- serviceFileName: Types.FileName;
406
+ view: {
407
+ /**
408
+ * The name by which the model's view class is exposed in the viewService/context. (e.g. aggregations)
409
+ */
410
+ serviceClassName: Types.ClassName;
411
+ /**
412
+ * The name by which the model's service is exposed in the viewService/context. (e.g. aggregations)
413
+ */
414
+ serviceVariableName: Types.VariableName;
415
+ /**
416
+ * Name of the file containing the view service for this model.
417
+ */
418
+ serviceFileName: Types.FileName;
419
+ /**
420
+ * Path to the file containing the view service.
421
+ */
422
+ serviceFilePath: Types.Path;
423
+ };
272
424
  /**
273
- * Path to the file containing the service.
425
+ * The definitions for the update service of a model
274
426
  */
275
- serviceFilePath: Types.Path;
427
+ update: {
428
+ /**
429
+ * The name by which the model's update class is exposed in the updateService/context. (e.g. aggregations)
430
+ */
431
+ serviceClassName: Types.ClassName;
432
+ /**
433
+ * The name by which the model's service is exposed in the updateService/context. (e.g. aggregations)
434
+ */
435
+ serviceVariableName: Types.VariableName;
436
+ /**
437
+ * Name of the file containing the update service for this model.
438
+ */
439
+ serviceFileName: Types.FileName;
440
+ /**
441
+ * Path to the file containing the update service.
442
+ */
443
+ serviceFilePath: Types.Path;
444
+ /**
445
+ * The name of the model used as a discriminator for the action execution. (e.g. `aggregation`)
446
+ */
447
+ actionModelDiscriminantName: Types.VariableName;
448
+ /**
449
+ * Name of the model's aggregated action type. (e.g. `Action_Aggregation`)
450
+ */
451
+ actionName: Types.VariableName;
452
+ /**
453
+ * Name of the model's aggregated action result type. (e.g. `ActionResult_Aggregation`)
454
+ */
455
+ actionResultName: Types.VariableName;
456
+ /**
457
+ * The model's name that is used to build the different action types.
458
+ * (e.g. `Aggregation` which will be used to build `Action_Aggregation_Create`)
459
+ */
460
+ actionNameModelPart: Types.VariableName;
461
+ /**
462
+ * Name of the function that creates a `create` action for the model (e.g. `createActionAggregationCreate`)
463
+ */
464
+ createActionFunctionNameCreate: Types.Fnction;
465
+ /**
466
+ * Name of the function that creates a `createMany` action for the model (e.g. `createActionAggregationCreateMany`)
467
+ */
468
+ createActionFunctionNameCreateMany: Types.Fnction;
469
+ /**
470
+ * Name of the function that creates a `update` action for the model (e.g. `createActionAggregationUpdate`)
471
+ */
472
+ createActionFunctionNameUpdate: Types.Fnction;
473
+ /**
474
+ * Name of the function that creates a `updateMany` action for the model (e.g. `createActionAggregationUpdateMany`)
475
+ */
476
+ createActionFunctionNameUpdateMany: Types.Fnction;
477
+ /**
478
+ * Name of the function that creates a `upsert` action for the model (e.g. `createActionAggregationUpsert`)
479
+ */
480
+ createActionFunctionNameUpsert: Types.Fnction;
481
+ /**
482
+ * Name of the function that creates a `upsertMany` action for the model (e.g. `createActionAggregationUpsertMany`)
483
+ */
484
+ createActionFunctionNameUpsertMany: Types.Fnction;
485
+ /**
486
+ * Name of the function that creates a `delete` action for the model (e.g. `createActionAggregationDelete`)
487
+ */
488
+ createActionFunctionNameDelete: Types.Fnction;
489
+ /**
490
+ * Name of the function that creates a `deleteMany` action for the model (e.g. `createActionAggregationDeleteMany`)
491
+ */
492
+ createActionFunctionNameDeleteMany: Types.Fnction;
493
+ };
276
494
  /**
277
495
  * Name by which the business logic service exposes the data service.
278
496
  */
@@ -450,10 +668,45 @@ export type ModelMetaData = {
450
668
  * e.g. `toAggregationId`.
451
669
  */
452
670
  toBrandedIdTypeFnName: Types.Fnction;
671
+ zodDecoderFnNames: {
672
+ /**
673
+ * The name of the function that decodes a scalar value to a branded ID type, e.g. `aggregationIdDecoder`.
674
+ */
675
+ id: Types.Fnction;
676
+ /**
677
+ * The name of the function that decodes a source (database) object to a fully typed object, e.g. `aggregationDatabaseDecoder`.
678
+ */
679
+ fromDatabase: Types.Fnction;
680
+ /**
681
+ * The name of the function that decodes a Create object to a fully typed object, e.g. `aggregationCreateDecoder`.
682
+ */
683
+ createObject: Types.Fnction;
684
+ /**
685
+ * The name of the function that decodes an Update object to a fully typed object, e.g. `aggregationUpdateDecoder`.
686
+ */
687
+ updateObject: Types.Fnction;
688
+ /**
689
+ * The name of the function that decodes an Upsert object to a fully typed object, e.g. `aggregationUpsertDecoder`.
690
+ */
691
+ upsertObject: Types.Fnction;
692
+ };
453
693
  /**
454
- * The name of the function that decodes a source (database) object to a fully typed object, e.g. `aggregationDecoder`.
694
+ * Type definitions for the different Data Transfer Objects (DTOs).
455
695
  */
456
- zodDecoderFnName: Types.Fnction;
696
+ dto: {
697
+ /**
698
+ * The name of the type that represents a DTO for creating a new object, e.g. `AggregationCreateDTO`.
699
+ */
700
+ create: Types.TypeName;
701
+ /**
702
+ * The name of the type that represents a DTO for updating an existing object, e.g. `AggregationUpdateDTO`.
703
+ */
704
+ update: Types.TypeName;
705
+ /**
706
+ * The name of the type that represents a DTO for upserting an existing object, e.g. `AggregationUpsertDTO`.
707
+ */
708
+ upsert: Types.TypeName;
709
+ };
457
710
  /**
458
711
  * The name of the file containing type definitions (e.g. `aggregation.type`).
459
712
  */
package/dist/lib/meta.js CHANGED
@@ -31,13 +31,23 @@ const string_1 = require("./utils/string");
31
31
  */
32
32
  function getSchemaMetadata({ config }) {
33
33
  return {
34
+ actions: {
35
+ moduleName: Types.toClassName(`ActionModule`),
36
+ importPath: Types.toPath(`@${config.project}/actions`),
37
+ actionExecutionInterfaceFilePath: Types.toPath(`@${config.project}/actions/actionExecution.class`),
38
+ actionExecutionInterface: Types.toClassName(`IActionExecution`),
39
+ actionExecutionClass: Types.toClassName(`ActionExecution`),
40
+ actionExecutionMock: Types.toClassName(`MockActionExecution`),
41
+ dispatcherServiceFilePath: Types.toPath(`${config.paths.actionsPath}dispatcher.service`),
42
+ },
34
43
  data: {
35
44
  moduleName: Types.toClassName(`DataModule`),
36
45
  importPath: Types.toPath(`@${config.project}/data`),
37
46
  dataModuleFilePath: Types.toPath(`${config.paths.dataLibPath}data.module`),
38
47
  dataMockModuleFilePath: Types.toPath(`${config.paths.dataLibPath}data.mock.module`),
39
- testDataServiceFilePath: Types.toPath(`${config.paths.dataLibPath}test-data.service`),
40
48
  dataServiceFilePath: Types.toPath(`${config.paths.dataLibPath}data.service`),
49
+ repositoryTypeFilePath: Types.toPath(`${config.paths.dataLibPath}repository.type`),
50
+ repositoryTypeName: Types.toTypeName(`Repository`),
41
51
  dataMockerFilePath: Types.toPath(`${config.paths.cypressPath}support/data-mocker.class`),
42
52
  dataMockerStubImportPath: Types.toPath(`${config.paths.cypressPath}support/stubs`),
43
53
  dataMockerStubIndexFilePath: Types.toPath(`${config.paths.cypressPath}support/stubs/index`),
@@ -50,25 +60,50 @@ function getSchemaMetadata({ config }) {
50
60
  importPath: Types.toPath(`@${config.project}/business-logic`),
51
61
  indexFilePath: Types.toPath(`${config.paths.businessLogicPath}index`),
52
62
  moduleFilePath: Types.toPath(`${config.paths.businessLogicPath}business-logic.module`),
53
- serviceClassName: Types.toClassName(`BusinessLogicService`),
54
- serviceFilePath: Types.toPath(`${config.paths.businessLogicPath}business-logic.service`),
63
+ view: {
64
+ moduleName: Types.toClassName(`ViewModule`),
65
+ importPath: Types.toPath(`@${config.project}/business-logic/view`),
66
+ indexFilePath: Types.toPath(`${config.paths.businessLogicPath}view/index`),
67
+ moduleFilePath: Types.toPath(`${config.paths.businessLogicPath}view/view.module`),
68
+ serviceClassName: Types.toClassName(`ViewService`),
69
+ serviceFilePath: Types.toPath(`${config.paths.businessLogicPath}view/view.service`),
70
+ },
71
+ update: {
72
+ moduleName: Types.toClassName(`UpdateModule`),
73
+ importPath: Types.toPath(`@${config.project}/business-logic/update`),
74
+ indexFilePath: Types.toPath(`${config.paths.businessLogicPath}update/index`),
75
+ moduleFilePath: Types.toPath(`${config.paths.businessLogicPath}update/update.module`),
76
+ serviceClassName: Types.toClassName(`UpdateService`),
77
+ serviceFilePath: Types.toPath(`${config.paths.businessLogicPath}update/update.service`),
78
+ actionTypesFilePath: Types.toPath(`${config.paths.businessLogicPath}update/actions.types`),
79
+ },
55
80
  },
56
81
  trpc: {
57
82
  routesFilePath: Types.toPath(`${config.paths.trpcRoutesFolderPath}index`),
58
83
  importPath: Types.toPath(`@${config.project}/trpc`),
59
84
  },
60
- seed: {
61
- indexFilePath: Types.toPath(`${config.paths.seedPath}data/index`),
62
- serviceFilePath: Types.toPath(`${config.paths.seedPath}seed.service`),
63
- templateExcelFilePath: Types.toPath(`${config.paths.seedPath}template.xlsx`),
64
- templateDecoderFilePath: Types.toPath(`${config.paths.seedPath}seed.decoder`),
85
+ seedData: {
86
+ importPath: Types.toPath(`@${config.project}/seed-data`),
87
+ initialMigrationFilePath: Types.toPath(`${config.paths.seedDataPath}001-base-data/001-seed.migration`),
88
+ templateExcelFilePath: Types.toPath(`${config.paths.seedDataPath}002-excel-example/template.xlsx`),
89
+ templateDecoderFilePath: Types.toPath(`${config.paths.seedDataPath}002-excel-example/template.decoder`),
65
90
  templateDecoderName: Types.toFunction(`seedTemplateDecoder`),
91
+ },
92
+ seed: {
93
+ seedDataTypeFilePath: Types.toPath(`${config.paths.seedLibPath}seed-data.type`),
94
+ serviceFilePath: Types.toPath(`${config.paths.seedLibPath}seed.service`),
95
+ serviceClassName: Types.toClassName(`SeedService`),
66
96
  importPath: Types.toPath(`@${config.project}/seed`),
67
- randomSeed: config.randomSeed,
68
97
  },
69
98
  types: {
70
99
  indexFilePath: Types.toPath(`${config.paths.modelTypeDefinitionsPath}index`),
71
100
  importPath: Types.toPath(`@${config.project}/types`),
101
+ dto: {
102
+ path: Types.toPath(`${config.paths.modelTypeDefinitionsPath}dto.types`),
103
+ create: Types.toTypeName(`CreateDTO`),
104
+ update: Types.toTypeName(`UpdateDTO`),
105
+ upsert: Types.toTypeName(`UpsertDTO`),
106
+ },
72
107
  },
73
108
  migrationsPath: Types.toPath(`${config.paths.migrationsFolderPath}`),
74
109
  config,
@@ -83,8 +118,12 @@ function getModelMetadata({ model }) {
83
118
  const { PascalCase, camelCase, pluralized, uncapitalizedPlural, uncapitalized, capitalizedPlural } = (0, string_1.conjugateNames)(name);
84
119
  return {
85
120
  userFriendlyName: PascalCase,
121
+ userFriendlyNamePlural: capitalizedPlural,
86
122
  internalSingularName: Types.toVariableName(camelCase),
87
123
  internalPluralName: Types.toVariableName(uncapitalizedPlural),
124
+ actions: {
125
+ actionScopeConstType: Types.toTypeName(`${camelCase}`),
126
+ },
88
127
  data: {
89
128
  mockDataPropertyName: Types.toVariableName(`${uncapitalizedPlural}`),
90
129
  defaultStubConstantName: Types.toVariableName(`${camelCase}DefaultStub`),
@@ -107,15 +146,36 @@ function getModelMetadata({ model }) {
107
146
  },
108
147
  },
109
148
  businessLogic: {
110
- importPath: Types.toPath(`@${config.project}/businessLogic`),
111
- serviceClassName: Types.toClassName(`${PascalCase}Service`),
112
- serviceVariableName: Types.toVariableName(`${uncapitalizedPlural}`),
113
- serviceFileName: Types.toFileName(`${camelCase}.service`),
114
- serviceFilePath: Types.toPath(`${config.paths.businessLogicPath}${camelCase}.service`),
149
+ scopeName: Types.toVariableName(`${camelCase}`),
150
+ importPath: Types.toPath(`@${config.project}/business-logic`),
151
+ view: {
152
+ serviceClassName: Types.toClassName(`${PascalCase}ViewService`),
153
+ serviceVariableName: Types.toVariableName(`${uncapitalizedPlural}`),
154
+ serviceFileName: Types.toFileName(`${camelCase}.view.service`),
155
+ serviceFilePath: Types.toPath(`${config.paths.businessLogicPath}view/${camelCase}.view.service`),
156
+ },
157
+ update: {
158
+ serviceClassName: Types.toClassName(`${PascalCase}UpdateService`),
159
+ serviceVariableName: Types.toVariableName(`${uncapitalizedPlural}`),
160
+ serviceFileName: Types.toFileName(`${camelCase}.update.service`),
161
+ serviceFilePath: Types.toPath(`${config.paths.businessLogicPath}update/${camelCase}.update.service`),
162
+ actionModelDiscriminantName: Types.toVariableName(`${camelCase}`),
163
+ actionName: Types.toVariableName(`Action_${PascalCase}`),
164
+ actionNameModelPart: Types.toVariableName(`${PascalCase}`),
165
+ actionResultName: Types.toVariableName(`ActionResult_${PascalCase}`),
166
+ createActionFunctionNameCreate: Types.toFunction(`createAction${PascalCase}Create`),
167
+ createActionFunctionNameCreateMany: Types.toFunction(`createAction${PascalCase}CreateMany`),
168
+ createActionFunctionNameUpdate: Types.toFunction(`createAction${PascalCase}Update`),
169
+ createActionFunctionNameUpdateMany: Types.toFunction(`createAction${PascalCase}UpdateMany`),
170
+ createActionFunctionNameUpsert: Types.toFunction(`createAction${PascalCase}Upsert`),
171
+ createActionFunctionNameUpsertMany: Types.toFunction(`createAction${PascalCase}UpsertMany`),
172
+ createActionFunctionNameDelete: Types.toFunction(`createAction${PascalCase}Delete`),
173
+ createActionFunctionNameDeleteMany: Types.toFunction(`createAction${PascalCase}DeleteMany`),
174
+ },
115
175
  dataRepositoryVariableName: Types.toVariableName(`data`),
116
176
  },
117
177
  seed: {
118
- filePath: Types.toPath(`${config.paths.seedPath}data/${uncapitalizedPlural}`),
178
+ filePath: Types.toPath(`${config.paths.seedDataPath}001-base-data/${uncapitalizedPlural}.seed`),
119
179
  constantName: Types.toVariableName(`${uncapitalizedPlural}`),
120
180
  importPath: Types.toPath(`@${config.project}/seed`),
121
181
  excel: {
@@ -181,7 +241,18 @@ function getModelMetadata({ model }) {
181
241
  filePath: Types.toPath(`${config.paths.modelTypeDefinitionsPath}${camelCase}.type`),
182
242
  brandedIdType: Types.toTypeName(`${PascalCase}Id`),
183
243
  toBrandedIdTypeFnName: Types.toFunction(`to${PascalCase}Id`),
184
- zodDecoderFnName: Types.toFunction(`${camelCase}Decoder`),
244
+ zodDecoderFnNames: {
245
+ id: Types.toFunction(`${camelCase}IdDecoder`),
246
+ fromDatabase: Types.toFunction(`${camelCase}DatabaseDecoder`),
247
+ createObject: Types.toFunction(`${camelCase}CreateDecoder`),
248
+ updateObject: Types.toFunction(`${camelCase}UpdateDecoder`),
249
+ upsertObject: Types.toFunction(`${camelCase}UpsertDecoder`),
250
+ },
251
+ dto: {
252
+ create: Types.toTypeName(`${PascalCase}CreateDTO`),
253
+ update: Types.toTypeName(`${PascalCase}UpdateDTO`),
254
+ upsert: Types.toTypeName(`${PascalCase}UpsertDTO`),
255
+ },
185
256
  typeName: Types.toTypeName(`${PascalCase}`),
186
257
  linkedTypeName: Types.toTypeName(`${PascalCase}Linked`),
187
258
  typeDefFileName: Types.toFileName(`${camelCase}.type`),
@@ -23,6 +23,10 @@ export type SchemaConfig = {
23
23
  * If true, data module will not be generated.
24
24
  */
25
25
  data: boolean;
26
+ /**
27
+ * If true, actions module will not be generated.
28
+ */
29
+ actions: boolean;
26
30
  /**
27
31
  * If true, business logic module will not be generated.
28
32
  */
@@ -59,6 +63,13 @@ export type SchemaConfig = {
59
63
  * Path to the directory containing Cypress project.
60
64
  */
61
65
  cypressPath: Types.Path;
66
+ /**
67
+ * Path to the directory containing actions.
68
+ *
69
+ * NOTE: Metadata assumes that project is set up so that certain parts of the code
70
+ * may reference actions using `@project/actions` import.
71
+ */
72
+ actionsPath: Types.Path;
62
73
  /**
63
74
  * Path to the directory containing business logic.
64
75
  *
@@ -67,12 +78,19 @@ export type SchemaConfig = {
67
78
  */
68
79
  businessLogicPath: Types.Path;
69
80
  /**
70
- * Path to the directory containing mock data samples.
81
+ * Path to the directory containing seed module.
71
82
  *
72
83
  * NOTE: Metadata assumes that project is set up so that certain parts of the code
73
84
  * may reference mock data using `@project/seed` import.
74
85
  */
75
- seedPath: Types.Path;
86
+ seedLibPath: Types.Path;
87
+ /**
88
+ * Path to the directory containing mock data samples.
89
+ *
90
+ * NOTE: Metadata assumes that project is set up so that certain parts of the code
91
+ * may reference mock data using `@project/seed-data` import.
92
+ */
93
+ seedDataPath: Types.Path;
76
94
  /**
77
95
  * Path to the directory containing React components.
78
96
  *
@@ -89,14 +107,14 @@ export type SchemaConfig = {
89
107
  */
90
108
  migrationsFolderPath: Types.Path;
91
109
  };
92
- /**
93
- * Seed to use for random generation.
94
- */
95
- randomSeed: number;
96
110
  /**
97
111
  * Whether the generator should overwrite existing files.
98
112
  */
99
113
  force: boolean;
114
+ /**
115
+ * Name of the User type
116
+ */
117
+ userType: Types.TypeName;
100
118
  };
101
119
  export type Model = Prettify<ModelCore & ModelFields>;
102
120
  /**
@@ -70,3 +70,7 @@ export type Path = string & {
70
70
  * Converts a string to a branded FileName.
71
71
  */
72
72
  export declare const toPath: (t: string) => Path;
73
+ /**
74
+ * Branded string values that can be used as import statement values in the generators
75
+ */
76
+ export type ImportableTypes = Fnction | ClassName | TypeName | VariableName;
@@ -1,4 +1,4 @@
1
1
  /**
2
2
  * Returns a string of JSDoc comments from an array of lines.
3
3
  */
4
- export declare function jsDocComment(lines: string[]): string;
4
+ export declare function toJsDocComment(comments: string[] | undefined): string;