@my-devkit/core 1.0.35 → 1.0.39

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,15 @@
1
+ import { Document } from './document';
2
+ export declare abstract class Event implements Document {
3
+ static counter: number;
4
+ id: string;
5
+ _type: string;
6
+ _correlationId: string;
7
+ _aggregateType: string;
8
+ _aggregateId: string;
9
+ _publishedBy: string;
10
+ private _publishedAt;
11
+ constructor();
12
+ get _path(): string;
13
+ get publishedAt(): Date;
14
+ set publishedAt(date: Date);
15
+ }
package/dist/event.js ADDED
@@ -0,0 +1,77 @@
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.Event = void 0;
13
+ var guid_1 = require("./guid");
14
+ var serialize_1 = require("./serialize");
15
+ var Event = /** @class */ (function () {
16
+ function Event() {
17
+ this.id = null;
18
+ this._type = null;
19
+ this._correlationId = null;
20
+ this._aggregateType = null;
21
+ this._aggregateId = null;
22
+ this._publishedBy = null;
23
+ this._publishedAt = null;
24
+ this.id = (0, guid_1.guid)();
25
+ this._type = this.constructor.name;
26
+ }
27
+ Object.defineProperty(Event.prototype, "_path", {
28
+ get: function () {
29
+ return "/events/".concat(this.id);
30
+ },
31
+ enumerable: false,
32
+ configurable: true
33
+ });
34
+ Object.defineProperty(Event.prototype, "publishedAt", {
35
+ get: function () {
36
+ return new Date(this._publishedAt.substr(0, 23) + 'Z');
37
+ },
38
+ set: function (date) {
39
+ Event.counter++;
40
+ this._publishedAt = date.toISOString().replace('Z', '.' + (('0'.repeat(9) + Event.counter).slice(-9))) + 'Z';
41
+ },
42
+ enumerable: false,
43
+ configurable: true
44
+ });
45
+ Event.counter = 0;
46
+ __decorate([
47
+ (0, serialize_1.autoserializeAs)(String),
48
+ __metadata("design:type", String)
49
+ ], Event.prototype, "id", void 0);
50
+ __decorate([
51
+ (0, serialize_1.autoserializeAs)(String),
52
+ __metadata("design:type", String)
53
+ ], Event.prototype, "_type", void 0);
54
+ __decorate([
55
+ (0, serialize_1.autoserializeAs)(String),
56
+ __metadata("design:type", String)
57
+ ], Event.prototype, "_correlationId", void 0);
58
+ __decorate([
59
+ (0, serialize_1.autoserializeAs)(String),
60
+ __metadata("design:type", String)
61
+ ], Event.prototype, "_aggregateType", void 0);
62
+ __decorate([
63
+ (0, serialize_1.autoserializeAs)(String),
64
+ __metadata("design:type", String)
65
+ ], Event.prototype, "_aggregateId", void 0);
66
+ __decorate([
67
+ (0, serialize_1.autoserializeAs)(String),
68
+ __metadata("design:type", String)
69
+ ], Event.prototype, "_publishedBy", void 0);
70
+ __decorate([
71
+ (0, serialize_1.autoserializeAs)(String),
72
+ __metadata("design:type", String)
73
+ ], Event.prototype, "_publishedAt", void 0);
74
+ return Event;
75
+ }());
76
+ exports.Event = Event;
77
+ //# sourceMappingURL=event.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"event.js","sourceRoot":"","sources":["../src/event.ts"],"names":[],"mappings":";;;;;;;;;;;;AACA,+BAA8B;AAC9B,yCAA8C;AAE9C;IAUI;QARgC,OAAE,GAAW,IAAI,CAAC;QAClB,UAAK,GAAW,IAAI,CAAC;QACrB,mBAAc,GAAW,IAAI,CAAC;QAC9B,mBAAc,GAAW,IAAI,CAAC;QAC9B,iBAAY,GA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AAK"}
package/dist/index.d.ts CHANGED
@@ -2,6 +2,7 @@ import * as validators from './validators';
2
2
  export * from './decorators';
3
3
  export * from './document';
4
4
  export * from './command';
5
+ export * from './event';
5
6
  export * from './date-helper';
6
7
  export * from './enum-helper';
7
8
  export * from './errors';
