mirror of
https://github.com/marcogll/passkit-generator.git
synced 2026-03-15 18:25:24 +00:00
Improved schemas in the project
This commit is contained in:
@@ -15,7 +15,7 @@ const genericDebug = debug("passkit:generic");
|
|||||||
const transitType = Symbol("transitType");
|
const transitType = Symbol("transitType");
|
||||||
const passProps = Symbol("_props");
|
const passProps = Symbol("_props");
|
||||||
|
|
||||||
const propsSchemaMap = new Map([
|
const propsSchemaMap = new Map<string, schema.Schema>([
|
||||||
["barcodes", "barcode"],
|
["barcodes", "barcode"],
|
||||||
["barcode", "barcode"],
|
["barcode", "barcode"],
|
||||||
["beacons", "beaconsDict"],
|
["beacons", "beaconsDict"],
|
||||||
@@ -634,10 +634,10 @@ function barcodesFromUncompleteData(message: string): schema.Barcode[] {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function processRelevancySet<T>(key: string, data: T[]): T[] {
|
function processRelevancySet<T>(key: string, data: T[]): T[] {
|
||||||
return getValidInArray(`${key}Dict`, data);
|
return getValidInArray(`${key}Dict` as schema.Schema, data);
|
||||||
}
|
}
|
||||||
|
|
||||||
function getValidInArray<T>(schemaName: string, contents: T[]): T[] {
|
function getValidInArray<T>(schemaName: schema.Schema, contents: T[]): T[] {
|
||||||
return contents.filter(current => Object.keys(current).length && schema.isValid(current, schemaName));
|
return contents.filter(current => Object.keys(current).length && schema.isValid(current, schemaName));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -455,7 +455,7 @@ const schemas = {
|
|||||||
personalizationDict
|
personalizationDict
|
||||||
};
|
};
|
||||||
|
|
||||||
type Schema = keyof typeof schemas;
|
export type Schema = keyof typeof schemas;
|
||||||
|
|
||||||
function resolveSchemaName(name: Schema) {
|
function resolveSchemaName(name: Schema) {
|
||||||
return schemas[name] || undefined;
|
return schemas[name] || undefined;
|
||||||
|
|||||||
Reference in New Issue
Block a user