samva 0.5.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.
Files changed (63) hide show
  1. package/AGENTS.md +3 -2
  2. package/README.md +12 -2
  3. package/dist/{categories-B9Nw2v_F.js → categories-4u9Az4No.js} +24 -8
  4. package/dist/client/sdk.gen.d.ts +406 -74
  5. package/dist/client/types.gen.d.ts +2583 -279
  6. package/dist/{client-B7gEkvEq.js → client-DCM6U0-I.js} +2183 -772
  7. package/dist/{client-attribution-B2yJBXdZ.js → client-attribution-DYUSAa76.js} +2 -2
  8. package/dist/effect/analytics.d.ts +66 -0
  9. package/dist/effect/analytics.js +21 -0
  10. package/dist/effect/api-keys.d.ts +198 -34
  11. package/dist/effect/api-keys.js +1 -1
  12. package/dist/effect/attachments.d.ts +53 -0
  13. package/dist/effect/attachments.js +17 -0
  14. package/dist/effect/campaigns.d.ts +36 -18
  15. package/dist/effect/campaigns.js +1 -1
  16. package/dist/effect/categories.d.ts +3 -3
  17. package/dist/effect/categories.js +1 -1
  18. package/dist/effect/client.js +1 -1
  19. package/dist/effect/contact-groups.d.ts +375 -0
  20. package/dist/effect/contact-groups.js +29 -0
  21. package/dist/effect/contacts.d.ts +35 -19
  22. package/dist/effect/contacts.js +1 -1
  23. package/dist/effect/conversations.d.ts +179 -47
  24. package/dist/effect/conversations.js +1 -1
  25. package/dist/effect/custom-fields.d.ts +111 -0
  26. package/dist/effect/custom-fields.js +17 -0
  27. package/dist/effect/design.d.ts +2 -2
  28. package/dist/effect/design.js +1 -1
  29. package/dist/effect/email.d.ts +254 -118
  30. package/dist/effect/email.js +2 -2
  31. package/dist/effect/generated-metadata.d.ts +12 -4
  32. package/dist/effect/generated.d.ts +11189 -6155
  33. package/dist/effect/index.d.ts +6 -1
  34. package/dist/effect/index.js +8 -3
  35. package/dist/effect/internal/operation.d.ts +115 -27
  36. package/dist/effect/media.d.ts +5 -5
  37. package/dist/effect/media.js +1 -1
  38. package/dist/effect/messages.d.ts +303 -73
  39. package/dist/effect/messages.js +1 -1
  40. package/dist/effect/operations.d.ts +6 -6
  41. package/dist/effect/operations.js +1 -1
  42. package/dist/effect/organizations.d.ts +7 -110
  43. package/dist/effect/organizations.js +2 -4
  44. package/dist/effect/retry.js +1 -1
  45. package/dist/effect/scheduled-messages.d.ts +7 -7
  46. package/dist/effect/scheduled-messages.js +1 -1
  47. package/dist/effect/templates.d.ts +35 -307
  48. package/dist/effect/templates.js +3 -5
  49. package/dist/effect/unsubscribe-groups.d.ts +161 -0
  50. package/dist/effect/unsubscribe-groups.js +25 -0
  51. package/dist/effect/webhooks.d.ts +18 -18
  52. package/dist/effect/webhooks.js +2 -2
  53. package/dist/index.js +2 -2
  54. package/dist/{normalize-BiIJnycv.js → normalize-B79uJIeb.js} +13 -14
  55. package/dist/normalize.d.ts +3 -7
  56. package/dist/{operation-B4FjN6wq.js → operation-02YX3hY9.js} +96 -8
  57. package/dist/promises/errors.gen.d.ts +30 -41
  58. package/dist/promises/index.d.ts +18 -4
  59. package/dist/promises/index.js +2 -2
  60. package/dist/promises/types.gen.d.ts +1 -1
  61. package/dist/{promises-CP_nxUus.js → promises-8MaPNAam.js} +1209 -288
  62. package/dist/service-map.d.ts +155 -8
  63. package/package.json +28 -8
package/AGENTS.md CHANGED
@@ -6,8 +6,9 @@ required.
6
6
 