package/dist/index.js CHANGED
@@ -15,6 +15,7 @@ var validators = require("./validators");
15
15
  __exportStar(require("./decorators"), exports);
16
16
  __exportStar(require("./document"), exports);
17
17
  __exportStar(require("./command"), exports);
18
+ __exportStar(require("./event"), exports);
18
19
  __exportStar(require("./date-helper"), exports);
19
20
  __exportStar(require("./enum-helper"), exports);
20
21
  __exportStar(require("./errors"), 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,+CAA6B;AAC7B,6CAA2B;AAC3B,4CAA0B;AAC1B,gDAA8B;AAC9B,gDAA8B;AAC9B,2CAAyB;AACzB,yCAAuB;AACvB,2CAAyB;AACzB,0CAAwB;AACxB,sDAAoC;AACpC,kDAAgC;AAChC,8CAA4B;AAC5B,0CAAwB;AACxB,0CAAwB;AACxB,4CAA0B;AACb,QAAA,UAAU,GAAG,UAAU,CAAC;AACrC,kEAAgE;AAAvD,mHAAA,eAAe,OAAA"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,yCAA2C;AAE3C,+CAA6B;AAC7B,6CAA2B;AAC3B,4CAA0B;AAC1B,0CAAwB;AACxB,gDAA8B;AAC9B,gDAA8B;AAC9B,2CAAyB;AACzB,yCAAuB;AACvB,2CAAyB;AACzB,0CAAwB;AACxB,sDAAoC;AACpC,kDAAgC;AAChC,8CAA4B;AAC5B,0CAAwB;AACxB,0CAAwB;AACxB,4CAA0B;AACb,QAAA,UAAU,GAAG,UAAU,CAAC;AACrC,kEAAgE;AAAvD,mHAAA,eAAe,OAAA"}
Binary file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@my-devkit/core",
3
- "version": "1.0.35",
3
+ "version": "1.0.39",
4
4
  "description": "My Devkit: common tools",
5
5
  "main": "dist/index.js",
6
6
  "typings": "dist/index.d.ts",
@@ -12,7 +12,6 @@
12
12
  "url": "https://github.com/BUONJG/my-devkit.git"
13
13
  },
14
14
  "scripts": {
15
- "preinstall": "npx only-allow pnpm",
16
15
  "clean": "pnpx ts-cleaner -d ./dist -s ./src || true",
17
16
  "build": "pnpm run clean && tsc",
18
17
  "watch": "pnpm run clean && tsc -w"
package/src/event.ts ADDED
@@ -0,0 +1,32 @@
1
+ import { Document } from './document';
2
+ import { guid } from './guid';
3
+ import { autoserializeAs } from './serialize';
4
+
5
+ export abstract class Event implements Document {
6
+ public static counter = 0;
7
+ @autoserializeAs(String) public id: string = null;
8
+ @autoserializeAs(String) public _type: string = null;
9
+ @autoserializeAs(String) public _correlationId: string = null;
10
+ @autoserializeAs(String) public _aggregateType: string = null;
11
+ @autoserializeAs(String) public _aggregateId: string = null;
12
+ @autoserializeAs(String) public _publishedBy: string = null;
13
+ @autoserializeAs(String) private _publishedAt: string = null;
14
+
15
+ constructor() {
16
+ this.id = guid();
17
+ this._type = this.constructor.name;
18
+ }
19
+
20
+ public get _path(): string {
21
+ return `/events/${this.id}`;
22
+ }
23
+
24
+ public get publishedAt(): Date {
25
+ return new Date(this._publishedAt.substr(0, 23) + 'Z');
26
+ }
27
+
28
+ public set publishedAt(date: Date) {
29
+ Event.counter++;
30
+ this._publishedAt = date.toISOString().replace('Z', '.' + (('0'.repeat(9) + Event.counter).slice(-9))) + 'Z';
31
+ }
32
+ }
package/src/index.ts CHANGED
@@ -3,6 +3,7 @@ import * as validators from './validators';
3
3
  export * from './decorators';
4
4
  export * from './document';
5
5
  export * from './command';
6
+ export * from './event';
6
7
  export * from './date-helper';
7
8
  export * from './enum-helper';
8
9
  export * from './errors';
Binary file