Skip to content

Commit b018a9a

Browse files
committed
DokumentSchema
1 parent 30724fe commit b018a9a

File tree

3 files changed

+89
-17
lines changed

3 files changed

+89
-17
lines changed

apps/dine-pleiepenger/api-mock-server/mockdata/saker.json

+56-1
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,62 @@
102102
},
103103
"kildesystem": "endringsdialog"
104104
},
105-
"dokumenter": []
105+
"dokumenter": [
106+
{
107+
"journalpostId": "637581439",
108+
"dokumentInfoId": "667123743",
109+
"saksnummer": "1DQAQRW",
110+
"tittel": "Søknad om pleiepenger for sykt barn",
111+
"filtype": "PDF",
112+
"harTilgang": true,
113+
"url": "http://sif-innsyn-api/dokument/637581439/667123743/ARKIV",
114+
"relevanteDatoer": [
115+
{
116+
"dato": "2024-02-13T08:52:46",
117+
"datotype": "DATO_OPPRETTET"
118+
},
119+
{
120+
"dato": "2024-02-13T08:52:46",
121+
"datotype": "DATO_DOKUMENT"
122+
},
123+
{
124+
"dato": "2024-02-13T08:52:54",
125+
"datotype": "DATO_JOURNALFOERT"
126+
},
127+
{
128+
"dato": "2024-02-13T08:52:43",
129+
"datotype": "DATO_REGISTRERT"
130+
}
131+
]
132+
},
133+
{
134+
"journalpostId": "637581439",
135+
"dokumentInfoId": "667123744",
136+
"saksnummer": "1DQAQRW",
137+
"tittel": "gray-tile.png",
138+
"filtype": "PDF",
139+
"harTilgang": true,
140+
"url": "http://sif-innsyn-api/dokument/637581439/667123744/ARKIV",
141+
"relevanteDatoer": [
142+
{
143+
"dato": "2024-02-13T08:52:46",
144+
"datotype": "DATO_OPPRETTET"
145+
},
146+
{
147+
"dato": "2024-02-13T08:52:46",
148+
"datotype": "DATO_DOKUMENT"
149+
},
150+
{
151+
"dato": "2024-02-13T08:52:54",
152+
"datotype": "DATO_JOURNALFOERT"
153+
},
154+
{
155+
"dato": "2024-02-13T08:52:43",
156+
"datotype": "DATO_REGISTRERT"
157+
}
158+
]
159+
}
160+
]
106161
}
107162
],
108163
"aksjonspunkter": []
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
import { z } from 'zod';
2+
import { parseMaybeDateStringToDate } from '../../utils/jsonParseUtils';
3+
4+
export type Dokument = z.infer<typeof DokumentSchema>;
5+
6+
enum DokumentFiltype {
7+
PDF = 'PDF',
8+
}
9+
10+
export enum DokumentDatoType {
11+
'DATO_OPPRETTET' = 'DATO_OPPRETTET',
12+
'DATO_DOKUMENT' = 'DATO_DOKUMENT',
13+
'DATO_JOURNALFOERT' = 'DATO_JOURNALFOERT',
14+
'DATO_REGISTRERT' = 'DATO_REGISTRERT',
15+
}
16+
17+
export const DokumentSchema = z.object({
18+
journalpostId: z.string(),
19+
dokumentInfoId: z.string(),
20+
// saksnummer: z.string(),
21+
tittel: z.string(),
22+
filtype: z.nativeEnum(DokumentFiltype),
23+
harTilgang: z.boolean(),
24+
url: z.string(),
25+
relevanteDatoer: z.array(
26+
z.object({
27+
dato: z.preprocess(parseMaybeDateStringToDate, z.date()),
28+
datotype: z.nativeEnum(DokumentDatoType),
29+
}),
30+
),
31+
});

apps/dine-pleiepenger/src/server/api-models/SøknadSchema.ts

+2-16
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,10 @@
11
import { z } from 'zod';
22
import { K9FormatSøknadSchema } from './K9FormatSøknadSchema';
33
import { InnsendtSøknadstype } from './InnsendtSøknadSchema';
4-
5-
enum SøknadDokumentFiltype {
6-
PDF = 'PDF',
7-
}
8-
9-
const SøknadDokumentSchema = z.object({
10-
journalpostId: z.string(),
11-
dokumentInfoId: z.string(),
12-
sakId: z.string(),
13-
tittel: z.string(),
14-
filtype: z.nativeEnum(SøknadDokumentFiltype),
15-
harTilgang: z.boolean(),
16-
url: z.string(),
17-
});
4+
import { DokumentSchema } from './DokumenetSchema';
185

196
const SøknadBaseSchema = z.object({
20-
// status: z.nativeEnum(InnsendtSøknadsstatus),
21-
dokumenter: z.array(z.union([SøknadDokumentSchema, z.any()])),
7+
dokumenter: z.array(DokumentSchema),
228
});
239

2410
const PleiepengerSøknadSchema = SøknadBaseSchema.extend({

0 commit comments

Comments
 (0)