@sparkvault/sdk-js 15.6.0 → 15.7.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/errors.d.ts +12 -1
- package/dist/index.cjs +43 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +36 -7
- package/dist/index.mjs +42 -4
- package/dist/index.mjs.map +1 -1
- package/dist/products/notify/project-types.d.ts +23 -5
- package/dist/sparkvault.js +1 -1
- package/dist/sparkvault.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -624,9 +624,15 @@ declare class IdentityModule {
|
|
|
624
624
|
/** Named Notify projects owned and billed by one company account. */
|
|
625
625
|
type NotifyProjectStatus = 'draft' | 'active' | 'read_only' | 'archived';
|
|
626
626
|
interface NotifyProjectBilling {
|
|
627
|
+
/** Present on the flat subscription backed by the company's shared wallet. */
|
|
628
|
+
billing_model?: 'usage_credits';
|
|
629
|
+
enabled?: boolean;
|
|
630
|
+
included_monthly_credits?: number;
|
|
631
|
+
renewal_included_monthly_credits?: number;
|
|
627
632
|
subscription_item_id?: string | null;
|
|
628
633
|
subscription_id?: string | null;
|
|
629
634
|
status: 'draft' | 'active' | 'past_due' | 'read_only';
|
|
635
|
+
/** Historical tier allowance. The credit model's compatibility value is not a usage ceiling. */
|
|
630
636
|
notifications_cap: number;
|
|
631
637
|
/** Allowance selected for the next period when a downgrade is scheduled. */
|
|
632
638
|
renewal_notifications_cap?: number;
|
|
@@ -674,12 +680,24 @@ interface UpdateNotifyProjectOptions {
|
|
|
674
680
|
description?: string;
|
|
675
681
|
sender_name?: string | null;
|
|
676
682
|
}
|
|
677
|
-
|
|
678
|
-
|
|
683
|
+
type PreviewNotifyProjectSubscriptionOptions =
|
|
684
|
+
/** New project: one flat monthly plan with credits shared across the company. */
|
|
685
|
+
{
|
|
686
|
+
billingModel: 'usage_credits';
|
|
687
|
+
notificationsPerMonth?: never;
|
|
679
688
|
}
|
|
689
|
+
/** Existing legacy project: retain its published notification tier. */
|
|
690
|
+
| {
|
|
691
|
+
billingModel?: undefined;
|
|
692
|
+
notificationsPerMonth: number;
|
|
693
|
+
};
|
|
680
694
|
interface NotifyProjectSubscriptionPreview {
|
|
681
695
|
project_id: string;
|
|
682
|
-
|
|
696
|
+
/** Present for the flat shared-credit plan; absent for historical tier plans. */
|
|
697
|
+
billing_model?: 'usage_credits';
|
|
698
|
+
included_monthly_credits?: number;
|
|
699
|
+
/** Present only when reviewing a historical tier plan. */
|
|
700
|
+
notifications_per_month?: number;
|
|
683
701
|
/** Exact decimal USD amounts, as strings; repeat the quote without float conversion. */
|
|
684
702
|
monthly_usd: string;
|
|
685
703
|
amount_due_now_usd: string;
|
|
@@ -688,11 +706,11 @@ interface NotifyProjectSubscriptionPreview {
|
|
|
688
706
|
effective_at: number | null;
|
|
689
707
|
checkout_required: boolean;
|
|
690
708
|
}
|
|
691
|
-
|
|
709
|
+
type SubscribeNotifyProjectOptions = PreviewNotifyProjectSubscriptionOptions & {
|
|
692
710
|
/** Repeat the reviewed quote; a changed price is refused rather than charged. */
|
|
693
711
|
quotedAmountDueNowUsd: string;
|
|
694
712
|
prorationDate: number;
|
|
695
|
-
}
|
|
713
|
+
};
|
|
696
714
|
interface NotifyProjectSubscriptionResponse {
|
|
697
715
|
project: NotifyProject;
|
|
698
716
|
/** Present when the company's first subscription needs hosted payment setup. */
|
|
@@ -4317,7 +4335,7 @@ declare class SparkVaultError extends Error {
|
|
|
4317
4335
|
* answer named none (a gateway's HTML). A typed refusal's `code` names its
|
|
4318
4336
|
* class of failure: one per 400 (`validation_error`), two per 401
|
|
4319
4337
|
* (`authentication_error`, `UNAUTHORIZED`), 402 (`PLAN_REQUIRED`,
|
|
4320
|
-
* `QUOTA_EXCEEDED`) and 403 (`authorization_error`, `NOTIFY_SUBSCRIPTION_REQUIRED`;
|
|
4338
|
+
* `QUOTA_EXCEEDED`, `USAGE_CREDITS_EXHAUSTED`) and 403 (`authorization_error`, `NOTIFY_SUBSCRIPTION_REQUIRED`;
|
|
4321
4339
|
* http.ts createErrorFromResponse), so this is what tells apart two
|
|
4322
4340
|
* refusals that share a code.
|
|
4323
4341
|
* Undefined on an error the SDK raised itself, on the Identity product's
|
|
@@ -4362,6 +4380,17 @@ type QuotaResource = 'storage' | 'bandwidth';
|
|
|
4362
4380
|
declare class PlanRequiredError extends SparkVaultError {
|
|
4363
4381
|
constructor(message: string, details?: Record<string, unknown>, retryAfterMs?: number | null, serviceCode?: string);
|
|
4364
4382
|
}
|
|
4383
|
+
/**
|
|
4384
|
+
* Prepaid usage is exhausted (402 USAGE_CREDITS_EXHAUSTED). The subscription
|
|
4385
|
+
* can still be active: an admin replenishes the shared usage-credit wallet.
|
|
4386
|
+
*/
|
|
4387
|
+
declare class UsageCreditsExhaustedError extends SparkVaultError {
|
|
4388
|
+
constructor(message: string, details?: Record<string, unknown>, retryAfterMs?: number | null, serviceCode?: string);
|
|
4389
|
+
}
|
|
4390
|
+
/** A payment reversal requires billing review; buying more credits cannot clear it. */
|
|
4391
|
+
declare class UsageCreditFundingReviewError extends SparkVaultError {
|
|
4392
|
+
constructor(message: string, details?: Record<string, unknown>, retryAfterMs?: number | null, serviceCode?: string);
|
|
4393
|
+
}
|
|
4365
4394
|
/**
|
|
4366
4395
|
* Quota exceeded gate (402 QUOTA_EXCEEDED) — a pooled-capacity limit is
|
|
4367
4396
|
* exhausted. `resource` identifies which pool so callers can point the CTA at
|
|
@@ -5553,5 +5582,5 @@ declare global {
|
|
|
5553
5582
|
}
|
|
5554
5583
|
}
|
|
5555
5584
|
|
|
5556
|
-
export { AuthenticationError, AuthorizationError, EntropyModule, FoldersModule, HelpDeskClient, HelpDeskModule, IdentityModule, IdentityProviderError, IngotsModule, NAME_CONFLICT_POLICIES, NOTIFY_PRESETS, NetworkError, NotifyModule, NotifyProductModule, NotifyProjectsModule, NotifySubscriptionRequiredError, PlanRequiredError, PopupBlockedError, ProductsModule, QuotaExceededError, SparkVault, SparkVaultError, SparksModule, TimeoutError, UnauthorizedError, UserCancelledError, ValidationError, VaultsModule, buildNotifyPresetSend, SparkVault as default, fetchDownload, isReceivedUploadFailure, logger, setDebugMode };
|
|
5585
|
+
export { AuthenticationError, AuthorizationError, EntropyModule, FoldersModule, HelpDeskClient, HelpDeskModule, IdentityModule, IdentityProviderError, IngotsModule, NAME_CONFLICT_POLICIES, NOTIFY_PRESETS, NetworkError, NotifyModule, NotifyProductModule, NotifyProjectsModule, NotifySubscriptionRequiredError, PlanRequiredError, PopupBlockedError, ProductsModule, QuotaExceededError, SparkVault, SparkVaultError, SparksModule, TimeoutError, UnauthorizedError, UsageCreditFundingReviewError, UsageCreditsExhaustedError, UserCancelledError, ValidationError, VaultsModule, buildNotifyPresetSend, SparkVault as default, fetchDownload, isReceivedUploadFailure, logger, setDebugMode };
|
|
5557
5586
|
export type { AccessLogRetention, AccessLogsOptions, CreateFolderOptions, CreateNotifyProjectOptions, CreateNotifySendOptions, CreateSparkOptions, CreateUploadOptions, CreateVaultOptions, CreatedIngot, CreatedSpark, DownloadIngotOptions, EntropyFormat, EntropyResult, FetchDownloadOptions, FetchedDownload, Folder, FolderBreadcrumbItem, FolderContents, FolderPage, GenerateEntropyOptions, HealthCheckOptions, HealthCheckResult, HelpDeskAttachmentDownload, HelpDeskAttachmentInput, HelpDeskAttachmentUpload, HelpDeskConnectOptions, HelpDeskCreateTicketOptions, HelpDeskCustomer, HelpDeskCustomerPatch, HelpDeskDesk, HelpDeskDraft, HelpDeskEvent, HelpDeskExternalChallenge, HelpDeskExternalIdentity, HelpDeskFormHandle, HelpDeskFormOptions, HelpDeskFormState, HelpDeskIdentityRequest, HelpDeskListTicketsOptions, HelpDeskMountFormOptions, HelpDeskOpenFormOptions, HelpDeskPinChallenge, HelpDeskReplyCreated, HelpDeskReplyOptions, HelpDeskRequestContext, HelpDeskSession, HelpDeskSessionChange, HelpDeskSupportHandle, HelpDeskSupportLauncherOptions, HelpDeskSupportOpenOptions, HelpDeskSupportOptions, HelpDeskSupportStage, HelpDeskSupportState, HelpDeskTicket, HelpDeskTicketCreated, HelpDeskTicketDetail, HelpDeskTicketList, HelpDeskTimeline, HelpDeskVerifyPinOptions, HelpDeskWidgetFormIdentity, HelpDeskWidgetIdentityChallenge, HelpDeskWidgetIdentityOptions, HelpDeskWidgetIdentitySession, AttachOptions as IdentityAttachOptions, Ingot, IngotAccessLog, IngotAccessLogPage, IngotDownloadLink, IngotInvitation, IngotInvite, IngotPage, IngotSharingConfig, IngotUpload, ListContentsOptions, ListFoldersOptions, ListIngotsOptions, ListNotificationsOptions, ListNotificationsResponse, ListNotifyInboxOptions, ListNotifyInboxResponse, ListNotifyProjectsResponse, ListNotifyReceiptsOptions, ListNotifyReceiptsResponse, ListNotifySendsOptions, ListNotifySendsResponse, ListSparksOptions, MarkAllNotificationsStateOptions, MarkAllNotificationsStateResponse, MarkAllReadResult, MarkNotificationStateOptions, MarkNotificationStateResponse, MarkNotifyInboxAllOptions, MarkNotifyInboxAllResponse, MarkNotifyInboxStateOptions, MarkNotifyInboxStateResponse, NameConflictPolicy, NotificationBulkMarkState, NotificationInboxState, NotificationMarkState, NotificationRow, NotificationSender, NotifyCategory, NotifyChannel, NotifyConfig, NotifyConfigCategory, NotifyConfigDelivery, NotifyConfigDeliveryPatch, NotifyConfigDestinations, NotifyConfigDestinationsPatch, NotifyConfigEvents, NotifyConfigEventsRead, NotifyConfigHistory, NotifyConfigOverrides, NotifyConfigPatch, NotifyConfigRealtimeFallbackDelay, NotifyConfigReliability, NotifyConfigResponse, NotifyConfigSecurity, NotifyDeliveryMode, NotifyDestinationFailureReason, NotifyDestinationKind, NotifyDestinationReason, NotifyDestinationSkipReason, NotifyDestinationState, NotifyDestinationTestReason, NotifyDestinationTestResult, NotifyDestinationTransportReason, NotifyEscalation, NotifyInboxBulkMarkState, NotifyInboxMarkState, NotifyInboxRow, NotifyInboxView, NotifyIngotRef, NotifyInteraction, NotifyPreset, NotifyPresetCategory, NotifyPresetName, NotifyPresetSendOptions, NotifyProject, NotifyProjectBilling, NotifyProjectStatus, NotifyProjectSubscriptionPreview, NotifyProjectSubscriptionResponse, NotifyProjectUsage, NotifyRecallMode, NotifyReceipt, NotifyReceiptEventType, NotifyRecipient, NotifyRecipientRef, NotifyRecipientState, NotifyReportableVerificationLevel, NotifySendContent, NotifySendPolicy, NotifySendReceipt, NotifySendReceiptsResponse, NotifySendResult, NotifySendState, NotifySendStatus, NotifySendStatusCounts, NotifySendStatusDestination, NotifySendStatusRecipient, NotifySendSummary, NotifySendSummaryDestination, NotifySlackDestination, NotifySuppressionReason, NotifyTeamsDestination, NotifyTeamsDestinationRead, NotifyVerificationLevel, NotifyWebhookDestination, NotifyWebhookDestinationRead, PreviewNotifyProjectSubscriptionOptions, QuotaResource, RecallNotifySendOptions, RecallNotifySendResponse, RegisterWebPushResponse, ReplaceIngotOptions, ResumeUploadOptions, ScheduledVaultDeletion, SearchIngotsOptions, SendUploadOptions, ShareSparkOptions, SignInOptions, SignInResult, Spark, SparkInviteResend, SparkLinkActionOptions, SparkPage, SparkShare, SparkSummary, SparkVaultConfig, SparkVisibility, StartedVaultDeletion, SubscribeNotifyProjectOptions, SubscribeWebPushOptions, SubscribeWebPushResult, SubscribeWebPushStatus, TokenClaims, UnreachedAdmin, UnreadCountResponse, UnsealVaultOptions, UnsealedVault, UnsubscribeWebPushResponse, UpdateFolderOptions, UpdateIngotSharingOptions, UpdateNotifyProjectOptions, UpdateVaultUploadOptions, UpdatedVault, UploadAttachOptions, UploadBranding, UploadEnd, UploadIngotOptions, UploadOptions, UploadProgress, UploadResult, UploadSession, Vault, VaultDetail, VaultLifecycle, VaultResealDefaults, VaultResealSettings, VaultResealSettingsResult, VaultSessionExtension, VaultSessionTiming, VaultSharingConfig, VaultSharingOptions, VaultSummary, VaultUploadConfig, VaultUploadSettings, VerifyOptions, VerifyResult, WebPushKeyResponse, WebPushStatus, WebPushStatusOptions, WebPushStatusResult, WebPushSubscriptionInput };
|
package/dist/index.mjs
CHANGED
|
@@ -845,6 +845,25 @@ class PlanRequiredError extends SparkVaultError {
|
|
|
845
845
|
Object.setPrototypeOf(this, PlanRequiredError.prototype);
|
|
846
846
|
}
|
|
847
847
|
}
|
|
848
|
+
/**
|
|
849
|
+
* Prepaid usage is exhausted (402 USAGE_CREDITS_EXHAUSTED). The subscription
|
|
850
|
+
* can still be active: an admin replenishes the shared usage-credit wallet.
|
|
851
|
+
*/
|
|
852
|
+
class UsageCreditsExhaustedError extends SparkVaultError {
|
|
853
|
+
constructor(message, details, retryAfterMs = null, serviceCode) {
|
|
854
|
+
super(message, 'USAGE_CREDITS_EXHAUSTED', 402, details, retryAfterMs, serviceCode);
|
|
855
|
+
this.name = 'UsageCreditsExhaustedError';
|
|
856
|
+
Object.setPrototypeOf(this, UsageCreditsExhaustedError.prototype);
|
|
857
|
+
}
|
|
858
|
+
}
|
|
859
|
+
/** A payment reversal requires billing review; buying more credits cannot clear it. */
|
|
860
|
+
class UsageCreditFundingReviewError extends SparkVaultError {
|
|
861
|
+
constructor(message, details, retryAfterMs = null, serviceCode) {
|
|
862
|
+
super(message, 'USAGE_CREDIT_FUNDING_REVIEW', 402, details, retryAfterMs, serviceCode);
|
|
863
|
+
this.name = 'UsageCreditFundingReviewError';
|
|
864
|
+
Object.setPrototypeOf(this, UsageCreditFundingReviewError.prototype);
|
|
865
|
+
}
|
|
866
|
+
}
|
|
848
867
|
/**
|
|
849
868
|
* Quota exceeded gate (402 QUOTA_EXCEEDED) — a pooled-capacity limit is
|
|
850
869
|
* exhausted. `resource` identifies which pool so callers can point the CTA at
|
|
@@ -1659,6 +1678,10 @@ class HttpClient {
|
|
|
1659
1678
|
return new UnauthorizedError(message, details, retryAfterMs, code);
|
|
1660
1679
|
return new AuthenticationError(message, details, retryAfterMs, code);
|
|
1661
1680
|
case 402:
|
|
1681
|
+
if (code === 'USAGE_CREDIT_FUNDING_REVIEW')
|
|
1682
|
+
return new UsageCreditFundingReviewError(message, details, retryAfterMs, code);
|
|
1683
|
+
if (code === 'USAGE_CREDITS_EXHAUSTED')
|
|
1684
|
+
return new UsageCreditsExhaustedError(message, details, retryAfterMs, code);
|
|
1662
1685
|
if (code === 'QUOTA_EXCEEDED')
|
|
1663
1686
|
return new QuotaExceededError(message, details, retryAfterMs, code);
|
|
1664
1687
|
// PLAN_REQUIRED is the canonical 402 gate; treat any other 402 as one too.
|
|
@@ -11605,6 +11628,11 @@ function requireNotifyProjectId(projectId) {
|
|
|
11605
11628
|
field: 'projectId', received: projectId,
|
|
11606
11629
|
});
|
|
11607
11630
|
}
|
|
11631
|
+
function subscriptionPlan(options) {
|
|
11632
|
+
return options.billingModel === 'usage_credits'
|
|
11633
|
+
? { billing_model: 'usage_credits' }
|
|
11634
|
+
: { notifications_per_month: options.notificationsPerMonth };
|
|
11635
|
+
}
|
|
11608
11636
|
/** Company-level project management. Creation saves a draft and charges nothing. */
|
|
11609
11637
|
class NotifyProjectsModule {
|
|
11610
11638
|
constructor(http) {
|
|
@@ -11637,14 +11665,14 @@ class NotifyProjectsModule {
|
|
|
11637
11665
|
/** Quote a named project's plan. Requires an interactive company-admin session. */
|
|
11638
11666
|
async previewSubscription(projectId, options) {
|
|
11639
11667
|
const id = requireNotifyProjectId(projectId);
|
|
11640
|
-
const response = await this.http.post(apiPath `/v1/products/notify/projects/${id}/subscription/preview`,
|
|
11668
|
+
const response = await this.http.post(apiPath `/v1/products/notify/projects/${id}/subscription/preview`, subscriptionPlan(options));
|
|
11641
11669
|
return response.data;
|
|
11642
11670
|
}
|
|
11643
11671
|
/** Purchase the reviewed plan on the company's invoice; an API key cannot authorize spending. */
|
|
11644
11672
|
async subscribe(projectId, options) {
|
|
11645
11673
|
const id = requireNotifyProjectId(projectId);
|
|
11646
11674
|
const response = await this.http.post(apiPath `/v1/products/notify/projects/${id}/subscription`, {
|
|
11647
|
-
|
|
11675
|
+
...subscriptionPlan(options),
|
|
11648
11676
|
quoted_amount_due_now_usd: options.quotedAmountDueNowUsd,
|
|
11649
11677
|
proration_date: options.prorationDate,
|
|
11650
11678
|
});
|
|
@@ -12867,6 +12895,16 @@ async function attemptDownload(link, state, options) {
|
|
|
12867
12895
|
*/
|
|
12868
12896
|
async function refusedDownloadError(response, outcome, controller) {
|
|
12869
12897
|
const statusMessage = `Download failed with status ${response.status}`;
|
|
12898
|
+
if (response.status === 402) {
|
|
12899
|
+
const failure = await withDeadline(readApiFailure(response), DOWNLOAD_IDLE_TIMEOUT_MS, controller, 'Download timed out reading the funding refusal');
|
|
12900
|
+
if (failure.code === 'USAGE_CREDITS_EXHAUSTED')
|
|
12901
|
+
return new UsageCreditsExhaustedError(failure.message, failure.details, failure.retryAfterMs, failure.code);
|
|
12902
|
+
if (failure.code === 'USAGE_CREDIT_FUNDING_REVIEW')
|
|
12903
|
+
return new UsageCreditFundingReviewError(failure.message, failure.details, failure.retryAfterMs, failure.code);
|
|
12904
|
+
if (failure.code === 'PLAN_REQUIRED')
|
|
12905
|
+
return new PlanRequiredError(failure.message, failure.details, failure.retryAfterMs, failure.code);
|
|
12906
|
+
return new SparkVaultError(statusMessage, 'download_failed', response.status);
|
|
12907
|
+
}
|
|
12870
12908
|
const { coreCode } = outcome;
|
|
12871
12909
|
if (outcome.verdict !== TRANSFER_VERDICT.REFUSED || coreCode === null) {
|
|
12872
12910
|
return new SparkVaultError(statusMessage, 'download_failed', response.status);
|
|
@@ -25117,7 +25155,7 @@ class SparkVault {
|
|
|
25117
25155
|
}
|
|
25118
25156
|
/** Get the SDK version */
|
|
25119
25157
|
static get version() {
|
|
25120
|
-
return '15.
|
|
25158
|
+
return '15.7.0';
|
|
25121
25159
|
}
|
|
25122
25160
|
}
|
|
25123
25161
|
if (typeof window !== 'undefined') {
|
|
@@ -25127,5 +25165,5 @@ if (typeof window !== 'undefined') {
|
|
|
25127
25165
|
window.SparkVault = instance ?? SparkVault;
|
|
25128
25166
|
}
|
|
25129
25167
|
|
|
25130
|
-
export { AuthenticationError, AuthorizationError, EntropyModule, FoldersModule, HelpDeskClient, HelpDeskModule, IdentityModule, IdentityProviderError, IngotsModule, NAME_CONFLICT_POLICIES, NOTIFY_PRESETS, NetworkError, NotifyModule, NotifyProductModule, NotifyProjectsModule, NotifySubscriptionRequiredError, PlanRequiredError, PopupBlockedError, ProductsModule, QuotaExceededError, SparkVault, SparkVaultError, SparksModule, TimeoutError, UnauthorizedError, UserCancelledError, ValidationError, VaultsModule, buildNotifyPresetSend, SparkVault as default, fetchDownload, isReceivedUploadFailure, logger, setDebugMode };
|
|
25168
|
+
export { AuthenticationError, AuthorizationError, EntropyModule, FoldersModule, HelpDeskClient, HelpDeskModule, IdentityModule, IdentityProviderError, IngotsModule, NAME_CONFLICT_POLICIES, NOTIFY_PRESETS, NetworkError, NotifyModule, NotifyProductModule, NotifyProjectsModule, NotifySubscriptionRequiredError, PlanRequiredError, PopupBlockedError, ProductsModule, QuotaExceededError, SparkVault, SparkVaultError, SparksModule, TimeoutError, UnauthorizedError, UsageCreditFundingReviewError, UsageCreditsExhaustedError, UserCancelledError, ValidationError, VaultsModule, buildNotifyPresetSend, SparkVault as default, fetchDownload, isReceivedUploadFailure, logger, setDebugMode };
|
|
25131
25169
|
//# sourceMappingURL=index.mjs.map
|