@notionhq/client 5.26.0 → 5.27.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (50) hide show
  1. package/README.md +130 -129
  2. package/build/package.json +4 -3
  3. package/build/src/Client.d.ts +1867 -130
  4. package/build/src/Client.d.ts.map +1 -1
  5. package/build/src/Client.js +95 -571
  6. package/build/src/Client.js.map +1 -1
  7. package/build/src/api-endpoint-methods.d.ts +920 -0
  8. package/build/src/api-endpoint-methods.d.ts.map +1 -0
  9. package/build/src/api-endpoint-methods.js +171 -0
  10. package/build/src/api-endpoint-methods.js.map +1 -0
  11. package/build/src/api-endpoints/agent-skills.d.ts +68 -0
  12. package/build/src/api-endpoints/agent-skills.d.ts.map +1 -0
  13. package/build/src/api-endpoints/agent-skills.js +36 -0
  14. package/build/src/api-endpoints/agent-skills.js.map +1 -0
  15. package/build/src/api-endpoints/agents.d.ts +173 -146
  16. package/build/src/api-endpoints/agents.d.ts.map +1 -1
  17. package/build/src/api-endpoints/agents.js.map +1 -1
  18. package/build/src/api-endpoints/data-sources.d.ts +1 -0
  19. package/build/src/api-endpoints/data-sources.d.ts.map +1 -1
  20. package/build/src/api-endpoints/data-sources.js.map +1 -1
  21. package/build/src/api-endpoints/databases.d.ts +3 -1
  22. package/build/src/api-endpoints/databases.d.ts.map +1 -1
  23. package/build/src/api-endpoints/databases.js +1 -0
  24. package/build/src/api-endpoints/databases.js.map +1 -1
  25. package/build/src/api-endpoints/file-uploads.d.ts.map +1 -1
  26. package/build/src/api-endpoints/file-uploads.js.map +1 -1
  27. package/build/src/api-endpoints/pages.d.ts.map +1 -1
  28. package/build/src/api-endpoints/pages.js.map +1 -1
  29. package/build/src/api-endpoints/users.d.ts.map +1 -1
  30. package/build/src/api-endpoints/users.js.map +1 -1
  31. package/build/src/api-endpoints.d.ts +1 -0
  32. package/build/src/api-endpoints.d.ts.map +1 -1
  33. package/build/src/api-endpoints.js +1 -0
  34. package/build/src/api-endpoints.js.map +1 -1
  35. package/build/src/errors.d.ts +11 -0
  36. package/build/src/errors.d.ts.map +1 -1
  37. package/build/src/errors.js +20 -1
  38. package/build/src/errors.js.map +1 -1
  39. package/build/src/helpers.d.ts +4 -4
  40. package/build/src/helpers.d.ts.map +1 -1
  41. package/build/src/helpers.js.map +1 -1
  42. package/build/src/index.d.ts +2 -2
  43. package/build/src/index.d.ts.map +1 -1
  44. package/build/src/index.js +2 -1
  45. package/build/src/index.js.map +1 -1
  46. package/build/src/webhooks.d.ts +12 -19
  47. package/build/src/webhooks.d.ts.map +1 -1
  48. package/build/src/webhooks.js +27 -35
  49. package/build/src/webhooks.js.map +1 -1
  50. package/package.json +4 -3
@@ -10,8 +10,9 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
10
10
  if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
11
11
  return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
12
12
  };
13
- var _Client_auth, _Client_logLevel, _Client_logger, _Client_prefixUrl, _Client_timeoutMs, _Client_notionVersion, _Client_fetch, _Client_agent, _Client_userAgent, _Client_maxRetries, _Client_initialRetryDelayMs, _Client_maxRetryDelayMs;
13
+ var _Client_endpointMethods, _Client_auth, _Client_logLevel, _Client_logger, _Client_prefixUrl, _Client_timeoutMs, _Client_notionVersion, _Client_fetch, _Client_agent, _Client_userAgent, _Client_maxRetries, _Client_initialRetryDelayMs, _Client_maxRetryDelayMs, _Client_dangerouslyAllowBrowser;
14
14
  Object.defineProperty(exports, "__esModule", { value: true });
15
+ const api_endpoint_methods_1 = require("./api-endpoint-methods");
15
16
  const logging_1 = require("./logging");
16
17
  const errors_1 = require("./errors");
17
18
  const utils_1 = require("./utils");
@@ -20,9 +21,36 @@ const api_endpoints_1 = require("./api-endpoints");
20
21
  const meeting_notes_1 = require("./api-endpoints/meeting-notes");
21
22
  const package_json_1 = require("../package.json");
22
23
  const START_CURSOR_PARAM_NAME = "start_cursor";
