@sentry/junior-google 0.244.0 → 0.246.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/README.md +38 -23
- package/dist/config.d.ts +3 -2
- package/dist/credentials.d.ts +31 -0
- package/dist/index.d.ts +3 -3
- package/dist/index.js +433 -106
- package/dist/tools/files.d.ts +76 -0
- package/dist/tools/{list-doc-comments.d.ts → list-file-comments.d.ts} +7 -7
- package/dist/tools/read-doc.d.ts +1 -1
- package/dist/tools/read-sheet.d.ts +145 -0
- package/dist/tools/read-slides.d.ts +144 -0
- package/dist/tools/{search-docs.d.ts → search-files.d.ts} +11 -8
- package/dist/tools/shared.d.ts +2 -1
- package/package.json +2 -2
- package/dist/tools/docs.d.ts +0 -37
package/README.md
CHANGED
|
@@ -4,8 +4,8 @@ Proof of concept. Junior acts as its own Google Workspace account, for example
|
|
|
4
4
|
`junior@sentry.io`. Junior does not use the Google credentials of the people it
|
|
5
5
|
helps. Tracking issue: getsentry/junior#2063.
|
|
6
6
|
|
|
7
|
-
This version supports Calendar and reading Google Docs
|
|
8
|
-
writes are out of scope.
|
|
7
|
+
This version supports Calendar and reading Google Docs, Sheets, and Slides.
|
|
8
|
+
Gmail and Drive writes are out of scope.
|
|
9
9
|
|
|
10
10
|
## Surfaces
|
|
11
11
|
|
|
@@ -42,17 +42,26 @@ writes are out of scope.
|
|
|
42
42
|
annotation on the Conversation. Junior shows its card with the next reply.
|
|
43
43
|
The card shows the title, time, and attendees, and links to the event. A
|
|
44
44
|
change to an event replaces its card.
|
|
45
|
-
- `
|
|
46
|
-
by words in the title or text.
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
- `
|
|
54
|
-
|
|
55
|
-
|
|
45
|
+
- `searchGoogleFiles` finds Google Docs, Sheets, and Slides that are shared
|
|
46
|
+
with Junior's account, by words in the title or text. A search can ask for only
|
|
47
|
+
some of these types. Files that are only shared by public link are not found,
|
|
48
|
+
because Drive search only covers files the account has.
|
|
49
|
+
- The read tools take a link or a file id. They work for files shared with
|
|
50
|
+
Junior's account and for files shared with anyone who has the link. A link's
|
|
51
|
+
`resourcekey` value is sent to Google, because older files shared by link
|
|
52
|
+
need it. Each result stops at 100,000 characters.
|
|
53
|
+
- `readGoogleDoc` reads one Doc as Markdown. Drive exports the Doc, so the
|
|
54
|
+
Docs API is not used.
|
|
55
|
+
- `readGoogleSheet` reads the cells of one Sheet as CSV, with values formatted
|
|
56
|
+
as the Sheet shows them. It reads every tab, or one A1 range such as
|
|
57
|
+
`Budget!A1:F50`. The result names every tab, so Junior can ask for a smaller
|
|
58
|
+
range when a Sheet is too large. A Drive CSV export has only the first tab,
|
|
59
|
+
so this tool uses the Sheets API.
|
|
60
|
+
- `readGoogleSlides` reads the text and speaker notes of each slide, with
|
|
61
|
+
tables as `|` rows. It uses the Slides API to keep slide numbers and notes.
|
|
62
|
+
- `listGoogleFileComments` reads the comments and replies on one Doc, Sheet,
|
|
63
|
+
or Slides file, 100 per call. Each comment gives its author name, text, the
|
|
64
|
+
file text it is attached to, and whether it is resolved.
|
|
56
65
|
- The **Google account** page on the dashboard Admin page shows whether the
|
|
57
66
|
account is connected. Its Connect button starts Google sign-in.
|
|
58
67
|
- `junior google connect` and `junior google status` are the operator CLI.
|
|
@@ -69,7 +78,7 @@ own.
|
|
|
69
78
|
2. Google sign-in opens with PKCE and a single-use state value.
|
|
70
79
|
3. The admin signs in as the configured account, not as themselves.
|
|
71
80
|
4. Junior checks that the identity token names the configured account. It also
|
|
72
|
-
checks that Google granted every Calendar and
|
|
81
|
+
checks that Google granted every Calendar and Drive scope. If a check
|
|
73
82
|
fails, Junior revokes the grant and stores nothing.
|
|
74
83
|
5. Junior stores the refresh token in the `junior_google_accounts` table.
|
|
75
84
|
|
|
@@ -95,9 +104,11 @@ request and the tool asks an admin to reconnect.
|
|
|
95
104
|
also keeps events that other people organize out of reach.
|
|
96
105
|
- Calendar scopes are `calendar.events.freebusy`, `calendar.events.readonly`,
|
|
97
106
|
and `calendar.events.owned`.
|
|
98
|
-
- The
|
|
99
|
-
narrower read scope
|
|
100
|
-
file metadata, export, and
|
|
107
|
+
- The Drive scope is `drive.readonly`. The Drive comments API accepts no
|
|
108
|
+
narrower read scope, and the Sheets and Slides APIs also accept it. Junior
|
|
109
|
+
permits only these requests: Drive file search, file metadata, export, and
|
|
110
|
+
comment reads; Sheets metadata and cell reads; and Slides reads. Each
|
|
111
|
+
request must go to the host of its own API.
|
|
101
112
|
- Junior also requests `openid email` to verify the account during sign-in.
|
|
102
113
|
|
|
103
114
|
## Setup
|
|
@@ -107,9 +118,11 @@ sign-in requests only its own scopes, so dashboard sign-in still asks only for
|
|
|
107
118
|
identity.
|
|
108
119
|
|
|
109
120
|
1. In the Google Cloud project of the dashboard OAuth client, enable the
|
|
110
|
-
Google Calendar API
|
|
121
|
+
Google Calendar API, Google Drive API, Google Sheets API, and Google Slides
|
|
122
|
+
API. If an API is not enabled, its tool tells the requester that an admin
|
|
123
|
+
must enable it.
|
|
111
124
|
2. On the OAuth consent screen, use user type **Internal** and add the
|
|
112
|
-
Calendar and
|
|
125
|
+
Calendar and Drive scopes above. `drive.readonly` is a restricted scope.
|
|
113
126
|
An Internal app does not need Google verification for it.
|
|
114
127
|
3. On the OAuth client, add these redirect URIs:
|
|
115
128
|
- `https://<junior host>/api/plugins/google/oauth/callback`
|
|
@@ -143,11 +156,13 @@ variables are set. The Admin page shows **Not configured** until then.
|
|
|
143
156
|
- Anyone who can talk to Junior can ask it to read a colleague's calendar.
|
|
144
157
|
Junior returns what its own account can see, so set the sharing default
|
|
145
158
|
with that in mind.
|
|
146
|
-
- Anyone who can talk to Junior can also ask it to read any
|
|
147
|
-
Junior's account. Share a
|
|
159
|
+
- Anyone who can talk to Junior can also ask it to read any file shared with
|
|
160
|
+
Junior's account. Share a file with that account only when everyone who can
|
|
148
161
|
talk to Junior may read it.
|
|
149
|
-
- `drive.readonly` lets the account read every Drive file it can open
|
|
150
|
-
|
|
162
|
+
- `drive.readonly` lets the account read every Drive file it can open. The
|
|
163
|
+
tools read only Google Docs, Sheets, and Slides.
|
|
164
|
+
- `readGoogleSheet` does not return formulas, notes on cells, or charts.
|
|
165
|
+
`readGoogleSlides` does not describe images or charts.
|
|
151
166
|
- Google does not expose the working hours that people set in Calendar.
|
|
152
167
|
Junior uses each calendar's time zone and one shared workday instead.
|
|
153
168
|
- Junior cannot find or book meeting rooms. Room discovery needs the Admin
|
package/dist/config.d.ts
CHANGED
|
@@ -18,8 +18,9 @@ export declare const GOOGLE_ALLOWED_DOMAINS_ENV = "GOOGLE_WORKSPACE_ALLOWED_DOMA
|
|
|
18
18
|
* still decide how much detail each calendar shows.
|
|
19
19
|
* - `calendar.events.owned`: create and change events on Junior's own
|
|
20
20
|
* calendar.
|
|
21
|
-
* - `drive.readonly`: search, export,
|
|
22
|
-
* comments API accepts no narrower read scope.
|
|
21
|
+
* - `drive.readonly`: search Drive, export Docs, read Sheets and Slides, and
|
|
22
|
+
* read comments. The Drive comments API accepts no narrower read scope. The
|
|
23
|
+
* Sheets and Slides APIs also accept this scope.
|
|
23
24
|
*/
|
|
24
25
|
export declare const GOOGLE_API_SCOPES: readonly ["https://www.googleapis.com/auth/calendar.events.freebusy", "https://www.googleapis.com/auth/calendar.events.owned", "https://www.googleapis.com/auth/calendar.events.readonly", "https://www.googleapis.com/auth/drive.readonly"];
|
|
25
26
|
/** Identity scopes used only to verify which account signed in. */
|
package/dist/credentials.d.ts
CHANGED
|
@@ -6,56 +6,87 @@
|
|
|
6
6
|
* callers get no Google credential at all.
|
|
7
7
|
*/
|
|
8
8
|
import { type EgressHookContext, type IssueCredentialHookContext, type PluginCredentialResult, type PluginGrant } from "@sentry/junior-plugin-api";
|
|
9
|
+
/** Calendar and Drive API host. */
|
|
9
10
|
export declare const GOOGLE_API_DOMAIN = "www.googleapis.com";
|
|
11
|
+
/** Every host that receives Junior's Google access token. */
|
|
12
|
+
export declare const GOOGLE_API_DOMAINS: string[];
|
|
10
13
|
/** Google API operations that plugin tools may perform. */
|
|
11
14
|
export declare const GOOGLE_OPERATIONS: {
|
|
12
15
|
readonly "google.calendar.event.create": {
|
|
13
16
|
readonly access: "write";
|
|
17
|
+
readonly host: "www.googleapis.com";
|
|
14
18
|
readonly method: "POST";
|
|
15
19
|
readonly path: RegExp;
|
|
16
20
|
};
|
|
17
21
|
readonly "google.calendar.event.delete": {
|
|
18
22
|
readonly access: "write";
|
|
23
|
+
readonly host: "www.googleapis.com";
|
|
19
24
|
readonly method: "DELETE";
|
|
20
25
|
readonly path: RegExp;
|
|
21
26
|
};
|
|
22
27
|
readonly "google.calendar.event.get": {
|
|
23
28
|
readonly access: "read";
|
|
29
|
+
readonly host: "www.googleapis.com";
|
|
24
30
|
readonly method: "GET";
|
|
25
31
|
readonly path: RegExp;
|
|
26
32
|
};
|
|
27
33
|
readonly "google.calendar.event.update": {
|
|
28
34
|
readonly access: "write";
|
|
35
|
+
readonly host: "www.googleapis.com";
|
|
29
36
|
readonly method: "PATCH";
|
|
30
37
|
readonly path: RegExp;
|
|
31
38
|
};
|
|
32
39
|
readonly "google.calendar.events.list": {
|
|
33
40
|
readonly access: "read";
|
|
41
|
+
readonly host: "www.googleapis.com";
|
|
34
42
|
readonly method: "GET";
|
|
35
43
|
readonly path: RegExp;
|
|
36
44
|
};
|
|
37
45
|
readonly "google.calendar.freebusy.query": {
|
|
38
46
|
readonly access: "read";
|
|
47
|
+
readonly host: "www.googleapis.com";
|
|
39
48
|
readonly method: "POST";
|
|
40
49
|
readonly path: RegExp;
|
|
41
50
|
};
|
|
42
51
|
readonly "google.drive.comments.list": {
|
|
43
52
|
readonly access: "read";
|
|
53
|
+
readonly host: "www.googleapis.com";
|
|
44
54
|
readonly method: "GET";
|
|
45
55
|
readonly path: RegExp;
|
|
46
56
|
};
|
|
47
57
|
readonly "google.drive.file.export": {
|
|
48
58
|
readonly access: "read";
|
|
59
|
+
readonly host: "www.googleapis.com";
|
|
49
60
|
readonly method: "GET";
|
|
50
61
|
readonly path: RegExp;
|
|
51
62
|
};
|
|
52
63
|
readonly "google.drive.file.get": {
|
|
53
64
|
readonly access: "read";
|
|
65
|
+
readonly host: "www.googleapis.com";
|
|
54
66
|
readonly method: "GET";
|
|
55
67
|
readonly path: RegExp;
|
|
56
68
|
};
|
|
57
69
|
readonly "google.drive.files.list": {
|
|
58
70
|
readonly access: "read";
|
|
71
|
+
readonly host: "www.googleapis.com";
|
|
72
|
+
readonly method: "GET";
|
|
73
|
+
readonly path: RegExp;
|
|
74
|
+
};
|
|
75
|
+
readonly "google.sheets.spreadsheet.get": {
|
|
76
|
+
readonly access: "read";
|
|
77
|
+
readonly host: "sheets.googleapis.com";
|
|
78
|
+
readonly method: "GET";
|
|
79
|
+
readonly path: RegExp;
|
|
80
|
+
};
|
|
81
|
+
readonly "google.sheets.values.batchGet": {
|
|
82
|
+
readonly access: "read";
|
|
83
|
+
readonly host: "sheets.googleapis.com";
|
|
84
|
+
readonly method: "GET";
|
|
85
|
+
readonly path: RegExp;
|
|
86
|
+
};
|
|
87
|
+
readonly "google.slides.presentation.get": {
|
|
88
|
+
readonly access: "read";
|
|
89
|
+
readonly host: "slides.googleapis.com";
|
|
59
90
|
readonly method: "GET";
|
|
60
91
|
readonly path: RegExp;
|
|
61
92
|
};
|
package/dist/index.d.ts
CHANGED
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
* Google plugin runtime boundary.
|
|
3
3
|
*
|
|
4
4
|
* Junior acts as its own Google Workspace account. A Junior admin connects
|
|
5
|
-
* that account out of band, through the dashboard Admin page or the CLI.
|
|
6
|
-
*
|
|
7
|
-
* credential.
|
|
5
|
+
* that account out of band, through the dashboard Admin page or the CLI.
|
|
6
|
+
* Calendar, Docs, Sheets, and Slides tools use host-owned egress, and the
|
|
7
|
+
* sandbox gets no Google credential.
|
|
8
8
|
*/
|
|
9
9
|
import { type PluginRegistration } from "@sentry/junior-plugin-api";
|
|
10
10
|
/** Register Junior's Google Workspace plugin. */
|