samva 0.50.0 → 0.51.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/AGENTS.md +44 -3
- package/README.md +136 -7
- package/dist/client/sdk.gen.d.ts +12 -11
- package/dist/client/sdk.gen.js +1399 -940
- package/dist/client/types.gen.d.ts +21 -10
- package/dist/effect/agents.d.ts +4 -4
- package/dist/effect/api-keys.d.ts +4 -6
- package/dist/effect/campaigns.d.ts +166 -174
- package/dist/effect/categories.d.ts +2 -2
- package/dist/effect/categories.js +6 -4
- package/dist/effect/contact-groups.d.ts +4 -4
- package/dist/effect/contacts.d.ts +8 -8
- package/dist/effect/conversations.d.ts +4 -4
- package/dist/effect/email.d.ts +17 -16
- package/dist/effect/errors.d.ts +1 -0
- package/dist/effect/errors.js +2 -1
- package/dist/effect/generated/api-keys.d.ts +0 -15
- package/dist/effect/generated/api-keys.js +1 -2
- package/dist/effect/generated/campaigns.d.ts +0 -62
- package/dist/effect/generated/campaigns.js +3 -9
- package/dist/effect/generated/email.d.ts +10 -3
- package/dist/effect/generated/email.js +3 -2
- package/dist/effect/generated/mailboxes.js +6 -6
- package/dist/effect/generated/namespaces.js +1 -1
- package/dist/effect/generated/policies.js +2 -2
- package/dist/effect/generated/scheduled-messages.d.ts +0 -26
- package/dist/effect/generated/scheduled-messages.js +1 -3
- package/dist/effect/generated/shared.d.ts +1 -0
- package/dist/effect/generated/shared.js +2 -1
- package/dist/effect/index.js +2 -1
- package/dist/effect/integrations.d.ts +2 -2
- package/dist/effect/internal/client.d.ts +19 -2
- package/dist/effect/internal/client.js +10 -2
- package/dist/effect/internal/email-sender.d.ts +4 -4
- package/dist/effect/internal/email-sender.js +5 -3
- package/dist/effect/internal/operation.d.ts +11 -0
- package/dist/effect/internal/operation.js +10 -6
- package/dist/effect/internal/send.d.ts +4 -0
- package/dist/effect/internal/send.js +11 -8
- package/dist/effect/internal/timeout.d.ts +16 -0
- package/dist/effect/internal/timeout.js +20 -0
- package/dist/effect/journeys.d.ts +152 -152
- package/dist/effect/mailboxes.d.ts +28 -28
- package/dist/effect/messages.d.ts +5 -5
- package/dist/effect/namespaces.d.ts +4 -4
- package/dist/effect/newsletter-domains.d.ts +2 -2
- package/dist/effect/operations.d.ts +2 -2
- package/dist/effect/scheduled-messages.d.ts +2 -6
- package/dist/effect/templates.d.ts +6 -6
- package/dist/effect/topics.d.ts +4 -4
- package/dist/effect/webhooks.d.ts +4 -4
- package/dist/effect/whatsapp-setup-links.d.ts +2 -2
- package/dist/index.js +2 -2
- package/dist/package.js +1 -1
- package/dist/promises/client.d.ts +5 -0
- package/dist/promises/client.js +12 -8
- package/dist/promises/errors.gen.d.ts +12 -1
- package/dist/promises/errors.gen.js +21 -2
- package/dist/promises/index.js +2 -2
- package/dist/promises/request.d.ts +31 -2
- package/dist/promises/request.js +42 -7
- package/dist/request-policy.d.ts +9 -0
- package/dist/request-policy.js +16 -1
- package/package.json +2 -2
|
@@ -1340,8 +1340,6 @@ export type ScheduledMessage = {
|
|
|
1340
1340
|
readonly failureReason: string | null;
|
|
1341
1341
|
readonly attempts: number;
|
|
1342
1342
|
readonly createdBy: string | null;
|
|
1343
|
-
readonly actorEmail: string;
|
|
1344
|
-
readonly memberRole: string;
|
|
1345
1343
|
readonly createdAt: string;
|
|
1346
1344
|
readonly updatedAt: string;
|
|
1347
1345
|
};
|
|
@@ -1642,8 +1640,6 @@ export declare const ScheduledMessage: Schema.Struct<{
|
|
|
1642
1640
|
readonly failureReason: Schema.Union<readonly [Schema.String, Schema.Null]>;
|
|
1643
1641
|
readonly attempts: Schema.Finite;
|
|
1644
1642
|
readonly createdBy: Schema.Union<readonly [Schema.String, Schema.Null]>;
|
|
1645
|
-
readonly actorEmail: Schema.String;
|
|
1646
|
-
readonly memberRole: Schema.String;
|
|
1647
1643
|
readonly createdAt: Schema.String;
|
|
1648
1644
|
readonly updatedAt: Schema.String;
|
|
1649
1645
|
}>;
|
|
@@ -1949,8 +1945,6 @@ export declare const ScheduledMessagePage: Schema.Struct<{
|
|
|
1949
1945
|
readonly failureReason: Schema.Union<readonly [Schema.String, Schema.Null]>;
|
|
1950
1946
|
readonly attempts: Schema.Finite;
|
|
1951
1947
|
readonly createdBy: Schema.Union<readonly [Schema.String, Schema.Null]>;
|
|
1952
|
-
readonly actorEmail: Schema.String;
|
|
1953
|
-
readonly memberRole: Schema.String;
|
|
1954
1948
|
readonly createdAt: Schema.String;
|
|
1955
1949
|
readonly updatedAt: Schema.String;
|
|
1956
1950
|
}>>;
|
|
@@ -2267,8 +2261,6 @@ export declare const ScheduledMessagesList200: Schema.Struct<{
|
|
|
2267
2261
|
readonly failureReason: Schema.Union<readonly [Schema.String, Schema.Null]>;
|
|
2268
2262
|
readonly attempts: Schema.Finite;
|
|
2269
2263
|
readonly createdBy: Schema.Union<readonly [Schema.String, Schema.Null]>;
|
|
2270
|
-
readonly actorEmail: Schema.String;
|
|
2271
|
-
readonly memberRole: Schema.String;
|
|
2272
2264
|
readonly createdAt: Schema.String;
|
|
2273
2265
|
readonly updatedAt: Schema.String;
|
|
2274
2266
|
}>>;
|
|
@@ -2888,8 +2880,6 @@ export declare const ScheduledMessagesCreate201: Schema.Struct<{
|
|
|
2888
2880
|
readonly failureReason: Schema.Union<readonly [Schema.String, Schema.Null]>;
|
|
2889
2881
|
readonly attempts: Schema.Finite;
|
|
2890
2882
|
readonly createdBy: Schema.Union<readonly [Schema.String, Schema.Null]>;
|
|
2891
|
-
readonly actorEmail: Schema.String;
|
|
2892
|
-
readonly memberRole: Schema.String;
|
|
2893
2883
|
readonly createdAt: Schema.String;
|
|
2894
2884
|
readonly updatedAt: Schema.String;
|
|
2895
2885
|
}>;
|
|
@@ -3215,8 +3205,6 @@ export declare const ScheduledMessagesGet200: Schema.Struct<{
|
|
|
3215
3205
|
readonly failureReason: Schema.Union<readonly [Schema.String, Schema.Null]>;
|
|
3216
3206
|
readonly attempts: Schema.Finite;
|
|
3217
3207
|
readonly createdBy: Schema.Union<readonly [Schema.String, Schema.Null]>;
|
|
3218
|
-
readonly actorEmail: Schema.String;
|
|
3219
|
-
readonly memberRole: Schema.String;
|
|
3220
3208
|
readonly createdAt: Schema.String;
|
|
3221
3209
|
readonly updatedAt: Schema.String;
|
|
3222
3210
|
}>;
|
|
@@ -3543,8 +3531,6 @@ export declare const ScheduledMessagesCancel200: Schema.Struct<{
|
|
|
3543
3531
|
readonly failureReason: Schema.Union<readonly [Schema.String, Schema.Null]>;
|
|
3544
3532
|
readonly attempts: Schema.Finite;
|
|
3545
3533
|
readonly createdBy: Schema.Union<readonly [Schema.String, Schema.Null]>;
|
|
3546
|
-
readonly actorEmail: Schema.String;
|
|
3547
|
-
readonly memberRole: Schema.String;
|
|
3548
3534
|
readonly createdAt: Schema.String;
|
|
3549
3535
|
readonly updatedAt: Schema.String;
|
|
3550
3536
|
}>;
|
|
@@ -3881,8 +3867,6 @@ export declare const ScheduledMessagesResume200: Schema.Struct<{
|
|
|
3881
3867
|
readonly failureReason: Schema.Union<readonly [Schema.String, Schema.Null]>;
|
|
3882
3868
|
readonly attempts: Schema.Finite;
|
|
3883
3869
|
readonly createdBy: Schema.Union<readonly [Schema.String, Schema.Null]>;
|
|
3884
|
-
readonly actorEmail: Schema.String;
|
|
3885
|
-
readonly memberRole: Schema.String;
|
|
3886
3870
|
readonly createdAt: Schema.String;
|
|
3887
3871
|
readonly updatedAt: Schema.String;
|
|
3888
3872
|
}>;
|
|
@@ -4207,8 +4191,6 @@ declare const ScheduledMessagesGroup_base: HttpApiGroup.HttpApiGroup<"Scheduled
|
|
|
4207
4191
|
readonly failureReason: Schema.Union<readonly [Schema.String, Schema.Null]>;
|
|
4208
4192
|
readonly attempts: Schema.Finite;
|
|
4209
4193
|
readonly createdBy: Schema.Union<readonly [Schema.String, Schema.Null]>;
|
|
4210
|
-
readonly actorEmail: Schema.String;
|
|
4211
|
-
readonly memberRole: Schema.String;
|
|
4212
4194
|
readonly createdAt: Schema.String;
|
|
4213
4195
|
readonly updatedAt: Schema.String;
|
|
4214
4196
|
}>;
|
|
@@ -4921,8 +4903,6 @@ declare const ScheduledMessagesGroup_base: HttpApiGroup.HttpApiGroup<"Scheduled
|
|
|
4921
4903
|
readonly failureReason: Schema.Union<readonly [Schema.String, Schema.Null]>;
|
|
4922
4904
|
readonly attempts: Schema.Finite;
|
|
4923
4905
|
readonly createdBy: Schema.Union<readonly [Schema.String, Schema.Null]>;
|
|
4924
|
-
readonly actorEmail: Schema.String;
|
|
4925
|
-
readonly memberRole: Schema.String;
|
|
4926
4906
|
readonly createdAt: Schema.String;
|
|
4927
4907
|
readonly updatedAt: Schema.String;
|
|
4928
4908
|
}>>, Schema.toCodecJson<Schema.Union<readonly [typeof ForbiddenError, typeof FlagDisabledError]> | Schema.decodeTo<Schema.declareConstructor<ConflictError, {
|
|
@@ -5344,8 +5324,6 @@ declare const ScheduledMessagesGroup_base: HttpApiGroup.HttpApiGroup<"Scheduled
|
|
|
5344
5324
|
readonly failureReason: Schema.Union<readonly [Schema.String, Schema.Null]>;
|
|
5345
5325
|
readonly attempts: Schema.Finite;
|
|
5346
5326
|
readonly createdBy: Schema.Union<readonly [Schema.String, Schema.Null]>;
|
|
5347
|
-
readonly actorEmail: Schema.String;
|
|
5348
|
-
readonly memberRole: Schema.String;
|
|
5349
5327
|
readonly createdAt: Schema.String;
|
|
5350
5328
|
readonly updatedAt: Schema.String;
|
|
5351
5329
|
}>>, Schema.toCodecJson<Schema.decodeTo<Schema.declareConstructor<ForbiddenError, {
|
|
@@ -5751,8 +5729,6 @@ declare const ScheduledMessagesGroup_base: HttpApiGroup.HttpApiGroup<"Scheduled
|
|
|
5751
5729
|
readonly failureReason: Schema.Union<readonly [Schema.String, Schema.Null]>;
|
|
5752
5730
|
readonly attempts: Schema.Finite;
|
|
5753
5731
|
readonly createdBy: Schema.Union<readonly [Schema.String, Schema.Null]>;
|
|
5754
|
-
readonly actorEmail: Schema.String;
|
|
5755
|
-
readonly memberRole: Schema.String;
|
|
5756
5732
|
readonly createdAt: Schema.String;
|
|
5757
5733
|
readonly updatedAt: Schema.String;
|
|
5758
5734
|
}>>;
|
|
@@ -6141,8 +6117,6 @@ declare const ScheduledMessagesGroup_base: HttpApiGroup.HttpApiGroup<"Scheduled
|
|
|
6141
6117
|
readonly failureReason: Schema.Union<readonly [Schema.String, Schema.Null]>;
|
|
6142
6118
|
readonly attempts: Schema.Finite;
|
|
6143
6119
|
readonly createdBy: Schema.Union<readonly [Schema.String, Schema.Null]>;
|
|
6144
|
-
readonly actorEmail: Schema.String;
|
|
6145
|
-
readonly memberRole: Schema.String;
|
|
6146
6120
|
readonly createdAt: Schema.String;
|
|
6147
6121
|
readonly updatedAt: Schema.String;
|
|
6148
6122
|
}>>, Schema.toCodecJson<Schema.Union<readonly [typeof FromAddressRequiredError, typeof ValidationError]> | Schema.decodeTo<Schema.declareConstructor<ConflictError, {
|
|
@@ -141,9 +141,7 @@ const ScheduledMessage = /* @__PURE__ */ (() => Schema.Struct({
|
|
|
141
141
|
referenceId: Schema.Union([Schema.String, Schema.Null]),
|
|
142
142
|
failureReason: Schema.Union([Schema.String, Schema.Null]),
|
|
143
143
|
attempts: Schema.Finite.check(Schema.isFinite().annotate({ expected: "a finite number" })),
|
|
144
|
-
createdBy: Schema.Union([Schema.String, Schema.Null]),
|
|
145
|
-
actorEmail: Schema.String,
|
|
146
|
-
memberRole: Schema.String,
|
|
144
|
+
createdBy: Schema.Union([Schema.String, Schema.Null]).annotate({ description: "The user id of the member who created it; for an API key, the key owner's user id. Never an email address." }),
|
|
147
145
|
createdAt: Schema.String,
|
|
148
146
|
updatedAt: Schema.String
|
|
149
147
|
}).annotate({ identifier: "ScheduledMessage" }))();
|
|
@@ -360,6 +360,7 @@ declare const FromAddressRequiredError_base: Schema.Class<FromAddressRequiredErr
|
|
|
360
360
|
readonly _tag: Schema.tag<"FromAddressRequiredError">;
|
|
361
361
|
readonly message: Schema.String;
|
|
362
362
|
readonly verifiedDomains: Schema.$Array<Schema.String>;
|
|
363
|
+
readonly addresses: Schema.$Array<Schema.String>;
|
|
363
364
|
}>, import("effect/Cause").YieldableError>;
|
|
364
365
|
export declare class FromAddressRequiredError extends FromAddressRequiredError_base {
|
|
365
366
|
}
|
|
@@ -334,7 +334,8 @@ var TemplateSourceError = class extends Schema.TaggedError()("TemplateSourceErro
|
|
|
334
334
|
})) {};
|
|
335
335
|
var FromAddressRequiredError = class extends Schema.TaggedError()("FromAddressRequiredError", Schema.Struct({
|
|
336
336
|
message: Schema.String,
|
|
337
|
-
verifiedDomains: Schema.Array(Schema.String)
|
|
337
|
+
verifiedDomains: Schema.Array(Schema.String),
|
|
338
|
+
addresses: Schema.Array(Schema.String)
|
|
338
339
|
})) {};
|
|
339
340
|
var BrandAddressRequiredError = class extends Schema.TaggedError()("BrandAddressRequiredError", Schema.Struct({
|
|
340
341
|
message: Schema.String,
|
package/dist/effect/index.js
CHANGED
|
@@ -2,6 +2,7 @@ import { MediaUploadError } from "../inline-attachments.js";
|
|
|
2
2
|
import { AnalyticsQueryError, BillingProviderError, BrandAddressRequiredError, CampaignFooterRequiredError, ConflictError, CredentialsError, DeliveryUnavailableError, EmailChannelError, ExternalServiceError, FlagDisabledError, ForbiddenError, FromAddressRequiredError, GatewayTimeoutError, InternalError, MailboxSendConflictError, MailboxSendRefusedError, MalformedRequestError, OnboardingReviewRequiredError, PaymentRequiredError, RateLimitedError, ResourceNotFoundError, SenderNotReadyError, ServiceUnavailableError, TemplateInUseError, TemplateSourceError, UnauthorizedError, ValidationError, WhatsAppChannelError, WhatsAppServiceWindowClosedError, WhatsAppSetupLinkUnavailableError } from "./generated/shared.js";
|
|
3
3
|
import { catchAuthError, catchBillingError, catchCategory, catchConflictError, catchNotFoundError, catchThrottlingError, catchTransient, catchValidationError, categoriesOf, hasCategory, isAuthError, isBillingError, isConflictError, isNotFoundError, isRetryable, isThrottlingError, isTransient, isValidationError } from "./categories.js";
|
|
4
4
|
import { retry_exports } from "./retry.js";
|
|
5
|
+
import { SamvaTimeoutError } from "./internal/timeout.js";
|
|
5
6
|
import { accounts_exports } from "./accounts.js";
|
|
6
7
|
import { integrations_catalog_exports } from "./integrations-catalog.js";
|
|
7
8
|
import { integrations_exports } from "./integrations.js";
|
|
@@ -43,4 +44,4 @@ import { whatsapp_flows_exports } from "./whatsapp-flows.js";
|
|
|
43
44
|
import { whatsapp_setup_links_exports } from "./whatsapp-setup-links.js";
|
|
44
45
|
import { template_registrations_exports } from "./template-registrations.js";
|
|
45
46
|
import { template_share_links_exports } from "./template-share-links.js";
|
|
46
|
-
export { accounts_exports as Accounts, agents_exports as Agents, analytics_exports as Analytics, AnalyticsQueryError, api_keys_exports as ApiKeys, approval_requests_exports as ApprovalRequests, attachments_exports as Attachments, BillingProviderError, BrandAddressRequiredError, brands_exports as Brands, CampaignFooterRequiredError, campaigns_exports as Campaigns, client_exports as Client, ConflictError, contact_groups_exports as ContactGroups, contacts_exports as Contacts, conversations_exports as Conversations, CredentialsError, custom_fields_exports as CustomFields, DeliveryUnavailableError, email_exports as Email, EmailChannelError, events_exports as Events, ExternalServiceError, feedback_exports as Feedback, FlagDisabledError, ForbiddenError, FromAddressRequiredError, GatewayTimeoutError, integrations_catalog_exports as IntegrationCatalog, integrations_exports as Integrations, InternalError, journeys_exports as Journeys, MailboxSendConflictError, MailboxSendRefusedError, mailboxes_exports as Mailboxes, MalformedRequestError, media_exports as Media, MediaUploadError, messages_exports as Messages, namespaces_exports as Namespaces, newsletter_domains_exports as NewsletterDomains, newsletter_issues_exports as NewsletterIssues, newsletters_exports as Newsletters, OnboardingReviewRequiredError, operations_exports as Operations, organizations_exports as Organizations, PaymentRequiredError, policies_exports as Policies, RateLimitedError, ResourceNotFoundError, retry_exports as Retry, scheduled_messages_exports as ScheduledMessages, SenderNotReadyError, ServiceUnavailableError, subscriptions_exports as Subscriptions, TemplateInUseError, template_registrations_exports as TemplateRegistrations, template_share_links_exports as TemplateShareLinks, TemplateSourceError, templates_exports as Templates, topic_forms_exports as TopicForms, topics_exports as Topics, UnauthorizedError, ValidationError, webhooks_exports as Webhooks, whatsapp_exports as WhatsApp, WhatsAppChannelError, whatsapp_flows_exports as WhatsAppFlows, WhatsAppServiceWindowClosedError, WhatsAppSetupLinkUnavailableError, whatsapp_setup_links_exports as WhatsAppSetupLinks, whoami_exports as Whoami, catchAuthError, catchBillingError, catchCategory, catchConflictError, catchNotFoundError, catchThrottlingError, catchTransient, catchValidationError, categoriesOf, hasCategory, isAuthError, isBillingError, isConflictError, isNotFoundError, isRetryable, isThrottlingError, isTransient, isValidationError };
|
|
47
|
+
export { accounts_exports as Accounts, agents_exports as Agents, analytics_exports as Analytics, AnalyticsQueryError, api_keys_exports as ApiKeys, approval_requests_exports as ApprovalRequests, attachments_exports as Attachments, BillingProviderError, BrandAddressRequiredError, brands_exports as Brands, CampaignFooterRequiredError, campaigns_exports as Campaigns, client_exports as Client, ConflictError, contact_groups_exports as ContactGroups, contacts_exports as Contacts, conversations_exports as Conversations, CredentialsError, custom_fields_exports as CustomFields, DeliveryUnavailableError, email_exports as Email, EmailChannelError, events_exports as Events, ExternalServiceError, feedback_exports as Feedback, FlagDisabledError, ForbiddenError, FromAddressRequiredError, GatewayTimeoutError, integrations_catalog_exports as IntegrationCatalog, integrations_exports as Integrations, InternalError, journeys_exports as Journeys, MailboxSendConflictError, MailboxSendRefusedError, mailboxes_exports as Mailboxes, MalformedRequestError, media_exports as Media, MediaUploadError, messages_exports as Messages, namespaces_exports as Namespaces, newsletter_domains_exports as NewsletterDomains, newsletter_issues_exports as NewsletterIssues, newsletters_exports as Newsletters, OnboardingReviewRequiredError, operations_exports as Operations, organizations_exports as Organizations, PaymentRequiredError, policies_exports as Policies, RateLimitedError, ResourceNotFoundError, retry_exports as Retry, SamvaTimeoutError, scheduled_messages_exports as ScheduledMessages, SenderNotReadyError, ServiceUnavailableError, subscriptions_exports as Subscriptions, TemplateInUseError, template_registrations_exports as TemplateRegistrations, template_share_links_exports as TemplateShareLinks, TemplateSourceError, templates_exports as Templates, topic_forms_exports as TopicForms, topics_exports as Topics, UnauthorizedError, ValidationError, webhooks_exports as Webhooks, whatsapp_exports as WhatsApp, WhatsAppChannelError, whatsapp_flows_exports as WhatsAppFlows, WhatsAppServiceWindowClosedError, WhatsAppSetupLinkUnavailableError, whatsapp_setup_links_exports as WhatsAppSetupLinks, whoami_exports as Whoami, catchAuthError, catchBillingError, catchCategory, catchConflictError, catchNotFoundError, catchThrottlingError, catchTransient, catchValidationError, categoriesOf, hasCategory, isAuthError, isBillingError, isConflictError, isNotFoundError, isRetryable, isThrottlingError, isTransient, isValidationError };
|
|
@@ -39,7 +39,7 @@ export declare const list: ((input?: {
|
|
|
39
39
|
readonly updatedAt: string;
|
|
40
40
|
}[];
|
|
41
41
|
readonly nextCursor: string | null;
|
|
42
|
-
}, import("./errors.js").ForbiddenError | import("./errors.js").GatewayTimeoutError | import("effect/http/HttpClientError").HttpClientError | import("./errors.js").InternalError | import("./errors.js").MalformedRequestError | import("effect/Schema").SchemaError | import("./errors.js").UnauthorizedError | import("./errors.js").ValidationError, import("./client.js").Service>;
|
|
42
|
+
}, import("./errors.js").ForbiddenError | import("./errors.js").GatewayTimeoutError | import("effect/http/HttpClientError").HttpClientError | import("./errors.js").InternalError | import("./errors.js").MalformedRequestError | import("./errors.js").SamvaTimeoutError | import("effect/Schema").SchemaError | import("./errors.js").UnauthorizedError | import("./errors.js").ValidationError, import("./client.js").Service>;
|
|
43
43
|
readonly items: (input?: {
|
|
44
44
|
readonly limit?: number | null | undefined;
|
|
45
45
|
readonly cursor?: string | undefined;
|
|
@@ -74,7 +74,7 @@ export declare const list: ((input?: {
|
|
|
74
74
|
readonly installedBy: (string & import("effect/Brand").Brand<"UserId">) | null;
|
|
75
75
|
readonly createdAt: string;
|
|
76
76
|
readonly updatedAt: string;
|
|
77
|
-
}, import("./errors.js").ForbiddenError | import("./errors.js").GatewayTimeoutError | import("effect/http/HttpClientError").HttpClientError | import("./errors.js").InternalError | import("./errors.js").MalformedRequestError | import("effect/Schema").SchemaError | import("./errors.js").UnauthorizedError | import("./errors.js").ValidationError, import("./client.js").Service>;
|
|
77
|
+
}, import("./errors.js").ForbiddenError | import("./errors.js").GatewayTimeoutError | import("effect/http/HttpClientError").HttpClientError | import("./errors.js").InternalError | import("./errors.js").MalformedRequestError | import("./errors.js").SamvaTimeoutError | import("effect/Schema").SchemaError | import("./errors.js").UnauthorizedError | import("./errors.js").ValidationError, import("./client.js").Service>;
|
|
78
78
|
};
|
|
79
79
|
export declare const install: (input: {
|
|
80
80
|
readonly app: string;
|
|
@@ -3,12 +3,24 @@ import { HttpApiClient, type HttpApiEndpoint, type HttpApiGroup } from "effect/h
|
|
|
3
3
|
import * as HttpClient from "effect/http/HttpClient";
|
|
4
4
|
import { MediaUploadError } from "../../inline-attachments.js";
|
|
5
5
|
import type { MailboxEventStreamConnection } from "../../mailbox-events.js";
|
|
6
|
+
import { type TimeoutSetting } from "../../request-policy.js";
|
|
6
7
|
import type { SamvaApi } from "../generated/index.js";
|
|
8
|
+
import { type SamvaTimeoutError } from "./timeout.js";
|
|
7
9
|
export interface ConfigBase {
|
|
8
10
|
readonly baseUrl?: string;
|
|
9
11
|
/** Generate the key once for each idempotent logical call. */
|
|
10
12
|
readonly idempotency?: ((operation: string) => string | undefined) | undefined;
|
|
11
13
|
readonly headers?: Readonly<Record<string, string | undefined>>;
|
|
14
|
+
/**
|
|
15
|
+
* Milliseconds each request attempt may take before it fails with `SamvaTimeoutError`
|
|
16
|
+
* (default 30 000). `null` disables the bound.
|
|
17
|
+
*/
|
|
18
|
+
readonly timeoutMs?: number | null | undefined;
|
|
19
|
+
/**
|
|
20
|
+
* Milliseconds each put of attachment bytes to storage may take (default 300 000). `null`
|
|
21
|
+
* disables the bound.
|
|
22
|
+
*/
|
|
23
|
+
readonly uploadTimeoutMs?: number | null | undefined;
|
|
12
24
|
}
|
|
13
25
|
export type Config = (ConfigBase & {
|
|
14
26
|
readonly apiKey: string | Redacted.Redacted<string>;
|
|
@@ -34,11 +46,13 @@ type OperationSuccess<Name extends Operation> = HttpApiClient.SuccessType<HttpAp
|
|
|
34
46
|
}>>>;
|
|
35
47
|
type MethodReturn<Method> = Method extends (...args: infer _Args) => infer Return ? Return : never;
|
|
36
48
|
/** What one operation wrapper returns: the endpoint's decoded success and typed failure. */
|
|
37
|
-
export type OperationResult<Name extends Operation> = Effect.Effect<OperationSuccess<Name>, Effect.Error<MethodReturn<FlatRaw[Name]
|
|
49
|
+
export type OperationResult<Name extends Operation> = Effect.Effect<OperationSuccess<Name>, Effect.Error<MethodReturn<FlatRaw[Name]>> | SamvaTimeoutError, Service>;
|
|
38
50
|
/** The generated call for one endpoint, with its decoded success and typed failure. */
|
|
39
51
|
type OperationCall<Name extends Operation> = (request?: unknown) => OperationResult<Name>;
|
|
40
52
|
export interface Interface {
|
|
41
53
|
readonly idempotency?: ((operation: string) => string | undefined) | undefined;
|
|
54
|
+
/** The client's per-attempt request bound; `undefined` means the default, `null` none. */
|
|
55
|
+
readonly timeoutMs?: number | null | undefined;
|
|
42
56
|
/**
|
|
43
57
|
* The generated call for one endpoint. A group's client is built on the first call to any of its
|
|
44
58
|
* endpoints and reused, so a group the program never calls costs nothing.
|
|
@@ -49,7 +63,8 @@ export interface Interface {
|
|
|
49
63
|
/**
|
|
50
64
|
* Put bytes at a presigned storage URL through the configured transport, replaying the
|
|
51
65
|
* instruction's headers exactly and sending no API credentials. Fails with the response status
|
|
52
|
-
* (or the transport error) as
|
|
66
|
+
* (or the transport error, or a `SamvaTimeoutError` past the upload bound) as
|
|
67
|
+
* `MediaUploadError`. `timeoutMs` overrides the client's `uploadTimeoutMs`.
|
|
53
68
|
*/
|
|
54
69
|
readonly putUpload: (input: {
|
|
55
70
|
readonly filename: string;
|
|
@@ -58,11 +73,13 @@ export interface Interface {
|
|
|
58
73
|
readonly method: string;
|
|
59
74
|
readonly headers: Readonly<Record<string, string>>;
|
|
60
75
|
readonly bytes: Uint8Array;
|
|
76
|
+
readonly timeoutMs?: TimeoutSetting;
|
|
61
77
|
}) => Effect.Effect<void, MediaUploadError>;
|
|
62
78
|
}
|
|
63
79
|
declare const Service_base: Context.ServiceClass<Service, "samva/Client", Interface>;
|
|
64
80
|
export declare class Service extends Service_base {
|
|
65
81
|
}
|
|
82
|
+
/** Throws a `RangeError` for an invalid `timeoutMs` or `uploadTimeoutMs`, as the Promise client does. */
|
|
66
83
|
export declare const layer: (config: Config) => Layer.Layer<Service, never, HttpClient.HttpClient>;
|
|
67
84
|
export declare const layerFetch: (config: Config) => Layer.Layer<Service>;
|
|
68
85
|
export {};
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { CLIENT_ATTRIBUTION_HEADER, clientAttribution } from "../../client-attribution.js";
|
|
2
|
+
import { DEFAULT_UPLOAD_TIMEOUT_MS, resolveTimeout, validateTimeout } from "../../request-policy.js";
|
|
2
3
|
import { MediaUploadError, uploadContentType } from "../../inline-attachments.js";
|
|
3
4
|
import { ApiKeySecurityMiddleware } from "../generated/shared.js";
|
|
5
|
+
import { withTimeout } from "./timeout.js";
|
|
4
6
|
import { Context, Effect, Layer, Redacted } from "effect";
|
|
5
7
|
import { HttpApi, HttpApiClient, HttpApiMiddleware } from "effect/http-api";
|
|
6
8
|
import * as FetchHttpClient from "effect/http/FetchHttpClient";
|
|
@@ -41,7 +43,7 @@ const make = (config) => Effect.gen(function* () {
|
|
|
41
43
|
};
|
|
42
44
|
const headers = removesAttribution ? {} : { [CLIENT_ATTRIBUTION_HEADER]: clientAttribution("typescript-effect") };
|
|
43
45
|
for (const [name, value] of Object.entries(requestHeaders)) if (value !== void 0) headers[name] = value;
|
|
44
|
-
const putUpload = (input) => storage.execute(HttpClientRequest.make(input.method)(input.url).pipe(HttpClientRequest.bodyUint8Array(input.bytes, uploadContentType(input.headers)), HttpClientRequest.setHeaders(input.headers))).pipe(Effect.mapError((cause) => new MediaUploadError({
|
|
46
|
+
const putUpload = (input) => withTimeout(storage.execute(HttpClientRequest.make(input.method)(input.url).pipe(HttpClientRequest.bodyUint8Array(input.bytes, uploadContentType(input.headers)), HttpClientRequest.setHeaders(input.headers))), resolveTimeout("uploadTimeoutMs", input.timeoutMs, config.uploadTimeoutMs, DEFAULT_UPLOAD_TIMEOUT_MS)).pipe(Effect.mapError((cause) => new MediaUploadError({
|
|
45
47
|
filename: input.filename,
|
|
46
48
|
mediaId: input.mediaId,
|
|
47
49
|
cause
|
|
@@ -52,6 +54,7 @@ const make = (config) => Effect.gen(function* () {
|
|
|
52
54
|
}))));
|
|
53
55
|
return Service.of({
|
|
54
56
|
idempotency: config.idempotency,
|
|
57
|
+
timeoutMs: config.timeoutMs,
|
|
55
58
|
putUpload,
|
|
56
59
|
endpoint: (group, name) => Effect.flatMap(groupClient(group), (client) => {
|
|
57
60
|
const call = client[name];
|
|
@@ -66,7 +69,12 @@ const make = (config) => Effect.gen(function* () {
|
|
|
66
69
|
}
|
|
67
70
|
});
|
|
68
71
|
});
|
|
69
|
-
|
|
72
|
+
/** Throws a `RangeError` for an invalid `timeoutMs` or `uploadTimeoutMs`, as the Promise client does. */
|
|
73
|
+
const layer = (config) => {
|
|
74
|
+
validateTimeout("timeoutMs", config.timeoutMs);
|
|
75
|
+
validateTimeout("uploadTimeoutMs", config.uploadTimeoutMs);
|
|
76
|
+
return Layer.effect(Service, make(config));
|
|
77
|
+
};
|
|
70
78
|
const layerFetch = (config) => layer(config).pipe(Layer.provide(FetchHttpClient.layer));
|
|
71
79
|
export { Service, layer, layerFetch };
|
|
72
80
|
|
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
import { Effect } from "effect";
|
|
2
2
|
import { type FlatRaw, Service } from "./client.js";
|
|
3
|
-
import { type RequestArg } from "./operation.js";
|
|
4
|
-
import type { ErgonomicEmailList
|
|
3
|
+
import { type OperationOptions, type RequestArg } from "./operation.js";
|
|
4
|
+
import type { ErgonomicEmailList } from "./send.js";
|
|
5
5
|
type AddSenderRequest = NonNullable<RequestArg<FlatRaw["emailAddSender"]>>;
|
|
6
6
|
export type EmailAddSenderInput = Omit<AddSenderRequest["payload"], "replyToEmails"> & {
|
|
7
7
|
readonly replyToEmails?: ErgonomicEmailList | null | undefined;
|
|
8
8
|
};
|
|
9
|
-
export declare const addEmailSender: (input: EmailAddSenderInput, options?:
|
|
9
|
+
export declare const addEmailSender: (input: EmailAddSenderInput, options?: OperationOptions | undefined) => Effect.Effect<{
|
|
10
10
|
readonly id: string & import("effect/Brand").Brand<"EmailSenderId">;
|
|
11
11
|
readonly email: string;
|
|
12
12
|
readonly status: "failed" | "pending" | "verified";
|
|
13
13
|
readonly providerLifecycle: "active" | "deleting" | "failed" | "provisioning";
|
|
14
14
|
readonly providerFailureCode: string | null;
|
|
15
15
|
readonly createdAt: string;
|
|
16
|
-
}, import("../index.js").ConflictError | import("../index.js").ExternalServiceError | import("../index.js").ForbiddenError | import("../index.js").GatewayTimeoutError | import("effect/http/HttpClientError").HttpClientError | import("../index.js").InternalError | import("../index.js").MalformedRequestError | import("../index.js").ResourceNotFoundError | import("effect/Schema").SchemaError | import("../index.js").UnauthorizedError | import("../index.js").ValidationError, Service>;
|
|
16
|
+
}, import("../index.js").ConflictError | import("../index.js").ExternalServiceError | import("../index.js").ForbiddenError | import("../index.js").GatewayTimeoutError | import("effect/http/HttpClientError").HttpClientError | import("../index.js").InternalError | import("../index.js").MalformedRequestError | import("../index.js").ResourceNotFoundError | import("./timeout.js").SamvaTimeoutError | import("effect/Schema").SchemaError | import("../index.js").UnauthorizedError | import("../index.js").ValidationError, Service>;
|
|
17
17
|
export {};
|
|
@@ -1,21 +1,23 @@
|
|
|
1
1
|
import { replyToEmailsPayload } from "../../normalize.js";
|
|
2
2
|
import { generateIdempotencyKey, withRetry } from "../retry.js";
|
|
3
|
+
import { withTimeout } from "./timeout.js";
|
|
3
4
|
import { Service } from "./client.js";
|
|
4
|
-
import { callEndpoint, stripUndefined } from "./operation.js";
|
|
5
|
+
import { attemptTimeout, callEndpoint, stripUndefined } from "./operation.js";
|
|
5
6
|
import { EmailGroup } from "../generated/email.js";
|
|
6
7
|
import { Effect } from "effect";
|
|
7
8
|
// src/effect/internal/email-sender.ts
|
|
8
9
|
const addEmailSender = Effect.fn("Email.addSender")(function* (input, options) {
|
|
9
10
|
const client = yield* Service;
|
|
11
|
+
const timeoutMs = attemptTimeout(options, client);
|
|
10
12
|
const idempotencyKey = options?.idempotencyKey ?? client.idempotency?.("emailAddSender") ?? (yield* generateIdempotencyKey);
|
|
11
13
|
const { replyToEmails, ...sender } = input;
|
|
12
|
-
return yield* withRetry(callEndpoint(EmailGroup, "emailAddSender", {
|
|
14
|
+
return yield* withRetry(withTimeout(callEndpoint(EmailGroup, "emailAddSender", {
|
|
13
15
|
headers: { "idempotency-key": idempotencyKey },
|
|
14
16
|
payload: stripUndefined({
|
|
15
17
|
...sender,
|
|
16
18
|
...replyToEmailsPayload(replyToEmails)
|
|
17
19
|
})
|
|
18
|
-
}));
|
|
20
|
+
}), timeoutMs));
|
|
19
21
|
});
|
|
20
22
|
export { addEmailSender };
|
|
21
23
|
|
|
@@ -24,7 +24,18 @@ type Input<Name extends SdkOperation> = Wire<FlattenRequest<NonNullable<RequestA
|
|
|
24
24
|
*/
|
|
25
25
|
export interface OperationOptions {
|
|
26
26
|
readonly idempotencyKey?: string | undefined;
|
|
27
|
+
/**
|
|
28
|
+
* Milliseconds each attempt may take before it fails with `SamvaTimeoutError`; `null` disables
|
|
29
|
+
* the bound, `undefined` inherits the client's `timeoutMs` (default 30 000).
|
|
30
|
+
*/
|
|
31
|
+
readonly timeoutMs?: number | null | undefined;
|
|
27
32
|
}
|
|
33
|
+
/** The call's bound, else the client's, else the default; throws a `RangeError` when invalid. */
|
|
34
|
+
export declare const attemptTimeout: (options: {
|
|
35
|
+
readonly timeoutMs?: number | null | undefined;
|
|
36
|
+
} | undefined, client: {
|
|
37
|
+
readonly timeoutMs?: number | null | undefined;
|
|
38
|
+
}) => number | null;
|
|
28
39
|
/**
|
|
29
40
|
* What one operation wrapper reads at runtime. `codegen/generate-registry.ts` emits a table of these
|
|
30
41
|
* beside each domain, so a focused entry carries its own operations' descriptors and not the API's.
|
|
@@ -1,9 +1,12 @@
|
|
|
1
|
-
import { isRetrySafe } from "../../request-policy.js";
|
|
1
|
+
import { DEFAULT_TIMEOUT_MS, isRetrySafe, resolveTimeout } from "../../request-policy.js";
|
|
2
2
|
import { streamCursorItems, streamCursorPages } from "../pagination.js";
|
|
3
3
|
import { generateIdempotencyKey, withRetry } from "../retry.js";
|
|
4
|
+
import { withTimeout } from "./timeout.js";
|
|
4
5
|
import { Service } from "./client.js";
|
|
5
6
|
import { Effect, Predicate } from "effect";
|
|
6
7
|
// src/effect/internal/operation.ts
|
|
8
|
+
/** The call's bound, else the client's, else the default; throws a `RangeError` when invalid. */
|
|
9
|
+
const attemptTimeout = (options, client) => resolveTimeout("timeoutMs", options?.timeoutMs, client.timeoutMs, DEFAULT_TIMEOUT_MS);
|
|
7
10
|
const traceName = (descriptor, operationName) => {
|
|
8
11
|
const moduleName = descriptor.group.split(" ").map((word) => word.charAt(0).toUpperCase() + word.slice(1).toLowerCase()).join("");
|
|
9
12
|
const prefix = moduleName.charAt(0).toLowerCase() + moduleName.slice(1);
|
|
@@ -17,16 +20,16 @@ const stripUndefined = (input) => {
|
|
|
17
20
|
if (Object.getPrototypeOf(input) !== Object.prototype) return input;
|
|
18
21
|
return Object.fromEntries(Object.entries(input).filter(([, value]) => value !== void 0).map(([key, value]) => [key, stripUndefined(value)]));
|
|
19
22
|
};
|
|
20
|
-
const adapt = (descriptor, operationName, rawCall, input, idempotencyKey) => {
|
|
23
|
+
const adapt = (descriptor, operationName, rawCall, input, idempotencyKey, timeoutMs) => {
|
|
21
24
|
const callDescriptor = descriptor.call;
|
|
22
25
|
const call = (request = {}) => {
|
|
23
|
-
const operation = rawCall({
|
|
26
|
+
const operation = withTimeout(rawCall({
|
|
24
27
|
...request,
|
|
25
28
|
headers: {
|
|
26
29
|
...request["headers"],
|
|
27
30
|
...idempotencyKey === void 0 ? {} : { "idempotency-key": idempotencyKey }
|
|
28
31
|
}
|
|
29
|
-
});
|
|
32
|
+
}), timeoutMs);
|
|
30
33
|
return isRetrySafe(descriptor, input) ? withRetry(operation) : operation;
|
|
31
34
|
};
|
|
32
35
|
if (callDescriptor.kind === "none") return call();
|
|
@@ -62,9 +65,10 @@ const callEndpoint = (group, name, request) => Effect.flatMap(Service, (client)
|
|
|
62
65
|
const make = (group, operationName, descriptor) => {
|
|
63
66
|
const call = Effect.fn(traceName(descriptor, operationName))(function* (input, options) {
|
|
64
67
|
const client = yield* Service;
|
|
68
|
+
const timeoutMs = attemptTimeout(options, client);
|
|
65
69
|
const rawCall = yield* client.endpoint(group, operationName);
|
|
66
70
|
const idempotencyKey = descriptor.idempotent ? options?.idempotencyKey ?? client.idempotency?.(operationName) ?? (yield* generateIdempotencyKey) : void 0;
|
|
67
|
-
return yield* adapt(descriptor, operationName, rawCall, input, idempotencyKey);
|
|
71
|
+
return yield* adapt(descriptor, operationName, rawCall, input, idempotencyKey, timeoutMs);
|
|
68
72
|
});
|
|
69
73
|
const operation = call;
|
|
70
74
|
if (descriptor.paginated) {
|
|
@@ -76,6 +80,6 @@ const make = (group, operationName, descriptor) => {
|
|
|
76
80
|
}
|
|
77
81
|
return operation;
|
|
78
82
|
};
|
|
79
|
-
export { callEndpoint, forGroup, stripUndefined };
|
|
83
|
+
export { attemptTimeout, callEndpoint, forGroup, stripUndefined };
|
|
80
84
|
|
|
81
85
|
//# sourceMappingURL=operation.js.map
|
|
@@ -19,6 +19,10 @@ type ErgonomicEmailContent = Omit<EmailPayload["email"], "replyTo"> & {
|
|
|
19
19
|
};
|
|
20
20
|
export interface SendOptions {
|
|
21
21
|
readonly idempotencyKey?: string;
|
|
22
|
+
/** Per-attempt bound on the send and its media requests; `null` disables it. */
|
|
23
|
+
readonly timeoutMs?: number | null | undefined;
|
|
24
|
+
/** Per-put bound on oversized attachment bytes; `null` disables it. */
|
|
25
|
+
readonly uploadTimeoutMs?: number | null | undefined;
|
|
22
26
|
}
|
|
23
27
|
export type MessageSendInput = Omit<EmailPayload, "to" | "cc" | "bcc" | "email"> & {
|
|
24
28
|
readonly to: ErgonomicMessageRecipient | ReadonlyArray<ErgonomicMessageRecipient>;
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { mediaCreateBody, planInlineUploads, withUploadedAttachments } from "../../inline-attachments.js";
|
|
2
2
|
import { buildEmailSendPayload, buildMessagesSendPayload } from "../../normalize.js";
|
|
3
3
|
import { generateIdempotencyKey, withRetry } from "../retry.js";
|
|
4
|
+
import { withTimeout } from "./timeout.js";
|
|
4
5
|
import { Service } from "./client.js";
|
|
5
|
-
import { callEndpoint, stripUndefined } from "./operation.js";
|
|
6
|
+
import { attemptTimeout, callEndpoint, stripUndefined } from "./operation.js";
|
|
6
7
|
import { MediaGroup } from "../generated/media.js";
|
|
7
8
|
import { MessagesGroup } from "../generated/messages.js";
|
|
8
9
|
import { Effect } from "effect";
|
|
@@ -13,21 +14,22 @@ import { Effect } from "effect";
|
|
|
13
14
|
* `mediaId`. The returned payload is the one request every send attempt reuses, so nothing is
|
|
14
15
|
* uploaded twice.
|
|
15
16
|
*/
|
|
16
|
-
const uploadOversizedAttachments = (client, payload) => Effect.gen(function* () {
|
|
17
|
+
const uploadOversizedAttachments = (client, payload, timeoutMs, uploadTimeoutMs) => Effect.gen(function* () {
|
|
17
18
|
const plan = planInlineUploads(payload);
|
|
18
19
|
if (plan.length === 0) return payload;
|
|
19
20
|
const uploaded = /* @__PURE__ */ new Map();
|
|
20
21
|
for (const upload of plan) {
|
|
21
|
-
const created = yield* callEndpoint(MediaGroup, "mediaCreate", { payload: mediaCreateBody(upload) });
|
|
22
|
+
const created = yield* withTimeout(callEndpoint(MediaGroup, "mediaCreate", { payload: mediaCreateBody(upload) }), timeoutMs);
|
|
22
23
|
yield* client.putUpload({
|
|
23
24
|
filename: upload.filename,
|
|
24
25
|
mediaId: created.id,
|
|
25
26
|
url: created.upload.url,
|
|
26
27
|
method: created.upload.method,
|
|
27
28
|
headers: created.upload.headers,
|
|
28
|
-
bytes: upload.bytes
|
|
29
|
+
bytes: upload.bytes,
|
|
30
|
+
timeoutMs: uploadTimeoutMs
|
|
29
31
|
});
|
|
30
|
-
yield* callEndpoint(MediaGroup, "mediaComplete", { params: { id: created.id } });
|
|
32
|
+
yield* withTimeout(callEndpoint(MediaGroup, "mediaComplete", { params: { id: created.id } }), timeoutMs);
|
|
31
33
|
uploaded.set(upload.index, {
|
|
32
34
|
mediaId: created.id,
|
|
33
35
|
upload
|
|
@@ -37,12 +39,13 @@ const uploadOversizedAttachments = (client, payload) => Effect.gen(function* ()
|
|
|
37
39
|
});
|
|
38
40
|
const sendPayload = (payload, options) => Effect.gen(function* () {
|
|
39
41
|
const client = yield* Service;
|
|
42
|
+
const timeoutMs = attemptTimeout(options, client);
|
|
40
43
|
const idempotencyKey = options?.idempotencyKey ?? client.idempotency?.("messagesSend") ?? (yield* generateIdempotencyKey);
|
|
41
|
-
const prepared = yield* uploadOversizedAttachments(client, payload);
|
|
42
|
-
return yield* withRetry(callEndpoint(MessagesGroup, "messagesSend", {
|
|
44
|
+
const prepared = yield* uploadOversizedAttachments(client, payload, timeoutMs, options?.uploadTimeoutMs);
|
|
45
|
+
return yield* withRetry(withTimeout(callEndpoint(MessagesGroup, "messagesSend", {
|
|
43
46
|
payload: stripUndefined(prepared),
|
|
44
47
|
headers: { "idempotency-key": idempotencyKey }
|
|
45
|
-
}));
|
|
48
|
+
}), timeoutMs));
|
|
46
49
|
});
|
|
47
50
|
const sendMessage = Effect.fn("Messages.send")(function* (input, options) {
|
|
48
51
|
return yield* sendPayload(buildMessagesSendPayload(input), options);
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { Effect, Schema } from "effect";
|
|
2
|
+
declare const SamvaTimeoutError_base: Schema.Class<SamvaTimeoutError, Schema.Struct<{
|
|
3
|
+
readonly _tag: Schema.tag<"SamvaTimeoutError">;
|
|
4
|
+
readonly timeoutMs: Schema.Finite;
|
|
5
|
+
}>, import("effect/Cause").YieldableError>;
|
|
6
|
+
/**
|
|
7
|
+
* A request attempt that did not finish within its `timeoutMs`. The request may still have reached
|
|
8
|
+
* the API, so the default retry policy retries it on retry-safe operations with the same
|
|
9
|
+
* idempotency key, exactly like a transport failure.
|
|
10
|
+
*/
|
|
11
|
+
export declare class SamvaTimeoutError extends SamvaTimeoutError_base {
|
|
12
|
+
get message(): string;
|
|
13
|
+
}
|
|
14
|
+
/** Bound one attempt; `null` leaves it unbounded. The losing request is interrupted. */
|
|
15
|
+
export declare const withTimeout: <A, E, R>(effect: Effect.Effect<A, E, R>, timeoutMs: number | null) => Effect.Effect<A, E | SamvaTimeoutError, R>;
|
|
16
|
+
export {};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { Duration, Effect, Schema } from "effect";
|
|
2
|
+
// src/effect/internal/timeout.ts
|
|
3
|
+
/**
|
|
4
|
+
* A request attempt that did not finish within its `timeoutMs`. The request may still have reached
|
|
5
|
+
* the API, so the default retry policy retries it on retry-safe operations with the same
|
|
6
|
+
* idempotency key, exactly like a transport failure.
|
|
7
|
+
*/
|
|
8
|
+
var SamvaTimeoutError = class extends Schema.TaggedError()("SamvaTimeoutError", Schema.Struct({ timeoutMs: Schema.Finite })) {
|
|
9
|
+
get message() {
|
|
10
|
+
return `Samva request did not finish within ${this.timeoutMs} ms`;
|
|
11
|
+
}
|
|
12
|
+
};
|
|
13
|
+
/** Bound one attempt; `null` leaves it unbounded. The losing request is interrupted. */
|
|
14
|
+
const withTimeout = (effect, timeoutMs) => timeoutMs === null ? effect : Effect.timeoutOrElse(effect, {
|
|
15
|
+
duration: Duration.millis(timeoutMs),
|
|
16
|
+
orElse: () => Effect.fail(new SamvaTimeoutError({ timeoutMs }))
|
|
17
|
+
});
|
|
18
|
+
export { SamvaTimeoutError, withTimeout };
|
|
19
|
+
|
|
20
|
+
//# sourceMappingURL=timeout.js.map
|