@settlemint/sdk-utils 2.3.2-pr6cb5dd2e → 2.3.2-pr74f654b5

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 (89) hide show
  1. package/README.md +51 -7
  2. package/dist/environment.cjs +25 -408
  3. package/dist/environment.d.cts +3 -176
  4. package/dist/environment.d.ts +3 -176
  5. package/dist/environment.js +4 -0
  6. package/dist/filesystem.cjs +39 -123
  7. package/dist/filesystem.d.cts +4 -59
  8. package/dist/filesystem.d.ts +4 -59
  9. package/dist/filesystem.js +5 -0
  10. package/dist/http.cjs +35 -147
  11. package/dist/http.d.cts +4 -50
  12. package/dist/http.d.ts +4 -50
  13. package/dist/http.js +5 -0
  14. package/dist/index.cjs +27 -184
  15. package/dist/index.d.cts +4 -122
  16. package/dist/index.d.ts +4 -122
  17. package/dist/index.js +7 -0
  18. package/dist/json.cjs +83 -0
  19. package/dist/json.cjs.map +1 -0
  20. package/dist/json.d.cts +56 -0
  21. package/dist/json.d.ts +56 -0
  22. package/dist/json.js +80 -0
  23. package/dist/json.js.map +1 -0
  24. package/dist/logging.cjs +34 -141
  25. package/dist/logging.d.cts +4 -70
  26. package/dist/logging.d.ts +4 -70
  27. package/dist/logging.js +5 -0
  28. package/dist/package-manager.cjs +51 -196
  29. package/dist/package-manager.d.cts +7 -114
  30. package/dist/package-manager.d.ts +7 -114
  31. package/dist/package-manager.js +9 -0
  32. package/dist/retry.cjs +69 -0
  33. package/dist/retry.cjs.map +1 -0
  34. package/dist/retry.d.cts +19 -0
  35. package/dist/retry.d.ts +19 -0
  36. package/dist/retry.js +46 -0
  37. package/dist/retry.js.map +1 -0
  38. package/dist/runtime.cjs +38 -42
  39. package/dist/runtime.d.cts +2 -32
  40. package/dist/runtime.d.ts +2 -32
  41. package/dist/runtime.js +3 -0
  42. package/dist/string.cjs +76 -0
  43. package/dist/string.cjs.map +1 -0
  44. package/dist/string.d.cts +58 -0
  45. package/dist/string.d.ts +58 -0
  46. package/dist/string.js +72 -0
  47. package/dist/string.js.map +1 -0
  48. package/dist/terminal.cjs +91 -258
  49. package/dist/terminal.d.cts +11 -219
  50. package/dist/terminal.d.ts +11 -219
  51. package/dist/terminal.js +12 -0
  52. package/dist/url.cjs +25 -0
  53. package/dist/url.cjs.map +1 -0
  54. package/dist/url.d.cts +20 -0
  55. package/dist/url.d.ts +20 -0
  56. package/dist/url.js +24 -0
  57. package/dist/url.js.map +1 -0
  58. package/dist/validation.cjs +89 -183
  59. package/dist/validation.d.cts +7 -239
  60. package/dist/validation.d.ts +7 -239
  61. package/dist/validation.js +8 -0
  62. package/package.json +6 -6
  63. package/dist/environment.cjs.map +0 -1
  64. package/dist/environment.mjs +0 -383
  65. package/dist/environment.mjs.map +0 -1
  66. package/dist/filesystem.cjs.map +0 -1
  67. package/dist/filesystem.mjs +0 -105
  68. package/dist/filesystem.mjs.map +0 -1
  69. package/dist/http.cjs.map +0 -1
  70. package/dist/http.mjs +0 -129
  71. package/dist/http.mjs.map +0 -1
  72. package/dist/index.cjs.map +0 -1
  73. package/dist/index.mjs +0 -156
  74. package/dist/index.mjs.map +0 -1
  75. package/dist/logging.cjs.map +0 -1
  76. package/dist/logging.mjs +0 -123
  77. package/dist/logging.mjs.map +0 -1
  78. package/dist/package-manager.cjs.map +0 -1
  79. package/dist/package-manager.mjs +0 -167
  80. package/dist/package-manager.mjs.map +0 -1
  81. package/dist/runtime.cjs.map +0 -1
  82. package/dist/runtime.mjs +0 -23
  83. package/dist/runtime.mjs.map +0 -1
  84. package/dist/terminal.cjs.map +0 -1
  85. package/dist/terminal.mjs +0 -230
  86. package/dist/terminal.mjs.map +0 -1
  87. package/dist/validation.cjs.map +0 -1
  88. package/dist/validation.mjs +0 -159
  89. package/dist/validation.mjs.map +0 -1
