@kamilio/wire 0.1.2 → 0.1.4
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/README.md +1 -1
- package/bin/wire-mcp.mjs +1 -1
- package/dist/adapters/root.d.ts +5 -2
- package/dist/adapters/root.d.ts.map +1 -1
- package/dist/adapters/root.js +58 -30
- package/dist/adapters/root.js.map +1 -1
- package/dist/auth.d.ts.map +1 -1
- package/dist/auth.js +9 -36
- package/dist/auth.js.map +1 -1
- package/dist/cli.js +2 -2
- package/dist/cli.js.map +1 -1
- package/dist/executable.d.ts +3 -1
- package/dist/executable.d.ts.map +1 -1
- package/dist/executable.js +38 -12
- package/dist/executable.js.map +1 -1
- package/dist/hooks.d.ts.map +1 -1
- package/dist/hooks.js +22 -7
- package/dist/hooks.js.map +1 -1
- package/node_modules/provider-asana/dist/asana-project.d.ts.map +1 -1
- package/node_modules/provider-asana/dist/asana-project.js +3 -0
- package/node_modules/provider-asana/dist/asana-project.js.map +1 -1
- package/node_modules/provider-asana/src/asana-project.ts +2 -0
- package/node_modules/provider-chatgpt/dist/chatgpt.d.ts.map +1 -1
- package/node_modules/provider-chatgpt/dist/chatgpt.js +24 -3
- package/node_modules/provider-chatgpt/dist/chatgpt.js.map +1 -1
- package/node_modules/provider-chatgpt/src/chatgpt.ts +21 -3
- package/node_modules/provider-gmail/dist/gmail.d.ts.map +1 -1
- package/node_modules/provider-gmail/dist/gmail.js +8 -2
- package/node_modules/provider-gmail/dist/gmail.js.map +1 -1
- package/node_modules/provider-gmail/src/gmail.ts +8 -2
- package/node_modules/provider-google-docs/dist/google-docs.d.ts.map +1 -1
- package/node_modules/provider-google-docs/dist/google-docs.js +373 -9
- package/node_modules/provider-google-docs/dist/google-docs.js.map +1 -1
- package/node_modules/provider-google-docs/dist/google-forms.d.ts +28 -0
- package/node_modules/provider-google-docs/dist/google-forms.d.ts.map +1 -0
- package/node_modules/provider-google-docs/dist/google-forms.js +191 -0
- package/node_modules/provider-google-docs/dist/google-forms.js.map +1 -0
- package/node_modules/provider-google-docs/dist/index.d.ts +26 -0
- package/node_modules/provider-google-docs/dist/index.d.ts.map +1 -1
- package/node_modules/provider-google-docs/dist/index.js +3 -1
- package/node_modules/provider-google-docs/dist/index.js.map +1 -1
- package/node_modules/provider-google-docs/src/google-docs.ts +342 -10
- package/node_modules/provider-google-docs/src/google-forms.ts +179 -0
- package/node_modules/provider-google-docs/src/index.ts +3 -1
- package/node_modules/provider-notion/dist/notion-sync.d.ts +2 -2
- package/node_modules/provider-notion/dist/notion-sync.d.ts.map +1 -1
- package/node_modules/provider-notion/dist/notion-sync.js +89 -38
- package/node_modules/provider-notion/dist/notion-sync.js.map +1 -1
- package/node_modules/provider-notion/dist/notion.js +1 -1
- package/node_modules/provider-notion/dist/notion.js.map +1 -1
- package/node_modules/provider-notion/src/notion-sync.ts +90 -35
- package/node_modules/provider-notion/src/notion.ts +1 -1
- package/node_modules/provider-slack/dist/slack.d.ts.map +1 -1
- package/node_modules/provider-slack/dist/slack.js +14 -7
- package/node_modules/provider-slack/dist/slack.js.map +1 -1
- package/node_modules/provider-slack/src/slack.ts +14 -5
- package/node_modules/provider-zoom/dist/zoom-hub.d.ts.map +1 -1
- package/node_modules/provider-zoom/dist/zoom-hub.js +42 -35
- package/node_modules/provider-zoom/dist/zoom-hub.js.map +1 -1
- package/node_modules/provider-zoom/src/zoom-hub.ts +40 -35
- package/node_modules/wire-core/dist/core/model.d.ts +1 -1
- package/node_modules/wire-core/dist/core/model.d.ts.map +1 -1
- package/node_modules/wire-core/dist/core/transform.d.ts +1 -0
- package/node_modules/wire-core/dist/core/transform.d.ts.map +1 -1
- package/node_modules/wire-core/dist/core/transform.js +4 -0
- package/node_modules/wire-core/dist/core/transform.js.map +1 -1
- package/node_modules/wire-core/dist/index.d.ts +3 -2
- package/node_modules/wire-core/dist/index.d.ts.map +1 -1
- package/node_modules/wire-core/dist/index.js +2 -2
- package/node_modules/wire-core/dist/index.js.map +1 -1
- package/node_modules/wire-core/dist/operations.d.ts +3 -0
- package/node_modules/wire-core/dist/operations.d.ts.map +1 -1
- package/node_modules/wire-core/dist/operations.js +50 -9
- package/node_modules/wire-core/dist/operations.js.map +1 -1
- package/node_modules/wire-core/dist/ports.d.ts +1 -0
- package/node_modules/wire-core/dist/ports.d.ts.map +1 -1
- package/node_modules/wire-core/dist/runtime/chrome.d.ts +1 -0
- package/node_modules/wire-core/dist/runtime/chrome.d.ts.map +1 -1
- package/node_modules/wire-core/dist/runtime/chrome.js +91 -83
- package/node_modules/wire-core/dist/runtime/chrome.js.map +1 -1
- package/node_modules/wire-core/dist/runtime/cookies.d.ts.map +1 -1
- package/node_modules/wire-core/dist/runtime/cookies.js +7 -2
- package/node_modules/wire-core/dist/runtime/cookies.js.map +1 -1
- package/node_modules/wire-core/dist/runtime/node.d.ts.map +1 -1
- package/node_modules/wire-core/dist/runtime/node.js +4 -0
- package/node_modules/wire-core/dist/runtime/node.js.map +1 -1
- package/node_modules/wire-core/dist/storage/registry.d.ts.map +1 -1
- package/node_modules/wire-core/dist/storage/registry.js +95 -208
- package/node_modules/wire-core/dist/storage/registry.js.map +1 -1
- package/node_modules/wire-core/dist/storage/workspace.d.ts +3 -0
- package/node_modules/wire-core/dist/storage/workspace.d.ts.map +1 -1
- package/node_modules/wire-core/dist/storage/workspace.js +10 -1
- package/node_modules/wire-core/dist/storage/workspace.js.map +1 -1
- package/node_modules/wire-core/package.json +4 -0
- package/node_modules/wire-core/src/core/model.ts +1 -1
- package/node_modules/wire-core/src/core/transform.ts +5 -1
- package/node_modules/wire-core/src/index.ts +3 -2
- package/node_modules/wire-core/src/operations.ts +56 -10
- package/node_modules/wire-core/src/ports.ts +1 -0
- package/node_modules/wire-core/src/runtime/chrome.ts +99 -80
- package/node_modules/wire-core/src/runtime/cookies.ts +4 -2
- package/node_modules/wire-core/src/runtime/node.ts +4 -0
- package/node_modules/wire-core/src/storage/registry.ts +48 -15
- package/node_modules/wire-core/src/storage/workspace.ts +10 -1
- package/package.json +1 -1
- package/src/adapters/root.ts +51 -31
- package/src/auth.ts +10 -29
- package/src/cli.ts +2 -2
- package/src/executable.ts +38 -12
- package/src/hooks.ts +21 -6
|
@@ -33,7 +33,7 @@ function inlineCode(value: string): string {
|
|
|
33
33
|
}
|
|
34
34
|
|
|
35
35
|
function escapeInlineMarkdown(value: string): string {
|
|
36
|
-
return value.replace(/\\/g, "\\\\").replace(/\*/g, "\\*").replace(/~/g, "\\~").replace(/\[/g, "\\[").replace(/\]/g, "\\]");
|
|
36
|
+
return value.replace(/\\/g, "\\\\").replace(/\*/g, "\\*").replace(/~/g, "\\~").replace(/`/g, "\\`").replace(/\[/g, "\\[").replace(/\]/g, "\\]");
|
|
37
37
|
}
|
|
38
38
|
|
|
39
39
|
function unescapeInlineMarkdown(value: string): string {
|
|
@@ -71,6 +71,11 @@ function normalizeMarks(marks: readonly JsonValue[]): JsonValue[] {
|
|
|
71
71
|
return marks.filter((mark) => Array.isArray(mark) && mark.length > 0 && array(mark)[0] !== "m").map((mark) => clone(mark)).sort((left, right) => compact(left).localeCompare(compact(right)));
|
|
72
72
|
}
|
|
73
73
|
|
|
74
|
+
function renderMarks(marks: readonly JsonValue[]): JsonValue[] {
|
|
75
|
+
const priority = new Map<string, number>([["c", 0], ["_", 1], ["h", 2], ["e", 3], ["p", 4], ["u", 5], ["d", 6], ["s", 7], ["i", 8], ["b", 9], ["a", 10]]);
|
|
76
|
+
return [...marks].sort((left, right) => priority.get(array(left)[0] as string)! - priority.get(array(right)[0] as string)! || compact(left).localeCompare(compact(right)));
|
|
77
|
+
}
|
|
78
|
+
|
|
74
79
|
function normalizeRichText(value: JsonValue): JsonValue {
|
|
75
80
|
const output: JsonValue[][] = [];
|
|
76
81
|
for (const raw of value as JsonValue[][]) {
|
|
@@ -133,6 +138,17 @@ function parseInline(value: string): NotionRichText {
|
|
|
133
138
|
rest = rest.slice(mentionSpan[0].length);
|
|
134
139
|
continue;
|
|
135
140
|
}
|
|
141
|
+
if (rest.startsWith("***")) {
|
|
142
|
+
const end = closingDelimiter(rest, 3, "***");
|
|
143
|
+
if (end !== -1) {
|
|
144
|
+
for (const segment of parseInline(rest.slice(3, end))) {
|
|
145
|
+
const marks = normalizeMarks([...((segment[1] as JsonValue[] | undefined) ?? []), ["b"], ["i"]]);
|
|
146
|
+
push(segment[0] as string, marks);
|
|
147
|
+
}
|
|
148
|
+
rest = rest.slice(end + 3);
|
|
149
|
+
continue;
|
|
150
|
+
}
|
|
151
|
+
}
|
|
136
152
|
if (rest.startsWith("**")) {
|
|
137
153
|
const end = closingDelimiter(rest, 2, "**");
|
|
138
154
|
if (end !== -1) {
|
|
@@ -194,7 +210,7 @@ function parseInline(value: string): NotionRichText {
|
|
|
194
210
|
function renderSegment(content: string, marks: readonly JsonValue[]): string {
|
|
195
211
|
let rendered = marks.some((raw) => (raw as JsonValue[])[0] === "c") ? content : escapeInlineMarkdown(content);
|
|
196
212
|
let link: string | null = null;
|
|
197
|
-
for (const raw of marks) {
|
|
213
|
+
for (const raw of renderMarks(marks)) {
|
|
198
214
|
const mark = raw as JsonValue[];
|
|
199
215
|
if (mark[0] === "c") rendered = inlineCode(rendered);
|
|
200
216
|
else if (mark[0] === "s") rendered = `~~${rendered}~~`;
|
|
@@ -273,6 +289,10 @@ function markdownBlockStart(stripped: string): boolean {
|
|
|
273
289
|
return /^(#{1,6})\s+|^[-*]\s+|^\d+\.\s+|^-\s+\[[ xX]\]\s+|^```|^---$|^!\[|^>|^\||^:::/.test(stripped);
|
|
274
290
|
}
|
|
275
291
|
|
|
292
|
+
function escapeBlockMarkdownLine(line: string): string {
|
|
293
|
+
return markdownBlockStart(line) ? `\\${line}` : line;
|
|
294
|
+
}
|
|
295
|
+
|
|
276
296
|
function colonFenceBody(lines: readonly string[], index: number): Readonly<{ body: readonly string[]; index: number }> {
|
|
277
297
|
const body: string[] = [];
|
|
278
298
|
let depth = 0;
|
|
@@ -364,8 +384,13 @@ function parseLines(lines: readonly string[], baseIndent = 0): NotionBlock[] {
|
|
|
364
384
|
continue;
|
|
365
385
|
}
|
|
366
386
|
if (stripped.startsWith("> ")) {
|
|
367
|
-
|
|
387
|
+
const content = [stripped.slice(2)];
|
|
368
388
|
index += 1;
|
|
389
|
+
while (index < lines.length && lines[index]!.trim() !== "" && baseIndent + lineIndent(lines[index]!) === indent && stripIndent(lines[index]!).startsWith("> ")) {
|
|
390
|
+
content.push(stripIndent(lines[index]!).slice(2));
|
|
391
|
+
index += 1;
|
|
392
|
+
}
|
|
393
|
+
blocks.push({ type: "quote", content: content.join("\n"), properties: {}, rich_text: parseInline(content.join("\n")), indent });
|
|
369
394
|
continue;
|
|
370
395
|
}
|
|
371
396
|
if (stripped.startsWith("|")) {
|
|
@@ -480,7 +505,26 @@ export function parseNotionMarkdown(markdown: string): readonly NotionBlock[] {
|
|
|
480
505
|
return parseLines(markdown.replace(/^\ufeff/, "").split("\n"));
|
|
481
506
|
}
|
|
482
507
|
|
|
483
|
-
function
|
|
508
|
+
function tableRowCells(block: NotionBlock, columnOrder?: readonly string[]): JsonObject {
|
|
509
|
+
const cells = object(block.properties["cells"]!);
|
|
510
|
+
if (columnOrder === undefined) return cells;
|
|
511
|
+
const localColumns = Object.keys(cells);
|
|
512
|
+
return Object.fromEntries(columnOrder.map((column, index) => [column, cells[localColumns[index]!]!]));
|
|
513
|
+
}
|
|
514
|
+
|
|
515
|
+
function tableColumnOrder(remote: JsonObject | undefined, local: NotionBlock): readonly string[] {
|
|
516
|
+
const localColumns = local.properties["column_ids"] as readonly string[];
|
|
517
|
+
if (remote === undefined) return localColumns;
|
|
518
|
+
const remoteColumns = object(remote["format"]!)["table_block_column_order"] as readonly string[];
|
|
519
|
+
const used = new Set<string>();
|
|
520
|
+
return localColumns.map((column, index) => {
|
|
521
|
+
const value = index < remoteColumns.length ? remoteColumns[index]! : used.has(column) ? `column_${index}_${randomUUID().replaceAll("-", "")}` : column;
|
|
522
|
+
used.add(value);
|
|
523
|
+
return value;
|
|
524
|
+
});
|
|
525
|
+
}
|
|
526
|
+
|
|
527
|
+
function parserBlockToNotionBlock(block: NotionBlock, id: string, parentId: string, parentTable: string, spaceId: string, userId: string, currentTime: number, columnOrder?: readonly string[]): JsonObject {
|
|
484
528
|
const base: Record<string, JsonValue> = { id, type: block.type, space_id: spaceId, parent_id: parentId, parent_table: parentTable, alive: true, created_time: currentTime, created_by_table: "notion_user", created_by_id: userId, last_edited_time: currentTime, last_edited_by_table: "notion_user", last_edited_by_id: userId };
|
|
485
529
|
if (block.properties["notion_opaque"] !== undefined) return { ...object(block.properties["notion_opaque"]!), ...base };
|
|
486
530
|
if (block.type === "divider") return base;
|
|
@@ -488,8 +532,8 @@ function parserBlockToNotionBlock(block: NotionBlock, id: string, parentId: stri
|
|
|
488
532
|
if (block.type === "code") return { ...base, properties: { title: [[block.content]], language: [[block.properties["language"]!]] } };
|
|
489
533
|
if (block.type === "to_do") return { ...base, properties: { title: block.rich_text, checked: [[block.properties["checked"] === true ? "Yes" : "No"]] } };
|
|
490
534
|
if (block.type === "image") return { ...base, properties: { source: [[block.properties["source"]!]], alt_text: [[block.properties["alt_text"]!]], ...(block.properties["caption"] === undefined ? {} : { caption: block.properties["caption"]! }) } };
|
|
491
|
-
if (block.type === "table") return { ...base, properties: {}, format: { table_block_column_order: block.properties["column_ids"]!, table_block_column_header: block.properties["has_header"]!, table_block_row_header: block.properties["has_row_header"]! } };
|
|
492
|
-
if (block.type === "table_row") return { ...base, properties: block
|
|
535
|
+
if (block.type === "table") return { ...base, properties: {}, format: { table_block_column_order: columnOrder ?? block.properties["column_ids"]!, table_block_column_header: block.properties["has_header"]!, table_block_row_header: block.properties["has_row_header"]! } };
|
|
536
|
+
if (block.type === "table_row") return { ...base, properties: tableRowCells(block, columnOrder) };
|
|
493
537
|
if (block.type === "column_list" || block.type === "transclusion_container") return { ...base, properties: {} };
|
|
494
538
|
if (block.type === "column") return { ...base, properties: {}, ...(block.properties["format"] === undefined ? {} : { format: block.properties["format"]! }) };
|
|
495
539
|
if (block.type === "callout") return { ...base, properties: { title: block.rich_text }, ...(block.properties["format"] === undefined ? {} : { format: block.properties["format"]! }) };
|
|
@@ -497,12 +541,13 @@ function parserBlockToNotionBlock(block: NotionBlock, id: string, parentId: stri
|
|
|
497
541
|
return { ...base, properties: { title: block.rich_text } };
|
|
498
542
|
}
|
|
499
543
|
|
|
500
|
-
export function buildNotionCreateOperations(blocks: readonly NotionBlock[], pageId: string, spaceId: string, userId: string, currentTime: number, createId: () => string = () => randomUUID()): Readonly<{ operations: readonly NotionOperation[]; topLevelIds: readonly string[] }> {
|
|
544
|
+
export function buildNotionCreateOperations(blocks: readonly NotionBlock[], pageId: string, spaceId: string, userId: string, currentTime: number, createId: () => string = () => randomUUID(), initialTableColumnOrder?: readonly string[]): Readonly<{ operations: readonly NotionOperation[]; topLevelIds: readonly string[] }> {
|
|
501
545
|
const operations: NotionOperation[] = [];
|
|
502
546
|
const topLevelIds: string[] = [];
|
|
503
547
|
const lastAtIndent = new Map<number, string>();
|
|
504
548
|
const lastChildByParent = new Map<string, string>();
|
|
505
549
|
let lastTableId: string | null = null;
|
|
550
|
+
let tableColumnOrder: readonly string[] | undefined = initialTableColumnOrder;
|
|
506
551
|
for (const block of blocks) {
|
|
507
552
|
const blockId = formatBlockId(createId().replaceAll("-", ""));
|
|
508
553
|
let parentId = pageId;
|
|
@@ -514,12 +559,15 @@ export function buildNotionCreateOperations(blocks: readonly NotionBlock[], page
|
|
|
514
559
|
}
|
|
515
560
|
if (block.type !== "table_row" && block.indent === 0) topLevelIds.push(blockId);
|
|
516
561
|
const parentTable = "block";
|
|
517
|
-
operations.push({ pointer: pointer(blockId, spaceId), path: [], command: "set", args: parserBlockToNotionBlock(block, blockId, parentId, parentTable, spaceId, userId, currentTime) });
|
|
562
|
+
operations.push({ pointer: pointer(blockId, spaceId), path: [], command: "set", args: parserBlockToNotionBlock(block, blockId, parentId, parentTable, spaceId, userId, currentTime, block.type === "table_row" ? tableColumnOrder : undefined) });
|
|
518
563
|
const after = lastChildByParent.get(parentId);
|
|
519
564
|
operations.push({ pointer: pointer(parentId, spaceId), path: ["content"], command: after === undefined ? "listBefore" : "listAfter", args: after === undefined ? { id: blockId } : { id: blockId, after } });
|
|
520
565
|
lastChildByParent.set(parentId, blockId);
|
|
521
566
|
if (["bulleted_list", "numbered_list", "to_do", "quote", "callout", "toggle", "header", "sub_header", "sub_sub_header", "table", "page", "column_list", "column", "transclusion_container"].includes(block.type)) lastAtIndent.set(block.indent, blockId);
|
|
522
|
-
if (block.type === "table")
|
|
567
|
+
if (block.type === "table") {
|
|
568
|
+
lastTableId = blockId;
|
|
569
|
+
tableColumnOrder = block.properties["column_ids"] as readonly string[];
|
|
570
|
+
}
|
|
523
571
|
}
|
|
524
572
|
if (operations.length > 0) operations.push({ pointer: pointer(pageId, spaceId), path: ["last_edited_time"], command: "set", args: currentTime });
|
|
525
573
|
return { operations, topLevelIds };
|
|
@@ -531,7 +579,7 @@ function canonicalBlock(value: JsonObject, columnOrder?: readonly string[]): Jso
|
|
|
531
579
|
if (type === "code") return { type, title: normalizeRichText(object(value["properties"]!)["title"]!), language: object(value["properties"]!)["language"]! };
|
|
532
580
|
if (type === "to_do") return { type, title: normalizeRichText(object(value["properties"]!)["title"]!), checked: object(value["properties"]!)["checked"] ?? [["No"]] };
|
|
533
581
|
if (type === "table") return { type, column_count: (object(value["format"]!)["table_block_column_order"] as JsonValue[]).length };
|
|
534
|
-
if (type === "table_row") return { type, cells: columnOrder!.map((column) => normalizeRichText(object(value["properties"]!)[column]
|
|
582
|
+
if (type === "table_row") return { type, cells: columnOrder!.map((column) => normalizeRichText(object(value["properties"]!)[column] ?? [])) };
|
|
535
583
|
if (type === "image") return { type, source: object(value["properties"]!)["source"]!, alt_text: object(value["properties"]!)["alt_text"]!, caption: object(value["properties"]!)["caption"] ?? null };
|
|
536
584
|
if (["divider", "column_list", "transclusion_container"].includes(type)) return { type };
|
|
537
585
|
if (type === "column") return { type, column_ratio: object(value["format"] ?? {})["column_ratio"] ?? null };
|
|
@@ -546,8 +594,12 @@ function canonicalParserBlock(block: NotionBlock, columnOrder?: readonly string[
|
|
|
546
594
|
if (block.type === "code") return { type: "code", title: normalizeRichText([[block.content]]), language: [[block.properties["language"]!]] };
|
|
547
595
|
if (block.type === "to_do") return { type: "to_do", title: normalizeRichText(block.rich_text), checked: [[block.properties["checked"] === true ? "Yes" : "No"]] };
|
|
548
596
|
if (block.type === "table") return { type: "table", column_count: (block.properties["column_ids"] as JsonValue[]).length };
|
|
549
|
-
if (block.type === "table_row")
|
|
597
|
+
if (block.type === "table_row") {
|
|
598
|
+
const cells = tableRowCells(block, columnOrder);
|
|
599
|
+
return { type: "table_row", cells: columnOrder!.map((column) => normalizeRichText(cells[column] ?? [])) };
|
|
600
|
+
}
|
|
550
601
|
if (block.type === "image") return { type: "image", source: [[block.properties["source"]!]], alt_text: [[block.properties["alt_text"]!]], caption: block.properties["caption"] ?? null };
|
|
602
|
+
if (block.type === "page" || block.type === "equation") return { type: block.type, title: normalizeRichText(block.rich_text) };
|
|
551
603
|
if (block.type === "column") return { type: "column", column_ratio: object(block.properties["format"] ?? {})["column_ratio"] ?? null };
|
|
552
604
|
if (block.type === "column_list" || block.type === "transclusion_container") return { type: block.type };
|
|
553
605
|
return { type: block.type };
|
|
@@ -583,18 +635,21 @@ function localTree(blocks: readonly NotionBlock[]): LocalNotionNode[] {
|
|
|
583
635
|
return roots;
|
|
584
636
|
}
|
|
585
637
|
|
|
586
|
-
function outputNode(node: LocalNotionNode, remoteNode: NotionTree | undefined, parentId: string, remote: Readonly<{ spaceId: string; userId: string }>, currentTime: number): NotionTree {
|
|
638
|
+
function outputNode(node: LocalNotionNode, remoteNode: NotionTree | undefined, parentId: string, remote: Readonly<{ spaceId: string; userId: string }>, currentTime: number, columnOrder?: readonly string[]): NotionTree {
|
|
587
639
|
const id = remoteNode?.id ?? formatBlockId(randomUUID().replaceAll("-", ""));
|
|
588
|
-
|
|
640
|
+
const block = parserBlockToNotionBlock(node.block, id, parentId, "block", remote.spaceId, remote.userId, currentTime, node.block.type === "table" ? tableColumnOrder(remoteNode?.block, node.block) : node.block.type === "table_row" ? columnOrder : undefined);
|
|
641
|
+
const nextColumnOrder = block["type"] === "table" ? object(block["format"]!)["table_block_column_order"] as readonly string[] : columnOrder;
|
|
642
|
+
return { id, block, children: node.children.map((child, index) => outputNode(child, remoteNode?.children[index], id, remote, currentTime, nextColumnOrder)) };
|
|
589
643
|
}
|
|
590
644
|
|
|
591
|
-
function emitUpdates(remote: JsonObject, local: NotionBlock, blockId: string, spaceId: string): NotionOperation[] {
|
|
645
|
+
function emitUpdates(remote: JsonObject, local: NotionBlock, blockId: string, spaceId: string, columnOrder?: readonly string[]): NotionOperation[] {
|
|
592
646
|
const operations: NotionOperation[] = [];
|
|
593
647
|
const remoteType = remote["type"] === "text" && object(remote["format"] ?? {})["toggleable"] === true ? "toggle" : remote["type"] as string;
|
|
594
648
|
const localType = local.type === "toggle" ? "text" : local.type;
|
|
595
649
|
const typeChanged = remoteType !== local.type;
|
|
596
650
|
if (typeChanged) operations.push({ pointer: pointer(blockId, spaceId), path: ["type"], command: "set", args: localType });
|
|
597
|
-
const
|
|
651
|
+
const effectiveColumnOrder = local.type === "table" ? tableColumnOrder(remote, local) : columnOrder;
|
|
652
|
+
const args = parserBlockToNotionBlock(local, blockId, remote["parent_id"] as string ?? "", "block", spaceId, "", 0, local.type === "table" || local.type === "table_row" ? effectiveColumnOrder : undefined);
|
|
598
653
|
const remoteProperties = object(remote["properties"] ?? {});
|
|
599
654
|
const nextProperties = object(args["properties"] ?? {});
|
|
600
655
|
if (typeChanged) {
|
|
@@ -617,8 +672,8 @@ function flattenLocalSubtree(node: LocalNotionNode): readonly NotionBlock[] {
|
|
|
617
672
|
return blocks;
|
|
618
673
|
}
|
|
619
674
|
|
|
620
|
-
function buildNotionCreateSubtreeOperations(node: LocalNotionNode, parentId: string, ambient: Readonly<{ spaceId: string; userId: string; currentTime: number }
|
|
621
|
-
return buildNotionCreateOperations(flattenLocalSubtree(node), parentId, ambient.spaceId, ambient.userId, ambient.currentTime);
|
|
675
|
+
function buildNotionCreateSubtreeOperations(node: LocalNotionNode, parentId: string, ambient: Readonly<{ spaceId: string; userId: string; currentTime: number }>, columnOrder?: readonly string[]): Readonly<{ operations: readonly NotionOperation[]; topLevelIds: readonly string[] }> {
|
|
676
|
+
return buildNotionCreateOperations(flattenLocalSubtree(node), parentId, ambient.spaceId, ambient.userId, ambient.currentTime, undefined, columnOrder);
|
|
622
677
|
}
|
|
623
678
|
|
|
624
679
|
function positionRootCreateOperations(operations: readonly NotionOperation[], parentId: string, spaceId: string, previousId: string | undefined): readonly NotionOperation[] {
|
|
@@ -644,10 +699,10 @@ function deleteRemoteSubtreeOperations(node: NotionTree, parentId: string, space
|
|
|
644
699
|
];
|
|
645
700
|
}
|
|
646
701
|
|
|
647
|
-
function diffNotionChildLists(remoteParent: NotionTree, localChildren: readonly LocalNotionNode[], ambient: Readonly<{ spaceId: string; userId: string; currentTime: number }>, summary: { inserted: number; updated: number; deleted: number; moved: number }, columnOrder?: readonly string[]): NotionOperation[] {
|
|
702
|
+
function diffNotionChildLists(remoteParent: NotionTree, localChildren: readonly LocalNotionNode[], ambient: Readonly<{ spaceId: string; userId: string; currentTime: number }>, summary: { inserted: number; updated: number; deleted: number; moved: number }, columnOrder?: readonly string[], localParent?: NotionBlock): NotionOperation[] {
|
|
648
703
|
const operations: NotionOperation[] = [];
|
|
649
704
|
const remoteChildren = [...remoteParent.children];
|
|
650
|
-
const nextColumnOrder = remoteParent.block["type"] === "table" ?
|
|
705
|
+
const nextColumnOrder = remoteParent.block["type"] === "table" ? tableColumnOrder(remoteParent.block, localParent!) : columnOrder;
|
|
651
706
|
const remoteHash = (index: number) => notionBlockContentHash(remoteChildren[index]!.block, nextColumnOrder);
|
|
652
707
|
const localHash = (index: number) => notionBlockContentHash(localChildren[index]!.block, nextColumnOrder);
|
|
653
708
|
let remoteIndex = 0;
|
|
@@ -657,7 +712,7 @@ function diffNotionChildLists(remoteParent: NotionTree, localChildren: readonly
|
|
|
657
712
|
const remoteNode = remoteChildren[remoteIndex]!;
|
|
658
713
|
const localNode = localChildren[localIndex]!;
|
|
659
714
|
if (remoteHash(remoteIndex) === localHash(localIndex)) {
|
|
660
|
-
operations.push(...diffNotionChildLists(remoteNode, localNode.children, ambient, summary, nextColumnOrder));
|
|
715
|
+
operations.push(...diffNotionChildLists(remoteNode, localNode.children, ambient, summary, nextColumnOrder, localNode.block));
|
|
661
716
|
previousId = remoteNode.id;
|
|
662
717
|
remoteIndex += 1;
|
|
663
718
|
localIndex += 1;
|
|
@@ -674,7 +729,7 @@ function diffNotionChildLists(remoteParent: NotionTree, localChildren: readonly
|
|
|
674
729
|
continue;
|
|
675
730
|
}
|
|
676
731
|
if (localIndex + 1 < localChildren.length && remoteHash(remoteIndex) === localHash(localIndex + 1)) {
|
|
677
|
-
const built = buildNotionCreateSubtreeOperations(localNode, remoteParent.id, ambient);
|
|
732
|
+
const built = buildNotionCreateSubtreeOperations(localNode, remoteParent.id, ambient, nextColumnOrder);
|
|
678
733
|
operations.push(...positionRootCreateOperations(built.operations, remoteParent.id, ambient.spaceId, previousId));
|
|
679
734
|
summary.inserted += localSubtreeSize(localNode);
|
|
680
735
|
previousId = built.topLevelIds[0]!;
|
|
@@ -688,8 +743,8 @@ function diffNotionChildLists(remoteParent: NotionTree, localChildren: readonly
|
|
|
688
743
|
continue;
|
|
689
744
|
}
|
|
690
745
|
const before = operations.length;
|
|
691
|
-
operations.push(...emitUpdates(remoteNode.block, localNode.block, remoteNode.id, ambient.spaceId));
|
|
692
|
-
operations.push(...diffNotionChildLists(remoteNode, localNode.children, ambient, summary, nextColumnOrder));
|
|
746
|
+
operations.push(...emitUpdates(remoteNode.block, localNode.block, remoteNode.id, ambient.spaceId, nextColumnOrder));
|
|
747
|
+
operations.push(...diffNotionChildLists(remoteNode, localNode.children, ambient, summary, nextColumnOrder, localNode.block));
|
|
693
748
|
if (operations.length > before) summary.updated += 1;
|
|
694
749
|
previousId = remoteNode.id;
|
|
695
750
|
remoteIndex += 1;
|
|
@@ -697,7 +752,7 @@ function diffNotionChildLists(remoteParent: NotionTree, localChildren: readonly
|
|
|
697
752
|
}
|
|
698
753
|
while (localIndex < localChildren.length) {
|
|
699
754
|
const localNode = localChildren[localIndex]!;
|
|
700
|
-
const built = buildNotionCreateSubtreeOperations(localNode, remoteParent.id, ambient);
|
|
755
|
+
const built = buildNotionCreateSubtreeOperations(localNode, remoteParent.id, ambient, nextColumnOrder);
|
|
701
756
|
operations.push(...positionRootCreateOperations(built.operations, remoteParent.id, ambient.spaceId, previousId ?? remoteChildren[remoteChildren.length - 1]?.id));
|
|
702
757
|
summary.inserted += localSubtreeSize(localNode);
|
|
703
758
|
previousId = built.topLevelIds[0]!;
|
|
@@ -732,19 +787,19 @@ function renderNode(tree: NotionTree, indent: number, parentType = ""): string[]
|
|
|
732
787
|
}
|
|
733
788
|
if (type === "bulleted_list") {
|
|
734
789
|
const lines = title.split("\n");
|
|
735
|
-
return [`${prefix}- ${lines[0]}`, ...lines.slice(1).map((line) => `${prefix} ${line}`), ...tree.children.flatMap((child) => renderNode(child, indent + 1, type))];
|
|
790
|
+
return [`${prefix}- ${lines[0]}`, ...lines.slice(1).map((line) => `${prefix} ${escapeBlockMarkdownLine(line)}`), ...tree.children.flatMap((child) => renderNode(child, indent + 1, type))];
|
|
736
791
|
}
|
|
737
792
|
if (type === "numbered_list") {
|
|
738
793
|
const lines = title.split("\n");
|
|
739
|
-
return [`${prefix}1. ${lines[0]}`, ...lines.slice(1).map((line) => `${prefix} ${line}`), ...tree.children.flatMap((child) => renderNode(child, indent + 1, type))];
|
|
794
|
+
return [`${prefix}1. ${lines[0]}`, ...lines.slice(1).map((line) => `${prefix} ${escapeBlockMarkdownLine(line)}`), ...tree.children.flatMap((child) => renderNode(child, indent + 1, type))];
|
|
740
795
|
}
|
|
741
796
|
if (type === "to_do") {
|
|
742
797
|
const checked = richTextText(properties["checked"] ?? [["No"]]) === "Yes";
|
|
743
798
|
if (title === "") return [`${prefix}:::to-do`, `${prefix}:::checked ${JSON.stringify(checked)}`, prefix, ...tree.children.flatMap((child) => renderNode(child, indent + 1, type)), `${prefix}:::`];
|
|
744
799
|
const lines = title.split("\n");
|
|
745
|
-
return [`${prefix}- [${checked ? "x" : " "}] ${lines[0]}`, ...lines.slice(1).map((line) => `${prefix} ${line}`), ...tree.children.flatMap((child) => renderNode(child, indent + 1, type))];
|
|
800
|
+
return [`${prefix}- [${checked ? "x" : " "}] ${lines[0]}`, ...lines.slice(1).map((line) => `${prefix} ${escapeBlockMarkdownLine(line)}`), ...tree.children.flatMap((child) => renderNode(child, indent + 1, type))];
|
|
746
801
|
}
|
|
747
|
-
if (type === "quote") return [`${prefix}> ${
|
|
802
|
+
if (type === "quote") return [...title.split("\n").map((line) => `${prefix}> ${escapeBlockMarkdownLine(line)}`), ...tree.children.flatMap((child) => renderNode(child, indent + 1, type))];
|
|
748
803
|
if (type === "divider") return [`${prefix}---`];
|
|
749
804
|
if (type === "code") {
|
|
750
805
|
const code = richTextText(properties["title"]!);
|
|
@@ -772,7 +827,7 @@ function renderNode(tree: NotionTree, indent: number, parentType = ""): string[]
|
|
|
772
827
|
}
|
|
773
828
|
if (title === "") return [`${prefix}:::text`, `${prefix}:::`];
|
|
774
829
|
if (["bulleted_list", "numbered_list", "to_do"].includes(parentType)) return [`${prefix}:::text`, ...title.split("\n").map((line) => `${prefix}${line}`), `${prefix}:::`];
|
|
775
|
-
return
|
|
830
|
+
return title.split("\n").map((line) => `${prefix}${escapeBlockMarkdownLine(line)}`);
|
|
776
831
|
}
|
|
777
832
|
|
|
778
833
|
export function renderNotionTreeToMarkdown(tree: NotionTree, mentions?: UserMentions): string {
|
|
@@ -801,9 +856,9 @@ async function fetchTree(runtime: RuntimeCapabilities, url: string, source: Sour
|
|
|
801
856
|
await runtime.http.request(url, { headers: { cookie } });
|
|
802
857
|
const spaces = await notionPost(runtime, "getSpaces", cookie, {}, {});
|
|
803
858
|
const spaceView = object(object(spaces[userId]!)["space_view"]!);
|
|
804
|
-
const
|
|
859
|
+
const initialSpaceId = object(spaceView[Object.keys(spaceView)[0]!]!)["spaceId"] as string;
|
|
805
860
|
const pageId = formatBlockId(source.identifier);
|
|
806
|
-
|
|
861
|
+
let headers = { "x-notion-active-user-header": userId, "x-notion-space-id": initialSpaceId, referer: url, ...(csrf === undefined ? {} : { "x-csrf-token": csrf }) };
|
|
807
862
|
const blocks = new Map<string, JsonObject>();
|
|
808
863
|
let stack: JsonValue[] = [];
|
|
809
864
|
let chunkNumber = 0;
|
|
@@ -814,6 +869,8 @@ async function fetchTree(runtime: RuntimeCapabilities, url: string, source: Sour
|
|
|
814
869
|
stack = cursors.length === 0 ? [] : cursors[0]!["stack"] as JsonValue[];
|
|
815
870
|
chunkNumber += 1;
|
|
816
871
|
} while (stack.length > 0);
|
|
872
|
+
const spaceId = blocks.get(pageId)!["space_id"] as string;
|
|
873
|
+
headers = { ...headers, "x-notion-space-id": spaceId };
|
|
817
874
|
while (true) {
|
|
818
875
|
const missing = new Set<string>();
|
|
819
876
|
const pending = [pageId];
|
|
@@ -862,6 +919,7 @@ export async function uploadNotionDocument(runtime: RuntimeCapabilities, markdow
|
|
|
862
919
|
const csrf = cookies.find((value) => value.name === "csrf")?.value;
|
|
863
920
|
const spaces = await notionPost(runtime, "getSpaces", cookie, {}, {});
|
|
864
921
|
const spaceView = object(object(spaces[userId]!)["space_view"]!);
|
|
922
|
+
if (Object.keys(spaceView).length !== 1) throw new Error("Notion upload requires an explicit target workspace.");
|
|
865
923
|
const spaceId = object(spaceView[Object.keys(spaceView)[0]!]!)["spaceId"] as string;
|
|
866
924
|
const pageId = randomUUID();
|
|
867
925
|
const compactPageId = pageId.replaceAll("-", "");
|
|
@@ -908,8 +966,7 @@ function splitTitle(markdown: string): Readonly<{ title: string; body: string }>
|
|
|
908
966
|
return { title: "", body: markdown };
|
|
909
967
|
}
|
|
910
968
|
|
|
911
|
-
export async function synchronizeNotionDocument(runtime: RuntimeCapabilities, url: string, base: JsonValue, markdown: string, _markdownPath: string): Promise<FetchedDocument> {
|
|
912
|
-
const source: Source = { service: "notion", identifier: /([a-f0-9]{32})/.exec(url)![1]!, type: "document" };
|
|
969
|
+
export async function synchronizeNotionDocument(runtime: RuntimeCapabilities, url: string, source: Source, base: JsonValue, markdown: string, _markdownPath: string): Promise<FetchedDocument> {
|
|
913
970
|
const remote = await fetchTree(runtime, url, source);
|
|
914
971
|
const baseObject = object(base);
|
|
915
972
|
const mentions = baseUserMentions(baseObject);
|
|
@@ -924,8 +981,6 @@ export async function synchronizeNotionDocument(runtime: RuntimeCapabilities, ur
|
|
|
924
981
|
const remoteTitleChanged = baseSplit.title !== currentSplit.title;
|
|
925
982
|
const localBodyChanged = baseSplit.body !== split.body;
|
|
926
983
|
const remoteBodyChanged = baseSplit.body !== currentSplit.body;
|
|
927
|
-
if (localTitleChanged && remoteTitleChanged && split.title !== currentSplit.title) throw new Error("Markdown and Notion changed since last sync");
|
|
928
|
-
if (localBodyChanged && remoteBodyChanged && split.body !== currentSplit.body) throw new Error("Markdown and Notion changed since last sync");
|
|
929
984
|
if ((localTitleChanged || localBodyChanged) && (remoteTitleChanged || remoteBodyChanged)) {
|
|
930
985
|
split = { title: localTitleChanged ? split.title : currentSplit.title, body: localBodyChanged ? split.body : currentSplit.body };
|
|
931
986
|
fieldMerged = true;
|
|
@@ -9,6 +9,6 @@ export const notionService = defineService<RuntimeCapabilities>({
|
|
|
9
9
|
matches: (url) => (url.hostname === "www.notion.so" || url.hostname === "notion.so" || url.hostname === "app.notion.com" || url.hostname.endsWith(".notion.site")) && notionPageId.test(url.href),
|
|
10
10
|
parse: (url) => Object.freeze({ service: "notion", identifier: notionPageId.exec(url.href)![0]!.replaceAll("-", "").toLowerCase(), type: "document" }),
|
|
11
11
|
fetch: fetchNotionDocument,
|
|
12
|
-
synchronize: (runtime, url,
|
|
12
|
+
synchronize: (runtime, url, source, base, markdown, markdownPath) => synchronizeNotionDocument(runtime, url, source, base, markdown, markdownPath),
|
|
13
13
|
upload: uploadNotionDocument,
|
|
14
14
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"slack.d.ts","sourceRoot":"","sources":["../src/slack.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,WAAW,CAAC;AAgDrD,eAAO,MAAM,YAAY;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"slack.d.ts","sourceRoot":"","sources":["../src/slack.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,WAAW,CAAC;AAgDrD,eAAO,MAAM,YAAY;;;;;;;;;;;;;;;;;;;;;;;;;EAkEvB,CAAC"}
|
|
@@ -60,7 +60,13 @@ export const slackService = defineService({
|
|
|
60
60
|
const metadata = await runtime.cookies.metadata("slack");
|
|
61
61
|
const origin = new URL(url).hostname === "app.slack.com" ? metadata["origin"] : new URL(url).origin;
|
|
62
62
|
const token = metadata["token"];
|
|
63
|
-
const
|
|
63
|
+
const replies = [];
|
|
64
|
+
let cursor;
|
|
65
|
+
do {
|
|
66
|
+
const response = await api(runtime, origin, token, cookie, "conversations.replies", { channel: source["channel_id"], ts: source["thread_timestamp"], limit: "999", ...(cursor === undefined ? {} : { cursor }) });
|
|
67
|
+
replies.push(...response["messages"]);
|
|
68
|
+
cursor = response["response_metadata"]?.["next_cursor"];
|
|
69
|
+
} while (cursor !== undefined && cursor !== "");
|
|
64
70
|
const userCache = new Map();
|
|
65
71
|
const botCache = new Map();
|
|
66
72
|
const resolveUser = async (id) => {
|
|
@@ -75,7 +81,7 @@ export const slackService = defineService({
|
|
|
75
81
|
return userCache.get(id);
|
|
76
82
|
};
|
|
77
83
|
const messages = [];
|
|
78
|
-
for (const raw of
|
|
84
|
+
for (const raw of replies) {
|
|
79
85
|
const userId = raw["user"];
|
|
80
86
|
let userName;
|
|
81
87
|
if (userId !== undefined)
|
|
@@ -92,17 +98,18 @@ export const slackService = defineService({
|
|
|
92
98
|
}
|
|
93
99
|
else
|
|
94
100
|
userName = "unknown";
|
|
95
|
-
|
|
101
|
+
const text = raw["text"];
|
|
96
102
|
const files = raw["files"] === undefined ? [] : raw["files"].map((file) => Object.freeze({ name: file["name"], url: file["url_private"] }));
|
|
97
|
-
if (text.trim() === "" && files.length > 0)
|
|
98
|
-
text = files.map((file) => `- [${markdownLinkLabel(file.name)}](${file.url})`).join("\n");
|
|
99
103
|
messages.push({ ts: raw["ts"], user_id: userId ?? "unknown", user_name: userName, text, files });
|
|
100
104
|
}
|
|
101
105
|
const mentioned = new Set(messages.flatMap((message) => [...message.text.matchAll(/<@([A-Z0-9]+)(?:\|[^>]+)?>/g)].map((match) => match[1])));
|
|
102
106
|
for (const id of mentioned)
|
|
103
107
|
await resolveUser(id);
|
|
104
|
-
for (const message of messages)
|
|
105
|
-
|
|
108
|
+
for (const message of messages) {
|
|
109
|
+
const cleaned = cleanText(message.text.replace(/<@([A-Z0-9]+)(?:\|[^>]+)?>/g, (_match, id) => `@${userCache.get(id)}`)).replace(/```([^\n])/g, "```\n$1").replace(/([^\n])```/g, "$1\n```");
|
|
110
|
+
const fileLines = message.files.map((file) => `- [${markdownLinkLabel(file.name)}](${file.url})`).join("\n");
|
|
111
|
+
message.text = cleaned.trim() === "" ? fileLines : fileLines === "" ? cleaned : `${cleaned}\n\n${fileLines}`;
|
|
112
|
+
}
|
|
106
113
|
const timezone = runtime.clock.localTimezone();
|
|
107
114
|
const date = formatTimestamp(messages[0].ts, timezone).slice(0, 10);
|
|
108
115
|
const titleText = messages[0].text.replace(/https?:\/\/\S+/g, "").slice(0, 30).replace(/[^\p{L}\p{N}_\s-]/gu, "").replace(/[\s-]+/g, "_").replace(/^_+|_+$/g, "");
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"slack.js","sourceRoot":"","sources":["../src/slack.ts"],"names":[],"mappings":"AA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C;QAC3B,KAAK,MAAM,OAAO,IAAI,QAAQ;YAAE,KAAK,CAAC,IAAI,CAAC,MAAM,OAAO,CAAC,SAAS,MAAM,eAAe,CAAC,OAAO,CAAC,EAAE,EAAE,QAAQ,CAAC,EAAE,EAAE,EAAE,EAAE,OAAO,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;QACvI,OAAO,MAAM,CAAC,MAAM,CAAC,EAAE,KAAK,EAAE,GAAG,IAAI,IAAI,SAAS,EAAE,EAAE,QAAQ,EAAE,GAAG,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,EAAE,UAAU,EAAE,MAAM,CAAC,YAAY,CAAW,EAAE,QAAQ,EAAE,EAAE,CAAC,CAAC;IACvK,CAAC;CACF,CAAC,CAAC"}
|
|
@@ -64,7 +64,13 @@ export const slackService = defineService<RuntimeCapabilities>({
|
|
|
64
64
|
const metadata = await runtime.cookies.metadata("slack");
|
|
65
65
|
const origin = new URL(url).hostname === "app.slack.com" ? metadata["origin"]! : new URL(url).origin;
|
|
66
66
|
const token = metadata["token"]!;
|
|
67
|
-
const
|
|
67
|
+
const replies: JsonObject[] = [];
|
|
68
|
+
let cursor: string | undefined;
|
|
69
|
+
do {
|
|
70
|
+
const response = await api(runtime, origin, token, cookie, "conversations.replies", { channel: source["channel_id"] as string, ts: source["thread_timestamp"] as string, limit: "999", ...(cursor === undefined ? {} : { cursor }) });
|
|
71
|
+
replies.push(...response["messages"] as readonly JsonObject[]);
|
|
72
|
+
cursor = ((response["response_metadata"] as JsonObject | undefined)?.["next_cursor"] as string | undefined);
|
|
73
|
+
} while (cursor !== undefined && cursor !== "");
|
|
68
74
|
const userCache = new Map<string, string>();
|
|
69
75
|
const botCache = new Map<string, string>();
|
|
70
76
|
const resolveUser = async (id: string) => {
|
|
@@ -79,7 +85,7 @@ export const slackService = defineService<RuntimeCapabilities>({
|
|
|
79
85
|
return userCache.get(id)!;
|
|
80
86
|
};
|
|
81
87
|
const messages = [];
|
|
82
|
-
for (const raw of
|
|
88
|
+
for (const raw of replies) {
|
|
83
89
|
const userId = raw["user"] as string | undefined;
|
|
84
90
|
let userName: string;
|
|
85
91
|
if (userId !== undefined) userName = await resolveUser(userId);
|
|
@@ -90,14 +96,17 @@ export const slackService = defineService<RuntimeCapabilities>({
|
|
|
90
96
|
if (!botCache.has(botId)) botCache.set(botId, ((await api(runtime, origin, token, cookie, "bots.info", { bot: botId }))["bot"] as JsonObject)["name"] as string);
|
|
91
97
|
userName = botCache.get(botId)!;
|
|
92
98
|
} else userName = "unknown";
|
|
93
|
-
|
|
99
|
+
const text = raw["text"] as string;
|
|
94
100
|
const files = raw["files"] === undefined ? [] : (raw["files"] as readonly JsonObject[]).map((file) => Object.freeze({ name: file["name"] as string, url: file["url_private"] as string }));
|
|
95
|
-
if (text.trim() === "" && files.length > 0) text = files.map((file) => `- [${markdownLinkLabel(file.name)}](${file.url})`).join("\n");
|
|
96
101
|
messages.push({ ts: raw["ts"] as string, user_id: userId ?? "unknown", user_name: userName, text, files });
|
|
97
102
|
}
|
|
98
103
|
const mentioned = new Set(messages.flatMap((message) => [...message.text.matchAll(/<@([A-Z0-9]+)(?:\|[^>]+)?>/g)].map((match) => match[1]!)));
|
|
99
104
|
for (const id of mentioned) await resolveUser(id);
|
|
100
|
-
for (const message of messages)
|
|
105
|
+
for (const message of messages) {
|
|
106
|
+
const cleaned = cleanText(message.text.replace(/<@([A-Z0-9]+)(?:\|[^>]+)?>/g, (_match, id: string) => `@${userCache.get(id)!}`)).replace(/```([^\n])/g, "```\n$1").replace(/([^\n])```/g, "$1\n```");
|
|
107
|
+
const fileLines = message.files.map((file) => `- [${markdownLinkLabel(file.name)}](${file.url})`).join("\n");
|
|
108
|
+
message.text = cleaned.trim() === "" ? fileLines : fileLines === "" ? cleaned : `${cleaned}\n\n${fileLines}`;
|
|
109
|
+
}
|
|
101
110
|
const timezone = runtime.clock.localTimezone();
|
|
102
111
|
const date = formatTimestamp(messages[0]!.ts, timezone).slice(0, 10);
|
|
103
112
|
const titleText = messages[0]!.text.replace(/https?:\/\/\S+/g, "").slice(0, 30).replace(/[^\p{L}\p{N}_\s-]/gu, "").replace(/[\s-]+/g, "_").replace(/^_+|_+$/g, "");
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"zoom-hub.d.ts","sourceRoot":"","sources":["../src/zoom-hub.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"zoom-hub.d.ts","sourceRoot":"","sources":["../src/zoom-hub.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,WAAW,CAAC;AAwJrD,eAAO,MAAM,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;EAmEzB,CAAC"}
|