@basis-theory-labs/cli 2.0.0 → 3.0.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 +174 -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 +21 -0
- package/dist/runtime/state.d.ts +6 -0
- package/dist/runtime/state.js +105 -0
- package/dist/runtime/utils.d.ts +39 -0
- package/dist/runtime/utils.js +171 -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/
|
|
22
|
+
@basis-theory-labs/cli/3.0.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/
|
|
65
|
+
_See code: [dist/commands/applications/index.ts](https://github.com/Basis-Theory-Labs/basistheory-cli/blob/v3.0.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/
|
|
154
|
+
_See code: [dist/commands/proxies/index.ts](https://github.com/Basis-Theory-Labs/basistheory-cli/blob/v3.0.0/dist/commands/proxies/index.ts)_
|
|
155
155
|
|
|
156
156
|
## `bt proxies create`
|
|
157
157
|
|
|
@@ -160,23 +160,74 @@ 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-package-json <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-package-json <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-image=<option> request-transform runtime image (node-bt|node22)
|
|
183
|
+
<options: node-bt|node22>
|
|
184
|
+
--request-transform-package-json=<value> path to runtime package.json JSON file (top-level dependencies
|
|
185
|
+
required; supports resolutions or overrides fallback; pinned versions
|
|
186
|
+
required) (node22 only)
|
|
187
|
+
--request-transform-permissions=<value>... request-transform permission to grant, repeatable (node22 only)
|
|
188
|
+
--request-transform-resources=<option> request-transform resource tier (node22 only)
|
|
189
|
+
<options: standard|large|xlarge>
|
|
190
|
+
--request-transform-timeout=<value> request-transform timeout in seconds, 1-30 (node22 only)
|
|
191
|
+
--request-transform-warm-concurrency=<value> request-transform warm concurrency, 0-1 (node22 only)
|
|
192
|
+
--response-transform-image=<option> response-transform runtime image (node-bt|node22)
|
|
193
|
+
<options: node-bt|node22>
|
|
194
|
+
--response-transform-package-json=<value> path to runtime package.json JSON file (top-level dependencies
|
|
195
|
+
required; supports resolutions or overrides fallback; pinned versions
|
|
196
|
+
required) (node22 only)
|
|
197
|
+
--response-transform-permissions=<value>... response-transform permission to grant, repeatable (node22 only)
|
|
198
|
+
--response-transform-resources=<option> response-transform resource tier (node22 only)
|
|
199
|
+
<options: standard|large|xlarge>
|
|
200
|
+
--response-transform-timeout=<value> response-transform timeout in seconds, 1-30 (node22 only)
|
|
201
|
+
--response-transform-warm-concurrency=<value> response-transform warm concurrency, 0-1 (node22 only)
|
|
174
202
|
|
|
175
203
|
DESCRIPTION
|
|
176
204
|
Creates a new Pre-Configured Proxy. Requires `proxy:create` Management Application permission
|
|
177
205
|
|
|
178
206
|
EXAMPLES
|
|
179
|
-
|
|
207
|
+
Create a proxy without transforms
|
|
208
|
+
|
|
209
|
+
$ bt proxies create --name "My Proxy" --destination-url https://api.example.com
|
|
210
|
+
|
|
211
|
+
Create a proxy with legacy runtime transforms
|
|
212
|
+
|
|
213
|
+
$ bt proxies create --name "My Proxy" --destination-url https://api.example.com --request-transform-code \
|
|
214
|
+
./request.js --request-transform-image node-bt --application-id <application-id>
|
|
215
|
+
|
|
216
|
+
Create a proxy with node22 transforms
|
|
217
|
+
|
|
218
|
+
$ bt proxies create --name "My Proxy" --destination-url https://api.example.com --request-transform-code \
|
|
219
|
+
./request.js --request-transform-image node22 --response-transform-code ./response.js --response-transform-image \
|
|
220
|
+
node22
|
|
221
|
+
|
|
222
|
+
Create a proxy with node22 transforms and all runtime options
|
|
223
|
+
|
|
224
|
+
$ bt proxies create --name "My Proxy" --destination-url https://api.example.com --configuration ./config.env \
|
|
225
|
+
--require-auth --request-transform-code ./request.js --request-transform-image node22 \
|
|
226
|
+
--request-transform-timeout 10 --request-transform-warm-concurrency 0 --request-transform-resources standard \
|
|
227
|
+
--request-transform-package-json ./request/package.json --request-transform-permissions token:read \
|
|
228
|
+
--response-transform-code ./response.js --response-transform-image node22 --response-transform-timeout 10 \
|
|
229
|
+
--response-transform-warm-concurrency 0 --response-transform-resources standard \
|
|
230
|
+
--response-transform-package-json ./response/package.json --response-transform-permissions token:read
|
|
180
231
|
```
|
|
181
232
|
|
|
182
233
|
## `bt proxies delete ID`
|
|
@@ -234,35 +285,78 @@ Updates an existing Pre-Configured Proxy. Requires `proxy:update` Management App
|
|
|
234
285
|
```
|
|
235
286
|
USAGE
|
|
236
287
|
$ bt proxies update ID -x <value> [-n <value>] [-u <value>] [-q <value>] [-s <value>] [-i <value>] [-c <value>]
|
|
237
|
-
[-a] [-
|
|
288
|
+
[-a] [--request-transform-image node-bt|node22] [--request-transform-package-json <value>]
|
|
289
|
+
[--request-transform-timeout <value>] [--request-transform-warm-concurrency <value>] [--request-transform-resources
|
|
290
|
+
standard|large|xlarge] [--request-transform-permissions <value>] [--response-transform-image node-bt|node22]
|
|
291
|
+
[--response-transform-package-json <value>] [--response-transform-timeout <value>]
|
|
292
|
+
[--response-transform-warm-concurrency <value>] [--response-transform-resources standard|large|xlarge]
|
|
293
|
+
[--response-transform-permissions <value>] [--async] [-w] [-l]
|
|
238
294
|
|
|
239
295
|
ARGUMENTS
|
|
240
296
|
ID Proxy id to update
|
|
241
297
|
|
|
242
298
|
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>
|
|
299
|
+
-a, --[no-]require-auth whether the Proxy requires Basis Theory authentication to be invoked.
|
|
300
|
+
Default: true
|
|
301
|
+
-c, --configuration=<value> path to configuration file (.env format) to use in the Proxy
|
|
302
|
+
-i, --application-id=<value> application ID to use in the Proxy
|
|
303
|
+
-l, --logs Start logs server after update
|
|
304
|
+
-n, --name=<value> name of the Proxy
|
|
305
|
+
-q, --request-transform-code=<value> path to JavaScript file containing a Request Transform code
|
|
306
|
+
-s, --response-transform-code=<value> path to JavaScript file containing a Response Transform code
|
|
307
|
+
-u, --destination-url=<value> URL to which requests will be proxied
|
|
308
|
+
-w, --watch Watch for changes in informed files
|
|
309
|
+
-x, --management-key=<value> (required) management key used for connecting with the reactor / proxy
|
|
310
|
+
--async do not wait for proxy to be ready (requires at least one transform with
|
|
311
|
+
node22)
|
|
312
|
+
--request-transform-image=<option> request-transform runtime image (node-bt|node22)
|
|
313
|
+
<options: node-bt|node22>
|
|
314
|
+
--request-transform-package-json=<value> path to runtime package.json JSON file (top-level dependencies
|
|
315
|
+
required; supports resolutions or overrides fallback; pinned versions
|
|
316
|
+
required) (node22 only)
|
|
317
|
+
--request-transform-permissions=<value>... request-transform permission to grant, repeatable (node22 only)
|
|
318
|
+
--request-transform-resources=<option> request-transform resource tier (node22 only)
|
|
319
|
+
<options: standard|large|xlarge>
|
|
320
|
+
--request-transform-timeout=<value> request-transform timeout in seconds, 1-30 (node22 only)
|
|
321
|
+
--request-transform-warm-concurrency=<value> request-transform warm concurrency, 0-1 (node22 only)
|
|
322
|
+
--response-transform-image=<option> response-transform runtime image (node-bt|node22)
|
|
323
|
+
<options: node-bt|node22>
|
|
324
|
+
--response-transform-package-json=<value> path to runtime package.json JSON file (top-level dependencies
|
|
325
|
+
required; supports resolutions or overrides fallback; pinned versions
|
|
326
|
+
required) (node22 only)
|
|
327
|
+
--response-transform-permissions=<value>... response-transform permission to grant, repeatable (node22 only)
|
|
328
|
+
--response-transform-resources=<option> response-transform resource tier (node22 only)
|
|
329
|
+
<options: standard|large|xlarge>
|
|
330
|
+
--response-transform-timeout=<value> response-transform timeout in seconds, 1-30 (node22 only)
|
|
331
|
+
--response-transform-warm-concurrency=<value> response-transform warm concurrency, 0-1 (node22 only)
|
|
254
332
|
|
|
255
333
|
DESCRIPTION
|
|
256
334
|
Updates an existing Pre-Configured Proxy. Requires `proxy:update` Management Application permission
|
|
257
335
|
|
|
258
336
|
EXAMPLES
|
|
259
|
-
|
|
337
|
+
Update a proxy destination URL
|
|
338
|
+
|
|
339
|
+
$ bt proxies update <proxy-id> --destination-url https://api.example.com
|
|
340
|
+
|
|
341
|
+
Update a proxy with legacy runtime transforms
|
|
342
|
+
|
|
343
|
+
$ bt proxies update <proxy-id> --request-transform-code ./request.js --request-transform-image node-bt \
|
|
344
|
+
--application-id <application-id>
|
|
260
345
|
|
|
261
|
-
|
|
346
|
+
Update a proxy with node22 transforms
|
|
262
347
|
|
|
263
|
-
|
|
348
|
+
$ bt proxies update <proxy-id> --request-transform-code ./request.js --request-transform-image node22 \
|
|
349
|
+
--response-transform-code ./response.js --response-transform-image node22
|
|
264
350
|
|
|
265
|
-
|
|
351
|
+
Update a proxy with node22 transforms and all runtime options
|
|
352
|
+
|
|
353
|
+
$ bt proxies update <proxy-id> --name "My Proxy" --destination-url https://api.example.com --configuration \
|
|
354
|
+
./config.env --require-auth --request-transform-code ./request.js --request-transform-image node22 \
|
|
355
|
+
--request-transform-timeout 10 --request-transform-warm-concurrency 0 --request-transform-resources standard \
|
|
356
|
+
--request-transform-package-json ./request/package.json --request-transform-permissions token:read \
|
|
357
|
+
--response-transform-code ./response.js --response-transform-image node22 --response-transform-timeout 10 \
|
|
358
|
+
--response-transform-warm-concurrency 0 --response-transform-resources standard \
|
|
359
|
+
--response-transform-package-json ./response/package.json --response-transform-permissions token:read
|
|
266
360
|
```
|
|
267
361
|
|
|
268
362
|
## `bt reactors`
|
|
@@ -284,7 +378,7 @@ EXAMPLES
|
|
|
284
378
|
$ bt reactors
|
|
285
379
|
```
|
|
286
380
|
|
|
287
|
-
_See code: [dist/commands/reactors/index.ts](https://github.com/Basis-Theory-Labs/basistheory-cli/blob/
|
|
381
|
+
_See code: [dist/commands/reactors/index.ts](https://github.com/Basis-Theory-Labs/basistheory-cli/blob/v3.0.0/dist/commands/reactors/index.ts)_
|
|
288
382
|
|
|
289
383
|
## `bt reactors create`
|
|
290
384
|
|
|
@@ -292,7 +386,9 @@ Creates a new Reactor. Requires `reactor:create` Management Application permissi
|
|
|
292
386
|
|
|
293
387
|
```
|
|
294
388
|
USAGE
|
|
295
|
-
$ bt reactors create -x <value> [-n <value>] [-c <value>] [-i <value>] [-r <value>]
|
|
389
|
+
$ bt reactors create -x <value> [-n <value>] [-c <value>] [-i <value>] [-r <value>] [--image node-bt|node22]
|
|
390
|
+
[--package-json <value>] [--timeout <value>] [--warm-concurrency <value>] [--resources standard|large|xlarge]
|
|
391
|
+
[--permissions <value>] [--async]
|
|
296
392
|
|
|
297
393
|
FLAGS
|
|
298
394
|
-c, --configuration=<value> path to configuration file (.env format) to use in the Reactor
|
|
@@ -300,12 +396,34 @@ FLAGS
|
|
|
300
396
|
-n, --name=<value> name of the Reactor
|
|
301
397
|
-r, --code=<value> path to JavaScript file containing the Reactor code
|
|
302
398
|
-x, --management-key=<value> (required) management key used for connecting with the reactor / proxy
|
|
399
|
+
--async do not wait for resource to be ready (node22 only)
|
|
400
|
+
--image=<option> runtime image (node-bt|node22)
|
|
401
|
+
<options: node-bt|node22>
|
|
402
|
+
--package-json=<value> path to runtime package.json JSON file (top-level dependencies required; supports
|
|
403
|
+
resolutions or overrides fallback; pinned versions required) (node22 only)
|
|
404
|
+
--permissions=<value>... permission to grant, repeatable (node22 only)
|
|
405
|
+
--resources=<option> resource tier (node22 only, default: standard)
|
|
406
|
+
<options: standard|large|xlarge>
|
|
407
|
+
--timeout=<value> timeout in seconds, 1-30 (node22 only, default: 10)
|
|
408
|
+
--warm-concurrency=<value> number of warm instances, 0-1 (node22 only, default: 0)
|
|
303
409
|
|
|
304
410
|
DESCRIPTION
|
|
305
411
|
Creates a new Reactor. Requires `reactor:create` Management Application permission
|
|
306
412
|
|
|
307
413
|
EXAMPLES
|
|
308
|
-
|
|
414
|
+
Create a reactor with legacy runtime
|
|
415
|
+
|
|
416
|
+
$ bt reactors create --name "My Reactor" --code ./reactor.js --image node-bt --application-id <application-id>
|
|
417
|
+
|
|
418
|
+
Create a reactor with node22 runtime
|
|
419
|
+
|
|
420
|
+
$ bt reactors create --name "My Reactor" --code ./reactor.js --image node22
|
|
421
|
+
|
|
422
|
+
Create a reactor with node22 and all runtime options
|
|
423
|
+
|
|
424
|
+
$ bt reactors create --name "My Reactor" --code ./reactor.js --configuration ./config.env --image node22 \
|
|
425
|
+
--timeout 10 --warm-concurrency 0 --resources standard --package-json ./package.json --permissions token:read \
|
|
426
|
+
--permissions token:create
|
|
309
427
|
```
|
|
310
428
|
|
|
311
429
|
## `bt reactors delete ID`
|
|
@@ -362,7 +480,9 @@ Updates an existing Reactor. Requires `reactor:update` Management Application pe
|
|
|
362
480
|
|
|
363
481
|
```
|
|
364
482
|
USAGE
|
|
365
|
-
$ bt reactors update ID -x <value> [-n <value>] [-c <value>] [-i <value>] [-r <value>] [
|
|
483
|
+
$ bt reactors update ID -x <value> [-n <value>] [-c <value>] [-i <value>] [-r <value>] [--image node-bt|node22]
|
|
484
|
+
[--package-json <value>] [--timeout <value>] [--warm-concurrency <value>] [--resources standard|large|xlarge]
|
|
485
|
+
[--permissions <value>] [--async] [-w] [-l]
|
|
366
486
|
|
|
367
487
|
ARGUMENTS
|
|
368
488
|
ID Reactor id to update
|
|
@@ -375,15 +495,33 @@ FLAGS
|
|
|
375
495
|
-r, --code=<value> path to JavaScript file containing the Reactor code
|
|
376
496
|
-w, --watch Watch for changes in informed files
|
|
377
497
|
-x, --management-key=<value> (required) management key used for connecting with the reactor / proxy
|
|
498
|
+
--async do not wait for resource to be ready (node22 only)
|
|
499
|
+
--image=<option> runtime image (node-bt|node22)
|
|
500
|
+
<options: node-bt|node22>
|
|
501
|
+
--package-json=<value> path to runtime package.json JSON file (top-level dependencies required; supports
|
|
502
|
+
resolutions or overrides fallback; pinned versions required) (node22 only)
|
|
503
|
+
--permissions=<value>... permission to grant, repeatable (node22 only)
|
|
504
|
+
--resources=<option> resource tier (node22 only, default: standard)
|
|
505
|
+
<options: standard|large|xlarge>
|
|
506
|
+
--timeout=<value> timeout in seconds, 1-30 (node22 only, default: 10)
|
|
507
|
+
--warm-concurrency=<value> number of warm instances, 0-1 (node22 only, default: 0)
|
|
378
508
|
|
|
379
509
|
DESCRIPTION
|
|
380
510
|
Updates an existing Reactor. Requires `reactor:update` Management Application permission
|
|
381
511
|
|
|
382
512
|
EXAMPLES
|
|
383
|
-
|
|
513
|
+
Update a reactor with legacy runtime
|
|
514
|
+
|
|
515
|
+
$ bt reactors update <reactor-id> --code ./reactor.js --image node-bt --application-id <application-id>
|
|
516
|
+
|
|
517
|
+
Update a reactor with node22 runtime
|
|
518
|
+
|
|
519
|
+
$ bt reactors update <reactor-id> --code ./reactor.js --image node22
|
|
384
520
|
|
|
385
|
-
|
|
521
|
+
Update a reactor with node22 and all runtime options
|
|
386
522
|
|
|
387
|
-
|
|
523
|
+
$ bt reactors update <reactor-id> --name "My Reactor" --code ./reactor.js --configuration ./config.env --image \
|
|
524
|
+
node22 --timeout 10 --warm-concurrency 0 --resources standard --package-json ./package.json --permissions \
|
|
525
|
+
token:read --permissions token:create
|
|
388
526
|
```
|
|
389
527
|
<!-- 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-package-json': 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-package-json': 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-package-json ./request/package.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-package-json ./response/package.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-package-json': 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-package-json': 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>>;
|