samva 0.50.0 → 0.52.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 +49 -5
- package/README.md +137 -7
- package/dist/client/sdk.gen.d.ts +78 -38
- package/dist/client/sdk.gen.js +1554 -967
- package/dist/client/types.gen.d.ts +541 -291
- package/dist/effect/agents.d.ts +4 -4
- package/dist/effect/api-keys.d.ts +4 -6
- package/dist/effect/campaigns.d.ts +222 -230
- 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/descriptors/integrations-catalog.d.ts +1 -1
- package/dist/effect/descriptors/integrations-catalog.js +1 -1
- package/dist/effect/descriptors/integrations.d.ts +1 -1
- package/dist/effect/descriptors/integrations.js +1 -1
- package/dist/effect/descriptors/logs.d.ts +21 -0
- package/dist/effect/descriptors/logs.js +23 -0
- package/dist/effect/descriptors/whats-app.d.ts +1 -1
- package/dist/effect/descriptors/whats-app.js +1 -1
- 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/agents.js +4 -4
- 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 +18 -68
- package/dist/effect/generated/campaigns.js +5 -15
- package/dist/effect/generated/email.d.ts +10 -3
- package/dist/effect/generated/email.js +6 -5
- package/dist/effect/generated/index.d.ts +3 -1
- package/dist/effect/generated/integrations-catalog.d.ts +93 -49
- package/dist/effect/generated/integrations-catalog.js +17 -28
- package/dist/effect/generated/integrations.d.ts +20 -40
- package/dist/effect/generated/integrations.js +9 -13
- package/dist/effect/generated/journeys.d.ts +61 -13
- package/dist/effect/generated/journeys.js +5 -5
- package/dist/effect/generated/logs.d.ts +2311 -0
- package/dist/effect/generated/logs.js +312 -0
- package/dist/effect/generated/mailboxes.d.ts +30 -24
- package/dist/effect/generated/mailboxes.js +25 -25
- package/dist/effect/generated/messages.d.ts +1 -882
- package/dist/effect/generated/messages.js +4 -243
- package/dist/effect/generated/namespaces.js +1 -1
- package/dist/effect/generated/newsletter-domains.d.ts +61 -13
- package/dist/effect/generated/newsletter-domains.js +5 -5
- package/dist/effect/generated/newsletter-issues.d.ts +166 -34
- package/dist/effect/generated/newsletter-issues.js +12 -12
- package/dist/effect/generated/newsletters.d.ts +76 -16
- package/dist/effect/generated/newsletters.js +6 -6
- package/dist/effect/generated/organizations.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 +2 -4
- package/dist/effect/generated/shared.d.ts +1139 -257
- package/dist/effect/generated/shared.js +323 -83
- package/dist/effect/generated/subscriptions.d.ts +4 -4
- package/dist/effect/generated/subscriptions.js +2 -6
- package/dist/effect/generated/template-registrations.d.ts +46 -10
- package/dist/effect/generated/template-registrations.js +4 -4
- package/dist/effect/generated/templates.js +2 -2
- package/dist/effect/generated/whats-app-flows.d.ts +151 -31
- package/dist/effect/generated/whats-app-flows.js +11 -11
- package/dist/effect/generated/whats-app-setup-links.d.ts +61 -13
- package/dist/effect/generated/whats-app-setup-links.js +5 -5
- package/dist/effect/generated/whats-app.d.ts +187 -65
- package/dist/effect/generated/whats-app.js +18 -24
- package/dist/effect/generated-metadata.d.ts +15 -3
- package/dist/effect/generated-metadata.js +375 -349
- package/dist/effect/index.d.ts +1 -0
- package/dist/effect/index.js +3 -1
- package/dist/effect/integrations-catalog.d.ts +92 -4
- package/dist/effect/integrations.d.ts +42 -10
- package/dist/effect/internal/client.d.ts +19 -2
- package/dist/effect/internal/client.js +35 -5
- package/dist/effect/internal/email-sender.d.ts +4 -4
- package/dist/effect/internal/email-sender.js +5 -3
- package/dist/effect/internal/log-events.d.ts +19 -0
- package/dist/effect/internal/log-events.js +53 -0
- package/dist/effect/internal/mailbox-events.d.ts +6 -2
- package/dist/effect/internal/mailbox-events.js +4 -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 +4 -4
- package/dist/effect/logs.d.ts +149 -0
- package/dist/effect/logs.js +18 -0
- package/dist/effect/mailboxes.d.ts +184 -178
- package/dist/effect/mailboxes.js +1 -1
- 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/effect/whatsapp.d.ts +73 -3
- package/dist/index.js +2 -2
- package/dist/mailbox-events.d.ts +50 -3
- package/dist/mailbox-events.js +38 -19
- package/dist/package.js +1 -1
- package/dist/promises/client.d.ts +8 -1
- package/dist/promises/client.js +15 -9
- package/dist/promises/errors.gen.d.ts +14 -1
- package/dist/promises/errors.gen.js +158 -36
- package/dist/promises/index.js +2 -2
- package/dist/promises/request.d.ts +31 -2
- package/dist/promises/request.js +42 -7
- package/dist/promises/types.gen.d.ts +1 -1
- package/dist/request-id.d.ts +3 -0
- package/dist/request-id.js +7 -0
- package/dist/request-policy.d.ts +9 -0
- package/dist/request-policy.js +16 -1
- package/dist/service-map.d.ts +14 -3
- package/package.json +6 -2
package/dist/effect/index.d.ts
CHANGED
|
@@ -35,6 +35,7 @@ export * as Email from "./email.js";
|
|
|
35
35
|
export * as Events from "./events.js";
|
|
36
36
|
export * as Feedback from "./feedback.js";
|
|
37
37
|
export * as Journeys from "./journeys.js";
|
|
38
|
+
export * as Logs from "./logs.js";
|
|
38
39
|
export * as Mailboxes from "./mailboxes.js";
|
|
39
40
|
export * as Media from "./media.js";
|
|
40
41
|
export * as Messages from "./messages.js";
|
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";
|
|
@@ -21,6 +22,7 @@ import { email_exports } from "./email.js";
|
|
|
21
22
|
import { events_exports } from "./events.js";
|
|
22
23
|
import { feedback_exports } from "./feedback.js";
|
|
23
24
|
import { journeys_exports } from "./journeys.js";
|
|
25
|
+
import { logs_exports } from "./logs.js";
|
|
24
26
|
import { mailboxes_exports } from "./mailboxes.js";
|
|
25
27
|
import { media_exports } from "./media.js";
|
|
26
28
|
import { messages_exports } from "./messages.js";
|
|
@@ -43,4 +45,4 @@ import { whatsapp_flows_exports } from "./whatsapp-flows.js";
|
|
|
43
45
|
import { whatsapp_setup_links_exports } from "./whatsapp-setup-links.js";
|
|
44
46
|
import { template_registrations_exports } from "./template-registrations.js";
|
|
45
47
|
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 };
|
|
48
|
+
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, logs_exports as Logs, 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 };
|
|
@@ -253,11 +253,99 @@ export declare const prepare: (input: {
|
|
|
253
253
|
} | null | undefined;
|
|
254
254
|
} | undefined;
|
|
255
255
|
}, options?: import("./internal/operation.js").OperationOptions) => import("./internal/client.js").OperationResult<"integrationCatalogPrepare">;
|
|
256
|
-
export declare const search: (input?: {
|
|
256
|
+
export declare const search: ((input?: {
|
|
257
257
|
readonly key?: string | undefined;
|
|
258
258
|
readonly query?: string | undefined;
|
|
259
259
|
readonly category?: "accounting" | "calendar" | "channel" | "commerce" | "crm" | "dns" | "forms" | "helpdesk" | "knowledge" | "other" | "payments" | "productivity" | "reviews" | "shipping" | undefined;
|
|
260
|
-
readonly
|
|
261
|
-
readonly
|
|
262
|
-
} | undefined, options?: import("./internal/operation.js").OperationOptions) => import("./internal/client.js").OperationResult<"integrationCatalogSearch"
|
|
260
|
+
readonly limit?: number | null | undefined;
|
|
261
|
+
readonly cursor?: string | undefined;
|
|
262
|
+
} | undefined, options?: import("./internal/operation.js").OperationOptions) => import("./internal/client.js").OperationResult<"integrationCatalogSearch">) & {
|
|
263
|
+
readonly pages: (input?: {
|
|
264
|
+
readonly key?: string | undefined;
|
|
265
|
+
readonly query?: string | undefined;
|
|
266
|
+
readonly category?: "accounting" | "calendar" | "channel" | "commerce" | "crm" | "dns" | "forms" | "helpdesk" | "knowledge" | "other" | "payments" | "productivity" | "reviews" | "shipping" | undefined;
|
|
267
|
+
readonly limit?: number | null | undefined;
|
|
268
|
+
readonly cursor?: string | undefined;
|
|
269
|
+
} | undefined) => import("effect/Stream").Stream<{
|
|
270
|
+
readonly items: readonly {
|
|
271
|
+
readonly key: string;
|
|
272
|
+
readonly kind: "graphql" | "mcp" | "openapi";
|
|
273
|
+
readonly name: string;
|
|
274
|
+
readonly description: string;
|
|
275
|
+
readonly domain: string | null;
|
|
276
|
+
readonly category: "accounting" | "calendar" | "channel" | "commerce" | "crm" | "dns" | "forms" | "helpdesk" | "knowledge" | "other" | "payments" | "productivity" | "reviews" | "shipping";
|
|
277
|
+
readonly icon: string | null;
|
|
278
|
+
readonly logo?: {
|
|
279
|
+
readonly file: string;
|
|
280
|
+
readonly monochrome?: boolean;
|
|
281
|
+
};
|
|
282
|
+
readonly featured: boolean;
|
|
283
|
+
readonly connectSpec: {
|
|
284
|
+
readonly provider: string;
|
|
285
|
+
readonly auth: "apiKey" | "discover" | "none" | "oauth";
|
|
286
|
+
readonly inputs: {
|
|
287
|
+
readonly [x: string]: {
|
|
288
|
+
readonly label: string;
|
|
289
|
+
readonly description: string;
|
|
290
|
+
readonly pattern: string;
|
|
291
|
+
readonly maxLength: number;
|
|
292
|
+
readonly example: string;
|
|
293
|
+
readonly default?: string;
|
|
294
|
+
readonly kind?: "hostnameLabel" | "httpsUrl";
|
|
295
|
+
};
|
|
296
|
+
};
|
|
297
|
+
readonly credentials: {
|
|
298
|
+
readonly [x: string]: {
|
|
299
|
+
readonly label: string;
|
|
300
|
+
};
|
|
301
|
+
};
|
|
302
|
+
};
|
|
303
|
+
readonly connectState: "checkedAtConnect" | "ready" | "unavailable";
|
|
304
|
+
readonly reason: string | null;
|
|
305
|
+
}[];
|
|
306
|
+
readonly nextCursor: string | null;
|
|
307
|
+
}, 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>;
|
|
308
|
+
readonly items: (input?: {
|
|
309
|
+
readonly key?: string | undefined;
|
|
310
|
+
readonly query?: string | undefined;
|
|
311
|
+
readonly category?: "accounting" | "calendar" | "channel" | "commerce" | "crm" | "dns" | "forms" | "helpdesk" | "knowledge" | "other" | "payments" | "productivity" | "reviews" | "shipping" | undefined;
|
|
312
|
+
readonly limit?: number | null | undefined;
|
|
313
|
+
readonly cursor?: string | undefined;
|
|
314
|
+
} | undefined) => import("effect/Stream").Stream<{
|
|
315
|
+
readonly key: string;
|
|
316
|
+
readonly kind: "graphql" | "mcp" | "openapi";
|
|
317
|
+
readonly name: string;
|
|
318
|
+
readonly description: string;
|
|
319
|
+
readonly domain: string | null;
|
|
320
|
+
readonly category: "accounting" | "calendar" | "channel" | "commerce" | "crm" | "dns" | "forms" | "helpdesk" | "knowledge" | "other" | "payments" | "productivity" | "reviews" | "shipping";
|
|
321
|
+
readonly icon: string | null;
|
|
322
|
+
readonly logo?: {
|
|
323
|
+
readonly file: string;
|
|
324
|
+
readonly monochrome?: boolean;
|
|
325
|
+
};
|
|
326
|
+
readonly featured: boolean;
|
|
327
|
+
readonly connectSpec: {
|
|
328
|
+
readonly provider: string;
|
|
329
|
+
readonly auth: "apiKey" | "discover" | "none" | "oauth";
|
|
330
|
+
readonly inputs: {
|
|
331
|
+
readonly [x: string]: {
|
|
332
|
+
readonly label: string;
|
|
333
|
+
readonly description: string;
|
|
334
|
+
readonly pattern: string;
|
|
335
|
+
readonly maxLength: number;
|
|
336
|
+
readonly example: string;
|
|
337
|
+
readonly default?: string;
|
|
338
|
+
readonly kind?: "hostnameLabel" | "httpsUrl";
|
|
339
|
+
};
|
|
340
|
+
};
|
|
341
|
+
readonly credentials: {
|
|
342
|
+
readonly [x: string]: {
|
|
343
|
+
readonly label: string;
|
|
344
|
+
};
|
|
345
|
+
};
|
|
346
|
+
};
|
|
347
|
+
readonly connectState: "checkedAtConnect" | "ready" | "unavailable";
|
|
348
|
+
readonly reason: string | null;
|
|
349
|
+
}, 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>;
|
|
350
|
+
};
|
|
263
351
|
export declare const list: (input?: never, options?: import("./internal/operation.js").OperationOptions) => import("./internal/client.js").OperationResult<"integrationCatalogList">;
|
|
@@ -30,8 +30,7 @@ export declare const list: ((input?: {
|
|
|
30
30
|
readonly runsWithoutApproval: boolean;
|
|
31
31
|
}[];
|
|
32
32
|
readonly toolPage: {
|
|
33
|
-
readonly
|
|
34
|
-
readonly total: number;
|
|
33
|
+
readonly nextCursor: string | null;
|
|
35
34
|
readonly revision: string;
|
|
36
35
|
};
|
|
37
36
|
readonly installedBy: (string & import("effect/Brand").Brand<"UserId">) | null;
|
|
@@ -39,7 +38,7 @@ export declare const list: ((input?: {
|
|
|
39
38
|
readonly updatedAt: string;
|
|
40
39
|
}[];
|
|
41
40
|
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>;
|
|
41
|
+
}, 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
42
|
readonly items: (input?: {
|
|
44
43
|
readonly limit?: number | null | undefined;
|
|
45
44
|
readonly cursor?: string | undefined;
|
|
@@ -67,14 +66,13 @@ export declare const list: ((input?: {
|
|
|
67
66
|
readonly runsWithoutApproval: boolean;
|
|
68
67
|
}[];
|
|
69
68
|
readonly toolPage: {
|
|
70
|
-
readonly
|
|
71
|
-
readonly total: number;
|
|
69
|
+
readonly nextCursor: string | null;
|
|
72
70
|
readonly revision: string;
|
|
73
71
|
};
|
|
74
72
|
readonly installedBy: (string & import("effect/Brand").Brand<"UserId">) | null;
|
|
75
73
|
readonly createdAt: string;
|
|
76
74
|
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>;
|
|
75
|
+
}, 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
76
|
};
|
|
79
77
|
export declare const install: (input: {
|
|
80
78
|
readonly app: string;
|
|
@@ -109,11 +107,45 @@ export declare const install: (input: {
|
|
|
109
107
|
} | null | undefined;
|
|
110
108
|
} | undefined;
|
|
111
109
|
}, options?: import("./internal/operation.js").OperationOptions) => import("./internal/client.js").OperationResult<"integrationsInstall">;
|
|
112
|
-
export declare const listTools: (input: {
|
|
110
|
+
export declare const listTools: ((input: {
|
|
113
111
|
readonly integrationId: string;
|
|
114
|
-
readonly
|
|
115
|
-
readonly
|
|
116
|
-
}, options?: import("./internal/operation.js").OperationOptions) => import("./internal/client.js").OperationResult<"integrationsListTools"
|
|
112
|
+
readonly limit?: number | null | undefined;
|
|
113
|
+
readonly cursor?: string | undefined;
|
|
114
|
+
}, options?: import("./internal/operation.js").OperationOptions) => import("./internal/client.js").OperationResult<"integrationsListTools">) & {
|
|
115
|
+
readonly pages: (input: {
|
|
116
|
+
readonly integrationId: string;
|
|
117
|
+
readonly limit?: number | null | undefined;
|
|
118
|
+
readonly cursor?: string | undefined;
|
|
119
|
+
}) => import("effect/Stream").Stream<{
|
|
120
|
+
readonly items: readonly {
|
|
121
|
+
readonly name: string;
|
|
122
|
+
readonly title: string;
|
|
123
|
+
readonly kind: "mutation" | "query";
|
|
124
|
+
readonly effect: "final" | "read" | "write";
|
|
125
|
+
readonly guards: readonly ("insideHours" | "pinnedDestination")[];
|
|
126
|
+
readonly granted: boolean;
|
|
127
|
+
readonly unavailableReason?: "input_schema_too_large";
|
|
128
|
+
readonly enabled: boolean;
|
|
129
|
+
readonly runsWithoutApproval: boolean;
|
|
130
|
+
}[];
|
|
131
|
+
readonly nextCursor: string | null;
|
|
132
|
+
}, import("./errors.js").ConflictError | import("./errors.js").ForbiddenError | import("./errors.js").GatewayTimeoutError | import("effect/http/HttpClientError").HttpClientError | import("./errors.js").InternalError | import("./errors.js").MalformedRequestError | import("./errors.js").ResourceNotFoundError | import("./errors.js").SamvaTimeoutError | import("effect/Schema").SchemaError | import("./errors.js").UnauthorizedError | import("./errors.js").ValidationError, import("./client.js").Service>;
|
|
133
|
+
readonly items: (input: {
|
|
134
|
+
readonly integrationId: string;
|
|
135
|
+
readonly limit?: number | null | undefined;
|
|
136
|
+
readonly cursor?: string | undefined;
|
|
137
|
+
}) => import("effect/Stream").Stream<{
|
|
138
|
+
readonly name: string;
|
|
139
|
+
readonly title: string;
|
|
140
|
+
readonly kind: "mutation" | "query";
|
|
141
|
+
readonly effect: "final" | "read" | "write";
|
|
142
|
+
readonly guards: readonly ("insideHours" | "pinnedDestination")[];
|
|
143
|
+
readonly granted: boolean;
|
|
144
|
+
readonly unavailableReason?: "input_schema_too_large";
|
|
145
|
+
readonly enabled: boolean;
|
|
146
|
+
readonly runsWithoutApproval: boolean;
|
|
147
|
+
}, import("./errors.js").ConflictError | import("./errors.js").ForbiddenError | import("./errors.js").GatewayTimeoutError | import("effect/http/HttpClientError").HttpClientError | import("./errors.js").InternalError | import("./errors.js").MalformedRequestError | import("./errors.js").ResourceNotFoundError | import("./errors.js").SamvaTimeoutError | import("effect/Schema").SchemaError | import("./errors.js").UnauthorizedError | import("./errors.js").ValidationError, import("./client.js").Service>;
|
|
148
|
+
};
|
|
117
149
|
export declare const readTool: (input: {
|
|
118
150
|
readonly integrationId: string;
|
|
119
151
|
readonly tool: 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,7 +1,10 @@
|
|
|
1
1
|
import { CLIENT_ATTRIBUTION_HEADER, clientAttribution } from "../../client-attribution.js";
|
|
2
|
+
import { DEFAULT_UPLOAD_TIMEOUT_MS, resolveTimeout, validateTimeout } from "../../request-policy.js";
|
|
3
|
+
import { samvaRequestId, withRequestIdMessage } from "../../request-id.js";
|
|
2
4
|
import { MediaUploadError, uploadContentType } from "../../inline-attachments.js";
|
|
3
5
|
import { ApiKeySecurityMiddleware } from "../generated/shared.js";
|
|
4
|
-
import {
|
|
6
|
+
import { withTimeout } from "./timeout.js";
|
|
7
|
+
import { Context, Effect, Layer, Predicate, Redacted } from "effect";
|
|
5
8
|
import { HttpApi, HttpApiClient, HttpApiMiddleware } from "effect/http-api";
|
|
6
9
|
import * as FetchHttpClient from "effect/http/FetchHttpClient";
|
|
7
10
|
import * as HttpClient from "effect/http/HttpClient";
|
|
@@ -14,12 +17,33 @@ const authHeaders = (config) => config.authToken !== void 0 ? {
|
|
|
14
17
|
...config.orgSlug === void 0 ? {} : { "x-org-slug": config.orgSlug }
|
|
15
18
|
} : { "x-api-key": Redacted.isRedacted(config.apiKey) ? Redacted.value(config.apiKey) : config.apiKey };
|
|
16
19
|
const AuthorizationClient = HttpApiMiddleware.layerClient(ApiKeySecurityMiddleware, ({ next, request }) => next(request));
|
|
20
|
+
const ResponseRequestId = Context.Reference("samva/ResponseRequestId", { defaultValue: () => void 0 });
|
|
21
|
+
const withResponseRequestId = (effect) => Effect.suspend(() => {
|
|
22
|
+
const requestId = { value: void 0 };
|
|
23
|
+
return effect.pipe(Effect.mapError((error) => {
|
|
24
|
+
if (requestId.value === void 0 || !Predicate.isObject(error) || typeof error.message !== "string") return error;
|
|
25
|
+
Object.defineProperties(error, {
|
|
26
|
+
requestId: {
|
|
27
|
+
value: requestId.value,
|
|
28
|
+
enumerable: true,
|
|
29
|
+
configurable: true
|
|
30
|
+
},
|
|
31
|
+
message: {
|
|
32
|
+
value: withRequestIdMessage(error.message, requestId.value),
|
|
33
|
+
configurable: true
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
return error;
|
|
37
|
+
}), Effect.provideService(ResponseRequestId, requestId));
|
|
38
|
+
});
|
|
17
39
|
const make = (config) => Effect.gen(function* () {
|
|
18
40
|
const baseUrl = config.baseUrl ?? DEFAULT_BASE_URL;
|
|
19
41
|
const removesAttribution = Object.entries(config.headers ?? {}).some(([name, value]) => name.toLowerCase() === "x-samva-client" && value === void 0);
|
|
20
42
|
const requestHeaders = Object.fromEntries(Object.entries(config.headers ?? {}).filter(([name]) => name.toLowerCase() !== "idempotency-key"));
|
|
21
43
|
const storage = yield* HttpClient.HttpClient;
|
|
22
|
-
const httpClient = storage.pipe(HttpClient.
|
|
44
|
+
const httpClient = storage.pipe(HttpClient.tap((response) => Effect.map(ResponseRequestId, (requestId) => {
|
|
45
|
+
if (requestId !== void 0) requestId.value = samvaRequestId(response.headers["x-samva-request-id"]);
|
|
46
|
+
})), HttpClient.mapRequest((request) => {
|
|
23
47
|
let attributed = HttpClientRequest.setHeader(request, CLIENT_ATTRIBUTION_HEADER, clientAttribution("typescript-effect"));
|
|
24
48
|
attributed = HttpClientRequest.setHeaders(attributed, requestHeaders);
|
|
25
49
|
if (removesAttribution) attributed = HttpClientRequest.removeHeader(attributed, CLIENT_ATTRIBUTION_HEADER);
|
|
@@ -41,7 +65,7 @@ const make = (config) => Effect.gen(function* () {
|
|
|
41
65
|
};
|
|
42
66
|
const headers = removesAttribution ? {} : { [CLIENT_ATTRIBUTION_HEADER]: clientAttribution("typescript-effect") };
|
|
43
67
|
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({
|
|
68
|
+
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
69
|
filename: input.filename,
|
|
46
70
|
mediaId: input.mediaId,
|
|
47
71
|
cause
|
|
@@ -52,10 +76,11 @@ const make = (config) => Effect.gen(function* () {
|
|
|
52
76
|
}))));
|
|
53
77
|
return Service.of({
|
|
54
78
|
idempotency: config.idempotency,
|
|
79
|
+
timeoutMs: config.timeoutMs,
|
|
55
80
|
putUpload,
|
|
56
81
|
endpoint: (group, name) => Effect.flatMap(groupClient(group), (client) => {
|
|
57
82
|
const call = client[name];
|
|
58
|
-
return call === void 0 ? Effect.die(/* @__PURE__ */ new Error(`${name} is not an endpoint of ${group.identifier}`)) : Effect.succeed(call);
|
|
83
|
+
return call === void 0 ? Effect.die(/* @__PURE__ */ new Error(`${name} is not an endpoint of ${group.identifier}`)) : Effect.succeed(((request) => withResponseRequestId(call(request))));
|
|
59
84
|
}),
|
|
60
85
|
connection: {
|
|
61
86
|
baseUrl,
|
|
@@ -66,7 +91,12 @@ const make = (config) => Effect.gen(function* () {
|
|
|
66
91
|
}
|
|
67
92
|
});
|
|
68
93
|
});
|
|
69
|
-
|
|
94
|
+
/** Throws a `RangeError` for an invalid `timeoutMs` or `uploadTimeoutMs`, as the Promise client does. */
|
|
95
|
+
const layer = (config) => {
|
|
96
|
+
validateTimeout("timeoutMs", config.timeoutMs);
|
|
97
|
+
validateTimeout("uploadTimeoutMs", config.uploadTimeoutMs);
|
|
98
|
+
return Layer.effect(Service, make(config));
|
|
99
|
+
};
|
|
70
100
|
const layerFetch = (config) => layer(config).pipe(Layer.provide(FetchHttpClient.layer));
|
|
71
101
|
export { Service, layer, layerFetch };
|
|
72
102
|
|
|
@@ -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
|
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { Effect } from "effect";
|
|
2
|
+
import { type MailboxEventStreamOptions } from "../../mailbox-events.js";
|
|
3
|
+
import { LogLine } from "../generated/logs.js";
|
|
4
|
+
import { Service } from "./client.js";
|
|
5
|
+
export type LogEventStreamOptions = Omit<MailboxEventStreamOptions, "mailboxIds" | "signal">;
|
|
6
|
+
export interface LogEvent {
|
|
7
|
+
/** The WebSocket position used to replay. The line has its own cursor for list queries. */
|
|
8
|
+
readonly cursor: string;
|
|
9
|
+
readonly line: LogLine;
|
|
10
|
+
readonly match: {
|
|
11
|
+
readonly mailboxIds: ReadonlyArray<string>;
|
|
12
|
+
readonly senderAddresses: ReadonlyArray<string>;
|
|
13
|
+
readonly credential: string;
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
/** Follow message log events, resuming within the stream's 72-hour replay window. */
|
|
17
|
+
export declare const events: (options?: LogEventStreamOptions) => import("effect/Stream").Stream<LogEvent, import("../../index.js").MailboxEventStreamFailure, Service>;
|
|
18
|
+
/** Take a stream checkpoint before fetching history so the subsequent replay covers the handoff. */
|
|
19
|
+
export declare const streamCursor: (options?: Pick<LogEventStreamOptions, "eventsUrl">) => Effect.Effect<string, import("../../index.js").MailboxEventStreamFailure, Service>;
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { EventStream, eventStreamUrl, readRefusalBody, refusalOutcome } from "../../mailbox-events.js";
|
|
2
|
+
import { Service } from "./client.js";
|
|
3
|
+
import { LogLine } from "../generated/logs.js";
|
|
4
|
+
import { streamEvents, toStreamError } from "./mailbox-events.js";
|
|
5
|
+
import { Effect, Schema } from "effect";
|
|
6
|
+
// src/effect/internal/log-events.ts
|
|
7
|
+
const LOG_EVENT_STREAM_PATH = "/v1/logs/events";
|
|
8
|
+
const StreamCursor = Schema.Struct({ cursor: Schema.String.check(Schema.isPattern(/^(0|[1-9]\d{0,14})$/u)) });
|
|
9
|
+
const decodeCursor = Schema.decodeUnknownPromise(StreamCursor);
|
|
10
|
+
const decodeEvent = Schema.decodeUnknownOption(Schema.Struct({
|
|
11
|
+
data: LogLine,
|
|
12
|
+
match: Schema.Struct({
|
|
13
|
+
mailboxIds: Schema.Array(Schema.String),
|
|
14
|
+
senderAddresses: Schema.Array(Schema.String),
|
|
15
|
+
credential: Schema.String
|
|
16
|
+
})
|
|
17
|
+
}));
|
|
18
|
+
/** Follow message log events, resuming within the stream's 72-hour replay window. */
|
|
19
|
+
const events = (options = {}) => streamEvents((connection) => new EventStream(connection, options, LOG_EVENT_STREAM_PATH, (frame) => {
|
|
20
|
+
if (frame.event.type !== "log.line") return void 0;
|
|
21
|
+
const payload = decodeEvent(frame.event);
|
|
22
|
+
if (payload._tag === "None") return void 0;
|
|
23
|
+
return {
|
|
24
|
+
cursor: frame.cursor,
|
|
25
|
+
line: payload.value.data,
|
|
26
|
+
match: payload.value.match
|
|
27
|
+
};
|
|
28
|
+
}));
|
|
29
|
+
/** Take a stream checkpoint before fetching history so the subsequent replay covers the handoff. */
|
|
30
|
+
const streamCursor = (options = {}) => Effect.gen(function* () {
|
|
31
|
+
const { connection } = yield* Service;
|
|
32
|
+
return yield* Effect.tryPromise({
|
|
33
|
+
try: async (signal) => {
|
|
34
|
+
const url = eventStreamUrl(connection, options, LOG_EVENT_STREAM_PATH);
|
|
35
|
+
url.protocol = url.protocol === "wss:" ? "https:" : "http:";
|
|
36
|
+
url.searchParams.set("head", "1");
|
|
37
|
+
const response = await (connection.fetch ?? fetch)(url, {
|
|
38
|
+
headers: typeof connection.headers === "function" ? await connection.headers() : connection.headers,
|
|
39
|
+
signal: AbortSignal.any([signal, AbortSignal.timeout(1e4)])
|
|
40
|
+
});
|
|
41
|
+
if (!response.ok) return { error: refusalOutcome({
|
|
42
|
+
status: response.status,
|
|
43
|
+
body: await readRefusalBody(response),
|
|
44
|
+
retryAfterSeconds: void 0
|
|
45
|
+
}).error };
|
|
46
|
+
return await decodeCursor(await response.json());
|
|
47
|
+
},
|
|
48
|
+
catch: toStreamError
|
|
49
|
+
}).pipe(Effect.flatMap((result) => "error" in result ? Effect.fail(toStreamError(result.error)) : Effect.succeed(result.cursor)));
|
|
50
|
+
});
|
|
51
|
+
export { events, streamCursor };
|
|
52
|
+
|
|
53
|
+
//# sourceMappingURL=log-events.js.map
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { Stream } from "effect";
|
|
2
|
-
import { type
|
|
2
|
+
import { type EventStream, type MailboxEventStreamConnection, type MailboxEventStreamOptions, type MailboxEventStreamFailure } from "../../mailbox-events.js";
|
|
3
3
|
import { Service } from "./client.js";
|
|
4
|
+
export declare const toStreamError: (cause: unknown) => MailboxEventStreamFailure;
|
|
4
5
|
/**
|
|
5
6
|
* The organization's mailbox events as a stream, resuming from `cursor`. An event counts as handled
|
|
6
7
|
* once the stream is pulled again, or once it ends successfully after the event (as `Stream.take`
|
|
@@ -8,4 +9,7 @@ import { Service } from "./client.js";
|
|
|
8
9
|
* The stream fails with a {@link MailboxEventStreamFailure}, which `Effect.catchTag` narrows by the
|
|
9
10
|
* `_tag` of the host's refusal.
|
|
10
11
|
*/
|
|
11
|
-
export declare const
|
|
12
|
+
export declare const streamEvents: <Event extends {
|
|
13
|
+
readonly cursor: string;
|
|
14
|
+
}>(open: (connection: MailboxEventStreamConnection) => EventStream<Event>) => Stream.Stream<Event, MailboxEventStreamFailure, Service>;
|
|
15
|
+
export declare const events: (options?: Omit<MailboxEventStreamOptions, "signal">) => Stream.Stream<import("../../index.js").MailboxEvent, MailboxEventStreamFailure, Service>;
|
|
@@ -13,10 +13,10 @@ const toStreamError = (cause) => cause instanceof MailboxEventStreamError ? caus
|
|
|
13
13
|
* The stream fails with a {@link MailboxEventStreamFailure}, which `Effect.catchTag` narrows by the
|
|
14
14
|
* `_tag` of the host's refusal.
|
|
15
15
|
*/
|
|
16
|
-
const
|
|
16
|
+
const streamEvents = (open) => Stream.scoped(Stream.unwrap(Effect.gen(function* () {
|
|
17
17
|
const client = yield* Service;
|
|
18
18
|
const iterator = (yield* Effect.acquireRelease(Effect.try({
|
|
19
|
-
try: () =>
|
|
19
|
+
try: () => open(client.connection),
|
|
20
20
|
catch: toStreamError
|
|
21
21
|
}), (opened, exit) => Effect.sync(() => {
|
|
22
22
|
if (Exit.isSuccess(exit)) opened.markHandled();
|
|
@@ -27,6 +27,7 @@ const events = (options = {}) => Stream.scoped(Stream.unwrap(Effect.gen(function
|
|
|
27
27
|
catch: toStreamError
|
|
28
28
|
}).pipe(Effect.flatMap((next) => next.done ? Cause.done() : Effect.succeed(next.value))));
|
|
29
29
|
})));
|
|
30
|
-
|
|
30
|
+
const events = (options = {}) => streamEvents((connection) => new MailboxEventStream(connection, options));
|
|
31
|
+
export { events, streamEvents, toStreamError };
|
|
31
32
|
|
|
32
33
|
//# sourceMappingURL=mailbox-events.js.map
|
|
@@ -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
|