@volontariapp/database 3.2.4 → 3.2.6

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/CHANGELOG.md CHANGED
@@ -1,5 +1,18 @@
1
1
  # Changelog
2
2
 
3
+ ## 3.2.6
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies []:
8
+ - @volontariapp/messaging@2.5.2
9
+
10
+ ## 3.2.5
11
+
12
+ ### Patch Changes
13
+
14
+ - feat(database): static creation of event
15
+
3
16
  ## 3.2.4
4
17
 
5
18
  ### Patch Changes
@@ -10,5 +10,13 @@ export declare class EventQueueEntity<K extends EventType = EventType, P = Event
10
10
  after: P;
11
11
  };
12
12
  processedAt?: Date;
13
+ static createEvent<K extends EventType = EventType>(props: {
14
+ type: K;
15
+ emitter: string;
16
+ emitterId: string;
17
+ traceId?: string;
18
+ payload: EventPayload<K>;
19
+ targetServices: Streams[];
20
+ }): EventQueueEntity<K>;
13
21
  }
14
22
  //# sourceMappingURL=event-queue.entity.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"event-queue.entity.d.ts","sourceRoot":"","sources":["../../../src/outbox/entities/event-queue.entity.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAC;AACjE,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AACxD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAEpD,qBAAa,gBAAgB,CAC3B,CAAC,SAAS,SAAS,GAAG,SAAS,EAC/B,CAAC,GAAG,YAAY,CAAC,CAAC,CAAC,CACnB,SAAQ,YAAY,CAAC,CAAC,CAAC;IACvB,OAAO,EAAG,MAAM,CAAC;IAEjB,cAAc,EAAE,OAAO,EAAE,CAAM;IAE/B,OAAO,EAAG;QACR,MAAM,CAAC,EAAE,CAAC,CAAC;QACX,KAAK,EAAE,CAAC,CAAC;KACV,CAAC;IAEF,WAAW,CAAC,EAAE,IAAI,CAAC;CACpB"}
