samva 0.51.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 +5 -2
- package/README.md +1 -0
- package/dist/client/sdk.gen.d.ts +67 -28
- package/dist/client/sdk.gen.js +157 -29
- package/dist/client/types.gen.d.ts +520 -281
- package/dist/effect/campaigns.d.ts +56 -56
- 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/generated/agents.js +4 -4
- package/dist/effect/generated/campaigns.d.ts +18 -6
- package/dist/effect/generated/campaigns.js +2 -6
- package/dist/effect/generated/email.js +3 -3
- 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 +20 -20
- package/dist/effect/generated/messages.d.ts +1 -882
- package/dist/effect/generated/messages.js +4 -243
- 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/scheduled-messages.js +1 -1
- package/dist/effect/generated/shared.d.ts +1138 -257
- package/dist/effect/generated/shared.js +321 -82
- 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 +2 -1
- package/dist/effect/integrations-catalog.d.ts +92 -4
- package/dist/effect/integrations.d.ts +40 -8
- package/dist/effect/internal/client.js +25 -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/journeys.d.ts +148 -148
- package/dist/effect/logs.d.ts +149 -0
- package/dist/effect/logs.js +18 -0
- package/dist/effect/mailboxes.d.ts +156 -150
- package/dist/effect/mailboxes.js +1 -1
- package/dist/effect/newsletter-domains.d.ts +2 -2
- package/dist/effect/whatsapp-setup-links.d.ts +2 -2
- package/dist/effect/whatsapp.d.ts +73 -3
- 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 +3 -1
- package/dist/promises/client.js +3 -1
- package/dist/promises/errors.gen.d.ts +2 -0
- package/dist/promises/errors.gen.js +137 -34
- 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/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
|
@@ -22,6 +22,7 @@ import { email_exports } from "./email.js";
|
|
|
22
22
|
import { events_exports } from "./events.js";
|
|
23
23
|
import { feedback_exports } from "./feedback.js";
|
|
24
24
|
import { journeys_exports } from "./journeys.js";
|
|
25
|
+
import { logs_exports } from "./logs.js";
|
|
25
26
|
import { mailboxes_exports } from "./mailboxes.js";
|
|
26
27
|
import { media_exports } from "./media.js";
|
|
27
28
|
import { messages_exports } from "./messages.js";
|
|
@@ -44,4 +45,4 @@ import { whatsapp_flows_exports } from "./whatsapp-flows.js";
|
|
|
44
45
|
import { whatsapp_setup_links_exports } from "./whatsapp-setup-links.js";
|
|
45
46
|
import { template_registrations_exports } from "./template-registrations.js";
|
|
46
47
|
import { template_share_links_exports } from "./template-share-links.js";
|
|
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 };
|
|
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;
|
|
@@ -67,8 +66,7 @@ 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;
|
|
@@ -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;
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { CLIENT_ATTRIBUTION_HEADER, clientAttribution } from "../../client-attribution.js";
|
|
2
2
|
import { DEFAULT_UPLOAD_TIMEOUT_MS, resolveTimeout, validateTimeout } from "../../request-policy.js";
|
|
3
|
+
import { samvaRequestId, withRequestIdMessage } from "../../request-id.js";
|
|
3
4
|
import { MediaUploadError, uploadContentType } from "../../inline-attachments.js";
|
|
4
5
|
import { ApiKeySecurityMiddleware } from "../generated/shared.js";
|
|
5
6
|
import { withTimeout } from "./timeout.js";
|
|
6
|
-
import { Context, Effect, Layer, Redacted } from "effect";
|
|
7
|
+
import { Context, Effect, Layer, Predicate, Redacted } from "effect";
|
|
7
8
|
import { HttpApi, HttpApiClient, HttpApiMiddleware } from "effect/http-api";
|
|
8
9
|
import * as FetchHttpClient from "effect/http/FetchHttpClient";
|
|
9
10
|
import * as HttpClient from "effect/http/HttpClient";
|
|
@@ -16,12 +17,33 @@ const authHeaders = (config) => config.authToken !== void 0 ? {
|
|
|
16
17
|
...config.orgSlug === void 0 ? {} : { "x-org-slug": config.orgSlug }
|
|
17
18
|
} : { "x-api-key": Redacted.isRedacted(config.apiKey) ? Redacted.value(config.apiKey) : config.apiKey };
|
|
18
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
|
+
});
|
|
19
39
|
const make = (config) => Effect.gen(function* () {
|
|
20
40
|
const baseUrl = config.baseUrl ?? DEFAULT_BASE_URL;
|
|
21
41
|
const removesAttribution = Object.entries(config.headers ?? {}).some(([name, value]) => name.toLowerCase() === "x-samva-client" && value === void 0);
|
|
22
42
|
const requestHeaders = Object.fromEntries(Object.entries(config.headers ?? {}).filter(([name]) => name.toLowerCase() !== "idempotency-key"));
|
|
23
43
|
const storage = yield* HttpClient.HttpClient;
|
|
24
|
-
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) => {
|
|
25
47
|
let attributed = HttpClientRequest.setHeader(request, CLIENT_ATTRIBUTION_HEADER, clientAttribution("typescript-effect"));
|
|
26
48
|
attributed = HttpClientRequest.setHeaders(attributed, requestHeaders);
|
|
27
49
|
if (removesAttribution) attributed = HttpClientRequest.removeHeader(attributed, CLIENT_ATTRIBUTION_HEADER);
|
|
@@ -58,7 +80,7 @@ const make = (config) => Effect.gen(function* () {
|
|
|
58
80
|
putUpload,
|
|
59
81
|
endpoint: (group, name) => Effect.flatMap(groupClient(group), (client) => {
|
|
60
82
|
const call = client[name];
|
|
61
|
-
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))));
|
|
62
84
|
}),
|
|
63
85
|
connection: {
|
|
64
86
|
baseUrl,
|
|
@@ -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
|