@sphereon/ssi-sdk.data-store 0.36.1-feature.fides.fixes.111 → 0.36.1-feature.fides.fixes.119

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -3271,7 +3271,9 @@ var CredentialBrandingEntity = class extends import_typeorm26.BaseEntity {
3271
3271
  this.lastUpdatedAt = /* @__PURE__ */ new Date();
3272
3272
  }
3273
3273
  setState() {
3274
- this.state = this.computeState();
3274
+ if (this.localeBranding && Array.isArray(this.localeBranding)) {
3275
+ this.state = this.computeState();
3276
+ }
3275
3277
  }
3276
3278
  async validate() {
3277
3279
  const validation = await (0, import_class_validator17.validate)(this);
@@ -4979,7 +4981,10 @@ var ContactStore = class extends import_ssi_sdk25.AbstractContactStore {
4979
4981
  const result = await partyRepository.find({
4980
4982
  where: {
4981
4983
  id: (0, import_typeorm35.In)(initialResult.map((party) => party.id))
4982
- }
4984
+ },
4985
+ relations: [
4986
+ "contact"
4987
+ ]
4983
4988
  });
4984
4989
  debug(`getParties() resulted in ${result.length} parties`);
4985
4990
  return result.filter((party) => {
@@ -5928,19 +5933,39 @@ var IssuanceBrandingStore = class extends import_ssi_sdk27.AbstractIssuanceBrand
5928
5933
  });
5929
5934
  }
5930
5935
  debug3("Getting credential branding", args);
5931
- const result = await (await this.dbConnection).getRepository(CredentialBrandingEntity).find({
5936
+ const repository = (await this.dbConnection).getRepository(CredentialBrandingEntity);
5937
+ if (knownStates && Object.keys(knownStates).length > 0) {
5938
+ const stateQuery = repository.createQueryBuilder("branding").select([
5939
+ "branding.id",
5940
+ "branding.state"
5941
+ ]);
5942
+ if (filter) {
5943
+ stateQuery.where(filter);
5944
+ }
5945
+ const stateResults = await stateQuery.getRawMany().then((rows) => rows.map((row) => ({
5946
+ id: row.branding_id,
5947
+ state: row.branding_state
5948
+ })));
5949
+ const dirtyIds = stateResults.filter((result3) => {
5950
+ const knownState = knownStates[result3.id];
5951
+ return !knownState || knownState !== result3.state;
5952
+ }).map((result3) => result3.id);
5953
+ if (dirtyIds.length === 0) {
5954
+ return [];
5955
+ }
5956
+ const result2 = await repository.find({
5957
+ where: {
5958
+ id: (0, import_typeorm37.In)(dirtyIds)
5959
+ }
5960
+ });
5961
+ return result2.map((branding) => credentialBrandingFrom(branding));
5962
+ }
5963
+ const result = await repository.find({
5932
5964
  ...filter && {
5933
5965
  where: filter
5934
5966
  }
5935
5967
  });
5936
- const credentialBranding = result.map((branding) => credentialBrandingFrom(branding));
5937
- if (!knownStates) {
5938
- return credentialBranding;
5939
- }
5940
- return credentialBranding.filter((branding) => {
5941
- const knownState = knownStates[branding.id];
5942
- return !knownState || knownState !== branding.state;
5943
- });
5968
+ return result.map((branding) => credentialBrandingFrom(branding));
5944
5969
  }, "getCredentialBranding");
5945
5970
  removeCredentialBranding = /* @__PURE__ */ __name(async (args) => {
5946
5971
  const { filter } = args;
@@ -8323,6 +8348,7 @@ var AddBrandingStateSqlite1766000000000 = class {
8323
8348
  await queryRunner.query(`ALTER TABLE "BaseLocaleBranding" ADD COLUMN "state" varchar(255) NOT NULL DEFAULT ''`);
8324
8349
  }
8325
8350
  async down(queryRunner) {
8351
+ await queryRunner.query(`PRAGMA foreign_keys = OFF`);
8326
8352
  await queryRunner.query(`
8327
8353
  CREATE TABLE "CredentialBranding_old"
8328
8354
  (
@@ -8381,6 +8407,7 @@ var AddBrandingStateSqlite1766000000000 = class {
8381
8407
  await queryRunner.query(`CREATE UNIQUE INDEX "IDX_CredentialLocaleBrandingEntity_credentialBranding_locale" ON "BaseLocaleBranding" ("credentialBrandingId", "locale")`);
8382
8408
  await queryRunner.query(`CREATE UNIQUE INDEX "IDX_IssuerLocaleBrandingEntity_issuerBranding_locale" ON "BaseLocaleBranding" ("issuerBrandingId", "locale")`);
8383
8409
  await queryRunner.query(`CREATE INDEX "IDX_BaseLocaleBranding_type" ON "BaseLocaleBranding" ("type")`);
8410
+ await queryRunner.query(`PRAGMA foreign_keys = ON`);
8384
8411
  }
8385
8412
  };
8386
8413