@sphereon/ssi-sdk.data-store 0.34.1-feature.SSISDK.47.43 → 0.34.1-feature.SSISDK.50.101

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 +1620 -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 +1576 -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 +34 -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,14 @@ 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
+ name: entity.name,
6955
+ defaultPurpose: entity.purpose,
6956
+ dcqlQuery: import_dcql.DcqlQuery.parse(JSON.parse(entity.dcqlPayload))
6957
+ }
6958
+ },
6957
6959
  createdAt: entity.createdAt,
6958
6960
  lastUpdatedAt: entity.lastUpdatedAt
6959
6961
  };
@@ -6966,8 +6968,12 @@ var presentationDefinitionEntityItemFrom = /* @__PURE__ */ __name((item) => {
6966
6968
  entity.version = item.version;
6967
6969
  entity.name = item.name;
6968
6970
  entity.purpose = item.purpose;
6969
- entity.definitionPayload = JSON.stringify(item.definitionPayload);
6970
- entity.dcqlPayload = JSON.stringify(item.dcqlPayload);
6971
+ if (item.definitionPayload) {
6972
+ entity.definitionPayload = JSON.stringify(item.definitionPayload);
6973
+ }
6974
+ if (item.dcqlPayload) {
6975
+ entity.dcqlPayload = JSON.stringify(item.dcqlPayload.dcqlQuery);
6976
+ }
6971
6977
  return entity;
6972
6978
  }, "presentationDefinitionEntityItemFrom");
6973
6979
  function hashPayload(payload) {
@@ -6975,13 +6981,24 @@ function hashPayload(payload) {
6975
6981
  }
6976
6982
  __name(hashPayload, "hashPayload");
6977
6983
  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) {
6984
+ if (base.definitionId !== compare.definitionId || base.tenantId !== compare.tenantId || base.version !== compare.version || base.name !== compare.name || base.purpose !== compare.purpose) {
6985
+ return false;
6986
+ }
6987
+ if (base.dcqlPayload && compare.dcqlPayload) {
6988
+ if (hashPayload(base.dcqlPayload) !== hashPayload(compare.dcqlPayload)) {
6989
+ return false;
6990
+ }
6991
+ } else if (base.dcqlPayload || compare.dcqlPayload) {
6979
6992
  return false;
6980
6993
  }
6981
6994
  if (base.definitionPayload && compare.definitionPayload) {
6982
- return hashPayload(base.definitionPayload) === hashPayload(compare.definitionPayload);
6995
+ if (hashPayload(base.definitionPayload) !== hashPayload(compare.definitionPayload)) {
6996
+ return false;
6997
+ }
6998
+ } else if (base.definitionPayload || compare.definitionPayload) {
6999
+ return false;
6983
7000
  }
6984
- return false;
7001
+ return true;
6985
7002
  }
6986
7003
  __name(isPresentationDefinitionEqual, "isPresentationDefinitionEqual");
6987
7004
 
