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