@settlemint/sdk-utils 2.3.2-pr708c218f → 2.3.2-pr74f654b5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +51 -7
- package/dist/environment.cjs +25 -409
- package/dist/environment.d.cts +3 -176
- package/dist/environment.d.ts +3 -176
- package/dist/environment.js +4 -0
- package/dist/filesystem.cjs +39 -123
- package/dist/filesystem.d.cts +4 -59
- package/dist/filesystem.d.ts +4 -59
- package/dist/filesystem.js +5 -0
- package/dist/http.cjs +34 -98
- package/dist/http.d.cts +4 -55
- package/dist/http.d.ts +4 -55
- package/dist/http.js +5 -0
- package/dist/index.cjs +27 -118
- package/dist/index.d.cts +4 -122
- package/dist/index.d.ts +4 -122
- package/dist/index.js +7 -0
- package/dist/json.cjs +83 -0
- package/dist/json.cjs.map +1 -0
- package/dist/json.d.cts +56 -0
- package/dist/json.d.ts +56 -0
- package/dist/json.js +80 -0
- package/dist/json.js.map +1 -0
- package/dist/logging.cjs +34 -141
- package/dist/logging.d.cts +4 -70
- package/dist/logging.d.ts +4 -70
- package/dist/logging.js +5 -0
- package/dist/package-manager.cjs +51 -196
- package/dist/package-manager.d.cts +7 -114
- package/dist/package-manager.d.ts +7 -114
- package/dist/package-manager.js +9 -0
- package/dist/retry.cjs +69 -0
- package/dist/retry.cjs.map +1 -0
- package/dist/retry.d.cts +19 -0
- package/dist/retry.d.ts +19 -0
- package/dist/retry.js +46 -0
- package/dist/retry.js.map +1 -0
- package/dist/runtime.cjs +38 -42
- package/dist/runtime.d.cts +2 -32
- package/dist/runtime.d.ts +2 -32
- package/dist/runtime.js +3 -0
- package/dist/string.cjs +76 -0
- package/dist/string.cjs.map +1 -0
- package/dist/string.d.cts +58 -0
- package/dist/string.d.ts +58 -0
- package/dist/string.js +72 -0
- package/dist/string.js.map +1 -0
- package/dist/terminal.cjs +91 -258
- package/dist/terminal.d.cts +11 -219
- package/dist/terminal.d.ts +11 -219
- package/dist/terminal.js +12 -0
- package/dist/url.cjs +25 -0
- package/dist/url.cjs.map +1 -0
- package/dist/url.d.cts +20 -0
- package/dist/url.d.ts +20 -0
- package/dist/url.js +24 -0
- package/dist/url.js.map +1 -0
- package/dist/validation.cjs +89 -186
- package/dist/validation.d.cts +7 -243
- package/dist/validation.d.ts +7 -243
- package/dist/validation.js +8 -0
- package/package.json +6 -6
- package/dist/environment.cjs.map +0 -1
- package/dist/environment.mjs +0 -384
- package/dist/environment.mjs.map +0 -1
- package/dist/filesystem.cjs.map +0 -1
- package/dist/filesystem.mjs +0 -105
- package/dist/filesystem.mjs.map +0 -1
- package/dist/http.cjs.map +0 -1
- package/dist/http.mjs +0 -80
- package/dist/http.mjs.map +0 -1
- package/dist/index.cjs.map +0 -1
- package/dist/index.mjs +0 -90
- package/dist/index.mjs.map +0 -1
- package/dist/logging.cjs.map +0 -1
- package/dist/logging.mjs +0 -123
- package/dist/logging.mjs.map +0 -1
- package/dist/package-manager.cjs.map +0 -1
- package/dist/package-manager.mjs +0 -167
- package/dist/package-manager.mjs.map +0 -1
- package/dist/runtime.cjs.map +0 -1
- package/dist/runtime.mjs +0 -23
- package/dist/runtime.mjs.map +0 -1
- package/dist/terminal.cjs.map +0 -1
- package/dist/terminal.mjs +0 -230
- package/dist/terminal.mjs.map +0 -1
- package/dist/validation.cjs.map +0 -1
- package/dist/validation.mjs +0 -161
- package/dist/validation.mjs.map +0 -1
package/dist/terminal.d.ts
CHANGED
|
@@ -1,219 +1,11 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
* ascii();
|
|
13
|
-
*/
|
|
14
|
-
declare const ascii: () => void;
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
* Error class used to indicate that the operation was cancelled.
|
|
18
|
-
* This error is used to signal that the operation should be aborted.
|
|
19
|
-
*/
|
|
20
|
-
declare class CancelError extends Error {
|
|
21
|
-
}
|
|
22
|
-
/**
|
|
23
|
-
* Displays an error message in red inverse text and throws a CancelError.
|
|
24
|
-
* Used to terminate execution with a visible error message.
|
|
25
|
-
* Any sensitive tokens in the message are masked before display.
|
|
26
|
-
*
|
|
27
|
-
* @param msg - The error message to display
|
|
28
|
-
* @returns never - Function does not return as it throws an error
|
|
29
|
-
* @example
|
|
30
|
-
* import { cancel } from "@settlemint/sdk-utils/terminal";
|
|
31
|
-
*
|
|
32
|
-
* // Exits process with error message
|
|
33
|
-
* cancel("An error occurred");
|
|
34
|
-
*/
|
|
35
|
-
declare const cancel: (msg: string) => never;
|
|
36
|
-
|
|
37
|
-
/**
|
|
38
|
-
* Options for executing a command, extending SpawnOptionsWithoutStdio
|
|
39
|
-
*/
|
|
40
|
-
interface ExecuteCommandOptions extends SpawnOptionsWithoutStdio {
|
|
41
|
-
/** Whether to suppress output to stdout/stderr */
|
|
42
|
-
silent?: boolean;
|
|
43
|
-
}
|
|
44
|
-
/**
|
|
45
|
-
* Error class for command execution errors
|
|
46
|
-
* @extends Error
|
|
47
|
-
*/
|
|
48
|
-
declare class CommandError extends Error {
|
|
49
|
-
readonly code: number;
|
|
50
|
-
readonly output: string[];
|
|
51
|
-
/**
|
|
52
|
-
* Constructs a new CommandError
|
|
53
|
-
* @param message - The error message
|
|
54
|
-
* @param code - The exit code of the command
|
|
55
|
-
* @param output - The output of the command
|
|
56
|
-
*/
|
|
57
|
-
constructor(message: string, code: number, output: string[]);
|
|
58
|
-
}
|
|
59
|
-
/**
|
|
60
|
-
* Executes a command with the given arguments in a child process.
|
|
61
|
-
* Pipes stdin to the child process and captures stdout/stderr output.
|
|
62
|
-
* Masks any sensitive tokens in the output before displaying or returning.
|
|
63
|
-
*
|
|
64
|
-
* @param command - The command to execute
|
|
65
|
-
* @param args - Array of arguments to pass to the command
|
|
66
|
-
* @param options - Options for customizing command execution
|
|
67
|
-
* @returns Array of output strings from stdout and stderr
|
|
68
|
-
* @throws {CommandError} If the process fails to start or exits with non-zero code
|
|
69
|
-
* @example
|
|
70
|
-
* import { executeCommand } from "@settlemint/sdk-utils/terminal";
|
|
71
|
-
*
|
|
72
|
-
* // Execute git clone
|
|
73
|
-
* await executeCommand("git", ["clone", "repo-url"]);
|
|
74
|
-
*
|
|
75
|
-
* // Execute silently
|
|
76
|
-
* await executeCommand("npm", ["install"], { silent: true });
|
|
77
|
-
*/
|
|
78
|
-
declare function executeCommand(command: string, args: string[], options?: ExecuteCommandOptions): Promise<string[]>;
|
|
79
|
-
|
|
80
|
-
/**
|
|
81
|
-
* Displays an introductory message in magenta text with padding.
|
|
82
|
-
* Any sensitive tokens in the message are masked before display.
|
|
83
|
-
*
|
|
84
|
-
* @param msg - The message to display as introduction
|
|
85
|
-
* @example
|
|
86
|
-
* import { intro } from "@settlemint/sdk-utils/terminal";
|
|
87
|
-
*
|
|
88
|
-
* // Display intro message
|
|
89
|
-
* intro("Starting deployment...");
|
|
90
|
-
*/
|
|
91
|
-
declare const intro: (msg: string) => void;
|
|
92
|
-
|
|
93
|
-
/**
|
|
94
|
-
* Displays a list of items in a formatted manner, supporting nested items.
|
|
95
|
-
*
|
|
96
|
-
* @param title - The title of the list
|
|
97
|
-
* @param items - The items to display, can be strings or arrays for nested items
|
|
98
|
-
* @returns The formatted list
|
|
99
|
-
* @example
|
|
100
|
-
* import { list } from "@settlemint/sdk-utils/terminal";
|
|
101
|
-
*
|
|
102
|
-
* // Simple list
|
|
103
|
-
* list("Use cases", ["use case 1", "use case 2", "use case 3"]);
|
|
104
|
-
*
|
|
105
|
-
* // Nested list
|
|
106
|
-
* list("Providers", [
|
|
107
|
-
* "AWS",
|
|
108
|
-
* ["us-east-1", "eu-west-1"],
|
|
109
|
-
* "Azure",
|
|
110
|
-
* ["eastus", "westeurope"]
|
|
111
|
-
* ]);
|
|
112
|
-
*/
|
|
113
|
-
declare function list(title: string, items: Array<string | string[]>): void;
|
|
114
|
-
|
|
115
|
-
/**
|
|
116
|
-
* Displays a note message with optional warning level formatting.
|
|
117
|
-
* Regular notes are displayed in normal text, while warnings are shown in yellow.
|
|
118
|
-
* Any sensitive tokens in the message are masked before display.
|
|
119
|
-
*
|
|
120
|
-
* @param message - The message to display as a note
|
|
121
|
-
* @param level - The note level: "info" (default) or "warn" for warning styling
|
|
122
|
-
* @example
|
|
123
|
-
* import { note } from "@settlemint/sdk-utils/terminal";
|
|
124
|
-
*
|
|
125
|
-
* // Display info note
|
|
126
|
-
* note("Operation completed successfully");
|
|
127
|
-
*
|
|
128
|
-
* // Display warning note
|
|
129
|
-
* note("Low disk space remaining", "warn");
|
|
130
|
-
*/
|
|
131
|
-
declare const note: (message: string, level?: "info" | "warn") => void;
|
|
132
|
-
|
|
133
|
-
/**
|
|
134
|
-
* Displays a closing message in green inverted text with padding.
|
|
135
|
-
* Any sensitive tokens in the message are masked before display.
|
|
136
|
-
*
|
|
137
|
-
* @param msg - The message to display as conclusion
|
|
138
|
-
* @example
|
|
139
|
-
* import { outro } from "@settlemint/sdk-utils/terminal";
|
|
140
|
-
*
|
|
141
|
-
* // Display outro message
|
|
142
|
-
* outro("Deployment completed successfully!");
|
|
143
|
-
*/
|
|
144
|
-
declare const outro: (msg: string) => void;
|
|
145
|
-
|
|
146
|
-
/**
|
|
147
|
-
* Error class used to indicate that the spinner operation failed.
|
|
148
|
-
* This error is used to signal that the operation should be aborted.
|
|
149
|
-
*/
|
|
150
|
-
declare class SpinnerError extends Error {
|
|
151
|
-
readonly originalError: Error;
|
|
152
|
-
constructor(message: string, originalError: Error);
|
|
153
|
-
}
|
|
154
|
-
/**
|
|
155
|
-
* Options for configuring the spinner behavior
|
|
156
|
-
*/
|
|
157
|
-
interface SpinnerOptions<R> {
|
|
158
|
-
/** Message to display when spinner starts */
|
|
159
|
-
startMessage: string;
|
|
160
|
-
/** Async task to execute while spinner is active */
|
|
161
|
-
task: (spinner?: Spinner) => Promise<R>;
|
|
162
|
-
/** Message to display when spinner completes successfully */
|
|
163
|
-
stopMessage: string;
|
|
164
|
-
}
|
|
165
|
-
/**
|
|
166
|
-
* Displays a loading spinner while executing an async task.
|
|
167
|
-
* Shows progress with start/stop messages and handles errors.
|
|
168
|
-
* Spinner is disabled in CI environments.
|
|
169
|
-
*
|
|
170
|
-
* @param options - Configuration options for the spinner
|
|
171
|
-
* @returns The result from the executed task
|
|
172
|
-
* @throws Will exit process with code 1 if task fails
|
|
173
|
-
* @example
|
|
174
|
-
* import { spinner } from "@settlemint/sdk-utils/terminal";
|
|
175
|
-
*
|
|
176
|
-
* // Show spinner during async task
|
|
177
|
-
* const result = await spinner({
|
|
178
|
-
* startMessage: "Deploying...",
|
|
179
|
-
* task: async () => {
|
|
180
|
-
* // Async work here
|
|
181
|
-
* return "success";
|
|
182
|
-
* },
|
|
183
|
-
* stopMessage: "Deployed successfully!"
|
|
184
|
-
* });
|
|
185
|
-
*/
|
|
186
|
-
declare const spinner: <R>(options: SpinnerOptions<R>) => Promise<R>;
|
|
187
|
-
|
|
188
|
-
/**
|
|
189
|
-
* Displays data in a formatted table in the terminal.
|
|
190
|
-
*
|
|
191
|
-
* @param title - Title to display above the table
|
|
192
|
-
* @param data - Array of objects to display in table format
|
|
193
|
-
* @example
|
|
194
|
-
* import { table } from "@settlemint/sdk-utils/terminal";
|
|
195
|
-
*
|
|
196
|
-
* const data = [
|
|
197
|
-
* { name: "Item 1", value: 100 },
|
|
198
|
-
* { name: "Item 2", value: 200 }
|
|
199
|
-
* ];
|
|
200
|
-
*
|
|
201
|
-
* table("My Table", data);
|
|
202
|
-
*/
|
|
203
|
-
declare function table(title: string, data: unknown[]): void;
|
|
204
|
-
|
|
205
|
-
/**
|
|
206
|
-
* Masks sensitive SettleMint tokens in output text by replacing them with asterisks.
|
|
207
|
-
* Handles personal access tokens (PAT), application access tokens (AAT), and service account tokens (SAT).
|
|
208
|
-
*
|
|
209
|
-
* @param output - The text string that may contain sensitive tokens
|
|
210
|
-
* @returns The text with any sensitive tokens masked with asterisks
|
|
211
|
-
* @example
|
|
212
|
-
* import { maskTokens } from "@settlemint/sdk-utils/terminal";
|
|
213
|
-
*
|
|
214
|
-
* // Masks a token in text
|
|
215
|
-
* const masked = maskTokens("Token: sm_pat_****"); // "Token: ***"
|
|
216
|
-
*/
|
|
217
|
-
declare const maskTokens: (output: string) => string;
|
|
218
|
-
|
|
219
|
-
export { CancelError, CommandError, type ExecuteCommandOptions, SpinnerError, type SpinnerOptions, ascii, cancel, executeCommand, intro, list, maskTokens, note, outro, spinner, table };
|
|
1
|
+
import { ascii } from "./terminal/ascii.js";
|
|
2
|
+
import { CancelError, cancel } from "./terminal/cancel.js";
|
|
3
|
+
import { CommandError, ExecuteCommandOptions, executeCommand } from "./terminal/execute-command.js";
|
|
4
|
+
import { intro } from "./terminal/intro.js";
|
|
5
|
+
import { list } from "./terminal/list.js";
|
|
6
|
+
import { note } from "./terminal/note.js";
|
|
7
|
+
import { outro } from "./terminal/outro.js";
|
|
8
|
+
import { SpinnerError, SpinnerOptions, spinner } from "./terminal/spinner.js";
|
|
9
|
+
import { table } from "./terminal/table.js";
|
|
10
|
+
import { maskTokens } from "./logging/mask-tokens.js";
|
|
11
|
+
export { CancelError, CommandError, ExecuteCommandOptions, SpinnerError, SpinnerOptions, ascii, cancel, executeCommand, intro, list, maskTokens, note, outro, spinner, table };
|
package/dist/terminal.js
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { ascii } from "./terminal/ascii.js";
|
|
2
|
+
import { CancelError, cancel } from "./terminal/cancel.js";
|
|
3
|
+
import { CommandError, executeCommand } from "./terminal/execute-command.js";
|
|
4
|
+
import { intro } from "./terminal/intro.js";
|
|
5
|
+
import { list } from "./terminal/list.js";
|
|
6
|
+
import { note } from "./terminal/note.js";
|
|
7
|
+
import { outro } from "./terminal/outro.js";
|
|
8
|
+
import { SpinnerError, spinner } from "./terminal/spinner.js";
|
|
9
|
+
import { table } from "./terminal/table.js";
|
|
10
|
+
import { maskTokens } from "./logging/mask-tokens.js";
|
|
11
|
+
|
|
12
|
+
export { CancelError, CommandError, SpinnerError, ascii, cancel, executeCommand, intro, list, maskTokens, note, outro, spinner, table };
|
package/dist/url.cjs
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
|
|
2
|
+
//#region src/url.ts
|
|
3
|
+
/**
|
|
4
|
+
* Extracts the base URL before a specific segment in a URL.
|
|
5
|
+
*
|
|
6
|
+
* @param baseUrl - The base URL to extract the path from
|
|
7
|
+
* @param pathSegment - The path segment to start from
|
|
8
|
+
* @returns The base URL before the specified segment
|
|
9
|
+
* @example
|
|
10
|
+
* ```typescript
|
|
11
|
+
* import { extractBaseUrlBeforeSegment } from "@settlemint/sdk-utils/url";
|
|
12
|
+
*
|
|
13
|
+
* const baseUrl = extractBaseUrlBeforeSegment("https://example.com/api/v1/subgraphs/name/my-subgraph", "/subgraphs");
|
|
14
|
+
* // Returns: "https://example.com/api/v1"
|
|
15
|
+
* ```
|
|
16
|
+
*/
|
|
17
|
+
function extractBaseUrlBeforeSegment(baseUrl, pathSegment) {
|
|
18
|
+
const url = new URL(baseUrl);
|
|
19
|
+
const segmentIndex = url.pathname.indexOf(pathSegment);
|
|
20
|
+
return url.origin + (segmentIndex >= 0 ? url.pathname.substring(0, segmentIndex) : url.pathname);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
//#endregion
|
|
24
|
+
exports.extractBaseUrlBeforeSegment = extractBaseUrlBeforeSegment;
|
|
25
|
+
//# sourceMappingURL=url.cjs.map
|
package/dist/url.cjs.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"url.cjs","names":["baseUrl: string","pathSegment: string"],"sources":["../src/url.ts"],"sourcesContent":["/**\n * Extracts the base URL before a specific segment in a URL.\n *\n * @param baseUrl - The base URL to extract the path from\n * @param pathSegment - The path segment to start from\n * @returns The base URL before the specified segment\n * @example\n * ```typescript\n * import { extractBaseUrlBeforeSegment } from \"@settlemint/sdk-utils/url\";\n *\n * const baseUrl = extractBaseUrlBeforeSegment(\"https://example.com/api/v1/subgraphs/name/my-subgraph\", \"/subgraphs\");\n * // Returns: \"https://example.com/api/v1\"\n * ```\n */\nexport function extractBaseUrlBeforeSegment(baseUrl: string, pathSegment: string) {\n const url = new URL(baseUrl);\n const segmentIndex = url.pathname.indexOf(pathSegment);\n return url.origin + (segmentIndex >= 0 ? url.pathname.substring(0, segmentIndex) : url.pathname);\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAcA,SAAgB,4BAA4BA,SAAiBC,aAAqB;CAChF,MAAM,MAAM,IAAI,IAAI;CACpB,MAAM,eAAe,IAAI,SAAS,QAAQ,YAAY;AACtD,QAAO,IAAI,UAAU,gBAAgB,IAAI,IAAI,SAAS,UAAU,GAAG,aAAa,GAAG,IAAI;AACxF"}
|
package/dist/url.d.cts
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
//#region src/url.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* Extracts the base URL before a specific segment in a URL.
|
|
4
|
+
*
|
|
5
|
+
* @param baseUrl - The base URL to extract the path from
|
|
6
|
+
* @param pathSegment - The path segment to start from
|
|
7
|
+
* @returns The base URL before the specified segment
|
|
8
|
+
* @example
|
|
9
|
+
* ```typescript
|
|
10
|
+
* import { extractBaseUrlBeforeSegment } from "@settlemint/sdk-utils/url";
|
|
11
|
+
*
|
|
12
|
+
* const baseUrl = extractBaseUrlBeforeSegment("https://example.com/api/v1/subgraphs/name/my-subgraph", "/subgraphs");
|
|
13
|
+
* // Returns: "https://example.com/api/v1"
|
|
14
|
+
* ```
|
|
15
|
+
*/
|
|
16
|
+
declare function extractBaseUrlBeforeSegment(baseUrl: string, pathSegment: string): string;
|
|
17
|
+
|
|
18
|
+
//#endregion
|
|
19
|
+
export { extractBaseUrlBeforeSegment };
|
|
20
|
+
//# sourceMappingURL=url.d.cts.map
|
package/dist/url.d.ts
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
//#region src/url.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* Extracts the base URL before a specific segment in a URL.
|
|
4
|
+
*
|
|
5
|
+
* @param baseUrl - The base URL to extract the path from
|
|
6
|
+
* @param pathSegment - The path segment to start from
|
|
7
|
+
* @returns The base URL before the specified segment
|
|
8
|
+
* @example
|
|
9
|
+
* ```typescript
|
|
10
|
+
* import { extractBaseUrlBeforeSegment } from "@settlemint/sdk-utils/url";
|
|
11
|
+
*
|
|
12
|
+
* const baseUrl = extractBaseUrlBeforeSegment("https://example.com/api/v1/subgraphs/name/my-subgraph", "/subgraphs");
|
|
13
|
+
* // Returns: "https://example.com/api/v1"
|
|
14
|
+
* ```
|
|
15
|
+
*/
|
|
16
|
+
declare function extractBaseUrlBeforeSegment(baseUrl: string, pathSegment: string): string;
|
|
17
|
+
|
|
18
|
+
//#endregion
|
|
19
|
+
export { extractBaseUrlBeforeSegment };
|
|
20
|
+
//# sourceMappingURL=url.d.ts.map
|
package/dist/url.js
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
//#region src/url.ts
|
|
2
|
+
/**
|
|
3
|
+
* Extracts the base URL before a specific segment in a URL.
|
|
4
|
+
*
|
|
5
|
+
* @param baseUrl - The base URL to extract the path from
|
|
6
|
+
* @param pathSegment - The path segment to start from
|
|
7
|
+
* @returns The base URL before the specified segment
|
|
8
|
+
* @example
|
|
9
|
+
* ```typescript
|
|
10
|
+
* import { extractBaseUrlBeforeSegment } from "@settlemint/sdk-utils/url";
|
|
11
|
+
*
|
|
12
|
+
* const baseUrl = extractBaseUrlBeforeSegment("https://example.com/api/v1/subgraphs/name/my-subgraph", "/subgraphs");
|
|
13
|
+
* // Returns: "https://example.com/api/v1"
|
|
14
|
+
* ```
|
|
15
|
+
*/
|
|
16
|
+
function extractBaseUrlBeforeSegment(baseUrl, pathSegment) {
|
|
17
|
+
const url = new URL(baseUrl);
|
|
18
|
+
const segmentIndex = url.pathname.indexOf(pathSegment);
|
|
19
|
+
return url.origin + (segmentIndex >= 0 ? url.pathname.substring(0, segmentIndex) : url.pathname);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
//#endregion
|
|
23
|
+
export { extractBaseUrlBeforeSegment };
|
|
24
|
+
//# sourceMappingURL=url.js.map
|
package/dist/url.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"url.js","names":["baseUrl: string","pathSegment: string"],"sources":["../src/url.ts"],"sourcesContent":["/**\n * Extracts the base URL before a specific segment in a URL.\n *\n * @param baseUrl - The base URL to extract the path from\n * @param pathSegment - The path segment to start from\n * @returns The base URL before the specified segment\n * @example\n * ```typescript\n * import { extractBaseUrlBeforeSegment } from \"@settlemint/sdk-utils/url\";\n *\n * const baseUrl = extractBaseUrlBeforeSegment(\"https://example.com/api/v1/subgraphs/name/my-subgraph\", \"/subgraphs\");\n * // Returns: \"https://example.com/api/v1\"\n * ```\n */\nexport function extractBaseUrlBeforeSegment(baseUrl: string, pathSegment: string) {\n const url = new URL(baseUrl);\n const segmentIndex = url.pathname.indexOf(pathSegment);\n return url.origin + (segmentIndex >= 0 ? url.pathname.substring(0, segmentIndex) : url.pathname);\n}\n"],"mappings":";;;;;;;;;;;;;;;AAcA,SAAgB,4BAA4BA,SAAiBC,aAAqB;CAChF,MAAM,MAAM,IAAI,IAAI;CACpB,MAAM,eAAe,IAAI,SAAS,QAAQ,YAAY;AACtD,QAAO,IAAI,UAAU,gBAAgB,IAAI,IAAI,SAAS,UAAU,GAAG,aAAa,GAAG,IAAI;AACxF"}
|
package/dist/validation.cjs
CHANGED
|
@@ -1,199 +1,102 @@
|
|
|
1
|
-
|
|
1
|
+
//#region rolldown:runtime
|
|
2
|
+
var __create = Object.create;
|
|
2
3
|
var __defProp = Object.defineProperty;
|
|
3
4
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
5
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
5
7
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
8
|
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
9
|
+
if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
10
|
+
key = keys[i];
|
|
11
|
+
if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
12
|
+
get: ((k) => from[k]).bind(null, key),
|
|
13
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
17
|
};
|
|
18
|
-
var
|
|
18
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
19
|
+
value: mod,
|
|
20
|
+
enumerable: true
|
|
21
|
+
}) : target, mod));
|
|
19
22
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
IdSchema: () => IdSchema,
|
|
28
|
-
PersonalAccessTokenSchema: () => PersonalAccessTokenSchema,
|
|
29
|
-
STANDALONE_INSTANCE: () => STANDALONE_INSTANCE,
|
|
30
|
-
UniqueNameSchema: () => UniqueNameSchema,
|
|
31
|
-
UrlOrPathSchema: () => UrlOrPathSchema,
|
|
32
|
-
UrlPathSchema: () => UrlPathSchema,
|
|
33
|
-
UrlSchema: () => UrlSchema,
|
|
34
|
-
validate: () => validate
|
|
35
|
-
});
|
|
36
|
-
module.exports = __toCommonJS(validation_exports);
|
|
23
|
+
//#endregion
|
|
24
|
+
const src_validation_validate_js = __toESM(require("./validation/validate.js"));
|
|
25
|
+
const src_validation_access_token_schema_js = __toESM(require("./validation/access-token.schema.js"));
|
|
26
|
+
const src_validation_dot_env_schema_js = __toESM(require("./validation/dot-env.schema.js"));
|
|
27
|
+
const src_validation_id_schema_js = __toESM(require("./validation/id.schema.js"));
|
|
28
|
+
const src_validation_unique_name_schema_js = __toESM(require("./validation/unique-name.schema.js"));
|
|
29
|
+
const src_validation_url_schema_js = __toESM(require("./validation/url.schema.js"));
|
|
37
30
|
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
function
|
|
41
|
-
|
|
42
|
-
return schema.parse(value);
|
|
43
|
-
} catch (error) {
|
|
44
|
-
if (error instanceof import_v4.ZodError) {
|
|
45
|
-
const formattedErrors = error.issues.map((err) => `- ${err.path.join(".")}: ${err.message}`).join("\n");
|
|
46
|
-
throw new Error(`Validation error${error.issues.length > 1 ? "s" : ""}:
|
|
47
|
-
${formattedErrors}`);
|
|
48
|
-
}
|
|
49
|
-
throw error;
|
|
31
|
+
Object.defineProperty(exports, 'AccessTokenSchema', {
|
|
32
|
+
enumerable: true,
|
|
33
|
+
get: function () {
|
|
34
|
+
return src_validation_access_token_schema_js.AccessTokenSchema;
|
|
50
35
|
}
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
var PersonalAccessTokenSchema = import_v42.z.string().regex(/^sm_pat_.*$/);
|
|
57
|
-
var AccessTokenSchema = import_v42.z.string().regex(/^sm_pat_.*|sm_aat_.*$/);
|
|
58
|
-
|
|
59
|
-
// src/json.ts
|
|
60
|
-
function tryParseJson(value, defaultValue = null) {
|
|
61
|
-
try {
|
|
62
|
-
const parsed = JSON.parse(value);
|
|
63
|
-
if (parsed === void 0 || parsed === null) {
|
|
64
|
-
return defaultValue;
|
|
65
|
-
}
|
|
66
|
-
return parsed;
|
|
67
|
-
} catch (err) {
|
|
68
|
-
return defaultValue;
|
|
36
|
+
});
|
|
37
|
+
Object.defineProperty(exports, 'ApplicationAccessTokenSchema', {
|
|
38
|
+
enumerable: true,
|
|
39
|
+
get: function () {
|
|
40
|
+
return src_validation_access_token_schema_js.ApplicationAccessTokenSchema;
|
|
69
41
|
}
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
// src/validation/dot-env.schema.ts
|
|
73
|
-
var import_v45 = require("zod/v4");
|
|
74
|
-
|
|
75
|
-
// src/validation/unique-name.schema.ts
|
|
76
|
-
var import_v43 = require("zod/v4");
|
|
77
|
-
var UniqueNameSchema = import_v43.z.string().regex(/^[a-z0-9-]+$/);
|
|
78
|
-
|
|
79
|
-
// src/validation/url.schema.ts
|
|
80
|
-
var import_v44 = require("zod/v4");
|
|
81
|
-
var UrlSchema = import_v44.z.string().url();
|
|
82
|
-
var UrlPathSchema = import_v44.z.string().regex(/^\/(?:[a-zA-Z0-9-_]+(?:\/[a-zA-Z0-9-_]+)*\/?)?$/, {
|
|
83
|
-
message: "Invalid URL path format. Must start with '/' and can contain letters, numbers, hyphens, and underscores."
|
|
84
42
|
});
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
/** Base URL of the SettleMint platform instance, set to standalone if your resources are not part of the SettleMint platform */
|
|
91
|
-
SETTLEMINT_INSTANCE: import_v45.z.union([UrlSchema, import_v45.z.literal(STANDALONE_INSTANCE)]).default("https://console.settlemint.com"),
|
|
92
|
-
/** Application access token for authenticating with SettleMint services */
|
|
93
|
-
SETTLEMINT_ACCESS_TOKEN: ApplicationAccessTokenSchema.optional(),
|
|
94
|
-
/** @internal */
|
|
95
|
-
SETTLEMINT_PERSONAL_ACCESS_TOKEN: PersonalAccessTokenSchema.optional(),
|
|
96
|
-
/** Unique name of the workspace */
|
|
97
|
-
SETTLEMINT_WORKSPACE: UniqueNameSchema.optional(),
|
|
98
|
-
/** Unique name of the application */
|
|
99
|
-
SETTLEMINT_APPLICATION: UniqueNameSchema.optional(),
|
|
100
|
-
/** Unique name of the blockchain network */
|
|
101
|
-
SETTLEMINT_BLOCKCHAIN_NETWORK: UniqueNameSchema.optional(),
|
|
102
|
-
/** Chain ID of the blockchain network */
|
|
103
|
-
SETTLEMINT_BLOCKCHAIN_NETWORK_CHAIN_ID: import_v45.z.string().optional(),
|
|
104
|
-
/** Unique name of the blockchain node (should have a private key for signing transactions) */
|
|
105
|
-
SETTLEMINT_BLOCKCHAIN_NODE: UniqueNameSchema.optional(),
|
|
106
|
-
/** JSON RPC endpoint for the blockchain node */
|
|
107
|
-
SETTLEMINT_BLOCKCHAIN_NODE_JSON_RPC_ENDPOINT: UrlSchema.optional(),
|
|
108
|
-
/** Unique name of the blockchain node or load balancer */
|
|
109
|
-
SETTLEMINT_BLOCKCHAIN_NODE_OR_LOAD_BALANCER: UniqueNameSchema.optional(),
|
|
110
|
-
/** JSON RPC endpoint for the blockchain node or load balancer */
|
|
111
|
-
SETTLEMINT_BLOCKCHAIN_NODE_OR_LOAD_BALANCER_JSON_RPC_ENDPOINT: UrlSchema.optional(),
|
|
112
|
-
/** Unique name of the Hasura instance */
|
|
113
|
-
SETTLEMINT_HASURA: UniqueNameSchema.optional(),
|
|
114
|
-
/** Endpoint URL for the Hasura GraphQL API */
|
|
115
|
-
SETTLEMINT_HASURA_ENDPOINT: UrlSchema.optional(),
|
|
116
|
-
/** Admin secret for authenticating with Hasura */
|
|
117
|
-
SETTLEMINT_HASURA_ADMIN_SECRET: import_v45.z.string().optional(),
|
|
118
|
-
/** Database connection URL for Hasura */
|
|
119
|
-
SETTLEMINT_HASURA_DATABASE_URL: import_v45.z.string().optional(),
|
|
120
|
-
/** Unique name of The Graph instance */
|
|
121
|
-
SETTLEMINT_THEGRAPH: UniqueNameSchema.optional(),
|
|
122
|
-
/** Array of endpoint URLs for The Graph subgraphs */
|
|
123
|
-
SETTLEMINT_THEGRAPH_SUBGRAPHS_ENDPOINTS: import_v45.z.preprocess(
|
|
124
|
-
(value) => tryParseJson(value, []),
|
|
125
|
-
import_v45.z.array(UrlSchema).optional()
|
|
126
|
-
),
|
|
127
|
-
/** Default The Graph subgraph to use */
|
|
128
|
-
SETTLEMINT_THEGRAPH_DEFAULT_SUBGRAPH: import_v45.z.string().optional(),
|
|
129
|
-
/** Unique name of the Smart Contract Portal instance */
|
|
130
|
-
SETTLEMINT_PORTAL: UniqueNameSchema.optional(),
|
|
131
|
-
/** GraphQL endpoint URL for the Portal */
|
|
132
|
-
SETTLEMINT_PORTAL_GRAPHQL_ENDPOINT: UrlSchema.optional(),
|
|
133
|
-
/** REST endpoint URL for the Portal */
|
|
134
|
-
SETTLEMINT_PORTAL_REST_ENDPOINT: UrlSchema.optional(),
|
|
135
|
-
/** WebSocket endpoint URL for the Portal */
|
|
136
|
-
SETTLEMINT_PORTAL_WS_ENDPOINT: UrlSchema.optional(),
|
|
137
|
-
/** Unique name of the HD private key */
|
|
138
|
-
SETTLEMINT_HD_PRIVATE_KEY: UniqueNameSchema.optional(),
|
|
139
|
-
/** Address of the HD private key forwarder */
|
|
140
|
-
SETTLEMINT_HD_PRIVATE_KEY_FORWARDER_ADDRESS: import_v45.z.string().optional(),
|
|
141
|
-
/** Unique name of the accessible private key */
|
|
142
|
-
SETTLEMINT_ACCESSIBLE_PRIVATE_KEY: UniqueNameSchema.optional(),
|
|
143
|
-
/** Unique name of the MinIO instance */
|
|
144
|
-
SETTLEMINT_MINIO: UniqueNameSchema.optional(),
|
|
145
|
-
/** Endpoint URL for MinIO */
|
|
146
|
-
SETTLEMINT_MINIO_ENDPOINT: UrlSchema.optional(),
|
|
147
|
-
/** Access key for MinIO authentication */
|
|
148
|
-
SETTLEMINT_MINIO_ACCESS_KEY: import_v45.z.string().optional(),
|
|
149
|
-
/** Secret key for MinIO authentication */
|
|
150
|
-
SETTLEMINT_MINIO_SECRET_KEY: import_v45.z.string().optional(),
|
|
151
|
-
/** Unique name of the IPFS instance */
|
|
152
|
-
SETTLEMINT_IPFS: UniqueNameSchema.optional(),
|
|
153
|
-
/** API endpoint URL for IPFS */
|
|
154
|
-
SETTLEMINT_IPFS_API_ENDPOINT: UrlSchema.optional(),
|
|
155
|
-
/** Pinning service endpoint URL for IPFS */
|
|
156
|
-
SETTLEMINT_IPFS_PINNING_ENDPOINT: UrlSchema.optional(),
|
|
157
|
-
/** Gateway endpoint URL for IPFS */
|
|
158
|
-
SETTLEMINT_IPFS_GATEWAY_ENDPOINT: UrlSchema.optional(),
|
|
159
|
-
/** Unique name of the custom deployment */
|
|
160
|
-
SETTLEMINT_CUSTOM_DEPLOYMENT: UniqueNameSchema.optional(),
|
|
161
|
-
/** Endpoint URL for the custom deployment */
|
|
162
|
-
SETTLEMINT_CUSTOM_DEPLOYMENT_ENDPOINT: UrlSchema.optional(),
|
|
163
|
-
/** Unique name of the Blockscout instance */
|
|
164
|
-
SETTLEMINT_BLOCKSCOUT: UniqueNameSchema.optional(),
|
|
165
|
-
/** GraphQL endpoint URL for Blockscout */
|
|
166
|
-
SETTLEMINT_BLOCKSCOUT_GRAPHQL_ENDPOINT: UrlSchema.optional(),
|
|
167
|
-
/** UI endpoint URL for Blockscout */
|
|
168
|
-
SETTLEMINT_BLOCKSCOUT_UI_ENDPOINT: UrlSchema.optional(),
|
|
169
|
-
/** Name of the new project being created */
|
|
170
|
-
SETTLEMINT_NEW_PROJECT_NAME: import_v45.z.string().optional(),
|
|
171
|
-
/** The log level to use */
|
|
172
|
-
SETTLEMINT_LOG_LEVEL: import_v45.z.enum(["debug", "info", "warn", "error", "none"]).default("warn")
|
|
43
|
+
Object.defineProperty(exports, 'DotEnvSchema', {
|
|
44
|
+
enumerable: true,
|
|
45
|
+
get: function () {
|
|
46
|
+
return src_validation_dot_env_schema_js.DotEnvSchema;
|
|
47
|
+
}
|
|
173
48
|
});
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
49
|
+
Object.defineProperty(exports, 'DotEnvSchemaPartial', {
|
|
50
|
+
enumerable: true,
|
|
51
|
+
get: function () {
|
|
52
|
+
return src_validation_dot_env_schema_js.DotEnvSchemaPartial;
|
|
53
|
+
}
|
|
54
|
+
});
|
|
55
|
+
Object.defineProperty(exports, 'IdSchema', {
|
|
56
|
+
enumerable: true,
|
|
57
|
+
get: function () {
|
|
58
|
+
return src_validation_id_schema_js.IdSchema;
|
|
59
|
+
}
|
|
60
|
+
});
|
|
61
|
+
Object.defineProperty(exports, 'PersonalAccessTokenSchema', {
|
|
62
|
+
enumerable: true,
|
|
63
|
+
get: function () {
|
|
64
|
+
return src_validation_access_token_schema_js.PersonalAccessTokenSchema;
|
|
65
|
+
}
|
|
66
|
+
});
|
|
67
|
+
Object.defineProperty(exports, 'STANDALONE_INSTANCE', {
|
|
68
|
+
enumerable: true,
|
|
69
|
+
get: function () {
|
|
70
|
+
return src_validation_dot_env_schema_js.STANDALONE_INSTANCE;
|
|
71
|
+
}
|
|
72
|
+
});
|
|
73
|
+
Object.defineProperty(exports, 'UniqueNameSchema', {
|
|
74
|
+
enumerable: true,
|
|
75
|
+
get: function () {
|
|
76
|
+
return src_validation_unique_name_schema_js.UniqueNameSchema;
|
|
77
|
+
}
|
|
198
78
|
});
|
|
199
|
-
|
|
79
|
+
Object.defineProperty(exports, 'UrlOrPathSchema', {
|
|
80
|
+
enumerable: true,
|
|
81
|
+
get: function () {
|
|
82
|
+
return src_validation_url_schema_js.UrlOrPathSchema;
|
|
83
|
+
}
|
|
84
|
+
});
|
|
85
|
+
Object.defineProperty(exports, 'UrlPathSchema', {
|
|
86
|
+
enumerable: true,
|
|
87
|
+
get: function () {
|
|
88
|
+
return src_validation_url_schema_js.UrlPathSchema;
|
|
89
|
+
}
|
|
90
|
+
});
|
|
91
|
+
Object.defineProperty(exports, 'UrlSchema', {
|
|
92
|
+
enumerable: true,
|
|
93
|
+
get: function () {
|
|
94
|
+
return src_validation_url_schema_js.UrlSchema;
|
|
95
|
+
}
|
|
96
|
+
});
|
|
97
|
+
Object.defineProperty(exports, 'validate', {
|
|
98
|
+
enumerable: true,
|
|
99
|
+
get: function () {
|
|
100
|
+
return src_validation_validate_js.validate;
|
|
101
|
+
}
|
|
102
|
+
});
|