@mshindi-labs/google 1.2.1 → 1.3.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 +4 -2
- package/dist/calendar.cjs +118 -166
- package/dist/calendar.cjs.map +1 -1
- package/dist/calendar.d.cts +1 -1
- package/dist/calendar.d.ts +1 -1
- package/dist/calendar.js +49 -97
- package/dist/calendar.js.map +1 -1
- package/dist/chunk-2MJE3WQ5.js +63 -0
- package/dist/chunk-2MJE3WQ5.js.map +1 -0
- package/dist/chunk-4UEM6VO4.cjs +119 -0
- package/dist/chunk-4UEM6VO4.cjs.map +1 -0
- package/dist/{chunk-FCHXM22B.js → chunk-6VGR73PY.js} +45 -2
- package/dist/{chunk-FCHXM22B.js.map → chunk-6VGR73PY.js.map} +1 -1
- package/dist/{chunk-6RDWEYXZ.js → chunk-7YVRJ3GY.js} +5 -4
- package/dist/chunk-7YVRJ3GY.js.map +1 -0
- package/dist/chunk-7ZLAL7UY.cjs +63 -0
- package/dist/chunk-7ZLAL7UY.cjs.map +1 -0
- package/dist/chunk-BYHOVCN3.cjs +20 -0
- package/dist/chunk-BYHOVCN3.cjs.map +1 -0
- package/dist/chunk-JA2JLBNN.js +119 -0
- package/dist/chunk-JA2JLBNN.js.map +1 -0
- package/dist/{chunk-DPAPYMB3.cjs → chunk-KFQ4O6MT.cjs} +57 -56
- package/dist/chunk-KFQ4O6MT.cjs.map +1 -0
- package/dist/chunk-LWCB3V7V.js +20 -0
- package/dist/chunk-LWCB3V7V.js.map +1 -0
- package/dist/{chunk-S357VL5V.cjs → chunk-MFVFONV7.cjs} +58 -17
- package/dist/chunk-MFVFONV7.cjs.map +1 -0
- package/dist/{chunk-6PMJ6VB6.cjs → chunk-RWRVNSQG.cjs} +6 -6
- package/dist/{chunk-6PMJ6VB6.cjs.map → chunk-RWRVNSQG.cjs.map} +1 -1
- package/dist/chunk-TXOTIP4G.js +97 -0
- package/dist/chunk-TXOTIP4G.js.map +1 -0
- package/dist/{chunk-SXD5K23S.js → chunk-UR3KSPDZ.js} +2 -2
- package/dist/{chunk-JZVDD4DL.cjs → chunk-UUXXCUIB.cjs} +45 -2
- package/dist/chunk-UUXXCUIB.cjs.map +1 -0
- package/dist/{chunk-JDA3ZRUY.cjs → chunk-V5Q6XSYZ.cjs} +3 -3
- package/dist/{chunk-JDA3ZRUY.cjs.map → chunk-V5Q6XSYZ.cjs.map} +1 -1
- package/dist/{chunk-4V5ZJNPI.js → chunk-ZPDFK5VR.js} +2 -2
- package/dist/core.cjs +28 -18
- package/dist/core.cjs.map +1 -1
- package/dist/core.d.cts +19 -2
- package/dist/core.d.ts +19 -2
- package/dist/core.js +14 -4
- package/dist/core.js.map +1 -1
- package/dist/{create-google-Bo8_Nc1C.d.cts → create-google-B0fX1ixG.d.cts} +1 -0
- package/dist/{create-google-snvkHaEk.d.ts → create-google-CjsKhktN.d.ts} +1 -0
- package/dist/gmail.cjs +47 -45
- package/dist/gmail.cjs.map +1 -1
- package/dist/gmail.d.cts +1 -1
- package/dist/gmail.d.ts +1 -1
- package/dist/gmail.js +13 -11
- package/dist/gmail.js.map +1 -1
- package/dist/postgres.cjs +8 -8
- package/dist/postgres.js +1 -1
- package/dist/sheets.cjs +1317 -0
- package/dist/sheets.cjs.map +1 -0
- package/dist/sheets.d.cts +292 -0
- package/dist/sheets.d.ts +292 -0
- package/dist/sheets.js +1317 -0
- package/dist/sheets.js.map +1 -0
- package/dist/testing.cjs +905 -38
- package/dist/testing.cjs.map +1 -1
- package/dist/testing.d.cts +133 -1
- package/dist/testing.d.ts +133 -1
- package/dist/testing.js +897 -30
- package/dist/testing.js.map +1 -1
- package/dist/transport-uuotQ13Y.d.cts +137 -0
- package/dist/transport-uuotQ13Y.d.ts +137 -0
- package/package.json +18 -1
- package/dist/chunk-6RDWEYXZ.js.map +0 -1
- package/dist/chunk-AMBBE4TW.js +0 -56
- package/dist/chunk-AMBBE4TW.js.map +0 -1
- package/dist/chunk-DPAPYMB3.cjs.map +0 -1
- package/dist/chunk-JZVDD4DL.cjs.map +0 -1
- package/dist/chunk-S357VL5V.cjs.map +0 -1
- /package/dist/{chunk-SXD5K23S.js.map → chunk-UR3KSPDZ.js.map} +0 -0
- /package/dist/{chunk-4V5ZJNPI.js.map → chunk-ZPDFK5VR.js.map} +0 -0
package/dist/calendar.js
CHANGED
|
@@ -1,31 +1,37 @@
|
|
|
1
1
|
import {
|
|
2
|
+
normalizeEmail
|
|
3
|
+
} from "./chunk-LWCB3V7V.js";
|
|
4
|
+
import {
|
|
5
|
+
withConnectionToken
|
|
6
|
+
} from "./chunk-2MJE3WQ5.js";
|
|
7
|
+
import {
|
|
8
|
+
RATE_REASONS,
|
|
2
9
|
asErr,
|
|
3
|
-
|
|
10
|
+
defaultSleep,
|
|
11
|
+
peerAuthClient,
|
|
4
12
|
readMessages,
|
|
5
13
|
readNetCode,
|
|
6
14
|
readReason,
|
|
7
15
|
readRetryAfterMs,
|
|
8
|
-
readStatus
|
|
9
|
-
|
|
16
|
+
readStatus,
|
|
17
|
+
runWithRetry
|
|
18
|
+
} from "./chunk-TXOTIP4G.js";
|
|
10
19
|
import {
|
|
11
|
-
assertServiceScopes,
|
|
12
20
|
internals
|
|
13
|
-
} from "./chunk-
|
|
21
|
+
} from "./chunk-7YVRJ3GY.js";
|
|
14
22
|
import {
|
|
15
23
|
loadPeer
|
|
16
|
-
} from "./chunk-
|
|
24
|
+
} from "./chunk-UR3KSPDZ.js";
|
|
17
25
|
import {
|
|
18
26
|
ConferencingUnavailableError,
|
|
19
|
-
ConnectionRevokedError,
|
|
20
27
|
EventCancelledError,
|
|
21
28
|
EventConflictError,
|
|
22
29
|
EventNotFoundError,
|
|
23
30
|
EventNotManagedError,
|
|
24
31
|
GoogleApiError,
|
|
25
32
|
GoogleLibError,
|
|
26
|
-
InvalidEventError
|
|
27
|
-
|
|
28
|
-
} from "./chunk-FCHXM22B.js";
|
|
33
|
+
InvalidEventError
|
|
34
|
+
} from "./chunk-6VGR73PY.js";
|
|
29
35
|
|
|
30
36
|
// src/calendar/service.ts
|
|
31
37
|
import { randomUUID } from "crypto";
|
|
@@ -105,7 +111,6 @@ var NETWORK_CODES = /* @__PURE__ */ new Set([
|
|
|
105
111
|
"ETIMEDOUT",
|
|
106
112
|
"ESOCKETTIMEDOUT"
|
|
107
113
|
]);
|
|
108
|
-
var RATE_REASONS = /* @__PURE__ */ new Set(["rateLimitExceeded", "userRateLimitExceeded"]);
|
|
109
114
|
function classifyCalendarError(err) {
|
|
110
115
|
if (err instanceof GoogleLibError) return { kind: "fail", error: err };
|
|
111
116
|
const e = asErr(err);
|
|
@@ -138,42 +143,27 @@ function classifyCalendarError(err) {
|
|
|
138
143
|
}
|
|
139
144
|
return { kind: "fail", error: new GoogleApiError(0, code, opts) };
|
|
140
145
|
}
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
const capMs = opts.capMs ?? 8e3;
|
|
146
|
-
const sleep = opts.sleep ?? defaultSleep;
|
|
147
|
-
const random = opts.random ?? Math.random;
|
|
148
|
-
for (let attempt = 0; ; attempt++) {
|
|
149
|
-
try {
|
|
150
|
-
return await fn();
|
|
151
|
-
} catch (err) {
|
|
146
|
+
function withCalendarRetry(fn, opts = {}) {
|
|
147
|
+
return runWithRetry(fn, {
|
|
148
|
+
...opts,
|
|
149
|
+
classify: (err) => {
|
|
152
150
|
const c = classifyCalendarError(err);
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
151
|
+
switch (c.kind) {
|
|
152
|
+
case "retry":
|
|
153
|
+
return c;
|
|
154
|
+
case "fail":
|
|
155
|
+
return { kind: "throw", error: c.error };
|
|
156
|
+
case "unauthorized":
|
|
157
|
+
return { kind: "throw", error: new CalendarUnauthorizedSignal() };
|
|
158
|
+
case "duplicate":
|
|
159
|
+
return { kind: "throw", error: new DuplicateEventSignal() };
|
|
160
|
+
case "gone":
|
|
161
|
+
return { kind: "throw", error: new EventGoneSignal() };
|
|
162
|
+
case "precondition":
|
|
163
|
+
return { kind: "throw", error: new PreconditionFailedSignal() };
|
|
160
164
|
}
|
|
161
|
-
if (attempt + 1 >= maxAttempts) {
|
|
162
|
-
const e = asErr(err);
|
|
163
|
-
const status = readStatus(e);
|
|
164
|
-
if (status === 429 || status === 403) {
|
|
165
|
-
throw new RateLimitedError(c.delayMs, { cause: err });
|
|
166
|
-
}
|
|
167
|
-
if (status !== null) {
|
|
168
|
-
throw new GoogleApiError(status, readReason(e), { cause: err });
|
|
169
|
-
}
|
|
170
|
-
throw new GoogleApiError(0, readNetCode(e), { cause: err });
|
|
171
|
-
}
|
|
172
|
-
await sleep(
|
|
173
|
-
c.delayMs ?? random() * Math.min(capMs, baseMs * 2 ** attempt)
|
|
174
|
-
);
|
|
175
165
|
}
|
|
176
|
-
}
|
|
166
|
+
});
|
|
177
167
|
}
|
|
178
168
|
|
|
179
169
|
// src/calendar/time.ts
|
|
@@ -521,15 +511,14 @@ function findCommonSlots(input) {
|
|
|
521
511
|
}
|
|
522
512
|
|
|
523
513
|
// src/calendar/transport.ts
|
|
524
|
-
import { OAuth2Client } from "google-auth-library";
|
|
525
514
|
var CALENDAR_ID = "primary";
|
|
526
515
|
var ifMatchArgs = (ifMatch) => ifMatch === void 0 ? [] : [{ headers: { "If-Match": ifMatch } }];
|
|
527
516
|
function createCalendarApiTransport() {
|
|
528
517
|
const client = async (accessToken) => {
|
|
529
518
|
const mod = await loadPeer("@googleapis/calendar");
|
|
530
|
-
const
|
|
531
|
-
const
|
|
532
|
-
auth
|
|
519
|
+
const peer = mod.calendar ? mod : mod.default;
|
|
520
|
+
const { calendar } = peer;
|
|
521
|
+
const auth = peerAuthClient(peer, accessToken);
|
|
533
522
|
return calendar({ version: "v3", auth });
|
|
534
523
|
};
|
|
535
524
|
return {
|
|
@@ -859,7 +848,6 @@ var PATCH_ATTEMPTS = 3;
|
|
|
859
848
|
var MAX_EVENT_MS2 = 24 * 36e5;
|
|
860
849
|
var BACKOFF_BASE_MS = 250;
|
|
861
850
|
var BACKOFF_CAP_MS = 8e3;
|
|
862
|
-
var defaultSleep2 = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
|
|
863
851
|
var conferenceStatus = (e) => e.conferenceData?.createRequest?.status?.statusCode;
|
|
864
852
|
var meetReady = (e) => conferenceStatus(e) === "success" && (e.conferenceData?.entryPoints ?? []).some(
|
|
865
853
|
(p) => p.entryPointType === "video" && typeof p.uri === "string"
|
|
@@ -1043,59 +1031,23 @@ function createCalendar(google, opts = {}) {
|
|
|
1043
1031
|
...opts.random ? { random: opts.random } : {}
|
|
1044
1032
|
};
|
|
1045
1033
|
const retry = (fn) => withCalendarRetry(fn, retryOpts);
|
|
1046
|
-
const sleep = opts.sleep ??
|
|
1034
|
+
const sleep = opts.sleep ?? defaultSleep;
|
|
1047
1035
|
const random = opts.random ?? Math.random;
|
|
1048
1036
|
const rethrow = (err) => withCalendarRetry(() => Promise.reject(err), {
|
|
1049
1037
|
...retryOpts,
|
|
1050
1038
|
maxAttempts: 1
|
|
1051
1039
|
});
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
const fresh = await tokens.getAccessToken(tenantId, connectionId, {
|
|
1064
|
-
forceRefresh: true
|
|
1065
|
-
});
|
|
1066
|
-
try {
|
|
1067
|
-
result = await fn(fresh.accessToken, view);
|
|
1068
|
-
} catch (err2) {
|
|
1069
|
-
if (!(err2 instanceof CalendarUnauthorizedSignal)) throw err2;
|
|
1070
|
-
await store.updateConnectionStatus(
|
|
1071
|
-
tenantId,
|
|
1072
|
-
connectionId,
|
|
1073
|
-
"revoked",
|
|
1074
|
-
"unauthorized"
|
|
1075
|
-
);
|
|
1076
|
-
tokens.evict(connectionId);
|
|
1077
|
-
await emit({
|
|
1078
|
-
type: "connection.revoked",
|
|
1079
|
-
tenantId,
|
|
1080
|
-
connectionId,
|
|
1081
|
-
reason: "unauthorized",
|
|
1082
|
-
at: now()
|
|
1083
|
-
});
|
|
1084
|
-
throw new ConnectionRevokedError("unauthorized", {
|
|
1085
|
-
tenantId,
|
|
1086
|
-
connectionId
|
|
1087
|
-
});
|
|
1088
|
-
}
|
|
1089
|
-
}
|
|
1090
|
-
try {
|
|
1091
|
-
await store.touchConnection(tenantId, connectionId, now());
|
|
1092
|
-
} catch {
|
|
1093
|
-
try {
|
|
1094
|
-
logger?.warn("google touchConnection failed");
|
|
1095
|
-
} catch {
|
|
1096
|
-
}
|
|
1097
|
-
}
|
|
1098
|
-
return result;
|
|
1040
|
+
function withToken(tenantId, connectionId, fn) {
|
|
1041
|
+
return withConnectionToken(
|
|
1042
|
+
google,
|
|
1043
|
+
{
|
|
1044
|
+
tenantId,
|
|
1045
|
+
connectionId,
|
|
1046
|
+
service: "calendar",
|
|
1047
|
+
isUnauthorized: (e) => e instanceof CalendarUnauthorizedSignal
|
|
1048
|
+
},
|
|
1049
|
+
fn
|
|
1050
|
+
);
|
|
1099
1051
|
}
|
|
1100
1052
|
const warn = (message) => {
|
|
1101
1053
|
try {
|