@sphereon/ssi-sdk.data-store 0.19.1-next.24 → 0.19.1-next.75

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.
Files changed (58) hide show
  1. package/dist/entities/machineState/MachineStateInfoEntity.d.ts +33 -0
  2. package/dist/entities/machineState/MachineStateInfoEntity.d.ts.map +1 -0
  3. package/dist/entities/machineState/MachineStateInfoEntity.js +85 -0
  4. package/dist/entities/machineState/MachineStateInfoEntity.js.map +1 -0
  5. package/dist/index.d.ts +7 -3
  6. package/dist/index.d.ts.map +1 -1
  7. package/dist/index.js +11 -2
  8. package/dist/index.js.map +1 -1
  9. package/dist/machineState/IAbstractMachineStateStore.d.ts +52 -0
  10. package/dist/machineState/IAbstractMachineStateStore.d.ts.map +1 -0
  11. package/dist/machineState/IAbstractMachineStateStore.js +13 -0
  12. package/dist/machineState/IAbstractMachineStateStore.js.map +1 -0
  13. package/dist/machineState/MachineStateStore.d.ts +21 -0
  14. package/dist/machineState/MachineStateStore.d.ts.map +1 -0
  15. package/dist/machineState/MachineStateStore.js +137 -0
  16. package/dist/machineState/MachineStateStore.js.map +1 -0
  17. package/dist/migrations/generic/7-CreateMachineStateStore.d.ts +7 -0
  18. package/dist/migrations/generic/7-CreateMachineStateStore.d.ts.map +1 -0
  19. package/dist/migrations/generic/7-CreateMachineStateStore.js +78 -0
  20. package/dist/migrations/generic/7-CreateMachineStateStore.js.map +1 -0
  21. package/dist/migrations/generic/index.d.ts +2 -0
  22. package/dist/migrations/generic/index.d.ts.map +1 -1
  23. package/dist/migrations/generic/index.js +4 -1
  24. package/dist/migrations/generic/index.js.map +1 -1
  25. package/dist/migrations/index.d.ts +1 -1
  26. package/dist/migrations/index.d.ts.map +1 -1
  27. package/dist/migrations/index.js +2 -1
  28. package/dist/migrations/index.js.map +1 -1
  29. package/dist/migrations/postgres/1708797018115-CreateMachineStateStore.d.ts +7 -0
  30. package/dist/migrations/postgres/1708797018115-CreateMachineStateStore.d.ts.map +1 -0
  31. package/dist/migrations/postgres/1708797018115-CreateMachineStateStore.js +45 -0
  32. package/dist/migrations/postgres/1708797018115-CreateMachineStateStore.js.map +1 -0
  33. package/dist/migrations/sqlite/1708796002272-CreateMachineStateStore.d.ts +7 -0
  34. package/dist/migrations/sqlite/1708796002272-CreateMachineStateStore.d.ts.map +1 -0
  35. package/dist/migrations/sqlite/1708796002272-CreateMachineStateStore.js +44 -0
  36. package/dist/migrations/sqlite/1708796002272-CreateMachineStateStore.js.map +1 -0
  37. package/dist/types/index.d.ts +1 -0
  38. package/dist/types/index.d.ts.map +1 -1
  39. package/dist/types/index.js +1 -0
  40. package/dist/types/index.js.map +1 -1
  41. package/dist/types/machineState/IAbstractMachineStateStore.d.ts +58 -0
  42. package/dist/types/machineState/IAbstractMachineStateStore.d.ts.map +1 -0
  43. package/dist/types/machineState/IAbstractMachineStateStore.js +3 -0
  44. package/dist/types/machineState/IAbstractMachineStateStore.js.map +1 -0
  45. package/package.json +4 -4
  46. package/src/__tests__/machineState.entities.test.ts +51 -0
  47. package/src/__tests__/machineState.store.test.ts +174 -0
  48. package/src/entities/machineState/MachineStateInfoEntity.ts +58 -0
  49. package/src/index.ts +9 -0
  50. package/src/machineState/IAbstractMachineStateStore.ts +65 -0
  51. package/src/machineState/MachineStateStore.ts +151 -0
  52. package/src/migrations/generic/7-CreateMachineStateStore.ts +66 -0
  53. package/src/migrations/generic/index.ts +3 -0
  54. package/src/migrations/index.ts +1 -0
  55. package/src/migrations/postgres/1708797018115-CreateMachineStateStore.ts +29 -0
  56. package/src/migrations/sqlite/1708796002272-CreateMachineStateStore.ts +28 -0
  57. package/src/types/index.ts +1 -0
  58. package/src/types/machineState/IAbstractMachineStateStore.ts +68 -0
@@ -3,6 +3,7 @@ import { CreateIssuanceBranding1659463079429 } from './2-CreateIssuanceBranding'
3
3
  import { CreateStatusList1693866470000 } from './4-CreateStatusList';
4
4
  import { CreateAuditEvents1701635835330 } from './5-CreateAuditEvents';
5
5
  import { CreateDigitalCredential1708525189000 } from './6-CreateDigitalCredential';
