@superdurable/connector-google-gmail 0.1.0 → 0.1.1

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.
@@ -31,67 +31,103 @@ __export(mock_exports, {
31
31
  getMessageRetry: () => getMessageRetry,
32
32
  getMessageRevokedGrant: () => getMessageRevokedGrant,
33
33
  replyToMessageBranch: () => replyToMessageBranch,
34
- replyToMessageConnectionLost: () => replyToMessageConnectionLost,
35
- replyToMessageDefault: () => replyToMessageDefault,
36
- replyToMessageEmptyBody: () => replyToMessageEmptyBody,
37
- replyToMessageMalformedSource: () => replyToMessageMalformedSource,
38
- replyToMessageRepliedInThread: () => replyToMessageRepliedInThread,
34
+ replyToMessageConnectionLost: () => replyToMessageConnectionLost2,
35
+ replyToMessageDefault: () => replyToMessageDefault2,
36
+ replyToMessageEmptyBody: () => replyToMessageEmptyBody2,
37
+ replyToMessageMalformedSource: () => replyToMessageMalformedSource2,
38
+ replyToMessageRepliedInThread: () => replyToMessageRepliedInThread2,
39
39
  replyToMessageRetry: () => replyToMessageRetry,
40
- replyToMessageSourceMissing: () => replyToMessageSourceMissing,
40
+ replyToMessageSourceMissing: () => replyToMessageSourceMissing2,
41
41
  sendMessageBranch: () => sendMessageBranch,
42
- sendMessageConnectionLost: () => sendMessageConnectionLost,
43
- sendMessageDefault: () => sendMessageDefault,
44
- sendMessageInvalidRecipient: () => sendMessageInvalidRecipient,
45
- sendMessageNoRecipients: () => sendMessageNoRecipients,
42
+ sendMessageConnectionLost: () => sendMessageConnectionLost2,
43
+ sendMessageDefault: () => sendMessageDefault2,
44
+ sendMessageInvalidRecipient: () => sendMessageInvalidRecipient2,
45
+ sendMessageNoRecipients: () => sendMessageNoRecipients2,
46
46
  sendMessageRetry: () => sendMessageRetry,
47
- sendMessageSentToCustomer: () => sendMessageSentToCustomer,
48
- sendMessageUnavailable: () => sendMessageUnavailable
47
+ sendMessageSentToCustomer: () => sendMessageSentToCustomer2,
48
+ sendMessageUnavailable: () => sendMessageUnavailable2
49
49
  });
50
50
  module.exports = __toCommonJS(mock_exports);
51
- var import_connectormock = require("@superdurable/connectors-sdk/connectormock");
51
+ var import_connectormock2 = require("@superdurable/connectors-sdk/connectormock");
52
52
 
53
53
  // src/models.ts
54
+ var import_zod2 = require("zod");
55
+
56
+ // src/generated/models.ts
54
57
  var import_zod = require("zod");
