safe-notion 0.1.2 → 0.1.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -28,7 +28,7 @@ export NOTION_TOKEN="your-notion-integration-token"
28
28
  設定ファイルを初期化:
29
29
 
30
30
  ```bash
31
- notion-safe config init
31
+ safe-notion config init
32
32
  ```
33
33
 
34
34
  設定ファイルの場所: `~/.config/safe-notion/config.jsonc`
@@ -85,34 +85,34 @@ notion-safe config init
85
85
  ### ページ操作
86
86
 
87
87
  ```bash
88
- notion-safe page get <page-id>
89
- notion-safe page create --parent <parent-id> --title "タイトル"
90
- notion-safe page update <page-id>
88
+ safe-notion page get <page-id>
89
+ safe-notion page create --parent <parent-id> --title "タイトル"
90
+ safe-notion page update <page-id>
91
91
  ```
92
92
 
93
93
  ### データベース操作
94
94
 
95
95
  ```bash
96
- notion-safe db get <database-id>
97
- notion-safe db query <database-id>
98
- notion-safe db create-page <database-id>
96
+ safe-notion db get <database-id>
97
+ safe-notion db query <database-id>
98
+ safe-notion db create-page <database-id>
99
99
  ```
100
100
 
101
101
  ### ブロック操作
102
102
 
103
103
  ```bash
104
- notion-safe block get <block-id>
105
- notion-safe block children <block-id>
106
- notion-safe block append <block-id> --children '<json>'
107
- notion-safe block delete <block-id>
104
+ safe-notion block get <block-id>
105
+ safe-notion block children <block-id>
106
+ safe-notion block append <block-id> --children '<json>'
107
+ safe-notion block delete <block-id>
108
108
  ```
109
109
 
110
110
  ### 設定管理
111
111
 
112
112
  ```bash
113
- notion-safe config init # 設定ファイルを初期化
114
- notion-safe config validate # 設定を検証
115
- notion-safe config path # 設定ファイルのパスを表示
113
+ safe-notion config init # 設定ファイルを初期化
114
+ safe-notion config validate # 設定を検証
115
+ safe-notion config path # 設定ファイルのパスを表示
116
116
  ```
117
117
 
118
118
  ## 開発
package/dist/index.js CHANGED
@@ -9,6 +9,7 @@ import { Command } from "commander";
9
9
 
10
10
  // src/notion-client.ts
11
11
  import { Client } from "@notionhq/client";
12
+ import { LogLevel } from "@notionhq/client/build/src/logging";
12
13
 
13
14
  // src/config.ts
14
15
  import { readFileSync, existsSync, mkdirSync, writeFileSync } from "node:fs";
@@ -356,12 +357,16 @@ function clearCache() {
356
357
  }
357
358
 
358
359
  // src/notion-client.ts
360
+ var debugMode = false;
359
361
  class NotionSafeClient {
360
362
  client;
361
363
  config;
362
364
  constructor() {
363
365
  const token = getNotionToken();
364
- this.client = new Client({ auth: token });
366
+ this.client = new Client({
367
+ auth: token,
368
+ logLevel: debugMode ? LogLevel.WARN : LogLevel.ERROR
369
+ });
365
370
  this.config = loadConfig();
366
371
  }
367
372
  async ensurePermission(resourceId, operation, pageIdForCondition) {
@@ -400,8 +405,18 @@ class NotionSafeClient {
400
405
  }
401
406
  async queryDatabase(databaseId, params) {
402
407
  await this.ensurePermission(databaseId, "database:query");
403
- return this.client.databases.query({
404
- database_id: databaseId,
408
+ const database = await this.client.databases.retrieve({
409
+ database_id: databaseId
410
+ });
411
+ const dataSourceId = database.data_sources?.[0]?.id;
412
+ if (!dataSourceId) {
413
+ throw {
414
+ error: "Database has no data source",
415
+ code: "NO_DATA_SOURCE"
416
+ };
417
+ }
418
+ return this.client.dataSources.query({
419
+ data_source_id: dataSourceId,
405
420
  ...params
406
421
  });
407
422
  }
@@ -680,9 +695,24 @@ function createConfigCommand() {
680
695
  return config;
681
696
  }
682
697
 
698
+ // src/notion-client.ts
699
+ import { Client as Client2 } from "@notionhq/client";
700
+ import { LogLevel as LogLevel2 } from "@notionhq/client/build/src/logging";
701
+ var debugMode2 = false;
702
+ function setDebugMode(enabled) {
703
+ debugMode2 = enabled;
704
+ clientInstance2 = null;
705
+ }
706
+ var clientInstance2 = null;
707
+
683
708
  // src/index.ts
684
709
  var program = new Command5;
685
- program.name("notion-safe").description("A safe Notion API wrapper CLI for AI agents").version("0.1.0");
710
+ program.name("notion-safe").description("A safe Notion API wrapper CLI for AI agents").version("0.1.0").option("--debug", "Enable debug output including API warnings").hook("preAction", () => {
711
+ const opts = program.opts();
712
+ if (opts.debug) {
713
+ setDebugMode(true);
714
+ }
715
+ });
686
716
  program.addCommand(createPageCommand());
687
717
  program.addCommand(createDbCommand());
688
718
  program.addCommand(createBlockCommand());
@@ -1,4 +1,5 @@
1
1
  import { Client } from "@notionhq/client";
2
+ export declare function setDebugMode(enabled: boolean): void;
2
3
  type CreatePageParams = Parameters<Client["pages"]["create"]>[0];
3
4
  type UpdatePageParams = Parameters<Client["pages"]["update"]>[0];
4
5
  type AppendBlockChildrenParams = Parameters<Client["blocks"]["children"]["append"]>[0];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "safe-notion",
3
- "version": "0.1.2",
3
+ "version": "0.1.4",
4
4
  "description": "A safe Notion API wrapper CLI for AI agents with granular permission control",
5
5
  "license": "MIT",
6
6
  "author": "shoppingjaws",
@@ -27,7 +27,7 @@
27
27
  "module": "dist/index.js",
28
28
  "types": "dist/index.d.ts",
29
29
  "bin": {
30
- "notion-safe": "dist/index.js"
30
+ "safe-notion": "dist/index.js"
31
31
  },
32
32
  "files": [
33
33
  "dist",