@twilio-labs/plugin-flex 4.10.0-alpha.0 → 5.0.1-dev.202202170426

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 (68) hide show
  1. package/README.md +51 -26
  2. package/dist/clients/FlexConfigurationClient.d.ts +1 -1
  3. package/dist/clients/FlexConfigurationClient.js +9 -3
  4. package/dist/clients/FlexConfigurationClient.js.map +1 -1
  5. package/dist/clients/ServerlessClient.d.ts +28 -1
  6. package/dist/clients/ServerlessClient.js +54 -3
  7. package/dist/clients/ServerlessClient.js.map +1 -1
  8. package/dist/commands/flex/plugins/archive/configuration.d.ts +1 -1
  9. package/dist/commands/flex/plugins/archive/plugin-version.d.ts +23 -1
  10. package/dist/commands/flex/plugins/archive/plugin-version.js +86 -1
  11. package/dist/commands/flex/plugins/archive/plugin-version.js.map +1 -1
  12. package/dist/commands/flex/plugins/archive/plugin.d.ts +12 -1
  13. package/dist/commands/flex/plugins/archive/plugin.js +54 -1
  14. package/dist/commands/flex/plugins/archive/plugin.js.map +1 -1
  15. package/dist/commands/flex/plugins/create.js +1 -1
  16. package/dist/commands/flex/plugins/create.js.map +1 -1
  17. package/dist/commands/flex/plugins/deploy.d.ts +4 -4
  18. package/dist/commands/flex/plugins/deploy.js +8 -7
  19. package/dist/commands/flex/plugins/deploy.js.map +1 -1
  20. package/dist/commands/flex/plugins/describe/configuration.d.ts +1 -1
  21. package/dist/commands/flex/plugins/describe/plugin-version.d.ts +1 -1
  22. package/dist/commands/flex/plugins/describe/plugin.d.ts +1 -1
  23. package/dist/commands/flex/plugins/describe/release.d.ts +1 -1
  24. package/dist/commands/flex/plugins/describe/release.js +1 -1
  25. package/dist/commands/flex/plugins/describe/release.js.map +1 -1
  26. package/dist/commands/flex/plugins/diff.d.ts +1 -2
  27. package/dist/commands/flex/plugins/diff.js +2 -1
  28. package/dist/commands/flex/plugins/diff.js.map +1 -1
  29. package/dist/commands/flex/plugins/list/configurations.d.ts +1 -1
  30. package/dist/commands/flex/plugins/list/plugin-versions.d.ts +1 -1
  31. package/dist/commands/flex/plugins/list/plugins.d.ts +1 -1
  32. package/dist/commands/flex/plugins/list/releases.d.ts +1 -1
  33. package/dist/commands/flex/plugins/release.d.ts +4 -4
  34. package/dist/commands/flex/plugins/release.js +16 -10
  35. package/dist/commands/flex/plugins/release.js.map +1 -1
  36. package/dist/commands/flex/plugins/start.d.ts +19 -0
  37. package/dist/commands/flex/plugins/start.js +90 -20
  38. package/dist/commands/flex/plugins/start.js.map +1 -1
  39. package/dist/commands/flex/plugins/test.js +1 -1
  40. package/dist/commands/flex/plugins/test.js.map +1 -1
  41. package/dist/commands/flex/plugins/upgrade-plugin.js +40 -25
  42. package/dist/commands/flex/plugins/upgrade-plugin.js.map +1 -1
  43. package/dist/prints/archiveResource.d.ts +1 -1
  44. package/dist/prints/archiveResource.js.map +1 -1
  45. package/dist/prints/deploy.d.ts +3 -3
  46. package/dist/prints/deploy.js +11 -3
  47. package/dist/prints/deploy.js.map +1 -1
  48. package/dist/prints/flexPlugin.d.ts +1 -1
  49. package/dist/prints/index.d.ts +3 -3
  50. package/dist/prints/release.d.ts +1 -1
  51. package/dist/prints/upgradePlugin.d.ts +2 -2
  52. package/dist/prints/upgradePlugin.js +4 -3
  53. package/dist/prints/upgradePlugin.js.map +1 -1
  54. package/dist/sub-commands/archive-resource.js +5 -2
  55. package/dist/sub-commands/archive-resource.js.map +1 -1
  56. package/dist/sub-commands/create-configuration.d.ts +1 -1
  57. package/dist/sub-commands/create-configuration.js +1 -1
  58. package/dist/sub-commands/create-configuration.js.map +1 -1
  59. package/dist/sub-commands/flex-plugin.d.ts +16 -10
  60. package/dist/sub-commands/flex-plugin.js +66 -28
  61. package/dist/sub-commands/flex-plugin.js.map +1 -1
  62. package/dist/sub-commands/information-flex-plugin.js +1 -1
  63. package/dist/sub-commands/information-flex-plugin.js.map +1 -1
  64. package/dist/utils/config.js +1 -1
  65. package/dist/utils/config.js.map +1 -1
  66. package/dist/utils/parser.js.map +1 -1
  67. package/oclif.manifest.json +1 -1
  68. package/package.json +31 -26
package/README.md CHANGED
@@ -78,9 +78,10 @@ OPTIONS
78
78
  -p, --profile=profile Shorthand identifier for your profile.
79
79
  --clear-terminal Clears the terminal before running the command.
80
80
  --sid=sid (required) The Flex Plugin Configuration SID to archive.
