samva 0.46.1 → 0.48.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 -7
  2. package/README.md +106 -8
  3. package/dist/agent/index.d.ts +57 -0
  4. package/dist/agent/index.js +53 -0
  5. package/dist/agent/runtime.d.ts +3 -0
  6. package/dist/agent/runtime.js +95 -0
  7. package/dist/agent/test.d.ts +31 -0
  8. package/dist/agent/test.js +66 -0
  9. package/dist/agent/types.d.ts +150 -0
  10. package/dist/client/sdk.gen.d.ts +50 -165
  11. package/dist/client/sdk.gen.js +1339 -1614
  12. package/dist/client/types.gen.d.ts +461 -989
  13. package/dist/effect/agents.d.ts +340 -8
  14. package/dist/effect/agents.js +4 -2
  15. package/dist/effect/api-keys.d.ts +2 -0
  16. package/dist/effect/campaigns.d.ts +160 -160
  17. package/dist/effect/contacts.d.ts +8 -0
  18. package/dist/effect/contacts.js +5 -1
  19. package/dist/effect/descriptors/agents.d.ts +12 -2
  20. package/dist/effect/descriptors/agents.js +12 -2
  21. package/dist/effect/descriptors/contacts.d.ts +20 -0
  22. package/dist/effect/descriptors/contacts.js +20 -0
  23. package/dist/effect/generated/accounts.d.ts +10 -0
  24. package/dist/effect/generated/accounts.js +1 -0
  25. package/dist/effect/generated/agents.d.ts +2967 -690
  26. package/dist/effect/generated/agents.js +54 -13
  27. package/dist/effect/generated/api-keys.d.ts +15 -0
  28. package/dist/effect/generated/api-keys.js +2 -0
  29. package/dist/effect/generated/contacts.d.ts +859 -1
  30. package/dist/effect/generated/contacts.js +62 -3
  31. package/dist/effect/generated/index.d.ts +1 -5
  32. package/dist/effect/generated/journeys.d.ts +351 -111
  33. package/dist/effect/generated/journeys.js +3 -1
  34. package/dist/effect/generated/mailboxes.d.ts +93 -95
  35. package/dist/effect/generated/mailboxes.js +21 -25
  36. package/dist/effect/generated/shared.d.ts +459 -139
  37. package/dist/effect/generated/shared.js +84 -39
  38. package/dist/effect/generated/template-registrations.d.ts +19 -4
  39. package/dist/effect/generated/template-registrations.js +8 -7
  40. package/dist/effect/generated/templates.d.ts +76 -11
  41. package/dist/effect/generated/templates.js +25 -12
  42. package/dist/effect/generated-metadata.d.ts +18 -84
  43. package/dist/effect/generated-metadata.js +362 -415
  44. package/dist/effect/index.d.ts +0 -2
  45. package/dist/effect/index.js +1 -3
  46. package/dist/effect/internal/client.js +1 -1
  47. package/dist/effect/internal/operation.js +4 -1
  48. package/dist/effect/journeys.d.ts +26 -2
  49. package/dist/effect/mailboxes.d.ts +41 -41
  50. package/dist/effect/scheduled-messages.d.ts +350 -350
  51. package/dist/effect/templates.d.ts +9 -0
  52. package/dist/effect/topics.d.ts +2 -2
  53. package/dist/package.js +1 -1
  54. package/dist/promises/client.d.ts +1 -5
  55. package/dist/promises/client.js +3 -7
  56. package/dist/promises/types.gen.d.ts +1 -1
  57. package/dist/service-map.d.ts +18 -75
  58. package/package.json +10 -22
  59. package/dist/effect/descriptors/extension-installations.d.ts +0 -90
  60. package/dist/effect/descriptors/extension-installations.js +0 -90
  61. package/dist/effect/descriptors/extensions.d.ts +0 -50
  62. package/dist/effect/descriptors/extensions.js +0 -50
  63. package/dist/effect/extension-installations.d.ts +0 -132
  64. package/dist/effect/extension-installations.js +0 -29
  65. package/dist/effect/extensions.d.ts +0 -102
  66. package/dist/effect/extensions.js +0 -21
  67. package/dist/effect/generated/extension-installations.d.ts +0 -2761
  68. package/dist/effect/generated/extension-installations.js +0 -405
  69. package/dist/effect/generated/extensions.d.ts +0 -1037
  70. package/dist/effect/generated/extensions.js +0 -214
  71. package/dist/mailbox/dispatch.d.ts +0 -10
  72. package/dist/mailbox/dispatch.js +0 -66
  73. package/dist/mailbox/index.d.ts +0 -17
  74. package/dist/mailbox/index.js +0 -30
  75. package/dist/mailbox/test.d.ts +0 -25
  76. package/dist/mailbox/test.js +0 -181
  77. package/dist/mailbox/types.d.ts +0 -221
  78. package/dist/mailbox/webhook.d.ts +0 -10
  79. package/dist/mailbox/webhook.js +0 -41
