@sphereon/ssi-sdk.data-store 0.37.1 → 0.37.2-next.14
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 +1544 -502
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +84 -5
- package/dist/index.d.ts +84 -5
- package/dist/index.js +1457 -415
- package/dist/index.js.map +1 -1
- package/package.json +8 -8
- package/src/__tests__/credential-design-store.test.ts +419 -0
- package/src/__tests__/credential-design.entities.test.ts +205 -0
- package/src/__tests__/issuanceBranding.entities.test.ts +1 -1
- package/src/__tests__/issuanceBranding.store.test.ts +1 -1
- package/src/credentialDesign/CredentialDesignStore.ts +201 -0
- package/src/entities/credentialDesign/CredentialDesignBrandingEntity.ts +39 -0
- package/src/entities/credentialDesign/FormStepEntity.ts +32 -0
- package/src/entities/credentialDesign/MetaDataKeyEntity.ts +30 -0
- package/src/entities/credentialDesign/MetaDataSetEntity.ts +39 -0
- package/src/entities/credentialDesign/MetaDataValueEntity.ts +30 -0
- package/src/entities/credentialDesign/SchemaDefinitionEntity.ts +36 -0
- package/src/entities/credentialDesign/index.ts +6 -0
- package/src/index.ts +26 -0
- package/src/migrations/generic/18-AddCredentialDesigns.ts +64 -0
- package/src/migrations/generic/index.ts +5 -2
- package/src/migrations/index.ts +1 -0
- package/src/migrations/postgres/1773657426000-AddCredentialDesigns.ts +208 -0
- package/src/migrations/sqlite/1773657426000-AddCredentialDesigns.ts +55 -0
- package/src/utils/credentialDesign/MappingUtils.ts +147 -0
|
@@ -0,0 +1,208 @@
|
|
|
1
|
+
import { MigrationInterface, QueryRunner } from 'typeorm'
|
|
2
|
+
|
|
3
|
+
export class AddCredentialDesignsPostgres1773657426000 implements MigrationInterface {
|
|
4
|
+
name = 'AddCredentialDesignsPostgres1773657426000'
|
|
5
|
+
|
|
6
|
+
public async up(queryRunner: QueryRunner): Promise<void> {
|
|
7
|
+
|
|
8
|
+
await queryRunner.query(`
|
|
9
|
+
CREATE TYPE IF NOT EXISTS "value_type" AS ENUM ('Text', 'Number', 'Boolean', 'Date');
|
|
10
|
+
`)
|
|
11
|
+
|
|
12
|
+
await queryRunner.query(`
|
|
13
|
+
CREATE TABLE IF NOT EXISTS "meta_data_set"
|
|
14
|
+
(
|
|
15
|
+
"id" uuid NOT NULL DEFAULT gen_random_uuid(),
|
|
16
|
+
"tenant_id" uuid,
|
|
17
|
+
"name" text NOT NULL,
|
|
18
|
+
CONSTRAINT "meta_data_set_pkey" PRIMARY KEY ("id")
|
|
19
|
+
)
|
|
20
|
+
`)
|
|
21
|
+
|
|
22
|
+
await queryRunner.query(`
|
|
23
|
+
CREATE UNIQUE INDEX IF NOT EXISTS "meta_data_set_unique_tenant" ON "meta_data_set" ("name", "tenant_id")
|
|
24
|
+
`)
|
|
25
|
+
|
|
26
|
+
await queryRunner.query(`
|
|
27
|
+
CREATE TABLE IF NOT EXISTS "meta_data_keys"
|
|
28
|
+
(
|
|
29
|
+
"id" uuid NOT NULL DEFAULT gen_random_uuid(),
|
|
30
|
+
"set_id" uuid NOT NULL,
|
|
31
|
+
"key" text NOT NULL,
|
|
32
|
+
"value_type" value_type NOT NULL,
|
|
33
|
+
CONSTRAINT "meta_data_keys_pkey" PRIMARY KEY ("id"),
|
|
34
|
+
CONSTRAINT "fk_meta_data_set" FOREIGN KEY ("set_id")
|
|
35
|
+
REFERENCES "meta_data_set" ("id")
|
|
36
|
+
)
|
|
37
|
+
`)
|
|
38
|
+
|
|
39
|
+
await queryRunner.query(`
|
|
40
|
+
CREATE TABLE IF NOT EXISTS "meta_data_values"
|
|
41
|
+
(
|
|
42
|
+
"id" uuid NOT NULL DEFAULT gen_random_uuid(),
|
|
43
|
+
"key_id" uuid NOT NULL,
|
|
44
|
+
"index" numeric,
|
|
45
|
+
"text_value" text,
|
|
46
|
+
"number_value" numeric,
|
|
47
|
+
"boolean_value" boolean,
|
|
48
|
+
"timestamp_value" timestamp without time zone,
|
|
49
|
+
CONSTRAINT "meta_data_values_pkey" PRIMARY KEY ("id"),
|
|
50
|
+
CONSTRAINT "fk_meta_data_keys" FOREIGN KEY ("key_id")
|
|
51
|
+
REFERENCES "meta_data_keys" ("id")
|
|
52
|
+
)
|
|
53
|
+
`)
|
|
54
|
+
|
|
55
|
+
await queryRunner.query(`
|
|
56
|
+
CREATE TABLE IF NOT EXISTS "form_step"
|
|
57
|
+
(
|
|
58
|
+
"id" uuid NOT NULL DEFAULT gen_random_uuid(),
|
|
59
|
+
"tenant_id" uuid,
|
|
60
|
+
"form_id" text,
|
|
61
|
+
"step_nr" numeric,
|
|
62
|
+
"order" numeric,
|
|
63
|
+
CONSTRAINT "formstep_pkey" PRIMARY KEY ("id")
|
|
64
|
+
)
|
|
65
|
+
`)
|
|
66
|
+
|
|
67
|
+
await queryRunner.query(`
|
|
68
|
+
CREATE UNIQUE INDEX IF NOT EXISTS "formstep_unique_step" ON "form_step" ("step_nr", "form_id", "order")
|
|
69
|
+
`)
|
|
70
|
+
|
|
71
|
+
await queryRunner.query(`
|
|
72
|
+
CREATE TABLE IF NOT EXISTS "schema_definition"
|
|
73
|
+
(
|
|
74
|
+
"id" uuid NOT NULL DEFAULT gen_random_uuid(),
|
|
75
|
+
"tenant_id" uuid,
|
|
76
|
+
"extends_id" uuid,
|
|
77
|
+
"correlation_id" text,
|
|
78
|
+
"schema_type" text,
|
|
79
|
+
"entity_type" text,
|
|
80
|
+
"schema" text NOT NULL,
|
|
81
|
+
"meta_data_set_id" uuid,
|
|
82
|
+
CONSTRAINT "schemadef_pkey" PRIMARY KEY ("id"),
|
|
83
|
+
CONSTRAINT "fk_schemadef_metadata"
|
|
84
|
+
FOREIGN KEY ("meta_data_set_id")
|
|
85
|
+
REFERENCES "meta_data_set" ("id")
|
|
86
|
+
)
|
|
87
|
+
`)
|
|
88
|
+
|
|
89
|
+
await queryRunner.query(`
|
|
90
|
+
CREATE TABLE IF NOT EXISTS "form_step_to_schema_definition"
|
|
91
|
+
(
|
|
92
|
+
"form_step_id" uuid NOT NULL,
|
|
93
|
+
"schema_definition_id" uuid NOT NULL,
|
|
94
|
+
CONSTRAINT "pk_form_step_to_schema_definition" PRIMARY KEY ("form_step_id", "schema_definition_id"),
|
|
95
|
+
CONSTRAINT "fk_form_step"
|
|
96
|
+
FOREIGN KEY ("form_step_id")
|
|
97
|
+
REFERENCES "form_step" ("id"),
|
|
98
|
+
CONSTRAINT "fk_schema_definition"
|
|
99
|
+
FOREIGN KEY ("schema_definition_id")
|
|
100
|
+
REFERENCES "schema_definition" ("id")
|
|
101
|
+
)
|
|
102
|
+
`)
|
|
103
|
+
|
|
104
|
+
// ── Credential design branding table ────────────────────────────
|
|
105
|
+
await queryRunner.query(`
|
|
106
|
+
CREATE TABLE IF NOT EXISTS "credential_design_branding"
|
|
107
|
+
(
|
|
108
|
+
"id" uuid NOT NULL DEFAULT gen_random_uuid(),
|
|
109
|
+
"logo" uuid,
|
|
110
|
+
"background_image" uuid,
|
|
111
|
+
"text_color" text,
|
|
112
|
+
"background_color" text,
|
|
113
|
+
"meta_data_set_id" uuid,
|
|
114
|
+
CONSTRAINT "credentialdesignbranding_pkey" PRIMARY KEY ("id"),
|
|
115
|
+
CONSTRAINT "fk_credentialdesignbranding_metadata" FOREIGN KEY ("meta_data_set_id") REFERENCES "meta_data_set" ("id") ON DELETE CASCADE,
|
|
116
|
+
CONSTRAINT "unique_meta_data_set_id" UNIQUE ("meta_data_set_id"),
|
|
117
|
+
CONSTRAINT "fk_branding_logo" FOREIGN KEY ("logo") REFERENCES "ImageAttributes" ("id"),
|
|
118
|
+
CONSTRAINT "fk_branding_background_image" FOREIGN KEY ("background_image") REFERENCES "ImageAttributes" ("id")
|
|
119
|
+
);
|
|
120
|
+
`)
|
|
121
|
+
|
|
122
|
+
// ── Cascade FK updates ──────────────────────────────────────────
|
|
123
|
+
await queryRunner.query(`
|
|
124
|
+
ALTER TABLE meta_data_keys DROP CONSTRAINT IF EXISTS fk_meta_data_set
|
|
125
|
+
`)
|
|
126
|
+
await queryRunner.query(`
|
|
127
|
+
ALTER TABLE meta_data_keys ADD CONSTRAINT fk_meta_data_set FOREIGN KEY (set_id) REFERENCES meta_data_set(id) ON DELETE CASCADE
|
|
128
|
+
`)
|
|
129
|
+
|
|
130
|
+
await queryRunner.query(`
|
|
131
|
+
ALTER TABLE schema_definition DROP CONSTRAINT IF EXISTS fk_schemadef_metadata
|
|
132
|
+
`)
|
|
133
|
+
await queryRunner.query(`
|
|
134
|
+
ALTER TABLE schema_definition ADD CONSTRAINT fk_schemadef_metadata FOREIGN KEY (meta_data_set_id) REFERENCES meta_data_set(id) ON DELETE CASCADE
|
|
135
|
+
`)
|
|
136
|
+
|
|
137
|
+
await queryRunner.query(`
|
|
138
|
+
ALTER TABLE meta_data_values DROP CONSTRAINT IF EXISTS fk_meta_data_keys
|
|
139
|
+
`)
|
|
140
|
+
await queryRunner.query(`
|
|
141
|
+
ALTER TABLE meta_data_values ADD CONSTRAINT fk_meta_data_keys FOREIGN KEY (key_id) REFERENCES meta_data_keys(id) ON DELETE CASCADE
|
|
142
|
+
`)
|
|
143
|
+
|
|
144
|
+
await queryRunner.query(`
|
|
145
|
+
ALTER TABLE form_step_to_schema_definition DROP CONSTRAINT IF EXISTS form_step_to_schema_definition_schema_definition_id_fkey;
|
|
146
|
+
`)
|
|
147
|
+
await queryRunner.query(`
|
|
148
|
+
ALTER TABLE form_step_to_schema_definition ADD CONSTRAINT form_step_to_schema_definition_schema_definition_id_fkey FOREIGN KEY (schema_definition_id) REFERENCES schema_definition(id) ON DELETE CASCADE;
|
|
149
|
+
`)
|
|
150
|
+
|
|
151
|
+
await queryRunner.query(`
|
|
152
|
+
ALTER TABLE form_step_to_schema_definition DROP CONSTRAINT IF EXISTS fk_schema_definition;
|
|
153
|
+
`)
|
|
154
|
+
await queryRunner.query(`
|
|
155
|
+
ALTER TABLE form_step_to_schema_definition ADD CONSTRAINT fk_schema_definition FOREIGN KEY (schema_definition_id) REFERENCES schema_definition(id) ON DELETE CASCADE;
|
|
156
|
+
`)
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
public async down(queryRunner: QueryRunner): Promise<void> {
|
|
160
|
+
// Restore non-cascade FKs
|
|
161
|
+
await queryRunner.query(`
|
|
162
|
+
ALTER TABLE form_step_to_schema_definition DROP CONSTRAINT IF EXISTS fk_schema_definition;
|
|
163
|
+
`)
|
|
164
|
+
await queryRunner.query(`
|
|
165
|
+
ALTER TABLE form_step_to_schema_definition ADD CONSTRAINT fk_schema_definition FOREIGN KEY (schema_definition_id) REFERENCES schema_definition(id);
|
|
166
|
+
`)
|
|
167
|
+
|
|
168
|
+
await queryRunner.query(`
|
|
169
|
+
ALTER TABLE form_step_to_schema_definition DROP CONSTRAINT IF EXISTS form_step_to_schema_definition_schema_definition_id_fkey;
|
|
170
|
+
`)
|
|
171
|
+
await queryRunner.query(`
|
|
172
|
+
ALTER TABLE form_step_to_schema_definition ADD CONSTRAINT form_step_to_schema_definition_schema_definition_id_fkey FOREIGN KEY (schema_definition_id) REFERENCES schema_definition(id);
|
|
173
|
+
`)
|
|
174
|
+
|
|
175
|
+
await queryRunner.query(`
|
|
176
|
+
ALTER TABLE meta_data_values DROP CONSTRAINT IF EXISTS fk_meta_data_keys;
|
|
177
|
+
`)
|
|
178
|
+
await queryRunner.query(`
|
|
179
|
+
ALTER TABLE meta_data_values ADD CONSTRAINT fk_meta_data_keys FOREIGN KEY (key_id) REFERENCES meta_data_keys(id);
|
|
180
|
+
`)
|
|
181
|
+
|
|
182
|
+
await queryRunner.query(`
|
|
183
|
+
ALTER TABLE schema_definition DROP CONSTRAINT IF EXISTS fk_schemadef_metadata;
|
|
184
|
+
`)
|
|
185
|
+
await queryRunner.query(`
|
|
186
|
+
ALTER TABLE schema_definition ADD CONSTRAINT fk_schemadef_metadata FOREIGN KEY (meta_data_set_id) REFERENCES meta_data_set(id);
|
|
187
|
+
`)
|
|
188
|
+
|
|
189
|
+
await queryRunner.query(`
|
|
190
|
+
ALTER TABLE meta_data_keys DROP CONSTRAINT IF EXISTS fk_meta_data_set;
|
|
191
|
+
`)
|
|
192
|
+
await queryRunner.query(`
|
|
193
|
+
ALTER TABLE meta_data_keys ADD CONSTRAINT fk_meta_data_set FOREIGN KEY (set_id) REFERENCES meta_data_set(id);
|
|
194
|
+
`)
|
|
195
|
+
|
|
196
|
+
// Drop functions and tables
|
|
197
|
+
await queryRunner.query(`DROP TABLE IF EXISTS "credential_design_branding"`)
|
|
198
|
+
await queryRunner.query(`DROP TABLE IF EXISTS "form_step_to_schema_definition"`)
|
|
199
|
+
await queryRunner.query(`DROP TABLE IF EXISTS "schema_definition"`)
|
|
200
|
+
await queryRunner.query(`DROP INDEX IF EXISTS "formstep_unique_step"`)
|
|
201
|
+
await queryRunner.query(`DROP TABLE IF EXISTS "form_step"`)
|
|
202
|
+
await queryRunner.query(`DROP TABLE IF EXISTS "meta_data_values"`)
|
|
203
|
+
await queryRunner.query(`DROP TABLE IF EXISTS "meta_data_keys"`)
|
|
204
|
+
await queryRunner.query(`DROP INDEX IF EXISTS "meta_data_set_unique_tenant"`)
|
|
205
|
+
await queryRunner.query(`DROP TABLE IF EXISTS "meta_data_set"`)
|
|
206
|
+
await queryRunner.query(`DROP TYPE IF EXISTS "value_type"`)
|
|
207
|
+
}
|
|
208
|
+
}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { MigrationInterface, QueryRunner } from 'typeorm'
|
|
2
|
+
|
|
3
|
+
export class AddCredentialDesignsSqlite1773657426000 implements MigrationInterface {
|
|
4
|
+
name = 'AddCredentialDesignsSqlite1773657426000'
|
|
5
|
+
|
|
6
|
+
public async up(queryRunner: QueryRunner): Promise<void> {
|
|
7
|
+
await queryRunner.query(
|
|
8
|
+
`CREATE TABLE IF NOT EXISTS "meta_data_set" ("id" varchar PRIMARY KEY NOT NULL, "tenant_id" varchar, "name" text NOT NULL)`,
|
|
9
|
+
)
|
|
10
|
+
|
|
11
|
+
await queryRunner.query(
|
|
12
|
+
`CREATE UNIQUE INDEX IF NOT EXISTS "meta_data_set_unique_tenant" ON "meta_data_set" ("name", "tenant_id")`,
|
|
13
|
+
)
|
|
14
|
+
|
|
15
|
+
await queryRunner.query(
|
|
16
|
+
`CREATE TABLE IF NOT EXISTS "meta_data_keys" ("id" varchar PRIMARY KEY NOT NULL, "set_id" varchar NOT NULL, "key" text NOT NULL, "value_type" varchar CHECK( "value_type" IN ('Text','Number','Boolean','Date') ) NOT NULL, CONSTRAINT "fk_meta_data_set" FOREIGN KEY ("set_id") REFERENCES "meta_data_set" ("id") ON DELETE CASCADE ON UPDATE NO ACTION)`,
|
|
17
|
+
)
|
|
18
|
+
|
|
19
|
+
await queryRunner.query(
|
|
20
|
+
`CREATE TABLE IF NOT EXISTS "meta_data_values" ("id" varchar PRIMARY KEY NOT NULL, "key_id" varchar NOT NULL, "index" integer, "text_value" text, "number_value" real, "boolean_value" boolean, "timestamp_value" datetime, CONSTRAINT "fk_meta_data_keys" FOREIGN KEY ("key_id") REFERENCES "meta_data_keys" ("id") ON DELETE CASCADE ON UPDATE NO ACTION)`,
|
|
21
|
+
)
|
|
22
|
+
|
|
23
|
+
await queryRunner.query(
|
|
24
|
+
`CREATE TABLE IF NOT EXISTS "form_step" ("id" varchar PRIMARY KEY NOT NULL, "tenant_id" varchar, "form_id" text, "step_nr" integer, "order" integer)`,
|
|
25
|
+
)
|
|
26
|
+
|
|
27
|
+
await queryRunner.query(
|
|
28
|
+
`CREATE UNIQUE INDEX IF NOT EXISTS "formstep_unique_step" ON "form_step" ("step_nr", "form_id", "order")`,
|
|
29
|
+
)
|
|
30
|
+
|
|
31
|
+
await queryRunner.query(
|
|
32
|
+
`CREATE TABLE IF NOT EXISTS "schema_definition" ("id" varchar PRIMARY KEY NOT NULL, "tenant_id" varchar, "extends_id" varchar, "correlation_id" text, "schema_type" text, "entity_type" text, "schema" text NOT NULL, "meta_data_set_id" varchar, CONSTRAINT "fk_schemadef_metadata" FOREIGN KEY ("meta_data_set_id") REFERENCES "meta_data_set" ("id") ON DELETE CASCADE ON UPDATE NO ACTION)`,
|
|
33
|
+
)
|
|
34
|
+
|
|
35
|
+
await queryRunner.query(
|
|
36
|
+
`CREATE TABLE IF NOT EXISTS "form_step_to_schema_definition" ("form_step_id" varchar NOT NULL, "schema_definition_id" varchar NOT NULL, PRIMARY KEY ("form_step_id", "schema_definition_id"), CONSTRAINT "fk_form_step" FOREIGN KEY ("form_step_id") REFERENCES "form_step" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION, CONSTRAINT "fk_schema_definition" FOREIGN KEY ("schema_definition_id") REFERENCES "schema_definition" ("id") ON DELETE CASCADE ON UPDATE NO ACTION)`,
|
|
37
|
+
)
|
|
38
|
+
|
|
39
|
+
await queryRunner.query(
|
|
40
|
+
`CREATE TABLE IF NOT EXISTS "credential_design_branding" ("id" varchar PRIMARY KEY NOT NULL, "logo" varchar, "background_image" varchar, "text_color" text, "background_color" text, "meta_data_set_id" varchar, CONSTRAINT "unique_meta_data_set_id" UNIQUE ("meta_data_set_id"), CONSTRAINT "fk_credentialdesignbranding_metadata" FOREIGN KEY ("meta_data_set_id") REFERENCES "meta_data_set" ("id") ON DELETE CASCADE ON UPDATE NO ACTION, CONSTRAINT "fk_branding_logo" FOREIGN KEY ("logo") REFERENCES "ImageAttributes" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION, CONSTRAINT "fk_branding_background_image" FOREIGN KEY ("background_image") REFERENCES "ImageAttributes" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION)`,
|
|
41
|
+
)
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
public async down(queryRunner: QueryRunner): Promise<void> {
|
|
45
|
+
await queryRunner.query(`DROP TABLE IF EXISTS "credential_design_branding"`)
|
|
46
|
+
await queryRunner.query(`DROP TABLE IF EXISTS "form_step_to_schema_definition"`)
|
|
47
|
+
await queryRunner.query(`DROP TABLE IF EXISTS "schema_definition"`)
|
|
48
|
+
await queryRunner.query(`DROP INDEX IF EXISTS "formstep_unique_step"`)
|
|
49
|
+
await queryRunner.query(`DROP TABLE IF EXISTS "form_step"`)
|
|
50
|
+
await queryRunner.query(`DROP TABLE IF EXISTS "meta_data_values"`)
|
|
51
|
+
await queryRunner.query(`DROP TABLE IF EXISTS "meta_data_keys"`)
|
|
52
|
+
await queryRunner.query(`DROP INDEX IF EXISTS "meta_data_set_unique_tenant"`)
|
|
53
|
+
await queryRunner.query(`DROP TABLE IF EXISTS "meta_data_set"`)
|
|
54
|
+
}
|
|
55
|
+
}
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
CredentialDesign,
|
|
3
|
+
CredentialDesignBranding,
|
|
4
|
+
IImageAttributes,
|
|
5
|
+
MetaDataKey,
|
|
6
|
+
MetaDataValue,
|
|
7
|
+
NonPersistedCredentialDesignBranding,
|
|
8
|
+
NonPersistedMetaDataKey,
|
|
9
|
+
NonPersistedMetaDataValue,
|
|
10
|
+
NonPersistedSchemaDefinition,
|
|
11
|
+
SchemaDefinition,
|
|
12
|
+
} from '@sphereon/ssi-sdk.data-store-types'
|
|
13
|
+
import { CredentialDesignBrandingEntity } from '../../entities/credentialDesign'
|
|
14
|
+
import { MetaDataKeyEntity, ValueType } from '../../entities/credentialDesign'
|
|
15
|
+
import { MetaDataSetEntity } from '../../entities/credentialDesign'
|
|
16
|
+
import { MetaDataValueEntity } from '../../entities/credentialDesign'
|
|
17
|
+
import { SchemaDefinitionEntity } from '../../entities/credentialDesign'
|
|
18
|
+
import { ImageAttributesEntity } from '../../entities/issuanceBranding/ImageAttributesEntity'
|
|
19
|
+
import { replaceNullWithUndefined } from '../FormattingUtils'
|
|
20
|
+
import { imageAttributesEntityFrom } from '../issuanceBranding/MappingUtils'
|
|
21
|
+
|
|
22
|
+
export const credentialDesignFrom = (entity: MetaDataSetEntity): CredentialDesign => {
|
|
23
|
+
const result: CredentialDesign = {
|
|
24
|
+
id: entity.id,
|
|
25
|
+
label: entity.name,
|
|
26
|
+
tenantId: entity.tenantId,
|
|
27
|
+
metaDataKeys: entity.metaDataKeys?.map((key) => metaDataKeyFrom(key)) ?? [],
|
|
28
|
+
schemaDefinitions: entity.schemaDefinitions?.map((schema) => schemaDefinitionFrom(schema)) ?? [],
|
|
29
|
+
branding: entity.credentialDesignBranding ? credentialDesignBrandingFrom(entity.credentialDesignBranding) : undefined,
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
return replaceNullWithUndefined(result)
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export const metaDataKeyFrom = (entity: MetaDataKeyEntity): MetaDataKey => {
|
|
36
|
+
const result: MetaDataKey = {
|
|
37
|
+
id: entity.id,
|
|
38
|
+
key: entity.key,
|
|
39
|
+
valueType: entity.valueType,
|
|
40
|
+
metaDataValues: entity.metaDataValues?.map((value) => metaDataValueFrom(value)) ?? [],
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
return replaceNullWithUndefined(result)
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export const metaDataValueFrom = (entity: MetaDataValueEntity): MetaDataValue => {
|
|
47
|
+
const result: MetaDataValue = {
|
|
48
|
+
id: entity.id,
|
|
49
|
+
index: entity.index,
|
|
50
|
+
textValue: entity.textValue,
|
|
51
|
+
numberValue: entity.numberValue,
|
|
52
|
+
booleanValue: entity.booleanValue,
|
|
53
|
+
timestampValue: entity.timestampValue,
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
return replaceNullWithUndefined(result)
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
export const schemaDefinitionFrom = (entity: SchemaDefinitionEntity): SchemaDefinition => {
|
|
60
|
+
const result: SchemaDefinition = {
|
|
61
|
+
id: entity.id,
|
|
62
|
+
tenantId: entity.tenantId,
|
|
63
|
+
extendsId: entity.extendsId,
|
|
64
|
+
correlationId: entity.correlationId,
|
|
65
|
+
schemaType: entity.schemaType,
|
|
66
|
+
entityType: entity.entityType,
|
|
67
|
+
schema: entity.schema,
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
return replaceNullWithUndefined(result)
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
export const credentialDesignBrandingFrom = (entity: CredentialDesignBrandingEntity): CredentialDesignBranding => {
|
|
74
|
+
const result: CredentialDesignBranding = {
|
|
75
|
+
id: entity.id,
|
|
76
|
+
textColor: entity.textColor,
|
|
77
|
+
backgroundColor: entity.backgroundColor,
|
|
78
|
+
logo: entity.logo ? imageAttributesFrom(entity.logo) : undefined,
|
|
79
|
+
backgroundImage: entity.backgroundImage ? imageAttributesFrom(entity.backgroundImage) : undefined,
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
return replaceNullWithUndefined(result)
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
export const imageAttributesFrom = (entity: ImageAttributesEntity): IImageAttributes => {
|
|
86
|
+
const result: IImageAttributes = {
|
|
87
|
+
id: entity.id,
|
|
88
|
+
uri: entity.uri,
|
|
89
|
+
dataUri: entity.dataUri,
|
|
90
|
+
mediaType: entity.mediaType,
|
|
91
|
+
alt: entity.alt,
|
|
92
|
+
dimensions: entity.dimensions
|
|
93
|
+
? {
|
|
94
|
+
id: entity.dimensions.id,
|
|
95
|
+
width: entity.dimensions.width,
|
|
96
|
+
height: entity.dimensions.height,
|
|
97
|
+
}
|
|
98
|
+
: undefined,
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
return replaceNullWithUndefined(result)
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
export const metaDataKeyEntityFrom = (input: NonPersistedMetaDataKey): MetaDataKeyEntity => {
|
|
105
|
+
const keyEntity = new MetaDataKeyEntity()
|
|
106
|
+
keyEntity.key = input.key
|
|
107
|
+
keyEntity.valueType = input.valueType as ValueType
|
|
108
|
+
keyEntity.metaDataValues = input.metaDataValues.map((valInput) => metaDataValueEntityFrom(valInput))
|
|
109
|
+
return keyEntity
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
export const metaDataValueEntityFrom = (input: NonPersistedMetaDataValue): MetaDataValueEntity => {
|
|
113
|
+
const valEntity = new MetaDataValueEntity()
|
|
114
|
+
valEntity.index = input.index
|
|
115
|
+
valEntity.textValue = input.textValue
|
|
116
|
+
valEntity.numberValue = input.numberValue
|
|
117
|
+
valEntity.booleanValue = input.booleanValue
|
|
118
|
+
valEntity.timestampValue = input.timestampValue
|
|
119
|
+
return valEntity
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
export const schemaDefinitionEntityFrom = (input: NonPersistedSchemaDefinition): SchemaDefinitionEntity => {
|
|
123
|
+
const schemaEntity = new SchemaDefinitionEntity()
|
|
124
|
+
schemaEntity.tenantId = input.tenantId
|
|
125
|
+
schemaEntity.extendsId = input.extendsId
|
|
126
|
+
schemaEntity.correlationId = input.correlationId
|
|
127
|
+
schemaEntity.schemaType = input.schemaType
|
|
128
|
+
schemaEntity.entityType = input.entityType
|
|
129
|
+
schemaEntity.schema = input.schema
|
|
130
|
+
return schemaEntity
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
export const credentialDesignBrandingEntityFrom = (input: NonPersistedCredentialDesignBranding): CredentialDesignBrandingEntity => {
|
|
134
|
+
const brandingEntity = new CredentialDesignBrandingEntity()
|
|
135
|
+
brandingEntity.textColor = input.textColor
|
|
136
|
+
brandingEntity.backgroundColor = input.backgroundColor
|
|
137
|
+
|
|
138
|
+
if (input.logo) {
|
|
139
|
+
brandingEntity.logo = imageAttributesEntityFrom(input.logo)
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
if (input.backgroundImage) {
|
|
143
|
+
brandingEntity.backgroundImage = imageAttributesEntityFrom(input.backgroundImage)
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
return brandingEntity
|
|
147
|
+
}
|