samva 0.17.0 → 0.19.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 (143) hide show
  1. package/AGENTS.md +5 -0
  2. package/README.md +18 -3
  3. package/dist/{rolldown-runtime-D7D4PA-g.js → _virtual/_rolldown/runtime.js} +1 -1
  4. package/dist/client/client/client.gen.js +174 -0
  5. package/dist/client/client/utils.gen.js +177 -0
  6. package/dist/client/client.gen.js +8 -0
  7. package/dist/client/core/auth.gen.js +12 -0
  8. package/dist/client/core/bodySerializer.gen.js +6 -0
  9. package/dist/client/core/params.gen.js +77 -0
  10. package/dist/client/core/pathSerializer.gen.js +82 -0
  11. package/dist/client/core/serverSentEvents.gen.js +96 -0
  12. package/dist/client/core/utils.gen.js +78 -0
  13. package/dist/client/sdk.gen.d.ts +39 -23
  14. package/dist/{promises---Kbh-7z.js → client/sdk.gen.js} +87 -2314
  15. package/dist/client/types.gen.d.ts +175 -44
  16. package/dist/client-attribution.js +9 -0
  17. package/dist/effect/analytics.d.ts +6 -6
  18. package/dist/effect/analytics.js +23 -2
  19. package/dist/effect/api-keys.d.ts +12 -12
  20. package/dist/effect/api-keys.js +29 -2
  21. package/dist/effect/attachments.d.ts +4 -4
  22. package/dist/effect/attachments.js +19 -2
  23. package/dist/effect/brands.d.ts +6 -6
  24. package/dist/effect/brands.js +26 -3
  25. package/dist/effect/campaigns.d.ts +18 -18
  26. package/dist/effect/campaigns.js +35 -2
  27. package/dist/effect/categories.d.ts +2 -2
  28. package/dist/effect/categories.js +95 -1
  29. package/dist/effect/client.js +3 -3
  30. package/dist/effect/contact-groups.d.ts +53 -17
  31. package/dist/effect/contact-groups.js +31 -2
  32. package/dist/effect/contacts.d.ts +244 -41
  33. package/dist/effect/contacts.js +54 -2
  34. package/dist/effect/conversations.d.ts +28 -28
  35. package/dist/effect/conversations.js +37 -2
  36. package/dist/effect/custom-fields.d.ts +4 -4
  37. package/dist/effect/custom-fields.js +19 -2
  38. package/dist/effect/email.d.ts +75 -75
  39. package/dist/effect/email.js +140 -2
  40. package/dist/effect/errors.d.ts +2 -0
  41. package/dist/effect/errors.js +3 -0
  42. package/dist/effect/events.d.ts +2 -2
  43. package/dist/effect/events.js +17 -3
  44. package/dist/effect/extension-installations.d.ts +23 -23
  45. package/dist/effect/extension-installations.js +29 -2
  46. package/dist/effect/extensions.d.ts +12 -12
  47. package/dist/effect/extensions.js +21 -2
  48. package/dist/effect/feedback.d.ts +1 -1
  49. package/dist/effect/feedback.js +14 -3
  50. package/dist/{analytics-CaqPRsry.js → effect/generated/analytics.js} +4 -23
  51. package/dist/{api-keys-Ce1Y4_Ip.js → effect/generated/api-keys.js} +4 -29
  52. package/dist/{attachments-DYqVIraC.js → effect/generated/attachments.js} +3 -18
  53. package/dist/{brands-ZwuOGIWO.js → effect/generated/brands.js} +5 -25
  54. package/dist/{campaigns-DZlz1E9E.js → effect/generated/campaigns.js} +4 -35
  55. package/dist/effect/generated/contact-events.js +37 -0
  56. package/dist/effect/generated/contact-groups.d.ts +33 -3
  57. package/dist/{contact-groups-BLbFXnjq.js → effect/generated/contact-groups.js} +3 -30
  58. package/dist/effect/generated/contacts.d.ts +477 -54
  59. package/dist/{contacts-BbsoXXB4.js → effect/generated/contacts.js} +41 -89
  60. package/dist/effect/generated/conversations.d.ts +25 -25
  61. package/dist/{conversations-_sRHueML.js → effect/generated/conversations.js} +4 -37
  62. package/dist/{custom-fields-BHWbwlKn.js → effect/generated/custom-fields.js} +5 -19
  63. package/dist/{email-R0NAA9PW.js → effect/generated/email.js} +995 -1146
  64. package/dist/{events-CxbTUHYT.js → effect/generated/events.js} +3 -15
  65. package/dist/effect/generated/extension-installations.d.ts +44 -44
  66. package/dist/{extension-installations-CD94LPmk.js → effect/generated/extension-installations.js} +10 -29
  67. package/dist/effect/generated/extensions.d.ts +10 -10
  68. package/dist/{extensions-BKyNQLvu.js → effect/generated/extensions.js} +5 -20
  69. package/dist/{feedback-Bpa09JOS.js → effect/generated/feedback.js} +3 -12
  70. package/dist/{journeys-CARo_BJT.js → effect/generated/journeys.js} +3 -38
  71. package/dist/effect/generated/mailboxes.d.ts +310 -0
  72. package/dist/{mailboxes-BRDn7BIK.js → effect/generated/mailboxes.js} +829 -954
  73. package/dist/{media-VrrtNnft.js → effect/generated/media.js} +3 -3
  74. package/dist/effect/generated/messages.d.ts +31 -0
  75. package/dist/effect/generated/messages.js +677 -0
  76. package/dist/{namespaces-CcvEbG-y.js → effect/generated/namespaces.js} +3 -20
  77. package/dist/{operations-CmB3FHwf.js → effect/generated/operations.js} +3 -16
  78. package/dist/effect/generated/organizations.d.ts +13 -11
  79. package/dist/{organizations-A-plufWc.js → effect/generated/organizations.js} +9 -26
  80. package/dist/{scheduled-messages-DkKZRRaN.js → effect/generated/scheduled-messages.js} +4 -21
  81. package/dist/effect/generated/shared.d.ts +70 -20
  82. package/dist/effect/generated/shared.js +1073 -0
  83. package/dist/{subscriptions-DEXYtMXg.js → effect/generated/subscriptions.js} +3 -9
  84. package/dist/{templates-DZomxsG7.js → effect/generated/templates.js} +3 -78
  85. package/dist/effect/generated/unsubscribe-groups.d.ts +173 -78
  86. package/dist/{unsubscribe-groups-Iqk4Isf9.js → effect/generated/unsubscribe-groups.js} +77 -84
  87. package/dist/effect/generated/webhooks.d.ts +19 -19
  88. package/dist/{webhooks-CPXuu8Xf.js → effect/generated/webhooks.js} +12 -34
  89. package/dist/{whoami-Ccz0jwlt.js → effect/generated/whoami.js} +5 -10
  90. package/dist/effect/generated-metadata.d.ts +7 -2
  91. package/dist/effect/generated-metadata.js +925 -0
  92. package/dist/effect/index.d.ts +1 -2
  93. package/dist/effect/index.js +32 -32
  94. package/dist/effect/internal/client.js +69 -0
  95. package/dist/effect/internal/email-sender.js +21 -0
  96. package/dist/effect/internal/mailbox-events.js +33 -0
  97. package/dist/effect/internal/operation.js +116 -0
  98. package/dist/effect/internal/send.js +56 -0
  99. package/dist/effect/journeys.d.ts +18 -18
  100. package/dist/effect/journeys.js +39 -2
  101. package/dist/effect/mailboxes.d.ts +314 -182
  102. package/dist/effect/mailboxes.js +135 -3
  103. package/dist/effect/media.d.ts +5 -5
  104. package/dist/effect/media.js +10 -10
  105. package/dist/effect/messages.d.ts +19 -14
  106. package/dist/effect/messages.js +15 -14
  107. package/dist/effect/namespaces.d.ts +7 -7
  108. package/dist/effect/namespaces.js +21 -2
  109. package/dist/effect/operations.d.ts +5 -5
  110. package/dist/effect/operations.js +17 -2
  111. package/dist/effect/organizations.d.ts +11 -11
  112. package/dist/effect/organizations.js +25 -2
  113. package/dist/effect/pagination.js +39 -0
  114. package/dist/effect/retry.js +3 -3
  115. package/dist/{runtime-P0l1_2-C.js → effect/runtime.js} +2 -2
  116. package/dist/effect/scheduled-messages.d.ts +7 -7
  117. package/dist/effect/scheduled-messages.js +21 -2
  118. package/dist/effect/subscriptions.d.ts +1 -1
  119. package/dist/effect/subscriptions.js +10 -2
  120. package/dist/effect/templates.d.ts +39 -39
  121. package/dist/effect/templates.js +80 -3
  122. package/dist/effect/unsubscribe-groups.d.ts +39 -28
  123. package/dist/effect/unsubscribe-groups.js +29 -2
  124. package/dist/effect/webhooks.d.ts +22 -22
  125. package/dist/effect/webhooks.js +35 -3
  126. package/dist/effect/whoami.d.ts +9 -9
  127. package/dist/effect/whoami.js +10 -2
  128. package/dist/index.js +4 -3
  129. package/dist/{inline-attachments-Bi1hDltp.js → inline-attachments.js} +13 -7
  130. package/dist/mailbox-events.d.ts +31 -4
  131. package/dist/{mailbox-events-VKR4f3qq.js → mailbox-events.js} +41 -13
  132. package/dist/{normalize-B79uJIeb.js → normalize.js} +2 -2
  133. package/dist/package.js +6 -0
  134. package/dist/promises/errors.gen.js +1340 -0
  135. package/dist/promises/index.d.ts +1 -1
  136. package/dist/promises/index.js +288 -3
  137. package/dist/promises/types.gen.d.ts +1 -1
  138. package/dist/service-map.d.ts +9 -4
  139. package/dist/{operation-n_IYgNVK.js → service-map.js} +12 -150
  140. package/package.json +6 -2
  141. package/dist/categories-CA4XIQAb.js +0 -1011
  142. package/dist/client-DOzUrdTE.js +0 -1115
  143. package/dist/send-Bxc0XfGE.js +0 -722
