@super-protocol/sp-cli 0.0.8 → 0.0.10-beta

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 (95) hide show
  1. package/README.md +200 -167
  2. package/dist/commands/account/base.d.ts +3 -4
  3. package/dist/commands/account/base.js +12 -9
  4. package/dist/commands/account/forget.d.ts +1 -1
  5. package/dist/commands/account/forget.js +66 -17
  6. package/dist/commands/account/get-sppi.js +7 -11
  7. package/dist/commands/account/info.d.ts +1 -13
  8. package/dist/commands/account/info.js +25 -45
  9. package/dist/commands/account/list.js +6 -6
  10. package/dist/commands/account/login.d.ts +10 -3
  11. package/dist/commands/account/login.js +143 -87
  12. package/dist/commands/account/switch.d.ts +3 -0
  13. package/dist/commands/account/switch.js +31 -11
  14. package/dist/commands/assets/base.d.ts +39 -0
  15. package/dist/commands/assets/base.js +217 -0
  16. package/dist/commands/assets/create.d.ts +41 -0
  17. package/dist/commands/assets/create.js +277 -0
  18. package/dist/commands/assets/delete.d.ts +14 -0
  19. package/dist/commands/assets/delete.js +69 -0
  20. package/dist/commands/assets/get.d.ts +14 -0
  21. package/dist/commands/assets/get.js +79 -0
  22. package/dist/commands/assets/list.d.ts +7 -0
  23. package/dist/commands/assets/list.js +33 -0
  24. package/dist/commands/assets/update.d.ts +44 -0
  25. package/dist/commands/assets/update.js +321 -0
  26. package/dist/commands/base.d.ts +1 -0
  27. package/dist/commands/base.js +6 -0
  28. package/dist/config/config.schema.d.ts +2 -11
  29. package/dist/config/config.schema.js +2 -7
  30. package/dist/constants.d.ts +3 -3
  31. package/dist/constants.js +3 -3
  32. package/dist/errors.d.ts +0 -2
  33. package/dist/errors.js +0 -2
  34. package/dist/hooks/prerun/auth.js +5 -9
  35. package/dist/interfaces/config-manager.interface.d.ts +3 -1
  36. package/dist/lib/container.d.ts +4 -12
  37. package/dist/lib/container.js +28 -113
  38. package/dist/lib/swarm-client/fetch-api.d.ts +7 -0
  39. package/dist/lib/swarm-client/fetch-api.js +41 -0
  40. package/dist/lib/swarm-client/fetch-timeout.client.d.ts +1 -0
  41. package/dist/lib/swarm-client/fetch-timeout.client.js +32 -0
  42. package/dist/lib/swarm-client/index.d.ts +6 -0
  43. package/dist/lib/swarm-client/index.js +31 -0
  44. package/dist/lib/swarm-client/middlewares/authorization.middleware.d.ts +2 -0
  45. package/dist/lib/swarm-client/middlewares/authorization.middleware.js +12 -0
  46. package/dist/lib/swarm-client/middlewares/index.d.ts +6 -0
  47. package/dist/lib/swarm-client/middlewares/index.js +5 -0
  48. package/dist/lib/swarm-client/middlewares/logger.middleware.d.ts +2 -0
  49. package/dist/lib/swarm-client/middlewares/logger.middleware.js +30 -0
  50. package/dist/lib/swarm-client/middlewares/request-id.middleware.d.ts +2 -0
  51. package/dist/lib/swarm-client/middlewares/request-id.middleware.js +13 -0
  52. package/dist/lib/swarm-client/types.d.ts +23 -0
  53. package/dist/lib/swarm-client/types.js +1 -0
  54. package/dist/managers/account-manager.d.ts +1 -0
  55. package/dist/managers/account-manager.js +13 -18
  56. package/dist/managers/config-file-manager.d.ts +24 -17
  57. package/dist/managers/config-file-manager.js +285 -161
  58. package/dist/managers/config-manager.d.ts +6 -6
  59. package/dist/managers/config-manager.js +8 -8
  60. package/dist/services/account.service.d.ts +42 -0
  61. package/dist/services/account.service.js +140 -0
  62. package/dist/services/asset.service.d.ts +35 -0
  63. package/dist/services/asset.service.js +120 -0
  64. package/dist/services/auth.service.d.ts +4 -6
  65. package/dist/services/auth.service.js +108 -118
  66. package/dist/utils/helper.js +2 -2
  67. package/dist/utils/progress.js +1 -0
  68. package/dist/utils/prompt.service.d.ts +8 -1
  69. package/dist/utils/prompt.service.js +33 -1
  70. package/oclif.manifest.json +479 -215
  71. package/package.json +7 -8
  72. package/dist/commands/files/download.d.ts +0 -15
  73. package/dist/commands/files/download.js +0 -63
  74. package/dist/commands/files/upload.d.ts +0 -18
  75. package/dist/commands/files/upload.js +0 -83
  76. package/dist/commands/storage/base.d.ts +0 -13
  77. package/dist/commands/storage/base.js +0 -125
  78. package/dist/commands/storage/create.d.ts +0 -11
  79. package/dist/commands/storage/create.js +0 -53
  80. package/dist/commands/storage/select.d.ts +0 -9
  81. package/dist/commands/storage/select.js +0 -38
  82. package/dist/commands/storage/show.d.ts +0 -17
  83. package/dist/commands/storage/show.js +0 -34
  84. package/dist/commands/storage/update.d.ts +0 -14
  85. package/dist/commands/storage/update.js +0 -204
  86. package/dist/commands/workflows/extend-lease.d.ts +0 -17
  87. package/dist/commands/workflows/extend-lease.js +0 -102
  88. package/dist/hooks/finally/shutdown-blockchain.d.ts +0 -3
  89. package/dist/hooks/finally/shutdown-blockchain.js +0 -8
  90. package/dist/middlewares/auth-middleware.d.ts +0 -9
  91. package/dist/middlewares/auth-middleware.js +0 -91
  92. package/dist/middlewares/cookies-middleware.d.ts +0 -8
  93. package/dist/middlewares/cookies-middleware.js +0 -80
  94. package/dist/services/storage.service.d.ts +0 -73
  95. package/dist/services/storage.service.js +0 -378
