From 1dec7d5a6b3fe4c2943dbbf826bf1a8348082e5b Mon Sep 17 00:00:00 2001 From: Songkeys Date: Mon, 3 Apr 2023 23:51:31 +0800 Subject: [PATCH 1/2] 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 { From a43d6e55d0dedb1cd7a8be878e48e9af6df930db Mon Sep 17 00:00:00 2001 From: Songkeys Date: Tue, 4 Apr 2023 00:00:49 +0800 Subject: [PATCH 2/2] chore: rename for consistency --- src/schemas/Field.ts | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/schemas/Field.ts b/src/schemas/Field.ts index cde28e6..f9852a3 100644 --- a/src/schemas/Field.ts +++ b/src/schemas/Field.ts @@ -1,26 +1,26 @@ import Joi from "joi"; import { Semantics } from "./Semantics"; -export type FieldDataDetectorType = +export type PKDataDetectorType = | "PKDataDetectorTypePhoneNumber" | "PKDataDetectorTypeLink" | "PKDataDetectorTypeAddress" | "PKDataDetectorTypeCalendarEvent"; -export type FieldTextAlignment = +export type PKTextAlignmentType = | "PKTextAlignmentLeft" | "PKTextAlignmentCenter" | "PKTextAlignmentRight" | "PKTextAlignmentNatural"; -export type FieldDateStyle = +export type PKDateStyleType = | "PKDateStyleNone" | "PKDateStyleShort" | "PKDateStyleMedium" | "PKDateStyleLong" | "PKDateStyleFull"; -export type FieldNumberStyle = +export type PKNumberStyleType = | "PKNumberStyleDecimal" | "PKNumberStylePercent" | "PKNumberStyleScientific" @@ -33,18 +33,18 @@ export type FieldNumberStyle = export interface Field { attributedValue?: string | number | Date; changeMessage?: string; - dataDetectorTypes?: FieldDataDetectorType[]; + dataDetectorTypes?: PKDataDetectorType[]; label?: string; - textAlignment?: FieldTextAlignment; + textAlignment?: PKTextAlignmentType; key: string; value: string | number | Date; semantics?: Semantics; - dateStyle?: FieldDateStyle; + dateStyle?: PKDateStyleType; ignoresTimeZone?: boolean; isRelative?: boolean; timeStyle?: string; currencyCode?: string; - numberStyle?: FieldNumberStyle; + numberStyle?: PKNumberStyleType; } export interface FieldWithRow extends Field {