From efac9f41536e9017b7aa5606484db1d7e1bab9d1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=B8ran=20Dalum?= Date: Thu, 25 Jun 2026 09:22:25 +0200 Subject: [PATCH] feat: add refundReasons spec --- examples/refundReasons.yaml | 18 ++++++++++ schema-definitions/refundReasons.json | 50 +++++++++++++++++++++++++++ src/index.ts | 1 + src/refund-reasons.ts | 14 ++++++++ src/tools/specifications-types.ts | 3 ++ 5 files changed, 86 insertions(+) create mode 100644 examples/refundReasons.yaml create mode 100644 schema-definitions/refundReasons.json create mode 100644 src/refund-reasons.ts diff --git a/examples/refundReasons.yaml b/examples/refundReasons.yaml new file mode 100644 index 0000000..f510b3b --- /dev/null +++ b/examples/refundReasons.yaml @@ -0,0 +1,18 @@ +# yaml-language-server: $schema=../schema-definitions/refundReasons.json +refundReasons: + - id: WRONG_TICKET_TYPE + name: + - lang: nob + value: Feil billettype + - lang: nno + value: Feil billettype + - lang: eng + value: Wrong ticket type + - id: OTHER + name: + - lang: nob + value: Annet + - lang: nno + value: Anna + - lang: eng + value: Other diff --git a/schema-definitions/refundReasons.json b/schema-definitions/refundReasons.json new file mode 100644 index 0000000..837ace0 --- /dev/null +++ b/schema-definitions/refundReasons.json @@ -0,0 +1,50 @@ +{ + "$schema": "https://json-schema.org/draft/2020-12/schema", + "title": "RefundReasons", + "type": "object", + "properties": { + "refundReasons": { + "default": [], + "type": "array", + "items": { + "type": "object", + "properties": { + "id": { + "type": "string" + }, + "name": { + "type": "array", + "items": { + "anyOf": [ + { + "type": "object", + "properties": { + "lang": { + "type": "string" + }, + "value": { + "type": "string" + } + }, + "required": ["lang", "value"] + }, + { + "type": "object", + "properties": { + "language": { + "type": "string" + }, + "value": { + "type": "string" + } + } + } + ] + } + } + }, + "required": ["id", "name"] + } + } + } +} diff --git a/src/index.ts b/src/index.ts index 3894f3f..ea73719 100644 --- a/src/index.ts +++ b/src/index.ts @@ -9,3 +9,4 @@ export * from './other'; export * from './reference-data'; export * from './stop-signal-button-config'; export * from './known-qr-code-urls'; +export * from './refund-reasons'; diff --git a/src/refund-reasons.ts b/src/refund-reasons.ts new file mode 100644 index 0000000..755e124 --- /dev/null +++ b/src/refund-reasons.ts @@ -0,0 +1,14 @@ +import {z} from 'zod'; +import {LanguageAndTextTypeArray} from './common'; + +export const RefundReason = z.object({ + id: z.string(), + name: LanguageAndTextTypeArray, +}); + +export const RefundReasons = z.object({ + refundReasons: z.array(RefundReason).default([]), +}); + +export type RefundReasonType = z.infer; +export type RefundReasonsType = z.infer; diff --git a/src/tools/specifications-types.ts b/src/tools/specifications-types.ts index 0f230fc..808f0f0 100644 --- a/src/tools/specifications-types.ts +++ b/src/tools/specifications-types.ts @@ -21,6 +21,7 @@ import {Other} from '../other'; import {ReferenceData} from '../reference-data'; import {StopSignalButtonConfig} from '../stop-signal-button-config'; import {KnownQrCodeUrls} from '../known-qr-code-urls'; +import {RefundReasons} from '../refund-reasons'; import {AppVersionedItem, AppVersionedItemSchema} from '../common'; // All supported specifications @@ -36,6 +37,7 @@ export const specifications = [ 'referenceData', 'stopSignalButtonConfig', 'knownQrCodeUrls', + 'refundReasons', ] as const; export type SchemaNames = (typeof specifications)[number]; @@ -76,6 +78,7 @@ export const schemaTypes = { referenceData: ReferenceData, stopSignalButtonConfig: StopSignalButtonConfig, knownQrCodeUrls: KnownQrCodeUrls.meta({title: 'KnownQrCodeUrls'}), + refundReasons: RefundReasons.meta({title: 'RefundReasons'}), } satisfies Record; // All correctly supported schema types as JSON Schema data structures