@wallentaine/cqrs-schematics 0.0.9 → 0.1.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/collection.json CHANGED
@@ -10,6 +10,11 @@
10
10
  "factory": "./lib/schematics/query",
11
11
  "schema": "./lib/schematics/query/schema.json",
12
12
  "description": "Generate CQRS Query files"
13
+ },
14
+ "event": {
15
+ "factory": "./lib/schematics/event",
16
+ "schema": "./lib/schematics/event/schema.json",
17
+ "description": "Generate CQRS Event files"
13
18
  }
14
19
  }
15
20
  }
@@ -0,0 +1,7 @@
1
+ import { QueryBase } from '@Libs/DDD/Query.base';
2
+
3
+ export class <%= className %>Query extends QueryBase {
4
+ public constructor(props: <%= className %>Query) {
5
+ super();
6
+ }
7
+ }
@@ -0,0 +1,12 @@
1
+ import { QueryHandler, IQueryHandler } from '@nestjs/cqrs';
2
+ import { <%= className %>Query } from './<%= name %>.query';
3
+
4
+ @QueryHandler(<%= className %>Query)
5
+ export class <%= className %>QueryHandler implements IQueryHandler<<%= className %>Query> {
6
+
7
+ public constructor() {}
8
+
9
+ async execute(query: <%= className %>Query): Promise<any> {
10
+ // Implement your query logic here
11
+ }
12
+ }
@@ -0,0 +1,4 @@
1
+ import { Rule } from "@angular-devkit/schematics";
2
+ import { Schema as CommandOptions } from "./schema";
3
+ export default function commandSchematic(options: CommandOptions): Rule;
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/schematics/event/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAMN,IAAI,EAIJ,MAAM,4BAA4B,CAAC;AAEpC,OAAO,EAAE,MAAM,IAAI,cAAc,EAAE,MAAM,UAAU,CAAC;AAEpD,MAAM,CAAC,OAAO,UAAU,gBAAgB,CAAC,OAAO,EAAE,cAAc,GAAG,IAAI,CAsBtE"}
@@ -0,0 +1,31 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.default = commandSchematic;
4
+ const schematics_1 = require("@angular-devkit/schematics");
5
+ const core_1 = require("@angular-devkit/core");
6
+ function commandSchematic(options) {
7
+ return (tree, context) => {
8
+ const classifiedName = core_1.strings.classify(options.name);
9
+ const modulePath = options.module ? `/${options.module}` : "";
10
+ const targetPath = `${options.path}${modulePath}/Events/${classifiedName}`;
11
+ const templateSource = (0, schematics_1.apply)((0, schematics_1.url)("./files"), [
12
+ (0, schematics_1.applyTemplates)({
13
+ ...core_1.strings,
14
+ ...options,
15
+ humanize,
16
+ name: classifiedName,
17
+ className: classifiedName,
18
+ }),
19
+ (0, schematics_1.move)(targetPath),
20
+ ]);
21
+ const rules = [(0, schematics_1.mergeWith)(templateSource)];
22
+ return (0, schematics_1.chain)(rules)(tree, context);
23
+ };
24
+ }
25
+ function humanize(str) {
26
+ return str
27
+ .replace(/([A-Z])/g, " $1")
28
+ .replace(/^./, (s) => s.toUpperCase())
29
+ .replace(/(Create|Update|Delete)/, "$1 ")
30
+ .trim();
31
+ }
@@ -0,0 +1,16 @@
1
+ export interface Schema {
2
+ /** Имя команды (например: CreatePost) */
3
+ name: string;
4
+ /** Модуль, в который добавить команду */
5
+ module: string;
6
+ /** Путь для генерации */
7
+ path?: string;
8
+ /** Пропустить импорт в модуль */
9
+ skipImport?: boolean;
10
+ /** Плоская структура файлов */
11
+ flat?: boolean;
12
+ /** Специфические для команды свойства */
13
+ hasDto?: boolean;
14
+ hasResponse?: boolean;
15
+ }
16
+ //# sourceMappingURL=schema.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../../src/schematics/event/schema.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,MAAM;IACtB,yCAAyC;IACzC,IAAI,EAAE,MAAM,CAAC;IAEb,yCAAyC;IACzC,MAAM,EAAE,MAAM,CAAC;IAEf,yBAAyB;IACzB,IAAI,CAAC,EAAE,MAAM,CAAC;IAEd,iCAAiC;IACjC,UAAU,CAAC,EAAE,OAAO,CAAC;IAErB,+BAA+B;IAC/B,IAAI,CAAC,EAAE,OAAO,CAAC;IAEf,yCAAyC;IACzC,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,WAAW,CAAC,EAAE,OAAO,CAAC;CACtB"}
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,38 @@
1
+ {
2
+ "$schema": "http://json-schema.org/schema",
3
+ "$id": "CqrsEvent",
4
+ "title": "CQRS Event Schematic",
5
+ "type": "object",
6
+ "properties": {
7
+ "name": {
8
+ "type": "string",
9
+ "description": "The name of the event",
10
+ "$default": {
11
+ "$source": "argv",
12
+ "index": 0
13
+ },
14
+ "x-prompt": "What name would you like to use for the Event?"
15
+ },
16
+ "module": {
17
+ "type": "string",
18
+ "description": "Module name",
19
+ "$default": {
20
+ "$source": "argv",
21
+ "index": 1
22
+ },
23
+ "x-prompt": "What name would you like to use for the Module?"
24
+ },
25
+ "path": {
26
+ "type": "string",
27
+ "description": "The path where to create the files",
28
+ "default": "src"
29
+ },
30
+ "prefix": {
31
+ "type": "string",
32
+ "description": "Command prefix (Create, Update, Delete)",
33
+ "default": "Create",
34
+ "x-prompt": "What prefix would you like to use? (Create, Update, Delete)"
35
+ }
36
+ },
37
+ "required": ["name", "module", "useSwagger"]
38
+ }
@@ -6,12 +6,12 @@
6
6
  "properties": {
7
7
  "name": {
8
8
  "type": "string",
9
- "description": "The name of the command",
9
+ "description": "The name of the query",
10
10
  "$default": {
11
11
  "$source": "argv",
12
12
  "index": 0
13
13
  },
14
- "x-prompt": "What name would you like to use for the Command?"
14
+ "x-prompt": "What name would you like to use for the Query?"
15
15
  },
16
16
  "module": {
17
17
  "type": "string",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wallentaine/cqrs-schematics",
3
- "version": "0.0.9",
3
+ "version": "0.1.0",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "scripts": {