81
+ --silent Suppress output and logs. This is a shorthand for "-l none -o none".
81
82
  ```
82
83
 
83
- _See code: [dist/commands/flex/plugins/archive/configuration.js](https://github.com/twilio/flex-plugin-builder/blob/v4.10.0-alpha.0/dist/commands/flex/plugins/archive/configuration.js)_
84
+ _See code: [dist/commands/flex/plugins/archive/configuration.js](https://github.com/twilio/flex-plugin-builder/blob/v5.0.1-dev.202202170426/dist/commands/flex/plugins/archive/configuration.js)_
84
85
 
85
86
  ## `twilio flex:plugins:archive:plugin`
86
87
 
@@ -95,9 +96,10 @@ OPTIONS
95
96
  -p, --profile=profile Shorthand identifier for your profile.
96
97
  --clear-terminal Clears the terminal before running the command.
97
98
  --name=name (required) The name of the Flex Plugin to archive.
99
+ --silent Suppress output and logs. This is a shorthand for "-l none -o none".
98
100
  ```
99
101
 
100
- _See code: [dist/commands/flex/plugins/archive/plugin.js](https://github.com/twilio/flex-plugin-builder/blob/v4.10.0-alpha.0/dist/commands/flex/plugins/archive/plugin.js)_
102
+ _See code: [dist/commands/flex/plugins/archive/plugin.js](https://github.com/twilio/flex-plugin-builder/blob/v5.0.1-dev.202202170426/dist/commands/flex/plugins/archive/plugin.js)_
101
103
 
102
104
  ## `twilio flex:plugins:archive:plugin-version`
103
105
 
@@ -112,10 +114,11 @@ OPTIONS
112
114
  -p, --profile=profile Shorthand identifier for your profile.
113
115
  --clear-terminal Clears the terminal before running the command.
114
116
  --name=name (required) The Flex Plugin name of the Plugin Version to archive.
117
+ --silent Suppress output and logs. This is a shorthand for "-l none -o none".
115
118
  --version=version (required) The Flex Plugin Version to archive.
116
119
  ```
117
120
 
118
- _See code: [dist/commands/flex/plugins/archive/plugin-version.js](https://github.com/twilio/flex-plugin-builder/blob/v4.10.0-alpha.0/dist/commands/flex/plugins/archive/plugin-version.js)_
121
+ _See code: [dist/commands/flex/plugins/archive/plugin-version.js](https://github.com/twilio/flex-plugin-builder/blob/v5.0.1-dev.202202170426/dist/commands/flex/plugins/archive/plugin-version.js)_
119
122
 
120
123
  ## `twilio flex:plugins:build`
121
124
 
@@ -129,9 +132,10 @@ OPTIONS
129
132
  -l=(debug|info|warn|error|none) [default: info] Level of logging messages.
130
133
  -p, --profile=profile Shorthand identifier for your profile.
131
134
  --clear-terminal Clears the terminal before running the command.
135
+ --silent Suppress output and logs. This is a shorthand for "-l none -o none".
132
136
  ```
133
137
 
134
- _See code: [dist/commands/flex/plugins/build.js](https://github.com/twilio/flex-plugin-builder/blob/v4.10.0-alpha.0/dist/commands/flex/plugins/build.js)_
138
+ _See code: [dist/commands/flex/plugins/build.js](https://github.com/twilio/flex-plugin-builder/blob/v5.0.1-dev.202202170426/dist/commands/flex/plugins/build.js)_
135
139
 
136
140
  ## `twilio flex:plugins:create NAME`
137
141
 
@@ -158,11 +162,11 @@ OPTIONS
158
162
  -y, --yarn Use yarn as your dependency manager
159
163
 
160
164
  DESCRIPTION
161
- Arguments:
165
+ Arguments:
162
166
  name Name of your plugin. This command needs to be invoked inside a plugin directory.
163
167
  ```
164
168
 
165
- _See code: [dist/commands/flex/plugins/create.js](https://github.com/twilio/flex-plugin-builder/blob/v4.10.0-alpha.0/dist/commands/flex/plugins/create.js)_
169
+ _See code: [dist/commands/flex/plugins/create.js](https://github.com/twilio/flex-plugin-builder/blob/v5.0.1-dev.202202170426/dist/commands/flex/plugins/create.js)_
166
170
 
167
171
  ## `twilio flex:plugins:create-configuration`
168
172
 
@@ -187,16 +191,18 @@ OPTIONS
187
191
  as a shortcut for enabling the latest version of the plugin. Use additional
188
192
  --enable-plugin to provide other plugins to enable.
189
193
 
190
- --name=name (required) [default: Autogenerated Release 1621275337196] The friendly name of the
194
+ --name=name (required) [default: Autogenerated Release 1645072225872] The friendly name of the
191
195
  Flex Plugin Configuration.
192
196
 
193
197
  --new Creates a new Flex Plugin Configuration, otherwise will append to existing active
194
198
  Configuration.
195
199
 
196
200
  --plugin=plugin Alias for --enable-plugin.
201
+
202
+ --silent Suppress output and logs. This is a shorthand for "-l none -o none".
197
203
  ```
198
204
 
199
- _See code: [dist/commands/flex/plugins/create-configuration.js](https://github.com/twilio/flex-plugin-builder/blob/v4.10.0-alpha.0/dist/commands/flex/plugins/create-configuration.js)_
205
+ _See code: [dist/commands/flex/plugins/create-configuration.js](https://github.com/twilio/flex-plugin-builder/blob/v5.0.1-dev.202202170426/dist/commands/flex/plugins/create-configuration.js)_
200
206
 
201
207
  ## `twilio flex:plugins:deploy`
202
208
 
@@ -216,10 +222,11 @@ OPTIONS
216
222
  --minor Publishes the version as a minor (SemVer).
217
223
  --patch Publishes the version as a patch (SemVer); this is the default.
218
224
  --public Publishes the plugin as a public Twilio Asset; default is private.
225
+ --silent Suppress output and logs. This is a shorthand for "-l none -o none".
219
226
  --version=version Publishes the version (SemVer).
220
227
  ```
221
228
 
222
- _See code: [dist/commands/flex/plugins/deploy.js](https://github.com/twilio/flex-plugin-builder/blob/v4.10.0-alpha.0/dist/commands/flex/plugins/deploy.js)_
229
+ _See code: [dist/commands/flex/plugins/deploy.js](https://github.com/twilio/flex-plugin-builder/blob/v5.0.1-dev.202202170426/dist/commands/flex/plugins/deploy.js)_
223
230
 
224
231
  ## `twilio flex:plugins:describe:configuration`
225
232
 
@@ -235,9 +242,10 @@ OPTIONS
235
242
  --clear-terminal Clears the terminal before running the command.
236
243
  --json Outputs the result of the command as json string.
237
244
  --sid=sid (required) The Flex Plugin Configuration SID.
245
+ --silent Suppress output and logs. This is a shorthand for "-l none -o none".
238
246
  ```
239
247
 
240
- _See code: [dist/commands/flex/plugins/describe/configuration.js](https://github.com/twilio/flex-plugin-builder/blob/v4.10.0-alpha.0/dist/commands/flex/plugins/describe/configuration.js)_
248
+ _See code: [dist/commands/flex/plugins/describe/configuration.js](https://github.com/twilio/flex-plugin-builder/blob/v5.0.1-dev.202202170426/dist/commands/flex/plugins/describe/configuration.js)_
241
249
 
242
250
  ## `twilio flex:plugins:describe:plugin`
243
251
 
@@ -253,9 +261,10 @@ OPTIONS
253
261
  --clear-terminal Clears the terminal before running the command.
254
262
  --json Outputs the result of the command as json string.
255
263
  --name=name (required) The name of the Flex Plugin to describe.
264
+ --silent Suppress output and logs. This is a shorthand for "-l none -o none".
256
265
  ```
257
266
 
258
- _See code: [dist/commands/flex/plugins/describe/plugin.js](https://github.com/twilio/flex-plugin-builder/blob/v4.10.0-alpha.0/dist/commands/flex/plugins/describe/plugin.js)_
267
+ _See code: [dist/commands/flex/plugins/describe/plugin.js](https://github.com/twilio/flex-plugin-builder/blob/v5.0.1-dev.202202170426/dist/commands/flex/plugins/describe/plugin.js)_
259
268
 
260
269
  ## `twilio flex:plugins:describe:plugin-version`
261
270
 
@@ -271,10 +280,11 @@ OPTIONS
271
280
  --clear-terminal Clears the terminal before running the command.
272
281
  --json Outputs the result of the command as json string.
273
282
  --name=name (required) The Flex Plugin name of the Plugin Version to describe.
283
+ --silent Suppress output and logs. This is a shorthand for "-l none -o none".
274
284
  --version=version (required) The Flex Plugin Version to describe.
275
285
  ```
276
286
 
277
- _See code: [dist/commands/flex/plugins/describe/plugin-version.js](https://github.com/twilio/flex-plugin-builder/blob/v4.10.0-alpha.0/dist/commands/flex/plugins/describe/plugin-version.js)_
287
+ _See code: [dist/commands/flex/plugins/describe/plugin-version.js](https://github.com/twilio/flex-plugin-builder/blob/v5.0.1-dev.202202170426/dist/commands/flex/plugins/describe/plugin-version.js)_
278
288
 
279
289
  ## `twilio flex:plugins:describe:release`
280
290
 
@@ -291,9 +301,10 @@ OPTIONS
291
301
  --clear-terminal Clears the terminal before running the command.
292
302
  --json Outputs the result of the command as json string.
293
303
  --sid=sid The Flex Plugin Release SID to describe.
304
+ --silent Suppress output and logs. This is a shorthand for "-l none -o none".
294
305
  ```
295
306
 
296
- _See code: [dist/commands/flex/plugins/describe/release.js](https://github.com/twilio/flex-plugin-builder/blob/v4.10.0-alpha.0/dist/commands/flex/plugins/describe/release.js)_
307
+ _See code: [dist/commands/flex/plugins/describe/release.js](https://github.com/twilio/flex-plugin-builder/blob/v5.0.1-dev.202202170426/dist/commands/flex/plugins/describe/release.js)_
297
308
 
298
309
  ## `twilio flex:plugins:diff ID1 [ID2]`
299
310
 
@@ -311,9 +322,10 @@ OPTIONS
311
322
  -l=(debug|info|warn|error|none) [default: info] Level of logging messages.
312
323
  -p, --profile=profile Shorthand identifier for your profile.
313
324
  --clear-terminal Clears the terminal before running the command.
325
+ --silent Suppress output and logs. This is a shorthand for "-l none -o none".
314
326
  ```
315
327
 
316
- _See code: [dist/commands/flex/plugins/diff.js](https://github.com/twilio/flex-plugin-builder/blob/v4.10.0-alpha.0/dist/commands/flex/plugins/diff.js)_
328
+ _See code: [dist/commands/flex/plugins/diff.js](https://github.com/twilio/flex-plugin-builder/blob/v5.0.1-dev.202202170426/dist/commands/flex/plugins/diff.js)_
317
329
 
318
330
  ## `twilio flex:plugins:list:configurations`
319
331
 
@@ -328,9 +340,10 @@ OPTIONS
328
340
  -p, --profile=profile Shorthand identifier for your profile.
329
341
  --clear-terminal Clears the terminal before running the command.
330
342
  --json Outputs the result of the command as json string.
343
+ --silent Suppress output and logs. This is a shorthand for "-l none -o none".
331
344
  ```
332
345
 
333
- _See code: [dist/commands/flex/plugins/list/configurations.js](https://github.com/twilio/flex-plugin-builder/blob/v4.10.0-alpha.0/dist/commands/flex/plugins/list/configurations.js)_
346
+ _See code: [dist/commands/flex/plugins/list/configurations.js](https://github.com/twilio/flex-plugin-builder/blob/v5.0.1-dev.202202170426/dist/commands/flex/plugins/list/configurations.js)_
334
347
 
335
348
  ## `twilio flex:plugins:list:plugin-versions`
336
349
 
@@ -346,9 +359,10 @@ OPTIONS
346
359
  --clear-terminal Clears the terminal before running the command.
347
360
  --json Outputs the result of the command as json string.
348
361
  --name=name (required) The plugin name to list its versions.
362
+ --silent Suppress output and logs. This is a shorthand for "-l none -o none".
349
363
  ```
350
364
 
351
- _See code: [dist/commands/flex/plugins/list/plugin-versions.js](https://github.com/twilio/flex-plugin-builder/blob/v4.10.0-alpha.0/dist/commands/flex/plugins/list/plugin-versions.js)_
365
+ _See code: [dist/commands/flex/plugins/list/plugin-versions.js](https://github.com/twilio/flex-plugin-builder/blob/v5.0.1-dev.202202170426/dist/commands/flex/plugins/list/plugin-versions.js)_
352
366
 
353
367
  ## `twilio flex:plugins:list:plugins`
354
368
 
@@ -363,9 +377,10 @@ OPTIONS
363
377
  -p, --profile=profile Shorthand identifier for your profile.
364
378
  --clear-terminal Clears the terminal before running the command.
365
379
  --json Outputs the result of the command as json string.
380
+ --silent Suppress output and logs. This is a shorthand for "-l none -o none".
366
381
  ```
367
382
 
368
- _See code: [dist/commands/flex/plugins/list/plugins.js](https://github.com/twilio/flex-plugin-builder/blob/v4.10.0-alpha.0/dist/commands/flex/plugins/list/plugins.js)_
383
+ _See code: [dist/commands/flex/plugins/list/plugins.js](https://github.com/twilio/flex-plugin-builder/blob/v5.0.1-dev.202202170426/dist/commands/flex/plugins/list/plugins.js)_
369
384
 
370
385
  ## `twilio flex:plugins:list:releases`
371
386
 
@@ -380,9 +395,10 @@ OPTIONS
380
395
  -p, --profile=profile Shorthand identifier for your profile.
381
396
  --clear-terminal Clears the terminal before running the command.
382
397
  --json Outputs the result of the command as json string.
398
+ --silent Suppress output and logs. This is a shorthand for "-l none -o none".
383
399
  ```
384
400
 
385
- _See code: [dist/commands/flex/plugins/list/releases.js](https://github.com/twilio/flex-plugin-builder/blob/v4.10.0-alpha.0/dist/commands/flex/plugins/list/releases.js)_
401
+ _See code: [dist/commands/flex/plugins/list/releases.js](https://github.com/twilio/flex-plugin-builder/blob/v5.0.1-dev.202202170426/dist/commands/flex/plugins/list/releases.js)_
386
402
 
387
403
  ## `twilio flex:plugins:release`
388
404
 
@@ -410,16 +426,18 @@ OPTIONS
410
426
  pluginName@latest as a shortcut for enabling the latest version of the plugin.
411
427
  Use additional --enable-plugin to provide other plugins to enable.
412
428
 
413
- --name=name [default: Autogenerated Release 1621275337196] The friendly name of the Flex
429
+ --name=name [default: Autogenerated Release 1645072225872] The friendly name of the Flex
414
430
  Plugin Configuration.
415
431
 
416
432
  --new Creates a new Flex Plugin Configuration, otherwise will append to existing
417
433
  active Configuration.
418
434
 
419
435
  --plugin=plugin Alias for --enable-plugin.
436
+
437
+ --silent Suppress output and logs. This is a shorthand for "-l none -o none".
420
438
  ```
421
439
 
422
- _See code: [dist/commands/flex/plugins/release.js](https://github.com/twilio/flex-plugin-builder/blob/v4.10.0-alpha.0/dist/commands/flex/plugins/release.js)_
440
+ _See code: [dist/commands/flex/plugins/release.js](https://github.com/twilio/flex-plugin-builder/blob/v5.0.1-dev.202202170426/dist/commands/flex/plugins/release.js)_
423
441
 
424
442
  ## `twilio flex:plugins:start`
425
443
 
@@ -433,14 +451,18 @@ OPTIONS
433
451
  -l=(debug|info|warn|error|none) [default: info] Level of logging messages.
434
452
  -p, --profile=profile Shorthand identifier for your profile.
435
453
  --clear-terminal Clears the terminal before running the command.
436
- --include-remote Use this flag to include all remote plugins in your build (in Pilot).
454
+ --include-remote Use this flag to include all remote plugins in your build.
437
455
 
438
456
  --name=name The name of the plugin you would like to run. You can provide multiple to run them
439
- all concurrently in the dev-environment (in Pilot). You can include specific active
440
- remote plugins using "--name 'plugin-name@remote'".
457
+ all concurrently. You can include specific active remote plugins using "--name
458
+ 'plugin-name@remote'" or "--name 'plugin-name@0.0.0'" for a specific remote version.
459
+
460
+ --port=port [default: 3000] The port to start your local development server on.
461
+
462
+ --silent Suppress output and logs. This is a shorthand for "-l none -o none".
441
463
  ```
442
464
 
443
- _See code: [dist/commands/flex/plugins/start.js](https://github.com/twilio/flex-plugin-builder/blob/v4.10.0-alpha.0/dist/commands/flex/plugins/start.js)_
465
+ _See code: [dist/commands/flex/plugins/start.js](https://github.com/twilio/flex-plugin-builder/blob/v5.0.1-dev.202202170426/dist/commands/flex/plugins/start.js)_
444
466
 
445
467
  ## `twilio flex:plugins:test`
446
468
 
@@ -454,9 +476,10 @@ OPTIONS
454
476
  -l=(debug|info|warn|error|none) [default: info] Level of logging messages.
455
477
  -p, --profile=profile Shorthand identifier for your profile.
456
478
  --clear-terminal Clears the terminal before running the command.
479
+ --silent Suppress output and logs. This is a shorthand for "-l none -o none".
457
480
  ```
458
481
 
459
- _See code: [dist/commands/flex/plugins/test.js](https://github.com/twilio/flex-plugin-builder/blob/v4.10.0-alpha.0/dist/commands/flex/plugins/test.js)_
482
+ _See code: [dist/commands/flex/plugins/test.js](https://github.com/twilio/flex-plugin-builder/blob/v5.0.1-dev.202202170426/dist/commands/flex/plugins/test.js)_
460
483
 
461
484
  ## `twilio flex:plugins:upgrade-plugin`
462
485
 
@@ -478,10 +501,12 @@ OPTIONS
478
501
  --remove-legacy-plugin Deletes legacy plugin bundle hosted on Twilio Assets (deployed via plugin builder
479
502
  v3).
480
503
 
504
+ --silent Suppress output and logs. This is a shorthand for "-l none -o none".
505
+
481
506
  --yarn Use yarn for installation.
482
507
 
483
508
  --yes If set, will answer yes to all prompts.
484
509
  ```
485
510
 
486
- _See code: [dist/commands/flex/plugins/upgrade-plugin.js](https://github.com/twilio/flex-plugin-builder/blob/v4.10.0-alpha.0/dist/commands/flex/plugins/upgrade-plugin.js)_
511
+ _See code: [dist/commands/flex/plugins/upgrade-plugin.js](https://github.com/twilio/flex-plugin-builder/blob/v5.0.1-dev.202202170426/dist/commands/flex/plugins/upgrade-plugin.js)_
487
512
  <!-- commandsstop -->
@@ -3,7 +3,7 @@ export interface FlexConfigurationClientOptions {
3
3
  accountSid: string;
4
4
  username: string;
5
5
  password: string;
6
- realm?: 'dev' | 'stage';
6
+ region?: 'dev' | 'stage';
7
7
  }
8
8
  /**
9
9
  * Wrapper Twilio Flex Configuration Public API
@@ -3,8 +3,9 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
+ const flex_dev_utils_1 = require("@twilio/flex-dev-utils");
7
+ const https_proxy_agent_1 = require("https-proxy-agent");
6
8
  const phin_1 = __importDefault(require("phin"));
7
- const flex_dev_utils_1 = require("flex-dev-utils");
8
9
  /**
9
10
  * Wrapper Twilio Flex Configuration Public API
10
11
  */
@@ -66,9 +67,11 @@ class FlexConfigurationClient {
66
67
  const auth = Buffer.from(`${this.options.username}:${this.options.password}`, 'utf8').toString('base64');
67
68
  // eslint-disable-next-line camelcase
68
69
  const data = { account_sid: this.options.accountSid, serverless_service_sids: sids };
69
- const url = this.options.realm
70
- ? `https://flex-api.${this.options.realm}.twilio.com/v1/Configuration`
70
+ const url = this.options.region
71
+ ? `https://flex-api.${this.options.region}.twilio.com/v1/Configuration`
71
72
  : 'https://flex-api.twilio.com/v1/Configuration';
73
+ // use proxy
74
+ const agent = process.env.HTTP_PROXY ? new https_proxy_agent_1.HttpsProxyAgent(process.env.HTTP_PROXY) : undefined;
72
75
  const response = await phin_1.default({
73
76
  url,
74
77
  method: 'POST',
@@ -78,6 +81,9 @@ class FlexConfigurationClient {
78
81
  },
79
82
  parse: 'json',
80
83
  data,
84
+ core: {
85
+ agent,
86
+ },
81
87
  });
82
88
  if (response.statusCode !== 200) {
83
89
  throw new flex_dev_utils_1.TwilioCliError(response.body);
@@ -1 +1 @@
1
- {"version":3,"file":"FlexConfigurationClient.js","sourceRoot":"","sources":["../../src/clients/FlexConfigurationClient.ts"],"names":[],"mappings":";;;;;AAAA,gDAAwB;AAExB,mDAAgD;AAShD;;GAEG;AACH,MAAqB,uBAAuB;IAK1C,YAAY,MAA4B,EAAE,OAAuC;QAC/E,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;IACzB,CAAC;IAED;;OAEG;IACI,KAAK,CAAC,KAAK;QAChB,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G;IACK,KAAK,CAAC,oBAAoB,CAAC,IAAc;QAC/C,MAAM,IAAI,GAAG,MAAM,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC,OAAO,CAAC,QAAQ,IAAI,IAAI,CAAC,OAAO,CAAC,QAAQ,EAAE,EAAE,MAAM,CAAC,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;QACzG,qCAAqC;QACrC,MAAM,IAAI,GAAG,EAAE,WAAW,EAAE,IAAI,CAAC,OAAO,CAAC,UAAU,EAAE,uBAAuB,EAAE,IAAI,EAAE,CAAC;QACrF,MAAM,GAAG,GAAG,IAAI,CAAC,OAAO,CAAC,MAAM;YAC7B,CAAC,CAAC,oBAAoB,IAAI,CAAC,OAAO,CAAC,MAAM,8BAA8B;YACvE,CAAC,CAAC,8CAA8C,CAAC;QAEnD,YAAY;QACZ,MAAM,KAAK,GAAG,OAAO,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC,CAAC,IAAI,mCAAe,CAAC,OAAO,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;QAE/F,MAAM,QAAQ,GAAG,MAAM,cAAI,CAAC;YAC1B,GAAG;YACH,MAAM,EAAE,MAAM;YACd,OAAO,EAAE;gBACP,cAAc,EAAE,kBAAkB;gBAClC,aAAa,EAAE,SAAS,IAAI,EAAE;aAC/B;YACD,KAAK,EAAE,MAAM;YACb,IAAI;YACJ,IAAI,EAAE;gBACJ,KAAK;aACN;SACF,CAAC,CAAC;QACH,IAAI,QAAQ,CAAC,UAAU,KAAK,GAAG,EAAE;YAC/B,MAAM,IAAI,+BAAc,CAAC,QAAQ,CAAC,IAAc,CAAC,CAAC;SACnD;IACH,CAAC;CACF;AAjGD,0CAiGC"}
@@ -1,5 +1,7 @@
1
1
  import { ServiceInstance, ServiceListInstance, ServiceListInstanceCreateOptions } from 'twilio/lib/rest/serverless/v1/service';
2
- import { Logger } from 'flex-dev-utils';
2
+ import { BuildInstance, BuildListInstanceCreateOptions } from 'twilio/lib/rest/serverless/v1/service/build';
3
+ import { Logger } from '@twilio/flex-dev-utils';
4
+ import { EnvironmentInstance } from 'twilio/lib/rest/serverless/v1/service/environment';
3
5
  /**
4
6
  * Wrapper Twilio Serverless Public API
5
7
  */
@@ -40,6 +42,31 @@ export default class ServerlessClient {
40
42
  * @param pluginName the plugin name
41
43
  */
42
44
  removeLegacy(serviceSid: string, pluginName: string): Promise<void>;
45
+ /**
46
+ * Creates a {@link BuildInstance} and deploys/activates it
47
+ * @param serviceSid the serviceSid the {@link BuildInstance} belongs to
48
+ * @param pluginName the plugin name that the build belongs to
49
+ * @param request the {@link BuildListInstanceCreateOptions} option
50
+ */
51
+ createBuildAndDeploy(serviceSid: string, pluginName: string, request: BuildListInstanceCreateOptions): Promise<void>;
52
+ /**
53
+ * Returns the {@link BuildInstance} belonging to the plugin name
54
+ * @param serviceSid the service sid
55
+ * @param pluginName the plugin name
56
+ */
57
+ getBuild(serviceSid: string, pluginName: string): Promise<BuildInstance | undefined>;
58
+ /**
59
+ * Deletes the {@link EnvironmentInstance}
60
+ * @param serviceSid the service sid
61
+ * @param environment the environment sid
62
+ */
63
+ deleteEnvironment(serviceSid: string, environmentSid: string): Promise<boolean>;
64
+ /**
65
+ * Returns the {@link EnvironmentInstance}
66
+ * @param serviceSid the service sid
67
+ * @param pluginName the plugin name
68
+ */
69
+ getEnvironment(serviceSid: string, pluginName: string): Promise<EnvironmentInstance | null>;
43
70
  /**
44
71
  * Fetches the {@link BuildInstance}
45
72
  * @param serviceSid the service sid
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- const flex_dev_utils_1 = require("flex-dev-utils");
3
+ const flex_dev_utils_1 = require("@twilio/flex-dev-utils");
4
4
  /**
5
5
  * Wrapper Twilio Serverless Public API
6
6
  */
@@ -72,15 +72,66 @@ class ServerlessClient {
72
72
  .filter((asset) => !asset.path.includes(`/plugins/${pluginName}/0.0.0/bundle.js`))
73
73
  .map((asset) => asset.sid);
74
74
  const functions = build.functionVersions.map((func) => func).map((func) => func.sid);
75
- const data = {
75
+ const request = {
76
76
  assetVersions: assets,
77
77
  functionVersions: functions,
78
78
  // @ts-ignore this is a type definition error in Twilio; dependencies should be object[] not a string
79
79
  dependencies: build.dependencies,
80
80
  };
81
- const newBuild = await this.createBuild(serviceSid, data);
81
+ await this.createBuildAndDeploy(serviceSid, pluginName, request);
82
+ }
83
+ /**
84
+ * Creates a {@link BuildInstance} and deploys/activates it
85
+ * @param serviceSid the serviceSid the {@link BuildInstance} belongs to
86
+ * @param pluginName the plugin name that the build belongs to
87
+ * @param request the {@link BuildListInstanceCreateOptions} option
88
+ */
89
+ async createBuildAndDeploy(serviceSid, pluginName, request) {
90
+ const { environment } = await this.getBuildAndEnvironment(serviceSid, pluginName);
91
+ if (!environment) {
92
+ return;
93
+ }
94
+ const newBuild = await this.createBuild(serviceSid, request);
82
95
  await environment.deployments().create({ buildSid: newBuild.sid });
83
96
  }
97
+ /**
98
+ * Returns the {@link BuildInstance} belonging to the plugin name
99
+ * @param serviceSid the service sid
100
+ * @param pluginName the plugin name
101
+ */
102
+ async getBuild(serviceSid, pluginName) {
103
+ const { build } = await this.getBuildAndEnvironment(serviceSid, pluginName);
104
+ return build;
105
+ }
106
+ /**
107
+ * Deletes the {@link EnvironmentInstance}
108
+ * @param serviceSid the service sid
109
+ * @param environment the environment sid
110
+ */
111
+ async deleteEnvironment(serviceSid, environmentSid) {
112
+ const service = await this.getService(serviceSid);
113
+ if (!service) {
114
+ return false;
115
+ }
116
+ return service.environments().get(environmentSid).remove();
117
+ }
118
+ /**
119
+ * Returns the {@link EnvironmentInstance}
120
+ * @param serviceSid the service sid
121
+ * @param pluginName the plugin name
122
+ */
123
+ async getEnvironment(serviceSid, pluginName) {
124
+ const service = await this.getService(serviceSid);
125
+ if (!service) {
126
+ return null;
127
+ }
128
+ const list = await service.environments().list();
129
+ const environment = list.find((e) => e.uniqueName === pluginName);
130
+ if (!environment || !environment.sid) {
131
+ return null;
132
+ }
133
+ return environment;
134
+ }
84
135
  /**
85
136
  * Fetches the {@link BuildInstance}
86
137
  * @param serviceSid the service sid
@@ -1 +1 @@
1
- {"version":3,"file":"ServerlessClient.js","sourceRoot":"","sources":["../../src/clients/ServerlessClient.ts"],"names":[],"mappings":";;AAMA,mDAAwD;AAaxD;;GAEG;AACH,MAAqB,gBAAgB;IAcnC,YAAY,MAA2B,EAAE,MAAc;QACrD,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACvB,CAAC;IAED;;;OAGG;IACH,KAAK,CAAC,UAAU,CAAC,UAAkB;QACjC,OAAO,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC,KAAK,EAAE,CAAC;IAC7C,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,YAAY;QAChB,OAAO,IAAI,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC;IAC5B,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,yBAAyB;QAC7B,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,YAAY,EAAE,CAAC;QACvC,MAAM,OAAO,GAAG,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,UAAU,KAAK,gBAAgB,CAAC,UAAU,CAAC,UAAU,CAAC,CAAC;QAC1F,IAAI,OAAO,EAAE;YACX,OAAO,OAAO,CAAC;SAChB;QAED,OAAO,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,gBAAgB,CAAC,UAAU,CAAC,CAAC;IACzD,CAAC;IAED;;;OAGG;IACH,KAAK,CAAC,iBAAiB,CAAC,UAAkB;QACxC,MAAM,OAAO,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC,KAAK,EAAE,CAAC;QAC1D,OAAO,CAAC,YAAY,GAAG,gBAAgB,CAAC,UAAU,CAA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AAM,4BAA4B,CAAC,CAAC;gBAEzF,IAAI,KAAK,CAAC,MAAM,KAAK,QAAQ,EAAE;oBAC7B,aAAa,CAAC,UAAU,CAAC,CAAC;oBAC1B,YAAY,CAAC,SAAS,CAAC,CAAC;oBAExB,MAAM,CAAC,IAAI,+BAAc,CAAC,KAAK,EAAE,kCAAkC,EAAE,GAAG,CAAC,CAAC,CAAC;iBAC5E;gBAED,IAAI,KAAK,CAAC,MAAM,KAAK,WAAW,EAAE;oBAChC,aAAa,CAAC,UAAU,CAAC,CAAC;oBAC1B,YAAY,CAAC,SAAS,CAAC,CAAC;oBAExB,OAAO,CAAC,KAAK,CAAC,CAAC;iBAChB;YACH,CAAC,EAAE,gBAAgB,CAAC,mBAAmB,CAAC,CAAC;QAC3C,CAAC,CAAC,CAAC;IACL,CAAC;IAED;;;;;OAKG;IACK,cAAc,CAAC,KAAoB,EAAE,UAAkB;QAC7D,OAAO,KAAK,CAAC,aAAa;aACvB,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAoB,CAAC;aACpC,IAAI,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,IAAI,KAAK,YAAY,UAAU,kBAAkB,CAAC,CAAC;IAC9E,CAAC;;AArPH,mCAsPC;AArPe,2BAAU,GAAqC;IAC3D,UAAU,EAAE,SAAS;IACrB,YAAY,EAAE,sDAAsD;CACrE,CAAC;AAEK,4BAAW,GAAG,KAAK,CAAC;AAEpB,oCAAmB,GAAG,GAAG,CAAC"}
@@ -1,4 +1,4 @@
1
- import { Configuration } from 'flex-plugins-api-toolkit';
1
+ import { Configuration } from '@twilio/flex-plugins-api-client';
2
2
  import { OutputFlags } from '@oclif/parser/lib/parse';
3
3
  import * as flags from '../../../../utils/flags';
4
4
  import ArchiveResource from '../../../../sub-commands/archive-resource';
@@ -1,4 +1,4 @@
1
- import { PluginVersion } from 'flex-plugins-api-toolkit';
1
+ import { PluginVersion } from '@twilio/flex-plugins-api-client';
2
2
  import { OutputFlags } from '@oclif/parser/lib/parse';
3
3
  import * as flags from '../../../../utils/flags';
4
4
  import ArchiveResource from '../../../../sub-commands/archive-resource';
@@ -24,6 +24,28 @@ export default class FlexPluginsArchivePluginVersion extends ArchiveResource<Plu
24
24
  * @override
25
25
  */
26
26
  getResourceType(): string;
27
+ /**
28
+ * Archives the resource on flex-plugins-api service
29
+ * @private
30
+ */
31
+ private archiveOnPluginsAPI;
32
+ /**
33
+ * Removes the serverless files
34
+ * @param build the active {@link BuildInstance} to remove the files from
35
+ * @private
36
+ */
37
+ private removeServerlessFiles;
38
+ /**
39
+ * Filters the asset by path
40
+ * @param asset the asset to filter
41
+ * @private
42
+ */
43
+ private filterAssetExists;
44
+ /**
45
+ * Returns the {@link BuildInstance} if found. It will also return undefined if the pluginVersion is not part of this build
46
+ * @private
47
+ */
48
+ private getBuildIfActive;
27
49
  /**
28
50
  * @override
29
51
  */
@@ -22,15 +22,39 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
22
22
  return (mod && mod.__esModule) ? mod : { "default": mod };
23
23
  };
24
24
  Object.defineProperty(exports, "__esModule", { value: true });
25
+ const flex_dev_utils_1 = require("@twilio/flex-dev-utils");
25
26
  const flags = __importStar(require("../../../../utils/flags"));
26
27
  const archive_resource_1 = __importDefault(require("../../../../sub-commands/archive-resource"));
27
28
  const general_1 = require("../../../../utils/general");
28
29
  class FlexPluginsArchivePluginVersion extends archive_resource_1.default {
30
+ constructor() {
31
+ super(...arguments);
32
+ /**
33
+ * Filters the asset by path
34
+ * @param asset the asset to filter
35
+ * @private
36
+ */
37
+ // The type definition for this from the twilio-node library is broken
38
+ // eslint-disable-next-line @typescript-eslint/ban-types
39
+ this.filterAssetExists = (asset) => {
40
+ const path = `/plugins/${this._flags.name}/${this._flags.version}/`;
41
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
42
+ return asset.path.includes(path);
43
+ };
44
+ }
29
45
  /**
30
46
  * @override
31
47
  */
32
48
  async doArchive() {
33
- return this.pluginsApiToolkit.archivePluginVersion({ name: this._flags.name, version: this._flags.version });
49
+ const pluginVersion = await flex_dev_utils_1.progress('Archiving Flex Plugin Version', async () => this.archiveOnPluginsAPI());
50
+ await flex_dev_utils_1.progress('Cleaning up Twilio Assets', async () => {
51
+ const build = await this.getBuildIfActive();
52
+ if (!build) {
53
+ throw new flex_dev_utils_1.TwilioApiError(20400, 'Plugin version is already archived', 400);
54
+ }
55
+ await this.removeServerlessFiles(build);
56
+ });
57
+ return pluginVersion;
34
58
  }
35
59
  /**
36
60
  * @override
@@ -45,6 +69,67 @@ class FlexPluginsArchivePluginVersion extends archive_resource_1.default {
45
69
  getResourceType() {
46
70
  return 'Flex Plugin Version';
47
71
  }
72
+ /**
73
+ * Archives the resource on flex-plugins-api service
74
+ * @private
75
+ */
76
+ async archiveOnPluginsAPI() {
77
+ try {
78
+ return await this.pluginsApiToolkit.archivePluginVersion({
79
+ name: this._flags.name,
80
+ version: this._flags.version,
81
+ });
82
+ }
83
+ catch (e) {
84
+ if (general_1.instanceOf(e, flex_dev_utils_1.TwilioApiError) && e.status === 400) {
85
+ return this.pluginsApiToolkit.describePluginVersion({
86
+ name: this._flags.name,
87
+ version: this._flags.version,
88
+ });
89
+ }
90
+ throw e;
91
+ }
92
+ }
93
+ /**
94
+ * Removes the serverless files
95
+ * @param build the active {@link BuildInstance} to remove the files from
96
+ * @private
97
+ */
98
+ async removeServerlessFiles(build) {
99
+ var _a, _b, _c, _d;
100
+ const request = {
101
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
102
+ functionVersions: (_a = build.functionVersions) === null || _a === void 0 ? void 0 : _a.map((f) => f.sid),
103
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
104
+ assetVersions: (_b = build.assetVersions) === null || _b === void 0 ? void 0 : _b.filter((a) => !this.filterAssetExists(a)).map((a) => a.sid),
105
+ // @ts-ignore this is a type definition error in Twilio; dependencies should be object[] not a string
106
+ dependencies: build.dependencies,
107
+ runtime: 'node12',
108
+ };
109
+ if (((_c = request.assetVersions) === null || _c === void 0 ? void 0 : _c.length) === 0 && ((_d = request.functionVersions) === null || _d === void 0 ? void 0 : _d.length) === 0) {
110
+ const environment = await this.serverlessClient.getEnvironment(build.serviceSid, this._flags.name);
111
+ if (environment) {
112
+ await this.serverlessClient.deleteEnvironment(build.serviceSid, environment.sid);
113
+ }
114
+ return;
115
+ }
116
+ await this.serverlessClient.createBuildAndDeploy(build.serviceSid, this._flags.name, request);
117
+ }
118
+ /**
119
+ * Returns the {@link BuildInstance} if found. It will also return undefined if the pluginVersion is not part of this build
120
+ * @private
121
+ */
122
+ async getBuildIfActive() {
123
+ const serviceSid = await this.flexConfigurationClient.getServerlessSid();
124
+ if (!serviceSid) {
125
+ return undefined;
126
+ }
127
+ const build = await this.serverlessClient.getBuild(serviceSid, this._flags.name);
128
+ if (!(build === null || build === void 0 ? void 0 : build.assetVersions.find(this.filterAssetExists))) {
129
+ return undefined;
130
+ }
131
+ return build;
132
+ }
48
133
  /**
49
134
  * @override
50
135
  */