@sparkvault/sdk-js 19.0.1 → 19.1.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.
Files changed (132) hide show
  1. package/README.md +26 -4
  2. package/dist/npm/chunks/index-BnP-2w0t.cjs +13025 -0
  3. package/dist/npm/chunks/index-BnP-2w0t.cjs.map +1 -0
  4. package/dist/npm/chunks/index-CgR08uMG.mjs +12960 -0
  5. package/dist/npm/chunks/index-CgR08uMG.mjs.map +1 -0
  6. package/dist/npm/identity.cjs +23 -0
  7. package/dist/npm/identity.cjs.map +1 -0
  8. package/dist/npm/identity.mjs +12 -0
  9. package/dist/npm/identity.mjs.map +1 -0
  10. package/dist/{index.cjs → npm/index.cjs} +799 -13755
  11. package/dist/npm/index.cjs.map +1 -0
  12. package/dist/{index.mjs → npm/index.mjs} +200 -13155
  13. package/dist/npm/index.mjs.map +1 -0
  14. package/dist/sparkvault-identity.js +2 -0
  15. package/dist/sparkvault-identity.js.map +1 -0
  16. package/dist/sparkvault.js +1 -1
  17. package/dist/types/identity.d.ts +8 -0
  18. package/dist/{index.d.ts → types/index.d.ts} +4 -790
  19. package/dist/types/shared/errors-C-gjmGBs.d.ts +800 -0
  20. package/package.json +20 -9
  21. package/dist/api-base.d.ts +0 -116
  22. package/dist/auto-init.d.ts +0 -32
  23. package/dist/config.d.ts +0 -79
  24. package/dist/entropy/index.d.ts +0 -35
  25. package/dist/entropy/types.d.ts +0 -32
  26. package/dist/errors.d.ts +0 -146
  27. package/dist/folders/index.d.ts +0 -102
  28. package/dist/folders/types.d.ts +0 -91
  29. package/dist/health.d.ts +0 -18
  30. package/dist/http.d.ts +0 -46
  31. package/dist/index.cjs.map +0 -1
  32. package/dist/index.mjs.map +0 -1
  33. package/dist/ingots/fetch-download.d.ts +0 -78
  34. package/dist/ingots/history.d.ts +0 -4
  35. package/dist/ingots/index.d.ts +0 -388
  36. package/dist/ingots/revision.d.ts +0 -4
  37. package/dist/ingots/types.d.ts +0 -556
  38. package/dist/logger.d.ts +0 -32
  39. package/dist/notify/index.d.ts +0 -154
  40. package/dist/notify/types.d.ts +0 -232
  41. package/dist/products/help-desk/client.d.ts +0 -198
  42. package/dist/products/help-desk/desk-id.d.ts +0 -2
  43. package/dist/products/help-desk/form-draft.d.ts +0 -37
  44. package/dist/products/help-desk/form-types.d.ts +0 -123
  45. package/dist/products/help-desk/form.d.ts +0 -83
  46. package/dist/products/help-desk/index.d.ts +0 -47
  47. package/dist/products/help-desk/kb-client.d.ts +0 -48
  48. package/dist/products/help-desk/kb-types.d.ts +0 -59
  49. package/dist/products/help-desk/modal.d.ts +0 -8
  50. package/dist/products/help-desk/styles.d.ts +0 -9
  51. package/dist/products/help-desk/support-analytics-types.d.ts +0 -32
  52. package/dist/products/help-desk/support-analytics.d.ts +0 -3
  53. package/dist/products/help-desk/support-brand.d.ts +0 -49
  54. package/dist/products/help-desk/support-controller.d.ts +0 -4
  55. package/dist/products/help-desk/support-history.d.ts +0 -38
  56. package/dist/products/help-desk/support-launcher.d.ts +0 -12
  57. package/dist/products/help-desk/support-styles.d.ts +0 -14
  58. package/dist/products/help-desk/support-types.d.ts +0 -66
  59. package/dist/products/help-desk/support-view.d.ts +0 -173
  60. package/dist/products/help-desk/types.d.ts +0 -285
  61. package/dist/products/help-desk/widget-identity.d.ts +0 -32
  62. package/dist/products/identity/api.d.ts +0 -237
  63. package/dist/products/identity/container.d.ts +0 -44
  64. package/dist/products/identity/dialog-launcher.d.ts +0 -133
  65. package/dist/products/identity/federation-flow.d.ts +0 -31
  66. package/dist/products/identity/handlers/otp-handler.d.ts +0 -69
  67. package/dist/products/identity/handlers/passkey-handler.d.ts +0 -105
  68. package/dist/products/identity/handlers/sparklink-handler.d.ts +0 -34
  69. package/dist/products/identity/index.d.ts +0 -296
  70. package/dist/products/identity/inline-container.d.ts +0 -53
  71. package/dist/products/identity/methods.d.ts +0 -19
  72. package/dist/products/identity/modal.d.ts +0 -51
  73. package/dist/products/identity/pending-signin.d.ts +0 -102
  74. package/dist/products/identity/popup-launcher.d.ts +0 -73
  75. package/dist/products/identity/renderer.d.ts +0 -525
  76. package/dist/products/identity/state.d.ts +0 -84
  77. package/dist/products/identity/styles.d.ts +0 -31
  78. package/dist/products/identity/types.d.ts +0 -561
  79. package/dist/products/identity/utils/cooldown-timer.d.ts +0 -73
  80. package/dist/products/identity/utils.d.ts +0 -85
  81. package/dist/products/identity/views/backup-verify.d.ts +0 -42
  82. package/dist/products/identity/views/base.d.ts +0 -51
  83. package/dist/products/identity/views/error.d.ts +0 -65
  84. package/dist/products/identity/views/icons.d.ts +0 -41
  85. package/dist/products/identity/views/identity-input.d.ts +0 -80
  86. package/dist/products/identity/views/index.d.ts +0 -20
  87. package/dist/products/identity/views/loading.d.ts +0 -23
  88. package/dist/products/identity/views/method-button.d.ts +0 -14
  89. package/dist/products/identity/views/method-select.d.ts +0 -42
  90. package/dist/products/identity/views/origin-not-allowed.d.ts +0 -25
  91. package/dist/products/identity/views/otp-verify.d.ts +0 -58
  92. package/dist/products/identity/views/passkey-auto.d.ts +0 -22
  93. package/dist/products/identity/views/passkey-prompt.d.ts +0 -25
  94. package/dist/products/identity/views/passkey.d.ts +0 -38
  95. package/dist/products/identity/views/product-not-configured.d.ts +0 -21
  96. package/dist/products/identity/views/service-unavailable.d.ts +0 -21
  97. package/dist/products/identity/views/sms-consent.d.ts +0 -16
  98. package/dist/products/identity/views/sparklink-waiting.d.ts +0 -40
  99. package/dist/products/identity/views/two-factor.d.ts +0 -37
  100. package/dist/products/index.d.ts +0 -51
  101. package/dist/products/messaging/index.d.ts +0 -38
  102. package/dist/products/messaging/types.d.ts +0 -162
  103. package/dist/products/notify/index.d.ts +0 -436
  104. package/dist/products/notify/project-types.d.ts +0 -44
  105. package/dist/products/notify/projects.d.ts +0 -15
  106. package/dist/products/notify/types.d.ts +0 -1327
  107. package/dist/products/structured-ingots/index.d.ts +0 -31
  108. package/dist/products/structured-ingots/types-client.d.ts +0 -19
  109. package/dist/products/structured-ingots/types.d.ts +0 -293
  110. package/dist/products/structured-ingots/validation.d.ts +0 -25
  111. package/dist/request-path.d.ts +0 -44
  112. package/dist/sparks/index.d.ts +0 -91
  113. package/dist/sparks/types.d.ts +0 -304
  114. package/dist/ui/chrome.d.ts +0 -16
  115. package/dist/ui/ds-tokens.d.ts +0 -59
  116. package/dist/ui/inline-shell.d.ts +0 -19
  117. package/dist/ui/live-region.d.ts +0 -15
  118. package/dist/ui/modal-shell.d.ts +0 -67
  119. package/dist/ui/target.d.ts +0 -6
  120. package/dist/utils/dom.d.ts +0 -26
  121. package/dist/vault-session.d.ts +0 -2
  122. package/dist/vaults/index.d.ts +0 -254
  123. package/dist/vaults/types.d.ts +0 -368
  124. package/dist/vaults/upload/api.d.ts +0 -310
  125. package/dist/vaults/upload/chrome.d.ts +0 -21
  126. package/dist/vaults/upload/container.d.ts +0 -37
  127. package/dist/vaults/upload/index.d.ts +0 -76
  128. package/dist/vaults/upload/inline-container.d.ts +0 -41
  129. package/dist/vaults/upload/modal.d.ts +0 -55
  130. package/dist/vaults/upload/renderer.d.ts +0 -150
  131. package/dist/vaults/upload/styles.d.ts +0 -14
  132. package/dist/vaults/upload/types.d.ts +0 -220
