@alevnyacow/nzmt 0.4.0 → 0.5.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/bin/cli.js CHANGED
@@ -127,10 +127,12 @@ function initDI() {
127
127
  "",
128
128
  "type DIEntries = Record<",
129
129
  "\tstring,",
130
+ "\t| { constantValue: object }",
130
131
  "\t| (new (...args: any[]) => any)",
131
132
  "\t| Record<'test' | 'dev' | 'prod',",
132
133
  "\t\t| [new (...args: any[]) => any, (x: BindInWhenOnFluentSyntax<unknown>) => any]",
133
134
  "\t\t| (new (...args: any[]) => any)",
135
+ "\t\t| { constantValue: object }",
134
136
  "\t>",
135
137
  ">",
136
138
  "",
@@ -154,6 +156,10 @@ function initDI() {
154
156
  "",
155
157
  "for (const rule in diEntries) {",
156
158
  "\tconst ruleContentRaw = diEntries[rule as keyof typeof diEntries]",
159
+ "\tif ('constantValue' in ruleContentRaw) {",
160
+ "\t\tcontainer.bind(rule).toConstantValue(ruleContentRaw.constantValue)",
161
+ "\t\tcontinue",
162
+ "\t}",
157
163
  "\tconst ruleContent =",
158
164
  "\t\ttypeof ruleContentRaw === 'object'",
159
165
  "\t\t\t? ruleContentRaw.dev",
@@ -163,6 +169,10 @@ function initDI() {
163
169
  "\t\tbuilder(container.bind(rule).to(Entry))",
164
170
  "\t\tcontinue",
165
171
  "\t}",
172
+ "\tif ('constantValue' in ruleContent) {",
173
+ "\t\tcontainer.bind(rule).toConstantValue(ruleContent.constantValue)",
174
+ "\t\tcontinue",
175
+ "\t}",
166
176
  "\tcontainer.bind(rule).to(ruleContent)",
167
177
  "}",
168
178
  "",
@@ -177,6 +187,10 @@ function initDI() {
177
187
  "",
178
188
  "for (const rule in diEntries) {",
179
189
  "\tconst ruleContentRaw = diEntries[rule as keyof typeof diEntries]",
190
+ "\tif ('constantValue' in ruleContentRaw) {",
191
+ "\t\tcontainer.bind(rule).toConstantValue(ruleContentRaw.constantValue)",
192
+ "\t\tcontinue",
193
+ "\t}",
180
194
  "\tconst ruleContent =",
181
195
  "\t\ttypeof ruleContentRaw === 'object'",
182
196
  "\t\t\t? ruleContentRaw.test",
@@ -186,6 +200,10 @@ function initDI() {
186
200
  "\t\tbuilder(container.bind(rule).to(Entry))",
187
201
  "\t\tcontinue",
188
202
  "\t}",
203
+ "\tif ('constantValue' in ruleContent) {",
204
+ "\t\tcontainer.bind(rule).toConstantValue(ruleContent.constantValue)",
205
+ "\t\tcontinue",
206
+ "\t}",
189
207
  "\tcontainer.bind(rule).to(ruleContent)",
190
208
  "}",
191
209
  "",
@@ -200,6 +218,10 @@ function initDI() {
200
218
  "",
201
219
  "for (const rule in diEntries) {",
202
220
  "\tconst ruleContentRaw = diEntries[rule as keyof typeof diEntries]",
221
+ "\tif ('constantValue' in ruleContentRaw) {",
222
+ "\t\tcontainer.bind(rule).toConstantValue(ruleContentRaw.constantValue)",
223
+ "\t\tcontinue",
224
+ "\t}",
203
225
  "\tconst ruleContent =",
204
226
  "\t\ttypeof ruleContentRaw === 'object'",
205
227
  "\t\t\t? ruleContentRaw.prod",
@@ -209,6 +231,10 @@ function initDI() {
209
231
  "\t\tbuilder(container.bind(rule).to(Entry))",
210
232
  "\t\tcontinue",
211
233
  "\t}",
234
+ "\tif ('constantValue' in ruleContent) {",
235
+ "\t\tcontainer.bind(rule).toConstantValue(ruleContent.constantValue)",
236
+ "\t\tcontinue",
237
+ "\t}",
212
238
  "\tcontainer.bind(rule).to(ruleContent)",
213
239
  "}",
214
240
  "",
@@ -445,13 +471,13 @@ function generateEntity(upperCase) {
445
471
 
446
472
  const body = [
447
473
  "import z from 'zod'",
448
- "import { Entities } from '@alevnyacow/nzmt'",
474
+ "import { ValueObjects } from '@alevnyacow/nzmt'",
449
475
  "",
450
476
  `export type ${upperCase}Model = z.infer<typeof ${upperCase}.schema>`,
451
477
  "",
452
478
  `export class ${upperCase} {`,
453
479
  "\tstatic schema = z.object({",
454
- "\t\tid: Entities.Identifier.schema,",
480
+ "\t\tid: ValueObjects.Identifier.schema,",
455
481
  fields.length ?
456
482
  fields.map(([fieldName, description]) => {
457
483
  return `\t\t${fieldName}: z.${description.split('.').join('().')}(),`
@@ -602,7 +628,7 @@ function generateService(lowerCase, upperCase, withCrud) {
602
628
  // Metadata
603
629
  if (withCrud) {
604
630
  fs.writeFileSync(path.resolve(folder, `${entityName}.service.metadata.ts`), [
605
- "import { type Module, Entities } from '@alevnyacow/nzmt'",
631
+ "import { type Module, ValueObjects } from '@alevnyacow/nzmt'",
606
632
  "import z from 'zod'",
607
633
  `import { ${lowerCase}StoreMetadata } from '${config?.paths?.stores?.replace('./src', '@')}/${entityName}'`,
608
634
  "",
@@ -620,7 +646,7 @@ function generateService(lowerCase, upperCase, withCrud) {
620
646
  `\t\tgetList: {`,
621
647
  `\t\t\tpayload: z.object({`,
622
648
  `\t\t\t\tfilter: ${lowerCase}StoreMetadata.searchPayload.list,`,
623
- `\t\t\t\tpagination: Entities.Pagination.schema.optional()`,
649
+ `\t\t\t\tpagination: ValueObjects.Pagination.schema.optional()`,
624
650
  `\t\t\t}),`,
625
651
  `\t\t\tresponse: z.object({`,
626
652
  `\t\t\t\titems: z.array(${lowerCase}StoreMetadata.models.list)`,
@@ -638,7 +664,7 @@ function generateService(lowerCase, upperCase, withCrud) {
638
664
  `\t\t\t\tpayload: ${lowerCase}StoreMetadata.actionsPayload.create`,
639
665
  `\t\t\t}),`,
640
666
  `\t\t\tresponse: z.object({`,
641
- `\t\t\t\tid: Entities.Identifier.schema`,
667
+ `\t\t\t\tid: ValueObjects.Identifier.schema`,
642
668
  `\t\t\t}),`,
643
669
  `\t\t},`,
644
670
  `\t\tdeleteOne: {`,
package/dist/index.cjs CHANGED
@@ -36,7 +36,7 @@ __webpack_require__.d(__webpack_exports__, {
36
36
  Controller: ()=>zod_controller_utils_namespaceObject,
37
37
  Store: ()=>store_namespaceObject,
38
38
  Module: ()=>zod_module_utils_namespaceObject,
39
- Entities: ()=>entities_namespaceObject
39
+ ValueObjects: ()=>entities_namespaceObject
40
40
  });
41
41
  var zod_module_utils_namespaceObject = {};
42
42
  __webpack_require__.r(zod_module_utils_namespaceObject);
@@ -540,14 +540,14 @@ class Identifier {
540
540
  }
541
541
  }
542
542
  exports.Controller = __webpack_exports__.Controller;
543
- exports.Entities = __webpack_exports__.Entities;
544
543
  exports.Module = __webpack_exports__.Module;
545
544
  exports.Store = __webpack_exports__.Store;
545
+ exports.ValueObjects = __webpack_exports__.ValueObjects;
546
546
  for(var __rspack_i in __webpack_exports__)if (-1 === [
547
547
  "Controller",
548
- "Entities",
549
548
  "Module",
550
- "Store"
549
+ "Store",
550
+ "ValueObjects"
551
551
  ].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
552
552
  Object.defineProperty(exports, '__esModule', {
553
553
  value: true
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
1
  export * as Module from './zod-module.utils';
2
2
  export * as Controller from './zod-controller.utils';
3
3
  export * as Store from './store';
4
- export * as Entities from './entities';
4
+ export * as ValueObjects from './entities';
package/dist/index.js CHANGED
@@ -499,4 +499,4 @@ class Identifier {
499
499
  return zod.uuidv4().safeParse(this.data).success;
500
500
  }
501
501
  }
502
- export { entities_namespaceObject as Entities, store_namespaceObject as Store, zod_controller_utils_namespaceObject as Controller, zod_module_utils_namespaceObject as Module };
502
+ export { entities_namespaceObject as ValueObjects, store_namespaceObject as Store, zod_controller_utils_namespaceObject as Controller, zod_module_utils_namespaceObject as Module };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@alevnyacow/nzmt",
3
- "version": "0.4.0",
3
+ "version": "0.5.1",
4
4
  "description": "Next Zod Modules Toolkit",
5
5
  "repository": {
6
6
  "type": "git",