From e986fda63bb977fe6140a6c94dc286ab4e00bb4e Mon Sep 17 00:00:00 2001 From: Songkeys Date: Mon, 3 Apr 2023 23:38:36 +0800 Subject: [PATCH 1/6] fix: transitType should be read when type is boardingPass (#137) --- src/PKPass.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/PKPass.ts b/src/PKPass.ts index e1347f4..d827be8 100644 --- a/src/PKPass.ts +++ b/src/PKPass.ts @@ -556,6 +556,7 @@ export default class PKPass extends Bundle { secondaryFields = [], auxiliaryFields = [], backFields = [], + transitType, } = data[type] || {}; this.headerFields.push(...headerFields); @@ -563,6 +564,9 @@ export default class PKPass extends Bundle { this.secondaryFields.push(...secondaryFields); this.auxiliaryFields.push(...auxiliaryFields); this.backFields.push(...backFields); + if (this.type === "boardingPass") { + this.transitType = transitType; + } } } From 1dec7d5a6b3fe4c2943dbbf826bf1a8348082e5b Mon Sep 17 00:00:00 2001 From: Songkeys Date: Mon, 3 Apr 2023 23:51:31 +0800 Subject: [PATCH 2/6] 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 3/6] 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 { From 07eb6f5cce2766a5b3fa71cd7e5953186c48c049 Mon Sep 17 00:00:00 2001 From: Alexander Cerutti Date: Mon, 3 Apr 2023 21:18:49 +0200 Subject: [PATCH 4/6] Added a bit of space: let's make the code breathe --- src/PKPass.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/PKPass.ts b/src/PKPass.ts index d827be8..00d8bc8 100644 --- a/src/PKPass.ts +++ b/src/PKPass.ts @@ -564,6 +564,7 @@ export default class PKPass extends Bundle { this.secondaryFields.push(...secondaryFields); this.auxiliaryFields.push(...auxiliaryFields); this.backFields.push(...backFields); + if (this.type === "boardingPass") { this.transitType = transitType; } From dd02a1ffad328d2aa8f3cef0f079f0dfb3dfddef Mon Sep 17 00:00:00 2001 From: Alexander Cerutti Date: Mon, 3 Apr 2023 21:44:10 +0200 Subject: [PATCH 5/6] Changelog update for version bump (3.1.9) --- CHANGELOG.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index b2f8eb5..edbb586 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,10 @@ # Changelog +## 3.1.9 - 03 Apr 2023 + + Fixed transitType which wasn't being imported when a boardingPass was getting read (PR#138) + Improved types for property in Field type (PR#139) + ## 3.1.8 - 26 Mar 2023 Fixed Typescript type for Semantics.WifiAccess (PR#136) From 722979f925d9b8a2c9d9d5ead837c96892c87af2 Mon Sep 17 00:00:00 2001 From: Alexander Cerutti Date: Mon, 3 Apr 2023 21:44:16 +0200 Subject: [PATCH 6/6] 3.1.9 --- package-lock.json | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/package-lock.json b/package-lock.json index 5dcc729..e52e8f8 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "passkit-generator", - "version": "3.1.8", + "version": "3.1.9", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "passkit-generator", - "version": "3.1.8", + "version": "3.1.9", "license": "MIT", "dependencies": { "do-not-zip": "^1.0.0", diff --git a/package.json b/package.json index ad184b7..163b0c0 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "passkit-generator", - "version": "3.1.8", + "version": "3.1.9", "description": "The easiest way to generate custom Apple Wallet passes in Node.js", "main": "lib/index.js", "scripts": {