@book.dev/sdk 1.66.0 → 1.68.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/authors.d.ts +31 -0
- package/dist/authors.js +49 -19
- package/dist/authors.js.map +1 -1
- package/dist/backup.d.ts +5 -3
- package/dist/backup.js +11 -3
- package/dist/backup.js.map +1 -1
- package/dist/client.d.ts +149 -0
- package/dist/client.js +351 -21
- package/dist/client.js.map +1 -1
- package/dist/forwarding/tunnelClient.js +9 -0
- package/dist/forwarding/tunnelClient.js.map +1 -1
- package/dist/identity.d.ts +27 -0
- package/dist/identity.js +36 -0
- package/dist/identity.js.map +1 -1
- package/dist/import.d.ts +265 -0
- package/dist/import.js +312 -0
- package/dist/import.js.map +1 -0
- package/dist/importAssets.d.ts +167 -0
- package/dist/importAssets.js +332 -0
- package/dist/importAssets.js.map +1 -0
- package/dist/index.d.ts +6 -2
- package/dist/index.js +6 -2
- package/dist/index.js.map +1 -1
- package/dist/markdownImport.d.ts +79 -0
- package/dist/markdownImport.js +348 -0
- package/dist/markdownImport.js.map +1 -0
- package/dist/notionImport.d.ts +58 -0
- package/dist/notionImport.js +539 -0
- package/dist/notionImport.js.map +1 -0
- package/dist/routes.d.ts +47 -0
- package/dist/routes.js +48 -0
- package/dist/routes.js.map +1 -1
- package/dist/sampleDocument.d.ts +6 -4
- package/dist/sampleDocument.js +12 -6
- package/dist/sampleDocument.js.map +1 -1
- package/dist/templates.d.ts +3 -2
- package/dist/templates.js +8 -6
- package/dist/templates.js.map +1 -1
- package/dist/types.d.ts +5 -4
- package/dist/types.js +4 -3
- package/dist/types.js.map +1 -1
- package/package.json +11 -5
|
@@ -0,0 +1,348 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* **Markdown / GFM → blocks importer.** Turns a CommonMark + GFM source string
|
|
3
|
+
* into the format-agnostic {@link ImportedDoc} IR (see `import.ts`), so
|
|
4
|
+
* {@link importDoc} can land it through the existing data paths. A parser's only
|
|
5
|
+
* job is this transform; it never touches the store, the CRDT, or the wire.
|
|
6
|
+
*
|
|
7
|
+
* **Parser choice — `marked`.** It is pure JS with zero runtime dependencies,
|
|
8
|
+
* ships first-class GFM (tables, task lists, strikethrough, autolinks), and —
|
|
9
|
+
* crucially — exposes a structured token AST via {@link lexer} (block tokens
|
|
10
|
+
* carry their inline children in `.tokens`). That lets us map tokens → blocks
|
|
11
|
+
* directly, with NO DOM. The UI's `htmlToRuns`/`htmlToBlocks` are deliberately
|
|
12
|
+
* *not* reused: they are `document`-bound (they return stripped plain text when
|
|
13
|
+
* `document` is undefined) and live in `@book.dev/ui`, which depends on the SDK —
|
|
14
|
+
* importing them here would invert that dependency. We build runs from marked's
|
|
15
|
+
* inline tokens instead.
|
|
16
|
+
*
|
|
17
|
+
* **Block mapping** (shapes cited from `@book.dev/ui`'s `blockeditor/model.ts`):
|
|
18
|
+
*
|
|
19
|
+
* | Markdown / GFM | Block (`ImportedBlock`) |
|
|
20
|
+
* | ------------------------- | ----------------------------------------------- |
|
|
21
|
+
* | `# … ######` heading | `heading` · `props.level` 1–3 (clamped, as editor)|
|
|
22
|
+
* | paragraph | `paragraph` |
|
|
23
|
+
* | `-`/`*`/`+` list | `list` · `props.kind:'bullet'` |
|
|
24
|
+
* | `1.` ordered list | `list` · `props.kind:'number'` |
|
|
25
|
+
* | nested list item | flat `list`/`todo` · `props.indent` = depth |
|
|
26
|
+
* | `- [ ]` / `- [x]` task | `todo` · `props.checked` |
|
|
27
|
+
* | `>` blockquote | `quote` (block children folded to its rich text) |
|
|
28
|
+
* | ```` ``` ```` fenced code | `code` · `props.language` |
|
|
29
|
+
* | GFM table | `table` → `row` → `cell` children |
|
|
30
|
+
* | `---` thematic break | `divider` |
|
|
31
|
+
* | `**`/`*`/`~~`/`` ` ``/link | inline `runs` (`{b,i,s,c,a}`) |
|
|
32
|
+
* | `` image | {@link imagePlaceholderBlock} (block) / linked run (cell)|
|
|
33
|
+
* | raw HTML / unknown | degrades to a `paragraph` — never dropped |
|
|
34
|
+
*
|
|
35
|
+
* **Images.** An image never vanishes: in body content it becomes the import
|
|
36
|
+
* core's {@link imagePlaceholderBlock} (preserving `src` + `alt` + `title`); in
|
|
37
|
+
* a table cell — which can hold only inline text — it becomes a link run to the
|
|
38
|
+
* `src` carrying the `alt`. **Unknown / unsupported constructs** degrade to a
|
|
39
|
+
* paragraph of their text, honoring the converter contract that import content
|
|
40
|
+
* is "never silently dropped" (`model.ts`).
|
|
41
|
+
*
|
|
42
|
+
* **Front-matter.** A leading `---` YAML block is read for `title:` (used as the
|
|
43
|
+
* page title); the remaining lines are passed through verbatim as a `yaml` code
|
|
44
|
+
* block rather than dropped.
|
|
45
|
+
*/
|
|
46
|
+
import { lexer } from 'marked';
|
|
47
|
+
import { imagePlaceholderBlock, } from './import';
|
|
48
|
+
const DEFAULT_TITLE = 'Imported document';
|
|
49
|
+
const hasAttrs = (a) => Object.keys(a).length > 0;
|
|
50
|
+
const sameAttrs = (a, b) => JSON.stringify(a ?? {}) === JSON.stringify(b ?? {});
|
|
51
|
+
/** Append text, merging into the previous run when the formatting is identical. */
|
|
52
|
+
function pushRun(out, text, attrs) {
|
|
53
|
+
if (text === '')
|
|
54
|
+
return;
|
|
55
|
+
const run = hasAttrs(attrs) ? { t: text, a: { ...attrs } } : { t: text };
|
|
56
|
+
const prev = out[out.length - 1];
|
|
57
|
+
if (prev && sameAttrs(prev.a, run.a))
|
|
58
|
+
prev.t += run.t;
|
|
59
|
+
else
|
|
60
|
+
out.push(run);
|
|
61
|
+
}
|
|
62
|
+
const assetOf = (img) => ({
|
|
63
|
+
kind: 'image',
|
|
64
|
+
ref: img.href,
|
|
65
|
+
...(img.text ? { alt: img.text } : {}),
|
|
66
|
+
...(img.title ? { title: img.title } : {}),
|
|
67
|
+
});
|
|
68
|
+
/** Fold a list of marked inline tokens into rich runs under the given attrs. */
|
|
69
|
+
function walkInline(tokens, attrs, out, ctx) {
|
|
70
|
+
if (!tokens)
|
|
71
|
+
return;
|
|
72
|
+
for (const tok of tokens) {
|
|
73
|
+
switch (tok.type) {
|
|
74
|
+
case 'text':
|
|
75
|
+
case 'escape': {
|
|
76
|
+
const t = tok;
|
|
77
|
+
if (t.tokens && t.tokens.length > 0)
|
|
78
|
+
walkInline(t.tokens, attrs, out, ctx);
|
|
79
|
+
else
|
|
80
|
+
pushRun(out, t.text ?? t.raw ?? '', attrs);
|
|
81
|
+
break;
|
|
82
|
+
}
|
|
83
|
+
case 'strong':
|
|
84
|
+
walkInline(tok.tokens, { ...attrs, b: true }, out, ctx);
|
|
85
|
+
break;
|
|
86
|
+
case 'em':
|
|
87
|
+
walkInline(tok.tokens, { ...attrs, i: true }, out, ctx);
|
|
88
|
+
break;
|
|
89
|
+
case 'del':
|
|
90
|
+
walkInline(tok.tokens, { ...attrs, s: true }, out, ctx);
|
|
91
|
+
break;
|
|
92
|
+
case 'codespan':
|
|
93
|
+
pushRun(out, tok.text, { ...attrs, c: true });
|
|
94
|
+
break;
|
|
95
|
+
case 'br':
|
|
96
|
+
pushRun(out, '\n', {});
|
|
97
|
+
break;
|
|
98
|
+
case 'link': {
|
|
99
|
+
const link = tok;
|
|
100
|
+
const linked = { ...attrs, a: link.href };
|
|
101
|
+
if (link.tokens && link.tokens.length > 0)
|
|
102
|
+
walkInline(link.tokens, linked, out, ctx);
|
|
103
|
+
else
|
|
104
|
+
pushRun(out, link.text ?? link.href, linked);
|
|
105
|
+
break;
|
|
106
|
+
}
|
|
107
|
+
case 'image': {
|
|
108
|
+
const img = tok;
|
|
109
|
+
if (ctx.inlineImages)
|
|
110
|
+
pushRun(out, img.text || img.href, { ...attrs, a: img.href });
|
|
111
|
+
else
|
|
112
|
+
ctx.images.push(assetOf(img));
|
|
113
|
+
break;
|
|
114
|
+
}
|
|
115
|
+
case 'checkbox':
|
|
116
|
+
// Task-list marker — handled via the list item's `task`/`checked` fields.
|
|
117
|
+
break;
|
|
118
|
+
case 'html':
|
|
119
|
+
// Inline raw HTML: degrade to its text, never drop.
|
|
120
|
+
pushRun(out, tok.text ?? tok.raw ?? '', attrs);
|
|
121
|
+
break;
|
|
122
|
+
default: {
|
|
123
|
+
// Any inline token we don't special-case: keep its text/raw verbatim.
|
|
124
|
+
const g = tok;
|
|
125
|
+
if (g.tokens && g.tokens.length > 0)
|
|
126
|
+
walkInline(g.tokens, attrs, out, ctx);
|
|
127
|
+
else
|
|
128
|
+
pushRun(out, g.text ?? g.raw ?? '', attrs);
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
/** Inline tokens → `{runs, images}`; `inlineImages` linkifies images in place. */
|
|
134
|
+
function inlineRuns(tokens, inlineImages = false) {
|
|
135
|
+
const ctx = { images: [], inlineImages };
|
|
136
|
+
const runs = [];
|
|
137
|
+
walkInline(tokens, {}, runs, ctx);
|
|
138
|
+
return { runs, images: ctx.images };
|
|
139
|
+
}
|
|
140
|
+
const plainText = (runs) => runs.map((r) => r.t).join('');
|
|
141
|
+
// ── Block tokens → ImportedBlock[] ───────────────────────────────────────────
|
|
142
|
+
/** Text-bearing blocks whose runs fold into a parent quote's rich text. */
|
|
143
|
+
const QUOTE_FOLDABLE = new Set(['paragraph', 'heading', 'list', 'todo', 'quote']);
|
|
144
|
+
/** Emit list items as flat `list`/`todo` blocks, recursing nested lists by depth. */
|
|
145
|
+
function emitList(list, depth, out) {
|
|
146
|
+
const kind = list.ordered ? 'number' : 'bullet';
|
|
147
|
+
for (const item of list.items) {
|
|
148
|
+
const runs = [];
|
|
149
|
+
const images = [];
|
|
150
|
+
const trailing = [];
|
|
151
|
+
const nested = [];
|
|
152
|
+
for (const child of item.tokens) {
|
|
153
|
+
if (child.type === 'checkbox') {
|
|
154
|
+
// The task marker — its state is carried by `item.task`/`item.checked`.
|
|
155
|
+
continue;
|
|
156
|
+
}
|
|
157
|
+
else if (child.type === 'list') {
|
|
158
|
+
nested.push(child);
|
|
159
|
+
}
|
|
160
|
+
else if (child.type === 'text' || child.type === 'paragraph') {
|
|
161
|
+
const r = inlineRuns(child.tokens);
|
|
162
|
+
runs.push(...r.runs);
|
|
163
|
+
images.push(...r.images);
|
|
164
|
+
}
|
|
165
|
+
else {
|
|
166
|
+
// Block content nested in a list item (code, blockquote, table…): keep
|
|
167
|
+
// it as a following block rather than dropping it.
|
|
168
|
+
tokensToBlocks([child], depth, trailing);
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
const isTodo = item.task === true;
|
|
172
|
+
const props = {};
|
|
173
|
+
if (isTodo) {
|
|
174
|
+
if (item.checked)
|
|
175
|
+
props.checked = true;
|
|
176
|
+
}
|
|
177
|
+
else {
|
|
178
|
+
props.kind = kind;
|
|
179
|
+
}
|
|
180
|
+
// Clamp the indent: the editor's CSS only defines `.obe-indent-1..4`, so a
|
|
181
|
+
// deeper nesting would render flat — pin it to the deepest defined level.
|
|
182
|
+
if (depth > 0)
|
|
183
|
+
props.indent = Math.min(4, depth);
|
|
184
|
+
out.push({ type: isTodo ? 'todo' : 'list', text: runs, ...(Object.keys(props).length > 0 ? { props } : {}) });
|
|
185
|
+
for (const img of images)
|
|
186
|
+
out.push(imagePlaceholderBlock(img));
|
|
187
|
+
out.push(...trailing);
|
|
188
|
+
for (const nl of nested)
|
|
189
|
+
emitList(nl, depth + 1, out);
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
/** Map a GFM table token to a `table` → `row` → `cell` block tree. */
|
|
193
|
+
function emitTable(table) {
|
|
194
|
+
const rowOf = (cells) => ({
|
|
195
|
+
type: 'row',
|
|
196
|
+
children: cells.map((cell) => ({ type: 'cell', text: inlineRuns(cell.tokens, true).runs })),
|
|
197
|
+
});
|
|
198
|
+
return {
|
|
199
|
+
type: 'table',
|
|
200
|
+
props: { header: true },
|
|
201
|
+
children: [rowOf(table.header), ...table.rows.map(rowOf)],
|
|
202
|
+
};
|
|
203
|
+
}
|
|
204
|
+
/** Fold a blockquote's child blocks into a single `quote`, keeping the rest after. */
|
|
205
|
+
function emitBlockquote(bq, out) {
|
|
206
|
+
const inner = [];
|
|
207
|
+
tokensToBlocks(bq.tokens, 0, inner);
|
|
208
|
+
const quoteRuns = [];
|
|
209
|
+
const trailing = [];
|
|
210
|
+
for (const b of inner) {
|
|
211
|
+
if (QUOTE_FOLDABLE.has(b.type) && b.text) {
|
|
212
|
+
if (quoteRuns.length > 0)
|
|
213
|
+
quoteRuns.push({ t: '\n' });
|
|
214
|
+
quoteRuns.push(...b.text);
|
|
215
|
+
}
|
|
216
|
+
else {
|
|
217
|
+
trailing.push(b);
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
out.push({ type: 'quote', text: quoteRuns });
|
|
221
|
+
out.push(...trailing);
|
|
222
|
+
}
|
|
223
|
+
/** Walk top-level (or nested) marked block tokens, appending blocks to `out`. */
|
|
224
|
+
function tokensToBlocks(tokens, depth, out) {
|
|
225
|
+
for (const tok of tokens) {
|
|
226
|
+
switch (tok.type) {
|
|
227
|
+
case 'space':
|
|
228
|
+
case 'def':
|
|
229
|
+
break;
|
|
230
|
+
case 'heading': {
|
|
231
|
+
const h = tok;
|
|
232
|
+
const { runs, images } = inlineRuns(h.tokens);
|
|
233
|
+
out.push({ type: 'heading', text: runs, props: { level: Math.min(3, Math.max(1, h.depth)) } });
|
|
234
|
+
for (const img of images)
|
|
235
|
+
out.push(imagePlaceholderBlock(img));
|
|
236
|
+
break;
|
|
237
|
+
}
|
|
238
|
+
case 'paragraph':
|
|
239
|
+
case 'text': {
|
|
240
|
+
const p = tok;
|
|
241
|
+
const { runs, images } = inlineRuns(p.tokens ?? undefined);
|
|
242
|
+
const text = plainText(runs);
|
|
243
|
+
if (text.trim() !== '')
|
|
244
|
+
out.push({ type: 'paragraph', text: runs });
|
|
245
|
+
for (const img of images)
|
|
246
|
+
out.push(imagePlaceholderBlock(img));
|
|
247
|
+
break;
|
|
248
|
+
}
|
|
249
|
+
case 'list':
|
|
250
|
+
emitList(tok, depth, out);
|
|
251
|
+
break;
|
|
252
|
+
case 'blockquote':
|
|
253
|
+
emitBlockquote(tok, out);
|
|
254
|
+
break;
|
|
255
|
+
case 'code': {
|
|
256
|
+
const c = tok;
|
|
257
|
+
const language = c.lang?.trim().split(/\s+/)[0];
|
|
258
|
+
out.push({ type: 'code', text: [{ t: c.text }], ...(language ? { props: { language } } : {}) });
|
|
259
|
+
break;
|
|
260
|
+
}
|
|
261
|
+
case 'table':
|
|
262
|
+
out.push(emitTable(tok));
|
|
263
|
+
break;
|
|
264
|
+
case 'hr':
|
|
265
|
+
out.push({ type: 'divider' });
|
|
266
|
+
break;
|
|
267
|
+
case 'html': {
|
|
268
|
+
// Raw HTML block — degrade to a paragraph carrying the markup verbatim.
|
|
269
|
+
const raw = (tok.text ?? tok.raw ?? '').trim();
|
|
270
|
+
if (raw !== '')
|
|
271
|
+
out.push({ type: 'paragraph', text: [{ t: raw }] });
|
|
272
|
+
break;
|
|
273
|
+
}
|
|
274
|
+
default: {
|
|
275
|
+
// Unknown / unsupported construct: never drop — degrade to its text.
|
|
276
|
+
const g = tok;
|
|
277
|
+
const raw = (g.text ?? g.raw ?? '').trim();
|
|
278
|
+
if (raw !== '')
|
|
279
|
+
out.push({ type: 'paragraph', text: [{ t: raw }] });
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
// ── Front-matter ─────────────────────────────────────────────────────────────
|
|
285
|
+
const FRONT_MATTER_RE = /^\uFEFF?---[ \t]*\r?\n([\s\S]*?)\r?\n---[ \t]*(?:\r?\n|$)/;
|
|
286
|
+
/** Split a leading `---` YAML block off the source; returns `{title, rest, body}`. */
|
|
287
|
+
function splitFrontMatter(markdown) {
|
|
288
|
+
const m = FRONT_MATTER_RE.exec(markdown);
|
|
289
|
+
if (!m)
|
|
290
|
+
return { rest: '', body: markdown.replace(/^\uFEFF/, '') };
|
|
291
|
+
const lines = m[1].split(/\r?\n/);
|
|
292
|
+
let title;
|
|
293
|
+
const rest = [];
|
|
294
|
+
for (const line of lines) {
|
|
295
|
+
const kv = /^(\w[\w-]*)\s*:\s*(.*)$/.exec(line);
|
|
296
|
+
if (title === undefined && kv && kv[1].toLowerCase() === 'title') {
|
|
297
|
+
title = kv[2].trim().replace(/^["']|["']$/g, '');
|
|
298
|
+
}
|
|
299
|
+
else {
|
|
300
|
+
rest.push(line);
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
return { title, rest: rest.join('\n').trim(), body: markdown.slice(m[0].length) };
|
|
304
|
+
}
|
|
305
|
+
// ── Public API ───────────────────────────────────────────────────────────────
|
|
306
|
+
/**
|
|
307
|
+
* Parse a Markdown/GFM string into {@link ImportedBlock}s. Pure and DOM-free, so
|
|
308
|
+
* it is directly unit-testable and reusable wherever only the block list is
|
|
309
|
+
* wanted (e.g. importing a fragment into an existing page). Honors the
|
|
310
|
+
* "never silently drop content" contract: unknown constructs degrade to text,
|
|
311
|
+
* images become placeholders.
|
|
312
|
+
*/
|
|
313
|
+
export function markdownToBlocks(markdown) {
|
|
314
|
+
const tokens = lexer(markdown ?? '', { gfm: true });
|
|
315
|
+
const blocks = [];
|
|
316
|
+
tokensToBlocks(tokens, 0, blocks);
|
|
317
|
+
return blocks;
|
|
318
|
+
}
|
|
319
|
+
/**
|
|
320
|
+
* Parse a full Markdown/GFM document into an {@link ImportedDoc} (a single page)
|
|
321
|
+
* ready for {@link importDoc}. The page title is resolved as:
|
|
322
|
+
*
|
|
323
|
+
* 1. `opts.title` (explicit), else
|
|
324
|
+
* 2. front-matter `title:`, else
|
|
325
|
+
* 3. a leading heading promoted to the title (consumed from the body) when
|
|
326
|
+
* `opts.firstHeadingAsTitle !== false`, else
|
|
327
|
+
* 4. `opts.defaultTitle` (default `'Imported document'`).
|
|
328
|
+
*
|
|
329
|
+
* Any non-title front-matter is preserved as a leading `yaml` code block.
|
|
330
|
+
*/
|
|
331
|
+
export function markdownToImportedDoc(markdown, opts = {}) {
|
|
332
|
+
const { title: fmTitle, rest, body } = splitFrontMatter(markdown ?? '');
|
|
333
|
+
const blocks = markdownToBlocks(body);
|
|
334
|
+
let title = opts.title ?? fmTitle;
|
|
335
|
+
if (title === undefined && opts.firstHeadingAsTitle !== false && blocks[0]?.type === 'heading') {
|
|
336
|
+
const headingText = plainText(blocks[0].text ?? []).trim();
|
|
337
|
+
if (headingText !== '') {
|
|
338
|
+
title = headingText;
|
|
339
|
+
blocks.shift();
|
|
340
|
+
}
|
|
341
|
+
}
|
|
342
|
+
title = title?.trim() || opts.defaultTitle || DEFAULT_TITLE;
|
|
343
|
+
// Preserve any leftover front-matter rather than dropping it.
|
|
344
|
+
if (rest !== '')
|
|
345
|
+
blocks.unshift({ type: 'code', text: [{ t: rest }], props: { language: 'yaml' } });
|
|
346
|
+
return { pages: [{ title, blocks }] };
|
|
347
|
+
}
|
|
348
|
+
//# sourceMappingURL=markdownImport.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"markdownImport.js","sourceRoot":"","sources":["../src/markdownImport.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4CG;AAEH,OAAO,EAAC,KAAK,EAA0B,MAAM,QAAQ,CAAC;AACtD,OAAO,EACL,qBAAqB,GAMtB,MAAM,UAAU,CAAC;AAelB,MAAM,aAAa,GAAG,mBAAmB,CAAC;AAe1C,MAAM,QAAQ,GAAG,CAAC,CAAoB,EAAW,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC;AAE9E,MAAM,SAAS,GAAG,CAAC,CAAgC,EAAE,CAAgC,EAAW,EAAE,CAChG,IAAI,CAAC,SAAS,CAAC,CAAC,IAAI,EAAE,CAAC,KAAK,IAAI,CAAC,SAAS,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC;AAEtD,mFAAmF;AACnF,SAAS,OAAO,CAAC,GAAoB,EAAE,IAAY,EAAE,KAAwB;IAC3E,IAAI,IAAI,KAAK,EA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M,MAAM,GAAG,gBAAgB,CAAC,IAAI,CAAC,CAAC;IAEtC,IAAI,KAAK,GAAG,IAAI,CAAC,KAAK,IAAI,OAAO,CAAC;IAClC,IAAI,KAAK,KAAK,SAAS,IAAI,IAAI,CAAC,mBAAmB,KAAK,KAAK,IAAI,MAAM,CAAC,CAAC,CAAC,EAAE,IAAI,KAAK,SAAS,EAAE,CAAC;QAC/F,MAAM,WAAW,GAAG,SAAS,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,IAAI,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC;QAC3D,IAAI,WAAW,KAAK,EAAE,EAAE,CAAC;YACvB,KAAK,GAAG,WAAW,CAAC;YACpB,MAAM,CAAC,KAAK,EAAE,CAAC;QACjB,CAAC;IACH,CAAC;IACD,KAAK,GAAG,KAAK,EAAE,IAAI,EAAE,IAAI,IAAI,CAAC,YAAY,IAAI,aAAa,CAAC;IAE5D,8DAA8D;IAC9D,IAAI,IAAI,KAAK,EAAE;QAAE,MAAM,CAAC,OAAO,CAAC,EAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,EAAC,CAAC,EAAE,IAAI,EAAC,CAAC,EAAE,KAAK,EAAE,EAAC,QAAQ,EAAE,MAAM,EAAC,EAAC,CAAC,CAAC;IAE9F,OAAO,EAAC,KAAK,EAAE,CAAC,EAAC,KAAK,EAAE,MAAM,EAAC,CAAC,EAAC,CAAC;AACpC,CAAC"}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* **Notion "Markdown & CSV" export → import IR.** Ingests the zip Notion produces
|
|
3
|
+
* for *Export → Markdown & CSV* and emits the format-agnostic {@link ImportedDoc}
|
|
4
|
+
* (see `import.ts`), so {@link importDoc} can land the whole tree through the
|
|
5
|
+
* existing data paths (Strategy B — a bundle the server id-remaps, link-rewrites,
|
|
6
|
+
* and name-dedups as one graph).
|
|
7
|
+
*
|
|
8
|
+
* **Export shape.** Notion writes a forest of folders + files; every page/database
|
|
9
|
+
* filename is suffixed with the 32-hex Notion id (dashes stripped):
|
|
10
|
+
*
|
|
11
|
+
* ```
|
|
12
|
+
* Export-<uuid>/ ← transparent wrapper (any non-page dir)
|
|
13
|
+
* Launch Plan <id>.md ← a page
|
|
14
|
+
* Launch Plan <id>/ ← its child pages live here
|
|
15
|
+
* Sub Note <id>.md
|
|
16
|
+
* Team Tasks <id>.csv ← a database (schema + rows)
|
|
17
|
+
* Team Tasks <id>/ ← the database's row pages (bodies)
|
|
18
|
+
* Ship v1 <id>.md
|
|
19
|
+
* ```
|
|
20
|
+
*
|
|
21
|
+
* - **Folder nesting → the page tree.** A `.md` at `A/B/C.md` whose sibling
|
|
22
|
+
* folder `A/B/C/` holds more `.md`/`.csv` becomes an {@link ImportedPage} with
|
|
23
|
+
* those as `children`. Titles drop the hash suffix.
|
|
24
|
+
* - **Each `.md` → blocks** via the merged Markdown importer
|
|
25
|
+
* ({@link markdownToImportedDoc}, T2) — reused verbatim, not reparsed.
|
|
26
|
+
* - **A `.csv` → an {@link ImportedDatabase}.** Column property types are inferred
|
|
27
|
+
* from the cell values (text / number / checkbox / date / select / multi_select
|
|
28
|
+
* / url / email — a comma-bearing cell ⇒ multi_select); each row links to its
|
|
29
|
+
* `.md` page in the sibling folder for the row body. **Scalar properties only**
|
|
30
|
+
* — a CSV cannot encode relation/rollup/formula targets, so those degrade to a
|
|
31
|
+
* plain scalar (never a dangling `relation`), the v1 owner decision.
|
|
32
|
+
* - **Internal links** (the hash-suffixed relative `.md`/`.csv` path Notion
|
|
33
|
+
* writes) resolve to an `@`-mention run when the target was imported; an
|
|
34
|
+
* unresolved internal link keeps its visible text (never dropped). External
|
|
35
|
+
* `http(s)`/`mailto:` links and file/asset refs are preserved as links.
|
|
36
|
+
* - **Icon** — a leading emoji on the page title is lifted to `sys_icon`.
|
|
37
|
+
* - **Images/files** — handled by the Markdown importer as the import core's
|
|
38
|
+
* {@link imagePlaceholderBlock} / a link run that preserves the ref.
|
|
39
|
+
* - **Toggles** — Notion flattens these to a heading/list in Markdown; the
|
|
40
|
+
* content survives via T2 (we do not reconstruct an `accordion`, whose
|
|
41
|
+
* structure does not survive the export).
|
|
42
|
+
*
|
|
43
|
+
* **Never silently drop.** Unknown constructs degrade to text (T2's contract);
|
|
44
|
+
* any `.md`/`.csv` the tree walk somehow misses is appended as a top-level page;
|
|
45
|
+
* a row with no matching body still lands with its properties.
|
|
46
|
+
*/
|
|
47
|
+
import { type ImportedDoc } from './import';
|
|
48
|
+
/**
|
|
49
|
+
* RFC-4180-ish CSV → a matrix of rows. Handles quoted fields containing commas
|
|
50
|
+
* and newlines, doubled `""` escapes, and CRLF — everything Notion emits.
|
|
51
|
+
*/
|
|
52
|
+
export declare function parseCsv(text: string): string[][];
|
|
53
|
+
/**
|
|
54
|
+
* Parse a Notion *Markdown & CSV* export zip into an {@link ImportedDoc} ready for
|
|
55
|
+
* {@link importDoc}. Pure (no client, no I/O beyond the in-memory unzip), so it is
|
|
56
|
+
* directly unit-testable. Throws only when the bytes are not a readable zip.
|
|
57
|
+
*/
|
|
58
|
+
export declare function notionExportToImportedDoc(zipBytes: Uint8Array): ImportedDoc;
|