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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (36) hide show
  1. package/dist/index.cjs +1616 -1477
  2. package/dist/index.cjs.map +1 -1
  3. package/dist/index.d.cts +187 -194
  4. package/dist/index.d.ts +187 -194
  5. package/dist/index.js +1582 -1443
  6. package/dist/index.js.map +1 -1
  7. package/package.json +8 -8
  8. package/src/__tests__/contact.entities.test.ts +2 -2
  9. package/src/__tests__/contact.store.test.ts +1 -1
  10. package/src/__tests__/digitalCredential.entities.test.ts +2 -1
  11. package/src/__tests__/digitalCredential.store.test.ts +5 -5
  12. package/src/__tests__/pd-manager.entities.test.ts +27 -98
  13. package/src/__tests__/pd-manager.store.test.ts +151 -101
  14. package/src/digitalCredential/DigitalCredentialStore.ts +9 -9
  15. package/src/entities/contact/IdentityEntity.ts +2 -1
  16. package/src/entities/digitalCredential/DigitalCredentialEntity.ts +2 -1
  17. package/src/entities/presentationDefinition/{PresentationDefinitionItemEntity.ts → DcqlQueryItemEntity.ts} +8 -12
  18. package/src/index.ts +3 -3
  19. package/src/migrations/generic/12-CreateBitstringStatusList.ts +32 -2
  20. package/src/migrations/generic/13-CreateDcqlQueryItem.ts +67 -0
  21. package/src/migrations/generic/index.ts +10 -5
  22. package/src/migrations/postgres/1716475165345-CreatePresentationDefinitions.ts +1 -1
  23. package/src/migrations/postgres/1726588800000-CreateDcqlQueryItem.ts +25 -0
  24. package/src/migrations/postgres/1737110469001-UpdateStatusList.ts +1 -1
  25. package/src/migrations/postgres/1741895823000-CreateBitstringStatusList.ts +15 -2
  26. package/src/migrations/sqlite/1716475165344-CreatePresentationDefinitions.ts +1 -1
  27. package/src/migrations/sqlite/1726617600000-CreateDcqlQueryItem.ts +24 -0
  28. package/src/presentationDefinition/AbstractPDStore.ts +5 -5
  29. package/src/presentationDefinition/PDStore.ts +40 -40
  30. package/src/types/contact/contact.ts +1 -1
  31. package/src/types/digitalCredential/IAbstractDigitalCredentialStore.ts +2 -1
  32. package/src/types/digitalCredential/enums.ts +0 -7
  33. package/src/types/digitalCredential/types.ts +2 -1
  34. package/src/types/presentationDefinition/IAbstractPDStore.ts +5 -5
  35. package/src/types/presentationDefinition/presentationDefinition.ts +8 -9
  36. package/src/utils/presentationDefinition/MappingUtils.ts +31 -22
