diff --git a/src/FieldsArray.ts b/src/FieldsArray.ts index f02df0f..00e07b0 100644 --- a/src/FieldsArray.ts +++ b/src/FieldsArray.ts @@ -10,6 +10,7 @@ import * as Messages from "./messages"; const passInstanceSymbol = Symbol("passInstance"); const sharedKeysPoolSymbol = Symbol("keysPool"); +const fieldSchemaSymbol = Symbol("fieldSchema"); export default class FieldsArray extends Array { private [passInstanceSymbol]: InstanceType; @@ -18,9 +19,11 @@ export default class FieldsArray extends Array { constructor( passInstance: InstanceType, keysPool: Set, + fieldSchema: typeof Schemas.Field | typeof Schemas.FieldWithRow, ...args: Schemas.Field[] ) { super(...args); + this[fieldSchemaSymbol] = fieldSchema; this[passInstanceSymbol] = passInstance; this[sharedKeysPoolSymbol] = keysPool; } @@ -75,7 +78,7 @@ function registerWithValidation( try { Schemas.assertValidity( - Schemas.Field, + instance[fieldSchemaSymbol], field, Messages.FIELDS.INVALID, ); diff --git a/src/PKPass.ts b/src/PKPass.ts index e74f0ba..58e02ba 100644 --- a/src/PKPass.ts +++ b/src/PKPass.ts @@ -353,12 +353,32 @@ export default class PKPass extends Bundle { const sharedKeysPool = new Set(); this[passTypeSymbol] = type; - this[propsSymbol][this[passTypeSymbol]] = { - headerFields /******/: new FieldsArray(this, sharedKeysPool), - primaryFields /*****/: new FieldsArray(this, sharedKeysPool), - secondaryFields /***/: new FieldsArray(this, sharedKeysPool), - auxiliaryFields /***/: new FieldsArray(this, sharedKeysPool), - backFields /********/: new FieldsArray(this, sharedKeysPool), + this[propsSymbol][type] = { + headerFields /******/: new FieldsArray( + this, + sharedKeysPool, + Schemas.Field, + ), + primaryFields /*****/: new FieldsArray( + this, + sharedKeysPool, + Schemas.Field, + ), + secondaryFields /***/: new FieldsArray( + this, + sharedKeysPool, + Schemas.Field, + ), + auxiliaryFields /***/: new FieldsArray( + this, + sharedKeysPool, + type === "eventTicket" ? Schemas.FieldWithRow : Schemas.Field, + ), + backFields /********/: new FieldsArray( + this, + sharedKeysPool, + Schemas.Field, + ), transitType: undefined, }; }