alexandercerutti / passkit-generator

The easiest way to generate custom Apple Wallet passes in Node.js
MIT License
893 stars 109 forks source link

overriding fields on generic pass not working #162

Closed ktwbc closed 1 year ago

ktwbc commented 1 year ago

Running OS

MacOS Ventura

Running Node Version

node 18

Description

I have a generic pass being created in a typescript function. Any of the items in the actual .json file are showing up as part of the pass, but I also need to use the override but none of those being picked up.

Taking this example from sample code:

    const pass = await PKPass.from({
        /**
         * Note: .pass extension is enforced when reading a
         * model from FS, even if not specified here below
         */
        model: "./passModels/myFirstModel.pass",
        certificates: {
            wwdr,
            signerCert,
            signerKey,
            signerKeyPassphrase
        },
    }, {
        // keys to be added or overridden
        serialNumber: "AAGH44625236dddaffbda"
    });

my block of overridden keys (b/c they're created dynamically) looks like this:

    {
      // keys to be added or overridden
      // serialNumber: "AAGH44625236dddaffbda"
      generic: {
        // primaryFields: [{ label: 'Licensee Name', key: 'student', value: dbObject.user_name }],
        secondaryFields: [
          { label: 'Certification', key: 'course', value: dbObject.course },
          { label: 'Cert Number', key: 'record_locator', value: dbObject.record_locator }
        ],

etc

alexandercerutti commented 1 year ago

Hi @ktwbc, thanks for using passkit-generator!

I see what you mean, but "overrides" should be used for properties that do not require a strict or tailored validation.

You can see here the list of properties here:

https://github.com/alexandercerutti/passkit-generator/blob/921b955a85e68731e6d5e0bedda30c1ac9ea6edf/src/schemas/index.ts#L123-L148

For all the other properties, there are some getters, setters and methods available, all described in the documentation, that are made on purpose to provide a better developer experience and to ensure validation happens correctly.

Let me know if you have any other question!