@sphereon/ssi-sdk.data-store 0.34.1-feature.SSISDK.45.91 → 0.34.1-feature.SSISDK.45.93

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.
package/dist/index.js CHANGED
@@ -96,13 +96,6 @@ var CredentialCorrelationType = /* @__PURE__ */ function(CredentialCorrelationTy
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;
@@ -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");
@@ -7140,9 +7135,120 @@ var CreateContacts1659463079429 = class {
7140
7135
  }
7141
7136
  };
7142
7137
 
7143
- // src/migrations/generic/2-CreateIssuanceBranding.ts
7138
+ // src/migrations/generic/10-CreatePresentationDefinitions.ts
7144
7139
  import Debug9 from "debug";
7145
7140
 
7141
+ // src/migrations/postgres/1716475165345-CreatePresentationDefinitions.ts
7142
+ var CreatePresentationDefinitions1716475165345 = class {
7143
+ static {
7144
+ __name(this, "CreatePresentationDefinitions1716475165345");
7145
+ }
7146
+ name = "CreatePresentationDefinitions1716475165345";
7147
+ async up(queryRunner) {
7148
+ await queryRunner.query(`
7149
+ CREATE TABLE "PresentationDefinitionItem" (
7150
+ "id" uuid NOT NULL DEFAULT uuid_generate_v4(),
7151
+ "tenant_id" TEXT,
7152
+ "definition_id" TEXT NOT NULL,
7153
+ "name" TEXT,
7154
+ "version" TEXT NOT NULL,
7155
+ "purpose" TEXT,
7156
+ "definition_payload" TEXT NOT NULL,
7157
+ "dcql_payload" TEXT,
7158
+ "created_at" TIMESTAMP NOT NULL DEFAULT now(),
7159
+ "last_updated_at" TIMESTAMP NOT NULL DEFAULT now(),
7160
+ CONSTRAINT "PK_PresentationDefinitionItem_id" PRIMARY KEY ("id"))
7161
+ `);
7162
+ }
7163
+ async down(queryRunner) {
7164
+ await queryRunner.query(`DROP TABLE "PresentationDefinitionItem"`);
7165
+ }
7166
+ };
7167
+
7168
+ // src/migrations/sqlite/1716475165344-CreatePresentationDefinitions.ts
7169
+ var CreatePresentationDefinitions1716475165344 = class {
7170
+ static {
7171
+ __name(this, "CreatePresentationDefinitions1716475165344");
7172
+ }
7173
+ name = "CreatePresentationDefinitions1716475165344";
7174
+ async up(queryRunner) {
7175
+ await queryRunner.query(`CREATE TABLE "PresentationDefinitionItem" (
7176
+ "id" varchar PRIMARY KEY NOT NULL,
7177
+ "tenant_id" varchar,
7178
+ "definition_id" varchar NOT NULL,
7179
+ "name" varchar,
7180
+ "version" varchar NOT NULL,
7181
+ "purpose" varchar,
7182
+ "definition_payload" varchar NOT NULL,
7183
+ "dcql_payload" varchar,
7184
+ "created_at" datetime NOT NULL DEFAULT (datetime('now')),
7185
+ "last_updated_at" datetime NOT NULL DEFAULT (datetime('now')))`);
7186
+ }
7187
+ async down(queryRunner) {
7188
+ await queryRunner.query(`DROP TABLE "PresentationDefinitionItem"`);
7189
+ }
7190
+ };
7191
+
7192
+ // src/migrations/generic/10-CreatePresentationDefinitions.ts
7193
+ var debug9 = Debug9("sphereon:ssi-sdk:migrations");
7194
+ var CreatePresentationDefinitions1716533767523 = class {
7195
+ static {
7196
+ __name(this, "CreatePresentationDefinitions1716533767523");
7197
+ }
7198
+ name = "CreatePresentationDefinitionItems1716533767523";
7199
+ async up(queryRunner) {
7200
+ debug9("migration: creating machine state tables");
7201
+ const dbType = queryRunner.connection.driver.options.type;
7202
+ switch (dbType) {
7203
+ case "postgres": {
7204
+ debug9("using postgres migration file");
7205
+ const mig = new CreatePresentationDefinitions1716475165345();
7206
+ await mig.up(queryRunner);
7207
+ debug9("Migration statements executed");
7208
+ return;
7209
+ }
7210
+ case "sqlite":
7211
+ case "expo":
7212
+ case "react-native": {
7213
+ debug9("using sqlite/react-native migration file");
7214
+ const mig = new CreatePresentationDefinitions1716475165344();
7215
+ await mig.up(queryRunner);
7216
+ debug9("Migration statements executed");
7217
+ return;
7218
+ }
7219
+ default:
7220
+ 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`);
7221
+ }
7222
+ }
7223
+ async down(queryRunner) {
7224
+ debug9("migration: reverting machine state tables");
7225
+ const dbType = queryRunner.connection.driver.options.type;
7226
+ switch (dbType) {
7227
+ case "postgres": {
7228
+ debug9("using postgres migration file");
7229
+ const mig = new CreatePresentationDefinitions1716475165345();
7230
+ await mig.down(queryRunner);
7231
+ debug9("Migration statements executed");
7232
+ return;
7233
+ }
7234
+ case "sqlite":
7235
+ case "expo":
7236
+ case "react-native": {
7237
+ debug9("using sqlite/react-native migration file");
7238
+ const mig = new CreatePresentationDefinitions1716475165344();
7239
+ await mig.down(queryRunner);
7240
+ debug9("Migration statements executed");
7241
+ return;
7242
+ }
7243
+ default:
7244
+ 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`);
7245
+ }
7246
+ }
7247
+ };
7248
+
7249
+ // src/migrations/generic/11-FixCredentialClaimsReferenceUuid.ts
7250
+ import Debug10 from "debug";
7251
+
7146
7252
  // src/migrations/postgres/1685628974232-CreateIssuanceBranding.ts
7147
7253
  import { enablePostgresUuidExtension as enablePostgresUuidExtension2 } from "@sphereon/ssi-sdk.core";
7148
7254
  var CreateIssuanceBranding1685628974232 = class {
@@ -7279,31 +7385,105 @@ var CreateIssuanceBranding1685628973231 = class {
7279
7385
  }
7280
7386
  };
7281
7387
 