6
+ import { CreateMachineStateStore1708098041262 } from './7-CreateMachineStateStore';
6
7
  /**
7
8
  * The migrations array that SHOULD be used when initializing a TypeORM database connection.
8
9
  *
@@ -15,5 +16,6 @@ export declare const DataStoreIssuanceBrandingMigrations: (typeof CreateIssuance
15
16
  export declare const DataStoreStatusListMigrations: (typeof CreateStatusList1693866470000)[];
16
17
  export declare const DataStoreEventLoggerMigrations: (typeof CreateAuditEvents1701635835330)[];
17
18
  export declare const DataStoreDigitalCredentialMigrations: (typeof CreateDigitalCredential1708525189000)[];
19
+ export declare const DataStoreMachineStateMigrations: (typeof CreateMachineStateStore1708098041262)[];
18
20
  export declare const DataStoreMigrations: (typeof CreateContacts1659463079429)[];
19
21
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/migrations/generic/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,2BAA2B,EAAE,MAAM,oBAAoB,CAAA;AAChE,OAAO,EAAE,mCAAmC,EAAE,MAAM,4BAA4B,CAAA;AAEhF,OAAO,EAAE,6BAA6B,EAAE,MAAM,sBAAsB,CAAA;AACpE,OAAO,EAAE,8BAA8B,EAAE,MAAM,uBAAuB,CAAA;AACtE,OAAO,EAAE,oCAAoC,EAAE,MAAM,6BAA6B,CAAA;AAElF;;;;;;GAMG;AAGH,eAAO,MAAM,0BAA0B,wCAA6D,CAAA;AACpG,eAAO,MAAM,mCAAmC,gDAAwC,CAAA;AACxF,eAAO,MAAM,6BAA6B,0CAAkC,CAAA;AAC5E,eAAO,MAAM,8BAA8B,2CAAmC,CAAA;AAC9E,eAAO,MAAM,oCAAoC,iDAAyC,CAAA;AAG1F,eAAO,MAAM,mBAAmB,wCAM/B,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/migrations/generic/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,2BAA2B,EAAE,MAAM,oBAAoB,CAAA;AAChE,OAAO,EAAE,mCAAmC,EAAE,MAAM,4BAA4B,CAAA;AAEhF,OAAO,EAAE,6BAA6B,EAAE,MAAM,sBAAsB,CAAA;AACpE,OAAO,EAAE,8BAA8B,EAAE,MAAM,uBAAuB,CAAA;AACtE,OAAO,EAAE,oCAAoC,EAAE,MAAM,6BAA6B,CAAA;AAClF,OAAO,EAAE,oCAAoC,EAAE,MAAM,6BAA6B,CAAA;AAElF;;;;;;GAMG;AAGH,eAAO,MAAM,0BAA0B,wCAA6D,CAAA;AACpG,eAAO,MAAM,mCAAmC,gDAAwC,CAAA;AACxF,eAAO,MAAM,6BAA6B,0CAAkC,CAAA;AAC5E,eAAO,MAAM,8BAA8B,2CAAmC,CAAA;AAC9E,eAAO,MAAM,oCAAoC,iDAAyC,CAAA;AAC1F,eAAO,MAAM,+BAA+B,iDAAyC,CAAA;AAGrF,eAAO,MAAM,mBAAmB,wCAO/B,CAAA"}
@@ -1,12 +1,13 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.DataStoreMigrations = exports.DataStoreDigitalCredentialMigrations = exports.DataStoreEventLoggerMigrations = exports.DataStoreStatusListMigrations = exports.DataStoreIssuanceBrandingMigrations = exports.DataStoreContactMigrations = void 0;
3
+ exports.DataStoreMigrations = exports.DataStoreMachineStateMigrations = exports.DataStoreDigitalCredentialMigrations = exports.DataStoreEventLoggerMigrations = exports.DataStoreStatusListMigrations = exports.DataStoreIssuanceBrandingMigrations = exports.DataStoreContactMigrations = void 0;
4
4
  const _1_CreateContacts_1 = require("./1-CreateContacts");
5
5
  const _2_CreateIssuanceBranding_1 = require("./2-CreateIssuanceBranding");
6
6
  const _3_CreateContacts_1 = require("./3-CreateContacts");
7
7
  const _4_CreateStatusList_1 = require("./4-CreateStatusList");
8
8
  const _5_CreateAuditEvents_1 = require("./5-CreateAuditEvents");
9
9
  const _6_CreateDigitalCredential_1 = require("./6-CreateDigitalCredential");
10
+ const _7_CreateMachineStateStore_1 = require("./7-CreateMachineStateStore");
10
11
  /**
11
12
  * The migrations array that SHOULD be used when initializing a TypeORM database connection.
12
13
  *
@@ -20,6 +21,7 @@ exports.DataStoreIssuanceBrandingMigrations = [_2_CreateIssuanceBranding_1.Creat
20
21
  exports.DataStoreStatusListMigrations = [_4_CreateStatusList_1.CreateStatusList1693866470000];
21
22
  exports.DataStoreEventLoggerMigrations = [_5_CreateAuditEvents_1.CreateAuditEvents1701635835330];
22
23
  exports.DataStoreDigitalCredentialMigrations = [_6_CreateDigitalCredential_1.CreateDigitalCredential1708525189000];
24
+ exports.DataStoreMachineStateMigrations = [_7_CreateMachineStateStore_1.CreateMachineStateStore1708098041262];
23
25
  // All migrations together
24
26
  exports.DataStoreMigrations = [
25
27
  ...exports.DataStoreContactMigrations,
@@ -27,5 +29,6 @@ exports.DataStoreMigrations = [
27
29
  ...exports.DataStoreStatusListMigrations,
28
30
  ...exports.DataStoreEventLoggerMigrations,
29
31
  ...exports.DataStoreDigitalCredentialMigrations,
32
+ ...exports.DataStoreMachineStateMigrations,
30
33
  ];
31
34
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/migrations/generic/index.ts"],"names":[],"mappings":";;;AAAA,0DAAgE;AAChE,0EAAgF;AAChF,0DAAgE;AAChE,8DAAoE;AACpE,gEAAsE;AACtE,4EAAkF;AAElF;;;;;;GAMG;AAEH,yJAAyJ;AAC5I,QAAA,0BAA0B,GAAG,CAAC,+CAA2B,EAAE,+CAA2B,CAAC,CAAA;AACvF,QAAA,mCAAmC,GAAG,CAAC,+DAAmC,CAAC,CAAA;AAC3E,QAAA,6BAA6B,GAAG,CAAC,mDAA6B,CAAC,CAAA;AAC/D,QAAA,8BAA8B,GAAG,CAAC,qDAA8B,CAAC,CAAA;AACjE,QAAA,oCAAoC,GAAG,CAAC,iEAAoC,CAAC,CAAA;AAE1F,0BAA0B;AACb,QAAA,mBAAmB,GAAG;IACjC,GAAG,kCAA0B;IAC7B,GAAG,2CAAmC;IACtC,GAAG,qCAA6B;IAChC,GAAG,sCAA8B;IACjC,GAAG,4CAAoC;CACxC,CAAA"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/migrations/generic/index.ts"],"names":[],"mappings":";;;AAAA,0DAAgE;AAChE,0EAAgF;AAChF,0DAAgE;AAChE,8DAAoE;AACpE,gEAAsE;AACtE,4EAAkF;AAClF,4EAAkF;AAElF;;;;;;GAMG;AAEH,yJAAyJ;AAC5I,QAAA,0BAA0B,GAAG,CAAC,+CAA2B,EAAE,+CAA2B,CAAC,CAAA;AACvF,QAAA,mCAAmC,GAAG,CAAC,+DAAmC,CAAC,CAAA;AAC3E,QAAA,6BAA6B,GAAG,CAAC,mDAA6B,CAAC,CAAA;AAC/D,QAAA,8BAA8B,GAAG,CAAC,qDAA8B,CAAC,CAAA;AACjE,QAAA,oCAAoC,GAAG,CAAC,iEAAoC,CAAC,CAAA;AAC7E,QAAA,+BAA+B,GAAG,CAAC,iEAAoC,CAAC,CAAA;AAErF,0BAA0B;AACb,QAAA,mBAAmB,GAAG;IACjC,GAAG,kCAA0B;IAC7B,GAAG,2CAAmC;IACtC,GAAG,qCAA6B;IAChC,GAAG,sCAA8B;IACjC,GAAG,4CAAoC;IACvC,GAAG,uCAA+B;CACnC,CAAA"}
@@ -1,2 +1,2 @@
1
- export { DataStoreMigrations, DataStoreEventLoggerMigrations, DataStoreContactMigrations, DataStoreIssuanceBrandingMigrations, DataStoreStatusListMigrations, DataStoreDigitalCredentialMigrations, } from './generic';
1
+ export { DataStoreMigrations, DataStoreEventLoggerMigrations, DataStoreContactMigrations, DataStoreIssuanceBrandingMigrations, DataStoreStatusListMigrations, DataStoreDigitalCredentialMigrations, DataStoreMachineStateMigrations, } from './generic';
2
2
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/migrations/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,mBAAmB,EACnB,8BAA8B,EAC9B,0BAA0B,EAC1B,mCAAmC,EACnC,6BAA6B,EAC7B,oCAAoC,GACrC,MAAM,WAAW,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/migrations/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,mBAAmB,EACnB,8BAA8B,EAC9B,0BAA0B,EAC1B,mCAAmC,EACnC,6BAA6B,EAC7B,oCAAoC,EACpC,+BAA+B,GAChC,MAAM,WAAW,CAAA"}
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.DataStoreDigitalCredentialMigrations = exports.DataStoreStatusListMigrations = exports.DataStoreIssuanceBrandingMigrations = exports.DataStoreContactMigrations = exports.DataStoreEventLoggerMigrations = exports.DataStoreMigrations = void 0;
3
+ exports.DataStoreMachineStateMigrations = exports.DataStoreDigitalCredentialMigrations = exports.DataStoreStatusListMigrations = exports.DataStoreIssuanceBrandingMigrations = exports.DataStoreContactMigrations = exports.DataStoreEventLoggerMigrations = exports.DataStoreMigrations = void 0;
4
4
  var generic_1 = require("./generic");
5
5
  Object.defineProperty(exports, "DataStoreMigrations", { enumerable: true, get: function () { return generic_1.DataStoreMigrations; } });
6
6
  Object.defineProperty(exports, "DataStoreEventLoggerMigrations", { enumerable: true, get: function () { return generic_1.DataStoreEventLoggerMigrations; } });
@@ -8,4 +8,5 @@ Object.defineProperty(exports, "DataStoreContactMigrations", { enumerable: true,
8
8
  Object.defineProperty(exports, "DataStoreIssuanceBrandingMigrations", { enumerable: true, get: function () { return generic_1.DataStoreIssuanceBrandingMigrations; } });
9
9
  Object.defineProperty(exports, "DataStoreStatusListMigrations", { enumerable: true, get: function () { return generic_1.DataStoreStatusListMigrations; } });
10
10
  Object.defineProperty(exports, "DataStoreDigitalCredentialMigrations", { enumerable: true, get: function () { return generic_1.DataStoreDigitalCredentialMigrations; } });
11
+ Object.defineProperty(exports, "DataStoreMachineStateMigrations", { enumerable: true, get: function () { return generic_1.DataStoreMachineStateMigrations; } });
11
12
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/migrations/index.ts"],"names":[],"mappings":";;;AAAA,qCAOkB;AANhB,8GAAA,mBAAmB,OAAA;AACnB,yHAAA,8BAA8B,OAAA;AAC9B,qHAAA,0BAA0B,OAAA;AAC1B,8HAAA,mCAAmC,OAAA;AACnC,wHAAA,6BAA6B,OAAA;AAC7B,+HAAA,oCAAoC,OAAA"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/migrations/index.ts"],"names":[],"mappings":";;;AAAA,qCAQkB;AAPhB,8GAAA,mBAAmB,OAAA;AACnB,yHAAA,8BAA8B,OAAA;AAC9B,qHAAA,0BAA0B,OAAA;AAC1B,8HAAA,mCAAmC,OAAA;AACnC,wHAAA,6BAA6B,OAAA;AAC7B,+HAAA,oCAAoC,OAAA;AACpC,0HAAA,+BAA+B,OAAA"}
@@ -0,0 +1,7 @@
1
+ import { MigrationInterface, QueryRunner } from 'typeorm';
2
+ export declare class CreateMachineStateStore1708797018115 implements MigrationInterface {
3
+ name: string;
4
+ up(queryRunner: QueryRunner): Promise<void>;
5
+ down(queryRunner: QueryRunner): Promise<void>;
6
+ }
7
+ //# sourceMappingURL=1708797018115-CreateMachineStateStore.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"1708797018115-CreateMachineStateStore.d.ts","sourceRoot":"","sources":["../../../src/migrations/postgres/1708797018115-CreateMachineStateStore.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,WAAW,EAAE,MAAM,SAAS,CAAA;AAEzD,qBAAa,oCAAqC,YAAW,kBAAkB;IAC7E,IAAI,SAAyC;IAEhC,EAAE,CAAC,WAAW,EAAE,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC;IAoB3C,IAAI,CAAC,WAAW,EAAE,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC;CAG3D"}
@@ -0,0 +1,45 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.CreateMachineStateStore1708797018115 = void 0;
13
+ class CreateMachineStateStore1708797018115 {
14
+ constructor() {
15
+ this.name = 'CreateMachineStateStore1708797018115';
16
+ }
17
+ up(queryRunner) {
18
+ return __awaiter(this, void 0, void 0, function* () {
19
+ yield queryRunner.query(`
20
+ CREATE TABLE "MachineStateInfoEntity" (
21
+ "instance_id" text NOT NULL,
22
+ "session_id" text,
23
+ "latest_state_name" text,
24
+ "machine_name" text NOT NULL,
25
+ "latest_event_type" text NOT NULL,
26
+ "state" text NOT NULL,
27
+ "created_at" TIMESTAMP NOT NULL DEFAULT now(),
28
+ "updated_at" TIMESTAMP NOT NULL DEFAULT now(),
29
+ "updated_count" integer NOT NULL DEFAULT 0,
30
+ "expires_at" TIMESTAMP,
31
+ "completed_at" TIMESTAMP,
32
+ "tenant_id" text,
33
+ CONSTRAINT "PK_MachineStateInfoEntity_id" PRIMARY KEY ("instance_id")
34
+ )
35
+ `);
36
+ });
37
+ }
38
+ down(queryRunner) {
39
+ return __awaiter(this, void 0, void 0, function* () {
40
+ yield queryRunner.query(`DROP TABLE "MachineStateInfoEntity"`);
41
+ });
42
+ }
43
+ }
44
+ exports.CreateMachineStateStore1708797018115 = CreateMachineStateStore1708797018115;
45
+ //# sourceMappingURL=1708797018115-CreateMachineStateStore.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"1708797018115-CreateMachineStateStore.js","sourceRoot":"","sources":["../../../src/migrations/postgres/1708797018115-CreateMachineStateStore.ts"],"names":[],"mappings":";;;;;;;;;;;;AAEA,MAAa,oCAAoC;IAAjD;QACE,SAAI,GAAG,sCAAsC,CAAA;IAyB/C,CAAC;IAvBc,EAAE,CAAC,WAAwB;;YACtC,MAAM,WAAW,CAAC,KAAK,CAAC;;;;;;;;;;;;;;;;SAgBnB,CAAC,CAAA;QACR,CAAC;KAAA;IAEY,IAAI,CAAC,WAAwB;;YACxC,MAAM,WAAW,CAAC,KAAK,CAAC,qCAAqC,CAAC,CAAA;QAChE,CAAC;KAAA;CACF;AA1BD,oFA0BC"}
@@ -0,0 +1,7 @@
1
+ import { MigrationInterface, QueryRunner } from 'typeorm';
2
+ export declare class CreateMachineStateStore1708796002272 implements MigrationInterface {
3
+ name: string;
4
+ up(queryRunner: QueryRunner): Promise<void>;
5
+ down(queryRunner: QueryRunner): Promise<void>;
6
+ }
7
+ //# sourceMappingURL=1708796002272-CreateMachineStateStore.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"1708796002272-CreateMachineStateStore.d.ts","sourceRoot":"","sources":["../../../src/migrations/sqlite/1708796002272-CreateMachineStateStore.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,WAAW,EAAE,MAAM,SAAS,CAAA;AAEzD,qBAAa,oCAAqC,YAAW,kBAAkB;IAC7E,IAAI,SAAyC;IAEhC,EAAE,CAAC,WAAW,EAAE,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC;IAmB3C,IAAI,CAAC,WAAW,EAAE,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC;CAG3D"}
@@ -0,0 +1,44 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.CreateMachineStateStore1708796002272 = void 0;
13
+ class CreateMachineStateStore1708796002272 {
14
+ constructor() {
15
+ this.name = 'CreateMachineStateStore1708796002272';
16
+ }
17
+ up(queryRunner) {
18
+ return __awaiter(this, void 0, void 0, function* () {
19
+ yield queryRunner.query(`
20
+ CREATE TABLE "MachineStateInfoEntity" (
21
+ "instance_id" varchar PRIMARY KEY NOT NULL,
22
+ "session_id" varchar,
23
+ "machine_name" varchar NOT NULL,
24
+ "latest_state_name" varchar,
25
+ "latest_event_type" varchar NOT NULL,
26
+ "state" text NOT NULL,
27
+ "created_at" datetime NOT NULL DEFAULT (datetime('now')),
28
+ "updated_at" datetime NOT NULL DEFAULT (datetime('now')),
29
+ "updated_count" integer NOT NULL DEFAULT 0,
30
+ "expires_at" datetime,
31
+ "completed_at" datetime,
32
+ "tenant_id" varchar
33
+ )
34
+ `);
35
+ });
36
+ }
37
+ down(queryRunner) {
38
+ return __awaiter(this, void 0, void 0, function* () {
39
+ yield queryRunner.query(`DROP TABLE "MachineStateInfoEntity"`);
40
+ });
41
+ }
42
+ }
43
+ exports.CreateMachineStateStore1708796002272 = CreateMachineStateStore1708796002272;
44
+ //# sourceMappingURL=1708796002272-CreateMachineStateStore.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"1708796002272-CreateMachineStateStore.js","sourceRoot":"","sources":["../../../src/migrations/sqlite/1708796002272-CreateMachineStateStore.ts"],"names":[],"mappings":";;;;;;;;;;;;AAEA,MAAa,oCAAoC;IAAjD;QACE,SAAI,GAAG,sCAAsC,CAAA;IAwB/C,CAAC;IAtBc,EAAE,CAAC,WAAwB;;YACtC,MAAM,WAAW,CAAC,KAAK,CAAC;;;;;;;;;;;;;;;SAenB,CAAC,CAAA;QACR,CAAC;KAAA;IAEY,IAAI,CAAC,WAAwB;;YACxC,MAAM,WAAW,CAAC,KAAK,CAAC,qCAAqC,CAAC,CAAA;QAChE,CAAC;KAAA;CACF;AAzBD,oFAyBC"}
@@ -7,4 +7,5 @@ export * from './statusList/statusList';
7
7
  export * from './statusList/IAbstractStatusListStore';
8
8
  export * from './eventLogger/IAbstractEventLoggerStore';
9
9
  export * from './eventLogger/eventLogger';
10
+ export * from './machineState/IAbstractMachineStateStore';
10
11
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA,cAAc,qCAAqC,CAAA;AACnD,cAAc,mDAAmD,CAAA;AACjE,cAAc,mBAAmB,CAAA;AACjC,cAAc,iCAAiC,CAAA;AAC/C,cAAc,yBAAyB,CAAA;AACvC,cAAc,yBAAyB,CAAA;AACvC,cAAc,uCAAuC,CAAA;AACrD,cAAc,yCAAyC,CAAA;AACvD,cAAc,2BAA2B,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA,cAAc,qCAAqC,CAAA;AACnD,cAAc,mDAAmD,CAAA;AACjE,cAAc,mBAAmB,CAAA;AACjC,cAAc,iCAAiC,CAAA;AAC/C,cAAc,yBAAyB,CAAA;AACvC,cAAc,yBAAyB,CAAA;AACvC,cAAc,uCAAuC,CAAA;AACrD,cAAc,yCAAyC,CAAA;AACvD,cAAc,2BAA2B,CAAA;AACzC,cAAc,2CAA2C,CAAA"}
@@ -23,4 +23,5 @@ __exportStar(require("./statusList/statusList"), exports);
23
23
  __exportStar(require("./statusList/IAbstractStatusListStore"), exports);
24
24
  __exportStar(require("./eventLogger/IAbstractEventLoggerStore"), exports);
25
25
  __exportStar(require("./eventLogger/eventLogger"), exports);
26
+ __exportStar(require("./machineState/IAbstractMachineStateStore"), exports);
26
27
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,sEAAmD;AACnD,oFAAiE;AACjE,oDAAiC;AACjC,kEAA+C;AAC/C,0DAAuC;AACvC,0DAAuC;AACvC,wEAAqD;AACrD,0EAAuD;AACvD,4DAAyC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,sEAAmD;AACnD,oFAAiE;AACjE,oDAAiC;AACjC,kEAA+C;AAC/C,0DAAuC;AACvC,0DAAuC;AACvC,wEAAqD;AACrD,0EAAuD;AACvD,4DAAyC;AACzC,4EAAyD"}
@@ -0,0 +1,58 @@
1
+ export type StoreMachineStatePersistArgs = Omit<StoreMachineStateInfo, 'createdAt' | 'updatedAt'>;
2
+ export type StoreMachineStatesFindActiveArgs = Partial<Pick<StoreMachineStateInfo, 'machineName' | 'tenantId' | 'instanceId'>>;
3
+ export type FindMachineStatesFilterArgs = Array<Partial<Omit<StoreMachineStateInfo, 'state'>>>;
4
+ export type StoreFindMachineStatesArgs = {
5
+ filter: FindMachineStatesFilterArgs;
6
+ };
7
+ export type StoreMachineStateGetArgs = Pick<StoreMachineStateInfo, 'instanceId' | 'tenantId'>;
8
+ export type StoreMachineStateDeleteArgs = StoreMachineStateGetArgs;
9
+ export type StoreMachineStateDeleteExpiredArgs = {
10
+ machineName?: string;
11
+ tenantId?: string;
12
+ deleteDoneStates?: boolean;
13
+ };
14
+ export interface StoreMachineStateInfo {
15
+ /**
16
+ * Unique instance ID of the machine
17
+ */
18
+ instanceId: string;
19
+ /**
20
+ * Session Id of the machine. Not necessarily unique
21
+ */
22
+ sessionId?: string;
23
+ /**
24
+ * Machine name
25
+ */
26
+ machineName: string;
27
+ /**
28
+ * The latest state name. Can be empty for a newly initialize machine
29
+ */
30
+ latestStateName?: string;
31
+ /**
32
+ * event types like SET_TOC, SET_FIRSTNAME, .... Will be xstate.init on a newly initialized machine
33
+ */
34
+ latestEventType: string;
35
+ /**
36
+ * Serialized Machine state
37
+ */
38
+ state: string;
39
+ /**
40
+ * Represents the creation date
41
+ */
42
+ createdAt: Date;
43
+ /**
44
+ * Represents the expiration date
45
+ */
46
+ expiresAt?: Date;
47
+ /**
48
+ * Represents the update date
49
+ */
50
+ updatedAt: Date;
51
+ /**
52
+ * Represents a counter for tracking updates.
53
+ */
54
+ updatedCount: number;
55
+ completedAt?: Date;
56
+ tenantId?: string;
57
+ }
58
+ //# sourceMappingURL=IAbstractMachineStateStore.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"IAbstractMachineStateStore.d.ts","sourceRoot":"","sources":["../../../src/types/machineState/IAbstractMachineStateStore.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,4BAA4B,GAAG,IAAI,CAAC,qBAAqB,EAAE,WAAW,GAAG,WAAW,CAAC,CAAA;AAEjG,MAAM,MAAM,gCAAgC,GAAG,OAAO,CAAC,IAAI,CAAC,qBAAqB,EAAE,aAAa,GAAG,UAAU,GAAG,YAAY,CAAC,CAAC,CAAA;AAE9H,MAAM,MAAM,2BAA2B,GAAG,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,qBAAqB,EAAE,OAAO,CAAC,CAAC,CAAC,CAAA;AAE9F,MAAM,MAAM,0BAA0B,GAAG;IACvC,MAAM,EAAE,2BAA2B,CAAA;CACpC,CAAA;AAED,MAAM,MAAM,wBAAwB,GAAG,IAAI,CAAC,qBAAqB,EAAE,YAAY,GAAG,UAAU,CAAC,CAAA;AAE7F,MAAM,MAAM,2BAA2B,GAAG,wBAAwB,CAAA;AAClE,MAAM,MAAM,kCAAkC,GAAG;IAAE,WAAW,CAAC,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAAC,gBAAgB,CAAC,EAAE,OAAO,CAAA;CAAE,CAAA;AAExH,MAAM,WAAW,qBAAqB;IACpC;;OAEG;IACH,UAAU,EAAE,MAAM,CAAA;IAElB;;OAEG;IACH,SAAS,CAAC,EAAE,MAAM,CAAA;IAElB;;OAEG;IACH,WAAW,EAAE,MAAM,CAAA;IAEnB;;OAEG;IACH,eAAe,CAAC,EAAE,MAAM,CAAA;IAExB;;OAEG;IACH,eAAe,EAAE,MAAM,CAAA;IAEvB;;OAEG;IACH,KAAK,EAAE,MAAM,CAAA;IAEb;;OAEG;IACH,SAAS,EAAE,IAAI,CAAA;IAEf;;OAEG;IACH,SAAS,CAAC,EAAE,IAAI,CAAA;IAEhB;;OAEG;IACH,SAAS,EAAE,IAAI,CAAA;IAEf;;OAEG;IACH,YAAY,EAAE,MAAM,CAAA;IACpB,WAAW,CAAC,EAAE,IAAI,CAAA;IAClB,QAAQ,CAAC,EAAE,MAAM,CAAA;CAClB"}
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=IAbstractMachineStateStore.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"IAbstractMachineStateStore.js","sourceRoot":"","sources":["../../../src/types/machineState/IAbstractMachineStateStore.ts"],"names":[],"mappings":""}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sphereon/ssi-sdk.data-store",
3
- "version": "0.19.1-next.24+282b8def",
3
+ "version": "0.19.1-next.75+03d3febb",
4
4
  "source": "src/index.ts",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -13,8 +13,8 @@
