@wirecat/notion-cli 0.3.0 → 0.4.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/CHANGELOG.md +25 -0
- package/README.md +3 -0
- package/contracts/wirecat.json +49 -0
- package/dist/bin/notion.js +2 -2
- package/dist/bundle/{chunk-CBGBFAYJ.js → chunk-FIHXADRF.js} +3 -1
- package/dist/bundle/notion.js +2 -2
- package/dist/bundle/{program-QC5MX4ZJ.js → program-7K34KI27.js} +510 -173
- package/dist/commands/comments.d.ts +4 -0
- package/dist/commands/comments.d.ts.map +1 -0
- package/dist/commands/comments.js +80 -0
- package/dist/commands/comments.js.map +1 -0
- package/dist/commands/documents.d.ts.map +1 -1
- package/dist/commands/documents.js +5 -102
- package/dist/commands/documents.js.map +1 -1
- package/dist/commands/files.d.ts +4 -0
- package/dist/commands/files.d.ts.map +1 -0
- package/dist/commands/files.js +57 -0
- package/dist/commands/files.js.map +1 -0
- package/dist/commands/library.d.ts.map +1 -1
- package/dist/commands/library.js +47 -8
- package/dist/commands/library.js.map +1 -1
- package/dist/commands/writing.d.ts +32 -0
- package/dist/commands/writing.d.ts.map +1 -0
- package/dist/commands/writing.js +126 -0
- package/dist/commands/writing.js.map +1 -0
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +3 -0
- package/dist/config.js.map +1 -1
- package/dist/notion/errors.d.ts.map +1 -1
- package/dist/notion/errors.js +2 -0
- package/dist/notion/errors.js.map +1 -1
- package/dist/notion/notion.d.ts +38 -0
- package/dist/notion/notion.d.ts.map +1 -1
- package/dist/notion/notion.js +43 -0
- package/dist/notion/notion.js.map +1 -1
- package/dist/notion/writes.d.ts +38 -0
- package/dist/notion/writes.d.ts.map +1 -1
- package/dist/notion/writes.js +73 -0
- package/dist/notion/writes.js.map +1 -1
- package/dist/program.d.ts.map +1 -1
- package/dist/program.js +4 -0
- package/dist/program.js.map +1 -1
- package/dist/sync/browse.d.ts +30 -0
- package/dist/sync/browse.d.ts.map +1 -0
- package/dist/sync/browse.js +67 -0
- package/dist/sync/browse.js.map +1 -0
- package/dist/sync/cursor.d.ts +17 -0
- package/dist/sync/cursor.d.ts.map +1 -1
- package/dist/sync/cursor.js +28 -0
- package/dist/sync/cursor.js.map +1 -1
- package/dist/sync/files.d.ts +1 -0
- package/dist/sync/files.d.ts.map +1 -1
- package/dist/sync/files.js +10 -0
- package/dist/sync/files.js.map +1 -1
- package/dist/sync/source.d.ts +3 -3
- package/dist/sync/source.d.ts.map +1 -1
- package/dist/sync/source.js +39 -39
- package/dist/sync/source.js.map +1 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +1 -1
|
@@ -817,7 +817,7 @@ import {
|
|
|
817
817
|
isRefused,
|
|
818
818
|
mapped,
|
|
819
819
|
require_src
|
|
820
|
-
} from "./chunk-
|
|
820
|
+
} from "./chunk-FIHXADRF.js";
|
|
821
821
|
import {
|
|
822
822
|
installerOf
|
|
823
823
|
} from "./chunk-YAPDU3SV.js";
|
|
@@ -27552,7 +27552,10 @@ var PAGE_WRITE_KEYS = {
|
|
|
27552
27552
|
"documents create": ["api.post-page"],
|
|
27553
27553
|
"documents update": ["api.update-page-markdown"],
|
|
27554
27554
|
"documents delete": ["api.patch-page"],
|
|
27555
|
-
"documents restore": ["api.patch-page"]
|
|
27555
|
+
"documents restore": ["api.patch-page"],
|
|
27556
|
+
"comments create": ["api.create-a-comment"],
|
|
27557
|
+
"comments reply": ["comments.create", "api.create-a-comment"],
|
|
27558
|
+
"files upload": ["api.create-file", "api.complete-file-upload", "api.patch-block-children"]
|
|
27556
27559
|
};
|
|
27557
27560
|
var TRASHING_OPERATIONS = [
|
|
27558
27561
|
"patch-page",
|
|
@@ -27903,6 +27906,29 @@ var databaseSchema = strictObject({
|
|
|
27903
27906
|
last_edited_time: nullable(string()),
|
|
27904
27907
|
data_sources: array(strictObject({ id: string(), title: string(), properties: array(propertySchema) }))
|
|
27905
27908
|
});
|
|
27909
|
+
var wireComment = looseObject({
|
|
27910
|
+
object: literal("comment"),
|
|
27911
|
+
id: string(),
|
|
27912
|
+
discussion_id: string(),
|
|
27913
|
+
parent: wireParent,
|
|
27914
|
+
created_time: string(),
|
|
27915
|
+
last_edited_time: optional(string()),
|
|
27916
|
+
created_by: looseObject({ id: string() }),
|
|
27917
|
+
rich_text: richText,
|
|
27918
|
+
display_name: optional(looseObject({ resolved_name: nullish(string()) })),
|
|
27919
|
+
attachments: optional(array(unknown()))
|
|
27920
|
+
});
|
|
27921
|
+
var commentSchema = strictObject({
|
|
27922
|
+
id: string(),
|
|
27923
|
+
discussion_id: string(),
|
|
27924
|
+
parent: nullable(strictObject({ type: string(), id: nullable(string()) })),
|
|
27925
|
+
author_id: string(),
|
|
27926
|
+
author_name: nullable(string()),
|
|
27927
|
+
text: string(),
|
|
27928
|
+
attachments: number(),
|
|
27929
|
+
created_time: string(),
|
|
27930
|
+
last_edited_time: nullable(string())
|
|
27931
|
+
});
|
|
27906
27932
|
var MORE_BLOCKS = 100;
|
|
27907
27933
|
var MORE_SOURCES = 100;
|
|
27908
27934
|
var placeholderFor = /* @__PURE__ */ __name((markdown, id5) => {
|
|
@@ -27993,6 +28019,25 @@ ${part.markdown}`;
|
|
|
27993
28019
|
});
|
|
27994
28020
|
return { items, hasMore: page.has_more, cursor: page.has_more ? page.next_cursor ?? void 0 : void 0 };
|
|
27995
28021
|
}, "databases"),
|
|
28022
|
+
/** One page of a page's or block's comments; Notion's API lists only the unresolved ones. */
|
|
28023
|
+
comments: /* @__PURE__ */ __name(async ({ block, limit, cursor }) => {
|
|
28024
|
+
const page = parsed(wireSearch, await mapped(() => client.comments.list({ block_id: block, page_size: limit, ...cursor ? { start_cursor: cursor } : {} })));
|
|
28025
|
+
const items = page.results.map((result) => {
|
|
28026
|
+
const comment = parsed(wireComment, result);
|
|
28027
|
+
return {
|
|
28028
|
+
id: comment.id,
|
|
28029
|
+
discussion_id: comment.discussion_id,
|
|
28030
|
+
parent: parentOf(comment.parent),
|
|
28031
|
+
author_id: comment.created_by.id,
|
|
28032
|
+
author_name: comment.display_name?.resolved_name ?? null,
|
|
28033
|
+
text: textOf2(comment.rich_text),
|
|
28034
|
+
attachments: comment.attachments?.length ?? 0,
|
|
28035
|
+
created_time: comment.created_time,
|
|
28036
|
+
last_edited_time: comment.last_edited_time ?? null
|
|
28037
|
+
};
|
|
28038
|
+
});
|
|
28039
|
+
return { items, hasMore: page.has_more, cursor: page.has_more ? page.next_cursor ?? void 0 : void 0 };
|
|
28040
|
+
}, "comments"),
|
|
27996
28041
|
/** A database with each data source's id and property schema: what a query or a filter needs. */
|
|
27997
28042
|
database: /* @__PURE__ */ __name(async (id5) => {
|
|
27998
28043
|
const database = parsed(wireDatabase, await mapped(() => client.databases.retrieve({ database_id: id5 })));
|
|
@@ -28051,6 +28096,31 @@ var parsed2 = /* @__PURE__ */ __name((schema, value3) => {
|
|
|
28051
28096
|
reason: "notion.invalid-response"
|
|
28052
28097
|
});
|
|
28053
28098
|
}, "parsed");
|
|
28099
|
+
var wireComment2 = looseObject({
|
|
28100
|
+
object: literal("comment"),
|
|
28101
|
+
id: string(),
|
|
28102
|
+
discussion_id: string(),
|
|
28103
|
+
created_time: optional(string())
|
|
28104
|
+
});
|
|
28105
|
+
var wireUpload = looseObject({
|
|
28106
|
+
object: literal("file_upload"),
|
|
28107
|
+
id: string(),
|
|
28108
|
+
status: string(),
|
|
28109
|
+
filename: nullish(string()),
|
|
28110
|
+
content_type: nullish(string())
|
|
28111
|
+
});
|
|
28112
|
+
var wireAppended = looseObject({
|
|
28113
|
+
object: literal("list"),
|
|
28114
|
+
results: array(looseObject({ id: string(), type: string() }))
|
|
28115
|
+
});
|
|
28116
|
+
var SINGLE_PART_BYTES = 20 * 1024 * 1024;
|
|
28117
|
+
var PART_BYTES = 10 * 1024 * 1024;
|
|
28118
|
+
var blockTypeOf = /* @__PURE__ */ __name((contentType) => {
|
|
28119
|
+
const [kind4] = (contentType ?? "").split("/");
|
|
28120
|
+
if (kind4 === "image" || kind4 === "video" || kind4 === "audio")
|
|
28121
|
+
return kind4;
|
|
28122
|
+
return contentType === "application/pdf" ? "pdf" : "file";
|
|
28123
|
+
}, "blockTypeOf");
|
|
28054
28124
|
var pageSchema = strictObject({
|
|
28055
28125
|
id: string(),
|
|
28056
28126
|
title: string(),
|
|
@@ -28112,6 +28182,47 @@ var liveWrites = /* @__PURE__ */ __name((client) => ({
|
|
|
28112
28182
|
throw allowDeleting ? error : withContentHint(error);
|
|
28113
28183
|
}
|
|
28114
28184
|
}), "replace"),
|
|
28185
|
+
/** A comment on a page, or a reply in a discussion; Notion takes inline Markdown only ([create a comment](https://developers.notion.com/reference/create-a-comment)). */
|
|
28186
|
+
comment: /* @__PURE__ */ __name((target, markdown) => writing(async () => {
|
|
28187
|
+
const body = "page" in target ? { parent: { page_id: target.page }, markdown, markdown_version: "v2" } : { discussion_id: target.discussion, markdown, markdown_version: "v2" };
|
|
28188
|
+
const comment = parsed2(wireComment2, await mapped(() => client.comments.create(body)));
|
|
28189
|
+
return { id: comment.id, discussion_id: comment.discussion_id, created_time: comment.created_time ?? null };
|
|
28190
|
+
}), "comment"),
|
|
28191
|
+
/**
|
|
28192
|
+
* The file sent to Notion, in parts when it is larger than one may be, then added to the end of the page as a block
|
|
28193
|
+
* of its kind. An upload not added to a page within an hour expires ([file uploads](https://developers.notion.com/reference/file-upload)).
|
|
28194
|
+
*/
|
|
28195
|
+
upload: /* @__PURE__ */ __name(({ page, filename, size, read: read4 }) => writing(async () => {
|
|
28196
|
+
const parts = size > SINGLE_PART_BYTES ? Math.ceil(size / PART_BYTES) : 1;
|
|
28197
|
+
const created = parsed2(wireUpload, await mapped(() => client.fileUploads.create(parts > 1 ? { mode: "multi_part", number_of_parts: parts, filename } : { filename })));
|
|
28198
|
+
let answer3;
|
|
28199
|
+
for (let part = 1; part <= parts; part++) {
|
|
28200
|
+
const offset = parts > 1 ? (part - 1) * PART_BYTES : 0;
|
|
28201
|
+
const data = new Blob([read4(offset, parts > 1 ? Math.min(PART_BYTES, size - offset) : size)]);
|
|
28202
|
+
answer3 = await mapped(() => client.fileUploads.send({
|
|
28203
|
+
file_upload_id: created.id,
|
|
28204
|
+
file: { filename, data },
|
|
28205
|
+
...parts > 1 ? { part_number: String(part) } : {}
|
|
28206
|
+
}));
|
|
28207
|
+
}
|
|
28208
|
+
if (parts > 1)
|
|
28209
|
+
answer3 = await mapped(() => client.fileUploads.complete({ file_upload_id: created.id }));
|
|
28210
|
+
const uploaded = parsed2(wireUpload, answer3);
|
|
28211
|
+
if (uploaded.status !== "uploaded")
|
|
28212
|
+
throw new CliError("invalid_response", `${NOTION} did not finish the upload: it is ${uploaded.status}`, {
|
|
28213
|
+
reason: "notion.upload-unfinished"
|
|
28214
|
+
});
|
|
28215
|
+
const type = blockTypeOf(uploaded.content_type);
|
|
28216
|
+
const block = { type, [type]: { type: "file_upload", file_upload: { id: uploaded.id } } };
|
|
28217
|
+
const appended = parsed2(wireAppended, await mapped(() => client.blocks.children.append({
|
|
28218
|
+
block_id: page,
|
|
28219
|
+
children: [block]
|
|
28220
|
+
})));
|
|
28221
|
+
return {
|
|
28222
|
+
upload: { id: uploaded.id, filename, content_type: uploaded.content_type ?? null, size, parts },
|
|
28223
|
+
block: { id: appended.results.at(-1)?.id ?? null, type }
|
|
28224
|
+
};
|
|
28225
|
+
}), "upload"),
|
|
28115
28226
|
/** Notion has no permanent delete in its API: a page goes to the trash and comes back from it ([trash a page](https://developers.notion.com/reference/trash-page)). */
|
|
28116
28227
|
trash: /* @__PURE__ */ __name((id5, inTrash) => writing(async () => pageOf3(await mapped(() => client.pages.update({ page_id: id5, in_trash: inTrash })))), "trash")
|
|
28117
28228
|
}), "liveWrites");
|
|
@@ -28339,26 +28450,179 @@ var notionId = /* @__PURE__ */ __name((input, what = "page") => {
|
|
|
28339
28450
|
});
|
|
28340
28451
|
}, "notionId");
|
|
28341
28452
|
|
|
28342
|
-
// dist/commands/
|
|
28453
|
+
// dist/commands/writing.js
|
|
28454
|
+
import { closeSync as closeSync4, constants, fstatSync, lstatSync as lstatSync2, openSync as openSync4, readFileSync as readFileSync25, realpathSync as realpathSync5 } from "node:fs";
|
|
28455
|
+
var write = /* @__PURE__ */ __name(async (command, extra, act2) => {
|
|
28456
|
+
const context = contextOf(command);
|
|
28457
|
+
const { settings, env, renderer } = context;
|
|
28458
|
+
const path = commandPath(command);
|
|
28459
|
+
const key = path.replaceAll(" ", ".");
|
|
28460
|
+
const token = tokenOf(command);
|
|
28461
|
+
const operationId = newOperationId();
|
|
28462
|
+
const levelOf = /* @__PURE__ */ __name((one) => levelFor(settings.permissions, one, permissions.defaults).level, "levelOf");
|
|
28463
|
+
const guard = keyedGuard((ask) => guardFor(
|
|
28464
|
+
IDENTITY,
|
|
28465
|
+
// Notion limits its own rate, so this guard keeps the levels and the journal, not a send cap.
|
|
28466
|
+
{ ...settings, sendsPerHour: Number.MAX_SAFE_INTEGER, permissionDefaults: permissions.defaults },
|
|
28467
|
+
renderer.warn,
|
|
28468
|
+
env,
|
|
28469
|
+
ask
|
|
28470
|
+
), terminalAsker(command), levelOf, [...PAGE_WRITE_KEYS[path] ?? [], ...extra]);
|
|
28471
|
+
const request = { chatId: null, kind: "edit", key, operationId };
|
|
28472
|
+
guard.refuse(request);
|
|
28473
|
+
try {
|
|
28474
|
+
const done = await guardedWrite(guard, request, () => context.run((events) => act2(notionWritesFor(command, token, events))));
|
|
28475
|
+
return { operationId, done };
|
|
28476
|
+
} catch (error) {
|
|
28477
|
+
if (error instanceof CliError && error.code === "outcome_unknown")
|
|
28478
|
+
throw new CliError("outcome_unknown", error.message, { ...error.details, operation_id: operationId });
|
|
28479
|
+
throw error;
|
|
28480
|
+
}
|
|
28481
|
+
}, "write");
|
|
28482
|
+
var realOf = /* @__PURE__ */ __name((path) => {
|
|
28483
|
+
try {
|
|
28484
|
+
return realpathSync5(path);
|
|
28485
|
+
} catch {
|
|
28486
|
+
return void 0;
|
|
28487
|
+
}
|
|
28488
|
+
}, "realOf");
|
|
28489
|
+
var isLink = /* @__PURE__ */ __name((file) => {
|
|
28490
|
+
try {
|
|
28491
|
+
return lstatSync2(file).isSymbolicLink();
|
|
28492
|
+
} catch {
|
|
28493
|
+
return false;
|
|
28494
|
+
}
|
|
28495
|
+
}, "isLink");
|
|
28496
|
+
var refusedFile = /* @__PURE__ */ __name((file) => new CliError("validation_error", `${file} is not read: only a regular file goes to Notion, never a link, a system file, a credential file, a browser profile or a WireCat folder`, { reason: "file.refused-place", sent: false }), "refusedFile");
|
|
28497
|
+
var openOwnFile = /* @__PURE__ */ __name((file, env) => {
|
|
28498
|
+
const outside = /* @__PURE__ */ __name((path) => path !== void 0 && refusedPlace(path, IDENTITY, env), "outside");
|
|
28499
|
+
if (outside(file))
|
|
28500
|
+
throw refusedFile(file);
|
|
28501
|
+
if (constants.O_NOFOLLOW === void 0 && isLink(file))
|
|
28502
|
+
throw refusedFile(file);
|
|
28503
|
+
let fd;
|
|
28504
|
+
try {
|
|
28505
|
+
fd = openSync4(file, constants.O_RDONLY | (constants.O_NOFOLLOW ?? 0) | (constants.O_NONBLOCK ?? 0));
|
|
28506
|
+
} catch (error) {
|
|
28507
|
+
const code = error.code;
|
|
28508
|
+
if (code === "ELOOP" || code === "EMLINK")
|
|
28509
|
+
throw refusedFile(file);
|
|
28510
|
+
throw new CliError("validation_error", `${file}: ${code === "ENOENT" ? "no such file" : "it cannot be read"}`, {
|
|
28511
|
+
sent: false
|
|
28512
|
+
});
|
|
28513
|
+
}
|
|
28514
|
+
try {
|
|
28515
|
+
const opened = process.platform === "linux" ? realOf(`/proc/self/fd/${fd}`) : void 0;
|
|
28516
|
+
const stat2 = fstatSync(fd);
|
|
28517
|
+
if (!stat2.isFile() || outside(opened))
|
|
28518
|
+
throw refusedFile(file);
|
|
28519
|
+
return { fd, size: stat2.size };
|
|
28520
|
+
} catch (error) {
|
|
28521
|
+
closeSync4(fd);
|
|
28522
|
+
throw error;
|
|
28523
|
+
}
|
|
28524
|
+
}, "openOwnFile");
|
|
28525
|
+
var readOwnFile = /* @__PURE__ */ __name((file, env) => {
|
|
28526
|
+
const { fd } = openOwnFile(file, env);
|
|
28527
|
+
try {
|
|
28528
|
+
return readFileSync25(fd, "utf8");
|
|
28529
|
+
} finally {
|
|
28530
|
+
closeSync4(fd);
|
|
28531
|
+
}
|
|
28532
|
+
}, "readOwnFile");
|
|
28533
|
+
var markdownOf = /* @__PURE__ */ __name(async (command, args, required, what = "the page's new text") => {
|
|
28534
|
+
if (args.text !== void 0 && args.file !== void 0)
|
|
28535
|
+
throw new CliError("validation_error", "give the text with --text or --file, not both", { sent: false });
|
|
28536
|
+
if (args.text !== void 0)
|
|
28537
|
+
return args.text;
|
|
28538
|
+
if (args.file === "-") {
|
|
28539
|
+
const { environment } = contextOf(command);
|
|
28540
|
+
const input = await bufferedInput(environment.stdin ?? process.stdin, {
|
|
28541
|
+
maxBytes: MAX_BUFFERED_INPUT,
|
|
28542
|
+
...environment.signal ? { signal: environment.signal } : {}
|
|
28543
|
+
});
|
|
28544
|
+
return input.toString("utf8");
|
|
28545
|
+
}
|
|
28546
|
+
if (args.file !== void 0)
|
|
28547
|
+
return readOwnFile(args.file, contextOf(command).env);
|
|
28548
|
+
if (required)
|
|
28549
|
+
throw new CliError("validation_error", `give ${what} with --text or --file`, { sent: false });
|
|
28550
|
+
return void 0;
|
|
28551
|
+
}, "markdownOf");
|
|
28552
|
+
var TEXT_OPTIONS = {
|
|
28553
|
+
text: "the text, as Notion-flavoured Markdown",
|
|
28554
|
+
file: "read the text from this file; - reads stdin"
|
|
28555
|
+
};
|
|
28556
|
+
|
|
28557
|
+
// dist/commands/comments.js
|
|
28343
28558
|
var CLI2 = IDENTITY.command;
|
|
28344
28559
|
var LARGEST_PAGE = 100;
|
|
28345
28560
|
var DEFAULT_PAGE = 50;
|
|
28561
|
+
var listCommand5 = /* @__PURE__ */ __name(() => answerEntity(annotate(new Command("list"), {
|
|
28562
|
+
effects: REMOTE_READ,
|
|
28563
|
+
offline: false,
|
|
28564
|
+
examples: [`${CLI2} personal comments list PAGE_ID`, `${CLI2} personal comments list PAGE_ID --limit 20 --json`]
|
|
28565
|
+
}), "notion_comment", commentSchema).summary("list the open comments on a Notion page or block, live").description("list the comments on a Notion page or block, live. Notion's API lists only unresolved comments: a resolved discussion is not shown. Reply to one with comments reply and its discussion_id").argument("<page>", "the page's or block's id, or its Notion link").option("--limit <n>", `at most this many, up to ${LARGEST_PAGE}; ${DEFAULT_PAGE} if not given`, positiveCount("--limit")).option("--cursor <cursor>", "go on from where the last page stopped; page.next gives it").action(async function(page) {
|
|
28566
|
+
const block = notionId(page);
|
|
28567
|
+
const { limit = DEFAULT_PAGE, cursor } = this.opts();
|
|
28568
|
+
const size = Math.min(limit, LARGEST_PAGE);
|
|
28569
|
+
const found = await withNotion(this, (notion) => notion.comments({ block, limit: size, cursor }));
|
|
28570
|
+
renderAnswer(this, outputFor(this), listOf(commandPath(this), {
|
|
28571
|
+
items: found.items,
|
|
28572
|
+
limit: size,
|
|
28573
|
+
has_more: found.hasMore,
|
|
28574
|
+
paging: "cursor",
|
|
28575
|
+
...found.cursor === void 0 ? {} : { cursor: found.cursor },
|
|
28576
|
+
args: { page: block }
|
|
28577
|
+
}));
|
|
28578
|
+
}), "listCommand");
|
|
28579
|
+
var withText = /* @__PURE__ */ __name((command) => command.addOption(secretInput(new Option("--text <text>", "the comment, as Markdown: bold, italic, code, links"))).option("--file <file>", "read the comment from this file; - reads stdin"), "withText");
|
|
28580
|
+
var COMMENT = "the comment's text";
|
|
28581
|
+
var createCommand = /* @__PURE__ */ __name(() => withText(annotate(new Command("create"), {
|
|
28582
|
+
effects: REMOTE_WRITE,
|
|
28583
|
+
offline: false,
|
|
28584
|
+
examples: [
|
|
28585
|
+
`${CLI2} personal comments create PAGE_ID --text "Looks good"`,
|
|
28586
|
+
`${CLI2} personal comments create PAGE_ID --file note.md --dry-run`
|
|
28587
|
+
]
|
|
28588
|
+
}).summary("comment on a Notion page").description("start a discussion on a Notion page with a comment. Notion keeps inline Markdown only: bold, italic, strikethrough, code and links").argument("<page>", "the page's id or its Notion link")).action(async function(page, args) {
|
|
28589
|
+
const id5 = notionId(page);
|
|
28590
|
+
const markdown = await markdownOf(this, args, true, COMMENT) ?? "";
|
|
28591
|
+
const { operationId, done } = await write(this, [], (notion) => notion.comment({ page: id5 }, markdown));
|
|
28592
|
+
renderAnswer(this, outputFor(this), itemOf({ operation_id: operationId, comment: done }));
|
|
28593
|
+
}), "createCommand");
|
|
28594
|
+
var replyCommand = /* @__PURE__ */ __name(() => withText(annotate(new Command("reply"), {
|
|
28595
|
+
effects: REMOTE_WRITE,
|
|
28596
|
+
offline: false,
|
|
28597
|
+
examples: [`${CLI2} personal comments reply DISCUSSION_ID --text "Done"`]
|
|
28598
|
+
}).summary("reply in a Notion discussion").description("add a comment to a discussion that comments list shows, by its discussion_id. It checks comments.create too, so denying that stops replies as well").argument("<discussion>", "the discussion_id from comments list")).action(async function(discussion, args) {
|
|
28599
|
+
const id5 = notionId(discussion, "discussion");
|
|
28600
|
+
const markdown = await markdownOf(this, args, true, COMMENT) ?? "";
|
|
28601
|
+
const { operationId, done } = await write(this, [], (notion) => notion.comment({ discussion: id5 }, markdown));
|
|
28602
|
+
renderAnswer(this, outputFor(this), itemOf({ operation_id: operationId, comment: done }));
|
|
28603
|
+
}), "replyCommand");
|
|
28604
|
+
var commentsCommand2 = /* @__PURE__ */ __name(() => annotate(new Command("comments"), { effects: REMOTE_READ }).description("read and write the comments on Notion pages, live").addCommand(listCommand5()).addCommand(createCommand()).addCommand(replyCommand()), "commentsCommand");
|
|
28605
|
+
|
|
28606
|
+
// dist/commands/databases.js
|
|
28607
|
+
var CLI3 = IDENTITY.command;
|
|
28608
|
+
var LARGEST_PAGE2 = 100;
|
|
28609
|
+
var DEFAULT_PAGE2 = 50;
|
|
28346
28610
|
var DATABASES_QUERY = {
|
|
28347
28611
|
entity: "database",
|
|
28348
28612
|
backend: "native",
|
|
28349
28613
|
fields: [termField("title", "txt", "title:Roadmap")]
|
|
28350
28614
|
};
|
|
28351
|
-
var
|
|
28615
|
+
var listCommand6 = /* @__PURE__ */ __name(() => withQuery(answerEntity(annotate(new Command("list"), {
|
|
28352
28616
|
effects: REMOTE_READ,
|
|
28353
28617
|
offline: false,
|
|
28354
28618
|
examples: [
|
|
28355
|
-
`${
|
|
28356
|
-
`${
|
|
28619
|
+
`${CLI3} personal databases list`,
|
|
28620
|
+
`${CLI3} personal databases list title:Roadmap --json=id,data_source_id,title`
|
|
28357
28621
|
]
|
|
28358
|
-
}), "database", databaseRowSchema), DATABASES_QUERY).summary("list the databases this token can see, live, one row per data source").description("list the databases this token can see, live from Notion's search: one row for each data source, with the database it belongs to. Notion's search can lag behind a new database by a few minutes").option("--limit <n>", `at most this many, up to ${
|
|
28622
|
+
}), "database", databaseRowSchema), DATABASES_QUERY).summary("list the databases this token can see, live, one row per data source").description("list the databases this token can see, live from Notion's search: one row for each data source, with the database it belongs to. Notion's search can lag behind a new database by a few minutes").option("--limit <n>", `at most this many, up to ${LARGEST_PAGE2}; ${DEFAULT_PAGE2} if not given`, positiveCount("--limit")).option("--cursor <cursor>", "go on from where the last page stopped; page.next gives it").action(async function(words3) {
|
|
28359
28623
|
const title = queryTerms(words3, DATABASES_QUERY, commandPath(this)).get("title");
|
|
28360
|
-
const { limit =
|
|
28361
|
-
const size = Math.min(limit,
|
|
28624
|
+
const { limit = DEFAULT_PAGE2, cursor } = this.opts();
|
|
28625
|
+
const size = Math.min(limit, LARGEST_PAGE2);
|
|
28362
28626
|
const found = await withNotion(this, (notion) => notion.databases({ limit: size, cursor, title }));
|
|
28363
28627
|
renderAnswer(this, outputFor(this), listOf(commandPath(this), {
|
|
28364
28628
|
items: found.items,
|
|
@@ -28373,14 +28637,51 @@ var showCommand4 = /* @__PURE__ */ __name(() => answerEntity(annotate(new Comman
|
|
|
28373
28637
|
effects: REMOTE_READ,
|
|
28374
28638
|
offline: false,
|
|
28375
28639
|
examples: [
|
|
28376
|
-
`${
|
|
28377
|
-
`${
|
|
28640
|
+
`${CLI3} personal databases show 0123456789abcdef0123456789abcdef`,
|
|
28641
|
+
`${CLI3} personal databases show https://www.notion.so/0123456789abcdef0123456789abcdef --json`
|
|
28378
28642
|
]
|
|
28379
28643
|
}), "database", databaseSchema).summary("show one database live: its data sources, their ids and properties").description("show one database live from Notion: its title, where it sits, and each of its data sources with its id and its properties, with the options of each select and status; a query of the database names a data source id").argument("<database>", "the database's id or its Notion link").action(async function(database) {
|
|
28380
28644
|
const id5 = notionId(database, "database");
|
|
28381
28645
|
renderAnswer(this, outputFor(this), itemOf(await withNotion(this, (notion) => notion.database(id5))));
|
|
28382
28646
|
}), "showCommand");
|
|
28383
|
-
var databasesCommand = /* @__PURE__ */ __name(() => annotate(new Command("databases"), { effects: REMOTE_READ }).description("read Notion databases and their data sources").addCommand(
|
|
28647
|
+
var databasesCommand = /* @__PURE__ */ __name(() => annotate(new Command("databases"), { effects: REMOTE_READ }).description("read Notion databases and their data sources").addCommand(listCommand6()).addCommand(showCommand4()), "databasesCommand");
|
|
28648
|
+
|
|
28649
|
+
// dist/commands/files.js
|
|
28650
|
+
import { closeSync as closeSync5, readSync } from "node:fs";
|
|
28651
|
+
import { basename as basename4 } from "node:path";
|
|
28652
|
+
var CLI4 = IDENTITY.command;
|
|
28653
|
+
var MB = 1024 * 1024;
|
|
28654
|
+
var uploadCommand = /* @__PURE__ */ __name(() => annotate(new Command("upload"), {
|
|
28655
|
+
effects: REMOTE_WRITE,
|
|
28656
|
+
offline: false,
|
|
28657
|
+
examples: [
|
|
28658
|
+
`${CLI4} personal files upload report.pdf --parent PAGE_ID`,
|
|
28659
|
+
`${CLI4} personal files upload photo.png --parent PAGE_ID --dry-run`
|
|
28660
|
+
]
|
|
28661
|
+
}).summary("upload a file to the end of a Notion page").description(`upload a file and add it to the end of a Notion page, as an image, video, audio, PDF or file block by its type. Up to ${SINGLE_PART_BYTES / MB} MB goes in one request, a larger file in parts of ${PART_BYTES / MB} MB. Notion's plan limits the size; a file too large for it is refused. Only a regular file is sent, never a link, a system file or a credential file`).argument("<file>", "the file to upload").requiredOption("--parent <id>", "the page to add the file to: its id or its Notion link").action(async function(file, args) {
|
|
28662
|
+
const page = notionId(args.parent);
|
|
28663
|
+
const { fd, size } = openOwnFile(file, contextOf(this).env);
|
|
28664
|
+
try {
|
|
28665
|
+
const read4 = /* @__PURE__ */ __name((offset, length) => {
|
|
28666
|
+
const bytes = new Uint8Array(length);
|
|
28667
|
+
let filled = 0;
|
|
28668
|
+
while (filled < length) {
|
|
28669
|
+
const got = readSync(fd, bytes, filled, length - filled, offset + filled);
|
|
28670
|
+
if (got === 0)
|
|
28671
|
+
throw new CliError("validation_error", `${file} changed while it was read; upload it again`, {
|
|
28672
|
+
sent: false
|
|
28673
|
+
});
|
|
28674
|
+
filled += got;
|
|
28675
|
+
}
|
|
28676
|
+
return bytes;
|
|
28677
|
+
}, "read");
|
|
28678
|
+
const { operationId, done } = await write(this, [], (notion) => notion.upload({ page, filename: basename4(file), size, read: read4 }));
|
|
28679
|
+
renderAnswer(this, outputFor(this), itemOf({ operation_id: operationId, page: { id: page }, ...done }));
|
|
28680
|
+
} finally {
|
|
28681
|
+
closeSync5(fd);
|
|
28682
|
+
}
|
|
28683
|
+
}), "uploadCommand");
|
|
28684
|
+
var filesCommand = /* @__PURE__ */ __name(() => annotate(new Command("files"), { effects: REMOTE_WRITE }).description("upload files to Notion pages").addCommand(uploadCommand()), "filesCommand");
|
|
28384
28685
|
|
|
28385
28686
|
// node_modules/.pnpm/@wirecat+cli-core@0.680.0_@wirecat+cli-base@0.106.0_commander@15.0.0_esbuild@0.28.2_typ_620ac9b386657c249f5c9038159a7caa/node_modules/@wirecat/cli-core/dist/services/documents/extraction.js
|
|
28386
28687
|
var Proposal = object({
|
|
@@ -28686,7 +28987,7 @@ import { createHash as createHash8 } from "node:crypto";
|
|
|
28686
28987
|
import { createHash as createHash7, randomUUID } from "node:crypto";
|
|
28687
28988
|
import { createReadStream } from "node:fs";
|
|
28688
28989
|
import { chmod, readdir, rename, rm, stat, writeFile } from "node:fs/promises";
|
|
28689
|
-
import { basename as
|
|
28990
|
+
import { basename as basename5, dirname as dirname12, join as join27, posix } from "node:path";
|
|
28690
28991
|
var SKIPPED = /^(\.|node_modules$|~\$)|(~|\.swp|\.tmp)$/;
|
|
28691
28992
|
var skippedName = /* @__PURE__ */ __name((name3) => SKIPPED.test(name3), "skippedName");
|
|
28692
28993
|
var hashFile = /* @__PURE__ */ __name((path) => new Promise((done, fail) => {
|
|
@@ -28695,7 +28996,7 @@ var hashFile = /* @__PURE__ */ __name((path) => new Promise((done, fail) => {
|
|
|
28695
28996
|
}), "hashFile");
|
|
28696
28997
|
var hashText = /* @__PURE__ */ __name((text5) => createHash7("sha256").update(text5).digest("hex"), "hashText");
|
|
28697
28998
|
var replaceLocal = /* @__PURE__ */ __name(async (file, content) => {
|
|
28698
|
-
const temp = join27(dirname12(file.absolute), `.${
|
|
28999
|
+
const temp = join27(dirname12(file.absolute), `.${basename5(file.absolute)}.${randomUUID().slice(0, 8)}.tmp`);
|
|
28699
29000
|
const { mode } = await stat(file.absolute);
|
|
28700
29001
|
await writeFile(temp, content, { flag: "wx" });
|
|
28701
29002
|
try {
|
|
@@ -30677,7 +30978,7 @@ var addDocumentCommands = /* @__PURE__ */ __name((program, options) => {
|
|
|
30677
30978
|
|
|
30678
30979
|
// dist/library.js
|
|
30679
30980
|
import { createHash as createHash11 } from "node:crypto";
|
|
30680
|
-
import { existsSync as existsSync23, readFileSync as
|
|
30981
|
+
import { existsSync as existsSync23, readFileSync as readFileSync26, rmSync as rmSync9 } from "node:fs";
|
|
30681
30982
|
import { join as join28 } from "node:path";
|
|
30682
30983
|
|
|
30683
30984
|
// dist/sync/cursor.js
|
|
@@ -30786,6 +31087,31 @@ var decodeListPosition = /* @__PURE__ */ __name((token) => {
|
|
|
30786
31087
|
});
|
|
30787
31088
|
return result.output;
|
|
30788
31089
|
}, "decodeListPosition");
|
|
31090
|
+
var BROWSE_PREFIX = "notion-browse1.";
|
|
31091
|
+
var BrowsePosition = object({
|
|
31092
|
+
parent: string(),
|
|
31093
|
+
at: variant("k", [
|
|
31094
|
+
object({ k: literal("search"), kind: picklist(["page", "data_source"]), start: optional(string()) }),
|
|
31095
|
+
object({ k: literal("list"), position: string() })
|
|
31096
|
+
]),
|
|
31097
|
+
/** The folders of that page of Notion's answer already shown: a page can hold more than one `--limit`. */
|
|
31098
|
+
skip: pipe(number(), integer(), minValue(0))
|
|
31099
|
+
});
|
|
31100
|
+
var encodeBrowsePosition = /* @__PURE__ */ __name((position) => `${BROWSE_PREFIX}${Buffer.from(JSON.stringify(position)).toString("base64url")}`, "encodeBrowsePosition");
|
|
31101
|
+
var decodeBrowsePosition = /* @__PURE__ */ __name((token, parent) => {
|
|
31102
|
+
let parsed3;
|
|
31103
|
+
try {
|
|
31104
|
+
parsed3 = token.startsWith(BROWSE_PREFIX) ? JSON.parse(Buffer.from(token.slice(BROWSE_PREFIX.length), "base64url").toString("utf8")) : void 0;
|
|
31105
|
+
} catch {
|
|
31106
|
+
parsed3 = void 0;
|
|
31107
|
+
}
|
|
31108
|
+
const result = safeParse(BrowsePosition, parsed3);
|
|
31109
|
+
if (!result.success || result.output.parent !== parent)
|
|
31110
|
+
throw new CliError("validation_error", "--cursor is not one folders browse gave for this --parent", {
|
|
31111
|
+
reason: "folder.cursor-invalid"
|
|
31112
|
+
});
|
|
31113
|
+
return result.output;
|
|
31114
|
+
}, "decodeBrowsePosition");
|
|
30789
31115
|
|
|
30790
31116
|
// dist/sync/files.js
|
|
30791
31117
|
var WORKSPACE_ROOT = "notion-workspace";
|
|
@@ -30806,8 +31132,68 @@ var parentId = /* @__PURE__ */ __name((parent) => {
|
|
|
30806
31132
|
var isNotionFolder = /* @__PURE__ */ __name((file) => file.providerMetadata.kind !== "row", "isNotionFolder");
|
|
30807
31133
|
var isNotionDocument = /* @__PURE__ */ __name((file) => file.providerMetadata.kind === "page", "isNotionDocument");
|
|
30808
31134
|
var UNTITLED = "Untitled";
|
|
31135
|
+
var workspaceFile = /* @__PURE__ */ __name(() => ({
|
|
31136
|
+
id: WORKSPACE_ROOT,
|
|
31137
|
+
name: "Notion workspace",
|
|
31138
|
+
mime: "application/vnd.notion.workspace",
|
|
31139
|
+
parents: [],
|
|
31140
|
+
url: "",
|
|
31141
|
+
trashed: false,
|
|
31142
|
+
canDownload: false,
|
|
31143
|
+
providerMetadata: { kind: "workspace" }
|
|
31144
|
+
}), "workspaceFile");
|
|
30809
31145
|
var sourceIds = /* @__PURE__ */ __name((file) => file?.providerMetadata.dataSources?.map((item) => item.id).sort().join(), "sourceIds");
|
|
30810
31146
|
|
|
31147
|
+
// dist/sync/browse.js
|
|
31148
|
+
var REQUESTS = 30;
|
|
31149
|
+
var SEARCH_PAGE = 25;
|
|
31150
|
+
var batchOf = /* @__PURE__ */ __name(async (ports, parent, at2) => {
|
|
31151
|
+
if (at2.k === "list") {
|
|
31152
|
+
const page2 = await ports.childrenPage(parent, at2.position);
|
|
31153
|
+
return { files: page2.files, ...page2.cursor ? { next: { k: "list", position: page2.cursor } } : {}, cut: false };
|
|
31154
|
+
}
|
|
31155
|
+
const page = await ports.topPage(at2.kind, at2.start, SEARCH_PAGE);
|
|
31156
|
+
const next = page.next ? { ...at2, start: page.next } : at2.kind === "page" ? { k: "search", kind: "data_source" } : void 0;
|
|
31157
|
+
return { files: page.files, ...next ? { next } : {}, cut: page.cut };
|
|
31158
|
+
}, "batchOf");
|
|
31159
|
+
var firstOf = /* @__PURE__ */ __name(async (ports, parent) => {
|
|
31160
|
+
if (parent === WORKSPACE_ROOT)
|
|
31161
|
+
return { parent, at: { k: "search", kind: "page" }, skip: 0 };
|
|
31162
|
+
const file = await ports.retrieve(parent);
|
|
31163
|
+
if (file.trashed)
|
|
31164
|
+
throw new CliError("not_found", "that page or database is in Notion's trash");
|
|
31165
|
+
if (file.providerMetadata.kind === "database")
|
|
31166
|
+
return void 0;
|
|
31167
|
+
const blocks = encodeListPosition({ k: "blocks", blocks: [{ id: parent }], seen: [] });
|
|
31168
|
+
return { parent, at: { k: "list", position: blocks }, skip: 0 };
|
|
31169
|
+
}, "firstOf");
|
|
31170
|
+
var browseLevel = /* @__PURE__ */ __name(async (ports, parent, limit, cursor) => {
|
|
31171
|
+
let position = cursor === void 0 ? await firstOf(ports, parent) : decodeBrowsePosition(cursor, parent);
|
|
31172
|
+
if (position && position.at.k === "search" !== (parent === WORKSPACE_ROOT))
|
|
31173
|
+
throw new CliError("validation_error", "--cursor is not one folders browse gave for this --parent", {
|
|
31174
|
+
reason: "folder.cursor-invalid"
|
|
31175
|
+
});
|
|
31176
|
+
const files = [];
|
|
31177
|
+
let cut3 = false;
|
|
31178
|
+
const most = ports.requests() + REQUESTS;
|
|
31179
|
+
while (position) {
|
|
31180
|
+
const batch = await batchOf(ports, parent, position.at);
|
|
31181
|
+
cut3 ||= batch.cut;
|
|
31182
|
+
const rest = batch.files.slice(position.skip);
|
|
31183
|
+
const room = limit - files.length;
|
|
31184
|
+
for (const file of rest.slice(0, room))
|
|
31185
|
+
files.push(file);
|
|
31186
|
+
if (rest.length > room)
|
|
31187
|
+
return { files, cut: cut3, cursor: encodeBrowsePosition({ ...position, skip: position.skip + room }) };
|
|
31188
|
+
if (!batch.next)
|
|
31189
|
+
break;
|
|
31190
|
+
position = { parent, at: batch.next, skip: 0 };
|
|
31191
|
+
if (files.length === limit || ports.requests() >= most)
|
|
31192
|
+
return { files, cut: cut3, cursor: encodeBrowsePosition(position) };
|
|
31193
|
+
}
|
|
31194
|
+
return { files, cut: cut3 };
|
|
31195
|
+
}, "browseLevel");
|
|
31196
|
+
|
|
30811
31197
|
// dist/sync/front-matter.js
|
|
30812
31198
|
var text3 = /* @__PURE__ */ __name((parts) => withoutSignedLinks(parts.map((part) => part.plain_text).join("")).text, "text");
|
|
30813
31199
|
var person3 = /* @__PURE__ */ __name((user) => user.name || user.id, "person");
|
|
@@ -31109,16 +31495,6 @@ var notionSource = /* @__PURE__ */ __name((notion, options = {}) => {
|
|
|
31109
31495
|
}
|
|
31110
31496
|
};
|
|
31111
31497
|
}, "databaseFile");
|
|
31112
|
-
const workspaceFile = /* @__PURE__ */ __name(() => ({
|
|
31113
|
-
id: WORKSPACE_ROOT,
|
|
31114
|
-
name: "Notion workspace",
|
|
31115
|
-
mime: "application/vnd.notion.workspace",
|
|
31116
|
-
parents: [],
|
|
31117
|
-
url: "",
|
|
31118
|
-
trashed: false,
|
|
31119
|
-
canDownload: false,
|
|
31120
|
-
providerMetadata: { kind: "workspace" }
|
|
31121
|
-
}), "workspaceFile");
|
|
31122
31498
|
const retrieve = /* @__PURE__ */ __name(async (id5, kind4) => {
|
|
31123
31499
|
if (id5 === WORKSPACE_ROOT)
|
|
31124
31500
|
return workspaceFile();
|
|
@@ -31214,10 +31590,10 @@ var notionSource = /* @__PURE__ */ __name((notion, options = {}) => {
|
|
|
31214
31590
|
return void 0;
|
|
31215
31591
|
}
|
|
31216
31592
|
}, "childDatabase");
|
|
31217
|
-
const searchPage = /* @__PURE__ */ __name((kind4, start) => reads.search({
|
|
31593
|
+
const searchPage = /* @__PURE__ */ __name((kind4, start, size = PAGE_SIZE) => reads.search({
|
|
31218
31594
|
filter: { property: "object", value: kind4 },
|
|
31219
31595
|
sort: { timestamp: "last_edited_time", direction: "descending" },
|
|
31220
|
-
page_size:
|
|
31596
|
+
page_size: size,
|
|
31221
31597
|
...start ? { start_cursor: start } : {}
|
|
31222
31598
|
}), "searchPage");
|
|
31223
31599
|
const isCut = /* @__PURE__ */ __name((page) => page.request_status?.type === "incomplete", "isCut");
|
|
@@ -31258,33 +31634,36 @@ var notionSource = /* @__PURE__ */ __name((notion, options = {}) => {
|
|
|
31258
31634
|
}
|
|
31259
31635
|
}, "readDatabase");
|
|
31260
31636
|
const isGone = /* @__PURE__ */ __name((database) => database === "gone" || database !== "unreadable" && database.in_trash, "isGone");
|
|
31261
|
-
const
|
|
31262
|
-
|
|
31263
|
-
|
|
31264
|
-
|
|
31265
|
-
|
|
31266
|
-
|
|
31267
|
-
|
|
31268
|
-
|
|
31269
|
-
|
|
31270
|
-
|
|
31271
|
-
|
|
31272
|
-
|
|
31273
|
-
|
|
31274
|
-
|
|
31275
|
-
|
|
31276
|
-
}
|
|
31277
|
-
const files = [];
|
|
31278
|
-
for (const page of pages)
|
|
31279
|
-
if (!page.in_trash)
|
|
31280
|
-
files.push(await pageFile(page));
|
|
31281
|
-
for (const database of databases.values())
|
|
31282
|
-
if (!database.in_trash)
|
|
31283
|
-
files.push(await databaseFile(database));
|
|
31284
|
-
return files.filter((file) => file.parents[0] === WORKSPACE_ROOT);
|
|
31637
|
+
const topFiles = /* @__PURE__ */ __name(async (results) => {
|
|
31638
|
+
const pages = results.filter((result) => result.object === "page");
|
|
31639
|
+
const sources = results.filter((result) => result.object === "data_source");
|
|
31640
|
+
for (const page of pages)
|
|
31641
|
+
accessible.add(page.id);
|
|
31642
|
+
for (const source2 of sources)
|
|
31643
|
+
accessible.add(source2.parent.database_id);
|
|
31644
|
+
const databases = /* @__PURE__ */ new Map();
|
|
31645
|
+
for (const source2 of sources) {
|
|
31646
|
+
const id5 = source2.parent.database_id;
|
|
31647
|
+
if (databases.has(id5) || source2.in_trash)
|
|
31648
|
+
continue;
|
|
31649
|
+
const database = await readDatabase(id5);
|
|
31650
|
+
if (typeof database === "object")
|
|
31651
|
+
databases.set(id5, database);
|
|
31285
31652
|
}
|
|
31286
|
-
|
|
31287
|
-
|
|
31653
|
+
const files = [];
|
|
31654
|
+
for (const page of pages)
|
|
31655
|
+
if (!page.in_trash)
|
|
31656
|
+
files.push(await pageFile(page));
|
|
31657
|
+
for (const database of databases.values())
|
|
31658
|
+
if (!database.in_trash)
|
|
31659
|
+
files.push(await databaseFile(database));
|
|
31660
|
+
return files.filter((file) => file.parents[0] === WORKSPACE_ROOT);
|
|
31661
|
+
}, "topFiles");
|
|
31662
|
+
const listed4 = /* @__PURE__ */ __name(async (id5) => id5 === WORKSPACE_ROOT ? topFiles([...await searchAll("page"), ...await searchAll("data_source")]) : [], "listed");
|
|
31663
|
+
const topPage = /* @__PURE__ */ __name(async (kind4, start, size) => {
|
|
31664
|
+
const page = await searchPage(kind4, start, size);
|
|
31665
|
+
return { files: await topFiles(page.results), next: page.has_more ? page.next_cursor : null, cut: isCut(page) };
|
|
31666
|
+
}, "topPage");
|
|
31288
31667
|
const confirm = /* @__PURE__ */ __name(async (missing, container, listing) => {
|
|
31289
31668
|
for (const file of missing) {
|
|
31290
31669
|
try {
|
|
@@ -31837,6 +32216,11 @@ var notionSource = /* @__PURE__ */ __name((notion, options = {}) => {
|
|
|
31837
32216
|
fresh();
|
|
31838
32217
|
return childrenPage(id5, cursor);
|
|
31839
32218
|
},
|
|
32219
|
+
async browse(parent, limit, cursor) {
|
|
32220
|
+
fresh();
|
|
32221
|
+
const ports = { retrieve: /* @__PURE__ */ __name((id5) => retrieve(id5), "retrieve"), childrenPage, topPage, requests: /* @__PURE__ */ __name(() => requests, "requests") };
|
|
32222
|
+
return browseLevel(ports, parent, limit, cursor);
|
|
32223
|
+
},
|
|
31840
32224
|
async startToken() {
|
|
31841
32225
|
const top = await reads.search({
|
|
31842
32226
|
filter: { property: "object", value: "page" },
|
|
@@ -31879,7 +32263,7 @@ var withStore3 = /* @__PURE__ */ __name(async (env, write2, fn) => {
|
|
|
31879
32263
|
var profileDir = /* @__PURE__ */ __name((env, profile) => join28(resolvePaths({ appName: IDENTITY.appName, prefix: IDENTITY.envPrefix, env }).state, "profiles", profile), "profileDir");
|
|
31880
32264
|
var readJson = /* @__PURE__ */ __name((path) => {
|
|
31881
32265
|
try {
|
|
31882
|
-
return JSON.parse(
|
|
32266
|
+
return JSON.parse(readFileSync26(path, "utf8"));
|
|
31883
32267
|
} catch (error) {
|
|
31884
32268
|
if (error.code === "ENOENT")
|
|
31885
32269
|
return void 0;
|
|
@@ -32052,14 +32436,13 @@ var knowledgeOf = /* @__PURE__ */ __name((store, principal) => {
|
|
|
32052
32436
|
}, "knowledgeOf");
|
|
32053
32437
|
|
|
32054
32438
|
// dist/commands/documents.js
|
|
32055
|
-
|
|
32056
|
-
var CLI3 = IDENTITY.command;
|
|
32439
|
+
var CLI5 = IDENTITY.command;
|
|
32057
32440
|
var getCommand = /* @__PURE__ */ __name(() => answerEntity(annotate(new Command("get"), {
|
|
32058
32441
|
effects: REMOTE_READ,
|
|
32059
32442
|
offline: false,
|
|
32060
32443
|
examples: [
|
|
32061
|
-
`${
|
|
32062
|
-
`${
|
|
32444
|
+
`${CLI5} personal documents get https://www.notion.so/Roadmap-0123456789abcdef0123456789abcdef`,
|
|
32445
|
+
`${CLI5} personal documents get 0123456789abcdef0123456789abcdef --json`
|
|
32063
32446
|
]
|
|
32064
32447
|
}), "document_markdown", documentSchema).summary("read one page live from Notion, as Markdown").description("read one page live from Notion as Notion-flavoured Markdown. A page too long for one answer is read in parts; a part the token may not see is listed in missing_block_ids, and a page that is not whole answers meta.complete false and exits non-zero. Signed file links lose their signature, so the output never carries a link that opens the file").argument("<page>", "the page's id or its Notion link").action(async function(page) {
|
|
32065
32448
|
const id5 = notionId(page);
|
|
@@ -32080,95 +32463,13 @@ var getCommand = /* @__PURE__ */ __name(() => answerEntity(annotate(new Command(
|
|
|
32080
32463
|
if (issues.length > 0 && output.format !== "json" && output.format !== "jsonl")
|
|
32081
32464
|
output.renderer.warn(`the page is incomplete: ${why}`);
|
|
32082
32465
|
}), "getCommand");
|
|
32083
|
-
var
|
|
32084
|
-
const context = contextOf(command);
|
|
32085
|
-
const { settings, env, renderer } = context;
|
|
32086
|
-
const path = commandPath(command);
|
|
32087
|
-
const key = path.replaceAll(" ", ".");
|
|
32088
|
-
const token = tokenOf(command);
|
|
32089
|
-
const operationId = newOperationId();
|
|
32090
|
-
const levelOf = /* @__PURE__ */ __name((one) => levelFor(settings.permissions, one, permissions.defaults).level, "levelOf");
|
|
32091
|
-
const guard = keyedGuard((ask) => guardFor(
|
|
32092
|
-
IDENTITY,
|
|
32093
|
-
// Notion limits its own rate, so this guard keeps the levels and the journal, not a send cap.
|
|
32094
|
-
{ ...settings, sendsPerHour: Number.MAX_SAFE_INTEGER, permissionDefaults: permissions.defaults },
|
|
32095
|
-
renderer.warn,
|
|
32096
|
-
env,
|
|
32097
|
-
ask
|
|
32098
|
-
), terminalAsker(command), levelOf, [...PAGE_WRITE_KEYS[path] ?? [], ...extra]);
|
|
32099
|
-
const request = { chatId: null, kind: "edit", key, operationId };
|
|
32100
|
-
guard.refuse(request);
|
|
32101
|
-
try {
|
|
32102
|
-
const done = await guardedWrite(guard, request, () => context.run((events) => act2(notionWritesFor(command, token, events))));
|
|
32103
|
-
return { operationId, done };
|
|
32104
|
-
} catch (error) {
|
|
32105
|
-
if (error instanceof CliError && error.code === "outcome_unknown")
|
|
32106
|
-
throw new CliError("outcome_unknown", error.message, { ...error.details, operation_id: operationId });
|
|
32107
|
-
throw error;
|
|
32108
|
-
}
|
|
32109
|
-
}, "write");
|
|
32110
|
-
var realOf = /* @__PURE__ */ __name((path) => {
|
|
32111
|
-
try {
|
|
32112
|
-
return realpathSync5(path);
|
|
32113
|
-
} catch {
|
|
32114
|
-
return void 0;
|
|
32115
|
-
}
|
|
32116
|
-
}, "realOf");
|
|
32117
|
-
var refusedFile = /* @__PURE__ */ __name((file) => new CliError("validation_error", `${file} is not read: only a regular file goes to Notion, never a link, a system file, a credential file, a browser profile or a WireCat folder`, { reason: "file.refused-place", sent: false }), "refusedFile");
|
|
32118
|
-
var readOwnFile = /* @__PURE__ */ __name((file, env) => {
|
|
32119
|
-
const outside = /* @__PURE__ */ __name((path) => path !== void 0 && refusedPlace(path, IDENTITY, env), "outside");
|
|
32120
|
-
if (outside(file))
|
|
32121
|
-
throw refusedFile(file);
|
|
32122
|
-
let fd;
|
|
32123
|
-
try {
|
|
32124
|
-
fd = openSync4(file, constants.O_RDONLY | (constants.O_NOFOLLOW ?? 0) | (constants.O_NONBLOCK ?? 0));
|
|
32125
|
-
} catch (error) {
|
|
32126
|
-
const code = error.code;
|
|
32127
|
-
if (code === "ELOOP" || code === "EMLINK")
|
|
32128
|
-
throw refusedFile(file);
|
|
32129
|
-
throw new CliError("validation_error", `${file}: ${code === "ENOENT" ? "no such file" : "it cannot be read"}`, {
|
|
32130
|
-
sent: false
|
|
32131
|
-
});
|
|
32132
|
-
}
|
|
32133
|
-
try {
|
|
32134
|
-
const opened = process.platform === "linux" ? realOf(`/proc/self/fd/${fd}`) : void 0;
|
|
32135
|
-
if (!fstatSync(fd).isFile() || outside(opened))
|
|
32136
|
-
throw refusedFile(file);
|
|
32137
|
-
return readFileSync26(fd, "utf8");
|
|
32138
|
-
} finally {
|
|
32139
|
-
closeSync4(fd);
|
|
32140
|
-
}
|
|
32141
|
-
}, "readOwnFile");
|
|
32142
|
-
var markdownOf = /* @__PURE__ */ __name(async (command, args, required) => {
|
|
32143
|
-
if (args.text !== void 0 && args.file !== void 0)
|
|
32144
|
-
throw new CliError("validation_error", "give the text with --text or --file, not both", { sent: false });
|
|
32145
|
-
if (args.text !== void 0)
|
|
32146
|
-
return args.text;
|
|
32147
|
-
if (args.file === "-") {
|
|
32148
|
-
const { environment } = contextOf(command);
|
|
32149
|
-
const input = await bufferedInput(environment.stdin ?? process.stdin, {
|
|
32150
|
-
maxBytes: MAX_BUFFERED_INPUT,
|
|
32151
|
-
...environment.signal ? { signal: environment.signal } : {}
|
|
32152
|
-
});
|
|
32153
|
-
return input.toString("utf8");
|
|
32154
|
-
}
|
|
32155
|
-
if (args.file !== void 0)
|
|
32156
|
-
return readOwnFile(args.file, contextOf(command).env);
|
|
32157
|
-
if (required)
|
|
32158
|
-
throw new CliError("validation_error", "give the page's new text with --text or --file", { sent: false });
|
|
32159
|
-
return void 0;
|
|
32160
|
-
}, "markdownOf");
|
|
32161
|
-
var TEXT_OPTIONS = {
|
|
32162
|
-
text: "the text, as Notion-flavoured Markdown",
|
|
32163
|
-
file: "read the text from this file; - reads stdin"
|
|
32164
|
-
};
|
|
32165
|
-
var createCommand = /* @__PURE__ */ __name(() => annotate(new Command("create"), {
|
|
32466
|
+
var createCommand2 = /* @__PURE__ */ __name(() => annotate(new Command("create"), {
|
|
32166
32467
|
effects: REMOTE_WRITE,
|
|
32167
32468
|
offline: false,
|
|
32168
32469
|
examples: [
|
|
32169
|
-
`${
|
|
32170
|
-
`${
|
|
32171
|
-
`${
|
|
32470
|
+
`${CLI5} personal documents create --parent PAGE_ID --title "Meeting notes" --text "Discussed the roadmap"`,
|
|
32471
|
+
`${CLI5} personal documents create --parent https://www.notion.so/Projects-0123456789abcdef0123456789abcdef --file notes.md`,
|
|
32472
|
+
`${CLI5} personal documents create --parent PAGE_ID --file notes.md --dry-run`
|
|
32172
32473
|
]
|
|
32173
32474
|
}).summary("create a Notion page under another page").description("create a Notion page under another page, from Notion-flavoured Markdown. With no --title, Notion takes the text's first # heading as the title").requiredOption("--parent <id>", "the parent page's id or its Notion link").option("--title <title>", "the page's title").option("--text <text>", TEXT_OPTIONS.text).option("--file <file>", TEXT_OPTIONS.file).action(async function(args) {
|
|
32174
32475
|
const parent = notionId(args.parent);
|
|
@@ -32180,9 +32481,9 @@ var updateCommand2 = /* @__PURE__ */ __name(() => annotate(new Command("update")
|
|
|
32180
32481
|
effects: REMOTE_WRITE,
|
|
32181
32482
|
offline: false,
|
|
32182
32483
|
examples: [
|
|
32183
|
-
`${
|
|
32184
|
-
`${
|
|
32185
|
-
`${
|
|
32484
|
+
`${CLI5} personal documents update PAGE_ID --file notes.md`,
|
|
32485
|
+
`${CLI5} personal documents update PAGE_ID --text "# Plan" --dry-run`,
|
|
32486
|
+
`${CLI5} personal documents update PAGE_ID --file page.md --allow-deleting-content`
|
|
32186
32487
|
]
|
|
32187
32488
|
}).summary("replace a Notion page's text").description("replace a Notion page's whole text with Notion-flavoured Markdown. A child page or database whose tag the new text leaves out is refused unless --allow-deleting-content is given, which asks as documents delete does").argument("<page>", "the page's id or its Notion link").option("--text <text>", TEXT_OPTIONS.text).option("--file <file>", TEXT_OPTIONS.file).option("--allow-deleting-content", "let Notion delete the child pages and databases the new text leaves out").action(async function(page, args) {
|
|
32188
32489
|
const id5 = notionId(page);
|
|
@@ -32197,7 +32498,7 @@ var updateCommand2 = /* @__PURE__ */ __name(() => annotate(new Command("update")
|
|
|
32197
32498
|
var trashCommand = /* @__PURE__ */ __name((name3, inTrash) => annotate(new Command(name3), {
|
|
32198
32499
|
effects: REMOTE_WRITE,
|
|
32199
32500
|
offline: false,
|
|
32200
|
-
examples: [`${
|
|
32501
|
+
examples: [`${CLI5} personal documents ${name3} PAGE_ID`, `${CLI5} personal documents ${name3} PAGE_ID --dry-run`]
|
|
32201
32502
|
}).argument("<page>", "the page's id or its Notion link").action(async function(page) {
|
|
32202
32503
|
const id5 = notionId(page);
|
|
32203
32504
|
const { operationId, done } = await write(this, [], (notion) => notion.trash(id5, inTrash));
|
|
@@ -32207,9 +32508,9 @@ var deleteCommand4 = /* @__PURE__ */ __name(() => trashCommand("delete", true).s
|
|
|
32207
32508
|
var restoreCommand = /* @__PURE__ */ __name(() => trashCommand("restore", false).summary("bring a Notion page back from the trash").description("bring a Notion page back from Notion's trash, where documents delete put it"), "restoreCommand");
|
|
32208
32509
|
|
|
32209
32510
|
// dist/commands/library.js
|
|
32210
|
-
var
|
|
32511
|
+
var CLI6 = IDENTITY.command;
|
|
32211
32512
|
var NOTION_WORDS = {
|
|
32212
|
-
app:
|
|
32513
|
+
app: CLI6,
|
|
32213
32514
|
remote: "notion",
|
|
32214
32515
|
provider: "Notion",
|
|
32215
32516
|
source: PROVIDER2.name,
|
|
@@ -32239,13 +32540,26 @@ var documentRow = /* @__PURE__ */ __name((file, reference2) => ({
|
|
|
32239
32540
|
created_at: file.createdAt ?? null,
|
|
32240
32541
|
reference: reference2
|
|
32241
32542
|
}), "documentRow");
|
|
32242
|
-
var
|
|
32543
|
+
var BROWSE_LIMIT = 100;
|
|
32544
|
+
var browseRow = strictObject({
|
|
32243
32545
|
id: string(),
|
|
32244
32546
|
name: string(),
|
|
32245
32547
|
kind: picklist(["page", "database"]),
|
|
32246
32548
|
url: string(),
|
|
32247
|
-
|
|
32549
|
+
parent: nullable(string()),
|
|
32550
|
+
added: boolean()
|
|
32248
32551
|
});
|
|
32552
|
+
var BROWSE_HELP = `
|
|
32553
|
+
Each item, one level of the tree (--json prints them under "items"):
|
|
32554
|
+
id page or database id to pass to --parent or to folders add
|
|
32555
|
+
name its title in Notion
|
|
32556
|
+
kind page or database; a database lists no folders inside, as its rows are not folders
|
|
32557
|
+
url its Notion link
|
|
32558
|
+
parent the --parent given, or null at the top of the workspace
|
|
32559
|
+
added whether sync already copies it (folders add)
|
|
32560
|
+
The top of the workspace holds its top-level pages and databases, and those whose parent the token cannot see.
|
|
32561
|
+
A level comes a page at a time: when page.has_more is true, run it again with --cursor from page.next_cursor.
|
|
32562
|
+
A page can come back with fewer items than --limit, or none, and still have more.`;
|
|
32249
32563
|
var issuesOf = /* @__PURE__ */ __name((warnings) => {
|
|
32250
32564
|
const seen2 = /* @__PURE__ */ new Set();
|
|
32251
32565
|
return warnings.flatMap((warning) => {
|
|
@@ -32258,7 +32572,7 @@ var issuesOf = /* @__PURE__ */ __name((warnings) => {
|
|
|
32258
32572
|
}, "issuesOf");
|
|
32259
32573
|
var errorOf = /* @__PURE__ */ __name((error) => isCliError(error) ? error : new CliError("provider_error", "a Notion read failed", { reason: "notion.failed" }), "errorOf");
|
|
32260
32574
|
var libraryCommands = /* @__PURE__ */ __name(() => {
|
|
32261
|
-
const holder = new Command(
|
|
32575
|
+
const holder = new Command(CLI6);
|
|
32262
32576
|
let running;
|
|
32263
32577
|
const command = /* @__PURE__ */ __name(() => {
|
|
32264
32578
|
if (!running)
|
|
@@ -32320,7 +32634,7 @@ var libraryCommands = /* @__PURE__ */ __name(() => {
|
|
|
32320
32634
|
const writes2 = /* @__PURE__ */ __name(() => metaOf(command()).effects?.local === "write", "writes");
|
|
32321
32635
|
const decider2 = /* @__PURE__ */ __name(() => {
|
|
32322
32636
|
const actor = actorOf(command());
|
|
32323
|
-
return actor === "owner" ? "owner" : { bot: actor, reason: `asked by ${actor} through ${
|
|
32637
|
+
return actor === "owner" ? "owner" : { bot: actor, reason: `asked by ${actor} through ${CLI6}` };
|
|
32324
32638
|
}, "decider");
|
|
32325
32639
|
const sourceFor = /* @__PURE__ */ __name((reads, held = false, deadline) => notionSource(reads, {
|
|
32326
32640
|
roots: rootsOf(env(), profile()),
|
|
@@ -32381,19 +32695,40 @@ var libraryCommands = /* @__PURE__ */ __name(() => {
|
|
|
32381
32695
|
answerEntity(annotate(folders2.command("browse"), {
|
|
32382
32696
|
effects: REMOTE_READ,
|
|
32383
32697
|
offline: false,
|
|
32384
|
-
examples: [
|
|
32385
|
-
|
|
32698
|
+
examples: [
|
|
32699
|
+
`${CLI6} personal folders browse`,
|
|
32700
|
+
`${CLI6} personal folders browse --parent PAGE_ID --json`,
|
|
32701
|
+
`${CLI6} personal folders browse --limit 20 --cursor CURSOR`
|
|
32702
|
+
]
|
|
32703
|
+
}), "notion_folder", browseRow).summary("list Notion pages and databases one level at a time, live").description("list Notion pages and databases one level at a time, live, to choose one for folders add").option("--parent <id>", "page id or Notion link to list inside; the top of the workspace without it").option("--limit <n>", `at most this many; ${BROWSE_LIMIT} if not given`, positiveCount("--limit")).option("--cursor <cursor>", "go on from where the last page stopped; page.next gives it, with the same --parent").addHelpText("after", BROWSE_HELP).action(async (args) => {
|
|
32386
32704
|
const parent = args.parent === void 0 ? WORKSPACE_ROOT : notionId(args.parent);
|
|
32705
|
+
const limit = args.limit ?? BROWSE_LIMIT;
|
|
32387
32706
|
const chosen = new Set(chosenFolders(env(), profile()));
|
|
32388
|
-
const
|
|
32389
|
-
const items =
|
|
32707
|
+
const level = await withNotionReads((reads) => sourceFor(reads).browse(parent, limit, args.cursor));
|
|
32708
|
+
const items = level.files.filter((file) => file.providerMetadata.kind === "page" || file.providerMetadata.kind === "database").map((file) => ({
|
|
32390
32709
|
id: file.id,
|
|
32391
32710
|
name: file.name,
|
|
32392
32711
|
kind: file.providerMetadata.kind,
|
|
32393
32712
|
url: file.url,
|
|
32394
|
-
|
|
32713
|
+
parent: args.parent === void 0 ? null : parent,
|
|
32714
|
+
added: chosen.has(file.id)
|
|
32715
|
+
}));
|
|
32716
|
+
output(listOf("folders browse", {
|
|
32717
|
+
items,
|
|
32718
|
+
limit,
|
|
32719
|
+
has_more: level.cursor !== void 0,
|
|
32720
|
+
paging: "cursor",
|
|
32721
|
+
...level.cursor ? { cursor: level.cursor } : {},
|
|
32722
|
+
args: args.parent === void 0 ? {} : { parent },
|
|
32723
|
+
...level.cut ? {
|
|
32724
|
+
missing: [
|
|
32725
|
+
{
|
|
32726
|
+
field: "items",
|
|
32727
|
+
why: "Notion's search gave only its 10,000 most recently edited results; older top-level pages or databases may be missing"
|
|
32728
|
+
}
|
|
32729
|
+
]
|
|
32730
|
+
} : {}
|
|
32395
32731
|
}));
|
|
32396
|
-
output(listOf("folders browse", { items, limit: Math.max(1, items.length), has_more: false }));
|
|
32397
32732
|
});
|
|
32398
32733
|
}, "browse")
|
|
32399
32734
|
},
|
|
@@ -32441,7 +32776,7 @@ var libraryCommands = /* @__PURE__ */ __name(() => {
|
|
|
32441
32776
|
if (!embed)
|
|
32442
32777
|
return synced;
|
|
32443
32778
|
const { embedNotes } = await import("./services-PT4PA4J6.js");
|
|
32444
|
-
return { ...synced, embeddings: await embedNotes(store, { maxChunks: 600, env: env(), command:
|
|
32779
|
+
return { ...synced, embeddings: await embedNotes(store, { maxChunks: 600, env: env(), command: CLI6 }) };
|
|
32445
32780
|
}));
|
|
32446
32781
|
});
|
|
32447
32782
|
const underWay = passUnderWay(syncState(env(), name3, "").read().cursor);
|
|
@@ -32517,7 +32852,7 @@ var libraryCommands = /* @__PURE__ */ __name(() => {
|
|
|
32517
32852
|
...options,
|
|
32518
32853
|
folderIds: [folder2.id],
|
|
32519
32854
|
env: env(),
|
|
32520
|
-
command:
|
|
32855
|
+
command: CLI6
|
|
32521
32856
|
});
|
|
32522
32857
|
return {
|
|
32523
32858
|
...rest,
|
|
@@ -32590,15 +32925,15 @@ var libraryCommands = /* @__PURE__ */ __name(() => {
|
|
|
32590
32925
|
}
|
|
32591
32926
|
});
|
|
32592
32927
|
documents.addCommand(getCommand());
|
|
32593
|
-
documents.addCommand(
|
|
32928
|
+
documents.addCommand(createCommand2()).addCommand(updateCommand2()).addCommand(deleteCommand4());
|
|
32594
32929
|
documents.addCommand(restoreCommand());
|
|
32595
32930
|
annotate(documents.command("add"), {
|
|
32596
32931
|
effects: FETCH,
|
|
32597
32932
|
mcp: false,
|
|
32598
32933
|
offline: false,
|
|
32599
32934
|
examples: [
|
|
32600
|
-
`${
|
|
32601
|
-
`${
|
|
32935
|
+
`${CLI6} personal documents add https://www.notion.so/Roadmap-0123456789abcdef0123456789abcdef`,
|
|
32936
|
+
`${CLI6} personal documents add PAGE_ID --subject person:PERSON_UID`
|
|
32602
32937
|
]
|
|
32603
32938
|
}).summary("keep one Notion page's text in memory, read live, without syncing a folder").description("read one page live and keep its text among the sources added by hand, where memo and search all find it; adding it again keeps its new text as the next revision").argument("<page>", "the page's id or its Notion link").option("--title <title>", "the title to keep it under; the page's own when omitted").option("--subject <ref>", "a person, organization, project, task or meeting it is about; repeat to add more", (value3, previous2 = []) => [...previous2, value3]).action(async (input, args) => {
|
|
32604
32939
|
const id5 = notionId(input);
|
|
@@ -34266,7 +34601,7 @@ var stringToBytes = qrcode.stringToBytes;
|
|
|
34266
34601
|
|
|
34267
34602
|
// dist/commands/session.js
|
|
34268
34603
|
var SERVICE = NOTION;
|
|
34269
|
-
var
|
|
34604
|
+
var CLI7 = IDENTITY.command;
|
|
34270
34605
|
var answer2 = /* @__PURE__ */ __name((command, item) => renderAnswer(command, outputFor(command), itemOf(item)), "answer");
|
|
34271
34606
|
var storageOf = /* @__PURE__ */ __name((raw) => {
|
|
34272
34607
|
if (raw === "keyring" || raw === "file")
|
|
@@ -34277,10 +34612,10 @@ var startCommand = /* @__PURE__ */ __name(() => logsInOrOut(annotate(new Command
|
|
|
34277
34612
|
effects: FETCH,
|
|
34278
34613
|
lifetime: "interactive",
|
|
34279
34614
|
mcp: false,
|
|
34280
|
-
examples: [`${
|
|
34615
|
+
examples: [`${CLI7} personal session start`, `${CLI7} personal session start --credential-storage file`]
|
|
34281
34616
|
})).summary("sign in to Notion with a personal access token or an internal connection's token").description("sign this profile in: a Notion personal access token, which acts with your own rights, or an internal connection's token, which sees only the pages shared with that connection. It is asked hidden or read from stdin, never taken as an argument, checked with Notion, and only then kept in the keyring, or in a private file").option("--credential-storage <storage>", "where the token is kept: keyring, which falls back to a private file by itself, or file", storageOf, "keyring").action(async function(args) {
|
|
34282
34617
|
const { env, profile, tokens, run: run3 } = contextOf(this);
|
|
34283
|
-
refuseCommandName(profile, commandWords(rootOf(this)),
|
|
34618
|
+
refuseCommandName(profile, commandWords(rootOf(this)), CLI7);
|
|
34284
34619
|
refuseOffline(this, SERVICE);
|
|
34285
34620
|
const token = (await readSecret("Notion token: ", secretInputOf(this))).trim();
|
|
34286
34621
|
if (!token)
|
|
@@ -34292,7 +34627,7 @@ var startCommand = /* @__PURE__ */ __name(() => logsInOrOut(annotate(new Command
|
|
|
34292
34627
|
}), "startCommand");
|
|
34293
34628
|
var statusCommand3 = /* @__PURE__ */ __name(() => annotate(new Command("status"), {
|
|
34294
34629
|
effects: REMOTE_READ,
|
|
34295
|
-
examples: [`${
|
|
34630
|
+
examples: [`${CLI7} personal session status`, `${CLI7} personal session status --check --json`]
|
|
34296
34631
|
}).summary("show where this profile's token comes from; never the token").description(`show where this profile's token comes from: ${IDENTITY.envPrefix}_TOKEN, the keyring or a file, never the token; --check asks ${SERVICE} whose token it is`).option("--check", `ask ${SERVICE} whether the token still works, and whose it is`).action(async function(args) {
|
|
34297
34632
|
const { profile, tokens } = contextOf(this);
|
|
34298
34633
|
const saved = tokens.read(profile);
|
|
@@ -34304,15 +34639,15 @@ var statusCommand3 = /* @__PURE__ */ __name(() => annotate(new Command("status")
|
|
|
34304
34639
|
var endCommand = /* @__PURE__ */ __name(() => logsInOrOut(annotate(new Command("end"), {
|
|
34305
34640
|
effects: LOCAL_WRITE,
|
|
34306
34641
|
mcp: false,
|
|
34307
|
-
examples: [`${
|
|
34642
|
+
examples: [`${CLI7} personal session end`]
|
|
34308
34643
|
})).summary("forget this profile's token on this computer").description(`forget this profile's token on this computer; the token itself stays valid in ${SERVICE}. Only this tool's own entry goes: Notion's own CLI keeps its tokens under the same keyring name, and they stay`).action(function() {
|
|
34309
34644
|
refuseUnderReadOnly(this, "session end");
|
|
34310
34645
|
const { profile, tokens } = contextOf(this);
|
|
34311
34646
|
answer2(this, { profile, ended: tokens.remove(profile) });
|
|
34312
34647
|
}), "endCommand");
|
|
34313
|
-
var
|
|
34648
|
+
var listCommand7 = /* @__PURE__ */ __name(() => profileFree(annotate(new Command("list"), {
|
|
34314
34649
|
effects: LOCAL_READ,
|
|
34315
|
-
examples: [`${
|
|
34650
|
+
examples: [`${CLI7} session list`, `${CLI7} session list --json`]
|
|
34316
34651
|
})).summary("list the profiles here and whether each is signed in").description("list the profiles on this computer and whether each has a token; picks none").action(function() {
|
|
34317
34652
|
const environment = environmentOf(this);
|
|
34318
34653
|
const env = environment.env ?? process.env;
|
|
@@ -34329,7 +34664,7 @@ var listCommand6 = /* @__PURE__ */ __name(() => profileFree(annotate(new Command
|
|
|
34329
34664
|
});
|
|
34330
34665
|
renderAnswer(this, outputFor(this), listOf("session list", { items, limit: Math.max(1, items.length), has_more: false }));
|
|
34331
34666
|
}), "listCommand");
|
|
34332
|
-
var sessionCommand = /* @__PURE__ */ __name(() => annotate(new Command("session"), { effects: LOCAL_READ }).description(`keep this profile's ${SERVICE} token in the OS keyring`).addCommand(startCommand()).addCommand(statusCommand3()).addCommand(endCommand()).addCommand(
|
|
34667
|
+
var sessionCommand = /* @__PURE__ */ __name(() => annotate(new Command("session"), { effects: LOCAL_READ }).description(`keep this profile's ${SERVICE} token in the OS keyring`).addCommand(startCommand()).addCommand(statusCommand3()).addCommand(endCommand()).addCommand(listCommand7()), "sessionCommand");
|
|
34333
34668
|
|
|
34334
34669
|
// dist/program.js
|
|
34335
34670
|
var update = appUpdate({
|
|
@@ -34367,6 +34702,8 @@ var definition = /* @__PURE__ */ __name(() => ({
|
|
|
34367
34702
|
sessionCommand(),
|
|
34368
34703
|
...libraryCommands(),
|
|
34369
34704
|
databasesCommand(),
|
|
34705
|
+
commentsCommand2(),
|
|
34706
|
+
filesCommand(),
|
|
34370
34707
|
apiCommand(),
|
|
34371
34708
|
appDoctorCommand2(IDENTITY, configuration, { packageName: PACKAGE }),
|
|
34372
34709
|
skillCommand3(IDENTITY, SKILL),
|