@construct-space/cli 1.4.0 → 1.4.2
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/index.js +62 -12
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -2873,9 +2873,66 @@ var init_auth = __esm(() => {
|
|
|
2873
2873
|
init_appdir();
|
|
2874
2874
|
});
|
|
2875
2875
|
|
|
2876
|
+
// src/commands/whoami.ts
|
|
2877
|
+
var exports_whoami = {};
|
|
2878
|
+
__export(exports_whoami, {
|
|
2879
|
+
whoami: () => whoami
|
|
2880
|
+
});
|
|
2881
|
+
async function whoami() {
|
|
2882
|
+
let creds;
|
|
2883
|
+
try {
|
|
2884
|
+
creds = load2();
|
|
2885
|
+
} catch {
|
|
2886
|
+
console.error(source_default.red("Not signed in."));
|
|
2887
|
+
console.error(source_default.dim("Run 'construct login' first."));
|
|
2888
|
+
process.exit(1);
|
|
2889
|
+
}
|
|
2890
|
+
const res = await fetch(ACCOUNTS_SCOPE_URL2, {
|
|
2891
|
+
headers: { Authorization: `Bearer ${creds.token}`, Accept: "application/json" }
|
|
2892
|
+
});
|
|
2893
|
+
if (!res.ok) {
|
|
2894
|
+
console.error(source_default.red(`Scope lookup failed (${res.status}).`));
|
|
2895
|
+
console.error(source_default.dim("Token may be expired. Try: construct login"));
|
|
2896
|
+
process.exit(1);
|
|
2897
|
+
}
|
|
2898
|
+
const s = await res.json();
|
|
2899
|
+
if (!s.authenticated || !s.user) {
|
|
2900
|
+
console.error(source_default.red("Token rejected."));
|
|
2901
|
+
process.exit(1);
|
|
2902
|
+
}
|
|
2903
|
+
const name = [s.user.first_name, s.user.last_name].filter(Boolean).join(" ") || s.user.username || "";
|
|
2904
|
+
console.log(source_default.bold(s.user.email || name));
|
|
2905
|
+
if (name && name !== s.user.email)
|
|
2906
|
+
console.log(source_default.dim(" " + name));
|
|
2907
|
+
if (s.user.uuid)
|
|
2908
|
+
console.log(source_default.dim(" user " + s.user.uuid));
|
|
2909
|
+
if (s.scope === "org" && s.org) {
|
|
2910
|
+
console.log();
|
|
2911
|
+
console.log(source_default.cyan("Organization"));
|
|
2912
|
+
console.log(` ${s.org.name || s.org.slug || s.org.id}`);
|
|
2913
|
+
if (s.org.id)
|
|
2914
|
+
console.log(source_default.dim(" " + s.org.id));
|
|
2915
|
+
if (s.roles && s.roles.length)
|
|
2916
|
+
console.log(source_default.dim(" roles: " + s.roles.join(", ")));
|
|
2917
|
+
} else {
|
|
2918
|
+
console.log();
|
|
2919
|
+
console.log(source_default.cyan("Scope"));
|
|
2920
|
+
console.log(" Personal (no organization)");
|
|
2921
|
+
console.log(source_default.dim(" Switch to an org at https://my.construct.space"));
|
|
2922
|
+
}
|
|
2923
|
+
if (s.developer)
|
|
2924
|
+
console.log(source_default.dim(`
|
|
2925
|
+
developer capability: enabled`));
|
|
2926
|
+
}
|
|
2927
|
+
var ACCOUNTS_SCOPE_URL2 = "https://my.construct.space/api/accounts/me/scope";
|
|
2928
|
+
var init_whoami = __esm(() => {
|
|
2929
|
+
init_source();
|
|
2930
|
+
init_auth();
|
|
2931
|
+
});
|
|
2932
|
+
|
|
2876
2933
|
// src/lib/graphClient.ts
|
|
2877
2934
|
function graphBaseURL() {
|
|
2878
|
-
return process.env.GRAPH_URL || "https://
|
|
2935
|
+
return process.env.GRAPH_URL || "https://graph.construct.space";
|
|
2879
2936
|
}
|
|
2880
2937
|
function resolveOrgId(explicit) {
|
|
2881
2938
|
if (explicit)
|
|
@@ -2897,10 +2954,6 @@ async function graphRequest(opts) {
|
|
|
2897
2954
|
Authorization: `Bearer ${creds.token}`,
|
|
2898
2955
|
"Content-Type": "application/json"
|
|
2899
2956
|
};
|
|
2900
|
-
if (creds.user?.id)
|
|
2901
|
-
headers["X-Auth-User-ID"] = creds.user.id;
|
|
2902
|
-
if (opts.orgId)
|
|
2903
|
-
headers["X-Auth-Org-ID"] = opts.orgId;
|
|
2904
2957
|
const resp = await fetch(graphBaseURL() + opts.path, {
|
|
2905
2958
|
method: opts.method || "GET",
|
|
2906
2959
|
headers,
|
|
@@ -2922,11 +2975,7 @@ async function graphRequest(opts) {
|
|
|
2922
2975
|
return JSON.parse(text);
|
|
2923
2976
|
}
|
|
2924
2977
|
function requireOrgId(explicit) {
|
|
2925
|
-
|
|
2926
|
-
if (!org) {
|
|
2927
|
-
throw new Error("org context required. Pass --org <id> or set CONSTRUCT_ORG_ID. " + "Find your org id on the profile page or via accounts /api/me/scope.");
|
|
2928
|
-
}
|
|
2929
|
-
return org;
|
|
2978
|
+
return resolveOrgId(explicit);
|
|
2930
2979
|
}
|
|
2931
2980
|
var init_graphClient = __esm(() => {
|
|
2932
2981
|
init_auth();
|
|
@@ -10734,7 +10783,7 @@ async function graphPush() {
|
|
|
10734
10783
|
console.error(source_default.red(err.message));
|
|
10735
10784
|
process.exit(1);
|
|
10736
10785
|
}
|
|
10737
|
-
const graphURL = process.env.GRAPH_URL || "https://
|
|
10786
|
+
const graphURL = process.env.GRAPH_URL || "https://graph.construct.space";
|
|
10738
10787
|
const spinner = ora("Registering models...").start();
|
|
10739
10788
|
try {
|
|
10740
10789
|
const userID = creds.user?.id || "";
|
|
@@ -10882,7 +10931,7 @@ async function graphMigrate(options) {
|
|
|
10882
10931
|
console.error(source_default.red(err.message));
|
|
10883
10932
|
process.exit(1);
|
|
10884
10933
|
}
|
|
10885
|
-
const graphURL = process.env.GRAPH_URL || "https://
|
|
10934
|
+
const graphURL = process.env.GRAPH_URL || "https://graph.construct.space";
|
|
10886
10935
|
const spinner = ora("Fetching current schema...").start();
|
|
10887
10936
|
let serverModels = [];
|
|
10888
10937
|
try {
|
|
@@ -11019,6 +11068,7 @@ program2.command("clean").description("Remove build artifacts").option("--all",
|
|
|
11019
11068
|
program2.command("login").description("Authenticate with Construct").option("--portal <url>", "Portal URL").option("--token <token>", "Authenticate with a token directly (skip desktop profile picker)").action(async (opts) => login(opts));
|
|
11020
11069
|
program2.command("logout").description("Sign out").action(() => logout());
|
|
11021
11070
|
program2.command("update").description("Update the CLI to the latest version").action(() => update());
|
|
11071
|
+
program2.command("whoami").alias("status").description("Show the signed-in user + current org scope").action(async () => (await Promise.resolve().then(() => (init_whoami(), exports_whoami))).whoami());
|
|
11022
11072
|
var graph = program2.command("graph").description("Construct Graph \u2014 data models and GraphQL");
|
|
11023
11073
|
graph.command("init").description("Initialize Graph in a space project").action(() => graphInit());
|
|
11024
11074
|
graph.command("generate <model> [fields...]").alias("g").description("Generate a data model").option("--access <rules>", "Access rules (e.g. read:member,create:member,update:owner,delete:admin)").action((model, fields, opts) => generate2(model, fields, opts));
|