1
+ {"version":3,"file":"event-queue.entity.d.ts","sourceRoot":"","sources":["../../../src/outbox/entities/event-queue.entity.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAC;AACjE,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AACxD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAIpD,qBAAa,gBAAgB,CAC3B,CAAC,SAAS,SAAS,GAAG,SAAS,EAC/B,CAAC,GAAG,YAAY,CAAC,CAAC,CAAC,CACnB,SAAQ,YAAY,CAAC,CAAC,CAAC;IACvB,OAAO,EAAG,MAAM,CAAC;IAEjB,cAAc,EAAE,OAAO,EAAE,CAAM;IAE/B,OAAO,EAAG;QACR,MAAM,CAAC,EAAE,CAAC,CAAC;QACX,KAAK,EAAE,CAAC,CAAC;KACV,CAAC;IAEF,WAAW,CAAC,EAAE,IAAI,CAAC;IAEnB,MAAM,CAAC,WAAW,CAAC,CAAC,SAAS,SAAS,GAAG,SAAS,EAAE,KAAK,EAAE;QACzD,IAAI,EAAE,CAAC,CAAC;QACR,OAAO,EAAE,MAAM,CAAC;QAChB,SAAS,EAAE,MAAM,CAAC;QAClB,OAAO,CAAC,EAAE,MAAM,CAAC;QACjB,OAAO,EAAE,YAAY,CAAC,CAAC,CAAC,CAAC;QACzB,cAAc,EAAE,OAAO,EAAE,CAAC;KAC3B,GAAG,gBAAgB,CAAC,CAAC,CAAC;CAgBxB"}
@@ -1,8 +1,26 @@
1
1
  import { OutboxEntity } from './outbox.entity.js';
2
+ import { randomUUID } from 'crypto';
3
+ import { OutboxStatus } from '../types/outbox.status.js';
2
4
  export class EventQueueEntity extends OutboxEntity {
3
5
  version;
4
6
  targetServices = [];
5
7
  payload;
6
8
  processedAt;
9
+ static createEvent(props) {
10
+ const entity = new EventQueueEntity();
11
+ entity.id = randomUUID();
12
+ entity.type = props.type;
13
+ entity.emitter = props.emitter;
14
+ entity.emitterId = props.emitterId;
15
+ entity.traceId = props.traceId;
16
+ entity.payload = { after: props.payload };
17
+ entity.targetServices = props.targetServices;
18
+ entity.status = OutboxStatus.PENDING;
19
+ entity.attempts = 0;
20
+ entity.version = 1;
21
+ entity.createdAt = new Date();
22
+ entity.updatedAt = new Date();
23
+ return entity;
24
+ }
7
25
  }
8
26
  //# sourceMappingURL=event-queue.entity.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"event-queue.entity.js","sourceRoot":"","sources":["../../../src/outbox/entities/event-queue.entity.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAIlD,MAAM,OAAO,gBAGX,SAAQ,YAAe;IACvB,OAAO,CAAU;IAEjB,cAAc,GAAc,EAAE,CAAC;IAE/B,OAAO,CAGL;IAEF,WAAW,CAAQ;CACpB"}
1
+ {"version":3,"file":"event-queue.entity.js","sourceRoot":"","sources":["../../../src/outbox/entities/event-queue.entity.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAGlD,OAAO,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAC;AACpC,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAEzD,MAAM,OAAO,gBAGX,SAAQ,YAAe;IACvB,OAAO,CAAU;IAEjB,cAAc,GAAc,EAAE,CAAC;IAE/B,OAAO,CAGL;IAEF,WAAW,CAAQ;IAEnB,MAAM,CAAC,WAAW,CAAkC,KAOnD;QACC,MAAM,MAAM,GAAG,IAAI,gBAAgB,EAAK,CAAC;QACzC,MAAM,CAAC,EAAE,GAAG,UAAU,EAAE,CAAC;QACzB,MAAM,CAAC,IAAI,GAAG,KAAK,CAAC,IAAI,CAAC;QACzB,MAAM,CAAC,OAAO,GAAG,KAAK,CAAC,OAAO,CAAC;QAC/B,MAAM,CAAC,SAAS,GAAG,KAAK,CAAC,SAAS,CAAC;QACnC,MAAM,CAAC,OAAO,GAAG,KAAK,CAAC,OAAO,CAAC;QAC/B,MAAM,CAAC,OAAO,GAAG,EAAE,KAAK,EAAE,KAAK,CAAC,OAAO,EAAE,CAAC;QAC1C,MAAM,CAAC,cAAc,GAAG,KAAK,CAAC,cAAc,CAAC;QAC7C,MAAM,CAAC,MAAM,GAAG,YAAY,CAAC,OAAO,CAAC;QACrC,MAAM,CAAC,QAAQ,GAAG,CAAC,CAAC;QACpB,MAAM,CAAC,OAAO,GAAG,CAAC,CAAC;QACnB,MAAM,CAAC,SAAS,GAAG,IAAI,IAAI,EAAE,CAAC;QAC9B,MAAM,CAAC,SAAS,GAAG,IAAI,IAAI,EAAE,CAAC;QAC9B,OAAO,MAAM,CAAC;IAChB,CAAC;CACF"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@volontariapp/database",
3
- "version": "3.2.4",
3
+ "version": "3.2.6",
4
4
  "publishConfig": {
5
5
  "access": "public",
6
6
  "provenance": true
@@ -44,7 +44,7 @@
44
44
  "@volontariapp/config": "3.1.1",
45
45
  "@volontariapp/errors": "0.5.2",
46
46
  "@volontariapp/logger": "0.2.5",
47
- "@volontariapp/messaging": "2.5.1",
47
+ "@volontariapp/messaging": "2.5.2",
48
48
  "@volontariapp/shared": "0.5.2",
49
49
  "class-transformer": "^0.5.1",
50
50
  "class-validator": "^0.14.1",