@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.
package/README.md CHANGED
@@ -8,7 +8,11 @@ npm install @superdurable/connector-google-gmail @superdurable/dex
8
8
 
9
9
  This package provides typed `getMessage`, `sendMessage`, and `replyToMessage` operations. Its operation identities, branches, retry policy, authorization fields, and mock cases mirror [the manifest](https://github.com/superdurable/dex-connectors-library/blob/main/connectors/google/gmail/connector.yaml). Gmail Triggers and the thread-reply Trigger runner currently belong to the Go connector.
10
10
 
11
+ The checked-in `src/generated/` contracts come from `connector.yaml` and the
12
+ Go operation structs. Run `go run ./cmd/connectorctl generate --lang typescript connectors/google/gmail/connector.yaml` from the repository root after either source changes. `src/models.ts` keeps credential requirements specific to Google OAuth and Workspace delegation, plus the public non-null send recipient arrays. `src/steps.ts` delegates to generated factories while requiring `GmailConnection` at compile time; `src/mock/index.ts` re-exports matching generated scenarios and validates send scenarios against the public result type. `src/project.ts` keeps the refresh codec and public connection constructor.
13
+
11
14
  Send and reply recipients are validated as mailboxes and returned in canonical header form, such as `<ada@example.com>` or `"Ada" <ada@example.com>`.
15
+ Decoded messages omit absent optional metadata and body fields, matching the Go connector's JSON output.
12
16
 
13
17
  ## Configure a connection
14
18
 
@@ -18,7 +22,7 @@ For personal Gmail or ordinary Workspace accounts, select **Google OAuth**. In [
18
22
 
19
23
  For administrator-managed Workspace delegation, use [Google Cloud service accounts](https://console.cloud.google.com/iam-admin/serviceaccounts) to create a service account and download its JSON key. In [Workspace domain-wide delegation](https://admin.google.com/ac/owl/domainwidedelegation), authorize that account's OAuth client ID for the Gmail readonly and send scopes. Put the JSON key and one managed mailbox in the connection form. The connector mints short-lived delegated tokens and uses that mailbox as the sender.
20
24
 
21
- `sendMessage` and `replyToMessage` claim a Dex heartbeat checkpoint before POST and search Sent Mail under a run-specific RFC `Message-ID` after an ambiguous send. A confirmed match returns `sent`; a miss retries read-back within the manifest budget without another POST. A conclusive 429 or 503 can permit another attempt after its own read-back; delayed Sent Mail indexing after a 503 can still cause duplicate delivery. An accepted 2xx never resends merely because its response body is unusable.
25
+ `sendMessage` and `replyToMessage` use synchronous Execute and claim a Dex heartbeat checkpoint before POST. They search Sent Mail under a run-specific RFC `Message-ID` after an ambiguous send. A confirmed match returns `sent`; a miss retries read-back within the manifest budget without another POST. A conclusive 429 or 503 can permit another attempt after its own read-back; delayed Sent Mail indexing after a 503 can still cause duplicate delivery. An accepted 2xx never resends merely because its response body is unusable.
22
26
 
23
27
  ## Run the example
24
28
 
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "connectorId": "gmail",
3
- "releaseTag": "connectors/google/gmail/v0.24.1",
3
+ "releaseTag": "connectors/google/gmail/go/v0.25.2",
4
4
  "package": {
5
5
  "ecosystem": "npm",
6
6
  "name": "@superdurable/connector-google-gmail",
7
- "version": "0.1.0"
7
+ "version": "0.1.1"
8
8
  },
9
9
  "factories": [
10
10
  {
@@ -1,50 +1,87 @@
1
1
  // src/models.ts
2
+ import { z as z2 } from "zod";
3
+
4
+ // src/generated/models.ts
2
5
  import { z } from "zod";
3
- var ConnectorID = "gmail";
4
- var ProviderID = "google";
5
- var GoogleOAuthAuthMethodID = "google-oauth";
6
- var WorkspaceDomainDelegationAuthMethodID = "workspace-domain-delegation";
7
- var GetMessageInputSchema = z.strictObject({ messageId: z.string() });
8
- var SendMessageInputSchema = z.strictObject({
9
- to: z.array(z.string()),
10
- subject: z.string(),
11
- textBody: z.string(),
12
- htmlBody: z.string().optional()
6
+ var ConfigSchema = z.object({
7
+ "endpoint": z.string().optional(),
8
+ "maxResponseBytes": z.number().int().optional(),
9
+ "maxMessageBytes": z.number().int().optional(),
10
+ "pollIntervalMs": z.number().int().optional(),
11
+ "pollPageSize": z.number().int().optional()
13
12
  });
14
- var ReplyToMessageInputSchema = z.strictObject({
15
- messageId: z.string(),
16
- textBody: z.string(),
17
- htmlBody: z.string().optional()
13
+ var GetMessageInputSchema = z.strictObject({
14
+ "messageId": z.string()
18
15
  });
19
16
  var MessageSchema = z.strictObject({
20
- messageId: z.string(),
21
- threadId: z.string(),
22
- rfcMessageId: z.string().optional(),
23
- inReplyTo: z.string().optional(),
24
- references: z.string().optional(),
25
- from: z.string(),
26
- replyTo: z.string().optional(),
27
- to: z.array(z.string()).optional(),
28
- subject: z.string(),
29
- textBody: z.string().optional(),
30
- htmlBody: z.string().optional(),
31
- snippet: z.string().optional(),
32
- receivedAt: z.iso.datetime({ offset: true }),
33
- labelIds: z.array(z.string()).optional()
17
+ "messageId": z.string(),
18
+ "threadId": z.string(),
19
+ "rfcMessageId": z.string().optional(),
20
+ "inReplyTo": z.string().optional(),
21
+ "references": z.string().optional(),
22
+ "from": z.string(),
23
+ "replyTo": z.string().optional(),
24
+ "to": z.array(z.string()).optional(),
25
+ "subject": z.string(),
26
+ "textBody": z.string().optional(),
27
+ "htmlBody": z.string().optional(),
28
+ "snippet": z.string().optional(),
29
+ "receivedAt": z.iso.datetime({ offset: true }),
30
+ "labelIds": z.array(z.string()).optional()
31
+ });
32
+ var SendMessageInputSchema = z.strictObject({
33
+ "to": z.array(z.string()).nullable(),
34
+ "subject": z.string(),
35
+ "textBody": z.string(),
36
+ "htmlBody": z.string().optional()
34
37
  });
35
38
  var SendMessageOutputSchema = z.strictObject({
36
- sender: z.string(),
37
- recipients: z.array(z.string()),
38
- messageId: z.string(),
39
- threadId: z.string()
39
+ "sender": z.string(),
40
+ "recipients": z.array(z.string()).nullable(),
41
+ "messageId": z.string(),
42
+ "threadId": z.string()
43
+ });
44
+ var ReplyToMessageInputSchema = z.strictObject({
45
+ "messageId": z.string(),
46
+ "textBody": z.string(),
47
+ "htmlBody": z.string().optional()
48
+ });
49
+
50
+ // src/models.ts
51
+ var SendMessageInputSchema2 = z2.strictObject({
52
+ to: z2.array(z2.string()),
53
+ subject: z2.string(),
54
+ textBody: z2.string(),
55
+ htmlBody: z2.string().optional()
56
+ });
57
+ var SendMessageOutputSchema2 = z2.strictObject({
58
+ sender: z2.string(),
59
+ recipients: z2.array(z2.string()),
60
+ messageId: z2.string(),
61
+ threadId: z2.string()
40
62
  });
63
+ var ConnectorID = "gmail";
64
+ var ProviderID = "google";
65
+ var GoogleOAuthAuthMethodID = "google-oauth";
66
+ var WorkspaceDomainDelegationAuthMethodID = "workspace-domain-delegation";
41
67
 
42
- // src/definitions.ts
43
- var GetMessageBranch = { Read: "read", NotFound: "notFound", ProviderRejected: "providerRejected", InvalidResponse: "invalidResponse", Defect: "defect" };
44
- var SendMessageBranch = { Sent: "sent", ProviderRejected: "providerRejected", Defect: "defect" };
45
- var ReplyToMessageBranch = { Sent: "sent", ProviderRejected: "providerRejected", InvalidResponse: "invalidResponse", Defect: "defect" };
68
+ // src/generated/definitions.ts
69
+ var ConnectorID2 = "gmail";
70
+ var ProviderID2 = "google";
71
+ var GetMessageBranch = {
72
+ Read: "read",
73
+ NotFound: "notFound",
74
+ ProviderRejected: "providerRejected",
75
+ InvalidResponse: "invalidResponse",
76
+ Defect: "defect"
77
+ };
78
+ var GetMessageBranchRead = GetMessageBranch.Read;
79
+ var GetMessageBranchNotFound = GetMessageBranch.NotFound;
80
+ var GetMessageBranchProviderRejected = GetMessageBranch.ProviderRejected;
81
+ var GetMessageBranchInvalidResponse = GetMessageBranch.InvalidResponse;
82
+ var GetMessageBranchDefect = GetMessageBranch.Defect;
46
83
  var GetMessageDefinition = {
47
- operation: { connectorId: ConnectorID, operationId: "getMessage" },
84
+ operation: { connectorId: ConnectorID2, operationId: "getMessage" },
48
85
  branches: [
49
86
  { id: "read", description: "The Gmail message was read." },
50
87
  { id: "notFound", description: "The Gmail message does not exist.", optional: true },
@@ -54,53 +91,59 @@ var GetMessageDefinition = {
54
91
  ],
55
92
  stepDefaults: { executeMethodTimeoutMs: 3e4, executeDurability: "async" }
56
93
  };
94
+ var SendMessageBranch = {
95
+ Sent: "sent",
96
+ ProviderRejected: "providerRejected",
97
+ Defect: "defect"
98
+ };
99
+ var SendMessageBranchSent = SendMessageBranch.Sent;
100
+ var SendMessageBranchProviderRejected = SendMessageBranch.ProviderRejected;
101
+ var SendMessageBranchDefect = SendMessageBranch.Defect;
57
102
  var SendMessageDefinition = {
58
- operation: { connectorId: ConnectorID, operationId: "sendMessage" },
103
+ operation: { connectorId: ConnectorID2, operationId: "sendMessage" },
59
104
  branches: [
60
105
  { id: "sent", description: "Gmail accepted the message; its message and thread IDs can be empty when an unusable accepted response has no Sent Mail match." },
61
106
  { id: "providerRejected", description: "Gmail conclusively rejected the message.", optional: true },
62
107
  { id: "defect", description: "Local input, connection configuration, or connector definition is invalid.", optional: true }
63
108
  ],
64
- stepDefaults: { executeMethodTimeoutMs: 3e4, executeDurability: "async", executeRetry: {
65
- initialIntervalMs: 1e3,
66
- backoffCoefficient: 2,
67
- maximumIntervalMs: 3e4,
68
- maximumAttempts: 5,
69
- totalDurationMs: 12e4
70
- } }
109
+ stepDefaults: { executeMethodTimeoutMs: 3e4, executeDurability: "sync", executeRetry: { initialIntervalMs: 1e3, backoffCoefficient: 2, maximumIntervalMs: 3e4, maximumAttempts: 5, totalDurationMs: 12e4 } }
71
110
  };
111
+ var ReplyToMessageBranch = {
112
+ Sent: "sent",
113
+ ProviderRejected: "providerRejected",
114
+ InvalidResponse: "invalidResponse",
115
+ Defect: "defect"
116
+ };
117
+ var ReplyToMessageBranchSent = ReplyToMessageBranch.Sent;
118
+ var ReplyToMessageBranchProviderRejected = ReplyToMessageBranch.ProviderRejected;
119
+ var ReplyToMessageBranchInvalidResponse = ReplyToMessageBranch.InvalidResponse;
120
+ var ReplyToMessageBranchDefect = ReplyToMessageBranch.Defect;
72
121
  var ReplyToMessageDefinition = {
73
- operation: { connectorId: ConnectorID, operationId: "replyToMessage" },
122
+ operation: { connectorId: ConnectorID2, operationId: "replyToMessage" },
74
123
  branches: [
75
124
  { id: "sent", description: "Gmail accepted the reply; its message ID can be empty when an unusable accepted response has no Sent Mail match, while the requested thread ID remains." },
76
125
  { id: "providerRejected", description: "Gmail conclusively rejected the reply.", optional: true },
77
126
  { id: "invalidResponse", description: "Gmail returned an invalid or oversized source message response before sending the reply.", optional: true },
78
127
  { id: "defect", description: "Local input, connection configuration, or connector definition is invalid.", optional: true }
79
128
  ],
80
- stepDefaults: { executeMethodTimeoutMs: 3e4, executeDurability: "async", executeRetry: {
81
- initialIntervalMs: 1e3,
82
- backoffCoefficient: 2,
83
- maximumIntervalMs: 3e4,
84
- maximumAttempts: 5,
85
- totalDurationMs: 12e4
86
- } }
129
+ stepDefaults: { executeMethodTimeoutMs: 3e4, executeDurability: "sync", executeRetry: { initialIntervalMs: 1e3, backoffCoefficient: 2, maximumIntervalMs: 3e4, maximumAttempts: 5, totalDurationMs: 12e4 } }
87
130
  };
88
131
 
89
132
  // src/message.ts
90
133
  import { createHash } from "crypto";
91
- import { z as z2 } from "zod";
92
- var GmailMessagePartSchema = z2.lazy(() => z2.object({
93
- mimeType: z2.string().nullish(),
94
- headers: z2.array(z2.object({ name: z2.string(), value: z2.string() })).nullish(),
95
- body: z2.object({ data: z2.string().nullish() }).nullish(),
96
- parts: z2.array(GmailMessagePartSchema).nullish()
134
+ import { z as z3 } from "zod";
135
+ var GmailMessagePartSchema = z3.lazy(() => z3.object({
136
+ mimeType: z3.string().nullish(),
137
+ headers: z3.array(z3.object({ name: z3.string(), value: z3.string() })).nullish(),
138
+ body: z3.object({ data: z3.string().nullish() }).nullish(),
139
+ parts: z3.array(GmailMessagePartSchema).nullish()
97
140
  }));
98
- var GmailMessageResourceSchema = z2.object({
99
- id: z2.string().nullish().transform((value) => value ?? ""),
100
- threadId: z2.string().nullish().transform((value) => value ?? ""),
101
- labelIds: z2.array(z2.string()).nullish(),
102
- snippet: z2.string().nullish(),
103
- internalDate: z2.string().nullish(),
141
+ var GmailMessageResourceSchema = z3.object({
142
+ id: z3.string().nullish().transform((value) => value ?? ""),
143
+ threadId: z3.string().nullish().transform((value) => value ?? ""),
144
+ labelIds: z3.array(z3.string()).nullish(),
145
+ snippet: z3.string().nullish(),
146
+ internalDate: z3.string().nullish(),
104
147
  payload: GmailMessagePartSchema.nullish()
105
148
  });
106
149
  function decodeGmailMessage(resource) {
@@ -115,18 +158,18 @@ function decodeGmailMessage(resource) {
115
158
  return {
116
159
  messageId: resource.id,
117
160
  threadId: resource.threadId,
118
- rfcMessageId: headers.get("message-id") ?? "",
119
- inReplyTo: headers.get("in-reply-to") ?? "",
120
- references: headers.get("references") ?? "",
161
+ ...headers.get("message-id") ? { rfcMessageId: headers.get("message-id") } : {},
162
+ ...headers.get("in-reply-to") ? { inReplyTo: headers.get("in-reply-to") } : {},
163
+ ...headers.get("references") ? { references: headers.get("references") } : {},
121
164
  from: headers.get("from") ?? "",
122
- replyTo: headers.get("reply-to") ?? "",
123
- to,
165
+ ...headers.get("reply-to") ? { replyTo: headers.get("reply-to") } : {},
166
+ ...to.length ? { to } : {},
124
167
  subject: decodeRFC2047Header(headers.get("subject") ?? ""),
125
- textBody: textBodies.join("\n"),
126
- htmlBody: htmlBodies.join("\n"),
127
- snippet: resource.snippet ?? "",
168
+ ...textBodies.length ? { textBody: textBodies.join("\n") } : {},
169
+ ...htmlBodies.length ? { htmlBody: htmlBodies.join("\n") } : {},
170
+ ...resource.snippet ? { snippet: resource.snippet } : {},
128
171
  receivedAt: receivedAt.toISOString().replace(".000Z", "Z"),
129
- labelIds: resource.labelIds ?? []
172
+ ...resource.labelIds?.length ? { labelIds: resource.labelIds } : {}
130
173
  };
131
174
  }
132
175
  function visitGmailBody(part, textBodies, htmlBodies) {
@@ -383,9 +426,9 @@ function validateCredentials(credentials) {
383
426
  }
384
427
 
385
428
  // src/provider.ts
386
- import { z as z3 } from "zod";
387
- var SentMessageSchema = z3.object({ id: z3.string().optional(), threadId: z3.string().optional() });
388
- var SentSearchSchema = z3.object({ messages: z3.array(SentMessageSchema).nullish() });
429
+ import { z as z4 } from "zod";
430
+ var SentMessageSchema = z4.object({ id: z4.string().optional(), threadId: z4.string().optional() });
431
+ var SentSearchSchema = z4.object({ messages: z4.array(SentMessageSchema).nullish() });
389
432
  var GmailProvider = class {
390
433
  #http;
391
434
  /** Bind the shared authenticated transport. */
@@ -454,11 +497,11 @@ import {
454
497
  signJWTBearerAssertion,
455
498
  TokenEndpoint
456
499
  } from "@superdurable/connectors-sdk/oauthtoken";
457
- import { z as z4 } from "zod";
500
+ import { z as z5 } from "zod";
458
501
  var GoogleOAuthTokenEndpoint = "https://oauth2.googleapis.com/token";
459
502
  var RequiredGmailScopes = ["https://www.googleapis.com/auth/gmail.readonly", "https://www.googleapis.com/auth/gmail.send"];
460
503
  var TerminalErrorCodes = ["invalid_grant", "invalid_client", "unauthorized_client"];
461
- var ServiceAccountKeySchema = z4.object({ client_email: z4.string().min(1), private_key: z4.string().min(1), token_uri: z4.url() });
504
+ var ServiceAccountKeySchema = z5.object({ client_email: z5.string().min(1), private_key: z5.string().min(1), token_uri: z5.url() });
462
505
  var GmailCredentialRefreshDriver = class {
463
506
  #fetch;
464
507
  #now;
@@ -495,12 +538,13 @@ var GmailCredentialRefreshDriver = class {
495
538
  } catch {
496
539
  throw new ReauthorizationRequiredError();
497
540
  }
498
- if (new URL(key.token_uri).protocol !== "https:" || !parseMailbox(credentials.delegatedUser ?? "")) throw new ReauthorizationRequiredError();
541
+ const delegatedUser = credentials.delegatedUser;
542
+ if (new URL(key.token_uri).protocol !== "https:" || !delegatedUser || !parseMailbox(delegatedUser)) throw new ReauthorizationRequiredError();
499
543
  let assertion;
500
544
  try {
501
545
  assertion = signJWTBearerAssertion({
502
546
  issuer: key.client_email,
503
- subject: credentials.delegatedUser,
547
+ subject: delegatedUser,
504
548
  audience: key.token_uri,
505
549
  scope: RequiredGmailScopes.join(" "),
506
550
  issuedAt: this.#now(),
@@ -652,7 +696,7 @@ var GmailSender = class {
652
696
  }
653
697
  let recipients;
654
698
  try {
655
- if (!SendMessageInputSchema.safeParse(input).success) throw new TypeError();
699
+ if (!SendMessageInputSchema2.safeParse(input).success) throw new TypeError();
656
700
  recipients = validateSendInput(input, credentials.primaryEmail);
657
701
  } catch (error) {
658
702
  return defect("sendMessage", "VALIDATION", error instanceof TypeError && error.message ? error.message : "sender, recipients, subject, and text body are required");
@@ -1020,38 +1064,52 @@ function classifyReadFailure(status, headers) {
1020
1064
  }
1021
1065
 
1022
1066
  // src/connection.ts
1067
+ import { ConnectionRefSchema as ConnectionRefSchema2 } from "@superdurable/connectors-sdk";
1068
+
1069
+ // src/generated/connection.ts
1023
1070
  import { ConnectionRefSchema } from "@superdurable/connectors-sdk";
1024
- var GmailConnection = class {
1025
- /** Stable logical credential reference. */
1071
+ var Connection = class {
1072
+ /** Stable provider and connection name. */
1026
1073
  reference;
1027
- /** Provider or mock operation implementations. */
1074
+ /** Bound provider operations. */
1028
1075
  operations;
1076
+ /** Validate a reference and bind operations. */
1077
+ constructor(reference, operations) {
1078
+ this.reference = ConnectionRefSchema.parse(reference);
1079
+ if (this.reference.provider !== ProviderID2) throw new TypeError("connection provider differs from the manifest");
1080
+ if (!operations) throw new TypeError("connector operations are required");
1081
+ this.operations = operations;
1082
+ }
1083
+ };
1084
+
1085
+ // src/connection.ts
1086
+ var GmailConnection = class extends Connection {
1029
1087
  /** Bind operation implementations to a static named Google connection. */
1030
1088
  constructor(operations, reference) {
1031
1089
  if (!operations) throw new TypeError("Gmail connector operations are required");
1032
- this.reference = ConnectionRefSchema.parse(reference);
1033
- if (this.reference.provider !== "google") throw new TypeError("Gmail connection provider must be google");
1034
- this.operations = operations;
1090
+ const validatedReference = ConnectionRefSchema2.parse(reference);
1091
+ if (validatedReference.provider !== "google") throw new TypeError("Gmail connection provider must be google");
1092
+ super(validatedReference, operations);
1035
1093
  }
1036
1094
  };
1037
1095
 
1038
1096
  // src/project.ts
1039
- import { ConnectionRefSchema as ConnectionRefSchema2 } from "@superdurable/connectors-sdk";
1097
+ import { ConnectionRefSchema as ConnectionRefSchema3 } from "@superdurable/connectors-sdk";
1040
1098
  import { newRefreshingCredentialProvider } from "@superdurable/connectors-sdk/projectconfig";
1041
- import { z as z6 } from "zod";
1099
+ import { z as z7 } from "zod";
1042
1100
 
1043
1101
  // src/credential_codec.ts
1044
1102
  import { SecretString } from "@superdurable/connectors-sdk";
1045
- import { z as z5 } from "zod";
1046
- var StoredCredentialsSchema = z5.object({
1047
- auth_method: z5.string().optional(),
1048
- oauth_client_id: z5.string().optional(),
1049
- oauth_client_secret: z5.string().optional(),
1050
- access_token: z5.string().optional(),
1051
- refresh_token: z5.string().optional(),
1052
- primary_email: z5.string().optional(),
1053
- service_account_key: z5.string().optional(),
1054
- delegated_user: z5.string().optional()
1103
+ import { z as z6 } from "zod";
1104
+ var StoredCredentialsSchema = z6.object({
1105
+ auth_method: z6.string().optional(),
1106
+ oauth_client_id: z6.string().optional(),
1107
+ oauth_client_secret: z6.string().optional(),
1108
+ access_token: z6.string().optional(),
1109
+ refresh_token: z6.string().optional(),
1110
+ primary_email: z6.string().optional(),
1111
+ service_account_key: z6.string().optional(),
1112
+ delegated_user: z6.string().optional()
1055
1113
  });
1056
1114
  function decodeGmailCredentials(value) {
1057
1115
  return decodeCredentialFields(value, false);
@@ -1099,19 +1157,19 @@ function decodeCredentialFields(value, isShared) {
1099
1157
  }
1100
1158
 
1101
1159
  // src/project.ts
1102
- var ProjectGmailConfigurationSchema = z6.object({
1103
- endpoint: z6.string().optional(),
1104
- maxResponseBytes: z6.number().int().safe().optional(),
1105
- maxMessageBytes: z6.number().int().safe().optional(),
1106
- pollInterval: z6.number().int().safe().optional(),
1107
- pollPageSize: z6.number().int().safe().optional()
1160
+ var ProjectGmailConfigurationSchema = z7.object({
1161
+ endpoint: z7.string().optional(),
1162
+ maxResponseBytes: z7.number().int().safe().optional(),
1163
+ maxMessageBytes: z7.number().int().safe().optional(),
1164
+ pollInterval: z7.number().int().safe().optional(),
1165
+ pollPageSize: z7.number().int().safe().optional()
1108
1166
  });
1109
1167
  function newProjectConnection(project, connectionName, options = {}) {
1110
1168
  return new GmailConnection(newProjectGmailClient(project, connectionName, options), { provider: ProviderID, name: connectionName });
1111
1169
  }
1112
1170
  function newProjectGmailClient(project, connectionName, options = {}) {
1113
1171
  if (!project) throw new TypeError("Gmail connection requires the loaded project configuration");
1114
- ConnectionRefSchema2.parse({ provider: ProviderID, name: connectionName });
1172
+ ConnectionRefSchema3.parse({ provider: ProviderID, name: connectionName });
1115
1173
  const entry = project.configuration.connections.find((connection) => connection.connectorId === ConnectorID && connection.connectionName === connectionName);
1116
1174
  if (!entry) throw new TypeError("Gmail project connection is not configured");
1117
1175
  if (entry.provider !== ProviderID) throw new TypeError("Gmail project connection provider differs from the manifest");
@@ -1127,12 +1185,12 @@ function newProjectGmailClient(project, connectionName, options = {}) {
1127
1185
  return new GmailClient(config, provider, options);
1128
1186
  }
1129
1187
 
1130
- // src/steps.ts
1131
- import { newMutationStep, newQueryStep, goToBranch } from "@superdurable/connectors-sdk";
1188
+ // src/generated/steps.ts
1189
+ import { goToBranch, newMutationStep, newQueryStep } from "@superdurable/connectors-sdk";
1132
1190
  function newGetMessageStep(configuration) {
1133
- const { connectionName, connection, read, notFound, providerRejected, invalidResponse, defect: defect2, ...stepConfiguration } = configuration;
1134
- validateNamedConnection(connectionName, connection);
1135
- return newQueryStep({ ...stepConfiguration, connection: connection.reference, operation: connection.operations.getMessage(), branches: [
1191
+ const { connection, connectionName, read, notFound, providerRejected, invalidResponse, defect: defect2, ...stepConfiguration } = configuration;
1192
+ if (!connection || connection.reference.name !== connectionName) throw new TypeError("Step connection name differs from the bound connection");
1193
+ return newQueryStep({ ...stepConfiguration, operation: connection.operations.getMessage(), connection: connection.reference, branches: [
1136
1194
  goToBranch("read", read),
1137
1195
  ...notFound ? [goToBranch("notFound", notFound)] : [],
1138
1196
  ...providerRejected ? [goToBranch("providerRejected", providerRejected)] : [],
@@ -1141,45 +1199,62 @@ function newGetMessageStep(configuration) {
1141
1199
  ] });
1142
1200
  }
1143
1201
  function newSendMessageStep(configuration) {
1144
- const { connectionName, connection, sent, providerRejected, defect: defect2, ...stepConfiguration } = configuration;
1145
- validateNamedConnection(connectionName, connection);
1146
- return newMutationStep({ ...stepConfiguration, connection: connection.reference, operation: connection.operations.sendMessage(), branches: [
1202
+ const { connection, connectionName, sent, providerRejected, defect: defect2, ...stepConfiguration } = configuration;
1203
+ if (!connection || connection.reference.name !== connectionName) throw new TypeError("Step connection name differs from the bound connection");
1204
+ return newMutationStep({ ...stepConfiguration, operation: connection.operations.sendMessage(), connection: connection.reference, branches: [
1147
1205
  goToBranch("sent", sent),
1148
1206
  ...providerRejected ? [goToBranch("providerRejected", providerRejected)] : [],
1149
1207
  ...defect2 ? [goToBranch("defect", defect2)] : []
1150
1208
  ] });
1151
1209
  }
1152
1210
  function newReplyToMessageStep(configuration) {
1153
- const { connectionName, connection, sent, providerRejected, invalidResponse, defect: defect2, ...stepConfiguration } = configuration;
1154
- validateNamedConnection(connectionName, connection);
1155
- return newMutationStep({ ...stepConfiguration, connection: connection.reference, operation: connection.operations.replyToMessage(), branches: [
1211
+ const { connection, connectionName, sent, providerRejected, invalidResponse, defect: defect2, ...stepConfiguration } = configuration;
1212
+ if (!connection || connection.reference.name !== connectionName) throw new TypeError("Step connection name differs from the bound connection");
1213
+ return newMutationStep({ ...stepConfiguration, operation: connection.operations.replyToMessage(), connection: connection.reference, branches: [
1156
1214
  goToBranch("sent", sent),
1157
1215
  ...providerRejected ? [goToBranch("providerRejected", providerRejected)] : [],
1158
1216
  ...invalidResponse ? [goToBranch("invalidResponse", invalidResponse)] : [],
1159
1217
  ...defect2 ? [goToBranch("defect", defect2)] : []
1160
1218
  ] });
1161
1219
  }
1162
- function validateNamedConnection(connectionName, connection) {
1220
+
1221
+ // src/steps.ts
1222
+ function requireGmailConnection(connection, connectionName) {
1163
1223
  if (!(connection instanceof GmailConnection) || !connectionName || connection.reference.name !== connectionName) {
1164
1224
  throw new TypeError("Gmail Step connection name must match its typed connection");
1165
1225
  }
1166
1226
  }
1227
+ function newGetMessageStep2(configuration) {
1228
+ requireGmailConnection(configuration.connection, configuration.connectionName);
1229
+ return newGetMessageStep(configuration);
1230
+ }
1231
+ function newSendMessageStep2(configuration) {
1232
+ requireGmailConnection(configuration.connection, configuration.connectionName);
1233
+ return newSendMessageStep(configuration);
1234
+ }
1235
+ function newReplyToMessageStep2(configuration) {
1236
+ requireGmailConnection(configuration.connection, configuration.connectionName);
1237
+ return newReplyToMessageStep(configuration);
1238
+ }
1167
1239
 
1168
1240
  export {
1241
+ GetMessageInputSchema,
1242
+ MessageSchema,
1243
+ SendMessageInputSchema,
1244
+ SendMessageOutputSchema,
1245
+ ReplyToMessageInputSchema,
1246
+ SendMessageInputSchema2,
1247
+ SendMessageOutputSchema2,
1169
1248
  ConnectorID,
1170
1249
  ProviderID,
1171
1250
  GoogleOAuthAuthMethodID,
1172
1251
  WorkspaceDomainDelegationAuthMethodID,
1173
- GetMessageInputSchema,
1174
- SendMessageInputSchema,
1175
- ReplyToMessageInputSchema,
1176
- MessageSchema,
1177
- SendMessageOutputSchema,
1252
+ ConnectorID2,
1178
1253
  GetMessageBranch,
1179
- SendMessageBranch,
1180
- ReplyToMessageBranch,
1181
1254
  GetMessageDefinition,
1255
+ SendMessageBranch,
1182
1256
  SendMessageDefinition,
1257
+ ReplyToMessageBranch,
1183
1258
  ReplyToMessageDefinition,
1184
1259
  GmailMessageResourceSchema,
1185
1260
  decodeGmailMessage,
@@ -1208,7 +1283,7 @@ export {
1208
1283
  GmailConnection,
1209
1284
  newProjectConnection,
1210
1285
  newProjectGmailClient,
1211
- newGetMessageStep,
1212
- newSendMessageStep,
1213
- newReplyToMessageStep
1286
+ newGetMessageStep2 as newGetMessageStep,
1287
+ newSendMessageStep2 as newSendMessageStep,
1288
+ newReplyToMessageStep2 as newReplyToMessageStep
1214
1289
  };