7282
- // src/migrations/generic/2-CreateIssuanceBranding.ts
7283
- var debug9 = Debug9("sphereon:ssi-sdk:migrations");
7284
- var CreateIssuanceBranding1659463079429 = class {
7388
+ // src/migrations/postgres/1741895822987-FixCredentialClaimsReferencesUuid.ts
7389
+ var FixCredentialClaimsReferencesUuidPG1741895822987 = class {
7285
7390
  static {
7286
- __name(this, "CreateIssuanceBranding1659463079429");
7391
+ __name(this, "FixCredentialClaimsReferencesUuidPG1741895822987");
7287
7392
  }
7288
- name = "CreateIssuanceBranding1659463079429";
7393
+ name = "FixCredentialClaimsReferencesUuid1741895822987";
7394
+ async up(queryRunner) {
7395
+ await queryRunner.query(`
7396
+ ALTER TABLE "CredentialClaims"
7397
+ ALTER COLUMN "credentialLocaleBrandingId" TYPE uuid USING "credentialLocaleBrandingId"::uuid;
7398
+ `);
7399
+ }
7400
+ async down(queryRunner) {
7401
+ await queryRunner.query(`
7402
+ ALTER TABLE "CredentialClaims"
7403
+ ALTER COLUMN "credentialLocaleBrandingId" TYPE character varying USING "credentialLocaleBrandingId"::text;
7404
+ `);
7405
+ }
7406
+ };
7407
+
7408
+ // src/migrations/sqlite/1741895822987-FixCredentialClaimsReferencesUuid.ts
7409
+ var FixCredentialClaimsReferencesUuidSqlite1741895822987 = class {
7410
+ static {
7411
+ __name(this, "FixCredentialClaimsReferencesUuidSqlite1741895822987");
7412
+ }
7413
+ name = "FixCredentialClaimsReferencesUuid1741895822987";
7414
+ async up(queryRunner) {
7415
+ await queryRunner.query(`
7416
+ CREATE TABLE "CredentialClaims_new"
7417
+ (
7418
+ "id" uuid NOT NULL DEFAULT (lower(hex(randomblob(16)))),
7419
+ "key" character varying(255) NOT NULL,
7420
+ "name" character varying(255) NOT NULL,
7421
+ "credentialLocaleBrandingId" uuid,
7422
+ CONSTRAINT "PK_CredentialClaims_id" PRIMARY KEY ("id")
7423
+ )
7424
+ `);
7425
+ await queryRunner.query(`
7426
+ INSERT INTO "CredentialClaims_new" ("id", "key", "name", "credentialLocaleBrandingId")
7427
+ SELECT "id", "key", "name", "credentialLocaleBrandingId"
7428
+ FROM "CredentialClaims"
7429
+ `);
7430
+ await queryRunner.query(`DROP TABLE "CredentialClaims"`);
7431
+ await queryRunner.query(`ALTER TABLE "CredentialClaims_new" RENAME TO "CredentialClaims"`);
7432
+ await queryRunner.query(`
7433
+ CREATE UNIQUE INDEX "IDX_CredentialClaimsEntity_credentialLocaleBranding_locale"
7434
+ ON "CredentialClaims" ("credentialLocaleBrandingId", "key")
7435
+ `);
7436
+ }
7437
+ async down(queryRunner) {
7438
+ await queryRunner.query(`
7439
+ CREATE TABLE "CredentialClaims_old"
7440
+ (
7441
+ "id" uuid NOT NULL DEFAULT (lower(hex(randomblob(16)))),
7442
+ "key" character varying(255) NOT NULL,
7443
+ "name" character varying(255) NOT NULL,
7444
+ "credentialLocaleBrandingId" character varying,
7445
+ CONSTRAINT "PK_CredentialClaims_id" PRIMARY KEY ("id")
7446
+ )
7447
+ `);
7448
+ await queryRunner.query(`
7449
+ INSERT INTO "CredentialClaims_old" ("id", "key", "name", "credentialLocaleBrandingId")
7450
+ SELECT "id", "key", "name", "credentialLocaleBrandingId"
7451
+ FROM "CredentialClaims"
7452
+ `);
7453
+ await queryRunner.query(`DROP TABLE "CredentialClaims"`);
7454
+ await queryRunner.query(`ALTER TABLE "CredentialClaims_old" RENAME TO "CredentialClaims"`);
7455
+ await queryRunner.query(`
7456
+ CREATE UNIQUE INDEX "IDX_CredentialClaimsEntity_credentialLocaleBranding_locale"
7457
+ ON "CredentialClaims" ("credentialLocaleBrandingId", "key")
7458
+ `);
7459
+ }
7460
+ };
7461
+
7462
+ // src/migrations/generic/11-FixCredentialClaimsReferenceUuid.ts
7463
+ var debug10 = Debug10("sphereon:ssi-sdk:migrations");
7464
+ var FixCredentialClaimsReferencesUuid1741895822987 = class {
7465
+ static {
7466
+ __name(this, "FixCredentialClaimsReferencesUuid1741895822987");
7467
+ }
7468
+ name = "FixCredentialClaimsReferenceUuid1741895822987";
7289
7469
  async up(queryRunner) {
7290
- debug9("migration: creating issuance branding tables");
7470
+ debug10("migration: creating issuance branding uuid problem");
7291
7471
  const dbType = queryRunner.connection.driver.options.type;
7292
7472
  switch (dbType) {
7293
7473
  case "postgres": {
7294
- debug9("using postgres migration file");
7295
- const mig = new CreateIssuanceBranding1685628974232();
7474
+ debug10("using postgres migration file");
7475
+ const mig = new FixCredentialClaimsReferencesUuidPG1741895822987();
7296
7476
  await mig.up(queryRunner);
7297
- debug9("Migration statements executed");
7477
+ debug10("Migration statements executed");
7298
7478
  return;
7299
7479
  }
7300
7480
  case "sqlite":
7301
7481
  case "expo":
7302
7482
  case "react-native": {
7303
- debug9("using sqlite/react-native migration file");
7304
- const mig = new CreateIssuanceBranding1685628973231();
7483
+ debug10("using sqlite/react-native migration file");
7484
+ const mig = new FixCredentialClaimsReferencesUuidSqlite1741895822987();
7305
7485
  await mig.up(queryRunner);
7306
- debug9("Migration statements executed");
7486
+ debug10("Migration statements executed");
7307
7487
  return;
7308
7488
  }
7309
7489
  default:
@@ -7311,23 +7491,23 @@ var CreateIssuanceBranding1659463079429 = class {
7311
7491
  }
7312
7492
  }
7313
7493
  async down(queryRunner) {
7314
- debug9("migration: reverting issuance branding tables");
7494
+ debug10("migration: reverting issuance branding uuid migration");
7315
7495
  const dbType = queryRunner.connection.driver.options.type;
7316
7496
  switch (dbType) {
7317
7497
  case "postgres": {
7318
- debug9("using postgres migration file");
7498
+ debug10("using postgres migration file");
7319
7499
  const mig = new CreateIssuanceBranding1685628974232();
7320
7500
  await mig.down(queryRunner);
7321
- debug9("Migration statements executed");
7501
+ debug10("Migration statements executed");
7322
7502
  return;
7323
7503
  }
7324
7504
  case "sqlite":
7325
7505
  case "expo":
7326
7506
  case "react-native": {
7327
- debug9("using sqlite/react-native migration file");
7507
+ debug10("using sqlite/react-native migration file");
7328
7508
  const mig = new CreateIssuanceBranding1685628973231();
7329
7509
  await mig.down(queryRunner);
7330
- debug9("Migration statements executed");
7510
+ debug10("Migration statements executed");
7331
7511
  return;
7332
7512
  }
7333
7513
  default:
@@ -7336,658 +7516,280 @@ var CreateIssuanceBranding1659463079429 = class {
7336
7516
  }
7337
7517
  };
7338
7518
 
7339
- // src/migrations/generic/3-CreateContacts.ts
7340
- import Debug10 from "debug";
7519
+ // src/migrations/generic/12-CreateBitstringStatusList.ts
7520
+ import Debug11 from "debug";
7341
7521
 
7342
- // src/migrations/sqlite/1690925872693-CreateContacts.ts
7343
- var CreateContacts1690925872693 = class {
7522
+ // src/migrations/postgres/1741895823000-CreateBitstringStatusList.ts
7523
+ var AddBitstringStatusListEnumPG1741895823000 = class {
7344
7524
  static {
7345
- __name(this, "CreateContacts1690925872693");
7525
+ __name(this, "AddBitstringStatusListEnumPG1741895823000");
7346
7526
  }
7347
- name = "CreateContacts1690925872693";
7527
+ name = "AddBitstringStatusListEnum1741895823000";
7348
7528
  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"`);
7529
+ await queryRunner.startTransaction();
7530
+ await queryRunner.query(`ALTER TYPE "StatusList_type_enum" ADD VALUE 'BitstringStatusList'`);
7531
+ await queryRunner.commitTransaction();
7425
7532
  }
7533
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
7426
7534
  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
7535
  }
7464
7536
  };
7465
-
7466
- // src/migrations/postgres/1690925872592-CreateContacts.ts
7467
- import { enablePostgresUuidExtension as enablePostgresUuidExtension3 } from "@sphereon/ssi-sdk.core";
7468
- var CreateContacts1690925872592 = class {
7537
+ var CreateBitstringStatusListPG1741895823000 = class {
7469
7538
  static {
7470
- __name(this, "CreateContacts1690925872592");
7539
+ __name(this, "CreateBitstringStatusListPG1741895823000");
7471
7540
  }
7472
- name = "CreateContacts1690925872592";
7541
+ name = "CreateBitstringStatusList1741895823000";
7473
7542
  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"`);
7543
+ await queryRunner.query(`ALTER TABLE "StatusList" ADD COLUMN "ttl" integer`);
7544
+ await queryRunner.query(`ALTER TABLE "StatusList" ADD COLUMN "validFrom" TIMESTAMP`);
7545
+ await queryRunner.query(`ALTER TABLE "StatusList" ADD COLUMN "validUntil" TIMESTAMP`);
7546
+ await queryRunner.query(`ALTER TABLE "StatusList" DROP CONSTRAINT IF EXISTS "CHK_StatusList_type"`);
7547
+ await queryRunner.query(`ALTER TABLE "StatusList" ADD CONSTRAINT "CHK_StatusList_type" CHECK ("type" IN ('StatusList2021', 'OAuthStatusList', 'BitstringStatusList'))`);
7548
+ await queryRunner.query(`ALTER TABLE "StatusListEntry" ADD COLUMN "type" character varying NOT NULL DEFAULT 'StatusListEntryEntity'`);
7549
+ await queryRunner.query(`ALTER TABLE "StatusListEntry" ADD COLUMN "statusPurpose" character varying`);
7550
+ await queryRunner.query(`ALTER TABLE "StatusListEntry" ADD COLUMN "statusMessage" text`);
7551
+ await queryRunner.query(`ALTER TABLE "StatusListEntry" ADD COLUMN "statusReference" text`);
7552
+ await queryRunner.query(`ALTER TABLE "StatusListEntry" ADD CONSTRAINT "CHK_StatusListEntry_type" CHECK ("type" IN ('StatusListEntryEntity', 'bitstring'))`);
7519
7553
  }
7520
7554
  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'`);
7555
+ await queryRunner.query(`ALTER TABLE "StatusListEntry" DROP CONSTRAINT "CHK_StatusListEntry_type"`);
7556
+ await queryRunner.query(`ALTER TABLE "StatusListEntry" DROP COLUMN "statusReference"`);
7557
+ await queryRunner.query(`ALTER TABLE "StatusListEntry" DROP COLUMN "statusMessage"`);
7558
+ await queryRunner.query(`ALTER TABLE "StatusListEntry" DROP COLUMN "bitsPerStatus"`);
7559
+ await queryRunner.query(`ALTER TABLE "StatusListEntry" DROP COLUMN "statusPurpose"`);
7560
+ await queryRunner.query(`ALTER TABLE "StatusListEntry" DROP COLUMN "type"`);
7561
+ await queryRunner.query(`ALTER TABLE "StatusList" DROP CONSTRAINT "CHK_StatusList_type"`);
7562
+ await queryRunner.query(`ALTER TABLE "StatusList" ADD CONSTRAINT "CHK_StatusList_type" CHECK ("type" IN ('StatusList2021', 'OAuthStatusList'))`);
7563
+ await queryRunner.query(`ALTER TABLE "StatusList" DROP COLUMN "validUntil"`);
7564
+ await queryRunner.query(`ALTER TABLE "StatusList" DROP COLUMN "validFrom"`);
7565
+ await queryRunner.query(`ALTER TABLE "StatusList" DROP COLUMN "ttl"`);
7566
+ await queryRunner.query(`ALTER TABLE "StatusList" DROP COLUMN "bitsPerStatus"`);
7557
7567
  }
7558
7568
  };
7559
7569
 
7560
- // src/migrations/generic/3-CreateContacts.ts
7561
- var debug10 = Debug10("sphereon:ssi-sdk:migrations");
7562
- var CreateContacts1690925872318 = class {
7570
+ // src/migrations/sqlite/1741895823001-CreateBitstringStatusList.ts
7571
+ var CreateBitstringStatusListSqlite1741895823001 = class {
7563
7572
  static {
7564
- __name(this, "CreateContacts1690925872318");
7573
+ __name(this, "CreateBitstringStatusListSqlite1741895823001");
7565
7574
  }
7566
- name = "CreateContacts1690925872318";
7575
+ name = "CreateBitstringStatusList1741895823000";
7567
7576
  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"`);
7577
+ await queryRunner.query(`
7578
+ CREATE TABLE "temporary_StatusList" (
7579
+ "id" varchar PRIMARY KEY NOT NULL,
7580
+ "correlationId" varchar NOT NULL,
7581
+ "length" integer NOT NULL,
7582
+ "issuer" text NOT NULL,
7583
+ "type" varchar CHECK( "type" IN ('StatusList2021', 'OAuthStatusList', 'BitstringStatusList') ) NOT NULL DEFAULT ('StatusList2021'),
7584
+ "driverType" varchar CHECK( "driverType" IN ('agent_typeorm','agent_kv_store','github','agent_filesystem') ) NOT NULL DEFAULT ('agent_typeorm'),
7585
+ "credentialIdMode" varchar CHECK( "credentialIdMode" IN ('ISSUANCE','PERSISTENCE','NEVER') ) NOT NULL DEFAULT ('ISSUANCE'),
7586
+ "proofFormat" varchar CHECK( "proofFormat" IN ('lds','jwt', 'vc+jwt') ) NOT NULL DEFAULT ('lds'),
7587
+ "indexingDirection" varchar CHECK( "indexingDirection" IN ('rightToLeft') ),
7588
+ "statusPurpose" varchar,
7589
+ "statusListCredential" text,
7590
+ "expiresAt" datetime,
7591
+ "bitsPerStatus" integer DEFAULT (1),
7592
+ "ttl" integer,
7593
+ "validFrom" datetime,
7594
+ "validUntil" datetime,
7595
+ CONSTRAINT "UQ_correlationId" UNIQUE ("correlationId")
7596
+ )
7597
+ `);
7598
+ await queryRunner.query(`
7599
+ INSERT INTO "temporary_StatusList"(
7600
+ "id", "correlationId", "length", "issuer", "type", "driverType",
7601
+ "credentialIdMode", "proofFormat", "indexingDirection", "statusPurpose",
7602
+ "statusListCredential", "bitsPerStatus", "expiresAt"
7603
+ )
7604
+ SELECT
7605
+ "id", "correlationId", "length", "issuer", "type", "driverType",
7606
+ "credentialIdMode", "proofFormat", "indexingDirection", "statusPurpose",
7607
+ "statusListCredential", "bitsPerStatus", "expiresAt"
7608
+ FROM "StatusList"
7609
+ `);
7663
7610
  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"`);
7611
+ await queryRunner.query(`ALTER TABLE "temporary_StatusList" RENAME TO "StatusList"`);
7612
+ await queryRunner.query(`
7613
+ CREATE TABLE "temporary_StatusListEntry" (
7614
+ "statusListId" varchar NOT NULL,
7615
+ "statusListIndex" integer NOT NULL,
7616
+ "credentialId" text,
7617
+ "credentialHash" varchar(128),
7618
+ "correlationId" varchar(255),
7619
+ "value" varchar(50),
7620
+ "type" varchar CHECK( "type" IN ('StatusListEntryEntity', 'bitstring') ) NOT NULL DEFAULT ('StatusListEntryEntity'),
7621
+ "statusPurpose" varchar,
7622
+ "bitsPerStatus" integer DEFAULT (1),
7623
+ "statusMessage" text,
7624
+ "statusReference" text,
7625
+ PRIMARY KEY ("statusListId", "statusListIndex")
7626
+ )
7627
+ `);
7628
+ await queryRunner.query(`
7629
+ INSERT INTO "temporary_StatusListEntry"(
7630
+ "statusListId", "statusListIndex", "credentialId", "credentialHash",
7631
+ "correlationId", "value", "type"
7632
+ )
7633
+ SELECT
7634
+ "statusListId", "statusListIndex", "credentialId", "credentialHash",
7635
+ "correlationId", "value", 'StatusListEntryEntity'
7636
+ FROM "StatusListEntry"
7637
+ `);
7718
7638
  await queryRunner.query(`DROP TABLE "StatusListEntry"`);
7719
7639
  await queryRunner.query(`ALTER TABLE "temporary_StatusListEntry" RENAME TO "StatusListEntry"`);
7720
7640
  }
7721
7641
  async down(queryRunner) {
7642
+ await queryRunner.query(`
7643
+ CREATE TABLE "temporary_StatusListEntry" (
7644
+ "statusListId" varchar NOT NULL,
7645
+ "statusListIndex" integer NOT NULL,
7646
+ "credentialId" text,
7647
+ "credentialHash" varchar(128),
7648
+ "correlationId" varchar(255),
7649
+ "value" varchar(50),
7650
+ PRIMARY KEY ("statusListId", "statusListIndex")
7651
+ )
7652
+ `);
7653
+ await queryRunner.query(`
7654
+ INSERT INTO "temporary_StatusListEntry"(
7655
+ "statusListId", "statusListIndex", "credentialId", "credentialHash",
7656
+ "correlationId", "value"
7657
+ )
7658
+ SELECT
7659
+ "statusListId", "statusListIndex", "credentialId", "credentialHash",
7660
+ "correlationId", "value"
7661
+ FROM "StatusListEntry"
7662
+ WHERE "type" = 'StatusListEntryEntity'
7663
+ `);
7722
7664
  await queryRunner.query(`DROP TABLE "StatusListEntry"`);
7665
+ await queryRunner.query(`ALTER TABLE "temporary_StatusListEntry" RENAME TO "StatusListEntry"`);
7666
+ await queryRunner.query(`
7667
+ CREATE TABLE "temporary_StatusList" (
7668
+ "id" varchar PRIMARY KEY NOT NULL,
7669
+ "correlationId" varchar NOT NULL,
7670
+ "length" integer NOT NULL,
7671
+ "issuer" text NOT NULL,
7672
+ "type" varchar CHECK( "type" IN ('StatusList2021', 'OAuthStatusList') ) NOT NULL DEFAULT ('StatusList2021'),
7673
+ "driverType" varchar CHECK( "driverType" IN ('agent_typeorm','agent_kv_store','github','agent_filesystem') ) NOT NULL DEFAULT ('agent_typeorm'),
7674
+ "credentialIdMode" varchar CHECK( "credentialIdMode" IN ('ISSUANCE','PERSISTENCE','NEVER') ) NOT NULL DEFAULT ('ISSUANCE'),
7675
+ "proofFormat" varchar CHECK( "proofFormat" IN ('lds','jwt', 'vc+jwt') ) NOT NULL DEFAULT ('lds'),
7676
+ "indexingDirection" varchar CHECK( "indexingDirection" IN ('rightToLeft') ),
7677
+ "statusPurpose" varchar,
7678
+ "statusListCredential" text,
7679
+ "bitsPerStatus" integer,
7680
+ "expiresAt" datetime,
7681
+ CONSTRAINT "UQ_correlationId" UNIQUE ("correlationId")
7682
+ )
7683
+ `);
7684
+ await queryRunner.query(`
7685
+ INSERT INTO "temporary_StatusList"(
7686
+ "id", "correlationId", "length", "issuer", "type", "driverType",
7687
+ "credentialIdMode", "proofFormat", "indexingDirection", "statusPurpose",
7688
+ "statusListCredential", "bitsPerStatus", "expiresAt"
7689
+ )
7690
+ SELECT
7691
+ "id", "correlationId", "length", "issuer",
7692
+ CASE WHEN "type" = 'BitstringStatusList' THEN 'StatusList2021' ELSE "type" END,
7693
+ "driverType", "credentialIdMode", "proofFormat", "indexingDirection",
7694
+ "statusPurpose", "statusListCredential", "bitsPerStatus", "expiresAt"
7695
+ FROM "StatusList"
7696
+ `);
7723
7697
  await queryRunner.query(`DROP TABLE "StatusList"`);
7698
+ await queryRunner.query(`ALTER TABLE "temporary_StatusList" RENAME TO "StatusList"`);
7724
7699
  }
7725
7700
  };
7726
7701
 
7727
- // src/migrations/postgres/1737110469001-UpdateStatusList.ts
7728
- var UpdateStatusList1737110469001 = class {
7702
+ // src/migrations/generic/12-CreateBitstringStatusList.ts
7703
+ var debug11 = Debug11("sphereon:ssi-sdk:migrations");
7704
+ var AddBitstringStatusListEnum1741895823000 = class {
7729
7705
  static {
7730
- __name(this, "UpdateStatusList1737110469001");
7706
+ __name(this, "AddBitstringStatusListEnum1741895823000");
7731
7707
  }
7732
- name = "UpdateStatusList1737110469001";
7708
+ name = "AddBitstringStatusListEnum1741895823000";
7733
7709
  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`);
7710
+ debug11("migration: creating bitstring status list tables");
7711
+ const dbType = queryRunner.connection.driver.options.type;
7712
+ switch (dbType) {
7713
+ case "postgres": {
7714
+ const mig = new AddBitstringStatusListEnumPG1741895823000();
7715
+ await mig.up(queryRunner);
7716
+ return;
7717
+ }
7718
+ case "sqlite":
7719
+ case "expo":
7720
+ case "react-native": {
7721
+ return;
7722
+ }
7723
+ default:
7724
+ return Promise.reject(`Migrations only supported for sqlite and postgres. Was ${dbType}`);
7725
+ }
7739
7726
  }
7727
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
7740
7728
  async down(queryRunner) {
7741
- await queryRunner.query(`ALTER TABLE "StatusList" DROP COLUMN "expiresAt"`);
7742
- await queryRunner.query(`ALTER TABLE "StatusList" DROP COLUMN "bitsPerStatus"`);
7743
- await queryRunner.query(`ALTER TABLE "StatusList" ALTER COLUMN "statusPurpose" SET NOT NULL`);
7744
- await queryRunner.query(`ALTER TABLE "StatusList" ALTER COLUMN "indexingDirection" SET NOT NULL`);
7745
7729
  }
7746
7730
  };
7747
-
7748
- // src/migrations/sqlite/1737110469000-UpdateStatusList.ts
7749
- var UpdateStatusList1737110469000 = class {
7731
+ var CreateBitstringStatusList1741895823000 = class {
7750
7732
  static {
7751
- __name(this, "UpdateStatusList1737110469000");
7733
+ __name(this, "CreateBitstringStatusList1741895823000");
7752
7734
  }
7753
- name = "UpdateStatusList1737110469000";
7735
+ name = "CreateBitstringStatusList1741895823000";
7754
7736
  async up(queryRunner) {
7755
- await queryRunner.query(`CREATE TABLE "temporary_StatusList" (
7756
- "id" varchar PRIMARY KEY NOT NULL,
7757
- "correlationId" varchar NOT NULL,
7758
- "length" integer NOT NULL,
7759
- "issuer" text NOT NULL,
7760
- "type" varchar CHECK( "type" IN ('StatusList2021', 'OAuthStatusList') ) NOT NULL DEFAULT ('StatusList2021'),
7761
- "driverType" varchar CHECK( "driverType" IN ('agent_typeorm','agent_kv_store','github','agent_filesystem') ) NOT NULL DEFAULT ('agent_typeorm'),
7762
- "credentialIdMode" varchar CHECK( "credentialIdMode" IN ('ISSUANCE','PERSISTENCE','NEVER') ) NOT NULL DEFAULT ('ISSUANCE'),
7763
- "proofFormat" varchar CHECK( "proofFormat" IN ('lds','jwt') ) NOT NULL DEFAULT ('lds'),
7764
- "indexingDirection" varchar CHECK( "indexingDirection" IN ('rightToLeft') ),
7765
- "statusPurpose" varchar,
7766
- "statusListCredential" text,
7767
- "bitsPerStatus" integer,
7768
- "expiresAt" datetime,
7769
- CONSTRAINT "UQ_correlationId" UNIQUE ("correlationId")
7770
- )`);
7771
- await queryRunner.query(`INSERT INTO "temporary_StatusList"(
7772
- "id", "correlationId", "length", "issuer", "type", "driverType",
7773
- "credentialIdMode", "proofFormat", "indexingDirection", "statusPurpose",
7774
- "statusListCredential"
7775
- )
7776
- SELECT
7777
- "id", "correlationId", "length", "issuer", "type", "driverType",
7778
- "credentialIdMode", "proofFormat", "indexingDirection", "statusPurpose",
7779
- "statusListCredential"
7780
- FROM "StatusList"`);
7781
- await queryRunner.query(`DROP TABLE "StatusList"`);
7782
- await queryRunner.query(`ALTER TABLE "temporary_StatusList" RENAME TO "StatusList"`);
7783
- }
7784
- async down(queryRunner) {
7785
- await queryRunner.query(`
7786
- ALTER TABLE "StatusListEntry"
7787
- RENAME COLUMN "entryCorrelationId" TO "correlationId"
7788
- `);
7789
- await queryRunner.query(`
7790
- ALTER TABLE "StatusListEntry"
7791
- DROP COLUMN "statusListCorrelationId"
7792
- `);
7793
- await queryRunner.query(`CREATE TABLE "temporary_StatusList" (
7794
- "id" varchar PRIMARY KEY NOT NULL,
7795
- "correlationId" varchar NOT NULL,
7796
- "length" integer NOT NULL,
7797
- "issuer" text NOT NULL,
7798
- "type" varchar CHECK( "type" IN ('StatusList2021') ) NOT NULL DEFAULT ('StatusList2021'),
7799
- "driverType" varchar CHECK( "driverType" IN ('agent_typeorm','agent_kv_store','github','agent_filesystem') ) NOT NULL DEFAULT ('agent_typeorm'),
7800
- "credentialIdMode" varchar CHECK( "credentialIdMode" IN ('ISSUANCE','PERSISTENCE','NEVER') ) NOT NULL DEFAULT ('ISSUANCE'),
7801
- "proofFormat" varchar CHECK( "proofFormat" IN ('lds','jwt') ) NOT NULL DEFAULT ('lds'),
7802
- "indexingDirection" varchar CHECK( "indexingDirection" IN ('rightToLeft') ) NOT NULL DEFAULT ('rightToLeft'),
7803
- "statusPurpose" varchar NOT NULL DEFAULT ('revocation'),
7804
- "statusListCredential" text,
7805
- CONSTRAINT "UQ_correlationId" UNIQUE ("correlationId")
7806
- )`);
7807
- await queryRunner.query(`INSERT INTO "temporary_StatusList"(
7808
- "id", "correlationId", "length", "issuer", "type", "driverType",
7809
- "credentialIdMode", "proofFormat", "indexingDirection", "statusPurpose",
7810
- "statusListCredential"
7811
- )
7812
- SELECT
7813
- "id", "correlationId", "length", "issuer",
7814
- CASE WHEN "type" = 'OAuthStatusList' THEN 'StatusList2021' ELSE "type" END,
7815
- "driverType", "credentialIdMode", "proofFormat", "indexingDirection",
7816
- COALESCE("statusPurpose", 'revocation'), "statusListCredential"
7817
- FROM "StatusList"`);
7818
- await queryRunner.query(`DROP TABLE "StatusList"`);
7819
- await queryRunner.query(`ALTER TABLE "temporary_StatusList" RENAME TO "StatusList"`);
7820
- }
7821
- };
7822
-
7823
- // src/migrations/generic/4-CreateStatusList.ts
7824
- var debug11 = Debug11("sphereon:ssi-sdk:migrations");
7825
- var CreateStatusList1693866470000 = class {
7826
- static {
7827
- __name(this, "CreateStatusList1693866470000");
7828
- }
7829
- name = "CreateStatusList1693866470000";
7830
- async up(queryRunner) {
7831
- debug11("migration: creating issuance branding tables");
7737
+ debug11("migration: creating bitstring status list tables");
7832
7738
  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`);
7739
+ switch (dbType) {
7740
+ case "postgres": {
7741
+ const mig = new CreateBitstringStatusListPG1741895823000();
7742
+ await mig.up(queryRunner);
7743
+ return;
7744
+ }
7745
+ case "sqlite":
7746
+ case "expo":
7747
+ case "react-native": {
7748
+ const mig = new CreateBitstringStatusListSqlite1741895823001();
7749
+ await mig.up(queryRunner);
7750
+ return;
7751
+ }
7752
+ default:
7753
+ return Promise.reject(`Migrations only supported for sqlite and postgres. Was ${dbType}`);
7851
7754
  }
7852
7755
  }
7853
7756
  async down(queryRunner) {
7854
- debug11("migration: reverting issuance branding tables");
7757
+ debug11("migration: dropping bitstring status list tables");
7855
7758
  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`);
7759
+ switch (dbType) {
7760
+ case "postgres": {
7761
+ const mig = new CreateBitstringStatusListPG1741895823000();
7762
+ await mig.down(queryRunner);
7763
+ return;
7764
+ }
7765
+ case "sqlite":
7766
+ case "expo":
7767
+ case "react-native": {
7768
+ const mig = new CreateBitstringStatusListSqlite1741895823001();
7769
+ await mig.down(queryRunner);
7770
+ return;
7771
+ }
7772
+ default:
7773
+ return Promise.reject(`Migrations only supported for sqlite and postgres. Was ${dbType}`);
7874
7774
  }
7875
7775
  }
7876
7776
  };
7877
7777
 
7878
- // src/migrations/generic/5-CreateAuditEvents.ts
7778
+ // src/migrations/generic/2-CreateIssuanceBranding.ts
7879
7779
  import Debug12 from "debug";
7880
-
7881
- // src/migrations/sqlite/1701634819487-CreateAuditEvents.ts
7882
- var CreateAuditEvents1701634819487 = class {
7883
- static {
7884
- __name(this, "CreateAuditEvents1701634819487");
7885
- }
7886
- name = "CreateAuditEvents1701634819487";
7887
- 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')))`);
7915
- }
7916
- async down(queryRunner) {
7917
- await queryRunner.query(`DROP TABLE "AuditEvents"`);
7918
- }
7919
- };
7920
-
7921
- // src/migrations/postgres/1701634812183-CreateAuditEvents.ts
7922
- var CreateAuditEvents1701634812183 = class {
7923
- static {
7924
- __name(this, "CreateAuditEvents1701634812183");
7925
- }
7926
- name = "CreateAuditEvents1701634812183";
7927
- async up(queryRunner) {
7928
- await queryRunner.query(`CREATE TYPE "public"."Level_enum" AS ENUM('0', '1', '2', '3', '4')`);
7929
- await queryRunner.query(`CREATE TYPE "public"."System_enum" AS ENUM('general', 'kms', 'identity', 'oid4vci', 'oid4vp', 'siopv2', 'PE', 'credentials', 'web3', 'profile', 'contact')`);
7930
- await queryRunner.query(`CREATE TYPE "public"."Subsystem_type_enum" AS ENUM('key', 'did_provider', 'did_resolver', 'oid4vp_op', 'oid4vci_client', 'siopv2_op', 'contact_manager', 'vc_issuer', 'vc_verifier', 'vc_persistence', 'transport', 'profile', 'api')`);
7931
- await queryRunner.query(`CREATE TYPE "public"."Action_type_enum" AS ENUM('create', 'read', 'update', 'delete', 'execute')`);
7932
- await queryRunner.query(`CREATE TYPE "public"."Initiator_type_enum" AS ENUM('user', 'system', 'external')`);
7933
- await queryRunner.query(`CREATE TYPE "public"."System_correlation_id_type_enum" AS ENUM('did', 'url', 'email', 'hostname', 'phone', 'user')`);
7934
- await queryRunner.query(`CREATE TYPE "public"."Party_correlation_type_enum" AS ENUM('did', 'url', 'email', 'hostname', 'phone')`);
7935
- await queryRunner.query(`CREATE TYPE "public"."Event_type_enum" AS ENUM('audit', 'activity', 'general')`);
7936
- await queryRunner.query(`CREATE TYPE "public"."Event_credential_type_enum" AS ENUM('JSON_LD', 'JWT', 'SD_JWT', 'MSO_MDOC')`);
7937
- await queryRunner.query(`CREATE TABLE "AuditEvents" (
7938
- "id" uuid NOT NULL DEFAULT uuid_generate_v4(),
7939
- "eventType" "public"."Event_type_enum" NOT NULL,
7940
- "timestamp" TIMESTAMP NOT NULL,
7941
- "level" "public"."Level_enum" NOT NULL,
7942
- "correlationId" TEXT NOT NULL,
7943
- "system" "public"."System_enum" NOT NULL,
7944
- "subSystemType" "public"."Subsystem_type_enum" NOT NULL,
7945
- "actionType" "public"."Action_type_enum" NOT NULL,
7946
- "actionSubType" TEXT NOT NULL,
7947
- "initiatorType" "public"."Initiator_type_enum" NOT NULL,
7948
- "systemCorrelationIdType" "public"."System_correlation_id_type_enum",
7949
- "systemCorrelationId" TEXT,
7950
- "systemAlias" TEXT,
7951
- "partyCorrelationType" "public"."Party_correlation_type_enum",
7952
- "partyCorrelationId" TEXT,
7953
- "partyAlias" TEXT,
7954
- "credentialType" "public"."Event_credential_type_enum",
7955
- "credentialHash" TEXT,
7956
- "originalCredential" TEXT,
7957
- "sharePurpose" TEXT,
7958
- "description" TEXT NOT NULL,
7959
- "data" TEXT,
7960
- "diagnosticData" TEXT,
7961
- "created_at" TIMESTAMP NOT NULL DEFAULT now(),
7962
- "last_updated_at" TIMESTAMP NOT NULL DEFAULT now(),
7963
- CONSTRAINT "PK_AuditEvents_id" PRIMARY KEY ("id"))`);
7964
- }
7965
- 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"`);
7974
- }
7975
- };
7976
-
7977
- // src/migrations/generic/5-CreateAuditEvents.ts
7978
7780
  var debug12 = Debug12("sphereon:ssi-sdk:migrations");