13
13
  "typeorm-postgres:migration:run": "pnpm run typeorm -- migration:run -c migration-postgres"
14
14
  },
15
15
  "dependencies": {
16
- "@sphereon/ssi-sdk.core": "0.19.1-next.24+282b8def",
17
- "@sphereon/ssi-types": "0.19.1-next.24+282b8def",
16
+ "@sphereon/ssi-sdk.core": "0.19.1-next.75+03d3febb",
17
+ "@sphereon/ssi-types": "0.19.1-next.75+03d3febb",
18
18
  "@veramo/core": "4.2.0",
19
19
  "@veramo/utils": "4.2.0",
20
20
  "class-validator": "^0.14.0",
@@ -44,5 +44,5 @@
44
44
  "PostgreSQL",
45
45
  "Contact Store"
46
46
  ],
47
- "gitHead": "282b8def3880eeeb43edcb33ef463ad57342ac76"
47
+ "gitHead": "03d3febb197a2dfe3cae0c133302d52107cdfa99"
48
48
  }
@@ -0,0 +1,51 @@
1
+ import { DataSource } from 'typeorm'
2
+ import { MachineStateInfoEntity } from '../entities/machineState/MachineStateInfoEntity'
3
+
4
+ import { DataStoreMachineStateEntities, DataStoreMachineStateMigrations, StoreMachineStatePersistArgs, MachineStateStore } from '../index'
5
+
6
+ describe('Machine State Info Database entities tests', (): void => {
7
+ let dbConnection: DataSource
8
+
9
+ beforeEach(async (): Promise<void> => {
10
+ dbConnection = await new DataSource({
11
+ type: 'sqlite',
12
+ database: ':memory:',
13
+ //logging: 'all',
14
+ migrationsRun: false,
15
+ migrations: DataStoreMachineStateMigrations,
16
+ synchronize: false,
17
+ entities: [...DataStoreMachineStateEntities],
18
+ }).initialize()
19
+ await dbConnection.runMigrations()
20
+ expect(await dbConnection.showMigrations()).toBeFalsy()
21
+ })
22
+
23
+ afterEach(async (): Promise<void> => {
24
+ await dbConnection.destroy()
25
+ })
26
+
27
+ it('should save machine state info to database', async (): Promise<void> => {
28
+ const expiresAt = new Date()
29
+ expiresAt.setTime(expiresAt.getTime() + 100000)
30
+ const machineInfo: StoreMachineStatePersistArgs = {
31
+ instanceId: 'Onboarding1',
32
+ latestStateName: 'acceptAgreement',
33
+ machineName: 'Onboarding',
34
+ updatedCount: 0,
35
+ latestEventType: 'SET_TOC',
36
+ state: JSON.stringify({ myState: 'test_state' }),
37
+ tenantId: 'test_tenant_id',
38
+ expiresAt,
39
+ }
40
+ const fromDb: MachineStateInfoEntity = await dbConnection
41
+ .getRepository(MachineStateInfoEntity)
42
+ .save(MachineStateStore.machineStateInfoEntityFrom(machineInfo))
43
+
44
+ expect(fromDb).toBeDefined()
45
+ expect(fromDb?.instanceId).not.toBeNull()
46
+ expect(fromDb?.machineName).toEqual(machineInfo.machineName)
47
+ expect(fromDb?.state).toEqual(machineInfo.state)
48
+ expect(fromDb?.tenantId).toEqual(machineInfo.tenantId)
49
+ expect(fromDb?.completedAt).toBeNull()
50
+ })
51
+ })
@@ -0,0 +1,174 @@
1
+ import { DataSource } from 'typeorm'
2
+ import { DataStoreMachineStateEntities, MachineStateStore, StoreMachineStatesFindActiveArgs, StoreMachineStatePersistArgs } from '../index'
3
+ import { DataStoreMachineStateMigrations } from '../migrations'
4
+
5
+ describe('Machine State store tests', (): void => {
6
+ let dbConnection: DataSource
7
+ let store: MachineStateStore
8
+
9
+ beforeEach(async (): Promise<void> => {
10
+ dbConnection = await new DataSource({
11
+ type: 'sqlite',
12
+ database: ':memory:',
13
+ logging: 'all',
14
+ migrationsRun: false,
15
+ migrations: DataStoreMachineStateMigrations,
16
+ synchronize: false,
17
+ entities: DataStoreMachineStateEntities,
18
+ }).initialize()
19
+ await dbConnection.runMigrations()
20
+ expect(await dbConnection.showMigrations()).toBeFalsy()
21
+ store = new MachineStateStore(dbConnection)
22
+ })
23
+
24
+ afterEach(async (): Promise<void> => {
25
+ await dbConnection.destroy()
26
+ })
27
+
28
+ it('should store machine state info', async (): Promise<void> => {
29
+ const persistArgs: StoreMachineStatePersistArgs = {
30
+ instanceId: 'Onboarding1',
31
+ machineName: 'Onboarding',
32
+ updatedCount: 0,
33
+ latestStateName: 'enterPersonalDetails',
34
+ latestEventType: 'SET_PERSONAL_DATA',
35
+ state: 'test_state',
36
+ expiresAt: new Date(new Date().getDate() + 100000),
37
+ tenantId: 'test_tenant_id',
38
+ }
39
+
40
+ const persistMachineStateResult = await store.persistMachineState(persistArgs)
41
+ expect(persistMachineStateResult).toBeDefined()
42
+ })
43
+
44
+ it('should get all machines with their current state', async (): Promise<void> => {
45
+ const persistArgs: StoreMachineStatePersistArgs = {
46
+ instanceId: 'Onboarding1',
47
+ machineName: 'Onboarding',
48
+ latestStateName: 'enterPersonalDetails',
49
+ latestEventType: 'SET_PERSONAL_DATA',
50
+ updatedCount: 0,
51
+ state: 'test_state',
52
+ expiresAt: new Date(new Date().getDate() + 100000),
53
+ tenantId: 'test_tenant_id',
54
+ }
55
+
56
+ const stateEvent1 = await store.persistMachineState({ ...persistArgs })
57
+ expect(stateEvent1).toBeDefined()
58
+
59
+ const stateEvent2 = await store.persistMachineState({ ...persistArgs, instanceId: 'Onboarding2' })
60
+ expect(stateEvent2).toBeDefined()
61
+
62
+ const result = await store.findMachineStates()
63
+ expect(result).toHaveLength(2)
64
+ })
65
+
66
+ it('should retrieve a machine state', async (): Promise<void> => {
67
+ const expiresAt = new Date()
68
+ expiresAt.setTime(expiresAt.getTime() + 100000)
69
+ const persistArgs: StoreMachineStatePersistArgs = {
70
+ instanceId: 'Onboarding1',
71
+ machineName: 'Onboarding',
72
+ latestStateName: 'enterPersonalDetails',
73
+ latestEventType: 'SET_PERSONAL_DATA',
74
+ state: 'test_state',
75
+ updatedCount: 0,
76
+ expiresAt,
77
+ tenantId: 'test_tenant_id',
78
+ }
79
+
80
+ const machineStatePersisted = await store.persistMachineState(persistArgs)
81
+ expect(machineStatePersisted).toBeDefined()
82
+ const result = await store.findActiveMachineStates({ machineName: persistArgs.machineName, tenantId: persistArgs.tenantId })
83
+ expect(result).toBeDefined()
84
+ })
85
+
86
+ it('should delete a machine state', async (): Promise<void> => {
87
+ const persistArgs: StoreMachineStatePersistArgs = {
88
+ instanceId: 'Onboarding1',
89
+ machineName: 'Onboarding',
90
+ updatedCount: 0,
91
+ latestStateName: 'enterPersonalDetails',
92
+ latestEventType: 'SET_PERSONAL_DATA',
93
+ state: 'test_state',
94
+ expiresAt: new Date(new Date().getDate() + 100000),
95
+ tenantId: 'test_tenant_id',
96
+ }
97
+
98
+ const persistedState = await store.persistMachineState(persistArgs)
99
+ expect(persistedState).toBeDefined()
100
+
101
+ const result: boolean = await store.deleteMachineState({ instanceId: persistedState.instanceId })
102
+ expect(result).toBeTruthy()
103
+ })
104
+
105
+ it('should return an error if type filter does not match', async (): Promise<void> => {
106
+ const args: StoreMachineStatesFindActiveArgs = {
107
+ machineName: 'unknown_machine',
108
+ }
109
+
110
+ await expect(store.findActiveMachineStates(args)).resolves.toEqual([])
111
+ })
112
+
113
+ it('should delete the expired records', async () => {
114
+ const futureExpiresAt = new Date()
115
+ futureExpiresAt.setTime(futureExpiresAt.getTime() + 100000) // Future expiration
116
+
117
+ const pastExpiresAt = new Date()
118
+ pastExpiresAt.setTime(pastExpiresAt.getTime() - 100000) // Past expiration, already expired
119
+
120
+ const oldestXstateEvent: StoreMachineStatePersistArgs = {
121
+ instanceId: 'Onboarding1',
122
+ machineName: 'Onboarding',
123
+ latestStateName: 'enterPersonalDetails',
124
+ latestEventType: 'SET_TOC',
125
+ updatedCount: 0,
126
+ state: 'test_state',
127
+ expiresAt: futureExpiresAt,
128
+ tenantId: 'test_tenant_id',
129
+ }
130
+ const middleXstateEvent: StoreMachineStatePersistArgs = {
131
+ instanceId: 'Onboarding1',
132
+ machineName: 'Onboarding',
133
+ latestStateName: 'TOC',
134
+ latestEventType: 'SET_POLICY2',
135
+ updatedCount: 1,
136
+ state: 'test_state',
137
+ expiresAt: futureExpiresAt,
138
+ tenantId: 'test_tenant_id',
139
+ }
140
+ const newestXstateEvent: StoreMachineStatePersistArgs = {
141
+ instanceId: 'OnboardingExpired',
142
+ machineName: 'Onboarding',
143
+ latestStateName: 'POLICY',
144
+ latestEventType: 'SET_PERSONAL_DATA',
145
+ updatedCount: 0,
146
+ state: 'test_state',
147
+ expiresAt: pastExpiresAt, // This event should be already expired
148
+ tenantId: 'test_tenant_id',
149
+ }
150
+
151
+ await store.persistMachineState(oldestXstateEvent)
152
+ await store.persistMachineState(middleXstateEvent)
153
+ await store.persistMachineState(newestXstateEvent)
154
+
155
+ await expect(store.findActiveMachineStates({ machineName: 'Onboarding' })).resolves.toHaveLength(1)
156
+
157
+ await store.deleteExpiredMachineStates({})
158
+ await expect(store.findActiveMachineStates({ machineName: 'Onboarding' })).resolves.toHaveLength(1)
159
+ await expect(store.findActiveMachineStates({ machineName: 'Onboarding' })).resolves.toMatchObject([
160
+ {
161
+ completedAt: null,
162
+ createdAt: expect.anything(),
163
+ expiresAt: expect.anything(),
164
+ instanceId: 'Onboarding1',
165
+ latestEventType: 'SET_POLICY2',
166
+ latestStateName: 'TOC',
167
+ machineName: 'Onboarding',
168
+ state: 'test_state',
169
+ tenantId: 'test_tenant_id',
170
+ updatedAt: expect.anything(),
171
+ },
172
+ ])
173
+ })
174
+ })
@@ -0,0 +1,58 @@
1
+ import { BaseEntity, Column, CreateDateColumn, Entity, PrimaryColumn, UpdateDateColumn } from 'typeorm'
2
+
3
+ /**
4
+ * @class MachineStateInfoEntity
5
+ * Represents a machine state. It allows to continue a machine at a later point in time at the point it was left of
6
+ *
7
+ * @param {string} instanceId - The instance ID of the machine state.
8
+ * @param {string} [sessionId] - The session ID of the machine state. (optional)
9
+ * @param {string} machineName - The name of the machine.
10
+ * @param {string} [latestStateName] - The name of the latest state. (optional)
11
+ * @param {string} latestEventType - The type of the latest event.
12
+ * @param {string} state - The current state of the machine.
13
+ * @param {Date} createdAt - The date and time when the machine state was created.
14
+ * @param {Date} updatedAt - The date and time when the machine state was last updated.
15
+ * @param {number} updatedCount - The number of times the machine state has been updated.
16
+ * @param {Date} [expiresAt] - The date and time when the machine state expires. (optional)
17
+ * @param {Date} [completedAt] - The date and time when the machine state was completed. (optional)
18
+ * @param {string} [tenantId] - The ID of the tenant associated with the machine state. (optional)
19
+ */
20
+ @Entity('MachineStateInfoEntity')
21
+ export class MachineStateInfoEntity extends BaseEntity {
22
+ @PrimaryColumn({ name: 'instance_id', type: 'varchar', nullable: false })
23
+ instanceId!: string
24
+
25
+ @Column({ name: 'session_id', type: 'varchar', nullable: true })
26
+ sessionId?: string
27
+
28
+ // Xstate moved to name instead of instanceId for V5. Also makes more sense
29
+ @Column({ name: 'machine_name', type: 'varchar', nullable: false })
30
+ machineName!: string
31
+
32
+ @Column({ name: 'latest_state_name', type: 'varchar', nullable: true })
33
+ latestStateName?: string
34
+
35
+ @Column({ name: 'latest_event_type', type: 'varchar', nullable: false })
36
+ latestEventType!: string
37
+
38
+ @Column({ name: 'state', type: 'text', nullable: false })
39
+ state!: string
40
+
41
+ @CreateDateColumn({ name: 'created_at', type: 'datetime', nullable: false })
42
+ createdAt!: Date
43
+
44
+ @UpdateDateColumn({ name: 'updated_at', type: 'datetime', nullable: false })
45
+ updatedAt!: Date
46
+
47
+ @Column({ name: 'updated_count', type: 'integer', nullable: false })
48
+ updatedCount!: number
49
+
50
+ @Column({ name: 'expires_at', type: 'datetime', nullable: true })
51
+ expiresAt?: Date
52
+
53
+ @Column({ name: 'completed_at', type: 'datetime', nullable: true })
54
+ completedAt?: Date
55
+
56
+ @Column({ name: 'tenant_id', type: 'varchar', nullable: true })
57
+ tenantId?: string
58
+ }