Skip to content

Typegenerering POC #6504

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,4 @@ ssh.exe.stackdump
!.yarn/versions

.nx
swagger.json
2 changes: 2 additions & 0 deletions apps/fp-frontend-app/.storybook/testdata/behandling.ts
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,8 @@ export const behandling: Behandling = {
besluttersBegrunnelse: null,
aksjonspunktType: AksjonspunktType.MANUELL,
kanLoses: true,
erAktivt: true,
fristTid: null,
endretTidspunkt: null,
endretAv: null,
},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
import { AksjonspunktKode, AksjonspunktStatus, BehandlingStatus } from '@navikt/fp-kodeverk';
import {
AksjonspunktKode,
AksjonspunktStatus,
AksjonspunktType,
BehandlingStatus,
VilkarType,
} from '@navikt/fp-kodeverk';
import type { Aksjonspunkt } from '@navikt/fp-types';

import { getAlleMerknaderFraBeslutter } from './getAlleMerknaderFraBeslutter';
Expand All @@ -12,6 +18,14 @@ describe('getAlleMerknaderFraBeslutter', () => {
kanLoses: true,
toTrinnsBehandling: true,
toTrinnsBehandlingGodkjent: false,
vilkarType: VilkarType.FODSELSVILKARET_MOR,
vurderPaNyttArsaker: null,
besluttersBegrunnelse: null,
aksjonspunktType: AksjonspunktType.MANUELL,
erAktivt: true,
fristTid: null,
endretTidspunkt: null,
endretAv: null,
},
];

Expand Down
20 changes: 20 additions & 0 deletions generate-api-types.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/bin/bash

# Step 1: Run the command
if ! yarn run openapi-ts; then
echo "❌ Typegenerering feilet. Sjekk error filen som ble generert."
echo "👉 Husk at du må ha en swagger.json lokalt."
echo "1. Kjør opp autotest. Gå til Swagger lokalt på localhost:9200"
echo "2. Åpne network og kopier openapi.json for relevant tjeneste"
exit 1
fi

# Step 2: Copy the generated file
cp temp-types/types.gen.ts packages/types/src/apiDtoGenerert.ts

# Step 3: Delete the temp folder
rm -rf temp-types

# Step 4: Format types
cd packages/types
yarn run prettier
7 changes: 7 additions & 0 deletions openapi-ts.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { defineConfig } from '@hey-api/openapi-ts';

