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.
Files changed (63) hide show
  1. package/AGENTS.md +3 -2
  2. package/README.md +12 -2
  3. package/dist/{categories-CsUa8ojo.js → categories-4u9Az4No.js} +28 -8
  4. package/dist/client/sdk.gen.d.ts +545 -74
  5. package/dist/client/types.gen.d.ts +3907 -747
  6. package/dist/{client-BmZK_uCt.js → client-DCM6U0-I.js} +3061 -808
  7. package/dist/{client-attribution-BslSOa_8.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 +52 -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 +191 -44
  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 +931 -97
  30. package/dist/effect/email.js +27 -3
  31. package/dist/effect/generated-metadata.d.ts +16 -4
  32. package/dist/effect/generated.d.ts +19596 -10819
  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 +124 -26
  36. package/dist/effect/media.d.ts +8 -8
  37. package/dist/effect/media.js +1 -1
  38. package/dist/effect/messages.d.ts +473 -64
  39. package/dist/effect/messages.js +5 -3
  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 +96 -12
  46. package/dist/effect/scheduled-messages.js +5 -3
  47. package/dist/effect/templates.d.ts +35 -295
  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 +52 -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-B1knNlxk.js → operation-02YX3hY9.js} +144 -8
  57. package/dist/promises/errors.gen.d.ts +47 -39
  58. package/dist/promises/index.d.ts +19 -4
  59. package/dist/promises/index.js +2 -2
  60. package/dist/promises/types.gen.d.ts +1 -1
  61. package/dist/{promises-n1opem5V.js → promises-8MaPNAam.js} +1679 -267
  62. package/dist/service-map.d.ts +221 -8
  63. package/package.json +29 -9
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,10 +34,18 @@ 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
32
44
  },
45
+ OnboardingReviewRequiredError: {
46
+ categories: ["validation"],
47
+ retryable: false
48
+ },
33
49
  PaymentRequiredError: {
34
50
  categories: ["billing"],
35
51
  retryable: false
@@ -49,10 +65,6 @@ const SamvaErrorMetadata = {
49
65
  ValidationError: {
50
66
  categories: ["validation"],
51
67
  retryable: false
52
- },
53
- WebhookEnqueueError: {
54
- categories: ["transient"],
55
- retryable: true
56
68
  }
57
69
  };
58
70
  //#endregion
@@ -114,7 +126,7 @@ const isRequestTransportError = (error) => {
114
126
  const reason = error.reason;
115
127
  return Predicate$1.isObject(reason) && Predicate$1.isTagged(reason, "TransportError");
116
128
  };
117
- /** True for transient failures, including raw request-transport errors (D4). */
129
+ /** True for transient failures, including raw request-transport errors. */
118
130
  const isTransient = (error) => hasCategory(error, "transient") || isRequestTransportError(error);
119
131
  /** True when an error is declared safe to retry (throttling / transient / transport). */
120
132
  const isRetryable = (error) => isRetryableError(error) || isRequestTransportError(error);
@@ -124,7 +136,15 @@ const isRetryable = (error) => isRetryableError(error) || isRequestTransportErro
124
136
  * category — while only total-membership classes are narrowed out of the error
125
137
  * channel (`EmailChannelError` stays: instances with other reasons pass through).
126
138
  */
127
- 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
+ };
128
148
  const catchAuthError = (handler) => catchCategory("auth", handler);
129
149
  const catchValidationError = (handler) => catchCategory("validation", handler);
130
150
  const catchNotFoundError = (handler) => catchCategory("notFound", handler);
@@ -136,8 +156,8 @@ const catchBillingError = (handler) => catchCategory("billing", handler);
136
156
  * fallback/degrade paths. The declared error channel is left intact because
137
157
  * transient covers untyped transport errors as well.
138
158
  */
139
- const catchTransient = (handler) => (effect) => Effect.catchIf(effect, (error) => isTransient(error), handler);
159
+ const catchTransient = (handler) => (effect) => Effect.catchIf(effect, isTransient, handler);
140
160
  //#endregion
141
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 };
142
162
 
143
- //# sourceMappingURL=categories-CsUa8ojo.js.map
163
+ //# sourceMappingURL=categories-4u9Az4No.js.map