@catafal/notion-cli 5.9.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 (162) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +552 -0
  3. package/bin/dev +17 -0
  4. package/bin/dev.cmd +3 -0
  5. package/bin/run +14 -0
  6. package/bin/run.cmd +3 -0
  7. package/dist/base-command.d.ts +73 -0
  8. package/dist/base-command.js +179 -0
  9. package/dist/base-flags.d.ts +14 -0
  10. package/dist/base-flags.js +59 -0
  11. package/dist/cache.d.ts +84 -0
  12. package/dist/cache.js +351 -0
  13. package/dist/commands/append.d.ts +37 -0
  14. package/dist/commands/append.js +120 -0
  15. package/dist/commands/batch/delete.d.ts +42 -0
  16. package/dist/commands/batch/delete.js +199 -0
  17. package/dist/commands/batch/retrieve.d.ts +43 -0
  18. package/dist/commands/batch/retrieve.js +272 -0
  19. package/dist/commands/block/append.d.ts +42 -0
  20. package/dist/commands/block/append.js +219 -0
  21. package/dist/commands/block/delete.d.ts +30 -0
  22. package/dist/commands/block/delete.js +97 -0
  23. package/dist/commands/block/retrieve/children.d.ts +31 -0
  24. package/dist/commands/block/retrieve/children.js +177 -0
  25. package/dist/commands/block/retrieve.d.ts +30 -0
  26. package/dist/commands/block/retrieve.js +101 -0
  27. package/dist/commands/block/update.d.ts +45 -0
  28. package/dist/commands/block/update.js +242 -0
  29. package/dist/commands/bookmark/list.d.ts +30 -0
  30. package/dist/commands/bookmark/list.js +60 -0
  31. package/dist/commands/bookmark/remove.d.ts +26 -0
  32. package/dist/commands/bookmark/remove.js +47 -0
  33. package/dist/commands/bookmark/set.d.ts +29 -0
  34. package/dist/commands/bookmark/set.js +96 -0
  35. package/dist/commands/browse.d.ts +13 -0
  36. package/dist/commands/browse.js +44 -0
  37. package/dist/commands/cache/info.d.ts +19 -0
  38. package/dist/commands/cache/info.js +145 -0
  39. package/dist/commands/config/set-token.d.ts +22 -0
  40. package/dist/commands/config/set-token.js +137 -0
  41. package/dist/commands/daily/index.d.ts +32 -0
  42. package/dist/commands/daily/index.js +135 -0
  43. package/dist/commands/daily/setup.d.ts +42 -0
  44. package/dist/commands/daily/setup.js +149 -0
  45. package/dist/commands/db/create.d.ts +31 -0
  46. package/dist/commands/db/create.js +124 -0
  47. package/dist/commands/db/query.d.ts +41 -0
  48. package/dist/commands/db/query.js +360 -0
  49. package/dist/commands/db/retrieve.d.ts +33 -0
  50. package/dist/commands/db/retrieve.js +134 -0
  51. package/dist/commands/db/schema.d.ts +32 -0
  52. package/dist/commands/db/schema.js +308 -0
  53. package/dist/commands/db/update.d.ts +31 -0
  54. package/dist/commands/db/update.js +117 -0
  55. package/dist/commands/doctor.d.ts +50 -0
  56. package/dist/commands/doctor.js +420 -0
  57. package/dist/commands/init.d.ts +65 -0
  58. package/dist/commands/init.js +479 -0
  59. package/dist/commands/list.d.ts +29 -0
  60. package/dist/commands/list.js +219 -0
  61. package/dist/commands/open.d.ts +29 -0
  62. package/dist/commands/open.js +100 -0
  63. package/dist/commands/page/create.d.ts +33 -0
  64. package/dist/commands/page/create.js +261 -0
  65. package/dist/commands/page/delete.d.ts +36 -0
  66. package/dist/commands/page/delete.js +107 -0
  67. package/dist/commands/page/export.d.ts +38 -0
  68. package/dist/commands/page/export.js +120 -0
  69. package/dist/commands/page/retrieve/property_item.d.ts +24 -0
  70. package/dist/commands/page/retrieve/property_item.js +75 -0
  71. package/dist/commands/page/retrieve.d.ts +36 -0
  72. package/dist/commands/page/retrieve.js +244 -0
  73. package/dist/commands/page/update.d.ts +34 -0
  74. package/dist/commands/page/update.js +184 -0
  75. package/dist/commands/quick.d.ts +35 -0
  76. package/dist/commands/quick.js +168 -0
  77. package/dist/commands/search.d.ts +43 -0
  78. package/dist/commands/search.js +361 -0
  79. package/dist/commands/stats.d.ts +35 -0
  80. package/dist/commands/stats.js +274 -0
  81. package/dist/commands/sync.d.ts +24 -0
  82. package/dist/commands/sync.js +183 -0
  83. package/dist/commands/template/get.d.ts +28 -0
  84. package/dist/commands/template/get.js +59 -0
  85. package/dist/commands/template/list.d.ts +32 -0
  86. package/dist/commands/template/list.js +62 -0
  87. package/dist/commands/template/remove.d.ts +27 -0
  88. package/dist/commands/template/remove.js +48 -0
  89. package/dist/commands/template/save.d.ts +32 -0
  90. package/dist/commands/template/save.js +92 -0
  91. package/dist/commands/template/use.d.ts +34 -0
  92. package/dist/commands/template/use.js +142 -0
  93. package/dist/commands/user/list.d.ts +27 -0
  94. package/dist/commands/user/list.js +99 -0
  95. package/dist/commands/user/retrieve/bot.d.ts +28 -0
  96. package/dist/commands/user/retrieve/bot.js +96 -0
  97. package/dist/commands/user/retrieve.d.ts +30 -0
  98. package/dist/commands/user/retrieve.js +103 -0
  99. package/dist/commands/whoami.d.ts +19 -0
  100. package/dist/commands/whoami.js +175 -0
  101. package/dist/deduplication.d.ts +41 -0
  102. package/dist/deduplication.js +71 -0
  103. package/dist/envelope.d.ts +169 -0
  104. package/dist/envelope.js +257 -0
  105. package/dist/errors/enhanced-errors.d.ts +168 -0
  106. package/dist/errors/enhanced-errors.js +567 -0
  107. package/dist/errors/index.d.ts +18 -0
  108. package/dist/errors/index.js +33 -0
  109. package/dist/examples/cache-retry-examples.d.ts +64 -0
  110. package/dist/examples/cache-retry-examples.js +375 -0
  111. package/dist/helper.d.ts +102 -0
  112. package/dist/helper.js +885 -0
  113. package/dist/http-agent.d.ts +38 -0
  114. package/dist/http-agent.js +60 -0
  115. package/dist/index.d.ts +1 -0
  116. package/dist/index.js +4 -0
  117. package/dist/interface.d.ts +4 -0
  118. package/dist/interface.js +2 -0
  119. package/dist/notion.d.ts +144 -0
  120. package/dist/notion.js +547 -0
  121. package/dist/retry.d.ts +72 -0
  122. package/dist/retry.js +381 -0
  123. package/dist/utils/bookmarks.d.ts +32 -0
  124. package/dist/utils/bookmarks.js +98 -0
  125. package/dist/utils/daily-config.d.ts +22 -0
  126. package/dist/utils/daily-config.js +60 -0
  127. package/dist/utils/disk-cache.d.ts +80 -0
  128. package/dist/utils/disk-cache.js +291 -0
  129. package/dist/utils/fuzzy.d.ts +36 -0
  130. package/dist/utils/fuzzy.js +69 -0
  131. package/dist/utils/interactive-navigator.d.ts +63 -0
  132. package/dist/utils/interactive-navigator.js +123 -0
  133. package/dist/utils/markdown-to-blocks.d.ts +21 -0
  134. package/dist/utils/markdown-to-blocks.js +333 -0
  135. package/dist/utils/notion-resolver.d.ts +49 -0
  136. package/dist/utils/notion-resolver.js +278 -0
  137. package/dist/utils/notion-url-parser.d.ts +48 -0
  138. package/dist/utils/notion-url-parser.js +121 -0
  139. package/dist/utils/property-expander.d.ts +45 -0
  140. package/dist/utils/property-expander.js +323 -0
  141. package/dist/utils/schema-examples.d.ts +40 -0
  142. package/dist/utils/schema-examples.js +359 -0
  143. package/dist/utils/schema-extractor.d.ts +65 -0
  144. package/dist/utils/schema-extractor.js +235 -0
  145. package/dist/utils/shell-config.d.ts +30 -0
  146. package/dist/utils/shell-config.js +84 -0
  147. package/dist/utils/table-formatter.d.ts +36 -0
  148. package/dist/utils/table-formatter.js +125 -0
  149. package/dist/utils/templates.d.ts +30 -0
  150. package/dist/utils/templates.js +82 -0
  151. package/dist/utils/terminal-banner.d.ts +24 -0
  152. package/dist/utils/terminal-banner.js +34 -0
  153. package/dist/utils/token-validator.d.ts +42 -0
  154. package/dist/utils/token-validator.js +66 -0
  155. package/dist/utils/update-notifier.d.ts +26 -0
  156. package/dist/utils/update-notifier.js +54 -0
  157. package/dist/utils/workspace-cache.d.ts +58 -0
  158. package/dist/utils/workspace-cache.js +185 -0
  159. package/oclif.manifest.json +6471 -0
  160. package/package.json +118 -0
  161. package/scripts/banner.js +38 -0
  162. package/scripts/postinstall.js +44 -0
