Skip to content
For the complete documentation index, see llms.txt. This page is also available as Markdown.

Aparté scripts

Reference of the Aparté ticket mapper script, extensions.aparte.ticket.mapper: registration, the MapFromAparte and GetPassType handlers and an example.

The Aparté connector turns each Aparté ticket into a pass. The ticket mapper script adjusts that work in two optional ways: it adds computed values to the data the pass template reads, and it chooses a pass type for a ticket. This page is the reference for extensions.aparte.ticket.mapper. The connector itself is described on the Aparté connector pages; the rules shared by every connector script are in Connector scripts.

The Aparté API is read-only for tickets, so the mapping goes one way, from the ticket to the pass.

Real-world examples
  • A venue sends tickets of the category "VIP" to a dedicated pass type and every other ticket to the connector's default pass type.

  • An organizer adds a computed label, such as the entrance and the seat in one string, to the data of the pass.

Registration

Key

Slot file

Methods (required in bold)

extensions.aparte.ticket.mapper

aparte.ticket.mapper.js

MapFromAparte, GetPassType

The file sits in server/scripts/. The slot sits in the Advanced tab of the Aparté connector settings, and is read and written with GET and PUT /api/{tenantId}/admin/extensions/aparte/scripts. When no script is registered, the default mapping applies and the connector's default pass type is used. Installation tracking is built into the connector and needs no script.

export default function (context) {
  context.register('extensions.aparte.ticket.mapper', {
    MapFromAparte: (ticket, entity) => {},
    GetPassType: async (ticket) => null
  });
}

When it runs

MapFromAparte runs when the connector fills the pass data from a ticket, after the default mapping. GetPassType runs when a ticket pass's metadata is updated and the ticket is read again: a non-empty name replaces the pass type and the change is logged. At creation, the connector's Default pass type is used and GetPassType is not called. When the ticket cannot be read and Invalid ticket pass type is set, the pass switches to that pass type instead.

Handlers

Both methods are optional: a method that is left out behaves as if it returned nothing.

Method
Parameters
Returns
Required
Sync or async

MapFromAparte

ticket, entity

nothing

Optional

Synchronous

GetPassType

ticket

a promise of a pass type name, or of null

Optional

Asynchronous: declare it async

  • ticket is the Aparté ticket. Its members are the PascalCase names of the Aparté ticket, for example CategoryLabel, DoorLabel, Rank and Seat. Its raw content is written on the pass data under debug.aparte.ticket, which shows the exact member names before writing the script.

  • entity is the pass data, a flat dictionary (see Data objects). MapFromAparte adds keys to it and the pass template reads them.

  • GetPassType returns the name of a pass type of the tenant, or null (or an empty string) to keep the current pass type.

Errors and edge cases

  • No script registered: the default mapping and the default pass type apply.

  • A method is missing: it is skipped, as both are optional.

  • GetPassType returns a name that is not a pass type of the tenant: the name is not checked and is set on the pass as is. Return only names of existing pass types.

  • MapFromAparte is declared async: it is not awaited, so changes made after an await are lost.

  • A script throws: the error is not caught. A throw in MapFromAparte fails the read of the ticket, and a throw in GetPassType fails the pass update.

Example

Tickets whose category label is VIP go to the pass type vip-ticket. The script also adds a display label made of the door and the seat.

Common pitfalls

  • GetPassType is not declared async: the connector awaits a promise, so return one.

  • A member name is typed from memory instead of being read in debug.aparte.ticket.

Last updated