mirror of
https://github.com/marcogll/passkit-generator.git
synced 2026-03-15 18:25:24 +00:00
Improved spaces, types and casting
This commit is contained in:
35
src/pass.ts
35
src/pass.ts
@@ -40,13 +40,11 @@ export class Pass {
|
|||||||
private fieldsKeys: Set<string> = new Set<string>();
|
private fieldsKeys: Set<string> = new Set<string>();
|
||||||
private passCore: Schemas.ValidPass;
|
private passCore: Schemas.ValidPass;
|
||||||
|
|
||||||
// Setting these as possibly undefined because we set
|
public headerFields: FieldsArray;
|
||||||
// them all in an loop later
|
public primaryFields: FieldsArray;
|
||||||
public headerFields: FieldsArray | undefined;
|
public secondaryFields: FieldsArray;
|
||||||
public primaryFields: FieldsArray | undefined;
|
public auxiliaryFields: FieldsArray;
|
||||||
public secondaryFields: FieldsArray | undefined;
|
public backFields: FieldsArray;
|
||||||
public auxiliaryFields: FieldsArray | undefined;
|
|
||||||
public backFields: FieldsArray | undefined;
|
|
||||||
|
|
||||||
private Certificates: Schemas.CertificatesSchema;
|
private Certificates: Schemas.CertificatesSchema;
|
||||||
private [transitType]: string = "";
|
private [transitType]: string = "";
|
||||||
@@ -93,6 +91,7 @@ export class Pass {
|
|||||||
const passCoreKeys = Object.keys(
|
const passCoreKeys = Object.keys(
|
||||||
this.passCore,
|
this.passCore,
|
||||||
) as (keyof Schemas.ValidPass)[];
|
) as (keyof Schemas.ValidPass)[];
|
||||||
|
|
||||||
const validatedPassKeys = passCoreKeys.reduce<Schemas.ValidPass>(
|
const validatedPassKeys = passCoreKeys.reduce<Schemas.ValidPass>(
|
||||||
(acc, current) => {
|
(acc, current) => {
|
||||||
if (this.type === current) {
|
if (this.type === current) {
|
||||||
@@ -115,7 +114,11 @@ export class Pass {
|
|||||||
currentSchema,
|
currentSchema,
|
||||||
this.passCore[current] as Schemas.ArrayPassSchema[],
|
this.passCore[current] as Schemas.ArrayPassSchema[],
|
||||||
);
|
);
|
||||||
return { ...acc, [current]: valid };
|
|
||||||
|
return {
|
||||||
|
...acc,
|
||||||
|
[current]: valid,
|
||||||
|
};
|
||||||
} else {
|
} else {
|
||||||
return {
|
return {
|
||||||
...acc,
|
...acc,
|
||||||
@@ -195,7 +198,7 @@ export class Pass {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
const finalBundle = { ...this.bundle } as Schemas.BundleUnit;
|
const finalBundle: Schemas.BundleUnit = { ...this.bundle };
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Iterating through languages and generating pass.string file
|
* Iterating through languages and generating pass.string file
|
||||||
@@ -488,7 +491,7 @@ export class Pass {
|
|||||||
return acc;
|
return acc;
|
||||||
}
|
}
|
||||||
|
|
||||||
return [...acc, validated] as Schemas.Barcode[];
|
return [...acc, validated];
|
||||||
},
|
},
|
||||||
[],
|
[],
|
||||||
);
|
);
|
||||||
@@ -669,17 +672,15 @@ function barcodesFromUncompleteData(message: string): Schemas.Barcode[] {
|
|||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
|
|
||||||
return [
|
return (
|
||||||
|
[
|
||||||
"PKBarcodeFormatQR",
|
"PKBarcodeFormatQR",
|
||||||
"PKBarcodeFormatPDF417",
|
"PKBarcodeFormatPDF417",
|
||||||
"PKBarcodeFormatAztec",
|
"PKBarcodeFormatAztec",
|
||||||
"PKBarcodeFormatCode128",
|
"PKBarcodeFormatCode128",
|
||||||
].map(
|
] as Array<Schemas.BarcodeFormat>
|
||||||
(format) =>
|
).map((format) =>
|
||||||
Schemas.getValidated(
|
Schemas.getValidated({ format, message }, Schemas.Barcode),
|
||||||
{ format, message },
|
|
||||||
Schemas.Barcode,
|
|
||||||
) as Schemas.Barcode,
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user