@@ -0,0 +1,36 @@
1
+ import { Command } from '@oclif/core';
2
+ /**
3
+ * Convenience alias for archiving (soft-deleting) a Notion page.
4
+ * Equivalent to: notion-cli page update PAGE_ID -a
5
+ *
6
+ * Notion API does not support hard deletes — archiving is the only delete operation.
7
+ */
8
+ export default class PageDelete extends Command {
9
+ static description: string;
10
+ static aliases: string[];
11
+ static examples: {
12
+ description: string;
13
+ command: string;
14
+ }[];
15
+ static args: {
16
+ page_id: import("@oclif/core/lib/interfaces").Arg<string, Record<string, unknown>>;
17
+ };
18
+ static flags: {
19
+ json: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
20
+ 'page-size': import("@oclif/core/lib/interfaces").OptionFlag<number, import("@oclif/core/lib/interfaces").CustomOptions>;
21
+ retry: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
22
+ timeout: import("@oclif/core/lib/interfaces").OptionFlag<number, import("@oclif/core/lib/interfaces").CustomOptions>;
23
+ 'no-cache': import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
24
+ verbose: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
25
+ minimal: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
26
+ columns: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces").CustomOptions>;
27
+ sort: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces").CustomOptions>;
28
+ filter: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces").CustomOptions>;
29
+ csv: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
30
+ extended: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
31
+ 'no-truncate': import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
32
+ 'no-header': import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
33
+ raw: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
34
+ };
35
+ run(): Promise<void>;
36
+ }
@@ -0,0 +1,107 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const core_1 = require("@oclif/core");
4
+ const notion = require("../../notion");
5
+ const helper_1 = require("../../helper");
6
+ const notion_resolver_1 = require("../../utils/notion-resolver");
7
+ const table_formatter_1 = require("../../utils/table-formatter");
8
+ const base_flags_1 = require("../../base-flags");
9
+ const errors_1 = require("../../errors");
10
+ /**
11
+ * Convenience alias for archiving (soft-deleting) a Notion page.
12
+ * Equivalent to: notion-cli page update PAGE_ID -a
13
+ *
14
+ * Notion API does not support hard deletes — archiving is the only delete operation.
15
+ */
16
+ class PageDelete extends core_1.Command {
17
+ async run() {
18
+ const { args, flags } = await this.parse(PageDelete);
19
+ try {
20
+ const pageId = await (0, notion_resolver_1.resolveNotionId)(args.page_id, 'page');
21
+ // Archive the page (Notion's soft-delete)
22
+ const res = await notion.updatePageProps({
23
+ page_id: pageId,
24
+ archived: true,
25
+ });
26
+ // JSON output for automation
27
+ if (flags.json) {
28
+ this.log(JSON.stringify({
29
+ success: true,
30
+ data: res,
31
+ timestamp: new Date().toISOString()
32
+ }, null, 2));
33
+ process.exit(0);
34
+ return;
35
+ }
36
+ // Raw JSON output (legacy)
37
+ if (flags.raw) {
38
+ (0, helper_1.outputRawJson)(res);
39
+ process.exit(0);
40
+ return;
41
+ }
42
+ // Table output (default)
43
+ const columns = {
44
+ title: {
45
+ get: (row) => (0, helper_1.getPageTitle)(row),
46
+ },
47
+ object: {},
48
+ id: {},
49
+ archived: {},
50
+ url: {},
51
+ };
52
+ const options = {
53
+ printLine: this.log.bind(this),
54
+ ...flags,
55
+ };
56
+ (0, table_formatter_1.formatTable)([res], columns, options);
57
+ process.exit(0);
58
+ }
59
+ catch (error) {
60
+ const cliError = error instanceof errors_1.NotionCLIError
61
+ ? error
62
+ : (0, errors_1.wrapNotionError)(error, {
63
+ resourceType: 'page',
64
+ attemptedId: args.page_id,
65
+ endpoint: 'pages.update'
66
+ });
67
+ if (flags.json) {
68
+ this.log(JSON.stringify(cliError.toJSON(), null, 2));
69
+ }
70
+ else {
71
+ this.error(cliError.toHumanString());
72
+ }
73
+ process.exit(1);
74
+ }
75
+ }
76
+ }
77
+ PageDelete.description = 'Archive (soft-delete) a Notion page';
78
+ PageDelete.aliases = ['page:d'];
79
+ PageDelete.examples = [
80
+ {
81
+ description: 'Delete (archive) a page by ID',
82
+ command: '$ notion-cli page delete PAGE_ID',
83
+ },
84
+ {
85
+ description: 'Delete (archive) a page by URL',
86
+ command: '$ notion-cli page delete https://notion.so/PAGE_ID',
87
+ },
88
+ {
89
+ description: 'Delete and output JSON for automation',
90
+ command: '$ notion-cli page delete PAGE_ID --json',
91
+ },
92
+ ];
93
+ PageDelete.args = {
94
+ page_id: core_1.Args.string({
95
+ required: true,
96
+ description: 'Page ID or full Notion URL',
97
+ }),
98
+ };
99
+ PageDelete.flags = {
100
+ raw: core_1.Flags.boolean({
101
+ char: 'r',
102
+ description: 'Output raw JSON',
103
+ }),
104
+ ...table_formatter_1.tableFlags,
105
+ ...base_flags_1.AutomationFlags,
106
+ };
107
+ exports.default = PageDelete;
@@ -0,0 +1,38 @@
1
+ import { Command } from '@oclif/core';
2
+ /**
3
+ * Export a Notion page to a local file (markdown or JSON).
4
+ *
5
+ * This is the reverse of `page create -f`: instead of reading a local file
6
+ * and pushing it to Notion, it pulls a Notion page and writes it locally.
7
+ *
8
+ * Markdown is the default format because it's human-readable and round-trips
9
+ * well with `page create -f`. JSON is available via --json for automation
10
+ * or lossless backups.
11
+ */
12
+ export default class PageExport extends Command {
13
+ static description: string;
14
+ static aliases: string[];
15
+ static examples: {
16
+ description: string;
17
+ command: string;
18
+ }[];
19
+ static args: {
20
+ page_id: import("@oclif/core/lib/interfaces").Arg<string, Record<string, unknown>>;
21
+ };
22
+ static flags: {
23
+ json: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
24
+ 'page-size': import("@oclif/core/lib/interfaces").OptionFlag<number, import("@oclif/core/lib/interfaces").CustomOptions>;
25
+ retry: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
26
+ timeout: import("@oclif/core/lib/interfaces").OptionFlag<number, import("@oclif/core/lib/interfaces").CustomOptions>;
27
+ 'no-cache': import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
28
+ verbose: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
29
+ minimal: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
30
+ output: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces").CustomOptions>;
31
+ };
32
+ run(): Promise<void>;
33
+ /**
34
+ * Validate output path to prevent directory traversal attacks.
35
+ * Ensures the resolved path stays within the current working directory.
36
+ */
37
+ private validateOutputPath;
38
+ }
@@ -0,0 +1,120 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const core_1 = require("@oclif/core");
4
+ const fs = require("fs");
5
+ const path = require("path");
6
+ const notion = require("../../notion");
7
+ const notion_to_md_1 = require("notion-to-md");
8
+ const notion_resolver_1 = require("../../utils/notion-resolver");
9
+ const helper_1 = require("../../helper");
10
+ const base_flags_1 = require("../../base-flags");
11
+ const errors_1 = require("../../errors");
12
+ /**
13
+ * Export a Notion page to a local file (markdown or JSON).
14
+ *
15
+ * This is the reverse of `page create -f`: instead of reading a local file
16
+ * and pushing it to Notion, it pulls a Notion page and writes it locally.
17
+ *
18
+ * Markdown is the default format because it's human-readable and round-trips
19
+ * well with `page create -f`. JSON is available via --json for automation
20
+ * or lossless backups.
21
+ */
22
+ class PageExport extends core_1.Command {
23
+ async run() {
24
+ const { args, flags } = await this.parse(PageExport);
25
+ try {
26
+ const pageId = await (0, notion_resolver_1.resolveNotionId)(args.page_id, 'page');
27
+ // Choose format: JSON for structured data, markdown for human-readable
28
+ let content;
29
+ if (flags.json) {
30
+ let page = await notion.retrievePage({ page_id: pageId });
31
+ if (flags.minimal) {
32
+ page = (0, helper_1.stripMetadata)(page);
33
+ }
34
+ content = JSON.stringify(page, null, 2);
35
+ }
36
+ else {
37
+ // notion-to-md handles all block fetching and conversion internally
38
+ const n2m = new notion_to_md_1.NotionToMarkdown({ notionClient: notion.client });
39
+ const mdBlocks = await n2m.pageToMarkdown(pageId);
40
+ content = n2m.toMarkdownString(mdBlocks).parent;
41
+ }
42
+ // Write to file or stdout
43
+ if (flags.output) {
44
+ const resolvedPath = this.validateOutputPath(flags.output);
45
+ fs.writeFileSync(resolvedPath, content, 'utf-8');
46
+ this.log(`Exported to ${flags.output}`);
47
+ }
48
+ else {
49
+ this.log(content);
50
+ }
51
+ process.exit(0);
52
+ }
53
+ catch (error) {
54
+ const cliError = error instanceof errors_1.NotionCLIError
55
+ ? error
56
+ : (0, errors_1.wrapNotionError)(error, {
57
+ resourceType: 'page',
58
+ attemptedId: args.page_id,
59
+ endpoint: 'page.export'
60
+ });
61
+ if (flags.json) {
62
+ this.log(JSON.stringify(cliError.toJSON(), null, 2));
63
+ }
64
+ else {
65
+ this.error(cliError.toHumanString());
66
+ }
67
+ process.exit(1);
68
+ }
69
+ }
70
+ /**
71
+ * Validate output path to prevent directory traversal attacks.
72
+ * Ensures the resolved path stays within the current working directory.
73
+ */
74
+ validateOutputPath(filePath) {
75
+ const basePath = path.resolve('./');
76
+ const resolved = path.resolve(basePath, filePath);
77
+ if (!resolved.startsWith(basePath)) {
78
+ throw new errors_1.NotionCLIError('VALIDATION_ERROR', 'Invalid output path: must be within current directory', [{ description: 'Use a relative path', command: 'notion-cli page export PAGE_ID -o ./output.md' }]);
79
+ }
80
+ return resolved;
81
+ }
82
+ }
83
+ PageExport.description = 'Export a Notion page to markdown or JSON';
84
+ PageExport.aliases = ['page:e'];
85
+ PageExport.examples = [
86
+ {
87
+ description: 'Export page as markdown to stdout',
88
+ command: '$ notion-cli page export PAGE_ID',
89
+ },
90
+ {
91
+ description: 'Export page as markdown to a file',
92
+ command: '$ notion-cli page export PAGE_ID -o notes.md',
93
+ },
94
+ {
95
+ description: 'Export page as JSON to a file',
96
+ command: '$ notion-cli page export PAGE_ID --json -o page.json',
97
+ },
98
+ {
99
+ description: 'Export using a Notion URL',
100
+ command: '$ notion-cli page export "https://notion.so/My-Page-abc123" -o notes.md',
101
+ },
102
+ {
103
+ description: 'Pipe markdown to another command',
104
+ command: '$ notion-cli page export PAGE_ID | head -20',
105
+ },
106
+ ];
107
+ PageExport.args = {
108
+ page_id: core_1.Args.string({
109
+ required: true,
110
+ description: 'Page ID or full Notion URL',
111
+ }),
112
+ };
113
+ PageExport.flags = {
114
+ output: core_1.Flags.string({
115
+ char: 'o',
116
+ description: 'File path to write (omit for stdout)',
117
+ }),
118
+ ...base_flags_1.AutomationFlags,
119
+ };
120
+ exports.default = PageExport;
@@ -0,0 +1,24 @@
1
+ import { Command } from '@oclif/core';
2
+ export default class PageRetrievePropertyItem extends Command {
3
+ static description: string;
4
+ static aliases: string[];
5
+ static examples: {
6
+ description: string;
7
+ command: string;
8
+ }[];
9
+ static args: {
10
+ page_id: import("@oclif/core/lib/interfaces").Arg<string, Record<string, unknown>>;
11
+ property_id: import("@oclif/core/lib/interfaces").Arg<string, Record<string, unknown>>;
12
+ };
13
+ static flags: {
14
+ json: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
15
+ 'page-size': import("@oclif/core/lib/interfaces").OptionFlag<number, import("@oclif/core/lib/interfaces").CustomOptions>;
16
+ retry: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
17
+ timeout: import("@oclif/core/lib/interfaces").OptionFlag<number, import("@oclif/core/lib/interfaces").CustomOptions>;
18
+ 'no-cache': import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
19
+ verbose: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
20
+ minimal: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
21
+ raw: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
22
+ };
23
+ run(): Promise<void>;
24
+ }
@@ -0,0 +1,75 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const core_1 = require("@oclif/core");
4
+ const notion = require("../../../notion");
5
+ const helper_1 = require("../../../helper");
6
+ const base_flags_1 = require("../../../base-flags");
7
+ const errors_1 = require("../../../errors");
8
+ const notion_resolver_1 = require("../../../utils/notion-resolver");
9
+ class PageRetrievePropertyItem extends core_1.Command {
10
+ async run() {
11
+ const { args, flags } = await this.parse(PageRetrievePropertyItem);
12
+ try {
13
+ // Resolve URL/name/ID to clean Notion ID (property_id stays raw — it's a schema key, not a Notion resource)
14
+ const pageId = await (0, notion_resolver_1.resolveNotionId)(args.page_id, 'page');
15
+ const res = await notion.retrievePageProperty(pageId, args.property_id);
16
+ // Handle JSON output for automation
17
+ if (flags.json) {
18
+ this.log(JSON.stringify({
19
+ success: true,
20
+ data: res,
21
+ timestamp: new Date().toISOString()
22
+ }, null, 2));
23
+ process.exit(0);
24
+ return;
25
+ }
26
+ // Handle raw JSON output (default for this command)
27
+ (0, helper_1.outputRawJson)(res);
28
+ process.exit(0);
29
+ }
30
+ catch (error) {
31
+ const cliError = error instanceof errors_1.NotionCLIError
32
+ ? error
33
+ : (0, errors_1.wrapNotionError)(error, {
34
+ resourceType: 'page',
35
+ attemptedId: args.page_id,
36
+ endpoint: 'pages.properties.retrieve'
37
+ });
38
+ if (flags.json) {
39
+ this.log(JSON.stringify(cliError.toJSON(), null, 2));
40
+ }
41
+ else {
42
+ this.error(cliError.toHumanString());
43
+ }
44
+ process.exit(1);
45
+ }
46
+ }
47
+ }
48
+ PageRetrievePropertyItem.description = 'Retrieve a page property item';
49
+ PageRetrievePropertyItem.aliases = ['page:r:pi'];
50
+ PageRetrievePropertyItem.examples = [
51
+ {
52
+ description: 'Retrieve a page property item',
53
+ command: `$ notion-cli page retrieve:property_item PAGE_ID PROPERTY_ID`,
54
+ },
55
+ {
56
+ description: 'Retrieve a page property item and output raw json',
57
+ command: `$ notion-cli page retrieve:property_item PAGE_ID PROPERTY_ID -r`,
58
+ },
59
+ {
60
+ description: 'Retrieve a page property item and output JSON for automation',
61
+ command: `$ notion-cli page retrieve:property_item PAGE_ID PROPERTY_ID --json`,
62
+ },
63
+ ];
64
+ PageRetrievePropertyItem.args = {
65
+ page_id: core_1.Args.string({ required: true }),
66
+ property_id: core_1.Args.string({ required: true }),
67
+ };
68
+ PageRetrievePropertyItem.flags = {
69
+ raw: core_1.Flags.boolean({
70
+ char: 'r',
71
+ description: 'output raw json',
72
+ }),
73
+ ...base_flags_1.AutomationFlags,
74
+ };
75
+ exports.default = PageRetrievePropertyItem;
@@ -0,0 +1,36 @@
1
+ import { Command } from '@oclif/core';
2
+ export default class PageRetrieve extends Command {
3
+ static description: string;
4
+ static aliases: string[];
5
+ static examples: {
6
+ description: string;
7
+ command: string;
8
+ }[];
9
+ static args: {
10
+ page_id: import("@oclif/core/lib/interfaces").Arg<string, Record<string, unknown>>;
11
+ };
12
+ static flags: {
13
+ json: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
14
+ 'page-size': import("@oclif/core/lib/interfaces").OptionFlag<number, import("@oclif/core/lib/interfaces").CustomOptions>;
15
+ retry: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
16
+ timeout: import("@oclif/core/lib/interfaces").OptionFlag<number, import("@oclif/core/lib/interfaces").CustomOptions>;
17
+ 'no-cache': import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
18
+ verbose: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
19
+ minimal: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
20
+ markdown: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
21
+ 'compact-json': import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
22
+ pretty: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
23
+ columns: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces").CustomOptions>;
24
+ sort: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces").CustomOptions>;
25
+ filter: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces").CustomOptions>;
26
+ csv: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
27
+ extended: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
28
+ 'no-truncate': import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
29
+ 'no-header': import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
30
+ raw: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
31
+ map: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
32
+ recursive: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
33
+ 'max-depth': import("@oclif/core/lib/interfaces").OptionFlag<number, import("@oclif/core/lib/interfaces").CustomOptions>;
34
+ };
35
+ run(): Promise<void>;
36
+ }