mirror of
https://github.com/marcogll/passkit-generator.git
synced 2026-03-15 21:25:26 +00:00
Added support for pass.json properties to be inserted in _props
This commit is contained in:
28
src/pass.ts
28
src/pass.ts
@@ -61,6 +61,13 @@ export class Pass implements PassIndexSignature {
|
|||||||
this.l10nBundles = options.model.l10nBundle;
|
this.l10nBundles = options.model.l10nBundle;
|
||||||
this.bundle = { ...options.model.bundle };
|
this.bundle = { ...options.model.bundle };
|
||||||
|
|
||||||
|
try {
|
||||||
|
// getting pass.json
|
||||||
|
this.passCore = JSON.parse(this.bundle["pass.json"].toString("utf8"));
|
||||||
|
} catch (err) {
|
||||||
|
throw new Error(formatMessage("PASSFILE_VALIDATION_FAILED"));
|
||||||
|
}
|
||||||
|
|
||||||
// Parsing the options and extracting only the valid ones.
|
// Parsing the options and extracting only the valid ones.
|
||||||
const validOverrides = schema.getValidated(options.overrides || {}, "supportedOptions") as schema.OverridesSupportedOptions;
|
const validOverrides = schema.getValidated(options.overrides || {}, "supportedOptions") as schema.OverridesSupportedOptions;
|
||||||
|
|
||||||
@@ -68,15 +75,22 @@ export class Pass implements PassIndexSignature {
|
|||||||
throw new Error(formatMessage("OVV_KEYS_BADFORMAT"))
|
throw new Error(formatMessage("OVV_KEYS_BADFORMAT"))
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Object.keys(validOverrides).length) {
|
this._props = [
|
||||||
this._props = { ...validOverrides };
|
"barcodes", "barcode",
|
||||||
|
"expirationDate", "voided",
|
||||||
|
"beacons", "locations",
|
||||||
|
"relevantDate", "nfc"
|
||||||
|
].reduce<schema.ValidPass>((acc, current) => {
|
||||||
|
if (!this.passCore[current]) {
|
||||||
|
return acc;
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
acc[current] = this.passCore[current];
|
||||||
// getting pass.json
|
return acc;
|
||||||
this.passCore = JSON.parse(this.bundle["pass.json"].toString("utf8"));
|
}, {});
|
||||||
} catch (err) {
|
|
||||||
throw new Error(formatMessage("PASSFILE_VALIDATION_FAILED"));
|
if (Object.keys(validOverrides).length) {
|
||||||
|
this._props = { ...this._props, ...validOverrides };
|
||||||
}
|
}
|
||||||
|
|
||||||
this.type = Object.keys(this.passCore)
|
this.type = Object.keys(this.passCore)
|
||||||
|
|||||||
Reference in New Issue
Block a user