From 1dec7d5a6b3fe4c2943dbbf826bf1a8348082e5b Mon Sep 17 00:00:00 2001 From: Songkeys Date: Mon, 3 Apr 2023 23:51:31 +0800 Subject: [PATCH] fix: complete pass field types for typescript --- src/schemas/Field.ts | 33 +++++++++++++++++++++++++++++---- 1 file changed, 29 insertions(+), 4 deletions(-) diff --git a/src/schemas/Field.ts b/src/schemas/Field.ts index 1c837c5..cde28e6 100644 --- a/src/schemas/Field.ts +++ b/src/schemas/Field.ts @@ -1,6 +1,31 @@ import Joi from "joi"; import { Semantics } from "./Semantics"; +export type FieldDataDetectorType = + | "PKDataDetectorTypePhoneNumber" + | "PKDataDetectorTypeLink" + | "PKDataDetectorTypeAddress" + | "PKDataDetectorTypeCalendarEvent"; + +export type FieldTextAlignment = + | "PKTextAlignmentLeft" + | "PKTextAlignmentCenter" + | "PKTextAlignmentRight" + | "PKTextAlignmentNatural"; + +export type FieldDateStyle = + | "PKDateStyleNone" + | "PKDateStyleShort" + | "PKDateStyleMedium" + | "PKDateStyleLong" + | "PKDateStyleFull"; + +export type FieldNumberStyle = + | "PKNumberStyleDecimal" + | "PKNumberStylePercent" + | "PKNumberStyleScientific" + | "PKNumberStyleSpellOut"; + /** * @see https://developer.apple.com/documentation/walletpasses/passfieldcontent */ @@ -8,18 +33,18 @@ import { Semantics } from "./Semantics"; export interface Field { attributedValue?: string | number | Date; changeMessage?: string; - dataDetectorTypes?: string[]; + dataDetectorTypes?: FieldDataDetectorType[]; label?: string; - textAlignment?: string; + textAlignment?: FieldTextAlignment; key: string; value: string | number | Date; semantics?: Semantics; - dateStyle?: string; + dateStyle?: FieldDateStyle; ignoresTimeZone?: boolean; isRelative?: boolean; timeStyle?: string; currencyCode?: string; - numberStyle?: string; + numberStyle?: FieldNumberStyle; } export interface FieldWithRow extends Field {