@stoneforge/quarry 1.13.0 → 1.14.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 (124) hide show
  1. package/dist/api/quarry-api.d.ts +9 -1
  2. package/dist/api/quarry-api.d.ts.map +1 -1
  3. package/dist/api/quarry-api.js +21 -2
  4. package/dist/api/quarry-api.js.map +1 -1
  5. package/dist/api/types.d.ts +8 -1
  6. package/dist/api/types.d.ts.map +1 -1
  7. package/dist/api/types.js.map +1 -1
  8. package/dist/cli/commands/auto-link-helper.d.ts.map +1 -1
  9. package/dist/cli/commands/auto-link-helper.js +1 -0
  10. package/dist/cli/commands/auto-link-helper.js.map +1 -1
  11. package/dist/cli/commands/crud.d.ts +2 -0
  12. package/dist/cli/commands/crud.d.ts.map +1 -1
  13. package/dist/cli/commands/crud.js +100 -10
  14. package/dist/cli/commands/crud.js.map +1 -1
  15. package/dist/cli/commands/docs.js +2 -2
  16. package/dist/cli/commands/docs.js.map +1 -1
  17. package/dist/cli/commands/document.js +1 -1
  18. package/dist/cli/commands/document.js.map +1 -1
  19. package/dist/cli/commands/entity.js +1 -1
  20. package/dist/cli/commands/entity.js.map +1 -1
  21. package/dist/cli/commands/external-sync.d.ts +6 -5
  22. package/dist/cli/commands/external-sync.d.ts.map +1 -1
  23. package/dist/cli/commands/external-sync.js +1032 -180
  24. package/dist/cli/commands/external-sync.js.map +1 -1
  25. package/dist/cli/commands/library.js +1 -1
  26. package/dist/cli/commands/library.js.map +1 -1
  27. package/dist/cli/commands/message.js +2 -2
  28. package/dist/cli/commands/message.js.map +1 -1
  29. package/dist/cli/commands/serve.d.ts.map +1 -1
  30. package/dist/cli/commands/serve.js +2 -0
  31. package/dist/cli/commands/serve.js.map +1 -1
  32. package/dist/cli/commands/task.d.ts.map +1 -1
  33. package/dist/cli/commands/task.js +7 -4
  34. package/dist/cli/commands/task.js.map +1 -1
  35. package/dist/cli/commands/team.js +1 -1
  36. package/dist/cli/commands/team.js.map +1 -1
  37. package/dist/cli/commands/workflow.js +1 -1
  38. package/dist/cli/commands/workflow.js.map +1 -1
  39. package/dist/cli/utils/progress.d.ts +30 -0
  40. package/dist/cli/utils/progress.d.ts.map +1 -0
  41. package/dist/cli/utils/progress.js +47 -0
  42. package/dist/cli/utils/progress.js.map +1 -0
  43. package/dist/config/config.d.ts.map +1 -1
  44. package/dist/config/config.js +6 -0
  45. package/dist/config/config.js.map +1 -1
  46. package/dist/config/defaults.d.ts.map +1 -1
  47. package/dist/config/defaults.js +1 -0
  48. package/dist/config/defaults.js.map +1 -1
  49. package/dist/config/file.d.ts.map +1 -1
  50. package/dist/config/file.js +10 -0
  51. package/dist/config/file.js.map +1 -1
  52. package/dist/config/merge.d.ts.map +1 -1
  53. package/dist/config/merge.js +7 -1
  54. package/dist/config/merge.js.map +1 -1
  55. package/dist/config/types.d.ts +7 -2
  56. package/dist/config/types.d.ts.map +1 -1
  57. package/dist/config/types.js +3 -0
  58. package/dist/config/types.js.map +1 -1
  59. package/dist/config/validation.d.ts.map +1 -1
  60. package/dist/config/validation.js +13 -0
  61. package/dist/config/validation.js.map +1 -1
  62. package/dist/external-sync/adapters/document-sync-adapter.d.ts +150 -0
  63. package/dist/external-sync/adapters/document-sync-adapter.d.ts.map +1 -0
  64. package/dist/external-sync/adapters/document-sync-adapter.js +325 -0
  65. package/dist/external-sync/adapters/document-sync-adapter.js.map +1 -0
  66. package/dist/external-sync/index.d.ts +3 -0
  67. package/dist/external-sync/index.d.ts.map +1 -1
  68. package/dist/external-sync/index.js +4 -0
  69. package/dist/external-sync/index.js.map +1 -1
  70. package/dist/external-sync/provider-registry.d.ts +7 -3
  71. package/dist/external-sync/provider-registry.d.ts.map +1 -1
  72. package/dist/external-sync/provider-registry.js +20 -3
  73. package/dist/external-sync/provider-registry.js.map +1 -1
  74. package/dist/external-sync/providers/folder/folder-document-adapter.d.ts +97 -0
  75. package/dist/external-sync/providers/folder/folder-document-adapter.d.ts.map +1 -0
  76. package/dist/external-sync/providers/folder/folder-document-adapter.js +261 -0
  77. package/dist/external-sync/providers/folder/folder-document-adapter.js.map +1 -0
  78. package/dist/external-sync/providers/folder/folder-fs.d.ts +146 -0
  79. package/dist/external-sync/providers/folder/folder-fs.d.ts.map +1 -0
  80. package/dist/external-sync/providers/folder/folder-fs.js +300 -0
  81. package/dist/external-sync/providers/folder/folder-fs.js.map +1 -0
  82. package/dist/external-sync/providers/folder/folder-provider.d.ts +28 -0
  83. package/dist/external-sync/providers/folder/folder-provider.d.ts.map +1 -0
  84. package/dist/external-sync/providers/folder/folder-provider.js +87 -0
  85. package/dist/external-sync/providers/folder/folder-provider.js.map +1 -0
  86. package/dist/external-sync/providers/folder/index.d.ts +11 -0
  87. package/dist/external-sync/providers/folder/index.d.ts.map +1 -0
  88. package/dist/external-sync/providers/folder/index.js +13 -0
  89. package/dist/external-sync/providers/folder/index.js.map +1 -0
  90. package/dist/external-sync/providers/index.d.ts +4 -0
  91. package/dist/external-sync/providers/index.d.ts.map +1 -1
  92. package/dist/external-sync/providers/index.js +5 -0
  93. package/dist/external-sync/providers/index.js.map +1 -1
  94. package/dist/external-sync/providers/notion/index.d.ts +19 -0
  95. package/dist/external-sync/providers/notion/index.d.ts.map +1 -0
  96. package/dist/external-sync/providers/notion/index.js +20 -0
  97. package/dist/external-sync/providers/notion/index.js.map +1 -0
  98. package/dist/external-sync/providers/notion/notion-api.d.ts +253 -0
  99. package/dist/external-sync/providers/notion/notion-api.d.ts.map +1 -0
  100. package/dist/external-sync/providers/notion/notion-api.js +492 -0
  101. package/dist/external-sync/providers/notion/notion-api.js.map +1 -0
  102. package/dist/external-sync/providers/notion/notion-blocks.d.ts +93 -0
  103. package/dist/external-sync/providers/notion/notion-blocks.d.ts.map +1 -0
  104. package/dist/external-sync/providers/notion/notion-blocks.js +773 -0
  105. package/dist/external-sync/providers/notion/notion-blocks.js.map +1 -0
  106. package/dist/external-sync/providers/notion/notion-document-adapter.d.ts +176 -0
  107. package/dist/external-sync/providers/notion/notion-document-adapter.d.ts.map +1 -0
  108. package/dist/external-sync/providers/notion/notion-document-adapter.js +413 -0
  109. package/dist/external-sync/providers/notion/notion-document-adapter.js.map +1 -0
  110. package/dist/external-sync/providers/notion/notion-provider.d.ts +57 -0
  111. package/dist/external-sync/providers/notion/notion-provider.d.ts.map +1 -0
  112. package/dist/external-sync/providers/notion/notion-provider.js +159 -0
  113. package/dist/external-sync/providers/notion/notion-provider.js.map +1 -0
  114. package/dist/external-sync/providers/notion/notion-types.d.ts +388 -0
  115. package/dist/external-sync/providers/notion/notion-types.d.ts.map +1 -0
  116. package/dist/external-sync/providers/notion/notion-types.js +47 -0
  117. package/dist/external-sync/providers/notion/notion-types.js.map +1 -0
  118. package/dist/external-sync/sync-engine.d.ts +70 -4
  119. package/dist/external-sync/sync-engine.d.ts.map +1 -1
  120. package/dist/external-sync/sync-engine.js +436 -67
  121. package/dist/external-sync/sync-engine.js.map +1 -1
  122. package/dist/server/index.js +8 -8
  123. package/dist/server/index.js.map +1 -1
  124. package/package.json +4 -12
