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