@@ -1,7 +1,3 @@
1
- import { t as Service } from "./client-DOzUrdTE.js";
2
- import { y as SamvaOperations } from "./categories-CA4XIQAb.js";
3
- import { withRetry } from "./effect/retry.js";
4
- import { Effect, Option, Predicate, Stream } from "effect";
5
1
  //#region src/service-map.ts
6
2
  /** How each generated Effect operation is adapted to the Promise facade's direct input shape. */
7
3
  const SDK_OPERATION_CALLS = {
@@ -438,6 +434,14 @@ const SDK_OPERATION_CALLS = {
438
434
  kind: "path",
439
435
  paths: ["id", "identityId"]
440
436
  },
437
+ contactsSetConsent: {
438
+ kind: "pathPayload",
439
+ paths: [
440
+ "id",
441
+ "identityId",
442
+ "channel"
443
+ ]
444
+ },
441
445
  contactsAddTags: {
442
446
  kind: "pathPayload",
443
447
  paths: ["id"]
@@ -725,11 +729,11 @@ const SDK_OPERATION_CALLS = {
725
729
  kind: "pathParams",
726
730
  paths: ["id"]
727
731
  },
728
- unsubscribeAddEmails: {
732
+ unsubscribeAddMembers: {
729
733
  kind: "pathPayload",
730
734
  paths: ["id"]
731
735
  },
732
- unsubscribeRemoveEmails: {
736
+ unsubscribeRemoveMembers: {
733
737
  kind: "pathPayload",
734
738
  paths: ["id"]
735
739
  },
@@ -1050,148 +1054,6 @@ const SDK_OPERATION_CALLS = {
1050
1054
  }
1051
1055
  };
1052
1056
  //#endregion
1053
- //#region src/effect/pagination.ts
1054
- /**
1055
- * Stream pagination for the Effect SDK.
1056
- *
1057
- * Every list operation whose success value is a page envelope gains `.pages()`
1058
- * and `.items()` companions on its domain operation. `.pages()` streams the raw
1059
- * envelopes; `.items()` flattens them into a stream of items. Every list pages
1060
- * by cursor, `{ items, nextCursor }`: each step passes the previous page's
1061
- * `nextCursor` as `cursor`, and the walk stops at a null `nextCursor`.
1062
- *
1063
- * The traversal is **lazy**: built on `Stream.paginate` (a pull-based source),
1064
- * so each page is fetched only as the stream is consumed — `Stream.take(n)`
1065
- * stops requesting further pages. Caller params (the start `cursor`,
1066
- * `limit`, filters) are respected; only the position is advanced per step.
1067
- *
1068
- * Retry is **not** re-applied here: the underlying domain operation is already
1069
- * wrapped in the ambient {@link import("./retry").Service} policy (reads are
1070
- * retry-safe), so each page fetch retries on its own and pagination composes
1071
- * with retry instead of nesting retries.
1072
- */
1073
- /** Honor a caller-supplied start `cursor`; default to the first page otherwise. */
1074
- const startCursorOf = (input) => {
1075
- const cursor = input?.cursor;
1076
- return typeof cursor === "string" ? cursor : void 0;
1077
- };
1078
- /** Fetch the page at `cursor`, preserving all other caller params. */
1079
- const fetchCursorPage = (operation, input, cursor) => operation({
1080
- ...input,
1081
- cursor
1082
- });
1083
- /** Stream the raw cursor page envelopes, one per request, from the caller's start cursor. */
1084
- const streamCursorPages = (operation, input) => Stream.paginate(startCursorOf(input), (cursor) => fetchCursorPage(operation, input, cursor).pipe(Effect.map((result) => [[result], Option.fromNullishOr(result.nextCursor)])));
1085
- /** Stream individual items across cursor pages, fetching the next page only when pulled. */
1086
- const streamCursorItems = (operation, input) => Stream.paginate(startCursorOf(input), (cursor) => fetchCursorPage(operation, input, cursor).pipe(Effect.map((result) => [result.items, Option.fromNullishOr(result.nextCursor)])));
1087
- //#endregion
1088
- //#region src/effect/internal/operation.ts
1089
- const READ_METHODS = /* @__PURE__ */ new Set(["GET", "HEAD"]);
1090
- const MODULE_NAMES = {
1091
- analytics: "Analytics",
1092
- apiKeys: "ApiKeys",
1093
- attachments: "Attachments",
1094
- brands: "Brands",
1095
- campaigns: "Campaigns",
1096
- contactGroups: "ContactGroups",
1097
- contacts: "Contacts",
1098
- conversations: "Conversations",
1099
- customFields: "CustomFields",
1100
- email: "Email",
1101
- extensions: "Extensions",
1102
- feedback: "Feedback",
1103
- mailboxes: "Mailboxes",
1104
- media: "Media",
1105
- messages: "Messages",
1106
- namespaces: "Namespaces",
1107
- operations: "Operations",
1108
- organizations: "Organizations",
1109
- scheduledMessages: "ScheduledMessages",
1110
- templates: "Templates",
1111
- unsubscribe: "UnsubscribeGroups",
1112
- webhooks: "Webhooks",
1113
- whoami: "Whoami"
1114
- };
1115
- const traceName = (operationName) => {
1116
- for (const [prefix, moduleName] of Object.entries(MODULE_NAMES)) {
1117
- if (!operationName.startsWith(prefix)) continue;
1118
- const method = operationName.slice(prefix.length);
1119
- return `${moduleName}.${method[0].toLowerCase()}${method.slice(1)}`;
1120
- }
1121
- return `Samva.${operationName}`;
1122
- };
1123
- const stripUndefined = (input) => {
1124
- if (!Predicate.isObject(input)) return input;
1125
- if (Array.isArray(input)) return input.map(stripUndefined);
1126
- if (Object.getPrototypeOf(input) !== Object.prototype) return input;
1127
- return Object.fromEntries(Object.entries(input).filter(([, value]) => value !== void 0).map(([key, value]) => [key, stripUndefined(value)]));
1128
- };
1129
- const adapt = (operationName, rawCall, input) => {
1130
- const descriptor = SDK_OPERATION_CALLS[operationName];
1131
- const call = READ_METHODS.has(SamvaOperations[operationName].method) ? (request) => withRetry(rawCall(request)) : rawCall;
1132
- if (descriptor.kind === "none") return call();
1133
- if (descriptor.kind === "params") return call({ query: stripUndefined(input) });
1134
- if (descriptor.kind === "payload") return call({ payload: stripUndefined(input) });
1135
- if (descriptor.kind === "idempotentPayload") {
1136
- const { idempotencyKey, ...payload } = input;
1137
- return call({
1138
- headers: { "idempotency-key": idempotencyKey },
1139
- payload: stripUndefined(payload)
1140
- });
1141
- }
1142
- const pathDescriptor = descriptor;
1143
- const inputRecord = input ?? {};
1144
- const params = {};
1145
- for (const path of pathDescriptor.paths) {
1146
- if (inputRecord[path] === void 0) return Effect.die(/* @__PURE__ */ new Error(`${operationName} requires path field ${path}`));
1147
- params[path] = inputRecord[path];
1148
- }
1149
- if (pathDescriptor.kind === "path") return call({ params });
1150
- if (pathDescriptor.kind === "idempotentPath") return call({
1151
- params,
1152
- headers: { "idempotency-key": inputRecord.idempotencyKey }
1153
- });
1154
- const optionalKeyHeaders = { headers: inputRecord.idempotencyKey === void 0 ? {} : { "idempotency-key": inputRecord.idempotencyKey } };
1155
- if (pathDescriptor.kind === "optionalIdempotentPath") return call({
1156
- params,
1157
- ...optionalKeyHeaders
1158
- });
1159
- const headerKey = pathDescriptor.kind === "optionalIdempotentPathPayload";
1160
- const remainingInput = stripUndefined(Object.fromEntries(Object.entries(inputRecord).filter(([key]) => !pathDescriptor.paths.includes(key) && !(headerKey && key === "idempotencyKey"))));
1161
- if (pathDescriptor.kind === "optionalIdempotentPathPayload") return call({
1162
- params,
1163
- payload: remainingInput,
1164
- ...optionalKeyHeaders
1165
- });
1166
- return call({
1167
- params,
1168
- [pathDescriptor.kind === "pathParams" ? "query" : "payload"]: remainingInput
1169
- });
1170
- };
1171
- const isCursorPageEnvelope = (value) => Predicate.isObject(value) && Array.isArray(value.items) && (value.nextCursor === null || typeof value.nextCursor === "string");
1172
- /**
1173
- * Operation factory for one API group. Each domain module binds its own group, so importing it
1174
- * loads that group's schemas and nothing else.
1175
- */
1176
- const forGroup = (group) => (operationName) => {
1177
- if (SamvaOperations[operationName].group !== group.identifier) throw new Error(`${operationName} is not an endpoint of ${group.identifier}`);
1178
- return make(group, operationName);
1179
- };
1180
- /** Call one endpoint with an already-shaped request, outside the direct-operation adapter. */
1181
- const callEndpoint = (group, name, request) => Effect.flatMap(Service, (client) => Effect.flatMap(client.endpoint(group, name), (call) => call(request)));
1182
- const make = (group, operationName) => {
1183
- const call = Effect.fn(traceName(operationName))((input) => Effect.flatMap(Service, (client) => Effect.flatMap(client.endpoint(group, operationName), (rawCall) => adapt(operationName, rawCall, input))));
1184
- const operation = call;
1185
- if (SamvaOperations[operationName].paginated) {
1186
- const list = (input) => Effect.filterOrElse(call(input), isCursorPageEnvelope, () => Effect.die(/* @__PURE__ */ new Error(`${operationName} did not return a cursor page envelope`)));
1187
- Object.assign(operation, {
1188
- pages: (input) => streamCursorPages(list, input ?? {}),
1189
- items: (input) => streamCursorItems(list, input ?? {})
1190
- });
1191
- }
1192
- return operation;
1193
- };
1194
- //#endregion
1195
- export { forGroup as n, stripUndefined as r, callEndpoint as t };
1057
+ export { SDK_OPERATION_CALLS };
1196
1058
 
1197
- //# sourceMappingURL=operation-n_IYgNVK.js.map
1059
+ //# sourceMappingURL=service-map.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "samva",
3
- "version": "0.17.0",
3
+ "version": "0.19.0",
4
4
  "description": "TypeScript SDK for the Samva email API",
5
5
  "keywords": [
6
6
  "api-client",
@@ -47,6 +47,10 @@
47
47
  "types": "./dist/effect/index.d.ts",
48
48
  "import": "./dist/effect/index.js"
49
49
  },
50
+ "./effect/errors": {
51
+ "types": "./dist/effect/errors.d.ts",
52
+ "import": "./dist/effect/errors.js"
53
+ },
50
54
  "./effect/categories": {
51
55
  "types": "./dist/effect/categories.d.ts",
52
56
  "import": "./dist/effect/categories.js"
@@ -196,7 +200,7 @@
196
200
  "typecheck": "tsc --noEmit && tsc --noEmit -p codegen/tsconfig.json && tsc --noEmit -p tests/tsconfig.json"
197
201
  },
198
202
  "dependencies": {
199
- "@samva/webhooks": "0.17.0"
203
+ "@samva/webhooks": "0.19.0"
200
204
  },
201
205
  "devDependencies": {
202
206
  "@effect/openapi-generator": "4.0.0",