@itm-studio/partner-sdk 0.6.5 → 0.6.7
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 +144 -62
- package/dist/index.d.mts +192 -13
- package/dist/index.d.ts +192 -13
- package/dist/index.js +416 -175
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +394 -176
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/schema/partner.graphql +70 -6
package/README.md
CHANGED
|
@@ -384,6 +384,29 @@ const { getPartnerBrand } = await itm.query({
|
|
|
384
384
|
domain is verified.
|
|
385
385
|
- `bio`, `spotifyUrl`, and `youtubeEmbedUrl` are `null` when unset.
|
|
386
386
|
|
|
387
|
+
### Public page URLs (`publicUrl`)
|
|
388
|
+
|
|
389
|
+
Every asset with a hosted page on ITM carries a `publicUrl`, so you never have
|
|
390
|
+
to assemble links from slugs. Select it on the create mutation to get the link
|
|
391
|
+
in the same call, or on any later read.
|
|
392
|
+
|
|
393
|
+
| Type | Page | Returned by |
|
|
394
|
+
| --- | --- | --- |
|
|
395
|
+
| `Moment` | `/m/{slug}` | `createPartnerMoment`, `getPartnerMoment`, `getPartnerMomentsForBrand` |
|
|
396
|
+
| `BrandDrop` | `/d/{slug}` | `createPartnerBrandDrop`, `getPartnerDrops` |
|
|
397
|
+
| `Echo` | `/echo/{slug}` | `getPartnerPublicEchoes` |
|
|
398
|
+
| `PartnerMembershipTier` | `/passes/{slug}` | `getPartnerMembershipTiers` |
|
|
399
|
+
| `Merch` | `/p/{slug}` | `getPartnerMerch` |
|
|
400
|
+
| `Form` | `/f/{slug}` | `getPartnerForm`, `getPartnerForms` |
|
|
401
|
+
|
|
402
|
+
- `publicUrl` is always returned, including for assets that are not public,
|
|
403
|
+
not active, or not yet published. It is the canonical address of the page,
|
|
404
|
+
not a promise that a visitor can use it: check the type's own state fields
|
|
405
|
+
(`isPublic`, `isActive`, `isPrivate`, `status`, `isLive`, `publishTime`)
|
|
406
|
+
before sharing a link.
|
|
407
|
+
- URLs use the brand's ITM subdomain (the same origin as
|
|
408
|
+
`getPartnerBrand.publicUrl`), not its custom domain.
|
|
409
|
+
|
|
387
410
|
### `getPartnerMomentsForBrand`
|
|
388
411
|
|
|
389
412
|
Get paginated moments (events) for your brand.
|
|
@@ -2120,6 +2143,7 @@ const { createPartnerBrandDrop: drop } = await itm.mutation({
|
|
|
2120
2143
|
},
|
|
2121
2144
|
uid: true,
|
|
2122
2145
|
slug: true,
|
|
2146
|
+
publicUrl: true, // hosted signup page, e.g. https://your-brand.itm.studio/d/join-our-community
|
|
2123
2147
|
},
|
|
2124
2148
|
});
|
|
2125
2149
|
|
|
@@ -2145,9 +2169,9 @@ const { createPartnerBrandSubscription: signup } = await itm.mutation({
|
|
|
2145
2169
|
// signup.verificationRequired === false; no OTP or user login step is required.
|
|
2146
2170
|
```
|
|
2147
2171
|
|
|
2148
|
-
- `createPartnerBrandDrop` supports `ctaType: 'SUBSCRIBE'`. Upload
|
|
2149
|
-
|
|
2150
|
-
|
|
2172
|
+
- `createPartnerBrandDrop` supports `ctaType: 'SUBSCRIBE'`. Upload an image
|
|
2173
|
+
with `uploadPartnerMedia`, or select an existing image with
|
|
2174
|
+
`getPartnerMediaAssets`. Both cover images must be active
|
|
2151
2175
|
assets owned by this brand. Save the returned drop UID and reuse it for signups;
|
|
2152
2176
|
retrying drop creation creates another drop.
|
|
2153
2177
|
- `dropUid` is optional. Supplying it creates both the brand subscription and the
|
|
@@ -2381,50 +2405,129 @@ export async function finishOtpSubscription(
|
|
|
2381
2405
|
|
|
2382
2406
|
### Media Upload Flow
|
|
2383
2407
|
|
|
2384
|
-
|
|
2408
|
+
Uploads go straight from your server to storage; the file never passes through
|
|
2409
|
+
the ITM API. `uploadPartnerMedia` runs the whole flow and returns the asset:
|
|
2385
2410
|
|
|
2386
|
-
|
|
2411
|
+
```typescript
|
|
2412
|
+
import {
|
|
2413
|
+
createITMPartnerClient,
|
|
2414
|
+
uploadPartnerMedia,
|
|
2415
|
+
} from "@itm-studio/partner-sdk";
|
|
2387
2416
|
|
|
2388
|
-
|
|
2417
|
+
const itm = createITMPartnerClient({ token: process.env.ITM_PARTNER_TOKEN! });
|
|
2389
2418
|
|
|
2390
|
-
|
|
2391
|
-
const
|
|
2392
|
-
getPartnerUploadUrl: {
|
|
2393
|
-
__args: { filename: "event-cover", fileExtension: "jpg" },
|
|
2394
|
-
url: true,
|
|
2395
|
-
filename: true,
|
|
2396
|
-
},
|
|
2397
|
-
});
|
|
2419
|
+
// From a file on disk (streamed on Node 20+)
|
|
2420
|
+
const asset = await uploadPartnerMedia(itm, { path: "./event-cover.jpg" });
|
|
2398
2421
|
|
|
2399
|
-
//
|
|
2400
|
-
await
|
|
2401
|
-
|
|
2402
|
-
|
|
2403
|
-
|
|
2404
|
-
});
|
|
2422
|
+
// Or from bytes you already hold: a Buffer, Uint8Array, ArrayBuffer or Blob
|
|
2423
|
+
const fromBytes = await uploadPartnerMedia(itm, { data: fileBuffer });
|
|
2424
|
+
|
|
2425
|
+
// asset.uid is the coverImageUid for createPartnerMoment
|
|
2426
|
+
console.log(asset.uid, asset.url, asset.dimensions);
|
|
2405
2427
|
```
|
|
2406
2428
|
|
|
2407
|
-
|
|
2429
|
+
It returns `uid`, `url`, `mimeType`, `size`, `dimensions` and `createdAt`.
|
|
2408
2430
|
|
|
2409
|
-
|
|
2431
|
+
| Kind | Types | Largest file |
|
|
2432
|
+
| ----- | --------------------------------------------------------------------------------- | ------------ |
|
|
2433
|
+
| Image | `image/jpeg`, `image/png`, `image/gif`, `image/webp`, `image/avif` | 25 MB |
|
|
2434
|
+
| Audio | `audio/mpeg`, `audio/mp4`, `audio/wav`, `audio/flac`, `audio/ogg`, `audio/webm` | 250 MB |
|
|
2435
|
+
| Video | `video/mp4`, `video/quicktime`, `video/webm` | 1 GB |
|
|
2436
|
+
|
|
2437
|
+
- **Type.** The helper reads the type from the file's first bytes, so you do not
|
|
2438
|
+
have to pass one. If you pass `contentType` (or a `Blob` with a `type`) and the
|
|
2439
|
+
file is something else, it throws before any request is made. SVG, PDF and
|
|
2440
|
+
other formats are refused.
|
|
2441
|
+
- **Dimensions.** ITM measures images from the file, so there is nothing to
|
|
2442
|
+
compute. For a video, pass the frame size as the third argument when you know
|
|
2443
|
+
it: `uploadPartnerMedia(itm, source, { dimensions: { width: 1920, height: 1080 } })`.
|
|
2444
|
+
- **Video and audio** are queued for streaming after the upload completes;
|
|
2445
|
+
Query the asset for `transforms.hls` after processing if your credentials allow it.
|
|
2446
|
+
- **Cancelling.** Pass `{ signal }` to cancel the storage upload and stop
|
|
2447
|
+
between steps. Pass the same signal when creating the client to also cancel
|
|
2448
|
+
an ITM API call in flight.
|
|
2449
|
+
|
|
2450
|
+
#### Errors
|
|
2451
|
+
|
|
2452
|
+
| Thrown | When |
|
|
2453
|
+
| ---------------------------- | ------------------------------------------------------------------------------------------------------- |
|
|
2454
|
+
| `ITMPartnerMediaUploadError` | `stage: "read"`: the file is missing, empty or not a supported format. `stage: "upload"`: storage refused the bytes or could not be reached; `status` holds the HTTP status when there was a response. |
|
|
2455
|
+
| `GenqlError` | ITM rejected the request: the type or size is not allowed, or the stored file failed verification. |
|
|
2456
|
+
| `ITMPartnerTransportError` | The ITM API itself failed. A lost response to the final step is retried once, because that step is repeatable. |
|
|
2457
|
+
|
|
2458
|
+
The upload URL is a credential. It never appears in an error message; keep it
|
|
2459
|
+
out of your own logs too.
|
|
2460
|
+
|
|
2461
|
+
#### Uploading a file from a URL
|
|
2462
|
+
|
|
2463
|
+
Fetch it yourself and pass the bytes:
|
|
2410
2464
|
|
|
2411
2465
|
```typescript
|
|
2412
|
-
const
|
|
2413
|
-
|
|
2466
|
+
const response = await fetch(imageUrl);
|
|
2467
|
+
if (!response.ok) throw new Error(`Download failed: ${response.status}`);
|
|
2468
|
+
const asset = await uploadPartnerMedia(itm, { data: await response.blob() });
|
|
2469
|
+
```
|
|
2470
|
+
|
|
2471
|
+
If the URL comes from a user or any other source you do not control, validate
|
|
2472
|
+
it before fetching: your server would otherwise fetch whatever address it is
|
|
2473
|
+
given, including ones inside your own network.
|
|
2474
|
+
|
|
2475
|
+
#### The three steps, if you need them separately
|
|
2476
|
+
|
|
2477
|
+
Use these when the bytes are not on the server that holds the token, for
|
|
2478
|
+
example when another service performs the PUT.
|
|
2479
|
+
|
|
2480
|
+
```typescript
|
|
2481
|
+
// 1. Reserve an upload for exactly this type and size
|
|
2482
|
+
const { createPartnerMediaUpload: upload } = await itm.mutation({
|
|
2483
|
+
createPartnerMediaUpload: {
|
|
2414
2484
|
__args: {
|
|
2415
|
-
|
|
2416
|
-
filename: getPartnerUploadUrl.filename, // from Step 1
|
|
2417
|
-
dimensions: { width: 1920, height: 1080 },
|
|
2485
|
+
input: { contentType: "image/jpeg", byteSize: fileBuffer.byteLength },
|
|
2418
2486
|
},
|
|
2487
|
+
uploadKey: true,
|
|
2488
|
+
uploadUrl: true,
|
|
2489
|
+
expiresAt: true,
|
|
2490
|
+
},
|
|
2491
|
+
});
|
|
2492
|
+
|
|
2493
|
+
// 2. PUT the bytes. Content-Type and the byte count are part of the signature,
|
|
2494
|
+
// so they must match step 1 exactly. The URL works for 15 minutes.
|
|
2495
|
+
await fetch(upload.uploadUrl, {
|
|
2496
|
+
method: "PUT",
|
|
2497
|
+
headers: { "Content-Type": "image/jpeg" },
|
|
2498
|
+
body: fileBuffer,
|
|
2499
|
+
});
|
|
2500
|
+
|
|
2501
|
+
// 3. Have ITM verify the stored file and create the asset
|
|
2502
|
+
const { completePartnerMediaUpload: asset } = await itm.mutation({
|
|
2503
|
+
completePartnerMediaUpload: {
|
|
2504
|
+
__args: { input: { uploadKey: upload.uploadKey } },
|
|
2419
2505
|
uid: true,
|
|
2420
2506
|
url: true,
|
|
2421
2507
|
mimeType: true,
|
|
2508
|
+
dimensions: { width: true, height: true },
|
|
2422
2509
|
},
|
|
2423
2510
|
});
|
|
2424
|
-
|
|
2425
|
-
// Use createPartnerMediaAsset.uid as coverImageUid when creating a moment
|
|
2426
2511
|
```
|
|
2427
2512
|
|
|
2513
|
+
- Step 2 needs a body with a known length (a `Buffer`, `Uint8Array` or `Blob`),
|
|
2514
|
+
not a stream: storage refuses a chunked upload because the size is signed.
|
|
2515
|
+
- Step 3 checks that the stored bytes really are the declared type, then copies
|
|
2516
|
+
them to their permanent location. Calling it again with the same `uploadKey`
|
|
2517
|
+
returns the same asset, so it is safe to retry.
|
|
2518
|
+
- An upload that is never completed creates no asset.
|
|
2519
|
+
- Both mutations are limited to 30 requests per minute.
|
|
2520
|
+
|
|
2521
|
+
Brand-agent sessions keep their own reserved-upload flow
|
|
2522
|
+
(`reserveAgentMediaUpload`); these mutations take a partner token or an
|
|
2523
|
+
integration credential.
|
|
2524
|
+
|
|
2525
|
+
#### Legacy flow
|
|
2526
|
+
|
|
2527
|
+
`getPartnerUploadUrl` and `createPartnerMediaAsset` still work for existing
|
|
2528
|
+
integrations. They do not check the file's type or size and take the dimensions
|
|
2529
|
+
you send as given, so new code should use `uploadPartnerMedia`.
|
|
2530
|
+
|
|
2428
2531
|
### `createPartnerMoment`
|
|
2429
2532
|
|
|
2430
2533
|
Create a moment (event) with optional venue and ticket tiers in one atomic operation.
|
|
@@ -2442,7 +2545,7 @@ const { createPartnerMoment } = await itm.mutation({
|
|
|
2442
2545
|
timezone: "America/New_York",
|
|
2443
2546
|
type: "IRL",
|
|
2444
2547
|
capacity: 250,
|
|
2445
|
-
coverImageUid:
|
|
2548
|
+
coverImageUid: asset.uid, // from uploadPartnerMedia
|
|
2446
2549
|
venue: {
|
|
2447
2550
|
name: "Rooftop Bar",
|
|
2448
2551
|
city: "New York",
|
|
@@ -2473,6 +2576,7 @@ const { createPartnerMoment } = await itm.mutation({
|
|
|
2473
2576
|
uid: true,
|
|
2474
2577
|
name: true,
|
|
2475
2578
|
slug: true,
|
|
2579
|
+
publicUrl: true, // hosted moment page
|
|
2476
2580
|
startDate: true,
|
|
2477
2581
|
endDate: true,
|
|
2478
2582
|
status: true,
|
|
@@ -2575,43 +2679,19 @@ const { editPartnerTicketTiersForMoment } = await itm.mutation({
|
|
|
2575
2679
|
### Complete Upload + Create Moment Flow
|
|
2576
2680
|
|
|
2577
2681
|
```typescript
|
|
2578
|
-
import {
|
|
2579
|
-
|
|
2682
|
+
import {
|
|
2683
|
+
createITMPartnerClient,
|
|
2684
|
+
uploadPartnerMedia,
|
|
2685
|
+
} from "@itm-studio/partner-sdk";
|
|
2580
2686
|
|
|
2581
2687
|
const itm = createITMPartnerClient({
|
|
2582
2688
|
token: process.env.ITM_PARTNER_TOKEN!,
|
|
2583
2689
|
});
|
|
2584
2690
|
|
|
2585
|
-
// 1.
|
|
2586
|
-
const
|
|
2587
|
-
getPartnerUploadUrl: {
|
|
2588
|
-
__args: { filename: "event-cover", fileExtension: "jpg" },
|
|
2589
|
-
url: true,
|
|
2590
|
-
filename: true,
|
|
2591
|
-
},
|
|
2592
|
-
});
|
|
2593
|
-
|
|
2594
|
-
// 2. Upload file to S3
|
|
2595
|
-
const file = await readFile("./event-cover.jpg");
|
|
2596
|
-
await fetch(getPartnerUploadUrl.url, {
|
|
2597
|
-
method: "PUT",
|
|
2598
|
-
body: file,
|
|
2599
|
-
headers: { "Content-Type": "image/jpeg" },
|
|
2600
|
-
});
|
|
2691
|
+
// 1. Upload the cover image
|
|
2692
|
+
const cover = await uploadPartnerMedia(itm, { path: "./event-cover.jpg" });
|
|
2601
2693
|
|
|
2602
|
-
//
|
|
2603
|
-
const { createPartnerMediaAsset } = await itm.mutation({
|
|
2604
|
-
createPartnerMediaAsset: {
|
|
2605
|
-
__args: {
|
|
2606
|
-
mimetype: "image/jpeg",
|
|
2607
|
-
filename: getPartnerUploadUrl.filename,
|
|
2608
|
-
dimensions: { width: 1920, height: 1080 },
|
|
2609
|
-
},
|
|
2610
|
-
uid: true,
|
|
2611
|
-
},
|
|
2612
|
-
});
|
|
2613
|
-
|
|
2614
|
-
// 4. Create the moment with the uploaded cover image
|
|
2694
|
+
// 2. Create the moment with the uploaded cover image
|
|
2615
2695
|
const { createPartnerMoment } = await itm.mutation({
|
|
2616
2696
|
createPartnerMoment: {
|
|
2617
2697
|
__args: {
|
|
@@ -2623,7 +2703,7 @@ const { createPartnerMoment } = await itm.mutation({
|
|
|
2623
2703
|
endDate: "2026-07-16T02:00:00.000Z",
|
|
2624
2704
|
timezone: "America/New_York",
|
|
2625
2705
|
type: "IRL",
|
|
2626
|
-
coverImageUid:
|
|
2706
|
+
coverImageUid: cover.uid,
|
|
2627
2707
|
venue: {
|
|
2628
2708
|
name: "The Venue",
|
|
2629
2709
|
city: "New York",
|
|
@@ -3426,4 +3506,6 @@ const { getPartnerBrand } = await client.query({
|
|
|
3426
3506
|
|
|
3427
3507
|
Provide exactly one of `token`, `agentSession`, `agentAccess`, or `integration`. Extra headers cannot override credential headers, regardless of casing. Create a client per inbound request; asynchronous token getters run per API request. `signal` cancels requests in every authentication mode. `ITMPartnerTransportError` exposes the HTTP status without copying a possibly sensitive response body; GraphQL failures remain `GenqlError`.
|
|
3428
3508
|
|
|
3509
|
+
An integration credential reads only what its scopes allow and writes one thing: with `itm:media:write` it can browse the media library (`getPartnerMediaAssets`, `getPartnerMediaAsset`) and upload into it (`createPartnerMediaUpload`, `completePartnerMediaUpload`, or `uploadPartnerMedia`, which selects only fields the credential may read). Every other mutation is refused.
|
|
3510
|
+
|
|
3429
3511
|
This SDK does not log in operators, choose brands, retain OAuth refresh tokens, or decide permissions. The MCP caller handles OAuth and supplies the delegated API credential.
|