@itm-studio/partner-sdk 0.6.0 → 0.6.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -628,6 +628,38 @@ reconciliation but is personal data; do not render it on public surfaces.
628
628
  Amounts are ITM cents (major units × 100, also for zero-decimal currencies) —
629
629
  see [Money Amounts](#money-amounts).
630
630
 
631
+ ### `getPartnerMerch`
632
+
633
+ List the brand's merch, newest first, with the UIDs you need to record a sale:
634
+ `merchSizes` for `merchSizeUid` and `merchPickupMoments` for `pickupMomentUid`.
635
+ `take` defaults to 50 and is capped at 100; follow `nextCursor` while
636
+ `hasNextPage` is true. Filter with `query`/`filters.search`, or
637
+ `filters.momentUid` for merch associated with a moment (including merch shown
638
+ or offered as an upsell there). That filter does not guarantee pickup eligibility:
639
+ choose `pickupMomentUid` from the item's `merchPickupMoments`. Requires a `token`
640
+ client. See [Record an off-platform merch purchase](#record-an-off-platform-merch-purchase).
641
+
642
+ ```typescript
643
+ const { getPartnerMerch } = await itm.query({
644
+ getPartnerMerch: {
645
+ __args: { input: { take: 50 } },
646
+ items: {
647
+ uid: true,
648
+ name: true,
649
+ price: true, // ITM cents
650
+ currency: { code: true },
651
+ fulfillmentType: true, // MOMENT, SHIPPING or MOMENT_OR_SHIPPING
652
+ fulfillmentPlatform: true, // EXTERNAL = Shopify fulfills; cannot be redeemed from ITM
653
+ checkoutPlatform: true, // only ITM merch can be recorded
654
+ merchSizes: { uid: true, name: true, isSoldOut: true },
655
+ merchPickupMoments: { uid: true, name: true, startDate: true },
656
+ },
657
+ hasNextPage: true,
658
+ nextCursor: true,
659
+ },
660
+ });
661
+ ```
662
+
631
663
  ### `getPartnerMoment`
632
664
 
633
665
  Get a single moment by slug.
@@ -769,6 +801,7 @@ const { getPartnerMomentStats } = await itm.query({
769
801
  waitlistCount: true,
770
802
  externalRsvpCount: true,
771
803
  ticketRsvpRequestsCount: true,
804
+ guestlist: { names: true, people: true, plusOnes: true, peopleCheckedIn: true },
772
805
  },
773
806
  });
774
807
  ```
@@ -819,8 +852,8 @@ const { getPartnerMomentAttendanceStats } = await itm.query({
819
852
  ```
820
853
 
821
854
  - `tickets` counts confirmed tickets, overall and per ticket tier.
822
- - `guestlist` counts guest-list entries, split into `unlabeled` and per-label
823
- buckets.
855
+ - `guestlist.total` counts people, including plus-ones; `checkedIn` counts admitted people.
856
+ Label buckets overlap: do not sum them to obtain the canonical total.
824
857
 
825
858
  > **Note:** Returns `null` if no moment matches the lookup or the moment is not
826
859
  > owned by the authenticated partner's brand. The request fails with a
@@ -828,6 +861,88 @@ const { getPartnerMomentAttendanceStats } = await itm.query({
828
861
  > `externalPlatform` and `externalId` are not provided together, when more than
829
862
  > one lookup key is given, or when an external ID matches multiple moments.
830
863
 
864
+ ### Moment guest lists and check-in history
865
+
866
+ Partner API keys can read the dedicated Guest List, separately from ticket holders.
867
+ These reads are live and brand-scoped; ITM agent credentials do not authorize them.
868
+ `getPartnerMomentStats.guestlist` provides cached totals: `names` (entries), `people`
869
+ (including plus-ones), `plusOnes`, `peopleCheckedIn`, `peopleRemaining`, and
870
+ `namesNotArrived` / `namesPartial` / `namesAllIn`. Overview counts may be five minutes old.
871
+
872
+ Both guest-list reads default to 50 results and accept `take` from 1 to 100. Pages
873
+ include `totalCount`, `hasNextPage`, and `nextCursor`. Pass the returned cursor to
874
+ continue with the same filters and sorting. Invalid/foreign cursors fail validation.
875
+ Pagination reads current data, not a frozen export; concurrent edits can change results.
876
+
877
+ ```typescript
878
+ function fetchGuestPage(cursor: string | null) {
879
+ return itm.query({
880
+ getPartnerGuestListForMoment: {
881
+ __args: { momentSlug: "my-event", take: 100, cursor },
882
+ totalCount: true,
883
+ hasNextPage: true,
884
+ nextCursor: true,
885
+ guestLists: {
886
+ uid: true, name: true, email: true, phoneNumber: true, notes: true,
887
+ numGuests: true, plusOnes: true, numCheckedIn: true,
888
+ checkedInAt: true, checkInStatus: true, source: true,
889
+ respondedToInvitation: true,
890
+ labels: { uid: true, name: true },
891
+ momentOccurrences: { uid: true, startsAt: true, endsAt: true },
892
+ invitationResponse: { guestNames: true },
893
+ guestInfos: {
894
+ guestIndex: true, fullName: true, companyName: true, jobTitle: true,
895
+ phoneNumber: true, birthday: true, invitedBy: true,
896
+ },
897
+ },
898
+ },
899
+ });
900
+ }
901
+ let cursor: string | null = null;
902
+ do {
903
+ const { getPartnerGuestListForMoment: page } = await fetchGuestPage(cursor);
904
+ for (const guest of page.guestLists) console.log(guest);
905
+ cursor = page.hasNextPage ? page.nextCursor : null;
906
+ } while (cursor);
907
+ ```
908
+
909
+ Optional `filters` support search, labels (`labelUid` / `labelUids`,
910
+ `includeUnlabeled`), `checkInStatus` (`NOT_ARRIVED`, `PARTIAL`, `ALL_IN`),
911
+ `checkedIn`, `hasPlusOnes`, `hasEmail`, `hasNotes`, `qrCodeSent`,
912
+ `addedByAdminUids`, `sessionDate`, and `momentOccurrenceUid`. Occurrence filters
913
+ also include guests assigned to the whole moment. Optional `sort` accepts
914
+ `CREATED_AT`, `NAME`, `PARTY_SIZE`, or `LAST_CHECKED_IN`, with `ASC` / `DESC`
915
+ direction. The default is newest-created first.
916
+
917
+ `numGuests` includes the invitee: a party of three has two `plusOnes`.
918
+ `checkedInAt` is the latest active party check-in, nullable when nobody is in.
919
+ Empty `momentOccurrences` means the whole moment. Profile answers and invitation
920
+ names are returned only when collected; missing values remain null or empty.
921
+ `guestIndex: 0` is the invitee; higher indexes are plus-ones. Guest profile fields
922
+ also include social handles/URLs, address, website, and submission timestamp.
923
+
924
+ Retrieve all recorded check-in actions with independent cursor pagination:
925
+
926
+ ```typescript
927
+ const { getPartnerGuestListCheckIns: page } = await itm.query({
928
+ getPartnerGuestListCheckIns: {
929
+ __args: { momentSlug: "my-event", guestlistUid: "guest-uid", take: 50 },
930
+ totalCount: true, hasNextPage: true, nextCursor: true,
931
+ batches: {
932
+ uid: true, checkedInAt: true, source: true,
933
+ count: true, activeCount: true, voidedAt: true, voidReason: true,
934
+ },
935
+ },
936
+ });
937
+ ```
938
+
939
+ Continue using `page.nextCursor` while `page.hasNextPage` is true. History includes
940
+ undone actions, is newest first, and is not truncated at 100 total actions.
941
+ `count` is the people admitted by an action; `activeCount` excludes undone admissions.
942
+ Admission slots do not identify named people, so a batch cannot establish which
943
+ named plus-one arrived. Legacy entries may have aggregate counts without ledger
944
+ history; these read operations never manufacture or backfill check-ins.
945
+
831
946
  ### `getPartnerTicketTiersForMoment`
832
947
 
833
948
  Get paginated, partner-facing ticket tiers for a moment. Use this for pricing,
@@ -1377,6 +1492,12 @@ const { respondToMomentLineup } = await itm.mutation({
1377
1492
 
1378
1493
  Admin-only lineup creation and ordering are not part of the partner-token SDK surface. Use backstage for managing lineup entries.
1379
1494
 
1495
+ ### `createPartnerMerchPurchase` / `redeemPartnerMerchPurchase`
1496
+
1497
+ Record a merch sale whose payment was collected outside ITM, and mark merch
1498
+ purchases redeemed (handed over). See
1499
+ [Record an off-platform merch purchase](#record-an-off-platform-merch-purchase).
1500
+
1380
1501
  ## Partner Brand Subscription Guide
1381
1502
 
1382
1503
  The partner brand subscription API supports two integration modes:
@@ -2716,6 +2837,212 @@ email or phone matches a current verified ITM identity; unmatched contacts do no
2716
2837
  create an account, and conflicting matches are rejected. `source` distinguishes
2717
2838
  `STRIPE`, `OFF_SITE`, and in-person `POS` independently of payment status.
2718
2839
 
2840
+ ### Record an off-platform merch purchase
2841
+
2842
+ When a brand sells ITM merch but takes the money elsewhere (its own POS, a card
2843
+ terminal, Venmo, a bank transfer), record the sale so it reaches the brand's ITM
2844
+ CRM: the customer's spend and product count, merch tags, and pickup attendance.
2845
+ This needs a partner `token` client; the backend derives brand scope from it.
2846
+ ITM moves no money and charges no fee for these sales. Run this integration on
2847
+ [your Node.js server](#authentication), using a partner API token rather than an
2848
+ agent session. The target backend must have
2849
+ [the partner merch API](https://github.com/itm-studio/itm-backend/pull/1174)
2850
+ deployed before using these operations; installing the SDK does not enable them
2851
+ on an older backend.
2852
+
2853
+ 1. Find the merch with `getPartnerMerch`.
2854
+ 2. Call `createPartnerMerchPurchase` once per merch line.
2855
+ 3. Call `redeemPartnerMerchPurchase` when the item is handed over, or pass
2856
+ `redeemed: true` on create when it is handed over at the time of sale.
2857
+
2858
+ ```ts
2859
+ const { createPartnerMerchPurchase } = await itm.mutation({
2860
+ createPartnerMerchPurchase: {
2861
+ __args: { input: {
2862
+ requestUid: `pos-${posOrderId}-line-${lineNumber}`, // 8-128 letters, digits, _ or -; retain across retries.
2863
+ merchUid,
2864
+ merchSizeUid,
2865
+ quantity: 2,
2866
+ amountCents: 7000, // Total collected, ITM cents (major units × 100, including JPY).
2867
+ currencyCode: 'USD', // Must match the merch currency.
2868
+ paymentMethod: 'CARD',
2869
+ paymentProvider: 'Square POS',
2870
+ externalPaymentReference: squarePaymentId,
2871
+ customer: { email: 'buyer@example.com', phoneNumber: '+14155550123', name: 'Alex Rivera' },
2872
+ pickupMomentUid, // Required for pickup fulfillment.
2873
+ redeemed: true, // Handed over at the counter.
2874
+ } },
2875
+ uid: true,
2876
+ userUid: true, // The customer's ITM user uid
2877
+ source: true, // PARTNER
2878
+ state: true, // SUCCESS
2879
+ redeemedAt: true,
2880
+ },
2881
+ });
2882
+ ```
2883
+
2884
+ Persist the returned `uid` alongside your external order line so it can be
2885
+ redeemed later. Each line is a separate request and can succeed or fail
2886
+ independently; recording a multi-line order is not atomic.
2887
+
2888
+ The response is a `PartnerMerchPurchase`: the purchase with related records
2889
+ (`merchUid`, `merchSizeUid`, `userUid`, `pickupMomentUid`) as uids. It never
2890
+ exposes the customer's ITM account details. `userUid` is null when redeeming a
2891
+ box-office walk-up purchase that has no customer.
2892
+
2893
+ `paymentMethod` records how the customer paid. It is required when
2894
+ `amountCents` is above 0 and must be omitted for a free purchase:
2895
+
2896
+ | Value | Use for |
2897
+ | --- | --- |
2898
+ | `CASH` | Physical currency |
2899
+ | `CARD` | A card taken on a non-ITM terminal or processor (Square, SumUp, Clover…), including Apple Pay or Google Pay tapped on that terminal |
2900
+ | `DIGITAL_WALLET` | Venmo, Cash App, PayPal, Zelle and similar apps |
2901
+ | `BANK_TRANSFER` | ACH, wire or bank deposit |
2902
+ | `CHECK` | Check or money order |
2903
+ | `OTHER` | Anything else, such as a third-party gift card, store credit or crypto |
2904
+
2905
+ Use `paymentProvider` (who took the money) and `externalPaymentReference` (that
2906
+ system's transaction or order ID, up to 255 characters each) so the sale can be
2907
+ reconciled; both appear in the brand's merch exports. They need a
2908
+ `paymentMethod`.
2909
+
2910
+ Behavior:
2911
+
2912
+ - **Retries.** A retry with the same `requestUid` returns the original purchase
2913
+ without counting the sale twice. Within 7 days of the sale, a retry of a sale
2914
+ that hasn't been cancelled also finishes any CRM, loyalty or Shopify
2915
+ processing that a failed attempt didn't queue. A `sendConfirmation` message is
2916
+ only sent by the attempt that recorded the sale. Reusing a `requestUid` with different
2917
+ details is rejected. `requestUid` is the idempotency key for this request, so
2918
+ keep it separate from `externalPaymentReference` when one payment covers
2919
+ several merch lines. Keys are scoped to the token's brand. Keep the original
2920
+ input, including `redeemed` and `sendConfirmation`, unchanged on a retry;
2921
+ redeem later with the separate mutation. The purchase stays deduplicated after
2922
+ 7 days, but retries no longer recover its create follow-ups.
2923
+ - **Customers.** The customer is matched to an existing ITM account by phone
2924
+ number or email, preferring verified login identities. ITM never adds the
2925
+ entered contact details or address to an existing account. When nobody
2926
+ matches, a customer is created from the phone number, or from the email when
2927
+ no phone number is given. The entered name, email and phone are kept with the
2928
+ purchase. Supply at least one of `customer.email` or `customer.phoneNumber`;
2929
+ a name alone is insufficient. Phone numbers need a leading `+` and country
2930
+ code. Conflicting verified identity matches are rejected; when neither contact
2931
+ has a verified match, conflicting on-file matches are also rejected. A verified
2932
+ match takes precedence over an unverified on-file contact. The customer joins
2933
+ the brand's contacts without a marketing subscription.
2934
+ - **Fulfillment.** Pickup merch needs `pickupMomentUid` (one of the merch's
2935
+ `merchPickupMoments`). Shipped merch needs `shippingAddress`. Merch offered as
2936
+ either needs `fulfillmentChoice`. Shopify-fulfilled merch
2937
+ (`fulfillmentPlatform: EXTERNAL`) creates its Shopify order as usual and
2938
+ cannot be redeemed from ITM.
2939
+ - **Inventory.** The sale counts against the size's supply and the merch's
2940
+ per-customer limit. A sale is rejected when either is used up, so raise the
2941
+ supply in ITM before recording sales it does not cover.
2942
+ - **Notifications.** ITM sends nothing by default. Set `sendConfirmation: true`
2943
+ to send ITM's SMS or email confirmation, which includes the pickup QR code.
2944
+ - **Corrections.** Payment details cannot be edited. A mistaken sale can be
2945
+ cancelled from the ITM dashboard: it is restocked with no money movement and
2946
+ the customer is emailed a cancellation. Cancelling does not reduce the
2947
+ customer's lifetime spend in the brand's CRM.
2948
+
2949
+ ```ts
2950
+ const { redeemPartnerMerchPurchase } = await itm.mutation({
2951
+ redeemPartnerMerchPurchase: {
2952
+ __args: { merchPurchaseUid },
2953
+ uid: true,
2954
+ redeemedAt: true,
2955
+ },
2956
+ });
2957
+ ```
2958
+
2959
+ Redeeming an already redeemed purchase returns it unchanged, so redeem calls are
2960
+ safe to retry while the purchase remains eligible. The purchase must belong to
2961
+ the token's brand, be in `SUCCESS` state, and use ITM fulfillment. Redemption
2962
+ marks the entire purchase quantity handed over; partial redemption is not
2963
+ supported. This operation can redeem eligible purchases from other sources too.
2964
+ For `source: PARTNER` purchases only, a retry within 7 days of redemption also
2965
+ finishes any loyalty or Shopify processing that the redeeming attempt didn't
2966
+ queue.
2967
+
2968
+ #### Shipping and free purchases
2969
+
2970
+ For `MOMENT` merch, pass a linked `pickupMomentUid`. For `SHIPPING` merch, pass
2971
+ `shippingAddress`. For `MOMENT_OR_SHIPPING`, also choose `PICKUP` or `SHIPPING`
2972
+ explicitly in `fulfillmentChoice`. Omit `shippingAddress` for pickup purchases;
2973
+ the backend rejects it. A shipping address is saved with the purchase, not in
2974
+ the customer's address book.
2975
+
2976
+ For example, record a shipped purchase from merch that supports shipping:
2977
+
2978
+ ```ts
2979
+ import type { CreatePartnerMerchPurchaseInput } from '@itm-studio/partner-sdk';
2980
+
2981
+ const shippingInput: CreatePartnerMerchPurchaseInput = {
2982
+ requestUid: 'pos-order-1043-line-1', // Persist once per order line.
2983
+ merchUid,
2984
+ merchSizeUid,
2985
+ quantity: 1,
2986
+ amountCents: 3500,
2987
+ currencyCode: 'USD',
2988
+ paymentMethod: 'CARD',
2989
+ customer: { email: 'buyer@example.com' },
2990
+ fulfillmentChoice: 'SHIPPING',
2991
+ shippingAddress: {
2992
+ name: 'Alex Rivera',
2993
+ phoneNumber: '+14155550123',
2994
+ addressLine1: '123 Main Street',
2995
+ city: 'San Francisco',
2996
+ state: 'CA',
2997
+ country: 'US',
2998
+ postalCode: '94105',
2999
+ },
3000
+ };
3001
+
3002
+ const shipped = await itm.mutation({
3003
+ createPartnerMerchPurchase: {
3004
+ __args: { input: shippingInput },
3005
+ uid: true,
3006
+ fulfillmentChoice: true,
3007
+ },
3008
+ });
3009
+ ```
3010
+
3011
+ For a free purchase, set `amountCents: 0` and omit `paymentMethod`,
3012
+ `paymentProvider`, and `externalPaymentReference`. Customer, currency, inventory,
3013
+ and fulfillment requirements still apply. The CRM product count tracks paid
3014
+ purchase lines, not individual units; free purchases do not increment that count.
3015
+
3016
+ `quantity` must be a positive integer; `amountCents` must be a non-negative
3017
+ integer representing the **total for the line**, not the unit price. These are
3018
+ [ITM cents](#money-amounts), even for zero-decimal currencies: JPY 1,000 is
3019
+ `100000`, and JPY amounts must be multiples of 100. For Shopify fulfillment,
3020
+ the total must also divide into an exact per-item price in that currency.
3021
+ `customer.name` is limited to 200 characters, `notes` to 500, and each shipping
3022
+ address field to 255. All shipping fields shown above are required;
3023
+ `addressLine2` is optional.
3024
+
3025
+ #### Failures and retries
3026
+
3027
+ The SDK surfaces GraphQL errors as `GenqlError`; network failures can throw
3028
+ other errors. An error does not necessarily mean nothing was saved: the sale
3029
+ may have committed before CRM or fulfillment work failed to queue. For a
3030
+ timeout or transient failure, retry with backoff and the **same requestUid and
3031
+ original input**, never a fresh key. Keep failures in your reconciliation queue
3032
+ until resolved. A successful response confirms recording, not completion of
3033
+ asynchronous CRM or Shopify processing.
3034
+
3035
+ Validation failures need attention before retrying: check inventory and
3036
+ per-customer limits, customer contacts, currency, fulfillment fields, and token
3037
+ brand scope. A `requestUid has different purchase details` error means the key
3038
+ already belongs to another payload; reconcile the original sale before creating
3039
+ a replacement. Retrying a cancelled purchase returns its current state and does
3040
+ not restore it. Confirmations are not replayed, so a failed first attempt can
3041
+ leave a recorded sale without an ITM confirmation.
3042
+
3043
+ If GraphQL reports `Cannot query field` for one of these operations, check that
3044
+ the API URL points to a backend with the partner merch API deployed.
3045
+
2719
3046
  ### Delegated integration credentials (MCP)
2720
3047
 
2721
3048
  The integration authentication mode accepts a backend-issued, short-lived **API** credential. It sends `x-itm-integration-access-token`; external MCP access tokens cannot authenticate to the business API.