@sphereon/ssi-sdk.data-store 0.18.2-unstable.98 → 0.19.1-next.100

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 (74) hide show
  1. package/dist/contact/AbstractContactStore.d.ts.map +1 -1
  2. package/dist/contact/AbstractContactStore.js.map +1 -1
  3. package/dist/contact/ContactStore.d.ts.map +1 -1
  4. package/dist/contact/ContactStore.js +12 -6
  5. package/dist/contact/ContactStore.js.map +1 -1
  6. package/dist/entities/machineState/MachineStateInfoEntity.d.ts +33 -0
  7. package/dist/entities/machineState/MachineStateInfoEntity.d.ts.map +1 -0
  8. package/dist/entities/machineState/MachineStateInfoEntity.js +85 -0
  9. package/dist/entities/machineState/MachineStateInfoEntity.js.map +1 -0
  10. package/dist/index.d.ts +7 -3
  11. package/dist/index.d.ts.map +1 -1
  12. package/dist/index.js +11 -2
  13. package/dist/index.js.map +1 -1
  14. package/dist/issuanceBranding/IssuanceBrandingStore.d.ts.map +1 -1
  15. package/dist/issuanceBranding/IssuanceBrandingStore.js.map +1 -1
  16. package/dist/machineState/IAbstractMachineStateStore.d.ts +52 -0
  17. package/dist/machineState/IAbstractMachineStateStore.d.ts.map +1 -0
  18. package/dist/machineState/IAbstractMachineStateStore.js +13 -0
  19. package/dist/machineState/IAbstractMachineStateStore.js.map +1 -0
  20. package/dist/machineState/MachineStateStore.d.ts +21 -0
  21. package/dist/machineState/MachineStateStore.d.ts.map +1 -0
  22. package/dist/machineState/MachineStateStore.js +139 -0
  23. package/dist/machineState/MachineStateStore.js.map +1 -0
  24. package/dist/migrations/generic/7-CreateMachineStateStore.d.ts +7 -0
  25. package/dist/migrations/generic/7-CreateMachineStateStore.d.ts.map +1 -0
  26. package/dist/migrations/generic/7-CreateMachineStateStore.js +78 -0
  27. package/dist/migrations/generic/7-CreateMachineStateStore.js.map +1 -0
  28. package/dist/migrations/generic/index.d.ts +2 -0
  29. package/dist/migrations/generic/index.d.ts.map +1 -1
  30. package/dist/migrations/generic/index.js +4 -1
  31. package/dist/migrations/generic/index.js.map +1 -1
  32. package/dist/migrations/index.d.ts +1 -1
  33. package/dist/migrations/index.d.ts.map +1 -1
  34. package/dist/migrations/index.js +2 -1
  35. package/dist/migrations/index.js.map +1 -1
  36. package/dist/migrations/postgres/1708797018115-CreateMachineStateStore.d.ts +7 -0
  37. package/dist/migrations/postgres/1708797018115-CreateMachineStateStore.d.ts.map +1 -0
  38. package/dist/migrations/postgres/1708797018115-CreateMachineStateStore.js +45 -0
  39. package/dist/migrations/postgres/1708797018115-CreateMachineStateStore.js.map +1 -0
  40. package/dist/migrations/sqlite/1708796002272-CreateMachineStateStore.d.ts +7 -0
  41. package/dist/migrations/sqlite/1708796002272-CreateMachineStateStore.d.ts.map +1 -0
  42. package/dist/migrations/sqlite/1708796002272-CreateMachineStateStore.js +44 -0
  43. package/dist/migrations/sqlite/1708796002272-CreateMachineStateStore.js.map +1 -0
  44. package/dist/types/contact/contact.d.ts.map +1 -1
  45. package/dist/types/contact/contact.js.map +1 -1
  46. package/dist/types/index.d.ts +1 -0
  47. package/dist/types/index.d.ts.map +1 -1
  48. package/dist/types/index.js +1 -0
  49. package/dist/types/index.js.map +1 -1
  50. package/dist/types/machineState/IAbstractMachineStateStore.d.ts +58 -0
  51. package/dist/types/machineState/IAbstractMachineStateStore.d.ts.map +1 -0
  52. package/dist/types/machineState/IAbstractMachineStateStore.js +3 -0
  53. package/dist/types/machineState/IAbstractMachineStateStore.js.map +1 -0
  54. package/package.json +4 -4
  55. package/src/__tests__/contact.entities.test.ts +32 -15
  56. package/src/__tests__/contact.store.test.ts +71 -28
  57. package/src/__tests__/machineState.entities.test.ts +51 -0
  58. package/src/__tests__/machineState.store.test.ts +174 -0
  59. package/src/contact/AbstractContactStore.ts +3 -2
  60. package/src/contact/ContactStore.ts +15 -9
  61. package/src/entities/contact/PhysicalAddressEntity.ts +1 -1
  62. package/src/entities/machineState/MachineStateInfoEntity.ts +58 -0
  63. package/src/index.ts +9 -0
  64. package/src/issuanceBranding/IssuanceBrandingStore.ts +6 -8
  65. package/src/machineState/IAbstractMachineStateStore.ts +65 -0
  66. package/src/machineState/MachineStateStore.ts +149 -0
  67. package/src/migrations/generic/7-CreateMachineStateStore.ts +66 -0
  68. package/src/migrations/generic/index.ts +3 -0
  69. package/src/migrations/index.ts +1 -0
  70. package/src/migrations/postgres/1708797018115-CreateMachineStateStore.ts +29 -0
  71. package/src/migrations/sqlite/1708796002272-CreateMachineStateStore.ts +28 -0
  72. package/src/types/contact/contact.ts +13 -2
  73. package/src/types/index.ts +1 -0
  74. package/src/types/machineState/IAbstractMachineStateStore.ts +68 -0
