@settlemint/sdk-utils 2.1.4 → 2.1.5

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.
@@ -41,6 +41,21 @@ interface ExecuteCommandOptions extends SpawnOptionsWithoutStdio {
41
41
  /** Whether to suppress output to stdout/stderr */
42
42
  silent?: boolean;
43
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
+ }
44
59
  /**
45
60
  * Executes a command with the given arguments in a child process.
46
61
  * Pipes stdin to the child process and captures stdout/stderr output.
@@ -50,7 +65,7 @@ interface ExecuteCommandOptions extends SpawnOptionsWithoutStdio {
50
65
  * @param args - Array of arguments to pass to the command
51
66
  * @param options - Options for customizing command execution
52
67
  * @returns Array of output strings from stdout and stderr
53
- * @throws {Error} If the process fails to start or exits with non-zero code
68
+ * @throws {CommandError} If the process fails to start or exits with non-zero code
54
69
  * @example
55
70
  * import { executeCommand } from "@settlemint/sdk-utils/terminal";
56
71
  *
@@ -201,4 +216,4 @@ declare function table(title: string, data: unknown[]): void;
201
216
  */
202
217
  declare const maskTokens: (output: string) => string;
203
218
 
204
- export { CancelError, type ExecuteCommandOptions, SpinnerError, type SpinnerOptions, ascii, cancel, executeCommand, intro, list, maskTokens, note, outro, spinner, table };
219
+ export { CancelError, CommandError, type ExecuteCommandOptions, SpinnerError, type SpinnerOptions, ascii, cancel, executeCommand, intro, list, maskTokens, note, outro, spinner, table };
package/dist/terminal.mjs CHANGED
@@ -1,14 +1,26 @@
1
1
  // src/terminal/ascii.ts
2
2
  import { magentaBright } from "yoctocolors";
