instant-cli 0.22.98-experimental.highl.20766596946.1 → 0.22.99-experimental.add-user-perm-rules.20792844601.1

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/dist/ui/index.js CHANGED
@@ -74,9 +74,6 @@ export var UI;
74
74
  console.log('config', status);
75
75
  return status;
76
76
  }
77
- data;
78
- options;
79
- params;
80
77
  constructor(params) {
81
78
  super(params.modifyOutput);
82
79
  this.on('attach', (terminal) => terminal.toggleCursor('hide'));
@@ -111,9 +108,10 @@ export var UI;
111
108
  return this.data.items[this.data.selectedIdx];
112
109
  }
113
110
  render(status) {
111
+ var _a;
114
112
  if (status === 'submitted') {
115
113
  return `${this.params.promptText}
116
- ${chalk.hex('#EA570B').bold('●')} ${this.params.options[this.data.selectedIdx]?.label}`;
114
+ ${chalk.hex('#EA570B').bold('●')} ${(_a = this.params.options[this.data.selectedIdx]) === null || _a === void 0 ? void 0 : _a.label}`;
117
115
  }
118
116
  const optionsList = this.options
119
117
  .map((option, idx) => {
@@ -148,7 +146,6 @@ ${optionsList}`;
148
146
  config(status) {
149
147
  return status;
150
148
  }
151
- inner;
152
149
  constructor(inner) {
153
150
  super();
154
151
  this.inner = inner;
@@ -170,6 +167,7 @@ ${optionsList}`;
170
167
  return this.value;
171
168
  }
172
169
  render(status) {
170
+ var _a, _b;
173
171
  if (status === 'submitted') {
174
172
  return `${this.props.prompt}
175
173
  ${this.value}`;
@@ -179,7 +177,7 @@ ${this.value}`;
179
177
  }
180
178
  let inputDisplay = '';
181
179
  if (this.value === '') {
182
- inputDisplay = `${chalk.inverse(this.props.placeholder?.substring(0, 1))}${chalk.dim(this.props.placeholder?.substring(1))}`;
180
+ inputDisplay = `${chalk.inverse((_a = this.props.placeholder) === null || _a === void 0 ? void 0 : _a.substring(0, 1))}${chalk.dim((_b = this.props.placeholder) === null || _b === void 0 ? void 0 : _b.substring(1))}`;
183
181
  }
184
182
  else {
185
183
  inputDisplay = `${this.value}${chalk.inverse(' ')}`;
@@ -190,9 +188,6 @@ ${this.value}`;
190
188
  return `${this.props.prompt}${errorText}
191
189
  ${inputDisplay}`;
192
190
  }
193
- value;
194
- errorText;
195
- props;
196
191
  constructor(props) {
197
192
  super(props.modifyOutput);
198
193
  this.on('attach', (terminal) => {
@@ -203,9 +198,10 @@ ${inputDisplay}`;
203
198
  terminal.toggleCursor('show');
204
199
  });
205
200
  this.on('input', (input, keyInfo) => {
201
+ var _a, _b, _c, _d, _e;
206
202
  if (keyInfo.name === 'escape') {
207
203
  if (!this.props.headless) {
208
- return this?.terminal?.resolve({
204
+ return (_a = this === null || this === void 0 ? void 0 : this.terminal) === null || _a === void 0 ? void 0 : _a.resolve({
209
205
  data: undefined,
210
206
  status: 'aborted',
211
207
  });
@@ -217,7 +213,7 @@ ${inputDisplay}`;
217
213
  if (keyInfo.name === 'return') {
218
214
  if (this.value === '' && this.props.defaultValue) {
219
215
  this.value = this.props.defaultValue;
220
- return this.terminal?.resolve({
216
+ return (_b = this.terminal) === null || _b === void 0 ? void 0 : _b.resolve({
221
217
  data: this.props.defaultValue,
222
218
  status: 'submitted',
223
219
  });
@@ -229,14 +225,14 @@ ${inputDisplay}`;
229
225
  this.errorText = validationResult;
230
226
  }
231
227
  else {
232
- return this.terminal?.resolve({
228
+ return (_c = this.terminal) === null || _c === void 0 ? void 0 : _c.resolve({
233
229
  data: this.value,
234
230
  status: 'submitted',
235
231
  });
236
232
  }
237
233
  }
238
234
  else {
239
- return this.terminal?.resolve({
235
+ return (_d = this.terminal) === null || _d === void 0 ? void 0 : _d.resolve({
240
236
  data: this.value,
241
237
  status: 'submitted',
242
238
  });
@@ -245,7 +241,7 @@ ${inputDisplay}`;
245
241
  if (keyInfo.name === 'backspace') {
246
242
  this.value = this.value.slice(0, -1);
247
243
  }
248
- else if (keyInfo.name?.length === 1) {
244
+ else if (((_e = keyInfo.name) === null || _e === void 0 ? void 0 : _e.length) === 1) {
249
245
  this.value += input;
250
246
  }
251
247
  else if (keyInfo.name === 'space') {
@@ -271,13 +267,6 @@ ${inputDisplay}`;
271
267
  }
272
268
  UI.TextInput = TextInput;
273
269
  class Spinner extends Prompt {
274
- props;
275
- promiseResult = null;
276
- promiseError = null;
277
- spinnerFrames = ['⠋', '⠙', '⠹', '⠸', '⠼', '⠴', '⠦', '⠧', '⠇', '⠏'];
278
- frameIndex = 0;
279
- intervalId = null;
280
- messages = [];
281
270
  result() {
282
271
  if (this.promiseError) {
283
272
  throw this.promiseError;
@@ -317,6 +306,12 @@ ${inputDisplay}`;
317
306
  }
318
307
  constructor(props) {
319
308
  super(props.modifyOutput);
309
+ this.promiseResult = null;
310
+ this.promiseError = null;
311
+ this.spinnerFrames = ['⠋', '⠙', '⠹', '⠸', '⠼', '⠴', '⠦', '⠧', '⠇', '⠏'];
312
+ this.frameIndex = 0;
313
+ this.intervalId = null;
314
+ this.messages = [];
320
315
  this.props = props;
321
316
  this.on('attach', (terminal) => {
322
317
  terminal.setAllowInteraction(false);
@@ -357,9 +352,11 @@ ${inputDisplay}`;
357
352
  UI.Spinner = Spinner;
358
353
  class Confirmation extends Prompt {
359
354
  result() {
360
- return this.value ?? this.props.defaultValue ?? false;
355
+ var _a, _b;
356
+ return (_b = (_a = this.value) !== null && _a !== void 0 ? _a : this.props.defaultValue) !== null && _b !== void 0 ? _b : false;
361
357
  }
362
358
  render(status) {
359
+ var _a, _b;
363
360
  const renderLabel = (text, active, width = 8) => {
364
361
  return boxen(text, {
365
362
  backgroundColor: active
@@ -372,18 +369,17 @@ ${inputDisplay}`;
372
369
  width,
373
370
  });
374
371
  };
375
- const yesStyle = renderLabel(this.props.yesText ?? 'Yes', this.value === true, 9);
376
- const noStyle = renderLabel(this.props.noText ?? 'No', this.value === false, 8);
372
+ const yesStyle = renderLabel((_a = this.props.yesText) !== null && _a !== void 0 ? _a : 'Yes', this.value === true, 9);
373
+ const noStyle = renderLabel((_b = this.props.noText) !== null && _b !== void 0 ? _b : 'No', this.value === false, 8);
377
374
  const display = `${this.props.promptText}${this.props.inline ? ' ' : '\n'}${yesStyle} ${noStyle}`;
378
375
  if (status === 'submitted') {
379
376
  return chalk.dim(display);
380
377
  }
381
378
  return display;
382
379
  }
383
- value = null;
384
- props;
385
380
  constructor(props) {
386
381
  super(props.modifyOutput);
382
+ this.value = null;
387
383
  this.props = props;
388
384
  this.on('attach', (terminal) => {
389
385
  terminal.toggleCursor('hide');
@@ -410,13 +406,11 @@ ${inputDisplay}`;
410
406
  }
411
407
  UI.Confirmation = Confirmation;
412
408
  class FocusHandle {
413
- parent = null;
414
- _focus;
415
- key;
416
- onFocusCallback = null;
417
- onBlurCallback = null;
418
- onKeyCallbacks = [];
419
409
  constructor(focus, key, parent) {
410
+ this.parent = null;
411
+ this.onFocusCallback = null;
412
+ this.onBlurCallback = null;
413
+ this.onKeyCallbacks = [];
420
414
  this._focus = focus;
421
415
  this.key = key;
422
416
  this.parent = parent;
@@ -427,7 +421,8 @@ ${inputDisplay}`;
427
421
  return newHandle;
428
422
  }
429
423
  setFocus(key) {
430
- this._focus?.setFocus(key);
424
+ var _a;
425
+ (_a = this._focus) === null || _a === void 0 ? void 0 : _a.setFocus(key);
431
426
  }
432
427
  onKey(callback) {
433
428
  this.onKeyCallbacks.push(callback);
@@ -450,27 +445,27 @@ ${inputDisplay}`;
450
445
  _notifyKey(str, key) {
451
446
  this.onKeyCallbacks.forEach((callback) => {
452
447
  callback(str, key, () => {
453
- this.parent?._notifyKey(str, key);
448
+ var _a;
449
+ (_a = this.parent) === null || _a === void 0 ? void 0 : _a._notifyKey(str, key);
454
450
  });
455
451
  });
456
452
  }
457
453
  _notifyFocusState(key) {
454
+ var _a, _b;
458
455
  if (key === this.key) {
459
- this.onFocusCallback?.();
456
+ (_a = this.onFocusCallback) === null || _a === void 0 ? void 0 : _a.call(this);
460
457
  }
461
458
  else {
462
- this.onBlurCallback?.();
459
+ (_b = this.onBlurCallback) === null || _b === void 0 ? void 0 : _b.call(this);
463
460
  }
464
461
  }
465
462
  }
466
463
  class Focus {
467
- selected;
468
- prompt;
469
- handles;
470
464
  constructor(prompt) {
471
465
  this.prompt = prompt;
472
466
  this.prompt.on('input', (arg1, arg2) => {
473
- this.handles[this.selected]?._notifyKey?.(arg1, arg2);
467
+ var _a, _b;
468
+ (_b = (_a = this.handles[this.selected]) === null || _a === void 0 ? void 0 : _a._notifyKey) === null || _b === void 0 ? void 0 : _b.call(_a, arg1, arg2);
474
469
  this.prompt.requestLayout();
475
470
  });
476
471
  this.handles = {};
@@ -489,8 +484,9 @@ ${inputDisplay}`;
489
484
  return this.selected;
490
485
  }
491
486
  setFocus(key) {
487
+ var _a, _b;
492
488
  this.selected = key;
493
- this.handles[key]?._notifyFocusState?.(key);
489
+ (_b = (_a = this.handles[key]) === null || _a === void 0 ? void 0 : _a._notifyFocusState) === null || _b === void 0 ? void 0 : _b.call(_a, key);
494
490
  this.prompt.requestLayout();
495
491
  }
496
492
  isFocused(key) {
@@ -499,33 +495,30 @@ ${inputDisplay}`;
499
495
  }
500
496
  UI.Focus = Focus;
501
497
  class Menu {
502
- items = [];
503
- selectedIdx = 0;
504
- focus;
505
- width = 40;
506
- maxHeight = 10;
507
- scrollOffset = 0;
508
- emptyState;
509
- showIdxWhileBlurred;
510
- onHoverChange;
511
- enableSearch;
512
- searchMode = false;
513
- searchQuery = '';
514
- allItems = [];
515
498
  constructor(props) {
516
- this.width = props.width ?? 40;
517
- this.maxHeight = props.maxHeight ?? 10;
499
+ var _a, _b, _c, _d;
500
+ this.items = [];
501
+ this.selectedIdx = 0;
502
+ this.width = 40;
503
+ this.maxHeight = 10;
504
+ this.scrollOffset = 0;
505
+ this.searchMode = false;
506
+ this.searchQuery = '';
507
+ this.allItems = [];
508
+ this.width = (_a = props.width) !== null && _a !== void 0 ? _a : 40;
509
+ this.maxHeight = (_b = props.maxHeight) !== null && _b !== void 0 ? _b : 10;
518
510
  this.focus = props.focus;
519
511
  this.emptyState = props.emptyState;
520
- this.showIdxWhileBlurred = props.showIdxWhileBlurred ?? false;
512
+ this.showIdxWhileBlurred = (_c = props.showIdxWhileBlurred) !== null && _c !== void 0 ? _c : false;
521
513
  this.onHoverChange = props.onHoverChange;
522
- this.enableSearch = props.enableSearch ?? false;
514
+ this.enableSearch = (_d = props.enableSearch) !== null && _d !== void 0 ? _d : false;
523
515
  if (props.resetIdxOnFocus) {
524
516
  this.focus.onFocus(() => {
525
517
  this.setSelectedItem(0);
526
518
  });
527
519
  }
528
520
  this.focus.onKey((key, keyInfo, propagate) => {
521
+ var _a;
529
522
  if (this.enableSearch && key === '/' && !this.searchMode) {
530
523
  this.searchMode = true;
531
524
  this.searchQuery = '';
@@ -579,7 +572,7 @@ ${inputDisplay}`;
579
572
  this.setSelectedItem(newIndex);
580
573
  }
581
574
  else if (keyInfo.name === 'return' || keyInfo.name === 'right') {
582
- this.items[this.selectedIdx]?.onSelect();
575
+ (_a = this.items[this.selectedIdx]) === null || _a === void 0 ? void 0 : _a.onSelect();
583
576
  }
584
577
  else {
585
578
  propagate();
@@ -627,6 +620,7 @@ ${inputDisplay}`;
627
620
  this.setSelectedItem(this.selectedIdx);
628
621
  }
629
622
  render() {
623
+ var _a;
630
624
  let output = '';
631
625
  if (this.searchMode) {
632
626
  const searchLine = (' Search: ' +
@@ -635,7 +629,7 @@ ${inputDisplay}`;
635
629
  output += chalk.hex('#EA570B')(searchLine) + '\n';
636
630
  }
637
631
  if (this.items.length === 0) {
638
- return output + (this.emptyState ?? chalk.dim('No items'));
632
+ return output + ((_a = this.emptyState) !== null && _a !== void 0 ? _a : chalk.dim('No items'));
639
633
  }
640
634
  const hasItemsAbove = this.scrollOffset > 0;
641
635
  const hasItemsBelow = this.scrollOffset + this.maxHeight < this.items.length;
@@ -669,18 +663,6 @@ ${inputDisplay}`;
669
663
  }
670
664
  UI.Menu = Menu;
671
665
  class AppSelector extends Prompt {
672
- props;
673
- api;
674
- dashResponse;
675
- creatingEphemeral = false;
676
- selectedAppName = '';
677
- selectedOrg = null;
678
- appNameInput;
679
- focus;
680
- appList;
681
- orgList;
682
- HEIGHT = 10;
683
- RIGHT_WIDTH = 70;
684
666
  result() {
685
667
  throw new Error('Method not implemented.');
686
668
  }
@@ -712,6 +694,7 @@ ${inputDisplay}`;
712
694
  });
713
695
  }
714
696
  render(status) {
697
+ var _a;
715
698
  if (status === 'submitted') {
716
699
  return boxen(' Selected App: ' + this.selectedAppName, {
717
700
  width: 50,
@@ -728,7 +711,7 @@ ${inputDisplay}`;
728
711
  : curFocus === 'newApp'
729
712
  ? 'Create app '
730
713
  : '';
731
- if (this.selectedOrg?.title) {
714
+ if ((_a = this.selectedOrg) === null || _a === void 0 ? void 0 : _a.title) {
732
715
  left += `(${this.selectedOrg.title}) `;
733
716
  }
734
717
  const keybindings = [];
@@ -766,38 +749,44 @@ ${inputDisplay}`;
766
749
  '\n' +
767
750
  chalk.dim(' ' + keybindings.join(' ')));
768
751
  }
769
- createAppList = (apps) => {
770
- const items = [];
771
- if (this.props.allowCreate) {
772
- items.push({
773
- label: chalk.italic('+ New App'),
774
- onSelect: () => {
775
- this.focus.setFocus('newApp');
776
- },
777
- });
778
- }
779
- apps
780
- .sort((a, b) => new Date(b.created_at).getTime() - new Date(a.created_at).getTime())
781
- .forEach((app) => {
782
- items.push({
783
- label: app.title,
784
- onSelect: () => {
785
- this.selectedAppName = app.title;
786
- this.terminal?.resolve({
787
- status: 'submitted',
788
- data: {
789
- appId: app.id,
790
- approach: 'import',
791
- adminToken: app.admin_token,
792
- },
793
- });
794
- },
795
- });
796
- });
797
- return items;
798
- };
799
752
  constructor(props) {
800
753
  super(props.modifyOutput);
754
+ this.creatingEphemeral = false;
755
+ this.selectedAppName = '';
756
+ this.selectedOrg = null;
757
+ this.HEIGHT = 10;
758
+ this.RIGHT_WIDTH = 70;
759
+ this.createAppList = (apps) => {
760
+ const items = [];
761
+ if (this.props.allowCreate) {
762
+ items.push({
763
+ label: chalk.italic('+ New App'),
764
+ onSelect: () => {
765
+ this.focus.setFocus('newApp');
766
+ },
767
+ });
768
+ }
769
+ apps
770
+ .sort((a, b) => new Date(b.created_at).getTime() - new Date(a.created_at).getTime())
771
+ .forEach((app) => {
772
+ items.push({
773
+ label: app.title,
774
+ onSelect: () => {
775
+ var _a;
776
+ this.selectedAppName = app.title;
777
+ (_a = this.terminal) === null || _a === void 0 ? void 0 : _a.resolve({
778
+ status: 'submitted',
779
+ data: {
780
+ appId: app.id,
781
+ approach: 'import',
782
+ adminToken: app.admin_token,
783
+ },
784
+ });
785
+ },
786
+ });
787
+ });
788
+ return items;
789
+ };
801
790
  this.props = props;
802
791
  this.api = props.api;
803
792
  this.dashResponse = this.api.getDash();
@@ -850,6 +839,7 @@ ${inputDisplay}`;
850
839
  headless: true,
851
840
  });
852
841
  this.focus.child('newApp').onKey((key, keyInfo) => {
842
+ var _a;
853
843
  if (keyInfo.name === 'escape' || keyInfo.name == 'left') {
854
844
  this.focus.setFocus('appList');
855
845
  }
@@ -857,27 +847,23 @@ ${inputDisplay}`;
857
847
  const name = this.appNameInput.value || 'my-instant-app';
858
848
  if (this.creatingEphemeral) {
859
849
  this.props.api.createEphemeralApp(name).then((pair) => {
850
+ var _a;
860
851
  this.selectedAppName = name;
861
- this.terminal?.resolve({
852
+ (_a = this.terminal) === null || _a === void 0 ? void 0 : _a.resolve({
862
853
  status: 'submitted',
863
- data: {
864
- ...pair,
865
- approach: 'ephemeral',
866
- },
854
+ data: Object.assign(Object.assign({}, pair), { approach: 'ephemeral' }),
867
855
  });
868
856
  });
869
857
  }
870
858
  else {
871
859
  this.props.api
872
- .createApp(name, this.selectedOrg?.id)
860
+ .createApp(name, (_a = this.selectedOrg) === null || _a === void 0 ? void 0 : _a.id)
873
861
  .then((pair) => {
862
+ var _a;
874
863
  this.selectedAppName = name;
875
- this.terminal?.resolve({
864
+ (_a = this.terminal) === null || _a === void 0 ? void 0 : _a.resolve({
876
865
  status: 'submitted',
877
- data: {
878
- ...pair,
879
- approach: 'create',
880
- },
866
+ data: Object.assign(Object.assign({}, pair), { approach: 'create' }),
881
867
  });
882
868
  });
883
869
  }
@@ -893,7 +879,8 @@ ${inputDisplay}`;
893
879
  }
894
880
  });
895
881
  this.on('attach', (terminal) => {
896
- this.terminal?.setAllowInteraction(false);
882
+ var _a;
883
+ (_a = this.terminal) === null || _a === void 0 ? void 0 : _a.setAllowInteraction(false);
897
884
  terminal.toggleCursor('hide');
898
885
  });
899
886
  this.on('detach', (terminal) => {