@mcp-monorepo/notion-query 1.2.0 → 1.3.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/dist/index.js +53 -6
- package/dist/index.js.map +1 -1
- package/dist/lib/config.d.ts +44 -0
- package/dist/lib/config.d.ts.map +1 -0
- package/dist/lib/config.js +49 -0
- package/dist/lib/config.js.map +1 -0
- package/dist/lib/notion-syncer.d.ts +27 -0
- package/dist/lib/notion-syncer.d.ts.map +1 -0
- package/dist/lib/notion-syncer.js +212 -0
- package/dist/lib/notion-syncer.js.map +1 -0
- package/dist/lib/property-parser.d.ts +8 -10
- package/dist/lib/property-parser.d.ts.map +1 -1
- package/dist/lib/property-parser.js +102 -15
- package/dist/lib/property-parser.js.map +1 -1
- package/dist/lib/sync-state-manager.d.ts +29 -0
- package/dist/lib/sync-state-manager.d.ts.map +1 -0
- package/dist/lib/sync-state-manager.js +45 -0
- package/dist/lib/sync-state-manager.js.map +1 -0
- package/dist/local-rag/DEMO.d.ts +22 -0
- package/dist/local-rag/DEMO.d.ts.map +1 -0
- package/dist/local-rag/DEMO.js +142 -0
- package/dist/local-rag/DEMO.js.map +1 -0
- package/dist/local-rag/chunker.d.ts +24 -0
- package/dist/local-rag/chunker.d.ts.map +1 -0
- package/dist/local-rag/chunker.js +58 -0
- package/dist/local-rag/chunker.js.map +1 -0
- package/dist/local-rag/embedder.d.ts +43 -0
- package/dist/local-rag/embedder.d.ts.map +1 -0
- package/dist/local-rag/embedder.js +74 -0
- package/dist/local-rag/embedder.js.map +1 -0
- package/dist/local-rag/embedder.service.d.ts +15 -0
- package/dist/local-rag/embedder.service.d.ts.map +1 -0
- package/dist/local-rag/embedder.service.js +84 -0
- package/dist/local-rag/embedder.service.js.map +1 -0
- package/dist/local-rag/embedder.worker.d.ts +2 -0
- package/dist/local-rag/embedder.worker.d.ts.map +1 -0
- package/dist/local-rag/embedder.worker.js +34 -0
- package/dist/local-rag/embedder.worker.js.map +1 -0
- package/dist/local-rag/errors.d.ts +31 -0
- package/dist/local-rag/errors.d.ts.map +1 -0
- package/dist/local-rag/errors.js +47 -0
- package/dist/local-rag/errors.js.map +1 -0
- package/dist/local-rag/html-parser.d.ts +2 -0
- package/dist/local-rag/html-parser.d.ts.map +1 -0
- package/dist/local-rag/html-parser.js +32 -0
- package/dist/local-rag/html-parser.js.map +1 -0
- package/dist/local-rag/index.d.ts +67 -0
- package/dist/local-rag/index.d.ts.map +1 -0
- package/dist/local-rag/index.js +410 -0
- package/dist/local-rag/index.js.map +1 -0
- package/dist/local-rag/parser.d.ts +59 -0
- package/dist/local-rag/parser.d.ts.map +1 -0
- package/dist/local-rag/parser.js +206 -0
- package/dist/local-rag/parser.js.map +1 -0
- package/dist/local-rag/types.d.ts +209 -0
- package/dist/local-rag/types.d.ts.map +1 -0
- package/dist/local-rag/types.js +5 -0
- package/dist/local-rag/types.js.map +1 -0
- package/dist/local-rag/utils/pool.d.ts +60 -0
- package/dist/local-rag/utils/pool.d.ts.map +1 -0
- package/dist/local-rag/utils/pool.js +140 -0
- package/dist/local-rag/utils/pool.js.map +1 -0
- package/dist/local-rag/utils/typed-emitter.d.ts +28 -0
- package/dist/local-rag/utils/typed-emitter.d.ts.map +1 -0
- package/dist/local-rag/utils/typed-emitter.js +44 -0
- package/dist/local-rag/utils/typed-emitter.js.map +1 -0
- package/dist/local-rag/vectordb/index.d.ts +91 -0
- package/dist/local-rag/vectordb/index.d.ts.map +1 -0
- package/dist/local-rag/vectordb/index.js +278 -0
- package/dist/local-rag/vectordb/index.js.map +1 -0
- package/dist/local-rag/vectordb/manager.d.ts +28 -0
- package/dist/local-rag/vectordb/manager.d.ts.map +1 -0
- package/dist/local-rag/vectordb/manager.js +91 -0
- package/dist/local-rag/vectordb/manager.js.map +1 -0
- package/dist/local-rag/vectordb/migration.d.ts +27 -0
- package/dist/local-rag/vectordb/migration.d.ts.map +1 -0
- package/dist/local-rag/vectordb/migration.js +121 -0
- package/dist/local-rag/vectordb/migration.js.map +1 -0
- package/dist/local-rag/vectordb/retriever.d.ts +51 -0
- package/dist/local-rag/vectordb/retriever.d.ts.map +1 -0
- package/dist/local-rag/vectordb/retriever.js +157 -0
- package/dist/local-rag/vectordb/retriever.js.map +1 -0
- package/dist/local-rag/vectordb/schema.d.ts +33 -0
- package/dist/local-rag/vectordb/schema.d.ts.map +1 -0
- package/dist/local-rag/vectordb/schema.js +102 -0
- package/dist/local-rag/vectordb/schema.js.map +1 -0
- package/dist/local-rag/watcher.d.ts +48 -0
- package/dist/local-rag/watcher.d.ts.map +1 -0
- package/dist/local-rag/watcher.js +102 -0
- package/dist/local-rag/watcher.js.map +1 -0
- package/dist/tools/create-pages.d.ts +2 -1
- package/dist/tools/create-pages.d.ts.map +1 -1
- package/dist/tools/create-pages.js +3 -2
- package/dist/tools/create-pages.js.map +1 -1
- package/dist/tools/fetch.d.ts +2 -1
- package/dist/tools/fetch.d.ts.map +1 -1
- package/dist/tools/fetch.js +2 -1
- package/dist/tools/fetch.js.map +1 -1
- package/dist/tools/query-datasource.d.ts +2 -1
- package/dist/tools/query-datasource.d.ts.map +1 -1
- package/dist/tools/query-datasource.js +3 -3
- package/dist/tools/query-datasource.js.map +1 -1
- package/dist/tools/search.d.ts +12 -0
- package/dist/tools/search.d.ts.map +1 -0
- package/dist/tools/search.js +75 -0
- package/dist/tools/search.js.map +1 -0
- package/dist/tools/update-page.d.ts +4 -0
- package/dist/tools/update-page.d.ts.map +1 -0
- package/dist/tools/update-page.js +135 -0
- package/dist/tools/update-page.js.map +1 -0
- package/package.json +15 -1
package/dist/index.js
CHANGED
|
@@ -1,12 +1,59 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import {
|
|
2
|
+
import { mkdir } from 'node:fs/promises';
|
|
3
|
+
import { createMcpServer, logger } from '@mcp-monorepo/shared';
|
|
4
|
+
import { NOTION_CONTENT_DIR, NOTION_RAG_DIR } from './lib/config.js';
|
|
5
|
+
import { NotionSyncer } from './lib/notion-syncer.js';
|
|
6
|
+
import { LocalRAG } from './local-rag/index.js';
|
|
3
7
|
import { registerCreatePagesTool } from './tools/create-pages.js';
|
|
4
8
|
import { registerFetchTool } from './tools/fetch.js';
|
|
5
9
|
import { registerQueryDatasourceTool } from './tools/query-datasource.js';
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
10
|
+
import { registerSearchTool } from './tools/search.js'; // Import the new tool
|
|
11
|
+
import { registerUpdatePageTool } from './tools/update-page.js';
|
|
12
|
+
/**
|
|
13
|
+
* Asynchronous main function to initialize services and start the MCP server.
|
|
14
|
+
*/
|
|
15
|
+
async function main() {
|
|
16
|
+
// 1. Initialize LocalRAG to watch the dedicated Notion content directory.
|
|
17
|
+
logger.info(`Initializing LocalRAG to watch: ${NOTION_CONTENT_DIR}`);
|
|
18
|
+
const localRag = await LocalRAG.create({
|
|
19
|
+
dbPath: NOTION_RAG_DIR,
|
|
20
|
+
baseDir: NOTION_RAG_DIR,
|
|
21
|
+
});
|
|
22
|
+
// Watch the content folder for changes
|
|
23
|
+
await mkdir(NOTION_CONTENT_DIR, { recursive: true });
|
|
24
|
+
logger.log(`Watching Notion content directory: ${NOTION_CONTENT_DIR}`);
|
|
25
|
+
await localRag.ingestFolder({ folderPath: NOTION_CONTENT_DIR, watch: true });
|
|
26
|
+
// 2. Initialize and start the Notion Syncer in the background.
|
|
27
|
+
const notionSyncer = new NotionSyncer();
|
|
28
|
+
await notionSyncer.start();
|
|
29
|
+
// 3. Create the MCP server and register all tools.
|
|
30
|
+
// The search tool gets access to the RAG and Syncer instances.
|
|
31
|
+
createMcpServer({
|
|
32
|
+
name: 'notion-query',
|
|
33
|
+
importMetaPath: import.meta.filename,
|
|
34
|
+
title: 'Notion Query MCP Server',
|
|
35
|
+
tools: [
|
|
36
|
+
(server) => registerQueryDatasourceTool(server, notionSyncer),
|
|
37
|
+
(server) => registerFetchTool(server, notionSyncer),
|
|
38
|
+
(server) => registerCreatePagesTool(server, notionSyncer),
|
|
39
|
+
(server) => registerUpdatePageTool(server, notionSyncer),
|
|
40
|
+
(server) => registerSearchTool(server, localRag, notionSyncer),
|
|
41
|
+
],
|
|
42
|
+
});
|
|
43
|
+
// 4. Graceful shutdown handling
|
|
44
|
+
const shutdown = async () => {
|
|
45
|
+
logger.info('Shutting down services gracefully...');
|
|
46
|
+
notionSyncer.stop();
|
|
47
|
+
await localRag.shutdown();
|
|
48
|
+
logger.close();
|
|
49
|
+
setTimeout(() => process.exit(0), 1000);
|
|
50
|
+
};
|
|
51
|
+
process.on('SIGINT', shutdown);
|
|
52
|
+
process.on('SIGTERM', shutdown);
|
|
53
|
+
}
|
|
54
|
+
// Execute the main function
|
|
55
|
+
main().catch((error) => {
|
|
56
|
+
logger.error('Failed to start the Notion Query MCP Server.', error);
|
|
57
|
+
setTimeout(() => process.exit(1), 1000);
|
|
11
58
|
});
|
|
12
59
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAEA,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAA;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAEA,OAAO,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAA;AAExC,OAAO,EAAE,eAAe,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAA;AAE9D,OAAO,EAAE,kBAAkB,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAA;AACpE,OAAO,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAA;AACrD,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAA;AAC/C,OAAO,EAAE,uBAAuB,EAAE,MAAM,yBAAyB,CAAA;AACjE,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAA;AACpD,OAAO,EAAE,2B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YACxD,CAAC,MAAM,EAAE,EAAE,CAAC,kBAAkB,CAAC,MAAM,EAAE,QAAQ,EAAE,YAAY,CAAC;SAC/D;KACF,CAAC,CAAA;IAEF,gCAAgC;IAChC,MAAM,QAAQ,GAAG,KAAK,IAAI,EAAE;QAC1B,MAAM,CAAC,IAAI,CAAC,sCAAsC,CAAC,CAAA;QACnD,YAAY,CAAC,IAAI,EAAE,CAAA;QACnB,MAAM,QAAQ,CAAC,QAAQ,EAAE,CAAA;QACzB,MAAM,CAAC,KAAK,EAAE,CAAA;QACd,UAAU,CAAC,GAAG,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC,CAAA;IACzC,CAAC,CAAA;IAED,OAAO,CAAC,EAAE,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAA;IAC9B,OAAO,CAAC,EAAE,CAAC,SAAS,EAAE,QAAQ,CAAC,CAAA;AACjC,CAAC;AAED,4BAA4B;AAC5B,IAAI,EAAE,CAAC,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE;IACrB,MAAM,CAAC,KAAK,CAAC,8CAA8C,EAAE,KAAK,CAAC,CAAA;IACnE,UAAU,CAAC,GAAG,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC,CAAA;AACzC,CAAC,CAAC,CAAA"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The root directory for all application-specific data, located in the user's home directory.
|
|
3
|
+
*/
|
|
4
|
+
export declare const APP_DATA_DIR: string;
|
|
5
|
+
/**
|
|
6
|
+
* The directory where all data related to the Notion RAG index is stored.
|
|
7
|
+
*/
|
|
8
|
+
export declare const NOTION_RAG_DIR: string;
|
|
9
|
+
/**
|
|
10
|
+
* The directory where downloaded and converted Notion pages (as Markdown) are stored.
|
|
11
|
+
* This is the folder that the LocalRAG instance will watch.
|
|
12
|
+
*/
|
|
13
|
+
export declare const NOTION_CONTENT_DIR: string;
|
|
14
|
+
/**
|
|
15
|
+
* The full path to the JSON file that stores the synchronization state.
|
|
16
|
+
*/
|
|
17
|
+
export declare const SYNC_STATE_PATH: string;
|
|
18
|
+
/**
|
|
19
|
+
* The delay in milliseconds between API calls enforced by the NotionApiThrottler.
|
|
20
|
+
* The Notion API has a limit of approximately 3 requests per second. 350ms provides a safe buffer.
|
|
21
|
+
*/
|
|
22
|
+
export declare const NOTION_API_RATE_LIMIT_DELAY_MS = 350;
|
|
23
|
+
/**
|
|
24
|
+
* The number of pages to fetch in a single paginated API request.
|
|
25
|
+
* The maximum allowed by the Notion API is 100.
|
|
26
|
+
*/
|
|
27
|
+
export declare const NOTION_PAGINATION_LIMIT = 100;
|
|
28
|
+
/**
|
|
29
|
+
* The total number of pages to add to the processing queue during each sync cycle.
|
|
30
|
+
* This acts as a cap to ensure each sync loop is reasonably short.
|
|
31
|
+
* @default 30
|
|
32
|
+
*/
|
|
33
|
+
export declare const SYNC_BATCH_SIZE: number;
|
|
34
|
+
/**
|
|
35
|
+
* The interval in milliseconds that the main synchronization loop waits after completing.
|
|
36
|
+
* @default 15 minutes
|
|
37
|
+
*/
|
|
38
|
+
export declare const SYNC_INTERVAL_MS: number;
|
|
39
|
+
/**
|
|
40
|
+
* The interval for the local-only garbage collection task, which removes orphaned files.
|
|
41
|
+
* @default 12 hours
|
|
42
|
+
*/
|
|
43
|
+
export declare const GC_INTERVAL_MS: number;
|
|
44
|
+
//# sourceMappingURL=config.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/lib/config.ts"],"names":[],"mappings":"AAMA;;GAEG;AACH,eAAO,MAAM,YAAY,QAEW,CAAA;AAEpC;;GAEG;AACH,eAAO,MAAM,cAAc,QAAe,CAAA;AAE1C;;;GAGG;AACH,eAAO,MAAM,kBAAkB,QAAmC,CAAA;AAElE;;GAEG;AACH,eAAO,MAAM,eAAe,QAA2C,CAAA;AAEvE;;;GAGG;AACH,eAAO,MAAM,8BAA8B,MAAM,CAAA;AAEjD;;;GAGG;AACH,eAAO,MAAM,uBAAuB,MAAM,CAAA;AAE1C;;;;GAIG;AACH,eAAO,MAAM,eAAe,QAA2D,CAAA;AAEvF;;;GAGG;AACH,eAAO,MAAM,gBAAgB,QAA2E,CAAA;AAExG;;;GAGG;AACH,eAAO,MAAM,cAAc,QAA6E,CAAA"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { resolve } from 'node:path';
|
|
2
|
+
import { findProjectRoot } from '@mcp-monorepo/shared';
|
|
3
|
+
const projectRoot = await findProjectRoot(import.meta.dirname);
|
|
4
|
+
/**
|
|
5
|
+
* The root directory for all application-specific data, located in the user's home directory.
|
|
6
|
+
*/
|
|
7
|
+
export const APP_DATA_DIR = process.env.NOTION_QUERY_APP_DATA_DIR
|
|
8
|
+
? resolve(process.env.NOTION_QUERY_APP_DATA_DIR)
|
|
9
|
+
: resolve(projectRoot, 'rag-data');
|
|
10
|
+
/**
|
|
11
|
+
* The directory where all data related to the Notion RAG index is stored.
|
|
12
|
+
*/
|
|
13
|
+
export const NOTION_RAG_DIR = APP_DATA_DIR;
|
|
14
|
+
/**
|
|
15
|
+
* The directory where downloaded and converted Notion pages (as Markdown) are stored.
|
|
16
|
+
* This is the folder that the LocalRAG instance will watch.
|
|
17
|
+
*/
|
|
18
|
+
export const NOTION_CONTENT_DIR = resolve(APP_DATA_DIR, 'content');
|
|
19
|
+
/**
|
|
20
|
+
* The full path to the JSON file that stores the synchronization state.
|
|
21
|
+
*/
|
|
22
|
+
export const SYNC_STATE_PATH = resolve(APP_DATA_DIR, 'sync-state.json');
|
|
23
|
+
/**
|
|
24
|
+
* The delay in milliseconds between API calls enforced by the NotionApiThrottler.
|
|
25
|
+
* The Notion API has a limit of approximately 3 requests per second. 350ms provides a safe buffer.
|
|
26
|
+
*/
|
|
27
|
+
export const NOTION_API_RATE_LIMIT_DELAY_MS = 350;
|
|
28
|
+
/**
|
|
29
|
+
* The number of pages to fetch in a single paginated API request.
|
|
30
|
+
* The maximum allowed by the Notion API is 100.
|
|
31
|
+
*/
|
|
32
|
+
export const NOTION_PAGINATION_LIMIT = 100;
|
|
33
|
+
/**
|
|
34
|
+
* The total number of pages to add to the processing queue during each sync cycle.
|
|
35
|
+
* This acts as a cap to ensure each sync loop is reasonably short.
|
|
36
|
+
* @default 30
|
|
37
|
+
*/
|
|
38
|
+
export const SYNC_BATCH_SIZE = parseInt(process.env.NOTION_SYNC_BATCH_SIZE ?? '30', 10);
|
|
39
|
+
/**
|
|
40
|
+
* The interval in milliseconds that the main synchronization loop waits after completing.
|
|
41
|
+
* @default 15 minutes
|
|
42
|
+
*/
|
|
43
|
+
export const SYNC_INTERVAL_MS = parseInt(process.env.NOTION_SYNC_INTERVAL_MS ?? `${15 * 60 * 1000}`, 10);
|
|
44
|
+
/**
|
|
45
|
+
* The interval for the local-only garbage collection task, which removes orphaned files.
|
|
46
|
+
* @default 12 hours
|
|
47
|
+
*/
|
|
48
|
+
export const GC_INTERVAL_MS = parseInt(process.env.NOTION_GC_INTERVAL_MS ?? `${6 * 60 * 60 * 1000}`, 10);
|
|
49
|
+
//# sourceMappingURL=config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../../src/lib/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AAEnC,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAA;AAEtD,MAAM,WAAW,GAAG,MAAM,eAAe,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAA;AAE9D;;GAEG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG,OAAO,CAAC,GAAG,CAAC,yBAAyB;IAC/D,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,yBAAyB,CAAC;IAChD,CAAC,CAAC,OAAO,CAAC,WAAW,EAAE,UAAU,CAAC,CAAA;AAEpC;;GAEG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,YAAY,CAAA;AAE1C;;;GAGG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG,OAAO,CAAC,YAAY,EAAE,SAAS,CAAC,CAAA;AAElE;;GAEG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG,OAAO,CAAC,YAAY,EAAE,iBAAiB,CAAC,CAAA;AAEvE;;;GAGG;AACH,MAAM,CAAC,MAAM,8BAA8B,GAAG,GAAG,CAAA;AAEjD;;;GAGG;AACH,MAAM,CAAC,MAAM,uBAAuB,GAAG,GAAG,CAAA;AAE1C;;;;GAIG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG,QAAQ,CAAC,OAAO,CAAC,GAAG,CAAC,sBAAsB,IAAI,IAAI,EAAE,EAAE,CAAC,CAAA;AAEvF;;;GAGG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,QAAQ,CAAC,OAAO,CAAC,GAAG,CAAC,uBAAuB,IAAI,GAAG,EAAE,GAAG,EAAE,GAAG,IAAI,EAAE,EAAE,EAAE,CAAC,CAAA;AAExG;;;GAGG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,QAAQ,CAAC,OAAO,CAAC,GAAG,CAAC,qBAAqB,IAAI,GAAG,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,IAAI,EAAE,EAAE,EAAE,CAAC,CAAA"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { type SyncState } from './sync-state-manager.js';
|
|
2
|
+
/**
|
|
3
|
+
* Manages the continuous, queue-based synchronization of a Notion workspace
|
|
4
|
+
* to a local RAG-compatible directory using a throttled, robust process.
|
|
5
|
+
*/
|
|
6
|
+
export declare class NotionSyncer {
|
|
7
|
+
private readonly notion;
|
|
8
|
+
private readonly throttler;
|
|
9
|
+
private state;
|
|
10
|
+
private syncTimeout;
|
|
11
|
+
private gcTimeout;
|
|
12
|
+
private isSyncing;
|
|
13
|
+
constructor();
|
|
14
|
+
start(): Promise<void>;
|
|
15
|
+
stop(): void;
|
|
16
|
+
getSyncState(): SyncState | undefined;
|
|
17
|
+
triggerImmediateSync(pageId: string): Promise<void>;
|
|
18
|
+
private scheduleNextSync;
|
|
19
|
+
private scheduleNextGc;
|
|
20
|
+
private _runSyncLoop;
|
|
21
|
+
private _buildProcessingQueue;
|
|
22
|
+
private _processQueue;
|
|
23
|
+
private _processPage;
|
|
24
|
+
private _garbageCollect;
|
|
25
|
+
private _deletePageData;
|
|
26
|
+
}
|
|
27
|
+
//# sourceMappingURL=notion-syncer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"notion-syncer.d.ts","sourceRoot":"","sources":["../../src/lib/notion-syncer.ts"],"names":[],"mappings":"AAkBA,OAAO,EAAgC,KAAK,SAAS,EAAE,MAAM,yBAAyB,CAAA;AAItF;;;GAGG;AACH,qBAAa,YAAY;IACvB,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAQ;IAC/B,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAmB;IAC7C,OAAO,CAAC,KAAK,CAAuB;IACpC,OAAO,CAAC,WAAW,CAA4B;IAC/C,OAAO,CAAC,SAAS,CAA4B;IAC7C,OAAO,CAAC,SAAS,CAAQ;;IAOZ,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IAQ5B,IAAI,IAAI,IAAI;IAMZ,YAAY,IAAI,SAAS,GAAG,SAAS;IAI/B,oBAAoB,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAehE,OAAO,CAAC,gBAAgB;IAWxB,OAAO,CAAC,cAAc;YAUR,YAAY;YAeZ,qBAAqB;YAgDrB,aAAa;YAoBb,YAAY;YA8BZ,eAAe;YAuBf,eAAe;CAM9B"}
|
|
@@ -0,0 +1,212 @@
|
|
|
1
|
+
import { rm, readdir, mkdir, writeFile } from 'node:fs/promises';
|
|
2
|
+
import { resolve } from 'node:path';
|
|
3
|
+
import { logger } from '@mcp-monorepo/shared';
|
|
4
|
+
import { ThrottledExecutor } from '@mcp-monorepo/shared';
|
|
5
|
+
import { isFullPage, APIErrorCode, isFullBlock } from '@notionhq/client';
|
|
6
|
+
import { getNotionClient } from './client.js';
|
|
7
|
+
import { GC_INTERVAL_MS, NOTION_API_RATE_LIMIT_DELAY_MS, NOTION_CONTENT_DIR, NOTION_PAGINATION_LIMIT, SYNC_BATCH_SIZE, SYNC_INTERVAL_MS, } from './config.js';
|
|
8
|
+
import { normalizeId } from './id-utils.js';
|
|
9
|
+
import { notionToMarkdown } from './markdown-converter.js';
|
|
10
|
+
import { loadSyncState, saveSyncState } from './sync-state-manager.js';
|
|
11
|
+
const NOTION_URL_REGEX = /https:\/\/www.notion.so\/[a-zA-Z0-9-]+-([a-zA-Z0-9]{32})/g;
|
|
12
|
+
/**
|
|
13
|
+
* Manages the continuous, queue-based synchronization of a Notion workspace
|
|
14
|
+
* to a local RAG-compatible directory using a throttled, robust process.
|
|
15
|
+
*/
|
|
16
|
+
export class NotionSyncer {
|
|
17
|
+
notion;
|
|
18
|
+
throttler;
|
|
19
|
+
state;
|
|
20
|
+
syncTimeout;
|
|
21
|
+
gcTimeout;
|
|
22
|
+
isSyncing = false;
|
|
23
|
+
constructor() {
|
|
24
|
+
this.notion = getNotionClient();
|
|
25
|
+
this.throttler = new ThrottledExecutor(NOTION_API_RATE_LIMIT_DELAY_MS);
|
|
26
|
+
}
|
|
27
|
+
async start() {
|
|
28
|
+
await mkdir(NOTION_CONTENT_DIR, { recursive: true });
|
|
29
|
+
this.state = await loadSyncState();
|
|
30
|
+
logger.info('NotionSyncer started. Scheduling initial sync and GC.');
|
|
31
|
+
this.scheduleNextSync(1000); // Start first sync almost immediately
|
|
32
|
+
this.scheduleNextGc(GC_INTERVAL_MS);
|
|
33
|
+
}
|
|
34
|
+
stop() {
|
|
35
|
+
if (this.syncTimeout)
|
|
36
|
+
clearTimeout(this.syncTimeout);
|
|
37
|
+
if (this.gcTimeout)
|
|
38
|
+
clearTimeout(this.gcTimeout);
|
|
39
|
+
logger.info('NotionSyncer stopped.');
|
|
40
|
+
}
|
|
41
|
+
getSyncState() {
|
|
42
|
+
return this.state;
|
|
43
|
+
}
|
|
44
|
+
async triggerImmediateSync(pageId) {
|
|
45
|
+
const normalizedId = normalizeId(pageId);
|
|
46
|
+
if (!normalizedId || !this.state)
|
|
47
|
+
return;
|
|
48
|
+
logger.info(`Received immediate sync trigger for page: ${normalizedId}`);
|
|
49
|
+
const existingPage = this.state.pages[normalizedId];
|
|
50
|
+
this.state.pages[normalizedId] = {
|
|
51
|
+
...(existingPage ?? { title: undefined, url: undefined }),
|
|
52
|
+
lastEdited: undefined, // Mark as needing processing
|
|
53
|
+
};
|
|
54
|
+
await saveSyncState(this.state);
|
|
55
|
+
}
|
|
56
|
+
scheduleNextSync(delay) {
|
|
57
|
+
if (this.syncTimeout)
|
|
58
|
+
clearTimeout(this.syncTimeout);
|
|
59
|
+
this.syncTimeout = setTimeout(() => {
|
|
60
|
+
this._runSyncLoop().catch((error) => {
|
|
61
|
+
logger.error('Fatal error in sync loop. Rescheduling.', error);
|
|
62
|
+
this.isSyncing = false;
|
|
63
|
+
this.scheduleNextSync(SYNC_INTERVAL_MS);
|
|
64
|
+
});
|
|
65
|
+
}, delay);
|
|
66
|
+
}
|
|
67
|
+
scheduleNextGc(delay) {
|
|
68
|
+
if (this.gcTimeout)
|
|
69
|
+
clearTimeout(this.gcTimeout);
|
|
70
|
+
this.gcTimeout = setTimeout(() => {
|
|
71
|
+
this._garbageCollect().catch((error) => {
|
|
72
|
+
logger.error('Error during garbage collection. Rescheduling.', error);
|
|
73
|
+
this.scheduleNextGc(GC_INTERVAL_MS);
|
|
74
|
+
});
|
|
75
|
+
}, delay);
|
|
76
|
+
}
|
|
77
|
+
async _runSyncLoop() {
|
|
78
|
+
if (this.isSyncing)
|
|
79
|
+
return;
|
|
80
|
+
this.isSyncing = true;
|
|
81
|
+
logger.info('Starting sync loop...');
|
|
82
|
+
try {
|
|
83
|
+
const processingQueue = await this._buildProcessingQueue();
|
|
84
|
+
await this._processQueue(processingQueue);
|
|
85
|
+
}
|
|
86
|
+
finally {
|
|
87
|
+
this.isSyncing = false;
|
|
88
|
+
logger.info('Sync loop finished.');
|
|
89
|
+
this.scheduleNextSync(SYNC_INTERVAL_MS);
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
async _buildProcessingQueue() {
|
|
93
|
+
if (!this.state)
|
|
94
|
+
return [];
|
|
95
|
+
const queue = new Set();
|
|
96
|
+
// Priority 1: Pages discovered but never processed
|
|
97
|
+
for (const [pageId, pageInfo] of Object.entries(this.state.pages)) {
|
|
98
|
+
if (pageInfo.lastEdited === undefined) {
|
|
99
|
+
queue.add(pageId);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
logger.info(`Found ${queue.size} unprocessed (discovered) pages.`);
|
|
103
|
+
if (queue.size >= SYNC_BATCH_SIZE) {
|
|
104
|
+
return Array.from(queue).slice(0, SYNC_BATCH_SIZE);
|
|
105
|
+
}
|
|
106
|
+
// Priority 2: Find recently changed pages via search API
|
|
107
|
+
let hasMore = true;
|
|
108
|
+
let nextCursor;
|
|
109
|
+
while (queue.size < SYNC_BATCH_SIZE && hasMore) {
|
|
110
|
+
const response = await this.throttler.execute(() => this.notion.search({
|
|
111
|
+
sort: { direction: 'descending', timestamp: 'last_edited_time' },
|
|
112
|
+
page_size: NOTION_PAGINATION_LIMIT,
|
|
113
|
+
start_cursor: nextCursor,
|
|
114
|
+
}));
|
|
115
|
+
for (const page of response.results) {
|
|
116
|
+
if (queue.size >= SYNC_BATCH_SIZE)
|
|
117
|
+
break;
|
|
118
|
+
if (isFullPage(page)) {
|
|
119
|
+
const existingPage = this.state.pages[page.id];
|
|
120
|
+
if (!existingPage) {
|
|
121
|
+
this.state.pages[page.id] = { lastEdited: undefined, title: undefined, url: undefined };
|
|
122
|
+
queue.add(page.id);
|
|
123
|
+
}
|
|
124
|
+
else if (existingPage.lastEdited !== page.last_edited_time) {
|
|
125
|
+
queue.add(page.id);
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
hasMore = response.has_more;
|
|
130
|
+
nextCursor = response.next_cursor ?? undefined;
|
|
131
|
+
}
|
|
132
|
+
await saveSyncState(this.state);
|
|
133
|
+
return Array.from(queue);
|
|
134
|
+
}
|
|
135
|
+
async _processQueue(queue) {
|
|
136
|
+
if (queue.length === 0)
|
|
137
|
+
return;
|
|
138
|
+
if (!this.state)
|
|
139
|
+
throw new Error('Sync state not initialized.');
|
|
140
|
+
logger.info(`Sync state contains ${Object.keys(this.state.pages).length} pages. ${queue.length} will be processed.`);
|
|
141
|
+
for (const pageId of queue) {
|
|
142
|
+
try {
|
|
143
|
+
await this._processPage(pageId);
|
|
144
|
+
await saveSyncState(this.state);
|
|
145
|
+
}
|
|
146
|
+
catch (error) {
|
|
147
|
+
if (typeof error === 'object' && error && 'code' in error && error.code === APIErrorCode.ObjectNotFound) {
|
|
148
|
+
logger.info(`Page ${pageId} not found on Notion during processing. Deleting.`);
|
|
149
|
+
await this._deletePageData(pageId);
|
|
150
|
+
}
|
|
151
|
+
else {
|
|
152
|
+
logger.error(`Failed to process page ${pageId}. It will be retried in a future cycle.`, error);
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
async _processPage(pageId) {
|
|
158
|
+
if (!this.state)
|
|
159
|
+
throw new Error('Sync state not initialized.');
|
|
160
|
+
const page = await this.throttler.execute(() => this.notion.pages.retrieve({ page_id: pageId }));
|
|
161
|
+
if (!isFullPage(page))
|
|
162
|
+
return;
|
|
163
|
+
const blocks = await this.throttler.execute(() => this.notion.blocks.children.list({ block_id: page.id }));
|
|
164
|
+
const markdownContent = await notionToMarkdown(blocks.results.filter(isFullBlock));
|
|
165
|
+
const titleProperty = Object.values(page.properties).find((prop) => prop.type === 'title');
|
|
166
|
+
const title = titleProperty?.type === 'title' && titleProperty.title[0]?.plain_text
|
|
167
|
+
? titleProperty.title[0].plain_text
|
|
168
|
+
: 'Untitled';
|
|
169
|
+
await writeFile(resolve(NOTION_CONTENT_DIR, `${page.id}.md`), `# ${title}\n\n${markdownContent}`, 'utf-8');
|
|
170
|
+
this.state.pages[page.id] = { lastEdited: page.last_edited_time, title, url: page.url };
|
|
171
|
+
const blockString = JSON.stringify(blocks.results);
|
|
172
|
+
const matches = blockString.matchAll(NOTION_URL_REGEX);
|
|
173
|
+
for (const match of matches) {
|
|
174
|
+
const childId = normalizeId(match[1]);
|
|
175
|
+
if (childId && !this.state.pages[childId]) {
|
|
176
|
+
logger.info(`Discovered new child page ${childId}. It will be processed in a future cycle.`);
|
|
177
|
+
this.state.pages[childId] = { lastEdited: undefined, title: undefined, url: undefined };
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
async _garbageCollect() {
|
|
182
|
+
if (!this.state)
|
|
183
|
+
return;
|
|
184
|
+
logger.info('Running local file garbage collection...');
|
|
185
|
+
let stateWasChanged = false;
|
|
186
|
+
try {
|
|
187
|
+
const localFileIds = (await readdir(NOTION_CONTENT_DIR)).map((name) => name.replace('.md', ''));
|
|
188
|
+
for (const fileId of localFileIds) {
|
|
189
|
+
if (!this.state.pages[fileId]) {
|
|
190
|
+
logger.info(`GC: Deleting orphaned local file: ${fileId}.md`);
|
|
191
|
+
await rm(resolve(NOTION_CONTENT_DIR, `${fileId}.md`));
|
|
192
|
+
stateWasChanged = true;
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
catch (error) {
|
|
197
|
+
logger.error('Error during local file garbage collection.', error);
|
|
198
|
+
}
|
|
199
|
+
if (stateWasChanged) {
|
|
200
|
+
await saveSyncState(this.state);
|
|
201
|
+
}
|
|
202
|
+
this.scheduleNextGc(GC_INTERVAL_MS);
|
|
203
|
+
}
|
|
204
|
+
async _deletePageData(pageId) {
|
|
205
|
+
if (!this.state)
|
|
206
|
+
return;
|
|
207
|
+
delete this.state.pages[pageId];
|
|
208
|
+
await rm(resolve(NOTION_CONTENT_DIR, `${pageId}.md`), { force: true });
|
|
209
|
+
await saveSyncState(this.state);
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
//# sourceMappingURL=notion-syncer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"notion-syncer.js","sourceRoot":"","sources":["../../src/lib/notion-syncer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAE,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAA;AAChE,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AAEnC,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAA;AAC7C,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAA;AACxD,OAAO,EAAE,UAAU,EAAE,YAAY,EAAe,WAAW,EAAE,MAAM,kBAAkB,CAAA;AAErF,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAA;AAC7C,OAAO,EACL,cAAc,EACd,8BAA8B,EAC9B,kBAAkB,EAClB,uBAAuB,EACvB,eAAe,EACf,gBAAgB,GACjB,MAAM,aAAa,CAAA;AACpB,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAA;AAC3C,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAA;AAC1D,OAAO,EAAE,aAAa,EAAE,aAAa,EAAkB,MAAM,yBAAyB,CAAA;AAEtF,MAAM,gBAAgB,GAAG,2DAA2D,CAAA;AAEpF;;;GAGG;AACH,MAAM,OAAO,YAAY;IACN,MAAM,CAAQ;IACd,SAAS,CAAmB;IACrC,KAAK,CAAuB;IAC5B,WAAW,CAA4B;IACvC,SAAS,CAA4B;IACrC,SAAS,GAAG,KAAK,CAAA;IAEzB;QACE,IAAI,CAAC,MAAM,GAAG,eAAe,EAAE,CAAA;QAC/B,IAAI,CAAC,SAAS,GAAG,IAAI,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AAM,CAAC,CAAA;QAC/B,MAAM,EAAE,CAAC,OAAO,CAAC,kBAAkB,EAAE,GAAG,MAAM,KAAK,CAAC,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAA;QACtE,MAAM,aAAa,CAAC,IAAI,CAAC,KAAK,CAAC,CAAA;IACjC,CAAC;CACF"}
|
|
@@ -2,24 +2,22 @@ import { type CreatePageParameters, type UpdatePageParameters } from '@notionhq/
|
|
|
2
2
|
import { type DataSourceObjectResponse } from '@notionhq/client/build/src/api-endpoints.js';
|
|
3
3
|
type DataSourceSchema = DataSourceObjectResponse['properties'];
|
|
4
4
|
type NotionProperties = CreatePageParameters['properties'];
|
|
5
|
+
type NotionUpdateProperties = UpdatePageParameters['properties'];
|
|
5
6
|
/**
|
|
6
7
|
* Parses a flat properties object from the 'create-pages' tool input
|
|
7
8
|
* into the format required by the Notion API.
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
* @param properties - A flat key-value map of properties from the tool input [1].
|
|
13
|
-
* @param dataSourceSchema - The schema of the parent data source, used to determine property types [6].
|
|
14
|
-
* @returns A Notion `CreatePageParameters['properties']` object ready for the API [9].
|
|
9
|
+
* @param properties - A flat key-value map of properties from the tool input.
|
|
10
|
+
* @param dataSourceSchema - The schema of the parent data source.
|
|
11
|
+
* @returns A Notion `CreatePageParameters['properties']` object.
|
|
15
12
|
*/
|
|
16
13
|
export declare function parsePropertiesForCreate(properties: Record<string, string | number | boolean | null>, dataSourceSchema?: DataSourceSchema): NotionProperties;
|
|
17
14
|
/**
|
|
18
15
|
* Parses a flat properties object with special keys (e.g., 'date:deadline:start')
|
|
19
16
|
* from the 'update-page' tool input into the format required by the Notion API.
|
|
20
|
-
* @param properties - A flat key-value map with special-cased keys.
|
|
21
|
-
* @
|
|
17
|
+
* @param properties - A flat key-value map with special-cased keys from the tool input [1].
|
|
18
|
+
* @param schema - The schema of the data source the page belongs to.
|
|
19
|
+
* @returns A Notion `NotionUpdateProperties` object.
|
|
22
20
|
*/
|
|
23
|
-
export declare function parsePropertiesForUpdate(
|
|
21
|
+
export declare function parsePropertiesForUpdate(properties: Record<string, string | number | boolean | null>, schema: DataSourceSchema): NotionUpdateProperties;
|
|
24
22
|
export {};
|
|
25
23
|
//# sourceMappingURL=property-parser.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"property-parser.d.ts","sourceRoot":"","sources":["../../src/lib/property-parser.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,oBAAoB,EAAE,KAAK,oBAAoB,EAAE,MAAM,kBAAkB,CAAA;AACvF,OAAO,EAAE,KAAK,wBAAwB,EAAE,MAAM,6CAA6C,CAAA;AAE3F,KAAK,gBAAgB,GAAG,wBAAwB,CAAC,YAAY,CAAC,CAAA;AAC9D,KAAK,gBAAgB,GAAG,oBAAoB,CAAC,YAAY,CAAC,CAAA;
|
|
1
|
+
{"version":3,"file":"property-parser.d.ts","sourceRoot":"","sources":["../../src/lib/property-parser.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,oBAAoB,EAAE,KAAK,oBAAoB,EAAE,MAAM,kBAAkB,CAAA;AACvF,OAAO,EAAE,KAAK,wBAAwB,EAAE,MAAM,6CAA6C,CAAA;AAE3F,KAAK,gBAAgB,GAAG,wBAAwB,CAAC,YAAY,CAAC,CAAA;AAC9D,KAAK,gBAAgB,GAAG,oBAAoB,CAAC,YAAY,CAAC,CAAA;AAC1D,KAAK,sBAAsB,GAAG,oBAAoB,CAAC,YAAY,CAAC,CAAA;AAEhE;;;;;;GAMG;AACH,wBAAgB,wBAAwB,CACtC,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,IAAI,CAAC,EAC5D,gBAAgB,CAAC,EAAE,gBAAgB,GAClC,gBAAgB,CA2FlB;AAED;;;;;;GAMG;AACH,wBAAgB,wBAAwB,CACtC,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,IAAI,CAAC,EAC5D,MAAM,EAAE,gBAAgB,GACvB,sBAAsB,CAoHxB"}
|
|
@@ -2,13 +2,9 @@ import { logger } from '@mcp-monorepo/shared';
|
|
|
2
2
|
/**
|
|
3
3
|
* Parses a flat properties object from the 'create-pages' tool input
|
|
4
4
|
* into the format required by the Notion API.
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
* @param properties - A flat key-value map of properties from the tool input [1].
|
|
10
|
-
* @param dataSourceSchema - The schema of the parent data source, used to determine property types [6].
|
|
11
|
-
* @returns A Notion `CreatePageParameters['properties']` object ready for the API [9].
|
|
5
|
+
* @param properties - A flat key-value map of properties from the tool input.
|
|
6
|
+
* @param dataSourceSchema - The schema of the parent data source.
|
|
7
|
+
* @returns A Notion `CreatePageParameters['properties']` object.
|
|
12
8
|
*/
|
|
13
9
|
export function parsePropertiesForCreate(properties, dataSourceSchema) {
|
|
14
10
|
const notionProperties = {};
|
|
@@ -100,14 +96,105 @@ export function parsePropertiesForCreate(properties, dataSourceSchema) {
|
|
|
100
96
|
/**
|
|
101
97
|
* Parses a flat properties object with special keys (e.g., 'date:deadline:start')
|
|
102
98
|
* from the 'update-page' tool input into the format required by the Notion API.
|
|
103
|
-
* @param properties - A flat key-value map with special-cased keys.
|
|
104
|
-
* @
|
|
99
|
+
* @param properties - A flat key-value map with special-cased keys from the tool input [1].
|
|
100
|
+
* @param schema - The schema of the data source the page belongs to.
|
|
101
|
+
* @returns A Notion `NotionUpdateProperties` object.
|
|
105
102
|
*/
|
|
106
|
-
export function parsePropertiesForUpdate(
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
//
|
|
110
|
-
|
|
111
|
-
|
|
103
|
+
export function parsePropertiesForUpdate(properties, schema) {
|
|
104
|
+
const notionProperties = {};
|
|
105
|
+
const groupedComplexProps = {};
|
|
106
|
+
// 1. Group complex, colon-separated properties like 'date' and 'place' [1].
|
|
107
|
+
for (const [key, value] of Object.entries(properties)) {
|
|
108
|
+
const parts = key.split(':');
|
|
109
|
+
if (parts.length > 1 && (parts[0] === 'date' || parts[0] === 'place')) {
|
|
110
|
+
const [type, propName, ...rest] = parts;
|
|
111
|
+
const part = rest.join(':'); // Join the rest in case property name has a colon
|
|
112
|
+
if (!groupedComplexProps[propName]) {
|
|
113
|
+
groupedComplexProps[propName] = { type: type, data: {} };
|
|
114
|
+
}
|
|
115
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
116
|
+
// @ts-ignore
|
|
117
|
+
groupedComplexProps[propName].data[part] = value;
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
// 2. Process grouped complex properties
|
|
121
|
+
for (const [name, { type, data }] of Object.entries(groupedComplexProps)) {
|
|
122
|
+
if (type === 'date') {
|
|
123
|
+
const dateObj = { start: data.start };
|
|
124
|
+
if (data.end)
|
|
125
|
+
dateObj.end = data.end;
|
|
126
|
+
// eslint-disable-next-line
|
|
127
|
+
notionProperties[name] = { date: data.start === null ? null : dateObj };
|
|
128
|
+
}
|
|
129
|
+
else if (type === 'place') {
|
|
130
|
+
// For a place to be valid, latitude and longitude are required [11].
|
|
131
|
+
if (typeof data.latitude === 'number' && typeof data.longitude === 'number') {
|
|
132
|
+
const placeObj = {
|
|
133
|
+
lat: data.latitude,
|
|
134
|
+
lon: data.longitude,
|
|
135
|
+
};
|
|
136
|
+
if (data.name)
|
|
137
|
+
placeObj.name = String(data.name);
|
|
138
|
+
if (data.address)
|
|
139
|
+
placeObj.address = String(data.address);
|
|
140
|
+
if (data.google_place_id)
|
|
141
|
+
placeObj.google_place_id = String(data.google_place_id);
|
|
142
|
+
notionProperties[name] = { place: placeObj };
|
|
143
|
+
}
|
|
144
|
+
else {
|
|
145
|
+
logger.warn(`Skipping place property "${name}" due to missing or invalid latitude/longitude.`);
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
// 3. Process simple and standard properties
|
|
150
|
+
for (const [name, value] of Object.entries(properties)) {
|
|
151
|
+
if (name.includes(':'))
|
|
152
|
+
continue; // Skip keys already processed in the grouping step.
|
|
153
|
+
const propSchema = schema[name];
|
|
154
|
+
const propType = propSchema?.type ?? (name.toLowerCase() === 'title' ? 'title' : undefined);
|
|
155
|
+
if (!propType) {
|
|
156
|
+
logger.warn(`Could not determine type for property "${name}". Skipping update.`);
|
|
157
|
+
continue;
|
|
158
|
+
}
|
|
159
|
+
/* eslint-disable no-restricted-syntax */
|
|
160
|
+
switch (propType) {
|
|
161
|
+
case 'title':
|
|
162
|
+
notionProperties[name] = { title: [{ text: { content: String(value) } }] };
|
|
163
|
+
break;
|
|
164
|
+
case 'rich_text':
|
|
165
|
+
notionProperties[name] = { rich_text: [{ text: { content: String(value ?? '') } }] };
|
|
166
|
+
break;
|
|
167
|
+
case 'number':
|
|
168
|
+
notionProperties[name] = { number: value === null ? null : Number(value) };
|
|
169
|
+
break;
|
|
170
|
+
case 'select':
|
|
171
|
+
notionProperties[name] = { select: value === null ? null : { name: String(value) } };
|
|
172
|
+
break;
|
|
173
|
+
case 'status':
|
|
174
|
+
notionProperties[name] = { status: value === null ? null : { name: String(value) } };
|
|
175
|
+
break;
|
|
176
|
+
case 'checkbox': {
|
|
177
|
+
const boolValue = String(value).toLowerCase() === '__yes__' || String(value).toLowerCase() === 'true';
|
|
178
|
+
notionProperties[name] = { checkbox: boolValue };
|
|
179
|
+
break;
|
|
180
|
+
}
|
|
181
|
+
case 'url':
|
|
182
|
+
notionProperties[name] = { url: value === null ? null : String(value) };
|
|
183
|
+
break;
|
|
184
|
+
case 'email':
|
|
185
|
+
notionProperties[name] = { email: value === null ? null : String(value) };
|
|
186
|
+
break;
|
|
187
|
+
case 'phone_number':
|
|
188
|
+
notionProperties[name] = { phone_number: value === null ? null : String(value) };
|
|
189
|
+
break;
|
|
190
|
+
default:
|
|
191
|
+
if (!Object.keys(groupedComplexProps).includes(name)) {
|
|
192
|
+
logger.warn(`Updates for property type "${propType}" are not supported. Skipping "${name}".`);
|
|
193
|
+
}
|
|
194
|
+
break;
|
|
195
|
+
}
|
|
196
|
+
/* eslint-enable no-restricted-syntax */
|
|
197
|
+
}
|
|
198
|
+
return notionProperties;
|
|
112
199
|
}
|
|
113
200
|
//# sourceMappingURL=property-parser.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"property-parser.js","sourceRoot":"","sources":["../../src/lib/property-parser.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAA;
|
|
1
|
+
{"version":3,"file":"property-parser.js","sourceRoot":"","sources":["../../src/lib/property-parser.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAA;AAQ7C;;;;;;GAMG;AACH,MAAM,UAAU,wBAAwB,CACtC,UAA4D,EAC5D,gBAAmC;IAEnC,MAAM,gBAAgB,GAAqB,EAAE,CAAA;IAE7C,4EAA4E;IAC5E,MAAM,cAAc,GAAG,gBAAgB;QACrC,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,gBAAgB,CAAC,CAAC,IAAI,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,gBAAgB,CAAC,GAAG,CAAC,EAAE,IAAI,KAAK,OAAO,CAAC;QACtF,CAAC,CAAC,OAAO,CAAA;IAEX,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,UAAU,CAAC,EAAE,CAAC;QACtD,8DAA8D;QAC9D,IAAI,KAAK,KAAK,IAAI,IAAI,KAAK,KAAK,SAAS;YAAE,SAAQ;QAEnD,4FAA4F;QAC5F,IAAI,GAAG,CAAC,WAAW,EAAE,KAAK,OAAO,IAAI,cAAc,EAAE,CAAC;YACpD,gBAAgB,CAAC,cAAc,CAAC,GAAG;gBACjC,KAAK,EAAE,CAAC,EAAE,IAAI,EAAE,EAAE,OAA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