@sphereon/ssi-sdk.data-store 0.34.1-feature.SSISDK.26.RP.58 → 0.34.1-feature.SSISDK.45.189

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 (36) hide show
  1. package/dist/index.cjs +1616 -1477
  2. package/dist/index.cjs.map +1 -1
  3. package/dist/index.d.cts +187 -194
  4. package/dist/index.d.ts +187 -194
  5. package/dist/index.js +1582 -1443
  6. package/dist/index.js.map +1 -1
  7. package/package.json +8 -8
  8. package/src/__tests__/contact.entities.test.ts +2 -2
  9. package/src/__tests__/contact.store.test.ts +1 -1
  10. package/src/__tests__/digitalCredential.entities.test.ts +2 -1
  11. package/src/__tests__/digitalCredential.store.test.ts +5 -5
  12. package/src/__tests__/pd-manager.entities.test.ts +27 -98
  13. package/src/__tests__/pd-manager.store.test.ts +151 -101
  14. package/src/digitalCredential/DigitalCredentialStore.ts +9 -9
  15. package/src/entities/contact/IdentityEntity.ts +2 -1
  16. package/src/entities/digitalCredential/DigitalCredentialEntity.ts +2 -1
  17. package/src/entities/presentationDefinition/{PresentationDefinitionItemEntity.ts → DcqlQueryItemEntity.ts} +8 -12
  18. package/src/index.ts +3 -3
  19. package/src/migrations/generic/12-CreateBitstringStatusList.ts +32 -2
  20. package/src/migrations/generic/13-CreateDcqlQueryItem.ts +67 -0
  21. package/src/migrations/generic/index.ts +10 -5
  22. package/src/migrations/postgres/1716475165345-CreatePresentationDefinitions.ts +1 -1
  23. package/src/migrations/postgres/1726588800000-CreateDcqlQueryItem.ts +25 -0
  24. package/src/migrations/postgres/1737110469001-UpdateStatusList.ts +1 -1
  25. package/src/migrations/postgres/1741895823000-CreateBitstringStatusList.ts +15 -2
  26. package/src/migrations/sqlite/1716475165344-CreatePresentationDefinitions.ts +1 -1
  27. package/src/migrations/sqlite/1726617600000-CreateDcqlQueryItem.ts +24 -0
  28. package/src/presentationDefinition/AbstractPDStore.ts +5 -5
  29. package/src/presentationDefinition/PDStore.ts +40 -40
  30. package/src/types/contact/contact.ts +1 -1
  31. package/src/types/digitalCredential/IAbstractDigitalCredentialStore.ts +2 -1
  32. package/src/types/digitalCredential/enums.ts +0 -7
  33. package/src/types/digitalCredential/types.ts +2 -1
  34. package/src/types/presentationDefinition/IAbstractPDStore.ts +5 -5
  35. package/src/types/presentationDefinition/presentationDefinition.ts +8 -9
  36. package/src/utils/presentationDefinition/MappingUtils.ts +31 -22
package/dist/index.js CHANGED
@@ -8,55 +8,55 @@ import typeorm6 from "typeorm";
8
8
  import typeorm5 from "typeorm";
9
9
 
10
10
  // src/types/contact/contact.ts
11
- var ConnectionType = /* @__PURE__ */ function(ConnectionType2) {
11
+ var ConnectionType = /* @__PURE__ */ (function(ConnectionType2) {
12
12
  ConnectionType2["OPENID_CONNECT"] = "OIDC";
13
13
  ConnectionType2["SIOPv2"] = "SIOPv2";
14
14
  ConnectionType2["SIOPv2_OpenID4VP"] = "SIOPv2+OpenID4VP";
15
15
  return ConnectionType2;
16
- }({});
17
- var CorrelationIdentifierType = /* @__PURE__ */ function(CorrelationIdentifierType2) {
16
+ })({});
17
+ var CorrelationIdentifierType = /* @__PURE__ */ (function(CorrelationIdentifierType2) {
18
18
  CorrelationIdentifierType2["DID"] = "did";
19
19
  CorrelationIdentifierType2["URL"] = "url";
20
20
  return CorrelationIdentifierType2;
21
- }({});
22
- var PartyTypeType = /* @__PURE__ */ function(PartyTypeType2) {
21
+ })({});
22
+ var PartyTypeType = /* @__PURE__ */ (function(PartyTypeType2) {
23
23
  PartyTypeType2["NATURAL_PERSON"] = "naturalPerson";
24
24
  PartyTypeType2["ORGANIZATION"] = "organization";
25
25
  return PartyTypeType2;
26
- }({});
27
- var PartyOrigin = /* @__PURE__ */ function(PartyOrigin2) {
26
+ })({});
27
+ var PartyOrigin = /* @__PURE__ */ (function(PartyOrigin2) {
28
28
  PartyOrigin2["INTERNAL"] = "INTERNAL";
29
29
  PartyOrigin2["EXTERNAL"] = "EXTERNAL";
30
30
  return PartyOrigin2;
31
- }({});
32
- var IdentityOrigin = /* @__PURE__ */ function(IdentityOrigin2) {
31
+ })({});
32
+ var IdentityOrigin = /* @__PURE__ */ (function(IdentityOrigin2) {
33
33
  IdentityOrigin2["INTERNAL"] = "INTERNAL";
34
34
  IdentityOrigin2["EXTERNAL"] = "EXTERNAL";
35
35
  return IdentityOrigin2;
36
- }({});
36
+ })({});
37
37
 
38
38
  // src/types/digitalCredential/enums.ts
39
- var DocumentType = /* @__PURE__ */ function(DocumentType2) {
39
+ var DocumentType = /* @__PURE__ */ (function(DocumentType2) {
40
40
  DocumentType2["VC"] = "VC";
41
41
  DocumentType2["VP"] = "VP";
42
42
  DocumentType2["P"] = "P";
43
43
  DocumentType2["C"] = "C";
44
44
  return DocumentType2;
45
- }({});
46
- var RegulationType = /* @__PURE__ */ function(RegulationType2) {
45
+ })({});
46
+ var RegulationType = /* @__PURE__ */ (function(RegulationType2) {
47
47
  RegulationType2["PID"] = "PID";
48
48
  RegulationType2["QEAA"] = "QEAA";
49
49
  RegulationType2["EAA"] = "EAA";
50
50
  RegulationType2["NON_REGULATED"] = "NON_REGULATED";
51
51
  return RegulationType2;
52
- }({});
53
- var CredentialDocumentFormat = /* @__PURE__ */ function(CredentialDocumentFormat2) {
52
+ })({});
53
+ var CredentialDocumentFormat = /* @__PURE__ */ (function(CredentialDocumentFormat2) {
54
54
  CredentialDocumentFormat2["JSON_LD"] = "JSON_LD";
55
55
  CredentialDocumentFormat2["JWT"] = "JWT";
56
56
  CredentialDocumentFormat2["SD_JWT"] = "SD_JWT";
57
57
  CredentialDocumentFormat2["MSO_MDOC"] = "MSO_MDOC";
58
58
  return CredentialDocumentFormat2;
59
- }({});
59
+ })({});
60
60
  (function(CredentialDocumentFormat2) {
61
61
  function fromSpecValue(credentialFormat) {
62
62
  const format = credentialFormat.toLowerCase();
@@ -89,26 +89,19 @@ var CredentialDocumentFormat = /* @__PURE__ */ function(CredentialDocumentFormat
89
89
  __name(toSpecValue, "toSpecValue");
90
90
  CredentialDocumentFormat2.toSpecValue = toSpecValue;
91
91
  })(CredentialDocumentFormat || (CredentialDocumentFormat = {}));
92
- var CredentialCorrelationType = /* @__PURE__ */ function(CredentialCorrelationType2) {
92
+ var CredentialCorrelationType = /* @__PURE__ */ (function(CredentialCorrelationType2) {
93
93
  CredentialCorrelationType2["DID"] = "DID";
94
94
  CredentialCorrelationType2["X509_SAN"] = "X509_SAN";
95
95
  CredentialCorrelationType2["KID"] = "KID";
96
96
  CredentialCorrelationType2["URL"] = "URL";
97
97
  return CredentialCorrelationType2;
98
- }({});
99
- var CredentialRole = /* @__PURE__ */ function(CredentialRole2) {
100
- CredentialRole2["ISSUER"] = "ISSUER";
101
- CredentialRole2["VERIFIER"] = "VERIFIER";
102
- CredentialRole2["HOLDER"] = "HOLDER";
103
- CredentialRole2["FEDERATION_TRUST_ANCHOR"] = "FEDERATION_TRUST_ANCHOR";
104
- return CredentialRole2;
105
- }({});
106
- var CredentialStateType = /* @__PURE__ */ function(CredentialStateType2) {
98
+ })({});
99
+ var CredentialStateType = /* @__PURE__ */ (function(CredentialStateType2) {
107
100
  CredentialStateType2["REVOKED"] = "REVOKED";
108
101
  CredentialStateType2["VERIFIED"] = "VERIFIED";
109
102
  CredentialStateType2["EXPIRED"] = "EXPIRED";
110
103
  return CredentialStateType2;
111
- }({});
104
+ })({});
112
105
 
113
106
  // src/entities/contact/IdentityEntity.ts
114
107
  import { BaseEntity as BaseEntity8, CreateDateColumn as CreateDateColumn7, Entity as Entity10, PrimaryGeneratedColumn as PrimaryGeneratedColumn10, UpdateDateColumn as UpdateDateColumn7, OneToOne as OneToOne4, JoinColumn as JoinColumn5, ManyToOne as ManyToOne7, Column as Column9, OneToMany as OneToMany4, BeforeInsert as BeforeInsert10, BeforeUpdate as BeforeUpdate10 } from "typeorm";
@@ -3769,6 +3762,7 @@ AuditEventEntity = _ts_decorate32([
3769
3762
 
3770
3763
  // src/entities/digitalCredential/DigitalCredentialEntity.ts
3771
3764
  import { typeormDate, typeOrmDateTime as typeOrmDateTime16 } from "@sphereon/ssi-sdk.agent-config";
3765
+ import { CredentialRole } from "@sphereon/ssi-types";
3772
3766
  import { BaseEntity as BaseEntity23, Column as Column30, CreateDateColumn as CreateDateColumn13, Entity as Entity25, PrimaryGeneratedColumn as PrimaryGeneratedColumn22, UpdateDateColumn as UpdateDateColumn13 } from "typeorm";
3773
3767
  function _ts_decorate33(decorators, target, key, desc) {
3774
3768
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
@@ -4028,7 +4022,7 @@ DigitalCredentialEntity = _ts_decorate33([
4028
4022
  Entity25("DigitalCredential")
4029
4023
  ], DigitalCredentialEntity);
4030
4024
 
4031
- // src/entities/presentationDefinition/PresentationDefinitionItemEntity.ts
4025
+ // src/entities/presentationDefinition/DcqlQueryItemEntity.ts
4032
4026
  import { BaseEntity as BaseEntity24, BeforeInsert as BeforeInsert20, BeforeUpdate as BeforeUpdate20, Column as Column31, CreateDateColumn as CreateDateColumn14, Entity as Entity26, Index as Index8, PrimaryGeneratedColumn as PrimaryGeneratedColumn23, UpdateDateColumn as UpdateDateColumn14 } from "typeorm";
4033
4027
  import { IsNotEmpty as IsNotEmpty12 } from "class-validator";
4034
4028
  import { typeOrmDateTime as typeOrmDateTime17 } from "@sphereon/ssi-sdk.agent-config";
@@ -4043,18 +4037,17 @@ function _ts_metadata33(k, v) {
4043
4037
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
4044
4038
  }
4045
4039
  __name(_ts_metadata33, "_ts_metadata");
4046
- var PresentationDefinitionItemEntity = class extends BaseEntity24 {
4040
+ var DcqlQueryItemEntity = class extends BaseEntity24 {
4047
4041
  static {
4048
- __name(this, "PresentationDefinitionItemEntity");
4042
+ __name(this, "DcqlQueryItemEntity");
4049
4043
  }
4050
4044
  id;
4051
- definitionId;
4045
+ queryId;
4052
4046
  version;
4053
4047
  tenantId;
4054
4048
  purpose;
4055
4049
  name;
4056
- definitionPayload;
4057
- dcqlPayload;
4050
+ query;
4058
4051
  createdAt;
4059
4052
  lastUpdatedAt;
4060
4053
  // By default, @UpdateDateColumn in TypeORM updates the timestamp only when the entity's top-level properties change.
@@ -4065,20 +4058,20 @@ var PresentationDefinitionItemEntity = class extends BaseEntity24 {
4065
4058
  _ts_decorate34([
4066
4059
  PrimaryGeneratedColumn23("uuid"),
4067
4060
  _ts_metadata33("design:type", String)
4068
- ], PresentationDefinitionItemEntity.prototype, "id", void 0);
4061
+ ], DcqlQueryItemEntity.prototype, "id", void 0);
4069
4062
  _ts_decorate34([
4070
4063
  Column31({
4071
- name: "definition_id",
4064
+ name: "query_id",
4072
4065
  length: 255,
4073
4066
  type: "varchar",
4074
4067
  nullable: false,
4075
4068
  unique: false
4076
4069
  }),
4077
4070
  IsNotEmpty12({
4078
- message: "A blank definition id field is not allowed"
4071
+ message: "A blank query id field is not allowed"
4079
4072
  }),
4080
4073
  _ts_metadata33("design:type", String)
4081
- ], PresentationDefinitionItemEntity.prototype, "definitionId", void 0);
4074
+ ], DcqlQueryItemEntity.prototype, "queryId", void 0);
4082
4075
  _ts_decorate34([
4083
4076
  Column31({
4084
4077
  name: "version",
@@ -4091,7 +4084,7 @@ _ts_decorate34([
4091
4084
  message: "A blank version field is not allowed"
4092
4085
  }),
4093
4086
  _ts_metadata33("design:type", String)
4094
- ], PresentationDefinitionItemEntity.prototype, "version", void 0);
4087
+ ], DcqlQueryItemEntity.prototype, "version", void 0);
4095
4088
  _ts_decorate34([
4096
4089
  Column31({
4097
4090
  name: "tenant_id",
@@ -4101,7 +4094,7 @@ _ts_decorate34([
4101
4094
  unique: false
4102
4095
  }),
4103
4096
  _ts_metadata33("design:type", String)
4104
- ], PresentationDefinitionItemEntity.prototype, "tenantId", void 0);
4097
+ ], DcqlQueryItemEntity.prototype, "tenantId", void 0);
4105
4098
  _ts_decorate34([
4106
4099
  Column31({
4107
4100
  name: "purpose",
@@ -4111,7 +4104,7 @@ _ts_decorate34([
4111
4104
  unique: false
4112
4105
  }),
4113
4106
  _ts_metadata33("design:type", String)
4114
- ], PresentationDefinitionItemEntity.prototype, "purpose", void 0);
4107
+ ], DcqlQueryItemEntity.prototype, "purpose", void 0);
4115
4108
  _ts_decorate34([
4116
4109
  Column31({
4117
4110
  name: "name",
@@ -4121,31 +4114,19 @@ _ts_decorate34([
4121
4114
  unique: false
4122
4115
  }),
4123
4116
  _ts_metadata33("design:type", String)
4124
- ], PresentationDefinitionItemEntity.prototype, "name", void 0);
4117
+ ], DcqlQueryItemEntity.prototype, "name", void 0);
4125
4118
  _ts_decorate34([
4126
4119
  Column31({
4127
- name: "definition_payload",
4120
+ name: "query",
4128
4121
  type: "text",
4129
4122
  nullable: false,
4130
4123
  unique: false
4131
4124
  }),
4132
4125
  IsNotEmpty12({
4133
- message: "A blank PD definition payload field is not allowed"
4126
+ message: "A blank dcql query payload field is not allowed"
4134
4127
  }),
4135
4128
  _ts_metadata33("design:type", String)
4136
- ], PresentationDefinitionItemEntity.prototype, "definitionPayload", void 0);
4137
- _ts_decorate34([
4138
- Column31({
4139
- name: "dcql_payload",
4140
- type: "text",
4141
- nullable: true,
4142
- unique: false
4143
- }),
4144
- IsNotEmpty12({
4145
- message: "A blank dcql definition payload field is not allowed"
4146
- }),
4147
- _ts_metadata33("design:type", String)
4148
- ], PresentationDefinitionItemEntity.prototype, "dcqlPayload", void 0);
4129
+ ], DcqlQueryItemEntity.prototype, "query", void 0);
4149
4130
  _ts_decorate34([
4150
4131
  CreateDateColumn14({
4151
4132
  name: "created_at",
@@ -4153,7 +4134,7 @@ _ts_decorate34([
4153
4134
  type: typeOrmDateTime17()
4154
4135
  }),
4155
4136
  _ts_metadata33("design:type", typeof Date === "undefined" ? Object : Date)
4156
- ], PresentationDefinitionItemEntity.prototype, "createdAt", void 0);
4137
+ ], DcqlQueryItemEntity.prototype, "createdAt", void 0);
4157
4138
  _ts_decorate34([
4158
4139
  UpdateDateColumn14({
4159
4140
  name: "last_updated_at",
@@ -4161,22 +4142,22 @@ _ts_decorate34([
4161
4142
  type: typeOrmDateTime17()
4162
4143
  }),
4163
4144
  _ts_metadata33("design:type", typeof Date === "undefined" ? Object : Date)
4164
- ], PresentationDefinitionItemEntity.prototype, "lastUpdatedAt", void 0);
4145
+ ], DcqlQueryItemEntity.prototype, "lastUpdatedAt", void 0);
4165
4146
  _ts_decorate34([
4166
4147
  BeforeInsert20(),
4167
4148
  BeforeUpdate20(),
4168
4149
  _ts_metadata33("design:type", Function),
4169
4150
  _ts_metadata33("design:paramtypes", []),
4170
4151
  _ts_metadata33("design:returntype", void 0)
4171
- ], PresentationDefinitionItemEntity.prototype, "updateUpdatedDate", null);
4172
- PresentationDefinitionItemEntity = _ts_decorate34([
4173
- Entity26("PresentationDefinitionItem"),
4152
+ ], DcqlQueryItemEntity.prototype, "updateUpdatedDate", null);
4153
+ DcqlQueryItemEntity = _ts_decorate34([
4154
+ Entity26("DcqlQueryItem"),
4174
4155
  Index8([
4175
4156
  "version"
4176
4157
  ], {
4177
4158
  unique: false
4178
4159
  })
4179
- ], PresentationDefinitionItemEntity);
4160
+ ], DcqlQueryItemEntity);
4180
4161
 
4181
4162
  // src/entities/oid4vcState/Oid4vcStateEntity.ts
4182
4163
  import { typeOrmDateTime as typeOrmDateTime18 } from "@sphereon/ssi-sdk.agent-config";
@@ -5346,6 +5327,7 @@ var AbstractDigitalCredentialStore = class {
5346
5327
  };
5347
5328
 
5348
5329
  // src/digitalCredential/DigitalCredentialStore.ts
5330
+ import { CredentialRole as CredentialRole2 } from "@sphereon/ssi-types";
5349
5331
  import Debug2 from "debug";
5350
5332
 
5351
5333
  // src/utils/SortingUtils.ts