@@ -7070,7 +7087,12 @@ var PDStore = class extends AbstractPDStore {
7070
7087
  updatedEntity.version = item.version;
7071
7088
  updatedEntity.name = item.name;
7072
7089
  updatedEntity.purpose = item.purpose;
7073
- updatedEntity.definitionPayload = JSON.stringify(item.definitionPayload);
7090
+ if (item.definitionPayload) {
7091
+ updatedEntity.definitionPayload = JSON.stringify(item.definitionPayload);
7092
+ }
7093
+ if (item.dcqlPayload) {
7094
+ updatedEntity.dcqlPayload = JSON.stringify(item.dcqlPayload.dcqlQuery);
7095
+ }
7074
7096
  debug7("Updating presentation definition entity", updatedEntity);
7075
7097
  const updateResult = await pdRepository.save(updatedEntity, {
7076
7098
  transaction: true
@@ -7306,9 +7328,120 @@ var CreateContacts1659463079429 = class {
7306
7328
  }
7307
7329
  };
7308
7330
 
7309
- // src/migrations/generic/2-CreateIssuanceBranding.ts
7331
+ // src/migrations/generic/10-CreatePresentationDefinitions.ts
7310
7332
  var import_debug9 = __toESM(require("debug"), 1);
7311
7333
 
7334
+ // src/migrations/postgres/1716475165345-CreatePresentationDefinitions.ts
7335
+ var CreatePresentationDefinitions1716475165345 = class {
7336
+ static {
7337
+ __name(this, "CreatePresentationDefinitions1716475165345");
7338
+ }
7339
+ name = "CreatePresentationDefinitions1716475165345";
7340
+ async up(queryRunner) {
7341
+ await queryRunner.query(`
7342
+ CREATE TABLE "PresentationDefinitionItem" (
7343
+ "id" uuid NOT NULL DEFAULT uuid_generate_v4(),
7344
+ "tenant_id" TEXT,
7345
+ "definition_id" TEXT NOT NULL,
7346
+ "name" TEXT,
7347
+ "version" TEXT NOT NULL,
7348
+ "purpose" TEXT,
7349
+ "definition_payload" TEXT NOT NULL,
7350
+ "dcql_payload" TEXT,
7351
+ "created_at" TIMESTAMP NOT NULL DEFAULT now(),
7352
+ "last_updated_at" TIMESTAMP NOT NULL DEFAULT now(),
7353
+ CONSTRAINT "PK_PresentationDefinitionItem_id" PRIMARY KEY ("id"))
7354
+ `);
7355
+ }
7356
+ async down(queryRunner) {
7357
+ await queryRunner.query(`DROP TABLE "PresentationDefinitionItem"`);
7358
+ }
7359
+ };
7360
+
7361
+ // src/migrations/sqlite/1716475165344-CreatePresentationDefinitions.ts
7362
+ var CreatePresentationDefinitions1716475165344 = class {
7363
+ static {
7364
+ __name(this, "CreatePresentationDefinitions1716475165344");
7365
+ }
7366
+ name = "CreatePresentationDefinitions1716475165344";
7367
+ async up(queryRunner) {
7368
+ await queryRunner.query(`CREATE TABLE "PresentationDefinitionItem" (
7369
+ "id" varchar PRIMARY KEY NOT NULL,
7370
+ "tenant_id" varchar,
7371
+ "definition_id" varchar NOT NULL,
7372
+ "name" varchar,
7373
+ "version" varchar NOT NULL,
7374
+ "purpose" varchar,
7375
+ "definition_payload" varchar NOT NULL,
7376
+ "dcql_payload" varchar,
7377
+ "created_at" datetime NOT NULL DEFAULT (datetime('now')),
7378
+ "last_updated_at" datetime NOT NULL DEFAULT (datetime('now')))`);
7379
+ }
7380
+ async down(queryRunner) {
7381
+ await queryRunner.query(`DROP TABLE "PresentationDefinitionItem"`);
7382
+ }
7383
+ };
7384
+
7385
+ // src/migrations/generic/10-CreatePresentationDefinitions.ts
7386
+ var debug9 = (0, import_debug9.default)("sphereon:ssi-sdk:migrations");
7387
+ var CreatePresentationDefinitions1716533767523 = class {
7388
+ static {
7389
+ __name(this, "CreatePresentationDefinitions1716533767523");
7390
+ }
7391
+ name = "CreatePresentationDefinitionItems1716533767523";
7392
+ async up(queryRunner) {
7393
+ debug9("migration: creating machine state tables");
7394
+ const dbType = queryRunner.connection.driver.options.type;
7395
+ switch (dbType) {
7396
+ case "postgres": {
7397
+ debug9("using postgres migration file");
7398
+ const mig = new CreatePresentationDefinitions1716475165345();
7399
+ await mig.up(queryRunner);
7400
+ debug9("Migration statements executed");
7401
+ return;
7402
+ }
7403
+ case "sqlite":
7404
+ case "expo":
7405
+ case "react-native": {
7406
+ debug9("using sqlite/react-native migration file");
7407
+ const mig = new CreatePresentationDefinitions1716475165344();
7408
+ await mig.up(queryRunner);
7409
+ debug9("Migration statements executed");
7410
+ return;
7411
+ }
7412
+ default:
7413
+ 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`);
7414
+ }
7415
+ }
7416
+ async down(queryRunner) {
7417
+ debug9("migration: reverting machine state tables");
7418
+ const dbType = queryRunner.connection.driver.options.type;
7419
+ switch (dbType) {
7420
+ case "postgres": {
7421
+ debug9("using postgres migration file");
7422
+ const mig = new CreatePresentationDefinitions1716475165345();
7423
+ await mig.down(queryRunner);
7424
+ debug9("Migration statements executed");
7425
+ return;
7426
+ }
7427
+ case "sqlite":
7428
+ case "expo":
7429
+ case "react-native": {
7430
+ debug9("using sqlite/react-native migration file");
7431
+ const mig = new CreatePresentationDefinitions1716475165344();
7432
+ await mig.down(queryRunner);
7433
+ debug9("Migration statements executed");
7434
+ return;
7435
+ }
7436
+ default:
7437
+ 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`);
7438
+ }
7439
+ }
7440
+ };
7441
+
7442
+ // src/migrations/generic/11-FixCredentialClaimsReferenceUuid.ts
7443
+ var import_debug10 = __toESM(require("debug"), 1);
7444
+
7312
7445
  // src/migrations/postgres/1685628974232-CreateIssuanceBranding.ts
7313
7446
  var import_ssi_sdk21 = require("@sphereon/ssi-sdk.core");
7314
7447
  var CreateIssuanceBranding1685628974232 = class {
@@ -7445,31 +7578,105 @@ var CreateIssuanceBranding1685628973231 = class {
7445
7578
  }
7446
7579
  };
7447
7580
 
7448
- // src/migrations/generic/2-CreateIssuanceBranding.ts
7449
- var debug9 = (0, import_debug9.default)("sphereon:ssi-sdk:migrations");
7450
- var CreateIssuanceBranding1659463079429 = class {
7581
+ // src/migrations/postgres/1741895822987-FixCredentialClaimsReferencesUuid.ts
7582
+ var FixCredentialClaimsReferencesUuidPG1741895822987 = class {
7451
7583
  static {
7452
- __name(this, "CreateIssuanceBranding1659463079429");
7584
+ __name(this, "FixCredentialClaimsReferencesUuidPG1741895822987");
7453
7585
  }
7454
- name = "CreateIssuanceBranding1659463079429";
7586
+ name = "FixCredentialClaimsReferencesUuid1741895822987";
7587
+ async up(queryRunner) {
7588
+ await queryRunner.query(`
7589
+ ALTER TABLE "CredentialClaims"
7590
+ ALTER COLUMN "credentialLocaleBrandingId" TYPE uuid USING "credentialLocaleBrandingId"::uuid;
7591
+ `);
7592
+ }
7593
+ async down(queryRunner) {
7594
+ await queryRunner.query(`
7595
+ ALTER TABLE "CredentialClaims"
7596
+ ALTER COLUMN "credentialLocaleBrandingId" TYPE character varying USING "credentialLocaleBrandingId"::text;
7597
+ `);
7598
+ }
7599
+ };
7600
+
7601
+ // src/migrations/sqlite/1741895822987-FixCredentialClaimsReferencesUuid.ts
7602
+ var FixCredentialClaimsReferencesUuidSqlite1741895822987 = class {
7603
+ static {
7604
+ __name(this, "FixCredentialClaimsReferencesUuidSqlite1741895822987");
7605
+ }
7606
+ name = "FixCredentialClaimsReferencesUuid1741895822987";
7607
+ async up(queryRunner) {
7608
+ await queryRunner.query(`
7609
+ CREATE TABLE "CredentialClaims_new"
7610
+ (
7611
+ "id" uuid NOT NULL DEFAULT (lower(hex(randomblob(16)))),
7612
+ "key" character varying(255) NOT NULL,
7613
+ "name" character varying(255) NOT NULL,
7614
+ "credentialLocaleBrandingId" uuid,
7615
+ CONSTRAINT "PK_CredentialClaims_id" PRIMARY KEY ("id")
7616
+ )
7617
+ `);
7618
+ await queryRunner.query(`
7619
+ INSERT INTO "CredentialClaims_new" ("id", "key", "name", "credentialLocaleBrandingId")
7620
+ SELECT "id", "key", "name", "credentialLocaleBrandingId"
7621
+ FROM "CredentialClaims"
7622
+ `);
7623
+ await queryRunner.query(`DROP TABLE "CredentialClaims"`);
7624
+ await queryRunner.query(`ALTER TABLE "CredentialClaims_new" RENAME TO "CredentialClaims"`);
7625
+ await queryRunner.query(`
7626
+ CREATE UNIQUE INDEX "IDX_CredentialClaimsEntity_credentialLocaleBranding_locale"
7627
+ ON "CredentialClaims" ("credentialLocaleBrandingId", "key")
7628
+ `);
7629
+ }
7630
+ async down(queryRunner) {
7631
+ await queryRunner.query(`
7632
+ CREATE TABLE "CredentialClaims_old"
7633
+ (
7634
+ "id" uuid NOT NULL DEFAULT (lower(hex(randomblob(16)))),
7635
+ "key" character varying(255) NOT NULL,
7636
+ "name" character varying(255) NOT NULL,
7637
+ "credentialLocaleBrandingId" character varying,
7638
+ CONSTRAINT "PK_CredentialClaims_id" PRIMARY KEY ("id")
7639
+ )
7640
+ `);
7641
+ await queryRunner.query(`
7642
+ INSERT INTO "CredentialClaims_old" ("id", "key", "name", "credentialLocaleBrandingId")
7643
+ SELECT "id", "key", "name", "credentialLocaleBrandingId"
7644
+ FROM "CredentialClaims"
7645
+ `);
7646
+ await queryRunner.query(`DROP TABLE "CredentialClaims"`);
7647
+ await queryRunner.query(`ALTER TABLE "CredentialClaims_old" RENAME TO "CredentialClaims"`);
7648
+ await queryRunner.query(`
7649
+ CREATE UNIQUE INDEX "IDX_CredentialClaimsEntity_credentialLocaleBranding_locale"
7650
+ ON "CredentialClaims" ("credentialLocaleBrandingId", "key")
7651
+ `);
7652
+ }
7653
+ };
7654
+
7655
+ // src/migrations/generic/11-FixCredentialClaimsReferenceUuid.ts
7656
+ var debug10 = (0, import_debug10.default)("sphereon:ssi-sdk:migrations");
7657
+ var FixCredentialClaimsReferencesUuid1741895822987 = class {
7658
+ static {
7659
+ __name(this, "FixCredentialClaimsReferencesUuid1741895822987");
7660
+ }
7661
+ name = "FixCredentialClaimsReferenceUuid1741895822987";
7455
7662
  async up(queryRunner) {
7456
- debug9("migration: creating issuance branding tables");
7663
+ debug10("migration: creating issuance branding uuid problem");
7457
7664
  const dbType = queryRunner.connection.driver.options.type;
7458
7665
  switch (dbType) {
7459
7666
  case "postgres": {
7460
- debug9("using postgres migration file");
7461
- const mig = new CreateIssuanceBranding1685628974232();
7667
+ debug10("using postgres migration file");
7668
+ const mig = new FixCredentialClaimsReferencesUuidPG1741895822987();
7462
7669
  await mig.up(queryRunner);
7463
- debug9("Migration statements executed");
7670
+ debug10("Migration statements executed");
7464
7671
  return;
7465
7672
  }
7466
7673
  case "sqlite":
7467
7674
  case "expo":
7468
7675
  case "react-native": {
7469
- debug9("using sqlite/react-native migration file");
7470
- const mig = new CreateIssuanceBranding1685628973231();
7676
+ debug10("using sqlite/react-native migration file");
7677
+ const mig = new FixCredentialClaimsReferencesUuidSqlite1741895822987();
7471
7678
  await mig.up(queryRunner);
7472
- debug9("Migration statements executed");
7679
+ debug10("Migration statements executed");
7473
7680
  return;
7474
7681
  }
7475
7682
  default:
@@ -7477,23 +7684,23 @@ var CreateIssuanceBranding1659463079429 = class {
7477
7684
  }
7478
7685
  }
7479
7686
  async down(queryRunner) {
7480
- debug9("migration: reverting issuance branding tables");
7687
+ debug10("migration: reverting issuance branding uuid migration");
7481
7688
  const dbType = queryRunner.connection.driver.options.type;
7482
7689
  switch (dbType) {
7483
7690
  case "postgres": {
7484
- debug9("using postgres migration file");
7691
+ debug10("using postgres migration file");
7485
7692
  const mig = new CreateIssuanceBranding1685628974232();
7486
7693
  await mig.down(queryRunner);
7487
- debug9("Migration statements executed");
7694
+ debug10("Migration statements executed");
7488
7695
  return;
7489
7696
  }
7490
7697
  case "sqlite":
7491
7698
  case "expo":
7492
7699
  case "react-native": {
7493
- debug9("using sqlite/react-native migration file");
7700
+ debug10("using sqlite/react-native migration file");
7494
7701
  const mig = new CreateIssuanceBranding1685628973231();
7495
7702
  await mig.down(queryRunner);
7496
- debug9("Migration statements executed");
7703
+ debug10("Migration statements executed");
7497
7704
  return;
7498
7705
  }
7499
7706
  default:
@@ -7502,658 +7709,364 @@ var CreateIssuanceBranding1659463079429 = class {
7502
7709
  }
7503
7710
  };
7504
7711
 
7505
- // src/migrations/generic/3-CreateContacts.ts
7506
- var import_debug10 = __toESM(require("debug"), 1);
7712
+ // src/migrations/generic/12-CreateBitstringStatusList.ts
7713
+ var import_debug11 = __toESM(require("debug"), 1);
7507
7714
 
7508
- // src/migrations/sqlite/1690925872693-CreateContacts.ts
7509
- var CreateContacts1690925872693 = class {
7715
+ // src/migrations/postgres/1741895823000-CreateBitstringStatusList.ts
7716
+ var AddBitstringStatusListEnumPG1741895823000 = class {
7510
7717
  static {
7511
- __name(this, "CreateContacts1690925872693");
7718
+ __name(this, "AddBitstringStatusListEnumPG1741895823000");
7512
7719
  }
7513
- name = "CreateContacts1690925872693";
7720
+ name = "AddBitstringStatusListEnum1741895823000";
7514
7721
  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"`);
7722
+ await queryRunner.startTransaction();
7723
+ await queryRunner.query(`ALTER TYPE "StatusList_type_enum" ADD VALUE 'BitstringStatusList'`);
7724
+ await queryRunner.commitTransaction();
7886
7725
  }
7726
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
7887
7727
  async down(queryRunner) {
7888
- await queryRunner.query(`DROP TABLE "StatusListEntry"`);
7889
- await queryRunner.query(`DROP TABLE "StatusList"`);
7890
7728
  }
7891
7729
  };
7892
-
7893
- // src/migrations/postgres/1737110469001-UpdateStatusList.ts
7894
- var UpdateStatusList1737110469001 = class {
7730
+ var CreateBitstringStatusListPG1741895823000 = class {
7895
7731
  static {
7896
- __name(this, "UpdateStatusList1737110469001");
7732
+ __name(this, "CreateBitstringStatusListPG1741895823000");
7897
7733
  }
7898
- name = "UpdateStatusList1737110469001";
7734
+ name = "CreateBitstringStatusList1741895823000";
7899
7735
  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`);
7736
+ await queryRunner.query(`ALTER TABLE "StatusList" ADD COLUMN "ttl" integer`);
7737
+ await queryRunner.query(`ALTER TABLE "StatusList" ADD COLUMN "validFrom" TIMESTAMP`);
7738
+ await queryRunner.query(`ALTER TABLE "StatusList" ADD COLUMN "validUntil" TIMESTAMP`);
7739
+ await queryRunner.query(`ALTER TABLE "StatusList" DROP CONSTRAINT IF EXISTS "CHK_StatusList_type"`);
7740
+ await queryRunner.query(`ALTER TABLE "StatusList" ADD CONSTRAINT "CHK_StatusList_type" CHECK ("type" IN ('StatusList2021', 'OAuthStatusList', 'BitstringStatusList'))`);
7741
+ await queryRunner.query(`ALTER TABLE "StatusListEntry" ADD COLUMN "type" character varying NOT NULL DEFAULT 'StatusListEntryEntity'`);
7742
+ await queryRunner.query(`ALTER TABLE "StatusListEntry" ADD COLUMN "statusPurpose" character varying`);
7743
+ await queryRunner.query(`ALTER TABLE "StatusListEntry" ADD COLUMN "statusMessage" text`);
7744
+ await queryRunner.query(`ALTER TABLE "StatusListEntry" ADD COLUMN "statusReference" text`);
7745
+ await queryRunner.query(`ALTER TABLE "StatusListEntry" ADD CONSTRAINT "CHK_StatusListEntry_type" CHECK ("type" IN ('StatusListEntryEntity', 'bitstring'))`);
7905
7746
  }
7906
7747
  async down(queryRunner) {
7907
- await queryRunner.query(`ALTER TABLE "StatusList" DROP COLUMN "expiresAt"`);
7748
+ await queryRunner.query(`ALTER TABLE "StatusListEntry" DROP CONSTRAINT "CHK_StatusListEntry_type"`);
7749
+ await queryRunner.query(`ALTER TABLE "StatusListEntry" DROP COLUMN "statusReference"`);
7750
+ await queryRunner.query(`ALTER TABLE "StatusListEntry" DROP COLUMN "statusMessage"`);
7751
+ await queryRunner.query(`ALTER TABLE "StatusListEntry" DROP COLUMN "bitsPerStatus"`);
7752
+ await queryRunner.query(`ALTER TABLE "StatusListEntry" DROP COLUMN "statusPurpose"`);
7753
+ await queryRunner.query(`ALTER TABLE "StatusListEntry" DROP COLUMN "type"`);
7754
+ await queryRunner.query(`ALTER TABLE "StatusList" DROP CONSTRAINT "CHK_StatusList_type"`);
7755
+ await queryRunner.query(`ALTER TABLE "StatusList" ADD CONSTRAINT "CHK_StatusList_type" CHECK ("type" IN ('StatusList2021', 'OAuthStatusList'))`);
7756
+ await queryRunner.query(`ALTER TABLE "StatusList" DROP COLUMN "validUntil"`);
7757
+ await queryRunner.query(`ALTER TABLE "StatusList" DROP COLUMN "validFrom"`);
7758
+ await queryRunner.query(`ALTER TABLE "StatusList" DROP COLUMN "ttl"`);
7908
7759
  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
7760
  }
7912
7761
  };
7913
7762
 
7914
- // src/migrations/sqlite/1737110469000-UpdateStatusList.ts
7915
- var UpdateStatusList1737110469000 = class {
7763
+ // src/migrations/sqlite/1741895823001-CreateBitstringStatusList.ts
7764
+ var CreateBitstringStatusListSqlite1741895823001 = class {
7916
7765
  static {
7917
- __name(this, "UpdateStatusList1737110469000");
7766
+ __name(this, "CreateBitstringStatusListSqlite1741895823001");
7918
7767
  }
7919
- name = "UpdateStatusList1737110469000";
7768
+ name = "CreateBitstringStatusList1741895823000";
7920
7769
  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"`);
7770
+ await queryRunner.query(`
7771
+ CREATE TABLE "temporary_StatusList" (
7772
+ "id" varchar PRIMARY KEY NOT NULL,
7773
+ "correlationId" varchar NOT NULL,
7774
+ "length" integer NOT NULL,
7775
+ "issuer" text NOT NULL,
7776
+ "type" varchar CHECK( "type" IN ('StatusList2021', 'OAuthStatusList', 'BitstringStatusList') ) NOT NULL DEFAULT ('StatusList2021'),
7777
+ "driverType" varchar CHECK( "driverType" IN ('agent_typeorm','agent_kv_store','github','agent_filesystem') ) NOT NULL DEFAULT ('agent_typeorm'),
7778
+ "credentialIdMode" varchar CHECK( "credentialIdMode" IN ('ISSUANCE','PERSISTENCE','NEVER') ) NOT NULL DEFAULT ('ISSUANCE'),
7779
+ "proofFormat" varchar CHECK( "proofFormat" IN ('lds','jwt', 'vc+jwt') ) NOT NULL DEFAULT ('lds'),
7780
+ "indexingDirection" varchar CHECK( "indexingDirection" IN ('rightToLeft') ),
7781
+ "statusPurpose" varchar,
7782
+ "statusListCredential" text,
7783
+ "expiresAt" datetime,
7784
+ "bitsPerStatus" integer DEFAULT (1),
7785
+ "ttl" integer,
7786
+ "validFrom" datetime,
7787
+ "validUntil" datetime,
7788
+ CONSTRAINT "UQ_correlationId" UNIQUE ("correlationId")
7789
+ )
7790
+ `);
7791
+ await queryRunner.query(`
7792
+ INSERT INTO "temporary_StatusList"(
7793
+ "id", "correlationId", "length", "issuer", "type", "driverType",
7794
+ "credentialIdMode", "proofFormat", "indexingDirection", "statusPurpose",
7795
+ "statusListCredential", "bitsPerStatus", "expiresAt"
7796
+ )
7797
+ SELECT
7798
+ "id", "correlationId", "length", "issuer", "type", "driverType",
7799
+ "credentialIdMode", "proofFormat", "indexingDirection", "statusPurpose",
7800
+ "statusListCredential", "bitsPerStatus", "expiresAt"
7801
+ FROM "StatusList"
7802
+ `);
7947
7803
  await queryRunner.query(`DROP TABLE "StatusList"`);
7948
7804
  await queryRunner.query(`ALTER TABLE "temporary_StatusList" RENAME TO "StatusList"`);
7805
+ await queryRunner.query(`
7806
+ CREATE TABLE "temporary_StatusListEntry" (
7807
+ "statusListId" varchar NOT NULL,
7808
+ "statusListIndex" integer NOT NULL,
7809
+ "credentialId" text,
7810
+ "credentialHash" varchar(128),
7811
+ "correlationId" varchar(255),
7812
+ "value" varchar(50),
7813
+ "type" varchar CHECK( "type" IN ('StatusListEntryEntity', 'bitstring') ) NOT NULL DEFAULT ('StatusListEntryEntity'),
7814
+ "statusPurpose" varchar,
7815
+ "bitsPerStatus" integer DEFAULT (1),
7816
+ "statusMessage" text,
7817
+ "statusReference" text,
7818
+ PRIMARY KEY ("statusListId", "statusListIndex")
7819
+ )
7820
+ `);
7821
+ await queryRunner.query(`
7822
+ INSERT INTO "temporary_StatusListEntry"(
7823
+ "statusListId", "statusListIndex", "credentialId", "credentialHash",
7824
+ "correlationId", "value", "type"
7825
+ )
7826
+ SELECT
7827
+ "statusListId", "statusListIndex", "credentialId", "credentialHash",
7828
+ "correlationId", "value", 'StatusListEntryEntity'
7829
+ FROM "StatusListEntry"
7830
+ `);
7831
+ await queryRunner.query(`DROP TABLE "StatusListEntry"`);
7832
+ await queryRunner.query(`ALTER TABLE "temporary_StatusListEntry" RENAME TO "StatusListEntry"`);
7949
7833
  }
7950
7834
  async down(queryRunner) {
7951
7835
  await queryRunner.query(`
7952
- ALTER TABLE "StatusListEntry"
7953
- RENAME COLUMN "entryCorrelationId" TO "correlationId"
7954
- `);
7836
+ CREATE TABLE "temporary_StatusListEntry" (
7837
+ "statusListId" varchar NOT NULL,
7838
+ "statusListIndex" integer NOT NULL,
7839
+ "credentialId" text,
7840
+ "credentialHash" varchar(128),
7841
+ "correlationId" varchar(255),
7842
+ "value" varchar(50),
7843
+ PRIMARY KEY ("statusListId", "statusListIndex")
7844
+ )
7845
+ `);
7955
7846
  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"`);
7847
+ INSERT INTO "temporary_StatusListEntry"(
7848
+ "statusListId", "statusListIndex", "credentialId", "credentialHash",
7849
+ "correlationId", "value"
7850
+ )
7851
+ SELECT
7852
+ "statusListId", "statusListIndex", "credentialId", "credentialHash",
7853
+ "correlationId", "value"
7854
+ FROM "StatusListEntry"
7855
+ WHERE "type" = 'StatusListEntryEntity'
7856
+ `);
7857
+ await queryRunner.query(`DROP TABLE "StatusListEntry"`);
7858
+ await queryRunner.query(`ALTER TABLE "temporary_StatusListEntry" RENAME TO "StatusListEntry"`);
7859
+ await queryRunner.query(`
7860
+ CREATE TABLE "temporary_StatusList" (
7861
+ "id" varchar PRIMARY KEY NOT NULL,
7862
+ "correlationId" varchar NOT NULL,
7863
+ "length" integer NOT NULL,
7864
+ "issuer" text NOT NULL,
7865
+ "type" varchar CHECK( "type" IN ('StatusList2021', 'OAuthStatusList') ) NOT NULL DEFAULT ('StatusList2021'),
7866
+ "driverType" varchar CHECK( "driverType" IN ('agent_typeorm','agent_kv_store','github','agent_filesystem') ) NOT NULL DEFAULT ('agent_typeorm'),
7867
+ "credentialIdMode" varchar CHECK( "credentialIdMode" IN ('ISSUANCE','PERSISTENCE','NEVER') ) NOT NULL DEFAULT ('ISSUANCE'),
7868
+ "proofFormat" varchar CHECK( "proofFormat" IN ('lds','jwt', 'vc+jwt') ) NOT NULL DEFAULT ('lds'),
7869
+ "indexingDirection" varchar CHECK( "indexingDirection" IN ('rightToLeft') ),
7870
+ "statusPurpose" varchar,
7871
+ "statusListCredential" text,
7872
+ "bitsPerStatus" integer,
7873
+ "expiresAt" datetime,
7874
+ CONSTRAINT "UQ_correlationId" UNIQUE ("correlationId")
7875
+ )
7876
+ `);
7877
+ await queryRunner.query(`
7878
+ INSERT INTO "temporary_StatusList"(
7879
+ "id", "correlationId", "length", "issuer", "type", "driverType",
7880
+ "credentialIdMode", "proofFormat", "indexingDirection", "statusPurpose",
7881
+ "statusListCredential", "bitsPerStatus", "expiresAt"
7882
+ )
7883
+ SELECT
7884
+ "id", "correlationId", "length", "issuer",
7885
+ CASE WHEN "type" = 'BitstringStatusList' THEN 'StatusList2021' ELSE "type" END,
7886
+ "driverType", "credentialIdMode", "proofFormat", "indexingDirection",
7887
+ "statusPurpose", "statusListCredential", "bitsPerStatus", "expiresAt"
7888
+ FROM "StatusList"
7889
+ `);
7984
7890
  await queryRunner.query(`DROP TABLE "StatusList"`);
7985
7891
  await queryRunner.query(`ALTER TABLE "temporary_StatusList" RENAME TO "StatusList"`);
7986
7892
  }
7987
7893
  };
7988
7894
 
7989
- // src/migrations/generic/4-CreateStatusList.ts
7895
+ // src/migrations/generic/12-CreateBitstringStatusList.ts
7990
7896
  var debug11 = (0, import_debug11.default)("sphereon:ssi-sdk:migrations");
7991
- var CreateStatusList1693866470000 = class {
7897
+ var AddBitstringStatusListEnum1741895823000 = class {
7992
7898
  static {
7993
- __name(this, "CreateStatusList1693866470000");
7899
+ __name(this, "AddBitstringStatusListEnum1741895823000");
7994
7900
  }
7995
- name = "CreateStatusList1693866470000";
7901
+ name = "AddBitstringStatusListEnum1741895823000";
7996
7902
  async up(queryRunner) {
7997
- debug11("migration: creating issuance branding tables");
7903
+ debug11("migration: creating bitstring status list tables");
7998
7904
  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`);
7905
+ switch (dbType) {
7906
+ case "postgres": {
7907
+ const mig = new AddBitstringStatusListEnumPG1741895823000();
7908
+ await mig.up(queryRunner);
7909
+ return;
7910
+ }
7911
+ case "sqlite":
7912
+ case "expo":
7913
+ case "react-native": {
7914
+ return;
7915
+ }
7916
+ default:
7917
+ return Promise.reject(`Migrations only supported for sqlite and postgres. Was ${dbType}`);
7918
+ }
7919
+ }
7920
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
7921
+ async down(queryRunner) {
7922
+ }
7923
+ };
7924
+ var CreateBitstringStatusList1741895823000 = class {
7925
+ static {
7926
+ __name(this, "CreateBitstringStatusList1741895823000");
7927
+ }
7928
+ name = "CreateBitstringStatusList1741895823000";
7929
+ async up(queryRunner) {
7930
+ debug11("migration: creating bitstring status list tables");
7931
+ const dbType = queryRunner.connection.driver.options.type;
7932
+ switch (dbType) {
7933
+ case "postgres": {
7934
+ const mig = new CreateBitstringStatusListPG1741895823000();
7935
+ await mig.up(queryRunner);
7936
+ return;
7937
+ }
7938
+ case "sqlite":
7939
+ case "expo":
7940
+ case "react-native": {
7941
+ const mig = new CreateBitstringStatusListSqlite1741895823001();
7942
+ await mig.up(queryRunner);
7943
+ return;
7944
+ }
7945
+ default:
7946
+ return Promise.reject(`Migrations only supported for sqlite and postgres. Was ${dbType}`);
8017
7947
  }
8018
7948
  }
8019
7949
  async down(queryRunner) {
8020
- debug11("migration: reverting issuance branding tables");
7950
+ debug11("migration: dropping bitstring status list tables");
8021
7951
  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`);
7952
+ switch (dbType) {
7953
+ case "postgres": {
7954
+ const mig = new CreateBitstringStatusListPG1741895823000();
7955
+ await mig.down(queryRunner);
7956
+ return;
7957
+ }
7958
+ case "sqlite":
7959
+ case "expo":
7960
+ case "react-native": {
7961
+ const mig = new CreateBitstringStatusListSqlite1741895823001();
7962
+ await mig.down(queryRunner);
7963
+ return;
7964
+ }
7965
+ default:
7966
+ return Promise.reject(`Migrations only supported for sqlite and postgres. Was ${dbType}`);
8040
7967
  }
8041
7968
  }
8042
7969
  };
8043
7970
 
8044
- // src/migrations/generic/5-CreateAuditEvents.ts
7971
+ // src/migrations/generic/13-UpdatePresentationDefinitionItemNullable.ts
8045
7972
  var import_debug12 = __toESM(require("debug"), 1);
8046
7973
 
8047
- // src/migrations/sqlite/1701634819487-CreateAuditEvents.ts
8048
- var CreateAuditEvents1701634819487 = class {
7974
+ // src/migrations/postgres/1756975509000-UpdatePresentationDefinitionItemNullable.ts
7975
+ var UpdatePresentationDefinitionItemNullablePG1741895824000 = class {
8049
7976
  static {
8050
- __name(this, "CreateAuditEvents1701634819487");
7977
+ __name(this, "UpdatePresentationDefinitionItemNullablePG1741895824000");
8051
7978
  }
8052
- name = "CreateAuditEvents1701634819487";
7979
+ name = "UpdatePresentationDefinitionItemNullable1741895824000";
8053
7980
  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')))`);
7981
+ await queryRunner.query(`ALTER TABLE "PresentationDefinitionItem" ALTER COLUMN "definition_payload" DROP NOT NULL`);
8081
7982
  }
8082
7983
  async down(queryRunner) {
8083
- await queryRunner.query(`DROP TABLE "AuditEvents"`);
7984
+ await queryRunner.query(`ALTER TABLE "PresentationDefinitionItem" ALTER COLUMN "definition_payload" SET NOT NULL`);
8084
7985
  }
8085
7986
  };
8086
7987
 
8087
- // src/migrations/postgres/1701634812183-CreateAuditEvents.ts
8088
- var CreateAuditEvents1701634812183 = class {
7988
+ // src/migrations/sqlite/1756975340000-UpdatePresentationDefinitionItemNullable.ts
7989
+ var UpdatePresentationDefinitionItemNullableSqlite1756975340000 = class {
8089
7990
  static {
8090
- __name(this, "CreateAuditEvents1701634812183");
7991
+ __name(this, "UpdatePresentationDefinitionItemNullableSqlite1756975340000");
8091
7992
  }
8092
- name = "CreateAuditEvents1701634812183";
7993
+ name = "UpdatePresentationDefinitionItemNullable1756975340000";
8093
7994
  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"))`);
7995
+ await queryRunner.query(`
7996
+ CREATE TABLE "temporary_PresentationDefinitionItem" (
7997
+ "id" varchar PRIMARY KEY NOT NULL,
7998
+ "definition_id" varchar(255) NOT NULL,
7999
+ "version" varchar(255) NOT NULL,
8000
+ "tenant_id" varchar(255),
8001
+ "purpose" varchar(255),
8002
+ "name" varchar(255),
8003
+ "definition_payload" text,
8004
+ "dcql_payload" text,
8005
+ "created_at" datetime NOT NULL DEFAULT (datetime('now')),
8006
+ "last_updated_at" datetime NOT NULL DEFAULT (datetime('now')),
8007
+ CONSTRAINT "UQ_PresentationDefinitionItem_definition_id_version" UNIQUE ("definition_id", "version")
8008
+ )
8009
+ `);
8010
+ await queryRunner.query(`
8011
+ INSERT INTO "temporary_PresentationDefinitionItem"(
8012
+ "id", "definition_id", "version", "tenant_id", "purpose", "name",
8013
+ "definition_payload", "dcql_payload", "created_at", "last_updated_at"
8014
+ )
8015
+ SELECT
8016
+ "id", "definition_id", "version", "tenant_id", "purpose", "name",
8017
+ "definition_payload", "dcql_payload", "created_at", "last_updated_at"
8018
+ FROM "PresentationDefinitionItem"
8019
+ `);
8020
+ await queryRunner.query(`DROP TABLE "PresentationDefinitionItem"`);
8021
+ await queryRunner.query(`ALTER TABLE "temporary_PresentationDefinitionItem" RENAME TO "PresentationDefinitionItem"`);
8022
+ await queryRunner.query(`CREATE INDEX "IDX_PresentationDefinitionItem_version" ON "PresentationDefinitionItem" ("version")`);
8130
8023
  }
8131
8024
  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"`);
8025
+ await queryRunner.query(`
8026
+ CREATE TABLE "temporary_PresentationDefinitionItem" (
8027
+ "id" varchar PRIMARY KEY NOT NULL,
8028
+ "definition_id" varchar(255) NOT NULL,
8029
+ "version" varchar(255) NOT NULL,
8030
+ "tenant_id" varchar(255),
8031
+ "purpose" varchar(255),
8032
+ "name" varchar(255),
8033
+ "definition_payload" text NOT NULL,
8034
+ "dcql_payload" text,
8035
+ "created_at" datetime NOT NULL DEFAULT (datetime('now')),
8036
+ "last_updated_at" datetime NOT NULL DEFAULT (datetime('now')),
8037
+ CONSTRAINT "UQ_PresentationDefinitionItem_definition_id_version" UNIQUE ("definition_id", "version")
8038
+ )
8039
+ `);
8040
+ await queryRunner.query(`
8041
+ INSERT INTO "temporary_PresentationDefinitionItem"(
8042
+ "id", "definition_id", "version", "tenant_id", "purpose", "name",
8043
+ "definition_payload", "dcql_payload", "created_at", "last_updated_at"
8044
+ )
8045
+ SELECT
8046
+ "id", "definition_id", "version", "tenant_id", "purpose", "name",
8047
+ "definition_payload", "dcql_payload", "created_at", "last_updated_at"
8048
+ FROM "PresentationDefinitionItem"
8049
+ `);
8050
+ await queryRunner.query(`DROP TABLE "PresentationDefinitionItem"`);
8051
+ await queryRunner.query(`ALTER TABLE "temporary_PresentationDefinitionItem" RENAME TO "PresentationDefinitionItem"`);
8052
+ await queryRunner.query(`CREATE INDEX "IDX_PresentationDefinitionItem_version" ON "PresentationDefinitionItem" ("version")`);
8140
8053
  }
8141
8054
  };
