@sphereon/ssi-sdk.data-store 0.34.1-fix.114 → 0.34.1-fix.141

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