@settlemint/sdk-utils 2.3.1 → 2.3.2

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.
@@ -79,14 +79,14 @@ var import_console_table_printer = require("console-table-printer");
79
79
  var import_yoctocolors7 = require("yoctocolors");
80
80
 
81
81
  // src/validation/validate.ts
82
- var import_zod = require("zod");
82
+ var import_v4 = require("zod/v4");
83
83
  function validate(schema, value) {
84
84
  try {
85
85
  return schema.parse(value);
86
86
  } catch (error) {
87
- if (error instanceof import_zod.ZodError) {
88
- const formattedErrors = error.errors.map((err) => `- ${err.path.join(".")}: ${err.message}`).join("\n");
89
- throw new Error(`Validation error${error.errors.length > 1 ? "s" : ""}:
87
+ if (error instanceof import_v4.ZodError) {
88
+ const formattedErrors = error.issues.map((err) => `- ${err.path.join(".")}: ${err.message}`).join("\n");
89
+ throw new Error(`Validation error${error.issues.length > 1 ? "s" : ""}:
90
90
  ${formattedErrors}`);
91
91
  }
92
92
  throw error;
@@ -94,10 +94,10 @@ ${formattedErrors}`);
94
94
  }
95
95
 
96
96
  // src/validation/access-token.schema.ts
97
- var import_zod2 = require("zod");
98
- var ApplicationAccessTokenSchema = import_zod2.z.string().regex(/^sm_aat_.*$/);
99
- var PersonalAccessTokenSchema = import_zod2.z.string().regex(/^sm_pat_.*$/);
100
- var AccessTokenSchema = import_zod2.z.string().regex(/^sm_pat_.*|sm_aat_.*$/);
97
+ var import_v42 = require("zod/v4");
98
+ var ApplicationAccessTokenSchema = import_v42.z.string().regex(/^sm_aat_.*$/);
99
+ var PersonalAccessTokenSchema = import_v42.z.string().regex(/^sm_pat_.*$/);
100
+ var AccessTokenSchema = import_v42.z.string().regex(/^sm_pat_.*|sm_aat_.*$/);
101
101
 
102
102
  // src/json.ts
103
103
  function tryParseJson(value, defaultValue = null) {
@@ -113,22 +113,22 @@ function tryParseJson(value, defaultValue = null) {
113
113
  }
114
114
 
115
115
  // src/validation/dot-env.schema.ts
116
- var import_zod5 = require("zod");
116
+ var import_v45 = require("zod/v4");
117
117
 
118
118
  // src/validation/unique-name.schema.ts
119
- var import_zod3 = require("zod");
120
- var UniqueNameSchema = import_zod3.z.string().regex(/^[a-z0-9-]+$/);
119
+ var import_v43 = require("zod/v4");
120
+ var UniqueNameSchema = import_v43.z.string().regex(/^[a-z0-9-]+$/);
121
121
 
122
122
  // src/validation/url.schema.ts
123
- var import_zod4 = require("zod");
124
- var UrlSchema = import_zod4.z.string().url();
125
- var UrlPathSchema = import_zod4.z.string().regex(/^\/(?:[a-zA-Z0-9-_]+(?:\/[a-zA-Z0-9-_]+)*\/?)?$/, {
123
+ var import_v44 = require("zod/v4");
124
+ var UrlSchema = import_v44.z.string().url();
125
+ var UrlPathSchema = import_v44.z.string().regex(/^\/(?:[a-zA-Z0-9-_]+(?:\/[a-zA-Z0-9-_]+)*\/?)?$/, {
126
126
  message: "Invalid URL path format. Must start with '/' and can contain letters, numbers, hyphens, and underscores."
127
127
  });
128
- var UrlOrPathSchema = import_zod4.z.union([UrlSchema, UrlPathSchema]);
128
+ var UrlOrPathSchema = import_v44.z.union([UrlSchema, UrlPathSchema]);
129
129
 
130
130
  // src/validation/dot-env.schema.ts
131
- var DotEnvSchema = import_zod5.z.object({
131
+ var DotEnvSchema = import_v45.z.object({
132
132
  /** Base URL of the SettleMint platform instance */
133
133
  SETTLEMINT_INSTANCE: UrlSchema.default("https://console.settlemint.com"),
134
134
  /** Application access token for authenticating with SettleMint services */
@@ -142,7 +142,7 @@ var DotEnvSchema = import_zod5.z.object({
142
142
  /** Unique name of the blockchain network */
143
143
  SETTLEMINT_BLOCKCHAIN_NETWORK: UniqueNameSchema.optional(),
144
144
  /** Chain ID of the blockchain network */
145
- SETTLEMINT_BLOCKCHAIN_NETWORK_CHAIN_ID: import_zod5.z.string().optional(),
145
+ SETTLEMINT_BLOCKCHAIN_NETWORK_CHAIN_ID: import_v45.z.string().optional(),
146
146
  /** Unique name of the blockchain node (should have a private key for signing transactions) */
147
147
  SETTLEMINT_BLOCKCHAIN_NODE: UniqueNameSchema.optional(),
148
148
  /** JSON RPC endpoint for the blockchain node */
@@ -156,18 +156,18 @@ var DotEnvSchema = import_zod5.z.object({
156
156
  /** Endpoint URL for the Hasura GraphQL API */
157
157
  SETTLEMINT_HASURA_ENDPOINT: UrlSchema.optional(),
158
158
  /** Admin secret for authenticating with Hasura */
159
- SETTLEMINT_HASURA_ADMIN_SECRET: import_zod5.z.string().optional(),
159
+ SETTLEMINT_HASURA_ADMIN_SECRET: import_v45.z.string().optional(),
160
160
  /** Database connection URL for Hasura */
161
- SETTLEMINT_HASURA_DATABASE_URL: import_zod5.z.string().optional(),
161
+ SETTLEMINT_HASURA_DATABASE_URL: import_v45.z.string().optional(),
162
162
  /** Unique name of The Graph instance */
163
163
  SETTLEMINT_THEGRAPH: UniqueNameSchema.optional(),
164
164
  /** Array of endpoint URLs for The Graph subgraphs */
165
- SETTLEMINT_THEGRAPH_SUBGRAPHS_ENDPOINTS: import_zod5.z.preprocess(
165
+ SETTLEMINT_THEGRAPH_SUBGRAPHS_ENDPOINTS: import_v45.z.preprocess(
166
166
  (value) => tryParseJson(value, []),
167
- import_zod5.z.array(UrlSchema).optional()
167
+ import_v45.z.array(UrlSchema).optional()
168
168
  ),
169
169
  /** Default The Graph subgraph to use */
170
- SETTLEMINT_THEGRAPH_DEFAULT_SUBGRAPH: import_zod5.z.string().optional(),
170
+ SETTLEMINT_THEGRAPH_DEFAULT_SUBGRAPH: import_v45.z.string().optional(),
171
171
  /** Unique name of the Smart Contract Portal instance */
172
172
  SETTLEMINT_PORTAL: UniqueNameSchema.optional(),
173
173
  /** GraphQL endpoint URL for the Portal */
@@ -179,7 +179,7 @@ var DotEnvSchema = import_zod5.z.object({
179
179
  /** Unique name of the HD private key */
180
180
  SETTLEMINT_HD_PRIVATE_KEY: UniqueNameSchema.optional(),
181
181
  /** Address of the HD private key forwarder */
182
- SETTLEMINT_HD_PRIVATE_KEY_FORWARDER_ADDRESS: import_zod5.z.string().optional(),
182
+ SETTLEMINT_HD_PRIVATE_KEY_FORWARDER_ADDRESS: import_v45.z.string().optional(),
183
183
  /** Unique name of the accessible private key */
184
184
  SETTLEMINT_ACCESSIBLE_PRIVATE_KEY: UniqueNameSchema.optional(),
185
185
  /** Unique name of the MinIO instance */
@@ -187,9 +187,9 @@ var DotEnvSchema = import_zod5.z.object({
187
187
  /** Endpoint URL for MinIO */
188
188
  SETTLEMINT_MINIO_ENDPOINT: UrlSchema.optional(),
189
189
  /** Access key for MinIO authentication */
190
- SETTLEMINT_MINIO_ACCESS_KEY: import_zod5.z.string().optional(),
190
+ SETTLEMINT_MINIO_ACCESS_KEY: import_v45.z.string().optional(),
191
191
  /** Secret key for MinIO authentication */
192
- SETTLEMINT_MINIO_SECRET_KEY: import_zod5.z.string().optional(),
192
+ SETTLEMINT_MINIO_SECRET_KEY: import_v45.z.string().optional(),
193
193
  /** Unique name of the IPFS instance */
194
194
  SETTLEMINT_IPFS: UniqueNameSchema.optional(),
195
195
  /** API endpoint URL for IPFS */
@@ -209,18 +209,18 @@ var DotEnvSchema = import_zod5.z.object({
209
209
  /** UI endpoint URL for Blockscout */
210
210
  SETTLEMINT_BLOCKSCOUT_UI_ENDPOINT: UrlSchema.optional(),
211
211
  /** Name of the new project being created */
212
- SETTLEMINT_NEW_PROJECT_NAME: import_zod5.z.string().optional(),
212
+ SETTLEMINT_NEW_PROJECT_NAME: import_v45.z.string().optional(),
213
213
  /** The log level to use */
214
- SETTLEMINT_LOG_LEVEL: import_zod5.z.enum(["debug", "info", "warn", "error", "none"]).default("warn")
214
+ SETTLEMINT_LOG_LEVEL: import_v45.z.enum(["debug", "info", "warn", "error", "none"]).default("warn")
215
215
  });
216
216
  var DotEnvSchemaPartial = DotEnvSchema.partial();
217
217
 
218
218
  // src/validation/id.schema.ts
219
- var import_zod6 = require("zod");
220
- var IdSchema = import_zod6.z.union([
221
- import_zod6.z.string().uuid(),
219
+ var import_v46 = require("zod/v4");
220
+ var IdSchema = import_v46.z.union([
221
+ import_v46.z.string().uuid(),
222
222
  // PostgreSQL UUID
223
- import_zod6.z.string().regex(/^[0-9a-fA-F]{24}$/)
223
+ import_v46.z.string().regex(/^[0-9a-fA-F]{24}$/)
224
224
  // MongoDB ObjectID
225
225
  ]);
226
226
 
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/environment.ts","../src/environment/load-env.ts","../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/outro.ts","../src/terminal/spinner.ts","../src/terminal/table.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","../src/environment/write-env.ts","../src/filesystem/project-root.ts","../src/filesystem/exists.ts","../src/filesystem/mono-repo.ts"],"sourcesContent":["export { loadEnv } from \"./environment/load-env.js\";\nexport { writeEnv } from \"./environment/write-env.js\";\n","import { join } from \"node:path\";\nimport { cancel } from \"@/terminal.js\";\nimport { type DotEnv, type DotEnvPartial, DotEnvSchema, DotEnvSchemaPartial, validate } from \"@/validation.js\";\nimport { config } from \"@dotenvx/dotenvx\";\n\n/**\n * Loads environment variables from .env files.\n * To enable encryption with dotenvx (https://www.dotenvx.com/docs) run `bunx dotenvx encrypt`\n *\n * @param validateEnv - Whether to validate the environment variables against the schema\n * @param prod - Whether to load production environment variables\n * @param path - Optional path to the directory containing .env files. Defaults to process.cwd()\n * @returns A promise that resolves to the validated environment variables\n * @throws Will throw an error if validation fails and validateEnv is true\n * @example\n * import { loadEnv } from '@settlemint/sdk-utils/environment';\n *\n * // Load and validate environment variables\n * const env = await loadEnv(true, false);\n * console.log(env.SETTLEMINT_INSTANCE);\n *\n * // Load without validation\n * const rawEnv = await loadEnv(false, false);\n */\nexport async function loadEnv<T extends boolean = true>(\n validateEnv: T,\n prod: boolean,\n path: string = process.cwd(),\n): Promise<T extends true ? DotEnv : DotEnvPartial> {\n return loadEnvironmentEnv(validateEnv, !!prod, path);\n}\n\nasync function loadEnvironmentEnv<T extends boolean = true>(\n validateEnv: T,\n prod: boolean,\n path: string = process.cwd(),\n): Promise<T extends true ? DotEnv : DotEnvPartial> {\n if (prod) {\n process.env.NODE_ENV = \"production\";\n }\n let { parsed } = config({\n convention: \"nextjs\",\n logLevel: \"error\",\n overload: true,\n quiet: true,\n path: [join(path, \".env\"), join(path, \".env.local\")],\n });\n\n if (!parsed) {\n parsed = {};\n }\n const defaultEnv = Object.fromEntries(\n Object.entries(process.env).filter(([_, value]) => typeof value === \"string\" && value !== \"\"),\n ) as Record<string, string>;\n try {\n return validate(validateEnv ? DotEnvSchema : DotEnvSchemaPartial, {\n ...parsed,\n ...defaultEnv,\n }) as T extends true ? DotEnv : DotEnvPartial;\n } catch (error) {\n cancel((error as Error).message);\n return {} as T extends true ? DotEnv : DotEnvPartial;\n }\n}\n","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 * 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 { silent, ...spawnOptions } = options ?? {};\n const child = spawn(command, args, { ...spawnOptions, 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 (!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 (!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 { 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","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","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\n/**\n * Converts a value to a JSON stringifiable format.\n *\n * @param value - The value to convert\n * @returns The JSON stringifiable value\n *\n * @example\n * import { makeJsonStringifiable } from \"@settlemint/sdk-utils\";\n *\n * const json = makeJsonStringifiable<{ amount: bigint }>({ amount: BigInt(1000) });\n * // Returns: '{\"amount\":\"1000\"}'\n */\nexport function makeJsonStringifiable<T>(value: unknown): T {\n if (value === undefined || value === null) {\n return value as T;\n }\n return tryParseJson<T>(\n JSON.stringify(\n value,\n (_, value) => (typeof value === \"bigint\" ? value.toString() : value), // return everything else unchanged\n ),\n ) as T;\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 /** WebSocket endpoint URL for the Portal */\n SETTLEMINT_PORTAL_WS_ENDPOINT: UrlSchema.optional(),\n /** Unique name of the HD private key */\n SETTLEMINT_HD_PRIVATE_KEY: UniqueNameSchema.optional(),\n /** Address of the HD private key forwarder */\n SETTLEMINT_HD_PRIVATE_KEY_FORWARDER_ADDRESS: z.string().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","import { writeFile } from \"node:fs/promises\";\nimport { join } from \"node:path\";\nimport { exists, projectRoot } from \"@/filesystem.js\";\nimport type { DotEnv } from \"@/validation.js\";\nimport { DotEnvSchema } from \"@/validation/dot-env.schema.js\";\nimport { config } from \"@dotenvx/dotenvx\";\nimport { deepmerge } from \"deepmerge-ts\";\nimport { findMonoRepoPackages } from \"../filesystem/mono-repo.js\";\n\n/**\n * Writes environment variables to .env files across a project or monorepo\n *\n * @param options - The options for writing the environment variables\n * @param options.prod - Whether to write production environment variables\n * @param options.env - The environment variables to write\n * @param options.secrets - Whether to write to .env.local files for secrets\n * @param options.cwd - The directory to start searching for the package.json file from (defaults to process.cwd())\n * @returns Promise that resolves when writing is complete\n * @throws Will throw an error if writing fails\n * @example\n * import { writeEnv } from '@settlemint/sdk-utils/environment';\n *\n * // Write development environment variables\n * await writeEnv({\n * prod: false,\n * env: {\n * SETTLEMINT_INSTANCE: 'https://dev.example.com'\n * },\n * secrets: false\n * });\n *\n * // Write production secrets\n * await writeEnv({\n * prod: true,\n * env: {\n * SETTLEMINT_ACCESS_TOKEN: 'secret-token'\n * },\n * secrets: true\n * });\n */\nexport async function writeEnv({\n prod,\n env,\n secrets,\n cwd,\n}: {\n prod: boolean;\n env: Partial<DotEnv>;\n secrets: boolean;\n cwd?: string;\n}): Promise<void> {\n const projectDir = await projectRoot(true, cwd);\n\n if (prod) {\n process.env.NODE_ENV = \"production\";\n }\n\n const targetDirs = await findMonoRepoPackages(projectDir);\n\n await Promise.all(\n targetDirs.map(async (dir) => {\n const envFile = join(\n dir,\n secrets ? `.env${prod ? \".production\" : \"\"}.local` : `.env${prod ? \".production\" : \"\"}`,\n );\n\n let { parsed: currentEnv } = (await exists(envFile))\n ? config({\n path: envFile,\n logLevel: \"error\",\n quiet: true,\n })\n : { parsed: {} };\n\n if (!currentEnv) {\n currentEnv = {};\n }\n\n const prunedEnv = pruneCurrentEnv(currentEnv, env);\n const mergedEnv = deepmerge(prunedEnv, env as Record<string, unknown>);\n await writeFile(envFile, stringify(mergedEnv));\n }),\n );\n}\n\nconst quote = /[\\s\"'#]/;\n\nfunction stringifyPair([key, val]: [string, unknown]): string | undefined {\n if (val === undefined) {\n return undefined;\n }\n if (val === null) {\n return `${key}=\"\"`;\n }\n\n const type = typeof val;\n if (type === \"string\") {\n return `${key}=${quote.test(val as string) ? JSON.stringify(val) : val}`;\n }\n if (type === \"boolean\" || type === \"number\") {\n return `${key}=${val}`;\n }\n if (type === \"object\") {\n return `${key}=${JSON.stringify(val)}`;\n }\n\n throw new Error(`Unsupported type for key \"${key}\": ${type}`);\n}\n\nfunction stringify(obj: Record<string, unknown>): string {\n return Object.entries(obj)\n .sort(([a], [b]) => a.localeCompare(b))\n .map(stringifyPair)\n .filter((value) => value !== undefined)\n .join(\"\\n\");\n}\n\n/**\n * Prunes the current environment variables from the new environment variables\n *\n * @param currentEnv - The current environment variables\n * @param env - The new environment variables\n * @returns The new environment variables with the current environment variables removed\n */\nfunction pruneCurrentEnv(currentEnv: Record<string, unknown>, env: Partial<DotEnv>): Record<string, unknown> {\n const dotEnvKeys = Object.keys(DotEnvSchema.shape);\n return Object.fromEntries(\n Object.entries(currentEnv).filter(([key]) => {\n if (dotEnvKeys.includes(key) && !env[key as keyof typeof env]) {\n return false;\n }\n return true;\n }),\n );\n}\n","import { dirname } from \"node:path\";\nimport { findUp } from \"find-up\";\n\n/**\n * Finds the root directory of the current project by locating the nearest package.json file\n *\n * @param fallbackToCwd - If true, will return the current working directory if no package.json is found\n * @param cwd - The directory to start searching for the package.json file from (defaults to process.cwd())\n * @returns Promise that resolves to the absolute path of the project root directory\n * @throws Will throw an error if no package.json is found in the directory tree\n * @example\n * import { projectRoot } from \"@settlemint/sdk-utils/filesystem\";\n *\n * // Get project root path\n * const rootDir = await projectRoot();\n * console.log(`Project root is at: ${rootDir}`);\n */\nexport async function projectRoot(fallbackToCwd = false, cwd?: string): Promise<string> {\n const packageJsonPath = await findUp(\"package.json\", { cwd });\n if (!packageJsonPath) {\n if (fallbackToCwd) {\n return process.cwd();\n }\n throw new Error(\"Unable to find project root (no package.json found)\");\n }\n return dirname(packageJsonPath);\n}\n","import type { PathLike } from \"node:fs\";\nimport { stat } from \"node:fs/promises\";\n\n/**\n * Checks if a file or directory exists at the given path\n *\n * @param path - The file system path to check for existence\n * @returns Promise that resolves to true if the path exists, false otherwise\n * @example\n * import { exists } from \"@settlemint/sdk-utils/filesystem\";\n *\n * // Check if file exists before reading\n * if (await exists('/path/to/file.txt')) {\n * // File exists, safe to read\n * }\n */\nexport async function exists(path: PathLike): Promise<boolean> {\n try {\n await stat(path);\n return true;\n } catch {\n return false;\n }\n}\n","import { readFile } from \"node:fs/promises\";\nimport { dirname, join } from \"node:path\";\nimport { exists } from \"@/filesystem.js\";\nimport { tryParseJson } from \"@/json.js\";\nimport { findUp } from \"find-up\";\nimport { glob } from \"glob\";\n\n/**\n * Finds the root directory of a monorepo\n *\n * @param startDir - The directory to start searching from\n * @returns The root directory of the monorepo or null if not found\n * @example\n * import { findMonoRepoRoot } from \"@settlemint/sdk-utils/filesystem\";\n *\n * const root = await findMonoRepoRoot(\"/path/to/your/project\");\n * console.log(root); // Output: /path/to/your/project/packages/core\n */\nexport async function findMonoRepoRoot(startDir: string): Promise<string | null> {\n const lockFilePath = await findUp([\"package-lock.json\", \"yarn.lock\", \"pnpm-lock.yaml\", \"bun.lockb\", \"bun.lock\"], {\n cwd: startDir,\n });\n if (lockFilePath) {\n const packageJsonPath = join(dirname(lockFilePath), \"package.json\");\n const hasWorkSpaces = await packageJsonHasWorkspaces(packageJsonPath);\n return hasWorkSpaces ? dirname(lockFilePath) : null;\n }\n\n let currentDir = startDir;\n\n while (currentDir !== \"/\") {\n const packageJsonPath = join(currentDir, \"package.json\");\n\n if (await packageJsonHasWorkspaces(packageJsonPath)) {\n return currentDir;\n }\n\n const parentDir = dirname(currentDir);\n if (parentDir === currentDir) {\n break; // We've reached the root\n }\n currentDir = parentDir;\n }\n\n return null;\n}\n\n/**\n * Finds all packages in a monorepo\n *\n * @param projectDir - The directory to start searching from\n * @returns An array of package directories\n * @example\n * import { findMonoRepoPackages } from \"@settlemint/sdk-utils/filesystem\";\n *\n * const packages = await findMonoRepoPackages(\"/path/to/your/project\");\n * console.log(packages); // Output: [\"/path/to/your/project/packages/core\", \"/path/to/your/project/packages/ui\"]\n */\nexport async function findMonoRepoPackages(projectDir: string): Promise<string[]> {\n try {\n const monoRepoRoot = await findMonoRepoRoot(projectDir);\n if (!monoRepoRoot) {\n return [projectDir];\n }\n\n const packageJsonPath = join(monoRepoRoot, \"package.json\");\n const packageJson = tryParseJson<{ workspaces: string[] }>(await readFile(packageJsonPath, \"utf-8\"));\n const workspaces = packageJson?.workspaces ?? [];\n\n const packagePaths = await Promise.all(\n workspaces.map(async (workspace: string) => {\n const matches = await glob(join(monoRepoRoot, workspace, \"package.json\"));\n return matches.map((match) => join(match, \"..\"));\n }),\n );\n\n const allPaths = packagePaths.flat();\n // If no packages found in workspaces, treat as non-monorepo\n return allPaths.length === 0 ? [projectDir] : [monoRepoRoot, ...allPaths];\n } catch (error) {\n // If any error occurs, treat as non-monorepo\n return [projectDir];\n }\n}\n\nasync function packageJsonHasWorkspaces(packageJsonPath: string): Promise<boolean> {\n if (await exists(packageJsonPath)) {\n const packageJson = tryParseJson<{ workspaces: string[] }>(await readFile(packageJsonPath, \"utf-8\"));\n if (packageJson?.workspaces && Array.isArray(packageJson?.workspaces) && packageJson?.workspaces.length > 0) {\n return true;\n }\n }\n return false;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,uBAAqB;;;ACArB,yBAA8B;;;ACYvB,IAAM,aAAa,CAAC,WAA2B;AACpD,SAAO,OAAO,QAAQ,kCAAkC,KAAK;AAC/D;;;ACbA,IAAAA,sBAAmC;AAM5B,IAAM,cAAN,cAA0B,MAAM;AAAC;AAejC,IAAM,SAAS,CAAC,QAAuB;AAC5C,UAAQ,IAAI,EAAE;AACd,UAAQ,QAAI,iCAAQ,+BAAU,WAAW,GAAG,CAAC,CAAC,CAAC;AAC/C,UAAQ,IAAI,EAAE;AACd,QAAM,IAAI,YAAY,GAAG;AAC3B;;;AC3BA,gCAAqD;;;ACCrD,IAAAC,sBAA8B;;;ACA9B,IAAAC,sBAA6B;;;ACC7B,IAAAC,sBAAqC;;;ACFrC,sBAAmB;AACnB,2BAA2C;AAC3C,IAAAC,sBAA0B;;;ACD1B,mCAAsB;AACtB,IAAAC,sBAA4B;;;ACF5B,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,EAAE;AAAA,IAC9F;AACA,UAAM;AAAA,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AA,IACZ,OAAO,QAAQ,UAAU,EAAE,OAAO,CAAC,CAAC,GAAG,MAAM;AAC3C,UAAI,WAAW,SAAS,GAAG,KAAK,CAAC,IAAI,GAAuB,GAAG;AAC7D,eAAO;AAAA,MACT;AACA,aAAO;AAAA,IACT,CAAC;AAAA,EACH;AACF;","names":["import_yoctocolors","import_yoctocolors","import_yoctocolors","import_yoctocolors","import_yoctocolors","import_yoctocolors","import_zod","import_zod","import_zod","import_zod","import_zod","import_promises","import_node_path","import_node_path","import_promises","import_node_path","import_find_up","import_dotenvx"]}
1
+ {"version":3,"sources":["../src/environment.ts","../src/environment/load-env.ts","../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/outro.ts","../src/terminal/spinner.ts","../src/terminal/table.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","../src/environment/write-env.ts","../src/filesystem/project-root.ts","../src/filesystem/exists.ts","../src/filesystem/mono-repo.ts"],"sourcesContent":["export { loadEnv } from \"./environment/load-env.js\";\nexport { writeEnv } from \"./environment/write-env.js\";\n","import { join } from \"node:path\";\nimport { cancel } from \"@/terminal.js\";\nimport { type DotEnv, type DotEnvPartial, DotEnvSchema, DotEnvSchemaPartial, validate } from \"@/validation.js\";\nimport { config } from \"@dotenvx/dotenvx\";\n\n/**\n * Loads environment variables from .env files.\n * To enable encryption with dotenvx (https://www.dotenvx.com/docs) run `bunx dotenvx encrypt`\n *\n * @param validateEnv - Whether to validate the environment variables against the schema\n * @param prod - Whether to load production environment variables\n * @param path - Optional path to the directory containing .env files. Defaults to process.cwd()\n * @returns A promise that resolves to the validated environment variables\n * @throws Will throw an error if validation fails and validateEnv is true\n * @example\n * import { loadEnv } from '@settlemint/sdk-utils/environment';\n *\n * // Load and validate environment variables\n * const env = await loadEnv(true, false);\n * console.log(env.SETTLEMINT_INSTANCE);\n *\n * // Load without validation\n * const rawEnv = await loadEnv(false, false);\n */\nexport async function loadEnv<T extends boolean = true>(\n validateEnv: T,\n prod: boolean,\n path: string = process.cwd(),\n): Promise<T extends true ? DotEnv : DotEnvPartial> {\n return loadEnvironmentEnv(validateEnv, !!prod, path);\n}\n\nasync function loadEnvironmentEnv<T extends boolean = true>(\n validateEnv: T,\n prod: boolean,\n path: string = process.cwd(),\n): Promise<T extends true ? DotEnv : DotEnvPartial> {\n if (prod) {\n process.env.NODE_ENV = \"production\";\n }\n let { parsed } = config({\n convention: \"nextjs\",\n logLevel: \"error\",\n overload: true,\n quiet: true,\n path: [join(path, \".env\"), join(path, \".env.local\")],\n });\n\n if (!parsed) {\n parsed = {};\n }\n const defaultEnv = Object.fromEntries(\n Object.entries(process.env).filter(([_, value]) => typeof value === \"string\" && value !== \"\"),\n ) as Record<string, string>;\n try {\n return validate(validateEnv ? DotEnvSchema : DotEnvSchemaPartial, {\n ...parsed,\n ...defaultEnv,\n }) as T extends true ? DotEnv : DotEnvPartial;\n } catch (error) {\n cancel((error as Error).message);\n return {} as T extends true ? DotEnv : DotEnvPartial;\n }\n}\n","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 * 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 { silent, ...spawnOptions } = options ?? {};\n const child = spawn(command, args, { ...spawnOptions, 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 (!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 (!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 { 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","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","import { ZodError, type ZodType } from \"zod/v4\";\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 ZodType>(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.issues.map((err) => `- ${err.path.join(\".\")}: ${err.message}`).join(\"\\n\");\n throw new Error(`Validation error${error.issues.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/v4\";\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\n/**\n * Converts a value to a JSON stringifiable format.\n *\n * @param value - The value to convert\n * @returns The JSON stringifiable value\n *\n * @example\n * import { makeJsonStringifiable } from \"@settlemint/sdk-utils\";\n *\n * const json = makeJsonStringifiable<{ amount: bigint }>({ amount: BigInt(1000) });\n * // Returns: '{\"amount\":\"1000\"}'\n */\nexport function makeJsonStringifiable<T>(value: unknown): T {\n if (value === undefined || value === null) {\n return value as T;\n }\n return tryParseJson<T>(\n JSON.stringify(\n value,\n (_, value) => (typeof value === \"bigint\" ? value.toString() : value), // return everything else unchanged\n ),\n ) as T;\n}\n","import { tryParseJson } from \"@/json.js\";\nimport { z } from \"zod/v4\";\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 /** WebSocket endpoint URL for the Portal */\n SETTLEMINT_PORTAL_WS_ENDPOINT: UrlSchema.optional(),\n /** Unique name of the HD private key */\n SETTLEMINT_HD_PRIVATE_KEY: UniqueNameSchema.optional(),\n /** Address of the HD private key forwarder */\n SETTLEMINT_HD_PRIVATE_KEY_FORWARDER_ADDRESS: z.string().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/v4\";\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/v4\";\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/v4\";\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","import { writeFile } from \"node:fs/promises\";\nimport { join } from \"node:path\";\nimport { exists, projectRoot } from \"@/filesystem.js\";\nimport type { DotEnv } from \"@/validation.js\";\nimport { DotEnvSchema } from \"@/validation/dot-env.schema.js\";\nimport { config } from \"@dotenvx/dotenvx\";\nimport { deepmerge } from \"deepmerge-ts\";\nimport { findMonoRepoPackages } from \"../filesystem/mono-repo.js\";\n\n/**\n * Writes environment variables to .env files across a project or monorepo\n *\n * @param options - The options for writing the environment variables\n * @param options.prod - Whether to write production environment variables\n * @param options.env - The environment variables to write\n * @param options.secrets - Whether to write to .env.local files for secrets\n * @param options.cwd - The directory to start searching for the package.json file from (defaults to process.cwd())\n * @returns Promise that resolves when writing is complete\n * @throws Will throw an error if writing fails\n * @example\n * import { writeEnv } from '@settlemint/sdk-utils/environment';\n *\n * // Write development environment variables\n * await writeEnv({\n * prod: false,\n * env: {\n * SETTLEMINT_INSTANCE: 'https://dev.example.com'\n * },\n * secrets: false\n * });\n *\n * // Write production secrets\n * await writeEnv({\n * prod: true,\n * env: {\n * SETTLEMINT_ACCESS_TOKEN: 'secret-token'\n * },\n * secrets: true\n * });\n */\nexport async function writeEnv({\n prod,\n env,\n secrets,\n cwd,\n}: {\n prod: boolean;\n env: Partial<DotEnv>;\n secrets: boolean;\n cwd?: string;\n}): Promise<void> {\n const projectDir = await projectRoot(true, cwd);\n\n if (prod) {\n process.env.NODE_ENV = \"production\";\n }\n\n const targetDirs = await findMonoRepoPackages(projectDir);\n\n await Promise.all(\n targetDirs.map(async (dir) => {\n const envFile = join(\n dir,\n secrets ? `.env${prod ? \".production\" : \"\"}.local` : `.env${prod ? \".production\" : \"\"}`,\n );\n\n let { parsed: currentEnv } = (await exists(envFile))\n ? config({\n path: envFile,\n logLevel: \"error\",\n quiet: true,\n })\n : { parsed: {} };\n\n if (!currentEnv) {\n currentEnv = {};\n }\n\n const prunedEnv = pruneCurrentEnv(currentEnv, env);\n const mergedEnv = deepmerge(prunedEnv, env as Record<string, unknown>);\n await writeFile(envFile, stringify(mergedEnv));\n }),\n );\n}\n\nconst quote = /[\\s\"'#]/;\n\nfunction stringifyPair([key, val]: [string, unknown]): string | undefined {\n if (val === undefined) {\n return undefined;\n }\n if (val === null) {\n return `${key}=\"\"`;\n }\n\n const type = typeof val;\n if (type === \"string\") {\n return `${key}=${quote.test(val as string) ? JSON.stringify(val) : val}`;\n }\n if (type === \"boolean\" || type === \"number\") {\n return `${key}=${val}`;\n }\n if (type === \"object\") {\n return `${key}=${JSON.stringify(val)}`;\n }\n\n throw new Error(`Unsupported type for key \"${key}\": ${type}`);\n}\n\nfunction stringify(obj: Record<string, unknown>): string {\n return Object.entries(obj)\n .sort(([a], [b]) => a.localeCompare(b))\n .map(stringifyPair)\n .filter((value) => value !== undefined)\n .join(\"\\n\");\n}\n\n/**\n * Prunes the current environment variables from the new environment variables\n *\n * @param currentEnv - The current environment variables\n * @param env - The new environment variables\n * @returns The new environment variables with the current environment variables removed\n */\nfunction pruneCurrentEnv(currentEnv: Record<string, unknown>, env: Partial<DotEnv>): Record<string, unknown> {\n const dotEnvKeys = Object.keys(DotEnvSchema.shape);\n return Object.fromEntries(\n Object.entries(currentEnv).filter(([key]) => {\n if (dotEnvKeys.includes(key) && !env[key as keyof typeof env]) {\n return false;\n }\n return true;\n }),\n );\n}\n","import { dirname } from \"node:path\";\nimport { findUp } from \"find-up\";\n\n/**\n * Finds the root directory of the current project by locating the nearest package.json file\n *\n * @param fallbackToCwd - If true, will return the current working directory if no package.json is found\n * @param cwd - The directory to start searching for the package.json file from (defaults to process.cwd())\n * @returns Promise that resolves to the absolute path of the project root directory\n * @throws Will throw an error if no package.json is found in the directory tree\n * @example\n * import { projectRoot } from \"@settlemint/sdk-utils/filesystem\";\n *\n * // Get project root path\n * const rootDir = await projectRoot();\n * console.log(`Project root is at: ${rootDir}`);\n */\nexport async function projectRoot(fallbackToCwd = false, cwd?: string): Promise<string> {\n const packageJsonPath = await findUp(\"package.json\", { cwd });\n if (!packageJsonPath) {\n if (fallbackToCwd) {\n return process.cwd();\n }\n throw new Error(\"Unable to find project root (no package.json found)\");\n }\n return dirname(packageJsonPath);\n}\n","import type { PathLike } from \"node:fs\";\nimport { stat } from \"node:fs/promises\";\n\n/**\n * Checks if a file or directory exists at the given path\n *\n * @param path - The file system path to check for existence\n * @returns Promise that resolves to true if the path exists, false otherwise\n * @example\n * import { exists } from \"@settlemint/sdk-utils/filesystem\";\n *\n * // Check if file exists before reading\n * if (await exists('/path/to/file.txt')) {\n * // File exists, safe to read\n * }\n */\nexport async function exists(path: PathLike): Promise<boolean> {\n try {\n await stat(path);\n return true;\n } catch {\n return false;\n }\n}\n","import { readFile } from \"node:fs/promises\";\nimport { dirname, join } from \"node:path\";\nimport { exists } from \"@/filesystem.js\";\nimport { tryParseJson } from \"@/json.js\";\nimport { findUp } from \"find-up\";\nimport { glob } from \"glob\";\n\n/**\n * Finds the root directory of a monorepo\n *\n * @param startDir - The directory to start searching from\n * @returns The root directory of the monorepo or null if not found\n * @example\n * import { findMonoRepoRoot } from \"@settlemint/sdk-utils/filesystem\";\n *\n * const root = await findMonoRepoRoot(\"/path/to/your/project\");\n * console.log(root); // Output: /path/to/your/project/packages/core\n */\nexport async function findMonoRepoRoot(startDir: string): Promise<string | null> {\n const lockFilePath = await findUp([\"package-lock.json\", \"yarn.lock\", \"pnpm-lock.yaml\", \"bun.lockb\", \"bun.lock\"], {\n cwd: startDir,\n });\n if (lockFilePath) {\n const packageJsonPath = join(dirname(lockFilePath), \"package.json\");\n const hasWorkSpaces = await packageJsonHasWorkspaces(packageJsonPath);\n return hasWorkSpaces ? dirname(lockFilePath) : null;\n }\n\n let currentDir = startDir;\n\n while (currentDir !== \"/\") {\n const packageJsonPath = join(currentDir, \"package.json\");\n\n if (await packageJsonHasWorkspaces(packageJsonPath)) {\n return currentDir;\n }\n\n const parentDir = dirname(currentDir);\n if (parentDir === currentDir) {\n break; // We've reached the root\n }\n currentDir = parentDir;\n }\n\n return null;\n}\n\n/**\n * Finds all packages in a monorepo\n *\n * @param projectDir - The directory to start searching from\n * @returns An array of package directories\n * @example\n * import { findMonoRepoPackages } from \"@settlemint/sdk-utils/filesystem\";\n *\n * const packages = await findMonoRepoPackages(\"/path/to/your/project\");\n * console.log(packages); // Output: [\"/path/to/your/project/packages/core\", \"/path/to/your/project/packages/ui\"]\n */\nexport async function findMonoRepoPackages(projectDir: string): Promise<string[]> {\n try {\n const monoRepoRoot = await findMonoRepoRoot(projectDir);\n if (!monoRepoRoot) {\n return [projectDir];\n }\n\n const packageJsonPath = join(monoRepoRoot, \"package.json\");\n const packageJson = tryParseJson<{ workspaces: string[] }>(await readFile(packageJsonPath, \"utf-8\"));\n const workspaces = packageJson?.workspaces ?? [];\n\n const packagePaths = await Promise.all(\n workspaces.map(async (workspace: string) => {\n const matches = await glob(join(monoRepoRoot, workspace, \"package.json\"));\n return matches.map((match) => join(match, \"..\"));\n }),\n );\n\n const allPaths = packagePaths.flat();\n // If no packages found in workspaces, treat as non-monorepo\n return allPaths.length === 0 ? [projectDir] : [monoRepoRoot, ...allPaths];\n } catch (error) {\n // If any error occurs, treat as non-monorepo\n return [projectDir];\n }\n}\n\nasync function packageJsonHasWorkspaces(packageJsonPath: string): Promise<boolean> {\n if (await exists(packageJsonPath)) {\n const packageJson = tryParseJson<{ workspaces: string[] }>(await readFile(packageJsonPath, \"utf-8\"));\n if (packageJson?.workspaces && Array.isArray(packageJson?.workspaces) && packageJson?.workspaces.length > 0) {\n return true;\n }\n }\n return false;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,uBAAqB;;;ACArB,yBAA8B;;;ACYvB,IAAM,aAAa,CAAC,WAA2B;AACpD,SAAO,OAAO,QAAQ,kCAAkC,KAAK;AAC/D;;;ACbA,IAAAA,sBAAmC;AAM5B,IAAM,cAAN,cAA0B,MAAM;AAAC;AAejC,IAAM,SAAS,CAAC,QAAuB;AAC5C,UAAQ,IAAI,EAAE;AACd,UAAQ,QAAI,iCAAQ,+BAAU,WAAW,GAAG,CAAC,CAAC,CAAC;AAC/C,UAAQ,IAAI,EAAE;AACd,QAAM,IAAI,YAAY,GAAG;AAC3B;;;AC3BA,gCAAqD;;;ACCrD,IAAAC,sBAA8B;;;ACA9B,IAAAC,sBAA6B;;;ACC7B,IAAAC,sBAAqC;;;ACFrC,sBAAmB;AACnB,2BAA2C;AAC3C,IAAAC,sBAA0B;;;ACD1B,mCAAsB;AACtB,IAAAC,sBAA4B;;;ACF5B,gBAAuC;AAehC,SAAS,SAA4B,QAAW,OAA8B;AACnF,MAAI;AACF,WAAO,OAAO,MAAM,KAAK;AAAA,EAC3B,SAAS,OAAO;AACd,QAAI,iBAAiB,oBAAU;AAC7B,YAAM,kBAAkB,MAAM,OAAO,IAAI,CAAC,QAAQ,KAAK,IAAI,KAAK,KAAK,GAAG,C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,IAAI,aAAa,EACjB,OAAO,CAAC,UAAU,UAAU,MAAS,EACrC,KAAK,IAAI;AACd;AASA,SAAS,gBAAgB,YAAqC,KAA+C;AAC3G,QAAM,aAAa,OAAO,KAAK,aAAa,KAAK;AACjD,SAAO,OAAO;AAAA,IACZ,OAAO,QAAQ,UAAU,EAAE,OAAO,CAAC,CAAC,GAAG,MAAM;AAC3C,UAAI,WAAW,SAAS,GAAG,KAAK,CAAC,IAAI,GAAuB,GAAG;AAC7D,eAAO;AAAA,MACT;AACA,aAAO;AAAA,IACT,CAAC;AAAA,EACH;AACF;","names":["import_yoctocolors","import_yoctocolors","import_yoctocolors","import_yoctocolors","import_yoctocolors","import_yoctocolors","import_v4","import_v4","import_v4","import_v4","import_v4","import_promises","import_node_path","import_node_path","import_promises","import_node_path","import_find_up","import_dotenvx"]}