8142
8055
 
8143
- // src/migrations/generic/5-CreateAuditEvents.ts
8056
+ // src/migrations/generic/13-UpdatePresentationDefinitionItemNullable.ts
8144
8057
  var debug12 = (0, import_debug12.default)("sphereon:ssi-sdk:migrations");
8145
- var CreateAuditEvents1701635835330 = class {
8058
+ var UpdatePresentationDefinitionItemNullable1741895824000 = class {
8146
8059
  static {
8147
- __name(this, "CreateAuditEvents1701635835330");
8060
+ __name(this, "UpdatePresentationDefinitionItemNullable1741895824000");
8148
8061
  }
8149
- name = "CreateAuditEvents1701635835330";
8062
+ name = "UpdatePresentationDefinitionItemNullable1741895824000";
8150
8063
  async up(queryRunner) {
8151
- debug12("migration: creating audit events tables");
8064
+ debug12("migration: updating presentation definition item nullable fields");
8152
8065
  const dbType = queryRunner.connection.driver.options.type;
8153
8066
  switch (dbType) {
8154
8067
  case "postgres": {
8155
8068
  debug12("using postgres migration file");
8156
- const mig = new CreateAuditEvents1701634812183();
8069
+ const mig = new UpdatePresentationDefinitionItemNullablePG1741895824000();
8157
8070
  await mig.up(queryRunner);
8158
8071
  debug12("Migration statements executed");
8159
8072
  return;
@@ -8162,7 +8075,7 @@ var CreateAuditEvents1701635835330 = class {
8162
8075
  case "expo":
8163
8076
  case "react-native": {
8164
8077
  debug12("using sqlite/react-native migration file");
8165
- const mig = new CreateAuditEvents1701634819487();
8078
+ const mig = new UpdatePresentationDefinitionItemNullableSqlite1756975340000();
8166
8079
  await mig.up(queryRunner);
8167
8080
  debug12("Migration statements executed");
8168
8081
  return;
@@ -8172,12 +8085,12 @@ var CreateAuditEvents1701635835330 = class {
8172
8085
  }
8173
8086
  }
8174
8087
  async down(queryRunner) {
8175
- debug12("migration: reverting audit events tables");
8088
+ debug12("migration: reverting presentation definition item nullable fields");
8176
8089
  const dbType = queryRunner.connection.driver.options.type;
8177
8090
  switch (dbType) {
8178
8091
  case "postgres": {
8179
8092
  debug12("using postgres migration file");
8180
- const mig = new CreateAuditEvents1701634812183();
8093
+ const mig = new UpdatePresentationDefinitionItemNullablePG1741895824000();
8181
8094
  await mig.down(queryRunner);
8182
8095
  debug12("Migration statements executed");
8183
8096
  return;
@@ -8186,7 +8099,7 @@ var CreateAuditEvents1701635835330 = class {
8186
8099
  case "expo":
8187
8100
  case "react-native": {
8188
8101
  debug12("using sqlite/react-native migration file");
8189
- const mig = new CreateAuditEvents1701634819487();
8102
+ const mig = new UpdatePresentationDefinitionItemNullableSqlite1756975340000();
8190
8103
  await mig.down(queryRunner);
8191
8104
  debug12("Migration statements executed");
8192
8105
  return;
@@ -8197,247 +8110,299 @@ var CreateAuditEvents1701635835330 = class {
8197
8110
  }
8198
8111
  };
8199
8112
 
8200
- // src/migrations/generic/6-CreateDigitalCredential.ts
8113
+ // src/migrations/generic/2-CreateIssuanceBranding.ts
8201
8114
  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
8115
  var debug13 = (0, import_debug13.default)("sphereon:ssi-sdk:migrations");
8310
- var CreateDigitalCredential1708525189000 = class {
8116
+ var CreateIssuanceBranding1659463079429 = class {
8311
8117
  static {
8312
- __name(this, "CreateDigitalCredential1708525189000");
8118
+ __name(this, "CreateIssuanceBranding1659463079429");
8313
8119
  }
8314
- name = "CreateDigitalCredential1708525189000";
8120
+ name = "CreateIssuanceBranding1659463079429";
8315
8121
  async up(queryRunner) {
8316
- debug13("migration: creating DigitalCredential tables");
8122
+ debug13("migration: creating issuance branding tables");
8317
8123
  const dbType = queryRunner.connection.driver.options.type;
8318
8124
  switch (dbType) {
8319
8125
  case "postgres": {
8320
- debug13("using postgres migration file for DigitalCredential");
8321
- const mig = new CreateDigitalCredential1708525189001();
8126
+ debug13("using postgres migration file");
8127
+ const mig = new CreateIssuanceBranding1685628974232();
8322
8128
  await mig.up(queryRunner);
8323
- debug13("Postgres Migration statements for DigitalCredential executed");
8129
+ debug13("Migration statements executed");
8324
8130
  return;
8325
8131
  }
8326
8132
  case "sqlite":
8327
8133
  case "expo":
8328
8134
  case "react-native": {
8329
- debug13("using sqlite/react-native migration file for DigitalCredential");
8330
- const mig = new CreateDigitalCredential1708525189002();
8135
+ debug13("using sqlite/react-native migration file");
8136
+ const mig = new CreateIssuanceBranding1685628973231();
8331
8137
  await mig.up(queryRunner);
8332
- debug13("SQLite Migration statements for DigitalCredential executed");
8138
+ debug13("Migration statements executed");
8333
8139
  return;
8334
8140
  }
8335
8141
  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`);
8142
+ 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
8143
  }
8338
8144
  }
8339
8145
  async down(queryRunner) {
8340
- debug13("migration: reverting DigitalCredential tables");
8146
+ debug13("migration: reverting issuance branding tables");
8341
8147
  const dbType = queryRunner.connection.driver.options.type;
8342
8148
  switch (dbType) {
8343
8149
  case "postgres": {
8344
- debug13("using postgres migration file for DigitalCredential");
8345
- const mig = new CreateDigitalCredential1708525189001();
8150
+ debug13("using postgres migration file");
8151
+ const mig = new CreateIssuanceBranding1685628974232();
8346
8152
  await mig.down(queryRunner);
8347
- debug13("Postgres Migration statements for DigitalCredential reverted");
8153
+ debug13("Migration statements executed");
8348
8154
  return;
8349
8155
  }
8350
8156
  case "sqlite":
8351
8157
  case "expo":
8352
8158
  case "react-native": {
8353
- debug13("using sqlite/react-native migration file for DigitalCredential");
8354
- const mig = new CreateDigitalCredential1708525189002();
8159
+ debug13("using sqlite/react-native migration file");
8160
+ const mig = new CreateIssuanceBranding1685628973231();
8355
8161
  await mig.down(queryRunner);
8356
- debug13("SQLite Migration statements for DigitalCredential reverted");
8162
+ debug13("Migration statements executed");
8357
8163
  return;
8358
8164
  }
8359
8165
  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`);
8166
+ 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
8167
  }
8362
8168
  }
8363
8169
  };
8364
8170
 
8365
- // src/migrations/generic/7-CreateMachineStateStore.ts
8171
+ // src/migrations/generic/3-CreateContacts.ts
8366
8172
  var import_debug14 = __toESM(require("debug"), 1);
8367
8173
 
8368
- // src/migrations/postgres/1708797018115-CreateMachineStateStore.ts
8369
- var CreateMachineStateStore1708797018115 = class {
8174
+ // src/migrations/sqlite/1690925872693-CreateContacts.ts
8175
+ var CreateContacts1690925872693 = class {
8370
8176
  static {
8371
- __name(this, "CreateMachineStateStore1708797018115");
8177
+ __name(this, "CreateContacts1690925872693");
8372
8178
  }
8373
- name = "CreateMachineStateStore1708797018115";
8179
+ name = "CreateContacts1690925872693";
8374
8180
  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
- `);
8181
+ 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"))`);
8182
+ await queryRunner.query(`INSERT INTO "temporary_CorrelationIdentifier"("id", "type", "correlation_id", "identityId") SELECT "id", "type", "correlation_id", "identityId" FROM "CorrelationIdentifier"`);
8183
+ await queryRunner.query(`DROP TABLE "CorrelationIdentifier"`);
8184
+ await queryRunner.query(`ALTER TABLE "temporary_CorrelationIdentifier" RENAME TO "CorrelationIdentifier"`);
8185
+ 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"))`);
8186
+ 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"`);
8187
+ await queryRunner.query(`DROP TABLE "Identity"`);
8188
+ await queryRunner.query(`ALTER TABLE "temporary_Identity" RENAME TO "Identity"`);
8189
+ 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"))`);
8190
+ await queryRunner.query(`INSERT INTO "temporary_Connection"("id", "type", "identityId") SELECT "id", "type", "identityId" FROM "Connection"`);
8191
+ await queryRunner.query(`DROP TABLE "Connection"`);
8192
+ await queryRunner.query(`ALTER TABLE "temporary_Connection" RENAME TO "Connection"`);
8193
+ 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"))`);
8194
+ await queryRunner.query(`INSERT INTO "temporary_CorrelationIdentifier"("id", "type", "correlation_id", "identity_id") SELECT "id", "type", "correlation_id", "identityId" FROM "CorrelationIdentifier"`);
8195
+ await queryRunner.query(`DROP TABLE "CorrelationIdentifier"`);
8196
+ await queryRunner.query(`ALTER TABLE "temporary_CorrelationIdentifier" RENAME TO "CorrelationIdentifier"`);
8197
+ 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"))`);
8198
+ 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"`);
8199
+ await queryRunner.query(`DROP TABLE "Identity"`);
8200
+ await queryRunner.query(`ALTER TABLE "temporary_Identity" RENAME TO "Identity"`);
8201
+ 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"))`);
8202
+ await queryRunner.query(`INSERT INTO "temporary_Connection"("id", "type", "identity_id") SELECT "id", "type", "identityId" FROM "Connection"`);
8203
+ await queryRunner.query(`DROP TABLE "Connection"`);
8204
+ await queryRunner.query(`ALTER TABLE "temporary_Connection" RENAME TO "Connection"`);
8205
+ 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"))`);
8206
+ await queryRunner.query(`CREATE UNIQUE INDEX "IDX_PartyType_type_tenant_id" ON "PartyType" ("type", "tenant_id")`);
8207
+ 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"))`);
8208
+ await queryRunner.query(`CREATE INDEX "IDX_BaseContact_type" ON "BaseContact" ("type")`);
8209
+ 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')))`);
8210
+ await queryRunner.query(`CREATE UNIQUE INDEX "IDX_PartyRelationship_left_right" ON "PartyRelationship" ("left_id", "right_id")`);
8211
+ 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)`);
8212
+ 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"))`);
8213
+ await queryRunner.query(`CREATE INDEX "IDX_BaseConfig_type" ON "BaseConfig" ("type")`);
8214
+ 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)`);
8215
+ await queryRunner.query(`INSERT INTO "temporary_CorrelationIdentifier"("id", "type", "correlation_id", "identity_id") SELECT "id", "type", "correlation_id", "identity_id" FROM "CorrelationIdentifier"`);
8216
+ await queryRunner.query(`DROP TABLE "CorrelationIdentifier"`);
8217
+ await queryRunner.query(`ALTER TABLE "temporary_CorrelationIdentifier" RENAME TO "CorrelationIdentifier"`);
8218
+ await queryRunner.query(`DROP INDEX "IDX_BaseContact_type"`);
8219
+ 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)`);
8220
+ 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"`);
8221
+ await queryRunner.query(`DROP TABLE "BaseContact"`);
8222
+ await queryRunner.query(`ALTER TABLE "temporary_BaseContact" RENAME TO "BaseContact"`);
8223
+ await queryRunner.query(`CREATE INDEX "IDX_BaseContact_type" ON "BaseContact" ("type")`);
8224
+ await queryRunner.query(`DROP INDEX "IDX_PartyRelationship_left_right"`);
8225
+ 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)`);
8226
+ 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"`);
8227
+ await queryRunner.query(`DROP TABLE "PartyRelationship"`);
8228
+ await queryRunner.query(`ALTER TABLE "temporary_PartyRelationship" RENAME TO "PartyRelationship"`);
8229
+ await queryRunner.query(`CREATE UNIQUE INDEX "IDX_PartyRelationship_left_right" ON "PartyRelationship" ("left_id", "right_id")`);
8230
+ 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)`);
8231
+ 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)`);
8232
+ 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)`);
8233
+ 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"`);
8234
+ await queryRunner.query(`DROP TABLE "Party"`);
8235
+ await queryRunner.query(`ALTER TABLE "temporary_Party" RENAME TO "Party"`);
8236
+ 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)`);
8237
+ 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"`);
8238
+ await queryRunner.query(`DROP TABLE "Identity"`);
8239
+ await queryRunner.query(`ALTER TABLE "temporary_Identity" RENAME TO "Identity"`);
8240
+ 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)`);
8241
+ await queryRunner.query(`INSERT INTO "temporary_Connection"("id", "type", "identity_id") SELECT "id", "type", "identity_id" FROM "Connection"`);
8242
+ await queryRunner.query(`DROP TABLE "Connection"`);
8243
+ await queryRunner.query(`ALTER TABLE "temporary_Connection" RENAME TO "Connection"`);
8244
+ await queryRunner.query(`DROP INDEX "IDX_BaseConfig_type"`);
8245
+ 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)`);
8246
+ 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"`);
8247
+ await queryRunner.query(`DROP TABLE "BaseConfig"`);
8248
+ await queryRunner.query(`ALTER TABLE "temporary_BaseConfig" RENAME TO "BaseConfig"`);
8249
+ await queryRunner.query(`CREATE INDEX "IDX_BaseConfig_type" ON "BaseConfig" ("type")`);
8250
+ 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"`);
8251
+ await queryRunner.query(`DROP TABLE "BaseConfigEntity"`);
8252
+ 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'))`);
8253
+ 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'))`);
8254
+ 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"`);
8255
+ 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"`);
8256
+ await queryRunner.query(`DROP TABLE "Contact"`);
8392
8257
  }
8393
8258
  async down(queryRunner) {
8394
- await queryRunner.query(`DROP TABLE "MachineStateInfoEntity"`);
8259
+ 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))`);
8260
+ 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'`);
8261
+ await queryRunner.query(`DROP TABLE "BaseContact"`);
8262
+ await queryRunner.query(`DROP TABLE "Party"`);
8263
+ 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)`);
8264
+ 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"`);
8265
+ await queryRunner.query(`DROP TABLE "BaseConfig"`);
8266
+ 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)`);
8267
+ 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"`);
8268
+ await queryRunner.query(`DROP TABLE "Party"`);
8269
+ await queryRunner.query(`ALTER TABLE "temporary_Party" RENAME TO "Party"`);
8270
+ await queryRunner.query(`DROP INDEX "IDX_PartyRelationship_left_right"`);
8271
+ 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)`);
8272
+ 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"`);
8273
+ await queryRunner.query(`DROP TABLE "PartyRelationship"`);
8274
+ await queryRunner.query(`ALTER TABLE "temporary_PartyRelationship" RENAME TO "PartyRelationship"`);
8275
+ await queryRunner.query(`CREATE UNIQUE INDEX "IDX_PartyRelationship_left_right" ON "PartyRelationship" ("left_id", "right_id")`);
8276
+ await queryRunner.query(`DROP INDEX "IDX_BaseContact_type"`);
8277
+ 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)`);
8278
+ 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"`);
8279
+ await queryRunner.query(`DROP TABLE "BaseContact"`);
8280
+ await queryRunner.query(`ALTER TABLE "temporary_BaseContact" RENAME TO "BaseContact"`);
8281
+ await queryRunner.query(`CREATE INDEX "IDX_BaseContact_type" ON "BaseContact" ("type")`);
8282
+ await queryRunner.query(`DROP INDEX "IDX_BaseConfig_type"`);
8283
+ 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)`);
8284
+ 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"`);
8285
+ await queryRunner.query(`DROP TABLE "BaseConfig"`);
8286
+ await queryRunner.query(`ALTER TABLE "temporary_BaseConfig" RENAME TO "BaseConfig"`);
8287
+ await queryRunner.query(`CREATE INDEX "IDX_BaseConfig_type" ON "BaseConfig" ("type")`);
8288
+ await queryRunner.query(`DROP INDEX "IDX_PartyType_type_tenant_id"`);
8289
+ await queryRunner.query(`DROP TABLE "PartyType"`);
8290
+ await queryRunner.query(`DROP TABLE "Connection"`);
8291
+ await queryRunner.query(`DROP TABLE "Identity"`);
8292
+ await queryRunner.query(`DROP TABLE "CorrelationIdentifier"`);
8293
+ await queryRunner.query(`DROP TABLE "ElectronicAddress"`);
8294
+ await queryRunner.query(`DROP TABLE "PhysicalAddress"`);
8395
8295
  }
