@basis-theory-labs/cli 1.13.0 → 2.1.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.
Files changed (55) hide show
  1. package/README.md +166 -87
  2. package/dist/applications/management.d.ts +8 -10
  3. package/dist/applications/management.js +14 -10
  4. package/dist/base.d.ts +2 -2
  5. package/dist/base.js +27 -14
  6. package/dist/commands/applications/create.js +6 -3
  7. package/dist/commands/applications/index.js +3 -1
  8. package/dist/commands/proxies/create.d.ts +17 -1
  9. package/dist/commands/proxies/create.js +84 -8
  10. package/dist/commands/proxies/index.js +3 -2
  11. package/dist/commands/proxies/logs.js +2 -1
  12. package/dist/commands/proxies/update.d.ts +17 -1
  13. package/dist/commands/proxies/update.js +66 -6
  14. package/dist/commands/reactors/create.d.ts +11 -1
  15. package/dist/commands/reactors/create.js +70 -8
  16. package/dist/commands/reactors/index.js +3 -2
  17. package/dist/commands/reactors/logs.js +2 -1
  18. package/dist/commands/reactors/update.d.ts +11 -1
  19. package/dist/commands/reactors/update.js +45 -5
  20. package/dist/logs/connect.d.ts +5 -5
  21. package/dist/logs/connect.js +1 -2
  22. package/dist/logs/index.d.ts +3 -3
  23. package/dist/logs/server.js +1 -2
  24. package/dist/proxies/management.d.ts +7 -7
  25. package/dist/proxies/management.js +16 -9
  26. package/dist/proxies/runtime.d.ts +5 -0
  27. package/dist/proxies/runtime.js +66 -0
  28. package/dist/proxies/utils.d.ts +26 -5
  29. package/dist/proxies/utils.js +78 -7
  30. package/dist/reactors/management.d.ts +7 -7
  31. package/dist/reactors/management.js +16 -9
  32. package/dist/reactors/runtime.d.ts +3 -0
  33. package/dist/reactors/runtime.js +27 -0
  34. package/dist/reactors/utils.d.ts +16 -5
  35. package/dist/reactors/utils.js +4 -1
  36. package/dist/runtime/flags.d.ts +10 -0
  37. package/dist/runtime/flags.js +37 -0
  38. package/dist/runtime/index.d.ts +3 -0
  39. package/dist/runtime/index.js +20 -0
  40. package/dist/runtime/state.d.ts +6 -0
  41. package/dist/runtime/state.js +86 -0
  42. package/dist/runtime/utils.d.ts +34 -0
  43. package/dist/runtime/utils.js +132 -0
  44. package/dist/utils.d.ts +12 -2
  45. package/dist/utils.js +44 -4
  46. package/oclif.manifest.json +333 -122
  47. package/package.json +4 -3
  48. package/dist/commands/reactorFormulas/index.d.ts +0 -10
  49. package/dist/commands/reactorFormulas/index.js +0 -27
  50. package/dist/commands/reactorFormulas/update.d.ts +0 -18
  51. package/dist/commands/reactorFormulas/update.js +0 -71
  52. package/dist/reactorFormulas/management.d.ts +0 -5
  53. package/dist/reactorFormulas/management.js +0 -54
  54. package/dist/reactorFormulas/utils.d.ts +0 -26
  55. package/dist/reactorFormulas/utils.js +0 -49
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.13.0 linux-x64 node-v18.20.7
22
+ @basis-theory-labs/cli/2.1.0 linux-x64 node-v18.20.8
23
23
  $ bt --help [COMMAND]
24
24
  USAGE
25
25
  $ bt COMMAND
