@itm-studio/partner-sdk 0.4.2 → 0.6.0

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
@@ -2504,7 +2504,9 @@ do {
2504
2504
  });
2505
2505
 
2506
2506
  for (const ticket of getPartnerTicketsForMoment.tickets) {
2507
- console.log(ticket.user.name);
2507
+ // `user` is typed nullable: box-office walk-up tickets have no holder
2508
+ // (they are left out of this list).
2509
+ console.log(ticket.user?.name);
2508
2510
  }
2509
2511
 
2510
2512
  cursor = getPartnerTicketsForMoment.nextCursor ?? null;
@@ -2713,3 +2715,22 @@ receipt eligibility. Omit it for no receipt. `userUid` is populated when entered
2713
2715
  email or phone matches a current verified ITM identity; unmatched contacts do not
2714
2716
  create an account, and conflicting matches are rejected. `source` distinguishes
2715
2717
  `STRIPE`, `OFF_SITE`, and in-person `POS` independently of payment status.
2718
+
2719
+ ### Delegated integration credentials (MCP)
2720
+
2721
+ 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.
2722
+
2723
+ ```ts
2724
+ const client = createITMPartnerClient({
2725
+ baseUrl: process.env.ITM_PARTNER_API_ORIGIN,
2726
+ integration: { accessToken: async () => requestScopedApiCredential },
2727
+ signal: request.signal,
2728
+ });
2729
+ const { getPartnerBrand } = await client.query({
2730
+ getPartnerBrand: { uid: true, name: true, slug: true, publicUrl: true },
2731
+ });
2732
+ ```
2733
+
2734
+ 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`.
2735
+
2736
+ 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.
package/dist/index.d.mts CHANGED
@@ -291,7 +291,11 @@ interface Ticket {
291
291
  externalId: (Scalars['String'] | null);
292
292
  hasExpired: Scalars['Boolean'];
293
293
  ticketTier: TicketTier;
294
- user: User;
294
+ /**
295
+ * The ticket holder. Null only for an ITM box-office walk-up sale, which has no
296
+ * holder; partner ticket lists leave those tickets out.
297
+ */
298
+ user: (User | null);
295
299
  moment: Moment;
296
300
  payment: (Payment | null);
297
301
  extensions: TicketExtension[];
@@ -1615,6 +1619,10 @@ interface TicketGenqlSelection {
1615
1619
  externalId?: boolean | number;
1616
1620
  hasExpired?: boolean | number;
1617
1621
  ticketTier?: TicketTierGenqlSelection;
1622
+ /**
1623
+ * The ticket holder. Null only for an ITM box-office walk-up sale, which has no
1624
+ * holder; partner ticket lists leave those tickets out.
1625
+ */
1618
1626
  user?: UserGenqlSelection;
1619
1627
  moment?: MomentGenqlSelection;
1620
1628
  payment?: PaymentGenqlSelection;
@@ -3621,6 +3629,8 @@ interface ITMPartnerTokenConfig {
3621
3629
  * @default DEFAULT_API_URL
3622
3630
  */
3623
3631
  baseUrl?: string;
3632
+ /** Cancellation for this request-scoped client. */
3633
+ signal?: AbortSignal;
3624
3634
  /**
3625
3635
  * Additional headers to include on every request.
3626
3636
  * A function is useful for request-scoped values like `x-forwarded-for`
@@ -3659,6 +3669,8 @@ interface ITMPartnerAgentSessionConfig {
3659
3669
  * @default DEFAULT_API_URL
3660
3670
  */
3661
3671
  baseUrl?: string;
3672
+ /** Cancellation for this request-scoped client. */
3673
+ signal?: AbortSignal;
3662
3674
  /**
3663
3675
  * Additional headers to include on every request. Credential headers
3664
3676
  * always take precedence and cannot be overridden.
@@ -3692,13 +3704,25 @@ interface ITMPartnerAgentAccessConfig {
3692
3704
  * @default DEFAULT_API_URL
3693
3705
  */
3694
3706
  baseUrl?: string;
3707
+ /** Cancellation for this request-scoped client. */
3708
+ signal?: AbortSignal;
3695
3709
  /**
3696
3710
  * Additional headers to include on every request. Credential headers
3697
3711
  * always take precedence and cannot be overridden.
3698
3712
  */
3699
3713
  headers?: ITMPartnerHeaders;
3700
3714
  }
3701
- type ITMPartnerClientConfig = ITMPartnerTokenConfig | ITMPartnerAgentSessionConfig | ITMPartnerAgentAccessConfig;
3715
+ interface ITMPartnerIntegrationCredentials {
3716
+ /** Short-lived API credential supplied by the caller, resolved afresh per request. */
3717
+ accessToken: string | (() => MaybePromise<string>);
3718
+ }
3719
+ interface ITMPartnerIntegrationConfig {
3720
+ integration: ITMPartnerIntegrationCredentials;
3721
+ baseUrl?: string;
3722
+ headers?: ITMPartnerHeaders;
3723
+ signal?: AbortSignal;
3724
+ }
3725
+ type ITMPartnerClientConfig = ITMPartnerIntegrationConfig | ITMPartnerTokenConfig | ITMPartnerAgentSessionConfig | ITMPartnerAgentAccessConfig;
3702
3726
  type ITMPartnerClient = Client;
3703
3727
  /**
3704
3728
  * Create a typed ITM Partner API client.
@@ -3730,5 +3754,12 @@ type ITMPartnerClient = Client;
3730
3754
  * ```
3731
3755
  */
3732
3756
  declare function createITMPartnerClient(config: ITMPartnerClientConfig): ITMPartnerClient;
3757
+ /** HTTP errors retain status without copying response bodies or credentials. */
3758
+ declare class ITMPartnerTransportError extends Error {
3759
+ readonly status: number | undefined;
3760
+ readonly requestId?: string | undefined;
3761
+ readonly name = "ITMPartnerTransportError";
3762
+ constructor(status: number | undefined, requestId?: string | undefined);
3763
+ }
3733
3764
 
