@my-devkit/core 1.0.89 → 1.0.91

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.
@@ -0,0 +1,9 @@
1
+ import { Document } from './document';
2
+ import { Event } from './event';
3
+ export declare abstract class Aggregate implements Document {
4
+ id: string;
5
+ _type: string;
6
+ constructor();
7
+ get _path(): string;
8
+ apply<E extends Event>(event: E): void;
9
+ }
@@ -0,0 +1,45 @@
1
+ "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
8
+ var __metadata = (this && this.__metadata) || function (k, v) {
9
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.Aggregate = void 0;
13
+ var serialize_1 = require("./serialize");
14
+ var Aggregate = /** @class */ (function () {
15
+ function Aggregate() {
16
+ this.id = null;
17
+ this._type = null;
18
+ this._type = this.constructor.name;
19
+ }
20
+ Object.defineProperty(Aggregate.prototype, "_path", {
21
+ get: function () {
22
+ return "/aggregates/".concat(this.id);
23
+ },
24
+ enumerable: false,
25
+ configurable: true
26
+ });
27
+ Aggregate.prototype.apply = function (event) {
28
+ var methodName = "apply".concat(event._type);
29
+ if (!(methodName in this)) {
30
+ throw new Error("".concat(this._type, ".").concat(methodName, " method is missing!"));
31
+ }
32
+ this[methodName](event);
33
+ };
34
+ __decorate([
35
+ (0, serialize_1.autoserializeAs)(String),
36
+ __metadata("design:type", String)
37
+ ], Aggregate.prototype, "id", void 0);
38
+ __decorate([
39
+ (0, serialize_1.autoserializeAs)(String),
40
+ __metadata("design:type", String)
41
+ ], Aggregate.prototype, "_type", void 0);
42
+ return Aggregate;
43
+ }());
44
+ exports.Aggregate = Aggregate;
45
+ //# sourceMappingURL=aggregate.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"aggregate.js","sourceRoot":"","sources":["../src/aggregate.ts"],"names":[],"mappings":";;;;;;;;;;;;AAEA,yCAA8C;AAE9C;IAII;QAHgC,OAAE,GAAW,IAAI,CAAC;QAClB,UAAK,GAAW,IAAI,CAAC;QAGjD,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC;IACvC,CAAC;IAED,sBAAW,4BAAK;aAAhB;YACI,OAAO,sBAAe,IAAI,CAAC,EAAE,CAAE,CAAC;QACpC,CAAC;;;OAAA;IAEM,yBAAK,GAAZ,UAA8B,KAAQ;QAClC,IAAM,UAAU,GAAG,eAAQ,KAAK,CAAC,KAAK,CAAE,CAAC;QACzC,IAAI,CAAC,CAAC,UAAU,IAAI,IAAI,CAAC,EAAE;YACvB,MAAM,IAAI,KAAK,CAAC,UAAG,IAAI,CAAC,KAAK,cAAI,UAAU,wBAAqB,CAAC,CAAC;SACrE;QAED,IAAI,CAAC,UAAU,CAAC,CAAC,KAAK,CAAC,CAAC;IAC5B,CAAC;IAlBD;QAAC,IAAA,2BAAe,EAAC,MAAM,CAAC;;yCAA0B;IAClD;QAAC,IAAA,2BAAe,EAAC,MAAM,CAAC;;4CAA6B;IAkBzD,gBAAC;CAAA,AApBD,IAoBC;AApBqB,8BAAS"}
package/dist/index.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  import * as validators from './validators';
2
+ export * from './aggregate';
2
3
  export * from './command';
3
4
  export * from './date-helper';
4
5
  export * from './decorators';
package/dist/index.js CHANGED
@@ -16,6 +16,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
17
  exports.Validators = exports.ValidationError = void 0;
18
18
  var validators = require("./validators");
19
+ __exportStar(require("./aggregate"), exports);
19
20
  __exportStar(require("./command"), exports);
20
21
  __exportStar(require("./date-helper"), exports);
21
22
  __exportStar(require("./decorators"), exports);
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,yCAA2C;AAE3C,4CAA0B;AAC1B,gDAA8B;AAC9B,+CAA6B;AAC7B,6CAA2B;AAC3B,gDAA8B;AAC9B,2CAAyB;AACzB,0CAAwB;AACxB,yCAAuB;AACvB,2CAAyB;AACzB,sDAAoC;AACpC,0CAAwB;AACxB,mDAAiC;AACjC,kDAAgC;AAChC,0CAAwB;AACxB,6DAA2C;AAC3C,8CAA4B;AAC5B,0CAAwB;AACxB,kEAAgE;AAAvD,mHAAA,eAAe,OAAA;AACxB,4CAA0B;AAEb,QAAA,UAAU,GAAG,UAAU,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,yCAA2C;AAE3C,8CAA4B;AAC5B,4CAA0B;AAC1B,gDAA8B;AAC9B,+CAA6B;AAC7B,6CAA2B;AAC3B,gDAA8B;AAC9B,2CAAyB;AACzB,0CAAwB;AACxB,yCAAuB;AACvB,2CAAyB;AACzB,sDAAoC;AACpC,0CAAwB;AACxB,mDAAiC;AACjC,kDAAgC;AAChC,0CAAwB;AACxB,6DAA2C;AAC3C,8CAA4B;AAC5B,0CAAwB;AACxB,kEAAgE;AAAvD,mHAAA,eAAe,OAAA;AACxB,4CAA0B;AAEb,QAAA,UAAU,GAAG,UAAU,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@my-devkit/core",
3
- "version": "1.0.89",
3
+ "version": "1.0.91",
4
4
  "description": "My Devkit: common tools",
5
5
  "main": "dist/index.js",
6
6
  "typings": "dist/index.d.ts",
@@ -24,7 +24,7 @@
24
24
  },
25
25
  "peerDependencies": {},
26
26
  "devDependencies": {
27
- "@my-devkit/cli": "1.0.25",
27
+ "@my-devkit/cli": "1.0.26",
28
28
  "@types/lodash": "4.14.173",
29
29
  "@types/node": "^14.14.19",
30
30
  "@typescript-eslint/eslint-plugin": "4.22.1",
@@ -0,0 +1,25 @@
1
+ import { Document } from './document';
2
+ import { Event } from './event';
3
+ import { autoserializeAs } from './serialize';
4
+
5
+ export abstract class Aggregate implements Document {
6
+ @autoserializeAs(String) public id: string = null;
7
+ @autoserializeAs(String) public _type: string = null;
8
+
9
+ public constructor() {
10
+ this._type = this.constructor.name;
11
+ }
12
+
13
+ public get _path(): string {
14
+ return `/aggregates/${this.id}`;
15
+ }
16
+
17
+ public apply<E extends Event>(event: E): void {
18
+ const methodName = `apply${event._type}`;
19
+ if (!(methodName in this)) {
20
+ throw new Error(`${this._type}.${methodName} method is missing!`);
21
+ }
22
+
23
+ this[methodName](event);
24
+ }
25
+ }
package/src/index.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  import * as validators from './validators';
2
2
 
3
+ export * from './aggregate';
3
4
  export * from './command';
4
5
  export * from './date-helper';
5
6
  export * from './decorators';