Skip to content

Commit d8d0e72

Browse files
feat: add related identifiers to DepositMetadata
I believe 'scheme', 'relation', and 'resource_type' could be fixed lists, and the type of 'identifier' based on 'scheme', but I've started with plain strings. Refs 34334fa
1 parent 9653d86 commit d8d0e72

4 files changed

Lines changed: 35 additions & 0 deletions

File tree

docs/modules/index.ts.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,12 @@ export type DepositMetadata = {
151151
name: string
152152
}>
153153
description: string
154+
related_identifiers?: NonEmptyArray<{
155+
scheme: string
156+
identifier: string
157+
relation: string
158+
resource_type?: string
159+
}>
154160
title: string
155161
} & (
156162
| {

src/index.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,12 @@ export type DepositMetadata = {
107107
name: string
108108
}>
109109
description: string
110+
related_identifiers?: NonEmptyArray<{
111+
scheme: string
112+
identifier: string
113+
relation: string
114+
resource_type?: string
115+
}>
110116
title: string
111117
} & (
112118
| {
@@ -495,6 +501,12 @@ const DepositMetadataC = pipe(
495501
C.intersect(
496502
C.partial({
497503
communities: NonEmptyArrayC(C.struct({ identifier: C.string })),
504+
related_identifiers: NonEmptyArrayC(
505+
pipe(
506+
C.struct({ identifier: C.string, scheme: C.string, relation: C.string }),
507+
C.intersect(C.partial({ resource_type: C.string })),
508+
),
509+
),
498510
}),
499511
),
500512
C.intersect(UploadTypeC),

test-d/index.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,9 @@ expectTypeOf(depositMetadata.creators).toEqualTypeOf<
5656
}>
5757
>()
5858
expectTypeOf(depositMetadata.description).toEqualTypeOf<string>()
59+
expectTypeOf(depositMetadata.related_identifiers).toEqualTypeOf<
60+
NonEmptyArray<{ scheme: string; identifier: string; relation: string; resource_type?: string }> | undefined
61+
>()
5962
expectTypeOf(depositMetadata.title).toEqualTypeOf<string>()
6063

6164
//

test/fc.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,20 @@ export const zenodoDepositMetadata = (): fc.Arbitrary<_.DepositMetadata> =>
183183
{ minLength: 1 },
184184
)
185185
.filter(isNonEmpty),
186+
related_identifiers: fc
187+
.array(
188+
fc.record(
189+
{
190+
scheme: fc.string(),
191+
identifier: fc.string(),
192+
relation: fc.string(),
193+
resource_type: fc.string(),
194+
},
195+
{ requiredKeys: ['scheme', 'identifier', 'relation'] },
196+
),
197+
{ minLength: 1 },
198+
)
199+
.filter(isNonEmpty),
186200
},
187201
{ withDeletedKeys: true },
188202
),

0 commit comments

Comments
 (0)