@settlemint/sdk-cli 2.1.4-pr3b65e859 → 2.1.4-pr4cff9a3b

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.
Files changed (3) hide show
  1. package/dist/cli.js +224 -29
  2. package/dist/cli.js.map +29 -26
  3. package/package.json +3 -3
package/dist/cli.js CHANGED
@@ -245278,7 +245278,7 @@ function pruneCurrentEnv(currentEnv, env2) {
245278
245278
  var package_default = {
245279
245279
  name: "@settlemint/sdk-cli",
245280
245280
  description: "Command-line interface for SettleMint SDK, providing development tools and project management capabilities",
245281
- version: "2.1.4-pr3b65e859",
245281
+ version: "2.1.4-pr4cff9a3b",
245282
245282
  type: "module",
245283
245283
  private: false,
245284
245284
  license: "FSL-1.1-MIT",
@@ -245327,8 +245327,8 @@ var package_default = {
245327
245327
  "@inquirer/input": "4.1.9",
245328
245328
  "@inquirer/password": "4.0.12",
245329
245329
  "@inquirer/select": "4.1.1",
245330
- "@settlemint/sdk-js": "2.1.4-pr3b65e859",
245331
- "@settlemint/sdk-utils": "2.1.4-pr3b65e859",
245330
+ "@settlemint/sdk-js": "2.1.4-pr4cff9a3b",
245331
+ "@settlemint/sdk-utils": "2.1.4-pr4cff9a3b",
245332
245332
  "@types/node": "22.14.1",
245333
245333
  "@types/semver": "7.7.0",
245334
245334
  "@types/which": "3.0.4",
@@ -248068,6 +248068,38 @@ var getLoadBalancers = graphql(`
248068
248068
  }
248069
248069
  }
248070
248070
  `, [LoadBalancerFragment]);
248071
+ var createLoadBalancer = graphql(`
248072
+ mutation createLoadBalancer(
248073
+ $applicationId: ID!
248074
+ $blockchainNetworkId: ID!
248075
+ $name: String!
248076
+ $provider: String!
248077
+ $region: String!
248078
+ $size: ClusterServiceSize
248079
+ $type: ClusterServiceType
248080
+ $connectedNodes: [ID!]!
248081
+ ) {
248082
+ createLoadBalancer(
248083
+ applicationId: $applicationId
248084
+ blockchainNetworkId: $blockchainNetworkId
248085
+ name: $name
248086
+ provider: $provider
248087
+ region: $region
248088
+ size: $size
248089
+ type: $type
248090
+ connectedNodes: $connectedNodes
248091
+ ) {
248092
+ ...LoadBalancer
248093
+ }
248094
+ }
248095
+ `, [LoadBalancerFragment]);
248096
+ var restartLoadBalancer = graphql(`
248097
+ mutation RestartLoadBalancer($uniqueName: String!) {
248098
+ restartLoadBalancerByUniqueName(uniqueName: $uniqueName) {
248099
+ ...LoadBalancer
248100
+ }
248101
+ }
248102
+ `, [LoadBalancerFragment]);
248071
248103
  var loadBalancerRead = (gqlClient) => {
248072
248104
  return async (loadBalancerUniqueName) => {
248073
248105
  const { loadBalancerByUniqueName: loadBalancer } = await gqlClient.request(getLoadBalancer, {
@@ -248084,6 +248116,29 @@ var loadBalancerList = (gqlClient) => {
248084
248116
  return items;
248085
248117
  };
248086
248118
  };
248119
+ var loadBalancerCreate = (gqlClient) => {
248120
+ return async (args) => {
248121
+ const { applicationUniqueName, blockchainNetworkUniqueName, connectedNodesUniqueNames, ...otherArgs } = args;
248122
+ const [application, blockchainNetwork, connectedNodes] = await Promise.all([
248123
+ applicationRead(gqlClient)(applicationUniqueName),
248124
+ blockchainNetworkRead(gqlClient)(blockchainNetworkUniqueName),
248125
+ Promise.all(connectedNodesUniqueNames.map((uniqueName) => blockchainNodeRead(gqlClient)(uniqueName)))
248126
+ ]);
248127
+ const { createLoadBalancer: loadBalancer } = await gqlClient.request(createLoadBalancer, {
248128
+ ...otherArgs,
248129
+ applicationId: application.id,
248130
+ blockchainNetworkId: blockchainNetwork.id,
248131
+ connectedNodes: connectedNodes.map((node) => node.id)
248132
+ });
248133
+ return loadBalancer;
248134
+ };
248135
+ };
248136
+ var loadBalancerRestart = (gqlClient) => async (loadBalancerUniqueName) => {
248137
+ const { restartLoadBalancerByUniqueName: loadBalancer } = await gqlClient.request(restartLoadBalancer, {
248138
+ uniqueName: loadBalancerUniqueName
248139
+ });
248140
+ return loadBalancer;
248141
+ };
248087
248142
  var InsightsFragment = graphql(`
248088
248143
  fragment Insights on Insights {
248089
248144
  __typename
@@ -248786,7 +248841,9 @@ function createSettleMintClient(options) {
248786
248841
  },
248787
248842
  loadBalancer: {
248788
248843
  list: loadBalancerList(gqlClient),
248789
- read: loadBalancerRead(gqlClient)
248844
+ read: loadBalancerRead(gqlClient),
248845
+ create: loadBalancerCreate(gqlClient),
248846
+ restart: loadBalancerRestart(gqlClient)
248790
248847
  },
248791
248848
  middleware: {
248792
248849
  list: middlewareList(gqlClient),
@@ -252211,6 +252268,7 @@ async function applicationPrompt(env2, applications, accept) {
252211
252268
  }
252212
252269
 
252213
252270
  // src/prompts/cluster-service/service.prompt.ts
252271
+ var ALL2 = "All";
252214
252272
  async function servicePrompt({
252215
252273
  env: env2,
252216
252274
  services,
@@ -252219,12 +252277,13 @@ async function servicePrompt({
252219
252277
  defaultHandler,
252220
252278
  isRequired = false,
252221
252279
  isCi = is_in_ci_default,
252222
- singleOptionMessage
252280
+ singleOptionMessage,
252281
+ allowAll = false
252223
252282
  }) {
252224
252283
  if (services.length === 0) {
252225
252284
  return;
252226
252285
  }
252227
- const selectedService = services.find((service) => service.uniqueName === env2[envKey]);
252286
+ const selectedService = services.find((service) => Array.isArray(service) ? false : service.uniqueName === env2[envKey]);
252228
252287
  const autoAccept = isCi || accept;
252229
252288
  if (autoAccept && selectedService) {
252230
252289
  return selectedService;
@@ -252233,7 +252292,7 @@ async function servicePrompt({
252233
252292
  return;
252234
252293
  }
252235
252294
  if (isRequired && services.length === 1) {
252236
- if (singleOptionMessage) {
252295
+ if (singleOptionMessage && !Array.isArray(services[0])) {
252237
252296
  note(singleOptionMessage(services[0].uniqueName));
252238
252297
  }
252239
252298
  return services[0];
@@ -252242,13 +252301,30 @@ async function servicePrompt({
252242
252301
  name: `${service.name} (${service.uniqueName})`,
252243
252302
  value: service
252244
252303
  }));
252304
+ if (allowAll) {
252305
+ choices.unshift({
252306
+ name: ALL2,
252307
+ value: services
252308
+ });
252309
+ }
252245
252310
  if (!isRequired) {
252246
252311
  choices.push({
252247
252312
  name: "None",
252248
252313
  value: undefined
252249
252314
  });
252250
252315
  }
252251
- return defaultHandler({ defaultService: selectedService, choices });
252316
+ return defaultHandler({
252317
+ defaultService: selectedService,
252318
+ choices
252319
+ });
252320
+ }
252321
+
252322
+ // src/utils/cluster-service.ts
252323
+ function hasValidPrivateKey(privateKey) {
252324
+ return privateKey.privateKeyType !== "HD_ECDSA_P256";
252325
+ }
252326
+ function isRunning(service) {
252327
+ return service === undefined || service?.status === "COMPLETED";
252252
252328
  }
252253
252329
 
252254
252330
  // src/prompts/cluster-service/blockchain-node.prompt.ts
@@ -252259,7 +252335,8 @@ async function blockchainNodePrompt({
252259
252335
  singleOptionMessage,
252260
252336
  promptMessage,
252261
252337
  filterRunningOnly = false,
252262
- isRequired = false
252338
+ isRequired = false,
252339
+ allowAll = false
252263
252340
  }) {
252264
252341
  return servicePrompt({
252265
252342
  env: env2,
@@ -252268,14 +252345,25 @@ async function blockchainNodePrompt({
252268
252345
  envKey: "SETTLEMINT_BLOCKCHAIN_NODE",
252269
252346
  isRequired,
252270
252347
  defaultHandler: async ({ defaultService: defaultNode, choices }) => {
252271
- const filteredChoices = filterRunningOnly ? choices.filter(({ value: node }) => node === undefined || node?.status === "COMPLETED") : choices;
252348
+ const filteredChoices = filterRunningOnly ? choices.filter(({ value: node }) => {
252349
+ return Array.isArray(node) ? true : isRunning(node);
252350
+ }).map((item) => {
252351
+ if (Array.isArray(item.value)) {
252352
+ return {
252353
+ ...item,
252354
+ value: item.value.filter(isRunning)
252355
+ };
252356
+ }
252357
+ return item;
252358
+ }) : choices;
252272
252359
  return esm_default3({
252273
252360
  message: promptMessage ?? "Which blockchain node do you want to connect to?",
252274
252361
  choices: filteredChoices,
252275
252362
  default: defaultNode
252276
252363
  });
252277
252364
  },
252278
- singleOptionMessage
252365
+ singleOptionMessage,
252366
+ allowAll
252279
252367
  });
252280
252368
  }
252281
252369
 
@@ -252764,7 +252852,7 @@ async function blockchainNodeOrLoadBalancerPrompt({
252764
252852
  }) {
252765
252853
  return servicePrompt({
252766
252854
  env: env2,
252767
- services: [...nodes, ...loadBalancers],
252855
+ services: [...loadBalancers, ...nodes],
252768
252856
  accept,
252769
252857
  envKey: "SETTLEMINT_BLOCKCHAIN_NODE_OR_LOAD_BALANCER",
252770
252858
  isRequired,
@@ -252809,19 +252897,20 @@ function connectCommand() {
252809
252897
  blockchainNodes,
252810
252898
  loadBalancers
252811
252899
  } = await servicesSpinner(settlemint, application.uniqueName);
252900
+ const nodesWithPrivateKey = blockchainNodes.filter((node) => node && ("privateKeys" in node) ? Array.isArray(node?.privateKeys) && node?.privateKeys?.length > 0 : false);
252812
252901
  const blockchainNode = await blockchainNodePrompt({
252813
252902
  env: env2,
252814
- nodes: blockchainNodes,
252903
+ nodes: nodesWithPrivateKey,
252815
252904
  accept: acceptDefaults,
252816
- promptMessage: "Which blockchain node do you want to SEND unsigned transactions from?"
252905
+ promptMessage: "Which blockchain node do you want to use for sending transactions?"
252817
252906
  });
252818
- const nodesWithNoSigning = blockchainNodes.filter((node) => node && ("privateKeys" in node) ? !Array.isArray(node?.privateKeys) || node?.privateKeys?.length === 0 : true);
252907
+ const nodesWithoutPrivateKey = blockchainNodes.filter((node) => node && ("privateKeys" in node) ? !Array.isArray(node?.privateKeys) || node?.privateKeys?.length === 0 : true);
252819
252908
  const loadBalancerOrBlockchainNode = await blockchainNodeOrLoadBalancerPrompt({
252820
252909
  env: env2,
252821
- nodes: nodesWithNoSigning,
252910
+ nodes: nodesWithoutPrivateKey,
252822
252911
  loadBalancers,
252823
252912
  accept: acceptDefaults,
252824
- promptMessage: "Which blockchain node or load balancer do you want to READ/WRITE from/to? Transactions should be signed before sending to this node or load balancer"
252913
+ promptMessage: "Which blockchain node or load balancer do you want to use for read operations?"
252825
252914
  });
252826
252915
  const hasura = await hasuraPrompt({
252827
252916
  env: env2,
@@ -252887,12 +252976,12 @@ function connectCommand() {
252887
252976
  uniqueName: blockchainNode.blockchainNetwork?.uniqueName
252888
252977
  },
252889
252978
  blockchainNode && {
252890
- type: "Blockchain Node",
252979
+ type: "Blockchain Node (with private key, use for sending transactions)",
252891
252980
  name: blockchainNode.name,
252892
252981
  uniqueName: blockchainNode.uniqueName
252893
252982
  },
252894
252983
  loadBalancerOrBlockchainNode && {
252895
- type: "Blockchain Node or Load Balancer (signed transactions only)",
252984
+ type: "Blockchain Node or Load Balancer (without private key, use for read operations)",
252896
252985
  name: loadBalancerOrBlockchainNode.name,
252897
252986
  uniqueName: loadBalancerOrBlockchainNode.uniqueName
252898
252987
  },
@@ -257521,6 +257610,104 @@ function integrationToolCreateCommand() {
257521
257610
  return cmd2;
257522
257611
  }
257523
257612
 
257613
+ // src/commands/platform/load-balancer/evm/create.ts
257614
+ function loadBalancerEvmCreateCommand() {
257615
+ return getCreateCommand({
257616
+ name: "evm",
257617
+ type: "load balancer",
257618
+ subType: "EVM",
257619
+ alias: "e",
257620
+ execute: (cmd2, baseAction) => {
257621
+ addClusterServiceArgs(cmd2).option("--app, --application <application>", "The application unique name to create the load balancer in (defaults to application from env)").option("--blockchain-nodes <blockchainNodes...>", "Blockchain node unique names where the load balancer connects to (must be from the same network)").action(async (name3, { application, provider, region, size, type: type4, blockchainNodes, acceptDefaults, ...defaultArgs }) => {
257622
+ return baseAction({
257623
+ ...defaultArgs,
257624
+ acceptDefaults,
257625
+ provider,
257626
+ region
257627
+ }, async ({ settlemint, env: env2, showSpinner, provider: provider2, region: region2 }) => {
257628
+ const applicationUniqueName = application ?? env2.SETTLEMINT_APPLICATION;
257629
+ if (!applicationUniqueName) {
257630
+ return missingApplication();
257631
+ }
257632
+ let networkUniqueName;
257633
+ let connectedNodesUniqueNames = blockchainNodes;
257634
+ if (!connectedNodesUniqueNames) {
257635
+ const networks = await serviceSpinner("blockchain network", () => settlemint.blockchainNetwork.list(applicationUniqueName));
257636
+ const network = await blockchainNetworkPrompt({
257637
+ env: env2,
257638
+ networks,
257639
+ accept: acceptDefaults,
257640
+ isRequired: true
257641
+ });
257642
+ if (!network) {
257643
+ return nothingSelectedError("blockchain network");
257644
+ }
257645
+ const blockchainNodes2 = await serviceSpinner("blockchain node", () => settlemint.blockchainNode.list(applicationUniqueName));
257646
+ const connectedNodes = await blockchainNodePrompt({
257647
+ env: env2,
257648
+ nodes: blockchainNodes2.filter((node) => node.blockchainNetwork?.uniqueName === networkUniqueName),
257649
+ accept: acceptDefaults,
257650
+ promptMessage: "Which blockchain node do you want to connect the load balancer to?",
257651
+ allowAll: true
257652
+ });
257653
+ connectedNodesUniqueNames = Array.isArray(connectedNodes) ? blockchainNodes2.map((node) => node.uniqueName) : connectedNodes ? [connectedNodes.uniqueName] : [];
257654
+ }
257655
+ if (!networkUniqueName) {
257656
+ const applicationBlockchainNodes = await serviceSpinner("blockchain node", () => settlemint.blockchainNode.list(applicationUniqueName));
257657
+ const selectedBlockchainNodes = applicationBlockchainNodes.filter((node) => connectedNodesUniqueNames.includes(node.uniqueName));
257658
+ if (selectedBlockchainNodes.length === 0) {
257659
+ return cancel2("blockchain network");
257660
+ }
257661
+ const onTheSameNetwork = selectedBlockchainNodes.every((node) => node.blockchainNetwork?.uniqueName === selectedBlockchainNodes[0].blockchainNetwork?.uniqueName);
257662
+ if (!onTheSameNetwork) {
257663
+ return cancel2("Blockchain nodes must be on the same network");
257664
+ }
257665
+ networkUniqueName = selectedBlockchainNodes[0].blockchainNetwork?.uniqueName;
257666
+ }
257667
+ const result = await showSpinner(() => settlemint.loadBalancer.create({
257668
+ applicationUniqueName,
257669
+ name: name3,
257670
+ blockchainNetworkUniqueName: networkUniqueName,
257671
+ provider: provider2,
257672
+ region: region2,
257673
+ size,
257674
+ type: type4,
257675
+ connectedNodesUniqueNames
257676
+ }));
257677
+ return {
257678
+ result,
257679
+ mapDefaultEnv: () => {
257680
+ return {
257681
+ SETTLEMINT_APPLICATION: applicationUniqueName,
257682
+ SETTLEMINT_BLOCKCHAIN_NODE_OR_LOAD_BALANCER: result.uniqueName
257683
+ };
257684
+ }
257685
+ };
257686
+ });
257687
+ });
257688
+ },
257689
+ examples: [
257690
+ {
257691
+ description: "Create an EVM load balancer and save as default",
257692
+ command: "platform create load-balancer evm my-lb --accept-defaults -d"
257693
+ },
257694
+ {
257695
+ description: "Create an EVM load balancer and connect to specific blockchain nodes",
257696
+ command: "platform create load-balancer evm my-lb --blockchain-nodes my-node1 my-node2 --accept-defaults"
257697
+ },
257698
+ {
257699
+ description: "Create an EVM load balancer in a different application",
257700
+ command: "platform create load-balancer evm my-lb --application my-app --accept-defaults"
257701
+ }
257702
+ ]
257703
+ });
257704
+ }
257705
+
257706
+ // src/commands/platform/load-balancer/create.ts
257707
+ function loadBalancerCreateCommand() {
257708
+ return new Command("load-balancer").alias("lb").description("Create a load balancer in the SettleMint platform").addCommand(loadBalancerEvmCreateCommand());
257709
+ }
257710
+
257524
257711
  // src/commands/platform/middleware/graph/create.ts
257525
257712
  function graphMiddlewareCreateCommand() {
257526
257713
  return getCreateCommand({
@@ -258021,7 +258208,7 @@ function storageCreateCommand() {
258021
258208
 
258022
258209
  // src/commands/platform/create.ts
258023
258210
  function createCommand3() {
258024
- return new Command("create").alias("c").description("Create a resource in the SettleMint platform").addCommand(workspaceCreateCommand()).addCommand(applicationCreateCommand()).addCommand(blockchainNetworkCreateCommand()).addCommand(blockchainNodeCreateCommand()).addCommand(privateKeyCreateCommand()).addCommand(middlewareCreateCommand()).addCommand(storageCreateCommand()).addCommand(integrationToolCreateCommand()).addCommand(insightsCreateCommand()).addCommand(applicationAccessTokenCreateCommand());
258211
+ return new Command("create").alias("c").description("Create a resource in the SettleMint platform").addCommand(workspaceCreateCommand()).addCommand(applicationCreateCommand()).addCommand(blockchainNetworkCreateCommand()).addCommand(blockchainNodeCreateCommand()).addCommand(privateKeyCreateCommand()).addCommand(middlewareCreateCommand()).addCommand(storageCreateCommand()).addCommand(integrationToolCreateCommand()).addCommand(insightsCreateCommand()).addCommand(applicationAccessTokenCreateCommand()).addCommand(loadBalancerCreateCommand());
258025
258212
  }
258026
258213
 
258027
258214
  // src/prompts/delete-confirmation.prompt.ts
@@ -258261,6 +258448,19 @@ function integrationToolRestartCommand() {
258261
258448
  return new Command("integration-tool").alias("it").description("Restart an integration tool service in the SettleMint platform").addCommand(hasuraRestartCommand());
258262
258449
  }
258263
258450
 
258451
+ // src/commands/platform/load-balancer/restart.ts
258452
+ function loadBalancerRestartCommand() {
258453
+ return getRestartCommand({
258454
+ name: "load-balancer",
258455
+ type: "load balancer",
258456
+ alias: "lb",
258457
+ envKey: "SETTLEMINT_BLOCKCHAIN_NODE_OR_LOAD_BALANCER",
258458
+ restartFunction: async (settlemint, id) => {
258459
+ return settlemint.loadBalancer.restart(id);
258460
+ }
258461
+ });
258462
+ }
258463
+
258264
258464
  // src/commands/platform/middleware/graph/restart.ts
258265
258465
  function graphRestartCommand() {
258266
258466
  return getRestartCommand({
@@ -258327,7 +258527,7 @@ function storageRestartCommand() {
258327
258527
 
258328
258528
  // src/commands/platform/restart.ts
258329
258529
  function restartCommand() {
258330
- const cmd2 = new Command("restart").description("Restart a resource in the SettleMint platform").addCommand(blockchainNetworkRestartCommand()).addCommand(customDeploymentRestartCommand()).addCommand(insightsRestartCommand()).addCommand(integrationToolRestartCommand()).addCommand(middlewareRestartCommand()).addCommand(storageRestartCommand());
258530
+ const cmd2 = new Command("restart").description("Restart a resource in the SettleMint platform").addCommand(blockchainNetworkRestartCommand()).addCommand(customDeploymentRestartCommand()).addCommand(insightsRestartCommand()).addCommand(integrationToolRestartCommand()).addCommand(middlewareRestartCommand()).addCommand(storageRestartCommand()).addCommand(loadBalancerRestartCommand());
258331
258531
  return cmd2;
258332
258532
  }
258333
258533
 
@@ -259170,11 +259370,6 @@ function getStatusAction(status) {
259170
259370
  return "Please try again later.";
259171
259371
  }
259172
259372
 
259173
- // src/utils/blockchain-node.ts
259174
- function validPrivateKey(privateKey) {
259175
- return privateKey.privateKeyType !== "HD_ECDSA_P256";
259176
- }
259177
-
259178
259373
  // src/commands/smart-contract-set/hardhat/utils/select-target-node.ts
259179
259374
  async function selectTargetNode({
259180
259375
  env: env2,
@@ -259220,7 +259415,7 @@ function validateNode(node, cancelOnError = true) {
259220
259415
  }
259221
259416
  return false;
259222
259417
  }
259223
- if (node.privateKeys?.filter((privateKey) => validPrivateKey(privateKey)).length === 0) {
259418
+ if (node.privateKeys?.filter(hasValidPrivateKey).length === 0) {
259224
259419
  if (cancelOnError) {
259225
259420
  cancel2(`The specified blockchain node '${node.uniqueName}' does not have an ECDSA P256 or HSM ECDSA P256 private key activated. Please activate an ECDSA P256 or HSM ECDSA P256 private key on your node and try again.`);
259226
259421
  }
@@ -259241,7 +259436,7 @@ async function addressPrompt({
259241
259436
  node,
259242
259437
  hardhatConfig
259243
259438
  }) {
259244
- const possiblePrivateKeys = node.privateKeys?.filter((privateKey) => validPrivateKey(privateKey)) ?? [];
259439
+ const possiblePrivateKeys = node.privateKeys?.filter(hasValidPrivateKey) ?? [];
259245
259440
  const defaultAddress = hardhatConfig.networks?.btp?.from ?? possiblePrivateKeys[0]?.address;
259246
259441
  const defaultPossible = accept && defaultAddress;
259247
259442
  if (defaultPossible) {
@@ -259997,4 +260192,4 @@ async function sdkCliCommand(argv = process.argv) {
259997
260192
  // src/cli.ts
259998
260193
  sdkCliCommand();
259999
260194
 
260000
- //# debugId=5250BB52C7AD397564756E2164756E21
260195
+ //# debugId=33076A9097BEE00964756E2164756E21