package/dist/index.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,
@@ -73,6 +72,7 @@ __export(index_exports, {
73
72
  DataStorePresentationDefinitionMigrations: () => DataStorePresentationDefinitionMigrations,
74
73
  DataStoreStatusListEntities: () => DataStoreStatusListEntities,
75
74
  DataStoreStatusListMigrations: () => DataStoreStatusListMigrations,
75
+ DcqlQueryItemEntity: () => DcqlQueryItemEntity,
76
76
  DidAuthConfigEntity: () => DidAuthConfigEntity,
77
77
  DigitalCredentialEntity: () => DigitalCredentialEntity,
78
78
  DigitalCredentialStore: () => DigitalCredentialStore,
@@ -98,7 +98,6 @@ __export(index_exports, {
98
98
  PartyOrigin: () => PartyOrigin,
99
99
  PartyTypeType: () => PartyTypeType,
100
100
  PhysicalAddressEntity: () => PhysicalAddressEntity,
101
- PresentationDefinitionItemEntity: () => PresentationDefinitionItemEntity,
102
101
  RegulationType: () => RegulationType,
103
102
  StatusList2021Entity: () => StatusList2021Entity,
104
103
  StatusListEntity: () => StatusListEntity,
@@ -122,6 +121,8 @@ __export(index_exports, {
122
121
  credentialBrandingFrom: () => credentialBrandingFrom,
123
122
  credentialClaimsEntityFrom: () => credentialClaimsEntityFrom,
124
123
  credentialLocaleBrandingEntityFrom: () => credentialLocaleBrandingEntityFrom,
124
+ dcqlQueryEntityItemFrom: () => dcqlQueryEntityItemFrom,
125
+ dcqlQueryItemFrom: () => dcqlQueryItemFrom,
125
126
  didAuthConfigEntityFrom: () => didAuthConfigEntityFrom,
126
127
  didAuthConfigFrom: () => didAuthConfigFrom,
127
128
  digitalCredentialFrom: () => digitalCredentialFrom,
@@ -161,8 +162,6 @@ __export(index_exports, {
161
162
  partyTypeFrom: () => partyTypeFrom,
162
163
  physicalAddressEntityFrom: () => physicalAddressEntityFrom,
163
164
  physicalAddressFrom: () => physicalAddressFrom,
164
- presentationDefinitionEntityItemFrom: () => presentationDefinitionEntityItemFrom,
165
- presentationDefinitionItemFrom: () => presentationDefinitionItemFrom,
166
165
  textAttributesEntityFrom: () => textAttributesEntityFrom
167
166
  });
168
167
  module.exports = __toCommonJS(index_exports);
@@ -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();
@@ -255,26 +254,19 @@ var CredentialDocumentFormat = /* @__PURE__ */ function(CredentialDocumentFormat
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", {
@@ -4194,7 +4187,7 @@ DigitalCredentialEntity = _ts_decorate33([
4194
4187
  (0, import_typeorm32.Entity)("DigitalCredential")
4195
4188
  ], DigitalCredentialEntity);
4196
4189
 
4197
- // src/entities/presentationDefinition/PresentationDefinitionItemEntity.ts
4190
+ // src/entities/presentationDefinition/DcqlQueryItemEntity.ts
4198
4191
  var import_typeorm33 = require("typeorm");
4199
4192
  var import_class_validator21 = require("class-validator");
4200
4193
  var import_ssi_sdk18 = require("@sphereon/ssi-sdk.agent-config");
@@ -4209,18 +4202,17 @@ function _ts_metadata33(k, v) {
4209
4202
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
4210
4203
  }
4211
4204
  __name(_ts_metadata33, "_ts_metadata");
4212
- var PresentationDefinitionItemEntity = class extends import_typeorm33.BaseEntity {
4205
+ var DcqlQueryItemEntity = class extends import_typeorm33.BaseEntity {
4213
4206
  static {
4214
- __name(this, "PresentationDefinitionItemEntity");
4207
+ __name(this, "DcqlQueryItemEntity");
4215
4208
  }
4216
4209
  id;
4217
- definitionId;
4210
+ queryId;
4218
4211
  version;
4219
4212
  tenantId;
4220
4213
  purpose;
4221
4214
  name;
4222
- definitionPayload;
4223
- dcqlPayload;
4215
+ query;
4224
4216
  createdAt;
4225
4217
  lastUpdatedAt;
4226
4218
  // By default, @UpdateDateColumn in TypeORM updates the timestamp only when the entity's top-level properties change.
@@ -4231,20 +4223,20 @@ var PresentationDefinitionItemEntity = class extends import_typeorm33.BaseEntity
4231
4223
  _ts_decorate34([
4232
4224
  (0, import_typeorm33.PrimaryGeneratedColumn)("uuid"),
4233
4225
  _ts_metadata33("design:type", String)
4234
- ], PresentationDefinitionItemEntity.prototype, "id", void 0);
4226
+ ], DcqlQueryItemEntity.prototype, "id", void 0);
4235
4227
  _ts_decorate34([
4236
4228
  (0, import_typeorm33.Column)({
4237
- name: "definition_id",
4229
+ name: "query_id",
4238
4230
  length: 255,
4239
4231
  type: "varchar",
4240
4232
  nullable: false,
4241
4233
  unique: false
4242
4234
  }),
4243
4235
  (0, import_class_validator21.IsNotEmpty)({
4244
- message: "A blank definition id field is not allowed"
4236
+ message: "A blank query id field is not allowed"
4245
4237
  }),
4246
4238
  _ts_metadata33("design:type", String)
4247
- ], PresentationDefinitionItemEntity.prototype, "definitionId", void 0);
4239
+ ], DcqlQueryItemEntity.prototype, "queryId", void 0);
4248
4240
  _ts_decorate34([
4249
4241
  (0, import_typeorm33.Column)({
4250
4242
  name: "version",
@@ -4257,7 +4249,7 @@ _ts_decorate34([
4257
4249
  message: "A blank version field is not allowed"
4258
4250
  }),
4259
4251
  _ts_metadata33("design:type", String)
4260
- ], PresentationDefinitionItemEntity.prototype, "version", void 0);
4252
+ ], DcqlQueryItemEntity.prototype, "version", void 0);
4261
4253
  _ts_decorate34([
4262
4254
  (0, import_typeorm33.Column)({
4263
4255
  name: "tenant_id",
@@ -4267,7 +4259,7 @@ _ts_decorate34([
4267
4259
  unique: false
4268
4260
  }),
4269
4261
  _ts_metadata33("design:type", String)
4270
- ], PresentationDefinitionItemEntity.prototype, "tenantId", void 0);
4262
+ ], DcqlQueryItemEntity.prototype, "tenantId", void 0);
4271
4263
  _ts_decorate34([
4272
4264
  (0, import_typeorm33.Column)({
4273
4265
  name: "purpose",
@@ -4277,7 +4269,7 @@ _ts_decorate34([
4277
4269
  unique: false
4278
4270
  }),
4279
4271
  _ts_metadata33("design:type", String)
4280
- ], PresentationDefinitionItemEntity.prototype, "purpose", void 0);
4272
+ ], DcqlQueryItemEntity.prototype, "purpose", void 0);
4281
4273
  _ts_decorate34([
4282
4274
  (0, import_typeorm33.Column)({
4283
4275
  name: "name",
@@ -4287,31 +4279,19 @@ _ts_decorate34([
4287
4279
  unique: false
4288
4280
  }),
4289
4281
  _ts_metadata33("design:type", String)
4290
- ], PresentationDefinitionItemEntity.prototype, "name", void 0);
4282
+ ], DcqlQueryItemEntity.prototype, "name", void 0);
4291
4283
  _ts_decorate34([
4292
4284
  (0, import_typeorm33.Column)({
4293
- name: "definition_payload",
4285
+ name: "query",
4294
4286
  type: "text",
4295
4287
  nullable: false,
4296
4288
  unique: false
4297
4289
  }),
4298
4290
  (0, import_class_validator21.IsNotEmpty)({
4299
- message: "A blank PD definition payload field is not allowed"
4300
- }),
4301
- _ts_metadata33("design:type", String)
4302
- ], PresentationDefinitionItemEntity.prototype, "definitionPayload", void 0);
4303
- _ts_decorate34([
4304
- (0, import_typeorm33.Column)({
4305
- name: "dcql_payload",
4306
- type: "text",
4307
- nullable: true,
4308
- unique: false
4309
- }),
4310
- (0, import_class_validator21.IsNotEmpty)({
4311
- message: "A blank dcql definition payload field is not allowed"
4291
+ message: "A blank dcql query payload field is not allowed"
4312
4292
  }),
4313
4293
  _ts_metadata33("design:type", String)
4314
- ], PresentationDefinitionItemEntity.prototype, "dcqlPayload", void 0);
4294
+ ], DcqlQueryItemEntity.prototype, "query", void 0);
4315
4295
  _ts_decorate34([
4316
4296
  (0, import_typeorm33.CreateDateColumn)({
4317
4297
  name: "created_at",
@@ -4319,7 +4299,7 @@ _ts_decorate34([
4319
4299
  type: (0, import_ssi_sdk18.typeOrmDateTime)()
4320
4300
  }),
4321
4301
  _ts_metadata33("design:type", typeof Date === "undefined" ? Object : Date)
4322
- ], PresentationDefinitionItemEntity.prototype, "createdAt", void 0);
4302
+ ], DcqlQueryItemEntity.prototype, "createdAt", void 0);
4323
4303
  _ts_decorate34([
4324
4304
  (0, import_typeorm33.UpdateDateColumn)({
4325
4305
  name: "last_updated_at",
@@ -4327,22 +4307,22 @@ _ts_decorate34([
4327
4307
  type: (0, import_ssi_sdk18.typeOrmDateTime)()
4328
4308
  }),
4329
4309
  _ts_metadata33("design:type", typeof Date === "undefined" ? Object : Date)
4330
- ], PresentationDefinitionItemEntity.prototype, "lastUpdatedAt", void 0);
4310
+ ], DcqlQueryItemEntity.prototype, "lastUpdatedAt", void 0);
4331
4311
  _ts_decorate34([
4332
4312
  (0, import_typeorm33.BeforeInsert)(),
4333
4313
  (0, import_typeorm33.BeforeUpdate)(),
4334
4314
  _ts_metadata33("design:type", Function),
4335
4315
  _ts_metadata33("design:paramtypes", []),
4336
4316
  _ts_metadata33("design:returntype", void 0)
4337
- ], PresentationDefinitionItemEntity.prototype, "updateUpdatedDate", null);
4338
- PresentationDefinitionItemEntity = _ts_decorate34([
4339
- (0, import_typeorm33.Entity)("PresentationDefinitionItem"),
4317
+ ], DcqlQueryItemEntity.prototype, "updateUpdatedDate", null);
4318
+ DcqlQueryItemEntity = _ts_decorate34([
4319
+ (0, import_typeorm33.Entity)("DcqlQueryItem"),
4340
4320
  (0, import_typeorm33.Index)([
4341
4321
  "version"
4342
4322
  ], {
4343
4323
  unique: false
4344
4324
  })
4345
- ], PresentationDefinitionItemEntity);
4325
+ ], DcqlQueryItemEntity);
4346
4326
 
4347
4327
  // src/entities/oid4vcState/Oid4vcStateEntity.ts
4348
4328
  var import_ssi_sdk19 = require("@sphereon/ssi-sdk.agent-config");
@@ -5512,6 +5492,7 @@ var AbstractDigitalCredentialStore = class {
5512
5492
  };
5513
5493
 
5514
5494
  // src/digitalCredential/DigitalCredentialStore.ts
5495
+ var import_ssi_types4 = require("@sphereon/ssi-types");
5515
5496
  var import_debug2 = __toESM(require("debug"), 1);
5516
5497
 
5517
5498
  // src/utils/SortingUtils.ts
@@ -5581,7 +5562,7 @@ var DigitalCredentialStore = class extends AbstractDigitalCredentialStore {
5581
5562
  if (!args) {
5582
5563
  return false;
5583
5564
  }
5584
- let query = {};
5565
+ const query = {};
5585
5566
  if ("id" in args) {
5586
5567
  query.id = args.id;
5587
5568
  } else if ("hash" in args) {
@@ -5667,7 +5648,7 @@ var DigitalCredentialStore = class extends AbstractDigitalCredentialStore {
5667
5648
  }, "updateCredentialState");
5668
5649
  assertValidDigitalCredential(credentialEntity) {
5669
5650
  const { kmsKeyRef, identifierMethod, credentialRole, isIssuerSigned } = credentialEntity;
5670
- const isRoleInvalid = credentialRole === CredentialRole.ISSUER || credentialRole === CredentialRole.HOLDER && !isIssuerSigned;
5651
+ const isRoleInvalid = credentialRole === import_ssi_types4.CredentialRole.ISSUER || credentialRole === import_ssi_types4.CredentialRole.HOLDER && !isIssuerSigned;
5671
5652
  if (isRoleInvalid && (!kmsKeyRef || !identifierMethod)) {
5672
5653
  const missingFields = [];
5673
5654
  if (!kmsKeyRef) missingFields.push("kmsKeyRef");
@@ -6181,41 +6162,41 @@ var IssuanceBrandingStore = class extends AbstractIssuanceBrandingStore {
6181
6162
  };
6182
6163
 
6183
6164
  // src/statusList/StatusListStore.ts
6184
- var import_ssi_types4 = require("@sphereon/ssi-types");
6165
+ var import_ssi_types6 = require("@sphereon/ssi-types");
6185
6166
  var import_debug4 = __toESM(require("debug"), 1);
6186
6167
  var import_typeorm37 = require("typeorm");
6187
6168
 
6188
6169
  // src/utils/statusList/MappingUtils.ts
6189
- var import_ssi_types3 = require("@sphereon/ssi-types");
6170
+ var import_ssi_types5 = require("@sphereon/ssi-types");
6190
6171
  var statusListEntityFrom = /* @__PURE__ */ __name((args) => {
6191
6172
  switch (args.type) {
6192
- case import_ssi_types3.StatusListType.StatusList2021: {
6173
+ case import_ssi_types5.StatusListType.StatusList2021: {
6193
6174
  const entity = new StatusList2021Entity();
6194
6175
  const sl2021 = args;
6195
6176
  entity.indexingDirection = sl2021.indexingDirection;
6196
6177
  entity.statusPurpose = sl2021.statusPurpose;
6197
6178
  setBaseFields(entity, args);
6198
6179
  Object.defineProperty(entity, "type", {
6199
- value: import_ssi_types3.StatusListType.StatusList2021,
6180
+ value: import_ssi_types5.StatusListType.StatusList2021,
6200
6181
  enumerable: true,
6201
6182
  configurable: true
6202
6183
  });
6203
6184
  return entity;
6204
6185
  }
6205
- case import_ssi_types3.StatusListType.OAuthStatusList: {
6186
+ case import_ssi_types5.StatusListType.OAuthStatusList: {
6206
6187
  const entity = new OAuthStatusListEntity();
6207
6188
  const oauthSl = args;
6208
6189
  entity.bitsPerStatus = oauthSl.bitsPerStatus;
6209
6190
  entity.expiresAt = oauthSl.expiresAt;
6210
6191
  setBaseFields(entity, args);
6211
6192
  Object.defineProperty(entity, "type", {
6212
- value: import_ssi_types3.StatusListType.OAuthStatusList,
6193
+ value: import_ssi_types5.StatusListType.OAuthStatusList,
6213
6194
  enumerable: true,
6214
6195
  configurable: true
6215
6196
  });
6216
6197
  return entity;
6217
6198
  }
6218
- case import_ssi_types3.StatusListType.BitstringStatusList: {
6199
+ case import_ssi_types5.StatusListType.BitstringStatusList: {
6219
6200
  const entity = new BitstringStatusListEntity();
6220
6201
  const bitstringsl = args;
6221
6202
  if (!bitstringsl.bitsPerStatus) {
@@ -6228,7 +6209,7 @@ var statusListEntityFrom = /* @__PURE__ */ __name((args) => {
6228
6209
  entity.ttl = bitstringsl.ttl;
6229
6210
  setBaseFields(entity, args);
6230
6211
  Object.defineProperty(entity, "type", {
6231
- value: import_ssi_types3.StatusListType.BitstringStatusList,
6212
+ value: import_ssi_types5.StatusListType.BitstringStatusList,
6232
6213
  enumerable: true,
6233
6214
  configurable: true
6234
6215
  });
@@ -6242,7 +6223,7 @@ var statusListFrom = /* @__PURE__ */ __name((entity) => {
6242
6223
  if (entity instanceof StatusList2021Entity) {
6243
6224
  const result = {
6244
6225
  ...getBaseFields(entity),
6245
- type: import_ssi_types3.StatusListType.StatusList2021,
6226
+ type: import_ssi_types5.StatusListType.StatusList2021,
6246
6227
  indexingDirection: entity.indexingDirection,
6247
6228
  statusPurpose: entity.statusPurpose
6248
6229
  };
@@ -6251,7 +6232,7 @@ var statusListFrom = /* @__PURE__ */ __name((entity) => {
6251
6232
  if (entity instanceof OAuthStatusListEntity) {
6252
6233
  const result = {
6253
6234
  ...getBaseFields(entity),
6254
- type: import_ssi_types3.StatusListType.OAuthStatusList,
6235
+ type: import_ssi_types5.StatusListType.OAuthStatusList,
6255
6236
  bitsPerStatus: entity.bitsPerStatus,
6256
6237
  expiresAt: entity.expiresAt
6257
6238
  };
@@ -6260,7 +6241,7 @@ var statusListFrom = /* @__PURE__ */ __name((entity) => {
6260
6241
  if (entity instanceof BitstringStatusListEntity) {
6261
6242
  const result = {
6262
6243
  ...getBaseFields(entity),
6263
- type: import_ssi_types3.StatusListType.BitstringStatusList,
6244
+ type: import_ssi_types5.StatusListType.BitstringStatusList,
6264
6245
  statusPurpose: entity.statusPurpose,
6265
6246
  bitsPerStatus: entity.bitsPerStatus,
6266
6247
  validFrom: entity.validFrom,
@@ -6581,11 +6562,11 @@ var StatusListStore = class {
6581
6562
  async getStatusListRepo(type) {
6582
6563
  const dataSource = await this.getDS();
6583
6564
  switch (type) {
6584
- case import_ssi_types4.StatusListType.StatusList2021:
6565
+ case import_ssi_types6.StatusListType.StatusList2021:
6585
6566
  return dataSource.getRepository(StatusList2021Entity);
6586
- case import_ssi_types4.StatusListType.OAuthStatusList:
6567
+ case import_ssi_types6.StatusListType.OAuthStatusList:
6587
6568
  return dataSource.getRepository(OAuthStatusListEntity);
6588
- case import_ssi_types4.StatusListType.BitstringStatusList:
6569
+ case import_ssi_types6.StatusListType.BitstringStatusList:
6589
6570
  return dataSource.getRepository(BitstringStatusListEntity);
6590
6571
  default:
6591
6572
  return dataSource.getRepository(StatusListEntity);
@@ -6594,7 +6575,7 @@ var StatusListStore = class {
6594
6575
  async getStatusListEntryRepo(type) {
6595
6576
  const dataSource = await this.getDS();
6596
6577
  switch (type) {
6597
- case import_ssi_types4.StatusListType.BitstringStatusList:
6578
+ case import_ssi_types6.StatusListType.BitstringStatusList:
6598
6579
  return dataSource.getRepository(BitstringStatusListEntryEntity);
6599
6580
  default:
6600
6581
  return dataSource.getRepository(StatusListEntryEntity);
@@ -6610,15 +6591,15 @@ var AbstractEventLoggerStore = class {
6610
6591
  };
6611
6592
 
6612
6593
  // src/eventLogger/EventLoggerStore.ts
6613
- var import_ssi_types6 = require("@sphereon/ssi-types");
6594
+ var import_ssi_types8 = require("@sphereon/ssi-types");
6614
6595
  var import_debug5 = __toESM(require("debug"), 1);
6615
6596
 
6616
6597
  // src/utils/eventLogger/MappingUtils.ts
6617
- var import_ssi_types5 = require("@sphereon/ssi-types");
6598
+ var import_ssi_types7 = require("@sphereon/ssi-types");
6618
6599
  var auditEventFrom = /* @__PURE__ */ __name((event) => {
6619
6600
  const result = {
6620
6601
  id: event.id,
6621
- type: import_ssi_types5.LoggingEventType.AUDIT,
6602
+ type: import_ssi_types7.LoggingEventType.AUDIT,
6622
6603
  description: event.description,
6623
6604
  timestamp: event.timestamp,
6624
6605
  level: event.level,
@@ -6645,7 +6626,7 @@ var auditEventFrom = /* @__PURE__ */ __name((event) => {
6645
6626
  }, "auditEventFrom");
6646
6627
  var auditEventEntityFrom = /* @__PURE__ */ __name((args) => {
6647
6628
  const auditEventEntity = new AuditEventEntity();
6648
- auditEventEntity.type = import_ssi_types5.LoggingEventType.AUDIT;
6629
+ auditEventEntity.type = import_ssi_types7.LoggingEventType.AUDIT;
6649
6630
  auditEventEntity.timestamp = args.timestamp;
6650
6631
  auditEventEntity.level = args.level;
6651
6632
  auditEventEntity.correlationId = args.correlationId;
@@ -6669,7 +6650,7 @@ var auditEventEntityFrom = /* @__PURE__ */ __name((args) => {
6669
6650
  var activityEventFrom = /* @__PURE__ */ __name((event) => {
6670
6651
  const result = {
6671
6652
  id: event.id,
6672
- type: import_ssi_types5.LoggingEventType.ACTIVITY,
6653
+ type: import_ssi_types7.LoggingEventType.ACTIVITY,
6673
6654
  credentialType: event.credentialType,
6674
6655
  originalCredential: event.originalCredential,
6675
6656
  credentialHash: event.credentialHash,
@@ -6701,7 +6682,7 @@ var activityEventFrom = /* @__PURE__ */ __name((event) => {
6701
6682
  }, "activityEventFrom");
6702
6683
  var activityEventEntityFrom = /* @__PURE__ */ __name((args) => {
6703
6684
  const activityEventEntity = new AuditEventEntity();
6704
- activityEventEntity.type = import_ssi_types5.LoggingEventType.ACTIVITY;
6685
+ activityEventEntity.type = import_ssi_types7.LoggingEventType.ACTIVITY;
6705
6686
  activityEventEntity.timestamp = args.timestamp;
6706
6687
  activityEventEntity.level = args.level;
6707
6688
  activityEventEntity.correlationId = args.correlationId;
@@ -6743,11 +6724,11 @@ var EventLoggerStore = class extends AbstractEventLoggerStore {
6743
6724
  const { filter = [] } = args ?? {};
6744
6725
  const auditEventsFilter = filter.map((item) => ({
6745
6726
  ...item,
6746
- type: import_ssi_types6.LoggingEventType.AUDIT
6727
+ type: import_ssi_types8.LoggingEventType.AUDIT
6747
6728
  }));
6748
6729
  if (auditEventsFilter.length === 0) {
6749
6730
  auditEventsFilter.push({
6750
- type: import_ssi_types6.LoggingEventType.AUDIT
6731
+ type: import_ssi_types8.LoggingEventType.AUDIT
6751
6732
  });
6752
6733
  }
6753
6734
  const connection = await this.dbConnection;
@@ -6769,11 +6750,11 @@ var EventLoggerStore = class extends AbstractEventLoggerStore {
6769
6750
  const { filter = [] } = args ?? {};
6770
6751
  const activityEventsFilter = filter.map((item) => ({
6771
6752
  ...item,
6772
- type: import_ssi_types6.LoggingEventType.ACTIVITY
6753
+ type: import_ssi_types8.LoggingEventType.ACTIVITY
6773
6754
  }));
6774
6755
  if (activityEventsFilter.length === 0) {
6775
6756
  activityEventsFilter.push({
6776
- type: import_ssi_types6.LoggingEventType.ACTIVITY
6757
+ type: import_ssi_types8.LoggingEventType.ACTIVITY
6777
6758
  });
6778
6759
  }
6779
6760
  const connection = await this.dbConnection;
@@ -6944,44 +6925,54 @@ var import_debug7 = __toESM(require("debug"), 1);
6944
6925
 
6945
6926
  // src/utils/presentationDefinition/MappingUtils.ts
6946
6927
  var blakepkg = __toESM(require("blakejs"), 1);
6947
- var presentationDefinitionItemFrom = /* @__PURE__ */ __name((entity) => {
6928
+ var import_dcql = require("dcql");
6929
+ var dcqlQueryItemFrom = /* @__PURE__ */ __name((entity) => {
6948
6930
  const result = {
6949
6931
  id: entity.id,
6950
6932
  tenantId: entity.tenantId,
6951
- definitionId: entity.definitionId,
6933
+ queryId: entity.queryId,
6952
6934
  version: entity.version,
6953
6935
  name: entity.name,
6954
6936
  purpose: entity.purpose,
6955
- definitionPayload: JSON.parse(entity.definitionPayload),
6956
- dcqlPayload: JSON.parse(entity.dcqlPayload),
6937
+ query: import_dcql.DcqlQuery.parse(JSON.parse(entity.query)),
6957
6938
  createdAt: entity.createdAt,
6958
6939
  lastUpdatedAt: entity.lastUpdatedAt
6959
6940
  };
6941
+ if (result.query) {
6942
+ import_dcql.DcqlQuery.validate(result.query);
6943
+ }
6960
6944
  return replaceNullWithUndefined(result);
6961
- }, "presentationDefinitionItemFrom");
6962
- var presentationDefinitionEntityItemFrom = /* @__PURE__ */ __name((item) => {
6963
- const entity = new PresentationDefinitionItemEntity();
6945
+ }, "dcqlQueryItemFrom");
6946
+ var dcqlQueryEntityItemFrom = /* @__PURE__ */ __name((item) => {
6947
+ const entity = new DcqlQueryItemEntity();
6964
6948
  entity.tenantId = item.tenantId;
6965
- entity.definitionId = item.definitionId;
6949
+ entity.queryId = item.queryId;
6966
6950
  entity.version = item.version;
6967
6951
  entity.name = item.name;
6968
6952
  entity.purpose = item.purpose;
6969
- entity.definitionPayload = JSON.stringify(item.definitionPayload);
6970
- entity.dcqlPayload = JSON.stringify(item.dcqlPayload);
6953
+ if (item.query) {
6954
+ const dcqlQuery = import_dcql.DcqlQuery.parse(item.query);
6955
+ import_dcql.DcqlQuery.validate(dcqlQuery);
6956
+ entity.query = JSON.stringify(item.query);
6957
+ }
6971
6958
  return entity;
6972
- }, "presentationDefinitionEntityItemFrom");
6959
+ }, "dcqlQueryEntityItemFrom");
6973
6960
  function hashPayload(payload) {
6974
6961
  return blakepkg.blake2bHex(JSON.stringify(payload));
6975
6962
  }
6976
6963
  __name(hashPayload, "hashPayload");
6977
6964
  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) {
6965
+ if (base.queryId !== compare.queryId || base.tenantId !== compare.tenantId || base.version !== compare.version || base.name !== compare.name || base.purpose !== compare.purpose) {
6979
6966
  return false;
6980
6967
  }
6981
- if (base.definitionPayload && compare.definitionPayload) {
6982
- return hashPayload(base.definitionPayload) === hashPayload(compare.definitionPayload);
6968
+ if (base.query && compare.query) {
6969
+ if (hashPayload(base.query) !== hashPayload(compare.query)) {
6970
+ return false;
6971
+ }
6972
+ } else if (base.query || compare.query) {
6973
+ return false;
6983
6974
  }
6984
- return false;
6975
+ return true;
6985
6976
  }
6986
6977
  __name(isPresentationDefinitionEqual, "isPresentationDefinitionEqual");
6987
6978
 
@@ -6998,7 +6989,7 @@ var PDStore = class extends AbstractPDStore {
6998
6989
  }
6999
6990
  getDefinition = /* @__PURE__ */ __name(async (args) => {
7000
6991
  const { itemId } = args ?? {};
7001
- const pdRepository = (await this.dbConnection).getRepository(PresentationDefinitionItemEntity);
6992
+ const pdRepository = (await this.dbConnection).getRepository(DcqlQueryItemEntity);
7002
6993
  const result = await pdRepository.findOne({
7003
6994
  where: {
7004
6995
  id: itemId
@@ -7007,11 +6998,11 @@ var PDStore = class extends AbstractPDStore {
7007
6998
  if (!result) {
7008
6999
  return Promise.reject(Error(`No presentation definition item found for id: ${itemId}`));
7009
7000
  }
7010
- return presentationDefinitionItemFrom(result);
7001
+ return dcqlQueryItemFrom(result);
7011
7002
  }, "getDefinition");
7012
7003
  hasDefinition = /* @__PURE__ */ __name(async (args) => {
7013
7004
  const { itemId } = args ?? {};
7014
- const pdRepository = (await this.dbConnection).getRepository(PresentationDefinitionItemEntity);
7005
+ const pdRepository = (await this.dbConnection).getRepository(DcqlQueryItemEntity);
7015
7006
  const resultCount = await pdRepository.count({
7016
7007
  where: {
7017
7008
  id: itemId
@@ -7021,7 +7012,7 @@ var PDStore = class extends AbstractPDStore {
7021
7012
  }, "hasDefinition");
7022
7013
  hasDefinitions = /* @__PURE__ */ __name(async (args) => {
7023
7014
  const { filter } = args;
7024
- const pdRepository = (await this.dbConnection).getRepository(PresentationDefinitionItemEntity);
7015
+ const pdRepository = (await this.dbConnection).getRepository(DcqlQueryItemEntity);
7025
7016
  const resultCount = await pdRepository.count({
7026
7017
  ...filter && {
7027
7018
  where: cleanFilter(filter)
@@ -7031,7 +7022,7 @@ var PDStore = class extends AbstractPDStore {
7031
7022
  }, "hasDefinitions");
7032
7023
  getDefinitions = /* @__PURE__ */ __name(async (args) => {
7033
7024
  const { filter } = args;
7034
- const pdRepository = (await this.dbConnection).getRepository(PresentationDefinitionItemEntity);
7025
+ const pdRepository = (await this.dbConnection).getRepository(DcqlQueryItemEntity);
7035
7026
  const initialResult = await this.findIds(pdRepository, filter);
7036
7027
  const result = await pdRepository.find({
7037
7028
  where: {
@@ -7041,19 +7032,19 @@ var PDStore = class extends AbstractPDStore {
7041
7032
  version: "DESC"
7042
7033
  }
7043
7034
  });
7044
- return result.map((entity) => presentationDefinitionItemFrom(entity));
7035
+ return result.map((entity) => dcqlQueryItemFrom(entity));
7045
7036
  }, "getDefinitions");
7046
7037
  addDefinition = /* @__PURE__ */ __name(async (item) => {
7047
- const pdRepository = (await this.dbConnection).getRepository(PresentationDefinitionItemEntity);
7048
- const entity = presentationDefinitionEntityItemFrom(item);
7038
+ const pdRepository = (await this.dbConnection).getRepository(DcqlQueryItemEntity);
7039
+ const entity = dcqlQueryEntityItemFrom(item);
7049
7040
  debug7("Adding presentation definition entity", item);
7050
7041
  const result = await pdRepository.save(entity, {
7051
7042
  transaction: true
7052
7043
  });
7053
- return presentationDefinitionItemFrom(result);
7044
+ return dcqlQueryItemFrom(result);
7054
7045
  }, "addDefinition");
7055
7046
  updateDefinition = /* @__PURE__ */ __name(async (item) => {
7056
- const pdRepository = (await this.dbConnection).getRepository(PresentationDefinitionItemEntity);
7047
+ const pdRepository = (await this.dbConnection).getRepository(DcqlQueryItemEntity);
7057
7048
  const result = await pdRepository.findOne({
7058
7049
  where: {
7059
7050
  id: item.id
@@ -7066,20 +7057,20 @@ var PDStore = class extends AbstractPDStore {
7066
7057
  ...result
7067
7058
  };
7068
7059
  updatedEntity.tenantId = item.tenantId;
7069
- updatedEntity.definitionId = item.definitionId;
7060
+ updatedEntity.queryId = item.queryId;
7070
7061
  updatedEntity.version = item.version;
7071
7062
  updatedEntity.name = item.name;
7072
7063
  updatedEntity.purpose = item.purpose;
7073
- updatedEntity.definitionPayload = JSON.stringify(item.definitionPayload);
7064
+ updatedEntity.query = JSON.stringify(item.query);
7074
7065
  debug7("Updating presentation definition entity", updatedEntity);
7075
7066
  const updateResult = await pdRepository.save(updatedEntity, {
7076
7067
  transaction: true
7077
7068
  });
7078
- return presentationDefinitionItemFrom(updateResult);
7069
+ return dcqlQueryItemFrom(updateResult);
7079
7070
  }, "updateDefinition");
7080
7071
  deleteDefinition = /* @__PURE__ */ __name(async (args) => {
7081
7072
  const { itemId } = args;
7082
- const pdRepository = (await this.dbConnection).getRepository(PresentationDefinitionItemEntity);
7073
+ const pdRepository = (await this.dbConnection).getRepository(DcqlQueryItemEntity);
7083
7074
  const entity = await pdRepository.findOne({
7084
7075
  where: {
7085
7076
  id: itemId
@@ -7093,7 +7084,7 @@ var PDStore = class extends AbstractPDStore {
7093
7084
  }, "deleteDefinition");
7094
7085
  deleteDefinitions = /* @__PURE__ */ __name(async (args) => {
7095
7086
  const { filter } = args;
7096
- const pdRepository = (await this.dbConnection).getRepository(PresentationDefinitionItemEntity);
7087
+ const pdRepository = (await this.dbConnection).getRepository(DcqlQueryItemEntity);
7097
7088
  const initialResult = await this.findIds(pdRepository, filter);
7098
7089
  const result = await pdRepository.find({
7099
7090
  where: {
@@ -7306,9 +7297,120 @@ var CreateContacts1659463079429 = class {
7306
7297
  }
7307
7298
  };
7308
7299
 
7309
- // src/migrations/generic/2-CreateIssuanceBranding.ts
7300
+ // src/migrations/generic/10-CreatePresentationDefinitions.ts
7310
7301
  var import_debug9 = __toESM(require("debug"), 1);
7311
7302
 
7303
+ // src/migrations/postgres/1716475165345-CreatePresentationDefinitions.ts
7304
+ var CreatePresentationDefinitions1716475165345 = class {
7305
+ static {
7306
+ __name(this, "CreatePresentationDefinitions1716475165345");
7307
+ }
7308
+ name = "CreatePresentationDefinitions1716475165345";
7309
+ async up(queryRunner) {
7310
+ await queryRunner.query(`
7311
+ CREATE TABLE "PresentationDefinitionItem" (
7312
+ "id" uuid NOT NULL DEFAULT uuid_generate_v4(),
7313
+ "tenant_id" TEXT,
7314
+ "definition_id" TEXT NOT NULL,
7315
+ "name" TEXT,
7316
+ "version" TEXT NOT NULL,
7317
+ "purpose" TEXT,
7318
+ "definition_payload" TEXT NOT NULL,
7319
+ "query" TEXT,
7320
+ "created_at" TIMESTAMP NOT NULL DEFAULT now(),
7321
+ "last_updated_at" TIMESTAMP NOT NULL DEFAULT now(),
7322
+ CONSTRAINT "PK_PresentationDefinitionItem_id" PRIMARY KEY ("id"))
7323
+ `);
7324
+ }
7325
+ async down(queryRunner) {
7326
+ await queryRunner.query(`DROP TABLE "PresentationDefinitionItem"`);
7327
+ }
7328
+ };
7329
+
7330
+ // src/migrations/sqlite/1716475165344-CreatePresentationDefinitions.ts
7331
+ var CreatePresentationDefinitions1716475165344 = class {
7332
+ static {
7333
+ __name(this, "CreatePresentationDefinitions1716475165344");
7334
+ }
7335
+ name = "CreatePresentationDefinitions1716475165344";
7336
+ async up(queryRunner) {
7337
+ await queryRunner.query(`CREATE TABLE "PresentationDefinitionItem" (
7338
+ "id" varchar PRIMARY KEY NOT NULL,
7339
+ "tenant_id" varchar,
7340
+ "definition_id" varchar NOT NULL,
7341
+ "name" varchar,
7342
+ "version" varchar NOT NULL,
7343
+ "purpose" varchar,
7344
+ "definition_payload" varchar NOT NULL,
7345
+ "query" varchar,
7346
+ "created_at" datetime NOT NULL DEFAULT (datetime('now')),
7347
+ "last_updated_at" datetime NOT NULL DEFAULT (datetime('now')))`);
7348
+ }
7349
+ async down(queryRunner) {
7350
+ await queryRunner.query(`DROP TABLE "PresentationDefinitionItem"`);
7351
+ }
7352
+ };
7353
+
7354
+ // src/migrations/generic/10-CreatePresentationDefinitions.ts
7355
+ var debug9 = (0, import_debug9.default)("sphereon:ssi-sdk:migrations");
7356
+ var CreatePresentationDefinitions1716533767523 = class {
7357
+ static {
7358
+ __name(this, "CreatePresentationDefinitions1716533767523");
7359
+ }
7360
+ name = "CreatePresentationDefinitionItems1716533767523";
7361
+ async up(queryRunner) {
7362
+ debug9("migration: creating machine state tables");
7363
+ const dbType = queryRunner.connection.driver.options.type;
7364
+ switch (dbType) {
7365
+ case "postgres": {
7366
+ debug9("using postgres migration file");
7367
+ const mig = new CreatePresentationDefinitions1716475165345();
7368
+ await mig.up(queryRunner);
7369
+ debug9("Migration statements executed");
7370
+ return;
7371
+ }
7372
+ case "sqlite":
7373
+ case "expo":
7374
+ case "react-native": {
7375
+ debug9("using sqlite/react-native migration file");
7376
+ const mig = new CreatePresentationDefinitions1716475165344();
7377
+ await mig.up(queryRunner);
7378
+ debug9("Migration statements executed");
7379
+ return;
7380
+ }
7381
+ default:
7382
+ 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`);
7383
+ }
7384
+ }
7385
+ async down(queryRunner) {
7386
+ debug9("migration: reverting machine state tables");
7387
+ const dbType = queryRunner.connection.driver.options.type;
7388
+ switch (dbType) {
7389
+ case "postgres": {
7390
+ debug9("using postgres migration file");
7391
+ const mig = new CreatePresentationDefinitions1716475165345();
7392
+ await mig.down(queryRunner);
7393
+ debug9("Migration statements executed");
7394
+ return;
7395
+ }
7396
+ case "sqlite":
7397
+ case "expo":
7398
+ case "react-native": {
7399
+ debug9("using sqlite/react-native migration file");
7400
+ const mig = new CreatePresentationDefinitions1716475165344();
7401
+ await mig.down(queryRunner);
7402
+ debug9("Migration statements executed");
7403
+ return;
7404
+ }
7405
+ default:
7406
+ 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`);
7407
+ }
7408
+ }
7409
+ };
7410
+
7411
+ // src/migrations/generic/11-FixCredentialClaimsReferenceUuid.ts
7412
+ var import_debug10 = __toESM(require("debug"), 1);
7413
+
7312
7414
  // src/migrations/postgres/1685628974232-CreateIssuanceBranding.ts
7313
7415
  var import_ssi_sdk21 = require("@sphereon/ssi-sdk.core");
7314
7416
  var CreateIssuanceBranding1685628974232 = class {
@@ -7445,31 +7547,105 @@ var CreateIssuanceBranding1685628973231 = class {
7445
7547
  }
7446
7548
  };
7447
7549
 
7448
- // src/migrations/generic/2-CreateIssuanceBranding.ts
7449
- var debug9 = (0, import_debug9.default)("sphereon:ssi-sdk:migrations");
7450
- var CreateIssuanceBranding1659463079429 = class {
7550
+ // src/migrations/postgres/1741895822987-FixCredentialClaimsReferencesUuid.ts
7551
+ var FixCredentialClaimsReferencesUuidPG1741895822987 = class {
7451
7552
  static {
7452
- __name(this, "CreateIssuanceBranding1659463079429");
7553
+ __name(this, "FixCredentialClaimsReferencesUuidPG1741895822987");
7453
7554
  }
7454
- name = "CreateIssuanceBranding1659463079429";
7555
+ name = "FixCredentialClaimsReferencesUuid1741895822987";
7556
+ async up(queryRunner) {
7557
+ await queryRunner.query(`
7558
+ ALTER TABLE "CredentialClaims"
7559
+ ALTER COLUMN "credentialLocaleBrandingId" TYPE uuid USING "credentialLocaleBrandingId"::uuid;
7560
+ `);
7561
+ }
7562
+ async down(queryRunner) {
7563
+ await queryRunner.query(`
7564
+ ALTER TABLE "CredentialClaims"
7565
+ ALTER COLUMN "credentialLocaleBrandingId" TYPE character varying USING "credentialLocaleBrandingId"::text;
7566
+ `);
7567
+ }
7568
+ };
7569
+
7570
+ // src/migrations/sqlite/1741895822987-FixCredentialClaimsReferencesUuid.ts
7571
+ var FixCredentialClaimsReferencesUuidSqlite1741895822987 = class {
7572
+ static {
7573
+ __name(this, "FixCredentialClaimsReferencesUuidSqlite1741895822987");
7574
+ }
7575
+ name = "FixCredentialClaimsReferencesUuid1741895822987";
7576
+ async up(queryRunner) {
7577
+ await queryRunner.query(`
7578
+ CREATE TABLE "CredentialClaims_new"
7579
+ (
7580
+ "id" uuid NOT NULL DEFAULT (lower(hex(randomblob(16)))),
7581
+ "key" character varying(255) NOT NULL,
7582
+ "name" character varying(255) NOT NULL,
7583
+ "credentialLocaleBrandingId" uuid,
7584
+ CONSTRAINT "PK_CredentialClaims_id" PRIMARY KEY ("id")
7585
+ )
7586
+ `);
7587
+ await queryRunner.query(`
7588
+ INSERT INTO "CredentialClaims_new" ("id", "key", "name", "credentialLocaleBrandingId")
7589
+ SELECT "id", "key", "name", "credentialLocaleBrandingId"
7590
+ FROM "CredentialClaims"
7591
+ `);
7592
+ await queryRunner.query(`DROP TABLE "CredentialClaims"`);
7593
+ await queryRunner.query(`ALTER TABLE "CredentialClaims_new" RENAME TO "CredentialClaims"`);
7594
+ await queryRunner.query(`
7595
+ CREATE UNIQUE INDEX "IDX_CredentialClaimsEntity_credentialLocaleBranding_locale"
7596
+ ON "CredentialClaims" ("credentialLocaleBrandingId", "key")
7597
+ `);
7598
+ }
7599
+ async down(queryRunner) {
7600
+ await queryRunner.query(`
7601
+ CREATE TABLE "CredentialClaims_old"
7602
+ (
7603
+ "id" uuid NOT NULL DEFAULT (lower(hex(randomblob(16)))),
7604
+ "key" character varying(255) NOT NULL,
7605
+ "name" character varying(255) NOT NULL,
7606
+ "credentialLocaleBrandingId" character varying,
7607
+ CONSTRAINT "PK_CredentialClaims_id" PRIMARY KEY ("id")
7608
+ )
7609
+ `);
7610
+ await queryRunner.query(`
7611
+ INSERT INTO "CredentialClaims_old" ("id", "key", "name", "credentialLocaleBrandingId")
7612
+ SELECT "id", "key", "name", "credentialLocaleBrandingId"
7613
+ FROM "CredentialClaims"
7614
+ `);
7615
+ await queryRunner.query(`DROP TABLE "CredentialClaims"`);
7616
+ await queryRunner.query(`ALTER TABLE "CredentialClaims_old" RENAME TO "CredentialClaims"`);
7617
+ await queryRunner.query(`
7618
+ CREATE UNIQUE INDEX "IDX_CredentialClaimsEntity_credentialLocaleBranding_locale"
7619
+ ON "CredentialClaims" ("credentialLocaleBrandingId", "key")
7620
+ `);
7621
+ }
7622
+ };
7623
+
7624
+ // src/migrations/generic/11-FixCredentialClaimsReferenceUuid.ts
7625
+ var debug10 = (0, import_debug10.default)("sphereon:ssi-sdk:migrations");
7626
+ var FixCredentialClaimsReferencesUuid1741895822987 = class {
7627
+ static {
7628
+ __name(this, "FixCredentialClaimsReferencesUuid1741895822987");
7629
+ }
7630
+ name = "FixCredentialClaimsReferenceUuid1741895822987";
7455
7631
  async up(queryRunner) {
7456
- debug9("migration: creating issuance branding tables");
7632
+ debug10("migration: creating issuance branding uuid problem");
7457
7633
  const dbType = queryRunner.connection.driver.options.type;
7458
7634
  switch (dbType) {
7459
7635
  case "postgres": {
7460
- debug9("using postgres migration file");
7461
- const mig = new CreateIssuanceBranding1685628974232();
7636
+ debug10("using postgres migration file");
7637
+ const mig = new FixCredentialClaimsReferencesUuidPG1741895822987();
7462
7638
  await mig.up(queryRunner);
7463
- debug9("Migration statements executed");
7639
+ debug10("Migration statements executed");
7464
7640
  return;
7465
7641
  }
7466
7642
  case "sqlite":
7467
7643
  case "expo":
7468
7644
  case "react-native": {
7469
- debug9("using sqlite/react-native migration file");
7470
- const mig = new CreateIssuanceBranding1685628973231();
7645
+ debug10("using sqlite/react-native migration file");
7646
+ const mig = new FixCredentialClaimsReferencesUuidSqlite1741895822987();
7471
7647
  await mig.up(queryRunner);
7472
- debug9("Migration statements executed");
7648
+ debug10("Migration statements executed");
7473
7649
  return;
7474
7650
  }
7475
7651
  default:
@@ -7477,23 +7653,23 @@ var CreateIssuanceBranding1659463079429 = class {
7477
7653
  }
7478
7654
  }
7479
7655
  async down(queryRunner) {
7480
- debug9("migration: reverting issuance branding tables");
7656
+ debug10("migration: reverting issuance branding uuid migration");
7481
7657
  const dbType = queryRunner.connection.driver.options.type;
7482
7658
  switch (dbType) {
7483
7659
  case "postgres": {
7484
- debug9("using postgres migration file");
7660
+ debug10("using postgres migration file");
7485
7661
  const mig = new CreateIssuanceBranding1685628974232();
7486
7662
  await mig.down(queryRunner);
7487
- debug9("Migration statements executed");
7663
+ debug10("Migration statements executed");
7488
7664
  return;
7489
7665
  }
7490
7666
  case "sqlite":
7491
7667
  case "expo":
7492
7668
  case "react-native": {
7493
- debug9("using sqlite/react-native migration file");
7669
+ debug10("using sqlite/react-native migration file");
7494
7670
  const mig = new CreateIssuanceBranding1685628973231();
7495
7671
  await mig.down(queryRunner);
7496
- debug9("Migration statements executed");
7672
+ debug10("Migration statements executed");
7497
7673
  return;
7498
7674
  }
7499
7675
  default:
@@ -7502,658 +7678,331 @@ var CreateIssuanceBranding1659463079429 = class {
7502
7678
  }
7503
7679
  };
7504
7680
 
7505
- // src/migrations/generic/3-CreateContacts.ts
7506
- var import_debug10 = __toESM(require("debug"), 1);
7681
+ // src/migrations/generic/12-CreateBitstringStatusList.ts
7682
+ var import_debug11 = __toESM(require("debug"), 1);
7507
7683
 
7508
- // src/migrations/sqlite/1690925872693-CreateContacts.ts
7509
- var CreateContacts1690925872693 = class {
7684
+ // src/migrations/postgres/1741895823000-CreateBitstringStatusList.ts
7685
+ var AddBitstringStatusListEnumPG1741895823000 = class {
7510
7686
  static {
7511
- __name(this, "CreateContacts1690925872693");
7687
+ __name(this, "AddBitstringStatusListEnumPG1741895823000");
7512
7688
  }
7513
- name = "CreateContacts1690925872693";
7689
+ name = "AddBitstringStatusListEnum1741895823000";
7514
7690
  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"`);
7691
+ await queryRunner.startTransaction();
7692
+ await queryRunner.query(`ALTER TYPE "StatusList_type_enum" ADD VALUE 'BitstringStatusList'`);
7693
+ await queryRunner.commitTransaction();
7886
7694
  }
7695
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
7887
7696
  async down(queryRunner) {
7888
- await queryRunner.query(`DROP TABLE "StatusListEntry"`);
7889
- await queryRunner.query(`DROP TABLE "StatusList"`);
7890
7697
  }
7891
7698
  };
7892
-
7893
- // src/migrations/postgres/1737110469001-UpdateStatusList.ts
7894
- var UpdateStatusList1737110469001 = class {
7699
+ var CreateBitstringStatusListPG1741895823000 = class {
7895
7700
  static {
7896
- __name(this, "UpdateStatusList1737110469001");
7701
+ __name(this, "CreateBitstringStatusListPG1741895823000");
7897
7702
  }
7898
- name = "UpdateStatusList1737110469001";
7703
+ name = "CreateBitstringStatusList1741895823000";
7899
7704
  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`);
7705
+ await queryRunner.query(`ALTER TABLE "StatusList" ADD COLUMN "ttl" integer`);
7706
+ await queryRunner.query(`ALTER TABLE "StatusList" ADD COLUMN "validFrom" TIMESTAMP`);
7707
+ await queryRunner.query(`ALTER TABLE "StatusList" ADD COLUMN "validUntil" TIMESTAMP`);
7708
+ await queryRunner.query(`ALTER TABLE "StatusList" DROP CONSTRAINT IF EXISTS "CHK_StatusList_type"`);
7709
+ await queryRunner.query(`ALTER TABLE "StatusList" ADD CONSTRAINT "CHK_StatusList_type" CHECK ("type" IN ('StatusList2021', 'OAuthStatusList', 'BitstringStatusList'))`);
7710
+ await queryRunner.query(`ALTER TABLE "StatusListEntry" ADD COLUMN "type" character varying NOT NULL DEFAULT 'StatusListEntryEntity'`);
7711
+ await queryRunner.query(`ALTER TABLE "StatusListEntry" ADD COLUMN "statusPurpose" character varying`);
7712
+ await queryRunner.query(`ALTER TABLE "StatusListEntry" ADD COLUMN "statusMessage" text`);
7713
+ await queryRunner.query(`ALTER TABLE "StatusListEntry" ADD COLUMN "statusReference" text`);
7714
+ await queryRunner.query(`ALTER TABLE "StatusListEntry" ADD CONSTRAINT "CHK_StatusListEntry_type" CHECK ("type" IN ('StatusListEntryEntity', 'bitstring'))`);
7905
7715
  }
7906
7716
  async down(queryRunner) {
7907
- await queryRunner.query(`ALTER TABLE "StatusList" DROP COLUMN "expiresAt"`);
7717
+ await queryRunner.query(`ALTER TABLE "StatusListEntry" DROP CONSTRAINT "CHK_StatusListEntry_type"`);
7718
+ await queryRunner.query(`ALTER TABLE "StatusListEntry" DROP COLUMN "statusReference"`);
7719
+ await queryRunner.query(`ALTER TABLE "StatusListEntry" DROP COLUMN "statusMessage"`);
7720
+ await queryRunner.query(`ALTER TABLE "StatusListEntry" DROP COLUMN "bitsPerStatus"`);
7721
+ await queryRunner.query(`ALTER TABLE "StatusListEntry" DROP COLUMN "statusPurpose"`);
7722
+ await queryRunner.query(`ALTER TABLE "StatusListEntry" DROP COLUMN "type"`);
7723
+ await queryRunner.query(`ALTER TABLE "StatusList" DROP CONSTRAINT "CHK_StatusList_type"`);
7724
+ await queryRunner.query(`ALTER TABLE "StatusList" ADD CONSTRAINT "CHK_StatusList_type" CHECK ("type" IN ('StatusList2021', 'OAuthStatusList'))`);
7725
+ await queryRunner.query(`ALTER TABLE "StatusList" DROP COLUMN "validUntil"`);
7726
+ await queryRunner.query(`ALTER TABLE "StatusList" DROP COLUMN "validFrom"`);
7727
+ await queryRunner.query(`ALTER TABLE "StatusList" DROP COLUMN "ttl"`);
7908
7728
  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
7729
  }
7912
7730
  };
7913
7731
 
7914
- // src/migrations/sqlite/1737110469000-UpdateStatusList.ts
7915
- var UpdateStatusList1737110469000 = class {
7732
+ // src/migrations/sqlite/1741895823001-CreateBitstringStatusList.ts
7733
+ var CreateBitstringStatusListSqlite1741895823001 = class {
7916
7734
  static {
7917
- __name(this, "UpdateStatusList1737110469000");
7735
+ __name(this, "CreateBitstringStatusListSqlite1741895823001");
7918
7736
  }
7919
- name = "UpdateStatusList1737110469000";
7737
+ name = "CreateBitstringStatusList1741895823000";
7920
7738
  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"`);
7739
+ await queryRunner.query(`
7740
+ CREATE TABLE "temporary_StatusList" (
7741
+ "id" varchar PRIMARY KEY NOT NULL,
7742
+ "correlationId" varchar NOT NULL,
7743
+ "length" integer NOT NULL,
7744
+ "issuer" text NOT NULL,
7745
+ "type" varchar CHECK( "type" IN ('StatusList2021', 'OAuthStatusList', 'BitstringStatusList') ) NOT NULL DEFAULT ('StatusList2021'),
7746
+ "driverType" varchar CHECK( "driverType" IN ('agent_typeorm','agent_kv_store','github','agent_filesystem') ) NOT NULL DEFAULT ('agent_typeorm'),
7747
+ "credentialIdMode" varchar CHECK( "credentialIdMode" IN ('ISSUANCE','PERSISTENCE','NEVER') ) NOT NULL DEFAULT ('ISSUANCE'),
7748
+ "proofFormat" varchar CHECK( "proofFormat" IN ('lds','jwt', 'vc+jwt') ) NOT NULL DEFAULT ('lds'),
7749
+ "indexingDirection" varchar CHECK( "indexingDirection" IN ('rightToLeft') ),
7750
+ "statusPurpose" varchar,
7751
+ "statusListCredential" text,
7752
+ "expiresAt" datetime,
7753
+ "bitsPerStatus" integer DEFAULT (1),
7754
+ "ttl" integer,
7755
+ "validFrom" datetime,
7756
+ "validUntil" datetime,
7757
+ CONSTRAINT "UQ_correlationId" UNIQUE ("correlationId")
7758
+ )
7759
+ `);
7760
+ await queryRunner.query(`
7761
+ INSERT INTO "temporary_StatusList"(
7762
+ "id", "correlationId", "length", "issuer", "type", "driverType",
7763
+ "credentialIdMode", "proofFormat", "indexingDirection", "statusPurpose",
7764
+ "statusListCredential", "bitsPerStatus", "expiresAt"
7765
+ )
7766
+ SELECT
7767
+ "id", "correlationId", "length", "issuer", "type", "driverType",
7768
+ "credentialIdMode", "proofFormat", "indexingDirection", "statusPurpose",
7769
+ "statusListCredential", "bitsPerStatus", "expiresAt"
7770
+ FROM "StatusList"
7771
+ `);
7947
7772
  await queryRunner.query(`DROP TABLE "StatusList"`);
7948
7773
  await queryRunner.query(`ALTER TABLE "temporary_StatusList" RENAME TO "StatusList"`);
7774
+ await queryRunner.query(`
7775
+ CREATE TABLE "temporary_StatusListEntry" (
7776
+ "statusListId" varchar NOT NULL,
7777
+ "statusListIndex" integer NOT NULL,
7778
+ "credentialId" text,
7779
+ "credentialHash" varchar(128),
7780
+ "correlationId" varchar(255),
7781
+ "value" varchar(50),
7782
+ "type" varchar CHECK( "type" IN ('StatusListEntryEntity', 'bitstring') ) NOT NULL DEFAULT ('StatusListEntryEntity'),
7783
+ "statusPurpose" varchar,
7784
+ "bitsPerStatus" integer DEFAULT (1),
7785
+ "statusMessage" text,
7786
+ "statusReference" text,
7787
+ PRIMARY KEY ("statusListId", "statusListIndex")
7788
+ )
7789
+ `);
7790
+ await queryRunner.query(`
7791
+ INSERT INTO "temporary_StatusListEntry"(
7792
+ "statusListId", "statusListIndex", "credentialId", "credentialHash",
7793
+ "correlationId", "value", "type"
7794
+ )
7795
+ SELECT
7796
+ "statusListId", "statusListIndex", "credentialId", "credentialHash",
7797
+ "correlationId", "value", 'StatusListEntryEntity'
7798
+ FROM "StatusListEntry"
7799
+ `);
7800
+ await queryRunner.query(`DROP TABLE "StatusListEntry"`);
7801
+ await queryRunner.query(`ALTER TABLE "temporary_StatusListEntry" RENAME TO "StatusListEntry"`);
7949
7802
  }
7950
7803
  async down(queryRunner) {
7951
7804
  await queryRunner.query(`
7952
- ALTER TABLE "StatusListEntry"
7953
- RENAME COLUMN "entryCorrelationId" TO "correlationId"
7954
- `);
7805
+ CREATE TABLE "temporary_StatusListEntry" (
7806
+ "statusListId" varchar NOT NULL,
7807
+ "statusListIndex" integer NOT NULL,
7808
+ "credentialId" text,
7809
+ "credentialHash" varchar(128),
7810
+ "correlationId" varchar(255),
7811
+ "value" varchar(50),
7812
+ PRIMARY KEY ("statusListId", "statusListIndex")
7813
+ )
7814
+ `);
7955
7815
  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"`);
7816
+ INSERT INTO "temporary_StatusListEntry"(
7817
+ "statusListId", "statusListIndex", "credentialId", "credentialHash",
7818
+ "correlationId", "value"
7819
+ )
7820
+ SELECT
7821
+ "statusListId", "statusListIndex", "credentialId", "credentialHash",
7822
+ "correlationId", "value"
7823
+ FROM "StatusListEntry"
7824
+ WHERE "type" = 'StatusListEntryEntity'
7825
+ `);
7826
+ await queryRunner.query(`DROP TABLE "StatusListEntry"`);
7827
+ await queryRunner.query(`ALTER TABLE "temporary_StatusListEntry" RENAME TO "StatusListEntry"`);
7828
+ await queryRunner.query(`
7829
+ CREATE TABLE "temporary_StatusList" (
7830
+ "id" varchar PRIMARY KEY NOT NULL,
7831
+ "correlationId" varchar NOT NULL,
7832
+ "length" integer NOT NULL,
7833
+ "issuer" text NOT NULL,
7834
+ "type" varchar CHECK( "type" IN ('StatusList2021', 'OAuthStatusList') ) NOT NULL DEFAULT ('StatusList2021'),
7835
+ "driverType" varchar CHECK( "driverType" IN ('agent_typeorm','agent_kv_store','github','agent_filesystem') ) NOT NULL DEFAULT ('agent_typeorm'),
7836
+ "credentialIdMode" varchar CHECK( "credentialIdMode" IN ('ISSUANCE','PERSISTENCE','NEVER') ) NOT NULL DEFAULT ('ISSUANCE'),
7837
+ "proofFormat" varchar CHECK( "proofFormat" IN ('lds','jwt', 'vc+jwt') ) NOT NULL DEFAULT ('lds'),
7838
+ "indexingDirection" varchar CHECK( "indexingDirection" IN ('rightToLeft') ),
7839
+ "statusPurpose" varchar,
7840
+ "statusListCredential" text,
7841
+ "bitsPerStatus" integer,
7842
+ "expiresAt" datetime,
7843
+ CONSTRAINT "UQ_correlationId" UNIQUE ("correlationId")
7844
+ )
7845
+ `);
7846
+ await queryRunner.query(`
7847
+ INSERT INTO "temporary_StatusList"(
7848
+ "id", "correlationId", "length", "issuer", "type", "driverType",
7849
+ "credentialIdMode", "proofFormat", "indexingDirection", "statusPurpose",
7850
+ "statusListCredential", "bitsPerStatus", "expiresAt"
7851
+ )
7852
+ SELECT
7853
+ "id", "correlationId", "length", "issuer",
7854
+ CASE WHEN "type" = 'BitstringStatusList' THEN 'StatusList2021' ELSE "type" END,
7855
+ "driverType", "credentialIdMode", "proofFormat", "indexingDirection",
7856
+ "statusPurpose", "statusListCredential", "bitsPerStatus", "expiresAt"
7857
+ FROM "StatusList"
7858
+ `);
7984
7859
  await queryRunner.query(`DROP TABLE "StatusList"`);
7985
7860
  await queryRunner.query(`ALTER TABLE "temporary_StatusList" RENAME TO "StatusList"`);
7986
7861
  }
7987
7862
  };
7988
7863
 
7989
- // src/migrations/generic/4-CreateStatusList.ts
7864
+ // src/migrations/generic/12-CreateBitstringStatusList.ts
7990
7865
  var debug11 = (0, import_debug11.default)("sphereon:ssi-sdk:migrations");
7991
- var CreateStatusList1693866470000 = class {
7866
+ var AddBitstringStatusListEnum1741895823000 = class {
7992
7867
  static {
7993
- __name(this, "CreateStatusList1693866470000");
7868
+ __name(this, "AddBitstringStatusListEnum1741895823000");
7994
7869
  }
7995
- name = "CreateStatusList1693866470000";
7870
+ name = "AddBitstringStatusListEnum1741895823000";
7996
7871
  async up(queryRunner) {
7997
- debug11("migration: creating issuance branding tables");
7872
+ debug11("migration: creating bitstring status list tables");
7998
7873
  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`);
7874
+ switch (dbType) {
7875
+ case "postgres": {
7876
+ const mig = new AddBitstringStatusListEnumPG1741895823000();
7877
+ await mig.up(queryRunner);
7878
+ return;
7879
+ }
7880
+ case "sqlite":
7881
+ case "expo":
7882
+ case "react-native": {
7883
+ return;
7884
+ }
7885
+ default:
7886
+ return Promise.reject(`Migrations only supported for sqlite and postgres. Was ${dbType}`);
7887
+ }
7888
+ }
7889
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
7890
+ async down(queryRunner) {
7891
+ }
7892
+ };
7893
+ var CreateBitstringStatusList1741895823000 = class {
7894
+ static {
7895
+ __name(this, "CreateBitstringStatusList1741895823000");
7896
+ }
7897
+ name = "CreateBitstringStatusList1741895823000";
7898
+ async up(queryRunner) {
7899
+ debug11("migration: creating bitstring status list tables");
7900
+ const dbType = queryRunner.connection.driver.options.type;
7901
+ switch (dbType) {
7902
+ case "postgres": {
7903
+ const mig = new CreateBitstringStatusListPG1741895823000();
7904
+ await mig.up(queryRunner);
7905
+ return;
7906
+ }
7907
+ case "sqlite":
7908
+ case "expo":
7909
+ case "react-native": {
7910
+ const mig = new CreateBitstringStatusListSqlite1741895823001();
7911
+ await mig.up(queryRunner);
7912
+ return;
7913
+ }
7914
+ default:
7915
+ return Promise.reject(`Migrations only supported for sqlite and postgres. Was ${dbType}`);
8017
7916
  }
8018
7917
  }
8019
7918
  async down(queryRunner) {
8020
- debug11("migration: reverting issuance branding tables");
7919
+ debug11("migration: dropping bitstring status list tables");
8021
7920
  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`);
7921
+ switch (dbType) {
7922
+ case "postgres": {
7923
+ const mig = new CreateBitstringStatusListPG1741895823000();
7924
+ await mig.down(queryRunner);
7925
+ return;
7926
+ }
7927
+ case "sqlite":
7928
+ case "expo":
7929
+ case "react-native": {
7930
+ const mig = new CreateBitstringStatusListSqlite1741895823001();
7931
+ await mig.down(queryRunner);
7932
+ return;
7933
+ }
7934
+ default:
7935
+ return Promise.reject(`Migrations only supported for sqlite and postgres. Was ${dbType}`);
8040
7936
  }
8041
7937
  }
8042
7938
  };
8043
7939
 
8044
- // src/migrations/generic/5-CreateAuditEvents.ts
7940
+ // src/migrations/generic/13-CreateDcqlQueryItem.ts
8045
7941
  var import_debug12 = __toESM(require("debug"), 1);
8046
7942
 
8047
- // src/migrations/sqlite/1701634819487-CreateAuditEvents.ts
8048
- var CreateAuditEvents1701634819487 = class {
7943
+ // src/migrations/postgres/1726588800000-CreateDcqlQueryItem.ts
7944
+ var CreateDcqlQueryItemPG1726588800000 = class {
8049
7945
  static {
8050
- __name(this, "CreateAuditEvents1701634819487");
7946
+ __name(this, "CreateDcqlQueryItemPG1726588800000");
8051
7947
  }
8052
- name = "CreateAuditEvents1701634819487";
7948
+ name = "CreateDcqlQueryItemPG1726588800000";
8053
7949
  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')))`);
7950
+ await queryRunner.query(`
7951
+ CREATE TABLE "DcqlQueryItem" (
7952
+ "id" uuid NOT NULL DEFAULT uuid_generate_v4(),
7953
+ "tenant_id" TEXT,
7954
+ "query_id" TEXT NOT NULL,
7955
+ "name" TEXT,
7956
+ "version" TEXT NOT NULL,
7957
+ "purpose" TEXT,
7958
+ "query" TEXT NOT NULL,
7959
+ "created_at" TIMESTAMP NOT NULL DEFAULT now(),
7960
+ "last_updated_at" TIMESTAMP NOT NULL DEFAULT now(),
7961
+ CONSTRAINT "PK_DcqlQueryItem_id" PRIMARY KEY ("id"))
7962
+ `);
8081
7963
  }
8082
7964
  async down(queryRunner) {
8083
- await queryRunner.query(`DROP TABLE "AuditEvents"`);
7965
+ await queryRunner.query(`DROP TABLE "DcqlQueryItem"`);
8084
7966
  }
8085
7967
  };
8086
7968
 
8087
- // src/migrations/postgres/1701634812183-CreateAuditEvents.ts
8088
- var CreateAuditEvents1701634812183 = class {
7969
+ // src/migrations/sqlite/1726617600000-CreateDcqlQueryItem.ts
7970
+ var CreateDcqlQueryItemSQlite1726617600000 = class {
8089
7971
  static {
8090
- __name(this, "CreateAuditEvents1701634812183");
7972
+ __name(this, "CreateDcqlQueryItemSQlite1726617600000");
8091
7973
  }
8092
- name = "CreateAuditEvents1701634812183";
7974
+ name = "CreateDcqlQueryItemSQlite1726617600000";
8093
7975
  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"))`);
7976
+ await queryRunner.query(`CREATE TABLE "DcqlQueryItem" (
7977
+ "id" varchar PRIMARY KEY NOT NULL,
7978
+ "tenant_id" varchar,
7979
+ "query_id" varchar NOT NULL,
7980
+ "name" varchar,
7981
+ "version" varchar NOT NULL,
7982
+ "purpose" varchar,
7983
+ "query" varchar NOT NULL,
7984
+ "created_at" datetime NOT NULL DEFAULT (datetime('now')),
7985
+ "last_updated_at" datetime NOT NULL DEFAULT (datetime('now')))`);
8130
7986
  }
8131
7987
  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"`);
7988
+ await queryRunner.query(`DROP TABLE "DcqlQueryItem"`);
8140
7989
  }
8141
7990
  };
8142
7991
 
8143
- // src/migrations/generic/5-CreateAuditEvents.ts
7992
+ // src/migrations/generic/13-CreateDcqlQueryItem.ts
8144
7993
  var debug12 = (0, import_debug12.default)("sphereon:ssi-sdk:migrations");
8145
- var CreateAuditEvents1701635835330 = class {
7994
+ var CreateDcqlQueryItem1726617600000 = class {
8146
7995
  static {
8147
- __name(this, "CreateAuditEvents1701635835330");
7996
+ __name(this, "CreateDcqlQueryItem1726617600000");
8148
7997
  }
8149
- name = "CreateAuditEvents1701635835330";
7998
+ name = "CreateDcqlQueryItem1726617600000";
8150
7999
  async up(queryRunner) {
8151
- debug12("migration: creating audit events tables");
8000
+ debug12("migration: updating presentation definition item nullable fields");
8152
8001
  const dbType = queryRunner.connection.driver.options.type;
8153
8002
  switch (dbType) {
8154
8003
  case "postgres": {
8155
8004
  debug12("using postgres migration file");
8156
- const mig = new CreateAuditEvents1701634812183();
8005
+ const mig = new CreateDcqlQueryItemPG1726588800000();
8157
8006
  await mig.up(queryRunner);
8158
8007
  debug12("Migration statements executed");
8159
8008
  return;
@@ -8162,7 +8011,7 @@ var CreateAuditEvents1701635835330 = class {
8162
8011
  case "expo":
8163
8012
  case "react-native": {
8164
8013
  debug12("using sqlite/react-native migration file");
8165
- const mig = new CreateAuditEvents1701634819487();
8014
+ const mig = new CreateDcqlQueryItemSQlite1726617600000();
8166
8015
  await mig.up(queryRunner);
8167
8016
  debug12("Migration statements executed");
8168
8017
  return;
@@ -8172,12 +8021,12 @@ var CreateAuditEvents1701635835330 = class {
8172
8021
  }
8173
8022
  }
8174
8023
  async down(queryRunner) {
8175
- debug12("migration: reverting audit events tables");
8024
+ debug12("migration: reverting presentation definition item nullable fields");
8176
8025
  const dbType = queryRunner.connection.driver.options.type;
8177
8026
  switch (dbType) {
8178
8027
  case "postgres": {
8179
8028
  debug12("using postgres migration file");
8180
- const mig = new CreateAuditEvents1701634812183();
8029
+ const mig = new CreateDcqlQueryItemPG1726588800000();
8181
8030
  await mig.down(queryRunner);
8182
8031
  debug12("Migration statements executed");
8183
8032
  return;
@@ -8186,7 +8035,7 @@ var CreateAuditEvents1701635835330 = class {
8186
8035
  case "expo":
8187
8036
  case "react-native": {
8188
8037
  debug12("using sqlite/react-native migration file");
8189
- const mig = new CreateAuditEvents1701634819487();
8038
+ const mig = new CreateDcqlQueryItemSQlite1726617600000();
8190
8039
  await mig.down(queryRunner);
8191
8040
  debug12("Migration statements executed");
8192
8041
  return;
@@ -8197,247 +8046,299 @@ var CreateAuditEvents1701635835330 = class {
8197
8046
  }
8198
8047
  };
8199
8048
 
8200
- // src/migrations/generic/6-CreateDigitalCredential.ts
8049
+ // src/migrations/generic/2-CreateIssuanceBranding.ts
8201
8050
  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
8051
  var debug13 = (0, import_debug13.default)("sphereon:ssi-sdk:migrations");
8310
- var CreateDigitalCredential1708525189000 = class {
8052
+ var CreateIssuanceBranding1659463079429 = class {
8311
8053
  static {
8312
- __name(this, "CreateDigitalCredential1708525189000");
8054
+ __name(this, "CreateIssuanceBranding1659463079429");
8313
8055
  }
8314
- name = "CreateDigitalCredential1708525189000";
8056
+ name = "CreateIssuanceBranding1659463079429";
8315
8057
  async up(queryRunner) {
8316
- debug13("migration: creating DigitalCredential tables");
8058
+ debug13("migration: creating issuance branding tables");
8317
8059
  const dbType = queryRunner.connection.driver.options.type;
8318
8060
  switch (dbType) {
8319
8061
  case "postgres": {
8320
- debug13("using postgres migration file for DigitalCredential");
8321
- const mig = new CreateDigitalCredential1708525189001();
8062
+ debug13("using postgres migration file");
8063
+ const mig = new CreateIssuanceBranding1685628974232();
8322
8064
  await mig.up(queryRunner);
8323
- debug13("Postgres Migration statements for DigitalCredential executed");
8065
+ debug13("Migration statements executed");
8324
8066
  return;
8325
8067
  }
8326
8068
  case "sqlite":
8327
8069
  case "expo":
8328
8070
  case "react-native": {
8329
- debug13("using sqlite/react-native migration file for DigitalCredential");
8330
- const mig = new CreateDigitalCredential1708525189002();
8071
+ debug13("using sqlite/react-native migration file");
8072
+ const mig = new CreateIssuanceBranding1685628973231();
8331
8073
  await mig.up(queryRunner);
8332
- debug13("SQLite Migration statements for DigitalCredential executed");
8074
+ debug13("Migration statements executed");
8333
8075
  return;
8334
8076
  }
8335
8077
  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`);
8078
+ 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
8079
  }
8338
8080
  }
8339
8081
  async down(queryRunner) {
8340
- debug13("migration: reverting DigitalCredential tables");
8082
+ debug13("migration: reverting issuance branding tables");
8341
8083
  const dbType = queryRunner.connection.driver.options.type;
8342
8084
  switch (dbType) {
8343
8085
  case "postgres": {
8344
- debug13("using postgres migration file for DigitalCredential");
8345
- const mig = new CreateDigitalCredential1708525189001();
8086
+ debug13("using postgres migration file");
8087
+ const mig = new CreateIssuanceBranding1685628974232();
8346
8088
  await mig.down(queryRunner);
8347
- debug13("Postgres Migration statements for DigitalCredential reverted");
8089
+ debug13("Migration statements executed");
8348
8090
  return;
8349
8091
  }
8350
8092
  case "sqlite":
8351
8093
  case "expo":
8352
8094
  case "react-native": {
8353
- debug13("using sqlite/react-native migration file for DigitalCredential");
8354
- const mig = new CreateDigitalCredential1708525189002();
8095
+ debug13("using sqlite/react-native migration file");
8096
+ const mig = new CreateIssuanceBranding1685628973231();
8355
8097
  await mig.down(queryRunner);
8356
- debug13("SQLite Migration statements for DigitalCredential reverted");
8098
+ debug13("Migration statements executed");
8357
8099
  return;
8358
8100
  }
8359
8101
  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`);
8102
+ 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
8103
  }
8362
8104
  }
8363
8105
  };
8364
8106
 
8365
- // src/migrations/generic/7-CreateMachineStateStore.ts
8107
+ // src/migrations/generic/3-CreateContacts.ts
8366
8108
  var import_debug14 = __toESM(require("debug"), 1);
8367
8109
 
8368
- // src/migrations/postgres/1708797018115-CreateMachineStateStore.ts
8369
- var CreateMachineStateStore1708797018115 = class {
8110
+ // src/migrations/sqlite/1690925872693-CreateContacts.ts
8111
+ var CreateContacts1690925872693 = class {
8370
8112
  static {
8371
- __name(this, "CreateMachineStateStore1708797018115");
8113
+ __name(this, "CreateContacts1690925872693");
8372
8114
  }
8373
- name = "CreateMachineStateStore1708797018115";
8115
+ name = "CreateContacts1690925872693";
8374
8116
  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
- `);
8117
+ 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"))`);
8118
+ await queryRunner.query(`INSERT INTO "temporary_CorrelationIdentifier"("id", "type", "correlation_id", "identityId") SELECT "id", "type", "correlation_id", "identityId" FROM "CorrelationIdentifier"`);
8119
+ await queryRunner.query(`DROP TABLE "CorrelationIdentifier"`);
8120
+ await queryRunner.query(`ALTER TABLE "temporary_CorrelationIdentifier" RENAME TO "CorrelationIdentifier"`);
8121
+ 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"))`);
8122
+ 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"`);
8123
+ await queryRunner.query(`DROP TABLE "Identity"`);
8124
+ await queryRunner.query(`ALTER TABLE "temporary_Identity" RENAME TO "Identity"`);
8125
+ 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"))`);
8126
+ await queryRunner.query(`INSERT INTO "temporary_Connection"("id", "type", "identityId") SELECT "id", "type", "identityId" FROM "Connection"`);
8127
+ await queryRunner.query(`DROP TABLE "Connection"`);
8128
+ await queryRunner.query(`ALTER TABLE "temporary_Connection" RENAME TO "Connection"`);
8129
+ 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"))`);
8130
+ await queryRunner.query(`INSERT INTO "temporary_CorrelationIdentifier"("id", "type", "correlation_id", "identity_id") SELECT "id", "type", "correlation_id", "identityId" FROM "CorrelationIdentifier"`);
8131
+ await queryRunner.query(`DROP TABLE "CorrelationIdentifier"`);
8132
+ await queryRunner.query(`ALTER TABLE "temporary_CorrelationIdentifier" RENAME TO "CorrelationIdentifier"`);
8133
+ 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"))`);
8134
+ 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"`);
8135
+ await queryRunner.query(`DROP TABLE "Identity"`);
8136
+ await queryRunner.query(`ALTER TABLE "temporary_Identity" RENAME TO "Identity"`);
8137
+ 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"))`);
8138
+ await queryRunner.query(`INSERT INTO "temporary_Connection"("id", "type", "identity_id") SELECT "id", "type", "identityId" FROM "Connection"`);
8139
+ await queryRunner.query(`DROP TABLE "Connection"`);
8140
+ await queryRunner.query(`ALTER TABLE "temporary_Connection" RENAME TO "Connection"`);
8141
+ 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"))`);
8142
+ await queryRunner.query(`CREATE UNIQUE INDEX "IDX_PartyType_type_tenant_id" ON "PartyType" ("type", "tenant_id")`);
8143
+ 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"))`);
8144
+ await queryRunner.query(`CREATE INDEX "IDX_BaseContact_type" ON "BaseContact" ("type")`);
8145
+ 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')))`);
8146
+ await queryRunner.query(`CREATE UNIQUE INDEX "IDX_PartyRelationship_left_right" ON "PartyRelationship" ("left_id", "right_id")`);
8147
+ 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)`);
8148
+ 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"))`);
8149
+ await queryRunner.query(`CREATE INDEX "IDX_BaseConfig_type" ON "BaseConfig" ("type")`);
8150
+ 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)`);
8151
+ await queryRunner.query(`INSERT INTO "temporary_CorrelationIdentifier"("id", "type", "correlation_id", "identity_id") SELECT "id", "type", "correlation_id", "identity_id" FROM "CorrelationIdentifier"`);
8152
+ await queryRunner.query(`DROP TABLE "CorrelationIdentifier"`);
8153
+ await queryRunner.query(`ALTER TABLE "temporary_CorrelationIdentifier" RENAME TO "CorrelationIdentifier"`);
8154
+ await queryRunner.query(`DROP INDEX "IDX_BaseContact_type"`);
8155
+ 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)`);
8156
+ 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"`);
8157
+ await queryRunner.query(`DROP TABLE "BaseContact"`);
8158
+ await queryRunner.query(`ALTER TABLE "temporary_BaseContact" RENAME TO "BaseContact"`);
8159
+ await queryRunner.query(`CREATE INDEX "IDX_BaseContact_type" ON "BaseContact" ("type")`);
8160
+ await queryRunner.query(`DROP INDEX "IDX_PartyRelationship_left_right"`);
8161
+ 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)`);
8162
+ 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"`);
8163
+ await queryRunner.query(`DROP TABLE "PartyRelationship"`);
8164
+ await queryRunner.query(`ALTER TABLE "temporary_PartyRelationship" RENAME TO "PartyRelationship"`);
8165
+ await queryRunner.query(`CREATE UNIQUE INDEX "IDX_PartyRelationship_left_right" ON "PartyRelationship" ("left_id", "right_id")`);
8166
+ 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)`);
8167
+ 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)`);
8168
+ 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)`);
8169
+ 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"`);
8170
+ await queryRunner.query(`DROP TABLE "Party"`);
8171
+ await queryRunner.query(`ALTER TABLE "temporary_Party" RENAME TO "Party"`);
8172
+ 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)`);
8173
+ 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"`);
8174
+ await queryRunner.query(`DROP TABLE "Identity"`);
8175
+ await queryRunner.query(`ALTER TABLE "temporary_Identity" RENAME TO "Identity"`);
8176
+ 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)`);
8177
+ await queryRunner.query(`INSERT INTO "temporary_Connection"("id", "type", "identity_id") SELECT "id", "type", "identity_id" FROM "Connection"`);
8178
+ await queryRunner.query(`DROP TABLE "Connection"`);
8179
+ await queryRunner.query(`ALTER TABLE "temporary_Connection" RENAME TO "Connection"`);
8180
+ await queryRunner.query(`DROP INDEX "IDX_BaseConfig_type"`);
8181
+ 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)`);
8182
+ 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"`);
8183
+ await queryRunner.query(`DROP TABLE "BaseConfig"`);
8184
+ await queryRunner.query(`ALTER TABLE "temporary_BaseConfig" RENAME TO "BaseConfig"`);
8185
+ await queryRunner.query(`CREATE INDEX "IDX_BaseConfig_type" ON "BaseConfig" ("type")`);
8186
+ 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"`);
8187
+ await queryRunner.query(`DROP TABLE "BaseConfigEntity"`);
8188
+ 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'))`);
8189
+ 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'))`);
8190
+ 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"`);
8191
+ 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"`);
8192
+ await queryRunner.query(`DROP TABLE "Contact"`);
8392
8193
  }
8393
8194
  async down(queryRunner) {
8394
- await queryRunner.query(`DROP TABLE "MachineStateInfoEntity"`);
8195
+ 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))`);
8196
+ 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'`);
8197
+ await queryRunner.query(`DROP TABLE "BaseContact"`);
8198
+ await queryRunner.query(`DROP TABLE "Party"`);
8199
+ 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)`);
8200
+ 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"`);
8201
+ await queryRunner.query(`DROP TABLE "BaseConfig"`);
8202
+ 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)`);
8203
+ 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"`);
8204
+ await queryRunner.query(`DROP TABLE "Party"`);
8205
+ await queryRunner.query(`ALTER TABLE "temporary_Party" RENAME TO "Party"`);
8206
+ await queryRunner.query(`DROP INDEX "IDX_PartyRelationship_left_right"`);
8207
+ 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)`);
8208
+ 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"`);
8209
+ await queryRunner.query(`DROP TABLE "PartyRelationship"`);
8210
+ await queryRunner.query(`ALTER TABLE "temporary_PartyRelationship" RENAME TO "PartyRelationship"`);
8211
+ await queryRunner.query(`CREATE UNIQUE INDEX "IDX_PartyRelationship_left_right" ON "PartyRelationship" ("left_id", "right_id")`);
8212
+ await queryRunner.query(`DROP INDEX "IDX_BaseContact_type"`);
8213
+ 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)`);
8214
+ 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"`);
8215
+ await queryRunner.query(`DROP TABLE "BaseContact"`);
8216
+ await queryRunner.query(`ALTER TABLE "temporary_BaseContact" RENAME TO "BaseContact"`);
8217
+ await queryRunner.query(`CREATE INDEX "IDX_BaseContact_type" ON "BaseContact" ("type")`);
8218
+ await queryRunner.query(`DROP INDEX "IDX_BaseConfig_type"`);
8219
+ 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)`);
8220
+ 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"`);
8221
+ await queryRunner.query(`DROP TABLE "BaseConfig"`);
8222
+ await queryRunner.query(`ALTER TABLE "temporary_BaseConfig" RENAME TO "BaseConfig"`);
8223
+ await queryRunner.query(`CREATE INDEX "IDX_BaseConfig_type" ON "BaseConfig" ("type")`);
8224
+ await queryRunner.query(`DROP INDEX "IDX_PartyType_type_tenant_id"`);
8225
+ await queryRunner.query(`DROP TABLE "PartyType"`);
8226
+ await queryRunner.query(`DROP TABLE "Connection"`);
8227
+ await queryRunner.query(`DROP TABLE "Identity"`);
8228
+ await queryRunner.query(`DROP TABLE "CorrelationIdentifier"`);
8229
+ await queryRunner.query(`DROP TABLE "ElectronicAddress"`);
8230
+ await queryRunner.query(`DROP TABLE "PhysicalAddress"`);
8395
8231
  }
8396
8232
  };
8397
8233
 
8398
- // src/migrations/sqlite/1708796002272-CreateMachineStateStore.ts
8399
- var CreateMachineStateStore1708796002272 = class {
8234
+ // src/migrations/postgres/1690925872592-CreateContacts.ts
8235
+ var import_ssi_sdk22 = require("@sphereon/ssi-sdk.core");
8236
+ var CreateContacts1690925872592 = class {
8400
8237
  static {
8401
- __name(this, "CreateMachineStateStore1708796002272");
8238
+ __name(this, "CreateContacts1690925872592");
8402
8239
  }
8403
- name = "CreateMachineStateStore1708796002272";
8240
+ name = "CreateContacts1690925872592";
8404
8241
  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
- `);
8242
+ await (0, import_ssi_sdk22.enablePostgresUuidExtension)(queryRunner);
8243
+ await queryRunner.query(`ALTER TABLE "CorrelationIdentifier" DROP CONSTRAINT "FK_CorrelationIdentifier_identityId"`);
8244
+ await queryRunner.query(`ALTER TABLE "IdentityMetadata" DROP CONSTRAINT "FK_IdentityMetadata_identityId"`);
8245
+ await queryRunner.query(`ALTER TABLE "Identity" DROP CONSTRAINT "FK_Identity_contactId"`);
8246
+ await queryRunner.query(`ALTER TABLE "Connection" DROP CONSTRAINT "FK_Connection_identityId"`);
8247
+ await queryRunner.query(`ALTER TABLE "CorrelationIdentifier" RENAME COLUMN "identityId" TO "identity_id"`);
8248
+ await queryRunner.query(`ALTER TABLE "Connection" RENAME COLUMN "identityId" TO "identity_id"`);
8249
+ await queryRunner.query(`CREATE TYPE "public"."PartyType_type_enum" AS ENUM('naturalPerson', 'organization')`);
8250
+ await queryRunner.query(`CREATE TYPE "public"."PartyOrigin_type_enum" AS ENUM('INTERNAL', 'EXTERNAL')`);
8251
+ 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"))`);
8252
+ await queryRunner.query(`CREATE UNIQUE INDEX "IDX_PartyType_type_tenant_id" ON "PartyType" ("type", "tenant_id")`);
8253
+ 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"))`);
8254
+ await queryRunner.query(`CREATE INDEX "IDX_BaseContact_type" ON "BaseContact" ("type")`);
8255
+ 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"))`);
8256
+ await queryRunner.query(`CREATE UNIQUE INDEX "IDX_PartyRelationship_left_right" ON "PartyRelationship" ("left_id", "right_id")`);
8257
+ 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"))`);
8258
+ 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"))`);
8259
+ 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"))`);
8260
+ 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"))`);
8261
+ await queryRunner.query(`CREATE INDEX "IDX_BaseConfig_type" ON "BaseConfig" ("type")`);
8262
+ await queryRunner.query(`ALTER TABLE "Identity" RENAME COLUMN "contactId" TO "partyId"`);
8263
+ await queryRunner.query(`ALTER TABLE "Identity" ALTER COLUMN "roles" SET NOT NULL`);
8264
+ await queryRunner.query(`CREATE TYPE "public"."IdentityOrigin_type_enum" AS ENUM('INTERNAL', 'EXTERNAL')`);
8265
+ await queryRunner.query(`ALTER TABLE "Identity" ADD COLUMN "origin" "public"."IdentityOrigin_type_enum" DEFAULT 'EXTERNAL' NOT NULL`);
8266
+ await queryRunner.query(`ALTER TABLE "Identity" ALTER COLUMN "origin" DROP DEFAULT`);
8267
+ 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`);
8268
+ await queryRunner.query(`ALTER TABLE "IdentityMetadata" ADD CONSTRAINT "FK_IdentityMetadata_identityId" FOREIGN KEY ("identityId") REFERENCES "Identity"("id") ON DELETE CASCADE ON UPDATE NO ACTION`);
8269
+ 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`);
8270
+ 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`);
8271
+ 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`);
8272
+ await queryRunner.query(`ALTER TABLE "ElectronicAddress" ADD CONSTRAINT "FK_ElectronicAddress_partyId" FOREIGN KEY ("partyId") REFERENCES "Party"("id") ON DELETE CASCADE ON UPDATE NO ACTION`);
8273
+ await queryRunner.query(`ALTER TABLE "PhysicalAddress" ADD CONSTRAINT "FK_PhysicalAddress_partyId" FOREIGN KEY ("partyId") REFERENCES "Party" ("id") ON DELETE CASCADE ON UPDATE NO ACTION`);
8274
+ 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`);
8275
+ await queryRunner.query(`ALTER TABLE "Identity" ADD CONSTRAINT "FK_Identity_partyId" FOREIGN KEY ("partyId") REFERENCES "Party"("id") ON DELETE CASCADE ON UPDATE NO ACTION`);
8276
+ 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`);
8277
+ 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`);
8278
+ await queryRunner.query(`ALTER TABLE "CorrelationIdentifier" RENAME CONSTRAINT "UQ_Correlation_id" TO "UQ_CorrelationIdentifier_correlation_id"`);
8279
+ await queryRunner.query(`ALTER TABLE "Identity" RENAME CONSTRAINT "UQ_Identity_Alias" TO "UQ_Identity_alias"`);
8280
+ 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"`);
8281
+ await queryRunner.query(`DROP TABLE "BaseConfigEntity"`);
8282
+ 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())`);
8283
+ 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())`);
8284
+ 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"`);
8285
+ 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"`);
8286
+ await queryRunner.query(`DROP TABLE "Contact"`);
8421
8287
  }
8422
8288
  async down(queryRunner) {
8423
- await queryRunner.query(`DROP TABLE "MachineStateInfoEntity"`);
8289
+ await queryRunner.query(`ALTER TABLE "BaseConfig" DROP CONSTRAINT "FK_BaseConfig_connection_id"`);
8290
+ await queryRunner.query(`ALTER TABLE "Connection" DROP CONSTRAINT "FK_Connection_identity_id"`);
8291
+ await queryRunner.query(`ALTER TABLE "Identity" DROP CONSTRAINT "FK_Identity_partyId"`);
8292
+ await queryRunner.query(`ALTER TABLE "Party" DROP CONSTRAINT "FK_Party_party_type_id"`);
8293
+ await queryRunner.query(`ALTER TABLE "PhysicalAddress" DROP CONSTRAINT "FK_PhysicalAddress_partyId"`);
8294
+ await queryRunner.query(`ALTER TABLE "ElectronicAddress" DROP CONSTRAINT "FK_ElectronicAddress_partyId"`);
8295
+ await queryRunner.query(`ALTER TABLE "PartyRelationship" DROP CONSTRAINT "FK_PartyRelationship_right_id"`);
8296
+ await queryRunner.query(`ALTER TABLE "PartyRelationship" DROP CONSTRAINT "FK_PartyRelationship_left_id"`);
8297
+ await queryRunner.query(`ALTER TABLE "BaseContact" DROP CONSTRAINT "FK_BaseContact_party_id"`);
8298
+ await queryRunner.query(`ALTER TABLE "IdentityMetadata" DROP CONSTRAINT "FK_IdentityMetadata_identityId"`);
8299
+ await queryRunner.query(`ALTER TABLE "CorrelationIdentifier" DROP CONSTRAINT "FK_CorrelationIdentifier_identity_id"`);
8300
+ await queryRunner.query(`ALTER TABLE "Identity" ALTER COLUMN "roles" DROP NOT NULL`);
8301
+ await queryRunner.query(`ALTER TABLE "Identity" DROP COLUMN "origin"`);
8302
+ await queryRunner.query(`DROP TYPE "public"."IdentityOrigin_type_enum"`);
8303
+ await queryRunner.query(`ALTER TABLE "Identity" RENAME COLUMN "partyId" TO "contactId"`);
8304
+ await queryRunner.query(`ALTER TABLE "Connection" RENAME COLUMN "identity_id" TO "identityId"`);
8305
+ await queryRunner.query(`ALTER TABLE "CorrelationIdentifier" RENAME COLUMN "identity_id" TO "identityId"`);
8306
+ await queryRunner.query(`DROP INDEX "IDX_BaseConfig_type"`);
8307
+ await queryRunner.query(`DROP TABLE "BaseConfig"`);
8308
+ await queryRunner.query(`DROP TABLE "Party"`);
8309
+ await queryRunner.query(`DROP INDEX "IDX_PartyRelationship_left_right"`);
8310
+ await queryRunner.query(`DROP TABLE "PartyRelationship"`);
8311
+ await queryRunner.query(`DROP INDEX "IDX_BaseContact_type"`);
8312
+ await queryRunner.query(`DROP TABLE "BaseContact"`);
8313
+ await queryRunner.query(`DROP TABLE "ElectronicAddress"`);
8314
+ await queryRunner.query(`DROP TABLE "PhysicalAddress"`);
8315
+ await queryRunner.query(`DROP INDEX "IDX_PartyType_type_tenant_id"`);
8316
+ await queryRunner.query(`DROP TABLE "PartyType"`);
8317
+ await queryRunner.query(`DROP TYPE "public"."PartyOrigin_type_enum"`);
8318
+ await queryRunner.query(`DROP TYPE "public"."PartyType_type_enum"`);
8319
+ await queryRunner.query(`ALTER TABLE "Connection" ADD CONSTRAINT "FK_Connection_identityId" FOREIGN KEY ("identityId") REFERENCES "Identity"("id") ON DELETE CASCADE ON UPDATE NO ACTION`);
8320
+ await queryRunner.query(`ALTER TABLE "Identity" ADD CONSTRAINT "FK_Identity_contactId" FOREIGN KEY ("contactId") REFERENCES "Contact"("id") ON DELETE CASCADE ON UPDATE NO ACTION`);
8321
+ await queryRunner.query(`ALTER TABLE "IdentityMetadata" ADD CONSTRAINT "FK_IdentityMetadata_identityId" FOREIGN KEY ("identityId") REFERENCES "Identity"("id") ON DELETE CASCADE ON UPDATE NO ACTION`);
8322
+ await queryRunner.query(`ALTER TABLE "CorrelationIdentifier" ADD CONSTRAINT "FK_CorrelationIdentifier_identityId" FOREIGN KEY ("identityId") REFERENCES "Identity"("id") ON DELETE CASCADE ON UPDATE NO ACTION`);
8323
+ 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"))`);
8324
+ 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
8325
  }
8425
8326
  };
8426
8327
 
8427
- // src/migrations/generic/7-CreateMachineStateStore.ts
8328
+ // src/migrations/generic/3-CreateContacts.ts
8428
8329
  var debug14 = (0, import_debug14.default)("sphereon:ssi-sdk:migrations");
8429
- var CreateMachineStateStore1708098041262 = class {
8330
+ var CreateContacts1690925872318 = class {
8430
8331
  static {
8431
- __name(this, "CreateMachineStateStore1708098041262");
8332
+ __name(this, "CreateContacts1690925872318");
8432
8333
  }
8433
- name = "CreateMachineStateStore1708098041262";
8334
+ name = "CreateContacts1690925872318";
8434
8335
  async up(queryRunner) {
8435
- debug14("migration: creating machine state tables");
8336
+ debug14("migration: creating contacts tables");
8436
8337
  const dbType = queryRunner.connection.driver.options.type;
8437
8338
  switch (dbType) {
8438
8339
  case "postgres": {
8439
8340
  debug14("using postgres migration file");
8440
- const mig = new CreateMachineStateStore1708797018115();
8341
+ const mig = new CreateContacts1690925872592();
8441
8342
  await mig.up(queryRunner);
8442
8343
  debug14("Migration statements executed");
8443
8344
  return;
@@ -8446,7 +8347,7 @@ var CreateMachineStateStore1708098041262 = class {
8446
8347
  case "expo":
8447
8348
  case "react-native": {
8448
8349
  debug14("using sqlite/react-native migration file");
8449
- const mig = new CreateMachineStateStore1708796002272();
8350
+ const mig = new CreateContacts1690925872693();
8450
8351
  await mig.up(queryRunner);
8451
8352
  debug14("Migration statements executed");
8452
8353
  return;
@@ -8456,12 +8357,12 @@ var CreateMachineStateStore1708098041262 = class {
8456
8357
  }
8457
8358
  }
8458
8359
  async down(queryRunner) {
8459
- debug14("migration: reverting machine state tables");
8360
+ debug14("migration: reverting contacts tables");
8460
8361
  const dbType = queryRunner.connection.driver.options.type;
8461
8362
  switch (dbType) {
8462
8363
  case "postgres": {
8463
8364
  debug14("using postgres migration file");
8464
- const mig = new CreateMachineStateStore1708797018115();
8365
+ const mig = new CreateContacts1690925872592();
8465
8366
  await mig.down(queryRunner);
8466
8367
  debug14("Migration statements executed");
8467
8368
  return;
@@ -8470,7 +8371,7 @@ var CreateMachineStateStore1708098041262 = class {
8470
8371
  case "expo":
8471
8372
  case "react-native": {
8472
8373
  debug14("using sqlite/react-native migration file");
8473
- const mig = new CreateMachineStateStore1708796002272();
8374
+ const mig = new CreateContacts1690925872693();
8474
8375
  await mig.down(queryRunner);
8475
8376
  debug14("Migration statements executed");
8476
8377
  return;
@@ -8481,303 +8382,380 @@ var CreateMachineStateStore1708098041262 = class {
8481
8382
  }
8482
8383
  };
8483
8384
 
8484
- // src/migrations/generic/8-CreateContacts.ts
8385
+ // src/migrations/generic/4-CreateStatusList.ts
8485
8386
  var import_debug15 = __toESM(require("debug"), 1);
8486
8387
 
8487
- // src/migrations/postgres/1710438363001-CreateContacts.ts
8488
- var CreateContacts1710438363001 = class {
8388
+ // src/migrations/postgres/1693866470001-CreateStatusList.ts
8389
+ var CreateStatusList1693866470001 = class {
8489
8390
  static {
8490
- __name(this, "CreateContacts1710438363001");
8391
+ __name(this, "CreateStatusList1693866470001");
8491
8392
  }
8492
- name = "CreateContacts1710438363001";
8393
+ name = "CreateStatusList1693866470001";
8493
8394
  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`);
8395
+ await queryRunner.query(`CREATE TYPE "StatusList_type_enum" AS ENUM('StatusList2021')`);
8396
+ await queryRunner.query(`CREATE TYPE "StatusList_drivertype_enum" AS ENUM('agent_typeorm', 'agent_kv_store', 'github', 'agent_filesystem')`);
8397
+ await queryRunner.query(`CREATE TYPE "StatusList_credentialidmode_enum" AS ENUM('ISSUANCE', 'PERSISTENCE', 'NEVER')`);
8398
+ await queryRunner.query(`CREATE TABLE "StatusListEntry"
8399
+ (
8400
+ "statusListId" character varying NOT NULL,
8401
+ "statusListIndex" integer NOT NULL,
8402
+ "credentialId" character varying,
8403
+ "credentialHash" character varying(128),
8404
+ "correlationId" character varying(255),
8405
+ "value" character varying(50),
8406
+ CONSTRAINT "PK_68704d2d13857360c6b44a3d1d0" PRIMARY KEY ("statusListId", "statusListIndex")
8407
+ )`);
8408
+ await queryRunner.query(`CREATE TABLE "StatusList"
8409
+ (
8410
+ "id" character varying NOT NULL,
8411
+ "correlationId" character varying NOT NULL,
8412
+ "length" integer NOT NULL,
8413
+ "issuer" text NOT NULL,
8414
+ "type" "StatusList_type_enum" NOT NULL DEFAULT 'StatusList2021',
8415
+ "driverType" "StatusList_drivertype_enum" NOT NULL DEFAULT 'agent_typeorm',
8416
+ "credentialIdMode" "StatusList_credentialidmode_enum" NOT NULL DEFAULT 'ISSUANCE',
8417
+ "proofFormat" character varying NOT NULL DEFAULT 'lds',
8418
+ "indexingDirection" character varying NOT NULL DEFAULT 'rightToLeft',
8419
+ "statusPurpose" character varying NOT NULL DEFAULT 'revocation',
8420
+ "statusListCredential" text,
8421
+ CONSTRAINT "UQ_correlationId" UNIQUE ("correlationId"),
8422
+ CONSTRAINT "PK_StatusList_Id" PRIMARY KEY ("id")
8423
+ )`);
8424
+ await queryRunner.query(`ALTER TABLE "StatusListEntry"
8425
+ ADD CONSTRAINT "FK_statusListEntry_statusListId" FOREIGN KEY ("statusListId") REFERENCES "StatusList" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION`);
8512
8426
  }
8513
8427
  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"`);
8428
+ await queryRunner.query(`ALTER TABLE "StatusListEntry"
8429
+ DROP CONSTRAINT "FK_statusListEntry_statusListId"`);
8430
+ await queryRunner.query(`DROP TABLE "StatusListEntry"`);
8431
+ await queryRunner.query(`DROP TABLE "StatusList"`);
8432
+ await queryRunner.query(`DROP TYPE "StatusList_credentialidmode_enum"`);
8433
+ await queryRunner.query(`DROP TYPE "StatusList_drivertype_enum"`);
8434
+ await queryRunner.query(`DROP TYPE "StatusList_type_enum"`);
8532
8435
  }
8533
8436
  };
8534
8437
 
8535
- // src/migrations/sqlite/1710438363002-CreateContacts.ts
8536
- var CreateContacts1710438363002 = class {
8438
+ // src/migrations/sqlite/1693866470000-CreateStatusList.ts
8439
+ var CreateStatusList1693866470002 = class {
8537
8440
  static {
8538
- __name(this, "CreateContacts1710438363002");
8441
+ __name(this, "CreateStatusList1693866470002");
8539
8442
  }
8540
- name = "CreateContacts1710438363002";
8443
+ name = "CreateStatusList1693866470002";
8541
8444
  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`);
8445
+ await queryRunner.query(`CREATE TABLE "StatusListEntry"
8446
+ (
8447
+ "statusListId" varchar NOT NULL,
8448
+ "statusListIndex" integer NOT NULL,
8449
+ "credentialId" varchar,
8450
+ "credentialHash" varchar(128),
8451
+ "correlationId" varchar(255),
8452
+ "value" varchar(50),
8453
+ PRIMARY KEY ("statusListId", "statusListIndex")
8454
+ )`);
8455
+ await queryRunner.query(`CREATE TABLE "StatusList"
8456
+ (
8457
+ "id" varchar PRIMARY KEY NOT NULL,
8458
+ "correlationId" varchar NOT NULL,
8459
+ "length" integer NOT NULL,
8460
+ "issuer" text NOT NULL,
8461
+ "type" varchar CHECK ( "type" IN ('StatusList2021') ) NOT NULL DEFAULT ('StatusList2021'),
8462
+ "driverType" varchar CHECK ( "driverType" IN ('agent_typeorm', 'agent_kv_store', 'github',
8463
+ 'agent_filesystem') ) NOT NULL DEFAULT ('agent_typeorm'),
8464
+ "credentialIdMode" varchar CHECK ( "credentialIdMode" IN ('ISSUANCE', 'PERSISTENCE', 'NEVER') ) NOT NULL DEFAULT ('ISSUANCE'),
8465
+ "proofFormat" varchar CHECK ( "proofFormat" IN ('lds', 'jwt') ) NOT NULL DEFAULT ('lds'),
8466
+ "indexingDirection" varchar CHECK ( "indexingDirection" IN ('rightToLeft') ) NOT NULL DEFAULT ('rightToLeft'),
8467
+ "statusPurpose" varchar NOT NULL DEFAULT ('revocation'),
8468
+ "statusListCredential" text,
8469
+ CONSTRAINT "UQ_correlationId" UNIQUE ("correlationId")
8470
+ )`);
8471
+ await queryRunner.query(`CREATE TABLE "temporary_StatusListEntry"
8472
+ (
8473
+ "statusListId" varchar NOT NULL,
8474
+ "statusListIndex" integer NOT NULL,
8475
+ "credentialId" varchar,
8476
+ "credentialHash" varchar(128),
8477
+ "correlationId" varchar(255),
8478
+ "value" varchar(50),
8479
+ CONSTRAINT "FK_statusListEntry_statusListId" FOREIGN KEY ("statusListId") REFERENCES "StatusList" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION,
8480
+ PRIMARY KEY ("statusListId", "statusListIndex")
8481
+ )`);
8482
+ await queryRunner.query(`INSERT INTO "temporary_StatusListEntry"("statusListId", "statusListIndex", "credentialId",
8483
+ "credentialHash", "correlationId", "value")
8484
+ SELECT "statusListId", "statusListIndex", "credentialId", "credentialHash", "correlationId", "value"
8485
+ FROM "StatusListEntry"`);
8486
+ await queryRunner.query(`DROP TABLE "StatusListEntry"`);
8487
+ await queryRunner.query(`ALTER TABLE "temporary_StatusListEntry" RENAME TO "StatusListEntry"`);
8575
8488
  }
8576
8489
  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"`);
8490
+ await queryRunner.query(`DROP TABLE "StatusListEntry"`);
8491
+ await queryRunner.query(`DROP TABLE "StatusList"`);
8492
+ }
8493
+ };
8494
+
8495
+ // src/migrations/postgres/1737110469001-UpdateStatusList.ts
8496
+ var UpdateStatusList1737110469001 = class {
8497
+ static {
8498
+ __name(this, "UpdateStatusList1737110469001");
8499
+ }
8500
+ name = "UpdateStatusList1737110469001";
8501
+ async up(queryRunner) {
8502
+ await queryRunner.query(`ALTER TYPE "StatusList_type_enum" ADD VALUE 'OAuthStatusList'`);
8503
+ await queryRunner.query(`ALTER TABLE "StatusList" ALTER COLUMN "indexingDirection" DROP NOT NULL`);
8504
+ await queryRunner.query(`ALTER TABLE "StatusList" ALTER COLUMN "statusPurpose" DROP NOT NULL`);
8505
+ await queryRunner.query(`ALTER TABLE "StatusList" ADD "bitsPerStatus" integer DEFAULT 1`);
8506
+ await queryRunner.query(`ALTER TABLE "StatusList" ADD "expiresAt" timestamp with time zone`);
8507
+ }
8508
+ async down(queryRunner) {
8509
+ await queryRunner.query(`ALTER TABLE "StatusList" DROP COLUMN "expiresAt"`);
8510
+ await queryRunner.query(`ALTER TABLE "StatusList" DROP COLUMN "bitsPerStatus"`);
8511
+ await queryRunner.query(`ALTER TABLE "StatusList" ALTER COLUMN "statusPurpose" SET NOT NULL`);
8512
+ await queryRunner.query(`ALTER TABLE "StatusList" ALTER COLUMN "indexingDirection" SET NOT NULL`);
8513
+ }
8514
+ };
8515
+
8516
+ // src/migrations/sqlite/1737110469000-UpdateStatusList.ts
8517
+ var UpdateStatusList1737110469000 = class {
8518
+ static {
8519
+ __name(this, "UpdateStatusList1737110469000");
8520
+ }
8521
+ name = "UpdateStatusList1737110469000";
8522
+ async up(queryRunner) {
8523
+ await queryRunner.query(`CREATE TABLE "temporary_StatusList" (
8524
+ "id" varchar PRIMARY KEY NOT NULL,
8525
+ "correlationId" varchar NOT NULL,
8526
+ "length" integer NOT NULL,
8527
+ "issuer" text NOT NULL,
8528
+ "type" varchar CHECK( "type" IN ('StatusList2021', 'OAuthStatusList') ) NOT NULL DEFAULT ('StatusList2021'),
8529
+ "driverType" varchar CHECK( "driverType" IN ('agent_typeorm','agent_kv_store','github','agent_filesystem') ) NOT NULL DEFAULT ('agent_typeorm'),
8530
+ "credentialIdMode" varchar CHECK( "credentialIdMode" IN ('ISSUANCE','PERSISTENCE','NEVER') ) NOT NULL DEFAULT ('ISSUANCE'),
8531
+ "proofFormat" varchar CHECK( "proofFormat" IN ('lds','jwt') ) NOT NULL DEFAULT ('lds'),
8532
+ "indexingDirection" varchar CHECK( "indexingDirection" IN ('rightToLeft') ),
8533
+ "statusPurpose" varchar,
8534
+ "statusListCredential" text,
8535
+ "bitsPerStatus" integer,
8536
+ "expiresAt" datetime,
8537
+ CONSTRAINT "UQ_correlationId" UNIQUE ("correlationId")
8538
+ )`);
8539
+ await queryRunner.query(`INSERT INTO "temporary_StatusList"(
8540
+ "id", "correlationId", "length", "issuer", "type", "driverType",
8541
+ "credentialIdMode", "proofFormat", "indexingDirection", "statusPurpose",
8542
+ "statusListCredential"
8543
+ )
8544
+ SELECT
8545
+ "id", "correlationId", "length", "issuer", "type", "driverType",
8546
+ "credentialIdMode", "proofFormat", "indexingDirection", "statusPurpose",
8547
+ "statusListCredential"
8548
+ FROM "StatusList"`);
8549
+ await queryRunner.query(`DROP TABLE "StatusList"`);
8550
+ await queryRunner.query(`ALTER TABLE "temporary_StatusList" RENAME TO "StatusList"`);
8551
+ }
8552
+ async down(queryRunner) {
8553
+ await queryRunner.query(`
8554
+ ALTER TABLE "StatusListEntry"
8555
+ RENAME COLUMN "entryCorrelationId" TO "correlationId"
8556
+ `);
8557
+ await queryRunner.query(`
8558
+ ALTER TABLE "StatusListEntry"
8559
+ DROP COLUMN "statusListCorrelationId"
8560
+ `);
8561
+ await queryRunner.query(`CREATE TABLE "temporary_StatusList" (
8562
+ "id" varchar PRIMARY KEY NOT NULL,
8563
+ "correlationId" varchar NOT NULL,
8564
+ "length" integer NOT NULL,
8565
+ "issuer" text NOT NULL,
8566
+ "type" varchar CHECK( "type" IN ('StatusList2021') ) NOT NULL DEFAULT ('StatusList2021'),
8567
+ "driverType" varchar CHECK( "driverType" IN ('agent_typeorm','agent_kv_store','github','agent_filesystem') ) NOT NULL DEFAULT ('agent_typeorm'),
8568
+ "credentialIdMode" varchar CHECK( "credentialIdMode" IN ('ISSUANCE','PERSISTENCE','NEVER') ) NOT NULL DEFAULT ('ISSUANCE'),
8569
+ "proofFormat" varchar CHECK( "proofFormat" IN ('lds','jwt') ) NOT NULL DEFAULT ('lds'),
8570
+ "indexingDirection" varchar CHECK( "indexingDirection" IN ('rightToLeft') ) NOT NULL DEFAULT ('rightToLeft'),
8571
+ "statusPurpose" varchar NOT NULL DEFAULT ('revocation'),
8572
+ "statusListCredential" text,
8573
+ CONSTRAINT "UQ_correlationId" UNIQUE ("correlationId")
8574
+ )`);
8575
+ await queryRunner.query(`INSERT INTO "temporary_StatusList"(
8576
+ "id", "correlationId", "length", "issuer", "type", "driverType",
8577
+ "credentialIdMode", "proofFormat", "indexingDirection", "statusPurpose",
8578
+ "statusListCredential"
8579
+ )
8580
+ SELECT
8581
+ "id", "correlationId", "length", "issuer",
8582
+ CASE WHEN "type" = 'OAuthStatusList' THEN 'StatusList2021' ELSE "type" END,
8583
+ "driverType", "credentialIdMode", "proofFormat", "indexingDirection",
8584
+ COALESCE("statusPurpose", 'revocation'), "statusListCredential"
8585
+ FROM "StatusList"`);
8586
+ await queryRunner.query(`DROP TABLE "StatusList"`);
8587
+ await queryRunner.query(`ALTER TABLE "temporary_StatusList" RENAME TO "StatusList"`);
8595
8588
  }
8596
8589
  };
8597
8590
 
8598
- // src/migrations/generic/8-CreateContacts.ts
8591
+ // src/migrations/generic/4-CreateStatusList.ts
8599
8592
  var debug15 = (0, import_debug15.default)("sphereon:ssi-sdk:migrations");
8600
- var CreateContacts1708525189000 = class {
8593
+ var CreateStatusList1693866470000 = class {
8601
8594
  static {
8602
- __name(this, "CreateContacts1708525189000");
8595
+ __name(this, "CreateStatusList1693866470000");
8603
8596
  }
8604
- name = "CreateContacts1708525189000";
8597
+ name = "CreateStatusList1693866470000";
8605
8598
  async up(queryRunner) {
8606
- debug15("migration: updating contact tables");
8599
+ debug15("migration: creating issuance branding tables");
8607
8600
  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`);
8601
+ if (dbType === "postgres") {
8602
+ debug15("using postgres migration files");
8603
+ const createMig = new CreateStatusList1693866470001();
8604
+ await createMig.up(queryRunner);
8605
+ const updateMig = new UpdateStatusList1737110469001();
8606
+ const up = await updateMig.up(queryRunner);
8607
+ debug15("Migration statements executed");
8608
+ return up;
8609
+ } else if (dbType === "sqlite" || dbType === "react-native" || dbType === "expo") {
8610
+ debug15("using sqlite/react-native migration files");
8611
+ const createMig = new CreateStatusList1693866470002();
8612
+ await createMig.up(queryRunner);
8613
+ const updateMig = new UpdateStatusList1737110469000();
8614
+ const up = await updateMig.up(queryRunner);
8615
+ debug15("Migration statements executed");
8616
+ return up;
8617
+ } else {
8618
+ 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
8619
  }
8628
8620
  }
8629
8621
  async down(queryRunner) {
8630
- debug15("migration: reverting machine state tables");
8622
+ debug15("migration: reverting issuance branding tables");
8631
8623
  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`);
8624
+ if (dbType === "postgres") {
8625
+ debug15("using postgres migration files");
8626
+ const updateMig = new UpdateStatusList1737110469001();
8627
+ await updateMig.down(queryRunner);
8628
+ const createMig = new CreateStatusList1693866470001();
8629
+ const down = await createMig.down(queryRunner);
8630
+ debug15("Migration statements executed");
8631
+ return down;
8632
+ } else if (dbType === "sqlite" || dbType === "react-native" || dbType === "expo") {
8633
+ debug15("using sqlite/react-native migration files");
8634
+ const updateMig = new UpdateStatusList1737110469000();
8635
+ await updateMig.down(queryRunner);
8636
+ const createMig = new CreateStatusList1693866470002();
8637
+ const down = await createMig.down(queryRunner);
8638
+ debug15("Migration statements executed");
8639
+ return down;
8640
+ } else {
8641
+ 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
8642
  }
8652
8643
  }
8653
8644
  };
8654
8645
 
8655
- // src/migrations/generic/9-CreateContacts.ts
8646
+ // src/migrations/generic/5-CreateAuditEvents.ts
8656
8647
  var import_debug16 = __toESM(require("debug"), 1);
8657
8648
 
8658
- // src/migrations/postgres/1715761125001-CreateContacts.ts
8659
- var CreateContacts1715761125001 = class {
8649
+ // src/migrations/sqlite/1701634819487-CreateAuditEvents.ts
8650
+ var CreateAuditEvents1701634819487 = class {
8660
8651
  static {
8661
- __name(this, "CreateContacts1715761125001");
8652
+ __name(this, "CreateAuditEvents1701634819487");
8662
8653
  }
8663
- name = "CreateContacts1715761125001";
8654
+ name = "CreateAuditEvents1701634819487";
8664
8655
  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
- )`);
8656
+ await queryRunner.query(`CREATE TABLE "AuditEvents" (
8657
+ "id" varchar PRIMARY KEY NOT NULL,
8658
+ "eventType" varchar CHECK( "eventType" IN ('audit','activity','general') ) NOT NULL,
8659
+ "timestamp" datetime NOT NULL,
8660
+ "level" varchar CHECK( "level" IN ('0','1','2','3','4') ) NOT NULL,
8661
+ "correlationId" varchar NOT NULL,
8662
+ "system" varchar CHECK( "system" IN ('general','kms','identity','oid4vci','oid4vp','siopv2','PE','credentials','web3','profile','contact') ) NOT NULL,
8663
+ "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,
8664
+ "actionType" varchar CHECK( "actionType" IN ('create','read','update','delete','execute') ) NOT NULL,
8665
+ "actionSubType" varchar NOT NULL,
8666
+ "initiatorType" varchar CHECK( "initiatorType" IN ('user','system','external') ) NOT NULL,
8667
+ "systemCorrelationIdType" varchar CHECK( "systemCorrelationIdType" IN ('did','url','email','hostname','phone','user') ),
8668
+ "systemCorrelationId" varchar,
8669
+ "systemAlias" varchar,
8670
+ "partyCorrelationType" varchar CHECK( "partyCorrelationType" IN ('did','url','email','hostname','phone') ),
8671
+ "partyCorrelationId" varchar,
8672
+ "partyAlias" varchar,
8673
+ "credentialType" varchar CHECK( "credentialType" IN ('JSON_LD','JWT','SD_JWT','MSO_MDOC') ),
8674
+ "credentialHash" varchar,
8675
+ "parentCredentialHash" varchar,
8676
+ "originalCredential" varchar,
8677
+ "sharePurpose" varchar,
8678
+ "description" varchar NOT NULL,
8679
+ "data" varchar,
8680
+ "diagnosticData" varchar,
8681
+ "created_at" datetime NOT NULL DEFAULT (datetime('now')),
8682
+ "last_updated_at" datetime NOT NULL DEFAULT (datetime('now')))`);
8694
8683
  }
8695
8684
  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"`);
8685
+ await queryRunner.query(`DROP TABLE "AuditEvents"`);
8710
8686
  }
8711
8687
  };
8712
8688
 
8713
- // src/migrations/sqlite/1715761125002-CreateContacts.ts
8714
- var CreateContacts1715761125002 = class {
8689
+ // src/migrations/postgres/1701634812183-CreateAuditEvents.ts
8690
+ var CreateAuditEvents1701634812183 = class {
8715
8691
  static {
8716
- __name(this, "CreateContacts1715761125002");
8692
+ __name(this, "CreateAuditEvents1701634812183");
8717
8693
  }
8718
- name = "CreateContacts1715761125002";
8694
+ name = "CreateAuditEvents1701634812183";
8719
8695
  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)`);
8696
+ await queryRunner.query(`CREATE TYPE "public"."Level_enum" AS ENUM('0', '1', '2', '3', '4')`);
8697
+ await queryRunner.query(`CREATE TYPE "public"."System_enum" AS ENUM('general', 'kms', 'identity', 'oid4vci', 'oid4vp', 'siopv2', 'PE', 'credentials', 'web3', 'profile', 'contact')`);
8698
+ 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')`);
8699
+ await queryRunner.query(`CREATE TYPE "public"."Action_type_enum" AS ENUM('create', 'read', 'update', 'delete', 'execute')`);
8700
+ await queryRunner.query(`CREATE TYPE "public"."Initiator_type_enum" AS ENUM('user', 'system', 'external')`);
8701
+ await queryRunner.query(`CREATE TYPE "public"."System_correlation_id_type_enum" AS ENUM('did', 'url', 'email', 'hostname', 'phone', 'user')`);
8702
+ await queryRunner.query(`CREATE TYPE "public"."Party_correlation_type_enum" AS ENUM('did', 'url', 'email', 'hostname', 'phone')`);
8703
+ await queryRunner.query(`CREATE TYPE "public"."Event_type_enum" AS ENUM('audit', 'activity', 'general')`);
8704
+ await queryRunner.query(`CREATE TYPE "public"."Event_credential_type_enum" AS ENUM('JSON_LD', 'JWT', 'SD_JWT', 'MSO_MDOC')`);
8705
+ await queryRunner.query(`CREATE TABLE "AuditEvents" (
8706
+ "id" uuid NOT NULL DEFAULT uuid_generate_v4(),
8707
+ "eventType" "public"."Event_type_enum" NOT NULL,
8708
+ "timestamp" TIMESTAMP NOT NULL,
8709
+ "level" "public"."Level_enum" NOT NULL,
8710
+ "correlationId" TEXT NOT NULL,
8711
+ "system" "public"."System_enum" NOT NULL,
8712
+ "subSystemType" "public"."Subsystem_type_enum" NOT NULL,
8713
+ "actionType" "public"."Action_type_enum" NOT NULL,
8714
+ "actionSubType" TEXT NOT NULL,
8715
+ "initiatorType" "public"."Initiator_type_enum" NOT NULL,
8716
+ "systemCorrelationIdType" "public"."System_correlation_id_type_enum",
8717
+ "systemCorrelationId" TEXT,
8718
+ "systemAlias" TEXT,
8719
+ "partyCorrelationType" "public"."Party_correlation_type_enum",
8720
+ "partyCorrelationId" TEXT,
8721
+ "partyAlias" TEXT,
8722
+ "credentialType" "public"."Event_credential_type_enum",
8723
+ "credentialHash" TEXT,
8724
+ "originalCredential" TEXT,
8725
+ "sharePurpose" TEXT,
8726
+ "description" TEXT NOT NULL,
8727
+ "data" TEXT,
8728
+ "diagnosticData" TEXT,
8729
+ "created_at" TIMESTAMP NOT NULL DEFAULT now(),
8730
+ "last_updated_at" TIMESTAMP NOT NULL DEFAULT now(),
8731
+ CONSTRAINT "PK_AuditEvents_id" PRIMARY KEY ("id"))`);
8748
8732
  }
8749
8733
  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"`);
8734
+ await queryRunner.query(`DROP TABLE "AuditEvents"`);
8735
+ await queryRunner.query(`DROP TYPE "public"."Party_correlation_type_enum"`);
8736
+ await queryRunner.query(`DROP TYPE "public"."System_correlation_id_type_enum"`);
8737
+ await queryRunner.query(`DROP TYPE "public"."Initiator_type_enum"`);
8738
+ await queryRunner.query(`DROP TYPE "public"."Action_type_enum"`);
8739
+ await queryRunner.query(`DROP TYPE "public"."Subsystem_type_enum"`);
8740
+ await queryRunner.query(`DROP TYPE "public"."System_enum"`);
8741
+ await queryRunner.query(`DROP TYPE "public"."Level_enum"`);
8764
8742
  }
8765
8743
  };
8766
8744
 
8767
- // src/migrations/generic/9-CreateContacts.ts
8745
+ // src/migrations/generic/5-CreateAuditEvents.ts
8768
8746
  var debug16 = (0, import_debug16.default)("sphereon:ssi-sdk:migrations");
8769
- var CreateContacts1715761125000 = class {
8747
+ var CreateAuditEvents1701635835330 = class {
8770
8748
  static {
8771
- __name(this, "CreateContacts1715761125000");
8749
+ __name(this, "CreateAuditEvents1701635835330");
8772
8750
  }
8773
- name = "CreateContacts1715761125000";
8751
+ name = "CreateAuditEvents1701635835330";
8774
8752
  async up(queryRunner) {
8775
- debug16("migration: updating contact tables");
8753
+ debug16("migration: creating audit events tables");
8776
8754
  const dbType = queryRunner.connection.driver.options.type;
8777
8755
  switch (dbType) {
8778
8756
  case "postgres": {
8779
8757
  debug16("using postgres migration file");
8780
- const mig = new CreateContacts1715761125001();
8758
+ const mig = new CreateAuditEvents1701634812183();
8781
8759
  await mig.up(queryRunner);
8782
8760
  debug16("Migration statements executed");
8783
8761
  return;
@@ -8786,7 +8764,7 @@ var CreateContacts1715761125000 = class {
8786
8764
  case "expo":
8787
8765
  case "react-native": {
8788
8766
  debug16("using sqlite/react-native migration file");
8789
- const mig = new CreateContacts1715761125002();
8767
+ const mig = new CreateAuditEvents1701634819487();
8790
8768
  await mig.up(queryRunner);
8791
8769
  debug16("Migration statements executed");
8792
8770
  return;
@@ -8796,12 +8774,12 @@ var CreateContacts1715761125000 = class {
8796
8774
  }
8797
8775
  }
8798
8776
  async down(queryRunner) {
8799
- debug16("migration: reverting machine state tables");
8777
+ debug16("migration: reverting audit events tables");
8800
8778
  const dbType = queryRunner.connection.driver.options.type;
8801
8779
  switch (dbType) {
8802
8780
  case "postgres": {
8803
8781
  debug16("using postgres migration file");
8804
- const mig = new CreateContacts1715761125001();
8782
+ const mig = new CreateAuditEvents1701634812183();
8805
8783
  await mig.down(queryRunner);
8806
8784
  debug16("Migration statements executed");
8807
8785
  return;
@@ -8810,7 +8788,7 @@ var CreateContacts1715761125000 = class {
8810
8788
  case "expo":
8811
8789
  case "react-native": {
8812
8790
  debug16("using sqlite/react-native migration file");
8813
- const mig = new CreateContacts1715761125002();
8791
+ const mig = new CreateAuditEvents1701634819487();
8814
8792
  await mig.down(queryRunner);
8815
8793
  debug16("Migration statements executed");
8816
8794
  return;
@@ -8821,85 +8799,258 @@ var CreateContacts1715761125000 = class {
8821
8799
  }
8822
8800
  };
8823
8801
 
8824
- // src/migrations/generic/10-CreatePresentationDefinitions.ts
8802
+ // src/migrations/generic/6-CreateDigitalCredential.ts
8825
8803
  var import_debug17 = __toESM(require("debug"), 1);
8826
8804
 
8827
- // src/migrations/postgres/1716475165345-CreatePresentationDefinitions.ts
8828
- var CreatePresentationDefinitions1716475165345 = class {
8805
+ // src/migrations/postgres/1708525189001-CreateDigitalCredential.ts
8806
+ var CreateDigitalCredential1708525189001 = class {
8829
8807
  static {
8830
- __name(this, "CreatePresentationDefinitions1716475165345");
8808
+ __name(this, "CreateDigitalCredential1708525189001");
8831
8809
  }
8832
- name = "CreatePresentationDefinitions1716475165345";
8810
+ name = "CreateDigitalCredential1708525189001";
8833
8811
  async up(queryRunner) {
8812
+ await queryRunner.query(`CREATE TYPE "digital_document_type" AS ENUM('VC', 'VP', 'C', 'P')`);
8813
+ await queryRunner.query(`CREATE TYPE "digital_regulation_type" AS ENUM('PID', 'QEAA', 'EAA', 'NON_REGULATED')`);
8814
+ await queryRunner.query(`CREATE TYPE "digital_credential_document_format" AS ENUM('JSON_LD', 'JWT', 'SD_JWT', 'MSO_MDOC')`);
8815
+ await queryRunner.query(`CREATE TYPE "digital_credential_credential_role" AS ENUM('ISSUER', 'VERIFIER', 'HOLDER', 'FEDERATION_TRUST_ANCHOR')`);
8816
+ await queryRunner.query(`CREATE TYPE "digital_credential_correlation_type" AS ENUM('DID', 'KID', 'URL', 'X509_SAN')`);
8817
+ await queryRunner.query(`CREATE TYPE "digital_credential_state_type" AS ENUM('REVOKED', 'VERIFIED', 'EXPIRED')`);
8834
8818
  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
- `);
8819
+ CREATE TABLE "DigitalCredential" (
8820
+ "id" uuid NOT NULL DEFAULT uuid_generate_v4(),
8821
+ "parent_id" text,
8822
+ "document_type" "digital_document_type" NOT NULL,
8823
+ "regulation_type" "digital_regulation_type" NOT NULL DEFAULT 'NON_REGULATED'::"digital_regulation_type",
8824
+ "document_format" "digital_credential_document_format" NOT NULL,
8825
+ "credential_role" "digital_credential_credential_role" NOT NULL,
8826
+ "raw_document" text NOT NULL,
8827
+ "uniform_document" text NOT NULL,
8828
+ "credential_id" text,
8829
+ "hash" text NOT NULL,
8830
+ "kms_key_ref" text,
8831
+ "identifier_method" text,
8832
+ "issuer_correlation_type" "digital_credential_correlation_type" NOT NULL,
8833
+ "subject_correlation_type" "digital_credential_correlation_type",
8834
+ "issuer_correlation_id" text NOT NULL,
8835
+ "subject_correlation_id" text,
8836
+ "verified_state" "digital_credential_state_type",
8837
+ "issuer_signed" boolean,
8838
+ "rp_correlation_id" text,
8839
+ "rp_correlation_type" "digital_credential_correlation_type",
8840
+ "tenant_id" text,
8841
+ "created_at" TIMESTAMP NOT NULL DEFAULT now(),
8842
+ "last_updated_at" TIMESTAMP NOT NULL DEFAULT now(),
8843
+ "presented_at" DATE,
8844
+ "valid_from" DATE,
8845
+ "valid_until" DATE,
8846
+ "verified_at" DATE,
8847
+ "revoked_at" DATE,
8848
+ PRIMARY KEY ("id"),
8849
+ UNIQUE ("hash", "credential_role")
8850
+ )
8851
+ `);
8848
8852
  }
8849
8853
  async down(queryRunner) {
8850
- await queryRunner.query(`DROP TABLE "PresentationDefinitionItem"`);
8854
+ await queryRunner.query(`DROP TABLE "DigitalCredential"`);
8855
+ await queryRunner.query(`DROP TYPE "digital_credential_state_type"`);
8856
+ await queryRunner.query(`DROP TYPE "digital_credential_correlation_type"`);
8857
+ await queryRunner.query(`DROP TYPE "digital_credential_document_format"`);
8858
+ await queryRunner.query(`DROP TYPE "digital_credential_credential_role"`);
8859
+ await queryRunner.query(`DROP TYPE "digital_regulation_type"`);
8860
+ await queryRunner.query(`DROP TYPE "digital_document_type"`);
8851
8861
  }
8852
8862
  };
8853
8863
 
8854
- // src/migrations/sqlite/1716475165344-CreatePresentationDefinitions.ts
8855
- var CreatePresentationDefinitions1716475165344 = class {
8864
+ // src/migrations/sqlite/1708525189002-CreateDigitalCredential.ts
8865
+ var CreateDigitalCredential1708525189002 = class {
8856
8866
  static {
8857
- __name(this, "CreatePresentationDefinitions1716475165344");
8867
+ __name(this, "CreateDigitalCredential1708525189002");
8858
8868
  }
8859
- name = "CreatePresentationDefinitions1716475165344";
8869
+ name = "CreateDigitalCredential1708525189002";
8860
8870
  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')))`);
8871
+ await queryRunner.query(`
8872
+ CREATE TABLE "DigitalCredential" (
8873
+ "id" varchar PRIMARY KEY NOT NULL,
8874
+ "parent_id" text,
8875
+ "document_type" varchar CHECK( "document_type" IN ('VC', 'VP', 'C', 'P') ) NOT NULL,
8876
+ "regulation_type" varchar CHECK( "regulation_type" IN ('PID', 'QEAA', 'EAA', 'NON_REGULATED') ) NOT NULL DEFAULT 'NON_REGULATED',
8877
+ "document_format" varchar CHECK( "document_format" IN ('JSON_LD', 'JWT', 'SD_JWT', 'MSO_MDOC') ) NOT NULL,
8878
+ "credential_role" varchar CHECK( "credential_role" IN ('ISSUER', 'VERIFIER', 'HOLDER', 'FEDERATION_TRUST_ANCHOR') ) NOT NULL,
8879
+ "raw_document" text NOT NULL,
8880
+ "uniform_document" text NOT NULL,
8881
+ "credential_id" text,
8882
+ "hash" text NOT NULL,
8883
+ "kms_key_ref" text,
8884
+ "identifier_method" text,
8885
+ "issuer_correlation_type" varchar CHECK( "issuer_correlation_type" IN ('DID', 'KID', 'URL', 'X509_SAN') ) NOT NULL,
8886
+ "subject_correlation_type" varchar CHECK( "subject_correlation_type" IN ('DID', 'KID', 'URL', 'X509_SAN') ),
8887
+ "issuer_correlation_id" text NOT NULL,
8888
+ "subject_correlation_id" text,
8889
+ "issuer_signed" boolean,
8890
+ "rp_correlation_id" text,
8891
+ "rp_correlation_type" varchar CHECK( "issuer_correlation_type" IN ('DID', 'KID', 'URL', 'X509_SAN') ),
8892
+ "verified_state" varchar CHECK( "verified_state" IN ('REVOKED', 'VERIFIED', 'EXPIRED') ),
8893
+ "tenant_id" text,
8894
+ "created_at" datetime NOT NULL DEFAULT (datetime('now')),
8895
+ "last_updated_at" datetime NOT NULL DEFAULT (datetime('now')),
8896
+ "presented_at" datetime,
8897
+ "valid_from" datetime,
8898
+ "valid_until" datetime,
8899
+ "verified_at" datetime,
8900
+ "revoked_at" datetime,
8901
+ UNIQUE ("hash", "credential_role")
8902
+ )
8903
+ `);
8904
+ }
8905
+ async down(queryRunner) {
8906
+ await queryRunner.query(`DROP TABLE "DigitalCredential"`);
8907
+ }
8908
+ };
8909
+
8910
+ // src/migrations/generic/6-CreateDigitalCredential.ts
8911
+ var debug17 = (0, import_debug17.default)("sphereon:ssi-sdk:migrations");
8912
+ var CreateDigitalCredential1708525189000 = class {
8913
+ static {
8914
+ __name(this, "CreateDigitalCredential1708525189000");
8915
+ }
8916
+ name = "CreateDigitalCredential1708525189000";
8917
+ async up(queryRunner) {
8918
+ debug17("migration: creating DigitalCredential tables");
8919
+ const dbType = queryRunner.connection.driver.options.type;
8920
+ switch (dbType) {
8921
+ case "postgres": {
8922
+ debug17("using postgres migration file for DigitalCredential");
8923
+ const mig = new CreateDigitalCredential1708525189001();
8924
+ await mig.up(queryRunner);
8925
+ debug17("Postgres Migration statements for DigitalCredential executed");
8926
+ return;
8927
+ }
8928
+ case "sqlite":
8929
+ case "expo":
8930
+ case "react-native": {
8931
+ debug17("using sqlite/react-native migration file for DigitalCredential");
8932
+ const mig = new CreateDigitalCredential1708525189002();
8933
+ await mig.up(queryRunner);
8934
+ debug17("SQLite Migration statements for DigitalCredential executed");
8935
+ return;
8936
+ }
8937
+ default:
8938
+ 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`);
8939
+ }
8940
+ }
8941
+ async down(queryRunner) {
8942
+ debug17("migration: reverting DigitalCredential tables");
8943
+ const dbType = queryRunner.connection.driver.options.type;
8944
+ switch (dbType) {
8945
+ case "postgres": {
8946
+ debug17("using postgres migration file for DigitalCredential");
8947
+ const mig = new CreateDigitalCredential1708525189001();
8948
+ await mig.down(queryRunner);
8949
+ debug17("Postgres Migration statements for DigitalCredential reverted");
8950
+ return;
8951
+ }
8952
+ case "sqlite":
8953
+ case "expo":
8954
+ case "react-native": {
8955
+ debug17("using sqlite/react-native migration file for DigitalCredential");
8956
+ const mig = new CreateDigitalCredential1708525189002();
8957
+ await mig.down(queryRunner);
8958
+ debug17("SQLite Migration statements for DigitalCredential reverted");
8959
+ return;
8960
+ }
8961
+ default:
8962
+ 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`);
8963
+ }
8964
+ }
8965
+ };
8966
+
8967
+ // src/migrations/generic/7-CreateMachineStateStore.ts
8968
+ var import_debug18 = __toESM(require("debug"), 1);
8969
+
8970
+ // src/migrations/postgres/1708797018115-CreateMachineStateStore.ts
8971
+ var CreateMachineStateStore1708797018115 = class {
8972
+ static {
8973
+ __name(this, "CreateMachineStateStore1708797018115");
8974
+ }
8975
+ name = "CreateMachineStateStore1708797018115";
8976
+ async up(queryRunner) {
8977
+ await queryRunner.query(`
8978
+ CREATE TABLE "MachineStateInfoEntity" (
8979
+ "instance_id" text NOT NULL,
8980
+ "session_id" text,
8981
+ "latest_state_name" text,
8982
+ "machine_name" text NOT NULL,
8983
+ "latest_event_type" text NOT NULL,
8984
+ "state" text NOT NULL,
8985
+ "created_at" TIMESTAMP NOT NULL DEFAULT now(),
8986
+ "updated_at" TIMESTAMP NOT NULL DEFAULT now(),
8987
+ "updated_count" integer NOT NULL DEFAULT 0,
8988
+ "expires_at" TIMESTAMP,
8989
+ "completed_at" TIMESTAMP,
8990
+ "tenant_id" text,
8991
+ CONSTRAINT "PK_MachineStateInfoEntity_id" PRIMARY KEY ("instance_id")
8992
+ )
8993
+ `);
8994
+ }
8995
+ async down(queryRunner) {
8996
+ await queryRunner.query(`DROP TABLE "MachineStateInfoEntity"`);
8997
+ }
8998
+ };
8999
+
9000
+ // src/migrations/sqlite/1708796002272-CreateMachineStateStore.ts
9001
+ var CreateMachineStateStore1708796002272 = class {
9002
+ static {
9003
+ __name(this, "CreateMachineStateStore1708796002272");
9004
+ }
9005
+ name = "CreateMachineStateStore1708796002272";
9006
+ async up(queryRunner) {
9007
+ await queryRunner.query(`
9008
+ CREATE TABLE "MachineStateInfoEntity" (
9009
+ "instance_id" varchar PRIMARY KEY NOT NULL,
9010
+ "session_id" varchar,
9011
+ "machine_name" varchar NOT NULL,
9012
+ "latest_state_name" varchar,
9013
+ "latest_event_type" varchar NOT NULL,
9014
+ "state" text NOT NULL,
9015
+ "created_at" datetime NOT NULL DEFAULT (datetime('now')),
9016
+ "updated_at" datetime NOT NULL DEFAULT (datetime('now')),
9017
+ "updated_count" integer NOT NULL DEFAULT 0,
9018
+ "expires_at" datetime,
9019
+ "completed_at" datetime,
9020
+ "tenant_id" varchar
9021
+ )
9022
+ `);
8872
9023
  }
8873
9024
  async down(queryRunner) {
8874
- await queryRunner.query(`DROP TABLE "PresentationDefinitionItem"`);
9025
+ await queryRunner.query(`DROP TABLE "MachineStateInfoEntity"`);
8875
9026
  }
8876
9027
  };
8877
9028
 
8878
- // src/migrations/generic/10-CreatePresentationDefinitions.ts
8879
- var debug17 = (0, import_debug17.default)("sphereon:ssi-sdk:migrations");
8880
- var CreatePresentationDefinitions1716533767523 = class {
9029
+ // src/migrations/generic/7-CreateMachineStateStore.ts
9030
+ var debug18 = (0, import_debug18.default)("sphereon:ssi-sdk:migrations");
9031
+ var CreateMachineStateStore1708098041262 = class {
8881
9032
  static {
8882
- __name(this, "CreatePresentationDefinitions1716533767523");
9033
+ __name(this, "CreateMachineStateStore1708098041262");
8883
9034
  }
8884
- name = "CreatePresentationDefinitionItems1716533767523";
9035
+ name = "CreateMachineStateStore1708098041262";
8885
9036
  async up(queryRunner) {
8886
- debug17("migration: creating machine state tables");
9037
+ debug18("migration: creating machine state tables");
8887
9038
  const dbType = queryRunner.connection.driver.options.type;
8888
9039
  switch (dbType) {
8889
9040
  case "postgres": {
8890
- debug17("using postgres migration file");
8891
- const mig = new CreatePresentationDefinitions1716475165345();
9041
+ debug18("using postgres migration file");
9042
+ const mig = new CreateMachineStateStore1708797018115();
8892
9043
  await mig.up(queryRunner);
8893
- debug17("Migration statements executed");
9044
+ debug18("Migration statements executed");
8894
9045
  return;
8895
9046
  }
8896
9047
  case "sqlite":
8897
9048
  case "expo":
8898
9049
  case "react-native": {
8899
- debug17("using sqlite/react-native migration file");
8900
- const mig = new CreatePresentationDefinitions1716475165344();
9050
+ debug18("using sqlite/react-native migration file");
9051
+ const mig = new CreateMachineStateStore1708796002272();
8901
9052
  await mig.up(queryRunner);
8902
- debug17("Migration statements executed");
9053
+ debug18("Migration statements executed");
8903
9054
  return;
8904
9055
  }
8905
9056
  default:
@@ -8907,23 +9058,23 @@ var CreatePresentationDefinitions1716533767523 = class {
8907
9058
  }
8908
9059
  }
8909
9060
  async down(queryRunner) {
8910
- debug17("migration: reverting machine state tables");
9061
+ debug18("migration: reverting machine state tables");
8911
9062
  const dbType = queryRunner.connection.driver.options.type;
8912
9063
  switch (dbType) {
8913
9064
  case "postgres": {
8914
- debug17("using postgres migration file");
8915
- const mig = new CreatePresentationDefinitions1716475165345();
9065
+ debug18("using postgres migration file");
9066
+ const mig = new CreateMachineStateStore1708797018115();
8916
9067
  await mig.down(queryRunner);
8917
- debug17("Migration statements executed");
9068
+ debug18("Migration statements executed");
8918
9069
  return;
8919
9070
  }
8920
9071
  case "sqlite":
8921
9072
  case "expo":
8922
9073
  case "react-native": {
8923
- debug17("using sqlite/react-native migration file");
8924
- const mig = new CreatePresentationDefinitions1716475165344();
9074
+ debug18("using sqlite/react-native migration file");
9075
+ const mig = new CreateMachineStateStore1708796002272();
8925
9076
  await mig.down(queryRunner);
8926
- debug17("Migration statements executed");
9077
+ debug18("Migration statements executed");
8927
9078
  return;
8928
9079
  }
8929
9080
  default:
@@ -8932,108 +9083,145 @@ var CreatePresentationDefinitions1716533767523 = class {
8932
9083
  }
8933
9084
  };
8934
9085
 
8935
- // src/migrations/generic/11-FixCredentialClaimsReferenceUuid.ts
8936
- var import_debug18 = __toESM(require("debug"), 1);
9086
+ // src/migrations/generic/8-CreateContacts.ts
9087
+ var import_debug19 = __toESM(require("debug"), 1);
8937
9088
 
8938
- // src/migrations/postgres/1741895822987-FixCredentialClaimsReferencesUuid.ts
8939
- var FixCredentialClaimsReferencesUuidPG1741895822987 = class {
9089
+ // src/migrations/postgres/1710438363001-CreateContacts.ts
9090
+ var CreateContacts1710438363001 = class {
8940
9091
  static {
8941
- __name(this, "FixCredentialClaimsReferencesUuidPG1741895822987");
9092
+ __name(this, "CreateContacts1710438363001");
8942
9093
  }
8943
- name = "FixCredentialClaimsReferencesUuid1741895822987";
9094
+ name = "CreateContacts1710438363001";
8944
9095
  async up(queryRunner) {
8945
- await queryRunner.query(`
8946
- ALTER TABLE "CredentialClaims"
8947
- ALTER COLUMN "credentialLocaleBrandingId" TYPE uuid USING "credentialLocaleBrandingId"::uuid;
8948
- `);
9096
+ await queryRunner.query(`ALTER TABLE "Party" ADD COLUMN "owner_id" uuid`);
9097
+ await queryRunner.query(`ALTER TABLE "Party" ADD COLUMN "tenant_id" uuid`);
9098
+ await queryRunner.query(`ALTER TABLE "Identity" ADD COLUMN "owner_id" uuid`);
9099
+ await queryRunner.query(`ALTER TABLE "Identity" ADD COLUMN "tenant_id" uuid`);
9100
+ await queryRunner.query(`ALTER TABLE "CorrelationIdentifier" ADD COLUMN "owner_id" uuid`);
9101
+ await queryRunner.query(`ALTER TABLE "CorrelationIdentifier" ADD COLUMN "tenant_id" uuid`);
9102
+ await queryRunner.query(`ALTER TABLE "Connection" ADD COLUMN "owner_id" uuid`);
9103
+ await queryRunner.query(`ALTER TABLE "Connection" ADD COLUMN "tenant_id" uuid`);
9104
+ await queryRunner.query(`ALTER TABLE "BaseConfig" ADD COLUMN "owner_id" uuid`);
9105
+ await queryRunner.query(`ALTER TABLE "BaseConfig" ADD COLUMN "tenant_id" uuid`);
9106
+ await queryRunner.query(`ALTER TABLE "BaseContact" ADD COLUMN "owner_id" uuid`);
9107
+ await queryRunner.query(`ALTER TABLE "BaseContact" ADD COLUMN "tenant_id" uuid`);
9108
+ await queryRunner.query(`ALTER TABLE "PartyRelationship" ADD COLUMN "owner_id" uuid`);
9109
+ await queryRunner.query(`ALTER TABLE "PartyRelationship" ADD COLUMN "tenant_id" uuid`);
9110
+ await queryRunner.query(`ALTER TABLE "ElectronicAddress" ADD COLUMN "owner_id" uuid`);
9111
+ await queryRunner.query(`ALTER TABLE "ElectronicAddress" ADD COLUMN "tenant_id" uuid`);
9112
+ await queryRunner.query(`ALTER TABLE "PhysicalAddress" ADD COLUMN "owner_id" uuid`);
9113
+ await queryRunner.query(`ALTER TABLE "PhysicalAddress" ADD COLUMN "tenant_id" uuid`);
8949
9114
  }
8950
9115
  async down(queryRunner) {
8951
- await queryRunner.query(`
8952
- ALTER TABLE "CredentialClaims"
8953
- ALTER COLUMN "credentialLocaleBrandingId" TYPE character varying USING "credentialLocaleBrandingId"::text;
8954
- `);
9116
+ await queryRunner.query(`ALTER TABLE "PhysicalAddress" DROP COLUMN "tenant_id"`);
9117
+ await queryRunner.query(`ALTER TABLE "PhysicalAddress" DROP COLUMN "owner_id"`);
9118
+ await queryRunner.query(`ALTER TABLE "ElectronicAddress" DROP COLUMN "tenant_id"`);
9119
+ await queryRunner.query(`ALTER TABLE "ElectronicAddress" DROP COLUMN "owner_id"`);
9120
+ await queryRunner.query(`ALTER TABLE "PartyRelationship" DROP COLUMN "tenant_id"`);
9121
+ await queryRunner.query(`ALTER TABLE "PartyRelationship" DROP COLUMN "owner_id"`);
9122
+ await queryRunner.query(`ALTER TABLE "BaseContact" DROP COLUMN "tenant_id"`);
9123
+ await queryRunner.query(`ALTER TABLE "BaseContact" DROP COLUMN "owner_id"`);
9124
+ await queryRunner.query(`ALTER TABLE "BaseConfig" DROP COLUMN "tenant_id"`);
9125
+ await queryRunner.query(`ALTER TABLE "BaseConfig" DROP COLUMN "owner_id"`);
9126
+ await queryRunner.query(`ALTER TABLE "Connection" DROP COLUMN "tenant_id"`);
9127
+ await queryRunner.query(`ALTER TABLE "Connection" DROP COLUMN "owner_id"`);
9128
+ await queryRunner.query(`ALTER TABLE "CorrelationIdentifier" DROP COLUMN "tenant_id"`);
9129
+ await queryRunner.query(`ALTER TABLE "CorrelationIdentifier" DROP COLUMN "owner_id"`);
9130
+ await queryRunner.query(`ALTER TABLE "Identity" DROP COLUMN "tenant_id"`);
9131
+ await queryRunner.query(`ALTER TABLE "Identity" DROP COLUMN "owner_id"`);
9132
+ await queryRunner.query(`ALTER TABLE "Party" DROP COLUMN "tenant_id"`);
9133
+ await queryRunner.query(`ALTER TABLE "Party" DROP COLUMN "owner_id"`);
8955
9134
  }
8956
9135
  };
8957
9136
 
8958
- // src/migrations/sqlite/1741895822987-FixCredentialClaimsReferencesUuid.ts
8959
- var FixCredentialClaimsReferencesUuidSqlite1741895822987 = class {
9137
+ // src/migrations/sqlite/1710438363002-CreateContacts.ts
9138
+ var CreateContacts1710438363002 = class {
8960
9139
  static {
8961
- __name(this, "FixCredentialClaimsReferencesUuidSqlite1741895822987");
9140
+ __name(this, "CreateContacts1710438363002");
8962
9141
  }
8963
- name = "FixCredentialClaimsReferencesUuid1741895822987";
9142
+ name = "CreateContacts1710438363002";
8964
9143
  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
- `);
9144
+ await queryRunner.query(`ALTER TABLE "Party" ADD COLUMN "owner_id" text`);
9145
+ await queryRunner.query(`ALTER TABLE "Party" ADD COLUMN "tenant_id" text`);
9146
+ await queryRunner.query(`CREATE TABLE "temporary_Identity" (
9147
+ "id" varchar PRIMARY KEY NOT NULL,
9148
+ "alias" varchar(255) NOT NULL,
9149
+ "roles" text NOT NULL,
9150
+ "origin" text NOT NULL,
9151
+ "created_at" datetime NOT NULL DEFAULT (datetime('now')),
9152
+ "last_updated_at" datetime NOT NULL DEFAULT (datetime('now')),
9153
+ "partyId" varchar,
9154
+ "owner_id" text,
9155
+ "tenant_id" text,
9156
+ CONSTRAINT "UQ_Identity_alias" UNIQUE ("alias"),
9157
+ CONSTRAINT "FK_Identity_partyId" FOREIGN KEY ("partyId") REFERENCES "Party" ("id") ON DELETE CASCADE ON UPDATE NO ACTION
9158
+ )`);
9159
+ await queryRunner.query(`INSERT INTO "temporary_Identity"("id", "alias", "roles", "created_at", "last_updated_at", "partyId", "owner_id", "tenant_id", "origin")
9160
+ SELECT "id", "alias", "roles", 'EXTERNAL' as "origin", "created_at", "last_updated_at", "partyId", NULL as "owner_id", NULL as "tenant_id" FROM "Identity"`);
9161
+ await queryRunner.query(`DROP TABLE "Identity"`);
9162
+ await queryRunner.query(`ALTER TABLE "temporary_Identity" RENAME TO "Identity"`);
9163
+ await queryRunner.query(`ALTER TABLE "CorrelationIdentifier" ADD COLUMN "owner_id" text`);
9164
+ await queryRunner.query(`ALTER TABLE "CorrelationIdentifier" ADD COLUMN "tenant_id" text`);
9165
+ await queryRunner.query(`ALTER TABLE "Connection" ADD COLUMN "owner_id" text`);
9166
+ await queryRunner.query(`ALTER TABLE "Connection" ADD COLUMN "tenant_id" text`);
9167
+ await queryRunner.query(`ALTER TABLE "BaseConfig" ADD COLUMN "owner_id" text`);
9168
+ await queryRunner.query(`ALTER TABLE "BaseConfig" ADD COLUMN "tenant_id" text`);
9169
+ await queryRunner.query(`ALTER TABLE "BaseContact" ADD COLUMN "owner_id" text`);
9170
+ await queryRunner.query(`ALTER TABLE "BaseContact" ADD COLUMN "tenant_id" text`);
9171
+ await queryRunner.query(`ALTER TABLE "PartyRelationship" ADD COLUMN "owner_id" text`);
9172
+ await queryRunner.query(`ALTER TABLE "PartyRelationship" ADD COLUMN "tenant_id" text`);
9173
+ await queryRunner.query(`ALTER TABLE "ElectronicAddress" ADD COLUMN "owner_id" text`);
9174
+ await queryRunner.query(`ALTER TABLE "ElectronicAddress" ADD COLUMN "tenant_id" text`);
9175
+ await queryRunner.query(`ALTER TABLE "PhysicalAddress" ADD COLUMN "owner_id" text`);
9176
+ await queryRunner.query(`ALTER TABLE "PhysicalAddress" ADD COLUMN "tenant_id" text`);
8986
9177
  }
8987
9178
  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
- `);
9179
+ await queryRunner.query(`ALTER TABLE "PhysicalAddress" DROP COLUMN "tenant_id"`);
9180
+ await queryRunner.query(`ALTER TABLE "PhysicalAddress" DROP COLUMN "owner_id"`);
9181
+ await queryRunner.query(`ALTER TABLE "ElectronicAddress" DROP COLUMN "tenant_id"`);
9182
+ await queryRunner.query(`ALTER TABLE "ElectronicAddress" DROP COLUMN "owner_id"`);
9183
+ await queryRunner.query(`ALTER TABLE "PartyRelationship" DROP COLUMN "tenant_id"`);
9184
+ await queryRunner.query(`ALTER TABLE "PartyRelationship" DROP COLUMN "owner_id"`);
9185
+ await queryRunner.query(`ALTER TABLE "BaseContact" DROP COLUMN "tenant_id"`);
9186
+ await queryRunner.query(`ALTER TABLE "BaseContact" DROP COLUMN "owner_id"`);
9187
+ await queryRunner.query(`ALTER TABLE "BaseConfig" DROP COLUMN "tenant_id"`);
9188
+ await queryRunner.query(`ALTER TABLE "BaseConfig" DROP COLUMN "owner_id"`);
9189
+ await queryRunner.query(`ALTER TABLE "Connection" DROP COLUMN "tenant_id"`);
9190
+ await queryRunner.query(`ALTER TABLE "Connection" DROP COLUMN "owner_id"`);
9191
+ await queryRunner.query(`ALTER TABLE "CorrelationIdentifier" DROP COLUMN "tenant_id"`);
9192
+ await queryRunner.query(`ALTER TABLE "CorrelationIdentifier" DROP COLUMN "owner_id"`);
9193
+ await queryRunner.query(`ALTER TABLE "Identity" DROP COLUMN "tenant_id"`);
9194
+ await queryRunner.query(`ALTER TABLE "Identity" DROP COLUMN "owner_id"`);
9195
+ await queryRunner.query(`ALTER TABLE "Party" DROP COLUMN "tenant_id"`);
9196
+ await queryRunner.query(`ALTER TABLE "Party" DROP COLUMN "owner_id"`);
9009
9197
  }
9010
9198
  };
9011
9199
 
9012
- // src/migrations/generic/11-FixCredentialClaimsReferenceUuid.ts
9013
- var debug18 = (0, import_debug18.default)("sphereon:ssi-sdk:migrations");
9014
- var FixCredentialClaimsReferencesUuid1741895822987 = class {
9200
+ // src/migrations/generic/8-CreateContacts.ts
9201
+ var debug19 = (0, import_debug19.default)("sphereon:ssi-sdk:migrations");
9202
+ var CreateContacts1708525189000 = class {
9015
9203
  static {
9016
- __name(this, "FixCredentialClaimsReferencesUuid1741895822987");
9204
+ __name(this, "CreateContacts1708525189000");
9017
9205
  }
9018
- name = "FixCredentialClaimsReferenceUuid1741895822987";
9206
+ name = "CreateContacts1708525189000";
9019
9207
  async up(queryRunner) {
9020
- debug18("migration: creating issuance branding uuid problem");
9208
+ debug19("migration: updating contact tables");
9021
9209
  const dbType = queryRunner.connection.driver.options.type;
9022
9210
  switch (dbType) {
9023
9211
  case "postgres": {
9024
- debug18("using postgres migration file");
9025
- const mig = new FixCredentialClaimsReferencesUuidPG1741895822987();
9212
+ debug19("using postgres migration file");
9213
+ const mig = new CreateContacts1710438363001();
9026
9214
  await mig.up(queryRunner);
9027
- debug18("Migration statements executed");
9215
+ debug19("Migration statements executed");
9028
9216
  return;
9029
9217
  }
9030
9218
  case "sqlite":
9031
9219
  case "expo":
9032
9220
  case "react-native": {
9033
- debug18("using sqlite/react-native migration file");
9034
- const mig = new FixCredentialClaimsReferencesUuidSqlite1741895822987();
9221
+ debug19("using sqlite/react-native migration file");
9222
+ const mig = new CreateContacts1710438363002();
9035
9223
  await mig.up(queryRunner);
9036
- debug18("Migration statements executed");
9224
+ debug19("Migration statements executed");
9037
9225
  return;
9038
9226
  }
9039
9227
  default:
@@ -9041,23 +9229,23 @@ var FixCredentialClaimsReferencesUuid1741895822987 = class {
9041
9229
  }
9042
9230
  }
9043
9231
  async down(queryRunner) {
9044
- debug18("migration: reverting issuance branding uuid migration");
9232
+ debug19("migration: reverting machine state tables");
9045
9233
  const dbType = queryRunner.connection.driver.options.type;
9046
9234
  switch (dbType) {
9047
9235
  case "postgres": {
9048
- debug18("using postgres migration file");
9049
- const mig = new CreateIssuanceBranding1685628974232();
9236
+ debug19("using postgres migration file");
9237
+ const mig = new CreateContacts1710438363001();
9050
9238
  await mig.down(queryRunner);
9051
- debug18("Migration statements executed");
9239
+ debug19("Migration statements executed");
9052
9240
  return;
9053
9241
  }
9054
9242
  case "sqlite":
9055
9243
  case "expo":
9056
9244
  case "react-native": {
9057
- debug18("using sqlite/react-native migration file");
9058
- const mig = new CreateIssuanceBranding1685628973231();
9245
+ debug19("using sqlite/react-native migration file");
9246
+ const mig = new CreateContacts1710438363002();
9059
9247
  await mig.down(queryRunner);
9060
- debug18("Migration statements executed");
9248
+ debug19("Migration statements executed");
9061
9249
  return;
9062
9250
  }
9063
9251
  default:
@@ -9066,222 +9254,171 @@ var FixCredentialClaimsReferencesUuid1741895822987 = class {
9066
9254
  }
9067
9255
  };
9068
9256
 
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'))`);
9257
+ // src/migrations/generic/9-CreateContacts.ts
9258
+ var import_debug20 = __toESM(require("debug"), 1);
9259
+
9260
+ // src/migrations/postgres/1715761125001-CreateContacts.ts
9261
+ var CreateContacts1715761125001 = class {
9262
+ static {
9263
+ __name(this, "CreateContacts1715761125001");
9264
+ }
9265
+ name = "CreateContacts1715761125001";
9266
+ async up(queryRunner) {
9267
+ await queryRunner.query(`ALTER TABLE "IdentityMetadata" RENAME TO "temporary_IdentityMetadata"`);
9268
+ await queryRunner.query(`CREATE TABLE "IdentityMetadata"
9269
+ (
9270
+ "id" uuid PRIMARY KEY NOT NULL DEFAULT uuid_generate_v4(),
9271
+ "label" character varying(255) NOT NULL,
9272
+ "valueType" character varying NOT NULL,
9273
+ "stringValue" text,
9274
+ "numberValue" double precision,
9275
+ "dateValue" TIMESTAMP,
9276
+ "boolValue" boolean,
9277
+ "identityId" uuid,
9278
+ CONSTRAINT "FK_Identity_IdentityMetadata" FOREIGN KEY ("identityId") REFERENCES "Identity" ("id") ON DELETE CASCADE
9279
+ )`);
9280
+ await queryRunner.query(`INSERT INTO "IdentityMetadata" ("id", "label", "valueType", "stringValue", "identityId")
9281
+ SELECT "id", "label", 'string', "value", "identityId"
9282
+ FROM "temporary_IdentityMetadata"`);
9283
+ await queryRunner.query(`DROP TABLE "temporary_IdentityMetadata"`);
9284
+ await queryRunner.query(`CREATE TABLE "ContactMetadata"
9285
+ (
9286
+ "id" uuid PRIMARY KEY NOT NULL DEFAULT uuid_generate_v4(),
9287
+ "label" character varying(255) NOT NULL,
9288
+ "valueType" character varying NOT NULL,
9289
+ "stringValue" text,
9290
+ "numberValue" double precision,
9291
+ "dateValue" TIMESTAMP,
9292
+ "boolValue" boolean,
9293
+ "contactId" uuid,
9294
+ CONSTRAINT "FK_BaseContact_ContactMetadata" FOREIGN KEY ("contactId") REFERENCES "BaseContact" ("id") ON DELETE CASCADE
9295
+ )`);
9091
9296
  }
9092
9297
  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"`);
9298
+ await queryRunner.query(`DROP TABLE "ContactMetadata"`);
9299
+ await queryRunner.query(`ALTER TABLE "IdentityMetadata" RENAME TO "temporary_IdentityMetadata"`);
9300
+ await queryRunner.query(`CREATE TABLE "IdentityMetadata"
9301
+ (
9302
+ "id" uuid PRIMARY KEY NOT NULL DEFAULT uuid_generate_v4(),
9303
+ "label" character varying(255) NOT NULL,
9304
+ "value" character varying(255) NOT NULL,
9305
+ "identityId" uuid,
9306
+ CONSTRAINT "FK_Identity_IdentityMetadata" FOREIGN KEY ("identityId") REFERENCES "Identity" ("id") ON DELETE CASCADE
9307
+ )`);
9308
+ await queryRunner.query(`INSERT INTO "IdentityMetadata" ("id", "label", "value", "identityId")
9309
+ SELECT "id", "label", "stringValue", "identityId"
9310
+ FROM "temporary_IdentityMetadata"`);
9311
+ await queryRunner.query(`DROP TABLE "temporary_IdentityMetadata"`);
9105
9312
  }
9106
9313
  };
9107
9314
 
9108
- // src/migrations/sqlite/1741895823001-CreateBitstringStatusList.ts
9109
- var CreateBitstringStatusListSqlite1741895823001 = class {
9315
+ // src/migrations/sqlite/1715761125002-CreateContacts.ts
9316
+ var CreateContacts1715761125002 = class {
9110
9317
  static {
9111
- __name(this, "CreateBitstringStatusListSqlite1741895823001");
9318
+ __name(this, "CreateContacts1715761125002");
9112
9319
  }
9113
- name = "CreateBitstringStatusList1741895823000";
9320
+ name = "CreateContacts1715761125002";
9114
9321
  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"`);
9322
+ await queryRunner.query(`ALTER TABLE "IdentityMetadata" RENAME TO "temporary_IdentityMetadata"`);
9323
+ await queryRunner.query(`CREATE TABLE "IdentityMetadata"
9324
+ (
9325
+ "id" varchar PRIMARY KEY NOT NULL,
9326
+ "label" varchar(255) NOT NULL,
9327
+ "valueType" varchar NOT NULL,
9328
+ "stringValue" varchar(255),
9329
+ "numberValue" double,
9330
+ "dateValue" datetime,
9331
+ "boolValue" boolean,
9332
+ "identityId" varchar,
9333
+ FOREIGN KEY ("identityId") REFERENCES "Identity" ("id") ON DELETE CASCADE)`);
9334
+ await queryRunner.query(`INSERT INTO "IdentityMetadata" ("id", "label", "valueType", "stringValue", "identityId")
9335
+ SELECT "id", "label", 'string', "value", "identityId"
9336
+ FROM "temporary_IdentityMetadata"
9337
+ `);
9338
+ await queryRunner.query(`DROP TABLE "temporary_IdentityMetadata"`);
9339
+ await queryRunner.query(`CREATE TABLE "ContactMetadata"
9340
+ (
9341
+ "id" varchar PRIMARY KEY NOT NULL,
9342
+ "label" varchar(255) NOT NULL,
9343
+ "valueType" varchar NOT NULL,
9344
+ "stringValue" text,
9345
+ "numberValue" double,
9346
+ "dateValue" datetime,
9347
+ "boolValue" boolean,
9348
+ "contactId" varchar,
9349
+ FOREIGN KEY ("contactId") REFERENCES "BaseContact" ("id") ON DELETE CASCADE)`);
9178
9350
  }
9179
9351
  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"`);
9352
+ await queryRunner.query(`DROP TABLE "ContactMetadata"`);
9353
+ await queryRunner.query(`ALTER TABLE "IdentityMetadata" RENAME TO "temporary_IdentityMetadata"`);
9354
+ await queryRunner.query(`CREATE TABLE "IdentityMetadata"
9355
+ (
9356
+ "id" varchar PRIMARY KEY NOT NULL,
9357
+ "label" varchar(255) NOT NULL,
9358
+ "value" varchar(255) NOT NULL,
9359
+ "identityId" varchar,
9360
+ FOREIGN KEY ("identityId") REFERENCES "Identity" ("id") ON DELETE CASCADE
9361
+ )`);
9362
+ await queryRunner.query(`INSERT INTO "IdentityMetadata" ("id", "label", "value", "identityId")
9363
+ SELECT "id", "label", "stringValue", "identityId"
9364
+ FROM "temporary_IdentityMetadata"`);
9365
+ await queryRunner.query(`DROP TABLE "temporary_IdentityMetadata"`);
9237
9366
  }
9238
9367
  };
9239
9368
 
9240
- // src/migrations/generic/12-CreateBitstringStatusList.ts
9241
- var debug19 = (0, import_debug19.default)("sphereon:ssi-sdk:migrations");
9242
- var CreateBitstringStatusList1741895823000 = class {
9369
+ // src/migrations/generic/9-CreateContacts.ts
9370
+ var debug20 = (0, import_debug20.default)("sphereon:ssi-sdk:migrations");
9371
+ var CreateContacts1715761125000 = class {
9243
9372
  static {
9244
- __name(this, "CreateBitstringStatusList1741895823000");
9373
+ __name(this, "CreateContacts1715761125000");
9245
9374
  }
9246
- name = "CreateBitstringStatusList1741895823000";
9375
+ name = "CreateContacts1715761125000";
9247
9376
  async up(queryRunner) {
9248
- debug19("migration: creating bitstring status list tables");
9377
+ debug20("migration: updating contact tables");
9249
9378
  const dbType = queryRunner.connection.driver.options.type;
9250
9379
  switch (dbType) {
9251
9380
  case "postgres": {
9252
- const mig = new CreateBitstringStatusListPG1741895823000();
9381
+ debug20("using postgres migration file");
9382
+ const mig = new CreateContacts1715761125001();
9253
9383
  await mig.up(queryRunner);
9384
+ debug20("Migration statements executed");
9254
9385
  return;
9255
9386
  }
9256
9387
  case "sqlite":
9257
9388
  case "expo":
9258
9389
  case "react-native": {
9259
- const mig = new CreateBitstringStatusListSqlite1741895823001();
9390
+ debug20("using sqlite/react-native migration file");
9391
+ const mig = new CreateContacts1715761125002();
9260
9392
  await mig.up(queryRunner);
9393
+ debug20("Migration statements executed");
9261
9394
  return;
9262
9395
  }
9263
9396
  default:
9264
- return Promise.reject(`Migrations only supported for sqlite and postgres. Was ${dbType}`);
9397
+ 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
9398
  }
9266
9399
  }
9267
9400
  async down(queryRunner) {
9268
- debug19("migration: dropping bitstring status list tables");
9401
+ debug20("migration: reverting machine state tables");
9269
9402
  const dbType = queryRunner.connection.driver.options.type;
9270
9403
  switch (dbType) {
9271
9404
  case "postgres": {
9272
- const mig = new CreateBitstringStatusListPG1741895823000();
9405
+ debug20("using postgres migration file");
9406
+ const mig = new CreateContacts1715761125001();
9273
9407
  await mig.down(queryRunner);
9408
+ debug20("Migration statements executed");
9274
9409
  return;
9275
9410
  }
9276
9411
  case "sqlite":
9277
9412
  case "expo":
9278
9413
  case "react-native": {
9279
- const mig = new CreateBitstringStatusListSqlite1741895823001();
9414
+ debug20("using sqlite/react-native migration file");
9415
+ const mig = new CreateContacts1715761125002();
9280
9416
  await mig.down(queryRunner);
9417
+ debug20("Migration statements executed");
9281
9418
  return;
9282
9419
  }
9283
9420
  default:
9284
- return Promise.reject(`Migrations only supported for sqlite and postgres. Was ${dbType}`);
9421
+ 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
9422
  }
9286
9423
  }
9287
9424
  };
@@ -9299,6 +9436,7 @@ var DataStoreIssuanceBrandingMigrations = [
9299
9436
  ];
9300
9437
  var DataStoreStatusListMigrations = [
9301
9438
  CreateStatusList1693866470000,
9439
+ AddBitstringStatusListEnum1741895823000,
9302
9440
  CreateBitstringStatusList1741895823000
9303
9441
  ];
9304
9442
  var DataStoreEventLoggerMigrations = [
@@ -9311,7 +9449,8 @@ var DataStoreMachineStateMigrations = [
9311
9449
  CreateMachineStateStore1708098041262
9312
9450
  ];
9313
9451
  var DataStorePresentationDefinitionMigrations = [
9314
- CreatePresentationDefinitions1716533767523
9452
+ CreatePresentationDefinitions1716533767523,
9453
+ CreateDcqlQueryItem1726617600000
9315
9454
  ];
9316
9455
  var DataStoreMigrations = [
9317
9456
  ...DataStoreContactMigrations,
@@ -9324,7 +9463,7 @@ var DataStoreMigrations = [
9324
9463
  ];
9325
9464
 
9326
9465
  // src/utils/digitalCredential/MappingUtils.ts
9327
- var import_ssi_types7 = require("@sphereon/ssi-types");
9466
+ var import_ssi_types9 = require("@sphereon/ssi-types");
9328
9467
  var import_utils = require("@veramo/utils");
9329
9468
  var import_ssi_sdk23 = require("@sphereon/ssi-sdk.core");
9330
9469
  function determineDocumentType(raw) {
@@ -9332,11 +9471,11 @@ function determineDocumentType(raw) {
9332
9471
  if (!rawDocument) {
9333
9472
  throw new Error(`Couldn't parse the credential: ${raw}`);
9334
9473
  }
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);
9474
+ const hasProof = import_ssi_types9.CredentialMapper.hasProof(rawDocument);
9475
+ const isCredential = isHex(raw) || import_ssi_types9.ObjectUtils.isBase64(raw) || import_ssi_types9.CredentialMapper.isCredential(rawDocument);
9476
+ const isPresentation = import_ssi_types9.CredentialMapper.isPresentation(rawDocument);
9338
9477
  if (isCredential) {
9339
- return hasProof || isHex(raw) || import_ssi_types7.ObjectUtils.isBase64(raw) ? DocumentType.VC : DocumentType.C;
9478
+ return hasProof || isHex(raw) || import_ssi_types9.ObjectUtils.isBase64(raw) ? DocumentType.VC : DocumentType.C;
9340
9479
  } else if (isPresentation) {
9341
9480
  return hasProof ? DocumentType.VP : DocumentType.P;
9342
9481
  }
@@ -9348,9 +9487,9 @@ function isHex(input) {
9348
9487
  }
9349
9488
  __name(isHex, "isHex");
9350
9489
  function parseRawDocument(raw) {
9351
- if (isHex(raw) || import_ssi_types7.ObjectUtils.isBase64(raw)) {
9490
+ if (isHex(raw) || import_ssi_types9.ObjectUtils.isBase64(raw)) {
9352
9491
  return raw;
9353
- } else if (import_ssi_types7.CredentialMapper.isJwtEncoded(raw) || import_ssi_types7.CredentialMapper.isSdJwtEncoded(raw)) {
9492
+ } else if (import_ssi_types9.CredentialMapper.isJwtEncoded(raw) || import_ssi_types9.CredentialMapper.isSdJwtEncoded(raw)) {
9354
9493
  return raw;
9355
9494
  }
9356
9495
  try {
@@ -9362,9 +9501,9 @@ function parseRawDocument(raw) {
9362
9501
  __name(parseRawDocument, "parseRawDocument");
9363
9502
  function ensureRawDocument(input) {
9364
9503
  if (typeof input === "string") {
9365
- if (isHex(input) || import_ssi_types7.ObjectUtils.isBase64(input)) {
9504
+ if (isHex(input) || import_ssi_types9.ObjectUtils.isBase64(input)) {
9366
9505
  return input;
9367
- } else if (import_ssi_types7.CredentialMapper.isJwtEncoded(input) || import_ssi_types7.CredentialMapper.isSdJwtEncoded(input)) {
9506
+ } else if (import_ssi_types9.CredentialMapper.isJwtEncoded(input) || import_ssi_types9.CredentialMapper.isSdJwtEncoded(input)) {
9368
9507
  return input;
9369
9508
  }
9370
9509
  throw Error("Unknown input to be mapped as rawDocument");
@@ -9378,13 +9517,13 @@ function ensureRawDocument(input) {
9378
9517
  __name(ensureRawDocument, "ensureRawDocument");
9379
9518
  function determineCredentialDocumentFormat(documentFormat) {
9380
9519
  switch (documentFormat) {
9381
- case import_ssi_types7.DocumentFormat.JSONLD:
9520
+ case import_ssi_types9.DocumentFormat.JSONLD:
9382
9521
  return CredentialDocumentFormat.JSON_LD;
9383
- case import_ssi_types7.DocumentFormat.JWT:
9522
+ case import_ssi_types9.DocumentFormat.JWT:
9384
9523
  return CredentialDocumentFormat.JWT;
9385
- case import_ssi_types7.DocumentFormat.SD_JWT_VC:
9524
+ case import_ssi_types9.DocumentFormat.SD_JWT_VC:
9386
9525
  return CredentialDocumentFormat.SD_JWT;
9387
- case import_ssi_types7.DocumentFormat.MSO_MDOC:
9526
+ case import_ssi_types9.DocumentFormat.MSO_MDOC:
9388
9527
  return CredentialDocumentFormat.MSO_MDOC;
9389
9528
  default:
9390
9529
  throw new Error(`Not supported document format: ${documentFormat}`);
@@ -9423,14 +9562,14 @@ var safeStringify = /* @__PURE__ */ __name((object) => {
9423
9562
  }, "safeStringify");
9424
9563
  var nonPersistedDigitalCredentialEntityFromAddArgs = /* @__PURE__ */ __name((addCredentialArgs) => {
9425
9564
  const documentType = determineDocumentType(addCredentialArgs.rawDocument);
9426
- const documentFormat = import_ssi_types7.CredentialMapper.detectDocumentType(addCredentialArgs.rawDocument);
9565
+ const documentFormat = import_ssi_types9.CredentialMapper.detectDocumentType(addCredentialArgs.rawDocument);
9427
9566
  const hasher = addCredentialArgs?.opts?.hasher ?? import_ssi_sdk23.defaultHasher;
9428
- if (documentFormat === import_ssi_types7.DocumentFormat.SD_JWT_VC && !addCredentialArgs.opts?.hasher) {
9567
+ if (documentFormat === import_ssi_types9.DocumentFormat.SD_JWT_VC && !addCredentialArgs.opts?.hasher) {
9429
9568
  throw new Error("No hasher function is provided for SD_JWT credential.");
9430
9569
  }
9431
- const uniformDocument = documentType === DocumentType.VC || documentType === DocumentType.C ? import_ssi_types7.CredentialMapper.toUniformCredential(addCredentialArgs.rawDocument, {
9570
+ const uniformDocument = documentType === DocumentType.VC || documentType === DocumentType.C ? import_ssi_types9.CredentialMapper.toUniformCredential(addCredentialArgs.rawDocument, {
9432
9571
  hasher
9433
- }) : import_ssi_types7.CredentialMapper.toUniformPresentation(addCredentialArgs.rawDocument, {
9572
+ }) : import_ssi_types9.CredentialMapper.toUniformPresentation(addCredentialArgs.rawDocument, {
9434
9573
  hasher
9435
9574
  });
9436
9575
  const validFrom = getValidFrom(uniformDocument);
@@ -9498,7 +9637,7 @@ var DataStoreIssuanceBrandingEntities = [
9498
9637
  CredentialClaimsEntity
9499
9638
  ];
9500
9639
  var DataStorePresentationDefinitionEntities = [
9501
- PresentationDefinitionItemEntity
9640
+ DcqlQueryItemEntity
9502
9641
  ];
9503
9642
  var DataStoreStatusListEntities = [
9504
9643
  StatusListEntity,