@sphereon/ssi-sdk.data-store 0.34.1-next.3 → 0.34.1-next.40
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 +979 -502
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +111 -26
- package/dist/index.d.ts +111 -26
- package/dist/index.js +925 -448
- package/dist/index.js.map +1 -1
- package/package.json +8 -8
- package/src/__tests__/statusList.entities.test.ts +58 -1
- package/src/__tests__/statusList.store.test.ts +64 -1
- package/src/entities/statusList/BitstringStatusListEntryEntity.ts +60 -0
- package/src/entities/statusList/StatusList2021EntryEntity.ts +4 -3
- package/src/entities/statusList/StatusListEntities.ts +54 -5
- package/src/index.ts +12 -2
- package/src/migrations/generic/12-CreateBitstringStatusList.ts +52 -0
- package/src/migrations/generic/index.ts +2 -1
- package/src/migrations/postgres/1741895823000-CreateBitstringStatusList.ts +53 -0
- package/src/migrations/sqlite/1741895823001-CreateBitstringStatusList.ts +145 -0
- package/src/statusList/IStatusListStore.ts +14 -11
- package/src/statusList/StatusListStore.ts +73 -35
- package/src/types/statusList/IAbstractStatusListStore.ts +54 -4
- package/src/types/statusList/statusList.ts +50 -2
- package/src/utils/statusList/MappingUtils.ts +71 -30
|
@@ -1,41 +1,70 @@
|
|
|
1
|
-
import { IOAuthStatusListEntity, IStatusList2021Entity, IStatusListEntity } from '../../types'
|
|
2
|
-
import {
|
|
1
|
+
import { IBitstringStatusListEntity, IOAuthStatusListEntity, IStatusList2021Entity, IStatusListEntity } from '../../types'
|
|
2
|
+
import {
|
|
3
|
+
BitstringStatusListEntity,
|
|
4
|
+
OAuthStatusListEntity,
|
|
5
|
+
StatusList2021Entity,
|
|
6
|
+
StatusListEntity,
|
|
7
|
+
} from '../../entities/statusList/StatusListEntities'
|
|
3
8
|
import { StatusListType } from '@sphereon/ssi-types'
|
|
4
9
|
import { replaceNullWithUndefined } from '../FormattingUtils'
|
|
5
10
|
|
|
6
11
|
export const statusListEntityFrom = (args: IStatusListEntity): StatusListEntity => {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
12
|
+
switch (args.type) {
|
|
13
|
+
case StatusListType.StatusList2021: {
|
|
14
|
+
const entity = new StatusList2021Entity()
|
|
15
|
+
const sl2021 = args as IStatusList2021Entity
|
|
16
|
+
entity.indexingDirection = sl2021.indexingDirection
|
|
17
|
+
entity.statusPurpose = sl2021.statusPurpose
|
|
18
|
+
setBaseFields(entity, args)
|
|
19
|
+
Object.defineProperty(entity, 'type', {
|
|
20
|
+
value: StatusListType.StatusList2021,
|
|
21
|
+
enumerable: true,
|
|
22
|
+
configurable: true,
|
|
23
|
+
})
|
|
24
|
+
return entity
|
|
25
|
+
}
|
|
20
26
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
27
|
+
case StatusListType.OAuthStatusList: {
|
|
28
|
+
const entity = new OAuthStatusListEntity()
|
|
29
|
+
const oauthSl = args as IOAuthStatusListEntity
|
|
30
|
+
entity.bitsPerStatus = oauthSl.bitsPerStatus
|
|
31
|
+
entity.expiresAt = oauthSl.expiresAt
|
|
32
|
+
setBaseFields(entity, args)
|
|
33
|
+
Object.defineProperty(entity, 'type', {
|
|
34
|
+
value: StatusListType.OAuthStatusList,
|
|
35
|
+
enumerable: true,
|
|
36
|
+
configurable: true,
|
|
37
|
+
})
|
|
38
|
+
return entity
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
case StatusListType.BitstringStatusList: {
|
|
42
|
+
const entity = new BitstringStatusListEntity()
|
|
43
|
+
const bitstringsl = args as IBitstringStatusListEntity
|
|
44
|
+
if (!bitstringsl.bitsPerStatus) {
|
|
45
|
+
throw Error('bitsPerStatus must be set for BitstringStatusList')
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
entity.statusPurpose = bitstringsl.statusPurpose
|
|
49
|
+
entity.bitsPerStatus = bitstringsl.bitsPerStatus
|
|
50
|
+
entity.validFrom = bitstringsl.validFrom
|
|
51
|
+
entity.validUntil = bitstringsl.validUntil
|
|
52
|
+
entity.ttl = bitstringsl.ttl
|
|
53
|
+
setBaseFields(entity, args)
|
|
54
|
+
Object.defineProperty(entity, 'type', {
|
|
55
|
+
value: StatusListType.BitstringStatusList,
|
|
56
|
+
enumerable: true,
|
|
57
|
+
configurable: true,
|
|
58
|
+
})
|
|
59
|
+
return entity
|
|
60
|
+
}
|
|
34
61
|
|
|
35
|
-
|
|
62
|
+
default:
|
|
63
|
+
throw new Error(`Invalid status list type ${args.type}`)
|
|
64
|
+
}
|
|
36
65
|
}
|
|
37
66
|
|
|
38
|
-
export const statusListFrom = (entity: StatusListEntity): IStatusListEntity => {
|
|
67
|
+
export const statusListFrom = (entity: StatusListEntity): IStatusListEntity | IBitstringStatusListEntity => {
|
|
39
68
|
if (entity instanceof StatusList2021Entity) {
|
|
40
69
|
const result: IStatusList2021Entity = {
|
|
41
70
|
...getBaseFields(entity),
|
|
@@ -56,6 +85,18 @@ export const statusListFrom = (entity: StatusListEntity): IStatusListEntity => {
|
|
|
56
85
|
return replaceNullWithUndefined(result)
|
|
57
86
|
}
|
|
58
87
|
|
|
88
|
+
if (entity instanceof BitstringStatusListEntity) {
|
|
89
|
+
const result: IBitstringStatusListEntity = {
|
|
90
|
+
...getBaseFields(entity),
|
|
91
|
+
type: StatusListType.BitstringStatusList,
|
|
92
|
+
statusPurpose: entity.statusPurpose,
|
|
93
|
+
bitsPerStatus: entity.bitsPerStatus,
|
|
94
|
+
validFrom: entity.validFrom,
|
|
95
|
+
validUntil: entity.validUntil,
|
|
96
|
+
ttl: entity.ttl,
|
|
97
|
+
}
|
|
98
|
+
return replaceNullWithUndefined(result)
|
|
99
|
+
}
|
|
59
100
|
throw new Error(`Invalid status list type ${typeof entity}`)
|
|
60
101
|
}
|
|
61
102
|
|