55
- var ConnectorID = "gmail";
56
- var GetMessageInputSchema = import_zod.z.strictObject({ messageId: import_zod.z.string() });
57
- var SendMessageInputSchema = import_zod.z.strictObject({
58
- to: import_zod.z.array(import_zod.z.string()),
59
- subject: import_zod.z.string(),
60
- textBody: import_zod.z.string(),
61
- htmlBody: import_zod.z.string().optional()
58
+ var ConfigSchema = import_zod.z.object({
59
+ "endpoint": import_zod.z.string().optional(),
60
+ "maxResponseBytes": import_zod.z.number().int().optional(),
61
+ "maxMessageBytes": import_zod.z.number().int().optional(),
62
+ "pollIntervalMs": import_zod.z.number().int().optional(),
63
+ "pollPageSize": import_zod.z.number().int().optional()
62
64
  });
63
- var ReplyToMessageInputSchema = import_zod.z.strictObject({
64
- messageId: import_zod.z.string(),
65
- textBody: import_zod.z.string(),
66
- htmlBody: import_zod.z.string().optional()
65
+ var GetMessageInputSchema = import_zod.z.strictObject({
66
+ "messageId": import_zod.z.string()
67
67
  });
68
68
  var MessageSchema = import_zod.z.strictObject({
69
- messageId: import_zod.z.string(),
70
- threadId: import_zod.z.string(),
71
- rfcMessageId: import_zod.z.string().optional(),
72
- inReplyTo: import_zod.z.string().optional(),
73
- references: import_zod.z.string().optional(),
74
- from: import_zod.z.string(),
75
- replyTo: import_zod.z.string().optional(),
76
- to: import_zod.z.array(import_zod.z.string()).optional(),
77
- subject: import_zod.z.string(),
78
- textBody: import_zod.z.string().optional(),
79
- htmlBody: import_zod.z.string().optional(),
80
- snippet: import_zod.z.string().optional(),
81
- receivedAt: import_zod.z.iso.datetime({ offset: true }),
82
- labelIds: import_zod.z.array(import_zod.z.string()).optional()
69
+ "messageId": import_zod.z.string(),
70
+ "threadId": import_zod.z.string(),
71
+ "rfcMessageId": import_zod.z.string().optional(),
72
+ "inReplyTo": import_zod.z.string().optional(),
73
+ "references": import_zod.z.string().optional(),
74
+ "from": import_zod.z.string(),
75
+ "replyTo": import_zod.z.string().optional(),
76
+ "to": import_zod.z.array(import_zod.z.string()).optional(),
77
+ "subject": import_zod.z.string(),
78
+ "textBody": import_zod.z.string().optional(),
79
+ "htmlBody": import_zod.z.string().optional(),
80
+ "snippet": import_zod.z.string().optional(),
81
+ "receivedAt": import_zod.z.iso.datetime({ offset: true }),
82
+ "labelIds": import_zod.z.array(import_zod.z.string()).optional()
83
+ });
84
+ var SendMessageInputSchema = import_zod.z.strictObject({
85
+ "to": import_zod.z.array(import_zod.z.string()).nullable(),
86
+ "subject": import_zod.z.string(),
87
+ "textBody": import_zod.z.string(),
88
+ "htmlBody": import_zod.z.string().optional()
83
89
  });
84
90
  var SendMessageOutputSchema = import_zod.z.strictObject({
85
- sender: import_zod.z.string(),
86
- recipients: import_zod.z.array(import_zod.z.string()),
87
- messageId: import_zod.z.string(),
88
- threadId: import_zod.z.string()
91
+ "sender": import_zod.z.string(),
92
+ "recipients": import_zod.z.array(import_zod.z.string()).nullable(),
93
+ "messageId": import_zod.z.string(),
94
+ "threadId": import_zod.z.string()
95
+ });
96
+ var ReplyToMessageInputSchema = import_zod.z.strictObject({
97
+ "messageId": import_zod.z.string(),
98
+ "textBody": import_zod.z.string(),
99
+ "htmlBody": import_zod.z.string().optional()
100
+ });
101
+
102
+ // src/models.ts
103
+ var SendMessageInputSchema2 = import_zod2.z.strictObject({
104
+ to: import_zod2.z.array(import_zod2.z.string()),
105
+ subject: import_zod2.z.string(),
106
+ textBody: import_zod2.z.string(),
107
+ htmlBody: import_zod2.z.string().optional()
108
+ });
109
+ var SendMessageOutputSchema2 = import_zod2.z.strictObject({
110
+ sender: import_zod2.z.string(),
111
+ recipients: import_zod2.z.array(import_zod2.z.string()),
112
+ messageId: import_zod2.z.string(),
113
+ threadId: import_zod2.z.string()
89
114
  });
90
115
 
91
- // src/definitions.ts
92
- var GetMessageBranch = { Read: "read", NotFound: "notFound", ProviderRejected: "providerRejected", InvalidResponse: "invalidResponse", Defect: "defect" };
93
- var SendMessageBranch = { Sent: "sent", ProviderRejected: "providerRejected", Defect: "defect" };
94
- var ReplyToMessageBranch = { Sent: "sent", ProviderRejected: "providerRejected", InvalidResponse: "invalidResponse", Defect: "defect" };
116
+ // src/generated/definitions.ts
117
+ var ConnectorID = "gmail";
118
+ var ProviderID = "google";
119
+ var GetMessageBranch = {
120
+ Read: "read",
121
+ NotFound: "notFound",
122
+ ProviderRejected: "providerRejected",
123
+ InvalidResponse: "invalidResponse",
124
+ Defect: "defect"
125
+ };
126
+ var GetMessageBranchRead = GetMessageBranch.Read;
127
+ var GetMessageBranchNotFound = GetMessageBranch.NotFound;
128
+ var GetMessageBranchProviderRejected = GetMessageBranch.ProviderRejected;
129
+ var GetMessageBranchInvalidResponse = GetMessageBranch.InvalidResponse;
130
+ var GetMessageBranchDefect = GetMessageBranch.Defect;
95
131
  var GetMessageDefinition = {
96
132
  operation: { connectorId: ConnectorID, operationId: "getMessage" },
97
133
  branches: [
@@ -103,6 +139,14 @@ var GetMessageDefinition = {
103
139
  ],
104
140
  stepDefaults: { executeMethodTimeoutMs: 3e4, executeDurability: "async" }
105
141
  };
142
+ var SendMessageBranch = {
143
+ Sent: "sent",
144
+ ProviderRejected: "providerRejected",
145
+ Defect: "defect"
146
+ };
147
+ var SendMessageBranchSent = SendMessageBranch.Sent;
148
+ var SendMessageBranchProviderRejected = SendMessageBranch.ProviderRejected;
149
+ var SendMessageBranchDefect = SendMessageBranch.Defect;
106
150
  var SendMessageDefinition = {
107
151
  operation: { connectorId: ConnectorID, operationId: "sendMessage" },
108
152
  branches: [
@@ -110,14 +154,18 @@ var SendMessageDefinition = {
110
154
  { id: "providerRejected", description: "Gmail conclusively rejected the message.", optional: true },
111
155
  { id: "defect", description: "Local input, connection configuration, or connector definition is invalid.", optional: true }
112
156
  ],
113
- stepDefaults: { executeMethodTimeoutMs: 3e4, executeDurability: "async", executeRetry: {
114
- initialIntervalMs: 1e3,
115
- backoffCoefficient: 2,
116
- maximumIntervalMs: 3e4,
117
- maximumAttempts: 5,
118
- totalDurationMs: 12e4
119
- } }
157
+ stepDefaults: { executeMethodTimeoutMs: 3e4, executeDurability: "sync", executeRetry: { initialIntervalMs: 1e3, backoffCoefficient: 2, maximumIntervalMs: 3e4, maximumAttempts: 5, totalDurationMs: 12e4 } }
120
158
  };
159
+ var ReplyToMessageBranch = {
160
+ Sent: "sent",
161
+ ProviderRejected: "providerRejected",
162
+ InvalidResponse: "invalidResponse",
163
+ Defect: "defect"
164
+ };
165
+ var ReplyToMessageBranchSent = ReplyToMessageBranch.Sent;
166
+ var ReplyToMessageBranchProviderRejected = ReplyToMessageBranch.ProviderRejected;
167
+ var ReplyToMessageBranchInvalidResponse = ReplyToMessageBranch.InvalidResponse;
168
+ var ReplyToMessageBranchDefect = ReplyToMessageBranch.Defect;
121
169
  var ReplyToMessageDefinition = {
122
170
  operation: { connectorId: ConnectorID, operationId: "replyToMessage" },
123
171
  branches: [
@@ -126,30 +174,24 @@ var ReplyToMessageDefinition = {
126
174
  { id: "invalidResponse", description: "Gmail returned an invalid or oversized source message response before sending the reply.", optional: true },
127
175
  { id: "defect", description: "Local input, connection configuration, or connector definition is invalid.", optional: true }
128
176
  ],
129
- stepDefaults: { executeMethodTimeoutMs: 3e4, executeDurability: "async", executeRetry: {
130
- initialIntervalMs: 1e3,
131
- backoffCoefficient: 2,
132
- maximumIntervalMs: 3e4,
133
- maximumAttempts: 5,
134
- totalDurationMs: 12e4
135
- } }
177
+ stepDefaults: { executeMethodTimeoutMs: 3e4, executeDurability: "sync", executeRetry: { initialIntervalMs: 1e3, backoffCoefficient: 2, maximumIntervalMs: 3e4, maximumAttempts: 5, totalDurationMs: 12e4 } }
136
178
  };
137
179
 
138
180
  // src/message.ts
139
181
  var import_node_crypto = require("crypto");
140
- var import_zod2 = require("zod");
141
- var GmailMessagePartSchema = import_zod2.z.lazy(() => import_zod2.z.object({
142
- mimeType: import_zod2.z.string().nullish(),
143
- headers: import_zod2.z.array(import_zod2.z.object({ name: import_zod2.z.string(), value: import_zod2.z.string() })).nullish(),
144
- body: import_zod2.z.object({ data: import_zod2.z.string().nullish() }).nullish(),
145
- parts: import_zod2.z.array(GmailMessagePartSchema).nullish()
182
+ var import_zod3 = require("zod");
183
+ var GmailMessagePartSchema = import_zod3.z.lazy(() => import_zod3.z.object({
184
+ mimeType: import_zod3.z.string().nullish(),
185
+ headers: import_zod3.z.array(import_zod3.z.object({ name: import_zod3.z.string(), value: import_zod3.z.string() })).nullish(),
186
+ body: import_zod3.z.object({ data: import_zod3.z.string().nullish() }).nullish(),
187
+ parts: import_zod3.z.array(GmailMessagePartSchema).nullish()
146
188
  }));
147
- var GmailMessageResourceSchema = import_zod2.z.object({
148
- id: import_zod2.z.string().nullish().transform((value) => value ?? ""),
149
- threadId: import_zod2.z.string().nullish().transform((value) => value ?? ""),
150
- labelIds: import_zod2.z.array(import_zod2.z.string()).nullish(),
151
- snippet: import_zod2.z.string().nullish(),
152
- internalDate: import_zod2.z.string().nullish(),
189
+ var GmailMessageResourceSchema = import_zod3.z.object({
190
+ id: import_zod3.z.string().nullish().transform((value) => value ?? ""),
191
+ threadId: import_zod3.z.string().nullish().transform((value) => value ?? ""),
192
+ labelIds: import_zod3.z.array(import_zod3.z.string()).nullish(),
193
+ snippet: import_zod3.z.string().nullish(),
194
+ internalDate: import_zod3.z.string().nullish(),
153
195
  payload: GmailMessagePartSchema.nullish()
154
196
  });
155
197
 
@@ -158,15 +200,15 @@ var import_connectors_sdk = require("@superdurable/connectors-sdk");
158
200
  var import_providerhttp = require("@superdurable/connectors-sdk/providerhttp");
159
201
 
160
202
  // src/provider.ts
161
- var import_zod3 = require("zod");
162
- var SentMessageSchema = import_zod3.z.object({ id: import_zod3.z.string().optional(), threadId: import_zod3.z.string().optional() });
163
- var SentSearchSchema = import_zod3.z.object({ messages: import_zod3.z.array(SentMessageSchema).nullish() });
203
+ var import_zod4 = require("zod");
204
+ var SentMessageSchema = import_zod4.z.object({ id: import_zod4.z.string().optional(), threadId: import_zod4.z.string().optional() });
205
+ var SentSearchSchema = import_zod4.z.object({ messages: import_zod4.z.array(SentMessageSchema).nullish() });
164
206
 
165
207
  // src/refresh.ts
166
208
  var import_connectors_sdk2 = require("@superdurable/connectors-sdk");
167
209
  var import_oauthtoken = require("@superdurable/connectors-sdk/oauthtoken");
168
- var import_zod4 = require("zod");
169
- var ServiceAccountKeySchema = import_zod4.z.object({ client_email: import_zod4.z.string().min(1), private_key: import_zod4.z.string().min(1), token_uri: import_zod4.z.url() });
210
+ var import_zod5 = require("zod");
211
+ var ServiceAccountKeySchema = import_zod5.z.object({ client_email: import_zod5.z.string().min(1), private_key: import_zod5.z.string().min(1), token_uri: import_zod5.z.url() });
170
212
 
171
213
  // src/send.ts
172
214
  var import_connectors_sdk3 = require("@superdurable/connectors-sdk");
@@ -193,61 +235,167 @@ var import_connectors_sdk4 = require("@superdurable/connectors-sdk");
193
235
  var import_providerhttp3 = require("@superdurable/connectors-sdk/providerhttp");
194
236
 
195
237
  // src/connection.ts
238
+ var import_connectors_sdk6 = require("@superdurable/connectors-sdk");
239
+
240
+ // src/generated/connection.ts
196
241
  var import_connectors_sdk5 = require("@superdurable/connectors-sdk");
197
- var GmailConnection = class {
198
- /** Stable logical credential reference. */
242
+ var Connection = class {
243
+ /** Stable provider and connection name. */
199
244
  reference;
200
- /** Provider or mock operation implementations. */
245
+ /** Bound provider operations. */
201
246
  operations;
247
+ /** Validate a reference and bind operations. */
248
+ constructor(reference, operations) {
249
+ this.reference = import_connectors_sdk5.ConnectionRefSchema.parse(reference);
250
+ if (this.reference.provider !== ProviderID) throw new TypeError("connection provider differs from the manifest");
251
+ if (!operations) throw new TypeError("connector operations are required");
252
+ this.operations = operations;
253
+ }
254
+ };
255
+
256
+ // src/connection.ts
257
+ var GmailConnection = class extends Connection {
202
258
  /** Bind operation implementations to a static named Google connection. */
203
259
  constructor(operations, reference) {
204
260
  if (!operations) throw new TypeError("Gmail connector operations are required");
205
- this.reference = import_connectors_sdk5.ConnectionRefSchema.parse(reference);
206
- if (this.reference.provider !== "google") throw new TypeError("Gmail connection provider must be google");
207
- this.operations = operations;
261
+ const validatedReference = import_connectors_sdk6.ConnectionRefSchema.parse(reference);
262
+ if (validatedReference.provider !== "google") throw new TypeError("Gmail connection provider must be google");
263
+ super(validatedReference, operations);
208
264
  }
209
265
  };
210
266
 
211
267
  // src/project.ts
212
- var import_connectors_sdk7 = require("@superdurable/connectors-sdk");
268
+ var import_connectors_sdk8 = require("@superdurable/connectors-sdk");
213
269
  var import_projectconfig = require("@superdurable/connectors-sdk/projectconfig");
214
- var import_zod6 = require("zod");
270
+ var import_zod7 = require("zod");
215
271
 
216
272
  // src/credential_codec.ts
217
- var import_connectors_sdk6 = require("@superdurable/connectors-sdk");
218
- var import_zod5 = require("zod");
219
- var StoredCredentialsSchema = import_zod5.z.object({
220
- auth_method: import_zod5.z.string().optional(),
221
- oauth_client_id: import_zod5.z.string().optional(),
222
- oauth_client_secret: import_zod5.z.string().optional(),
223
- access_token: import_zod5.z.string().optional(),
224
- refresh_token: import_zod5.z.string().optional(),
225
- primary_email: import_zod5.z.string().optional(),
226
- service_account_key: import_zod5.z.string().optional(),
227
- delegated_user: import_zod5.z.string().optional()
273
+ var import_connectors_sdk7 = require("@superdurable/connectors-sdk");
274
+ var import_zod6 = require("zod");
275
+ var StoredCredentialsSchema = import_zod6.z.object({
276
+ auth_method: import_zod6.z.string().optional(),
277
+ oauth_client_id: import_zod6.z.string().optional(),
278
+ oauth_client_secret: import_zod6.z.string().optional(),
279
+ access_token: import_zod6.z.string().optional(),
280
+ refresh_token: import_zod6.z.string().optional(),
281
+ primary_email: import_zod6.z.string().optional(),
282
+ service_account_key: import_zod6.z.string().optional(),
283
+ delegated_user: import_zod6.z.string().optional()
228
284
  });
229
285
 
230
286
  // src/project.ts
231
- var ProjectGmailConfigurationSchema = import_zod6.z.object({
232
- endpoint: import_zod6.z.string().optional(),
233
- maxResponseBytes: import_zod6.z.number().int().safe().optional(),
234
- maxMessageBytes: import_zod6.z.number().int().safe().optional(),
235
- pollInterval: import_zod6.z.number().int().safe().optional(),
236
- pollPageSize: import_zod6.z.number().int().safe().optional()
287
+ var ProjectGmailConfigurationSchema = import_zod7.z.object({
288
+ endpoint: import_zod7.z.string().optional(),
289
+ maxResponseBytes: import_zod7.z.number().int().safe().optional(),
290
+ maxMessageBytes: import_zod7.z.number().int().safe().optional(),
291
+ pollInterval: import_zod7.z.number().int().safe().optional(),
292
+ pollPageSize: import_zod7.z.number().int().safe().optional()
237
293
  });
238
294
 
239
- // src/steps.ts
240
- var import_connectors_sdk8 = require("@superdurable/connectors-sdk");
295
+ // src/generated/steps.ts
296
+ var import_connectors_sdk9 = require("@superdurable/connectors-sdk");
297
+
298
+ // src/generated/mock.ts
299
+ var import_connectormock = require("@superdurable/connectors-sdk/connectormock");
300
+ var emptyGetMessageInput = GetMessageInputSchema.parse({
301
+ "messageId": ""
302
+ });
303
+ var emptyMessage = MessageSchema.parse({
304
+ "messageId": "",
305
+ "threadId": "",
306
+ "from": "",
307
+ "subject": "",
308
+ "receivedAt": "0001-01-01T00:00:00Z"
309
+ });
310
+ var emptySendMessageInput = SendMessageInputSchema.parse({
311
+ "to": [],
312
+ "subject": "",
313
+ "textBody": ""
314
+ });
315
+ var emptySendMessageOutput = SendMessageOutputSchema.parse({
316
+ "sender": "",
317
+ "recipients": [],
318
+ "messageId": "",
319
+ "threadId": ""
320
+ });
321
+ var emptyReplyToMessageInput = ReplyToMessageInputSchema.parse({
322
+ "messageId": "",
323
+ "textBody": ""
324
+ });
325
+ function getMessageRetry(failure, retryAfterMs = 0) {
326
+ return (0, import_connectormock.retryCase)(failure, retryAfterMs);
327
+ }
328
+ function getMessageCustomerQuestion() {
329
+ const value = MessageSchema.parse({ "from": "Ada Customer <ada@example.com>", "htmlBody": "<p>Hello, my order 1042 has not arrived yet. Can you check?</p>", "inReplyTo": "<welcome-1@mail.example.com>", "labelIds": ["INBOX", "UNREAD"], "messageId": "18c0a1b2c3d4e5f6", "receivedAt": "2026-03-04T09:15:00Z", "references": "<welcome-1@mail.example.com>", "replyTo": "ada.support@example.com", "rfcMessageId": "<question-1@mail.example.com>", "snippet": "Hello, my order 1042 has not arrived yet.", "subject": "Re: Order 1042 has not arrived", "textBody": "Hello, my order 1042 has not arrived yet. Can you check?", "threadId": "18c0a1b2c3d4e5f0", "to": ["support@example.org"] });
330
+ return (0, import_connectormock.branchCase)("read", value);
331
+ }
332
+ function getMessageDefault() {
333
+ return getMessageCustomerQuestion();
334
+ }
335
+ function getMessageDeletedMessage() {
336
+ const value = emptyMessage;
337
+ return (0, import_connectormock.branchCase)("notFound", value, { kind: "NOT_FOUND", provider: ConnectorID, operation: "getMessage", message: "The Gmail message does not exist." });
338
+ }
339
+ function getMessageRevokedGrant() {
340
+ const value = emptyMessage;
341
+ return (0, import_connectormock.branchCase)("providerRejected", value, { kind: "AUTHORIZATION", provider: ConnectorID, operation: "getMessage", message: "Gmail rejected the message query for the granted scopes." });
342
+ }
343
+ function getMessageMalformedPayload() {
344
+ const value = emptyMessage;
345
+ return (0, import_connectormock.branchCase)("invalidResponse", value, { kind: "PROTOCOL", provider: ConnectorID, operation: "getMessage", message: "Gmail returned an invalid message payload." });
346
+ }
347
+ function getMessageEmptyMessageID() {
348
+ const value = emptyMessage;
349
+ return (0, import_connectormock.branchCase)("defect", value, { kind: "VALIDATION", provider: ConnectorID, operation: "getMessage", message: "The message ID is required." });
350
+ }
351
+ function getMessageRateLimited() {
352
+ return (0, import_connectormock.retryCase)({ kind: "RATE_LIMIT", provider: ConnectorID, operation: "getMessage", message: "Gmail rate limit was reached." }, 1e3);
353
+ }
354
+ function sendMessageSentToCustomer() {
355
+ const value = SendMessageOutputSchema.parse({ "messageId": "18c0a1b2c3d4e600", "recipients": ["ada@example.com"], "sender": "support@example.org", "threadId": "18c0a1b2c3d4e600" });
356
+ return (0, import_connectormock.branchCase)("sent", value);
357
+ }
358
+ function sendMessageDefault() {
359
+ return sendMessageSentToCustomer();
360
+ }
361
+ function sendMessageInvalidRecipient() {
362
+ const value = emptySendMessageOutput;
363
+ return (0, import_connectormock.branchCase)("providerRejected", value, { kind: "PROVIDER_REJECTION", provider: ConnectorID, operation: "sendMessage", message: "Gmail rejected the message recipients." });
364
+ }
365
+ function sendMessageConnectionLost() {
366
+ return (0, import_connectormock.retryCase)({ kind: "TRANSPORT", provider: ConnectorID, operation: "sendMessage", message: "The connection closed before Gmail answered." });
367
+ }
368
+ function sendMessageNoRecipients() {
369
+ const value = emptySendMessageOutput;
370
+ return (0, import_connectormock.branchCase)("defect", value, { kind: "VALIDATION", provider: ConnectorID, operation: "sendMessage", message: "At least one recipient is required." });
371
+ }
372
+ function sendMessageUnavailable() {
373
+ return (0, import_connectormock.retryCase)({ kind: "AVAILABILITY", provider: ConnectorID, operation: "sendMessage", message: "Gmail is temporarily unavailable." });
374
+ }
375
+ function replyToMessageRepliedInThread() {
376
+ const value = SendMessageOutputSchema.parse({ "messageId": "18c0a1b2c3d4e700", "recipients": ["ada.support@example.com"], "sender": "support@example.org", "threadId": "18c0a1b2c3d4e5f0" });
377
+ return (0, import_connectormock.branchCase)("sent", value);
378
+ }
379
+ function replyToMessageDefault() {
380
+ return replyToMessageRepliedInThread();
381
+ }
382
+ function replyToMessageSourceMissing() {
383
+ const value = emptySendMessageOutput;
384
+ return (0, import_connectormock.branchCase)("providerRejected", value, { kind: "NOT_FOUND", provider: ConnectorID, operation: "replyToMessage", message: "The source Gmail message does not exist." });
385
+ }
386
+ function replyToMessageMalformedSource() {
387
+ const value = emptySendMessageOutput;
388
+ return (0, import_connectormock.branchCase)("invalidResponse", value, { kind: "PROTOCOL", provider: ConnectorID, operation: "replyToMessage", message: "Gmail returned an invalid source message." });
389
+ }
390
+ function replyToMessageConnectionLost() {
391
+ return (0, import_connectormock.retryCase)({ kind: "TRANSPORT", provider: ConnectorID, operation: "replyToMessage", message: "The connection closed before Gmail answered." });
392
+ }
393
+ function replyToMessageEmptyBody() {
394
+ const value = emptySendMessageOutput;
395
+ return (0, import_connectormock.branchCase)("defect", value, { kind: "VALIDATION", provider: ConnectorID, operation: "replyToMessage", message: "The reply body is required." });
396
+ }
241
397
 
242
398
  // src/mock/index.ts
243
- var EmptyMessage = {
244
- messageId: "",
245
- threadId: "",
246
- from: "",
247
- subject: "",
248
- receivedAt: "0001-01-01T00:00:00Z"
249
- };
250
- var EmptySend = { sender: "", recipients: [], messageId: "", threadId: "" };
251
399
  var GmailMock = class {
252
400
  #getMessage;
253
401
  #sendMessage;
@@ -256,9 +404,9 @@ var GmailMock = class {
256
404
  /** Construct all three operation scripts under one static connection name. */
257
405
  constructor(connectionName) {
258
406
  if (!connectionName.trim()) throw new TypeError("Gmail mock connection name is required");
259
- this.#getMessage = (0, import_connectormock.newQuery)(GetMessageDefinition).default(getMessageDefault());
260
- this.#sendMessage = (0, import_connectormock.newMutation)(SendMessageDefinition).default(sendMessageDefault());
261
- this.#replyToMessage = (0, import_connectormock.newMutation)(ReplyToMessageDefinition).default(replyToMessageDefault());
407
+ this.#getMessage = (0, import_connectormock2.newQuery)(GetMessageDefinition).default(getMessageDefault());
408
+ this.#sendMessage = (0, import_connectormock2.newMutation)(SendMessageDefinition).default(sendMessageDefault2());
409
+ this.#replyToMessage = (0, import_connectormock2.newMutation)(ReplyToMessageDefinition).default(replyToMessageDefault2());
262
410
  this.#connection = new GmailConnection(this, { provider: "google", name: connectionName });
263
411
  }
264
412
  /** Return the typed connection for Gmail Step factories. */
@@ -278,99 +426,42 @@ var GmailMock = class {
278
426
  return this.#replyToMessage;
279
427
  }
280
428
  };
281
- function failure(operation, kind, message) {
282
- return { kind, provider: "gmail", operation, message };
283
- }
284
- function getMessageBranch(branch, value, reason) {
285
- return (0, import_connectormock.branchCase)(branch, value, reason);
429
+ function publicSendCase(scripted) {
430
+ if (scripted.kind === "retry") return (0, import_connectormock2.retryCase)(scripted.failure, scripted.retryAfterMs);
431
+ const value = SendMessageOutputSchema2.parse(scripted.value);
432
+ if (scripted.kind === "uncertain") return (0, import_connectormock2.uncertainCase)(value, scripted.failure);
433
+ return (0, import_connectormock2.branchCase)(scripted.branch, value, scripted.failure);
286
434
  }
287
- function getMessageRetry(reason, afterMs = 0) {
288
- return (0, import_connectormock.retryCase)(reason, afterMs);
289
- }
290
- function getMessageCustomerQuestion() {
291
- return (0, import_connectormock.branchCase)(GetMessageBranch.Read, MessageSchema.parse({
292
- messageId: "18c0a1b2c3d4e5f6",
293
- threadId: "18c0a1b2c3d4e5f0",
294
- rfcMessageId: "<question-1@mail.example.com>",
295
- inReplyTo: "<welcome-1@mail.example.com>",
296
- references: "<welcome-1@mail.example.com>",
297
- from: "Ada Customer <ada@example.com>",
298
- replyTo: "ada.support@example.com",
299
- to: ["support@example.org"],
300
- subject: "Re: Order 1042 has not arrived",
301
- textBody: "Hello, my order 1042 has not arrived yet. Can you check?",
302
- htmlBody: "<p>Hello, my order 1042 has not arrived yet. Can you check?</p>",
303
- snippet: "Hello, my order 1042 has not arrived yet.",
304
- receivedAt: "2026-03-04T09:15:00Z",
305
- labelIds: ["INBOX", "UNREAD"]
306
- }));
307
- }
308
- function getMessageDeletedMessage() {
309
- return (0, import_connectormock.branchCase)(GetMessageBranch.NotFound, EmptyMessage, failure("getMessage", "NOT_FOUND", "The Gmail message does not exist."));
310
- }
311
- function getMessageRevokedGrant() {
312
- return (0, import_connectormock.branchCase)(GetMessageBranch.ProviderRejected, EmptyMessage, failure("getMessage", "AUTHORIZATION", "Gmail rejected the message query for the granted scopes."));
313
- }
314
- function getMessageMalformedPayload() {
315
- return (0, import_connectormock.branchCase)(GetMessageBranch.InvalidResponse, EmptyMessage, failure("getMessage", "PROTOCOL", "Gmail returned an invalid message payload."));
435
+ function adaptGeneratedSendCase(factory) {
436
+ return () => publicSendCase(factory());
316
437
  }
317
- function getMessageEmptyMessageID() {
318
- return (0, import_connectormock.branchCase)(GetMessageBranch.Defect, EmptyMessage, failure("getMessage", "VALIDATION", "The message ID is required."));
319
- }
320
- function getMessageRateLimited() {
321
- return (0, import_connectormock.retryCase)(failure("getMessage", "RATE_LIMIT", "Gmail rate limit was reached."), 1e3);
322
- }
323
- function getMessageDefault() {
324
- return getMessageCustomerQuestion();
438
+ function getMessageBranch(branch, value, reason) {
439
+ return (0, import_connectormock2.branchCase)(branch, value, reason);
325
440
  }
326
441
  function sendMessageBranch(branch, value, reason) {
327
- return (0, import_connectormock.branchCase)(branch, value, reason);
442
+ return (0, import_connectormock2.branchCase)(branch, value, reason);
328
443
  }
329
444
  function sendMessageRetry(reason, afterMs = 0) {
330
- return (0, import_connectormock.retryCase)(reason, afterMs);
331
- }
332
- function sendMessageSentToCustomer() {
333
- return (0, import_connectormock.branchCase)(SendMessageBranch.Sent, SendMessageOutputSchema.parse({ sender: "support@example.org", recipients: ["ada@example.com"], messageId: "18c0a1b2c3d4e600", threadId: "18c0a1b2c3d4e600" }));
334
- }
335
- function sendMessageInvalidRecipient() {
336
- return (0, import_connectormock.branchCase)(SendMessageBranch.ProviderRejected, EmptySend, failure("sendMessage", "PROVIDER_REJECTION", "Gmail rejected the message recipients."));
337
- }
338
- function sendMessageConnectionLost() {
339
- return (0, import_connectormock.retryCase)(failure("sendMessage", "TRANSPORT", "The connection closed before Gmail answered."));
340
- }
341
- function sendMessageNoRecipients() {
342
- return (0, import_connectormock.branchCase)(SendMessageBranch.Defect, EmptySend, failure("sendMessage", "VALIDATION", "At least one recipient is required."));
343
- }
344
- function sendMessageUnavailable() {
345
- return (0, import_connectormock.retryCase)(failure("sendMessage", "AVAILABILITY", "Gmail is temporarily unavailable."));
346
- }
347
- function sendMessageDefault() {
348
- return sendMessageSentToCustomer();
445
+ return (0, import_connectormock2.retryCase)(reason, afterMs);
349
446
  }
447
+ var sendMessageSentToCustomer2 = adaptGeneratedSendCase(sendMessageSentToCustomer);
448
+ var sendMessageInvalidRecipient2 = adaptGeneratedSendCase(sendMessageInvalidRecipient);
449
+ var sendMessageConnectionLost2 = adaptGeneratedSendCase(sendMessageConnectionLost);
450
+ var sendMessageNoRecipients2 = adaptGeneratedSendCase(sendMessageNoRecipients);
451
+ var sendMessageUnavailable2 = adaptGeneratedSendCase(sendMessageUnavailable);
452
+ var sendMessageDefault2 = adaptGeneratedSendCase(sendMessageDefault);
350
453
  function replyToMessageBranch(branch, value, reason) {
351
- return (0, import_connectormock.branchCase)(branch, value, reason);
454
+ return (0, import_connectormock2.branchCase)(branch, value, reason);
352
455
  }
353
456
  function replyToMessageRetry(reason, afterMs = 0) {
354
- return (0, import_connectormock.retryCase)(reason, afterMs);
355
- }
356
- function replyToMessageRepliedInThread() {
357
- return (0, import_connectormock.branchCase)(ReplyToMessageBranch.Sent, SendMessageOutputSchema.parse({ sender: "support@example.org", recipients: ["ada.support@example.com"], messageId: "18c0a1b2c3d4e700", threadId: "18c0a1b2c3d4e5f0" }));
358
- }
359
- function replyToMessageSourceMissing() {
360
- return (0, import_connectormock.branchCase)(ReplyToMessageBranch.ProviderRejected, EmptySend, failure("replyToMessage", "NOT_FOUND", "The source Gmail message does not exist."));
361
- }
362
- function replyToMessageMalformedSource() {
363
- return (0, import_connectormock.branchCase)(ReplyToMessageBranch.InvalidResponse, EmptySend, failure("replyToMessage", "PROTOCOL", "Gmail returned an invalid source message."));
364
- }
365
- function replyToMessageConnectionLost() {
366
- return (0, import_connectormock.retryCase)(failure("replyToMessage", "TRANSPORT", "The connection closed before Gmail answered."));
367
- }
368
- function replyToMessageEmptyBody() {
369
- return (0, import_connectormock.branchCase)(ReplyToMessageBranch.Defect, EmptySend, failure("replyToMessage", "VALIDATION", "The reply body is required."));
370
- }
371
- function replyToMessageDefault() {
372
- return replyToMessageRepliedInThread();
457
+ return (0, import_connectormock2.retryCase)(reason, afterMs);
373
458
  }
459
+ var replyToMessageRepliedInThread2 = adaptGeneratedSendCase(replyToMessageRepliedInThread);
460
+ var replyToMessageSourceMissing2 = adaptGeneratedSendCase(replyToMessageSourceMissing);
461
+ var replyToMessageMalformedSource2 = adaptGeneratedSendCase(replyToMessageMalformedSource);
462
+ var replyToMessageConnectionLost2 = adaptGeneratedSendCase(replyToMessageConnectionLost);
463
+ var replyToMessageEmptyBody2 = adaptGeneratedSendCase(replyToMessageEmptyBody);
464
+ var replyToMessageDefault2 = adaptGeneratedSendCase(replyToMessageDefault);
374
465
  // Annotate the CommonJS export names for ESM import in node:
375
466
  0 && (module.exports = {
376
467
  GmailMock,