7979
- var CreateAuditEvents1701635835330 = class {
7781
+ var CreateIssuanceBranding1659463079429 = class {
7980
7782
  static {
7981
- __name(this, "CreateAuditEvents1701635835330");
7783
+ __name(this, "CreateIssuanceBranding1659463079429");
7982
7784
  }
7983
- name = "CreateAuditEvents1701635835330";
7785
+ name = "CreateIssuanceBranding1659463079429";
7984
7786
  async up(queryRunner) {
7985
- debug12("migration: creating audit events tables");
7787
+ debug12("migration: creating issuance branding tables");
7986
7788
  const dbType = queryRunner.connection.driver.options.type;
7987
7789
  switch (dbType) {
7988
7790
  case "postgres": {
7989
7791
  debug12("using postgres migration file");
7990
- const mig = new CreateAuditEvents1701634812183();
7792
+ const mig = new CreateIssuanceBranding1685628974232();
7991
7793
  await mig.up(queryRunner);
7992
7794
  debug12("Migration statements executed");
7993
7795
  return;
@@ -7996,7 +7798,7 @@ var CreateAuditEvents1701635835330 = class {
7996
7798
  case "expo":
7997
7799
  case "react-native": {
7998
7800
  debug12("using sqlite/react-native migration file");
7999
- const mig = new CreateAuditEvents1701634819487();
7801
+ const mig = new CreateIssuanceBranding1685628973231();
8000
7802
  await mig.up(queryRunner);
8001
7803
  debug12("Migration statements executed");
8002
7804
  return;
@@ -8006,12 +7808,12 @@ var CreateAuditEvents1701635835330 = class {
8006
7808
  }
8007
7809
  }
8008
7810
  async down(queryRunner) {
8009
- debug12("migration: reverting audit events tables");
7811
+ debug12("migration: reverting issuance branding tables");
8010
7812
  const dbType = queryRunner.connection.driver.options.type;
8011
7813
  switch (dbType) {
8012
7814
  case "postgres": {
8013
7815
  debug12("using postgres migration file");
8014
- const mig = new CreateAuditEvents1701634812183();
7816
+ const mig = new CreateIssuanceBranding1685628974232();
8015
7817
  await mig.down(queryRunner);
8016
7818
  debug12("Migration statements executed");
8017
7819
  return;
@@ -8020,7 +7822,7 @@ var CreateAuditEvents1701635835330 = class {
8020
7822
  case "expo":
8021
7823
  case "react-native": {
8022
7824
  debug12("using sqlite/react-native migration file");
8023
- const mig = new CreateAuditEvents1701634819487();
7825
+ const mig = new CreateIssuanceBranding1685628973231();
8024
7826
  await mig.down(queryRunner);
8025
7827
  debug12("Migration statements executed");
8026
7828
  return;
@@ -8031,418 +7833,658 @@ var CreateAuditEvents1701635835330 = class {
8031
7833
  }
8032
7834
  };
8033
7835
 
8034
- // src/migrations/generic/6-CreateDigitalCredential.ts
7836
+ // src/migrations/generic/3-CreateContacts.ts
8035
7837
  import Debug13 from "debug";
8036
7838
 
8037
- // src/migrations/postgres/1708525189001-CreateDigitalCredential.ts
8038
- var CreateDigitalCredential1708525189001 = class {
7839
+ // src/migrations/sqlite/1690925872693-CreateContacts.ts
7840
+ var CreateContacts1690925872693 = class {
8039
7841
  static {
8040
- __name(this, "CreateDigitalCredential1708525189001");
7842
+ __name(this, "CreateContacts1690925872693");
8041
7843
  }
8042
- name = "CreateDigitalCredential1708525189001";
7844
+ name = "CreateContacts1690925872693";
8043
7845
  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
- `);
7846
+ 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"))`);
7847
+ await queryRunner.query(`INSERT INTO "temporary_CorrelationIdentifier"("id", "type", "correlation_id", "identityId") SELECT "id", "type", "correlation_id", "identityId" FROM "CorrelationIdentifier"`);
7848
+ await queryRunner.query(`DROP TABLE "CorrelationIdentifier"`);
7849
+ await queryRunner.query(`ALTER TABLE "temporary_CorrelationIdentifier" RENAME TO "CorrelationIdentifier"`);
7850
+ 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"))`);
7851
+ 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"`);
7852
+ await queryRunner.query(`DROP TABLE "Identity"`);
7853
+ await queryRunner.query(`ALTER TABLE "temporary_Identity" RENAME TO "Identity"`);
7854
+ 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"))`);
7855
+ await queryRunner.query(`INSERT INTO "temporary_Connection"("id", "type", "identityId") SELECT "id", "type", "identityId" FROM "Connection"`);
7856
+ await queryRunner.query(`DROP TABLE "Connection"`);
7857
+ await queryRunner.query(`ALTER TABLE "temporary_Connection" RENAME TO "Connection"`);
7858
+ 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"))`);
7859
+ await queryRunner.query(`INSERT INTO "temporary_CorrelationIdentifier"("id", "type", "correlation_id", "identity_id") SELECT "id", "type", "correlation_id", "identityId" FROM "CorrelationIdentifier"`);
7860
+ await queryRunner.query(`DROP TABLE "CorrelationIdentifier"`);
7861
+ await queryRunner.query(`ALTER TABLE "temporary_CorrelationIdentifier" RENAME TO "CorrelationIdentifier"`);
7862
+ 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"))`);
7863
+ 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"`);
7864
+ await queryRunner.query(`DROP TABLE "Identity"`);
7865
+ await queryRunner.query(`ALTER TABLE "temporary_Identity" RENAME TO "Identity"`);
7866
+ 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"))`);
7867
+ await queryRunner.query(`INSERT INTO "temporary_Connection"("id", "type", "identity_id") SELECT "id", "type", "identityId" FROM "Connection"`);
7868
+ await queryRunner.query(`DROP TABLE "Connection"`);
7869
+ await queryRunner.query(`ALTER TABLE "temporary_Connection" RENAME TO "Connection"`);
7870
+ 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"))`);
7871
+ await queryRunner.query(`CREATE UNIQUE INDEX "IDX_PartyType_type_tenant_id" ON "PartyType" ("type", "tenant_id")`);
7872
+ 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"))`);
7873
+ await queryRunner.query(`CREATE INDEX "IDX_BaseContact_type" ON "BaseContact" ("type")`);
7874
+ 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')))`);
7875
+ await queryRunner.query(`CREATE UNIQUE INDEX "IDX_PartyRelationship_left_right" ON "PartyRelationship" ("left_id", "right_id")`);
7876
+ 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)`);
7877
+ 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"))`);
7878
+ await queryRunner.query(`CREATE INDEX "IDX_BaseConfig_type" ON "BaseConfig" ("type")`);
7879
+ 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)`);
7880
+ await queryRunner.query(`INSERT INTO "temporary_CorrelationIdentifier"("id", "type", "correlation_id", "identity_id") SELECT "id", "type", "correlation_id", "identity_id" FROM "CorrelationIdentifier"`);
7881
+ await queryRunner.query(`DROP TABLE "CorrelationIdentifier"`);
7882
+ await queryRunner.query(`ALTER TABLE "temporary_CorrelationIdentifier" RENAME TO "CorrelationIdentifier"`);
7883
+ await queryRunner.query(`DROP INDEX "IDX_BaseContact_type"`);
7884
+ 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)`);
7885
+ 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"`);
7886
+ await queryRunner.query(`DROP TABLE "BaseContact"`);
7887
+ await queryRunner.query(`ALTER TABLE "temporary_BaseContact" RENAME TO "BaseContact"`);
7888
+ await queryRunner.query(`CREATE INDEX "IDX_BaseContact_type" ON "BaseContact" ("type")`);
7889
+ await queryRunner.query(`DROP INDEX "IDX_PartyRelationship_left_right"`);
7890
+ 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)`);
7891
+ 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"`);
7892
+ await queryRunner.query(`DROP TABLE "PartyRelationship"`);
7893
+ await queryRunner.query(`ALTER TABLE "temporary_PartyRelationship" RENAME TO "PartyRelationship"`);
7894
+ await queryRunner.query(`CREATE UNIQUE INDEX "IDX_PartyRelationship_left_right" ON "PartyRelationship" ("left_id", "right_id")`);
7895
+ 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)`);
7896
+ 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)`);
7897
+ 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)`);
7898
+ 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"`);
7899
+ await queryRunner.query(`DROP TABLE "Party"`);
7900
+ await queryRunner.query(`ALTER TABLE "temporary_Party" RENAME TO "Party"`);
7901
+ 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)`);
7902
+ 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"`);
7903
+ await queryRunner.query(`DROP TABLE "Identity"`);
7904
+ await queryRunner.query(`ALTER TABLE "temporary_Identity" RENAME TO "Identity"`);
7905
+ 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)`);
7906
+ await queryRunner.query(`INSERT INTO "temporary_Connection"("id", "type", "identity_id") SELECT "id", "type", "identity_id" FROM "Connection"`);
7907
+ await queryRunner.query(`DROP TABLE "Connection"`);
7908
+ await queryRunner.query(`ALTER TABLE "temporary_Connection" RENAME TO "Connection"`);
7909
+ await queryRunner.query(`DROP INDEX "IDX_BaseConfig_type"`);
7910
+ 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)`);
7911
+ 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"`);
7912
+ await queryRunner.query(`DROP TABLE "BaseConfig"`);
7913
+ await queryRunner.query(`ALTER TABLE "temporary_BaseConfig" RENAME TO "BaseConfig"`);
7914
+ await queryRunner.query(`CREATE INDEX "IDX_BaseConfig_type" ON "BaseConfig" ("type")`);
7915
+ 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"`);
7916
+ await queryRunner.query(`DROP TABLE "BaseConfigEntity"`);
7917
+ 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'))`);
7918
+ 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'))`);
7919
+ 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"`);
7920
+ 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"`);
7921
+ await queryRunner.query(`DROP TABLE "Contact"`);
8084
7922
  }
8085
7923
  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"`);
7924
+ 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))`);
7925
+ 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'`);
7926
+ await queryRunner.query(`DROP TABLE "BaseContact"`);
7927
+ await queryRunner.query(`DROP TABLE "Party"`);
7928
+ 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)`);
7929
+ 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"`);
7930
+ await queryRunner.query(`DROP TABLE "BaseConfig"`);
7931
+ 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)`);
7932
+ 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"`);
7933
+ await queryRunner.query(`DROP TABLE "Party"`);
7934
+ await queryRunner.query(`ALTER TABLE "temporary_Party" RENAME TO "Party"`);
7935
+ await queryRunner.query(`DROP INDEX "IDX_PartyRelationship_left_right"`);
7936
+ 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)`);
7937
+ 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"`);
7938
+ await queryRunner.query(`DROP TABLE "PartyRelationship"`);
7939
+ await queryRunner.query(`ALTER TABLE "temporary_PartyRelationship" RENAME TO "PartyRelationship"`);
7940
+ await queryRunner.query(`CREATE UNIQUE INDEX "IDX_PartyRelationship_left_right" ON "PartyRelationship" ("left_id", "right_id")`);
7941
+ await queryRunner.query(`DROP INDEX "IDX_BaseContact_type"`);
7942
+ 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)`);
7943
+ 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"`);
7944
+ await queryRunner.query(`DROP TABLE "BaseContact"`);
7945
+ await queryRunner.query(`ALTER TABLE "temporary_BaseContact" RENAME TO "BaseContact"`);
7946
+ await queryRunner.query(`CREATE INDEX "IDX_BaseContact_type" ON "BaseContact" ("type")`);
7947
+ await queryRunner.query(`DROP INDEX "IDX_BaseConfig_type"`);
7948
+ 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)`);
7949
+ 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"`);
7950
+ await queryRunner.query(`DROP TABLE "BaseConfig"`);
7951
+ await queryRunner.query(`ALTER TABLE "temporary_BaseConfig" RENAME TO "BaseConfig"`);
7952
+ await queryRunner.query(`CREATE INDEX "IDX_BaseConfig_type" ON "BaseConfig" ("type")`);
7953
+ await queryRunner.query(`DROP INDEX "IDX_PartyType_type_tenant_id"`);
7954
+ await queryRunner.query(`DROP TABLE "PartyType"`);
7955
+ await queryRunner.query(`DROP TABLE "Connection"`);
7956
+ await queryRunner.query(`DROP TABLE "Identity"`);
7957
+ await queryRunner.query(`DROP TABLE "CorrelationIdentifier"`);
7958
+ await queryRunner.query(`DROP TABLE "ElectronicAddress"`);
7959
+ await queryRunner.query(`DROP TABLE "PhysicalAddress"`);
8093
7960
  }
8094
7961
  };
8095
7962
 
