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

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