oneclient 0.1.2 → 0.1.4

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 (2) hide show
  1. package/dist/index.js +22 -9
  2. package/package.json +4 -4
package/dist/index.js CHANGED
@@ -5,7 +5,7 @@ import { readFile, stat } from "node:fs/promises";
5
5
  import process from "node:process";
6
6
  import { createInterface } from "node:readline/promises";
7
7
  import { Command } from "commander";
8
- import { createClient } from "@oneclient/sdk";
8
+ import { createClient, creditsToMicros, OneClientError, } from "@oneclient/sdk";
9
9
  import { deploymentWaitTimeout, waitForDeployment } from "./deployment-wait.js";
10
10
  import { createArtifact } from "./artifact-create.js";
11
11
  import { clearDeveloperCredentials, readDeveloperCredentials, writeDeveloperCredentials, } from "./credentials.js";
@@ -19,7 +19,7 @@ const program = new Command();
19
19
  program
20
20
  .name("oneclient")
21
21
  .description("Deploy and manage OneClient projects")
22
- .version("0.1.2")
22
+ .version("0.1.3")
23
23
  .option("--api-url <url>", "Control or environment API URL", process.env.ONECLIENT_API_URL)
24
24
  .option("--organization <id>", "Organization ID", process.env.ONECLIENT_ORGANIZATION_ID)
25
25
  .option("--json", "Print stable JSON for scripts and agents", false)
@@ -276,14 +276,14 @@ program
276
276
  .action(async () => print(await organizationSessionClient().then((api) => api.billing.subscriptionCheckout()), "Subscription checkout"));
277
277
  program
278
278
  .command("billing:topup")
279
- .description("Create a prepaid credit Checkout session")
280
- .requiredOption("--usd <amount>", "USD amount; minimum $25")
279
+ .description("Create a prepaid OneClient credit-pack Checkout session")
280
+ .requiredOption("--credits <amount>", "OneClient credits; available packs start at 2,500")
281
281
  .action(async (options) => {
282
- const dollars = Number(options.usd);
283
- if (!Number.isFinite(dollars) || dollars < 25 || Math.round(dollars * 100) !== dollars * 100)
284
- throw new Error("usd must be at least 25 with no more than two decimal places");
285
- const amountMicros = String(Math.round(dollars * 1_000_000));
286
- print(await organizationSessionClient().then((api) => api.billing.topupCheckout(amountMicros)), "Credit checkout");
282
+ if (!/^[1-9][0-9]*$/.test(options.credits) || BigInt(options.credits) < 2500n) {
283
+ throw new Error("credits must be a whole number of at least 2,500");
284
+ }
285
+ const amountMicros = creditsToMicros(options.credits);
286
+ print(await organizationSessionClient().then((api) => api.billing.topupCheckout(amountMicros)), "Credit-pack checkout");
287
287
  });
288
288
  program
289
289
  .command("domain:list")
@@ -553,6 +553,19 @@ program
553
553
  process.stdout.write(logs.endsWith("\n") ? logs : `${logs}\n`);
554
554
  });
555
555
  program.parseAsync().catch((error) => {
556
+ if (program.opts().json && error instanceof OneClientError) {
557
+ process.stderr.write(`${JSON.stringify({
558
+ error: {
559
+ code: error.code,
560
+ message: error.message,
561
+ requestId: error.requestId,
562
+ status: error.status,
563
+ ...(error.details ? { details: error.details } : {}),
564
+ },
565
+ })}\n`);
566
+ process.exitCode = 1;
567
+ return;
568
+ }
556
569
  const message = error instanceof Error ? error.message : String(error);
557
570
  process.stderr.write(`${statusLine("error", message, colorEnabled())}\n`);
558
571
  process.exitCode = 1;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "oneclient",
3
- "version": "0.1.2",
3
+ "version": "0.1.4",
4
4
  "description": "One package for the complete OneClient TypeScript SDK and developer CLI.",
5
5
  "license": "UNLICENSED",
6
6
  "homepage": "https://one-client.com",
@@ -36,10 +36,10 @@
36
36
  }
37
37
  },
38
38
  "dependencies": {
39
+ "@oneclient/contracts": "0.1.1",
40
+ "@oneclient/sdk": "0.1.2",
39
41
  "commander": "15.0.0",
40
- "tar": "7.5.22",
41
- "@oneclient/contracts": "0.1.0",
42
- "@oneclient/sdk": "0.1.0"
42
+ "tar": "7.5.22"
43
43
  },
44
44
  "devDependencies": {
45
45
  "@types/node": "26.4.0",