8096
- // src/migrations/sqlite/1708525189002-CreateDigitalCredential.ts
8097
- var CreateDigitalCredential1708525189002 = class {
7963
+ // src/migrations/postgres/1690925872592-CreateContacts.ts
7964
+ import { enablePostgresUuidExtension as enablePostgresUuidExtension3 } from "@sphereon/ssi-sdk.core";
7965
+ var CreateContacts1690925872592 = class {
8098
7966
  static {
8099
- __name(this, "CreateDigitalCredential1708525189002");
7967
+ __name(this, "CreateContacts1690925872592");
8100
7968
  }
8101
- name = "CreateDigitalCredential1708525189002";
7969
+ name = "CreateContacts1690925872592";
8102
7970
  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
- `);
7971
+ await enablePostgresUuidExtension3(queryRunner);
7972
+ await queryRunner.query(`ALTER TABLE "CorrelationIdentifier" DROP CONSTRAINT "FK_CorrelationIdentifier_identityId"`);
7973
+ await queryRunner.query(`ALTER TABLE "IdentityMetadata" DROP CONSTRAINT "FK_IdentityMetadata_identityId"`);
7974
+ await queryRunner.query(`ALTER TABLE "Identity" DROP CONSTRAINT "FK_Identity_contactId"`);
7975
+ await queryRunner.query(`ALTER TABLE "Connection" DROP CONSTRAINT "FK_Connection_identityId"`);
7976
+ await queryRunner.query(`ALTER TABLE "CorrelationIdentifier" RENAME COLUMN "identityId" TO "identity_id"`);
7977
+ await queryRunner.query(`ALTER TABLE "Connection" RENAME COLUMN "identityId" TO "identity_id"`);
7978
+ await queryRunner.query(`CREATE TYPE "public"."PartyType_type_enum" AS ENUM('naturalPerson', 'organization')`);
7979
+ await queryRunner.query(`CREATE TYPE "public"."PartyOrigin_type_enum" AS ENUM('INTERNAL', 'EXTERNAL')`);
7980
+ 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"))`);
7981
+ await queryRunner.query(`CREATE UNIQUE INDEX "IDX_PartyType_type_tenant_id" ON "PartyType" ("type", "tenant_id")`);
7982
+ 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"))`);
7983
+ await queryRunner.query(`CREATE INDEX "IDX_BaseContact_type" ON "BaseContact" ("type")`);
7984
+ 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"))`);
7985
+ await queryRunner.query(`CREATE UNIQUE INDEX "IDX_PartyRelationship_left_right" ON "PartyRelationship" ("left_id", "right_id")`);
7986
+ 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"))`);
7987
+ 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"))`);
7988
+ 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"))`);
7989
+ 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"))`);
7990
+ await queryRunner.query(`CREATE INDEX "IDX_BaseConfig_type" ON "BaseConfig" ("type")`);
7991
+ await queryRunner.query(`ALTER TABLE "Identity" RENAME COLUMN "contactId" TO "partyId"`);
7992
+ await queryRunner.query(`ALTER TABLE "Identity" ALTER COLUMN "roles" SET NOT NULL`);
7993
+ await queryRunner.query(`CREATE TYPE "public"."IdentityOrigin_type_enum" AS ENUM('INTERNAL', 'EXTERNAL')`);
7994
+ await queryRunner.query(`ALTER TABLE "Identity" ADD COLUMN "origin" "public"."IdentityOrigin_type_enum" DEFAULT 'EXTERNAL' NOT NULL`);
7995
+ await queryRunner.query(`ALTER TABLE "Identity" ALTER COLUMN "origin" DROP DEFAULT`);
7996
+ 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`);
7997
+ await queryRunner.query(`ALTER TABLE "IdentityMetadata" ADD CONSTRAINT "FK_IdentityMetadata_identityId" FOREIGN KEY ("identityId") REFERENCES "Identity"("id") ON DELETE CASCADE ON UPDATE NO ACTION`);
7998
+ 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`);
7999
+ 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`);
8000
+ 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`);
8001
+ await queryRunner.query(`ALTER TABLE "ElectronicAddress" ADD CONSTRAINT "FK_ElectronicAddress_partyId" FOREIGN KEY ("partyId") REFERENCES "Party"("id") ON DELETE CASCADE ON UPDATE NO ACTION`);
8002
+ await queryRunner.query(`ALTER TABLE "PhysicalAddress" ADD CONSTRAINT "FK_PhysicalAddress_partyId" FOREIGN KEY ("partyId") REFERENCES "Party" ("id") ON DELETE CASCADE ON UPDATE NO ACTION`);
8003
+ 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`);
8004
+ await queryRunner.query(`ALTER TABLE "Identity" ADD CONSTRAINT "FK_Identity_partyId" FOREIGN KEY ("partyId") REFERENCES "Party"("id") ON DELETE CASCADE ON UPDATE NO ACTION`);
8005
+ 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`);
8006
+ 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`);
8007
+ await queryRunner.query(`ALTER TABLE "CorrelationIdentifier" RENAME CONSTRAINT "UQ_Correlation_id" TO "UQ_CorrelationIdentifier_correlation_id"`);
8008
+ await queryRunner.query(`ALTER TABLE "Identity" RENAME CONSTRAINT "UQ_Identity_Alias" TO "UQ_Identity_alias"`);
8009
+ 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"`);
8010
+ await queryRunner.query(`DROP TABLE "BaseConfigEntity"`);
8011
+ 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())`);
8012
+ 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())`);
8013
+ 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"`);
8014
+ 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"`);
8015
+ await queryRunner.query(`DROP TABLE "Contact"`);
8136
8016
  }
8137
8017
  async down(queryRunner) {
8138
- await queryRunner.query(`DROP TABLE "DigitalCredential"`);
8018
+ await queryRunner.query(`ALTER TABLE "BaseConfig" DROP CONSTRAINT "FK_BaseConfig_connection_id"`);
8019
+ await queryRunner.query(`ALTER TABLE "Connection" DROP CONSTRAINT "FK_Connection_identity_id"`);
8020
+ await queryRunner.query(`ALTER TABLE "Identity" DROP CONSTRAINT "FK_Identity_partyId"`);
8021
+ await queryRunner.query(`ALTER TABLE "Party" DROP CONSTRAINT "FK_Party_party_type_id"`);
8022
+ await queryRunner.query(`ALTER TABLE "PhysicalAddress" DROP CONSTRAINT "FK_PhysicalAddress_partyId"`);
8023
+ await queryRunner.query(`ALTER TABLE "ElectronicAddress" DROP CONSTRAINT "FK_ElectronicAddress_partyId"`);
8024
+ await queryRunner.query(`ALTER TABLE "PartyRelationship" DROP CONSTRAINT "FK_PartyRelationship_right_id"`);
8025
+ await queryRunner.query(`ALTER TABLE "PartyRelationship" DROP CONSTRAINT "FK_PartyRelationship_left_id"`);
8026
+ await queryRunner.query(`ALTER TABLE "BaseContact" DROP CONSTRAINT "FK_BaseContact_party_id"`);
8027
+ await queryRunner.query(`ALTER TABLE "IdentityMetadata" DROP CONSTRAINT "FK_IdentityMetadata_identityId"`);
8028
+ await queryRunner.query(`ALTER TABLE "CorrelationIdentifier" DROP CONSTRAINT "FK_CorrelationIdentifier_identity_id"`);
8029
+ await queryRunner.query(`ALTER TABLE "Identity" ALTER COLUMN "roles" DROP NOT NULL`);
8030
+ await queryRunner.query(`ALTER TABLE "Identity" DROP COLUMN "origin"`);
8031
+ await queryRunner.query(`DROP TYPE "public"."IdentityOrigin_type_enum"`);
8032
+ await queryRunner.query(`ALTER TABLE "Identity" RENAME COLUMN "partyId" TO "contactId"`);
8033
+ await queryRunner.query(`ALTER TABLE "Connection" RENAME COLUMN "identity_id" TO "identityId"`);
8034
+ await queryRunner.query(`ALTER TABLE "CorrelationIdentifier" RENAME COLUMN "identity_id" TO "identityId"`);
8035
+ await queryRunner.query(`DROP INDEX "IDX_BaseConfig_type"`);
8036
+ await queryRunner.query(`DROP TABLE "BaseConfig"`);
8037
+ await queryRunner.query(`DROP TABLE "Party"`);
8038
+ await queryRunner.query(`DROP INDEX "IDX_PartyRelationship_left_right"`);
8039
+ await queryRunner.query(`DROP TABLE "PartyRelationship"`);
8040
+ await queryRunner.query(`DROP INDEX "IDX_BaseContact_type"`);
8041
+ await queryRunner.query(`DROP TABLE "BaseContact"`);
8042
+ await queryRunner.query(`DROP TABLE "ElectronicAddress"`);
8043
+ await queryRunner.query(`DROP TABLE "PhysicalAddress"`);
8044
+ await queryRunner.query(`DROP INDEX "IDX_PartyType_type_tenant_id"`);
8045
+ await queryRunner.query(`DROP TABLE "PartyType"`);
8046
+ await queryRunner.query(`DROP TYPE "public"."PartyOrigin_type_enum"`);
8047
+ await queryRunner.query(`DROP TYPE "public"."PartyType_type_enum"`);
8048
+ await queryRunner.query(`ALTER TABLE "Connection" ADD CONSTRAINT "FK_Connection_identityId" FOREIGN KEY ("identityId") REFERENCES "Identity"("id") ON DELETE CASCADE ON UPDATE NO ACTION`);
8049
+ await queryRunner.query(`ALTER TABLE "Identity" ADD CONSTRAINT "FK_Identity_contactId" FOREIGN KEY ("contactId") REFERENCES "Contact"("id") ON DELETE CASCADE ON UPDATE NO ACTION`);
8050
+ await queryRunner.query(`ALTER TABLE "IdentityMetadata" ADD CONSTRAINT "FK_IdentityMetadata_identityId" FOREIGN KEY ("identityId") REFERENCES "Identity"("id") ON DELETE CASCADE ON UPDATE NO ACTION`);
8051
+ await queryRunner.query(`ALTER TABLE "CorrelationIdentifier" ADD CONSTRAINT "FK_CorrelationIdentifier_identityId" FOREIGN KEY ("identityId") REFERENCES "Identity"("id") ON DELETE CASCADE ON UPDATE NO ACTION`);
8052
+ 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"))`);
8053
+ 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'`);
8139
8054
  }
8140
8055
  };
8141
8056
 
8142
- // src/migrations/generic/6-CreateDigitalCredential.ts
8057
+ // src/migrations/generic/3-CreateContacts.ts
8143
8058
  var debug13 = Debug13("sphereon:ssi-sdk:migrations");
8144
- var CreateDigitalCredential1708525189000 = class {
8059
+ var CreateContacts1690925872318 = class {
8145
8060
  static {
8146
- __name(this, "CreateDigitalCredential1708525189000");
8061
+ __name(this, "CreateContacts1690925872318");
8147
8062
  }
8148
- name = "CreateDigitalCredential1708525189000";
8063
+ name = "CreateContacts1690925872318";
8149
8064
  async up(queryRunner) {
8150
- debug13("migration: creating DigitalCredential tables");
8065
+ debug13("migration: creating contacts tables");
8151
8066
  const dbType = queryRunner.connection.driver.options.type;
8152
8067
  switch (dbType) {
8153
8068
  case "postgres": {
8154
- debug13("using postgres migration file for DigitalCredential");
8155
- const mig = new CreateDigitalCredential1708525189001();
8069
+ debug13("using postgres migration file");
8070
+ const mig = new CreateContacts1690925872592();
8156
8071
  await mig.up(queryRunner);
8157
- debug13("Postgres Migration statements for DigitalCredential executed");
8072
+ debug13("Migration statements executed");
8158
8073
  return;
8159
8074
  }
8160
8075
  case "sqlite":
8161
8076
  case "expo":
8162
8077
  case "react-native": {
8163
- debug13("using sqlite/react-native migration file for DigitalCredential");
8164
- const mig = new CreateDigitalCredential1708525189002();
8078
+ debug13("using sqlite/react-native migration file");
8079
+ const mig = new CreateContacts1690925872693();
8165
8080
  await mig.up(queryRunner);
8166
- debug13("SQLite Migration statements for DigitalCredential executed");
8081
+ debug13("Migration statements executed");
8167
8082
  return;
8168
8083
  }
8169
8084
  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`);
8085
+ 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
8086
  }
8172
8087
  }
8173
8088
  async down(queryRunner) {
8174
- debug13("migration: reverting DigitalCredential tables");
8089
+ debug13("migration: reverting contacts tables");
8175
8090
  const dbType = queryRunner.connection.driver.options.type;
8176
8091
  switch (dbType) {
8177
8092
  case "postgres": {
8178
- debug13("using postgres migration file for DigitalCredential");
8179
- const mig = new CreateDigitalCredential1708525189001();
8093
+ debug13("using postgres migration file");
8094
+ const mig = new CreateContacts1690925872592();
8180
8095
  await mig.down(queryRunner);
8181
- debug13("Postgres Migration statements for DigitalCredential reverted");
8096
+ debug13("Migration statements executed");
8182
8097
  return;
8183
8098
  }
8184
8099
  case "sqlite":
8185
8100
  case "expo":
8186
8101
  case "react-native": {
8187
- debug13("using sqlite/react-native migration file for DigitalCredential");
8188
- const mig = new CreateDigitalCredential1708525189002();
8102
+ debug13("using sqlite/react-native migration file");
8103
+ const mig = new CreateContacts1690925872693();
8189
8104
  await mig.down(queryRunner);
8190
- debug13("SQLite Migration statements for DigitalCredential reverted");
8105
+ debug13("Migration statements executed");
8191
8106
  return;
8192
8107
  }
8193
8108
  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`);
8109
+ 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
8110
  }
8196
8111
  }
8197
8112
  };
8198
8113
 
8199
- // src/migrations/generic/7-CreateMachineStateStore.ts
8114
+ // src/migrations/generic/4-CreateStatusList.ts
8200
8115
  import Debug14 from "debug";
8201
8116
 
