@sphereon/ssi-sdk.data-store 0.34.1-feature.SSISDK.46.41 → 0.34.1-feature.SSISDK.50.98

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 (31) hide show
  1. package/dist/index.cjs +1618 -1417
  2. package/dist/index.cjs.map +1 -1
  3. package/dist/index.d.cts +160 -166
  4. package/dist/index.d.ts +160 -166
  5. package/dist/index.js +1574 -1373
  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 +15 -37
  13. package/src/__tests__/pd-manager.store.test.ts +133 -0
  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 +1 -1
  18. package/src/migrations/generic/12-CreateBitstringStatusList.ts +32 -2
  19. package/src/migrations/generic/13-UpdatePresentationDefinitionItemNullable.ts +67 -0
  20. package/src/migrations/generic/index.ts +13 -5
  21. package/src/migrations/postgres/1737110469001-UpdateStatusList.ts +1 -1
  22. package/src/migrations/postgres/1741895823000-CreateBitstringStatusList.ts +15 -2
  23. package/src/migrations/postgres/1756975509000-UpdatePresentationDefinitionItemNullable.ts +15 -0
  24. package/src/migrations/sqlite/1756975340000-UpdatePresentationDefinitionItemNullable.ts +77 -0
  25. package/src/presentationDefinition/PDStore.ts +6 -1
  26. package/src/types/contact/contact.ts +1 -1
  27. package/src/types/digitalCredential/IAbstractDigitalCredentialStore.ts +2 -1
  28. package/src/types/digitalCredential/enums.ts +1 -8
  29. package/src/types/digitalCredential/types.ts +2 -1
  30. package/src/types/presentationDefinition/presentationDefinition.ts +3 -3
  31. package/src/utils/presentationDefinition/MappingUtils.ts +32 -10
