@settlemint/sdk-cli 1.2.4-pr09e9ca2d → 1.2.4-pr1b64bb2f

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
@@ -259517,7 +259517,7 @@ function pruneCurrentEnv(currentEnv, env2) {
259517
259517
  var package_default = {
259518
259518
  name: "@settlemint/sdk-cli",
259519
259519
  description: "Command-line interface for SettleMint SDK, providing development tools and project management capabilities",
259520
- version: "1.2.4-pr09e9ca2d",
259520
+ version: "1.2.4-pr1b64bb2f",
259521
259521
  type: "module",
259522
259522
  private: false,
259523
259523
  license: "FSL-1.1-MIT",
@@ -259566,9 +259566,9 @@ var package_default = {
259566
259566
  "@inquirer/input": "4.1.8",
259567
259567
  "@inquirer/password": "4.0.11",
259568
259568
  "@inquirer/select": "4.1.0",
259569
- "@settlemint/sdk-js": "1.2.4-pr09e9ca2d",
259570
- "@settlemint/sdk-utils": "1.2.4-pr09e9ca2d",
259571
- "@types/node": "22.13.10",
259569
+ "@settlemint/sdk-js": "1.2.4-pr1b64bb2f",
259570
+ "@settlemint/sdk-utils": "1.2.4-pr1b64bb2f",
259571
+ "@types/node": "22.13.11",
259572
259572
  "@types/semver": "7.5.8",
259573
259573
  "@types/which": "3.0.4",
259574
259574
  "get-tsconfig": "4.10.0",
@@ -269930,19 +269930,19 @@ async function serviceSpinner(type4, task) {
269930
269930
  });
269931
269931
  }
269932
269932
 
269933
- // src/commands/hasura/track-table.ts
269934
- function hasuraTrackTableCommand() {
269935
- return new Command("track-table").alias("tt").description("Track a table in Hasura").usage(createExamples([
269933
+ // src/commands/hasura/track.ts
269934
+ function hasuraTrackCommand() {
269935
+ return new Command("track").alias("t").description("Track all tables in Hasura").usage(createExamples([
269936
269936
  {
269937
- description: "Track a table in the public schema",
269938
- command: "hasura track-table --schema public --table user"
269937
+ description: "Track all tables of the default database",
269938
+ command: "hasura track"
269939
269939
  },
269940
269940
  {
269941
- description: "Track a table and accept default values",
269942
- command: "hasura track-table --schema public --table payments --accept-defaults"
269941
+ description: "Track all tables of a specific database",
269942
+ command: "hasura track --database my-database"
269943
269943
  }
269944
- ])).requiredOption("--schema <schema>", "Schema name of the table (e.g., public)").requiredOption("--table <table>", "Name of the table to track").option("-a, --accept-defaults", "Accept the default and previously set values").action(async ({ schema, table: table2, acceptDefaults }) => {
269945
- intro("Tracking table in Hasura");
269944
+ ])).option("-a, --accept-defaults", "Accept the default and previously set values").option("-db, --database <database>", "Database name", "default").action(async ({ acceptDefaults, database }) => {
269945
+ intro("Tracking all tables in Hasura");
269946
269946
  const env2 = await loadEnv(false, false);
269947
269947
  const applicationUniqueName = env2.SETTLEMINT_APPLICATION;
269948
269948
  if (!applicationUniqueName) {
@@ -269975,11 +269975,11 @@ function hasuraTrackTableCommand() {
269975
269975
  return note("Could not retrieve Hasura endpoint or admin secret. Please check your configuration.");
269976
269976
  }
269977
269977
  const baseUrl = new URL(hasuraGraphqlEndpoint);
269978
- const queryEndpoint = new URL("/v1/query", baseUrl.origin).toString();
269978
+ const queryEndpoint = new URL("/v1/metadata", baseUrl.origin).toString();
269979
269979
  const messages = [];
269980
- await spinner({
269981
- startMessage: `Tracking table '${schema}.${table2}' in Hasura`,
269982
- stopMessage: `Successfully tracked table '${schema}.${table2}' in Hasura`,
269980
+ const { result } = await spinner({
269981
+ startMessage: `Tracking all tables in Hasura from database "${database}"`,
269982
+ stopMessage: "Successfully tracked all tables in Hasura",
269983
269983
  task: async () => {
269984
269984
  const executeHasuraQuery = async (query) => {
269985
269985
  const response = await fetch(queryEndpoint, {
@@ -269996,49 +269996,58 @@ function hasuraTrackTableCommand() {
269996
269996
  }
269997
269997
  return { ok: true, data: await response.json() };
269998
269998
  };
269999
- const trackTable = async () => {
270000
- return executeHasuraQuery({
270001
- type: "track_table",
270002
- args: { schema, table: table2 }
270003
- });
270004
- };
270005
- const untrackTable = async () => {
270006
- return executeHasuraQuery({
270007
- type: "untrack_table",
270008
- args: { schema, table: table2 }
270009
- });
270010
- };
270011
- const trackResult = await trackTable();
270012
- if (trackResult.ok) {
270013
- return { data: trackResult.data };
270014
- }
270015
- if (trackResult.data.code !== "already-tracked") {
270016
- throw new Error(`Failed to track table: ${JSON.stringify(trackResult.data)}`);
270017
- }
270018
- messages.push(`Table '${schema}.${table2}' is already tracked. Untracking and retracking...`);
270019
- const untrackResult = await untrackTable();
270020
- if (!untrackResult.ok) {
270021
- throw new Error(`Failed to untrack table: ${JSON.stringify(untrackResult.data)}`);
270022
- }
270023
- messages.push(`Successfully untracked table '${schema}.${table2}'.`);
270024
- const retrackResult = await trackTable();
270025
- if (!retrackResult.ok) {
270026
- throw new Error(`Failed to re-track table: ${JSON.stringify(retrackResult.data)}`);
269999
+ const getTablesResult = await executeHasuraQuery({
270000
+ type: "pg_get_source_tables",
270001
+ args: {
270002
+ source: database
270003
+ }
270004
+ });
270005
+ if (!getTablesResult.ok) {
270006
+ throw new Error(`Failed to get tables: ${JSON.stringify(getTablesResult.data)}`);
270007
+ }
270008
+ const tables = getTablesResult.data;
270009
+ if (tables.length === 0) {
270010
+ return { result: "no-tables" };
270011
+ }
270012
+ messages.push(`Found ${tables.length} tables in database "${database}"`);
270013
+ await executeHasuraQuery({
270014
+ type: "pg_untrack_tables",
270015
+ args: {
270016
+ tables: tables.map((table2) => ({
270017
+ table: table2.name
270018
+ })),
270019
+ allow_warnings: true
270020
+ }
270021
+ });
270022
+ const trackResult = await executeHasuraQuery({
270023
+ type: "pg_track_tables",
270024
+ args: {
270025
+ tables: tables.map((table2) => ({
270026
+ table: table2.name
270027
+ })),
270028
+ allow_warnings: true
270029
+ }
270030
+ });
270031
+ if (!trackResult.ok) {
270032
+ throw new Error(`Failed to track tables: ${JSON.stringify(trackResult.data)}`);
270027
270033
  }
270028
- messages.push(`Successfully re-tracked table '${schema}.${table2}'.`);
270029
- return { data: retrackResult.data };
270034
+ messages.push(`Successfully tracked ${tables.length} tables`);
270035
+ return { result: "success" };
270030
270036
  }
270031
270037
  });
270032
270038
  for (const message of messages) {
270033
270039
  note(message);
270034
270040
  }
270035
- outro("Table tracking completed");
270041
+ if (result === "no-tables") {
270042
+ outro(`No tables found in database "${database}"`);
270043
+ }
270044
+ outro("Table tracking completed successfully");
270036
270045
  });
270037
270046
  }
270038
270047
 
270039
270048
  // src/commands/hasura/index.ts
270040
270049
  function hasuraCommand() {
270041
- return new Command("hasura").alias("ha").description("Manage Hasura service in the SettleMint platform").addCommand(hasuraTrackTableCommand());
270050
+ return new Command("hasura").alias("ha").description("Manage Hasura service in the SettleMint platform").addCommand(hasuraTrackCommand());
270042
270051
  }
270043
270052
 
270044
270053
  // src/prompts/pat.prompt.ts
@@ -273544,4 +273553,4 @@ async function sdkCliCommand(argv = process.argv) {
273544
273553
  // src/cli.ts
273545
273554
  sdkCliCommand();
273546
273555
 
273547
- //# debugId=849E2F1F2C47692F64756E2164756E21
273556
+ //# debugId=A0FFEEA7DBEC221C64756E2164756E21