not-manage 0.2.0 → 0.2.2

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.
@@ -1,156 +0,0 @@
1
- const {
2
- clip,
3
- compactQuery,
4
- formatBoolean,
5
- parseLimit,
6
- printKeyValueRows,
7
- readContactName,
8
- readUserName,
9
- } = require("./resource-utils");
10
- const { createGetCommand, createListCommand } = require("./resource-command-runner");
11
- const { getResourceMetadata } = require("./resource-metadata");
12
-
13
- const MATTER_RESOURCE = getResourceMetadata("matters");
14
-
15
- function readStatus(status) {
16
- if (!status) {
17
- return "-";
18
- }
19
- if (typeof status === "string") {
20
- return status;
21
- }
22
- return status.name || status.value || status.state || "-";
23
- }
24
-
25
- function readClientName(matter) {
26
- const single = readContactName(matter.client);
27
- if (single !== "-") {
28
- return single;
29
- }
30
-
31
- const list = Array.isArray(matter.clients) ? matter.clients : [];
32
- if (list.length > 0) {
33
- return readContactName(list[0]);
34
- }
35
-
36
- return "-";
37
- }
38
-
39
- function formatMatterRow(matter) {
40
- const id = matter.id || "-";
41
- const displayNumber = matter.display_number || matter.number || "-";
42
- const status = readStatus(matter.status);
43
- const client = readClientName(matter);
44
- const description = matter.description || "-";
45
-
46
- return {
47
- id: String(id),
48
- displayNumber: String(displayNumber),
49
- status: String(status),
50
- client: String(client),
51
- description: String(description),
52
- };
53
- }
54
-
55
- function buildMatterQuery(options) {
56
- return compactQuery({
57
- client_id: options.clientId || undefined,
58
- created_since: options.createdSince || undefined,
59
- fields: options.fields || MATTER_RESOURCE.defaultFields.list,
60
- limit: parseLimit(options.limit),
61
- order: options.order || undefined,
62
- originating_attorney_id: options.originatingAttorneyId || undefined,
63
- page_token: options.pageToken || undefined,
64
- practice_area_id: options.practiceAreaId || undefined,
65
- query: options.query || undefined,
66
- responsible_attorney_id: options.responsibleAttorneyId || undefined,
67
- responsible_staff_id: options.responsibleStaffId || undefined,
68
- status: options.status || undefined,
69
- updated_since: options.updatedSince || undefined,
70
- });
71
- }
72
-
73
- function printMatterList(matterRows, options) {
74
- if (matterRows.length === 0) {
75
- console.log("No matters found for the selected filters.");
76
- return;
77
- }
78
-
79
- const rows = matterRows.slice(0, 50);
80
-
81
- console.log("ID MATTER STATUS CLIENT DESCRIPTION");
82
- console.log("-------- --------------------- --------- -------------------- ------------------------------");
83
-
84
- rows.forEach((row) => {
85
- const line = [
86
- clip(row.id, 8).padEnd(8, " "),
87
- clip(row.displayNumber, 21).padEnd(21, " "),
88
- clip(row.status, 9).padEnd(9, " "),
89
- clip(row.client, 20).padEnd(20, " "),
90
- clip(row.description, 30),
91
- ].join(" ");
92
-
93
- console.log(line);
94
- });
95
-
96
- if (matterRows.length > rows.length) {
97
- console.log(
98
- `Showing ${rows.length} of ${matterRows.length} matters. Use --json for full output.`
99
- );
100
- }
101
-
102
- if (!options.all && options.nextPageUrl) {
103
- console.log("");
104
- console.log("More results are available.");
105
- console.log("Run again with `--all` or pass `--page-token` from `--json` output.");
106
- }
107
- }
108
-
109
- function printMatter(matter) {
110
- printKeyValueRows([
111
- ["ID", matter.id],
112
- ["Matter", matter.display_number || matter.number],
113
- ["Description", matter.description],
114
- ["Status", readStatus(matter.status)],
115
- ["Client", readClientName(matter)],
116
- ["Practice Area", matter.practice_area?.name],
117
- ["Responsible Attorney", readUserName(matter.responsible_attorney)],
118
- ["Responsible Staff", readUserName(matter.responsible_staff)],
119
- ["Originating Attorney", readUserName(matter.originating_attorney)],
120
- ["Billable", formatBoolean(matter.billable)],
121
- ["Open Date", matter.open_date],
122
- ["Pending Date", matter.pending_date],
123
- ["Close Date", matter.close_date],
124
- ["Created", matter.created_at],
125
- ["Updated", matter.updated_at],
126
- ]);
127
- }
128
-
129
- const mattersList = createListCommand({
130
- apiPath: MATTER_RESOURCE.apiPath,
131
- buildQuery: buildMatterQuery,
132
- formatRow: formatMatterRow,
133
- pluralLabel: MATTER_RESOURCE.summaryLabels.plural,
134
- printList: printMatterList,
135
- redactionResourceType: MATTER_RESOURCE.redaction.resourceType,
136
- singularLabel: MATTER_RESOURCE.summaryLabels.singular,
137
- });
138
-
139
- const mattersGet = createGetCommand({
140
- apiPath: MATTER_RESOURCE.apiPath,
141
- defaultFields: MATTER_RESOURCE.defaultFields.get,
142
- printItem: printMatter,
143
- redactionResourceType: MATTER_RESOURCE.redaction.resourceType,
144
- usage: "Usage: not-manage matters get <id> [--fields ...] [--json]",
145
- });
146
-
147
- module.exports = {
148
- mattersGet,
149
- mattersList,
150
- __private: {
151
- buildMatterQuery,
152
- formatMatterRow,
153
- printMatter,
154
- printMatterList,
155
- },
156
- };
@@ -1,155 +0,0 @@
1
- const {
2
- clip,
3
- compactQuery,
4
- formatBoolean,
5
- parseLimit,
6
- printKeyValueRows,
7
- readMatterLabel,
8
- readUserName,
9
- } = require("./resource-utils");
10
- const { createGetCommand, createListCommand } = require("./resource-command-runner");
11
- const { getResourceMetadata } = require("./resource-metadata");
12
-
13
- const TASK_RESOURCE = getResourceMetadata("tasks");
14
-
15
- function readTaskStatus(status) {
16
- if (!status) {
17
- return "-";
18
- }
19
-
20
- if (typeof status === "string") {
21
- return status;
22
- }
23
-
24
- return status.name || status.value || status.state || "-";
25
- }
26
-
27
- function readTaskComplete(task) {
28
- if (typeof task?.complete === "boolean") {
29
- return task.complete;
30
- }
31
-
32
- if (typeof task?.status === "string") {
33
- return task.status.toLowerCase() === "complete";
34
- }
35
-
36
- return undefined;
37
- }
38
-
39
- function buildTaskQuery(options) {
40
- return compactQuery({
41
- client_id: options.clientId || undefined,
42
- complete:
43
- options.complete === undefined || options.complete === null
44
- ? undefined
45
- : Boolean(options.complete),
46
- created_since: options.createdSince || undefined,
47
- due_at_from: options.dueAtFrom || undefined,
48
- due_at_to: options.dueAtTo || undefined,
49
- fields: options.fields || TASK_RESOURCE.defaultFields.list,
50
- limit: parseLimit(options.limit),
51
- matter_id: options.matterId || undefined,
52
- order: options.order || undefined,
53
- page_token: options.pageToken || undefined,
54
- priority: options.priority || undefined,
55
- query: options.query || undefined,
56
- responsible_attorney_id: options.responsibleAttorneyId || undefined,
57
- status: options.status || undefined,
58
- task_type_id: options.taskTypeId || undefined,
59
- updated_since: options.updatedSince || undefined,
60
- });
61
- }
62
-
63
- function formatTaskRow(task) {
64
- return {
65
- id: String(task.id || "-"),
66
- status: String(readTaskStatus(task.status)),
67
- dueAt: String(task.due_at || "-"),
68
- priority: String(task.priority || "-"),
69
- matter: readMatterLabel(task.matter),
70
- task: String(task.name || "-"),
71
- };
72
- }
73
-
74
- function printTaskList(rows, options) {
75
- if (rows.length === 0) {
76
- console.log("No tasks found for the selected filters.");
77
- return;
78
- }
79
-
80
- const visibleRows = rows.slice(0, 50);
81
- console.log("ID STATUS DUE PRIORITY MATTER TASK");
82
- console.log("-------- ------------ ------------ -------- -------------------- ------------------------------");
83
-
84
- visibleRows.forEach((row) => {
85
- const line = [
86
- clip(row.id, 8).padEnd(8, " "),
87
- clip(row.status, 12).padEnd(12, " "),
88
- clip(row.dueAt, 12).padEnd(12, " "),
89
- clip(row.priority, 8).padEnd(8, " "),
90
- clip(row.matter, 20).padEnd(20, " "),
91
- clip(row.task, 30),
92
- ].join(" ");
93
-
94
- console.log(line);
95
- });
96
-
97
- if (rows.length > visibleRows.length) {
98
- console.log(`Showing ${visibleRows.length} of ${rows.length} tasks. Use --json for full output.`);
99
- }
100
-
101
- if (!options.all && options.nextPageUrl) {
102
- console.log("");
103
- console.log("More results are available.");
104
- console.log("Run again with `--all` or pass `--page-token` from `--json` output.");
105
- }
106
- }
107
-
108
- function printTask(task) {
109
- printKeyValueRows([
110
- ["ID", task.id],
111
- ["Name", task.name],
112
- ["Description", task.description],
113
- ["Status", readTaskStatus(task.status)],
114
- ["Priority", task.priority],
115
- ["Due", task.due_at],
116
- ["Complete", formatBoolean(readTaskComplete(task))],
117
- ["Matter", readMatterLabel(task.matter)],
118
- ["Assignee", readUserName(task.assignee)],
119
- ["Assigner", readUserName(task.assigner)],
120
- ["Task Type", task.task_type?.name],
121
- ["Created", task.created_at],
122
- ["Updated", task.updated_at],
123
- ]);
124
- }
125
-
126
- const tasksList = createListCommand({
127
- apiPath: TASK_RESOURCE.apiPath,
128
- buildQuery: buildTaskQuery,
129
- formatRow: formatTaskRow,
130
- pluralLabel: TASK_RESOURCE.summaryLabels.plural,
131
- printList: printTaskList,
132
- redactionResourceType: TASK_RESOURCE.redaction.resourceType,
133
- singularLabel: TASK_RESOURCE.summaryLabels.singular,
134
- });
135
-
136
- const tasksGet = createGetCommand({
137
- apiPath: TASK_RESOURCE.apiPath,
138
- defaultFields: TASK_RESOURCE.defaultFields.get,
139
- printItem: printTask,
140
- redactionResourceType: TASK_RESOURCE.redaction.resourceType,
141
- usage: "Usage: not-manage tasks get <id> [--fields ...] [--json]",
142
- });
143
-
144
- module.exports = {
145
- tasksGet,
146
- tasksList,
147
- __private: {
148
- buildTaskQuery,
149
- formatTaskRow,
150
- readTaskComplete,
151
- printTask,
152
- printTaskList,
153
- readTaskStatus,
154
- },
155
- };
@@ -1,134 +0,0 @@
1
- const {
2
- clip,
3
- compactQuery,
4
- formatBoolean,
5
- parseLimit,
6
- printKeyValueRows,
7
- readUserName,
8
- } = require("./resource-utils");
9
- const { createGetCommand, createListCommand } = require("./resource-command-runner");
10
- const { getResourceMetadata } = require("./resource-metadata");
11
-
12
- const USER_RESOURCE = getResourceMetadata("users");
13
-
14
- function readRoleList(user) {
15
- const roles = Array.isArray(user?.roles) ? user.roles : [];
16
- if (roles.length === 0) {
17
- return "-";
18
- }
19
- return roles.join(", ");
20
- }
21
-
22
- function buildUserQuery(options) {
23
- return compactQuery({
24
- created_since: options.createdSince || undefined,
25
- enabled:
26
- options.enabled === undefined || options.enabled === null
27
- ? undefined
28
- : Boolean(options.enabled),
29
- fields: options.fields || USER_RESOURCE.defaultFields.list,
30
- include_co_counsel: options.includeCoCounsel ? true : undefined,
31
- limit: parseLimit(options.limit, 2000),
32
- name: options.name || undefined,
33
- order: options.order || undefined,
34
- page_token: options.pageToken || undefined,
35
- pending_setup:
36
- options.pendingSetup === undefined || options.pendingSetup === null
37
- ? undefined
38
- : Boolean(options.pendingSetup),
39
- role: options.role || undefined,
40
- subscription_type: options.subscriptionType || undefined,
41
- updated_since: options.updatedSince || undefined,
42
- });
43
- }
44
-
45
- function formatUserRow(user) {
46
- return {
47
- id: String(user.id || "-"),
48
- name: readUserName(user),
49
- email: String(user.email || "-"),
50
- enabled: formatBoolean(user.enabled),
51
- roles: readRoleList(user),
52
- };
53
- }
54
-
55
- function printUserList(rows, options) {
56
- if (rows.length === 0) {
57
- console.log("No users found for the selected filters.");
58
- return;
59
- }
60
-
61
- const visibleRows = rows.slice(0, 50);
62
- console.log("ID NAME EMAIL ENABLED ROLES");
63
- console.log("-------- ---------------------------- ---------------------------- ------- ------------------------------");
64
-
65
- visibleRows.forEach((row) => {
66
- const line = [
67
- clip(row.id, 8).padEnd(8, " "),
68
- clip(row.name, 28).padEnd(28, " "),
69
- clip(row.email, 28).padEnd(28, " "),
70
- clip(row.enabled, 7).padEnd(7, " "),
71
- clip(row.roles, 30),
72
- ].join(" ");
73
-
74
- console.log(line);
75
- });
76
-
77
- if (rows.length > visibleRows.length) {
78
- console.log(`Showing ${visibleRows.length} of ${rows.length} users. Use --json for full output.`);
79
- }
80
-
81
- if (!options.all && options.nextPageUrl) {
82
- console.log("");
83
- console.log("More results are available.");
84
- console.log("Run again with `--all` or pass `--page-token` from `--json` output.");
85
- }
86
- }
87
-
88
- function printUser(user) {
89
- printKeyValueRows([
90
- ["ID", user.id],
91
- ["Name", readUserName(user)],
92
- ["Email", user.email],
93
- ["Enabled", formatBoolean(user.enabled)],
94
- ["Roles", readRoleList(user)],
95
- ["Subscription", user.subscription_type],
96
- ["Phone", user.phone_number],
97
- ["Time Zone", user.time_zone],
98
- ["Rate", user.rate],
99
- ["Account Owner", formatBoolean(user.account_owner)],
100
- ["Clio Connect", formatBoolean(user.clio_connect)],
101
- ["Court Rules Default Attendee", formatBoolean(user.court_rules_default_attendee)],
102
- ["Created", user.created_at],
103
- ["Updated", user.updated_at],
104
- ]);
105
- }
106
-
107
- const usersList = createListCommand({
108
- apiPath: USER_RESOURCE.apiPath,
109
- buildQuery: buildUserQuery,
110
- formatRow: formatUserRow,
111
- pluralLabel: USER_RESOURCE.summaryLabels.plural,
112
- printList: printUserList,
113
- redactionResourceType: USER_RESOURCE.redaction.resourceType,
114
- singularLabel: USER_RESOURCE.summaryLabels.singular,
115
- });
116
-
117
- const usersGet = createGetCommand({
118
- apiPath: USER_RESOURCE.apiPath,
119
- defaultFields: USER_RESOURCE.defaultFields.get,
120
- printItem: printUser,
121
- redactionResourceType: USER_RESOURCE.redaction.resourceType,
122
- usage: "Usage: not-manage users get <id> [--fields ...] [--json]",
123
- });
124
-
125
- module.exports = {
126
- usersGet,
127
- usersList,
128
- __private: {
129
- buildUserQuery,
130
- formatUserRow,
131
- printUser,
132
- printUserList,
133
- },
134
- };
@@ -1,140 +0,0 @@
1
- const { setupWizard } = require("./commands-auth");
2
- const { ask, withPrompt } = require("./prompt");
3
- const { findConfig } = require("./store");
4
-
5
- const SKIP_POSTINSTALL_ENV_VARS = [
6
- "NOT_MANAGE_SKIP_POSTINSTALL_SETUP",
7
- "CLIO_MANAGE_SKIP_POSTINSTALL_SETUP",
8
- ];
9
-
10
- function printConfidentialityNotice(log = console.log) {
11
- log("Confidentiality notice:");
12
- log(" not-manage can display client-identifying, confidential, or privileged matter data.");
13
- log(" `--redacted` is best-effort only and may miss identifiers in labels, custom fields, or free text.");
14
- log(" Review all output before sharing it with AI tools, tickets, chats, or other third parties.");
15
- log(" Use only with workflows and vendors your firm has approved.");
16
- }
17
-
18
- function shouldShowPostinstallNotice(options = {}) {
19
- const env = options.env || process.env;
20
-
21
- if (SKIP_POSTINSTALL_ENV_VARS.some((name) => env[name] === "1")) {
22
- return false;
23
- }
24
-
25
- if (env.CI) {
26
- return false;
27
- }
28
-
29
- if (env.npm_config_global !== "true") {
30
- return false;
31
- }
32
-
33
- return true;
34
- }
35
-
36
- function shouldRunPostinstallOnboarding(options = {}) {
37
- const stdin = options.stdin || process.stdin;
38
- const stdout = options.stdout || process.stdout;
39
-
40
- if (!shouldShowPostinstallNotice(options)) {
41
- return false;
42
- }
43
-
44
- if (!stdin.isTTY || !stdout.isTTY) {
45
- return false;
46
- }
47
-
48
- return true;
49
- }
50
-
51
- function printPostinstallIntro(log = console.log) {
52
- log("");
53
- log("+===========================================+");
54
- log("| NOT MANAGE IS INSTALLED |");
55
- log("+===========================================+");
56
- log("| Start first-time setup from npm? |");
57
- log("+===========================================+");
58
- log("");
59
- log("This prompt only appears on fresh interactive global installs.");
60
- log("If you skip it now, run `not-manage setup` whenever you are ready.");
61
- log("");
62
- printConfidentialityNotice(log);
63
- log("");
64
- }
65
-
66
- function printPostinstallInstalledNotice(log = console.log) {
67
- log("");
68
- log("not-manage is installed.");
69
- printConfidentialityNotice(log);
70
- log("Run `not-manage setup` whenever you are ready.");
71
- }
72
-
73
- function printPostinstallWelcomeBack(log = console.log) {
74
- log("");
75
- log("Welcome back. Clio is already configured on this machine.");
76
- log("Run `not-manage auth status` to verify the current connection, or `not-manage setup` to reconfigure.");
77
- }
78
-
79
- async function maybeRunPostinstallOnboarding(options = {}) {
80
- const log = options.log || console.log;
81
- const findConfigFn = options.findConfig || findConfig;
82
- const setupWizardFn = options.setupWizard || setupWizard;
83
- const withPromptFn = options.withPrompt || withPrompt;
84
- const askFn = options.ask || ask;
85
-
86
- if (!shouldShowPostinstallNotice(options)) {
87
- return false;
88
- }
89
-
90
- const config = await findConfigFn();
91
- if (config) {
92
- printPostinstallWelcomeBack(log);
93
- return false;
94
- }
95
-
96
- if (!shouldRunPostinstallOnboarding(options)) {
97
- printPostinstallInstalledNotice(log);
98
- return false;
99
- }
100
-
101
- printPostinstallIntro(log);
102
-
103
- const answer = String(
104
- await withPromptFn((rl) => askFn(rl, "Start guided Clio setup now", "yes"))
105
- )
106
- .trim()
107
- .toLowerCase();
108
-
109
- if (["n", "no", "skip"].includes(answer)) {
110
- log("Skipping setup for now. Run `not-manage setup` when you are ready.");
111
- return false;
112
- }
113
-
114
- await setupWizardFn();
115
- return true;
116
- }
117
-
118
- async function main(options = {}) {
119
- const log = options.log || console.log;
120
- const errorLog = options.errorLog || console.error;
121
-
122
- try {
123
- await maybeRunPostinstallOnboarding(options);
124
- } catch (_error) {
125
- errorLog("Post-install setup was skipped.");
126
- log("Run `not-manage setup` when you are ready.");
127
- }
128
- }
129
-
130
- if (require.main === module) {
131
- main();
132
- }
133
-
134
- module.exports = {
135
- main,
136
- maybeRunPostinstallOnboarding,
137
- printConfidentialityNotice,
138
- shouldShowPostinstallNotice,
139
- shouldRunPostinstallOnboarding,
140
- };