@heymantle/core-api-client 0.4.5 → 0.5.1

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/dist/index.d.mts CHANGED
@@ -16810,6 +16810,21 @@ type components = {
16810
16810
  status?: string;
16811
16811
  title?: string;
16812
16812
  };
16813
+ /** @description The associated timeline comment (for comment events). */
16814
+ timelineComment?: {
16815
+ comment?: string | null;
16816
+ commentHtml?: string | null;
16817
+ /** Format: date-time */
16818
+ createdAt?: string;
16819
+ id?: string;
16820
+ /** Format: date-time */
16821
+ updatedAt?: string;
16822
+ user?: {
16823
+ email?: string;
16824
+ id?: string;
16825
+ name?: string;
16826
+ } | null;
16827
+ } | null;
16813
16828
  /** @description The type of event (stage_progression, deal_activity, note, etc.). */
16814
16829
  type?: string;
16815
16830
  /** @description The user who created/performed the event. */
@@ -19408,15 +19423,6 @@ type components = {
19408
19423
  pathItems: never;
19409
19424
  };
19410
19425
 
19411
- /**
19412
- * Result returned by the refreshAccessToken callback.
19413
- */
19414
- interface TokenRefreshResult {
19415
- /** The new access token */
19416
- accessToken: string;
19417
- /** When the new token expires. Used for preemptive refresh on subsequent requests. */
19418
- expiresAt?: Date;
19419
- }
19420
19426
  /**
19421
19427
  * Configuration for the MantleCoreClient
19422
19428
  */
