@sparkvault/sdk-js 18.0.8 → 19.0.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 +3 -7
- package/dist/errors.d.ts +1 -14
- package/dist/index.cjs +27 -65
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +33 -96
- package/dist/index.mjs +28 -65
- package/dist/index.mjs.map +1 -1
- package/dist/products/notify/index.d.ts +11 -8
- package/dist/products/notify/project-types.d.ts +6 -57
- package/dist/products/notify/projects.d.ts +3 -9
- package/dist/products/notify/types.d.ts +11 -7
- package/dist/sparkvault.js +1 -1
- package/dist/sparkvault.js.map +1 -1
- package/package.json +1 -1
|
@@ -367,27 +367,30 @@ export declare class NotifyProductModule {
|
|
|
367
367
|
/**
|
|
368
368
|
* Post one test message to your destination of `kind` (a webhook, a Slack
|
|
369
369
|
* channel or a Teams workflow) and learn what became of it, without a send:
|
|
370
|
-
* nothing reaches a recipient, no send is stored
|
|
371
|
-
* the test never appears in send history. The post shows the title "Test
|
|
370
|
+
* nothing reaches a recipient, no send is stored, and
|
|
371
|
+
* the test spends destination delivery credits and never appears in send history. The post shows the title "Test
|
|
372
372
|
* post from SparkVault Notify" under your organization's name, through the
|
|
373
373
|
* sender a send's post takes. A webhook receives a body signed like any
|
|
374
374
|
* other, typed `notify.destination.test`, naming no send, with a
|
|
375
375
|
* `delivery_id` of its own. The post is made once and never tried again,
|
|
376
|
-
* so a fault a send's post would retry reads `failed`.
|
|
376
|
+
* so a fault a send's post would retry reads `failed`. Retain request_id across retries;
|
|
377
|
+
* a replay returns the saved verdict without another post or charge.
|
|
377
378
|
*
|
|
378
|
-
* An org admin's call
|
|
379
|
+
* An org admin's call: anyone else is
|
|
379
380
|
* refused 403 `FORBIDDEN` (`details: { sections: ['destinations'],
|
|
380
|
-
* required_role: 'admin' }`)
|
|
381
|
-
* `
|
|
381
|
+
* required_role: 'admin' }`). Insufficient credits returns a failed verdict
|
|
382
|
+
* with reason `usage_credits_exhausted`. A kind with no destination saved is 404
|
|
382
383
|
* `NOT_FOUND`, an organization name a send would be refused under is 409
|
|
383
384
|
* (`NOTIFY_SENDER_NAME_REQUIRED` or `NOTIFY_SENDER_NAME_RESERVED`), and each
|
|
384
385
|
* kind takes 20 tests an hour (429 `RATE_LIMIT_EXCEEDED`).
|
|
385
386
|
*
|
|
386
387
|
* @example
|
|
387
|
-
* const { state, reason } = await sv.products.notify.testDestination('webhook');
|
|
388
|
+
* const { state, reason } = await sv.products.notify.testDestination('webhook', { request_id: 'test_webhook_0001' });
|
|
388
389
|
* if (state !== 'delivered') console.warn(`Test post ${state}: ${reason}`);
|
|
389
390
|
*/
|
|
390
|
-
testDestination(kind: NotifyDestinationKind
|
|
391
|
+
testDestination(kind: NotifyDestinationKind, request: {
|
|
392
|
+
request_id: string;
|
|
393
|
+
}): Promise<NotifyDestinationTestResult>;
|
|
391
394
|
/**
|
|
392
395
|
* Who your organization's Notify email is from, as the API answers it
|
|
393
396
|
* (verbatim snake_case): `"{organization name}" <from_address>`, with a
|
|
@@ -1,25 +1,8 @@
|
|
|
1
|
-
/** Named Notify projects owned and
|
|
2
|
-
export type NotifyProjectStatus = '
|
|
1
|
+
/** Named Notify projects owned by one company and funded by its shared wallet. */
|
|
2
|
+
export type NotifyProjectStatus = 'active' | 'archived';
|
|
3
3
|
export interface NotifyProjectBilling {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
enabled?: boolean;
|
|
7
|
-
included_monthly_credits?: number;
|
|
8
|
-
renewal_included_monthly_credits?: number;
|
|
9
|
-
subscription_item_id?: string | null;
|
|
10
|
-
subscription_id?: string | null;
|
|
11
|
-
status: 'draft' | 'active' | 'past_due' | 'read_only';
|
|
12
|
-
/** Historical tier allowance. The credit model's compatibility value is not a usage ceiling. */
|
|
13
|
-
notifications_cap: number;
|
|
14
|
-
/** Allowance selected for the next period when a downgrade is scheduled. */
|
|
15
|
-
renewal_notifications_cap?: number;
|
|
16
|
-
current_period_end?: number | null;
|
|
17
|
-
cancel_at_period_end?: boolean;
|
|
18
|
-
price_id?: string | null;
|
|
19
|
-
stripe_product_id?: string | null;
|
|
20
|
-
tier_price_id?: string | null;
|
|
21
|
-
/** Default uses the company's existing Notify subscription. */
|
|
22
|
-
legacy?: boolean;
|
|
4
|
+
billing_model: 'usage_credits';
|
|
5
|
+
enabled: boolean;
|
|
23
6
|
}
|
|
24
7
|
export interface NotifyProjectUsage {
|
|
25
8
|
notifications_used: number;
|
|
@@ -45,6 +28,8 @@ export interface ListNotifyProjectsResponse {
|
|
|
45
28
|
items: NotifyProject[];
|
|
46
29
|
}
|
|
47
30
|
export interface CreateNotifyProjectOptions {
|
|
31
|
+
/** Stable idempotency key: 16 to 128 letters, numbers, underscores or hyphens. */
|
|
32
|
+
request_id: string;
|
|
48
33
|
/** A recognizable name, up to 80 characters. */
|
|
49
34
|
name: string;
|
|
50
35
|
/** Up to 240 characters. */
|
|
@@ -57,39 +42,3 @@ export interface UpdateNotifyProjectOptions {
|
|
|
57
42
|
description?: string;
|
|
58
43
|
sender_name?: string | null;
|
|
59
44
|
}
|
|
60
|
-
export type PreviewNotifyProjectSubscriptionOptions =
|
|
61
|
-
/** New project: one flat monthly plan with credits shared across the company. */
|
|
62
|
-
{
|
|
63
|
-
billingModel: 'usage_credits';
|
|
64
|
-
notificationsPerMonth?: never;
|
|
65
|
-
}
|
|
66
|
-
/** Existing legacy project: retain its published notification tier. */
|
|
67
|
-
| {
|
|
68
|
-
billingModel?: undefined;
|
|
69
|
-
notificationsPerMonth: number;
|
|
70
|
-
};
|
|
71
|
-
export interface NotifyProjectSubscriptionPreview {
|
|
72
|
-
project_id: string;
|
|
73
|
-
/** Present for the flat shared-credit plan; absent for historical tier plans. */
|
|
74
|
-
billing_model?: 'usage_credits';
|
|
75
|
-
included_monthly_credits?: number;
|
|
76
|
-
/** Present only when reviewing a historical tier plan. */
|
|
77
|
-
notifications_per_month?: number;
|
|
78
|
-
/** Exact decimal USD amounts, as strings; repeat the quote without float conversion. */
|
|
79
|
-
monthly_usd: string;
|
|
80
|
-
amount_due_now_usd: string;
|
|
81
|
-
currency: string;
|
|
82
|
-
proration_date: number;
|
|
83
|
-
effective_at: number | null;
|
|
84
|
-
checkout_required: boolean;
|
|
85
|
-
}
|
|
86
|
-
export type SubscribeNotifyProjectOptions = PreviewNotifyProjectSubscriptionOptions & {
|
|
87
|
-
/** Repeat the reviewed quote; a changed price is refused rather than charged. */
|
|
88
|
-
quotedAmountDueNowUsd: string;
|
|
89
|
-
prorationDate: number;
|
|
90
|
-
};
|
|
91
|
-
export interface NotifyProjectSubscriptionResponse {
|
|
92
|
-
project: NotifyProject;
|
|
93
|
-
/** Present when the company's first subscription needs hosted payment setup. */
|
|
94
|
-
checkout_url?: string;
|
|
95
|
-
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { HttpClient } from '../../http';
|
|
2
|
-
import type { CreateNotifyProjectOptions, ListNotifyProjectsResponse, NotifyProject,
|
|
2
|
+
import type { CreateNotifyProjectOptions, ListNotifyProjectsResponse, NotifyProject, UpdateNotifyProjectOptions } from './project-types';
|
|
3
3
|
/** Reject malformed project paths before a credentialed request leaves. */
|
|
4
4
|
export declare function requireNotifyProjectId(projectId: unknown): string;
|
|
5
|
-
/** Company-level project management. Creation
|
|
5
|
+
/** Company-level project management. Creation is idempotent and charges nothing. */
|
|
6
6
|
export declare class NotifyProjectsModule {
|
|
7
7
|
private readonly http;
|
|
8
8
|
constructor(http: HttpClient);
|
|
@@ -10,12 +10,6 @@ export declare class NotifyProjectsModule {
|
|
|
10
10
|
create(options: CreateNotifyProjectOptions): Promise<NotifyProject>;
|
|
11
11
|
get(projectId: string): Promise<NotifyProject>;
|
|
12
12
|
update(projectId: string, options: UpdateNotifyProjectOptions): Promise<NotifyProject>;
|
|
13
|
-
/** Archive
|
|
13
|
+
/** Archive an active project; Default cannot be archived. */
|
|
14
14
|
archive(projectId: string): Promise<NotifyProject>;
|
|
15
|
-
/** Quote a named project's plan. Requires an interactive company-admin session. */
|
|
16
|
-
previewSubscription(projectId: string, options: PreviewNotifyProjectSubscriptionOptions): Promise<NotifyProjectSubscriptionPreview>;
|
|
17
|
-
/** Purchase the reviewed plan on the company's invoice; an API key cannot authorize spending. */
|
|
18
|
-
subscribe(projectId: string, options: SubscribeNotifyProjectOptions): Promise<NotifyProjectSubscriptionResponse>;
|
|
19
|
-
/** End a named project's plan at its paid period deadline; retained history stays readable. */
|
|
20
|
-
cancelSubscription(projectId: string): Promise<NotifyProjectSubscriptionResponse>;
|
|
21
15
|
}
|
|
@@ -92,7 +92,7 @@ export type NotifyDestinationReason = NotifyDestinationSkipReason | NotifyDestin
|
|
|
92
92
|
* be sent at all (`unsent`), or too little of the post's time was left to
|
|
93
93
|
* start it (`deadline_reached`).
|
|
94
94
|
*/
|
|
95
|
-
export type NotifyDestinationTransportReason = 'network' | 'timeout' | 'unsent' | 'deadline_reached';
|
|
95
|
+
export type NotifyDestinationTransportReason = 'network' | 'timeout' | 'unsent' | 'deadline_reached' | 'usage_credits_exhausted' | 'usage_credit_funding_review' | 'usage_operation_pending' | 'usage_operation_released';
|
|
96
96
|
/**
|
|
97
97
|
* Why `updateConfig` refused a patch that lacks a field: the `details.reason`
|
|
98
98
|
* of its 400 `VALIDATION_ERROR`, beside `details.missing`.
|
|
@@ -121,7 +121,7 @@ export type NotifyDestinationTestReason = NotifyDestinationSkipReason | 'possibl
|
|
|
121
121
|
/**
|
|
122
122
|
* What became of a test post to one of your destinations, in a send status's
|
|
123
123
|
* words. A test post is made once and never tried again, so a fault a send's
|
|
124
|
-
* post would retry reads `failed`. No send is stored
|
|
124
|
+
* post would retry reads `failed`. No send is stored. Each delivered test consumes usage credits.
|
|
125
125
|
*/
|
|
126
126
|
export interface NotifyDestinationTestResult {
|
|
127
127
|
kind: NotifyDestinationKind;
|
|
@@ -311,11 +311,14 @@ export interface NotifySendPolicy {
|
|
|
311
311
|
* schedule from the account config.
|
|
312
312
|
*/
|
|
313
313
|
export interface NotifyEscalation {
|
|
314
|
-
delays
|
|
314
|
+
delays?: number[];
|
|
315
|
+
/** Defaults to true. False delivers every configured step even after the notification is seen. */
|
|
316
|
+
stop_on_seen?: boolean;
|
|
315
317
|
}
|
|
316
318
|
export interface CreateNotifySendOptions {
|
|
317
319
|
/**
|
|
318
|
-
* Idempotency key, `^[A-Za-z0-9_.:-]{1,128}$`.
|
|
320
|
+
* Idempotency key, `^[A-Za-z0-9_.:-]{1,128}$`. The `hd.` and `identity-alert:`
|
|
321
|
+
* prefixes are reserved for trusted product events. Replaying an existing id returns
|
|
319
322
|
* the stored send unchanged (never re-sealed, never re-delivered) with
|
|
320
323
|
* `idempotent: true`. Generated (`ntsnd_*`) when absent. A replay must repeat
|
|
321
324
|
* what the recipient meets (the delivery mode, the content or ingot, the
|
|
@@ -329,7 +332,7 @@ export interface CreateNotifySendOptions {
|
|
|
329
332
|
* same send.
|
|
330
333
|
*/
|
|
331
334
|
sendId?: string;
|
|
332
|
-
/** 1-500 recipients. An ingot send accepts exactly one. */
|
|
335
|
+
/** 1-500 recipients, or [] for a plaintext destination-only send with explicit destinations and channels: []. An ingot send accepts exactly one. */
|
|
333
336
|
recipients: NotifyRecipient[];
|
|
334
337
|
/** Provide exactly one content source: `content` OR `ingot`. */
|
|
335
338
|
content?: NotifySendContent;
|
|
@@ -386,9 +389,10 @@ export interface CreateNotifySendOptions {
|
|
|
386
389
|
* `false` keeps this one send out of the organization's destinations (its
|
|
387
390
|
* webhook, Slack channel and Teams workflow): none is posted to, and the
|
|
388
391
|
* send's status reports `destinations: []`. Omitted or `true`, the send is
|
|
389
|
-
* posted to every destination that routes its category.
|
|
392
|
+
* posted to every destination that routes its category. A list selects a
|
|
393
|
+
* distinct subset of configured destinations routing this category.
|
|
390
394
|
*/
|
|
391
|
-
destinations?: boolean;
|
|
395
|
+
destinations?: boolean | NotifyDestinationKind[];
|
|
392
396
|
}
|
|
393
397
|
/**
|
|
394
398
|
* Options for a preset helper (`sendAlert`, `sendSecureMessage`, …): the one
|