@heymantle/core-api-client 0.4.5 → 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/dist/index.d.mts +2 -39
- package/dist/index.d.ts +2 -39
- package/dist/index.js +1 -60
- package/dist/index.mjs +1 -60
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -19408,15 +19408,6 @@ type components = {
|
|
|
19408
19408
|
pathItems: never;
|
|
19409
19409
|
};
|
|
19410
19410
|
|
|
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
19411
|
/**
|
|
19421
19412
|
* Configuration for the MantleCoreClient
|
|
19422
19413
|
*/
|
|
@@ -19427,21 +19418,6 @@ interface MantleCoreClientConfig {
|
|
|
19427
19418
|
apiKey?: string;
|
|
19428
19419
|
/** OAuth access token for authentication */
|
|
19429
19420
|
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
19421
|
/** Request timeout in milliseconds. Defaults to 30000 */
|
|
19446
19422
|
timeout?: number;
|
|
19447
19423
|
/** openapi-fetch middleware to register on instantiation */
|
|
@@ -27515,9 +27491,6 @@ declare class MantleCoreClient {
|
|
|
27515
27491
|
readonly _api: Client<paths>;
|
|
27516
27492
|
private apiKey?;
|
|
27517
27493
|
private accessToken?;
|
|
27518
|
-
private accessTokenExpiresAt?;
|
|
27519
|
-
private refreshAccessToken?;
|
|
27520
|
-
private refreshPromise?;
|
|
27521
27494
|
readonly affiliateCommissions: AffiliateCommissionsResource;
|
|
27522
27495
|
readonly affiliatePayouts: AffiliatePayoutsResource;
|
|
27523
27496
|
readonly affiliatePrograms: AffiliateProgramsResource;
|
|
@@ -27571,22 +27544,12 @@ declare class MantleCoreClient {
|
|
|
27571
27544
|
*/
|
|
27572
27545
|
eject(middleware: Middleware): this;
|
|
27573
27546
|
/**
|
|
27574
|
-
* Update authentication credentials
|
|
27547
|
+
* Update authentication credentials at runtime.
|
|
27575
27548
|
*/
|
|
27576
27549
|
updateAuth(credentials: {
|
|
27577
27550
|
apiKey?: string;
|
|
27578
27551
|
accessToken?: string;
|
|
27579
|
-
accessTokenExpiresAt?: Date;
|
|
27580
27552
|
}): 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
27553
|
}
|
|
27591
27554
|
|
|
27592
27555
|
type AccountOwner = components['schemas']['AccountOwner'];
|
|
@@ -27836,4 +27799,4 @@ interface RateLimitOptions {
|
|
|
27836
27799
|
*/
|
|
27837
27800
|
declare function createRateLimitMiddleware(options?: RateLimitOptions): Middleware;
|
|
27838
27801
|
|
|
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
|
|
27802
|
+
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
|
@@ -19408,15 +19408,6 @@ type components = {
|
|
|
19408
19408
|
pathItems: never;
|
|
19409
19409
|
};
|
|
19410
19410
|
|
|
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
19411
|
/**
|
|
19421
19412
|
* Configuration for the MantleCoreClient
|
|
19422
19413
|
*/
|
|
@@ -19427,21 +19418,6 @@ interface MantleCoreClientConfig {
|
|
|
19427
19418
|
apiKey?: string;
|
|
19428
19419
|
/** OAuth access token for authentication */
|
|
19429
19420
|
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
19421
|
/** Request timeout in milliseconds. Defaults to 30000 */
|
|
19446
19422
|
timeout?: number;
|
|
19447
19423
|
/** openapi-fetch middleware to register on instantiation */
|
|
@@ -27515,9 +27491,6 @@ declare class MantleCoreClient {
|
|
|
27515
27491
|
readonly _api: Client<paths>;
|
|
27516
27492
|
private apiKey?;
|
|
27517
27493
|
private accessToken?;
|
|
27518
|
-
private accessTokenExpiresAt?;
|
|
27519
|
-
private refreshAccessToken?;
|
|
27520
|
-
private refreshPromise?;
|
|
27521
27494
|
readonly affiliateCommissions: AffiliateCommissionsResource;
|
|
27522
27495
|
readonly affiliatePayouts: AffiliatePayoutsResource;
|
|
27523
27496
|
readonly affiliatePrograms: AffiliateProgramsResource;
|
|
@@ -27571,22 +27544,12 @@ declare class MantleCoreClient {
|
|
|
27571
27544
|
*/
|
|
27572
27545
|
eject(middleware: Middleware): this;
|
|
27573
27546
|
/**
|
|
27574
|
-
* Update authentication credentials
|
|
27547
|
+
* Update authentication credentials at runtime.
|
|
27575
27548
|
*/
|
|
27576
27549
|
updateAuth(credentials: {
|
|
27577
27550
|
apiKey?: string;
|
|
27578
27551
|
accessToken?: string;
|
|
27579
|
-
accessTokenExpiresAt?: Date;
|
|
27580
27552
|
}): 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
27553
|
}
|
|
27591
27554
|
|
|
27592
27555
|
type AccountOwner = components['schemas']['AccountOwner'];
|
|
@@ -27836,4 +27799,4 @@ interface RateLimitOptions {
|
|
|
27836
27799
|
*/
|
|
27837
27800
|
declare function createRateLimitMiddleware(options?: RateLimitOptions): Middleware;
|
|
27838
27801
|
|
|
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
|
|
27802
|
+
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
|
|