8202
- // src/migrations/postgres/1708797018115-CreateMachineStateStore.ts
8203
- var CreateMachineStateStore1708797018115 = class {
8117
+ // src/migrations/postgres/1693866470001-CreateStatusList.ts
8118
+ var CreateStatusList1693866470001 = class {
8204
8119
  static {
8205
- __name(this, "CreateMachineStateStore1708797018115");
8120
+ __name(this, "CreateStatusList1693866470001");
8206
8121
  }
8207
- name = "CreateMachineStateStore1708797018115";
8122
+ name = "CreateStatusList1693866470001";
8208
8123
  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
- `);
8124
+ await queryRunner.query(`CREATE TYPE "StatusList_type_enum" AS ENUM('StatusList2021')`);
8125
+ await queryRunner.query(`CREATE TYPE "StatusList_drivertype_enum" AS ENUM('agent_typeorm', 'agent_kv_store', 'github', 'agent_filesystem')`);
8126
+ await queryRunner.query(`CREATE TYPE "StatusList_credentialidmode_enum" AS ENUM('ISSUANCE', 'PERSISTENCE', 'NEVER')`);
8127
+ await queryRunner.query(`CREATE TABLE "StatusListEntry"
8128
+ (
8129
+ "statusListId" character varying NOT NULL,
8130
+ "statusListIndex" integer NOT NULL,
8131
+ "credentialId" character varying,
8132
+ "credentialHash" character varying(128),
8133
+ "correlationId" character varying(255),
8134
+ "value" character varying(50),
8135
+ CONSTRAINT "PK_68704d2d13857360c6b44a3d1d0" PRIMARY KEY ("statusListId", "statusListIndex")
8136
+ )`);
8137
+ await queryRunner.query(`CREATE TABLE "StatusList"
8138
+ (
8139
+ "id" character varying NOT NULL,
8140
+ "correlationId" character varying NOT NULL,
8141
+ "length" integer NOT NULL,
8142
+ "issuer" text NOT NULL,
8143
+ "type" "StatusList_type_enum" NOT NULL DEFAULT 'StatusList2021',
8144
+ "driverType" "StatusList_drivertype_enum" NOT NULL DEFAULT 'agent_typeorm',
8145
+ "credentialIdMode" "StatusList_credentialidmode_enum" NOT NULL DEFAULT 'ISSUANCE',
8146
+ "proofFormat" character varying NOT NULL DEFAULT 'lds',
8147
+ "indexingDirection" character varying NOT NULL DEFAULT 'rightToLeft',
8148
+ "statusPurpose" character varying NOT NULL DEFAULT 'revocation',
8149
+ "statusListCredential" text,
8150
+ CONSTRAINT "UQ_correlationId" UNIQUE ("correlationId"),
8151
+ CONSTRAINT "PK_StatusList_Id" PRIMARY KEY ("id")
8152
+ )`);
8153
+ await queryRunner.query(`ALTER TABLE "StatusListEntry"
8154
+ ADD CONSTRAINT "FK_statusListEntry_statusListId" FOREIGN KEY ("statusListId") REFERENCES "StatusList" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION`);
8226
8155
  }
8227
8156
  async down(queryRunner) {
8228
- await queryRunner.query(`DROP TABLE "MachineStateInfoEntity"`);
8157
+ await queryRunner.query(`ALTER TABLE "StatusListEntry"
8158
+ DROP CONSTRAINT "FK_statusListEntry_statusListId"`);
8159
+ await queryRunner.query(`DROP TABLE "StatusListEntry"`);
8160
+ await queryRunner.query(`DROP TABLE "StatusList"`);
8161
+ await queryRunner.query(`DROP TYPE "StatusList_credentialidmode_enum"`);
8162
+ await queryRunner.query(`DROP TYPE "StatusList_drivertype_enum"`);
8163
+ await queryRunner.query(`DROP TYPE "StatusList_type_enum"`);
8229
8164
  }
8230
8165
  };
8231
8166
 
8232
- // src/migrations/sqlite/1708796002272-CreateMachineStateStore.ts
8233
- var CreateMachineStateStore1708796002272 = class {
8167
+ // src/migrations/sqlite/1693866470000-CreateStatusList.ts
8168
+ var CreateStatusList1693866470002 = class {
8234
8169
  static {
8235
- __name(this, "CreateMachineStateStore1708796002272");
8170
+ __name(this, "CreateStatusList1693866470002");
8236
8171
  }
8237
- name = "CreateMachineStateStore1708796002272";
8172
+ name = "CreateStatusList1693866470002";
8173
+ async up(queryRunner) {
8174
+ await queryRunner.query(`CREATE TABLE "StatusListEntry"
8175
+ (
8176
+ "statusListId" varchar NOT NULL,
8177
+ "statusListIndex" integer NOT NULL,
8178
+ "credentialId" varchar,
8179
+ "credentialHash" varchar(128),
8180
+ "correlationId" varchar(255),
8181
+ "value" varchar(50),
8182
+ PRIMARY KEY ("statusListId", "statusListIndex")
8183
+ )`);
8184
+ await queryRunner.query(`CREATE TABLE "StatusList"
8185
+ (
8186
+ "id" varchar PRIMARY KEY NOT NULL,
8187
+ "correlationId" varchar NOT NULL,
8188
+ "length" integer NOT NULL,
8189
+ "issuer" text NOT NULL,
8190
+ "type" varchar CHECK ( "type" IN ('StatusList2021') ) NOT NULL DEFAULT ('StatusList2021'),
8191
+ "driverType" varchar CHECK ( "driverType" IN ('agent_typeorm', 'agent_kv_store', 'github',
8192
+ 'agent_filesystem') ) NOT NULL DEFAULT ('agent_typeorm'),
8193
+ "credentialIdMode" varchar CHECK ( "credentialIdMode" IN ('ISSUANCE', 'PERSISTENCE', 'NEVER') ) NOT NULL DEFAULT ('ISSUANCE'),
8194
+ "proofFormat" varchar CHECK ( "proofFormat" IN ('lds', 'jwt') ) NOT NULL DEFAULT ('lds'),
8195
+ "indexingDirection" varchar CHECK ( "indexingDirection" IN ('rightToLeft') ) NOT NULL DEFAULT ('rightToLeft'),
8196
+ "statusPurpose" varchar NOT NULL DEFAULT ('revocation'),
8197
+ "statusListCredential" text,
8198
+ CONSTRAINT "UQ_correlationId" UNIQUE ("correlationId")
8199
+ )`);
8200
+ await queryRunner.query(`CREATE TABLE "temporary_StatusListEntry"
8201
+ (
8202
+ "statusListId" varchar NOT NULL,
8203
+ "statusListIndex" integer NOT NULL,
8204
+ "credentialId" varchar,
8205
+ "credentialHash" varchar(128),
8206
+ "correlationId" varchar(255),
8207
+ "value" varchar(50),
8208
+ CONSTRAINT "FK_statusListEntry_statusListId" FOREIGN KEY ("statusListId") REFERENCES "StatusList" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION,
8209
+ PRIMARY KEY ("statusListId", "statusListIndex")
8210
+ )`);
8211
+ await queryRunner.query(`INSERT INTO "temporary_StatusListEntry"("statusListId", "statusListIndex", "credentialId",
8212
+ "credentialHash", "correlationId", "value")
8213
+ SELECT "statusListId", "statusListIndex", "credentialId", "credentialHash", "correlationId", "value"
8214
+ FROM "StatusListEntry"`);
8215
+ await queryRunner.query(`DROP TABLE "StatusListEntry"`);
8216
+ await queryRunner.query(`ALTER TABLE "temporary_StatusListEntry" RENAME TO "StatusListEntry"`);
8217
+ }
8218
+ async down(queryRunner) {
8219
+ await queryRunner.query(`DROP TABLE "StatusListEntry"`);
8220
+ await queryRunner.query(`DROP TABLE "StatusList"`);
8221
+ }
8222
+ };
8223
+
8224
+ // src/migrations/postgres/1737110469001-UpdateStatusList.ts
8225
+ var UpdateStatusList1737110469001 = class {
8226
+ static {
8227
+ __name(this, "UpdateStatusList1737110469001");
8228
+ }
8229
+ name = "UpdateStatusList1737110469001";
8230
+ async up(queryRunner) {
8231
+ await queryRunner.query(`ALTER TYPE "StatusList_type_enum" ADD VALUE 'OAuthStatusList'`);
8232
+ await queryRunner.query(`ALTER TABLE "StatusList" ALTER COLUMN "indexingDirection" DROP NOT NULL`);
8233
+ await queryRunner.query(`ALTER TABLE "StatusList" ALTER COLUMN "statusPurpose" DROP NOT NULL`);
8234
+ await queryRunner.query(`ALTER TABLE "StatusList" ADD "bitsPerStatus" integer DEFAULT 1`);
8235
+ await queryRunner.query(`ALTER TABLE "StatusList" ADD "expiresAt" timestamp with time zone`);
8236
+ }
8237
+ async down(queryRunner) {
8238
+ await queryRunner.query(`ALTER TABLE "StatusList" DROP COLUMN "expiresAt"`);
8239
+ await queryRunner.query(`ALTER TABLE "StatusList" DROP COLUMN "bitsPerStatus"`);
8240
+ await queryRunner.query(`ALTER TABLE "StatusList" ALTER COLUMN "statusPurpose" SET NOT NULL`);
8241
+ await queryRunner.query(`ALTER TABLE "StatusList" ALTER COLUMN "indexingDirection" SET NOT NULL`);
8242
+ }
8243
+ };
8244
+
8245
+ // src/migrations/sqlite/1737110469000-UpdateStatusList.ts
8246
+ var UpdateStatusList1737110469000 = class {
8247
+ static {
8248
+ __name(this, "UpdateStatusList1737110469000");
8249
+ }
8250
+ name = "UpdateStatusList1737110469000";
8238
8251
  async up(queryRunner) {
8252
+ await queryRunner.query(`CREATE TABLE "temporary_StatusList" (
8253
+ "id" varchar PRIMARY KEY NOT NULL,
8254
+ "correlationId" varchar NOT NULL,
8255
+ "length" integer NOT NULL,
8256
+ "issuer" text NOT NULL,
8257
+ "type" varchar CHECK( "type" IN ('StatusList2021', 'OAuthStatusList') ) NOT NULL DEFAULT ('StatusList2021'),
8258
+ "driverType" varchar CHECK( "driverType" IN ('agent_typeorm','agent_kv_store','github','agent_filesystem') ) NOT NULL DEFAULT ('agent_typeorm'),
8259
+ "credentialIdMode" varchar CHECK( "credentialIdMode" IN ('ISSUANCE','PERSISTENCE','NEVER') ) NOT NULL DEFAULT ('ISSUANCE'),
8260
+ "proofFormat" varchar CHECK( "proofFormat" IN ('lds','jwt') ) NOT NULL DEFAULT ('lds'),
8261
+ "indexingDirection" varchar CHECK( "indexingDirection" IN ('rightToLeft') ),
8262
+ "statusPurpose" varchar,
8263
+ "statusListCredential" text,
8264
+ "bitsPerStatus" integer,
8265
+ "expiresAt" datetime,
8266
+ CONSTRAINT "UQ_correlationId" UNIQUE ("correlationId")
8267
+ )`);
8268
+ await queryRunner.query(`INSERT INTO "temporary_StatusList"(
8269
+ "id", "correlationId", "length", "issuer", "type", "driverType",
8270
+ "credentialIdMode", "proofFormat", "indexingDirection", "statusPurpose",
8271
+ "statusListCredential"
8272
+ )
8273
+ SELECT
8274
+ "id", "correlationId", "length", "issuer", "type", "driverType",
8275
+ "credentialIdMode", "proofFormat", "indexingDirection", "statusPurpose",
8276
+ "statusListCredential"
8277
+ FROM "StatusList"`);
8278
+ await queryRunner.query(`DROP TABLE "StatusList"`);
8279
+ await queryRunner.query(`ALTER TABLE "temporary_StatusList" RENAME TO "StatusList"`);
8280
+ }
8281
+ async down(queryRunner) {
8239
8282
  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
8283
+ ALTER TABLE "StatusListEntry"
8284
+ RENAME COLUMN "entryCorrelationId" TO "correlationId"
8285
+ `);
8286
+ await queryRunner.query(`
8287
+ ALTER TABLE "StatusListEntry"
8288
+ DROP COLUMN "statusListCorrelationId"
8289
+ `);
8290
+ await queryRunner.query(`CREATE TABLE "temporary_StatusList" (
8291
+ "id" varchar PRIMARY KEY NOT NULL,
8292
+ "correlationId" varchar NOT NULL,
8293
+ "length" integer NOT NULL,
8294
+ "issuer" text NOT NULL,
8295
+ "type" varchar CHECK( "type" IN ('StatusList2021') ) NOT NULL DEFAULT ('StatusList2021'),
8296
+ "driverType" varchar CHECK( "driverType" IN ('agent_typeorm','agent_kv_store','github','agent_filesystem') ) NOT NULL DEFAULT ('agent_typeorm'),
8297
+ "credentialIdMode" varchar CHECK( "credentialIdMode" IN ('ISSUANCE','PERSISTENCE','NEVER') ) NOT NULL DEFAULT ('ISSUANCE'),
8298
+ "proofFormat" varchar CHECK( "proofFormat" IN ('lds','jwt') ) NOT NULL DEFAULT ('lds'),
8299
+ "indexingDirection" varchar CHECK( "indexingDirection" IN ('rightToLeft') ) NOT NULL DEFAULT ('rightToLeft'),
8300
+ "statusPurpose" varchar NOT NULL DEFAULT ('revocation'),
8301
+ "statusListCredential" text,
8302
+ CONSTRAINT "UQ_correlationId" UNIQUE ("correlationId")
8303
+ )`);
8304
+ await queryRunner.query(`INSERT INTO "temporary_StatusList"(
8305
+ "id", "correlationId", "length", "issuer", "type", "driverType",
8306
+ "credentialIdMode", "proofFormat", "indexingDirection", "statusPurpose",
8307
+ "statusListCredential"
8253
8308
  )
8254
- `);
8255
- }
8256
- async down(queryRunner) {
8257
- await queryRunner.query(`DROP TABLE "MachineStateInfoEntity"`);
8309
+ SELECT
8310
+ "id", "correlationId", "length", "issuer",
8311
+ CASE WHEN "type" = 'OAuthStatusList' THEN 'StatusList2021' ELSE "type" END,
8312
+ "driverType", "credentialIdMode", "proofFormat", "indexingDirection",
8313
+ COALESCE("statusPurpose", 'revocation'), "statusListCredential"
8314
+ FROM "StatusList"`);
8315
+ await queryRunner.query(`DROP TABLE "StatusList"`);
8316
+ await queryRunner.query(`ALTER TABLE "temporary_StatusList" RENAME TO "StatusList"`);
8258
8317
  }
8259
8318
  };
8260
8319
 
8261
- // src/migrations/generic/7-CreateMachineStateStore.ts
8320
+ // src/migrations/generic/4-CreateStatusList.ts
8262
8321
  var debug14 = Debug14("sphereon:ssi-sdk:migrations");
8263
- var CreateMachineStateStore1708098041262 = class {
8322
+ var CreateStatusList1693866470000 = class {
8264
8323
  static {
8265
- __name(this, "CreateMachineStateStore1708098041262");
8324
+ __name(this, "CreateStatusList1693866470000");
8266
8325
  }
8267
- name = "CreateMachineStateStore1708098041262";
8326
+ name = "CreateStatusList1693866470000";
8268
8327
  async up(queryRunner) {
8269
- debug14("migration: creating machine state tables");
8328
+ debug14("migration: creating issuance branding tables");
8270
8329
  const dbType = queryRunner.connection.driver.options.type;
8271
- switch (dbType) {
8272
- case "postgres": {
8273
- debug14("using postgres migration file");
8274
- const mig = new CreateMachineStateStore1708797018115();
8275
- await mig.up(queryRunner);
8276
- debug14("Migration statements executed");
8277
- return;
8278
- }
8279
- case "sqlite":
8280
- case "expo":
8281
- case "react-native": {
8282
- debug14("using sqlite/react-native migration file");
8283
- const mig = new CreateMachineStateStore1708796002272();
8284
- await mig.up(queryRunner);
8285
- debug14("Migration statements executed");
8286
- return;
8287
- }
8288
- default:
8289
- return Promise.reject(`Migrations are currently only supported for sqlite, react-native, expo and postgres. Was ${dbType}. Please run your database without migrations and with 'migrationsRun: false' and 'synchronize: true' for now`);
8330
+ if (dbType === "postgres") {
8331
+ debug14("using postgres migration files");
8332
+ const createMig = new CreateStatusList1693866470001();
8333
+ await createMig.up(queryRunner);
8334
+ const updateMig = new UpdateStatusList1737110469001();
8335
+ const up = await updateMig.up(queryRunner);
8336
+ debug14("Migration statements executed");
8337
+ return up;
8338
+ } else if (dbType === "sqlite" || dbType === "react-native" || dbType === "expo") {
8339
+ debug14("using sqlite/react-native migration files");
8340
+ const createMig = new CreateStatusList1693866470002();
8341
+ await createMig.up(queryRunner);
8342
+ const updateMig = new UpdateStatusList1737110469000();
8343
+ const up = await updateMig.up(queryRunner);
8344
+ debug14("Migration statements executed");
8345
+ return up;
8346
+ } else {
8347
+ return Promise.reject(`Migrations are currently only supported for sqlite, react-native, expo and postgres. Was ${dbType}. Please run your database without migrations and with 'migrationsRun: false' and 'synchronize: true' for now`);
8290
8348
  }
8291
8349
  }
8292
8350
  async down(queryRunner) {
8293
- debug14("migration: reverting machine state tables");
8351
+ debug14("migration: reverting issuance branding tables");
8294
8352
  const dbType = queryRunner.connection.driver.options.type;
8295
- switch (dbType) {
8296
- case "postgres": {
8297
- debug14("using postgres migration file");
8298
- const mig = new CreateMachineStateStore1708797018115();
8299
- await mig.down(queryRunner);
8300
- debug14("Migration statements executed");
8301
- return;
8302
- }
8303
- case "sqlite":
8304
- case "expo":
8305
- case "react-native": {
8306
- debug14("using sqlite/react-native migration file");
8307
- const mig = new CreateMachineStateStore1708796002272();
8308
- await mig.down(queryRunner);
8309
- debug14("Migration statements executed");
8310
- return;
8311
- }
8312
- default:
8313
- return Promise.reject(`Migrations are currently only supported for sqlite, react-native, expo and postgres. Was ${dbType}. Please run your database without migrations and with 'migrationsRun: false' and 'synchronize: true' for now`);
8353
+ if (dbType === "postgres") {
8354
+ debug14("using postgres migration files");
8355
+ const updateMig = new UpdateStatusList1737110469001();
8356
+ await updateMig.down(queryRunner);
8357
+ const createMig = new CreateStatusList1693866470001();
8358
+ const down = await createMig.down(queryRunner);
8359
+ debug14("Migration statements executed");
8360
+ return down;
8361
+ } else if (dbType === "sqlite" || dbType === "react-native" || dbType === "expo") {
8362
+ debug14("using sqlite/react-native migration files");
8363
+ const updateMig = new UpdateStatusList1737110469000();
8364
+ await updateMig.down(queryRunner);
8365
+ const createMig = new CreateStatusList1693866470002();
8366
+ const down = await createMig.down(queryRunner);
8367
+ debug14("Migration statements executed");
8368
+ return down;
8369
+ } else {
8370
+ return Promise.reject(`Migrations are currently only supported for sqlite, react-native, expo and postgres. Was ${dbType}. Please run your database without migrations and with 'migrationsRun: false' and 'synchronize: true' for now`);
8314
8371
  }
8315
8372
  }
8316
8373
  };
8317
8374
 
8318
- // src/migrations/generic/8-CreateContacts.ts
8375
+ // src/migrations/generic/5-CreateAuditEvents.ts
8319
8376
  import Debug15 from "debug";
8320
8377
 
8321
- // src/migrations/postgres/1710438363001-CreateContacts.ts
8322
- var CreateContacts1710438363001 = class {
8378
+ // src/migrations/sqlite/1701634819487-CreateAuditEvents.ts
8379
+ var CreateAuditEvents1701634819487 = class {
8323
8380
  static {
8324
- __name(this, "CreateContacts1710438363001");
8381
+ __name(this, "CreateAuditEvents1701634819487");
8325
8382
  }
8326
- name = "CreateContacts1710438363001";
8383
+ name = "CreateAuditEvents1701634819487";
8327
8384
  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`);
8385
+ await queryRunner.query(`CREATE TABLE "AuditEvents" (
8386
+ "id" varchar PRIMARY KEY NOT NULL,
8387
+ "eventType" varchar CHECK( "eventType" IN ('audit','activity','general') ) NOT NULL,
8388
+ "timestamp" datetime NOT NULL,
8389
+ "level" varchar CHECK( "level" IN ('0','1','2','3','4') ) NOT NULL,
8390
+ "correlationId" varchar NOT NULL,
8391
+ "system" varchar CHECK( "system" IN ('general','kms','identity','oid4vci','oid4vp','siopv2','PE','credentials','web3','profile','contact') ) NOT NULL,
8392
+ "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,
8393
+ "actionType" varchar CHECK( "actionType" IN ('create','read','update','delete','execute') ) NOT NULL,
8394
+ "actionSubType" varchar NOT NULL,
8395
+ "initiatorType" varchar CHECK( "initiatorType" IN ('user','system','external') ) NOT NULL,
8396
+ "systemCorrelationIdType" varchar CHECK( "systemCorrelationIdType" IN ('did','url','email','hostname','phone','user') ),
8397
+ "systemCorrelationId" varchar,
8398
+ "systemAlias" varchar,
8399
+ "partyCorrelationType" varchar CHECK( "partyCorrelationType" IN ('did','url','email','hostname','phone') ),
8400
+ "partyCorrelationId" varchar,
8401
+ "partyAlias" varchar,
8402
+ "credentialType" varchar CHECK( "credentialType" IN ('JSON_LD','JWT','SD_JWT','MSO_MDOC') ),
8403
+ "credentialHash" varchar,
8404
+ "parentCredentialHash" varchar,
8405
+ "originalCredential" varchar,
8406
+ "sharePurpose" varchar,
8407
+ "description" varchar NOT NULL,
8408
+ "data" varchar,
8409
+ "diagnosticData" varchar,
8410
+ "created_at" datetime NOT NULL DEFAULT (datetime('now')),
8411
+ "last_updated_at" datetime NOT NULL DEFAULT (datetime('now')))`);
8346
8412
  }
