@doist/automations-cli 1.3.0 → 1.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/dist/index.js +35 -12
- package/dist/index.js.map +3 -3
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -15,7 +15,7 @@ import { fileURLToPath } from "node:url";
|
|
|
15
15
|
// package.json
|
|
16
16
|
var package_default = {
|
|
17
17
|
name: "@doist/automations-cli",
|
|
18
|
-
version: "1.
|
|
18
|
+
version: "1.4.0",
|
|
19
19
|
description: "Command-line client for Todoist Automations",
|
|
20
20
|
type: "module",
|
|
21
21
|
bin: {
|
|
@@ -21555,7 +21555,8 @@ var FRONTEND_COHORT_EVENTS = [
|
|
|
21555
21555
|
"onboarding:completed",
|
|
21556
21556
|
"chat:sent",
|
|
21557
21557
|
"automation:repaired",
|
|
21558
|
-
"template:used"
|
|
21558
|
+
"template:used",
|
|
21559
|
+
"top-up:completed"
|
|
21559
21560
|
];
|
|
21560
21561
|
var BACKEND_COHORT_EVENTS = [
|
|
21561
21562
|
// API-process (publish lifecycle)
|
|
@@ -27703,16 +27704,24 @@ function formatWorkspaceList(workspaces) {
|
|
|
27703
27704
|
if (workspaces.length === 0) {
|
|
27704
27705
|
return "No workspaces. Automations you create belong to your personal space.";
|
|
27705
27706
|
}
|
|
27706
|
-
return workspaces.map(
|
|
27707
|
-
|
|
27708
|
-
|
|
27709
|
-
|
|
27707
|
+
return workspaces.map(
|
|
27708
|
+
(workspace) => `${workspace.id} ${workspace.name} ${workspace.plan} ${workspace.role}${lockedNote(workspace)}`
|
|
27709
|
+
).join("\n");
|
|
27710
|
+
}
|
|
27711
|
+
function lockedNote(workspace) {
|
|
27712
|
+
return workspace.access === "locked" ? " (locked: plan does not cover Automations)" : "";
|
|
27710
27713
|
}
|
|
27711
27714
|
function summarizeWorkspaceList(workspaces) {
|
|
27712
27715
|
return { workspaces };
|
|
27713
27716
|
}
|
|
27714
27717
|
function formatCurrentWorkspace(result) {
|
|
27715
|
-
|
|
27718
|
+
if (result.workspaceId === null) {
|
|
27719
|
+
return "Personal space. Pin a workspace with `tda workspace use <workspace-id>`.";
|
|
27720
|
+
}
|
|
27721
|
+
if (!result.workspace) {
|
|
27722
|
+
return `Workspace ${result.workspaceId}, which is no longer available to you. Run \`tda workspace list\` to pick another, or \`tda workspace clear\`.`;
|
|
27723
|
+
}
|
|
27724
|
+
return `Workspace ${result.workspace.name} (${result.workspaceId})${lockedNote(result.workspace)}`;
|
|
27716
27725
|
}
|
|
27717
27726
|
function formatWorkspaceSelection(result) {
|
|
27718
27727
|
return result.action === "cleared" ? "Cleared. Commands now act on your personal space." : `Pinned ${result.name ?? result.workspaceId}. \`automation list\`, \`view\` and \`trigger\` now act on this workspace; everything else stays personal. Use --personal for a one-off.`;
|
|
@@ -27737,8 +27746,7 @@ function registerWorkspaceCommand(program) {
|
|
|
27737
27746
|
await runApiCommand(
|
|
27738
27747
|
command,
|
|
27739
27748
|
async ({ api, signal }) => {
|
|
27740
|
-
const
|
|
27741
|
-
const match = workspaces.find((candidate) => candidate.id === workspaceId);
|
|
27749
|
+
const match = await findWorkspace(api, workspaceId, signal);
|
|
27742
27750
|
if (!match) {
|
|
27743
27751
|
throw new Error(
|
|
27744
27752
|
`No workspace ${workspaceId} available to you. Run \`tda workspace list\` to see which are.`
|
|
@@ -27757,10 +27765,21 @@ function registerWorkspaceCommand(program) {
|
|
|
27757
27765
|
);
|
|
27758
27766
|
});
|
|
27759
27767
|
workspace.command("current").description("Show which workspace commands act on").action(async (_options, command) => {
|
|
27760
|
-
await
|
|
27768
|
+
const workspaceId = await getDefaultWorkspaceId();
|
|
27769
|
+
if (workspaceId === null) {
|
|
27770
|
+
await runLocalCommand(command, async () => ({ workspaceId }), {
|
|
27771
|
+
human: formatCurrentWorkspace
|
|
27772
|
+
});
|
|
27773
|
+
return;
|
|
27774
|
+
}
|
|
27775
|
+
await runApiCommand(
|
|
27761
27776
|
command,
|
|
27762
|
-
async (
|
|
27763
|
-
|
|
27777
|
+
async ({ api, signal }) => {
|
|
27778
|
+
const workspace2 = await findWorkspace(api, workspaceId, signal);
|
|
27779
|
+
return { workspaceId, workspace: workspace2 };
|
|
27780
|
+
},
|
|
27781
|
+
{ human: formatCurrentWorkspace },
|
|
27782
|
+
{ spinner: "Loading workspace..." }
|
|
27764
27783
|
);
|
|
27765
27784
|
});
|
|
27766
27785
|
workspace.command("clear").description("Unpin the workspace and go back to your personal space").action(async (_options, command) => {
|
|
@@ -27774,6 +27793,10 @@ function registerWorkspaceCommand(program) {
|
|
|
27774
27793
|
);
|
|
27775
27794
|
});
|
|
27776
27795
|
}
|
|
27796
|
+
async function findWorkspace(api, workspaceId, signal) {
|
|
27797
|
+
const workspaces = await api.workspaces.list({ signal });
|
|
27798
|
+
return workspaces.find((candidate) => candidate.id === workspaceId);
|
|
27799
|
+
}
|
|
27777
27800
|
|
|
27778
27801
|
// src/lib/command-output.ts
|
|
27779
27802
|
function configureCommandOutput(command) {
|