@superdurable/connector-google-gmail 0.1.1 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.cts CHANGED
@@ -1,5 +1,5 @@
1
- import { M as Message, R as ReplyToMessageInput, S as SendMessageInput, C as Config, a as CredentialSource, b as Credentials, c as SendMessageOutput, G as GetMessageInput, d as GmailOperations, e as GmailConnection } from './connection-NE_da2Az.cjs';
2
- export { f as ConnectorID, g as GetMessageInputSchema, h as GoogleOAuthAuthMethodID, i as MessageSchema, P as ProviderID, j as ReplyToMessageInputSchema, k as SendMessageInputSchema, l as SendMessageOutputSchema, W as WorkspaceDomainDelegationAuthMethodID } from './connection-NE_da2Az.cjs';
1
+ import { M as Message, R as ReplyToMessageInput, S as SendMessageInput, C as Config, a as CredentialSource, b as Credentials, c as SendMessageOutput, G as GetMessageInput, d as GmailOperations, e as GmailConnection } from './connection-D8OV_Hfe.cjs';
2
+ export { f as ConnectorID, g as GetMessageInputSchema, h as GoogleOAuthAuthMethodID, i as MessageSchema, P as ProviderID, j as ReplyToMessageInputSchema, k as SendMessageInputSchema, l as SendMessageOutputSchema, W as WorkspaceDomainDelegationAuthMethodID } from './connection-D8OV_Hfe.cjs';
3
3
  import * as _superdurable_connectors_sdk from '@superdurable/connectors-sdk';
4
4
  import { QueryDefinition, MutationDefinition, CredentialRefreshDriver, Call, FailureKind, CredentialRefreshState, CredentialRefreshResult, Mutation, MutationAttempt, Query, QueryAttempt, Failure, ReceiptDraft, QueryStepConfig, QueryResult, MutationStepConfig, MutationResult, QueryStep, MutationStep } from '@superdurable/connectors-sdk';
5
5
  import { z } from 'zod';
