google-mcp-suite 1.9.0 → 1.10.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.
Files changed (242) hide show
  1. package/ADOPTING.md +3 -1
  2. package/PROVISIONING.md +7 -5
  3. package/README.md +10 -5
  4. package/dist/auth/oauth.d.ts.map +1 -1
  5. package/dist/auth/oauth.js +35 -4
  6. package/dist/auth/oauth.js.map +1 -1
  7. package/dist/calendar/instructions.js +1 -1
  8. package/dist/calendar/instructions.js.map +1 -1
  9. package/dist/calendar/lib/attendees.d.ts +1 -1
  10. package/dist/calendar/lib/attendees.d.ts.map +1 -1
  11. package/dist/calendar/lib/attendees.js +2 -1
  12. package/dist/calendar/lib/attendees.js.map +1 -1
  13. package/dist/calendar/lib/datetime.d.ts +1 -1
  14. package/dist/calendar/lib/datetime.d.ts.map +1 -1
  15. package/dist/calendar/lib/datetime.js +1 -1
  16. package/dist/calendar/lib/datetime.js.map +1 -1
  17. package/dist/calendar/lib/event.js +1 -1
  18. package/dist/calendar/lib/event.js.map +1 -1
  19. package/dist/calendar/lib/meet.d.ts +1 -1
  20. package/dist/calendar/lib/meet.d.ts.map +1 -1
  21. package/dist/calendar/lib/meet.js.map +1 -1
  22. package/dist/calendar/lib/notifications.d.ts +1 -1
  23. package/dist/calendar/lib/notifications.d.ts.map +1 -1
  24. package/dist/calendar/lib/notifications.js.map +1 -1
  25. package/dist/calendar/lib/suggest.d.ts +1 -1
  26. package/dist/calendar/lib/suggest.d.ts.map +1 -1
  27. package/dist/calendar/lib/suggest.js.map +1 -1
  28. package/dist/calendar/methods/create_calendar/handler.js +1 -1
  29. package/dist/calendar/methods/create_calendar/handler.js.map +1 -1
  30. package/dist/calendar/methods/list_event_instances/handler.js +1 -1
  31. package/dist/calendar/methods/list_event_instances/handler.js.map +1 -1
  32. package/dist/calendar/methods/list_settings/handler.js +1 -1
  33. package/dist/calendar/methods/list_settings/handler.js.map +1 -1
  34. package/dist/calendar/methods/move_event/handler.js +1 -1
  35. package/dist/calendar/methods/move_event/handler.js.map +1 -1
  36. package/dist/calendar/methods/patch_event/handler.js +1 -1
  37. package/dist/calendar/methods/patch_event/handler.js.map +1 -1
  38. package/dist/calendar/methods/patch_event/index.d.ts +1 -1
  39. package/dist/calendar/methods/patch_event/schema.d.ts +1 -1
  40. package/dist/calendar/methods/query_free_busy/handler.js +1 -1
  41. package/dist/calendar/methods/query_free_busy/handler.js.map +1 -1
  42. package/dist/calendar/methods/quick_add_event/handler.js +1 -1
  43. package/dist/calendar/methods/quick_add_event/handler.js.map +1 -1
  44. package/dist/calendar/methods/registry.d.ts +1 -1
  45. package/dist/calendar/methods/update_calendar/handler.js +1 -1
  46. package/dist/calendar/methods/update_calendar/handler.js.map +1 -1
  47. package/dist/calendar/methods/update_calendar_entry/handler.js +1 -1
  48. package/dist/calendar/methods/update_calendar_entry/handler.js.map +1 -1
  49. package/dist/calendar/tools/create_event/handler.js +1 -1
  50. package/dist/calendar/tools/create_event/handler.js.map +1 -1
  51. package/dist/calendar/tools/list_calendars/handler.js +1 -1
  52. package/dist/calendar/tools/list_calendars/handler.js.map +1 -1
  53. package/dist/calendar/tools/list_calendars/index.d.ts +1 -1
  54. package/dist/calendar/tools/list_calendars/schema.d.ts +1 -1
  55. package/dist/calendar/tools/list_events/handler.js +1 -1
  56. package/dist/calendar/tools/list_events/handler.js.map +1 -1
  57. package/dist/calendar/tools/list_events/index.d.ts +1 -1
  58. package/dist/calendar/tools/list_events/schema.d.ts +1 -1
  59. package/dist/calendar/tools/registry.d.ts +2 -2
  60. package/dist/calendar/tools/suggest_time/handler.js +1 -1
  61. package/dist/calendar/tools/suggest_time/handler.js.map +1 -1
  62. package/dist/calendar/tools/update_event/handler.js +1 -1
  63. package/dist/calendar/tools/update_event/handler.js.map +1 -1
  64. package/dist/docs/instructions.js +1 -1
  65. package/dist/docs/instructions.js.map +1 -1
  66. package/dist/docs/methods/replace_all_text/handler.js +1 -1
  67. package/dist/docs/methods/replace_all_text/handler.js.map +1 -1
  68. package/dist/docs/methods/update_paragraph_style/handler.js +1 -1
  69. package/dist/docs/methods/update_paragraph_style/handler.js.map +1 -1
  70. package/dist/docs/methods/update_text_style/handler.js +1 -1
  71. package/dist/docs/methods/update_text_style/handler.js.map +1 -1
  72. package/dist/doctor/accounts.d.ts +7 -4
  73. package/dist/doctor/accounts.d.ts.map +1 -1
  74. package/dist/doctor/accounts.js +8 -14
  75. package/dist/doctor/accounts.js.map +1 -1
  76. package/dist/doctor/diagnose.d.ts.map +1 -1
  77. package/dist/doctor/diagnose.js +2 -1
  78. package/dist/doctor/diagnose.js.map +1 -1
  79. package/dist/doctor/index.js +2 -1
  80. package/dist/doctor/index.js.map +1 -1
  81. package/dist/doctor/status.d.ts.map +1 -1
  82. package/dist/doctor/status.js +4 -3
  83. package/dist/doctor/status.js.map +1 -1
  84. package/dist/drive/instructions.js +1 -1
  85. package/dist/drive/instructions.js.map +1 -1
  86. package/dist/drive/lib/comment.js +1 -1
  87. package/dist/drive/lib/comment.js.map +1 -1
  88. package/dist/drive/lib/content.d.ts +2 -7
  89. package/dist/drive/lib/content.d.ts.map +1 -1
  90. package/dist/drive/lib/content.js +4 -18
  91. package/dist/drive/lib/content.js.map +1 -1
  92. package/dist/drive/lib/file.js +1 -1
  93. package/dist/drive/lib/file.js.map +1 -1
  94. package/dist/drive/lib/query.d.ts.map +1 -1
  95. package/dist/drive/lib/query.js +3 -8
  96. package/dist/drive/lib/query.js.map +1 -1
  97. package/dist/drive/methods/create_comment/handler.js +1 -1
  98. package/dist/drive/methods/create_comment/handler.js.map +1 -1
  99. package/dist/drive/methods/create_reply/handler.js +1 -1
  100. package/dist/drive/methods/create_reply/handler.js.map +1 -1
  101. package/dist/drive/methods/delete_shared_drive/handler.js +1 -1
  102. package/dist/drive/methods/delete_shared_drive/handler.js.map +1 -1
  103. package/dist/drive/methods/empty_trash/handler.js +1 -1
  104. package/dist/drive/methods/empty_trash/handler.js.map +1 -1
  105. package/dist/drive/methods/get_comment/handler.js +1 -1
  106. package/dist/drive/methods/get_comment/handler.js.map +1 -1
  107. package/dist/drive/methods/get_reply/handler.js +1 -1
  108. package/dist/drive/methods/get_reply/handler.js.map +1 -1
  109. package/dist/drive/methods/get_shared_drive/handler.js +1 -1
  110. package/dist/drive/methods/get_shared_drive/handler.js.map +1 -1
  111. package/dist/drive/methods/list_comments/handler.js +1 -1
  112. package/dist/drive/methods/list_comments/handler.js.map +1 -1
  113. package/dist/drive/methods/list_replies/handler.js +1 -1
  114. package/dist/drive/methods/list_replies/handler.js.map +1 -1
  115. package/dist/drive/methods/list_revisions/handler.js +1 -1
  116. package/dist/drive/methods/list_revisions/handler.js.map +1 -1
  117. package/dist/drive/methods/list_shared_drives/handler.js +1 -1
  118. package/dist/drive/methods/list_shared_drives/handler.js.map +1 -1
  119. package/dist/drive/methods/update_file/handler.js +1 -1
  120. package/dist/drive/methods/update_file/handler.js.map +1 -1
  121. package/dist/drive/methods/update_revision/handler.js +1 -1
  122. package/dist/drive/methods/update_revision/handler.js.map +1 -1
  123. package/dist/drive/methods/update_shared_drive/handler.js +1 -1
  124. package/dist/drive/methods/update_shared_drive/handler.js.map +1 -1
  125. package/dist/drive/tools/copy_file/handler.js +1 -1
  126. package/dist/drive/tools/copy_file/handler.js.map +1 -1
  127. package/dist/drive/tools/create_file/handler.d.ts.map +1 -1
  128. package/dist/drive/tools/create_file/handler.js +4 -9
  129. package/dist/drive/tools/create_file/handler.js.map +1 -1
  130. package/dist/drive/tools/download_file_content/handler.d.ts.map +1 -1
  131. package/dist/drive/tools/download_file_content/handler.js +12 -3
  132. package/dist/drive/tools/download_file_content/handler.js.map +1 -1
  133. package/dist/drive/tools/get_file_permissions/handler.js +1 -1
  134. package/dist/drive/tools/get_file_permissions/handler.js.map +1 -1
  135. package/dist/drive/tools/list_recent_files/handler.js +1 -1
  136. package/dist/drive/tools/list_recent_files/handler.js.map +1 -1
  137. package/dist/drive/tools/read_file_content/handler.d.ts.map +1 -1
  138. package/dist/drive/tools/read_file_content/handler.js +12 -3
  139. package/dist/drive/tools/read_file_content/handler.js.map +1 -1
  140. package/dist/drive/tools/search_files/handler.js +1 -1
  141. package/dist/drive/tools/search_files/handler.js.map +1 -1
  142. package/dist/gmail/instructions.js +1 -1
  143. package/dist/gmail/instructions.js.map +1 -1
  144. package/dist/gmail/lib/filter.js +1 -1
  145. package/dist/gmail/lib/filter.js.map +1 -1
  146. package/dist/gmail/lib/message.d.ts +1 -1
  147. package/dist/gmail/lib/message.d.ts.map +1 -1
  148. package/dist/gmail/lib/message.js.map +1 -1
  149. package/dist/gmail/methods/batch_modify_messages/handler.js +1 -1
  150. package/dist/gmail/methods/batch_modify_messages/handler.js.map +1 -1
  151. package/dist/gmail/methods/create_filter/handler.js +1 -1
  152. package/dist/gmail/methods/create_filter/handler.js.map +1 -1
  153. package/dist/gmail/methods/download_attachment/handler.d.ts.map +1 -1
  154. package/dist/gmail/methods/download_attachment/handler.js +2 -4
  155. package/dist/gmail/methods/download_attachment/handler.js.map +1 -1
  156. package/dist/gmail/methods/list_messages/handler.js +1 -1
  157. package/dist/gmail/methods/list_messages/handler.js.map +1 -1
  158. package/dist/gmail/methods/send_message/handler.js +1 -1
  159. package/dist/gmail/methods/send_message/handler.js.map +1 -1
  160. package/dist/gmail/methods/update_label/handler.js +1 -1
  161. package/dist/gmail/methods/update_label/handler.js.map +1 -1
  162. package/dist/gmail/tools/create_draft/handler.js +1 -1
  163. package/dist/gmail/tools/create_draft/handler.js.map +1 -1
  164. package/dist/gmail/tools/create_label/handler.js +1 -1
  165. package/dist/gmail/tools/create_label/handler.js.map +1 -1
  166. package/dist/gmail/tools/list_drafts/handler.js +1 -1
  167. package/dist/gmail/tools/list_drafts/handler.js.map +1 -1
  168. package/dist/gmail/tools/search_threads/handler.js +1 -1
  169. package/dist/gmail/tools/search_threads/handler.js.map +1 -1
  170. package/dist/lib/capabilities.d.ts +20 -1
  171. package/dist/lib/capabilities.d.ts.map +1 -1
  172. package/dist/lib/capabilities.js +33 -1
  173. package/dist/lib/capabilities.js.map +1 -1
  174. package/dist/lib/instructions.d.ts +35 -0
  175. package/dist/lib/instructions.d.ts.map +1 -0
  176. package/dist/lib/instructions.js +58 -0
  177. package/dist/lib/instructions.js.map +1 -0
  178. package/dist/lib/limits.d.ts +17 -3
  179. package/dist/lib/limits.d.ts.map +1 -1
  180. package/dist/lib/limits.js +21 -3
  181. package/dist/lib/limits.js.map +1 -1
  182. package/dist/lib/optionality.d.ts +34 -0
  183. package/dist/lib/optionality.d.ts.map +1 -0
  184. package/dist/lib/optionality.js +26 -0
  185. package/dist/lib/optionality.js.map +1 -0
  186. package/dist/lib/server.d.ts +0 -53
  187. package/dist/lib/server.d.ts.map +1 -1
  188. package/dist/lib/server.js +7 -86
  189. package/dist/lib/server.js.map +1 -1
  190. package/dist/lib/utils/error.d.ts +8 -0
  191. package/dist/lib/utils/error.d.ts.map +1 -0
  192. package/dist/lib/utils/error.js +10 -0
  193. package/dist/lib/utils/error.js.map +1 -0
  194. package/dist/lib/utils/json.d.ts +8 -0
  195. package/dist/lib/utils/json.d.ts.map +1 -0
  196. package/dist/lib/utils/json.js +10 -0
  197. package/dist/lib/utils/json.js.map +1 -0
  198. package/dist/lib/utils/lookup.d.ts +10 -0
  199. package/dist/lib/utils/lookup.d.ts.map +1 -0
  200. package/dist/lib/utils/lookup.js +12 -0
  201. package/dist/lib/utils/lookup.js.map +1 -0
  202. package/dist/lib/{enums.d.ts → utils/narrow.d.ts} +1 -1
  203. package/dist/lib/utils/narrow.d.ts.map +1 -0
  204. package/dist/lib/{enums.js → utils/narrow.js} +1 -1
  205. package/dist/lib/utils/narrow.js.map +1 -0
  206. package/dist/sheets/instructions.js +1 -1
  207. package/dist/sheets/instructions.js.map +1 -1
  208. package/dist/sheets/lib/filters.js +2 -2
  209. package/dist/sheets/lib/filters.js.map +1 -1
  210. package/dist/sheets/lib/metadata.js +1 -1
  211. package/dist/sheets/lib/metadata.js.map +1 -1
  212. package/dist/sheets/lib/spreadsheet.js +1 -1
  213. package/dist/sheets/lib/spreadsheet.js.map +1 -1
  214. package/dist/sheets/lib/values.js +1 -1
  215. package/dist/sheets/lib/values.js.map +1 -1
  216. package/dist/sheets/methods/append_values/handler.js +1 -1
  217. package/dist/sheets/methods/append_values/handler.js.map +1 -1
  218. package/dist/sheets/methods/batch_get_values/handler.js +1 -1
  219. package/dist/sheets/methods/batch_get_values/handler.js.map +1 -1
  220. package/dist/sheets/methods/batch_get_values_by_data_filter/handler.js +1 -1
  221. package/dist/sheets/methods/batch_get_values_by_data_filter/handler.js.map +1 -1
  222. package/dist/sheets/methods/batch_update_values/handler.js +1 -1
  223. package/dist/sheets/methods/batch_update_values/handler.js.map +1 -1
  224. package/dist/sheets/methods/batch_update_values_by_data_filter/handler.js +1 -1
  225. package/dist/sheets/methods/batch_update_values_by_data_filter/handler.js.map +1 -1
  226. package/dist/sheets/methods/create_spreadsheet/handler.js +1 -1
  227. package/dist/sheets/methods/create_spreadsheet/handler.js.map +1 -1
  228. package/dist/sheets/methods/get_values/handler.js +1 -1
  229. package/dist/sheets/methods/get_values/handler.js.map +1 -1
  230. package/dist/sheets/methods/update_values/handler.js +1 -1
  231. package/dist/sheets/methods/update_values/handler.js.map +1 -1
  232. package/package.json +17 -14
  233. package/dist/lib/enums.d.ts.map +0 -1
  234. package/dist/lib/enums.js.map +0 -1
  235. package/dist/lib/google.d.ts +0 -27
  236. package/dist/lib/google.d.ts.map +0 -1
  237. package/dist/lib/google.js +0 -4
  238. package/dist/lib/google.js.map +0 -1
  239. package/dist/lib/types.d.ts +0 -13
  240. package/dist/lib/types.d.ts.map +0 -1
  241. package/dist/lib/types.js +0 -2
  242. package/dist/lib/types.js.map +0 -1