@@ -0,0 +1 @@
1
+ {"version":3,"file":"notion-blocks.js","sourceRoot":"","sources":["../../../../src/external-sync/providers/notion/notion-blocks.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAOH,OAAO,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAExD,+EAA+E;AAC/E,mDAAmD;AACnD,+EAA+E;AAE/E;;;GAGG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAG,IAAI,CAAC;AAE3C;;;;;GAKG;AACH,MAAM,CAAC,MAAM,iCAAiC,GAAG,GAAG,CAAC;AAErD;;;GAGG;AACH,SAAS,yBAAyB,CAChC,IAAY,EACZ,SAAS,GAAG,sBAAsB;IAElC,IAAI,IAAI,CAAC,MAAM,IAAI,SAAS,EAAE,CAAC;QAC7B,OAAO,CAAC,IAAI,CAAC,CAAC;IAChB,CAAC;IAED,MAAM,MAAM,GAAa,EAAE,CAAC;IAC5B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I,EAAE,QAAQ;IACd,IAAI,EAAE,IAAI;IACV,QAAQ,EAAE,IAAI;IACd,QAAQ,EAAE,IAAI;IACd,OAAO,EAAE,MAAM;IACf,IAAI,EAAE,UAAU;IAChB,MAAM,EAAE,YAAY;IACpB,KAAK,EAAE,YAAY;IACnB,WAAW,EAAE,YAAY;IACzB,EAAE,EAAE,YAAY;CACjB,CAAC;AAEF;;;;;;GAMG;AACH,MAAM,UAAU,mBAAmB,CAAC,IAAY;IAC9C,MAAM,KAAK,GAAG,IAAI,CAAC,WAAW,EAAE,CAAC,IAAI,EAAE,CAAC;IACxC,IAAI,gBAAgB,CAAC,GAAG,CAAC,KAAK,CAAC;QAAE,OAAO,KAAK,CAAC;IAC9C,IAAI,gBAAgB,CAAC,KAAK,CAAC;QAAE,OAAO,gBAAgB,CAAC,KAAK,CAAC,CAAC;IAC5D,OAAO,YAAY,CAAC,CAAC,gBAAgB;AACvC,CAAC;AAED;;;GAGG;AACH,SAAS,iBAAiB,CAAC,IAAY;IACrC,OAAO,mBAAmB,CAAC,IAAI,CAAC,CAAC;AACnC,CAAC"}
@@ -0,0 +1,176 @@
1
+ /**
2
+ * Notion Document Sync Adapter
3
+ *
4
+ * Implements the DocumentSyncAdapter interface for Notion pages.
5
+ * Converts between Stoneforge documents and Notion pages using the
6
+ * Notion API client and the blocks ↔ markdown converter.
7
+ *
8
+ * Key operations:
9
+ * - getPage: Fetch a page's properties and blocks, convert to ExternalDocument
10
+ * - listPagesSince: Query a database for recently edited pages
11
+ * - createPage: Convert markdown to Notion blocks, create page with properties
12
+ * - updatePage: Update page properties and/or replace content blocks
13
+ *
14
+ * The adapter expects:
15
+ * - `project` = Notion database ID
16
+ * - `externalId` = Notion page ID
17
+ *
18
+ * Schema discovery:
19
+ * The adapter discovers the database schema on first use via GET /databases/{id}.
20
+ * Every Notion database has exactly one property of type "title", but its name
21
+ * varies (common names: "Name", "Title"). The adapter discovers and caches this
22
+ * name rather than hardcoding it.
23
+ *
24
+ * Optional properties (Category as select, Tags as multi_select, Library as
25
+ * select) are only included in page properties when the database schema
26
+ * confirms they exist. If they don't exist, the adapter attempts to auto-create
27
+ * them via PATCH /databases/{id}. If that fails (e.g., insufficient
28
+ * permissions), they are silently skipped.
29
+ */
30
+ import type { DocumentSyncAdapter, ExternalDocument, ExternalDocumentInput } from '@stoneforge/core';
31
+ import type { Timestamp } from '@stoneforge/core';
32
+ import type { NotionProperty, NotionDatabaseSchema } from './notion-types.js';
33
+ import { NotionApiClient } from './notion-api.js';
34
+ /**
35
+ * Extracts the title from a Notion page's properties.
36
+ *
37
+ * Searches through all properties for one of type 'title', then
38
+ * concatenates the plain_text of all rich text elements within it.
39
+ *
40
+ * @param properties - The page's properties record
41
+ * @returns The page title, or empty string if no title property is found
42
+ */
43
+ export declare function extractTitleFromProperties(properties: Record<string, NotionProperty>): string;
44
+ /**
45
+ * Builds Notion page properties for creating or updating a page.
46
+ *
47
+ * Uses the discovered database schema to:
48
+ * - Set the title on the correct property (discovered name, not hardcoded)
49
+ * - Only include Category, Tags, and Library if the database schema confirms they exist
50
+ *
51
+ * @param title - The page title
52
+ * @param schema - The discovered database schema with property availability info
53
+ * @param category - Optional category for the Category select property
54
+ * @param tags - Optional tags for the Tags multi_select property
55
+ * @param libraryPath - Optional library path for the Library select property
56
+ * @returns A properties record suitable for the Notion API
57
+ */
58
+ export declare function buildPageProperties(title: string, schema: NotionDatabaseSchema, category?: string, tags?: readonly string[], libraryPath?: string): Record<string, unknown>;
59
+ /**
60
+ * DocumentSyncAdapter implementation for Notion.
61
+ *
62
+ * Uses the NotionApiClient for all API interactions and the
63
+ * blocks ↔ markdown converter for content transformation.
64
+ *
65
+ * On first use of createPage() or updatePage(), the adapter discovers the
66
+ * database schema to find the title property name and check which optional
67
+ * properties exist. The schema is cached per database ID, so only one
68
+ * getDatabase() call is made per adapter instance per database.
69
+ *
70
+ * @example
71
+ * ```typescript
72
+ * const api = new NotionApiClient({ token: 'ntn_...' });
73
+ * const adapter = new NotionDocumentAdapter(api);
74
+ *
75
+ * // Fetch a page
76
+ * const doc = await adapter.getPage('database-id', 'page-id');
77
+ *
78
+ * // List recently edited pages
79
+ * const docs = await adapter.listPagesSince('database-id', '2024-01-01T00:00:00Z');
80
+ *
81
+ * // Create a new page (schema is discovered automatically)
82
+ * const newDoc = await adapter.createPage('database-id', {
83
+ * title: 'New Page',
84
+ * content: '# Hello\n\nWorld',
85
+ * contentType: 'markdown',
86
+ * });
87
+ * ```
88
+ */
89
+ export declare class NotionDocumentAdapter implements DocumentSyncAdapter {
90
+ private readonly api;
91
+ /** Cached database schemas keyed by database ID */
92
+ private readonly schemaCache;
93
+ constructor(api: NotionApiClient);
94
+ /**
95
+ * Discover and cache the database schema for a given database ID.
96
+ *
97
+ * Fetches the database schema from the Notion API, discovers the title
98
+ * property name (every database has exactly one property of type 'title'),
99
+ * and checks for the existence of Category (select), Tags (multi_select),
100
+ * and Library (select) properties.
101
+ *
102
+ * If Category, Tags, or Library properties don't exist, attempts to
103
+ * auto-create them via PATCH /databases/{id}. If the integration lacks
104
+ * permission, the properties are simply skipped — no error is thrown.
105
+ *
106
+ * Results are cached per database ID so only one API call is made per
107
+ * adapter instance per database.
108
+ *
109
+ * @param databaseId - The Notion database ID to discover
110
+ * @returns The discovered database schema
111
+ * @throws Error if the database has no title property
112
+ */
113
+ getDatabaseSchema(databaseId: string): Promise<NotionDatabaseSchema>;
114
+ /**
115
+ * Fetch a single page by its ID.
116
+ *
117
+ * Retrieves the page properties and block children, converts the blocks
118
+ * to markdown, and returns a normalized ExternalDocument.
119
+ *
120
+ * @param project - The Notion database ID
121
+ * @param externalId - The Notion page ID
122
+ * @returns The page as an ExternalDocument, or null if not found
123
+ */
124
+ getPage(project: string, externalId: string): Promise<ExternalDocument | null>;
125
+ /**
126
+ * List pages in a database that have been edited since a given timestamp.
127
+ *
128
+ * Queries the database with a `last_edited_time > since` filter and
129
+ * returns all matching pages as ExternalDocuments. Block content is
130
+ * fetched for each page to build the full document.
131
+ *
132
+ * @param project - The Notion database ID
133
+ * @param since - ISO 8601 timestamp to filter by last_edited_time
134
+ * @returns Array of ExternalDocuments edited since the given time
135
+ */
136
+ listPagesSince(project: string, since: Timestamp): Promise<ExternalDocument[]>;
137
+ /**
138
+ * Create a new page in a Notion database.
139
+ *
140
+ * Discovers the database schema (if not cached), then converts the markdown
141
+ * content to Notion blocks and creates a page with the discovered title
142
+ * property name. Category (select) and Tags (multi_select) properties are
143
+ * only set if they exist in the database schema.
144
+ *
145
+ * Notion limits POST /pages to 100 children blocks. If the content exceeds
146
+ * this limit, the page is created with the first 100 blocks, and the
147
+ * remaining blocks are appended in batches of 100 via PATCH /blocks/{id}/children.
148
+ *
149
+ * @param project - The Notion database ID
150
+ * @param page - The document input with title and content
151
+ * @returns The created page as an ExternalDocument
152
+ */
153
+ createPage(project: string, page: ExternalDocumentInput): Promise<ExternalDocument>;
154
+ /**
155
+ * Update an existing page's properties and/or content.
156
+ *
157
+ * If the updates include a title, the title property is updated using the
158
+ * discovered property name from the database schema.
159
+ * If the updates include content, all existing blocks are replaced
160
+ * with new blocks converted from the updated markdown.
161
+ *
162
+ * @param project - The Notion database ID
163
+ * @param externalId - The Notion page ID to update
164
+ * @param updates - Partial updates to apply
165
+ * @returns The updated page as an ExternalDocument
166
+ */
167
+ updatePage(project: string, externalId: string, updates: Partial<ExternalDocumentInput>): Promise<ExternalDocument>;
168
+ }
169
+ /**
170
+ * Create a NotionDocumentAdapter from a NotionApiClient.
171
+ *
172
+ * @param api - A configured NotionApiClient
173
+ * @returns A DocumentSyncAdapter for Notion
174
+ */
175
+ export declare function createNotionDocumentAdapter(api: NotionApiClient): NotionDocumentAdapter;
176
+ //# sourceMappingURL=notion-document-adapter.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"notion-document-adapter.d.ts","sourceRoot":"","sources":["../../../../src/external-sync/providers/notion/notion-document-adapter.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;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AeG;IACG,UAAU,CACd,OAAO,EAAE,MAAM,EACf,IAAI,EAAE,qBAAqB,GAC1B,OAAO,CAAC,gBAAgB,CAAC;IA4B5B;;;;;;;;;;;;OAYG;IACG,UAAU,CACd,OAAO,EAAE,MAAM,EACf,UAAU,EAAE,MAAM,EAClB,OAAO,EAAE,OAAO,CAAC,qBAAqB,CAAC,GACtC,OAAO,CAAC,gBAAgB,CAAC;CA4D7B;AAoBD;;;;;GAKG;AACH,wBAAgB,2BAA2B,CACzC,GAAG,EAAE,eAAe,GACnB,qBAAqB,CAEvB"}
@@ -0,0 +1,413 @@
1
+ /**
2
+ * Notion Document Sync Adapter
3
+ *
4
+ * Implements the DocumentSyncAdapter interface for Notion pages.
5
+ * Converts between Stoneforge documents and Notion pages using the
6
+ * Notion API client and the blocks ↔ markdown converter.
7
+ *
8
+ * Key operations:
9
+ * - getPage: Fetch a page's properties and blocks, convert to ExternalDocument
10
+ * - listPagesSince: Query a database for recently edited pages
11
+ * - createPage: Convert markdown to Notion blocks, create page with properties
12
+ * - updatePage: Update page properties and/or replace content blocks
13
+ *
14
+ * The adapter expects:
15
+ * - `project` = Notion database ID
16
+ * - `externalId` = Notion page ID
17
+ *
18
+ * Schema discovery:
19
+ * The adapter discovers the database schema on first use via GET /databases/{id}.
20
+ * Every Notion database has exactly one property of type "title", but its name
21
+ * varies (common names: "Name", "Title"). The adapter discovers and caches this
22
+ * name rather than hardcoding it.
23
+ *
24
+ * Optional properties (Category as select, Tags as multi_select, Library as
25
+ * select) are only included in page properties when the database schema
26
+ * confirms they exist. If they don't exist, the adapter attempts to auto-create
27
+ * them via PATCH /databases/{id}. If that fails (e.g., insufficient
28
+ * permissions), they are silently skipped.
29
+ */
30
+ import { notionBlocksToMarkdown, markdownToNotionBlocks } from './notion-blocks.js';
31
+ // ============================================================================
32
+ // Helper Functions
33
+ // ============================================================================
34
+ /**
35
+ * Extracts the title from a Notion page's properties.
36
+ *
37
+ * Searches through all properties for one of type 'title', then
38
+ * concatenates the plain_text of all rich text elements within it.
39
+ *
40
+ * @param properties - The page's properties record
41
+ * @returns The page title, or empty string if no title property is found
42
+ */
43
+ export function extractTitleFromProperties(properties) {
44
+ for (const prop of Object.values(properties)) {
45
+ if (prop.type === 'title' && prop.title) {
46
+ return prop.title.map((rt) => rt.plain_text).join('');
47
+ }
48
+ }
49
+ return '';
50
+ }
51
+ /**
52
+ * Builds Notion page properties for creating or updating a page.
53
+ *
54
+ * Uses the discovered database schema to:
55
+ * - Set the title on the correct property (discovered name, not hardcoded)
56
+ * - Only include Category, Tags, and Library if the database schema confirms they exist
57
+ *
58
+ * @param title - The page title
59
+ * @param schema - The discovered database schema with property availability info
60
+ * @param category - Optional category for the Category select property
61
+ * @param tags - Optional tags for the Tags multi_select property
62
+ * @param libraryPath - Optional library path for the Library select property
63
+ * @returns A properties record suitable for the Notion API
64
+ */
65
+ export function buildPageProperties(title, schema, category, tags, libraryPath) {
66
+ const properties = {
67
+ [schema.titlePropertyName]: {
68
+ title: [
69
+ {
70
+ text: { content: title },
71
+ },
72
+ ],
73
+ },
74
+ };
75
+ if (category && schema.hasCategoryProperty) {
76
+ properties.Category = {
77
+ select: { name: category },
78
+ };
79
+ }
80
+ if (tags && tags.length > 0 && schema.hasTagsProperty) {
81
+ properties.Tags = {
82
+ multi_select: tags.map((tag) => ({ name: tag })),
83
+ };
84
+ }
85
+ if (libraryPath && schema.hasLibraryProperty) {
86
+ properties.Library = {
87
+ select: { name: libraryPath },
88
+ };
89
+ }
90
+ return properties;
91
+ }
92
+ /**
93
+ * Converts a Notion page and its blocks into an ExternalDocument.
94
+ *
95
+ * @param page - The Notion page object
96
+ * @param markdown - The markdown content converted from page blocks
97
+ * @param databaseId - The database ID (project)
98
+ * @returns An ExternalDocument representation
99
+ */
100
+ function pageToExternalDocument(page, markdown, databaseId) {
101
+ // Extract the Library select value if present
102
+ const libraryProp = page.properties['Library'];
103
+ const libraryPath = libraryProp?.type === 'select' && libraryProp.select
104
+ ? libraryProp.select.name
105
+ : undefined;
106
+ return {
107
+ externalId: page.id,
108
+ url: page.url,
109
+ provider: 'notion',
110
+ project: databaseId,
111
+ title: extractTitleFromProperties(page.properties),
112
+ content: markdown,
113
+ contentType: 'markdown',
114
+ updatedAt: page.last_edited_time,
115
+ ...(libraryPath ? { libraryPath } : {}),
116
+ raw: page,
117
+ };
118
+ }
119
+ // ============================================================================
120
+ // NotionDocumentAdapter
121
+ // ============================================================================
122
+ /**
123
+ * DocumentSyncAdapter implementation for Notion.
124
+ *
125
+ * Uses the NotionApiClient for all API interactions and the
126
+ * blocks ↔ markdown converter for content transformation.
127
+ *
128
+ * On first use of createPage() or updatePage(), the adapter discovers the
129
+ * database schema to find the title property name and check which optional
130
+ * properties exist. The schema is cached per database ID, so only one
131
+ * getDatabase() call is made per adapter instance per database.
132
+ *
133
+ * @example
134
+ * ```typescript
135
+ * const api = new NotionApiClient({ token: 'ntn_...' });
136
+ * const adapter = new NotionDocumentAdapter(api);
137
+ *
138
+ * // Fetch a page
139
+ * const doc = await adapter.getPage('database-id', 'page-id');
140
+ *
141
+ * // List recently edited pages
142
+ * const docs = await adapter.listPagesSince('database-id', '2024-01-01T00:00:00Z');
143
+ *
144
+ * // Create a new page (schema is discovered automatically)
145
+ * const newDoc = await adapter.createPage('database-id', {
146
+ * title: 'New Page',
147
+ * content: '# Hello\n\nWorld',
148
+ * contentType: 'markdown',
149
+ * });
150
+ * ```
151
+ */
152
+ export class NotionDocumentAdapter {
153
+ api;
154
+ /** Cached database schemas keyed by database ID */
155
+ schemaCache = new Map();
156
+ constructor(api) {
157
+ this.api = api;
158
+ }
159
+ /**
160
+ * Discover and cache the database schema for a given database ID.
161
+ *
162
+ * Fetches the database schema from the Notion API, discovers the title
163
+ * property name (every database has exactly one property of type 'title'),
164
+ * and checks for the existence of Category (select), Tags (multi_select),
165
+ * and Library (select) properties.
166
+ *
167
+ * If Category, Tags, or Library properties don't exist, attempts to
168
+ * auto-create them via PATCH /databases/{id}. If the integration lacks
169
+ * permission, the properties are simply skipped — no error is thrown.
170
+ *
171
+ * Results are cached per database ID so only one API call is made per
172
+ * adapter instance per database.
173
+ *
174
+ * @param databaseId - The Notion database ID to discover
175
+ * @returns The discovered database schema
176
+ * @throws Error if the database has no title property
177
+ */
178
+ async getDatabaseSchema(databaseId) {
179
+ const cached = this.schemaCache.get(databaseId);
180
+ if (cached)
181
+ return cached;
182
+ const db = await this.api.getDatabase(databaseId);
183
+ // Discover the title property name
184
+ let titlePropertyName = null;
185
+ for (const [name, prop] of Object.entries(db.properties)) {
186
+ if (prop.type === 'title') {
187
+ titlePropertyName = name;
188
+ break;
189
+ }
190
+ }
191
+ if (!titlePropertyName) {
192
+ throw new Error(`Notion database ${databaseId} has no title property. ` +
193
+ 'Every Notion database should have exactly one property of type "title".');
194
+ }
195
+ // Check if Category, Tags, and Library properties exist with the expected types
196
+ let hasCategoryProperty = db.properties['Category']?.type === 'select';
197
+ let hasTagsProperty = db.properties['Tags']?.type === 'multi_select';
198
+ let hasLibraryProperty = db.properties['Library']?.type === 'select';
199
+ // Auto-create missing properties if needed
200
+ if (!hasCategoryProperty || !hasTagsProperty || !hasLibraryProperty) {
201
+ const propertiesToCreate = {};
202
+ if (!hasCategoryProperty) {
203
+ propertiesToCreate['Category'] = { select: { options: [] } };
204
+ }
205
+ if (!hasTagsProperty) {
206
+ propertiesToCreate['Tags'] = { multi_select: { options: [] } };
207
+ }
208
+ if (!hasLibraryProperty) {
209
+ propertiesToCreate['Library'] = { select: { options: [] } };
210
+ }
211
+ try {
212
+ const updatedDb = await this.api.updateDatabase(databaseId, {
213
+ properties: propertiesToCreate,
214
+ });
215
+ // Re-check after creation attempt
216
+ hasCategoryProperty = updatedDb.properties['Category']?.type === 'select';
217
+ hasTagsProperty = updatedDb.properties['Tags']?.type === 'multi_select';
218
+ hasLibraryProperty = updatedDb.properties['Library']?.type === 'select';
219
+ }
220
+ catch {
221
+ // If we lack permission to update the database schema, just skip.
222
+ // The adapter will omit Category/Tags/Library from page properties.
223
+ }
224
+ }
225
+ const schema = {
226
+ titlePropertyName,
227
+ hasCategoryProperty,
228
+ hasTagsProperty,
229
+ hasLibraryProperty,
230
+ };
231
+ this.schemaCache.set(databaseId, schema);
232
+ return schema;
233
+ }
234
+ /**
235
+ * Fetch a single page by its ID.
236
+ *
237
+ * Retrieves the page properties and block children, converts the blocks
238
+ * to markdown, and returns a normalized ExternalDocument.
239
+ *
240
+ * @param project - The Notion database ID
241
+ * @param externalId - The Notion page ID
242
+ * @returns The page as an ExternalDocument, or null if not found
243
+ */
244
+ async getPage(project, externalId) {
245
+ try {
246
+ const [page, blocks] = await Promise.all([
247
+ this.api.getPage(externalId),
248
+ this.api.getBlocks(externalId),
249
+ ]);
250
+ const markdown = notionBlocksToMarkdown(blocks);
251
+ return pageToExternalDocument(page, markdown, project);
252
+ }
253
+ catch (error) {
254
+ // Return null for not-found errors (matching adapter contract)
255
+ if (isNotFoundError(error)) {
256
+ return null;
257
+ }
258
+ throw error;
259
+ }
260
+ }
261
+ /**
262
+ * List pages in a database that have been edited since a given timestamp.
263
+ *
264
+ * Queries the database with a `last_edited_time > since` filter and
265
+ * returns all matching pages as ExternalDocuments. Block content is
266
+ * fetched for each page to build the full document.
267
+ *
268
+ * @param project - The Notion database ID
269
+ * @param since - ISO 8601 timestamp to filter by last_edited_time
270
+ * @returns Array of ExternalDocuments edited since the given time
271
+ */
272
+ async listPagesSince(project, since) {
273
+ const filter = {
274
+ timestamp: 'last_edited_time',
275
+ last_edited_time: {
276
+ after: since,
277
+ },
278
+ };
279
+ const pages = await this.api.queryDatabaseAll(project, filter);
280
+ // Fetch blocks for each page and convert to ExternalDocument
281
+ const documents = await Promise.all(pages.map(async (page) => {
282
+ const blocks = await this.api.getBlocks(page.id);
283
+ const markdown = notionBlocksToMarkdown(blocks);
284
+ return pageToExternalDocument(page, markdown, project);
285
+ }));
286
+ return documents;
287
+ }
288
+ /**
289
+ * Create a new page in a Notion database.
290
+ *
291
+ * Discovers the database schema (if not cached), then converts the markdown
292
+ * content to Notion blocks and creates a page with the discovered title
293
+ * property name. Category (select) and Tags (multi_select) properties are
294
+ * only set if they exist in the database schema.
295
+ *
296
+ * Notion limits POST /pages to 100 children blocks. If the content exceeds
297
+ * this limit, the page is created with the first 100 blocks, and the
298
+ * remaining blocks are appended in batches of 100 via PATCH /blocks/{id}/children.
299
+ *
300
+ * @param project - The Notion database ID
301
+ * @param page - The document input with title and content
302
+ * @returns The created page as an ExternalDocument
303
+ */
304
+ async createPage(project, page) {
305
+ // Discover the database schema to get the correct title property name
306
+ // and check which optional properties exist
307
+ const schema = await this.getDatabaseSchema(project);
308
+ // markdownToNotionBlocks returns NotionBlock[] which is structurally
309
+ // compatible with NotionBlockInput[] but needs a cast due to index signature
310
+ const blocks = markdownToNotionBlocks(page.content);
311
+ const properties = buildPageProperties(page.title, schema, page.category, page.tags, page.libraryPath);
312
+ // Notion limits POST /pages to 100 children blocks
313
+ const BLOCK_LIMIT = 100;
314
+ const firstBatch = blocks.slice(0, BLOCK_LIMIT);
315
+ const remaining = blocks.slice(BLOCK_LIMIT);
316
+ // Create page with up to 100 blocks
317
+ const createdPage = await this.api.createPage(project, properties, firstBatch);
318
+ // Append remaining blocks in batches of 100
319
+ if (remaining.length > 0) {
320
+ await this.api.appendBlocks(createdPage.id, remaining);
321
+ }
322
+ // Return the created page as an ExternalDocument
323
+ // The content is the original markdown (we just sent it as blocks)
324
+ return pageToExternalDocument(createdPage, page.content, project);
325
+ }
326
+ /**
327
+ * Update an existing page's properties and/or content.
328
+ *
329
+ * If the updates include a title, the title property is updated using the
330
+ * discovered property name from the database schema.
331
+ * If the updates include content, all existing blocks are replaced
332
+ * with new blocks converted from the updated markdown.
333
+ *
334
+ * @param project - The Notion database ID
335
+ * @param externalId - The Notion page ID to update
336
+ * @param updates - Partial updates to apply
337
+ * @returns The updated page as an ExternalDocument
338
+ */
339
+ async updatePage(project, externalId, updates) {
340
+ // Update properties if title, category, tags, or libraryPath changed
341
+ const hasPropertyUpdates = updates.title !== undefined ||
342
+ updates.category !== undefined ||
343
+ updates.tags !== undefined ||
344
+ updates.libraryPath !== undefined;
345
+ if (hasPropertyUpdates) {
346
+ const schema = await this.getDatabaseSchema(project);
347
+ // Build properties selectively — only include fields being updated
348
+ // to avoid overwriting unchanged properties (e.g., setting title to ''
349
+ // when only category changed)
350
+ const properties = {};
351
+ if (updates.title !== undefined) {
352
+ properties[schema.titlePropertyName] = {
353
+ title: [{ text: { content: updates.title } }],
354
+ };
355
+ }
356
+ if (updates.category !== undefined && schema.hasCategoryProperty) {
357
+ properties.Category = {
358
+ select: { name: updates.category },
359
+ };
360
+ }
361
+ if (updates.tags !== undefined && updates.tags.length > 0 && schema.hasTagsProperty) {
362
+ properties.Tags = {
363
+ multi_select: updates.tags.map((tag) => ({ name: tag })),
364
+ };
365
+ }
366
+ if (updates.libraryPath !== undefined && schema.hasLibraryProperty) {
367
+ properties.Library = {
368
+ select: { name: updates.libraryPath },
369
+ };
370
+ }
371
+ if (Object.keys(properties).length > 0) {
372
+ await this.api.updatePage(externalId, properties);
373
+ }
374
+ }
375
+ // Update content blocks if content changed
376
+ if (updates.content !== undefined) {
377
+ const contentBlocks = markdownToNotionBlocks(updates.content);
378
+ await this.api.updatePageContent(externalId, contentBlocks);
379
+ }
380
+ // Fetch the updated page to return a complete ExternalDocument
381
+ const [updatedPage, blocks] = await Promise.all([
382
+ this.api.getPage(externalId),
383
+ this.api.getBlocks(externalId),
384
+ ]);
385
+ const markdown = notionBlocksToMarkdown(blocks);
386
+ return pageToExternalDocument(updatedPage, markdown, project);
387
+ }
388
+ }
389
+ // ============================================================================
390
+ // Error Helpers
391
+ // ============================================================================
392
+ /**
393
+ * Checks if an error represents a "not found" response from the Notion API.
394
+ */
395
+ function isNotFoundError(error) {
396
+ if (error && typeof error === 'object' && 'isNotFound' in error) {
397
+ return error.isNotFound;
398
+ }
399
+ return false;
400
+ }
401
+ // ============================================================================
402
+ // Factory
403
+ // ============================================================================
404
+ /**
405
+ * Create a NotionDocumentAdapter from a NotionApiClient.
406
+ *
407
+ * @param api - A configured NotionApiClient
408
+ * @returns A DocumentSyncAdapter for Notion
409
+ */
410
+ export function createNotionDocumentAdapter(api) {
411
+ return new NotionDocumentAdapter(api);
412
+ }
413
+ //# sourceMappingURL=notion-document-adapter.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"notion-document-adapter.js","sourceRoot":"","sources":["../../../../src/external-sync/providers/notion/notion-document-adapter.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AAUH,OAAO,EAAE,sBAAsB,EAAE,sBAAsB,EAAE,MAAM,oBAAoB,CAAC;AAEpF,+EAA+E;AAC/E,mBAAmB;AACnB,+EAA+E;AAE/E;;;;;;;;GAQG;AACH,MAAM,UAAU,0BAA0B,CACxC,UAA0C;IAE1C,KAAK,MAAM,IAAI,IAAI,MAAM,CAAC,MAAM,CAAC,UAAU,CAAC,EAAE,CAAC;QAC7C,IAAI,IAAI,CAAC,IAAI,KAAK,OAAO,IAAI,IAAI,CAAC,KAAK,EAAE,CAAC;YACxC,OAAO,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,EAAkB,EAAE,EAAE,CAAC,EAAE,CAAC,UAAU,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QACxE,CAAC;IACH,CAAC;IACD,OAAO,EAAE,CAAC;AACZ,CAAC;AAED;;;;;;;;;;;;;GAaG;AACH,MAAM,UAAU,mBAAmB,CACjC,KAAa,EACb,MAA4B,EAC5B,QAAiB,EACjB,IAAwB,EACxB,WAAoB;IAEpB,MAAM,UAAU,GAA4B;QAC1C,CAAC,MAAM,CAAC,iBAAiB,CAAC,EAAE;YAC1B,KAAK,EAAE;gBACL;oBACE,IAAI,EAAE,EAAE,OAAO,EAAE,KAAK,EAAE;iBACzB;aACF;SACF;KACF,CAAC;IAEF,IAAI,QAAQ,IAAI,MAAM,CAAC,mBAAmB,EAAE,CAAC;QAC3C,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