8396
8296
  };
8397
8297
 
8398
- // src/migrations/sqlite/1708796002272-CreateMachineStateStore.ts
8399
- var CreateMachineStateStore1708796002272 = class {
8298
+ // src/migrations/postgres/1690925872592-CreateContacts.ts
8299
+ var import_ssi_sdk22 = require("@sphereon/ssi-sdk.core");
8300
+ var CreateContacts1690925872592 = class {
8400
8301
  static {
8401
- __name(this, "CreateMachineStateStore1708796002272");
8302
+ __name(this, "CreateContacts1690925872592");
8402
8303
  }
8403
- name = "CreateMachineStateStore1708796002272";
8304
+ name = "CreateContacts1690925872592";
8404
8305
  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
- `);
8306
+ await (0, import_ssi_sdk22.enablePostgresUuidExtension)(queryRunner);
8307
+ await queryRunner.query(`ALTER TABLE "CorrelationIdentifier" DROP CONSTRAINT "FK_CorrelationIdentifier_identityId"`);
8308
+ await queryRunner.query(`ALTER TABLE "IdentityMetadata" DROP CONSTRAINT "FK_IdentityMetadata_identityId"`);
8309
+ await queryRunner.query(`ALTER TABLE "Identity" DROP CONSTRAINT "FK_Identity_contactId"`);
8310
+ await queryRunner.query(`ALTER TABLE "Connection" DROP CONSTRAINT "FK_Connection_identityId"`);
8311
+ await queryRunner.query(`ALTER TABLE "CorrelationIdentifier" RENAME COLUMN "identityId" TO "identity_id"`);
8312
+ await queryRunner.query(`ALTER TABLE "Connection" RENAME COLUMN "identityId" TO "identity_id"`);
8313
+ await queryRunner.query(`CREATE TYPE "public"."PartyType_type_enum" AS ENUM('naturalPerson', 'organization')`);
8314
+ await queryRunner.query(`CREATE TYPE "public"."PartyOrigin_type_enum" AS ENUM('INTERNAL', 'EXTERNAL')`);
8315
+ 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"))`);
8316
+ await queryRunner.query(`CREATE UNIQUE INDEX "IDX_PartyType_type_tenant_id" ON "PartyType" ("type", "tenant_id")`);
8317
+ 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"))`);
8318
+ await queryRunner.query(`CREATE INDEX "IDX_BaseContact_type" ON "BaseContact" ("type")`);
8319
+ 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"))`);
8320
+ await queryRunner.query(`CREATE UNIQUE INDEX "IDX_PartyRelationship_left_right" ON "PartyRelationship" ("left_id", "right_id")`);
8321
+ 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"))`);
8322
+ 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"))`);
8323
+ 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"))`);
8324
+ 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"))`);
8325
+ await queryRunner.query(`CREATE INDEX "IDX_BaseConfig_type" ON "BaseConfig" ("type")`);
8326
+ await queryRunner.query(`ALTER TABLE "Identity" RENAME COLUMN "contactId" TO "partyId"`);
8327
+ await queryRunner.query(`ALTER TABLE "Identity" ALTER COLUMN "roles" SET NOT NULL`);
8328
+ await queryRunner.query(`CREATE TYPE "public"."IdentityOrigin_type_enum" AS ENUM('INTERNAL', 'EXTERNAL')`);
8329
+ await queryRunner.query(`ALTER TABLE "Identity" ADD COLUMN "origin" "public"."IdentityOrigin_type_enum" DEFAULT 'EXTERNAL' NOT NULL`);
8330
+ await queryRunner.query(`ALTER TABLE "Identity" ALTER COLUMN "origin" DROP DEFAULT`);
8331
+ 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`);
8332
+ await queryRunner.query(`ALTER TABLE "IdentityMetadata" ADD CONSTRAINT "FK_IdentityMetadata_identityId" FOREIGN KEY ("identityId") REFERENCES "Identity"("id") ON DELETE CASCADE ON UPDATE NO ACTION`);
8333
+ 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`);
8334
+ 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`);
8335
+ 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`);
8336
+ await queryRunner.query(`ALTER TABLE "ElectronicAddress" ADD CONSTRAINT "FK_ElectronicAddress_partyId" FOREIGN KEY ("partyId") REFERENCES "Party"("id") ON DELETE CASCADE ON UPDATE NO ACTION`);
8337
+ await queryRunner.query(`ALTER TABLE "PhysicalAddress" ADD CONSTRAINT "FK_PhysicalAddress_partyId" FOREIGN KEY ("partyId") REFERENCES "Party" ("id") ON DELETE CASCADE ON UPDATE NO ACTION`);
8338
+ 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`);
8339
+ await queryRunner.query(`ALTER TABLE "Identity" ADD CONSTRAINT "FK_Identity_partyId" FOREIGN KEY ("partyId") REFERENCES "Party"("id") ON DELETE CASCADE ON UPDATE NO ACTION`);
8340
+ 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`);
8341
+ 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`);
8342
+ await queryRunner.query(`ALTER TABLE "CorrelationIdentifier" RENAME CONSTRAINT "UQ_Correlation_id" TO "UQ_CorrelationIdentifier_correlation_id"`);
8343
+ await queryRunner.query(`ALTER TABLE "Identity" RENAME CONSTRAINT "UQ_Identity_Alias" TO "UQ_Identity_alias"`);
8344
+ 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"`);
8345
+ await queryRunner.query(`DROP TABLE "BaseConfigEntity"`);
8346
+ 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())`);
8347
+ 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())`);
8348
+ 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"`);
8349
+ 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"`);
8350
+ await queryRunner.query(`DROP TABLE "Contact"`);
8421
8351
  }
8422
8352
  async down(queryRunner) {
8423
- await queryRunner.query(`DROP TABLE "MachineStateInfoEntity"`);
8353
+ await queryRunner.query(`ALTER TABLE "BaseConfig" DROP CONSTRAINT "FK_BaseConfig_connection_id"`);
8354
+ await queryRunner.query(`ALTER TABLE "Connection" DROP CONSTRAINT "FK_Connection_identity_id"`);
8355
+ await queryRunner.query(`ALTER TABLE "Identity" DROP CONSTRAINT "FK_Identity_partyId"`);
8356
+ await queryRunner.query(`ALTER TABLE "Party" DROP CONSTRAINT "FK_Party_party_type_id"`);
8357
+ await queryRunner.query(`ALTER TABLE "PhysicalAddress" DROP CONSTRAINT "FK_PhysicalAddress_partyId"`);
8358
+ await queryRunner.query(`ALTER TABLE "ElectronicAddress" DROP CONSTRAINT "FK_ElectronicAddress_partyId"`);
8359
+ await queryRunner.query(`ALTER TABLE "PartyRelationship" DROP CONSTRAINT "FK_PartyRelationship_right_id"`);
8360
+ await queryRunner.query(`ALTER TABLE "PartyRelationship" DROP CONSTRAINT "FK_PartyRelationship_left_id"`);
8361
+ await queryRunner.query(`ALTER TABLE "BaseContact" DROP CONSTRAINT "FK_BaseContact_party_id"`);
8362
+ await queryRunner.query(`ALTER TABLE "IdentityMetadata" DROP CONSTRAINT "FK_IdentityMetadata_identityId"`);
8363
+ await queryRunner.query(`ALTER TABLE "CorrelationIdentifier" DROP CONSTRAINT "FK_CorrelationIdentifier_identity_id"`);
8364
+ await queryRunner.query(`ALTER TABLE "Identity" ALTER COLUMN "roles" DROP NOT NULL`);
8365
+ await queryRunner.query(`ALTER TABLE "Identity" DROP COLUMN "origin"`);
8366
+ await queryRunner.query(`DROP TYPE "public"."IdentityOrigin_type_enum"`);
8367
+ await queryRunner.query(`ALTER TABLE "Identity" RENAME COLUMN "partyId" TO "contactId"`);
8368
+ await queryRunner.query(`ALTER TABLE "Connection" RENAME COLUMN "identity_id" TO "identityId"`);
8369
+ await queryRunner.query(`ALTER TABLE "CorrelationIdentifier" RENAME COLUMN "identity_id" TO "identityId"`);
8370
+ await queryRunner.query(`DROP INDEX "IDX_BaseConfig_type"`);
8371
+ await queryRunner.query(`DROP TABLE "BaseConfig"`);
8372
+ await queryRunner.query(`DROP TABLE "Party"`);
8373
+ await queryRunner.query(`DROP INDEX "IDX_PartyRelationship_left_right"`);
8374
+ await queryRunner.query(`DROP TABLE "PartyRelationship"`);
8375
+ await queryRunner.query(`DROP INDEX "IDX_BaseContact_type"`);
8376
+ await queryRunner.query(`DROP TABLE "BaseContact"`);
8377
+ await queryRunner.query(`DROP TABLE "ElectronicAddress"`);
8378
+ await queryRunner.query(`DROP TABLE "PhysicalAddress"`);
8379
+ await queryRunner.query(`DROP INDEX "IDX_PartyType_type_tenant_id"`);
8380
+ await queryRunner.query(`DROP TABLE "PartyType"`);
8381
+ await queryRunner.query(`DROP TYPE "public"."PartyOrigin_type_enum"`);
8382
+ await queryRunner.query(`DROP TYPE "public"."PartyType_type_enum"`);
8383
+ await queryRunner.query(`ALTER TABLE "Connection" ADD CONSTRAINT "FK_Connection_identityId" FOREIGN KEY ("identityId") REFERENCES "Identity"("id") ON DELETE CASCADE ON UPDATE NO ACTION`);
8384
+ await queryRunner.query(`ALTER TABLE "Identity" ADD CONSTRAINT "FK_Identity_contactId" FOREIGN KEY ("contactId") REFERENCES "Contact"("id") ON DELETE CASCADE ON UPDATE NO ACTION`);
8385
+ await queryRunner.query(`ALTER TABLE "IdentityMetadata" ADD CONSTRAINT "FK_IdentityMetadata_identityId" FOREIGN KEY ("identityId") REFERENCES "Identity"("id") ON DELETE CASCADE ON UPDATE NO ACTION`);
8386
+ await queryRunner.query(`ALTER TABLE "CorrelationIdentifier" ADD CONSTRAINT "FK_CorrelationIdentifier_identityId" FOREIGN KEY ("identityId") REFERENCES "Identity"("id") ON DELETE CASCADE ON UPDATE NO ACTION`);
8387
+ 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"))`);
8388
+ 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
8389
  }
8425
8390
  };
8426
8391
 
8427
- // src/migrations/generic/7-CreateMachineStateStore.ts
8392
+ // src/migrations/generic/3-CreateContacts.ts
8428
8393
  var debug14 = (0, import_debug14.default)("sphereon:ssi-sdk:migrations");
