@itm-studio/partner-sdk 0.4.2 → 0.5.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
@@ -2713,3 +2713,22 @@ receipt eligibility. Omit it for no receipt. `userUid` is populated when entered
2713
2713
  email or phone matches a current verified ITM identity; unmatched contacts do not
2714
2714
  create an account, and conflicting matches are rejected. `source` distinguishes
2715
2715
  `STRIPE`, `OFF_SITE`, and in-person `POS` independently of payment status.
2716
+
2717
+ ### Delegated integration credentials (MCP)
2718
+
2719
+ 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.
2720
+
2721
+ ```ts
2722
+ const client = createITMPartnerClient({
2723
+ baseUrl: process.env.ITM_PARTNER_API_ORIGIN,
2724
+ integration: { accessToken: async () => requestScopedApiCredential },
2725
+ signal: request.signal,
2726
+ });
2727
+ const { getPartnerBrand } = await client.query({
2728
+ getPartnerBrand: { uid: true, name: true, slug: true, publicUrl: true },
2729
+ });
2730
+ ```
2731
+
2732
+ 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`.
2733
+
2734
+ 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
@@ -3621,6 +3621,8 @@ interface ITMPartnerTokenConfig {
3621
3621
  * @default DEFAULT_API_URL
3622
3622
  */
3623
3623
  baseUrl?: string;
3624
+ /** Cancellation for this request-scoped client. */
3625
+ signal?: AbortSignal;
3624
3626
  /**
3625
3627
  * Additional headers to include on every request.
3626
3628
  * A function is useful for request-scoped values like `x-forwarded-for`
@@ -3659,6 +3661,8 @@ interface ITMPartnerAgentSessionConfig {
3659
3661
  * @default DEFAULT_API_URL
3660
3662
  */
3661
3663
  baseUrl?: string;
3664
+ /** Cancellation for this request-scoped client. */
3665
+ signal?: AbortSignal;
3662
3666
  /**
3663
3667
  * Additional headers to include on every request. Credential headers
3664
3668
  * always take precedence and cannot be overridden.
@@ -3692,13 +3696,25 @@ interface ITMPartnerAgentAccessConfig {
3692
3696
  * @default DEFAULT_API_URL
3693
3697
  */
3694
3698
  baseUrl?: string;
3699
+ /** Cancellation for this request-scoped client. */
3700
+ signal?: AbortSignal;
3695
3701
  /**
3696
3702
  * Additional headers to include on every request. Credential headers
3697
3703
  * always take precedence and cannot be overridden.
3698
3704
  */
3699
3705
  headers?: ITMPartnerHeaders;
3700
3706
  }
3701
- type ITMPartnerClientConfig = ITMPartnerTokenConfig | ITMPartnerAgentSessionConfig | ITMPartnerAgentAccessConfig;
3707
+ interface ITMPartnerIntegrationCredentials {
3708
+ /** Short-lived API credential supplied by the caller, resolved afresh per request. */
3709
+ accessToken: string | (() => MaybePromise<string>);
3710
+ }
3711
+ interface ITMPartnerIntegrationConfig {
3712
+ integration: ITMPartnerIntegrationCredentials;
3713
+ baseUrl?: string;
3714
+ headers?: ITMPartnerHeaders;
3715
+ signal?: AbortSignal;
3716
+ }
3717
+ type ITMPartnerClientConfig = ITMPartnerIntegrationConfig | ITMPartnerTokenConfig | ITMPartnerAgentSessionConfig | ITMPartnerAgentAccessConfig;
3702
3718
  type ITMPartnerClient = Client;
3703
3719
  /**
3704
3720
  * Create a typed ITM Partner API client.
@@ -3730,5 +3746,12 @@ type ITMPartnerClient = Client;
3730
3746
  * ```
3731
3747
  */
3732
3748
  declare function createITMPartnerClient(config: ITMPartnerClientConfig): ITMPartnerClient;
3749
+ /** HTTP errors retain status without copying response bodies or credentials. */
3750
+ declare class ITMPartnerTransportError extends Error {
3751
+ readonly status: number | undefined;
3752
+ readonly requestId?: string | undefined;
3753
+ readonly name = "ITMPartnerTransportError";
3754
+ constructor(status: number | undefined, requestId?: string | undefined);
3755
+ }
3733
3756
 
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 };
3757
+ 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
@@ -3621,6 +3621,8 @@ interface ITMPartnerTokenConfig {
3621
3621
  * @default DEFAULT_API_URL
3622
3622
  */
3623
3623
  baseUrl?: string;
3624
+ /** Cancellation for this request-scoped client. */
3625
+ signal?: AbortSignal;
3624
3626
  /**
3625
3627
  * Additional headers to include on every request.
3626
3628
  * A function is useful for request-scoped values like `x-forwarded-for`
@@ -3659,6 +3661,8 @@ interface ITMPartnerAgentSessionConfig {
3659
3661
  * @default DEFAULT_API_URL
3660
3662
  */
3661
3663
  baseUrl?: string;
3664
+ /** Cancellation for this request-scoped client. */
3665
+ signal?: AbortSignal;
3662
3666
  /**
3663
3667
  * Additional headers to include on every request. Credential headers
3664
3668
  * always take precedence and cannot be overridden.
@@ -3692,13 +3696,25 @@ interface ITMPartnerAgentAccessConfig {
3692
3696
  * @default DEFAULT_API_URL
3693
3697
  */
3694
3698
  baseUrl?: string;
3699
+ /** Cancellation for this request-scoped client. */
3700
+ signal?: AbortSignal;
3695
3701
  /**
3696
3702
  * Additional headers to include on every request. Credential headers
3697
3703
  * always take precedence and cannot be overridden.
3698
3704
  */
3699
3705
  headers?: ITMPartnerHeaders;
3700
3706
  }
3701
- type ITMPartnerClientConfig = ITMPartnerTokenConfig | ITMPartnerAgentSessionConfig | ITMPartnerAgentAccessConfig;
3707
+ interface ITMPartnerIntegrationCredentials {
3708
+ /** Short-lived API credential supplied by the caller, resolved afresh per request. */
3709
+ accessToken: string | (() => MaybePromise<string>);
3710
+ }
3711
+ interface ITMPartnerIntegrationConfig {
3712
+ integration: ITMPartnerIntegrationCredentials;
3713
+ baseUrl?: string;
3714
+ headers?: ITMPartnerHeaders;
3715
+ signal?: AbortSignal;
3716
+ }
3717
+ type ITMPartnerClientConfig = ITMPartnerIntegrationConfig | ITMPartnerTokenConfig | ITMPartnerAgentSessionConfig | ITMPartnerAgentAccessConfig;
3702
3718
  type ITMPartnerClient = Client;
3703
3719
  /**
3704
3720
  * Create a typed ITM Partner API client.
@@ -3730,5 +3746,12 @@ type ITMPartnerClient = Client;
3730
3746
  * ```
3731
3747
  */
3732
3748
  declare function createITMPartnerClient(config: ITMPartnerClientConfig): ITMPartnerClient;
3749
+ /** HTTP errors retain status without copying response bodies or credentials. */
3750
+ declare class ITMPartnerTransportError extends Error {
3751
+ readonly status: number | undefined;
3752
+ readonly requestId?: string | undefined;
3753
+ readonly name = "ITMPartnerTransportError";
3754
+ constructor(status: number | undefined, requestId?: string | undefined);
3755
+ }
3733
3756
 
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 };
3757
+ 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;