@settlemint/sdk-utils 2.3.2-prfd3a56ad → 2.3.3

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 (98) hide show
  1. package/README.md +121 -77
  2. package/dist/environment.cjs +17708 -384
  3. package/dist/environment.cjs.map +1 -1
  4. package/dist/environment.d.cts +263 -98
  5. package/dist/environment.d.ts +263 -98
  6. package/dist/environment.js +17746 -0
  7. package/dist/environment.js.map +1 -0
  8. package/dist/filesystem.cjs +6746 -113
  9. package/dist/filesystem.cjs.map +1 -1
  10. package/dist/filesystem.d.cts +22 -1
  11. package/dist/filesystem.d.ts +22 -1
  12. package/dist/filesystem.js +6766 -0
  13. package/dist/filesystem.js.map +1 -0
  14. package/dist/http.cjs +214 -94
  15. package/dist/http.cjs.map +1 -1
  16. package/dist/http.d.cts +9 -1
  17. package/dist/http.d.ts +9 -1
  18. package/dist/http.js +226 -0
  19. package/dist/http.js.map +1 -0
  20. package/dist/index.cjs +295 -104
  21. package/dist/index.cjs.map +1 -1
  22. package/dist/index.d.cts +26 -1
  23. package/dist/index.d.ts +26 -1
  24. package/dist/index.js +306 -0
  25. package/dist/index.js.map +1 -0
  26. package/dist/json.cjs +83 -0
  27. package/dist/json.cjs.map +1 -0
  28. package/dist/json.d.cts +56 -0
  29. package/dist/json.d.ts +56 -0
  30. package/dist/json.js +80 -0
  31. package/dist/json.js.map +1 -0
  32. package/dist/logging.cjs +209 -137
  33. package/dist/logging.cjs.map +1 -1
  34. package/dist/logging.d.cts +23 -14
  35. package/dist/logging.d.ts +23 -14
  36. package/dist/logging.js +221 -0
  37. package/dist/logging.js.map +1 -0
  38. package/dist/package-manager.cjs +7353 -173
  39. package/dist/package-manager.cjs.map +1 -1
  40. package/dist/package-manager.d.cts +26 -3
  41. package/dist/package-manager.d.ts +26 -3
  42. package/dist/package-manager.js +7385 -0
  43. package/dist/package-manager.js.map +1 -0
  44. package/dist/retry.cjs +137 -0
  45. package/dist/retry.cjs.map +1 -0
  46. package/dist/retry.d.cts +19 -0
  47. package/dist/retry.d.ts +19 -0
  48. package/dist/retry.js +136 -0
  49. package/dist/retry.js.map +1 -0
  50. package/dist/runtime.cjs +58 -40
  51. package/dist/runtime.cjs.map +1 -1
  52. package/dist/runtime.d.cts +3 -0
  53. package/dist/runtime.d.ts +3 -0
  54. package/dist/runtime.js +45 -0
  55. package/dist/runtime.js.map +1 -0
  56. package/dist/string.cjs +76 -0
  57. package/dist/string.cjs.map +1 -0
  58. package/dist/string.d.cts +58 -0
  59. package/dist/string.d.ts +58 -0
  60. package/dist/string.js +72 -0
  61. package/dist/string.js.map +1 -0
  62. package/dist/terminal.cjs +426 -229
  63. package/dist/terminal.cjs.map +1 -1
  64. package/dist/terminal.d.cts +54 -24
  65. package/dist/terminal.d.ts +54 -24
  66. package/dist/terminal.js +441 -0
  67. package/dist/terminal.js.map +1 -0
  68. package/dist/url.cjs +25 -0
  69. package/dist/url.cjs.map +1 -0
  70. package/dist/url.d.cts +20 -0
  71. package/dist/url.d.ts +20 -0
  72. package/dist/url.js +24 -0
  73. package/dist/url.js.map +1 -0
  74. package/dist/validation.cjs +10486 -193
  75. package/dist/validation.cjs.map +1 -1
  76. package/dist/validation.d.cts +124 -94
  77. package/dist/validation.d.ts +124 -94
  78. package/dist/validation.js +10482 -0
  79. package/dist/validation.js.map +1 -0
  80. package/package.json +6 -6
  81. package/dist/environment.mjs +0 -384
  82. package/dist/environment.mjs.map +0 -1
  83. package/dist/filesystem.mjs +0 -105
  84. package/dist/filesystem.mjs.map +0 -1
  85. package/dist/http.mjs +0 -80
  86. package/dist/http.mjs.map +0 -1
  87. package/dist/index.mjs +0 -90
  88. package/dist/index.mjs.map +0 -1
  89. package/dist/logging.mjs +0 -123
  90. package/dist/logging.mjs.map +0 -1
  91. package/dist/package-manager.mjs +0 -167
  92. package/dist/package-manager.mjs.map +0 -1
  93. package/dist/runtime.mjs +0 -23
  94. package/dist/runtime.mjs.map +0 -1
  95. package/dist/terminal.mjs +0 -230
  96. package/dist/terminal.mjs.map +0 -1
  97. package/dist/validation.mjs +0 -161
  98. package/dist/validation.mjs.map +0 -1
package/dist/logging.cjs CHANGED
@@ -1,152 +1,224 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
1
 
