@commercelayer/agent-cli 1.0.0-dev.15 → 1.0.0-dev.16
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/README.md +1 -1
- package/dist/engine.js +18 -3
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -78,7 +78,7 @@ Destructive verbs (deletes, `orders cancel`, `payments void` and `refund`, `sand
|
|
|
78
78
|
- A verb that never runs live (sandbox, plans, sales calls, `auth login`, `auth switch`, `shop`) stops on this machine with `state_required`.
|
|
79
79
|
- `c11r status --live --org <slug>` is the organization's live status, with `live_credential` and the warning `live_credential_held` while the API holds one.
|
|
80
80
|
- `c11r auth logout --live --org <slug>` revokes that credential in Commerce Layer (`DELETE /v1/auth/live`): `{ org, revoked, credential }`. The login stays on this machine. `--dry-run` says what it would revoke.
|
|
81
|
-
- A
|
|
81
|
+
- A verb that needs a yes is confirmed by the API in live, with a sentence naming the action, the amount and the mode (`Refunds EUR 1.00 on order N, in LIVE mode, real money.`): the CLI sends it without `confirm=true` and shows that `confirmation_required` as it is, with the API's next command, or asks it with those words in a terminal. `--yes` sends `confirm=true` on every live write, `payments capture` included.
|
|
82
82
|
- A verb that answers a secret (`credentials create`) writes it in live only to the file the human chose with `--out`: without it, `missing_value` with the command and `--out FILE`. Never to c11r's secrets folder, never printed. A live delete leaves the test mode's secret files of the same organization alone.
|
|
83
83
|
- `store.yml`, `.c11r/export.json` and the drift notes are of an organization in a mode: a live write marks a live `store.yml` behind, never a test one, and the other way round.
|
|
84
84
|
- `c11r organizations disconnect <slug>` (confirmed) has the API revoke its credentials and the organization tokens; this machine then forgets the token, its secret files and a `.c11r.json` naming it, as `sandbox destroy` does, and answers `forgotten`.
|
package/dist/engine.js
CHANGED
|
@@ -118,10 +118,16 @@ async function executeOnce(argv, opts) {
|
|
|
118
118
|
const loginOrg = org.source && org.source !== 'only_stored' ? org.org : null;
|
|
119
119
|
let confirmed = false;
|
|
120
120
|
const confirmFlags = verb.confirmIf.filter((k) => parsed.values[k] !== undefined && parsed.values[k] !== false);
|
|
121
|
-
|
|
121
|
+
// In live mode the API asks for the verbs it confirms, with a sentence naming the action, the
|
|
122
|
+
// amount and the mode ("Refunds EUR 1.00 on order N, in LIVE mode, real money."): the CLI sends
|
|
123
|
+
// without confirm=true and shows that 428 as it is, or asks it in a terminal. --yes sends
|
|
124
|
+
// confirm=true on every live write, payments capture included.
|
|
125
|
+
const apiAsks = live && (verb.confirm || confirmFlags.length > 0);
|
|
126
|
+
if (live && cmd.globals.yes && verb.method !== 'GET')
|
|
127
|
+
confirmed = true;
|
|
128
|
+
if ((verb.destructive || verb.confirm || confirmFlags.length) && !cmd.globals.dryRun && !apiAsks) {
|
|
122
129
|
const what = `${verb.name} ${schema.noun}${parsed.id ? ` ${parsed.id}` : ''}${confirmFlags.length ? ` with ${confirmFlags.map(toFlag).join(' ')}` : ''}`;
|
|
123
|
-
|
|
124
|
-
const sentence = `${what.charAt(0).toUpperCase() + what.slice(1)}${live ? `, in LIVE mode on ${liveOrg}` : ''}`;
|
|
130
|
+
const sentence = what.charAt(0).toUpperCase() + what.slice(1);
|
|
125
131
|
await confirm(sentence, line, { yes: cmd.globals.yes, prompter: opts.prompter });
|
|
126
132
|
confirmed = true;
|
|
127
133
|
}
|
|
@@ -149,6 +155,15 @@ async function executeOnce(argv, opts) {
|
|
|
149
155
|
return await sendOnce(req);
|
|
150
156
|
}
|
|
151
157
|
catch (e) {
|
|
158
|
+
// The API's own confirmation, in live: as it is with no terminal; asked with its words in one.
|
|
159
|
+
if (live && !confirmed && e instanceof CliError && e.code === 'confirmation_required') {
|
|
160
|
+
const p = opts.prompter ?? terminal;
|
|
161
|
+
if (!p.interactive)
|
|
162
|
+
throw e;
|
|
163
|
+
await confirm(e.body.message, line, { yes: false, prompter: p, sentence: e.body.message });
|
|
164
|
+
confirmed = true;
|
|
165
|
+
return sendOnce(req);
|
|
166
|
+
}
|
|
152
167
|
// A login token Commerce Layer no longer takes: mint a new one, once.
|
|
153
168
|
if (!(e instanceof CliError && e.code === 'login_required') || !login)
|
|
154
169
|
throw e;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@commercelayer/agent-cli",
|
|
3
|
-
"version": "1.0.0-dev.
|
|
3
|
+
"version": "1.0.0-dev.16",
|
|
4
4
|
"description": "c11r: the Commerce Layer CLI for coding agents. One grammar, c11r <noun> <verb>, from a sandbox to a running organization.",
|
|
5
5
|
"homepage": "https://commercelayer.ai",
|
|
6
6
|
"keywords": [
|