@@ -4,7 +4,14 @@ export type ConfirmOptions = ClackConfirmOptions;
4
4
  export type SelectOptions<T> = ClackSelectOptions<T>;
5
5
  export type PasswordOptions = ClackPasswordOptions;
6
6
  type ParseValue = (input: string) => string | number | boolean;
7
- export declare class PromptService {
7
+ export declare class NonInteractiveError extends Error {
8
+ constructor(message: string);
9
+ }
10
+ declare class PromptService {
11
+ private _isInteractive;
12
+ setInteractiveMode(value: boolean): void;
13
+ get isInteractive(): boolean;
14
+ private checkInteractive;
8
15
  text(options: ClackTextOptions): Promise<string>;
9
16
  confirm(options: ClackConfirmOptions): Promise<boolean>;
10
17
  select<T>(options: ClackSelectOptions<T>): Promise<T>;
@@ -1,6 +1,29 @@
1
1
  import { confirm as clackConfirm, password as clackPassword, select as clackSelect, text as clackText, isCancel, } from '@clack/prompts';
2
- export class PromptService {
2
+ import { isInteractiveMode } from './tty.js';
3
+ export class NonInteractiveError extends Error {
4
+ constructor(message) {
5
+ super(message);
6
+ this.name = 'NonInteractiveError';
7
+ }
8
+ }
9
+ class PromptService {
10
+ _isInteractive = null;
11
+ setInteractiveMode(value) {
12
+ this._isInteractive = value;
13
+ }
14
+ get isInteractive() {
15
+ if (this._isInteractive === null) {
16
+ this._isInteractive = isInteractiveMode();
17
+ }
18
+ return this._isInteractive;
19
+ }
20
+ checkInteractive(operation) {
21
+ if (!this.isInteractive) {
22
+ throw new NonInteractiveError(`Cannot ${operation} in non-interactive mode. Use appropriate flags or run without --no-tty.`);
23
+ }
24
+ }
3
25
  async text(options) {
26
+ this.checkInteractive('prompt for text input');
4
27
  const result = await clackText(options);
5
28
  if (isCancel(result)) {
6
29
  throw new Error('Operation cancelled.');
@@ -8,6 +31,12 @@ export class PromptService {
8
31
  return result;
9
32
  }
10
33
  async confirm(options) {
34
+ if (!this.isInteractive) {
35
+ if (options.initialValue !== undefined) {
36
+ return options.initialValue;
37
+ }
38
+ throw new NonInteractiveError('Cannot prompt for confirmation in non-interactive mode. Use --force or run without --no-tty.');
39
+ }
11
40
  const result = await clackConfirm(options);
12
41
  if (isCancel(result)) {
13
42
  throw new Error('Operation cancelled.');
@@ -15,6 +44,7 @@ export class PromptService {
15
44
  return result;
16
45
  }
17
46
  async select(options) {
47
+ this.checkInteractive('show selection menu');
18
48
  const result = await clackSelect(options);
19
49
  if (isCancel(result)) {
20
50
  throw new Error('Operation cancelled.');
@@ -22,6 +52,7 @@ export class PromptService {
22
52
  return result;
23
53
  }
24
54
  async password(options) {
55
+ this.checkInteractive('prompt for password');
25
56
  const result = await clackPassword(options);
26
57
  if (isCancel(result)) {
27
58
  throw new Error('Operation cancelled.');
@@ -35,6 +66,7 @@ export class PromptService {
35
66
  return value;
36
67
  }
37
68
  async promptForValue(name, description, type, parseValue) {
69
+ this.checkInteractive('prompt for value');
38
70
  const fullDescription = description ? ` (${description})` : '';
39
71
  if (type === 'boolean') {
40
72
  const message = `Enable ${name}${fullDescription}?`;