@alevnyacow/nzmt 0.3.0 → 0.3.2

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 (3) hide show
  1. package/README.md +35 -0
  2. package/bin/cli.js +6 -6
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -128,6 +128,41 @@ const { result } = mathService.basicOperation({
128
128
 
129
129
  Desribes module metadata. Metadata is used as an argument in `methods`.
130
130
 
131
+ ### DTOs
132
+
133
+ Extracts all request and response DTOs for every method by `Metadata`.
134
+
135
+ Example:
136
+
137
+ ```ts
138
+ import { Module } from '@alevnyacow/nzmt'
139
+
140
+ const testMetadata = {
141
+ name: 'TestService',
142
+ schemas: {
143
+ testMethod: {
144
+ payload: z.object({
145
+ stringField: z.string()
146
+ }),
147
+ response: z.object({
148
+ result: z.boolean()
149
+ })
150
+ },
151
+ }
152
+ } satisfies Module.Metadata
153
+
154
+ type TestServiceDTOs = Module.DTOs<typeof testMetadata>
155
+
156
+ /**
157
+ * TestServiceDTOs:
158
+ * {
159
+ * testMethodPayload: { stringField: string }
160
+ * testMethodResponse: { result: boolean }
161
+ * }
162
+ *
163
+ */
164
+ ```
165
+
131
166
  ## <a id='controller'></a>Controller
132
167
 
133
168
  ## <a id='store'></a>Store
package/bin/cli.js CHANGED
@@ -241,7 +241,7 @@ function initDI() {
241
241
  ].join('\n'))
242
242
  };
243
243
 
244
- if (command === 'init') {
244
+ if (command.toLowerCase() === 'init' || command === 'i') {
245
245
  createDefaultConfig()
246
246
  initDI()
247
247
  process.exit(0)
@@ -431,7 +431,7 @@ function generateStores(lowerCase, upperCase, withEntityPreset) {
431
431
 
432
432
  }
433
433
 
434
- if (command === 'store') {
434
+ if (command.toLowerCase() === 'store' || command === 's') {
435
435
  var [lowerCase, upperCase] = camelizeVariants(entityName)
436
436
  generateStores(lowerCase, upperCase)
437
437
  process.exit(0);
@@ -476,7 +476,7 @@ function generateEntity(upperCase) {
476
476
  fs.writeFileSync(path.resolve(folder, 'index.ts'), `export * from './${entityName}.entity'`)
477
477
  }
478
478
 
479
- if (command === 'entity') {
479
+ if (command.toLowerCase() === 'entity' || command === 'e') {
480
480
  var [lowerCase, upperCase] = camelizeVariants(entityName)
481
481
  generateEntity(upperCase)
482
482
  process.exit(0)
@@ -519,7 +519,7 @@ function generateValueObject(upperCase) {
519
519
  fs.writeFileSync(path.resolve(folder, 'index.ts'), `export * from './${entityName}.value-object'`)
520
520
  }
521
521
 
522
- if (command === 'value-object') {
522
+ if (command.toLowerCase() === 'value-object' || command === 'vo') {
523
523
  var [lowerCase, upperCase] = camelizeVariants(entityName)
524
524
  generateValueObject(upperCase)
525
525
  process.exit(0)
@@ -675,13 +675,13 @@ function generateService(lowerCase, upperCase, withCrud) {
675
675
  )
676
676
  }
677
677
 
678
- if (command === 'service') {
678
+ if (command.toLowerCase() === 'service' || command === 'S') {
679
679
  var [lowerCase, upperCase] = camelizeVariants(entityName)
680
680
  generateService(lowerCase, upperCase, false)
681
681
  process.exit(0)
682
682
  }
683
683
 
684
- if (command === 'crud') {
684
+ if (command.toLowerCase() === 'crud') {
685
685
  var [lowerCase, upperCase] = camelizeVariants(entityName)
686
686
  generateEntity(upperCase)
687
687
  generateStores(lowerCase, upperCase, true)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@alevnyacow/nzmt",
3
- "version": "0.3.0",
3
+ "version": "0.3.2",
4
4
  "description": "Next Zod Modules Toolkit",
5
5
  "repository": {
6
6
  "type": "git",