samva 0.0.1 → 0.2.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.
Files changed (79) hide show
  1. package/AGENTS.md +13 -0
  2. package/LICENSE +21 -0
  3. package/README.md +392 -5
  4. package/dist/categories-CsUa8ojo.js +143 -0
  5. package/dist/client/client/client.gen.d.ts +2 -0
  6. package/dist/client/client/index.d.ts +10 -0
  7. package/dist/client/client/types.gen.d.ts +120 -0
  8. package/dist/client/client/utils.gen.d.ts +37 -0
  9. package/dist/client/client.gen.d.ts +12 -0
  10. package/dist/client/core/auth.gen.d.ts +25 -0
  11. package/dist/client/core/bodySerializer.gen.d.ts +25 -0
  12. package/dist/client/core/params.gen.d.ts +43 -0
  13. package/dist/client/core/pathSerializer.gen.d.ts +33 -0
  14. package/dist/client/core/queryKeySerializer.gen.d.ts +18 -0
  15. package/dist/client/core/serverSentEvents.gen.d.ts +71 -0
  16. package/dist/client/core/types.gen.d.ts +83 -0
  17. package/dist/client/core/utils.gen.d.ts +19 -0
  18. package/dist/client/sdk.gen.d.ts +1558 -0
  19. package/dist/client/types.gen.d.ts +7917 -0
  20. package/dist/client-BqkU-sFv.js +6049 -0
  21. package/dist/effect/api-keys.d.ts +190 -0
  22. package/dist/effect/api-keys.js +27 -0
  23. package/dist/effect/campaigns.d.ts +2055 -0
  24. package/dist/effect/campaigns.js +33 -0
  25. package/dist/effect/categories.d.ts +65 -0
  26. package/dist/effect/categories.js +2 -0
  27. package/dist/effect/client.d.ts +9 -0
  28. package/dist/effect/client.js +13 -0
  29. package/dist/effect/contacts.d.ts +1278 -0
  30. package/dist/effect/contacts.js +39 -0
  31. package/dist/effect/conversations.d.ts +1604 -0
  32. package/dist/effect/conversations.js +23 -0
  33. package/dist/effect/design.d.ts +209 -0
  34. package/dist/effect/design.js +13 -0
  35. package/dist/effect/email.d.ts +1022 -0
  36. package/dist/effect/email.js +111 -0
  37. package/dist/effect/generated-metadata.d.ts +54 -0
  38. package/dist/effect/generated.d.ts +32156 -0
  39. package/dist/effect/index.d.ts +36 -0
  40. package/dist/effect/index.js +17 -0
  41. package/dist/effect/internal/client.d.ts +35 -0
  42. package/dist/effect/internal/operation.d.ts +466 -0
  43. package/dist/effect/messages.d.ts +1047 -0
  44. package/dist/effect/messages.js +23 -0
  45. package/dist/effect/operations.d.ts +97 -0
  46. package/dist/effect/operations.js +15 -0
  47. package/dist/effect/organizations.d.ts +559 -0
  48. package/dist/effect/organizations.js +21 -0
  49. package/dist/effect/pagination.d.ts +37 -0
  50. package/dist/effect/retry.d.ts +60 -0
  51. package/dist/effect/retry.js +112 -0
  52. package/dist/effect/runtime.d.ts +7 -0
  53. package/dist/effect/scheduled-messages.d.ts +1009 -0
  54. package/dist/effect/scheduled-messages.js +17 -0
  55. package/dist/effect/templates.d.ts +2591 -0
  56. package/dist/effect/templates.js +66 -0
  57. package/dist/effect/webhooks.d.ts +228 -0
  58. package/dist/effect/webhooks.js +33 -0
  59. package/dist/index.d.ts +1 -0
  60. package/dist/index.js +2 -0
  61. package/dist/normalize-LkWl4HUF.js +82 -0
  62. package/dist/normalize.d.ts +87 -0
  63. package/dist/operation-Ccqh_yxb.js +596 -0
  64. package/dist/promises/errors.gen.d.ts +179 -0
  65. package/dist/promises/index.d.ts +153 -0
  66. package/dist/promises/index.js +2 -0
  67. package/dist/promises/types.gen.d.ts +1 -0
  68. package/dist/promises-Dgv8UmCC.js +5911 -0
  69. package/dist/rolldown-runtime-D7D4PA-g.js +13 -0
  70. package/dist/service-map.d.ts +732 -0
  71. package/dist/webhooks/effect.d.ts +1 -0
  72. package/dist/webhooks/effect.js +1 -0
  73. package/dist/webhooks/promise.d.ts +1 -0
  74. package/dist/webhooks/promise.js +1 -0
  75. package/package.json +151 -4
  76. package/CLAUDE.md +0 -111
  77. package/bun.lock +0 -29
  78. package/index.ts +0 -1
  79. package/tsconfig.json +0 -29