@@ -37,8 +37,6 @@ USAGE
37
37
  * [`bt proxies delete ID`](#bt-proxies-delete-id)
38
38
  * [`bt proxies logs [ID]`](#bt-proxies-logs-id)
39
39
  * [`bt proxies update ID`](#bt-proxies-update-id)
40
- * [`bt reactorFormulas`](#bt-reactorformulas)
41
- * [`bt reactorFormulas update ID`](#bt-reactorformulas-update-id)
42
40
  * [`bt reactors`](#bt-reactors)
43
41
  * [`bt reactors create`](#bt-reactors-create)
44
42
  * [`bt reactors delete ID`](#bt-reactors-delete-id)
@@ -64,7 +62,7 @@ EXAMPLES
64
62
  $ bt applications
65
63
  ```
66
64
 
67
- _See code: [dist/commands/applications/index.ts](https://github.com/Basis-Theory-Labs/basistheory-cli/blob/v1.13.0/dist/commands/applications/index.ts)_
65
+ _See code: [dist/commands/applications/index.ts](https://github.com/Basis-Theory-Labs/basistheory-cli/blob/v2.1.0/dist/commands/applications/index.ts)_
68
66
 
69
67
  ## `bt applications create`
70
68
 
@@ -153,7 +151,7 @@ EXAMPLES
153
151
  $ bt proxies
154
152
  ```
155
153
 
156
- _See code: [dist/commands/proxies/index.ts](https://github.com/Basis-Theory-Labs/basistheory-cli/blob/v1.13.0/dist/commands/proxies/index.ts)_
154
+ _See code: [dist/commands/proxies/index.ts](https://github.com/Basis-Theory-Labs/basistheory-cli/blob/v2.1.0/dist/commands/proxies/index.ts)_
157
155
 
158
156
  ## `bt proxies create`
159
157
 
@@ -162,23 +160,72 @@ Creates a new Pre-Configured Proxy. Requires `proxy:create` Management Applicati
162
160
  ```
163
161
  USAGE
164
162
  $ bt proxies create -x <value> [-n <value>] [-u <value>] [-q <value>] [-s <value>] [-i <value>] [-c <value>] [-a]
163
+ [--request-transform-image node-bt|node22] [--request-transform-dependencies <value>] [--request-transform-timeout
164
+ <value>] [--request-transform-warm-concurrency <value>] [--request-transform-resources standard|large|xlarge]
165
+ [--request-transform-permissions <value>] [--response-transform-image node-bt|node22]
166
+ [--response-transform-dependencies <value>] [--response-transform-timeout <value>]
167
+ [--response-transform-warm-concurrency <value>] [--response-transform-resources standard|large|xlarge]
168
+ [--response-transform-permissions <value>] [--async]
165
169
 
166
170
  FLAGS
167
- -a, --[no-]require-auth whether the Proxy requires Basis Theory authentication to be invoked. Default:
168
- true
169
- -c, --configuration=<value> path to configuration file (.env format) to use in the Proxy
170
- -i, --application-id=<value> application ID to use in the Proxy
171
- -n, --name=<value> name of the Proxy
172
- -q, --request-transform-code=<value> path to JavaScript file containing a Request Transform code
173
- -s, --response-transform-code=<value> path to JavaScript file containing a Response Transform code
174
- -u, --destination-url=<value> URL to which requests will be proxied
175
- -x, --management-key=<value> (required) management key used for connecting with the reactor / proxy
171
+ -a, --[no-]require-auth whether the Proxy requires Basis Theory authentication to be invoked.
172
+ Default: true
173
+ -c, --configuration=<value> path to configuration file (.env format) to use in the Proxy
174
+ -i, --application-id=<value> application ID to use in the Proxy
175
+ -n, --name=<value> name of the Proxy
176
+ -q, --request-transform-code=<value> path to JavaScript file containing a Request Transform code
177
+ -s, --response-transform-code=<value> path to JavaScript file containing a Response Transform code
178
+ -u, --destination-url=<value> URL to which requests will be proxied
179
+ -x, --management-key=<value> (required) management key used for connecting with the reactor / proxy
180
+ --async do not wait for proxy to be ready (requires at least one transform with
181
+ node22)
182
+ --request-transform-dependencies=<value> path to JSON file with npm dependencies, e.g. {"axios": "1.7.9",
183
+ "lodash": "4.17.21"} (node22 only)
184
+ --request-transform-image=<option> request-transform runtime image (node-bt|node22)
185
+ <options: node-bt|node22>
186
+ --request-transform-permissions=<value>... request-transform permission to grant, repeatable (node22 only)
187
+ --request-transform-resources=<option> request-transform resource tier (node22 only)
188
+ <options: standard|large|xlarge>
189
+ --request-transform-timeout=<value> request-transform timeout in seconds, 1-30 (node22 only)
190
+ --request-transform-warm-concurrency=<value> request-transform warm concurrency, 0-1 (node22 only)
191
+ --response-transform-dependencies=<value> path to JSON file with npm dependencies, e.g. {"axios": "1.7.9",
192
+ "lodash": "4.17.21"} (node22 only)
193
+ --response-transform-image=<option> response-transform runtime image (node-bt|node22)
194
+ <options: node-bt|node22>
195
+ --response-transform-permissions=<value>... response-transform permission to grant, repeatable (node22 only)
196
+ --response-transform-resources=<option> response-transform resource tier (node22 only)
197
+ <options: standard|large|xlarge>
198
+ --response-transform-timeout=<value> response-transform timeout in seconds, 1-30 (node22 only)
199
+ --response-transform-warm-concurrency=<value> response-transform warm concurrency, 0-1 (node22 only)
176
200
 
177
201
  DESCRIPTION
178
202
  Creates a new Pre-Configured Proxy. Requires `proxy:create` Management Application permission
179
203
 
180
204
  EXAMPLES
181
- $ bt proxies create
205
+ Create a proxy without transforms
206
+
207
+ $ bt proxies create --name "My Proxy" --destination-url https://api.example.com
208
+
209
+ Create a proxy with legacy runtime transforms
210
+
211
+ $ bt proxies create --name "My Proxy" --destination-url https://api.example.com --request-transform-code \
212
+ ./request.js --request-transform-image node-bt --application-id <application-id>
213
+
214
+ Create a proxy with node22 transforms
215
+
216
+ $ bt proxies create --name "My Proxy" --destination-url https://api.example.com --request-transform-code \
217
+ ./request.js --request-transform-image node22 --response-transform-code ./response.js --response-transform-image \
218
+ node22
219
+
220
+ Create a proxy with node22 transforms and all runtime options
221
+
222
+ $ bt proxies create --name "My Proxy" --destination-url https://api.example.com --configuration ./config.env \
223
+ --require-auth --request-transform-code ./request.js --request-transform-image node22 \
224
+ --request-transform-timeout 10 --request-transform-warm-concurrency 0 --request-transform-resources standard \
225
+ --request-transform-dependencies ./deps.json --request-transform-permissions token:read \
226
+ --response-transform-code ./response.js --response-transform-image node22 --response-transform-timeout 10 \
227
+ --response-transform-warm-concurrency 0 --response-transform-resources standard \
228
+ --response-transform-dependencies ./deps.json --response-transform-permissions token:read
182
229
  ```
183
230
 
184
231
  ## `bt proxies delete ID`
@@ -236,88 +283,76 @@ Updates an existing Pre-Configured Proxy. Requires `proxy:update` Management App
236
283
  ```
237
284
  USAGE
238
285
  $ bt proxies update ID -x <value> [-n <value>] [-u <value>] [-q <value>] [-s <value>] [-i <value>] [-c <value>]
239
- [-a] [-w] [-l]
286
+ [-a] [--request-transform-image node-bt|node22] [--request-transform-dependencies <value>]
287
+ [--request-transform-timeout <value>] [--request-transform-warm-concurrency <value>] [--request-transform-resources
288
+ standard|large|xlarge] [--request-transform-permissions <value>] [--response-transform-image node-bt|node22]
289
+ [--response-transform-dependencies <value>] [--response-transform-timeout <value>]
290
+ [--response-transform-warm-concurrency <value>] [--response-transform-resources standard|large|xlarge]
291
+ [--response-transform-permissions <value>] [--async] [-w] [-l]
240
292
 
241
293
  ARGUMENTS
242
294
  ID Proxy id to update
243
295
 
244
296
  FLAGS
245
- -a, --[no-]require-auth whether the Proxy requires Basis Theory authentication to be invoked. Default:
246
- true
247
- -c, --configuration=<value> path to configuration file (.env format) to use in the Proxy
248
- -i, --application-id=<value> application ID to use in the Proxy
249
- -l, --logs Start logs server after update
250
- -n, --name=<value> name of the Proxy
251
- -q, --request-transform-code=<value> path to JavaScript file containing a Request Transform code
252
- -s, --response-transform-code=<value> path to JavaScript file containing a Response Transform code
253
- -u, --destination-url=<value> URL to which requests will be proxied
254
- -w, --watch Watch for changes in informed files
255
- -x, --management-key=<value> (required) management key used for connecting with the reactor / proxy
297
+ -a, --[no-]require-auth whether the Proxy requires Basis Theory authentication to be invoked.
298
+ Default: true
299
+ -c, --configuration=<value> path to configuration file (.env format) to use in the Proxy
300
+ -i, --application-id=<value> application ID to use in the Proxy
301
+ -l, --logs Start logs server after update
302
+ -n, --name=<value> name of the Proxy
303
+ -q, --request-transform-code=<value> path to JavaScript file containing a Request Transform code
304
+ -s, --response-transform-code=<value> path to JavaScript file containing a Response Transform code
305
+ -u, --destination-url=<value> URL to which requests will be proxied
306
+ -w, --watch Watch for changes in informed files
307
+ -x, --management-key=<value> (required) management key used for connecting with the reactor / proxy
308
+ --async do not wait for proxy to be ready (requires at least one transform with
309
+ node22)
310
+ --request-transform-dependencies=<value> path to JSON file with npm dependencies, e.g. {"axios": "1.7.9",
311
+ "lodash": "4.17.21"} (node22 only)
312
+ --request-transform-image=<option> request-transform runtime image (node-bt|node22)
313
+ <options: node-bt|node22>
314
+ --request-transform-permissions=<value>... request-transform permission to grant, repeatable (node22 only)
315
+ --request-transform-resources=<option> request-transform resource tier (node22 only)
316
+ <options: standard|large|xlarge>
317
+ --request-transform-timeout=<value> request-transform timeout in seconds, 1-30 (node22 only)
318
+ --request-transform-warm-concurrency=<value> request-transform warm concurrency, 0-1 (node22 only)
319
+ --response-transform-dependencies=<value> path to JSON file with npm dependencies, e.g. {"axios": "1.7.9",
320
+ "lodash": "4.17.21"} (node22 only)
321
+ --response-transform-image=<option> response-transform runtime image (node-bt|node22)
322
+ <options: node-bt|node22>
323
+ --response-transform-permissions=<value>... response-transform permission to grant, repeatable (node22 only)
324
+ --response-transform-resources=<option> response-transform resource tier (node22 only)
325
+ <options: standard|large|xlarge>
326
+ --response-transform-timeout=<value> response-transform timeout in seconds, 1-30 (node22 only)
327
+ --response-transform-warm-concurrency=<value> response-transform warm concurrency, 0-1 (node22 only)
256
328
 
257
329
  DESCRIPTION
258
330
  Updates an existing Pre-Configured Proxy. Requires `proxy:update` Management Application permission
259
331
 
260
332
  EXAMPLES
261
- $ bt proxies update 03858bf5-32d3-4a2e-b74b-daeea0883bca
333
+ Update a proxy destination URL
262
334
 
263
- $ bt proxies update 03858bf5-32d3-4a2e-b74b-daeea0883bca --destination-url https://echo.basistheory.com
335
+ $ bt proxies update <proxy-id> --destination-url https://api.example.com
264
336
 
265
- $ bt proxies update 03858bf5-32d3-4a2e-b74b-daeea0883bca --request-transform-code ./myRequestTransform.js
337
+ Update a proxy with legacy runtime transforms
266
338
 
267
- $ bt proxies update 03858bf5-32d3-4a2e-b74b-daeea0883bca --configuration ./.env.proxy
268
- ```
339
+ $ bt proxies update <proxy-id> --request-transform-code ./request.js --request-transform-image node-bt \
340
+ --application-id <application-id>
269
341
 
270
- ## `bt reactorFormulas`
342
+ Update a proxy with node22 transforms
271
343
 
272
- [Deprecated] List Reactor Formulas. Requires `reactor:read` Management Application permission
344
+ $ bt proxies update <proxy-id> --request-transform-code ./request.js --request-transform-image node22 \
345
+ --response-transform-code ./response.js --response-transform-image node22
273
346
 
274
- ```
275
- USAGE
276
- $ bt reactorFormulas -x <value> [-p <value>]
347
+ Update a proxy with node22 transforms and all runtime options
277
348
 
278
- FLAGS
279
- -p, --page=<value> [default: 1] Reactors formulas list page to fetch
280
- -x, --management-key=<value> (required) management key used for connecting with the reactor / proxy
281
-
282
- DESCRIPTION
283
- [Deprecated] List Reactor Formulas. Requires `reactor:read` Management Application permission
284
-
285
- EXAMPLES
286
- $ bt reactorFormulas
287
- ```
288
-
289
- _See code: [dist/commands/reactorFormulas/index.ts](https://github.com/Basis-Theory-Labs/basistheory-cli/blob/v1.13.0/dist/commands/reactorFormulas/index.ts)_
290
-
291
- ## `bt reactorFormulas update ID`
292
-
293
- [Deprecated] Updates an existing Reactor Formula. Requires `reactor:update` Management Application permission
294
-
295
- ```
296
- USAGE
297
- $ bt reactorFormulas update ID -x <value> -n <value> -s <value> -c <value> -p <value> [-d <value>] [-i <value>] [-w]
298
-
299
- ARGUMENTS
300
- ID Reactor Formula id to update
301
-
302
- FLAGS
303
- -c, --configuration=<value> (required) path to configuration definition to use in the Reactor Formula
304
- -d, --description=<value> description of the Reactor Formula
305
- -i, --icon=<value> icon of the Reactor Formula
306
- -n, --name=<value> (required) name of the Reactor Formula
307
- -p, --request-parameters=<value> (required) path to request params definition to use in the Reactor Formula
308
- -s, --code=<value> (required) path to JavaScript file containing code
309
- -w, --watch Watch for changes in informed files
310
- -x, --management-key=<value> (required) management key used for connecting with the reactor / proxy
311
-
312
- DESCRIPTION
313
- [Deprecated] Updates an existing Reactor Formula. Requires `reactor:update` Management Application permission
314
-
315
- EXAMPLES
316
- $ bt reactorFormulas update 03858bf5-32d3-4a2e-b74b-daeea0883bca
317
-
318
- $ bt reactorFormulas update 03858bf5-32d3-4a2e-b74b-daeea0883bca --code ./formula.js
319
-
320
- $ bt reactorFormulas update 03858bf5-32d3-4a2e-b74b-daeea0883bca --code ./formula.js -w
349
+ $ bt proxies update <proxy-id> --name "My Proxy" --destination-url https://api.example.com --configuration \
350
+ ./config.env --require-auth --request-transform-code ./request.js --request-transform-image node22 \
351
+ --request-transform-timeout 10 --request-transform-warm-concurrency 0 --request-transform-resources standard \
352
+ --request-transform-dependencies ./deps.json --request-transform-permissions token:read \
353
+ --response-transform-code ./response.js --response-transform-image node22 --response-transform-timeout 10 \
354
+ --response-transform-warm-concurrency 0 --response-transform-resources standard \
355
+ --response-transform-dependencies ./deps.json --response-transform-permissions token:read
321
356
  ```
322
357
 
323
358
  ## `bt reactors`
@@ -339,7 +374,7 @@ EXAMPLES
339
374
  $ bt reactors
340
375
  ```
341
376
 
342
- _See code: [dist/commands/reactors/index.ts](https://github.com/Basis-Theory-Labs/basistheory-cli/blob/v1.13.0/dist/commands/reactors/index.ts)_
377
+ _See code: [dist/commands/reactors/index.ts](https://github.com/Basis-Theory-Labs/basistheory-cli/blob/v2.1.0/dist/commands/reactors/index.ts)_
343
378
 
344
379
  ## `bt reactors create`
345
380
 
@@ -347,7 +382,9 @@ Creates a new Reactor. Requires `reactor:create` Management Application permissi
347
382
 
348
383
  ```
349
384
  USAGE
350
- $ bt reactors create -x <value> [-n <value>] [-c <value>] [-i <value>] [-r <value>]
385
+ $ bt reactors create -x <value> [-n <value>] [-c <value>] [-i <value>] [-r <value>] [--image node-bt|node22]
386
+ [--dependencies <value>] [--timeout <value>] [--warm-concurrency <value>] [--resources standard|large|xlarge]
387
+ [--permissions <value>] [--async]
351
388
 
352
389
  FLAGS
353
390
  -c, --configuration=<value> path to configuration file (.env format) to use in the Reactor
@@ -355,12 +392,34 @@ FLAGS
355
392
  -n, --name=<value> name of the Reactor
356
393
  -r, --code=<value> path to JavaScript file containing the Reactor code
357
394
  -x, --management-key=<value> (required) management key used for connecting with the reactor / proxy
395
+ --async do not wait for resource to be ready (node22 only)
396
+ --dependencies=<value> path to JSON file with npm dependencies, e.g. {"axios": "1.7.9", "lodash": "4.17.21"}
397
+ (node22 only)
398
+ --image=<option> runtime image (node-bt|node22)
399
+ <options: node-bt|node22>
400
+ --permissions=<value>... permission to grant, repeatable (node22 only)
401
+ --resources=<option> resource tier (node22 only, default: standard)
402
+ <options: standard|large|xlarge>
403
+ --timeout=<value> timeout in seconds, 1-30 (node22 only, default: 10)
404
+ --warm-concurrency=<value> number of warm instances, 0-1 (node22 only, default: 0)
358
405
 
359
406
  DESCRIPTION
360
407
  Creates a new Reactor. Requires `reactor:create` Management Application permission
361
408
 
362
409
  EXAMPLES
363
- $ bt reactors create
410
+ Create a reactor with legacy runtime
411
+
412
+ $ bt reactors create --name "My Reactor" --code ./reactor.js --image node-bt --application-id <application-id>
413
+
414
+ Create a reactor with node22 runtime
415
+
416
+ $ bt reactors create --name "My Reactor" --code ./reactor.js --image node22
417
+
418
+ Create a reactor with node22 and all runtime options
419
+
420
+ $ bt reactors create --name "My Reactor" --code ./reactor.js --configuration ./config.env --image node22 \
421
+ --timeout 10 --warm-concurrency 0 --resources standard --dependencies ./deps.json --permissions token:read \
422
+ --permissions token:create
364
423
  ```
365
424
 
366
425
  ## `bt reactors delete ID`
@@ -417,7 +476,9 @@ Updates an existing Reactor. Requires `reactor:update` Management Application pe
417
476
 
418
477
  ```
419
478
  USAGE
420
- $ bt reactors update ID -x <value> [-n <value>] [-c <value>] [-i <value>] [-r <value>] [-w] [-l]
479
+ $ bt reactors update ID -x <value> [-n <value>] [-c <value>] [-i <value>] [-r <value>] [--image node-bt|node22]
480
+ [--dependencies <value>] [--timeout <value>] [--warm-concurrency <value>] [--resources standard|large|xlarge]
481
+ [--permissions <value>] [--async] [-w] [-l]
421
482
 
422
483
  ARGUMENTS
423
484
  ID Reactor id to update
@@ -430,15 +491,33 @@ FLAGS
430
491
  -r, --code=<value> path to JavaScript file containing the Reactor code
431
492
  -w, --watch Watch for changes in informed files
432
493
  -x, --management-key=<value> (required) management key used for connecting with the reactor / proxy
494
+ --async do not wait for resource to be ready (node22 only)
495
+ --dependencies=<value> path to JSON file with npm dependencies, e.g. {"axios": "1.7.9", "lodash": "4.17.21"}
496
+ (node22 only)
497
+ --image=<option> runtime image (node-bt|node22)
498
+ <options: node-bt|node22>
499
+ --permissions=<value>... permission to grant, repeatable (node22 only)
500
+ --resources=<option> resource tier (node22 only, default: standard)
501
+ <options: standard|large|xlarge>
502
+ --timeout=<value> timeout in seconds, 1-30 (node22 only, default: 10)
503
+ --warm-concurrency=<value> number of warm instances, 0-1 (node22 only, default: 0)
433
504
 
434
505
  DESCRIPTION
435
506
  Updates an existing Reactor. Requires `reactor:update` Management Application permission
436
507
 
437
508
  EXAMPLES
438
- $ bt reactors update 03858bf5-32d3-4a2e-b74b-daeea0883bca
509
+ Update a reactor with legacy runtime
510
+
511
+ $ bt reactors update <reactor-id> --code ./reactor.js --image node-bt --application-id <application-id>
512
+
513
+ Update a reactor with node22 runtime
514
+
515
+ $ bt reactors update <reactor-id> --code ./reactor.js --image node22
439
516
 
440
- $ bt reactors update 03858bf5-32d3-4a2e-b74b-daeea0883bca --code ./reactor.js
517
+ Update a reactor with node22 and all runtime options
441
518
 
442
- $ bt reactors update 03858bf5-32d3-4a2e-b74b-daeea0883bca --configuration ./.env.reactor
519
+ $ bt reactors update <reactor-id> --name "My Reactor" --code ./reactor.js --configuration ./config.env --image \
520
+ node22 --timeout 10 --warm-concurrency 0 --resources standard --dependencies ./deps.json --permissions \
521
+ token:read --permissions token:create
443
522
  ```
444
523
  <!-- commandsstop -->
@@ -1,11 +1,9 @@
1
- import type { Application, ApplicationType, CreateApplication, Permission, UpdateApplication } from '@basis-theory/basis-theory-js/types/models';
2
- import { ApplicationTemplate } from '@basis-theory/basis-theory-js/types/models/application-templates';
3
- import type { BasisTheory as IBasisTheory } from '@basis-theory/basis-theory-js/types/sdk';
4
- declare const listPermissions: (bt: IBasisTheory, type: ApplicationType) => Promise<Permission[]>;
5
- declare const selectApplication: (bt: IBasisTheory, page: number) => Promise<Application | undefined>;
6
- declare const createApplication: (bt: IBasisTheory, model: CreateApplication) => Promise<Application>;
7
- declare const updateApplication: (bt: IBasisTheory, id: string, model: UpdateApplication) => Promise<Application>;
8
- declare const deleteApplication: (bt: IBasisTheory, id: string, force?: boolean) => Promise<boolean>;
9
- declare const createApplicationFromTemplate: (bt: IBasisTheory, templateId: string) => Promise<Application>;
10
- declare const promptTemplate: (bt: IBasisTheory) => Promise<ApplicationTemplate | undefined>;
1
+ import type { BasisTheory, BasisTheoryClient } from '@basis-theory/node-sdk';
2
+ declare const listPermissions: (bt: BasisTheoryClient, type: string) => Promise<BasisTheory.Permission[]>;
3
+ declare const selectApplication: (bt: BasisTheoryClient, page: number) => Promise<BasisTheory.Application | undefined>;
4
+ declare const createApplication: (bt: BasisTheoryClient, model: BasisTheory.CreateApplicationRequest) => Promise<BasisTheory.Application>;
5
+ declare const updateApplication: (bt: BasisTheoryClient, id: string, model: Partial<BasisTheory.UpdateApplicationRequest>) => Promise<BasisTheory.Application>;
6
+ declare const deleteApplication: (bt: BasisTheoryClient, id: string, force?: boolean) => Promise<boolean>;
7
+ declare const createApplicationFromTemplate: (bt: BasisTheoryClient, templateId: string) => Promise<BasisTheory.Application>;
8
+ declare const promptTemplate: (bt: BasisTheoryClient) => Promise<BasisTheory.ApplicationTemplate | undefined>;
11
9
  export { listPermissions, createApplication, updateApplication, selectApplication, deleteApplication, createApplicationFromTemplate, promptTemplate, };
@@ -12,19 +12,19 @@ const listPermissions = (bt, type) => bt.permissions
12
12
  .list({
13
13
  applicationType: type,
14
14
  })
15
- .then((permissions) => permissions.sort((p1, p2) => p1.type.localeCompare(p2.type)));
15
+ .then((permissions) => permissions.sort((p1, p2) => { var _a, _b; return ((_a = p1.type) !== null && _a !== void 0 ? _a : '').localeCompare((_b = p2.type) !== null && _b !== void 0 ? _b : ''); }));
16
16
  exports.listPermissions = listPermissions;
17
17
  const listApplications = async (bt, page) => {
18
18
  const size = 5;
19
19
  debug('Listing applications', `page: ${page}`, `size: ${size}`);
20
- const applications = await bt.applications.list({
20
+ const applicationsPage = await bt.applications.list({
21
21
  size,
22
22
  page,
23
23
  });
24
24
  let data = [];
25
- if (applications.pagination.totalItems > 0) {
26
- const last = (applications.pagination.pageNumber - 1) * size;
27
- data = applications.data.map((application, index) => ({
25
+ if (applicationsPage.data.length) {
26
+ const last = (page - 1) * size;
27
+ data = applicationsPage.data.map((application, index) => ({
28
28
  '#': last + (index + 1),
29
29
  ...application,
30
30
  }));
@@ -40,16 +40,17 @@ const listApplications = async (bt, page) => {
40
40
  }
41
41
  return {
42
42
  data,
43
- pagination: applications.pagination,
43
+ page,
44
+ hasNextPage: applicationsPage.hasNextPage(),
44
45
  };
45
46
  };
46
47
  const retrieveApplication = (bt, id) => {
47
48
  debug(`Retrieving Application ${id}`);
48
- return bt.applications.retrieve(id);
49
+ return bt.applications.get(id);
49
50
  };
50
51
  const selectApplication = async (bt, page) => {
51
52
  const applications = await listApplications(bt, page);
52
- if (applications.pagination.totalItems === 0) {
53
+ if (!applications.data.length) {
53
54
  return undefined;
54
55
  }
55
56
  const selection = await (0, utils_1.selectOrNavigate)(applications, '#');
@@ -71,7 +72,7 @@ const updateApplication = async (bt, id, model) => {
71
72
  const application = await retrieveApplication(bt, id);
72
73
  debug(`Updating Application ${id}`, JSON.stringify(model, undefined, 2));
73
74
  return bt.applications.update(id, {
74
- name: model.name || application.name,
75
+ name: model.name || application.name || '',
75
76
  permissions: model.permissions || application.permissions,
76
77
  rules: model.permissions ? undefined : application.rules, // if permissions were passed, overwrite rules
77
78
  });
@@ -93,7 +94,10 @@ const deleteApplication = async (bt, id, force = false) => {
93
94
  };
94
95
  exports.deleteApplication = deleteApplication;
95
96
  const createApplicationFromTemplate = async (bt, templateId) => {
96
- const template = await bt.applicationTemplates.retrieve(templateId);
97
+ const template = await bt.applicationTemplates.get(templateId);
98
+ if (!template.name || !template.applicationType) {
99
+ throw new Error('Invalid template: missing name or applicationType');
100
+ }
97
101
  return createApplication(bt, {
98
102
  name: template.name,
99
103
  type: template.applicationType,
package/dist/base.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import type { BasisTheory as IBasisTheory } from '@basis-theory/basis-theory-js/types/sdk';
1
+ import { BasisTheoryClient } from '@basis-theory/node-sdk';
2
2
  import { Command } from '@oclif/core';
3
3
  import type { ArgOutput, FlagOutput, Input, ParserOutput } from '@oclif/core/lib/interfaces/parser';
4
4
  export declare abstract class BaseCommand extends Command {
@@ -7,7 +7,7 @@ export declare abstract class BaseCommand extends Command {
7
7
  'api-base-url': import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
8
8
  };
9
9
  protected parse<F extends FlagOutput, B extends FlagOutput, A extends ArgOutput>(options?: Input<F, B, A>, argv?: string[]): Promise<ParserOutput<F, B, A> & {
10
- bt: IBasisTheory;
10
+ bt: BasisTheoryClient;
11
11
  }>;
12
12
  protected catch(err: unknown): Promise<unknown>;
13
13
  }
package/dist/base.js CHANGED
@@ -1,23 +1,35 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.BaseCommand = void 0;
4
- const basis_theory_js_1 = require("@basis-theory/basis-theory-js");
5
- const common_1 = require("@basis-theory/basis-theory-js/common");
4
+ const node_sdk_1 = require("@basis-theory/node-sdk");
6
5
  const core_1 = require("@oclif/core");
6
+ const formatApiError = (body) => {
7
+ const parts = [];
8
+ if (body.title) {
9
+ const status = body.status ? ` [${body.status}]` : '';
10
+ parts.push(`${body.title}${status}`);
11
+ }
12
+ if (body.detail) {
13
+ parts.push(`Detail: ${body.detail}`);
14
+ }
15
+ if ('errors' in body && body.errors) {
16
+ for (const [field, messages] of Object.entries(body.errors)) {
17
+ if (Array.isArray(messages)) {
18
+ for (const message of messages) {
19
+ parts.push(` - ${field}: ${message}`);
20
+ }
21
+ }
22
+ }
23
+ }
24
+ return parts.join('\n');
25
+ };
7
26
  class BaseCommand extends core_1.Command {
8
27
  async parse(options, argv) {
9
28
  const { flags, ...parsed } = await super.parse(options, argv);
10
29
  const { 'management-key': managementKey, 'api-base-url': apiBaseUrl } = flags;
11
- const bt = await new basis_theory_js_1.BasisTheory().init(managementKey, {
12
- appInfo: {
13
- name: this.config.userAgent,
14
- version: this.config.version,
15
- },
16
- ...(apiBaseUrl
17
- ? {
18
- apiBaseUrl,
19
- }
20
- : {}),
30
+ const bt = new node_sdk_1.BasisTheoryClient({
31
+ apiKey: managementKey,
32
+ ...(apiBaseUrl ? { environment: apiBaseUrl } : {}),
21
33
  });
22
34
  return {
23
35
  ...parsed,
@@ -26,8 +38,9 @@ class BaseCommand extends core_1.Command {
26
38
  };
27
39
  }
28
40
  catch(err) {
29
- if (err instanceof common_1.BasisTheoryApiError) {
30
- this.logJson(err.data);
41
+ if (err instanceof node_sdk_1.BasisTheoryError && err.body) {
42
+ const formatted = formatApiError(err.body);
43
+ return super.catch(new core_1.Errors.CLIError(formatted));
31
44
  }
32
45
  return super.catch(err);
33
46
  }
@@ -1,11 +1,11 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- const models_1 = require("@basis-theory/basis-theory-js/types/models");
4
3
  const core_1 = require("@oclif/core");
5
4
  const management_1 = require("../../applications/management");
6
5
  const utils_1 = require("../../applications/utils");
7
6
  const base_1 = require("../../base");
8
7
  const utils_2 = require("../../utils");
8
+ const APPLICATION_TYPES = ['private', 'public', 'management'];
9
9
  class Create extends base_1.BaseCommand {
10
10
  async run() {
11
11
  const { flags, bt } = await this.parse(Create);
@@ -35,7 +35,7 @@ class Create extends base_1.BaseCommand {
35
35
  else {
36
36
  type = (await (0, utils_2.promptSelectIfUndefined)(flags.type, {
37
37
  message: 'What is the Application type?',
38
- choices: models_1.APPLICATION_TYPES.map((t) => ({ value: t })),
38
+ choices: APPLICATION_TYPES.map((t) => ({ value: t })),
39
39
  }));
40
40
  const available = await (0, management_1.listPermissions)(bt, type);
41
41
  permissions = await (0, utils_2.promptCheckboxIfUndefined)(flags.permission, {
@@ -46,6 +46,9 @@ class Create extends base_1.BaseCommand {
46
46
  loop: false,
47
47
  });
48
48
  }
49
+ if (!type) {
50
+ throw new Error('Application type is required');
51
+ }
49
52
  application = await (0, management_1.createApplication)(bt, {
50
53
  name,
51
54
  type,
@@ -66,7 +69,7 @@ Create.flags = {
66
69
  type: core_1.Flags.string({
67
70
  char: 't',
68
71
  description: 'type of the Application',
69
- options: [...models_1.APPLICATION_TYPES],
72
+ options: [...APPLICATION_TYPES],
70
73
  }),
71
74
  template: core_1.Flags.string({
72
75
  description: 'template ID to create the application with',
@@ -7,6 +7,7 @@ const management_1 = require("../../applications/management");
7
7
  const base_1 = require("../../base");
8
8
  class Applications extends base_1.BaseCommand {
9
9
  async run() {
10
+ var _a;
10
11
  const { bt, flags: { page }, } = await this.parse(Applications);
11
12
  const application = await (0, management_1.selectApplication)(bt, page);
12
13
  if (!application) {
@@ -29,7 +30,8 @@ class Applications extends base_1.BaseCommand {
29
30
  this.logJson(application);
30
31
  return undefined;
31
32
  }
32
- if (action === 'delete' && (await (0, management_1.deleteApplication)(bt, application.id))) {
33
+ if (action === 'delete' &&
34
+ (await (0, management_1.deleteApplication)(bt, (_a = application.id) !== null && _a !== void 0 ? _a : ''))) {
33
35
  return this.log('Application deleted successfully!');
34
36
  }
35
37
  return undefined;
@@ -2,7 +2,10 @@
2
2
  import { BaseCommand } from '../../base';
3
3
  export default class Create extends BaseCommand {
4
4
  static description: string;
5
- static examples: string[];
5
+ static examples: {
6
+ description: string;
7
+ command: string;
8
+ }[];
6
9
  static flags: {
7
10
  name: import("@oclif/core/lib/interfaces/parser").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
8
11
  'destination-url': import("@oclif/core/lib/interfaces/parser").OptionFlag<import("url").URL | undefined, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
@@ -11,6 +14,19 @@ export default class Create extends BaseCommand {
11
14
  'application-id': import("@oclif/core/lib/interfaces/parser").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
12
15
  configuration: import("@oclif/core/lib/interfaces/parser").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
13
16
  'require-auth': import("@oclif/core/lib/interfaces/parser").BooleanFlag<boolean>;
17
+ 'request-transform-image': import("@oclif/core/lib/interfaces/parser").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
18
+ 'request-transform-dependencies': import("@oclif/core/lib/interfaces/parser").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
19
+ 'request-transform-timeout': import("@oclif/core/lib/interfaces/parser").OptionFlag<number | undefined, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
20
+ 'request-transform-warm-concurrency': import("@oclif/core/lib/interfaces/parser").OptionFlag<number | undefined, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
21
+ 'request-transform-resources': import("@oclif/core/lib/interfaces/parser").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
22
+ 'request-transform-permissions': import("@oclif/core/lib/interfaces/parser").OptionFlag<string[] | undefined, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
23
+ 'response-transform-image': import("@oclif/core/lib/interfaces/parser").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
24
+ 'response-transform-dependencies': import("@oclif/core/lib/interfaces/parser").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
25
+ 'response-transform-timeout': import("@oclif/core/lib/interfaces/parser").OptionFlag<number | undefined, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
26
+ 'response-transform-warm-concurrency': import("@oclif/core/lib/interfaces/parser").OptionFlag<number | undefined, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
27
+ 'response-transform-resources': import("@oclif/core/lib/interfaces/parser").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
28
+ 'response-transform-permissions': import("@oclif/core/lib/interfaces/parser").OptionFlag<string[] | undefined, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
29
+ async: import("@oclif/core/lib/interfaces/parser").BooleanFlag<boolean>;
14
30
  };
15
31
  run(): Promise<void>;
16
32
  }