package/dist/index.cjs CHANGED
@@ -54,7 +54,6 @@ __export(index_exports, {
54
54
  CredentialCorrelationType: () => CredentialCorrelationType,
55
55
  CredentialDocumentFormat: () => CredentialDocumentFormat,
56
56
  CredentialLocaleBrandingEntity: () => CredentialLocaleBrandingEntity,
57
- CredentialRole: () => CredentialRole,
58
57
  CredentialStateType: () => CredentialStateType,
59
58
  DataStoreContactEntities: () => DataStoreContactEntities,
60
59
  DataStoreContactMigrations: () => DataStoreContactMigrations,
@@ -174,55 +173,55 @@ var import_typeorm12 = __toESM(require("typeorm"), 1);
174
173
  var import_typeorm11 = __toESM(require("typeorm"), 1);
175
174
 
176
175
  // src/types/contact/contact.ts
177
- var ConnectionType = /* @__PURE__ */ (function(ConnectionType2) {
176
+ var ConnectionType = /* @__PURE__ */ function(ConnectionType2) {
178
177
  ConnectionType2["OPENID_CONNECT"] = "OIDC";
179
178
  ConnectionType2["SIOPv2"] = "SIOPv2";
180
179
  ConnectionType2["SIOPv2_OpenID4VP"] = "SIOPv2+OpenID4VP";
181
180
  return ConnectionType2;
182
- })({});
183
- var CorrelationIdentifierType = /* @__PURE__ */ (function(CorrelationIdentifierType2) {
181
+ }({});
182
+ var CorrelationIdentifierType = /* @__PURE__ */ function(CorrelationIdentifierType2) {
184
183
  CorrelationIdentifierType2["DID"] = "did";
185
184
  CorrelationIdentifierType2["URL"] = "url";
186
185
  return CorrelationIdentifierType2;
187
- })({});
188
- var PartyTypeType = /* @__PURE__ */ (function(PartyTypeType2) {
186
+ }({});
187
+ var PartyTypeType = /* @__PURE__ */ function(PartyTypeType2) {
189
188
  PartyTypeType2["NATURAL_PERSON"] = "naturalPerson";
190
189
  PartyTypeType2["ORGANIZATION"] = "organization";
191
190
  return PartyTypeType2;
192
- })({});
193
- var PartyOrigin = /* @__PURE__ */ (function(PartyOrigin2) {
191
+ }({});
192
+ var PartyOrigin = /* @__PURE__ */ function(PartyOrigin2) {
194
193
  PartyOrigin2["INTERNAL"] = "INTERNAL";
195
194
  PartyOrigin2["EXTERNAL"] = "EXTERNAL";
196
195
  return PartyOrigin2;
197
- })({});
198
- var IdentityOrigin = /* @__PURE__ */ (function(IdentityOrigin2) {
196
+ }({});
197
+ var IdentityOrigin = /* @__PURE__ */ function(IdentityOrigin2) {
199
198
  IdentityOrigin2["INTERNAL"] = "INTERNAL";
200
199
  IdentityOrigin2["EXTERNAL"] = "EXTERNAL";
201
200
  return IdentityOrigin2;
202
- })({});
201
+ }({});
203
202
 
204
203
  // src/types/digitalCredential/enums.ts
205
- var DocumentType = /* @__PURE__ */ (function(DocumentType2) {
204
+ var DocumentType = /* @__PURE__ */ function(DocumentType2) {
206
205
  DocumentType2["VC"] = "VC";
207
206
  DocumentType2["VP"] = "VP";
208
207
  DocumentType2["P"] = "P";
209
208
  DocumentType2["C"] = "C";
210
209
  return DocumentType2;
211
- })({});
212
- var RegulationType = /* @__PURE__ */ (function(RegulationType2) {
210
+ }({});
211
+ var RegulationType = /* @__PURE__ */ function(RegulationType2) {
213
212
  RegulationType2["PID"] = "PID";
214
213
  RegulationType2["QEAA"] = "QEAA";
215
214
  RegulationType2["EAA"] = "EAA";
216
215
  RegulationType2["NON_REGULATED"] = "NON_REGULATED";
217
216
  return RegulationType2;
218
- })({});
219
- var CredentialDocumentFormat = /* @__PURE__ */ (function(CredentialDocumentFormat2) {
217
+ }({});
218
+ var CredentialDocumentFormat = /* @__PURE__ */ function(CredentialDocumentFormat2) {
220
219
  CredentialDocumentFormat2["JSON_LD"] = "JSON_LD";
221
220
  CredentialDocumentFormat2["JWT"] = "JWT";
222
221
  CredentialDocumentFormat2["SD_JWT"] = "SD_JWT";
223
222
  CredentialDocumentFormat2["MSO_MDOC"] = "MSO_MDOC";
224
223
  return CredentialDocumentFormat2;
225
- })({});
224
+ }({});
226
225
  (function(CredentialDocumentFormat2) {
227
226
  function fromSpecValue(credentialFormat) {
228
227
  const format = credentialFormat.toLowerCase();
@@ -243,7 +242,7 @@ var CredentialDocumentFormat = /* @__PURE__ */ (function(CredentialDocumentForma
243
242
  function toSpecValue(documentFormat, documentType) {
244
243
  switch (documentFormat) {
245
244
  case "SD_JWT":
246
- return "vc+sd-jwt";
245
+ return "dc+sd-jwt";
247
246
  case "MSO_MDOC":
248
247
  return "mso_mdoc";
249
248
  case "JSON_LD":
@@ -255,26 +254,19 @@ var CredentialDocumentFormat = /* @__PURE__ */ (function(CredentialDocumentForma
255
254
  __name(toSpecValue, "toSpecValue");
256
255
  CredentialDocumentFormat2.toSpecValue = toSpecValue;
257
256
  })(CredentialDocumentFormat || (CredentialDocumentFormat = {}));
258
- var CredentialCorrelationType = /* @__PURE__ */ (function(CredentialCorrelationType2) {
257
+ var CredentialCorrelationType = /* @__PURE__ */ function(CredentialCorrelationType2) {
259
258
  CredentialCorrelationType2["DID"] = "DID";
260
259
  CredentialCorrelationType2["X509_SAN"] = "X509_SAN";
261
260
  CredentialCorrelationType2["KID"] = "KID";
262
261
  CredentialCorrelationType2["URL"] = "URL";
263
262
  return CredentialCorrelationType2;
264
- })({});
265
- var CredentialRole = /* @__PURE__ */ (function(CredentialRole2) {
266
- CredentialRole2["ISSUER"] = "ISSUER";
267
- CredentialRole2["VERIFIER"] = "VERIFIER";
268
- CredentialRole2["HOLDER"] = "HOLDER";
269
- CredentialRole2["FEDERATION_TRUST_ANCHOR"] = "FEDERATION_TRUST_ANCHOR";
270
- return CredentialRole2;
271
- })({});
272
- var CredentialStateType = /* @__PURE__ */ (function(CredentialStateType2) {
263
+ }({});
264
+ var CredentialStateType = /* @__PURE__ */ function(CredentialStateType2) {
273
265
  CredentialStateType2["REVOKED"] = "REVOKED";
274
266
  CredentialStateType2["VERIFIED"] = "VERIFIED";
275
267
  CredentialStateType2["EXPIRED"] = "EXPIRED";
276
268
  return CredentialStateType2;
277
- })({});
269
+ }({});
278
270
 
279
271
  // src/entities/contact/IdentityEntity.ts
280
272
  var import_typeorm10 = require("typeorm");
@@ -3935,6 +3927,7 @@ AuditEventEntity = _ts_decorate32([
3935
3927
 
3936
3928
  // src/entities/digitalCredential/DigitalCredentialEntity.ts
3937
3929
  var import_ssi_sdk17 = require("@sphereon/ssi-sdk.agent-config");
3930
+ var import_ssi_types3 = require("@sphereon/ssi-types");
3938
3931
  var import_typeorm32 = require("typeorm");
3939
3932
  function _ts_decorate33(decorators, target, key, desc) {
3940
3933
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
@@ -4018,10 +4011,10 @@ _ts_decorate33([
4018
4011
  _ts_decorate33([
4019
4012
  (0, import_typeorm32.Column)("simple-enum", {
4020
4013
  name: "credential_role",
4021
- enum: CredentialRole,
4014
+ enum: import_ssi_types3.CredentialRole,
4022
4015
  nullable: false
4023
4016
  }),
4024
- _ts_metadata32("design:type", typeof CredentialRole === "undefined" ? Object : CredentialRole)
4017
+ _ts_metadata32("design:type", typeof import_ssi_types3.CredentialRole === "undefined" ? Object : import_ssi_types3.CredentialRole)
4025
4018
  ], DigitalCredentialEntity.prototype, "credentialRole", void 0);
4026
4019
  _ts_decorate33([
4027
4020
  (0, import_typeorm32.Column)("text", {
@@ -4292,7 +4285,7 @@ _ts_decorate34([
4292
4285
  (0, import_typeorm33.Column)({
4293
4286
  name: "definition_payload",
4294
4287
  type: "text",
4295
- nullable: false,
4288
+ nullable: true,
4296
4289
  unique: false
4297
4290
  }),
4298
4291
  (0, import_class_validator21.IsNotEmpty)({
@@ -5512,6 +5505,7 @@ var AbstractDigitalCredentialStore = class {
5512
5505
  };
5513
5506
 
5514
5507
  // src/digitalCredential/DigitalCredentialStore.ts
5508
+ var import_ssi_types4 = require("@sphereon/ssi-types");
5515
5509
  var import_debug2 = __toESM(require("debug"), 1);
5516
5510
 
5517
5511
  // src/utils/SortingUtils.ts
@@ -5581,7 +5575,7 @@ var DigitalCredentialStore = class extends AbstractDigitalCredentialStore {
5581
5575
  if (!args) {
5582
5576
  return false;
5583
5577
  }
5584
- let query = {};
5578
+ const query = {};
5585
5579
  if ("id" in args) {
5586
5580
  query.id = args.id;
5587
5581
  } else if ("hash" in args) {
@@ -5667,7 +5661,7 @@ var DigitalCredentialStore = class extends AbstractDigitalCredentialStore {
5667
5661
  }, "updateCredentialState");
5668
5662
  assertValidDigitalCredential(credentialEntity) {
5669
5663
  const { kmsKeyRef, identifierMethod, credentialRole, isIssuerSigned } = credentialEntity;
5670
- const isRoleInvalid = credentialRole === CredentialRole.ISSUER || credentialRole === CredentialRole.HOLDER && !isIssuerSigned;
5664
+ const isRoleInvalid = credentialRole === import_ssi_types4.CredentialRole.ISSUER || credentialRole === import_ssi_types4.CredentialRole.HOLDER && !isIssuerSigned;
5671
5665
  if (isRoleInvalid && (!kmsKeyRef || !identifierMethod)) {
5672
5666
  const missingFields = [];
5673
5667
  if (!kmsKeyRef) missingFields.push("kmsKeyRef");
@@ -6181,41 +6175,41 @@ var IssuanceBrandingStore = class extends AbstractIssuanceBrandingStore {
6181
6175
  };
6182
6176
 
6183
6177
  // src/statusList/StatusListStore.ts
6184
- var import_ssi_types4 = require("@sphereon/ssi-types");
6178
+ var import_ssi_types6 = require("@sphereon/ssi-types");
6185
6179
  var import_debug4 = __toESM(require("debug"), 1);
6186
6180
  var import_typeorm37 = require("typeorm");
6187
6181
 
6188
6182
  // src/utils/statusList/MappingUtils.ts
6189
- var import_ssi_types3 = require("@sphereon/ssi-types");
6183
+ var import_ssi_types5 = require("@sphereon/ssi-types");
6190
6184
  var statusListEntityFrom = /* @__PURE__ */ __name((args) => {
6191
6185
  switch (args.type) {
6192
- case import_ssi_types3.StatusListType.StatusList2021: {
6186
+ case import_ssi_types5.StatusListType.StatusList2021: {
6193
6187
  const entity = new StatusList2021Entity();
6194
6188
  const sl2021 = args;
6195
6189
  entity.indexingDirection = sl2021.indexingDirection;
6196
6190
  entity.statusPurpose = sl2021.statusPurpose;
6197
6191
  setBaseFields(entity, args);
6198
6192
  Object.defineProperty(entity, "type", {
6199
- value: import_ssi_types3.StatusListType.StatusList2021,
6193
+ value: import_ssi_types5.StatusListType.StatusList2021,
6200
6194
  enumerable: true,
6201
6195
  configurable: true
6202
6196
  });
6203
6197
  return entity;
6204
6198
  }
6205
- case import_ssi_types3.StatusListType.OAuthStatusList: {
6199
+ case import_ssi_types5.StatusListType.OAuthStatusList: {
6206
6200
  const entity = new OAuthStatusListEntity();
6207
6201
  const oauthSl = args;
6208
6202
  entity.bitsPerStatus = oauthSl.bitsPerStatus;
6209
6203
  entity.expiresAt = oauthSl.expiresAt;
6210
6204
  setBaseFields(entity, args);
6211
6205
  Object.defineProperty(entity, "type", {
6212
- value: import_ssi_types3.StatusListType.OAuthStatusList,
6206
+ value: import_ssi_types5.StatusListType.OAuthStatusList,
6213
6207
  enumerable: true,
6214
6208
  configurable: true
6215
6209
  });
6216
6210
  return entity;
6217
6211
  }
6218
- case import_ssi_types3.StatusListType.BitstringStatusList: {
6212
+ case import_ssi_types5.StatusListType.BitstringStatusList: {
6219
6213
  const entity = new BitstringStatusListEntity();
6220
6214
  const bitstringsl = args;
6221
6215
  if (!bitstringsl.bitsPerStatus) {
@@ -6228,7 +6222,7 @@ var statusListEntityFrom = /* @__PURE__ */ __name((args) => {
6228
6222
  entity.ttl = bitstringsl.ttl;
6229
6223
  setBaseFields(entity, args);
6230
6224
  Object.defineProperty(entity, "type", {
6231
- value: import_ssi_types3.StatusListType.BitstringStatusList,
6225
+ value: import_ssi_types5.StatusListType.BitstringStatusList,
6232
6226
  enumerable: true,
6233
6227
  configurable: true
6234
6228
  });
@@ -6242,7 +6236,7 @@ var statusListFrom = /* @__PURE__ */ __name((entity) => {
6242
6236
  if (entity instanceof StatusList2021Entity) {
6243
6237
  const result = {
6244
6238
  ...getBaseFields(entity),
6245
- type: import_ssi_types3.StatusListType.StatusList2021,
6239
+ type: import_ssi_types5.StatusListType.StatusList2021,
6246
6240
  indexingDirection: entity.indexingDirection,
6247
6241
  statusPurpose: entity.statusPurpose
6248
6242
  };
@@ -6251,7 +6245,7 @@ var statusListFrom = /* @__PURE__ */ __name((entity) => {
6251
6245
  if (entity instanceof OAuthStatusListEntity) {
6252
6246
  const result = {
6253
6247
  ...getBaseFields(entity),
6254
- type: import_ssi_types3.StatusListType.OAuthStatusList,
6248
+ type: import_ssi_types5.StatusListType.OAuthStatusList,
6255
6249
  bitsPerStatus: entity.bitsPerStatus,
6256
6250
  expiresAt: entity.expiresAt
6257
6251
  };
@@ -6260,7 +6254,7 @@ var statusListFrom = /* @__PURE__ */ __name((entity) => {
6260
6254
  if (entity instanceof BitstringStatusListEntity) {
6261
6255
  const result = {
6262
6256
  ...getBaseFields(entity),
6263
- type: import_ssi_types3.StatusListType.BitstringStatusList,
6257
+ type: import_ssi_types5.StatusListType.BitstringStatusList,
6264
6258
  statusPurpose: entity.statusPurpose,
6265
6259
  bitsPerStatus: entity.bitsPerStatus,
6266
6260
  validFrom: entity.validFrom,
@@ -6581,11 +6575,11 @@ var StatusListStore = class {
6581
6575
  async getStatusListRepo(type) {
6582
6576
  const dataSource = await this.getDS();
6583
6577
  switch (type) {
6584
- case import_ssi_types4.StatusListType.StatusList2021:
6578
+ case import_ssi_types6.StatusListType.StatusList2021:
6585
6579
  return dataSource.getRepository(StatusList2021Entity);
6586
- case import_ssi_types4.StatusListType.OAuthStatusList:
6580
+ case import_ssi_types6.StatusListType.OAuthStatusList:
6587
6581
  return dataSource.getRepository(OAuthStatusListEntity);
6588
- case import_ssi_types4.StatusListType.BitstringStatusList:
6582
+ case import_ssi_types6.StatusListType.BitstringStatusList:
6589
6583
  return dataSource.getRepository(BitstringStatusListEntity);
6590
6584
  default:
6591
6585
  return dataSource.getRepository(StatusListEntity);
@@ -6594,7 +6588,7 @@ var StatusListStore = class {
6594
6588
  async getStatusListEntryRepo(type) {
6595
6589
  const dataSource = await this.getDS();
6596
6590
  switch (type) {
6597
- case import_ssi_types4.StatusListType.BitstringStatusList:
6591
+ case import_ssi_types6.StatusListType.BitstringStatusList:
6598
6592
  return dataSource.getRepository(BitstringStatusListEntryEntity);
6599
6593
  default:
6600
6594
  return dataSource.getRepository(StatusListEntryEntity);
@@ -6610,15 +6604,15 @@ var AbstractEventLoggerStore = class {
6610
6604
  };
6611
6605
 
6612
6606
  // src/eventLogger/EventLoggerStore.ts
6613
- var import_ssi_types6 = require("@sphereon/ssi-types");
6607
+ var import_ssi_types8 = require("@sphereon/ssi-types");
6614
6608
  var import_debug5 = __toESM(require("debug"), 1);
6615
6609
 
6616
6610
  // src/utils/eventLogger/MappingUtils.ts
6617
- var import_ssi_types5 = require("@sphereon/ssi-types");
6611
+ var import_ssi_types7 = require("@sphereon/ssi-types");
6618
6612
  var auditEventFrom = /* @__PURE__ */ __name((event) => {
6619
6613
  const result = {
6620
6614
  id: event.id,
6621
- type: import_ssi_types5.LoggingEventType.AUDIT,
6615
+ type: import_ssi_types7.LoggingEventType.AUDIT,
6622
6616
  description: event.description,
6623
6617
  timestamp: event.timestamp,
6624
6618
  level: event.level,
@@ -6645,7 +6639,7 @@ var auditEventFrom = /* @__PURE__ */ __name((event) => {
6645
6639
  }, "auditEventFrom");
6646
6640
  var auditEventEntityFrom = /* @__PURE__ */ __name((args) => {
6647
6641
  const auditEventEntity = new AuditEventEntity();
6648
- auditEventEntity.type = import_ssi_types5.LoggingEventType.AUDIT;
6642
+ auditEventEntity.type = import_ssi_types7.LoggingEventType.AUDIT;
6649
6643
  auditEventEntity.timestamp = args.timestamp;
6650
6644
  auditEventEntity.level = args.level;
6651
6645
  auditEventEntity.correlationId = args.correlationId;
@@ -6669,7 +6663,7 @@ var auditEventEntityFrom = /* @__PURE__ */ __name((args) => {
6669
6663
  var activityEventFrom = /* @__PURE__ */ __name((event) => {
6670
6664
  const result = {
6671
6665
  id: event.id,
6672
- type: import_ssi_types5.LoggingEventType.ACTIVITY,
6666
+ type: import_ssi_types7.LoggingEventType.ACTIVITY,
6673
6667
  credentialType: event.credentialType,
6674
6668
  originalCredential: event.originalCredential,
6675
6669
  credentialHash: event.credentialHash,
@@ -6701,7 +6695,7 @@ var activityEventFrom = /* @__PURE__ */ __name((event) => {
6701
6695
  }, "activityEventFrom");
6702
6696
  var activityEventEntityFrom = /* @__PURE__ */ __name((args) => {
6703
6697
  const activityEventEntity = new AuditEventEntity();
6704
- activityEventEntity.type = import_ssi_types5.LoggingEventType.ACTIVITY;
6698
+ activityEventEntity.type = import_ssi_types7.LoggingEventType.ACTIVITY;
6705
6699
  activityEventEntity.timestamp = args.timestamp;
6706
6700
  activityEventEntity.level = args.level;
6707
6701
  activityEventEntity.correlationId = args.correlationId;
@@ -6743,11 +6737,11 @@ var EventLoggerStore = class extends AbstractEventLoggerStore {
6743
6737
  const { filter = [] } = args ?? {};
6744
6738
  const auditEventsFilter = filter.map((item) => ({
6745
6739
  ...item,
6746
- type: import_ssi_types6.LoggingEventType.AUDIT
6740
+ type: import_ssi_types8.LoggingEventType.AUDIT
6747
6741
  }));
6748
6742
  if (auditEventsFilter.length === 0) {
6749
6743
  auditEventsFilter.push({
6750
- type: import_ssi_types6.LoggingEventType.AUDIT
6744
+ type: import_ssi_types8.LoggingEventType.AUDIT
6751
6745
  });
6752
6746
  }
6753
6747
  const connection = await this.dbConnection;
@@ -6769,11 +6763,11 @@ var EventLoggerStore = class extends AbstractEventLoggerStore {
6769
6763
  const { filter = [] } = args ?? {};
6770
6764
  const activityEventsFilter = filter.map((item) => ({
6771
6765
  ...item,
6772
- type: import_ssi_types6.LoggingEventType.ACTIVITY
6766
+ type: import_ssi_types8.LoggingEventType.ACTIVITY
6773
6767
  }));
6774
6768
  if (activityEventsFilter.length === 0) {
6775
6769
  activityEventsFilter.push({
6776
- type: import_ssi_types6.LoggingEventType.ACTIVITY
6770
+ type: import_ssi_types8.LoggingEventType.ACTIVITY
6777
6771
  });
6778
6772
  }
6779
6773
  const connection = await this.dbConnection;
@@ -6943,6 +6937,7 @@ var import_typeorm39 = require("typeorm");
6943
6937
  var import_debug7 = __toESM(require("debug"), 1);
6944
6938
 
6945
6939
  // src/utils/presentationDefinition/MappingUtils.ts
6940
+ var import_dcql = require("dcql");
6946
6941
  var blakepkg = __toESM(require("blakejs"), 1);
6947
6942
  var presentationDefinitionItemFrom = /* @__PURE__ */ __name((entity) => {
6948
6943
  const result = {
@@ -6953,7 +6948,12 @@ var presentationDefinitionItemFrom = /* @__PURE__ */ __name((entity) => {
6953
6948
  name: entity.name,
6954
6949
  purpose: entity.purpose,
6955
6950
  definitionPayload: JSON.parse(entity.definitionPayload),
6956
- dcqlPayload: JSON.parse(entity.dcqlPayload),
6951
+ ...entity.dcqlPayload && {
6952
+ dcqlPayload: {
6953
+ queryId: entity.definitionId,
6954
+ dcqlQuery: import_dcql.DcqlQuery.parse(JSON.parse(entity.dcqlPayload))
6955
+ }
6956
+ },
6957
6957
  createdAt: entity.createdAt,
6958
6958
  lastUpdatedAt: entity.lastUpdatedAt
6959
6959
  };
@@ -6966,8 +6966,12 @@ var presentationDefinitionEntityItemFrom = /* @__PURE__ */ __name((item) => {
6966
6966
  entity.version = item.version;
6967
6967
  entity.name = item.name;
6968
6968
  entity.purpose = item.purpose;
6969
- entity.definitionPayload = JSON.stringify(item.definitionPayload);
6970
- entity.dcqlPayload = JSON.stringify(item.dcqlPayload);
6969
+ if (item.definitionPayload) {
6970
+ entity.definitionPayload = JSON.stringify(item.definitionPayload);
6971
+ }
6972
+ if (item.dcqlPayload) {
6973
+ entity.dcqlPayload = JSON.stringify(item.dcqlPayload.dcqlQuery);
6974
+ }
6971
6975
  return entity;
6972
6976
  }, "presentationDefinitionEntityItemFrom");
6973
6977
  function hashPayload(payload) {
@@ -6975,13 +6979,24 @@ function hashPayload(payload) {
6975
6979
  }
6976
6980
  __name(hashPayload, "hashPayload");
6977
6981
  function isPresentationDefinitionEqual(base, compare) {
6978
- if (base.definitionId !== compare.definitionId || base.tenantId != compare.tenantId || base.version !== compare.version || base.name != compare.name || base.purpose != compare.purpose) {
6982
+ if (base.definitionId !== compare.definitionId || base.tenantId !== compare.tenantId || base.version !== compare.version || base.name !== compare.name || base.purpose !== compare.purpose) {
6983
+ return false;
6984
+ }
6985
+ if (base.dcqlPayload && compare.dcqlPayload) {
6986
+ if (hashPayload(base.dcqlPayload) !== hashPayload(compare.dcqlPayload)) {
6987
+ return false;
6988
+ }
6989
+ } else if (base.dcqlPayload || compare.dcqlPayload) {
6979
6990
  return false;
6980
6991
  }
6981
6992
  if (base.definitionPayload && compare.definitionPayload) {
6982
- return hashPayload(base.definitionPayload) === hashPayload(compare.definitionPayload);
6993
+ if (hashPayload(base.definitionPayload) !== hashPayload(compare.definitionPayload)) {
6994
+ return false;
6995
+ }
6996
+ } else if (base.definitionPayload || compare.definitionPayload) {
6997
+ return false;
6983
6998
  }
6984
- return false;
6999
+ return true;
6985
7000
  }
6986
7001
  __name(isPresentationDefinitionEqual, "isPresentationDefinitionEqual");
6987
7002
 
@@ -7070,7 +7085,12 @@ var PDStore = class extends AbstractPDStore {
7070
7085
  updatedEntity.version = item.version;
7071
7086
  updatedEntity.name = item.name;
7072
7087
  updatedEntity.purpose = item.purpose;
7073
- updatedEntity.definitionPayload = JSON.stringify(item.definitionPayload);
7088
+ if (item.definitionPayload) {
7089
+ updatedEntity.definitionPayload = JSON.stringify(item.definitionPayload);
7090
+ }
7091
+ if (item.dcqlPayload) {
7092
+ updatedEntity.dcqlPayload = JSON.stringify(item.dcqlPayload.dcqlQuery);
7093
+ }
7074
7094
  debug7("Updating presentation definition entity", updatedEntity);
7075
7095
  const updateResult = await pdRepository.save(updatedEntity, {
7076
7096
  transaction: true
@@ -7306,9 +7326,120 @@ var CreateContacts1659463079429 = class {
7306
7326
  }
7307
7327
  };
7308
7328
 
7309
- // src/migrations/generic/2-CreateIssuanceBranding.ts
7329
+ // src/migrations/generic/10-CreatePresentationDefinitions.ts
7310
7330
  var import_debug9 = __toESM(require("debug"), 1);
7311
7331
 
7332
+ // src/migrations/postgres/1716475165345-CreatePresentationDefinitions.ts
7333
+ var CreatePresentationDefinitions1716475165345 = class {
7334
+ static {
7335
+ __name(this, "CreatePresentationDefinitions1716475165345");
7336
+ }
7337
+ name = "CreatePresentationDefinitions1716475165345";
7338
+ async up(queryRunner) {
7339
+ await queryRunner.query(`
7340
+ CREATE TABLE "PresentationDefinitionItem" (
7341
+ "id" uuid NOT NULL DEFAULT uuid_generate_v4(),
7342
+ "tenant_id" TEXT,
7343
+ "definition_id" TEXT NOT NULL,
7344
+ "name" TEXT,
7345
+ "version" TEXT NOT NULL,
7346
+ "purpose" TEXT,
7347
+ "definition_payload" TEXT NOT NULL,
7348
+ "dcql_payload" TEXT,
7349
+ "created_at" TIMESTAMP NOT NULL DEFAULT now(),
7350
+ "last_updated_at" TIMESTAMP NOT NULL DEFAULT now(),
7351
+ CONSTRAINT "PK_PresentationDefinitionItem_id" PRIMARY KEY ("id"))
7352
+ `);
7353
+ }
7354
+ async down(queryRunner) {
7355
+ await queryRunner.query(`DROP TABLE "PresentationDefinitionItem"`);
7356
+ }
7357
+ };
7358
+
7359
+ // src/migrations/sqlite/1716475165344-CreatePresentationDefinitions.ts
7360
+ var CreatePresentationDefinitions1716475165344 = class {
7361
+ static {
7362
+ __name(this, "CreatePresentationDefinitions1716475165344");
7363
+ }
7364
+ name = "CreatePresentationDefinitions1716475165344";
7365
+ async up(queryRunner) {
7366
+ await queryRunner.query(`CREATE TABLE "PresentationDefinitionItem" (
7367
+ "id" varchar PRIMARY KEY NOT NULL,
7368
+ "tenant_id" varchar,
7369
+ "definition_id" varchar NOT NULL,
7370
+ "name" varchar,
7371
+ "version" varchar NOT NULL,
7372
+ "purpose" varchar,
7373
+ "definition_payload" varchar NOT NULL,
7374
+ "dcql_payload" varchar,
7375
+ "created_at" datetime NOT NULL DEFAULT (datetime('now')),
7376
+ "last_updated_at" datetime NOT NULL DEFAULT (datetime('now')))`);
7377
+ }
7378
+ async down(queryRunner) {
7379
+ await queryRunner.query(`DROP TABLE "PresentationDefinitionItem"`);
7380
+ }
7381
+ };
7382
+
7383
+ // src/migrations/generic/10-CreatePresentationDefinitions.ts
7384
+ var debug9 = (0, import_debug9.default)("sphereon:ssi-sdk:migrations");
7385
+ var CreatePresentationDefinitions1716533767523 = class {
7386
+ static {
7387
+ __name(this, "CreatePresentationDefinitions1716533767523");
7388
+ }
7389
+ name = "CreatePresentationDefinitionItems1716533767523";
7390
+ async up(queryRunner) {
7391
+ debug9("migration: creating machine state tables");
7392
+ const dbType = queryRunner.connection.driver.options.type;
7393
+ switch (dbType) {
7394
+ case "postgres": {
7395
+ debug9("using postgres migration file");
7396
+ const mig = new CreatePresentationDefinitions1716475165345();
7397
+ await mig.up(queryRunner);
7398
+ debug9("Migration statements executed");
7399
+ return;
7400
+ }
7401
+ case "sqlite":
7402
+ case "expo":
7403
+ case "react-native": {
7404
+ debug9("using sqlite/react-native migration file");
7405
+ const mig = new CreatePresentationDefinitions1716475165344();
7406
+ await mig.up(queryRunner);
7407
+ debug9("Migration statements executed");
7408
+ return;
7409
+ }
7410
+ default:
7411
+ 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`);
7412
+ }
7413
+ }
7414
+ async down(queryRunner) {
7415
+ debug9("migration: reverting machine state tables");
7416
+ const dbType = queryRunner.connection.driver.options.type;
7417
+ switch (dbType) {
7418
+ case "postgres": {
7419
+ debug9("using postgres migration file");
7420
+ const mig = new CreatePresentationDefinitions1716475165345();
7421
+ await mig.down(queryRunner);
7422
+ debug9("Migration statements executed");
7423
+ return;
7424
+ }
7425
+ case "sqlite":
7426
+ case "expo":
7427
+ case "react-native": {
7428
+ debug9("using sqlite/react-native migration file");
7429
+ const mig = new CreatePresentationDefinitions1716475165344();
7430
+ await mig.down(queryRunner);
7431
+ debug9("Migration statements executed");
7432
+ return;
7433
+ }
7434
+ default:
7435
+ 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`);
7436
+ }
7437
+ }
7438
+ };
7439
+
7440
+ // src/migrations/generic/11-FixCredentialClaimsReferenceUuid.ts
7441
+ var import_debug10 = __toESM(require("debug"), 1);
7442
+
7312
7443
  // src/migrations/postgres/1685628974232-CreateIssuanceBranding.ts
7313
7444
  var import_ssi_sdk21 = require("@sphereon/ssi-sdk.core");
7314
7445
  var CreateIssuanceBranding1685628974232 = class {
@@ -7445,31 +7576,105 @@ var CreateIssuanceBranding1685628973231 = class {
7445
7576
  }
7446
7577
  };
7447
7578
 
7448
- // src/migrations/generic/2-CreateIssuanceBranding.ts
7449
- var debug9 = (0, import_debug9.default)("sphereon:ssi-sdk:migrations");
7450
- var CreateIssuanceBranding1659463079429 = class {
7579
+ // src/migrations/postgres/1741895822987-FixCredentialClaimsReferencesUuid.ts
7580
+ var FixCredentialClaimsReferencesUuidPG1741895822987 = class {
7451
7581
  static {
7452
- __name(this, "CreateIssuanceBranding1659463079429");
7582
+ __name(this, "FixCredentialClaimsReferencesUuidPG1741895822987");
7453
7583
  }
7454
- name = "CreateIssuanceBranding1659463079429";
7584
+ name = "FixCredentialClaimsReferencesUuid1741895822987";
7585
+ async up(queryRunner) {
7586
+ await queryRunner.query(`
7587
+ ALTER TABLE "CredentialClaims"
7588
+ ALTER COLUMN "credentialLocaleBrandingId" TYPE uuid USING "credentialLocaleBrandingId"::uuid;
7589
+ `);
7590
+ }
7591
+ async down(queryRunner) {
7592
+ await queryRunner.query(`
7593
+ ALTER TABLE "CredentialClaims"
7594
+ ALTER COLUMN "credentialLocaleBrandingId" TYPE character varying USING "credentialLocaleBrandingId"::text;
7595
+ `);
7596
+ }
7597
+ };
7598
+
7599
+ // src/migrations/sqlite/1741895822987-FixCredentialClaimsReferencesUuid.ts
7600
+ var FixCredentialClaimsReferencesUuidSqlite1741895822987 = class {
7601
+ static {
7602
+ __name(this, "FixCredentialClaimsReferencesUuidSqlite1741895822987");
7603
+ }
7604
+ name = "FixCredentialClaimsReferencesUuid1741895822987";
7605
+ async up(queryRunner) {
7606
+ await queryRunner.query(`
7607
+ CREATE TABLE "CredentialClaims_new"
7608
+ (
7609
+ "id" uuid NOT NULL DEFAULT (lower(hex(randomblob(16)))),
7610
+ "key" character varying(255) NOT NULL,
7611
+ "name" character varying(255) NOT NULL,
7612
+ "credentialLocaleBrandingId" uuid,
7613
+ CONSTRAINT "PK_CredentialClaims_id" PRIMARY KEY ("id")
7614
+ )
7615
+ `);
7616
+ await queryRunner.query(`
7617
+ INSERT INTO "CredentialClaims_new" ("id", "key", "name", "credentialLocaleBrandingId")
7618
+ SELECT "id", "key", "name", "credentialLocaleBrandingId"
7619
+ FROM "CredentialClaims"
7620
+ `);
7621
+ await queryRunner.query(`DROP TABLE "CredentialClaims"`);
7622
+ await queryRunner.query(`ALTER TABLE "CredentialClaims_new" RENAME TO "CredentialClaims"`);
7623
+ await queryRunner.query(`
7624
+ CREATE UNIQUE INDEX "IDX_CredentialClaimsEntity_credentialLocaleBranding_locale"
7625
+ ON "CredentialClaims" ("credentialLocaleBrandingId", "key")
7626
+ `);
7627
+ }
7628
+ async down(queryRunner) {
7629
+ await queryRunner.query(`
7630
+ CREATE TABLE "CredentialClaims_old"
7631
+ (
7632
+ "id" uuid NOT NULL DEFAULT (lower(hex(randomblob(16)))),
7633
+ "key" character varying(255) NOT NULL,
7634
+ "name" character varying(255) NOT NULL,
7635
+ "credentialLocaleBrandingId" character varying,
7636
+ CONSTRAINT "PK_CredentialClaims_id" PRIMARY KEY ("id")
7637
+ )
7638
+ `);
7639
+ await queryRunner.query(`
7640
+ INSERT INTO "CredentialClaims_old" ("id", "key", "name", "credentialLocaleBrandingId")
7641
+ SELECT "id", "key", "name", "credentialLocaleBrandingId"
7642
+ FROM "CredentialClaims"
7643
+ `);
7644
+ await queryRunner.query(`DROP TABLE "CredentialClaims"`);
7645
+ await queryRunner.query(`ALTER TABLE "CredentialClaims_old" RENAME TO "CredentialClaims"`);
7646
+ await queryRunner.query(`
7647
+ CREATE UNIQUE INDEX "IDX_CredentialClaimsEntity_credentialLocaleBranding_locale"
7648
+ ON "CredentialClaims" ("credentialLocaleBrandingId", "key")
7649
+ `);
7650
+ }
7651
+ };
7652
+
7653
+ // src/migrations/generic/11-FixCredentialClaimsReferenceUuid.ts
7654
+ var debug10 = (0, import_debug10.default)("sphereon:ssi-sdk:migrations");
7655
+ var FixCredentialClaimsReferencesUuid1741895822987 = class {
7656
+ static {
7657
+ __name(this, "FixCredentialClaimsReferencesUuid1741895822987");
7658
+ }
7659
+ name = "FixCredentialClaimsReferenceUuid1741895822987";
7455
7660
  async up(queryRunner) {
7456
- debug9("migration: creating issuance branding tables");
7661
+ debug10("migration: creating issuance branding uuid problem");
7457
7662
  const dbType = queryRunner.connection.driver.options.type;
7458
7663
  switch (dbType) {
7459
7664
  case "postgres": {
7460
- debug9("using postgres migration file");
7461
- const mig = new CreateIssuanceBranding1685628974232();
7665
+ debug10("using postgres migration file");
7666
+ const mig = new FixCredentialClaimsReferencesUuidPG1741895822987();
7462
7667
  await mig.up(queryRunner);
7463
- debug9("Migration statements executed");
7668
+ debug10("Migration statements executed");
7464
7669
  return;
7465
7670
  }
7466
7671
  case "sqlite":
7467
7672
  case "expo":
7468
7673
  case "react-native": {
7469
- debug9("using sqlite/react-native migration file");
7470
- const mig = new CreateIssuanceBranding1685628973231();
7674
+ debug10("using sqlite/react-native migration file");
7675
+ const mig = new FixCredentialClaimsReferencesUuidSqlite1741895822987();
7471
7676
  await mig.up(queryRunner);
7472
- debug9("Migration statements executed");
7677
+ debug10("Migration statements executed");
7473
7678
  return;
7474
7679
  }
7475
7680
  default:
@@ -7477,23 +7682,23 @@ var CreateIssuanceBranding1659463079429 = class {
7477
7682
  }
7478
7683
  }
7479
7684
  async down(queryRunner) {
7480
- debug9("migration: reverting issuance branding tables");
7685
+ debug10("migration: reverting issuance branding uuid migration");
7481
7686
  const dbType = queryRunner.connection.driver.options.type;
7482
7687
  switch (dbType) {
7483
7688
  case "postgres": {
7484
- debug9("using postgres migration file");
7689
+ debug10("using postgres migration file");
7485
7690
  const mig = new CreateIssuanceBranding1685628974232();
7486
7691
  await mig.down(queryRunner);
7487
- debug9("Migration statements executed");
7692
+ debug10("Migration statements executed");
7488
7693
  return;
7489
7694
  }
7490
7695
  case "sqlite":
7491
7696
  case "expo":
7492
7697
  case "react-native": {
7493
- debug9("using sqlite/react-native migration file");
7698
+ debug10("using sqlite/react-native migration file");
7494
7699
  const mig = new CreateIssuanceBranding1685628973231();
7495
7700
  await mig.down(queryRunner);
7496
- debug9("Migration statements executed");
7701
+ debug10("Migration statements executed");
7497
7702
  return;
7498
7703
  }
7499
7704
  default:
@@ -7502,658 +7707,364 @@ var CreateIssuanceBranding1659463079429 = class {
7502
7707
  }
7503
7708
  };
7504
7709
 
7505
- // src/migrations/generic/3-CreateContacts.ts
7506
- var import_debug10 = __toESM(require("debug"), 1);
7710
+ // src/migrations/generic/12-CreateBitstringStatusList.ts
7711
+ var import_debug11 = __toESM(require("debug"), 1);
7507
7712
 
7508
- // src/migrations/sqlite/1690925872693-CreateContacts.ts
7509
- var CreateContacts1690925872693 = class {
7713
+ // src/migrations/postgres/1741895823000-CreateBitstringStatusList.ts
7714
+ var AddBitstringStatusListEnumPG1741895823000 = class {
7510
7715
  static {
7511
- __name(this, "CreateContacts1690925872693");
7716
+ __name(this, "AddBitstringStatusListEnumPG1741895823000");
7512
7717
  }
7513
- name = "CreateContacts1690925872693";
7718
+ name = "AddBitstringStatusListEnum1741895823000";
7514
7719
  async up(queryRunner) {
7515
- 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"))`);
7516
- await queryRunner.query(`INSERT INTO "temporary_CorrelationIdentifier"("id", "type", "correlation_id", "identityId") SELECT "id", "type", "correlation_id", "identityId" FROM "CorrelationIdentifier"`);
7517
- await queryRunner.query(`DROP TABLE "CorrelationIdentifier"`);
7518
- await queryRunner.query(`ALTER TABLE "temporary_CorrelationIdentifier" RENAME TO "CorrelationIdentifier"`);
7519
- 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"))`);
7520
- 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"`);
7521
- await queryRunner.query(`DROP TABLE "Identity"`);
7522
- await queryRunner.query(`ALTER TABLE "temporary_Identity" RENAME TO "Identity"`);
7523
- 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"))`);
7524
- await queryRunner.query(`INSERT INTO "temporary_Connection"("id", "type", "identityId") SELECT "id", "type", "identityId" FROM "Connection"`);
7525
- await queryRunner.query(`DROP TABLE "Connection"`);
7526
- await queryRunner.query(`ALTER TABLE "temporary_Connection" RENAME TO "Connection"`);
7527
- 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"))`);
7528
- await queryRunner.query(`INSERT INTO "temporary_CorrelationIdentifier"("id", "type", "correlation_id", "identity_id") SELECT "id", "type", "correlation_id", "identityId" FROM "CorrelationIdentifier"`);
7529
- await queryRunner.query(`DROP TABLE "CorrelationIdentifier"`);
7530
- await queryRunner.query(`ALTER TABLE "temporary_CorrelationIdentifier" RENAME TO "CorrelationIdentifier"`);
7531
- 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"))`);
7532
- 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"`);
7533
- await queryRunner.query(`DROP TABLE "Identity"`);
7534
- await queryRunner.query(`ALTER TABLE "temporary_Identity" RENAME TO "Identity"`);
7535
- 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"))`);
7536
- await queryRunner.query(`INSERT INTO "temporary_Connection"("id", "type", "identity_id") SELECT "id", "type", "identityId" FROM "Connection"`);
7537
- await queryRunner.query(`DROP TABLE "Connection"`);
7538
- await queryRunner.query(`ALTER TABLE "temporary_Connection" RENAME TO "Connection"`);
7539
- 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"))`);
7540
- await queryRunner.query(`CREATE UNIQUE INDEX "IDX_PartyType_type_tenant_id" ON "PartyType" ("type", "tenant_id")`);
7541
- 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"))`);
7542
- await queryRunner.query(`CREATE INDEX "IDX_BaseContact_type" ON "BaseContact" ("type")`);
7543
- 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')))`);
7544
- await queryRunner.query(`CREATE UNIQUE INDEX "IDX_PartyRelationship_left_right" ON "PartyRelationship" ("left_id", "right_id")`);
7545
- 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)`);
7546
- 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"))`);
7547
- await queryRunner.query(`CREATE INDEX "IDX_BaseConfig_type" ON "BaseConfig" ("type")`);
7548
- 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)`);
7549
- await queryRunner.query(`INSERT INTO "temporary_CorrelationIdentifier"("id", "type", "correlation_id", "identity_id") SELECT "id", "type", "correlation_id", "identity_id" FROM "CorrelationIdentifier"`);
7550
- await queryRunner.query(`DROP TABLE "CorrelationIdentifier"`);
7551
- await queryRunner.query(`ALTER TABLE "temporary_CorrelationIdentifier" RENAME TO "CorrelationIdentifier"`);
7552
- await queryRunner.query(`DROP INDEX "IDX_BaseContact_type"`);
7553
- 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)`);
7554
- 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"`);
7555
- await queryRunner.query(`DROP TABLE "BaseContact"`);
7556
- await queryRunner.query(`ALTER TABLE "temporary_BaseContact" RENAME TO "BaseContact"`);
7557
- await queryRunner.query(`CREATE INDEX "IDX_BaseContact_type" ON "BaseContact" ("type")`);
7558
- await queryRunner.query(`DROP INDEX "IDX_PartyRelationship_left_right"`);
7559
- 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)`);
7560
- 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"`);
7561
- await queryRunner.query(`DROP TABLE "PartyRelationship"`);
7562
- await queryRunner.query(`ALTER TABLE "temporary_PartyRelationship" RENAME TO "PartyRelationship"`);
7563
- await queryRunner.query(`CREATE UNIQUE INDEX "IDX_PartyRelationship_left_right" ON "PartyRelationship" ("left_id", "right_id")`);
7564
- 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)`);
7565
- 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)`);
7566
- 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)`);
7567
- 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"`);
7568
- await queryRunner.query(`DROP TABLE "Party"`);
7569
- await queryRunner.query(`ALTER TABLE "temporary_Party" RENAME TO "Party"`);
7570
- 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)`);
7571
- 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"`);
7572
- await queryRunner.query(`DROP TABLE "Identity"`);
7573
- await queryRunner.query(`ALTER TABLE "temporary_Identity" RENAME TO "Identity"`);
7574
- 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)`);
7575
- await queryRunner.query(`INSERT INTO "temporary_Connection"("id", "type", "identity_id") SELECT "id", "type", "identity_id" FROM "Connection"`);
7576
- await queryRunner.query(`DROP TABLE "Connection"`);
7577
- await queryRunner.query(`ALTER TABLE "temporary_Connection" RENAME TO "Connection"`);
7578
- await queryRunner.query(`DROP INDEX "IDX_BaseConfig_type"`);
7579
- 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)`);
7580
- 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"`);
7581
- await queryRunner.query(`DROP TABLE "BaseConfig"`);
7582
- await queryRunner.query(`ALTER TABLE "temporary_BaseConfig" RENAME TO "BaseConfig"`);
7583
- await queryRunner.query(`CREATE INDEX "IDX_BaseConfig_type" ON "BaseConfig" ("type")`);
7584
- 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"`);
7585
- await queryRunner.query(`DROP TABLE "BaseConfigEntity"`);
7586
- 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'))`);
7587
- 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'))`);
7588
- 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"`);
7589
- 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"`);
7590
- await queryRunner.query(`DROP TABLE "Contact"`);
7591
- }
7592
- async down(queryRunner) {
7593
- 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))`);
7594
- 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'`);
7595
- await queryRunner.query(`DROP TABLE "BaseContact"`);
7596
- await queryRunner.query(`DROP TABLE "Party"`);
7597
- 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)`);
7598
- 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"`);
7599
- await queryRunner.query(`DROP TABLE "BaseConfig"`);
7600
- 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)`);
7601
- 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"`);
7602
- await queryRunner.query(`DROP TABLE "Party"`);
7603
- await queryRunner.query(`ALTER TABLE "temporary_Party" RENAME TO "Party"`);
7604
- await queryRunner.query(`DROP INDEX "IDX_PartyRelationship_left_right"`);
7605
- 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)`);
7606
- 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"`);
7607
- await queryRunner.query(`DROP TABLE "PartyRelationship"`);
7608
- await queryRunner.query(`ALTER TABLE "temporary_PartyRelationship" RENAME TO "PartyRelationship"`);
7609
- await queryRunner.query(`CREATE UNIQUE INDEX "IDX_PartyRelationship_left_right" ON "PartyRelationship" ("left_id", "right_id")`);
7610
- await queryRunner.query(`DROP INDEX "IDX_BaseContact_type"`);
7611
- 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)`);
7612
- 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"`);
7613
- await queryRunner.query(`DROP TABLE "BaseContact"`);
7614
- await queryRunner.query(`ALTER TABLE "temporary_BaseContact" RENAME TO "BaseContact"`);
7615
- await queryRunner.query(`CREATE INDEX "IDX_BaseContact_type" ON "BaseContact" ("type")`);
7616
- await queryRunner.query(`DROP INDEX "IDX_BaseConfig_type"`);
7617
- 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)`);
7618
- 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"`);
7619
- await queryRunner.query(`DROP TABLE "BaseConfig"`);
7620
- await queryRunner.query(`ALTER TABLE "temporary_BaseConfig" RENAME TO "BaseConfig"`);
7621
- await queryRunner.query(`CREATE INDEX "IDX_BaseConfig_type" ON "BaseConfig" ("type")`);
7622
- await queryRunner.query(`DROP INDEX "IDX_PartyType_type_tenant_id"`);
7623
- await queryRunner.query(`DROP TABLE "PartyType"`);
7624
- await queryRunner.query(`DROP TABLE "Connection"`);
7625
- await queryRunner.query(`DROP TABLE "Identity"`);
7626
- await queryRunner.query(`DROP TABLE "CorrelationIdentifier"`);
7627
- await queryRunner.query(`DROP TABLE "ElectronicAddress"`);
7628
- await queryRunner.query(`DROP TABLE "PhysicalAddress"`);
7629
- }
7630
- };
7631
-
7632
- // src/migrations/postgres/1690925872592-CreateContacts.ts
7633
- var import_ssi_sdk22 = require("@sphereon/ssi-sdk.core");
7634
- var CreateContacts1690925872592 = class {
7635
- static {
7636
- __name(this, "CreateContacts1690925872592");
7637
- }
7638
- name = "CreateContacts1690925872592";
7639
- async up(queryRunner) {
7640
- await (0, import_ssi_sdk22.enablePostgresUuidExtension)(queryRunner);
7641
- await queryRunner.query(`ALTER TABLE "CorrelationIdentifier" DROP CONSTRAINT "FK_CorrelationIdentifier_identityId"`);
7642
- await queryRunner.query(`ALTER TABLE "IdentityMetadata" DROP CONSTRAINT "FK_IdentityMetadata_identityId"`);
7643
- await queryRunner.query(`ALTER TABLE "Identity" DROP CONSTRAINT "FK_Identity_contactId"`);
7644
- await queryRunner.query(`ALTER TABLE "Connection" DROP CONSTRAINT "FK_Connection_identityId"`);
7645
- await queryRunner.query(`ALTER TABLE "CorrelationIdentifier" RENAME COLUMN "identityId" TO "identity_id"`);
7646
- await queryRunner.query(`ALTER TABLE "Connection" RENAME COLUMN "identityId" TO "identity_id"`);
7647
- await queryRunner.query(`CREATE TYPE "public"."PartyType_type_enum" AS ENUM('naturalPerson', 'organization')`);
7648
- await queryRunner.query(`CREATE TYPE "public"."PartyOrigin_type_enum" AS ENUM('INTERNAL', 'EXTERNAL')`);
7649
- 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"))`);
7650
- await queryRunner.query(`CREATE UNIQUE INDEX "IDX_PartyType_type_tenant_id" ON "PartyType" ("type", "tenant_id")`);
7651
- 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"))`);
7652
- await queryRunner.query(`CREATE INDEX "IDX_BaseContact_type" ON "BaseContact" ("type")`);
7653
- 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"))`);
7654
- await queryRunner.query(`CREATE UNIQUE INDEX "IDX_PartyRelationship_left_right" ON "PartyRelationship" ("left_id", "right_id")`);
7655
- 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"))`);
7656
- 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"))`);
7657
- 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"))`);
7658
- 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"))`);
7659
- await queryRunner.query(`CREATE INDEX "IDX_BaseConfig_type" ON "BaseConfig" ("type")`);
7660
- await queryRunner.query(`ALTER TABLE "Identity" RENAME COLUMN "contactId" TO "partyId"`);
7661
- await queryRunner.query(`ALTER TABLE "Identity" ALTER COLUMN "roles" SET NOT NULL`);
7662
- await queryRunner.query(`CREATE TYPE "public"."IdentityOrigin_type_enum" AS ENUM('INTERNAL', 'EXTERNAL')`);
7663
- await queryRunner.query(`ALTER TABLE "Identity" ADD COLUMN "origin" "public"."IdentityOrigin_type_enum" DEFAULT 'EXTERNAL' NOT NULL`);
7664
- await queryRunner.query(`ALTER TABLE "Identity" ALTER COLUMN "origin" DROP DEFAULT`);
7665
- 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`);
7666
- await queryRunner.query(`ALTER TABLE "IdentityMetadata" ADD CONSTRAINT "FK_IdentityMetadata_identityId" FOREIGN KEY ("identityId") REFERENCES "Identity"("id") ON DELETE CASCADE ON UPDATE NO ACTION`);
7667
- 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`);
7668
- 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`);
7669
- 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`);
7670
- await queryRunner.query(`ALTER TABLE "ElectronicAddress" ADD CONSTRAINT "FK_ElectronicAddress_partyId" FOREIGN KEY ("partyId") REFERENCES "Party"("id") ON DELETE CASCADE ON UPDATE NO ACTION`);
7671
- await queryRunner.query(`ALTER TABLE "PhysicalAddress" ADD CONSTRAINT "FK_PhysicalAddress_partyId" FOREIGN KEY ("partyId") REFERENCES "Party" ("id") ON DELETE CASCADE ON UPDATE NO ACTION`);
7672
- 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`);
7673
- await queryRunner.query(`ALTER TABLE "Identity" ADD CONSTRAINT "FK_Identity_partyId" FOREIGN KEY ("partyId") REFERENCES "Party"("id") ON DELETE CASCADE ON UPDATE NO ACTION`);
7674
- 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`);
7675
- 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`);
7676
- await queryRunner.query(`ALTER TABLE "CorrelationIdentifier" RENAME CONSTRAINT "UQ_Correlation_id" TO "UQ_CorrelationIdentifier_correlation_id"`);
7677
- await queryRunner.query(`ALTER TABLE "Identity" RENAME CONSTRAINT "UQ_Identity_Alias" TO "UQ_Identity_alias"`);
7678
- 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"`);
7679
- await queryRunner.query(`DROP TABLE "BaseConfigEntity"`);
7680
- 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())`);
7681
- 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())`);
7682
- 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"`);
7683
- 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"`);
7684
- await queryRunner.query(`DROP TABLE "Contact"`);
7685
- }
7686
- async down(queryRunner) {
7687
- await queryRunner.query(`ALTER TABLE "BaseConfig" DROP CONSTRAINT "FK_BaseConfig_connection_id"`);
7688
- await queryRunner.query(`ALTER TABLE "Connection" DROP CONSTRAINT "FK_Connection_identity_id"`);
7689
- await queryRunner.query(`ALTER TABLE "Identity" DROP CONSTRAINT "FK_Identity_partyId"`);
7690
- await queryRunner.query(`ALTER TABLE "Party" DROP CONSTRAINT "FK_Party_party_type_id"`);
7691
- await queryRunner.query(`ALTER TABLE "PhysicalAddress" DROP CONSTRAINT "FK_PhysicalAddress_partyId"`);
7692
- await queryRunner.query(`ALTER TABLE "ElectronicAddress" DROP CONSTRAINT "FK_ElectronicAddress_partyId"`);
7693
- await queryRunner.query(`ALTER TABLE "PartyRelationship" DROP CONSTRAINT "FK_PartyRelationship_right_id"`);
7694
- await queryRunner.query(`ALTER TABLE "PartyRelationship" DROP CONSTRAINT "FK_PartyRelationship_left_id"`);
7695
- await queryRunner.query(`ALTER TABLE "BaseContact" DROP CONSTRAINT "FK_BaseContact_party_id"`);
7696
- await queryRunner.query(`ALTER TABLE "IdentityMetadata" DROP CONSTRAINT "FK_IdentityMetadata_identityId"`);
7697
- await queryRunner.query(`ALTER TABLE "CorrelationIdentifier" DROP CONSTRAINT "FK_CorrelationIdentifier_identity_id"`);
7698
- await queryRunner.query(`ALTER TABLE "Identity" ALTER COLUMN "roles" DROP NOT NULL`);
7699
- await queryRunner.query(`ALTER TABLE "Identity" DROP COLUMN "origin"`);
7700
- await queryRunner.query(`DROP TYPE "public"."IdentityOrigin_type_enum"`);
7701
- await queryRunner.query(`ALTER TABLE "Identity" RENAME COLUMN "partyId" TO "contactId"`);
7702
- await queryRunner.query(`ALTER TABLE "Connection" RENAME COLUMN "identity_id" TO "identityId"`);
7703
- await queryRunner.query(`ALTER TABLE "CorrelationIdentifier" RENAME COLUMN "identity_id" TO "identityId"`);
7704
- await queryRunner.query(`DROP INDEX "IDX_BaseConfig_type"`);
7705
- await queryRunner.query(`DROP TABLE "BaseConfig"`);
7706
- await queryRunner.query(`DROP TABLE "Party"`);
7707
- await queryRunner.query(`DROP INDEX "IDX_PartyRelationship_left_right"`);
7708
- await queryRunner.query(`DROP TABLE "PartyRelationship"`);
7709
- await queryRunner.query(`DROP INDEX "IDX_BaseContact_type"`);
7710
- await queryRunner.query(`DROP TABLE "BaseContact"`);
7711
- await queryRunner.query(`DROP TABLE "ElectronicAddress"`);
7712
- await queryRunner.query(`DROP TABLE "PhysicalAddress"`);
7713
- await queryRunner.query(`DROP INDEX "IDX_PartyType_type_tenant_id"`);
7714
- await queryRunner.query(`DROP TABLE "PartyType"`);
7715
- await queryRunner.query(`DROP TYPE "public"."PartyOrigin_type_enum"`);
7716
- await queryRunner.query(`DROP TYPE "public"."PartyType_type_enum"`);
7717
- await queryRunner.query(`ALTER TABLE "Connection" ADD CONSTRAINT "FK_Connection_identityId" FOREIGN KEY ("identityId") REFERENCES "Identity"("id") ON DELETE CASCADE ON UPDATE NO ACTION`);
7718
- await queryRunner.query(`ALTER TABLE "Identity" ADD CONSTRAINT "FK_Identity_contactId" FOREIGN KEY ("contactId") REFERENCES "Contact"("id") ON DELETE CASCADE ON UPDATE NO ACTION`);
7719
- await queryRunner.query(`ALTER TABLE "IdentityMetadata" ADD CONSTRAINT "FK_IdentityMetadata_identityId" FOREIGN KEY ("identityId") REFERENCES "Identity"("id") ON DELETE CASCADE ON UPDATE NO ACTION`);
7720
- await queryRunner.query(`ALTER TABLE "CorrelationIdentifier" ADD CONSTRAINT "FK_CorrelationIdentifier_identityId" FOREIGN KEY ("identityId") REFERENCES "Identity"("id") ON DELETE CASCADE ON UPDATE NO ACTION`);
7721
- 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"))`);
7722
- 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'`);
7723
- }
7724
- };
7725
-
7726
- // src/migrations/generic/3-CreateContacts.ts
7727
- var debug10 = (0, import_debug10.default)("sphereon:ssi-sdk:migrations");
7728
- var CreateContacts1690925872318 = class {
7729
- static {
7730
- __name(this, "CreateContacts1690925872318");
7731
- }
7732
- name = "CreateContacts1690925872318";
7733
- async up(queryRunner) {
7734
- debug10("migration: creating contacts tables");
7735
- const dbType = queryRunner.connection.driver.options.type;
7736
- switch (dbType) {
7737
- case "postgres": {
7738
- debug10("using postgres migration file");
7739
- const mig = new CreateContacts1690925872592();
7740
- await mig.up(queryRunner);
7741
- debug10("Migration statements executed");
7742
- return;
7743
- }
7744
- case "sqlite":
7745
- case "expo":
7746
- case "react-native": {
7747
- debug10("using sqlite/react-native migration file");
7748
- const mig = new CreateContacts1690925872693();
7749
- await mig.up(queryRunner);
7750
- debug10("Migration statements executed");
7751
- return;
7752
- }
7753
- default:
7754
- 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`);
7755
- }
7756
- }
7757
- async down(queryRunner) {
7758
- debug10("migration: reverting contacts tables");
7759
- const dbType = queryRunner.connection.driver.options.type;
7760
- switch (dbType) {
7761
- case "postgres": {
7762
- debug10("using postgres migration file");
7763
- const mig = new CreateContacts1690925872592();
7764
- await mig.down(queryRunner);
7765
- debug10("Migration statements executed");
7766
- return;
7767
- }
7768
- case "sqlite":
7769
- case "expo":
7770
- case "react-native": {
7771
- debug10("using sqlite/react-native migration file");
7772
- const mig = new CreateContacts1690925872693();
7773
- await mig.down(queryRunner);
7774
- debug10("Migration statements executed");
7775
- return;
7776
- }
7777
- default:
7778
- 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`);
7779
- }
7780
- }
7781
- };
7782
-
7783
- // src/migrations/generic/4-CreateStatusList.ts
7784
- var import_debug11 = __toESM(require("debug"), 1);
7785
-
7786
- // src/migrations/postgres/1693866470001-CreateStatusList.ts
7787
- var CreateStatusList1693866470001 = class {
7788
- static {
7789
- __name(this, "CreateStatusList1693866470001");
7790
- }
7791
- name = "CreateStatusList1693866470001";
7792
- async up(queryRunner) {
7793
- await queryRunner.query(`CREATE TYPE "StatusList_type_enum" AS ENUM('StatusList2021')`);
7794
- await queryRunner.query(`CREATE TYPE "StatusList_drivertype_enum" AS ENUM('agent_typeorm', 'agent_kv_store', 'github', 'agent_filesystem')`);
7795
- await queryRunner.query(`CREATE TYPE "StatusList_credentialidmode_enum" AS ENUM('ISSUANCE', 'PERSISTENCE', 'NEVER')`);
7796
- await queryRunner.query(`CREATE TABLE "StatusListEntry"
7797
- (
7798
- "statusListId" character varying NOT NULL,
7799
- "statusListIndex" integer NOT NULL,
7800
- "credentialId" character varying,
7801
- "credentialHash" character varying(128),
7802
- "correlationId" character varying(255),
7803
- "value" character varying(50),
7804
- CONSTRAINT "PK_68704d2d13857360c6b44a3d1d0" PRIMARY KEY ("statusListId", "statusListIndex")
7805
- )`);
7806
- await queryRunner.query(`CREATE TABLE "StatusList"
7807
- (
7808
- "id" character varying NOT NULL,
7809
- "correlationId" character varying NOT NULL,
7810
- "length" integer NOT NULL,
7811
- "issuer" text NOT NULL,
7812
- "type" "StatusList_type_enum" NOT NULL DEFAULT 'StatusList2021',
7813
- "driverType" "StatusList_drivertype_enum" NOT NULL DEFAULT 'agent_typeorm',
7814
- "credentialIdMode" "StatusList_credentialidmode_enum" NOT NULL DEFAULT 'ISSUANCE',
7815
- "proofFormat" character varying NOT NULL DEFAULT 'lds',
7816
- "indexingDirection" character varying NOT NULL DEFAULT 'rightToLeft',
7817
- "statusPurpose" character varying NOT NULL DEFAULT 'revocation',
7818
- "statusListCredential" text,
7819
- CONSTRAINT "UQ_correlationId" UNIQUE ("correlationId"),
7820
- CONSTRAINT "PK_StatusList_Id" PRIMARY KEY ("id")
7821
- )`);
7822
- await queryRunner.query(`ALTER TABLE "StatusListEntry"
7823
- ADD CONSTRAINT "FK_statusListEntry_statusListId" FOREIGN KEY ("statusListId") REFERENCES "StatusList" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION`);
7824
- }
7825
- async down(queryRunner) {
7826
- await queryRunner.query(`ALTER TABLE "StatusListEntry"
7827
- DROP CONSTRAINT "FK_statusListEntry_statusListId"`);
7828
- await queryRunner.query(`DROP TABLE "StatusListEntry"`);
7829
- await queryRunner.query(`DROP TABLE "StatusList"`);
7830
- await queryRunner.query(`DROP TYPE "StatusList_credentialidmode_enum"`);
7831
- await queryRunner.query(`DROP TYPE "StatusList_drivertype_enum"`);
7832
- await queryRunner.query(`DROP TYPE "StatusList_type_enum"`);
7833
- }
7834
- };
7835
-
7836
- // src/migrations/sqlite/1693866470000-CreateStatusList.ts
7837
- var CreateStatusList1693866470002 = class {
7838
- static {
7839
- __name(this, "CreateStatusList1693866470002");
7840
- }
7841
- name = "CreateStatusList1693866470002";
7842
- async up(queryRunner) {
7843
- await queryRunner.query(`CREATE TABLE "StatusListEntry"
7844
- (
7845
- "statusListId" varchar NOT NULL,
7846
- "statusListIndex" integer NOT NULL,
7847
- "credentialId" varchar,
7848
- "credentialHash" varchar(128),
7849
- "correlationId" varchar(255),
7850
- "value" varchar(50),
7851
- PRIMARY KEY ("statusListId", "statusListIndex")
7852
- )`);
7853
- await queryRunner.query(`CREATE TABLE "StatusList"
7854
- (
7855
- "id" varchar PRIMARY KEY NOT NULL,
7856
- "correlationId" varchar NOT NULL,
7857
- "length" integer NOT NULL,
7858
- "issuer" text NOT NULL,
7859
- "type" varchar CHECK ( "type" IN ('StatusList2021') ) NOT NULL DEFAULT ('StatusList2021'),
7860
- "driverType" varchar CHECK ( "driverType" IN ('agent_typeorm', 'agent_kv_store', 'github',
7861
- 'agent_filesystem') ) NOT NULL DEFAULT ('agent_typeorm'),
7862
- "credentialIdMode" varchar CHECK ( "credentialIdMode" IN ('ISSUANCE', 'PERSISTENCE', 'NEVER') ) NOT NULL DEFAULT ('ISSUANCE'),
7863
- "proofFormat" varchar CHECK ( "proofFormat" IN ('lds', 'jwt') ) NOT NULL DEFAULT ('lds'),
7864
- "indexingDirection" varchar CHECK ( "indexingDirection" IN ('rightToLeft') ) NOT NULL DEFAULT ('rightToLeft'),
7865
- "statusPurpose" varchar NOT NULL DEFAULT ('revocation'),
7866
- "statusListCredential" text,
7867
- CONSTRAINT "UQ_correlationId" UNIQUE ("correlationId")
7868
- )`);
7869
- await queryRunner.query(`CREATE TABLE "temporary_StatusListEntry"
7870
- (
7871
- "statusListId" varchar NOT NULL,
7872
- "statusListIndex" integer NOT NULL,
7873
- "credentialId" varchar,
7874
- "credentialHash" varchar(128),
7875
- "correlationId" varchar(255),
7876
- "value" varchar(50),
7877
- CONSTRAINT "FK_statusListEntry_statusListId" FOREIGN KEY ("statusListId") REFERENCES "StatusList" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION,
7878
- PRIMARY KEY ("statusListId", "statusListIndex")
7879
- )`);
7880
- await queryRunner.query(`INSERT INTO "temporary_StatusListEntry"("statusListId", "statusListIndex", "credentialId",
7881
- "credentialHash", "correlationId", "value")
7882
- SELECT "statusListId", "statusListIndex", "credentialId", "credentialHash", "correlationId", "value"
7883
- FROM "StatusListEntry"`);
7884
- await queryRunner.query(`DROP TABLE "StatusListEntry"`);
7885
- await queryRunner.query(`ALTER TABLE "temporary_StatusListEntry" RENAME TO "StatusListEntry"`);
7720
+ await queryRunner.startTransaction();
7721
+ await queryRunner.query(`ALTER TYPE "StatusList_type_enum" ADD VALUE 'BitstringStatusList'`);
7722
+ await queryRunner.commitTransaction();
7886
7723
  }
7724
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
7887
7725
  async down(queryRunner) {
7888
- await queryRunner.query(`DROP TABLE "StatusListEntry"`);
7889
- await queryRunner.query(`DROP TABLE "StatusList"`);
7890
7726
  }
7891
7727
  };
7892
-
7893
- // src/migrations/postgres/1737110469001-UpdateStatusList.ts
7894
- var UpdateStatusList1737110469001 = class {
7728
+ var CreateBitstringStatusListPG1741895823000 = class {
7895
7729
  static {
7896
- __name(this, "UpdateStatusList1737110469001");
7730
+ __name(this, "CreateBitstringStatusListPG1741895823000");
7897
7731
  }
7898
- name = "UpdateStatusList1737110469001";
7732
+ name = "CreateBitstringStatusList1741895823000";
7899
7733
  async up(queryRunner) {
7900
- await queryRunner.query(`ALTER TYPE "StatusList_type_enum" ADD VALUE 'OAuthStatusList'`);
7901
- await queryRunner.query(`ALTER TABLE "StatusList" ALTER COLUMN "indexingDirection" DROP NOT NULL`);
7902
- await queryRunner.query(`ALTER TABLE "StatusList" ALTER COLUMN "statusPurpose" DROP NOT NULL`);
7903
- await queryRunner.query(`ALTER TABLE "StatusList" ADD "bitsPerStatus" integer`);
7904
- await queryRunner.query(`ALTER TABLE "StatusList" ADD "expiresAt" timestamp with time zone`);
7734
+ await queryRunner.query(`ALTER TABLE "StatusList" ADD COLUMN "ttl" integer`);
7735
+ await queryRunner.query(`ALTER TABLE "StatusList" ADD COLUMN "validFrom" TIMESTAMP`);
7736
+ await queryRunner.query(`ALTER TABLE "StatusList" ADD COLUMN "validUntil" TIMESTAMP`);
7737
+ await queryRunner.query(`ALTER TABLE "StatusList" DROP CONSTRAINT IF EXISTS "CHK_StatusList_type"`);
7738
+ await queryRunner.query(`ALTER TABLE "StatusList" ADD CONSTRAINT "CHK_StatusList_type" CHECK ("type" IN ('StatusList2021', 'OAuthStatusList', 'BitstringStatusList'))`);
7739
+ await queryRunner.query(`ALTER TABLE "StatusListEntry" ADD COLUMN "type" character varying NOT NULL DEFAULT 'StatusListEntryEntity'`);
7740
+ await queryRunner.query(`ALTER TABLE "StatusListEntry" ADD COLUMN "statusPurpose" character varying`);
7741
+ await queryRunner.query(`ALTER TABLE "StatusListEntry" ADD COLUMN "statusMessage" text`);
7742
+ await queryRunner.query(`ALTER TABLE "StatusListEntry" ADD COLUMN "statusReference" text`);
7743
+ await queryRunner.query(`ALTER TABLE "StatusListEntry" ADD CONSTRAINT "CHK_StatusListEntry_type" CHECK ("type" IN ('StatusListEntryEntity', 'bitstring'))`);
7905
7744
  }
7906
7745
  async down(queryRunner) {
7907
- await queryRunner.query(`ALTER TABLE "StatusList" DROP COLUMN "expiresAt"`);
7746
+ await queryRunner.query(`ALTER TABLE "StatusListEntry" DROP CONSTRAINT "CHK_StatusListEntry_type"`);
7747
+ await queryRunner.query(`ALTER TABLE "StatusListEntry" DROP COLUMN "statusReference"`);
7748
+ await queryRunner.query(`ALTER TABLE "StatusListEntry" DROP COLUMN "statusMessage"`);
7749
+ await queryRunner.query(`ALTER TABLE "StatusListEntry" DROP COLUMN "bitsPerStatus"`);
7750
+ await queryRunner.query(`ALTER TABLE "StatusListEntry" DROP COLUMN "statusPurpose"`);
7751
+ await queryRunner.query(`ALTER TABLE "StatusListEntry" DROP COLUMN "type"`);
7752
+ await queryRunner.query(`ALTER TABLE "StatusList" DROP CONSTRAINT "CHK_StatusList_type"`);
7753
+ await queryRunner.query(`ALTER TABLE "StatusList" ADD CONSTRAINT "CHK_StatusList_type" CHECK ("type" IN ('StatusList2021', 'OAuthStatusList'))`);
7754
+ await queryRunner.query(`ALTER TABLE "StatusList" DROP COLUMN "validUntil"`);
7755
+ await queryRunner.query(`ALTER TABLE "StatusList" DROP COLUMN "validFrom"`);
7756
+ await queryRunner.query(`ALTER TABLE "StatusList" DROP COLUMN "ttl"`);
7908
7757
  await queryRunner.query(`ALTER TABLE "StatusList" DROP COLUMN "bitsPerStatus"`);
7909
- await queryRunner.query(`ALTER TABLE "StatusList" ALTER COLUMN "statusPurpose" SET NOT NULL`);
7910
- await queryRunner.query(`ALTER TABLE "StatusList" ALTER COLUMN "indexingDirection" SET NOT NULL`);
7911
7758
  }
7912
7759
  };
7913
7760
 
7914
- // src/migrations/sqlite/1737110469000-UpdateStatusList.ts
7915
- var UpdateStatusList1737110469000 = class {
7761
+ // src/migrations/sqlite/1741895823001-CreateBitstringStatusList.ts
7762
+ var CreateBitstringStatusListSqlite1741895823001 = class {
7916
7763
  static {
7917
- __name(this, "UpdateStatusList1737110469000");
7764
+ __name(this, "CreateBitstringStatusListSqlite1741895823001");
7918
7765
  }
7919
- name = "UpdateStatusList1737110469000";
7766
+ name = "CreateBitstringStatusList1741895823000";
7920
7767
  async up(queryRunner) {
7921
- await queryRunner.query(`CREATE TABLE "temporary_StatusList" (
7922
- "id" varchar PRIMARY KEY NOT NULL,
7923
- "correlationId" varchar NOT NULL,
7924
- "length" integer NOT NULL,
7925
- "issuer" text NOT NULL,
7926
- "type" varchar CHECK( "type" IN ('StatusList2021', 'OAuthStatusList') ) NOT NULL DEFAULT ('StatusList2021'),
7927
- "driverType" varchar CHECK( "driverType" IN ('agent_typeorm','agent_kv_store','github','agent_filesystem') ) NOT NULL DEFAULT ('agent_typeorm'),
7928
- "credentialIdMode" varchar CHECK( "credentialIdMode" IN ('ISSUANCE','PERSISTENCE','NEVER') ) NOT NULL DEFAULT ('ISSUANCE'),
7929
- "proofFormat" varchar CHECK( "proofFormat" IN ('lds','jwt') ) NOT NULL DEFAULT ('lds'),
7930
- "indexingDirection" varchar CHECK( "indexingDirection" IN ('rightToLeft') ),
7931
- "statusPurpose" varchar,
7932
- "statusListCredential" text,
7933
- "bitsPerStatus" integer,
7934
- "expiresAt" datetime,
7935
- CONSTRAINT "UQ_correlationId" UNIQUE ("correlationId")
7936
- )`);
7937
- await queryRunner.query(`INSERT INTO "temporary_StatusList"(
7938
- "id", "correlationId", "length", "issuer", "type", "driverType",
7939
- "credentialIdMode", "proofFormat", "indexingDirection", "statusPurpose",
7940
- "statusListCredential"
7941
- )
7942
- SELECT
7943
- "id", "correlationId", "length", "issuer", "type", "driverType",
7944
- "credentialIdMode", "proofFormat", "indexingDirection", "statusPurpose",
7945
- "statusListCredential"
7946
- FROM "StatusList"`);
7768
+ await queryRunner.query(`
7769
+ CREATE TABLE "temporary_StatusList" (
7770
+ "id" varchar PRIMARY KEY NOT NULL,
7771
+ "correlationId" varchar NOT NULL,
7772
+ "length" integer NOT NULL,
7773
+ "issuer" text NOT NULL,
7774
+ "type" varchar CHECK( "type" IN ('StatusList2021', 'OAuthStatusList', 'BitstringStatusList') ) NOT NULL DEFAULT ('StatusList2021'),
7775
+ "driverType" varchar CHECK( "driverType" IN ('agent_typeorm','agent_kv_store','github','agent_filesystem') ) NOT NULL DEFAULT ('agent_typeorm'),
7776
+ "credentialIdMode" varchar CHECK( "credentialIdMode" IN ('ISSUANCE','PERSISTENCE','NEVER') ) NOT NULL DEFAULT ('ISSUANCE'),
7777
+ "proofFormat" varchar CHECK( "proofFormat" IN ('lds','jwt', 'vc+jwt') ) NOT NULL DEFAULT ('lds'),
7778
+ "indexingDirection" varchar CHECK( "indexingDirection" IN ('rightToLeft') ),
7779
+ "statusPurpose" varchar,
7780
+ "statusListCredential" text,
7781
+ "expiresAt" datetime,
7782
+ "bitsPerStatus" integer DEFAULT (1),
7783
+ "ttl" integer,
7784
+ "validFrom" datetime,
7785
+ "validUntil" datetime,
7786
+ CONSTRAINT "UQ_correlationId" UNIQUE ("correlationId")
7787
+ )
7788
+ `);
7789
+ await queryRunner.query(`
7790
+ INSERT INTO "temporary_StatusList"(
7791
+ "id", "correlationId", "length", "issuer", "type", "driverType",
7792
+ "credentialIdMode", "proofFormat", "indexingDirection", "statusPurpose",
7793
+ "statusListCredential", "bitsPerStatus", "expiresAt"
7794
+ )
7795
+ SELECT
7796
+ "id", "correlationId", "length", "issuer", "type", "driverType",
7797
+ "credentialIdMode", "proofFormat", "indexingDirection", "statusPurpose",
7798
+ "statusListCredential", "bitsPerStatus", "expiresAt"
7799
+ FROM "StatusList"
7800
+ `);
7947
7801
  await queryRunner.query(`DROP TABLE "StatusList"`);
7948
7802
  await queryRunner.query(`ALTER TABLE "temporary_StatusList" RENAME TO "StatusList"`);
7803
+ await queryRunner.query(`
7804
+ CREATE TABLE "temporary_StatusListEntry" (
7805
+ "statusListId" varchar NOT NULL,
7806
+ "statusListIndex" integer NOT NULL,
7807
+ "credentialId" text,
7808
+ "credentialHash" varchar(128),
7809
+ "correlationId" varchar(255),
7810
+ "value" varchar(50),
7811
+ "type" varchar CHECK( "type" IN ('StatusListEntryEntity', 'bitstring') ) NOT NULL DEFAULT ('StatusListEntryEntity'),
7812
+ "statusPurpose" varchar,
7813
+ "bitsPerStatus" integer DEFAULT (1),
7814
+ "statusMessage" text,
7815
+ "statusReference" text,
7816
+ PRIMARY KEY ("statusListId", "statusListIndex")
7817
+ )
7818
+ `);
7819
+ await queryRunner.query(`
7820
+ INSERT INTO "temporary_StatusListEntry"(
7821
+ "statusListId", "statusListIndex", "credentialId", "credentialHash",
7822
+ "correlationId", "value", "type"
7823
+ )
7824
+ SELECT
7825
+ "statusListId", "statusListIndex", "credentialId", "credentialHash",
7826
+ "correlationId", "value", 'StatusListEntryEntity'
7827
+ FROM "StatusListEntry"
7828
+ `);
7829
+ await queryRunner.query(`DROP TABLE "StatusListEntry"`);
7830
+ await queryRunner.query(`ALTER TABLE "temporary_StatusListEntry" RENAME TO "StatusListEntry"`);
7949
7831
  }
7950
7832
  async down(queryRunner) {
7951
7833
  await queryRunner.query(`
7952
- ALTER TABLE "StatusListEntry"
7953
- RENAME COLUMN "entryCorrelationId" TO "correlationId"
7954
- `);
7834
+ CREATE TABLE "temporary_StatusListEntry" (
7835
+ "statusListId" varchar NOT NULL,
7836
+ "statusListIndex" integer NOT NULL,
7837
+ "credentialId" text,
7838
+ "credentialHash" varchar(128),
7839
+ "correlationId" varchar(255),
7840
+ "value" varchar(50),
7841
+ PRIMARY KEY ("statusListId", "statusListIndex")
7842
+ )
7843
+ `);
7955
7844
  await queryRunner.query(`
7956
- ALTER TABLE "StatusListEntry"
7957
- DROP COLUMN "statusListCorrelationId"
7958
- `);
7959
- await queryRunner.query(`CREATE TABLE "temporary_StatusList" (
7960
- "id" varchar PRIMARY KEY NOT NULL,
7961
- "correlationId" varchar NOT NULL,
7962
- "length" integer NOT NULL,
7963
- "issuer" text NOT NULL,
7964
- "type" varchar CHECK( "type" IN ('StatusList2021') ) NOT NULL DEFAULT ('StatusList2021'),
7965
- "driverType" varchar CHECK( "driverType" IN ('agent_typeorm','agent_kv_store','github','agent_filesystem') ) NOT NULL DEFAULT ('agent_typeorm'),
7966
- "credentialIdMode" varchar CHECK( "credentialIdMode" IN ('ISSUANCE','PERSISTENCE','NEVER') ) NOT NULL DEFAULT ('ISSUANCE'),
7967
- "proofFormat" varchar CHECK( "proofFormat" IN ('lds','jwt') ) NOT NULL DEFAULT ('lds'),
7968
- "indexingDirection" varchar CHECK( "indexingDirection" IN ('rightToLeft') ) NOT NULL DEFAULT ('rightToLeft'),
7969
- "statusPurpose" varchar NOT NULL DEFAULT ('revocation'),
7970
- "statusListCredential" text,
7971
- CONSTRAINT "UQ_correlationId" UNIQUE ("correlationId")
7972
- )`);
7973
- await queryRunner.query(`INSERT INTO "temporary_StatusList"(
7974
- "id", "correlationId", "length", "issuer", "type", "driverType",
7975
- "credentialIdMode", "proofFormat", "indexingDirection", "statusPurpose",
7976
- "statusListCredential"
7977
- )
7978
- SELECT
7979
- "id", "correlationId", "length", "issuer",
7980
- CASE WHEN "type" = 'OAuthStatusList' THEN 'StatusList2021' ELSE "type" END,
7981
- "driverType", "credentialIdMode", "proofFormat", "indexingDirection",
7982
- COALESCE("statusPurpose", 'revocation'), "statusListCredential"
7983
- FROM "StatusList"`);
7845
+ INSERT INTO "temporary_StatusListEntry"(
7846
+ "statusListId", "statusListIndex", "credentialId", "credentialHash",
7847
+ "correlationId", "value"
7848
+ )
7849
+ SELECT
7850
+ "statusListId", "statusListIndex", "credentialId", "credentialHash",
7851
+ "correlationId", "value"
7852
+ FROM "StatusListEntry"
7853
+ WHERE "type" = 'StatusListEntryEntity'
7854
+ `);
7855
+ await queryRunner.query(`DROP TABLE "StatusListEntry"`);
7856
+ await queryRunner.query(`ALTER TABLE "temporary_StatusListEntry" RENAME TO "StatusListEntry"`);
7857
+ await queryRunner.query(`
7858
+ CREATE TABLE "temporary_StatusList" (
7859
+ "id" varchar PRIMARY KEY NOT NULL,
7860
+ "correlationId" varchar NOT NULL,
7861
+ "length" integer NOT NULL,
7862
+ "issuer" text NOT NULL,
7863
+ "type" varchar CHECK( "type" IN ('StatusList2021', 'OAuthStatusList') ) NOT NULL DEFAULT ('StatusList2021'),
7864
+ "driverType" varchar CHECK( "driverType" IN ('agent_typeorm','agent_kv_store','github','agent_filesystem') ) NOT NULL DEFAULT ('agent_typeorm'),
7865
+ "credentialIdMode" varchar CHECK( "credentialIdMode" IN ('ISSUANCE','PERSISTENCE','NEVER') ) NOT NULL DEFAULT ('ISSUANCE'),
7866
+ "proofFormat" varchar CHECK( "proofFormat" IN ('lds','jwt', 'vc+jwt') ) NOT NULL DEFAULT ('lds'),
7867
+ "indexingDirection" varchar CHECK( "indexingDirection" IN ('rightToLeft') ),
7868
+ "statusPurpose" varchar,
7869
+ "statusListCredential" text,
7870
+ "bitsPerStatus" integer,
7871
+ "expiresAt" datetime,
7872
+ CONSTRAINT "UQ_correlationId" UNIQUE ("correlationId")
7873
+ )
7874
+ `);
7875
+ await queryRunner.query(`
7876
+ INSERT INTO "temporary_StatusList"(
7877
+ "id", "correlationId", "length", "issuer", "type", "driverType",
7878
+ "credentialIdMode", "proofFormat", "indexingDirection", "statusPurpose",
7879
+ "statusListCredential", "bitsPerStatus", "expiresAt"
7880
+ )
7881
+ SELECT
7882
+ "id", "correlationId", "length", "issuer",
7883
+ CASE WHEN "type" = 'BitstringStatusList' THEN 'StatusList2021' ELSE "type" END,
7884
+ "driverType", "credentialIdMode", "proofFormat", "indexingDirection",
7885
+ "statusPurpose", "statusListCredential", "bitsPerStatus", "expiresAt"
7886
+ FROM "StatusList"
7887
+ `);
7984
7888
  await queryRunner.query(`DROP TABLE "StatusList"`);
7985
7889
  await queryRunner.query(`ALTER TABLE "temporary_StatusList" RENAME TO "StatusList"`);
7986
7890
  }
7987
7891
  };
7988
7892
 
7989
- // src/migrations/generic/4-CreateStatusList.ts
7893
+ // src/migrations/generic/12-CreateBitstringStatusList.ts
7990
7894
  var debug11 = (0, import_debug11.default)("sphereon:ssi-sdk:migrations");
7991
- var CreateStatusList1693866470000 = class {
7895
+ var AddBitstringStatusListEnum1741895823000 = class {
7992
7896
  static {
7993
- __name(this, "CreateStatusList1693866470000");
7897
+ __name(this, "AddBitstringStatusListEnum1741895823000");
7994
7898
  }
7995
- name = "CreateStatusList1693866470000";
7899
+ name = "AddBitstringStatusListEnum1741895823000";
7996
7900
  async up(queryRunner) {
7997
- debug11("migration: creating issuance branding tables");
7901
+ debug11("migration: creating bitstring status list tables");
7998
7902
  const dbType = queryRunner.connection.driver.options.type;
7999
- if (dbType === "postgres") {
8000
- debug11("using postgres migration files");
8001
- const createMig = new CreateStatusList1693866470001();
8002
- await createMig.up(queryRunner);
8003
- const updateMig = new UpdateStatusList1737110469001();
8004
- const up = await updateMig.up(queryRunner);
8005
- debug11("Migration statements executed");
8006
- return up;
8007
- } else if (dbType === "sqlite" || dbType === "react-native" || dbType === "expo") {
8008
- debug11("using sqlite/react-native migration files");
8009
- const createMig = new CreateStatusList1693866470002();
8010
- await createMig.up(queryRunner);
8011
- const updateMig = new UpdateStatusList1737110469000();
8012
- const up = await updateMig.up(queryRunner);
8013
- debug11("Migration statements executed");
8014
- return up;
8015
- } else {
8016
- 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`);
7903
+ switch (dbType) {
7904
+ case "postgres": {
7905
+ const mig = new AddBitstringStatusListEnumPG1741895823000();
7906
+ await mig.up(queryRunner);
7907
+ return;
7908
+ }
7909
+ case "sqlite":
7910
+ case "expo":
7911
+ case "react-native": {
7912
+ return;
7913
+ }
7914
+ default:
7915
+ return Promise.reject(`Migrations only supported for sqlite and postgres. Was ${dbType}`);
7916
+ }
7917
+ }
7918
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
7919
+ async down(queryRunner) {
7920
+ }
7921
+ };
7922
+ var CreateBitstringStatusList1741895823000 = class {
7923
+ static {
7924
+ __name(this, "CreateBitstringStatusList1741895823000");
7925
+ }
7926
+ name = "CreateBitstringStatusList1741895823000";
7927
+ async up(queryRunner) {
7928
+ debug11("migration: creating bitstring status list tables");
7929
+ const dbType = queryRunner.connection.driver.options.type;
7930
+ switch (dbType) {
7931
+ case "postgres": {
7932
+ const mig = new CreateBitstringStatusListPG1741895823000();
7933
+ await mig.up(queryRunner);
7934
+ return;
7935
+ }
7936
+ case "sqlite":
7937
+ case "expo":
7938
+ case "react-native": {
7939
+ const mig = new CreateBitstringStatusListSqlite1741895823001();
7940
+ await mig.up(queryRunner);
7941
+ return;
7942
+ }
7943
+ default:
7944
+ return Promise.reject(`Migrations only supported for sqlite and postgres. Was ${dbType}`);
8017
7945
  }
8018
7946
  }
8019
7947
  async down(queryRunner) {
8020
- debug11("migration: reverting issuance branding tables");
7948
+ debug11("migration: dropping bitstring status list tables");
8021
7949
  const dbType = queryRunner.connection.driver.options.type;
8022
- if (dbType === "postgres") {
8023
- debug11("using postgres migration files");
8024
- const updateMig = new UpdateStatusList1737110469001();
8025
- await updateMig.down(queryRunner);
8026
- const createMig = new CreateStatusList1693866470001();
8027
- const down = await createMig.down(queryRunner);
8028
- debug11("Migration statements executed");
8029
- return down;
8030
- } else if (dbType === "sqlite" || dbType === "react-native" || dbType === "expo") {
8031
- debug11("using sqlite/react-native migration files");
8032
- const updateMig = new UpdateStatusList1737110469000();
8033
- await updateMig.down(queryRunner);
8034
- const createMig = new CreateStatusList1693866470002();
8035
- const down = await createMig.down(queryRunner);
8036
- debug11("Migration statements executed");
8037
- return down;
8038
- } else {
8039
- 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`);
7950
+ switch (dbType) {
7951
+ case "postgres": {
7952
+ const mig = new CreateBitstringStatusListPG1741895823000();
7953
+ await mig.down(queryRunner);
7954
+ return;
7955
+ }
7956
+ case "sqlite":
7957
+ case "expo":
7958
+ case "react-native": {
7959
+ const mig = new CreateBitstringStatusListSqlite1741895823001();
7960
+ await mig.down(queryRunner);
7961
+ return;
7962
+ }
7963
+ default:
7964
+ return Promise.reject(`Migrations only supported for sqlite and postgres. Was ${dbType}`);
8040
7965
  }
8041
7966
  }
8042
7967
  };
8043
7968
 
8044
- // src/migrations/generic/5-CreateAuditEvents.ts
7969
+ // src/migrations/generic/13-UpdatePresentationDefinitionItemNullable.ts
8045
7970
  var import_debug12 = __toESM(require("debug"), 1);
8046
7971
 
8047
- // src/migrations/sqlite/1701634819487-CreateAuditEvents.ts
8048
- var CreateAuditEvents1701634819487 = class {
7972
+ // src/migrations/postgres/1756975509000-UpdatePresentationDefinitionItemNullable.ts
7973
+ var UpdatePresentationDefinitionItemNullablePG1741895824000 = class {
8049
7974
  static {
8050
- __name(this, "CreateAuditEvents1701634819487");
7975
+ __name(this, "UpdatePresentationDefinitionItemNullablePG1741895824000");
8051
7976
  }
8052
- name = "CreateAuditEvents1701634819487";
7977
+ name = "UpdatePresentationDefinitionItemNullable1741895824000";
8053
7978
  async up(queryRunner) {
8054
- await queryRunner.query(`CREATE TABLE "AuditEvents" (
8055
- "id" varchar PRIMARY KEY NOT NULL,
8056
- "eventType" varchar CHECK( "eventType" IN ('audit','activity','general') ) NOT NULL,
8057
- "timestamp" datetime NOT NULL,
8058
- "level" varchar CHECK( "level" IN ('0','1','2','3','4') ) NOT NULL,
8059
- "correlationId" varchar NOT NULL,
8060
- "system" varchar CHECK( "system" IN ('general','kms','identity','oid4vci','oid4vp','siopv2','PE','credentials','web3','profile','contact') ) NOT NULL,
8061
- "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,
8062
- "actionType" varchar CHECK( "actionType" IN ('create','read','update','delete','execute') ) NOT NULL,
8063
- "actionSubType" varchar NOT NULL,
8064
- "initiatorType" varchar CHECK( "initiatorType" IN ('user','system','external') ) NOT NULL,
8065
- "systemCorrelationIdType" varchar CHECK( "systemCorrelationIdType" IN ('did','url','email','hostname','phone','user') ),
8066
- "systemCorrelationId" varchar,
8067
- "systemAlias" varchar,
8068
- "partyCorrelationType" varchar CHECK( "partyCorrelationType" IN ('did','url','email','hostname','phone') ),
8069
- "partyCorrelationId" varchar,
8070
- "partyAlias" varchar,
8071
- "credentialType" varchar CHECK( "credentialType" IN ('JSON_LD','JWT','SD_JWT','MSO_MDOC') ),
8072
- "credentialHash" varchar,
8073
- "parentCredentialHash" varchar,
8074
- "originalCredential" varchar,
8075
- "sharePurpose" varchar,
8076
- "description" varchar NOT NULL,
8077
- "data" varchar,
8078
- "diagnosticData" varchar,
8079
- "created_at" datetime NOT NULL DEFAULT (datetime('now')),
8080
- "last_updated_at" datetime NOT NULL DEFAULT (datetime('now')))`);
7979
+ await queryRunner.query(`ALTER TABLE "PresentationDefinitionItem" ALTER COLUMN "definition_payload" DROP NOT NULL`);
8081
7980
  }
8082
7981
  async down(queryRunner) {
8083
- await queryRunner.query(`DROP TABLE "AuditEvents"`);
7982
+ await queryRunner.query(`ALTER TABLE "PresentationDefinitionItem" ALTER COLUMN "definition_payload" SET NOT NULL`);
8084
7983
  }
8085
7984
  };
8086
7985
 
8087
- // src/migrations/postgres/1701634812183-CreateAuditEvents.ts
8088
- var CreateAuditEvents1701634812183 = class {
7986
+ // src/migrations/sqlite/1756975340000-UpdatePresentationDefinitionItemNullable.ts
7987
+ var UpdatePresentationDefinitionItemNullableSqlite1756975340000 = class {
8089
7988
  static {
8090
- __name(this, "CreateAuditEvents1701634812183");
7989
+ __name(this, "UpdatePresentationDefinitionItemNullableSqlite1756975340000");
8091
7990
  }
8092
- name = "CreateAuditEvents1701634812183";
7991
+ name = "UpdatePresentationDefinitionItemNullable1756975340000";
8093
7992
  async up(queryRunner) {
8094
- await queryRunner.query(`CREATE TYPE "public"."Level_enum" AS ENUM('0', '1', '2', '3', '4')`);
8095
- await queryRunner.query(`CREATE TYPE "public"."System_enum" AS ENUM('general', 'kms', 'identity', 'oid4vci', 'oid4vp', 'siopv2', 'PE', 'credentials', 'web3', 'profile', 'contact')`);
8096
- 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')`);
8097
- await queryRunner.query(`CREATE TYPE "public"."Action_type_enum" AS ENUM('create', 'read', 'update', 'delete', 'execute')`);
8098
- await queryRunner.query(`CREATE TYPE "public"."Initiator_type_enum" AS ENUM('user', 'system', 'external')`);
8099
- await queryRunner.query(`CREATE TYPE "public"."System_correlation_id_type_enum" AS ENUM('did', 'url', 'email', 'hostname', 'phone', 'user')`);
8100
- await queryRunner.query(`CREATE TYPE "public"."Party_correlation_type_enum" AS ENUM('did', 'url', 'email', 'hostname', 'phone')`);
8101
- await queryRunner.query(`CREATE TYPE "public"."Event_type_enum" AS ENUM('audit', 'activity', 'general')`);
8102
- await queryRunner.query(`CREATE TYPE "public"."Event_credential_type_enum" AS ENUM('JSON_LD', 'JWT', 'SD_JWT', 'MSO_MDOC')`);
8103
- await queryRunner.query(`CREATE TABLE "AuditEvents" (
8104
- "id" uuid NOT NULL DEFAULT uuid_generate_v4(),
8105
- "eventType" "public"."Event_type_enum" NOT NULL,
8106
- "timestamp" TIMESTAMP NOT NULL,
8107
- "level" "public"."Level_enum" NOT NULL,
8108
- "correlationId" TEXT NOT NULL,
8109
- "system" "public"."System_enum" NOT NULL,
8110
- "subSystemType" "public"."Subsystem_type_enum" NOT NULL,
8111
- "actionType" "public"."Action_type_enum" NOT NULL,
8112
- "actionSubType" TEXT NOT NULL,
8113
- "initiatorType" "public"."Initiator_type_enum" NOT NULL,
8114
- "systemCorrelationIdType" "public"."System_correlation_id_type_enum",
8115
- "systemCorrelationId" TEXT,
8116
- "systemAlias" TEXT,
8117
- "partyCorrelationType" "public"."Party_correlation_type_enum",
8118
- "partyCorrelationId" TEXT,
8119
- "partyAlias" TEXT,
8120
- "credentialType" "public"."Event_credential_type_enum",
8121
- "credentialHash" TEXT,
8122
- "originalCredential" TEXT,
8123
- "sharePurpose" TEXT,
8124
- "description" TEXT NOT NULL,
8125
- "data" TEXT,
8126
- "diagnosticData" TEXT,
8127
- "created_at" TIMESTAMP NOT NULL DEFAULT now(),
8128
- "last_updated_at" TIMESTAMP NOT NULL DEFAULT now(),
8129
- CONSTRAINT "PK_AuditEvents_id" PRIMARY KEY ("id"))`);
7993
+ await queryRunner.query(`
7994
+ CREATE TABLE "temporary_PresentationDefinitionItem" (
7995
+ "id" varchar PRIMARY KEY NOT NULL,
7996
+ "definition_id" varchar(255) NOT NULL,
7997
+ "version" varchar(255) NOT NULL,
7998
+ "tenant_id" varchar(255),
7999
+ "purpose" varchar(255),
8000
+ "name" varchar(255),
8001
+ "definition_payload" text,
8002
+ "dcql_payload" text,
8003
+ "created_at" datetime NOT NULL DEFAULT (datetime('now')),
8004
+ "last_updated_at" datetime NOT NULL DEFAULT (datetime('now')),
8005
+ CONSTRAINT "UQ_PresentationDefinitionItem_definition_id_version" UNIQUE ("definition_id", "version")
8006
+ )
8007
+ `);
8008
+ await queryRunner.query(`
8009
+ INSERT INTO "temporary_PresentationDefinitionItem"(
8010
+ "id", "definition_id", "version", "tenant_id", "purpose", "name",
8011
+ "definition_payload", "dcql_payload", "created_at", "last_updated_at"
8012
+ )
8013
+ SELECT
8014
+ "id", "definition_id", "version", "tenant_id", "purpose", "name",
8015
+ "definition_payload", "dcql_payload", "created_at", "last_updated_at"
8016
+ FROM "PresentationDefinitionItem"
8017
+ `);
8018
+ await queryRunner.query(`DROP TABLE "PresentationDefinitionItem"`);
8019
+ await queryRunner.query(`ALTER TABLE "temporary_PresentationDefinitionItem" RENAME TO "PresentationDefinitionItem"`);
8020
+ await queryRunner.query(`CREATE INDEX "IDX_PresentationDefinitionItem_version" ON "PresentationDefinitionItem" ("version")`);
8130
8021
  }
8131
8022
  async down(queryRunner) {
8132
- await queryRunner.query(`DROP TABLE "AuditEvents"`);
8133
- await queryRunner.query(`DROP TYPE "public"."Party_correlation_type_enum"`);
8134
- await queryRunner.query(`DROP TYPE "public"."System_correlation_id_type_enum"`);
8135
- await queryRunner.query(`DROP TYPE "public"."Initiator_type_enum"`);
8136
- await queryRunner.query(`DROP TYPE "public"."Action_type_enum"`);
8137
- await queryRunner.query(`DROP TYPE "public"."Subsystem_type_enum"`);
8138
- await queryRunner.query(`DROP TYPE "public"."System_enum"`);
8139
- await queryRunner.query(`DROP TYPE "public"."Level_enum"`);
8023
+ await queryRunner.query(`
8024
+ CREATE TABLE "temporary_PresentationDefinitionItem" (
8025
+ "id" varchar PRIMARY KEY NOT NULL,
8026
+ "definition_id" varchar(255) NOT NULL,
8027
+ "version" varchar(255) NOT NULL,
8028
+ "tenant_id" varchar(255),
8029
+ "purpose" varchar(255),
8030
+ "name" varchar(255),
8031
+ "definition_payload" text NOT NULL,
8032
+ "dcql_payload" text,
8033
+ "created_at" datetime NOT NULL DEFAULT (datetime('now')),
8034
+ "last_updated_at" datetime NOT NULL DEFAULT (datetime('now')),
8035
+ CONSTRAINT "UQ_PresentationDefinitionItem_definition_id_version" UNIQUE ("definition_id", "version")
8036
+ )
8037
+ `);
8038
+ await queryRunner.query(`
8039
+ INSERT INTO "temporary_PresentationDefinitionItem"(
8040
+ "id", "definition_id", "version", "tenant_id", "purpose", "name",
8041
+ "definition_payload", "dcql_payload", "created_at", "last_updated_at"
8042
+ )
8043
+ SELECT
8044
+ "id", "definition_id", "version", "tenant_id", "purpose", "name",
8045
+ "definition_payload", "dcql_payload", "created_at", "last_updated_at"
8046
+ FROM "PresentationDefinitionItem"
8047
+ `);
8048
+ await queryRunner.query(`DROP TABLE "PresentationDefinitionItem"`);
8049
+ await queryRunner.query(`ALTER TABLE "temporary_PresentationDefinitionItem" RENAME TO "PresentationDefinitionItem"`);
8050
+ await queryRunner.query(`CREATE INDEX "IDX_PresentationDefinitionItem_version" ON "PresentationDefinitionItem" ("version")`);
8140
8051
  }
8141
8052
  };
8142
8053
 
8143
- // src/migrations/generic/5-CreateAuditEvents.ts
8054
+ // src/migrations/generic/13-UpdatePresentationDefinitionItemNullable.ts
8144
8055
  var debug12 = (0, import_debug12.default)("sphereon:ssi-sdk:migrations");
8145
- var CreateAuditEvents1701635835330 = class {
8056
+ var UpdatePresentationDefinitionItemNullable1741895824000 = class {
8146
8057
  static {
8147
- __name(this, "CreateAuditEvents1701635835330");
8058
+ __name(this, "UpdatePresentationDefinitionItemNullable1741895824000");
8148
8059
  }
8149
- name = "CreateAuditEvents1701635835330";
8060
+ name = "UpdatePresentationDefinitionItemNullable1741895824000";
8150
8061
  async up(queryRunner) {
8151
- debug12("migration: creating audit events tables");
8062
+ debug12("migration: updating presentation definition item nullable fields");
8152
8063
  const dbType = queryRunner.connection.driver.options.type;
8153
8064
  switch (dbType) {
8154
8065
  case "postgres": {
8155
8066
  debug12("using postgres migration file");
8156
- const mig = new CreateAuditEvents1701634812183();
8067
+ const mig = new UpdatePresentationDefinitionItemNullablePG1741895824000();
8157
8068
  await mig.up(queryRunner);
8158
8069
  debug12("Migration statements executed");
8159
8070
  return;
@@ -8162,7 +8073,7 @@ var CreateAuditEvents1701635835330 = class {
8162
8073
  case "expo":
8163
8074
  case "react-native": {
8164
8075
  debug12("using sqlite/react-native migration file");
8165
- const mig = new CreateAuditEvents1701634819487();
8076
+ const mig = new UpdatePresentationDefinitionItemNullableSqlite1756975340000();
8166
8077
  await mig.up(queryRunner);
8167
8078
  debug12("Migration statements executed");
8168
8079
  return;
@@ -8172,12 +8083,12 @@ var CreateAuditEvents1701635835330 = class {
8172
8083
  }
8173
8084
  }
8174
8085
  async down(queryRunner) {
8175
- debug12("migration: reverting audit events tables");
8086
+ debug12("migration: reverting presentation definition item nullable fields");
8176
8087
  const dbType = queryRunner.connection.driver.options.type;
8177
8088
  switch (dbType) {
8178
8089
  case "postgres": {
8179
8090
  debug12("using postgres migration file");
8180
- const mig = new CreateAuditEvents1701634812183();
8091
+ const mig = new UpdatePresentationDefinitionItemNullablePG1741895824000();
8181
8092
  await mig.down(queryRunner);
8182
8093
  debug12("Migration statements executed");
8183
8094
  return;
@@ -8186,7 +8097,7 @@ var CreateAuditEvents1701635835330 = class {
8186
8097
  case "expo":
8187
8098
  case "react-native": {
8188
8099
  debug12("using sqlite/react-native migration file");
8189
- const mig = new CreateAuditEvents1701634819487();
8100
+ const mig = new UpdatePresentationDefinitionItemNullableSqlite1756975340000();
8190
8101
  await mig.down(queryRunner);
8191
8102
  debug12("Migration statements executed");
8192
8103
  return;
@@ -8197,247 +8108,299 @@ var CreateAuditEvents1701635835330 = class {
8197
8108
  }
8198
8109
  };
8199
8110
 
8200
- // src/migrations/generic/6-CreateDigitalCredential.ts
8111
+ // src/migrations/generic/2-CreateIssuanceBranding.ts
8201
8112
  var import_debug13 = __toESM(require("debug"), 1);
8202
-
8203
- // src/migrations/postgres/1708525189001-CreateDigitalCredential.ts
8204
- var CreateDigitalCredential1708525189001 = class {
8205
- static {
8206
- __name(this, "CreateDigitalCredential1708525189001");
8207
- }
8208
- name = "CreateDigitalCredential1708525189001";
8209
- async up(queryRunner) {
8210
- await queryRunner.query(`CREATE TYPE "digital_document_type" AS ENUM('VC', 'VP', 'C', 'P')`);
8211
- await queryRunner.query(`CREATE TYPE "digital_regulation_type" AS ENUM('PID', 'QEAA', 'EAA', 'NON_REGULATED')`);
8212
- await queryRunner.query(`CREATE TYPE "digital_credential_document_format" AS ENUM('JSON_LD', 'JWT', 'SD_JWT', 'MSO_MDOC')`);
8213
- await queryRunner.query(`CREATE TYPE "digital_credential_credential_role" AS ENUM('ISSUER', 'VERIFIER', 'HOLDER', 'FEDERATION_TRUST_ANCHOR')`);
8214
- await queryRunner.query(`CREATE TYPE "digital_credential_correlation_type" AS ENUM('DID', 'KID', 'URL', 'X509_SAN')`);
8215
- await queryRunner.query(`CREATE TYPE "digital_credential_state_type" AS ENUM('REVOKED', 'VERIFIED', 'EXPIRED')`);
8216
- await queryRunner.query(`
8217
- CREATE TABLE "DigitalCredential" (
8218
- "id" uuid NOT NULL DEFAULT uuid_generate_v4(),
8219
- "parent_id" text,
8220
- "document_type" "digital_document_type" NOT NULL,
8221
- "regulation_type" "digital_regulation_type" NOT NULL DEFAULT 'NON_REGULATED'::"digital_regulation_type",
8222
- "document_format" "digital_credential_document_format" NOT NULL,
8223
- "credential_role" "digital_credential_credential_role" NOT NULL,
8224
- "raw_document" text NOT NULL,
8225
- "uniform_document" text NOT NULL,
8226
- "credential_id" text,
8227
- "hash" text NOT NULL,
8228
- "kms_key_ref" text,
8229
- "identifier_method" text,
8230
- "issuer_correlation_type" "digital_credential_correlation_type" NOT NULL,
8231
- "subject_correlation_type" "digital_credential_correlation_type",
8232
- "issuer_correlation_id" text NOT NULL,
8233
- "subject_correlation_id" text,
8234
- "verified_state" "digital_credential_state_type",
8235
- "issuer_signed" boolean,
8236
- "rp_correlation_id" text,
8237
- "rp_correlation_type" "digital_credential_correlation_type",
8238
- "tenant_id" text,
8239
- "created_at" TIMESTAMP NOT NULL DEFAULT now(),
8240
- "last_updated_at" TIMESTAMP NOT NULL DEFAULT now(),
8241
- "presented_at" DATE,
8242
- "valid_from" DATE,
8243
- "valid_until" DATE,
8244
- "verified_at" DATE,
8245
- "revoked_at" DATE,
8246
- PRIMARY KEY ("id"),
8247
- UNIQUE ("hash", "credential_role")
8248
- )
8249
- `);
8250
- }
8251
- async down(queryRunner) {
8252
- await queryRunner.query(`DROP TABLE "DigitalCredential"`);
8253
- await queryRunner.query(`DROP TYPE "digital_credential_state_type"`);
8254
- await queryRunner.query(`DROP TYPE "digital_credential_correlation_type"`);
8255
- await queryRunner.query(`DROP TYPE "digital_credential_document_format"`);
8256
- await queryRunner.query(`DROP TYPE "digital_credential_credential_role"`);
8257
- await queryRunner.query(`DROP TYPE "digital_regulation_type"`);
8258
- await queryRunner.query(`DROP TYPE "digital_document_type"`);
8259
- }
8260
- };
8261
-
8262
- // src/migrations/sqlite/1708525189002-CreateDigitalCredential.ts
8263
- var CreateDigitalCredential1708525189002 = class {
8264
- static {
8265
- __name(this, "CreateDigitalCredential1708525189002");
8266
- }
8267
- name = "CreateDigitalCredential1708525189002";
8268
- async up(queryRunner) {
8269
- await queryRunner.query(`
8270
- CREATE TABLE "DigitalCredential" (
8271
- "id" varchar PRIMARY KEY NOT NULL,
8272
- "parent_id" text,
8273
- "document_type" varchar CHECK( "document_type" IN ('VC', 'VP', 'C', 'P') ) NOT NULL,
8274
- "regulation_type" varchar CHECK( "regulation_type" IN ('PID', 'QEAA', 'EAA', 'NON_REGULATED') ) NOT NULL DEFAULT 'NON_REGULATED',
8275
- "document_format" varchar CHECK( "document_format" IN ('JSON_LD', 'JWT', 'SD_JWT', 'MSO_MDOC') ) NOT NULL,
8276
- "credential_role" varchar CHECK( "credential_role" IN ('ISSUER', 'VERIFIER', 'HOLDER', 'FEDERATION_TRUST_ANCHOR') ) NOT NULL,
8277
- "raw_document" text NOT NULL,
8278
- "uniform_document" text NOT NULL,
8279
- "credential_id" text,
8280
- "hash" text NOT NULL,
8281
- "kms_key_ref" text,
8282
- "identifier_method" text,
8283
- "issuer_correlation_type" varchar CHECK( "issuer_correlation_type" IN ('DID', 'KID', 'URL', 'X509_SAN') ) NOT NULL,
8284
- "subject_correlation_type" varchar CHECK( "subject_correlation_type" IN ('DID', 'KID', 'URL', 'X509_SAN') ),
8285
- "issuer_correlation_id" text NOT NULL,
8286
- "subject_correlation_id" text,
8287
- "issuer_signed" boolean,
8288
- "rp_correlation_id" text,
8289
- "rp_correlation_type" varchar CHECK( "issuer_correlation_type" IN ('DID', 'KID', 'URL', 'X509_SAN') ),
8290
- "verified_state" varchar CHECK( "verified_state" IN ('REVOKED', 'VERIFIED', 'EXPIRED') ),
8291
- "tenant_id" text,
8292
- "created_at" datetime NOT NULL DEFAULT (datetime('now')),
8293
- "last_updated_at" datetime NOT NULL DEFAULT (datetime('now')),
8294
- "presented_at" datetime,
8295
- "valid_from" datetime,
8296
- "valid_until" datetime,
8297
- "verified_at" datetime,
8298
- "revoked_at" datetime,
8299
- UNIQUE ("hash", "credential_role")
8300
- )
8301
- `);
8302
- }
8303
- async down(queryRunner) {
8304
- await queryRunner.query(`DROP TABLE "DigitalCredential"`);
8305
- }
8306
- };
8307
-
8308
- // src/migrations/generic/6-CreateDigitalCredential.ts
8309
8113
  var debug13 = (0, import_debug13.default)("sphereon:ssi-sdk:migrations");
8310
- var CreateDigitalCredential1708525189000 = class {
8114
+ var CreateIssuanceBranding1659463079429 = class {
8311
8115
  static {
8312
- __name(this, "CreateDigitalCredential1708525189000");
8116
+ __name(this, "CreateIssuanceBranding1659463079429");
8313
8117
  }
8314
- name = "CreateDigitalCredential1708525189000";
8118
+ name = "CreateIssuanceBranding1659463079429";
8315
8119
  async up(queryRunner) {
8316
- debug13("migration: creating DigitalCredential tables");
8120
+ debug13("migration: creating issuance branding tables");
8317
8121
  const dbType = queryRunner.connection.driver.options.type;
8318
8122
  switch (dbType) {
8319
8123
  case "postgres": {
8320
- debug13("using postgres migration file for DigitalCredential");
8321
- const mig = new CreateDigitalCredential1708525189001();
8124
+ debug13("using postgres migration file");
8125
+ const mig = new CreateIssuanceBranding1685628974232();
8322
8126
  await mig.up(queryRunner);
8323
- debug13("Postgres Migration statements for DigitalCredential executed");
8127
+ debug13("Migration statements executed");
8324
8128
  return;
8325
8129
  }
8326
8130
  case "sqlite":
8327
8131
  case "expo":
8328
8132
  case "react-native": {
8329
- debug13("using sqlite/react-native migration file for DigitalCredential");
8330
- const mig = new CreateDigitalCredential1708525189002();
8133
+ debug13("using sqlite/react-native migration file");
8134
+ const mig = new CreateIssuanceBranding1685628973231();
8331
8135
  await mig.up(queryRunner);
8332
- debug13("SQLite Migration statements for DigitalCredential executed");
8136
+ debug13("Migration statements executed");
8333
8137
  return;
8334
8138
  }
8335
8139
  default:
8336
- 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`);
8140
+ 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`);
8337
8141
  }
8338
8142
  }
8339
8143
  async down(queryRunner) {
8340
- debug13("migration: reverting DigitalCredential tables");
8144
+ debug13("migration: reverting issuance branding tables");
8341
8145
  const dbType = queryRunner.connection.driver.options.type;
8342
8146
  switch (dbType) {
8343
8147
  case "postgres": {
8344
- debug13("using postgres migration file for DigitalCredential");
8345
- const mig = new CreateDigitalCredential1708525189001();
8148
+ debug13("using postgres migration file");
8149
+ const mig = new CreateIssuanceBranding1685628974232();
8346
8150
  await mig.down(queryRunner);
8347
- debug13("Postgres Migration statements for DigitalCredential reverted");
8151
+ debug13("Migration statements executed");
8348
8152
  return;
8349
8153
  }
8350
8154
  case "sqlite":
8351
8155
  case "expo":
8352
8156
  case "react-native": {
8353
- debug13("using sqlite/react-native migration file for DigitalCredential");
8354
- const mig = new CreateDigitalCredential1708525189002();
8157
+ debug13("using sqlite/react-native migration file");
8158
+ const mig = new CreateIssuanceBranding1685628973231();
8355
8159
  await mig.down(queryRunner);
8356
- debug13("SQLite Migration statements for DigitalCredential reverted");
8160
+ debug13("Migration statements executed");
8357
8161
  return;
8358
8162
  }
8359
8163
  default:
8360
- 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`);
8164
+ 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`);
8361
8165
  }
8362
8166
  }
8363
8167
  };
8364
8168
 
8365
- // src/migrations/generic/7-CreateMachineStateStore.ts
8169
+ // src/migrations/generic/3-CreateContacts.ts
8366
8170
  var import_debug14 = __toESM(require("debug"), 1);
8367
8171
 
8368
- // src/migrations/postgres/1708797018115-CreateMachineStateStore.ts
8369
- var CreateMachineStateStore1708797018115 = class {
8172
+ // src/migrations/sqlite/1690925872693-CreateContacts.ts
8173
+ var CreateContacts1690925872693 = class {
8370
8174
  static {
8371
- __name(this, "CreateMachineStateStore1708797018115");
8175
+ __name(this, "CreateContacts1690925872693");
8372
8176
  }
8373
- name = "CreateMachineStateStore1708797018115";
8177
+ name = "CreateContacts1690925872693";
8374
8178
  async up(queryRunner) {
8375
- await queryRunner.query(`
8376
- CREATE TABLE "MachineStateInfoEntity" (
8377
- "instance_id" text NOT NULL,
8378
- "session_id" text,
8379
- "latest_state_name" text,
8380
- "machine_name" text NOT NULL,
8381
- "latest_event_type" text NOT NULL,
8382
- "state" text NOT NULL,
8383
- "created_at" TIMESTAMP NOT NULL DEFAULT now(),
8384
- "updated_at" TIMESTAMP NOT NULL DEFAULT now(),
8385
- "updated_count" integer NOT NULL DEFAULT 0,
8386
- "expires_at" TIMESTAMP,
8387
- "completed_at" TIMESTAMP,
8388
- "tenant_id" text,
8389
- CONSTRAINT "PK_MachineStateInfoEntity_id" PRIMARY KEY ("instance_id")
8390
- )
8391
- `);
8179
+ 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"))`);
8180
+ await queryRunner.query(`INSERT INTO "temporary_CorrelationIdentifier"("id", "type", "correlation_id", "identityId") SELECT "id", "type", "correlation_id", "identityId" FROM "CorrelationIdentifier"`);
8181
+ await queryRunner.query(`DROP TABLE "CorrelationIdentifier"`);
8182
+ await queryRunner.query(`ALTER TABLE "temporary_CorrelationIdentifier" RENAME TO "CorrelationIdentifier"`);
8183
+ 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"))`);
8184
+ 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"`);
8185
+ await queryRunner.query(`DROP TABLE "Identity"`);
8186
+ await queryRunner.query(`ALTER TABLE "temporary_Identity" RENAME TO "Identity"`);
8187
+ 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"))`);
8188
+ await queryRunner.query(`INSERT INTO "temporary_Connection"("id", "type", "identityId") SELECT "id", "type", "identityId" FROM "Connection"`);
8189
+ await queryRunner.query(`DROP TABLE "Connection"`);
8190
+ await queryRunner.query(`ALTER TABLE "temporary_Connection" RENAME TO "Connection"`);
8191
+ 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"))`);
8192
+ await queryRunner.query(`INSERT INTO "temporary_CorrelationIdentifier"("id", "type", "correlation_id", "identity_id") SELECT "id", "type", "correlation_id", "identityId" FROM "CorrelationIdentifier"`);
8193
+ await queryRunner.query(`DROP TABLE "CorrelationIdentifier"`);
8194
+ await queryRunner.query(`ALTER TABLE "temporary_CorrelationIdentifier" RENAME TO "CorrelationIdentifier"`);
8195
+ 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"))`);
8196
+ 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"`);
8197
+ await queryRunner.query(`DROP TABLE "Identity"`);
8198
+ await queryRunner.query(`ALTER TABLE "temporary_Identity" RENAME TO "Identity"`);
8199
+ 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"))`);
8200
+ await queryRunner.query(`INSERT INTO "temporary_Connection"("id", "type", "identity_id") SELECT "id", "type", "identityId" FROM "Connection"`);
8201
+ await queryRunner.query(`DROP TABLE "Connection"`);
8202
+ await queryRunner.query(`ALTER TABLE "temporary_Connection" RENAME TO "Connection"`);
8203
+ 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"))`);
8204
+ await queryRunner.query(`CREATE UNIQUE INDEX "IDX_PartyType_type_tenant_id" ON "PartyType" ("type", "tenant_id")`);
8205
+ 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"))`);
8206
+ await queryRunner.query(`CREATE INDEX "IDX_BaseContact_type" ON "BaseContact" ("type")`);
8207
+ 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')))`);
8208
+ await queryRunner.query(`CREATE UNIQUE INDEX "IDX_PartyRelationship_left_right" ON "PartyRelationship" ("left_id", "right_id")`);
8209
+ 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)`);
8210
+ 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"))`);
8211
+ await queryRunner.query(`CREATE INDEX "IDX_BaseConfig_type" ON "BaseConfig" ("type")`);
8212
+ 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)`);
8213
+ await queryRunner.query(`INSERT INTO "temporary_CorrelationIdentifier"("id", "type", "correlation_id", "identity_id") SELECT "id", "type", "correlation_id", "identity_id" FROM "CorrelationIdentifier"`);
8214
+ await queryRunner.query(`DROP TABLE "CorrelationIdentifier"`);
8215
+ await queryRunner.query(`ALTER TABLE "temporary_CorrelationIdentifier" RENAME TO "CorrelationIdentifier"`);
8216
+ await queryRunner.query(`DROP INDEX "IDX_BaseContact_type"`);
8217
+ 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)`);
8218
+ 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"`);
8219
+ await queryRunner.query(`DROP TABLE "BaseContact"`);
8220
+ await queryRunner.query(`ALTER TABLE "temporary_BaseContact" RENAME TO "BaseContact"`);
8221
+ await queryRunner.query(`CREATE INDEX "IDX_BaseContact_type" ON "BaseContact" ("type")`);
8222
+ await queryRunner.query(`DROP INDEX "IDX_PartyRelationship_left_right"`);
8223
+ 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)`);
8224
+ 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"`);
8225
+ await queryRunner.query(`DROP TABLE "PartyRelationship"`);
8226
+ await queryRunner.query(`ALTER TABLE "temporary_PartyRelationship" RENAME TO "PartyRelationship"`);
8227
+ await queryRunner.query(`CREATE UNIQUE INDEX "IDX_PartyRelationship_left_right" ON "PartyRelationship" ("left_id", "right_id")`);
8228
+ 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)`);
8229
+ 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)`);
8230
+ 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)`);
8231
+ 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"`);
8232
+ await queryRunner.query(`DROP TABLE "Party"`);
8233
+ await queryRunner.query(`ALTER TABLE "temporary_Party" RENAME TO "Party"`);
8234
+ 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)`);
8235
+ 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"`);
8236
+ await queryRunner.query(`DROP TABLE "Identity"`);
8237
+ await queryRunner.query(`ALTER TABLE "temporary_Identity" RENAME TO "Identity"`);
8238
+ 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)`);
8239
+ await queryRunner.query(`INSERT INTO "temporary_Connection"("id", "type", "identity_id") SELECT "id", "type", "identity_id" FROM "Connection"`);
8240
+ await queryRunner.query(`DROP TABLE "Connection"`);
8241
+ await queryRunner.query(`ALTER TABLE "temporary_Connection" RENAME TO "Connection"`);
8242
+ await queryRunner.query(`DROP INDEX "IDX_BaseConfig_type"`);
8243
+ 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)`);
8244
+ 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"`);
8245
+ await queryRunner.query(`DROP TABLE "BaseConfig"`);
8246
+ await queryRunner.query(`ALTER TABLE "temporary_BaseConfig" RENAME TO "BaseConfig"`);
8247
+ await queryRunner.query(`CREATE INDEX "IDX_BaseConfig_type" ON "BaseConfig" ("type")`);
8248
+ 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"`);
8249
+ await queryRunner.query(`DROP TABLE "BaseConfigEntity"`);
8250
+ 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'))`);
8251
+ 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'))`);
8252
+ 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"`);
8253
+ 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"`);
8254
+ await queryRunner.query(`DROP TABLE "Contact"`);
8392
8255
  }
8393
8256
  async down(queryRunner) {
8394
- await queryRunner.query(`DROP TABLE "MachineStateInfoEntity"`);
8257
+ 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))`);
8258
+ 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'`);
8259
+ await queryRunner.query(`DROP TABLE "BaseContact"`);
8260
+ await queryRunner.query(`DROP TABLE "Party"`);
8261
+ 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)`);
8262
+ 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"`);
8263
+ await queryRunner.query(`DROP TABLE "BaseConfig"`);
8264
+ 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)`);
8265
+ 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"`);
8266
+ await queryRunner.query(`DROP TABLE "Party"`);
8267
+ await queryRunner.query(`ALTER TABLE "temporary_Party" RENAME TO "Party"`);
8268
+ await queryRunner.query(`DROP INDEX "IDX_PartyRelationship_left_right"`);
8269
+ 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)`);
8270
+ 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"`);
8271
+ await queryRunner.query(`DROP TABLE "PartyRelationship"`);
8272
+ await queryRunner.query(`ALTER TABLE "temporary_PartyRelationship" RENAME TO "PartyRelationship"`);
8273
+ await queryRunner.query(`CREATE UNIQUE INDEX "IDX_PartyRelationship_left_right" ON "PartyRelationship" ("left_id", "right_id")`);
8274
+ await queryRunner.query(`DROP INDEX "IDX_BaseContact_type"`);
8275
+ 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)`);
8276
+ 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"`);
8277
+ await queryRunner.query(`DROP TABLE "BaseContact"`);
8278
+ await queryRunner.query(`ALTER TABLE "temporary_BaseContact" RENAME TO "BaseContact"`);
8279
+ await queryRunner.query(`CREATE INDEX "IDX_BaseContact_type" ON "BaseContact" ("type")`);
8280
+ await queryRunner.query(`DROP INDEX "IDX_BaseConfig_type"`);
8281
+ 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)`);
8282
+ 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"`);
8283
+ await queryRunner.query(`DROP TABLE "BaseConfig"`);
8284
+ await queryRunner.query(`ALTER TABLE "temporary_BaseConfig" RENAME TO "BaseConfig"`);
8285
+ await queryRunner.query(`CREATE INDEX "IDX_BaseConfig_type" ON "BaseConfig" ("type")`);
8286
+ await queryRunner.query(`DROP INDEX "IDX_PartyType_type_tenant_id"`);
8287
+ await queryRunner.query(`DROP TABLE "PartyType"`);
8288
+ await queryRunner.query(`DROP TABLE "Connection"`);
8289
+ await queryRunner.query(`DROP TABLE "Identity"`);
8290
+ await queryRunner.query(`DROP TABLE "CorrelationIdentifier"`);
8291
+ await queryRunner.query(`DROP TABLE "ElectronicAddress"`);
8292
+ await queryRunner.query(`DROP TABLE "PhysicalAddress"`);
8395
8293
  }
8396
8294
  };
8397
8295
 
8398
- // src/migrations/sqlite/1708796002272-CreateMachineStateStore.ts
8399
- var CreateMachineStateStore1708796002272 = class {
8296
+ // src/migrations/postgres/1690925872592-CreateContacts.ts
8297
+ var import_ssi_sdk22 = require("@sphereon/ssi-sdk.core");
8298
+ var CreateContacts1690925872592 = class {
8400
8299
  static {
8401
- __name(this, "CreateMachineStateStore1708796002272");
8300
+ __name(this, "CreateContacts1690925872592");
8402
8301
  }
8403
- name = "CreateMachineStateStore1708796002272";
8302
+ name = "CreateContacts1690925872592";
8404
8303
  async up(queryRunner) {
8405
- await queryRunner.query(`
8406
- CREATE TABLE "MachineStateInfoEntity" (
8407
- "instance_id" varchar PRIMARY KEY NOT NULL,
8408
- "session_id" varchar,
8409
- "machine_name" varchar NOT NULL,
8410
- "latest_state_name" varchar,
8411
- "latest_event_type" varchar NOT NULL,
8412
- "state" text NOT NULL,
8413
- "created_at" datetime NOT NULL DEFAULT (datetime('now')),
8414
- "updated_at" datetime NOT NULL DEFAULT (datetime('now')),
8415
- "updated_count" integer NOT NULL DEFAULT 0,
8416
- "expires_at" datetime,
8417
- "completed_at" datetime,
8418
- "tenant_id" varchar
8419
- )
8420
- `);
8304
+ await (0, import_ssi_sdk22.enablePostgresUuidExtension)(queryRunner);
8305
+ await queryRunner.query(`ALTER TABLE "CorrelationIdentifier" DROP CONSTRAINT "FK_CorrelationIdentifier_identityId"`);
8306
+ await queryRunner.query(`ALTER TABLE "IdentityMetadata" DROP CONSTRAINT "FK_IdentityMetadata_identityId"`);
8307
+ await queryRunner.query(`ALTER TABLE "Identity" DROP CONSTRAINT "FK_Identity_contactId"`);
8308
+ await queryRunner.query(`ALTER TABLE "Connection" DROP CONSTRAINT "FK_Connection_identityId"`);
8309
+ await queryRunner.query(`ALTER TABLE "CorrelationIdentifier" RENAME COLUMN "identityId" TO "identity_id"`);
8310
+ await queryRunner.query(`ALTER TABLE "Connection" RENAME COLUMN "identityId" TO "identity_id"`);
8311
+ await queryRunner.query(`CREATE TYPE "public"."PartyType_type_enum" AS ENUM('naturalPerson', 'organization')`);
8312
+ await queryRunner.query(`CREATE TYPE "public"."PartyOrigin_type_enum" AS ENUM('INTERNAL', 'EXTERNAL')`);
8313
+ 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"))`);
8314
+ await queryRunner.query(`CREATE UNIQUE INDEX "IDX_PartyType_type_tenant_id" ON "PartyType" ("type", "tenant_id")`);
8315
+ 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"))`);
8316
+ await queryRunner.query(`CREATE INDEX "IDX_BaseContact_type" ON "BaseContact" ("type")`);
8317
+ 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"))`);
8318
+ await queryRunner.query(`CREATE UNIQUE INDEX "IDX_PartyRelationship_left_right" ON "PartyRelationship" ("left_id", "right_id")`);
8319
+ 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"))`);
8320
+ 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"))`);
8321
+ 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"))`);
8322
+ 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"))`);
8323
+ await queryRunner.query(`CREATE INDEX "IDX_BaseConfig_type" ON "BaseConfig" ("type")`);
8324
+ await queryRunner.query(`ALTER TABLE "Identity" RENAME COLUMN "contactId" TO "partyId"`);
8325
+ await queryRunner.query(`ALTER TABLE "Identity" ALTER COLUMN "roles" SET NOT NULL`);
8326
+ await queryRunner.query(`CREATE TYPE "public"."IdentityOrigin_type_enum" AS ENUM('INTERNAL', 'EXTERNAL')`);
8327
+ await queryRunner.query(`ALTER TABLE "Identity" ADD COLUMN "origin" "public"."IdentityOrigin_type_enum" DEFAULT 'EXTERNAL' NOT NULL`);
8328
+ await queryRunner.query(`ALTER TABLE "Identity" ALTER COLUMN "origin" DROP DEFAULT`);
8329
+ 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`);
8330
+ await queryRunner.query(`ALTER TABLE "IdentityMetadata" ADD CONSTRAINT "FK_IdentityMetadata_identityId" FOREIGN KEY ("identityId") REFERENCES "Identity"("id") ON DELETE CASCADE ON UPDATE NO ACTION`);
8331
+ 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`);
8332
+ 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`);
8333
+ 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`);
8334
+ await queryRunner.query(`ALTER TABLE "ElectronicAddress" ADD CONSTRAINT "FK_ElectronicAddress_partyId" FOREIGN KEY ("partyId") REFERENCES "Party"("id") ON DELETE CASCADE ON UPDATE NO ACTION`);
8335
+ await queryRunner.query(`ALTER TABLE "PhysicalAddress" ADD CONSTRAINT "FK_PhysicalAddress_partyId" FOREIGN KEY ("partyId") REFERENCES "Party" ("id") ON DELETE CASCADE ON UPDATE NO ACTION`);
8336
+ 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`);
8337
+ await queryRunner.query(`ALTER TABLE "Identity" ADD CONSTRAINT "FK_Identity_partyId" FOREIGN KEY ("partyId") REFERENCES "Party"("id") ON DELETE CASCADE ON UPDATE NO ACTION`);
8338
+ 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`);
8339
+ 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`);
8340
+ await queryRunner.query(`ALTER TABLE "CorrelationIdentifier" RENAME CONSTRAINT "UQ_Correlation_id" TO "UQ_CorrelationIdentifier_correlation_id"`);
8341
+ await queryRunner.query(`ALTER TABLE "Identity" RENAME CONSTRAINT "UQ_Identity_Alias" TO "UQ_Identity_alias"`);
8342
+ 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"`);
8343
+ await queryRunner.query(`DROP TABLE "BaseConfigEntity"`);
8344
+ 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())`);
8345
+ 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())`);
8346
+ 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"`);
8347
+ 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"`);
8348
+ await queryRunner.query(`DROP TABLE "Contact"`);
8421
8349
  }
8422
8350
  async down(queryRunner) {
8423
- await queryRunner.query(`DROP TABLE "MachineStateInfoEntity"`);
8351
+ await queryRunner.query(`ALTER TABLE "BaseConfig" DROP CONSTRAINT "FK_BaseConfig_connection_id"`);
8352
+ await queryRunner.query(`ALTER TABLE "Connection" DROP CONSTRAINT "FK_Connection_identity_id"`);
8353
+ await queryRunner.query(`ALTER TABLE "Identity" DROP CONSTRAINT "FK_Identity_partyId"`);
8354
+ await queryRunner.query(`ALTER TABLE "Party" DROP CONSTRAINT "FK_Party_party_type_id"`);
8355
+ await queryRunner.query(`ALTER TABLE "PhysicalAddress" DROP CONSTRAINT "FK_PhysicalAddress_partyId"`);
8356
+ await queryRunner.query(`ALTER TABLE "ElectronicAddress" DROP CONSTRAINT "FK_ElectronicAddress_partyId"`);
8357
+ await queryRunner.query(`ALTER TABLE "PartyRelationship" DROP CONSTRAINT "FK_PartyRelationship_right_id"`);
8358
+ await queryRunner.query(`ALTER TABLE "PartyRelationship" DROP CONSTRAINT "FK_PartyRelationship_left_id"`);
8359
+ await queryRunner.query(`ALTER TABLE "BaseContact" DROP CONSTRAINT "FK_BaseContact_party_id"`);
8360
+ await queryRunner.query(`ALTER TABLE "IdentityMetadata" DROP CONSTRAINT "FK_IdentityMetadata_identityId"`);
8361
+ await queryRunner.query(`ALTER TABLE "CorrelationIdentifier" DROP CONSTRAINT "FK_CorrelationIdentifier_identity_id"`);
8362
+ await queryRunner.query(`ALTER TABLE "Identity" ALTER COLUMN "roles" DROP NOT NULL`);
8363
+ await queryRunner.query(`ALTER TABLE "Identity" DROP COLUMN "origin"`);
8364
+ await queryRunner.query(`DROP TYPE "public"."IdentityOrigin_type_enum"`);
8365
+ await queryRunner.query(`ALTER TABLE "Identity" RENAME COLUMN "partyId" TO "contactId"`);
8366
+ await queryRunner.query(`ALTER TABLE "Connection" RENAME COLUMN "identity_id" TO "identityId"`);
8367
+ await queryRunner.query(`ALTER TABLE "CorrelationIdentifier" RENAME COLUMN "identity_id" TO "identityId"`);
8368
+ await queryRunner.query(`DROP INDEX "IDX_BaseConfig_type"`);
8369
+ await queryRunner.query(`DROP TABLE "BaseConfig"`);
8370
+ await queryRunner.query(`DROP TABLE "Party"`);
8371
+ await queryRunner.query(`DROP INDEX "IDX_PartyRelationship_left_right"`);
8372
+ await queryRunner.query(`DROP TABLE "PartyRelationship"`);
8373
+ await queryRunner.query(`DROP INDEX "IDX_BaseContact_type"`);
8374
+ await queryRunner.query(`DROP TABLE "BaseContact"`);
8375
+ await queryRunner.query(`DROP TABLE "ElectronicAddress"`);
8376
+ await queryRunner.query(`DROP TABLE "PhysicalAddress"`);
8377
+ await queryRunner.query(`DROP INDEX "IDX_PartyType_type_tenant_id"`);
8378
+ await queryRunner.query(`DROP TABLE "PartyType"`);
8379
+ await queryRunner.query(`DROP TYPE "public"."PartyOrigin_type_enum"`);
8380
+ await queryRunner.query(`DROP TYPE "public"."PartyType_type_enum"`);
8381
+ await queryRunner.query(`ALTER TABLE "Connection" ADD CONSTRAINT "FK_Connection_identityId" FOREIGN KEY ("identityId") REFERENCES "Identity"("id") ON DELETE CASCADE ON UPDATE NO ACTION`);
8382
+ await queryRunner.query(`ALTER TABLE "Identity" ADD CONSTRAINT "FK_Identity_contactId" FOREIGN KEY ("contactId") REFERENCES "Contact"("id") ON DELETE CASCADE ON UPDATE NO ACTION`);
8383
+ await queryRunner.query(`ALTER TABLE "IdentityMetadata" ADD CONSTRAINT "FK_IdentityMetadata_identityId" FOREIGN KEY ("identityId") REFERENCES "Identity"("id") ON DELETE CASCADE ON UPDATE NO ACTION`);
8384
+ await queryRunner.query(`ALTER TABLE "CorrelationIdentifier" ADD CONSTRAINT "FK_CorrelationIdentifier_identityId" FOREIGN KEY ("identityId") REFERENCES "Identity"("id") ON DELETE CASCADE ON UPDATE NO ACTION`);
8385
+ 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"))`);
8386
+ 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'`);
8424
8387
  }
8425
8388
  };
8426
8389
 
8427
- // src/migrations/generic/7-CreateMachineStateStore.ts
8390
+ // src/migrations/generic/3-CreateContacts.ts
8428
8391
  var debug14 = (0, import_debug14.default)("sphereon:ssi-sdk:migrations");
8429
- var CreateMachineStateStore1708098041262 = class {
8392
+ var CreateContacts1690925872318 = class {
8430
8393
  static {
8431
- __name(this, "CreateMachineStateStore1708098041262");
8394
+ __name(this, "CreateContacts1690925872318");
8432
8395
  }
8433
- name = "CreateMachineStateStore1708098041262";
8396
+ name = "CreateContacts1690925872318";
8434
8397
  async up(queryRunner) {
8435
- debug14("migration: creating machine state tables");
8398
+ debug14("migration: creating contacts tables");
8436
8399
  const dbType = queryRunner.connection.driver.options.type;
8437
8400
  switch (dbType) {
8438
8401
  case "postgres": {
8439
8402
  debug14("using postgres migration file");
8440
- const mig = new CreateMachineStateStore1708797018115();
8403
+ const mig = new CreateContacts1690925872592();
8441
8404
  await mig.up(queryRunner);
8442
8405
  debug14("Migration statements executed");
8443
8406
  return;
@@ -8446,7 +8409,7 @@ var CreateMachineStateStore1708098041262 = class {
8446
8409
  case "expo":
8447
8410
  case "react-native": {
8448
8411
  debug14("using sqlite/react-native migration file");
8449
- const mig = new CreateMachineStateStore1708796002272();
8412
+ const mig = new CreateContacts1690925872693();
8450
8413
  await mig.up(queryRunner);
8451
8414
  debug14("Migration statements executed");
8452
8415
  return;
@@ -8456,12 +8419,12 @@ var CreateMachineStateStore1708098041262 = class {
8456
8419
  }
8457
8420
  }
8458
8421
  async down(queryRunner) {
8459
- debug14("migration: reverting machine state tables");
8422
+ debug14("migration: reverting contacts tables");
8460
8423
  const dbType = queryRunner.connection.driver.options.type;
8461
8424
  switch (dbType) {
8462
8425
  case "postgres": {
8463
8426
  debug14("using postgres migration file");
8464
- const mig = new CreateMachineStateStore1708797018115();
8427
+ const mig = new CreateContacts1690925872592();
8465
8428
  await mig.down(queryRunner);
8466
8429
  debug14("Migration statements executed");
8467
8430
  return;
@@ -8470,7 +8433,7 @@ var CreateMachineStateStore1708098041262 = class {
8470
8433
  case "expo":
8471
8434
  case "react-native": {
8472
8435
  debug14("using sqlite/react-native migration file");
8473
- const mig = new CreateMachineStateStore1708796002272();
8436
+ const mig = new CreateContacts1690925872693();
8474
8437
  await mig.down(queryRunner);
8475
8438
  debug14("Migration statements executed");
8476
8439
  return;
@@ -8481,303 +8444,380 @@ var CreateMachineStateStore1708098041262 = class {
8481
8444
  }
8482
8445
  };
8483
8446
 
8484
- // src/migrations/generic/8-CreateContacts.ts
8447
+ // src/migrations/generic/4-CreateStatusList.ts
8485
8448
  var import_debug15 = __toESM(require("debug"), 1);
8486
8449
 
8487
- // src/migrations/postgres/1710438363001-CreateContacts.ts
8488
- var CreateContacts1710438363001 = class {
8450
+ // src/migrations/postgres/1693866470001-CreateStatusList.ts
8451
+ var CreateStatusList1693866470001 = class {
8489
8452
  static {
8490
- __name(this, "CreateContacts1710438363001");
8453
+ __name(this, "CreateStatusList1693866470001");
8491
8454
  }
8492
- name = "CreateContacts1710438363001";
8455
+ name = "CreateStatusList1693866470001";
8493
8456
  async up(queryRunner) {
8494
- await queryRunner.query(`ALTER TABLE "Party" ADD COLUMN "owner_id" uuid`);
8495
- await queryRunner.query(`ALTER TABLE "Party" ADD COLUMN "tenant_id" uuid`);
8496
- await queryRunner.query(`ALTER TABLE "Identity" ADD COLUMN "owner_id" uuid`);
8497
- await queryRunner.query(`ALTER TABLE "Identity" ADD COLUMN "tenant_id" uuid`);
8498
- await queryRunner.query(`ALTER TABLE "CorrelationIdentifier" ADD COLUMN "owner_id" uuid`);
8499
- await queryRunner.query(`ALTER TABLE "CorrelationIdentifier" ADD COLUMN "tenant_id" uuid`);
8500
- await queryRunner.query(`ALTER TABLE "Connection" ADD COLUMN "owner_id" uuid`);
8501
- await queryRunner.query(`ALTER TABLE "Connection" ADD COLUMN "tenant_id" uuid`);
8502
- await queryRunner.query(`ALTER TABLE "BaseConfig" ADD COLUMN "owner_id" uuid`);
8503
- await queryRunner.query(`ALTER TABLE "BaseConfig" ADD COLUMN "tenant_id" uuid`);
8504
- await queryRunner.query(`ALTER TABLE "BaseContact" ADD COLUMN "owner_id" uuid`);
8505
- await queryRunner.query(`ALTER TABLE "BaseContact" ADD COLUMN "tenant_id" uuid`);
8506
- await queryRunner.query(`ALTER TABLE "PartyRelationship" ADD COLUMN "owner_id" uuid`);
8507
- await queryRunner.query(`ALTER TABLE "PartyRelationship" ADD COLUMN "tenant_id" uuid`);
8508
- await queryRunner.query(`ALTER TABLE "ElectronicAddress" ADD COLUMN "owner_id" uuid`);
8509
- await queryRunner.query(`ALTER TABLE "ElectronicAddress" ADD COLUMN "tenant_id" uuid`);
8510
- await queryRunner.query(`ALTER TABLE "PhysicalAddress" ADD COLUMN "owner_id" uuid`);
8511
- await queryRunner.query(`ALTER TABLE "PhysicalAddress" ADD COLUMN "tenant_id" uuid`);
8457
+ await queryRunner.query(`CREATE TYPE "StatusList_type_enum" AS ENUM('StatusList2021')`);
8458
+ await queryRunner.query(`CREATE TYPE "StatusList_drivertype_enum" AS ENUM('agent_typeorm', 'agent_kv_store', 'github', 'agent_filesystem')`);
8459
+ await queryRunner.query(`CREATE TYPE "StatusList_credentialidmode_enum" AS ENUM('ISSUANCE', 'PERSISTENCE', 'NEVER')`);
8460
+ await queryRunner.query(`CREATE TABLE "StatusListEntry"
8461
+ (
8462
+ "statusListId" character varying NOT NULL,
8463
+ "statusListIndex" integer NOT NULL,
8464
+ "credentialId" character varying,
8465
+ "credentialHash" character varying(128),
8466
+ "correlationId" character varying(255),
8467
+ "value" character varying(50),
8468
+ CONSTRAINT "PK_68704d2d13857360c6b44a3d1d0" PRIMARY KEY ("statusListId", "statusListIndex")
8469
+ )`);
8470
+ await queryRunner.query(`CREATE TABLE "StatusList"
8471
+ (
8472
+ "id" character varying NOT NULL,
8473
+ "correlationId" character varying NOT NULL,
8474
+ "length" integer NOT NULL,
8475
+ "issuer" text NOT NULL,
8476
+ "type" "StatusList_type_enum" NOT NULL DEFAULT 'StatusList2021',
8477
+ "driverType" "StatusList_drivertype_enum" NOT NULL DEFAULT 'agent_typeorm',
8478
+ "credentialIdMode" "StatusList_credentialidmode_enum" NOT NULL DEFAULT 'ISSUANCE',
8479
+ "proofFormat" character varying NOT NULL DEFAULT 'lds',
8480
+ "indexingDirection" character varying NOT NULL DEFAULT 'rightToLeft',
8481
+ "statusPurpose" character varying NOT NULL DEFAULT 'revocation',
8482
+ "statusListCredential" text,
8483
+ CONSTRAINT "UQ_correlationId" UNIQUE ("correlationId"),
8484
+ CONSTRAINT "PK_StatusList_Id" PRIMARY KEY ("id")
8485
+ )`);
8486
+ await queryRunner.query(`ALTER TABLE "StatusListEntry"
8487
+ ADD CONSTRAINT "FK_statusListEntry_statusListId" FOREIGN KEY ("statusListId") REFERENCES "StatusList" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION`);
8512
8488
  }
8513
8489
  async down(queryRunner) {
8514
- await queryRunner.query(`ALTER TABLE "PhysicalAddress" DROP COLUMN "tenant_id"`);
8515
- await queryRunner.query(`ALTER TABLE "PhysicalAddress" DROP COLUMN "owner_id"`);
8516
- await queryRunner.query(`ALTER TABLE "ElectronicAddress" DROP COLUMN "tenant_id"`);
8517
- await queryRunner.query(`ALTER TABLE "ElectronicAddress" DROP COLUMN "owner_id"`);
8518
- await queryRunner.query(`ALTER TABLE "PartyRelationship" DROP COLUMN "tenant_id"`);
8519
- await queryRunner.query(`ALTER TABLE "PartyRelationship" DROP COLUMN "owner_id"`);
8520
- await queryRunner.query(`ALTER TABLE "BaseContact" DROP COLUMN "tenant_id"`);
8521
- await queryRunner.query(`ALTER TABLE "BaseContact" DROP COLUMN "owner_id"`);
8522
- await queryRunner.query(`ALTER TABLE "BaseConfig" DROP COLUMN "tenant_id"`);
8523
- await queryRunner.query(`ALTER TABLE "BaseConfig" DROP COLUMN "owner_id"`);
8524
- await queryRunner.query(`ALTER TABLE "Connection" DROP COLUMN "tenant_id"`);
8525
- await queryRunner.query(`ALTER TABLE "Connection" DROP COLUMN "owner_id"`);
8526
- await queryRunner.query(`ALTER TABLE "CorrelationIdentifier" DROP COLUMN "tenant_id"`);
8527
- await queryRunner.query(`ALTER TABLE "CorrelationIdentifier" DROP COLUMN "owner_id"`);
8528
- await queryRunner.query(`ALTER TABLE "Identity" DROP COLUMN "tenant_id"`);
8529
- await queryRunner.query(`ALTER TABLE "Identity" DROP COLUMN "owner_id"`);
8530
- await queryRunner.query(`ALTER TABLE "Party" DROP COLUMN "tenant_id"`);
8531
- await queryRunner.query(`ALTER TABLE "Party" DROP COLUMN "owner_id"`);
8490
+ await queryRunner.query(`ALTER TABLE "StatusListEntry"
8491
+ DROP CONSTRAINT "FK_statusListEntry_statusListId"`);
8492
+ await queryRunner.query(`DROP TABLE "StatusListEntry"`);
8493
+ await queryRunner.query(`DROP TABLE "StatusList"`);
8494
+ await queryRunner.query(`DROP TYPE "StatusList_credentialidmode_enum"`);
8495
+ await queryRunner.query(`DROP TYPE "StatusList_drivertype_enum"`);
8496
+ await queryRunner.query(`DROP TYPE "StatusList_type_enum"`);
8532
8497
  }
8533
8498
  };
8534
8499
 
8535
- // src/migrations/sqlite/1710438363002-CreateContacts.ts
8536
- var CreateContacts1710438363002 = class {
8500
+ // src/migrations/sqlite/1693866470000-CreateStatusList.ts
8501
+ var CreateStatusList1693866470002 = class {
8537
8502
  static {
8538
- __name(this, "CreateContacts1710438363002");
8503
+ __name(this, "CreateStatusList1693866470002");
8539
8504
  }
8540
- name = "CreateContacts1710438363002";
8505
+ name = "CreateStatusList1693866470002";
8541
8506
  async up(queryRunner) {
8542
- await queryRunner.query(`ALTER TABLE "Party" ADD COLUMN "owner_id" text`);
8543
- await queryRunner.query(`ALTER TABLE "Party" ADD COLUMN "tenant_id" text`);
8544
- await queryRunner.query(`CREATE TABLE "temporary_Identity" (
8545
- "id" varchar PRIMARY KEY NOT NULL,
8546
- "alias" varchar(255) NOT NULL,
8547
- "roles" text NOT NULL,
8548
- "origin" text NOT NULL,
8549
- "created_at" datetime NOT NULL DEFAULT (datetime('now')),
8550
- "last_updated_at" datetime NOT NULL DEFAULT (datetime('now')),
8551
- "partyId" varchar,
8552
- "owner_id" text,
8553
- "tenant_id" text,
8554
- CONSTRAINT "UQ_Identity_alias" UNIQUE ("alias"),
8555
- CONSTRAINT "FK_Identity_partyId" FOREIGN KEY ("partyId") REFERENCES "Party" ("id") ON DELETE CASCADE ON UPDATE NO ACTION
8556
- )`);
8557
- await queryRunner.query(`INSERT INTO "temporary_Identity"("id", "alias", "roles", "created_at", "last_updated_at", "partyId", "owner_id", "tenant_id", "origin")
8558
- SELECT "id", "alias", "roles", 'EXTERNAL' as "origin", "created_at", "last_updated_at", "partyId", NULL as "owner_id", NULL as "tenant_id" FROM "Identity"`);
8559
- await queryRunner.query(`DROP TABLE "Identity"`);
8560
- await queryRunner.query(`ALTER TABLE "temporary_Identity" RENAME TO "Identity"`);
8561
- await queryRunner.query(`ALTER TABLE "CorrelationIdentifier" ADD COLUMN "owner_id" text`);
8562
- await queryRunner.query(`ALTER TABLE "CorrelationIdentifier" ADD COLUMN "tenant_id" text`);
8563
- await queryRunner.query(`ALTER TABLE "Connection" ADD COLUMN "owner_id" text`);
8564
- await queryRunner.query(`ALTER TABLE "Connection" ADD COLUMN "tenant_id" text`);
8565
- await queryRunner.query(`ALTER TABLE "BaseConfig" ADD COLUMN "owner_id" text`);
8566
- await queryRunner.query(`ALTER TABLE "BaseConfig" ADD COLUMN "tenant_id" text`);
8567
- await queryRunner.query(`ALTER TABLE "BaseContact" ADD COLUMN "owner_id" text`);
8568
- await queryRunner.query(`ALTER TABLE "BaseContact" ADD COLUMN "tenant_id" text`);
8569
- await queryRunner.query(`ALTER TABLE "PartyRelationship" ADD COLUMN "owner_id" text`);
8570
- await queryRunner.query(`ALTER TABLE "PartyRelationship" ADD COLUMN "tenant_id" text`);
8571
- await queryRunner.query(`ALTER TABLE "ElectronicAddress" ADD COLUMN "owner_id" text`);
8572
- await queryRunner.query(`ALTER TABLE "ElectronicAddress" ADD COLUMN "tenant_id" text`);
8573
- await queryRunner.query(`ALTER TABLE "PhysicalAddress" ADD COLUMN "owner_id" text`);
8574
- await queryRunner.query(`ALTER TABLE "PhysicalAddress" ADD COLUMN "tenant_id" text`);
8507
+ await queryRunner.query(`CREATE TABLE "StatusListEntry"
8508
+ (
8509
+ "statusListId" varchar NOT NULL,
8510
+ "statusListIndex" integer NOT NULL,
8511
+ "credentialId" varchar,
8512
+ "credentialHash" varchar(128),
8513
+ "correlationId" varchar(255),
8514
+ "value" varchar(50),
8515
+ PRIMARY KEY ("statusListId", "statusListIndex")
8516
+ )`);
8517
+ await queryRunner.query(`CREATE TABLE "StatusList"
8518
+ (
8519
+ "id" varchar PRIMARY KEY NOT NULL,
8520
+ "correlationId" varchar NOT NULL,
8521
+ "length" integer NOT NULL,
8522
+ "issuer" text NOT NULL,
8523
+ "type" varchar CHECK ( "type" IN ('StatusList2021') ) NOT NULL DEFAULT ('StatusList2021'),
8524
+ "driverType" varchar CHECK ( "driverType" IN ('agent_typeorm', 'agent_kv_store', 'github',
8525
+ 'agent_filesystem') ) NOT NULL DEFAULT ('agent_typeorm'),
8526
+ "credentialIdMode" varchar CHECK ( "credentialIdMode" IN ('ISSUANCE', 'PERSISTENCE', 'NEVER') ) NOT NULL DEFAULT ('ISSUANCE'),
8527
+ "proofFormat" varchar CHECK ( "proofFormat" IN ('lds', 'jwt') ) NOT NULL DEFAULT ('lds'),
8528
+ "indexingDirection" varchar CHECK ( "indexingDirection" IN ('rightToLeft') ) NOT NULL DEFAULT ('rightToLeft'),
8529
+ "statusPurpose" varchar NOT NULL DEFAULT ('revocation'),
8530
+ "statusListCredential" text,
8531
+ CONSTRAINT "UQ_correlationId" UNIQUE ("correlationId")
8532
+ )`);
8533
+ await queryRunner.query(`CREATE TABLE "temporary_StatusListEntry"
8534
+ (
8535
+ "statusListId" varchar NOT NULL,
8536
+ "statusListIndex" integer NOT NULL,
8537
+ "credentialId" varchar,
8538
+ "credentialHash" varchar(128),
8539
+ "correlationId" varchar(255),
8540
+ "value" varchar(50),
8541
+ CONSTRAINT "FK_statusListEntry_statusListId" FOREIGN KEY ("statusListId") REFERENCES "StatusList" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION,
8542
+ PRIMARY KEY ("statusListId", "statusListIndex")
8543
+ )`);
8544
+ await queryRunner.query(`INSERT INTO "temporary_StatusListEntry"("statusListId", "statusListIndex", "credentialId",
8545
+ "credentialHash", "correlationId", "value")
8546
+ SELECT "statusListId", "statusListIndex", "credentialId", "credentialHash", "correlationId", "value"
8547
+ FROM "StatusListEntry"`);
8548
+ await queryRunner.query(`DROP TABLE "StatusListEntry"`);
8549
+ await queryRunner.query(`ALTER TABLE "temporary_StatusListEntry" RENAME TO "StatusListEntry"`);
8575
8550
  }
8576
8551
  async down(queryRunner) {
8577
- await queryRunner.query(`ALTER TABLE "PhysicalAddress" DROP COLUMN "tenant_id"`);
8578
- await queryRunner.query(`ALTER TABLE "PhysicalAddress" DROP COLUMN "owner_id"`);
8579
- await queryRunner.query(`ALTER TABLE "ElectronicAddress" DROP COLUMN "tenant_id"`);
8580
- await queryRunner.query(`ALTER TABLE "ElectronicAddress" DROP COLUMN "owner_id"`);
8581
- await queryRunner.query(`ALTER TABLE "PartyRelationship" DROP COLUMN "tenant_id"`);
8582
- await queryRunner.query(`ALTER TABLE "PartyRelationship" DROP COLUMN "owner_id"`);
8583
- await queryRunner.query(`ALTER TABLE "BaseContact" DROP COLUMN "tenant_id"`);
8584
- await queryRunner.query(`ALTER TABLE "BaseContact" DROP COLUMN "owner_id"`);
8585
- await queryRunner.query(`ALTER TABLE "BaseConfig" DROP COLUMN "tenant_id"`);
8586
- await queryRunner.query(`ALTER TABLE "BaseConfig" DROP COLUMN "owner_id"`);
8587
- await queryRunner.query(`ALTER TABLE "Connection" DROP COLUMN "tenant_id"`);
8588
- await queryRunner.query(`ALTER TABLE "Connection" DROP COLUMN "owner_id"`);
8589
- await queryRunner.query(`ALTER TABLE "CorrelationIdentifier" DROP COLUMN "tenant_id"`);
8590
- await queryRunner.query(`ALTER TABLE "CorrelationIdentifier" DROP COLUMN "owner_id"`);
8591
- await queryRunner.query(`ALTER TABLE "Identity" DROP COLUMN "tenant_id"`);
8592
- await queryRunner.query(`ALTER TABLE "Identity" DROP COLUMN "owner_id"`);
8593
- await queryRunner.query(`ALTER TABLE "Party" DROP COLUMN "tenant_id"`);
8594
- await queryRunner.query(`ALTER TABLE "Party" DROP COLUMN "owner_id"`);
8552
+ await queryRunner.query(`DROP TABLE "StatusListEntry"`);
8553
+ await queryRunner.query(`DROP TABLE "StatusList"`);
8554
+ }
8555
+ };
8556
+
8557
+ // src/migrations/postgres/1737110469001-UpdateStatusList.ts
8558
+ var UpdateStatusList1737110469001 = class {
8559
+ static {
8560
+ __name(this, "UpdateStatusList1737110469001");
8561
+ }
8562
+ name = "UpdateStatusList1737110469001";
8563
+ async up(queryRunner) {
8564
+ await queryRunner.query(`ALTER TYPE "StatusList_type_enum" ADD VALUE 'OAuthStatusList'`);
8565
+ await queryRunner.query(`ALTER TABLE "StatusList" ALTER COLUMN "indexingDirection" DROP NOT NULL`);
8566
+ await queryRunner.query(`ALTER TABLE "StatusList" ALTER COLUMN "statusPurpose" DROP NOT NULL`);
8567
+ await queryRunner.query(`ALTER TABLE "StatusList" ADD "bitsPerStatus" integer DEFAULT 1`);
8568
+ await queryRunner.query(`ALTER TABLE "StatusList" ADD "expiresAt" timestamp with time zone`);
8569
+ }
8570
+ async down(queryRunner) {
8571
+ await queryRunner.query(`ALTER TABLE "StatusList" DROP COLUMN "expiresAt"`);
8572
+ await queryRunner.query(`ALTER TABLE "StatusList" DROP COLUMN "bitsPerStatus"`);
8573
+ await queryRunner.query(`ALTER TABLE "StatusList" ALTER COLUMN "statusPurpose" SET NOT NULL`);
8574
+ await queryRunner.query(`ALTER TABLE "StatusList" ALTER COLUMN "indexingDirection" SET NOT NULL`);
8575
+ }
8576
+ };
8577
+
8578
+ // src/migrations/sqlite/1737110469000-UpdateStatusList.ts
8579
+ var UpdateStatusList1737110469000 = class {
8580
+ static {
8581
+ __name(this, "UpdateStatusList1737110469000");
8582
+ }
8583
+ name = "UpdateStatusList1737110469000";
8584
+ async up(queryRunner) {
8585
+ await queryRunner.query(`CREATE TABLE "temporary_StatusList" (
8586
+ "id" varchar PRIMARY KEY NOT NULL,
8587
+ "correlationId" varchar NOT NULL,
8588
+ "length" integer NOT NULL,
8589
+ "issuer" text NOT NULL,
8590
+ "type" varchar CHECK( "type" IN ('StatusList2021', 'OAuthStatusList') ) NOT NULL DEFAULT ('StatusList2021'),
8591
+ "driverType" varchar CHECK( "driverType" IN ('agent_typeorm','agent_kv_store','github','agent_filesystem') ) NOT NULL DEFAULT ('agent_typeorm'),
8592
+ "credentialIdMode" varchar CHECK( "credentialIdMode" IN ('ISSUANCE','PERSISTENCE','NEVER') ) NOT NULL DEFAULT ('ISSUANCE'),
8593
+ "proofFormat" varchar CHECK( "proofFormat" IN ('lds','jwt') ) NOT NULL DEFAULT ('lds'),
8594
+ "indexingDirection" varchar CHECK( "indexingDirection" IN ('rightToLeft') ),
8595
+ "statusPurpose" varchar,
8596
+ "statusListCredential" text,
8597
+ "bitsPerStatus" integer,
8598
+ "expiresAt" datetime,
8599
+ CONSTRAINT "UQ_correlationId" UNIQUE ("correlationId")
8600
+ )`);
8601
+ await queryRunner.query(`INSERT INTO "temporary_StatusList"(
8602
+ "id", "correlationId", "length", "issuer", "type", "driverType",
8603
+ "credentialIdMode", "proofFormat", "indexingDirection", "statusPurpose",
8604
+ "statusListCredential"
8605
+ )
8606
+ SELECT
8607
+ "id", "correlationId", "length", "issuer", "type", "driverType",
8608
+ "credentialIdMode", "proofFormat", "indexingDirection", "statusPurpose",
8609
+ "statusListCredential"
8610
+ FROM "StatusList"`);
8611
+ await queryRunner.query(`DROP TABLE "StatusList"`);
8612
+ await queryRunner.query(`ALTER TABLE "temporary_StatusList" RENAME TO "StatusList"`);
8613
+ }
8614
+ async down(queryRunner) {
8615
+ await queryRunner.query(`
8616
+ ALTER TABLE "StatusListEntry"
8617
+ RENAME COLUMN "entryCorrelationId" TO "correlationId"
8618
+ `);
8619
+ await queryRunner.query(`
8620
+ ALTER TABLE "StatusListEntry"
8621
+ DROP COLUMN "statusListCorrelationId"
8622
+ `);
8623
+ await queryRunner.query(`CREATE TABLE "temporary_StatusList" (
8624
+ "id" varchar PRIMARY KEY NOT NULL,
8625
+ "correlationId" varchar NOT NULL,
8626
+ "length" integer NOT NULL,
8627
+ "issuer" text NOT NULL,
8628
+ "type" varchar CHECK( "type" IN ('StatusList2021') ) NOT NULL DEFAULT ('StatusList2021'),
8629
+ "driverType" varchar CHECK( "driverType" IN ('agent_typeorm','agent_kv_store','github','agent_filesystem') ) NOT NULL DEFAULT ('agent_typeorm'),
8630
+ "credentialIdMode" varchar CHECK( "credentialIdMode" IN ('ISSUANCE','PERSISTENCE','NEVER') ) NOT NULL DEFAULT ('ISSUANCE'),
8631
+ "proofFormat" varchar CHECK( "proofFormat" IN ('lds','jwt') ) NOT NULL DEFAULT ('lds'),
8632
+ "indexingDirection" varchar CHECK( "indexingDirection" IN ('rightToLeft') ) NOT NULL DEFAULT ('rightToLeft'),
8633
+ "statusPurpose" varchar NOT NULL DEFAULT ('revocation'),
8634
+ "statusListCredential" text,
8635
+ CONSTRAINT "UQ_correlationId" UNIQUE ("correlationId")
8636
+ )`);
8637
+ await queryRunner.query(`INSERT INTO "temporary_StatusList"(
8638
+ "id", "correlationId", "length", "issuer", "type", "driverType",
8639
+ "credentialIdMode", "proofFormat", "indexingDirection", "statusPurpose",
8640
+ "statusListCredential"
8641
+ )
8642
+ SELECT
8643
+ "id", "correlationId", "length", "issuer",
8644
+ CASE WHEN "type" = 'OAuthStatusList' THEN 'StatusList2021' ELSE "type" END,
8645
+ "driverType", "credentialIdMode", "proofFormat", "indexingDirection",
8646
+ COALESCE("statusPurpose", 'revocation'), "statusListCredential"
8647
+ FROM "StatusList"`);
8648
+ await queryRunner.query(`DROP TABLE "StatusList"`);
8649
+ await queryRunner.query(`ALTER TABLE "temporary_StatusList" RENAME TO "StatusList"`);
8595
8650
  }
8596
8651
  };
8597
8652
 
8598
- // src/migrations/generic/8-CreateContacts.ts
8653
+ // src/migrations/generic/4-CreateStatusList.ts
8599
8654
  var debug15 = (0, import_debug15.default)("sphereon:ssi-sdk:migrations");
8600
- var CreateContacts1708525189000 = class {
8655
+ var CreateStatusList1693866470000 = class {
8601
8656
  static {
8602
- __name(this, "CreateContacts1708525189000");
8657
+ __name(this, "CreateStatusList1693866470000");
8603
8658
  }
8604
- name = "CreateContacts1708525189000";
8659
+ name = "CreateStatusList1693866470000";
8605
8660
  async up(queryRunner) {
8606
- debug15("migration: updating contact tables");
8661
+ debug15("migration: creating issuance branding tables");
8607
8662
  const dbType = queryRunner.connection.driver.options.type;
8608
- switch (dbType) {
8609
- case "postgres": {
8610
- debug15("using postgres migration file");
8611
- const mig = new CreateContacts1710438363001();
8612
- await mig.up(queryRunner);
8613
- debug15("Migration statements executed");
8614
- return;
8615
- }
8616
- case "sqlite":
8617
- case "expo":
8618
- case "react-native": {
8619
- debug15("using sqlite/react-native migration file");
8620
- const mig = new CreateContacts1710438363002();
8621
- await mig.up(queryRunner);
8622
- debug15("Migration statements executed");
8623
- return;
8624
- }
8625
- default:
8626
- 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`);
8663
+ if (dbType === "postgres") {
8664
+ debug15("using postgres migration files");
8665
+ const createMig = new CreateStatusList1693866470001();
8666
+ await createMig.up(queryRunner);
8667
+ const updateMig = new UpdateStatusList1737110469001();
8668
+ const up = await updateMig.up(queryRunner);
8669
+ debug15("Migration statements executed");
8670
+ return up;
8671
+ } else if (dbType === "sqlite" || dbType === "react-native" || dbType === "expo") {
8672
+ debug15("using sqlite/react-native migration files");
8673
+ const createMig = new CreateStatusList1693866470002();
8674
+ await createMig.up(queryRunner);
8675
+ const updateMig = new UpdateStatusList1737110469000();
8676
+ const up = await updateMig.up(queryRunner);
8677
+ debug15("Migration statements executed");
8678
+ return up;
8679
+ } else {
8680
+ 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`);
8627
8681
  }
8628
8682
  }
8629
8683
  async down(queryRunner) {
8630
- debug15("migration: reverting machine state tables");
8684
+ debug15("migration: reverting issuance branding tables");
8631
8685
  const dbType = queryRunner.connection.driver.options.type;
8632
- switch (dbType) {
8633
- case "postgres": {
8634
- debug15("using postgres migration file");
8635
- const mig = new CreateContacts1710438363001();
8636
- await mig.down(queryRunner);
8637
- debug15("Migration statements executed");
8638
- return;
8639
- }
8640
- case "sqlite":
8641
- case "expo":
8642
- case "react-native": {
8643
- debug15("using sqlite/react-native migration file");
8644
- const mig = new CreateContacts1710438363002();
8645
- await mig.down(queryRunner);
8646
- debug15("Migration statements executed");
8647
- return;
8648
- }
8649
- default:
8650
- 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`);
8686
+ if (dbType === "postgres") {
8687
+ debug15("using postgres migration files");
8688
+ const updateMig = new UpdateStatusList1737110469001();
8689
+ await updateMig.down(queryRunner);
8690
+ const createMig = new CreateStatusList1693866470001();
8691
+ const down = await createMig.down(queryRunner);
8692
+ debug15("Migration statements executed");
8693
+ return down;
8694
+ } else if (dbType === "sqlite" || dbType === "react-native" || dbType === "expo") {
8695
+ debug15("using sqlite/react-native migration files");
8696
+ const updateMig = new UpdateStatusList1737110469000();
8697
+ await updateMig.down(queryRunner);
8698
+ const createMig = new CreateStatusList1693866470002();
8699
+ const down = await createMig.down(queryRunner);
8700
+ debug15("Migration statements executed");
8701
+ return down;
8702
+ } else {
8703
+ 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`);
8651
8704
  }
8652
8705
  }
8653
8706
  };
8654
8707
 
8655
- // src/migrations/generic/9-CreateContacts.ts
8708
+ // src/migrations/generic/5-CreateAuditEvents.ts
8656
8709
  var import_debug16 = __toESM(require("debug"), 1);
8657
8710
 
8658
- // src/migrations/postgres/1715761125001-CreateContacts.ts
8659
- var CreateContacts1715761125001 = class {
8711
+ // src/migrations/sqlite/1701634819487-CreateAuditEvents.ts
8712
+ var CreateAuditEvents1701634819487 = class {
8660
8713
  static {
8661
- __name(this, "CreateContacts1715761125001");
8714
+ __name(this, "CreateAuditEvents1701634819487");
8662
8715
  }
8663
- name = "CreateContacts1715761125001";
8716
+ name = "CreateAuditEvents1701634819487";
8664
8717
  async up(queryRunner) {
8665
- await queryRunner.query(`ALTER TABLE "IdentityMetadata" RENAME TO "temporary_IdentityMetadata"`);
8666
- await queryRunner.query(`CREATE TABLE "IdentityMetadata"
8667
- (
8668
- "id" uuid PRIMARY KEY NOT NULL DEFAULT uuid_generate_v4(),
8669
- "label" character varying(255) NOT NULL,
8670
- "valueType" character varying NOT NULL,
8671
- "stringValue" text,
8672
- "numberValue" double precision,
8673
- "dateValue" TIMESTAMP,
8674
- "boolValue" boolean,
8675
- "identityId" uuid,
8676
- CONSTRAINT "FK_Identity_IdentityMetadata" FOREIGN KEY ("identityId") REFERENCES "Identity" ("id") ON DELETE CASCADE
8677
- )`);
8678
- await queryRunner.query(`INSERT INTO "IdentityMetadata" ("id", "label", "valueType", "stringValue", "identityId")
8679
- SELECT "id", "label", 'string', "value", "identityId"
8680
- FROM "temporary_IdentityMetadata"`);
8681
- await queryRunner.query(`DROP TABLE "temporary_IdentityMetadata"`);
8682
- await queryRunner.query(`CREATE TABLE "ContactMetadata"
8683
- (
8684
- "id" uuid PRIMARY KEY NOT NULL DEFAULT uuid_generate_v4(),
8685
- "label" character varying(255) NOT NULL,
8686
- "valueType" character varying NOT NULL,
8687
- "stringValue" text,
8688
- "numberValue" double precision,
8689
- "dateValue" TIMESTAMP,
8690
- "boolValue" boolean,
8691
- "contactId" uuid,
8692
- CONSTRAINT "FK_BaseContact_ContactMetadata" FOREIGN KEY ("contactId") REFERENCES "BaseContact" ("id") ON DELETE CASCADE
8693
- )`);
8718
+ await queryRunner.query(`CREATE TABLE "AuditEvents" (
8719
+ "id" varchar PRIMARY KEY NOT NULL,
8720
+ "eventType" varchar CHECK( "eventType" IN ('audit','activity','general') ) NOT NULL,
8721
+ "timestamp" datetime NOT NULL,
8722
+ "level" varchar CHECK( "level" IN ('0','1','2','3','4') ) NOT NULL,
8723
+ "correlationId" varchar NOT NULL,
8724
+ "system" varchar CHECK( "system" IN ('general','kms','identity','oid4vci','oid4vp','siopv2','PE','credentials','web3','profile','contact') ) NOT NULL,
8725
+ "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,
8726
+ "actionType" varchar CHECK( "actionType" IN ('create','read','update','delete','execute') ) NOT NULL,
8727
+ "actionSubType" varchar NOT NULL,
8728
+ "initiatorType" varchar CHECK( "initiatorType" IN ('user','system','external') ) NOT NULL,
8729
+ "systemCorrelationIdType" varchar CHECK( "systemCorrelationIdType" IN ('did','url','email','hostname','phone','user') ),
8730
+ "systemCorrelationId" varchar,
8731
+ "systemAlias" varchar,
8732
+ "partyCorrelationType" varchar CHECK( "partyCorrelationType" IN ('did','url','email','hostname','phone') ),
8733
+ "partyCorrelationId" varchar,
8734
+ "partyAlias" varchar,
8735
+ "credentialType" varchar CHECK( "credentialType" IN ('JSON_LD','JWT','SD_JWT','MSO_MDOC') ),
8736
+ "credentialHash" varchar,
8737
+ "parentCredentialHash" varchar,
8738
+ "originalCredential" varchar,
8739
+ "sharePurpose" varchar,
8740
+ "description" varchar NOT NULL,
8741
+ "data" varchar,
8742
+ "diagnosticData" varchar,
8743
+ "created_at" datetime NOT NULL DEFAULT (datetime('now')),
8744
+ "last_updated_at" datetime NOT NULL DEFAULT (datetime('now')))`);
8694
8745
  }
8695
8746
  async down(queryRunner) {
8696
- await queryRunner.query(`DROP TABLE "ContactMetadata"`);
8697
- await queryRunner.query(`ALTER TABLE "IdentityMetadata" RENAME TO "temporary_IdentityMetadata"`);
8698
- await queryRunner.query(`CREATE TABLE "IdentityMetadata"
8699
- (
8700
- "id" uuid PRIMARY KEY NOT NULL DEFAULT uuid_generate_v4(),
8701
- "label" character varying(255) NOT NULL,
8702
- "value" character varying(255) NOT NULL,
8703
- "identityId" uuid,
8704
- CONSTRAINT "FK_Identity_IdentityMetadata" FOREIGN KEY ("identityId") REFERENCES "Identity" ("id") ON DELETE CASCADE
8705
- )`);
8706
- await queryRunner.query(`INSERT INTO "IdentityMetadata" ("id", "label", "value", "identityId")
8707
- SELECT "id", "label", "stringValue", "identityId"
8708
- FROM "temporary_IdentityMetadata"`);
8709
- await queryRunner.query(`DROP TABLE "temporary_IdentityMetadata"`);
8747
+ await queryRunner.query(`DROP TABLE "AuditEvents"`);
8710
8748
  }
8711
8749
  };
8712
8750
 
8713
- // src/migrations/sqlite/1715761125002-CreateContacts.ts
8714
- var CreateContacts1715761125002 = class {
8751
+ // src/migrations/postgres/1701634812183-CreateAuditEvents.ts
8752
+ var CreateAuditEvents1701634812183 = class {
8715
8753
  static {
8716
- __name(this, "CreateContacts1715761125002");
8754
+ __name(this, "CreateAuditEvents1701634812183");
8717
8755
  }
8718
- name = "CreateContacts1715761125002";
8756
+ name = "CreateAuditEvents1701634812183";
8719
8757
  async up(queryRunner) {
8720
- await queryRunner.query(`ALTER TABLE "IdentityMetadata" RENAME TO "temporary_IdentityMetadata"`);
8721
- await queryRunner.query(`CREATE TABLE "IdentityMetadata"
8722
- (
8723
- "id" varchar PRIMARY KEY NOT NULL,
8724
- "label" varchar(255) NOT NULL,
8725
- "valueType" varchar NOT NULL,
8726
- "stringValue" varchar(255),
8727
- "numberValue" double,
8728
- "dateValue" datetime,
8729
- "boolValue" boolean,
8730
- "identityId" varchar,
8731
- FOREIGN KEY ("identityId") REFERENCES "Identity" ("id") ON DELETE CASCADE)`);
8732
- await queryRunner.query(`INSERT INTO "IdentityMetadata" ("id", "label", "valueType", "stringValue", "identityId")
8733
- SELECT "id", "label", 'string', "value", "identityId"
8734
- FROM "temporary_IdentityMetadata"
8735
- `);
8736
- await queryRunner.query(`DROP TABLE "temporary_IdentityMetadata"`);
8737
- await queryRunner.query(`CREATE TABLE "ContactMetadata"
8738
- (
8739
- "id" varchar PRIMARY KEY NOT NULL,
8740
- "label" varchar(255) NOT NULL,
8741
- "valueType" varchar NOT NULL,
8742
- "stringValue" text,
8743
- "numberValue" double,
8744
- "dateValue" datetime,
8745
- "boolValue" boolean,
8746
- "contactId" varchar,
8747
- FOREIGN KEY ("contactId") REFERENCES "BaseContact" ("id") ON DELETE CASCADE)`);
8758
+ await queryRunner.query(`CREATE TYPE "public"."Level_enum" AS ENUM('0', '1', '2', '3', '4')`);
8759
+ await queryRunner.query(`CREATE TYPE "public"."System_enum" AS ENUM('general', 'kms', 'identity', 'oid4vci', 'oid4vp', 'siopv2', 'PE', 'credentials', 'web3', 'profile', 'contact')`);
8760
+ 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')`);
8761
+ await queryRunner.query(`CREATE TYPE "public"."Action_type_enum" AS ENUM('create', 'read', 'update', 'delete', 'execute')`);
8762
+ await queryRunner.query(`CREATE TYPE "public"."Initiator_type_enum" AS ENUM('user', 'system', 'external')`);
8763
+ await queryRunner.query(`CREATE TYPE "public"."System_correlation_id_type_enum" AS ENUM('did', 'url', 'email', 'hostname', 'phone', 'user')`);
8764
+ await queryRunner.query(`CREATE TYPE "public"."Party_correlation_type_enum" AS ENUM('did', 'url', 'email', 'hostname', 'phone')`);
8765
+ await queryRunner.query(`CREATE TYPE "public"."Event_type_enum" AS ENUM('audit', 'activity', 'general')`);
8766
+ await queryRunner.query(`CREATE TYPE "public"."Event_credential_type_enum" AS ENUM('JSON_LD', 'JWT', 'SD_JWT', 'MSO_MDOC')`);
8767
+ await queryRunner.query(`CREATE TABLE "AuditEvents" (
8768
+ "id" uuid NOT NULL DEFAULT uuid_generate_v4(),
8769
+ "eventType" "public"."Event_type_enum" NOT NULL,
8770
+ "timestamp" TIMESTAMP NOT NULL,
8771
+ "level" "public"."Level_enum" NOT NULL,
8772
+ "correlationId" TEXT NOT NULL,
8773
+ "system" "public"."System_enum" NOT NULL,
8774
+ "subSystemType" "public"."Subsystem_type_enum" NOT NULL,
8775
+ "actionType" "public"."Action_type_enum" NOT NULL,
8776
+ "actionSubType" TEXT NOT NULL,
8777
+ "initiatorType" "public"."Initiator_type_enum" NOT NULL,
8778
+ "systemCorrelationIdType" "public"."System_correlation_id_type_enum",
8779
+ "systemCorrelationId" TEXT,
8780
+ "systemAlias" TEXT,
8781
+ "partyCorrelationType" "public"."Party_correlation_type_enum",
8782
+ "partyCorrelationId" TEXT,
8783
+ "partyAlias" TEXT,
8784
+ "credentialType" "public"."Event_credential_type_enum",
8785
+ "credentialHash" TEXT,
8786
+ "originalCredential" TEXT,
8787
+ "sharePurpose" TEXT,
8788
+ "description" TEXT NOT NULL,
8789
+ "data" TEXT,
8790
+ "diagnosticData" TEXT,
8791
+ "created_at" TIMESTAMP NOT NULL DEFAULT now(),
8792
+ "last_updated_at" TIMESTAMP NOT NULL DEFAULT now(),
8793
+ CONSTRAINT "PK_AuditEvents_id" PRIMARY KEY ("id"))`);
8748
8794
  }
8749
8795
  async down(queryRunner) {
8750
- await queryRunner.query(`DROP TABLE "ContactMetadata"`);
8751
- await queryRunner.query(`ALTER TABLE "IdentityMetadata" RENAME TO "temporary_IdentityMetadata"`);
8752
- await queryRunner.query(`CREATE TABLE "IdentityMetadata"
8753
- (
8754
- "id" varchar PRIMARY KEY NOT NULL,
8755
- "label" varchar(255) NOT NULL,
8756
- "value" varchar(255) NOT NULL,
8757
- "identityId" varchar,
8758
- FOREIGN KEY ("identityId") REFERENCES "Identity" ("id") ON DELETE CASCADE
8759
- )`);
8760
- await queryRunner.query(`INSERT INTO "IdentityMetadata" ("id", "label", "value", "identityId")
8761
- SELECT "id", "label", "stringValue", "identityId"
8762
- FROM "temporary_IdentityMetadata"`);
8763
- await queryRunner.query(`DROP TABLE "temporary_IdentityMetadata"`);
8796
+ await queryRunner.query(`DROP TABLE "AuditEvents"`);
8797
+ await queryRunner.query(`DROP TYPE "public"."Party_correlation_type_enum"`);
8798
+ await queryRunner.query(`DROP TYPE "public"."System_correlation_id_type_enum"`);
8799
+ await queryRunner.query(`DROP TYPE "public"."Initiator_type_enum"`);
8800
+ await queryRunner.query(`DROP TYPE "public"."Action_type_enum"`);
8801
+ await queryRunner.query(`DROP TYPE "public"."Subsystem_type_enum"`);
8802
+ await queryRunner.query(`DROP TYPE "public"."System_enum"`);
8803
+ await queryRunner.query(`DROP TYPE "public"."Level_enum"`);
8764
8804
  }
8765
8805
  };
8766
8806
 
8767
- // src/migrations/generic/9-CreateContacts.ts
8807
+ // src/migrations/generic/5-CreateAuditEvents.ts
8768
8808
  var debug16 = (0, import_debug16.default)("sphereon:ssi-sdk:migrations");
8769
- var CreateContacts1715761125000 = class {
8809
+ var CreateAuditEvents1701635835330 = class {
8770
8810
  static {
8771
- __name(this, "CreateContacts1715761125000");
8811
+ __name(this, "CreateAuditEvents1701635835330");
8772
8812
  }
8773
- name = "CreateContacts1715761125000";
8813
+ name = "CreateAuditEvents1701635835330";
8774
8814
  async up(queryRunner) {
8775
- debug16("migration: updating contact tables");
8815
+ debug16("migration: creating audit events tables");
8776
8816
  const dbType = queryRunner.connection.driver.options.type;
8777
8817
  switch (dbType) {
8778
8818
  case "postgres": {
8779
8819
  debug16("using postgres migration file");
8780
- const mig = new CreateContacts1715761125001();
8820
+ const mig = new CreateAuditEvents1701634812183();
8781
8821
  await mig.up(queryRunner);
8782
8822
  debug16("Migration statements executed");
8783
8823
  return;
@@ -8786,7 +8826,7 @@ var CreateContacts1715761125000 = class {
8786
8826
  case "expo":
8787
8827
  case "react-native": {
8788
8828
  debug16("using sqlite/react-native migration file");
8789
- const mig = new CreateContacts1715761125002();
8829
+ const mig = new CreateAuditEvents1701634819487();
8790
8830
  await mig.up(queryRunner);
8791
8831
  debug16("Migration statements executed");
8792
8832
  return;
@@ -8796,12 +8836,12 @@ var CreateContacts1715761125000 = class {
8796
8836
  }
8797
8837
  }
8798
8838
  async down(queryRunner) {
8799
- debug16("migration: reverting machine state tables");
8839
+ debug16("migration: reverting audit events tables");
8800
8840
  const dbType = queryRunner.connection.driver.options.type;
8801
8841
  switch (dbType) {
8802
8842
  case "postgres": {
8803
8843
  debug16("using postgres migration file");
8804
- const mig = new CreateContacts1715761125001();
8844
+ const mig = new CreateAuditEvents1701634812183();
8805
8845
  await mig.down(queryRunner);
8806
8846
  debug16("Migration statements executed");
8807
8847
  return;
@@ -8810,7 +8850,7 @@ var CreateContacts1715761125000 = class {
8810
8850
  case "expo":
8811
8851
  case "react-native": {
8812
8852
  debug16("using sqlite/react-native migration file");
8813
- const mig = new CreateContacts1715761125002();
8853
+ const mig = new CreateAuditEvents1701634819487();
8814
8854
  await mig.down(queryRunner);
8815
8855
  debug16("Migration statements executed");
8816
8856
  return;
@@ -8821,85 +8861,258 @@ var CreateContacts1715761125000 = class {
8821
8861
  }
8822
8862
  };
8823
8863
 
8824
- // src/migrations/generic/10-CreatePresentationDefinitions.ts
8864
+ // src/migrations/generic/6-CreateDigitalCredential.ts
8825
8865
  var import_debug17 = __toESM(require("debug"), 1);
8826
8866
 
8827
- // src/migrations/postgres/1716475165345-CreatePresentationDefinitions.ts
8828
- var CreatePresentationDefinitions1716475165345 = class {
8867
+ // src/migrations/postgres/1708525189001-CreateDigitalCredential.ts
8868
+ var CreateDigitalCredential1708525189001 = class {
8829
8869
  static {
8830
- __name(this, "CreatePresentationDefinitions1716475165345");
8870
+ __name(this, "CreateDigitalCredential1708525189001");
8831
8871
  }
8832
- name = "CreatePresentationDefinitions1716475165345";
8872
+ name = "CreateDigitalCredential1708525189001";
8833
8873
  async up(queryRunner) {
8874
+ await queryRunner.query(`CREATE TYPE "digital_document_type" AS ENUM('VC', 'VP', 'C', 'P')`);
8875
+ await queryRunner.query(`CREATE TYPE "digital_regulation_type" AS ENUM('PID', 'QEAA', 'EAA', 'NON_REGULATED')`);
8876
+ await queryRunner.query(`CREATE TYPE "digital_credential_document_format" AS ENUM('JSON_LD', 'JWT', 'SD_JWT', 'MSO_MDOC')`);
8877
+ await queryRunner.query(`CREATE TYPE "digital_credential_credential_role" AS ENUM('ISSUER', 'VERIFIER', 'HOLDER', 'FEDERATION_TRUST_ANCHOR')`);
8878
+ await queryRunner.query(`CREATE TYPE "digital_credential_correlation_type" AS ENUM('DID', 'KID', 'URL', 'X509_SAN')`);
8879
+ await queryRunner.query(`CREATE TYPE "digital_credential_state_type" AS ENUM('REVOKED', 'VERIFIED', 'EXPIRED')`);
8834
8880
  await queryRunner.query(`
8835
- CREATE TABLE "PresentationDefinitionItem" (
8836
- "id" uuid NOT NULL DEFAULT uuid_generate_v4(),
8837
- "tenant_id" TEXT,
8838
- "definition_id" TEXT NOT NULL,
8839
- "name" TEXT,
8840
- "version" TEXT NOT NULL,
8841
- "purpose" TEXT,
8842
- "definition_payload" TEXT NOT NULL,
8843
- "dcql_payload" TEXT,
8844
- "created_at" TIMESTAMP NOT NULL DEFAULT now(),
8845
- "last_updated_at" TIMESTAMP NOT NULL DEFAULT now(),
8846
- CONSTRAINT "PK_PresentationDefinitionItem_id" PRIMARY KEY ("id"))
8847
- `);
8881
+ CREATE TABLE "DigitalCredential" (
8882
+ "id" uuid NOT NULL DEFAULT uuid_generate_v4(),
8883
+ "parent_id" text,
8884
+ "document_type" "digital_document_type" NOT NULL,
8885
+ "regulation_type" "digital_regulation_type" NOT NULL DEFAULT 'NON_REGULATED'::"digital_regulation_type",
8886
+ "document_format" "digital_credential_document_format" NOT NULL,
8887
+ "credential_role" "digital_credential_credential_role" NOT NULL,
8888
+ "raw_document" text NOT NULL,
8889
+ "uniform_document" text NOT NULL,
8890
+ "credential_id" text,
8891
+ "hash" text NOT NULL,
8892
+ "kms_key_ref" text,
8893
+ "identifier_method" text,
8894
+ "issuer_correlation_type" "digital_credential_correlation_type" NOT NULL,
8895
+ "subject_correlation_type" "digital_credential_correlation_type",
8896
+ "issuer_correlation_id" text NOT NULL,
8897
+ "subject_correlation_id" text,
8898
+ "verified_state" "digital_credential_state_type",
8899
+ "issuer_signed" boolean,
8900
+ "rp_correlation_id" text,
8901
+ "rp_correlation_type" "digital_credential_correlation_type",
8902
+ "tenant_id" text,
8903
+ "created_at" TIMESTAMP NOT NULL DEFAULT now(),
8904
+ "last_updated_at" TIMESTAMP NOT NULL DEFAULT now(),
8905
+ "presented_at" DATE,
8906
+ "valid_from" DATE,
8907
+ "valid_until" DATE,
8908
+ "verified_at" DATE,
8909
+ "revoked_at" DATE,
8910
+ PRIMARY KEY ("id"),
8911
+ UNIQUE ("hash", "credential_role")
8912
+ )
8913
+ `);
8848
8914
  }
8849
8915
  async down(queryRunner) {
8850
- await queryRunner.query(`DROP TABLE "PresentationDefinitionItem"`);
8916
+ await queryRunner.query(`DROP TABLE "DigitalCredential"`);
8917
+ await queryRunner.query(`DROP TYPE "digital_credential_state_type"`);
8918
+ await queryRunner.query(`DROP TYPE "digital_credential_correlation_type"`);
8919
+ await queryRunner.query(`DROP TYPE "digital_credential_document_format"`);
8920
+ await queryRunner.query(`DROP TYPE "digital_credential_credential_role"`);
8921
+ await queryRunner.query(`DROP TYPE "digital_regulation_type"`);
8922
+ await queryRunner.query(`DROP TYPE "digital_document_type"`);
8851
8923
  }
8852
8924
  };
8853
8925
 
8854
- // src/migrations/sqlite/1716475165344-CreatePresentationDefinitions.ts
8855
- var CreatePresentationDefinitions1716475165344 = class {
8926
+ // src/migrations/sqlite/1708525189002-CreateDigitalCredential.ts
8927
+ var CreateDigitalCredential1708525189002 = class {
8856
8928
  static {
8857
- __name(this, "CreatePresentationDefinitions1716475165344");
8929
+ __name(this, "CreateDigitalCredential1708525189002");
8858
8930
  }
8859
- name = "CreatePresentationDefinitions1716475165344";
8931
+ name = "CreateDigitalCredential1708525189002";
8860
8932
  async up(queryRunner) {
8861
- await queryRunner.query(`CREATE TABLE "PresentationDefinitionItem" (
8862
- "id" varchar PRIMARY KEY NOT NULL,
8863
- "tenant_id" varchar,
8864
- "definition_id" varchar NOT NULL,
8865
- "name" varchar,
8866
- "version" varchar NOT NULL,
8867
- "purpose" varchar,
8868
- "definition_payload" varchar NOT NULL,
8869
- "dcql_payload" varchar,
8870
- "created_at" datetime NOT NULL DEFAULT (datetime('now')),
8871
- "last_updated_at" datetime NOT NULL DEFAULT (datetime('now')))`);
8933
+ await queryRunner.query(`
8934
+ CREATE TABLE "DigitalCredential" (
8935
+ "id" varchar PRIMARY KEY NOT NULL,
8936
+ "parent_id" text,
8937
+ "document_type" varchar CHECK( "document_type" IN ('VC', 'VP', 'C', 'P') ) NOT NULL,
8938
+ "regulation_type" varchar CHECK( "regulation_type" IN ('PID', 'QEAA', 'EAA', 'NON_REGULATED') ) NOT NULL DEFAULT 'NON_REGULATED',
8939
+ "document_format" varchar CHECK( "document_format" IN ('JSON_LD', 'JWT', 'SD_JWT', 'MSO_MDOC') ) NOT NULL,
8940
+ "credential_role" varchar CHECK( "credential_role" IN ('ISSUER', 'VERIFIER', 'HOLDER', 'FEDERATION_TRUST_ANCHOR') ) NOT NULL,
8941
+ "raw_document" text NOT NULL,
8942
+ "uniform_document" text NOT NULL,
8943
+ "credential_id" text,
8944
+ "hash" text NOT NULL,
8945
+ "kms_key_ref" text,
8946
+ "identifier_method" text,
8947
+ "issuer_correlation_type" varchar CHECK( "issuer_correlation_type" IN ('DID', 'KID', 'URL', 'X509_SAN') ) NOT NULL,
8948
+ "subject_correlation_type" varchar CHECK( "subject_correlation_type" IN ('DID', 'KID', 'URL', 'X509_SAN') ),
8949
+ "issuer_correlation_id" text NOT NULL,
8950
+ "subject_correlation_id" text,
8951
+ "issuer_signed" boolean,
8952
+ "rp_correlation_id" text,
8953
+ "rp_correlation_type" varchar CHECK( "issuer_correlation_type" IN ('DID', 'KID', 'URL', 'X509_SAN') ),
8954
+ "verified_state" varchar CHECK( "verified_state" IN ('REVOKED', 'VERIFIED', 'EXPIRED') ),
8955
+ "tenant_id" text,
8956
+ "created_at" datetime NOT NULL DEFAULT (datetime('now')),
8957
+ "last_updated_at" datetime NOT NULL DEFAULT (datetime('now')),
8958
+ "presented_at" datetime,
8959
+ "valid_from" datetime,
8960
+ "valid_until" datetime,
8961
+ "verified_at" datetime,
8962
+ "revoked_at" datetime,
8963
+ UNIQUE ("hash", "credential_role")
8964
+ )
8965
+ `);
8966
+ }
8967
+ async down(queryRunner) {
8968
+ await queryRunner.query(`DROP TABLE "DigitalCredential"`);
8969
+ }
8970
+ };
8971
+
8972
+ // src/migrations/generic/6-CreateDigitalCredential.ts
8973
+ var debug17 = (0, import_debug17.default)("sphereon:ssi-sdk:migrations");
8974
+ var CreateDigitalCredential1708525189000 = class {
8975
+ static {
8976
+ __name(this, "CreateDigitalCredential1708525189000");
8977
+ }
8978
+ name = "CreateDigitalCredential1708525189000";
8979
+ async up(queryRunner) {
8980
+ debug17("migration: creating DigitalCredential tables");
8981
+ const dbType = queryRunner.connection.driver.options.type;
8982
+ switch (dbType) {
8983
+ case "postgres": {
8984
+ debug17("using postgres migration file for DigitalCredential");
8985
+ const mig = new CreateDigitalCredential1708525189001();
8986
+ await mig.up(queryRunner);
8987
+ debug17("Postgres Migration statements for DigitalCredential executed");
8988
+ return;
8989
+ }
8990
+ case "sqlite":
8991
+ case "expo":
8992
+ case "react-native": {
8993
+ debug17("using sqlite/react-native migration file for DigitalCredential");
8994
+ const mig = new CreateDigitalCredential1708525189002();
8995
+ await mig.up(queryRunner);
8996
+ debug17("SQLite Migration statements for DigitalCredential executed");
8997
+ return;
8998
+ }
8999
+ default:
9000
+ 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`);
9001
+ }
9002
+ }
9003
+ async down(queryRunner) {
9004
+ debug17("migration: reverting DigitalCredential tables");
9005
+ const dbType = queryRunner.connection.driver.options.type;
9006
+ switch (dbType) {
9007
+ case "postgres": {
9008
+ debug17("using postgres migration file for DigitalCredential");
9009
+ const mig = new CreateDigitalCredential1708525189001();
9010
+ await mig.down(queryRunner);
9011
+ debug17("Postgres Migration statements for DigitalCredential reverted");
9012
+ return;
9013
+ }
9014
+ case "sqlite":
9015
+ case "expo":
9016
+ case "react-native": {
9017
+ debug17("using sqlite/react-native migration file for DigitalCredential");
9018
+ const mig = new CreateDigitalCredential1708525189002();
9019
+ await mig.down(queryRunner);
9020
+ debug17("SQLite Migration statements for DigitalCredential reverted");
9021
+ return;
9022
+ }
9023
+ default:
9024
+ 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`);
9025
+ }
9026
+ }
9027
+ };
9028
+
9029
+ // src/migrations/generic/7-CreateMachineStateStore.ts
9030
+ var import_debug18 = __toESM(require("debug"), 1);
9031
+
9032
+ // src/migrations/postgres/1708797018115-CreateMachineStateStore.ts
9033
+ var CreateMachineStateStore1708797018115 = class {
9034
+ static {
9035
+ __name(this, "CreateMachineStateStore1708797018115");
9036
+ }
9037
+ name = "CreateMachineStateStore1708797018115";
9038
+ async up(queryRunner) {
9039
+ await queryRunner.query(`
9040
+ CREATE TABLE "MachineStateInfoEntity" (
9041
+ "instance_id" text NOT NULL,
9042
+ "session_id" text,
9043
+ "latest_state_name" text,
9044
+ "machine_name" text NOT NULL,
9045
+ "latest_event_type" text NOT NULL,
9046
+ "state" text NOT NULL,
9047
+ "created_at" TIMESTAMP NOT NULL DEFAULT now(),
9048
+ "updated_at" TIMESTAMP NOT NULL DEFAULT now(),
9049
+ "updated_count" integer NOT NULL DEFAULT 0,
9050
+ "expires_at" TIMESTAMP,
9051
+ "completed_at" TIMESTAMP,
9052
+ "tenant_id" text,
9053
+ CONSTRAINT "PK_MachineStateInfoEntity_id" PRIMARY KEY ("instance_id")
9054
+ )
9055
+ `);
9056
+ }
9057
+ async down(queryRunner) {
9058
+ await queryRunner.query(`DROP TABLE "MachineStateInfoEntity"`);
9059
+ }
9060
+ };
9061
+
9062
+ // src/migrations/sqlite/1708796002272-CreateMachineStateStore.ts
9063
+ var CreateMachineStateStore1708796002272 = class {
9064
+ static {
9065
+ __name(this, "CreateMachineStateStore1708796002272");
9066
+ }
9067
+ name = "CreateMachineStateStore1708796002272";
9068
+ async up(queryRunner) {
9069
+ await queryRunner.query(`
9070
+ CREATE TABLE "MachineStateInfoEntity" (
9071
+ "instance_id" varchar PRIMARY KEY NOT NULL,
9072
+ "session_id" varchar,
9073
+ "machine_name" varchar NOT NULL,
9074
+ "latest_state_name" varchar,
9075
+ "latest_event_type" varchar NOT NULL,
9076
+ "state" text NOT NULL,
9077
+ "created_at" datetime NOT NULL DEFAULT (datetime('now')),
9078
+ "updated_at" datetime NOT NULL DEFAULT (datetime('now')),
9079
+ "updated_count" integer NOT NULL DEFAULT 0,
9080
+ "expires_at" datetime,
9081
+ "completed_at" datetime,
9082
+ "tenant_id" varchar
9083
+ )
9084
+ `);
8872
9085
  }
8873
9086
  async down(queryRunner) {
8874
- await queryRunner.query(`DROP TABLE "PresentationDefinitionItem"`);
9087
+ await queryRunner.query(`DROP TABLE "MachineStateInfoEntity"`);
8875
9088
  }
8876
9089
  };
8877
9090
 
8878
- // src/migrations/generic/10-CreatePresentationDefinitions.ts
8879
- var debug17 = (0, import_debug17.default)("sphereon:ssi-sdk:migrations");
8880
- var CreatePresentationDefinitions1716533767523 = class {
9091
+ // src/migrations/generic/7-CreateMachineStateStore.ts
9092
+ var debug18 = (0, import_debug18.default)("sphereon:ssi-sdk:migrations");
9093
+ var CreateMachineStateStore1708098041262 = class {
8881
9094
  static {
8882
- __name(this, "CreatePresentationDefinitions1716533767523");
9095
+ __name(this, "CreateMachineStateStore1708098041262");
8883
9096
  }
8884
- name = "CreatePresentationDefinitionItems1716533767523";
9097
+ name = "CreateMachineStateStore1708098041262";
8885
9098
  async up(queryRunner) {
8886
- debug17("migration: creating machine state tables");
9099
+ debug18("migration: creating machine state tables");
8887
9100
  const dbType = queryRunner.connection.driver.options.type;
8888
9101
  switch (dbType) {
8889
9102
  case "postgres": {
8890
- debug17("using postgres migration file");
8891
- const mig = new CreatePresentationDefinitions1716475165345();
9103
+ debug18("using postgres migration file");
9104
+ const mig = new CreateMachineStateStore1708797018115();
8892
9105
  await mig.up(queryRunner);
8893
- debug17("Migration statements executed");
9106
+ debug18("Migration statements executed");
8894
9107
  return;
8895
9108
  }
8896
9109
  case "sqlite":
8897
9110
  case "expo":
8898
9111
  case "react-native": {
8899
- debug17("using sqlite/react-native migration file");
8900
- const mig = new CreatePresentationDefinitions1716475165344();
9112
+ debug18("using sqlite/react-native migration file");
9113
+ const mig = new CreateMachineStateStore1708796002272();
8901
9114
  await mig.up(queryRunner);
8902
- debug17("Migration statements executed");
9115
+ debug18("Migration statements executed");
8903
9116
  return;
8904
9117
  }
8905
9118
  default:
@@ -8907,23 +9120,23 @@ var CreatePresentationDefinitions1716533767523 = class {
8907
9120
  }
8908
9121
  }
8909
9122
  async down(queryRunner) {
8910
- debug17("migration: reverting machine state tables");
9123
+ debug18("migration: reverting machine state tables");
8911
9124
  const dbType = queryRunner.connection.driver.options.type;
8912
9125
  switch (dbType) {
8913
9126
  case "postgres": {
8914
- debug17("using postgres migration file");
8915
- const mig = new CreatePresentationDefinitions1716475165345();
9127
+ debug18("using postgres migration file");
9128
+ const mig = new CreateMachineStateStore1708797018115();
8916
9129
  await mig.down(queryRunner);
8917
- debug17("Migration statements executed");
9130
+ debug18("Migration statements executed");
8918
9131
  return;
8919
9132
  }
8920
9133
  case "sqlite":
8921
9134
  case "expo":
8922
9135
  case "react-native": {
8923
- debug17("using sqlite/react-native migration file");
8924
- const mig = new CreatePresentationDefinitions1716475165344();
9136
+ debug18("using sqlite/react-native migration file");
9137
+ const mig = new CreateMachineStateStore1708796002272();
8925
9138
  await mig.down(queryRunner);
8926
- debug17("Migration statements executed");
9139
+ debug18("Migration statements executed");
8927
9140
  return;
8928
9141
  }
8929
9142
  default:
@@ -8932,108 +9145,145 @@ var CreatePresentationDefinitions1716533767523 = class {
8932
9145
  }
8933
9146
  };
8934
9147
 
8935
- // src/migrations/generic/11-FixCredentialClaimsReferenceUuid.ts
8936
- var import_debug18 = __toESM(require("debug"), 1);
9148
+ // src/migrations/generic/8-CreateContacts.ts
9149
+ var import_debug19 = __toESM(require("debug"), 1);
8937
9150
 
8938
- // src/migrations/postgres/1741895822987-FixCredentialClaimsReferencesUuid.ts
8939
- var FixCredentialClaimsReferencesUuidPG1741895822987 = class {
9151
+ // src/migrations/postgres/1710438363001-CreateContacts.ts
9152
+ var CreateContacts1710438363001 = class {
8940
9153
  static {
8941
- __name(this, "FixCredentialClaimsReferencesUuidPG1741895822987");
9154
+ __name(this, "CreateContacts1710438363001");
8942
9155
  }
8943
- name = "FixCredentialClaimsReferencesUuid1741895822987";
9156
+ name = "CreateContacts1710438363001";
8944
9157
  async up(queryRunner) {
8945
- await queryRunner.query(`
8946
- ALTER TABLE "CredentialClaims"
8947
- ALTER COLUMN "credentialLocaleBrandingId" TYPE uuid USING "credentialLocaleBrandingId"::uuid;
8948
- `);
9158
+ await queryRunner.query(`ALTER TABLE "Party" ADD COLUMN "owner_id" uuid`);
9159
+ await queryRunner.query(`ALTER TABLE "Party" ADD COLUMN "tenant_id" uuid`);
9160
+ await queryRunner.query(`ALTER TABLE "Identity" ADD COLUMN "owner_id" uuid`);
9161
+ await queryRunner.query(`ALTER TABLE "Identity" ADD COLUMN "tenant_id" uuid`);
9162
+ await queryRunner.query(`ALTER TABLE "CorrelationIdentifier" ADD COLUMN "owner_id" uuid`);
9163
+ await queryRunner.query(`ALTER TABLE "CorrelationIdentifier" ADD COLUMN "tenant_id" uuid`);
9164
+ await queryRunner.query(`ALTER TABLE "Connection" ADD COLUMN "owner_id" uuid`);
9165
+ await queryRunner.query(`ALTER TABLE "Connection" ADD COLUMN "tenant_id" uuid`);
9166
+ await queryRunner.query(`ALTER TABLE "BaseConfig" ADD COLUMN "owner_id" uuid`);
9167
+ await queryRunner.query(`ALTER TABLE "BaseConfig" ADD COLUMN "tenant_id" uuid`);
9168
+ await queryRunner.query(`ALTER TABLE "BaseContact" ADD COLUMN "owner_id" uuid`);
9169
+ await queryRunner.query(`ALTER TABLE "BaseContact" ADD COLUMN "tenant_id" uuid`);
9170
+ await queryRunner.query(`ALTER TABLE "PartyRelationship" ADD COLUMN "owner_id" uuid`);
9171
+ await queryRunner.query(`ALTER TABLE "PartyRelationship" ADD COLUMN "tenant_id" uuid`);
9172
+ await queryRunner.query(`ALTER TABLE "ElectronicAddress" ADD COLUMN "owner_id" uuid`);
9173
+ await queryRunner.query(`ALTER TABLE "ElectronicAddress" ADD COLUMN "tenant_id" uuid`);
9174
+ await queryRunner.query(`ALTER TABLE "PhysicalAddress" ADD COLUMN "owner_id" uuid`);
9175
+ await queryRunner.query(`ALTER TABLE "PhysicalAddress" ADD COLUMN "tenant_id" uuid`);
8949
9176
  }
8950
9177
  async down(queryRunner) {
8951
- await queryRunner.query(`
8952
- ALTER TABLE "CredentialClaims"
8953
- ALTER COLUMN "credentialLocaleBrandingId" TYPE character varying USING "credentialLocaleBrandingId"::text;
8954
- `);
9178
+ await queryRunner.query(`ALTER TABLE "PhysicalAddress" DROP COLUMN "tenant_id"`);
9179
+ await queryRunner.query(`ALTER TABLE "PhysicalAddress" DROP COLUMN "owner_id"`);
9180
+ await queryRunner.query(`ALTER TABLE "ElectronicAddress" DROP COLUMN "tenant_id"`);
9181
+ await queryRunner.query(`ALTER TABLE "ElectronicAddress" DROP COLUMN "owner_id"`);
9182
+ await queryRunner.query(`ALTER TABLE "PartyRelationship" DROP COLUMN "tenant_id"`);
9183
+ await queryRunner.query(`ALTER TABLE "PartyRelationship" DROP COLUMN "owner_id"`);
9184
+ await queryRunner.query(`ALTER TABLE "BaseContact" DROP COLUMN "tenant_id"`);
9185
+ await queryRunner.query(`ALTER TABLE "BaseContact" DROP COLUMN "owner_id"`);
9186
+ await queryRunner.query(`ALTER TABLE "BaseConfig" DROP COLUMN "tenant_id"`);
9187
+ await queryRunner.query(`ALTER TABLE "BaseConfig" DROP COLUMN "owner_id"`);
9188
+ await queryRunner.query(`ALTER TABLE "Connection" DROP COLUMN "tenant_id"`);
9189
+ await queryRunner.query(`ALTER TABLE "Connection" DROP COLUMN "owner_id"`);
9190
+ await queryRunner.query(`ALTER TABLE "CorrelationIdentifier" DROP COLUMN "tenant_id"`);
9191
+ await queryRunner.query(`ALTER TABLE "CorrelationIdentifier" DROP COLUMN "owner_id"`);
9192
+ await queryRunner.query(`ALTER TABLE "Identity" DROP COLUMN "tenant_id"`);
9193
+ await queryRunner.query(`ALTER TABLE "Identity" DROP COLUMN "owner_id"`);
9194
+ await queryRunner.query(`ALTER TABLE "Party" DROP COLUMN "tenant_id"`);
9195
+ await queryRunner.query(`ALTER TABLE "Party" DROP COLUMN "owner_id"`);
8955
9196
  }
8956
9197
  };
8957
9198
 
8958
- // src/migrations/sqlite/1741895822987-FixCredentialClaimsReferencesUuid.ts
8959
- var FixCredentialClaimsReferencesUuidSqlite1741895822987 = class {
9199
+ // src/migrations/sqlite/1710438363002-CreateContacts.ts
9200
+ var CreateContacts1710438363002 = class {
8960
9201
  static {
8961
- __name(this, "FixCredentialClaimsReferencesUuidSqlite1741895822987");
9202
+ __name(this, "CreateContacts1710438363002");
8962
9203
  }
8963
- name = "FixCredentialClaimsReferencesUuid1741895822987";
9204
+ name = "CreateContacts1710438363002";
8964
9205
  async up(queryRunner) {
8965
- await queryRunner.query(`
8966
- CREATE TABLE "CredentialClaims_new"
8967
- (
8968
- "id" uuid NOT NULL DEFAULT (lower(hex(randomblob(16)))),
8969
- "key" character varying(255) NOT NULL,
8970
- "name" character varying(255) NOT NULL,
8971
- "credentialLocaleBrandingId" uuid,
8972
- CONSTRAINT "PK_CredentialClaims_id" PRIMARY KEY ("id")
8973
- )
8974
- `);
8975
- await queryRunner.query(`
8976
- INSERT INTO "CredentialClaims_new" ("id", "key", "name", "credentialLocaleBrandingId")
8977
- SELECT "id", "key", "name", "credentialLocaleBrandingId"
8978
- FROM "CredentialClaims"
8979
- `);
8980
- await queryRunner.query(`DROP TABLE "CredentialClaims"`);
8981
- await queryRunner.query(`ALTER TABLE "CredentialClaims_new" RENAME TO "CredentialClaims"`);
8982
- await queryRunner.query(`
8983
- CREATE UNIQUE INDEX "IDX_CredentialClaimsEntity_credentialLocaleBranding_locale"
8984
- ON "CredentialClaims" ("credentialLocaleBrandingId", "key")
8985
- `);
9206
+ await queryRunner.query(`ALTER TABLE "Party" ADD COLUMN "owner_id" text`);
9207
+ await queryRunner.query(`ALTER TABLE "Party" ADD COLUMN "tenant_id" text`);
9208
+ await queryRunner.query(`CREATE TABLE "temporary_Identity" (
9209
+ "id" varchar PRIMARY KEY NOT NULL,
9210
+ "alias" varchar(255) NOT NULL,
9211
+ "roles" text NOT NULL,
9212
+ "origin" text NOT NULL,
9213
+ "created_at" datetime NOT NULL DEFAULT (datetime('now')),
9214
+ "last_updated_at" datetime NOT NULL DEFAULT (datetime('now')),
9215
+ "partyId" varchar,
9216
+ "owner_id" text,
9217
+ "tenant_id" text,
9218
+ CONSTRAINT "UQ_Identity_alias" UNIQUE ("alias"),
9219
+ CONSTRAINT "FK_Identity_partyId" FOREIGN KEY ("partyId") REFERENCES "Party" ("id") ON DELETE CASCADE ON UPDATE NO ACTION
9220
+ )`);
9221
+ await queryRunner.query(`INSERT INTO "temporary_Identity"("id", "alias", "roles", "created_at", "last_updated_at", "partyId", "owner_id", "tenant_id", "origin")
9222
+ SELECT "id", "alias", "roles", 'EXTERNAL' as "origin", "created_at", "last_updated_at", "partyId", NULL as "owner_id", NULL as "tenant_id" FROM "Identity"`);
9223
+ await queryRunner.query(`DROP TABLE "Identity"`);
9224
+ await queryRunner.query(`ALTER TABLE "temporary_Identity" RENAME TO "Identity"`);
9225
+ await queryRunner.query(`ALTER TABLE "CorrelationIdentifier" ADD COLUMN "owner_id" text`);
9226
+ await queryRunner.query(`ALTER TABLE "CorrelationIdentifier" ADD COLUMN "tenant_id" text`);
9227
+ await queryRunner.query(`ALTER TABLE "Connection" ADD COLUMN "owner_id" text`);
9228
+ await queryRunner.query(`ALTER TABLE "Connection" ADD COLUMN "tenant_id" text`);
9229
+ await queryRunner.query(`ALTER TABLE "BaseConfig" ADD COLUMN "owner_id" text`);
9230
+ await queryRunner.query(`ALTER TABLE "BaseConfig" ADD COLUMN "tenant_id" text`);
9231
+ await queryRunner.query(`ALTER TABLE "BaseContact" ADD COLUMN "owner_id" text`);
9232
+ await queryRunner.query(`ALTER TABLE "BaseContact" ADD COLUMN "tenant_id" text`);
9233
+ await queryRunner.query(`ALTER TABLE "PartyRelationship" ADD COLUMN "owner_id" text`);
9234
+ await queryRunner.query(`ALTER TABLE "PartyRelationship" ADD COLUMN "tenant_id" text`);
9235
+ await queryRunner.query(`ALTER TABLE "ElectronicAddress" ADD COLUMN "owner_id" text`);
9236
+ await queryRunner.query(`ALTER TABLE "ElectronicAddress" ADD COLUMN "tenant_id" text`);
9237
+ await queryRunner.query(`ALTER TABLE "PhysicalAddress" ADD COLUMN "owner_id" text`);
9238
+ await queryRunner.query(`ALTER TABLE "PhysicalAddress" ADD COLUMN "tenant_id" text`);
8986
9239
  }
8987
9240
  async down(queryRunner) {
8988
- await queryRunner.query(`
8989
- CREATE TABLE "CredentialClaims_old"
8990
- (
8991
- "id" uuid NOT NULL DEFAULT (lower(hex(randomblob(16)))),
8992
- "key" character varying(255) NOT NULL,
8993
- "name" character varying(255) NOT NULL,
8994
- "credentialLocaleBrandingId" character varying,
8995
- CONSTRAINT "PK_CredentialClaims_id" PRIMARY KEY ("id")
8996
- )
8997
- `);
8998
- await queryRunner.query(`
8999
- INSERT INTO "CredentialClaims_old" ("id", "key", "name", "credentialLocaleBrandingId")
9000
- SELECT "id", "key", "name", "credentialLocaleBrandingId"
9001
- FROM "CredentialClaims"
9002
- `);
9003
- await queryRunner.query(`DROP TABLE "CredentialClaims"`);
9004
- await queryRunner.query(`ALTER TABLE "CredentialClaims_old" RENAME TO "CredentialClaims"`);
9005
- await queryRunner.query(`
9006
- CREATE UNIQUE INDEX "IDX_CredentialClaimsEntity_credentialLocaleBranding_locale"
9007
- ON "CredentialClaims" ("credentialLocaleBrandingId", "key")
9008
- `);
9241
+ await queryRunner.query(`ALTER TABLE "PhysicalAddress" DROP COLUMN "tenant_id"`);
9242
+ await queryRunner.query(`ALTER TABLE "PhysicalAddress" DROP COLUMN "owner_id"`);
9243
+ await queryRunner.query(`ALTER TABLE "ElectronicAddress" DROP COLUMN "tenant_id"`);
9244
+ await queryRunner.query(`ALTER TABLE "ElectronicAddress" DROP COLUMN "owner_id"`);
9245
+ await queryRunner.query(`ALTER TABLE "PartyRelationship" DROP COLUMN "tenant_id"`);
9246
+ await queryRunner.query(`ALTER TABLE "PartyRelationship" DROP COLUMN "owner_id"`);
9247
+ await queryRunner.query(`ALTER TABLE "BaseContact" DROP COLUMN "tenant_id"`);
9248
+ await queryRunner.query(`ALTER TABLE "BaseContact" DROP COLUMN "owner_id"`);
9249
+ await queryRunner.query(`ALTER TABLE "BaseConfig" DROP COLUMN "tenant_id"`);
9250
+ await queryRunner.query(`ALTER TABLE "BaseConfig" DROP COLUMN "owner_id"`);
9251
+ await queryRunner.query(`ALTER TABLE "Connection" DROP COLUMN "tenant_id"`);
9252
+ await queryRunner.query(`ALTER TABLE "Connection" DROP COLUMN "owner_id"`);
9253
+ await queryRunner.query(`ALTER TABLE "CorrelationIdentifier" DROP COLUMN "tenant_id"`);
9254
+ await queryRunner.query(`ALTER TABLE "CorrelationIdentifier" DROP COLUMN "owner_id"`);
9255
+ await queryRunner.query(`ALTER TABLE "Identity" DROP COLUMN "tenant_id"`);
9256
+ await queryRunner.query(`ALTER TABLE "Identity" DROP COLUMN "owner_id"`);
9257
+ await queryRunner.query(`ALTER TABLE "Party" DROP COLUMN "tenant_id"`);
9258
+ await queryRunner.query(`ALTER TABLE "Party" DROP COLUMN "owner_id"`);
9009
9259
  }
9010
9260
  };
9011
9261
 
9012
- // src/migrations/generic/11-FixCredentialClaimsReferenceUuid.ts
9013
- var debug18 = (0, import_debug18.default)("sphereon:ssi-sdk:migrations");
9014
- var FixCredentialClaimsReferencesUuid1741895822987 = class {
9262
+ // src/migrations/generic/8-CreateContacts.ts
9263
+ var debug19 = (0, import_debug19.default)("sphereon:ssi-sdk:migrations");
9264
+ var CreateContacts1708525189000 = class {
9015
9265
  static {
9016
- __name(this, "FixCredentialClaimsReferencesUuid1741895822987");
9266
+ __name(this, "CreateContacts1708525189000");
9017
9267
  }
9018
- name = "FixCredentialClaimsReferenceUuid1741895822987";
9268
+ name = "CreateContacts1708525189000";
9019
9269
  async up(queryRunner) {
9020
- debug18("migration: creating issuance branding uuid problem");
9270
+ debug19("migration: updating contact tables");
9021
9271
  const dbType = queryRunner.connection.driver.options.type;
9022
9272
  switch (dbType) {
9023
9273
  case "postgres": {
9024
- debug18("using postgres migration file");
9025
- const mig = new FixCredentialClaimsReferencesUuidPG1741895822987();
9274
+ debug19("using postgres migration file");
9275
+ const mig = new CreateContacts1710438363001();
9026
9276
  await mig.up(queryRunner);
9027
- debug18("Migration statements executed");
9277
+ debug19("Migration statements executed");
9028
9278
  return;
9029
9279
  }
9030
9280
  case "sqlite":
9031
9281
  case "expo":
9032
9282
  case "react-native": {
9033
- debug18("using sqlite/react-native migration file");
9034
- const mig = new FixCredentialClaimsReferencesUuidSqlite1741895822987();
9283
+ debug19("using sqlite/react-native migration file");
9284
+ const mig = new CreateContacts1710438363002();
9035
9285
  await mig.up(queryRunner);
9036
- debug18("Migration statements executed");
9286
+ debug19("Migration statements executed");
9037
9287
  return;
9038
9288
  }
9039
9289
  default:
@@ -9041,23 +9291,23 @@ var FixCredentialClaimsReferencesUuid1741895822987 = class {
9041
9291
  }
9042
9292
  }
9043
9293
  async down(queryRunner) {
9044
- debug18("migration: reverting issuance branding uuid migration");
9294
+ debug19("migration: reverting machine state tables");
9045
9295
  const dbType = queryRunner.connection.driver.options.type;
9046
9296
  switch (dbType) {
9047
9297
  case "postgres": {
9048
- debug18("using postgres migration file");
9049
- const mig = new CreateIssuanceBranding1685628974232();
9298
+ debug19("using postgres migration file");
9299
+ const mig = new CreateContacts1710438363001();
9050
9300
  await mig.down(queryRunner);
9051
- debug18("Migration statements executed");
9301
+ debug19("Migration statements executed");
9052
9302
  return;
9053
9303
  }
9054
9304
  case "sqlite":
9055
9305
  case "expo":
9056
9306
  case "react-native": {
9057
- debug18("using sqlite/react-native migration file");
9058
- const mig = new CreateIssuanceBranding1685628973231();
9307
+ debug19("using sqlite/react-native migration file");
9308
+ const mig = new CreateContacts1710438363002();
9059
9309
  await mig.down(queryRunner);
9060
- debug18("Migration statements executed");
9310
+ debug19("Migration statements executed");
9061
9311
  return;
9062
9312
  }
9063
9313
  default:
@@ -9066,222 +9316,171 @@ var FixCredentialClaimsReferencesUuid1741895822987 = class {
9066
9316
  }
9067
9317
  };
9068
9318
 
9069
- // src/migrations/generic/12-CreateBitstringStatusList.ts
9070
- var import_debug19 = __toESM(require("debug"), 1);
9071
-
9072
- // src/migrations/postgres/1741895823000-CreateBitstringStatusList.ts
9073
- var CreateBitstringStatusListPG1741895823000 = class {
9074
- static {
9075
- __name(this, "CreateBitstringStatusListPG1741895823000");
9076
- }
9077
- name = "CreateBitstringStatusList1741895823000";
9078
- async up(queryRunner) {
9079
- await queryRunner.query(`ALTER TABLE "StatusList" ADD COLUMN "bitsPerStatus" integer DEFAULT 1`);
9080
- await queryRunner.query(`ALTER TABLE "StatusList" ADD COLUMN "ttl" integer`);
9081
- await queryRunner.query(`ALTER TABLE "StatusList" ADD COLUMN "validFrom" TIMESTAMP`);
9082
- await queryRunner.query(`ALTER TABLE "StatusList" ADD COLUMN "validUntil" TIMESTAMP`);
9083
- await queryRunner.query(`ALTER TABLE "StatusList" DROP CONSTRAINT IF EXISTS "CHK_StatusList_type"`);
9084
- await queryRunner.query(`ALTER TABLE "StatusList" ADD CONSTRAINT "CHK_StatusList_type" CHECK ("type" IN ('StatusList2021', 'OAuthStatusList', 'BitstringStatusList'))`);
9085
- await queryRunner.query(`ALTER TABLE "StatusListEntry" ADD COLUMN "type" character varying NOT NULL DEFAULT 'StatusListEntryEntity'`);
9086
- await queryRunner.query(`ALTER TABLE "StatusListEntry" ADD COLUMN "statusPurpose" character varying`);
9087
- await queryRunner.query(`ALTER TABLE "StatusListEntry" ADD COLUMN "bitsPerStatus" integer DEFAULT 1`);
9088
- await queryRunner.query(`ALTER TABLE "StatusListEntry" ADD COLUMN "statusMessage" text`);
9089
- await queryRunner.query(`ALTER TABLE "StatusListEntry" ADD COLUMN "statusReference" text`);
9090
- await queryRunner.query(`ALTER TABLE "StatusListEntry" ADD CONSTRAINT "CHK_StatusListEntry_type" CHECK ("type" IN ('StatusListEntryEntity', 'bitstring'))`);
9319
+ // src/migrations/generic/9-CreateContacts.ts
9320
+ var import_debug20 = __toESM(require("debug"), 1);
9321
+
9322
+ // src/migrations/postgres/1715761125001-CreateContacts.ts
9323
+ var CreateContacts1715761125001 = class {
9324
+ static {
9325
+ __name(this, "CreateContacts1715761125001");
9326
+ }
9327
+ name = "CreateContacts1715761125001";
9328
+ async up(queryRunner) {
9329
+ await queryRunner.query(`ALTER TABLE "IdentityMetadata" RENAME TO "temporary_IdentityMetadata"`);
9330
+ await queryRunner.query(`CREATE TABLE "IdentityMetadata"
9331
+ (
9332
+ "id" uuid PRIMARY KEY NOT NULL DEFAULT uuid_generate_v4(),
9333
+ "label" character varying(255) NOT NULL,
9334
+ "valueType" character varying NOT NULL,
9335
+ "stringValue" text,
9336
+ "numberValue" double precision,
9337
+ "dateValue" TIMESTAMP,
9338
+ "boolValue" boolean,
9339
+ "identityId" uuid,
9340
+ CONSTRAINT "FK_Identity_IdentityMetadata" FOREIGN KEY ("identityId") REFERENCES "Identity" ("id") ON DELETE CASCADE
9341
+ )`);
9342
+ await queryRunner.query(`INSERT INTO "IdentityMetadata" ("id", "label", "valueType", "stringValue", "identityId")
9343
+ SELECT "id", "label", 'string', "value", "identityId"
9344
+ FROM "temporary_IdentityMetadata"`);
9345
+ await queryRunner.query(`DROP TABLE "temporary_IdentityMetadata"`);
9346
+ await queryRunner.query(`CREATE TABLE "ContactMetadata"
9347
+ (
9348
+ "id" uuid PRIMARY KEY NOT NULL DEFAULT uuid_generate_v4(),
9349
+ "label" character varying(255) NOT NULL,
9350
+ "valueType" character varying NOT NULL,
9351
+ "stringValue" text,
9352
+ "numberValue" double precision,
9353
+ "dateValue" TIMESTAMP,
9354
+ "boolValue" boolean,
9355
+ "contactId" uuid,
9356
+ CONSTRAINT "FK_BaseContact_ContactMetadata" FOREIGN KEY ("contactId") REFERENCES "BaseContact" ("id") ON DELETE CASCADE
9357
+ )`);
9091
9358
  }
9092
9359
  async down(queryRunner) {
9093
- await queryRunner.query(`ALTER TABLE "StatusListEntry" DROP CONSTRAINT "CHK_StatusListEntry_type"`);
9094
- await queryRunner.query(`ALTER TABLE "StatusListEntry" DROP COLUMN "statusReference"`);
9095
- await queryRunner.query(`ALTER TABLE "StatusListEntry" DROP COLUMN "statusMessage"`);
9096
- await queryRunner.query(`ALTER TABLE "StatusListEntry" DROP COLUMN "bitsPerStatus"`);
9097
- await queryRunner.query(`ALTER TABLE "StatusListEntry" DROP COLUMN "statusPurpose"`);
9098
- await queryRunner.query(`ALTER TABLE "StatusListEntry" DROP COLUMN "type"`);
9099
- await queryRunner.query(`ALTER TABLE "StatusList" DROP CONSTRAINT "CHK_StatusList_type"`);
9100
- await queryRunner.query(`ALTER TABLE "StatusList" ADD CONSTRAINT "CHK_StatusList_type" CHECK ("type" IN ('StatusList2021', 'OAuthStatusList'))`);
9101
- await queryRunner.query(`ALTER TABLE "StatusList" DROP COLUMN "validUntil"`);
9102
- await queryRunner.query(`ALTER TABLE "StatusList" DROP COLUMN "validFrom"`);
9103
- await queryRunner.query(`ALTER TABLE "StatusList" DROP COLUMN "ttl"`);
9104
- await queryRunner.query(`ALTER TABLE "StatusList" DROP COLUMN "bitsPerStatus"`);
9360
+ await queryRunner.query(`DROP TABLE "ContactMetadata"`);
9361
+ await queryRunner.query(`ALTER TABLE "IdentityMetadata" RENAME TO "temporary_IdentityMetadata"`);
9362
+ await queryRunner.query(`CREATE TABLE "IdentityMetadata"
9363
+ (
9364
+ "id" uuid PRIMARY KEY NOT NULL DEFAULT uuid_generate_v4(),
9365
+ "label" character varying(255) NOT NULL,
9366
+ "value" character varying(255) NOT NULL,
9367
+ "identityId" uuid,
9368
+ CONSTRAINT "FK_Identity_IdentityMetadata" FOREIGN KEY ("identityId") REFERENCES "Identity" ("id") ON DELETE CASCADE
9369
+ )`);
9370
+ await queryRunner.query(`INSERT INTO "IdentityMetadata" ("id", "label", "value", "identityId")
9371
+ SELECT "id", "label", "stringValue", "identityId"
9372
+ FROM "temporary_IdentityMetadata"`);
9373
+ await queryRunner.query(`DROP TABLE "temporary_IdentityMetadata"`);
9105
9374
  }
9106
9375
  };
9107
9376
 
9108
- // src/migrations/sqlite/1741895823001-CreateBitstringStatusList.ts
9109
- var CreateBitstringStatusListSqlite1741895823001 = class {
9377
+ // src/migrations/sqlite/1715761125002-CreateContacts.ts
9378
+ var CreateContacts1715761125002 = class {
9110
9379
  static {
9111
- __name(this, "CreateBitstringStatusListSqlite1741895823001");
9380
+ __name(this, "CreateContacts1715761125002");
9112
9381
  }
9113
- name = "CreateBitstringStatusList1741895823000";
9382
+ name = "CreateContacts1715761125002";
9114
9383
  async up(queryRunner) {
9115
- await queryRunner.query(`
9116
- CREATE TABLE "temporary_StatusList" (
9117
- "id" varchar PRIMARY KEY NOT NULL,
9118
- "correlationId" varchar NOT NULL,
9119
- "length" integer NOT NULL,
9120
- "issuer" text NOT NULL,
9121
- "type" varchar CHECK( "type" IN ('StatusList2021', 'OAuthStatusList', 'BitstringStatusList') ) NOT NULL DEFAULT ('StatusList2021'),
9122
- "driverType" varchar CHECK( "driverType" IN ('agent_typeorm','agent_kv_store','github','agent_filesystem') ) NOT NULL DEFAULT ('agent_typeorm'),
9123
- "credentialIdMode" varchar CHECK( "credentialIdMode" IN ('ISSUANCE','PERSISTENCE','NEVER') ) NOT NULL DEFAULT ('ISSUANCE'),
9124
- "proofFormat" varchar CHECK( "proofFormat" IN ('lds','jwt', 'vc+jwt') ) NOT NULL DEFAULT ('lds'),
9125
- "indexingDirection" varchar CHECK( "indexingDirection" IN ('rightToLeft') ),
9126
- "statusPurpose" varchar,
9127
- "statusListCredential" text,
9128
- "expiresAt" datetime,
9129
- "bitsPerStatus" integer DEFAULT (1),
9130
- "ttl" integer,
9131
- "validFrom" datetime,
9132
- "validUntil" datetime,
9133
- CONSTRAINT "UQ_correlationId" UNIQUE ("correlationId")
9134
- )
9135
- `);
9136
- await queryRunner.query(`
9137
- INSERT INTO "temporary_StatusList"(
9138
- "id", "correlationId", "length", "issuer", "type", "driverType",
9139
- "credentialIdMode", "proofFormat", "indexingDirection", "statusPurpose",
9140
- "statusListCredential", "bitsPerStatus", "expiresAt"
9141
- )
9142
- SELECT
9143
- "id", "correlationId", "length", "issuer", "type", "driverType",
9144
- "credentialIdMode", "proofFormat", "indexingDirection", "statusPurpose",
9145
- "statusListCredential", "bitsPerStatus", "expiresAt"
9146
- FROM "StatusList"
9147
- `);
9148
- await queryRunner.query(`DROP TABLE "StatusList"`);
9149
- await queryRunner.query(`ALTER TABLE "temporary_StatusList" RENAME TO "StatusList"`);
9150
- await queryRunner.query(`
9151
- CREATE TABLE "temporary_StatusListEntry" (
9152
- "statusListId" varchar NOT NULL,
9153
- "statusListIndex" integer NOT NULL,
9154
- "credentialId" text,
9155
- "credentialHash" varchar(128),
9156
- "correlationId" varchar(255),
9157
- "value" varchar(50),
9158
- "type" varchar CHECK( "type" IN ('StatusListEntryEntity', 'bitstring') ) NOT NULL DEFAULT ('StatusListEntryEntity'),
9159
- "statusPurpose" varchar,
9160
- "bitsPerStatus" integer DEFAULT (1),
9161
- "statusMessage" text,
9162
- "statusReference" text,
9163
- PRIMARY KEY ("statusListId", "statusListIndex")
9164
- )
9165
- `);
9166
- await queryRunner.query(`
9167
- INSERT INTO "temporary_StatusListEntry"(
9168
- "statusListId", "statusListIndex", "credentialId", "credentialHash",
9169
- "correlationId", "value", "type"
9170
- )
9171
- SELECT
9172
- "statusListId", "statusListIndex", "credentialId", "credentialHash",
9173
- "correlationId", "value", 'StatusListEntryEntity'
9174
- FROM "StatusListEntry"
9175
- `);
9176
- await queryRunner.query(`DROP TABLE "StatusListEntry"`);
9177
- await queryRunner.query(`ALTER TABLE "temporary_StatusListEntry" RENAME TO "StatusListEntry"`);
9384
+ await queryRunner.query(`ALTER TABLE "IdentityMetadata" RENAME TO "temporary_IdentityMetadata"`);
9385
+ await queryRunner.query(`CREATE TABLE "IdentityMetadata"
9386
+ (
9387
+ "id" varchar PRIMARY KEY NOT NULL,
9388
+ "label" varchar(255) NOT NULL,
9389
+ "valueType" varchar NOT NULL,
9390
+ "stringValue" varchar(255),
9391
+ "numberValue" double,
9392
+ "dateValue" datetime,
9393
+ "boolValue" boolean,
9394
+ "identityId" varchar,
9395
+ FOREIGN KEY ("identityId") REFERENCES "Identity" ("id") ON DELETE CASCADE)`);
9396
+ await queryRunner.query(`INSERT INTO "IdentityMetadata" ("id", "label", "valueType", "stringValue", "identityId")
9397
+ SELECT "id", "label", 'string', "value", "identityId"
9398
+ FROM "temporary_IdentityMetadata"
9399
+ `);
9400
+ await queryRunner.query(`DROP TABLE "temporary_IdentityMetadata"`);
9401
+ await queryRunner.query(`CREATE TABLE "ContactMetadata"
9402
+ (
9403
+ "id" varchar PRIMARY KEY NOT NULL,
9404
+ "label" varchar(255) NOT NULL,
9405
+ "valueType" varchar NOT NULL,
9406
+ "stringValue" text,
9407
+ "numberValue" double,
9408
+ "dateValue" datetime,
9409
+ "boolValue" boolean,
9410
+ "contactId" varchar,
9411
+ FOREIGN KEY ("contactId") REFERENCES "BaseContact" ("id") ON DELETE CASCADE)`);
9178
9412
  }
9179
9413
  async down(queryRunner) {
9180
- await queryRunner.query(`
9181
- CREATE TABLE "temporary_StatusListEntry" (
9182
- "statusListId" varchar NOT NULL,
9183
- "statusListIndex" integer NOT NULL,
9184
- "credentialId" text,
9185
- "credentialHash" varchar(128),
9186
- "correlationId" varchar(255),
9187
- "value" varchar(50),
9188
- PRIMARY KEY ("statusListId", "statusListIndex")
9189
- )
9190
- `);
9191
- await queryRunner.query(`
9192
- INSERT INTO "temporary_StatusListEntry"(
9193
- "statusListId", "statusListIndex", "credentialId", "credentialHash",
9194
- "correlationId", "value"
9195
- )
9196
- SELECT
9197
- "statusListId", "statusListIndex", "credentialId", "credentialHash",
9198
- "correlationId", "value"
9199
- FROM "StatusListEntry"
9200
- WHERE "type" = 'StatusListEntryEntity'
9201
- `);
9202
- await queryRunner.query(`DROP TABLE "StatusListEntry"`);
9203
- await queryRunner.query(`ALTER TABLE "temporary_StatusListEntry" RENAME TO "StatusListEntry"`);
9204
- await queryRunner.query(`
9205
- CREATE TABLE "temporary_StatusList" (
9206
- "id" varchar PRIMARY KEY NOT NULL,
9207
- "correlationId" varchar NOT NULL,
9208
- "length" integer NOT NULL,
9209
- "issuer" text NOT NULL,
9210
- "type" varchar CHECK( "type" IN ('StatusList2021', 'OAuthStatusList') ) NOT NULL DEFAULT ('StatusList2021'),
9211
- "driverType" varchar CHECK( "driverType" IN ('agent_typeorm','agent_kv_store','github','agent_filesystem') ) NOT NULL DEFAULT ('agent_typeorm'),
9212
- "credentialIdMode" varchar CHECK( "credentialIdMode" IN ('ISSUANCE','PERSISTENCE','NEVER') ) NOT NULL DEFAULT ('ISSUANCE'),
9213
- "proofFormat" varchar CHECK( "proofFormat" IN ('lds','jwt', 'vc+jwt') ) NOT NULL DEFAULT ('lds'),
9214
- "indexingDirection" varchar CHECK( "indexingDirection" IN ('rightToLeft') ),
9215
- "statusPurpose" varchar,
9216
- "statusListCredential" text,
9217
- "bitsPerStatus" integer,
9218
- "expiresAt" datetime,
9219
- CONSTRAINT "UQ_correlationId" UNIQUE ("correlationId")
9220
- )
9221
- `);
9222
- await queryRunner.query(`
9223
- INSERT INTO "temporary_StatusList"(
9224
- "id", "correlationId", "length", "issuer", "type", "driverType",
9225
- "credentialIdMode", "proofFormat", "indexingDirection", "statusPurpose",
9226
- "statusListCredential", "bitsPerStatus", "expiresAt"
9227
- )
9228
- SELECT
9229
- "id", "correlationId", "length", "issuer",
9230
- CASE WHEN "type" = 'BitstringStatusList' THEN 'StatusList2021' ELSE "type" END,
9231
- "driverType", "credentialIdMode", "proofFormat", "indexingDirection",
9232
- "statusPurpose", "statusListCredential", "bitsPerStatus", "expiresAt"
9233
- FROM "StatusList"
9234
- `);
9235
- await queryRunner.query(`DROP TABLE "StatusList"`);
9236
- await queryRunner.query(`ALTER TABLE "temporary_StatusList" RENAME TO "StatusList"`);
9414
+ await queryRunner.query(`DROP TABLE "ContactMetadata"`);
9415
+ await queryRunner.query(`ALTER TABLE "IdentityMetadata" RENAME TO "temporary_IdentityMetadata"`);
9416
+ await queryRunner.query(`CREATE TABLE "IdentityMetadata"
9417
+ (
9418
+ "id" varchar PRIMARY KEY NOT NULL,
9419
+ "label" varchar(255) NOT NULL,
9420
+ "value" varchar(255) NOT NULL,
9421
+ "identityId" varchar,
9422
+ FOREIGN KEY ("identityId") REFERENCES "Identity" ("id") ON DELETE CASCADE
9423
+ )`);
9424
+ await queryRunner.query(`INSERT INTO "IdentityMetadata" ("id", "label", "value", "identityId")
9425
+ SELECT "id", "label", "stringValue", "identityId"
9426
+ FROM "temporary_IdentityMetadata"`);
9427
+ await queryRunner.query(`DROP TABLE "temporary_IdentityMetadata"`);
9237
9428
  }
9238
9429
  };
9239
9430
 
9240
- // src/migrations/generic/12-CreateBitstringStatusList.ts
9241
- var debug19 = (0, import_debug19.default)("sphereon:ssi-sdk:migrations");
9242
- var CreateBitstringStatusList1741895823000 = class {
9431
+ // src/migrations/generic/9-CreateContacts.ts
9432
+ var debug20 = (0, import_debug20.default)("sphereon:ssi-sdk:migrations");
9433
+ var CreateContacts1715761125000 = class {
9243
9434
  static {
9244
- __name(this, "CreateBitstringStatusList1741895823000");
9435
+ __name(this, "CreateContacts1715761125000");
9245
9436
  }
9246
- name = "CreateBitstringStatusList1741895823000";
9437
+ name = "CreateContacts1715761125000";
9247
9438
  async up(queryRunner) {
9248
- debug19("migration: creating bitstring status list tables");
9439
+ debug20("migration: updating contact tables");
9249
9440
  const dbType = queryRunner.connection.driver.options.type;
9250
9441
  switch (dbType) {
9251
9442
  case "postgres": {
9252
- const mig = new CreateBitstringStatusListPG1741895823000();
9443
+ debug20("using postgres migration file");
9444
+ const mig = new CreateContacts1715761125001();
9253
9445
  await mig.up(queryRunner);
9446
+ debug20("Migration statements executed");
9254
9447
  return;
9255
9448
  }
9256
9449
  case "sqlite":
9257
9450
  case "expo":
9258
9451
  case "react-native": {
9259
- const mig = new CreateBitstringStatusListSqlite1741895823001();
9452
+ debug20("using sqlite/react-native migration file");
9453
+ const mig = new CreateContacts1715761125002();
9260
9454
  await mig.up(queryRunner);
9455
+ debug20("Migration statements executed");
9261
9456
  return;
9262
9457
  }
9263
9458
  default:
9264
- return Promise.reject(`Migrations only supported for sqlite and postgres. Was ${dbType}`);
9459
+ 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`);
9265
9460
  }
9266
9461
  }
9267
9462
  async down(queryRunner) {
9268
- debug19("migration: dropping bitstring status list tables");
9463
+ debug20("migration: reverting machine state tables");
9269
9464
  const dbType = queryRunner.connection.driver.options.type;
9270
9465
  switch (dbType) {
9271
9466
  case "postgres": {
9272
- const mig = new CreateBitstringStatusListPG1741895823000();
9467
+ debug20("using postgres migration file");
9468
+ const mig = new CreateContacts1715761125001();
9273
9469
  await mig.down(queryRunner);
9470
+ debug20("Migration statements executed");
9274
9471
  return;
9275
9472
  }
9276
9473
  case "sqlite":
9277
9474
  case "expo":
9278
9475
  case "react-native": {
9279
- const mig = new CreateBitstringStatusListSqlite1741895823001();
9476
+ debug20("using sqlite/react-native migration file");
9477
+ const mig = new CreateContacts1715761125002();
9280
9478
  await mig.down(queryRunner);
9479
+ debug20("Migration statements executed");
9281
9480
  return;
9282
9481
  }
9283
9482
  default:
9284
- return Promise.reject(`Migrations only supported for sqlite and postgres. Was ${dbType}`);
9483
+ 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`);
9285
9484
  }
9286
9485
  }
9287
9486
  };
@@ -9299,6 +9498,7 @@ var DataStoreIssuanceBrandingMigrations = [
9299
9498
  ];
9300
9499
  var DataStoreStatusListMigrations = [
9301
9500
  CreateStatusList1693866470000,
9501
+ AddBitstringStatusListEnum1741895823000,
9302
9502
  CreateBitstringStatusList1741895823000
9303
9503
  ];
9304
9504
  var DataStoreEventLoggerMigrations = [
@@ -9311,7 +9511,8 @@ var DataStoreMachineStateMigrations = [
9311
9511
  CreateMachineStateStore1708098041262
9312
9512
  ];
9313
9513
  var DataStorePresentationDefinitionMigrations = [
9314
- CreatePresentationDefinitions1716533767523
9514
+ CreatePresentationDefinitions1716533767523,
9515
+ UpdatePresentationDefinitionItemNullable1741895824000
9315
9516
  ];
9316
9517
  var DataStoreMigrations = [
9317
9518
  ...DataStoreContactMigrations,
@@ -9324,7 +9525,7 @@ var DataStoreMigrations = [
9324
9525
  ];
9325
9526
 
9326
9527
  // src/utils/digitalCredential/MappingUtils.ts
9327
- var import_ssi_types7 = require("@sphereon/ssi-types");
9528
+ var import_ssi_types9 = require("@sphereon/ssi-types");
9328
9529
  var import_utils = require("@veramo/utils");
9329
9530
  var import_ssi_sdk23 = require("@sphereon/ssi-sdk.core");
9330
9531
  function determineDocumentType(raw) {
@@ -9332,11 +9533,11 @@ function determineDocumentType(raw) {
9332
9533
  if (!rawDocument) {
9333
9534
  throw new Error(`Couldn't parse the credential: ${raw}`);
9334
9535
  }
9335
- const hasProof = import_ssi_types7.CredentialMapper.hasProof(rawDocument);
9336
- const isCredential = isHex(raw) || import_ssi_types7.ObjectUtils.isBase64(raw) || import_ssi_types7.CredentialMapper.isCredential(rawDocument);
9337
- const isPresentation = import_ssi_types7.CredentialMapper.isPresentation(rawDocument);
9536
+ const hasProof = import_ssi_types9.CredentialMapper.hasProof(rawDocument);
9537
+ const isCredential = isHex(raw) || import_ssi_types9.ObjectUtils.isBase64(raw) || import_ssi_types9.CredentialMapper.isCredential(rawDocument);
9538
+ const isPresentation = import_ssi_types9.CredentialMapper.isPresentation(rawDocument);
9338
9539
  if (isCredential) {
9339
- return hasProof || isHex(raw) || import_ssi_types7.ObjectUtils.isBase64(raw) ? DocumentType.VC : DocumentType.C;
9540
+ return hasProof || isHex(raw) || import_ssi_types9.ObjectUtils.isBase64(raw) ? DocumentType.VC : DocumentType.C;
9340
9541
  } else if (isPresentation) {
9341
9542
  return hasProof ? DocumentType.VP : DocumentType.P;
9342
9543
  }
@@ -9348,9 +9549,9 @@ function isHex(input) {
9348
9549
  }
9349
9550
  __name(isHex, "isHex");
9350
9551
  function parseRawDocument(raw) {
9351
- if (isHex(raw) || import_ssi_types7.ObjectUtils.isBase64(raw)) {
9552
+ if (isHex(raw) || import_ssi_types9.ObjectUtils.isBase64(raw)) {
9352
9553
  return raw;
9353
- } else if (import_ssi_types7.CredentialMapper.isJwtEncoded(raw) || import_ssi_types7.CredentialMapper.isSdJwtEncoded(raw)) {
9554
+ } else if (import_ssi_types9.CredentialMapper.isJwtEncoded(raw) || import_ssi_types9.CredentialMapper.isSdJwtEncoded(raw)) {
9354
9555
  return raw;
9355
9556
  }
9356
9557
  try {
@@ -9362,9 +9563,9 @@ function parseRawDocument(raw) {
9362
9563
  __name(parseRawDocument, "parseRawDocument");
9363
9564
  function ensureRawDocument(input) {
9364
9565
  if (typeof input === "string") {
9365
- if (isHex(input) || import_ssi_types7.ObjectUtils.isBase64(input)) {
9566
+ if (isHex(input) || import_ssi_types9.ObjectUtils.isBase64(input)) {
9366
9567
  return input;
9367
- } else if (import_ssi_types7.CredentialMapper.isJwtEncoded(input) || import_ssi_types7.CredentialMapper.isSdJwtEncoded(input)) {
9568
+ } else if (import_ssi_types9.CredentialMapper.isJwtEncoded(input) || import_ssi_types9.CredentialMapper.isSdJwtEncoded(input)) {
9368
9569
  return input;
9369
9570
  }
9370
9571
  throw Error("Unknown input to be mapped as rawDocument");
@@ -9378,13 +9579,13 @@ function ensureRawDocument(input) {
9378
9579
  __name(ensureRawDocument, "ensureRawDocument");
9379
9580
  function determineCredentialDocumentFormat(documentFormat) {
9380
9581
  switch (documentFormat) {
9381
- case import_ssi_types7.DocumentFormat.JSONLD:
9582
+ case import_ssi_types9.DocumentFormat.JSONLD:
9382
9583
  return CredentialDocumentFormat.JSON_LD;
9383
- case import_ssi_types7.DocumentFormat.JWT:
9584
+ case import_ssi_types9.DocumentFormat.JWT:
9384
9585
  return CredentialDocumentFormat.JWT;
9385
- case import_ssi_types7.DocumentFormat.SD_JWT_VC:
9586
+ case import_ssi_types9.DocumentFormat.SD_JWT_VC:
9386
9587
  return CredentialDocumentFormat.SD_JWT;
9387
- case import_ssi_types7.DocumentFormat.MSO_MDOC:
9588
+ case import_ssi_types9.DocumentFormat.MSO_MDOC:
9388
9589
  return CredentialDocumentFormat.MSO_MDOC;
9389
9590
  default:
9390
9591
  throw new Error(`Not supported document format: ${documentFormat}`);
@@ -9423,14 +9624,14 @@ var safeStringify = /* @__PURE__ */ __name((object) => {
9423
9624
  }, "safeStringify");
9424
9625
  var nonPersistedDigitalCredentialEntityFromAddArgs = /* @__PURE__ */ __name((addCredentialArgs) => {
9425
9626
  const documentType = determineDocumentType(addCredentialArgs.rawDocument);
9426
- const documentFormat = import_ssi_types7.CredentialMapper.detectDocumentType(addCredentialArgs.rawDocument);
9627
+ const documentFormat = import_ssi_types9.CredentialMapper.detectDocumentType(addCredentialArgs.rawDocument);
9427
9628
  const hasher = addCredentialArgs?.opts?.hasher ?? import_ssi_sdk23.defaultHasher;
9428
- if (documentFormat === import_ssi_types7.DocumentFormat.SD_JWT_VC && !addCredentialArgs.opts?.hasher) {
9629
+ if (documentFormat === import_ssi_types9.DocumentFormat.SD_JWT_VC && !addCredentialArgs.opts?.hasher) {
9429
9630
  throw new Error("No hasher function is provided for SD_JWT credential.");
9430
9631
  }
9431
- const uniformDocument = documentType === DocumentType.VC || documentType === DocumentType.C ? import_ssi_types7.CredentialMapper.toUniformCredential(addCredentialArgs.rawDocument, {
9632
+ const uniformDocument = documentType === DocumentType.VC || documentType === DocumentType.C ? import_ssi_types9.CredentialMapper.toUniformCredential(addCredentialArgs.rawDocument, {
9432
9633
  hasher
9433
- }) : import_ssi_types7.CredentialMapper.toUniformPresentation(addCredentialArgs.rawDocument, {
9634
+ }) : import_ssi_types9.CredentialMapper.toUniformPresentation(addCredentialArgs.rawDocument, {
9434
9635
  hasher
9435
9636
  });
9436
9637
  const validFrom = getValidFrom(uniformDocument);