@itm-studio/partner-sdk 0.6.3 → 0.6.5
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 +247 -3
- package/dist/index.d.mts +361 -1
- package/dist/index.d.ts +361 -1
- package/dist/index.js +770 -308
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +770 -308
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/schema/partner.graphql +219 -0
package/README.md
CHANGED
|
@@ -1394,6 +1394,126 @@ amount. These are ITM prices, not Stripe minor-unit amounts.
|
|
|
1394
1394
|
`activeMemberCount` counts ACTIVE and PAST_DUE membership rows, excluding deleted
|
|
1395
1395
|
users; it is not a count of distinct people.
|
|
1396
1396
|
|
|
1397
|
+
#### Render a public membership grid and enroll in a selected level
|
|
1398
|
+
|
|
1399
|
+
Fetch the catalog on your server with `isActive: true` and `isPublic: true`.
|
|
1400
|
+
Do not expose the partner token in browser code. Use `name` as the membership
|
|
1401
|
+
card title, and preserve each tier's `slug` for its Join action. Continue through
|
|
1402
|
+
all pages; a single request does not necessarily return the entire catalog.
|
|
1403
|
+
|
|
1404
|
+
```typescript
|
|
1405
|
+
import type { GetPartnerMembershipTiersInput } from "@itm-studio/partner-sdk";
|
|
1406
|
+
|
|
1407
|
+
const { getPartnerBrand: brand } = await itm.query({
|
|
1408
|
+
getPartnerBrand: { publicUrl: true },
|
|
1409
|
+
});
|
|
1410
|
+
let cursor: string | null = null;
|
|
1411
|
+
do {
|
|
1412
|
+
const input: GetPartnerMembershipTiersInput = {
|
|
1413
|
+
isActive: true, isPublic: true, take: 100, cursor,
|
|
1414
|
+
};
|
|
1415
|
+
const { getPartnerMembershipTiers: page } = await itm.query({
|
|
1416
|
+
getPartnerMembershipTiers: {
|
|
1417
|
+
__args: { input },
|
|
1418
|
+
membershipTiers: {
|
|
1419
|
+
uid: true, slug: true, name: true, description: true, benefits: true,
|
|
1420
|
+
coverImage: {
|
|
1421
|
+
url: true, mimeType: true, dimensions: { width: true, height: true },
|
|
1422
|
+
transforms: { original: true, small: true, medium: true, large: true },
|
|
1423
|
+
},
|
|
1424
|
+
currencyCode: true, price: true, yearlyPrice: true, oneTimePrice: true,
|
|
1425
|
+
passType: true, billingInterval: true, trialDays: true,
|
|
1426
|
+
expiryType: true, durationDays: true, fixedEndDate: true, totalUses: true,
|
|
1427
|
+
memberLimit: true, supplyCap: true, activeMemberCount: true,
|
|
1428
|
+
sortOrder: true, finePrint: true,
|
|
1429
|
+
payWhatYouWantMaxPrice: true, payWhatYouWantSuggestedPrice: true,
|
|
1430
|
+
payWhatYouWantMessage: true,
|
|
1431
|
+
},
|
|
1432
|
+
hasNextPage: true, nextCursor: true,
|
|
1433
|
+
},
|
|
1434
|
+
});
|
|
1435
|
+
const cards = page.membershipTiers.map(tier => ({
|
|
1436
|
+
...tier,
|
|
1437
|
+
enrollmentUrl: new URL(
|
|
1438
|
+
`/passes/${encodeURIComponent(tier.slug)}/embed/modal`, brand.publicUrl,
|
|
1439
|
+
).href,
|
|
1440
|
+
}));
|
|
1441
|
+
// Return cards to your frontend and append them in the received order.
|
|
1442
|
+
// On Join, open that card's enrollmentUrl in your enrollment iframe/modal.
|
|
1443
|
+
if (!page.hasNextPage) break;
|
|
1444
|
+
if (!page.nextCursor || page.nextCursor === cursor) {
|
|
1445
|
+
throw new Error("Missing or repeated membership tier cursor");
|
|
1446
|
+
}
|
|
1447
|
+
cursor = page.nextCursor;
|
|
1448
|
+
} while (true);
|
|
1449
|
+
```
|
|
1450
|
+
|
|
1451
|
+
The selected pass is part of the URL path: use its **slug**, not its UID or
|
|
1452
|
+
`name`. The ITM enrollment widget loads that level's current checkout rules and
|
|
1453
|
+
pricing, including any eligibility requirements. A public/active listing is not
|
|
1454
|
+
a guarantee of checkout availability. Use `/passes/{slug}/embed/inline` for an
|
|
1455
|
+
inline iframe, or `/passes/{slug}` for a normal page. For the ITM button and
|
|
1456
|
+
parent modal event handling, copy the pass embed from Backstage's Embed page.
|
|
1457
|
+
Allow `payment` on the enrollment iframe.
|
|
1458
|
+
|
|
1459
|
+
`RECURRING` and `RECURRING_OR_ONE_TIME` passes use `billingInterval` to describe
|
|
1460
|
+
recurring choices: `MONTHLY`, `YEARLY`, or `MONTHLY_OR_YEARLY`. For the latter,
|
|
1461
|
+
`price` is the monthly amount and `yearlyPrice` is the annual amount. For
|
|
1462
|
+
`YEARLY`, `price` is the annual amount. A `ONE_TIME` pass uses `price`;
|
|
1463
|
+
`RECURRING_OR_ONE_TIME` also offers `oneTimePrice`. If `yearlyPrice` or
|
|
1464
|
+
`oneTimePrice` is null, checkout falls back to `price`; use `??` so zero-priced
|
|
1465
|
+
options remain free. Display `trialDays` and the
|
|
1466
|
+
expiry/use limits when present. Do not infer a recurring interval for a one-time
|
|
1467
|
+
pass. Optional contribution amounts use the same x100 display units as tier
|
|
1468
|
+
prices and are **added to** the base price. Artwork, fine print, and optional
|
|
1469
|
+
contribution settings can be null.
|
|
1470
|
+
|
|
1471
|
+
The new `coverImage`, `finePrint`, and `payWhatYouWant*` selections require the
|
|
1472
|
+
matching backend contract to be deployed before an SDK release selects them.
|
|
1473
|
+
|
|
1474
|
+
#### Fetch a moment's photo gallery
|
|
1475
|
+
|
|
1476
|
+
`getMomentGalleryPhotos` reads the photos attached to a moment, separate from
|
|
1477
|
+
`Moment.coverImage`. These are the same `MomentMedia` photos uploaded, removed,
|
|
1478
|
+
and reordered through Backstage's `MomentGallery` on the moment page. Pass the
|
|
1479
|
+
moment **UID** returned by `getPartnerMoment` or
|
|
1480
|
+
`getPartnerMomentsForBrand`. This is an existing public read operation; it does
|
|
1481
|
+
not grant gallery editing access or change visibility rules. The default page
|
|
1482
|
+
size is 20, capped at 50. Results follow the configured gallery order; append
|
|
1483
|
+
pages in the order returned rather than sorting fractional `sortOrder` strings
|
|
1484
|
+
with locale-aware sorting.
|
|
1485
|
+
|
|
1486
|
+
```typescript
|
|
1487
|
+
let photoCursor: string | null = null;
|
|
1488
|
+
do {
|
|
1489
|
+
const photoArgs: { momentUid: string; take: number; cursor: string | null } = {
|
|
1490
|
+
momentUid: "moment-uid", take: 50, cursor: photoCursor,
|
|
1491
|
+
};
|
|
1492
|
+
const { getMomentGalleryPhotos: page } = await itm.query({
|
|
1493
|
+
getMomentGalleryPhotos: {
|
|
1494
|
+
__args: photoArgs,
|
|
1495
|
+
momentMedia: {
|
|
1496
|
+
uid: true, sortOrder: true,
|
|
1497
|
+
mediaAsset: {
|
|
1498
|
+
uid: true, url: true, mimeType: true,
|
|
1499
|
+
dimensions: { width: true, height: true },
|
|
1500
|
+
placeholderUrl: true, blurhash: true,
|
|
1501
|
+
transforms: { original: true, small: true, medium: true, large: true },
|
|
1502
|
+
},
|
|
1503
|
+
},
|
|
1504
|
+
totalCount: true, hasNextPage: true, nextCursor: true,
|
|
1505
|
+
},
|
|
1506
|
+
});
|
|
1507
|
+
// Render each entry.mediaAsset; use transforms?.medium ?? url for a thumbnail.
|
|
1508
|
+
// Empty galleries return momentMedia: [] and hasNextPage: false.
|
|
1509
|
+
if (!page.hasNextPage) break;
|
|
1510
|
+
if (!page.nextCursor || page.nextCursor === photoCursor) {
|
|
1511
|
+
throw new Error("Missing or repeated moment photo cursor");
|
|
1512
|
+
}
|
|
1513
|
+
photoCursor = page.nextCursor;
|
|
1514
|
+
} while (true);
|
|
1515
|
+
```
|
|
1516
|
+
|
|
1397
1517
|
#### `getPartnerMembers`: fetch brand-wide or selected tiers
|
|
1398
1518
|
|
|
1399
1519
|
Each `members` row represents one membership, identified by its `uid`, with
|
|
@@ -1454,10 +1574,134 @@ guarantee: changes during a walk, especially tier reordering, can omit or repeat
|
|
|
1454
1574
|
rows. `remainingUses: null` means unlimited; a null `currentPeriodEnd` alone does
|
|
1455
1575
|
not establish whether a membership has no expiry.
|
|
1456
1576
|
|
|
1457
|
-
The
|
|
1577
|
+
The membership responses expose the allowlisted customer, membership, and tier
|
|
1458
1578
|
fields, excluding QR tokens, Stripe/payment identifiers, guest information, and
|
|
1459
|
-
form responses.
|
|
1460
|
-
|
|
1579
|
+
embedded form responses. Use `signupFormResponseUid` with the form response reads
|
|
1580
|
+
below to retrieve exact signup answers. Both membership endpoints are limited to
|
|
1581
|
+
120 requests per minute per partner token.
|
|
1582
|
+
|
|
1583
|
+
### Forms, responses, and membership signup answers
|
|
1584
|
+
|
|
1585
|
+
These reads require a **partner API token** and run on your Node.js server.
|
|
1586
|
+
The authenticated token selects the brand; none accepts a brand ID. Agent
|
|
1587
|
+
credentials do not grant access to these operations. Keep tokens and returned
|
|
1588
|
+
customer answers out of browser bundles and application logs.
|
|
1589
|
+
|
|
1590
|
+
| Operation | Result and filters |
|
|
1591
|
+
| --- | --- |
|
|
1592
|
+
| `getPartnerForms(input?)` | Paginated `forms`. Filter by `sources` (`MANUAL`, `AUTO`, `AGENT`), `isActive`, and case-insensitive name `search`. Set `includeArchived: true` to include archived forms. Private and inactive forms are included by default. |
|
|
1593
|
+
| `getPartnerForm(uid)` | One brand-owned form, including an archived form. Foreign and nonexistent UIDs both return `Form not found`. |
|
|
1594
|
+
| `getPartnerFormResponses(input?)` | Paginated `formResponses` across the brand. Filter by `formUids`, `customerUids`, `responseUids`, `createdAtFrom`, and `createdAtBefore`. Historical responses on archived forms are included; responses belonging to deleted users are excluded. |
|
|
1595
|
+
|
|
1596
|
+
Forms include metadata, labels, display mode, success messages, scoring settings,
|
|
1597
|
+
FAQs, ordered sections, and current questions. Questions include their UID,
|
|
1598
|
+
label, type, required flag, defaults, validation rules, options, choice images,
|
|
1599
|
+
and `sectionUid`. Form fields exclude archived questions; a response's answers
|
|
1600
|
+
retain their archived question definitions so old answers remain readable.
|
|
1601
|
+
|
|
1602
|
+
```typescript
|
|
1603
|
+
const { getPartnerForms: page } = await itm.query({
|
|
1604
|
+
getPartnerForms: {
|
|
1605
|
+
__args: { input: { take: 100, includeArchived: true } },
|
|
1606
|
+
forms: {
|
|
1607
|
+
uid: true, name: true, slug: true, description: true,
|
|
1608
|
+
isActive: true, isPublic: true, deletedAt: true,
|
|
1609
|
+
mode: true, source: true, responsesCount: true,
|
|
1610
|
+
sections: { uid: true, title: true, description: true, sortOrder: true },
|
|
1611
|
+
fields: {
|
|
1612
|
+
uid: true, label: true, subLabel: true, type: true,
|
|
1613
|
+
isRequired: true, placeholder: true, defaultValue: true,
|
|
1614
|
+
validationSchema: true, options: true, sortOrder: true, sectionUid: true,
|
|
1615
|
+
optionImages: { option: true, image: { uid: true, url: true } },
|
|
1616
|
+
},
|
|
1617
|
+
faqs: { uid: true, question: true, answer: true, sortOrder: true },
|
|
1618
|
+
},
|
|
1619
|
+
totalCount: true, hasNextPage: true, nextCursor: true,
|
|
1620
|
+
},
|
|
1621
|
+
});
|
|
1622
|
+
// Follow page.nextCursor while page.hasNextPage, preserving the filters.
|
|
1623
|
+
// Use getPartnerForm: { __args: { uid: "form-uid" }, ... } for one form.
|
|
1624
|
+
```
|
|
1625
|
+
|
|
1626
|
+
Responses include raw `responseData`, `extraData`, submission/update timestamps,
|
|
1627
|
+
`contextType`, relevance scores/details, the original form, customer contact
|
|
1628
|
+
details, and `formFieldResponses`. Each answer includes its value, typed value
|
|
1629
|
+
columns, validation result, and current question definition. JSON values preserve
|
|
1630
|
+
`null`, `false`, `0`, arrays, and structured upload/signature/address values.
|
|
1631
|
+
Question definitions reflect current stored metadata, not an immutable snapshot
|
|
1632
|
+
of the wording at submission time. Internal numeric context IDs, the unrestricted
|
|
1633
|
+
user profile, and device/location compliance records are not exposed.
|
|
1634
|
+
|
|
1635
|
+
`customer.uid` is the same UID used by `getPartnerMembers.customer.uid` and
|
|
1636
|
+
`getPartnerAudience.uid`. Batch up to 100 distinct customer UIDs to retrieve
|
|
1637
|
+
their responses without issuing one request per person:
|
|
1638
|
+
|
|
1639
|
+
```typescript
|
|
1640
|
+
import type { GetPartnerFormResponsesInput } from "@itm-studio/partner-sdk";
|
|
1641
|
+
|
|
1642
|
+
async function* responsesForCustomers(customerUids: string[]) {
|
|
1643
|
+
if (customerUids.length === 0) return;
|
|
1644
|
+
let cursor: string | null = null;
|
|
1645
|
+
const seenCursors = new Set<string>();
|
|
1646
|
+
do {
|
|
1647
|
+
const input: GetPartnerFormResponsesInput = { customerUids, take: 100, cursor };
|
|
1648
|
+
const { getPartnerFormResponses: page } = await itm.query({
|
|
1649
|
+
getPartnerFormResponses: {
|
|
1650
|
+
__args: { input },
|
|
1651
|
+
formResponses: {
|
|
1652
|
+
uid: true, responseData: true, extraData: true, contextType: true,
|
|
1653
|
+
createdAt: true, updatedAt: true, relevancyScore: true,
|
|
1654
|
+
customer: { uid: true, name: true, email: true, emailVerified: true, phoneNumber: true },
|
|
1655
|
+
form: { uid: true, slug: true, name: true, deletedAt: true },
|
|
1656
|
+
formFieldResponses: {
|
|
1657
|
+
uid: true, value: true, valueString: true, valueNumber: true,
|
|
1658
|
+
valueBoolean: true, valueDate: true, valueArray: true,
|
|
1659
|
+
isValid: true, validationError: true,
|
|
1660
|
+
formField: { uid: true, label: true, type: true, options: true, sectionUid: true, deletedAt: true },
|
|
1661
|
+
},
|
|
1662
|
+
},
|
|
1663
|
+
totalCount: true, hasNextPage: true, nextCursor: true,
|
|
1664
|
+
},
|
|
1665
|
+
});
|
|
1666
|
+
yield* page.formResponses;
|
|
1667
|
+
if (!page.hasNextPage) break;
|
|
1668
|
+
if (!page.nextCursor || seenCursors.has(page.nextCursor)) {
|
|
1669
|
+
throw new Error("Missing or repeated form response cursor");
|
|
1670
|
+
}
|
|
1671
|
+
cursor = page.nextCursor;
|
|
1672
|
+
seenCursors.add(cursor);
|
|
1673
|
+
} while (true);
|
|
1674
|
+
}
|
|
1675
|
+
```
|
|
1676
|
+
|
|
1677
|
+
For an **exact membership signup**, select `signupFormResponseUid` on
|
|
1678
|
+
`getPartnerMembers.members` and pass the non-null values to the response query's
|
|
1679
|
+
`responseUids` filter. The link remains attached to the original signup response
|
|
1680
|
+
even if a tier's form changes. A tier's `signupFormUid` identifies its currently
|
|
1681
|
+
configured form and can be passed to `getPartnerForm`. Null links mean no linked
|
|
1682
|
+
response/form; do not substitute another response from the same customer.
|
|
1683
|
+
|
|
1684
|
+
Both listings return `totalCount`, `hasNextPage`, and `nextCursor`. Page size
|
|
1685
|
+
defaults to 50 and is capped at 100; nonpositive page sizes fail. Results are
|
|
1686
|
+
ordered newest first, with a stable tie-break for identical creation timestamps.
|
|
1687
|
+
UID filters accept at most 100 distinct values after trimming and deduplication;
|
|
1688
|
+
omitted, null, or empty lists mean no filter. Filters combine with AND, and values
|
|
1689
|
+
inside one UID list combine with OR. Date `From` bounds are inclusive and `Before`
|
|
1690
|
+
bounds exclusive. Form name search is limited to 100 characters.
|
|
1691
|
+
|
|
1692
|
+
Keep filters identical when following cursors. Foreign or nonexistent form UIDs
|
|
1693
|
+
fail uniformly; foreign customer/response UIDs match no rows. Invalid/foreign
|
|
1694
|
+
cursors fail, and response cursors must still match the filters. Pagination reads
|
|
1695
|
+
live data, not a cross-request snapshot: concurrent writes can change counts or
|
|
1696
|
+
visibility. `responsesCount` is form-wide; use the response page's `totalCount`
|
|
1697
|
+
for a filtered count. Each operation is limited to 120 requests/minute per token;
|
|
1698
|
+
handle GraphQL errors and back off on rate limits using the client's existing
|
|
1699
|
+
transport error handling.
|
|
1700
|
+
|
|
1701
|
+
**Deployment:** deploy the backend contract before releasing an SDK that selects
|
|
1702
|
+
these operations or the new membership fields. Existing membership selections
|
|
1703
|
+
continue to work without requesting the additions. Backstage and Reader operations
|
|
1704
|
+
do not need changes or codegen for this additive partner API contract.
|
|
1461
1705
|
|
|
1462
1706
|
### `getPartnerMomentCollection`
|
|
1463
1707
|
|