oneclient 0.1.1 → 0.1.3
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/config.d.ts +3 -0
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +9 -0
- package/dist/index.js +37 -16
- package/package.json +3 -3
package/dist/config.d.ts
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
export declare const DEFAULT_CONTROL_API_URL = "https://control.one-client.com";
|
|
2
2
|
export declare const DEFAULT_CONSOLE_ORIGIN = "https://console.one-client.com";
|
|
3
3
|
export declare function developerAuthOrigin(apiUrl: string): string;
|
|
4
|
+
export declare function inferOrganizationId(explicitId: string | undefined, organizations: Array<{
|
|
5
|
+
id: string;
|
|
6
|
+
}>): string;
|
|
4
7
|
//# sourceMappingURL=config.d.ts.map
|
package/dist/config.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,uBAAuB,mCAAmC,CAAC;AACxE,eAAO,MAAM,sBAAsB,mCAAmC,CAAC;AAEvE,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAG1D"}
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,uBAAuB,mCAAmC,CAAC;AACxE,eAAO,MAAM,sBAAsB,mCAAmC,CAAC;AAEvE,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAG1D;AAED,wBAAgB,mBAAmB,CACjC,UAAU,EAAE,MAAM,GAAG,SAAS,EAC9B,aAAa,EAAE,KAAK,CAAC;IAAE,EAAE,EAAE,MAAM,CAAA;CAAE,CAAC,GACnC,MAAM,CAMR"}
|
package/dist/config.js
CHANGED
|
@@ -4,3 +4,12 @@ export function developerAuthOrigin(apiUrl) {
|
|
|
4
4
|
const origin = new URL(apiUrl).origin;
|
|
5
5
|
return origin === DEFAULT_CONTROL_API_URL ? DEFAULT_CONSOLE_ORIGIN : origin;
|
|
6
6
|
}
|
|
7
|
+
export function inferOrganizationId(explicitId, organizations) {
|
|
8
|
+
if (explicitId)
|
|
9
|
+
return explicitId;
|
|
10
|
+
if (organizations.length === 1)
|
|
11
|
+
return organizations[0].id;
|
|
12
|
+
if (organizations.length === 0)
|
|
13
|
+
throw new Error("Create an organization with `oneclient organization:create` first");
|
|
14
|
+
throw new Error("This account has multiple organizations; pass --organization <id>");
|
|
15
|
+
}
|
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";
|
|
@@ -14,12 +14,12 @@ import { deployTokenFromEnvironment, parseServerKeyScopes, serverKeyFromEnvironm
|
|
|
14
14
|
import { secretValueFromOptions } from "./secret-input.js";
|
|
15
15
|
import { brand, formatOutput, statusLine } from "./presenter.js";
|
|
16
16
|
import { slugify } from "./slug.js";
|
|
17
|
-
import { DEFAULT_CONTROL_API_URL } from "./config.js";
|
|
17
|
+
import { DEFAULT_CONTROL_API_URL, inferOrganizationId } from "./config.js";
|
|
18
18
|
const program = new Command();
|
|
19
19
|
program
|
|
20
20
|
.name("oneclient")
|
|
21
21
|
.description("Deploy and manage OneClient projects")
|
|
22
|
-
.version("0.1.
|
|
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)
|
|
@@ -115,7 +115,7 @@ program
|
|
|
115
115
|
program
|
|
116
116
|
.command("projects")
|
|
117
117
|
.description("List projects")
|
|
118
|
-
.action(async () => print(await
|
|
118
|
+
.action(async () => print(await organizationSessionClient().then((api) => api.projects.list()), "Projects"));
|
|
119
119
|
program
|
|
120
120
|
.command("project:create")
|
|
121
121
|
.description("Create a project and its development and production environments")
|
|
@@ -155,7 +155,7 @@ program
|
|
|
155
155
|
program
|
|
156
156
|
.command("usage")
|
|
157
157
|
.description("Show the prepaid wallet and retention reserve")
|
|
158
|
-
.action(async () => print(await
|
|
158
|
+
.action(async () => print(await organizationSessionClient().then((api) => api.usage.summary()), "Usage & balance"));
|
|
159
159
|
program
|
|
160
160
|
.command("status")
|
|
161
161
|
.description("Show account, organization, project, and spend status in one view")
|
|
@@ -199,7 +199,7 @@ program
|
|
|
199
199
|
const limit = Number(options.limit);
|
|
200
200
|
if (!Number.isInteger(limit) || limit < 1 || limit > 100)
|
|
201
201
|
throw new Error("limit must be an integer from 1 through 100");
|
|
202
|
-
print(await
|
|
202
|
+
print(await organizationSessionClient().then((api) => api.usage.activity(limit)), "Recent activity");
|
|
203
203
|
});
|
|
204
204
|
program
|
|
205
205
|
.command("deployments")
|
|
@@ -269,26 +269,26 @@ program
|
|
|
269
269
|
program
|
|
270
270
|
.command("billing:portal")
|
|
271
271
|
.description("Create a secure Stripe billing-portal session")
|
|
272
|
-
.action(async () => print(await
|
|
272
|
+
.action(async () => print(await organizationSessionClient().then((api) => api.billing.portal()), "Billing portal"));
|
|
273
273
|
program
|
|
274
274
|
.command("billing:subscribe")
|
|
275
275
|
.description("Create a subscription Checkout session")
|
|
276
|
-
.action(async () => print(await
|
|
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("--
|
|
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
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
const amountMicros =
|
|
286
|
-
print(await
|
|
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")
|
|
290
290
|
.description("List application, API, and sending domains")
|
|
291
|
-
.action(async () => print(await
|
|
291
|
+
.action(async () => print(await organizationSessionClient().then((api) => api.domains.list()), "Domains"));
|
|
292
292
|
program
|
|
293
293
|
.command("domain:add")
|
|
294
294
|
.description("Attach a custom hostname")
|
|
@@ -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;
|
|
@@ -572,6 +585,14 @@ async function sessionClient(organizationId) {
|
|
|
572
585
|
: {}),
|
|
573
586
|
});
|
|
574
587
|
}
|
|
588
|
+
async function organizationSessionClient() {
|
|
589
|
+
const explicitId = program.opts().organization;
|
|
590
|
+
if (explicitId)
|
|
591
|
+
return sessionClient(explicitId);
|
|
592
|
+
const base = await sessionClient();
|
|
593
|
+
const organizations = await base.organizations.list();
|
|
594
|
+
return sessionClient(inferOrganizationId(undefined, organizations));
|
|
595
|
+
}
|
|
575
596
|
async function deployClient() {
|
|
576
597
|
const options = program.opts();
|
|
577
598
|
const deployToken = deployTokenFromEnvironment();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "oneclient",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.3",
|
|
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",
|
|
@@ -38,8 +38,8 @@
|
|
|
38
38
|
"dependencies": {
|
|
39
39
|
"commander": "15.0.0",
|
|
40
40
|
"tar": "7.5.22",
|
|
41
|
-
"@oneclient/
|
|
42
|
-
"@oneclient/
|
|
41
|
+
"@oneclient/sdk": "0.1.1",
|
|
42
|
+
"@oneclient/contracts": "0.1.0"
|
|
43
43
|
},
|
|
44
44
|
"devDependencies": {
|
|
45
45
|
"@types/node": "26.4.0",
|