@basis-theory-labs/cli 1.6.0 → 1.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/README.md CHANGED
@@ -19,7 +19,7 @@ $ npm install -g @basis-theory-labs/cli
19
19
  $ bt COMMAND
20
20
  running command...
21
21
  $ bt (--version)
22
- @basis-theory-labs/cli/1.6.0 linux-x64 node-v18.16.1
22
+ @basis-theory-labs/cli/1.7.0 linux-x64 node-v18.17.0
23
23
  $ bt --help [COMMAND]
24
24
  USAGE
25
25
  $ bt COMMAND
@@ -33,6 +33,8 @@ USAGE
33
33
  * [`bt proxies delete ID`](#bt-proxies-delete-id)
34
34
  * [`bt proxies logs [ID]`](#bt-proxies-logs-id)
35
35
  * [`bt proxies update ID`](#bt-proxies-update-id)
36
+ * [`bt reactorFormulas`](#bt-reactorformulas)
37
+ * [`bt reactorFormulas update ID`](#bt-reactorformulas-update-id)
36
38
  * [`bt reactors`](#bt-reactors)
37
39
  * [`bt reactors logs [ID]`](#bt-reactors-logs-id)
38
40
 
@@ -55,7 +57,7 @@ EXAMPLES
55
57
  $ bt proxies
56
58
  ```
57
59
 
58
- _See code: [dist/commands/proxies/index.ts](https://github.com/Basis-Theory-Labs/basistheory-cli/blob/v1.6.0/dist/commands/proxies/index.ts)_
60
+ _See code: [dist/commands/proxies/index.ts](https://github.com/Basis-Theory-Labs/basistheory-cli/blob/v1.7.0/dist/commands/proxies/index.ts)_
59
61
 
60
62
  ## `bt proxies create`
61
63
 
@@ -169,6 +171,59 @@ EXAMPLES
169
171
  $ bt proxies update 03858bf5-32d3-4a2e-b74b-daeea0883bca --configuration ./.env.proxy
170
172
  ```
171
173
 
174
+ ## `bt reactorFormulas`
175
+
176
+ List Reactor Formulas. Requires `reactor:read` Management Application permission
177
+
178
+ ```
179
+ USAGE
180
+ $ bt reactorFormulas -x <value> [-p <value>]
181
+
182
+ FLAGS
183
+ -p, --page=<value> [default: 1] reactors formulas list page to fetch
184
+ -x, --management-key=<value> (required) management key used for connecting with the reactor / proxy
185
+
186
+ DESCRIPTION
187
+ List Reactor Formulas. Requires `reactor:read` Management Application permission
188
+
189
+ EXAMPLES
190
+ $ bt reactorFormulas
191
+ ```
192
+
193
+ _See code: [dist/commands/reactorFormulas/index.ts](https://github.com/Basis-Theory-Labs/basistheory-cli/blob/v1.7.0/dist/commands/reactorFormulas/index.ts)_
194
+
195
+ ## `bt reactorFormulas update ID`
196
+
197
+ Updates an existing Reactor Formula. Requires `reactor:update` Management Application permission
198
+
199
+ ```
200
+ USAGE
201
+ $ bt reactorFormulas update ID -x <value> -n <value> -s <value> -c <value> -p <value> [-d <value>] [-i <value>] [-w]
202
+
203
+ ARGUMENTS
204
+ ID Reactor Formula id to update
205
+
206
+ FLAGS
207
+ -c, --configuration=<value> (required) path to configuration definition to use in the Reactor Formula
208
+ -d, --description=<value> description of the Reactor Formula
209
+ -i, --icon=<value> icon of the Reactor Formula
210
+ -n, --name=<value> (required) name of the Reactor Formula
211
+ -p, --request-parameters=<value> (required) path to request params definition to use in the Reactor Formula
212
+ -s, --code=<value> (required) path to JavaScript file containing code
213
+ -w, --watch Watch for changes in informed files
214
+ -x, --management-key=<value> (required) management key used for connecting with the reactor / proxy
215
+
216
+ DESCRIPTION
217
+ Updates an existing Reactor Formula. Requires `reactor:update` Management Application permission
218
+
219
+ EXAMPLES
220
+ $ bt reactorFormulas update 03858bf5-32d3-4a2e-b74b-daeea0883bca
221
+
222
+ $ bt reactorFormulas update 03858bf5-32d3-4a2e-b74b-daeea0883bca --code ./formula.js
223
+
224
+ $ bt reactorFormulas update 03858bf5-32d3-4a2e-b74b-daeea0883bca --code ./formula.js -w
225
+ ```
226
+
172
227
  ## `bt reactors`
173
228
 
174
229
  List Reactors. Requires `reactor:read` Management Application permission
@@ -188,7 +243,7 @@ EXAMPLES
188
243
  $ bt reactors
189
244
  ```
190
245
 
191
- _See code: [dist/commands/reactors/index.ts](https://github.com/Basis-Theory-Labs/basistheory-cli/blob/v1.6.0/dist/commands/reactors/index.ts)_
246
+ _See code: [dist/commands/reactors/index.ts](https://github.com/Basis-Theory-Labs/basistheory-cli/blob/v1.7.0/dist/commands/reactors/index.ts)_
192
247
 
193
248
  ## `bt reactors logs [ID]`
194
249
 
@@ -0,0 +1,10 @@
1
+ import { BaseCommand } from '../../base';
2
+ export default class ReactorFormulas extends BaseCommand {
3
+ static description: string;
4
+ static examples: string[];
5
+ static flags: {
6
+ page: import("@oclif/core/lib/interfaces/parser").OptionFlag<number, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
7
+ };
8
+ static args: {};
9
+ run(): Promise<void>;
10
+ }
@@ -0,0 +1,26 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const core_1 = require("@oclif/core");
4
+ const base_1 = require("../../base");
5
+ const management_1 = require("../../reactorFormulas/management");
6
+ class ReactorFormulas extends base_1.BaseCommand {
7
+ async run() {
8
+ const { bt, flags: { page }, } = await this.parse(ReactorFormulas);
9
+ const reactor = await (0, management_1.selectReactorFormula)(bt, page);
10
+ if (!reactor) {
11
+ return undefined;
12
+ }
13
+ return undefined;
14
+ }
15
+ }
16
+ exports.default = ReactorFormulas;
17
+ ReactorFormulas.description = 'List Reactor Formulas. Requires `reactor:read` Management Application permission';
18
+ ReactorFormulas.examples = ['<%= config.bin %> <%= command.id %>'];
19
+ ReactorFormulas.flags = {
20
+ page: core_1.Flags.integer({
21
+ char: 'p',
22
+ description: 'reactors formulas list page to fetch',
23
+ default: 1,
24
+ }),
25
+ };
26
+ ReactorFormulas.args = {};
@@ -0,0 +1,18 @@
1
+ import { BaseCommand } from '../../base';
2
+ export default class Update extends BaseCommand {
3
+ static description: string;
4
+ static examples: string[];
5
+ static flags: {
6
+ watch: import("@oclif/core/lib/interfaces/parser").BooleanFlag<boolean>;
7
+ name: import("@oclif/core/lib/interfaces/parser").OptionFlag<string, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
8
+ description: import("@oclif/core/lib/interfaces/parser").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
9
+ icon: import("@oclif/core/lib/interfaces/parser").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
10
+ code: import("@oclif/core/lib/interfaces/parser").OptionFlag<string, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
11
+ configuration: import("@oclif/core/lib/interfaces/parser").OptionFlag<string, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
12
+ 'request-parameters': import("@oclif/core/lib/interfaces/parser").OptionFlag<string, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
13
+ };
14
+ static args: {
15
+ id: import("@oclif/core/lib/interfaces/parser").Arg<string, Record<string, unknown>>;
16
+ };
17
+ run(): Promise<void>;
18
+ }
@@ -0,0 +1,70 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const core_1 = require("@oclif/core");
4
+ const base_1 = require("../../base");
5
+ const files_1 = require("../../files");
6
+ const management_1 = require("../../reactorFormulas/management");
7
+ const utils_1 = require("../../reactorFormulas/utils");
8
+ class Update extends base_1.BaseCommand {
9
+ async run() {
10
+ const { bt, args: { id }, flags: { name, description, code, configuration = '', 'request-parameters': requestParameters = '', watch, }, } = await this.parse(Update);
11
+ const model = (0, utils_1.createModelFromFlags)({
12
+ name,
13
+ description,
14
+ type: 'private',
15
+ code,
16
+ configuration,
17
+ requestParameters,
18
+ });
19
+ await (0, management_1.updateReactorFormula)(bt, id, model);
20
+ this.log('Reactor Formula updated successfully!');
21
+ if (watch) {
22
+ const entries = Object.entries({
23
+ code,
24
+ configuration,
25
+ requestParameters,
26
+ }).filter(([, value]) => Boolean(value));
27
+ const files = entries.reduce((arr, [, file]) => [...arr, file], []);
28
+ if (files.length) {
29
+ this.log(`Watching files for changes: ${files.join(', ')} `);
30
+ }
31
+ entries.forEach(([prop, file]) => {
32
+ (0, files_1.watchForChanges)(file, async () => {
33
+ core_1.ux.action.start(`Detected change in ${file}. Pushing changes`);
34
+ await (0, management_1.updateReactorFormula)(bt, id, (0, utils_1.createModelFromFlags)({
35
+ name,
36
+ description,
37
+ type: 'private',
38
+ code,
39
+ configuration,
40
+ requestParameters,
41
+ [prop]: file,
42
+ }));
43
+ core_1.ux.action.stop('✅\t');
44
+ });
45
+ });
46
+ }
47
+ }
48
+ }
49
+ exports.default = Update;
50
+ Update.description = 'Updates an existing Reactor Formula. Requires `reactor:update` Management Application permission';
51
+ Update.examples = [
52
+ '<%= config.bin %> <%= command.id %> 03858bf5-32d3-4a2e-b74b-daeea0883bca',
53
+ '<%= config.bin %> <%= command.id %> 03858bf5-32d3-4a2e-b74b-daeea0883bca --code ./formula.js',
54
+ '<%= config.bin %> <%= command.id %> 03858bf5-32d3-4a2e-b74b-daeea0883bca --code ./formula.js -w',
55
+ ];
56
+ Update.flags = {
57
+ ...utils_1.REACTOR_FORMULA_FLAGS,
58
+ watch: core_1.Flags.boolean({
59
+ char: 'w',
60
+ description: 'Watch for changes in informed files',
61
+ default: false,
62
+ required: false,
63
+ }),
64
+ };
65
+ Update.args = {
66
+ id: core_1.Args.string({
67
+ description: 'Reactor Formula id to update',
68
+ required: true,
69
+ }),
70
+ };
@@ -0,0 +1,5 @@
1
+ import type { ReactorFormula, CreateReactorFormula } from '@basis-theory/basis-theory-js/types/models';
2
+ import type { BasisTheory as IBasisTheory } from '@basis-theory/basis-theory-js/types/sdk';
3
+ declare const selectReactorFormula: (bt: IBasisTheory, page: number) => Promise<ReactorFormula | undefined>;
4
+ declare const updateReactorFormula: (bt: IBasisTheory, id: string, model: CreateReactorFormula) => Promise<ReactorFormula>;
5
+ export { selectReactorFormula, updateReactorFormula };
@@ -0,0 +1,54 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.updateReactorFormula = exports.selectReactorFormula = void 0;
4
+ const core_1 = require("@oclif/core");
5
+ const utils_1 = require("../utils");
6
+ const debug = require('debug')('reactor-formulas:management');
7
+ const listReactorFormulas = async (bt, page) => {
8
+ const size = 5;
9
+ debug('Listing reactor formulas', `page: ${page}`, `size: ${size}`);
10
+ const reactorFormulas = await bt.reactorFormulas.list({
11
+ size,
12
+ page,
13
+ });
14
+ let data = [];
15
+ if (reactorFormulas.pagination.totalItems > 0) {
16
+ const last = (reactorFormulas.pagination.pageNumber - 1) * size;
17
+ data = reactorFormulas.data.map((reactorFormula, index) => ({
18
+ '#': last + (index + 1),
19
+ ...reactorFormula,
20
+ }));
21
+ core_1.ux.table(data, {
22
+ '#': {},
23
+ id: {},
24
+ name: {},
25
+ });
26
+ }
27
+ else {
28
+ core_1.ux.log('No reactor formulas found.');
29
+ }
30
+ return {
31
+ data,
32
+ pagination: reactorFormulas.pagination,
33
+ };
34
+ };
35
+ const selectReactorFormula = async (bt, page) => {
36
+ const reactors = await listReactorFormulas(bt, page);
37
+ if (reactors.pagination.totalItems === 0) {
38
+ return undefined;
39
+ }
40
+ const selection = await (0, utils_1.selectOrNavigate)(reactors, '#');
41
+ if (selection === 'previous') {
42
+ return selectReactorFormula(bt, page - 1);
43
+ }
44
+ if (selection === 'next') {
45
+ return selectReactorFormula(bt, page + 1);
46
+ }
47
+ return selection;
48
+ };
49
+ exports.selectReactorFormula = selectReactorFormula;
50
+ const updateReactorFormula = (bt, id, model) => {
51
+ debug(`Updating Reactor Formula ${id}`, JSON.stringify(model, undefined, 2));
52
+ return bt.reactorFormulas.update(id, model);
53
+ };
54
+ exports.updateReactorFormula = updateReactorFormula;
@@ -0,0 +1,26 @@
1
+ import type { CreateReactorFormula as CreateReactorFormulaModel } from '@basis-theory/basis-theory-js/types/models/reactor-formulas';
2
+ declare const REACTOR_FORMULA_FLAGS: {
3
+ name: import("@oclif/core/lib/interfaces/parser").OptionFlag<string, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
4
+ description: import("@oclif/core/lib/interfaces/parser").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
5
+ icon: import("@oclif/core/lib/interfaces/parser").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
6
+ code: import("@oclif/core/lib/interfaces/parser").OptionFlag<string, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
7
+ configuration: import("@oclif/core/lib/interfaces/parser").OptionFlag<string, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
8
+ 'request-parameters': import("@oclif/core/lib/interfaces/parser").OptionFlag<string, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
9
+ };
10
+ interface ReactorFormulaFlagProps {
11
+ /**
12
+ * Path to code file
13
+ */
14
+ code?: string;
15
+ /**
16
+ * Path to code file
17
+ */
18
+ requestParameters: string;
19
+ /**
20
+ * Path to .env file
21
+ */
22
+ configuration: string;
23
+ }
24
+ type CreateReactorFormula = ReactorFormulaFlagProps & Omit<CreateReactorFormulaModel, 'configuration' | 'requestParameters' | 'code'>;
25
+ declare function createModelFromFlags(payload: CreateReactorFormula): CreateReactorFormulaModel;
26
+ export { REACTOR_FORMULA_FLAGS, createModelFromFlags };
@@ -0,0 +1,49 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createModelFromFlags = exports.REACTOR_FORMULA_FLAGS = void 0;
4
+ const core_1 = require("@oclif/core");
5
+ const files_1 = require("../files");
6
+ const REACTOR_FORMULA_FLAGS = {
7
+ name: core_1.Flags.string({
8
+ char: 'n',
9
+ description: 'name of the Reactor Formula',
10
+ required: true,
11
+ }),
12
+ description: core_1.Flags.string({
13
+ char: 'd',
14
+ description: 'description of the Reactor Formula',
15
+ }),
16
+ icon: core_1.Flags.string({
17
+ char: 'i',
18
+ description: 'icon of the Reactor Formula',
19
+ }),
20
+ code: core_1.Flags.file({
21
+ char: 's',
22
+ description: 'path to JavaScript file containing code',
23
+ required: true,
24
+ }),
25
+ configuration: core_1.Flags.file({
26
+ char: 'c',
27
+ description: 'path to configuration definition to use in the Reactor Formula',
28
+ required: true,
29
+ }),
30
+ 'request-parameters': core_1.Flags.file({
31
+ char: 'p',
32
+ description: 'path to request params definition to use in the Reactor Formula',
33
+ required: true,
34
+ }),
35
+ };
36
+ exports.REACTOR_FORMULA_FLAGS = REACTOR_FORMULA_FLAGS;
37
+ // eslint-disable-next-line get-off-my-lawn/prefer-arrow-functions
38
+ function createModelFromFlags({ name, description, icon, code, type, configuration, requestParameters, }) {
39
+ return {
40
+ name,
41
+ description,
42
+ icon,
43
+ type,
44
+ code: code ? (0, files_1.readFileContents)(code) : '',
45
+ configuration: JSON.parse((0, files_1.readFileContents)(configuration)),
46
+ requestParameters: JSON.parse((0, files_1.readFileContents)(requestParameters)),
47
+ };
48
+ }
49
+ exports.createModelFromFlags = createModelFromFlags;
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "1.6.0",
2
+ "version": "1.7.0",
3
3
  "commands": {
4
4
  "proxies:create": {
5
5
  "id": "proxies:create",
@@ -310,6 +310,136 @@
310
310
  }
311
311
  }
312
312
  },
313
+ "reactorFormulas": {
314
+ "id": "reactorFormulas",
315
+ "description": "List Reactor Formulas. Requires `reactor:read` Management Application permission",
316
+ "strict": true,
317
+ "pluginName": "@basis-theory-labs/cli",
318
+ "pluginAlias": "@basis-theory-labs/cli",
319
+ "pluginType": "core",
320
+ "aliases": [],
321
+ "examples": [
322
+ "<%= config.bin %> <%= command.id %>"
323
+ ],
324
+ "flags": {
325
+ "management-key": {
326
+ "name": "management-key",
327
+ "type": "option",
328
+ "char": "x",
329
+ "description": "management key used for connecting with the reactor / proxy",
330
+ "required": true,
331
+ "multiple": false
332
+ },
333
+ "api-base-url": {
334
+ "name": "api-base-url",
335
+ "type": "option",
336
+ "description": "base API URL to use in Basis Theory SDK",
337
+ "hidden": true,
338
+ "multiple": false
339
+ },
340
+ "page": {
341
+ "name": "page",
342
+ "type": "option",
343
+ "char": "p",
344
+ "description": "reactors formulas list page to fetch",
345
+ "multiple": false,
346
+ "default": 1
347
+ }
348
+ },
349
+ "args": {}
350
+ },
351
+ "reactorFormulas:update": {
352
+ "id": "reactorFormulas:update",
353
+ "description": "Updates an existing Reactor Formula. Requires `reactor:update` Management Application permission",
354
+ "strict": true,
355
+ "pluginName": "@basis-theory-labs/cli",
356
+ "pluginAlias": "@basis-theory-labs/cli",
357
+ "pluginType": "core",
358
+ "aliases": [],
359
+ "examples": [
360
+ "<%= config.bin %> <%= command.id %> 03858bf5-32d3-4a2e-b74b-daeea0883bca",
361
+ "<%= config.bin %> <%= command.id %> 03858bf5-32d3-4a2e-b74b-daeea0883bca --code ./formula.js",
362
+ "<%= config.bin %> <%= command.id %> 03858bf5-32d3-4a2e-b74b-daeea0883bca --code ./formula.js -w"
363
+ ],
364
+ "flags": {
365
+ "management-key": {
366
+ "name": "management-key",
367
+ "type": "option",
368
+ "char": "x",
369
+ "description": "management key used for connecting with the reactor / proxy",
370
+ "required": true,
371
+ "multiple": false
372
+ },
373
+ "api-base-url": {
374
+ "name": "api-base-url",
375
+ "type": "option",
376
+ "description": "base API URL to use in Basis Theory SDK",
377
+ "hidden": true,
378
+ "multiple": false
379
+ },
380
+ "name": {
381
+ "name": "name",
382
+ "type": "option",
383
+ "char": "n",
384
+ "description": "name of the Reactor Formula",
385
+ "required": true,
386
+ "multiple": false
387
+ },
388
+ "description": {
389
+ "name": "description",
390
+ "type": "option",
391
+ "char": "d",
392
+ "description": "description of the Reactor Formula",
393
+ "multiple": false
394
+ },
395
+ "icon": {
396
+ "name": "icon",
397
+ "type": "option",
398
+ "char": "i",
399
+ "description": "icon of the Reactor Formula",
400
+ "multiple": false
401
+ },
402
+ "code": {
403
+ "name": "code",
404
+ "type": "option",
405
+ "char": "s",
406
+ "description": "path to JavaScript file containing code",
407
+ "required": true,
408
+ "multiple": false
409
+ },
410
+ "configuration": {
411
+ "name": "configuration",
412
+ "type": "option",
413
+ "char": "c",
414
+ "description": "path to configuration definition to use in the Reactor Formula",
415
+ "required": true,
416
+ "multiple": false
417
+ },
418
+ "request-parameters": {
419
+ "name": "request-parameters",
420
+ "type": "option",
421
+ "char": "p",
422
+ "description": "path to request params definition to use in the Reactor Formula",
423
+ "required": true,
424
+ "multiple": false
425
+ },
426
+ "watch": {
427
+ "name": "watch",
428
+ "type": "boolean",
429
+ "char": "w",
430
+ "description": "Watch for changes in informed files",
431
+ "required": false,
432
+ "allowNo": false
433
+ }
434
+ },
435
+ "args": {
436
+ "id": {
437
+ "name": "id",
438
+ "description": "Reactor Formula id to update",
439
+ "required": true
440
+ }
441
+ }
442
+ },
313
443
  "reactors": {
314
444
  "id": "reactors",
315
445
  "description": "List Reactors. Requires `reactor:read` Management Application permission",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@basis-theory-labs/cli",
3
- "version": "1.6.0",
3
+ "version": "1.7.0",
4
4
  "description": "Basis Theory CLI tool",
5
5
  "author": "Davi Aquino @djejaquino",
6
6
  "bin": {