@@ -149,14 +149,14 @@ declare class GmailProvider {
149
149
  /** Parse one accepted Gmail send response. */
150
150
  declare function parseSentResponse(response: ProviderResponse): SentMessageIdentity | undefined;
151
151
 
152
- /** Refresh Gmail OAuth or Workspace delegation credentials without owning persistence. */
152
+ /** Refresh Gmail credentials using generated grant declarations and Google-specific validation. */
153
153
  declare class GmailCredentialRefreshDriver implements CredentialRefreshDriver<Credentials> {
154
154
  #private;
155
- /** Inject the token request transport and clock for deterministic verification. */
155
+ /** Inject the token transport and clock without transferring ownership. */
156
156
  constructor(fetchImplementation?: typeof fetch, now?: () => Date);
157
- /** Refresh absent credentials or tokens whose expiry is within five minutes. */
157
+ /** Refresh absent credentials and tokens approaching expiry, including missing expiry. */
158
158
  refreshRequired(state: CredentialRefreshState<Credentials>): boolean;
159
- /** Make one Google token exchange after the host admits and serializes refresh. */
159
+ /** Apply Gmail's method and delegated mailbox checks before the declared token exchange. */
160
160
  refresh(state: CredentialRefreshState<Credentials>, signal: AbortSignal): Promise<CredentialRefreshResult<Credentials>>;
161
161
  }
162
162
 
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { M as Message, R as ReplyToMessageInput, S as SendMessageInput, C as Config, a as CredentialSource, b as Credentials, c as SendMessageOutput, G as GetMessageInput, d as GmailOperations, e as GmailConnection } from './connection-NE_da2Az.js';
2
- export { f as ConnectorID, g as GetMessageInputSchema, h as GoogleOAuthAuthMethodID, i as MessageSchema, P as ProviderID, j as ReplyToMessageInputSchema, k as SendMessageInputSchema, l as SendMessageOutputSchema, W as WorkspaceDomainDelegationAuthMethodID } from './connection-NE_da2Az.js';
1
+ import { M as Message, R as ReplyToMessageInput, S as SendMessageInput, C as Config, a as CredentialSource, b as Credentials, c as SendMessageOutput, G as GetMessageInput, d as GmailOperations, e as GmailConnection } from './connection-D8OV_Hfe.js';
2
+ export { f as ConnectorID, g as GetMessageInputSchema, h as GoogleOAuthAuthMethodID, i as MessageSchema, P as ProviderID, j as ReplyToMessageInputSchema, k as SendMessageInputSchema, l as SendMessageOutputSchema, W as WorkspaceDomainDelegationAuthMethodID } from './connection-D8OV_Hfe.js';
3
3
  import * as _superdurable_connectors_sdk from '@superdurable/connectors-sdk';
4
4
  import { QueryDefinition, MutationDefinition, CredentialRefreshDriver, Call, FailureKind, CredentialRefreshState, CredentialRefreshResult, Mutation, MutationAttempt, Query, QueryAttempt, Failure, ReceiptDraft, QueryStepConfig, QueryResult, MutationStepConfig, MutationResult, QueryStep, MutationStep } from '@superdurable/connectors-sdk';
5
5
  import { z } from 'zod';
@@ -149,14 +149,14 @@ declare class GmailProvider {
149
149
  /** Parse one accepted Gmail send response. */
150
150
  declare function parseSentResponse(response: ProviderResponse): SentMessageIdentity | undefined;
151
151
 
152
- /** Refresh Gmail OAuth or Workspace delegation credentials without owning persistence. */
152
+ /** Refresh Gmail credentials using generated grant declarations and Google-specific validation. */
153
153
  declare class GmailCredentialRefreshDriver implements CredentialRefreshDriver<Credentials> {
154
154
  #private;
155
- /** Inject the token request transport and clock for deterministic verification. */
155
+ /** Inject the token transport and clock without transferring ownership. */
156
156
  constructor(fetchImplementation?: typeof fetch, now?: () => Date);
157
- /** Refresh absent credentials or tokens whose expiry is within five minutes. */
157
+ /** Refresh absent credentials and tokens approaching expiry, including missing expiry. */
158
158
  refreshRequired(state: CredentialRefreshState<Credentials>): boolean;
159
- /** Make one Google token exchange after the host admits and serializes refresh. */
159
+ /** Apply Gmail's method and delegated mailbox checks before the declared token exchange. */
160
160
  refresh(state: CredentialRefreshState<Credentials>, signal: AbortSignal): Promise<CredentialRefreshResult<Credentials>>;
161
161
  }
162
162
 
package/dist/index.js CHANGED
@@ -44,7 +44,7 @@ import {
44
44
  rfcMessageIDAddress,
45
45
  statusFailureKind,
46
46
  validateSendInput
47
- } from "./chunk-TWBWDIC7.js";
47
+ } from "./chunk-KVNIQW5Y.js";
48
48
  export {
49
49
  ConnectorID,
50
50
  GetMessageBranch,
@@ -55,6 +55,30 @@ var import_zod2 = require("zod");
55
55
 
56
56
  // src/generated/models.ts
57
57
  var import_zod = require("zod");
58
+ var import_connectors_sdk = require("@superdurable/connectors-sdk");
59
+ var goTimeJSONPattern = /^(\d{4})-(\d{2})-(\d{2})T(\d{1,2}):(\d{2}):(\d{2})(?:[.,](\d+))?(Z|([+-])(\d{2}):(\d{2}))$/;
60
+ function isGoTimeJSON(value) {
61
+ const match = goTimeJSONPattern.exec(value);
62
+ if (!match) return false;
63
+ const [, yearText, monthText, dayText, hourText, minuteText, secondText, , zone, , zoneHourText, zoneMinuteText] = match;
64
+ const year = Number(yearText);
65
+ const month = Number(monthText);
66
+ const day = Number(dayText);
67
+ const isLeap = year % 4 === 0 && (year % 100 !== 0 || year % 400 === 0);
68
+ const monthDays = [31, isLeap ? 29 : 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
69
+ return month >= 1 && month <= 12 && day >= 1 && day <= monthDays[month - 1] && Number(hourText) <= 23 && Number(minuteText) <= 59 && Number(secondText) <= 59 && (zone === "Z" || Number(zoneHourText) <= 24 && Number(zoneMinuteText) <= 60);
70
+ }
71
+ function canonicalGoTimeJSON(value) {
72
+ const match = goTimeJSONPattern.exec(value);
73
+ const [, year, month, day, hour, minute, second, fraction, zone, sign, zoneHour, zoneMinute] = match;
74
+ const clock = year + "-" + month + "-" + day + "T" + hour.padStart(2, "0") + ":" + minute + ":" + second;
75
+ const digits = (fraction ?? "").slice(0, 9).replace(/0+$/, "");
76
+ const offsetMinutes = zone === "Z" ? 0 : (Number(zoneHour) * 60 + Number(zoneMinute)) * (sign === "+" ? 1 : -1);
77
+ if (Math.abs(offsetMinutes) >= 1440) return value;
78
+ const offset = offsetMinutes === 0 ? "Z" : (offsetMinutes > 0 ? "+" : "-") + String(Math.floor(Math.abs(offsetMinutes) / 60)).padStart(2, "0") + ":" + String(Math.abs(offsetMinutes) % 60).padStart(2, "0");
79
+ return clock + (digits ? "." + digits : "") + offset;
80
+ }
81
+ var GoTimeJSONSchema = import_zod.z.string().refine(isGoTimeJSON, "invalid Go time.Time JSON timestamp").transform(canonicalGoTimeJSON);
58
82
  var ConfigSchema = import_zod.z.object({
59
83
  "endpoint": import_zod.z.string().optional(),
60
84
  "maxResponseBytes": import_zod.z.number().int().optional(),
@@ -78,7 +102,7 @@ var MessageSchema = import_zod.z.strictObject({
78
102
  "textBody": import_zod.z.string().optional(),
79
103
  "htmlBody": import_zod.z.string().optional(),
80
104
  "snippet": import_zod.z.string().optional(),
81
- "receivedAt": import_zod.z.iso.datetime({ offset: true }),
105
+ "receivedAt": GoTimeJSONSchema,
82
106
  "labelIds": import_zod.z.array(import_zod.z.string()).optional()
83
107
  });
84
108
  var SendMessageInputSchema = import_zod.z.strictObject({
@@ -196,7 +220,7 @@ var GmailMessageResourceSchema = import_zod3.z.object({
196
220
  });
197
221
 
198
222
  // src/http.ts
199
- var import_connectors_sdk = require("@superdurable/connectors-sdk");
223
+ var import_connectors_sdk2 = require("@superdurable/connectors-sdk");
200
224
  var import_providerhttp = require("@superdurable/connectors-sdk/providerhttp");
201
225
 
202
226
  // src/provider.ts
@@ -205,13 +229,11 @@ var SentMessageSchema = import_zod4.z.object({ id: import_zod4.z.string().option
205
229
  var SentSearchSchema = import_zod4.z.object({ messages: import_zod4.z.array(SentMessageSchema).nullish() });
206
230
 
207
231
  // src/refresh.ts
208
- var import_connectors_sdk2 = require("@superdurable/connectors-sdk");
232
+ var import_connectors_sdk3 = require("@superdurable/connectors-sdk");
209
233
  var import_oauthtoken = require("@superdurable/connectors-sdk/oauthtoken");
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() });
212
234
 
213
235
  // src/send.ts
214
- var import_connectors_sdk3 = require("@superdurable/connectors-sdk");
236
+ var import_connectors_sdk4 = require("@superdurable/connectors-sdk");
215
237
  var import_providerhttp2 = require("@superdurable/connectors-sdk/providerhttp");
216
238
  var import_singledispatch = require("@superdurable/connectors-sdk/singledispatch");
217
239
  var import_promises = require("timers/promises");
@@ -231,14 +253,15 @@ var ReplyToMessageOutcomes = {
231
253
  };
232
254
 
233
255
  // src/client.ts
234
- var import_connectors_sdk4 = require("@superdurable/connectors-sdk");
256
+ var import_connectors_sdk5 = require("@superdurable/connectors-sdk");
235
257
  var import_providerhttp3 = require("@superdurable/connectors-sdk/providerhttp");
236
258
 
237
259
  // src/connection.ts
238
- var import_connectors_sdk6 = require("@superdurable/connectors-sdk");
260
+ var import_connectors_sdk7 = require("@superdurable/connectors-sdk");
239
261
 
240
262
  // src/generated/connection.ts
241
- var import_connectors_sdk5 = require("@superdurable/connectors-sdk");
263
+ var import_connectors_sdk6 = require("@superdurable/connectors-sdk");
264
+ var import_projectconfig = require("@superdurable/connectors-sdk/projectconfig");
242
265
  var Connection = class {
243
266
  /** Stable provider and connection name. */
244
267
  reference;
@@ -246,7 +269,7 @@ var Connection = class {
246
269
  operations;
247
270
  /** Validate a reference and bind operations. */
248
271
  constructor(reference, operations) {
249
- this.reference = import_connectors_sdk5.ConnectionRefSchema.parse(reference);
272
+ this.reference = import_connectors_sdk6.ConnectionRefSchema.parse(reference);
250
273
  if (this.reference.provider !== ProviderID) throw new TypeError("connection provider differs from the manifest");
251
274
  if (!operations) throw new TypeError("connector operations are required");
252
275
  this.operations = operations;
@@ -258,42 +281,30 @@ var GmailConnection = class extends Connection {
258
281
  /** Bind operation implementations to a static named Google connection. */
259
282
  constructor(operations, reference) {
260
283
  if (!operations) throw new TypeError("Gmail connector operations are required");
261
- const validatedReference = import_connectors_sdk6.ConnectionRefSchema.parse(reference);
284
+ const validatedReference = import_connectors_sdk7.ConnectionRefSchema.parse(reference);
262
285
  if (validatedReference.provider !== "google") throw new TypeError("Gmail connection provider must be google");
263
286
  super(validatedReference, operations);
264
287
  }
265
288
  };
266
289
 
267
290
  // src/project.ts
268
- var import_connectors_sdk8 = require("@superdurable/connectors-sdk");
269
- var import_projectconfig = require("@superdurable/connectors-sdk/projectconfig");
270
- var import_zod7 = require("zod");
291
+ var import_connectors_sdk9 = require("@superdurable/connectors-sdk");
292
+ var import_zod5 = require("zod");
271
293
 
272
294
  // src/credential_codec.ts
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()
284
- });
295
+ var import_connectors_sdk8 = require("@superdurable/connectors-sdk");
285
296
 
286
297
  // src/project.ts
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()
298
+ var ProjectGmailConfigurationSchema = import_zod5.z.object({
299
+ endpoint: import_zod5.z.string().optional(),
300
+ maxResponseBytes: import_zod5.z.number().int().safe().optional(),
301
+ maxMessageBytes: import_zod5.z.number().int().safe().optional(),
302
+ pollInterval: import_zod5.z.number().int().safe().optional(),
303
+ pollPageSize: import_zod5.z.number().int().safe().optional()
293
304
  });
294
305
 
295
306
  // src/generated/steps.ts
296
- var import_connectors_sdk9 = require("@superdurable/connectors-sdk");
307
+ var import_connectors_sdk10 = require("@superdurable/connectors-sdk");
297
308
 
298
309
  // src/generated/mock.ts
299
310
  var import_connectormock = require("@superdurable/connectors-sdk/connectormock");
@@ -1,6 +1,6 @@
1
1
  import { Failure } from '@superdurable/connectors-sdk';
2
2
  import { Case, MockQuery, MockMutation } from '@superdurable/connectors-sdk/connectormock';
3
- import { M as Message, e as GmailConnection, G as GetMessageInput, S as SendMessageInput, c as SendMessageOutput, R as ReplyToMessageInput } from '../connection-NE_da2Az.cjs';
3
+ import { M as Message, e as GmailConnection, G as GetMessageInput, S as SendMessageInput, c as SendMessageOutput, R as ReplyToMessageInput } from '../connection-D8OV_Hfe.cjs';
4
4
  import 'zod';
5
5
 
6
6
  /** Script a safe retry of getMessage. */
@@ -1,6 +1,6 @@
1
1
  import { Failure } from '@superdurable/connectors-sdk';
2
2
  import { Case, MockQuery, MockMutation } from '@superdurable/connectors-sdk/connectormock';
3
- import { M as Message, e as GmailConnection, G as GetMessageInput, S as SendMessageInput, c as SendMessageOutput, R as ReplyToMessageInput } from '../connection-NE_da2Az.js';
3
+ import { M as Message, e as GmailConnection, G as GetMessageInput, S as SendMessageInput, c as SendMessageOutput, R as ReplyToMessageInput } from '../connection-D8OV_Hfe.js';
4
4
  import 'zod';
5
5
 
6
6
  /** Script a safe retry of getMessage. */
@@ -10,7 +10,7 @@ import {
10
10
  SendMessageInputSchema,
11
11
  SendMessageOutputSchema,
12
12
  SendMessageOutputSchema2
13
- } from "../chunk-TWBWDIC7.js";
13
+ } from "../chunk-KVNIQW5Y.js";
14
14
 
15
15
  // src/mock/index.ts
16
16
  import { branchCase as branchCase2, newMutation as newMutation2, newQuery as newQuery2, retryCase as retryCase2, uncertainCase } from "@superdurable/connectors-sdk/connectormock";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@superdurable/connector-google-gmail",
3
- "version": "0.1.1",
3
+ "version": "0.2.0",
4
4
  "license": "MIT",
5
5
  "description": "Dex Gmail connector for TypeScript",
6
6
  "repository": {
@@ -35,7 +35,8 @@
35
35
  "types": "./dist/mock/index.d.cts",
36
36
  "default": "./dist/mock/index.cjs"
37
37
  }
38
- }
38
+ },
39
+ "./dex-connector.json": "./dex-connector.json"
39
40
  },
40
41
  "files": [
41
42
  "dist",
@@ -55,7 +56,7 @@
55
56
  "check": "npm run typecheck && npm run test-d && npm run lint && npm test"
56
57
  },
57
58
  "dependencies": {
58
- "@superdurable/connectors-sdk": "0.1.0",
59
+ "@superdurable/connectors-sdk": "0.6.0",
59
60
  "@superdurable/dex": ">=1.28.0",
60
61
  "zod": "^4.1.0"
61
62
  },