@@ -4,6 +4,7 @@ import { CreateContacts1690925872318 } from './3-CreateContacts'
4
4
  import { CreateStatusList1693866470000 } from './4-CreateStatusList'
5
5
  import { CreateAuditEvents1701635835330 } from './5-CreateAuditEvents'
6
6
  import { CreateDigitalCredential1708525189000 } from './6-CreateDigitalCredential'
7
+ import { CreateMachineStateStore1708098041262 } from './7-CreateMachineStateStore'
7
8
 
8
9
  /**
9
10
  * The migrations array that SHOULD be used when initializing a TypeORM database connection.
@@ -19,6 +20,7 @@ export const DataStoreIssuanceBrandingMigrations = [CreateIssuanceBranding165946
19
20
  export const DataStoreStatusListMigrations = [CreateStatusList1693866470000]
20
21
  export const DataStoreEventLoggerMigrations = [CreateAuditEvents1701635835330]
21
22
  export const DataStoreDigitalCredentialMigrations = [CreateDigitalCredential1708525189000]
23
+ export const DataStoreMachineStateMigrations = [CreateMachineStateStore1708098041262]
22
24
 
23
25
  // All migrations together
24
26
  export const DataStoreMigrations = [
@@ -27,4 +29,5 @@ export const DataStoreMigrations = [
27
29
  ...DataStoreStatusListMigrations,
28
30
  ...DataStoreEventLoggerMigrations,
29
31
  ...DataStoreDigitalCredentialMigrations,
32
+ ...DataStoreMachineStateMigrations,
30
33
  ]
@@ -5,4 +5,5 @@ export {
5
5
  DataStoreIssuanceBrandingMigrations,
6
6
  DataStoreStatusListMigrations,
7
7
  DataStoreDigitalCredentialMigrations,
8
+ DataStoreMachineStateMigrations,
8
9
  } from './generic'
@@ -0,0 +1,29 @@
1
+ import { MigrationInterface, QueryRunner } from 'typeorm'
2
+
3
+ export class CreateMachineStateStore1708797018115 implements MigrationInterface {
4
+ name = 'CreateMachineStateStore1708797018115'
5
+
6
+ public async up(queryRunner: QueryRunner): Promise<void> {
7
+ await queryRunner.query(`
8
+ CREATE TABLE "MachineStateInfoEntity" (
9
+ "instance_id" text NOT NULL,
10
+ "session_id" text,
11
+ "latest_state_name" text,
12
+ "machine_name" text NOT NULL,
13
+ "latest_event_type" text NOT NULL,
14
+ "state" text NOT NULL,
15
+ "created_at" TIMESTAMP NOT NULL DEFAULT now(),
16
+ "updated_at" TIMESTAMP NOT NULL DEFAULT now(),
17
+ "updated_count" integer NOT NULL DEFAULT 0,
18
+ "expires_at" TIMESTAMP,
19
+ "completed_at" TIMESTAMP,
20
+ "tenant_id" text,
21
+ CONSTRAINT "PK_MachineStateInfoEntity_id" PRIMARY KEY ("instance_id")
22
+ )
23
+ `)
24
+ }
25
+
26
+ public async down(queryRunner: QueryRunner): Promise<void> {
27
+ await queryRunner.query(`DROP TABLE "MachineStateInfoEntity"`)
28
+ }
29
+ }
@@ -0,0 +1,28 @@
1
+ import { MigrationInterface, QueryRunner } from 'typeorm'
2
+
3
+ export class CreateMachineStateStore1708796002272 implements MigrationInterface {
4
+ name = 'CreateMachineStateStore1708796002272'
5
+
6
+ public async up(queryRunner: QueryRunner): Promise<void> {
7
+ await queryRunner.query(`
8
+ CREATE TABLE "MachineStateInfoEntity" (
9
+ "instance_id" varchar PRIMARY KEY NOT NULL,
10
+ "session_id" varchar,
11
+ "machine_name" varchar NOT NULL,
12
+ "latest_state_name" varchar,
13
+ "latest_event_type" varchar NOT NULL,
14
+ "state" text NOT NULL,
15
+ "created_at" datetime NOT NULL DEFAULT (datetime('now')),
16
+ "updated_at" datetime NOT NULL DEFAULT (datetime('now')),
17
+ "updated_count" integer NOT NULL DEFAULT 0,
18
+ "expires_at" datetime,
19
+ "completed_at" datetime,
20
+ "tenant_id" varchar
21
+ )
22
+ `)
23
+ }
24
+
25
+ public async down(queryRunner: QueryRunner): Promise<void> {
26
+ await queryRunner.query(`DROP TABLE "MachineStateInfoEntity"`)
27
+ }
28
+ }
@@ -15,7 +15,16 @@ export type Party = {
15
15
  }
16
16
  export type NonPersistedParty = Omit<
17
17
  Party,
18
- 'id' | 'identities' | 'electronicAddresses' | 'physicalAddresses' | 'contact' | 'roles' | 'partyType' | 'relationships' | 'createdAt' | 'lastUpdatedAt'
18
+ | 'id'
19
+ | 'identities'
20
+ | 'electronicAddresses'
21
+ | 'physicalAddresses'
22
+ | 'contact'
23
+ | 'roles'
24
+ | 'partyType'
25
+ | 'relationships'
26
+ | 'createdAt'
27
+ | 'lastUpdatedAt'
19
28
  > & {
20
29
  identities?: Array<NonPersistedIdentity>
21
30
  electronicAddresses?: Array<NonPersistedElectronicAddress>
@@ -24,7 +33,9 @@ export type NonPersistedParty = Omit<
24
33
  partyType: NonPersistedPartyType
25
34
  relationships?: Array<NonPersistedPartyRelationship>
26
35
  }
27
- export type PartialParty = Partial<Omit<Party, 'identities' | 'electronicAddresses' | 'physicalAddresses' | 'contact' | 'partyType' | 'relationships'>> & {
36
+ export type PartialParty = Partial<
37
+ Omit<Party, 'identities' | 'electronicAddresses' | 'physicalAddresses' | 'contact' | 'partyType' | 'relationships'>
38
+ > & {
28
39
  identities?: PartialIdentity
29
40
  electronicAddresses?: PartialElectronicAddress
30
41
  physicalAddresses?: PartialPhysicalAddress
@@ -7,3 +7,4 @@ 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'
@@ -0,0 +1,68 @@
1
+ export type StoreMachineStatePersistArgs = Omit<StoreMachineStateInfo, 'createdAt' | 'updatedAt'>
2
+
3
+ export type StoreMachineStatesFindActiveArgs = Partial<Pick<StoreMachineStateInfo, 'machineName' | 'tenantId' | 'instanceId'>>
4
+
5
+ export type FindMachineStatesFilterArgs = Array<Partial<Omit<StoreMachineStateInfo, 'state'>>>
6
+
7
+ export type StoreFindMachineStatesArgs = {
8
+ filter: FindMachineStatesFilterArgs
9
+ }
10
+
11
+ export type StoreMachineStateGetArgs = Pick<StoreMachineStateInfo, 'instanceId' | 'tenantId'>
12
+
13
+ export type StoreMachineStateDeleteArgs = StoreMachineStateGetArgs
14
+ export type StoreMachineStateDeleteExpiredArgs = { machineName?: string; tenantId?: string; deleteDoneStates?: boolean }
15
+
16
+ export interface StoreMachineStateInfo {
17
+ /**
18
+ * Unique instance ID of the machine
19
+ */
20
+ instanceId: string
21
+
22
+ /**
23
+ * Session Id of the machine. Not necessarily unique
24
+ */
25
+ sessionId?: string
26
+
27
+ /**
28
+ * Machine name
29
+ */
30
+ machineName: string
31
+
32
+ /**
33
+ * The latest state name. Can be empty for a newly initialize machine
34
+ */
35
+ latestStateName?: string
36
+
37
+ /**
38
+ * event types like SET_TOC, SET_FIRSTNAME, .... Will be xstate.init on a newly initialized machine
39
+ */
40
+ latestEventType: string
41
+
42
+ /**
43
+ * Serialized Machine state
44
+ */
45
+ state: string
46
+
47
+ /**
48
+ * Represents the creation date
49
+ */
50
+ createdAt: Date
51
+
52
+ /**
53
+ * Represents the expiration date
54
+ */
55
+ expiresAt?: Date
56
+
57
+ /**
58
+ * Represents the update date
59
+ */
60
+ updatedAt: Date
61
+
62
+ /**
63
+ * Represents a counter for tracking updates.
64
+ */
65
+ updatedCount: number
66
+ completedAt?: Date
67
+ tenantId?: string
68
+ }