@settlemint/sdk-cli 2.4.1-maina8cce418 → 2.4.1-mainc7da27d9
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/cli.js +362 -245
- package/dist/cli.js.map +20 -19
- package/package.json +7 -6
package/dist/cli.js
CHANGED
@@ -44630,7 +44630,7 @@ var require_util = __commonJS((exports) => {
|
|
44630
44630
|
return path7;
|
44631
44631
|
}
|
44632
44632
|
exports.normalize = normalize4;
|
44633
|
-
function
|
44633
|
+
function join5(aRoot, aPath) {
|
44634
44634
|
if (aRoot === "") {
|
44635
44635
|
aRoot = ".";
|
44636
44636
|
}
|
@@ -44662,7 +44662,7 @@ var require_util = __commonJS((exports) => {
|
|
44662
44662
|
}
|
44663
44663
|
return joined;
|
44664
44664
|
}
|
44665
|
-
exports.join =
|
44665
|
+
exports.join = join5;
|
44666
44666
|
exports.isAbsolute = function(aPath) {
|
44667
44667
|
return aPath.charAt(0) === "/" || urlRegexp.test(aPath);
|
44668
44668
|
};
|
@@ -44835,7 +44835,7 @@ var require_util = __commonJS((exports) => {
|
|
44835
44835
|
parsed.path = parsed.path.substring(0, index + 1);
|
44836
44836
|
}
|
44837
44837
|
}
|
44838
|
-
sourceURL =
|
44838
|
+
sourceURL = join5(urlGenerate(parsed), sourceURL);
|
44839
44839
|
}
|
44840
44840
|
return normalize4(sourceURL);
|
44841
44841
|
}
|
@@ -48913,7 +48913,7 @@ var require_typescript = __commonJS((exports, module) => {
|
|
48913
48913
|
walkUpParenthesizedTypesAndGetParentAndChild: () => walkUpParenthesizedTypesAndGetParentAndChild,
|
48914
48914
|
whitespaceOrMapCommentRegExp: () => whitespaceOrMapCommentRegExp,
|
48915
48915
|
writeCommentRange: () => writeCommentRange,
|
48916
|
-
writeFile: () =>
|
48916
|
+
writeFile: () => writeFile3,
|
48917
48917
|
writeFileEnsuringDirectories: () => writeFileEnsuringDirectories,
|
48918
48918
|
zipWith: () => zipWith
|
48919
48919
|
});
|
@@ -66192,7 +66192,7 @@ ${lanes.join(`
|
|
66192
66192
|
sourceFilePath = isSourceFileInCommonSourceDirectory ? sourceFilePath.substring(commonSourceDirectory.length) : sourceFilePath;
|
66193
66193
|
return combinePaths(newDirPath, sourceFilePath);
|
66194
66194
|
}
|
66195
|
-
function
|
66195
|
+
function writeFile3(host, diagnostics, fileName, text, writeByteOrderMark, sourceFiles, data) {
|
66196
66196
|
host.writeFile(fileName, text, writeByteOrderMark, (hostErrorMessage) => {
|
66197
66197
|
diagnostics.add(createCompilerDiagnostic(Diagnostics.Could_not_write_file_0_Colon_1, fileName, hostErrorMessage));
|
66198
66198
|
}, sourceFiles, data);
|
@@ -148136,7 +148136,7 @@ ${lanes.join(`
|
|
148136
148136
|
return;
|
148137
148137
|
}
|
148138
148138
|
const buildInfo = host.getBuildInfo() || { version: version4 };
|
148139
|
-
|
148139
|
+
writeFile3(host, emitterDiagnostics, buildInfoPath, getBuildInfoText(buildInfo), false, undefined, { buildInfo });
|
148140
148140
|
emittedFilesList == null || emittedFilesList.push(buildInfoPath);
|
148141
148141
|
}
|
148142
148142
|
function emitJsFileOrBundle(sourceFileOrBundle, jsFilePath, sourceMapFilePath) {
|
@@ -148295,14 +148295,14 @@ ${lanes.join(`
|
|
148295
148295
|
}
|
148296
148296
|
if (sourceMapFilePath) {
|
148297
148297
|
const sourceMap = sourceMapGenerator.toString();
|
148298
|
-
|
148298
|
+
writeFile3(host, emitterDiagnostics, sourceMapFilePath, sourceMap, false, sourceFiles);
|
148299
148299
|
}
|
148300
148300
|
} else {
|
148301
148301
|
writer.writeLine();
|
148302
148302
|
}
|
148303
148303
|
const text = writer.getText();
|
148304
148304
|
const data = { sourceMapUrlPos, diagnostics: transform22.diagnostics };
|
148305
|
-
|
148305
|
+
writeFile3(host, emitterDiagnostics, jsFilePath, text, !!compilerOptions.emitBOM, sourceFiles, data);
|
148306
148306
|
writer.clear();
|
148307
148307
|
return !data.skippedDtsWrite;
|
148308
148308
|
}
|
@@ -204176,7 +204176,7 @@ ${options.prefix}` : `
|
|
204176
204176
|
walkUpParenthesizedTypesAndGetParentAndChild: () => walkUpParenthesizedTypesAndGetParentAndChild,
|
204177
204177
|
whitespaceOrMapCommentRegExp: () => whitespaceOrMapCommentRegExp,
|
204178
204178
|
writeCommentRange: () => writeCommentRange,
|
204179
|
-
writeFile: () =>
|
204179
|
+
writeFile: () => writeFile3,
|
204180
204180
|
writeFileEnsuringDirectories: () => writeFileEnsuringDirectories,
|
204181
204181
|
zipWith: () => zipWith
|
204182
204182
|
});
|
@@ -231623,7 +231623,7 @@ function size(value4) {
|
|
231623
231623
|
var init_size = () => {};
|
231624
231624
|
|
231625
231625
|
// ../../node_modules/viem/_esm/errors/version.js
|
231626
|
-
var version5 = "2.31.
|
231626
|
+
var version5 = "2.31.7";
|
231627
231627
|
|
231628
231628
|
// ../../node_modules/viem/_esm/errors/base.js
|
231629
231629
|
function walk(err, fn) {
|
@@ -265083,7 +265083,7 @@ function pruneCurrentEnv(currentEnv, env2) {
|
|
265083
265083
|
var package_default = {
|
265084
265084
|
name: "@settlemint/sdk-cli",
|
265085
265085
|
description: "Command-line interface for SettleMint SDK, providing development tools and project management capabilities",
|
265086
|
-
version: "2.4.1-
|
265086
|
+
version: "2.4.1-mainc7da27d9",
|
265087
265087
|
type: "module",
|
265088
265088
|
private: false,
|
265089
265089
|
license: "FSL-1.1-MIT",
|
@@ -265134,10 +265134,11 @@ var package_default = {
|
|
265134
265134
|
"@inquirer/input": "4.2.0",
|
265135
265135
|
"@inquirer/password": "4.0.16",
|
265136
265136
|
"@inquirer/select": "4.2.4",
|
265137
|
-
"@settlemint/sdk-
|
265138
|
-
"@settlemint/sdk-
|
265139
|
-
"@settlemint/sdk-
|
265140
|
-
"@
|
265137
|
+
"@settlemint/sdk-hasura": "2.4.1-mainc7da27d9",
|
265138
|
+
"@settlemint/sdk-js": "2.4.1-mainc7da27d9",
|
265139
|
+
"@settlemint/sdk-utils": "2.4.1-mainc7da27d9",
|
265140
|
+
"@settlemint/sdk-viem": "2.4.1-mainc7da27d9",
|
265141
|
+
"@types/node": "24.0.12",
|
265141
265142
|
"@types/semver": "7.7.0",
|
265142
265143
|
"@types/which": "3.0.4",
|
265143
265144
|
"get-tsconfig": "4.10.1",
|
@@ -265145,7 +265146,7 @@ var package_default = {
|
|
265145
265146
|
"is-in-ci": "1.0.0",
|
265146
265147
|
semver: "7.7.2",
|
265147
265148
|
slugify: "1.6.6",
|
265148
|
-
viem: "2.31.
|
265149
|
+
viem: "2.31.7",
|
265149
265150
|
which: "5.0.0",
|
265150
265151
|
yaml: "2.8.0",
|
265151
265152
|
yoctocolors: "2.1.1"
|
@@ -301778,17 +301779,20 @@ async function isSdkInstalledGlobally() {
|
|
301778
301779
|
}
|
301779
301780
|
}
|
301780
301781
|
|
301782
|
+
// ../../node_modules/@gql.tada/cli-utils/dist/gql-tada-cli.mjs
|
301783
|
+
init_index_chunk();
|
301784
|
+
|
301781
301785
|
// src/commands/codegen/utils/write-template.ts
|
301782
|
-
import { mkdir as
|
301783
|
-
import { join as
|
301786
|
+
import { mkdir as mkdir3, writeFile as writeFile4 } from "node:fs/promises";
|
301787
|
+
import { join as join6 } from "node:path";
|
301784
301788
|
async function writeTemplate(template, directory, filename) {
|
301785
301789
|
const projectDir = await projectRoot3();
|
301786
|
-
const hasSrcDir = await exists3(
|
301787
|
-
const basePath = hasSrcDir ?
|
301788
|
-
const codegenDir =
|
301789
|
-
await
|
301790
|
-
const filePath =
|
301791
|
-
await
|
301790
|
+
const hasSrcDir = await exists3(join6(projectDir, "src"));
|
301791
|
+
const basePath = hasSrcDir ? join6(projectDir, "src") : projectDir;
|
301792
|
+
const codegenDir = join6(basePath, directory);
|
301793
|
+
await mkdir3(codegenDir, { recursive: true });
|
301794
|
+
const filePath = join6(codegenDir, filename);
|
301795
|
+
await writeFile4(filePath, template, "utf8");
|
301792
301796
|
}
|
301793
301797
|
|
301794
301798
|
// src/error/missing-config-error.ts
|
@@ -301843,9 +301847,6 @@ var getApplicationOrPersonalAccessToken = async ({
|
|
301843
301847
|
return prefer === "personal" ? missingPersonalAccessTokenError() : missingAccessTokenError(!!personalAccessToken);
|
301844
301848
|
};
|
301845
301849
|
|
301846
|
-
// ../../node_modules/@gql.tada/cli-utils/dist/gql-tada-cli.mjs
|
301847
|
-
init_index_chunk();
|
301848
|
-
|
301849
301850
|
// src/commands/codegen/codegen-hasura.ts
|
301850
301851
|
var PACKAGE_NAME = "@settlemint/sdk-hasura";
|
301851
301852
|
async function codegenHasura(env2) {
|
@@ -301867,7 +301868,7 @@ async function codegenHasura(env2) {
|
|
301867
301868
|
...accessToken ? { "x-auth-token": accessToken } : {}
|
301868
301869
|
}
|
301869
301870
|
});
|
301870
|
-
const hasuraTemplate = `import { createHasuraClient } from "${PACKAGE_NAME}";
|
301871
|
+
const hasuraTemplate = `import { createHasuraClient, createHasuraMetadataClient } from "${PACKAGE_NAME}";
|
301871
301872
|
import type { introspection } from "@schemas/hasura-env";
|
301872
301873
|
import { createLogger, requestLogger, type LogLevel } from '@settlemint/sdk-utils/logging';
|
301873
301874
|
|
@@ -301894,7 +301895,13 @@ export const { client: hasuraClient, graphql: hasuraGraphql } = createHasuraClie
|
|
301894
301895
|
adminSecret: process.env.SETTLEMINT_HASURA_ADMIN_SECRET!,
|
301895
301896
|
}, {
|
301896
301897
|
fetch: requestLogger(logger, "hasura", fetch) as typeof fetch,
|
301897
|
-
})
|
301898
|
+
});
|
301899
|
+
|
301900
|
+
export const hasuraMetadataClient = createHasuraMetadataClient({
|
301901
|
+
instance: process.env.SETTLEMINT_HASURA_ENDPOINT!,
|
301902
|
+
accessToken: process.env.SETTLEMINT_ACCESS_TOKEN,
|
301903
|
+
adminSecret: process.env.SETTLEMINT_HASURA_ADMIN_SECRET!,
|
301904
|
+
}, logger);`;
|
301898
301905
|
await writeTemplate(hasuraTemplate, "/lib/settlemint", "hasura.ts");
|
301899
301906
|
} else {
|
301900
301907
|
note("[Codegen] Missing required Hasura environment variables", "warn");
|
@@ -301956,7 +301963,7 @@ export const { client: portalClient, graphql: portalGraphql } = createPortalClie
|
|
301956
301963
|
fetch: requestLogger(logger, "portal", fetch) as typeof fetch,
|
301957
301964
|
});
|
301958
301965
|
|
301959
|
-
export const
|
301966
|
+
export const portalWebsocketClient = getWebsocketClient({
|
301960
301967
|
portalGraphqlEndpoint: process.env.SETTLEMINT_PORTAL_GRAPHQL_ENDPOINT!,
|
301961
301968
|
accessToken: process.env.SETTLEMINT_ACCESS_TOKEN,
|
301962
301969
|
});
|
@@ -301968,16 +301975,6 @@ export const getPortalWebsocketClient = getWebsocketClient({
|
|
301968
301975
|
}
|
301969
301976
|
}
|
301970
301977
|
|
301971
|
-
// src/commands/codegen/utils/get-variable-name.ts
|
301972
|
-
function getVariableName(name3) {
|
301973
|
-
return name3.split(/[^a-zA-Z0-9]/g).map((word2, index) => (index === 0 ? word2.charAt(0).toLowerCase() : word2.charAt(0).toUpperCase()) + word2.slice(1)).join("");
|
301974
|
-
}
|
301975
|
-
|
301976
|
-
// src/utils/subgraph/subgraph-name.ts
|
301977
|
-
function getSubgraphName(endpoint) {
|
301978
|
-
return endpoint.split("/").pop();
|
301979
|
-
}
|
301980
|
-
|
301981
301978
|
// ../utils/dist/index.js
|
301982
301979
|
var maskTokens5 = (output) => {
|
301983
301980
|
return output.replace(/sm_(pat|aat|sat)_[0-9a-zA-Z]+/g, "***");
|
@@ -302076,10 +302073,26 @@ function replaceUnderscoresAndHyphensWithSpaces(s6) {
|
|
302076
302073
|
}
|
302077
302074
|
function extractBaseUrlBeforeSegment(baseUrl, pathSegment) {
|
302078
302075
|
const url4 = new URL(baseUrl);
|
302076
|
+
if (pathSegment.trim() === "") {
|
302077
|
+
return url4.toString();
|
302078
|
+
}
|
302079
302079
|
const segmentIndex = url4.pathname.indexOf(pathSegment);
|
302080
302080
|
return url4.origin + (segmentIndex >= 0 ? url4.pathname.substring(0, segmentIndex) : url4.pathname);
|
302081
302081
|
}
|
302082
302082
|
|
302083
|
+
// src/commands/codegen/utils/get-variable-name.ts
|
302084
|
+
function getVariableName(name3) {
|
302085
|
+
return name3.split(/[^a-zA-Z0-9]/g).map((word2, index) => (index === 0 ? word2.charAt(0).toLowerCase() : word2.charAt(0).toUpperCase()) + word2.slice(1)).join("");
|
302086
|
+
}
|
302087
|
+
|
302088
|
+
// src/utils/subgraph/subgraph-name.ts
|
302089
|
+
function getSubgraphName(endpoint) {
|
302090
|
+
if (endpoint.toLowerCase().includes("/subgraphs/")) {
|
302091
|
+
return endpoint.split("/").pop();
|
302092
|
+
}
|
302093
|
+
return;
|
302094
|
+
}
|
302095
|
+
|
302083
302096
|
// src/commands/codegen/codegen-the-graph.ts
|
302084
302097
|
var PACKAGE_NAME3 = "@settlemint/sdk-thegraph";
|
302085
302098
|
async function codegenTheGraph(env2, subgraphNames) {
|
@@ -302113,6 +302126,9 @@ async function codegenTheGraph(env2, subgraphNames) {
|
|
302113
302126
|
template.push("", "const logger = createLogger({ level: process.env.SETTLEMINT_LOG_LEVEL as LogLevel });");
|
302114
302127
|
for (const gqlEndpoint of toGenerate) {
|
302115
302128
|
const name3 = getSubgraphName(gqlEndpoint);
|
302129
|
+
if (!name3) {
|
302130
|
+
continue;
|
302131
|
+
}
|
302116
302132
|
const introspectionVariable = getVariableName(`${name3}Introspection`);
|
302117
302133
|
note(`Generating TheGraph subgraph ${name3}`);
|
302118
302134
|
await generateSchema({
|
@@ -302175,45 +302191,6 @@ export const theGraphGraphql = ${graphqlVariable};
|
|
302175
302191
|
// src/commands/codegen/codegen-tsconfig.ts
|
302176
302192
|
import { writeFile as writeFile5 } from "node:fs/promises";
|
302177
302193
|
|
302178
|
-
// src/commands/codegen/utils/test-gql-endpoint.ts
|
302179
|
-
async function testGqlEndpoint({
|
302180
|
-
accessToken,
|
302181
|
-
hasuraAdminSecret,
|
302182
|
-
gqlEndpoint,
|
302183
|
-
isHasura = false
|
302184
|
-
}) {
|
302185
|
-
if (!gqlEndpoint) {
|
302186
|
-
return false;
|
302187
|
-
}
|
302188
|
-
try {
|
302189
|
-
await graphqlFetchWithRetry(gqlEndpoint, {
|
302190
|
-
method: "POST",
|
302191
|
-
headers: appendHeaders({
|
302192
|
-
"Content-Type": "application/json",
|
302193
|
-
...isHasura ? { "x-hasura-admin-secret": hasuraAdminSecret ?? "" } : {}
|
302194
|
-
}, {
|
302195
|
-
"x-auth-token": accessToken
|
302196
|
-
}),
|
302197
|
-
body: JSON.stringify({
|
302198
|
-
query: `
|
302199
|
-
query {
|
302200
|
-
__schema {
|
302201
|
-
types {
|
302202
|
-
name
|
302203
|
-
}
|
302204
|
-
}
|
302205
|
-
}
|
302206
|
-
`
|
302207
|
-
})
|
302208
|
-
});
|
302209
|
-
return true;
|
302210
|
-
} catch (err) {
|
302211
|
-
const error44 = err;
|
302212
|
-
note(`GraphQL endpoint '${gqlEndpoint}' is not reachable: ${error44.message}`, "warn");
|
302213
|
-
return false;
|
302214
|
-
}
|
302215
|
-
}
|
302216
|
-
|
302217
302194
|
// ../../node_modules/get-tsconfig/dist/index.mjs
|
302218
302195
|
import m6 from "node:path";
|
302219
302196
|
import te3 from "node:fs";
|
@@ -303105,6 +303082,45 @@ var Xe2 = o7(({ config: e10, path: t8 }, s7 = Oe2()) => {
|
|
303105
303082
|
};
|
303106
303083
|
}, "createFilesMatcher");
|
303107
303084
|
|
303085
|
+
// src/commands/codegen/utils/test-gql-endpoint.ts
|
303086
|
+
async function testGqlEndpoint({
|
303087
|
+
accessToken,
|
303088
|
+
hasuraAdminSecret,
|
303089
|
+
gqlEndpoint,
|
303090
|
+
isHasura = false
|
303091
|
+
}) {
|
303092
|
+
if (!gqlEndpoint) {
|
303093
|
+
return false;
|
303094
|
+
}
|
303095
|
+
try {
|
303096
|
+
await graphqlFetchWithRetry(gqlEndpoint, {
|
303097
|
+
method: "POST",
|
303098
|
+
headers: appendHeaders({
|
303099
|
+
"Content-Type": "application/json",
|
303100
|
+
...isHasura ? { "x-hasura-admin-secret": hasuraAdminSecret ?? "" } : {}
|
303101
|
+
}, {
|
303102
|
+
"x-auth-token": accessToken
|
303103
|
+
}),
|
303104
|
+
body: JSON.stringify({
|
303105
|
+
query: `
|
303106
|
+
query {
|
303107
|
+
__schema {
|
303108
|
+
types {
|
303109
|
+
name
|
303110
|
+
}
|
303111
|
+
}
|
303112
|
+
}
|
303113
|
+
`
|
303114
|
+
})
|
303115
|
+
});
|
303116
|
+
return true;
|
303117
|
+
} catch (err) {
|
303118
|
+
const error44 = err;
|
303119
|
+
note(`GraphQL endpoint '${gqlEndpoint}' is not reachable: ${error44.message}`, "warn");
|
303120
|
+
return false;
|
303121
|
+
}
|
303122
|
+
}
|
303123
|
+
|
303108
303124
|
// src/commands/codegen/codegen-tsconfig.ts
|
303109
303125
|
async function codegenTsconfig(env2, thegraphSubgraphNames) {
|
303110
303126
|
const tsconfig = he4();
|
@@ -303182,13 +303198,16 @@ async function codegenTsconfig(env2, thegraphSubgraphNames) {
|
|
303182
303198
|
] : [],
|
303183
303199
|
...thegraph.filter((endpoint) => endpoint.success).map(({ endpoint }) => {
|
303184
303200
|
const name3 = getSubgraphName(endpoint);
|
303201
|
+
if (!name3) {
|
303202
|
+
return;
|
303203
|
+
}
|
303185
303204
|
return {
|
303186
303205
|
name: `thegraph-${name3}`,
|
303187
303206
|
schema: `the-graph-schema-${name3}.graphql`,
|
303188
303207
|
tadaOutputLocation: `the-graph-env-${name3}.d.ts`,
|
303189
303208
|
tadaTurboLocation: `the-graph-cache-${name3}.d.ts`
|
303190
303209
|
};
|
303191
|
-
}),
|
303210
|
+
}).filter((schema) => schema !== undefined),
|
303192
303211
|
...portal ? [
|
303193
303212
|
{
|
303194
303213
|
name: "portal",
|
@@ -320667,6 +320686,118 @@ function codegenCommand() {
|
|
320667
320686
|
});
|
320668
320687
|
}
|
320669
320688
|
|
320689
|
+
// ../utils/dist/logging.js
|
320690
|
+
var maskTokens6 = (output) => {
|
320691
|
+
return output.replace(/sm_(pat|aat|sat)_[0-9a-zA-Z]+/g, "***");
|
320692
|
+
};
|
320693
|
+
function createLogger3(options = {}) {
|
320694
|
+
const { level = "warn", prefix = "" } = options;
|
320695
|
+
const logLevels = {
|
320696
|
+
debug: 0,
|
320697
|
+
info: 1,
|
320698
|
+
warn: 2,
|
320699
|
+
error: 3,
|
320700
|
+
none: 4
|
320701
|
+
};
|
320702
|
+
const currentLevelValue = logLevels[level];
|
320703
|
+
const formatArgs = (args) => {
|
320704
|
+
if (args.length === 0 || args.every((arg) => arg === undefined || arg === null)) {
|
320705
|
+
return "";
|
320706
|
+
}
|
320707
|
+
const formatted = args.map((arg) => {
|
320708
|
+
if (arg instanceof Error) {
|
320709
|
+
return `
|
320710
|
+
${arg.stack || arg.message}`;
|
320711
|
+
}
|
320712
|
+
if (typeof arg === "object" && arg !== null) {
|
320713
|
+
return `
|
320714
|
+
${JSON.stringify(arg, null, 2)}`;
|
320715
|
+
}
|
320716
|
+
return ` ${String(arg)}`;
|
320717
|
+
}).join("");
|
320718
|
+
return `, args:${formatted}`;
|
320719
|
+
};
|
320720
|
+
const shouldLog = (level$1) => {
|
320721
|
+
return logLevels[level$1] >= currentLevelValue;
|
320722
|
+
};
|
320723
|
+
return {
|
320724
|
+
debug: (message, ...args) => {
|
320725
|
+
if (shouldLog("debug")) {
|
320726
|
+
console.debug(`\x1B[32m${prefix}[DEBUG] ${maskTokens6(message)}${maskTokens6(formatArgs(args))}\x1B[0m`);
|
320727
|
+
}
|
320728
|
+
},
|
320729
|
+
info: (message, ...args) => {
|
320730
|
+
if (shouldLog("info")) {
|
320731
|
+
console.info(`\x1B[34m${prefix}[INFO] ${maskTokens6(message)}${maskTokens6(formatArgs(args))}\x1B[0m`);
|
320732
|
+
}
|
320733
|
+
},
|
320734
|
+
warn: (message, ...args) => {
|
320735
|
+
if (shouldLog("warn")) {
|
320736
|
+
console.warn(`\x1B[33m${prefix}[WARN] ${maskTokens6(message)}${maskTokens6(formatArgs(args))}\x1B[0m`);
|
320737
|
+
}
|
320738
|
+
},
|
320739
|
+
error: (message, ...args) => {
|
320740
|
+
if (shouldLog("error")) {
|
320741
|
+
console.error(`\x1B[31m${prefix}[ERROR] ${maskTokens6(message)}${maskTokens6(formatArgs(args))}\x1B[0m`);
|
320742
|
+
}
|
320743
|
+
}
|
320744
|
+
};
|
320745
|
+
}
|
320746
|
+
var logger3 = createLogger3();
|
320747
|
+
function truncate(value4, maxLength) {
|
320748
|
+
if (value4.length <= maxLength) {
|
320749
|
+
return value4;
|
320750
|
+
}
|
320751
|
+
return `${value4.slice(0, maxLength)}...`;
|
320752
|
+
}
|
320753
|
+
var WARNING_THRESHOLD = 500;
|
320754
|
+
var TRUNCATE_LENGTH = 50;
|
320755
|
+
function requestLogger(logger$1, name3, fn) {
|
320756
|
+
return async (...args) => {
|
320757
|
+
const start3 = Date.now();
|
320758
|
+
try {
|
320759
|
+
return await fn(...args);
|
320760
|
+
} finally {
|
320761
|
+
const end = Date.now();
|
320762
|
+
const duration6 = end - start3;
|
320763
|
+
const body = extractInfoFromBody(args[1]?.body ?? "{}");
|
320764
|
+
const message = `${name3} path: ${args[0]}, took ${formatDuration(duration6)}`;
|
320765
|
+
if (duration6 > WARNING_THRESHOLD) {
|
320766
|
+
logger$1.warn(message, body);
|
320767
|
+
} else {
|
320768
|
+
logger$1.info(message, body);
|
320769
|
+
}
|
320770
|
+
}
|
320771
|
+
};
|
320772
|
+
}
|
320773
|
+
function formatDuration(duration6) {
|
320774
|
+
return duration6 < 1000 ? `${duration6}ms` : `${(duration6 / 1000).toFixed(3)}s`;
|
320775
|
+
}
|
320776
|
+
function extractInfoFromBody(body) {
|
320777
|
+
try {
|
320778
|
+
const parsedBody = typeof body === "string" ? JSON.parse(body) : body;
|
320779
|
+
if (parsedBody === null || parsedBody === undefined || Object.keys(parsedBody).length === 0) {
|
320780
|
+
return null;
|
320781
|
+
}
|
320782
|
+
const dataToKeep = {};
|
320783
|
+
if ("query" in parsedBody) {
|
320784
|
+
dataToKeep.query = truncate(parsedBody.query, TRUNCATE_LENGTH);
|
320785
|
+
}
|
320786
|
+
if ("variables" in parsedBody) {
|
320787
|
+
dataToKeep.variables = truncate(JSON.stringify(parsedBody.variables), TRUNCATE_LENGTH);
|
320788
|
+
}
|
320789
|
+
if ("operationName" in parsedBody) {
|
320790
|
+
dataToKeep.operationName = truncate(parsedBody.operationName, TRUNCATE_LENGTH);
|
320791
|
+
}
|
320792
|
+
if (Object.keys(dataToKeep).length > 0) {
|
320793
|
+
return JSON.stringify(dataToKeep);
|
320794
|
+
}
|
320795
|
+
return truncate(JSON.stringify(parsedBody || "{}"), TRUNCATE_LENGTH);
|
320796
|
+
} catch {
|
320797
|
+
return "{}";
|
320798
|
+
}
|
320799
|
+
}
|
320800
|
+
|
320670
320801
|
// ../../node_modules/@inquirer/confirm/dist/esm/index.js
|
320671
320802
|
function getBooleanValue(value4, defaultValue) {
|
320672
320803
|
let answer = defaultValue !== false;
|
@@ -320963,35 +321094,6 @@ function isRunning(service) {
|
|
320963
321094
|
return service === undefined || service?.status === "COMPLETED";
|
320964
321095
|
}
|
320965
321096
|
|
320966
|
-
// src/prompts/cluster-service/blockchain-node-or-load-balancer.prompt.ts
|
320967
|
-
async function blockchainNodeOrLoadBalancerPrompt({
|
320968
|
-
env: env2,
|
320969
|
-
nodes,
|
320970
|
-
loadBalancers,
|
320971
|
-
accept,
|
320972
|
-
singleOptionMessage,
|
320973
|
-
promptMessage,
|
320974
|
-
filterRunningOnly = false,
|
320975
|
-
isRequired = false
|
320976
|
-
}) {
|
320977
|
-
return servicePrompt({
|
320978
|
-
env: env2,
|
320979
|
-
services: [...loadBalancers, ...nodes],
|
320980
|
-
accept,
|
320981
|
-
envKey: "SETTLEMINT_BLOCKCHAIN_NODE_OR_LOAD_BALANCER",
|
320982
|
-
isRequired,
|
320983
|
-
defaultHandler: async ({ defaultService: defaultNode, choices }) => {
|
320984
|
-
const filteredChoices = filterRunningOnly ? choices.filter(({ value: node }) => isRunning(node)) : choices;
|
320985
|
-
return esm_default3({
|
320986
|
-
message: promptMessage ?? "Which blockchain node or load balancer do you want to connect to?",
|
320987
|
-
choices: filteredChoices,
|
320988
|
-
default: defaultNode
|
320989
|
-
});
|
320990
|
-
},
|
320991
|
-
singleOptionMessage
|
320992
|
-
});
|
320993
|
-
}
|
320994
|
-
|
320995
321097
|
// src/prompts/cluster-service/blockchain-node.prompt.ts
|
320996
321098
|
async function blockchainNodePrompt({
|
320997
321099
|
env: env2,
|
@@ -321032,6 +321134,35 @@ async function blockchainNodePrompt({
|
|
321032
321134
|
});
|
321033
321135
|
}
|
321034
321136
|
|
321137
|
+
// src/prompts/cluster-service/blockchain-node-or-load-balancer.prompt.ts
|
321138
|
+
async function blockchainNodeOrLoadBalancerPrompt({
|
321139
|
+
env: env2,
|
321140
|
+
nodes,
|
321141
|
+
loadBalancers,
|
321142
|
+
accept,
|
321143
|
+
singleOptionMessage,
|
321144
|
+
promptMessage,
|
321145
|
+
filterRunningOnly = false,
|
321146
|
+
isRequired = false
|
321147
|
+
}) {
|
321148
|
+
return servicePrompt({
|
321149
|
+
env: env2,
|
321150
|
+
services: [...loadBalancers, ...nodes],
|
321151
|
+
accept,
|
321152
|
+
envKey: "SETTLEMINT_BLOCKCHAIN_NODE_OR_LOAD_BALANCER",
|
321153
|
+
isRequired,
|
321154
|
+
defaultHandler: async ({ defaultService: defaultNode, choices }) => {
|
321155
|
+
const filteredChoices = filterRunningOnly ? choices.filter(({ value: node }) => isRunning(node)) : choices;
|
321156
|
+
return esm_default3({
|
321157
|
+
message: promptMessage ?? "Which blockchain node or load balancer do you want to connect to?",
|
321158
|
+
choices: filteredChoices,
|
321159
|
+
default: defaultNode
|
321160
|
+
});
|
321161
|
+
},
|
321162
|
+
singleOptionMessage
|
321163
|
+
});
|
321164
|
+
}
|
321165
|
+
|
321035
321166
|
// src/prompts/cluster-service/blockscout.prompt.ts
|
321036
321167
|
async function blockscoutPrompt({
|
321037
321168
|
env: env2,
|
@@ -321505,10 +321636,10 @@ function getBlockchainNetworkChainId(blockchainNetwork) {
|
|
321505
321636
|
}
|
321506
321637
|
|
321507
321638
|
// ../utils/dist/retry.js
|
321508
|
-
var
|
321639
|
+
var maskTokens7 = (output) => {
|
321509
321640
|
return output.replace(/sm_(pat|aat|sat)_[0-9a-zA-Z]+/g, "***");
|
321510
321641
|
};
|
321511
|
-
function
|
321642
|
+
function createLogger4(options = {}) {
|
321512
321643
|
const { level = "warn", prefix = "" } = options;
|
321513
321644
|
const logLevels = {
|
321514
321645
|
debug: 0,
|
@@ -321541,27 +321672,27 @@ ${JSON.stringify(arg, null, 2)}`;
|
|
321541
321672
|
return {
|
321542
321673
|
debug: (message, ...args) => {
|
321543
321674
|
if (shouldLog("debug")) {
|
321544
|
-
console.debug(`\x1B[32m${prefix}[DEBUG] ${
|
321675
|
+
console.debug(`\x1B[32m${prefix}[DEBUG] ${maskTokens7(message)}${maskTokens7(formatArgs(args))}\x1B[0m`);
|
321545
321676
|
}
|
321546
321677
|
},
|
321547
321678
|
info: (message, ...args) => {
|
321548
321679
|
if (shouldLog("info")) {
|
321549
|
-
console.info(`\x1B[34m${prefix}[INFO] ${
|
321680
|
+
console.info(`\x1B[34m${prefix}[INFO] ${maskTokens7(message)}${maskTokens7(formatArgs(args))}\x1B[0m`);
|
321550
321681
|
}
|
321551
321682
|
},
|
321552
321683
|
warn: (message, ...args) => {
|
321553
321684
|
if (shouldLog("warn")) {
|
321554
|
-
console.warn(`\x1B[33m${prefix}[WARN] ${
|
321685
|
+
console.warn(`\x1B[33m${prefix}[WARN] ${maskTokens7(message)}${maskTokens7(formatArgs(args))}\x1B[0m`);
|
321555
321686
|
}
|
321556
321687
|
},
|
321557
321688
|
error: (message, ...args) => {
|
321558
321689
|
if (shouldLog("error")) {
|
321559
|
-
console.error(`\x1B[31m${prefix}[ERROR] ${
|
321690
|
+
console.error(`\x1B[31m${prefix}[ERROR] ${maskTokens7(message)}${maskTokens7(formatArgs(args))}\x1B[0m`);
|
321560
321691
|
}
|
321561
321692
|
}
|
321562
321693
|
};
|
321563
321694
|
}
|
321564
|
-
var
|
321695
|
+
var logger4 = createLogger4();
|
321565
321696
|
async function retryWhenFailed3(fn, maxRetries = 5, initialSleepTime = 1000, stopOnError) {
|
321566
321697
|
let retries = 0;
|
321567
321698
|
const maxAttempts = maxRetries + 1;
|
@@ -321582,7 +321713,7 @@ async function retryWhenFailed3(fn, maxRetries = 5, initialSleepTime = 1000, sto
|
|
321582
321713
|
const jitterAmount = initialSleepTime * (Math.random() / 10);
|
321583
321714
|
const delay2 = baseDelay + jitterAmount;
|
321584
321715
|
retries += 1;
|
321585
|
-
|
321716
|
+
logger4.warn(`An error occurred ${error45.message}, retrying in ${delay2.toFixed(0)}ms (retry ${retries} of ${maxRetries})...`);
|
321586
321717
|
await new Promise((resolve6) => setTimeout(resolve6, delay2));
|
321587
321718
|
}
|
321588
321719
|
}
|
@@ -321701,6 +321832,9 @@ function getHdPrivateKeyEnv(service) {
|
|
321701
321832
|
// ../utils/dist/url.js
|
321702
321833
|
function extractBaseUrlBeforeSegment2(baseUrl, pathSegment) {
|
321703
321834
|
const url5 = new URL(baseUrl);
|
321835
|
+
if (pathSegment.trim() === "") {
|
321836
|
+
return url5.toString();
|
321837
|
+
}
|
321704
321838
|
const segmentIndex = url5.pathname.indexOf(pathSegment);
|
321705
321839
|
return url5.origin + (segmentIndex >= 0 ? url5.pathname.substring(0, segmentIndex) : url5.pathname);
|
321706
321840
|
}
|
@@ -321737,7 +321871,7 @@ function getTheGraphUrl(subgraphUrls) {
|
|
321737
321871
|
}
|
321738
321872
|
function getTheGraphSubgraphNames(subgraphUrls) {
|
321739
321873
|
if (Array.isArray(subgraphUrls) && subgraphUrls.length > 0) {
|
321740
|
-
return subgraphUrls.map((url5) => getSubgraphName(url5));
|
321874
|
+
return subgraphUrls.map((url5) => getSubgraphName(url5)).filter((name3) => name3 !== undefined);
|
321741
321875
|
}
|
321742
321876
|
return [];
|
321743
321877
|
}
|
@@ -321750,75 +321884,17 @@ function getTheGraphSubgraphUrl(theGraphUrl, subgraphName) {
|
|
321750
321884
|
return url5.toString();
|
321751
321885
|
}
|
321752
321886
|
|
321753
|
-
// ../utils/dist/logging.js
|
321754
|
-
var maskTokens7 = (output) => {
|
321755
|
-
return output.replace(/sm_(pat|aat|sat)_[0-9a-zA-Z]+/g, "***");
|
321756
|
-
};
|
321757
|
-
function createLogger4(options = {}) {
|
321758
|
-
const { level = "warn", prefix = "" } = options;
|
321759
|
-
const logLevels = {
|
321760
|
-
debug: 0,
|
321761
|
-
info: 1,
|
321762
|
-
warn: 2,
|
321763
|
-
error: 3,
|
321764
|
-
none: 4
|
321765
|
-
};
|
321766
|
-
const currentLevelValue = logLevels[level];
|
321767
|
-
const formatArgs = (args) => {
|
321768
|
-
if (args.length === 0 || args.every((arg) => arg === undefined || arg === null)) {
|
321769
|
-
return "";
|
321770
|
-
}
|
321771
|
-
const formatted = args.map((arg) => {
|
321772
|
-
if (arg instanceof Error) {
|
321773
|
-
return `
|
321774
|
-
${arg.stack || arg.message}`;
|
321775
|
-
}
|
321776
|
-
if (typeof arg === "object" && arg !== null) {
|
321777
|
-
return `
|
321778
|
-
${JSON.stringify(arg, null, 2)}`;
|
321779
|
-
}
|
321780
|
-
return ` ${String(arg)}`;
|
321781
|
-
}).join("");
|
321782
|
-
return `, args:${formatted}`;
|
321783
|
-
};
|
321784
|
-
const shouldLog = (level$1) => {
|
321785
|
-
return logLevels[level$1] >= currentLevelValue;
|
321786
|
-
};
|
321787
|
-
return {
|
321788
|
-
debug: (message, ...args) => {
|
321789
|
-
if (shouldLog("debug")) {
|
321790
|
-
console.debug(`\x1B[32m${prefix}[DEBUG] ${maskTokens7(message)}${maskTokens7(formatArgs(args))}\x1B[0m`);
|
321791
|
-
}
|
321792
|
-
},
|
321793
|
-
info: (message, ...args) => {
|
321794
|
-
if (shouldLog("info")) {
|
321795
|
-
console.info(`\x1B[34m${prefix}[INFO] ${maskTokens7(message)}${maskTokens7(formatArgs(args))}\x1B[0m`);
|
321796
|
-
}
|
321797
|
-
},
|
321798
|
-
warn: (message, ...args) => {
|
321799
|
-
if (shouldLog("warn")) {
|
321800
|
-
console.warn(`\x1B[33m${prefix}[WARN] ${maskTokens7(message)}${maskTokens7(formatArgs(args))}\x1B[0m`);
|
321801
|
-
}
|
321802
|
-
},
|
321803
|
-
error: (message, ...args) => {
|
321804
|
-
if (shouldLog("error")) {
|
321805
|
-
console.error(`\x1B[31m${prefix}[ERROR] ${maskTokens7(message)}${maskTokens7(formatArgs(args))}\x1B[0m`);
|
321806
|
-
}
|
321807
|
-
}
|
321808
|
-
};
|
321809
|
-
}
|
321810
|
-
var logger4 = createLogger4();
|
321811
|
-
|
321812
321887
|
// src/prompts/standalone/service-value.prompt.ts
|
321813
321888
|
async function serviceValuePrompt({
|
321814
321889
|
defaultValue,
|
321815
321890
|
example,
|
321816
321891
|
message = "Enter service value:",
|
321817
321892
|
accept = false,
|
321818
|
-
isCi = is_in_ci_default
|
321893
|
+
isCi = is_in_ci_default,
|
321894
|
+
required: required5 = true
|
321819
321895
|
}) {
|
321820
321896
|
const autoAccept = !!accept || isCi;
|
321821
|
-
if (autoAccept && defaultValue) {
|
321897
|
+
if (autoAccept && (defaultValue || !required5)) {
|
321822
321898
|
return defaultValue;
|
321823
321899
|
}
|
321824
321900
|
if (isCi) {
|
@@ -322130,7 +322206,8 @@ async function connectToStandalone(env2, acceptDefaults, prod) {
|
|
322130
322206
|
message: "What are the names of the subgraphs you want to connect to (separated by commas)?",
|
322131
322207
|
example: "subgraph-1,subgraph-2",
|
322132
322208
|
defaultValue: getTheGraphSubgraphNames(env2.SETTLEMINT_THEGRAPH_SUBGRAPHS_ENDPOINTS).join(","),
|
322133
|
-
type: "value"
|
322209
|
+
type: "value",
|
322210
|
+
required: false
|
322134
322211
|
},
|
322135
322212
|
{
|
322136
322213
|
id: "portalGraphqlEndpoint",
|
@@ -322198,7 +322275,8 @@ async function connectToStandalone(env2, acceptDefaults, prod) {
|
|
322198
322275
|
message,
|
322199
322276
|
example,
|
322200
322277
|
defaultValue,
|
322201
|
-
accept: acceptDefaults
|
322278
|
+
accept: acceptDefaults,
|
322279
|
+
required: prompt.required
|
322202
322280
|
});
|
322203
322281
|
selectedServices[id] = {
|
322204
322282
|
label: prompt.label,
|
@@ -322210,7 +322288,7 @@ async function connectToStandalone(env2, acceptDefaults, prod) {
|
|
322210
322288
|
table("Configuration", Object.values(selectedServices).filter((item) => !item.isSecret).map((item) => {
|
322211
322289
|
return {
|
322212
322290
|
name: item.label,
|
322213
|
-
value: item.result ?
|
322291
|
+
value: item.result ? maskTokens6(item.result) : undefined
|
322214
322292
|
};
|
322215
322293
|
}).filter(Boolean));
|
322216
322294
|
}
|
@@ -322223,7 +322301,7 @@ async function connectToStandalone(env2, acceptDefaults, prod) {
|
|
322223
322301
|
SETTLEMINT_HASURA_ENDPOINT: selectedServices.hasuraEndpoint?.result,
|
322224
322302
|
SETTLEMINT_HASURA_ADMIN_SECRET: selectedServices.hasuraAdminSecret?.result,
|
322225
322303
|
SETTLEMINT_HASURA_DATABASE_URL: selectedServices.hasuraDatabaseUrl?.result,
|
322226
|
-
SETTLEMINT_THEGRAPH_SUBGRAPHS_ENDPOINTS: theGraphUrl && theGraphSubgraphNames ? theGraphSubgraphNames.split(",").map((name3) => getTheGraphSubgraphUrl(theGraphUrl, name3)) : [],
|
322304
|
+
SETTLEMINT_THEGRAPH_SUBGRAPHS_ENDPOINTS: theGraphUrl && theGraphSubgraphNames ? theGraphSubgraphNames.split(",").map((name3) => getTheGraphSubgraphUrl(theGraphUrl, name3)) : theGraphUrl ? [theGraphUrl] : [],
|
322227
322305
|
SETTLEMINT_THEGRAPH_DEFAULT_SUBGRAPH: theGraphSubgraphNames ? theGraphSubgraphNames.split(",")[0] : undefined,
|
322228
322306
|
SETTLEMINT_PORTAL_GRAPHQL_ENDPOINT: selectedServices.portalGraphqlEndpoint?.result,
|
322229
322307
|
SETTLEMINT_MINIO_ENDPOINT: selectedServices.minioEndpoint?.result,
|
@@ -326071,6 +326149,101 @@ function createCommand2() {
|
|
326071
326149
|
});
|
326072
326150
|
}
|
326073
326151
|
|
326152
|
+
// ../hasura/dist/hasura.js
|
326153
|
+
async function trackAllTables(databaseName, client, tableOptions = {
|
326154
|
+
includeSchemas: undefined,
|
326155
|
+
excludeSchemas: undefined
|
326156
|
+
}) {
|
326157
|
+
const messages = [];
|
326158
|
+
const { includeSchemas, excludeSchemas } = tableOptions;
|
326159
|
+
const getTablesResult = await client({
|
326160
|
+
type: "pg_get_source_tables",
|
326161
|
+
args: { source: databaseName }
|
326162
|
+
});
|
326163
|
+
if (!getTablesResult.ok) {
|
326164
|
+
throw new Error(`Failed to get tables: ${JSON.stringify(getTablesResult.data)}`);
|
326165
|
+
}
|
326166
|
+
const tables = getTablesResult.data;
|
326167
|
+
if (tables.length === 0) {
|
326168
|
+
return {
|
326169
|
+
result: "no-tables",
|
326170
|
+
messages
|
326171
|
+
};
|
326172
|
+
}
|
326173
|
+
messages.push(`Found ${tables.length} tables in database "${databaseName}"`);
|
326174
|
+
await client({
|
326175
|
+
type: "pg_untrack_tables",
|
326176
|
+
args: {
|
326177
|
+
tables: tables.map((table2) => ({ table: table2 })),
|
326178
|
+
allow_warnings: true
|
326179
|
+
}
|
326180
|
+
});
|
326181
|
+
const tablesToTrack = tables.filter((table2) => {
|
326182
|
+
if (Array.isArray(includeSchemas)) {
|
326183
|
+
return includeSchemas.includes(table2.schema);
|
326184
|
+
}
|
326185
|
+
if (Array.isArray(excludeSchemas)) {
|
326186
|
+
return !excludeSchemas.includes(table2.schema);
|
326187
|
+
}
|
326188
|
+
return true;
|
326189
|
+
});
|
326190
|
+
const trackResult = await client({
|
326191
|
+
type: "pg_track_tables",
|
326192
|
+
args: {
|
326193
|
+
tables: tablesToTrack.map((table2) => ({ table: table2 })),
|
326194
|
+
allow_warnings: true
|
326195
|
+
}
|
326196
|
+
});
|
326197
|
+
if (!trackResult.ok) {
|
326198
|
+
throw new Error(`Failed to track tables: ${JSON.stringify(trackResult.data)}`);
|
326199
|
+
}
|
326200
|
+
messages.push(`Successfully tracked ${tablesToTrack.length} tables`);
|
326201
|
+
return {
|
326202
|
+
result: "success",
|
326203
|
+
messages
|
326204
|
+
};
|
326205
|
+
}
|
326206
|
+
var ClientOptionsSchema3 = exports_external.object({
|
326207
|
+
instance: UrlOrPathSchema2,
|
326208
|
+
accessToken: ApplicationAccessTokenSchema2.optional(),
|
326209
|
+
adminSecret: exports_external.string(),
|
326210
|
+
cache: exports_external.enum([
|
326211
|
+
"default",
|
326212
|
+
"force-cache",
|
326213
|
+
"no-cache",
|
326214
|
+
"no-store",
|
326215
|
+
"only-if-cached",
|
326216
|
+
"reload"
|
326217
|
+
]).optional()
|
326218
|
+
});
|
326219
|
+
function createHasuraMetadataClient(options, logger5) {
|
326220
|
+
ensureServer();
|
326221
|
+
const validatedOptions = validate2(ClientOptionsSchema3, options);
|
326222
|
+
const baseUrl = extractBaseUrlBeforeSegment(options.instance, "/v1/graphql");
|
326223
|
+
const queryEndpoint = new URL(`${baseUrl}/v1/metadata`).toString();
|
326224
|
+
const fetchInstance = logger5 ? requestLogger(logger5, "hasura", fetch) : fetch;
|
326225
|
+
return async (query) => {
|
326226
|
+
const response = await fetchInstance(queryEndpoint, {
|
326227
|
+
method: "POST",
|
326228
|
+
headers: appendHeaders({ "Content-Type": "application/json" }, {
|
326229
|
+
"x-auth-token": validatedOptions.accessToken,
|
326230
|
+
"x-hasura-admin-secret": validatedOptions.adminSecret
|
326231
|
+
}),
|
326232
|
+
body: JSON.stringify(query)
|
326233
|
+
});
|
326234
|
+
if (!response.ok) {
|
326235
|
+
return {
|
326236
|
+
ok: false,
|
326237
|
+
data: await response.json()
|
326238
|
+
};
|
326239
|
+
}
|
326240
|
+
return {
|
326241
|
+
ok: true,
|
326242
|
+
data: await response.json()
|
326243
|
+
};
|
326244
|
+
};
|
326245
|
+
}
|
326246
|
+
|
326074
326247
|
// src/constants/resource-type.ts
|
326075
326248
|
var SETTLEMINT_CLIENT_MAP = {
|
326076
326249
|
application: "application",
|
@@ -326174,68 +326347,12 @@ function hasuraTrackCommand() {
|
|
326174
326347
|
if (!hasuraGraphqlEndpoint || !hasuraAdminSecret) {
|
326175
326348
|
return note("Could not retrieve Hasura endpoint or admin secret. Please check your configuration.");
|
326176
326349
|
}
|
326177
|
-
const
|
326178
|
-
|
326179
|
-
|
326180
|
-
|
326181
|
-
startMessage: `Tracking all tables in Hasura from database "${database}"`,
|
326182
|
-
stopMessage: "Successfully tracked all tables in Hasura",
|
326183
|
-
task: async () => {
|
326184
|
-
const executeHasuraQuery = async (query) => {
|
326185
|
-
const response = await fetch(queryEndpoint, {
|
326186
|
-
method: "POST",
|
326187
|
-
headers: appendHeaders({
|
326188
|
-
"Content-Type": "application/json",
|
326189
|
-
"X-Hasura-Admin-Secret": hasuraAdminSecret
|
326190
|
-
}, {
|
326191
|
-
"x-auth-token": accessToken
|
326192
|
-
}),
|
326193
|
-
body: JSON.stringify(query)
|
326194
|
-
});
|
326195
|
-
if (!response.ok) {
|
326196
|
-
return { ok: false, data: await response.json() };
|
326197
|
-
}
|
326198
|
-
return { ok: true, data: await response.json() };
|
326199
|
-
};
|
326200
|
-
const getTablesResult = await executeHasuraQuery({
|
326201
|
-
type: "pg_get_source_tables",
|
326202
|
-
args: {
|
326203
|
-
source: database
|
326204
|
-
}
|
326205
|
-
});
|
326206
|
-
if (!getTablesResult.ok) {
|
326207
|
-
throw new Error(`Failed to get tables: ${JSON.stringify(getTablesResult.data)}`);
|
326208
|
-
}
|
326209
|
-
const tables = getTablesResult.data;
|
326210
|
-
if (tables.length === 0) {
|
326211
|
-
return { result: "no-tables" };
|
326212
|
-
}
|
326213
|
-
messages.push(`Found ${tables.length} tables in database "${database}"`);
|
326214
|
-
await executeHasuraQuery({
|
326215
|
-
type: "pg_untrack_tables",
|
326216
|
-
args: {
|
326217
|
-
tables: tables.map((table2) => ({
|
326218
|
-
table: table2.name
|
326219
|
-
})),
|
326220
|
-
allow_warnings: true
|
326221
|
-
}
|
326222
|
-
});
|
326223
|
-
const trackResult = await executeHasuraQuery({
|
326224
|
-
type: "pg_track_tables",
|
326225
|
-
args: {
|
326226
|
-
tables: tables.map((table2) => ({
|
326227
|
-
table: table2.name
|
326228
|
-
})),
|
326229
|
-
allow_warnings: true
|
326230
|
-
}
|
326231
|
-
});
|
326232
|
-
if (!trackResult.ok) {
|
326233
|
-
throw new Error(`Failed to track tables: ${JSON.stringify(trackResult.data)}`);
|
326234
|
-
}
|
326235
|
-
messages.push(`Successfully tracked ${tables.length} tables`);
|
326236
|
-
return { result: "success" };
|
326237
|
-
}
|
326350
|
+
const hasuraMetadataClient = createHasuraMetadataClient({
|
326351
|
+
instance: hasuraGraphqlEndpoint,
|
326352
|
+
accessToken,
|
326353
|
+
adminSecret: hasuraAdminSecret
|
326238
326354
|
});
|
326355
|
+
const { result, messages } = await trackAllTables(database, hasuraMetadataClient);
|
326239
326356
|
for (const message of messages) {
|
326240
326357
|
note(message);
|
326241
326358
|
}
|
@@ -330812,4 +330929,4 @@ async function sdkCliCommand(argv = process.argv) {
|
|
330812
330929
|
// src/cli.ts
|
330813
330930
|
sdkCliCommand();
|
330814
330931
|
|
330815
|
-
//# debugId=
|
330932
|
+
//# debugId=D2A5C01E54C9DE3E64756E2164756E21
|