@kamilio/wire 0.1.22 → 0.1.24
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 +8 -2
- package/dist/adapters/root.d.ts +6 -0
- package/dist/adapters/root.d.ts.map +1 -1
- package/dist/adapters/root.js +54 -16
- package/dist/adapters/root.js.map +1 -1
- package/dist/cli.js +3 -3
- package/dist/cli.js.map +1 -1
- package/dist/executable.d.ts.map +1 -1
- package/dist/executable.js +3 -2
- package/dist/executable.js.map +1 -1
- package/node_modules/@xmldom/xmldom/CHANGELOG.md +1132 -0
- package/node_modules/@xmldom/xmldom/LICENSE +8 -0
- package/node_modules/@xmldom/xmldom/SECURITY.md +50 -0
- package/node_modules/@xmldom/xmldom/index.d.ts +1843 -0
- package/node_modules/@xmldom/xmldom/lib/.eslintrc.yml +3 -0
- package/node_modules/@xmldom/xmldom/lib/conventions.js +429 -0
- package/node_modules/@xmldom/xmldom/lib/dom-parser.js +591 -0
- package/node_modules/@xmldom/xmldom/lib/dom.js +3759 -0
- package/node_modules/@xmldom/xmldom/lib/entities.js +2171 -0
- package/node_modules/@xmldom/xmldom/lib/errors.js +205 -0
- package/node_modules/@xmldom/xmldom/lib/grammar.js +559 -0
- package/node_modules/@xmldom/xmldom/lib/index.js +41 -0
- package/node_modules/@xmldom/xmldom/lib/sax.js +983 -0
- package/node_modules/@xmldom/xmldom/package.json +77 -0
- package/node_modules/@xmldom/xmldom/readme.md +366 -0
- package/node_modules/marked/LICENSE.md +44 -0
- package/node_modules/marked/README.md +107 -0
- package/node_modules/marked/bin/main.js +284 -0
- package/node_modules/marked/bin/marked.js +16 -0
- package/node_modules/marked/lib/marked.d.ts +759 -0
- package/node_modules/marked/lib/marked.esm.js +72 -0
- package/node_modules/marked/lib/marked.esm.js.map +7 -0
- package/node_modules/marked/lib/marked.umd.js +74 -0
- package/node_modules/marked/lib/marked.umd.js.map +7 -0
- package/node_modules/marked/man/marked.1 +113 -0
- package/node_modules/marked/man/marked.1.md +93 -0
- package/node_modules/marked/package.json +103 -0
- package/node_modules/provider-asana/dist/asana-explore.d.ts +2 -1
- package/node_modules/provider-asana/dist/asana-explore.d.ts.map +1 -1
- package/node_modules/provider-asana/dist/asana-explore.js +17 -1
- package/node_modules/provider-asana/dist/asana-explore.js.map +1 -1
- package/node_modules/provider-asana/dist/asana-markdown.d.ts +5 -0
- package/node_modules/provider-asana/dist/asana-markdown.d.ts.map +1 -0
- package/node_modules/provider-asana/dist/asana-markdown.js +127 -0
- package/node_modules/provider-asana/dist/asana-markdown.js.map +1 -0
- package/node_modules/provider-asana/dist/asana-task.d.ts +9 -4
- package/node_modules/provider-asana/dist/asana-task.d.ts.map +1 -1
- package/node_modules/provider-asana/dist/asana-task.js +92 -12
- package/node_modules/provider-asana/dist/asana-task.js.map +1 -1
- package/node_modules/provider-asana/dist/index.d.ts +2 -2
- package/node_modules/provider-asana/dist/index.d.ts.map +1 -1
- package/node_modules/provider-asana/dist/index.js +2 -2
- package/node_modules/provider-asana/dist/index.js.map +1 -1
- package/node_modules/provider-asana/package.json +2 -0
- package/node_modules/provider-asana/src/asana-explore.ts +17 -2
- package/node_modules/provider-asana/src/asana-markdown.ts +113 -0
- package/node_modules/provider-asana/src/asana-task.ts +80 -12
- package/node_modules/provider-asana/src/index.ts +2 -2
- package/package.json +12 -6
- package/src/adapters/root.ts +56 -16
- package/src/cli.ts +3 -3
- package/src/executable.ts +3 -2
package/src/adapters/root.ts
CHANGED
|
@@ -417,9 +417,15 @@ function authGroup(service: AuthService, description: string, loginDescription:
|
|
|
417
417
|
}
|
|
418
418
|
|
|
419
419
|
type AsanaExplorer = {
|
|
420
|
+
lookup?(query: string): Promise<readonly JsonObject[]>;
|
|
420
421
|
projects(): ReturnType<typeof listAsanaProjects>;
|
|
421
422
|
tasks(project: string): ReturnType<typeof listAsanaTasks>;
|
|
422
423
|
show(task: string): Promise<FetchedDocument>;
|
|
424
|
+
writes?: {
|
|
425
|
+
edit(task: string, fields: JsonObject): Promise<JsonObject>;
|
|
426
|
+
comment(task: string, body: string): Promise<JsonObject>;
|
|
427
|
+
editComment(comment: string, body: string): Promise<JsonObject>;
|
|
428
|
+
};
|
|
423
429
|
};
|
|
424
430
|
|
|
425
431
|
export function createRoot(wire: Wire, currentDirectory: string, auth?: Auth, readInput?: TextInputReader, options: WireRootOptions = { allowPaste: true }, sendSlack?: (destination: string, markdown: string) => Promise<SlackSentMessage>, lookupSlack?: (query: string) => Promise<readonly JsonObject[]>, editSlack?: (url: string, markdown: string) => Promise<SlackSentMessage>, lookupNotion?: (query: string) => Promise<readonly JsonObject[]>, asana?: AsanaExplorer): WireRoot {
|
|
@@ -456,7 +462,21 @@ export function createRoot(wire: Wire, currentDirectory: string, auth?: Auth, re
|
|
|
456
462
|
const authCommand = (service: (typeof authServices)[number]) => {
|
|
457
463
|
const title = serviceTitle(service);
|
|
458
464
|
const group = authGroup(service, `Manage ${title} login.`, "Capture cookies once; normal commands reuse saved cookies.", auth!, readInput, options);
|
|
459
|
-
|
|
465
|
+
const lookup = service === "slack" ? lookupSlack : service === "notion" ? lookupNotion : service === "asana" ? asana?.lookup : undefined;
|
|
466
|
+
const users = lookup === undefined ? [] : [defineGroup({ name: "users", description: "Find people by email or name.", children: [defineCommand({
|
|
467
|
+
name: "lookup",
|
|
468
|
+
description: service === "asana" ? "Find users by partial name or exact email. Returns names, emails, and assignee IDs." : "Look up active users by exact email or name. Email lookup avoids ambiguous names.",
|
|
469
|
+
positional: ["query"],
|
|
470
|
+
params: S.Object({ query: S.String({ description: "Email address or name to look up." }) }),
|
|
471
|
+
handler: ({ params }) => userFacing(() => lookup(params.query)),
|
|
472
|
+
render: render<readonly JsonObject[]>((results) => results.length === 0 ? "No matching users" : results.map((user) => {
|
|
473
|
+
if (service === "asana") return `${user["gid"]} ${user["name"]} ${user["email"] ?? ""}`;
|
|
474
|
+
const profile = user["profile"] as JsonObject | undefined;
|
|
475
|
+
return service === "slack" ? `${user["id"]} ${user["real_name"] ?? user["name"]} ${profile?.["email"] ?? ""}` : `${user["userId"]} ${user["name"] ?? ""} ${(user["aliases"] as readonly string[] | undefined ?? []).join(", ")}`;
|
|
476
|
+
}).join("\n")),
|
|
477
|
+
})] })];
|
|
478
|
+
const writes = asana?.writes;
|
|
479
|
+
if (service === "asana" && asana !== undefined) return defineGroup({ ...group, description: "Browse Asana projects, edit tasks and comments, and manage login.", children: [...group.children, ...users,
|
|
460
480
|
defineGroup({ name: "projects", description: "Browse projects.", children: [defineCommand({
|
|
461
481
|
name: "list", description: "List active projects by workspace and team.", params: S.Object({}),
|
|
462
482
|
handler: () => userFacing(() => asana.projects()),
|
|
@@ -469,29 +489,49 @@ export function createRoot(wire: Wire, currentDirectory: string, auth?: Auth, re
|
|
|
469
489
|
})),
|
|
470
490
|
].join("\n")).join("\n\n") || "No workspaces"),
|
|
471
491
|
})] }),
|
|
472
|
-
defineGroup({ name: "tasks", description: "Browse tasks.", children: [defineCommand({
|
|
492
|
+
defineGroup({ name: "tasks", description: "Browse and edit tasks.", children: [defineCommand({
|
|
473
493
|
name: "list", description: "List tasks in a project, with completion status and task IDs.", positional: ["project"],
|
|
474
494
|
params: S.Object({ project: S.String({ description: "Asana project ID." }) }),
|
|
475
495
|
handler: ({ params }) => userFacing(() => asana.tasks(params.project)),
|
|
476
496
|
render: render<Awaited<ReturnType<typeof listAsanaTasks>>>((tasks) => tasks.map((task) => `- [${task.completed ? "x" : " "}] ${lineText(task.name)} ${task.gid}`).join("\n") || "No tasks"),
|
|
477
497
|
}), defineCommand({
|
|
478
|
-
name: "show", description: "Show a task's
|
|
498
|
+
name: "show", description: "Show a task's properties, custom field IDs, Markdown description, comments, and activity.", positional: ["task"],
|
|
479
499
|
params: S.Object({ task: S.String({ description: "Asana task ID." }) }),
|
|
480
500
|
handler: ({ params }) => userFacing(() => asana.show(params.task)), render: wirePresentation.view,
|
|
481
|
-
})
|
|
501
|
+
}), ...(writes ? [defineCommand({
|
|
502
|
+
name: "edit", description: "Update task properties. Use --fields with a JSON object for other writable Asana properties, including custom_fields keyed by ID.", positional: ["task"],
|
|
503
|
+
params: S.Object({
|
|
504
|
+
task: S.String({ description: "Asana task ID." }),
|
|
505
|
+
title: S.Optional(S.String({ description: "New task name." })),
|
|
506
|
+
body: S.Optional(S.String({ description: "New description in Markdown." })),
|
|
507
|
+
assignee: S.Optional(S.String({ description: "Email, user ID, or me." })),
|
|
508
|
+
due: S.Optional(S.String({ description: "Due date (YYYY-MM-DD)." })),
|
|
509
|
+
fields: S.Optional(S.Json()),
|
|
510
|
+
}),
|
|
511
|
+
handler: ({ params: { task, fields, title, body, assignee, due } }) => userFacing(async () => {
|
|
512
|
+
if (fields !== undefined && (!fields || typeof fields !== "object" || Array.isArray(fields))) throw new UserError("--fields requires a JSON object.");
|
|
513
|
+
const changes = { ...fields };
|
|
514
|
+
for (const [key, value] of Object.entries({ name: title, notes: body, assignee, due_on: due })) {
|
|
515
|
+
if (value === undefined) continue;
|
|
516
|
+
if (Object.hasOwn(changes, key)) throw new UserError(`Task field specified twice: ${key}.`);
|
|
517
|
+
changes[key] = value;
|
|
518
|
+
}
|
|
519
|
+
return writes.edit(task, changes);
|
|
520
|
+
}),
|
|
521
|
+
render: render<JsonObject>((task) => `Updated task ${task["gid"]}: ${task["permalink_url"]}`),
|
|
522
|
+
}), defineCommand({
|
|
523
|
+
name: "comment", description: "Add a Markdown comment to a task.", positional: ["task"],
|
|
524
|
+
params: S.Object({ task: S.String({ description: "Asana task ID." }), body: S.String({ description: "Comment in Markdown." }) }),
|
|
525
|
+
handler: ({ params }) => userFacing(() => writes.comment(params.task, params.body)),
|
|
526
|
+
render: render<JsonObject>((comment) => `Added comment ${comment["gid"]}`),
|
|
527
|
+
})] : [])] }),
|
|
528
|
+
...(writes ? [defineGroup({ name: "comments", description: "Edit Asana comments.", children: [defineCommand({
|
|
529
|
+
name: "edit", description: "Replace an editable comment using its story ID from tasks show.", positional: ["comment"],
|
|
530
|
+
params: S.Object({ comment: S.String({ description: "Comment ID from tasks show." }), body: S.String({ description: "Replacement comment in Markdown." }) }),
|
|
531
|
+
handler: ({ params }) => userFacing(() => writes.editComment(params.comment, params.body)),
|
|
532
|
+
render: render<JsonObject>((comment) => `Updated comment ${comment["gid"]}`),
|
|
533
|
+
})] })] : []),
|
|
482
534
|
] });
|
|
483
|
-
const lookup = service === "slack" ? lookupSlack : service === "notion" ? lookupNotion : undefined;
|
|
484
|
-
const users = lookup === undefined ? [] : [defineGroup({ name: "users", description: "Find people by email or name.", children: [defineCommand({
|
|
485
|
-
name: "lookup",
|
|
486
|
-
description: "Look up active users by exact email or name. Email lookup avoids ambiguous names.",
|
|
487
|
-
positional: ["query"],
|
|
488
|
-
params: S.Object({ query: S.String({ description: "Email address or name to look up." }) }),
|
|
489
|
-
handler: ({ params }) => userFacing(() => lookup(params.query)),
|
|
490
|
-
render: render<readonly JsonObject[]>((results) => results.length === 0 ? "No matching users" : results.map((user) => {
|
|
491
|
-
const profile = user["profile"] as JsonObject | undefined;
|
|
492
|
-
return service === "slack" ? `${user["id"]} ${user["real_name"] ?? user["name"]} ${profile?.["email"] ?? ""}` : `${user["userId"]} ${user["name"] ?? ""} ${(user["aliases"] as readonly string[] | undefined ?? []).join(", ")}`;
|
|
493
|
-
}).join("\n")),
|
|
494
|
-
})] })];
|
|
495
535
|
if (service !== "slack") return users.length === 0 ? group : defineGroup({ ...group, children: [...group.children, ...users] });
|
|
496
536
|
return defineGroup({ name: "slack", description: "Read Slack channels, DMs, and threads, send Markdown, and manage login.", children: [preview, defaultAttach, sync, ...group.children, ...users, ...(sendSlack === undefined ? [] : [defineCommand({
|
|
497
537
|
name: "send",
|
package/src/cli.ts
CHANGED
|
@@ -241,7 +241,7 @@ function excessPositionals(argv: readonly string[]): Readonly<{ commandPath: str
|
|
|
241
241
|
if (command in fixedCommandPositionals) return Object.freeze({ commandPath: command, expected: fixedCommandPositionals[command as keyof typeof fixedCommandPositionals].expected, received: words.length - 1 });
|
|
242
242
|
if (command === "asana" && ((words[1] === "projects" && words[2] === "list") || (words[1] === "tasks" && (words[2] === "list" || words[2] === "show")))) return { commandPath: words.slice(0, 3).join(" "), expected: words[1] === "projects" ? 0 : 1, received: words.length - 3 };
|
|
243
243
|
if (command === "slack" && slackResourceCommands.has(words[1]!)) return { commandPath: `slack ${words[1]}`, expected: 1, received: words.length - 2 };
|
|
244
|
-
if ((command === "slack" || command === "notion") && words[1] === "users" && words[2] === "lookup") return { commandPath: `${command} users lookup`, expected: 1, received: words.length - 3 };
|
|
244
|
+
if ((command === "slack" || command === "notion" || command === "asana") && words[1] === "users" && words[2] === "lookup") return { commandPath: `${command} users lookup`, expected: 1, received: words.length - 3 };
|
|
245
245
|
if (command === "slack" && (words[1] === "send" || words[1] === "edit")) return { commandPath: `slack ${words[1]}`, expected: 2, received: words.length - 2 };
|
|
246
246
|
if (authServices.has(command)) {
|
|
247
247
|
const authCommand = words[1];
|
|
@@ -259,7 +259,7 @@ function missingPositionals(argv: readonly string[]): Readonly<{ commandPath: st
|
|
|
259
259
|
const command = words[0]!;
|
|
260
260
|
if (command === "asana" && words[1] === "tasks" && (words[2] === "list" || words[2] === "show") && words.length === 3) return { commandPath: words.join(" "), name: words[2] === "list" ? "project" : "task" };
|
|
261
261
|
if (command === "slack" && slackResourceCommands.has(words[1]!) && words.length < 3) return { commandPath: `slack ${words[1]}`, name: words[1] === "sync" ? "resource" : "url" };
|
|
262
|
-
if ((command === "slack" || command === "notion") && words[1] === "users" && words[2] === "lookup" && words.length < 4) return { commandPath: `${command} users lookup`, name: "query" };
|
|
262
|
+
if ((command === "slack" || command === "notion" || command === "asana") && words[1] === "users" && words[2] === "lookup" && words.length < 4) return { commandPath: `${command} users lookup`, name: "query" };
|
|
263
263
|
if (command === "slack" && (words[1] === "send" || words[1] === "edit") && words.length < 4) return { commandPath: `slack ${words[1]}`, name: words.length === 2 ? words[1] === "send" ? "destination" : "url" : "markdown" };
|
|
264
264
|
if (!(command in fixedCommandPositionals)) return null;
|
|
265
265
|
const positional = fixedCommandPositionals[command as keyof typeof fixedCommandPositionals];
|
|
@@ -296,7 +296,7 @@ function renderRemovedCommand(argv: readonly string[]): boolean {
|
|
|
296
296
|
function renderUnknownAuthCommand(argv: readonly string[]): boolean {
|
|
297
297
|
if (hasRootSeparator(argv)) return false;
|
|
298
298
|
const words = positionalWords(argv);
|
|
299
|
-
if (words === null || words.length < 2 || !authServices.has(words[0]!) || authCommands.has(words[1]!) || words[0] === "asana" && (words[1] === "projects" || words[1] === "tasks") || (words[0] === "slack" || words[0] === "notion") && words[1] === "users" || words[0] === "slack" && (words[1] === "send" || words[1] === "edit" || slackResourceCommands.has(words[1]!))) return false;
|
|
299
|
+
if (words === null || words.length < 2 || !authServices.has(words[0]!) || authCommands.has(words[1]!) || words[0] === "asana" && (words[1] === "projects" || words[1] === "tasks" || words[1] === "comments") || (words[0] === "slack" || words[0] === "notion" || words[0] === "asana") && words[1] === "users" || words[0] === "slack" && (words[1] === "send" || words[1] === "edit" || slackResourceCommands.has(words[1]!))) return false;
|
|
300
300
|
renderCliError(argv, `Unknown command: ${words[1]}`, `wire ${words[0]} --help`, `Unknown command: ${cliValue(words[1]!)}`);
|
|
301
301
|
return true;
|
|
302
302
|
}
|
package/src/executable.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { existsSync, readFileSync, statSync } from "node:fs";
|
|
|
2
2
|
import { mkdir, writeFile } from "node:fs/promises";
|
|
3
3
|
import { dirname, isAbsolute, join, resolve } from "node:path";
|
|
4
4
|
|
|
5
|
-
import { listAsanaProjects, listAsanaTasks, showAsanaTask } from "provider-asana";
|
|
5
|
+
import { addAsanaComment, editAsanaComment, editAsanaTask, listAsanaProjects, listAsanaTasks, lookupAsanaUsers, showAsanaTask } from "provider-asana";
|
|
6
6
|
import { sendSlackMessage, editSlackMessage, lookupSlackUsers } from "provider-slack";
|
|
7
7
|
|
|
8
8
|
import { lookupNotionUsers } from "provider-notion";
|
|
@@ -131,6 +131,7 @@ export function createExecutableRoot(environment: NodeEnvironment, currentDirect
|
|
|
131
131
|
});
|
|
132
132
|
const wire = withWireHooks(configuredWire, { currentDirectory, home, environment: configuredEnvironment() });
|
|
133
133
|
return createRoot(wire, currentDirectory, auth, readStandardInput, options, (destination, markdown) => sendSlackMessage(runtime, destination, markdown), (query) => lookupSlackUsers(runtime, query), (url, markdown) => editSlackMessage(runtime, url, markdown), (query) => lookupNotionUsers(runtime, query), {
|
|
134
|
-
projects: () => listAsanaProjects(runtime), tasks: (project) => listAsanaTasks(runtime, project), show: (task) => showAsanaTask(runtime, task),
|
|
134
|
+
lookup: (query) => lookupAsanaUsers(runtime, query), projects: () => listAsanaProjects(runtime), tasks: (project) => listAsanaTasks(runtime, project), show: (task) => showAsanaTask(runtime, task),
|
|
135
|
+
writes: { edit: (task, fields) => editAsanaTask(runtime, task, fields), comment: (task, body) => addAsanaComment(runtime, task, body), editComment: (comment, body) => editAsanaComment(runtime, comment, body) },
|
|
135
136
|
});
|
|
136
137
|
}
|