@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,169 +0,0 @@
|
|
|
1
|
-
const BASH_COMPLETION = `###-begin-ay-completions-###
|
|
2
|
-
_ay_completions() {
|
|
3
|
-
local cur commands
|
|
4
|
-
COMPREPLY=()
|
|
5
|
-
cur="\${COMP_WORDS[COMP_CWORD]}"
|
|
6
|
-
commands="modules list get edit copy create describe audit stream events storage whoami login logout completions alias config actions exec ai services deploy monitor delete update batch search webhooks jobs export users sync permissions templates"
|
|
7
|
-
|
|
8
|
-
if [[ \${COMP_CWORD} -eq 1 ]]; then
|
|
9
|
-
COMPREPLY=( $(compgen -W "\${commands}" -- "\${cur}") )
|
|
10
|
-
fi
|
|
11
|
-
}
|
|
12
|
-
complete -F _ay_completions ay
|
|
13
|
-
###-end-ay-completions-###`;
|
|
14
|
-
const ZSH_COMPLETION = `###-begin-ay-completions-###
|
|
15
|
-
_ay() {
|
|
16
|
-
local -a commands
|
|
17
|
-
commands=(
|
|
18
|
-
'modules:Browse modules interactively'
|
|
19
|
-
'list:List entries in a collection'
|
|
20
|
-
'get:Get entries from a collection'
|
|
21
|
-
'edit:Edit an entry in a collection'
|
|
22
|
-
'copy:Copy an entry in a collection'
|
|
23
|
-
'create:Create a new entry in a collection'
|
|
24
|
-
'describe:Describe an entry in a collection'
|
|
25
|
-
'audit:View audit history of an entry'
|
|
26
|
-
'stream:Attach to the live data stream'
|
|
27
|
-
'events:Attach to the live event bus'
|
|
28
|
-
'storage:Show current local storage'
|
|
29
|
-
'whoami:Show your user information'
|
|
30
|
-
'login:Login to your aYOUne account'
|
|
31
|
-
'logout:Logout from your aYOUne account'
|
|
32
|
-
'completions:Generate shell completion script'
|
|
33
|
-
'alias:Manage command aliases'
|
|
34
|
-
'config:Manage CLI configuration'
|
|
35
|
-
'actions:Discover registered API actions'
|
|
36
|
-
'exec:Execute any API action by operationId'
|
|
37
|
-
'ai:AI assistant commands'
|
|
38
|
-
'services:Discover and manage platform services'
|
|
39
|
-
'deploy:Manage deployments and pipelines'
|
|
40
|
-
'monitor:Monitor platform activity, logs, and alerts'
|
|
41
|
-
'delete:Delete entries from a collection'
|
|
42
|
-
'update:Update an entry non-interactively'
|
|
43
|
-
'batch:Run bulk operations on multiple entries'
|
|
44
|
-
'search:Search entries with advanced filtering'
|
|
45
|
-
'webhooks:Manage webhooks and event subscriptions'
|
|
46
|
-
'jobs:Manage background jobs and automations'
|
|
47
|
-
'export:Export data from collections'
|
|
48
|
-
'users:Manage users, teams, and roles'
|
|
49
|
-
'sync:Synchronize platform data across systems'
|
|
50
|
-
'permissions:Manage permissions and access requests'
|
|
51
|
-
'templates:Manage platform templates'
|
|
52
|
-
)
|
|
53
|
-
_describe 'command' commands
|
|
54
|
-
}
|
|
55
|
-
compdef _ay ay
|
|
56
|
-
###-end-ay-completions-###`;
|
|
57
|
-
const FISH_COMPLETION = `###-begin-ay-completions-###
|
|
58
|
-
complete -c ay -n '__fish_use_subcommand' -a modules -d 'Browse modules interactively'
|
|
59
|
-
complete -c ay -n '__fish_use_subcommand' -a list -d 'List entries in a collection'
|
|
60
|
-
complete -c ay -n '__fish_use_subcommand' -a get -d 'Get entries from a collection'
|
|
61
|
-
complete -c ay -n '__fish_use_subcommand' -a edit -d 'Edit an entry in a collection'
|
|
62
|
-
complete -c ay -n '__fish_use_subcommand' -a copy -d 'Copy an entry in a collection'
|
|
63
|
-
complete -c ay -n '__fish_use_subcommand' -a create -d 'Create a new entry in a collection'
|
|
64
|
-
complete -c ay -n '__fish_use_subcommand' -a describe -d 'Describe an entry in a collection'
|
|
65
|
-
complete -c ay -n '__fish_use_subcommand' -a audit -d 'View audit history of an entry'
|
|
66
|
-
complete -c ay -n '__fish_use_subcommand' -a stream -d 'Attach to the live data stream'
|
|
67
|
-
complete -c ay -n '__fish_use_subcommand' -a events -d 'Attach to the live event bus'
|
|
68
|
-
complete -c ay -n '__fish_use_subcommand' -a storage -d 'Show current local storage'
|
|
69
|
-
complete -c ay -n '__fish_use_subcommand' -a whoami -d 'Show your user information'
|
|
70
|
-
complete -c ay -n '__fish_use_subcommand' -a login -d 'Login to your aYOUne account'
|
|
71
|
-
complete -c ay -n '__fish_use_subcommand' -a logout -d 'Logout from your aYOUne account'
|
|
72
|
-
complete -c ay -n '__fish_use_subcommand' -a completions -d 'Generate shell completion script'
|
|
73
|
-
complete -c ay -n '__fish_use_subcommand' -a alias -d 'Manage command aliases'
|
|
74
|
-
complete -c ay -n '__fish_use_subcommand' -a config -d 'Manage CLI configuration'
|
|
75
|
-
complete -c ay -n '__fish_use_subcommand' -a actions -d 'Discover registered API actions'
|
|
76
|
-
complete -c ay -n '__fish_use_subcommand' -a exec -d 'Execute any API action by operationId'
|
|
77
|
-
complete -c ay -n '__fish_use_subcommand' -a ai -d 'AI assistant commands'
|
|
78
|
-
complete -c ay -n '__fish_use_subcommand' -a services -d 'Discover and manage platform services'
|
|
79
|
-
complete -c ay -n '__fish_use_subcommand' -a deploy -d 'Manage deployments and pipelines'
|
|
80
|
-
complete -c ay -n '__fish_use_subcommand' -a monitor -d 'Monitor platform activity, logs, and alerts'
|
|
81
|
-
complete -c ay -n '__fish_use_subcommand' -a delete -d 'Delete entries from a collection'
|
|
82
|
-
complete -c ay -n '__fish_use_subcommand' -a update -d 'Update an entry non-interactively'
|
|
83
|
-
complete -c ay -n '__fish_use_subcommand' -a batch -d 'Run bulk operations on multiple entries'
|
|
84
|
-
complete -c ay -n '__fish_use_subcommand' -a search -d 'Search entries with advanced filtering'
|
|
85
|
-
complete -c ay -n '__fish_use_subcommand' -a webhooks -d 'Manage webhooks and event subscriptions'
|
|
86
|
-
complete -c ay -n '__fish_use_subcommand' -a jobs -d 'Manage background jobs and automations'
|
|
87
|
-
complete -c ay -n '__fish_use_subcommand' -a export -d 'Export data from collections'
|
|
88
|
-
complete -c ay -n '__fish_use_subcommand' -a users -d 'Manage users, teams, and roles'
|
|
89
|
-
complete -c ay -n '__fish_use_subcommand' -a sync -d 'Synchronize platform data across systems'
|
|
90
|
-
complete -c ay -n '__fish_use_subcommand' -a permissions -d 'Manage permissions and access requests'
|
|
91
|
-
complete -c ay -n '__fish_use_subcommand' -a templates -d 'Manage platform templates'
|
|
92
|
-
###-end-ay-completions-###`;
|
|
93
|
-
const POWERSHELL_COMPLETION = `###-begin-ay-completions-###
|
|
94
|
-
Register-ArgumentCompleter -CommandName ay -ScriptBlock {
|
|
95
|
-
param($wordToComplete, $commandAst, $cursorPosition)
|
|
96
|
-
$commands = @(
|
|
97
|
-
@{ Name = 'modules'; Description = 'Browse modules interactively' }
|
|
98
|
-
@{ Name = 'list'; Description = 'List entries in a collection' }
|
|
99
|
-
@{ Name = 'get'; Description = 'Get entries from a collection' }
|
|
100
|
-
@{ Name = 'edit'; Description = 'Edit an entry in a collection' }
|
|
101
|
-
@{ Name = 'copy'; Description = 'Copy an entry in a collection' }
|
|
102
|
-
@{ Name = 'create'; Description = 'Create a new entry in a collection' }
|
|
103
|
-
@{ Name = 'describe'; Description = 'Describe an entry in a collection' }
|
|
104
|
-
@{ Name = 'audit'; Description = 'View audit history of an entry' }
|
|
105
|
-
@{ Name = 'stream'; Description = 'Attach to the live data stream' }
|
|
106
|
-
@{ Name = 'events'; Description = 'Attach to the live event bus' }
|
|
107
|
-
@{ Name = 'storage'; Description = 'Show current local storage' }
|
|
108
|
-
@{ Name = 'whoami'; Description = 'Show your user information' }
|
|
109
|
-
@{ Name = 'login'; Description = 'Login to your aYOUne account' }
|
|
110
|
-
@{ Name = 'logout'; Description = 'Logout from your aYOUne account' }
|
|
111
|
-
@{ Name = 'completions'; Description = 'Generate shell completion script' }
|
|
112
|
-
@{ Name = 'alias'; Description = 'Manage command aliases' }
|
|
113
|
-
@{ Name = 'config'; Description = 'Manage CLI configuration' }
|
|
114
|
-
@{ Name = 'actions'; Description = 'Discover registered API actions' }
|
|
115
|
-
@{ Name = 'exec'; Description = 'Execute any API action by operationId' }
|
|
116
|
-
@{ Name = 'ai'; Description = 'AI assistant commands' }
|
|
117
|
-
@{ Name = 'services'; Description = 'Discover and manage platform services' }
|
|
118
|
-
@{ Name = 'deploy'; Description = 'Manage deployments and pipelines' }
|
|
119
|
-
@{ Name = 'monitor'; Description = 'Monitor platform activity, logs, and alerts' }
|
|
120
|
-
@{ Name = 'delete'; Description = 'Delete entries from a collection' }
|
|
121
|
-
@{ Name = 'update'; Description = 'Update an entry non-interactively' }
|
|
122
|
-
@{ Name = 'batch'; Description = 'Run bulk operations on multiple entries' }
|
|
123
|
-
@{ Name = 'search'; Description = 'Search entries with advanced filtering' }
|
|
124
|
-
@{ Name = 'webhooks'; Description = 'Manage webhooks and event subscriptions' }
|
|
125
|
-
@{ Name = 'jobs'; Description = 'Manage background jobs and automations' }
|
|
126
|
-
@{ Name = 'export'; Description = 'Export data from collections' }
|
|
127
|
-
@{ Name = 'users'; Description = 'Manage users, teams, and roles' }
|
|
128
|
-
@{ Name = 'sync'; Description = 'Synchronize platform data across systems' }
|
|
129
|
-
@{ Name = 'permissions'; Description = 'Manage permissions and access requests' }
|
|
130
|
-
@{ Name = 'templates'; Description = 'Manage platform templates' }
|
|
131
|
-
)
|
|
132
|
-
$commands | Where-Object { $_.Name -like "$wordToComplete*" } | ForEach-Object {
|
|
133
|
-
[System.Management.Automation.CompletionResult]::new($_.Name, $_.Name, 'ParameterValue', $_.Description)
|
|
134
|
-
}
|
|
135
|
-
}
|
|
136
|
-
###-end-ay-completions-###`;
|
|
137
|
-
export function createCompletionsCommand(program) {
|
|
138
|
-
program
|
|
139
|
-
.command("completions")
|
|
140
|
-
.alias("completion")
|
|
141
|
-
.description("Generate shell completion script")
|
|
142
|
-
.addHelpText("after", `
|
|
143
|
-
Examples:
|
|
144
|
-
ay completions bash >> ~/.bashrc Add bash completions
|
|
145
|
-
ay completions zsh >> ~/.zshrc Add zsh completions
|
|
146
|
-
ay completions fish > ~/.config/fish/completions/ay.fish
|
|
147
|
-
ay completions powershell >> $PROFILE Add PowerShell completions`)
|
|
148
|
-
.argument("<shell>", "Shell type (bash, zsh, fish, powershell)")
|
|
149
|
-
.action((shell) => {
|
|
150
|
-
switch (shell) {
|
|
151
|
-
case "bash":
|
|
152
|
-
console.log(BASH_COMPLETION);
|
|
153
|
-
break;
|
|
154
|
-
case "zsh":
|
|
155
|
-
console.log(ZSH_COMPLETION);
|
|
156
|
-
break;
|
|
157
|
-
case "fish":
|
|
158
|
-
console.log(FISH_COMPLETION);
|
|
159
|
-
break;
|
|
160
|
-
case "powershell":
|
|
161
|
-
case "pwsh":
|
|
162
|
-
console.log(POWERSHELL_COMPLETION);
|
|
163
|
-
break;
|
|
164
|
-
default:
|
|
165
|
-
console.error(`Unknown shell: ${shell}. Supported: bash, zsh, fish, powershell`);
|
|
166
|
-
process.exit(2);
|
|
167
|
-
}
|
|
168
|
-
});
|
|
169
|
-
}
|
|
@@ -1,208 +0,0 @@
|
|
|
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
|
-
}
|
|
@@ -1,39 +0,0 @@
|
|
|
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
|
-
}
|
|
@@ -1,50 +0,0 @@
|
|
|
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
|
-
}
|
|
@@ -1,98 +0,0 @@
|
|
|
1
|
-
import { Argument } from "commander";
|
|
2
|
-
import chalk from "chalk";
|
|
3
|
-
import { getModuleFromCollection } from "../models/getModuleFromCollection.js";
|
|
4
|
-
import { handleDeleteSingleOperation } from "../operations/handleDeleteSingleOperation.js";
|
|
5
|
-
import { localStorage } from "../helpers/localStorage.js";
|
|
6
|
-
import { spinner } from "../../index.js";
|
|
7
|
-
import { EXIT_GENERAL_ERROR, EXIT_MISUSE } from "../exitCodes.js";
|
|
8
|
-
export function createDeleteCommand(program) {
|
|
9
|
-
program
|
|
10
|
-
.command("delete")
|
|
11
|
-
.alias("rm")
|
|
12
|
-
.description("Delete one or more entries from a collection")
|
|
13
|
-
.addHelpText("after", `
|
|
14
|
-
Examples:
|
|
15
|
-
ay delete contacts 64a1b2c3d4e5 Delete a single contact
|
|
16
|
-
ay rm contacts 64a1b2c3d4e5 --force Skip confirmation
|
|
17
|
-
ay delete contacts id1,id2,id3 Delete multiple entries
|
|
18
|
-
echo "id1,id2" | ay delete contacts --ids-stdin Read IDs from stdin`)
|
|
19
|
-
.addArgument(new Argument("[collection]", "The collection to use").default(localStorage.getItem("lastCollection"), `The last used collection (${localStorage.getItem("lastCollection")})`))
|
|
20
|
-
.addArgument(new Argument("[ids]", "Comma-separated ID(s) to delete").default(localStorage.getItem("lastId"), `The last used id (${localStorage.getItem("lastId")})`))
|
|
21
|
-
.option("--ids-stdin", "Read IDs from stdin (one per line or comma-separated)")
|
|
22
|
-
.action(async (collection, ids, options) => {
|
|
23
|
-
try {
|
|
24
|
-
if (!collection) {
|
|
25
|
-
spinner.error({ text: "Missing required argument: collection. Run a list or get command first, or provide it explicitly." });
|
|
26
|
-
process.exit(EXIT_MISUSE);
|
|
27
|
-
}
|
|
28
|
-
const opts = { ...program.opts(), ...options };
|
|
29
|
-
const module = getModuleFromCollection(collection);
|
|
30
|
-
// Collect IDs from argument and/or stdin
|
|
31
|
-
let idList = [];
|
|
32
|
-
if (ids) {
|
|
33
|
-
idList = ids.split(",").map((id) => id.trim()).filter(Boolean);
|
|
34
|
-
}
|
|
35
|
-
if (opts.idsStdin && !process.stdin.isTTY) {
|
|
36
|
-
const chunks = [];
|
|
37
|
-
for await (const chunk of process.stdin) {
|
|
38
|
-
chunks.push(chunk);
|
|
39
|
-
}
|
|
40
|
-
const stdinContent = Buffer.concat(chunks).toString("utf-8").trim();
|
|
41
|
-
if (stdinContent) {
|
|
42
|
-
const stdinIds = stdinContent
|
|
43
|
-
.split(/[,\n]/)
|
|
44
|
-
.map((id) => id.trim())
|
|
45
|
-
.filter(Boolean);
|
|
46
|
-
idList.push(...stdinIds);
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
if (idList.length === 0) {
|
|
50
|
-
spinner.error({ text: "No IDs provided. Pass IDs as argument or via --ids-stdin." });
|
|
51
|
-
process.exit(EXIT_MISUSE);
|
|
52
|
-
}
|
|
53
|
-
// Confirmation prompt (unless --force)
|
|
54
|
-
if (!opts.force && process.stdin.isTTY) {
|
|
55
|
-
const inquirer = (await import("inquirer")).default;
|
|
56
|
-
const { confirmed } = await inquirer.prompt([
|
|
57
|
-
{
|
|
58
|
-
type: "confirm",
|
|
59
|
-
name: "confirmed",
|
|
60
|
-
message: `Delete ${idList.length} entry/entries from ${collection}?`,
|
|
61
|
-
default: false,
|
|
62
|
-
},
|
|
63
|
-
]);
|
|
64
|
-
if (!confirmed) {
|
|
65
|
-
spinner.stop();
|
|
66
|
-
console.error(chalk.yellow(" Aborted."));
|
|
67
|
-
return;
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
// Execute deletions
|
|
71
|
-
let successCount = 0;
|
|
72
|
-
let errorCount = 0;
|
|
73
|
-
for (const id of idList) {
|
|
74
|
-
try {
|
|
75
|
-
await handleDeleteSingleOperation(module.module, collection, id, opts);
|
|
76
|
-
successCount++;
|
|
77
|
-
}
|
|
78
|
-
catch (e) {
|
|
79
|
-
errorCount++;
|
|
80
|
-
spinner.error({ text: `Failed to delete ${id}: ${e.message}` });
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
if (idList.length > 1) {
|
|
84
|
-
spinner.success({ text: `Deleted ${successCount}/${idList.length} entries from ${collection}` });
|
|
85
|
-
spinner.stop();
|
|
86
|
-
}
|
|
87
|
-
localStorage.setItem("lastModule", module.module);
|
|
88
|
-
localStorage.setItem("lastCollection", collection);
|
|
89
|
-
if (errorCount > 0) {
|
|
90
|
-
process.exit(EXIT_GENERAL_ERROR);
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
catch (e) {
|
|
94
|
-
spinner.error({ text: e.message || "An unexpected error occurred" });
|
|
95
|
-
process.exit(EXIT_GENERAL_ERROR);
|
|
96
|
-
}
|
|
97
|
-
});
|
|
98
|
-
}
|