7
7
  Effect applications should import Pascal-cased domain modules from focused subpaths such as
8
8
  `samva/effect/email` and provide `Client.layerFetch` from `samva/effect/client`. Install the optional
9
- peer `effect@4.0.0-rc.112` when using those entrypoints. Keep that exact release candidate pinned. Tagged API
10
- failures remain in the Effect error channel and can be handled with `Effect.catchTag`.
9
+ peer `effect` at the exact version this package's `peerDependencies` names when using those
10
+ entrypoints; a different release candidate is unsupported. Tagged API failures remain in the
11
+ Effect error channel and can be handled with `Effect.catchTag`.
11
12
 
12
13
  Treat exported request and response types as the API contract. Do not import package-internal files
13
14
  or generated implementation paths; use only the subpaths declared in `package.json`.
package/README.md CHANGED
@@ -65,7 +65,7 @@ const messages = await client.messages.list({
65
65
  Install `effect` next to `samva` when using the Effect entrypoint:
66
66
 
67
67
  ```bash
68
- bun add samva effect@4.0.0-rc.112
68
+ bun add samva effect@4.0.0-rc.117
69
69
  ```
70
70
 
71
71
  ```typescript
@@ -112,7 +112,7 @@ const client = createClient({
112
112
  - The token is user-scoped; send the target organization slug on every request via the `x-org-slug` header.
113
113
  - There is no SDK `orgSlug` helper — pass the header directly.
114
114
 
115
- For terminal workflows (`samva login`, `samva org use`, `samva email send --dry-run`), see the [`@samva/cli` README](https://github.com/AryaLabsHQ/samva/tree/main/packages/cli).
115
+ For terminal workflows (`samva login`, `samva org use`, `samva email send --dry-run`), see [`@samva/cli`](https://www.npmjs.com/package/@samva/cli).
116
116
 
117
117
  The Promise and Effect clients identify their public SDK surface and package version with the
118
118
  advisory `x-samva-client` request header. Supply your own value in `headers`, or set the header to
@@ -122,10 +122,14 @@ advisory `x-samva-client` request header. Supply your own value in `headers`, or
122
122
 
123
123
  The Promise client exposes:
124
124
 
125
+ - `analytics`
125
126
  - `apiKeys`
127
+ - `attachments`
126
128
  - `campaigns`
129
+ - `contactGroups`
127
130
  - `contacts`
128
131
  - `conversations`
132
+ - `customFields`
129
133
  - `design`
130
134
  - `email`
131
135
  - `media`
@@ -134,14 +138,19 @@ The Promise client exposes:
134
138
  - `organizations`
135
139
  - `scheduledMessages`
136
140
  - `templates`
141
+ - `unsubscribeGroups`
137
142
  - `webhooks`
138
143
 
139
144
  The Effect SDK exposes Pascal-cased domain modules with lower-camel operations:
140
145
 
146
+ - `Analytics`
141
147
  - `ApiKeys`
148
+ - `Attachments`
142
149
  - `Campaigns`
150
+ - `ContactGroups`
143
151
  - `Contacts`
144
152
  - `Conversations`
153
+ - `CustomFields`
145
154
  - `Design`
146
155
  - `Email`
147
156
  - `Media`
@@ -150,6 +159,7 @@ The Effect SDK exposes Pascal-cased domain modules with lower-camel operations:
150
159
  - `Organizations`
151
160
  - `ScheduledMessages`
152
161
  - `Templates`
162
+ - `UnsubscribeGroups`
153
163
  - `Webhooks`
154
164
 
155
165
  Effect operations take direct parameter objects: body, path, and query fields are not wrapped in `payload` or `params` envelopes. Import the modules you use from `samva/effect/<lower-kebab>` and provide `Client.layerFetch` once at the program boundary. `Client.raw` exposes the underlying generated client for advanced access, but ordinary workflows do not require it.
@@ -2,6 +2,10 @@ import { Effect } from "effect";
2
2
  import * as Predicate$1 from "effect/Predicate";
3
3
  //#region src/effect/generated-metadata.ts
4
4
  const SamvaErrorMetadata = {
5
+ AnalyticsQueryError: {
6
+ categories: [],
7
+ retryable: false
8
+ },
5
9
  BillingProviderError: {
6
10
  categories: ["transient"],
7
11
  retryable: true
@@ -10,6 +14,10 @@ const SamvaErrorMetadata = {
10
14
  categories: ["conflict"],
11
15
  retryable: false
12
16
  },
17
+ DeliveryUnavailableError: {
18
+ categories: ["transient"],
19
+ retryable: true
20
+ },
13
21
  EmailChannelError: {
14
22
  categories: [],
15
23
  retryable: false
@@ -26,6 +34,10 @@ const SamvaErrorMetadata = {
26
34
  categories: ["auth"],
27
35
  retryable: false
28
36
  },
37
+ GatewayTimeoutError: {
38
+ categories: ["transient"],
39
+ retryable: true
40
+ },
29
41
  InternalError: {
30
42
  categories: ["transient"],
31
43
  retryable: true
@@ -53,10 +65,6 @@ const SamvaErrorMetadata = {
53
65
  ValidationError: {
54
66
  categories: ["validation"],
55
67
  retryable: false
56
- },
57
- WebhookEnqueueError: {
58
- categories: ["transient"],
59
- retryable: true
60
68
  }
61
69
  };
62
70
  //#endregion
@@ -118,7 +126,7 @@ const isRequestTransportError = (error) => {
118
126
  const reason = error.reason;
119
127
  return Predicate$1.isObject(reason) && Predicate$1.isTagged(reason, "TransportError");
120
128
  };
121
- /** True for transient failures, including raw request-transport errors (D4). */
129
+ /** True for transient failures, including raw request-transport errors. */
122
130
  const isTransient = (error) => hasCategory(error, "transient") || isRequestTransportError(error);
123
131
  /** True when an error is declared safe to retry (throttling / transient / transport). */
124
132
  const isRetryable = (error) => isRetryableError(error) || isRequestTransportError(error);
@@ -128,7 +136,15 @@ const isRetryable = (error) => isRetryableError(error) || isRequestTransportErro
128
136
  * category — while only total-membership classes are narrowed out of the error
129
137
  * channel (`EmailChannelError` stays: instances with other reasons pass through).
130
138
  */
131
- const catchCategory = (category, handler) => (effect) => Effect.catchIf(effect, (error) => hasCategory(error, category), handler);
139
+ const catchCategory = (category, handler) => (effect) => {
140
+ const inCategory = (error) => hasCategory(error, category);
141
+ const outsideCategory = (error) => !hasCategory(error, category);
142
+ return Effect.catch(effect, (error) => {
143
+ if (inCategory(error)) return handler(error);
144
+ if (outsideCategory(error)) return Effect.fail(error);
145
+ return Effect.die(error);
146
+ });
147
+ };
132
148
  const catchAuthError = (handler) => catchCategory("auth", handler);
133
149
  const catchValidationError = (handler) => catchCategory("validation", handler);
134
150
  const catchNotFoundError = (handler) => catchCategory("notFound", handler);
@@ -140,8 +156,8 @@ const catchBillingError = (handler) => catchCategory("billing", handler);
140
156
  * fallback/degrade paths. The declared error channel is left intact because
141
157
  * transient covers untyped transport errors as well.
142
158
  */
143
- const catchTransient = (handler) => (effect) => Effect.catchIf(effect, (error) => isTransient(error), handler);
159
+ const catchTransient = (handler) => (effect) => Effect.catchIf(effect, isTransient, handler);
144
160
  //#endregion
145
161
  export { isTransient as _, catchNotFoundError as a, catchValidationError as c, isAuthError as d, isBillingError as f, isThrottlingError as g, isRetryable as h, catchConflictError as i, categoriesOf as l, isNotFoundError as m, catchBillingError as n, catchThrottlingError as o, isConflictError as p, catchCategory as r, catchTransient as s, catchAuthError as t, hasCategory as u, isValidationError as v };
146
162
 
147
- //# sourceMappingURL=categories-B9Nw2v_F.js.map
163
+ //# sourceMappingURL=categories-4u9Az4No.js.map