@tolinax/ayoune-cli 2026.2.4 → 2026.3.1
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/package.json +160 -158
- package/data/defaultActions.js +0 -9
- package/data/modelsAndRights.js +0 -3189
- package/data/modules.js +0 -111
- package/data/operations.js +0 -5
- package/data/services.js +0 -139
- package/index.js +0 -11
- package/lib/api/apiCallHandler.js +0 -68
- package/lib/api/apiClient.js +0 -100
- package/lib/api/auditCallHandler.js +0 -21
- package/lib/api/decodeToken.js +0 -4
- package/lib/api/handleAPIError.js +0 -59
- package/lib/api/login.js +0 -45
- package/lib/commands/createActionsCommand.js +0 -109
- package/lib/commands/createAiCommand.js +0 -188
- package/lib/commands/createAliasCommand.js +0 -106
- package/lib/commands/createAuditCommand.js +0 -49
- package/lib/commands/createBatchCommand.js +0 -304
- package/lib/commands/createCompletionsCommand.js +0 -169
- package/lib/commands/createConfigCommand.js +0 -208
- package/lib/commands/createCopyCommand.js +0 -39
- package/lib/commands/createCreateCommand.js +0 -50
- package/lib/commands/createDeleteCommand.js +0 -98
- package/lib/commands/createDeployCommand.js +0 -666
- package/lib/commands/createDescribeCommand.js +0 -42
- package/lib/commands/createEditCommand.js +0 -43
- package/lib/commands/createEventsCommand.js +0 -60
- package/lib/commands/createExecCommand.js +0 -182
- package/lib/commands/createExportCommand.js +0 -219
- package/lib/commands/createGetCommand.js +0 -47
- package/lib/commands/createJobsCommand.js +0 -168
- package/lib/commands/createListCommand.js +0 -49
- package/lib/commands/createLoginCommand.js +0 -18
- package/lib/commands/createLogoutCommand.js +0 -21
- package/lib/commands/createModulesCommand.js +0 -89
- package/lib/commands/createMonitorCommand.js +0 -283
- package/lib/commands/createPermissionsCommand.js +0 -241
- package/lib/commands/createProgram.js +0 -185
- package/lib/commands/createSearchCommand.js +0 -101
- package/lib/commands/createServicesCommand.js +0 -228
- package/lib/commands/createStorageCommand.js +0 -54
- package/lib/commands/createStreamCommand.js +0 -50
- package/lib/commands/createSyncCommand.js +0 -177
- package/lib/commands/createTemplateCommand.js +0 -238
- package/lib/commands/createUpdateCommand.js +0 -115
- package/lib/commands/createUsersCommand.js +0 -285
- package/lib/commands/createWebhooksCommand.js +0 -156
- package/lib/commands/createWhoAmICommand.js +0 -88
- package/lib/exitCodes.js +0 -6
- package/lib/helpers/addSpacesToCamelCase.js +0 -5
- package/lib/helpers/config.js +0 -6
- package/lib/helpers/configLoader.js +0 -60
- package/lib/helpers/formatDocument.js +0 -176
- package/lib/helpers/handleResponseFormatOptions.js +0 -85
- package/lib/helpers/initializeSettings.js +0 -14
- package/lib/helpers/localStorage.js +0 -4
- package/lib/helpers/makeRandomToken.js +0 -27
- package/lib/helpers/parseInt.js +0 -7
- package/lib/helpers/requireArg.js +0 -9
- package/lib/helpers/saveFile.js +0 -39
- package/lib/models/getCollections.js +0 -15
- package/lib/models/getModelsInModules.js +0 -13
- package/lib/models/getModuleFromCollection.js +0 -7
- package/lib/operations/handleAuditOperation.js +0 -22
- package/lib/operations/handleCollectionOperation.js +0 -91
- package/lib/operations/handleCopySingleOperation.js +0 -22
- package/lib/operations/handleCreateSingleOperation.js +0 -35
- package/lib/operations/handleDeleteSingleOperation.js +0 -14
- package/lib/operations/handleDescribeSingleOperation.js +0 -22
- package/lib/operations/handleEditOperation.js +0 -51
- package/lib/operations/handleEditRawOperation.js +0 -35
- package/lib/operations/handleGetOperation.js +0 -29
- package/lib/operations/handleGetSingleOperation.js +0 -20
- package/lib/operations/handleListOperation.js +0 -63
- package/lib/operations/handleSingleAuditOperation.js +0 -27
- package/lib/prompts/promptAudits.js +0 -15
- package/lib/prompts/promptCollection.js +0 -13
- package/lib/prompts/promptCollectionInModule.js +0 -13
- package/lib/prompts/promptCollectionWithModule.js +0 -15
- package/lib/prompts/promptConfirm.js +0 -12
- package/lib/prompts/promptDefaultAction.js +0 -13
- package/lib/prompts/promptEntry.js +0 -19
- package/lib/prompts/promptFileName.js +0 -12
- package/lib/prompts/promptFilePath.js +0 -18
- package/lib/prompts/promptModule.js +0 -19
- package/lib/prompts/promptName.js +0 -11
- package/lib/prompts/promptOperation.js +0 -13
- package/lib/socket/customerSocketClient.js +0 -13
- package/lib/socket/socketClient.js +0 -12
- package/lib/types.js +0 -1
|
@@ -1,168 +0,0 @@
|
|
|
1
|
-
import { apiCallHandler } from "../api/apiCallHandler.js";
|
|
2
|
-
import { handleResponseFormatOptions } from "../helpers/handleResponseFormatOptions.js";
|
|
3
|
-
import { saveFile } from "../helpers/saveFile.js";
|
|
4
|
-
import { spinner } from "../../index.js";
|
|
5
|
-
import { EXIT_GENERAL_ERROR } from "../exitCodes.js";
|
|
6
|
-
export function createJobsCommand(program) {
|
|
7
|
-
const jobs = program
|
|
8
|
-
.command("jobs")
|
|
9
|
-
.alias("j")
|
|
10
|
-
.description("Manage background jobs, automations, and triggers");
|
|
11
|
-
// ay jobs list
|
|
12
|
-
jobs
|
|
13
|
-
.command("list")
|
|
14
|
-
.alias("ls")
|
|
15
|
-
.description("List scheduled/queued jobs")
|
|
16
|
-
.option("--status <status>", "Filter: active, waiting, completed, failed, delayed")
|
|
17
|
-
.option("-l, --limit <number>", "Limit results", parseInt, 50)
|
|
18
|
-
.option("-p, --page <number>", "Page number", parseInt, 1)
|
|
19
|
-
.action(async (options) => {
|
|
20
|
-
var _a, _b, _c;
|
|
21
|
-
try {
|
|
22
|
-
const opts = { ...program.opts(), ...options };
|
|
23
|
-
spinner.start({ text: "Fetching jobs...", color: "magenta" });
|
|
24
|
-
const params = {
|
|
25
|
-
page: opts.page,
|
|
26
|
-
limit: opts.limit,
|
|
27
|
-
responseFormat: opts.responseFormat,
|
|
28
|
-
verbosity: opts.verbosity,
|
|
29
|
-
};
|
|
30
|
-
if (opts.status)
|
|
31
|
-
params.status = opts.status;
|
|
32
|
-
const res = await apiCallHandler("general", "agendajobs", "get", null, params);
|
|
33
|
-
handleResponseFormatOptions(opts, res);
|
|
34
|
-
const total = (_c = (_b = (_a = res.meta) === null || _a === void 0 ? void 0 : _a.pageInfo) === null || _b === void 0 ? void 0 : _b.totalEntries) !== null && _c !== void 0 ? _c : 0;
|
|
35
|
-
spinner.success({ text: `Found ${total} jobs` });
|
|
36
|
-
spinner.stop();
|
|
37
|
-
if (opts.save)
|
|
38
|
-
await saveFile("jobs-list", opts, res);
|
|
39
|
-
}
|
|
40
|
-
catch (e) {
|
|
41
|
-
spinner.error({ text: e.message || "Failed to list jobs" });
|
|
42
|
-
process.exit(EXIT_GENERAL_ERROR);
|
|
43
|
-
}
|
|
44
|
-
});
|
|
45
|
-
// ay jobs triggers
|
|
46
|
-
jobs
|
|
47
|
-
.command("triggers")
|
|
48
|
-
.description("List automation triggers")
|
|
49
|
-
.option("-l, --limit <number>", "Limit results", parseInt, 50)
|
|
50
|
-
.option("-p, --page <number>", "Page number", parseInt, 1)
|
|
51
|
-
.action(async (options) => {
|
|
52
|
-
var _a, _b, _c;
|
|
53
|
-
try {
|
|
54
|
-
const opts = { ...program.opts(), ...options };
|
|
55
|
-
spinner.start({ text: "Fetching triggers...", color: "magenta" });
|
|
56
|
-
const res = await apiCallHandler("automation", "triggers", "get", null, {
|
|
57
|
-
page: opts.page,
|
|
58
|
-
limit: opts.limit,
|
|
59
|
-
responseFormat: opts.responseFormat,
|
|
60
|
-
verbosity: opts.verbosity,
|
|
61
|
-
});
|
|
62
|
-
handleResponseFormatOptions(opts, res);
|
|
63
|
-
const total = (_c = (_b = (_a = res.meta) === null || _a === void 0 ? void 0 : _a.pageInfo) === null || _b === void 0 ? void 0 : _b.totalEntries) !== null && _c !== void 0 ? _c : 0;
|
|
64
|
-
spinner.success({ text: `Found ${total} triggers` });
|
|
65
|
-
spinner.stop();
|
|
66
|
-
if (opts.save)
|
|
67
|
-
await saveFile("jobs-triggers", opts, res);
|
|
68
|
-
}
|
|
69
|
-
catch (e) {
|
|
70
|
-
spinner.error({ text: e.message || "Failed to list triggers" });
|
|
71
|
-
process.exit(EXIT_GENERAL_ERROR);
|
|
72
|
-
}
|
|
73
|
-
});
|
|
74
|
-
// ay jobs automations
|
|
75
|
-
jobs
|
|
76
|
-
.command("automations")
|
|
77
|
-
.alias("auto")
|
|
78
|
-
.description("List automations")
|
|
79
|
-
.option("--active", "Show only active automations")
|
|
80
|
-
.option("-l, --limit <number>", "Limit results", parseInt, 50)
|
|
81
|
-
.option("-p, --page <number>", "Page number", parseInt, 1)
|
|
82
|
-
.action(async (options) => {
|
|
83
|
-
var _a, _b, _c;
|
|
84
|
-
try {
|
|
85
|
-
const opts = { ...program.opts(), ...options };
|
|
86
|
-
spinner.start({ text: "Fetching automations...", color: "magenta" });
|
|
87
|
-
const params = {
|
|
88
|
-
page: opts.page,
|
|
89
|
-
limit: opts.limit,
|
|
90
|
-
responseFormat: opts.responseFormat,
|
|
91
|
-
verbosity: opts.verbosity,
|
|
92
|
-
};
|
|
93
|
-
if (opts.active)
|
|
94
|
-
params.active = "true";
|
|
95
|
-
const res = await apiCallHandler("automation", "automations", "get", null, params);
|
|
96
|
-
handleResponseFormatOptions(opts, res);
|
|
97
|
-
const total = (_c = (_b = (_a = res.meta) === null || _a === void 0 ? void 0 : _a.pageInfo) === null || _b === void 0 ? void 0 : _b.totalEntries) !== null && _c !== void 0 ? _c : 0;
|
|
98
|
-
spinner.success({ text: `Found ${total} automations` });
|
|
99
|
-
spinner.stop();
|
|
100
|
-
if (opts.save)
|
|
101
|
-
await saveFile("jobs-automations", opts, res);
|
|
102
|
-
}
|
|
103
|
-
catch (e) {
|
|
104
|
-
spinner.error({ text: e.message || "Failed to list automations" });
|
|
105
|
-
process.exit(EXIT_GENERAL_ERROR);
|
|
106
|
-
}
|
|
107
|
-
});
|
|
108
|
-
// ay jobs execute <automationId>
|
|
109
|
-
jobs
|
|
110
|
-
.command("execute <automationId>")
|
|
111
|
-
.alias("run")
|
|
112
|
-
.description("Execute an automation immediately")
|
|
113
|
-
.option("--body <json>", "Optional payload as JSON")
|
|
114
|
-
.action(async (automationId, options) => {
|
|
115
|
-
try {
|
|
116
|
-
const opts = { ...program.opts(), ...options };
|
|
117
|
-
spinner.start({ text: `Executing automation ${automationId}...`, color: "magenta" });
|
|
118
|
-
let body = null;
|
|
119
|
-
if (opts.body) {
|
|
120
|
-
try {
|
|
121
|
-
body = JSON.parse(opts.body);
|
|
122
|
-
}
|
|
123
|
-
catch (_a) {
|
|
124
|
-
spinner.error({ text: "Invalid JSON in --body" });
|
|
125
|
-
process.exit(EXIT_GENERAL_ERROR);
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
const res = await apiCallHandler("automation", `automations/${automationId}/execute`, "post", body, { responseFormat: opts.responseFormat });
|
|
129
|
-
handleResponseFormatOptions(opts, res);
|
|
130
|
-
spinner.success({ text: `Automation ${automationId} executed` });
|
|
131
|
-
spinner.stop();
|
|
132
|
-
}
|
|
133
|
-
catch (e) {
|
|
134
|
-
spinner.error({ text: e.message || "Failed to execute automation" });
|
|
135
|
-
process.exit(EXIT_GENERAL_ERROR);
|
|
136
|
-
}
|
|
137
|
-
});
|
|
138
|
-
// ay jobs notifications
|
|
139
|
-
jobs
|
|
140
|
-
.command("notifications")
|
|
141
|
-
.alias("notify")
|
|
142
|
-
.description("List recent notifications")
|
|
143
|
-
.option("-l, --limit <number>", "Limit results", parseInt, 25)
|
|
144
|
-
.option("-p, --page <number>", "Page number", parseInt, 1)
|
|
145
|
-
.action(async (options) => {
|
|
146
|
-
var _a, _b, _c;
|
|
147
|
-
try {
|
|
148
|
-
const opts = { ...program.opts(), ...options };
|
|
149
|
-
spinner.start({ text: "Fetching notifications...", color: "magenta" });
|
|
150
|
-
const res = await apiCallHandler("general", "notifications", "get", null, {
|
|
151
|
-
page: opts.page,
|
|
152
|
-
limit: opts.limit,
|
|
153
|
-
responseFormat: opts.responseFormat,
|
|
154
|
-
verbosity: opts.verbosity,
|
|
155
|
-
});
|
|
156
|
-
handleResponseFormatOptions(opts, res);
|
|
157
|
-
const total = (_c = (_b = (_a = res.meta) === null || _a === void 0 ? void 0 : _a.pageInfo) === null || _b === void 0 ? void 0 : _b.totalEntries) !== null && _c !== void 0 ? _c : 0;
|
|
158
|
-
spinner.success({ text: `Found ${total} notifications` });
|
|
159
|
-
spinner.stop();
|
|
160
|
-
if (opts.save)
|
|
161
|
-
await saveFile("jobs-notifications", opts, res);
|
|
162
|
-
}
|
|
163
|
-
catch (e) {
|
|
164
|
-
spinner.error({ text: e.message || "Failed to list notifications" });
|
|
165
|
-
process.exit(EXIT_GENERAL_ERROR);
|
|
166
|
-
}
|
|
167
|
-
});
|
|
168
|
-
}
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
import { parseInteger } from "../helpers/parseInt.js";
|
|
2
|
-
import { promptCollectionWithModule } from "../prompts/promptCollectionWithModule.js";
|
|
3
|
-
import { getModuleFromCollection } from "../models/getModuleFromCollection.js";
|
|
4
|
-
import { handleListOperation } from "../operations/handleListOperation.js";
|
|
5
|
-
import { saveFile } from "../helpers/saveFile.js";
|
|
6
|
-
import { localStorage } from "../helpers/localStorage.js";
|
|
7
|
-
import { spinner } from "../../index.js";
|
|
8
|
-
import { EXIT_GENERAL_ERROR, EXIT_MISUSE } from "../exitCodes.js";
|
|
9
|
-
export function createListCommand(program) {
|
|
10
|
-
program
|
|
11
|
-
.command("list [collection]")
|
|
12
|
-
.alias("l")
|
|
13
|
-
.description("List entries in a collection with pagination support")
|
|
14
|
-
.addHelpText("after", `
|
|
15
|
-
Examples:
|
|
16
|
-
ay list contacts List contacts (page 1, limit 20)
|
|
17
|
-
ay list products -p 2 -l 50 List products page 2, 50 per page
|
|
18
|
-
ay list orders -r yaml -s List orders as YAML and save to file
|
|
19
|
-
ay list contacts --all Fetch all pages
|
|
20
|
-
ay list contacts --jq '[].name' Extract just names using JMESPath`)
|
|
21
|
-
.option("-p, --page <number>", "Page", parseInteger, 1)
|
|
22
|
-
.option("-l, --limit <number>", "Limit", parseInteger, 20)
|
|
23
|
-
.option("-f, --from <date>", "From date")
|
|
24
|
-
.option("-a, --all", "Fetch all pages automatically")
|
|
25
|
-
.action(async (collection, options) => {
|
|
26
|
-
try {
|
|
27
|
-
const opts = { ...program.opts(), ...options };
|
|
28
|
-
if (!collection) {
|
|
29
|
-
if (!process.stdin.isTTY) {
|
|
30
|
-
spinner.error({ text: "Missing required argument: collection" });
|
|
31
|
-
process.exit(EXIT_MISUSE);
|
|
32
|
-
}
|
|
33
|
-
collection = await promptCollectionWithModule();
|
|
34
|
-
}
|
|
35
|
-
const module = getModuleFromCollection(collection);
|
|
36
|
-
localStorage.setItem("lastModule", module.module);
|
|
37
|
-
localStorage.setItem("lastCollection", collection);
|
|
38
|
-
let result = {};
|
|
39
|
-
result = await handleListOperation(module.module, collection, opts);
|
|
40
|
-
if (opts.save) {
|
|
41
|
-
await saveFile("list", opts, result);
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
catch (e) {
|
|
45
|
-
spinner.error({ text: e.message || "An unexpected error occurred" });
|
|
46
|
-
process.exit(EXIT_GENERAL_ERROR);
|
|
47
|
-
}
|
|
48
|
-
});
|
|
49
|
-
}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { login } from "../api/login.js";
|
|
2
|
-
import { spinner } from "../../index.js";
|
|
3
|
-
import { EXIT_AUTH_REQUIRED } from "../exitCodes.js";
|
|
4
|
-
export function createLoginCommand(program) {
|
|
5
|
-
program
|
|
6
|
-
.command("login")
|
|
7
|
-
.alias("auth")
|
|
8
|
-
.description("Authenticate with your aYOUne account via browser")
|
|
9
|
-
.action(async () => {
|
|
10
|
-
try {
|
|
11
|
-
await login();
|
|
12
|
-
}
|
|
13
|
-
catch (e) {
|
|
14
|
-
spinner.error({ text: e.message || "An unexpected error occurred" });
|
|
15
|
-
process.exit(EXIT_AUTH_REQUIRED);
|
|
16
|
-
}
|
|
17
|
-
});
|
|
18
|
-
}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { localStorage } from "../helpers/localStorage.js";
|
|
2
|
-
import { spinner } from "../../index.js";
|
|
3
|
-
import { EXIT_GENERAL_ERROR } from "../exitCodes.js";
|
|
4
|
-
export function createLogoutCommand(program) {
|
|
5
|
-
program
|
|
6
|
-
.command("logout")
|
|
7
|
-
.alias("signout")
|
|
8
|
-
.description("Clear stored credentials and log out")
|
|
9
|
-
.action(async (options) => {
|
|
10
|
-
try {
|
|
11
|
-
spinner.start({ text: "Clearing credentials" });
|
|
12
|
-
localStorage.removeItem("token");
|
|
13
|
-
localStorage.removeItem("refreshToken");
|
|
14
|
-
spinner.success({ text: "Credentials cleared" });
|
|
15
|
-
}
|
|
16
|
-
catch (e) {
|
|
17
|
-
spinner.error({ text: e.message || "An unexpected error occurred" });
|
|
18
|
-
process.exit(EXIT_GENERAL_ERROR);
|
|
19
|
-
}
|
|
20
|
-
});
|
|
21
|
-
}
|
|
@@ -1,89 +0,0 @@
|
|
|
1
|
-
import { promptModule } from "../prompts/promptModule.js";
|
|
2
|
-
import { promptCollectionInModule } from "../prompts/promptCollectionInModule.js";
|
|
3
|
-
import { promptOperation } from "../prompts/promptOperation.js";
|
|
4
|
-
import { handleListOperation } from "../operations/handleListOperation.js";
|
|
5
|
-
import { promptEntry } from "../prompts/promptEntry.js";
|
|
6
|
-
import { handleCollectionOperation } from "../operations/handleCollectionOperation.js";
|
|
7
|
-
import { localStorage } from "../helpers/localStorage.js";
|
|
8
|
-
import { parseInteger } from "../helpers/parseInt.js";
|
|
9
|
-
import { handleGetOperation } from "../operations/handleGetOperation.js";
|
|
10
|
-
import { aYOUneModules } from "../../data/modules.js";
|
|
11
|
-
import { getModelsInModules } from "../models/getModelsInModules.js";
|
|
12
|
-
import { spinner } from "../../index.js";
|
|
13
|
-
import { EXIT_GENERAL_ERROR, EXIT_MISUSE } from "../exitCodes.js";
|
|
14
|
-
function resolveModule(input) {
|
|
15
|
-
const lower = input.toLowerCase();
|
|
16
|
-
const match = aYOUneModules.find((m) => m.module === lower || m.label.toLowerCase() === lower);
|
|
17
|
-
return match ? match.module : null;
|
|
18
|
-
}
|
|
19
|
-
function resolveCollection(module, input) {
|
|
20
|
-
const lower = input.toLowerCase();
|
|
21
|
-
const collections = getModelsInModules(module);
|
|
22
|
-
const match = collections.find((c) => c.value === lower || c.name.toLowerCase() === lower);
|
|
23
|
-
return match ? match.value : null;
|
|
24
|
-
}
|
|
25
|
-
export function createModulesCommand(program) {
|
|
26
|
-
program
|
|
27
|
-
.command("modules [module] [collection]")
|
|
28
|
-
.alias("m")
|
|
29
|
-
.description("Browse modules, collections, and entries interactively")
|
|
30
|
-
.addHelpText("after", `
|
|
31
|
-
Examples:
|
|
32
|
-
ay modules Start interactive module browser
|
|
33
|
-
ay m Same using alias
|
|
34
|
-
ay m crm Jump straight to the CRM module
|
|
35
|
-
ay m crm consumers Jump to CRM consumers collection`)
|
|
36
|
-
.option("-p, --page <number>", "Page", parseInteger, 1)
|
|
37
|
-
.option("-l, --limit <number>", "Limit", parseInteger, 20)
|
|
38
|
-
.option("-f, --from <date>", "From date")
|
|
39
|
-
.action(async (moduleArg, collectionArg, options) => {
|
|
40
|
-
try {
|
|
41
|
-
const opts = { ...program.opts(), ...options };
|
|
42
|
-
if (!process.stdin.isTTY) {
|
|
43
|
-
spinner.error({ text: "The modules command requires an interactive terminal" });
|
|
44
|
-
process.exit(EXIT_MISUSE);
|
|
45
|
-
}
|
|
46
|
-
let module;
|
|
47
|
-
if (moduleArg) {
|
|
48
|
-
const resolved = resolveModule(moduleArg);
|
|
49
|
-
if (!resolved) {
|
|
50
|
-
spinner.error({ text: `Unknown module: ${moduleArg}` });
|
|
51
|
-
process.exit(EXIT_MISUSE);
|
|
52
|
-
}
|
|
53
|
-
module = resolved;
|
|
54
|
-
}
|
|
55
|
-
else {
|
|
56
|
-
module = await promptModule();
|
|
57
|
-
}
|
|
58
|
-
let collection;
|
|
59
|
-
if (collectionArg) {
|
|
60
|
-
const resolved = resolveCollection(module, collectionArg);
|
|
61
|
-
if (!resolved) {
|
|
62
|
-
spinner.error({ text: `Unknown collection: ${collectionArg} in module ${module}` });
|
|
63
|
-
process.exit(EXIT_MISUSE);
|
|
64
|
-
}
|
|
65
|
-
collection = resolved;
|
|
66
|
-
}
|
|
67
|
-
else {
|
|
68
|
-
collection = await promptCollectionInModule(module);
|
|
69
|
-
}
|
|
70
|
-
const operation = await promptOperation();
|
|
71
|
-
localStorage.setItem("lastModule", module);
|
|
72
|
-
localStorage.setItem("lastCollection", collection);
|
|
73
|
-
let entry = "";
|
|
74
|
-
if (operation === "list") {
|
|
75
|
-
const { result } = await handleListOperation(module, collection, opts);
|
|
76
|
-
entry = await promptEntry(result);
|
|
77
|
-
}
|
|
78
|
-
if (operation === "get") {
|
|
79
|
-
const { result } = await handleGetOperation(module, collection, opts);
|
|
80
|
-
entry = await promptEntry(result);
|
|
81
|
-
}
|
|
82
|
-
await handleCollectionOperation(module, collection, entry, opts);
|
|
83
|
-
}
|
|
84
|
-
catch (e) {
|
|
85
|
-
spinner.error({ text: e.message || "An unexpected error occurred" });
|
|
86
|
-
process.exit(EXIT_GENERAL_ERROR);
|
|
87
|
-
}
|
|
88
|
-
});
|
|
89
|
-
}
|
|
@@ -1,283 +0,0 @@
|
|
|
1
|
-
import { apiCallHandler } from "../api/apiCallHandler.js";
|
|
2
|
-
import { handleResponseFormatOptions } from "../helpers/handleResponseFormatOptions.js";
|
|
3
|
-
import { saveFile } from "../helpers/saveFile.js";
|
|
4
|
-
import { spinner } from "../../index.js";
|
|
5
|
-
import { EXIT_GENERAL_ERROR } from "../exitCodes.js";
|
|
6
|
-
export function createMonitorCommand(program) {
|
|
7
|
-
const monitor = program
|
|
8
|
-
.command("monitor")
|
|
9
|
-
.alias("mon")
|
|
10
|
-
.description("Monitor platform activity, logs, and alerts");
|
|
11
|
-
// ay monitor logs [type]
|
|
12
|
-
monitor
|
|
13
|
-
.command("logs [type]")
|
|
14
|
-
.description("List recent platform logs (api, error, mail, ai, trigger, ...)")
|
|
15
|
-
.addHelpText("after", `
|
|
16
|
-
Log types: api, error, mail, ai, trigger, doi, export, sms, whatsapp, production, setup, state, shop, score, sensor, stock, soi, reward, merge, download, post, webreceiver, work, computingentitieslogs, consumerapi, accessterminal, googleads
|
|
17
|
-
|
|
18
|
-
Examples:
|
|
19
|
-
ay monitor logs error List recent error logs
|
|
20
|
-
ay monitor logs api -l 10 List last 10 API logs
|
|
21
|
-
ay monitor logs ai -r table List AI logs in table format`)
|
|
22
|
-
.option("-l, --limit <number>", "Limit results", parseInt, 25)
|
|
23
|
-
.option("-p, --page <number>", "Page number", parseInt, 1)
|
|
24
|
-
.option("--sort <field>", "Sort by field", "-createdAt")
|
|
25
|
-
.action(async (type, options) => {
|
|
26
|
-
var _a, _b, _c;
|
|
27
|
-
try {
|
|
28
|
-
const opts = { ...program.opts(), ...options };
|
|
29
|
-
const logType = type || "api";
|
|
30
|
-
const collectionMap = {
|
|
31
|
-
api: "apilogs",
|
|
32
|
-
error: "errorlogs",
|
|
33
|
-
mail: "maillogs",
|
|
34
|
-
ai: "ailogs",
|
|
35
|
-
trigger: "triggerlogs",
|
|
36
|
-
doi: "doilogs",
|
|
37
|
-
export: "exportlogs",
|
|
38
|
-
sms: "smslogs",
|
|
39
|
-
whatsapp: "whatsapplogs",
|
|
40
|
-
production: "productionlogs",
|
|
41
|
-
setup: "setuplogs",
|
|
42
|
-
state: "statelogs",
|
|
43
|
-
shop: "shoplogs",
|
|
44
|
-
score: "scorelogs",
|
|
45
|
-
sensor: "sensorlogs",
|
|
46
|
-
stock: "stocklogs",
|
|
47
|
-
soi: "soilogs",
|
|
48
|
-
reward: "rewardlogs",
|
|
49
|
-
merge: "mergelogs",
|
|
50
|
-
download: "downloadlogs",
|
|
51
|
-
post: "postlogs",
|
|
52
|
-
webreceiver: "webreceiverlogs",
|
|
53
|
-
work: "worklogs",
|
|
54
|
-
consumerapi: "consumerapilogs",
|
|
55
|
-
accessterminal: "accessterminallogs",
|
|
56
|
-
googleads: "adwordslogs",
|
|
57
|
-
computing: "computingentitieslogs",
|
|
58
|
-
};
|
|
59
|
-
const collection = collectionMap[logType] || `${logType}logs`;
|
|
60
|
-
spinner.start({ text: `Fetching ${logType} logs...`, color: "magenta" });
|
|
61
|
-
const res = await apiCallHandler("logs", collection, "get", null, {
|
|
62
|
-
page: opts.page,
|
|
63
|
-
limit: opts.limit,
|
|
64
|
-
sort: opts.sort,
|
|
65
|
-
responseFormat: opts.responseFormat,
|
|
66
|
-
verbosity: opts.verbosity,
|
|
67
|
-
hideMeta: opts.hideMeta,
|
|
68
|
-
});
|
|
69
|
-
handleResponseFormatOptions(opts, res);
|
|
70
|
-
const total = (_c = (_b = (_a = res.meta) === null || _a === void 0 ? void 0 : _a.pageInfo) === null || _b === void 0 ? void 0 : _b.totalEntries) !== null && _c !== void 0 ? _c : 0;
|
|
71
|
-
spinner.success({ text: `Found ${total} ${logType} log entries` });
|
|
72
|
-
spinner.stop();
|
|
73
|
-
if (opts.save)
|
|
74
|
-
await saveFile(`monitor-logs-${logType}`, opts, res);
|
|
75
|
-
}
|
|
76
|
-
catch (e) {
|
|
77
|
-
spinner.error({ text: e.message || "Failed to fetch logs" });
|
|
78
|
-
process.exit(EXIT_GENERAL_ERROR);
|
|
79
|
-
}
|
|
80
|
-
});
|
|
81
|
-
// ay monitor alerts — command group
|
|
82
|
-
const alerts = monitor
|
|
83
|
-
.command("alerts")
|
|
84
|
-
.description("Manage platform alerts (list, acknowledge, resolve)");
|
|
85
|
-
// ay monitor alerts list
|
|
86
|
-
alerts
|
|
87
|
-
.command("list")
|
|
88
|
-
.alias("ls")
|
|
89
|
-
.description("List active alerts")
|
|
90
|
-
.addHelpText("after", `
|
|
91
|
-
Examples:
|
|
92
|
-
ay monitor alerts list List all active alerts
|
|
93
|
-
ay monitor alerts list --severity critical Show critical alerts only
|
|
94
|
-
ay monitor alerts list --type pod_crash Filter by alert type
|
|
95
|
-
ay monitor alerts list --status acknowledged Show acknowledged alerts`)
|
|
96
|
-
.option("-l, --limit <number>", "Limit results", parseInt, 50)
|
|
97
|
-
.option("-p, --page <number>", "Page number", parseInt, 1)
|
|
98
|
-
.option("--severity <level>", "Filter: info, warning, critical")
|
|
99
|
-
.option("--type <type>", "Filter: pod_crash, oom_killed, image_pull_error, deployment_failed, pipeline_failed, cluster_unreachable, high_restart_count, custom")
|
|
100
|
-
.option("--status <status>", "Filter: active, acknowledged, resolved", "active")
|
|
101
|
-
.action(async (options) => {
|
|
102
|
-
var _a, _b, _c;
|
|
103
|
-
try {
|
|
104
|
-
const opts = { ...program.opts(), ...options };
|
|
105
|
-
spinner.start({ text: "Fetching alerts...", color: "magenta" });
|
|
106
|
-
const params = {
|
|
107
|
-
page: opts.page,
|
|
108
|
-
limit: opts.limit,
|
|
109
|
-
responseFormat: opts.responseFormat,
|
|
110
|
-
verbosity: opts.verbosity,
|
|
111
|
-
hideMeta: opts.hideMeta,
|
|
112
|
-
};
|
|
113
|
-
if (opts.severity)
|
|
114
|
-
params.severity = opts.severity;
|
|
115
|
-
if (opts.type)
|
|
116
|
-
params.type = opts.type;
|
|
117
|
-
if (opts.status)
|
|
118
|
-
params.status = opts.status;
|
|
119
|
-
const res = await apiCallHandler("devops", "alerts", "get", null, params);
|
|
120
|
-
handleResponseFormatOptions(opts, res);
|
|
121
|
-
const total = (_c = (_b = (_a = res.meta) === null || _a === void 0 ? void 0 : _a.pageInfo) === null || _b === void 0 ? void 0 : _b.totalEntries) !== null && _c !== void 0 ? _c : 0;
|
|
122
|
-
spinner.success({ text: `Found ${total} alerts` });
|
|
123
|
-
spinner.stop();
|
|
124
|
-
if (opts.save)
|
|
125
|
-
await saveFile("monitor-alerts", opts, res);
|
|
126
|
-
}
|
|
127
|
-
catch (e) {
|
|
128
|
-
spinner.error({ text: e.message || "Failed to fetch alerts" });
|
|
129
|
-
process.exit(EXIT_GENERAL_ERROR);
|
|
130
|
-
}
|
|
131
|
-
});
|
|
132
|
-
// ay monitor alerts ack <id>
|
|
133
|
-
alerts
|
|
134
|
-
.command("ack <id>")
|
|
135
|
-
.alias("acknowledge")
|
|
136
|
-
.description("Acknowledge an alert")
|
|
137
|
-
.action(async (id, options) => {
|
|
138
|
-
try {
|
|
139
|
-
const opts = { ...program.opts(), ...options };
|
|
140
|
-
spinner.start({ text: `Acknowledging alert ${id}...`, color: "magenta" });
|
|
141
|
-
const res = await apiCallHandler("devops", `alerts/${id}/acknowledge`, "put", null, {
|
|
142
|
-
responseFormat: opts.responseFormat,
|
|
143
|
-
});
|
|
144
|
-
handleResponseFormatOptions(opts, res);
|
|
145
|
-
spinner.success({ text: `Alert ${id} acknowledged` });
|
|
146
|
-
spinner.stop();
|
|
147
|
-
}
|
|
148
|
-
catch (e) {
|
|
149
|
-
spinner.error({ text: e.message || "Failed to acknowledge alert" });
|
|
150
|
-
process.exit(EXIT_GENERAL_ERROR);
|
|
151
|
-
}
|
|
152
|
-
});
|
|
153
|
-
// ay monitor alerts resolve <id>
|
|
154
|
-
alerts
|
|
155
|
-
.command("resolve <id>")
|
|
156
|
-
.description("Resolve an alert")
|
|
157
|
-
.action(async (id, options) => {
|
|
158
|
-
try {
|
|
159
|
-
const opts = { ...program.opts(), ...options };
|
|
160
|
-
spinner.start({ text: `Resolving alert ${id}...`, color: "magenta" });
|
|
161
|
-
const res = await apiCallHandler("devops", `alerts/${id}/resolve`, "put", null, {
|
|
162
|
-
responseFormat: opts.responseFormat,
|
|
163
|
-
});
|
|
164
|
-
handleResponseFormatOptions(opts, res);
|
|
165
|
-
spinner.success({ text: `Alert ${id} resolved` });
|
|
166
|
-
spinner.stop();
|
|
167
|
-
}
|
|
168
|
-
catch (e) {
|
|
169
|
-
spinner.error({ text: e.message || "Failed to resolve alert" });
|
|
170
|
-
process.exit(EXIT_GENERAL_ERROR);
|
|
171
|
-
}
|
|
172
|
-
});
|
|
173
|
-
// ay monitor sessions
|
|
174
|
-
monitor
|
|
175
|
-
.command("sessions")
|
|
176
|
-
.description("List active user sessions")
|
|
177
|
-
.option("-l, --limit <number>", "Limit results", parseInt, 50)
|
|
178
|
-
.action(async (options) => {
|
|
179
|
-
var _a, _b, _c;
|
|
180
|
-
try {
|
|
181
|
-
const opts = { ...program.opts(), ...options };
|
|
182
|
-
spinner.start({ text: "Fetching active sessions...", color: "magenta" });
|
|
183
|
-
const res = await apiCallHandler("monitoring", "sessions", "get", null, {
|
|
184
|
-
limit: opts.limit,
|
|
185
|
-
responseFormat: opts.responseFormat,
|
|
186
|
-
verbosity: opts.verbosity,
|
|
187
|
-
});
|
|
188
|
-
handleResponseFormatOptions(opts, res);
|
|
189
|
-
const total = (_c = (_b = (_a = res.meta) === null || _a === void 0 ? void 0 : _a.pageInfo) === null || _b === void 0 ? void 0 : _b.totalEntries) !== null && _c !== void 0 ? _c : 0;
|
|
190
|
-
spinner.success({ text: `Found ${total} active sessions` });
|
|
191
|
-
spinner.stop();
|
|
192
|
-
if (opts.save)
|
|
193
|
-
await saveFile("monitor-sessions", opts, res);
|
|
194
|
-
}
|
|
195
|
-
catch (e) {
|
|
196
|
-
spinner.error({ text: e.message || "Failed to fetch sessions" });
|
|
197
|
-
process.exit(EXIT_GENERAL_ERROR);
|
|
198
|
-
}
|
|
199
|
-
});
|
|
200
|
-
// ay monitor checks
|
|
201
|
-
monitor
|
|
202
|
-
.command("checks")
|
|
203
|
-
.description("List monitoring checks and their results")
|
|
204
|
-
.option("-l, --limit <number>", "Limit results", parseInt, 50)
|
|
205
|
-
.action(async (options) => {
|
|
206
|
-
var _a, _b, _c;
|
|
207
|
-
try {
|
|
208
|
-
const opts = { ...program.opts(), ...options };
|
|
209
|
-
spinner.start({ text: "Fetching monitoring checks...", color: "magenta" });
|
|
210
|
-
const res = await apiCallHandler("monitoring", "checks", "get", null, {
|
|
211
|
-
limit: opts.limit,
|
|
212
|
-
responseFormat: opts.responseFormat,
|
|
213
|
-
verbosity: opts.verbosity,
|
|
214
|
-
});
|
|
215
|
-
handleResponseFormatOptions(opts, res);
|
|
216
|
-
const total = (_c = (_b = (_a = res.meta) === null || _a === void 0 ? void 0 : _a.pageInfo) === null || _b === void 0 ? void 0 : _b.totalEntries) !== null && _c !== void 0 ? _c : 0;
|
|
217
|
-
spinner.success({ text: `Found ${total} monitoring checks` });
|
|
218
|
-
spinner.stop();
|
|
219
|
-
if (opts.save)
|
|
220
|
-
await saveFile("monitor-checks", opts, res);
|
|
221
|
-
}
|
|
222
|
-
catch (e) {
|
|
223
|
-
spinner.error({ text: e.message || "Failed to fetch checks" });
|
|
224
|
-
process.exit(EXIT_GENERAL_ERROR);
|
|
225
|
-
}
|
|
226
|
-
});
|
|
227
|
-
// ay monitor activeusers
|
|
228
|
-
monitor
|
|
229
|
-
.command("activeusers")
|
|
230
|
-
.alias("users")
|
|
231
|
-
.description("Show currently active users on the platform")
|
|
232
|
-
.option("-l, --limit <number>", "Limit results", parseInt, 50)
|
|
233
|
-
.action(async (options) => {
|
|
234
|
-
var _a, _b, _c;
|
|
235
|
-
try {
|
|
236
|
-
const opts = { ...program.opts(), ...options };
|
|
237
|
-
spinner.start({ text: "Fetching active users...", color: "magenta" });
|
|
238
|
-
const res = await apiCallHandler("monitoring", "activeusers", "get", null, {
|
|
239
|
-
limit: opts.limit,
|
|
240
|
-
responseFormat: opts.responseFormat,
|
|
241
|
-
verbosity: opts.verbosity,
|
|
242
|
-
});
|
|
243
|
-
handleResponseFormatOptions(opts, res);
|
|
244
|
-
const total = (_c = (_b = (_a = res.meta) === null || _a === void 0 ? void 0 : _a.pageInfo) === null || _b === void 0 ? void 0 : _b.totalEntries) !== null && _c !== void 0 ? _c : 0;
|
|
245
|
-
spinner.success({ text: `${total} active users` });
|
|
246
|
-
spinner.stop();
|
|
247
|
-
if (opts.save)
|
|
248
|
-
await saveFile("monitor-activeusers", opts, res);
|
|
249
|
-
}
|
|
250
|
-
catch (e) {
|
|
251
|
-
spinner.error({ text: e.message || "Failed to fetch active users" });
|
|
252
|
-
process.exit(EXIT_GENERAL_ERROR);
|
|
253
|
-
}
|
|
254
|
-
});
|
|
255
|
-
// ay monitor pagestats
|
|
256
|
-
monitor
|
|
257
|
-
.command("pagestats")
|
|
258
|
-
.alias("pages")
|
|
259
|
-
.description("View page view statistics")
|
|
260
|
-
.option("-l, --limit <number>", "Limit results", parseInt, 50)
|
|
261
|
-
.action(async (options) => {
|
|
262
|
-
var _a, _b, _c;
|
|
263
|
-
try {
|
|
264
|
-
const opts = { ...program.opts(), ...options };
|
|
265
|
-
spinner.start({ text: "Fetching page statistics...", color: "magenta" });
|
|
266
|
-
const res = await apiCallHandler("monitoring", "pagestats", "get", null, {
|
|
267
|
-
limit: opts.limit,
|
|
268
|
-
responseFormat: opts.responseFormat,
|
|
269
|
-
verbosity: opts.verbosity,
|
|
270
|
-
});
|
|
271
|
-
handleResponseFormatOptions(opts, res);
|
|
272
|
-
const total = (_c = (_b = (_a = res.meta) === null || _a === void 0 ? void 0 : _a.pageInfo) === null || _b === void 0 ? void 0 : _b.totalEntries) !== null && _c !== void 0 ? _c : 0;
|
|
273
|
-
spinner.success({ text: `Found ${total} page stat entries` });
|
|
274
|
-
spinner.stop();
|
|
275
|
-
if (opts.save)
|
|
276
|
-
await saveFile("monitor-pagestats", opts, res);
|
|
277
|
-
}
|
|
278
|
-
catch (e) {
|
|
279
|
-
spinner.error({ text: e.message || "Failed to fetch page stats" });
|
|
280
|
-
process.exit(EXIT_GENERAL_ERROR);
|
|
281
|
-
}
|
|
282
|
-
});
|
|
283
|
-
}
|