samva 0.43.0 → 0.43.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +9 -9
- package/dist/client/sdk.gen.d.ts +3 -3
- package/dist/client/sdk.gen.js +3 -3
- package/dist/client/types.gen.d.ts +4 -4
- package/dist/effect/generated/campaigns.js +1 -1
- package/dist/effect/generated/mailboxes.d.ts +148 -148
- package/dist/effect/generated/mailboxes.js +2 -0
- package/dist/effect/generated/messages.js +1 -1
- package/dist/effect/generated/scheduled-messages.js +1 -1
- package/dist/effect/generated/shared.d.ts +10 -10
- package/dist/effect/generated/shared.js +2 -0
- package/dist/effect/mailboxes.d.ts +16 -16
- package/dist/mailbox/types.d.ts +1 -1
- package/dist/package.js +1 -1
- package/dist/promises/errors.gen.js +4 -0
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# samva
|
|
2
2
|
|
|
3
|
-
Samva is
|
|
3
|
+
Samva is email and WhatsApp for AI agents, and the API developers build on. An agent gets its own address and WhatsApp number, and the same platform covers transactional and campaign sending, inbound replies threaded into conversations, programmable mailboxes, and signed webhooks.
|
|
4
4
|
|
|
5
5
|
TypeScript SDK for Samva's public customer API.
|
|
6
6
|
|
|
@@ -144,7 +144,7 @@ const samva = createClient({
|
|
|
144
144
|
```
|
|
145
145
|
|
|
146
146
|
- `X-API-Key` is configured automatically from `apiKey`.
|
|
147
|
-
- Organization context is derived from the API key
|
|
147
|
+
- Organization context is derived from the API key, so do not send `x-org-slug`.
|
|
148
148
|
|
|
149
149
|
### OAuth bearer (interactive, multi-org)
|
|
150
150
|
|
|
@@ -256,9 +256,9 @@ error with `Effect.catchTag` does not require importing its constructor.
|
|
|
256
256
|
|
|
257
257
|
Both clients retry safe operations by default:
|
|
258
258
|
|
|
259
|
-
- **What retries
|
|
260
|
-
- **When
|
|
261
|
-
- **How
|
|
259
|
+
- **What retries**: reads (`GET`/`HEAD`) and requests covered by `x-idempotent` in the OpenAPI document and its optional `x-idempotent-when` condition. Both clients attach one key per logical call and reuse it across retries. Other mutations never retry.
|
|
260
|
+
- **When**: only for `isRetryable` failures: throttling (`429`), transient server errors (including a transient `BillingProviderError`), and request-transport failures. `ValidationError`, `ConflictError`, `NotFound`, auth, and billing-limit `PaymentRequiredError` failures never retry.
|
|
261
|
+
- **How**: jittered exponential backoff, bounded to four attempts total. A `429` honors the server's `retryAfterSeconds` hint (capped at 60s) in place of the computed delay.
|
|
262
262
|
|
|
263
263
|
`contacts.startImport` retries only `mode: "new"`. Resumes use a generation fence and never retry automatically, even with an explicit key. After an ambiguous resume response, read `contacts.getImportJob` before deciding what to do next.
|
|
264
264
|
|
|
@@ -278,7 +278,7 @@ program.pipe(Effect.provide(Retry.layer({ times: 6, while: isRetryable })));
|
|
|
278
278
|
|
|
279
279
|
### Idempotency keys
|
|
280
280
|
|
|
281
|
-
Each idempotent operation generates an `Idempotency-Key` per logical call
|
|
281
|
+
Each idempotent operation generates an `Idempotency-Key` per logical call, stable across the built-in retries and distinct across calls, so a retried send never delivers twice. Pass an explicit key for cross-process deduplication (safe to replay the same request from a different machine):
|
|
282
282
|
|
|
283
283
|
```typescript
|
|
284
284
|
import { createClient } from "samva";
|
|
@@ -307,8 +307,8 @@ Effect pagination uses Streams:
|
|
|
307
307
|
|
|
308
308
|
Every list answers `{ items, nextCursor }`: pass `nextCursor` back as `cursor` for the next page, and stop when it is null. Every list operation that pages carries two `Stream` companions, so you traverse pages without hand-rolling a cursor loop:
|
|
309
309
|
|
|
310
|
-
- **`list.items(input?)
|
|
311
|
-
- **`list.pages(input?)
|
|
310
|
+
- **`list.items(input?)`**: a `Stream` of individual items across all pages.
|
|
311
|
+
- **`list.pages(input?)`**: a `Stream` of raw page envelopes.
|
|
312
312
|
|
|
313
313
|
```typescript
|
|
314
314
|
import { Effect, Stream } from "effect";
|
|
@@ -334,7 +334,7 @@ Effect client configuration accepts `apiKey: string | Redacted<string>` and unwr
|
|
|
334
334
|
only for authentication. Promise client configuration accepts `apiKey: string` and does not require
|
|
335
335
|
Effect, including in browser bundles.
|
|
336
336
|
|
|
337
|
-
Secret-bearing response fields
|
|
337
|
+
Secret-bearing response fields (the plaintext API key returned by `apiKeys.create` / `apiKeys.rotate`, and the webhook signing secret from `webhooks.regenerateSecret`) decode to `Redacted<string>` on the Effect surface. The secret never leaks through logs, `String(...)`, or `JSON.stringify`; unwrap it explicitly with `Redacted.value` when you need the plaintext:
|
|
338
338
|
|
|
339
339
|
```typescript
|
|
340
340
|
import { Effect, Redacted } from "effect";
|
package/dist/client/sdk.gen.d.ts
CHANGED
|
@@ -37,7 +37,7 @@ export declare class Messages {
|
|
|
37
37
|
/**
|
|
38
38
|
* Send a message
|
|
39
39
|
*
|
|
40
|
-
* Sends a message on the requested channel and returns its receipt (id, status, and why it waits when it does) with a 201 Created status. Requires `messages:create` or the send permission of the channel it sends on, such as `email:send`. `channel` selects the payload variant. Email and WhatsApp sends are available. Repeating an identical request with the same optional `Idempotency-Key` header returns the original receipt; reusing the key for different content returns a conflict.
|
|
40
|
+
* An email send whose namespace has no sending setup returns ValidationError: share the sender domain with namespaces, or use a sender owned by that namespace. Sending setup that has stopped after failure returns ValidationError; restart or reconcile the domain's sending setup. Setup still in progress returns ConflictError. Sends a message on the requested channel and returns its receipt (id, status, and why it waits when it does) with a 201 Created status. Requires `messages:create` or the send permission of the channel it sends on, such as `email:send`. `channel` selects the payload variant. Email and WhatsApp sends are available. Repeating an identical request with the same optional `Idempotency-Key` header returns the original receipt; reusing the key for different content returns a conflict.
|
|
41
41
|
*/
|
|
42
42
|
static send<ThrowOnError extends boolean = false>(parameters: EmailSendMessagePayload | SmsSendMessagePayload | WhatsAppSendMessagePayload, options?: Options<never, ThrowOnError>): RequestResult<MessagesSendResponses, MessagesSendErrors, ThrowOnError>;
|
|
43
43
|
/**
|
|
@@ -166,7 +166,7 @@ export declare class ScheduledMessages {
|
|
|
166
166
|
/**
|
|
167
167
|
* Schedule a message
|
|
168
168
|
*
|
|
169
|
-
* Schedules a message for dispatch at the absolute ISO-8601 timestamp supplied in scheduledFor. Requires `messages:create` or the send permission of the channel it sends on, such as `email:send`. The send payload is the same channel union the immediate send accepts, with each channel's content checked at schedule time so a send that could never render fails now rather than hours later: email and WhatsApp schedules are available. Optional timezone is validated IANA display metadata only and never changes the execution instant.
|
|
169
|
+
* Schedules a message for dispatch at the absolute ISO-8601 timestamp supplied in scheduledFor. Requires `messages:create` or the send permission of the channel it sends on, such as `email:send`. The send payload is the same channel union the immediate send accepts, with each channel's content checked at schedule time so a send that could never render fails now rather than hours later: email and WhatsApp schedules are available. Email schedules placed explicitly in a namespace require its sending setup to be ready: ValidationError means share the sender domain with namespaces or use a sender owned by that namespace. Setup that has stopped after failure also returns ValidationError and requires restarting or reconciling the domain's sending setup. ConflictError means setup is still in progress. Optional timezone is validated IANA display metadata only and never changes the execution instant.
|
|
170
170
|
*/
|
|
171
171
|
static create<ThrowOnError extends boolean = false>(parameters: {
|
|
172
172
|
namespaceId?: NamespaceId | null | undefined;
|
|
@@ -294,7 +294,7 @@ export declare class Campaigns {
|
|
|
294
294
|
/**
|
|
295
295
|
* Schedule a campaign run
|
|
296
296
|
*
|
|
297
|
-
* Schedules an email campaign run at the absolute ISO-8601 instant in scheduledFor, or immediately when omitted. The optional Idempotency-Key header is scoped to the organization and replays return the original run. An email campaign must carry the brand footer: it is refused with CampaignFooterRequiredError when its footer is off and its template renders no BrandFooter, and with BrandAddressRequiredError when a brand that signs it off has no postal address.
|
|
297
|
+
* Schedules an email campaign run at the absolute ISO-8601 instant in scheduledFor, or immediately when omitted. The optional Idempotency-Key header is scoped to the organization and replays return the original run. Scheduling refuses with ValidationError when the sending namespace has no sending setup: share the sender domain with namespaces, or use a sender owned by that namespace. Sending setup that has stopped after failure returns ValidationError; restart or reconcile the domain's sending setup. Setup still in progress returns ConflictError; retry after setup finishes. An email campaign must carry the brand footer: it is refused with CampaignFooterRequiredError when its footer is off and its template renders no BrandFooter, and with BrandAddressRequiredError when a brand that signs it off has no postal address.
|
|
298
298
|
*/
|
|
299
299
|
static scheduleRun<ThrowOnError extends boolean = false>(parameters: {
|
|
300
300
|
id: CampaignId;
|
package/dist/client/sdk.gen.js
CHANGED
|
@@ -69,7 +69,7 @@ var Messages = class {
|
|
|
69
69
|
/**
|
|
70
70
|
* Send a message
|
|
71
71
|
*
|
|
72
|
-
* Sends a message on the requested channel and returns its receipt (id, status, and why it waits when it does) with a 201 Created status. Requires `messages:create` or the send permission of the channel it sends on, such as `email:send`. `channel` selects the payload variant. Email and WhatsApp sends are available. Repeating an identical request with the same optional `Idempotency-Key` header returns the original receipt; reusing the key for different content returns a conflict.
|
|
72
|
+
* An email send whose namespace has no sending setup returns ValidationError: share the sender domain with namespaces, or use a sender owned by that namespace. Sending setup that has stopped after failure returns ValidationError; restart or reconcile the domain's sending setup. Setup still in progress returns ConflictError. Sends a message on the requested channel and returns its receipt (id, status, and why it waits when it does) with a 201 Created status. Requires `messages:create` or the send permission of the channel it sends on, such as `email:send`. `channel` selects the payload variant. Email and WhatsApp sends are available. Repeating an identical request with the same optional `Idempotency-Key` header returns the original receipt; reusing the key for different content returns a conflict.
|
|
73
73
|
*/
|
|
74
74
|
static send(parameters, options) {
|
|
75
75
|
const params = { body: parameters };
|
|
@@ -438,7 +438,7 @@ var ScheduledMessages = class {
|
|
|
438
438
|
/**
|
|
439
439
|
* Schedule a message
|
|
440
440
|
*
|
|
441
|
-
* Schedules a message for dispatch at the absolute ISO-8601 timestamp supplied in scheduledFor. Requires `messages:create` or the send permission of the channel it sends on, such as `email:send`. The send payload is the same channel union the immediate send accepts, with each channel's content checked at schedule time so a send that could never render fails now rather than hours later: email and WhatsApp schedules are available. Optional timezone is validated IANA display metadata only and never changes the execution instant.
|
|
441
|
+
* Schedules a message for dispatch at the absolute ISO-8601 timestamp supplied in scheduledFor. Requires `messages:create` or the send permission of the channel it sends on, such as `email:send`. The send payload is the same channel union the immediate send accepts, with each channel's content checked at schedule time so a send that could never render fails now rather than hours later: email and WhatsApp schedules are available. Email schedules placed explicitly in a namespace require its sending setup to be ready: ValidationError means share the sender domain with namespaces or use a sender owned by that namespace. Setup that has stopped after failure also returns ValidationError and requires restarting or reconciling the domain's sending setup. ConflictError means setup is still in progress. Optional timezone is validated IANA display metadata only and never changes the execution instant.
|
|
442
442
|
*/
|
|
443
443
|
static create(parameters, options) {
|
|
444
444
|
const params = buildClientParams([parameters], [{ args: [
|
|
@@ -846,7 +846,7 @@ var Campaigns = class {
|
|
|
846
846
|
/**
|
|
847
847
|
* Schedule a campaign run
|
|
848
848
|
*
|
|
849
|
-
* Schedules an email campaign run at the absolute ISO-8601 instant in scheduledFor, or immediately when omitted. The optional Idempotency-Key header is scoped to the organization and replays return the original run. An email campaign must carry the brand footer: it is refused with CampaignFooterRequiredError when its footer is off and its template renders no BrandFooter, and with BrandAddressRequiredError when a brand that signs it off has no postal address.
|
|
849
|
+
* Schedules an email campaign run at the absolute ISO-8601 instant in scheduledFor, or immediately when omitted. The optional Idempotency-Key header is scoped to the organization and replays return the original run. Scheduling refuses with ValidationError when the sending namespace has no sending setup: share the sender domain with namespaces, or use a sender owned by that namespace. Sending setup that has stopped after failure returns ValidationError; restart or reconcile the domain's sending setup. Setup still in progress returns ConflictError; retry after setup finishes. An email campaign must carry the brand footer: it is refused with CampaignFooterRequiredError when its footer is off and its template renders no BrandFooter, and with BrandAddressRequiredError when a brand that signs it off has no postal address.
|
|
850
850
|
*/
|
|
851
851
|
static scheduleRun(parameters, options) {
|
|
852
852
|
const params = buildClientParams([parameters], [{ args: [{
|
|
@@ -434,12 +434,12 @@ export type MailboxActionDecision = {
|
|
|
434
434
|
outcome: "allow" | "hold" | "refuse";
|
|
435
435
|
reason: string;
|
|
436
436
|
scopes: Array<{
|
|
437
|
-
kind: "organization" | "mailbox" | "agent" | "apiKey";
|
|
437
|
+
kind: "organization" | "integration" | "mailbox" | "agent" | "apiKey";
|
|
438
438
|
id: string;
|
|
439
439
|
}>;
|
|
440
440
|
rule?: {
|
|
441
441
|
scope: {
|
|
442
|
-
kind: "organization" | "mailbox" | "agent" | "apiKey";
|
|
442
|
+
kind: "organization" | "integration" | "mailbox" | "agent" | "apiKey";
|
|
443
443
|
id: string;
|
|
444
444
|
};
|
|
445
445
|
index: number;
|
|
@@ -1250,12 +1250,12 @@ export type PolicyDecision = {
|
|
|
1250
1250
|
outcome: "allow" | "hold" | "refuse";
|
|
1251
1251
|
reason: string;
|
|
1252
1252
|
scopes: Array<{
|
|
1253
|
-
kind: "organization" | "mailbox" | "agent" | "apiKey";
|
|
1253
|
+
kind: "organization" | "integration" | "mailbox" | "agent" | "apiKey";
|
|
1254
1254
|
id: string;
|
|
1255
1255
|
}>;
|
|
1256
1256
|
rule?: {
|
|
1257
1257
|
scope: {
|
|
1258
|
-
kind: "organization" | "mailbox" | "agent" | "apiKey";
|
|
1258
|
+
kind: "organization" | "integration" | "mailbox" | "agent" | "apiKey";
|
|
1259
1259
|
id: string;
|
|
1260
1260
|
};
|
|
1261
1261
|
index: number;
|
|
@@ -600,7 +600,7 @@ var CampaignsGroup = class extends HttpApiGroup.make("Campaigns").add(HttpApiEnd
|
|
|
600
600
|
CampaignsScheduleRun503.pipe(HttpApiSchema.status(503)),
|
|
601
601
|
CampaignsScheduleRun504.pipe(HttpApiSchema.status(504))
|
|
602
602
|
]
|
|
603
|
-
}).middleware(ApiKeySecurityMiddleware).annotate(OpenApi.Identifier, "campaigns.scheduleRun").annotate(OpenApi.Summary, "Schedule a campaign run").annotate(OpenApi.Description, "Schedules an email campaign run at the absolute ISO-8601 instant in scheduledFor, or immediately when omitted. The optional Idempotency-Key header is scoped to the organization and replays return the original run. An email campaign must carry the brand footer: it is refused with CampaignFooterRequiredError when its footer is off and its template renders no BrandFooter, and with BrandAddressRequiredError when a brand that signs it off has no postal address."), HttpApiEndpoint.get("campaignsGetRun", "/v1/campaigns/:id/runs/:runId", {
|
|
603
|
+
}).middleware(ApiKeySecurityMiddleware).annotate(OpenApi.Identifier, "campaigns.scheduleRun").annotate(OpenApi.Summary, "Schedule a campaign run").annotate(OpenApi.Description, "Schedules an email campaign run at the absolute ISO-8601 instant in scheduledFor, or immediately when omitted. The optional Idempotency-Key header is scoped to the organization and replays return the original run. Scheduling refuses with ValidationError when the sending namespace has no sending setup: share the sender domain with namespaces, or use a sender owned by that namespace. Sending setup that has stopped after failure returns ValidationError; restart or reconcile the domain's sending setup. Setup still in progress returns ConflictError; retry after setup finishes. An email campaign must carry the brand footer: it is refused with CampaignFooterRequiredError when its footer is off and its template renders no BrandFooter, and with BrandAddressRequiredError when a brand that signs it off has no postal address."), HttpApiEndpoint.get("campaignsGetRun", "/v1/campaigns/:id/runs/:runId", {
|
|
604
604
|
params: CampaignsGetRunPathParams,
|
|
605
605
|
success: CampaignsGetRun200,
|
|
606
606
|
error: [
|