8429
- var CreateMachineStateStore1708098041262 = class {
8394
+ var CreateContacts1690925872318 = class {
8430
8395
  static {
8431
- __name(this, "CreateMachineStateStore1708098041262");
8396
+ __name(this, "CreateContacts1690925872318");
8432
8397
  }
8433
- name = "CreateMachineStateStore1708098041262";
8398
+ name = "CreateContacts1690925872318";
8434
8399
  async up(queryRunner) {
8435
- debug14("migration: creating machine state tables");
8400
+ debug14("migration: creating contacts tables");
8436
8401
  const dbType = queryRunner.connection.driver.options.type;
8437
8402
  switch (dbType) {
8438
8403
  case "postgres": {
8439
8404
  debug14("using postgres migration file");
8440
- const mig = new CreateMachineStateStore1708797018115();
8405
+ const mig = new CreateContacts1690925872592();
8441
8406
  await mig.up(queryRunner);
8442
8407
  debug14("Migration statements executed");
8443
8408
  return;
@@ -8446,7 +8411,7 @@ var CreateMachineStateStore1708098041262 = class {
8446
8411
  case "expo":
8447
8412
  case "react-native": {
8448
8413
  debug14("using sqlite/react-native migration file");
8449
- const mig = new CreateMachineStateStore1708796002272();
8414
+ const mig = new CreateContacts1690925872693();
8450
8415
  await mig.up(queryRunner);
8451
8416
  debug14("Migration statements executed");
8452
8417
  return;
@@ -8456,12 +8421,12 @@ var CreateMachineStateStore1708098041262 = class {
8456
8421
  }
8457
8422
  }
8458
8423
  async down(queryRunner) {
8459
- debug14("migration: reverting machine state tables");
8424
+ debug14("migration: reverting contacts tables");
8460
8425
  const dbType = queryRunner.connection.driver.options.type;
8461
8426
  switch (dbType) {
8462
8427
  case "postgres": {
8463
8428
  debug14("using postgres migration file");
8464
- const mig = new CreateMachineStateStore1708797018115();
8429
+ const mig = new CreateContacts1690925872592();
8465
8430
  await mig.down(queryRunner);
8466
8431
  debug14("Migration statements executed");
8467
8432
  return;
@@ -8470,7 +8435,7 @@ var CreateMachineStateStore1708098041262 = class {
8470
8435
  case "expo":
8471
8436
  case "react-native": {
8472
8437
  debug14("using sqlite/react-native migration file");
8473
- const mig = new CreateMachineStateStore1708796002272();
8438
+ const mig = new CreateContacts1690925872693();
8474
8439
  await mig.down(queryRunner);
8475
8440
  debug14("Migration statements executed");
8476
8441
  return;
@@ -8481,303 +8446,380 @@ var CreateMachineStateStore1708098041262 = class {
8481
8446
  }
8482
8447
  };
8483
8448
 
8484
- // src/migrations/generic/8-CreateContacts.ts
8449
+ // src/migrations/generic/4-CreateStatusList.ts
8485
8450
  var import_debug15 = __toESM(require("debug"), 1);
8486
8451
 
8487
- // src/migrations/postgres/1710438363001-CreateContacts.ts
8488
- var CreateContacts1710438363001 = class {
8452
+ // src/migrations/postgres/1693866470001-CreateStatusList.ts
8453
+ var CreateStatusList1693866470001 = class {
8489
8454
  static {
8490
- __name(this, "CreateContacts1710438363001");
8455
+ __name(this, "CreateStatusList1693866470001");
8491
8456
  }
8492
- name = "CreateContacts1710438363001";
8457
+ name = "CreateStatusList1693866470001";
8493
8458
  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`);
8459
+ await queryRunner.query(`CREATE TYPE "StatusList_type_enum" AS ENUM('StatusList2021')`);
8460
+ await queryRunner.query(`CREATE TYPE "StatusList_drivertype_enum" AS ENUM('agent_typeorm', 'agent_kv_store', 'github', 'agent_filesystem')`);
8461
+ await queryRunner.query(`CREATE TYPE "StatusList_credentialidmode_enum" AS ENUM('ISSUANCE', 'PERSISTENCE', 'NEVER')`);
8462
+ await queryRunner.query(`CREATE TABLE "StatusListEntry"
8463
+ (
8464
+ "statusListId" character varying NOT NULL,
8465
+ "statusListIndex" integer NOT NULL,
8466
+ "credentialId" character varying,
8467
+ "credentialHash" character varying(128),
8468
+ "correlationId" character varying(255),
8469
+ "value" character varying(50),
8470
+ CONSTRAINT "PK_68704d2d13857360c6b44a3d1d0" PRIMARY KEY ("statusListId", "statusListIndex")
8471
+ )`);
8472
+ await queryRunner.query(`CREATE TABLE "StatusList"
8473
+ (
8474
+ "id" character varying NOT NULL,
8475
+ "correlationId" character varying NOT NULL,
8476
+ "length" integer NOT NULL,
8477
+ "issuer" text NOT NULL,
8478
+ "type" "StatusList_type_enum" NOT NULL DEFAULT 'StatusList2021',
8479
+ "driverType" "StatusList_drivertype_enum" NOT NULL DEFAULT 'agent_typeorm',
8480
+ "credentialIdMode" "StatusList_credentialidmode_enum" NOT NULL DEFAULT 'ISSUANCE',
8481
+ "proofFormat" character varying NOT NULL DEFAULT 'lds',
8482
+ "indexingDirection" character varying NOT NULL DEFAULT 'rightToLeft',
8483
+ "statusPurpose" character varying NOT NULL DEFAULT 'revocation',
8484
+ "statusListCredential" text,
8485
+ CONSTRAINT "UQ_correlationId" UNIQUE ("correlationId"),
8486
+ CONSTRAINT "PK_StatusList_Id" PRIMARY KEY ("id")
8487
+ )`);
8488
+ await queryRunner.query(`ALTER TABLE "StatusListEntry"
8489
+ ADD CONSTRAINT "FK_statusListEntry_statusListId" FOREIGN KEY ("statusListId") REFERENCES "StatusList" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION`);
8512
8490
  }
8513
8491
  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"`);
8492
+ await queryRunner.query(`ALTER TABLE "StatusListEntry"
8493
+ DROP CONSTRAINT "FK_statusListEntry_statusListId"`);
8494
+ await queryRunner.query(`DROP TABLE "StatusListEntry"`);
8495
+ await queryRunner.query(`DROP TABLE "StatusList"`);
8496
+ await queryRunner.query(`DROP TYPE "StatusList_credentialidmode_enum"`);
8497
+ await queryRunner.query(`DROP TYPE "StatusList_drivertype_enum"`);
8498
+ await queryRunner.query(`DROP TYPE "StatusList_type_enum"`);
8532
8499
  }
8533
8500
  };
8534
8501
 
8535
- // src/migrations/sqlite/1710438363002-CreateContacts.ts
8536
- var CreateContacts1710438363002 = class {
8502
+ // src/migrations/sqlite/1693866470000-CreateStatusList.ts
8503
+ var CreateStatusList1693866470002 = class {
8537
8504
  static {
8538
- __name(this, "CreateContacts1710438363002");
8505
+ __name(this, "CreateStatusList1693866470002");
8539
8506
  }
8540
- name = "CreateContacts1710438363002";
8507
+ name = "CreateStatusList1693866470002";
8541
8508
  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`);
8509
+ await queryRunner.query(`CREATE TABLE "StatusListEntry"
8510
+ (
8511
+ "statusListId" varchar NOT NULL,
8512
+ "statusListIndex" integer NOT NULL,
8513
+ "credentialId" varchar,
8514
+ "credentialHash" varchar(128),
8515
+ "correlationId" varchar(255),
8516
+ "value" varchar(50),
8517
+ PRIMARY KEY ("statusListId", "statusListIndex")
8518
+ )`);
8519
+ await queryRunner.query(`CREATE TABLE "StatusList"
8520
+ (
8521
+ "id" varchar PRIMARY KEY NOT NULL,
8522
+ "correlationId" varchar NOT NULL,
8523
+ "length" integer NOT NULL,
8524
+ "issuer" text NOT NULL,
8525
+ "type" varchar CHECK ( "type" IN ('StatusList2021') ) NOT NULL DEFAULT ('StatusList2021'),
8526
+ "driverType" varchar CHECK ( "driverType" IN ('agent_typeorm', 'agent_kv_store', 'github',
8527
+ 'agent_filesystem') ) NOT NULL DEFAULT ('agent_typeorm'),
8528
+ "credentialIdMode" varchar CHECK ( "credentialIdMode" IN ('ISSUANCE', 'PERSISTENCE', 'NEVER') ) NOT NULL DEFAULT ('ISSUANCE'),
8529
+ "proofFormat" varchar CHECK ( "proofFormat" IN ('lds', 'jwt') ) NOT NULL DEFAULT ('lds'),
8530
+ "indexingDirection" varchar CHECK ( "indexingDirection" IN ('rightToLeft') ) NOT NULL DEFAULT ('rightToLeft'),
8531
+ "statusPurpose" varchar NOT NULL DEFAULT ('revocation'),
8532
+ "statusListCredential" text,
8533
+ CONSTRAINT "UQ_correlationId" UNIQUE ("correlationId")
8534
+ )`);
8535
+ await queryRunner.query(`CREATE TABLE "temporary_StatusListEntry"
8536
+ (
8537
+ "statusListId" varchar NOT NULL,
8538
+ "statusListIndex" integer NOT NULL,
8539
+ "credentialId" varchar,
8540
+ "credentialHash" varchar(128),
8541
+ "correlationId" varchar(255),
8542
+ "value" varchar(50),
8543
+ CONSTRAINT "FK_statusListEntry_statusListId" FOREIGN KEY ("statusListId") REFERENCES "StatusList" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION,
8544
+ PRIMARY KEY ("statusListId", "statusListIndex")
8545
+ )`);
8546
+ await queryRunner.query(`INSERT INTO "temporary_StatusListEntry"("statusListId", "statusListIndex", "credentialId",
8547
+ "credentialHash", "correlationId", "value")
8548
+ SELECT "statusListId", "statusListIndex", "credentialId", "credentialHash", "correlationId", "value"
8549
+ FROM "StatusListEntry"`);
8550
+ await queryRunner.query(`DROP TABLE "StatusListEntry"`);
8551
+ await queryRunner.query(`ALTER TABLE "temporary_StatusListEntry" RENAME TO "StatusListEntry"`);
8575
8552
  }
8576
8553
  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"`);
8554
+ await queryRunner.query(`DROP TABLE "StatusListEntry"`);
8555
+ await queryRunner.query(`DROP TABLE "StatusList"`);
8556
+ }
8557
+ };
8558
+
8559
+ // src/migrations/postgres/1737110469001-UpdateStatusList.ts
8560
+ var UpdateStatusList1737110469001 = class {
8561
+ static {
8562
+ __name(this, "UpdateStatusList1737110469001");
8563
+ }
8564
+ name = "UpdateStatusList1737110469001";
8565
+ async up(queryRunner) {
8566
+ await queryRunner.query(`ALTER TYPE "StatusList_type_enum" ADD VALUE 'OAuthStatusList'`);
8567
+ await queryRunner.query(`ALTER TABLE "StatusList" ALTER COLUMN "indexingDirection" DROP NOT NULL`);
8568
+ await queryRunner.query(`ALTER TABLE "StatusList" ALTER COLUMN "statusPurpose" DROP NOT NULL`);
8569
+ await queryRunner.query(`ALTER TABLE "StatusList" ADD "bitsPerStatus" integer DEFAULT 1`);
8570
+ await queryRunner.query(`ALTER TABLE "StatusList" ADD "expiresAt" timestamp with time zone`);
8571
+ }
8572
+ async down(queryRunner) {
8573
+ await queryRunner.query(`ALTER TABLE "StatusList" DROP COLUMN "expiresAt"`);
8574
+ await queryRunner.query(`ALTER TABLE "StatusList" DROP COLUMN "bitsPerStatus"`);
8575
+ await queryRunner.query(`ALTER TABLE "StatusList" ALTER COLUMN "statusPurpose" SET NOT NULL`);
8576
+ await queryRunner.query(`ALTER TABLE "StatusList" ALTER COLUMN "indexingDirection" SET NOT NULL`);
8577
+ }
8578
+ };
8579
+
8580
+ // src/migrations/sqlite/1737110469000-UpdateStatusList.ts
8581
+ var UpdateStatusList1737110469000 = class {
8582
+ static {
8583
+ __name(this, "UpdateStatusList1737110469000");
8584
+ }
8585
+ name = "UpdateStatusList1737110469000";
8586
+ async up(queryRunner) {
8587
+ await queryRunner.query(`CREATE TABLE "temporary_StatusList" (
8588
+ "id" varchar PRIMARY KEY NOT NULL,
8589
+ "correlationId" varchar NOT NULL,
8590
+ "length" integer NOT NULL,
8591
+ "issuer" text NOT NULL,
8592
+ "type" varchar CHECK( "type" IN ('StatusList2021', 'OAuthStatusList') ) NOT NULL DEFAULT ('StatusList2021'),
8593
+ "driverType" varchar CHECK( "driverType" IN ('agent_typeorm','agent_kv_store','github','agent_filesystem') ) NOT NULL DEFAULT ('agent_typeorm'),
8594
+ "credentialIdMode" varchar CHECK( "credentialIdMode" IN ('ISSUANCE','PERSISTENCE','NEVER') ) NOT NULL DEFAULT ('ISSUANCE'),
8595
+ "proofFormat" varchar CHECK( "proofFormat" IN ('lds','jwt') ) NOT NULL DEFAULT ('lds'),
8596
+ "indexingDirection" varchar CHECK( "indexingDirection" IN ('rightToLeft') ),
8597
+ "statusPurpose" varchar,
8598
+ "statusListCredential" text,
8599
+ "bitsPerStatus" integer,
8600
+ "expiresAt" datetime,
8601
+ CONSTRAINT "UQ_correlationId" UNIQUE ("correlationId")
8602
+ )`);
8603
+ await queryRunner.query(`INSERT INTO "temporary_StatusList"(
8604
+ "id", "correlationId", "length", "issuer", "type", "driverType",
8605
+ "credentialIdMode", "proofFormat", "indexingDirection", "statusPurpose",
8606
+ "statusListCredential"
8607
+ )
8608
+ SELECT
8609
+ "id", "correlationId", "length", "issuer", "type", "driverType",
8610
+ "credentialIdMode", "proofFormat", "indexingDirection", "statusPurpose",
8611
+ "statusListCredential"
8612
+ FROM "StatusList"`);
8613
+ await queryRunner.query(`DROP TABLE "StatusList"`);
8614
+ await queryRunner.query(`ALTER TABLE "temporary_StatusList" RENAME TO "StatusList"`);
8615
+ }
8616
+ async down(queryRunner) {
8617
+ await queryRunner.query(`
8618
+ ALTER TABLE "StatusListEntry"
8619
+ RENAME COLUMN "entryCorrelationId" TO "correlationId"
8620
+ `);
8621
+ await queryRunner.query(`
8622
+ ALTER TABLE "StatusListEntry"
8623
+ DROP COLUMN "statusListCorrelationId"
8624
+ `);
8625
+ await queryRunner.query(`CREATE TABLE "temporary_StatusList" (
8626
+ "id" varchar PRIMARY KEY NOT NULL,
8627
+ "correlationId" varchar NOT NULL,
8628
+ "length" integer NOT NULL,
8629
+ "issuer" text NOT NULL,
8630
+ "type" varchar CHECK( "type" IN ('StatusList2021') ) NOT NULL DEFAULT ('StatusList2021'),
8631
+ "driverType" varchar CHECK( "driverType" IN ('agent_typeorm','agent_kv_store','github','agent_filesystem') ) NOT NULL DEFAULT ('agent_typeorm'),
8632
+ "credentialIdMode" varchar CHECK( "credentialIdMode" IN ('ISSUANCE','PERSISTENCE','NEVER') ) NOT NULL DEFAULT ('ISSUANCE'),
8633
+ "proofFormat" varchar CHECK( "proofFormat" IN ('lds','jwt') ) NOT NULL DEFAULT ('lds'),
8634
+ "indexingDirection" varchar CHECK( "indexingDirection" IN ('rightToLeft') ) NOT NULL DEFAULT ('rightToLeft'),
8635
+ "statusPurpose" varchar NOT NULL DEFAULT ('revocation'),
8636
+ "statusListCredential" text,
8637
+ CONSTRAINT "UQ_correlationId" UNIQUE ("correlationId")
8638
+ )`);
8639
+ await queryRunner.query(`INSERT INTO "temporary_StatusList"(
8640
+ "id", "correlationId", "length", "issuer", "type", "driverType",
8641
+ "credentialIdMode", "proofFormat", "indexingDirection", "statusPurpose",
8642
+ "statusListCredential"
8643
+ )
8644
+ SELECT
8645
+ "id", "correlationId", "length", "issuer",
8646
+ CASE WHEN "type" = 'OAuthStatusList' THEN 'StatusList2021' ELSE "type" END,
8647
+ "driverType", "credentialIdMode", "proofFormat", "indexingDirection",
8648
+ COALESCE("statusPurpose", 'revocation'), "statusListCredential"
8649
+ FROM "StatusList"`);
8650
+ await queryRunner.query(`DROP TABLE "StatusList"`);
8651
+ await queryRunner.query(`ALTER TABLE "temporary_StatusList" RENAME TO "StatusList"`);
8595
8652
  }
8596
8653
  };
8597
8654
 
8598
- // src/migrations/generic/8-CreateContacts.ts
8655
+ // src/migrations/generic/4-CreateStatusList.ts
8599
8656
  var debug15 = (0, import_debug15.default)("sphereon:ssi-sdk:migrations");
8600
- var CreateContacts1708525189000 = class {
8657
+ var CreateStatusList1693866470000 = class {
8601
8658
  static {
8602
- __name(this, "CreateContacts1708525189000");
8659
+ __name(this, "CreateStatusList1693866470000");
8603
8660
  }
8604
- name = "CreateContacts1708525189000";
8661
+ name = "CreateStatusList1693866470000";
8605
8662
  async up(queryRunner) {
8606
- debug15("migration: updating contact tables");
8663
+ debug15("migration: creating issuance branding tables");
8607
8664
  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`);
8665
+ if (dbType === "postgres") {
8666
+ debug15("using postgres migration files");
8667
+ const createMig = new CreateStatusList1693866470001();
8668
+ await createMig.up(queryRunner);
8669
+ const updateMig = new UpdateStatusList1737110469001();
8670
+ const up = await updateMig.up(queryRunner);
8671
+ debug15("Migration statements executed");
8672
+ return up;
8673
+ } else if (dbType === "sqlite" || dbType === "react-native" || dbType === "expo") {
8674
+ debug15("using sqlite/react-native migration files");
8675
+ const createMig = new CreateStatusList1693866470002();
8676
+ await createMig.up(queryRunner);
8677
+ const updateMig = new UpdateStatusList1737110469000();
8678
+ const up = await updateMig.up(queryRunner);
8679
+ debug15("Migration statements executed");
8680
+ return up;
8681
+ } else {
8682
+ 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
8683
  }
8628
8684
  }
8629
8685
  async down(queryRunner) {
8630
- debug15("migration: reverting machine state tables");
8686
+ debug15("migration: reverting issuance branding tables");
8631
8687
  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`);
8688
+ if (dbType === "postgres") {
8689
+ debug15("using postgres migration files");
8690
+ const updateMig = new UpdateStatusList1737110469001();
8691
+ await updateMig.down(queryRunner);
8692
+ const createMig = new CreateStatusList1693866470001();
8693
+ const down = await createMig.down(queryRunner);
8694
+ debug15("Migration statements executed");
8695
+ return down;
8696
+ } else if (dbType === "sqlite" || dbType === "react-native" || dbType === "expo") {
8697
+ debug15("using sqlite/react-native migration files");
8698
+ const updateMig = new UpdateStatusList1737110469000();
8699
+ await updateMig.down(queryRunner);
8700
+ const createMig = new CreateStatusList1693866470002();
8701
+ const down = await createMig.down(queryRunner);
8702
+ debug15("Migration statements executed");
8703
+ return down;
8704
+ } else {
8705
+ 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
8706
  }
8652
8707
  }
8653
8708
  };
8654
8709
 
8655
- // src/migrations/generic/9-CreateContacts.ts
8710
+ // src/migrations/generic/5-CreateAuditEvents.ts
8656
8711
  var import_debug16 = __toESM(require("debug"), 1);
8657
8712
 
8658
- // src/migrations/postgres/1715761125001-CreateContacts.ts
8659
- var CreateContacts1715761125001 = class {
8713
+ // src/migrations/sqlite/1701634819487-CreateAuditEvents.ts
8714
+ var CreateAuditEvents1701634819487 = class {
8660
8715
  static {
8661
- __name(this, "CreateContacts1715761125001");
8716
+ __name(this, "CreateAuditEvents1701634819487");
8662
8717
  }
8663
- name = "CreateContacts1715761125001";
8718
+ name = "CreateAuditEvents1701634819487";
8664
8719
  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
- )`);
8720
+ await queryRunner.query(`CREATE TABLE "AuditEvents" (
8721
+ "id" varchar PRIMARY KEY NOT NULL,
8722
+ "eventType" varchar CHECK( "eventType" IN ('audit','activity','general') ) NOT NULL,
8723
+ "timestamp" datetime NOT NULL,
8724
+ "level" varchar CHECK( "level" IN ('0','1','2','3','4') ) NOT NULL,
8725
+ "correlationId" varchar NOT NULL,
8726
+ "system" varchar CHECK( "system" IN ('general','kms','identity','oid4vci','oid4vp','siopv2','PE','credentials','web3','profile','contact') ) NOT NULL,
8727
+ "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,
8728
+ "actionType" varchar CHECK( "actionType" IN ('create','read','update','delete','execute') ) NOT NULL,
8729
+ "actionSubType" varchar NOT NULL,
8730
+ "initiatorType" varchar CHECK( "initiatorType" IN ('user','system','external') ) NOT NULL,
8731
+ "systemCorrelationIdType" varchar CHECK( "systemCorrelationIdType" IN ('did','url','email','hostname','phone','user') ),
8732
+ "systemCorrelationId" varchar,
8733
+ "systemAlias" varchar,
8734
+ "partyCorrelationType" varchar CHECK( "partyCorrelationType" IN ('did','url','email','hostname','phone') ),
8735
+ "partyCorrelationId" varchar,
8736
+ "partyAlias" varchar,
8737
+ "credentialType" varchar CHECK( "credentialType" IN ('JSON_LD','JWT','SD_JWT','MSO_MDOC') ),
8738
+ "credentialHash" varchar,
8739
+ "parentCredentialHash" varchar,
8740
+ "originalCredential" varchar,
8741
+ "sharePurpose" varchar,
8742
+ "description" varchar NOT NULL,
8743
+ "data" varchar,
8744
+ "diagnosticData" varchar,
8745
+ "created_at" datetime NOT NULL DEFAULT (datetime('now')),
8746
+ "last_updated_at" datetime NOT NULL DEFAULT (datetime('now')))`);
8694
8747
  }
8695
8748
  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"`);
8749
+ await queryRunner.query(`DROP TABLE "AuditEvents"`);
8710
8750
  }
8711
8751
  };
8712
8752
 
8713
- // src/migrations/sqlite/1715761125002-CreateContacts.ts
8714
- var CreateContacts1715761125002 = class {
8753
+ // src/migrations/postgres/1701634812183-CreateAuditEvents.ts
8754
+ var CreateAuditEvents1701634812183 = class {
8715
8755
  static {
8716
- __name(this, "CreateContacts1715761125002");
8756
+ __name(this, "CreateAuditEvents1701634812183");
8717
8757
  }
8718
- name = "CreateContacts1715761125002";
8758
+ name = "CreateAuditEvents1701634812183";
8719
8759
  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)`);
8760
+ await queryRunner.query(`CREATE TYPE "public"."Level_enum" AS ENUM('0', '1', '2', '3', '4')`);
8761
+ await queryRunner.query(`CREATE TYPE "public"."System_enum" AS ENUM('general', 'kms', 'identity', 'oid4vci', 'oid4vp', 'siopv2', 'PE', 'credentials', 'web3', 'profile', 'contact')`);
8762
+ 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')`);
8763
+ await queryRunner.query(`CREATE TYPE "public"."Action_type_enum" AS ENUM('create', 'read', 'update', 'delete', 'execute')`);
8764
+ await queryRunner.query(`CREATE TYPE "public"."Initiator_type_enum" AS ENUM('user', 'system', 'external')`);
8765
+ await queryRunner.query(`CREATE TYPE "public"."System_correlation_id_type_enum" AS ENUM('did', 'url', 'email', 'hostname', 'phone', 'user')`);
8766
+ await queryRunner.query(`CREATE TYPE "public"."Party_correlation_type_enum" AS ENUM('did', 'url', 'email', 'hostname', 'phone')`);
8767
+ await queryRunner.query(`CREATE TYPE "public"."Event_type_enum" AS ENUM('audit', 'activity', 'general')`);
8768
+ await queryRunner.query(`CREATE TYPE "public"."Event_credential_type_enum" AS ENUM('JSON_LD', 'JWT', 'SD_JWT', 'MSO_MDOC')`);
8769
+ await queryRunner.query(`CREATE TABLE "AuditEvents" (
8770
+ "id" uuid NOT NULL DEFAULT uuid_generate_v4(),
8771
+ "eventType" "public"."Event_type_enum" NOT NULL,
8772
+ "timestamp" TIMESTAMP NOT NULL,
8773
+ "level" "public"."Level_enum" NOT NULL,
8774
+ "correlationId" TEXT NOT NULL,
8775
+ "system" "public"."System_enum" NOT NULL,
8776
+ "subSystemType" "public"."Subsystem_type_enum" NOT NULL,
8777
+ "actionType" "public"."Action_type_enum" NOT NULL,
8778
+ "actionSubType" TEXT NOT NULL,
8779
+ "initiatorType" "public"."Initiator_type_enum" NOT NULL,
8780
+ "systemCorrelationIdType" "public"."System_correlation_id_type_enum",
8781
+ "systemCorrelationId" TEXT,
8782
+ "systemAlias" TEXT,
8783
+ "partyCorrelationType" "public"."Party_correlation_type_enum",
8784
+ "partyCorrelationId" TEXT,
8785
+ "partyAlias" TEXT,
8786
+ "credentialType" "public"."Event_credential_type_enum",
8787
+ "credentialHash" TEXT,
8788
+ "originalCredential" TEXT,
8789
+ "sharePurpose" TEXT,
8790
+ "description" TEXT NOT NULL,
8791
+ "data" TEXT,
8792
+ "diagnosticData" TEXT,
8793
+ "created_at" TIMESTAMP NOT NULL DEFAULT now(),
8794
+ "last_updated_at" TIMESTAMP NOT NULL DEFAULT now(),
8795
+ CONSTRAINT "PK_AuditEvents_id" PRIMARY KEY ("id"))`);
8748
8796
  }
8749
8797
  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"`);
8798
+ await queryRunner.query(`DROP TABLE "AuditEvents"`);
8799
+ await queryRunner.query(`DROP TYPE "public"."Party_correlation_type_enum"`);
8800
+ await queryRunner.query(`DROP TYPE "public"."System_correlation_id_type_enum"`);
8801
+ await queryRunner.query(`DROP TYPE "public"."Initiator_type_enum"`);
8802
+ await queryRunner.query(`DROP TYPE "public"."Action_type_enum"`);
8803
+ await queryRunner.query(`DROP TYPE "public"."Subsystem_type_enum"`);
8804
+ await queryRunner.query(`DROP TYPE "public"."System_enum"`);
8805
+ await queryRunner.query(`DROP TYPE "public"."Level_enum"`);
8764
8806
  }
8765
8807
  };
8766
8808
 
8767
- // src/migrations/generic/9-CreateContacts.ts
8809
+ // src/migrations/generic/5-CreateAuditEvents.ts
8768
8810
  var debug16 = (0, import_debug16.default)("sphereon:ssi-sdk:migrations");
8769
- var CreateContacts1715761125000 = class {
8811
+ var CreateAuditEvents1701635835330 = class {
8770
8812
  static {
8771
- __name(this, "CreateContacts1715761125000");
8813
+ __name(this, "CreateAuditEvents1701635835330");
8772
8814
  }
8773
- name = "CreateContacts1715761125000";
8815
+ name = "CreateAuditEvents1701635835330";
8774
8816
  async up(queryRunner) {
8775
- debug16("migration: updating contact tables");
8817
+ debug16("migration: creating audit events tables");
8776
8818
  const dbType = queryRunner.connection.driver.options.type;
8777
8819
  switch (dbType) {
8778
8820
  case "postgres": {
8779
8821
  debug16("using postgres migration file");
8780
- const mig = new CreateContacts1715761125001();
8822
+ const mig = new CreateAuditEvents1701634812183();
8781
8823
  await mig.up(queryRunner);
8782
8824
  debug16("Migration statements executed");
8783
8825
  return;
@@ -8786,7 +8828,7 @@ var CreateContacts1715761125000 = class {
8786
8828
  case "expo":
8787
8829
  case "react-native": {
8788
8830
  debug16("using sqlite/react-native migration file");
8789
- const mig = new CreateContacts1715761125002();
8831
+ const mig = new CreateAuditEvents1701634819487();
8790
8832
  await mig.up(queryRunner);
8791
8833
  debug16("Migration statements executed");
8792
8834
  return;
@@ -8796,12 +8838,12 @@ var CreateContacts1715761125000 = class {
8796
8838
  }
8797
8839
  }
8798
8840
  async down(queryRunner) {
8799
- debug16("migration: reverting machine state tables");
8841
+ debug16("migration: reverting audit events tables");
8800
8842
  const dbType = queryRunner.connection.driver.options.type;
8801
8843
  switch (dbType) {
8802
8844
  case "postgres": {
8803
8845
  debug16("using postgres migration file");
8804
- const mig = new CreateContacts1715761125001();
8846
+ const mig = new CreateAuditEvents1701634812183();
8805
8847
  await mig.down(queryRunner);
8806
8848
  debug16("Migration statements executed");
8807
8849
  return;
@@ -8810,7 +8852,7 @@ var CreateContacts1715761125000 = class {
8810
8852
  case "expo":
8811
8853
  case "react-native": {
8812
8854
  debug16("using sqlite/react-native migration file");
8813
- const mig = new CreateContacts1715761125002();
8855
+ const mig = new CreateAuditEvents1701634819487();
8814
8856
  await mig.down(queryRunner);
8815
8857
  debug16("Migration statements executed");
8816
8858
  return;
@@ -8821,85 +8863,258 @@ var CreateContacts1715761125000 = class {
8821
8863
  }
8822
8864
  };
8823
8865
 
8824
- // src/migrations/generic/10-CreatePresentationDefinitions.ts
8866
+ // src/migrations/generic/6-CreateDigitalCredential.ts
8825
8867
  var import_debug17 = __toESM(require("debug"), 1);
8826
8868
 
8827
- // src/migrations/postgres/1716475165345-CreatePresentationDefinitions.ts
8828
- var CreatePresentationDefinitions1716475165345 = class {
8869
+ // src/migrations/postgres/1708525189001-CreateDigitalCredential.ts
8870
+ var CreateDigitalCredential1708525189001 = class {
8829
8871
  static {
8830
- __name(this, "CreatePresentationDefinitions1716475165345");
8872
+ __name(this, "CreateDigitalCredential1708525189001");
8831
8873
  }
8832
- name = "CreatePresentationDefinitions1716475165345";
8874
+ name = "CreateDigitalCredential1708525189001";
8833
8875
  async up(queryRunner) {
8876
+ await queryRunner.query(`CREATE TYPE "digital_document_type" AS ENUM('VC', 'VP', 'C', 'P')`);
8877
+ await queryRunner.query(`CREATE TYPE "digital_regulation_type" AS ENUM('PID', 'QEAA', 'EAA', 'NON_REGULATED')`);
8878
+ await queryRunner.query(`CREATE TYPE "digital_credential_document_format" AS ENUM('JSON_LD', 'JWT', 'SD_JWT', 'MSO_MDOC')`);
8879
+ await queryRunner.query(`CREATE TYPE "digital_credential_credential_role" AS ENUM('ISSUER', 'VERIFIER', 'HOLDER', 'FEDERATION_TRUST_ANCHOR')`);
8880
+ await queryRunner.query(`CREATE TYPE "digital_credential_correlation_type" AS ENUM('DID', 'KID', 'URL', 'X509_SAN')`);
8881
+ await queryRunner.query(`CREATE TYPE "digital_credential_state_type" AS ENUM('REVOKED', 'VERIFIED', 'EXPIRED')`);
8834
8882
  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
- `);
8883
+ CREATE TABLE "DigitalCredential" (
8884
+ "id" uuid NOT NULL DEFAULT uuid_generate_v4(),
8885
+ "parent_id" text,
8886
+ "document_type" "digital_document_type" NOT NULL,
8887
+ "regulation_type" "digital_regulation_type" NOT NULL DEFAULT 'NON_REGULATED'::"digital_regulation_type",
8888
+ "document_format" "digital_credential_document_format" NOT NULL,
8889
+ "credential_role" "digital_credential_credential_role" NOT NULL,
8890
+ "raw_document" text NOT NULL,
8891
+ "uniform_document" text NOT NULL,
8892
+ "credential_id" text,
8893
+ "hash" text NOT NULL,
8894
+ "kms_key_ref" text,
8895
+ "identifier_method" text,
8896
+ "issuer_correlation_type" "digital_credential_correlation_type" NOT NULL,
8897
+ "subject_correlation_type" "digital_credential_correlation_type",
8898
+ "issuer_correlation_id" text NOT NULL,
8899
+ "subject_correlation_id" text,
8900
+ "verified_state" "digital_credential_state_type",
8901
+ "issuer_signed" boolean,
8902
+ "rp_correlation_id" text,
8903
+ "rp_correlation_type" "digital_credential_correlation_type",
8904
+ "tenant_id" text,
8905
+ "created_at" TIMESTAMP NOT NULL DEFAULT now(),
8906
+ "last_updated_at" TIMESTAMP NOT NULL DEFAULT now(),
8907
+ "presented_at" DATE,
8908
+ "valid_from" DATE,
8909
+ "valid_until" DATE,
8910
+ "verified_at" DATE,
8911
+ "revoked_at" DATE,
8912
+ PRIMARY KEY ("id"),
8913
+ UNIQUE ("hash", "credential_role")
8914
+ )
8915
+ `);
8848
8916
  }
8849
8917
  async down(queryRunner) {
8850
- await queryRunner.query(`DROP TABLE "PresentationDefinitionItem"`);
8918
+ await queryRunner.query(`DROP TABLE "DigitalCredential"`);
8919
+ await queryRunner.query(`DROP TYPE "digital_credential_state_type"`);
8920
+ await queryRunner.query(`DROP TYPE "digital_credential_correlation_type"`);
8921
+ await queryRunner.query(`DROP TYPE "digital_credential_document_format"`);
8922
+ await queryRunner.query(`DROP TYPE "digital_credential_credential_role"`);
8923
+ await queryRunner.query(`DROP TYPE "digital_regulation_type"`);
8924
+ await queryRunner.query(`DROP TYPE "digital_document_type"`);
8851
8925
  }
8852
8926
  };
8853
8927
 
8854
- // src/migrations/sqlite/1716475165344-CreatePresentationDefinitions.ts
8855
- var CreatePresentationDefinitions1716475165344 = class {
8928
+ // src/migrations/sqlite/1708525189002-CreateDigitalCredential.ts
8929
+ var CreateDigitalCredential1708525189002 = class {
8856
8930
  static {
8857
- __name(this, "CreatePresentationDefinitions1716475165344");
8931
+ __name(this, "CreateDigitalCredential1708525189002");
8858
8932
  }
8859
- name = "CreatePresentationDefinitions1716475165344";
8933
+ name = "CreateDigitalCredential1708525189002";
8860
8934
  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')))`);
8935
+ await queryRunner.query(`
8936
+ CREATE TABLE "DigitalCredential" (
8937
+ "id" varchar PRIMARY KEY NOT NULL,
8938
+ "parent_id" text,
8939
+ "document_type" varchar CHECK( "document_type" IN ('VC', 'VP', 'C', 'P') ) NOT NULL,
8940
+ "regulation_type" varchar CHECK( "regulation_type" IN ('PID', 'QEAA', 'EAA', 'NON_REGULATED') ) NOT NULL DEFAULT 'NON_REGULATED',
8941
+ "document_format" varchar CHECK( "document_format" IN ('JSON_LD', 'JWT', 'SD_JWT', 'MSO_MDOC') ) NOT NULL,
8942
+ "credential_role" varchar CHECK( "credential_role" IN ('ISSUER', 'VERIFIER', 'HOLDER', 'FEDERATION_TRUST_ANCHOR') ) NOT NULL,
8943
+ "raw_document" text NOT NULL,
8944
+ "uniform_document" text NOT NULL,
8945
+ "credential_id" text,
8946
+ "hash" text NOT NULL,
8947
+ "kms_key_ref" text,
8948
+ "identifier_method" text,
8949
+ "issuer_correlation_type" varchar CHECK( "issuer_correlation_type" IN ('DID', 'KID', 'URL', 'X509_SAN') ) NOT NULL,
8950
+ "subject_correlation_type" varchar CHECK( "subject_correlation_type" IN ('DID', 'KID', 'URL', 'X509_SAN') ),
8951
+ "issuer_correlation_id" text NOT NULL,
8952
+ "subject_correlation_id" text,
8953
+ "issuer_signed" boolean,
8954
+ "rp_correlation_id" text,
8955
+ "rp_correlation_type" varchar CHECK( "issuer_correlation_type" IN ('DID', 'KID', 'URL', 'X509_SAN') ),
8956
+ "verified_state" varchar CHECK( "verified_state" IN ('REVOKED', 'VERIFIED', 'EXPIRED') ),
8957
+ "tenant_id" text,
8958
+ "created_at" datetime NOT NULL DEFAULT (datetime('now')),
8959
+ "last_updated_at" datetime NOT NULL DEFAULT (datetime('now')),
8960
+ "presented_at" datetime,
8961
+ "valid_from" datetime,
8962
+ "valid_until" datetime,
8963
+ "verified_at" datetime,
8964
+ "revoked_at" datetime,
8965
+ UNIQUE ("hash", "credential_role")
8966
+ )
8967
+ `);
8968
+ }
8969
+ async down(queryRunner) {
8970
+ await queryRunner.query(`DROP TABLE "DigitalCredential"`);
8971
+ }
8972
+ };
8973
+
8974
+ // src/migrations/generic/6-CreateDigitalCredential.ts
8975
+ var debug17 = (0, import_debug17.default)("sphereon:ssi-sdk:migrations");
8976
+ var CreateDigitalCredential1708525189000 = class {
8977
+ static {
8978
+ __name(this, "CreateDigitalCredential1708525189000");
8979
+ }
8980
+ name = "CreateDigitalCredential1708525189000";
8981
+ async up(queryRunner) {
8982
+ debug17("migration: creating DigitalCredential tables");
8983
+ const dbType = queryRunner.connection.driver.options.type;
8984
+ switch (dbType) {
8985
+ case "postgres": {
8986
+ debug17("using postgres migration file for DigitalCredential");
8987
+ const mig = new CreateDigitalCredential1708525189001();
8988
+ await mig.up(queryRunner);
8989
+ debug17("Postgres Migration statements for DigitalCredential executed");
8990
+ return;
8991
+ }
8992
+ case "sqlite":
8993
+ case "expo":
8994
+ case "react-native": {
8995
+ debug17("using sqlite/react-native migration file for DigitalCredential");
8996
+ const mig = new CreateDigitalCredential1708525189002();
8997
+ await mig.up(queryRunner);
8998
+ debug17("SQLite Migration statements for DigitalCredential executed");
8999
+ return;
9000
+ }
9001
+ default:
9002
+ 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`);
9003
+ }
9004
+ }
9005
+ async down(queryRunner) {
9006
+ debug17("migration: reverting DigitalCredential tables");
9007
+ const dbType = queryRunner.connection.driver.options.type;
9008
+ switch (dbType) {
9009
+ case "postgres": {
9010
+ debug17("using postgres migration file for DigitalCredential");
9011
+ const mig = new CreateDigitalCredential1708525189001();
9012
+ await mig.down(queryRunner);
9013
+ debug17("Postgres Migration statements for DigitalCredential reverted");
9014
+ return;
9015
+ }
9016
+ case "sqlite":
9017
+ case "expo":
9018
+ case "react-native": {
9019
+ debug17("using sqlite/react-native migration file for DigitalCredential");
9020
+ const mig = new CreateDigitalCredential1708525189002();
9021
+ await mig.down(queryRunner);
9022
+ debug17("SQLite Migration statements for DigitalCredential reverted");
9023
+ return;
9024
+ }
9025
+ default:
9026
+ 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`);
9027
+ }
9028
+ }
9029
+ };
9030
+
9031
+ // src/migrations/generic/7-CreateMachineStateStore.ts
9032
+ var import_debug18 = __toESM(require("debug"), 1);
9033
+
9034
+ // src/migrations/postgres/1708797018115-CreateMachineStateStore.ts
9035
+ var CreateMachineStateStore1708797018115 = class {
9036
+ static {
9037
+ __name(this, "CreateMachineStateStore1708797018115");
9038
+ }
9039
+ name = "CreateMachineStateStore1708797018115";
9040
+ async up(queryRunner) {
9041
+ await queryRunner.query(`
9042
+ CREATE TABLE "MachineStateInfoEntity" (
9043
+ "instance_id" text NOT NULL,
9044
+ "session_id" text,
9045
+ "latest_state_name" text,
9046
+ "machine_name" text NOT NULL,
9047
+ "latest_event_type" text NOT NULL,
9048
+ "state" text NOT NULL,
9049
+ "created_at" TIMESTAMP NOT NULL DEFAULT now(),
9050
+ "updated_at" TIMESTAMP NOT NULL DEFAULT now(),
9051
+ "updated_count" integer NOT NULL DEFAULT 0,
9052
+ "expires_at" TIMESTAMP,
9053
+ "completed_at" TIMESTAMP,
9054
+ "tenant_id" text,
9055
+ CONSTRAINT "PK_MachineStateInfoEntity_id" PRIMARY KEY ("instance_id")
9056
+ )
9057
+ `);
9058
+ }
9059
+ async down(queryRunner) {
9060
+ await queryRunner.query(`DROP TABLE "MachineStateInfoEntity"`);
9061
+ }
9062
+ };
9063
+
9064
+ // src/migrations/sqlite/1708796002272-CreateMachineStateStore.ts
9065
+ var CreateMachineStateStore1708796002272 = class {
9066
+ static {
9067
+ __name(this, "CreateMachineStateStore1708796002272");
9068
+ }
9069
+ name = "CreateMachineStateStore1708796002272";
9070
+ async up(queryRunner) {
9071
+ await queryRunner.query(`
9072
+ CREATE TABLE "MachineStateInfoEntity" (
9073
+ "instance_id" varchar PRIMARY KEY NOT NULL,
9074
+ "session_id" varchar,
9075
+ "machine_name" varchar NOT NULL,
9076
+ "latest_state_name" varchar,
9077
+ "latest_event_type" varchar NOT NULL,
9078
+ "state" text NOT NULL,
9079
+ "created_at" datetime NOT NULL DEFAULT (datetime('now')),
9080
+ "updated_at" datetime NOT NULL DEFAULT (datetime('now')),
9081
+ "updated_count" integer NOT NULL DEFAULT 0,
9082
+ "expires_at" datetime,
9083
+ "completed_at" datetime,
9084
+ "tenant_id" varchar
9085
+ )
9086
+ `);
8872
9087
  }
8873
9088
  async down(queryRunner) {
8874
- await queryRunner.query(`DROP TABLE "PresentationDefinitionItem"`);
9089
+ await queryRunner.query(`DROP TABLE "MachineStateInfoEntity"`);
8875
9090
  }
8876
9091
  };
8877
9092
 
8878
- // src/migrations/generic/10-CreatePresentationDefinitions.ts
8879
- var debug17 = (0, import_debug17.default)("sphereon:ssi-sdk:migrations");
8880
- var CreatePresentationDefinitions1716533767523 = class {
9093
+ // src/migrations/generic/7-CreateMachineStateStore.ts
9094
+ var debug18 = (0, import_debug18.default)("sphereon:ssi-sdk:migrations");
9095
+ var CreateMachineStateStore1708098041262 = class {
8881
9096
  static {
8882
- __name(this, "CreatePresentationDefinitions1716533767523");
9097
+ __name(this, "CreateMachineStateStore1708098041262");
8883
9098
  }
8884
- name = "CreatePresentationDefinitionItems1716533767523";
9099
+ name = "CreateMachineStateStore1708098041262";
8885
9100
  async up(queryRunner) {
8886
- debug17("migration: creating machine state tables");
9101
+ debug18("migration: creating machine state tables");
8887
9102
  const dbType = queryRunner.connection.driver.options.type;
8888
9103
  switch (dbType) {
8889
9104
  case "postgres": {
8890
- debug17("using postgres migration file");
8891
- const mig = new CreatePresentationDefinitions1716475165345();
9105
+ debug18("using postgres migration file");
9106
+ const mig = new CreateMachineStateStore1708797018115();
8892
9107
  await mig.up(queryRunner);
8893
- debug17("Migration statements executed");
9108
+ debug18("Migration statements executed");
8894
9109
  return;
8895
9110
  }
8896
9111
  case "sqlite":
8897
9112
  case "expo":
8898
9113
  case "react-native": {
8899
- debug17("using sqlite/react-native migration file");
8900
- const mig = new CreatePresentationDefinitions1716475165344();
9114
+ debug18("using sqlite/react-native migration file");
9115
+ const mig = new CreateMachineStateStore1708796002272();
8901
9116
  await mig.up(queryRunner);
8902
- debug17("Migration statements executed");
9117
+ debug18("Migration statements executed");
8903
9118
  return;
8904
9119
  }
8905
9120
  default:
@@ -8907,23 +9122,23 @@ var CreatePresentationDefinitions1716533767523 = class {
8907
9122
  }
8908
9123
  }
8909
9124
  async down(queryRunner) {
8910
- debug17("migration: reverting machine state tables");
9125
+ debug18("migration: reverting machine state tables");
8911
9126
  const dbType = queryRunner.connection.driver.options.type;
8912
9127
  switch (dbType) {
8913
9128
  case "postgres": {
8914
- debug17("using postgres migration file");
8915
- const mig = new CreatePresentationDefinitions1716475165345();
9129
+ debug18("using postgres migration file");
9130
+ const mig = new CreateMachineStateStore1708797018115();
8916
9131
  await mig.down(queryRunner);
8917
- debug17("Migration statements executed");
9132
+ debug18("Migration statements executed");
8918
9133
  return;
8919
9134
  }
8920
9135
  case "sqlite":
8921
9136
  case "expo":
8922
9137
  case "react-native": {
8923
- debug17("using sqlite/react-native migration file");
8924
- const mig = new CreatePresentationDefinitions1716475165344();
9138
+ debug18("using sqlite/react-native migration file");
9139
+ const mig = new CreateMachineStateStore1708796002272();
8925
9140
  await mig.down(queryRunner);
8926
- debug17("Migration statements executed");
9141
+ debug18("Migration statements executed");
8927
9142
  return;
8928
9143
  }
8929
9144
  default:
@@ -8932,108 +9147,145 @@ var CreatePresentationDefinitions1716533767523 = class {
8932
9147
  }
8933
9148
  };
8934
9149
 
8935
- // src/migrations/generic/11-FixCredentialClaimsReferenceUuid.ts
8936
- var import_debug18 = __toESM(require("debug"), 1);
9150
+ // src/migrations/generic/8-CreateContacts.ts
9151
+ var import_debug19 = __toESM(require("debug"), 1);
8937
9152
 
8938
- // src/migrations/postgres/1741895822987-FixCredentialClaimsReferencesUuid.ts
8939
- var FixCredentialClaimsReferencesUuidPG1741895822987 = class {
9153
+ // src/migrations/postgres/1710438363001-CreateContacts.ts
9154
+ var CreateContacts1710438363001 = class {
8940
9155
  static {
8941
- __name(this, "FixCredentialClaimsReferencesUuidPG1741895822987");
9156
+ __name(this, "CreateContacts1710438363001");
8942
9157
  }
8943
- name = "FixCredentialClaimsReferencesUuid1741895822987";
9158
+ name = "CreateContacts1710438363001";
8944
9159
  async up(queryRunner) {
8945
- await queryRunner.query(`
8946
- ALTER TABLE "CredentialClaims"
8947
- ALTER COLUMN "credentialLocaleBrandingId" TYPE uuid USING "credentialLocaleBrandingId"::uuid;
8948
- `);
9160
+ await queryRunner.query(`ALTER TABLE "Party" ADD COLUMN "owner_id" uuid`);
9161
+ await queryRunner.query(`ALTER TABLE "Party" ADD COLUMN "tenant_id" uuid`);
9162
+ await queryRunner.query(`ALTER TABLE "Identity" ADD COLUMN "owner_id" uuid`);
9163
+ await queryRunner.query(`ALTER TABLE "Identity" ADD COLUMN "tenant_id" uuid`);
9164
+ await queryRunner.query(`ALTER TABLE "CorrelationIdentifier" ADD COLUMN "owner_id" uuid`);
9165
+ await queryRunner.query(`ALTER TABLE "CorrelationIdentifier" ADD COLUMN "tenant_id" uuid`);
9166
+ await queryRunner.query(`ALTER TABLE "Connection" ADD COLUMN "owner_id" uuid`);
9167
+ await queryRunner.query(`ALTER TABLE "Connection" ADD COLUMN "tenant_id" uuid`);
9168
+ await queryRunner.query(`ALTER TABLE "BaseConfig" ADD COLUMN "owner_id" uuid`);
9169
+ await queryRunner.query(`ALTER TABLE "BaseConfig" ADD COLUMN "tenant_id" uuid`);
9170
+ await queryRunner.query(`ALTER TABLE "BaseContact" ADD COLUMN "owner_id" uuid`);
9171
+ await queryRunner.query(`ALTER TABLE "BaseContact" ADD COLUMN "tenant_id" uuid`);
9172
+ await queryRunner.query(`ALTER TABLE "PartyRelationship" ADD COLUMN "owner_id" uuid`);
9173
+ await queryRunner.query(`ALTER TABLE "PartyRelationship" ADD COLUMN "tenant_id" uuid`);
9174
+ await queryRunner.query(`ALTER TABLE "ElectronicAddress" ADD COLUMN "owner_id" uuid`);
9175
+ await queryRunner.query(`ALTER TABLE "ElectronicAddress" ADD COLUMN "tenant_id" uuid`);
9176
+ await queryRunner.query(`ALTER TABLE "PhysicalAddress" ADD COLUMN "owner_id" uuid`);
9177
+ await queryRunner.query(`ALTER TABLE "PhysicalAddress" ADD COLUMN "tenant_id" uuid`);
8949
9178
  }
8950
9179
  async down(queryRunner) {
8951
- await queryRunner.query(`
8952
- ALTER TABLE "CredentialClaims"
8953
- ALTER COLUMN "credentialLocaleBrandingId" TYPE character varying USING "credentialLocaleBrandingId"::text;
8954
- `);
9180
+ await queryRunner.query(`ALTER TABLE "PhysicalAddress" DROP COLUMN "tenant_id"`);
9181
+ await queryRunner.query(`ALTER TABLE "PhysicalAddress" DROP COLUMN "owner_id"`);
9182
+ await queryRunner.query(`ALTER TABLE "ElectronicAddress" DROP COLUMN "tenant_id"`);
9183
+ await queryRunner.query(`ALTER TABLE "ElectronicAddress" DROP COLUMN "owner_id"`);
9184
+ await queryRunner.query(`ALTER TABLE "PartyRelationship" DROP COLUMN "tenant_id"`);
9185
+ await queryRunner.query(`ALTER TABLE "PartyRelationship" DROP COLUMN "owner_id"`);
9186
+ await queryRunner.query(`ALTER TABLE "BaseContact" DROP COLUMN "tenant_id"`);
9187
+ await queryRunner.query(`ALTER TABLE "BaseContact" DROP COLUMN "owner_id"`);
9188
+ await queryRunner.query(`ALTER TABLE "BaseConfig" DROP COLUMN "tenant_id"`);
9189
+ await queryRunner.query(`ALTER TABLE "BaseConfig" DROP COLUMN "owner_id"`);
9190
+ await queryRunner.query(`ALTER TABLE "Connection" DROP COLUMN "tenant_id"`);
9191
+ await queryRunner.query(`ALTER TABLE "Connection" DROP COLUMN "owner_id"`);
9192
+ await queryRunner.query(`ALTER TABLE "CorrelationIdentifier" DROP COLUMN "tenant_id"`);
9193
+ await queryRunner.query(`ALTER TABLE "CorrelationIdentifier" DROP COLUMN "owner_id"`);
9194
+ await queryRunner.query(`ALTER TABLE "Identity" DROP COLUMN "tenant_id"`);
9195
+ await queryRunner.query(`ALTER TABLE "Identity" DROP COLUMN "owner_id"`);
9196
+ await queryRunner.query(`ALTER TABLE "Party" DROP COLUMN "tenant_id"`);
9197
+ await queryRunner.query(`ALTER TABLE "Party" DROP COLUMN "owner_id"`);
8955
9198
  }
8956
9199
  };
8957
9200
 
8958
- // src/migrations/sqlite/1741895822987-FixCredentialClaimsReferencesUuid.ts
8959
- var FixCredentialClaimsReferencesUuidSqlite1741895822987 = class {
9201
+ // src/migrations/sqlite/1710438363002-CreateContacts.ts
9202
+ var CreateContacts1710438363002 = class {
8960
9203
  static {
8961
- __name(this, "FixCredentialClaimsReferencesUuidSqlite1741895822987");
9204
+ __name(this, "CreateContacts1710438363002");
8962
9205
  }
8963
- name = "FixCredentialClaimsReferencesUuid1741895822987";
9206
+ name = "CreateContacts1710438363002";
8964
9207
  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
- `);
9208
+ await queryRunner.query(`ALTER TABLE "Party" ADD COLUMN "owner_id" text`);
9209
+ await queryRunner.query(`ALTER TABLE "Party" ADD COLUMN "tenant_id" text`);
9210
+ await queryRunner.query(`CREATE TABLE "temporary_Identity" (
9211
+ "id" varchar PRIMARY KEY NOT NULL,
9212
+ "alias" varchar(255) NOT NULL,
9213
+ "roles" text NOT NULL,
9214
+ "origin" text NOT NULL,
9215
+ "created_at" datetime NOT NULL DEFAULT (datetime('now')),
9216
+ "last_updated_at" datetime NOT NULL DEFAULT (datetime('now')),
9217
+ "partyId" varchar,
9218
+ "owner_id" text,
9219
+ "tenant_id" text,
9220
+ CONSTRAINT "UQ_Identity_alias" UNIQUE ("alias"),
9221
+ CONSTRAINT "FK_Identity_partyId" FOREIGN KEY ("partyId") REFERENCES "Party" ("id") ON DELETE CASCADE ON UPDATE NO ACTION
9222
+ )`);
9223
+ await queryRunner.query(`INSERT INTO "temporary_Identity"("id", "alias", "roles", "created_at", "last_updated_at", "partyId", "owner_id", "tenant_id", "origin")
9224
+ SELECT "id", "alias", "roles", 'EXTERNAL' as "origin", "created_at", "last_updated_at", "partyId", NULL as "owner_id", NULL as "tenant_id" FROM "Identity"`);
9225
+ await queryRunner.query(`DROP TABLE "Identity"`);
9226
+ await queryRunner.query(`ALTER TABLE "temporary_Identity" RENAME TO "Identity"`);
9227
+ await queryRunner.query(`ALTER TABLE "CorrelationIdentifier" ADD COLUMN "owner_id" text`);
9228
+ await queryRunner.query(`ALTER TABLE "CorrelationIdentifier" ADD COLUMN "tenant_id" text`);
9229
+ await queryRunner.query(`ALTER TABLE "Connection" ADD COLUMN "owner_id" text`);
9230
+ await queryRunner.query(`ALTER TABLE "Connection" ADD COLUMN "tenant_id" text`);
9231
+ await queryRunner.query(`ALTER TABLE "BaseConfig" ADD COLUMN "owner_id" text`);
9232
+ await queryRunner.query(`ALTER TABLE "BaseConfig" ADD COLUMN "tenant_id" text`);
9233
+ await queryRunner.query(`ALTER TABLE "BaseContact" ADD COLUMN "owner_id" text`);
9234
+ await queryRunner.query(`ALTER TABLE "BaseContact" ADD COLUMN "tenant_id" text`);
9235
+ await queryRunner.query(`ALTER TABLE "PartyRelationship" ADD COLUMN "owner_id" text`);
9236
+ await queryRunner.query(`ALTER TABLE "PartyRelationship" ADD COLUMN "tenant_id" text`);
9237
+ await queryRunner.query(`ALTER TABLE "ElectronicAddress" ADD COLUMN "owner_id" text`);
9238
+ await queryRunner.query(`ALTER TABLE "ElectronicAddress" ADD COLUMN "tenant_id" text`);
9239
+ await queryRunner.query(`ALTER TABLE "PhysicalAddress" ADD COLUMN "owner_id" text`);
9240
+ await queryRunner.query(`ALTER TABLE "PhysicalAddress" ADD COLUMN "tenant_id" text`);
8986
9241
  }
8987
9242
  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
- `);
9243
+ await queryRunner.query(`ALTER TABLE "PhysicalAddress" DROP COLUMN "tenant_id"`);
9244
+ await queryRunner.query(`ALTER TABLE "PhysicalAddress" DROP COLUMN "owner_id"`);
9245
+ await queryRunner.query(`ALTER TABLE "ElectronicAddress" DROP COLUMN "tenant_id"`);
9246
+ await queryRunner.query(`ALTER TABLE "ElectronicAddress" DROP COLUMN "owner_id"`);
9247
+ await queryRunner.query(`ALTER TABLE "PartyRelationship" DROP COLUMN "tenant_id"`);
9248
+ await queryRunner.query(`ALTER TABLE "PartyRelationship" DROP COLUMN "owner_id"`);
9249
+ await queryRunner.query(`ALTER TABLE "BaseContact" DROP COLUMN "tenant_id"`);
9250
+ await queryRunner.query(`ALTER TABLE "BaseContact" DROP COLUMN "owner_id"`);
9251
+ await queryRunner.query(`ALTER TABLE "BaseConfig" DROP COLUMN "tenant_id"`);
9252
+ await queryRunner.query(`ALTER TABLE "BaseConfig" DROP COLUMN "owner_id"`);
9253
+ await queryRunner.query(`ALTER TABLE "Connection" DROP COLUMN "tenant_id"`);
9254
+ await queryRunner.query(`ALTER TABLE "Connection" DROP COLUMN "owner_id"`);
9255
+ await queryRunner.query(`ALTER TABLE "CorrelationIdentifier" DROP COLUMN "tenant_id"`);
9256
+ await queryRunner.query(`ALTER TABLE "CorrelationIdentifier" DROP COLUMN "owner_id"`);
9257
+ await queryRunner.query(`ALTER TABLE "Identity" DROP COLUMN "tenant_id"`);
9258
+ await queryRunner.query(`ALTER TABLE "Identity" DROP COLUMN "owner_id"`);
9259
+ await queryRunner.query(`ALTER TABLE "Party" DROP COLUMN "tenant_id"`);
9260
+ await queryRunner.query(`ALTER TABLE "Party" DROP COLUMN "owner_id"`);
9009
9261
  }
9010
9262
  };
9011
9263
 
9012
- // src/migrations/generic/11-FixCredentialClaimsReferenceUuid.ts
9013
- var debug18 = (0, import_debug18.default)("sphereon:ssi-sdk:migrations");
9014
- var FixCredentialClaimsReferencesUuid1741895822987 = class {
9264
+ // src/migrations/generic/8-CreateContacts.ts
9265
+ var debug19 = (0, import_debug19.default)("sphereon:ssi-sdk:migrations");
9266
+ var CreateContacts1708525189000 = class {
9015
9267
  static {
9016
- __name(this, "FixCredentialClaimsReferencesUuid1741895822987");
9268
+ __name(this, "CreateContacts1708525189000");
9017
9269
  }
9018
- name = "FixCredentialClaimsReferenceUuid1741895822987";
9270
+ name = "CreateContacts1708525189000";
9019
9271
  async up(queryRunner) {
9020
- debug18("migration: creating issuance branding uuid problem");
9272
+ debug19("migration: updating contact tables");
9021
9273
  const dbType = queryRunner.connection.driver.options.type;
9022
9274
  switch (dbType) {
9023
9275
  case "postgres": {
9024
- debug18("using postgres migration file");
9025
- const mig = new FixCredentialClaimsReferencesUuidPG1741895822987();
9276
+ debug19("using postgres migration file");
9277
+ const mig = new CreateContacts1710438363001();
9026
9278
  await mig.up(queryRunner);
9027
- debug18("Migration statements executed");
9279
+ debug19("Migration statements executed");
9028
9280
  return;
9029
9281
  }
9030
9282
  case "sqlite":
9031
9283
  case "expo":
9032
9284
  case "react-native": {
9033
- debug18("using sqlite/react-native migration file");
9034
- const mig = new FixCredentialClaimsReferencesUuidSqlite1741895822987();
9285
+ debug19("using sqlite/react-native migration file");
9286
+ const mig = new CreateContacts1710438363002();
9035
9287
  await mig.up(queryRunner);
9036
- debug18("Migration statements executed");
9288
+ debug19("Migration statements executed");
9037
9289
  return;
9038
9290
  }
9039
9291
  default:
@@ -9041,23 +9293,23 @@ var FixCredentialClaimsReferencesUuid1741895822987 = class {
9041
9293
  }
9042
9294
  }
9043
9295
  async down(queryRunner) {
9044
- debug18("migration: reverting issuance branding uuid migration");
9296
+ debug19("migration: reverting machine state tables");
9045
9297
  const dbType = queryRunner.connection.driver.options.type;
9046
9298
  switch (dbType) {
9047
9299
  case "postgres": {
9048
- debug18("using postgres migration file");
9049
- const mig = new CreateIssuanceBranding1685628974232();
9300
+ debug19("using postgres migration file");
9301
+ const mig = new CreateContacts1710438363001();
9050
9302
  await mig.down(queryRunner);
9051
- debug18("Migration statements executed");
9303
+ debug19("Migration statements executed");
9052
9304
  return;
9053
9305
  }
9054
9306
  case "sqlite":
9055
9307
  case "expo":
9056
9308
  case "react-native": {
9057
- debug18("using sqlite/react-native migration file");
9058
- const mig = new CreateIssuanceBranding1685628973231();
9309
+ debug19("using sqlite/react-native migration file");
9310
+ const mig = new CreateContacts1710438363002();
9059
9311
  await mig.down(queryRunner);
9060
- debug18("Migration statements executed");
9312
+ debug19("Migration statements executed");
9061
9313
  return;
9062
9314
  }
9063
9315
  default:
@@ -9066,222 +9318,171 @@ var FixCredentialClaimsReferencesUuid1741895822987 = class {
9066
9318
  }
9067
9319
  };
9068
9320
 
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'))`);
9321
+ // src/migrations/generic/9-CreateContacts.ts
9322
+ var import_debug20 = __toESM(require("debug"), 1);
9323
+
9324
+ // src/migrations/postgres/1715761125001-CreateContacts.ts
9325
+ var CreateContacts1715761125001 = class {
9326
+ static {
9327
+ __name(this, "CreateContacts1715761125001");
9328
+ }
9329
+ name = "CreateContacts1715761125001";
9330
+ async up(queryRunner) {
9331
+ await queryRunner.query(`ALTER TABLE "IdentityMetadata" RENAME TO "temporary_IdentityMetadata"`);
9332
+ await queryRunner.query(`CREATE TABLE "IdentityMetadata"
9333
+ (
9334
+ "id" uuid PRIMARY KEY NOT NULL DEFAULT uuid_generate_v4(),
9335
+ "label" character varying(255) NOT NULL,
9336
+ "valueType" character varying NOT NULL,
9337
+ "stringValue" text,
9338
+ "numberValue" double precision,
9339
+ "dateValue" TIMESTAMP,
9340
+ "boolValue" boolean,
9341
+ "identityId" uuid,
9342
+ CONSTRAINT "FK_Identity_IdentityMetadata" FOREIGN KEY ("identityId") REFERENCES "Identity" ("id") ON DELETE CASCADE
9343
+ )`);
9344
+ await queryRunner.query(`INSERT INTO "IdentityMetadata" ("id", "label", "valueType", "stringValue", "identityId")
9345
+ SELECT "id", "label", 'string', "value", "identityId"
9346
+ FROM "temporary_IdentityMetadata"`);
9347
+ await queryRunner.query(`DROP TABLE "temporary_IdentityMetadata"`);
9348
+ await queryRunner.query(`CREATE TABLE "ContactMetadata"
9349
+ (
9350
+ "id" uuid PRIMARY KEY NOT NULL DEFAULT uuid_generate_v4(),
9351
+ "label" character varying(255) NOT NULL,
9352
+ "valueType" character varying NOT NULL,
9353
+ "stringValue" text,
9354
+ "numberValue" double precision,
9355
+ "dateValue" TIMESTAMP,
9356
+ "boolValue" boolean,
9357
+ "contactId" uuid,
9358
+ CONSTRAINT "FK_BaseContact_ContactMetadata" FOREIGN KEY ("contactId") REFERENCES "BaseContact" ("id") ON DELETE CASCADE
9359
+ )`);
9091
9360
  }
9092
9361
  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"`);
9362
+ await queryRunner.query(`DROP TABLE "ContactMetadata"`);
9363
+ await queryRunner.query(`ALTER TABLE "IdentityMetadata" RENAME TO "temporary_IdentityMetadata"`);
9364
+ await queryRunner.query(`CREATE TABLE "IdentityMetadata"
9365
+ (
9366
+ "id" uuid PRIMARY KEY NOT NULL DEFAULT uuid_generate_v4(),
9367
+ "label" character varying(255) NOT NULL,
9368
+ "value" character varying(255) NOT NULL,
9369
+ "identityId" uuid,
9370
+ CONSTRAINT "FK_Identity_IdentityMetadata" FOREIGN KEY ("identityId") REFERENCES "Identity" ("id") ON DELETE CASCADE
9371
+ )`);
9372
+ await queryRunner.query(`INSERT INTO "IdentityMetadata" ("id", "label", "value", "identityId")
9373
+ SELECT "id", "label", "stringValue", "identityId"
9374
+ FROM "temporary_IdentityMetadata"`);
9375
+ await queryRunner.query(`DROP TABLE "temporary_IdentityMetadata"`);
9105
9376
  }
9106
9377
  };
9107
9378
 
9108
- // src/migrations/sqlite/1741895823001-CreateBitstringStatusList.ts
9109
- var CreateBitstringStatusListSqlite1741895823001 = class {
9379
+ // src/migrations/sqlite/1715761125002-CreateContacts.ts
9380
+ var CreateContacts1715761125002 = class {
9110
9381
  static {
9111
- __name(this, "CreateBitstringStatusListSqlite1741895823001");
9382
+ __name(this, "CreateContacts1715761125002");
9112
9383
  }
9113
- name = "CreateBitstringStatusList1741895823000";
9384
+ name = "CreateContacts1715761125002";
9114
9385
  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"`);
9386
+ await queryRunner.query(`ALTER TABLE "IdentityMetadata" RENAME TO "temporary_IdentityMetadata"`);
9387
+ await queryRunner.query(`CREATE TABLE "IdentityMetadata"
9388
+ (
9389
+ "id" varchar PRIMARY KEY NOT NULL,
9390
+ "label" varchar(255) NOT NULL,
9391
+ "valueType" varchar NOT NULL,
9392
+ "stringValue" varchar(255),
9393
+ "numberValue" double,
9394
+ "dateValue" datetime,
9395
+ "boolValue" boolean,
9396
+ "identityId" varchar,
9397
+ FOREIGN KEY ("identityId") REFERENCES "Identity" ("id") ON DELETE CASCADE)`);
9398
+ await queryRunner.query(`INSERT INTO "IdentityMetadata" ("id", "label", "valueType", "stringValue", "identityId")
9399
+ SELECT "id", "label", 'string', "value", "identityId"
9400
+ FROM "temporary_IdentityMetadata"
9401
+ `);
9402
+ await queryRunner.query(`DROP TABLE "temporary_IdentityMetadata"`);
9403
+ await queryRunner.query(`CREATE TABLE "ContactMetadata"
9404
+ (
9405
+ "id" varchar PRIMARY KEY NOT NULL,
9406
+ "label" varchar(255) NOT NULL,
9407
+ "valueType" varchar NOT NULL,
9408
+ "stringValue" text,
9409
+ "numberValue" double,
9410
+ "dateValue" datetime,
9411
+ "boolValue" boolean,
9412
+ "contactId" varchar,
9413
+ FOREIGN KEY ("contactId") REFERENCES "BaseContact" ("id") ON DELETE CASCADE)`);
9178
9414
  }
9179
9415
  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"`);
9416
+ await queryRunner.query(`DROP TABLE "ContactMetadata"`);
9417
+ await queryRunner.query(`ALTER TABLE "IdentityMetadata" RENAME TO "temporary_IdentityMetadata"`);
9418
+ await queryRunner.query(`CREATE TABLE "IdentityMetadata"
9419
+ (
9420
+ "id" varchar PRIMARY KEY NOT NULL,
9421
+ "label" varchar(255) NOT NULL,
9422
+ "value" varchar(255) NOT NULL,
9423
+ "identityId" varchar,
9424
+ FOREIGN KEY ("identityId") REFERENCES "Identity" ("id") ON DELETE CASCADE
9425
+ )`);
9426
+ await queryRunner.query(`INSERT INTO "IdentityMetadata" ("id", "label", "value", "identityId")
9427
+ SELECT "id", "label", "stringValue", "identityId"
9428
+ FROM "temporary_IdentityMetadata"`);
9429
+ await queryRunner.query(`DROP TABLE "temporary_IdentityMetadata"`);
9237
9430
  }
9238
9431
  };
9239
9432
 
9240
- // src/migrations/generic/12-CreateBitstringStatusList.ts
9241
- var debug19 = (0, import_debug19.default)("sphereon:ssi-sdk:migrations");
9242
- var CreateBitstringStatusList1741895823000 = class {
9433
+ // src/migrations/generic/9-CreateContacts.ts
9434
+ var debug20 = (0, import_debug20.default)("sphereon:ssi-sdk:migrations");
9435
+ var CreateContacts1715761125000 = class {
9243
9436
  static {
9244
- __name(this, "CreateBitstringStatusList1741895823000");
9437
+ __name(this, "CreateContacts1715761125000");
9245
9438
  }
9246
- name = "CreateBitstringStatusList1741895823000";
9439
+ name = "CreateContacts1715761125000";
9247
9440
  async up(queryRunner) {
9248
- debug19("migration: creating bitstring status list tables");
9441
+ debug20("migration: updating contact tables");
9249
9442
  const dbType = queryRunner.connection.driver.options.type;
9250
9443
  switch (dbType) {
9251
9444
  case "postgres": {
9252
- const mig = new CreateBitstringStatusListPG1741895823000();
9445
+ debug20("using postgres migration file");
9446
+ const mig = new CreateContacts1715761125001();
9253
9447
  await mig.up(queryRunner);
9448
+ debug20("Migration statements executed");
9254
9449
  return;
9255
9450
  }
9256
9451
  case "sqlite":
9257
9452
  case "expo":
9258
9453
  case "react-native": {
9259
- const mig = new CreateBitstringStatusListSqlite1741895823001();
9454
+ debug20("using sqlite/react-native migration file");
9455
+ const mig = new CreateContacts1715761125002();
9260
9456
  await mig.up(queryRunner);
9457
+ debug20("Migration statements executed");
9261
9458
  return;
9262
9459
  }
9263
9460
  default:
9264
- return Promise.reject(`Migrations only supported for sqlite and postgres. Was ${dbType}`);
9461
+ 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
9462
  }
9266
9463
  }
9267
9464
  async down(queryRunner) {
9268
- debug19("migration: dropping bitstring status list tables");
9465
+ debug20("migration: reverting machine state tables");
9269
9466
  const dbType = queryRunner.connection.driver.options.type;
9270
9467
  switch (dbType) {
9271
9468
  case "postgres": {
9272
- const mig = new CreateBitstringStatusListPG1741895823000();
9469
+ debug20("using postgres migration file");
9470
+ const mig = new CreateContacts1715761125001();
9273
9471
  await mig.down(queryRunner);
9472
+ debug20("Migration statements executed");
9274
9473
  return;
9275
9474
  }
9276
9475
  case "sqlite":
9277
9476
  case "expo":
9278
9477
  case "react-native": {
9279
- const mig = new CreateBitstringStatusListSqlite1741895823001();
9478
+ debug20("using sqlite/react-native migration file");
9479
+ const mig = new CreateContacts1715761125002();
9280
9480
  await mig.down(queryRunner);
9481
+ debug20("Migration statements executed");
9281
9482
  return;
9282
9483
  }
9283
9484
  default:
9284
- return Promise.reject(`Migrations only supported for sqlite and postgres. Was ${dbType}`);
9485
+ 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
9486
  }
9286
9487
  }
9287
9488
  };
@@ -9299,6 +9500,7 @@ var DataStoreIssuanceBrandingMigrations = [
9299
9500
  ];
9300
9501
  var DataStoreStatusListMigrations = [
9301
9502
  CreateStatusList1693866470000,
9503
+ AddBitstringStatusListEnum1741895823000,
9302
9504
  CreateBitstringStatusList1741895823000
9303
9505
  ];
9304
9506
  var DataStoreEventLoggerMigrations = [
@@ -9311,7 +9513,8 @@ var DataStoreMachineStateMigrations = [
9311
9513
  CreateMachineStateStore1708098041262
9312
9514
  ];
9313
9515
  var DataStorePresentationDefinitionMigrations = [
9314
- CreatePresentationDefinitions1716533767523
9516
+ CreatePresentationDefinitions1716533767523,
9517
+ UpdatePresentationDefinitionItemNullable1741895824000
9315
9518
  ];
9316
9519
  var DataStoreMigrations = [
9317
9520
  ...DataStoreContactMigrations,
@@ -9324,7 +9527,7 @@ var DataStoreMigrations = [
9324
9527
  ];
9325
9528
 
9326
9529
  // src/utils/digitalCredential/MappingUtils.ts
9327
- var import_ssi_types7 = require("@sphereon/ssi-types");
9530
+ var import_ssi_types9 = require("@sphereon/ssi-types");
9328
9531
  var import_utils = require("@veramo/utils");
9329
9532
  var import_ssi_sdk23 = require("@sphereon/ssi-sdk.core");
9330
9533
  function determineDocumentType(raw) {
@@ -9332,11 +9535,11 @@ function determineDocumentType(raw) {
9332
9535
  if (!rawDocument) {
9333
9536
  throw new Error(`Couldn't parse the credential: ${raw}`);
9334
9537
  }
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);
9538
+ const hasProof = import_ssi_types9.CredentialMapper.hasProof(rawDocument);
9539
+ const isCredential = isHex(raw) || import_ssi_types9.ObjectUtils.isBase64(raw) || import_ssi_types9.CredentialMapper.isCredential(rawDocument);
9540
+ const isPresentation = import_ssi_types9.CredentialMapper.isPresentation(rawDocument);
9338
9541
  if (isCredential) {
9339
- return hasProof || isHex(raw) || import_ssi_types7.ObjectUtils.isBase64(raw) ? DocumentType.VC : DocumentType.C;
9542
+ return hasProof || isHex(raw) || import_ssi_types9.ObjectUtils.isBase64(raw) ? DocumentType.VC : DocumentType.C;
9340
9543
  } else if (isPresentation) {
9341
9544
  return hasProof ? DocumentType.VP : DocumentType.P;
9342
9545
  }
@@ -9348,9 +9551,9 @@ function isHex(input) {
9348
9551
  }
9349
9552
  __name(isHex, "isHex");
9350
9553
  function parseRawDocument(raw) {
9351
- if (isHex(raw) || import_ssi_types7.ObjectUtils.isBase64(raw)) {
9554
+ if (isHex(raw) || import_ssi_types9.ObjectUtils.isBase64(raw)) {
9352
9555
  return raw;
9353
- } else if (import_ssi_types7.CredentialMapper.isJwtEncoded(raw) || import_ssi_types7.CredentialMapper.isSdJwtEncoded(raw)) {
9556
+ } else if (import_ssi_types9.CredentialMapper.isJwtEncoded(raw) || import_ssi_types9.CredentialMapper.isSdJwtEncoded(raw)) {
9354
9557
  return raw;
9355
9558
  }
9356
9559
  try {
@@ -9362,9 +9565,9 @@ function parseRawDocument(raw) {
9362
9565
  __name(parseRawDocument, "parseRawDocument");
9363
9566
  function ensureRawDocument(input) {
9364
9567
  if (typeof input === "string") {
9365
- if (isHex(input) || import_ssi_types7.ObjectUtils.isBase64(input)) {
9568
+ if (isHex(input) || import_ssi_types9.ObjectUtils.isBase64(input)) {
9366
9569
  return input;
9367
- } else if (import_ssi_types7.CredentialMapper.isJwtEncoded(input) || import_ssi_types7.CredentialMapper.isSdJwtEncoded(input)) {
9570
+ } else if (import_ssi_types9.CredentialMapper.isJwtEncoded(input) || import_ssi_types9.CredentialMapper.isSdJwtEncoded(input)) {
9368
9571
  return input;
9369
9572
  }
9370
9573
  throw Error("Unknown input to be mapped as rawDocument");
@@ -9378,13 +9581,13 @@ function ensureRawDocument(input) {
9378
9581
  __name(ensureRawDocument, "ensureRawDocument");
9379
9582
  function determineCredentialDocumentFormat(documentFormat) {
9380
9583
  switch (documentFormat) {
9381
- case import_ssi_types7.DocumentFormat.JSONLD:
9584
+ case import_ssi_types9.DocumentFormat.JSONLD:
9382
9585
  return CredentialDocumentFormat.JSON_LD;
9383
- case import_ssi_types7.DocumentFormat.JWT:
9586
+ case import_ssi_types9.DocumentFormat.JWT:
9384
9587
  return CredentialDocumentFormat.JWT;
9385
- case import_ssi_types7.DocumentFormat.SD_JWT_VC:
9588
+ case import_ssi_types9.DocumentFormat.SD_JWT_VC:
9386
9589
  return CredentialDocumentFormat.SD_JWT;
9387
- case import_ssi_types7.DocumentFormat.MSO_MDOC:
9590
+ case import_ssi_types9.DocumentFormat.MSO_MDOC:
9388
9591
  return CredentialDocumentFormat.MSO_MDOC;
9389
9592
  default:
9390
9593
  throw new Error(`Not supported document format: ${documentFormat}`);
@@ -9423,14 +9626,14 @@ var safeStringify = /* @__PURE__ */ __name((object) => {
9423
9626
  }, "safeStringify");
9424
9627
  var nonPersistedDigitalCredentialEntityFromAddArgs = /* @__PURE__ */ __name((addCredentialArgs) => {
9425
9628
  const documentType = determineDocumentType(addCredentialArgs.rawDocument);
9426
- const documentFormat = import_ssi_types7.CredentialMapper.detectDocumentType(addCredentialArgs.rawDocument);
9629
+ const documentFormat = import_ssi_types9.CredentialMapper.detectDocumentType(addCredentialArgs.rawDocument);
9427
9630
  const hasher = addCredentialArgs?.opts?.hasher ?? import_ssi_sdk23.defaultHasher;
9428
- if (documentFormat === import_ssi_types7.DocumentFormat.SD_JWT_VC && !addCredentialArgs.opts?.hasher) {
9631
+ if (documentFormat === import_ssi_types9.DocumentFormat.SD_JWT_VC && !addCredentialArgs.opts?.hasher) {
9429
9632
  throw new Error("No hasher function is provided for SD_JWT credential.");
9430
9633
  }
9431
- const uniformDocument = documentType === DocumentType.VC || documentType === DocumentType.C ? import_ssi_types7.CredentialMapper.toUniformCredential(addCredentialArgs.rawDocument, {
9634
+ const uniformDocument = documentType === DocumentType.VC || documentType === DocumentType.C ? import_ssi_types9.CredentialMapper.toUniformCredential(addCredentialArgs.rawDocument, {
9432
9635
  hasher
9433
- }) : import_ssi_types7.CredentialMapper.toUniformPresentation(addCredentialArgs.rawDocument, {
9636
+ }) : import_ssi_types9.CredentialMapper.toUniformPresentation(addCredentialArgs.rawDocument, {
9434
9637
  hasher
9435
9638
  });
9436
9639
  const validFrom = getValidFrom(uniformDocument);