mirror of
https://github.com/marcogll/passkit-generator.git
synced 2026-03-15 16:25:21 +00:00
Moved preferredStyleSchemes schema and properties to root (fixed Apple WWDC video misinformation)
This commit is contained in:
@@ -216,6 +216,44 @@ export default class PKPass extends Bundle {
|
|||||||
return Utils.cloneRecursive(this[propsSymbol]);
|
return Utils.cloneRecursive(this[propsSymbol]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Allows accessing to iOS 18 new Event Ticket
|
||||||
|
* property `preferredStyleSchemes`.
|
||||||
|
*
|
||||||
|
* @throws (automatically) if current type is not
|
||||||
|
* "eventTicket".
|
||||||
|
*/
|
||||||
|
|
||||||
|
public get preferredStyleSchemes(): Schemas.PreferredStyleSchemes {
|
||||||
|
return this[propsSymbol].preferredStyleSchemes;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Allows setting a preferredStyleSchemes property
|
||||||
|
* for a eventTicket.
|
||||||
|
*
|
||||||
|
* @throws if current type is not "eventTicket".
|
||||||
|
* @param value
|
||||||
|
*/
|
||||||
|
|
||||||
|
public set preferredStyleSchemes(value: Schemas.PreferredStyleSchemes) {
|
||||||
|
Utils.assertUnfrozen(this);
|
||||||
|
|
||||||
|
if (this.type !== "eventTicket") {
|
||||||
|
throw new TypeError(
|
||||||
|
Messages.PREFERRED_STYLE_SCHEMES.UNEXPECTED_PASS_TYPE,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Schemas.assertValidity(
|
||||||
|
Schemas.PreferredStyleSchemes,
|
||||||
|
value,
|
||||||
|
Messages.PREFERRED_STYLE_SCHEMES.INVALID,
|
||||||
|
);
|
||||||
|
|
||||||
|
this[propsSymbol].preferredStyleSchemes = value;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Allows setting a transitType property
|
* Allows setting a transitType property
|
||||||
* for a boardingPass.
|
* for a boardingPass.
|
||||||
@@ -316,44 +354,6 @@ export default class PKPass extends Bundle {
|
|||||||
return this[propsSymbol][this.type].backFields;
|
return this[propsSymbol][this.type].backFields;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Allows accessing to iOS 18 new Event Ticket
|
|
||||||
* property `preferredStyleSchemes`.
|
|
||||||
*
|
|
||||||
* @throws (automatically) if current type is not
|
|
||||||
* "eventTicket".
|
|
||||||
*/
|
|
||||||
|
|
||||||
public get preferredStyleSchemes(): Schemas.PreferredStyleSchemes {
|
|
||||||
return this[propsSymbol]["eventTicket"].preferredStyleSchemes;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Allows setting a preferredStyleSchemes property
|
|
||||||
* for a eventTicket.
|
|
||||||
*
|
|
||||||
* @throws if current type is not "eventTicket".
|
|
||||||
* @param value
|
|
||||||
*/
|
|
||||||
|
|
||||||
public set preferredStyleSchemes(value: Schemas.PreferredStyleSchemes) {
|
|
||||||
Utils.assertUnfrozen(this);
|
|
||||||
|
|
||||||
if (this.type !== "eventTicket") {
|
|
||||||
throw new TypeError(
|
|
||||||
Messages.PREFERRED_STYLE_SCHEMES.UNEXPECTED_PASS_TYPE,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
Schemas.assertValidity(
|
|
||||||
Schemas.PreferredStyleSchemes,
|
|
||||||
value,
|
|
||||||
Messages.PREFERRED_STYLE_SCHEMES.INVALID,
|
|
||||||
);
|
|
||||||
|
|
||||||
this[propsSymbol]["eventTicket"].preferredStyleSchemes = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Allows setting a pass type.
|
* Allows setting a pass type.
|
||||||
*
|
*
|
||||||
@@ -383,6 +383,7 @@ export default class PKPass extends Bundle {
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
this[propsSymbol][this.type] = undefined;
|
this[propsSymbol][this.type] = undefined;
|
||||||
|
this[propsSymbol].preferredStyleSchemes = undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
const sharedKeysPool = new Set<string>();
|
const sharedKeysPool = new Set<string>();
|
||||||
@@ -415,7 +416,6 @@ export default class PKPass extends Bundle {
|
|||||||
Schemas.Field,
|
Schemas.Field,
|
||||||
),
|
),
|
||||||
transitType: undefined,
|
transitType: undefined,
|
||||||
preferredStyleSchemes: undefined,
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -584,7 +584,6 @@ export default class PKPass extends Bundle {
|
|||||||
auxiliaryFields = [],
|
auxiliaryFields = [],
|
||||||
backFields = [],
|
backFields = [],
|
||||||
transitType,
|
transitType,
|
||||||
preferredStyleSchemes = [],
|
|
||||||
} = data[type] || {};
|
} = data[type] || {};
|
||||||
|
|
||||||
this.headerFields.push(...headerFields);
|
this.headerFields.push(...headerFields);
|
||||||
@@ -596,10 +595,6 @@ export default class PKPass extends Bundle {
|
|||||||
if (this.type === "boardingPass") {
|
if (this.type === "boardingPass") {
|
||||||
this.transitType = transitType;
|
this.transitType = transitType;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.type === "eventTicket") {
|
|
||||||
this.preferredStyleSchemes = preferredStyleSchemes;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -12,13 +12,6 @@ export const TransitType = Joi.string().regex(
|
|||||||
/(PKTransitTypeAir|PKTransitTypeBoat|PKTransitTypeBus|PKTransitTypeGeneric|PKTransitTypeTrain)/,
|
/(PKTransitTypeAir|PKTransitTypeBoat|PKTransitTypeBus|PKTransitTypeGeneric|PKTransitTypeTrain)/,
|
||||||
);
|
);
|
||||||
|
|
||||||
export type PreferredStyleSchemes = ("posterEventTicket" | "eventTicket")[];
|
|
||||||
|
|
||||||
export const PreferredStyleSchemes = Joi.array().items(
|
|
||||||
"posterEventTicket",
|
|
||||||
"eventTicket",
|
|
||||||
) satisfies Joi.Schema<PreferredStyleSchemes>;
|
|
||||||
|
|
||||||
export interface PassFields {
|
export interface PassFields {
|
||||||
auxiliaryFields: FieldWithRow[];
|
auxiliaryFields: FieldWithRow[];
|
||||||
backFields: Field[];
|
backFields: Field[];
|
||||||
@@ -26,7 +19,6 @@ export interface PassFields {
|
|||||||
primaryFields: Field[];
|
primaryFields: Field[];
|
||||||
secondaryFields: Field[];
|
secondaryFields: Field[];
|
||||||
transitType?: TransitType;
|
transitType?: TransitType;
|
||||||
preferredStyleSchemes?: PreferredStyleSchemes;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export const PassFields = Joi.object<PassFields>().keys({
|
export const PassFields = Joi.object<PassFields>().keys({
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ import { Barcode } from "./Barcode";
|
|||||||
import { Location } from "./Location";
|
import { Location } from "./Location";
|
||||||
import { Beacon } from "./Beacon";
|
import { Beacon } from "./Beacon";
|
||||||
import { NFC } from "./NFC";
|
import { NFC } from "./NFC";
|
||||||
import { PassFields, PreferredStyleSchemes, TransitType } from "./PassFields";
|
import { PassFields, TransitType } from "./PassFields";
|
||||||
import { Semantics } from "./Semantics";
|
import { Semantics } from "./Semantics";
|
||||||
import { CertificatesSchema } from "./Certificates";
|
import { CertificatesSchema } from "./Certificates";
|
||||||
|
|
||||||
@@ -26,6 +26,13 @@ const RGB_COLOR_REGEX =
|
|||||||
|
|
||||||
const URL_REGEX = /https?:\/\/(?:[a-z0-9]+\.?)+(?::\d{2,})?(?:\/[\S]+)*/;
|
const URL_REGEX = /https?:\/\/(?:[a-z0-9]+\.?)+(?::\d{2,})?(?:\/[\S]+)*/;
|
||||||
|
|
||||||
|
export type PreferredStyleSchemes = ("posterEventTicket" | "eventTicket")[];
|
||||||
|
|
||||||
|
export const PreferredStyleSchemes = Joi.array().items(
|
||||||
|
"posterEventTicket",
|
||||||
|
"eventTicket",
|
||||||
|
) satisfies Joi.Schema<PreferredStyleSchemes>;
|
||||||
|
|
||||||
export interface FileBuffers {
|
export interface FileBuffers {
|
||||||
[key: string]: Buffer;
|
[key: string]: Buffer;
|
||||||
}
|
}
|
||||||
@@ -63,20 +70,7 @@ export interface PassProps {
|
|||||||
locations?: Location[];
|
locations?: Location[];
|
||||||
|
|
||||||
boardingPass?: PassFields & { transitType: TransitType };
|
boardingPass?: PassFields & { transitType: TransitType };
|
||||||
eventTicket?: PassFields & {
|
eventTicket?: PassFields;
|
||||||
/**
|
|
||||||
* New field coming in iOS 18
|
|
||||||
* `"eventTicket"` is the legacy style.
|
|
||||||
*
|
|
||||||
* If used, passkit will try to render following the old style
|
|
||||||
* first.
|
|
||||||
*
|
|
||||||
* Which means that `primaryFields`, `secondaryFields` and
|
|
||||||
* so on, are not necessary anymore for the new style,
|
|
||||||
* as semantics are preferred.
|
|
||||||
*/
|
|
||||||
preferredStyleSchemes?: PreferredStyleSchemes;
|
|
||||||
};
|
|
||||||
coupon?: PassFields;
|
coupon?: PassFields;
|
||||||
generic?: PassFields;
|
generic?: PassFields;
|
||||||
storeCard?: PassFields;
|
storeCard?: PassFields;
|
||||||
@@ -98,6 +92,12 @@ export interface PassProps {
|
|||||||
* Event Ticket
|
* Event Ticket
|
||||||
*/
|
*/
|
||||||
parkingInformationURL?: string;
|
parkingInformationURL?: string;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* New field for iOS 18
|
||||||
|
* Event Ticket
|
||||||
|
*/
|
||||||
|
preferredStyleSchemes?: PreferredStyleSchemes;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -145,22 +145,7 @@ export const PassKindsProps = Joi.object<PassKindsProps>({
|
|||||||
coupon: PassFields.disallow("transitType"),
|
coupon: PassFields.disallow("transitType"),
|
||||||
generic: PassFields.disallow("transitType"),
|
generic: PassFields.disallow("transitType"),
|
||||||
storeCard: PassFields.disallow("transitType"),
|
storeCard: PassFields.disallow("transitType"),
|
||||||
eventTicket: PassFields.disallow("transitType").concat(
|
eventTicket: PassFields.disallow("transitType"),
|
||||||
Joi.object<PassProps["eventTicket"]>().keys({
|
|
||||||
/**
|
|
||||||
* New field coming in iOS 18
|
|
||||||
* `"eventTicket"` is the legacy style.
|
|
||||||
*
|
|
||||||
* If used, passkit will try to render following the old style
|
|
||||||
* first.
|
|
||||||
*
|
|
||||||
* Which means that `primaryFields`, `secondaryFields` and
|
|
||||||
* so on, are not necessary anymore for the new style,
|
|
||||||
* as semantics are preferred.
|
|
||||||
*/
|
|
||||||
preferredStyleSchemes: PreferredStyleSchemes,
|
|
||||||
}),
|
|
||||||
),
|
|
||||||
boardingPass: PassFields,
|
boardingPass: PassFields,
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -206,6 +191,10 @@ export const OverridablePassProps = Joi.object<OverridablePassProps>({
|
|||||||
/**
|
/**
|
||||||
* New field for iOS 18
|
* New field for iOS 18
|
||||||
* Event Ticket
|
* Event Ticket
|
||||||
|
* `"eventTicket"` is the legacy style.
|
||||||
|
*
|
||||||
|
* Passkit will try to render a style based on the order
|
||||||
|
* of the properties
|
||||||
*/
|
*/
|
||||||
parkingInformationURL: Joi.string().regex(URL_REGEX),
|
parkingInformationURL: Joi.string().regex(URL_REGEX),
|
||||||
}).with("webServiceURL", "authenticationToken");
|
}).with("webServiceURL", "authenticationToken");
|
||||||
|
|||||||
Reference in New Issue
Block a user