mirror of
https://github.com/marcogll/passkit-generator.git
synced 2026-03-15 19:25:23 +00:00
Added fieldSchema property to FieldsArray
This commit is contained in:
@@ -10,6 +10,7 @@ import * as Messages from "./messages";
|
|||||||
|
|
||||||
const passInstanceSymbol = Symbol("passInstance");
|
const passInstanceSymbol = Symbol("passInstance");
|
||||||
const sharedKeysPoolSymbol = Symbol("keysPool");
|
const sharedKeysPoolSymbol = Symbol("keysPool");
|
||||||
|
const fieldSchemaSymbol = Symbol("fieldSchema");
|
||||||
|
|
||||||
export default class FieldsArray extends Array<Schemas.Field> {
|
export default class FieldsArray extends Array<Schemas.Field> {
|
||||||
private [passInstanceSymbol]: InstanceType<typeof PKPass>;
|
private [passInstanceSymbol]: InstanceType<typeof PKPass>;
|
||||||
@@ -18,9 +19,11 @@ export default class FieldsArray extends Array<Schemas.Field> {
|
|||||||
constructor(
|
constructor(
|
||||||
passInstance: InstanceType<typeof PKPass>,
|
passInstance: InstanceType<typeof PKPass>,
|
||||||
keysPool: Set<string>,
|
keysPool: Set<string>,
|
||||||
|
fieldSchema: typeof Schemas.Field | typeof Schemas.FieldWithRow,
|
||||||
...args: Schemas.Field[]
|
...args: Schemas.Field[]
|
||||||
) {
|
) {
|
||||||
super(...args);
|
super(...args);
|
||||||
|
this[fieldSchemaSymbol] = fieldSchema;
|
||||||
this[passInstanceSymbol] = passInstance;
|
this[passInstanceSymbol] = passInstance;
|
||||||
this[sharedKeysPoolSymbol] = keysPool;
|
this[sharedKeysPoolSymbol] = keysPool;
|
||||||
}
|
}
|
||||||
@@ -75,7 +78,7 @@ function registerWithValidation(
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
Schemas.assertValidity(
|
Schemas.assertValidity(
|
||||||
Schemas.Field,
|
instance[fieldSchemaSymbol],
|
||||||
field,
|
field,
|
||||||
Messages.FIELDS.INVALID,
|
Messages.FIELDS.INVALID,
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -353,12 +353,32 @@ export default class PKPass extends Bundle {
|
|||||||
const sharedKeysPool = new Set<string>();
|
const sharedKeysPool = new Set<string>();
|
||||||
|
|
||||||
this[passTypeSymbol] = type;
|
this[passTypeSymbol] = type;
|
||||||
this[propsSymbol][this[passTypeSymbol]] = {
|
this[propsSymbol][type] = {
|
||||||
headerFields /******/: new FieldsArray(this, sharedKeysPool),
|
headerFields /******/: new FieldsArray(
|
||||||
primaryFields /*****/: new FieldsArray(this, sharedKeysPool),
|
this,
|
||||||
secondaryFields /***/: new FieldsArray(this, sharedKeysPool),
|
sharedKeysPool,
|
||||||
auxiliaryFields /***/: new FieldsArray(this, sharedKeysPool),
|
Schemas.Field,
|
||||||
backFields /********/: new FieldsArray(this, sharedKeysPool),
|
),
|
||||||
|
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,
|
transitType: undefined,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user