package/dist/terminal.cjs CHANGED
@@ -1,279 +1,112 @@
1
- "use strict";
1
+ //#region rolldown:runtime
2
2
  var __create = Object.create;
3
3
  var __defProp = Object.defineProperty;
4
4
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
5
  var __getOwnPropNames = Object.getOwnPropertyNames;
6
6
  var __getProtoOf = Object.getPrototypeOf;
7
7
  var __hasOwnProp = Object.prototype.hasOwnProperty;
8
- var __export = (target, all) => {
9
- for (var name in all)
10
- __defProp(target, name, { get: all[name], enumerable: true });
11
- };
12
8
  var __copyProps = (to, from, except, desc) => {
13
- if (from && typeof from === "object" || typeof from === "function") {
14
- for (let key of __getOwnPropNames(from))
15
- if (!__hasOwnProp.call(to, key) && key !== except)
16
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
- }
18
- return to;
9
+ if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
10
+ key = keys[i];
11
+ if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
12
+ get: ((k) => from[k]).bind(null, key),
13
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
14
+ });
15
+ }
16
+ return to;
19
17
  };
20
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
- // If the importer is in node compatibility mode or this is not an ESM
22
- // file that has been converted to a CommonJS file using a Babel-
23
- // compatible transform (i.e. "__esModule" has not been set), then set
24
- // "default" to the CommonJS "module.exports" for node compatibility.
25
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
- mod
27
- ));
28
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
-
30
- // src/terminal.ts
31
- var terminal_exports = {};
32
- __export(terminal_exports, {
33
- CancelError: () => CancelError,
34
- CommandError: () => CommandError,
35
- SpinnerError: () => SpinnerError,
36
- ascii: () => ascii,
37
- cancel: () => cancel,
38
- executeCommand: () => executeCommand,
39
- intro: () => intro,
40
- list: () => list,
41
- maskTokens: () => maskTokens,
42
- note: () => note,
43
- outro: () => outro,
44
- spinner: () => spinner,
45
- table: () => table
18
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
19
+ value: mod,
20
+ enumerable: true
21
+ }) : target, mod));
22
+
23
+ //#endregion
24
+ const src_terminal_ascii_js = __toESM(require("./terminal/ascii.js"));
25
+ const src_terminal_cancel_js = __toESM(require("./terminal/cancel.js"));
26
+ const src_terminal_execute_command_js = __toESM(require("./terminal/execute-command.js"));
27
+ const src_terminal_intro_js = __toESM(require("./terminal/intro.js"));
28
+ const src_terminal_list_js = __toESM(require("./terminal/list.js"));
29
+ const src_terminal_note_js = __toESM(require("./terminal/note.js"));
30
+ const src_terminal_outro_js = __toESM(require("./terminal/outro.js"));
31
+ const src_terminal_spinner_js = __toESM(require("./terminal/spinner.js"));
32
+ const src_terminal_table_js = __toESM(require("./terminal/table.js"));
33
+ const src_logging_mask_tokens_js = __toESM(require("./logging/mask-tokens.js"));
34
+
35
+ Object.defineProperty(exports, 'CancelError', {
36
+ enumerable: true,
37
+ get: function () {
38
+ return src_terminal_cancel_js.CancelError;
39
+ }
46
40
  });