3
- var ascii = () => console.log(
4
- magentaBright(`
3
+
4
+ // src/terminal/should-print.ts
5
+ function shouldPrint() {
6
+ return process.env.SETTLEMINT_DISABLE_TERMINAL !== "true";
7
+ }
8
+
9
+ // src/terminal/ascii.ts
10
+ var ascii = () => {
11
+ if (!shouldPrint()) {
12
+ return;
13
+ }
14
+ console.log(
15
+ magentaBright(`
5
16
  _________ __ __ .__ _____ .__ __
6
17
  / _____/ _____/ |__/ |_| | ____ / \\ |__| _____/ |_
7
18
  \\_____ \\_/ __ \\ __\\ __\\ | _/ __ \\ / \\ / \\| |/ \\ __\\
8
19
  / \\ ___/| | | | | |_\\ ___// Y \\ | | \\ |
9
20
  /_________/\\_____>__| |__| |____/\\_____>____|____/__|___|__/__|
10
21
  `)
11
- );
22
+ );
23
+ };
12
24
 
13
25
  // src/logging/mask-tokens.ts
14
26
  var maskTokens = (output) => {
@@ -28,6 +40,19 @@ var cancel = (msg) => {
28
40
 
29
41
  // src/terminal/execute-command.ts
30
42
  import { spawn } from "node:child_process";
43
+ var CommandError = class extends Error {
44
+ /**
45
+ * Constructs a new CommandError
46
+ * @param message - The error message
47
+ * @param code - The exit code of the command
48
+ * @param output - The output of the command
49
+ */
50
+ constructor(message, code, output) {
51
+ super(message);
52
+ this.code = code;
53
+ this.output = output;
54
+ }
55
+ };
31
56
  async function executeCommand(command, args, options) {
32
57
  const child = spawn(command, args, { env: { ...process.env, ...options?.env } });
33
58
  process.stdin.pipe(child.stdin);
@@ -47,14 +72,17 @@ async function executeCommand(command, args, options) {
47
72
  }
48
73
  output.push(maskedData);
49
74
  });
50
- child.on("error", (err) => reject(err));
75
+ child.on(
76
+ "error",
77
+ (err) => reject(new CommandError(err.message, "code" in err && typeof err.code === "number" ? err.code : 1, output))
78
+ );
51
79
  child.on("close", (code) => {
52
80
  if (code === 0 || code === null || code === 143) {
53
81
  process.stdin.unpipe(child.stdin);
54
82
  resolve(output);
55
83
  return;
56
84
  }
57
- reject(new Error(`Command "${command}" exited with code ${code}`));
85
+ reject(new CommandError(`Command "${command}" exited with code ${code}`, code, output));
58
86
  });
59
87
  });
60
88
  }
@@ -62,6 +90,9 @@ async function executeCommand(command, args, options) {
62
90
  // src/terminal/intro.ts
63
91
  import { magentaBright as magentaBright2 } from "yoctocolors";
64
92
  var intro = (msg) => {
93
+ if (!shouldPrint()) {
94
+ return;
95
+ }
65
96
  console.log("");
66
97
  console.log(magentaBright2(maskTokens(msg)));
67
98
  console.log("");
@@ -70,6 +101,9 @@ var intro = (msg) => {
70
101
  // src/terminal/note.ts
71
102
  import { yellowBright } from "yoctocolors";
72
103
  var note = (message, level = "info") => {
104
+ if (!shouldPrint()) {
105
+ return;
106
+ }
73
107
  const maskedMessage = maskTokens(message);
74
108
  console.log("");
75
109
  if (level === "warn") {
@@ -97,6 +131,9 @@ ${formatItems(items)}`);
97
131
  // src/terminal/outro.ts
98
132
  import { greenBright, inverse as inverse2 } from "yoctocolors";
99
133
  var outro = (msg) => {
134
+ if (!shouldPrint()) {
135
+ return;
136
+ }
100
137
  console.log("");
101
138
  console.log(inverse2(greenBright(maskTokens(msg))));
102
139
  console.log("");
@@ -121,7 +158,7 @@ var spinner = async (options) => {
121
158
  ${error.stack}`));
122
159
  throw new SpinnerError(errorMessage, error);
123
160
  };
124
- if (isInCi) {
161
+ if (isInCi || !shouldPrint()) {
125
162
  try {
126
163
  return await options.task();
127
164
  } catch (err) {
@@ -155,6 +192,9 @@ function camelCaseToWords(s) {
155
192
  import { Table } from "console-table-printer";
156
193
  import { whiteBright } from "yoctocolors";
157
194
  function table(title, data) {
195
+ if (!shouldPrint()) {
196
+ return;
197
+ }
158
198
  note(title);
159
199
  if (!data || data.length === 0) {
160
200
  note("No data to display");
@@ -173,6 +213,7 @@ function table(title, data) {
173
213
  }
174
214
  export {
175
215
  CancelError,
216
+ CommandError,
176
217
  SpinnerError,
177
218
  ascii,
178
219
  cancel,
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/terminal/ascii.ts","../src/logging/mask-tokens.ts","../src/terminal/cancel.ts","../src/terminal/execute-command.ts","../src/terminal/intro.ts","../src/terminal/note.ts","../src/terminal/list.ts","../src/terminal/outro.ts","../src/terminal/spinner.ts","../src/string.ts","../src/terminal/table.ts"],"sourcesContent":["import { magentaBright } from \"yoctocolors\";\n\n/**\n * Prints the SettleMint ASCII art logo to the console in magenta color.\n * Used for CLI branding and visual identification.\n *\n * @example\n * import { ascii } from \"@settlemint/sdk-utils/terminal\";\n *\n * // Prints the SettleMint logo\n * ascii();\n */\nexport const ascii = (): void =>\n console.log(\n magentaBright(`\n _________ __ __ .__ _____ .__ __\n / _____/ _____/ |__/ |_| | ____ / \\\\ |__| _____/ |_\n \\\\_____ \\\\_/ __ \\\\ __\\\\ __\\\\ | _/ __ \\\\ / \\\\ / \\\\| |/ \\\\ __\\\\\n / \\\\ ___/| | | | | |_\\\\ ___// Y \\\\ | | \\\\ |\n/_________/\\\\_____>__| |__| |____/\\\\_____>____|____/__|___|__/__|\n`),\n );\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 \"@/logging/mask-tokens.js\";\nimport { inverse, redBright } from \"yoctocolors\";\n\n/**\n * Error class used to indicate that the operation was cancelled.\n * This error is used to signal that the operation should be aborted.\n */\nexport class CancelError extends Error {}\n\n/**\n * Displays an error message in red inverse text and throws a CancelError.\n * Used to terminate execution with a visible error message.\n * Any sensitive tokens in the message are masked before display.\n *\n * @param msg - The error message to display\n * @returns never - Function does not return as it throws an error\n * @example\n * import { cancel } from \"@settlemint/sdk-utils/terminal\";\n *\n * // Exits process with error message\n * cancel(\"An error occurred\");\n */\nexport const cancel = (msg: string): never => {\n console.log(\"\");\n console.log(inverse(redBright(maskTokens(msg))));\n console.log(\"\");\n throw new CancelError(msg);\n};\n","import { type SpawnOptionsWithoutStdio, spawn } from \"node:child_process\";\nimport { maskTokens } from \"../logging/mask-tokens.js\";\n\n/**\n * Options for executing a command, extending SpawnOptionsWithoutStdio\n */\nexport interface ExecuteCommandOptions extends SpawnOptionsWithoutStdio {\n /** Whether to suppress output to stdout/stderr */\n silent?: boolean;\n}\n\n/**\n * Executes a command with the given arguments in a child process.\n * Pipes stdin to the child process and captures stdout/stderr output.\n * Masks any sensitive tokens in the output before displaying or returning.\n *\n * @param command - The command to execute\n * @param args - Array of arguments to pass to the command\n * @param options - Options for customizing command execution\n * @returns Array of output strings from stdout and stderr\n * @throws {Error} If the process fails to start or exits with non-zero code\n * @example\n * import { executeCommand } from \"@settlemint/sdk-utils/terminal\";\n *\n * // Execute git clone\n * await executeCommand(\"git\", [\"clone\", \"repo-url\"]);\n *\n * // Execute silently\n * await executeCommand(\"npm\", [\"install\"], { silent: true });\n */\nexport async function executeCommand(\n command: string,\n args: string[],\n options?: ExecuteCommandOptions,\n): Promise<string[]> {\n const child = spawn(command, args, { env: { ...process.env, ...options?.env } });\n process.stdin.pipe(child.stdin);\n const output: string[] = [];\n return new Promise((resolve, reject) => {\n child.stdout.on(\"data\", (data: Buffer | string) => {\n const maskedData = maskTokens(data.toString());\n if (!options?.silent) {\n process.stdout.write(maskedData);\n }\n output.push(maskedData);\n });\n child.stderr.on(\"data\", (data: Buffer | string) => {\n const maskedData = maskTokens(data.toString());\n if (!options?.silent) {\n process.stderr.write(maskedData);\n }\n output.push(maskedData);\n });\n child.on(\"error\", (err) => reject(err));\n child.on(\"close\", (code) => {\n if (code === 0 || code === null || code === 143) {\n process.stdin.unpipe(child.stdin);\n resolve(output);\n return;\n }\n reject(new Error(`Command \"${command}\" exited with code ${code}`));\n });\n });\n}\n","import { maskTokens } from \"@/logging/mask-tokens.js\";\nimport { magentaBright } from \"yoctocolors\";\n\n/**\n * Displays an introductory message in magenta text with padding.\n * Any sensitive tokens in the message are masked before display.\n *\n * @param msg - The message to display as introduction\n * @example\n * import { intro } from \"@settlemint/sdk-utils/terminal\";\n *\n * // Display intro message\n * intro(\"Starting deployment...\");\n */\nexport const intro = (msg: string): void => {\n console.log(\"\");\n console.log(magentaBright(maskTokens(msg)));\n console.log(\"\");\n};\n","import { maskTokens } from \"@/logging/mask-tokens.js\";\nimport { yellowBright } from \"yoctocolors\";\n\n/**\n * Displays a note message with optional warning level formatting.\n * Regular notes are displayed in normal text, while warnings are shown in yellow.\n * Any sensitive tokens in the message are masked before display.\n *\n * @param message - The message to display as a note\n * @param level - The note level: \"info\" (default) or \"warn\" for warning styling\n * @example\n * import { note } from \"@settlemint/sdk-utils/terminal\";\n *\n * // Display info note\n * note(\"Operation completed successfully\");\n *\n * // Display warning note\n * note(\"Low disk space remaining\", \"warn\");\n */\nexport const note = (message: string, level: \"info\" | \"warn\" = \"info\"): void => {\n const maskedMessage = maskTokens(message);\n\n console.log(\"\");\n if (level === \"warn\") {\n console.warn(yellowBright(maskedMessage));\n return;\n }\n\n console.log(maskedMessage);\n};\n","import { note } from \"./note.js\";\n\n/**\n * Displays a list of items in a formatted manner, supporting nested items.\n *\n * @param title - The title of the list\n * @param items - The items to display, can be strings or arrays for nested items\n * @returns The formatted list\n * @example\n * import { list } from \"@settlemint/sdk-utils/terminal\";\n *\n * // Simple list\n * list(\"Use cases\", [\"use case 1\", \"use case 2\", \"use case 3\"]);\n *\n * // Nested list\n * list(\"Providers\", [\n * \"AWS\",\n * [\"us-east-1\", \"eu-west-1\"],\n * \"Azure\",\n * [\"eastus\", \"westeurope\"]\n * ]);\n */\nexport function list(title: string, items: Array<string | string[]>) {\n const formatItems = (items: Array<string | string[]>): string => {\n return items\n .map((item) => {\n if (Array.isArray(item)) {\n return item.map((subItem) => ` • ${subItem}`).join(\"\\n\");\n }\n return ` • ${item}`;\n })\n .join(\"\\n\");\n };\n\n return note(`${title}:\\n\\n${formatItems(items)}`);\n}\n","import { maskTokens } from \"@/logging/mask-tokens.js\";\nimport { greenBright, inverse } from \"yoctocolors\";\n\n/**\n * Displays a closing message in green inverted text with padding.\n * Any sensitive tokens in the message are masked before display.\n *\n * @param msg - The message to display as conclusion\n * @example\n * import { outro } from \"@settlemint/sdk-utils/terminal\";\n *\n * // Display outro message\n * outro(\"Deployment completed successfully!\");\n */\nexport const outro = (msg: string): void => {\n console.log(\"\");\n console.log(inverse(greenBright(maskTokens(msg))));\n console.log(\"\");\n};\n","import isInCi from \"is-in-ci\";\nimport yoctoSpinner, { type Spinner } from \"yocto-spinner\";\nimport { redBright } from \"yoctocolors\";\nimport { maskTokens } from \"../logging/mask-tokens.js\";\nimport { note } from \"./note.js\";\n\n/**\n * Error class used to indicate that the spinner operation failed.\n * This error is used to signal that the operation should be aborted.\n */\nexport class SpinnerError extends Error {\n constructor(\n message: string,\n public readonly originalError: Error,\n ) {\n super(message);\n this.name = \"SpinnerError\";\n }\n}\n\n/**\n * Options for configuring the spinner behavior\n */\nexport interface SpinnerOptions<R> {\n /** Message to display when spinner starts */\n startMessage: string;\n /** Async task to execute while spinner is active */\n task: (spinner?: Spinner) => Promise<R>;\n /** Message to display when spinner completes successfully */\n stopMessage: string;\n}\n\n/**\n * Displays a loading spinner while executing an async task.\n * Shows progress with start/stop messages and handles errors.\n * Spinner is disabled in CI environments.\n *\n * @param options - Configuration options for the spinner\n * @returns The result from the executed task\n * @throws Will exit process with code 1 if task fails\n * @example\n * import { spinner } from \"@settlemint/sdk-utils/terminal\";\n *\n * // Show spinner during async task\n * const result = await spinner({\n * startMessage: \"Deploying...\",\n * task: async () => {\n * // Async work here\n * return \"success\";\n * },\n * stopMessage: \"Deployed successfully!\"\n * });\n */\nexport const spinner = async <R>(options: SpinnerOptions<R>): Promise<R> => {\n const handleError = (error: Error) => {\n const errorMessage = maskTokens(error.message);\n note(redBright(`${errorMessage}\\n\\n${error.stack}`));\n throw new SpinnerError(errorMessage, error);\n };\n if (isInCi) {\n try {\n return await options.task();\n } catch (err) {\n return handleError(err as Error);\n }\n }\n const spinner = yoctoSpinner({ stream: process.stdout }).start(options.startMessage);\n try {\n const result = await options.task(spinner);\n spinner.success(options.stopMessage);\n // Ensure spinner success message renders before proceeding to avoid\n // terminal output overlap issues with subsequent messages\n await new Promise((resolve) => process.nextTick(resolve));\n return result;\n } catch (err) {\n spinner.error(redBright(`${options.startMessage} --> Error!`));\n return handleError(err as Error);\n }\n};\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 { camelCaseToWords } from \"@/string.js\";\nimport { Table } from \"console-table-printer\";\nimport { whiteBright } from \"yoctocolors\";\nimport { note } from \"./note.js\";\n/**\n * Displays data in a formatted table in the terminal.\n *\n * @param title - Title to display above the table\n * @param data - Array of objects to display in table format\n * @example\n * import { table } from \"@settlemint/sdk-utils/terminal\";\n *\n * const data = [\n * { name: \"Item 1\", value: 100 },\n * { name: \"Item 2\", value: 200 }\n * ];\n *\n * table(\"My Table\", data);\n */\nexport function table(title: string, data: unknown[]): void {\n note(title);\n\n if (!data || data.length === 0) {\n note(\"No data to display\");\n return;\n }\n\n const columnKeys = Object.keys(data[0] as Record<string, unknown>);\n const table = new Table({\n columns: columnKeys.map((key) => ({\n name: key,\n title: whiteBright(camelCaseToWords(key)),\n alignment: \"left\",\n })),\n });\n table.addRows(data);\n table.printTable();\n}\n"],"mappings":";AAAA,SAAS,qBAAqB;AAYvB,IAAM,QAAQ,MACnB,QAAQ;AAAA,EACN,cAAc;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,CAMjB;AACC;;;ACTK,IAAM,aAAa,CAAC,WAA2B;AACpD,SAAO,OAAO,QAAQ,kCAAkC,KAAK;AAC/D;;;ACbA,SAAS,SAAS,iBAAiB;AAM5B,IAAM,cAAN,cAA0B,MAAM;AAAC;AAejC,IAAM,SAAS,CAAC,QAAuB;AAC5C,UAAQ,IAAI,EAAE;AACd,UAAQ,IAAI,QAAQ,UAAU,WAAW,GAAG,CAAC,CAAC,CAAC;AAC/C,UAAQ,IAAI,EAAE;AACd,QAAM,IAA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AQ,IAAI;AAClB,EAAAA,OAAM,WAAW;AACnB;","names":["magentaBright","items","inverse","redBright","redBright","spinner","table"]}
1
+ {"version":3,"sources":["../src/terminal/ascii.ts","../src/terminal/should-print.ts","../src/logging/mask-tokens.ts","../src/terminal/cancel.ts","../src/terminal/execute-command.ts","../src/terminal/intro.ts","../src/terminal/note.ts","../src/terminal/list.ts","../src/terminal/outro.ts","../src/terminal/spinner.ts","../src/string.ts","../src/terminal/table.ts"],"sourcesContent":["import { magentaBright } from \"yoctocolors\";\nimport { shouldPrint } from \"./should-print.js\";\n\n/**\n * Prints the SettleMint ASCII art logo to the console in magenta color.\n * Used for CLI branding and visual identification.\n *\n * @example\n * import { ascii } from \"@settlemint/sdk-utils/terminal\";\n *\n * // Prints the SettleMint logo\n * ascii();\n */\nexport const ascii = (): void => {\n if (!shouldPrint()) {\n return;\n }\n console.log(\n magentaBright(`\n _________ __ __ .__ _____ .__ __\n / _____/ _____/ |__/ |_| | ____ / \\\\ |__| _____/ |_\n \\\\_____ \\\\_/ __ \\\\ __\\\\ __\\\\ | _/ __ \\\\ / \\\\ / \\\\| |/ \\\\ __\\\\\n / \\\\ ___/| | | | | |_\\\\ ___// Y \\\\ | | \\\\ |\n/_________/\\\\_____>__| |__| |____/\\\\_____>____|____/__|___|__/__|\n`),\n );\n};\n","/**\n * Returns true if the terminal should print, false otherwise.\n * @returns true if the terminal should print, false otherwise.\n */\nexport function shouldPrint() {\n return process.env.SETTLEMINT_DISABLE_TERMINAL !== \"true\";\n}\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 \"@/logging/mask-tokens.js\";\nimport { inverse, redBright } from \"yoctocolors\";\n\n/**\n * Error class used to indicate that the operation was cancelled.\n * This error is used to signal that the operation should be aborted.\n */\nexport class CancelError extends Error {}\n\n/**\n * Displays an error message in red inverse text and throws a CancelError.\n * Used to terminate execution with a visible error message.\n * Any sensitive tokens in the message are masked before display.\n *\n * @param msg - The error message to display\n * @returns never - Function does not return as it throws an error\n * @example\n * import { cancel } from \"@settlemint/sdk-utils/terminal\";\n *\n * // Exits process with error message\n * cancel(\"An error occurred\");\n */\nexport const cancel = (msg: string): never => {\n console.log(\"\");\n console.log(inverse(redBright(maskTokens(msg))));\n console.log(\"\");\n throw new CancelError(msg);\n};\n","import { type SpawnOptionsWithoutStdio, spawn } from \"node:child_process\";\nimport { maskTokens } from \"../logging/mask-tokens.js\";\n\n/**\n * Options for executing a command, extending SpawnOptionsWithoutStdio\n */\nexport interface ExecuteCommandOptions extends SpawnOptionsWithoutStdio {\n /** Whether to suppress output to stdout/stderr */\n silent?: boolean;\n}\n\n/**\n * Error class for command execution errors\n * @extends Error\n */\nexport class CommandError extends Error {\n /**\n * Constructs a new CommandError\n * @param message - The error message\n * @param code - The exit code of the command\n * @param output - The output of the command\n */\n constructor(\n message: string,\n public readonly code: number,\n public readonly output: string[],\n ) {\n super(message);\n }\n}\n\n/**\n * Executes a command with the given arguments in a child process.\n * Pipes stdin to the child process and captures stdout/stderr output.\n * Masks any sensitive tokens in the output before displaying or returning.\n *\n * @param command - The command to execute\n * @param args - Array of arguments to pass to the command\n * @param options - Options for customizing command execution\n * @returns Array of output strings from stdout and stderr\n * @throws {CommandError} If the process fails to start or exits with non-zero code\n * @example\n * import { executeCommand } from \"@settlemint/sdk-utils/terminal\";\n *\n * // Execute git clone\n * await executeCommand(\"git\", [\"clone\", \"repo-url\"]);\n *\n * // Execute silently\n * await executeCommand(\"npm\", [\"install\"], { silent: true });\n */\nexport async function executeCommand(\n command: string,\n args: string[],\n options?: ExecuteCommandOptions,\n): Promise<string[]> {\n const child = spawn(command, args, { env: { ...process.env, ...options?.env } });\n process.stdin.pipe(child.stdin);\n const output: string[] = [];\n return new Promise((resolve, reject) => {\n child.stdout.on(\"data\", (data: Buffer | string) => {\n const maskedData = maskTokens(data.toString());\n if (!options?.silent) {\n process.stdout.write(maskedData);\n }\n output.push(maskedData);\n });\n child.stderr.on(\"data\", (data: Buffer | string) => {\n const maskedData = maskTokens(data.toString());\n if (!options?.silent) {\n process.stderr.write(maskedData);\n }\n output.push(maskedData);\n });\n child.on(\"error\", (err) =>\n reject(new CommandError(err.message, \"code\" in err && typeof err.code === \"number\" ? err.code : 1, output)),\n );\n child.on(\"close\", (code) => {\n if (code === 0 || code === null || code === 143) {\n process.stdin.unpipe(child.stdin);\n resolve(output);\n return;\n }\n reject(new CommandError(`Command \"${command}\" exited with code ${code}`, code, output));\n });\n });\n}\n","import { maskTokens } from \"@/logging/mask-tokens.js\";\nimport { magentaBright } from \"yoctocolors\";\nimport { shouldPrint } from \"./should-print.js\";\n\n/**\n * Displays an introductory message in magenta text with padding.\n * Any sensitive tokens in the message are masked before display.\n *\n * @param msg - The message to display as introduction\n * @example\n * import { intro } from \"@settlemint/sdk-utils/terminal\";\n *\n * // Display intro message\n * intro(\"Starting deployment...\");\n */\nexport const intro = (msg: string): void => {\n if (!shouldPrint()) {\n return;\n }\n console.log(\"\");\n console.log(magentaBright(maskTokens(msg)));\n console.log(\"\");\n};\n","import { maskTokens } from \"@/logging/mask-tokens.js\";\nimport { yellowBright } from \"yoctocolors\";\nimport { shouldPrint } from \"./should-print.js\";\n\n/**\n * Displays a note message with optional warning level formatting.\n * Regular notes are displayed in normal text, while warnings are shown in yellow.\n * Any sensitive tokens in the message are masked before display.\n *\n * @param message - The message to display as a note\n * @param level - The note level: \"info\" (default) or \"warn\" for warning styling\n * @example\n * import { note } from \"@settlemint/sdk-utils/terminal\";\n *\n * // Display info note\n * note(\"Operation completed successfully\");\n *\n * // Display warning note\n * note(\"Low disk space remaining\", \"warn\");\n */\nexport const note = (message: string, level: \"info\" | \"warn\" = \"info\"): void => {\n if (!shouldPrint()) {\n return;\n }\n const maskedMessage = maskTokens(message);\n\n console.log(\"\");\n if (level === \"warn\") {\n console.warn(yellowBright(maskedMessage));\n return;\n }\n\n console.log(maskedMessage);\n};\n","import { note } from \"./note.js\";\n\n/**\n * Displays a list of items in a formatted manner, supporting nested items.\n *\n * @param title - The title of the list\n * @param items - The items to display, can be strings or arrays for nested items\n * @returns The formatted list\n * @example\n * import { list } from \"@settlemint/sdk-utils/terminal\";\n *\n * // Simple list\n * list(\"Use cases\", [\"use case 1\", \"use case 2\", \"use case 3\"]);\n *\n * // Nested list\n * list(\"Providers\", [\n * \"AWS\",\n * [\"us-east-1\", \"eu-west-1\"],\n * \"Azure\",\n * [\"eastus\", \"westeurope\"]\n * ]);\n */\nexport function list(title: string, items: Array<string | string[]>) {\n const formatItems = (items: Array<string | string[]>): string => {\n return items\n .map((item) => {\n if (Array.isArray(item)) {\n return item.map((subItem) => ` • ${subItem}`).join(\"\\n\");\n }\n return ` • ${item}`;\n })\n .join(\"\\n\");\n };\n\n return note(`${title}:\\n\\n${formatItems(items)}`);\n}\n","import { maskTokens } from \"@/logging/mask-tokens.js\";\nimport { shouldPrint } from \"@/terminal/should-print.js\";\nimport { greenBright, inverse } from \"yoctocolors\";\n\n/**\n * Displays a closing message in green inverted text with padding.\n * Any sensitive tokens in the message are masked before display.\n *\n * @param msg - The message to display as conclusion\n * @example\n * import { outro } from \"@settlemint/sdk-utils/terminal\";\n *\n * // Display outro message\n * outro(\"Deployment completed successfully!\");\n */\nexport const outro = (msg: string): void => {\n if (!shouldPrint()) {\n return;\n }\n console.log(\"\");\n console.log(inverse(greenBright(maskTokens(msg))));\n console.log(\"\");\n};\n","import isInCi from \"is-in-ci\";\nimport yoctoSpinner, { type Spinner } from \"yocto-spinner\";\nimport { redBright } from \"yoctocolors\";\nimport { maskTokens } from \"../logging/mask-tokens.js\";\nimport { note } from \"./note.js\";\nimport { shouldPrint } from \"./should-print.js\";\n\n/**\n * Error class used to indicate that the spinner operation failed.\n * This error is used to signal that the operation should be aborted.\n */\nexport class SpinnerError extends Error {\n constructor(\n message: string,\n public readonly originalError: Error,\n ) {\n super(message);\n this.name = \"SpinnerError\";\n }\n}\n\n/**\n * Options for configuring the spinner behavior\n */\nexport interface SpinnerOptions<R> {\n /** Message to display when spinner starts */\n startMessage: string;\n /** Async task to execute while spinner is active */\n task: (spinner?: Spinner) => Promise<R>;\n /** Message to display when spinner completes successfully */\n stopMessage: string;\n}\n\n/**\n * Displays a loading spinner while executing an async task.\n * Shows progress with start/stop messages and handles errors.\n * Spinner is disabled in CI environments.\n *\n * @param options - Configuration options for the spinner\n * @returns The result from the executed task\n * @throws Will exit process with code 1 if task fails\n * @example\n * import { spinner } from \"@settlemint/sdk-utils/terminal\";\n *\n * // Show spinner during async task\n * const result = await spinner({\n * startMessage: \"Deploying...\",\n * task: async () => {\n * // Async work here\n * return \"success\";\n * },\n * stopMessage: \"Deployed successfully!\"\n * });\n */\nexport const spinner = async <R>(options: SpinnerOptions<R>): Promise<R> => {\n const handleError = (error: Error) => {\n const errorMessage = maskTokens(error.message);\n note(redBright(`${errorMessage}\\n\\n${error.stack}`));\n throw new SpinnerError(errorMessage, error);\n };\n if (isInCi || !shouldPrint()) {\n try {\n return await options.task();\n } catch (err) {\n return handleError(err as Error);\n }\n }\n const spinner = yoctoSpinner({ stream: process.stdout }).start(options.startMessage);\n try {\n const result = await options.task(spinner);\n spinner.success(options.stopMessage);\n // Ensure spinner success message renders before proceeding to avoid\n // terminal output overlap issues with subsequent messages\n await new Promise((resolve) => process.nextTick(resolve));\n return result;\n } catch (err) {\n spinner.error(redBright(`${options.startMessage} --> Error!`));\n return handleError(err as Error);\n }\n};\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 { camelCaseToWords } from \"@/string.js\";\nimport { Table } from \"console-table-printer\";\nimport { whiteBright } from \"yoctocolors\";\nimport { note } from \"./note.js\";\nimport { shouldPrint } from \"./should-print.js\";\n/**\n * Displays data in a formatted table in the terminal.\n *\n * @param title - Title to display above the table\n * @param data - Array of objects to display in table format\n * @example\n * import { table } from \"@settlemint/sdk-utils/terminal\";\n *\n * const data = [\n * { name: \"Item 1\", value: 100 },\n * { name: \"Item 2\", value: 200 }\n * ];\n *\n * table(\"My Table\", data);\n */\nexport function table(title: string, data: unknown[]): void {\n if (!shouldPrint()) {\n return;\n }\n\n note(title);\n\n if (!data || data.length === 0) {\n note(\"No data to display\");\n return;\n }\n\n const columnKeys = Object.keys(data[0] as Record<string, unknown>);\n const table = new Table({\n columns: columnKeys.map((key) => ({\n name: key,\n title: whiteBright(camelCaseToWords(key)),\n alignment: \"left\",\n })),\n });\n table.addRows(data);\n table.printTable();\n}\n"],"mappings":";AAAA,SAAS,qBAAqB;;;ACIvB,SAAS,cAAc;AAC5B,SAAO,QAAQ,IAAI,gCAAgC;AACrD;;;ADOO,IAAM,QAAQ,MAAY;AAC/B,MAAI,CAAC,YAAY,GAAG;AAClB;AAAA,EACF;AACA,UAAQ;AAAA,IACN,cAAc;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,CAMjB;AAAA,EACC;AACF;;;AEdO,IAAM,aAAa,CAAC,WAA2B;AACpD,SAAO,OAAO,QAAQ,kCAAkC,KAAK;AAC/D;;;ACbA,SAAS,SAAS,iBAAiB;AAM5B,IAAM,cAAN,cAA0B,MAAM;AAAC;AAejC,IAAM,SAAS,CAAC,QAAuB;AAC5C,UAAQ,IAAI,EAAE;AACd,UAAQ,IAAI,QAAQ,UAAU,WAAW,GAAG,CAAC,CAAC,CAAC;AAC/C,UAAQ,IAAI,EAAE;AACd,QAAM,IAAI,YAAY,GAAG;AAC3B;;;AC3BA,SAAwC,aAAa;AAe9C,IAAM,eAAN,cAA2B,MAAM;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOtC,YACE,SACgB,MACA,QAChB;AACA,UAAM,OAAO;AAHG;AACA;AAAA,EAGlB;AACF;AAqBA,eAAsB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ACF;AAEA,QAAM,aAAa,OAAO,KAAK,KAAK,CAAC,CAA4B;AACjE,QAAME,SAAQ,IAAI,MAAM;AAAA,IACtB,SAAS,WAAW,IAAI,CAAC,SAAS;AAAA,MAChC,MAAM;AAAA,MACN,OAAO,YAAY,iBAAiB,GAAG,CAAC;AAAA,MACxC,WAAW;AAAA,IACb,EAAE;AAAA,EACJ,CAAC;AACD,EAAAA,OAAM,QAAQ,IAAI;AAClB,EAAAA,OAAM,WAAW;AACnB;","names":["magentaBright","magentaBright","items","inverse","redBright","redBright","spinner","table"]}
@@ -97,10 +97,16 @@ var DotEnvSchema = import_zod5.z.object({
97
97
  SETTLEMINT_APPLICATION: UniqueNameSchema.optional(),
98
98
  /** Unique name of the blockchain network */
99
99
  SETTLEMINT_BLOCKCHAIN_NETWORK: UniqueNameSchema.optional(),
100
- /** Unique name of the blockchain node */
100
+ /** Chain ID of the blockchain network */
101
+ SETTLEMINT_BLOCKCHAIN_NETWORK_CHAIN_ID: import_zod5.z.string().optional(),
102
+ /** Unique name of the blockchain node (should have a private key for signing transactions) */
101
103
  SETTLEMINT_BLOCKCHAIN_NODE: UniqueNameSchema.optional(),
102
- /** Unique name of the load balancer */
103
- SETTLEMINT_LOAD_BALANCER: UniqueNameSchema.optional(),
104
+ /** JSON RPC endpoint for the blockchain node */
105
+ SETTLEMINT_BLOCKCHAIN_NODE_JSON_RPC_ENDPOINT: UrlSchema.optional(),
106
+ /** Unique name of the blockchain node or load balancer */
107
+ SETTLEMINT_BLOCKCHAIN_NODE_OR_LOAD_BALANCER: UniqueNameSchema.optional(),
108
+ /** JSON RPC endpoint for the blockchain node or load balancer */
109
+ SETTLEMINT_BLOCKCHAIN_NODE_OR_LOAD_BALANCER_JSON_RPC_ENDPOINT: UrlSchema.optional(),
104
110
  /** Unique name of the Hasura instance */
105
111
  SETTLEMINT_HASURA: UniqueNameSchema.optional(),
106
112
  /** Endpoint URL for the Hasura GraphQL API */
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/validation.ts","../src/validation/validate.ts","../src/validation/access-token.schema.ts","../src/json.ts","../src/validation/dot-env.schema.ts","../src/validation/unique-name.schema.ts","../src/validation/url.schema.ts","../src/validation/id.schema.ts"],"sourcesContent":["export { validate } from \"./validation/validate.js\";\nexport {\n ApplicationAccessTokenSchema,\n type ApplicationAccessToken,\n PersonalAccessTokenSchema,\n type PersonalAccessToken,\n AccessTokenSchema,\n type AccessToken,\n} from \"./validation/access-token.schema.js\";\nexport { DotEnvSchema, DotEnvSchemaPartial, type DotEnv, type DotEnvPartial } from \"./validation/dot-env.schema.js\";\nexport { IdSchema, type Id } from \"./validation/id.schema.js\";\nexport { UniqueNameSchema } from \"./validation/unique-name.schema.js\";\nexport {\n UrlOrPathSchema,\n UrlPathSchema,\n UrlSchema,\n type Url,\n type UrlOrPath,\n type UrlPath,\n} from \"./validation/url.schema.js\";\n","import { ZodError, type ZodSchema } from \"zod\";\n\n/**\n * Validates a value against a given Zod schema.\n *\n * @param schema - The Zod schema to validate against.\n * @param value - The value to validate.\n * @returns The validated and parsed value.\n * @throws Will throw an error if validation fails, with formatted error messages.\n *\n * @example\n * import { validate } from \"@settlemint/sdk-utils/validation\";\n *\n * const validatedId = validate(IdSchema, \"550e8400-e29b-41d4-a716-446655440000\");\n */\nexport function validate<T extends ZodSchema>(schema: T, value: unknown): T[\"_output\"] {\n try {\n return schema.parse(value);\n } catch (error) {\n if (error instanceof ZodError) {\n const formattedErrors = error.errors.map((err) => `- ${err.path.join(\".\")}: ${err.message}`).join(\"\\n\");\n throw new Error(`Validation error${error.errors.length > 1 ? \"s\" : \"\"}:\\n${formattedErrors}`);\n }\n throw error; // Re-throw if it's not a ZodError\n }\n}\n","import { type ZodString, z } from \"zod\";\n\n/**\n * Schema for validating application access tokens.\n * Application access tokens start with 'sm_aat_' prefix.\n */\nexport const ApplicationAccessTokenSchema: ZodString = z.string().regex(/^sm_aat_.*$/);\nexport type ApplicationAccessToken = z.infer<typeof ApplicationAccessTokenSchema>;\n\n/**\n * Schema for validating personal access tokens.\n * Personal access tokens start with 'sm_pat_' prefix.\n */\nexport const PersonalAccessTokenSchema: ZodString = z.string().regex(/^sm_pat_.*$/);\nexport type PersonalAccessToken = z.infer<typeof PersonalAccessTokenSchema>;\n\n/**\n * Schema for validating both application and personal access tokens.\n * Accepts tokens starting with either 'sm_pat_' or 'sm_aat_' prefix.\n */\nexport const AccessTokenSchema: ZodString = z.string().regex(/^sm_pat_.*|sm_aat_.*$/);\nexport type AccessToken = z.infer<typeof AccessTokenSchema>;\n","/**\n * Attempts to parse a JSON string into a typed value, returning a default value if parsing fails.\n *\n * @param value - The JSON string to parse\n * @param defaultValue - The value to return if parsing fails or results in null/undefined\n * @returns The parsed JSON value as type T, or the default value if parsing fails\n *\n * @example\n * import { tryParseJson } from \"@settlemint/sdk-utils\";\n *\n * const config = tryParseJson<{ port: number }>(\n * '{\"port\": 3000}',\n * { port: 8080 }\n * );\n * // Returns: { port: 3000 }\n *\n * const invalid = tryParseJson<string[]>(\n * 'invalid json',\n * []\n * );\n * // Returns: []\n */\nexport function tryParseJson<T>(value: string, defaultValue: T | null = null): T | null {\n try {\n const parsed = JSON.parse(value) as T;\n if (parsed === undefined || parsed === null) {\n return defaultValue;\n }\n return parsed;\n } catch (err) {\n // Invalid json\n return defaultValue;\n }\n}\n","import { tryParseJson } from \"@/json.js\";\nimport { z } from \"zod\";\nimport { ApplicationAccessTokenSchema, PersonalAccessTokenSchema } from \"./access-token.schema.js\";\nimport { UniqueNameSchema } from \"./unique-name.schema.js\";\nimport { UrlSchema } from \"./url.schema.js\";\n\n/**\n * Schema for validating environment variables used by the SettleMint SDK.\n * Defines validation rules and types for configuration values like URLs,\n * access tokens, workspace names, and service endpoints.\n */\nexport const DotEnvSchema = z.object({\n /** Base URL of the SettleMint platform instance */\n SETTLEMINT_INSTANCE: UrlSchema.default(\"https://console.settlemint.com\"),\n /** Application access token for authenticating with SettleMint services */\n SETTLEMINT_ACCESS_TOKEN: ApplicationAccessTokenSchema.optional(),\n /** @internal */\n SETTLEMINT_PERSONAL_ACCESS_TOKEN: PersonalAccessTokenSchema.optional(),\n /** Unique name of the workspace */\n SETTLEMINT_WORKSPACE: UniqueNameSchema.optional(),\n /** Unique name of the application */\n SETTLEMINT_APPLICATION: UniqueNameSchema.optional(),\n /** Unique name of the blockchain network */\n SETTLEMINT_BLOCKCHAIN_NETWORK: UniqueNameSchema.optional(),\n /** Unique name of the blockchain node */\n SETTLEMINT_BLOCKCHAIN_NODE: UniqueNameSchema.optional(),\n /** Unique name of the load balancer */\n SETTLEMINT_LOAD_BALANCER: UniqueNameSchema.optional(),\n /** Unique name of the Hasura instance */\n SETTLEMINT_HASURA: UniqueNameSchema.optional(),\n /** Endpoint URL for the Hasura GraphQL API */\n SETTLEMINT_HASURA_ENDPOINT: UrlSchema.optional(),\n /** Admin secret for authenticating with Hasura */\n SETTLEMINT_HASURA_ADMIN_SECRET: z.string().optional(),\n /** Database connection URL for Hasura */\n SETTLEMINT_HASURA_DATABASE_URL: z.string().optional(),\n /** Unique name of The Graph instance */\n SETTLEMINT_THEGRAPH: UniqueNameSchema.optional(),\n /** Array of endpoint URLs for The Graph subgraphs */\n SETTLEMINT_THEGRAPH_SUBGRAPHS_ENDPOINTS: z.preprocess(\n (value) => tryParseJson(value as string, []),\n z.array(UrlSchema).optional(),\n ),\n /** Default The Graph subgraph to use */\n SETTLEMINT_THEGRAPH_DEFAULT_SUBGRAPH: z.string().optional(),\n /** Unique name of the Smart Contract Portal instance */\n SETTLEMINT_PORTAL: UniqueNameSchema.optional(),\n /** GraphQL endpoint URL for the Portal */\n SETTLEMINT_PORTAL_GRAPHQL_ENDPOINT: UrlSchema.optional(),\n /** REST endpoint URL for the Portal */\n SETTLEMINT_PORTAL_REST_ENDPOINT: UrlSchema.optional(),\n /** Unique name of the HD private key */\n SETTLEMINT_HD_PRIVATE_KEY: UniqueNameSchema.optional(),\n /** Unique name of the accessible private key */\n SETTLEMINT_ACCESSIBLE_PRIVATE_KEY: UniqueNameSchema.optional(),\n /** Unique name of the MinIO instance */\n SETTLEMINT_MINIO: UniqueNameSchema.optional(),\n /** Endpoint URL for MinIO */\n SETTLEMINT_MINIO_ENDPOINT: UrlSchema.optional(),\n /** Access key for MinIO authentication */\n SETTLEMINT_MINIO_ACCESS_KEY: z.string().optional(),\n /** Secret key for MinIO authentication */\n SETTLEMINT_MINIO_SECRET_KEY: z.string().optional(),\n /** Unique name of the IPFS instance */\n SETTLEMINT_IPFS: UniqueNameSchema.optional(),\n /** API endpoint URL for IPFS */\n SETTLEMINT_IPFS_API_ENDPOINT: UrlSchema.optional(),\n /** Pinning service endpoint URL for IPFS */\n SETTLEMINT_IPFS_PINNING_ENDPOINT: UrlSchema.optional(),\n /** Gateway endpoint URL for IPFS */\n SETTLEMINT_IPFS_GATEWAY_ENDPOINT: UrlSchema.optional(),\n /** Unique name of the custom deployment */\n SETTLEMINT_CUSTOM_DEPLOYMENT: UniqueNameSchema.optional(),\n /** Endpoint URL for the custom deployment */\n SETTLEMINT_CUSTOM_DEPLOYMENT_ENDPOINT: UrlSchema.optional(),\n /** Unique name of the Blockscout instance */\n SETTLEMINT_BLOCKSCOUT: UniqueNameSchema.optional(),\n /** GraphQL endpoint URL for Blockscout */\n SETTLEMINT_BLOCKSCOUT_GRAPHQL_ENDPOINT: UrlSchema.optional(),\n /** UI endpoint URL for Blockscout */\n SETTLEMINT_BLOCKSCOUT_UI_ENDPOINT: UrlSchema.optional(),\n /** Name of the new project being created */\n SETTLEMINT_NEW_PROJECT_NAME: z.string().optional(),\n /** The log level to use */\n SETTLEMINT_LOG_LEVEL: z.enum([\"debug\", \"info\", \"warn\", \"error\", \"none\"]).default(\"warn\"),\n});\n\n/**\n * Type definition for the environment variables schema.\n */\nexport type DotEnv = z.infer<typeof DotEnvSchema>;\n\n/**\n * Partial version of the environment variables schema where all fields are optional.\n * Useful for validating incomplete configurations during development or build time.\n */\nexport const DotEnvSchemaPartial = DotEnvSchema.partial();\n\n/**\n * Type definition for the partial environment variables schema.\n */\nexport type DotEnvPartial = z.infer<typeof DotEnvSchemaPartial>;\n","import { z } from \"zod\";\n\n/**\n * Schema for validating unique names used across the SettleMint platform.\n * Only accepts lowercase alphanumeric characters and hyphens.\n * Used for workspace names, application names, service names etc.\n *\n * @example\n * import { UniqueNameSchema } from \"@settlemint/sdk-utils/validation\";\n *\n * // Validate a workspace name\n * const isValidName = UniqueNameSchema.safeParse(\"my-workspace-123\").success;\n * // true\n *\n * // Invalid names will fail validation\n * const isInvalidName = UniqueNameSchema.safeParse(\"My Workspace!\").success;\n * // false\n */\nexport const UniqueNameSchema = z.string().regex(/^[a-z0-9-]+$/);\n\n/**\n * Type definition for unique names, inferred from UniqueNameSchema.\n */\nexport type UniqueName = z.infer<typeof UniqueNameSchema>;\n","import { z } from \"zod\";\n\n/**\n * Schema for validating URLs.\n *\n * @example\n * import { UrlSchema } from \"@settlemint/sdk-utils/validation\";\n *\n * // Validate a URL\n * const isValidUrl = UrlSchema.safeParse(\"https://console.settlemint.com\").success;\n * // true\n *\n * // Invalid URLs will fail validation\n * const isInvalidUrl = UrlSchema.safeParse(\"not-a-url\").success;\n * // false\n */\nexport const UrlSchema = z.string().url();\nexport type Url = z.infer<typeof UrlSchema>;\n\n/**\n * Schema for validating URL paths.\n *\n * @example\n * import { UrlPathSchema } from \"@settlemint/sdk-utils/validation\";\n *\n * // Validate a URL path\n * const isValidPath = UrlPathSchema.safeParse(\"/api/v1/users\").success;\n * // true\n *\n * // Invalid paths will fail validation\n * const isInvalidPath = UrlPathSchema.safeParse(\"not-a-path\").success;\n * // false\n */\nexport const UrlPathSchema = z.string().regex(/^\\/(?:[a-zA-Z0-9-_]+(?:\\/[a-zA-Z0-9-_]+)*\\/?)?$/, {\n message: \"Invalid URL path format. Must start with '/' and can contain letters, numbers, hyphens, and underscores.\",\n});\n\nexport type UrlPath = z.infer<typeof UrlPathSchema>;\n\n/**\n * Schema that accepts either a full URL or a URL path.\n *\n * @example\n * import { UrlOrPathSchema } from \"@settlemint/sdk-utils/validation\";\n *\n * // Validate a URL\n * const isValidUrl = UrlOrPathSchema.safeParse(\"https://console.settlemint.com\").success;\n * // true\n *\n * // Validate a path\n * const isValidPath = UrlOrPathSchema.safeParse(\"/api/v1/users\").success;\n * // true\n */\nexport const UrlOrPathSchema = z.union([UrlSchema, UrlPathSchema]);\nexport type UrlOrPath = z.infer<typeof UrlOrPathSchema>;\n","import { z } from \"zod\";\n\n/**\n * Schema for validating database IDs. Accepts both PostgreSQL UUIDs and MongoDB ObjectIDs.\n * PostgreSQL UUIDs are 32 hexadecimal characters with hyphens (e.g. 123e4567-e89b-12d3-a456-426614174000).\n * MongoDB ObjectIDs are 24 hexadecimal characters (e.g. 507f1f77bcf86cd799439011).\n *\n * @example\n * import { IdSchema } from \"@settlemint/sdk-utils/validation\";\n *\n * // Validate PostgreSQL UUID\n * const isValidUuid = IdSchema.safeParse(\"123e4567-e89b-12d3-a456-426614174000\").success;\n *\n * // Validate MongoDB ObjectID\n * const isValidObjectId = IdSchema.safeParse(\"507f1f77bcf86cd799439011\").success;\n */\nexport const IdSchema = z.union([\n z\n .string()\n .uuid(), // PostgreSQL UUID\n z\n .string()\n .regex(/^[0-9a-fA-F]{24}$/), // MongoDB ObjectID\n]);\n\n/**\n * Type definition for database IDs, inferred from IdSchema.\n * Can be either a PostgreSQL UUID string or MongoDB ObjectID string.\n */\nexport type Id = z.infer<typeof IdSchema>;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,iBAAyC;AAelC,SAAS,SAA8B,QAAW,OAA8B;AACrF,MAAI;AACF,WAAO,OAAO,MAAM,KAAK;AAAA,EAC3B,SAAS,OAAO;AACd,QAAI,iBAAiB,qBAAU;AAC7B,YAAM,kBAAkB,MAAM,OAAO,IAAI,CAAC,QAAQ,KAAK,IAAI,KAAK,KAAK,GAA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E,OAAO,EAAE,SAAS;AAAA;AAAA,EAEjD,sBAAsB,cAAE,KAAK,CAAC,SAAS,QAAQ,QAAQ,SAAS,MAAM,CAAC,EAAE,QAAQ,MAAM;AACzF,CAAC;AAWM,IAAM,sBAAsB,aAAa,QAAQ;;;AGhGxD,IAAAC,cAAkB;AAgBX,IAAM,WAAW,cAAE,MAAM;AAAA,EAC9B,cACG,OAAO,EACP,KAAK;AAAA;AAAA,EACR,cACG,OAAO,EACP,MAAM,mBAAmB;AAAA;AAC9B,CAAC;","names":["import_zod","import_zod","import_zod","import_zod","import_zod"]}
1
+ {"version":3,"sources":["../src/validation.ts","../src/validation/validate.ts","../src/validation/access-token.schema.ts","../src/json.ts","../src/validation/dot-env.schema.ts","../src/validation/unique-name.schema.ts","../src/validation/url.schema.ts","../src/validation/id.schema.ts"],"sourcesContent":["export { validate } from \"./validation/validate.js\";\nexport {\n ApplicationAccessTokenSchema,\n type ApplicationAccessToken,\n PersonalAccessTokenSchema,\n type PersonalAccessToken,\n AccessTokenSchema,\n type AccessToken,\n} from \"./validation/access-token.schema.js\";\nexport { DotEnvSchema, DotEnvSchemaPartial, type DotEnv, type DotEnvPartial } from \"./validation/dot-env.schema.js\";\nexport { IdSchema, type Id } from \"./validation/id.schema.js\";\nexport { UniqueNameSchema } from \"./validation/unique-name.schema.js\";\nexport {\n UrlOrPathSchema,\n UrlPathSchema,\n UrlSchema,\n type Url,\n type UrlOrPath,\n type UrlPath,\n} from \"./validation/url.schema.js\";\n","import { ZodError, type ZodSchema } from \"zod\";\n\n/**\n * Validates a value against a given Zod schema.\n *\n * @param schema - The Zod schema to validate against.\n * @param value - The value to validate.\n * @returns The validated and parsed value.\n * @throws Will throw an error if validation fails, with formatted error messages.\n *\n * @example\n * import { validate } from \"@settlemint/sdk-utils/validation\";\n *\n * const validatedId = validate(IdSchema, \"550e8400-e29b-41d4-a716-446655440000\");\n */\nexport function validate<T extends ZodSchema>(schema: T, value: unknown): T[\"_output\"] {\n try {\n return schema.parse(value);\n } catch (error) {\n if (error instanceof ZodError) {\n const formattedErrors = error.errors.map((err) => `- ${err.path.join(\".\")}: ${err.message}`).join(\"\\n\");\n throw new Error(`Validation error${error.errors.length > 1 ? \"s\" : \"\"}:\\n${formattedErrors}`);\n }\n throw error; // Re-throw if it's not a ZodError\n }\n}\n","import { type ZodString, z } from \"zod\";\n\n/**\n * Schema for validating application access tokens.\n * Application access tokens start with 'sm_aat_' prefix.\n */\nexport const ApplicationAccessTokenSchema: ZodString = z.string().regex(/^sm_aat_.*$/);\nexport type ApplicationAccessToken = z.infer<typeof ApplicationAccessTokenSchema>;\n\n/**\n * Schema for validating personal access tokens.\n * Personal access tokens start with 'sm_pat_' prefix.\n */\nexport const PersonalAccessTokenSchema: ZodString = z.string().regex(/^sm_pat_.*$/);\nexport type PersonalAccessToken = z.infer<typeof PersonalAccessTokenSchema>;\n\n/**\n * Schema for validating both application and personal access tokens.\n * Accepts tokens starting with either 'sm_pat_' or 'sm_aat_' prefix.\n */\nexport const AccessTokenSchema: ZodString = z.string().regex(/^sm_pat_.*|sm_aat_.*$/);\nexport type AccessToken = z.infer<typeof AccessTokenSchema>;\n","/**\n * Attempts to parse a JSON string into a typed value, returning a default value if parsing fails.\n *\n * @param value - The JSON string to parse\n * @param defaultValue - The value to return if parsing fails or results in null/undefined\n * @returns The parsed JSON value as type T, or the default value if parsing fails\n *\n * @example\n * import { tryParseJson } from \"@settlemint/sdk-utils\";\n *\n * const config = tryParseJson<{ port: number }>(\n * '{\"port\": 3000}',\n * { port: 8080 }\n * );\n * // Returns: { port: 3000 }\n *\n * const invalid = tryParseJson<string[]>(\n * 'invalid json',\n * []\n * );\n * // Returns: []\n */\nexport function tryParseJson<T>(value: string, defaultValue: T | null = null): T | null {\n try {\n const parsed = JSON.parse(value) as T;\n if (parsed === undefined || parsed === null) {\n return defaultValue;\n }\n return parsed;\n } catch (err) {\n // Invalid json\n return defaultValue;\n }\n}\n\n/**\n * Extracts a JSON object from a string.\n *\n * @param value - The string to extract the JSON object from\n * @returns The parsed JSON object, or null if no JSON object is found\n * @throws {Error} If the input string is too long (longer than 5000 characters)\n * @example\n * import { extractJsonObject } from \"@settlemint/sdk-utils\";\n *\n * const json = extractJsonObject<{ port: number }>(\n * 'port info: {\"port\": 3000}',\n * );\n * // Returns: { port: 3000 }\n */\nexport function extractJsonObject<T>(value: string): T | null {\n if (value.length > 5000) {\n throw new Error(\"Input too long\");\n }\n const result = /\\{([\\s\\S]*)\\}/.exec(value);\n if (!result) {\n return null;\n }\n return tryParseJson<T>(result[0]);\n}\n","import { tryParseJson } from \"@/json.js\";\nimport { z } from \"zod\";\nimport { ApplicationAccessTokenSchema, PersonalAccessTokenSchema } from \"./access-token.schema.js\";\nimport { UniqueNameSchema } from \"./unique-name.schema.js\";\nimport { UrlSchema } from \"./url.schema.js\";\n\n/**\n * Schema for validating environment variables used by the SettleMint SDK.\n * Defines validation rules and types for configuration values like URLs,\n * access tokens, workspace names, and service endpoints.\n */\nexport const DotEnvSchema = z.object({\n /** Base URL of the SettleMint platform instance */\n SETTLEMINT_INSTANCE: UrlSchema.default(\"https://console.settlemint.com\"),\n /** Application access token for authenticating with SettleMint services */\n SETTLEMINT_ACCESS_TOKEN: ApplicationAccessTokenSchema.optional(),\n /** @internal */\n SETTLEMINT_PERSONAL_ACCESS_TOKEN: PersonalAccessTokenSchema.optional(),\n /** Unique name of the workspace */\n SETTLEMINT_WORKSPACE: UniqueNameSchema.optional(),\n /** Unique name of the application */\n SETTLEMINT_APPLICATION: UniqueNameSchema.optional(),\n /** Unique name of the blockchain network */\n SETTLEMINT_BLOCKCHAIN_NETWORK: UniqueNameSchema.optional(),\n /** Chain ID of the blockchain network */\n SETTLEMINT_BLOCKCHAIN_NETWORK_CHAIN_ID: z.string().optional(),\n /** Unique name of the blockchain node (should have a private key for signing transactions) */\n SETTLEMINT_BLOCKCHAIN_NODE: UniqueNameSchema.optional(),\n /** JSON RPC endpoint for the blockchain node */\n SETTLEMINT_BLOCKCHAIN_NODE_JSON_RPC_ENDPOINT: UrlSchema.optional(),\n /** Unique name of the blockchain node or load balancer */\n SETTLEMINT_BLOCKCHAIN_NODE_OR_LOAD_BALANCER: UniqueNameSchema.optional(),\n /** JSON RPC endpoint for the blockchain node or load balancer */\n SETTLEMINT_BLOCKCHAIN_NODE_OR_LOAD_BALANCER_JSON_RPC_ENDPOINT: UrlSchema.optional(),\n /** Unique name of the Hasura instance */\n SETTLEMINT_HASURA: UniqueNameSchema.optional(),\n /** Endpoint URL for the Hasura GraphQL API */\n SETTLEMINT_HASURA_ENDPOINT: UrlSchema.optional(),\n /** Admin secret for authenticating with Hasura */\n SETTLEMINT_HASURA_ADMIN_SECRET: z.string().optional(),\n /** Database connection URL for Hasura */\n SETTLEMINT_HASURA_DATABASE_URL: z.string().optional(),\n /** Unique name of The Graph instance */\n SETTLEMINT_THEGRAPH: UniqueNameSchema.optional(),\n /** Array of endpoint URLs for The Graph subgraphs */\n SETTLEMINT_THEGRAPH_SUBGRAPHS_ENDPOINTS: z.preprocess(\n (value) => tryParseJson(value as string, []),\n z.array(UrlSchema).optional(),\n ),\n /** Default The Graph subgraph to use */\n SETTLEMINT_THEGRAPH_DEFAULT_SUBGRAPH: z.string().optional(),\n /** Unique name of the Smart Contract Portal instance */\n SETTLEMINT_PORTAL: UniqueNameSchema.optional(),\n /** GraphQL endpoint URL for the Portal */\n SETTLEMINT_PORTAL_GRAPHQL_ENDPOINT: UrlSchema.optional(),\n /** REST endpoint URL for the Portal */\n SETTLEMINT_PORTAL_REST_ENDPOINT: UrlSchema.optional(),\n /** Unique name of the HD private key */\n SETTLEMINT_HD_PRIVATE_KEY: UniqueNameSchema.optional(),\n /** Unique name of the accessible private key */\n SETTLEMINT_ACCESSIBLE_PRIVATE_KEY: UniqueNameSchema.optional(),\n /** Unique name of the MinIO instance */\n SETTLEMINT_MINIO: UniqueNameSchema.optional(),\n /** Endpoint URL for MinIO */\n SETTLEMINT_MINIO_ENDPOINT: UrlSchema.optional(),\n /** Access key for MinIO authentication */\n SETTLEMINT_MINIO_ACCESS_KEY: z.string().optional(),\n /** Secret key for MinIO authentication */\n SETTLEMINT_MINIO_SECRET_KEY: z.string().optional(),\n /** Unique name of the IPFS instance */\n SETTLEMINT_IPFS: UniqueNameSchema.optional(),\n /** API endpoint URL for IPFS */\n SETTLEMINT_IPFS_API_ENDPOINT: UrlSchema.optional(),\n /** Pinning service endpoint URL for IPFS */\n SETTLEMINT_IPFS_PINNING_ENDPOINT: UrlSchema.optional(),\n /** Gateway endpoint URL for IPFS */\n SETTLEMINT_IPFS_GATEWAY_ENDPOINT: UrlSchema.optional(),\n /** Unique name of the custom deployment */\n SETTLEMINT_CUSTOM_DEPLOYMENT: UniqueNameSchema.optional(),\n /** Endpoint URL for the custom deployment */\n SETTLEMINT_CUSTOM_DEPLOYMENT_ENDPOINT: UrlSchema.optional(),\n /** Unique name of the Blockscout instance */\n SETTLEMINT_BLOCKSCOUT: UniqueNameSchema.optional(),\n /** GraphQL endpoint URL for Blockscout */\n SETTLEMINT_BLOCKSCOUT_GRAPHQL_ENDPOINT: UrlSchema.optional(),\n /** UI endpoint URL for Blockscout */\n SETTLEMINT_BLOCKSCOUT_UI_ENDPOINT: UrlSchema.optional(),\n /** Name of the new project being created */\n SETTLEMINT_NEW_PROJECT_NAME: z.string().optional(),\n /** The log level to use */\n SETTLEMINT_LOG_LEVEL: z.enum([\"debug\", \"info\", \"warn\", \"error\", \"none\"]).default(\"warn\"),\n});\n\n/**\n * Type definition for the environment variables schema.\n */\nexport type DotEnv = z.infer<typeof DotEnvSchema>;\n\n/**\n * Partial version of the environment variables schema where all fields are optional.\n * Useful for validating incomplete configurations during development or build time.\n */\nexport const DotEnvSchemaPartial = DotEnvSchema.partial();\n\n/**\n * Type definition for the partial environment variables schema.\n */\nexport type DotEnvPartial = z.infer<typeof DotEnvSchemaPartial>;\n","import { z } from \"zod\";\n\n/**\n * Schema for validating unique names used across the SettleMint platform.\n * Only accepts lowercase alphanumeric characters and hyphens.\n * Used for workspace names, application names, service names etc.\n *\n * @example\n * import { UniqueNameSchema } from \"@settlemint/sdk-utils/validation\";\n *\n * // Validate a workspace name\n * const isValidName = UniqueNameSchema.safeParse(\"my-workspace-123\").success;\n * // true\n *\n * // Invalid names will fail validation\n * const isInvalidName = UniqueNameSchema.safeParse(\"My Workspace!\").success;\n * // false\n */\nexport const UniqueNameSchema = z.string().regex(/^[a-z0-9-]+$/);\n\n/**\n * Type definition for unique names, inferred from UniqueNameSchema.\n */\nexport type UniqueName = z.infer<typeof UniqueNameSchema>;\n","import { z } from \"zod\";\n\n/**\n * Schema for validating URLs.\n *\n * @example\n * import { UrlSchema } from \"@settlemint/sdk-utils/validation\";\n *\n * // Validate a URL\n * const isValidUrl = UrlSchema.safeParse(\"https://console.settlemint.com\").success;\n * // true\n *\n * // Invalid URLs will fail validation\n * const isInvalidUrl = UrlSchema.safeParse(\"not-a-url\").success;\n * // false\n */\nexport const UrlSchema = z.string().url();\nexport type Url = z.infer<typeof UrlSchema>;\n\n/**\n * Schema for validating URL paths.\n *\n * @example\n * import { UrlPathSchema } from \"@settlemint/sdk-utils/validation\";\n *\n * // Validate a URL path\n * const isValidPath = UrlPathSchema.safeParse(\"/api/v1/users\").success;\n * // true\n *\n * // Invalid paths will fail validation\n * const isInvalidPath = UrlPathSchema.safeParse(\"not-a-path\").success;\n * // false\n */\nexport const UrlPathSchema = z.string().regex(/^\\/(?:[a-zA-Z0-9-_]+(?:\\/[a-zA-Z0-9-_]+)*\\/?)?$/, {\n message: \"Invalid URL path format. Must start with '/' and can contain letters, numbers, hyphens, and underscores.\",\n});\n\nexport type UrlPath = z.infer<typeof UrlPathSchema>;\n\n/**\n * Schema that accepts either a full URL or a URL path.\n *\n * @example\n * import { UrlOrPathSchema } from \"@settlemint/sdk-utils/validation\";\n *\n * // Validate a URL\n * const isValidUrl = UrlOrPathSchema.safeParse(\"https://console.settlemint.com\").success;\n * // true\n *\n * // Validate a path\n * const isValidPath = UrlOrPathSchema.safeParse(\"/api/v1/users\").success;\n * // true\n */\nexport const UrlOrPathSchema = z.union([UrlSchema, UrlPathSchema]);\nexport type UrlOrPath = z.infer<typeof UrlOrPathSchema>;\n","import { z } from \"zod\";\n\n/**\n * Schema for validating database IDs. Accepts both PostgreSQL UUIDs and MongoDB ObjectIDs.\n * PostgreSQL UUIDs are 32 hexadecimal characters with hyphens (e.g. 123e4567-e89b-12d3-a456-426614174000).\n * MongoDB ObjectIDs are 24 hexadecimal characters (e.g. 507f1f77bcf86cd799439011).\n *\n * @example\n * import { IdSchema } from \"@settlemint/sdk-utils/validation\";\n *\n * // Validate PostgreSQL UUID\n * const isValidUuid = IdSchema.safeParse(\"123e4567-e89b-12d3-a456-426614174000\").success;\n *\n * // Validate MongoDB ObjectID\n * const isValidObjectId = IdSchema.safeParse(\"507f1f77bcf86cd799439011\").success;\n */\nexport const IdSchema = z.union([\n z\n .string()\n .uuid(), // PostgreSQL UUID\n z\n .string()\n .regex(/^[0-9a-fA-F]{24}$/), // MongoDB ObjectID\n]);\n\n/**\n * Type definition for database IDs, inferred from IdSchema.\n * Can be either a PostgreSQL UUID string or MongoDB ObjectID string.\n */\nexport type Id = z.infer<typeof IdSchema>;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,iBAAyC;AAelC,SAAS,SAA8B,QAAW,OAA8B;AACrF,MAAI;AACF,WAAO,OAAO,MAAM,KAAK;AAAA,EAC3B,SAAS,OAAO;AACd,QAAI,iBAAiB,qBAAU;AAC7B,YAAM,kBAAkB,MAAM,OAAO,IAAI,CAAC,QAAQ,KAAK,IAAI,KAAK,KAAK,GAAG,CAAC,KAAK,IAAI,OAAO,EAAE,EAAE,KAAK,IAAI;AACtG,YAAM,IAAI,MAAM,mBAAmB,MAAM,OAAO,SAAS,IAAI,MAAM,EAAE;AAAA,EAAM,eAAe,EAA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AE,SAAS;AAAA;AAAA,EAEjD,sBAAsB,cAAE,KAAK,CAAC,SAAS,QAAQ,QAAQ,SAAS,MAAM,CAAC,EAAE,QAAQ,MAAM;AACzF,CAAC;AAWM,IAAM,sBAAsB,aAAa,QAAQ;;;AGtGxD,IAAAC,cAAkB;AAgBX,IAAM,WAAW,cAAE,MAAM;AAAA,EAC9B,cACG,OAAO,EACP,KAAK;AAAA;AAAA,EACR,cACG,OAAO,EACP,MAAM,mBAAmB;AAAA;AAC9B,CAAC;","names":["import_zod","import_zod","import_zod","import_zod","import_zod"]}
@@ -52,10 +52,16 @@ declare const DotEnvSchema: z.ZodObject<{
52
52
  SETTLEMINT_APPLICATION: z.ZodOptional<z.ZodString>;
53
53
  /** Unique name of the blockchain network */
54
54
  SETTLEMINT_BLOCKCHAIN_NETWORK: z.ZodOptional<z.ZodString>;
55
- /** Unique name of the blockchain node */
55
+ /** Chain ID of the blockchain network */
56
+ SETTLEMINT_BLOCKCHAIN_NETWORK_CHAIN_ID: z.ZodOptional<z.ZodString>;
57
+ /** Unique name of the blockchain node (should have a private key for signing transactions) */
56
58
  SETTLEMINT_BLOCKCHAIN_NODE: z.ZodOptional<z.ZodString>;
57
- /** Unique name of the load balancer */
58
- SETTLEMINT_LOAD_BALANCER: z.ZodOptional<z.ZodString>;
59
+ /** JSON RPC endpoint for the blockchain node */
60
+ SETTLEMINT_BLOCKCHAIN_NODE_JSON_RPC_ENDPOINT: z.ZodOptional<z.ZodString>;
61
+ /** Unique name of the blockchain node or load balancer */
62
+ SETTLEMINT_BLOCKCHAIN_NODE_OR_LOAD_BALANCER: z.ZodOptional<z.ZodString>;
63
+ /** JSON RPC endpoint for the blockchain node or load balancer */
64
+ SETTLEMINT_BLOCKCHAIN_NODE_OR_LOAD_BALANCER_JSON_RPC_ENDPOINT: z.ZodOptional<z.ZodString>;
59
65
  /** Unique name of the Hasura instance */
60
66
  SETTLEMINT_HASURA: z.ZodOptional<z.ZodString>;
61
67
  /** Endpoint URL for the Hasura GraphQL API */
@@ -118,8 +124,11 @@ declare const DotEnvSchema: z.ZodObject<{
118
124
  SETTLEMINT_WORKSPACE?: string | undefined;
119
125
  SETTLEMINT_APPLICATION?: string | undefined;
120
126
  SETTLEMINT_BLOCKCHAIN_NETWORK?: string | undefined;
127
+ SETTLEMINT_BLOCKCHAIN_NETWORK_CHAIN_ID?: string | undefined;
121
128
  SETTLEMINT_BLOCKCHAIN_NODE?: string | undefined;
122
- SETTLEMINT_LOAD_BALANCER?: string | undefined;
129
+ SETTLEMINT_BLOCKCHAIN_NODE_JSON_RPC_ENDPOINT?: string | undefined;
130
+ SETTLEMINT_BLOCKCHAIN_NODE_OR_LOAD_BALANCER?: string | undefined;
131
+ SETTLEMINT_BLOCKCHAIN_NODE_OR_LOAD_BALANCER_JSON_RPC_ENDPOINT?: string | undefined;
123
132
  SETTLEMINT_HASURA?: string | undefined;
124
133
  SETTLEMINT_HASURA_ENDPOINT?: string | undefined;
125
134
  SETTLEMINT_HASURA_ADMIN_SECRET?: string | undefined;
@@ -153,8 +162,11 @@ declare const DotEnvSchema: z.ZodObject<{
153
162
  SETTLEMINT_WORKSPACE?: string | undefined;
154
163
  SETTLEMINT_APPLICATION?: string | undefined;
155
164
  SETTLEMINT_BLOCKCHAIN_NETWORK?: string | undefined;
165
+ SETTLEMINT_BLOCKCHAIN_NETWORK_CHAIN_ID?: string | undefined;
156
166
  SETTLEMINT_BLOCKCHAIN_NODE?: string | undefined;
157
- SETTLEMINT_LOAD_BALANCER?: string | undefined;
167
+ SETTLEMINT_BLOCKCHAIN_NODE_JSON_RPC_ENDPOINT?: string | undefined;
168
+ SETTLEMINT_BLOCKCHAIN_NODE_OR_LOAD_BALANCER?: string | undefined;
169
+ SETTLEMINT_BLOCKCHAIN_NODE_OR_LOAD_BALANCER_JSON_RPC_ENDPOINT?: string | undefined;
158
170
  SETTLEMINT_HASURA?: string | undefined;
159
171
  SETTLEMINT_HASURA_ENDPOINT?: string | undefined;
160
172
  SETTLEMINT_HASURA_ADMIN_SECRET?: string | undefined;
@@ -198,8 +210,11 @@ declare const DotEnvSchemaPartial: z.ZodObject<{
198
210
  SETTLEMINT_WORKSPACE: z.ZodOptional<z.ZodOptional<z.ZodString>>;
199
211
  SETTLEMINT_APPLICATION: z.ZodOptional<z.ZodOptional<z.ZodString>>;
200
212
  SETTLEMINT_BLOCKCHAIN_NETWORK: z.ZodOptional<z.ZodOptional<z.ZodString>>;
213
+ SETTLEMINT_BLOCKCHAIN_NETWORK_CHAIN_ID: z.ZodOptional<z.ZodOptional<z.ZodString>>;
201
214
  SETTLEMINT_BLOCKCHAIN_NODE: z.ZodOptional<z.ZodOptional<z.ZodString>>;
202
- SETTLEMINT_LOAD_BALANCER: z.ZodOptional<z.ZodOptional<z.ZodString>>;
215
+ SETTLEMINT_BLOCKCHAIN_NODE_JSON_RPC_ENDPOINT: z.ZodOptional<z.ZodOptional<z.ZodString>>;
216
+ SETTLEMINT_BLOCKCHAIN_NODE_OR_LOAD_BALANCER: z.ZodOptional<z.ZodOptional<z.ZodString>>;
217
+ SETTLEMINT_BLOCKCHAIN_NODE_OR_LOAD_BALANCER_JSON_RPC_ENDPOINT: z.ZodOptional<z.ZodOptional<z.ZodString>>;
203
218
  SETTLEMINT_HASURA: z.ZodOptional<z.ZodOptional<z.ZodString>>;
204
219
  SETTLEMINT_HASURA_ENDPOINT: z.ZodOptional<z.ZodOptional<z.ZodString>>;
205
220
  SETTLEMINT_HASURA_ADMIN_SECRET: z.ZodOptional<z.ZodOptional<z.ZodString>>;
@@ -234,8 +249,11 @@ declare const DotEnvSchemaPartial: z.ZodObject<{
234
249
  SETTLEMINT_WORKSPACE?: string | undefined;
235
250
  SETTLEMINT_APPLICATION?: string | undefined;
236
251
  SETTLEMINT_BLOCKCHAIN_NETWORK?: string | undefined;
252
+ SETTLEMINT_BLOCKCHAIN_NETWORK_CHAIN_ID?: string | undefined;
237
253
  SETTLEMINT_BLOCKCHAIN_NODE?: string | undefined;
238
- SETTLEMINT_LOAD_BALANCER?: string | undefined;
254
+ SETTLEMINT_BLOCKCHAIN_NODE_JSON_RPC_ENDPOINT?: string | undefined;
255
+ SETTLEMINT_BLOCKCHAIN_NODE_OR_LOAD_BALANCER?: string | undefined;
256
+ SETTLEMINT_BLOCKCHAIN_NODE_OR_LOAD_BALANCER_JSON_RPC_ENDPOINT?: string | undefined;
239
257
  SETTLEMINT_HASURA?: string | undefined;
240
258
  SETTLEMINT_HASURA_ENDPOINT?: string | undefined;
241
259
  SETTLEMINT_HASURA_ADMIN_SECRET?: string | undefined;
@@ -270,8 +288,11 @@ declare const DotEnvSchemaPartial: z.ZodObject<{
270
288
  SETTLEMINT_WORKSPACE?: string | undefined;
271
289
  SETTLEMINT_APPLICATION?: string | undefined;
272
290
  SETTLEMINT_BLOCKCHAIN_NETWORK?: string | undefined;
291
+ SETTLEMINT_BLOCKCHAIN_NETWORK_CHAIN_ID?: string | undefined;
273
292
  SETTLEMINT_BLOCKCHAIN_NODE?: string | undefined;
274
- SETTLEMINT_LOAD_BALANCER?: string | undefined;
293
+ SETTLEMINT_BLOCKCHAIN_NODE_JSON_RPC_ENDPOINT?: string | undefined;
294
+ SETTLEMINT_BLOCKCHAIN_NODE_OR_LOAD_BALANCER?: string | undefined;
295
+ SETTLEMINT_BLOCKCHAIN_NODE_OR_LOAD_BALANCER_JSON_RPC_ENDPOINT?: string | undefined;
275
296
  SETTLEMINT_HASURA?: string | undefined;
276
297
  SETTLEMINT_HASURA_ENDPOINT?: string | undefined;
277
298
  SETTLEMINT_HASURA_ADMIN_SECRET?: string | undefined;
@@ -52,10 +52,16 @@ declare const DotEnvSchema: z.ZodObject<{
52
52
  SETTLEMINT_APPLICATION: z.ZodOptional<z.ZodString>;
53
53
  /** Unique name of the blockchain network */
54
54
  SETTLEMINT_BLOCKCHAIN_NETWORK: z.ZodOptional<z.ZodString>;
55
- /** Unique name of the blockchain node */
55
+ /** Chain ID of the blockchain network */
56
+ SETTLEMINT_BLOCKCHAIN_NETWORK_CHAIN_ID: z.ZodOptional<z.ZodString>;
57
+ /** Unique name of the blockchain node (should have a private key for signing transactions) */
56
58
  SETTLEMINT_BLOCKCHAIN_NODE: z.ZodOptional<z.ZodString>;
57
- /** Unique name of the load balancer */
58
- SETTLEMINT_LOAD_BALANCER: z.ZodOptional<z.ZodString>;
59
+ /** JSON RPC endpoint for the blockchain node */
60
+ SETTLEMINT_BLOCKCHAIN_NODE_JSON_RPC_ENDPOINT: z.ZodOptional<z.ZodString>;
61
+ /** Unique name of the blockchain node or load balancer */
62
+ SETTLEMINT_BLOCKCHAIN_NODE_OR_LOAD_BALANCER: z.ZodOptional<z.ZodString>;
63
+ /** JSON RPC endpoint for the blockchain node or load balancer */
64
+ SETTLEMINT_BLOCKCHAIN_NODE_OR_LOAD_BALANCER_JSON_RPC_ENDPOINT: z.ZodOptional<z.ZodString>;
59
65
  /** Unique name of the Hasura instance */
60
66
  SETTLEMINT_HASURA: z.ZodOptional<z.ZodString>;
61
67
  /** Endpoint URL for the Hasura GraphQL API */
@@ -118,8 +124,11 @@ declare const DotEnvSchema: z.ZodObject<{
118
124
  SETTLEMINT_WORKSPACE?: string | undefined;
119
125
  SETTLEMINT_APPLICATION?: string | undefined;
120
126
  SETTLEMINT_BLOCKCHAIN_NETWORK?: string | undefined;
127
+ SETTLEMINT_BLOCKCHAIN_NETWORK_CHAIN_ID?: string | undefined;
121
128
  SETTLEMINT_BLOCKCHAIN_NODE?: string | undefined;
122
- SETTLEMINT_LOAD_BALANCER?: string | undefined;
129
+ SETTLEMINT_BLOCKCHAIN_NODE_JSON_RPC_ENDPOINT?: string | undefined;
130
+ SETTLEMINT_BLOCKCHAIN_NODE_OR_LOAD_BALANCER?: string | undefined;
131
+ SETTLEMINT_BLOCKCHAIN_NODE_OR_LOAD_BALANCER_JSON_RPC_ENDPOINT?: string | undefined;
123
132
  SETTLEMINT_HASURA?: string | undefined;
124
133
  SETTLEMINT_HASURA_ENDPOINT?: string | undefined;
125
134
  SETTLEMINT_HASURA_ADMIN_SECRET?: string | undefined;
@@ -153,8 +162,11 @@ declare const DotEnvSchema: z.ZodObject<{
153
162
  SETTLEMINT_WORKSPACE?: string | undefined;
154
163
  SETTLEMINT_APPLICATION?: string | undefined;
155
164
  SETTLEMINT_BLOCKCHAIN_NETWORK?: string | undefined;
165
+ SETTLEMINT_BLOCKCHAIN_NETWORK_CHAIN_ID?: string | undefined;
156
166
  SETTLEMINT_BLOCKCHAIN_NODE?: string | undefined;
157
- SETTLEMINT_LOAD_BALANCER?: string | undefined;
167
+ SETTLEMINT_BLOCKCHAIN_NODE_JSON_RPC_ENDPOINT?: string | undefined;
168
+ SETTLEMINT_BLOCKCHAIN_NODE_OR_LOAD_BALANCER?: string | undefined;
169
+ SETTLEMINT_BLOCKCHAIN_NODE_OR_LOAD_BALANCER_JSON_RPC_ENDPOINT?: string | undefined;
158
170
  SETTLEMINT_HASURA?: string | undefined;
159
171
  SETTLEMINT_HASURA_ENDPOINT?: string | undefined;
160
172
  SETTLEMINT_HASURA_ADMIN_SECRET?: string | undefined;
@@ -198,8 +210,11 @@ declare const DotEnvSchemaPartial: z.ZodObject<{
198
210
  SETTLEMINT_WORKSPACE: z.ZodOptional<z.ZodOptional<z.ZodString>>;
199
211
  SETTLEMINT_APPLICATION: z.ZodOptional<z.ZodOptional<z.ZodString>>;
200
212
  SETTLEMINT_BLOCKCHAIN_NETWORK: z.ZodOptional<z.ZodOptional<z.ZodString>>;
213
+ SETTLEMINT_BLOCKCHAIN_NETWORK_CHAIN_ID: z.ZodOptional<z.ZodOptional<z.ZodString>>;
201
214
  SETTLEMINT_BLOCKCHAIN_NODE: z.ZodOptional<z.ZodOptional<z.ZodString>>;
202
- SETTLEMINT_LOAD_BALANCER: z.ZodOptional<z.ZodOptional<z.ZodString>>;
215
+ SETTLEMINT_BLOCKCHAIN_NODE_JSON_RPC_ENDPOINT: z.ZodOptional<z.ZodOptional<z.ZodString>>;
216
+ SETTLEMINT_BLOCKCHAIN_NODE_OR_LOAD_BALANCER: z.ZodOptional<z.ZodOptional<z.ZodString>>;
217
+ SETTLEMINT_BLOCKCHAIN_NODE_OR_LOAD_BALANCER_JSON_RPC_ENDPOINT: z.ZodOptional<z.ZodOptional<z.ZodString>>;
203
218
  SETTLEMINT_HASURA: z.ZodOptional<z.ZodOptional<z.ZodString>>;
204
219
  SETTLEMINT_HASURA_ENDPOINT: z.ZodOptional<z.ZodOptional<z.ZodString>>;
205
220
  SETTLEMINT_HASURA_ADMIN_SECRET: z.ZodOptional<z.ZodOptional<z.ZodString>>;
@@ -234,8 +249,11 @@ declare const DotEnvSchemaPartial: z.ZodObject<{
234
249
  SETTLEMINT_WORKSPACE?: string | undefined;
235
250
  SETTLEMINT_APPLICATION?: string | undefined;
236
251
  SETTLEMINT_BLOCKCHAIN_NETWORK?: string | undefined;
252
+ SETTLEMINT_BLOCKCHAIN_NETWORK_CHAIN_ID?: string | undefined;
237
253
  SETTLEMINT_BLOCKCHAIN_NODE?: string | undefined;
238
- SETTLEMINT_LOAD_BALANCER?: string | undefined;
254
+ SETTLEMINT_BLOCKCHAIN_NODE_JSON_RPC_ENDPOINT?: string | undefined;
255
+ SETTLEMINT_BLOCKCHAIN_NODE_OR_LOAD_BALANCER?: string | undefined;
256
+ SETTLEMINT_BLOCKCHAIN_NODE_OR_LOAD_BALANCER_JSON_RPC_ENDPOINT?: string | undefined;
239
257
  SETTLEMINT_HASURA?: string | undefined;
240
258
  SETTLEMINT_HASURA_ENDPOINT?: string | undefined;
241
259
  SETTLEMINT_HASURA_ADMIN_SECRET?: string | undefined;
@@ -270,8 +288,11 @@ declare const DotEnvSchemaPartial: z.ZodObject<{
270
288
  SETTLEMINT_WORKSPACE?: string | undefined;
271
289
  SETTLEMINT_APPLICATION?: string | undefined;
272
290
  SETTLEMINT_BLOCKCHAIN_NETWORK?: string | undefined;
291
+ SETTLEMINT_BLOCKCHAIN_NETWORK_CHAIN_ID?: string | undefined;
273
292
  SETTLEMINT_BLOCKCHAIN_NODE?: string | undefined;
274
- SETTLEMINT_LOAD_BALANCER?: string | undefined;
293
+ SETTLEMINT_BLOCKCHAIN_NODE_JSON_RPC_ENDPOINT?: string | undefined;
294
+ SETTLEMINT_BLOCKCHAIN_NODE_OR_LOAD_BALANCER?: string | undefined;
295
+ SETTLEMINT_BLOCKCHAIN_NODE_OR_LOAD_BALANCER_JSON_RPC_ENDPOINT?: string | undefined;
275
296
  SETTLEMINT_HASURA?: string | undefined;
276
297
  SETTLEMINT_HASURA_ENDPOINT?: string | undefined;
277
298
  SETTLEMINT_HASURA_ADMIN_SECRET?: string | undefined;
@@ -61,10 +61,16 @@ var DotEnvSchema = z4.object({
61
61
  SETTLEMINT_APPLICATION: UniqueNameSchema.optional(),
62
62
  /** Unique name of the blockchain network */
63
63
  SETTLEMINT_BLOCKCHAIN_NETWORK: UniqueNameSchema.optional(),
64
- /** Unique name of the blockchain node */
64
+ /** Chain ID of the blockchain network */
65
+ SETTLEMINT_BLOCKCHAIN_NETWORK_CHAIN_ID: z4.string().optional(),
66
+ /** Unique name of the blockchain node (should have a private key for signing transactions) */
65
67
  SETTLEMINT_BLOCKCHAIN_NODE: UniqueNameSchema.optional(),
66
- /** Unique name of the load balancer */
67
- SETTLEMINT_LOAD_BALANCER: UniqueNameSchema.optional(),
68
+ /** JSON RPC endpoint for the blockchain node */
69
+ SETTLEMINT_BLOCKCHAIN_NODE_JSON_RPC_ENDPOINT: UrlSchema.optional(),
70
+ /** Unique name of the blockchain node or load balancer */
71
+ SETTLEMINT_BLOCKCHAIN_NODE_OR_LOAD_BALANCER: UniqueNameSchema.optional(),
72
+ /** JSON RPC endpoint for the blockchain node or load balancer */
73
+ SETTLEMINT_BLOCKCHAIN_NODE_OR_LOAD_BALANCER_JSON_RPC_ENDPOINT: UrlSchema.optional(),
68
74
  /** Unique name of the Hasura instance */
69
75
  SETTLEMINT_HASURA: UniqueNameSchema.optional(),
70
76
  /** Endpoint URL for the Hasura GraphQL API */