@itm-studio/partner-sdk 0.6.9 → 0.6.11

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
@@ -1821,6 +1821,96 @@ these operations or the new membership fields. Existing membership selections
1821
1821
  continue to work without requesting the additions. Backstage and Reader operations
1822
1822
  do not need changes or codegen for this additive partner API contract.
1823
1823
 
1824
+ ### Venue spaces and availability
1825
+
1826
+ Read a brand's bookable spaces, what is on their calendar, and whether they are free. All three operations are read-only and accept a partner API key or a delegated integration credential (`itm:workspace:read`). The brand always comes from the credential. Integration credentials (used by the ITM MCP) are limited to a fixed field list per operation; the examples below stay within it.
1827
+
1828
+ **Model.** A *location* (venue) has *spaces* (rooms). A `COMBINED` space is made of other spaces (`parts`): booking a part blocks the combined space and the reverse; sibling parts stay independent. A *hold* is a tentative claim on a space for a time; overlapping tentative holds on linked spaces form a line ordered by `position`. A hold with status `CONFIRMED` is a booking. A *block* takes a space (or the whole location when `spaceUid` is null) out of service. *Closures* are the times outside a space's opening hours.
1829
+
1830
+ **Dates are local.** `startsOn`, `endsOn`, `localDate`, `startTime` and `endTime` are in the location's `timezone` (IANA). Instants (`startsAt`, `endsAt`) are ISO 8601 UTC. Calendar and availability reads fail with `LOCATION_TIMEZONE_REQUIRED` for a location without a time zone.
1831
+
1832
+ ```typescript
1833
+ // 1. Find locations and their spaces (paginated: take defaults to 25, max 50).
1834
+ const { getPartnerSpaceLocations } = await itm.query({
1835
+ getPartnerSpaceLocations: {
1836
+ __args: { take: 25 },
1837
+ locations: {
1838
+ uid: true,
1839
+ name: true,
1840
+ timezone: true,
1841
+ spaces: { uid: true, name: true, kind: true, capacity: true, parts: { uid: true } },
1842
+ },
1843
+ totalCount: true,
1844
+ hasNextPage: true,
1845
+ nextCursor: true,
1846
+ },
1847
+ });
1848
+
1849
+ // 2. Is anything free on Saturday evening?
1850
+ const { getPartnerSpaceAvailability } = await itm.query({
1851
+ getPartnerSpaceAvailability: {
1852
+ __args: {
1853
+ input: {
1854
+ locationUid: "location-uid",
1855
+ startsOn: "2027-04-24",
1856
+ endsOn: "2027-04-24",
1857
+ startTime: "18:00", // omit both times to check whole local days
1858
+ endTime: "02:00", // ends at or before startTime: runs past midnight
1859
+ },
1860
+ },
1861
+ timezone: true,
1862
+ spaces: {
1863
+ spaceUid: true,
1864
+ name: true,
1865
+ dates: {
1866
+ localDate: true,
1867
+ outcome: true,
1868
+ lineSize: true,
1869
+ closed: true,
1870
+ conflicts: { kind: true, label: true, startsAt: true, endsAt: true },
1871
+ },
1872
+ },
1873
+ },
1874
+ });
1875
+
1876
+ // 3. What is on the calendar this week?
1877
+ const { getPartnerSpaceCalendar } = await itm.query({
1878
+ getPartnerSpaceCalendar: {
1879
+ __args: { input: { locationUid: "location-uid", startsOn: "2027-04-19", endsOn: "2027-04-25" } },
1880
+ timezone: true,
1881
+ spaces: { uid: true, name: true },
1882
+ holds: {
1883
+ uid: true,
1884
+ spaceUid: true,
1885
+ startsAt: true,
1886
+ endsAt: true,
1887
+ status: true,
1888
+ position: true,
1889
+ isLapsed: true,
1890
+ request: { title: true, organization: true, headcount: true },
1891
+ },
1892
+ blocks: { spaceUid: true, startsAt: true, endsAt: true, reason: true },
1893
+ closures: { spaceUid: true, localDate: true, startsAt: true, endsAt: true },
1894
+ },
1895
+ });
1896
+ ```
1897
+
1898
+ **Availability outcomes**, per space and local date:
1899
+
1900
+ | `outcome` | Meaning |
1901
+ | --- | --- |
1902
+ | `OPEN` | Nothing overlaps the checked time. |
1903
+ | `IN_LINE` | Only tentative holds overlap; `lineSize` says how many. A new hold would join the line. |
1904
+ | `UNAVAILABLE` | A confirmed booking or a block overlaps; `conflicts` names each one with its times (a booking's include its setup and teardown). |
1905
+
1906
+ Without a time window each row checks the whole local day, so an event that runs past midnight makes the next day `UNAVAILABLE` too; pass the hours you care about to check an evening. With a window, each space's setup and teardown minutes are added around it. `closed` is true when the venue is not open for the checked time: for a whole day, no opening hours start on that date; with a window, opening hours do not cover the window including setup and teardown. Opening hours and booking rules (minimum length, notice, start interval) never change the outcome, so treat a `closed` date as unavailable even when its outcome is `OPEN`.
1907
+
1908
+ **Limits.** Availability covers at most 31 days and 250 space-days per request (narrow the dates or pass `spaceUids`). The calendar covers at most 62 days and 250 spaces once combined spaces and their parts are counted. Both accept at most 50 `spaceUids` and default to every active space. Calendar and availability reads also stop at 1,000 records (holds, blocks, closures or conflicts) and fails with `INVALID_RANGE`; narrow the dates or choose fewer spaces.
1909
+
1910
+ **Not covered.** Moments (ticketed events) do not occupy the space calendar: a show appears only if a hold or booking was placed for it, so check `getPartnerMomentsForBrand` for the same dates. Holds past `expiresAt` are not expired automatically; they keep their place in line and are flagged `isLapsed`. This SDK does not expose a space request's contact name, email, phone or note.
1911
+
1912
+ Deploy the backend contract before publishing an SDK version that uses these operations.
1913
+
1824
1914
  ### `getPartnerMomentCollection`
1825
1915
 
1826
1916
  Get a moment collection by slug. Collections group related moments together (e.g. a summer series, a festival lineup). Returns the collection with its moments and links.
@@ -3147,6 +3237,130 @@ Hosted sign-in offers the same optional checkbox on ITM's code and "Continue to
3147
3237
  - Regenerate the session ID after either sign-in flow succeeds, invalidate the old session, and clear pending login state. Use your framework's session API for the `rotateSession()` placeholder above.
3148
3238
  - Protect your send-code and verify endpoints with CSRF tokens and your own bot protection.
3149
3239
 
3240
+ ## Read plans, date polls, and budgets
3241
+
3242
+ Use the Node SDK from your server with a workspace partner key. The key
3243
+ determines the workspace. A delegated integration credential uses
3244
+ `itm:workspace:read` and sends one allowlisted query per request.
3245
+
3246
+ ```ts
3247
+ import { createITMPartnerClient } from "@itm-studio/partner-sdk";
3248
+
3249
+ const itm = createITMPartnerClient({ token: process.env.ITM_PARTNER_TOKEN! });
3250
+
3251
+ async function readPlanPage(search: string, cursor: string | null) {
3252
+ const { getPartnerPlans } = await itm.query({
3253
+ getPartnerPlans: {
3254
+ __args: { input: { search, cursor, take: 25 } },
3255
+ plans: { uid: true, name: true, status: true },
3256
+ nextCursor: true,
3257
+ hasNextPage: true,
3258
+ },
3259
+ });
3260
+ return getPartnerPlans;
3261
+ }
3262
+
3263
+ async function findPlans(search: string) {
3264
+ const plans = [];
3265
+ let cursor: string | null = null;
3266
+
3267
+ do {
3268
+ const page = await readPlanPage(search, cursor);
3269
+ plans.push(...page.plans);
3270
+ cursor = page.hasNextPage ? page.nextCursor : null;
3271
+ } while (cursor);
3272
+
3273
+ return plans;
3274
+ }
3275
+
3276
+ async function readPlan(planUid: string) {
3277
+ const { getPartnerPlan: plan } = await itm.query({
3278
+ getPartnerPlan: {
3279
+ __args: { planUid },
3280
+ uid: true,
3281
+ name: true,
3282
+ schedule: {
3283
+ type: true, timezone: true, startsAt: true, endsAt: true,
3284
+ startsOn: true, endsOn: true, frequency: true, interval: true,
3285
+ daysOfWeek: true, count: true, includeDates: true, excludeDates: true,
3286
+ times: { time: true, durationMinutes: true },
3287
+ },
3288
+ },
3289
+ });
3290
+ const { getPartnerPlanDatePoll: poll } = await itm.query({
3291
+ getPartnerPlanDatePoll: {
3292
+ __args: { planUid },
3293
+ status: true, timeMode: true, timezone: true, replyByDate: true,
3294
+ chosenOptionUid: true, answeredCount: true, notAnsweredCount: true,
3295
+ needsUpdateCount: true,
3296
+ results: {
3297
+ optionUid: true, localDate: true, startTime: true, endTime: true,
3298
+ status: true, freeCount: true, ifNeedBeCount: true,
3299
+ unavailableCount: true, unansweredCount: true,
3300
+ bestSlot: { startTime: true, endTime: true },
3301
+ },
3302
+ },
3303
+ });
3304
+ const { getPartnerPlanBudgets: budgets } = await itm.query({
3305
+ getPartnerPlanBudgets: {
3306
+ __args: { planUid },
3307
+ uid: true, name: true, revision: true, currencyCode: true,
3308
+ scheduleIsStale: true,
3309
+ },
3310
+ });
3311
+ return { plan, poll, budgets };
3312
+ }
3313
+
3314
+ async function readBudget(budgetUid: string) {
3315
+ const { getPartnerPlanBudget: budget } = await itm.query({
3316
+ getPartnerPlanBudget: {
3317
+ __args: { budgetUid },
3318
+ uid: true, planUid: true, name: true, revision: true,
3319
+ currencyCode: true, currencyExponent: true, scheduleIsStale: true,
3320
+ document: true, calculation: true,
3321
+ },
3322
+ });
3323
+ return budget;
3324
+ }
3325
+
3326
+ const matches = await findPlans("Summer show");
3327
+ if (matches.length === 1) {
3328
+ const details = await readPlan(matches[0].uid);
3329
+ console.log(details);
3330
+ if (details.budgets.length === 1) {
3331
+ console.log(await readBudget(details.budgets[0].uid));
3332
+ }
3333
+ }
3334
+ ```
3335
+
3336
+ - Plan lists return active plans by default. Use `status: "ARCHIVED"` to
3337
+ browse archived plans. Search matches the name or slug. Keep your filters
3338
+ when following a cursor. The SDK defaults to 25 per page and supports up to 100.
3339
+ - The plan's `schedule` gives the current planned date, including edits after a
3340
+ poll closes. One-time timestamps are UTC. Recurring dates and times are
3341
+ local to the schedule timezone. Moment dates and venue availability are
3342
+ available through the respective Moment and venue reads.
3343
+ - A `null` poll means that the plan has no poll. Poll times use the returned
3344
+ timezone. A closed poll can have a null `chosenOptionUid`. Match a chosen
3345
+ UID to `results[].optionUid`. Results are ranked best first. `WAITING` means
3346
+ someone who could cover an unmet required role has yet to respond.
3347
+ `BLOCKED` means that role remains unmet after responses. In `WINDOW` mode,
3348
+ availability counts describe the best slot. A participant who needs to
3349
+ update their answers may already have answered some candidates.
3350
+ - Budget lists contain up to 20 active budgets, most recently updated first.
3351
+ Budget `document` holds the saved inputs, including categories, lines, ticket
3352
+ tiers and assumptions. Match `calculation.lines` to `document.lines` by UID
3353
+ for planned and forecast totals. A line's forecast uses the first available
3354
+ total in this order: actual, committed, quoted, then planned. Use
3355
+ `calculation.walkouts` for saved sell-through scenarios and
3356
+ `breakEvenStatus` to distinguish `NOT_REACHED` from `UNAVAILABLE`.
3357
+ - Amounts ending in `Minor` are exact integer strings. With
3358
+ `currencyExponent: 2`, `"2500"` in USD is 25.00 USD. With exponent 0, the
3359
+ same string in JPY is 2,500 JPY. Use `BigInt` or decimal arithmetic for
3360
+ calculations. Basis points represent hundredths of a percent, so 8000 is
3361
+ 80%. When `scheduleIsStale` is true, calculations use the previously
3362
+ captured schedule.
3363
+
3150
3364
  ## Pagination
3151
3365
 
3152
3366
  All list endpoints use cursor-based pagination. The default page size is **50** items if `take` is not specified.