@sphereon/ssi-sdk.data-store 0.33.0 → 0.33.1-feature.vcdm2.4
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/contact/AbstractContactStore.js +1 -5
- package/dist/contact/AbstractContactStore.js.map +1 -1
- package/dist/contact/ContactStore.js +544 -545
- package/dist/contact/ContactStore.js.map +1 -1
- package/dist/digitalCredential/AbstractDigitalCredentialStore.js +1 -5
- package/dist/digitalCredential/AbstractDigitalCredentialStore.js.map +1 -1
- package/dist/digitalCredential/DigitalCredentialStore.js +131 -142
- package/dist/digitalCredential/DigitalCredentialStore.js.map +1 -1
- package/dist/entities/contact/BaseConfigEntity.js +13 -14
- package/dist/entities/contact/BaseConfigEntity.js.map +1 -1
- package/dist/entities/contact/BaseContactEntity.js +24 -22
- package/dist/entities/contact/BaseContactEntity.js.map +1 -1
- package/dist/entities/contact/ConnectionEntity.js +23 -20
- package/dist/entities/contact/ConnectionEntity.js.map +1 -1
- package/dist/entities/contact/ContactMetadataItemEntity.js +38 -44
- package/dist/entities/contact/ContactMetadataItemEntity.js.map +1 -1
- package/dist/entities/contact/CorrelationIdentifierEntity.js +34 -42
- package/dist/entities/contact/CorrelationIdentifierEntity.js.map +1 -1
- package/dist/entities/contact/DidAuthConfigEntity.js +16 -14
- package/dist/entities/contact/DidAuthConfigEntity.js.map +1 -1
- package/dist/entities/contact/ElectronicAddressEntity.js +42 -47
- package/dist/entities/contact/ElectronicAddressEntity.js.map +1 -1
- package/dist/entities/contact/IdentityEntity.js +56 -57
- package/dist/entities/contact/IdentityEntity.js.map +1 -1
- package/dist/entities/contact/IdentityMetadataItemEntity.js +38 -44
- package/dist/entities/contact/IdentityMetadataItemEntity.js.map +1 -1
- package/dist/entities/contact/NaturalPersonEntity.js +35 -43
- package/dist/entities/contact/NaturalPersonEntity.js.map +1 -1
- package/dist/entities/contact/OpenIdConfigEntity.js +24 -18
- package/dist/entities/contact/OpenIdConfigEntity.js.map +1 -1
- package/dist/entities/contact/OrganizationEntity.js +28 -38
- package/dist/entities/contact/OrganizationEntity.js.map +1 -1
- package/dist/entities/contact/PartyEntity.js +57 -59
- package/dist/entities/contact/PartyEntity.js.map +1 -1
- package/dist/entities/contact/PartyRelationshipEntity.js +37 -43
- package/dist/entities/contact/PartyRelationshipEntity.js.map +1 -1
- package/dist/entities/contact/PartyTypeEntity.js +44 -49
- package/dist/entities/contact/PartyTypeEntity.js.map +1 -1
- package/dist/entities/contact/PhysicalAddressEntity.js +61 -60
- package/dist/entities/contact/PhysicalAddressEntity.js.map +1 -1
- package/dist/entities/digitalCredential/DigitalCredentialEntity.js +63 -38
- package/dist/entities/digitalCredential/DigitalCredentialEntity.js.map +1 -1
- package/dist/entities/eventLogger/AuditEventEntity.js +60 -37
- package/dist/entities/eventLogger/AuditEventEntity.js.map +1 -1
- package/dist/entities/issuanceBranding/BackgroundAttributesEntity.js +25 -36
- package/dist/entities/issuanceBranding/BackgroundAttributesEntity.js.map +1 -1
- package/dist/entities/issuanceBranding/BaseLocaleBrandingEntity.js +48 -53
- package/dist/entities/issuanceBranding/BaseLocaleBrandingEntity.js.map +1 -1
- package/dist/entities/issuanceBranding/CredentialBrandingEntity.js +35 -43
- package/dist/entities/issuanceBranding/CredentialBrandingEntity.js.map +1 -1
- package/dist/entities/issuanceBranding/CredentialClaimsEntity.js +28 -38
- package/dist/entities/issuanceBranding/CredentialClaimsEntity.js.map +1 -1
- package/dist/entities/issuanceBranding/CredentialLocaleBrandingEntity.js +18 -18
- package/dist/entities/issuanceBranding/CredentialLocaleBrandingEntity.js.map +1 -1
- package/dist/entities/issuanceBranding/ImageAttributesEntity.js +34 -42
- package/dist/entities/issuanceBranding/ImageAttributesEntity.js.map +1 -1
- package/dist/entities/issuanceBranding/ImageDimensionsEntity.js +11 -11
- package/dist/entities/issuanceBranding/ImageDimensionsEntity.js.map +1 -1
- package/dist/entities/issuanceBranding/IssuerBrandingEntity.js +31 -40
- package/dist/entities/issuanceBranding/IssuerBrandingEntity.js.map +1 -1
- package/dist/entities/issuanceBranding/IssuerLocaleBrandingEntity.js +27 -24
- package/dist/entities/issuanceBranding/IssuerLocaleBrandingEntity.js.map +1 -1
- package/dist/entities/issuanceBranding/TextAttributesEntity.js +20 -32
- package/dist/entities/issuanceBranding/TextAttributesEntity.js.map +1 -1
- package/dist/entities/machineState/MachineStateInfoEntity.js +31 -21
- package/dist/entities/machineState/MachineStateInfoEntity.js.map +1 -1
- package/dist/entities/oid4vcState/Oid4vcStateEntity.js +24 -18
- package/dist/entities/oid4vcState/Oid4vcStateEntity.js.map +1 -1
- package/dist/entities/presentationDefinition/PresentationDefinitionItemEntity.js +34 -27
- package/dist/entities/presentationDefinition/PresentationDefinitionItemEntity.js.map +1 -1
- package/dist/entities/statusList/StatusList2021EntryEntity.js +26 -22
- package/dist/entities/statusList/StatusList2021EntryEntity.js.map +1 -1
- package/dist/entities/statusList/StatusListEntities.js +48 -39
- package/dist/entities/statusList/StatusListEntities.js.map +1 -1
- package/dist/entities/validators/index.js +6 -10
- package/dist/entities/validators/index.js.map +1 -1
- package/dist/eventLogger/AbstractEventLoggerStore.js +1 -5
- package/dist/eventLogger/AbstractEventLoggerStore.js.map +1 -1
- package/dist/eventLogger/EventLoggerStore.js +50 -65
- package/dist/eventLogger/EventLoggerStore.js.map +1 -1
- package/dist/index.js +96 -163
- package/dist/index.js.map +1 -1
- package/dist/issuanceBranding/AbstractIssuanceBrandingStore.js +1 -5
- package/dist/issuanceBranding/AbstractIssuanceBrandingStore.js.map +1 -1
- package/dist/issuanceBranding/IssuanceBrandingStore.js +331 -333
- package/dist/issuanceBranding/IssuanceBrandingStore.js.map +1 -1
- package/dist/machineState/IAbstractMachineStateStore.js +1 -5
- package/dist/machineState/IAbstractMachineStateStore.js.map +1 -1
- package/dist/machineState/MachineStateStore.js +102 -122
- package/dist/machineState/MachineStateStore.js.map +1 -1
- package/dist/migrations/generic/1-CreateContacts.js +50 -72
- package/dist/migrations/generic/1-CreateContacts.js.map +1 -1
- package/dist/migrations/generic/10-CreatePresentationDefinitions.js +50 -72
- package/dist/migrations/generic/10-CreatePresentationDefinitions.js.map +1 -1
- package/dist/migrations/generic/11-FixCredentialClaimsReferenceUuid.js +52 -74
- package/dist/migrations/generic/11-FixCredentialClaimsReferenceUuid.js.map +1 -1
- package/dist/migrations/generic/2-CreateIssuanceBranding.js +50 -72
- package/dist/migrations/generic/2-CreateIssuanceBranding.js.map +1 -1
- package/dist/migrations/generic/3-CreateContacts.js +50 -72
- package/dist/migrations/generic/3-CreateContacts.js.map +1 -1
- package/dist/migrations/generic/4-CreateStatusList.js +56 -78
- package/dist/migrations/generic/4-CreateStatusList.js.map +1 -1
- package/dist/migrations/generic/5-CreateAuditEvents.js +50 -72
- package/dist/migrations/generic/5-CreateAuditEvents.js.map +1 -1
- package/dist/migrations/generic/6-CreateDigitalCredential.js +50 -72
- package/dist/migrations/generic/6-CreateDigitalCredential.js.map +1 -1
- package/dist/migrations/generic/7-CreateMachineStateStore.js +50 -72
- package/dist/migrations/generic/7-CreateMachineStateStore.js.map +1 -1
- package/dist/migrations/generic/8-CreateContacts.js +50 -72
- package/dist/migrations/generic/8-CreateContacts.js.map +1 -1
- package/dist/migrations/generic/9-CreateContacts.js +50 -72
- package/dist/migrations/generic/9-CreateContacts.js.map +1 -1
- package/dist/migrations/generic/index.js +30 -33
- package/dist/migrations/generic/index.js.map +1 -1
- package/dist/migrations/index.js +1 -12
- package/dist/migrations/index.js.map +1 -1
- package/dist/migrations/internal-migrations-ormconfig.js +6 -8
- package/dist/migrations/internal-migrations-ormconfig.js.map +1 -1
- package/dist/migrations/postgres/1659463079428-CreateContacts.js +34 -53
- package/dist/migrations/postgres/1659463079428-CreateContacts.js.map +1 -1
- package/dist/migrations/postgres/1685628974232-CreateIssuanceBranding.js +50 -69
- package/dist/migrations/postgres/1685628974232-CreateIssuanceBranding.js.map +1 -1
- package/dist/migrations/postgres/1690925872592-CreateContacts.js +87 -106
- package/dist/migrations/postgres/1690925872592-CreateContacts.js.map +1 -1
- package/dist/migrations/postgres/1693866470001-CreateStatusList.js +16 -35
- package/dist/migrations/postgres/1693866470001-CreateStatusList.js.map +1 -1
- package/dist/migrations/postgres/1701634812183-CreateAuditEvents.js +22 -41
- package/dist/migrations/postgres/1701634812183-CreateAuditEvents.js.map +1 -1
- package/dist/migrations/postgres/1708525189001-CreateDigitalCredential.js +19 -38
- package/dist/migrations/postgres/1708525189001-CreateDigitalCredential.js.map +1 -1
- package/dist/migrations/postgres/1708797018115-CreateMachineStateStore.js +6 -25
- package/dist/migrations/postgres/1708797018115-CreateMachineStateStore.js.map +1 -1
- package/dist/migrations/postgres/1710438363001-CreateContacts.js +40 -59
- package/dist/migrations/postgres/1710438363001-CreateContacts.js.map +1 -1
- package/dist/migrations/postgres/1715761125001-CreateContacts.js +18 -37
- package/dist/migrations/postgres/1715761125001-CreateContacts.js.map +1 -1
- package/dist/migrations/postgres/1716475165345-CreatePresentationDefinitions.js +6 -25
- package/dist/migrations/postgres/1716475165345-CreatePresentationDefinitions.js.map +1 -1
- package/dist/migrations/postgres/1737110469001-UpdateStatusList.js +16 -35
- package/dist/migrations/postgres/1737110469001-UpdateStatusList.js.map +1 -1
- package/dist/migrations/postgres/1741895822987-FixCredentialClaimsReferencesUuid.js +8 -27
- package/dist/migrations/postgres/1741895822987-FixCredentialClaimsReferencesUuid.js.map +1 -1
- package/dist/migrations/sqlite/1659463069549-CreateContacts.js +56 -75
- package/dist/migrations/sqlite/1659463069549-CreateContacts.js.map +1 -1
- package/dist/migrations/sqlite/1685628973231-CreateIssuanceBranding.js +70 -89
- package/dist/migrations/sqlite/1685628973231-CreateIssuanceBranding.js.map +1 -1
- package/dist/migrations/sqlite/1690925872693-CreateContacts.js +120 -139
- package/dist/migrations/sqlite/1690925872693-CreateContacts.js.map +1 -1
- package/dist/migrations/sqlite/1693866470000-CreateStatusList.js +12 -31
- package/dist/migrations/sqlite/1693866470000-CreateStatusList.js.map +1 -1
- package/dist/migrations/sqlite/1701634819487-CreateAuditEvents.js +6 -25
- package/dist/migrations/sqlite/1701634819487-CreateAuditEvents.js.map +1 -1
- package/dist/migrations/sqlite/1708525189002-CreateDigitalCredential.js +7 -26
- package/dist/migrations/sqlite/1708525189002-CreateDigitalCredential.js.map +1 -1
- package/dist/migrations/sqlite/1708796002272-CreateMachineStateStore.js +6 -25
- package/dist/migrations/sqlite/1708796002272-CreateMachineStateStore.js.map +1 -1
- package/dist/migrations/sqlite/1710438363002-CreateContacts.js +43 -62
- package/dist/migrations/sqlite/1710438363002-CreateContacts.js.map +1 -1
- package/dist/migrations/sqlite/1715761125002-CreateContacts.js +18 -37
- package/dist/migrations/sqlite/1715761125002-CreateContacts.js.map +1 -1
- package/dist/migrations/sqlite/1716475165344-CreatePresentationDefinitions.js +6 -25
- package/dist/migrations/sqlite/1716475165344-CreatePresentationDefinitions.js.map +1 -1
- package/dist/migrations/sqlite/1737110469000-UpdateStatusList.js +20 -39
- package/dist/migrations/sqlite/1737110469000-UpdateStatusList.js.map +1 -1
- package/dist/migrations/sqlite/1741895822987-FixCredentialClaimsReferencesUuid.js +25 -44
- package/dist/migrations/sqlite/1741895822987-FixCredentialClaimsReferencesUuid.js.map +1 -1
- package/dist/presentationDefinition/AbstractPDStore.js +1 -5
- package/dist/presentationDefinition/AbstractPDStore.js.map +1 -1
- package/dist/presentationDefinition/PDStore.js +114 -123
- package/dist/presentationDefinition/PDStore.js.map +1 -1
- package/dist/statusList/IStatusListStore.js +1 -2
- package/dist/statusList/StatusListStore.js +196 -225
- package/dist/statusList/StatusListStore.js.map +1 -1
- package/dist/types/contact/IAbstractContactStore.js +1 -2
- package/dist/types/contact/contact.js +10 -13
- package/dist/types/contact/contact.js.map +1 -1
- package/dist/types/digitalCredential/IAbstractDigitalCredentialStore.js +1 -2
- package/dist/types/digitalCredential/digitalCredential.js +13 -16
- package/dist/types/digitalCredential/digitalCredential.js.map +1 -1
- package/dist/types/eventLogger/IAbstractEventLoggerStore.js +1 -2
- package/dist/types/eventLogger/eventLogger.js +1 -2
- package/dist/types/index.js +14 -30
- package/dist/types/index.js.map +1 -1
- package/dist/types/issuanceBranding/IAbstractIssuanceBrandingStore.js +1 -2
- package/dist/types/issuanceBranding/issuanceBranding.js +1 -2
- package/dist/types/machineState/IAbstractMachineStateStore.js +1 -2
- package/dist/types/presentationDefinition/IAbstractPDStore.js +1 -2
- package/dist/types/presentationDefinition/presentationDefinition.js +1 -2
- package/dist/types/statusList/IAbstractStatusListStore.js +1 -2
- package/dist/types/statusList/statusList.js +1 -2
- package/dist/types/validation/validation.js +1 -2
- package/dist/utils/FormattingUtils.js +3 -7
- package/dist/utils/FormattingUtils.js.map +1 -1
- package/dist/utils/SortingUtils.js +1 -5
- package/dist/utils/SortingUtils.js.map +1 -1
- package/dist/utils/ValidatorUtils.js +2 -6
- package/dist/utils/ValidatorUtils.js.map +1 -1
- package/dist/utils/contact/MappingUtils.js +124 -150
- package/dist/utils/contact/MappingUtils.js.map +1 -1
- package/dist/utils/digitalCredential/MappingUtils.js +50 -47
- package/dist/utils/digitalCredential/MappingUtils.js.map +1 -1
- package/dist/utils/eventLogger/MappingUtils.js +60 -22
- package/dist/utils/eventLogger/MappingUtils.js.map +1 -1
- package/dist/utils/issuanceBranding/MappingUtils.js +71 -77
- package/dist/utils/issuanceBranding/MappingUtils.js.map +1 -1
- package/dist/utils/presentationDefinition/MappingUtils.js +9 -15
- package/dist/utils/presentationDefinition/MappingUtils.js.map +1 -1
- package/dist/utils/statusList/MappingUtils.js +27 -22
- package/dist/utils/statusList/MappingUtils.js.map +1 -1
- package/package.json +5 -5
|
@@ -1,362 +1,360 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
};
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
const debug_1 = __importDefault(require("debug"));
|
|
17
|
-
const typeorm_1 = require("typeorm");
|
|
18
|
-
const MappingUtils_1 = require("../utils/issuanceBranding/MappingUtils");
|
|
19
|
-
const BackgroundAttributesEntity_1 = require("../entities/issuanceBranding/BackgroundAttributesEntity");
|
|
20
|
-
const ImageAttributesEntity_1 = require("../entities/issuanceBranding/ImageAttributesEntity");
|
|
21
|
-
const ImageDimensionsEntity_1 = require("../entities/issuanceBranding/ImageDimensionsEntity");
|
|
22
|
-
const IssuerBrandingEntity_1 = require("../entities/issuanceBranding/IssuerBrandingEntity");
|
|
23
|
-
const CredentialBrandingEntity_1 = require("../entities/issuanceBranding/CredentialBrandingEntity");
|
|
24
|
-
const CredentialLocaleBrandingEntity_1 = require("../entities/issuanceBranding/CredentialLocaleBrandingEntity");
|
|
25
|
-
const IssuerLocaleBrandingEntity_1 = require("../entities/issuanceBranding/IssuerLocaleBrandingEntity");
|
|
26
|
-
const TextAttributesEntity_1 = require("../entities/issuanceBranding/TextAttributesEntity");
|
|
27
|
-
const AbstractIssuanceBrandingStore_1 = require("./AbstractIssuanceBrandingStore");
|
|
28
|
-
const debug = (0, debug_1.default)('sphereon:ssi-sdk:issuance-branding-store');
|
|
29
|
-
class IssuanceBrandingStore extends AbstractIssuanceBrandingStore_1.AbstractIssuanceBrandingStore {
|
|
1
|
+
import Debug from 'debug';
|
|
2
|
+
import { In, Not } from 'typeorm';
|
|
3
|
+
import { credentialBrandingEntityFrom, credentialBrandingFrom, credentialLocaleBrandingEntityFrom, issuerBrandingEntityFrom, issuerBrandingFrom, issuerLocaleBrandingEntityFrom, localeBrandingFrom, } from '../utils/issuanceBranding/MappingUtils';
|
|
4
|
+
import { BackgroundAttributesEntity } from '../entities/issuanceBranding/BackgroundAttributesEntity';
|
|
5
|
+
import { ImageAttributesEntity } from '../entities/issuanceBranding/ImageAttributesEntity';
|
|
6
|
+
import { ImageDimensionsEntity } from '../entities/issuanceBranding/ImageDimensionsEntity';
|
|
7
|
+
import { IssuerBrandingEntity } from '../entities/issuanceBranding/IssuerBrandingEntity';
|
|
8
|
+
import { CredentialBrandingEntity } from '../entities/issuanceBranding/CredentialBrandingEntity';
|
|
9
|
+
import { CredentialLocaleBrandingEntity } from '../entities/issuanceBranding/CredentialLocaleBrandingEntity';
|
|
10
|
+
import { IssuerLocaleBrandingEntity } from '../entities/issuanceBranding/IssuerLocaleBrandingEntity';
|
|
11
|
+
import { TextAttributesEntity } from '../entities/issuanceBranding/TextAttributesEntity';
|
|
12
|
+
import { AbstractIssuanceBrandingStore } from './AbstractIssuanceBrandingStore';
|
|
13
|
+
const debug = Debug('sphereon:ssi-sdk:issuance-branding-store');
|
|
14
|
+
export class IssuanceBrandingStore extends AbstractIssuanceBrandingStore {
|
|
15
|
+
dbConnection;
|
|
30
16
|
constructor(dbConnection) {
|
|
31
17
|
super();
|
|
32
|
-
this.
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
18
|
+
this.dbConnection = dbConnection;
|
|
19
|
+
}
|
|
20
|
+
addCredentialBranding = async (args) => {
|
|
21
|
+
const { localeBranding, vcHash } = args;
|
|
22
|
+
const repository = (await this.dbConnection).getRepository(CredentialBrandingEntity);
|
|
23
|
+
const result = await repository.findOne({
|
|
24
|
+
where: [{ vcHash }],
|
|
25
|
+
});
|
|
26
|
+
if (result) {
|
|
27
|
+
return Promise.reject(Error(`Credential branding already present for vc with hash: ${vcHash}`));
|
|
28
|
+
}
|
|
29
|
+
if (await this.hasDuplicateLocales(localeBranding)) {
|
|
30
|
+
return Promise.reject(Error(`Credential branding contains duplicate locales`));
|
|
31
|
+
}
|
|
32
|
+
const credentialBrandingEntity = credentialBrandingEntityFrom(args);
|
|
33
|
+
debug('Adding credential branding', credentialBrandingEntity);
|
|
34
|
+
const createdResult = await repository.save(credentialBrandingEntity);
|
|
35
|
+
return credentialBrandingFrom(createdResult);
|
|
36
|
+
};
|
|
37
|
+
getCredentialBranding = async (args) => {
|
|
38
|
+
const { filter } = args ?? {};
|
|
39
|
+
if (filter) {
|
|
40
|
+
filter.forEach((filter) => {
|
|
41
|
+
if (filter.localeBranding && 'locale' in filter.localeBranding && filter.localeBranding.locale === undefined) {
|
|
42
|
+
filter.localeBranding.locale = '';
|
|
43
|
+
}
|
|
37
44
|
});
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
return Promise.reject(Error(`Credential branding contains duplicate locales`));
|
|
43
|
-
}
|
|
44
|
-
const credentialBrandingEntity = (0, MappingUtils_1.credentialBrandingEntityFrom)(args);
|
|
45
|
-
debug('Adding credential branding', credentialBrandingEntity);
|
|
46
|
-
const createdResult = yield repository.save(credentialBrandingEntity);
|
|
47
|
-
return (0, MappingUtils_1.credentialBrandingFrom)(createdResult);
|
|
45
|
+
}
|
|
46
|
+
debug('Getting credential branding', args);
|
|
47
|
+
const result = await (await this.dbConnection).getRepository(CredentialBrandingEntity).find({
|
|
48
|
+
...(filter && { where: filter }),
|
|
48
49
|
});
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
});
|
|
57
|
-
}
|
|
58
|
-
debug('Getting credential branding', args);
|
|
59
|
-
const result = yield (yield this.dbConnection).getRepository(CredentialBrandingEntity_1.CredentialBrandingEntity).find(Object.assign({}, (filter && { where: filter })));
|
|
60
|
-
return result.map((credentialBranding) => (0, MappingUtils_1.credentialBrandingFrom)(credentialBranding));
|
|
50
|
+
return result.map((credentialBranding) => credentialBrandingFrom(credentialBranding));
|
|
51
|
+
};
|
|
52
|
+
removeCredentialBranding = async (args) => {
|
|
53
|
+
const { filter } = args;
|
|
54
|
+
const repository = (await this.dbConnection).getRepository(CredentialBrandingEntity);
|
|
55
|
+
const credentialBranding = await repository.find({
|
|
56
|
+
where: filter,
|
|
61
57
|
});
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
58
|
+
debug('Removing credential locale branding', args);
|
|
59
|
+
const localeBrandingDeletions = credentialBranding.map((credentialBranding) => credentialBranding.localeBranding.map(async (localeBranding) => this.removeLocaleBranding(localeBranding)));
|
|
60
|
+
await Promise.all(localeBrandingDeletions);
|
|
61
|
+
debug('Removing credential branding', args);
|
|
62
|
+
const credentialBrandingDeletions = filter.map(async (filter) => await repository.delete(filter));
|
|
63
|
+
await Promise.all(credentialBrandingDeletions);
|
|
64
|
+
};
|
|
65
|
+
updateCredentialBranding = async (args) => {
|
|
66
|
+
const { credentialBranding } = args;
|
|
67
|
+
const repository = (await this.dbConnection).getRepository(CredentialBrandingEntity);
|
|
68
|
+
const credentialBrandingEntity = await repository.findOne({
|
|
69
|
+
where: { id: credentialBranding.id },
|
|
74
70
|
});
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
71
|
+
if (!credentialBrandingEntity) {
|
|
72
|
+
return Promise.reject(Error(`No credential branding found for id: ${credentialBranding.id}`));
|
|
73
|
+
}
|
|
74
|
+
const branding = {
|
|
75
|
+
...credentialBranding,
|
|
76
|
+
localeBranding: credentialBrandingEntity.localeBranding,
|
|
77
|
+
};
|
|
78
|
+
debug('Updating credential branding', branding);
|
|
79
|
+
const result = await repository.save(branding, { transaction: true });
|
|
80
|
+
return credentialBrandingFrom(result);
|
|
81
|
+
};
|
|
82
|
+
addCredentialLocaleBranding = async (args) => {
|
|
83
|
+
const { credentialBrandingId, localeBranding } = args;
|
|
84
|
+
const credentialBrandingRepository = (await this.dbConnection).getRepository(CredentialBrandingEntity);
|
|
85
|
+
const credentialBranding = await credentialBrandingRepository.findOne({
|
|
86
|
+
where: { id: credentialBrandingId },
|
|
88
87
|
});
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
return Promise.reject(Error(`No credential branding found for id: ${credentialBrandingId}`));
|
|
97
|
-
}
|
|
98
|
-
const locales = yield (yield this.dbConnection).getRepository(CredentialLocaleBrandingEntity_1.CredentialLocaleBrandingEntity).find({
|
|
99
|
-
where: {
|
|
100
|
-
credentialBranding: {
|
|
101
|
-
id: credentialBrandingId,
|
|
102
|
-
},
|
|
103
|
-
locale: (0, typeorm_1.In)(localeBranding.map((localeBranding) => localeBranding.locale)),
|
|
88
|
+
if (!credentialBranding) {
|
|
89
|
+
return Promise.reject(Error(`No credential branding found for id: ${credentialBrandingId}`));
|
|
90
|
+
}
|
|
91
|
+
const locales = await (await this.dbConnection).getRepository(CredentialLocaleBrandingEntity).find({
|
|
92
|
+
where: {
|
|
93
|
+
credentialBranding: {
|
|
94
|
+
id: credentialBrandingId,
|
|
104
95
|
},
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
return Promise.reject(Error(`Credential branding already contains locales: ${locales === null || locales === void 0 ? void 0 : locales.map((credentialLocaleBrandingEntity) => credentialLocaleBrandingEntity.locale)}`));
|
|
108
|
-
}
|
|
109
|
-
const credentialLocaleBrandingRepository = (yield this.dbConnection).getRepository(CredentialLocaleBrandingEntity_1.CredentialLocaleBrandingEntity);
|
|
110
|
-
const addCredentialLocaleBranding = localeBranding.map((localeBranding) => __awaiter(this, void 0, void 0, function* () {
|
|
111
|
-
const credentialLocaleBrandingEntity = (0, MappingUtils_1.credentialLocaleBrandingEntityFrom)(localeBranding);
|
|
112
|
-
debug('Adding credential locale branding', credentialLocaleBrandingEntity);
|
|
113
|
-
credentialLocaleBrandingEntity.credentialBranding = credentialBranding;
|
|
114
|
-
yield credentialLocaleBrandingRepository.save(credentialLocaleBrandingEntity, { transaction: true });
|
|
115
|
-
}));
|
|
116
|
-
yield Promise.all(addCredentialLocaleBranding);
|
|
117
|
-
const result = yield credentialBrandingRepository.findOne({
|
|
118
|
-
where: { id: credentialBrandingId },
|
|
119
|
-
});
|
|
120
|
-
if (!result) {
|
|
121
|
-
return Promise.reject(Error('Unable to get updated credential branding'));
|
|
122
|
-
}
|
|
123
|
-
return (0, MappingUtils_1.credentialBrandingFrom)(result);
|
|
96
|
+
locale: In(localeBranding.map((localeBranding) => localeBranding.locale)),
|
|
97
|
+
},
|
|
124
98
|
});
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
}
|
|
134
|
-
debug('Getting credential locale branding', args);
|
|
135
|
-
const credentialBrandingLocale = yield (yield this.dbConnection)
|
|
136
|
-
.getRepository(CredentialLocaleBrandingEntity_1.CredentialLocaleBrandingEntity)
|
|
137
|
-
.find(Object.assign({}, (filter && { where: filter })));
|
|
138
|
-
return credentialBrandingLocale
|
|
139
|
-
? credentialBrandingLocale.map((credentialLocaleBranding) => (0, MappingUtils_1.localeBrandingFrom)(credentialLocaleBranding))
|
|
140
|
-
: [];
|
|
99
|
+
if (locales && locales.length > 0) {
|
|
100
|
+
return Promise.reject(Error(`Credential branding already contains locales: ${locales?.map((credentialLocaleBrandingEntity) => credentialLocaleBrandingEntity.locale)}`));
|
|
101
|
+
}
|
|
102
|
+
const credentialLocaleBrandingRepository = (await this.dbConnection).getRepository(CredentialLocaleBrandingEntity);
|
|
103
|
+
const addCredentialLocaleBranding = localeBranding.map(async (localeBranding) => {
|
|
104
|
+
const credentialLocaleBrandingEntity = credentialLocaleBrandingEntityFrom(localeBranding);
|
|
105
|
+
debug('Adding credential locale branding', credentialLocaleBrandingEntity);
|
|
106
|
+
credentialLocaleBrandingEntity.credentialBranding = credentialBranding;
|
|
107
|
+
await credentialLocaleBrandingRepository.save(credentialLocaleBrandingEntity, { transaction: true });
|
|
141
108
|
});
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
.getRepository(CredentialLocaleBrandingEntity_1.CredentialLocaleBrandingEntity)
|
|
146
|
-
.find({
|
|
147
|
-
where: filter,
|
|
148
|
-
});
|
|
149
|
-
debug('Removing credential locale branding', args);
|
|
150
|
-
const localeBrandingDeletions = credentialLocaleBranding.map((localeBranding) => __awaiter(this, void 0, void 0, function* () { return this.removeLocaleBranding(localeBranding); }));
|
|
151
|
-
yield Promise.all(localeBrandingDeletions);
|
|
109
|
+
await Promise.all(addCredentialLocaleBranding);
|
|
110
|
+
const result = await credentialBrandingRepository.findOne({
|
|
111
|
+
where: { id: credentialBrandingId },
|
|
152
112
|
});
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
113
|
+
if (!result) {
|
|
114
|
+
return Promise.reject(Error('Unable to get updated credential branding'));
|
|
115
|
+
}
|
|
116
|
+
return credentialBrandingFrom(result);
|
|
117
|
+
};
|
|
118
|
+
getCredentialLocaleBranding = async (args) => {
|
|
119
|
+
const { filter } = args ?? {};
|
|
120
|
+
if (filter) {
|
|
121
|
+
filter.forEach((filter) => {
|
|
122
|
+
if ('locale' in filter && filter.locale === undefined) {
|
|
123
|
+
filter.locale = '';
|
|
124
|
+
}
|
|
158
125
|
});
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
126
|
+
}
|
|
127
|
+
debug('Getting credential locale branding', args);
|
|
128
|
+
const credentialBrandingLocale = await (await this.dbConnection)
|
|
129
|
+
.getRepository(CredentialLocaleBrandingEntity)
|
|
130
|
+
.find({
|
|
131
|
+
...(filter && { where: filter }),
|
|
132
|
+
});
|
|
133
|
+
return credentialBrandingLocale
|
|
134
|
+
? credentialBrandingLocale.map((credentialLocaleBranding) => localeBrandingFrom(credentialLocaleBranding))
|
|
135
|
+
: [];
|
|
136
|
+
};
|
|
137
|
+
removeCredentialLocaleBranding = async (args) => {
|
|
138
|
+
const { filter } = args;
|
|
139
|
+
const credentialLocaleBranding = await (await this.dbConnection)
|
|
140
|
+
.getRepository(CredentialLocaleBrandingEntity)
|
|
141
|
+
.find({
|
|
142
|
+
where: filter,
|
|
143
|
+
});
|
|
144
|
+
debug('Removing credential locale branding', args);
|
|
145
|
+
const localeBrandingDeletions = credentialLocaleBranding.map(async (localeBranding) => this.removeLocaleBranding(localeBranding));
|
|
146
|
+
await Promise.all(localeBrandingDeletions);
|
|
147
|
+
};
|
|
148
|
+
updateCredentialLocaleBranding = async (args) => {
|
|
149
|
+
const { localeBranding } = args;
|
|
150
|
+
const repository = (await this.dbConnection).getRepository(CredentialLocaleBrandingEntity);
|
|
151
|
+
const result = await repository.findOne({
|
|
152
|
+
where: { id: localeBranding.id },
|
|
153
|
+
});
|
|
154
|
+
if (!result) {
|
|
155
|
+
return Promise.reject(Error(`No credential locale branding found for id: ${localeBranding.id}`));
|
|
156
|
+
}
|
|
157
|
+
const locales = await repository.find({
|
|
158
|
+
where: {
|
|
159
|
+
credentialBranding: {
|
|
160
|
+
id: result.credentialBrandingId,
|
|
169
161
|
},
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
162
|
+
id: Not(In([localeBranding.id])),
|
|
163
|
+
locale: localeBranding.locale,
|
|
164
|
+
},
|
|
165
|
+
});
|
|
166
|
+
if (locales && locales.length > 0) {
|
|
167
|
+
return Promise.reject(Error(`Credential branding: ${result.credentialBrandingId} already contains locale: ${localeBranding.locale}`));
|
|
168
|
+
}
|
|
169
|
+
debug('Updating credential locale branding', localeBranding);
|
|
170
|
+
const updatedResult = await repository.save(localeBranding, { transaction: true });
|
|
171
|
+
return localeBrandingFrom(updatedResult);
|
|
172
|
+
};
|
|
173
|
+
addIssuerBranding = async (args) => {
|
|
174
|
+
const { localeBranding, issuerCorrelationId } = args;
|
|
175
|
+
const repository = (await this.dbConnection).getRepository(IssuerBrandingEntity);
|
|
176
|
+
const result = await repository.findOne({
|
|
177
|
+
where: [{ issuerCorrelationId }],
|
|
177
178
|
});
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
179
|
+
if (result) {
|
|
180
|
+
return Promise.reject(Error(`Issuer branding already present for issuer with correlation id: ${issuerCorrelationId}`));
|
|
181
|
+
}
|
|
182
|
+
if (await this.hasDuplicateLocales(localeBranding)) {
|
|
183
|
+
return Promise.reject(Error(`Issuer branding contains duplicate locales`));
|
|
184
|
+
}
|
|
185
|
+
const issuerBrandingEntity = issuerBrandingEntityFrom(args);
|
|
186
|
+
debug('Adding issuer branding', issuerBrandingEntity);
|
|
187
|
+
const createdResult = await repository.save(issuerBrandingEntity);
|
|
188
|
+
return issuerBrandingFrom(createdResult);
|
|
189
|
+
};
|
|
190
|
+
getIssuerBranding = async (args) => {
|
|
191
|
+
const { filter } = args ?? {};
|
|
192
|
+
if (filter) {
|
|
193
|
+
filter.forEach((filter) => {
|
|
194
|
+
if (filter.localeBranding && 'locale' in filter.localeBranding && filter.localeBranding.locale === undefined) {
|
|
195
|
+
filter.localeBranding.locale = '';
|
|
196
|
+
}
|
|
183
197
|
});
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
return Promise.reject(Error(`Issuer branding contains duplicate locales`));
|
|
189
|
-
}
|
|
190
|
-
const issuerBrandingEntity = (0, MappingUtils_1.issuerBrandingEntityFrom)(args);
|
|
191
|
-
debug('Adding issuer branding', issuerBrandingEntity);
|
|
192
|
-
const createdResult = yield repository.save(issuerBrandingEntity);
|
|
193
|
-
return (0, MappingUtils_1.issuerBrandingFrom)(createdResult);
|
|
198
|
+
}
|
|
199
|
+
debug('Getting issuer branding', args);
|
|
200
|
+
const result = await (await this.dbConnection).getRepository(IssuerBrandingEntity).find({
|
|
201
|
+
...(filter && { where: filter }),
|
|
194
202
|
});
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
});
|
|
203
|
-
}
|
|
204
|
-
debug('Getting issuer branding', args);
|
|
205
|
-
const result = yield (yield this.dbConnection).getRepository(IssuerBrandingEntity_1.IssuerBrandingEntity).find(Object.assign({}, (filter && { where: filter })));
|
|
206
|
-
return result.map((issuerBranding) => (0, MappingUtils_1.issuerBrandingFrom)(issuerBranding));
|
|
203
|
+
return result.map((issuerBranding) => issuerBrandingFrom(issuerBranding));
|
|
204
|
+
};
|
|
205
|
+
removeIssuerBranding = async (args) => {
|
|
206
|
+
const { filter } = args;
|
|
207
|
+
const repository = (await this.dbConnection).getRepository(IssuerBrandingEntity);
|
|
208
|
+
const issuerBranding = await repository.find({
|
|
209
|
+
where: filter,
|
|
207
210
|
});
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
211
|
+
debug('Removing issuer locale branding', args);
|
|
212
|
+
const localeBrandingDeletions = issuerBranding.map((issuerBranding) => issuerBranding.localeBranding.map(async (localeBranding) => this.removeLocaleBranding(localeBranding)));
|
|
213
|
+
await Promise.all(localeBrandingDeletions);
|
|
214
|
+
debug('Removing issuer branding', args);
|
|
215
|
+
const issuerBrandingDeletions = filter.map(async (filter) => await repository.delete(filter));
|
|
216
|
+
await Promise.all(issuerBrandingDeletions);
|
|
217
|
+
};
|
|
218
|
+
updateIssuerBranding = async (args) => {
|
|
219
|
+
const { issuerBranding } = args;
|
|
220
|
+
const repository = (await this.dbConnection).getRepository(IssuerBrandingEntity);
|
|
221
|
+
const issuerBrandingEntity = await repository.findOne({
|
|
222
|
+
where: { id: issuerBranding.id },
|
|
220
223
|
});
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
224
|
+
if (!issuerBrandingEntity) {
|
|
225
|
+
return Promise.reject(Error(`No issuer branding found for id: ${issuerBranding.id}`));
|
|
226
|
+
}
|
|
227
|
+
const branding = {
|
|
228
|
+
...issuerBranding,
|
|
229
|
+
localeBranding: issuerBrandingEntity.localeBranding,
|
|
230
|
+
};
|
|
231
|
+
debug('Updating issuer branding', branding);
|
|
232
|
+
const result = await repository.save(branding, { transaction: true });
|
|
233
|
+
return issuerBrandingFrom(result);
|
|
234
|
+
};
|
|
235
|
+
addIssuerLocaleBranding = async (args) => {
|
|
236
|
+
const { localeBranding, issuerBrandingId } = args;
|
|
237
|
+
const issuerBrandingRepository = (await this.dbConnection).getRepository(IssuerBrandingEntity);
|
|
238
|
+
const issuerBranding = await issuerBrandingRepository.findOne({
|
|
239
|
+
where: { id: issuerBrandingId },
|
|
234
240
|
});
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
return Promise.reject(Error(`No issuer branding found for id: ${issuerBrandingId}`));
|
|
243
|
-
}
|
|
244
|
-
const locales = yield (yield this.dbConnection).getRepository(IssuerLocaleBrandingEntity_1.IssuerLocaleBrandingEntity).find({
|
|
245
|
-
where: {
|
|
246
|
-
issuerBranding: {
|
|
247
|
-
id: issuerBrandingId,
|
|
248
|
-
},
|
|
249
|
-
locale: (0, typeorm_1.In)(localeBranding.map((localeBranding) => localeBranding.locale)),
|
|
241
|
+
if (!issuerBranding) {
|
|
242
|
+
return Promise.reject(Error(`No issuer branding found for id: ${issuerBrandingId}`));
|
|
243
|
+
}
|
|
244
|
+
const locales = await (await this.dbConnection).getRepository(IssuerLocaleBrandingEntity).find({
|
|
245
|
+
where: {
|
|
246
|
+
issuerBranding: {
|
|
247
|
+
id: issuerBrandingId,
|
|
250
248
|
},
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
return Promise.reject(Error(`Issuer branding already contains locales: ${locales === null || locales === void 0 ? void 0 : locales.map((issuerLocaleBrandingEntity) => issuerLocaleBrandingEntity.locale)}`));
|
|
254
|
-
}
|
|
255
|
-
const issuerLocaleBrandingRepository = (yield this.dbConnection).getRepository(IssuerLocaleBrandingEntity_1.IssuerLocaleBrandingEntity);
|
|
256
|
-
const addIssuerLocaleBranding = localeBranding.map((localeBranding) => __awaiter(this, void 0, void 0, function* () {
|
|
257
|
-
const issuerLocaleBrandingEntity = (0, MappingUtils_1.issuerLocaleBrandingEntityFrom)(localeBranding);
|
|
258
|
-
debug('Adding issuer locale branding', issuerLocaleBrandingEntity);
|
|
259
|
-
issuerLocaleBrandingEntity.issuerBranding = issuerBranding;
|
|
260
|
-
yield issuerLocaleBrandingRepository.save(issuerLocaleBrandingEntity, { transaction: true });
|
|
261
|
-
}));
|
|
262
|
-
yield Promise.all(addIssuerLocaleBranding);
|
|
263
|
-
const result = yield issuerBrandingRepository.findOne({
|
|
264
|
-
where: { id: issuerBrandingId },
|
|
265
|
-
});
|
|
266
|
-
if (!result) {
|
|
267
|
-
return Promise.reject(Error('Unable to get updated issuer branding'));
|
|
268
|
-
}
|
|
269
|
-
return (0, MappingUtils_1.issuerBrandingFrom)(result);
|
|
249
|
+
locale: In(localeBranding.map((localeBranding) => localeBranding.locale)),
|
|
250
|
+
},
|
|
270
251
|
});
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
}
|
|
280
|
-
debug('Getting issuer locale branding', args);
|
|
281
|
-
const issuerLocaleBranding = yield (yield this.dbConnection)
|
|
282
|
-
.getRepository(IssuerLocaleBrandingEntity_1.IssuerLocaleBrandingEntity)
|
|
283
|
-
.find(Object.assign({}, (filter && { where: filter })));
|
|
284
|
-
return issuerLocaleBranding
|
|
285
|
-
? issuerLocaleBranding.map((issuerLocaleBranding) => (0, MappingUtils_1.localeBrandingFrom)(issuerLocaleBranding))
|
|
286
|
-
: [];
|
|
252
|
+
if (locales && locales.length > 0) {
|
|
253
|
+
return Promise.reject(Error(`Issuer branding already contains locales: ${locales?.map((issuerLocaleBrandingEntity) => issuerLocaleBrandingEntity.locale)}`));
|
|
254
|
+
}
|
|
255
|
+
const issuerLocaleBrandingRepository = (await this.dbConnection).getRepository(IssuerLocaleBrandingEntity);
|
|
256
|
+
const addIssuerLocaleBranding = localeBranding.map(async (localeBranding) => {
|
|
257
|
+
const issuerLocaleBrandingEntity = issuerLocaleBrandingEntityFrom(localeBranding);
|
|
258
|
+
debug('Adding issuer locale branding', issuerLocaleBrandingEntity);
|
|
259
|
+
issuerLocaleBrandingEntity.issuerBranding = issuerBranding;
|
|
260
|
+
await issuerLocaleBrandingRepository.save(issuerLocaleBrandingEntity, { transaction: true });
|
|
287
261
|
});
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
where: filter,
|
|
292
|
-
});
|
|
293
|
-
debug('Removing credential locale branding', args);
|
|
294
|
-
const localeBrandingDeletions = issuerLocaleBranding.map((localeBranding) => __awaiter(this, void 0, void 0, function* () { return this.removeLocaleBranding(localeBranding); }));
|
|
295
|
-
yield Promise.all(localeBrandingDeletions);
|
|
262
|
+
await Promise.all(addIssuerLocaleBranding);
|
|
263
|
+
const result = await issuerBrandingRepository.findOne({
|
|
264
|
+
where: { id: issuerBrandingId },
|
|
296
265
|
});
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
id: result.issuerBrandingId,
|
|
310
|
-
},
|
|
311
|
-
id: (0, typeorm_1.Not)((0, typeorm_1.In)([localeBranding.id])),
|
|
312
|
-
locale: localeBranding.locale,
|
|
313
|
-
},
|
|
266
|
+
if (!result) {
|
|
267
|
+
return Promise.reject(Error('Unable to get updated issuer branding'));
|
|
268
|
+
}
|
|
269
|
+
return issuerBrandingFrom(result);
|
|
270
|
+
};
|
|
271
|
+
getIssuerLocaleBranding = async (args) => {
|
|
272
|
+
const { filter } = args ?? {};
|
|
273
|
+
if (filter) {
|
|
274
|
+
filter.forEach((filter) => {
|
|
275
|
+
if ('locale' in filter && filter.locale === undefined) {
|
|
276
|
+
filter.locale = '';
|
|
277
|
+
}
|
|
314
278
|
});
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
279
|
+
}
|
|
280
|
+
debug('Getting issuer locale branding', args);
|
|
281
|
+
const issuerLocaleBranding = await (await this.dbConnection)
|
|
282
|
+
.getRepository(IssuerLocaleBrandingEntity)
|
|
283
|
+
.find({
|
|
284
|
+
...(filter && { where: filter }),
|
|
321
285
|
});
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
286
|
+
return issuerLocaleBranding
|
|
287
|
+
? issuerLocaleBranding.map((issuerLocaleBranding) => localeBrandingFrom(issuerLocaleBranding))
|
|
288
|
+
: [];
|
|
289
|
+
};
|
|
290
|
+
removeIssuerLocaleBranding = async (args) => {
|
|
291
|
+
const { filter } = args;
|
|
292
|
+
const issuerLocaleBranding = await (await this.dbConnection).getRepository(IssuerLocaleBrandingEntity).find({
|
|
293
|
+
where: filter,
|
|
327
294
|
});
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
yield (yield this.dbConnection).getRepository(ImageAttributesEntity_1.ImageAttributesEntity).delete({ id: (_h = (_g = localeBranding.background) === null || _g === void 0 ? void 0 : _g.image) === null || _h === void 0 ? void 0 : _h.id });
|
|
338
|
-
}
|
|
339
|
-
// Delete background
|
|
340
|
-
if (localeBranding.background) {
|
|
341
|
-
yield (yield this.dbConnection).getRepository(BackgroundAttributesEntity_1.BackgroundAttributesEntity).delete({ id: (_j = localeBranding.background) === null || _j === void 0 ? void 0 : _j.id });
|
|
342
|
-
}
|
|
343
|
-
// Delete logo image dimensions
|
|
344
|
-
if ((_k = localeBranding.logo) === null || _k === void 0 ? void 0 : _k.dimensions) {
|
|
345
|
-
yield (yield this.dbConnection).getRepository(ImageDimensionsEntity_1.ImageDimensionsEntity).delete({ id: (_m = (_l = localeBranding.logo) === null || _l === void 0 ? void 0 : _l.dimensions) === null || _m === void 0 ? void 0 : _m.id });
|
|
346
|
-
}
|
|
347
|
-
// Delete logo
|
|
348
|
-
if (localeBranding.logo) {
|
|
349
|
-
yield (yield this.dbConnection).getRepository(ImageAttributesEntity_1.ImageAttributesEntity).delete({ id: (_o = localeBranding.logo) === null || _o === void 0 ? void 0 : _o.id });
|
|
350
|
-
}
|
|
351
|
-
// Delete text
|
|
352
|
-
if (localeBranding.text) {
|
|
353
|
-
yield (yield this.dbConnection).getRepository(TextAttributesEntity_1.TextAttributesEntity).delete({ id: (_p = localeBranding.text) === null || _p === void 0 ? void 0 : _p.id });
|
|
354
|
-
}
|
|
355
|
-
// Delete locale branding
|
|
356
|
-
yield (yield this.dbConnection).getRepository(CredentialLocaleBrandingEntity_1.CredentialLocaleBrandingEntity).delete({ id: localeBranding.id });
|
|
295
|
+
debug('Removing credential locale branding', args);
|
|
296
|
+
const localeBrandingDeletions = issuerLocaleBranding.map(async (localeBranding) => this.removeLocaleBranding(localeBranding));
|
|
297
|
+
await Promise.all(localeBrandingDeletions);
|
|
298
|
+
};
|
|
299
|
+
updateIssuerLocaleBranding = async (args) => {
|
|
300
|
+
const { localeBranding } = args;
|
|
301
|
+
const repository = (await this.dbConnection).getRepository(IssuerLocaleBrandingEntity);
|
|
302
|
+
const result = await repository.findOne({
|
|
303
|
+
where: { id: localeBranding.id },
|
|
357
304
|
});
|
|
358
|
-
|
|
359
|
-
|
|
305
|
+
if (!result) {
|
|
306
|
+
return Promise.reject(Error(`No issuer locale branding found for id: ${localeBranding.id}`));
|
|
307
|
+
}
|
|
308
|
+
const locales = await repository.find({
|
|
309
|
+
where: {
|
|
310
|
+
issuerBranding: {
|
|
311
|
+
id: result.issuerBrandingId,
|
|
312
|
+
},
|
|
313
|
+
id: Not(In([localeBranding.id])),
|
|
314
|
+
locale: localeBranding.locale,
|
|
315
|
+
},
|
|
316
|
+
});
|
|
317
|
+
if (locales && locales.length > 0) {
|
|
318
|
+
return Promise.reject(Error(`Issuer branding: ${result.issuerBrandingId} already contains locale: ${localeBranding.locale}`));
|
|
319
|
+
}
|
|
320
|
+
debug('Updating issuer locale branding', localeBranding);
|
|
321
|
+
const updatedResult = await repository.save(localeBranding, { transaction: true });
|
|
322
|
+
return localeBrandingFrom(updatedResult);
|
|
323
|
+
};
|
|
324
|
+
hasDuplicateLocales = async (localeBranding) => {
|
|
325
|
+
let seen = new Set();
|
|
326
|
+
return localeBranding.some((localeBranding) => {
|
|
327
|
+
return seen.size === seen.add(localeBranding.locale).size;
|
|
328
|
+
});
|
|
329
|
+
};
|
|
330
|
+
removeLocaleBranding = async (localeBranding) => {
|
|
331
|
+
debug('Removing credential locale branding', localeBranding);
|
|
332
|
+
// Delete background image dimensions
|
|
333
|
+
if (localeBranding.background?.image?.dimensions) {
|
|
334
|
+
await (await this.dbConnection).getRepository(ImageDimensionsEntity).delete({ id: localeBranding.background?.image?.dimensions?.id });
|
|
335
|
+
}
|
|
336
|
+
// Delete background image
|
|
337
|
+
if (localeBranding.background?.image) {
|
|
338
|
+
await (await this.dbConnection).getRepository(ImageAttributesEntity).delete({ id: localeBranding.background?.image?.id });
|
|
339
|
+
}
|
|
340
|
+
// Delete background
|
|
341
|
+
if (localeBranding.background) {
|
|
342
|
+
await (await this.dbConnection).getRepository(BackgroundAttributesEntity).delete({ id: localeBranding.background?.id });
|
|
343
|
+
}
|
|
344
|
+
// Delete logo image dimensions
|
|
345
|
+
if (localeBranding.logo?.dimensions) {
|
|
346
|
+
await (await this.dbConnection).getRepository(ImageDimensionsEntity).delete({ id: localeBranding.logo?.dimensions?.id });
|
|
347
|
+
}
|
|
348
|
+
// Delete logo
|
|
349
|
+
if (localeBranding.logo) {
|
|
350
|
+
await (await this.dbConnection).getRepository(ImageAttributesEntity).delete({ id: localeBranding.logo?.id });
|
|
351
|
+
}
|
|
352
|
+
// Delete text
|
|
353
|
+
if (localeBranding.text) {
|
|
354
|
+
await (await this.dbConnection).getRepository(TextAttributesEntity).delete({ id: localeBranding.text?.id });
|
|
355
|
+
}
|
|
356
|
+
// Delete locale branding
|
|
357
|
+
await (await this.dbConnection).getRepository(CredentialLocaleBrandingEntity).delete({ id: localeBranding.id });
|
|
358
|
+
};
|
|
360
359
|
}
|
|
361
|
-
exports.IssuanceBrandingStore = IssuanceBrandingStore;
|
|
362
360
|
//# sourceMappingURL=IssuanceBrandingStore.js.map
|