3734
- export { type AgentThreadSeedContext, type ApplyDynamicPricingInput, type BrandAgentEmailMessageInput, type BrandAgentEmailSendBatch, type BrandAgentEmailSendBatchStatus, type BrandAgentEmailSendMessage, type BrandAgentEmailSendMessageStatus, type BrandApp, type BrandAppStatus, type BrandDrop, type BrandDropCtaType, type BrandDropMusicLink, type BrandSubscription, type CheckoutMarketingConsentInput, type CheckoutMarketingConsentPrompt, type ConsentChannel, type ConsentPromptCategory, type ConsentStatus, type ContributionAdmin, type ContributionPageAdmin, type ContributionPageStatusFilter, type ContributionPagesResponse, type ContributionSource, type ContributionStatus, type ContributionsResponse, type CreateBrandAppInput, type CreateManualContributionInput, type CreateMomentOnlineConfigInput, type CreatePartnerBrandDropInput, type CreatePartnerBrandSubscriptionInput, type CreatePartnerBrandSubscriptionResponse, type CreatePartnerMomentInput, type CreatePartnerTicketTierInput, type CreatePlanBudgetInput, type CreatePlanInput, type Currency, DEFAULT_API_URL, type Dimensions, type DimensionsInput, type DynamicPricingActorType, type DynamicPricingAdmissionWindow, type DynamicPricingBatch, type DynamicPricingBatchEvent, type DynamicPricingBatchEventType, type DynamicPricingBatchItem, type DynamicPricingBatchItemStatus, type DynamicPricingBatchStatus, type DynamicPricingContext, type DynamicPricingExecutionMode, type DynamicPricingInventoryGuardInput, type DynamicPricingInventoryGuardMode, type DynamicPricingInventoryMetric, type DynamicPricingMomentInput, type DynamicPricingTierContext, type DynamicPricingTierUpdateInput, type Echo, type EchoMediaAsset, type EchoType, type EditPartnerTicketTiersForMomentInput, type EventImportPlatform, GenqlError, type GetBrandEchoesForUserResponse, type GetMomentLineupsResponse, type GetMomentTagAssignmentsResponse, type GetPartnerAudienceInput, type GetPartnerAudienceResponse, type GetPartnerCustomersResponse, type GetPartnerDropsResponse, type GetPartnerMediaAssetsInput, type GetPartnerMediaAssetsResponse, type GetPartnerMembersInput, type GetPartnerMembersResponse, type GetPartnerMembershipTiersInput, type GetPartnerMembershipTiersResponse, type GetPartnerTicketTiersForMomentInput, type GetPartnerTicketTiersForMomentResponse, type GetPlansInput, type GetPlansResponse, type GetPublicMomentsResponse, type GetTicketsResponse, type ITMPartnerAgentAccessConfig, type ITMPartnerAgentAccessCredentials, type ITMPartnerAgentSessionConfig, type ITMPartnerAgentSessionCredentials, type ITMPartnerClient, type ITMPartnerClientConfig, type ITMPartnerHeaders, type ITMPartnerHeadersObject, type ITMPartnerTokenConfig, type LoginCodeChannel, type ManualContributionReceiptType, type MediaAsset, type MediaAssetUploadUrl, type MembershipBillingInterval, type MembershipExpiryType, type MembershipPassType, type MembershipPurchaseType, type MembershipSource, type MembershipStatus, type MerchPurchase, type Moment, type MomentCategory, type MomentCollection, type MomentCollectionLink, type MomentDiscountCodeUsage, type MomentDynamicPricingPolicy, type MomentDynamicPricingTierRule, type MomentLineup, type MomentLineupDisplayLabel, type MomentLineupResponseResult, type MomentLineupStatus, type MomentLineupType, type MomentOccurrenceScheduleFrequency, type MomentOnlineProvider, type MomentPublicVenuePreview, type MomentSortOrder, type MomentStatus, type MomentSubcategory, type MomentTagAssignment, type MomentType, type MusicReleaseType, type Mutation, type PaginationInput, type PartnerAppLogin, type PartnerAppLoginChallenge, type PartnerAppLoginProfile, type PartnerAudienceCustomer, type PartnerAudienceFiltersInput, type PartnerAudienceSortField, type PartnerAudienceSortInput, type PartnerBrand, type PartnerCustomer, type PartnerMember, type PartnerMemberCustomer, type PartnerMemberTier, type PartnerMembershipTier, type PartnerMomentAttendanceCount, type PartnerMomentAttendanceLookupInput, type PartnerMomentAttendanceStats, type PartnerMomentGuestlistAttendance, type PartnerMomentGuestlistLabelAttendance, type PartnerMomentStats, type PartnerMomentTicketAttendance, type PartnerMomentTicketTierAttendance, type PartnerMomentsFiltersInput, type PartnerTicketStatus, type PartnerTicketTier, type PartnerTicketTierUpdateInput, type PartnerTicketUserLookupInput, type PartnerTicketsForUserInput, type Payment, type PaymentStatus, type Plan, type PlanBudget, type PlanBudgetAllocationType, type PlanBudgetArtistDealBasis, type PlanBudgetArtistDealInput, type PlanBudgetArtistDealType, type PlanBudgetCapacityAllocationInput, type PlanBudgetCategoryInput, type PlanBudgetCategoryKind, type PlanBudgetChargeCalculation, type PlanBudgetChargeKind, type PlanBudgetChargeTreatment, type PlanBudgetExternalTicketingChannelInput, type PlanBudgetFeeAssessment, type PlanBudgetFeeComponentKind, type PlanBudgetFeePercentageBasis, type PlanBudgetGuaranteeBasis, type PlanBudgetLineBasis, type PlanBudgetLineInput, type PlanBudgetPaymentStatus, type PlanBudgetPricingMode, type PlanBudgetSummary, type PlanBudgetTicketChargeRuleInput, type PlanBudgetTicketTierInput, type PlanBudgetTicketingChannelType, type PlanBudgetTicketingFeeComponentInput, type PlanKind, type PlanLinkMetadataStatus, type PlanMoodboard, type PlanMoodboardItem, type PlanMoodboardItemType, type PlanSchedule, type PlanScheduleInput, type PlanScheduleTime, type PlanScheduleTimeInput, type PlanScheduleType, type PlanStatus, type PlanSummary, type PlanningProposal, type PlanningSource, type PlanningSourceDispositionInput, type PlanningSourceSection, type PostSubscriptionEmailInput, type PostSubscriptionMessageInput, type PostSubscriptionPushInput, type PostSubscriptionSmsInput, type PreparePlanningProposalInput, type PublicMomentLineupInfo, type Query, type ReplacePlanBudgetDraftInput, type RespondToMomentLineupInput, type SendPartnerAgentEmailInput, type SortDirection, type StartPartnerAppLoginInput, type SubscriptionComplianceInput, type Tag, type TagSource, type ThirdPartyEchoType, type Ticket, type TicketAdmissionWindowSource, type TicketAttendanceMode, type TicketExtension, type TicketExtensionStatus, type TicketTier, type Transforms, type UpdatePlanInput, type User, type UserSource, type Venue, type VenueInput, type VerifyPartnerAppLoginInput, type VerifyPartnerBrandSubscriptionInput, createITMPartnerClient, everything, generateMutationOp, generateQueryOp };
3765
+ export { type AgentThreadSeedContext, type ApplyDynamicPricingInput, type BrandAgentEmailMessageInput, type BrandAgentEmailSendBatch, type BrandAgentEmailSendBatchStatus, type BrandAgentEmailSendMessage, type BrandAgentEmailSendMessageStatus, type BrandApp, type BrandAppStatus, type BrandDrop, type BrandDropCtaType, type BrandDropMusicLink, type BrandSubscription, type CheckoutMarketingConsentInput, type CheckoutMarketingConsentPrompt, type ConsentChannel, type ConsentPromptCategory, type ConsentStatus, type ContributionAdmin, type ContributionPageAdmin, type ContributionPageStatusFilter, type ContributionPagesResponse, type ContributionSource, type ContributionStatus, type ContributionsResponse, type CreateBrandAppInput, type CreateManualContributionInput, type CreateMomentOnlineConfigInput, type CreatePartnerBrandDropInput, type CreatePartnerBrandSubscriptionInput, type CreatePartnerBrandSubscriptionResponse, type CreatePartnerMomentInput, type CreatePartnerTicketTierInput, type CreatePlanBudgetInput, type CreatePlanInput, type Currency, DEFAULT_API_URL, type Dimensions, type DimensionsInput, type DynamicPricingActorType, type DynamicPricingAdmissionWindow, type DynamicPricingBatch, type DynamicPricingBatchEvent, type DynamicPricingBatchEventType, type DynamicPricingBatchItem, type DynamicPricingBatchItemStatus, type DynamicPricingBatchStatus, type DynamicPricingContext, type DynamicPricingExecutionMode, type DynamicPricingInventoryGuardInput, type DynamicPricingInventoryGuardMode, type DynamicPricingInventoryMetric, type DynamicPricingMomentInput, type DynamicPricingTierContext, type DynamicPricingTierUpdateInput, type Echo, type EchoMediaAsset, type EchoType, type EditPartnerTicketTiersForMomentInput, type EventImportPlatform, GenqlError, type GetBrandEchoesForUserResponse, type GetMomentLineupsResponse, type GetMomentTagAssignmentsResponse, type GetPartnerAudienceInput, type GetPartnerAudienceResponse, type GetPartnerCustomersResponse, type GetPartnerDropsResponse, type GetPartnerMediaAssetsInput, type GetPartnerMediaAssetsResponse, type GetPartnerMembersInput, type GetPartnerMembersResponse, type GetPartnerMembershipTiersInput, type GetPartnerMembershipTiersResponse, type GetPartnerTicketTiersForMomentInput, type GetPartnerTicketTiersForMomentResponse, type GetPlansInput, type GetPlansResponse, type GetPublicMomentsResponse, type GetTicketsResponse, type ITMPartnerAgentAccessConfig, type ITMPartnerAgentAccessCredentials, type ITMPartnerAgentSessionConfig, type ITMPartnerAgentSessionCredentials, type ITMPartnerClient, type ITMPartnerClientConfig, type ITMPartnerHeaders, type ITMPartnerHeadersObject, type ITMPartnerIntegrationConfig, type ITMPartnerIntegrationCredentials, type ITMPartnerTokenConfig, ITMPartnerTransportError, type LoginCodeChannel, type ManualContributionReceiptType, type MediaAsset, type MediaAssetUploadUrl, type MembershipBillingInterval, type MembershipExpiryType, type MembershipPassType, type MembershipPurchaseType, type MembershipSource, type MembershipStatus, type MerchPurchase, type Moment, type MomentCategory, type MomentCollection, type MomentCollectionLink, type MomentDiscountCodeUsage, type MomentDynamicPricingPolicy, type MomentDynamicPricingTierRule, type MomentLineup, type MomentLineupDisplayLabel, type MomentLineupResponseResult, type MomentLineupStatus, type MomentLineupType, type MomentOccurrenceScheduleFrequency, type MomentOnlineProvider, type MomentPublicVenuePreview, type MomentSortOrder, type MomentStatus, type MomentSubcategory, type MomentTagAssignment, type MomentType, type MusicReleaseType, type Mutation, type PaginationInput, type PartnerAppLogin, type PartnerAppLoginChallenge, type PartnerAppLoginProfile, type PartnerAudienceCustomer, type PartnerAudienceFiltersInput, type PartnerAudienceSortField, type PartnerAudienceSortInput, type PartnerBrand, type PartnerCustomer, type PartnerMember, type PartnerMemberCustomer, type PartnerMemberTier, type PartnerMembershipTier, type PartnerMomentAttendanceCount, type PartnerMomentAttendanceLookupInput, type PartnerMomentAttendanceStats, type PartnerMomentGuestlistAttendance, type PartnerMomentGuestlistLabelAttendance, type PartnerMomentStats, type PartnerMomentTicketAttendance, type PartnerMomentTicketTierAttendance, type PartnerMomentsFiltersInput, type PartnerTicketStatus, type PartnerTicketTier, type PartnerTicketTierUpdateInput, type PartnerTicketUserLookupInput, type PartnerTicketsForUserInput, type Payment, type PaymentStatus, type Plan, type PlanBudget, type PlanBudgetAllocationType, type PlanBudgetArtistDealBasis, type PlanBudgetArtistDealInput, type PlanBudgetArtistDealType, type PlanBudgetCapacityAllocationInput, type PlanBudgetCategoryInput, type PlanBudgetCategoryKind, type PlanBudgetChargeCalculation, type PlanBudgetChargeKind, type PlanBudgetChargeTreatment, type PlanBudgetExternalTicketingChannelInput, type PlanBudgetFeeAssessment, type PlanBudgetFeeComponentKind, type PlanBudgetFeePercentageBasis, type PlanBudgetGuaranteeBasis, type PlanBudgetLineBasis, type PlanBudgetLineInput, type PlanBudgetPaymentStatus, type PlanBudgetPricingMode, type PlanBudgetSummary, type PlanBudgetTicketChargeRuleInput, type PlanBudgetTicketTierInput, type PlanBudgetTicketingChannelType, type PlanBudgetTicketingFeeComponentInput, type PlanKind, type PlanLinkMetadataStatus, type PlanMoodboard, type PlanMoodboardItem, type PlanMoodboardItemType, type PlanSchedule, type PlanScheduleInput, type PlanScheduleTime, type PlanScheduleTimeInput, type PlanScheduleType, type PlanStatus, type PlanSummary, type PlanningProposal, type PlanningSource, type PlanningSourceDispositionInput, type PlanningSourceSection, type PostSubscriptionEmailInput, type PostSubscriptionMessageInput, type PostSubscriptionPushInput, type PostSubscriptionSmsInput, type PreparePlanningProposalInput, type PublicMomentLineupInfo, type Query, type ReplacePlanBudgetDraftInput, type RespondToMomentLineupInput, type SendPartnerAgentEmailInput, type SortDirection, type StartPartnerAppLoginInput, type SubscriptionComplianceInput, type Tag, type TagSource, type ThirdPartyEchoType, type Ticket, type TicketAdmissionWindowSource, type TicketAttendanceMode, type TicketExtension, type TicketExtensionStatus, type TicketTier, type Transforms, type UpdatePlanInput, type User, type UserSource, type Venue, type VenueInput, type VerifyPartnerAppLoginInput, type VerifyPartnerBrandSubscriptionInput, createITMPartnerClient, everything, generateMutationOp, generateQueryOp };
package/dist/index.d.ts CHANGED
@@ -291,7 +291,11 @@ interface Ticket {
291
291
  externalId: (Scalars['String'] | null);
292
292
  hasExpired: Scalars['Boolean'];
293
293
  ticketTier: TicketTier;
294
- user: User;
294
+ /**
295
+ * The ticket holder. Null only for an ITM box-office walk-up sale, which has no
296
+ * holder; partner ticket lists leave those tickets out.
297
+ */
298
+ user: (User | null);
295
299
  moment: Moment;
296
300
  payment: (Payment | null);
297
301
  extensions: TicketExtension[];
@@ -1615,6 +1619,10 @@ interface TicketGenqlSelection {
1615
1619
  externalId?: boolean | number;
1616
1620
  hasExpired?: boolean | number;
1617
1621
  ticketTier?: TicketTierGenqlSelection;
1622
+ /**
1623
+ * The ticket holder. Null only for an ITM box-office walk-up sale, which has no
1624
+ * holder; partner ticket lists leave those tickets out.
1625
+ */
1618
1626
  user?: UserGenqlSelection;
1619
1627
  moment?: MomentGenqlSelection;
1620
1628
  payment?: PaymentGenqlSelection;
@@ -3621,6 +3629,8 @@ interface ITMPartnerTokenConfig {
3621
3629
  * @default DEFAULT_API_URL
3622
3630
  */
3623
3631
  baseUrl?: string;
3632
+ /** Cancellation for this request-scoped client. */
3633
+ signal?: AbortSignal;
3624
3634
  /**
3625
3635
  * Additional headers to include on every request.
3626
3636
  * A function is useful for request-scoped values like `x-forwarded-for`
@@ -3659,6 +3669,8 @@ interface ITMPartnerAgentSessionConfig {
3659
3669
  * @default DEFAULT_API_URL
3660
3670
  */
3661
3671
  baseUrl?: string;
3672
+ /** Cancellation for this request-scoped client. */
3673
+ signal?: AbortSignal;
3662
3674
  /**
3663
3675
  * Additional headers to include on every request. Credential headers
3664
3676
  * always take precedence and cannot be overridden.
@@ -3692,13 +3704,25 @@ interface ITMPartnerAgentAccessConfig {
3692
3704
  * @default DEFAULT_API_URL
3693
3705
  */
3694
3706
  baseUrl?: string;
3707
+ /** Cancellation for this request-scoped client. */
3708
+ signal?: AbortSignal;
3695
3709
  /**
3696
3710
  * Additional headers to include on every request. Credential headers
3697
3711
  * always take precedence and cannot be overridden.
3698
3712
  */
3699
3713
  headers?: ITMPartnerHeaders;
3700
3714
  }
3701
- type ITMPartnerClientConfig = ITMPartnerTokenConfig | ITMPartnerAgentSessionConfig | ITMPartnerAgentAccessConfig;
3715
+ interface ITMPartnerIntegrationCredentials {
3716
+ /** Short-lived API credential supplied by the caller, resolved afresh per request. */
3717
+ accessToken: string | (() => MaybePromise<string>);
3718
+ }
3719
+ interface ITMPartnerIntegrationConfig {
3720
+ integration: ITMPartnerIntegrationCredentials;
3721
+ baseUrl?: string;
3722
+ headers?: ITMPartnerHeaders;
3723
+ signal?: AbortSignal;
3724
+ }
3725
+ type ITMPartnerClientConfig = ITMPartnerIntegrationConfig | ITMPartnerTokenConfig | ITMPartnerAgentSessionConfig | ITMPartnerAgentAccessConfig;
3702
3726
  type ITMPartnerClient = Client;
3703
3727
  /**
3704
3728
  * Create a typed ITM Partner API client.
@@ -3730,5 +3754,12 @@ type ITMPartnerClient = Client;
3730
3754
  * ```
3731
3755
  */
3732
3756
  declare function createITMPartnerClient(config: ITMPartnerClientConfig): ITMPartnerClient;
3757
+ /** HTTP errors retain status without copying response bodies or credentials. */
3758
+ declare class ITMPartnerTransportError extends Error {
3759
+ readonly status: number | undefined;
3760
+ readonly requestId?: string | undefined;
3761
+ readonly name = "ITMPartnerTransportError";
3762
+ constructor(status: number | undefined, requestId?: string | undefined);
3763
+ }
3733
3764
 
3734
- export { type AgentThreadSeedContext, type ApplyDynamicPricingInput, type BrandAgentEmailMessageInput, type BrandAgentEmailSendBatch, type BrandAgentEmailSendBatchStatus, type BrandAgentEmailSendMessage, type BrandAgentEmailSendMessageStatus, type BrandApp, type BrandAppStatus, type BrandDrop, type BrandDropCtaType, type BrandDropMusicLink, type BrandSubscription, type CheckoutMarketingConsentInput, type CheckoutMarketingConsentPrompt, type ConsentChannel, type ConsentPromptCategory, type ConsentStatus, type ContributionAdmin, type ContributionPageAdmin, type ContributionPageStatusFilter, type ContributionPagesResponse, type ContributionSource, type ContributionStatus, type ContributionsResponse, type CreateBrandAppInput, type CreateManualContributionInput, type CreateMomentOnlineConfigInput, type CreatePartnerBrandDropInput, type CreatePartnerBrandSubscriptionInput, type CreatePartnerBrandSubscriptionResponse, type CreatePartnerMomentInput, type CreatePartnerTicketTierInput, type CreatePlanBudgetInput, type CreatePlanInput, type Currency, DEFAULT_API_URL, type Dimensions, type DimensionsInput, type DynamicPricingActorType, type DynamicPricingAdmissionWindow, type DynamicPricingBatch, type DynamicPricingBatchEvent, type DynamicPricingBatchEventType, type DynamicPricingBatchItem, type DynamicPricingBatchItemStatus, type DynamicPricingBatchStatus, type DynamicPricingContext, type DynamicPricingExecutionMode, type DynamicPricingInventoryGuardInput, type DynamicPricingInventoryGuardMode, type DynamicPricingInventoryMetric, type DynamicPricingMomentInput, type DynamicPricingTierContext, type DynamicPricingTierUpdateInput, type Echo, type EchoMediaAsset, type EchoType, type EditPartnerTicketTiersForMomentInput, type EventImportPlatform, GenqlError, type GetBrandEchoesForUserResponse, type GetMomentLineupsResponse, type GetMomentTagAssignmentsResponse, type GetPartnerAudienceInput, type GetPartnerAudienceResponse, type GetPartnerCustomersResponse, type GetPartnerDropsResponse, type GetPartnerMediaAssetsInput, type GetPartnerMediaAssetsResponse, type GetPartnerMembersInput, type GetPartnerMembersResponse, type GetPartnerMembershipTiersInput, type GetPartnerMembershipTiersResponse, type GetPartnerTicketTiersForMomentInput, type GetPartnerTicketTiersForMomentResponse, type GetPlansInput, type GetPlansResponse, type GetPublicMomentsResponse, type GetTicketsResponse, type ITMPartnerAgentAccessConfig, type ITMPartnerAgentAccessCredentials, type ITMPartnerAgentSessionConfig, type ITMPartnerAgentSessionCredentials, type ITMPartnerClient, type ITMPartnerClientConfig, type ITMPartnerHeaders, type ITMPartnerHeadersObject, type ITMPartnerTokenConfig, type LoginCodeChannel, type ManualContributionReceiptType, type MediaAsset, type MediaAssetUploadUrl, type MembershipBillingInterval, type MembershipExpiryType, type MembershipPassType, type MembershipPurchaseType, type MembershipSource, type MembershipStatus, type MerchPurchase, type Moment, type MomentCategory, type MomentCollection, type MomentCollectionLink, type MomentDiscountCodeUsage, type MomentDynamicPricingPolicy, type MomentDynamicPricingTierRule, type MomentLineup, type MomentLineupDisplayLabel, type MomentLineupResponseResult, type MomentLineupStatus, type MomentLineupType, type MomentOccurrenceScheduleFrequency, type MomentOnlineProvider, type MomentPublicVenuePreview, type MomentSortOrder, type MomentStatus, type MomentSubcategory, type MomentTagAssignment, type MomentType, type MusicReleaseType, type Mutation, type PaginationInput, type PartnerAppLogin, type PartnerAppLoginChallenge, type PartnerAppLoginProfile, type PartnerAudienceCustomer, type PartnerAudienceFiltersInput, type PartnerAudienceSortField, type PartnerAudienceSortInput, type PartnerBrand, type PartnerCustomer, type PartnerMember, type PartnerMemberCustomer, type PartnerMemberTier, type PartnerMembershipTier, type PartnerMomentAttendanceCount, type PartnerMomentAttendanceLookupInput, type PartnerMomentAttendanceStats, type PartnerMomentGuestlistAttendance, type PartnerMomentGuestlistLabelAttendance, type PartnerMomentStats, type PartnerMomentTicketAttendance, type PartnerMomentTicketTierAttendance, type PartnerMomentsFiltersInput, type PartnerTicketStatus, type PartnerTicketTier, type PartnerTicketTierUpdateInput, type PartnerTicketUserLookupInput, type PartnerTicketsForUserInput, type Payment, type PaymentStatus, type Plan, type PlanBudget, type PlanBudgetAllocationType, type PlanBudgetArtistDealBasis, type PlanBudgetArtistDealInput, type PlanBudgetArtistDealType, type PlanBudgetCapacityAllocationInput, type PlanBudgetCategoryInput, type PlanBudgetCategoryKind, type PlanBudgetChargeCalculation, type PlanBudgetChargeKind, type PlanBudgetChargeTreatment, type PlanBudgetExternalTicketingChannelInput, type PlanBudgetFeeAssessment, type PlanBudgetFeeComponentKind, type PlanBudgetFeePercentageBasis, type PlanBudgetGuaranteeBasis, type PlanBudgetLineBasis, type PlanBudgetLineInput, type PlanBudgetPaymentStatus, type PlanBudgetPricingMode, type PlanBudgetSummary, type PlanBudgetTicketChargeRuleInput, type PlanBudgetTicketTierInput, type PlanBudgetTicketingChannelType, type PlanBudgetTicketingFeeComponentInput, type PlanKind, type PlanLinkMetadataStatus, type PlanMoodboard, type PlanMoodboardItem, type PlanMoodboardItemType, type PlanSchedule, type PlanScheduleInput, type PlanScheduleTime, type PlanScheduleTimeInput, type PlanScheduleType, type PlanStatus, type PlanSummary, type PlanningProposal, type PlanningSource, type PlanningSourceDispositionInput, type PlanningSourceSection, type PostSubscriptionEmailInput, type PostSubscriptionMessageInput, type PostSubscriptionPushInput, type PostSubscriptionSmsInput, type PreparePlanningProposalInput, type PublicMomentLineupInfo, type Query, type ReplacePlanBudgetDraftInput, type RespondToMomentLineupInput, type SendPartnerAgentEmailInput, type SortDirection, type StartPartnerAppLoginInput, type SubscriptionComplianceInput, type Tag, type TagSource, type ThirdPartyEchoType, type Ticket, type TicketAdmissionWindowSource, type TicketAttendanceMode, type TicketExtension, type TicketExtensionStatus, type TicketTier, type Transforms, type UpdatePlanInput, type User, type UserSource, type Venue, type VenueInput, type VerifyPartnerAppLoginInput, type VerifyPartnerBrandSubscriptionInput, createITMPartnerClient, everything, generateMutationOp, generateQueryOp };
3765
+ export { type AgentThreadSeedContext, type ApplyDynamicPricingInput, type BrandAgentEmailMessageInput, type BrandAgentEmailSendBatch, type BrandAgentEmailSendBatchStatus, type BrandAgentEmailSendMessage, type BrandAgentEmailSendMessageStatus, type BrandApp, type BrandAppStatus, type BrandDrop, type BrandDropCtaType, type BrandDropMusicLink, type BrandSubscription, type CheckoutMarketingConsentInput, type CheckoutMarketingConsentPrompt, type ConsentChannel, type ConsentPromptCategory, type ConsentStatus, type ContributionAdmin, type ContributionPageAdmin, type ContributionPageStatusFilter, type ContributionPagesResponse, type ContributionSource, type ContributionStatus, type ContributionsResponse, type CreateBrandAppInput, type CreateManualContributionInput, type CreateMomentOnlineConfigInput, type CreatePartnerBrandDropInput, type CreatePartnerBrandSubscriptionInput, type CreatePartnerBrandSubscriptionResponse, type CreatePartnerMomentInput, type CreatePartnerTicketTierInput, type CreatePlanBudgetInput, type CreatePlanInput, type Currency, DEFAULT_API_URL, type Dimensions, type DimensionsInput, type DynamicPricingActorType, type DynamicPricingAdmissionWindow, type DynamicPricingBatch, type DynamicPricingBatchEvent, type DynamicPricingBatchEventType, type DynamicPricingBatchItem, type DynamicPricingBatchItemStatus, type DynamicPricingBatchStatus, type DynamicPricingContext, type DynamicPricingExecutionMode, type DynamicPricingInventoryGuardInput, type DynamicPricingInventoryGuardMode, type DynamicPricingInventoryMetric, type DynamicPricingMomentInput, type DynamicPricingTierContext, type DynamicPricingTierUpdateInput, type Echo, type EchoMediaAsset, type EchoType, type EditPartnerTicketTiersForMomentInput, type EventImportPlatform, GenqlError, type GetBrandEchoesForUserResponse, type GetMomentLineupsResponse, type GetMomentTagAssignmentsResponse, type GetPartnerAudienceInput, type GetPartnerAudienceResponse, type GetPartnerCustomersResponse, type GetPartnerDropsResponse, type GetPartnerMediaAssetsInput, type GetPartnerMediaAssetsResponse, type GetPartnerMembersInput, type GetPartnerMembersResponse, type GetPartnerMembershipTiersInput, type GetPartnerMembershipTiersResponse, type GetPartnerTicketTiersForMomentInput, type GetPartnerTicketTiersForMomentResponse, type GetPlansInput, type GetPlansResponse, type GetPublicMomentsResponse, type GetTicketsResponse, type ITMPartnerAgentAccessConfig, type ITMPartnerAgentAccessCredentials, type ITMPartnerAgentSessionConfig, type ITMPartnerAgentSessionCredentials, type ITMPartnerClient, type ITMPartnerClientConfig, type ITMPartnerHeaders, type ITMPartnerHeadersObject, type ITMPartnerIntegrationConfig, type ITMPartnerIntegrationCredentials, type ITMPartnerTokenConfig, ITMPartnerTransportError, type LoginCodeChannel, type ManualContributionReceiptType, type MediaAsset, type MediaAssetUploadUrl, type MembershipBillingInterval, type MembershipExpiryType, type MembershipPassType, type MembershipPurchaseType, type MembershipSource, type MembershipStatus, type MerchPurchase, type Moment, type MomentCategory, type MomentCollection, type MomentCollectionLink, type MomentDiscountCodeUsage, type MomentDynamicPricingPolicy, type MomentDynamicPricingTierRule, type MomentLineup, type MomentLineupDisplayLabel, type MomentLineupResponseResult, type MomentLineupStatus, type MomentLineupType, type MomentOccurrenceScheduleFrequency, type MomentOnlineProvider, type MomentPublicVenuePreview, type MomentSortOrder, type MomentStatus, type MomentSubcategory, type MomentTagAssignment, type MomentType, type MusicReleaseType, type Mutation, type PaginationInput, type PartnerAppLogin, type PartnerAppLoginChallenge, type PartnerAppLoginProfile, type PartnerAudienceCustomer, type PartnerAudienceFiltersInput, type PartnerAudienceSortField, type PartnerAudienceSortInput, type PartnerBrand, type PartnerCustomer, type PartnerMember, type PartnerMemberCustomer, type PartnerMemberTier, type PartnerMembershipTier, type PartnerMomentAttendanceCount, type PartnerMomentAttendanceLookupInput, type PartnerMomentAttendanceStats, type PartnerMomentGuestlistAttendance, type PartnerMomentGuestlistLabelAttendance, type PartnerMomentStats, type PartnerMomentTicketAttendance, type PartnerMomentTicketTierAttendance, type PartnerMomentsFiltersInput, type PartnerTicketStatus, type PartnerTicketTier, type PartnerTicketTierUpdateInput, type PartnerTicketUserLookupInput, type PartnerTicketsForUserInput, type Payment, type PaymentStatus, type Plan, type PlanBudget, type PlanBudgetAllocationType, type PlanBudgetArtistDealBasis, type PlanBudgetArtistDealInput, type PlanBudgetArtistDealType, type PlanBudgetCapacityAllocationInput, type PlanBudgetCategoryInput, type PlanBudgetCategoryKind, type PlanBudgetChargeCalculation, type PlanBudgetChargeKind, type PlanBudgetChargeTreatment, type PlanBudgetExternalTicketingChannelInput, type PlanBudgetFeeAssessment, type PlanBudgetFeeComponentKind, type PlanBudgetFeePercentageBasis, type PlanBudgetGuaranteeBasis, type PlanBudgetLineBasis, type PlanBudgetLineInput, type PlanBudgetPaymentStatus, type PlanBudgetPricingMode, type PlanBudgetSummary, type PlanBudgetTicketChargeRuleInput, type PlanBudgetTicketTierInput, type PlanBudgetTicketingChannelType, type PlanBudgetTicketingFeeComponentInput, type PlanKind, type PlanLinkMetadataStatus, type PlanMoodboard, type PlanMoodboardItem, type PlanMoodboardItemType, type PlanSchedule, type PlanScheduleInput, type PlanScheduleTime, type PlanScheduleTimeInput, type PlanScheduleType, type PlanStatus, type PlanSummary, type PlanningProposal, type PlanningSource, type PlanningSourceDispositionInput, type PlanningSourceSection, type PostSubscriptionEmailInput, type PostSubscriptionMessageInput, type PostSubscriptionPushInput, type PostSubscriptionSmsInput, type PreparePlanningProposalInput, type PublicMomentLineupInfo, type Query, type ReplacePlanBudgetDraftInput, type RespondToMomentLineupInput, type SendPartnerAgentEmailInput, type SortDirection, type StartPartnerAppLoginInput, type SubscriptionComplianceInput, type Tag, type TagSource, type ThirdPartyEchoType, type Ticket, type TicketAdmissionWindowSource, type TicketAttendanceMode, type TicketExtension, type TicketExtensionStatus, type TicketTier, type Transforms, type UpdatePlanInput, type User, type UserSource, type Venue, type VenueInput, type VerifyPartnerAppLoginInput, type VerifyPartnerBrandSubscriptionInput, createITMPartnerClient, everything, generateMutationOp, generateQueryOp };
package/dist/index.js CHANGED
@@ -5382,24 +5382,46 @@ assertNodeServerRuntime();
5382
5382
  var DEFAULT_API_URL = "https://itm-backend-production.up.railway.app/graphql";
5383
5383
  var RESERVED_AGENT_HEADERS = /* @__PURE__ */ new Set([
5384
5384
  "authorization",
5385
+ "x-itm-integration-access-token",
5385
5386
  "x-itm-agent-session-id",
5386
5387
  "x-itm-agent-bootstrap-token",
5387
5388
  "x-itm-agent-access-token",
5388
5389
  "x-partner-api-key"
5389
5390
  ]);
5390
5391
  function createITMPartnerClient(config) {
5391
- const { baseUrl, headers: extraHeaders } = config;
5392
+ const { baseUrl, headers: extraHeaders, signal } = config;
5392
5393
  const token = "token" in config ? config.token : void 0;
5393
5394
  const agentSession = "agentSession" in config ? config.agentSession : void 0;
5394
5395
  const agentAccess = "agentAccess" in config ? config.agentAccess : void 0;
5395
- const providedModes = [token, agentSession, agentAccess].filter(
5396
+ const integration = "integration" in config ? config.integration : void 0;
5397
+ const providedModes = [token, agentSession, agentAccess, integration].filter(
5396
5398
  (mode) => mode !== void 0
5397
5399
  );
5398
5400
  if (providedModes.length > 1) {
5399
5401
  throw new Error(
5400
- "ITM Partner SDK: provide exactly one of token, agentSession, or agentAccess authentication."
5402
+ "ITM Partner SDK: provide exactly one of token, agentSession, agentAccess, or integration authentication."
5401
5403
  );
5402
5404
  }
5405
+ if (integration !== void 0) {
5406
+ if (typeof integration.accessToken !== "function" && (typeof integration.accessToken !== "string" || !integration.accessToken.trim())) {
5407
+ throw new Error("ITM Partner SDK: integration.accessToken is required.");
5408
+ }
5409
+ return createSafeClient({
5410
+ url: baseUrl ?? DEFAULT_API_URL,
5411
+ signal,
5412
+ headers: async () => {
5413
+ const extra = typeof extraHeaders === "function" ? await extraHeaders() : extraHeaders;
5414
+ let credential;
5415
+ try {
5416
+ credential = typeof integration.accessToken === "function" ? await integration.accessToken() : integration.accessToken;
5417
+ } catch {
5418
+ throw new Error("ITM Partner SDK: integration credential is unavailable.");
5419
+ }
5420
+ if (typeof credential !== "string" || !credential.trim()) throw new Error("ITM Partner SDK: integration credential is unavailable.");
5421
+ return { ...sanitizeHeaders(extra), "x-itm-integration-access-token": credential, "Content-Type": "application/json" };
5422
+ }
5423
+ });
5424
+ }
5403
5425
  if (agentAccess !== void 0) {
5404
5426
  if (typeof agentAccess.workloadToken !== "function") {
5405
5427
  throw new Error(
@@ -5409,8 +5431,9 @@ function createITMPartnerClient(config) {
5409
5431
  if (!agentAccess.accessToken) {
5410
5432
  throw new Error("ITM Partner SDK: agentAccess.accessToken is required.");
5411
5433
  }
5412
- return createClient2({
5434
+ return createSafeClient({
5413
5435
  url: baseUrl ?? DEFAULT_API_URL,
5436
+ signal,
5414
5437
  headers: async () => {
5415
5438
  const resolvedExtraHeaders = typeof extraHeaders === "function" ? await extraHeaders() : extraHeaders;
5416
5439
  const sanitizedExtraHeaders = Object.fromEntries(
@@ -5442,8 +5465,9 @@ function createITMPartnerClient(config) {
5442
5465
  if (!agentSession.sessionUid) {
5443
5466
  throw new Error("ITM Partner SDK: agentSession.sessionUid is required.");
5444
5467
  }
5445
- return createClient2({
5468
+ return createSafeClient({
5446
5469
  url: baseUrl ?? DEFAULT_API_URL,
5470
+ signal,
5447
5471
  headers: async () => {
5448
5472
  const resolvedExtraHeaders = typeof extraHeaders === "function" ? await extraHeaders() : extraHeaders;
5449
5473
  const sanitizedExtraHeaders = Object.fromEntries(
@@ -5472,21 +5496,80 @@ function createITMPartnerClient(config) {
5472
5496
  "ITM Partner SDK: token is required. Get one from backstage: Settings > Partner API."
5473
5497
  );
5474
5498
  }
5475
- return createClient2({
5499
+ return createSafeClient({
5476
5500
  url: baseUrl ?? DEFAULT_API_URL,
5501
+ signal,
5477
5502
  headers: async () => {
5478
5503
  const resolvedExtraHeaders = typeof extraHeaders === "function" ? await extraHeaders() : extraHeaders;
5479
5504
  return {
5480
- ...resolvedExtraHeaders ?? {},
5505
+ ...sanitizeHeaders(resolvedExtraHeaders),
5481
5506
  "x-partner-api-key": token,
5482
5507
  "Content-Type": "application/json"
5483
5508
  };
5484
5509
  }
5485
5510
  });
5486
5511
  }
5512
+ function sanitizeHeaders(headers) {
5513
+ return Object.fromEntries(Object.entries(headers ?? {}).filter(([name]) => !RESERVED_AGENT_HEADERS.has(name.toLowerCase())));
5514
+ }
5515
+ var ITMPartnerTransportError = class extends Error {
5516
+ constructor(status, requestId) {
5517
+ super(status ? `ITM Partner API request failed (HTTP ${status}).` : "ITM Partner API request failed.");
5518
+ this.status = status;
5519
+ this.requestId = requestId;
5520
+ }
5521
+ name = "ITMPartnerTransportError";
5522
+ };
5523
+ function createSafeClient(options) {
5524
+ return createClient2({ fetcher: async (operation) => {
5525
+ options.signal?.throwIfAborted();
5526
+ const headers = await withCancellation(options.headers, options.signal);
5527
+ options.signal?.throwIfAborted();
5528
+ let response;
5529
+ try {
5530
+ response = await fetch(options.url, { method: "POST", headers, body: JSON.stringify(operation), signal: options.signal, redirect: "error" });
5531
+ } catch {
5532
+ options.signal?.throwIfAborted();
5533
+ throw new ITMPartnerTransportError(void 0);
5534
+ }
5535
+ if (!response.ok) throw new ITMPartnerTransportError(response.status, response.headers.get("x-request-id") ?? void 0);
5536
+ let value;
5537
+ try {
5538
+ value = await response.json();
5539
+ } catch {
5540
+ options.signal?.throwIfAborted();
5541
+ throw new ITMPartnerTransportError(response.status);
5542
+ }
5543
+ if (!value || typeof value !== "object" || !("data" in value || "errors" in value)) throw new ITMPartnerTransportError(response.status);
5544
+ const result = value;
5545
+ const secrets = Object.entries(headers).filter(([key]) => RESERVED_AGENT_HEADERS.has(key.toLowerCase())).flatMap(([, v]) => [v, v.replace(/^Bearer /i, "")]).filter(Boolean);
5546
+ const redact = (message) => secrets.reduce((text, secret) => text.split(secret).join("[redacted]"), message);
5547
+ if (result.errors) result.errors = result.errors.map((error) => ({ name: "GraphQLError", message: redact(typeof error.message === "string" ? error.message : "GraphQL request failed"), extensions: typeof error.extensions?.code === "string" ? { code: redact(error.extensions.code) } : void 0 }));
5548
+ return result;
5549
+ } });
5550
+ }
5551
+ async function withCancellation(operation, signal) {
5552
+ signal?.throwIfAborted();
5553
+ if (!signal) return operation();
5554
+ let abort = () => {
5555
+ };
5556
+ try {
5557
+ return await Promise.race([
5558
+ operation(),
5559
+ new Promise((_resolve, reject) => {
5560
+ abort = () => reject(signal.reason);
5561
+ signal.addEventListener("abort", abort, { once: true });
5562
+ if (signal.aborted) abort();
5563
+ })
5564
+ ]);
5565
+ } finally {
5566
+ signal.removeEventListener("abort", abort);
5567
+ }
5568
+ }
5487
5569
 
5488
5570
  exports.DEFAULT_API_URL = DEFAULT_API_URL;
5489
5571
  exports.GenqlError = GenqlError;
5572
+ exports.ITMPartnerTransportError = ITMPartnerTransportError;
5490
5573
  exports.createITMPartnerClient = createITMPartnerClient;
5491
5574
  exports.everything = everything;
5492
5575
  exports.generateMutationOp = generateMutationOp;