@@ -19427,21 +19433,6 @@ interface MantleCoreClientConfig {
19427
19433
  apiKey?: string;
19428
19434
  /** OAuth access token for authentication */
19429
19435
  accessToken?: string;
19430
- /**
19431
- * When the access token expires. If set, the client will proactively
19432
- * call refreshAccessToken before sending a request with an expired token.
19433
- */
19434
- accessTokenExpiresAt?: Date;
19435
- /**
19436
- * Callback to obtain a fresh access token. Called automatically when:
19437
- * - accessTokenExpiresAt is in the past (preemptive, before the request)
19438
- * - A 401 response is received for an expired/revoked token (reactive)
19439
- *
19440
- * The callback owns the full refresh lifecycle: look up the refresh token,
19441
- * call the auth server, persist the new credentials, and return the new
19442
- * access token. Concurrent requests will share a single in-flight refresh.
19443
- */
19444
- refreshAccessToken?: () => Promise<TokenRefreshResult>;
19445
19436
  /** Request timeout in milliseconds. Defaults to 30000 */
19446
19437
  timeout?: number;
19447
19438
  /** openapi-fetch middleware to register on instantiation */
@@ -22650,6 +22641,18 @@ declare class DealsResource extends BaseResource {
22650
22641
  status?: string | undefined;
22651
22642
  title?: string | undefined;
22652
22643
  } | undefined;
22644
+ timelineComment?: {
22645
+ comment?: string | null | undefined;
22646
+ commentHtml?: string | null | undefined;
22647
+ createdAt?: string | undefined;
22648
+ id?: string | undefined;
22649
+ updatedAt?: string | undefined;
22650
+ user?: {
22651
+ email?: string | undefined;
22652
+ id?: string | undefined;
22653
+ name?: string | undefined;
22654
+ } | null | undefined;
22655
+ } | null | undefined;
22653
22656
  type?: string | undefined;
22654
22657
  user?: {
22655
22658
  email?: string | undefined;
@@ -22817,6 +22820,18 @@ declare class DealsResource extends BaseResource {
22817
22820
  status?: string | undefined;
22818
22821
  title?: string | undefined;
22819
22822
  } | undefined;
22823
+ timelineComment?: {
22824
+ comment?: string | null | undefined;
22825
+ commentHtml?: string | null | undefined;
22826
+ createdAt?: string | undefined;
22827
+ id?: string | undefined;
22828
+ updatedAt?: string | undefined;
22829
+ user?: {
22830
+ email?: string | undefined;
22831
+ id?: string | undefined;
22832
+ name?: string | undefined;
22833
+ } | null | undefined;
22834
+ } | null | undefined;
22820
22835
  type?: string | undefined;
22821
22836
  user?: {
22822
22837
  email?: string | undefined;
@@ -23107,6 +23122,18 @@ declare class DealsResource extends BaseResource {
23107
23122
  status?: string | undefined;
23108
23123
  title?: string | undefined;
23109
23124
  } | undefined;
23125
+ timelineComment?: {
23126
+ comment?: string | null | undefined;
23127
+ commentHtml?: string | null | undefined;
23128
+ createdAt?: string | undefined;
23129
+ id?: string | undefined;
23130
+ updatedAt?: string | undefined;
23131
+ user?: {
23132
+ email?: string | undefined;
23133
+ id?: string | undefined;
23134
+ name?: string | undefined;
23135
+ } | null | undefined;
23136
+ } | null | undefined;
23110
23137
  type?: string | undefined;
23111
23138
  user?: {
23112
23139
  email?: string | undefined;
@@ -27515,9 +27542,6 @@ declare class MantleCoreClient {
27515
27542
  readonly _api: Client<paths>;
27516
27543
  private apiKey?;
27517
27544
  private accessToken?;
27518
- private accessTokenExpiresAt?;
27519
- private refreshAccessToken?;
27520
- private refreshPromise?;
27521
27545
  readonly affiliateCommissions: AffiliateCommissionsResource;
27522
27546
  readonly affiliatePayouts: AffiliatePayoutsResource;
27523
27547
  readonly affiliatePrograms: AffiliateProgramsResource;
@@ -27571,22 +27595,12 @@ declare class MantleCoreClient {
27571
27595
  */
27572
27596
  eject(middleware: Middleware): this;
27573
27597
  /**
27574
- * Update authentication credentials
27598
+ * Update authentication credentials at runtime.
27575
27599
  */
27576
27600
  updateAuth(credentials: {
27577
27601
  apiKey?: string;
27578
27602
  accessToken?: string;
27579
- accessTokenExpiresAt?: Date;
27580
27603
  }): void;
27581
- /**
27582
- * Check if the access token is expired (with a 30-second buffer).
27583
- */
27584
- private isTokenExpired;
27585
- /**
27586
- * Execute a token refresh, deduplicating concurrent calls.
27587
- * All concurrent requests will await the same in-flight refresh promise.
27588
- */
27589
- private doRefresh;
27590
27604
  }
27591
27605
 
27592
27606
  type AccountOwner = components['schemas']['AccountOwner'];
@@ -27836,4 +27850,4 @@ interface RateLimitOptions {
27836
27850
  */
27837
27851
  declare function createRateLimitMiddleware(options?: RateLimitOptions): Middleware;
27838
27852
 
27839
- export { type AccountOwner, type AccountOwnerType, type Action, type ActiveSubscriptionsResponse, type Affiliate, type AffiliateAttributionWebhook, type AffiliateCommission, AffiliateCommissionsResource, type AffiliateMembershipWebhook, type AffiliatePayout, type AffiliatePayoutWebhook, AffiliatePayoutsResource, type AffiliateProgram, type AffiliateProgramGroup, type AffiliateProgramMembership, type AffiliateProgramWebhook, AffiliateProgramsResource, type AffiliateReferral, AffiliateReferralsResource, type AffiliateRules, type AffiliateRulesWebhook, type AffiliateWebhook, AffiliatesResource, type Agent, type AgentRun, AgentsResource, AiAgentRunsResource, type App, type AppChargeWebhook, type AppEvent, type AppInstallation, type AppInstallationWebhook, type AppWebhook, AppsResource, type BaseCustomerWebhook, BaseResource, ChannelsResource, type Charge, ChargesResource, type Checklist, type ChecklistStep, CompaniesResource, type Company, type Contact, type ContactWebhook, ContactsResource, type CursorPagination, CustomDataResource, type CustomField, type CustomFieldDefaultValue, type Customer, type CustomerContact, type CustomerContactWebhook, type CustomerSegment, CustomerSegmentsResource, type CustomerWebhook, type CustomerWithoutSubscriptionWebhook, CustomersResource, type Deal, type DealAcquirer, DealActivitiesResource, type DealActivity, type DealAffiliate, type DealApp, type DealContact, type DealCustomData, type DealCustomer, type DealEvent, type DealFlow, type DealFlowAffiliate, type DealFlowDefaultSource, type DealFlowPartnership, type DealFlowStage, type DealFlowUser, DealFlowsResource, type DealOwner, type DealPartnership, type DealPlan, type DealStage, DealsResource, type DetailedAffiliate, type DetailedFlow, type DocsCollection, type DocsCollectionResponse, type DocsGenerateJobResponse, type DocsGenerateStatusCompleted, type DocsGenerateStatusFailed, type DocsGenerateStatusPending, type DocsGroup, type DocsGroupResponse, type DocsPage, type DocsPageResponse, type DocsPageSummary, type DocsRepository, DocsResource, type EmailCampaign, type EmailDelivery, type EmailDeliveryStats, type EmailLayout, type EmailPreview, type EmailSender, type EmailUnsubscribeGroup, type EmailUnsubscribeGroupMember, EmailUnsubscribeGroupsResource, EntitiesResource, type EventWebhook, type ExtensionUninstallPayload, type ExtensionWebhook, type Feature, type Flow, type FlowActionRun, FlowExtensionsResource, FlowsResource, type InvalidTokenError, type Invoice, type InvoiceWebhook, JournalEntriesResource, type JournalEntry, type JournalEntryApp, type JournalEntryFile, type List, ListsResource, type LogoChurnResponse, MantleAPIError, MantleAuthenticationError, MantleCoreClient, type MantleCoreClientConfig, MantleNotFoundError, MantlePermissionError, MantleRateLimitError, MantleValidationError, MeResource, type Meeting, type MeetingAttendee, type MeetingAttendeeRef, type MeetingContactRef, type MeetingCustomer, type MeetingDeal, type MeetingPermission, type MeetingTaskSuggestion, type MeetingTranscript, type MeetingUser, type MeetingUtterance, MeetingsResource, MetricsResource, type MissingScopesError, type MrrResponse, type NetInstallsResponse, type NetRevenueResponse, type NetRevenueRetentionResponse, type Organization, OrganizationResource, type Pagination, type PayoutResponse, type Plan, type PlanFeature, type PlanFeatureWebhook, type PlanUsageChargeWebhook, type PlanWebhook, type PredictedLtvResponse, type RateLimitOptions, type RevenueRetentionResponse, type Review, type ReviewWebhook, type StandardMetricResponse, type Subscription, type SubscriptionWebhook, SubscriptionsResource, type SyncedEmail, type SyncedEmailContact, type SyncedEmailCustomer, type SyncedEmailDeal, type SyncedEmailMessage, type SyncedEmailUser, SyncedEmailsResource, type Task, type TaskComment, type TaskTodoItem, TasksResource, type ThreadEventType, type ThreadMessageWebhook, type ThreadWebhook, type Ticket, type TicketAgent, type TicketApp, type TicketAttachment, type TicketChannel, type TicketContact, type TicketCustomer, type TicketEvent, type TicketLoop, type TicketMessage, TicketsResource, type TimeSeriesDataPoint, type TimelineComment, TimelineCommentsResource, type TokenRefreshResult, type Transaction, type TransactionWebhook, TransactionsResource, type Trigger, type UninstallEventWebhook, type UsageEvent, type UsageEventResponse, UsageEventsResource, type UsageMetric, type UsageMetricResponse, type User, UsersResource, type Webhook, WebhooksResource, type components, createRateLimitMiddleware, type paths };
27853
+ export { type AccountOwner, type AccountOwnerType, type Action, type ActiveSubscriptionsResponse, type Affiliate, type AffiliateAttributionWebhook, type AffiliateCommission, AffiliateCommissionsResource, type AffiliateMembershipWebhook, type AffiliatePayout, type AffiliatePayoutWebhook, AffiliatePayoutsResource, type AffiliateProgram, type AffiliateProgramGroup, type AffiliateProgramMembership, type AffiliateProgramWebhook, AffiliateProgramsResource, type AffiliateReferral, AffiliateReferralsResource, type AffiliateRules, type AffiliateRulesWebhook, type AffiliateWebhook, AffiliatesResource, type Agent, type AgentRun, AgentsResource, AiAgentRunsResource, type App, type AppChargeWebhook, type AppEvent, type AppInstallation, type AppInstallationWebhook, type AppWebhook, AppsResource, type BaseCustomerWebhook, BaseResource, ChannelsResource, type Charge, ChargesResource, type Checklist, type ChecklistStep, CompaniesResource, type Company, type Contact, type ContactWebhook, ContactsResource, type CursorPagination, CustomDataResource, type CustomField, type CustomFieldDefaultValue, type Customer, type CustomerContact, type CustomerContactWebhook, type CustomerSegment, CustomerSegmentsResource, type CustomerWebhook, type CustomerWithoutSubscriptionWebhook, CustomersResource, type Deal, type DealAcquirer, DealActivitiesResource, type DealActivity, type DealAffiliate, type DealApp, type DealContact, type DealCustomData, type DealCustomer, type DealEvent, type DealFlow, type DealFlowAffiliate, type DealFlowDefaultSource, type DealFlowPartnership, type DealFlowStage, type DealFlowUser, DealFlowsResource, type DealOwner, type DealPartnership, type DealPlan, type DealStage, DealsResource, type DetailedAffiliate, type DetailedFlow, type DocsCollection, type DocsCollectionResponse, type DocsGenerateJobResponse, type DocsGenerateStatusCompleted, type DocsGenerateStatusFailed, type DocsGenerateStatusPending, type DocsGroup, type DocsGroupResponse, type DocsPage, type DocsPageResponse, type DocsPageSummary, type DocsRepository, DocsResource, type EmailCampaign, type EmailDelivery, type EmailDeliveryStats, type EmailLayout, type EmailPreview, type EmailSender, type EmailUnsubscribeGroup, type EmailUnsubscribeGroupMember, EmailUnsubscribeGroupsResource, EntitiesResource, type EventWebhook, type ExtensionUninstallPayload, type ExtensionWebhook, type Feature, type Flow, type FlowActionRun, FlowExtensionsResource, FlowsResource, type InvalidTokenError, type Invoice, type InvoiceWebhook, JournalEntriesResource, type JournalEntry, type JournalEntryApp, type JournalEntryFile, type List, ListsResource, type LogoChurnResponse, MantleAPIError, MantleAuthenticationError, MantleCoreClient, type MantleCoreClientConfig, MantleNotFoundError, MantlePermissionError, MantleRateLimitError, MantleValidationError, MeResource, type Meeting, type MeetingAttendee, type MeetingAttendeeRef, type MeetingContactRef, type MeetingCustomer, type MeetingDeal, type MeetingPermission, type MeetingTaskSuggestion, type MeetingTranscript, type MeetingUser, type MeetingUtterance, MeetingsResource, MetricsResource, type MissingScopesError, type MrrResponse, type NetInstallsResponse, type NetRevenueResponse, type NetRevenueRetentionResponse, type Organization, OrganizationResource, type Pagination, type PayoutResponse, type Plan, type PlanFeature, type PlanFeatureWebhook, type PlanUsageChargeWebhook, type PlanWebhook, type PredictedLtvResponse, type RateLimitOptions, type RevenueRetentionResponse, type Review, type ReviewWebhook, type StandardMetricResponse, type Subscription, type SubscriptionWebhook, SubscriptionsResource, type SyncedEmail, type SyncedEmailContact, type SyncedEmailCustomer, type SyncedEmailDeal, type SyncedEmailMessage, type SyncedEmailUser, SyncedEmailsResource, type Task, type TaskComment, type TaskTodoItem, TasksResource, type ThreadEventType, type ThreadMessageWebhook, type ThreadWebhook, type Ticket, type TicketAgent, type TicketApp, type TicketAttachment, type TicketChannel, type TicketContact, type TicketCustomer, type TicketEvent, type TicketLoop, type TicketMessage, TicketsResource, type TimeSeriesDataPoint, type TimelineComment, TimelineCommentsResource, type Transaction, type TransactionWebhook, TransactionsResource, type Trigger, type UninstallEventWebhook, type UsageEvent, type UsageEventResponse, UsageEventsResource, type UsageMetric, type UsageMetricResponse, type User, UsersResource, type Webhook, WebhooksResource, type components, createRateLimitMiddleware, type paths };
package/dist/index.d.ts CHANGED
@@ -16810,6 +16810,21 @@ type components = {
16810
16810
  status?: string;
16811
16811
  title?: string;
16812
16812
  };
16813
+ /** @description The associated timeline comment (for comment events). */
16814
+ timelineComment?: {
16815
+ comment?: string | null;
16816
+ commentHtml?: string | null;
16817
+ /** Format: date-time */
16818
+ createdAt?: string;
16819
+ id?: string;
16820
+ /** Format: date-time */
16821
+ updatedAt?: string;
16822
+ user?: {
16823
+ email?: string;
16824
+ id?: string;
16825
+ name?: string;
16826
+ } | null;
16827
+ } | null;
16813
16828
  /** @description The type of event (stage_progression, deal_activity, note, etc.). */
16814
16829
  type?: string;
16815
16830
  /** @description The user who created/performed the event. */
@@ -19408,15 +19423,6 @@ type components = {
19408
19423
  pathItems: never;
19409
19424
  };
19410
19425
 
19411
- /**
19412
- * Result returned by the refreshAccessToken callback.
19413
- */
19414
- interface TokenRefreshResult {
19415
- /** The new access token */
19416
- accessToken: string;
19417
- /** When the new token expires. Used for preemptive refresh on subsequent requests. */
19418
- expiresAt?: Date;
19419
- }
19420
19426
  /**
19421
19427
  * Configuration for the MantleCoreClient
19422
19428
  */
@@ -19427,21 +19433,6 @@ interface MantleCoreClientConfig {
19427
19433
  apiKey?: string;
19428
19434
  /** OAuth access token for authentication */
19429
19435
  accessToken?: string;
19430
- /**
19431
- * When the access token expires. If set, the client will proactively
19432
- * call refreshAccessToken before sending a request with an expired token.
19433
- */
19434
- accessTokenExpiresAt?: Date;
19435
- /**
19436
- * Callback to obtain a fresh access token. Called automatically when:
19437
- * - accessTokenExpiresAt is in the past (preemptive, before the request)
19438
- * - A 401 response is received for an expired/revoked token (reactive)
19439
- *
19440
- * The callback owns the full refresh lifecycle: look up the refresh token,
19441
- * call the auth server, persist the new credentials, and return the new
19442
- * access token. Concurrent requests will share a single in-flight refresh.
19443
- */
19444
- refreshAccessToken?: () => Promise<TokenRefreshResult>;
19445
19436
  /** Request timeout in milliseconds. Defaults to 30000 */
19446
19437
  timeout?: number;
19447
19438
  /** openapi-fetch middleware to register on instantiation */
@@ -22650,6 +22641,18 @@ declare class DealsResource extends BaseResource {
22650
22641
  status?: string | undefined;
22651
22642
  title?: string | undefined;
22652
22643
  } | undefined;
22644
+ timelineComment?: {
22645
+ comment?: string | null | undefined;
22646
+ commentHtml?: string | null | undefined;
22647
+ createdAt?: string | undefined;
22648
+ id?: string | undefined;
22649
+ updatedAt?: string | undefined;
22650
+ user?: {
22651
+ email?: string | undefined;
22652
+ id?: string | undefined;
22653
+ name?: string | undefined;
22654
+ } | null | undefined;
22655
+ } | null | undefined;
22653
22656
  type?: string | undefined;
22654
22657
  user?: {
22655
22658
  email?: string | undefined;
@@ -22817,6 +22820,18 @@ declare class DealsResource extends BaseResource {
22817
22820
  status?: string | undefined;
22818
22821
  title?: string | undefined;
22819
22822
  } | undefined;
22823
+ timelineComment?: {
22824
+ comment?: string | null | undefined;
22825
+ commentHtml?: string | null | undefined;
22826
+ createdAt?: string | undefined;
22827
+ id?: string | undefined;
22828
+ updatedAt?: string | undefined;
22829
+ user?: {
22830
+ email?: string | undefined;
22831
+ id?: string | undefined;
22832
+ name?: string | undefined;
22833
+ } | null | undefined;
22834
+ } | null | undefined;
22820
22835
  type?: string | undefined;
22821
22836
  user?: {
22822
22837
  email?: string | undefined;
@@ -23107,6 +23122,18 @@ declare class DealsResource extends BaseResource {
23107
23122
  status?: string | undefined;
23108
23123
  title?: string | undefined;
23109
23124
  } | undefined;
23125
+ timelineComment?: {
23126
+ comment?: string | null | undefined;
23127
+ commentHtml?: string | null | undefined;
23128
+ createdAt?: string | undefined;
23129
+ id?: string | undefined;
23130
+ updatedAt?: string | undefined;
23131
+ user?: {
23132
+ email?: string | undefined;
23133
+ id?: string | undefined;
23134
+ name?: string | undefined;
23135
+ } | null | undefined;
23136
+ } | null | undefined;
23110
23137
  type?: string | undefined;
23111
23138
  user?: {
23112
23139
  email?: string | undefined;
@@ -27515,9 +27542,6 @@ declare class MantleCoreClient {
27515
27542
  readonly _api: Client<paths>;
27516
27543
  private apiKey?;
27517
27544
  private accessToken?;
27518
- private accessTokenExpiresAt?;
27519
- private refreshAccessToken?;
27520
- private refreshPromise?;
27521
27545
  readonly affiliateCommissions: AffiliateCommissionsResource;
27522
27546
  readonly affiliatePayouts: AffiliatePayoutsResource;
27523
27547
  readonly affiliatePrograms: AffiliateProgramsResource;
@@ -27571,22 +27595,12 @@ declare class MantleCoreClient {
27571
27595
  */
27572
27596
  eject(middleware: Middleware): this;
27573
27597
  /**
27574
- * Update authentication credentials
27598
+ * Update authentication credentials at runtime.
27575
27599
  */
27576
27600
  updateAuth(credentials: {
27577
27601
  apiKey?: string;
27578
27602
  accessToken?: string;
27579
- accessTokenExpiresAt?: Date;
27580
27603
  }): void;
27581
- /**
27582
- * Check if the access token is expired (with a 30-second buffer).
27583
- */
27584
- private isTokenExpired;
27585
- /**
27586
- * Execute a token refresh, deduplicating concurrent calls.
27587
- * All concurrent requests will await the same in-flight refresh promise.
27588
- */
27589
- private doRefresh;
27590
27604
  }
27591
27605
 
27592
27606
  type AccountOwner = components['schemas']['AccountOwner'];
@@ -27836,4 +27850,4 @@ interface RateLimitOptions {
27836
27850
  */
27837
27851
  declare function createRateLimitMiddleware(options?: RateLimitOptions): Middleware;
27838
27852
 
27839
- export { type AccountOwner, type AccountOwnerType, type Action, type ActiveSubscriptionsResponse, type Affiliate, type AffiliateAttributionWebhook, type AffiliateCommission, AffiliateCommissionsResource, type AffiliateMembershipWebhook, type AffiliatePayout, type AffiliatePayoutWebhook, AffiliatePayoutsResource, type AffiliateProgram, type AffiliateProgramGroup, type AffiliateProgramMembership, type AffiliateProgramWebhook, AffiliateProgramsResource, type AffiliateReferral, AffiliateReferralsResource, type AffiliateRules, type AffiliateRulesWebhook, type AffiliateWebhook, AffiliatesResource, type Agent, type AgentRun, AgentsResource, AiAgentRunsResource, type App, type AppChargeWebhook, type AppEvent, type AppInstallation, type AppInstallationWebhook, type AppWebhook, AppsResource, type BaseCustomerWebhook, BaseResource, ChannelsResource, type Charge, ChargesResource, type Checklist, type ChecklistStep, CompaniesResource, type Company, type Contact, type ContactWebhook, ContactsResource, type CursorPagination, CustomDataResource, type CustomField, type CustomFieldDefaultValue, type Customer, type CustomerContact, type CustomerContactWebhook, type CustomerSegment, CustomerSegmentsResource, type CustomerWebhook, type CustomerWithoutSubscriptionWebhook, CustomersResource, type Deal, type DealAcquirer, DealActivitiesResource, type DealActivity, type DealAffiliate, type DealApp, type DealContact, type DealCustomData, type DealCustomer, type DealEvent, type DealFlow, type DealFlowAffiliate, type DealFlowDefaultSource, type DealFlowPartnership, type DealFlowStage, type DealFlowUser, DealFlowsResource, type DealOwner, type DealPartnership, type DealPlan, type DealStage, DealsResource, type DetailedAffiliate, type DetailedFlow, type DocsCollection, type DocsCollectionResponse, type DocsGenerateJobResponse, type DocsGenerateStatusCompleted, type DocsGenerateStatusFailed, type DocsGenerateStatusPending, type DocsGroup, type DocsGroupResponse, type DocsPage, type DocsPageResponse, type DocsPageSummary, type DocsRepository, DocsResource, type EmailCampaign, type EmailDelivery, type EmailDeliveryStats, type EmailLayout, type EmailPreview, type EmailSender, type EmailUnsubscribeGroup, type EmailUnsubscribeGroupMember, EmailUnsubscribeGroupsResource, EntitiesResource, type EventWebhook, type ExtensionUninstallPayload, type ExtensionWebhook, type Feature, type Flow, type FlowActionRun, FlowExtensionsResource, FlowsResource, type InvalidTokenError, type Invoice, type InvoiceWebhook, JournalEntriesResource, type JournalEntry, type JournalEntryApp, type JournalEntryFile, type List, ListsResource, type LogoChurnResponse, MantleAPIError, MantleAuthenticationError, MantleCoreClient, type MantleCoreClientConfig, MantleNotFoundError, MantlePermissionError, MantleRateLimitError, MantleValidationError, MeResource, type Meeting, type MeetingAttendee, type MeetingAttendeeRef, type MeetingContactRef, type MeetingCustomer, type MeetingDeal, type MeetingPermission, type MeetingTaskSuggestion, type MeetingTranscript, type MeetingUser, type MeetingUtterance, MeetingsResource, MetricsResource, type MissingScopesError, type MrrResponse, type NetInstallsResponse, type NetRevenueResponse, type NetRevenueRetentionResponse, type Organization, OrganizationResource, type Pagination, type PayoutResponse, type Plan, type PlanFeature, type PlanFeatureWebhook, type PlanUsageChargeWebhook, type PlanWebhook, type PredictedLtvResponse, type RateLimitOptions, type RevenueRetentionResponse, type Review, type ReviewWebhook, type StandardMetricResponse, type Subscription, type SubscriptionWebhook, SubscriptionsResource, type SyncedEmail, type SyncedEmailContact, type SyncedEmailCustomer, type SyncedEmailDeal, type SyncedEmailMessage, type SyncedEmailUser, SyncedEmailsResource, type Task, type TaskComment, type TaskTodoItem, TasksResource, type ThreadEventType, type ThreadMessageWebhook, type ThreadWebhook, type Ticket, type TicketAgent, type TicketApp, type TicketAttachment, type TicketChannel, type TicketContact, type TicketCustomer, type TicketEvent, type TicketLoop, type TicketMessage, TicketsResource, type TimeSeriesDataPoint, type TimelineComment, TimelineCommentsResource, type TokenRefreshResult, type Transaction, type TransactionWebhook, TransactionsResource, type Trigger, type UninstallEventWebhook, type UsageEvent, type UsageEventResponse, UsageEventsResource, type UsageMetric, type UsageMetricResponse, type User, UsersResource, type Webhook, WebhooksResource, type components, createRateLimitMiddleware, type paths };
27853
+ export { type AccountOwner, type AccountOwnerType, type Action, type ActiveSubscriptionsResponse, type Affiliate, type AffiliateAttributionWebhook, type AffiliateCommission, AffiliateCommissionsResource, type AffiliateMembershipWebhook, type AffiliatePayout, type AffiliatePayoutWebhook, AffiliatePayoutsResource, type AffiliateProgram, type AffiliateProgramGroup, type AffiliateProgramMembership, type AffiliateProgramWebhook, AffiliateProgramsResource, type AffiliateReferral, AffiliateReferralsResource, type AffiliateRules, type AffiliateRulesWebhook, type AffiliateWebhook, AffiliatesResource, type Agent, type AgentRun, AgentsResource, AiAgentRunsResource, type App, type AppChargeWebhook, type AppEvent, type AppInstallation, type AppInstallationWebhook, type AppWebhook, AppsResource, type BaseCustomerWebhook, BaseResource, ChannelsResource, type Charge, ChargesResource, type Checklist, type ChecklistStep, CompaniesResource, type Company, type Contact, type ContactWebhook, ContactsResource, type CursorPagination, CustomDataResource, type CustomField, type CustomFieldDefaultValue, type Customer, type CustomerContact, type CustomerContactWebhook, type CustomerSegment, CustomerSegmentsResource, type CustomerWebhook, type CustomerWithoutSubscriptionWebhook, CustomersResource, type Deal, type DealAcquirer, DealActivitiesResource, type DealActivity, type DealAffiliate, type DealApp, type DealContact, type DealCustomData, type DealCustomer, type DealEvent, type DealFlow, type DealFlowAffiliate, type DealFlowDefaultSource, type DealFlowPartnership, type DealFlowStage, type DealFlowUser, DealFlowsResource, type DealOwner, type DealPartnership, type DealPlan, type DealStage, DealsResource, type DetailedAffiliate, type DetailedFlow, type DocsCollection, type DocsCollectionResponse, type DocsGenerateJobResponse, type DocsGenerateStatusCompleted, type DocsGenerateStatusFailed, type DocsGenerateStatusPending, type DocsGroup, type DocsGroupResponse, type DocsPage, type DocsPageResponse, type DocsPageSummary, type DocsRepository, DocsResource, type EmailCampaign, type EmailDelivery, type EmailDeliveryStats, type EmailLayout, type EmailPreview, type EmailSender, type EmailUnsubscribeGroup, type EmailUnsubscribeGroupMember, EmailUnsubscribeGroupsResource, EntitiesResource, type EventWebhook, type ExtensionUninstallPayload, type ExtensionWebhook, type Feature, type Flow, type FlowActionRun, FlowExtensionsResource, FlowsResource, type InvalidTokenError, type Invoice, type InvoiceWebhook, JournalEntriesResource, type JournalEntry, type JournalEntryApp, type JournalEntryFile, type List, ListsResource, type LogoChurnResponse, MantleAPIError, MantleAuthenticationError, MantleCoreClient, type MantleCoreClientConfig, MantleNotFoundError, MantlePermissionError, MantleRateLimitError, MantleValidationError, MeResource, type Meeting, type MeetingAttendee, type MeetingAttendeeRef, type MeetingContactRef, type MeetingCustomer, type MeetingDeal, type MeetingPermission, type MeetingTaskSuggestion, type MeetingTranscript, type MeetingUser, type MeetingUtterance, MeetingsResource, MetricsResource, type MissingScopesError, type MrrResponse, type NetInstallsResponse, type NetRevenueResponse, type NetRevenueRetentionResponse, type Organization, OrganizationResource, type Pagination, type PayoutResponse, type Plan, type PlanFeature, type PlanFeatureWebhook, type PlanUsageChargeWebhook, type PlanWebhook, type PredictedLtvResponse, type RateLimitOptions, type RevenueRetentionResponse, type Review, type ReviewWebhook, type StandardMetricResponse, type Subscription, type SubscriptionWebhook, SubscriptionsResource, type SyncedEmail, type SyncedEmailContact, type SyncedEmailCustomer, type SyncedEmailDeal, type SyncedEmailMessage, type SyncedEmailUser, SyncedEmailsResource, type Task, type TaskComment, type TaskTodoItem, TasksResource, type ThreadEventType, type ThreadMessageWebhook, type ThreadWebhook, type Ticket, type TicketAgent, type TicketApp, type TicketAttachment, type TicketChannel, type TicketContact, type TicketCustomer, type TicketEvent, type TicketLoop, type TicketMessage, TicketsResource, type TimeSeriesDataPoint, type TimelineComment, TimelineCommentsResource, type Transaction, type TransactionWebhook, TransactionsResource, type Trigger, type UninstallEventWebhook, type UsageEvent, type UsageEventResponse, UsageEventsResource, type UsageMetric, type UsageMetricResponse, type User, UsersResource, type Webhook, WebhooksResource, type components, createRateLimitMiddleware, type paths };
package/dist/index.js CHANGED
@@ -1165,8 +1165,6 @@ var MantleCoreClient = class {
1165
1165
  }
1166
1166
  this.apiKey = config.apiKey;
1167
1167
  this.accessToken = config.accessToken;
1168
- this.accessTokenExpiresAt = config.accessTokenExpiresAt;
1169
- this.refreshAccessToken = config.refreshAccessToken;
1170
1168
  const timeoutMs = config.timeout ?? 3e4;
1171
1169
  this._api = (0, import_openapi_fetch.default)({
1172
1170
  baseUrl: config.baseURL || "https://api.heymantle.com/v1",
@@ -1177,38 +1175,11 @@ var MantleCoreClient = class {
1177
1175
  });
1178
1176
  this._api.use({
1179
1177
  onRequest: async ({ request }) => {
1180
- if (this.refreshAccessToken && this.isTokenExpired()) {
1181
- await this.doRefresh();
1182
- }
1183
1178
  const token = this.accessToken || this.apiKey;
1184
1179
  if (token) {
1185
1180
  request.headers.set("Authorization", `Bearer ${token}`);
1186
1181
  }
1187
1182
  return request;
1188
- },
1189
- onResponse: async ({ request, response }) => {
1190
- if (response.status !== 401 || !this.refreshAccessToken) return void 0;
1191
- try {
1192
- const body = await response.clone().json();
1193
- const errorMsg = typeof body?.error === "string" ? body.error : "";
1194
- if (errorMsg.startsWith("invalid_token") || errorMsg.startsWith("invalid_client")) {
1195
- return void 0;
1196
- }
1197
- } catch {
1198
- }
1199
- try {
1200
- const newToken = await this.doRefresh();
1201
- const headers = new Headers(request.headers);
1202
- headers.set("Authorization", `Bearer ${newToken}`);
1203
- return fetch(new Request(request.url, {
1204
- method: request.method,
1205
- headers,
1206
- body: request.body,
1207
- signal: request.signal
1208
- }));
1209
- } catch {
1210
- return void 0;
1211
- }
1212
1183
  }
1213
1184
  });
1214
1185
  if (timeoutMs > 0) {
@@ -1283,7 +1254,7 @@ var MantleCoreClient = class {
1283
1254
  return this;
1284
1255
  }
1285
1256
  /**
1286
- * Update authentication credentials
1257
+ * Update authentication credentials at runtime.
1287
1258
  */
1288
1259
  updateAuth(credentials) {
1289
1260
  if (credentials.apiKey !== void 0) {
@@ -1292,36 +1263,6 @@ var MantleCoreClient = class {
1292
1263
  if (credentials.accessToken !== void 0) {
1293
1264
  this.accessToken = credentials.accessToken;
1294
1265
  }
1295
- if (credentials.accessTokenExpiresAt !== void 0) {
1296
- this.accessTokenExpiresAt = credentials.accessTokenExpiresAt;
1297
- }
1298
- }
1299
- /**
1300
- * Check if the access token is expired (with a 30-second buffer).
1301
- */
1302
- isTokenExpired() {
1303
- if (!this.accessTokenExpiresAt) return false;
1304
- return this.accessTokenExpiresAt.getTime() - Date.now() <= 3e4;
1305
- }
1306
- /**
1307
- * Execute a token refresh, deduplicating concurrent calls.
1308
- * All concurrent requests will await the same in-flight refresh promise.
1309
- */
1310
- async doRefresh() {
1311
- if (this.refreshPromise) return this.refreshPromise;
1312
- this.refreshPromise = (async () => {
1313
- try {
1314
- const result = await this.refreshAccessToken();
1315
- this.accessToken = result.accessToken;
1316
- if (result.expiresAt) {
1317
- this.accessTokenExpiresAt = result.expiresAt;
1318
- }
1319
- return result.accessToken;
1320
- } finally {
1321
- this.refreshPromise = void 0;
1322
- }
1323
- })();
1324
- return this.refreshPromise;
1325
1266
  }
1326
1267
  };
1327
1268
 
package/dist/index.mjs CHANGED
@@ -1083,8 +1083,6 @@ var MantleCoreClient = class {
1083
1083
  }
1084
1084
  this.apiKey = config.apiKey;
1085
1085
  this.accessToken = config.accessToken;
1086
- this.accessTokenExpiresAt = config.accessTokenExpiresAt;
1087
- this.refreshAccessToken = config.refreshAccessToken;
1088
1086
  const timeoutMs = config.timeout ?? 3e4;
1089
1087
  this._api = createClient({
1090
1088
  baseUrl: config.baseURL || "https://api.heymantle.com/v1",
@@ -1095,38 +1093,11 @@ var MantleCoreClient = class {
1095
1093
  });
1096
1094
  this._api.use({
1097
1095
  onRequest: async ({ request }) => {
1098
- if (this.refreshAccessToken && this.isTokenExpired()) {
1099
- await this.doRefresh();
1100
- }
1101
1096
  const token = this.accessToken || this.apiKey;
1102
1097
  if (token) {
1103
1098
  request.headers.set("Authorization", `Bearer ${token}`);
1104
1099
  }
1105
1100
  return request;
1106
- },
1107
- onResponse: async ({ request, response }) => {
1108
- if (response.status !== 401 || !this.refreshAccessToken) return void 0;
1109
- try {
1110
- const body = await response.clone().json();
1111
- const errorMsg = typeof body?.error === "string" ? body.error : "";
1112
- if (errorMsg.startsWith("invalid_token") || errorMsg.startsWith("invalid_client")) {
1113
- return void 0;
1114
- }
1115
- } catch {
1116
- }
1117
- try {
1118
- const newToken = await this.doRefresh();
1119
- const headers = new Headers(request.headers);
1120
- headers.set("Authorization", `Bearer ${newToken}`);
1121
- return fetch(new Request(request.url, {
1122
- method: request.method,
1123
- headers,
1124
- body: request.body,
1125
- signal: request.signal
1126
- }));
1127
- } catch {
1128
- return void 0;
1129
- }
1130
1101
  }
1131
1102
  });
1132
1103
  if (timeoutMs > 0) {
@@ -1201,7 +1172,7 @@ var MantleCoreClient = class {
1201
1172
  return this;
1202
1173
  }
1203
1174
  /**
1204
- * Update authentication credentials
1175
+ * Update authentication credentials at runtime.
1205
1176
  */
1206
1177
  updateAuth(credentials) {
1207
1178
  if (credentials.apiKey !== void 0) {
@@ -1210,36 +1181,6 @@ var MantleCoreClient = class {
1210
1181
  if (credentials.accessToken !== void 0) {
1211
1182
  this.accessToken = credentials.accessToken;
1212
1183
  }
1213
- if (credentials.accessTokenExpiresAt !== void 0) {
1214
- this.accessTokenExpiresAt = credentials.accessTokenExpiresAt;
1215
- }
1216
- }
1217
- /**
1218
- * Check if the access token is expired (with a 30-second buffer).
1219
- */
1220
- isTokenExpired() {
1221
- if (!this.accessTokenExpiresAt) return false;
1222
- return this.accessTokenExpiresAt.getTime() - Date.now() <= 3e4;
1223
- }
1224
- /**
1225
- * Execute a token refresh, deduplicating concurrent calls.
1226
- * All concurrent requests will await the same in-flight refresh promise.
1227
- */
1228
- async doRefresh() {
1229
- if (this.refreshPromise) return this.refreshPromise;
1230
- this.refreshPromise = (async () => {
1231
- try {
1232
- const result = await this.refreshAccessToken();
1233
- this.accessToken = result.accessToken;
1234
- if (result.expiresAt) {
1235
- this.accessTokenExpiresAt = result.expiresAt;
1236
- }
1237
- return result.accessToken;
1238
- } finally {
1239
- this.refreshPromise = void 0;
1240
- }
1241
- })();
1242
- return this.refreshPromise;
1243
1184
  }
1244
1185
  };
1245
1186
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@heymantle/core-api-client",
3
- "version": "0.4.5",
3
+ "version": "0.5.1",
4
4
  "description": "TypeScript SDK for the Mantle Core API",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",