@commercelayer/agent-cli 0.5.1 → 0.7.0

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/dist/bin.js CHANGED
@@ -5,7 +5,7 @@
5
5
  import * as cmd from './commands.js';
6
6
  import { CliError, print } from './output.js';
7
7
  import { LATEST_HINT, NPX } from './version.js';
8
- const VALUE_OPTIONS = new Set(['--name', '--sku', '--quantity', '--country', '--code', '--file', '--store', '--item', '--email', '--first-name', '--last-name', '--phone', '--street', '--city', '--postal-code', '--region', '--shipping', '--category', '--min-price', '--max-price', '--status', '--payment', '--fulfillment', '--limit', '--archived', '--amount', '--carrier', '--tracking', '--tracking-url']);
8
+ const VALUE_OPTIONS = new Set(['--name', '--sku', '--quantity', '--country', '--code', '--file', '--store', '--item', '--email', '--first-name', '--last-name', '--phone', '--street', '--city', '--postal-code', '--region', '--shipping', '--category', '--min-price', '--max-price', '--status', '--payment', '--fulfillment', '--limit', '--archived', '--amount', '--carrier', '--tracking', '--tracking-url', '--since', '--until', '--by', '--company', '--line-2', '--query', '--reference', '--notes', '--language', '--source', '--channel', '--label', '--unlabel', '--move']);
9
9
  const argv = process.argv.slice(2);
10
10
  const flags = new Set();
11
11
  const values = {};
@@ -93,13 +93,15 @@ async function run() {
93
93
  case 'orders':
94
94
  if (sub === 'test')
95
95
  return cmd.ordersTest(flags, values);
96
+ if (sub === 'create')
97
+ return cmd.ordersCreate(values, lists, flags);
96
98
  if (sub === 'list')
97
99
  return cmd.ordersList(values, flags);
98
100
  if (sub === 'show')
99
101
  return cmd.ordersShow(args[2]);
100
- if (sub === 'approve' || sub === 'capture' || sub === 'cancel' || sub === 'refund' || sub === 'archive' || sub === 'unarchive')
102
+ if (sub === 'place' || sub === 'approve' || sub === 'capture' || sub === 'cancel' || sub === 'refund' || sub === 'archive' || sub === 'unarchive')
101
103
  return cmd.ordersAct(sub, args[2], values, flags);
102
- throw new CliError('unknown_command', `There is no command "orders ${sub ?? ''}".`, 'Use `c11r orders list`, `show <number>`, `approve <number> [--capture]`, `capture`, `cancel`, `refund <number> [--amount <n>]`, `archive`, `unarchive`, or `orders test`.');
104
+ throw new CliError('unknown_command', `There is no command "orders ${sub ?? ''}".`, 'Use `c11r orders list`, `show <number>`, `create`, `place <number>`, `approve <number> [--capture]`, `capture`, `cancel`, `refund <number> [--amount <n>]`, `archive`, `unarchive`, or `orders test`.');
103
105
  case 'fulfillment':
104
106
  if (sub === 'list')
105
107
  return cmd.fulfillmentList(values);
@@ -108,15 +110,35 @@ async function run() {
108
110
  if (sub === 'hold' || sub === 'pick' || sub === 'pack' || sub === 'ready' || sub === 'ship' || sub === 'deliver')
109
111
  return cmd.fulfillmentAct(sub, args[2], values);
110
112
  throw new CliError('unknown_command', `There is no command "fulfillment ${sub ?? ''}".`, 'Use `c11r fulfillment list`, `show <shipment>`, `hold`, `pick`, `pack`, `ready`, `ship <shipment> [--carrier --tracking --tracking-url]` or `deliver`.');
113
+ case 'ops':
114
+ if (sub === 'check')
115
+ return cmd.opsCheck(values);
116
+ if (sub === 'run')
117
+ return cmd.opsRun(flags);
118
+ if (sub === 'digest')
119
+ return cmd.opsDigest(values);
120
+ throw new CliError('unknown_command', `There is no command "ops ${sub ?? ''}".`, 'Use `c11r ops check`, `ops run [--dry-run]` or `ops digest [--since 24h]`.');
121
+ case 'insights':
122
+ return cmd.insights(values);
123
+ case 'inbox':
124
+ if (sub === 'check')
125
+ return cmd.inboxCheck();
126
+ if (sub === 'list')
127
+ return cmd.inboxList(values, flags);
128
+ if (sub === 'pull')
129
+ return cmd.inboxPull(args[2], values, flags);
130
+ if (sub === 'tag')
131
+ return cmd.inboxTag(args[2], lists, values, flags);
132
+ throw new CliError('unknown_command', `There is no command "inbox ${sub ?? ''}".`, sub === 'reply' ? 'The CLI does not send email: replies stay with the human or their mail app.' : 'Use `c11r inbox check`, `list [--unseen] [--since 24h] [--limit 20]`, `pull <id> | --unseen` or `tag <id> --label <name> | --unlabel <name> | --move <folder> | --seen`.');
111
133
  case 'ucp':
112
134
  if (sub === 'profile')
113
135
  return cmd.ucpProfile(flags);
114
136
  if (sub === 'check')
115
137
  return cmd.ucpCheck();
116
138
  if (sub === 'search')
117
- return cmd.ucpSearch(args.slice(2).join(' '), values, lists);
139
+ return cmd.ucpSearch(args.slice(2).join(' '), values, lists, flags);
118
140
  if (sub === 'product')
119
- return cmd.ucpProduct(args[2], values);
141
+ return cmd.ucpProduct(args[2], values, flags);
120
142
  if (sub === 'order')
121
143
  return cmd.ucpOrder(args[2], values);
122
144
  if (sub === 'ask')
@@ -148,7 +170,7 @@ run()
148
170
  })
149
171
  .catch((e) => {
150
172
  if (e instanceof CliError) {
151
- print({ error: { code: e.code, message: e.message, hint: e.hint } });
173
+ print({ error: { code: e.code, message: e.message, hint: e.hint, ...(e.path ? { path: e.path } : {}) } });
152
174
  }
153
175
  else {
154
176
  const message = e instanceof Error ? e.message : String(e);