47
- module.exports = __toCommonJS(terminal_exports);
48
-
49
- // src/terminal/ascii.ts
50
- var import_yoctocolors = require("yoctocolors");
51
-
52
- // src/terminal/should-print.ts
53
- function shouldPrint() {
54
- return process.env.SETTLEMINT_DISABLE_TERMINAL !== "true";
55
- }
56
-
57
- // src/terminal/ascii.ts
58
- var ascii = () => {
59
- if (!shouldPrint()) {
60
- return;
41
+ Object.defineProperty(exports, 'CommandError', {
42
+ enumerable: true,
43
+ get: function () {
44
+ return src_terminal_execute_command_js.CommandError;
61
45
  }
62
- console.log(
63
- (0, import_yoctocolors.magentaBright)(`
64
- _________ __ __ .__ _____ .__ __
65
- / _____/ _____/ |__/ |_| | ____ / \\ |__| _____/ |_
66
- \\_____ \\_/ __ \\ __\\ __\\ | _/ __ \\ / \\ / \\| |/ \\ __\\
67
- / \\ ___/| | | | | |_\\ ___// Y \\ | | \\ |
68
- /_________/\\_____>__| |__| |____/\\_____>____|____/__|___|__/__|
69
- `)
70
- );
71
- };
72
-
73
- // src/logging/mask-tokens.ts
74
- var maskTokens = (output) => {
75
- return output.replace(/sm_(pat|aat|sat)_[0-9a-zA-Z]+/g, "***");
76
- };
77
-
78
- // src/terminal/cancel.ts
79
- var import_yoctocolors2 = require("yoctocolors");
80
- var CancelError = class extends Error {
81
- };
82
- var cancel = (msg) => {
83
- console.log("");
84
- console.log((0, import_yoctocolors2.inverse)((0, import_yoctocolors2.redBright)(maskTokens(msg))));
85
- console.log("");
86
- throw new CancelError(msg);
87
- };
88
-
89
- // src/terminal/execute-command.ts
90
- var import_node_child_process = require("child_process");
91
- var CommandError = class extends Error {
92
- /**
93
- * Constructs a new CommandError
94
- * @param message - The error message
95
- * @param code - The exit code of the command
96
- * @param output - The output of the command
97
- */
98
- constructor(message, code, output) {
99
- super(message);
100
- this.code = code;
101
- this.output = output;
46
+ });
47
+ Object.defineProperty(exports, 'SpinnerError', {
48
+ enumerable: true,
49
+ get: function () {
50
+ return src_terminal_spinner_js.SpinnerError;
102
51
  }
103
- };
104
- async function executeCommand(command, args, options) {
105
- const { silent, ...spawnOptions } = options ?? {};
106
- const child = (0, import_node_child_process.spawn)(command, args, { ...spawnOptions, env: { ...process.env, ...options?.env } });
107
- process.stdin.pipe(child.stdin);
108
- const output = [];
109
- return new Promise((resolve, reject) => {
110
- child.stdout.on("data", (data) => {
111
- const maskedData = maskTokens(data.toString());
112
- if (!silent) {
113
- process.stdout.write(maskedData);
114
- }
115
- output.push(maskedData);
116
- });
117
- child.stderr.on("data", (data) => {
118
- const maskedData = maskTokens(data.toString());
119
- if (!silent) {
120
- process.stderr.write(maskedData);
121
- }
122
- output.push(maskedData);
123
- });
124
- child.on(
125
- "error",
126
- (err) => reject(new CommandError(err.message, "code" in err && typeof err.code === "number" ? err.code : 1, output))
127
- );
128
- child.on("close", (code) => {
129
- if (code === 0 || code === null || code === 143) {
130
- process.stdin.unpipe(child.stdin);
131
- resolve(output);
132
- return;
133
- }
134
- reject(new CommandError(`Command "${command}" exited with code ${code}`, code, output));
135
- });
136
- });
137
- }
138
-
139
- // src/terminal/intro.ts
140
- var import_yoctocolors3 = require("yoctocolors");
141
- var intro = (msg) => {
142
- if (!shouldPrint()) {
143
- return;
52
+ });
53
+ Object.defineProperty(exports, 'ascii', {
54
+ enumerable: true,
55
+ get: function () {
56
+ return src_terminal_ascii_js.ascii;
144
57
  }
145
- console.log("");
146
- console.log((0, import_yoctocolors3.magentaBright)(maskTokens(msg)));
147
- console.log("");
148
- };
149
-
150
- // src/terminal/note.ts
151
- var import_yoctocolors4 = require("yoctocolors");
152
- var note = (message, level = "info") => {
153
- if (!shouldPrint()) {
154
- return;
58
+ });
59
+ Object.defineProperty(exports, 'cancel', {
60
+ enumerable: true,
61
+ get: function () {
62
+ return src_terminal_cancel_js.cancel;
155
63
  }
156
- const maskedMessage = maskTokens(message);
157
- console.log("");
158
- if (level === "warn") {
159
- console.warn((0, import_yoctocolors4.yellowBright)(maskedMessage));
160
- return;
64
+ });
65
+ Object.defineProperty(exports, 'executeCommand', {
66
+ enumerable: true,
67
+ get: function () {
68
+ return src_terminal_execute_command_js.executeCommand;
161
69
  }
162
- console.log(maskedMessage);
163
- };
164
-
165
- // src/terminal/list.ts
166
- function list(title, items) {
167
- const formatItems = (items2) => {
168
- return items2.map((item) => {
169
- if (Array.isArray(item)) {
170
- return item.map((subItem) => ` \u2022 ${subItem}`).join("\n");
171
- }
172
- return ` \u2022 ${item}`;
173
- }).join("\n");
174
- };
175
- return note(`${title}:
176
-
177
- ${formatItems(items)}`);
178
- }
179
-
180
- // src/terminal/outro.ts
181
- var import_yoctocolors5 = require("yoctocolors");
182
- var outro = (msg) => {
183
- if (!shouldPrint()) {
184
- return;
70
+ });
71
+ Object.defineProperty(exports, 'intro', {
72
+ enumerable: true,
73
+ get: function () {
74
+ return src_terminal_intro_js.intro;
185
75
  }
186
- console.log("");
187
- console.log((0, import_yoctocolors5.inverse)((0, import_yoctocolors5.greenBright)(maskTokens(msg))));
188
- console.log("");
189
- };
190
-
191
- // src/terminal/spinner.ts
192
- var import_is_in_ci = __toESM(require("is-in-ci"), 1);
193
- var import_yocto_spinner = __toESM(require("yocto-spinner"), 1);
194
- var import_yoctocolors6 = require("yoctocolors");
195
- var SpinnerError = class extends Error {
196
- constructor(message, originalError) {
197
- super(message);
198
- this.originalError = originalError;
199
- this.name = "SpinnerError";
76
+ });
77
+ Object.defineProperty(exports, 'list', {
78
+ enumerable: true,
79
+ get: function () {
80
+ return src_terminal_list_js.list;
200
81
  }
201
- };
202
- var spinner = async (options) => {
203
- const handleError = (error) => {
204
- const errorMessage = maskTokens(error.message);
205
- note((0, import_yoctocolors6.redBright)(`${errorMessage}
206
-
207
- ${error.stack}`));
208
- throw new SpinnerError(errorMessage, error);
209
- };
210
- if (import_is_in_ci.default || !shouldPrint()) {
211
- try {
212
- return await options.task();
213
- } catch (err) {
214
- return handleError(err);
215
- }
82
+ });
83
+ Object.defineProperty(exports, 'maskTokens', {
84
+ enumerable: true,
85
+ get: function () {
86
+ return src_logging_mask_tokens_js.maskTokens;
216
87
  }
217
- const spinner2 = (0, import_yocto_spinner.default)({ stream: process.stdout }).start(options.startMessage);
218
- try {
219
- const result = await options.task(spinner2);
220
- spinner2.success(options.stopMessage);
221
- await new Promise((resolve) => process.nextTick(resolve));
222
- return result;
223
- } catch (err) {
224
- spinner2.error((0, import_yoctocolors6.redBright)(`${options.startMessage} --> Error!`));
225
- return handleError(err);
88
+ });
89
+ Object.defineProperty(exports, 'note', {
90
+ enumerable: true,
91
+ get: function () {
92
+ return src_terminal_note_js.note;
226
93
  }
227
- };
228
-
229
- // src/string.ts
230
- function capitalizeFirstLetter(val) {
231
- return String(val).charAt(0).toUpperCase() + String(val).slice(1);
232
- }
233
- function camelCaseToWords(s) {
234
- const result = s.replace(/([a-z])([A-Z])/g, "$1 $2");
235
- const withSpaces = result.replace(/([A-Z])([a-z])/g, " $1$2");
236
- const capitalized = capitalizeFirstLetter(withSpaces);
237
- return capitalized.replace(/\s+/g, " ").trim();
238
- }
239
-
240
- // src/terminal/table.ts
241
- var import_console_table_printer = require("console-table-printer");
242
- var import_yoctocolors7 = require("yoctocolors");
243
- function table(title, data) {
244
- if (!shouldPrint()) {
245
- return;
94
+ });
95
+ Object.defineProperty(exports, 'outro', {
96
+ enumerable: true,
97
+ get: function () {
98
+ return src_terminal_outro_js.outro;
246
99
  }
247
- note(title);
248
- if (!data || data.length === 0) {
249
- note("No data to display");
250
- return;
100
+ });
101
+ Object.defineProperty(exports, 'spinner', {
102
+ enumerable: true,
103
+ get: function () {
104
+ return src_terminal_spinner_js.spinner;
251
105
  }
252
- const columnKeys = Object.keys(data[0]);
253
- const table2 = new import_console_table_printer.Table({
254
- columns: columnKeys.map((key) => ({
255
- name: key,
256
- title: (0, import_yoctocolors7.whiteBright)(camelCaseToWords(key)),
257
- alignment: "left"
258
- }))
259
- });
260
- table2.addRows(data);
261
- table2.printTable();
262
- }
263
- // Annotate the CommonJS export names for ESM import in node:
264
- 0 && (module.exports = {
265
- CancelError,
266
- CommandError,
267
- SpinnerError,
268
- ascii,
269
- cancel,
270
- executeCommand,
271
- intro,
272
- list,
273
- maskTokens,
274
- note,
275
- outro,
276
- spinner,
277
- table
278
106
  });
279
- //# sourceMappingURL=terminal.cjs.map
107
+ Object.defineProperty(exports, 'table', {
108
+ enumerable: true,
109
+ get: function () {
110
+ return src_terminal_table_js.table;
111
+ }
112
+ });
@@ -1,219 +1,11 @@
1
- import { SpawnOptionsWithoutStdio } from 'node:child_process';
2
- import { Spinner } from 'yocto-spinner';
3
-
4
- /**
5
- * Prints the SettleMint ASCII art logo to the console in magenta color.
6
- * Used for CLI branding and visual identification.
7
- *
8
- * @example
9
- * import { ascii } from "@settlemint/sdk-utils/terminal";
10
- *
11
- * // Prints the SettleMint logo
12
- * ascii();
13
- */
14
- declare const ascii: () => void;
15
-
16
- /**
17
- * Error class used to indicate that the operation was cancelled.
18
- * This error is used to signal that the operation should be aborted.
19
- */
20
- declare class CancelError extends Error {
21
- }
22
- /**
23
- * Displays an error message in red inverse text and throws a CancelError.
24
- * Used to terminate execution with a visible error message.
25
- * Any sensitive tokens in the message are masked before display.
26
- *
27
- * @param msg - The error message to display
28
- * @returns never - Function does not return as it throws an error
29
- * @example
30
- * import { cancel } from "@settlemint/sdk-utils/terminal";
31
- *
32
- * // Exits process with error message
33
- * cancel("An error occurred");
34
- */
35
- declare const cancel: (msg: string) => never;
36
-
37
- /**
38
- * Options for executing a command, extending SpawnOptionsWithoutStdio
39
- */
40
- interface ExecuteCommandOptions extends SpawnOptionsWithoutStdio {
41
- /** Whether to suppress output to stdout/stderr */
42
- silent?: boolean;
43
- }
44
- /**
45
- * Error class for command execution errors
46
- * @extends Error
47
- */
48
- declare class CommandError extends Error {
49
- readonly code: number;
50
- readonly output: string[];
51
- /**
52
- * Constructs a new CommandError
53
- * @param message - The error message
54
- * @param code - The exit code of the command
55
- * @param output - The output of the command
56
- */
57
- constructor(message: string, code: number, output: string[]);
58
- }
59
- /**
60
- * Executes a command with the given arguments in a child process.
61
- * Pipes stdin to the child process and captures stdout/stderr output.
62
- * Masks any sensitive tokens in the output before displaying or returning.
63
- *
64
- * @param command - The command to execute
65
- * @param args - Array of arguments to pass to the command
66
- * @param options - Options for customizing command execution
67
- * @returns Array of output strings from stdout and stderr
68
- * @throws {CommandError} If the process fails to start or exits with non-zero code
69
- * @example
70
- * import { executeCommand } from "@settlemint/sdk-utils/terminal";
71
- *
72
- * // Execute git clone
73
- * await executeCommand("git", ["clone", "repo-url"]);
74
- *
75
- * // Execute silently
76
- * await executeCommand("npm", ["install"], { silent: true });
77
- */
78
- declare function executeCommand(command: string, args: string[], options?: ExecuteCommandOptions): Promise<string[]>;
79
-
80
- /**
81
- * Displays an introductory message in magenta text with padding.
82
- * Any sensitive tokens in the message are masked before display.
83
- *
84
- * @param msg - The message to display as introduction
85
- * @example
86
- * import { intro } from "@settlemint/sdk-utils/terminal";
87
- *
88
- * // Display intro message
89
- * intro("Starting deployment...");
90
- */
91
- declare const intro: (msg: string) => void;
92
-
93
- /**
94
- * Displays a list of items in a formatted manner, supporting nested items.
95
- *
96
- * @param title - The title of the list
97
- * @param items - The items to display, can be strings or arrays for nested items
98
- * @returns The formatted list
99
- * @example
100
- * import { list } from "@settlemint/sdk-utils/terminal";
101
- *
102
- * // Simple list
103
- * list("Use cases", ["use case 1", "use case 2", "use case 3"]);
104
- *
105
- * // Nested list
106
- * list("Providers", [
107
- * "AWS",
108
- * ["us-east-1", "eu-west-1"],
109
- * "Azure",
110
- * ["eastus", "westeurope"]
111
- * ]);
112
- */
113
- declare function list(title: string, items: Array<string | string[]>): void;
114
-
115
- /**
116
- * Displays a note message with optional warning level formatting.
117
- * Regular notes are displayed in normal text, while warnings are shown in yellow.
118
- * Any sensitive tokens in the message are masked before display.
119
- *
120
- * @param message - The message to display as a note
121
- * @param level - The note level: "info" (default) or "warn" for warning styling
122
- * @example
123
- * import { note } from "@settlemint/sdk-utils/terminal";
124
- *
125
- * // Display info note
126
- * note("Operation completed successfully");
127
- *
128
- * // Display warning note
129
- * note("Low disk space remaining", "warn");
130
- */
131
- declare const note: (message: string, level?: "info" | "warn") => void;
132
-
133
- /**
134
- * Displays a closing message in green inverted text with padding.
135
- * Any sensitive tokens in the message are masked before display.
136
- *
137
- * @param msg - The message to display as conclusion
138
- * @example
139
- * import { outro } from "@settlemint/sdk-utils/terminal";
140
- *
141
- * // Display outro message
142
- * outro("Deployment completed successfully!");
143
- */
144
- declare const outro: (msg: string) => void;
145
-
146
- /**
147
- * Error class used to indicate that the spinner operation failed.
148
- * This error is used to signal that the operation should be aborted.
149
- */
150
- declare class SpinnerError extends Error {
151
- readonly originalError: Error;
152
- constructor(message: string, originalError: Error);
153
- }
154
- /**
155
- * Options for configuring the spinner behavior
156
- */
157
- interface SpinnerOptions<R> {
158
- /** Message to display when spinner starts */
159
- startMessage: string;
160
- /** Async task to execute while spinner is active */
161
- task: (spinner?: Spinner) => Promise<R>;
162
- /** Message to display when spinner completes successfully */
163
- stopMessage: string;
164
- }
165
- /**
166
- * Displays a loading spinner while executing an async task.
167
- * Shows progress with start/stop messages and handles errors.
168
- * Spinner is disabled in CI environments.
169
- *
170
- * @param options - Configuration options for the spinner
171
- * @returns The result from the executed task
172
- * @throws Will exit process with code 1 if task fails
173
- * @example
174
- * import { spinner } from "@settlemint/sdk-utils/terminal";
175
- *
176
- * // Show spinner during async task
177
- * const result = await spinner({
178
- * startMessage: "Deploying...",
179
- * task: async () => {
180
- * // Async work here
181
- * return "success";
182
- * },
183
- * stopMessage: "Deployed successfully!"
184
- * });
185
- */
186
- declare const spinner: <R>(options: SpinnerOptions<R>) => Promise<R>;
187
-
188
- /**
189
- * Displays data in a formatted table in the terminal.
190
- *
191
- * @param title - Title to display above the table
192
- * @param data - Array of objects to display in table format
193
- * @example
194
- * import { table } from "@settlemint/sdk-utils/terminal";
195
- *
196
- * const data = [
197
- * { name: "Item 1", value: 100 },
198
- * { name: "Item 2", value: 200 }
199
- * ];
200
- *
201
- * table("My Table", data);
202
- */
203
- declare function table(title: string, data: unknown[]): void;
204
-
205
- /**
206
- * Masks sensitive SettleMint tokens in output text by replacing them with asterisks.
207
- * Handles personal access tokens (PAT), application access tokens (AAT), and service account tokens (SAT).
208
- *
209
- * @param output - The text string that may contain sensitive tokens
210
- * @returns The text with any sensitive tokens masked with asterisks
211
- * @example
212
- * import { maskTokens } from "@settlemint/sdk-utils/terminal";
213
- *
214
- * // Masks a token in text
215
- * const masked = maskTokens("Token: sm_pat_****"); // "Token: ***"
216
- */
217
- declare const maskTokens: (output: string) => string;
218
-
219
- export { CancelError, CommandError, type ExecuteCommandOptions, SpinnerError, type SpinnerOptions, ascii, cancel, executeCommand, intro, list, maskTokens, note, outro, spinner, table };
1
+ import { ascii } from "./terminal/ascii.js";
2
+ import { CancelError, cancel } from "./terminal/cancel.js";
3
+ import { CommandError, ExecuteCommandOptions, executeCommand } from "./terminal/execute-command.js";
4
+ import { intro } from "./terminal/intro.js";
5
+ import { list } from "./terminal/list.js";
6
+ import { note } from "./terminal/note.js";
7
+ import { outro } from "./terminal/outro.js";
8
+ import { SpinnerError, SpinnerOptions, spinner } from "./terminal/spinner.js";
9
+ import { table } from "./terminal/table.js";
10
+ import { maskTokens } from "./logging/mask-tokens.js";
11
+ export { CancelError, CommandError, ExecuteCommandOptions, SpinnerError, SpinnerOptions, ascii, cancel, executeCommand, intro, list, maskTokens, note, outro, spinner, table };