24
+ /**
25
+ * True inside a browser page, web worker, or service worker: the places where
26
+ * every visitor downloads the script, so a token in it is public. Test runners
27
+ * that emulate a browser, such as jsdom, also count as a browser here.
28
+ *
29
+ * A browser worker's global object is an instance of `WorkerGlobalScope` and
30
+ * has an `importScripts` function. Some server runtimes match one but not
31
+ * both: the global object in Cloudflare Workers is not an instance of
32
+ * `WorkerGlobalScope`, and Deno worker threads lack `importScripts`. Both
33
+ * checks look for browser traits, so a global that a polyfill or other
34
+ * library adds can only make this check stricter, never turn it off.
35
+ */
36
+ function isBrowserEnvironment() {
37
+ var _a;
38
+ const browserGlobals = globalThis;
39
+ if (((_a = browserGlobals.window) === null || _a === void 0 ? void 0 : _a.document) !== undefined) {
40
+ return true;
41
+ }
42
+ const workerGlobalScope = browserGlobals.WorkerGlobalScope;
43
+ return (typeof workerGlobalScope === "function" &&
44
+ globalThis instanceof workerGlobalScope &&
45
+ typeof browserGlobals.importScripts === "function");
46
+ }
23
47
  class Client {
24
48
  constructor(options) {
25
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
49
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o;
50
+ _Client_endpointMethods.set(this, (0, api_endpoint_methods_1.createEndpointMethods)({
51
+ request: args => this.request(args),
52
+ warnUnknownParams: (args, endpoint) => this.warnUnknownParams(args, endpoint),
53
+ }));
26
54
  _Client_auth.set(this, void 0);
27
55
  _Client_logLevel.set(this, void 0);
28
56
  _Client_logger.set(this, void 0);
@@ -35,129 +63,29 @@ class Client {
35
63
  _Client_maxRetries.set(this, void 0);
36
64
  _Client_initialRetryDelayMs.set(this, void 0);
37
65
  _Client_maxRetryDelayMs.set(this, void 0);
66
+ _Client_dangerouslyAllowBrowser.set(this, void 0);
38
67
  /*
39
68
  * Notion API endpoints
40
69
  */
41
- this.agents = {
42
- /**
43
- * Retrieve an agent
44
- */
45
- retrieve: (args) => {
46
- this.warnUnknownParams(args, api_endpoints_1.getAgent);
47
- return this.request({
48
- path: api_endpoints_1.getAgent.path(args),
49
- method: api_endpoints_1.getAgent.method,
50
- query: (0, utils_1.pick)(args, api_endpoints_1.getAgent.queryParams),
51
- body: (0, utils_1.pick)(args, api_endpoints_1.getAgent.bodyParams),
52
- auth: args === null || args === void 0 ? void 0 : args.auth,
53
- });
54
- },
55
- /**
56
- * Query agents
57
- */
58
- query: (args) => {
59
- this.warnUnknownParams(args, api_endpoints_1.queryAgents);
60
- return this.request({
61
- path: api_endpoints_1.queryAgents.path(),
62
- method: api_endpoints_1.queryAgents.method,
63
- query: (0, utils_1.pick)(args, api_endpoints_1.queryAgents.queryParams),
64
- body: (0, utils_1.pick)(args, api_endpoints_1.queryAgents.bodyParams),
65
- auth: args === null || args === void 0 ? void 0 : args.auth,
66
- });
67
- },
68
- /**
69
- * Retrieve agent insights
70
- */
71
- retrieveInsights: (args) => {
72
- this.warnUnknownParams(args, api_endpoints_1.getInsights);
73
- return this.request({
74
- path: api_endpoints_1.getInsights.path(args),
75
- method: api_endpoints_1.getInsights.method,
76
- query: (0, utils_1.pick)(args, api_endpoints_1.getInsights.queryParams),
77
- body: (0, utils_1.pick)(args, api_endpoints_1.getInsights.bodyParams),
78
- auth: args === null || args === void 0 ? void 0 : args.auth,
79
- });
80
- },
81
- /**
82
- * Update an agent's credit limit
83
- */
84
- updateCreditLimit: (args) => {
85
- this.warnUnknownParams(args, api_endpoints_1.updateAgentCreditLimit);
86
- return this.request({
87
- path: api_endpoints_1.updateAgentCreditLimit.path(args),
88
- method: api_endpoints_1.updateAgentCreditLimit.method,
89
- query: (0, utils_1.pick)(args, api_endpoints_1.updateAgentCreditLimit.queryParams),
90
- body: (0, utils_1.pick)(args, api_endpoints_1.updateAgentCreditLimit.bodyParams),
91
- auth: args === null || args === void 0 ? void 0 : args.auth,
92
- });
93
- },
94
- /**
95
- * Update an agent's status
96
- */
97
- updateStatus: (args) => {
98
- this.warnUnknownParams(args, api_endpoints_1.updateAgentStatus);
99
- return this.request({
100
- path: api_endpoints_1.updateAgentStatus.path(args),
101
- method: api_endpoints_1.updateAgentStatus.method,
102
- query: (0, utils_1.pick)(args, api_endpoints_1.updateAgentStatus.queryParams),
103
- body: (0, utils_1.pick)(args, api_endpoints_1.updateAgentStatus.bodyParams),
104
- auth: args === null || args === void 0 ? void 0 : args.auth,
105
- });
106
- },
107
- /**
108
- * Delete an agent
109
- */
110
- delete: (args) => {
111
- this.warnUnknownParams(args, api_endpoints_1.deleteAgent);
112
- return this.request({
113
- path: api_endpoints_1.deleteAgent.path(args),
114
- method: api_endpoints_1.deleteAgent.method,
115
- query: (0, utils_1.pick)(args, api_endpoints_1.deleteAgent.queryParams),
116
- body: (0, utils_1.pick)(args, api_endpoints_1.deleteAgent.bodyParams),
117
- auth: args === null || args === void 0 ? void 0 : args.auth,
118
- });
119
- },
120
- /**
121
- * Apply many agent operations
122
- */
123
- batch: (args) => {
124
- this.warnUnknownParams(args, api_endpoints_1.agentBatch);
125
- return this.request({
126
- path: api_endpoints_1.agentBatch.path(),
127
- method: api_endpoints_1.agentBatch.method,
128
- query: (0, utils_1.pick)(args, api_endpoints_1.agentBatch.queryParams),
129
- body: (0, utils_1.pick)(args, api_endpoints_1.agentBatch.bodyParams),
130
- auth: args === null || args === void 0 ? void 0 : args.auth,
131
- });
132
- },
70
+ this.plugins = {
71
+ list: __classPrivateFieldGet(this, _Client_endpointMethods, "f").plugins.list,
72
+ retrieve: (args) => __classPrivateFieldGet(this, _Client_endpointMethods, "f").plugins.retrieve({
73
+ ...args,
74
+ // Plugin IDs can be tag IDs containing URL delimiters, not just UUIDs.
75
+ id: encodeURIComponent(args.id),
76
+ }),
133
77
  };
78
+ this.skills = __classPrivateFieldGet(this, _Client_endpointMethods, "f").skills;
79
+ this.agents = __classPrivateFieldGet(this, _Client_endpointMethods, "f").agents;
134
80
  this.sessions = {
135
81
  /**
136
82
  * Retrieve a session
137
83
  */
138
- retrieve: (args) => {
139
- this.warnUnknownParams(args, api_endpoints_1.retrieveSession);
140
- return this.request({
141
- path: api_endpoints_1.retrieveSession.path(args),
142
- method: api_endpoints_1.retrieveSession.method,
143
- query: (0, utils_1.pick)(args, api_endpoints_1.retrieveSession.queryParams),
144
- body: (0, utils_1.pick)(args, api_endpoints_1.retrieveSession.bodyParams),
145
- auth: args === null || args === void 0 ? void 0 : args.auth,
146
- });
147
- },
84
+ retrieve: __classPrivateFieldGet(this, _Client_endpointMethods, "f").sessions.retrieve,
148
85
  /**
149
86
  * Update a session
150
87
  */
151
- update: (args) => {
152
- this.warnUnknownParams(args, api_endpoints_1.updateSession);
153
- return this.request({
154
- path: api_endpoints_1.updateSession.path(),
155
- method: api_endpoints_1.updateSession.method,
156
- query: (0, utils_1.pick)(args, api_endpoints_1.updateSession.queryParams),
157
- body: (0, utils_1.pick)(args, api_endpoints_1.updateSession.bodyParams),
158
- auth: args === null || args === void 0 ? void 0 : args.auth,
159
- });
160
- },
88
+ update: __classPrivateFieldGet(this, _Client_endpointMethods, "f").sessions.update,
161
89
  /**
162
90
  * Open a session stream
163
91
  */
@@ -175,140 +103,36 @@ class Client {
175
103
  /**
176
104
  * Cancel a session
177
105
  */
178
- cancel: (args) => {
179
- this.warnUnknownParams(args, api_endpoints_1.cancelSession);
180
- return this.request({
181
- path: api_endpoints_1.cancelSession.path(args),
182
- method: api_endpoints_1.cancelSession.method,
183
- query: (0, utils_1.pick)(args, api_endpoints_1.cancelSession.queryParams),
184
- body: (0, utils_1.pick)(args, api_endpoints_1.cancelSession.bodyParams),
185
- auth: args === null || args === void 0 ? void 0 : args.auth,
186
- });
187
- },
106
+ cancel: __classPrivateFieldGet(this, _Client_endpointMethods, "f").sessions.cancel,
188
107
  /**
189
108
  * Query sessions
190
109
  */
191
- query: (args) => {
192
- this.warnUnknownParams(args, api_endpoints_1.querySessions);
193
- return this.request({
194
- path: api_endpoints_1.querySessions.path(),
195
- method: api_endpoints_1.querySessions.method,
196
- query: (0, utils_1.pick)(args, api_endpoints_1.querySessions.queryParams),
197
- body: (0, utils_1.pick)(args, api_endpoints_1.querySessions.bodyParams),
198
- auth: args === null || args === void 0 ? void 0 : args.auth,
199
- });
200
- },
110
+ query: __classPrivateFieldGet(this, _Client_endpointMethods, "f").sessions.query,
201
111
  /**
202
112
  * Query session events
203
113
  */
204
- queryEvents: (args) => {
205
- this.warnUnknownParams(args, api_endpoints_1.querySessionEvents);
206
- return this.request({
207
- path: api_endpoints_1.querySessionEvents.path(args),
208
- method: api_endpoints_1.querySessionEvents.method,
209
- query: (0, utils_1.pick)(args, api_endpoints_1.querySessionEvents.queryParams),
210
- body: (0, utils_1.pick)(args, api_endpoints_1.querySessionEvents.bodyParams),
211
- auth: args === null || args === void 0 ? void 0 : args.auth,
212
- });
213
- },
214
- };
215
- this.asyncTasks = {
216
- /**
217
- * Retrieve an async task
218
- */
219
- retrieve: (args) => {
220
- this.warnUnknownParams(args, api_endpoints_1.getAsyncTask);
221
- return this.request({
222
- path: api_endpoints_1.getAsyncTask.path(args),
223
- method: api_endpoints_1.getAsyncTask.method,
224
- query: (0, utils_1.pick)(args, api_endpoints_1.getAsyncTask.queryParams),
225
- body: (0, utils_1.pick)(args, api_endpoints_1.getAsyncTask.bodyParams),
226
- auth: args === null || args === void 0 ? void 0 : args.auth,
227
- });
228
- },
114
+ queryEvents: __classPrivateFieldGet(this, _Client_endpointMethods, "f").sessions.queryEvents,
229
115
  };
116
+ this.asyncTasks = __classPrivateFieldGet(this, _Client_endpointMethods, "f").asyncTasks;
230
117
  this.blocks = {
231
118
  /**
232
119
  * Retrieve block
233
120
  */
234
- retrieve: (args) => {
235
- this.warnUnknownParams(args, api_endpoints_1.getBlock);
236
- return this.request({
237
- path: api_endpoints_1.getBlock.path(args),
238
- method: api_endpoints_1.getBlock.method,
239
- query: (0, utils_1.pick)(args, api_endpoints_1.getBlock.queryParams),
240
- body: (0, utils_1.pick)(args, api_endpoints_1.getBlock.bodyParams),
241
- auth: args === null || args === void 0 ? void 0 : args.auth,
242
- });
243
- },
121
+ retrieve: __classPrivateFieldGet(this, _Client_endpointMethods, "f").blocks.retrieve,
244
122
  /**
245
123
  * Update block
246
124
  */
247
- update: (args) => {
248
- this.warnUnknownParams(args, api_endpoints_1.updateBlock);
249
- return this.request({
250
- path: api_endpoints_1.updateBlock.path(args),
251
- method: api_endpoints_1.updateBlock.method,
252
- query: (0, utils_1.pick)(args, api_endpoints_1.updateBlock.queryParams),
253
- body: (0, utils_1.pick)(args, api_endpoints_1.updateBlock.bodyParams),
254
- auth: args === null || args === void 0 ? void 0 : args.auth,
255
- });
256
- },
125
+ update: __classPrivateFieldGet(this, _Client_endpointMethods, "f").blocks.update,
257
126
  /**
258
127
  * Delete block
259
128
  */
260
- delete: (args) => {
261
- this.warnUnknownParams(args, api_endpoints_1.deleteBlock);
262
- return this.request({
263
- path: api_endpoints_1.deleteBlock.path(args),
264
- method: api_endpoints_1.deleteBlock.method,
265
- query: (0, utils_1.pick)(args, api_endpoints_1.deleteBlock.queryParams),
266
- body: (0, utils_1.pick)(args, api_endpoints_1.deleteBlock.bodyParams),
267
- auth: args === null || args === void 0 ? void 0 : args.auth,
268
- });
269
- },
270
- children: {
271
- /**
272
- * Append block children
273
- */
274
- append: (args) => {
275
- this.warnUnknownParams(args, api_endpoints_1.appendBlockChildren);
276
- return this.request({
277
- path: api_endpoints_1.appendBlockChildren.path(args),
278
- method: api_endpoints_1.appendBlockChildren.method,
279
- query: (0, utils_1.pick)(args, api_endpoints_1.appendBlockChildren.queryParams),
280
- body: (0, utils_1.pick)(args, api_endpoints_1.appendBlockChildren.bodyParams),
281
- auth: args === null || args === void 0 ? void 0 : args.auth,
282
- });
283
- },
284
- /**
285
- * Retrieve block children
286
- */
287
- list: (args) => {
288
- this.warnUnknownParams(args, api_endpoints_1.listBlockChildren);
289
- return this.request({
290
- path: api_endpoints_1.listBlockChildren.path(args),
291
- method: api_endpoints_1.listBlockChildren.method,
292
- query: (0, utils_1.pick)(args, api_endpoints_1.listBlockChildren.queryParams),
293
- body: (0, utils_1.pick)(args, api_endpoints_1.listBlockChildren.bodyParams),
294
- auth: args === null || args === void 0 ? void 0 : args.auth,
295
- });
296
- },
297
- },
129
+ delete: __classPrivateFieldGet(this, _Client_endpointMethods, "f").blocks.delete,
130
+ children: __classPrivateFieldGet(this, _Client_endpointMethods, "f").blocks.children,
298
131
  meetingNotes: {
299
132
  /**
300
133
  * Create a meeting note
301
134
  */
302
- create: (args) => {
303
- this.warnUnknownParams(args, meeting_notes_1.createMeetingNote);
304
- return this.request({
305
- path: meeting_notes_1.createMeetingNote.path(),
306
- method: meeting_notes_1.createMeetingNote.method,
307
- query: (0, utils_1.pick)(args, meeting_notes_1.createMeetingNote.queryParams),
308
- body: (0, utils_1.pick)(args, meeting_notes_1.createMeetingNote.bodyParams),
309
- auth: args === null || args === void 0 ? void 0 : args.auth,
310
- });
311
- },
135
+ create: __classPrivateFieldGet(this, _Client_endpointMethods, "f").blocks.meetingNotes.create,
312
136
  /**
313
137
  * Query meeting notes
314
138
  */
@@ -323,167 +147,25 @@ class Client {
323
147
  },
324
148
  },
325
149
  };
326
- this.databases = {
327
- /**
328
- * Retrieve a database
329
- */
330
- retrieve: (args) => {
331
- this.warnUnknownParams(args, api_endpoints_1.getDatabase);
332
- return this.request({
333
- path: api_endpoints_1.getDatabase.path(args),
334
- method: api_endpoints_1.getDatabase.method,
335
- query: (0, utils_1.pick)(args, api_endpoints_1.getDatabase.queryParams),
336
- body: (0, utils_1.pick)(args, api_endpoints_1.getDatabase.bodyParams),
337
- auth: args === null || args === void 0 ? void 0 : args.auth,
338
- });
339
- },
340
- /**
341
- * Create a database
342
- */
343
- create: (args) => {
344
- this.warnUnknownParams(args, api_endpoints_1.createDatabase);
345
- return this.request({
346
- path: api_endpoints_1.createDatabase.path(),
347
- method: api_endpoints_1.createDatabase.method,
348
- query: (0, utils_1.pick)(args, api_endpoints_1.createDatabase.queryParams),
349
- body: (0, utils_1.pick)(args, api_endpoints_1.createDatabase.bodyParams),
350
- auth: args === null || args === void 0 ? void 0 : args.auth,
351
- });
352
- },
353
- /**
354
- * Update a database
355
- */
356
- update: (args) => {
357
- this.warnUnknownParams(args, api_endpoints_1.updateDatabase);
358
- return this.request({
359
- path: api_endpoints_1.updateDatabase.path(args),
360
- method: api_endpoints_1.updateDatabase.method,
361
- query: (0, utils_1.pick)(args, api_endpoints_1.updateDatabase.queryParams),
362
- body: (0, utils_1.pick)(args, api_endpoints_1.updateDatabase.bodyParams),
363
- auth: args === null || args === void 0 ? void 0 : args.auth,
364
- });
365
- },
366
- };
367
- this.dataSources = {
368
- /**
369
- * Retrieve a data source
370
- */
371
- retrieve: (args) => {
372
- this.warnUnknownParams(args, api_endpoints_1.getDataSource);
373
- return this.request({
374
- path: api_endpoints_1.getDataSource.path(args),
375
- method: api_endpoints_1.getDataSource.method,
376
- query: (0, utils_1.pick)(args, api_endpoints_1.getDataSource.queryParams),
377
- body: (0, utils_1.pick)(args, api_endpoints_1.getDataSource.bodyParams),
378
- auth: args === null || args === void 0 ? void 0 : args.auth,
379
- });
380
- },
381
- /**
382
- * Query a data source
383
- */
384
- query: (args) => {
385
- this.warnUnknownParams(args, api_endpoints_1.queryDataSource);
386
- return this.request({
387
- path: api_endpoints_1.queryDataSource.path(args),
388
- method: api_endpoints_1.queryDataSource.method,
389
- query: (0, utils_1.pick)(args, api_endpoints_1.queryDataSource.queryParams),
390
- body: (0, utils_1.pick)(args, api_endpoints_1.queryDataSource.bodyParams),
391
- auth: args === null || args === void 0 ? void 0 : args.auth,
392
- });
393
- },
394
- /**
395
- * Create a data source
396
- */
397
- create: (args) => {
398
- this.warnUnknownParams(args, api_endpoints_1.createDataSource);
399
- return this.request({
400
- path: api_endpoints_1.createDataSource.path(),
401
- method: api_endpoints_1.createDataSource.method,
402
- query: (0, utils_1.pick)(args, api_endpoints_1.createDataSource.queryParams),
403
- body: (0, utils_1.pick)(args, api_endpoints_1.createDataSource.bodyParams),
404
- auth: args === null || args === void 0 ? void 0 : args.auth,
405
- });
406
- },
407
- /**
408
- * Update a data source
409
- */
410
- update: (args) => {
411
- this.warnUnknownParams(args, api_endpoints_1.updateDataSource);
412
- return this.request({
413
- path: api_endpoints_1.updateDataSource.path(args),
414
- method: api_endpoints_1.updateDataSource.method,
415
- query: (0, utils_1.pick)(args, api_endpoints_1.updateDataSource.queryParams),
416
- body: (0, utils_1.pick)(args, api_endpoints_1.updateDataSource.bodyParams),
417
- auth: args === null || args === void 0 ? void 0 : args.auth,
418
- });
419
- },
420
- /**
421
- * List page templates that are available for a data source
422
- */
423
- listTemplates: (args) => {
424
- this.warnUnknownParams(args, api_endpoints_1.listDataSourceTemplates);
425
- return this.request({
426
- path: api_endpoints_1.listDataSourceTemplates.path(args),
427
- method: api_endpoints_1.listDataSourceTemplates.method,
428
- query: (0, utils_1.pick)(args, api_endpoints_1.listDataSourceTemplates.queryParams),
429
- body: (0, utils_1.pick)(args, api_endpoints_1.listDataSourceTemplates.bodyParams),
430
- auth: args === null || args === void 0 ? void 0 : args.auth,
431
- });
432
- },
433
- };
150
+ this.databases = __classPrivateFieldGet(this, _Client_endpointMethods, "f").databases;
151
+ this.dataSources = __classPrivateFieldGet(this, _Client_endpointMethods, "f").dataSources;
434
152
  this.pages = {
435
153
  /**
436
154
  * Create a page
437
155
  */
438
- create: (args) => {
439
- this.warnUnknownParams(args, api_endpoints_1.createPage);
440
- return this.request({
441
- path: api_endpoints_1.createPage.path(),
442
- method: api_endpoints_1.createPage.method,
443
- query: (0, utils_1.pick)(args, api_endpoints_1.createPage.queryParams),
444
- body: (0, utils_1.pick)(args, api_endpoints_1.createPage.bodyParams),
445
- auth: args === null || args === void 0 ? void 0 : args.auth,
446
- });
447
- },
156
+ create: __classPrivateFieldGet(this, _Client_endpointMethods, "f").pages.create,
448
157
  /**
449
158
  * Retrieve a page
450
159
  */
451
- retrieve: (args) => {
452
- this.warnUnknownParams(args, api_endpoints_1.getPage);
453
- return this.request({
454
- path: api_endpoints_1.getPage.path(args),
455
- method: api_endpoints_1.getPage.method,
456
- query: (0, utils_1.pick)(args, api_endpoints_1.getPage.queryParams),
457
- body: (0, utils_1.pick)(args, api_endpoints_1.getPage.bodyParams),
458
- auth: args === null || args === void 0 ? void 0 : args.auth,
459
- });
460
- },
160
+ retrieve: __classPrivateFieldGet(this, _Client_endpointMethods, "f").pages.retrieve,
461
161
  /**
462
162
  * Update page properties
463
163
  */
464
- update: (args) => {
465
- this.warnUnknownParams(args, api_endpoints_1.updatePage);
466
- return this.request({
467
- path: api_endpoints_1.updatePage.path(args),
468
- method: api_endpoints_1.updatePage.method,
469
- query: (0, utils_1.pick)(args, api_endpoints_1.updatePage.queryParams),
470
- body: (0, utils_1.pick)(args, api_endpoints_1.updatePage.bodyParams),
471
- auth: args === null || args === void 0 ? void 0 : args.auth,
472
- });
473
- },
164
+ update: __classPrivateFieldGet(this, _Client_endpointMethods, "f").pages.update,
474
165
  /**
475
166
  * Move a page
476
167
  */
477
- move: (args) => {
478
- this.warnUnknownParams(args, api_endpoints_1.movePage);
479
- return this.request({
480
- path: api_endpoints_1.movePage.path(args),
481
- method: api_endpoints_1.movePage.method,
482
- query: (0, utils_1.pick)(args, api_endpoints_1.movePage.queryParams),
483
- body: (0, utils_1.pick)(args, api_endpoints_1.movePage.bodyParams),
484
- auth: args === null || args === void 0 ? void 0 : args.auth,
485
- });
486
- },
168
+ move: __classPrivateFieldGet(this, _Client_endpointMethods, "f").pages.move,
487
169
  /**
488
170
  * Retrieve a page as markdown
489
171
  */
@@ -508,63 +190,9 @@ class Client {
508
190
  auth: args === null || args === void 0 ? void 0 : args.auth,
509
191
  });
510
192
  },
511
- properties: {
512
- /**
513
- * Retrieve page property
514
- */
515
- retrieve: (args) => {
516
- this.warnUnknownParams(args, api_endpoints_1.getPageProperty);
517
- return this.request({
518
- path: api_endpoints_1.getPageProperty.path(args),
519
- method: api_endpoints_1.getPageProperty.method,
520
- query: (0, utils_1.pick)(args, api_endpoints_1.getPageProperty.queryParams),
521
- body: (0, utils_1.pick)(args, api_endpoints_1.getPageProperty.bodyParams),
522
- auth: args === null || args === void 0 ? void 0 : args.auth,
523
- });
524
- },
525
- },
526
- };
527
- this.users = {
528
- /**
529
- * Retrieve a user
530
- */
531
- retrieve: (args) => {
532
- this.warnUnknownParams(args, api_endpoints_1.getUser);
533
- return this.request({
534
- path: api_endpoints_1.getUser.path(args),
535
- method: api_endpoints_1.getUser.method,
536
- query: (0, utils_1.pick)(args, api_endpoints_1.getUser.queryParams),
537
- body: (0, utils_1.pick)(args, api_endpoints_1.getUser.bodyParams),
538
- auth: args === null || args === void 0 ? void 0 : args.auth,
539
- });
540
- },
541
- /**
542
- * List all users
543
- */
544
- list: (args) => {
545
- this.warnUnknownParams(args, api_endpoints_1.listUsers);
546
- return this.request({
547
- path: api_endpoints_1.listUsers.path(),
548
- method: api_endpoints_1.listUsers.method,
549
- query: (0, utils_1.pick)(args, api_endpoints_1.listUsers.queryParams),
550
- body: (0, utils_1.pick)(args, api_endpoints_1.listUsers.bodyParams),
551
- auth: args === null || args === void 0 ? void 0 : args.auth,
552
- });
553
- },
554
- /**
555
- * Get details about bot
556
- */
557
- me: (args) => {
558
- this.warnUnknownParams(args, api_endpoints_1.getSelf);
559
- return this.request({
560
- path: api_endpoints_1.getSelf.path(),
561
- method: api_endpoints_1.getSelf.method,
562
- query: (0, utils_1.pick)(args, api_endpoints_1.getSelf.queryParams),
563
- body: (0, utils_1.pick)(args, api_endpoints_1.getSelf.bodyParams),
564
- auth: args === null || args === void 0 ? void 0 : args.auth,
565
- });
566
- },
193
+ properties: __classPrivateFieldGet(this, _Client_endpointMethods, "f").pages.properties,
567
194
  };
195
+ this.users = __classPrivateFieldGet(this, _Client_endpointMethods, "f").users;
568
196
  this.customEmojis = {
569
197
  /**
570
198
  * List custom emojis
@@ -580,87 +208,12 @@ class Client {
580
208
  });
581
209
  },
582
210
  };
583
- this.comments = {
584
- /**
585
- * Create a comment
586
- */
587
- create: (args) => {
588
- this.warnUnknownParams(args, api_endpoints_1.createComment);
589
- return this.request({
590
- path: api_endpoints_1.createComment.path(),
591
- method: api_endpoints_1.createComment.method,
592
- query: (0, utils_1.pick)(args, api_endpoints_1.createComment.queryParams),
593
- body: (0, utils_1.pick)(args, api_endpoints_1.createComment.bodyParams),
594
- auth: args === null || args === void 0 ? void 0 : args.auth,
595
- });
596
- },
597
- /**
598
- * List comments
599
- */
600
- list: (args) => {
601
- this.warnUnknownParams(args, api_endpoints_1.listComments);
602
- return this.request({
603
- path: api_endpoints_1.listComments.path(),
604
- method: api_endpoints_1.listComments.method,
605
- query: (0, utils_1.pick)(args, api_endpoints_1.listComments.queryParams),
606
- body: (0, utils_1.pick)(args, api_endpoints_1.listComments.bodyParams),
607
- auth: args === null || args === void 0 ? void 0 : args.auth,
608
- });
609
- },
610
- /**
611
- * Retrieve a comment
612
- */
613
- retrieve: (args) => {
614
- this.warnUnknownParams(args, api_endpoints_1.getComment);
615
- return this.request({
616
- path: api_endpoints_1.getComment.path(args),
617
- method: api_endpoints_1.getComment.method,
618
- query: (0, utils_1.pick)(args, api_endpoints_1.getComment.queryParams),
619
- body: (0, utils_1.pick)(args, api_endpoints_1.getComment.bodyParams),
620
- auth: args === null || args === void 0 ? void 0 : args.auth,
621
- });
622
- },
623
- /**
624
- * Update a comment
625
- */
626
- update: (args) => {
627
- this.warnUnknownParams(args, api_endpoints_1.updateComment);
628
- return this.request({
629
- path: api_endpoints_1.updateComment.path(args),
630
- method: api_endpoints_1.updateComment.method,
631
- query: (0, utils_1.pick)(args, api_endpoints_1.updateComment.queryParams),
632
- body: (0, utils_1.pick)(args, api_endpoints_1.updateComment.bodyParams),
633
- auth: args === null || args === void 0 ? void 0 : args.auth,
634
- });
635
- },
636
- /**
637
- * Delete a comment
638
- */
639
- delete: (args) => {
640
- this.warnUnknownParams(args, api_endpoints_1.deleteComment);
641
- return this.request({
642
- path: api_endpoints_1.deleteComment.path(args),
643
- method: api_endpoints_1.deleteComment.method,
644
- query: (0, utils_1.pick)(args, api_endpoints_1.deleteComment.queryParams),
645
- body: (0, utils_1.pick)(args, api_endpoints_1.deleteComment.bodyParams),
646
- auth: args === null || args === void 0 ? void 0 : args.auth,
647
- });
648
- },
649
- };
211
+ this.comments = __classPrivateFieldGet(this, _Client_endpointMethods, "f").comments;
650
212
  this.fileUploads = {
651
213
  /**
652
214
  * Create a file upload
653
215
  */
654
- create: (args) => {
655
- this.warnUnknownParams(args, api_endpoints_1.createFileUpload);
656
- return this.request({
657
- path: api_endpoints_1.createFileUpload.path(),
658
- method: api_endpoints_1.createFileUpload.method,
659
- query: (0, utils_1.pick)(args, api_endpoints_1.createFileUpload.queryParams),
660
- body: (0, utils_1.pick)(args, api_endpoints_1.createFileUpload.bodyParams),
661
- auth: args === null || args === void 0 ? void 0 : args.auth,
662
- });
663
- },
216
+ create: __classPrivateFieldGet(this, _Client_endpointMethods, "f").fileUploads.create,
664
217
  /**
665
218
  * Retrieve a file upload
666
219
  */
@@ -751,16 +304,7 @@ class Client {
751
304
  /**
752
305
  * Retrieve a view
753
306
  */
754
- retrieve: (args) => {
755
- this.warnUnknownParams(args, api_endpoints_1.getView);
756
- return this.request({
757
- path: api_endpoints_1.getView.path(args),
758
- method: api_endpoints_1.getView.method,
759
- query: (0, utils_1.pick)(args, api_endpoints_1.getView.queryParams),
760
- body: (0, utils_1.pick)(args, api_endpoints_1.getView.bodyParams),
761
- auth: args === null || args === void 0 ? void 0 : args.auth,
762
- });
763
- },
307
+ retrieve: __classPrivateFieldGet(this, _Client_endpointMethods, "f").views.retrieve,
764
308
  /**
765
309
  * Update a view
766
310
  */
@@ -782,29 +326,11 @@ class Client {
782
326
  /**
783
327
  * Delete a view
784
328
  */
785
- delete: (args) => {
786
- this.warnUnknownParams(args, api_endpoints_1.deleteView);
787
- return this.request({
788
- path: api_endpoints_1.deleteView.path(args),
789
- method: api_endpoints_1.deleteView.method,
790
- query: (0, utils_1.pick)(args, api_endpoints_1.deleteView.queryParams),
791
- body: (0, utils_1.pick)(args, api_endpoints_1.deleteView.bodyParams),
792
- auth: args === null || args === void 0 ? void 0 : args.auth,
793
- });
794
- },
329
+ delete: __classPrivateFieldGet(this, _Client_endpointMethods, "f").views.delete,
795
330
  /**
796
331
  * List views for a database
797
332
  */
798
- list: (args) => {
799
- this.warnUnknownParams(args, api_endpoints_1.listDatabaseViews);
800
- return this.request({
801
- path: api_endpoints_1.listDatabaseViews.path(),
802
- method: api_endpoints_1.listDatabaseViews.method,
803
- query: (0, utils_1.pick)(args, api_endpoints_1.listDatabaseViews.queryParams),
804
- body: (0, utils_1.pick)(args, api_endpoints_1.listDatabaseViews.bodyParams),
805
- auth: args === null || args === void 0 ? void 0 : args.auth,
806
- });
807
- },
333
+ list: __classPrivateFieldGet(this, _Client_endpointMethods, "f").views.list,
808
334
  queries: {
809
335
  /**
810
336
  * Create a view query
@@ -821,44 +347,17 @@ class Client {
821
347
  /**
822
348
  * Get view query results
823
349
  */
824
- results: (args) => {
825
- this.warnUnknownParams(args, api_endpoints_1.getViewQueryResults);
826
- return this.request({
827
- path: api_endpoints_1.getViewQueryResults.path(args),
828
- method: api_endpoints_1.getViewQueryResults.method,
829
- query: (0, utils_1.pick)(args, api_endpoints_1.getViewQueryResults.queryParams),
830
- body: (0, utils_1.pick)(args, api_endpoints_1.getViewQueryResults.bodyParams),
831
- auth: args === null || args === void 0 ? void 0 : args.auth,
832
- });
833
- },
350
+ results: __classPrivateFieldGet(this, _Client_endpointMethods, "f").views.queries.results,
834
351
  /**
835
352
  * Delete a view query
836
353
  */
837
- delete: (args) => {
838
- this.warnUnknownParams(args, api_endpoints_1.deleteViewQuery);
839
- return this.request({
840
- path: api_endpoints_1.deleteViewQuery.path(args),
841
- method: api_endpoints_1.deleteViewQuery.method,
842
- query: (0, utils_1.pick)(args, api_endpoints_1.deleteViewQuery.queryParams),
843
- body: (0, utils_1.pick)(args, api_endpoints_1.deleteViewQuery.bodyParams),
844
- auth: args === null || args === void 0 ? void 0 : args.auth,
845
- });
846
- },
354
+ delete: __classPrivateFieldGet(this, _Client_endpointMethods, "f").views.queries.delete,
847
355
  },
848
356
  };
849
357
  /**
850
358
  * Search
851
359
  */
852
- this.search = (args) => {
853
- this.warnUnknownParams(args, api_endpoints_1.search);
854
- return this.request({
855
- path: api_endpoints_1.search.path(),
856
- method: api_endpoints_1.search.method,
857
- query: (0, utils_1.pick)(args, api_endpoints_1.search.queryParams),
858
- body: (0, utils_1.pick)(args, api_endpoints_1.search.bodyParams),
859
- auth: args === null || args === void 0 ? void 0 : args.auth,
860
- });
861
- };
360
+ this.search = __classPrivateFieldGet(this, _Client_endpointMethods, "f").search;
862
361
  this.oauth = {
863
362
  /**
864
363
  * Get token
@@ -925,6 +424,10 @@ class Client {
925
424
  __classPrivateFieldSet(this, _Client_initialRetryDelayMs, (_k = (_j = options === null || options === void 0 ? void 0 : options.retry) === null || _j === void 0 ? void 0 : _j.initialRetryDelayMs) !== null && _k !== void 0 ? _k : constants_1.DEFAULT_INITIAL_RETRY_DELAY_MS, "f");
926
425
  __classPrivateFieldSet(this, _Client_maxRetryDelayMs, (_m = (_l = options === null || options === void 0 ? void 0 : options.retry) === null || _l === void 0 ? void 0 : _l.maxRetryDelayMs) !== null && _m !== void 0 ? _m : constants_1.DEFAULT_MAX_RETRY_DELAY_MS, "f");
927
426
  }
427
+ __classPrivateFieldSet(this, _Client_dangerouslyAllowBrowser, (_o = options === null || options === void 0 ? void 0 : options.dangerouslyAllowBrowser) !== null && _o !== void 0 ? _o : false, "f");
428
+ if ((options === null || options === void 0 ? void 0 : options.auth) !== undefined) {
429
+ this.assertTokenAllowedHere();
430
+ }
928
431
  }
929
432
  /**
930
433
  * Sends a request.
@@ -1064,8 +567,12 @@ class Client {
1064
567
  ...customHeaders,
1065
568
  ...authorizationHeader,
1066
569
  "Notion-Version": __classPrivateFieldGet(this, _Client_notionVersion, "f"),
1067
- "user-agent": __classPrivateFieldGet(this, _Client_userAgent, "f"),
1068
570
  };
571
+ // Firefox and Safari send a custom user-agent, so the CORS preflight asks
572
+ // for it, and a proxy set as `baseUrl` may not allow it.
573
+ if (!isBrowserEnvironment()) {
574
+ headers["user-agent"] = __classPrivateFieldGet(this, _Client_userAgent, "f");
575
+ }
1069
576
  if (bodyAsJsonString !== undefined) {
1070
577
  headers["content-type"] = "application/json";
1071
578
  }
@@ -1075,6 +582,9 @@ class Client {
1075
582
  * Builds the authorization header based on auth type.
1076
583
  */
1077
584
  buildAuthHeader(auth) {
585
+ if (auth !== undefined) {
586
+ this.assertTokenAllowedHere();
587
+ }
1078
588
  if (typeof auth === "object") {
1079
589
  const unencodedCredential = `${auth.client_id}:${auth.client_secret}`;
1080
590
  const encodedCredential = Buffer.from(unencodedCredential).toString("base64");
@@ -1285,8 +795,9 @@ class Client {
1285
795
  */
1286
796
  warnUnknownParams(args, endpoint) {
1287
797
  var _a;
1288
- if (!args || typeof args !== "object")
798
+ if (!args || typeof args !== "object") {
1289
799
  return;
800
+ }
1290
801
  const unknownKeys = (0, utils_1.getUnknownParams)(args, endpoint);
1291
802
  if (unknownKeys.length > 0) {
1292
803
  this.log(logging_1.LogLevel.WARN, "unknown parameters were ignored", {
@@ -1311,6 +822,19 @@ class Client {
1311
822
  __classPrivateFieldGet(this, _Client_logger, "f").call(this, level, message, extraInfo);
1312
823
  }
1313
824
  }
825
+ /**
826
+ * Blocks a token or client secret inside a browser unless the caller opted
827
+ * in. Covers both the constructor `auth` and per-request `auth`, since a
828
+ * page that asks the visitor to type a token usually uses the latter. A
829
+ * client without a token stays usable, for example behind a proxy that
830
+ * adds the token on a server.
831
+ */
832
+ assertTokenAllowedHere() {
833
+ if (__classPrivateFieldGet(this, _Client_dangerouslyAllowBrowser, "f") || !isBrowserEnvironment()) {
834
+ return;
835
+ }
836
+ throw new errors_1.BrowserTokenNotAllowedError();
837
+ }
1314
838
  /**
1315
839
  * Transforms an API key or access token into a headers object suitable for an HTTP request.
1316
840
  *
@@ -1329,7 +853,7 @@ class Client {
1329
853
  return headers;
1330
854
  }
1331
855
  }
1332
- _Client_auth = new WeakMap(), _Client_logLevel = new WeakMap(), _Client_logger = new WeakMap(), _Client_prefixUrl = new WeakMap(), _Client_timeoutMs = new WeakMap(), _Client_notionVersion = new WeakMap(), _Client_fetch = new WeakMap(), _Client_agent = new WeakMap(), _Client_userAgent = new WeakMap(), _Client_maxRetries = new WeakMap(), _Client_initialRetryDelayMs = new WeakMap(), _Client_maxRetryDelayMs = new WeakMap();
856
+ _Client_endpointMethods = new WeakMap(), _Client_auth = new WeakMap(), _Client_logLevel = new WeakMap(), _Client_logger = new WeakMap(), _Client_prefixUrl = new WeakMap(), _Client_timeoutMs = new WeakMap(), _Client_notionVersion = new WeakMap(), _Client_fetch = new WeakMap(), _Client_agent = new WeakMap(), _Client_userAgent = new WeakMap(), _Client_maxRetries = new WeakMap(), _Client_initialRetryDelayMs = new WeakMap(), _Client_maxRetryDelayMs = new WeakMap(), _Client_dangerouslyAllowBrowser = new WeakMap();
1333
857
  Client.defaultNotionVersion = "2025-09-03";
1334
858
  exports.default = Client;
1335
859
  const sessionStreamEventTypes = new Set([