8347
8413
  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"`);
8414
+ await queryRunner.query(`DROP TABLE "AuditEvents"`);
8366
8415
  }
8367
8416
  };
8368
8417
 
8369
- // src/migrations/sqlite/1710438363002-CreateContacts.ts
8370
- var CreateContacts1710438363002 = class {
8418
+ // src/migrations/postgres/1701634812183-CreateAuditEvents.ts
8419
+ var CreateAuditEvents1701634812183 = class {
8371
8420
  static {
8372
- __name(this, "CreateContacts1710438363002");
8421
+ __name(this, "CreateAuditEvents1701634812183");
8373
8422
  }
8374
- name = "CreateContacts1710438363002";
8423
+ name = "CreateAuditEvents1701634812183";
8375
8424
  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`);
8425
+ await queryRunner.query(`CREATE TYPE "public"."Level_enum" AS ENUM('0', '1', '2', '3', '4')`);
8426
+ await queryRunner.query(`CREATE TYPE "public"."System_enum" AS ENUM('general', 'kms', 'identity', 'oid4vci', 'oid4vp', 'siopv2', 'PE', 'credentials', 'web3', 'profile', 'contact')`);
8427
+ 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')`);
8428
+ await queryRunner.query(`CREATE TYPE "public"."Action_type_enum" AS ENUM('create', 'read', 'update', 'delete', 'execute')`);
8429
+ await queryRunner.query(`CREATE TYPE "public"."Initiator_type_enum" AS ENUM('user', 'system', 'external')`);
8430
+ await queryRunner.query(`CREATE TYPE "public"."System_correlation_id_type_enum" AS ENUM('did', 'url', 'email', 'hostname', 'phone', 'user')`);
8431
+ await queryRunner.query(`CREATE TYPE "public"."Party_correlation_type_enum" AS ENUM('did', 'url', 'email', 'hostname', 'phone')`);
8432
+ await queryRunner.query(`CREATE TYPE "public"."Event_type_enum" AS ENUM('audit', 'activity', 'general')`);
8433
+ await queryRunner.query(`CREATE TYPE "public"."Event_credential_type_enum" AS ENUM('JSON_LD', 'JWT', 'SD_JWT', 'MSO_MDOC')`);
8434
+ await queryRunner.query(`CREATE TABLE "AuditEvents" (
8435
+ "id" uuid NOT NULL DEFAULT uuid_generate_v4(),
8436
+ "eventType" "public"."Event_type_enum" NOT NULL,
8437
+ "timestamp" TIMESTAMP NOT NULL,
8438
+ "level" "public"."Level_enum" NOT NULL,
8439
+ "correlationId" TEXT NOT NULL,
8440
+ "system" "public"."System_enum" NOT NULL,
8441
+ "subSystemType" "public"."Subsystem_type_enum" NOT NULL,
8442
+ "actionType" "public"."Action_type_enum" NOT NULL,
8443
+ "actionSubType" TEXT NOT NULL,
8444
+ "initiatorType" "public"."Initiator_type_enum" NOT NULL,
8445
+ "systemCorrelationIdType" "public"."System_correlation_id_type_enum",
8446
+ "systemCorrelationId" TEXT,
8447
+ "systemAlias" TEXT,
8448
+ "partyCorrelationType" "public"."Party_correlation_type_enum",
8449
+ "partyCorrelationId" TEXT,
8450
+ "partyAlias" TEXT,
8451
+ "credentialType" "public"."Event_credential_type_enum",
8452
+ "credentialHash" TEXT,
8453
+ "originalCredential" TEXT,
8454
+ "sharePurpose" TEXT,
8455
+ "description" TEXT NOT NULL,
8456
+ "data" TEXT,
8457
+ "diagnosticData" TEXT,
8458
+ "created_at" TIMESTAMP NOT NULL DEFAULT now(),
8459
+ "last_updated_at" TIMESTAMP NOT NULL DEFAULT now(),
8460
+ CONSTRAINT "PK_AuditEvents_id" PRIMARY KEY ("id"))`);
8409
8461
  }
8410
8462
  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"`);
8463
+ await queryRunner.query(`DROP TABLE "AuditEvents"`);
8464
+ await queryRunner.query(`DROP TYPE "public"."Party_correlation_type_enum"`);
8465
+ await queryRunner.query(`DROP TYPE "public"."System_correlation_id_type_enum"`);
8466
+ await queryRunner.query(`DROP TYPE "public"."Initiator_type_enum"`);
8467
+ await queryRunner.query(`DROP TYPE "public"."Action_type_enum"`);
8468
+ await queryRunner.query(`DROP TYPE "public"."Subsystem_type_enum"`);
8469
+ await queryRunner.query(`DROP TYPE "public"."System_enum"`);
8470
+ await queryRunner.query(`DROP TYPE "public"."Level_enum"`);
8429
8471
  }
8430
8472
  };
8431
8473
 
8432
- // src/migrations/generic/8-CreateContacts.ts
8474
+ // src/migrations/generic/5-CreateAuditEvents.ts
8433
8475
  var debug15 = Debug15("sphereon:ssi-sdk:migrations");