20
- // src/logging.ts
21
- var logging_exports = {};
22
- __export(logging_exports, {
23
- createLogger: () => createLogger,
24
- maskTokens: () => maskTokens,
25
- requestLogger: () => requestLogger
26
- });
27
- module.exports = __toCommonJS(logging_exports);
28
-
29
- // src/logging/mask-tokens.ts
30
- var maskTokens = (output) => {
31
- return output.replace(/sm_(pat|aat|sat)_[0-9a-zA-Z]+/g, "***");
2
+ //#region src/logging/mask-tokens.ts
3
+ /**
4
+ * Masks sensitive SettleMint tokens in output text by replacing them with asterisks.
5
+ * Handles personal access tokens (PAT), application access tokens (AAT), and service account tokens (SAT).
6
+ *
7
+ * @param output - The text string that may contain sensitive tokens
8
+ * @returns The text with any sensitive tokens masked with asterisks
9
+ * @example
10
+ * import { maskTokens } from "@settlemint/sdk-utils/terminal";
11
+ *
12
+ * // Masks a token in text
13
+ * const masked = maskTokens("Token: sm_pat_****"); // "Token: ***"
14
+ */
15
+ const maskTokens = (output) => {
16
+ return output.replace(/sm_(pat|aat|sat)_[0-9a-zA-Z]+/g, "***");
32
17
  };
33
18
 
34
- // src/logging/logger.ts
19
+ //#endregion
20
+ //#region src/logging/logger.ts
21
+ /**
22
+ * Creates a simple logger with configurable log level
23
+ *
24
+ * @param options - Configuration options for the logger
25
+ * @param options.level - The minimum log level to output (default: warn)
26
+ * @param options.prefix - The prefix to add to the log message (default: "")
27
+ * @returns A logger instance with debug, info, warn, and error methods
28
+ *
29
+ * @example
30
+ * import { createLogger } from "@/utils/logging/logger";
31
+ *
32
+ * const logger = createLogger({ level: 'info' });
33
+ *
34
+ * logger.info('User logged in', { userId: '123' });
35
+ * logger.error('Operation failed', new Error('Connection timeout'));
36
+ */
35
37
  function createLogger(options = {}) {
36
- const { level = "warn", prefix = "" } = options;
37
- const logLevels = {
38
- debug: 0,
39
- info: 1,
40
- warn: 2,
41
- error: 3,
42
- none: 4
43
- };
44
- const currentLevelValue = logLevels[level];
45
- const formatArgs = (args) => {
46
- if (args.length === 0 || args.every((arg) => arg === void 0 || arg === null)) {
47
- return "";
48
- }
49
- const formatted = args.map((arg) => {
50
- if (arg instanceof Error) {
51
- return `
52
- ${arg.stack || arg.message}`;
53
- }
54
- if (typeof arg === "object" && arg !== null) {
55
- return `
56
- ${JSON.stringify(arg, null, 2)}`;
57
- }
58
- return ` ${String(arg)}`;
59
- }).join("");
60
- return `, args:${formatted}`;
61
- };
62
- const shouldLog = (level2) => {
63
- return logLevels[level2] >= currentLevelValue;
64
- };
65
- return {
66
- debug: (message, ...args) => {
67
- if (shouldLog("debug")) {
68
- console.debug(`\x1B[32m${prefix}[DEBUG] ${maskTokens(message)}${maskTokens(formatArgs(args))}\x1B[0m`);
69
- }
70
- },
71
- info: (message, ...args) => {
72
- if (shouldLog("info")) {
73
- console.info(`\x1B[34m${prefix}[INFO] ${maskTokens(message)}${maskTokens(formatArgs(args))}\x1B[0m`);
74
- }
75
- },
76
- warn: (message, ...args) => {
77
- if (shouldLog("warn")) {
78
- console.warn(`\x1B[33m${prefix}[WARN] ${maskTokens(message)}${maskTokens(formatArgs(args))}\x1B[0m`);
79
- }
80
- },
81
- error: (message, ...args) => {
82
- if (shouldLog("error")) {
83
- console.error(`\x1B[31m${prefix}[ERROR] ${maskTokens(message)}${maskTokens(formatArgs(args))}\x1B[0m`);
84
- }
85
- }
86
- };
38
+ const { level = "warn", prefix = "" } = options;
39
+ const logLevels = {
40
+ debug: 0,
41
+ info: 1,
42
+ warn: 2,
43
+ error: 3,
44
+ none: 4
45
+ };
46
+ const currentLevelValue = logLevels[level];
47
+ const formatArgs = (args) => {
48
+ if (args.length === 0 || args.every((arg) => arg === undefined || arg === null)) {
49
+ return "";
50
+ }
51
+ const formatted = args.map((arg) => {
52
+ if (arg instanceof Error) {
53
+ return `\n${arg.stack || arg.message}`;
54
+ }
55
+ if (typeof arg === "object" && arg !== null) {
56
+ return `\n${JSON.stringify(arg, null, 2)}`;
57
+ }
58
+ return ` ${String(arg)}`;
59
+ }).join("");
60
+ return `, args:${formatted}`;
61
+ };
62
+ const shouldLog = (level$1) => {
63
+ return logLevels[level$1] >= currentLevelValue;
64
+ };
65
+ return {
66
+ debug: (message, ...args) => {
67
+ if (shouldLog("debug")) {
68
+ console.debug(`\x1b[32m${prefix}[DEBUG] ${maskTokens(message)}${maskTokens(formatArgs(args))}\x1b[0m`);
69
+ }
70
+ },
71
+ info: (message, ...args) => {
72
+ if (shouldLog("info")) {
73
+ console.info(`\x1b[34m${prefix}[INFO] ${maskTokens(message)}${maskTokens(formatArgs(args))}\x1b[0m`);
74
+ }
75
+ },
76
+ warn: (message, ...args) => {
77
+ if (shouldLog("warn")) {
78
+ console.warn(`\x1b[33m${prefix}[WARN] ${maskTokens(message)}${maskTokens(formatArgs(args))}\x1b[0m`);
79
+ }
80
+ },
81
+ error: (message, ...args) => {
82
+ if (shouldLog("error")) {
83
+ console.error(`\x1b[31m${prefix}[ERROR] ${maskTokens(message)}${maskTokens(formatArgs(args))}\x1b[0m`);
84
+ }
85
+ }
86
+ };
87
87
  }
88
- var logger = createLogger();
88
+ /**
89
+ * Default logger instance with standard configuration
90
+ */
91
+ const logger = createLogger();
89
92
 
90
- // src/string.ts
93
+ //#endregion
94
+ //#region src/string.ts
95
+ /**
96
+ * Capitalizes the first letter of a string.
97
+ *
98
+ * @param val - The string to capitalize
99
+ * @returns The input string with its first letter capitalized
100
+ *
101
+ * @example
102
+ * import { capitalizeFirstLetter } from "@settlemint/sdk-utils";
103
+ *
104
+ * const capitalized = capitalizeFirstLetter("hello");
105
+ * // Returns: "Hello"
106
+ */
107
+ function capitalizeFirstLetter(val) {
108
+ return String(val).charAt(0).toUpperCase() + String(val).slice(1);
109
+ }
110
+ /**
111
+ * Converts a camelCase string to a human-readable string.
112
+ *
113
+ * @param s - The camelCase string to convert
114
+ * @returns The human-readable string
115
+ *
116
+ * @example
117
+ * import { camelCaseToWords } from "@settlemint/sdk-utils";
118
+ *
119
+ * const words = camelCaseToWords("camelCaseString");
120
+ * // Returns: "Camel Case String"
121
+ */
122
+ function camelCaseToWords(s) {
123
+ const result = s.replace(/([a-z])([A-Z])/g, "$1 $2");
124
+ const withSpaces = result.replace(/([A-Z])([a-z])/g, " $1$2");
125
+ const capitalized = capitalizeFirstLetter(withSpaces);
126
+ return capitalized.replace(/\s+/g, " ").trim();
127
+ }
128
+ /**
129
+ * Replaces underscores and hyphens with spaces.
130
+ *
131
+ * @param s - The string to replace underscores and hyphens with spaces
132
+ * @returns The input string with underscores and hyphens replaced with spaces
133
+ *
134
+ * @example
135
+ * import { replaceUnderscoresAndHyphensWithSpaces } from "@settlemint/sdk-utils";
136
+ *
137
+ * const result = replaceUnderscoresAndHyphensWithSpaces("Already_Spaced-Second");
138
+ * // Returns: "Already Spaced Second"
139
+ */
140
+ function replaceUnderscoresAndHyphensWithSpaces(s) {
141
+ return s.replace(/[-_]/g, " ");
142
+ }
143
+ /**
144
+ * Truncates a string to a maximum length and appends "..." if it is longer.
145
+ *
146
+ * @param value - The string to truncate
147
+ * @param maxLength - The maximum length of the string
148
+ * @returns The truncated string or the original string if it is shorter than the maximum length
149
+ *
150
+ * @example
151
+ * import { truncate } from "@settlemint/sdk-utils";
152
+ *
153
+ * const truncated = truncate("Hello, world!", 10);
154
+ * // Returns: "Hello, wor..."
155
+ */
91
156
  function truncate(value, maxLength) {
92
- if (value.length <= maxLength) {
93
- return value;
94
- }
95
- return `${value.slice(0, maxLength)}...`;
157
+ if (value.length <= maxLength) {
158
+ return value;
159
+ }
160
+ return `${value.slice(0, maxLength)}...`;
96
161
  }
97
162
 
98
- // src/logging/request-logger.ts
99
- var WARNING_THRESHOLD = 500;
100
- var TRUNCATE_LENGTH = 50;
101
- function requestLogger(logger2, name, fn) {
102
- return async (...args) => {
103
- const start = Date.now();
104
- try {
105
- return await fn(...args);
106
- } finally {
107
- const end = Date.now();
108
- const duration = end - start;
109
- const body = extractInfoFromBody(args[1]?.body ?? "{}");
110
- const message = `${name} path: ${args[0]}, took ${formatDuration(duration)}`;
111
- if (duration > WARNING_THRESHOLD) {
112
- logger2.warn(message, body);
113
- } else {
114
- logger2.info(message, body);
115
- }
116
- }
117
- };
163
+ //#endregion
164
+ //#region src/logging/request-logger.ts
165
+ const WARNING_THRESHOLD = 500;
166
+ const TRUNCATE_LENGTH = 50;
167
+ /**
168
+ * Logs the request and duration of a fetch call (> 500ms is logged as warn, otherwise info)
169
+ * @param logger - The logger to use
170
+ * @param name - The name of the request
171
+ * @param fn - The fetch function to use
172
+ * @returns The fetch function
173
+ */
174
+ function requestLogger(logger$1, name, fn) {
175
+ return async (...args) => {
176
+ const start = Date.now();
177
+ try {
178
+ return await fn(...args);
179
+ } finally {
180
+ const end = Date.now();
181
+ const duration = end - start;
182
+ const body = extractInfoFromBody(args[1]?.body ?? "{}");
183
+ const message = `${name} path: ${args[0]}, took ${formatDuration(duration)}`;
184
+ if (duration > WARNING_THRESHOLD) {
185
+ logger$1.warn(message, body);
186
+ } else {
187
+ logger$1.info(message, body);
188
+ }
189
+ }
190
+ };
118
191
  }
119
192
  function formatDuration(duration) {
120
- return duration < 1e3 ? `${duration}ms` : `${(duration / 1e3).toFixed(3)}s`;
193
+ return duration < 1e3 ? `${duration}ms` : `${(duration / 1e3).toFixed(3)}s`;
121
194
  }
122
195
  function extractInfoFromBody(body) {
123
- try {
124
- const parsedBody = typeof body === "string" ? JSON.parse(body) : body;
125
- if (parsedBody === null || parsedBody === void 0 || Object.keys(parsedBody).length === 0) {
126
- return null;
127
- }
128
- const dataToKeep = {};
129
- if ("query" in parsedBody) {
130
- dataToKeep.query = truncate(parsedBody.query, TRUNCATE_LENGTH);
131
- }
132
- if ("variables" in parsedBody) {
133
- dataToKeep.variables = truncate(JSON.stringify(parsedBody.variables), TRUNCATE_LENGTH);
134
- }
135
- if ("operationName" in parsedBody) {
136
- dataToKeep.operationName = truncate(parsedBody.operationName, TRUNCATE_LENGTH);
137
- }
138
- if (Object.keys(dataToKeep).length > 0) {
139
- return JSON.stringify(dataToKeep);
140
- }
141
- return truncate(JSON.stringify(parsedBody || "{}"), TRUNCATE_LENGTH);
142
- } catch {
143
- return "{}";
144
- }
196
+ try {
197
+ const parsedBody = typeof body === "string" ? JSON.parse(body) : body;
198
+ if (parsedBody === null || parsedBody === undefined || Object.keys(parsedBody).length === 0) {
199
+ return null;
200
+ }
201
+ const dataToKeep = {};
202
+ if ("query" in parsedBody) {
203
+ dataToKeep.query = truncate(parsedBody.query, TRUNCATE_LENGTH);
204
+ }
205
+ if ("variables" in parsedBody) {
206
+ dataToKeep.variables = truncate(JSON.stringify(parsedBody.variables), TRUNCATE_LENGTH);
207
+ }
208
+ if ("operationName" in parsedBody) {
209
+ dataToKeep.operationName = truncate(parsedBody.operationName, TRUNCATE_LENGTH);
210
+ }
211
+ if (Object.keys(dataToKeep).length > 0) {
212
+ return JSON.stringify(dataToKeep);
213
+ }
214
+ return truncate(JSON.stringify(parsedBody || "{}"), TRUNCATE_LENGTH);
215
+ } catch {
216
+ return "{}";
217
+ }
145
218
  }
146
- // Annotate the CommonJS export names for ESM import in node:
147
- 0 && (module.exports = {
148
- createLogger,
149
- maskTokens,
150
- requestLogger
151
- });
219
+
220
+ //#endregion
221
+ exports.createLogger = createLogger;
222
+ exports.maskTokens = maskTokens;
223
+ exports.requestLogger = requestLogger;
152
224
  //# sourceMappingURL=logging.cjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/logging.ts","../src/logging/mask-tokens.ts","../src/logging/logger.ts","../src/string.ts","../src/logging/request-logger.ts"],"sourcesContent":["export { createLogger, type Logger, type LoggerOptions, type LogLevel } from \"./logging/logger.js\";\nexport { requestLogger } from \"./logging/request-logger.js\";\nexport { maskTokens } from \"./logging/mask-tokens.js\";\n","/**\n * Masks sensitive SettleMint tokens in output text by replacing them with asterisks.\n * Handles personal access tokens (PAT), application access tokens (AAT), and service account tokens (SAT).\n *\n * @param output - The text string that may contain sensitive tokens\n * @returns The text with any sensitive tokens masked with asterisks\n * @example\n * import { maskTokens } from \"@settlemint/sdk-utils/terminal\";\n *\n * // Masks a token in text\n * const masked = maskTokens(\"Token: sm_pat_****\"); // \"Token: ***\"\n */\nexport const maskTokens = (output: string): string => {\n return output.replace(/sm_(pat|aat|sat)_[0-9a-zA-Z]+/g, \"***\");\n};\n","import { maskTokens } from \"./mask-tokens.js\";\n\n/**\n * Log levels supported by the logger\n */\nexport type LogLevel = \"debug\" | \"info\" | \"warn\" | \"error\" | \"none\";\n\n/**\n * Configuration options for the logger\n * @interface LoggerOptions\n */\nexport interface LoggerOptions {\n /** The minimum log level to output */\n level?: LogLevel;\n /** The prefix to add to the log message */\n prefix?: string;\n}\n\n/**\n * Simple logger interface with basic logging methods\n * @interface Logger\n */\nexport interface Logger {\n /** Log debug information */\n debug: (message: string, ...args: unknown[]) => void;\n /** Log general information */\n info: (message: string, ...args: unknown[]) => void;\n /** Log warnings */\n warn: (message: string, ...args: unknown[]) => void;\n /** Log errors */\n error: (message: string, ...args: unknown[]) => void;\n}\n\n/**\n * Creates a simple logger with configurable log level\n *\n * @param options - Configuration options for the logger\n * @param options.level - The minimum log level to output (default: warn)\n * @param options.prefix - The prefix to add to the log message (default: \"\")\n * @returns A logger instance with debug, info, warn, and error methods\n *\n * @example\n * import { createLogger } from \"@/utils/logging/logger\";\n *\n * const logger = createLogger({ level: 'info' });\n *\n * logger.info('User logged in', { userId: '123' });\n * logger.error('Operation failed', new Error('Connection timeout'));\n */\nexport function createLogger(options: LoggerOptions = {}): Logger {\n const { level = \"warn\", prefix = \"\" } = options;\n\n const logLevels: Record<LogLevel, number> = {\n debug: 0,\n info: 1,\n warn: 2,\n error: 3,\n none: 4,\n };\n\n const currentLevelValue = logLevels[level];\n\n const formatArgs = (args: unknown[]): string => {\n if (args.length === 0 || args.every((arg) => arg === undefined || arg === null)) {\n return \"\";\n }\n\n const formatted = args\n .map((arg) => {\n if (arg instanceof Error) {\n return `\\n${arg.stack || arg.message}`;\n }\n if (typeof arg === \"object\" && arg !== null) {\n return `\\n${JSON.stringify(arg, null, 2)}`;\n }\n return ` ${String(arg)}`;\n })\n .join(\"\");\n\n return `, args:${formatted}`;\n };\n\n const shouldLog = (level: LogLevel): boolean => {\n return logLevels[level] >= currentLevelValue;\n };\n\n return {\n debug: (message: string, ...args: unknown[]) => {\n if (shouldLog(\"debug\")) {\n console.debug(`\\x1b[32m${prefix}[DEBUG] ${maskTokens(message)}${maskTokens(formatArgs(args))}\\x1b[0m`);\n }\n },\n info: (message: string, ...args: unknown[]) => {\n if (shouldLog(\"info\")) {\n console.info(`\\x1b[34m${prefix}[INFO] ${maskTokens(message)}${maskTokens(formatArgs(args))}\\x1b[0m`);\n }\n },\n warn: (message: string, ...args: unknown[]) => {\n if (shouldLog(\"warn\")) {\n console.warn(`\\x1b[33m${prefix}[WARN] ${maskTokens(message)}${maskTokens(formatArgs(args))}\\x1b[0m`);\n }\n },\n error: (message: string, ...args: unknown[]) => {\n if (shouldLog(\"error\")) {\n console.error(`\\x1b[31m${prefix}[ERROR] ${maskTokens(message)}${maskTokens(formatArgs(args))}\\x1b[0m`);\n }\n },\n };\n}\n\n/**\n * Default logger instance with standard configuration\n */\nexport const logger = createLogger();\n","/**\n * Capitalizes the first letter of a string.\n *\n * @param val - The string to capitalize\n * @returns The input string with its first letter capitalized\n *\n * @example\n * import { capitalizeFirstLetter } from \"@settlemint/sdk-utils\";\n *\n * const capitalized = capitalizeFirstLetter(\"hello\");\n * // Returns: \"Hello\"\n */\nexport function capitalizeFirstLetter(val: string) {\n return String(val).charAt(0).toUpperCase() + String(val).slice(1);\n}\n\n/**\n * Converts a camelCase string to a human-readable string.\n *\n * @param s - The camelCase string to convert\n * @returns The human-readable string\n *\n * @example\n * import { camelCaseToWords } from \"@settlemint/sdk-utils\";\n *\n * const words = camelCaseToWords(\"camelCaseString\");\n * // Returns: \"Camel Case String\"\n */\nexport function camelCaseToWords(s: string) {\n const result = s.replace(/([a-z])([A-Z])/g, \"$1 $2\");\n const withSpaces = result.replace(/([A-Z])([a-z])/g, \" $1$2\");\n const capitalized = capitalizeFirstLetter(withSpaces);\n return capitalized.replace(/\\s+/g, \" \").trim();\n}\n\n/**\n * Replaces underscores and hyphens with spaces.\n *\n * @param s - The string to replace underscores and hyphens with spaces\n * @returns The input string with underscores and hyphens replaced with spaces\n *\n * @example\n * import { replaceUnderscoresAndHyphensWithSpaces } from \"@settlemint/sdk-utils\";\n *\n * const result = replaceUnderscoresAndHyphensWithSpaces(\"Already_Spaced-Second\");\n * // Returns: \"Already Spaced Second\"\n */\nexport function replaceUnderscoresAndHyphensWithSpaces(s: string) {\n return s.replace(/[-_]/g, \" \");\n}\n\n/**\n * Truncates a string to a maximum length and appends \"...\" if it is longer.\n *\n * @param value - The string to truncate\n * @param maxLength - The maximum length of the string\n * @returns The truncated string or the original string if it is shorter than the maximum length\n *\n * @example\n * import { truncate } from \"@settlemint/sdk-utils\";\n *\n * const truncated = truncate(\"Hello, world!\", 10);\n * // Returns: \"Hello, wor...\"\n */\nexport function truncate(value: string, maxLength: number) {\n if (value.length <= maxLength) {\n return value;\n }\n return `${value.slice(0, maxLength)}...`;\n}\n","import { truncate } from \"../string.js\";\nimport type { Logger } from \"./logger.js\";\n\nconst WARNING_THRESHOLD = 500;\nconst TRUNCATE_LENGTH = 50;\n\n/**\n * Logs the request and duration of a fetch call (> 500ms is logged as warn, otherwise info)\n * @param logger - The logger to use\n * @param name - The name of the request\n * @param fn - The fetch function to use\n * @returns The fetch function\n */\nexport function requestLogger(logger: Logger, name: string, fn: typeof fetch) {\n return async (...args: Parameters<typeof fetch>) => {\n const start = Date.now();\n try {\n return await fn(...args);\n } finally {\n const end = Date.now();\n const duration = end - start;\n const body = extractInfoFromBody(args[1]?.body ?? \"{}\");\n const message = `${name} path: ${args[0]}, took ${formatDuration(duration)}`;\n if (duration > WARNING_THRESHOLD) {\n logger.warn(message, body);\n } else {\n logger.info(message, body);\n }\n }\n };\n}\n\nfunction formatDuration(duration: number) {\n return duration < 1000 ? `${duration}ms` : `${(duration / 1000).toFixed(3)}s`;\n}\n\nfunction extractInfoFromBody(body: BodyInit) {\n try {\n const parsedBody = typeof body === \"string\" ? JSON.parse(body) : body;\n\n if (parsedBody === null || parsedBody === undefined || Object.keys(parsedBody).length === 0) {\n return null;\n }\n\n const dataToKeep: Record<string, unknown> = {};\n // Check for graphql fields\n if (\"query\" in parsedBody) {\n dataToKeep.query = truncate(parsedBody.query, TRUNCATE_LENGTH);\n }\n if (\"variables\" in parsedBody) {\n dataToKeep.variables = truncate(JSON.stringify(parsedBody.variables), TRUNCATE_LENGTH);\n }\n if (\"operationName\" in parsedBody) {\n dataToKeep.operationName = truncate(parsedBody.operationName, TRUNCATE_LENGTH);\n }\n\n if (Object.keys(dataToKeep).length > 0) {\n return JSON.stringify(dataToKeep);\n }\n\n // Not graphql, return the body as is\n return truncate(JSON.stringify(parsedBody || \"{}\"), TRUNCATE_LENGTH);\n } catch {\n return \"{}\";\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACYO,IAAM,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AI,WAAW,KAAM,QAAQ,CAAC,CAAC;AAC5E;AAEA,SAAS,oBAAoB,MAAgB;AAC3C,MAAI;AACF,UAAM,aAAa,OAAO,SAAS,WAAW,KAAK,MAAM,IAAI,IAAI;AAEjE,QAAI,eAAe,QAAQ,eAAe,UAAa,OAAO,KAAK,UAAU,EAAE,WAAW,GAAG;AAC3F,aAAO;AAAA,IACT;AAEA,UAAM,aAAsC,CAAC;AAE7C,QAAI,WAAW,YAAY;AACzB,iBAAW,QAAQ,SAAS,WAAW,OAAO,eAAe;AAAA,IAC/D;AACA,QAAI,eAAe,YAAY;AAC7B,iBAAW,YAAY,SAAS,KAAK,UAAU,WAAW,SAAS,GAAG,eAAe;AAAA,IACvF;AACA,QAAI,mBAAmB,YAAY;AACjC,iBAAW,gBAAgB,SAAS,WAAW,eAAe,eAAe;AAAA,IAC/E;AAEA,QAAI,OAAO,KAAK,UAAU,EAAE,SAAS,GAAG;AACtC,aAAO,KAAK,UAAU,UAAU;AAAA,IAClC;AAGA,WAAO,SAAS,KAAK,UAAU,cAAc,IAAI,GAAG,eAAe;AAAA,EACrE,QAAQ;AACN,WAAO;AAAA,EACT;AACF;","names":["level","logger"]}
1
+ {"version":3,"file":"logging.cjs","names":["output: string","options: LoggerOptions","logLevels: Record<LogLevel, number>","args: unknown[]","level: LogLevel","level","message: string","val: string","s: string","value: string","maxLength: number","logger: Logger","name: string","fn: typeof fetch","duration: number","body: BodyInit","dataToKeep: Record<string, unknown>"],"sources":["../src/logging/mask-tokens.ts","../src/logging/logger.ts","../src/string.ts","../src/logging/request-logger.ts"],"sourcesContent":["/**\n * Masks sensitive SettleMint tokens in output text by replacing them with asterisks.\n * Handles personal access tokens (PAT), application access tokens (AAT), and service account tokens (SAT).\n *\n * @param output - The text string that may contain sensitive tokens\n * @returns The text with any sensitive tokens masked with asterisks\n * @example\n * import { maskTokens } from \"@settlemint/sdk-utils/terminal\";\n *\n * // Masks a token in text\n * const masked = maskTokens(\"Token: sm_pat_****\"); // \"Token: ***\"\n */\nexport const maskTokens = (output: string): string => {\n return output.replace(/sm_(pat|aat|sat)_[0-9a-zA-Z]+/g, \"***\");\n};\n","import { maskTokens } from \"./mask-tokens.js\";\n\n/**\n * Log levels supported by the logger\n */\nexport type LogLevel = \"debug\" | \"info\" | \"warn\" | \"error\" | \"none\";\n\n/**\n * Configuration options for the logger\n * @interface LoggerOptions\n */\nexport interface LoggerOptions {\n /** The minimum log level to output */\n level?: LogLevel;\n /** The prefix to add to the log message */\n prefix?: string;\n}\n\n/**\n * Simple logger interface with basic logging methods\n * @interface Logger\n */\nexport interface Logger {\n /** Log debug information */\n debug: (message: string, ...args: unknown[]) => void;\n /** Log general information */\n info: (message: string, ...args: unknown[]) => void;\n /** Log warnings */\n warn: (message: string, ...args: unknown[]) => void;\n /** Log errors */\n error: (message: string, ...args: unknown[]) => void;\n}\n\n/**\n * Creates a simple logger with configurable log level\n *\n * @param options - Configuration options for the logger\n * @param options.level - The minimum log level to output (default: warn)\n * @param options.prefix - The prefix to add to the log message (default: \"\")\n * @returns A logger instance with debug, info, warn, and error methods\n *\n * @example\n * import { createLogger } from \"@/utils/logging/logger\";\n *\n * const logger = createLogger({ level: 'info' });\n *\n * logger.info('User logged in', { userId: '123' });\n * logger.error('Operation failed', new Error('Connection timeout'));\n */\nexport function createLogger(options: LoggerOptions = {}): Logger {\n const { level = \"warn\", prefix = \"\" } = options;\n\n const logLevels: Record<LogLevel, number> = {\n debug: 0,\n info: 1,\n warn: 2,\n error: 3,\n none: 4,\n };\n\n const currentLevelValue = logLevels[level];\n\n const formatArgs = (args: unknown[]): string => {\n if (args.length === 0 || args.every((arg) => arg === undefined || arg === null)) {\n return \"\";\n }\n\n const formatted = args\n .map((arg) => {\n if (arg instanceof Error) {\n return `\\n${arg.stack || arg.message}`;\n }\n if (typeof arg === \"object\" && arg !== null) {\n return `\\n${JSON.stringify(arg, null, 2)}`;\n }\n return ` ${String(arg)}`;\n })\n .join(\"\");\n\n return `, args:${formatted}`;\n };\n\n const shouldLog = (level: LogLevel): boolean => {\n return logLevels[level] >= currentLevelValue;\n };\n\n return {\n debug: (message: string, ...args: unknown[]) => {\n if (shouldLog(\"debug\")) {\n console.debug(`\\x1b[32m${prefix}[DEBUG] ${maskTokens(message)}${maskTokens(formatArgs(args))}\\x1b[0m`);\n }\n },\n info: (message: string, ...args: unknown[]) => {\n if (shouldLog(\"info\")) {\n console.info(`\\x1b[34m${prefix}[INFO] ${maskTokens(message)}${maskTokens(formatArgs(args))}\\x1b[0m`);\n }\n },\n warn: (message: string, ...args: unknown[]) => {\n if (shouldLog(\"warn\")) {\n console.warn(`\\x1b[33m${prefix}[WARN] ${maskTokens(message)}${maskTokens(formatArgs(args))}\\x1b[0m`);\n }\n },\n error: (message: string, ...args: unknown[]) => {\n if (shouldLog(\"error\")) {\n console.error(`\\x1b[31m${prefix}[ERROR] ${maskTokens(message)}${maskTokens(formatArgs(args))}\\x1b[0m`);\n }\n },\n };\n}\n\n/**\n * Default logger instance with standard configuration\n */\nexport const logger = createLogger();\n","/**\n * Capitalizes the first letter of a string.\n *\n * @param val - The string to capitalize\n * @returns The input string with its first letter capitalized\n *\n * @example\n * import { capitalizeFirstLetter } from \"@settlemint/sdk-utils\";\n *\n * const capitalized = capitalizeFirstLetter(\"hello\");\n * // Returns: \"Hello\"\n */\nexport function capitalizeFirstLetter(val: string) {\n return String(val).charAt(0).toUpperCase() + String(val).slice(1);\n}\n\n/**\n * Converts a camelCase string to a human-readable string.\n *\n * @param s - The camelCase string to convert\n * @returns The human-readable string\n *\n * @example\n * import { camelCaseToWords } from \"@settlemint/sdk-utils\";\n *\n * const words = camelCaseToWords(\"camelCaseString\");\n * // Returns: \"Camel Case String\"\n */\nexport function camelCaseToWords(s: string) {\n const result = s.replace(/([a-z])([A-Z])/g, \"$1 $2\");\n const withSpaces = result.replace(/([A-Z])([a-z])/g, \" $1$2\");\n const capitalized = capitalizeFirstLetter(withSpaces);\n return capitalized.replace(/\\s+/g, \" \").trim();\n}\n\n/**\n * Replaces underscores and hyphens with spaces.\n *\n * @param s - The string to replace underscores and hyphens with spaces\n * @returns The input string with underscores and hyphens replaced with spaces\n *\n * @example\n * import { replaceUnderscoresAndHyphensWithSpaces } from \"@settlemint/sdk-utils\";\n *\n * const result = replaceUnderscoresAndHyphensWithSpaces(\"Already_Spaced-Second\");\n * // Returns: \"Already Spaced Second\"\n */\nexport function replaceUnderscoresAndHyphensWithSpaces(s: string) {\n return s.replace(/[-_]/g, \" \");\n}\n\n/**\n * Truncates a string to a maximum length and appends \"...\" if it is longer.\n *\n * @param value - The string to truncate\n * @param maxLength - The maximum length of the string\n * @returns The truncated string or the original string if it is shorter than the maximum length\n *\n * @example\n * import { truncate } from \"@settlemint/sdk-utils\";\n *\n * const truncated = truncate(\"Hello, world!\", 10);\n * // Returns: \"Hello, wor...\"\n */\nexport function truncate(value: string, maxLength: number) {\n if (value.length <= maxLength) {\n return value;\n }\n return `${value.slice(0, maxLength)}...`;\n}\n","import { truncate } from \"../string.js\";\nimport type { Logger } from \"./logger.js\";\n\nconst WARNING_THRESHOLD = 500;\nconst TRUNCATE_LENGTH = 50;\n\n/**\n * Logs the request and duration of a fetch call (> 500ms is logged as warn, otherwise info)\n * @param logger - The logger to use\n * @param name - The name of the request\n * @param fn - The fetch function to use\n * @returns The fetch function\n */\nexport function requestLogger(logger: Logger, name: string, fn: typeof fetch) {\n return async (...args: Parameters<typeof fetch>) => {\n const start = Date.now();\n try {\n return await fn(...args);\n } finally {\n const end = Date.now();\n const duration = end - start;\n const body = extractInfoFromBody(args[1]?.body ?? \"{}\");\n const message = `${name} path: ${args[0]}, took ${formatDuration(duration)}`;\n if (duration > WARNING_THRESHOLD) {\n logger.warn(message, body);\n } else {\n logger.info(message, body);\n }\n }\n };\n}\n\nfunction formatDuration(duration: number) {\n return duration < 1000 ? `${duration}ms` : `${(duration / 1000).toFixed(3)}s`;\n}\n\nfunction extractInfoFromBody(body: BodyInit) {\n try {\n const parsedBody = typeof body === \"string\" ? JSON.parse(body) : body;\n\n if (parsedBody === null || parsedBody === undefined || Object.keys(parsedBody).length === 0) {\n return null;\n }\n\n const dataToKeep: Record<string, unknown> = {};\n // Check for graphql fields\n if (\"query\" in parsedBody) {\n dataToKeep.query = truncate(parsedBody.query, TRUNCATE_LENGTH);\n }\n if (\"variables\" in parsedBody) {\n dataToKeep.variables = truncate(JSON.stringify(parsedBody.variables), TRUNCATE_LENGTH);\n }\n if (\"operationName\" in parsedBody) {\n dataToKeep.operationName = truncate(parsedBody.operationName, TRUNCATE_LENGTH);\n }\n\n if (Object.keys(dataToKeep).length > 0) {\n return JSON.stringify(dataToKeep);\n }\n\n // Not graphql, return the body as is\n return truncate(JSON.stringify(parsedBody || \"{}\"), TRUNCATE_LENGTH);\n } catch {\n return \"{}\";\n }\n}\n"],"mappings":";;;;;;;;;;;;;;AAYA,MAAa,aAAa,CAACA,WAA2B;AACpD,QAAO,OAAO,QAAQ,kCAAkC,MAAM;AAC/D;;;;;;;;;;;;;;;;;;;;ACmCD,SAAgB,aAAaC,UAAyB,CAAE,GAAU;CAChE,MAAM,EAAE,QAAQ,QAAQ,SAAS,IAAI,GAAG;CAExC,MAAMC,YAAsC;EAC1C,OAAO;EACP,MAAM;EACN,MAAM;EACN,OAAO;EACP,MAAM;CACP;CAED,MAAM,oBAAoB,UAAU;CAEpC,MAAM,aAAa,CAACC,SAA4B;AAC9C,MAAI,KAAK,WAAW,KAAK,KAAK,MAAM,CAAC,QAAQ,QAAQ,aAAa,QAAQ,KAAK,EAAE;AAC/E,UAAO;EACR;EAED,MAAM,YAAY,KACf,IAAI,CAAC,QAAQ;AACZ,OAAI,eAAe,OAAO;AACxB,YAAQ,IAAI,IAAI,SAAS,IAAI,QAAQ;GACtC;AACD,cAAW,QAAQ,YAAY,QAAQ,MAAM;AAC3C,YAAQ,IAAI,KAAK,UAAU,KAAK,MAAM,EAAE,CAAC;GAC1C;AACD,WAAQ,GAAG,OAAO,IAAI,CAAC;EACxB,EAAC,CACD,K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AK,UAAU,WAAW,UAAU,EAAE,gBAAgB;EACvF;AACD,MAAI,mBAAmB,YAAY;AACjC,cAAW,gBAAgB,SAAS,WAAW,eAAe,gBAAgB;EAC/E;AAED,MAAI,OAAO,KAAK,WAAW,CAAC,SAAS,GAAG;AACtC,UAAO,KAAK,UAAU,WAAW;EAClC;AAGD,SAAO,SAAS,KAAK,UAAU,cAAc,KAAK,EAAE,gBAAgB;CACrE,QAAO;AACN,SAAO;CACR;AACF"}
@@ -1,3 +1,4 @@
1
+ //#region src/logging/logger.d.ts
1
2
  /**
2
3
  * Log levels supported by the logger
3
4
  */
@@ -7,24 +8,24 @@ type LogLevel = "debug" | "info" | "warn" | "error" | "none";
7
8
  * @interface LoggerOptions
8
9
  */
9
10
  interface LoggerOptions {
10
- /** The minimum log level to output */
11
- level?: LogLevel;
12
- /** The prefix to add to the log message */
13
- prefix?: string;
11
+ /** The minimum log level to output */
12
+ level?: LogLevel;
13
+ /** The prefix to add to the log message */
14
+ prefix?: string;
14
15
  }
15
16
  /**
16
17
  * Simple logger interface with basic logging methods
17
18
  * @interface Logger
18
19
  */
19
20
  interface Logger {
20
- /** Log debug information */
21
- debug: (message: string, ...args: unknown[]) => void;
22
- /** Log general information */
23
- info: (message: string, ...args: unknown[]) => void;
24
- /** Log warnings */
25
- warn: (message: string, ...args: unknown[]) => void;
26
- /** Log errors */
27
- error: (message: string, ...args: unknown[]) => void;
21
+ /** Log debug information */
22
+ debug: (message: string, ...args: unknown[]) => void;
23
+ /** Log general information */
24
+ info: (message: string, ...args: unknown[]) => void;
25
+ /** Log warnings */
26
+ warn: (message: string, ...args: unknown[]) => void;
27
+ /** Log errors */
28
+ error: (message: string, ...args: unknown[]) => void;
28
29
  }
29
30
  /**
30
31
  * Creates a simple logger with configurable log level
@@ -43,7 +44,11 @@ interface Logger {
43
44
  * logger.error('Operation failed', new Error('Connection timeout'));
44
45
  */
45
46
  declare function createLogger(options?: LoggerOptions): Logger;
46
-
47
+ /**
48
+ * Default logger instance with standard configuration
49
+ */
50
+ declare const logger: Logger; //#endregion
51
+ //#region src/logging/request-logger.d.ts
47
52
  /**
48
53
  * Logs the request and duration of a fetch call (> 500ms is logged as warn, otherwise info)
49
54
  * @param logger - The logger to use
@@ -53,6 +58,8 @@ declare function createLogger(options?: LoggerOptions): Logger;
53
58
  */
54
59
  declare function requestLogger(logger: Logger, name: string, fn: typeof fetch): (...args: Parameters<typeof fetch>) => Promise<Response>;
55
60
 
61
+ //#endregion
62
+ //#region src/logging/mask-tokens.d.ts
56
63
  /**
57
64
  * Masks sensitive SettleMint tokens in output text by replacing them with asterisks.
58
65
  * Handles personal access tokens (PAT), application access tokens (AAT), and service account tokens (SAT).
@@ -67,4 +74,6 @@ declare function requestLogger(logger: Logger, name: string, fn: typeof fetch):
67
74
  */
68
75
  declare const maskTokens: (output: string) => string;
69
76
 
70
- export { type LogLevel, type Logger, type LoggerOptions, createLogger, maskTokens, requestLogger };
77
+ //#endregion
78
+ export { LogLevel, Logger, LoggerOptions, createLogger, maskTokens, requestLogger };
79
+ //# sourceMappingURL=logging.d.cts.map
package/dist/logging.d.ts CHANGED
@@ -1,3 +1,4 @@
1
+ //#region src/logging/logger.d.ts
1
2
  /**
2
3
  * Log levels supported by the logger
3
4
  */
@@ -7,24 +8,24 @@ type LogLevel = "debug" | "info" | "warn" | "error" | "none";
7
8
  * @interface LoggerOptions
8
9
  */
9
10
  interface LoggerOptions {
10
- /** The minimum log level to output */
11
- level?: LogLevel;
12
- /** The prefix to add to the log message */
13
- prefix?: string;
11
+ /** The minimum log level to output */
12
+ level?: LogLevel;
13
+ /** The prefix to add to the log message */
14
+ prefix?: string;
14
15
  }
15
16
  /**
16
17
  * Simple logger interface with basic logging methods
17
18
  * @interface Logger
18
19
  */
19
20
  interface Logger {
20
- /** Log debug information */
21
- debug: (message: string, ...args: unknown[]) => void;
22
- /** Log general information */
23
- info: (message: string, ...args: unknown[]) => void;
24
- /** Log warnings */
25
- warn: (message: string, ...args: unknown[]) => void;
26
- /** Log errors */
27
- error: (message: string, ...args: unknown[]) => void;
21
+ /** Log debug information */
22
+ debug: (message: string, ...args: unknown[]) => void;
23
+ /** Log general information */
24
+ info: (message: string, ...args: unknown[]) => void;
25
+ /** Log warnings */
26
+ warn: (message: string, ...args: unknown[]) => void;
27
+ /** Log errors */
28
+ error: (message: string, ...args: unknown[]) => void;
28
29
  }
29
30
  /**
30
31
  * Creates a simple logger with configurable log level
@@ -43,7 +44,11 @@ interface Logger {
43
44
  * logger.error('Operation failed', new Error('Connection timeout'));
44
45
  */
45
46
  declare function createLogger(options?: LoggerOptions): Logger;
46
-
47
+ /**
48
+ * Default logger instance with standard configuration
49
+ */
50
+ declare const logger: Logger; //#endregion
51
+ //#region src/logging/request-logger.d.ts
47
52
  /**
48
53
  * Logs the request and duration of a fetch call (> 500ms is logged as warn, otherwise info)
49
54
  * @param logger - The logger to use
@@ -53,6 +58,8 @@ declare function createLogger(options?: LoggerOptions): Logger;
53
58
  */
54
59
  declare function requestLogger(logger: Logger, name: string, fn: typeof fetch): (...args: Parameters<typeof fetch>) => Promise<Response>;
55
60
 
61
+ //#endregion
62
+ //#region src/logging/mask-tokens.d.ts
56
63
  /**
57
64
  * Masks sensitive SettleMint tokens in output text by replacing them with asterisks.
58
65
  * Handles personal access tokens (PAT), application access tokens (AAT), and service account tokens (SAT).
@@ -67,4 +74,6 @@ declare function requestLogger(logger: Logger, name: string, fn: typeof fetch):
67
74
  */
68
75
  declare const maskTokens: (output: string) => string;
69
76
 
70
- export { type LogLevel, type Logger, type LoggerOptions, createLogger, maskTokens, requestLogger };
77
+ //#endregion
78
+ export { LogLevel, Logger, LoggerOptions, createLogger, maskTokens, requestLogger };
79
+ //# sourceMappingURL=logging.d.ts.map