@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.
- package/LICENSE +21 -0
- package/README.md +552 -0
- package/bin/dev +17 -0
- package/bin/dev.cmd +3 -0
- package/bin/run +14 -0
- package/bin/run.cmd +3 -0
- package/dist/base-command.d.ts +73 -0
- package/dist/base-command.js +179 -0
- package/dist/base-flags.d.ts +14 -0
- package/dist/base-flags.js +59 -0
- package/dist/cache.d.ts +84 -0
- package/dist/cache.js +351 -0
- package/dist/commands/append.d.ts +37 -0
- package/dist/commands/append.js +120 -0
- package/dist/commands/batch/delete.d.ts +42 -0
- package/dist/commands/batch/delete.js +199 -0
- package/dist/commands/batch/retrieve.d.ts +43 -0
- package/dist/commands/batch/retrieve.js +272 -0
- package/dist/commands/block/append.d.ts +42 -0
- package/dist/commands/block/append.js +219 -0
- package/dist/commands/block/delete.d.ts +30 -0
- package/dist/commands/block/delete.js +97 -0
- package/dist/commands/block/retrieve/children.d.ts +31 -0
- package/dist/commands/block/retrieve/children.js +177 -0
- package/dist/commands/block/retrieve.d.ts +30 -0
- package/dist/commands/block/retrieve.js +101 -0
- package/dist/commands/block/update.d.ts +45 -0
- package/dist/commands/block/update.js +242 -0
- package/dist/commands/bookmark/list.d.ts +30 -0
- package/dist/commands/bookmark/list.js +60 -0
- package/dist/commands/bookmark/remove.d.ts +26 -0
- package/dist/commands/bookmark/remove.js +47 -0
- package/dist/commands/bookmark/set.d.ts +29 -0
- package/dist/commands/bookmark/set.js +96 -0
- package/dist/commands/browse.d.ts +13 -0
- package/dist/commands/browse.js +44 -0
- package/dist/commands/cache/info.d.ts +19 -0
- package/dist/commands/cache/info.js +145 -0
- package/dist/commands/config/set-token.d.ts +22 -0
- package/dist/commands/config/set-token.js +137 -0
- package/dist/commands/daily/index.d.ts +32 -0
- package/dist/commands/daily/index.js +135 -0
- package/dist/commands/daily/setup.d.ts +42 -0
- package/dist/commands/daily/setup.js +149 -0
- package/dist/commands/db/create.d.ts +31 -0
- package/dist/commands/db/create.js +124 -0
- package/dist/commands/db/query.d.ts +41 -0
- package/dist/commands/db/query.js +360 -0
- package/dist/commands/db/retrieve.d.ts +33 -0
- package/dist/commands/db/retrieve.js +134 -0
- package/dist/commands/db/schema.d.ts +32 -0
- package/dist/commands/db/schema.js +308 -0
- package/dist/commands/db/update.d.ts +31 -0
- package/dist/commands/db/update.js +117 -0
- package/dist/commands/doctor.d.ts +50 -0
- package/dist/commands/doctor.js +420 -0
- package/dist/commands/init.d.ts +65 -0
- package/dist/commands/init.js +479 -0
- package/dist/commands/list.d.ts +29 -0
- package/dist/commands/list.js +219 -0
- package/dist/commands/open.d.ts +29 -0
- package/dist/commands/open.js +100 -0
- package/dist/commands/page/create.d.ts +33 -0
- package/dist/commands/page/create.js +261 -0
- package/dist/commands/page/delete.d.ts +36 -0
- package/dist/commands/page/delete.js +107 -0
- package/dist/commands/page/export.d.ts +38 -0
- package/dist/commands/page/export.js +120 -0
- package/dist/commands/page/retrieve/property_item.d.ts +24 -0
- package/dist/commands/page/retrieve/property_item.js +75 -0
- package/dist/commands/page/retrieve.d.ts +36 -0
- package/dist/commands/page/retrieve.js +244 -0
- package/dist/commands/page/update.d.ts +34 -0
- package/dist/commands/page/update.js +184 -0
- package/dist/commands/quick.d.ts +35 -0
- package/dist/commands/quick.js +168 -0
- package/dist/commands/search.d.ts +43 -0
- package/dist/commands/search.js +361 -0
- package/dist/commands/stats.d.ts +35 -0
- package/dist/commands/stats.js +274 -0
- package/dist/commands/sync.d.ts +24 -0
- package/dist/commands/sync.js +183 -0
- package/dist/commands/template/get.d.ts +28 -0
- package/dist/commands/template/get.js +59 -0
- package/dist/commands/template/list.d.ts +32 -0
- package/dist/commands/template/list.js +62 -0
- package/dist/commands/template/remove.d.ts +27 -0
- package/dist/commands/template/remove.js +48 -0
- package/dist/commands/template/save.d.ts +32 -0
- package/dist/commands/template/save.js +92 -0
- package/dist/commands/template/use.d.ts +34 -0
- package/dist/commands/template/use.js +142 -0
- package/dist/commands/user/list.d.ts +27 -0
- package/dist/commands/user/list.js +99 -0
- package/dist/commands/user/retrieve/bot.d.ts +28 -0
- package/dist/commands/user/retrieve/bot.js +96 -0
- package/dist/commands/user/retrieve.d.ts +30 -0
- package/dist/commands/user/retrieve.js +103 -0
- package/dist/commands/whoami.d.ts +19 -0
- package/dist/commands/whoami.js +175 -0
- package/dist/deduplication.d.ts +41 -0
- package/dist/deduplication.js +71 -0
- package/dist/envelope.d.ts +169 -0
- package/dist/envelope.js +257 -0
- package/dist/errors/enhanced-errors.d.ts +168 -0
- package/dist/errors/enhanced-errors.js +567 -0
- package/dist/errors/index.d.ts +18 -0
- package/dist/errors/index.js +33 -0
- package/dist/examples/cache-retry-examples.d.ts +64 -0
- package/dist/examples/cache-retry-examples.js +375 -0
- package/dist/helper.d.ts +102 -0
- package/dist/helper.js +885 -0
- package/dist/http-agent.d.ts +38 -0
- package/dist/http-agent.js +60 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +4 -0
- package/dist/interface.d.ts +4 -0
- package/dist/interface.js +2 -0
- package/dist/notion.d.ts +144 -0
- package/dist/notion.js +547 -0
- package/dist/retry.d.ts +72 -0
- package/dist/retry.js +381 -0
- package/dist/utils/bookmarks.d.ts +32 -0
- package/dist/utils/bookmarks.js +98 -0
- package/dist/utils/daily-config.d.ts +22 -0
- package/dist/utils/daily-config.js +60 -0
- package/dist/utils/disk-cache.d.ts +80 -0
- package/dist/utils/disk-cache.js +291 -0
- package/dist/utils/fuzzy.d.ts +36 -0
- package/dist/utils/fuzzy.js +69 -0
- package/dist/utils/interactive-navigator.d.ts +63 -0
- package/dist/utils/interactive-navigator.js +123 -0
- package/dist/utils/markdown-to-blocks.d.ts +21 -0
- package/dist/utils/markdown-to-blocks.js +333 -0
- package/dist/utils/notion-resolver.d.ts +49 -0
- package/dist/utils/notion-resolver.js +278 -0
- package/dist/utils/notion-url-parser.d.ts +48 -0
- package/dist/utils/notion-url-parser.js +121 -0
- package/dist/utils/property-expander.d.ts +45 -0
- package/dist/utils/property-expander.js +323 -0
- package/dist/utils/schema-examples.d.ts +40 -0
- package/dist/utils/schema-examples.js +359 -0
- package/dist/utils/schema-extractor.d.ts +65 -0
- package/dist/utils/schema-extractor.js +235 -0
- package/dist/utils/shell-config.d.ts +30 -0
- package/dist/utils/shell-config.js +84 -0
- package/dist/utils/table-formatter.d.ts +36 -0
- package/dist/utils/table-formatter.js +125 -0
- package/dist/utils/templates.d.ts +30 -0
- package/dist/utils/templates.js +82 -0
- package/dist/utils/terminal-banner.d.ts +24 -0
- package/dist/utils/terminal-banner.js +34 -0
- package/dist/utils/token-validator.d.ts +42 -0
- package/dist/utils/token-validator.js +66 -0
- package/dist/utils/update-notifier.d.ts +26 -0
- package/dist/utils/update-notifier.js +54 -0
- package/dist/utils/workspace-cache.d.ts +58 -0
- package/dist/utils/workspace-cache.js +185 -0
- package/oclif.manifest.json +6471 -0
- package/package.json +118 -0
- package/scripts/banner.js +38 -0
- package/scripts/postinstall.js +44 -0
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* HTTP Agent Configuration
|
|
3
|
+
*
|
|
4
|
+
* Configures connection pooling and HTTP keep-alive to reduce connection overhead.
|
|
5
|
+
* Enables connection reuse across multiple API requests for better performance.
|
|
6
|
+
*/
|
|
7
|
+
import { Agent } from 'undici';
|
|
8
|
+
/**
|
|
9
|
+
* Undici Agent with keep-alive and connection pooling enabled
|
|
10
|
+
* Undici is used instead of native https.Agent because Node.js fetch uses undici under the hood
|
|
11
|
+
*/
|
|
12
|
+
export declare const httpsAgent: Agent;
|
|
13
|
+
/**
|
|
14
|
+
* Default request timeout in milliseconds
|
|
15
|
+
* Note: timeout is set per-request, not on the agent
|
|
16
|
+
*/
|
|
17
|
+
export declare const REQUEST_TIMEOUT: number;
|
|
18
|
+
/**
|
|
19
|
+
* Get current agent statistics
|
|
20
|
+
* Note: undici Agent doesn't expose socket statistics like https.Agent
|
|
21
|
+
*/
|
|
22
|
+
export declare function getAgentStats(): {
|
|
23
|
+
sockets: number;
|
|
24
|
+
freeSockets: number;
|
|
25
|
+
requests: number;
|
|
26
|
+
};
|
|
27
|
+
/**
|
|
28
|
+
* Destroy all connections (cleanup)
|
|
29
|
+
*/
|
|
30
|
+
export declare function destroyAgents(): void;
|
|
31
|
+
/**
|
|
32
|
+
* Get agent configuration
|
|
33
|
+
*/
|
|
34
|
+
export declare function getAgentConfig(): {
|
|
35
|
+
connections: number;
|
|
36
|
+
keepAliveTimeout: number;
|
|
37
|
+
requestTimeout: number;
|
|
38
|
+
};
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* HTTP Agent Configuration
|
|
4
|
+
*
|
|
5
|
+
* Configures connection pooling and HTTP keep-alive to reduce connection overhead.
|
|
6
|
+
* Enables connection reuse across multiple API requests for better performance.
|
|
7
|
+
*/
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.REQUEST_TIMEOUT = exports.httpsAgent = void 0;
|
|
10
|
+
exports.getAgentStats = getAgentStats;
|
|
11
|
+
exports.destroyAgents = destroyAgents;
|
|
12
|
+
exports.getAgentConfig = getAgentConfig;
|
|
13
|
+
const undici_1 = require("undici");
|
|
14
|
+
/**
|
|
15
|
+
* Undici Agent with keep-alive and connection pooling enabled
|
|
16
|
+
* Undici is used instead of native https.Agent because Node.js fetch uses undici under the hood
|
|
17
|
+
*/
|
|
18
|
+
exports.httpsAgent = new undici_1.Agent({
|
|
19
|
+
// Connection pooling
|
|
20
|
+
connections: parseInt(process.env.NOTION_CLI_HTTP_MAX_SOCKETS || '50', 10),
|
|
21
|
+
// Keep-alive settings
|
|
22
|
+
keepAliveTimeout: parseInt(process.env.NOTION_CLI_HTTP_KEEP_ALIVE_MS || '60000', 10),
|
|
23
|
+
keepAliveMaxTimeout: parseInt(process.env.NOTION_CLI_HTTP_KEEP_ALIVE_MS || '60000', 10),
|
|
24
|
+
// Pipelining (HTTP/1.1 request pipelining, 0 = disabled)
|
|
25
|
+
pipelining: 0,
|
|
26
|
+
});
|
|
27
|
+
/**
|
|
28
|
+
* Default request timeout in milliseconds
|
|
29
|
+
* Note: timeout is set per-request, not on the agent
|
|
30
|
+
*/
|
|
31
|
+
exports.REQUEST_TIMEOUT = parseInt(process.env.NOTION_CLI_HTTP_TIMEOUT || '30000', 10);
|
|
32
|
+
/**
|
|
33
|
+
* Get current agent statistics
|
|
34
|
+
* Note: undici Agent doesn't expose socket statistics like https.Agent
|
|
35
|
+
*/
|
|
36
|
+
function getAgentStats() {
|
|
37
|
+
// undici's Agent doesn't expose internal socket statistics
|
|
38
|
+
// Return placeholder values for now
|
|
39
|
+
return {
|
|
40
|
+
sockets: 0,
|
|
41
|
+
freeSockets: 0,
|
|
42
|
+
requests: 0,
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Destroy all connections (cleanup)
|
|
47
|
+
*/
|
|
48
|
+
function destroyAgents() {
|
|
49
|
+
exports.httpsAgent.destroy();
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Get agent configuration
|
|
53
|
+
*/
|
|
54
|
+
function getAgentConfig() {
|
|
55
|
+
return {
|
|
56
|
+
connections: parseInt(process.env.NOTION_CLI_HTTP_MAX_SOCKETS || '50', 10),
|
|
57
|
+
keepAliveTimeout: parseInt(process.env.NOTION_CLI_HTTP_KEEP_ALIVE_MS || '60000', 10),
|
|
58
|
+
requestTimeout: exports.REQUEST_TIMEOUT,
|
|
59
|
+
};
|
|
60
|
+
}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { run } from '@oclif/core';
|
package/dist/index.js
ADDED
package/dist/notion.d.ts
ADDED
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
import { Client } from '@notionhq/client';
|
|
2
|
+
import { CreateDatabaseParameters, QueryDataSourceResponse, GetDatabaseResponse, GetDataSourceResponse, CreateDatabaseResponse, UpdateDatabaseParameters, UpdateDataSourceParameters, GetPageParameters, CreatePageParameters, BlockObjectRequest, UpdatePageParameters, AppendBlockChildrenParameters, UpdateBlockParameters, SearchParameters } from '@notionhq/client/build/src/api-endpoints';
|
|
3
|
+
export declare const client: Client;
|
|
4
|
+
/**
|
|
5
|
+
* Configuration for batch operations
|
|
6
|
+
*/
|
|
7
|
+
export declare const BATCH_CONFIG: {
|
|
8
|
+
deleteConcurrency: number;
|
|
9
|
+
childrenConcurrency: number;
|
|
10
|
+
};
|
|
11
|
+
/**
|
|
12
|
+
* Legacy fetchWithRetry for backward compatibility
|
|
13
|
+
* @deprecated Use the enhanced retry logic from retry.ts
|
|
14
|
+
*/
|
|
15
|
+
export declare const fetchWithRetry: (fn: () => Promise<any>, retries?: number) => Promise<any>;
|
|
16
|
+
/**
|
|
17
|
+
* Fetch all pages in a data source with pagination
|
|
18
|
+
*/
|
|
19
|
+
export declare const fetchAllPagesInDS: (databaseId: string, filter?: object | undefined) => Promise<QueryDataSourceResponse["results"]>;
|
|
20
|
+
/**
|
|
21
|
+
* Create a database
|
|
22
|
+
*/
|
|
23
|
+
export declare const createDb: (dbProps: CreateDatabaseParameters) => Promise<CreateDatabaseResponse>;
|
|
24
|
+
/**
|
|
25
|
+
* Update a database
|
|
26
|
+
*/
|
|
27
|
+
export declare const updateDb: (dbProps: UpdateDatabaseParameters) => Promise<GetDatabaseResponse>;
|
|
28
|
+
/**
|
|
29
|
+
* Retrieve a database (cached)
|
|
30
|
+
*/
|
|
31
|
+
export declare const retrieveDb: (databaseId: string) => Promise<GetDatabaseResponse>;
|
|
32
|
+
/**
|
|
33
|
+
* Retrieve a data source (cached)
|
|
34
|
+
*/
|
|
35
|
+
export declare const retrieveDataSource: (dataSourceId: string) => Promise<GetDataSourceResponse>;
|
|
36
|
+
/**
|
|
37
|
+
* Update a data source
|
|
38
|
+
*/
|
|
39
|
+
export declare const updateDataSource: (dsProps: UpdateDataSourceParameters) => Promise<GetDataSourceResponse>;
|
|
40
|
+
/**
|
|
41
|
+
* Retrieve a page (cached with short TTL)
|
|
42
|
+
*/
|
|
43
|
+
export declare const retrievePage: (pageProp: GetPageParameters) => Promise<import("@notionhq/client").GetPageResponse>;
|
|
44
|
+
/**
|
|
45
|
+
* Retrieve page property
|
|
46
|
+
*/
|
|
47
|
+
export declare const retrievePageProperty: (pageId: string, propId: string) => Promise<import("@notionhq/client").GetPagePropertyResponse>;
|
|
48
|
+
/**
|
|
49
|
+
* Create a page
|
|
50
|
+
*/
|
|
51
|
+
export declare const createPage: (pageProps: CreatePageParameters) => Promise<import("@notionhq/client").CreatePageResponse>;
|
|
52
|
+
/**
|
|
53
|
+
* Update page properties
|
|
54
|
+
*/
|
|
55
|
+
export declare const updatePageProps: (pageParams: UpdatePageParameters) => Promise<import("@notionhq/client").UpdatePageResponse>;
|
|
56
|
+
/**
|
|
57
|
+
* Update page content by replacing all blocks
|
|
58
|
+
* To keep the same page URL, remove all blocks in the page and add new blocks
|
|
59
|
+
*/
|
|
60
|
+
export declare const updatePage: (pageId: string, blocks: BlockObjectRequest[]) => Promise<import("@notionhq/client").AppendBlockChildrenResponse>;
|
|
61
|
+
/**
|
|
62
|
+
* Retrieve a block (cached with very short TTL)
|
|
63
|
+
*/
|
|
64
|
+
export declare const retrieveBlock: (blockId: string) => Promise<import("@notionhq/client").GetBlockResponse>;
|
|
65
|
+
/**
|
|
66
|
+
* Update a block
|
|
67
|
+
*/
|
|
68
|
+
export declare const updateBlock: (params: UpdateBlockParameters) => Promise<import("@notionhq/client").UpdateBlockResponse>;
|
|
69
|
+
/**
|
|
70
|
+
* Retrieve block children (cached with very short TTL)
|
|
71
|
+
*/
|
|
72
|
+
export declare const retrieveBlockChildren: (blockId: string) => Promise<import("@notionhq/client").ListBlockChildrenResponse>;
|
|
73
|
+
/**
|
|
74
|
+
* Append block children
|
|
75
|
+
*/
|
|
76
|
+
export declare const appendBlockChildren: (params: AppendBlockChildrenParameters) => Promise<import("@notionhq/client").AppendBlockChildrenResponse>;
|
|
77
|
+
/**
|
|
78
|
+
* Delete a block
|
|
79
|
+
*/
|
|
80
|
+
export declare const deleteBlock: (blockId: string) => Promise<import("@notionhq/client").DeleteBlockResponse>;
|
|
81
|
+
/**
|
|
82
|
+
* Retrieve a user (cached with long TTL)
|
|
83
|
+
*/
|
|
84
|
+
export declare const retrieveUser: (userId: string) => Promise<import("@notionhq/client").UserObjectResponse>;
|
|
85
|
+
/**
|
|
86
|
+
* List all users (cached with long TTL)
|
|
87
|
+
*/
|
|
88
|
+
export declare const listUser: () => Promise<import("@notionhq/client").ListUsersResponse>;
|
|
89
|
+
/**
|
|
90
|
+
* Get bot user info (cached with long TTL)
|
|
91
|
+
*/
|
|
92
|
+
export declare const botUser: () => Promise<import("@notionhq/client").UserObjectResponse>;
|
|
93
|
+
/**
|
|
94
|
+
* Search for databases (cached with medium TTL)
|
|
95
|
+
*/
|
|
96
|
+
export declare const searchDb: () => Promise<(import("@notionhq/client").DataSourceObjectResponse | import("@notionhq/client").PageObjectResponse | import("@notionhq/client").PartialDataSourceObjectResponse | import("@notionhq/client").PartialPageObjectResponse)[]>;
|
|
97
|
+
/**
|
|
98
|
+
* General search (not cached due to variable parameters)
|
|
99
|
+
*/
|
|
100
|
+
export declare const search: (params: SearchParameters) => Promise<import("@notionhq/client").SearchResponse>;
|
|
101
|
+
/**
|
|
102
|
+
* Export cache manager for external use
|
|
103
|
+
*/
|
|
104
|
+
export { cacheManager } from './cache';
|
|
105
|
+
/**
|
|
106
|
+
* Export retry utilities for external use
|
|
107
|
+
*/
|
|
108
|
+
export { fetchWithRetry as enhancedFetchWithRetry, CircuitBreaker } from './retry';
|
|
109
|
+
/**
|
|
110
|
+
* Recursively retrieve a page with all its blocks and nested content
|
|
111
|
+
* @param pageId - The ID of the page to retrieve
|
|
112
|
+
* @param depth - Current recursion depth (internal use)
|
|
113
|
+
* @param maxDepth - Maximum depth to recurse (default: 3)
|
|
114
|
+
* @returns Object containing page metadata, blocks, and optional warnings
|
|
115
|
+
*/
|
|
116
|
+
export declare const retrievePageRecursive: (pageId: string, depth?: number, maxDepth?: number) => Promise<{
|
|
117
|
+
page: any;
|
|
118
|
+
blocks: any[];
|
|
119
|
+
warnings?: Array<{
|
|
120
|
+
block_id: string;
|
|
121
|
+
type: string;
|
|
122
|
+
notion_type?: string;
|
|
123
|
+
message: string;
|
|
124
|
+
has_children: boolean;
|
|
125
|
+
}>;
|
|
126
|
+
}>;
|
|
127
|
+
/**
|
|
128
|
+
* Map page structure (fast page discovery with parallel fetching)
|
|
129
|
+
* Returns minimal structure info (titles, types, IDs) instead of full content
|
|
130
|
+
* @param pageId - The ID of the page to map
|
|
131
|
+
* @returns Object containing page ID, title, icon, and structure overview
|
|
132
|
+
*/
|
|
133
|
+
export declare const mapPageStructure: (pageId: string) => Promise<{
|
|
134
|
+
id: string;
|
|
135
|
+
title: string;
|
|
136
|
+
type: string;
|
|
137
|
+
icon?: string;
|
|
138
|
+
structure: Array<{
|
|
139
|
+
type: string;
|
|
140
|
+
id: string;
|
|
141
|
+
title?: string;
|
|
142
|
+
text?: string;
|
|
143
|
+
}>;
|
|
144
|
+
}>;
|