@settlemint/sdk-cli 2.4.1-pra16d0163 → 2.4.1-pre00912fe

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 CHANGED
@@ -44630,7 +44630,7 @@ var require_util = __commonJS((exports) => {
44630
44630
  return path7;
44631
44631
  }
44632
44632
  exports.normalize = normalize4;
44633
- function join6(aRoot, aPath) {
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 = join6;
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 = join6(urlGenerate(parsed), 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: () => writeFile4,
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 writeFile4(host, diagnostics, fileName, text, writeByteOrderMark, sourceFiles, data) {
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
- writeFile4(host, emitterDiagnostics, buildInfoPath, getBuildInfoText(buildInfo), false, undefined, { buildInfo });
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
- writeFile4(host, emitterDiagnostics, sourceMapFilePath, sourceMap, false, sourceFiles);
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
- writeFile4(host, emitterDiagnostics, jsFilePath, text, !!compilerOptions.emitBOM, sourceFiles, data);
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: () => writeFile4,
204179
+ writeFile: () => writeFile3,
204180
204180
  writeFileEnsuringDirectories: () => writeFileEnsuringDirectories,
204181
204181
  zipWith: () => zipWith
204182
204182
  });
@@ -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-pra16d0163",
265086
+ version: "2.4.1-pre00912fe",
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-js": "2.4.1-pra16d0163",
265138
- "@settlemint/sdk-utils": "2.4.1-pra16d0163",
265139
- "@settlemint/sdk-viem": "2.4.1-pra16d0163",
265140
- "@types/node": "24.0.10",
265137
+ "@settlemint/sdk-hasura": "2.4.1-pre00912fe",
265138
+ "@settlemint/sdk-js": "2.4.1-pre00912fe",
265139
+ "@settlemint/sdk-utils": "2.4.1-pre00912fe",
265140
+ "@settlemint/sdk-viem": "2.4.1-pre00912fe",
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",
@@ -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 mkdir2, writeFile as writeFile3 } from "node:fs/promises";
301783
- import { join as join5 } from "node:path";
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(join5(projectDir, "src"));
301787
- const basePath = hasSrcDir ? join5(projectDir, "src") : projectDir;
301788
- const codegenDir = join5(basePath, directory);
301789
- await mkdir2(codegenDir, { recursive: true });
301790
- const filePath = join5(codegenDir, filename);
301791
- await writeFile3(filePath, template, "utf8");
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) {
@@ -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 getPortalWebsocketClient = getWebsocketClient({
301966
+ export const portalWebsocketClient = getWebsocketClient({
301960
301967
  portalGraphqlEndpoint: process.env.SETTLEMINT_PORTAL_GRAPHQL_ENDPOINT!,
301961
301968
  accessToken: process.env.SETTLEMINT_ACCESS_TOKEN,
301962
301969
  });
@@ -321808,6 +321815,59 @@ ${JSON.stringify(arg, null, 2)}`;
321808
321815
  };
321809
321816
  }
321810
321817
  var logger4 = createLogger4();
321818
+ function truncate(value4, maxLength) {
321819
+ if (value4.length <= maxLength) {
321820
+ return value4;
321821
+ }
321822
+ return `${value4.slice(0, maxLength)}...`;
321823
+ }
321824
+ var WARNING_THRESHOLD = 500;
321825
+ var TRUNCATE_LENGTH = 50;
321826
+ function requestLogger(logger$1, name3, fn) {
321827
+ return async (...args) => {
321828
+ const start3 = Date.now();
321829
+ try {
321830
+ return await fn(...args);
321831
+ } finally {
321832
+ const end = Date.now();
321833
+ const duration6 = end - start3;
321834
+ const body = extractInfoFromBody(args[1]?.body ?? "{}");
321835
+ const message = `${name3} path: ${args[0]}, took ${formatDuration(duration6)}`;
321836
+ if (duration6 > WARNING_THRESHOLD) {
321837
+ logger$1.warn(message, body);
321838
+ } else {
321839
+ logger$1.info(message, body);
321840
+ }
321841
+ }
321842
+ };
321843
+ }
321844
+ function formatDuration(duration6) {
321845
+ return duration6 < 1000 ? `${duration6}ms` : `${(duration6 / 1000).toFixed(3)}s`;
321846
+ }
321847
+ function extractInfoFromBody(body) {
321848
+ try {
321849
+ const parsedBody = typeof body === "string" ? JSON.parse(body) : body;
321850
+ if (parsedBody === null || parsedBody === undefined || Object.keys(parsedBody).length === 0) {
321851
+ return null;
321852
+ }
321853
+ const dataToKeep = {};
321854
+ if ("query" in parsedBody) {
321855
+ dataToKeep.query = truncate(parsedBody.query, TRUNCATE_LENGTH);
321856
+ }
321857
+ if ("variables" in parsedBody) {
321858
+ dataToKeep.variables = truncate(JSON.stringify(parsedBody.variables), TRUNCATE_LENGTH);
321859
+ }
321860
+ if ("operationName" in parsedBody) {
321861
+ dataToKeep.operationName = truncate(parsedBody.operationName, TRUNCATE_LENGTH);
321862
+ }
321863
+ if (Object.keys(dataToKeep).length > 0) {
321864
+ return JSON.stringify(dataToKeep);
321865
+ }
321866
+ return truncate(JSON.stringify(parsedBody || "{}"), TRUNCATE_LENGTH);
321867
+ } catch {
321868
+ return "{}";
321869
+ }
321870
+ }
321811
321871
 
321812
321872
  // src/prompts/standalone/service-value.prompt.ts
321813
321873
  async function serviceValuePrompt({
@@ -326071,6 +326131,88 @@ function createCommand2() {
326071
326131
  });
326072
326132
  }
326073
326133
 
326134
+ // ../hasura/dist/hasura.js
326135
+ async function trackAllTables(databaseName, client) {
326136
+ const messages = [];
326137
+ const getTablesResult = await client({
326138
+ type: "pg_get_source_tables",
326139
+ args: { source: databaseName }
326140
+ });
326141
+ if (!getTablesResult.ok) {
326142
+ throw new Error(`Failed to get tables: ${JSON.stringify(getTablesResult.data)}`);
326143
+ }
326144
+ const tables = getTablesResult.data;
326145
+ if (tables.length === 0) {
326146
+ return {
326147
+ result: "no-tables",
326148
+ messages
326149
+ };
326150
+ }
326151
+ messages.push(`Found ${tables.length} tables in database "${databaseName}"`);
326152
+ await client({
326153
+ type: "pg_untrack_tables",
326154
+ args: {
326155
+ tables: tables.map((table2) => ({ table: table2.name })),
326156
+ allow_warnings: true
326157
+ }
326158
+ });
326159
+ const trackResult = await client({
326160
+ type: "pg_track_tables",
326161
+ args: {
326162
+ tables: tables.map((table2) => ({ table: table2.name })),
326163
+ allow_warnings: true
326164
+ }
326165
+ });
326166
+ if (!trackResult.ok) {
326167
+ throw new Error(`Failed to track tables: ${JSON.stringify(trackResult.data)}`);
326168
+ }
326169
+ messages.push(`Successfully tracked ${tables.length} tables`);
326170
+ return {
326171
+ result: "success",
326172
+ messages
326173
+ };
326174
+ }
326175
+ var ClientOptionsSchema3 = exports_external.object({
326176
+ instance: UrlOrPathSchema2,
326177
+ accessToken: ApplicationAccessTokenSchema2.optional(),
326178
+ adminSecret: exports_external.string(),
326179
+ cache: exports_external.enum([
326180
+ "default",
326181
+ "force-cache",
326182
+ "no-cache",
326183
+ "no-store",
326184
+ "only-if-cached",
326185
+ "reload"
326186
+ ]).optional()
326187
+ });
326188
+ function createHasuraMetadataClient(options, logger5) {
326189
+ ensureServer();
326190
+ const validatedOptions = validate2(ClientOptionsSchema3, options);
326191
+ const baseUrl = extractBaseUrlBeforeSegment(options.instance, "/v1/graphql");
326192
+ const queryEndpoint = new URL(`${baseUrl}/v1/metadata`).toString();
326193
+ const fetchInstance = logger5 ? requestLogger(logger5, "hasura", fetch) : fetch;
326194
+ return async (query) => {
326195
+ const response = await fetchInstance(queryEndpoint, {
326196
+ method: "POST",
326197
+ headers: appendHeaders({ "Content-Type": "application/json" }, {
326198
+ "x-auth-token": validatedOptions.accessToken,
326199
+ "x-hasura-admin-secret": validatedOptions.adminSecret
326200
+ }),
326201
+ body: JSON.stringify(query)
326202
+ });
326203
+ if (!response.ok) {
326204
+ return {
326205
+ ok: false,
326206
+ data: await response.json()
326207
+ };
326208
+ }
326209
+ return {
326210
+ ok: true,
326211
+ data: await response.json()
326212
+ };
326213
+ };
326214
+ }
326215
+
326074
326216
  // src/constants/resource-type.ts
326075
326217
  var SETTLEMINT_CLIENT_MAP = {
326076
326218
  application: "application",
@@ -326174,68 +326316,12 @@ function hasuraTrackCommand() {
326174
326316
  if (!hasuraGraphqlEndpoint || !hasuraAdminSecret) {
326175
326317
  return note("Could not retrieve Hasura endpoint or admin secret. Please check your configuration.");
326176
326318
  }
326177
- const baseUrl = extractBaseUrlBeforeSegment(hasuraGraphqlEndpoint, "/v1/graphql");
326178
- const queryEndpoint = new URL(`${baseUrl}/v1/metadata`).toString();
326179
- const messages = [];
326180
- const { result } = await spinner({
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
- }
326319
+ const hasuraMetadataClient = createHasuraMetadataClient({
326320
+ instance: hasuraGraphqlEndpoint,
326321
+ accessToken,
326322
+ adminSecret: hasuraAdminSecret
326238
326323
  });
326324
+ const { result, messages } = await trackAllTables(database, hasuraMetadataClient);
326239
326325
  for (const message of messages) {
326240
326326
  note(message);
326241
326327
  }
@@ -330812,4 +330898,4 @@ async function sdkCliCommand(argv = process.argv) {
330812
330898
  // src/cli.ts
330813
330899
  sdkCliCommand();
330814
330900
 
330815
- //# debugId=5977483E5588F34764756E2164756E21
330901
+ //# debugId=880FBB03BED3501F64756E2164756E21