export default defineConfig({
input: './swagger.json',
output: 'temp-types',
plugins: ['@hey-api/client-fetch'],
});
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
},
"devDependencies": {
"@eslint/js": "9.32.0",
"@hey-api/openapi-ts": "0.79.1",
"@navikt/aksel-stylelint": "7.25.1",
"@sentry/cli": "2.50.2",
"@storybook/addon-links": "9.0.18",
Expand Down
32 changes: 30 additions & 2 deletions packages/fakta/adopsjon/src/AdopsjonFaktaIndex.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,16 @@ import { type ComponentProps } from 'react';

import type { Meta, StoryObj } from '@storybook/react';

import { AksjonspunktKode, AksjonspunktStatus, FarSøkerType, SoknadType } from '@navikt/fp-kodeverk';
import {
AksjonspunktKode,
AksjonspunktStatus,
AksjonspunktType,
FarSøkerType,
SoknadType,
VilkarType,
} from '@navikt/fp-kodeverk';
import { type PanelDataArgs, withMellomlagretFormData, withPanelData } from '@navikt/fp-storybook-utils';
import type { FamilieHendelseSamling, Soknad } from '@navikt/fp-types';
import type { Aksjonspunkt, FamilieHendelseSamling, Soknad } from '@navikt/fp-types';

import { AdopsjonFaktaIndex } from './AdopsjonFaktaIndex';

Expand Down Expand Up @@ -48,10 +55,28 @@ export default meta;

type Story = StoryObj<typeof meta>;

const aksjonspunktDefault = {
definisjon: AksjonspunktKode.OMSORGSOVERTAKELSE,
status: AksjonspunktStatus.OPPRETTET,
begrunnelse: null,
kanLoses: true,
toTrinnsBehandling: false,
toTrinnsBehandlingGodkjent: null,
vurderPaNyttArsaker: null,
besluttersBegrunnelse: null,
aksjonspunktType: AksjonspunktType.AUTOPUNKT,
vilkarType: VilkarType.OMSORGSVILKARET,
erAktivt: true,
fristTid: null,
endretTidspunkt: null,
endretAv: null,
} satisfies Aksjonspunkt;

export const AksjonspunktForAdopsjonsvilkåret: Story = {
args: {
aksjonspunkterForPanel: [
{
...aksjonspunktDefault,
definisjon: AksjonspunktKode.ADOPSJONSDOKUMENTAJON,
status: AksjonspunktStatus.OPPRETTET,
begrunnelse: null,
Expand All @@ -68,6 +93,7 @@ export const AksjonspunktForOmSøkerErMannSomAdoptererAlene: Story = {
args: {
aksjonspunkterForPanel: [
{
...aksjonspunktDefault,
definisjon: AksjonspunktKode.OM_SOKER_ER_MANN_SOM_ADOPTERER_ALENE,
status: AksjonspunktStatus.OPPRETTET,
begrunnelse: null,
Expand All @@ -84,6 +110,7 @@ export const AksjonspunktForOmAdopsjonGjelderEktefellesBarn: Story = {
args: {
aksjonspunkterForPanel: [
{
...aksjonspunktDefault,
definisjon: AksjonspunktKode.OM_ADOPSJON_GJELDER_EKTEFELLES_BARN,
status: AksjonspunktStatus.OPPRETTET,
begrunnelse: null,
Expand All @@ -100,6 +127,7 @@ export const IkkeVisBarnetsAnkomstDatoForEngangsstønad: Story = {
args: {
aksjonspunkterForPanel: [
{
...aksjonspunktDefault,
definisjon: AksjonspunktKode.OM_ADOPSJON_GJELDER_EKTEFELLES_BARN,
status: AksjonspunktStatus.OPPRETTET,
begrunnelse: null,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import type { ComponentProps } from 'react';

import type { Meta, StoryObj } from '@storybook/react';

import { AksjonspunktKode, AksjonspunktStatus } from '@navikt/fp-kodeverk';
import { AksjonspunktKode, AksjonspunktStatus, AksjonspunktType, VilkarType } from '@navikt/fp-kodeverk';
import { type PanelDataArgs, withMellomlagretFormData, withPanelData } from '@navikt/fp-storybook-utils';
import type { Aksjonspunkt, ArbeidsgiverOpplysningerPerId } from '@navikt/fp-types';

Expand Down Expand Up @@ -30,6 +30,16 @@ const lagAksjonspunkt = (apKode: AksjonspunktKode, status: AksjonspunktStatus, b
status,
kanLoses: true,
begrunnelse: begrunnelse ?? null,
toTrinnsBehandling: false,
toTrinnsBehandlingGodkjent: null,
vurderPaNyttArsaker: null,
besluttersBegrunnelse: null,
aksjonspunktType: AksjonspunktType.AUTOPUNKT,
vilkarType: VilkarType.OMSORGSVILKARET,
erAktivt: true,
fristTid: null,
endretTidspunkt: null,
endretAv: null,
});

const meta = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,21 @@ import {
AdresseType,
AksjonspunktKode,
AksjonspunktStatus,
AksjonspunktType,
FarSøkerType,
NavBrukerKjonn,
SivilstandType,
SoknadType,
VilkarType,
} from '@navikt/fp-kodeverk';
import { type PanelDataArgs, withPanelData } from '@navikt/fp-storybook-utils';
import type { FamilieHendelseSamling, InntektArbeidYtelse, Personoversikt, Soknad } from '@navikt/fp-types';
import type {
Aksjonspunkt,
FamilieHendelseSamling,
InntektArbeidYtelse,
Personoversikt,
Soknad,
} from '@navikt/fp-types';

import { OmsorgOgForeldreansvarFaktaIndex } from './OmsorgOgForeldreansvarFaktaIndex';

Expand Down Expand Up @@ -102,10 +110,28 @@ export default meta;

type Story = StoryObj<typeof meta>;

const aksjonspunktDefault = {
definisjon: AksjonspunktKode.OMSORGSOVERTAKELSE,
status: AksjonspunktStatus.OPPRETTET,
begrunnelse: null,
kanLoses: true,
toTrinnsBehandling: false,
toTrinnsBehandlingGodkjent: null,
vurderPaNyttArsaker: null,
besluttersBegrunnelse: null,
aksjonspunktType: AksjonspunktType.AUTOPUNKT,
vilkarType: VilkarType.OMSORGSVILKARET,
erAktivt: true,
fristTid: null,
endretTidspunkt: null,
endretAv: null,
} satisfies Aksjonspunkt;

export const ÅpentAksjonspunktForOmsorgovertakelse: Story = {
args: {
aksjonspunkterForPanel: [
{
...aksjonspunktDefault,
definisjon: AksjonspunktKode.OMSORGSOVERTAKELSE,
status: AksjonspunktStatus.OPPRETTET,
begrunnelse: null,
Expand All @@ -132,6 +158,7 @@ export const UtførtAksjonspunktForOmsorgovertakelse: Story = {
},
aksjonspunkterForPanel: [
{
...aksjonspunktDefault,
definisjon: AksjonspunktKode.OMSORGSOVERTAKELSE,
status: AksjonspunktStatus.UTFORT,
begrunnelse: 'dette er en begrunnelse',
Expand All @@ -149,6 +176,7 @@ export const ÅpentAksjonspunktForAvklareVilkårForForeldreansvar: Story = {
args: {
aksjonspunkterForPanel: [
{
...aksjonspunktDefault,
definisjon: AksjonspunktKode.AVKLAR_VILKAR_FOR_FORELDREANSVAR,
status: AksjonspunktStatus.OPPRETTET,
begrunnelse: null,
Expand All @@ -166,6 +194,7 @@ export const UtførtAksjonspunktForAvklareVilkårForForeldreansvar: Story = {
args: {
aksjonspunkterForPanel: [
{
...aksjonspunktDefault,
definisjon: AksjonspunktKode.AVKLAR_VILKAR_FOR_FORELDREANSVAR,
status: AksjonspunktStatus.UTFORT,
begrunnelse: 'dette er en begrunnelse',
Expand Down
19 changes: 18 additions & 1 deletion packages/fakta/omsorg/src/OmsorgFaktaIndex.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,14 @@ import type { ComponentProps } from 'react';
import { TIDENES_ENDE } from '@navikt/ft-utils';
import type { Meta, StoryObj } from '@storybook/react';

import { AdresseType, AksjonspunktKode, AksjonspunktStatus, SivilstandType } from '@navikt/fp-kodeverk';
import {
AdresseType,
AksjonspunktKode,
AksjonspunktStatus,
AksjonspunktType,
SivilstandType,
VilkarType,
} from '@navikt/fp-kodeverk';
import { type PanelDataArgs, withMellomlagretFormData, withPanelData } from '@navikt/fp-storybook-utils';
import { KjønnkodeEnum, type PersonopplysningerBasis, type Ytelsefordeling } from '@navikt/fp-types';

Expand Down Expand Up @@ -85,6 +92,16 @@ export const ÅpentAksjonspunktForKontrollAvOmBrukerHarOmsorg: Story = {
status: AksjonspunktStatus.OPPRETTET,
begrunnelse: null,
kanLoses: true,
vilkarType: VilkarType.FODSELSVILKARET_MOR,
toTrinnsBehandling: false,
toTrinnsBehandlingGodkjent: null,
vurderPaNyttArsaker: null,
besluttersBegrunnelse: null,
aksjonspunktType: AksjonspunktType.AUTOPUNKT,
erAktivt: true,
fristTid: null,
endretTidspunkt: null,
endretAv: null,
},
],
alleMerknaderFraBeslutter: {
Expand Down
31 changes: 29 additions & 2 deletions packages/fakta/opptjening/src/OpptjeningFaktaIndex.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,15 @@ import type { ComponentProps } from 'react';

import type { Meta, StoryObj } from '@storybook/react';

import { AksjonspunktKode, AksjonspunktStatus, OpptjeningAktivitetType } from '@navikt/fp-kodeverk';
import {
AksjonspunktKode,
AksjonspunktStatus,
AksjonspunktType,
OpptjeningAktivitetType,
VilkarType,
} from '@navikt/fp-kodeverk';
import { type PanelDataArgs, withMellomlagretFormData, withPanelData } from '@navikt/fp-storybook-utils';
import type { ArbeidsgiverOpplysningerPerId, Opptjening } from '@navikt/fp-types';
import type { Aksjonspunkt, ArbeidsgiverOpplysningerPerId, Opptjening } from '@navikt/fp-types';

import { OpptjeningFaktaIndex } from './OpptjeningFaktaIndex';

Expand Down Expand Up @@ -37,10 +43,28 @@ export default meta;

type Story = StoryObj<typeof meta>;

const aksjonspunktDefault = {
definisjon: AksjonspunktKode.OMSORGSOVERTAKELSE,
status: AksjonspunktStatus.OPPRETTET,
begrunnelse: null,
kanLoses: true,
toTrinnsBehandling: false,
toTrinnsBehandlingGodkjent: null,
vurderPaNyttArsaker: null,
besluttersBegrunnelse: null,
aksjonspunktType: AksjonspunktType.AUTOPUNKT,
vilkarType: VilkarType.OMSORGSVILKARET,
erAktivt: true,
fristTid: null,
endretTidspunkt: null,
endretAv: null,
} satisfies Aksjonspunkt;

export const MedAksjonspunkt: Story = {
args: {
aksjonspunkterForPanel: [
{
...aksjonspunktDefault,
definisjon: AksjonspunktKode.VURDER_PERIODER_MED_OPPTJENING,
status: AksjonspunktStatus.OPPRETTET,
begrunnelse: null,
Expand Down Expand Up @@ -182,6 +206,7 @@ export const MedToLikePerioderForSammeAktivitetstype: Story = {
args: {
aksjonspunkterForPanel: [
{
...aksjonspunktDefault,
definisjon: AksjonspunktKode.VURDER_PERIODER_MED_OPPTJENING,
status: AksjonspunktStatus.OPPRETTET,
begrunnelse: null,
Expand Down Expand Up @@ -243,6 +268,8 @@ export const MedAlleOpptjeningsaktiviteterFiltrertBort: Story = {
args: {
aksjonspunkterForPanel: [
{
...aksjonspunktDefault,

definisjon: AksjonspunktKode.VURDER_PERIODER_MED_OPPTJENING,
status: AksjonspunktStatus.OPPRETTET,
begrunnelse: null,
Expand Down
Loading