8434
- var CreateContacts1708525189000 = class {
8476
+ var CreateAuditEvents1701635835330 = class {
8435
8477
  static {
8436
- __name(this, "CreateContacts1708525189000");
8478
+ __name(this, "CreateAuditEvents1701635835330");
8437
8479
  }
8438
- name = "CreateContacts1708525189000";
8480
+ name = "CreateAuditEvents1701635835330";
8439
8481
  async up(queryRunner) {
8440
- debug15("migration: updating contact tables");
8482
+ debug15("migration: creating audit events tables");
8441
8483
  const dbType = queryRunner.connection.driver.options.type;
8442
8484
  switch (dbType) {
8443
8485
  case "postgres": {
8444
8486
  debug15("using postgres migration file");
8445
- const mig = new CreateContacts1710438363001();
8487
+ const mig = new CreateAuditEvents1701634812183();
8446
8488
  await mig.up(queryRunner);
8447
8489
  debug15("Migration statements executed");
8448
8490
  return;
@@ -8451,7 +8493,7 @@ var CreateContacts1708525189000 = class {
8451
8493
  case "expo":
8452
8494
  case "react-native": {
8453
8495
  debug15("using sqlite/react-native migration file");
8454
- const mig = new CreateContacts1710438363002();
8496
+ const mig = new CreateAuditEvents1701634819487();
8455
8497
  await mig.up(queryRunner);
8456
8498
  debug15("Migration statements executed");
8457
8499
  return;
@@ -8461,12 +8503,12 @@ var CreateContacts1708525189000 = class {
8461
8503
  }
8462
8504
  }
8463
8505
  async down(queryRunner) {
8464
- debug15("migration: reverting machine state tables");
8506
+ debug15("migration: reverting audit events tables");
8465
8507
  const dbType = queryRunner.connection.driver.options.type;
8466
8508
  switch (dbType) {
8467
8509
  case "postgres": {
8468
8510
  debug15("using postgres migration file");
8469
- const mig = new CreateContacts1710438363001();
8511
+ const mig = new CreateAuditEvents1701634812183();
8470
8512
  await mig.down(queryRunner);
8471
8513
  debug15("Migration statements executed");
8472
8514
  return;
@@ -8475,7 +8517,7 @@ var CreateContacts1708525189000 = class {
8475
8517
  case "expo":
8476
8518
  case "react-native": {
8477
8519
  debug15("using sqlite/react-native migration file");
8478
- const mig = new CreateContacts1710438363002();
8520
+ const mig = new CreateAuditEvents1701634819487();
8479
8521
  await mig.down(queryRunner);
8480
8522
  debug15("Migration statements executed");
8481
8523
  return;
@@ -8486,243 +8528,247 @@ var CreateContacts1708525189000 = class {
8486
8528
  }
8487
8529
  };
8488
8530
 
8489
- // src/migrations/generic/9-CreateContacts.ts
8531
+ // src/migrations/generic/6-CreateDigitalCredential.ts
8490
8532
  import Debug16 from "debug";
8491
8533
 
8492
- // src/migrations/postgres/1715761125001-CreateContacts.ts
8493
- var CreateContacts1715761125001 = class {
8534
+ // src/migrations/postgres/1708525189001-CreateDigitalCredential.ts
8535
+ var CreateDigitalCredential1708525189001 = class {
8494
8536
  static {
8495
- __name(this, "CreateContacts1715761125001");
8537
+ __name(this, "CreateDigitalCredential1708525189001");
8496
8538
  }
8497
- name = "CreateContacts1715761125001";
8539
+ name = "CreateDigitalCredential1708525189001";
8498
8540
  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
- )`);
8541
+ await queryRunner.query(`CREATE TYPE "digital_document_type" AS ENUM('VC', 'VP', 'C', 'P')`);
8542
+ await queryRunner.query(`CREATE TYPE "digital_regulation_type" AS ENUM('PID', 'QEAA', 'EAA', 'NON_REGULATED')`);
8543
+ await queryRunner.query(`CREATE TYPE "digital_credential_document_format" AS ENUM('JSON_LD', 'JWT', 'SD_JWT', 'MSO_MDOC')`);
8544
+ await queryRunner.query(`CREATE TYPE "digital_credential_credential_role" AS ENUM('ISSUER', 'VERIFIER', 'HOLDER', 'FEDERATION_TRUST_ANCHOR')`);
8545
+ await queryRunner.query(`CREATE TYPE "digital_credential_correlation_type" AS ENUM('DID', 'KID', 'URL', 'X509_SAN')`);
8546
+ await queryRunner.query(`CREATE TYPE "digital_credential_state_type" AS ENUM('REVOKED', 'VERIFIED', 'EXPIRED')`);
8547
+ await queryRunner.query(`
8548
+ CREATE TABLE "DigitalCredential" (
8549
+ "id" uuid NOT NULL DEFAULT uuid_generate_v4(),
8550
+ "parent_id" text,
8551
+ "document_type" "digital_document_type" NOT NULL,
8552
+ "regulation_type" "digital_regulation_type" NOT NULL DEFAULT 'NON_REGULATED'::"digital_regulation_type",
8553
+ "document_format" "digital_credential_document_format" NOT NULL,
8554
+ "credential_role" "digital_credential_credential_role" NOT NULL,
8555
+ "raw_document" text NOT NULL,
8556
+ "uniform_document" text NOT NULL,
8557
+ "credential_id" text,
8558
+ "hash" text NOT NULL,
8559
+ "kms_key_ref" text,
8560
+ "identifier_method" text,
8561
+ "issuer_correlation_type" "digital_credential_correlation_type" NOT NULL,
8562
+ "subject_correlation_type" "digital_credential_correlation_type",
8563
+ "issuer_correlation_id" text NOT NULL,
8564
+ "subject_correlation_id" text,
8565
+ "verified_state" "digital_credential_state_type",
8566
+ "issuer_signed" boolean,
8567
+ "rp_correlation_id" text,
8568
+ "rp_correlation_type" "digital_credential_correlation_type",
8569
+ "tenant_id" text,
8570
+ "created_at" TIMESTAMP NOT NULL DEFAULT now(),
8571
+ "last_updated_at" TIMESTAMP NOT NULL DEFAULT now(),
8572
+ "presented_at" DATE,
8573
+ "valid_from" DATE,
8574
+ "valid_until" DATE,
8575
+ "verified_at" DATE,
8576
+ "revoked_at" DATE,
8577
+ PRIMARY KEY ("id"),
8578
+ UNIQUE ("hash", "credential_role")
8579
+ )
8580
+ `);
8528
8581
  }
8529
8582
  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"`);
8583
+ await queryRunner.query(`DROP TABLE "DigitalCredential"`);
8584
+ await queryRunner.query(`DROP TYPE "digital_credential_state_type"`);
8585
+ await queryRunner.query(`DROP TYPE "digital_credential_correlation_type"`);
8586
+ await queryRunner.query(`DROP TYPE "digital_credential_document_format"`);
8587
+ await queryRunner.query(`DROP TYPE "digital_credential_credential_role"`);
8588
+ await queryRunner.query(`DROP TYPE "digital_regulation_type"`);
8589
+ await queryRunner.query(`DROP TYPE "digital_document_type"`);
8544
8590
  }
8545
8591
  };
8546
8592
 
8547
- // src/migrations/sqlite/1715761125002-CreateContacts.ts
8548
- var CreateContacts1715761125002 = class {
8593
+ // src/migrations/sqlite/1708525189002-CreateDigitalCredential.ts
8594
+ var CreateDigitalCredential1708525189002 = class {
8549
8595
  static {
8550
- __name(this, "CreateContacts1715761125002");
8596
+ __name(this, "CreateDigitalCredential1708525189002");
8551
8597
  }
8552
- name = "CreateContacts1715761125002";
8598
+ name = "CreateDigitalCredential1708525189002";
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"
8600
+ await queryRunner.query(`
8601
+ CREATE TABLE "DigitalCredential" (
8602
+ "id" varchar PRIMARY KEY NOT NULL,
8603
+ "parent_id" text,
8604
+ "document_type" varchar CHECK( "document_type" IN ('VC', 'VP', 'C', 'P') ) NOT NULL,
8605
+ "regulation_type" varchar CHECK( "regulation_type" IN ('PID', 'QEAA', 'EAA', 'NON_REGULATED') ) NOT NULL DEFAULT 'NON_REGULATED',
8606
+ "document_format" varchar CHECK( "document_format" IN ('JSON_LD', 'JWT', 'SD_JWT', 'MSO_MDOC') ) NOT NULL,
8607
+ "credential_role" varchar CHECK( "credential_role" IN ('ISSUER', 'VERIFIER', 'HOLDER', 'FEDERATION_TRUST_ANCHOR') ) NOT NULL,
8608
+ "raw_document" text NOT NULL,
8609
+ "uniform_document" text NOT NULL,
8610
+ "credential_id" text,
8611
+ "hash" text NOT NULL,
8612
+ "kms_key_ref" text,
8613
+ "identifier_method" text,
8614
+ "issuer_correlation_type" varchar CHECK( "issuer_correlation_type" IN ('DID', 'KID', 'URL', 'X509_SAN') ) NOT NULL,
8615
+ "subject_correlation_type" varchar CHECK( "subject_correlation_type" IN ('DID', 'KID', 'URL', 'X509_SAN') ),
8616
+ "issuer_correlation_id" text NOT NULL,
8617
+ "subject_correlation_id" text,
8618
+ "issuer_signed" boolean,
8619
+ "rp_correlation_id" text,
8620
+ "rp_correlation_type" varchar CHECK( "issuer_correlation_type" IN ('DID', 'KID', 'URL', 'X509_SAN') ),
8621
+ "verified_state" varchar CHECK( "verified_state" IN ('REVOKED', 'VERIFIED', 'EXPIRED') ),
8622
+ "tenant_id" text,
8623
+ "created_at" datetime NOT NULL DEFAULT (datetime('now')),
8624
+ "last_updated_at" datetime NOT NULL DEFAULT (datetime('now')),
8625
+ "presented_at" datetime,
8626
+ "valid_from" datetime,
8627
+ "valid_until" datetime,
8628
+ "verified_at" datetime,
8629
+ "revoked_at" datetime,
8630
+ UNIQUE ("hash", "credential_role")
8631
+ )
8569
8632
  `);
8570
- await queryRunner.query(`DROP TABLE "temporary_IdentityMetadata"`);
8571
- await queryRunner.query(`CREATE TABLE "ContactMetadata"
8572
- (
8573
- "id" varchar PRIMARY KEY NOT NULL,
8574
- "label" varchar(255) NOT NULL,
8575
- "valueType" varchar NOT NULL,
8576
- "stringValue" text,
8577
- "numberValue" double,
8578
- "dateValue" datetime,
8579
- "boolValue" boolean,
8580
- "contactId" varchar,
8581
- FOREIGN KEY ("contactId") REFERENCES "BaseContact" ("id") ON DELETE CASCADE)`);
8582
8633
  }
8583
8634
  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"`);
8635
+ await queryRunner.query(`DROP TABLE "DigitalCredential"`);
8598
8636
  }
8599
8637
  };
8600
8638
 
8601
- // src/migrations/generic/9-CreateContacts.ts
8639
+ // src/migrations/generic/6-CreateDigitalCredential.ts
8602
8640
  var debug16 = Debug16("sphereon:ssi-sdk:migrations");
8603
- var CreateContacts1715761125000 = class {
8641
+ var CreateDigitalCredential1708525189000 = class {
8604
8642
  static {
8605
- __name(this, "CreateContacts1715761125000");
8643
+ __name(this, "CreateDigitalCredential1708525189000");
8606
8644
  }
8607
- name = "CreateContacts1715761125000";
8645
+ name = "CreateDigitalCredential1708525189000";
8608
8646
  async up(queryRunner) {
8609
- debug16("migration: updating contact tables");
8647
+ debug16("migration: creating DigitalCredential tables");
8610
8648
  const dbType = queryRunner.connection.driver.options.type;
8611
8649
  switch (dbType) {
8612
8650
  case "postgres": {
8613
- debug16("using postgres migration file");
8614
- const mig = new CreateContacts1715761125001();
8651
+ debug16("using postgres migration file for DigitalCredential");
8652
+ const mig = new CreateDigitalCredential1708525189001();
8615
8653
  await mig.up(queryRunner);
8616
- debug16("Migration statements executed");
8654
+ debug16("Postgres Migration statements for DigitalCredential executed");
8617
8655
  return;
8618
8656
  }
8619
8657
  case "sqlite":
8620
8658
  case "expo":
8621
8659
  case "react-native": {
8622
- debug16("using sqlite/react-native migration file");
8623
- const mig = new CreateContacts1715761125002();
8660
+ debug16("using sqlite/react-native migration file for DigitalCredential");
8661
+ const mig = new CreateDigitalCredential1708525189002();
8624
8662
  await mig.up(queryRunner);
8625
- debug16("Migration statements executed");
8663
+ debug16("SQLite Migration statements for DigitalCredential executed");
8626
8664
  return;
8627
8665
  }
8628
8666
  default:
8629
- return Promise.reject(`Migrations are currently only supported for sqlite, react-native, expo and postgres. Was ${dbType}. Please run your database without migrations and with 'migrationsRun: false' and 'synchronize: true' for now`);
8667
+ return Promise.reject(`Migrations are currently only supported for sqlite, react-native, expo, and postgres for UniformCredential. Was ${dbType}. Please run your database without migrations and with 'migrationsRun: false' and 'synchronize: true' for now`);
8630
8668
  }
8631
8669
  }
8632
8670
  async down(queryRunner) {
8633
- debug16("migration: reverting machine state tables");
8671
+ debug16("migration: reverting DigitalCredential tables");
8634
8672
  const dbType = queryRunner.connection.driver.options.type;
8635
8673
  switch (dbType) {
8636
8674
  case "postgres": {
8637
- debug16("using postgres migration file");
8638
- const mig = new CreateContacts1715761125001();
8675
+ debug16("using postgres migration file for DigitalCredential");
8676
+ const mig = new CreateDigitalCredential1708525189001();
8639
8677
  await mig.down(queryRunner);
8640
- debug16("Migration statements executed");
8678
+ debug16("Postgres Migration statements for DigitalCredential reverted");
8641
8679
  return;
8642
8680
  }
8643
8681
  case "sqlite":
8644
8682
  case "expo":
8645
8683
  case "react-native": {
8646
- debug16("using sqlite/react-native migration file");
8647
- const mig = new CreateContacts1715761125002();
8684
+ debug16("using sqlite/react-native migration file for DigitalCredential");
8685
+ const mig = new CreateDigitalCredential1708525189002();
8648
8686
  await mig.down(queryRunner);
8649
- debug16("Migration statements executed");
8687
+ debug16("SQLite Migration statements for DigitalCredential reverted");
8650
8688
  return;
8651
8689
  }
8652
8690
  default:
8653
- return Promise.reject(`Migrations are currently only supported for sqlite, react-native, expo and postgres. Was ${dbType}. Please run your database without migrations and with 'migrationsRun: false' and 'synchronize: true' for now`);
8691
+ return Promise.reject(`Migrations are currently only supported for sqlite, react-native, expo, and postgres for DigitalCredential. Was ${dbType}. Please run your database without migrations and with 'migrationsRun: false' and 'synchronize: true' for now`);
8654
8692
  }
8655
8693
  }
8656
8694
  };
8657
8695
 
8658
- // src/migrations/generic/10-CreatePresentationDefinitions.ts
8696
+ // src/migrations/generic/7-CreateMachineStateStore.ts
8659
8697
  import Debug17 from "debug";
8660
8698
 
8661
- // src/migrations/postgres/1716475165345-CreatePresentationDefinitions.ts
8662
- var CreatePresentationDefinitions1716475165345 = class {
8699
+ // src/migrations/postgres/1708797018115-CreateMachineStateStore.ts
8700
+ var CreateMachineStateStore1708797018115 = class {
8663
8701
  static {
8664
- __name(this, "CreatePresentationDefinitions1716475165345");
8702
+ __name(this, "CreateMachineStateStore1708797018115");
8665
8703
  }
8666
- name = "CreatePresentationDefinitions1716475165345";
8704
+ name = "CreateMachineStateStore1708797018115";
8667
8705
  async up(queryRunner) {
8668
8706
  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
- `);
8707
+ CREATE TABLE "MachineStateInfoEntity" (
8708
+ "instance_id" text NOT NULL,
8709
+ "session_id" text,
8710
+ "latest_state_name" text,
8711
+ "machine_name" text NOT NULL,
8712
+ "latest_event_type" text NOT NULL,
8713
+ "state" text NOT NULL,
8714
+ "created_at" TIMESTAMP NOT NULL DEFAULT now(),
8715
+ "updated_at" TIMESTAMP NOT NULL DEFAULT now(),
8716
+ "updated_count" integer NOT NULL DEFAULT 0,
8717
+ "expires_at" TIMESTAMP,
8718
+ "completed_at" TIMESTAMP,
8719
+ "tenant_id" text,
8720
+ CONSTRAINT "PK_MachineStateInfoEntity_id" PRIMARY KEY ("instance_id")
8721
+ )
8722
+ `);
8682
8723
  }
8683
8724
  async down(queryRunner) {
8684
- await queryRunner.query(`DROP TABLE "PresentationDefinitionItem"`);
8725
+ await queryRunner.query(`DROP TABLE "MachineStateInfoEntity"`);
8685
8726
  }
8686
8727
  };
8687
8728
 
8688
- // src/migrations/sqlite/1716475165344-CreatePresentationDefinitions.ts
8689
- var CreatePresentationDefinitions1716475165344 = class {
8729
+ // src/migrations/sqlite/1708796002272-CreateMachineStateStore.ts
8730
+ var CreateMachineStateStore1708796002272 = class {
8690
8731
  static {
8691
- __name(this, "CreatePresentationDefinitions1716475165344");
8732
+ __name(this, "CreateMachineStateStore1708796002272");
8692
8733
  }
8693
- name = "CreatePresentationDefinitions1716475165344";
8734
+ name = "CreateMachineStateStore1708796002272";
8694
8735
  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')))`);
8736
+ await queryRunner.query(`
8737
+ CREATE TABLE "MachineStateInfoEntity" (
8738
+ "instance_id" varchar PRIMARY KEY NOT NULL,
8739
+ "session_id" varchar,
8740
+ "machine_name" varchar NOT NULL,
8741
+ "latest_state_name" varchar,
8742
+ "latest_event_type" varchar NOT NULL,
8743
+ "state" text NOT NULL,
8744
+ "created_at" datetime NOT NULL DEFAULT (datetime('now')),
8745
+ "updated_at" datetime NOT NULL DEFAULT (datetime('now')),
8746
+ "updated_count" integer NOT NULL DEFAULT 0,
8747
+ "expires_at" datetime,
8748
+ "completed_at" datetime,
8749
+ "tenant_id" varchar
8750
+ )
8751
+ `);
8706
8752
  }
8707
8753
  async down(queryRunner) {
8708
- await queryRunner.query(`DROP TABLE "PresentationDefinitionItem"`);
8754
+ await queryRunner.query(`DROP TABLE "MachineStateInfoEntity"`);
8709
8755
  }
8710
8756
  };
8711
8757
 
8712
- // src/migrations/generic/10-CreatePresentationDefinitions.ts
8758
+ // src/migrations/generic/7-CreateMachineStateStore.ts
8713
8759
  var debug17 = Debug17("sphereon:ssi-sdk:migrations");
8714
- var CreatePresentationDefinitions1716533767523 = class {
8760
+ var CreateMachineStateStore1708098041262 = class {
8715
8761
  static {
8716
- __name(this, "CreatePresentationDefinitions1716533767523");
8762
+ __name(this, "CreateMachineStateStore1708098041262");
8717
8763
  }
8718
- name = "CreatePresentationDefinitionItems1716533767523";
8764
+ name = "CreateMachineStateStore1708098041262";
8719
8765
  async up(queryRunner) {
8720
8766
  debug17("migration: creating machine state tables");
8721
8767
  const dbType = queryRunner.connection.driver.options.type;
8722
8768
  switch (dbType) {
8723
8769
  case "postgres": {
8724
8770
  debug17("using postgres migration file");
8725
- const mig = new CreatePresentationDefinitions1716475165345();
8771
+ const mig = new CreateMachineStateStore1708797018115();
8726
8772
  await mig.up(queryRunner);
8727
8773
  debug17("Migration statements executed");
8728
8774
  return;
@@ -8731,7 +8777,7 @@ var CreatePresentationDefinitions1716533767523 = class {
8731
8777
  case "expo":
8732
8778
  case "react-native": {
8733
8779
  debug17("using sqlite/react-native migration file");
8734
- const mig = new CreatePresentationDefinitions1716475165344();
8780
+ const mig = new CreateMachineStateStore1708796002272();
8735
8781
  await mig.up(queryRunner);
8736
8782
  debug17("Migration statements executed");
8737
8783
  return;
@@ -8746,7 +8792,7 @@ var CreatePresentationDefinitions1716533767523 = class {
8746
8792
  switch (dbType) {
8747
8793
  case "postgres": {
8748
8794
  debug17("using postgres migration file");
8749
- const mig = new CreatePresentationDefinitions1716475165345();
8795
+ const mig = new CreateMachineStateStore1708797018115();
8750
8796
  await mig.down(queryRunner);
8751
8797
  debug17("Migration statements executed");
8752
8798
  return;
@@ -8755,7 +8801,7 @@ var CreatePresentationDefinitions1716533767523 = class {
8755
8801
  case "expo":
8756
8802
  case "react-native": {
8757
8803
  debug17("using sqlite/react-native migration file");
8758
- const mig = new CreatePresentationDefinitions1716475165344();
8804
+ const mig = new CreateMachineStateStore1708796002272();
8759
8805
  await mig.down(queryRunner);
8760
8806
  debug17("Migration statements executed");
8761
8807
  return;
@@ -8766,97 +8812,134 @@ var CreatePresentationDefinitions1716533767523 = class {
8766
8812
  }
8767
8813
  };
8768
8814
 
8769
- // src/migrations/generic/11-FixCredentialClaimsReferenceUuid.ts
8815
+ // src/migrations/generic/8-CreateContacts.ts
8770
8816
  import Debug18 from "debug";
8771
8817
 
8772
- // src/migrations/postgres/1741895822987-FixCredentialClaimsReferencesUuid.ts
8773
- var FixCredentialClaimsReferencesUuidPG1741895822987 = class {
8818
+ // src/migrations/postgres/1710438363001-CreateContacts.ts
8819
+ var CreateContacts1710438363001 = class {
8774
8820
  static {
8775
- __name(this, "FixCredentialClaimsReferencesUuidPG1741895822987");
8821
+ __name(this, "CreateContacts1710438363001");
8776
8822
  }
8777
- name = "FixCredentialClaimsReferencesUuid1741895822987";
8823
+ name = "CreateContacts1710438363001";
8778
8824
  async up(queryRunner) {
8779
- await queryRunner.query(`
8780
- ALTER TABLE "CredentialClaims"
8781
- ALTER COLUMN "credentialLocaleBrandingId" TYPE uuid USING "credentialLocaleBrandingId"::uuid;
8782
- `);
8825
+ await queryRunner.query(`ALTER TABLE "Party" ADD COLUMN "owner_id" uuid`);
8826
+ await queryRunner.query(`ALTER TABLE "Party" ADD COLUMN "tenant_id" uuid`);
8827
+ await queryRunner.query(`ALTER TABLE "Identity" ADD COLUMN "owner_id" uuid`);
8828
+ await queryRunner.query(`ALTER TABLE "Identity" ADD COLUMN "tenant_id" uuid`);
8829
+ await queryRunner.query(`ALTER TABLE "CorrelationIdentifier" ADD COLUMN "owner_id" uuid`);
8830
+ await queryRunner.query(`ALTER TABLE "CorrelationIdentifier" ADD COLUMN "tenant_id" uuid`);
8831
+ await queryRunner.query(`ALTER TABLE "Connection" ADD COLUMN "owner_id" uuid`);
8832
+ await queryRunner.query(`ALTER TABLE "Connection" ADD COLUMN "tenant_id" uuid`);
8833
+ await queryRunner.query(`ALTER TABLE "BaseConfig" ADD COLUMN "owner_id" uuid`);
8834
+ await queryRunner.query(`ALTER TABLE "BaseConfig" ADD COLUMN "tenant_id" uuid`);
8835
+ await queryRunner.query(`ALTER TABLE "BaseContact" ADD COLUMN "owner_id" uuid`);
8836
+ await queryRunner.query(`ALTER TABLE "BaseContact" ADD COLUMN "tenant_id" uuid`);
8837
+ await queryRunner.query(`ALTER TABLE "PartyRelationship" ADD COLUMN "owner_id" uuid`);
8838
+ await queryRunner.query(`ALTER TABLE "PartyRelationship" ADD COLUMN "tenant_id" uuid`);
8839
+ await queryRunner.query(`ALTER TABLE "ElectronicAddress" ADD COLUMN "owner_id" uuid`);
8840
+ await queryRunner.query(`ALTER TABLE "ElectronicAddress" ADD COLUMN "tenant_id" uuid`);
8841
+ await queryRunner.query(`ALTER TABLE "PhysicalAddress" ADD COLUMN "owner_id" uuid`);
8842
+ await queryRunner.query(`ALTER TABLE "PhysicalAddress" ADD COLUMN "tenant_id" uuid`);
8783
8843
  }
8784
8844
  async down(queryRunner) {
8785
- await queryRunner.query(`
8786
- ALTER TABLE "CredentialClaims"
8787
- ALTER COLUMN "credentialLocaleBrandingId" TYPE character varying USING "credentialLocaleBrandingId"::text;
8788
- `);
8845
+ await queryRunner.query(`ALTER TABLE "PhysicalAddress" DROP COLUMN "tenant_id"`);
8846
+ await queryRunner.query(`ALTER TABLE "PhysicalAddress" DROP COLUMN "owner_id"`);
8847
+ await queryRunner.query(`ALTER TABLE "ElectronicAddress" DROP COLUMN "tenant_id"`);
8848
+ await queryRunner.query(`ALTER TABLE "ElectronicAddress" DROP COLUMN "owner_id"`);
8849
+ await queryRunner.query(`ALTER TABLE "PartyRelationship" DROP COLUMN "tenant_id"`);
8850
+ await queryRunner.query(`ALTER TABLE "PartyRelationship" DROP COLUMN "owner_id"`);
8851
+ await queryRunner.query(`ALTER TABLE "BaseContact" DROP COLUMN "tenant_id"`);
8852
+ await queryRunner.query(`ALTER TABLE "BaseContact" DROP COLUMN "owner_id"`);
8853
+ await queryRunner.query(`ALTER TABLE "BaseConfig" DROP COLUMN "tenant_id"`);
8854
+ await queryRunner.query(`ALTER TABLE "BaseConfig" DROP COLUMN "owner_id"`);
8855
+ await queryRunner.query(`ALTER TABLE "Connection" DROP COLUMN "tenant_id"`);
8856
+ await queryRunner.query(`ALTER TABLE "Connection" DROP COLUMN "owner_id"`);
8857
+ await queryRunner.query(`ALTER TABLE "CorrelationIdentifier" DROP COLUMN "tenant_id"`);
8858
+ await queryRunner.query(`ALTER TABLE "CorrelationIdentifier" DROP COLUMN "owner_id"`);
8859
+ await queryRunner.query(`ALTER TABLE "Identity" DROP COLUMN "tenant_id"`);
8860
+ await queryRunner.query(`ALTER TABLE "Identity" DROP COLUMN "owner_id"`);
8861
+ await queryRunner.query(`ALTER TABLE "Party" DROP COLUMN "tenant_id"`);
8862
+ await queryRunner.query(`ALTER TABLE "Party" DROP COLUMN "owner_id"`);
8789
8863
  }
8790
8864
  };
8791
8865
 
8792
- // src/migrations/sqlite/1741895822987-FixCredentialClaimsReferencesUuid.ts
8793
- var FixCredentialClaimsReferencesUuidSqlite1741895822987 = class {
8866
+ // src/migrations/sqlite/1710438363002-CreateContacts.ts
8867
+ var CreateContacts1710438363002 = class {
8794
8868
  static {
8795
- __name(this, "FixCredentialClaimsReferencesUuidSqlite1741895822987");
8869
+ __name(this, "CreateContacts1710438363002");
8796
8870
  }
8797
- name = "FixCredentialClaimsReferencesUuid1741895822987";
8871
+ name = "CreateContacts1710438363002";
8798
8872
  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
- `);
8873
+ await queryRunner.query(`ALTER TABLE "Party" ADD COLUMN "owner_id" text`);
8874
+ await queryRunner.query(`ALTER TABLE "Party" ADD COLUMN "tenant_id" text`);
8875
+ await queryRunner.query(`CREATE TABLE "temporary_Identity" (
8876
+ "id" varchar PRIMARY KEY NOT NULL,
8877
+ "alias" varchar(255) NOT NULL,
8878
+ "roles" text NOT NULL,
8879
+ "origin" text NOT NULL,
8880
+ "created_at" datetime NOT NULL DEFAULT (datetime('now')),
8881
+ "last_updated_at" datetime NOT NULL DEFAULT (datetime('now')),
8882
+ "partyId" varchar,
8883
+ "owner_id" text,
8884
+ "tenant_id" text,
8885
+ CONSTRAINT "UQ_Identity_alias" UNIQUE ("alias"),
8886
+ CONSTRAINT "FK_Identity_partyId" FOREIGN KEY ("partyId") REFERENCES "Party" ("id") ON DELETE CASCADE ON UPDATE NO ACTION
8887
+ )`);
8888
+ await queryRunner.query(`INSERT INTO "temporary_Identity"("id", "alias", "roles", "created_at", "last_updated_at", "partyId", "owner_id", "tenant_id", "origin")
8889
+ SELECT "id", "alias", "roles", 'EXTERNAL' as "origin", "created_at", "last_updated_at", "partyId", NULL as "owner_id", NULL as "tenant_id" FROM "Identity"`);
8890
+ await queryRunner.query(`DROP TABLE "Identity"`);
8891
+ await queryRunner.query(`ALTER TABLE "temporary_Identity" RENAME TO "Identity"`);
8892
+ await queryRunner.query(`ALTER TABLE "CorrelationIdentifier" ADD COLUMN "owner_id" text`);
8893
+ await queryRunner.query(`ALTER TABLE "CorrelationIdentifier" ADD COLUMN "tenant_id" text`);
8894
+ await queryRunner.query(`ALTER TABLE "Connection" ADD COLUMN "owner_id" text`);
8895
+ await queryRunner.query(`ALTER TABLE "Connection" ADD COLUMN "tenant_id" text`);
8896
+ await queryRunner.query(`ALTER TABLE "BaseConfig" ADD COLUMN "owner_id" text`);
8897
+ await queryRunner.query(`ALTER TABLE "BaseConfig" ADD COLUMN "tenant_id" text`);
8898
+ await queryRunner.query(`ALTER TABLE "BaseContact" ADD COLUMN "owner_id" text`);
8899
+ await queryRunner.query(`ALTER TABLE "BaseContact" ADD COLUMN "tenant_id" text`);
8900
+ await queryRunner.query(`ALTER TABLE "PartyRelationship" ADD COLUMN "owner_id" text`);
8901
+ await queryRunner.query(`ALTER TABLE "PartyRelationship" ADD COLUMN "tenant_id" text`);
8902
+ await queryRunner.query(`ALTER TABLE "ElectronicAddress" ADD COLUMN "owner_id" text`);
8903
+ await queryRunner.query(`ALTER TABLE "ElectronicAddress" ADD COLUMN "tenant_id" text`);
8904
+ await queryRunner.query(`ALTER TABLE "PhysicalAddress" ADD COLUMN "owner_id" text`);
8905
+ await queryRunner.query(`ALTER TABLE "PhysicalAddress" ADD COLUMN "tenant_id" text`);
8820
8906
  }
8821
8907
  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
- `);
8908
+ await queryRunner.query(`ALTER TABLE "PhysicalAddress" DROP COLUMN "tenant_id"`);
8909
+ await queryRunner.query(`ALTER TABLE "PhysicalAddress" DROP COLUMN "owner_id"`);
8910
+ await queryRunner.query(`ALTER TABLE "ElectronicAddress" DROP COLUMN "tenant_id"`);
8911
+ await queryRunner.query(`ALTER TABLE "ElectronicAddress" DROP COLUMN "owner_id"`);
8912
+ await queryRunner.query(`ALTER TABLE "PartyRelationship" DROP COLUMN "tenant_id"`);
8913
+ await queryRunner.query(`ALTER TABLE "PartyRelationship" DROP COLUMN "owner_id"`);
8914
+ await queryRunner.query(`ALTER TABLE "BaseContact" DROP COLUMN "tenant_id"`);
8915
+ await queryRunner.query(`ALTER TABLE "BaseContact" DROP COLUMN "owner_id"`);
8916
+ await queryRunner.query(`ALTER TABLE "BaseConfig" DROP COLUMN "tenant_id"`);
8917
+ await queryRunner.query(`ALTER TABLE "BaseConfig" DROP COLUMN "owner_id"`);
8918
+ await queryRunner.query(`ALTER TABLE "Connection" DROP COLUMN "tenant_id"`);
8919
+ await queryRunner.query(`ALTER TABLE "Connection" DROP COLUMN "owner_id"`);
8920
+ await queryRunner.query(`ALTER TABLE "CorrelationIdentifier" DROP COLUMN "tenant_id"`);
8921
+ await queryRunner.query(`ALTER TABLE "CorrelationIdentifier" DROP COLUMN "owner_id"`);
8922
+ await queryRunner.query(`ALTER TABLE "Identity" DROP COLUMN "tenant_id"`);
8923
+ await queryRunner.query(`ALTER TABLE "Identity" DROP COLUMN "owner_id"`);
8924
+ await queryRunner.query(`ALTER TABLE "Party" DROP COLUMN "tenant_id"`);
8925
+ await queryRunner.query(`ALTER TABLE "Party" DROP COLUMN "owner_id"`);
8843
8926
  }
8844
8927
  };
8845
8928
 
8846
- // src/migrations/generic/11-FixCredentialClaimsReferenceUuid.ts
8929
+ // src/migrations/generic/8-CreateContacts.ts
8847
8930
  var debug18 = Debug18("sphereon:ssi-sdk:migrations");
8848
- var FixCredentialClaimsReferencesUuid1741895822987 = class {
8931
+ var CreateContacts1708525189000 = class {
8849
8932
  static {
8850
- __name(this, "FixCredentialClaimsReferencesUuid1741895822987");
8933
+ __name(this, "CreateContacts1708525189000");
8851
8934
  }
8852
- name = "FixCredentialClaimsReferenceUuid1741895822987";
8935
+ name = "CreateContacts1708525189000";
8853
8936
  async up(queryRunner) {
8854
- debug18("migration: creating issuance branding uuid problem");
8937
+ debug18("migration: updating contact tables");
8855
8938
  const dbType = queryRunner.connection.driver.options.type;
8856
8939
  switch (dbType) {
8857
8940
  case "postgres": {
8858
8941
  debug18("using postgres migration file");
8859
- const mig = new FixCredentialClaimsReferencesUuidPG1741895822987();
8942
+ const mig = new CreateContacts1710438363001();
8860
8943
  await mig.up(queryRunner);
8861
8944
  debug18("Migration statements executed");
8862
8945
  return;
@@ -8865,7 +8948,7 @@ var FixCredentialClaimsReferencesUuid1741895822987 = class {
8865
8948
  case "expo":
8866
8949
  case "react-native": {
8867
8950
  debug18("using sqlite/react-native migration file");
8868
- const mig = new FixCredentialClaimsReferencesUuidSqlite1741895822987();
8951
+ const mig = new CreateContacts1710438363002();
8869
8952
  await mig.up(queryRunner);
8870
8953
  debug18("Migration statements executed");
8871
8954
  return;
@@ -8875,12 +8958,12 @@ var FixCredentialClaimsReferencesUuid1741895822987 = class {
8875
8958
  }
8876
8959
  }
8877
8960
  async down(queryRunner) {
8878
- debug18("migration: reverting issuance branding uuid migration");
8961
+ debug18("migration: reverting machine state tables");
8879
8962
  const dbType = queryRunner.connection.driver.options.type;
8880
8963
  switch (dbType) {
8881
8964
  case "postgres": {
8882
8965
  debug18("using postgres migration file");
8883
- const mig = new CreateIssuanceBranding1685628974232();
8966
+ const mig = new CreateContacts1710438363001();
8884
8967
  await mig.down(queryRunner);
8885
8968
  debug18("Migration statements executed");
8886
8969
  return;
@@ -8889,7 +8972,7 @@ var FixCredentialClaimsReferencesUuid1741895822987 = class {
8889
8972
  case "expo":
8890
8973
  case "react-native": {
8891
8974
  debug18("using sqlite/react-native migration file");
8892
- const mig = new CreateIssuanceBranding1685628973231();
8975
+ const mig = new CreateContacts1710438363002();
8893
8976
  await mig.down(queryRunner);
8894
8977
  debug18("Migration statements executed");
8895
8978
  return;
@@ -8899,224 +8982,172 @@ var FixCredentialClaimsReferencesUuid1741895822987 = class {
8899
8982
  }
8900
8983
  }
8901
8984
  };
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'))`);
8985
+
8986
+ // src/migrations/generic/9-CreateContacts.ts
8987
+ import Debug19 from "debug";
8988
+
8989
+ // src/migrations/postgres/1715761125001-CreateContacts.ts
8990
+ var CreateContacts1715761125001 = class {
8991
+ static {
8992
+ __name(this, "CreateContacts1715761125001");
8993
+ }
8994
+ name = "CreateContacts1715761125001";
8995
+ async up(queryRunner) {
8996
+ await queryRunner.query(`ALTER TABLE "IdentityMetadata" RENAME TO "temporary_IdentityMetadata"`);
8997
+ await queryRunner.query(`CREATE TABLE "IdentityMetadata"
8998
+ (
8999
+ "id" uuid PRIMARY KEY NOT NULL DEFAULT uuid_generate_v4(),
9000
+ "label" character varying(255) NOT NULL,
9001
+ "valueType" character varying NOT NULL,
9002
+ "stringValue" text,
9003
+ "numberValue" double precision,
9004
+ "dateValue" TIMESTAMP,
9005
+ "boolValue" boolean,
9006
+ "identityId" uuid,
9007
+ CONSTRAINT "FK_Identity_IdentityMetadata" FOREIGN KEY ("identityId") REFERENCES "Identity" ("id") ON DELETE CASCADE
9008
+ )`);
9009
+ await queryRunner.query(`INSERT INTO "IdentityMetadata" ("id", "label", "valueType", "stringValue", "identityId")
9010
+ SELECT "id", "label", 'string', "value", "identityId"
9011
+ FROM "temporary_IdentityMetadata"`);
9012
+ await queryRunner.query(`DROP TABLE "temporary_IdentityMetadata"`);
9013
+ await queryRunner.query(`CREATE TABLE "ContactMetadata"
9014
+ (
9015
+ "id" uuid PRIMARY KEY NOT NULL DEFAULT uuid_generate_v4(),
9016
+ "label" character varying(255) NOT NULL,
9017
+ "valueType" character varying NOT NULL,
9018
+ "stringValue" text,
9019
+ "numberValue" double precision,
9020
+ "dateValue" TIMESTAMP,
9021
+ "boolValue" boolean,
9022
+ "contactId" uuid,
9023
+ CONSTRAINT "FK_BaseContact_ContactMetadata" FOREIGN KEY ("contactId") REFERENCES "BaseContact" ("id") ON DELETE CASCADE
9024
+ )`);
8926
9025
  }
8927
9026
  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"`);
9027
+ await queryRunner.query(`DROP TABLE "ContactMetadata"`);
9028
+ await queryRunner.query(`ALTER TABLE "IdentityMetadata" RENAME TO "temporary_IdentityMetadata"`);
9029
+ await queryRunner.query(`CREATE TABLE "IdentityMetadata"
9030
+ (
9031
+ "id" uuid PRIMARY KEY NOT NULL DEFAULT uuid_generate_v4(),
9032
+ "label" character varying(255) NOT NULL,
9033
+ "value" character varying(255) NOT NULL,
9034
+ "identityId" uuid,
9035
+ CONSTRAINT "FK_Identity_IdentityMetadata" FOREIGN KEY ("identityId") REFERENCES "Identity" ("id") ON DELETE CASCADE
9036
+ )`);
9037
+ await queryRunner.query(`INSERT INTO "IdentityMetadata" ("id", "label", "value", "identityId")
9038
+ SELECT "id", "label", "stringValue", "identityId"
9039
+ FROM "temporary_IdentityMetadata"`);
9040
+ await queryRunner.query(`DROP TABLE "temporary_IdentityMetadata"`);
8940
9041
  }
8941
9042
  };
8942
9043
 
8943
- // src/migrations/sqlite/1741895823001-CreateBitstringStatusList.ts
8944
- var CreateBitstringStatusListSqlite1741895823001 = class {
9044
+ // src/migrations/sqlite/1715761125002-CreateContacts.ts
9045
+ var CreateContacts1715761125002 = class {
8945
9046
  static {
8946
- __name(this, "CreateBitstringStatusListSqlite1741895823001");
9047
+ __name(this, "CreateContacts1715761125002");
8947
9048
  }
8948
- name = "CreateBitstringStatusList1741895823000";
9049
+ name = "CreateContacts1715761125002";
8949
9050
  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"`);
9051
+ await queryRunner.query(`ALTER TABLE "IdentityMetadata" RENAME TO "temporary_IdentityMetadata"`);
9052
+ await queryRunner.query(`CREATE TABLE "IdentityMetadata"
9053
+ (
9054
+ "id" varchar PRIMARY KEY NOT NULL,
9055
+ "label" varchar(255) NOT NULL,
9056
+ "valueType" varchar NOT NULL,
9057
+ "stringValue" varchar(255),
9058
+ "numberValue" double,
9059
+ "dateValue" datetime,
9060
+ "boolValue" boolean,
9061
+ "identityId" varchar,
9062
+ FOREIGN KEY ("identityId") REFERENCES "Identity" ("id") ON DELETE CASCADE)`);
9063
+ await queryRunner.query(`INSERT INTO "IdentityMetadata" ("id", "label", "valueType", "stringValue", "identityId")
9064
+ SELECT "id", "label", 'string', "value", "identityId"
9065
+ FROM "temporary_IdentityMetadata"
9066
+ `);
9067
+ await queryRunner.query(`DROP TABLE "temporary_IdentityMetadata"`);
9068
+ await queryRunner.query(`CREATE TABLE "ContactMetadata"
9069
+ (
9070
+ "id" varchar PRIMARY KEY NOT NULL,
9071
+ "label" varchar(255) NOT NULL,
9072
+ "valueType" varchar NOT NULL,
9073
+ "stringValue" text,
9074
+ "numberValue" double,
9075
+ "dateValue" datetime,
9076
+ "boolValue" boolean,
9077
+ "contactId" varchar,
9078
+ FOREIGN KEY ("contactId") REFERENCES "BaseContact" ("id") ON DELETE CASCADE)`);
9013
9079
  }
9014
9080
  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"`);
9081
+ await queryRunner.query(`DROP TABLE "ContactMetadata"`);
9082
+ await queryRunner.query(`ALTER TABLE "IdentityMetadata" RENAME TO "temporary_IdentityMetadata"`);
9083
+ await queryRunner.query(`CREATE TABLE "IdentityMetadata"
9084
+ (
9085
+ "id" varchar PRIMARY KEY NOT NULL,
9086
+ "label" varchar(255) NOT NULL,
9087
+ "value" varchar(255) NOT NULL,
9088
+ "identityId" varchar,
9089
+ FOREIGN KEY ("identityId") REFERENCES "Identity" ("id") ON DELETE CASCADE
9090
+ )`);
9091
+ await queryRunner.query(`INSERT INTO "IdentityMetadata" ("id", "label", "value", "identityId")
9092
+ SELECT "id", "label", "stringValue", "identityId"
9093
+ FROM "temporary_IdentityMetadata"`);
9094
+ await queryRunner.query(`DROP TABLE "temporary_IdentityMetadata"`);
9072
9095
  }
9073
9096
  };
9074
9097
 
9075
- // src/migrations/generic/12-CreateBitstringStatusList.ts
9098
+ // src/migrations/generic/9-CreateContacts.ts
9076
9099
  var debug19 = Debug19("sphereon:ssi-sdk:migrations");
9077
- var CreateBitstringStatusList1741895823000 = class {
9100
+ var CreateContacts1715761125000 = class {
9078
9101
  static {
9079
- __name(this, "CreateBitstringStatusList1741895823000");
9102
+ __name(this, "CreateContacts1715761125000");
9080
9103
  }
9081
- name = "CreateBitstringStatusList1741895823000";
9104
+ name = "CreateContacts1715761125000";
9082
9105
  async up(queryRunner) {
9083
- debug19("migration: creating bitstring status list tables");
9106
+ debug19("migration: updating contact tables");
9084
9107
  const dbType = queryRunner.connection.driver.options.type;
9085
9108
  switch (dbType) {
9086
9109
  case "postgres": {
9087
- const mig = new CreateBitstringStatusListPG1741895823000();
9110
+ debug19("using postgres migration file");
9111
+ const mig = new CreateContacts1715761125001();
9088
9112
  await mig.up(queryRunner);
9113
+ debug19("Migration statements executed");
9089
9114
  return;
9090
9115
  }
9091
9116
  case "sqlite":
9092
9117
  case "expo":
9093
9118
  case "react-native": {
9094
- const mig = new CreateBitstringStatusListSqlite1741895823001();
9119
+ debug19("using sqlite/react-native migration file");
9120
+ const mig = new CreateContacts1715761125002();
9095
9121
  await mig.up(queryRunner);
9122
+ debug19("Migration statements executed");
9096
9123
  return;
9097
9124
  }
9098
9125
  default:
9099
- return Promise.reject(`Migrations only supported for sqlite and postgres. Was ${dbType}`);
9126
+ 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
9127
  }
9101
9128
  }
9102
9129
  async down(queryRunner) {
9103
- debug19("migration: dropping bitstring status list tables");
9130
+ debug19("migration: reverting machine state tables");
9104
9131
  const dbType = queryRunner.connection.driver.options.type;
9105
9132
  switch (dbType) {
9106
9133
  case "postgres": {
9107
- const mig = new CreateBitstringStatusListPG1741895823000();
9134
+ debug19("using postgres migration file");
9135
+ const mig = new CreateContacts1715761125001();
9108
9136
  await mig.down(queryRunner);
9137
+ debug19("Migration statements executed");
9109
9138
  return;
9110
9139
  }
9111
9140
  case "sqlite":
9112
9141
  case "expo":
9113
9142
  case "react-native": {
9114
- const mig = new CreateBitstringStatusListSqlite1741895823001();
9143
+ debug19("using sqlite/react-native migration file");
9144
+ const mig = new CreateContacts1715761125002();
9115
9145
  await mig.down(queryRunner);
9146
+ debug19("Migration statements executed");
9116
9147
  return;
9117
9148
  }
9118
9149
  default:
9119
- return Promise.reject(`Migrations only supported for sqlite and postgres. Was ${dbType}`);
9150
+ 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
9151
  }
9121
9152
  }
9122
9153
  };
@@ -9134,6 +9165,7 @@ var DataStoreIssuanceBrandingMigrations = [
9134
9165
  ];
9135
9166
  var DataStoreStatusListMigrations = [
9136
9167
  CreateStatusList1693866470000,
9168
+ AddBitstringStatusListEnum1741895823000,
9137
9169
  CreateBitstringStatusList1741895823000
9138
9170
  ];
9139
9171
  var DataStoreEventLoggerMigrations = [
@@ -9385,7 +9417,6 @@ export {
9385
9417
  CredentialCorrelationType,
9386
9418
  CredentialDocumentFormat,
9387
9419
  CredentialLocaleBrandingEntity,
9388
- CredentialRole,
9389
9420
  CredentialStateType,
9390
9421
  DataStoreContactEntities,
9391
9422
  DataStoreContactMigrations,