@@ -5415,7 +5397,7 @@ var DigitalCredentialStore = class extends AbstractDigitalCredentialStore {
5415
5397
  if (!args) {
5416
5398
  return false;
5417
5399
  }
5418
- let query = {};
5400
+ const query = {};
5419
5401
  if ("id" in args) {
5420
5402
  query.id = args.id;
5421
5403
  } else if ("hash" in args) {
@@ -5501,7 +5483,7 @@ var DigitalCredentialStore = class extends AbstractDigitalCredentialStore {
5501
5483
  }, "updateCredentialState");
5502
5484
  assertValidDigitalCredential(credentialEntity) {
5503
5485
  const { kmsKeyRef, identifierMethod, credentialRole, isIssuerSigned } = credentialEntity;
5504
- const isRoleInvalid = credentialRole === CredentialRole.ISSUER || credentialRole === CredentialRole.HOLDER && !isIssuerSigned;
5486
+ const isRoleInvalid = credentialRole === CredentialRole2.ISSUER || credentialRole === CredentialRole2.HOLDER && !isIssuerSigned;
5505
5487
  if (isRoleInvalid && (!kmsKeyRef || !identifierMethod)) {
5506
5488
  const missingFields = [];
5507
5489
  if (!kmsKeyRef) missingFields.push("kmsKeyRef");
@@ -6778,44 +6760,54 @@ import Debug7 from "debug";
6778
6760
 
6779
6761
  // src/utils/presentationDefinition/MappingUtils.ts
6780
6762
  import * as blakepkg from "blakejs";
6781
- var presentationDefinitionItemFrom = /* @__PURE__ */ __name((entity) => {
6763
+ import { DcqlQuery } from "dcql";
6764
+ var dcqlQueryItemFrom = /* @__PURE__ */ __name((entity) => {
6782
6765
  const result = {
6783
6766
  id: entity.id,
6784
6767
  tenantId: entity.tenantId,
6785
- definitionId: entity.definitionId,
6768
+ queryId: entity.queryId,
6786
6769
  version: entity.version,
6787
6770
  name: entity.name,
6788
6771
  purpose: entity.purpose,
6789
- definitionPayload: JSON.parse(entity.definitionPayload),
6790
- dcqlPayload: JSON.parse(entity.dcqlPayload),
6772
+ query: DcqlQuery.parse(JSON.parse(entity.query)),
6791
6773
  createdAt: entity.createdAt,
6792
6774
  lastUpdatedAt: entity.lastUpdatedAt
6793
6775
  };
6776
+ if (result.query) {
6777
+ DcqlQuery.validate(result.query);
6778
+ }
6794
6779
  return replaceNullWithUndefined(result);
6795
- }, "presentationDefinitionItemFrom");
6796
- var presentationDefinitionEntityItemFrom = /* @__PURE__ */ __name((item) => {
6797
- const entity = new PresentationDefinitionItemEntity();
6780
+ }, "dcqlQueryItemFrom");
6781
+ var dcqlQueryEntityItemFrom = /* @__PURE__ */ __name((item) => {
6782
+ const entity = new DcqlQueryItemEntity();
6798
6783
  entity.tenantId = item.tenantId;
6799
- entity.definitionId = item.definitionId;
6784
+ entity.queryId = item.queryId;
6800
6785
  entity.version = item.version;
6801
6786
  entity.name = item.name;
6802
6787
  entity.purpose = item.purpose;
6803
- entity.definitionPayload = JSON.stringify(item.definitionPayload);
6804
- entity.dcqlPayload = JSON.stringify(item.dcqlPayload);
6788
+ if (item.query) {
6789
+ const dcqlQuery = DcqlQuery.parse(item.query);
6790
+ DcqlQuery.validate(dcqlQuery);
6791
+ entity.query = JSON.stringify(item.query);
6792
+ }
6805
6793
  return entity;
6806
- }, "presentationDefinitionEntityItemFrom");
6794
+ }, "dcqlQueryEntityItemFrom");
6807
6795
  function hashPayload(payload) {
6808
6796
  return blakepkg.blake2bHex(JSON.stringify(payload));
6809
6797
  }
6810
6798
  __name(hashPayload, "hashPayload");
6811
6799
  function isPresentationDefinitionEqual(base, compare) {
6812
- if (base.definitionId !== compare.definitionId || base.tenantId != compare.tenantId || base.version !== compare.version || base.name != compare.name || base.purpose != compare.purpose) {
6800
+ if (base.queryId !== compare.queryId || base.tenantId !== compare.tenantId || base.version !== compare.version || base.name !== compare.name || base.purpose !== compare.purpose) {
6813
6801
  return false;
6814
6802
  }
6815
- if (base.definitionPayload && compare.definitionPayload) {
6816
- return hashPayload(base.definitionPayload) === hashPayload(compare.definitionPayload);
6803
+ if (base.query && compare.query) {
6804
+ if (hashPayload(base.query) !== hashPayload(compare.query)) {
6805
+ return false;
6806
+ }
6807
+ } else if (base.query || compare.query) {
6808
+ return false;
6817
6809
  }
6818
- return false;
6810
+ return true;
6819
6811
  }
6820
6812
  __name(isPresentationDefinitionEqual, "isPresentationDefinitionEqual");
6821
6813
 
@@ -6832,7 +6824,7 @@ var PDStore = class extends AbstractPDStore {
6832
6824
  }
6833
6825
  getDefinition = /* @__PURE__ */ __name(async (args) => {
6834
6826
  const { itemId } = args ?? {};
6835
- const pdRepository = (await this.dbConnection).getRepository(PresentationDefinitionItemEntity);
6827
+ const pdRepository = (await this.dbConnection).getRepository(DcqlQueryItemEntity);
6836
6828
  const result = await pdRepository.findOne({
6837
6829
  where: {
6838
6830
  id: itemId
@@ -6841,11 +6833,11 @@ var PDStore = class extends AbstractPDStore {
6841
6833
  if (!result) {
6842
6834
  return Promise.reject(Error(`No presentation definition item found for id: ${itemId}`));
6843
6835
  }
6844
- return presentationDefinitionItemFrom(result);
6836
+ return dcqlQueryItemFrom(result);
6845
6837
  }, "getDefinition");
6846
6838
  hasDefinition = /* @__PURE__ */ __name(async (args) => {
6847
6839
  const { itemId } = args ?? {};
6848
- const pdRepository = (await this.dbConnection).getRepository(PresentationDefinitionItemEntity);
6840
+ const pdRepository = (await this.dbConnection).getRepository(DcqlQueryItemEntity);
6849
6841
  const resultCount = await pdRepository.count({
6850
6842
  where: {
6851
6843
  id: itemId
@@ -6855,7 +6847,7 @@ var PDStore = class extends AbstractPDStore {
6855
6847
  }, "hasDefinition");
6856
6848
  hasDefinitions = /* @__PURE__ */ __name(async (args) => {
6857
6849
  const { filter } = args;
6858
- const pdRepository = (await this.dbConnection).getRepository(PresentationDefinitionItemEntity);
6850
+ const pdRepository = (await this.dbConnection).getRepository(DcqlQueryItemEntity);
6859
6851
  const resultCount = await pdRepository.count({
6860
6852
  ...filter && {
6861
6853
  where: cleanFilter(filter)
@@ -6865,7 +6857,7 @@ var PDStore = class extends AbstractPDStore {
6865
6857
  }, "hasDefinitions");
6866
6858
  getDefinitions = /* @__PURE__ */ __name(async (args) => {
6867
6859
  const { filter } = args;
6868
- const pdRepository = (await this.dbConnection).getRepository(PresentationDefinitionItemEntity);
6860
+ const pdRepository = (await this.dbConnection).getRepository(DcqlQueryItemEntity);
6869
6861
  const initialResult = await this.findIds(pdRepository, filter);
6870
6862
  const result = await pdRepository.find({
6871
6863
  where: {
@@ -6875,19 +6867,19 @@ var PDStore = class extends AbstractPDStore {
6875
6867
  version: "DESC"
6876
6868
  }
6877
6869
  });
6878
- return result.map((entity) => presentationDefinitionItemFrom(entity));
6870
+ return result.map((entity) => dcqlQueryItemFrom(entity));
6879
6871
  }, "getDefinitions");
6880
6872
  addDefinition = /* @__PURE__ */ __name(async (item) => {
6881
- const pdRepository = (await this.dbConnection).getRepository(PresentationDefinitionItemEntity);
6882
- const entity = presentationDefinitionEntityItemFrom(item);
6873
+ const pdRepository = (await this.dbConnection).getRepository(DcqlQueryItemEntity);
6874
+ const entity = dcqlQueryEntityItemFrom(item);
6883
6875
  debug7("Adding presentation definition entity", item);
6884
6876
  const result = await pdRepository.save(entity, {
6885
6877
  transaction: true
6886
6878
  });
6887
- return presentationDefinitionItemFrom(result);
6879
+ return dcqlQueryItemFrom(result);
6888
6880
  }, "addDefinition");
6889
6881
  updateDefinition = /* @__PURE__ */ __name(async (item) => {
6890
- const pdRepository = (await this.dbConnection).getRepository(PresentationDefinitionItemEntity);
6882
+ const pdRepository = (await this.dbConnection).getRepository(DcqlQueryItemEntity);
6891
6883
  const result = await pdRepository.findOne({
6892
6884
  where: {
6893
6885
  id: item.id
@@ -6900,20 +6892,20 @@ var PDStore = class extends AbstractPDStore {
6900
6892
  ...result
6901
6893
  };
6902
6894
  updatedEntity.tenantId = item.tenantId;
6903
- updatedEntity.definitionId = item.definitionId;
6895
+ updatedEntity.queryId = item.queryId;
6904
6896
  updatedEntity.version = item.version;
6905
6897
  updatedEntity.name = item.name;
6906
6898
  updatedEntity.purpose = item.purpose;
6907
- updatedEntity.definitionPayload = JSON.stringify(item.definitionPayload);
6899
+ updatedEntity.query = JSON.stringify(item.query);
6908
6900
  debug7("Updating presentation definition entity", updatedEntity);
6909
6901
  const updateResult = await pdRepository.save(updatedEntity, {
6910
6902
  transaction: true
6911
6903
  });
6912
- return presentationDefinitionItemFrom(updateResult);
6904
+ return dcqlQueryItemFrom(updateResult);
6913
6905
  }, "updateDefinition");
6914
6906
  deleteDefinition = /* @__PURE__ */ __name(async (args) => {
6915
6907
  const { itemId } = args;
6916
- const pdRepository = (await this.dbConnection).getRepository(PresentationDefinitionItemEntity);
6908
+ const pdRepository = (await this.dbConnection).getRepository(DcqlQueryItemEntity);
6917
6909
  const entity = await pdRepository.findOne({
6918
6910
  where: {
6919
6911
  id: itemId
@@ -6927,7 +6919,7 @@ var PDStore = class extends AbstractPDStore {
6927
6919
  }, "deleteDefinition");
6928
6920
  deleteDefinitions = /* @__PURE__ */ __name(async (args) => {
6929
6921
  const { filter } = args;
6930
- const pdRepository = (await this.dbConnection).getRepository(PresentationDefinitionItemEntity);
6922
+ const pdRepository = (await this.dbConnection).getRepository(DcqlQueryItemEntity);
6931
6923
  const initialResult = await this.findIds(pdRepository, filter);
6932
6924
  const result = await pdRepository.find({
6933
6925
  where: {
@@ -7140,9 +7132,120 @@ var CreateContacts1659463079429 = class {
7140
7132
  }
7141
7133
  };
7142
7134
 
7143
- // src/migrations/generic/2-CreateIssuanceBranding.ts
7135
+ // src/migrations/generic/10-CreatePresentationDefinitions.ts
7144
7136
  import Debug9 from "debug";
7145
7137
 
7138
+ // src/migrations/postgres/1716475165345-CreatePresentationDefinitions.ts
7139
+ var CreatePresentationDefinitions1716475165345 = class {
7140
+ static {
7141
+ __name(this, "CreatePresentationDefinitions1716475165345");
7142
+ }
7143
+ name = "CreatePresentationDefinitions1716475165345";
7144
+ async up(queryRunner) {
7145
+ await queryRunner.query(`
7146
+ CREATE TABLE "PresentationDefinitionItem" (
7147
+ "id" uuid NOT NULL DEFAULT uuid_generate_v4(),
7148
+ "tenant_id" TEXT,
7149
+ "definition_id" TEXT NOT NULL,
7150
+ "name" TEXT,
7151
+ "version" TEXT NOT NULL,
7152
+ "purpose" TEXT,
7153
+ "definition_payload" TEXT NOT NULL,
7154
+ "query" TEXT,
7155
+ "created_at" TIMESTAMP NOT NULL DEFAULT now(),
7156
+ "last_updated_at" TIMESTAMP NOT NULL DEFAULT now(),
7157
+ CONSTRAINT "PK_PresentationDefinitionItem_id" PRIMARY KEY ("id"))
7158
+ `);
7159
+ }
7160
+ async down(queryRunner) {
7161
+ await queryRunner.query(`DROP TABLE "PresentationDefinitionItem"`);
7162
+ }
7163
+ };
7164
+
7165
+ // src/migrations/sqlite/1716475165344-CreatePresentationDefinitions.ts
7166
+ var CreatePresentationDefinitions1716475165344 = class {
7167
+ static {
7168
+ __name(this, "CreatePresentationDefinitions1716475165344");
7169
+ }
7170
+ name = "CreatePresentationDefinitions1716475165344";
7171
+ async up(queryRunner) {
7172
+ await queryRunner.query(`CREATE TABLE "PresentationDefinitionItem" (
7173
+ "id" varchar PRIMARY KEY NOT NULL,
7174
+ "tenant_id" varchar,
7175
+ "definition_id" varchar NOT NULL,
7176
+ "name" varchar,
7177
+ "version" varchar NOT NULL,
7178
+ "purpose" varchar,
7179
+ "definition_payload" varchar NOT NULL,
7180
+ "query" varchar,
7181
+ "created_at" datetime NOT NULL DEFAULT (datetime('now')),
7182
+ "last_updated_at" datetime NOT NULL DEFAULT (datetime('now')))`);
7183
+ }
7184
+ async down(queryRunner) {
7185
+ await queryRunner.query(`DROP TABLE "PresentationDefinitionItem"`);
7186
+ }
7187
+ };
7188
+
7189
+ // src/migrations/generic/10-CreatePresentationDefinitions.ts
7190
+ var debug9 = Debug9("sphereon:ssi-sdk:migrations");
7191
+ var CreatePresentationDefinitions1716533767523 = class {
7192
+ static {
7193
+ __name(this, "CreatePresentationDefinitions1716533767523");
7194
+ }
7195
+ name = "CreatePresentationDefinitionItems1716533767523";
7196
+ async up(queryRunner) {
7197
+ debug9("migration: creating machine state tables");
7198
+ const dbType = queryRunner.connection.driver.options.type;
7199
+ switch (dbType) {
7200
+ case "postgres": {
7201
+ debug9("using postgres migration file");
7202
+ const mig = new CreatePresentationDefinitions1716475165345();
7203
+ await mig.up(queryRunner);
7204
+ debug9("Migration statements executed");
7205
+ return;
7206
+ }
7207
+ case "sqlite":
7208
+ case "expo":
7209
+ case "react-native": {
7210
+ debug9("using sqlite/react-native migration file");
7211
+ const mig = new CreatePresentationDefinitions1716475165344();
7212
+ await mig.up(queryRunner);
7213
+ debug9("Migration statements executed");
7214
+ return;
7215
+ }
7216
+ default:
7217
+ return Promise.reject(`Migrations are currently only supported for sqlite, react-native, expo and postgres. Was ${dbType}. Please run your database without migrations and with 'migrationsRun: false' and 'synchronize: true' for now`);
7218
+ }
7219
+ }
7220
+ async down(queryRunner) {
7221
+ debug9("migration: reverting machine state tables");
7222
+ const dbType = queryRunner.connection.driver.options.type;
7223
+ switch (dbType) {
7224
+ case "postgres": {
7225
+ debug9("using postgres migration file");
7226
+ const mig = new CreatePresentationDefinitions1716475165345();
7227
+ await mig.down(queryRunner);
7228
+ debug9("Migration statements executed");
7229
+ return;
7230
+ }
7231
+ case "sqlite":
7232
+ case "expo":
7233
+ case "react-native": {
7234
+ debug9("using sqlite/react-native migration file");
7235
+ const mig = new CreatePresentationDefinitions1716475165344();
7236
+ await mig.down(queryRunner);
7237
+ debug9("Migration statements executed");
7238
+ return;
7239
+ }
7240
+ default:
7241
+ return Promise.reject(`Migrations are currently only supported for sqlite, react-native, expo and postgres. Was ${dbType}. Please run your database without migrations and with 'migrationsRun: false' and 'synchronize: true' for now`);
7242
+ }
7243
+ }
7244
+ };
7245
+
7246
+ // src/migrations/generic/11-FixCredentialClaimsReferenceUuid.ts
7247
+ import Debug10 from "debug";
7248
+
7146
7249
  // src/migrations/postgres/1685628974232-CreateIssuanceBranding.ts
7147
7250
  import { enablePostgresUuidExtension as enablePostgresUuidExtension2 } from "@sphereon/ssi-sdk.core";
7148
7251
  var CreateIssuanceBranding1685628974232 = class {
@@ -7279,31 +7382,105 @@ var CreateIssuanceBranding1685628973231 = class {
7279
7382
  }
7280
7383
  };
7281
7384
 
7282
- // src/migrations/generic/2-CreateIssuanceBranding.ts
7283
- var debug9 = Debug9("sphereon:ssi-sdk:migrations");
7284
- var CreateIssuanceBranding1659463079429 = class {
7385
+ // src/migrations/postgres/1741895822987-FixCredentialClaimsReferencesUuid.ts
7386
+ var FixCredentialClaimsReferencesUuidPG1741895822987 = class {
7285
7387
  static {
7286
- __name(this, "CreateIssuanceBranding1659463079429");
7388
+ __name(this, "FixCredentialClaimsReferencesUuidPG1741895822987");
7287
7389
  }
7288
- name = "CreateIssuanceBranding1659463079429";
7390
+ name = "FixCredentialClaimsReferencesUuid1741895822987";
7391
+ async up(queryRunner) {
7392
+ await queryRunner.query(`
7393
+ ALTER TABLE "CredentialClaims"
7394
+ ALTER COLUMN "credentialLocaleBrandingId" TYPE uuid USING "credentialLocaleBrandingId"::uuid;
7395
+ `);
7396
+ }
7397
+ async down(queryRunner) {
7398
+ await queryRunner.query(`
7399
+ ALTER TABLE "CredentialClaims"
7400
+ ALTER COLUMN "credentialLocaleBrandingId" TYPE character varying USING "credentialLocaleBrandingId"::text;
7401
+ `);
7402
+ }
7403
+ };
7404
+
7405
+ // src/migrations/sqlite/1741895822987-FixCredentialClaimsReferencesUuid.ts
7406
+ var FixCredentialClaimsReferencesUuidSqlite1741895822987 = class {
7407
+ static {
7408
+ __name(this, "FixCredentialClaimsReferencesUuidSqlite1741895822987");
7409
+ }
7410
+ name = "FixCredentialClaimsReferencesUuid1741895822987";
7411
+ async up(queryRunner) {
7412
+ await queryRunner.query(`
7413
+ CREATE TABLE "CredentialClaims_new"
7414
+ (
7415
+ "id" uuid NOT NULL DEFAULT (lower(hex(randomblob(16)))),
7416
+ "key" character varying(255) NOT NULL,
7417
+ "name" character varying(255) NOT NULL,
7418
+ "credentialLocaleBrandingId" uuid,
7419
+ CONSTRAINT "PK_CredentialClaims_id" PRIMARY KEY ("id")
7420
+ )
7421
+ `);
7422
+ await queryRunner.query(`
7423
+ INSERT INTO "CredentialClaims_new" ("id", "key", "name", "credentialLocaleBrandingId")
7424
+ SELECT "id", "key", "name", "credentialLocaleBrandingId"
7425
+ FROM "CredentialClaims"
7426
+ `);
7427
+ await queryRunner.query(`DROP TABLE "CredentialClaims"`);
7428
+ await queryRunner.query(`ALTER TABLE "CredentialClaims_new" RENAME TO "CredentialClaims"`);
7429
+ await queryRunner.query(`
7430
+ CREATE UNIQUE INDEX "IDX_CredentialClaimsEntity_credentialLocaleBranding_locale"
7431
+ ON "CredentialClaims" ("credentialLocaleBrandingId", "key")
7432
+ `);
7433
+ }
7434
+ async down(queryRunner) {
7435
+ await queryRunner.query(`
7436
+ CREATE TABLE "CredentialClaims_old"
7437
+ (
7438
+ "id" uuid NOT NULL DEFAULT (lower(hex(randomblob(16)))),
7439
+ "key" character varying(255) NOT NULL,
7440
+ "name" character varying(255) NOT NULL,
7441
+ "credentialLocaleBrandingId" character varying,
7442
+ CONSTRAINT "PK_CredentialClaims_id" PRIMARY KEY ("id")
7443
+ )
7444
+ `);
7445
+ await queryRunner.query(`
7446
+ INSERT INTO "CredentialClaims_old" ("id", "key", "name", "credentialLocaleBrandingId")
7447
+ SELECT "id", "key", "name", "credentialLocaleBrandingId"
7448
+ FROM "CredentialClaims"
7449
+ `);
7450
+ await queryRunner.query(`DROP TABLE "CredentialClaims"`);
7451
+ await queryRunner.query(`ALTER TABLE "CredentialClaims_old" RENAME TO "CredentialClaims"`);
7452
+ await queryRunner.query(`
7453
+ CREATE UNIQUE INDEX "IDX_CredentialClaimsEntity_credentialLocaleBranding_locale"
7454
+ ON "CredentialClaims" ("credentialLocaleBrandingId", "key")
7455
+ `);
7456
+ }
7457
+ };
7458
+
7459
+ // src/migrations/generic/11-FixCredentialClaimsReferenceUuid.ts
7460
+ var debug10 = Debug10("sphereon:ssi-sdk:migrations");
7461
+ var FixCredentialClaimsReferencesUuid1741895822987 = class {
7462
+ static {
7463
+ __name(this, "FixCredentialClaimsReferencesUuid1741895822987");
7464
+ }
7465
+ name = "FixCredentialClaimsReferenceUuid1741895822987";
7289
7466
  async up(queryRunner) {
7290
- debug9("migration: creating issuance branding tables");
7467
+ debug10("migration: creating issuance branding uuid problem");
7291
7468
  const dbType = queryRunner.connection.driver.options.type;
7292
7469
  switch (dbType) {
7293
7470
  case "postgres": {
7294
- debug9("using postgres migration file");
7295
- const mig = new CreateIssuanceBranding1685628974232();
7471
+ debug10("using postgres migration file");
7472
+ const mig = new FixCredentialClaimsReferencesUuidPG1741895822987();
7296
7473
  await mig.up(queryRunner);
7297
- debug9("Migration statements executed");
7474
+ debug10("Migration statements executed");
7298
7475
  return;
7299
7476
  }
7300
7477
  case "sqlite":
7301
7478
  case "expo":
7302
7479
  case "react-native": {
7303
- debug9("using sqlite/react-native migration file");
7304
- const mig = new CreateIssuanceBranding1685628973231();
7480
+ debug10("using sqlite/react-native migration file");
7481
+ const mig = new FixCredentialClaimsReferencesUuidSqlite1741895822987();
7305
7482
  await mig.up(queryRunner);
7306
- debug9("Migration statements executed");
7483
+ debug10("Migration statements executed");
7307
7484
  return;
7308
7485
  }
7309
7486
  default:
@@ -7311,23 +7488,23 @@ var CreateIssuanceBranding1659463079429 = class {
7311
7488
  }
7312
7489
  }
7313
7490
  async down(queryRunner) {
7314
- debug9("migration: reverting issuance branding tables");
7491
+ debug10("migration: reverting issuance branding uuid migration");
7315
7492
  const dbType = queryRunner.connection.driver.options.type;
7316
7493
  switch (dbType) {
7317
7494
  case "postgres": {
7318
- debug9("using postgres migration file");
7495
+ debug10("using postgres migration file");
7319
7496
  const mig = new CreateIssuanceBranding1685628974232();
7320
7497
  await mig.down(queryRunner);
7321
- debug9("Migration statements executed");
7498
+ debug10("Migration statements executed");
7322
7499
  return;
7323
7500
  }
7324
7501
  case "sqlite":
7325
7502
  case "expo":
7326
7503
  case "react-native": {
7327
- debug9("using sqlite/react-native migration file");
7504
+ debug10("using sqlite/react-native migration file");
7328
7505
  const mig = new CreateIssuanceBranding1685628973231();
7329
7506
  await mig.down(queryRunner);
7330
- debug9("Migration statements executed");
7507
+ debug10("Migration statements executed");
7331
7508
  return;
7332
7509
  }
7333
7510
  default:
@@ -7336,669 +7513,678 @@ var CreateIssuanceBranding1659463079429 = class {
7336
7513
  }
7337
7514
  };
7338
7515
 
7339
- // src/migrations/generic/3-CreateContacts.ts
7340
- import Debug10 from "debug";
7516
+ // src/migrations/generic/12-CreateBitstringStatusList.ts
7517
+ import Debug11 from "debug";
7341
7518
 
7342
- // src/migrations/sqlite/1690925872693-CreateContacts.ts
7343
- var CreateContacts1690925872693 = class {
7519
+ // src/migrations/postgres/1741895823000-CreateBitstringStatusList.ts
7520
+ var AddBitstringStatusListEnumPG1741895823000 = class {
7344
7521
  static {
7345
- __name(this, "CreateContacts1690925872693");
7522
+ __name(this, "AddBitstringStatusListEnumPG1741895823000");
7346
7523
  }
7347
- name = "CreateContacts1690925872693";
7524
+ name = "AddBitstringStatusListEnum1741895823000";
7348
7525
  async up(queryRunner) {
7349
- await queryRunner.query(`CREATE TABLE "temporary_CorrelationIdentifier" ("id" varchar PRIMARY KEY NOT NULL, "type" varchar CHECK( "type" IN ('did','url') ) NOT NULL, "correlation_id" text NOT NULL, "identityId" varchar, CONSTRAINT "REL_CorrelationIdentifier_identityId" UNIQUE ("identityId"), CONSTRAINT "UQ_CorrelationIdentifier_correlation_id" UNIQUE ("correlation_id"))`);
7350
- await queryRunner.query(`INSERT INTO "temporary_CorrelationIdentifier"("id", "type", "correlation_id", "identityId") SELECT "id", "type", "correlation_id", "identityId" FROM "CorrelationIdentifier"`);
7351
- await queryRunner.query(`DROP TABLE "CorrelationIdentifier"`);
7352
- await queryRunner.query(`ALTER TABLE "temporary_CorrelationIdentifier" RENAME TO "CorrelationIdentifier"`);
7353
- await queryRunner.query(`CREATE TABLE "temporary_Identity" ("id" varchar PRIMARY KEY NOT NULL, "alias" varchar(255) NOT NULL, "roles" text NOT NULL, "created_at" datetime NOT NULL DEFAULT (datetime('now')), "last_updated_at" datetime NOT NULL DEFAULT (datetime('now')), "contactId" varchar, CONSTRAINT "UQ_Identity_alias" UNIQUE ("alias"))`);
7354
- await queryRunner.query(`INSERT INTO "temporary_Identity"("id", "alias", "roles", "created_at", "last_updated_at", "contactId") SELECT "id", "alias", "roles", "created_at", "last_updated_at", "contactId" FROM "Identity"`);
7355
- await queryRunner.query(`DROP TABLE "Identity"`);
7356
- await queryRunner.query(`ALTER TABLE "temporary_Identity" RENAME TO "Identity"`);
7357
- await queryRunner.query(`CREATE TABLE "temporary_Connection" ("id" varchar PRIMARY KEY NOT NULL, "type" varchar CHECK( "type" IN ('OIDC','SIOPv2','SIOPv2+OpenID4VP') ) NOT NULL, "identityId" varchar, CONSTRAINT "REL_Connection_identityId" UNIQUE ("identityId"))`);
7358
- await queryRunner.query(`INSERT INTO "temporary_Connection"("id", "type", "identityId") SELECT "id", "type", "identityId" FROM "Connection"`);
7359
- await queryRunner.query(`DROP TABLE "Connection"`);
7360
- await queryRunner.query(`ALTER TABLE "temporary_Connection" RENAME TO "Connection"`);
7361
- await queryRunner.query(`CREATE TABLE "temporary_CorrelationIdentifier" ("id" varchar PRIMARY KEY NOT NULL, "type" varchar CHECK( "type" IN ('did','url') ) NOT NULL, "correlation_id" text NOT NULL, "identity_id" varchar, CONSTRAINT "REL_CorrelationIdentifier_identityId" UNIQUE ("identity_id"), CONSTRAINT "UQ_CorrelationIdentifier_correlation_id" UNIQUE ("correlation_id"))`);
7362
- await queryRunner.query(`INSERT INTO "temporary_CorrelationIdentifier"("id", "type", "correlation_id", "identity_id") SELECT "id", "type", "correlation_id", "identityId" FROM "CorrelationIdentifier"`);
7363
- await queryRunner.query(`DROP TABLE "CorrelationIdentifier"`);
7364
- await queryRunner.query(`ALTER TABLE "temporary_CorrelationIdentifier" RENAME TO "CorrelationIdentifier"`);
7365
- await queryRunner.query(`CREATE TABLE "temporary_Identity" ("id" varchar PRIMARY KEY NOT NULL, "alias" varchar(255) NOT NULL, "roles" text NOT NULL, "created_at" datetime NOT NULL DEFAULT (datetime('now')), "last_updated_at" datetime NOT NULL DEFAULT (datetime('now')), "partyId" varchar, CONSTRAINT "UQ_Identity_alias" UNIQUE ("alias"))`);
7366
- await queryRunner.query(`INSERT INTO "temporary_Identity"("id", "alias", "roles", "created_at", "last_updated_at", "partyId") SELECT "id", "alias", "roles", "created_at", "last_updated_at", "contactId" FROM "Identity"`);
7367
- await queryRunner.query(`DROP TABLE "Identity"`);
7368
- await queryRunner.query(`ALTER TABLE "temporary_Identity" RENAME TO "Identity"`);
7369
- await queryRunner.query(`CREATE TABLE "temporary_Connection" ("id" varchar PRIMARY KEY NOT NULL, "type" varchar CHECK( "type" IN ('OIDC','SIOPv2','SIOPv2+OpenID4VP') ) NOT NULL, "identity_id" varchar, CONSTRAINT "REL_Connection_identityId" UNIQUE ("identity_id"))`);
7370
- await queryRunner.query(`INSERT INTO "temporary_Connection"("id", "type", "identity_id") SELECT "id", "type", "identityId" FROM "Connection"`);
7371
- await queryRunner.query(`DROP TABLE "Connection"`);
7372
- await queryRunner.query(`ALTER TABLE "temporary_Connection" RENAME TO "Connection"`);
7373
- await queryRunner.query(`CREATE TABLE "PartyType" ("id" varchar PRIMARY KEY NOT NULL, "type" varchar CHECK( "type" IN ('naturalPerson','organization') ) NOT NULL, "origin" varchar CHECK( "origin" IN ('INTERNAL', 'EXTERNAL') ) NOT NULL, "name" varchar(255) NOT NULL, "description" varchar(255), "tenant_id" varchar(255) NOT NULL, "created_at" datetime NOT NULL DEFAULT (datetime('now')), "last_updated_at" datetime NOT NULL DEFAULT (datetime('now')), CONSTRAINT "UQ_PartyType_name" UNIQUE ("name"))`);
7374
- await queryRunner.query(`CREATE UNIQUE INDEX "IDX_PartyType_type_tenant_id" ON "PartyType" ("type", "tenant_id")`);
7375
- await queryRunner.query(`CREATE TABLE "BaseContact" ("id" varchar PRIMARY KEY NOT NULL, "created_at" datetime NOT NULL DEFAULT (datetime('now')), "last_updated_at" datetime NOT NULL DEFAULT (datetime('now')), "legal_name" varchar(255), "display_name" varchar(255), "first_name" varchar(255), "middle_name" varchar(255), "last_name" varchar(255), "type" varchar NOT NULL, "party_id" varchar, CONSTRAINT "UQ_BaseContact_legal_name" UNIQUE ("legal_name"), CONSTRAINT "REL_BaseContact_party_id" UNIQUE ("party_id"))`);
7376
- await queryRunner.query(`CREATE INDEX "IDX_BaseContact_type" ON "BaseContact" ("type")`);
7377
- await queryRunner.query(`CREATE TABLE "PartyRelationship" ("id" varchar PRIMARY KEY NOT NULL, "left_id" varchar NOT NULL, "right_id" varchar NOT NULL, "created_at" datetime NOT NULL DEFAULT (datetime('now')), "last_updated_at" datetime NOT NULL DEFAULT (datetime('now')))`);
7378
- await queryRunner.query(`CREATE UNIQUE INDEX "IDX_PartyRelationship_left_right" ON "PartyRelationship" ("left_id", "right_id")`);
7379
- await queryRunner.query(`CREATE TABLE "Party" ("id" varchar PRIMARY KEY NOT NULL, "uri" varchar(255) NOT NULL, "created_at" datetime NOT NULL DEFAULT (datetime('now')), "last_updated_at" datetime NOT NULL DEFAULT (datetime('now')), "party_type_id" varchar NOT NULL)`);
7380
- await queryRunner.query(`CREATE TABLE "BaseConfig" ("id" varchar PRIMARY KEY NOT NULL, "identifier" varchar(255), "redirect_url" varchar(255), "session_id" varchar(255), "client_id" varchar(255), "client_secret" varchar(255), "scopes" text, "issuer" varchar(255), "dangerously_allow_insecure_http_requests" boolean, "client_auth_method" text, "type" varchar NOT NULL, "connection_id" varchar, CONSTRAINT "REL_BaseConfig_connection_id" UNIQUE ("connection_id"))`);
7381
- await queryRunner.query(`CREATE INDEX "IDX_BaseConfig_type" ON "BaseConfig" ("type")`);
7382
- await queryRunner.query(`CREATE TABLE "temporary_CorrelationIdentifier" ("id" varchar PRIMARY KEY NOT NULL, "type" varchar CHECK( "type" IN ('did','url') ) NOT NULL, "correlation_id" text NOT NULL, "identity_id" varchar, CONSTRAINT "REL_CorrelationIdentifier_identity_id" UNIQUE ("identity_id"), CONSTRAINT "UQ_CorrelationIdentifier_correlation_id" UNIQUE ("correlation_id"), CONSTRAINT "FK_CorrelationIdentifier_identity_id" FOREIGN KEY ("identity_id") REFERENCES "Identity" ("id") ON DELETE CASCADE ON UPDATE NO ACTION)`);
7383
- await queryRunner.query(`INSERT INTO "temporary_CorrelationIdentifier"("id", "type", "correlation_id", "identity_id") SELECT "id", "type", "correlation_id", "identity_id" FROM "CorrelationIdentifier"`);
7384
- await queryRunner.query(`DROP TABLE "CorrelationIdentifier"`);
7385
- await queryRunner.query(`ALTER TABLE "temporary_CorrelationIdentifier" RENAME TO "CorrelationIdentifier"`);
7386
- await queryRunner.query(`DROP INDEX "IDX_BaseContact_type"`);
7387
- await queryRunner.query(`CREATE TABLE "temporary_BaseContact" ("id" varchar PRIMARY KEY NOT NULL, "created_at" datetime NOT NULL DEFAULT (datetime('now')), "last_updated_at" datetime NOT NULL DEFAULT (datetime('now')), "legal_name" varchar(255), "display_name" varchar(255), "first_name" varchar(255), "middle_name" varchar(255), "last_name" varchar(255), "type" varchar NOT NULL, "party_id" varchar, CONSTRAINT "UQ_BaseContact_legal_name" UNIQUE ("legal_name"), CONSTRAINT "REL_BaseContact_party_id" UNIQUE ("party_id"), CONSTRAINT "FK_BaseContact_party_id" FOREIGN KEY ("party_id") REFERENCES "Party" ("id") ON DELETE CASCADE ON UPDATE NO ACTION)`);
7388
- await queryRunner.query(`INSERT INTO "temporary_BaseContact"("id", "created_at", "last_updated_at", "legal_name", "display_name", "first_name", "middle_name", "last_name", "type", "party_id") SELECT "id", "created_at", "last_updated_at", "legal_name", "display_name", "first_name", "middle_name", "last_name", "type", "party_id" FROM "BaseContact"`);
7389
- await queryRunner.query(`DROP TABLE "BaseContact"`);
7390
- await queryRunner.query(`ALTER TABLE "temporary_BaseContact" RENAME TO "BaseContact"`);
7391
- await queryRunner.query(`CREATE INDEX "IDX_BaseContact_type" ON "BaseContact" ("type")`);
7392
- await queryRunner.query(`DROP INDEX "IDX_PartyRelationship_left_right"`);
7393
- await queryRunner.query(`CREATE TABLE "temporary_PartyRelationship" ("id" varchar PRIMARY KEY NOT NULL, "left_id" varchar NOT NULL, "right_id" varchar NOT NULL, "created_at" datetime NOT NULL DEFAULT (datetime('now')), "last_updated_at" datetime NOT NULL DEFAULT (datetime('now')), CONSTRAINT "FK_PartyRelationship_left_id" FOREIGN KEY ("left_id") REFERENCES "Party" ("id") ON DELETE CASCADE ON UPDATE NO ACTION, CONSTRAINT "FK_PartyRelationship_right_id" FOREIGN KEY ("right_id") REFERENCES "Party" ("id") ON DELETE CASCADE ON UPDATE NO ACTION)`);
7394
- await queryRunner.query(`INSERT INTO "temporary_PartyRelationship"("id", "left_id", "right_id", "created_at", "last_updated_at") SELECT "id", "left_id", "right_id", "created_at", "last_updated_at" FROM "PartyRelationship"`);
7395
- await queryRunner.query(`DROP TABLE "PartyRelationship"`);
7396
- await queryRunner.query(`ALTER TABLE "temporary_PartyRelationship" RENAME TO "PartyRelationship"`);
7397
- await queryRunner.query(`CREATE UNIQUE INDEX "IDX_PartyRelationship_left_right" ON "PartyRelationship" ("left_id", "right_id")`);
7398
- await queryRunner.query(`CREATE TABLE "ElectronicAddress" ("id" varchar PRIMARY KEY NOT NULL, "type" varchar(255) NOT NULL, "electronic_address" varchar(255) NOT NULL, "created_at" datetime NOT NULL DEFAULT (datetime('now')), "last_updated_at" datetime NOT NULL DEFAULT (datetime('now')), "partyId" varchar, CONSTRAINT "FK_ElectronicAddress_partyId" FOREIGN KEY ("partyId") REFERENCES "Party" ("id") ON DELETE CASCADE ON UPDATE NO ACTION)`);
7399
- await queryRunner.query(`CREATE TABLE "PhysicalAddress" ("id" varchar PRIMARY KEY NOT NULL, "type" varchar(255) NOT NULL, "street_name" varchar(255) NOT NULL, "street_number" varchar(255) NOT NULL, "postal_code" varchar(255) NOT NULL, "city_name" varchar(255) NOT NULL, "province_name" varchar(255) NOT NULL, "country_code" varchar(2) NOT NULL, "building_name" varchar(255), "partyId" varchar, "created_at" datetime NOT NULL DEFAULT (datetime('now')), "last_updated_at" datetime NOT NULL DEFAULT (datetime('now')), CONSTRAINT "FK_PhysicalAddressEntity_partyId" FOREIGN KEY ("partyId") REFERENCES "Party" ("id") ON DELETE CASCADE ON UPDATE NO ACTION)`);
7400
- await queryRunner.query(`CREATE TABLE "temporary_Party" ("id" varchar PRIMARY KEY NOT NULL, "uri" varchar(255), "created_at" datetime NOT NULL DEFAULT (datetime('now')), "last_updated_at" datetime NOT NULL DEFAULT (datetime('now')), "party_type_id" varchar NOT NULL, CONSTRAINT "FK_Party_party_type_id" FOREIGN KEY ("party_type_id") REFERENCES "PartyType" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION)`);
7401
- await queryRunner.query(`INSERT INTO "temporary_Party"("id", "uri", "created_at", "last_updated_at", "party_type_id") SELECT "id", "uri", "created_at", "last_updated_at", "party_type_id" FROM "Party"`);
7402
- await queryRunner.query(`DROP TABLE "Party"`);
7403
- await queryRunner.query(`ALTER TABLE "temporary_Party" RENAME TO "Party"`);
7404
- await queryRunner.query(`CREATE TABLE "temporary_Identity" ("id" varchar PRIMARY KEY NOT NULL, "alias" varchar(255) NOT NULL, "roles" text NOT NULL, "created_at" datetime NOT NULL DEFAULT (datetime('now')), "last_updated_at" datetime NOT NULL DEFAULT (datetime('now')), "partyId" varchar, CONSTRAINT "UQ_Identity_alias" UNIQUE ("alias"), CONSTRAINT "FK_Identity_partyId" FOREIGN KEY ("partyId") REFERENCES "Party" ("id") ON DELETE CASCADE ON UPDATE NO ACTION)`);
7405
- await queryRunner.query(`INSERT INTO "temporary_Identity"("id", "alias", "roles", "created_at", "last_updated_at", "partyId") SELECT "id", "alias", "roles", "created_at", "last_updated_at", "partyId" FROM "Identity"`);
7406
- await queryRunner.query(`DROP TABLE "Identity"`);
7407
- await queryRunner.query(`ALTER TABLE "temporary_Identity" RENAME TO "Identity"`);
7408
- await queryRunner.query(`CREATE TABLE "temporary_Connection" ("id" varchar PRIMARY KEY NOT NULL, "type" varchar CHECK( "type" IN ('OIDC','SIOPv2','SIOPv2+OpenID4VP') ) NOT NULL, "identity_id" varchar, CONSTRAINT "REL_Connection_identity_id" UNIQUE ("identity_id"), CONSTRAINT "FK_Connection_identity_id" FOREIGN KEY ("identity_id") REFERENCES "Identity" ("id") ON DELETE CASCADE ON UPDATE NO ACTION)`);
7409
- await queryRunner.query(`INSERT INTO "temporary_Connection"("id", "type", "identity_id") SELECT "id", "type", "identity_id" FROM "Connection"`);
7410
- await queryRunner.query(`DROP TABLE "Connection"`);
7411
- await queryRunner.query(`ALTER TABLE "temporary_Connection" RENAME TO "Connection"`);
7412
- await queryRunner.query(`DROP INDEX "IDX_BaseConfig_type"`);
7413
- await queryRunner.query(`CREATE TABLE "temporary_BaseConfig" ("id" varchar PRIMARY KEY NOT NULL, "identifier" varchar(255), "redirect_url" varchar(255), "session_id" varchar(255), "client_id" varchar(255), "client_secret" varchar(255), "scopes" text, "issuer" varchar(255), "dangerously_allow_insecure_http_requests" boolean, "client_auth_method" text, "type" varchar NOT NULL, "connection_id" varchar, CONSTRAINT "REL_BaseConfig_connection_id" UNIQUE ("connection_id"), CONSTRAINT "FK_BaseConfig_connection_id" FOREIGN KEY ("connection_id") REFERENCES "Connection" ("id") ON DELETE CASCADE ON UPDATE NO ACTION)`);
7414
- await queryRunner.query(`INSERT INTO "temporary_BaseConfig"("id", "identifier", "redirect_url", "session_id", "client_id", "client_secret", "scopes", "issuer", "dangerously_allow_insecure_http_requests", "client_auth_method", "type", "connection_id") SELECT "id", "identifier", "redirect_url", "session_id", "client_id", "client_secret", "scopes", "issuer", "dangerously_allow_insecure_http_requests", "client_auth_method", "type", "connection_id" FROM "BaseConfig"`);
7415
- await queryRunner.query(`DROP TABLE "BaseConfig"`);
7416
- await queryRunner.query(`ALTER TABLE "temporary_BaseConfig" RENAME TO "BaseConfig"`);
7417
- await queryRunner.query(`CREATE INDEX "IDX_BaseConfig_type" ON "BaseConfig" ("type")`);
7418
- await queryRunner.query(`INSERT INTO "BaseConfig"("id", "identifier", "redirect_url", "session_id", "client_id", "client_secret", "scopes", "issuer", "dangerously_allow_insecure_http_requests", "client_auth_method", "type", "connection_id") SELECT "id", "identifier", "redirect_url", "session_id", "client_id", "client_secret", "scopes", "issuer", "dangerously_allow_insecure_http_requests", "client_auth_method", "type", "connectionId" FROM "BaseConfigEntity"`);
7419
- await queryRunner.query(`DROP TABLE "BaseConfigEntity"`);
7420
- await queryRunner.query(`INSERT INTO "PartyType"(id, type, origin, name, description, tenant_id, created_at, last_updated_at) VALUES ('3875c12e-fdaa-4ef6-a340-c936e054b627', 'organization', 'INTERNAL', 'Sphereon_default_organization_type', 'sphereon_default_organization', '95e09cfc-c974-4174-86aa-7bf1d5251fb4', datetime('now'), datetime('now'))`);
7421
- await queryRunner.query(`INSERT INTO "PartyType"(id, type, origin, name, description, tenant_id, created_at, last_updated_at) VALUES ('7d248798-41ca-4fc1-a130-9934b43d532e', 'naturalPerson', 'INTERNAL', 'Sphereon_default_natural_person_type', 'sphereon_default_natural_person', '95e09cfc-c974-4174-86aa-7bf1d5251fb4', datetime('now'), datetime('now'))`);
7422
- await queryRunner.query(`INSERT INTO "Party"(id, uri, created_at, last_updated_at, party_type_id) SELECT id, uri, created_at, last_updated_at, '3875c12e-fdaa-4ef6-a340-c936e054b627' FROM "Contact"`);
7423
- await queryRunner.query(`INSERT INTO "BaseContact"(id, legal_name, display_name, party_id, created_at, last_updated_at, type) SELECT id, name, alias, id, created_at, last_updated_at, 'Organization' FROM "Contact"`);
7424
- await queryRunner.query(`DROP TABLE "Contact"`);
7526
+ await queryRunner.startTransaction();
7527
+ await queryRunner.query(`ALTER TYPE "StatusList_type_enum" ADD VALUE 'BitstringStatusList'`);
7528
+ await queryRunner.commitTransaction();
7425
7529
  }
7530
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
7426
7531
  async down(queryRunner) {
7427
- await queryRunner.query(`CREATE TABLE "Contact" ("id" varchar PRIMARY KEY NOT NULL, "uri" varchar(255), "created_at" datetime NOT NULL DEFAULT (datetime('now')), "last_updated_at" datetime NOT NULL DEFAULT (datetime('now')), "name" varchar(255), "alias" varchar(255))`);
7428
- await queryRunner.query(`INSERT INTO "Contact"(id, uri, created_at, last_updated_at, name, alias) SELECT id, uri, created_at, last_updated_at, (SELECT legal_name FROM "BaseContact" WHERE "BaseContact"."party_id" = "Party"."id"), (SELECT display_name FROM "BaseContact" WHERE "BaseContact"."party_id" = "Party"."id") FROM "Party" WHERE party_type_id = '3875c12e-fdaa-4ef6-a340-c936e054b627'`);
7429
- await queryRunner.query(`DROP TABLE "BaseContact"`);
7430
- await queryRunner.query(`DROP TABLE "Party"`);
7431
- await queryRunner.query(`CREATE TABLE "BaseConfigEntity" ("id" varchar PRIMARY KEY NOT NULL, "identifier" varchar(255), "redirect_url" varchar(255), "session_id" varchar(255), "client_id" varchar(255), "client_secret" varchar(255), "scopes" text, "issuer" varchar(255), "dangerously_allow_insecure_http_requests" boolean, "client_auth_method" text, "type" varchar NOT NULL, "connectionId" varchar)`);
7432
- await queryRunner.query(`INSERT INTO "BaseConfigEntity"("id", "identifier", "redirect_url", "session_id", "client_id", "client_secret", "scopes", "issuer", "dangerously_allow_insecure_http_requests", "client_auth_method", "type", "connectionId") SELECT "id", "identifier", "redirect_url", "session_id", "client_id", "client_secret", "scopes", "issuer", "dangerously_allow_insecure_http_requests", "client_auth_method", "type", "connection_id" FROM "BaseConfig"`);
7433
- await queryRunner.query(`DROP TABLE "BaseConfig"`);
7434
- await queryRunner.query(`CREATE TABLE "temporary_Party" ("id" varchar PRIMARY KEY NOT NULL, "uri" varchar(255), "created_at" datetime NOT NULL DEFAULT (datetime('now')), "last_updated_at" datetime NOT NULL DEFAULT (datetime('now')), "party_type_id" varchar NOT NULL, CONSTRAINT "FK_Party_party_type_id" FOREIGN KEY ("party_type_id") REFERENCES "PartyType" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION)`);
7435
- await queryRunner.query(`INSERT INTO "temporary_Party"("id", "uri", "created_at", "last_updated_at", "party_type_id") SELECT "id", "uri", "created_at", "last_updated_at", "party_type_id" FROM "Party"`);
7436
- await queryRunner.query(`DROP TABLE "Party"`);
7437
- await queryRunner.query(`ALTER TABLE "temporary_Party" RENAME TO "Party"`);
7438
- await queryRunner.query(`DROP INDEX "IDX_PartyRelationship_left_right"`);
7439
- await queryRunner.query(`CREATE TABLE "temporary_PartyRelationship" ("id" varchar PRIMARY KEY NOT NULL, "left_id" varchar NOT NULL, "right_id" varchar NOT NULL, "created_at" datetime NOT NULL DEFAULT (datetime('now')), "last_updated_at" datetime NOT NULL DEFAULT (datetime('now')), CONSTRAINT "FK_PartyRelationship_left_id" FOREIGN KEY ("left_id") REFERENCES "Party" ("id") ON DELETE CASCADE ON UPDATE NO ACTION, CONSTRAINT "FK_PartyRelationship_right_id" FOREIGN KEY ("right_id") REFERENCES "Party" ("id") ON DELETE CASCADE ON UPDATE NO ACTION)`);
7440
- await queryRunner.query(`INSERT INTO "temporary_PartyRelationship"("id", "left_id", "right_id", "created_at", "last_updated_at") SELECT "id", "left_id", "right_id", "created_at", "last_updated_at" FROM "PartyRelationship"`);
7441
- await queryRunner.query(`DROP TABLE "PartyRelationship"`);
7442
- await queryRunner.query(`ALTER TABLE "temporary_PartyRelationship" RENAME TO "PartyRelationship"`);
7443
- await queryRunner.query(`CREATE UNIQUE INDEX "IDX_PartyRelationship_left_right" ON "PartyRelationship" ("left_id", "right_id")`);
7444
- await queryRunner.query(`DROP INDEX "IDX_BaseContact_type"`);
7445
- await queryRunner.query(`CREATE TABLE "temporary_BaseContact" ("id" varchar PRIMARY KEY NOT NULL, "created_at" datetime NOT NULL DEFAULT (datetime('now')), "last_updated_at" datetime NOT NULL DEFAULT (datetime('now')), "legal_name" varchar(255), "display_name" varchar(255), "first_name" varchar(255), "middle_name" varchar(255), "last_name" varchar(255), "type" varchar NOT NULL, "party_id" varchar, CONSTRAINT "UQ_BaseContact_legal_name" UNIQUE ("legal_name"), CONSTRAINT "REL_BaseContact_party_id" UNIQUE ("party_id"), CONSTRAINT "FK_BaseContact_party_id" FOREIGN KEY ("party_id") REFERENCES "Party" ("id") ON DELETE CASCADE ON UPDATE NO ACTION)`);
7446
- await queryRunner.query(`INSERT INTO "temporary_BaseContact"("id", "created_at", "last_updated_at", "legal_name", "display_name", "first_name", "middle_name", "last_name", "type", "party_id") SELECT "id", "created_at", "last_updated_at", "legal_name", "display_name", "first_name", "middle_name", "last_name", "type", "party_id" FROM "BaseContact"`);
7447
- await queryRunner.query(`DROP TABLE "BaseContact"`);
7448
- await queryRunner.query(`ALTER TABLE "temporary_BaseContact" RENAME TO "BaseContact"`);
7449
- await queryRunner.query(`CREATE INDEX "IDX_BaseContact_type" ON "BaseContact" ("type")`);
7450
- await queryRunner.query(`DROP INDEX "IDX_BaseConfig_type"`);
7451
- await queryRunner.query(`CREATE TABLE "temporary_BaseConfig" ("id" varchar PRIMARY KEY NOT NULL, "identifier" varchar(255), "redirect_url" varchar(255), "session_id" varchar(255), "client_id" varchar(255), "client_secret" varchar(255), "scopes" text, "issuer" varchar(255), "dangerously_allow_insecure_http_requests" boolean, "client_auth_method" text, "type" varchar NOT NULL, "connection_id" varchar, CONSTRAINT "REL_BaseConfig_connection_id" UNIQUE ("connection_id"), CONSTRAINT "FK_BaseConfig_connection_id" FOREIGN KEY ("connection_id") REFERENCES "Connection" ("id") ON DELETE CASCADE ON UPDATE NO ACTION)`);
7452
- await queryRunner.query(`INSERT INTO "temporary_BaseConfig"("id", "identifier", "redirect_url", "session_id", "client_id", "client_secret", "scopes", "issuer", "dangerously_allow_insecure_http_requests", "client_auth_method", "type", "connection_id") SELECT "id", "identifier", "redirect_url", "session_id", "client_id", "client_secret", "scopes", "issuer", "dangerously_allow_insecure_http_requests", "client_auth_method", "type", "connection_id" FROM "BaseConfig"`);
7453
- await queryRunner.query(`DROP TABLE "BaseConfig"`);
7454
- await queryRunner.query(`ALTER TABLE "temporary_BaseConfig" RENAME TO "BaseConfig"`);
7455
- await queryRunner.query(`CREATE INDEX "IDX_BaseConfig_type" ON "BaseConfig" ("type")`);
7456
- await queryRunner.query(`DROP INDEX "IDX_PartyType_type_tenant_id"`);
7457
- await queryRunner.query(`DROP TABLE "PartyType"`);
7458
- await queryRunner.query(`DROP TABLE "Connection"`);
7459
- await queryRunner.query(`DROP TABLE "Identity"`);
7460
- await queryRunner.query(`DROP TABLE "CorrelationIdentifier"`);
7461
- await queryRunner.query(`DROP TABLE "ElectronicAddress"`);
7462
- await queryRunner.query(`DROP TABLE "PhysicalAddress"`);
7532
+ }
7533
+ };
7534
+ var CreateBitstringStatusListPG1741895823000 = class {
7535
+ static {
7536
+ __name(this, "CreateBitstringStatusListPG1741895823000");
7537
+ }
7538
+ name = "CreateBitstringStatusList1741895823000";
7539
+ async up(queryRunner) {
7540
+ await queryRunner.query(`ALTER TABLE "StatusList" ADD COLUMN "ttl" integer`);
7541
+ await queryRunner.query(`ALTER TABLE "StatusList" ADD COLUMN "validFrom" TIMESTAMP`);
7542
+ await queryRunner.query(`ALTER TABLE "StatusList" ADD COLUMN "validUntil" TIMESTAMP`);
7543
+ await queryRunner.query(`ALTER TABLE "StatusList" DROP CONSTRAINT IF EXISTS "CHK_StatusList_type"`);
7544
+ await queryRunner.query(`ALTER TABLE "StatusList" ADD CONSTRAINT "CHK_StatusList_type" CHECK ("type" IN ('StatusList2021', 'OAuthStatusList', 'BitstringStatusList'))`);
7545
+ await queryRunner.query(`ALTER TABLE "StatusListEntry" ADD COLUMN "type" character varying NOT NULL DEFAULT 'StatusListEntryEntity'`);
7546
+ await queryRunner.query(`ALTER TABLE "StatusListEntry" ADD COLUMN "statusPurpose" character varying`);
7547
+ await queryRunner.query(`ALTER TABLE "StatusListEntry" ADD COLUMN "statusMessage" text`);
7548
+ await queryRunner.query(`ALTER TABLE "StatusListEntry" ADD COLUMN "statusReference" text`);
7549
+ await queryRunner.query(`ALTER TABLE "StatusListEntry" ADD CONSTRAINT "CHK_StatusListEntry_type" CHECK ("type" IN ('StatusListEntryEntity', 'bitstring'))`);
7550
+ }
7551
+ async down(queryRunner) {
7552
+ await queryRunner.query(`ALTER TABLE "StatusListEntry" DROP CONSTRAINT "CHK_StatusListEntry_type"`);
7553
+ await queryRunner.query(`ALTER TABLE "StatusListEntry" DROP COLUMN "statusReference"`);
7554
+ await queryRunner.query(`ALTER TABLE "StatusListEntry" DROP COLUMN "statusMessage"`);
7555
+ await queryRunner.query(`ALTER TABLE "StatusListEntry" DROP COLUMN "bitsPerStatus"`);
7556
+ await queryRunner.query(`ALTER TABLE "StatusListEntry" DROP COLUMN "statusPurpose"`);
7557
+ await queryRunner.query(`ALTER TABLE "StatusListEntry" DROP COLUMN "type"`);
7558
+ await queryRunner.query(`ALTER TABLE "StatusList" DROP CONSTRAINT "CHK_StatusList_type"`);
7559
+ await queryRunner.query(`ALTER TABLE "StatusList" ADD CONSTRAINT "CHK_StatusList_type" CHECK ("type" IN ('StatusList2021', 'OAuthStatusList'))`);
7560
+ await queryRunner.query(`ALTER TABLE "StatusList" DROP COLUMN "validUntil"`);
7561
+ await queryRunner.query(`ALTER TABLE "StatusList" DROP COLUMN "validFrom"`);
7562
+ await queryRunner.query(`ALTER TABLE "StatusList" DROP COLUMN "ttl"`);
7563
+ await queryRunner.query(`ALTER TABLE "StatusList" DROP COLUMN "bitsPerStatus"`);
7463
7564
  }
7464
7565
  };
7465
7566
 
7466
- // src/migrations/postgres/1690925872592-CreateContacts.ts
7467
- import { enablePostgresUuidExtension as enablePostgresUuidExtension3 } from "@sphereon/ssi-sdk.core";
7468
- var CreateContacts1690925872592 = class {
7567
+ // src/migrations/sqlite/1741895823001-CreateBitstringStatusList.ts
7568
+ var CreateBitstringStatusListSqlite1741895823001 = class {
7469
7569
  static {
7470
- __name(this, "CreateContacts1690925872592");
7570
+ __name(this, "CreateBitstringStatusListSqlite1741895823001");
7471
7571
  }
7472
- name = "CreateContacts1690925872592";
7572
+ name = "CreateBitstringStatusList1741895823000";
7473
7573
  async up(queryRunner) {
7474
- await enablePostgresUuidExtension3(queryRunner);
7475
- await queryRunner.query(`ALTER TABLE "CorrelationIdentifier" DROP CONSTRAINT "FK_CorrelationIdentifier_identityId"`);
7476
- await queryRunner.query(`ALTER TABLE "IdentityMetadata" DROP CONSTRAINT "FK_IdentityMetadata_identityId"`);
7477
- await queryRunner.query(`ALTER TABLE "Identity" DROP CONSTRAINT "FK_Identity_contactId"`);
7478
- await queryRunner.query(`ALTER TABLE "Connection" DROP CONSTRAINT "FK_Connection_identityId"`);
7479
- await queryRunner.query(`ALTER TABLE "CorrelationIdentifier" RENAME COLUMN "identityId" TO "identity_id"`);
7480
- await queryRunner.query(`ALTER TABLE "Connection" RENAME COLUMN "identityId" TO "identity_id"`);
7481
- await queryRunner.query(`CREATE TYPE "public"."PartyType_type_enum" AS ENUM('naturalPerson', 'organization')`);
7482
- await queryRunner.query(`CREATE TYPE "public"."PartyOrigin_type_enum" AS ENUM('INTERNAL', 'EXTERNAL')`);
7483
- await queryRunner.query(`CREATE TABLE "PartyType" ("id" uuid NOT NULL DEFAULT uuid_generate_v4(), "type" "public"."PartyType_type_enum" NOT NULL, "origin" "public"."PartyOrigin_type_enum" NOT NULL, "name" character varying(255) NOT NULL, "description" character varying(255), "tenant_id" character varying(255) NOT NULL, "created_at" TIMESTAMP NOT NULL DEFAULT now(), "last_updated_at" TIMESTAMP NOT NULL DEFAULT now(), CONSTRAINT "UQ_PartyType_name" UNIQUE ("name"), CONSTRAINT "PK_PartyType_id" PRIMARY KEY ("id"))`);
7484
- await queryRunner.query(`CREATE UNIQUE INDEX "IDX_PartyType_type_tenant_id" ON "PartyType" ("type", "tenant_id")`);
7485
- await queryRunner.query(`CREATE TABLE "BaseContact" ("id" uuid NOT NULL DEFAULT uuid_generate_v4(), "created_at" TIMESTAMP NOT NULL DEFAULT now(), "last_updated_at" TIMESTAMP NOT NULL DEFAULT now(), "legal_name" character varying(255), "display_name" character varying(255), "first_name" character varying(255), "middle_name" character varying(255), "last_name" character varying(255), "type" character varying NOT NULL, "party_id" uuid, CONSTRAINT "UQ_BaseContact_legal_name" UNIQUE ("legal_name"), CONSTRAINT "REL_BaseContact_party_id" UNIQUE ("party_id"), CONSTRAINT "PK_BaseContact_id" PRIMARY KEY ("id"))`);
7486
- await queryRunner.query(`CREATE INDEX "IDX_BaseContact_type" ON "BaseContact" ("type")`);
7487
- await queryRunner.query(`CREATE TABLE "PartyRelationship" ("id" uuid NOT NULL DEFAULT uuid_generate_v4(), "left_id" uuid NOT NULL, "right_id" uuid NOT NULL, "created_at" TIMESTAMP NOT NULL DEFAULT now(), "last_updated_at" TIMESTAMP NOT NULL DEFAULT now(), CONSTRAINT "PK_PartyRelationship_id" PRIMARY KEY ("id"))`);
7488
- await queryRunner.query(`CREATE UNIQUE INDEX "IDX_PartyRelationship_left_right" ON "PartyRelationship" ("left_id", "right_id")`);
7489
- await queryRunner.query(`CREATE TABLE "ElectronicAddress" ("id" uuid NOT NULL DEFAULT uuid_generate_v4(), "type" character varying(255) NOT NULL, "electronic_address" character varying(255) NOT NULL, "created_at" TIMESTAMP NOT NULL DEFAULT now(), "last_updated_at" TIMESTAMP NOT NULL DEFAULT now(), "partyId" uuid, CONSTRAINT "PK_ElectronicAddress_id" PRIMARY KEY ("id"))`);
7490
- await queryRunner.query(`CREATE TABLE "PhysicalAddress" ("id" uuid NOT NULL DEFAULT uuid_generate_v4(), "type" character varying(255) NOT NULL, "street_name" character varying(255) NOT NULL, "street_number" character varying(255) NOT NULL, "postal_code" character varying(255) NOT NULL, "city_name" character varying(255) NOT NULL, "province_name" character varying(255) NOT NULL, "country_code" character varying(2) NOT NULL, "building_name" character varying(255), "partyId" uuid, "created_at" TIMESTAMP NOT NULL DEFAULT now(), "last_updated_at" TIMESTAMP NOT NULL DEFAULT now(), CONSTRAINT "PK_PhysicalAddress_id" PRIMARY KEY ("id"))`);
7491
- await queryRunner.query(`CREATE TABLE "Party" ("id" uuid NOT NULL DEFAULT uuid_generate_v4(), "uri" character varying(255), "created_at" TIMESTAMP NOT NULL DEFAULT now(), "last_updated_at" TIMESTAMP NOT NULL DEFAULT now(), "party_type_id" uuid NOT NULL, CONSTRAINT "PK_Party_id" PRIMARY KEY ("id"))`);
7492
- await queryRunner.query(`CREATE TABLE "BaseConfig" ("id" uuid NOT NULL DEFAULT uuid_generate_v4(), "identifier" character varying(255), "redirect_url" character varying(255), "session_id" character varying(255), "client_id" character varying(255), "client_secret" character varying(255), "scopes" text, "issuer" character varying(255), "dangerously_allow_insecure_http_requests" boolean, "client_auth_method" text, "type" character varying NOT NULL, "connection_id" uuid, CONSTRAINT "REL_BaseConfig_connection_id" UNIQUE ("connection_id"), CONSTRAINT "PK_BaseConfig_id" PRIMARY KEY ("id"))`);
7493
- await queryRunner.query(`CREATE INDEX "IDX_BaseConfig_type" ON "BaseConfig" ("type")`);
7494
- await queryRunner.query(`ALTER TABLE "Identity" RENAME COLUMN "contactId" TO "partyId"`);
7495
- await queryRunner.query(`ALTER TABLE "Identity" ALTER COLUMN "roles" SET NOT NULL`);
7496
- await queryRunner.query(`CREATE TYPE "public"."IdentityOrigin_type_enum" AS ENUM('INTERNAL', 'EXTERNAL')`);
7497
- await queryRunner.query(`ALTER TABLE "Identity" ADD COLUMN "origin" "public"."IdentityOrigin_type_enum" DEFAULT 'EXTERNAL' NOT NULL`);
7498
- await queryRunner.query(`ALTER TABLE "Identity" ALTER COLUMN "origin" DROP DEFAULT`);
7499
- await queryRunner.query(`ALTER TABLE "CorrelationIdentifier" ADD CONSTRAINT "FK_CorrelationIdentifier_identity_id" FOREIGN KEY ("identity_id") REFERENCES "Identity"("id") ON DELETE CASCADE ON UPDATE NO ACTION`);
7500
- await queryRunner.query(`ALTER TABLE "IdentityMetadata" ADD CONSTRAINT "FK_IdentityMetadata_identityId" FOREIGN KEY ("identityId") REFERENCES "Identity"("id") ON DELETE CASCADE ON UPDATE NO ACTION`);
7501
- await queryRunner.query(`ALTER TABLE "BaseContact" ADD CONSTRAINT "FK_BaseContact_party_id" FOREIGN KEY ("party_id") REFERENCES "Party"("id") ON DELETE CASCADE ON UPDATE NO ACTION`);
7502
- await queryRunner.query(`ALTER TABLE "PartyRelationship" ADD CONSTRAINT "FK_PartyRelationship_left_id" FOREIGN KEY ("left_id") REFERENCES "Party"("id") ON DELETE CASCADE ON UPDATE NO ACTION`);
7503
- await queryRunner.query(`ALTER TABLE "PartyRelationship" ADD CONSTRAINT "FK_PartyRelationship_right_id" FOREIGN KEY ("right_id") REFERENCES "Party"("id") ON DELETE CASCADE ON UPDATE NO ACTION`);
7504
- await queryRunner.query(`ALTER TABLE "ElectronicAddress" ADD CONSTRAINT "FK_ElectronicAddress_partyId" FOREIGN KEY ("partyId") REFERENCES "Party"("id") ON DELETE CASCADE ON UPDATE NO ACTION`);
7505
- await queryRunner.query(`ALTER TABLE "PhysicalAddress" ADD CONSTRAINT "FK_PhysicalAddress_partyId" FOREIGN KEY ("partyId") REFERENCES "Party" ("id") ON DELETE CASCADE ON UPDATE NO ACTION`);
7506
- await queryRunner.query(`ALTER TABLE "Party" ADD CONSTRAINT "FK_Party_party_type_id" FOREIGN KEY ("party_type_id") REFERENCES "PartyType"("id") ON DELETE NO ACTION ON UPDATE NO ACTION`);
7507
- await queryRunner.query(`ALTER TABLE "Identity" ADD CONSTRAINT "FK_Identity_partyId" FOREIGN KEY ("partyId") REFERENCES "Party"("id") ON DELETE CASCADE ON UPDATE NO ACTION`);
7508
- await queryRunner.query(`ALTER TABLE "Connection" ADD CONSTRAINT "FK_Connection_identity_id" FOREIGN KEY ("identity_id") REFERENCES "Identity"("id") ON DELETE CASCADE ON UPDATE NO ACTION`);
7509
- await queryRunner.query(`ALTER TABLE "BaseConfig" ADD CONSTRAINT "FK_BaseConfig_connection_id" FOREIGN KEY ("connection_id") REFERENCES "Connection"("id") ON DELETE CASCADE ON UPDATE NO ACTION`);
7510
- await queryRunner.query(`ALTER TABLE "CorrelationIdentifier" RENAME CONSTRAINT "UQ_Correlation_id" TO "UQ_CorrelationIdentifier_correlation_id"`);
7511
- await queryRunner.query(`ALTER TABLE "Identity" RENAME CONSTRAINT "UQ_Identity_Alias" TO "UQ_Identity_alias"`);
7512
- await queryRunner.query(`INSERT INTO "BaseConfig"("id", "identifier", "redirect_url", "session_id", "client_id", "client_secret", "scopes", "issuer", "dangerously_allow_insecure_http_requests", "client_auth_method", "type", "connection_id") SELECT "id", "identifier", "redirect_url", "session_id", "client_id", "client_secret", "scopes", "issuer", "dangerously_allow_insecure_http_requests", "client_auth_method", "type", "connectionId" FROM "BaseConfigEntity"`);
7513
- await queryRunner.query(`DROP TABLE "BaseConfigEntity"`);
7514
- await queryRunner.query(`INSERT INTO "PartyType"(id, type, origin, name, description, tenant_id, created_at, last_updated_at) VALUES ('3875c12e-fdaa-4ef6-a340-c936e054b627', 'organization', 'INTERNAL', 'Sphereon_default_organization_type', 'sphereon_default_organization', '95e09cfc-c974-4174-86aa-7bf1d5251fb4', now(), now())`);
7515
- await queryRunner.query(`INSERT INTO "PartyType"(id, type, origin, name, description, tenant_id, created_at, last_updated_at) VALUES ('7d248798-41ca-4fc1-a130-9934b43d532e', 'naturalPerson', 'INTERNAL', 'Sphereon_default_natural_person_type', 'sphereon_default_natural_person', '95e09cfc-c974-4174-86aa-7bf1d5251fb4', now(), now())`);
7516
- await queryRunner.query(`INSERT INTO "Party"(id, uri, created_at, last_updated_at, party_type_id) SELECT id, uri, created_at, last_updated_at, '3875c12e-fdaa-4ef6-a340-c936e054b627' FROM "Contact"`);
7517
- await queryRunner.query(`INSERT INTO "BaseContact"(id, legal_name, display_name, party_id, created_at, last_updated_at, type) SELECT id, name, alias, id, created_at, last_updated_at, 'Organization' FROM "Contact"`);
7518
- await queryRunner.query(`DROP TABLE "Contact"`);
7574
+ await queryRunner.query(`
7575
+ CREATE TABLE "temporary_StatusList" (
7576
+ "id" varchar PRIMARY KEY NOT NULL,
7577
+ "correlationId" varchar NOT NULL,
7578
+ "length" integer NOT NULL,
7579
+ "issuer" text NOT NULL,
7580
+ "type" varchar CHECK( "type" IN ('StatusList2021', 'OAuthStatusList', 'BitstringStatusList') ) NOT NULL DEFAULT ('StatusList2021'),
7581
+ "driverType" varchar CHECK( "driverType" IN ('agent_typeorm','agent_kv_store','github','agent_filesystem') ) NOT NULL DEFAULT ('agent_typeorm'),
7582
+ "credentialIdMode" varchar CHECK( "credentialIdMode" IN ('ISSUANCE','PERSISTENCE','NEVER') ) NOT NULL DEFAULT ('ISSUANCE'),
7583
+ "proofFormat" varchar CHECK( "proofFormat" IN ('lds','jwt', 'vc+jwt') ) NOT NULL DEFAULT ('lds'),
7584
+ "indexingDirection" varchar CHECK( "indexingDirection" IN ('rightToLeft') ),
7585
+ "statusPurpose" varchar,
7586
+ "statusListCredential" text,
7587
+ "expiresAt" datetime,
7588
+ "bitsPerStatus" integer DEFAULT (1),
7589
+ "ttl" integer,
7590
+ "validFrom" datetime,
7591
+ "validUntil" datetime,
7592
+ CONSTRAINT "UQ_correlationId" UNIQUE ("correlationId")
7593
+ )
7594
+ `);
7595
+ await queryRunner.query(`
7596
+ INSERT INTO "temporary_StatusList"(
7597
+ "id", "correlationId", "length", "issuer", "type", "driverType",
7598
+ "credentialIdMode", "proofFormat", "indexingDirection", "statusPurpose",
7599
+ "statusListCredential", "bitsPerStatus", "expiresAt"
7600
+ )
7601
+ SELECT
7602
+ "id", "correlationId", "length", "issuer", "type", "driverType",
7603
+ "credentialIdMode", "proofFormat", "indexingDirection", "statusPurpose",
7604
+ "statusListCredential", "bitsPerStatus", "expiresAt"
7605
+ FROM "StatusList"
7606
+ `);
7607
+ await queryRunner.query(`DROP TABLE "StatusList"`);
7608
+ await queryRunner.query(`ALTER TABLE "temporary_StatusList" RENAME TO "StatusList"`);
7609
+ await queryRunner.query(`
7610
+ CREATE TABLE "temporary_StatusListEntry" (
7611
+ "statusListId" varchar NOT NULL,
7612
+ "statusListIndex" integer NOT NULL,
7613
+ "credentialId" text,
7614
+ "credentialHash" varchar(128),
7615
+ "correlationId" varchar(255),
7616
+ "value" varchar(50),
7617
+ "type" varchar CHECK( "type" IN ('StatusListEntryEntity', 'bitstring') ) NOT NULL DEFAULT ('StatusListEntryEntity'),
7618
+ "statusPurpose" varchar,
7619
+ "bitsPerStatus" integer DEFAULT (1),
7620
+ "statusMessage" text,
7621
+ "statusReference" text,
7622
+ PRIMARY KEY ("statusListId", "statusListIndex")
7623
+ )
7624
+ `);
7625
+ await queryRunner.query(`
7626
+ INSERT INTO "temporary_StatusListEntry"(
7627
+ "statusListId", "statusListIndex", "credentialId", "credentialHash",
7628
+ "correlationId", "value", "type"
7629
+ )
7630
+ SELECT
7631
+ "statusListId", "statusListIndex", "credentialId", "credentialHash",
7632
+ "correlationId", "value", 'StatusListEntryEntity'
7633
+ FROM "StatusListEntry"
7634
+ `);
7635
+ await queryRunner.query(`DROP TABLE "StatusListEntry"`);
7636
+ await queryRunner.query(`ALTER TABLE "temporary_StatusListEntry" RENAME TO "StatusListEntry"`);
7519
7637
  }
7520
7638
  async down(queryRunner) {
7521
- await queryRunner.query(`ALTER TABLE "BaseConfig" DROP CONSTRAINT "FK_BaseConfig_connection_id"`);
7522
- await queryRunner.query(`ALTER TABLE "Connection" DROP CONSTRAINT "FK_Connection_identity_id"`);
7523
- await queryRunner.query(`ALTER TABLE "Identity" DROP CONSTRAINT "FK_Identity_partyId"`);
7524
- await queryRunner.query(`ALTER TABLE "Party" DROP CONSTRAINT "FK_Party_party_type_id"`);
7525
- await queryRunner.query(`ALTER TABLE "PhysicalAddress" DROP CONSTRAINT "FK_PhysicalAddress_partyId"`);
7526
- await queryRunner.query(`ALTER TABLE "ElectronicAddress" DROP CONSTRAINT "FK_ElectronicAddress_partyId"`);
7527
- await queryRunner.query(`ALTER TABLE "PartyRelationship" DROP CONSTRAINT "FK_PartyRelationship_right_id"`);
7528
- await queryRunner.query(`ALTER TABLE "PartyRelationship" DROP CONSTRAINT "FK_PartyRelationship_left_id"`);
7529
- await queryRunner.query(`ALTER TABLE "BaseContact" DROP CONSTRAINT "FK_BaseContact_party_id"`);
7530
- await queryRunner.query(`ALTER TABLE "IdentityMetadata" DROP CONSTRAINT "FK_IdentityMetadata_identityId"`);
7531
- await queryRunner.query(`ALTER TABLE "CorrelationIdentifier" DROP CONSTRAINT "FK_CorrelationIdentifier_identity_id"`);
7532
- await queryRunner.query(`ALTER TABLE "Identity" ALTER COLUMN "roles" DROP NOT NULL`);
7533
- await queryRunner.query(`ALTER TABLE "Identity" DROP COLUMN "origin"`);
7534
- await queryRunner.query(`DROP TYPE "public"."IdentityOrigin_type_enum"`);
7535
- await queryRunner.query(`ALTER TABLE "Identity" RENAME COLUMN "partyId" TO "contactId"`);
7536
- await queryRunner.query(`ALTER TABLE "Connection" RENAME COLUMN "identity_id" TO "identityId"`);
7537
- await queryRunner.query(`ALTER TABLE "CorrelationIdentifier" RENAME COLUMN "identity_id" TO "identityId"`);
7538
- await queryRunner.query(`DROP INDEX "IDX_BaseConfig_type"`);
7539
- await queryRunner.query(`DROP TABLE "BaseConfig"`);
7540
- await queryRunner.query(`DROP TABLE "Party"`);
7541
- await queryRunner.query(`DROP INDEX "IDX_PartyRelationship_left_right"`);
7542
- await queryRunner.query(`DROP TABLE "PartyRelationship"`);
7543
- await queryRunner.query(`DROP INDEX "IDX_BaseContact_type"`);
7544
- await queryRunner.query(`DROP TABLE "BaseContact"`);
7545
- await queryRunner.query(`DROP TABLE "ElectronicAddress"`);
7546
- await queryRunner.query(`DROP TABLE "PhysicalAddress"`);
7547
- await queryRunner.query(`DROP INDEX "IDX_PartyType_type_tenant_id"`);
7548
- await queryRunner.query(`DROP TABLE "PartyType"`);
7549
- await queryRunner.query(`DROP TYPE "public"."PartyOrigin_type_enum"`);
7550
- await queryRunner.query(`DROP TYPE "public"."PartyType_type_enum"`);
7551
- await queryRunner.query(`ALTER TABLE "Connection" ADD CONSTRAINT "FK_Connection_identityId" FOREIGN KEY ("identityId") REFERENCES "Identity"("id") ON DELETE CASCADE ON UPDATE NO ACTION`);
7552
- await queryRunner.query(`ALTER TABLE "Identity" ADD CONSTRAINT "FK_Identity_contactId" FOREIGN KEY ("contactId") REFERENCES "Contact"("id") ON DELETE CASCADE ON UPDATE NO ACTION`);
7553
- await queryRunner.query(`ALTER TABLE "IdentityMetadata" ADD CONSTRAINT "FK_IdentityMetadata_identityId" FOREIGN KEY ("identityId") REFERENCES "Identity"("id") ON DELETE CASCADE ON UPDATE NO ACTION`);
7554
- await queryRunner.query(`ALTER TABLE "CorrelationIdentifier" ADD CONSTRAINT "FK_CorrelationIdentifier_identityId" FOREIGN KEY ("identityId") REFERENCES "Identity"("id") ON DELETE CASCADE ON UPDATE NO ACTION`);
7555
- await queryRunner.query(`CREATE TABLE "Contact" ("id" uuid NOT NULL DEFAULT uuid_generate_v4(), "uri" character varying(255), "created_at" TIMESTAMP NOT NULL DEFAULT now(), "last_updated_at" TIMESTAMP NOT NULL DEFAULT now(), "name" character varying(255), "alias" character varying(255), CONSTRAINT "PK_Contact_id" PRIMARY KEY ("id"))`);
7556
- await queryRunner.query(`INSERT INTO "Contact"(id, uri, created_at, last_updated_at, name, alias) SELECT id, uri, created_at, last_updated_at, (SELECT legal_name FROM "BaseContact" WHERE "BaseContact"."party_id" = "Party"."id"), (SELECT display_name FROM "BaseContact" WHERE "BaseContact"."party_id" = "Party"."id") FROM "Party" WHERE party_type_id = '3875c12e-fdaa-4ef6-a340-c936e054b627'`);
7639
+ await queryRunner.query(`
7640
+ CREATE TABLE "temporary_StatusListEntry" (
7641
+ "statusListId" varchar NOT NULL,
7642
+ "statusListIndex" integer NOT NULL,
7643
+ "credentialId" text,
7644
+ "credentialHash" varchar(128),
7645
+ "correlationId" varchar(255),
7646
+ "value" varchar(50),
7647
+ PRIMARY KEY ("statusListId", "statusListIndex")
7648
+ )
7649
+ `);
7650
+ await queryRunner.query(`
7651
+ INSERT INTO "temporary_StatusListEntry"(
7652
+ "statusListId", "statusListIndex", "credentialId", "credentialHash",
7653
+ "correlationId", "value"
7654
+ )
7655
+ SELECT
7656
+ "statusListId", "statusListIndex", "credentialId", "credentialHash",
7657
+ "correlationId", "value"
7658
+ FROM "StatusListEntry"
7659
+ WHERE "type" = 'StatusListEntryEntity'
7660
+ `);
7661
+ await queryRunner.query(`DROP TABLE "StatusListEntry"`);
7662
+ await queryRunner.query(`ALTER TABLE "temporary_StatusListEntry" RENAME TO "StatusListEntry"`);
7663
+ await queryRunner.query(`
7664
+ CREATE TABLE "temporary_StatusList" (
7665
+ "id" varchar PRIMARY KEY NOT NULL,
7666
+ "correlationId" varchar NOT NULL,
7667
+ "length" integer NOT NULL,
7668
+ "issuer" text NOT NULL,
7669
+ "type" varchar CHECK( "type" IN ('StatusList2021', 'OAuthStatusList') ) NOT NULL DEFAULT ('StatusList2021'),
7670
+ "driverType" varchar CHECK( "driverType" IN ('agent_typeorm','agent_kv_store','github','agent_filesystem') ) NOT NULL DEFAULT ('agent_typeorm'),
7671
+ "credentialIdMode" varchar CHECK( "credentialIdMode" IN ('ISSUANCE','PERSISTENCE','NEVER') ) NOT NULL DEFAULT ('ISSUANCE'),
7672
+ "proofFormat" varchar CHECK( "proofFormat" IN ('lds','jwt', 'vc+jwt') ) NOT NULL DEFAULT ('lds'),
7673
+ "indexingDirection" varchar CHECK( "indexingDirection" IN ('rightToLeft') ),
7674
+ "statusPurpose" varchar,
7675
+ "statusListCredential" text,
7676
+ "bitsPerStatus" integer,
7677
+ "expiresAt" datetime,
7678
+ CONSTRAINT "UQ_correlationId" UNIQUE ("correlationId")
7679
+ )
7680
+ `);
7681
+ await queryRunner.query(`
7682
+ INSERT INTO "temporary_StatusList"(
7683
+ "id", "correlationId", "length", "issuer", "type", "driverType",
7684
+ "credentialIdMode", "proofFormat", "indexingDirection", "statusPurpose",
7685
+ "statusListCredential", "bitsPerStatus", "expiresAt"
7686
+ )
7687
+ SELECT
7688
+ "id", "correlationId", "length", "issuer",
7689
+ CASE WHEN "type" = 'BitstringStatusList' THEN 'StatusList2021' ELSE "type" END,
7690
+ "driverType", "credentialIdMode", "proofFormat", "indexingDirection",
7691
+ "statusPurpose", "statusListCredential", "bitsPerStatus", "expiresAt"
7692
+ FROM "StatusList"
7693
+ `);
7694
+ await queryRunner.query(`DROP TABLE "StatusList"`);
7695
+ await queryRunner.query(`ALTER TABLE "temporary_StatusList" RENAME TO "StatusList"`);
7557
7696
  }
7558
7697
  };
7559
7698
 
7560
- // src/migrations/generic/3-CreateContacts.ts
7561
- var debug10 = Debug10("sphereon:ssi-sdk:migrations");
7562
- var CreateContacts1690925872318 = class {
7699
+ // src/migrations/generic/12-CreateBitstringStatusList.ts
7700
+ var debug11 = Debug11("sphereon:ssi-sdk:migrations");
7701
+ var AddBitstringStatusListEnum1741895823000 = class {
7702
+ static {
7703
+ __name(this, "AddBitstringStatusListEnum1741895823000");
7704
+ }
7705
+ name = "AddBitstringStatusListEnum1741895823000";
7706
+ async up(queryRunner) {
7707
+ debug11("migration: creating bitstring status list tables");
7708
+ const dbType = queryRunner.connection.driver.options.type;
7709
+ switch (dbType) {
7710
+ case "postgres": {
7711
+ const mig = new AddBitstringStatusListEnumPG1741895823000();
7712
+ await mig.up(queryRunner);
7713
+ return;
7714
+ }
7715
+ case "sqlite":
7716
+ case "expo":
7717
+ case "react-native": {
7718
+ return;
7719
+ }
7720
+ default:
7721
+ return Promise.reject(`Migrations only supported for sqlite and postgres. Was ${dbType}`);
7722
+ }
7723
+ }
7724
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
7725
+ async down(queryRunner) {
7726
+ }
7727
+ };
7728
+ var CreateBitstringStatusList1741895823000 = class {
7563
7729
  static {
7564
- __name(this, "CreateContacts1690925872318");
7730
+ __name(this, "CreateBitstringStatusList1741895823000");
7565
7731
  }
7566
- name = "CreateContacts1690925872318";
7732
+ name = "CreateBitstringStatusList1741895823000";
7567
7733
  async up(queryRunner) {
7568
- debug10("migration: creating contacts tables");
7734
+ debug11("migration: creating bitstring status list tables");
7569
7735
  const dbType = queryRunner.connection.driver.options.type;
7570
7736
  switch (dbType) {
7571
7737
  case "postgres": {
7572
- debug10("using postgres migration file");
7573
- const mig = new CreateContacts1690925872592();
7738
+ const mig = new CreateBitstringStatusListPG1741895823000();
7574
7739
  await mig.up(queryRunner);
7575
- debug10("Migration statements executed");
7576
7740
  return;
7577
7741
  }
7578
7742
  case "sqlite":
7579
7743
  case "expo":
7580
7744
  case "react-native": {
7581
- debug10("using sqlite/react-native migration file");
7582
- const mig = new CreateContacts1690925872693();
7745
+ const mig = new CreateBitstringStatusListSqlite1741895823001();
7583
7746
  await mig.up(queryRunner);
7584
- debug10("Migration statements executed");
7585
7747
  return;
7586
7748
  }
7587
7749
  default:
7588
- return Promise.reject(`Migrations are currently only supported for sqlite, react-native, expo and postgres. Was ${dbType}. Please run your database without migrations and with 'migrationsRun: false' and 'synchronize: true' for now`);
7750
+ return Promise.reject(`Migrations only supported for sqlite and postgres. Was ${dbType}`);
7589
7751
  }
7590
7752
  }
7591
7753
  async down(queryRunner) {
7592
- debug10("migration: reverting contacts tables");
7754
+ debug11("migration: dropping bitstring status list tables");
7593
7755
  const dbType = queryRunner.connection.driver.options.type;
7594
7756
  switch (dbType) {
7595
7757
  case "postgres": {
7596
- debug10("using postgres migration file");
7597
- const mig = new CreateContacts1690925872592();
7758
+ const mig = new CreateBitstringStatusListPG1741895823000();
7598
7759
  await mig.down(queryRunner);
7599
- debug10("Migration statements executed");
7600
7760
  return;
7601
7761
  }
7602
7762
  case "sqlite":
7603
7763
  case "expo":
7604
7764
  case "react-native": {
7605
- debug10("using sqlite/react-native migration file");
7606
- const mig = new CreateContacts1690925872693();
7765
+ const mig = new CreateBitstringStatusListSqlite1741895823001();
7607
7766
  await mig.down(queryRunner);
7608
- debug10("Migration statements executed");
7609
7767
  return;
7610
7768
  }
7611
7769
  default:
7612
- return Promise.reject(`Migrations are currently only supported for sqlite, react-native, expo and postgres. Was ${dbType}. Please run your database without migrations and with 'migrationsRun: false' and 'synchronize: true' for now`);
7770
+ return Promise.reject(`Migrations only supported for sqlite and postgres. Was ${dbType}`);
7613
7771
  }
7614
7772
  }
7615
7773
  };
7616
7774
 
7617
- // src/migrations/generic/4-CreateStatusList.ts
7618
- import Debug11 from "debug";
7619
-
7620
- // src/migrations/postgres/1693866470001-CreateStatusList.ts
7621
- var CreateStatusList1693866470001 = class {
7622
- static {
7623
- __name(this, "CreateStatusList1693866470001");
7624
- }
7625
- name = "CreateStatusList1693866470001";
7626
- async up(queryRunner) {
7627
- await queryRunner.query(`CREATE TYPE "StatusList_type_enum" AS ENUM('StatusList2021')`);
7628
- await queryRunner.query(`CREATE TYPE "StatusList_drivertype_enum" AS ENUM('agent_typeorm', 'agent_kv_store', 'github', 'agent_filesystem')`);
7629
- await queryRunner.query(`CREATE TYPE "StatusList_credentialidmode_enum" AS ENUM('ISSUANCE', 'PERSISTENCE', 'NEVER')`);
7630
- await queryRunner.query(`CREATE TABLE "StatusListEntry"
7631
- (
7632
- "statusListId" character varying NOT NULL,
7633
- "statusListIndex" integer NOT NULL,
7634
- "credentialId" character varying,
7635
- "credentialHash" character varying(128),
7636
- "correlationId" character varying(255),
7637
- "value" character varying(50),
7638
- CONSTRAINT "PK_68704d2d13857360c6b44a3d1d0" PRIMARY KEY ("statusListId", "statusListIndex")
7639
- )`);
7640
- await queryRunner.query(`CREATE TABLE "StatusList"
7641
- (
7642
- "id" character varying NOT NULL,
7643
- "correlationId" character varying NOT NULL,
7644
- "length" integer NOT NULL,
7645
- "issuer" text NOT NULL,
7646
- "type" "StatusList_type_enum" NOT NULL DEFAULT 'StatusList2021',
7647
- "driverType" "StatusList_drivertype_enum" NOT NULL DEFAULT 'agent_typeorm',
7648
- "credentialIdMode" "StatusList_credentialidmode_enum" NOT NULL DEFAULT 'ISSUANCE',
7649
- "proofFormat" character varying NOT NULL DEFAULT 'lds',
7650
- "indexingDirection" character varying NOT NULL DEFAULT 'rightToLeft',
7651
- "statusPurpose" character varying NOT NULL DEFAULT 'revocation',
7652
- "statusListCredential" text,
7653
- CONSTRAINT "UQ_correlationId" UNIQUE ("correlationId"),
7654
- CONSTRAINT "PK_StatusList_Id" PRIMARY KEY ("id")
7655
- )`);
7656
- await queryRunner.query(`ALTER TABLE "StatusListEntry"
7657
- ADD CONSTRAINT "FK_statusListEntry_statusListId" FOREIGN KEY ("statusListId") REFERENCES "StatusList" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION`);
7658
- }
7659
- async down(queryRunner) {
7660
- await queryRunner.query(`ALTER TABLE "StatusListEntry"
7661
- DROP CONSTRAINT "FK_statusListEntry_statusListId"`);
7662
- await queryRunner.query(`DROP TABLE "StatusListEntry"`);
7663
- await queryRunner.query(`DROP TABLE "StatusList"`);
7664
- await queryRunner.query(`DROP TYPE "StatusList_credentialidmode_enum"`);
7665
- await queryRunner.query(`DROP TYPE "StatusList_drivertype_enum"`);
7666
- await queryRunner.query(`DROP TYPE "StatusList_type_enum"`);
7667
- }
7668
- };
7775
+ // src/migrations/generic/13-CreateDcqlQueryItem.ts
7776
+ import Debug12 from "debug";
7669
7777
 
7670
- // src/migrations/sqlite/1693866470000-CreateStatusList.ts
7671
- var CreateStatusList1693866470002 = class {
7778
+ // src/migrations/postgres/1726588800000-CreateDcqlQueryItem.ts
7779
+ var CreateDcqlQueryItemPG1726588800000 = class {
7672
7780
  static {
7673
- __name(this, "CreateStatusList1693866470002");
7781
+ __name(this, "CreateDcqlQueryItemPG1726588800000");
7674
7782
  }
7675
- name = "CreateStatusList1693866470002";
7783
+ name = "CreateDcqlQueryItemPG1726588800000";
7676
7784
  async up(queryRunner) {
7677
- await queryRunner.query(`CREATE TABLE "StatusListEntry"
7678
- (
7679
- "statusListId" varchar NOT NULL,
7680
- "statusListIndex" integer NOT NULL,
7681
- "credentialId" varchar,
7682
- "credentialHash" varchar(128),
7683
- "correlationId" varchar(255),
7684
- "value" varchar(50),
7685
- PRIMARY KEY ("statusListId", "statusListIndex")
7686
- )`);
7687
- await queryRunner.query(`CREATE TABLE "StatusList"
7688
- (
7689
- "id" varchar PRIMARY KEY NOT NULL,
7690
- "correlationId" varchar NOT NULL,
7691
- "length" integer NOT NULL,
7692
- "issuer" text NOT NULL,
7693
- "type" varchar CHECK ( "type" IN ('StatusList2021') ) NOT NULL DEFAULT ('StatusList2021'),
7694
- "driverType" varchar CHECK ( "driverType" IN ('agent_typeorm', 'agent_kv_store', 'github',
7695
- 'agent_filesystem') ) NOT NULL DEFAULT ('agent_typeorm'),
7696
- "credentialIdMode" varchar CHECK ( "credentialIdMode" IN ('ISSUANCE', 'PERSISTENCE', 'NEVER') ) NOT NULL DEFAULT ('ISSUANCE'),
7697
- "proofFormat" varchar CHECK ( "proofFormat" IN ('lds', 'jwt') ) NOT NULL DEFAULT ('lds'),
7698
- "indexingDirection" varchar CHECK ( "indexingDirection" IN ('rightToLeft') ) NOT NULL DEFAULT ('rightToLeft'),
7699
- "statusPurpose" varchar NOT NULL DEFAULT ('revocation'),
7700
- "statusListCredential" text,
7701
- CONSTRAINT "UQ_correlationId" UNIQUE ("correlationId")
7702
- )`);
7703
- await queryRunner.query(`CREATE TABLE "temporary_StatusListEntry"
7704
- (
7705
- "statusListId" varchar NOT NULL,
7706
- "statusListIndex" integer NOT NULL,
7707
- "credentialId" varchar,
7708
- "credentialHash" varchar(128),
7709
- "correlationId" varchar(255),
7710
- "value" varchar(50),
7711
- CONSTRAINT "FK_statusListEntry_statusListId" FOREIGN KEY ("statusListId") REFERENCES "StatusList" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION,
7712
- PRIMARY KEY ("statusListId", "statusListIndex")
7713
- )`);
7714
- await queryRunner.query(`INSERT INTO "temporary_StatusListEntry"("statusListId", "statusListIndex", "credentialId",
7715
- "credentialHash", "correlationId", "value")
7716
- SELECT "statusListId", "statusListIndex", "credentialId", "credentialHash", "correlationId", "value"
7717
- FROM "StatusListEntry"`);
7718
- await queryRunner.query(`DROP TABLE "StatusListEntry"`);
7719
- await queryRunner.query(`ALTER TABLE "temporary_StatusListEntry" RENAME TO "StatusListEntry"`);
7785
+ await queryRunner.query(`
7786
+ CREATE TABLE "DcqlQueryItem" (
7787
+ "id" uuid NOT NULL DEFAULT uuid_generate_v4(),
7788
+ "tenant_id" TEXT,
7789
+ "query_id" TEXT NOT NULL,
7790
+ "name" TEXT,
7791
+ "version" TEXT NOT NULL,
7792
+ "purpose" TEXT,
7793
+ "query" TEXT NOT NULL,
7794
+ "created_at" TIMESTAMP NOT NULL DEFAULT now(),
7795
+ "last_updated_at" TIMESTAMP NOT NULL DEFAULT now(),
7796
+ CONSTRAINT "PK_DcqlQueryItem_id" PRIMARY KEY ("id"))
7797
+ `);
7720
7798
  }
7721
7799
  async down(queryRunner) {
7722
- await queryRunner.query(`DROP TABLE "StatusListEntry"`);
7723
- await queryRunner.query(`DROP TABLE "StatusList"`);
7800
+ await queryRunner.query(`DROP TABLE "DcqlQueryItem"`);
7724
7801
  }
7725
7802
  };
7726
7803
 
7727
- // src/migrations/postgres/1737110469001-UpdateStatusList.ts
7728
- var UpdateStatusList1737110469001 = class {
7804
+ // src/migrations/sqlite/1726617600000-CreateDcqlQueryItem.ts
7805
+ var CreateDcqlQueryItemSQlite1726617600000 = class {
7729
7806
  static {
7730
- __name(this, "UpdateStatusList1737110469001");
7807
+ __name(this, "CreateDcqlQueryItemSQlite1726617600000");
7731
7808
  }
7732
- name = "UpdateStatusList1737110469001";
7809
+ name = "CreateDcqlQueryItemSQlite1726617600000";
7733
7810
  async up(queryRunner) {
7734
- await queryRunner.query(`ALTER TYPE "StatusList_type_enum" ADD VALUE 'OAuthStatusList'`);
7735
- await queryRunner.query(`ALTER TABLE "StatusList" ALTER COLUMN "indexingDirection" DROP NOT NULL`);
7736
- await queryRunner.query(`ALTER TABLE "StatusList" ALTER COLUMN "statusPurpose" DROP NOT NULL`);
7737
- await queryRunner.query(`ALTER TABLE "StatusList" ADD "bitsPerStatus" integer`);
7738
- await queryRunner.query(`ALTER TABLE "StatusList" ADD "expiresAt" timestamp with time zone`);
7811
+ await queryRunner.query(`CREATE TABLE "DcqlQueryItem" (
7812
+ "id" varchar PRIMARY KEY NOT NULL,
7813
+ "tenant_id" varchar,
7814
+ "query_id" varchar NOT NULL,
7815
+ "name" varchar,
7816
+ "version" varchar NOT NULL,
7817
+ "purpose" varchar,
7818
+ "query" varchar NOT NULL,
7819
+ "created_at" datetime NOT NULL DEFAULT (datetime('now')),
7820
+ "last_updated_at" datetime NOT NULL DEFAULT (datetime('now')))`);
7739
7821
  }
7740
7822
  async down(queryRunner) {
7741
- await queryRunner.query(`ALTER TABLE "StatusList" DROP COLUMN "expiresAt"`);
7742
- await queryRunner.query(`ALTER TABLE "StatusList" DROP COLUMN "bitsPerStatus"`);
7743
- await queryRunner.query(`ALTER TABLE "StatusList" ALTER COLUMN "statusPurpose" SET NOT NULL`);
7744
- await queryRunner.query(`ALTER TABLE "StatusList" ALTER COLUMN "indexingDirection" SET NOT NULL`);
7823
+ await queryRunner.query(`DROP TABLE "DcqlQueryItem"`);
7745
7824
  }
7746
7825
  };
7747
7826
 
7748
- // src/migrations/sqlite/1737110469000-UpdateStatusList.ts
7749
- var UpdateStatusList1737110469000 = class {
7827
+ // src/migrations/generic/13-CreateDcqlQueryItem.ts
7828
+ var debug12 = Debug12("sphereon:ssi-sdk:migrations");
7829
+ var CreateDcqlQueryItem1726617600000 = class {
7750
7830
  static {
7751
- __name(this, "UpdateStatusList1737110469000");
7831
+ __name(this, "CreateDcqlQueryItem1726617600000");
7752
7832
  }
7753
- name = "UpdateStatusList1737110469000";
7833
+ name = "CreateDcqlQueryItem1726617600000";
7754
7834
  async up(queryRunner) {
7755
- await queryRunner.query(`CREATE TABLE "temporary_StatusList" (
7756
- "id" varchar PRIMARY KEY NOT NULL,
7757
- "correlationId" varchar NOT NULL,
7758
- "length" integer NOT NULL,
7759
- "issuer" text NOT NULL,
7760
- "type" varchar CHECK( "type" IN ('StatusList2021', 'OAuthStatusList') ) NOT NULL DEFAULT ('StatusList2021'),
7761
- "driverType" varchar CHECK( "driverType" IN ('agent_typeorm','agent_kv_store','github','agent_filesystem') ) NOT NULL DEFAULT ('agent_typeorm'),
7762
- "credentialIdMode" varchar CHECK( "credentialIdMode" IN ('ISSUANCE','PERSISTENCE','NEVER') ) NOT NULL DEFAULT ('ISSUANCE'),
7763
- "proofFormat" varchar CHECK( "proofFormat" IN ('lds','jwt') ) NOT NULL DEFAULT ('lds'),
7764
- "indexingDirection" varchar CHECK( "indexingDirection" IN ('rightToLeft') ),
7765
- "statusPurpose" varchar,
7766
- "statusListCredential" text,
7767
- "bitsPerStatus" integer,
7768
- "expiresAt" datetime,
7769
- CONSTRAINT "UQ_correlationId" UNIQUE ("correlationId")
7770
- )`);
7771
- await queryRunner.query(`INSERT INTO "temporary_StatusList"(
7772
- "id", "correlationId", "length", "issuer", "type", "driverType",
7773
- "credentialIdMode", "proofFormat", "indexingDirection", "statusPurpose",
7774
- "statusListCredential"
7775
- )
7776
- SELECT
7777
- "id", "correlationId", "length", "issuer", "type", "driverType",
7778
- "credentialIdMode", "proofFormat", "indexingDirection", "statusPurpose",
7779
- "statusListCredential"
7780
- FROM "StatusList"`);
7781
- await queryRunner.query(`DROP TABLE "StatusList"`);
7782
- await queryRunner.query(`ALTER TABLE "temporary_StatusList" RENAME TO "StatusList"`);
7835
+ debug12("migration: updating presentation definition item nullable fields");
7836
+ const dbType = queryRunner.connection.driver.options.type;
7837
+ switch (dbType) {
7838
+ case "postgres": {
7839
+ debug12("using postgres migration file");
7840
+ const mig = new CreateDcqlQueryItemPG1726588800000();
7841
+ await mig.up(queryRunner);
7842
+ debug12("Migration statements executed");
7843
+ return;
7844
+ }
7845
+ case "sqlite":
7846
+ case "expo":
7847
+ case "react-native": {
7848
+ debug12("using sqlite/react-native migration file");
7849
+ const mig = new CreateDcqlQueryItemSQlite1726617600000();
7850
+ await mig.up(queryRunner);
7851
+ debug12("Migration statements executed");
7852
+ return;
7853
+ }
7854
+ default:
7855
+ return Promise.reject(`Migrations are currently only supported for sqlite, react-native, expo and postgres. Was ${dbType}. Please run your database without migrations and with 'migrationsRun: false' and 'synchronize: true' for now`);
7856
+ }
7783
7857
  }
7784
7858
  async down(queryRunner) {
7785
- await queryRunner.query(`
7786
- ALTER TABLE "StatusListEntry"
7787
- RENAME COLUMN "entryCorrelationId" TO "correlationId"
7788
- `);
7789
- await queryRunner.query(`
7790
- ALTER TABLE "StatusListEntry"
7791
- DROP COLUMN "statusListCorrelationId"
7792
- `);
7793
- await queryRunner.query(`CREATE TABLE "temporary_StatusList" (
7794
- "id" varchar PRIMARY KEY NOT NULL,
7795
- "correlationId" varchar NOT NULL,
7796
- "length" integer NOT NULL,
7797
- "issuer" text NOT NULL,
7798
- "type" varchar CHECK( "type" IN ('StatusList2021') ) NOT NULL DEFAULT ('StatusList2021'),
7799
- "driverType" varchar CHECK( "driverType" IN ('agent_typeorm','agent_kv_store','github','agent_filesystem') ) NOT NULL DEFAULT ('agent_typeorm'),
7800
- "credentialIdMode" varchar CHECK( "credentialIdMode" IN ('ISSUANCE','PERSISTENCE','NEVER') ) NOT NULL DEFAULT ('ISSUANCE'),
7801
- "proofFormat" varchar CHECK( "proofFormat" IN ('lds','jwt') ) NOT NULL DEFAULT ('lds'),
7802
- "indexingDirection" varchar CHECK( "indexingDirection" IN ('rightToLeft') ) NOT NULL DEFAULT ('rightToLeft'),
7803
- "statusPurpose" varchar NOT NULL DEFAULT ('revocation'),
7804
- "statusListCredential" text,
7805
- CONSTRAINT "UQ_correlationId" UNIQUE ("correlationId")
7806
- )`);
7807
- await queryRunner.query(`INSERT INTO "temporary_StatusList"(
7808
- "id", "correlationId", "length", "issuer", "type", "driverType",
7809
- "credentialIdMode", "proofFormat", "indexingDirection", "statusPurpose",
7810
- "statusListCredential"
7811
- )
7812
- SELECT
7813
- "id", "correlationId", "length", "issuer",
7814
- CASE WHEN "type" = 'OAuthStatusList' THEN 'StatusList2021' ELSE "type" END,
7815
- "driverType", "credentialIdMode", "proofFormat", "indexingDirection",
7816
- COALESCE("statusPurpose", 'revocation'), "statusListCredential"
7817
- FROM "StatusList"`);
7818
- await queryRunner.query(`DROP TABLE "StatusList"`);
7819
- await queryRunner.query(`ALTER TABLE "temporary_StatusList" RENAME TO "StatusList"`);
7859
+ debug12("migration: reverting presentation definition item nullable fields");
7860
+ const dbType = queryRunner.connection.driver.options.type;
7861
+ switch (dbType) {
7862
+ case "postgres": {
7863
+ debug12("using postgres migration file");
7864
+ const mig = new CreateDcqlQueryItemPG1726588800000();
7865
+ await mig.down(queryRunner);
7866
+ debug12("Migration statements executed");
7867
+ return;
7868
+ }
7869
+ case "sqlite":
7870
+ case "expo":
7871
+ case "react-native": {
7872
+ debug12("using sqlite/react-native migration file");
7873
+ const mig = new CreateDcqlQueryItemSQlite1726617600000();
7874
+ await mig.down(queryRunner);
7875
+ debug12("Migration statements executed");
7876
+ return;
7877
+ }
7878
+ default:
7879
+ return Promise.reject(`Migrations are currently only supported for sqlite, react-native, expo and postgres. Was ${dbType}. Please run your database without migrations and with 'migrationsRun: false' and 'synchronize: true' for now`);
7880
+ }
7820
7881
  }
7821
7882
  };
7822
7883
 
7823
- // src/migrations/generic/4-CreateStatusList.ts
7824
- var debug11 = Debug11("sphereon:ssi-sdk:migrations");
7825
- var CreateStatusList1693866470000 = class {
7884
+ // src/migrations/generic/2-CreateIssuanceBranding.ts
7885
+ import Debug13 from "debug";
7886
+ var debug13 = Debug13("sphereon:ssi-sdk:migrations");
7887
+ var CreateIssuanceBranding1659463079429 = class {
7826
7888
  static {
7827
- __name(this, "CreateStatusList1693866470000");
7889
+ __name(this, "CreateIssuanceBranding1659463079429");
7828
7890
  }
7829
- name = "CreateStatusList1693866470000";
7891
+ name = "CreateIssuanceBranding1659463079429";
7830
7892
  async up(queryRunner) {
7831
- debug11("migration: creating issuance branding tables");
7893
+ debug13("migration: creating issuance branding tables");
7832
7894
  const dbType = queryRunner.connection.driver.options.type;
7833
- if (dbType === "postgres") {
7834
- debug11("using postgres migration files");
7835
- const createMig = new CreateStatusList1693866470001();
7836
- await createMig.up(queryRunner);
7837
- const updateMig = new UpdateStatusList1737110469001();
7838
- const up = await updateMig.up(queryRunner);
7839
- debug11("Migration statements executed");
7840
- return up;
7841
- } else if (dbType === "sqlite" || dbType === "react-native" || dbType === "expo") {
7842
- debug11("using sqlite/react-native migration files");
7843
- const createMig = new CreateStatusList1693866470002();
7844
- await createMig.up(queryRunner);
7845
- const updateMig = new UpdateStatusList1737110469000();
7846
- const up = await updateMig.up(queryRunner);
7847
- debug11("Migration statements executed");
7848
- return up;
7849
- } else {
7850
- return Promise.reject(`Migrations are currently only supported for sqlite, react-native, expo and postgres. Was ${dbType}. Please run your database without migrations and with 'migrationsRun: false' and 'synchronize: true' for now`);
7895
+ switch (dbType) {
7896
+ case "postgres": {
7897
+ debug13("using postgres migration file");
7898
+ const mig = new CreateIssuanceBranding1685628974232();
7899
+ await mig.up(queryRunner);
7900
+ debug13("Migration statements executed");
7901
+ return;
7902
+ }
7903
+ case "sqlite":
7904
+ case "expo":
7905
+ case "react-native": {
7906
+ debug13("using sqlite/react-native migration file");
7907
+ const mig = new CreateIssuanceBranding1685628973231();
7908
+ await mig.up(queryRunner);
7909
+ debug13("Migration statements executed");
7910
+ return;
7911
+ }
7912
+ default:
7913
+ return Promise.reject(`Migrations are currently only supported for sqlite, react-native, expo and postgres. Was ${dbType}. Please run your database without migrations and with 'migrationsRun: false' and 'synchronize: true' for now`);
7851
7914
  }
7852
7915
  }
7853
7916
  async down(queryRunner) {
7854
- debug11("migration: reverting issuance branding tables");
7917
+ debug13("migration: reverting issuance branding tables");
7855
7918
  const dbType = queryRunner.connection.driver.options.type;
7856
- if (dbType === "postgres") {
7857
- debug11("using postgres migration files");
7858
- const updateMig = new UpdateStatusList1737110469001();
7859
- await updateMig.down(queryRunner);
7860
- const createMig = new CreateStatusList1693866470001();
7861
- const down = await createMig.down(queryRunner);
7862
- debug11("Migration statements executed");
7863
- return down;
7864
- } else if (dbType === "sqlite" || dbType === "react-native" || dbType === "expo") {
7865
- debug11("using sqlite/react-native migration files");
7866
- const updateMig = new UpdateStatusList1737110469000();
7867
- await updateMig.down(queryRunner);
7868
- const createMig = new CreateStatusList1693866470002();
7869
- const down = await createMig.down(queryRunner);
7870
- debug11("Migration statements executed");
7871
- return down;
7872
- } else {
7873
- return Promise.reject(`Migrations are currently only supported for sqlite, react-native, expo and postgres. Was ${dbType}. Please run your database without migrations and with 'migrationsRun: false' and 'synchronize: true' for now`);
7919
+ switch (dbType) {
7920
+ case "postgres": {
7921
+ debug13("using postgres migration file");
7922
+ const mig = new CreateIssuanceBranding1685628974232();
7923
+ await mig.down(queryRunner);
7924
+ debug13("Migration statements executed");
7925
+ return;
7926
+ }
7927
+ case "sqlite":
7928
+ case "expo":
7929
+ case "react-native": {
7930
+ debug13("using sqlite/react-native migration file");
7931
+ const mig = new CreateIssuanceBranding1685628973231();
7932
+ await mig.down(queryRunner);
7933
+ debug13("Migration statements executed");
7934
+ return;
7935
+ }
7936
+ default:
7937
+ return Promise.reject(`Migrations are currently only supported for sqlite, react-native, expo and postgres. Was ${dbType}. Please run your database without migrations and with 'migrationsRun: false' and 'synchronize: true' for now`);
7874
7938
  }
7875
7939
  }
7876
7940
  };
7877
7941
 
7878
- // src/migrations/generic/5-CreateAuditEvents.ts
7879
- import Debug12 from "debug";
7942
+ // src/migrations/generic/3-CreateContacts.ts
7943
+ import Debug14 from "debug";
7880
7944
 
7881
- // src/migrations/sqlite/1701634819487-CreateAuditEvents.ts
7882
- var CreateAuditEvents1701634819487 = class {
7945
+ // src/migrations/sqlite/1690925872693-CreateContacts.ts
7946
+ var CreateContacts1690925872693 = class {
7883
7947
  static {
7884
- __name(this, "CreateAuditEvents1701634819487");
7948
+ __name(this, "CreateContacts1690925872693");
7885
7949
  }
7886
- name = "CreateAuditEvents1701634819487";
7950
+ name = "CreateContacts1690925872693";
7887
7951
  async up(queryRunner) {
7888
- await queryRunner.query(`CREATE TABLE "AuditEvents" (
7889
- "id" varchar PRIMARY KEY NOT NULL,
7890
- "eventType" varchar CHECK( "eventType" IN ('audit','activity','general') ) NOT NULL,
7891
- "timestamp" datetime NOT NULL,
7892
- "level" varchar CHECK( "level" IN ('0','1','2','3','4') ) NOT NULL,
7893
- "correlationId" varchar NOT NULL,
7894
- "system" varchar CHECK( "system" IN ('general','kms','identity','oid4vci','oid4vp','siopv2','PE','credentials','web3','profile','contact') ) NOT NULL,
7895
- "subSystemType" varchar CHECK( "subSystemType" IN ('key','did_provider','did_resolver','oid4vp_op','oid4vci_client','siopv2_op','contact_manager','vc_issuer','vc_verifier','vc_persistence','transport','profile','api') ) NOT NULL,
7896
- "actionType" varchar CHECK( "actionType" IN ('create','read','update','delete','execute') ) NOT NULL,
7897
- "actionSubType" varchar NOT NULL,
7898
- "initiatorType" varchar CHECK( "initiatorType" IN ('user','system','external') ) NOT NULL,
7899
- "systemCorrelationIdType" varchar CHECK( "systemCorrelationIdType" IN ('did','url','email','hostname','phone','user') ),
7900
- "systemCorrelationId" varchar,
7901
- "systemAlias" varchar,
7902
- "partyCorrelationType" varchar CHECK( "partyCorrelationType" IN ('did','url','email','hostname','phone') ),
7903
- "partyCorrelationId" varchar,
7904
- "partyAlias" varchar,
7905
- "credentialType" varchar CHECK( "credentialType" IN ('JSON_LD','JWT','SD_JWT','MSO_MDOC') ),
7906
- "credentialHash" varchar,
7907
- "parentCredentialHash" varchar,
7908
- "originalCredential" varchar,
7909
- "sharePurpose" varchar,
7910
- "description" varchar NOT NULL,
7911
- "data" varchar,
7912
- "diagnosticData" varchar,
7913
- "created_at" datetime NOT NULL DEFAULT (datetime('now')),
7914
- "last_updated_at" datetime NOT NULL DEFAULT (datetime('now')))`);
7952
+ await queryRunner.query(`CREATE TABLE "temporary_CorrelationIdentifier" ("id" varchar PRIMARY KEY NOT NULL, "type" varchar CHECK( "type" IN ('did','url') ) NOT NULL, "correlation_id" text NOT NULL, "identityId" varchar, CONSTRAINT "REL_CorrelationIdentifier_identityId" UNIQUE ("identityId"), CONSTRAINT "UQ_CorrelationIdentifier_correlation_id" UNIQUE ("correlation_id"))`);
7953
+ await queryRunner.query(`INSERT INTO "temporary_CorrelationIdentifier"("id", "type", "correlation_id", "identityId") SELECT "id", "type", "correlation_id", "identityId" FROM "CorrelationIdentifier"`);
7954
+ await queryRunner.query(`DROP TABLE "CorrelationIdentifier"`);
7955
+ await queryRunner.query(`ALTER TABLE "temporary_CorrelationIdentifier" RENAME TO "CorrelationIdentifier"`);
7956
+ await queryRunner.query(`CREATE TABLE "temporary_Identity" ("id" varchar PRIMARY KEY NOT NULL, "alias" varchar(255) NOT NULL, "roles" text NOT NULL, "created_at" datetime NOT NULL DEFAULT (datetime('now')), "last_updated_at" datetime NOT NULL DEFAULT (datetime('now')), "contactId" varchar, CONSTRAINT "UQ_Identity_alias" UNIQUE ("alias"))`);
7957
+ await queryRunner.query(`INSERT INTO "temporary_Identity"("id", "alias", "roles", "created_at", "last_updated_at", "contactId") SELECT "id", "alias", "roles", "created_at", "last_updated_at", "contactId" FROM "Identity"`);
7958
+ await queryRunner.query(`DROP TABLE "Identity"`);
7959
+ await queryRunner.query(`ALTER TABLE "temporary_Identity" RENAME TO "Identity"`);
7960
+ await queryRunner.query(`CREATE TABLE "temporary_Connection" ("id" varchar PRIMARY KEY NOT NULL, "type" varchar CHECK( "type" IN ('OIDC','SIOPv2','SIOPv2+OpenID4VP') ) NOT NULL, "identityId" varchar, CONSTRAINT "REL_Connection_identityId" UNIQUE ("identityId"))`);
7961
+ await queryRunner.query(`INSERT INTO "temporary_Connection"("id", "type", "identityId") SELECT "id", "type", "identityId" FROM "Connection"`);
7962
+ await queryRunner.query(`DROP TABLE "Connection"`);
7963
+ await queryRunner.query(`ALTER TABLE "temporary_Connection" RENAME TO "Connection"`);
7964
+ await queryRunner.query(`CREATE TABLE "temporary_CorrelationIdentifier" ("id" varchar PRIMARY KEY NOT NULL, "type" varchar CHECK( "type" IN ('did','url') ) NOT NULL, "correlation_id" text NOT NULL, "identity_id" varchar, CONSTRAINT "REL_CorrelationIdentifier_identityId" UNIQUE ("identity_id"), CONSTRAINT "UQ_CorrelationIdentifier_correlation_id" UNIQUE ("correlation_id"))`);
7965
+ await queryRunner.query(`INSERT INTO "temporary_CorrelationIdentifier"("id", "type", "correlation_id", "identity_id") SELECT "id", "type", "correlation_id", "identityId" FROM "CorrelationIdentifier"`);
7966
+ await queryRunner.query(`DROP TABLE "CorrelationIdentifier"`);
7967
+ await queryRunner.query(`ALTER TABLE "temporary_CorrelationIdentifier" RENAME TO "CorrelationIdentifier"`);
7968
+ await queryRunner.query(`CREATE TABLE "temporary_Identity" ("id" varchar PRIMARY KEY NOT NULL, "alias" varchar(255) NOT NULL, "roles" text NOT NULL, "created_at" datetime NOT NULL DEFAULT (datetime('now')), "last_updated_at" datetime NOT NULL DEFAULT (datetime('now')), "partyId" varchar, CONSTRAINT "UQ_Identity_alias" UNIQUE ("alias"))`);
7969
+ await queryRunner.query(`INSERT INTO "temporary_Identity"("id", "alias", "roles", "created_at", "last_updated_at", "partyId") SELECT "id", "alias", "roles", "created_at", "last_updated_at", "contactId" FROM "Identity"`);
7970
+ await queryRunner.query(`DROP TABLE "Identity"`);
7971
+ await queryRunner.query(`ALTER TABLE "temporary_Identity" RENAME TO "Identity"`);
7972
+ await queryRunner.query(`CREATE TABLE "temporary_Connection" ("id" varchar PRIMARY KEY NOT NULL, "type" varchar CHECK( "type" IN ('OIDC','SIOPv2','SIOPv2+OpenID4VP') ) NOT NULL, "identity_id" varchar, CONSTRAINT "REL_Connection_identityId" UNIQUE ("identity_id"))`);
7973
+ await queryRunner.query(`INSERT INTO "temporary_Connection"("id", "type", "identity_id") SELECT "id", "type", "identityId" FROM "Connection"`);
7974
+ await queryRunner.query(`DROP TABLE "Connection"`);
7975
+ await queryRunner.query(`ALTER TABLE "temporary_Connection" RENAME TO "Connection"`);
7976
+ await queryRunner.query(`CREATE TABLE "PartyType" ("id" varchar PRIMARY KEY NOT NULL, "type" varchar CHECK( "type" IN ('naturalPerson','organization') ) NOT NULL, "origin" varchar CHECK( "origin" IN ('INTERNAL', 'EXTERNAL') ) NOT NULL, "name" varchar(255) NOT NULL, "description" varchar(255), "tenant_id" varchar(255) NOT NULL, "created_at" datetime NOT NULL DEFAULT (datetime('now')), "last_updated_at" datetime NOT NULL DEFAULT (datetime('now')), CONSTRAINT "UQ_PartyType_name" UNIQUE ("name"))`);
7977
+ await queryRunner.query(`CREATE UNIQUE INDEX "IDX_PartyType_type_tenant_id" ON "PartyType" ("type", "tenant_id")`);
7978
+ await queryRunner.query(`CREATE TABLE "BaseContact" ("id" varchar PRIMARY KEY NOT NULL, "created_at" datetime NOT NULL DEFAULT (datetime('now')), "last_updated_at" datetime NOT NULL DEFAULT (datetime('now')), "legal_name" varchar(255), "display_name" varchar(255), "first_name" varchar(255), "middle_name" varchar(255), "last_name" varchar(255), "type" varchar NOT NULL, "party_id" varchar, CONSTRAINT "UQ_BaseContact_legal_name" UNIQUE ("legal_name"), CONSTRAINT "REL_BaseContact_party_id" UNIQUE ("party_id"))`);
7979
+ await queryRunner.query(`CREATE INDEX "IDX_BaseContact_type" ON "BaseContact" ("type")`);
7980
+ await queryRunner.query(`CREATE TABLE "PartyRelationship" ("id" varchar PRIMARY KEY NOT NULL, "left_id" varchar NOT NULL, "right_id" varchar NOT NULL, "created_at" datetime NOT NULL DEFAULT (datetime('now')), "last_updated_at" datetime NOT NULL DEFAULT (datetime('now')))`);
7981
+ await queryRunner.query(`CREATE UNIQUE INDEX "IDX_PartyRelationship_left_right" ON "PartyRelationship" ("left_id", "right_id")`);
7982
+ await queryRunner.query(`CREATE TABLE "Party" ("id" varchar PRIMARY KEY NOT NULL, "uri" varchar(255) NOT NULL, "created_at" datetime NOT NULL DEFAULT (datetime('now')), "last_updated_at" datetime NOT NULL DEFAULT (datetime('now')), "party_type_id" varchar NOT NULL)`);
7983
+ await queryRunner.query(`CREATE TABLE "BaseConfig" ("id" varchar PRIMARY KEY NOT NULL, "identifier" varchar(255), "redirect_url" varchar(255), "session_id" varchar(255), "client_id" varchar(255), "client_secret" varchar(255), "scopes" text, "issuer" varchar(255), "dangerously_allow_insecure_http_requests" boolean, "client_auth_method" text, "type" varchar NOT NULL, "connection_id" varchar, CONSTRAINT "REL_BaseConfig_connection_id" UNIQUE ("connection_id"))`);
7984
+ await queryRunner.query(`CREATE INDEX "IDX_BaseConfig_type" ON "BaseConfig" ("type")`);
7985
+ await queryRunner.query(`CREATE TABLE "temporary_CorrelationIdentifier" ("id" varchar PRIMARY KEY NOT NULL, "type" varchar CHECK( "type" IN ('did','url') ) NOT NULL, "correlation_id" text NOT NULL, "identity_id" varchar, CONSTRAINT "REL_CorrelationIdentifier_identity_id" UNIQUE ("identity_id"), CONSTRAINT "UQ_CorrelationIdentifier_correlation_id" UNIQUE ("correlation_id"), CONSTRAINT "FK_CorrelationIdentifier_identity_id" FOREIGN KEY ("identity_id") REFERENCES "Identity" ("id") ON DELETE CASCADE ON UPDATE NO ACTION)`);
7986
+ await queryRunner.query(`INSERT INTO "temporary_CorrelationIdentifier"("id", "type", "correlation_id", "identity_id") SELECT "id", "type", "correlation_id", "identity_id" FROM "CorrelationIdentifier"`);
7987
+ await queryRunner.query(`DROP TABLE "CorrelationIdentifier"`);
7988
+ await queryRunner.query(`ALTER TABLE "temporary_CorrelationIdentifier" RENAME TO "CorrelationIdentifier"`);
7989
+ await queryRunner.query(`DROP INDEX "IDX_BaseContact_type"`);
7990
+ await queryRunner.query(`CREATE TABLE "temporary_BaseContact" ("id" varchar PRIMARY KEY NOT NULL, "created_at" datetime NOT NULL DEFAULT (datetime('now')), "last_updated_at" datetime NOT NULL DEFAULT (datetime('now')), "legal_name" varchar(255), "display_name" varchar(255), "first_name" varchar(255), "middle_name" varchar(255), "last_name" varchar(255), "type" varchar NOT NULL, "party_id" varchar, CONSTRAINT "UQ_BaseContact_legal_name" UNIQUE ("legal_name"), CONSTRAINT "REL_BaseContact_party_id" UNIQUE ("party_id"), CONSTRAINT "FK_BaseContact_party_id" FOREIGN KEY ("party_id") REFERENCES "Party" ("id") ON DELETE CASCADE ON UPDATE NO ACTION)`);
7991
+ await queryRunner.query(`INSERT INTO "temporary_BaseContact"("id", "created_at", "last_updated_at", "legal_name", "display_name", "first_name", "middle_name", "last_name", "type", "party_id") SELECT "id", "created_at", "last_updated_at", "legal_name", "display_name", "first_name", "middle_name", "last_name", "type", "party_id" FROM "BaseContact"`);
7992
+ await queryRunner.query(`DROP TABLE "BaseContact"`);
7993
+ await queryRunner.query(`ALTER TABLE "temporary_BaseContact" RENAME TO "BaseContact"`);
7994
+ await queryRunner.query(`CREATE INDEX "IDX_BaseContact_type" ON "BaseContact" ("type")`);
7995
+ await queryRunner.query(`DROP INDEX "IDX_PartyRelationship_left_right"`);
7996
+ await queryRunner.query(`CREATE TABLE "temporary_PartyRelationship" ("id" varchar PRIMARY KEY NOT NULL, "left_id" varchar NOT NULL, "right_id" varchar NOT NULL, "created_at" datetime NOT NULL DEFAULT (datetime('now')), "last_updated_at" datetime NOT NULL DEFAULT (datetime('now')), CONSTRAINT "FK_PartyRelationship_left_id" FOREIGN KEY ("left_id") REFERENCES "Party" ("id") ON DELETE CASCADE ON UPDATE NO ACTION, CONSTRAINT "FK_PartyRelationship_right_id" FOREIGN KEY ("right_id") REFERENCES "Party" ("id") ON DELETE CASCADE ON UPDATE NO ACTION)`);
7997
+ await queryRunner.query(`INSERT INTO "temporary_PartyRelationship"("id", "left_id", "right_id", "created_at", "last_updated_at") SELECT "id", "left_id", "right_id", "created_at", "last_updated_at" FROM "PartyRelationship"`);
7998
+ await queryRunner.query(`DROP TABLE "PartyRelationship"`);
7999
+ await queryRunner.query(`ALTER TABLE "temporary_PartyRelationship" RENAME TO "PartyRelationship"`);
8000
+ await queryRunner.query(`CREATE UNIQUE INDEX "IDX_PartyRelationship_left_right" ON "PartyRelationship" ("left_id", "right_id")`);
8001
+ await queryRunner.query(`CREATE TABLE "ElectronicAddress" ("id" varchar PRIMARY KEY NOT NULL, "type" varchar(255) NOT NULL, "electronic_address" varchar(255) NOT NULL, "created_at" datetime NOT NULL DEFAULT (datetime('now')), "last_updated_at" datetime NOT NULL DEFAULT (datetime('now')), "partyId" varchar, CONSTRAINT "FK_ElectronicAddress_partyId" FOREIGN KEY ("partyId") REFERENCES "Party" ("id") ON DELETE CASCADE ON UPDATE NO ACTION)`);
8002
+ await queryRunner.query(`CREATE TABLE "PhysicalAddress" ("id" varchar PRIMARY KEY NOT NULL, "type" varchar(255) NOT NULL, "street_name" varchar(255) NOT NULL, "street_number" varchar(255) NOT NULL, "postal_code" varchar(255) NOT NULL, "city_name" varchar(255) NOT NULL, "province_name" varchar(255) NOT NULL, "country_code" varchar(2) NOT NULL, "building_name" varchar(255), "partyId" varchar, "created_at" datetime NOT NULL DEFAULT (datetime('now')), "last_updated_at" datetime NOT NULL DEFAULT (datetime('now')), CONSTRAINT "FK_PhysicalAddressEntity_partyId" FOREIGN KEY ("partyId") REFERENCES "Party" ("id") ON DELETE CASCADE ON UPDATE NO ACTION)`);
8003
+ await queryRunner.query(`CREATE TABLE "temporary_Party" ("id" varchar PRIMARY KEY NOT NULL, "uri" varchar(255), "created_at" datetime NOT NULL DEFAULT (datetime('now')), "last_updated_at" datetime NOT NULL DEFAULT (datetime('now')), "party_type_id" varchar NOT NULL, CONSTRAINT "FK_Party_party_type_id" FOREIGN KEY ("party_type_id") REFERENCES "PartyType" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION)`);
8004
+ await queryRunner.query(`INSERT INTO "temporary_Party"("id", "uri", "created_at", "last_updated_at", "party_type_id") SELECT "id", "uri", "created_at", "last_updated_at", "party_type_id" FROM "Party"`);
8005
+ await queryRunner.query(`DROP TABLE "Party"`);
8006
+ await queryRunner.query(`ALTER TABLE "temporary_Party" RENAME TO "Party"`);
8007
+ await queryRunner.query(`CREATE TABLE "temporary_Identity" ("id" varchar PRIMARY KEY NOT NULL, "alias" varchar(255) NOT NULL, "roles" text NOT NULL, "created_at" datetime NOT NULL DEFAULT (datetime('now')), "last_updated_at" datetime NOT NULL DEFAULT (datetime('now')), "partyId" varchar, CONSTRAINT "UQ_Identity_alias" UNIQUE ("alias"), CONSTRAINT "FK_Identity_partyId" FOREIGN KEY ("partyId") REFERENCES "Party" ("id") ON DELETE CASCADE ON UPDATE NO ACTION)`);
8008
+ await queryRunner.query(`INSERT INTO "temporary_Identity"("id", "alias", "roles", "created_at", "last_updated_at", "partyId") SELECT "id", "alias", "roles", "created_at", "last_updated_at", "partyId" FROM "Identity"`);
8009
+ await queryRunner.query(`DROP TABLE "Identity"`);
8010
+ await queryRunner.query(`ALTER TABLE "temporary_Identity" RENAME TO "Identity"`);
8011
+ await queryRunner.query(`CREATE TABLE "temporary_Connection" ("id" varchar PRIMARY KEY NOT NULL, "type" varchar CHECK( "type" IN ('OIDC','SIOPv2','SIOPv2+OpenID4VP') ) NOT NULL, "identity_id" varchar, CONSTRAINT "REL_Connection_identity_id" UNIQUE ("identity_id"), CONSTRAINT "FK_Connection_identity_id" FOREIGN KEY ("identity_id") REFERENCES "Identity" ("id") ON DELETE CASCADE ON UPDATE NO ACTION)`);
8012
+ await queryRunner.query(`INSERT INTO "temporary_Connection"("id", "type", "identity_id") SELECT "id", "type", "identity_id" FROM "Connection"`);
8013
+ await queryRunner.query(`DROP TABLE "Connection"`);
8014
+ await queryRunner.query(`ALTER TABLE "temporary_Connection" RENAME TO "Connection"`);
8015
+ await queryRunner.query(`DROP INDEX "IDX_BaseConfig_type"`);
8016
+ await queryRunner.query(`CREATE TABLE "temporary_BaseConfig" ("id" varchar PRIMARY KEY NOT NULL, "identifier" varchar(255), "redirect_url" varchar(255), "session_id" varchar(255), "client_id" varchar(255), "client_secret" varchar(255), "scopes" text, "issuer" varchar(255), "dangerously_allow_insecure_http_requests" boolean, "client_auth_method" text, "type" varchar NOT NULL, "connection_id" varchar, CONSTRAINT "REL_BaseConfig_connection_id" UNIQUE ("connection_id"), CONSTRAINT "FK_BaseConfig_connection_id" FOREIGN KEY ("connection_id") REFERENCES "Connection" ("id") ON DELETE CASCADE ON UPDATE NO ACTION)`);
8017
+ await queryRunner.query(`INSERT INTO "temporary_BaseConfig"("id", "identifier", "redirect_url", "session_id", "client_id", "client_secret", "scopes", "issuer", "dangerously_allow_insecure_http_requests", "client_auth_method", "type", "connection_id") SELECT "id", "identifier", "redirect_url", "session_id", "client_id", "client_secret", "scopes", "issuer", "dangerously_allow_insecure_http_requests", "client_auth_method", "type", "connection_id" FROM "BaseConfig"`);
8018
+ await queryRunner.query(`DROP TABLE "BaseConfig"`);
8019
+ await queryRunner.query(`ALTER TABLE "temporary_BaseConfig" RENAME TO "BaseConfig"`);
8020
+ await queryRunner.query(`CREATE INDEX "IDX_BaseConfig_type" ON "BaseConfig" ("type")`);
8021
+ await queryRunner.query(`INSERT INTO "BaseConfig"("id", "identifier", "redirect_url", "session_id", "client_id", "client_secret", "scopes", "issuer", "dangerously_allow_insecure_http_requests", "client_auth_method", "type", "connection_id") SELECT "id", "identifier", "redirect_url", "session_id", "client_id", "client_secret", "scopes", "issuer", "dangerously_allow_insecure_http_requests", "client_auth_method", "type", "connectionId" FROM "BaseConfigEntity"`);
8022
+ await queryRunner.query(`DROP TABLE "BaseConfigEntity"`);
8023
+ await queryRunner.query(`INSERT INTO "PartyType"(id, type, origin, name, description, tenant_id, created_at, last_updated_at) VALUES ('3875c12e-fdaa-4ef6-a340-c936e054b627', 'organization', 'INTERNAL', 'Sphereon_default_organization_type', 'sphereon_default_organization', '95e09cfc-c974-4174-86aa-7bf1d5251fb4', datetime('now'), datetime('now'))`);
8024
+ await queryRunner.query(`INSERT INTO "PartyType"(id, type, origin, name, description, tenant_id, created_at, last_updated_at) VALUES ('7d248798-41ca-4fc1-a130-9934b43d532e', 'naturalPerson', 'INTERNAL', 'Sphereon_default_natural_person_type', 'sphereon_default_natural_person', '95e09cfc-c974-4174-86aa-7bf1d5251fb4', datetime('now'), datetime('now'))`);
8025
+ await queryRunner.query(`INSERT INTO "Party"(id, uri, created_at, last_updated_at, party_type_id) SELECT id, uri, created_at, last_updated_at, '3875c12e-fdaa-4ef6-a340-c936e054b627' FROM "Contact"`);
8026
+ await queryRunner.query(`INSERT INTO "BaseContact"(id, legal_name, display_name, party_id, created_at, last_updated_at, type) SELECT id, name, alias, id, created_at, last_updated_at, 'Organization' FROM "Contact"`);
8027
+ await queryRunner.query(`DROP TABLE "Contact"`);
7915
8028
  }
7916
8029
  async down(queryRunner) {
7917
- await queryRunner.query(`DROP TABLE "AuditEvents"`);
8030
+ await queryRunner.query(`CREATE TABLE "Contact" ("id" varchar PRIMARY KEY NOT NULL, "uri" varchar(255), "created_at" datetime NOT NULL DEFAULT (datetime('now')), "last_updated_at" datetime NOT NULL DEFAULT (datetime('now')), "name" varchar(255), "alias" varchar(255))`);
8031
+ await queryRunner.query(`INSERT INTO "Contact"(id, uri, created_at, last_updated_at, name, alias) SELECT id, uri, created_at, last_updated_at, (SELECT legal_name FROM "BaseContact" WHERE "BaseContact"."party_id" = "Party"."id"), (SELECT display_name FROM "BaseContact" WHERE "BaseContact"."party_id" = "Party"."id") FROM "Party" WHERE party_type_id = '3875c12e-fdaa-4ef6-a340-c936e054b627'`);
8032
+ await queryRunner.query(`DROP TABLE "BaseContact"`);
8033
+ await queryRunner.query(`DROP TABLE "Party"`);
8034
+ await queryRunner.query(`CREATE TABLE "BaseConfigEntity" ("id" varchar PRIMARY KEY NOT NULL, "identifier" varchar(255), "redirect_url" varchar(255), "session_id" varchar(255), "client_id" varchar(255), "client_secret" varchar(255), "scopes" text, "issuer" varchar(255), "dangerously_allow_insecure_http_requests" boolean, "client_auth_method" text, "type" varchar NOT NULL, "connectionId" varchar)`);
8035
+ await queryRunner.query(`INSERT INTO "BaseConfigEntity"("id", "identifier", "redirect_url", "session_id", "client_id", "client_secret", "scopes", "issuer", "dangerously_allow_insecure_http_requests", "client_auth_method", "type", "connectionId") SELECT "id", "identifier", "redirect_url", "session_id", "client_id", "client_secret", "scopes", "issuer", "dangerously_allow_insecure_http_requests", "client_auth_method", "type", "connection_id" FROM "BaseConfig"`);
8036
+ await queryRunner.query(`DROP TABLE "BaseConfig"`);
8037
+ await queryRunner.query(`CREATE TABLE "temporary_Party" ("id" varchar PRIMARY KEY NOT NULL, "uri" varchar(255), "created_at" datetime NOT NULL DEFAULT (datetime('now')), "last_updated_at" datetime NOT NULL DEFAULT (datetime('now')), "party_type_id" varchar NOT NULL, CONSTRAINT "FK_Party_party_type_id" FOREIGN KEY ("party_type_id") REFERENCES "PartyType" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION)`);
8038
+ await queryRunner.query(`INSERT INTO "temporary_Party"("id", "uri", "created_at", "last_updated_at", "party_type_id") SELECT "id", "uri", "created_at", "last_updated_at", "party_type_id" FROM "Party"`);
8039
+ await queryRunner.query(`DROP TABLE "Party"`);
8040
+ await queryRunner.query(`ALTER TABLE "temporary_Party" RENAME TO "Party"`);
8041
+ await queryRunner.query(`DROP INDEX "IDX_PartyRelationship_left_right"`);
8042
+ await queryRunner.query(`CREATE TABLE "temporary_PartyRelationship" ("id" varchar PRIMARY KEY NOT NULL, "left_id" varchar NOT NULL, "right_id" varchar NOT NULL, "created_at" datetime NOT NULL DEFAULT (datetime('now')), "last_updated_at" datetime NOT NULL DEFAULT (datetime('now')), CONSTRAINT "FK_PartyRelationship_left_id" FOREIGN KEY ("left_id") REFERENCES "Party" ("id") ON DELETE CASCADE ON UPDATE NO ACTION, CONSTRAINT "FK_PartyRelationship_right_id" FOREIGN KEY ("right_id") REFERENCES "Party" ("id") ON DELETE CASCADE ON UPDATE NO ACTION)`);
8043
+ await queryRunner.query(`INSERT INTO "temporary_PartyRelationship"("id", "left_id", "right_id", "created_at", "last_updated_at") SELECT "id", "left_id", "right_id", "created_at", "last_updated_at" FROM "PartyRelationship"`);
8044
+ await queryRunner.query(`DROP TABLE "PartyRelationship"`);
8045
+ await queryRunner.query(`ALTER TABLE "temporary_PartyRelationship" RENAME TO "PartyRelationship"`);
8046
+ await queryRunner.query(`CREATE UNIQUE INDEX "IDX_PartyRelationship_left_right" ON "PartyRelationship" ("left_id", "right_id")`);
8047
+ await queryRunner.query(`DROP INDEX "IDX_BaseContact_type"`);
8048
+ await queryRunner.query(`CREATE TABLE "temporary_BaseContact" ("id" varchar PRIMARY KEY NOT NULL, "created_at" datetime NOT NULL DEFAULT (datetime('now')), "last_updated_at" datetime NOT NULL DEFAULT (datetime('now')), "legal_name" varchar(255), "display_name" varchar(255), "first_name" varchar(255), "middle_name" varchar(255), "last_name" varchar(255), "type" varchar NOT NULL, "party_id" varchar, CONSTRAINT "UQ_BaseContact_legal_name" UNIQUE ("legal_name"), CONSTRAINT "REL_BaseContact_party_id" UNIQUE ("party_id"), CONSTRAINT "FK_BaseContact_party_id" FOREIGN KEY ("party_id") REFERENCES "Party" ("id") ON DELETE CASCADE ON UPDATE NO ACTION)`);
8049
+ await queryRunner.query(`INSERT INTO "temporary_BaseContact"("id", "created_at", "last_updated_at", "legal_name", "display_name", "first_name", "middle_name", "last_name", "type", "party_id") SELECT "id", "created_at", "last_updated_at", "legal_name", "display_name", "first_name", "middle_name", "last_name", "type", "party_id" FROM "BaseContact"`);
8050
+ await queryRunner.query(`DROP TABLE "BaseContact"`);
8051
+ await queryRunner.query(`ALTER TABLE "temporary_BaseContact" RENAME TO "BaseContact"`);
8052
+ await queryRunner.query(`CREATE INDEX "IDX_BaseContact_type" ON "BaseContact" ("type")`);
8053
+ await queryRunner.query(`DROP INDEX "IDX_BaseConfig_type"`);
8054
+ await queryRunner.query(`CREATE TABLE "temporary_BaseConfig" ("id" varchar PRIMARY KEY NOT NULL, "identifier" varchar(255), "redirect_url" varchar(255), "session_id" varchar(255), "client_id" varchar(255), "client_secret" varchar(255), "scopes" text, "issuer" varchar(255), "dangerously_allow_insecure_http_requests" boolean, "client_auth_method" text, "type" varchar NOT NULL, "connection_id" varchar, CONSTRAINT "REL_BaseConfig_connection_id" UNIQUE ("connection_id"), CONSTRAINT "FK_BaseConfig_connection_id" FOREIGN KEY ("connection_id") REFERENCES "Connection" ("id") ON DELETE CASCADE ON UPDATE NO ACTION)`);
8055
+ await queryRunner.query(`INSERT INTO "temporary_BaseConfig"("id", "identifier", "redirect_url", "session_id", "client_id", "client_secret", "scopes", "issuer", "dangerously_allow_insecure_http_requests", "client_auth_method", "type", "connection_id") SELECT "id", "identifier", "redirect_url", "session_id", "client_id", "client_secret", "scopes", "issuer", "dangerously_allow_insecure_http_requests", "client_auth_method", "type", "connection_id" FROM "BaseConfig"`);
8056
+ await queryRunner.query(`DROP TABLE "BaseConfig"`);
8057
+ await queryRunner.query(`ALTER TABLE "temporary_BaseConfig" RENAME TO "BaseConfig"`);
8058
+ await queryRunner.query(`CREATE INDEX "IDX_BaseConfig_type" ON "BaseConfig" ("type")`);
8059
+ await queryRunner.query(`DROP INDEX "IDX_PartyType_type_tenant_id"`);
8060
+ await queryRunner.query(`DROP TABLE "PartyType"`);
8061
+ await queryRunner.query(`DROP TABLE "Connection"`);
8062
+ await queryRunner.query(`DROP TABLE "Identity"`);
8063
+ await queryRunner.query(`DROP TABLE "CorrelationIdentifier"`);
8064
+ await queryRunner.query(`DROP TABLE "ElectronicAddress"`);
8065
+ await queryRunner.query(`DROP TABLE "PhysicalAddress"`);
7918
8066
  }
7919
8067
  };
7920
8068
 
7921
- // src/migrations/postgres/1701634812183-CreateAuditEvents.ts
7922
- var CreateAuditEvents1701634812183 = class {
8069
+ // src/migrations/postgres/1690925872592-CreateContacts.ts
8070
+ import { enablePostgresUuidExtension as enablePostgresUuidExtension3 } from "@sphereon/ssi-sdk.core";
8071
+ var CreateContacts1690925872592 = class {
7923
8072
  static {
7924
- __name(this, "CreateAuditEvents1701634812183");
7925
- }
7926
- name = "CreateAuditEvents1701634812183";
7927
- async up(queryRunner) {
7928
- await queryRunner.query(`CREATE TYPE "public"."Level_enum" AS ENUM('0', '1', '2', '3', '4')`);
7929
- await queryRunner.query(`CREATE TYPE "public"."System_enum" AS ENUM('general', 'kms', 'identity', 'oid4vci', 'oid4vp', 'siopv2', 'PE', 'credentials', 'web3', 'profile', 'contact')`);
7930
- await queryRunner.query(`CREATE TYPE "public"."Subsystem_type_enum" AS ENUM('key', 'did_provider', 'did_resolver', 'oid4vp_op', 'oid4vci_client', 'siopv2_op', 'contact_manager', 'vc_issuer', 'vc_verifier', 'vc_persistence', 'transport', 'profile', 'api')`);
7931
- await queryRunner.query(`CREATE TYPE "public"."Action_type_enum" AS ENUM('create', 'read', 'update', 'delete', 'execute')`);
7932
- await queryRunner.query(`CREATE TYPE "public"."Initiator_type_enum" AS ENUM('user', 'system', 'external')`);
7933
- await queryRunner.query(`CREATE TYPE "public"."System_correlation_id_type_enum" AS ENUM('did', 'url', 'email', 'hostname', 'phone', 'user')`);
7934
- await queryRunner.query(`CREATE TYPE "public"."Party_correlation_type_enum" AS ENUM('did', 'url', 'email', 'hostname', 'phone')`);
7935
- await queryRunner.query(`CREATE TYPE "public"."Event_type_enum" AS ENUM('audit', 'activity', 'general')`);
7936
- await queryRunner.query(`CREATE TYPE "public"."Event_credential_type_enum" AS ENUM('JSON_LD', 'JWT', 'SD_JWT', 'MSO_MDOC')`);
7937
- await queryRunner.query(`CREATE TABLE "AuditEvents" (
7938
- "id" uuid NOT NULL DEFAULT uuid_generate_v4(),
7939
- "eventType" "public"."Event_type_enum" NOT NULL,
7940
- "timestamp" TIMESTAMP NOT NULL,
7941
- "level" "public"."Level_enum" NOT NULL,
7942
- "correlationId" TEXT NOT NULL,
7943
- "system" "public"."System_enum" NOT NULL,
7944
- "subSystemType" "public"."Subsystem_type_enum" NOT NULL,
7945
- "actionType" "public"."Action_type_enum" NOT NULL,
7946
- "actionSubType" TEXT NOT NULL,
7947
- "initiatorType" "public"."Initiator_type_enum" NOT NULL,
7948
- "systemCorrelationIdType" "public"."System_correlation_id_type_enum",
7949
- "systemCorrelationId" TEXT,
7950
- "systemAlias" TEXT,
7951
- "partyCorrelationType" "public"."Party_correlation_type_enum",
7952
- "partyCorrelationId" TEXT,
7953
- "partyAlias" TEXT,
7954
- "credentialType" "public"."Event_credential_type_enum",
7955
- "credentialHash" TEXT,
7956
- "originalCredential" TEXT,
7957
- "sharePurpose" TEXT,
7958
- "description" TEXT NOT NULL,
7959
- "data" TEXT,
7960
- "diagnosticData" TEXT,
7961
- "created_at" TIMESTAMP NOT NULL DEFAULT now(),
7962
- "last_updated_at" TIMESTAMP NOT NULL DEFAULT now(),
7963
- CONSTRAINT "PK_AuditEvents_id" PRIMARY KEY ("id"))`);
8073
+ __name(this, "CreateContacts1690925872592");
8074
+ }
8075
+ name = "CreateContacts1690925872592";
8076
+ async up(queryRunner) {
8077
+ await enablePostgresUuidExtension3(queryRunner);
8078
+ await queryRunner.query(`ALTER TABLE "CorrelationIdentifier" DROP CONSTRAINT "FK_CorrelationIdentifier_identityId"`);
8079
+ await queryRunner.query(`ALTER TABLE "IdentityMetadata" DROP CONSTRAINT "FK_IdentityMetadata_identityId"`);
8080
+ await queryRunner.query(`ALTER TABLE "Identity" DROP CONSTRAINT "FK_Identity_contactId"`);
8081
+ await queryRunner.query(`ALTER TABLE "Connection" DROP CONSTRAINT "FK_Connection_identityId"`);
8082
+ await queryRunner.query(`ALTER TABLE "CorrelationIdentifier" RENAME COLUMN "identityId" TO "identity_id"`);
8083
+ await queryRunner.query(`ALTER TABLE "Connection" RENAME COLUMN "identityId" TO "identity_id"`);
8084
+ await queryRunner.query(`CREATE TYPE "public"."PartyType_type_enum" AS ENUM('naturalPerson', 'organization')`);
8085
+ await queryRunner.query(`CREATE TYPE "public"."PartyOrigin_type_enum" AS ENUM('INTERNAL', 'EXTERNAL')`);
8086
+ await queryRunner.query(`CREATE TABLE "PartyType" ("id" uuid NOT NULL DEFAULT uuid_generate_v4(), "type" "public"."PartyType_type_enum" NOT NULL, "origin" "public"."PartyOrigin_type_enum" NOT NULL, "name" character varying(255) NOT NULL, "description" character varying(255), "tenant_id" character varying(255) NOT NULL, "created_at" TIMESTAMP NOT NULL DEFAULT now(), "last_updated_at" TIMESTAMP NOT NULL DEFAULT now(), CONSTRAINT "UQ_PartyType_name" UNIQUE ("name"), CONSTRAINT "PK_PartyType_id" PRIMARY KEY ("id"))`);
8087
+ await queryRunner.query(`CREATE UNIQUE INDEX "IDX_PartyType_type_tenant_id" ON "PartyType" ("type", "tenant_id")`);
8088
+ await queryRunner.query(`CREATE TABLE "BaseContact" ("id" uuid NOT NULL DEFAULT uuid_generate_v4(), "created_at" TIMESTAMP NOT NULL DEFAULT now(), "last_updated_at" TIMESTAMP NOT NULL DEFAULT now(), "legal_name" character varying(255), "display_name" character varying(255), "first_name" character varying(255), "middle_name" character varying(255), "last_name" character varying(255), "type" character varying NOT NULL, "party_id" uuid, CONSTRAINT "UQ_BaseContact_legal_name" UNIQUE ("legal_name"), CONSTRAINT "REL_BaseContact_party_id" UNIQUE ("party_id"), CONSTRAINT "PK_BaseContact_id" PRIMARY KEY ("id"))`);
8089
+ await queryRunner.query(`CREATE INDEX "IDX_BaseContact_type" ON "BaseContact" ("type")`);
8090
+ await queryRunner.query(`CREATE TABLE "PartyRelationship" ("id" uuid NOT NULL DEFAULT uuid_generate_v4(), "left_id" uuid NOT NULL, "right_id" uuid NOT NULL, "created_at" TIMESTAMP NOT NULL DEFAULT now(), "last_updated_at" TIMESTAMP NOT NULL DEFAULT now(), CONSTRAINT "PK_PartyRelationship_id" PRIMARY KEY ("id"))`);
8091
+ await queryRunner.query(`CREATE UNIQUE INDEX "IDX_PartyRelationship_left_right" ON "PartyRelationship" ("left_id", "right_id")`);
8092
+ await queryRunner.query(`CREATE TABLE "ElectronicAddress" ("id" uuid NOT NULL DEFAULT uuid_generate_v4(), "type" character varying(255) NOT NULL, "electronic_address" character varying(255) NOT NULL, "created_at" TIMESTAMP NOT NULL DEFAULT now(), "last_updated_at" TIMESTAMP NOT NULL DEFAULT now(), "partyId" uuid, CONSTRAINT "PK_ElectronicAddress_id" PRIMARY KEY ("id"))`);
8093
+ await queryRunner.query(`CREATE TABLE "PhysicalAddress" ("id" uuid NOT NULL DEFAULT uuid_generate_v4(), "type" character varying(255) NOT NULL, "street_name" character varying(255) NOT NULL, "street_number" character varying(255) NOT NULL, "postal_code" character varying(255) NOT NULL, "city_name" character varying(255) NOT NULL, "province_name" character varying(255) NOT NULL, "country_code" character varying(2) NOT NULL, "building_name" character varying(255), "partyId" uuid, "created_at" TIMESTAMP NOT NULL DEFAULT now(), "last_updated_at" TIMESTAMP NOT NULL DEFAULT now(), CONSTRAINT "PK_PhysicalAddress_id" PRIMARY KEY ("id"))`);
8094
+ await queryRunner.query(`CREATE TABLE "Party" ("id" uuid NOT NULL DEFAULT uuid_generate_v4(), "uri" character varying(255), "created_at" TIMESTAMP NOT NULL DEFAULT now(), "last_updated_at" TIMESTAMP NOT NULL DEFAULT now(), "party_type_id" uuid NOT NULL, CONSTRAINT "PK_Party_id" PRIMARY KEY ("id"))`);
8095
+ await queryRunner.query(`CREATE TABLE "BaseConfig" ("id" uuid NOT NULL DEFAULT uuid_generate_v4(), "identifier" character varying(255), "redirect_url" character varying(255), "session_id" character varying(255), "client_id" character varying(255), "client_secret" character varying(255), "scopes" text, "issuer" character varying(255), "dangerously_allow_insecure_http_requests" boolean, "client_auth_method" text, "type" character varying NOT NULL, "connection_id" uuid, CONSTRAINT "REL_BaseConfig_connection_id" UNIQUE ("connection_id"), CONSTRAINT "PK_BaseConfig_id" PRIMARY KEY ("id"))`);
8096
+ await queryRunner.query(`CREATE INDEX "IDX_BaseConfig_type" ON "BaseConfig" ("type")`);
8097
+ await queryRunner.query(`ALTER TABLE "Identity" RENAME COLUMN "contactId" TO "partyId"`);
8098
+ await queryRunner.query(`ALTER TABLE "Identity" ALTER COLUMN "roles" SET NOT NULL`);
8099
+ await queryRunner.query(`CREATE TYPE "public"."IdentityOrigin_type_enum" AS ENUM('INTERNAL', 'EXTERNAL')`);
8100
+ await queryRunner.query(`ALTER TABLE "Identity" ADD COLUMN "origin" "public"."IdentityOrigin_type_enum" DEFAULT 'EXTERNAL' NOT NULL`);
8101
+ await queryRunner.query(`ALTER TABLE "Identity" ALTER COLUMN "origin" DROP DEFAULT`);
8102
+ await queryRunner.query(`ALTER TABLE "CorrelationIdentifier" ADD CONSTRAINT "FK_CorrelationIdentifier_identity_id" FOREIGN KEY ("identity_id") REFERENCES "Identity"("id") ON DELETE CASCADE ON UPDATE NO ACTION`);
8103
+ await queryRunner.query(`ALTER TABLE "IdentityMetadata" ADD CONSTRAINT "FK_IdentityMetadata_identityId" FOREIGN KEY ("identityId") REFERENCES "Identity"("id") ON DELETE CASCADE ON UPDATE NO ACTION`);
8104
+ await queryRunner.query(`ALTER TABLE "BaseContact" ADD CONSTRAINT "FK_BaseContact_party_id" FOREIGN KEY ("party_id") REFERENCES "Party"("id") ON DELETE CASCADE ON UPDATE NO ACTION`);
8105
+ await queryRunner.query(`ALTER TABLE "PartyRelationship" ADD CONSTRAINT "FK_PartyRelationship_left_id" FOREIGN KEY ("left_id") REFERENCES "Party"("id") ON DELETE CASCADE ON UPDATE NO ACTION`);
8106
+ await queryRunner.query(`ALTER TABLE "PartyRelationship" ADD CONSTRAINT "FK_PartyRelationship_right_id" FOREIGN KEY ("right_id") REFERENCES "Party"("id") ON DELETE CASCADE ON UPDATE NO ACTION`);
8107
+ await queryRunner.query(`ALTER TABLE "ElectronicAddress" ADD CONSTRAINT "FK_ElectronicAddress_partyId" FOREIGN KEY ("partyId") REFERENCES "Party"("id") ON DELETE CASCADE ON UPDATE NO ACTION`);
8108
+ await queryRunner.query(`ALTER TABLE "PhysicalAddress" ADD CONSTRAINT "FK_PhysicalAddress_partyId" FOREIGN KEY ("partyId") REFERENCES "Party" ("id") ON DELETE CASCADE ON UPDATE NO ACTION`);
8109
+ await queryRunner.query(`ALTER TABLE "Party" ADD CONSTRAINT "FK_Party_party_type_id" FOREIGN KEY ("party_type_id") REFERENCES "PartyType"("id") ON DELETE NO ACTION ON UPDATE NO ACTION`);
8110
+ await queryRunner.query(`ALTER TABLE "Identity" ADD CONSTRAINT "FK_Identity_partyId" FOREIGN KEY ("partyId") REFERENCES "Party"("id") ON DELETE CASCADE ON UPDATE NO ACTION`);
8111
+ await queryRunner.query(`ALTER TABLE "Connection" ADD CONSTRAINT "FK_Connection_identity_id" FOREIGN KEY ("identity_id") REFERENCES "Identity"("id") ON DELETE CASCADE ON UPDATE NO ACTION`);
8112
+ await queryRunner.query(`ALTER TABLE "BaseConfig" ADD CONSTRAINT "FK_BaseConfig_connection_id" FOREIGN KEY ("connection_id") REFERENCES "Connection"("id") ON DELETE CASCADE ON UPDATE NO ACTION`);
8113
+ await queryRunner.query(`ALTER TABLE "CorrelationIdentifier" RENAME CONSTRAINT "UQ_Correlation_id" TO "UQ_CorrelationIdentifier_correlation_id"`);
8114
+ await queryRunner.query(`ALTER TABLE "Identity" RENAME CONSTRAINT "UQ_Identity_Alias" TO "UQ_Identity_alias"`);
8115
+ await queryRunner.query(`INSERT INTO "BaseConfig"("id", "identifier", "redirect_url", "session_id", "client_id", "client_secret", "scopes", "issuer", "dangerously_allow_insecure_http_requests", "client_auth_method", "type", "connection_id") SELECT "id", "identifier", "redirect_url", "session_id", "client_id", "client_secret", "scopes", "issuer", "dangerously_allow_insecure_http_requests", "client_auth_method", "type", "connectionId" FROM "BaseConfigEntity"`);
8116
+ await queryRunner.query(`DROP TABLE "BaseConfigEntity"`);
8117
+ await queryRunner.query(`INSERT INTO "PartyType"(id, type, origin, name, description, tenant_id, created_at, last_updated_at) VALUES ('3875c12e-fdaa-4ef6-a340-c936e054b627', 'organization', 'INTERNAL', 'Sphereon_default_organization_type', 'sphereon_default_organization', '95e09cfc-c974-4174-86aa-7bf1d5251fb4', now(), now())`);
8118
+ await queryRunner.query(`INSERT INTO "PartyType"(id, type, origin, name, description, tenant_id, created_at, last_updated_at) VALUES ('7d248798-41ca-4fc1-a130-9934b43d532e', 'naturalPerson', 'INTERNAL', 'Sphereon_default_natural_person_type', 'sphereon_default_natural_person', '95e09cfc-c974-4174-86aa-7bf1d5251fb4', now(), now())`);
8119
+ await queryRunner.query(`INSERT INTO "Party"(id, uri, created_at, last_updated_at, party_type_id) SELECT id, uri, created_at, last_updated_at, '3875c12e-fdaa-4ef6-a340-c936e054b627' FROM "Contact"`);
8120
+ await queryRunner.query(`INSERT INTO "BaseContact"(id, legal_name, display_name, party_id, created_at, last_updated_at, type) SELECT id, name, alias, id, created_at, last_updated_at, 'Organization' FROM "Contact"`);
8121
+ await queryRunner.query(`DROP TABLE "Contact"`);
7964
8122
  }
7965
8123
  async down(queryRunner) {
7966
- await queryRunner.query(`DROP TABLE "AuditEvents"`);
7967
- await queryRunner.query(`DROP TYPE "public"."Party_correlation_type_enum"`);
7968
- await queryRunner.query(`DROP TYPE "public"."System_correlation_id_type_enum"`);
7969
- await queryRunner.query(`DROP TYPE "public"."Initiator_type_enum"`);
7970
- await queryRunner.query(`DROP TYPE "public"."Action_type_enum"`);
7971
- await queryRunner.query(`DROP TYPE "public"."Subsystem_type_enum"`);
7972
- await queryRunner.query(`DROP TYPE "public"."System_enum"`);
7973
- await queryRunner.query(`DROP TYPE "public"."Level_enum"`);
8124
+ await queryRunner.query(`ALTER TABLE "BaseConfig" DROP CONSTRAINT "FK_BaseConfig_connection_id"`);
8125
+ await queryRunner.query(`ALTER TABLE "Connection" DROP CONSTRAINT "FK_Connection_identity_id"`);
8126
+ await queryRunner.query(`ALTER TABLE "Identity" DROP CONSTRAINT "FK_Identity_partyId"`);
8127
+ await queryRunner.query(`ALTER TABLE "Party" DROP CONSTRAINT "FK_Party_party_type_id"`);
8128
+ await queryRunner.query(`ALTER TABLE "PhysicalAddress" DROP CONSTRAINT "FK_PhysicalAddress_partyId"`);
8129
+ await queryRunner.query(`ALTER TABLE "ElectronicAddress" DROP CONSTRAINT "FK_ElectronicAddress_partyId"`);
8130
+ await queryRunner.query(`ALTER TABLE "PartyRelationship" DROP CONSTRAINT "FK_PartyRelationship_right_id"`);
8131
+ await queryRunner.query(`ALTER TABLE "PartyRelationship" DROP CONSTRAINT "FK_PartyRelationship_left_id"`);
8132
+ await queryRunner.query(`ALTER TABLE "BaseContact" DROP CONSTRAINT "FK_BaseContact_party_id"`);
8133
+ await queryRunner.query(`ALTER TABLE "IdentityMetadata" DROP CONSTRAINT "FK_IdentityMetadata_identityId"`);
8134
+ await queryRunner.query(`ALTER TABLE "CorrelationIdentifier" DROP CONSTRAINT "FK_CorrelationIdentifier_identity_id"`);
8135
+ await queryRunner.query(`ALTER TABLE "Identity" ALTER COLUMN "roles" DROP NOT NULL`);
8136
+ await queryRunner.query(`ALTER TABLE "Identity" DROP COLUMN "origin"`);
8137
+ await queryRunner.query(`DROP TYPE "public"."IdentityOrigin_type_enum"`);
8138
+ await queryRunner.query(`ALTER TABLE "Identity" RENAME COLUMN "partyId" TO "contactId"`);
8139
+ await queryRunner.query(`ALTER TABLE "Connection" RENAME COLUMN "identity_id" TO "identityId"`);
8140
+ await queryRunner.query(`ALTER TABLE "CorrelationIdentifier" RENAME COLUMN "identity_id" TO "identityId"`);
8141
+ await queryRunner.query(`DROP INDEX "IDX_BaseConfig_type"`);
8142
+ await queryRunner.query(`DROP TABLE "BaseConfig"`);
8143
+ await queryRunner.query(`DROP TABLE "Party"`);
8144
+ await queryRunner.query(`DROP INDEX "IDX_PartyRelationship_left_right"`);
8145
+ await queryRunner.query(`DROP TABLE "PartyRelationship"`);
8146
+ await queryRunner.query(`DROP INDEX "IDX_BaseContact_type"`);
8147
+ await queryRunner.query(`DROP TABLE "BaseContact"`);
8148
+ await queryRunner.query(`DROP TABLE "ElectronicAddress"`);
8149
+ await queryRunner.query(`DROP TABLE "PhysicalAddress"`);
8150
+ await queryRunner.query(`DROP INDEX "IDX_PartyType_type_tenant_id"`);
8151
+ await queryRunner.query(`DROP TABLE "PartyType"`);
8152
+ await queryRunner.query(`DROP TYPE "public"."PartyOrigin_type_enum"`);
8153
+ await queryRunner.query(`DROP TYPE "public"."PartyType_type_enum"`);
8154
+ await queryRunner.query(`ALTER TABLE "Connection" ADD CONSTRAINT "FK_Connection_identityId" FOREIGN KEY ("identityId") REFERENCES "Identity"("id") ON DELETE CASCADE ON UPDATE NO ACTION`);
8155
+ await queryRunner.query(`ALTER TABLE "Identity" ADD CONSTRAINT "FK_Identity_contactId" FOREIGN KEY ("contactId") REFERENCES "Contact"("id") ON DELETE CASCADE ON UPDATE NO ACTION`);
8156
+ await queryRunner.query(`ALTER TABLE "IdentityMetadata" ADD CONSTRAINT "FK_IdentityMetadata_identityId" FOREIGN KEY ("identityId") REFERENCES "Identity"("id") ON DELETE CASCADE ON UPDATE NO ACTION`);
8157
+ await queryRunner.query(`ALTER TABLE "CorrelationIdentifier" ADD CONSTRAINT "FK_CorrelationIdentifier_identityId" FOREIGN KEY ("identityId") REFERENCES "Identity"("id") ON DELETE CASCADE ON UPDATE NO ACTION`);
8158
+ await queryRunner.query(`CREATE TABLE "Contact" ("id" uuid NOT NULL DEFAULT uuid_generate_v4(), "uri" character varying(255), "created_at" TIMESTAMP NOT NULL DEFAULT now(), "last_updated_at" TIMESTAMP NOT NULL DEFAULT now(), "name" character varying(255), "alias" character varying(255), CONSTRAINT "PK_Contact_id" PRIMARY KEY ("id"))`);
8159
+ await queryRunner.query(`INSERT INTO "Contact"(id, uri, created_at, last_updated_at, name, alias) SELECT id, uri, created_at, last_updated_at, (SELECT legal_name FROM "BaseContact" WHERE "BaseContact"."party_id" = "Party"."id"), (SELECT display_name FROM "BaseContact" WHERE "BaseContact"."party_id" = "Party"."id") FROM "Party" WHERE party_type_id = '3875c12e-fdaa-4ef6-a340-c936e054b627'`);
7974
8160
  }
7975
8161
  };
7976
8162
 
7977
- // src/migrations/generic/5-CreateAuditEvents.ts
7978
- var debug12 = Debug12("sphereon:ssi-sdk:migrations");
7979
- var CreateAuditEvents1701635835330 = class {
8163
+ // src/migrations/generic/3-CreateContacts.ts
8164
+ var debug14 = Debug14("sphereon:ssi-sdk:migrations");
8165
+ var CreateContacts1690925872318 = class {
7980
8166
  static {
7981
- __name(this, "CreateAuditEvents1701635835330");
8167
+ __name(this, "CreateContacts1690925872318");
7982
8168
  }
7983
- name = "CreateAuditEvents1701635835330";
8169
+ name = "CreateContacts1690925872318";
7984
8170
  async up(queryRunner) {
7985
- debug12("migration: creating audit events tables");
8171
+ debug14("migration: creating contacts tables");
7986
8172
  const dbType = queryRunner.connection.driver.options.type;
7987
8173
  switch (dbType) {
7988
8174
  case "postgres": {
7989
- debug12("using postgres migration file");
7990
- const mig = new CreateAuditEvents1701634812183();
8175
+ debug14("using postgres migration file");
8176
+ const mig = new CreateContacts1690925872592();
7991
8177
  await mig.up(queryRunner);
7992
- debug12("Migration statements executed");
8178
+ debug14("Migration statements executed");
7993
8179
  return;
7994
8180
  }
7995
8181
  case "sqlite":
7996
8182
  case "expo":
7997
8183
  case "react-native": {
7998
- debug12("using sqlite/react-native migration file");
7999
- const mig = new CreateAuditEvents1701634819487();
8184
+ debug14("using sqlite/react-native migration file");
8185
+ const mig = new CreateContacts1690925872693();
8000
8186
  await mig.up(queryRunner);
8001
- debug12("Migration statements executed");
8187
+ debug14("Migration statements executed");
8002
8188
  return;
8003
8189
  }
8004
8190
  default:
@@ -8006,23 +8192,23 @@ var CreateAuditEvents1701635835330 = class {
8006
8192
  }
8007
8193
  }
8008
8194
  async down(queryRunner) {
8009
- debug12("migration: reverting audit events tables");
8195
+ debug14("migration: reverting contacts tables");
8010
8196
  const dbType = queryRunner.connection.driver.options.type;
8011
8197
  switch (dbType) {
8012
8198
  case "postgres": {
8013
- debug12("using postgres migration file");
8014
- const mig = new CreateAuditEvents1701634812183();
8199
+ debug14("using postgres migration file");
8200
+ const mig = new CreateContacts1690925872592();
8015
8201
  await mig.down(queryRunner);
8016
- debug12("Migration statements executed");
8202
+ debug14("Migration statements executed");
8017
8203
  return;
8018
8204
  }
8019
8205
  case "sqlite":
8020
8206
  case "expo":
8021
8207
  case "react-native": {
8022
- debug12("using sqlite/react-native migration file");
8023
- const mig = new CreateAuditEvents1701634819487();
8208
+ debug14("using sqlite/react-native migration file");
8209
+ const mig = new CreateContacts1690925872693();
8024
8210
  await mig.down(queryRunner);
8025
- debug12("Migration statements executed");
8211
+ debug14("Migration statements executed");
8026
8212
  return;
8027
8213
  }
8028
8214
  default:
@@ -8031,429 +8217,391 @@ var CreateAuditEvents1701635835330 = class {
8031
8217
  }
8032
8218
  };
8033
8219
 
8034
- // src/migrations/generic/6-CreateDigitalCredential.ts
8035
- import Debug13 from "debug";
8036
-
8037
- // src/migrations/postgres/1708525189001-CreateDigitalCredential.ts
8038
- var CreateDigitalCredential1708525189001 = class {
8039
- static {
8040
- __name(this, "CreateDigitalCredential1708525189001");
8041
- }
8042
- name = "CreateDigitalCredential1708525189001";
8043
- async up(queryRunner) {
8044
- await queryRunner.query(`CREATE TYPE "digital_document_type" AS ENUM('VC', 'VP', 'C', 'P')`);
8045
- await queryRunner.query(`CREATE TYPE "digital_regulation_type" AS ENUM('PID', 'QEAA', 'EAA', 'NON_REGULATED')`);
8046
- await queryRunner.query(`CREATE TYPE "digital_credential_document_format" AS ENUM('JSON_LD', 'JWT', 'SD_JWT', 'MSO_MDOC')`);
8047
- await queryRunner.query(`CREATE TYPE "digital_credential_credential_role" AS ENUM('ISSUER', 'VERIFIER', 'HOLDER', 'FEDERATION_TRUST_ANCHOR')`);
8048
- await queryRunner.query(`CREATE TYPE "digital_credential_correlation_type" AS ENUM('DID', 'KID', 'URL', 'X509_SAN')`);
8049
- await queryRunner.query(`CREATE TYPE "digital_credential_state_type" AS ENUM('REVOKED', 'VERIFIED', 'EXPIRED')`);
8050
- await queryRunner.query(`
8051
- CREATE TABLE "DigitalCredential" (
8052
- "id" uuid NOT NULL DEFAULT uuid_generate_v4(),
8053
- "parent_id" text,
8054
- "document_type" "digital_document_type" NOT NULL,
8055
- "regulation_type" "digital_regulation_type" NOT NULL DEFAULT 'NON_REGULATED'::"digital_regulation_type",
8056
- "document_format" "digital_credential_document_format" NOT NULL,
8057
- "credential_role" "digital_credential_credential_role" NOT NULL,
8058
- "raw_document" text NOT NULL,
8059
- "uniform_document" text NOT NULL,
8060
- "credential_id" text,
8061
- "hash" text NOT NULL,
8062
- "kms_key_ref" text,
8063
- "identifier_method" text,
8064
- "issuer_correlation_type" "digital_credential_correlation_type" NOT NULL,
8065
- "subject_correlation_type" "digital_credential_correlation_type",
8066
- "issuer_correlation_id" text NOT NULL,
8067
- "subject_correlation_id" text,
8068
- "verified_state" "digital_credential_state_type",
8069
- "issuer_signed" boolean,
8070
- "rp_correlation_id" text,
8071
- "rp_correlation_type" "digital_credential_correlation_type",
8072
- "tenant_id" text,
8073
- "created_at" TIMESTAMP NOT NULL DEFAULT now(),
8074
- "last_updated_at" TIMESTAMP NOT NULL DEFAULT now(),
8075
- "presented_at" DATE,
8076
- "valid_from" DATE,
8077
- "valid_until" DATE,
8078
- "verified_at" DATE,
8079
- "revoked_at" DATE,
8080
- PRIMARY KEY ("id"),
8081
- UNIQUE ("hash", "credential_role")
8082
- )
8083
- `);
8084
- }
8085
- async down(queryRunner) {
8086
- await queryRunner.query(`DROP TABLE "DigitalCredential"`);
8087
- await queryRunner.query(`DROP TYPE "digital_credential_state_type"`);
8088
- await queryRunner.query(`DROP TYPE "digital_credential_correlation_type"`);
8089
- await queryRunner.query(`DROP TYPE "digital_credential_document_format"`);
8090
- await queryRunner.query(`DROP TYPE "digital_credential_credential_role"`);
8091
- await queryRunner.query(`DROP TYPE "digital_regulation_type"`);
8092
- await queryRunner.query(`DROP TYPE "digital_document_type"`);
8093
- }
8094
- };
8220
+ // src/migrations/generic/4-CreateStatusList.ts
8221
+ import Debug15 from "debug";
8095
8222
 
8096
- // src/migrations/sqlite/1708525189002-CreateDigitalCredential.ts
8097
- var CreateDigitalCredential1708525189002 = class {
8223
+ // src/migrations/postgres/1693866470001-CreateStatusList.ts
8224
+ var CreateStatusList1693866470001 = class {
8098
8225
  static {
8099
- __name(this, "CreateDigitalCredential1708525189002");
8226
+ __name(this, "CreateStatusList1693866470001");
8100
8227
  }
8101
- name = "CreateDigitalCredential1708525189002";
8228
+ name = "CreateStatusList1693866470001";
8102
8229
  async up(queryRunner) {
8103
- await queryRunner.query(`
8104
- CREATE TABLE "DigitalCredential" (
8105
- "id" varchar PRIMARY KEY NOT NULL,
8106
- "parent_id" text,
8107
- "document_type" varchar CHECK( "document_type" IN ('VC', 'VP', 'C', 'P') ) NOT NULL,
8108
- "regulation_type" varchar CHECK( "regulation_type" IN ('PID', 'QEAA', 'EAA', 'NON_REGULATED') ) NOT NULL DEFAULT 'NON_REGULATED',
8109
- "document_format" varchar CHECK( "document_format" IN ('JSON_LD', 'JWT', 'SD_JWT', 'MSO_MDOC') ) NOT NULL,
8110
- "credential_role" varchar CHECK( "credential_role" IN ('ISSUER', 'VERIFIER', 'HOLDER', 'FEDERATION_TRUST_ANCHOR') ) NOT NULL,
8111
- "raw_document" text NOT NULL,
8112
- "uniform_document" text NOT NULL,
8113
- "credential_id" text,
8114
- "hash" text NOT NULL,
8115
- "kms_key_ref" text,
8116
- "identifier_method" text,
8117
- "issuer_correlation_type" varchar CHECK( "issuer_correlation_type" IN ('DID', 'KID', 'URL', 'X509_SAN') ) NOT NULL,
8118
- "subject_correlation_type" varchar CHECK( "subject_correlation_type" IN ('DID', 'KID', 'URL', 'X509_SAN') ),
8119
- "issuer_correlation_id" text NOT NULL,
8120
- "subject_correlation_id" text,
8121
- "issuer_signed" boolean,
8122
- "rp_correlation_id" text,
8123
- "rp_correlation_type" varchar CHECK( "issuer_correlation_type" IN ('DID', 'KID', 'URL', 'X509_SAN') ),
8124
- "verified_state" varchar CHECK( "verified_state" IN ('REVOKED', 'VERIFIED', 'EXPIRED') ),
8125
- "tenant_id" text,
8126
- "created_at" datetime NOT NULL DEFAULT (datetime('now')),
8127
- "last_updated_at" datetime NOT NULL DEFAULT (datetime('now')),
8128
- "presented_at" datetime,
8129
- "valid_from" datetime,
8130
- "valid_until" datetime,
8131
- "verified_at" datetime,
8132
- "revoked_at" datetime,
8133
- UNIQUE ("hash", "credential_role")
8134
- )
8135
- `);
8230
+ await queryRunner.query(`CREATE TYPE "StatusList_type_enum" AS ENUM('StatusList2021')`);
8231
+ await queryRunner.query(`CREATE TYPE "StatusList_drivertype_enum" AS ENUM('agent_typeorm', 'agent_kv_store', 'github', 'agent_filesystem')`);
8232
+ await queryRunner.query(`CREATE TYPE "StatusList_credentialidmode_enum" AS ENUM('ISSUANCE', 'PERSISTENCE', 'NEVER')`);
8233
+ await queryRunner.query(`CREATE TABLE "StatusListEntry"
8234
+ (
8235
+ "statusListId" character varying NOT NULL,
8236
+ "statusListIndex" integer NOT NULL,
8237
+ "credentialId" character varying,
8238
+ "credentialHash" character varying(128),
8239
+ "correlationId" character varying(255),
8240
+ "value" character varying(50),
8241
+ CONSTRAINT "PK_68704d2d13857360c6b44a3d1d0" PRIMARY KEY ("statusListId", "statusListIndex")
8242
+ )`);
8243
+ await queryRunner.query(`CREATE TABLE "StatusList"
8244
+ (
8245
+ "id" character varying NOT NULL,
8246
+ "correlationId" character varying NOT NULL,
8247
+ "length" integer NOT NULL,
8248
+ "issuer" text NOT NULL,
8249
+ "type" "StatusList_type_enum" NOT NULL DEFAULT 'StatusList2021',
8250
+ "driverType" "StatusList_drivertype_enum" NOT NULL DEFAULT 'agent_typeorm',
8251
+ "credentialIdMode" "StatusList_credentialidmode_enum" NOT NULL DEFAULT 'ISSUANCE',
8252
+ "proofFormat" character varying NOT NULL DEFAULT 'lds',
8253
+ "indexingDirection" character varying NOT NULL DEFAULT 'rightToLeft',
8254
+ "statusPurpose" character varying NOT NULL DEFAULT 'revocation',
8255
+ "statusListCredential" text,
8256
+ CONSTRAINT "UQ_correlationId" UNIQUE ("correlationId"),
8257
+ CONSTRAINT "PK_StatusList_Id" PRIMARY KEY ("id")
8258
+ )`);
8259
+ await queryRunner.query(`ALTER TABLE "StatusListEntry"
8260
+ ADD CONSTRAINT "FK_statusListEntry_statusListId" FOREIGN KEY ("statusListId") REFERENCES "StatusList" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION`);
8136
8261
  }
8137
8262
  async down(queryRunner) {
8138
- await queryRunner.query(`DROP TABLE "DigitalCredential"`);
8263
+ await queryRunner.query(`ALTER TABLE "StatusListEntry"
8264
+ DROP CONSTRAINT "FK_statusListEntry_statusListId"`);
8265
+ await queryRunner.query(`DROP TABLE "StatusListEntry"`);
8266
+ await queryRunner.query(`DROP TABLE "StatusList"`);
8267
+ await queryRunner.query(`DROP TYPE "StatusList_credentialidmode_enum"`);
8268
+ await queryRunner.query(`DROP TYPE "StatusList_drivertype_enum"`);
8269
+ await queryRunner.query(`DROP TYPE "StatusList_type_enum"`);
8139
8270
  }
8140
8271
  };
8141
8272
 
8142
- // src/migrations/generic/6-CreateDigitalCredential.ts
8143
- var debug13 = Debug13("sphereon:ssi-sdk:migrations");
8144
- var CreateDigitalCredential1708525189000 = class {
8273
+ // src/migrations/sqlite/1693866470000-CreateStatusList.ts
8274
+ var CreateStatusList1693866470002 = class {
8145
8275
  static {
8146
- __name(this, "CreateDigitalCredential1708525189000");
8276
+ __name(this, "CreateStatusList1693866470002");
8147
8277
  }
8148
- name = "CreateDigitalCredential1708525189000";
8278
+ name = "CreateStatusList1693866470002";
8149
8279
  async up(queryRunner) {
8150
- debug13("migration: creating DigitalCredential tables");
8151
- const dbType = queryRunner.connection.driver.options.type;
8152
- switch (dbType) {
8153
- case "postgres": {
8154
- debug13("using postgres migration file for DigitalCredential");
8155
- const mig = new CreateDigitalCredential1708525189001();
8156
- await mig.up(queryRunner);
8157
- debug13("Postgres Migration statements for DigitalCredential executed");
8158
- return;
8159
- }
8160
- case "sqlite":
8161
- case "expo":
8162
- case "react-native": {
8163
- debug13("using sqlite/react-native migration file for DigitalCredential");
8164
- const mig = new CreateDigitalCredential1708525189002();
8165
- await mig.up(queryRunner);
8166
- debug13("SQLite Migration statements for DigitalCredential executed");
8167
- return;
8168
- }
8169
- default:
8170
- return Promise.reject(`Migrations are currently only supported for sqlite, react-native, expo, and postgres for UniformCredential. Was ${dbType}. Please run your database without migrations and with 'migrationsRun: false' and 'synchronize: true' for now`);
8171
- }
8280
+ await queryRunner.query(`CREATE TABLE "StatusListEntry"
8281
+ (
8282
+ "statusListId" varchar NOT NULL,
8283
+ "statusListIndex" integer NOT NULL,
8284
+ "credentialId" varchar,
8285
+ "credentialHash" varchar(128),
8286
+ "correlationId" varchar(255),
8287
+ "value" varchar(50),
8288
+ PRIMARY KEY ("statusListId", "statusListIndex")
8289
+ )`);
8290
+ await queryRunner.query(`CREATE TABLE "StatusList"
8291
+ (
8292
+ "id" varchar PRIMARY KEY NOT NULL,
8293
+ "correlationId" varchar NOT NULL,
8294
+ "length" integer NOT NULL,
8295
+ "issuer" text NOT NULL,
8296
+ "type" varchar CHECK ( "type" IN ('StatusList2021') ) NOT NULL DEFAULT ('StatusList2021'),
8297
+ "driverType" varchar CHECK ( "driverType" IN ('agent_typeorm', 'agent_kv_store', 'github',
8298
+ 'agent_filesystem') ) NOT NULL DEFAULT ('agent_typeorm'),
8299
+ "credentialIdMode" varchar CHECK ( "credentialIdMode" IN ('ISSUANCE', 'PERSISTENCE', 'NEVER') ) NOT NULL DEFAULT ('ISSUANCE'),
8300
+ "proofFormat" varchar CHECK ( "proofFormat" IN ('lds', 'jwt') ) NOT NULL DEFAULT ('lds'),
8301
+ "indexingDirection" varchar CHECK ( "indexingDirection" IN ('rightToLeft') ) NOT NULL DEFAULT ('rightToLeft'),
8302
+ "statusPurpose" varchar NOT NULL DEFAULT ('revocation'),
8303
+ "statusListCredential" text,
8304
+ CONSTRAINT "UQ_correlationId" UNIQUE ("correlationId")
8305
+ )`);
8306
+ await queryRunner.query(`CREATE TABLE "temporary_StatusListEntry"
8307
+ (
8308
+ "statusListId" varchar NOT NULL,
8309
+ "statusListIndex" integer NOT NULL,
8310
+ "credentialId" varchar,
8311
+ "credentialHash" varchar(128),
8312
+ "correlationId" varchar(255),
8313
+ "value" varchar(50),
8314
+ CONSTRAINT "FK_statusListEntry_statusListId" FOREIGN KEY ("statusListId") REFERENCES "StatusList" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION,
8315
+ PRIMARY KEY ("statusListId", "statusListIndex")
8316
+ )`);
8317
+ await queryRunner.query(`INSERT INTO "temporary_StatusListEntry"("statusListId", "statusListIndex", "credentialId",
8318
+ "credentialHash", "correlationId", "value")
8319
+ SELECT "statusListId", "statusListIndex", "credentialId", "credentialHash", "correlationId", "value"
8320
+ FROM "StatusListEntry"`);
8321
+ await queryRunner.query(`DROP TABLE "StatusListEntry"`);
8322
+ await queryRunner.query(`ALTER TABLE "temporary_StatusListEntry" RENAME TO "StatusListEntry"`);
8172
8323
  }
8173
8324
  async down(queryRunner) {
8174
- debug13("migration: reverting DigitalCredential tables");
8175
- const dbType = queryRunner.connection.driver.options.type;
8176
- switch (dbType) {
8177
- case "postgres": {
8178
- debug13("using postgres migration file for DigitalCredential");
8179
- const mig = new CreateDigitalCredential1708525189001();
8180
- await mig.down(queryRunner);
8181
- debug13("Postgres Migration statements for DigitalCredential reverted");
8182
- return;
8183
- }
8184
- case "sqlite":
8185
- case "expo":
8186
- case "react-native": {
8187
- debug13("using sqlite/react-native migration file for DigitalCredential");
8188
- const mig = new CreateDigitalCredential1708525189002();
8189
- await mig.down(queryRunner);
8190
- debug13("SQLite Migration statements for DigitalCredential reverted");
8191
- return;
8192
- }
8193
- default:
8194
- return Promise.reject(`Migrations are currently only supported for sqlite, react-native, expo, and postgres for DigitalCredential. Was ${dbType}. Please run your database without migrations and with 'migrationsRun: false' and 'synchronize: true' for now`);
8195
- }
8325
+ await queryRunner.query(`DROP TABLE "StatusListEntry"`);
8326
+ await queryRunner.query(`DROP TABLE "StatusList"`);
8196
8327
  }
8197
8328
  };
8198
8329
 
8199
- // src/migrations/generic/7-CreateMachineStateStore.ts
8200
- import Debug14 from "debug";
8201
-
8202
- // src/migrations/postgres/1708797018115-CreateMachineStateStore.ts
8203
- var CreateMachineStateStore1708797018115 = class {
8330
+ // src/migrations/postgres/1737110469001-UpdateStatusList.ts
8331
+ var UpdateStatusList1737110469001 = class {
8204
8332
  static {
8205
- __name(this, "CreateMachineStateStore1708797018115");
8333
+ __name(this, "UpdateStatusList1737110469001");
8206
8334
  }
8207
- name = "CreateMachineStateStore1708797018115";
8335
+ name = "UpdateStatusList1737110469001";
8208
8336
  async up(queryRunner) {
8209
- await queryRunner.query(`
8210
- CREATE TABLE "MachineStateInfoEntity" (
8211
- "instance_id" text NOT NULL,
8212
- "session_id" text,
8213
- "latest_state_name" text,
8214
- "machine_name" text NOT NULL,
8215
- "latest_event_type" text NOT NULL,
8216
- "state" text NOT NULL,
8217
- "created_at" TIMESTAMP NOT NULL DEFAULT now(),
8218
- "updated_at" TIMESTAMP NOT NULL DEFAULT now(),
8219
- "updated_count" integer NOT NULL DEFAULT 0,
8220
- "expires_at" TIMESTAMP,
8221
- "completed_at" TIMESTAMP,
8222
- "tenant_id" text,
8223
- CONSTRAINT "PK_MachineStateInfoEntity_id" PRIMARY KEY ("instance_id")
8224
- )
8225
- `);
8337
+ await queryRunner.query(`ALTER TYPE "StatusList_type_enum" ADD VALUE 'OAuthStatusList'`);
8338
+ await queryRunner.query(`ALTER TABLE "StatusList" ALTER COLUMN "indexingDirection" DROP NOT NULL`);
8339
+ await queryRunner.query(`ALTER TABLE "StatusList" ALTER COLUMN "statusPurpose" DROP NOT NULL`);
8340
+ await queryRunner.query(`ALTER TABLE "StatusList" ADD "bitsPerStatus" integer DEFAULT 1`);
8341
+ await queryRunner.query(`ALTER TABLE "StatusList" ADD "expiresAt" timestamp with time zone`);
8226
8342
  }
8227
8343
  async down(queryRunner) {
8228
- await queryRunner.query(`DROP TABLE "MachineStateInfoEntity"`);
8344
+ await queryRunner.query(`ALTER TABLE "StatusList" DROP COLUMN "expiresAt"`);
8345
+ await queryRunner.query(`ALTER TABLE "StatusList" DROP COLUMN "bitsPerStatus"`);
8346
+ await queryRunner.query(`ALTER TABLE "StatusList" ALTER COLUMN "statusPurpose" SET NOT NULL`);
8347
+ await queryRunner.query(`ALTER TABLE "StatusList" ALTER COLUMN "indexingDirection" SET NOT NULL`);
8229
8348
  }
8230
8349
  };
8231
8350
 
8232
- // src/migrations/sqlite/1708796002272-CreateMachineStateStore.ts
8233
- var CreateMachineStateStore1708796002272 = class {
8351
+ // src/migrations/sqlite/1737110469000-UpdateStatusList.ts
8352
+ var UpdateStatusList1737110469000 = class {
8234
8353
  static {
8235
- __name(this, "CreateMachineStateStore1708796002272");
8354
+ __name(this, "UpdateStatusList1737110469000");
8236
8355
  }
8237
- name = "CreateMachineStateStore1708796002272";
8356
+ name = "UpdateStatusList1737110469000";
8238
8357
  async up(queryRunner) {
8239
- await queryRunner.query(`
8240
- CREATE TABLE "MachineStateInfoEntity" (
8241
- "instance_id" varchar PRIMARY KEY NOT NULL,
8242
- "session_id" varchar,
8243
- "machine_name" varchar NOT NULL,
8244
- "latest_state_name" varchar,
8245
- "latest_event_type" varchar NOT NULL,
8246
- "state" text NOT NULL,
8247
- "created_at" datetime NOT NULL DEFAULT (datetime('now')),
8248
- "updated_at" datetime NOT NULL DEFAULT (datetime('now')),
8249
- "updated_count" integer NOT NULL DEFAULT 0,
8250
- "expires_at" datetime,
8251
- "completed_at" datetime,
8252
- "tenant_id" varchar
8358
+ await queryRunner.query(`CREATE TABLE "temporary_StatusList" (
8359
+ "id" varchar PRIMARY KEY NOT NULL,
8360
+ "correlationId" varchar NOT NULL,
8361
+ "length" integer NOT NULL,
8362
+ "issuer" text NOT NULL,
8363
+ "type" varchar CHECK( "type" IN ('StatusList2021', 'OAuthStatusList') ) NOT NULL DEFAULT ('StatusList2021'),
8364
+ "driverType" varchar CHECK( "driverType" IN ('agent_typeorm','agent_kv_store','github','agent_filesystem') ) NOT NULL DEFAULT ('agent_typeorm'),
8365
+ "credentialIdMode" varchar CHECK( "credentialIdMode" IN ('ISSUANCE','PERSISTENCE','NEVER') ) NOT NULL DEFAULT ('ISSUANCE'),
8366
+ "proofFormat" varchar CHECK( "proofFormat" IN ('lds','jwt') ) NOT NULL DEFAULT ('lds'),
8367
+ "indexingDirection" varchar CHECK( "indexingDirection" IN ('rightToLeft') ),
8368
+ "statusPurpose" varchar,
8369
+ "statusListCredential" text,
8370
+ "bitsPerStatus" integer,
8371
+ "expiresAt" datetime,
8372
+ CONSTRAINT "UQ_correlationId" UNIQUE ("correlationId")
8373
+ )`);
8374
+ await queryRunner.query(`INSERT INTO "temporary_StatusList"(
8375
+ "id", "correlationId", "length", "issuer", "type", "driverType",
8376
+ "credentialIdMode", "proofFormat", "indexingDirection", "statusPurpose",
8377
+ "statusListCredential"
8253
8378
  )
8254
- `);
8379
+ SELECT
8380
+ "id", "correlationId", "length", "issuer", "type", "driverType",
8381
+ "credentialIdMode", "proofFormat", "indexingDirection", "statusPurpose",
8382
+ "statusListCredential"
8383
+ FROM "StatusList"`);
8384
+ await queryRunner.query(`DROP TABLE "StatusList"`);
8385
+ await queryRunner.query(`ALTER TABLE "temporary_StatusList" RENAME TO "StatusList"`);
8255
8386
  }
8256
8387
  async down(queryRunner) {
8257
- await queryRunner.query(`DROP TABLE "MachineStateInfoEntity"`);
8388
+ await queryRunner.query(`
8389
+ ALTER TABLE "StatusListEntry"
8390
+ RENAME COLUMN "entryCorrelationId" TO "correlationId"
8391
+ `);
8392
+ await queryRunner.query(`
8393
+ ALTER TABLE "StatusListEntry"
8394
+ DROP COLUMN "statusListCorrelationId"
8395
+ `);
8396
+ await queryRunner.query(`CREATE TABLE "temporary_StatusList" (
8397
+ "id" varchar PRIMARY KEY NOT NULL,
8398
+ "correlationId" varchar NOT NULL,
8399
+ "length" integer NOT NULL,
8400
+ "issuer" text NOT NULL,
8401
+ "type" varchar CHECK( "type" IN ('StatusList2021') ) NOT NULL DEFAULT ('StatusList2021'),
8402
+ "driverType" varchar CHECK( "driverType" IN ('agent_typeorm','agent_kv_store','github','agent_filesystem') ) NOT NULL DEFAULT ('agent_typeorm'),
8403
+ "credentialIdMode" varchar CHECK( "credentialIdMode" IN ('ISSUANCE','PERSISTENCE','NEVER') ) NOT NULL DEFAULT ('ISSUANCE'),
8404
+ "proofFormat" varchar CHECK( "proofFormat" IN ('lds','jwt') ) NOT NULL DEFAULT ('lds'),
8405
+ "indexingDirection" varchar CHECK( "indexingDirection" IN ('rightToLeft') ) NOT NULL DEFAULT ('rightToLeft'),
8406
+ "statusPurpose" varchar NOT NULL DEFAULT ('revocation'),
8407
+ "statusListCredential" text,
8408
+ CONSTRAINT "UQ_correlationId" UNIQUE ("correlationId")
8409
+ )`);
8410
+ await queryRunner.query(`INSERT INTO "temporary_StatusList"(
8411
+ "id", "correlationId", "length", "issuer", "type", "driverType",
8412
+ "credentialIdMode", "proofFormat", "indexingDirection", "statusPurpose",
8413
+ "statusListCredential"
8414
+ )
8415
+ SELECT
8416
+ "id", "correlationId", "length", "issuer",
8417
+ CASE WHEN "type" = 'OAuthStatusList' THEN 'StatusList2021' ELSE "type" END,
8418
+ "driverType", "credentialIdMode", "proofFormat", "indexingDirection",
8419
+ COALESCE("statusPurpose", 'revocation'), "statusListCredential"
8420
+ FROM "StatusList"`);
8421
+ await queryRunner.query(`DROP TABLE "StatusList"`);
8422
+ await queryRunner.query(`ALTER TABLE "temporary_StatusList" RENAME TO "StatusList"`);
8258
8423
  }
8259
8424
  };
8260
8425
 
8261
- // src/migrations/generic/7-CreateMachineStateStore.ts
8262
- var debug14 = Debug14("sphereon:ssi-sdk:migrations");
8263
- var CreateMachineStateStore1708098041262 = class {
8426
+ // src/migrations/generic/4-CreateStatusList.ts
8427
+ var debug15 = Debug15("sphereon:ssi-sdk:migrations");
8428
+ var CreateStatusList1693866470000 = class {
8264
8429
  static {
8265
- __name(this, "CreateMachineStateStore1708098041262");
8266
- }
8267
- name = "CreateMachineStateStore1708098041262";
8268
- async up(queryRunner) {
8269
- debug14("migration: creating machine state tables");
8270
- const dbType = queryRunner.connection.driver.options.type;
8271
- switch (dbType) {
8272
- case "postgres": {
8273
- debug14("using postgres migration file");
8274
- const mig = new CreateMachineStateStore1708797018115();
8275
- await mig.up(queryRunner);
8276
- debug14("Migration statements executed");
8277
- return;
8278
- }
8279
- case "sqlite":
8280
- case "expo":
8281
- case "react-native": {
8282
- debug14("using sqlite/react-native migration file");
8283
- const mig = new CreateMachineStateStore1708796002272();
8284
- await mig.up(queryRunner);
8285
- debug14("Migration statements executed");
8286
- return;
8287
- }
8288
- default:
8289
- return Promise.reject(`Migrations are currently only supported for sqlite, react-native, expo and postgres. Was ${dbType}. Please run your database without migrations and with 'migrationsRun: false' and 'synchronize: true' for now`);
8430
+ __name(this, "CreateStatusList1693866470000");
8431
+ }
8432
+ name = "CreateStatusList1693866470000";
8433
+ async up(queryRunner) {
8434
+ debug15("migration: creating issuance branding tables");
8435
+ const dbType = queryRunner.connection.driver.options.type;
8436
+ if (dbType === "postgres") {
8437
+ debug15("using postgres migration files");
8438
+ const createMig = new CreateStatusList1693866470001();
8439
+ await createMig.up(queryRunner);
8440
+ const updateMig = new UpdateStatusList1737110469001();
8441
+ const up = await updateMig.up(queryRunner);
8442
+ debug15("Migration statements executed");
8443
+ return up;
8444
+ } else if (dbType === "sqlite" || dbType === "react-native" || dbType === "expo") {
8445
+ debug15("using sqlite/react-native migration files");
8446
+ const createMig = new CreateStatusList1693866470002();
8447
+ await createMig.up(queryRunner);
8448
+ const updateMig = new UpdateStatusList1737110469000();
8449
+ const up = await updateMig.up(queryRunner);
8450
+ debug15("Migration statements executed");
8451
+ return up;
8452
+ } else {
8453
+ return Promise.reject(`Migrations are currently only supported for sqlite, react-native, expo and postgres. Was ${dbType}. Please run your database without migrations and with 'migrationsRun: false' and 'synchronize: true' for now`);
8290
8454
  }
8291
8455
  }
8292
8456
  async down(queryRunner) {
8293
- debug14("migration: reverting machine state tables");
8457
+ debug15("migration: reverting issuance branding tables");
8294
8458
  const dbType = queryRunner.connection.driver.options.type;
8295
- switch (dbType) {
8296
- case "postgres": {
8297
- debug14("using postgres migration file");
8298
- const mig = new CreateMachineStateStore1708797018115();
8299
- await mig.down(queryRunner);
8300
- debug14("Migration statements executed");
8301
- return;
8302
- }
8303
- case "sqlite":
8304
- case "expo":
8305
- case "react-native": {
8306
- debug14("using sqlite/react-native migration file");
8307
- const mig = new CreateMachineStateStore1708796002272();
8308
- await mig.down(queryRunner);
8309
- debug14("Migration statements executed");
8310
- return;
8311
- }
8312
- default:
8313
- return Promise.reject(`Migrations are currently only supported for sqlite, react-native, expo and postgres. Was ${dbType}. Please run your database without migrations and with 'migrationsRun: false' and 'synchronize: true' for now`);
8459
+ if (dbType === "postgres") {
8460
+ debug15("using postgres migration files");
8461
+ const updateMig = new UpdateStatusList1737110469001();
8462
+ await updateMig.down(queryRunner);
8463
+ const createMig = new CreateStatusList1693866470001();
8464
+ const down = await createMig.down(queryRunner);
8465
+ debug15("Migration statements executed");
8466
+ return down;
8467
+ } else if (dbType === "sqlite" || dbType === "react-native" || dbType === "expo") {
8468
+ debug15("using sqlite/react-native migration files");
8469
+ const updateMig = new UpdateStatusList1737110469000();
8470
+ await updateMig.down(queryRunner);
8471
+ const createMig = new CreateStatusList1693866470002();
8472
+ const down = await createMig.down(queryRunner);
8473
+ debug15("Migration statements executed");
8474
+ return down;
8475
+ } else {
8476
+ return Promise.reject(`Migrations are currently only supported for sqlite, react-native, expo and postgres. Was ${dbType}. Please run your database without migrations and with 'migrationsRun: false' and 'synchronize: true' for now`);
8314
8477
  }
8315
8478
  }
8316
8479
  };
8317
8480
 
8318
- // src/migrations/generic/8-CreateContacts.ts
8319
- import Debug15 from "debug";
8481
+ // src/migrations/generic/5-CreateAuditEvents.ts
8482
+ import Debug16 from "debug";
8320
8483
 
8321
- // src/migrations/postgres/1710438363001-CreateContacts.ts
8322
- var CreateContacts1710438363001 = class {
8484
+ // src/migrations/sqlite/1701634819487-CreateAuditEvents.ts
8485
+ var CreateAuditEvents1701634819487 = class {
8323
8486
  static {
8324
- __name(this, "CreateContacts1710438363001");
8487
+ __name(this, "CreateAuditEvents1701634819487");
8325
8488
  }
8326
- name = "CreateContacts1710438363001";
8489
+ name = "CreateAuditEvents1701634819487";
8327
8490
  async up(queryRunner) {
8328
- await queryRunner.query(`ALTER TABLE "Party" ADD COLUMN "owner_id" uuid`);
8329
- await queryRunner.query(`ALTER TABLE "Party" ADD COLUMN "tenant_id" uuid`);
8330
- await queryRunner.query(`ALTER TABLE "Identity" ADD COLUMN "owner_id" uuid`);
8331
- await queryRunner.query(`ALTER TABLE "Identity" ADD COLUMN "tenant_id" uuid`);
8332
- await queryRunner.query(`ALTER TABLE "CorrelationIdentifier" ADD COLUMN "owner_id" uuid`);
8333
- await queryRunner.query(`ALTER TABLE "CorrelationIdentifier" ADD COLUMN "tenant_id" uuid`);
8334
- await queryRunner.query(`ALTER TABLE "Connection" ADD COLUMN "owner_id" uuid`);
8335
- await queryRunner.query(`ALTER TABLE "Connection" ADD COLUMN "tenant_id" uuid`);
8336
- await queryRunner.query(`ALTER TABLE "BaseConfig" ADD COLUMN "owner_id" uuid`);
8337
- await queryRunner.query(`ALTER TABLE "BaseConfig" ADD COLUMN "tenant_id" uuid`);
8338
- await queryRunner.query(`ALTER TABLE "BaseContact" ADD COLUMN "owner_id" uuid`);
8339
- await queryRunner.query(`ALTER TABLE "BaseContact" ADD COLUMN "tenant_id" uuid`);
8340
- await queryRunner.query(`ALTER TABLE "PartyRelationship" ADD COLUMN "owner_id" uuid`);
8341
- await queryRunner.query(`ALTER TABLE "PartyRelationship" ADD COLUMN "tenant_id" uuid`);
8342
- await queryRunner.query(`ALTER TABLE "ElectronicAddress" ADD COLUMN "owner_id" uuid`);
8343
- await queryRunner.query(`ALTER TABLE "ElectronicAddress" ADD COLUMN "tenant_id" uuid`);
8344
- await queryRunner.query(`ALTER TABLE "PhysicalAddress" ADD COLUMN "owner_id" uuid`);
8345
- await queryRunner.query(`ALTER TABLE "PhysicalAddress" ADD COLUMN "tenant_id" uuid`);
8491
+ await queryRunner.query(`CREATE TABLE "AuditEvents" (
8492
+ "id" varchar PRIMARY KEY NOT NULL,
8493
+ "eventType" varchar CHECK( "eventType" IN ('audit','activity','general') ) NOT NULL,
8494
+ "timestamp" datetime NOT NULL,
8495
+ "level" varchar CHECK( "level" IN ('0','1','2','3','4') ) NOT NULL,
8496
+ "correlationId" varchar NOT NULL,
8497
+ "system" varchar CHECK( "system" IN ('general','kms','identity','oid4vci','oid4vp','siopv2','PE','credentials','web3','profile','contact') ) NOT NULL,
8498
+ "subSystemType" varchar CHECK( "subSystemType" IN ('key','did_provider','did_resolver','oid4vp_op','oid4vci_client','siopv2_op','contact_manager','vc_issuer','vc_verifier','vc_persistence','transport','profile','api') ) NOT NULL,
8499
+ "actionType" varchar CHECK( "actionType" IN ('create','read','update','delete','execute') ) NOT NULL,
8500
+ "actionSubType" varchar NOT NULL,
8501
+ "initiatorType" varchar CHECK( "initiatorType" IN ('user','system','external') ) NOT NULL,
8502
+ "systemCorrelationIdType" varchar CHECK( "systemCorrelationIdType" IN ('did','url','email','hostname','phone','user') ),
8503
+ "systemCorrelationId" varchar,
8504
+ "systemAlias" varchar,
8505
+ "partyCorrelationType" varchar CHECK( "partyCorrelationType" IN ('did','url','email','hostname','phone') ),
8506
+ "partyCorrelationId" varchar,
8507
+ "partyAlias" varchar,
8508
+ "credentialType" varchar CHECK( "credentialType" IN ('JSON_LD','JWT','SD_JWT','MSO_MDOC') ),
8509
+ "credentialHash" varchar,
8510
+ "parentCredentialHash" varchar,
8511
+ "originalCredential" varchar,
8512
+ "sharePurpose" varchar,
8513
+ "description" varchar NOT NULL,
8514
+ "data" varchar,
8515
+ "diagnosticData" varchar,
8516
+ "created_at" datetime NOT NULL DEFAULT (datetime('now')),
8517
+ "last_updated_at" datetime NOT NULL DEFAULT (datetime('now')))`);
8346
8518
  }
8347
8519
  async down(queryRunner) {
8348
- await queryRunner.query(`ALTER TABLE "PhysicalAddress" DROP COLUMN "tenant_id"`);
8349
- await queryRunner.query(`ALTER TABLE "PhysicalAddress" DROP COLUMN "owner_id"`);
8350
- await queryRunner.query(`ALTER TABLE "ElectronicAddress" DROP COLUMN "tenant_id"`);
8351
- await queryRunner.query(`ALTER TABLE "ElectronicAddress" DROP COLUMN "owner_id"`);
8352
- await queryRunner.query(`ALTER TABLE "PartyRelationship" DROP COLUMN "tenant_id"`);
8353
- await queryRunner.query(`ALTER TABLE "PartyRelationship" DROP COLUMN "owner_id"`);
8354
- await queryRunner.query(`ALTER TABLE "BaseContact" DROP COLUMN "tenant_id"`);
8355
- await queryRunner.query(`ALTER TABLE "BaseContact" DROP COLUMN "owner_id"`);
8356
- await queryRunner.query(`ALTER TABLE "BaseConfig" DROP COLUMN "tenant_id"`);
8357
- await queryRunner.query(`ALTER TABLE "BaseConfig" DROP COLUMN "owner_id"`);
8358
- await queryRunner.query(`ALTER TABLE "Connection" DROP COLUMN "tenant_id"`);
8359
- await queryRunner.query(`ALTER TABLE "Connection" DROP COLUMN "owner_id"`);
8360
- await queryRunner.query(`ALTER TABLE "CorrelationIdentifier" DROP COLUMN "tenant_id"`);
8361
- await queryRunner.query(`ALTER TABLE "CorrelationIdentifier" DROP COLUMN "owner_id"`);
8362
- await queryRunner.query(`ALTER TABLE "Identity" DROP COLUMN "tenant_id"`);
8363
- await queryRunner.query(`ALTER TABLE "Identity" DROP COLUMN "owner_id"`);
8364
- await queryRunner.query(`ALTER TABLE "Party" DROP COLUMN "tenant_id"`);
8365
- await queryRunner.query(`ALTER TABLE "Party" DROP COLUMN "owner_id"`);
8520
+ await queryRunner.query(`DROP TABLE "AuditEvents"`);
8366
8521
  }
8367
8522
  };
8368
8523
 
8369
- // src/migrations/sqlite/1710438363002-CreateContacts.ts
8370
- var CreateContacts1710438363002 = class {
8524
+ // src/migrations/postgres/1701634812183-CreateAuditEvents.ts
8525
+ var CreateAuditEvents1701634812183 = class {
8371
8526
  static {
8372
- __name(this, "CreateContacts1710438363002");
8527
+ __name(this, "CreateAuditEvents1701634812183");
8373
8528
  }
8374
- name = "CreateContacts1710438363002";
8529
+ name = "CreateAuditEvents1701634812183";
8375
8530
  async up(queryRunner) {
8376
- await queryRunner.query(`ALTER TABLE "Party" ADD COLUMN "owner_id" text`);
8377
- await queryRunner.query(`ALTER TABLE "Party" ADD COLUMN "tenant_id" text`);
8378
- await queryRunner.query(`CREATE TABLE "temporary_Identity" (
8379
- "id" varchar PRIMARY KEY NOT NULL,
8380
- "alias" varchar(255) NOT NULL,
8381
- "roles" text NOT NULL,
8382
- "origin" text NOT NULL,
8383
- "created_at" datetime NOT NULL DEFAULT (datetime('now')),
8384
- "last_updated_at" datetime NOT NULL DEFAULT (datetime('now')),
8385
- "partyId" varchar,
8386
- "owner_id" text,
8387
- "tenant_id" text,
8388
- CONSTRAINT "UQ_Identity_alias" UNIQUE ("alias"),
8389
- CONSTRAINT "FK_Identity_partyId" FOREIGN KEY ("partyId") REFERENCES "Party" ("id") ON DELETE CASCADE ON UPDATE NO ACTION
8390
- )`);
8391
- await queryRunner.query(`INSERT INTO "temporary_Identity"("id", "alias", "roles", "created_at", "last_updated_at", "partyId", "owner_id", "tenant_id", "origin")
8392
- SELECT "id", "alias", "roles", 'EXTERNAL' as "origin", "created_at", "last_updated_at", "partyId", NULL as "owner_id", NULL as "tenant_id" FROM "Identity"`);
8393
- await queryRunner.query(`DROP TABLE "Identity"`);
8394
- await queryRunner.query(`ALTER TABLE "temporary_Identity" RENAME TO "Identity"`);
8395
- await queryRunner.query(`ALTER TABLE "CorrelationIdentifier" ADD COLUMN "owner_id" text`);
8396
- await queryRunner.query(`ALTER TABLE "CorrelationIdentifier" ADD COLUMN "tenant_id" text`);
8397
- await queryRunner.query(`ALTER TABLE "Connection" ADD COLUMN "owner_id" text`);
8398
- await queryRunner.query(`ALTER TABLE "Connection" ADD COLUMN "tenant_id" text`);
8399
- await queryRunner.query(`ALTER TABLE "BaseConfig" ADD COLUMN "owner_id" text`);
8400
- await queryRunner.query(`ALTER TABLE "BaseConfig" ADD COLUMN "tenant_id" text`);
8401
- await queryRunner.query(`ALTER TABLE "BaseContact" ADD COLUMN "owner_id" text`);
8402
- await queryRunner.query(`ALTER TABLE "BaseContact" ADD COLUMN "tenant_id" text`);
8403
- await queryRunner.query(`ALTER TABLE "PartyRelationship" ADD COLUMN "owner_id" text`);
8404
- await queryRunner.query(`ALTER TABLE "PartyRelationship" ADD COLUMN "tenant_id" text`);
8405
- await queryRunner.query(`ALTER TABLE "ElectronicAddress" ADD COLUMN "owner_id" text`);
8406
- await queryRunner.query(`ALTER TABLE "ElectronicAddress" ADD COLUMN "tenant_id" text`);
8407
- await queryRunner.query(`ALTER TABLE "PhysicalAddress" ADD COLUMN "owner_id" text`);
8408
- await queryRunner.query(`ALTER TABLE "PhysicalAddress" ADD COLUMN "tenant_id" text`);
8531
+ await queryRunner.query(`CREATE TYPE "public"."Level_enum" AS ENUM('0', '1', '2', '3', '4')`);
8532
+ await queryRunner.query(`CREATE TYPE "public"."System_enum" AS ENUM('general', 'kms', 'identity', 'oid4vci', 'oid4vp', 'siopv2', 'PE', 'credentials', 'web3', 'profile', 'contact')`);
8533
+ await queryRunner.query(`CREATE TYPE "public"."Subsystem_type_enum" AS ENUM('key', 'did_provider', 'did_resolver', 'oid4vp_op', 'oid4vci_client', 'siopv2_op', 'contact_manager', 'vc_issuer', 'vc_verifier', 'vc_persistence', 'transport', 'profile', 'api')`);
8534
+ await queryRunner.query(`CREATE TYPE "public"."Action_type_enum" AS ENUM('create', 'read', 'update', 'delete', 'execute')`);
8535
+ await queryRunner.query(`CREATE TYPE "public"."Initiator_type_enum" AS ENUM('user', 'system', 'external')`);
8536
+ await queryRunner.query(`CREATE TYPE "public"."System_correlation_id_type_enum" AS ENUM('did', 'url', 'email', 'hostname', 'phone', 'user')`);
8537
+ await queryRunner.query(`CREATE TYPE "public"."Party_correlation_type_enum" AS ENUM('did', 'url', 'email', 'hostname', 'phone')`);
8538
+ await queryRunner.query(`CREATE TYPE "public"."Event_type_enum" AS ENUM('audit', 'activity', 'general')`);
8539
+ await queryRunner.query(`CREATE TYPE "public"."Event_credential_type_enum" AS ENUM('JSON_LD', 'JWT', 'SD_JWT', 'MSO_MDOC')`);
8540
+ await queryRunner.query(`CREATE TABLE "AuditEvents" (
8541
+ "id" uuid NOT NULL DEFAULT uuid_generate_v4(),
8542
+ "eventType" "public"."Event_type_enum" NOT NULL,
8543
+ "timestamp" TIMESTAMP NOT NULL,
8544
+ "level" "public"."Level_enum" NOT NULL,
8545
+ "correlationId" TEXT NOT NULL,
8546
+ "system" "public"."System_enum" NOT NULL,
8547
+ "subSystemType" "public"."Subsystem_type_enum" NOT NULL,
8548
+ "actionType" "public"."Action_type_enum" NOT NULL,
8549
+ "actionSubType" TEXT NOT NULL,
8550
+ "initiatorType" "public"."Initiator_type_enum" NOT NULL,
8551
+ "systemCorrelationIdType" "public"."System_correlation_id_type_enum",
8552
+ "systemCorrelationId" TEXT,
8553
+ "systemAlias" TEXT,
8554
+ "partyCorrelationType" "public"."Party_correlation_type_enum",
8555
+ "partyCorrelationId" TEXT,
8556
+ "partyAlias" TEXT,
8557
+ "credentialType" "public"."Event_credential_type_enum",
8558
+ "credentialHash" TEXT,
8559
+ "originalCredential" TEXT,
8560
+ "sharePurpose" TEXT,
8561
+ "description" TEXT NOT NULL,
8562
+ "data" TEXT,
8563
+ "diagnosticData" TEXT,
8564
+ "created_at" TIMESTAMP NOT NULL DEFAULT now(),
8565
+ "last_updated_at" TIMESTAMP NOT NULL DEFAULT now(),
8566
+ CONSTRAINT "PK_AuditEvents_id" PRIMARY KEY ("id"))`);
8409
8567
  }
8410
8568
  async down(queryRunner) {
8411
- await queryRunner.query(`ALTER TABLE "PhysicalAddress" DROP COLUMN "tenant_id"`);
8412
- await queryRunner.query(`ALTER TABLE "PhysicalAddress" DROP COLUMN "owner_id"`);
8413
- await queryRunner.query(`ALTER TABLE "ElectronicAddress" DROP COLUMN "tenant_id"`);
8414
- await queryRunner.query(`ALTER TABLE "ElectronicAddress" DROP COLUMN "owner_id"`);
8415
- await queryRunner.query(`ALTER TABLE "PartyRelationship" DROP COLUMN "tenant_id"`);
8416
- await queryRunner.query(`ALTER TABLE "PartyRelationship" DROP COLUMN "owner_id"`);
8417
- await queryRunner.query(`ALTER TABLE "BaseContact" DROP COLUMN "tenant_id"`);
8418
- await queryRunner.query(`ALTER TABLE "BaseContact" DROP COLUMN "owner_id"`);
8419
- await queryRunner.query(`ALTER TABLE "BaseConfig" DROP COLUMN "tenant_id"`);
8420
- await queryRunner.query(`ALTER TABLE "BaseConfig" DROP COLUMN "owner_id"`);
8421
- await queryRunner.query(`ALTER TABLE "Connection" DROP COLUMN "tenant_id"`);
8422
- await queryRunner.query(`ALTER TABLE "Connection" DROP COLUMN "owner_id"`);
8423
- await queryRunner.query(`ALTER TABLE "CorrelationIdentifier" DROP COLUMN "tenant_id"`);
8424
- await queryRunner.query(`ALTER TABLE "CorrelationIdentifier" DROP COLUMN "owner_id"`);
8425
- await queryRunner.query(`ALTER TABLE "Identity" DROP COLUMN "tenant_id"`);
8426
- await queryRunner.query(`ALTER TABLE "Identity" DROP COLUMN "owner_id"`);
8427
- await queryRunner.query(`ALTER TABLE "Party" DROP COLUMN "tenant_id"`);
8428
- await queryRunner.query(`ALTER TABLE "Party" DROP COLUMN "owner_id"`);
8569
+ await queryRunner.query(`DROP TABLE "AuditEvents"`);
8570
+ await queryRunner.query(`DROP TYPE "public"."Party_correlation_type_enum"`);
8571
+ await queryRunner.query(`DROP TYPE "public"."System_correlation_id_type_enum"`);
8572
+ await queryRunner.query(`DROP TYPE "public"."Initiator_type_enum"`);
8573
+ await queryRunner.query(`DROP TYPE "public"."Action_type_enum"`);
8574
+ await queryRunner.query(`DROP TYPE "public"."Subsystem_type_enum"`);
8575
+ await queryRunner.query(`DROP TYPE "public"."System_enum"`);
8576
+ await queryRunner.query(`DROP TYPE "public"."Level_enum"`);
8429
8577
  }
8430
8578
  };
8431
8579
 
8432
- // src/migrations/generic/8-CreateContacts.ts
8433
- var debug15 = Debug15("sphereon:ssi-sdk:migrations");
8434
- var CreateContacts1708525189000 = class {
8580
+ // src/migrations/generic/5-CreateAuditEvents.ts
8581
+ var debug16 = Debug16("sphereon:ssi-sdk:migrations");
8582
+ var CreateAuditEvents1701635835330 = class {
8435
8583
  static {
8436
- __name(this, "CreateContacts1708525189000");
8584
+ __name(this, "CreateAuditEvents1701635835330");
8437
8585
  }
8438
- name = "CreateContacts1708525189000";
8586
+ name = "CreateAuditEvents1701635835330";
8439
8587
  async up(queryRunner) {
8440
- debug15("migration: updating contact tables");
8588
+ debug16("migration: creating audit events tables");
8441
8589
  const dbType = queryRunner.connection.driver.options.type;
8442
8590
  switch (dbType) {
8443
8591
  case "postgres": {
8444
- debug15("using postgres migration file");
8445
- const mig = new CreateContacts1710438363001();
8592
+ debug16("using postgres migration file");
8593
+ const mig = new CreateAuditEvents1701634812183();
8446
8594
  await mig.up(queryRunner);
8447
- debug15("Migration statements executed");
8595
+ debug16("Migration statements executed");
8448
8596
  return;
8449
8597
  }
8450
8598
  case "sqlite":
8451
8599
  case "expo":
8452
8600
  case "react-native": {
8453
- debug15("using sqlite/react-native migration file");
8454
- const mig = new CreateContacts1710438363002();
8601
+ debug16("using sqlite/react-native migration file");
8602
+ const mig = new CreateAuditEvents1701634819487();
8455
8603
  await mig.up(queryRunner);
8456
- debug15("Migration statements executed");
8604
+ debug16("Migration statements executed");
8457
8605
  return;
8458
8606
  }
8459
8607
  default:
@@ -8461,23 +8609,23 @@ var CreateContacts1708525189000 = class {
8461
8609
  }
8462
8610
  }
8463
8611
  async down(queryRunner) {
8464
- debug15("migration: reverting machine state tables");
8612
+ debug16("migration: reverting audit events tables");
8465
8613
  const dbType = queryRunner.connection.driver.options.type;
8466
8614
  switch (dbType) {
8467
8615
  case "postgres": {
8468
- debug15("using postgres migration file");
8469
- const mig = new CreateContacts1710438363001();
8616
+ debug16("using postgres migration file");
8617
+ const mig = new CreateAuditEvents1701634812183();
8470
8618
  await mig.down(queryRunner);
8471
- debug15("Migration statements executed");
8619
+ debug16("Migration statements executed");
8472
8620
  return;
8473
8621
  }
8474
8622
  case "sqlite":
8475
8623
  case "expo":
8476
8624
  case "react-native": {
8477
- debug15("using sqlite/react-native migration file");
8478
- const mig = new CreateContacts1710438363002();
8625
+ debug16("using sqlite/react-native migration file");
8626
+ const mig = new CreateAuditEvents1701634819487();
8479
8627
  await mig.down(queryRunner);
8480
- debug15("Migration statements executed");
8628
+ debug16("Migration statements executed");
8481
8629
  return;
8482
8630
  }
8483
8631
  default:
@@ -8486,254 +8634,258 @@ var CreateContacts1708525189000 = class {
8486
8634
  }
8487
8635
  };
8488
8636
 
8489
- // src/migrations/generic/9-CreateContacts.ts
8490
- import Debug16 from "debug";
8637
+ // src/migrations/generic/6-CreateDigitalCredential.ts
8638
+ import Debug17 from "debug";
8491
8639
 
8492
- // src/migrations/postgres/1715761125001-CreateContacts.ts
8493
- var CreateContacts1715761125001 = class {
8640
+ // src/migrations/postgres/1708525189001-CreateDigitalCredential.ts
8641
+ var CreateDigitalCredential1708525189001 = class {
8494
8642
  static {
8495
- __name(this, "CreateContacts1715761125001");
8643
+ __name(this, "CreateDigitalCredential1708525189001");
8496
8644
  }
8497
- name = "CreateContacts1715761125001";
8645
+ name = "CreateDigitalCredential1708525189001";
8498
8646
  async up(queryRunner) {
8499
- await queryRunner.query(`ALTER TABLE "IdentityMetadata" RENAME TO "temporary_IdentityMetadata"`);
8500
- await queryRunner.query(`CREATE TABLE "IdentityMetadata"
8501
- (
8502
- "id" uuid PRIMARY KEY NOT NULL DEFAULT uuid_generate_v4(),
8503
- "label" character varying(255) NOT NULL,
8504
- "valueType" character varying NOT NULL,
8505
- "stringValue" text,
8506
- "numberValue" double precision,
8507
- "dateValue" TIMESTAMP,
8508
- "boolValue" boolean,
8509
- "identityId" uuid,
8510
- CONSTRAINT "FK_Identity_IdentityMetadata" FOREIGN KEY ("identityId") REFERENCES "Identity" ("id") ON DELETE CASCADE
8511
- )`);
8512
- await queryRunner.query(`INSERT INTO "IdentityMetadata" ("id", "label", "valueType", "stringValue", "identityId")
8513
- SELECT "id", "label", 'string', "value", "identityId"
8514
- FROM "temporary_IdentityMetadata"`);
8515
- await queryRunner.query(`DROP TABLE "temporary_IdentityMetadata"`);
8516
- await queryRunner.query(`CREATE TABLE "ContactMetadata"
8517
- (
8518
- "id" uuid PRIMARY KEY NOT NULL DEFAULT uuid_generate_v4(),
8519
- "label" character varying(255) NOT NULL,
8520
- "valueType" character varying NOT NULL,
8521
- "stringValue" text,
8522
- "numberValue" double precision,
8523
- "dateValue" TIMESTAMP,
8524
- "boolValue" boolean,
8525
- "contactId" uuid,
8526
- CONSTRAINT "FK_BaseContact_ContactMetadata" FOREIGN KEY ("contactId") REFERENCES "BaseContact" ("id") ON DELETE CASCADE
8527
- )`);
8647
+ await queryRunner.query(`CREATE TYPE "digital_document_type" AS ENUM('VC', 'VP', 'C', 'P')`);
8648
+ await queryRunner.query(`CREATE TYPE "digital_regulation_type" AS ENUM('PID', 'QEAA', 'EAA', 'NON_REGULATED')`);
8649
+ await queryRunner.query(`CREATE TYPE "digital_credential_document_format" AS ENUM('JSON_LD', 'JWT', 'SD_JWT', 'MSO_MDOC')`);
8650
+ await queryRunner.query(`CREATE TYPE "digital_credential_credential_role" AS ENUM('ISSUER', 'VERIFIER', 'HOLDER', 'FEDERATION_TRUST_ANCHOR')`);
8651
+ await queryRunner.query(`CREATE TYPE "digital_credential_correlation_type" AS ENUM('DID', 'KID', 'URL', 'X509_SAN')`);
8652
+ await queryRunner.query(`CREATE TYPE "digital_credential_state_type" AS ENUM('REVOKED', 'VERIFIED', 'EXPIRED')`);
8653
+ await queryRunner.query(`
8654
+ CREATE TABLE "DigitalCredential" (
8655
+ "id" uuid NOT NULL DEFAULT uuid_generate_v4(),
8656
+ "parent_id" text,
8657
+ "document_type" "digital_document_type" NOT NULL,
8658
+ "regulation_type" "digital_regulation_type" NOT NULL DEFAULT 'NON_REGULATED'::"digital_regulation_type",
8659
+ "document_format" "digital_credential_document_format" NOT NULL,
8660
+ "credential_role" "digital_credential_credential_role" NOT NULL,
8661
+ "raw_document" text NOT NULL,
8662
+ "uniform_document" text NOT NULL,
8663
+ "credential_id" text,
8664
+ "hash" text NOT NULL,
8665
+ "kms_key_ref" text,
8666
+ "identifier_method" text,
8667
+ "issuer_correlation_type" "digital_credential_correlation_type" NOT NULL,
8668
+ "subject_correlation_type" "digital_credential_correlation_type",
8669
+ "issuer_correlation_id" text NOT NULL,
8670
+ "subject_correlation_id" text,
8671
+ "verified_state" "digital_credential_state_type",
8672
+ "issuer_signed" boolean,
8673
+ "rp_correlation_id" text,
8674
+ "rp_correlation_type" "digital_credential_correlation_type",
8675
+ "tenant_id" text,
8676
+ "created_at" TIMESTAMP NOT NULL DEFAULT now(),
8677
+ "last_updated_at" TIMESTAMP NOT NULL DEFAULT now(),
8678
+ "presented_at" DATE,
8679
+ "valid_from" DATE,
8680
+ "valid_until" DATE,
8681
+ "verified_at" DATE,
8682
+ "revoked_at" DATE,
8683
+ PRIMARY KEY ("id"),
8684
+ UNIQUE ("hash", "credential_role")
8685
+ )
8686
+ `);
8528
8687
  }
8529
8688
  async down(queryRunner) {
8530
- await queryRunner.query(`DROP TABLE "ContactMetadata"`);
8531
- await queryRunner.query(`ALTER TABLE "IdentityMetadata" RENAME TO "temporary_IdentityMetadata"`);
8532
- await queryRunner.query(`CREATE TABLE "IdentityMetadata"
8533
- (
8534
- "id" uuid PRIMARY KEY NOT NULL DEFAULT uuid_generate_v4(),
8535
- "label" character varying(255) NOT NULL,
8536
- "value" character varying(255) NOT NULL,
8537
- "identityId" uuid,
8538
- CONSTRAINT "FK_Identity_IdentityMetadata" FOREIGN KEY ("identityId") REFERENCES "Identity" ("id") ON DELETE CASCADE
8539
- )`);
8540
- await queryRunner.query(`INSERT INTO "IdentityMetadata" ("id", "label", "value", "identityId")
8541
- SELECT "id", "label", "stringValue", "identityId"
8542
- FROM "temporary_IdentityMetadata"`);
8543
- await queryRunner.query(`DROP TABLE "temporary_IdentityMetadata"`);
8689
+ await queryRunner.query(`DROP TABLE "DigitalCredential"`);
8690
+ await queryRunner.query(`DROP TYPE "digital_credential_state_type"`);
8691
+ await queryRunner.query(`DROP TYPE "digital_credential_correlation_type"`);
8692
+ await queryRunner.query(`DROP TYPE "digital_credential_document_format"`);
8693
+ await queryRunner.query(`DROP TYPE "digital_credential_credential_role"`);
8694
+ await queryRunner.query(`DROP TYPE "digital_regulation_type"`);
8695
+ await queryRunner.query(`DROP TYPE "digital_document_type"`);
8544
8696
  }
8545
8697
  };
8546
8698
 
8547
- // src/migrations/sqlite/1715761125002-CreateContacts.ts
8548
- var CreateContacts1715761125002 = class {
8699
+ // src/migrations/sqlite/1708525189002-CreateDigitalCredential.ts
8700
+ var CreateDigitalCredential1708525189002 = class {
8549
8701
  static {
8550
- __name(this, "CreateContacts1715761125002");
8702
+ __name(this, "CreateDigitalCredential1708525189002");
8551
8703
  }
8552
- name = "CreateContacts1715761125002";
8704
+ name = "CreateDigitalCredential1708525189002";
8553
8705
  async up(queryRunner) {
8554
- await queryRunner.query(`ALTER TABLE "IdentityMetadata" RENAME TO "temporary_IdentityMetadata"`);
8555
- await queryRunner.query(`CREATE TABLE "IdentityMetadata"
8556
- (
8557
- "id" varchar PRIMARY KEY NOT NULL,
8558
- "label" varchar(255) NOT NULL,
8559
- "valueType" varchar NOT NULL,
8560
- "stringValue" varchar(255),
8561
- "numberValue" double,
8562
- "dateValue" datetime,
8563
- "boolValue" boolean,
8564
- "identityId" varchar,
8565
- FOREIGN KEY ("identityId") REFERENCES "Identity" ("id") ON DELETE CASCADE)`);
8566
- await queryRunner.query(`INSERT INTO "IdentityMetadata" ("id", "label", "valueType", "stringValue", "identityId")
8567
- SELECT "id", "label", 'string', "value", "identityId"
8568
- FROM "temporary_IdentityMetadata"
8706
+ await queryRunner.query(`
8707
+ CREATE TABLE "DigitalCredential" (
8708
+ "id" varchar PRIMARY KEY NOT NULL,
8709
+ "parent_id" text,
8710
+ "document_type" varchar CHECK( "document_type" IN ('VC', 'VP', 'C', 'P') ) NOT NULL,
8711
+ "regulation_type" varchar CHECK( "regulation_type" IN ('PID', 'QEAA', 'EAA', 'NON_REGULATED') ) NOT NULL DEFAULT 'NON_REGULATED',
8712
+ "document_format" varchar CHECK( "document_format" IN ('JSON_LD', 'JWT', 'SD_JWT', 'MSO_MDOC') ) NOT NULL,
8713
+ "credential_role" varchar CHECK( "credential_role" IN ('ISSUER', 'VERIFIER', 'HOLDER', 'FEDERATION_TRUST_ANCHOR') ) NOT NULL,
8714
+ "raw_document" text NOT NULL,
8715
+ "uniform_document" text NOT NULL,
8716
+ "credential_id" text,
8717
+ "hash" text NOT NULL,
8718
+ "kms_key_ref" text,
8719
+ "identifier_method" text,
8720
+ "issuer_correlation_type" varchar CHECK( "issuer_correlation_type" IN ('DID', 'KID', 'URL', 'X509_SAN') ) NOT NULL,
8721
+ "subject_correlation_type" varchar CHECK( "subject_correlation_type" IN ('DID', 'KID', 'URL', 'X509_SAN') ),
8722
+ "issuer_correlation_id" text NOT NULL,
8723
+ "subject_correlation_id" text,
8724
+ "issuer_signed" boolean,
8725
+ "rp_correlation_id" text,
8726
+ "rp_correlation_type" varchar CHECK( "issuer_correlation_type" IN ('DID', 'KID', 'URL', 'X509_SAN') ),
8727
+ "verified_state" varchar CHECK( "verified_state" IN ('REVOKED', 'VERIFIED', 'EXPIRED') ),
8728
+ "tenant_id" text,
8729
+ "created_at" datetime NOT NULL DEFAULT (datetime('now')),
8730
+ "last_updated_at" datetime NOT NULL DEFAULT (datetime('now')),
8731
+ "presented_at" datetime,
8732
+ "valid_from" datetime,
8733
+ "valid_until" datetime,
8734
+ "verified_at" datetime,
8735
+ "revoked_at" datetime,
8736
+ UNIQUE ("hash", "credential_role")
8737
+ )
8569
8738
  `);
8570
- await queryRunner.query(`DROP TABLE "temporary_IdentityMetadata"`);
8571
- await queryRunner.query(`CREATE TABLE "ContactMetadata"
8572
- (
8573
- "id" varchar PRIMARY KEY NOT NULL,
8574
- "label" varchar(255) NOT NULL,
8575
- "valueType" varchar NOT NULL,
8576
- "stringValue" text,
8577
- "numberValue" double,
8578
- "dateValue" datetime,
8579
- "boolValue" boolean,
8580
- "contactId" varchar,
8581
- FOREIGN KEY ("contactId") REFERENCES "BaseContact" ("id") ON DELETE CASCADE)`);
8582
8739
  }
8583
8740
  async down(queryRunner) {
8584
- await queryRunner.query(`DROP TABLE "ContactMetadata"`);
8585
- await queryRunner.query(`ALTER TABLE "IdentityMetadata" RENAME TO "temporary_IdentityMetadata"`);
8586
- await queryRunner.query(`CREATE TABLE "IdentityMetadata"
8587
- (
8588
- "id" varchar PRIMARY KEY NOT NULL,
8589
- "label" varchar(255) NOT NULL,
8590
- "value" varchar(255) NOT NULL,
8591
- "identityId" varchar,
8592
- FOREIGN KEY ("identityId") REFERENCES "Identity" ("id") ON DELETE CASCADE
8593
- )`);
8594
- await queryRunner.query(`INSERT INTO "IdentityMetadata" ("id", "label", "value", "identityId")
8595
- SELECT "id", "label", "stringValue", "identityId"
8596
- FROM "temporary_IdentityMetadata"`);
8597
- await queryRunner.query(`DROP TABLE "temporary_IdentityMetadata"`);
8741
+ await queryRunner.query(`DROP TABLE "DigitalCredential"`);
8598
8742
  }
8599
8743
  };
8600
8744
 
8601
- // src/migrations/generic/9-CreateContacts.ts
8602
- var debug16 = Debug16("sphereon:ssi-sdk:migrations");
8603
- var CreateContacts1715761125000 = class {
8745
+ // src/migrations/generic/6-CreateDigitalCredential.ts
8746
+ var debug17 = Debug17("sphereon:ssi-sdk:migrations");
8747
+ var CreateDigitalCredential1708525189000 = class {
8604
8748
  static {
8605
- __name(this, "CreateContacts1715761125000");
8749
+ __name(this, "CreateDigitalCredential1708525189000");
8606
8750
  }
8607
- name = "CreateContacts1715761125000";
8751
+ name = "CreateDigitalCredential1708525189000";
8608
8752
  async up(queryRunner) {
8609
- debug16("migration: updating contact tables");
8753
+ debug17("migration: creating DigitalCredential tables");
8610
8754
  const dbType = queryRunner.connection.driver.options.type;
8611
8755
  switch (dbType) {
8612
8756
  case "postgres": {
8613
- debug16("using postgres migration file");
8614
- const mig = new CreateContacts1715761125001();
8757
+ debug17("using postgres migration file for DigitalCredential");
8758
+ const mig = new CreateDigitalCredential1708525189001();
8615
8759
  await mig.up(queryRunner);
8616
- debug16("Migration statements executed");
8760
+ debug17("Postgres Migration statements for DigitalCredential executed");
8617
8761
  return;
8618
8762
  }
8619
8763
  case "sqlite":
8620
8764
  case "expo":
8621
8765
  case "react-native": {
8622
- debug16("using sqlite/react-native migration file");
8623
- const mig = new CreateContacts1715761125002();
8766
+ debug17("using sqlite/react-native migration file for DigitalCredential");
8767
+ const mig = new CreateDigitalCredential1708525189002();
8624
8768
  await mig.up(queryRunner);
8625
- debug16("Migration statements executed");
8769
+ debug17("SQLite Migration statements for DigitalCredential executed");
8626
8770
  return;
8627
8771
  }
8628
8772
  default:
8629
- return Promise.reject(`Migrations are currently only supported for sqlite, react-native, expo and postgres. Was ${dbType}. Please run your database without migrations and with 'migrationsRun: false' and 'synchronize: true' for now`);
8773
+ return Promise.reject(`Migrations are currently only supported for sqlite, react-native, expo, and postgres for UniformCredential. Was ${dbType}. Please run your database without migrations and with 'migrationsRun: false' and 'synchronize: true' for now`);
8630
8774
  }
8631
8775
  }
8632
8776
  async down(queryRunner) {
8633
- debug16("migration: reverting machine state tables");
8777
+ debug17("migration: reverting DigitalCredential tables");
8634
8778
  const dbType = queryRunner.connection.driver.options.type;
8635
8779
  switch (dbType) {
8636
8780
  case "postgres": {
8637
- debug16("using postgres migration file");
8638
- const mig = new CreateContacts1715761125001();
8781
+ debug17("using postgres migration file for DigitalCredential");
8782
+ const mig = new CreateDigitalCredential1708525189001();
8639
8783
  await mig.down(queryRunner);
8640
- debug16("Migration statements executed");
8784
+ debug17("Postgres Migration statements for DigitalCredential reverted");
8641
8785
  return;
8642
8786
  }
8643
8787
  case "sqlite":
8644
8788
  case "expo":
8645
8789
  case "react-native": {
8646
- debug16("using sqlite/react-native migration file");
8647
- const mig = new CreateContacts1715761125002();
8790
+ debug17("using sqlite/react-native migration file for DigitalCredential");
8791
+ const mig = new CreateDigitalCredential1708525189002();
8648
8792
  await mig.down(queryRunner);
8649
- debug16("Migration statements executed");
8793
+ debug17("SQLite Migration statements for DigitalCredential reverted");
8650
8794
  return;
8651
8795
  }
8652
8796
  default:
8653
- return Promise.reject(`Migrations are currently only supported for sqlite, react-native, expo and postgres. Was ${dbType}. Please run your database without migrations and with 'migrationsRun: false' and 'synchronize: true' for now`);
8797
+ return Promise.reject(`Migrations are currently only supported for sqlite, react-native, expo, and postgres for DigitalCredential. Was ${dbType}. Please run your database without migrations and with 'migrationsRun: false' and 'synchronize: true' for now`);
8654
8798
  }
8655
8799
  }
8656
8800
  };
8657
8801
 
8658
- // src/migrations/generic/10-CreatePresentationDefinitions.ts
8659
- import Debug17 from "debug";
8802
+ // src/migrations/generic/7-CreateMachineStateStore.ts
8803
+ import Debug18 from "debug";
8660
8804
 
8661
- // src/migrations/postgres/1716475165345-CreatePresentationDefinitions.ts
8662
- var CreatePresentationDefinitions1716475165345 = class {
8805
+ // src/migrations/postgres/1708797018115-CreateMachineStateStore.ts
8806
+ var CreateMachineStateStore1708797018115 = class {
8663
8807
  static {
8664
- __name(this, "CreatePresentationDefinitions1716475165345");
8808
+ __name(this, "CreateMachineStateStore1708797018115");
8665
8809
  }
8666
- name = "CreatePresentationDefinitions1716475165345";
8810
+ name = "CreateMachineStateStore1708797018115";
8667
8811
  async up(queryRunner) {
8668
8812
  await queryRunner.query(`
8669
- CREATE TABLE "PresentationDefinitionItem" (
8670
- "id" uuid NOT NULL DEFAULT uuid_generate_v4(),
8671
- "tenant_id" TEXT,
8672
- "definition_id" TEXT NOT NULL,
8673
- "name" TEXT,
8674
- "version" TEXT NOT NULL,
8675
- "purpose" TEXT,
8676
- "definition_payload" TEXT NOT NULL,
8677
- "dcql_payload" TEXT,
8678
- "created_at" TIMESTAMP NOT NULL DEFAULT now(),
8679
- "last_updated_at" TIMESTAMP NOT NULL DEFAULT now(),
8680
- CONSTRAINT "PK_PresentationDefinitionItem_id" PRIMARY KEY ("id"))
8681
- `);
8813
+ CREATE TABLE "MachineStateInfoEntity" (
8814
+ "instance_id" text NOT NULL,
8815
+ "session_id" text,
8816
+ "latest_state_name" text,
8817
+ "machine_name" text NOT NULL,
8818
+ "latest_event_type" text NOT NULL,
8819
+ "state" text NOT NULL,
8820
+ "created_at" TIMESTAMP NOT NULL DEFAULT now(),
8821
+ "updated_at" TIMESTAMP NOT NULL DEFAULT now(),
8822
+ "updated_count" integer NOT NULL DEFAULT 0,
8823
+ "expires_at" TIMESTAMP,
8824
+ "completed_at" TIMESTAMP,
8825
+ "tenant_id" text,
8826
+ CONSTRAINT "PK_MachineStateInfoEntity_id" PRIMARY KEY ("instance_id")
8827
+ )
8828
+ `);
8682
8829
  }
8683
8830
  async down(queryRunner) {
8684
- await queryRunner.query(`DROP TABLE "PresentationDefinitionItem"`);
8831
+ await queryRunner.query(`DROP TABLE "MachineStateInfoEntity"`);
8685
8832
  }
8686
8833
  };
8687
8834
 
8688
- // src/migrations/sqlite/1716475165344-CreatePresentationDefinitions.ts
8689
- var CreatePresentationDefinitions1716475165344 = class {
8835
+ // src/migrations/sqlite/1708796002272-CreateMachineStateStore.ts
8836
+ var CreateMachineStateStore1708796002272 = class {
8690
8837
  static {
8691
- __name(this, "CreatePresentationDefinitions1716475165344");
8838
+ __name(this, "CreateMachineStateStore1708796002272");
8692
8839
  }
8693
- name = "CreatePresentationDefinitions1716475165344";
8840
+ name = "CreateMachineStateStore1708796002272";
8694
8841
  async up(queryRunner) {
8695
- await queryRunner.query(`CREATE TABLE "PresentationDefinitionItem" (
8696
- "id" varchar PRIMARY KEY NOT NULL,
8697
- "tenant_id" varchar,
8698
- "definition_id" varchar NOT NULL,
8699
- "name" varchar,
8700
- "version" varchar NOT NULL,
8701
- "purpose" varchar,
8702
- "definition_payload" varchar NOT NULL,
8703
- "dcql_payload" varchar,
8704
- "created_at" datetime NOT NULL DEFAULT (datetime('now')),
8705
- "last_updated_at" datetime NOT NULL DEFAULT (datetime('now')))`);
8842
+ await queryRunner.query(`
8843
+ CREATE TABLE "MachineStateInfoEntity" (
8844
+ "instance_id" varchar PRIMARY KEY NOT NULL,
8845
+ "session_id" varchar,
8846
+ "machine_name" varchar NOT NULL,
8847
+ "latest_state_name" varchar,
8848
+ "latest_event_type" varchar NOT NULL,
8849
+ "state" text NOT NULL,
8850
+ "created_at" datetime NOT NULL DEFAULT (datetime('now')),
8851
+ "updated_at" datetime NOT NULL DEFAULT (datetime('now')),
8852
+ "updated_count" integer NOT NULL DEFAULT 0,
8853
+ "expires_at" datetime,
8854
+ "completed_at" datetime,
8855
+ "tenant_id" varchar
8856
+ )
8857
+ `);
8706
8858
  }
8707
8859
  async down(queryRunner) {
8708
- await queryRunner.query(`DROP TABLE "PresentationDefinitionItem"`);
8860
+ await queryRunner.query(`DROP TABLE "MachineStateInfoEntity"`);
8709
8861
  }
8710
8862
  };
8711
8863
 
8712
- // src/migrations/generic/10-CreatePresentationDefinitions.ts
8713
- var debug17 = Debug17("sphereon:ssi-sdk:migrations");
8714
- var CreatePresentationDefinitions1716533767523 = class {
8864
+ // src/migrations/generic/7-CreateMachineStateStore.ts
8865
+ var debug18 = Debug18("sphereon:ssi-sdk:migrations");
8866
+ var CreateMachineStateStore1708098041262 = class {
8715
8867
  static {
8716
- __name(this, "CreatePresentationDefinitions1716533767523");
8868
+ __name(this, "CreateMachineStateStore1708098041262");
8717
8869
  }
8718
- name = "CreatePresentationDefinitionItems1716533767523";
8870
+ name = "CreateMachineStateStore1708098041262";
8719
8871
  async up(queryRunner) {
8720
- debug17("migration: creating machine state tables");
8872
+ debug18("migration: creating machine state tables");
8721
8873
  const dbType = queryRunner.connection.driver.options.type;
8722
8874
  switch (dbType) {
8723
8875
  case "postgres": {
8724
- debug17("using postgres migration file");
8725
- const mig = new CreatePresentationDefinitions1716475165345();
8876
+ debug18("using postgres migration file");
8877
+ const mig = new CreateMachineStateStore1708797018115();
8726
8878
  await mig.up(queryRunner);
8727
- debug17("Migration statements executed");
8879
+ debug18("Migration statements executed");
8728
8880
  return;
8729
8881
  }
8730
8882
  case "sqlite":
8731
8883
  case "expo":
8732
8884
  case "react-native": {
8733
- debug17("using sqlite/react-native migration file");
8734
- const mig = new CreatePresentationDefinitions1716475165344();
8885
+ debug18("using sqlite/react-native migration file");
8886
+ const mig = new CreateMachineStateStore1708796002272();
8735
8887
  await mig.up(queryRunner);
8736
- debug17("Migration statements executed");
8888
+ debug18("Migration statements executed");
8737
8889
  return;
8738
8890
  }
8739
8891
  default:
@@ -8741,23 +8893,23 @@ var CreatePresentationDefinitions1716533767523 = class {
8741
8893
  }
8742
8894
  }
8743
8895
  async down(queryRunner) {
8744
- debug17("migration: reverting machine state tables");
8896
+ debug18("migration: reverting machine state tables");
8745
8897
  const dbType = queryRunner.connection.driver.options.type;
8746
8898
  switch (dbType) {
8747
8899
  case "postgres": {
8748
- debug17("using postgres migration file");
8749
- const mig = new CreatePresentationDefinitions1716475165345();
8900
+ debug18("using postgres migration file");
8901
+ const mig = new CreateMachineStateStore1708797018115();
8750
8902
  await mig.down(queryRunner);
8751
- debug17("Migration statements executed");
8903
+ debug18("Migration statements executed");
8752
8904
  return;
8753
8905
  }
8754
8906
  case "sqlite":
8755
8907
  case "expo":
8756
8908
  case "react-native": {
8757
- debug17("using sqlite/react-native migration file");
8758
- const mig = new CreatePresentationDefinitions1716475165344();
8909
+ debug18("using sqlite/react-native migration file");
8910
+ const mig = new CreateMachineStateStore1708796002272();
8759
8911
  await mig.down(queryRunner);
8760
- debug17("Migration statements executed");
8912
+ debug18("Migration statements executed");
8761
8913
  return;
8762
8914
  }
8763
8915
  default:
@@ -8766,108 +8918,145 @@ var CreatePresentationDefinitions1716533767523 = class {
8766
8918
  }
8767
8919
  };
8768
8920
 
8769
- // src/migrations/generic/11-FixCredentialClaimsReferenceUuid.ts
8770
- import Debug18 from "debug";
8921
+ // src/migrations/generic/8-CreateContacts.ts
8922
+ import Debug19 from "debug";
8771
8923
 
8772
- // src/migrations/postgres/1741895822987-FixCredentialClaimsReferencesUuid.ts
8773
- var FixCredentialClaimsReferencesUuidPG1741895822987 = class {
8924
+ // src/migrations/postgres/1710438363001-CreateContacts.ts
8925
+ var CreateContacts1710438363001 = class {
8774
8926
  static {
8775
- __name(this, "FixCredentialClaimsReferencesUuidPG1741895822987");
8927
+ __name(this, "CreateContacts1710438363001");
8776
8928
  }
8777
- name = "FixCredentialClaimsReferencesUuid1741895822987";
8929
+ name = "CreateContacts1710438363001";
8778
8930
  async up(queryRunner) {
8779
- await queryRunner.query(`
8780
- ALTER TABLE "CredentialClaims"
8781
- ALTER COLUMN "credentialLocaleBrandingId" TYPE uuid USING "credentialLocaleBrandingId"::uuid;
8782
- `);
8931
+ await queryRunner.query(`ALTER TABLE "Party" ADD COLUMN "owner_id" uuid`);
8932
+ await queryRunner.query(`ALTER TABLE "Party" ADD COLUMN "tenant_id" uuid`);
8933
+ await queryRunner.query(`ALTER TABLE "Identity" ADD COLUMN "owner_id" uuid`);
8934
+ await queryRunner.query(`ALTER TABLE "Identity" ADD COLUMN "tenant_id" uuid`);
8935
+ await queryRunner.query(`ALTER TABLE "CorrelationIdentifier" ADD COLUMN "owner_id" uuid`);
8936
+ await queryRunner.query(`ALTER TABLE "CorrelationIdentifier" ADD COLUMN "tenant_id" uuid`);
8937
+ await queryRunner.query(`ALTER TABLE "Connection" ADD COLUMN "owner_id" uuid`);
8938
+ await queryRunner.query(`ALTER TABLE "Connection" ADD COLUMN "tenant_id" uuid`);
8939
+ await queryRunner.query(`ALTER TABLE "BaseConfig" ADD COLUMN "owner_id" uuid`);
8940
+ await queryRunner.query(`ALTER TABLE "BaseConfig" ADD COLUMN "tenant_id" uuid`);
8941
+ await queryRunner.query(`ALTER TABLE "BaseContact" ADD COLUMN "owner_id" uuid`);
8942
+ await queryRunner.query(`ALTER TABLE "BaseContact" ADD COLUMN "tenant_id" uuid`);
8943
+ await queryRunner.query(`ALTER TABLE "PartyRelationship" ADD COLUMN "owner_id" uuid`);
8944
+ await queryRunner.query(`ALTER TABLE "PartyRelationship" ADD COLUMN "tenant_id" uuid`);
8945
+ await queryRunner.query(`ALTER TABLE "ElectronicAddress" ADD COLUMN "owner_id" uuid`);
8946
+ await queryRunner.query(`ALTER TABLE "ElectronicAddress" ADD COLUMN "tenant_id" uuid`);
8947
+ await queryRunner.query(`ALTER TABLE "PhysicalAddress" ADD COLUMN "owner_id" uuid`);
8948
+ await queryRunner.query(`ALTER TABLE "PhysicalAddress" ADD COLUMN "tenant_id" uuid`);
8783
8949
  }
8784
8950
  async down(queryRunner) {
8785
- await queryRunner.query(`
8786
- ALTER TABLE "CredentialClaims"
8787
- ALTER COLUMN "credentialLocaleBrandingId" TYPE character varying USING "credentialLocaleBrandingId"::text;
8788
- `);
8951
+ await queryRunner.query(`ALTER TABLE "PhysicalAddress" DROP COLUMN "tenant_id"`);
8952
+ await queryRunner.query(`ALTER TABLE "PhysicalAddress" DROP COLUMN "owner_id"`);
8953
+ await queryRunner.query(`ALTER TABLE "ElectronicAddress" DROP COLUMN "tenant_id"`);
8954
+ await queryRunner.query(`ALTER TABLE "ElectronicAddress" DROP COLUMN "owner_id"`);
8955
+ await queryRunner.query(`ALTER TABLE "PartyRelationship" DROP COLUMN "tenant_id"`);
8956
+ await queryRunner.query(`ALTER TABLE "PartyRelationship" DROP COLUMN "owner_id"`);
8957
+ await queryRunner.query(`ALTER TABLE "BaseContact" DROP COLUMN "tenant_id"`);
8958
+ await queryRunner.query(`ALTER TABLE "BaseContact" DROP COLUMN "owner_id"`);
8959
+ await queryRunner.query(`ALTER TABLE "BaseConfig" DROP COLUMN "tenant_id"`);
8960
+ await queryRunner.query(`ALTER TABLE "BaseConfig" DROP COLUMN "owner_id"`);
8961
+ await queryRunner.query(`ALTER TABLE "Connection" DROP COLUMN "tenant_id"`);
8962
+ await queryRunner.query(`ALTER TABLE "Connection" DROP COLUMN "owner_id"`);
8963
+ await queryRunner.query(`ALTER TABLE "CorrelationIdentifier" DROP COLUMN "tenant_id"`);
8964
+ await queryRunner.query(`ALTER TABLE "CorrelationIdentifier" DROP COLUMN "owner_id"`);
8965
+ await queryRunner.query(`ALTER TABLE "Identity" DROP COLUMN "tenant_id"`);
8966
+ await queryRunner.query(`ALTER TABLE "Identity" DROP COLUMN "owner_id"`);
8967
+ await queryRunner.query(`ALTER TABLE "Party" DROP COLUMN "tenant_id"`);
8968
+ await queryRunner.query(`ALTER TABLE "Party" DROP COLUMN "owner_id"`);
8789
8969
  }
8790
8970
  };
8791
8971
 
8792
- // src/migrations/sqlite/1741895822987-FixCredentialClaimsReferencesUuid.ts
8793
- var FixCredentialClaimsReferencesUuidSqlite1741895822987 = class {
8972
+ // src/migrations/sqlite/1710438363002-CreateContacts.ts
8973
+ var CreateContacts1710438363002 = class {
8794
8974
  static {
8795
- __name(this, "FixCredentialClaimsReferencesUuidSqlite1741895822987");
8975
+ __name(this, "CreateContacts1710438363002");
8796
8976
  }
8797
- name = "FixCredentialClaimsReferencesUuid1741895822987";
8977
+ name = "CreateContacts1710438363002";
8798
8978
  async up(queryRunner) {
8799
- await queryRunner.query(`
8800
- CREATE TABLE "CredentialClaims_new"
8801
- (
8802
- "id" uuid NOT NULL DEFAULT (lower(hex(randomblob(16)))),
8803
- "key" character varying(255) NOT NULL,
8804
- "name" character varying(255) NOT NULL,
8805
- "credentialLocaleBrandingId" uuid,
8806
- CONSTRAINT "PK_CredentialClaims_id" PRIMARY KEY ("id")
8807
- )
8808
- `);
8809
- await queryRunner.query(`
8810
- INSERT INTO "CredentialClaims_new" ("id", "key", "name", "credentialLocaleBrandingId")
8811
- SELECT "id", "key", "name", "credentialLocaleBrandingId"
8812
- FROM "CredentialClaims"
8813
- `);
8814
- await queryRunner.query(`DROP TABLE "CredentialClaims"`);
8815
- await queryRunner.query(`ALTER TABLE "CredentialClaims_new" RENAME TO "CredentialClaims"`);
8816
- await queryRunner.query(`
8817
- CREATE UNIQUE INDEX "IDX_CredentialClaimsEntity_credentialLocaleBranding_locale"
8818
- ON "CredentialClaims" ("credentialLocaleBrandingId", "key")
8819
- `);
8979
+ await queryRunner.query(`ALTER TABLE "Party" ADD COLUMN "owner_id" text`);
8980
+ await queryRunner.query(`ALTER TABLE "Party" ADD COLUMN "tenant_id" text`);
8981
+ await queryRunner.query(`CREATE TABLE "temporary_Identity" (
8982
+ "id" varchar PRIMARY KEY NOT NULL,
8983
+ "alias" varchar(255) NOT NULL,
8984
+ "roles" text NOT NULL,
8985
+ "origin" text NOT NULL,
8986
+ "created_at" datetime NOT NULL DEFAULT (datetime('now')),
8987
+ "last_updated_at" datetime NOT NULL DEFAULT (datetime('now')),
8988
+ "partyId" varchar,
8989
+ "owner_id" text,
8990
+ "tenant_id" text,
8991
+ CONSTRAINT "UQ_Identity_alias" UNIQUE ("alias"),
8992
+ CONSTRAINT "FK_Identity_partyId" FOREIGN KEY ("partyId") REFERENCES "Party" ("id") ON DELETE CASCADE ON UPDATE NO ACTION
8993
+ )`);
8994
+ await queryRunner.query(`INSERT INTO "temporary_Identity"("id", "alias", "roles", "created_at", "last_updated_at", "partyId", "owner_id", "tenant_id", "origin")
8995
+ SELECT "id", "alias", "roles", 'EXTERNAL' as "origin", "created_at", "last_updated_at", "partyId", NULL as "owner_id", NULL as "tenant_id" FROM "Identity"`);
8996
+ await queryRunner.query(`DROP TABLE "Identity"`);
8997
+ await queryRunner.query(`ALTER TABLE "temporary_Identity" RENAME TO "Identity"`);
8998
+ await queryRunner.query(`ALTER TABLE "CorrelationIdentifier" ADD COLUMN "owner_id" text`);
8999
+ await queryRunner.query(`ALTER TABLE "CorrelationIdentifier" ADD COLUMN "tenant_id" text`);
9000
+ await queryRunner.query(`ALTER TABLE "Connection" ADD COLUMN "owner_id" text`);
9001
+ await queryRunner.query(`ALTER TABLE "Connection" ADD COLUMN "tenant_id" text`);
9002
+ await queryRunner.query(`ALTER TABLE "BaseConfig" ADD COLUMN "owner_id" text`);
9003
+ await queryRunner.query(`ALTER TABLE "BaseConfig" ADD COLUMN "tenant_id" text`);
9004
+ await queryRunner.query(`ALTER TABLE "BaseContact" ADD COLUMN "owner_id" text`);
9005
+ await queryRunner.query(`ALTER TABLE "BaseContact" ADD COLUMN "tenant_id" text`);
9006
+ await queryRunner.query(`ALTER TABLE "PartyRelationship" ADD COLUMN "owner_id" text`);
9007
+ await queryRunner.query(`ALTER TABLE "PartyRelationship" ADD COLUMN "tenant_id" text`);
9008
+ await queryRunner.query(`ALTER TABLE "ElectronicAddress" ADD COLUMN "owner_id" text`);
9009
+ await queryRunner.query(`ALTER TABLE "ElectronicAddress" ADD COLUMN "tenant_id" text`);
9010
+ await queryRunner.query(`ALTER TABLE "PhysicalAddress" ADD COLUMN "owner_id" text`);
9011
+ await queryRunner.query(`ALTER TABLE "PhysicalAddress" ADD COLUMN "tenant_id" text`);
8820
9012
  }
8821
9013
  async down(queryRunner) {
8822
- await queryRunner.query(`
8823
- CREATE TABLE "CredentialClaims_old"
8824
- (
8825
- "id" uuid NOT NULL DEFAULT (lower(hex(randomblob(16)))),
8826
- "key" character varying(255) NOT NULL,
8827
- "name" character varying(255) NOT NULL,
8828
- "credentialLocaleBrandingId" character varying,
8829
- CONSTRAINT "PK_CredentialClaims_id" PRIMARY KEY ("id")
8830
- )
8831
- `);
8832
- await queryRunner.query(`
8833
- INSERT INTO "CredentialClaims_old" ("id", "key", "name", "credentialLocaleBrandingId")
8834
- SELECT "id", "key", "name", "credentialLocaleBrandingId"
8835
- FROM "CredentialClaims"
8836
- `);
8837
- await queryRunner.query(`DROP TABLE "CredentialClaims"`);
8838
- await queryRunner.query(`ALTER TABLE "CredentialClaims_old" RENAME TO "CredentialClaims"`);
8839
- await queryRunner.query(`
8840
- CREATE UNIQUE INDEX "IDX_CredentialClaimsEntity_credentialLocaleBranding_locale"
8841
- ON "CredentialClaims" ("credentialLocaleBrandingId", "key")
8842
- `);
9014
+ await queryRunner.query(`ALTER TABLE "PhysicalAddress" DROP COLUMN "tenant_id"`);
9015
+ await queryRunner.query(`ALTER TABLE "PhysicalAddress" DROP COLUMN "owner_id"`);
9016
+ await queryRunner.query(`ALTER TABLE "ElectronicAddress" DROP COLUMN "tenant_id"`);
9017
+ await queryRunner.query(`ALTER TABLE "ElectronicAddress" DROP COLUMN "owner_id"`);
9018
+ await queryRunner.query(`ALTER TABLE "PartyRelationship" DROP COLUMN "tenant_id"`);
9019
+ await queryRunner.query(`ALTER TABLE "PartyRelationship" DROP COLUMN "owner_id"`);
9020
+ await queryRunner.query(`ALTER TABLE "BaseContact" DROP COLUMN "tenant_id"`);
9021
+ await queryRunner.query(`ALTER TABLE "BaseContact" DROP COLUMN "owner_id"`);
9022
+ await queryRunner.query(`ALTER TABLE "BaseConfig" DROP COLUMN "tenant_id"`);
9023
+ await queryRunner.query(`ALTER TABLE "BaseConfig" DROP COLUMN "owner_id"`);
9024
+ await queryRunner.query(`ALTER TABLE "Connection" DROP COLUMN "tenant_id"`);
9025
+ await queryRunner.query(`ALTER TABLE "Connection" DROP COLUMN "owner_id"`);
9026
+ await queryRunner.query(`ALTER TABLE "CorrelationIdentifier" DROP COLUMN "tenant_id"`);
9027
+ await queryRunner.query(`ALTER TABLE "CorrelationIdentifier" DROP COLUMN "owner_id"`);
9028
+ await queryRunner.query(`ALTER TABLE "Identity" DROP COLUMN "tenant_id"`);
9029
+ await queryRunner.query(`ALTER TABLE "Identity" DROP COLUMN "owner_id"`);
9030
+ await queryRunner.query(`ALTER TABLE "Party" DROP COLUMN "tenant_id"`);
9031
+ await queryRunner.query(`ALTER TABLE "Party" DROP COLUMN "owner_id"`);
8843
9032
  }
8844
9033
  };
8845
9034
 
8846
- // src/migrations/generic/11-FixCredentialClaimsReferenceUuid.ts
8847
- var debug18 = Debug18("sphereon:ssi-sdk:migrations");
8848
- var FixCredentialClaimsReferencesUuid1741895822987 = class {
9035
+ // src/migrations/generic/8-CreateContacts.ts
9036
+ var debug19 = Debug19("sphereon:ssi-sdk:migrations");
9037
+ var CreateContacts1708525189000 = class {
8849
9038
  static {
8850
- __name(this, "FixCredentialClaimsReferencesUuid1741895822987");
9039
+ __name(this, "CreateContacts1708525189000");
8851
9040
  }
8852
- name = "FixCredentialClaimsReferenceUuid1741895822987";
9041
+ name = "CreateContacts1708525189000";
8853
9042
  async up(queryRunner) {
8854
- debug18("migration: creating issuance branding uuid problem");
9043
+ debug19("migration: updating contact tables");
8855
9044
  const dbType = queryRunner.connection.driver.options.type;
8856
9045
  switch (dbType) {
8857
9046
  case "postgres": {
8858
- debug18("using postgres migration file");
8859
- const mig = new FixCredentialClaimsReferencesUuidPG1741895822987();
9047
+ debug19("using postgres migration file");
9048
+ const mig = new CreateContacts1710438363001();
8860
9049
  await mig.up(queryRunner);
8861
- debug18("Migration statements executed");
9050
+ debug19("Migration statements executed");
8862
9051
  return;
8863
9052
  }
8864
9053
  case "sqlite":
8865
9054
  case "expo":
8866
9055
  case "react-native": {
8867
- debug18("using sqlite/react-native migration file");
8868
- const mig = new FixCredentialClaimsReferencesUuidSqlite1741895822987();
9056
+ debug19("using sqlite/react-native migration file");
9057
+ const mig = new CreateContacts1710438363002();
8869
9058
  await mig.up(queryRunner);
8870
- debug18("Migration statements executed");
9059
+ debug19("Migration statements executed");
8871
9060
  return;
8872
9061
  }
8873
9062
  default:
@@ -8875,23 +9064,23 @@ var FixCredentialClaimsReferencesUuid1741895822987 = class {
8875
9064
  }
8876
9065
  }
8877
9066
  async down(queryRunner) {
8878
- debug18("migration: reverting issuance branding uuid migration");
9067
+ debug19("migration: reverting machine state tables");
8879
9068
  const dbType = queryRunner.connection.driver.options.type;
8880
9069
  switch (dbType) {
8881
9070
  case "postgres": {
8882
- debug18("using postgres migration file");
8883
- const mig = new CreateIssuanceBranding1685628974232();
9071
+ debug19("using postgres migration file");
9072
+ const mig = new CreateContacts1710438363001();
8884
9073
  await mig.down(queryRunner);
8885
- debug18("Migration statements executed");
9074
+ debug19("Migration statements executed");
8886
9075
  return;
8887
9076
  }
8888
9077
  case "sqlite":
8889
9078
  case "expo":
8890
9079
  case "react-native": {
8891
- debug18("using sqlite/react-native migration file");
8892
- const mig = new CreateIssuanceBranding1685628973231();
9080
+ debug19("using sqlite/react-native migration file");
9081
+ const mig = new CreateContacts1710438363002();
8893
9082
  await mig.down(queryRunner);
8894
- debug18("Migration statements executed");
9083
+ debug19("Migration statements executed");
8895
9084
  return;
8896
9085
  }
8897
9086
  default:
@@ -8900,222 +9089,171 @@ var FixCredentialClaimsReferencesUuid1741895822987 = class {
8900
9089
  }
8901
9090
  };
8902
9091
 
8903
- // src/migrations/generic/12-CreateBitstringStatusList.ts
8904
- import Debug19 from "debug";
9092
+ // src/migrations/generic/9-CreateContacts.ts
9093
+ import Debug20 from "debug";
8905
9094
 
8906
- // src/migrations/postgres/1741895823000-CreateBitstringStatusList.ts
8907
- var CreateBitstringStatusListPG1741895823000 = class {
9095
+ // src/migrations/postgres/1715761125001-CreateContacts.ts
9096
+ var CreateContacts1715761125001 = class {
8908
9097
  static {
8909
- __name(this, "CreateBitstringStatusListPG1741895823000");
9098
+ __name(this, "CreateContacts1715761125001");
8910
9099
  }
8911
- name = "CreateBitstringStatusList1741895823000";
9100
+ name = "CreateContacts1715761125001";
8912
9101
  async up(queryRunner) {
8913
- await queryRunner.query(`ALTER TABLE "StatusList" ADD COLUMN "bitsPerStatus" integer DEFAULT 1`);
8914
- await queryRunner.query(`ALTER TABLE "StatusList" ADD COLUMN "ttl" integer`);
8915
- await queryRunner.query(`ALTER TABLE "StatusList" ADD COLUMN "validFrom" TIMESTAMP`);
8916
- await queryRunner.query(`ALTER TABLE "StatusList" ADD COLUMN "validUntil" TIMESTAMP`);
8917
- await queryRunner.query(`ALTER TABLE "StatusList" DROP CONSTRAINT IF EXISTS "CHK_StatusList_type"`);
8918
- await queryRunner.query(`ALTER TABLE "StatusList" ADD CONSTRAINT "CHK_StatusList_type" CHECK ("type" IN ('StatusList2021', 'OAuthStatusList', 'BitstringStatusList'))`);
8919
- await queryRunner.query(`ALTER TABLE "StatusListEntry" ADD COLUMN "type" character varying NOT NULL DEFAULT 'StatusListEntryEntity'`);
8920
- await queryRunner.query(`ALTER TABLE "StatusListEntry" ADD COLUMN "statusPurpose" character varying`);
8921
- await queryRunner.query(`ALTER TABLE "StatusListEntry" ADD COLUMN "bitsPerStatus" integer DEFAULT 1`);
8922
- await queryRunner.query(`ALTER TABLE "StatusListEntry" ADD COLUMN "statusMessage" text`);
8923
- await queryRunner.query(`ALTER TABLE "StatusListEntry" ADD COLUMN "statusReference" text`);
8924
- await queryRunner.query(`ALTER TABLE "StatusListEntry" ADD CONSTRAINT "CHK_StatusListEntry_type" CHECK ("type" IN ('StatusListEntryEntity', 'bitstring'))`);
9102
+ await queryRunner.query(`ALTER TABLE "IdentityMetadata" RENAME TO "temporary_IdentityMetadata"`);
9103
+ await queryRunner.query(`CREATE TABLE "IdentityMetadata"
9104
+ (
9105
+ "id" uuid PRIMARY KEY NOT NULL DEFAULT uuid_generate_v4(),
9106
+ "label" character varying(255) NOT NULL,
9107
+ "valueType" character varying NOT NULL,
9108
+ "stringValue" text,
9109
+ "numberValue" double precision,
9110
+ "dateValue" TIMESTAMP,
9111
+ "boolValue" boolean,
9112
+ "identityId" uuid,
9113
+ CONSTRAINT "FK_Identity_IdentityMetadata" FOREIGN KEY ("identityId") REFERENCES "Identity" ("id") ON DELETE CASCADE
9114
+ )`);
9115
+ await queryRunner.query(`INSERT INTO "IdentityMetadata" ("id", "label", "valueType", "stringValue", "identityId")
9116
+ SELECT "id", "label", 'string', "value", "identityId"
9117
+ FROM "temporary_IdentityMetadata"`);
9118
+ await queryRunner.query(`DROP TABLE "temporary_IdentityMetadata"`);
9119
+ await queryRunner.query(`CREATE TABLE "ContactMetadata"
9120
+ (
9121
+ "id" uuid PRIMARY KEY NOT NULL DEFAULT uuid_generate_v4(),
9122
+ "label" character varying(255) NOT NULL,
9123
+ "valueType" character varying NOT NULL,
9124
+ "stringValue" text,
9125
+ "numberValue" double precision,
9126
+ "dateValue" TIMESTAMP,
9127
+ "boolValue" boolean,
9128
+ "contactId" uuid,
9129
+ CONSTRAINT "FK_BaseContact_ContactMetadata" FOREIGN KEY ("contactId") REFERENCES "BaseContact" ("id") ON DELETE CASCADE
9130
+ )`);
8925
9131
  }
8926
9132
  async down(queryRunner) {
8927
- await queryRunner.query(`ALTER TABLE "StatusListEntry" DROP CONSTRAINT "CHK_StatusListEntry_type"`);
8928
- await queryRunner.query(`ALTER TABLE "StatusListEntry" DROP COLUMN "statusReference"`);
8929
- await queryRunner.query(`ALTER TABLE "StatusListEntry" DROP COLUMN "statusMessage"`);
8930
- await queryRunner.query(`ALTER TABLE "StatusListEntry" DROP COLUMN "bitsPerStatus"`);
8931
- await queryRunner.query(`ALTER TABLE "StatusListEntry" DROP COLUMN "statusPurpose"`);
8932
- await queryRunner.query(`ALTER TABLE "StatusListEntry" DROP COLUMN "type"`);
8933
- await queryRunner.query(`ALTER TABLE "StatusList" DROP CONSTRAINT "CHK_StatusList_type"`);
8934
- await queryRunner.query(`ALTER TABLE "StatusList" ADD CONSTRAINT "CHK_StatusList_type" CHECK ("type" IN ('StatusList2021', 'OAuthStatusList'))`);
8935
- await queryRunner.query(`ALTER TABLE "StatusList" DROP COLUMN "validUntil"`);
8936
- await queryRunner.query(`ALTER TABLE "StatusList" DROP COLUMN "validFrom"`);
8937
- await queryRunner.query(`ALTER TABLE "StatusList" DROP COLUMN "ttl"`);
8938
- await queryRunner.query(`ALTER TABLE "StatusList" DROP COLUMN "bitsPerStatus"`);
9133
+ await queryRunner.query(`DROP TABLE "ContactMetadata"`);
9134
+ await queryRunner.query(`ALTER TABLE "IdentityMetadata" RENAME TO "temporary_IdentityMetadata"`);
9135
+ await queryRunner.query(`CREATE TABLE "IdentityMetadata"
9136
+ (
9137
+ "id" uuid PRIMARY KEY NOT NULL DEFAULT uuid_generate_v4(),
9138
+ "label" character varying(255) NOT NULL,
9139
+ "value" character varying(255) NOT NULL,
9140
+ "identityId" uuid,
9141
+ CONSTRAINT "FK_Identity_IdentityMetadata" FOREIGN KEY ("identityId") REFERENCES "Identity" ("id") ON DELETE CASCADE
9142
+ )`);
9143
+ await queryRunner.query(`INSERT INTO "IdentityMetadata" ("id", "label", "value", "identityId")
9144
+ SELECT "id", "label", "stringValue", "identityId"
9145
+ FROM "temporary_IdentityMetadata"`);
9146
+ await queryRunner.query(`DROP TABLE "temporary_IdentityMetadata"`);
8939
9147
  }
8940
9148
  };
8941
9149
 
8942
- // src/migrations/sqlite/1741895823001-CreateBitstringStatusList.ts
8943
- var CreateBitstringStatusListSqlite1741895823001 = class {
9150
+ // src/migrations/sqlite/1715761125002-CreateContacts.ts
9151
+ var CreateContacts1715761125002 = class {
8944
9152
  static {
8945
- __name(this, "CreateBitstringStatusListSqlite1741895823001");
9153
+ __name(this, "CreateContacts1715761125002");
8946
9154
  }
8947
- name = "CreateBitstringStatusList1741895823000";
9155
+ name = "CreateContacts1715761125002";
8948
9156
  async up(queryRunner) {
8949
- await queryRunner.query(`
8950
- CREATE TABLE "temporary_StatusList" (
8951
- "id" varchar PRIMARY KEY NOT NULL,
8952
- "correlationId" varchar NOT NULL,
8953
- "length" integer NOT NULL,
8954
- "issuer" text NOT NULL,
8955
- "type" varchar CHECK( "type" IN ('StatusList2021', 'OAuthStatusList', 'BitstringStatusList') ) NOT NULL DEFAULT ('StatusList2021'),
8956
- "driverType" varchar CHECK( "driverType" IN ('agent_typeorm','agent_kv_store','github','agent_filesystem') ) NOT NULL DEFAULT ('agent_typeorm'),
8957
- "credentialIdMode" varchar CHECK( "credentialIdMode" IN ('ISSUANCE','PERSISTENCE','NEVER') ) NOT NULL DEFAULT ('ISSUANCE'),
8958
- "proofFormat" varchar CHECK( "proofFormat" IN ('lds','jwt', 'vc+jwt') ) NOT NULL DEFAULT ('lds'),
8959
- "indexingDirection" varchar CHECK( "indexingDirection" IN ('rightToLeft') ),
8960
- "statusPurpose" varchar,
8961
- "statusListCredential" text,
8962
- "expiresAt" datetime,
8963
- "bitsPerStatus" integer DEFAULT (1),
8964
- "ttl" integer,
8965
- "validFrom" datetime,
8966
- "validUntil" datetime,
8967
- CONSTRAINT "UQ_correlationId" UNIQUE ("correlationId")
8968
- )
8969
- `);
8970
- await queryRunner.query(`
8971
- INSERT INTO "temporary_StatusList"(
8972
- "id", "correlationId", "length", "issuer", "type", "driverType",
8973
- "credentialIdMode", "proofFormat", "indexingDirection", "statusPurpose",
8974
- "statusListCredential", "bitsPerStatus", "expiresAt"
8975
- )
8976
- SELECT
8977
- "id", "correlationId", "length", "issuer", "type", "driverType",
8978
- "credentialIdMode", "proofFormat", "indexingDirection", "statusPurpose",
8979
- "statusListCredential", "bitsPerStatus", "expiresAt"
8980
- FROM "StatusList"
8981
- `);
8982
- await queryRunner.query(`DROP TABLE "StatusList"`);
8983
- await queryRunner.query(`ALTER TABLE "temporary_StatusList" RENAME TO "StatusList"`);
8984
- await queryRunner.query(`
8985
- CREATE TABLE "temporary_StatusListEntry" (
8986
- "statusListId" varchar NOT NULL,
8987
- "statusListIndex" integer NOT NULL,
8988
- "credentialId" text,
8989
- "credentialHash" varchar(128),
8990
- "correlationId" varchar(255),
8991
- "value" varchar(50),
8992
- "type" varchar CHECK( "type" IN ('StatusListEntryEntity', 'bitstring') ) NOT NULL DEFAULT ('StatusListEntryEntity'),
8993
- "statusPurpose" varchar,
8994
- "bitsPerStatus" integer DEFAULT (1),
8995
- "statusMessage" text,
8996
- "statusReference" text,
8997
- PRIMARY KEY ("statusListId", "statusListIndex")
8998
- )
8999
- `);
9000
- await queryRunner.query(`
9001
- INSERT INTO "temporary_StatusListEntry"(
9002
- "statusListId", "statusListIndex", "credentialId", "credentialHash",
9003
- "correlationId", "value", "type"
9004
- )
9005
- SELECT
9006
- "statusListId", "statusListIndex", "credentialId", "credentialHash",
9007
- "correlationId", "value", 'StatusListEntryEntity'
9008
- FROM "StatusListEntry"
9009
- `);
9010
- await queryRunner.query(`DROP TABLE "StatusListEntry"`);
9011
- await queryRunner.query(`ALTER TABLE "temporary_StatusListEntry" RENAME TO "StatusListEntry"`);
9157
+ await queryRunner.query(`ALTER TABLE "IdentityMetadata" RENAME TO "temporary_IdentityMetadata"`);
9158
+ await queryRunner.query(`CREATE TABLE "IdentityMetadata"
9159
+ (
9160
+ "id" varchar PRIMARY KEY NOT NULL,
9161
+ "label" varchar(255) NOT NULL,
9162
+ "valueType" varchar NOT NULL,
9163
+ "stringValue" varchar(255),
9164
+ "numberValue" double,
9165
+ "dateValue" datetime,
9166
+ "boolValue" boolean,
9167
+ "identityId" varchar,
9168
+ FOREIGN KEY ("identityId") REFERENCES "Identity" ("id") ON DELETE CASCADE)`);
9169
+ await queryRunner.query(`INSERT INTO "IdentityMetadata" ("id", "label", "valueType", "stringValue", "identityId")
9170
+ SELECT "id", "label", 'string', "value", "identityId"
9171
+ FROM "temporary_IdentityMetadata"
9172
+ `);
9173
+ await queryRunner.query(`DROP TABLE "temporary_IdentityMetadata"`);
9174
+ await queryRunner.query(`CREATE TABLE "ContactMetadata"
9175
+ (
9176
+ "id" varchar PRIMARY KEY NOT NULL,
9177
+ "label" varchar(255) NOT NULL,
9178
+ "valueType" varchar NOT NULL,
9179
+ "stringValue" text,
9180
+ "numberValue" double,
9181
+ "dateValue" datetime,
9182
+ "boolValue" boolean,
9183
+ "contactId" varchar,
9184
+ FOREIGN KEY ("contactId") REFERENCES "BaseContact" ("id") ON DELETE CASCADE)`);
9012
9185
  }
9013
9186
  async down(queryRunner) {
9014
- await queryRunner.query(`
9015
- CREATE TABLE "temporary_StatusListEntry" (
9016
- "statusListId" varchar NOT NULL,
9017
- "statusListIndex" integer NOT NULL,
9018
- "credentialId" text,
9019
- "credentialHash" varchar(128),
9020
- "correlationId" varchar(255),
9021
- "value" varchar(50),
9022
- PRIMARY KEY ("statusListId", "statusListIndex")
9023
- )
9024
- `);
9025
- await queryRunner.query(`
9026
- INSERT INTO "temporary_StatusListEntry"(
9027
- "statusListId", "statusListIndex", "credentialId", "credentialHash",
9028
- "correlationId", "value"
9029
- )
9030
- SELECT
9031
- "statusListId", "statusListIndex", "credentialId", "credentialHash",
9032
- "correlationId", "value"
9033
- FROM "StatusListEntry"
9034
- WHERE "type" = 'StatusListEntryEntity'
9035
- `);
9036
- await queryRunner.query(`DROP TABLE "StatusListEntry"`);
9037
- await queryRunner.query(`ALTER TABLE "temporary_StatusListEntry" RENAME TO "StatusListEntry"`);
9038
- await queryRunner.query(`
9039
- CREATE TABLE "temporary_StatusList" (
9040
- "id" varchar PRIMARY KEY NOT NULL,
9041
- "correlationId" varchar NOT NULL,
9042
- "length" integer NOT NULL,
9043
- "issuer" text NOT NULL,
9044
- "type" varchar CHECK( "type" IN ('StatusList2021', 'OAuthStatusList') ) NOT NULL DEFAULT ('StatusList2021'),
9045
- "driverType" varchar CHECK( "driverType" IN ('agent_typeorm','agent_kv_store','github','agent_filesystem') ) NOT NULL DEFAULT ('agent_typeorm'),
9046
- "credentialIdMode" varchar CHECK( "credentialIdMode" IN ('ISSUANCE','PERSISTENCE','NEVER') ) NOT NULL DEFAULT ('ISSUANCE'),
9047
- "proofFormat" varchar CHECK( "proofFormat" IN ('lds','jwt', 'vc+jwt') ) NOT NULL DEFAULT ('lds'),
9048
- "indexingDirection" varchar CHECK( "indexingDirection" IN ('rightToLeft') ),
9049
- "statusPurpose" varchar,
9050
- "statusListCredential" text,
9051
- "bitsPerStatus" integer,
9052
- "expiresAt" datetime,
9053
- CONSTRAINT "UQ_correlationId" UNIQUE ("correlationId")
9054
- )
9055
- `);
9056
- await queryRunner.query(`
9057
- INSERT INTO "temporary_StatusList"(
9058
- "id", "correlationId", "length", "issuer", "type", "driverType",
9059
- "credentialIdMode", "proofFormat", "indexingDirection", "statusPurpose",
9060
- "statusListCredential", "bitsPerStatus", "expiresAt"
9061
- )
9062
- SELECT
9063
- "id", "correlationId", "length", "issuer",
9064
- CASE WHEN "type" = 'BitstringStatusList' THEN 'StatusList2021' ELSE "type" END,
9065
- "driverType", "credentialIdMode", "proofFormat", "indexingDirection",
9066
- "statusPurpose", "statusListCredential", "bitsPerStatus", "expiresAt"
9067
- FROM "StatusList"
9068
- `);
9069
- await queryRunner.query(`DROP TABLE "StatusList"`);
9070
- await queryRunner.query(`ALTER TABLE "temporary_StatusList" RENAME TO "StatusList"`);
9187
+ await queryRunner.query(`DROP TABLE "ContactMetadata"`);
9188
+ await queryRunner.query(`ALTER TABLE "IdentityMetadata" RENAME TO "temporary_IdentityMetadata"`);
9189
+ await queryRunner.query(`CREATE TABLE "IdentityMetadata"
9190
+ (
9191
+ "id" varchar PRIMARY KEY NOT NULL,
9192
+ "label" varchar(255) NOT NULL,
9193
+ "value" varchar(255) NOT NULL,
9194
+ "identityId" varchar,
9195
+ FOREIGN KEY ("identityId") REFERENCES "Identity" ("id") ON DELETE CASCADE
9196
+ )`);
9197
+ await queryRunner.query(`INSERT INTO "IdentityMetadata" ("id", "label", "value", "identityId")
9198
+ SELECT "id", "label", "stringValue", "identityId"
9199
+ FROM "temporary_IdentityMetadata"`);
9200
+ await queryRunner.query(`DROP TABLE "temporary_IdentityMetadata"`);
9071
9201
  }
9072
9202
  };
9073
9203
 
9074
- // src/migrations/generic/12-CreateBitstringStatusList.ts
9075
- var debug19 = Debug19("sphereon:ssi-sdk:migrations");
9076
- var CreateBitstringStatusList1741895823000 = class {
9204
+ // src/migrations/generic/9-CreateContacts.ts
9205
+ var debug20 = Debug20("sphereon:ssi-sdk:migrations");
9206
+ var CreateContacts1715761125000 = class {
9077
9207
  static {
9078
- __name(this, "CreateBitstringStatusList1741895823000");
9208
+ __name(this, "CreateContacts1715761125000");
9079
9209
  }
9080
- name = "CreateBitstringStatusList1741895823000";
9210
+ name = "CreateContacts1715761125000";
9081
9211
  async up(queryRunner) {
9082
- debug19("migration: creating bitstring status list tables");
9212
+ debug20("migration: updating contact tables");
9083
9213
  const dbType = queryRunner.connection.driver.options.type;
9084
9214
  switch (dbType) {
9085
9215
  case "postgres": {
9086
- const mig = new CreateBitstringStatusListPG1741895823000();
9216
+ debug20("using postgres migration file");
9217
+ const mig = new CreateContacts1715761125001();
9087
9218
  await mig.up(queryRunner);
9219
+ debug20("Migration statements executed");
9088
9220
  return;
9089
9221
  }
9090
9222
  case "sqlite":
9091
9223
  case "expo":
9092
9224
  case "react-native": {
9093
- const mig = new CreateBitstringStatusListSqlite1741895823001();
9225
+ debug20("using sqlite/react-native migration file");
9226
+ const mig = new CreateContacts1715761125002();
9094
9227
  await mig.up(queryRunner);
9228
+ debug20("Migration statements executed");
9095
9229
  return;
9096
9230
  }
9097
9231
  default:
9098
- return Promise.reject(`Migrations only supported for sqlite and postgres. Was ${dbType}`);
9232
+ return Promise.reject(`Migrations are currently only supported for sqlite, react-native, expo and postgres. Was ${dbType}. Please run your database without migrations and with 'migrationsRun: false' and 'synchronize: true' for now`);
9099
9233
  }
9100
9234
  }
9101
9235
  async down(queryRunner) {
9102
- debug19("migration: dropping bitstring status list tables");
9236
+ debug20("migration: reverting machine state tables");
9103
9237
  const dbType = queryRunner.connection.driver.options.type;
9104
9238
  switch (dbType) {
9105
9239
  case "postgres": {
9106
- const mig = new CreateBitstringStatusListPG1741895823000();
9240
+ debug20("using postgres migration file");
9241
+ const mig = new CreateContacts1715761125001();
9107
9242
  await mig.down(queryRunner);
9243
+ debug20("Migration statements executed");
9108
9244
  return;
9109
9245
  }
9110
9246
  case "sqlite":
9111
9247
  case "expo":
9112
9248
  case "react-native": {
9113
- const mig = new CreateBitstringStatusListSqlite1741895823001();
9249
+ debug20("using sqlite/react-native migration file");
9250
+ const mig = new CreateContacts1715761125002();
9114
9251
  await mig.down(queryRunner);
9252
+ debug20("Migration statements executed");
9115
9253
  return;
9116
9254
  }
9117
9255
  default:
9118
- return Promise.reject(`Migrations only supported for sqlite and postgres. Was ${dbType}`);
9256
+ return Promise.reject(`Migrations are currently only supported for sqlite, react-native, expo and postgres. Was ${dbType}. Please run your database without migrations and with 'migrationsRun: false' and 'synchronize: true' for now`);
9119
9257
  }
9120
9258
  }
9121
9259
  };
@@ -9133,6 +9271,7 @@ var DataStoreIssuanceBrandingMigrations = [
9133
9271
  ];
9134
9272
  var DataStoreStatusListMigrations = [
9135
9273
  CreateStatusList1693866470000,
9274
+ AddBitstringStatusListEnum1741895823000,
9136
9275
  CreateBitstringStatusList1741895823000
9137
9276
  ];
9138
9277
  var DataStoreEventLoggerMigrations = [
@@ -9145,7 +9284,8 @@ var DataStoreMachineStateMigrations = [
9145
9284
  CreateMachineStateStore1708098041262
9146
9285
  ];
9147
9286
  var DataStorePresentationDefinitionMigrations = [
9148
- CreatePresentationDefinitions1716533767523
9287
+ CreatePresentationDefinitions1716533767523,
9288
+ CreateDcqlQueryItem1726617600000
9149
9289
  ];
9150
9290
  var DataStoreMigrations = [
9151
9291
  ...DataStoreContactMigrations,
@@ -9332,7 +9472,7 @@ var DataStoreIssuanceBrandingEntities = [
9332
9472
  CredentialClaimsEntity
9333
9473
  ];
9334
9474
  var DataStorePresentationDefinitionEntities = [
9335
- PresentationDefinitionItemEntity
9475
+ DcqlQueryItemEntity
9336
9476
  ];
9337
9477
  var DataStoreStatusListEntities = [
9338
9478
  StatusListEntity,
@@ -9384,7 +9524,6 @@ export {
9384
9524
  CredentialCorrelationType,
9385
9525
  CredentialDocumentFormat,
9386
9526
  CredentialLocaleBrandingEntity,
9387
- CredentialRole,
9388
9527
  CredentialStateType,
9389
9528
  DataStoreContactEntities,
9390
9529
  DataStoreContactMigrations,
@@ -9403,6 +9542,7 @@ export {
9403
9542
  DataStorePresentationDefinitionMigrations,
9404
9543
  DataStoreStatusListEntities,
9405
9544
  DataStoreStatusListMigrations,
9545
+ DcqlQueryItemEntity,
9406
9546
  DidAuthConfigEntity,
9407
9547
  DigitalCredentialEntity,
9408
9548
  DigitalCredentialStore,
@@ -9428,7 +9568,6 @@ export {
9428
9568
  PartyOrigin,
9429
9569
  PartyTypeType,
9430
9570
  PhysicalAddressEntity,
9431
- PresentationDefinitionItemEntity,
9432
9571
  RegulationType,
9433
9572
  StatusList2021Entity,
9434
9573
  StatusListEntity,
@@ -9452,6 +9591,8 @@ export {
9452
9591
  credentialBrandingFrom,
9453
9592
  credentialClaimsEntityFrom,
9454
9593
  credentialLocaleBrandingEntityFrom,
9594
+ dcqlQueryEntityItemFrom,
9595
+ dcqlQueryItemFrom,
9455
9596
  didAuthConfigEntityFrom,
9456
9597
  didAuthConfigFrom,
9457
9598
  digitalCredentialFrom,
@@ -9491,8 +9632,6 @@ export {
9491
9632
  partyTypeFrom,
9492
9633
  physicalAddressEntityFrom,
9493
9634
  physicalAddressFrom,
9494
- presentationDefinitionEntityItemFrom,
9495
- presentationDefinitionItemFrom,
9496
9635
  textAttributesEntityFrom
9497
9636
  };
9498
9637
  //# sourceMappingURL=index.js.map