@tolinax/ayoune-cli 2026.2.1 → 2026.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.
- package/data/defaultActions.js +9 -0
- package/data/modelsAndRights.js +3189 -0
- package/data/modules.js +111 -0
- package/data/operations.js +5 -0
- package/data/services.js +139 -0
- package/lib/api/apiCallHandler.js +68 -0
- package/lib/api/apiClient.js +100 -0
- package/lib/api/auditCallHandler.js +21 -0
- package/lib/api/decodeToken.js +4 -0
- package/lib/api/handleAPIError.js +59 -0
- package/lib/api/login.js +45 -0
- package/lib/commands/createActionsCommand.js +109 -0
- package/lib/commands/createAiCommand.js +188 -0
- package/lib/commands/createAliasCommand.js +106 -0
- package/lib/commands/createAuditCommand.js +49 -0
- package/lib/commands/createCompletionsCommand.js +136 -0
- package/lib/commands/createConfigCommand.js +208 -0
- package/lib/commands/createCopyCommand.js +39 -0
- package/lib/commands/createCreateCommand.js +50 -0
- package/lib/commands/createDeployCommand.js +666 -0
- package/lib/commands/createDescribeCommand.js +42 -0
- package/lib/commands/createEditCommand.js +43 -0
- package/lib/commands/createEventsCommand.js +60 -0
- package/lib/commands/createExecCommand.js +182 -0
- package/lib/commands/createGetCommand.js +47 -0
- package/lib/commands/createListCommand.js +49 -0
- package/lib/commands/createLoginCommand.js +18 -0
- package/lib/commands/createLogoutCommand.js +21 -0
- package/lib/commands/createModulesCommand.js +89 -0
- package/lib/commands/createMonitorCommand.js +283 -0
- package/lib/commands/createProgram.js +163 -0
- package/lib/commands/createServicesCommand.js +228 -0
- package/lib/commands/createStorageCommand.js +54 -0
- package/lib/commands/createStreamCommand.js +50 -0
- package/lib/commands/createWhoAmICommand.js +88 -0
- package/lib/exitCodes.js +6 -0
- package/lib/helpers/addSpacesToCamelCase.js +5 -0
- package/lib/helpers/config.js +6 -0
- package/lib/helpers/configLoader.js +60 -0
- package/lib/helpers/formatDocument.js +176 -0
- package/lib/helpers/handleResponseFormatOptions.js +85 -0
- package/lib/helpers/initializeSettings.js +14 -0
- package/lib/helpers/localStorage.js +4 -0
- package/lib/helpers/makeRandomToken.js +27 -0
- package/lib/helpers/parseInt.js +7 -0
- package/lib/helpers/requireArg.js +9 -0
- package/lib/helpers/saveFile.js +39 -0
- package/lib/models/getCollections.js +15 -0
- package/lib/models/getModelsInModules.js +13 -0
- package/lib/models/getModuleFromCollection.js +7 -0
- package/lib/operations/handleAuditOperation.js +22 -0
- package/lib/operations/handleCollectionOperation.js +91 -0
- package/lib/operations/handleCopySingleOperation.js +22 -0
- package/lib/operations/handleCreateSingleOperation.js +35 -0
- package/lib/operations/handleDeleteSingleOperation.js +14 -0
- package/lib/operations/handleDescribeSingleOperation.js +22 -0
- package/lib/operations/handleEditOperation.js +51 -0
- package/lib/operations/handleEditRawOperation.js +35 -0
- package/lib/operations/handleGetOperation.js +29 -0
- package/lib/operations/handleGetSingleOperation.js +20 -0
- package/lib/operations/handleListOperation.js +63 -0
- package/lib/operations/handleSingleAuditOperation.js +27 -0
- package/lib/prompts/promptAudits.js +15 -0
- package/lib/prompts/promptCollection.js +13 -0
- package/lib/prompts/promptCollectionInModule.js +13 -0
- package/lib/prompts/promptCollectionWithModule.js +15 -0
- package/lib/prompts/promptConfirm.js +12 -0
- package/lib/prompts/promptDefaultAction.js +13 -0
- package/lib/prompts/promptEntry.js +19 -0
- package/lib/prompts/promptFileName.js +12 -0
- package/lib/prompts/promptFilePath.js +18 -0
- package/lib/prompts/promptModule.js +19 -0
- package/lib/prompts/promptName.js +11 -0
- package/lib/prompts/promptOperation.js +13 -0
- package/lib/socket/customerSocketClient.js +13 -0
- package/lib/socket/socketClient.js +12 -0
- package/lib/types.js +1 -0
- package/package.json +2 -2
|
@@ -0,0 +1,208 @@
|
|
|
1
|
+
import chalk from "chalk";
|
|
2
|
+
import inquirer from "inquirer";
|
|
3
|
+
import { loadConfig, saveConfig } from "../helpers/configLoader.js";
|
|
4
|
+
import { EXIT_GENERAL_ERROR, EXIT_MISUSE } from "../exitCodes.js";
|
|
5
|
+
import { spinner } from "../../index.js";
|
|
6
|
+
const SETTABLE_KEYS = {
|
|
7
|
+
responseFormat: { type: "string", choices: ["json", "csv", "yaml", "table"] },
|
|
8
|
+
verbosity: { type: "string", choices: ["default", "extended", "minimal"] },
|
|
9
|
+
outPath: { type: "string" },
|
|
10
|
+
hideMeta: { type: "boolean" },
|
|
11
|
+
quiet: { type: "boolean" },
|
|
12
|
+
force: { type: "boolean" },
|
|
13
|
+
dryRun: { type: "boolean" },
|
|
14
|
+
};
|
|
15
|
+
function parseBoolean(value) {
|
|
16
|
+
const truthy = ["true", "1", "yes", "on"];
|
|
17
|
+
const falsy = ["false", "0", "no", "off"];
|
|
18
|
+
if (truthy.includes(value.toLowerCase()))
|
|
19
|
+
return true;
|
|
20
|
+
if (falsy.includes(value.toLowerCase()))
|
|
21
|
+
return false;
|
|
22
|
+
return null;
|
|
23
|
+
}
|
|
24
|
+
function displayDefaults(defaults) {
|
|
25
|
+
const entries = Object.entries(SETTABLE_KEYS);
|
|
26
|
+
const maxLabel = Math.max(...entries.map(([k]) => k.length));
|
|
27
|
+
console.log();
|
|
28
|
+
console.log(chalk.bold(" Default Options"));
|
|
29
|
+
console.log(chalk.dim(` ${"─".repeat(44)}`));
|
|
30
|
+
for (const [key] of entries) {
|
|
31
|
+
const value = defaults[key];
|
|
32
|
+
const display = value !== undefined && value !== null ? String(value) : chalk.dim("(not set)");
|
|
33
|
+
console.log(` ${chalk.dim(key.padEnd(maxLabel + 2))} ${chalk.white(display)}`);
|
|
34
|
+
}
|
|
35
|
+
console.log();
|
|
36
|
+
}
|
|
37
|
+
export function createConfigCommand(program) {
|
|
38
|
+
const config = program
|
|
39
|
+
.command("config")
|
|
40
|
+
.description("Manage default CLI options")
|
|
41
|
+
.addHelpText("after", `
|
|
42
|
+
Examples:
|
|
43
|
+
ay config Interactive defaults menu
|
|
44
|
+
ay config set responseFormat yaml Set default response format
|
|
45
|
+
ay config get responseFormat Show current response format default
|
|
46
|
+
ay config list Show all defaults
|
|
47
|
+
ay config reset Clear all defaults`)
|
|
48
|
+
.action(async () => {
|
|
49
|
+
var _a, _b, _c, _d, _e;
|
|
50
|
+
try {
|
|
51
|
+
const cfg = loadConfig();
|
|
52
|
+
const defaults = (_a = cfg.defaults) !== null && _a !== void 0 ? _a : {};
|
|
53
|
+
const answers = await inquirer.prompt([
|
|
54
|
+
{
|
|
55
|
+
type: "list",
|
|
56
|
+
name: "responseFormat",
|
|
57
|
+
message: "Default response format",
|
|
58
|
+
choices: ["json", "csv", "yaml", "table"],
|
|
59
|
+
default: defaults.responseFormat || "json",
|
|
60
|
+
},
|
|
61
|
+
{
|
|
62
|
+
type: "list",
|
|
63
|
+
name: "verbosity",
|
|
64
|
+
message: "Default verbosity level",
|
|
65
|
+
choices: ["default", "extended", "minimal"],
|
|
66
|
+
default: defaults.verbosity || "default",
|
|
67
|
+
},
|
|
68
|
+
{
|
|
69
|
+
type: "confirm",
|
|
70
|
+
name: "hideMeta",
|
|
71
|
+
message: "Hide meta information by default?",
|
|
72
|
+
default: (_b = defaults.hideMeta) !== null && _b !== void 0 ? _b : false,
|
|
73
|
+
},
|
|
74
|
+
{
|
|
75
|
+
type: "confirm",
|
|
76
|
+
name: "quiet",
|
|
77
|
+
message: "Quiet mode by default?",
|
|
78
|
+
default: (_c = defaults.quiet) !== null && _c !== void 0 ? _c : false,
|
|
79
|
+
},
|
|
80
|
+
{
|
|
81
|
+
type: "confirm",
|
|
82
|
+
name: "force",
|
|
83
|
+
message: "Skip confirmation prompts by default?",
|
|
84
|
+
default: (_d = defaults.force) !== null && _d !== void 0 ? _d : false,
|
|
85
|
+
},
|
|
86
|
+
{
|
|
87
|
+
type: "confirm",
|
|
88
|
+
name: "dryRun",
|
|
89
|
+
message: "Dry-run mode by default?",
|
|
90
|
+
default: (_e = defaults.dryRun) !== null && _e !== void 0 ? _e : false,
|
|
91
|
+
},
|
|
92
|
+
{
|
|
93
|
+
type: "input",
|
|
94
|
+
name: "outPath",
|
|
95
|
+
message: "Default output path (leave blank to keep current)",
|
|
96
|
+
default: defaults.outPath || "",
|
|
97
|
+
},
|
|
98
|
+
]);
|
|
99
|
+
const newDefaults = {
|
|
100
|
+
responseFormat: answers.responseFormat,
|
|
101
|
+
verbosity: answers.verbosity,
|
|
102
|
+
hideMeta: answers.hideMeta,
|
|
103
|
+
quiet: answers.quiet,
|
|
104
|
+
force: answers.force,
|
|
105
|
+
dryRun: answers.dryRun,
|
|
106
|
+
};
|
|
107
|
+
if (answers.outPath) {
|
|
108
|
+
newDefaults.outPath = answers.outPath;
|
|
109
|
+
}
|
|
110
|
+
cfg.defaults = newDefaults;
|
|
111
|
+
saveConfig(cfg);
|
|
112
|
+
displayDefaults(newDefaults);
|
|
113
|
+
spinner.success({ text: "Defaults saved" });
|
|
114
|
+
}
|
|
115
|
+
catch (e) {
|
|
116
|
+
spinner.error({ text: e.message || "Failed to save config" });
|
|
117
|
+
process.exit(EXIT_GENERAL_ERROR);
|
|
118
|
+
}
|
|
119
|
+
});
|
|
120
|
+
config
|
|
121
|
+
.command("set <key> <value>")
|
|
122
|
+
.description("Set a default option value")
|
|
123
|
+
.action((key, value) => {
|
|
124
|
+
var _a;
|
|
125
|
+
try {
|
|
126
|
+
const meta = SETTABLE_KEYS[key];
|
|
127
|
+
if (!meta) {
|
|
128
|
+
spinner.error({ text: `Unknown config key '${key}'. Valid keys: ${Object.keys(SETTABLE_KEYS).join(", ")}` });
|
|
129
|
+
process.exit(EXIT_MISUSE);
|
|
130
|
+
}
|
|
131
|
+
let parsed = value;
|
|
132
|
+
if (meta.type === "boolean") {
|
|
133
|
+
parsed = parseBoolean(value);
|
|
134
|
+
if (parsed === null) {
|
|
135
|
+
spinner.error({ text: `Invalid boolean value '${value}'. Use true/false, yes/no, 1/0, on/off` });
|
|
136
|
+
process.exit(EXIT_MISUSE);
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
else if (meta.choices && !meta.choices.includes(value)) {
|
|
140
|
+
spinner.error({ text: `Invalid value '${value}' for ${key}. Choices: ${meta.choices.join(", ")}` });
|
|
141
|
+
process.exit(EXIT_MISUSE);
|
|
142
|
+
}
|
|
143
|
+
const cfg = loadConfig();
|
|
144
|
+
cfg.defaults = (_a = cfg.defaults) !== null && _a !== void 0 ? _a : {};
|
|
145
|
+
cfg.defaults[key] = parsed;
|
|
146
|
+
saveConfig(cfg);
|
|
147
|
+
spinner.success({ text: `${key} set to '${parsed}'` });
|
|
148
|
+
}
|
|
149
|
+
catch (e) {
|
|
150
|
+
spinner.error({ text: e.message || "Failed to save config" });
|
|
151
|
+
process.exit(EXIT_GENERAL_ERROR);
|
|
152
|
+
}
|
|
153
|
+
});
|
|
154
|
+
config
|
|
155
|
+
.command("get <key>")
|
|
156
|
+
.description("Show a default option value")
|
|
157
|
+
.action((key) => {
|
|
158
|
+
var _a;
|
|
159
|
+
if (!SETTABLE_KEYS[key]) {
|
|
160
|
+
spinner.error({ text: `Unknown config key '${key}'. Valid keys: ${Object.keys(SETTABLE_KEYS).join(", ")}` });
|
|
161
|
+
process.exit(EXIT_MISUSE);
|
|
162
|
+
}
|
|
163
|
+
const cfg = loadConfig();
|
|
164
|
+
const value = (_a = cfg.defaults) === null || _a === void 0 ? void 0 : _a[key];
|
|
165
|
+
if (value !== undefined && value !== null) {
|
|
166
|
+
console.log(value);
|
|
167
|
+
}
|
|
168
|
+
else {
|
|
169
|
+
console.log(chalk.dim("(not set)"));
|
|
170
|
+
}
|
|
171
|
+
});
|
|
172
|
+
config
|
|
173
|
+
.command("list")
|
|
174
|
+
.description("Show all default options")
|
|
175
|
+
.action(() => {
|
|
176
|
+
var _a;
|
|
177
|
+
const cfg = loadConfig();
|
|
178
|
+
displayDefaults((_a = cfg.defaults) !== null && _a !== void 0 ? _a : {});
|
|
179
|
+
});
|
|
180
|
+
config
|
|
181
|
+
.command("reset")
|
|
182
|
+
.description("Clear all default options")
|
|
183
|
+
.action(async (options) => {
|
|
184
|
+
try {
|
|
185
|
+
const opts = { ...program.opts(), ...options };
|
|
186
|
+
if (!opts.force) {
|
|
187
|
+
const { confirm } = await inquirer.prompt([
|
|
188
|
+
{
|
|
189
|
+
type: "confirm",
|
|
190
|
+
name: "confirm",
|
|
191
|
+
message: "Reset all defaults to factory settings?",
|
|
192
|
+
default: false,
|
|
193
|
+
},
|
|
194
|
+
]);
|
|
195
|
+
if (!confirm)
|
|
196
|
+
return;
|
|
197
|
+
}
|
|
198
|
+
const cfg = loadConfig();
|
|
199
|
+
cfg.defaults = {};
|
|
200
|
+
saveConfig(cfg);
|
|
201
|
+
spinner.success({ text: "All defaults have been reset" });
|
|
202
|
+
}
|
|
203
|
+
catch (e) {
|
|
204
|
+
spinner.error({ text: e.message || "Failed to reset config" });
|
|
205
|
+
process.exit(EXIT_GENERAL_ERROR);
|
|
206
|
+
}
|
|
207
|
+
});
|
|
208
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { Argument } from "commander";
|
|
2
|
+
import { getModuleFromCollection } from "../models/getModuleFromCollection.js";
|
|
3
|
+
import { handleCopySingleOperation } from "../operations/handleCopySingleOperation.js";
|
|
4
|
+
import { localStorage } from "../helpers/localStorage.js";
|
|
5
|
+
import { spinner } from "../../index.js";
|
|
6
|
+
import { EXIT_GENERAL_ERROR, EXIT_MISUSE } from "../exitCodes.js";
|
|
7
|
+
export function createCopyCommand(program) {
|
|
8
|
+
program
|
|
9
|
+
.command("copy")
|
|
10
|
+
.addArgument(new Argument("[collection]", "The collection to use").default(localStorage.getItem("lastCollection"), `The last used collection (${localStorage.getItem("lastCollection")})`))
|
|
11
|
+
.addArgument(new Argument("[id]", "The ID of the entry to copy").default(localStorage.getItem("lastId"), `The last used id (${localStorage.getItem("lastId")})`))
|
|
12
|
+
.alias("cp")
|
|
13
|
+
.description("Duplicate an entry by ID in a collection")
|
|
14
|
+
.addHelpText("after", `
|
|
15
|
+
Examples:
|
|
16
|
+
ay copy contacts 64a1b2c3d4e5 Copy a contact entry
|
|
17
|
+
ay cp Copy last used entry`)
|
|
18
|
+
.action(async (collection, id, options) => {
|
|
19
|
+
try {
|
|
20
|
+
if (!collection) {
|
|
21
|
+
spinner.error({ text: "Missing required argument: collection. Run a list or get command first, or provide it explicitly." });
|
|
22
|
+
process.exit(EXIT_MISUSE);
|
|
23
|
+
}
|
|
24
|
+
if (!id) {
|
|
25
|
+
spinner.error({ text: "Missing required argument: id. Provide an entry ID explicitly." });
|
|
26
|
+
process.exit(EXIT_MISUSE);
|
|
27
|
+
}
|
|
28
|
+
const opts = { ...program.opts(), ...options };
|
|
29
|
+
const module = getModuleFromCollection(collection);
|
|
30
|
+
await handleCopySingleOperation(module.module, collection, id, {
|
|
31
|
+
...opts,
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
catch (e) {
|
|
35
|
+
spinner.error({ text: e.message || "An unexpected error occurred" });
|
|
36
|
+
process.exit(EXIT_GENERAL_ERROR);
|
|
37
|
+
}
|
|
38
|
+
});
|
|
39
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { Argument } from "commander";
|
|
2
|
+
import { getModuleFromCollection } from "../models/getModuleFromCollection.js";
|
|
3
|
+
import { promptCollectionWithModule } from "../prompts/promptCollectionWithModule.js";
|
|
4
|
+
import { handleCreateSingleOperation } from "../operations/handleCreateSingleOperation.js";
|
|
5
|
+
import { promptName } from "../prompts/promptName.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 createCreateCommand(program) {
|
|
10
|
+
program
|
|
11
|
+
.command("create")
|
|
12
|
+
.alias("c")
|
|
13
|
+
.addArgument(new Argument("[collection]", "The collection to use").default(localStorage.getItem("lastCollection"), `The last used collection (${localStorage.getItem("lastCollection")})`))
|
|
14
|
+
.addArgument(new Argument("[name]", "The name of the new item"))
|
|
15
|
+
.description("Create a new entry in a collection")
|
|
16
|
+
.addHelpText("after", `
|
|
17
|
+
Examples:
|
|
18
|
+
ay create contacts "John Doe" Create a new contact
|
|
19
|
+
ay c products "Widget" Create a new product using alias`)
|
|
20
|
+
.action(async (collection, name, options) => {
|
|
21
|
+
try {
|
|
22
|
+
const opts = { ...program.opts(), ...options };
|
|
23
|
+
if (!collection) {
|
|
24
|
+
if (!process.stdin.isTTY) {
|
|
25
|
+
spinner.error({ text: "Missing required argument: collection" });
|
|
26
|
+
process.exit(EXIT_MISUSE);
|
|
27
|
+
}
|
|
28
|
+
collection = await promptCollectionWithModule();
|
|
29
|
+
}
|
|
30
|
+
const module = getModuleFromCollection(collection);
|
|
31
|
+
let entryName = name;
|
|
32
|
+
if (!entryName) {
|
|
33
|
+
if (!process.stdin.isTTY) {
|
|
34
|
+
spinner.error({ text: "Missing required argument: name" });
|
|
35
|
+
process.exit(EXIT_MISUSE);
|
|
36
|
+
}
|
|
37
|
+
entryName = await promptName();
|
|
38
|
+
}
|
|
39
|
+
await handleCreateSingleOperation(module.module, collection, entryName, {
|
|
40
|
+
...opts,
|
|
41
|
+
});
|
|
42
|
+
localStorage.setItem("lastModule", module.module);
|
|
43
|
+
localStorage.setItem("lastCollection", collection);
|
|
44
|
+
}
|
|
45
|
+
catch (e) {
|
|
46
|
+
spinner.error({ text: e.message || "An unexpected error occurred" });
|
|
47
|
+
process.exit(EXIT_GENERAL_ERROR);
|
|
48
|
+
}
|
|
49
|
+
});
|
|
50
|
+
}
|