samva 0.4.0 → 0.6.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 +3 -2
- package/README.md +12 -2
- package/dist/{categories-CsUa8ojo.js → categories-4u9Az4No.js} +28 -8
- package/dist/client/sdk.gen.d.ts +545 -74
- package/dist/client/types.gen.d.ts +3907 -747
- package/dist/{client-BmZK_uCt.js → client-DCM6U0-I.js} +3061 -808
- package/dist/{client-attribution-BslSOa_8.js → client-attribution-DYUSAa76.js} +2 -2
- package/dist/effect/analytics.d.ts +66 -0
- package/dist/effect/analytics.js +21 -0
- package/dist/effect/api-keys.d.ts +198 -34
- package/dist/effect/api-keys.js +1 -1
- package/dist/effect/attachments.d.ts +53 -0
- package/dist/effect/attachments.js +17 -0
- package/dist/effect/campaigns.d.ts +52 -18
- package/dist/effect/campaigns.js +1 -1
- package/dist/effect/categories.d.ts +3 -3
- package/dist/effect/categories.js +1 -1
- package/dist/effect/client.js +1 -1
- package/dist/effect/contact-groups.d.ts +375 -0
- package/dist/effect/contact-groups.js +29 -0
- package/dist/effect/contacts.d.ts +35 -19
- package/dist/effect/contacts.js +1 -1
- package/dist/effect/conversations.d.ts +191 -44
- package/dist/effect/conversations.js +1 -1
- package/dist/effect/custom-fields.d.ts +111 -0
- package/dist/effect/custom-fields.js +17 -0
- package/dist/effect/design.d.ts +2 -2
- package/dist/effect/design.js +1 -1
- package/dist/effect/email.d.ts +931 -97
- package/dist/effect/email.js +27 -3
- package/dist/effect/generated-metadata.d.ts +16 -4
- package/dist/effect/generated.d.ts +19596 -10819
- package/dist/effect/index.d.ts +6 -1
- package/dist/effect/index.js +8 -3
- package/dist/effect/internal/operation.d.ts +124 -26
- package/dist/effect/media.d.ts +8 -8
- package/dist/effect/media.js +1 -1
- package/dist/effect/messages.d.ts +473 -64
- package/dist/effect/messages.js +5 -3
- package/dist/effect/operations.d.ts +6 -6
- package/dist/effect/operations.js +1 -1
- package/dist/effect/organizations.d.ts +7 -110
- package/dist/effect/organizations.js +2 -4
- package/dist/effect/retry.js +1 -1
- package/dist/effect/scheduled-messages.d.ts +96 -12
- package/dist/effect/scheduled-messages.js +5 -3
- package/dist/effect/templates.d.ts +35 -295
- package/dist/effect/templates.js +3 -5
- package/dist/effect/unsubscribe-groups.d.ts +161 -0
- package/dist/effect/unsubscribe-groups.js +25 -0
- package/dist/effect/webhooks.d.ts +52 -18
- package/dist/effect/webhooks.js +2 -2
- package/dist/index.js +2 -2
- package/dist/{normalize-BiIJnycv.js → normalize-B79uJIeb.js} +13 -14
- package/dist/normalize.d.ts +3 -7
- package/dist/{operation-B1knNlxk.js → operation-02YX3hY9.js} +144 -8
- package/dist/promises/errors.gen.d.ts +47 -39
- package/dist/promises/index.d.ts +19 -4
- package/dist/promises/index.js +2 -2
- package/dist/promises/types.gen.d.ts +1 -1
- package/dist/{promises-n1opem5V.js → promises-8MaPNAam.js} +1679 -267
- package/dist/service-map.d.ts +221 -8
- package/package.json +29 -9
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { n as buildMessagesSendPayload, r as replyToEmailsPayload, t as buildEmailSendPayload } from "./normalize-
|
|
2
|
-
import {
|
|
1
|
+
import { n as buildMessagesSendPayload, r as replyToEmailsPayload, t as buildEmailSendPayload } from "./normalize-B79uJIeb.js";
|
|
2
|
+
import { t as Service, y as SamvaApi } from "./client-DCM6U0-I.js";
|
|
3
3
|
import { generateIdempotencyKey, withRetry } from "./effect/retry.js";
|
|
4
4
|
import { Effect, Option, Predicate, Stream } from "effect";
|
|
5
5
|
//#region src/service-map.ts
|
|
@@ -18,6 +18,7 @@ const SDK_OPERATION_CALLS = {
|
|
|
18
18
|
},
|
|
19
19
|
messagesList: { kind: "params" },
|
|
20
20
|
messagesSend: { kind: "payload" },
|
|
21
|
+
messagesValidateEmail: { kind: "payload" },
|
|
21
22
|
messagesGet: {
|
|
22
23
|
kind: "path",
|
|
23
24
|
paths: ["id"]
|
|
@@ -65,6 +66,10 @@ const SDK_OPERATION_CALLS = {
|
|
|
65
66
|
kind: "path",
|
|
66
67
|
paths: ["id"]
|
|
67
68
|
},
|
|
69
|
+
scheduledMessagesResume: {
|
|
70
|
+
kind: "pathPayload",
|
|
71
|
+
paths: ["id"]
|
|
72
|
+
},
|
|
68
73
|
campaignsList: { kind: "params" },
|
|
69
74
|
campaignsCreate: { kind: "payload" },
|
|
70
75
|
campaignsGet: {
|
|
@@ -112,7 +117,14 @@ const SDK_OPERATION_CALLS = {
|
|
|
112
117
|
emailUpdateTrackingDefaults: { kind: "payload" },
|
|
113
118
|
emailGetRecipientTrackingPreference: { kind: "params" },
|
|
114
119
|
emailUpdateRecipientTrackingPreference: { kind: "payload" },
|
|
120
|
+
emailGetOnboardingReview: { kind: "none" },
|
|
121
|
+
emailReapplyOnboardingReview: { kind: "payload" },
|
|
122
|
+
emailRespondToOnboardingInformationRequest: { kind: "payload" },
|
|
115
123
|
emailAddDomain: { kind: "payload" },
|
|
124
|
+
emailRotateDomainDkim: {
|
|
125
|
+
kind: "idempotentPath",
|
|
126
|
+
paths: ["id"]
|
|
127
|
+
},
|
|
116
128
|
emailGetDomainVerification: {
|
|
117
129
|
kind: "path",
|
|
118
130
|
paths: ["id"]
|
|
@@ -189,7 +201,39 @@ const SDK_OPERATION_CALLS = {
|
|
|
189
201
|
kind: "path",
|
|
190
202
|
paths: ["id"]
|
|
191
203
|
},
|
|
204
|
+
emailGetDomainWarming: {
|
|
205
|
+
kind: "path",
|
|
206
|
+
paths: ["id"]
|
|
207
|
+
},
|
|
208
|
+
emailCreateDomainWarmingPlan: {
|
|
209
|
+
kind: "pathPayload",
|
|
210
|
+
paths: ["id"]
|
|
211
|
+
},
|
|
212
|
+
emailUpdateDomainWarmingPolicy: {
|
|
213
|
+
kind: "pathPayload",
|
|
214
|
+
paths: ["id"]
|
|
215
|
+
},
|
|
216
|
+
emailCancelDomainWarmingBatch: {
|
|
217
|
+
kind: "path",
|
|
218
|
+
paths: ["id", "batchId"]
|
|
219
|
+
},
|
|
220
|
+
emailPauseDomainWarming: {
|
|
221
|
+
kind: "pathPayload",
|
|
222
|
+
paths: ["id"]
|
|
223
|
+
},
|
|
224
|
+
emailResumeDomainWarming: {
|
|
225
|
+
kind: "pathPayload",
|
|
226
|
+
paths: ["id"]
|
|
227
|
+
},
|
|
228
|
+
emailCompleteDomainWarming: {
|
|
229
|
+
kind: "pathPayload",
|
|
230
|
+
paths: ["id"]
|
|
231
|
+
},
|
|
192
232
|
emailListSenders: { kind: "params" },
|
|
233
|
+
emailGetSender: {
|
|
234
|
+
kind: "path",
|
|
235
|
+
paths: ["id"]
|
|
236
|
+
},
|
|
193
237
|
emailAddSender: { kind: "idempotentPayload" },
|
|
194
238
|
emailCheckSenderVerification: {
|
|
195
239
|
kind: "path",
|
|
@@ -294,7 +338,6 @@ const SDK_OPERATION_CALLS = {
|
|
|
294
338
|
},
|
|
295
339
|
templatesList: { kind: "params" },
|
|
296
340
|
templatesCreate: { kind: "payload" },
|
|
297
|
-
templatesListDashboard: { kind: "params" },
|
|
298
341
|
templatesListFamilies: { kind: "params" },
|
|
299
342
|
templatesCreateFamily: { kind: "payload" },
|
|
300
343
|
templatesGetFamily: {
|
|
@@ -439,7 +482,6 @@ const SDK_OPERATION_CALLS = {
|
|
|
439
482
|
kind: "path",
|
|
440
483
|
paths: ["webhookId"]
|
|
441
484
|
},
|
|
442
|
-
organizationsBootstrap: { kind: "payload" },
|
|
443
485
|
organizationsCreate: { kind: "payload" },
|
|
444
486
|
organizationsGet: { kind: "none" },
|
|
445
487
|
organizationsUpdate: { kind: "payload" },
|
|
@@ -474,7 +516,90 @@ const SDK_OPERATION_CALLS = {
|
|
|
474
516
|
apiKeysGetActivity: {
|
|
475
517
|
kind: "pathParams",
|
|
476
518
|
paths: ["id"]
|
|
477
|
-
}
|
|
519
|
+
},
|
|
520
|
+
attachmentsList: { kind: "params" },
|
|
521
|
+
attachmentsGetById: {
|
|
522
|
+
kind: "path",
|
|
523
|
+
paths: ["id"]
|
|
524
|
+
},
|
|
525
|
+
attachmentsRemove: {
|
|
526
|
+
kind: "path",
|
|
527
|
+
paths: ["id"]
|
|
528
|
+
},
|
|
529
|
+
attachmentsDownloadUrl: {
|
|
530
|
+
kind: "pathParams",
|
|
531
|
+
paths: ["id"]
|
|
532
|
+
},
|
|
533
|
+
contactGroupsList: { kind: "params" },
|
|
534
|
+
contactGroupsCreate: { kind: "payload" },
|
|
535
|
+
contactGroupsGetById: {
|
|
536
|
+
kind: "path",
|
|
537
|
+
paths: ["id"]
|
|
538
|
+
},
|
|
539
|
+
contactGroupsUpdate: {
|
|
540
|
+
kind: "pathPayload",
|
|
541
|
+
paths: ["id"]
|
|
542
|
+
},
|
|
543
|
+
contactGroupsRemove: {
|
|
544
|
+
kind: "path",
|
|
545
|
+
paths: ["id"]
|
|
546
|
+
},
|
|
547
|
+
contactGroupsPreview: { kind: "payload" },
|
|
548
|
+
contactGroupsEvaluateDynamic: {
|
|
549
|
+
kind: "path",
|
|
550
|
+
paths: ["groupId"]
|
|
551
|
+
},
|
|
552
|
+
contactGroupsGetMembers: {
|
|
553
|
+
kind: "pathParams",
|
|
554
|
+
paths: ["groupId"]
|
|
555
|
+
},
|
|
556
|
+
contactGroupsAddMembers: {
|
|
557
|
+
kind: "pathPayload",
|
|
558
|
+
paths: ["groupId"]
|
|
559
|
+
},
|
|
560
|
+
contactGroupsRemoveMembers: {
|
|
561
|
+
kind: "pathPayload",
|
|
562
|
+
paths: ["groupId"]
|
|
563
|
+
},
|
|
564
|
+
customFieldsList: { kind: "params" },
|
|
565
|
+
customFieldsCreate: { kind: "payload" },
|
|
566
|
+
customFieldsUpdate: {
|
|
567
|
+
kind: "pathPayload",
|
|
568
|
+
paths: ["id"]
|
|
569
|
+
},
|
|
570
|
+
customFieldsRemove: {
|
|
571
|
+
kind: "path",
|
|
572
|
+
paths: ["id"]
|
|
573
|
+
},
|
|
574
|
+
unsubscribeList: { kind: "params" },
|
|
575
|
+
unsubscribeCreate: { kind: "payload" },
|
|
576
|
+
unsubscribeUpdate: {
|
|
577
|
+
kind: "pathPayload",
|
|
578
|
+
paths: ["id"]
|
|
579
|
+
},
|
|
580
|
+
unsubscribeRemove: {
|
|
581
|
+
kind: "path",
|
|
582
|
+
paths: ["id"]
|
|
583
|
+
},
|
|
584
|
+
unsubscribeListMembers: {
|
|
585
|
+
kind: "pathParams",
|
|
586
|
+
paths: ["groupId"]
|
|
587
|
+
},
|
|
588
|
+
unsubscribeAddEmails: {
|
|
589
|
+
kind: "pathPayload",
|
|
590
|
+
paths: ["groupId"]
|
|
591
|
+
},
|
|
592
|
+
unsubscribeRemoveEmails: {
|
|
593
|
+
kind: "pathPayload",
|
|
594
|
+
paths: ["groupId"]
|
|
595
|
+
},
|
|
596
|
+
unsubscribeCheckSubscription: { kind: "params" },
|
|
597
|
+
analyticsGetStats: { kind: "params" },
|
|
598
|
+
analyticsGetChannelStats: { kind: "params" },
|
|
599
|
+
analyticsGetTopContacts: { kind: "params" },
|
|
600
|
+
analyticsGetHourlyDistribution: { kind: "params" },
|
|
601
|
+
analyticsGetDeliveryMetrics: { kind: "params" },
|
|
602
|
+
analyticsExportData: { kind: "payload" }
|
|
478
603
|
};
|
|
479
604
|
//#endregion
|
|
480
605
|
//#region src/effect/pagination.ts
|
|
@@ -542,10 +667,14 @@ const readOperations = () => {
|
|
|
542
667
|
};
|
|
543
668
|
const READ_OPERATIONS = readOperations();
|
|
544
669
|
const MODULE_NAMES = {
|
|
670
|
+
analytics: "Analytics",
|
|
545
671
|
apiKeys: "ApiKeys",
|
|
672
|
+
attachments: "Attachments",
|
|
546
673
|
campaigns: "Campaigns",
|
|
674
|
+
contactGroups: "ContactGroups",
|
|
547
675
|
contacts: "Contacts",
|
|
548
676
|
conversations: "Conversations",
|
|
677
|
+
customFields: "CustomFields",
|
|
549
678
|
design: "Design",
|
|
550
679
|
email: "Email",
|
|
551
680
|
media: "Media",
|
|
@@ -554,6 +683,7 @@ const MODULE_NAMES = {
|
|
|
554
683
|
organizations: "Organizations",
|
|
555
684
|
scheduledMessages: "ScheduledMessages",
|
|
556
685
|
templates: "Templates",
|
|
686
|
+
unsubscribe: "UnsubscribeGroups",
|
|
557
687
|
webhooks: "Webhooks"
|
|
558
688
|
};
|
|
559
689
|
const traceName = (operationName) => {
|
|
@@ -592,16 +722,22 @@ const adapt = (operationName, rawCall, input) => {
|
|
|
592
722
|
params[path] = inputRecord[path];
|
|
593
723
|
}
|
|
594
724
|
if (pathDescriptor.kind === "path") return call({ params });
|
|
725
|
+
if (pathDescriptor.kind === "idempotentPath") return call({
|
|
726
|
+
params,
|
|
727
|
+
headers: { "idempotency-key": inputRecord.idempotencyKey }
|
|
728
|
+
});
|
|
595
729
|
const remainingInput = stripUndefined(Object.fromEntries(Object.entries(inputRecord).filter(([key]) => !pathDescriptor.paths.includes(key))));
|
|
596
730
|
return call({
|
|
597
731
|
params,
|
|
598
732
|
[pathDescriptor.kind === "pathParams" ? "query" : "payload"]: remainingInput
|
|
599
733
|
});
|
|
600
734
|
};
|
|
735
|
+
const isPageEnvelope = (value) => Predicate.isObject(value) && Array.isArray(value.items) && Predicate.isObject(value.pagination) && typeof value.pagination.page === "number" && typeof value.pagination.limit === "number" && typeof value.pagination.total === "number" && typeof value.pagination.totalPages === "number";
|
|
601
736
|
const make = (operationName) => {
|
|
602
|
-
const
|
|
737
|
+
const call = Effect.fn(traceName(operationName))((input) => Effect.flatMap(Service, (client) => adapt(operationName, rawOperation(client, operationName), input)));
|
|
738
|
+
const operation = call;
|
|
603
739
|
if (PAGINATED_OPERATIONS.has(operationName)) {
|
|
604
|
-
const list =
|
|
740
|
+
const list = (input) => Effect.filterOrElse(call(input), isPageEnvelope, () => Effect.die(/* @__PURE__ */ new Error(`${operationName} did not return a page envelope`)));
|
|
605
741
|
Object.assign(operation, {
|
|
606
742
|
pages: (input) => streamPages(list, input ?? {}),
|
|
607
743
|
items: (input) => streamItems(list, input ?? {})
|
|
@@ -638,4 +774,4 @@ const addEmailSender = Effect.fn("Email.addSender")(function* (input, options) {
|
|
|
638
774
|
//#endregion
|
|
639
775
|
export { sendMessage as i, make as n, sendEmail as r, addEmailSender as t };
|
|
640
776
|
|
|
641
|
-
//# sourceMappingURL=operation-
|
|
777
|
+
//# sourceMappingURL=operation-02YX3hY9.js.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export type SamvaApiErrorTag = "BillingProviderError" | "ConflictError" | "EmailChannelError" | "ExternalServiceError" | "FlagDisabledError" | "ForbiddenError" | "InternalError" | "PaymentRequiredError" | "RateLimitedError" | "ResourceNotFoundError" | "UnauthorizedError" | "ValidationError"
|
|
1
|
+
export type SamvaApiErrorTag = "AnalyticsQueryError" | "BillingProviderError" | "ConflictError" | "DeliveryUnavailableError" | "EmailChannelError" | "ExternalServiceError" | "FlagDisabledError" | "ForbiddenError" | "GatewayTimeoutError" | "InternalError" | "OnboardingReviewRequiredError" | "PaymentRequiredError" | "RateLimitedError" | "ResourceNotFoundError" | "UnauthorizedError" | "ValidationError";
|
|
2
2
|
export interface SamvaApiErrorContext {
|
|
3
3
|
readonly request?: Request | undefined;
|
|
4
4
|
readonly response?: Response | undefined;
|
|
@@ -20,40 +20,52 @@ export declare class SamvaTransportError extends Error {
|
|
|
20
20
|
readonly cause: unknown;
|
|
21
21
|
constructor(cause: unknown, context?: SamvaApiErrorContext);
|
|
22
22
|
}
|
|
23
|
+
type AnalyticsQueryErrorPayload = {
|
|
24
|
+
readonly _tag: "AnalyticsQueryError";
|
|
25
|
+
readonly message: string;
|
|
26
|
+
};
|
|
27
|
+
export declare class AnalyticsQueryError extends SamvaApiError<"AnalyticsQueryError"> {
|
|
28
|
+
readonly _tag: "AnalyticsQueryError";
|
|
29
|
+
constructor(payload: Omit<AnalyticsQueryErrorPayload, "_tag">, context?: SamvaApiErrorContext);
|
|
30
|
+
}
|
|
23
31
|
type BillingProviderErrorPayload = {
|
|
24
32
|
readonly _tag: "BillingProviderError";
|
|
25
33
|
readonly message: string;
|
|
26
|
-
readonly operation: string;
|
|
27
34
|
};
|
|
28
35
|
export declare class BillingProviderError extends SamvaApiError<"BillingProviderError"> {
|
|
29
36
|
readonly _tag: "BillingProviderError";
|
|
30
|
-
readonly "operation": string;
|
|
31
37
|
constructor(payload: Omit<BillingProviderErrorPayload, "_tag">, context?: SamvaApiErrorContext);
|
|
32
38
|
}
|
|
33
39
|
type ConflictErrorPayload = {
|
|
34
40
|
readonly _tag: "ConflictError";
|
|
35
41
|
readonly id?: string | null;
|
|
36
42
|
readonly message: string;
|
|
37
|
-
readonly operation: string;
|
|
38
43
|
readonly resource: string;
|
|
39
44
|
};
|
|
40
45
|
export declare class ConflictError extends SamvaApiError<"ConflictError"> {
|
|
41
46
|
readonly _tag: "ConflictError";
|
|
42
47
|
readonly "id"?: string | null;
|
|
43
|
-
readonly "operation": string;
|
|
44
48
|
readonly "resource": string;
|
|
45
49
|
constructor(payload: Omit<ConflictErrorPayload, "_tag">, context?: SamvaApiErrorContext);
|
|
46
50
|
}
|
|
51
|
+
type DeliveryUnavailableErrorPayload = {
|
|
52
|
+
readonly _tag: "DeliveryUnavailableError";
|
|
53
|
+
readonly message: string;
|
|
54
|
+
readonly retryAfterSeconds: number;
|
|
55
|
+
};
|
|
56
|
+
export declare class DeliveryUnavailableError extends SamvaApiError<"DeliveryUnavailableError"> {
|
|
57
|
+
readonly _tag: "DeliveryUnavailableError";
|
|
58
|
+
readonly "retryAfterSeconds": number;
|
|
59
|
+
constructor(payload: Omit<DeliveryUnavailableErrorPayload, "_tag">, context?: SamvaApiErrorContext);
|
|
60
|
+
}
|
|
47
61
|
type EmailChannelErrorPayload = {
|
|
48
62
|
readonly _tag: "EmailChannelError";
|
|
49
63
|
readonly message: string;
|
|
50
|
-
readonly operation: string;
|
|
51
64
|
readonly reason: "transport" | "rejected" | "rate_limited" | "auth";
|
|
52
65
|
readonly statusCode?: number | null;
|
|
53
66
|
};
|
|
54
67
|
export declare class EmailChannelError extends SamvaApiError<"EmailChannelError"> {
|
|
55
68
|
readonly _tag: "EmailChannelError";
|
|
56
|
-
readonly "operation": string;
|
|
57
69
|
readonly "reason": "transport" | "rejected" | "rate_limited" | "auth";
|
|
58
70
|
readonly "statusCode"?: number | null;
|
|
59
71
|
constructor(payload: Omit<EmailChannelErrorPayload, "_tag">, context?: SamvaApiErrorContext);
|
|
@@ -61,119 +73,115 @@ export declare class EmailChannelError extends SamvaApiError<"EmailChannelError"
|
|
|
61
73
|
type ExternalServiceErrorPayload = {
|
|
62
74
|
readonly _tag: "ExternalServiceError";
|
|
63
75
|
readonly message: string;
|
|
64
|
-
readonly operation: string;
|
|
65
76
|
};
|
|
66
77
|
export declare class ExternalServiceError extends SamvaApiError<"ExternalServiceError"> {
|
|
67
78
|
readonly _tag: "ExternalServiceError";
|
|
68
|
-
readonly "operation": string;
|
|
69
79
|
constructor(payload: Omit<ExternalServiceErrorPayload, "_tag">, context?: SamvaApiErrorContext);
|
|
70
80
|
}
|
|
71
81
|
type FlagDisabledErrorPayload = {
|
|
72
82
|
readonly _tag: "FlagDisabledError";
|
|
73
83
|
readonly flag: string;
|
|
74
|
-
readonly operation: string;
|
|
75
84
|
};
|
|
76
85
|
export declare class FlagDisabledError extends SamvaApiError<"FlagDisabledError"> {
|
|
77
86
|
readonly _tag: "FlagDisabledError";
|
|
78
87
|
readonly "flag": string;
|
|
79
|
-
readonly "operation": string;
|
|
80
88
|
constructor(payload: Omit<FlagDisabledErrorPayload, "_tag">, context?: SamvaApiErrorContext);
|
|
81
89
|
}
|
|
82
90
|
type ForbiddenErrorPayload = {
|
|
83
91
|
readonly _tag: "ForbiddenError";
|
|
84
92
|
readonly message: string;
|
|
85
|
-
readonly operation: string;
|
|
86
93
|
};
|
|
87
94
|
export declare class ForbiddenError extends SamvaApiError<"ForbiddenError"> {
|
|
88
95
|
readonly _tag: "ForbiddenError";
|
|
89
|
-
readonly "operation": string;
|
|
90
96
|
constructor(payload: Omit<ForbiddenErrorPayload, "_tag">, context?: SamvaApiErrorContext);
|
|
91
97
|
}
|
|
98
|
+
type GatewayTimeoutErrorPayload = {
|
|
99
|
+
readonly _tag: "GatewayTimeoutError";
|
|
100
|
+
readonly message: string;
|
|
101
|
+
readonly retryAfterSeconds: number;
|
|
102
|
+
};
|
|
103
|
+
export declare class GatewayTimeoutError extends SamvaApiError<"GatewayTimeoutError"> {
|
|
104
|
+
readonly _tag: "GatewayTimeoutError";
|
|
105
|
+
readonly "retryAfterSeconds": number;
|
|
106
|
+
constructor(payload: Omit<GatewayTimeoutErrorPayload, "_tag">, context?: SamvaApiErrorContext);
|
|
107
|
+
}
|
|
92
108
|
type InternalErrorPayload = {
|
|
93
109
|
readonly _tag: "InternalError";
|
|
94
110
|
readonly message: string;
|
|
95
|
-
readonly operation: string;
|
|
96
111
|
};
|
|
97
112
|
export declare class InternalError extends SamvaApiError<"InternalError"> {
|
|
98
113
|
readonly _tag: "InternalError";
|
|
99
|
-
readonly "operation": string;
|
|
100
114
|
constructor(payload: Omit<InternalErrorPayload, "_tag">, context?: SamvaApiErrorContext);
|
|
101
115
|
}
|
|
116
|
+
type OnboardingReviewRequiredErrorPayload = {
|
|
117
|
+
readonly _tag: "OnboardingReviewRequiredError";
|
|
118
|
+
readonly code: "review_required" | "review_in_progress" | "information_required" | "review_rejected" | "identity_review_required" | "identity_review_rejected" | "identity_changed";
|
|
119
|
+
readonly decision: "undecided" | "approved" | "rejected" | "exempt";
|
|
120
|
+
readonly identityId?: string | null;
|
|
121
|
+
readonly nextAction: "wait_for_review" | "provide_information" | "verify_sending_identity" | "reapply" | "contact_support";
|
|
122
|
+
readonly stage: "collecting" | "automated_review" | "manual_review" | "information_requested" | "complete";
|
|
123
|
+
};
|
|
124
|
+
export declare class OnboardingReviewRequiredError extends SamvaApiError<"OnboardingReviewRequiredError"> {
|
|
125
|
+
readonly _tag: "OnboardingReviewRequiredError";
|
|
126
|
+
readonly "code": "review_required" | "review_in_progress" | "information_required" | "review_rejected" | "identity_review_required" | "identity_review_rejected" | "identity_changed";
|
|
127
|
+
readonly "decision": "undecided" | "approved" | "rejected" | "exempt";
|
|
128
|
+
readonly "identityId"?: string | null;
|
|
129
|
+
readonly "nextAction": "wait_for_review" | "provide_information" | "verify_sending_identity" | "reapply" | "contact_support";
|
|
130
|
+
readonly "stage": "collecting" | "automated_review" | "manual_review" | "information_requested" | "complete";
|
|
131
|
+
constructor(payload: Omit<OnboardingReviewRequiredErrorPayload, "_tag">, context?: SamvaApiErrorContext);
|
|
132
|
+
}
|
|
102
133
|
type PaymentRequiredErrorPayload = {
|
|
103
134
|
readonly _tag: "PaymentRequiredError";
|
|
104
135
|
readonly currentUsage: number;
|
|
105
136
|
readonly limit: number;
|
|
106
|
-
readonly operation: string;
|
|
107
137
|
readonly resource: string;
|
|
108
138
|
};
|
|
109
139
|
export declare class PaymentRequiredError extends SamvaApiError<"PaymentRequiredError"> {
|
|
110
140
|
readonly _tag: "PaymentRequiredError";
|
|
111
141
|
readonly "currentUsage": number;
|
|
112
142
|
readonly "limit": number;
|
|
113
|
-
readonly "operation": string;
|
|
114
143
|
readonly "resource": string;
|
|
115
144
|
constructor(payload: Omit<PaymentRequiredErrorPayload, "_tag">, context?: SamvaApiErrorContext);
|
|
116
145
|
}
|
|
117
146
|
type RateLimitedErrorPayload = {
|
|
118
147
|
readonly _tag: "RateLimitedError";
|
|
119
|
-
readonly operation: string;
|
|
120
148
|
readonly retryAfterSeconds: number;
|
|
121
149
|
};
|
|
122
150
|
export declare class RateLimitedError extends SamvaApiError<"RateLimitedError"> {
|
|
123
151
|
readonly _tag: "RateLimitedError";
|
|
124
|
-
readonly "operation": string;
|
|
125
152
|
readonly "retryAfterSeconds": number;
|
|
126
153
|
constructor(payload: Omit<RateLimitedErrorPayload, "_tag">, context?: SamvaApiErrorContext);
|
|
127
154
|
}
|
|
128
155
|
type ResourceNotFoundErrorPayload = {
|
|
129
156
|
readonly _tag: "ResourceNotFoundError";
|
|
130
157
|
readonly id: string;
|
|
131
|
-
readonly operation: string;
|
|
132
158
|
readonly resource: string;
|
|
133
159
|
};
|
|
134
160
|
export declare class ResourceNotFoundError extends SamvaApiError<"ResourceNotFoundError"> {
|
|
135
161
|
readonly _tag: "ResourceNotFoundError";
|
|
136
162
|
readonly "id": string;
|
|
137
|
-
readonly "operation": string;
|
|
138
163
|
readonly "resource": string;
|
|
139
164
|
constructor(payload: Omit<ResourceNotFoundErrorPayload, "_tag">, context?: SamvaApiErrorContext);
|
|
140
165
|
}
|
|
141
166
|
type UnauthorizedErrorPayload = {
|
|
142
167
|
readonly _tag: "UnauthorizedError";
|
|
143
168
|
readonly message: string;
|
|
144
|
-
readonly operation: string;
|
|
145
169
|
};
|
|
146
170
|
export declare class UnauthorizedError extends SamvaApiError<"UnauthorizedError"> {
|
|
147
171
|
readonly _tag: "UnauthorizedError";
|
|
148
|
-
readonly "operation": string;
|
|
149
172
|
constructor(payload: Omit<UnauthorizedErrorPayload, "_tag">, context?: SamvaApiErrorContext);
|
|
150
173
|
}
|
|
151
174
|
type ValidationErrorPayload = {
|
|
152
175
|
readonly _tag: "ValidationError";
|
|
153
176
|
readonly fields?: Record<string, Array<string>> | null;
|
|
154
177
|
readonly message: string;
|
|
155
|
-
readonly operation: string;
|
|
156
178
|
};
|
|
157
179
|
export declare class ValidationError extends SamvaApiError<"ValidationError"> {
|
|
158
180
|
readonly _tag: "ValidationError";
|
|
159
181
|
readonly "fields"?: Record<string, Array<string>> | null;
|
|
160
|
-
readonly "operation": string;
|
|
161
182
|
constructor(payload: Omit<ValidationErrorPayload, "_tag">, context?: SamvaApiErrorContext);
|
|
162
183
|
}
|
|
163
|
-
type
|
|
164
|
-
readonly _tag: "WebhookEnqueueError";
|
|
165
|
-
readonly details?: string | null;
|
|
166
|
-
readonly operation: string;
|
|
167
|
-
readonly reason: string;
|
|
168
|
-
};
|
|
169
|
-
export declare class WebhookEnqueueError extends SamvaApiError<"WebhookEnqueueError"> {
|
|
170
|
-
readonly _tag: "WebhookEnqueueError";
|
|
171
|
-
readonly "details"?: string | null;
|
|
172
|
-
readonly "operation": string;
|
|
173
|
-
readonly "reason": string;
|
|
174
|
-
constructor(payload: Omit<WebhookEnqueueErrorPayload, "_tag">, context?: SamvaApiErrorContext);
|
|
175
|
-
}
|
|
176
|
-
export type AnySamvaApiError = BillingProviderError | ConflictError | EmailChannelError | ExternalServiceError | FlagDisabledError | ForbiddenError | InternalError | PaymentRequiredError | RateLimitedError | ResourceNotFoundError | UnauthorizedError | ValidationError | WebhookEnqueueError;
|
|
184
|
+
export type AnySamvaApiError = AnalyticsQueryError | BillingProviderError | ConflictError | DeliveryUnavailableError | EmailChannelError | ExternalServiceError | FlagDisabledError | ForbiddenError | GatewayTimeoutError | InternalError | OnboardingReviewRequiredError | PaymentRequiredError | RateLimitedError | ResourceNotFoundError | UnauthorizedError | ValidationError;
|
|
177
185
|
/** Convert a decoded error payload into its generated JavaScript error class. */
|
|
178
186
|
export declare function fromApiError(error: unknown, context?: SamvaApiErrorContext): AnySamvaApiError | SamvaTransportError;
|
|
179
187
|
export {};
|
package/dist/promises/index.d.ts
CHANGED
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
* ```
|
|
28
28
|
*/
|
|
29
29
|
import { type Client, type Config } from "../client/client";
|
|
30
|
-
import { ApiKeys as apiKeys, Campaigns as campaigns, Contacts as contacts, Conversations as conversations, Design as design, Email as email, Media as media, Messages as messages, Operations as operations, Organizations as organizations, ScheduledMessages as scheduledMessages, Templates as templates, Webhooks as webhooks } from "../client/sdk.gen";
|
|
30
|
+
import { Analytics as analytics, ApiKeys as apiKeys, Attachments as attachments, Campaigns as campaigns, ContactGroups as contactGroups, Contacts as contacts, Conversations as conversations, CustomFields as customFields, Design as design, Email as email, Media as media, Messages as messages, Operations as operations, Organizations as organizations, ScheduledMessages as scheduledMessages, Templates as templates, Unsubscribe as unsubscribeGroups, Webhooks as webhooks } from "../client/sdk.gen";
|
|
31
31
|
import type { MessagesSendData } from "../client/types.gen";
|
|
32
32
|
export * from "./errors.gen";
|
|
33
33
|
export type * from "./types.gen";
|
|
@@ -47,6 +47,10 @@ export type SamvaClientConfig = (SamvaClientConfigBase & {
|
|
|
47
47
|
type MessageSendBody = MessagesSendData["body"];
|
|
48
48
|
type MessageRecipient = MessageSendBody["to"][number];
|
|
49
49
|
type MessageSendRequestOptions<ThrowOnError extends boolean = false> = Omit<NonNullable<Parameters<typeof messages.send<ThrowOnError>>[1]>, "client">;
|
|
50
|
+
type MessageSendOptions<ThrowOnError extends boolean = false> = MessageSendRequestOptions<ThrowOnError> & {
|
|
51
|
+
/** Sent as the `idempotency-key` header; defaults to a fresh UUID per call. */
|
|
52
|
+
readonly idempotencyKey?: string | undefined;
|
|
53
|
+
};
|
|
50
54
|
type MessageSendResponse<ThrowOnError extends boolean = false> = ReturnType<typeof messages.send<ThrowOnError>>;
|
|
51
55
|
type ContactObjectRecipient = {
|
|
52
56
|
readonly id: string;
|
|
@@ -82,7 +86,8 @@ type PromiseMessagesTransport = {
|
|
|
82
86
|
readonly getEmail: typeof messages.getEmail;
|
|
83
87
|
readonly getStatus: typeof messages.getStatus;
|
|
84
88
|
readonly getEvents: typeof messages.getEvents;
|
|
85
|
-
readonly
|
|
89
|
+
readonly validateEmail: typeof messages.validateEmail;
|
|
90
|
+
readonly send: <ThrowOnError extends boolean = false>(input: ErgonomicMessageSendInput, options?: MessageSendOptions<ThrowOnError>) => MessageSendResponse<ThrowOnError>;
|
|
86
91
|
};
|
|
87
92
|
type ErgonomicEmailSendBody = Omit<EmailMessageSendBody, "channel" | "email" | "to" | "cc" | "bcc"> & ErgonomicEmailContent & {
|
|
88
93
|
readonly to: ErgonomicMessageRecipient | ReadonlyArray<ErgonomicMessageRecipient>;
|
|
@@ -90,11 +95,11 @@ type ErgonomicEmailSendBody = Omit<EmailMessageSendBody, "channel" | "email" | "
|
|
|
90
95
|
readonly bcc?: ErgonomicMessageRecipient | ReadonlyArray<ErgonomicMessageRecipient>;
|
|
91
96
|
};
|
|
92
97
|
type PromiseEmailTransport = Omit<typeof email, "send"> & {
|
|
93
|
-
readonly send: <ThrowOnError extends boolean = false>(input: ErgonomicEmailSendBody, options?:
|
|
98
|
+
readonly send: <ThrowOnError extends boolean = false>(input: ErgonomicEmailSendBody, options?: MessageSendOptions<ThrowOnError>) => MessageSendResponse<ThrowOnError>;
|
|
94
99
|
readonly addSender: <ThrowOnError extends boolean = false>(input: ErgonomicEmailAddSenderInput, options?: EmailAddSenderOptions<ThrowOnError>) => ReturnType<typeof email.addSender<ThrowOnError>>;
|
|
95
100
|
};
|
|
96
101
|
type PromiseTemplatesTransport = typeof templates;
|
|
97
|
-
type RawMethod = (...arguments_: Array<
|
|
102
|
+
type RawMethod = (...arguments_: Array<never>) => PromiseLike<unknown>;
|
|
98
103
|
type SuccessValue<Method extends RawMethod> = Exclude<Awaited<ReturnType<Method>> extends infer Result ? Result extends {
|
|
99
104
|
readonly data: infer Data;
|
|
100
105
|
} ? Data : never : never, undefined>;
|
|
@@ -122,6 +127,11 @@ export interface SamvaRawClient {
|
|
|
122
127
|
readonly operations: typeof operations;
|
|
123
128
|
readonly apiKeys: typeof apiKeys;
|
|
124
129
|
readonly organizations: typeof organizations;
|
|
130
|
+
readonly attachments: typeof attachments;
|
|
131
|
+
readonly contactGroups: typeof contactGroups;
|
|
132
|
+
readonly customFields: typeof customFields;
|
|
133
|
+
readonly unsubscribeGroups: typeof unsubscribeGroups;
|
|
134
|
+
readonly analytics: typeof analytics;
|
|
125
135
|
}
|
|
126
136
|
export interface SamvaClient {
|
|
127
137
|
/** Bound, unmodified Hey API methods and their original result envelopes. */
|
|
@@ -139,6 +149,11 @@ export interface SamvaClient {
|
|
|
139
149
|
readonly operations: DirectService<typeof operations>;
|
|
140
150
|
readonly apiKeys: DirectService<typeof apiKeys>;
|
|
141
151
|
readonly organizations: DirectService<typeof organizations>;
|
|
152
|
+
readonly attachments: DirectService<typeof attachments>;
|
|
153
|
+
readonly contactGroups: DirectService<typeof contactGroups>;
|
|
154
|
+
readonly customFields: DirectService<typeof customFields>;
|
|
155
|
+
readonly unsubscribeGroups: DirectService<typeof unsubscribeGroups>;
|
|
156
|
+
readonly analytics: DirectService<typeof analytics>;
|
|
142
157
|
}
|
|
143
158
|
/** Create a configured Promise client. */
|
|
144
159
|
export declare function createClient(config: SamvaClientConfig): SamvaClient;
|
package/dist/promises/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { _ as
|
|
2
|
-
export { BillingProviderError, ConflictError, EmailChannelError, ExternalServiceError, FlagDisabledError, ForbiddenError, InternalError, PaymentRequiredError, RateLimitedError, ResourceNotFoundError, SamvaApiError, SamvaTransportError, UnauthorizedError, ValidationError,
|
|
1
|
+
import { _ as SamvaTransportError, a as DeliveryUnavailableError, b as fromApiError, c as FlagDisabledError, d as InternalError, f as OnboardingReviewRequiredError, g as SamvaApiError, h as ResourceNotFoundError, i as ConflictError, l as ForbiddenError, m as RateLimitedError, n as AnalyticsQueryError, o as EmailChannelError, p as PaymentRequiredError, r as BillingProviderError, s as ExternalServiceError, t as createClient, u as GatewayTimeoutError, v as UnauthorizedError, y as ValidationError } from "../promises-8MaPNAam.js";
|
|
2
|
+
export { AnalyticsQueryError, BillingProviderError, ConflictError, DeliveryUnavailableError, EmailChannelError, ExternalServiceError, FlagDisabledError, ForbiddenError, GatewayTimeoutError, InternalError, OnboardingReviewRequiredError, PaymentRequiredError, RateLimitedError, ResourceNotFoundError, SamvaApiError, SamvaTransportError, UnauthorizedError, ValidationError, createClient, fromApiError };
|