package/ADOPTING.md CHANGED
@@ -335,7 +335,9 @@ Start a fresh session of the client, then:
335
335
  and Drive `get_about`. Where an operation returns identity, check it
336
336
  against the label's intended account: Drive `get_about` returns the
337
337
  account's `emailAddress`, and the Calendar list contains the primary
338
- calendar, whose id is the account's email. A consent mis-click in step 3
338
+ calendar, whose id is the account's email. `google-mcp-doctor` prints the
339
+ same mapping from outside the client: its Services table shows each label
340
+ beside the email its probes resolved. A consent mis-click in step 3
339
341
  surfaces here as the wrong email; fix it with
340
342
  `google-mcp-doctor auth <label>` and a more careful click.
341
343
  3. The superseded surfaces are gone. Claude Code: in a fresh session, no
package/PROVISIONING.md CHANGED
@@ -238,22 +238,24 @@ Default layout (all overridable by env, read lazily):
238
238
 
239
239
  ## Phase 6: register the MCP server
240
240
 
241
- One server instance per account, each pinned via `GOOGLE_MCP_ACCOUNT`. Example
242
- entries for an MCP host config (e.g. `~/.claude.json` `mcpServers`):
241
+ One server instance per account, each pinned via `GOOGLE_MCP_ACCOUNT`. The
242
+ value must be a label Phase 5 actually created: a bare email, or a roster
243
+ alias like `work` ([ADOPTING.md](./ADOPTING.md) step 3 writes the roster).
244
+ Example entries for an MCP host config (e.g. `~/.claude.json` `mcpServers`):
243
245
 
244
246
  ```jsonc
245
247
  {
246
- "gmail-simiancraft": {
248
+ "gmail-work": {
247
249
  "type": "stdio",
248
250
  "command": "google-mcp-gmail",
249
- "env": { "GOOGLE_MCP_ACCOUNT": "simiancraft" }
251
+ "env": { "GOOGLE_MCP_ACCOUNT": "work" }
250
252
  },
251
253
  // or, from a source checkout:
252
254
  "gmail-from-source": {
253
255
  "type": "stdio",
254
256
  "command": "node",
255
257
  "args": ["<abs-path-to-repo>/dist/gmail/index.js"],
256
- "env": { "GOOGLE_MCP_ACCOUNT": "simiancraft" }
258
+ "env": { "GOOGLE_MCP_ACCOUNT": "work" }
257
259
  }
258
260
  }
259
261
  ```
package/README.md CHANGED
@@ -13,8 +13,8 @@
13
13
  </p>
14
14
 
15
15
  <p align="center">
16
- <strong>Google MCP servers you can read in an afternoon, one per service.</strong><br />
17
- The curated <a href="https://modelcontextprotocol.io/">MCP</a> toolset plus the broader REST surface, one server per service per account: <strong>117 self-describing operations</strong> across five Google services, so an agent can do (nearly) anything your accounts can, on several accounts at once, and never on the wrong one. Every operation cites its Google reference page and validates input and output; test coverage is pinned at 100%.
16
+ <strong>Google Workspace MCP servers you can read in an afternoon, one per service.</strong><br />
17
+ The curated <a href="https://modelcontextprotocol.io/">MCP</a> toolset plus the broader REST surface for Gmail, Google Calendar, Google Drive, Google Docs, and Google Sheets, one server per service per account: <strong>117 self-describing operations</strong> across five Google services, so an AI agent (Claude, Cursor, or any MCP client) can do (nearly) anything your accounts can, on several accounts at once, and never on the wrong one. Every operation cites its Google reference page and validates input and output; test coverage is pinned at 100%.
18
18
  </p>
19
19
 
20
20
  <p align="center">
@@ -78,9 +78,10 @@ One thing first: a Google Cloud OAuth client (roughly ten minutes of console cli
78
78
  ```sh
79
79
  npm install -g google-mcp-suite
80
80
 
81
- google-mcp-doctor scopes # the exact APIs + scopes to enable in Google Cloud
82
- google-mcp-doctor auth you@example.com # browser consent; writes the account token
83
- google-mcp-doctor # provisioned, authorized, reachable?
81
+ google-mcp-doctor scopes # the exact APIs + scopes to enable in Google Cloud
82
+ google-mcp-doctor auth personal@example.com # browser consent; writes the account token
83
+ google-mcp-doctor auth work@example.com # once per account
84
+ google-mcp-doctor # provisioned, authorized, reachable?
84
85
  ```
85
86
 
86
87
  Then point your MCP client at the servers, one instance per service per account:
@@ -120,6 +121,10 @@ Then point your MCP client at the servers, one instance per service per account:
120
121
  }
121
122
  ```
122
123
 
124
+ The `GOOGLE_MCP_ACCOUNT` value must be the same string `doctor auth` was given;
125
+ a bare email is its own account label. For short aliases (`personal`, `work`)
126
+ write the optional roster first, as [ADOPTING.md](./ADOPTING.md) step 3 does.
127
+
123
128
  Then ask your agent for something no single-account tool can do:
124
129
 
125
130
  > Find a free 30-minute window next week that works across my work and personal calendars, book it on the work calendar with a Meet link, email the invite summary to my personal address, and log the booking in my scheduling spreadsheet.
@@ -1 +1 @@
1
- {"version":3,"file":"oauth.d.ts","sourceRoot":"","sources":["../../src/auth/oauth.ts"],"names":[],"mappings":"AAGA,OAAO,EAAyC,YAAY,EAAE,MAAM,qBAAqB,CAAC;AA+B1F;;;;GAIG;AACH,wBAAsB,gBAAgB,CAAC,OAAO,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,YAAY,CAAC,CAQ9E;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAsB,WAAW,CAC/B,OAAO,CAAC,EAAE,MAAM,EAChB,OAAO,GAAE;IACP,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,WAAW,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,OAAO,CAAC;IACvC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;CACf,GACL,OAAO,CAAC,IAAI,CAAC,CAmGf"}
1
+ {"version":3,"file":"oauth.d.ts","sourceRoot":"","sources":["../../src/auth/oauth.ts"],"names":[],"mappings":"AAGA,OAAO,EAAuB,YAAY,EAAE,MAAM,qBAAqB,CAAC;AA6DxE;;;;GAIG;AACH,wBAAsB,gBAAgB,CAAC,OAAO,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,YAAY,CAAC,CAQ9E;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAsB,WAAW,CAC/B,OAAO,CAAC,EAAE,MAAM,EAChB,OAAO,GAAE;IACP,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,WAAW,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,OAAO,CAAC;IACvC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;CACf,GACL,OAAO,CAAC,IAAI,CAAC,CAmGf"}
@@ -1,22 +1,51 @@
1
1
  import { randomBytes } from 'node:crypto';
2
- import { chmodSync, mkdirSync, readFileSync, rmSync, writeFileSync } from 'node:fs';
2
+ import { chmodSync, mkdirSync, rmSync, writeFileSync } from 'node:fs';
3
3
  import { createServer } from 'node:http';
4
4
  import { CodeChallengeMethod, OAuth2Client } from 'google-auth-library';
5
5
  import open from 'open';
6
+ import { z } from 'zod';
7
+ import { forGoogle } from '../lib/optionality.js';
8
+ import { readJsonFile } from '../lib/utils/json.js';
6
9
  import { loadConfig, resolveAccount, SCOPES, tokenPath } from './config.js';
7
10
  // The loopback IP literal, not `localhost` (RFC 8252 section 8.3, and Google's
8
11
  // loopback guidance): name resolution is host-file-manipulable and can point
9
12
  // `localhost` at ::1 where nothing listens.
10
13
  const redirectUri = (port) => `http://127.0.0.1:${port}/oauth2callback`;
14
+ const ClientKeys = z.object({
15
+ client_id: z.string().optional(),
16
+ client_secret: z.string().optional(),
17
+ });
18
+ /** The two shapes Google's console downloads use; everything else is rejected below. */
19
+ const ClientSecretFile = z.object({
20
+ installed: ClientKeys.optional(),
21
+ web: ClientKeys.optional(),
22
+ });
11
23
  function loadClientSecret() {
12
24
  const secretPath = loadConfig().clientSecretPath;
13
- const raw = JSON.parse(readFileSync(secretPath, 'utf8'));
25
+ let raw;
26
+ try {
27
+ raw = readJsonFile(secretPath, ClientSecretFile);
28
+ }
29
+ catch (err) {
30
+ if (err instanceof z.ZodError) {
31
+ throw new Error(`Invalid OAuth client secret at ${secretPath} (expected "installed" or "web").`);
32
+ }
33
+ throw err;
34
+ }
14
35
  const keys = raw.installed ?? raw.web;
15
36
  if (!keys?.client_id || !keys.client_secret) {
16
37
  throw new Error(`Invalid OAuth client secret at ${secretPath} (expected "installed" or "web").`);
17
38
  }
18
39
  return { client_id: keys.client_id, client_secret: keys.client_secret };
19
40
  }
