@basis-theory-labs/cli 2.0.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.
- package/README.md +170 -36
- package/dist/base.js +22 -1
- package/dist/commands/proxies/create.d.ts +17 -1
- package/dist/commands/proxies/create.js +84 -8
- package/dist/commands/proxies/update.d.ts +17 -1
- package/dist/commands/proxies/update.js +66 -6
- package/dist/commands/reactors/create.d.ts +11 -1
- package/dist/commands/reactors/create.js +70 -8
- package/dist/commands/reactors/update.d.ts +11 -1
- package/dist/commands/reactors/update.js +45 -5
- package/dist/proxies/management.d.ts +2 -1
- package/dist/proxies/management.js +9 -3
- package/dist/proxies/runtime.d.ts +5 -0
- package/dist/proxies/runtime.js +66 -0
- package/dist/proxies/utils.d.ts +23 -2
- package/dist/proxies/utils.js +78 -7
- package/dist/reactors/management.d.ts +2 -1
- package/dist/reactors/management.js +9 -3
- package/dist/reactors/runtime.d.ts +3 -0
- package/dist/reactors/runtime.js +27 -0
- package/dist/reactors/utils.d.ts +13 -2
- package/dist/reactors/utils.js +4 -1
- package/dist/runtime/flags.d.ts +10 -0
- package/dist/runtime/flags.js +37 -0
- package/dist/runtime/index.d.ts +3 -0
- package/dist/runtime/index.js +20 -0
- package/dist/runtime/state.d.ts +6 -0
- package/dist/runtime/state.js +86 -0
- package/dist/runtime/utils.d.ts +34 -0
- package/dist/runtime/utils.js +132 -0
- package/dist/utils.d.ts +7 -1
- package/dist/utils.js +41 -1
- package/oclif.manifest.json +351 -10
- package/package.json +2 -2
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/2.
|
|
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
|
|
@@ -62,7 +62,7 @@ EXAMPLES
|
|
|
62
62
|
$ bt applications
|
|
63
63
|
```
|
|
64
64
|
|
|
65
|
-
_See code: [dist/commands/applications/index.ts](https://github.com/Basis-Theory-Labs/basistheory-cli/blob/v2.
|
|
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)_
|
|
66
66
|
|
|
67
67
|
## `bt applications create`
|
|
68
68
|
|
|
@@ -151,7 +151,7 @@ EXAMPLES
|
|
|
151
151
|
$ bt proxies
|
|
152
152
|
```
|
|
153
153
|
|
|
154
|
-
_See code: [dist/commands/proxies/index.ts](https://github.com/Basis-Theory-Labs/basistheory-cli/blob/v2.
|
|
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)_
|
|
155
155
|
|
|
156
156
|
## `bt proxies create`
|
|
157
157
|
|
|
@@ -160,23 +160,72 @@ Creates a new Pre-Configured Proxy. Requires `proxy:create` Management Applicati
|
|
|
160
160
|
```
|
|
161
161
|
USAGE
|
|
162
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]
|
|
163
169
|
|
|
164
170
|
FLAGS
|
|
165
|
-
-a, --[no-]require-auth
|
|
166
|
-
|
|
167
|
-
-c, --configuration=<value>
|
|
168
|
-
-i, --application-id=<value>
|
|
169
|
-
-n, --name=<value>
|
|
170
|
-
-q, --request-transform-code=<value>
|
|
171
|
-
-s, --response-transform-code=<value>
|
|
172
|
-
-u, --destination-url=<value>
|
|
173
|
-
-x, --management-key=<value>
|
|
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)
|
|
174
200
|
|
|
175
201
|
DESCRIPTION
|
|
176
202
|
Creates a new Pre-Configured Proxy. Requires `proxy:create` Management Application permission
|
|
177
203
|
|
|
178
204
|
EXAMPLES
|
|
179
|
-
|
|
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
|
|
180
229
|
```
|
|
181
230
|
|
|
182
231
|
## `bt proxies delete ID`
|
|
@@ -234,35 +283,76 @@ Updates an existing Pre-Configured Proxy. Requires `proxy:update` Management App
|
|
|
234
283
|
```
|
|
235
284
|
USAGE
|
|
236
285
|
$ bt proxies update ID -x <value> [-n <value>] [-u <value>] [-q <value>] [-s <value>] [-i <value>] [-c <value>]
|
|
237
|
-
[-a] [-
|
|
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]
|
|
238
292
|
|
|
239
293
|
ARGUMENTS
|
|
240
294
|
ID Proxy id to update
|
|
241
295
|
|
|
242
296
|
FLAGS
|
|
243
|
-
-a, --[no-]require-auth
|
|
244
|
-
|
|
245
|
-
-c, --configuration=<value>
|
|
246
|
-
-i, --application-id=<value>
|
|
247
|
-
-l, --logs
|
|
248
|
-
-n, --name=<value>
|
|
249
|
-
-q, --request-transform-code=<value>
|
|
250
|
-
-s, --response-transform-code=<value>
|
|
251
|
-
-u, --destination-url=<value>
|
|
252
|
-
-w, --watch
|
|
253
|
-
-x, --management-key=<value>
|
|
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)
|
|
254
328
|
|
|
255
329
|
DESCRIPTION
|
|
256
330
|
Updates an existing Pre-Configured Proxy. Requires `proxy:update` Management Application permission
|
|
257
331
|
|
|
258
332
|
EXAMPLES
|
|
259
|
-
|
|
333
|
+
Update a proxy destination URL
|
|
334
|
+
|
|
335
|
+
$ bt proxies update <proxy-id> --destination-url https://api.example.com
|
|
336
|
+
|
|
337
|
+
Update a proxy with legacy runtime transforms
|
|
338
|
+
|
|
339
|
+
$ bt proxies update <proxy-id> --request-transform-code ./request.js --request-transform-image node-bt \
|
|
340
|
+
--application-id <application-id>
|
|
260
341
|
|
|
261
|
-
|
|
342
|
+
Update a proxy with node22 transforms
|
|
262
343
|
|
|
263
|
-
|
|
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
|
|
264
346
|
|
|
265
|
-
|
|
347
|
+
Update a proxy with node22 transforms and all runtime options
|
|
348
|
+
|
|
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
|
|
266
356
|
```
|
|
267
357
|
|
|
268
358
|
## `bt reactors`
|
|
@@ -284,7 +374,7 @@ EXAMPLES
|
|
|
284
374
|
$ bt reactors
|
|
285
375
|
```
|
|
286
376
|
|
|
287
|
-
_See code: [dist/commands/reactors/index.ts](https://github.com/Basis-Theory-Labs/basistheory-cli/blob/v2.
|
|
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)_
|
|
288
378
|
|
|
289
379
|
## `bt reactors create`
|
|
290
380
|
|
|
@@ -292,7 +382,9 @@ Creates a new Reactor. Requires `reactor:create` Management Application permissi
|
|
|
292
382
|
|
|
293
383
|
```
|
|
294
384
|
USAGE
|
|
295
|
-
$ 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]
|
|
296
388
|
|
|
297
389
|
FLAGS
|
|
298
390
|
-c, --configuration=<value> path to configuration file (.env format) to use in the Reactor
|
|
@@ -300,12 +392,34 @@ FLAGS
|
|
|
300
392
|
-n, --name=<value> name of the Reactor
|
|
301
393
|
-r, --code=<value> path to JavaScript file containing the Reactor code
|
|
302
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)
|
|
303
405
|
|
|
304
406
|
DESCRIPTION
|
|
305
407
|
Creates a new Reactor. Requires `reactor:create` Management Application permission
|
|
306
408
|
|
|
307
409
|
EXAMPLES
|
|
308
|
-
|
|
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
|
|
309
423
|
```
|
|
310
424
|
|
|
311
425
|
## `bt reactors delete ID`
|
|
@@ -362,7 +476,9 @@ Updates an existing Reactor. Requires `reactor:update` Management Application pe
|
|
|
362
476
|
|
|
363
477
|
```
|
|
364
478
|
USAGE
|
|
365
|
-
$ bt reactors update ID -x <value> [-n <value>] [-c <value>] [-i <value>] [-r <value>] [
|
|
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]
|
|
366
482
|
|
|
367
483
|
ARGUMENTS
|
|
368
484
|
ID Reactor id to update
|
|
@@ -375,15 +491,33 @@ FLAGS
|
|
|
375
491
|
-r, --code=<value> path to JavaScript file containing the Reactor code
|
|
376
492
|
-w, --watch Watch for changes in informed files
|
|
377
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)
|
|
378
504
|
|
|
379
505
|
DESCRIPTION
|
|
380
506
|
Updates an existing Reactor. Requires `reactor:update` Management Application permission
|
|
381
507
|
|
|
382
508
|
EXAMPLES
|
|
383
|
-
|
|
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
|
|
384
516
|
|
|
385
|
-
|
|
517
|
+
Update a reactor with node22 and all runtime options
|
|
386
518
|
|
|
387
|
-
|
|
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
|
|
388
522
|
```
|
|
389
523
|
<!-- commandsstop -->
|
package/dist/base.js
CHANGED
|
@@ -3,6 +3,26 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.BaseCommand = void 0;
|
|
4
4
|
const node_sdk_1 = require("@basis-theory/node-sdk");
|
|
5
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
|
+
};
|
|
6
26
|
class BaseCommand extends core_1.Command {
|
|
7
27
|
async parse(options, argv) {
|
|
8
28
|
const { flags, ...parsed } = await super.parse(options, argv);
|
|
@@ -19,7 +39,8 @@ class BaseCommand extends core_1.Command {
|
|
|
19
39
|
}
|
|
20
40
|
catch(err) {
|
|
21
41
|
if (err instanceof node_sdk_1.BasisTheoryError && err.body) {
|
|
22
|
-
|
|
42
|
+
const formatted = formatApiError(err.body);
|
|
43
|
+
return super.catch(new core_1.Errors.CLIError(formatted));
|
|
23
44
|
}
|
|
24
45
|
return super.catch(err);
|
|
25
46
|
}
|
|
@@ -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:
|
|
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
|
}
|
|
@@ -2,12 +2,16 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const base_1 = require("../../base");
|
|
4
4
|
const management_1 = require("../../proxies/management");
|
|
5
|
+
const runtime_1 = require("../../proxies/runtime");
|
|
5
6
|
const utils_1 = require("../../proxies/utils");
|
|
7
|
+
const runtime_2 = require("../../runtime");
|
|
6
8
|
const utils_2 = require("../../utils");
|
|
7
9
|
class Create extends base_1.BaseCommand {
|
|
8
10
|
async run() {
|
|
9
11
|
var _a, _b;
|
|
10
12
|
const { flags, metadata, bt } = await this.parse(Create);
|
|
13
|
+
(0, runtime_1.validateTransformRuntimeFlags)('request-transform', flags, flags['request-transform-image']);
|
|
14
|
+
(0, runtime_1.validateTransformRuntimeFlags)('response-transform', flags, flags['response-transform-image']);
|
|
11
15
|
const name = await (0, utils_2.promptStringIfUndefined)(flags.name, {
|
|
12
16
|
message: 'What is the Proxy name?',
|
|
13
17
|
validate: (value) => Boolean(value),
|
|
@@ -18,12 +22,22 @@ class Create extends base_1.BaseCommand {
|
|
|
18
22
|
const requestTransformCode = await (0, utils_2.promptStringIfUndefined)(flags['request-transform-code'], {
|
|
19
23
|
message: '(Optional) Enter the Request Transform code file path:',
|
|
20
24
|
});
|
|
25
|
+
const requestTransformImage = requestTransformCode
|
|
26
|
+
? await (0, runtime_2.promptRuntimeImage)(flags['request-transform-image'], 'Which runtime do you want for the request transform?')
|
|
27
|
+
: flags['request-transform-image'];
|
|
21
28
|
const responseTransformCode = await (0, utils_2.promptStringIfUndefined)(flags['response-transform-code'], {
|
|
22
29
|
message: '(Optional) Enter the Response Transform code file path:',
|
|
23
30
|
});
|
|
24
|
-
const
|
|
25
|
-
|
|
26
|
-
|
|
31
|
+
const responseTransformImage = responseTransformCode
|
|
32
|
+
? await (0, runtime_2.promptRuntimeImage)(flags['response-transform-image'], 'Which runtime do you want for the response transform?')
|
|
33
|
+
: flags['response-transform-image'];
|
|
34
|
+
const hasLegacyTransform = (0, runtime_2.isLegacyRuntimeImage)(requestTransformImage) ||
|
|
35
|
+
(0, runtime_2.isLegacyRuntimeImage)(responseTransformImage);
|
|
36
|
+
const applicationId = hasLegacyTransform
|
|
37
|
+
? await (0, utils_2.promptStringIfUndefined)(flags['application-id'], {
|
|
38
|
+
message: '(Optional) Enter the Application ID to use in the Proxy:',
|
|
39
|
+
})
|
|
40
|
+
: flags['application-id'];
|
|
27
41
|
const configuration = await (0, utils_2.promptStringIfUndefined)(flags.configuration, {
|
|
28
42
|
message: '(Optional) Enter the configuration file path (.env format):',
|
|
29
43
|
});
|
|
@@ -33,6 +47,14 @@ class Create extends base_1.BaseCommand {
|
|
|
33
47
|
message: 'Does the Proxy require Basis Theory authentication?',
|
|
34
48
|
default: true,
|
|
35
49
|
});
|
|
50
|
+
const updatedFlags = {
|
|
51
|
+
...flags,
|
|
52
|
+
'request-transform-image': requestTransformImage,
|
|
53
|
+
'response-transform-image': responseTransformImage,
|
|
54
|
+
};
|
|
55
|
+
(0, runtime_1.validateProxyApplicationId)(applicationId, updatedFlags);
|
|
56
|
+
const requestTransformRuntime = await (0, runtime_1.promptTransformRuntime)('request', flags, requestTransformCode, requestTransformImage);
|
|
57
|
+
const responseTransformRuntime = await (0, runtime_1.promptTransformRuntime)('response', flags, responseTransformCode, responseTransformImage);
|
|
36
58
|
const model = (0, utils_1.createModelFromFlags)({
|
|
37
59
|
name,
|
|
38
60
|
destinationUrl,
|
|
@@ -41,16 +63,70 @@ class Create extends base_1.BaseCommand {
|
|
|
41
63
|
applicationId,
|
|
42
64
|
configuration,
|
|
43
65
|
requireAuth,
|
|
66
|
+
requestTransformRuntime,
|
|
67
|
+
responseTransformRuntime,
|
|
44
68
|
});
|
|
45
|
-
const
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
69
|
+
const proxy = await (0, management_1.createProxy)(bt, model);
|
|
70
|
+
if (!flags.async && proxy.id) {
|
|
71
|
+
try {
|
|
72
|
+
await (0, runtime_2.waitForResourceState)(bt, 'proxy', proxy.id, proxy.state);
|
|
73
|
+
this.log('Proxy created successfully!');
|
|
74
|
+
this.log(`id: ${proxy.id}`);
|
|
75
|
+
this.log(`key: ${proxy.key}`);
|
|
76
|
+
}
|
|
77
|
+
catch (error) {
|
|
78
|
+
this.log('Proxy created but failed to become ready.');
|
|
79
|
+
this.log(`id: ${proxy.id}`);
|
|
80
|
+
this.log(`key: ${proxy.key}`);
|
|
81
|
+
this.log(`You can retry by running: bt proxies update ${proxy.id} [OPTIONS]`);
|
|
82
|
+
throw error;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
else {
|
|
86
|
+
this.log('Proxy created successfully!');
|
|
87
|
+
this.log(`id: ${proxy.id}`);
|
|
88
|
+
this.log(`key: ${proxy.key}`);
|
|
89
|
+
}
|
|
49
90
|
}
|
|
50
91
|
}
|
|
51
92
|
exports.default = Create;
|
|
52
93
|
Create.description = 'Creates a new Pre-Configured Proxy. Requires `proxy:create` Management Application permission';
|
|
53
|
-
Create.examples = [
|
|
94
|
+
Create.examples = [
|
|
95
|
+
{
|
|
96
|
+
description: 'Create a proxy without transforms',
|
|
97
|
+
command: '<%= config.bin %> <%= command.id %> --name "My Proxy" --destination-url https://api.example.com',
|
|
98
|
+
},
|
|
99
|
+
{
|
|
100
|
+
description: 'Create a proxy with legacy runtime transforms',
|
|
101
|
+
command: '<%= config.bin %> <%= command.id %> --name "My Proxy" --destination-url https://api.example.com --request-transform-code ./request.js --request-transform-image node-bt --application-id <application-id>',
|
|
102
|
+
},
|
|
103
|
+
{
|
|
104
|
+
description: 'Create a proxy with node22 transforms',
|
|
105
|
+
command: '<%= config.bin %> <%= command.id %> --name "My Proxy" --destination-url https://api.example.com --request-transform-code ./request.js --request-transform-image node22 --response-transform-code ./response.js --response-transform-image node22',
|
|
106
|
+
},
|
|
107
|
+
{
|
|
108
|
+
description: 'Create a proxy with node22 transforms and all runtime options',
|
|
109
|
+
command: '<%= config.bin %> <%= command.id %> ' +
|
|
110
|
+
'--name "My Proxy" ' +
|
|
111
|
+
'--destination-url https://api.example.com ' +
|
|
112
|
+
'--configuration ./config.env ' +
|
|
113
|
+
'--require-auth ' +
|
|
114
|
+
'--request-transform-code ./request.js ' +
|
|
115
|
+
'--request-transform-image node22 ' +
|
|
116
|
+
'--request-transform-timeout 10 ' +
|
|
117
|
+
'--request-transform-warm-concurrency 0 ' +
|
|
118
|
+
'--request-transform-resources standard ' +
|
|
119
|
+
'--request-transform-dependencies ./deps.json ' +
|
|
120
|
+
'--request-transform-permissions token:read ' +
|
|
121
|
+
'--response-transform-code ./response.js ' +
|
|
122
|
+
'--response-transform-image node22 ' +
|
|
123
|
+
'--response-transform-timeout 10 ' +
|
|
124
|
+
'--response-transform-warm-concurrency 0 ' +
|
|
125
|
+
'--response-transform-resources standard ' +
|
|
126
|
+
'--response-transform-dependencies ./deps.json ' +
|
|
127
|
+
'--response-transform-permissions token:read',
|
|
128
|
+
},
|
|
129
|
+
];
|
|
54
130
|
Create.flags = {
|
|
55
131
|
...utils_1.PROXY_FLAGS,
|
|
56
132
|
};
|
|
@@ -2,7 +2,10 @@
|
|
|
2
2
|
import { BaseCommand } from '../../base';
|
|
3
3
|
export default class Update extends BaseCommand {
|
|
4
4
|
static description: string;
|
|
5
|
-
static examples:
|
|
5
|
+
static examples: {
|
|
6
|
+
description: string;
|
|
7
|
+
command: string;
|
|
8
|
+
}[];
|
|
6
9
|
static flags: {
|
|
7
10
|
watch: import("@oclif/core/lib/interfaces/parser").BooleanFlag<boolean>;
|
|
8
11
|
logs: import("@oclif/core/lib/interfaces/parser").BooleanFlag<boolean>;
|
|
@@ -13,6 +16,19 @@ export default class Update extends BaseCommand {
|
|
|
13
16
|
'application-id': import("@oclif/core/lib/interfaces/parser").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
14
17
|
configuration: import("@oclif/core/lib/interfaces/parser").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
15
18
|
'require-auth': import("@oclif/core/lib/interfaces/parser").BooleanFlag<boolean>;
|
|
19
|
+
'request-transform-image': import("@oclif/core/lib/interfaces/parser").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
20
|
+
'request-transform-dependencies': import("@oclif/core/lib/interfaces/parser").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
21
|
+
'request-transform-timeout': import("@oclif/core/lib/interfaces/parser").OptionFlag<number | undefined, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
22
|
+
'request-transform-warm-concurrency': import("@oclif/core/lib/interfaces/parser").OptionFlag<number | undefined, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
23
|
+
'request-transform-resources': import("@oclif/core/lib/interfaces/parser").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
24
|
+
'request-transform-permissions': import("@oclif/core/lib/interfaces/parser").OptionFlag<string[] | undefined, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
25
|
+
'response-transform-image': import("@oclif/core/lib/interfaces/parser").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
26
|
+
'response-transform-dependencies': import("@oclif/core/lib/interfaces/parser").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
27
|
+
'response-transform-timeout': import("@oclif/core/lib/interfaces/parser").OptionFlag<number | undefined, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
28
|
+
'response-transform-warm-concurrency': import("@oclif/core/lib/interfaces/parser").OptionFlag<number | undefined, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
29
|
+
'response-transform-resources': import("@oclif/core/lib/interfaces/parser").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
30
|
+
'response-transform-permissions': import("@oclif/core/lib/interfaces/parser").OptionFlag<string[] | undefined, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
31
|
+
async: import("@oclif/core/lib/interfaces/parser").BooleanFlag<boolean>;
|
|
16
32
|
};
|
|
17
33
|
static args: {
|
|
18
34
|
id: import("@oclif/core/lib/interfaces/parser").Arg<string, Record<string, unknown>>;
|