@gearbox-protocol/cli-utils 6.16.2 → 9.0.0-beta.12
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/dist/index.d.ts +436 -19
- package/dist/index.js +1402 -19
- package/dist/index.js.map +1 -0
- package/package.json +26 -13
- package/dist/CensoredString.d.ts +0 -8
- package/dist/CensoredString.js +0 -31
- package/dist/CensoredURL.d.ts +0 -11
- package/dist/CensoredURL.js +0 -53
- package/dist/SSMManager.d.ts +0 -5
- package/dist/SSMManager.js +0 -30
- package/dist/SecretsManager.d.ts +0 -6
- package/dist/SecretsManager.js +0 -52
- package/dist/Whitelist.d.ts +0 -30
- package/dist/Whitelist.js +0 -84
- package/dist/Zommand.d.ts +0 -25
- package/dist/Zommand.js +0 -98
- package/dist/compressedConfig.d.ts +0 -10
- package/dist/compressedConfig.js +0 -22
- package/dist/createPinoCensor.d.ts +0 -5
- package/dist/createPinoCensor.js +0 -53
- package/dist/fetchRetry.d.ts +0 -7
- package/dist/fetchRetry.js +0 -26
- package/dist/getFirstHttpTransportOptions.d.ts +0 -7
- package/dist/getFirstHttpTransportOptions.js +0 -13
- package/dist/getPromisePath.d.ts +0 -7
- package/dist/getPromisePath.js +0 -18
- package/dist/getProviders.d.ts +0 -4
- package/dist/getProviders.js +0 -104
- package/dist/notifications/NotificationsService.d.ts +0 -19
- package/dist/notifications/NotificationsService.js +0 -76
- package/dist/notifications/SignlNotifier.d.ts +0 -13
- package/dist/notifications/SignlNotifier.js +0 -58
- package/dist/notifications/SlackNotifier.d.ts +0 -8
- package/dist/notifications/SlackNotifier.js +0 -38
- package/dist/notifications/TelegramNotifier.d.ts +0 -14
- package/dist/notifications/TelegramNotifier.js +0 -119
- package/dist/notifications/ThrottleManager.d.ts +0 -18
- package/dist/notifications/ThrottleManager.js +0 -40
- package/dist/notifications/createNotifier.d.ts +0 -4
- package/dist/notifications/createNotifier.js +0 -18
- package/dist/notifications/index.d.ts +0 -4
- package/dist/notifications/index.js +0 -4
- package/dist/notifications/schema.d.ts +0 -33
- package/dist/notifications/schema.js +0 -46
- package/dist/notifications/types.d.ts +0 -91
- package/dist/notifications/types.js +0 -1
- package/dist/providers-schema.d.ts +0 -49
- package/dist/providers-schema.js +0 -122
- package/dist/providers.d.ts +0 -6
- package/dist/providers.js +0 -103
- package/dist/resolveYamlFiles.d.ts +0 -40
- package/dist/resolveYamlFiles.js +0 -170
- package/dist/schema-primitives.d.ts +0 -10
- package/dist/schema-primitives.js +0 -30
- package/dist/sleep.d.ts +0 -1
- package/dist/sleep.js +0 -6
- package/dist/uncensorMap.d.ts +0 -4
- package/dist/uncensorMap.js +0 -3
- package/dist/whitelist-schema.d.ts +0 -54
- package/dist/whitelist-schema.js +0 -21
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import YAML from "yaml";
|
|
2
|
-
export type TemplateData = Record<string, unknown>;
|
|
3
|
-
/**
|
|
4
|
-
* Merges yaml files, respecting .extends references.
|
|
5
|
-
* Performs env variable substitution on the config.
|
|
6
|
-
* Respects YAML anchors and aliases, and merge keys - so that they can be shared across two files
|
|
7
|
-
*
|
|
8
|
-
* x-* anchors are removed from resulting document (a-la docker compose yaml)
|
|
9
|
-
*
|
|
10
|
-
* @param file
|
|
11
|
-
* @param templateData
|
|
12
|
-
* @returns
|
|
13
|
-
*/
|
|
14
|
-
export declare function resolveYamlFiles(file: string, templateData?: TemplateData): Promise<object>;
|
|
15
|
-
/**
|
|
16
|
-
* Merges yaml documents, respecting .extends references.
|
|
17
|
-
* Optionally, performs env-style variable substitution on the config.
|
|
18
|
-
* Respects YAML anchors and aliases, and merge keys - so that they can be shared across two files
|
|
19
|
-
* Supports s3 links for file
|
|
20
|
-
*
|
|
21
|
-
* @param file
|
|
22
|
-
* @param templateData
|
|
23
|
-
* @returns
|
|
24
|
-
*/
|
|
25
|
-
export declare function resolveYamlDoc(file: string, templateData?: TemplateData): Promise<YAML.Document>;
|
|
26
|
-
/**
|
|
27
|
-
* Helper function that gets object with templated values
|
|
28
|
-
* Just because async ast already exists in yaml, but not in json reviver
|
|
29
|
-
* @param json
|
|
30
|
-
* @param templateData
|
|
31
|
-
* @returns
|
|
32
|
-
*/
|
|
33
|
-
export declare function resolveFromObject(json: object, templateData?: TemplateData): Promise<object>;
|
|
34
|
-
/**
|
|
35
|
-
* Given file and a relative file path, returns full path of the relative file
|
|
36
|
-
* Supports s3 links for base file
|
|
37
|
-
* @param file
|
|
38
|
-
* @param relativeFile
|
|
39
|
-
*/
|
|
40
|
-
export declare function getRelativePath(baseFile: string, relativeFile: string): string;
|
package/dist/resolveYamlFiles.js
DELETED
|
@@ -1,170 +0,0 @@
|
|
|
1
|
-
import { readFile } from "node:fs/promises";
|
|
2
|
-
import { dirname, resolve as pathResolve } from "node:path";
|
|
3
|
-
import { GetObjectCommand, S3Client } from "@aws-sdk/client-s3";
|
|
4
|
-
import YAML, { isPair, isScalar, isSeq } from "yaml";
|
|
5
|
-
import getPromisePath from "./getPromisePath.js";
|
|
6
|
-
/**
|
|
7
|
-
* Template key regexp
|
|
8
|
-
* Consists of alphanumeric+underscore parts separated by dots, all wrappped in env-style brackets
|
|
9
|
-
* e.g. ${KEY} or ${KEY.SUBKEY}
|
|
10
|
-
*
|
|
11
|
-
* Optionally supports a bash-style default value via `:-`, e.g. `${KEY:-fallback}`.
|
|
12
|
-
* The default is used when the resolved value is undefined, null, or an empty string.
|
|
13
|
-
* Capture groups: 1 = key path, 2 = optional default literal (no `}` allowed).
|
|
14
|
-
*/
|
|
15
|
-
const templateKeyRegex = /\$\{([\w-]+(?:\.[\w-]+)*)(?::-([^}]*))?\}/g;
|
|
16
|
-
/**
|
|
17
|
-
* Replaces all `${...}` template tokens in a string using the provided template data.
|
|
18
|
-
* Supports bash-style `${KEY:-default}` fallback when the resolved value is missing
|
|
19
|
-
* (undefined, null, or empty string). The default is a literal and is not further
|
|
20
|
-
* interpolated.
|
|
21
|
-
*/
|
|
22
|
-
async function resolveScalarValue(val, templateData) {
|
|
23
|
-
const matches = val.matchAll(templateKeyRegex);
|
|
24
|
-
for (const match of matches) {
|
|
25
|
-
const [whole, key, defaultValue] = match;
|
|
26
|
-
const resolved = await getPromisePath(templateData, key);
|
|
27
|
-
if (resolved !== undefined && resolved !== null && resolved !== "") {
|
|
28
|
-
val = val.replace(whole, String(resolved));
|
|
29
|
-
}
|
|
30
|
-
else if (defaultValue !== undefined) {
|
|
31
|
-
val = val.replace(whole, defaultValue);
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
return val;
|
|
35
|
-
}
|
|
36
|
-
/**
|
|
37
|
-
* Merges yaml files, respecting .extends references.
|
|
38
|
-
* Performs env variable substitution on the config.
|
|
39
|
-
* Respects YAML anchors and aliases, and merge keys - so that they can be shared across two files
|
|
40
|
-
*
|
|
41
|
-
* x-* anchors are removed from resulting document (a-la docker compose yaml)
|
|
42
|
-
*
|
|
43
|
-
* @param file
|
|
44
|
-
* @param templateData
|
|
45
|
-
* @returns
|
|
46
|
-
*/
|
|
47
|
-
export async function resolveYamlFiles(file, templateData) {
|
|
48
|
-
const doc = await resolveYamlDoc(file, templateData);
|
|
49
|
-
const obj = doc.toJSON();
|
|
50
|
-
return Object.fromEntries(Object.entries(obj).filter(([k]) => !k.startsWith("x-")));
|
|
51
|
-
}
|
|
52
|
-
/**
|
|
53
|
-
* Merges yaml documents, respecting .extends references.
|
|
54
|
-
* Optionally, performs env-style variable substitution on the config.
|
|
55
|
-
* Respects YAML anchors and aliases, and merge keys - so that they can be shared across two files
|
|
56
|
-
* Supports s3 links for file
|
|
57
|
-
*
|
|
58
|
-
* @param file
|
|
59
|
-
* @param templateData
|
|
60
|
-
* @returns
|
|
61
|
-
*/
|
|
62
|
-
export async function resolveYamlDoc(file, templateData) {
|
|
63
|
-
const content = await loadFile(file);
|
|
64
|
-
// if (templateData) {
|
|
65
|
-
// const compiled = template(content);
|
|
66
|
-
// content = compiled(templateData);
|
|
67
|
-
// }
|
|
68
|
-
let cfgRaw = YAML.parseDocument(content, { merge: true });
|
|
69
|
-
// let cfgRaw = YAML.parse(content, { merge: true });
|
|
70
|
-
if (cfgRaw.has("extends")) {
|
|
71
|
-
const baseFile = cfgRaw.get("extends");
|
|
72
|
-
const extended = cfgRaw;
|
|
73
|
-
// extends is a relative path to the base file
|
|
74
|
-
cfgRaw = await resolveYamlDoc(getRelativePath(file, baseFile), templateData);
|
|
75
|
-
YAML.visit(extended, {
|
|
76
|
-
Pair(_, pair, rawPath) {
|
|
77
|
-
const path = getNodesPath(rawPath);
|
|
78
|
-
if (isScalar(pair.key) && (isScalar(pair.value) || isSeq(pair.value))) {
|
|
79
|
-
if (pair.key.value === "extends") {
|
|
80
|
-
return;
|
|
81
|
-
}
|
|
82
|
-
cfgRaw.setIn([...path, pair.key.value], pair.value);
|
|
83
|
-
return YAML.visit.SKIP;
|
|
84
|
-
}
|
|
85
|
-
},
|
|
86
|
-
});
|
|
87
|
-
}
|
|
88
|
-
await YAML.visitAsync(cfgRaw, {
|
|
89
|
-
Scalar: async (_, node) => {
|
|
90
|
-
if (typeof node.value === "string") {
|
|
91
|
-
node.value = await resolveScalarValue(node.value, templateData);
|
|
92
|
-
}
|
|
93
|
-
},
|
|
94
|
-
});
|
|
95
|
-
return cfgRaw;
|
|
96
|
-
}
|
|
97
|
-
/**
|
|
98
|
-
* Helper function that gets object with templated values
|
|
99
|
-
* Just because async ast already exists in yaml, but not in json reviver
|
|
100
|
-
* @param json
|
|
101
|
-
* @param templateData
|
|
102
|
-
* @returns
|
|
103
|
-
*/
|
|
104
|
-
export async function resolveFromObject(json, templateData) {
|
|
105
|
-
const content = YAML.stringify(json);
|
|
106
|
-
const cfgRaw = YAML.parseDocument(content, { merge: true });
|
|
107
|
-
await YAML.visitAsync(cfgRaw, {
|
|
108
|
-
Scalar: async (_, node) => {
|
|
109
|
-
if (typeof node.value === "string") {
|
|
110
|
-
node.value = await resolveScalarValue(node.value, templateData);
|
|
111
|
-
}
|
|
112
|
-
},
|
|
113
|
-
});
|
|
114
|
-
return cfgRaw.toJSON();
|
|
115
|
-
}
|
|
116
|
-
function getNodesPath(nodes) {
|
|
117
|
-
return nodes
|
|
118
|
-
.map(n => {
|
|
119
|
-
if (isPair(n) && isScalar(n.key)) {
|
|
120
|
-
return n.key.value;
|
|
121
|
-
}
|
|
122
|
-
return "";
|
|
123
|
-
})
|
|
124
|
-
.filter(Boolean);
|
|
125
|
-
}
|
|
126
|
-
/**
|
|
127
|
-
* Loads file from s3 or local file system
|
|
128
|
-
* @param file - s3 link or local file path
|
|
129
|
-
* @returns file content
|
|
130
|
-
*/
|
|
131
|
-
async function loadFile(file) {
|
|
132
|
-
if (file.startsWith("s3://")) {
|
|
133
|
-
return await loadS3File(file);
|
|
134
|
-
}
|
|
135
|
-
return await readFile(file, "utf-8");
|
|
136
|
-
}
|
|
137
|
-
/**
|
|
138
|
-
* Loads file from s3
|
|
139
|
-
* @param file - s3 link like s3://bucket/path/to/file.yaml
|
|
140
|
-
* @returns file content
|
|
141
|
-
*/
|
|
142
|
-
async function loadS3File(file) {
|
|
143
|
-
const url = new URL(file);
|
|
144
|
-
const bucket = url.hostname;
|
|
145
|
-
const key = url.pathname.slice(1);
|
|
146
|
-
const s3 = new S3Client({});
|
|
147
|
-
const response = await s3.send(new GetObjectCommand({
|
|
148
|
-
Bucket: bucket,
|
|
149
|
-
Key: key,
|
|
150
|
-
}));
|
|
151
|
-
if (!response.Body) {
|
|
152
|
-
throw new Error(`file ${file} not found`);
|
|
153
|
-
}
|
|
154
|
-
return response.Body.transformToString("utf-8");
|
|
155
|
-
}
|
|
156
|
-
/**
|
|
157
|
-
* Given file and a relative file path, returns full path of the relative file
|
|
158
|
-
* Supports s3 links for base file
|
|
159
|
-
* @param file
|
|
160
|
-
* @param relativeFile
|
|
161
|
-
*/
|
|
162
|
-
export function getRelativePath(baseFile, relativeFile) {
|
|
163
|
-
if (baseFile.startsWith("s3://")) {
|
|
164
|
-
const url = new URL(baseFile);
|
|
165
|
-
const relPathname = pathResolve(dirname(url.pathname), relativeFile);
|
|
166
|
-
url.pathname = relPathname;
|
|
167
|
-
return url.toString();
|
|
168
|
-
}
|
|
169
|
-
return pathResolve(dirname(baseFile), relativeFile);
|
|
170
|
-
}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { z } from "zod/v4";
|
|
2
|
-
export declare const boolLike: () => z.ZodPipe<z.ZodAny, z.ZodTransform<boolean, any>>;
|
|
3
|
-
export declare const stringArrayLike: () => z.ZodUnion<readonly [z.ZodArray<z.ZodString>, z.ZodPipe<z.ZodString, z.ZodTransform<string[], string>>]>;
|
|
4
|
-
export declare const optionalStringArrayLike: () => z.ZodPipe<z.ZodOptional<z.ZodUnion<readonly [z.ZodArray<z.ZodString>, z.ZodPipe<z.ZodString, z.ZodTransform<string[], string>>]>>, z.ZodTransform<string[] | undefined, string[] | undefined>>;
|
|
5
|
-
/**
|
|
6
|
-
* Like Address from abitype/zod, but converts an address into an address that is checksum encoded.
|
|
7
|
-
*/
|
|
8
|
-
export declare const addressLike: () => z.ZodPipe<z.ZodString, z.ZodTransform<`0x${string}`, string>>;
|
|
9
|
-
export declare const addressArrayLike: () => z.ZodPipe<z.ZodUnion<readonly [z.ZodArray<z.ZodString>, z.ZodPipe<z.ZodString, z.ZodTransform<string[], string>>]>, z.ZodArray<z.ZodPipe<z.ZodString, z.ZodTransform<`0x${string}`, string>>>>;
|
|
10
|
-
export declare const optionalAddressArrayLike: () => z.ZodPipe<z.ZodOptional<z.ZodPipe<z.ZodUnion<readonly [z.ZodArray<z.ZodString>, z.ZodPipe<z.ZodString, z.ZodTransform<string[], string>>]>, z.ZodArray<z.ZodPipe<z.ZodString, z.ZodTransform<`0x${string}`, string>>>>>, z.ZodTransform<`0x${string}`[] | undefined, `0x${string}`[] | undefined>>;
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import { getAddress, isAddress } from "viem";
|
|
2
|
-
import { z } from "zod/v4";
|
|
3
|
-
export const boolLike = () => z.any().transform(v => {
|
|
4
|
-
if (typeof v === "string") {
|
|
5
|
-
return ["true", "1"].includes(v.toLowerCase());
|
|
6
|
-
}
|
|
7
|
-
return Boolean(v);
|
|
8
|
-
});
|
|
9
|
-
export const stringArrayLike = () => z.union([z.array(z.string()), z.string().transform(val => val.split(","))]);
|
|
10
|
-
export const optionalStringArrayLike = () => stringArrayLike()
|
|
11
|
-
.optional()
|
|
12
|
-
.transform(v => (v?.length ? v : undefined));
|
|
13
|
-
/**
|
|
14
|
-
* Like Address from abitype/zod, but converts an address into an address that is checksum encoded.
|
|
15
|
-
*/
|
|
16
|
-
export const addressLike = () => z.string().transform((val, ctx) => {
|
|
17
|
-
if (!isAddress(val)) {
|
|
18
|
-
ctx.issues.push({
|
|
19
|
-
code: "custom",
|
|
20
|
-
message: `invalid address ${val}`,
|
|
21
|
-
input: ctx.value,
|
|
22
|
-
});
|
|
23
|
-
}
|
|
24
|
-
return getAddress(val);
|
|
25
|
-
});
|
|
26
|
-
export const addressArrayLike = () => stringArrayLike().pipe(z.array(addressLike()));
|
|
27
|
-
export const optionalAddressArrayLike = () => stringArrayLike()
|
|
28
|
-
.pipe(z.array(addressLike()))
|
|
29
|
-
.optional()
|
|
30
|
-
.transform(v => (v?.length ? v : undefined));
|
package/dist/sleep.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function sleep(ms: number): Promise<unknown>;
|
package/dist/sleep.js
DELETED
package/dist/uncensorMap.d.ts
DELETED
package/dist/uncensorMap.js
DELETED
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
import { z } from "zod/v4";
|
|
2
|
-
export declare const WhitelistItemsSchema: z.ZodObject<{
|
|
3
|
-
network: z.ZodEnum<{
|
|
4
|
-
Mainnet: "Mainnet";
|
|
5
|
-
Arbitrum: "Arbitrum";
|
|
6
|
-
Optimism: "Optimism";
|
|
7
|
-
Base: "Base";
|
|
8
|
-
Sonic: "Sonic";
|
|
9
|
-
MegaETH: "MegaETH";
|
|
10
|
-
Monad: "Monad";
|
|
11
|
-
Berachain: "Berachain";
|
|
12
|
-
Avalanche: "Avalanche";
|
|
13
|
-
BNB: "BNB";
|
|
14
|
-
WorldChain: "WorldChain";
|
|
15
|
-
Etherlink: "Etherlink";
|
|
16
|
-
Hemi: "Hemi";
|
|
17
|
-
Lisk: "Lisk";
|
|
18
|
-
Plasma: "Plasma";
|
|
19
|
-
Somnia: "Somnia";
|
|
20
|
-
}>;
|
|
21
|
-
addresses: z.ZodArray<z.ZodPipe<z.ZodString, z.ZodTransform<`0x${string}`, string>>>;
|
|
22
|
-
reason: z.ZodDefault<z.ZodString>;
|
|
23
|
-
issue: z.ZodOptional<z.ZodString>;
|
|
24
|
-
expiresAt: z.ZodOptional<z.ZodNumber>;
|
|
25
|
-
}, z.core.$strip>;
|
|
26
|
-
export type WhitelistItemsSchema = z.infer<typeof WhitelistItemsSchema>;
|
|
27
|
-
export declare const WhitelistItemSchema: z.ZodObject<{
|
|
28
|
-
network: z.ZodEnum<{
|
|
29
|
-
Mainnet: "Mainnet";
|
|
30
|
-
Arbitrum: "Arbitrum";
|
|
31
|
-
Optimism: "Optimism";
|
|
32
|
-
Base: "Base";
|
|
33
|
-
Sonic: "Sonic";
|
|
34
|
-
MegaETH: "MegaETH";
|
|
35
|
-
Monad: "Monad";
|
|
36
|
-
Berachain: "Berachain";
|
|
37
|
-
Avalanche: "Avalanche";
|
|
38
|
-
BNB: "BNB";
|
|
39
|
-
WorldChain: "WorldChain";
|
|
40
|
-
Etherlink: "Etherlink";
|
|
41
|
-
Hemi: "Hemi";
|
|
42
|
-
Lisk: "Lisk";
|
|
43
|
-
Plasma: "Plasma";
|
|
44
|
-
Somnia: "Somnia";
|
|
45
|
-
}>;
|
|
46
|
-
category: z.ZodString;
|
|
47
|
-
address: z.ZodPipe<z.ZodString, z.ZodTransform<`0x${string}`, string>>;
|
|
48
|
-
reason: z.ZodDefault<z.ZodString>;
|
|
49
|
-
issue: z.ZodOptional<z.ZodString>;
|
|
50
|
-
contractType: z.ZodOptional<z.ZodString>;
|
|
51
|
-
createdAt: z.ZodNumber;
|
|
52
|
-
expiresAt: z.ZodOptional<z.ZodNumber>;
|
|
53
|
-
}, z.core.$strip>;
|
|
54
|
-
export type WhitelistItemSchema = z.infer<typeof WhitelistItemSchema>;
|
package/dist/whitelist-schema.js
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
// Mirror of packages/shared/src/whitelist-schema.ts; keep in sync.
|
|
2
|
-
import { NetworkType } from "@gearbox-protocol/sdk";
|
|
3
|
-
import { z } from "zod/v4";
|
|
4
|
-
import { addressLike } from "./schema-primitives.js";
|
|
5
|
-
export const WhitelistItemsSchema = z.object({
|
|
6
|
-
network: NetworkType,
|
|
7
|
-
addresses: z.array(addressLike()).min(1),
|
|
8
|
-
reason: z.string().default(""),
|
|
9
|
-
issue: z.string().optional(),
|
|
10
|
-
expiresAt: z.number().optional(),
|
|
11
|
-
});
|
|
12
|
-
export const WhitelistItemSchema = z.object({
|
|
13
|
-
network: NetworkType,
|
|
14
|
-
category: z.string(),
|
|
15
|
-
address: addressLike(),
|
|
16
|
-
reason: z.string().default(""),
|
|
17
|
-
issue: z.string().optional(),
|
|
18
|
-
contractType: z.string().optional(),
|
|
19
|
-
createdAt: z.number(),
|
|
20
|
-
expiresAt: z.number().optional(),
|
|
21
|
-
});
|