@@ -0,0 +1,596 @@
1
+ import { n as buildMessagesSendPayload, r as replyToEmailsPayload, t as buildEmailSendPayload } from "./normalize-LkWl4HUF.js";
2
+ import { _ as SamvaApi, t as Service } from "./client-BqkU-sFv.js";
3
+ import { generateIdempotencyKey, withRetry } from "./effect/retry.js";
4
+ import { Effect, Option, Predicate, Stream } from "effect";
5
+ //#region src/service-map.ts
6
+ /** How each generated Effect operation is adapted to the Promise facade's direct input shape. */
7
+ const SDK_OPERATION_CALLS = {
8
+ designGet: { kind: "none" },
9
+ designUpdate: { kind: "payload" },
10
+ operationsList: { kind: "params" },
11
+ operationsGet: {
12
+ kind: "path",
13
+ paths: ["operationId"]
14
+ },
15
+ operationsRetry: {
16
+ kind: "path",
17
+ paths: ["operationId"]
18
+ },
19
+ messagesList: { kind: "params" },
20
+ messagesSend: { kind: "payload" },
21
+ messagesGet: {
22
+ kind: "path",
23
+ paths: ["id"]
24
+ },
25
+ messagesGetEmail: {
26
+ kind: "pathParams",
27
+ paths: ["id"]
28
+ },
29
+ messagesRemove: {
30
+ kind: "path",
31
+ paths: ["id"]
32
+ },
33
+ messagesGetStatus: {
34
+ kind: "path",
35
+ paths: ["id"]
36
+ },
37
+ messagesGetEvents: {
38
+ kind: "path",
39
+ paths: ["id"]
40
+ },
41
+ scheduledMessagesList: { kind: "params" },
42
+ scheduledMessagesCreate: { kind: "payload" },
43
+ scheduledMessagesGet: {
44
+ kind: "path",
45
+ paths: ["id"]
46
+ },
47
+ scheduledMessagesCancel: {
48
+ kind: "path",
49
+ paths: ["id"]
50
+ },
51
+ campaignsList: { kind: "params" },
52
+ campaignsCreate: { kind: "payload" },
53
+ campaignsGet: {
54
+ kind: "path",
55
+ paths: ["id"]
56
+ },
57
+ campaignsArchive: {
58
+ kind: "path",
59
+ paths: ["id"]
60
+ },
61
+ campaignsUpdate: {
62
+ kind: "pathPayload",
63
+ paths: ["id"]
64
+ },
65
+ campaignsListRuns: {
66
+ kind: "pathParams",
67
+ paths: ["id"]
68
+ },
69
+ campaignsScheduleRun: {
70
+ kind: "pathPayload",
71
+ paths: ["id"]
72
+ },
73
+ campaignsGetRun: {
74
+ kind: "path",
75
+ paths: ["id", "runId"]
76
+ },
77
+ campaignsPauseRun: {
78
+ kind: "path",
79
+ paths: ["id", "runId"]
80
+ },
81
+ campaignsResumeRun: {
82
+ kind: "path",
83
+ paths: ["id", "runId"]
84
+ },
85
+ campaignsCancelRun: {
86
+ kind: "path",
87
+ paths: ["id", "runId"]
88
+ },
89
+ campaignsListRecipients: {
90
+ kind: "pathParams",
91
+ paths: ["id", "runId"]
92
+ },
93
+ emailListDomains: { kind: "params" },
94
+ emailGetTrackingDefaults: { kind: "none" },
95
+ emailUpdateTrackingDefaults: { kind: "payload" },
96
+ emailGetRecipientTrackingPreference: { kind: "params" },
97
+ emailUpdateRecipientTrackingPreference: { kind: "payload" },
98
+ emailAddDomain: { kind: "payload" },
99
+ emailGetDomainVerification: {
100
+ kind: "path",
101
+ paths: ["id"]
102
+ },
103
+ emailAdvanceDomainVerification: {
104
+ kind: "path",
105
+ paths: ["id"]
106
+ },
107
+ emailGetDomainById: {
108
+ kind: "path",
109
+ paths: ["id"]
110
+ },
111
+ emailRemoveDomain: {
112
+ kind: "path",
113
+ paths: ["id"]
114
+ },
115
+ emailSetDefaultDomain: {
116
+ kind: "path",
117
+ paths: ["id"]
118
+ },
119
+ emailSetDomainDefaultSender: {
120
+ kind: "pathPayload",
121
+ paths: ["id"]
122
+ },
123
+ emailClearDomainDefaultSender: {
124
+ kind: "path",
125
+ paths: ["id"]
126
+ },
127
+ emailUpdateDomainConfig: {
128
+ kind: "pathPayload",
129
+ paths: ["id"]
130
+ },
131
+ emailDetectRegistrar: {
132
+ kind: "pathPayload",
133
+ paths: ["id"]
134
+ },
135
+ emailGetDomainConnect: {
136
+ kind: "path",
137
+ paths: ["id"]
138
+ },
139
+ emailBuildDomainConnectApplyUrl: {
140
+ kind: "pathPayload",
141
+ paths: ["id"]
142
+ },
143
+ emailCompleteDomainConnect: {
144
+ kind: "pathPayload",
145
+ paths: ["id"]
146
+ },
147
+ emailEnableReceiving: {
148
+ kind: "pathPayload",
149
+ paths: ["id"]
150
+ },
151
+ emailEnableCustomTracking: {
152
+ kind: "pathPayload",
153
+ paths: ["id"]
154
+ },
155
+ emailGetCustomTracking: {
156
+ kind: "path",
157
+ paths: ["id"]
158
+ },
159
+ emailGetCustomTrackingDomainConnect: {
160
+ kind: "path",
161
+ paths: ["id"]
162
+ },
163
+ emailBuildCustomTrackingDomainConnectApplyUrl: {
164
+ kind: "path",
165
+ paths: ["id"]
166
+ },
167
+ emailCompleteCustomTrackingDomainConnect: {
168
+ kind: "pathPayload",
169
+ paths: ["id"]
170
+ },
171
+ emailDisableCustomTracking: {
172
+ kind: "path",
173
+ paths: ["id"]
174
+ },
175
+ emailListSenders: { kind: "params" },
176
+ emailAddSender: { kind: "payload" },
177
+ emailCheckSenderVerification: {
178
+ kind: "path",
179
+ paths: ["id"]
180
+ },
181
+ emailRemoveSender: {
182
+ kind: "path",
183
+ paths: ["id"]
184
+ },
185
+ emailSetDefaultSender: {
186
+ kind: "path",
187
+ paths: ["id"]
188
+ },
189
+ emailGetStats: { kind: "params" },
190
+ emailEnableCatchAll: { kind: "payload" },
191
+ emailDisableCatchAll: { kind: "payload" },
192
+ emailGetCatchAllConfig: { kind: "params" },
193
+ emailUpdateCatchAllConfig: { kind: "payload" },
194
+ emailGetCatchAllStats: { kind: "params" },
195
+ emailListSuppressions: { kind: "params" },
196
+ emailRemoveSuppression: {
197
+ kind: "path",
198
+ paths: ["id"]
199
+ },
200
+ emailListBlocks: { kind: "params" },
201
+ emailAddBlock: { kind: "payload" },
202
+ emailRemoveBlock: {
203
+ kind: "path",
204
+ paths: ["id"]
205
+ },
206
+ emailUpdateBlock: {
207
+ kind: "pathPayload",
208
+ paths: ["id"]
209
+ },
210
+ emailGetBlockLogs: { kind: "params" },
211
+ emailCheckBlocked: { kind: "payload" },
212
+ emailListForwardingRules: { kind: "params" },
213
+ emailCreateForwardingRule: { kind: "payload" },
214
+ emailDeleteForwardingRule: {
215
+ kind: "path",
216
+ paths: ["id"]
217
+ },
218
+ emailUpdateForwardingRule: {
219
+ kind: "pathPayload",
220
+ paths: ["id"]
221
+ },
222
+ emailGetForwardingLog: { kind: "params" },
223
+ conversationsList: { kind: "params" },
224
+ conversationsCreate: { kind: "payload" },
225
+ conversationsGetById: {
226
+ kind: "path",
227
+ paths: ["id"]
228
+ },
229
+ conversationsListMessages: {
230
+ kind: "pathParams",
231
+ paths: ["id"]
232
+ },
233
+ conversationsUpdate: {
234
+ kind: "pathPayload",
235
+ paths: ["id"]
236
+ },
237
+ conversationsAddContacts: {
238
+ kind: "pathPayload",
239
+ paths: ["id"]
240
+ },
241
+ conversationsRemoveContacts: {
242
+ kind: "pathPayload",
243
+ paths: ["id"]
244
+ },
245
+ contactsList: { kind: "params" },
246
+ contactsCreate: { kind: "payload" },
247
+ contactsFind: { kind: "payload" },
248
+ contactsFindOrCreate: { kind: "payload" },
249
+ contactsGet: {
250
+ kind: "path",
251
+ paths: ["id"]
252
+ },
253
+ contactsRemove: {
254
+ kind: "path",
255
+ paths: ["id"]
256
+ },
257
+ contactsUpdate: {
258
+ kind: "pathPayload",
259
+ paths: ["id"]
260
+ },
261
+ contactsGetEngagement: {
262
+ kind: "path",
263
+ paths: ["id"]
264
+ },
265
+ contactsBulkImport: { kind: "payload" },
266
+ contactsBulkDelete: { kind: "payload" },
267
+ contactsBulkUpdateTags: { kind: "payload" },
268
+ contactsBulkUpdateStatus: { kind: "payload" },
269
+ contactsExport: { kind: "payload" },
270
+ contactsGetActivityTimeline: {
271
+ kind: "pathParams",
272
+ paths: ["id"]
273
+ },
274
+ contactsGetGroupMemberships: {
275
+ kind: "path",
276
+ paths: ["id"]
277
+ },
278
+ templatesList: { kind: "params" },
279
+ templatesCreate: { kind: "payload" },
280
+ templatesListDashboard: { kind: "params" },
281
+ templatesListFamilies: { kind: "params" },
282
+ templatesCreateFamily: { kind: "payload" },
283
+ templatesGetFamily: {
284
+ kind: "path",
285
+ paths: ["familyId"]
286
+ },
287
+ templatesDeleteFamily: {
288
+ kind: "path",
289
+ paths: ["familyId"]
290
+ },
291
+ templatesRenameFamily: {
292
+ kind: "pathPayload",
293
+ paths: ["familyId"]
294
+ },
295
+ templatesCreateFamilyFromTemplate: {
296
+ kind: "pathPayload",
297
+ paths: ["templateId"]
298
+ },
299
+ templatesAttachFamilyMember: {
300
+ kind: "path",
301
+ paths: ["familyId", "templateId"]
302
+ },
303
+ templatesDetachFamilyMember: {
304
+ kind: "path",
305
+ paths: ["familyId", "templateId"]
306
+ },
307
+ templatesAddFamilyChannel: {
308
+ kind: "path",
309
+ paths: ["familyId", "channel"]
310
+ },
311
+ templatesGetById: {
312
+ kind: "path",
313
+ paths: ["id"]
314
+ },
315
+ templatesRemove: {
316
+ kind: "path",
317
+ paths: ["id"]
318
+ },
319
+ templatesUpdate: {
320
+ kind: "pathPayload",
321
+ paths: ["id"]
322
+ },
323
+ templatesApprove: {
324
+ kind: "pathPayload",
325
+ paths: ["id"]
326
+ },
327
+ templateDocumentsBootstrap: { kind: "payload" },
328
+ templateDocumentsGet: {
329
+ kind: "path",
330
+ paths: ["templateId"]
331
+ },
332
+ templateDocumentsReplace: {
333
+ kind: "pathPayload",
334
+ paths: ["templateId"]
335
+ },
336
+ templateDocumentsSave: {
337
+ kind: "pathPayload",
338
+ paths: ["templateId"]
339
+ },
340
+ templateDocumentsRender: {
341
+ kind: "pathPayload",
342
+ paths: ["templateId"]
343
+ },
344
+ templateDocumentsSpamCheck: {
345
+ kind: "pathPayload",
346
+ paths: ["templateId"]
347
+ },
348
+ templateDocumentsTestSend: {
349
+ kind: "pathPayload",
350
+ paths: ["templateId"]
351
+ },
352
+ templateDocumentsVersions: {
353
+ kind: "path",
354
+ paths: ["templateId"]
355
+ },
356
+ templateDocumentsPublish: {
357
+ kind: "path",
358
+ paths: ["templateId"]
359
+ },
360
+ templateDocumentsUnpublish: {
361
+ kind: "path",
362
+ paths: ["templateId"]
363
+ },
364
+ templateDocumentsRestore: {
365
+ kind: "pathPayload",
366
+ paths: ["templateId", "versionId"]
367
+ },
368
+ webhooksList: { kind: "params" },
369
+ webhooksCreate: { kind: "payload" },
370
+ webhooksGet: {
371
+ kind: "path",
372
+ paths: ["id"]
373
+ },
374
+ webhooksRemove: {
375
+ kind: "path",
376
+ paths: ["id"]
377
+ },
378
+ webhooksUpdate: {
379
+ kind: "pathPayload",
380
+ paths: ["id"]
381
+ },
382
+ webhooksTest: {
383
+ kind: "pathPayload",
384
+ paths: ["id"]
385
+ },
386
+ webhooksGetLogs: {
387
+ kind: "pathParams",
388
+ paths: ["webhookId"]
389
+ },
390
+ webhooksGetStats: {
391
+ kind: "pathParams",
392
+ paths: ["webhookId"]
393
+ },
394
+ webhooksRetryDelivery: {
395
+ kind: "pathPayload",
396
+ paths: ["webhookId"]
397
+ },
398
+ webhooksRegenerateSecret: {
399
+ kind: "path",
400
+ paths: ["webhookId"]
401
+ },
402
+ organizationsBootstrap: { kind: "payload" },
403
+ organizationsCreate: { kind: "payload" },
404
+ organizationsGet: { kind: "none" },
405
+ organizationsUpdate: { kind: "payload" },
406
+ organizationsGetUsage: { kind: "params" },
407
+ organizationsDelete: { kind: "idempotentPayload" },
408
+ apiKeysList: { kind: "params" },
409
+ apiKeysCreate: { kind: "payload" },
410
+ apiKeysGet: {
411
+ kind: "path",
412
+ paths: ["id"]
413
+ },
414
+ apiKeysRevoke: {
415
+ kind: "path",
416
+ paths: ["id"]
417
+ },
418
+ apiKeysUpdate: {
419
+ kind: "pathPayload",
420
+ paths: ["id"]
421
+ },
422
+ apiKeysRotate: {
423
+ kind: "path",
424
+ paths: ["id"]
425
+ },
426
+ apiKeysRemove: {
427
+ kind: "path",
428
+ paths: ["id"]
429
+ },
430
+ apiKeysGetStats: {
431
+ kind: "pathParams",
432
+ paths: ["id"]
433
+ },
434
+ apiKeysGetActivity: {
435
+ kind: "pathParams",
436
+ paths: ["id"]
437
+ }
438
+ };
439
+ //#endregion
440
+ //#region src/effect/pagination.ts
441
+ /**
442
+ * Stream pagination for the Effect SDK.
443
+ *
444
+ * Every list operation whose success value is the uniform page envelope —
445
+ * `{ items, pagination: { page, limit, total, totalPages } }` — gains `.pages()`
446
+ * and `.items()` companions on its domain operation. `.pages()`
447
+ * streams the raw envelopes; `.items()` flattens them into a stream of items.
448
+ *
449
+ * The traversal is **lazy**: built on `Stream.paginate` (a pull-based source),
450
+ * so each page is fetched only as the stream is consumed — `Stream.take(n)`
451
+ * stops requesting further pages. Caller params (start `page`, `limit`, filters)
452
+ * are respected; only `page` is advanced per step, and the walk stops once the
453
+ * server-echoed `page` reaches `totalPages`.
454
+ *
455
+ * Retry is **not** re-applied here: the underlying domain operation is already
456
+ * wrapped in the ambient {@link import("./retry").Service} policy (reads are
457
+ * retry-safe), so each page fetch retries on its own and pagination composes
458
+ * with retry instead of nesting retries.
459
+ */
460
+ /** The next page number, or `none` once the last page has been yielded. */
461
+ const nextPage = (pagination) => pagination.page < pagination.totalPages ? Option.some(pagination.page + 1) : Option.none();
462
+ /** Honor a caller-supplied start `page`; default to the first page otherwise. */
463
+ const startPageOf = (input) => {
464
+ const page = input?.page;
465
+ const parsed = typeof page === "string" ? Number(page) : NaN;
466
+ return Number.isFinite(parsed) && parsed >= 1 ? parsed : 1;
467
+ };
468
+ /** Fetch one page at `page`, preserving all other caller params. */
469
+ const fetchPage = (operation, input, page) => operation({
470
+ ...input,
471
+ page: page.toString()
472
+ });
473
+ /** Stream the raw page envelopes, one per request, from the caller's start page. */
474
+ const streamPages = (operation, input) => Stream.paginate(startPageOf(input), (page) => fetchPage(operation, input, page).pipe(Effect.map((result) => [[result], nextPage(result.pagination)])));
475
+ /** Stream individual items across pages, fetching the next page only when pulled. */
476
+ const streamItems = (operation, input) => Stream.paginate(startPageOf(input), (page) => fetchPage(operation, input, page).pipe(Effect.map((result) => [result.items, nextPage(result.pagination)])));
477
+ //#endregion
478
+ //#region src/effect/internal/operation.ts
479
+ const hasField = (node, name) => node?.propertySignatures?.some((property) => property.name === name) ?? false;
480
+ const isPaginatedSuccess = (success) => {
481
+ if (!(success instanceof Set)) return false;
482
+ for (const schema of success) for (const node of [
483
+ schema.ast,
484
+ schema.ast?.to,
485
+ schema.ast?.from
486
+ ]) if (hasField(node, "items") && hasField(node, "pagination")) return true;
487
+ return false;
488
+ };
489
+ const paginatedOperations = () => {
490
+ const paginated = /* @__PURE__ */ new Set();
491
+ const groups = SamvaApi.groups;
492
+ for (const group of Object.values(groups)) for (const [name, endpoint] of Object.entries(group.endpoints)) if (isPaginatedSuccess(endpoint.success)) paginated.add(name);
493
+ return paginated;
494
+ };
495
+ const PAGINATED_OPERATIONS = paginatedOperations();
496
+ const READ_METHODS = /* @__PURE__ */ new Set(["GET", "HEAD"]);
497
+ const readOperations = () => {
498
+ const reads = /* @__PURE__ */ new Set();
499
+ const groups = SamvaApi.groups;
500
+ for (const group of Object.values(groups)) for (const [name, endpoint] of Object.entries(group.endpoints)) if (READ_METHODS.has(endpoint.method)) reads.add(name);
501
+ return reads;
502
+ };
503
+ const READ_OPERATIONS = readOperations();
504
+ const MODULE_NAMES = {
505
+ apiKeys: "ApiKeys",
506
+ campaigns: "Campaigns",
507
+ contacts: "Contacts",
508
+ conversations: "Conversations",
509
+ design: "Design",
510
+ email: "Email",
511
+ messages: "Messages",
512
+ operations: "Operations",
513
+ organizations: "Organizations",
514
+ scheduledMessages: "ScheduledMessages",
515
+ templates: "Templates",
516
+ webhooks: "Webhooks"
517
+ };
518
+ const traceName = (operationName) => {
519
+ for (const [prefix, moduleName] of Object.entries(MODULE_NAMES)) {
520
+ if (!operationName.startsWith(prefix)) continue;
521
+ const method = operationName.slice(prefix.length);
522
+ return `${moduleName}.${method[0].toLowerCase()}${method.slice(1)}`;
523
+ }
524
+ return `Samva.${operationName}`;
525
+ };
526
+ const stripUndefined = (input) => {
527
+ if (!Predicate.isObject(input)) return input;
528
+ if (Array.isArray(input)) return input.map(stripUndefined);
529
+ if (Object.getPrototypeOf(input) !== Object.prototype) return input;
530
+ return Object.fromEntries(Object.entries(input).filter(([, value]) => value !== void 0).map(([key, value]) => [key, stripUndefined(value)]));
531
+ };
532
+ const rawOperation = (client, name) => client.operation(name);
533
+ const adapt = (operationName, rawCall, input) => {
534
+ const descriptor = SDK_OPERATION_CALLS[operationName];
535
+ const call = READ_OPERATIONS.has(operationName) ? (request) => withRetry(rawCall(request)) : rawCall;
536
+ if (descriptor.kind === "none") return call();
537
+ if (descriptor.kind === "params") return call({ query: stripUndefined(input) });
538
+ if (descriptor.kind === "payload") return call({ payload: stripUndefined(input) });
539
+ if (descriptor.kind === "idempotentPayload") {
540
+ const { idempotencyKey, ...payload } = input;
541
+ return call({
542
+ headers: { "idempotency-key": idempotencyKey },
543
+ payload: stripUndefined(payload)
544
+ });
545
+ }
546
+ const pathDescriptor = descriptor;
547
+ const inputRecord = input ?? {};
548
+ const params = {};
549
+ for (const path of pathDescriptor.paths) {
550
+ if (inputRecord[path] === void 0) return Effect.die(/* @__PURE__ */ new Error(`${operationName} requires path field ${path}`));
551
+ params[path] = inputRecord[path];
552
+ }
553
+ if (pathDescriptor.kind === "path") return call({ params });
554
+ const remainingInput = stripUndefined(Object.fromEntries(Object.entries(inputRecord).filter(([key]) => !pathDescriptor.paths.includes(key))));
555
+ return call({
556
+ params,
557
+ [pathDescriptor.kind === "pathParams" ? "query" : "payload"]: remainingInput
558
+ });
559
+ };
560
+ const make = (operationName) => {
561
+ const operation = Effect.fn(traceName(operationName))((input) => Effect.flatMap(Service, (client) => adapt(operationName, rawOperation(client, operationName), input)));
562
+ if (PAGINATED_OPERATIONS.has(operationName)) {
563
+ const list = operation;
564
+ Object.assign(operation, {
565
+ pages: (input) => streamPages(list, input ?? {}),
566
+ items: (input) => streamItems(list, input ?? {})
567
+ });
568
+ }
569
+ return operation;
570
+ };
571
+ const sendPayload = (payload, options) => Effect.gen(function* () {
572
+ const client = yield* Service;
573
+ const idempotencyKey = options?.idempotencyKey ?? (yield* generateIdempotencyKey);
574
+ return yield* withRetry(rawOperation(client, "messagesSend")({
575
+ payload: stripUndefined(payload),
576
+ headers: { "idempotency-key": idempotencyKey }
577
+ }));
578
+ });
579
+ const sendMessage = Effect.fn("Messages.send")(function* (input, options) {
580
+ return yield* sendPayload(buildMessagesSendPayload(input), options);
581
+ });
582
+ const sendEmail = Effect.fn("Email.send")(function* (input, options) {
583
+ return yield* sendPayload(buildEmailSendPayload(input), options);
584
+ });
585
+ const addEmailSender = Effect.fn("Email.addSender")(function* (input) {
586
+ const client = yield* Service;
587
+ const { replyToEmails, ...sender } = input;
588
+ return yield* rawOperation(client, "emailAddSender")({ payload: stripUndefined({
589
+ ...sender,
590
+ ...replyToEmailsPayload(replyToEmails)
591
+ }) });
592
+ });
593
+ //#endregion
594
+ export { sendMessage as i, make as n, sendEmail as r, addEmailSender as t };
595
+
596
+ //# sourceMappingURL=operation-Ccqh_yxb.js.map