41
+ /**
42
+ * The token fields the library refreshes from; everything else Google stores
43
+ * in the file rides along untyped (the file is this suite's own write).
44
+ */
45
+ const StoredToken = z.looseObject({
46
+ access_token: z.string().optional(),
47
+ refresh_token: z.string().optional(),
48
+ });
20
49
  function newClient(port = 3000) {
21
50
  const { client_id, client_secret } = loadClientSecret();
22
51
  return new OAuth2Client(client_id, client_secret, redirectUri(port));
@@ -29,8 +58,10 @@ function newClient(port = 3000) {
29
58
  export async function authorizedClient(account) {
30
59
  const client = newClient();
31
60
  const config = loadConfig();
32
- const token = JSON.parse(readFileSync(tokenPath(resolveAccount(account, config), config), 'utf8'));
33
- client.setCredentials(token);
61
+ const token = readJsonFile(tokenPath(resolveAccount(account, config), config), StoredToken);
62
+ // forGoogle drops undefined-valued keys, reconciling zod's `?: T | undefined`
63
+ // with the library's exactOptionalPropertyTypes-strict Credentials.
64
+ client.setCredentials(forGoogle(token));
34
65
  return client;
35
66
  }
36
67
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"oauth.js","sourceRoot":"","sources":["../../src/auth/oauth.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AACpF,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AACzC,OAAO,EAAE,mBAAmB,EAAoB,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAC1F,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAE5E,+EAA+E;AAC/E,6EAA6E;AAC7E,4CAA4C;AAC5C,MAAM,WAAW,GAAG,CAAC,IAAY,EAAE,EAAE,CAAC,oBAAoB,IAAI,iBAAiB,CAAC;AAIhF,SAAS,gBAAgB;IACvB,MAAM,UAAU,GAAG,UAAU,EAAE,CAAC,gBAAgB,CAAC;IACjD,MAAM,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,UAAU,EAAE,MAAM,CAAC,CAGtD,CAAC;IACF,MAAM,IAAI,GAAG,GAAG,CAAC,SAAS,IAAI,GAAG,CAAC,GAAG,CAAC;IACtC,IAAI,CAAC,IAAI,EAAE,SAAS,IAAI,CAAC,IAAI,CAAC,aAAa,EAAE,CAAC;QAC5C,MAAM,IAAI,KAAK,CACb,kCAAkC,UAAU,mCAAmC,CAChF,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Sync, mkdirSync, readFileSync, rmSync, writeFileSync } from 'node:fs';\nimport { createServer } from 'node:http';\nimport { CodeChallengeMethod, type Credentials, OAuth2Client } from 'google-auth-library';\nimport open from 'open';\nimport { loadConfig, resolveAccount, SCOPES, tokenPath } from './config.js';\n\n// The loopback IP literal, not `localhost` (RFC 8252 section 8.3, and Google's\n// loopback guidance): name resolution is host-file-manipulable and can point\n// `localhost` at ::1 where nothing listens.\nconst redirectUri = (port: number) => `http://127.0.0.1:${port}/oauth2callback`;\n\ntype ClientSecret = { client_id: string; client_secret: string };\n\nfunction loadClientSecret(): ClientSecret {\n const secretPath = loadConfig().clientSecretPath;\n const raw = JSON.parse(readFileSync(secretPath, 'utf8')) as {\n installed?: ClientSecret;\n web?: ClientSecret;\n };\n const keys = raw.installed ?? raw.web;\n if (!keys?.client_id || !keys.client_secret) {\n throw new Error(\n `Invalid OAuth client secret at ${secretPath} (expected \"installed\" or \"web\").`,\n );\n }\n return { client_id: keys.client_id, client_secret: keys.client_secret };\n}\n\nfunction newClient(port = 3000): OAuth2Client {\n const { client_id, client_secret } = loadClientSecret();\n return new OAuth2Client(client_id, client_secret, redirectUri(port));\n}\n\n/**\n * Build an authenticated client for `account` (default: GOOGLE_MCP_ACCOUNT) from\n * its stored token. The library auto-refreshes the access token from the refresh\n * token as needed.\n */\nexport async function authorizedClient(account?: string): Promise<OAuth2Client> {\n const client = newClient();\n const config = loadConfig();\n const token: Credentials = JSON.parse(\n readFileSync(tokenPath(resolveAccount(account, config), config), 'utf8'),\n );\n client.setCredentials(token);\n return client;\n}\n\n/**\n * Run the browser consent flow for `account` and persist its token. The token\n * file is written 0600 inside a 0700 tokens dir; the consent requests offline\n * access and forces the screen so a refresh token is always returned. The flow\n * carries a random `state` (verified at the callback: any browser tab can fire\n * requests at the loopback port, since CORS blocks reads, not sends, so only\n * the redirect Google issued for this flow is accepted) and PKCE (RFC 8252\n * section 8.1: a local process that wins a race for the port cannot exchange\n * an intercepted code without the verifier). `port`, `openBrowser`, and\n * `timeoutMs` are injectable for testing; the callback server is closed on\n * every exit path, including an abandoned consent. `loginHint` prefills the\n * Google account chooser when the account label is not itself an email\n * (e.g. a short alias like `personal`).\n */\nexport async function runAuthFlow(\n account?: string,\n options: {\n port?: number;\n openBrowser?: (url: string) => unknown;\n loginHint?: string;\n timeoutMs?: number;\n } = {},\n): Promise<void> {\n const port = options.port ?? 3000;\n const openBrowser = options.openBrowser ?? open;\n const timeoutMs = options.timeoutMs ?? 5 * 60 * 1000;\n const config = loadConfig();\n const acct = resolveAccount(account, config);\n const client = newClient(port);\n const loginHint = options.loginHint ?? (acct.includes('@') ? acct : undefined);\n const { codeVerifier, codeChallenge } = await client.generateCodeVerifierAsync();\n if (!codeChallenge) {\n throw new Error('PKCE challenge generation failed; cannot start the consent flow.');\n }\n const state = randomBytes(16).toString('hex');\n const authUrl = client.generateAuthUrl({\n access_type: 'offline',\n prompt: 'consent',\n scope: SCOPES,\n state,\n code_challenge_method: CodeChallengeMethod.S256,\n code_challenge: codeChallenge,\n ...(loginHint ? { login_hint: loginHint } : {}),\n });\n\n await new Promise<void>((resolve, reject) => {\n const server = createServer(async (req, res) => {\n // Absolute-form request targets reach req.url verbatim, and an\n // unparseable one (proxy-style \"GET http:// HTTP/1.1\") would throw in\n // the URL constructor; answer 400 rather than crash the flow on an\n // unhandled rejection.\n let requested: URL;\n try {\n requested = new URL(req.url ?? '/', redirectUri(port));\n } catch {\n res.writeHead(400);\n res.end();\n return;\n }\n if (requested.pathname !== '/oauth2callback') {\n // Browsers probe for favicons; answer rather than leave sockets hanging.\n res.writeHead(404);\n res.end();\n return;\n }\n const finish = (status: number, body: string, err?: unknown) => {\n res.writeHead(status);\n res.end(body);\n clearTimeout(timer);\n server.close();\n if (err) {\n reject(err);\n } else {\n resolve();\n }\n };\n const params = requested.searchParams;\n if (params.get('state') !== state) {\n finish(403, 'State mismatch.', new Error('OAuth state mismatch; possible CSRF.'));\n return;\n }\n const code = params.get('code');\n if (!code) {\n finish(\n 400,\n 'No authorization code provided.',\n new Error('No authorization code provided.'),\n );\n return;\n }\n try {\n const { tokens } = await client.getToken({ code, codeVerifier });\n mkdirSync(config.tokensDir, { recursive: true, mode: 0o700 });\n // mkdir's mode applies only on create; tighten a pre-existing dir so\n // token filenames (account labels) stay unreadable to other users.\n chmodSync(config.tokensDir, 0o700);\n const file = tokenPath(acct, config);\n // Recreate rather than overwrite: writeFileSync applies mode only on\n // create, and tightening afterwards would leave fresh token bytes\n // briefly readable through a pre-existing looser mode.\n rmSync(file, { force: true });\n writeFileSync(file, JSON.stringify(tokens), { mode: 0o600 });\n finish(200, `Authorized ${acct}. You can close this window.`);\n } catch (error) {\n finish(500, 'Authentication failed.', error);\n }\n });\n const timer = setTimeout(() => {\n server.close();\n reject(new Error(`Authorization timed out after ${timeoutMs}ms; rerun doctor auth.`));\n }, timeoutMs);\n server.on('error', (err) => {\n clearTimeout(timer);\n reject(err);\n });\n // Loopback only (RFC 8252 section 8.3): with no host, Node binds every\n // interface and the consent port is briefly LAN-reachable.\n server.listen(port, '127.0.0.1');\n console.error(`Visit this URL to authorize ${acct}:\\n${authUrl}`);\n void openBrowser(authUrl);\n });\n}\n"]}
1
+ {"version":3,"file":"oauth.js","sourceRoot":"","sources":["../../src/auth/oauth.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AACtE,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AACzC,OAAO,EAAE,mBAAmB,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACxE,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAClD,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CA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CAAC,+BAA+B,IAAI,MAAM,OAAO,EAAE,CAAC,CAAC;QAClE,KAAK,WAAW,CAAC,OAAO,CAAC,CAAC;IAC5B,CAAC,CAAC,CAAC;AACL,CAAC","sourcesContent":["import { randomBytes } from 'node:crypto';\nimport { chmodSync, mkdirSync, rmSync, writeFileSync } from 'node:fs';\nimport { createServer } from 'node:http';\nimport { CodeChallengeMethod, OAuth2Client } from 'google-auth-library';\nimport open from 'open';\nimport { z } from 'zod';\nimport { forGoogle } from '../lib/optionality.js';\nimport { readJsonFile } from '../lib/utils/json.js';\nimport { loadConfig, resolveAccount, SCOPES, tokenPath } from './config.js';\n\n// The loopback IP literal, not `localhost` (RFC 8252 section 8.3, and Google's\n// loopback guidance): name resolution is host-file-manipulable and can point\n// `localhost` at ::1 where nothing listens.\nconst redirectUri = (port: number) => `http://127.0.0.1:${port}/oauth2callback`;\n\nconst ClientKeys = z.object({\n client_id: z.string().optional(),\n client_secret: z.string().optional(),\n});\n\n/** The two shapes Google's console downloads use; everything else is rejected below. */\nconst ClientSecretFile = z.object({\n installed: ClientKeys.optional(),\n web: ClientKeys.optional(),\n});\n\ntype ClientSecret = { client_id: string; client_secret: string };\n\nfunction loadClientSecret(): ClientSecret {\n const secretPath = loadConfig().clientSecretPath;\n let raw: z.infer<typeof ClientSecretFile>;\n try {\n raw = readJsonFile(secretPath, ClientSecretFile);\n } catch (err) {\n if (err instanceof z.ZodError) {\n throw new Error(\n `Invalid OAuth client secret at ${secretPath} (expected \"installed\" or \"web\").`,\n );\n }\n throw err;\n }\n const keys = raw.installed ?? raw.web;\n if (!keys?.client_id || !keys.client_secret) {\n throw new Error(\n `Invalid OAuth client secret at ${secretPath} (expected \"installed\" or \"web\").`,\n );\n }\n return { client_id: keys.client_id, client_secret: keys.client_secret };\n}\n\n/**\n * The token fields the library refreshes from; everything else Google stores\n * in the file rides along untyped (the file is this suite's own write).\n */\nconst StoredToken = z.looseObject({\n access_token: z.string().optional(),\n refresh_token: z.string().optional(),\n});\n\nfunction newClient(port = 3000): OAuth2Client {\n const { client_id, client_secret } = loadClientSecret();\n return new OAuth2Client(client_id, client_secret, redirectUri(port));\n}\n\n/**\n * Build an authenticated client for `account` (default: GOOGLE_MCP_ACCOUNT) from\n * its stored token. The library auto-refreshes the access token from the refresh\n * token as needed.\n */\nexport async function authorizedClient(account?: string): Promise<OAuth2Client> {\n const client = newClient();\n const config = loadConfig();\n const token = readJsonFile(tokenPath(resolveAccount(account, config), config), StoredToken);\n // forGoogle drops undefined-valued keys, reconciling zod's `?: T | undefined`\n // with the library's exactOptionalPropertyTypes-strict Credentials.\n client.setCredentials(forGoogle(token));\n return client;\n}\n\n/**\n * Run the browser consent flow for `account` and persist its token. The token\n * file is written 0600 inside a 0700 tokens dir; the consent requests offline\n * access and forces the screen so a refresh token is always returned. The flow\n * carries a random `state` (verified at the callback: any browser tab can fire\n * requests at the loopback port, since CORS blocks reads, not sends, so only\n * the redirect Google issued for this flow is accepted) and PKCE (RFC 8252\n * section 8.1: a local process that wins a race for the port cannot exchange\n * an intercepted code without the verifier). `port`, `openBrowser`, and\n * `timeoutMs` are injectable for testing; the callback server is closed on\n * every exit path, including an abandoned consent. `loginHint` prefills the\n * Google account chooser when the account label is not itself an email\n * (e.g. a short alias like `personal`).\n */\nexport async function runAuthFlow(\n account?: string,\n options: {\n port?: number;\n openBrowser?: (url: string) => unknown;\n loginHint?: string;\n timeoutMs?: number;\n } = {},\n): Promise<void> {\n const port = options.port ?? 3000;\n const openBrowser = options.openBrowser ?? open;\n const timeoutMs = options.timeoutMs ?? 5 * 60 * 1000;\n const config = loadConfig();\n const acct = resolveAccount(account, config);\n const client = newClient(port);\n const loginHint = options.loginHint ?? (acct.includes('@') ? acct : undefined);\n const { codeVerifier, codeChallenge } = await client.generateCodeVerifierAsync();\n if (!codeChallenge) {\n throw new Error('PKCE challenge generation failed; cannot start the consent flow.');\n }\n const state = randomBytes(16).toString('hex');\n const authUrl = client.generateAuthUrl({\n access_type: 'offline',\n prompt: 'consent',\n scope: SCOPES,\n state,\n code_challenge_method: CodeChallengeMethod.S256,\n code_challenge: codeChallenge,\n ...(loginHint ? { login_hint: loginHint } : {}),\n });\n\n await new Promise<void>((resolve, reject) => {\n const server = createServer(async (req, res) => {\n // Absolute-form request targets reach req.url verbatim, and an\n // unparseable one (proxy-style \"GET http:// HTTP/1.1\") would throw in\n // the URL constructor; answer 400 rather than crash the flow on an\n // unhandled rejection.\n let requested: URL;\n try {\n requested = new URL(req.url ?? '/', redirectUri(port));\n } catch {\n res.writeHead(400);\n res.end();\n return;\n }\n if (requested.pathname !== '/oauth2callback') {\n // Browsers probe for favicons; answer rather than leave sockets hanging.\n res.writeHead(404);\n res.end();\n return;\n }\n const finish = (status: number, body: string, err?: unknown) => {\n res.writeHead(status);\n res.end(body);\n clearTimeout(timer);\n server.close();\n if (err) {\n reject(err);\n } else {\n resolve();\n }\n };\n const params = requested.searchParams;\n if (params.get('state') !== state) {\n finish(403, 'State mismatch.', new Error('OAuth state mismatch; possible CSRF.'));\n return;\n }\n const code = params.get('code');\n if (!code) {\n finish(\n 400,\n 'No authorization code provided.',\n new Error('No authorization code provided.'),\n );\n return;\n }\n try {\n const { tokens } = await client.getToken({ code, codeVerifier });\n mkdirSync(config.tokensDir, { recursive: true, mode: 0o700 });\n // mkdir's mode applies only on create; tighten a pre-existing dir so\n // token filenames (account labels) stay unreadable to other users.\n chmodSync(config.tokensDir, 0o700);\n const file = tokenPath(acct, config);\n // Recreate rather than overwrite: writeFileSync applies mode only on\n // create, and tightening afterwards would leave fresh token bytes\n // briefly readable through a pre-existing looser mode.\n rmSync(file, { force: true });\n writeFileSync(file, JSON.stringify(tokens), { mode: 0o600 });\n finish(200, `Authorized ${acct}. You can close this window.`);\n } catch (error) {\n finish(500, 'Authentication failed.', error);\n }\n });\n const timer = setTimeout(() => {\n server.close();\n reject(new Error(`Authorization timed out after ${timeoutMs}ms; rerun doctor auth.`));\n }, timeoutMs);\n server.on('error', (err) => {\n clearTimeout(timer);\n reject(err);\n });\n // Loopback only (RFC 8252 section 8.3): with no host, Node binds every\n // interface and the consent port is briefly LAN-reachable.\n server.listen(port, '127.0.0.1');\n console.error(`Visit this URL to authorize ${acct}:\\n${authUrl}`);\n void openBrowser(authUrl);\n });\n}\n"]}
@@ -3,7 +3,7 @@
3
3
  * src/lib/server.ts. A standalone module so tests can pin the content without
4
4
  * booting the server (index.ts's import side effect is `await server()`).
5
5
  */
6
- import { identityInstructions, untrustedContentInstructions, vocabularyInstructions, } from '../lib/server.js';
6
+ import { identityInstructions, untrustedContentInstructions, vocabularyInstructions, } from '../lib/instructions.js';
7
7
  export const instructions = identityInstructions('Google account') +
8
8
  vocabularyInstructions({
9
9
  tools: 'startTime, pageSize, notificationLevel',
@@ -1 +1 @@
1
- {"version":3,"file":"instructions.js","sourceRoot":"","sources":["../../src/calendar/instructions.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,EACL,oBAAoB,EACpB,4BAA4B,EAC5B,sBAAsB,GACvB,MAAM,kBAAkB,CAAC;AAE1B,MAAM,CAAC,MAAM,YAAY,GACvB,oBAAoB,CAAC,gBAAgB,CAAC;IACtC,sBAAsB,CAAC;QACrB,KAAK,EAAE,wCAAwC;QAC/C,OAAO,EAAE,kCAAkC;KAC5C,CAAC;IACF,4BAA4B,EAAE;IAC9B,qEAAqE;IACrE,wEAAwE;IACxE,2EAA2E;IAC3E,sEAAsE;IACtE,mEAAmE;IACnE,0BAA0B,CAAC","sourcesContent":["/**\n * Served in the MCP initialize result; see `ServerOptions.instructions` in\n * src/lib/server.ts. A standalone module so tests can pin the content without\n * booting the server (index.ts's import side effect is `await server()`).\n */\nimport {\n identityInstructions,\n untrustedContentInstructions,\n vocabularyInstructions,\n} from '../lib/server.js';\n\nexport const instructions =\n identityInstructions('Google account') +\n vocabularyInstructions({\n tools: 'startTime, pageSize, notificationLevel',\n methods: 'timeMin, maxResults, sendUpdates',\n }) +\n untrustedContentInstructions() +\n 'Event start and end take exactly one of date (all-day) or dateTime ' +\n '(timed); timeZone is required for recurring events. Writes that touch ' +\n 'attendees can email guests, controlled by notificationLevel on tools and ' +\n 'sendUpdates on methods. suggest_time refuses to answer, rather than ' +\n \"proposing slots that may conflict, when any requested calendar's \" +\n 'free/busy is unreadable.';\n"]}
1
+ {"version":3,"file":"instructions.js","sourceRoot":"","sources":["../../src/calendar/instructions.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,EACL,oBAAoB,EACpB,4BAA4B,EAC5B,sBAAsB,GACvB,MAAM,wBAAwB,CAAC;AAEhC,MAAM,CAAC,MAAM,YAAY,GACvB,oBAAoB,CAAC,gBAAgB,CAAC;IACtC,sBAAsB,CAAC;QACrB,KAAK,EAAE,wCAAwC;QAC/C,OAAO,EAAE,kCAAkC;KAC5C,CAAC;IACF,4BAA4B,EAAE;IAC9B,qEAAqE;IACrE,wEAAwE;IACxE,2EAA2E;IAC3E,sEAAsE;IACtE,mEAAmE;IACnE,0BAA0B,CAAC","sourcesContent":["/**\n * Served in the MCP initialize result; see `ServerOptions.instructions` in\n * src/lib/server.ts. A standalone module so tests can pin the content without\n * booting the server (index.ts's import side effect is `await server()`).\n */\nimport {\n identityInstructions,\n untrustedContentInstructions,\n vocabularyInstructions,\n} from '../lib/instructions.js';\n\nexport const instructions =\n identityInstructions('Google account') +\n vocabularyInstructions({\n tools: 'startTime, pageSize, notificationLevel',\n methods: 'timeMin, maxResults, sendUpdates',\n }) +\n untrustedContentInstructions() +\n 'Event start and end take exactly one of date (all-day) or dateTime ' +\n '(timed); timeZone is required for recurring events. Writes that touch ' +\n 'attendees can email guests, controlled by notificationLevel on tools and ' +\n 'sendUpdates on methods. suggest_time refuses to answer, rather than ' +\n \"proposing slots that may conflict, when any requested calendar's \" +\n 'free/busy is unreadable.';\n"]}
@@ -1,5 +1,5 @@
1
1
  import type { calendar_v3 } from '@googleapis/calendar';
2
- import type { Optional } from '../../lib/types.js';
2
+ import { type Optional } from '../../lib/optionality.js';
3
3
  /**
4
4
  * Apply attendee email deltas to a REST attendee array: drop the removed
5
5
  * addresses, then append the added ones as bare attendees. Addresses compare
@@ -1 +1 @@
1
- {"version":3,"file":"attendees.d.ts","sourceRoot":"","sources":["../../../src/calendar/lib/attendees.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AACxD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAEnD;;;;;GAKG;AACH,wBAAgB,mBAAmB,CACjC,SAAS,EAAE,WAAW,CAAC,oBAAoB,EAAE,EAC7C,MAAM,EAAE;IAAE,KAAK,CAAC,EAAE,QAAQ,CAAC,MAAM,EAAE,CAAC,CAAC;IAAC,OAAO,CAAC,EAAE,QAAQ,CAAC,MAAM,EAAE,CAAC,CAAA;CAAE,GACnE,WAAW,CAAC,oBAAoB,EAAE,CAapC;AAED;;;;;;GAMG;AACH,wBAAgB,aAAa,CAC3B,SAAS,EAAE,WAAW,CAAC,oBAAoB,EAAE,EAC7C,QAAQ,EAAE;IACR,cAAc,EAAE,UAAU,GAAG,WAAW,GAAG,UAAU,CAAC;IACtD,OAAO,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,CAAC;CAC5B,GACA,WAAW,CAAC,oBAAoB,EAAE,CAgBpC"}
1
+ {"version":3,"file":"attendees.d.ts","sourceRoot":"","sources":["../../../src/calendar/lib/attendees.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AACxD,OAAO,EAAa,KAAK,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AAEpE;;;;;GAKG;AACH,wBAAgB,mBAAmB,CACjC,SAAS,EAAE,WAAW,CAAC,oBAAoB,EAAE,EAC7C,MAAM,EAAE;IAAE,KAAK,CAAC,EAAE,QAAQ,CAAC,MAAM,EAAE,CAAC,CAAC;IAAC,OAAO,CAAC,EAAE,QAAQ,CAAC,MAAM,EAAE,CAAC,CAAA;CAAE,GACnE,WAAW,CAAC,oBAAoB,EAAE,CAapC;AAED;;;;;;GAMG;AACH,wBAAgB,aAAa,CAC3B,SAAS,EAAE,WAAW,CAAC,oBAAoB,EAAE,EAC7C,QAAQ,EAAE;IACR,cAAc,EAAE,UAAU,GAAG,WAAW,GAAG,UAAU,CAAC;IACtD,OAAO,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,CAAC;CAC5B,GACA,WAAW,CAAC,oBAAoB,EAAE,CAgBpC"}
@@ -1,3 +1,4 @@
1
+ import { forGoogle } from '../../lib/optionality.js';
1
2
  /**
2
3
  * Apply attendee email deltas to a REST attendee array: drop the removed
3
4
  * addresses, then append the added ones as bare attendees. Addresses compare
@@ -34,7 +35,7 @@ export function respondAsSelf(attendees, response) {
34
35
  ? {
35
36
  ...attendee,
36
37
  responseStatus: response.responseStatus,
37
- ...(response.comment === undefined ? {} : { comment: response.comment }),
38
+ ...forGoogle({ comment: response.comment }),
38
39
  }
39
40
  : attendee);
40
41
  }
@@ -1 +1 @@
1
- {"version":3,"file":"attendees.js","sourceRoot":"","sources":["../../../src/calendar/lib/attendees.ts"],"names":[],"mappings":"AAGA;;;;;GAKG;AACH,MAAM,UAAU,mBAAmB,CACjC,SAA6C,EAC7C,MAAoE;IAEpE,MAAM,OAAO,GAAG,IAAI,GAAG,CAAC,CAAC,MAAM,CAAC,OAAO,IAAI,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC;IACpF,MAAM,IAAI,GAAG,SAAS,CAAC,MAAM,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,QAAQ,CAAC,KAAK,IAAI,EAAE,CAAC,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC;IAChG,MAAM,OAAO,GAAG,IAAI,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAC,QAAQ,CAAC,KAAK,IAAI,EAAE,CAAC,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC;IACtF,MAAM,MAAM,GAAG,CAAC,GAAG,IAAI,CAAC,CAAC;IACzB,KAAK,MAAM,KAAK,IAAI,MAAM,CAAC,KAAK,IAAI,EAAE,EAAE,CAAC;QACvC,IAAI,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,WAAW,EAAE,CAAC,EAAE,CAAC;YACrC,SAAS;QACX,CAAC;QACD,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,WAAW,EAAE,CAAC,CAAC;QACjC,MAAM,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC;IACzB,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,aAAa,CAC3B,SAA6C,EAC7C,QAGC;IAED,MAAM,IAAI,GAAG,SAAS,CAAC,IAAI,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,QAAQ,CAAC,IAAI,KAAK,IAAI,CAAC,CAAC;IAClE,IAAI,IAAI,KAAK,SAAS,EAAE,CAAC;QACvB,MAAM,IAAI,KAAK,CACb,kHAAkH,CACnH,CAAC;IACJ,CAAC;IACD,OAAO,SAAS,CAAC,GAAG,CAAC,CAAC,QAAQ,EAAE,EAAE,CAChC,QAAQ,KAAK,IAAI;QACf,CAAC,CAAC;YACE,GAAG,QAAQ;YACX,cAAc,EAAE,QAAQ,CAAC,cAAc;YACvC,GAAG,CAAC,QAAQ,CAAC,OAAO,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,QAAQ,CAAC,OAAO,EAAE,CAAC;SACzE;QACH,CAAC,CAAC,QAAQ,CACb,CAAC;AACJ,CAAC","sourcesContent":["import type { calendar_v3 } from '@googleapis/calendar';\nimport type { Optional } from '../../lib/types.js';\n\n/**\n * Apply attendee email deltas to a REST attendee array: drop the removed\n * addresses, then append the added ones as bare attendees. Addresses compare\n * case-insensitively, and an added address that is already on the list is\n * skipped rather than duplicated.\n */\nexport function applyAttendeeDeltas(\n attendees: calendar_v3.Schema$EventAttendee[],\n deltas: { added?: Optional<string[]>; removed?: Optional<string[]> },\n): calendar_v3.Schema$EventAttendee[] {\n const removed = new Set((deltas.removed ?? []).map((email) => email.toLowerCase()));\n const kept = attendees.filter((attendee) => !removed.has((attendee.email ?? '').toLowerCase()));\n const present = new Set(kept.map((attendee) => (attendee.email ?? '').toLowerCase()));\n const result = [...kept];\n for (const email of deltas.added ?? []) {\n if (present.has(email.toLowerCase())) {\n continue;\n }\n present.add(email.toLowerCase());\n result.push({ email });\n }\n return result;\n}\n\n/**\n * Rewrite the self attendee's invitation response in a REST attendee array:\n * set its `responseStatus` and, when a comment is given, its `comment`,\n * leaving every other attendee untouched. Throws when no attendee carries\n * `self: true`: the authenticated user is not on the guest list, so there is\n * no response of theirs to rewrite.\n */\nexport function respondAsSelf(\n attendees: calendar_v3.Schema$EventAttendee[],\n response: {\n responseStatus: 'declined' | 'tentative' | 'accepted';\n comment?: Optional<string>;\n },\n): calendar_v3.Schema$EventAttendee[] {\n const self = attendees.find((attendee) => attendee.self === true);\n if (self === undefined) {\n throw new Error(\n 'The event has no self attendee; the authenticated user is not on the guest list, so there is no response to set.',\n );\n }\n return attendees.map((attendee) =>\n attendee === self\n ? {\n ...attendee,\n responseStatus: response.responseStatus,\n ...(response.comment === undefined ? {} : { comment: response.comment }),\n }\n : attendee,\n );\n}\n"]}
1
+ {"version":3,"file":"attendees.js","sourceRoot":"","sources":["../../../src/calendar/lib/attendees.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAiB,MAAM,0BAA0B,CAAC;AAEpE;;;;;GAKG;AACH,MAAM,UAAU,mBAAmB,CACjC,SAA6C,EAC7C,MAAoE;IAEpE,MAAM,OAAO,GAAG,IAAI,GAAG,CAAC,CAAC,MAAM,CAAC,OAAO,IAAI,EAA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AK,IAAI;QACf,CAAC,CAAC;YACE,GAAG,QAAQ;YACX,cAAc,EAAE,QAAQ,CAAC,cAAc;YACvC,GAAG,SAAS,CAAC,EAAE,OAAO,EAAE,QAAQ,CAAC,OAAO,EAAE,CAAC;SAC5C;QACH,CAAC,CAAC,QAAQ,CACb,CAAC;AACJ,CAAC","sourcesContent":["import type { calendar_v3 } from '@googleapis/calendar';\nimport { forGoogle, type Optional } from '../../lib/optionality.js';\n\n/**\n * Apply attendee email deltas to a REST attendee array: drop the removed\n * addresses, then append the added ones as bare attendees. Addresses compare\n * case-insensitively, and an added address that is already on the list is\n * skipped rather than duplicated.\n */\nexport function applyAttendeeDeltas(\n attendees: calendar_v3.Schema$EventAttendee[],\n deltas: { added?: Optional<string[]>; removed?: Optional<string[]> },\n): calendar_v3.Schema$EventAttendee[] {\n const removed = new Set((deltas.removed ?? []).map((email) => email.toLowerCase()));\n const kept = attendees.filter((attendee) => !removed.has((attendee.email ?? '').toLowerCase()));\n const present = new Set(kept.map((attendee) => (attendee.email ?? '').toLowerCase()));\n const result = [...kept];\n for (const email of deltas.added ?? []) {\n if (present.has(email.toLowerCase())) {\n continue;\n }\n present.add(email.toLowerCase());\n result.push({ email });\n }\n return result;\n}\n\n/**\n * Rewrite the self attendee's invitation response in a REST attendee array:\n * set its `responseStatus` and, when a comment is given, its `comment`,\n * leaving every other attendee untouched. Throws when no attendee carries\n * `self: true`: the authenticated user is not on the guest list, so there is\n * no response of theirs to rewrite.\n */\nexport function respondAsSelf(\n attendees: calendar_v3.Schema$EventAttendee[],\n response: {\n responseStatus: 'declined' | 'tentative' | 'accepted';\n comment?: Optional<string>;\n },\n): calendar_v3.Schema$EventAttendee[] {\n const self = attendees.find((attendee) => attendee.self === true);\n if (self === undefined) {\n throw new Error(\n 'The event has no self attendee; the authenticated user is not on the guest list, so there is no response to set.',\n );\n }\n return attendees.map((attendee) =>\n attendee === self\n ? {\n ...attendee,\n responseStatus: response.responseStatus,\n ...forGoogle({ comment: response.comment }),\n }\n : attendee,\n );\n}\n"]}
@@ -1,5 +1,5 @@
1
1
  import type { calendar_v3 } from '@googleapis/calendar';
2
- import type { Optional } from '../../lib/types.js';
2
+ import type { Optional } from '../../lib/optionality.js';
3
3
  import type { EventDateTime } from '../entities/EventDateTime.js';
4
4
  /**
5
5
  * Build the REST `EventDateTime` for a tool's time input. Timed events carry
@@ -1 +1 @@
1
- {"version":3,"file":"datetime.d.ts","sourceRoot":"","sources":["../../../src/calendar/lib/datetime.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAExD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;AAElE;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAAC,IAAI,EAAE;IACvC,oEAAoE;IACpE,QAAQ,EAAE,MAAM,CAAC;IACjB,oEAAoE;IACpE,QAAQ,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,CAAC;IAC5B,sEAAsE;IACtE,MAAM,CAAC,EAAE,QAAQ,CAAC,OAAO,CAAC,CAAC;CAC5B,GAAG,WAAW,CAAC,oBAAoB,CAKnC;AAED,0EAA0E;AAC1E,wBAAgB,oBAAoB,CAAC,QAAQ,EAAE,WAAW,CAAC,oBAAoB,GAAG,aAAa,CAM9F"}
1
+ {"version":3,"file":"datetime.d.ts","sourceRoot":"","sources":["../../../src/calendar/lib/datetime.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AACxD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AAEzD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;AAElE;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAAC,IAAI,EAAE;IACvC,oEAAoE;IACpE,QAAQ,EAAE,MAAM,CAAC;IACjB,oEAAoE;IACpE,QAAQ,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,CAAC;IAC5B,sEAAsE;IACtE,MAAM,CAAC,EAAE,QAAQ,CAAC,OAAO,CAAC,CAAC;CAC5B,GAAG,WAAW,CAAC,oBAAoB,CAKnC;AAED,0EAA0E;AAC1E,wBAAgB,oBAAoB,CAAC,QAAQ,EAAE,WAAW,CAAC,oBAAoB,GAAG,aAAa,CAM9F"}
@@ -1,4 +1,4 @@
1
- import { forGoogle } from '../../lib/google.js';
1
+ import { forGoogle } from '../../lib/optionality.js';
2
2
  /**
3
3
  * Build the REST `EventDateTime` for a tool's time input. Timed events carry
4
4
  * the ISO timestamp as `dateTime` (plus the optional IANA `timeZone`); all-day
@@ -1 +1 @@
1
- {"version":3,"file":"datetime.js","sourceRoot":"","sources":["../../../src/calendar/lib/datetime.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAIhD;;;;;GAKG;AACH,MAAM,UAAU,kBAAkB,CAAC,IAOlC;IACC,IAAI,IAAI,CAAC,MAAM,EAAE,CAAC;QAChB,OAAO,SAAS,CAAC,EAAE,IAAI,EAAE,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,EAAE,QAAQ,EAAE,IAAI,CAAC,QAAQ,EAAE,CAAC,CAAC;IAClF,CAAC;IACD,OAAO,SAAS,CAAC,EAAE,QAAQ,EAAE,IAAI,CAAC,QAAQ,EAAE,QAAQ,EAAE,IAAI,CAAC,QAAQ,EAAE,CAAC,CAAC;AACzE,CAAC;AAED,0EAA0E;AAC1E,MAAM,UAAU,oBAAoB,CAAC,QAA0C;IAC7E,OAAO;QACL,IAAI,EAAE,QAAQ,CAAC,IAAI,IAAI,SAAS;QAChC,QAAQ,EAAE,QAAQ,CAAC,QAAQ,IAAI,SAAS;QACxC,QAAQ,EAAE,QAAQ,CAAC,QAAQ,IAAI,SAAS;KACzC,CAAC;AACJ,CAAC","sourcesContent":["import type { calendar_v3 } from '@googleapis/calendar';\nimport { forGoogle } from '../../lib/google.js';\nimport type { Optional } from '../../lib/types.js';\nimport type { EventDateTime } from '../entities/EventDateTime.js';\n\n/**\n * Build the REST `EventDateTime` for a tool's time input. Timed events carry\n * the ISO timestamp as `dateTime` (plus the optional IANA `timeZone`); all-day\n * events carry only the calendar date, so the tool's midnight-UTC timestamp\n * collapses to its `yyyy-mm-dd` prefix.\n */\nexport function buildEventDateTime(args: {\n /** An ISO 8601 timestamp, for example 2026-06-10T09:00:00-05:00. */\n dateTime: string;\n /** An IANA Time Zone Database name, for example America/Chicago. */\n timeZone?: Optional<string>;\n /** When true, build the all-day `date` form instead of `dateTime`. */\n allDay?: Optional<boolean>;\n}): calendar_v3.Schema$EventDateTime {\n if (args.allDay) {\n return forGoogle({ date: args.dateTime.slice(0, 10), timeZone: args.timeZone });\n }\n return forGoogle({ dateTime: args.dateTime, timeZone: args.timeZone });\n}\n\n/** Project a REST EventDateTime onto the entity shape, dropping nulls. */\nexport function projectEventDateTime(dateTime: calendar_v3.Schema$EventDateTime): EventDateTime {\n return {\n date: dateTime.date ?? undefined,\n dateTime: dateTime.dateTime ?? undefined,\n timeZone: dateTime.timeZone ?? undefined,\n };\n}\n"]}
1
+ {"version":3,"file":"datetime.js","sourceRoot":"","sources":["../../../src/calendar/lib/datetime.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAC;AAGrD;;;;;GAKG;AACH,MAAM,UAAU,kBAAkB,CAAC,IAOlC;IACC,IAAI,IAAI,CAAC,MAAM,EAAE,CAAC;QAChB,OAAO,SAAS,CAAC,EAAE,IAAI,EAAE,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,EAAE,QAAQ,EAAE,IAAI,CAAC,QAAQ,EAAE,CAAC,CAAC;IAClF,CAAC;IACD,OAAO,SAAS,CAAC,EAAE,QAAQ,EAAE,IAAI,CAAC,QAAQ,EAAE,QAAQ,EAAE,IAAI,CAAC,QAAQ,EAAE,CAAC,CAAC;AACzE,CAAC;AAED,0EAA0E;AAC1E,MAAM,UAAU,oBAAoB,CAAC,QAA0C;IAC7E,OAAO;QACL,IAAI,EAAE,QAAQ,CAAC,IAAI,IAAI,SAAS;QAChC,QAAQ,EAAE,QAAQ,CAAC,QAAQ,IAAI,SAAS;QACxC,QAAQ,EAAE,QAAQ,CAAC,QAAQ,IAAI,SAAS;KACzC,CAAC;AACJ,CAAC","sourcesContent":["import type { calendar_v3 } from '@googleapis/calendar';\nimport type { Optional } from '../../lib/optionality.js';\nimport { forGoogle } from '../../lib/optionality.js';\nimport type { EventDateTime } from '../entities/EventDateTime.js';\n\n/**\n * Build the REST `EventDateTime` for a tool's time input. Timed events carry\n * the ISO timestamp as `dateTime` (plus the optional IANA `timeZone`); all-day\n * events carry only the calendar date, so the tool's midnight-UTC timestamp\n * collapses to its `yyyy-mm-dd` prefix.\n */\nexport function buildEventDateTime(args: {\n /** An ISO 8601 timestamp, for example 2026-06-10T09:00:00-05:00. */\n dateTime: string;\n /** An IANA Time Zone Database name, for example America/Chicago. */\n timeZone?: Optional<string>;\n /** When true, build the all-day `date` form instead of `dateTime`. */\n allDay?: Optional<boolean>;\n}): calendar_v3.Schema$EventDateTime {\n if (args.allDay) {\n return forGoogle({ date: args.dateTime.slice(0, 10), timeZone: args.timeZone });\n }\n return forGoogle({ dateTime: args.dateTime, timeZone: args.timeZone });\n}\n\n/** Project a REST EventDateTime onto the entity shape, dropping nulls. */\nexport function projectEventDateTime(dateTime: calendar_v3.Schema$EventDateTime): EventDateTime {\n return {\n date: dateTime.date ?? undefined,\n dateTime: dateTime.dateTime ?? undefined,\n timeZone: dateTime.timeZone ?? undefined,\n };\n}\n"]}
@@ -1,4 +1,4 @@
1
- import { narrow } from '../../lib/enums.js';
1
+ import { narrow } from '../../lib/utils/narrow.js';
2
2
  import { Reminder } from '../entities/Reminder.js';
3
3
  import { projectEventDateTime } from './datetime.js';
4
4
  /** Project a REST event principal (creator or organizer) onto the Principal shape. */
@@ -1 +1 @@
1
- {"version":3,"file":"event.js","sourceRoot":"","sources":["../../../src/calendar/lib/event.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAI5C,OAAO,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AACnD,OAAO,EAAE,oBAAoB,EAAE,MAAM,eAAe,CAAC;AAKrD,sFAAsF;AACtF,SAAS,gBAAgB,CAAC,SAAwB;IAChD,OAAO;QACL,KAAK,EAAE,SAAS,CAAC,KAAK;QACtB,WAAW,EAAE,SAAS,CAAC,WAAW;QAClC,IAAI,EAAE,SAAS,CAAC,IAAI;KACrB,CAAC;AACJ,CAAC;AAED,0FAA0F;AAC1F,SAAS,eAAe,CAAC,QAA0C;IACjE,OAAO;QACL,EAAE,EAAE,QAAQ,CAAC,EAAE,IAAI,SAAS;QAC5B,KAAK,EAAE,QAAQ,CAAC,KAAK,IAAI,EAAE;QAC3B,WAAW,EAAE,QAAQ,CAAC,WAAW,IAAI,SAAS;QAC9C,SAAS,EAAE,QAAQ,CAAC,SAAS,IAAI,SAAS;QAC1C,IAAI,EAAE,QAAQ,CAAC,IAAI,IAAI,SAAS;QAChC,QAAQ,EAAE,QAAQ,CAAC,QAAQ,IAAI,SAAS;QACxC,gBAAgB,EAAE,QAAQ,CAAC,QAAQ,IAAI,SAAS;QAChD,cAAc,EAAE,QAAQ,CAAC,cAAc,IAAI,SAAS;QACpD,OAAO,EAAE,QAAQ,CAAC,OAAO,IAAI,SAAS;QACtC,gBAAgB,EAAE,QAAQ,CAAC,gBAAgB,IAAI,SAAS;KACzD,CAAC;AACJ,CAAC;AAED,uHAAuH;AACvH,MAAM,UAAU,eAAe,CAAC,QAA0C;IACxE,OAAO;QACL,MAAM,EAAE,MAAM,CAAC,QAAQ,CAAC,MAAM,EAAE,QAAQ,CAAC,KAAK,CAAC,MAAM,CAA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AC,oBAAoB,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,SAAS;QAC1D,UAAU,EAAE,IAAI,CAAC,UAAU,IAAI,SAAS;QACxC,gBAAgB,EAAE,IAAI,CAAC,gBAAgB,IAAI,SAAS;QACpD,iBAAiB,EAAE,IAAI,CAAC,iBAAiB;YACvC,CAAC,CAAC,oBAAoB,CAAC,IAAI,CAAC,iBAAiB,CAAC;YAC9C,CAAC,CAAC,SAAS;QACb,YAAY,EAAE,IAAI,CAAC,YAAY,IAAI,SAAS;QAC5C,UAAU,EAAE,IAAI,CAAC,UAAU,IAAI,SAAS;QACxC,SAAS,EAAE,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC,SAAS;QAC3E,SAAS,EAAE,IAAI,CAAC,SAAS,IAAI,SAAS;QACtC,aAAa,EAAE,aAAa,CAAC,IAAI,CAAC;QAClC,OAAO,EAAE,IAAI,CAAC,OAAO,IAAI,SAAS;QAClC,iBAAiB,EAAE,IAAI,CAAC,SAAS,EAAE,SAAS;YAC1C,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,SAAS,CAAC,GAAG,CAAC,eAAe,CAAC;YAC/C,CAAC,CAAC,SAAS;KACd,CAAC;AACJ,CAAC","sourcesContent":["import type { calendar_v3 } from '@googleapis/calendar';\nimport { narrow } from '../../lib/enums.js';\nimport type { Attendee } from '../entities/Attendee.js';\nimport type { Event } from '../entities/Event.js';\nimport type { Principal } from '../entities/Principal.js';\nimport { Reminder } from '../entities/Reminder.js';\nimport { projectEventDateTime } from './datetime.js';\n\n/** The REST shape of an event's creator and organizer (structurally identical). */\ntype RestPrincipal = NonNullable<calendar_v3.Schema$Event['creator']>;\n\n/** Project a REST event principal (creator or organizer) onto the Principal shape. */\nfunction projectPrincipal(principal: RestPrincipal): Principal {\n return {\n email: principal.email,\n displayName: principal.displayName,\n self: principal.self,\n };\n}\n\n/** Project a REST attendee onto the Attendee shape (`optional` -> `optionalAttendee`). */\nfunction projectAttendee(attendee: calendar_v3.Schema$EventAttendee): Attendee {\n return {\n id: attendee.id ?? undefined,\n email: attendee.email ?? '',\n displayName: attendee.displayName ?? undefined,\n organizer: attendee.organizer ?? undefined,\n self: attendee.self ?? undefined,\n resource: attendee.resource ?? undefined,\n optionalAttendee: attendee.optional ?? undefined,\n responseStatus: attendee.responseStatus ?? undefined,\n comment: attendee.comment ?? undefined,\n additionalGuests: attendee.additionalGuests ?? undefined,\n };\n}\n\n/** Project a REST reminder onto the Reminder shape; unknown delivery methods drop rather than masquerade as popups. */\nexport function projectReminder(reminder: calendar_v3.Schema$EventReminder): Reminder {\n return {\n method: narrow(reminder.method, Reminder.shape.method.unwrap().options),\n minutes: reminder.minutes ?? 0,\n };\n}\n\n/**\n * The Google Meet link: the `conferenceData` video entry point's URI, falling\n * back to the legacy `hangoutLink` when the conference data carries none.\n */\nfunction conferenceUrl(event: calendar_v3.Schema$Event): Event['conferenceUrl'] {\n const video = event.conferenceData?.entryPoints?.find(\n (entryPoint) => entryPoint.entryPointType === 'video',\n );\n return video?.uri ?? event.hangoutLink ?? undefined;\n}\n\n/**\n * Project a raw REST event onto the documented Event shape: collapse\n * `conferenceData` to `conferenceUrl`, rename attendee `optional` to\n * `optionalAttendee`, surface `reminders.overrides` as `overrideReminders`,\n * and clean nulls to undefined.\n */\nexport function projectEvent(data: calendar_v3.Schema$Event): Event {\n return {\n id: data.id ?? '',\n status: data.status ?? undefined,\n htmlLink: data.htmlLink ?? undefined,\n created: data.created ?? undefined,\n updated: data.updated ?? undefined,\n summary: data.summary ?? undefined,\n description: data.description ?? undefined,\n location: data.location ?? undefined,\n creator: data.creator ? projectPrincipal(data.creator) : undefined,\n organizer: data.organizer ? projectPrincipal(data.organizer) : undefined,\n start: data.start ? projectEventDateTime(data.start) : undefined,\n end: data.end ? projectEventDateTime(data.end) : undefined,\n recurrence: data.recurrence ?? undefined,\n recurringEventId: data.recurringEventId ?? undefined,\n originalStartTime: data.originalStartTime\n ? projectEventDateTime(data.originalStartTime)\n : undefined,\n transparency: data.transparency ?? undefined,\n visibility: data.visibility ?? undefined,\n attendees: data.attendees ? data.attendees.map(projectAttendee) : undefined,\n eventType: data.eventType ?? undefined,\n conferenceUrl: conferenceUrl(data),\n colorId: data.colorId ?? undefined,\n overrideReminders: data.reminders?.overrides\n ? data.reminders.overrides.map(projectReminder)\n : undefined,\n };\n}\n"]}
1
+ {"version":3,"file":"event.js","sourceRoot":"","sources":["../../../src/calendar/lib/event.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,2BAA2B,CAAC;AAInD,OAAO,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AACnD,OAAO,EAAE,oBAAoB,EAAE,MAAM,eAAe,CAAC;AAKrD,sFAAsF;AACtF,SAAS,gBAAgB,CAAC,SAAwB;IAChD,OAAO;QACL,KAAK,EAAE,SAAS,CAAC,KAAK;QACtB,WAAW,EAAE,SAAS,CAAC,WAAW;QAClC,IAAI,EAAE,SAAS,CAAC,IAAI;KACrB,CAAC;AACJ,CAAC;AAED,0FAA0F;AAC1F,SAAS,eAAe,CAAC,QAA0C;IACjE,OAAO;QACL,EAAE,EAAE,QAAQ,CAAC,EAAE,IAAI,SAAS;QAC5B,KAAK,EAAE,QAAQ,CAAC,KAAK,IAAI,EAAE;QAC3B,WAAW,EAAE,QAAQ,CAAC,WAAW,IAAI,SAAS;QAC9C,SAAS,EAAE,QAAQ,CAAC,SAAS,IAAI,SAAS;QAC1C,IAAI,EAAE,QAAQ,CAAC,IAAI,IAAI,SAAS;QAChC,QAAQ,EAAE,QAAQ,CAAC,QAAQ,IAAI,SAAS;QACxC,gBAAgB,EAAE,QAAQ,CAAC,QAAQ,IAAI,SAAS;QAChD,cAAc,EAAE,QAAQ,CAAC,cAAc,IAAI,SAAS;QACpD,OAAO,EAAE,QAAQ,CAAC,OAAO,IAAI,SAAS;QACtC,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B,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,SAAS;QACxE,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,oBAAoB,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,SAAS;QAChE,GAAG,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,oBAAoB,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,SAAS;QAC1D,UAAU,EAAE,IAAI,CAAC,UAAU,IAAI,SAAS;QACxC,gBAAgB,EAAE,IAAI,CAAC,gBAAgB,IAAI,SAAS;QACpD,iBAAiB,EAAE,IAAI,CAAC,iBAAiB;YACvC,CAAC,CAAC,oBAAoB,CAAC,IAAI,CAAC,iBAAiB,CAAC;YAC9C,CAAC,CAAC,SAAS;QACb,YAAY,EAAE,IAAI,CAAC,YAAY,IAAI,SAAS;QAC5C,UAAU,EAAE,IAAI,CAAC,UAAU,IAAI,SAAS;QACxC,SAAS,EAAE,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC,SAAS;QAC3E,SAAS,EAAE,IAAI,CAAC,SAAS,IAAI,SAAS;QACtC,aAAa,EAAE,aAAa,CAAC,IAAI,CAAC;QAClC,OAAO,EAAE,IAAI,CAAC,OAAO,IAAI,SAAS;QAClC,iBAAiB,EAAE,IAAI,CAAC,SAAS,EAAE,SAAS;YAC1C,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,SAAS,CAAC,GAAG,CAAC,eAAe,CAAC;YAC/C,CAAC,CAAC,SAAS;KACd,CAAC;AACJ,CAAC","sourcesContent":["import type { calendar_v3 } from '@googleapis/calendar';\nimport { narrow } from '../../lib/utils/narrow.js';\nimport type { Attendee } from '../entities/Attendee.js';\nimport type { Event } from '../entities/Event.js';\nimport type { Principal } from '../entities/Principal.js';\nimport { Reminder } from '../entities/Reminder.js';\nimport { projectEventDateTime } from './datetime.js';\n\n/** The REST shape of an event's creator and organizer (structurally identical). */\ntype RestPrincipal = NonNullable<calendar_v3.Schema$Event['creator']>;\n\n/** Project a REST event principal (creator or organizer) onto the Principal shape. */\nfunction projectPrincipal(principal: RestPrincipal): Principal {\n return {\n email: principal.email,\n displayName: principal.displayName,\n self: principal.self,\n };\n}\n\n/** Project a REST attendee onto the Attendee shape (`optional` -> `optionalAttendee`). */\nfunction projectAttendee(attendee: calendar_v3.Schema$EventAttendee): Attendee {\n return {\n id: attendee.id ?? undefined,\n email: attendee.email ?? '',\n displayName: attendee.displayName ?? undefined,\n organizer: attendee.organizer ?? undefined,\n self: attendee.self ?? undefined,\n resource: attendee.resource ?? undefined,\n optionalAttendee: attendee.optional ?? undefined,\n responseStatus: attendee.responseStatus ?? undefined,\n comment: attendee.comment ?? undefined,\n additionalGuests: attendee.additionalGuests ?? undefined,\n };\n}\n\n/** Project a REST reminder onto the Reminder shape; unknown delivery methods drop rather than masquerade as popups. */\nexport function projectReminder(reminder: calendar_v3.Schema$EventReminder): Reminder {\n return {\n method: narrow(reminder.method, Reminder.shape.method.unwrap().options),\n minutes: reminder.minutes ?? 0,\n };\n}\n\n/**\n * The Google Meet link: the `conferenceData` video entry point's URI, falling\n * back to the legacy `hangoutLink` when the conference data carries none.\n */\nfunction conferenceUrl(event: calendar_v3.Schema$Event): Event['conferenceUrl'] {\n const video = event.conferenceData?.entryPoints?.find(\n (entryPoint) => entryPoint.entryPointType === 'video',\n );\n return video?.uri ?? event.hangoutLink ?? undefined;\n}\n\n/**\n * Project a raw REST event onto the documented Event shape: collapse\n * `conferenceData` to `conferenceUrl`, rename attendee `optional` to\n * `optionalAttendee`, surface `reminders.overrides` as `overrideReminders`,\n * and clean nulls to undefined.\n */\nexport function projectEvent(data: calendar_v3.Schema$Event): Event {\n return {\n id: data.id ?? '',\n status: data.status ?? undefined,\n htmlLink: data.htmlLink ?? undefined,\n created: data.created ?? undefined,\n updated: data.updated ?? undefined,\n summary: data.summary ?? undefined,\n description: data.description ?? undefined,\n location: data.location ?? undefined,\n creator: data.creator ? projectPrincipal(data.creator) : undefined,\n organizer: data.organizer ? projectPrincipal(data.organizer) : undefined,\n start: data.start ? projectEventDateTime(data.start) : undefined,\n end: data.end ? projectEventDateTime(data.end) : undefined,\n recurrence: data.recurrence ?? undefined,\n recurringEventId: data.recurringEventId ?? undefined,\n originalStartTime: data.originalStartTime\n ? projectEventDateTime(data.originalStartTime)\n : undefined,\n transparency: data.transparency ?? undefined,\n visibility: data.visibility ?? undefined,\n attendees: data.attendees ? data.attendees.map(projectAttendee) : undefined,\n eventType: data.eventType ?? undefined,\n conferenceUrl: conferenceUrl(data),\n colorId: data.colorId ?? undefined,\n overrideReminders: data.reminders?.overrides\n ? data.reminders.overrides.map(projectReminder)\n : undefined,\n };\n}\n"]}
@@ -1,5 +1,5 @@
1
1
  import type { calendar_v3 } from '@googleapis/calendar';
2
- import type { Optional } from '../../lib/types.js';
2
+ import type { Optional } from '../../lib/optionality.js';
3
3
  /**
4
4
  * The conference payload for the requested Meet handling: an explicit
5
5
  * googleMeetUrl attaches as a video entry point and wins over
@@ -1 +1 @@
1
- {"version":3,"file":"meet.d.ts","sourceRoot":"","sources":["../../../src/calendar/lib/meet.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AACxD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAEnD;;;;;;GAMG;AACH,wBAAgB,kBAAkB,CAAC,IAAI,EAAE;IACvC,gBAAgB,CAAC,EAAE,QAAQ,CAAC,OAAO,CAAC,CAAC;IACrC,aAAa,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,CAAC;CAClC,GAAG,QAAQ,CAAC,WAAW,CAAC,qBAAqB,CAAC,CAU9C"}
1
+ {"version":3,"file":"meet.d.ts","sourceRoot":"","sources":["../../../src/calendar/lib/meet.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AACxD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AAEzD;;;;;;GAMG;AACH,wBAAgB,kBAAkB,CAAC,IAAI,EAAE;IACvC,gBAAgB,CAAC,EAAE,QAAQ,CAAC,OAAO,CAAC,CAAC;IACrC,aAAa,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,CAAC;CAClC,GAAG,QAAQ,CAAC,WAAW,CAAC,qBAAqB,CAAC,CAU9C"}
@@ -1 +1 @@
1
- {"version":3,"file":"meet.js","sourceRoot":"","sources":["../../../src/calendar/lib/meet.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAIzC;;;;;;GAMG;AACH,MAAM,UAAU,kBAAkB,CAAC,IAGlC;IACC,IAAI,IAAI,CAAC,aAAa,KAAK,SAAS,EAAE,CAAC;QACrC,OAAO,EAAE,WAAW,EAAE,CAAC,EAAE,cAAc,EAAE,OAAO,EAAE,GAAG,EAAE,IAAI,CAAC,aAAa,EAAE,CAAC,EAAE,CAAC;IACjF,CAAC;IACD,IAAI,IAAI,CAAC,gBAAgB,EAAE,CAAC;QAC1B,OAAO;YACL,aAAa,EAAE,EAAE,SAAS,EAAE,UAAU,EAAE,EAAE,qBAAqB,EAAE,EAAE,IAAI,EAAE,cAAc,EAAE,EAAE;SAC5F,CAAC;IACJ,CAAC;IACD,OAAO,SAAS,CAAC;AACnB,CAAC","sourcesContent":["import { randomUUID } from 'node:crypto';\nimport type { calendar_v3 } from '@googleapis/calendar';\nimport type { Optional } from '../../lib/types.js';\n\n/**\n * The conference payload for the requested Meet handling: an explicit\n * googleMeetUrl attaches as a video entry point and wins over\n * addGoogleMeetUrl, which asks Google to mint a new Meet link via a create\n * request. Writing conference data requires conferenceDataVersion 1 on the\n * query; handlers set it whenever this returns a payload.\n */\nexport function meetConferenceData(args: {\n addGoogleMeetUrl?: Optional<boolean>;\n googleMeetUrl?: Optional<string>;\n}): Optional<calendar_v3.Schema$ConferenceData> {\n if (args.googleMeetUrl !== undefined) {\n return { entryPoints: [{ entryPointType: 'video', uri: args.googleMeetUrl }] };\n }\n if (args.addGoogleMeetUrl) {\n return {\n createRequest: { requestId: randomUUID(), conferenceSolutionKey: { type: 'hangoutsMeet' } },\n };\n }\n return undefined;\n}\n"]}
1
+ {"version":3,"file":"meet.js","sourceRoot":"","sources":["../../../src/calendar/lib/meet.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAIzC;;;;;;GAMG;AACH,MAAM,UAAU,kBAAkB,CAAC,IAGlC;IACC,IAAI,IAAI,CAAC,aAAa,KAAK,SAAS,EAAE,CAAC;QACrC,OAAO,EAAE,WAAW,EAAE,CAAC,EAAE,cAAc,EAAE,OAAO,EAAE,GAAG,EAAE,IAAI,CAAC,aAAa,EAAE,CAAC,EAAE,CAAC;IACjF,CAAC;IACD,IAAI,IAAI,CAAC,gBAAgB,EAAE,CAAC;QAC1B,OAAO;YACL,aAAa,EAAE,EAAE,SAAS,EAAE,UAAU,EAAE,EAAE,qBAAqB,EAAE,EAAE,IAAI,EAAE,cAAc,EAAE,EAAE;SAC5F,CAAC;IACJ,CAAC;IACD,OAAO,SAAS,CAAC;AACnB,CAAC","sourcesContent":["import { randomUUID } from 'node:crypto';\nimport type { calendar_v3 } from '@googleapis/calendar';\nimport type { Optional } from '../../lib/optionality.js';\n\n/**\n * The conference payload for the requested Meet handling: an explicit\n * googleMeetUrl attaches as a video entry point and wins over\n * addGoogleMeetUrl, which asks Google to mint a new Meet link via a create\n * request. Writing conference data requires conferenceDataVersion 1 on the\n * query; handlers set it whenever this returns a payload.\n */\nexport function meetConferenceData(args: {\n addGoogleMeetUrl?: Optional<boolean>;\n googleMeetUrl?: Optional<string>;\n}): Optional<calendar_v3.Schema$ConferenceData> {\n if (args.googleMeetUrl !== undefined) {\n return { entryPoints: [{ entryPointType: 'video', uri: args.googleMeetUrl }] };\n }\n if (args.addGoogleMeetUrl) {\n return {\n createRequest: { requestId: randomUUID(), conferenceSolutionKey: { type: 'hangoutsMeet' } },\n };\n }\n return undefined;\n}\n"]}
@@ -1,4 +1,4 @@
1
- import type { Optional } from '../../lib/types.js';
1
+ import type { Optional } from '../../lib/optionality.js';
2
2
  import type { NotificationLevel } from '../entities/NotificationLevel.js';
3
3
  /** The REST `sendUpdates` value for each notification level. */
4
4
  declare const sendUpdates: {
@@ -1 +1 @@
1
- {"version":3,"file":"notifications.d.ts","sourceRoot":"","sources":["../../../src/calendar/lib/notifications.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,kCAAkC,CAAC;AAE1E,gEAAgE;AAChE,QAAA,MAAM,WAAW;;;;CAIP,CAAC;AAEX;;;GAGG;AACH,wBAAgB,aAAa,CAC3B,KAAK,EAAE,QAAQ,CAAC,iBAAiB,CAAC,GACjC,CAAC,OAAO,WAAW,CAAC,CAAC,iBAAiB,CAAC,CAEzC"}
1
+ {"version":3,"file":"notifications.d.ts","sourceRoot":"","sources":["../../../src/calendar/lib/notifications.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AACzD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,kCAAkC,CAAC;AAE1E,gEAAgE;AAChE,QAAA,MAAM,WAAW;;;;CAIP,CAAC;AAEX;;;GAGG;AACH,wBAAgB,aAAa,CAC3B,KAAK,EAAE,QAAQ,CAAC,iBAAiB,CAAC,GACjC,CAAC,OAAO,WAAW,CAAC,CAAC,iBAAiB,CAAC,CAEzC"}
@@ -1 +1 @@
1
- {"version":3,"file":"notifications.js","sourceRoot":"","sources":["../../../src/calendar/lib/notifications.ts"],"names":[],"mappings":"AAGA,gEAAgE;AAChE,MAAM,WAAW,GAAG;IAClB,IAAI,EAAE,MAAM;IACZ,aAAa,EAAE,cAAc;IAC7B,GAAG,EAAE,KAAK;CACF,CAAC;AAEX;;;GAGG;AACH,MAAM,UAAU,aAAa,CAC3B,KAAkC;IAElC,OAAO,WAAW,CAAC,KAAK,IAAI,MAAM,CAAC,CAAC;AACtC,CAAC","sourcesContent":["import type { Optional } from '../../lib/types.js';\nimport type { NotificationLevel } from '../entities/NotificationLevel.js';\n\n/** The REST `sendUpdates` value for each notification level. */\nconst sendUpdates = {\n NONE: 'none',\n EXTERNAL_ONLY: 'externalOnly',\n ALL: 'all',\n} as const;\n\n/**\n * Map a write tool's `notificationLevel` input onto the REST `sendUpdates`\n * query parameter; an unset level means NONE (send no notification emails).\n */\nexport function toSendUpdates(\n level: Optional<NotificationLevel>,\n): (typeof sendUpdates)[NotificationLevel] {\n return sendUpdates[level ?? 'NONE'];\n}\n"]}
1
+ {"version":3,"file":"notifications.js","sourceRoot":"","sources":["../../../src/calendar/lib/notifications.ts"],"names":[],"mappings":"AAGA,gEAAgE;AAChE,MAAM,WAAW,GAAG;IAClB,IAAI,EAAE,MAAM;IACZ,aAAa,EAAE,cAAc;IAC7B,GAAG,EAAE,KAAK;CACF,CAAC;AAEX;;;GAGG;AACH,MAAM,UAAU,aAAa,CAC3B,KAAkC;IAElC,OAAO,WAAW,CAAC,KAAK,IAAI,MAAM,CAAC,CAAC;AACtC,CAAC","sourcesContent":["import type { Optional } from '../../lib/optionality.js';\nimport type { NotificationLevel } from '../entities/NotificationLevel.js';\n\n/** The REST `sendUpdates` value for each notification level. */\nconst sendUpdates = {\n NONE: 'none',\n EXTERNAL_ONLY: 'externalOnly',\n ALL: 'all',\n} as const;\n\n/**\n * Map a write tool's `notificationLevel` input onto the REST `sendUpdates`\n * query parameter; an unset level means NONE (send no notification emails).\n */\nexport function toSendUpdates(\n level: Optional<NotificationLevel>,\n): (typeof sendUpdates)[NotificationLevel] {\n return sendUpdates[level ?? 'NONE'];\n}\n"]}
@@ -1,4 +1,4 @@
1
- import type { Optional } from '../../lib/types.js';
1
+ import type { Optional } from '../../lib/optionality.js';
2
2
  /** A busy interval on some attendee's calendar, as ISO 8601 instants. */
3
3
  type BusyPeriod = {
4
4
  start: string;
@@ -1 +1 @@
1
- {"version":3,"file":"suggest.d.ts","sourceRoot":"","sources":["../../../src/calendar/lib/suggest.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAEnD,yEAAyE;AACzE,KAAK,UAAU,GAAG;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,MAAM,CAAA;CAAE,CAAC;AAEjD,8EAA8E;AAC9E,KAAK,QAAQ,GAAG;IAAE,SAAS,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAC;IAAC,eAAe,EAAE,MAAM,CAAA;CAAE,CAAC;AAEhF,uEAAuE;AACvE,KAAK,WAAW,GAAG;IACjB,SAAS,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,CAAC;IAC7B,OAAO,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,CAAC;IAC3B,eAAe,CAAC,EAAE,QAAQ,CAAC,OAAO,CAAC,CAAC;IACpC,QAAQ,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,CAAC;CAC7B,CAAC;AAUF,8GAA8G;AAC9G,eAAO,MAAM,WAAW,QAA8B,CAAC;AAqDvD;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE;IAClC,IAAI,EAAE,UAAU,EAAE,CAAC;IACnB,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,MAAM,CAAC;IAClB,eAAe,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,CAAC;IAC5B,WAAW,CAAC,EAAE,QAAQ,CAAC,WAAW,CAAC,CAAC;CACrC,GAAG,QAAQ,EAAE,CAmEb"}
1
+ {"version":3,"file":"suggest.d.ts","sourceRoot":"","sources":["../../../src/calendar/lib/suggest.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AAEzD,yEAAyE;AACzE,KAAK,UAAU,GAAG;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,MAAM,CAAA;CAAE,CAAC;AAEjD,8EAA8E;AAC9E,KAAK,QAAQ,GAAG;IAAE,SAAS,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAC;IAAC,eAAe,EAAE,MAAM,CAAA;CAAE,CAAC;AAEhF,uEAAuE;AACvE,KAAK,WAAW,GAAG;IACjB,SAAS,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,CAAC;IAC7B,OAAO,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,CAAC;IAC3B,eAAe,CAAC,EAAE,QAAQ,CAAC,OAAO,CAAC,CAAC;IACpC,QAAQ,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,CAAC;CAC7B,CAAC;AAUF,8GAA8G;AAC9G,eAAO,MAAM,WAAW,QAA8B,CAAC;AAqDvD;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE;IAClC,IAAI,EAAE,UAAU,EAAE,CAAC;IACnB,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,MAAM,CAAC;IAClB,eAAe,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,CAAC;IAC5B,WAAW,CAAC,EAAE,QAAQ,CAAC,WAAW,CAAC,CAAC;CACrC,GAAG,QAAQ,EAAE,CAmEb"}
@@ -1 +1 @@
1
- {"version":3,"file":"suggest.js","sourceRoot":"","sources":["../../../src/calendar/lib/suggest.ts"],"names":[],"mappings":"AAmBA,MAAM,mBAAmB,GAAG,MAAM,CAAC;AAEnC,MAAM,SAAS,GAAG,MAAM,CAAC;AAC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;QACF,IAAI,OAAO,KAAK,SAAS,EAAE,CAAC;YAC1B,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC;YACrB,SAAS;QACX,CAAC;QACD,MAAM,EAAE,OAAO,EAAE,YAAY,EAAE,GAAG,UAAU,CAAC,SAAS,EAAE,MAAM,CAAC,CAAC;QAChE,IAAI,eAAe,IAAI,CAAC,OAAO,KAAK,KAAK,IAAI,OAAO,KAAK,KAAK,CAAC,EAAE,CAAC;YAChE,qEAAqE;YACrE,0BAA0B;YAC1B,MAAM,IAAI,CAAC,WAAW,GAAG,YAAY,CAAC,GAAG,SAAS,CAAC;YACnD,SAAS;QACX,CAAC;QACD,IAAI,YAAY,GAAG,cAAc,EAAE,CAAC;YAClC,MAAM,IAAI,CAAC,cAAc,GAAG,YAAY,CAAC,GAAG,SAAS,CAAC;YACtD,SAAS;QACX,CAAC;QACD,IAAI,cAAc,KAAK,SAAS,IAAI,YAAY,GAAG,KAAK,CAAC,eAAe,GAAG,cAAc,EAAE,CAAC;YAC1F,wEAAwE;YACxE,sCAAsC;YACtC,MAAM,IAAI,CAAC,WAAW,GAAG,YAAY,CAAC,GAAG,SAAS,CAAC;YACnD,SAAS;QACX,CAAC;QACD,KAAK,CAAC,IAAI,CAAC;YACT,SAAS,EAAE,IAAI,IAAI,CAAC,MAAM,CAAC,CAAC,WAAW,EAAE;YACzC,OAAO,EAAE,IAAI,IAAI,CAAC,MAAM,GAAG,UAAU,CAAC,CAAC,WAAW,EAAE;YACpD,eAAe,EAAE,KAAK,CAAC,eAAe;SACvC,CAAC,CAAC;QACH,MAAM,IAAI,UAAU,CAAC;IACvB,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC","sourcesContent":["import type { Optional } from '../../lib/types.js';\n\n/** A busy interval on some attendee's calendar, as ISO 8601 instants. */\ntype BusyPeriod = { start: string; end: string };\n\n/** A suggested free slot, as ISO 8601 instants plus its length in minutes. */\ntype TimeSlot = { startTime: string; endTime: string; durationMinutes: number };\n\n/** Scheduling preferences narrowing where suggested slots may fall. */\ntype Preferences = {\n startHour?: Optional<string>;\n endHour?: Optional<string>;\n excludeWeekends?: Optional<boolean>;\n pageSize?: Optional<number>;\n};\n\n/** A busy interval in epoch milliseconds. */\ntype Interval = { start: number; end: number };\n\nconst MAX_SCAN_ITERATIONS = 10_000;\n\nconst MINUTE_MS = 60_000;\nconst DAY_MINUTES = 24 * 60;\n\n/** The HH:MM clock format the working-hour bounds require; also enforced by the suggest_time input schema. */\nexport const HOUR_OF_DAY = /^([01]\\d|2[0-3]):[0-5]\\d$/;\n\n/**\n * Parse an HH:MM working-hour bound into minutes since local midnight. Throws on\n * any other shape: a malformed bound would otherwise parse to NaN, and every\n * NaN comparison is false, so the working-hours constraint would be silently\n * ignored rather than rejected.\n */\nfunction toMinutesOfDay(hourMinute: string): number {\n if (!HOUR_OF_DAY.test(hourMinute)) {\n throw new Error(`Invalid working-hour bound \"${hourMinute}\": expected HH:MM, e.g. 09:00.`);\n }\n return Number(hourMinute.slice(0, 2)) * 60 + Number(hourMinute.slice(3, 5));\n}\n\n/** Sort busy periods chronologically and merge every overlapping or adjacent pair. */\nfunction mergeBusy(busy: BusyPeriod[]): Interval[] {\n const sorted = busy\n .map((period) => ({ start: Date.parse(period.start), end: Date.parse(period.end) }))\n .sort((a, b) => a.start - b.start);\n const merged: Interval[] = [];\n for (const period of sorted) {\n const last = merged.at(-1);\n if (last !== undefined && period.start <= last.end) {\n last.end = Math.max(last.end, period.end);\n } else {\n merged.push(period);\n }\n }\n return merged;\n}\n\n/** The local weekday and minutes since local midnight of a UTC instant. */\nfunction localClock(\n formatter: Intl.DateTimeFormat,\n at: number,\n): { weekday: string; minutesOfDay: number } {\n let weekday = '';\n let minutesOfDay = 0;\n for (const part of formatter.formatToParts(new Date(at))) {\n if (part.type === 'weekday') {\n weekday = part.value;\n }\n if (part.type === 'hour') {\n minutesOfDay += Number(part.value) * 60;\n }\n if (part.type === 'minute') {\n minutesOfDay += Number(part.value);\n }\n }\n return { weekday, minutesOfDay };\n}\n\n/**\n * Compute free time slots within a window, given the busy periods of every\n * attendee calendar.\n *\n * The window is scanned chronologically: slots of exactly `durationMinutes`\n * are emitted back to back inside every gap that overlaps no busy period, and\n * the scan stops at `preferences.pageSize` slots (default 5). A slot belongs\n * to the local day of its start instant in `timeZone` (default UTC): when\n * `excludeWeekends` is set, a slot starting on a local Saturday or Sunday is\n * skipped, and the working-hour bounds (`startHour` and `endHour`, as HH:MM)\n * require the slot to start at or after `startHour` and, measured on the\n * start's local clock, to end at or before `endHour`. Date arithmetic is plain\n * UTC; the time zone matters only for those local determinations, so the scan\n * self-corrects across DST transitions by re-reading the local clock after\n * every jump.\n */\nexport function suggestSlots(input: {\n busy: BusyPeriod[];\n windowStart: string;\n windowEnd: string;\n durationMinutes: number;\n timeZone?: Optional<string>;\n preferences?: Optional<Preferences>;\n}): TimeSlot[] {\n const durationMs = input.durationMinutes * MINUTE_MS;\n const cap = input.preferences?.pageSize ?? 5;\n const startHour = input.preferences?.startHour;\n const endHour = input.preferences?.endHour;\n const openingMinutes = startHour === undefined ? 0 : toMinutesOfDay(startHour);\n const closingMinutes = endHour === undefined ? undefined : toMinutesOfDay(endHour);\n const excludeWeekends = input.preferences?.excludeWeekends ?? false;\n const formatter = new Intl.DateTimeFormat('en-US', {\n timeZone: input.timeZone ?? 'UTC',\n weekday: 'short',\n hour: '2-digit',\n minute: '2-digit',\n hourCycle: 'h23',\n });\n const busy = mergeBusy(input.busy);\n const windowEnd = Date.parse(input.windowEnd);\n const slots: TimeSlot[] = [];\n let cursor = Date.parse(input.windowStart);\n\n // Cap the scan: every branch advances the cursor, so 10,000 iterations\n // covers roughly 27 years of day-by-day skipping; preferences that never\n // admit a slot would otherwise walk an arbitrarily wide window on the\n // single server thread. Throwing (rather than returning partial slots)\n // keeps the refusal posture: a partial answer here looks complete.\n let iterations = 0;\n\n while (slots.length < cap && cursor + durationMs <= windowEnd) {\n iterations += 1;\n if (iterations > MAX_SCAN_ITERATIONS) {\n throw new Error(\n `suggest_time scanned ${MAX_SCAN_ITERATIONS} candidate start times without filling the request; ` +\n 'narrow the window or relax the preferences.',\n );\n }\n const blocked = busy.find(\n (period) => period.start < cursor + durationMs && period.end > cursor,\n );\n if (blocked !== undefined) {\n cursor = blocked.end;\n continue;\n }\n const { weekday, minutesOfDay } = localClock(formatter, cursor);\n if (excludeWeekends && (weekday === 'Sat' || weekday === 'Sun')) {\n // Jump to (approximately) the next local midnight; the re-read above\n // corrects any DST drift.\n cursor += (DAY_MINUTES - minutesOfDay) * MINUTE_MS;\n continue;\n }\n if (minutesOfDay < openingMinutes) {\n cursor += (openingMinutes - minutesOfDay) * MINUTE_MS;\n continue;\n }\n if (closingMinutes !== undefined && minutesOfDay + input.durationMinutes > closingMinutes) {\n // Past closing for today; jump to the next local midnight, and the next\n // iteration advances to opening time.\n cursor += (DAY_MINUTES - minutesOfDay) * MINUTE_MS;\n continue;\n }\n slots.push({\n startTime: new Date(cursor).toISOString(),\n endTime: new Date(cursor + durationMs).toISOString(),\n durationMinutes: input.durationMinutes,\n });\n cursor += durationMs;\n }\n return slots;\n}\n"]}
1
+ {"version":3,"file":"suggest.js","sourceRoot":"","sources":["../../../src/calendar/lib/suggest.ts"],"names":[],"mappings":"AAmBA,MAAM,mBAAmB,GAAG,MAAM,CAAC;AAEnC,MAAM,SAAS,GAAG,MAAM,CAAC;AACzB,MAAM,WAAW,GAAG,EAAE,GAAG,EAAE,CAAC;AAE5B,8GAA8G;AAC9G,MAAM,CAAC,MAAM,WAAW,GAAG,2BAA2B,CAAC;AAEvD;;;;;GAKG;AACH,SAAS,cAAc,CAAC,UAAkB;IACxC,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,UAAU,CAAC,EAAE,CAAC;QAClC,MAAM,IAAI,KAAK,CAAC,+BAA+B,UAAU,gCAAgC,CAAC,CAAC;IAC7F,CAAC;IACD,OAAO,MAAM,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAA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AC;YACnD,SAAS;QACX,CAAC;QACD,IAAI,YAAY,GAAG,cAAc,EAAE,CAAC;YAClC,MAAM,IAAI,CAAC,cAAc,GAAG,YAAY,CAAC,GAAG,SAAS,CAAC;YACtD,SAAS;QACX,CAAC;QACD,IAAI,cAAc,KAAK,SAAS,IAAI,YAAY,GAAG,KAAK,CAAC,eAAe,GAAG,cAAc,EAAE,CAAC;YAC1F,wEAAwE;YACxE,sCAAsC;YACtC,MAAM,IAAI,CAAC,WAAW,GAAG,YAAY,CAAC,GAAG,SAAS,CAAC;YACnD,SAAS;QACX,CAAC;QACD,KAAK,CAAC,IAAI,CAAC;YACT,SAAS,EAAE,IAAI,IAAI,CAAC,MAAM,CAAC,CAAC,WAAW,EAAE;YACzC,OAAO,EAAE,IAAI,IAAI,CAAC,MAAM,GAAG,UAAU,CAAC,CAAC,WAAW,EAAE;YACpD,eAAe,EAAE,KAAK,CAAC,eAAe;SACvC,CAAC,CAAC;QACH,MAAM,IAAI,UAAU,CAAC;IACvB,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC","sourcesContent":["import type { Optional } from '../../lib/optionality.js';\n\n/** A busy interval on some attendee's calendar, as ISO 8601 instants. */\ntype BusyPeriod = { start: string; end: string };\n\n/** A suggested free slot, as ISO 8601 instants plus its length in minutes. */\ntype TimeSlot = { startTime: string; endTime: string; durationMinutes: number };\n\n/** Scheduling preferences narrowing where suggested slots may fall. */\ntype Preferences = {\n startHour?: Optional<string>;\n endHour?: Optional<string>;\n excludeWeekends?: Optional<boolean>;\n pageSize?: Optional<number>;\n};\n\n/** A busy interval in epoch milliseconds. */\ntype Interval = { start: number; end: number };\n\nconst MAX_SCAN_ITERATIONS = 10_000;\n\nconst MINUTE_MS = 60_000;\nconst DAY_MINUTES = 24 * 60;\n\n/** The HH:MM clock format the working-hour bounds require; also enforced by the suggest_time input schema. */\nexport const HOUR_OF_DAY = /^([01]\\d|2[0-3]):[0-5]\\d$/;\n\n/**\n * Parse an HH:MM working-hour bound into minutes since local midnight. Throws on\n * any other shape: a malformed bound would otherwise parse to NaN, and every\n * NaN comparison is false, so the working-hours constraint would be silently\n * ignored rather than rejected.\n */\nfunction toMinutesOfDay(hourMinute: string): number {\n if (!HOUR_OF_DAY.test(hourMinute)) {\n throw new Error(`Invalid working-hour bound \"${hourMinute}\": expected HH:MM, e.g. 09:00.`);\n }\n return Number(hourMinute.slice(0, 2)) * 60 + Number(hourMinute.slice(3, 5));\n}\n\n/** Sort busy periods chronologically and merge every overlapping or adjacent pair. */\nfunction mergeBusy(busy: BusyPeriod[]): Interval[] {\n const sorted = busy\n .map((period) => ({ start: Date.parse(period.start), end: Date.parse(period.end) }))\n .sort((a, b) => a.start - b.start);\n const merged: Interval[] = [];\n for (const period of sorted) {\n const last = merged.at(-1);\n if (last !== undefined && period.start <= last.end) {\n last.end = Math.max(last.end, period.end);\n } else {\n merged.push(period);\n }\n }\n return merged;\n}\n\n/** The local weekday and minutes since local midnight of a UTC instant. */\nfunction localClock(\n formatter: Intl.DateTimeFormat,\n at: number,\n): { weekday: string; minutesOfDay: number } {\n let weekday = '';\n let minutesOfDay = 0;\n for (const part of formatter.formatToParts(new Date(at))) {\n if (part.type === 'weekday') {\n weekday = part.value;\n }\n if (part.type === 'hour') {\n minutesOfDay += Number(part.value) * 60;\n }\n if (part.type === 'minute') {\n minutesOfDay += Number(part.value);\n }\n }\n return { weekday, minutesOfDay };\n}\n\n/**\n * Compute free time slots within a window, given the busy periods of every\n * attendee calendar.\n *\n * The window is scanned chronologically: slots of exactly `durationMinutes`\n * are emitted back to back inside every gap that overlaps no busy period, and\n * the scan stops at `preferences.pageSize` slots (default 5). A slot belongs\n * to the local day of its start instant in `timeZone` (default UTC): when\n * `excludeWeekends` is set, a slot starting on a local Saturday or Sunday is\n * skipped, and the working-hour bounds (`startHour` and `endHour`, as HH:MM)\n * require the slot to start at or after `startHour` and, measured on the\n * start's local clock, to end at or before `endHour`. Date arithmetic is plain\n * UTC; the time zone matters only for those local determinations, so the scan\n * self-corrects across DST transitions by re-reading the local clock after\n * every jump.\n */\nexport function suggestSlots(input: {\n busy: BusyPeriod[];\n windowStart: string;\n windowEnd: string;\n durationMinutes: number;\n timeZone?: Optional<string>;\n preferences?: Optional<Preferences>;\n}): TimeSlot[] {\n const durationMs = input.durationMinutes * MINUTE_MS;\n const cap = input.preferences?.pageSize ?? 5;\n const startHour = input.preferences?.startHour;\n const endHour = input.preferences?.endHour;\n const openingMinutes = startHour === undefined ? 0 : toMinutesOfDay(startHour);\n const closingMinutes = endHour === undefined ? undefined : toMinutesOfDay(endHour);\n const excludeWeekends = input.preferences?.excludeWeekends ?? false;\n const formatter = new Intl.DateTimeFormat('en-US', {\n timeZone: input.timeZone ?? 'UTC',\n weekday: 'short',\n hour: '2-digit',\n minute: '2-digit',\n hourCycle: 'h23',\n });\n const busy = mergeBusy(input.busy);\n const windowEnd = Date.parse(input.windowEnd);\n const slots: TimeSlot[] = [];\n let cursor = Date.parse(input.windowStart);\n\n // Cap the scan: every branch advances the cursor, so 10,000 iterations\n // covers roughly 27 years of day-by-day skipping; preferences that never\n // admit a slot would otherwise walk an arbitrarily wide window on the\n // single server thread. Throwing (rather than returning partial slots)\n // keeps the refusal posture: a partial answer here looks complete.\n let iterations = 0;\n\n while (slots.length < cap && cursor + durationMs <= windowEnd) {\n iterations += 1;\n if (iterations > MAX_SCAN_ITERATIONS) {\n throw new Error(\n `suggest_time scanned ${MAX_SCAN_ITERATIONS} candidate start times without filling the request; ` +\n 'narrow the window or relax the preferences.',\n );\n }\n const blocked = busy.find(\n (period) => period.start < cursor + durationMs && period.end > cursor,\n );\n if (blocked !== undefined) {\n cursor = blocked.end;\n continue;\n }\n const { weekday, minutesOfDay } = localClock(formatter, cursor);\n if (excludeWeekends && (weekday === 'Sat' || weekday === 'Sun')) {\n // Jump to (approximately) the next local midnight; the re-read above\n // corrects any DST drift.\n cursor += (DAY_MINUTES - minutesOfDay) * MINUTE_MS;\n continue;\n }\n if (minutesOfDay < openingMinutes) {\n cursor += (openingMinutes - minutesOfDay) * MINUTE_MS;\n continue;\n }\n if (closingMinutes !== undefined && minutesOfDay + input.durationMinutes > closingMinutes) {\n // Past closing for today; jump to the next local midnight, and the next\n // iteration advances to opening time.\n cursor += (DAY_MINUTES - minutesOfDay) * MINUTE_MS;\n continue;\n }\n slots.push({\n startTime: new Date(cursor).toISOString(),\n endTime: new Date(cursor + durationMs).toISOString(),\n durationMinutes: input.durationMinutes,\n });\n cursor += durationMs;\n }\n return slots;\n}\n"]}
@@ -1,4 +1,4 @@
1
- import { forGoogle } from '../../../lib/google.js';
1
+ import { forGoogle } from '../../../lib/optionality.js';
2
2
  import { projectCalendar } from '../../lib/calendar.js';
3
3
  export async function handler(calendar, args) {
4
4
  const { data } = await calendar.calendars.insert({
@@ -1 +1 @@
1
- {"version":3,"file":"handler.js","sourceRoot":"","sources":["../../../../src/calendar/methods/create_calendar/handler.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AACnD,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAGxD,MAAM,CAAC,KAAK,UAAU,OAAO,CAC3B,QAA8B,EAC9B,IAAkC;IAElC,MAAM,EAAE,IAAI,EAAE,GAAG,MAAM,QAAQ,CAAC,SAAS,CAAC,MAAM,CAAC;QAC/C,WAAW,EAAE,SAAS,CAAC;YACrB,OAAO,EAAE,IAAI,CAAC,OAAO;YACrB,WAAW,EAAE,IAAI,CAAC,WAAW;YAC7B,QAAQ,EAAE,IAAI,CAAC,QAAQ;YACvB,QAAQ,EAAE,IAAI,CAAC,QAAQ;SACxB,CAAC;KACH,CAAC,CAAC;IACH,OAAO,eAAe,CAAC,IAAI,CAAC,CAAC;AAC/B,CAAC","sourcesContent":["import type { calendar_v3 } from '@googleapis/calendar';\nimport type { z } from 'zod';\nimport { forGoogle } from '../../../lib/google.js';\nimport { projectCalendar } from '../../lib/calendar.js';\nimport type { schema } from './schema.js';\n\nexport async function handler(\n calendar: calendar_v3.Calendar,\n args: z.infer<typeof schema.input>,\n): Promise<z.infer<typeof schema.output>> {\n const { data } = await calendar.calendars.insert({\n requestBody: forGoogle({\n summary: args.summary,\n description: args.description,\n location: args.location,\n timeZone: args.timeZone,\n }),\n });\n return projectCalendar(data);\n}\n"]}
1
+ {"version":3,"file":"handler.js","sourceRoot":"","sources":["../../../../src/calendar/methods/create_calendar/handler.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,SAAS,EAAE,MAAM,6BAA6B,CAAC;AACxD,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAGxD,MAAM,CAAC,KAAK,UAAU,OAAO,CAC3B,QAA8B,EAC9B,IAAkC;IAElC,MAAM,EAAE,IAAI,EAAE,GAAG,MAAM,QAAQ,CAAC,SAAS,CAAC,MAAM,CAAC;QAC/C,WAAW,EAAE,SAAS,CAAC;YACrB,OAAO,EAAE,IAAI,CAAC,OAAO;YACrB,WAAW,EAAE,IAAI,CAAC,WAAW;YAC7B,QAAQ,EAAE,IAAI,CAAC,QAAQ;YACvB,QAAQ,EAAE,IAAI,CAAC,QAAQ;SACxB,CAAC;KACH,CAAC,CAAC;IACH,OAAO,eAAe,CAAC,IAAI,CAAC,CAAC;AAC/B,CAAC","sourcesContent":["import type { calendar_v3 } from '@googleapis/calendar';\nimport type { z } from 'zod';\nimport { forGoogle } from '../../../lib/optionality.js';\nimport { projectCalendar } from '../../lib/calendar.js';\nimport type { schema } from './schema.js';\n\nexport async function handler(\n calendar: calendar_v3.Calendar,\n args: z.infer<typeof schema.input>,\n): Promise<z.infer<typeof schema.output>> {\n const { data } = await calendar.calendars.insert({\n requestBody: forGoogle({\n summary: args.summary,\n description: args.description,\n location: args.location,\n timeZone: args.timeZone,\n }),\n });\n return projectCalendar(data);\n}\n"]}
@@ -1,4 +1,4 @@
1
- import { forGoogle } from '../../../lib/google.js';
1
+ import { forGoogle } from '../../../lib/optionality.js';
2
2
  import { projectEvent, projectReminder } from '../../lib/event.js';
3
3
  export async function handler(calendar, args) {
4
4
  const { data } = await calendar.events.instances(forGoogle({
@@ -1 +1 @@
1
- {"version":3,"file":"handler.js","sourceRoot":"","sources":["../../../../src/calendar/methods/list_event_instances/handler.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AACnD,OAAO,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAGnE,MAAM,CAAC,KAAK,UAAU,OAAO,CAC3B,QAA8B,EAC9B,IAAkC;IAElC,MAAM,EAAE,IAAI,EAAE,GAAG,MAAM,QAAQ,CAAC,MAAM,CAAC,SAAS,CAC9C,SAAS,CAAC;QACR,UAAU,EAAE,IAAI,CAAC,UAAU,IAAI,SAAS;QACxC,OAAO,EAAE,IAAI,CAAC,OAAO;QACrB,UAAU,EAAE,IAAI,CAAC,UAAU;QAC3B,SAAS,EAAE,IAAI,CAAC,SAAS;QACzB,aAAa,EAAE,IAAI,CAAC,aAAa;QACjC,WAAW,EAAE,IAAI,CAAC,WAAW;QAC7B,OAAO,EAAE,IAAI,CAAC,OAAO;QACrB,OAAO,EAAE,IAAI,CAAC,OAAO;QACrB,QAAQ,EAAE,IAAI,CAAC,QAAQ;KACxB,CAAC,CACH,CAAC;IACF,OAAO;QACL,OAAO,EAAE,IAAI,CAAC,OAAO,IAAI,SAAS;QAClC,WAAW,EAAE,IAAI,CAAC,WAAW,IAAI,SAAS;QAC1C,OAAO,EAAE,IAAI,CAAC,OAAO,IAAI,SAAS;QAClC,QAAQ,EAAE,IAAI,CAAC,QAAQ,IAAI,SAAS;QACpC,UAAU,EAAE,IAAI,CAAC,UAAU,IAAI,SAAS;QACxC,gBAAgB,EAAE,IAAI,CAAC,gBAAgB;YACrC,CAAC,CAAC,IAAI,CAAC,gBAAgB,CAAC,GAAG,CAAC,eAAe,CAAC;YAC5C,CAAC,CAAC,SAAS;QACb,MAAM,EAAE,CAAC,IAAI,CAAC,KAAK,IAAI,EAAE,CAAC,CAAC,GAAG,CAAC,YAAY,CAAC;QAC5C,aAAa,EAAE,IAAI,CAAC,aAAa,IAAI,SAAS;KAC/C,CAAC;AACJ,CAAC","sourcesContent":["import type { calendar_v3 } from '@googleapis/calendar';\nimport type { z } from 'zod';\nimport { forGoogle } from '../../../lib/google.js';\nimport { projectEvent, projectReminder } from '../../lib/event.js';\nimport type { schema } from './schema.js';\n\nexport async function handler(\n calendar: calendar_v3.Calendar,\n args: z.infer<typeof schema.input>,\n): Promise<z.infer<typeof schema.output>> {\n const { data } = await calendar.events.instances(\n forGoogle({\n calendarId: args.calendarId ?? 'primary',\n eventId: args.eventId,\n maxResults: args.maxResults,\n pageToken: args.pageToken,\n originalStart: args.originalStart,\n showDeleted: args.showDeleted,\n timeMin: args.timeMin,\n timeMax: args.timeMax,\n timeZone: args.timeZone,\n }),\n );\n return {\n summary: data.summary ?? undefined,\n description: data.description ?? undefined,\n updated: data.updated ?? undefined,\n timeZone: data.timeZone ?? undefined,\n accessRole: data.accessRole ?? undefined,\n defaultReminders: data.defaultReminders\n ? data.defaultReminders.map(projectReminder)\n : undefined,\n events: (data.items ?? []).map(projectEvent),\n nextPageToken: data.nextPageToken ?? undefined,\n };\n}\n"]}
1
+ {"version":3,"file":"handler.js","sourceRoot":"","sources":["../../../../src/calendar/methods/list_event_instances/handler.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,SAAS,EAAE,MAAM,6BAA6B,CAAC;AACxD,OAAO,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAGnE,MAAM,CAAC,KAAK,UAAU,OAAO,CAC3B,QAA8B,EAC9B,IAAkC;IAElC,MAAM,EAAE,IAAI,EAAE,GAAG,MAAM,QAAQ,CAAC,MAAM,CAAC,SAAS,CAC9C,SAAS,CAAC;QACR,UAAU,EAAE,IAAI,CAAC,UAAU,IAAI,SAAS;QACxC,OAAO,EAAE,IAAI,CAAC,OAAO;QACrB,UAAU,EAAE,IAAI,CAAC,UAAU;QAC3B,SAAS,EAAE,IAAI,CAAC,SAAS;QACzB,aAAa,EAAE,IAAI,CAAC,aAAa;QACjC,WAAW,EAAE,IAAI,CAAC,WAAW;QAC7B,OAAO,EAAE,IAAI,CAAC,OAAO;QACrB,OAAO,EAAE,IAAI,CAAC,OAAO;QACrB,QAAQ,EAAE,IAAI,CAAC,QAAQ;KACxB,CAAC,CACH,CAAC;IACF,OAAO;QACL,OAAO,EAAE,IAAI,CAAC,OAAO,IAAI,SAAS;QAClC,WAAW,EAAE,IAAI,CAAC,WAAW,IAAI,SAAS;QAC1C,OAAO,EAAE,IAAI,CAAC,OAAO,IAAI,SAAS;QAClC,QAAQ,EAAE,IAAI,CAAC,QAAQ,IAAI,SAAS;QACpC,UAAU,EAAE,IAAI,CAAC,UAAU,IAAI,SAAS;QACxC,gBAAgB,EAAE,IAAI,CAAC,gBAAgB;YACrC,CAAC,CAAC,IAAI,CAAC,gBAAgB,CAAC,GAAG,CAAC,eAAe,CAAC;YAC5C,CAAC,CAAC,SAAS;QACb,MAAM,EAAE,CAAC,IAAI,CAAC,KAAK,IAAI,EAAE,CAAC,CAAC,GAAG,CAAC,YAAY,CAAC;QAC5C,aAAa,EAAE,IAAI,CAAC,aAAa,IAAI,SAAS;KAC/C,CAAC;AACJ,CAAC","sourcesContent":["import type { calendar_v3 } from '@googleapis/calendar';\nimport type { z } from 'zod';\nimport { forGoogle } from '../../../lib/optionality.js';\nimport { projectEvent, projectReminder } from '../../lib/event.js';\nimport type { schema } from './schema.js';\n\nexport async function handler(\n calendar: calendar_v3.Calendar,\n args: z.infer<typeof schema.input>,\n): Promise<z.infer<typeof schema.output>> {\n const { data } = await calendar.events.instances(\n forGoogle({\n calendarId: args.calendarId ?? 'primary',\n eventId: args.eventId,\n maxResults: args.maxResults,\n pageToken: args.pageToken,\n originalStart: args.originalStart,\n showDeleted: args.showDeleted,\n timeMin: args.timeMin,\n timeMax: args.timeMax,\n timeZone: args.timeZone,\n }),\n );\n return {\n summary: data.summary ?? undefined,\n description: data.description ?? undefined,\n updated: data.updated ?? undefined,\n timeZone: data.timeZone ?? undefined,\n accessRole: data.accessRole ?? undefined,\n defaultReminders: data.defaultReminders\n ? data.defaultReminders.map(projectReminder)\n : undefined,\n events: (data.items ?? []).map(projectEvent),\n nextPageToken: data.nextPageToken ?? undefined,\n };\n}\n"]}
@@ -1,4 +1,4 @@
1
- import { forGoogle } from '../../../lib/google.js';
1
+ import { forGoogle } from '../../../lib/optionality.js';
2
2
  export async function handler(calendar, args) {
3
3
  const { data } = await calendar.settings.list(forGoogle({
4
4
  maxResults: args.maxResults,
@@ -1 +1 @@
1
- {"version":3,"file":"handler.js","sourceRoot":"","sources":["../../../../src/calendar/methods/list_settings/handler.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AAGnD,MAAM,CAAC,KAAK,UAAU,OAAO,CAC3B,QAA8B,EAC9B,IAAkC;IAElC,MAAM,EAAE,IAAI,EAAE,GAAG,MAAM,QAAQ,CAAC,QAAQ,CAAC,IAAI,CAC3C,SAAS,CAAC;QACR,UAAU,EAAE,IAAI,CAAC,UAAU;QAC3B,SAAS,EAAE,IAAI,CAAC,SAAS;KAC1B,CAAC,CACH,CAAC;IACF,OAAO;QACL,QAAQ,EAAE,CAAC,IAAI,CAAC,KAAK,IAAI,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC;YAC7C,EAAE,EAAE,OAAO,CAAC,EAAE,IAAI,EAAE;YACpB,KAAK,EAAE,OAAO,CAAC,KAAK,IAAI,EAAE;SAC3B,CAAC,CAAC;QACH,aAAa,EAAE,IAAI,CAAC,aAAa,IAAI,SAAS;KAC/C,CAAC;AACJ,CAAC","sourcesContent":["import type { calendar_v3 } from '@googleapis/calendar';\nimport type { z } from 'zod';\nimport { forGoogle } from '../../../lib/google.js';\nimport type { schema } from './schema.js';\n\nexport async function handler(\n calendar: calendar_v3.Calendar,\n args: z.infer<typeof schema.input>,\n): Promise<z.infer<typeof schema.output>> {\n const { data } = await calendar.settings.list(\n forGoogle({\n maxResults: args.maxResults,\n pageToken: args.pageToken,\n }),\n );\n return {\n settings: (data.items ?? []).map((setting) => ({\n id: setting.id ?? '',\n value: setting.value ?? '',\n })),\n nextPageToken: data.nextPageToken ?? undefined,\n };\n}\n"]}
1
+ {"version":3,"file":"handler.js","sourceRoot":"","sources":["../../../../src/calendar/methods/list_settings/handler.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,SAAS,EAAE,MAAM,6BAA6B,CAAC;AAGxD,MAAM,CAAC,KAAK,UAAU,OAAO,CAC3B,QAA8B,EAC9B,IAAkC;IAElC,MAAM,EAAE,IAAI,EAAE,GAAG,MAAM,QAAQ,CAAC,QAAQ,CAAC,IAAI,CAC3C,SAAS,CAAC;QACR,UAAU,EAAE,IAAI,CAAC,UAAU;QAC3B,SAAS,EAAE,IAAI,CAAC,SAAS;KAC1B,CAAC,CACH,CAAC;IACF,OAAO;QACL,QAAQ,EAAE,CAAC,IAAI,CAAC,KAAK,IAAI,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC;YAC7C,EAAE,EAAE,OAAO,CAAC,EAAE,IAAI,EAAE;YACpB,KAAK,EAAE,OAAO,CAAC,KAAK,IAAI,EAAE;SAC3B,CAAC,CAAC;QACH,aAAa,EAAE,IAAI,CAAC,aAAa,IAAI,SAAS;KAC/C,CAAC;AACJ,CAAC","sourcesContent":["import type { calendar_v3 } from '@googleapis/calendar';\nimport type { z } from 'zod';\nimport { forGoogle } from '../../../lib/optionality.js';\nimport type { schema } from './schema.js';\n\nexport async function handler(\n calendar: calendar_v3.Calendar,\n args: z.infer<typeof schema.input>,\n): Promise<z.infer<typeof schema.output>> {\n const { data } = await calendar.settings.list(\n forGoogle({\n maxResults: args.maxResults,\n pageToken: args.pageToken,\n }),\n );\n return {\n settings: (data.items ?? []).map((setting) => ({\n id: setting.id ?? '',\n value: setting.value ?? '',\n })),\n nextPageToken: data.nextPageToken ?? undefined,\n };\n}\n"]}
@@ -1,4 +1,4 @@
1
- import { forGoogle } from '../../../lib/google.js';
1
+ import { forGoogle } from '../../../lib/optionality.js';
2
2
  import { projectEvent } from '../../lib/event.js';
3
3
  export async function handler(calendar, args) {
4
4
  const { data } = await calendar.events.move(forGoogle({
@@ -1 +1 @@
1
- {"version":3,"file":"handler.js","sourceRoot":"","sources":["../../../../src/calendar/methods/move_event/handler.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AACnD,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAGlD,MAAM,CAAC,KAAK,UAAU,OAAO,CAC3B,QAA8B,EAC9B,IAAkC;IAElC,MAAM,EAAE,IAAI,EAAE,GAAG,MAAM,QAAQ,CAAC,MAAM,CAAC,IAAI,CACzC,SAAS,CAAC;QACR,UAAU,EAAE,IAAI,CAAC,UAAU,IAAI,SAAS;QACxC,OAAO,EAAE,IAAI,CAAC,OAAO;QACrB,WAAW,EAAE,IAAI,CAAC,WAAW;QAC7B,WAAW,EAAE,IAAI,CAAC,WAAW;KAC9B,CAAC,CACH,CAAC;IACF,OAAO,YAAY,CAAC,IAAI,CAAC,CAAC;AAC5B,CAAC","sourcesContent":["import type { calendar_v3 } from '@googleapis/calendar';\nimport type { z } from 'zod';\nimport { forGoogle } from '../../../lib/google.js';\nimport { projectEvent } from '../../lib/event.js';\nimport type { schema } from './schema.js';\n\nexport async function handler(\n calendar: calendar_v3.Calendar,\n args: z.infer<typeof schema.input>,\n): Promise<z.infer<typeof schema.output>> {\n const { data } = await calendar.events.move(\n forGoogle({\n calendarId: args.calendarId ?? 'primary',\n eventId: args.eventId,\n destination: args.destination,\n sendUpdates: args.sendUpdates,\n }),\n );\n return projectEvent(data);\n}\n"]}
1
+ {"version":3,"file":"handler.js","sourceRoot":"","sources":["../../../../src/calendar/methods/move_event/handler.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,SAAS,EAAE,MAAM,6BAA6B,CAAC;AACxD,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAGlD,MAAM,CAAC,KAAK,UAAU,OAAO,CAC3B,QAA8B,EAC9B,IAAkC;IAElC,MAAM,EAAE,IAAI,EAAE,GAAG,MAAM,QAAQ,CAAC,MAAM,CAAC,IAAI,CACzC,SAAS,CAAC;QACR,UAAU,EAAE,IAAI,CAAC,UAAU,IAAI,SAAS;QACxC,OAAO,EAAE,IAAI,CAAC,OAAO;QACrB,WAAW,EAAE,IAAI,CAAC,WAAW;QAC7B,WAAW,EAAE,IAAI,CAAC,WAAW;KAC9B,CAAC,CACH,CAAC;IACF,OAAO,YAAY,CAAC,IAAI,CAAC,CAAC;AAC5B,CAAC","sourcesContent":["import type { calendar_v3 } from '@googleapis/calendar';\nimport type { z } from 'zod';\nimport { forGoogle } from '../../../lib/optionality.js';\nimport { projectEvent } from '../../lib/event.js';\nimport type { schema } from './schema.js';\n\nexport async function handler(\n calendar: calendar_v3.Calendar,\n args: z.infer<typeof schema.input>,\n): Promise<z.infer<typeof schema.output>> {\n const { data } = await calendar.events.move(\n forGoogle({\n calendarId: args.calendarId ?? 'primary',\n eventId: args.eventId,\n destination: args.destination,\n sendUpdates: args.sendUpdates,\n }),\n );\n return projectEvent(data);\n}\n"]}
@@ -1,4 +1,4 @@
1
- import { forGoogle } from '../../../lib/google.js';
1
+ import { forGoogle } from '../../../lib/optionality.js';
2
2
  import { projectEvent } from '../../lib/event.js';
3
3
  export async function handler(calendar, args) {
4
4
  const { data } = await calendar.events.patch(forGoogle({