@@ -1,214 +0,0 @@
1
- import { ApiKeySecurityMiddleware, ConflictError, ExtensionId, ExtensionVersionId, ExtensionVersionRef, ForbiddenError, GatewayTimeoutError, InternalError, MalformedRequestError, ResourceNotFoundError, UnauthorizedError, ValidationError } from "./shared.js";
2
- import { HttpApiEndpoint, HttpApiGroup, HttpApiSchema, OpenApi } from "effect/http-api";
3
- import * as Schema from "effect/Schema";
4
- // src/effect/generated/extensions.ts
5
- const ExtensionBundle = /* @__PURE__ */ (() => Schema.Struct({
6
- sha256: Schema.String,
7
- sizeBytes: Schema.Finite.check(Schema.isInt().annotate({ expected: "an integer" })).check(Schema.isGreaterThanOrEqualTo(-9007199254740991).annotate({ expected: "a value greater than or equal to -9007199254740991" })).check(Schema.isLessThanOrEqualTo(9007199254740991).annotate({ expected: "a value less than or equal to 9007199254740991" }))
8
- }).annotate({ identifier: "ExtensionBundle" }))();
9
- const ExtensionVersion = /* @__PURE__ */ (() => Schema.Struct({
10
- id: ExtensionVersionId,
11
- version: Schema.String,
12
- runtime: Schema.Union([Schema.Literal("hosted"), Schema.Literal("webhook")]),
13
- bundle: Schema.Union([ExtensionBundle, Schema.Null]),
14
- publishedAt: Schema.String,
15
- manifest: Schema.Struct({
16
- name: Schema.String.check(Schema.isPattern(new globalThis.RegExp("^[a-z][a-z0-9-]{1,62}[a-z0-9]$", "u")).annotate({ expected: "a string matching the RegExp ^[a-z][a-z0-9-]{1,62}[a-z0-9]$" })),
17
- displayName: Schema.String.check(Schema.isMinLength(1).annotate({ expected: "a value with a length of at least 1" })).check(Schema.isMaxCodePoints(80).annotate({ expected: "a string with at most 80 code points" })).check(Schema.isMaxLength(80).annotate({ expected: "a value with a length of at most 80" })),
18
- description: Schema.optionalKey(Schema.Union([Schema.String.check(Schema.isMaxCodePoints(500).annotate({ expected: "a string with at most 500 code points" })).check(Schema.isMaxLength(500).annotate({ expected: "a value with a length of at most 500" })), Schema.Null])),
19
- version: Schema.String.check(Schema.isPattern(new globalThis.RegExp("^\\d{1,6}\\.\\d{1,6}\\.\\d{1,6}(?:-[0-9A-Za-z.-]{1,64})?$", "u")).annotate({ expected: "a string matching the RegExp ^\\d{1,6}\\.\\d{1,6}\\.\\d{1,6}(?:-[0-9A-Za-z.-]{1,64})?$" })),
20
- runtime: Schema.Union([Schema.Literal("hosted"), Schema.Literal("webhook")]),
21
- events: Schema.Array(Schema.Union([
22
- Schema.Literal("mailbox.message.received"),
23
- Schema.Literal("mailbox.message.sent"),
24
- Schema.Literal("mailbox.action.pending_approval"),
25
- Schema.Literal("mailbox.action.resolved"),
26
- Schema.Literal("mailbox.message.quarantined"),
27
- Schema.Literal("mailbox.message.released"),
28
- Schema.Literal("mailbox.message.discarded")
29
- ])).check(Schema.isMinLength(1).annotate({ expected: "a value with a length of at least 1" })),
30
- permissions: Schema.Array(Schema.Union([
31
- Schema.Literal("read"),
32
- Schema.Literal("update"),
33
- Schema.Literal("send"),
34
- Schema.Literal("quarantine.read")
35
- ]))
36
- })
37
- }).annotate({ identifier: "ExtensionVersion" }))();
38
- const ExtensionVersionSummary = /* @__PURE__ */ (() => Schema.Struct({
39
- id: ExtensionVersionId,
40
- version: Schema.String,
41
- runtime: Schema.Union([Schema.Literal("hosted"), Schema.Literal("webhook")]),
42
- bundle: Schema.Union([ExtensionBundle, Schema.Null]),
43
- publishedAt: Schema.String
44
- }).annotate({ identifier: "ExtensionVersionSummary" }))();
45
- const Extension = /* @__PURE__ */ (() => Schema.Struct({
46
- id: ExtensionId,
47
- name: Schema.String,
48
- displayName: Schema.String,
49
- description: Schema.Union([Schema.String, Schema.Null]),
50
- runtime: Schema.Union([Schema.Literal("hosted"), Schema.Literal("webhook")]),
51
- latestVersion: ExtensionVersionRef,
52
- createdAt: Schema.String,
53
- updatedAt: Schema.String
54
- }).annotate({ identifier: "Extension" }))();
55
- const ExtensionVersionPage = /* @__PURE__ */ (() => Schema.Struct({
56
- items: Schema.Array(ExtensionVersionSummary),
57
- nextCursor: Schema.Union([Schema.String, Schema.Null])
58
- }).annotate({ identifier: "ExtensionVersionPage" }))();
59
- const ExtensionPage = /* @__PURE__ */ (() => Schema.Struct({
60
- items: Schema.Array(Extension),
61
- nextCursor: Schema.Union([Schema.String, Schema.Null])
62
- }).annotate({ identifier: "ExtensionPage" }))();
63
- const PublishExtensionVersionResponse = /* @__PURE__ */ (() => Schema.Struct({
64
- extension: Extension,
65
- version: ExtensionVersion
66
- }).annotate({ identifier: "PublishExtensionVersionResponse" }))();
67
- const ExtensionsListQuery = /* @__PURE__ */ (() => Schema.Struct({
68
- limit: Schema.optionalKey(Schema.Union([Schema.Finite.annotate({ description: "Items per page, at most 100." }).check(Schema.isInt().annotate({ expected: "an integer" })).check(Schema.isLessThanOrEqualTo(100).annotate({ expected: "a value less than or equal to 100" })).check(Schema.isGreaterThan(0).annotate({ expected: "a value greater than 0" })), Schema.Null])),
69
- cursor: Schema.optionalKey(Schema.String),
70
- after: Schema.optionalKey(Schema.String),
71
- before: Schema.optionalKey(Schema.String)
72
- }))();
73
- const ExtensionsList200 = ExtensionPage;
74
- const ExtensionsList400 = MalformedRequestError;
75
- const ExtensionsList401 = UnauthorizedError;
76
- const ExtensionsList403 = ForbiddenError;
77
- const ExtensionsList404 = ResourceNotFoundError;
78
- const ExtensionsList422 = ValidationError;
79
- const ExtensionsList500 = InternalError;
80
- const ExtensionsList504 = GatewayTimeoutError;
81
- const ExtensionsPublishRequestJson = /* @__PURE__ */ (() => Schema.Struct({
82
- manifest: Schema.Struct({
83
- name: Schema.String.check(Schema.isPattern(new globalThis.RegExp("^[a-z][a-z0-9-]{1,62}[a-z0-9]$", "u")).annotate({ expected: "a string matching the RegExp ^[a-z][a-z0-9-]{1,62}[a-z0-9]$" })),
84
- displayName: Schema.String.check(Schema.isMinLength(1).annotate({ expected: "a value with a length of at least 1" })).check(Schema.isMaxCodePoints(80).annotate({ expected: "a string with at most 80 code points" })).check(Schema.isMaxLength(80).annotate({ expected: "a value with a length of at most 80" })),
85
- description: Schema.optionalKey(Schema.Union([Schema.String.check(Schema.isMaxCodePoints(500).annotate({ expected: "a string with at most 500 code points" })).check(Schema.isMaxLength(500).annotate({ expected: "a value with a length of at most 500" })), Schema.Null])),
86
- version: Schema.String.check(Schema.isPattern(new globalThis.RegExp("^\\d{1,6}\\.\\d{1,6}\\.\\d{1,6}(?:-[0-9A-Za-z.-]{1,64})?$", "u")).annotate({ expected: "a string matching the RegExp ^\\d{1,6}\\.\\d{1,6}\\.\\d{1,6}(?:-[0-9A-Za-z.-]{1,64})?$" })),
87
- runtime: Schema.Union([Schema.Literal("hosted"), Schema.Literal("webhook")]),
88
- events: Schema.Array(Schema.Union([
89
- Schema.Literal("mailbox.message.received"),
90
- Schema.Literal("mailbox.message.sent"),
91
- Schema.Literal("mailbox.action.pending_approval"),
92
- Schema.Literal("mailbox.action.resolved"),
93
- Schema.Literal("mailbox.message.quarantined"),
94
- Schema.Literal("mailbox.message.released"),
95
- Schema.Literal("mailbox.message.discarded")
96
- ])).check(Schema.isMinLength(1).annotate({ expected: "a value with a length of at least 1" })),
97
- permissions: Schema.Array(Schema.Union([
98
- Schema.Literal("read"),
99
- Schema.Literal("update"),
100
- Schema.Literal("send"),
101
- Schema.Literal("quarantine.read")
102
- ]))
103
- }),
104
- bundle: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null]))
105
- }))();
106
- const ExtensionsPublish201 = PublishExtensionVersionResponse;
107
- const ExtensionsPublish400 = MalformedRequestError;
108
- const ExtensionsPublish401 = UnauthorizedError;
109
- const ExtensionsPublish403 = ForbiddenError;
110
- const ExtensionsPublish404 = ResourceNotFoundError;
111
- const ExtensionsPublish409 = ConflictError;
112
- const ExtensionsPublish422 = ValidationError;
113
- const ExtensionsPublish500 = InternalError;
114
- const ExtensionsPublish504 = GatewayTimeoutError;
115
- const ExtensionsGetPathParams = /* @__PURE__ */ (() => Schema.Struct({ id: Schema.String.annotate({ description: "The extension's id (`ext_…`) or its name." }).check(Schema.isMinLength(1).annotate({ expected: "a value with a length of at least 1" })).check(Schema.isMaxCodePoints(64).annotate({ expected: "a string with at most 64 code points" })).check(Schema.isMaxLength(64).annotate({ expected: "a value with a length of at most 64" })) }))();
116
- const ExtensionsGet200 = Extension;
117
- const ExtensionsGet400 = MalformedRequestError;
118
- const ExtensionsGet401 = UnauthorizedError;
119
- const ExtensionsGet403 = ForbiddenError;
120
- const ExtensionsGet404 = ResourceNotFoundError;
121
- const ExtensionsGet422 = ValidationError;
122
- const ExtensionsGet500 = InternalError;
123
- const ExtensionsGet504 = GatewayTimeoutError;
124
- const ExtensionsListVersionsPathParams = /* @__PURE__ */ (() => Schema.Struct({ id: Schema.String.annotate({ description: "The extension's id (`ext_…`) or its name." }).check(Schema.isMinLength(1).annotate({ expected: "a value with a length of at least 1" })).check(Schema.isMaxCodePoints(64).annotate({ expected: "a string with at most 64 code points" })).check(Schema.isMaxLength(64).annotate({ expected: "a value with a length of at most 64" })) }))();
125
- const ExtensionsListVersionsQuery = /* @__PURE__ */ (() => Schema.Struct({
126
- limit: Schema.optionalKey(Schema.Union([Schema.Finite.annotate({ description: "Items per page, at most 100." }).check(Schema.isInt().annotate({ expected: "an integer" })).check(Schema.isLessThanOrEqualTo(100).annotate({ expected: "a value less than or equal to 100" })).check(Schema.isGreaterThan(0).annotate({ expected: "a value greater than 0" })), Schema.Null])),
127
- cursor: Schema.optionalKey(Schema.String)
128
- }))();
129
- const ExtensionsListVersions200 = ExtensionVersionPage;
130
- const ExtensionsListVersions400 = MalformedRequestError;
131
- const ExtensionsListVersions401 = UnauthorizedError;
132
- const ExtensionsListVersions403 = ForbiddenError;
133
- const ExtensionsListVersions404 = ResourceNotFoundError;
134
- const ExtensionsListVersions422 = ValidationError;
135
- const ExtensionsListVersions500 = InternalError;
136
- const ExtensionsListVersions504 = GatewayTimeoutError;
137
- const ExtensionsGetVersionPathParams = /* @__PURE__ */ (() => Schema.Struct({
138
- id: Schema.String.annotate({ description: "The extension's id (`ext_…`) or its name." }).check(Schema.isMinLength(1).annotate({ expected: "a value with a length of at least 1" })).check(Schema.isMaxCodePoints(64).annotate({ expected: "a string with at most 64 code points" })).check(Schema.isMaxLength(64).annotate({ expected: "a value with a length of at most 64" })),
139
- versionId: Schema.String.annotate({ description: "The version's id (`extver_…`) or its version string, such as `1.0.0`." }).check(Schema.isMinLength(1).annotate({ expected: "a value with a length of at least 1" })).check(Schema.isMaxCodePoints(85).annotate({ expected: "a string with at most 85 code points" })).check(Schema.isMaxLength(85).annotate({ expected: "a value with a length of at most 85" }))
140
- }))();
141
- const ExtensionsGetVersion200 = ExtensionVersion;
142
- const ExtensionsGetVersion400 = MalformedRequestError;
143
- const ExtensionsGetVersion401 = UnauthorizedError;
144
- const ExtensionsGetVersion403 = ForbiddenError;
145
- const ExtensionsGetVersion404 = ResourceNotFoundError;
146
- const ExtensionsGetVersion422 = ValidationError;
147
- const ExtensionsGetVersion500 = InternalError;
148
- const ExtensionsGetVersion504 = GatewayTimeoutError;
149
- var ExtensionsGroup = class extends HttpApiGroup.make("Extensions").add(HttpApiEndpoint.get("extensionsList", "/v1/extensions", {
150
- query: ExtensionsListQuery,
151
- success: ExtensionsList200,
152
- error: [
153
- ExtensionsList400.pipe(HttpApiSchema.status(400)),
154
- ExtensionsList401.pipe(HttpApiSchema.status(401)),
155
- ExtensionsList403.pipe(HttpApiSchema.status(403)),
156
- ExtensionsList404.pipe(HttpApiSchema.status(404)),
157
- ExtensionsList422.pipe(HttpApiSchema.status(422)),
158
- ExtensionsList500,
159
- ExtensionsList504.pipe(HttpApiSchema.status(504))
160
- ]
161
- }).middleware(ApiKeySecurityMiddleware).annotate(OpenApi.Identifier, "extensions.list").annotate(OpenApi.Summary, "List extensions").annotate(OpenApi.Description, "Returns the organization's published extensions with their latest version, newest first, filterable by creation time (`after`, `before`). Pass `nextCursor` back as `cursor` for the next page; it is null on the last page."), HttpApiEndpoint.post("extensionsPublish", "/v1/extensions", {
162
- payload: ExtensionsPublishRequestJson,
163
- success: ExtensionsPublish201.pipe(HttpApiSchema.status(201)),
164
- error: [
165
- ExtensionsPublish400.pipe(HttpApiSchema.status(400)),
166
- ExtensionsPublish401.pipe(HttpApiSchema.status(401)),
167
- ExtensionsPublish403.pipe(HttpApiSchema.status(403)),
168
- ExtensionsPublish404.pipe(HttpApiSchema.status(404)),
169
- ExtensionsPublish409.pipe(HttpApiSchema.status(409)),
170
- ExtensionsPublish422.pipe(HttpApiSchema.status(422)),
171
- ExtensionsPublish500,
172
- ExtensionsPublish504.pipe(HttpApiSchema.status(504))
173
- ]
174
- }).middleware(ApiKeySecurityMiddleware).annotate(OpenApi.Identifier, "extensions.publish").annotate(OpenApi.Summary, "Publish an extension version").annotate(OpenApi.Description, "Publishes one version from its manifest and returns it with status 201, creating the extension named by the manifest on its first version. A hosted manifest carries its bundle. Publishing a version again with the same manifest and bundle returns it; a different one conflicts, so bump the manifest's version. Only a person can publish, not an API key."), HttpApiEndpoint.get("extensionsGet", "/v1/extensions/:id", {
175
- params: ExtensionsGetPathParams,
176
- success: ExtensionsGet200,
177
- error: [
178
- ExtensionsGet400.pipe(HttpApiSchema.status(400)),
179
- ExtensionsGet401.pipe(HttpApiSchema.status(401)),
180
- ExtensionsGet403.pipe(HttpApiSchema.status(403)),
181
- ExtensionsGet404.pipe(HttpApiSchema.status(404)),
182
- ExtensionsGet422.pipe(HttpApiSchema.status(422)),
183
- ExtensionsGet500,
184
- ExtensionsGet504.pipe(HttpApiSchema.status(504))
185
- ]
186
- }).middleware(ApiKeySecurityMiddleware).annotate(OpenApi.Identifier, "extensions.get").annotate(OpenApi.Summary, "Get an extension").annotate(OpenApi.Description, "Returns one extension by its id or name. Its versions are `GET /v1/extensions/{id}/versions`."), HttpApiEndpoint.get("extensionsListVersions", "/v1/extensions/:id/versions", {
187
- params: ExtensionsListVersionsPathParams,
188
- query: ExtensionsListVersionsQuery,
189
- success: ExtensionsListVersions200,
190
- error: [
191
- ExtensionsListVersions400.pipe(HttpApiSchema.status(400)),
192
- ExtensionsListVersions401.pipe(HttpApiSchema.status(401)),
193
- ExtensionsListVersions403.pipe(HttpApiSchema.status(403)),
194
- ExtensionsListVersions404.pipe(HttpApiSchema.status(404)),
195
- ExtensionsListVersions422.pipe(HttpApiSchema.status(422)),
196
- ExtensionsListVersions500,
197
- ExtensionsListVersions504.pipe(HttpApiSchema.status(504))
198
- ]
199
- }).middleware(ApiKeySecurityMiddleware).annotate(OpenApi.Identifier, "extensions.listVersions").annotate(OpenApi.Summary, "List an extension's versions").annotate(OpenApi.Description, "Returns summaries of an extension's published versions, newest first. Pass `nextCursor` back as `cursor` for the next page; it is null on the last page. Read a version's manifest with `GET /v1/extensions/{id}/versions/{versionId}`."), HttpApiEndpoint.get("extensionsGetVersion", "/v1/extensions/:id/versions/:versionId", {
200
- params: ExtensionsGetVersionPathParams,
201
- success: ExtensionsGetVersion200,
202
- error: [
203
- ExtensionsGetVersion400.pipe(HttpApiSchema.status(400)),
204
- ExtensionsGetVersion401.pipe(HttpApiSchema.status(401)),
205
- ExtensionsGetVersion403.pipe(HttpApiSchema.status(403)),
206
- ExtensionsGetVersion404.pipe(HttpApiSchema.status(404)),
207
- ExtensionsGetVersion422.pipe(HttpApiSchema.status(422)),
208
- ExtensionsGetVersion500,
209
- ExtensionsGetVersion504.pipe(HttpApiSchema.status(504))
210
- ]
211
- }).middleware(ApiKeySecurityMiddleware).annotate(OpenApi.Identifier, "extensions.getVersion").annotate(OpenApi.Summary, "Get an extension version").annotate(OpenApi.Description, "Returns one version, by its id or version string, with the manifest it was published with.")).annotate(OpenApi.Description, "Code that receives mailbox events and acts through the mailbox API") {};
212
- export { Extension, ExtensionBundle, ExtensionPage, ExtensionVersion, ExtensionVersionPage, ExtensionVersionSummary, ExtensionsGet200, ExtensionsGet400, ExtensionsGet401, ExtensionsGet403, ExtensionsGet404, ExtensionsGet422, ExtensionsGet500, ExtensionsGet504, ExtensionsGetPathParams, ExtensionsGetVersion200, ExtensionsGetVersion400, ExtensionsGetVersion401, ExtensionsGetVersion403, ExtensionsGetVersion404, ExtensionsGetVersion422, ExtensionsGetVersion500, ExtensionsGetVersion504, ExtensionsGetVersionPathParams, ExtensionsGroup, ExtensionsList200, ExtensionsList400, ExtensionsList401, ExtensionsList403, ExtensionsList404, ExtensionsList422, ExtensionsList500, ExtensionsList504, ExtensionsListQuery, ExtensionsListVersions200, ExtensionsListVersions400, ExtensionsListVersions401, ExtensionsListVersions403, ExtensionsListVersions404, ExtensionsListVersions422, ExtensionsListVersions500, ExtensionsListVersions504, ExtensionsListVersionsPathParams, ExtensionsListVersionsQuery, ExtensionsPublish201, ExtensionsPublish400, ExtensionsPublish401, ExtensionsPublish403, ExtensionsPublish404, ExtensionsPublish409, ExtensionsPublish422, ExtensionsPublish500, ExtensionsPublish504, ExtensionsPublishRequestJson, PublishExtensionVersionResponse };
213
-
214
- //# sourceMappingURL=extensions.js.map
@@ -1,10 +0,0 @@
1
- import { type SamvaClient } from "../promises/client.js";
2
- import type { DispatchResult, ExtensionDefinition, Invocation } from "./types.js";
3
- declare const errorMessage: (error: unknown) => string;
4
- export { errorMessage };
5
- /**
6
- * A run's log is the lines its handler writes with `log()`. The global console is left alone:
7
- * patching it would make concurrent runs in one isolate share it, and a handler that never settles
8
- * would hold it.
9
- */
10
- export declare function dispatchEvent(extension: ExtensionDefinition, invocation: Invocation, client: SamvaClient): Promise<DispatchResult>;
@@ -1,66 +0,0 @@
1
- import { clientWithIdempotency } from "../promises/client.js";
2
- // src/mailbox/dispatch.ts
3
- const sendKeyMethods = {
4
- mailboxesReply: "reply",
5
- mailboxesReplyAll: "replyAll",
6
- mailboxesForward: "forward",
7
- mailboxesSendMessage: "send"
8
- };
9
- const errorMessage = (error) => error instanceof Error ? error.message : String(error);
10
- /**
11
- * A run's log is the lines its handler writes with `log()`. The global console is left alone:
12
- * patching it would make concurrent runs in one isolate share it, and a handler that never settles
13
- * would hold it.
14
- */
15
- async function dispatchEvent(extension, invocation, client) {
16
- const logs = [];
17
- const log = (...args) => {
18
- logs.push(args.map((arg) => {
19
- if (typeof arg === "string") return arg;
20
- try {
21
- return JSON.stringify(arg) ?? String(arg);
22
- } catch {
23
- return String(arg);
24
- }
25
- }).join(" "));
26
- };
27
- try {
28
- if (typeof invocation.eventId !== "string" || !Number.isInteger(invocation.attempt) || invocation.attempt < 1 || typeof invocation.body !== "string") throw new Error("Invalid extension invocation");
29
- const payload = JSON.parse(invocation.body);
30
- if (typeof payload !== "object" || payload === null || !("type" in payload) || typeof payload.type !== "string" || !("timestamp" in payload) || typeof payload.timestamp !== "string" || !("data" in payload) || typeof payload.data !== "object" || payload.data === null) throw new Error("Invalid extension event envelope");
31
- if (!Object.hasOwn(extension.on, payload.type)) return {
32
- ok: true,
33
- logs
34
- };
35
- const event = {
36
- ...payload,
37
- id: invocation.eventId
38
- };
39
- const handler = extension.on[event.type];
40
- const counts = /* @__PURE__ */ new Map();
41
- await handler?.(event, {
42
- samva: clientWithIdempotency(client, (operation) => {
43
- const method = sendKeyMethods[operation] ?? operation;
44
- const n = (counts.get(method) ?? 0) + 1;
45
- counts.set(method, n);
46
- return `${event.id}:${method}:${n}`;
47
- }),
48
- log,
49
- event,
50
- attempt: invocation.attempt
51
- });
52
- return {
53
- ok: true,
54
- logs
55
- };
56
- } catch (error) {
57
- return {
58
- ok: false,
59
- error: errorMessage(error),
60
- logs
61
- };
62
- }
63
- }
64
- export { dispatchEvent, errorMessage };
65
-
66
- //# sourceMappingURL=dispatch.js.map
@@ -1,17 +0,0 @@
1
- import { createBoundClient } from "../promises/client.js";
2
- import type { ExtensionDefinition, ExtensionManifest } from "./types.js";
3
- type Fetch = NonNullable<Parameters<typeof createBoundClient>[0]["fetch"]>;
4
- export * from "./types.js";
5
- export { dispatchEvent } from "./dispatch.js";
6
- export declare function defineExtension<const M extends ExtensionManifest>(definition: {
7
- manifest: M;
8
- on: ExtensionDefinition<M["events"][number]>["on"];
9
- }): {
10
- manifest: M;
11
- on: ExtensionDefinition<M["events"][number]>["on"];
12
- fetch(request: Request, env: {
13
- SAMVA: {
14
- fetch: Fetch;
15
- };
16
- }): Promise<Response>;
17
- };
@@ -1,30 +0,0 @@
1
- import { createBoundClient } from "../promises/client.js";
2
- import { dispatchEvent, errorMessage } from "./dispatch.js";
3
- // src/mailbox/index.ts
4
- function defineExtension(definition) {
5
- for (const key of Object.keys(definition.on)) if (!definition.manifest.events.includes(key)) throw new Error(`Handler ${key} is not listed in manifest.events`);
6
- if (!definition.manifest.permissions.includes("read")) throw new Error("An extension requires the read permission");
7
- return {
8
- ...definition,
9
- async fetch(request, env) {
10
- try {
11
- if (request.method !== "POST") throw new Error("Hosted invocations require POST");
12
- const invocation = await request.json();
13
- const client = createBoundClient({
14
- fetch: env.SAMVA.fetch.bind(env.SAMVA),
15
- baseUrl: "https://api.samva.dev"
16
- });
17
- return Response.json(await dispatchEvent(definition, invocation, client));
18
- } catch (error) {
19
- return Response.json({
20
- ok: false,
21
- error: errorMessage(error),
22
- logs: []
23
- });
24
- }
25
- }
26
- };
27
- }
28
- export { defineExtension, dispatchEvent };
29
-
30
- //# sourceMappingURL=index.js.map
@@ -1,25 +0,0 @@
1
- import { type SamvaClient } from "../promises/client.js";
2
- import type { EventData, EventType, ExtensionDefinition, ExtensionEvent } from "./types.js";
3
- export interface RecordedCall {
4
- method: string;
5
- path: string;
6
- body: unknown;
7
- idempotencyKey: string | null;
8
- }
9
- /** Canned responses are keyed by `METHOD /path`. */
10
- export declare function createTestClient(responses?: Record<string, unknown>): SamvaClient & {
11
- calls: RecordedCall[];
12
- };
13
- export declare function runExtension(extension: ExtensionDefinition, event: ExtensionEvent, options?: {
14
- client?: SamvaClient & {
15
- calls?: RecordedCall[];
16
- };
17
- attempt?: number;
18
- }): Promise<{
19
- ok: boolean;
20
- logs: readonly string[];
21
- error: string | undefined;
22
- calls: RecordedCall[];
23
- }>;
24
- /** Top-level data overrides replace the corresponding fixture field. */
25
- export declare function mailboxEvent<T extends EventType>(type: T, overrides?: Partial<EventData[T]>): ExtensionEvent<T>;
@@ -1,181 +0,0 @@
1
- import { createBoundClient } from "../promises/client.js";
2
- import { dispatchEvent } from "./dispatch.js";
3
- // src/mailbox/test.ts
4
- /** Canned responses are keyed by `METHOD /path`. */
5
- function createTestClient(responses = {}) {
6
- const calls = [];
7
- const client = createBoundClient({
8
- baseUrl: "https://api.samva.dev",
9
- async fetch(input, init) {
10
- const request = new Request(input, init);
11
- const url = new URL(request.url);
12
- const path = url.pathname + url.search;
13
- const text = await request.text();
14
- calls.push({
15
- method: request.method,
16
- path,
17
- body: text ? JSON.parse(text) : void 0,
18
- idempotencyKey: request.headers.get("idempotency-key")
19
- });
20
- const response = responses[`${request.method} ${path}`];
21
- return Response.json(response ?? {});
22
- }
23
- });
24
- return Object.assign(client, { calls });
25
- }
26
- async function runExtension(extension, event, options = {}) {
27
- const client = options.client ?? createTestClient();
28
- const start = client.calls?.length ?? 0;
29
- const { id, ...body } = event;
30
- const result = await dispatchEvent(extension, {
31
- eventId: id,
32
- attempt: options.attempt ?? 1,
33
- body: JSON.stringify(body)
34
- }, client);
35
- return {
36
- ...result,
37
- error: result.error,
38
- calls: client.calls?.slice(start) ?? []
39
- };
40
- }
41
- const timestamp = "2026-01-01T00:00:00.000Z";
42
- const message = {
43
- id: "msg_0000000000000000",
44
- channel: "email",
45
- threadId: "thread_0000000000000000",
46
- from: { address: "sender@example.com" },
47
- to: ["inbox@example.com"],
48
- cc: [],
49
- subject: "Hello",
50
- text: "Hello",
51
- replyText: "Hello",
52
- attachments: [],
53
- occurredAt: timestamp
54
- };
55
- const actor = {
56
- kind: "extension",
57
- id: "exti_0000000000000000",
58
- source: "extension"
59
- };
60
- const thread = {
61
- id: message.threadId,
62
- endpointId: "mbxep_0000000000000000",
63
- subject: "Hello",
64
- preview: "Hello"
65
- };
66
- const common = {
67
- mailboxId: "mbx_0000000000000000",
68
- namespaceId: null
69
- };
70
- const fixtures = {
71
- "mailbox.message.received": {
72
- ...common,
73
- message,
74
- thread
75
- },
76
- "mailbox.message.sent": {
77
- ...common,
78
- state: "completed",
79
- acceptedAt: timestamp,
80
- message,
81
- actor,
82
- actionId: "mbxact_0000000000000000"
83
- },
84
- "mailbox.action.pending_approval": {
85
- ...common,
86
- action: {
87
- state: "approvalRequired",
88
- reviewRound: 1,
89
- decision: {
90
- id: "pdec_0000000000000000",
91
- reviewRound: 1,
92
- requirement: "person",
93
- decider: "person",
94
- outcome: "hold",
95
- reason: "Approval required",
96
- scopes: [{
97
- kind: "mailbox",
98
- id: common.mailboxId
99
- }]
100
- },
101
- id: "mbxact_0000000000000000",
102
- type: "sendMessage",
103
- threadId: message.threadId,
104
- reason: null,
105
- proposedBy: actor,
106
- createdAt: timestamp
107
- },
108
- draft: {
109
- to: message.to,
110
- cc: [],
111
- subject: "Hello"
112
- }
113
- },
114
- "mailbox.action.resolved": {
115
- ...common,
116
- action: {
117
- id: "mbxact_0000000000000000",
118
- type: "sendMessage",
119
- reviewRound: 1,
120
- threadId: message.threadId,
121
- proposedBy: actor,
122
- createdAt: timestamp
123
- },
124
- resolution: {
125
- outcome: "approved",
126
- actor: {
127
- kind: "user",
128
- id: "user_0000000000000000",
129
- source: "humanUi"
130
- },
131
- resolvedAt: timestamp,
132
- reason: null
133
- }
134
- },
135
- "mailbox.message.quarantined": {
136
- ...common,
137
- disposition: "quarantined",
138
- reason: "spam",
139
- source: "receipt",
140
- message: {
141
- id: message.id,
142
- from: message.from,
143
- subject: message.subject,
144
- receivedAt: timestamp
145
- }
146
- },
147
- "mailbox.message.released": {
148
- ...common,
149
- message,
150
- thread,
151
- releasedBy: actor,
152
- reason: "spam"
153
- },
154
- "mailbox.message.discarded": {
155
- ...common,
156
- discardedBy: actor,
157
- disposition: "quarantined",
158
- reason: "spam",
159
- message: {
160
- id: message.id,
161
- from: message.from,
162
- subject: message.subject,
163
- receivedAt: timestamp
164
- }
165
- }
166
- };
167
- /** Top-level data overrides replace the corresponding fixture field. */
168
- function mailboxEvent(type, overrides = {}) {
169
- return {
170
- id: "whevt_0000000000000000",
171
- type,
172
- timestamp,
173
- data: {
174
- ...structuredClone(fixtures[type]),
175
- ...overrides
176
- }
177
- };
178
- }
179
- export { createTestClient, mailboxEvent, runExtension };
180
-
181
- //# sourceMappingURL=test.js.map