From 356e68378af1762feca5298af61f9532b63475b3 Mon Sep 17 00:00:00 2001 From: Alexander Cerutti Date: Thu, 5 Dec 2019 23:55:28 +0100 Subject: [PATCH] Improved schemas in the project --- src/pass.ts | 6 +++--- src/schema.ts | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/pass.ts b/src/pass.ts index 3698821..12176cc 100644 --- a/src/pass.ts +++ b/src/pass.ts @@ -15,7 +15,7 @@ const genericDebug = debug("passkit:generic"); const transitType = Symbol("transitType"); const passProps = Symbol("_props"); -const propsSchemaMap = new Map([ +const propsSchemaMap = new Map([ ["barcodes", "barcode"], ["barcode", "barcode"], ["beacons", "beaconsDict"], @@ -634,10 +634,10 @@ function barcodesFromUncompleteData(message: string): schema.Barcode[] { } function processRelevancySet(key: string, data: T[]): T[] { - return getValidInArray(`${key}Dict`, data); + return getValidInArray(`${key}Dict` as schema.Schema, data); } -function getValidInArray(schemaName: string, contents: T[]): T[] { +function getValidInArray(schemaName: schema.Schema, contents: T[]): T[] { return contents.filter(current => Object.keys(current).length && schema.isValid(current, schemaName)); } diff --git a/src/schema.ts b/src/schema.ts index 2b90157..8aaaa20 100644 --- a/src/schema.ts +++ b/src/schema.ts @@ -455,7 +455,7 @@ const schemas = { personalizationDict }; -type Schema = keyof typeof schemas; +export type Schema = keyof typeof schemas; function resolveSchemaName(name: Schema) { return schemas[name] || undefined;