@@ -1,1327 +0,0 @@
1
- /**
2
- * Notify Product Types: the TENANT (sender) surface of `/v1/products/notify/*`.
3
- *
4
- * Wire-shape convention, split deliberately and consistently:
5
- *
6
- * - **Option bags are camelCase** and mapped to the snake_case body, matching
7
- * every other data-plane module (`sparks`, `ingots`, and the recipient
8
- * `notify` module's `createdAt`). Call ergonomics belong to the caller's
9
- * language.
10
- * - **Responses mirror the wire verbatim** (snake_case), for the same reason the
11
- * recipient module documents: inbox rows and receipts are one shape shared
12
- * with `@sparkvault/sdk-mobile` and the first-party console. Do not remap them.
13
- * - **The config patch is the ONE exception on the input side**: it stays
14
- * snake_case verbatim. It is a partial PATCH against a server-validated schema
15
- * whose `categories` map is OPEN-KEYED: a tenant names its own topics
16
- * (`weekly_newsletter`) and those keys are addressed in send payloads and
17
- * rendered into recipient-facing preference URLs. Case-mapping the tree would
18
- * silently corrupt them, so the config travels exactly as the server defines it.
19
- */
20
- import type { ListNotificationsResponse, MarkNotificationStateResponse, NotificationInboxState, NotificationMarkState, NotificationBulkMarkState, NotifyInboxRow } from '../../notify/types';
21
- import type { UnsealedVault } from '../../vaults/types';
22
- /**
23
- * Every transport the dispatch seam can carry a notification on: what a send's
24
- * status, a stored ladder and a config read can name. An organization's own
25
- * send, and its config's ladders, may name six of them:
26
- *
27
- * | Channel | An organization's send |
28
- * | --- | --- |
29
- * | `in_app` | Delivered by the notification's row in your Notify inbox, which your app reads through `getInbox`: the inbox lists a recipient's row when their `in_app` step runs, at once when it leads the ladder and only when that step comes due when it follows `email` (a stop that ends the ladder first, such as an unsubscribe on a non-critical send or a recall, leaves it unlisted), so a send naming `email` alone lists nothing there, and neither does one to a recipient who switched In-app off for your site on auth.sv (any send but a `security` one, which crosses that switch) |
30
- * | `email` | Goes out from your organization's own sender (`getEmailSender`) |
31
- * | `push`, `web_push` | Reach the devices an active member of your organization, addressed by their SparkVault user id (`usr_*`), registered with SparkVault (its phone app and browser push), titled with your organization's name first; dropped from the ladder of a recipient with none |
32
- * | `sms`, `voice` | Text and call the recipient's `phone`, once texts and calls are enabled (until then refused 403 `NOTIFY_CHANNEL_NOT_AVAILABLE`): only a phone registered with SparkVault, which a SparkVault Identity holds, in the United States for a text and the United States or Canada for a call, and never one the person switched texts or calls off for on your site, whatever the category. A text opens with your organization's name and carries a plaintext send's title and body, or a sealed send's title, instructions and link; a call speaks the same words without the link. Each is funded from your usage credits when it goes out (a text by the segment, a call by the call); dropped from the ladder of a recipient with no phone |
33
- * | `whatsapp`, `rcs` | Refused 403 `NOTIFY_CHANNEL_NOT_AVAILABLE`: Notify delivers no chat message |
34
- *
35
- * A send's posts to your organization's own webhook, Slack channel or Teams
36
- * workflow are no channel: they are its destinations (`NotifyConfig['destinations']`).
37
- */
38
- export type NotifyChannel = 'in_app' | 'email' | 'sms' | 'push' | 'web_push' | 'voice' | 'whatsapp' | 'rcs';
39
- /**
40
- * The kinds of send-level destination your organization's Notify config names,
41
- * at most one of each, in the order every reader lists them: a webhook of your
42
- * own, a Slack channel (through your organization's SparkVault Slack app) and a
43
- * Microsoft Teams workflow. Each receives one post of every send whose category
44
- * it lists, never one per recipient, and never a `security` send.
45
- */
46
- export type NotifyDestinationKind = 'webhook' | 'slack' | 'teams';
47
- /**
48
- * One of a send's destinations, as its status and its history summary report it.
49
- *
50
- * - `pending`: the post has not settled yet (it is queued, or waits to be tried again).
51
- * - `delivered`: the destination accepted the post.
52
- * - `skipped`: nothing was posted, and trying again would not post it.
53
- * - `failed`: the post was given up on.
54
- * - `recalled`: the whole send was recalled before the post settled.
55
- * - `unknown`: the send's delivery record is gone (past its history horizon).
56
- */
57
- export type NotifyDestinationState = 'pending' | 'delivered' | 'skipped' | 'failed' | 'recalled' | 'unknown';
58
- /**
59
- * Why a destination's post was skipped: the sending account was suspended or
60
- * is being deleted (`account_inactive`), the destination was removed
61
- * (`destination_removed`) or stopped listing the send's category
62
- * (`destination_unrouted`) before the post went out, its URL no longer
63
- * resolves to a public host (`unsafe_url`) or answered with a redirect, which
64
- * is never followed (`redirect_refused`), or Slack's own reasons: no
65
- * SparkVault Slack app is installed (`slack_not_installed`), it needs an
66
- * admin's Refresh Connection (`slack_reauthorization_required`), the channel
67
- * is gone (`channel_not_found`) or archived (`is_archived`), the app was
68
- * removed from it (`not_in_channel`: saving the destination again adds it back
69
- * to a public channel), the notification has no visible title or sender name
70
- * (`display_not_shown`), or Slack refused it with a code of no fixed form
71
- * (`rejected_unrecognized`).
72
- */
73
- export type NotifyDestinationSkipReason = 'account_inactive' | 'destination_removed' | 'destination_unrouted' | 'unsafe_url' | 'redirect_refused' | 'slack_not_installed' | 'slack_reauthorization_required' | 'channel_not_found' | 'is_archived' | 'not_in_channel' | 'display_not_shown' | 'rejected_unrecognized';
74
- /**
75
- * Why a destination's post failed: it was sent and its answer was lost, so it
76
- * may have landed and is never tried again, since that could post it twice
77
- * (`possibly_delivered`), or every attempt met a fault that may clear, and
78
- * none was left (`attempts_exhausted`).
79
- */
80
- export type NotifyDestinationFailureReason = 'possibly_delivered' | 'attempts_exhausted';
81
- /**
82
- * The `reason` beside a skipped or failed destination: a fixed reason, the
83
- * HTTP status a webhook or Teams workflow refused the post with
84
- * (`status_404`), or the error code Slack refused it with
85
- * (`rejected_restricted_action`).
86
- */
87
- export type NotifyDestinationReason = NotifyDestinationSkipReason | NotifyDestinationFailureReason | `status_${number}` | `rejected_${string}`;
88
- /**
89
- * Why a test post reached no answer that settles it, a fault a send's post
90
- * would be tried again on: the receiver could not be reached (`network`) or
91
- * did not answer in time (`timeout`), the Teams workflow's request could not
92
- * be sent at all (`unsent`), or too little of the post's time was left to
93
- * start it (`deadline_reached`).
94
- */
95
- export type NotifyDestinationTransportReason = 'network' | 'timeout' | 'unsent' | 'deadline_reached' | 'usage_credits_exhausted' | 'usage_credit_funding_review' | 'usage_operation_pending' | 'usage_operation_released';
96
- /**
97
- * Why `updateConfig` refused a patch that lacks a field: the `details.reason`
98
- * of its 400 `VALIDATION_ERROR`, beside `details.missing`.
99
- *
100
- * - `secret_required_on_new_host`: a webhook destination's `url`, or
101
- * `events.webhook_url`, moved to another host or port without a new
102
- * `secret` beside it (`details.missing: ['secret']`). Saving again with a
103
- * new secret lands.
104
- * - `destination_incomplete`: the patch names a destination the account does
105
- * not hold, which is created with every field of its kind, and it lacks the
106
- * ones `details.missing` names. A partial patch of a destination removed
107
- * since it was read meets this too: read the config again.
108
- */
109
- export type NotifyConfigRefusalReason = 'secret_required_on_new_host' | 'destination_incomplete';
110
- /**
111
- * The `reason` beside a test post's `skipped` or `failed`
112
- * (`testDestination`): a skip reason a send status reports, or, beside
113
- * `failed`, `possibly_delivered` (the post was sent and its answer was lost),
114
- * a transport fault, a status a retry can clear (`status_503`), or the Slack
115
- * app's own: Slack limited the call (`slack_rate_limited`), another worker was
116
- * renewing the app's token (`slack_token_refresh_in_progress`), Slack could
117
- * not be reached (`slack_unavailable`), or the installation could not be read
118
- * (`installation_unavailable`).
119
- */
120
- export type NotifyDestinationTestReason = NotifyDestinationSkipReason | 'possibly_delivered' | NotifyDestinationTransportReason | 'slack_rate_limited' | 'slack_token_refresh_in_progress' | 'slack_unavailable' | 'installation_unavailable' | `status_${number}` | `rejected_${string}`;
121
- /**
122
- * What became of a test post to one of your destinations, in a send status's
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. Each delivered test consumes usage credits.
125
- */
126
- export interface NotifyDestinationTestResult {
127
- kind: NotifyDestinationKind;
128
- /** `delivered` once the destination accepted it; `skipped` when nothing was posted; `failed` when no answer settled it. */
129
- state: 'delivered' | 'skipped' | 'failed';
130
- /** Null when delivered. */
131
- reason: NotifyDestinationTestReason | null;
132
- }
133
- /**
134
- * How a send's content reaches the recipient.
135
- * - `sealed` (default): content is sealed into a Spark behind a single-use
136
- * SparkLink; channels carry only the pointer ("tap to view").
137
- * - `plaintext`: a short non-confidential body rendered INLINE in the channel
138
- * payload. Fail-closed: at most 50 recipients, never allowed on a
139
- * confidential category, and on the inline-capable channels alone, which
140
- * are all six of an organization's (`in_app`, `email`, `sms`, `push`,
141
- * `web_push`, `voice`).
142
- */
143
- export type NotifyDeliveryMode = 'sealed' | 'plaintext';
144
- /**
145
- * What a recipient must prove before the SparkLink reveals its content.
146
- *
147
- * Three levels, because three is what the Identity ceremony can achieve, and the
148
- * bar is enforced on the method the recipient ACHIEVED: a passkey-level grant is
149
- * never satisfied by an identifier session. A level the reveal cannot satisfy is
150
- * not a stronger guarantee; it is a send nobody can open.
151
- *
152
- * `identifier` is the platform default for a sealed send: unset here, the
153
- * account config's `security.verification_level` applies, and it ships as
154
- * `identifier` rather than `none` because a sealed pointer under no verification
155
- * is a bearer token.
156
- */
157
- export type NotifyVerificationLevel = 'none' | 'identifier' | 'passkey';
158
- /** What the recipient does at the reveal: the interaction the receipt attests to. */
159
- export type NotifyInteraction = 'view' | 'acknowledge' | 'sign' | 'approve' | 'reply';
160
- /**
161
- * The fixed categories the five presets classify their sends as. Each is seeded
162
- * into the account's `config.categories` like any other topic, so its
163
- * `required` flag decides whether a recipient may mute it and whether it sits on
164
- * the compliance floor: `secure`, `approval` and `signature` are seeded
165
- * required, `alert` and `conversation` are not. A tenant may demote or tombstone
166
- * any of them (only `security` is reserved). The send endpoint accepts a preset
167
- * category whatever the map holds, so an edit changes what the category
168
- * derives, never whether it can be sent.
169
- */
170
- export type NotifyPresetCategory = 'alert' | 'secure' | 'conversation' | 'approval' | 'signature';
171
- /**
172
- * A send's display category. The server accepts either a key configured in the
173
- * account's open-keyed `config.categories` map or one of the five preset
174
- * categories, so this is a string that offers the preset values as hints rather
175
- * than a closed union the account's own topics could not satisfy.
176
- */
177
- export type NotifyCategory = NotifyPresetCategory | (string & Record<never, never>);
178
- /** The five secure-by-default preset bundles. */
179
- export type NotifyPresetName = 'alert' | 'secureMessage' | 'conversation' | 'approval' | 'signatureRequest';
180
- /**
181
- * A recipient addressed by the handles the SENDER knows them by. `id` is your
182
- * own key for them, their Identity id (SVID, `ing_*`), or the SparkVault user
183
- * id (`usr_*`) of an active member of your organization, which also reaches the
184
- * devices they registered with SparkVault (`push`, `web_push`); `email` is
185
- * where the email channel delivers and the address a sealed send's recipient
186
- * proves to open it. A bare string is an email address, an E.164 phone number
187
- * (reached only by `sms` and `voice`), or one of those SparkVault ids: a bare
188
- * address is also the address its recipient proves, while a bare id keys the
189
- * person's inbox row and carries no address to verify. An `id` that is an email
190
- * address, with no `email` beside it, is that address:
191
- * `{ id: 'pat@example.com' }`, `'pat@example.com'` and
192
- * `{ email: 'pat@example.com' }` are one recipient, emailed and verified alike;
193
- * an `id` that is a phone number, with no `phone` beside it, is that phone the
194
- * same way.
195
- *
196
- * The recipient's key is its `id`, else its `email`, trimmed, with an email
197
- * address lowercased the way Identity stores it: it names their row in your
198
- * Notify inbox, and `getSendStatus` and `getSendReceipts` report it as
199
- * `recipient_id`.
200
- *
201
- * A person's stored notification preferences apply however you address them:
202
- * an SVID `id` names the person, and each address a recipient carries is
203
- * resolved to the person who holds it through Identity's directory.
204
- *
205
- * Refused with one 400 (`serviceCode` `VALIDATION_ERROR`) naming each such entry
206
- * by index: a SparkVault user id (`usr_*`) that is not an active member of your
207
- * organization (another account's member, one still invited, or no member at
208
- * all), and any id that only starts as one (`usr_`, `usr_x-1`), which names no
209
- * member; a recipient with no email address that a phone number would key (a
210
- * bare number, `{ phone }`, or an `id` that is an E.164 number) on a send whose
211
- * channels name neither `sms` nor `voice`; on a sealed send, one whose only
212
- * handle is a phone (`{ id, phone }`); and, on a sealed
213
- * send at the default `identifier` level or at `passkey`, one with no address
214
- * to verify (a bare id, or an `id` alone that is no email address): give it
215
- * `{ id, email }`, or send at `verificationLevel: 'none'`.
216
- */
217
- export interface NotifyRecipientRef {
218
- /**
219
- * At most 256 bytes of UTF-8 with no control characters: it keys the
220
- * recipient's inbox. One that is an email address, with no `email` beside
221
- * it, is also the address the recipient is emailed at and verified against.
222
- */
223
- id?: string;
224
- /**
225
- * The address the email channel delivers to. A recipient with no `id` is keyed
226
- * by its address, which is then held to the id's 256-byte bound: give an address
227
- * longer than that an `id` of your own (`{ id, email }`), or the send is refused.
228
- */
229
- email?: string;
230
- /**
231
- * E.164. What `sms` and `voice` text and call, once enabled. A recipient
232
- * keyed by a phone alone needs a plaintext send whose channels name one of
233
- * them; a sealed send also needs an `email`.
234
- */
235
- phone?: string;
236
- }
237
- export type NotifyRecipient = string | NotifyRecipientRef;
238
- /** Content to seal into a fresh Spark, one per recipient. */
239
- export interface NotifySendContent {
240
- /**
241
- * Sealed as written. A plaintext send's has its text-direction control
242
- * characters (U+202A to U+202E, U+2066 to U+2069) removed, so it shows in
243
- * the order it is written.
244
- */
245
- payload: string;
246
- /** Defaults to `text/plain`. A plaintext send accepts only `text/plain` or `text/html`. */
247
- contentType?: string;
248
- filename?: string;
249
- /**
250
- * Sealed-content lifetime: a whole number of minutes from 1 to 1440 (24h).
251
- * Defaults to 1440. A fraction is refused with a `ValidationError`. The grant
252
- * never outlives the content it points at.
253
- */
254
- ttlMinutes?: number;
255
- }
256
- /**
257
- * An EXISTING ingot to point the grant at instead of sealing new content. One
258
- * persistent asset carries a single grant, so an ingot send is 1:1: it targets
259
- * exactly one recipient.
260
- *
261
- * The recipient opens the file in the SparkVault file viewer, which has no
262
- * action bar, so an ingot send is view-only: a non-view `policy.interaction`
263
- * (including the `conversation`, `approval` and `signatureRequest` presets) is
264
- * rejected with 400 `VALIDATION_ERROR`. The vault must be the caller's with
265
- * public file sharing enabled (404 / 412 `PRECONDITION_FAILED` otherwise), and
266
- * the sender must hold a Full License (403 `LICENSE_REQUIRED`).
267
- *
268
- * Only a holder of the vault's key may publish its files, so the send carries
269
- * the unsealed vault's read-write VAT as `X-Vault-Access-Token`, exactly what
270
- * the vault's own sharing calls demand. A missing, unknown or revoked VAT is 401
271
- * `AUTHENTICATION_ERROR`; an expired one 403 (`details.reason: 'VAT_EXPIRED'`,
272
- * unseal again and retry), a read-only one 403 (`'VAT_READ_ONLY'`), and one for
273
- * another vault 403 `FORBIDDEN`.
274
- *
275
- * Each code named here is the service's and arrives as the thrown error's
276
- * `serviceCode`; a 400, 401 or 403 error's own `code` names its class
277
- * (`validation_error`, `authentication_error`, `authorization_error`).
278
- */
279
- export interface NotifyIngotRef {
280
- ingotId: string;
281
- /**
282
- * The ingot's vault, unsealed with the VMK or a read-write DVAK
283
- * (`sv.vaults.unseal(vaultId, key)`). Its id addresses the ingot and its VAT
284
- * proves key possession.
285
- */
286
- vault: UnsealedVault;
287
- }
288
- /** The access policy stamped onto each minted SparkLink grant. */
289
- export interface NotifySendPolicy {
290
- verificationLevel?: NotifyVerificationLevel;
291
- interaction?: NotifyInteraction;
292
- /** Require the recipient to have verified within N minutes of revealing. */
293
- revealFreshnessMinutes?: number;
294
- /**
295
- * What an `approve` or `sign` receipt attests the recipient acted on: 64
296
- * lowercase hex, the SHA-256 of the canonical bytes of the thing being
297
- * approved or signed. It is stamped onto every grant, and the signed receipt
298
- * carries it verbatim as its `action_hash`, so a hash recomputed later from
299
- * your own copy proves WHAT was approved. Without it the receipt carries a
300
- * digest of the grant itself, which no hash of your document can match, so
301
- * supply it on every approve and sign send. A value of another shape is
302
- * refused with 400, `serviceCode` `VALIDATION_ERROR`.
303
- */
304
- actionHash?: string;
305
- }
306
- /**
307
- * Cumulative per-step delays in SECONDS from send time, one per channel step.
308
- * Step 0 always fires immediately (any `delays[0]` is ignored), and the sequence
309
- * is aligned non-decreasing. Each value is at most 86400 (24 hours, the longest a
310
- * sealed grant lives); a later one is rejected with a 400. Omit to derive the
311
- * schedule from the account config.
312
- */
313
- export interface NotifyEscalation {
314
- delays?: number[];
315
- /** Defaults to true. False delivers every configured step even after the notification is seen. */
316
- stop_on_seen?: boolean;
317
- }
318
- export interface CreateNotifySendOptions {
319
- /**
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
322
- * the stored send unchanged (never re-sealed, never re-delivered) with
323
- * `idempotent: true`. Generated (`ntsnd_*`) when absent. A replay must repeat
324
- * what the recipient meets (the delivery mode, the content or ingot, the
325
- * recipients and their handles, title, category, instructions, policy,
326
- * channels, escalation and destinations): one that differs in any of them is
327
- * refused 400 (`serviceCode` `VALIDATION_ERROR`), and the stored send stands. `type` and
328
- * `historyTtlDays` are not compared: the stored send keeps its own. The send
329
- * stores the title, instructions and a plaintext payload without their
330
- * text-direction control characters (U+202A to U+202E, U+2066 to U+2069) and
331
- * compares a replay's the same way, so one that differs only by them is the
332
- * same send.
333
- */
334
- sendId?: string;
335
- /** 1-500 recipients, or [] for a plaintext destination-only send with explicit destinations and channels: []. An ingot send accepts exactly one. */
336
- recipients: NotifyRecipient[];
337
- /** Provide exactly one content source: `content` OR `ingot`. */
338
- content?: NotifySendContent;
339
- /** Provide exactly one content source: `content` OR `ingot`. */
340
- ingot?: NotifyIngotRef;
341
- /** Defaults to `sealed`. */
342
- delivery?: NotifyDeliveryMode;
343
- policy?: NotifySendPolicy;
344
- /**
345
- * Channel ladder override, in escalation order; omit to resolve from the
346
- * account config per category. An organization's send names its own six
347
- * channels (see `NotifyChannel`): any other, or `sms` or `voice` before texts
348
- * and calls are enabled, is refused 403, `serviceCode`
349
- * `NOTIFY_CHANNEL_NOT_AVAILABLE`, `details: { field: 'channels', channels }`.
350
- */
351
- channels?: Array<'in_app' | 'email' | 'sms' | 'push' | 'web_push' | 'voice'>;
352
- escalation?: NotifyEscalation;
353
- /**
354
- * Channel-agnostic display title (rides the email subject). Its text-direction
355
- * control characters (U+202A to U+202E, U+2066 to U+2069) are removed, and it
356
- * is cut to 200 characters, never rejected for its length. A title that reads
357
- * as SparkVault is refused 400 with
358
- * `details: { field: 'title', reason: 'reserved_name' }`: the notification goes
359
- * out in your organization's name.
360
- */
361
- title?: string;
362
- /**
363
- * REQUIRED. The category this send is classified as: one of your configured
364
- * `categories`, or a preset category. It decides the channel ladder, whether a
365
- * recipient may mute it, and whether the mail carries an unsubscribe
366
- * affordance, so the server rejects a send without one rather than guessing:
367
- * defaulting an uncategorized send either way silently changes what the
368
- * recipient consented to. The preset helpers stamp their own.
369
- */
370
- category: NotifyCategory;
371
- /**
372
- * Display classifier the tenant tags the send with, at most 64 characters once
373
- * folded to one line; a longer one is refused rather than cut short.
374
- */
375
- type?: string;
376
- /**
377
- * NON-SECRET display text (≤500 chars once its text-direction control
378
- * characters are removed) shown alongside a sealed send, such as
379
- * "verify with your passkey to open". It is never the sealed content.
380
- */
381
- instructions?: string;
382
- /**
383
- * Inbox-row retention in days, 1 to 3650. Defaults to the account's
384
- * `history.history_ttl_days` (30 unless configured); a value outside the
385
- * range is refused 400. A plaintext send is capped at 7.
386
- */
387
- historyTtlDays?: number;
388
- /**
389
- * `false` keeps this one send out of the organization's destinations (its
390
- * webhook, Slack channel and Teams workflow): none is posted to, and the
391
- * send's status reports `destinations: []`. Omitted or `true`, the send is
392
- * posted to every destination that routes its category. A list selects a
393
- * distinct subset of configured destinations routing this category.
394
- */
395
- destinations?: boolean | NotifyDestinationKind[];
396
- }
397
- /**
398
- * Options for a preset helper (`sendAlert`, `sendSecureMessage`, …): the one
399
- * send contract, with `category` optional because the preset stamps its own
400
- * when the caller names none.
401
- */
402
- export type NotifyPresetSendOptions = Omit<CreateNotifySendOptions, 'category'> & {
403
- category?: NotifyCategory;
404
- };
405
- export interface NotifySendResult {
406
- send_id: string;
407
- /** Number of recipients the send was accepted for. */
408
- recipients: number;
409
- /**
410
- * `pending`: accepted for delivery. The send row's status is written once and
411
- * never advances, so read how the send is landing from `getSendStatus` or
412
- * `listSends`, whose state is derived.
413
- */
414
- status: string;
415
- /**
416
- * Present (and `true`) ONLY on an idempotent replay of an existing `send_id`.
417
- * The first accept OMITS the field entirely; it is never `false`.
418
- */
419
- idempotent?: boolean;
420
- }
421
- /**
422
- * One preset's fixed bundle, merged UNDER the caller's own arguments. The
423
- * exported table is shared by every send in the process, so it is read-only:
424
- * `buildNotifyPresetSend` hands back options of the caller's own to adjust.
425
- */
426
- export interface NotifyPreset {
427
- readonly category: NotifyPresetCategory;
428
- readonly delivery?: NotifyDeliveryMode;
429
- readonly channels?: readonly NotifyChannel[];
430
- readonly policy: {
431
- readonly verificationLevel: NotifyVerificationLevel;
432
- readonly interaction: NotifyInteraction;
433
- };
434
- }
435
- /** Inbox views the feed can be filtered to. `all` excludes archived rows. */
436
- export type NotifyInboxView = NotificationInboxState;
437
- /** Terminal display states applicable to a single row. */
438
- export type NotifyInboxMarkState = NotificationMarkState;
439
- /**
440
- * States a BULK drain can apply. `archived` is per-row only: it has no sparse
441
- * GSI, so bulk-archiving would require a full-partition scan.
442
- */
443
- export type NotifyInboxBulkMarkState = NotificationBulkMarkState;
444
- export interface ListNotifyInboxOptions {
445
- /**
446
- * The inbox owner: the recipient's key (see `NotifyRecipientRef`), or the id
447
- * or address as the send named it, which is read in that form. Rows stay
448
- * under the key they were sent to: none is moved or aliased when the person
449
- * later gets an SVID, so a tenant that switches from email to SVID addressing
450
- * should also read the email-keyed inbox for its `history_ttl_days` window.
451
- * A SparkVault user id (`usr_*`), or any id that only starts as one, names a
452
- * member's own inbox, which only that member reads, signed in to SparkVault:
453
- * it is refused 400 `VALIDATION_ERROR` before anything is read, here and on
454
- * both marks.
455
- */
456
- recipientId: string;
457
- state?: NotifyInboxView;
458
- /** Page size, 1-100 (server default 50). */
459
- limit?: number;
460
- cursor?: string;
461
- }
462
- export type { NotifyInboxRow };
463
- /**
464
- * Both Notify inbox front doors run on one engine and page alike, so the
465
- * sender-side page is typed as the recipient feed's, with the sender's rows.
466
- */
467
- export type ListNotifyInboxResponse = Omit<ListNotificationsResponse, 'notifications'> & {
468
- notifications: NotifyInboxRow[];
469
- };
470
- export interface MarkNotifyInboxStateOptions {
471
- recipientId: string;
472
- /** The row's own `created_at` (epoch seconds), round-tripped from the feed row. */
473
- createdAt: number;
474
- state: NotifyInboxMarkState;
475
- }
476
- export type MarkNotifyInboxStateResponse = MarkNotificationStateResponse;
477
- export interface MarkNotifyInboxAllOptions {
478
- recipientId: string;
479
- state: NotifyInboxBulkMarkState;
480
- /** Continuation cursor from a prior call; loop until the response cursor is null. */
481
- cursor?: string;
482
- }
483
- export interface MarkNotifyInboxAllResponse {
484
- /** Rows marked in THIS bounded page. */
485
- updated: number;
486
- /** Next page, or null when the drain is complete. */
487
- cursor: string | null;
488
- }
489
- /**
490
- * The one answer for a recipient, derived from their row (never stored, so it
491
- * cannot drift from the facts it summarizes).
492
- *
493
- * - `pending`: still in flight, or not yet driven; the escalation ladder has a
494
- * step left to run and nothing has settled them, whatever its steps so far
495
- * recorded short of a delivery. A recipient whose first channel declined
496
- * stays here while the next one waits its turn.
497
- * - `delivered`: a channel accepted it and no provider has repudiated that, or
498
- * the recipient opened the sealed content or marked it seen and a later
499
- * escalation step recorded that before any recall.
500
- * - `undeliverable`: the ladder ran its course and every channel attempted
501
- * declined (no handle, bounced, not implemented). The recipient cannot be
502
- * reached as addressed. A hard bounce of their only delivery moves them here
503
- * at once, even with a step left to run (or to `failed`, if another channel
504
- * gave up), until a later step delivers it or records that they opened or
505
- * marked it seen. A recipient whose grant expired before a channel reached
506
- * them reads `undeliverable` too, unless a channel had already failed. Their
507
- * address may be fine: the grant can expire before their first step goes, or
508
- * while their email retries or is deferred, and then `channel_outcomes`
509
- * record no decline.
510
- * - `failed`: the ladder ran its course (or their grant expired, or a hard
511
- * bounce of their only delivery settled them), every attempt ended, and a
512
- * channel gave up: it exhausted its retries, their deferred email, text or
513
- * call could not go within 24 hours of the send, or a text or call's answer
514
- * was lost after the carrier took it (it may have reached them). OUR
515
- * transport gave up; the address may be perfectly good.
516
- * - `suppressed`: taken out of the ladder by a decision, not a fault. Usually
517
- * the PERSON chose silence (site off, category muted, every offered channel
518
- * opted out, your site blocked on auth.sv for a sealed send, or the address
519
- * unsubscribed); otherwise your account was suspended or began deleting before
520
- * their next queued step came due. Not something to route around.
521
- * - `rate_limited`: skipped by the per-recipient abuse ceiling for that minute,
522
- * decided once per send and recipient.
523
- * - `recalled`: the sender took it back, and nothing on this recipient's row
524
- * outranks the recall. The reveal is revoked and no further delivery will be
525
- * attempted. Recall cannot undo what already happened, so it ranks BELOW every
526
- * answer the row already records: `delivered` (a channel reached them, or
527
- * engagement an escalation step recorded before the recall), `suppressed`,
528
- * `rate_limited`, and `undeliverable` / `failed` when no channel could reach
529
- * them or their ladder ran its course with every channel declining or giving
530
- * up before the recall. A recall that stops a ladder before it runs its course
531
- * reads `recalled`, whatever its earlier steps recorded, so a recipient whose
532
- * first channel skipped them and who was recalled before their next channel
533
- * reads `recalled`. It also covers recipients with no row
534
- * yet: everyone a whole-audience recall stopped the fan-out before reaching,
535
- * and everyone a targeted recall named before the fan-out reached them.
536
- */
537
- export type NotifyRecipientState = 'pending' | 'delivered' | 'undeliverable' | 'failed' | 'suppressed' | 'rate_limited' | 'recalled';
538
- /**
539
- * Why the pipeline took a recipient out of the ladder, as a fixed token (never a
540
- * transport's own words, so nothing recipient-identifying rides it).
541
- *
542
- * - `no_channels`: the send offered no usable channel at all.
543
- * - `unreachable`: every offered channel lacks a handle for them.
544
- * - `global_off`: the person switched this sender off entirely.
545
- * - `category_muted`: the person muted this category.
546
- * - `all_channels_opted_out`: the person opted out of every channel offered.
547
- * - `site_blocked`: the person blocked your site on auth.sv, and the send was
548
- * sealed, so opening it asks them to prove the address it was sent to, a proof
549
- * of address that signs them in to nothing and opens no session, and their
550
- * block refuses that proof.
551
- * - `identifier_unsubscribed`: a transport reported, mid-ladder, that the
552
- * person unsubscribed the address the send was addressed to.
553
- * - `account_unavailable`: your account was suspended or began deleting before
554
- * the recipient's next queued step came due, so their ladder ended there.
555
- *
556
- * The first two roll up to the `undeliverable` state (they need an address that
557
- * reaches them), the other six to `suppressed` (a decision, not a fault: the
558
- * person asked to be left alone, or your account was stopped).
559
- */
560
- export type NotifySuppressionReason = 'no_channels' | 'unreachable' | 'global_off' | 'category_muted' | 'all_channels_opted_out' | 'site_blocked' | 'identifier_unsubscribed' | 'account_unavailable';
561
- export interface NotifySendStatusRecipient {
562
- recipient_id: string;
563
- /** The derived per-recipient state: the field to branch on. */
564
- state: NotifyRecipientState;
565
- /** True once the recipient's first delivery step was enqueued. */
566
- enqueued: boolean;
567
- seen_at: number | null;
568
- read_at: number | null;
569
- archived_at: number | null;
570
- /**
571
- * When the recipient was taken out of the ladder: by their own choice or their
572
- * block of your site, for want of an address that reaches them, or by your
573
- * account's stop. Not always an opt-out: `suppressed_reason` says why, and
574
- * `state` already separates an unreachable recipient from one who opted out.
575
- */
576
- suppressed_at: number | null;
577
- /** Why the recipient was taken out of the ladder; null while `suppressed_at` is. */
578
- suppressed_reason: NotifySuppressionReason | null;
579
- /**
580
- * When the per-recipient ceiling skipped them, decided once per send and
581
- * recipient. Only a delivery that raced the refusal (a retried fan-out that
582
- * read them admitted before it landed) clears it, and then they read as any
583
- * driven recipient.
584
- */
585
- rate_limited_at: number | null;
586
- /**
587
- * The latest dispatch outcome per attempted channel: the difference between a
588
- * notification that actually left the building and one whose every channel
589
- * declined. `{}` until the first dispatch is recorded. The adapter `detail`
590
- * string is deliberately NOT carried here: it can echo a provider response body,
591
- * and with it a phone number or address the rollup does not otherwise carry.
592
- */
593
- channel_outcomes: Partial<Record<NotifyChannel, {
594
- outcome: 'delivered'
595
- /**
596
- * The channel did not reach them and will not: no address or device
597
- * for it, or, for a text or call, `reason` `phone_opted_out`, or a
598
- * `phone_` reason it would have waited for until after its next
599
- * channel was due. The ladder moves on to its next channel.
600
- */
601
- | 'skipped' | 'not_implemented' | 'retryable'
602
- /**
603
- * An email, text or call step that could not go yet, tried again at
604
- * `retry_at` for its `reason`. Not terminal: a step that cannot go within 24 hours
605
- * of the send is recorded `failed` instead. Left out once the
606
- * recipient's record holds a stop its step meets when it wakes (they
607
- * saw the notification, it was recalled, or their ladder already
608
- * ended undelivered), since that step sends nothing. A stop held on
609
- * no record (their grant spent or expired, your account stopped) is
610
- * met only when the step wakes, and the entry stays until then.
611
- */
612
- | 'deferred'
613
- /**
614
- * The step exhausted its retries, was deferred and could not go
615
- * within 24 hours of the send, or was a text, call or email handed
616
- * on whose answer was lost (`reason` `possibly_delivered`: it may
617
- * have reached the person, so it is never sent again, and a new send
618
- * to them could reach them twice): terminal, unlike `retryable`.
619
- * The ladder moves on to its next channel.
620
- */
621
- | 'failed'
622
- /**
623
- * The provider repudiated a delivery it had accepted. It REPLACES the
624
- * channel's `delivered` entry: handing a message to the email provider
625
- * was never proof it reached a mailbox.
626
- */
627
- | 'bounced';
628
- /** Epoch seconds the outcome was recorded. */
629
- at: number | null;
630
- /** Escalation step index the outcome came from. */
631
- step: number | null;
632
- /** For a `deferred` step, epoch seconds it is tried again; null on every other outcome. */
633
- retry_at: number | null;
634
- /**
635
- * For a `deferred` step, why it waits. An email: the platform's
636
- * per-second rate or its hourly email lane, your account's hourly email
637
- * share, the provider refusing for its rate, the provider's sending
638
- * paused, the platform's own mail domain the email goes out from not
639
- * verified for sending, or your organization's own sending domain not
640
- * verified for sending (the step waits while the domain is checked
641
- * again). A text or call (the `phone_` reasons): your account's hourly
642
- * or daily share of texts and calls, the platform's daily budget for
643
- * them, the recipient's phone reached too recently or too often this
644
- * hour, the provider refusing for its rate, or texts and calls
645
- * unavailable for now. For a `skipped` text or call,
646
- * `phone_opted_out`: the phone texted STOP to the number every
647
- * organization's texts and calls go out from, so nothing went out;
648
- * the recipient's other text and call steps are skipped the same way,
649
- * the ladder carries on to its other channels, and it is never an
650
- * unsubscribe from your organization (texting START to that number
651
- * lifts it). For a `skipped` text or call, a `phone_` reason too: it
652
- * would have waited for it until after its next channel was due, so
653
- * it was passed over and the ladder went on to that channel. For a
654
- * `failed` text, call or email, `possibly_delivered`. Null on every
655
- * other outcome.
656
- */
657
- reason: 'platform_rate' | 'platform_hourly' | 'account_hourly' | 'provider_throttled' | 'sending_paused' | 'sender_identity_unverified' | 'sending_domain_unverified' | 'phone_account_rate' | 'phone_platform_budget' | 'phone_destination_rate' | 'phone_provider_throttled' | 'phone_unavailable' | 'phone_opted_out' | 'possibly_delivered' | null;
658
- }>>;
659
- /**
660
- * At least one channel accepted the notification for this recipient. A
661
- * transport fact only: `state` is `delivered` for a recipient who opened or
662
- * saw it even when every channel declined.
663
- */
664
- delivered: boolean;
665
- /**
666
- * Something was attempted, nothing delivered, and every recorded outcome
667
- * declined (`skipped`, `not_implemented`, or `bounced`). False while nothing
668
- * has been attempted yet and while a `retryable` attempt is still in flight. A
669
- * transport fact about the attempts so far: while the ladder has a step left
670
- * to run it can be true with `state` still `pending`.
671
- */
672
- undeliverable: boolean;
673
- /**
674
- * Every attempt is terminal, nothing delivered, and at least one channel's
675
- * outcome is `failed`: it exhausted its retries, was deferred and could not
676
- * go within 24 hours of the send, or was a text or call whose answer was
677
- * lost. It is a transport problem on our side, not an address that cannot
678
- * receive. A transport fact about the attempts so
679
- * far, like `undeliverable`.
680
- */
681
- failed: boolean;
682
- }
683
- export interface NotifySendStatusCounts {
684
- total: number;
685
- enqueued: number;
686
- seen: number;
687
- read: number;
688
- archived: number;
689
- /**
690
- * Recipients with a deferred email, text or call step, whatever their `state`: one no
691
- * other channel reached reads `pending` until the step runs, and one
692
- * another channel already reached reads `delivered` while it waits. A wait
693
- * is not counted once the recipient's record holds a stop its step meets
694
- * when it wakes (they saw the notification, it was recalled, or their
695
- * ladder already ended undelivered): that step sends nothing. A stop held
696
- * on no record (their grant spent or expired, your account stopped) is met
697
- * only when the step wakes, and the wait is counted until then.
698
- */
699
- deferred: number;
700
- /**
701
- * The seven state counters below PARTITION the audience, one per
702
- * `NotifyRecipientState`:
703
- * `pending + delivered + undeliverable + failed + suppressed + rate_limited + recalled === total`.
704
- * (`enqueued` / `seen` / `read` / `archived` / `deferred` are independent
705
- * progress markers and do not partition anything.)
706
- */
707
- pending: number;
708
- /** Recipients whose `state` is `delivered`. */
709
- delivered: number;
710
- /** Recipients whose `state` is `undeliverable`. */
711
- undeliverable: number;
712
- /** Recipients whose `state` is `failed`. */
713
- failed: number;
714
- /**
715
- * Recipients taken out of the ladder by a decision: their own, or your
716
- * account's stop. Never a delivery failure.
717
- */
718
- suppressed: number;
719
- /** Recipients skipped by the per-recipient ceiling. */
720
- rate_limited: number;
721
- /**
722
- * Recipients whose `state` is `recalled`: taken back by the sender with nothing
723
- * on their row outranking the recall (see `NotifyRecipientState`). A recalled
724
- * send therefore settles instead of sitting on `pending` until it expires.
725
- */
726
- recalled: number;
727
- }
728
- /**
729
- * The sender's per-recipient delivery rollup. Metadata only by construction: it
730
- * never carries the SparkLink pointer, policy internals, or a contact you did not
731
- * supply. `recipient_id` is the recipient's key (see `NotifyRecipientRef`), so a
732
- * recipient addressed by email alone appears as that address, trimmed and
733
- * lowercased. Address recipients as `{ id, email }` to keep their addresses out
734
- * of the rollup.
735
- */
736
- export interface NotifySendStatus {
737
- send_id: string;
738
- /**
739
- * DERIVED, never stored, and by the SAME function the send-history list uses,
740
- * so the two never disagree about what a state means.
741
- *
742
- * - `unknown`: no audience denominator, so no honest statement about "all
743
- * recipients" can be made.
744
- * - `pending`: accepted; nothing handed to delivery yet.
745
- * - `sending`: in flight.
746
- * - `delivered`: every recipient settled delivered, whether a channel
747
- * accepted it or their engagement was recorded (see the recipient `state`).
748
- * - `partial`: every recipient resolved; some delivered, some did not.
749
- * - `failed`: every recipient resolved and none delivered.
750
- *
751
- * A whole-audience recall resolves every recipient a channel had not already
752
- * reached, so a recalled send reads `partial`, `failed` when nothing had been
753
- * delivered, or `delivered` when every recipient already had been. The list
754
- * feeds it the send's best-effort counters (and its `recalled_at`); this view
755
- * recomputes them from the authoritative per-recipient rows. When the two
756
- * differ, this view is the one to trust; for WHY a given recipient did not get
757
- * it, read that recipient's `state`.
758
- */
759
- status: 'unknown' | 'pending' | 'sending' | 'delivered' | 'partial' | 'failed';
760
- channels: NotifyChannel[];
761
- created_at: number;
762
- title: string | null;
763
- category: string | null;
764
- type: string | null;
765
- /**
766
- * How the send carries its message. Only a `sealed` send minted a link per
767
- * recipient, so only a sealed send can be recalled (`recallSend`); a
768
- * `plaintext` one delivered its body inline.
769
- */
770
- delivery: NotifyDeliveryMode;
771
- /**
772
- * Epoch seconds of a whole-audience recall; null when there was none. A
773
- * targeted recall of named recipients never sets it; a named recipient reads
774
- * `recalled` in their `state` unless their row records something recall does
775
- * not undo (one a channel already reached stays `delivered`).
776
- */
777
- recalled_at: number | null;
778
- recipients: NotifySendStatusRecipient[];
779
- counts: NotifySendStatusCounts;
780
- /**
781
- * Each of your organization's destinations the send was routed to when it
782
- * was accepted, in `NotifyDestinationKind` order; empty when none was.
783
- * Reported beside the recipients, never part of them: `status` and `counts`
784
- * are the recipients' alone.
785
- */
786
- destinations: NotifySendStatusDestination[];
787
- }
788
- /** One of a send status's `destinations`. */
789
- export interface NotifySendStatusDestination {
790
- kind: NotifyDestinationKind;
791
- state: NotifyDestinationState;
792
- /** Epoch seconds the state was recorded; null for a post no attempt has recorded anything for yet. */
793
- at: number | null;
794
- /** Beside a `skipped` or `failed` state; null otherwise. */
795
- reason: NotifyDestinationReason | null;
796
- /**
797
- * Where the post went: the webhook's host, the Slack channel id, or the
798
- * Teams workflow's host. Null when no attempt recorded one.
799
- */
800
- target: string | null;
801
- /**
802
- * The Slack channel's name beside its id in `target`, as the Slack
803
- * destination's `channel_name` read when the post was decided. Null for a
804
- * webhook or Teams post, whose host names itself, and for a Slack post whose
805
- * destination held no name.
806
- */
807
- target_name: string | null;
808
- }
809
- /**
810
- * A send's delivery state, DERIVED from its counters: the send row itself is
811
- * write-once, so there is no stored lifecycle to read.
812
- *
813
- * `failed` counts every recipient who reached a terminal answer without being
814
- * delivered (declined, retries exhausted, opted out, rate limited, a bounce that
815
- * repudiated a delivery, or a recall that ended their ladder), so
816
- * `delivered + failed` is how many have resolved; a recipient still climbing
817
- * the escalation ladder is in neither,
818
- * which is why an in-flight send reads `sending` rather than being scored early.
819
- * A whole-audience recall resolves every recipient a channel had not already
820
- * reached, so a recalled send reads `partial` or `failed` (see `recalled_at`).
821
- *
822
- * `unknown` means no statement about all of a send's recipients can be made:
823
- * it carries no audience denominator (`recipient_count` null or 0), or its
824
- * counters cannot be read (it is past its history horizon and its counters are
825
- * already gone). The state is reported as not knowable rather than guessed at.
826
- */
827
- export type NotifySendState = 'unknown' | 'pending' | 'sending' | 'delivered' | 'partial' | 'failed';
828
- /**
829
- * One row of the account's send history. Metadata only: the audience is not
830
- * projected into the history index, so this shape cannot carry a recipient's
831
- * contact or the SparkLink pointer.
832
- *
833
- * A counter the send row does not carry is `null`, never an invented 0: each
834
- * delivery counter is created by its first increment, so on a send with a
835
- * `recipient_count` a null counter counts 0. An in-flight send reads
836
- * `delivered_count: null` until its first delivery, and a send no recipient
837
- * failed keeps `failed_count: null`.
838
- */
839
- export interface NotifySendSummary {
840
- send_id: string | null;
841
- /** Named project id; absent on Default. */
842
- notify_project_id?: string;
843
- /** Epoch seconds. */
844
- created_at: number | null;
845
- title: string | null;
846
- category: string | null;
847
- delivery: NotifyDeliveryMode | null;
848
- /** The sender name recipients saw. Display only: nothing routes on it. */
849
- display_sender_name: string | null;
850
- /**
851
- * Audience size at accept: the denominator of the counters below. Null or 0
852
- * only on a send that carries no audience count, which reads
853
- * `state: 'unknown'`.
854
- */
855
- recipient_count: number | null;
856
- /** Recipients whose first delivery step was handed to delivery. */
857
- enqueued_count: number | null;
858
- /**
859
- * Recipients settled delivered, on the same evidence as the recipient
860
- * `delivered` state: a channel accepted it, or they opened the sealed content
861
- * or marked it seen and a later escalation step recorded that before any recall.
862
- */
863
- delivered_count: number | null;
864
- /**
865
- * Recipients who reached a terminal answer without being delivered: every
866
- * attempted channel declined or gave up, they were suppressed or rate limited,
867
- * or they were recalled before a channel reached them (counted when the next
868
- * step of their ladder stops on the revoked grant).
869
- */
870
- failed_count: number | null;
871
- /**
872
- * Epoch seconds of a whole-audience recall; null when there was none (a
873
- * targeted recall of named recipients never sets it: those recipients resolve
874
- * through `failed_count`, and `getSendStatus` names them `recalled`). A
875
- * recalled send settles: the remainder it withdrew counts as resolved without
876
- * being delivered, so `state` reads `partial`, `failed` when nothing had been
877
- * delivered, or `delivered` when every recipient already had been: this is
878
- * what tells that recall apart from a delivery failure.
879
- */
880
- recalled_at: number | null;
881
- state: NotifySendState;
882
- /**
883
- * The state of each of your organization's destinations the send was routed
884
- * to, in `NotifyDestinationKind` order (empty when none was), with the reason
885
- * beside a `skipped` or `failed` one, as `getSendStatus` reports them; null
886
- * when the send's delivery record is gone (`state: 'unknown'`).
887
- */
888
- destinations: NotifySendSummaryDestination[] | null;
889
- }
890
- /** One of a send-history summary's `destinations`. */
891
- export interface NotifySendSummaryDestination {
892
- kind: NotifyDestinationKind;
893
- state: NotifyDestinationState;
894
- /** Beside a `skipped` or `failed` state; null otherwise. */
895
- reason: NotifyDestinationReason | null;
896
- }
897
- export interface ListNotifySendsOptions {
898
- /** Page size, 1-100 (server default 50). */
899
- limit?: number;
900
- cursor?: string;
901
- }
902
- export interface ListNotifySendsResponse {
903
- sends: NotifySendSummary[];
904
- /** Next-page cursor, or null on the last page. This is a real key query: a full page means more may follow, a null cursor means the end. */
905
- cursor: string | null;
906
- }
907
- /**
908
- * Recall depth.
909
- * - `grant` (default): revoke the access grant; the content survives.
910
- * - `content`: hard-burn the sealed spark so the content is unreadable for
911
- * everyone, then drop the grant. Spark-backed sends only: an ingot send
912
- * references the owner's durable vault content and can only be grant-recalled, so
913
- * a `content` recall of one is a 400, refused before anything is revoked or
914
- * stopped.
915
- */
916
- export type NotifyRecallMode = 'grant' | 'content';
917
- export interface RecallNotifySendOptions {
918
- /**
919
- * Recall only these recipients. OMIT to recall the whole audience. An empty
920
- * array is rejected rather than guessed at, because "nobody" and "everybody"
921
- * are both plausible readings of it on a destructive call.
922
- */
923
- recipientIds?: string[];
924
- mode?: NotifyRecallMode;
925
- }
926
- export interface RecallNotifySendResponse {
927
- send_id: string;
928
- mode: NotifyRecallMode;
929
- /** Grants revoked. An already-revoked grant counts here: recall is idempotent. */
930
- recalled: number;
931
- failed: number;
932
- /** Requested recipient ids that are not on this send's audience. */
933
- not_found: string[];
934
- /**
935
- * One entry per recipient whose recall failed (the rest still ran). `error`
936
- * is the code the API answers that failure with on its own: a refusal's code
937
- * (such as `VALIDATION_ERROR`), else `INTERNAL_ERROR` or a public server
938
- * error code (such as `CRYPTOGRAPHIC_ERROR`); never the error's text.
939
- */
940
- failures: Array<{
941
- recipient_id: string;
942
- error: string;
943
- }>;
944
- }
945
- /** The five verified-interaction receipt subtypes (SparkLink lifecycle events are not receipts). */
946
- export type NotifyReceiptEventType = 'sparklink_accessed' | 'sparklink_signed' | 'sparklink_approved' | 'sparklink_denied' | 'sparklink_replied';
947
- /**
948
- * Every verification level a receipt can report: the levels a send may ask for,
949
- * and `out_of_band` and `dual_control`, which no send can ask for but a stored
950
- * grant may name, and is enforced at.
951
- */
952
- export type NotifyReportableVerificationLevel = NotifyVerificationLevel | 'out_of_band' | 'dual_control';
953
- /**
954
- * The receipt of a verified interaction. A ceremony's (acknowledge, sign,
955
- * approve, reply) is portable proof: `signed_token` is the Identity-signed
956
- * EdDSA token a third party verifies against the tenant's JWKS, and
957
- * `action_hash` binds it to the action an approve or a sign answered. An
958
- * open's (`sparklink_accessed`) is an unsigned access record: its
959
- * `signed_token` is null. An acknowledge records `sparklink_signed`, as a sign
960
- * does; `interaction` tells them apart. `link_code` is masked (`abc123***`)
961
- * exactly as stored.
962
- */
963
- export interface NotifyReceipt {
964
- event_type: NotifyReceiptEventType | null;
965
- occurred_at: number | null;
966
- interaction: NotifyInteraction | null;
967
- identity: string | null;
968
- asset_id: string | null;
969
- vault_id: string | null;
970
- link_code: string | null;
971
- /**
972
- * The correlation key the interaction events quote (`notify.signed`,
973
- * `notify.approved`, `notify.denied`, `notify.replied`): 32 hex of the SHA-256
974
- * over the grant code, never the code itself. Match an event to its receipt on
975
- * this, never on `link_code`. Null on a receipt stored without one, which only
976
- * its `link_code` names.
977
- */
978
- link_code_hash: string | null;
979
- link_type: string | null;
980
- verification_level: NotifyReportableVerificationLevel | null;
981
- action_hash: string | null;
982
- signed_token: string | null;
983
- decision: string | null;
984
- thread_id: string | null;
985
- reply_spark_id: string | null;
986
- /**
987
- * The send whose grant produced this receipt, stamped at mint time: present on
988
- * a `listReceipts` receipt of a grant a Notify send created, and null for a
989
- * standalone SparkLink. Null on every `getSendReceipts` row, which is read from
990
- * the audit rows; the send there is the one you asked for.
991
- */
992
- send_id: string | null;
993
- /** The send's display title, alongside `send_id` and under the same conditions. */
994
- title: string | null;
995
- /** The receipt's own id. Null on a per-send receipt (`getSendReceipts`). */
996
- receipt_id: string | null;
997
- }
998
- /** A receipt correlated to the recipient whose grant produced it. */
999
- export interface NotifySendReceipt extends NotifyReceipt {
1000
- recipient_id: string;
1001
- }
1002
- export interface ListNotifyReceiptsOptions {
1003
- /** Page size, 1-100 (server default 50). */
1004
- limit?: number;
1005
- cursor?: string;
1006
- /** Narrow to a single interaction mode. */
1007
- interaction?: NotifyInteraction;
1008
- }
1009
- export interface ListNotifyReceiptsResponse {
1010
- receipts: NotifyReceipt[];
1011
- /**
1012
- * Next-page cursor, or null on the last page. A page can still come back SHORT
1013
- * of `limit` (even empty) while more rows follow (`interaction` narrows with
1014
- * a filter applied after each page is read), so follow the cursor; never treat
1015
- * a short page as the end.
1016
- */
1017
- cursor: string | null;
1018
- }
1019
- export interface NotifySendReceiptsResponse {
1020
- send_id: string;
1021
- receipts: NotifySendReceipt[];
1022
- /**
1023
- * True when the call's page cap stopped the walk before it reached the send's
1024
- * creation, so more receipts of this send may follow: re-call with `cursor`.
1025
- * False means `receipts` is the send's whole set: no receipt of a send
1026
- * predates it, so the walk never reads further back.
1027
- */
1028
- truncated: boolean;
1029
- /** Where the next call resumes a truncated walk; null when it is complete. */
1030
- cursor: string | null;
1031
- }
1032
- /** One notification topic. `required: true` is the compliance floor, unmutable by the recipient. */
1033
- export interface NotifyConfigCategory {
1034
- /** ≤60 chars. */
1035
- label?: string;
1036
- /** ≤200 chars. */
1037
- description?: string;
1038
- required?: boolean;
1039
- }
1040
- /** When the email step goes, in whole minutes from send time, 0..1440 (24 hours). */
1041
- export interface NotifyConfigRealtimeFallbackDelay {
1042
- email_minutes?: number;
1043
- }
1044
- export interface NotifyConfigDelivery {
1045
- default_channels?: NotifyChannel[];
1046
- /** Per-category channel order, keyed by category. */
1047
- channel_priority?: Record<string, NotifyChannel[]>;
1048
- realtime_fallback_delay?: NotifyConfigRealtimeFallbackDelay;
1049
- escalation_enabled?: boolean;
1050
- }
1051
- /**
1052
- * `delivery` as a patch writes it. Its ladders name an organization's own six
1053
- * channels, `in_app`, `email`, `sms`, `push`, `web_push` and `voice` (see
1054
- * `NotifyChannel`): any other, or `sms` or `voice` before texts and calls are
1055
- * enabled, is refused 403, `serviceCode` `NOTIFY_CHANNEL_NOT_AVAILABLE`,
1056
- * `details.field` naming the ladder's field (and `details.category` the
1057
- * category, for a category's ladder in `channel_priority`), and nothing is
1058
- * stored.
1059
- */
1060
- export interface NotifyConfigDeliveryPatch extends Omit<NotifyConfigDelivery, 'channel_priority'> {
1061
- /**
1062
- * Per-category channel order. Each ladder names at least one channel, each at
1063
- * most once; a NEW key must name a category a send can carry (one of the
1064
- * account's, one the same patch creates, or a preset category). `null` removes
1065
- * that category's ladder. At most 50 ladders.
1066
- */
1067
- channel_priority?: Record<string, NotifyChannel[] | null>;
1068
- }
1069
- export interface NotifyConfigReliability {
1070
- /**
1071
- * Notifications per recipient per minute, 1-600, counted per person: a
1072
- * recipient counts against its own id and each email or phone it names. An
1073
- * abuse/bug backstop the tenant cannot switch off: 0 is rejected.
1074
- */
1075
- rate_limit_per_recipient_per_minute?: number;
1076
- }
1077
- export interface NotifyConfigHistory {
1078
- /** Inbox-row retention in whole days, 1 to 3650 (default 30). */
1079
- history_ttl_days?: number;
1080
- /** Receipt retention in whole days, 1 to 3650 (default 365). */
1081
- receipt_retention_days?: number;
1082
- }
1083
- export interface NotifyConfigSecurity {
1084
- verification_level?: NotifyVerificationLevel;
1085
- /** 0 = off. */
1086
- reveal_freshness_minutes?: number;
1087
- /**
1088
- * Categories that must seal, ADDED to the hardcoded confidential baseline
1089
- * (`secure`/`conversation`/`approval`/`signature`). Expand-only: the baseline can
1090
- * never be removed here.
1091
- */
1092
- mandatory_seal_categories?: string[];
1093
- }
1094
- /**
1095
- * The account's outbound EVENT webhook: how a backend learns, without polling
1096
- * for it, that a recipient signed, approved, denied, or replied
1097
- * (`notify.signed`, `notify.approved`, `notify.denied`, `notify.replied`), and
1098
- * how delivery to each recipient turned out (`notify.delivered`,
1099
- * `notify.failed`, `notify.bounced`). Opening a notification emits no event:
1100
- * read view receipts with `listReceipts`.
1101
- *
1102
- * Both fields are required before anything is sent: an unsigned event is not
1103
- * offered. `webhook_url` must be https on a public host (loopback, private,
1104
- * link-local, and CGNAT addresses are rejected server-side). A patch names only
1105
- * what it changes, but a `webhook_url` on another host or port than the
1106
- * stored one needs a new `secret` in the same patch (400 `VALIDATION_ERROR`
1107
- * naming `events.secret`, `details.missing: ['secret']`, `details.reason:
1108
- * 'secret_required_on_new_host'`): a secret never follows its URL to a
1109
- * different host. A patch of `events: null` removes the
1110
- * webhook, URL and secret together, and no event is sent from then on; a
1111
- * `null` for either field alone is refused 400.
1112
- *
1113
- * Each event is POSTed as JSON with a `User-Agent` that begins `SparkVault/`,
1114
- * so an edge in front of the receiver that refuses a request without one lets
1115
- * it through.
1116
- *
1117
- * Delivery is BEST EFFORT: one retry, then the event is dropped. Polling
1118
- * (`listSends`, `getSendStatus`, `listReceipts`) remains the source of truth;
1119
- * the webhook exists to make that poll rare, not to replace it.
1120
- */
1121
- export interface NotifyConfigEvents {
1122
- /**
1123
- * https only, ≤2048 chars. WRITE-ONLY: a config read reports
1124
- * `webhook_url_set` and `webhook_url_host` instead, since a catch hook's URL
1125
- * carries its own token.
1126
- */
1127
- webhook_url?: string;
1128
- /**
1129
- * HMAC-SHA256 signing secret, 16-256 chars. Sent as the hex digest of the raw
1130
- * body in `X-SparkVault-Signature`. WRITE-ONLY: a config read reports
1131
- * `secret_set` instead of the value.
1132
- */
1133
- secret?: string;
1134
- }
1135
- /** `events` as it comes BACK from a read: neither the URL nor the secret is ever echoed. */
1136
- export interface NotifyConfigEventsRead {
1137
- /** Whether an event webhook URL is stored. The URL itself is never returned. */
1138
- webhook_url_set?: boolean;
1139
- /** The stored event webhook URL's host, so an editor can say where events go. */
1140
- webhook_url_host?: string;
1141
- /** Whether a signing secret is stored. The secret itself is never returned. */
1142
- secret_set?: boolean;
1143
- }
1144
- /**
1145
- * Your own HTTPS endpoint as a destination. Each routed send is POSTed to `url`
1146
- * once as JSON, signed like the event webhook (the hex HMAC-SHA256 of the raw
1147
- * body under `secret`, in `X-SparkVault-Signature`) and, like it, with a
1148
- * `User-Agent` that begins `SparkVault/`; a post that may not have
1149
- * landed is tried again with the same `delivery_id`, so drop a repeat you
1150
- * already received. A redirect is never followed.
1151
- */
1152
- export interface NotifyWebhookDestination {
1153
- /**
1154
- * https only on a public host, ≤2048 chars. WRITE-ONLY: a read reports
1155
- * `url_set` and `url_host` instead, since a catch hook's URL carries its own
1156
- * token.
1157
- */
1158
- url: string;
1159
- /** Signing secret, 16-256 chars. WRITE-ONLY: a read reports `secret_set` instead. */
1160
- secret: string;
1161
- /**
1162
- * The categories whose sends it receives one post of: 1-50, each once, each a
1163
- * category a send can carry, never `security` (a person's security notices go
1164
- * only to that person). A refused one is a 400 naming it in `details.category`.
1165
- */
1166
- categories: string[];
1167
- }
1168
- /** The webhook destination as a read returns it: neither its URL nor its secret is ever echoed. */
1169
- export interface NotifyWebhookDestinationRead {
1170
- /** Whether an endpoint URL is stored. The URL itself is never returned. */
1171
- url_set: boolean;
1172
- /** The stored endpoint URL's host, so an editor can say which endpoint it is. */
1173
- url_host: string;
1174
- /** Whether a signing secret is stored. The secret itself is never returned. */
1175
- secret_set: boolean;
1176
- categories: string[];
1177
- }
1178
- /**
1179
- * A channel in your organization's Slack workspace as a destination, posted to
1180
- * through its SparkVault Slack app installation. A save naming `channel_id`
1181
- * (even the one already saved) prepares the channel first: the app reads it and
1182
- * joins a public one it is not in, and a private channel needs the app invited
1183
- * first. A channel the app cannot post in is refused 400 with `details.reason`
1184
- * naming why, and nothing is stored.
1185
- */
1186
- export interface NotifySlackDestination {
1187
- /** The channel's Slack id, as the console's channel picker lists it. */
1188
- channel_id: string;
1189
- /** As `NotifyWebhookDestination['categories']`. */
1190
- categories: string[];
1191
- }
1192
- /** The Slack destination as a read returns it: its channel by id and by name. */
1193
- export interface NotifySlackDestinationRead extends NotifySlackDestination {
1194
- /**
1195
- * The channel's name, without its `#`, as Slack named it when the last save
1196
- * naming `channel_id` prepared it, so every such save refreshes it. Set by
1197
- * the save, never by a patch (one naming it is refused 400). Null until a
1198
- * save naming `channel_id` captures it.
1199
- */
1200
- channel_name: string | null;
1201
- }
1202
- /** A Microsoft Teams workflow as a destination, posted to through its webhook URL. */
1203
- export interface NotifyTeamsDestination {
1204
- /**
1205
- * https only on a public host, ≤2048 chars. The URL is itself the credential
1206
- * that posts to the channel. WRITE-ONLY: a read reports `webhook_url_set`
1207
- * and `webhook_url_host` instead.
1208
- */
1209
- webhook_url: string;
1210
- /** As `NotifyWebhookDestination['categories']`. */
1211
- categories: string[];
1212
- }
1213
- /** The Teams destination as a read returns it: the workflow URL is never echoed. */
1214
- export interface NotifyTeamsDestinationRead {
1215
- /** Whether a workflow URL is stored. */
1216
- webhook_url_set: boolean;
1217
- /** The stored workflow URL's host, so an editor can say which workflow it is. */
1218
- webhook_url_host: string;
1219
- categories: string[];
1220
- }
1221
- /** The destinations a config read returns, each present only once configured. */
1222
- export interface NotifyConfigDestinations {
1223
- webhook?: NotifyWebhookDestinationRead;
1224
- slack?: NotifySlackDestinationRead;
1225
- teams?: NotifyTeamsDestinationRead;
1226
- }
1227
- /**
1228
- * A patch of the destinations: null removes the destination of its kind; an
1229
- * object creates it, naming every field, or patches the one stored, naming
1230
- * only what it changes (a credential it leaves out stays as stored); one
1231
- * created without every field is refused 400 `VALIDATION_ERROR` with
1232
- * `details.missing` and `details.reason: 'destination_incomplete'`. A webhook
1233
- * `url` on another host or port than the stored one needs a new `secret` in
1234
- * the same patch (400 `VALIDATION_ERROR` naming
1235
- * `destinations.webhook.secret`, `details.missing: ['secret']`,
1236
- * `details.reason: 'secret_required_on_new_host'`): a secret never follows its
1237
- * URL to a different host. (`NotifyConfigRefusalReason`)
1238
- */
1239
- export interface NotifyConfigDestinationsPatch {
1240
- webhook?: Partial<NotifyWebhookDestination> | null;
1241
- slack?: Partial<NotifySlackDestination> | null;
1242
- teams?: Partial<NotifyTeamsDestination> | null;
1243
- }
1244
- /** The account's effective config: secure defaults deep-merged with its overrides. */
1245
- export interface NotifyConfig {
1246
- delivery: NotifyConfigDelivery;
1247
- reliability: NotifyConfigReliability;
1248
- history: NotifyConfigHistory;
1249
- security: NotifyConfigSecurity;
1250
- /** Absent until the account configures an event webhook. */
1251
- events?: NotifyConfigEventsRead;
1252
- /**
1253
- * Who the organization's Notify email is from. `sending_domain` is the
1254
- * organization's own domain its email is selected to go out from (as
1255
- * `notify@{domain}`), or null for its handle under send.sv; `getEmailSender`
1256
- * says whether it serves now.
1257
- */
1258
- email: {
1259
- sending_domain: string | null;
1260
- };
1261
- /** Your organization's send-level destinations; empty until an admin configures one. */
1262
- destinations: NotifyConfigDestinations;
1263
- /** Tombstoned entries are already dropped; a deleted category is simply gone. */
1264
- categories: Record<string, NotifyConfigCategory>;
1265
- }
1266
- /**
1267
- * A partial PATCH of the account's config overrides. Only the sections present are
1268
- * touched, and every field is validated server-side before any write.
1269
- *
1270
- * `categories.<key>: null` DELETES a category. A seeded default's delete (say
1271
- * `marketing`) is stored as a tombstone, which keeps the default from
1272
- * re-appearing on the next merge; any other delete leaves no entry. Storing a
1273
- * normal object under the same key later re-creates it. The reserved `security`
1274
- * category can neither be removed nor made optional, the promotional
1275
- * categories `marketing` and `product` can never be made required: their email
1276
- * always carries an unsubscribe link, and `help_desk_alert` can be neither
1277
- * removed nor made required: each member decides on auth.sv, under it, whether
1278
- * the help desk's alerts reach them. Each refusal is a 400 `VALIDATION_ERROR`
1279
- * naming the category in `details.category`.
1280
- */
1281
- export interface NotifyConfigPatch {
1282
- delivery?: NotifyConfigDeliveryPatch;
1283
- reliability?: NotifyConfigReliability;
1284
- history?: NotifyConfigHistory;
1285
- /** Admin only. */
1286
- security?: NotifyConfigSecurity;
1287
- /** Admin only. `null` removes the event webhook. */
1288
- events?: NotifyConfigEvents | null;
1289
- /**
1290
- * Admin only. `sending_domain`: one of the organization's own domains, its
1291
- * ownership verified and its email sending ready, to send from as
1292
- * `notify@{domain}`; null sends from the organization's handle,
1293
- * `notify@{handle}.send.sv`. A domain the organization does not hold is
1294
- * refused 404, one not ready for Notify 409 `DOMAIN_NOT_READY`
1295
- * (`details: { domain, product: 'notify' }`), and a change past the
1296
- * organization's hourly sending-domain selections 429.
1297
- */
1298
- email?: {
1299
- sending_domain?: string | null;
1300
- };
1301
- /** Admin only. */
1302
- destinations?: NotifyConfigDestinationsPatch;
1303
- categories?: Record<string, NotifyConfigCategory | null>;
1304
- }
1305
- /**
1306
- * The stored override delta, seeded-category tombstones included, because that is
1307
- * what a write merges onto. The credentials are held back: `events.secret` and
1308
- * the webhook destination's `secret` come back as `secret_set`, the webhook
1309
- * destination's `url` as `url_set` and `url_host`, and `events.webhook_url` and
1310
- * the Teams destination's `webhook_url` as `webhook_url_set` and
1311
- * `webhook_url_host`, so a patch never has to resend them.
1312
- */
1313
- export type NotifyConfigOverrides = Omit<NotifyConfigPatch, 'events' | 'destinations'> & {
1314
- events?: NotifyConfigEventsRead;
1315
- destinations?: NotifyConfigDestinations;
1316
- };
1317
- export interface NotifyConfigResponse {
1318
- effective: NotifyConfig;
1319
- overrides: NotifyConfigOverrides;
1320
- /**
1321
- * The version of the stored configuration this answer shows: 0 before
1322
- * anything is saved, one higher with each save that lands. Of two answers
1323
- * to overlapping saves, which can arrive in either order, the one with the
1324
- * higher version is the newer configuration.
1325
- */
1326
- version: number;
1327
- }