@indigoai-us/hq-cli 5.8.3 → 5.8.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.
- package/dist/commands/files.js +24 -6
- package/dist/index.js +1 -1
- package/package.json +1 -1
- package/src/commands/files.ts +28 -6
- package/src/index.ts +1 -1
package/dist/commands/files.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
|
|
2
|
-
!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="
|
|
2
|
+
!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="3d902660-a8aa-5671-ab69-21ffc0143c60")}catch(e){}}();
|
|
3
3
|
import chalk from "chalk";
|
|
4
4
|
import { ensureCognitoToken } from "../utils/cognito-session.js";
|
|
5
5
|
import { vaultApiFetch, getCompanyUid } from "./secrets.js";
|
|
@@ -33,12 +33,28 @@ export function registerFilesCommand(program) {
|
|
|
33
33
|
const token = await ensureCognitoToken();
|
|
34
34
|
const companySlug = files.opts().company;
|
|
35
35
|
const companyUid = await getCompanyUid(token, companySlug);
|
|
36
|
-
|
|
36
|
+
let res = await vaultApiFetch({
|
|
37
37
|
token,
|
|
38
38
|
path: `/files/${encodeURIComponent(companyUid)}/acl/grant`,
|
|
39
39
|
method: "POST",
|
|
40
40
|
body: { prefix: canonicalPrefix, granteeType, granteeId, permission: opts.permission },
|
|
41
41
|
});
|
|
42
|
+
// No ACL row exists yet for this prefix. Auto-create one with this
|
|
43
|
+
// grant as its first entry, then report success — saves the caller
|
|
44
|
+
// from needing a separate "create" step.
|
|
45
|
+
let autoCreated = false;
|
|
46
|
+
if (res.status === 404) {
|
|
47
|
+
res = await vaultApiFetch({
|
|
48
|
+
token,
|
|
49
|
+
path: `/files/${encodeURIComponent(companyUid)}/acl`,
|
|
50
|
+
method: "POST",
|
|
51
|
+
body: {
|
|
52
|
+
prefix: canonicalPrefix,
|
|
53
|
+
entries: [{ granteeType, granteeId, permission: opts.permission }],
|
|
54
|
+
},
|
|
55
|
+
});
|
|
56
|
+
autoCreated = res.ok;
|
|
57
|
+
}
|
|
42
58
|
if (!res.ok) {
|
|
43
59
|
const body = await res.json().catch(() => ({}));
|
|
44
60
|
if (res.status === 401) {
|
|
@@ -62,8 +78,9 @@ export function registerFilesCommand(program) {
|
|
|
62
78
|
process.exit(1);
|
|
63
79
|
}
|
|
64
80
|
const data = await res.json();
|
|
65
|
-
const printedPrefix = data.acl?.prefix ?? canonicalPrefix;
|
|
66
|
-
|
|
81
|
+
const printedPrefix = data.acl?.path ?? data.acl?.prefix ?? canonicalPrefix;
|
|
82
|
+
const verb = autoCreated ? "Created ACL and granted" : "Granted";
|
|
83
|
+
console.log(chalk.green(`${verb} ${opts.permission} on ${printedPrefix} to ${granteeId}`));
|
|
67
84
|
}
|
|
68
85
|
catch (err) {
|
|
69
86
|
console.error(chalk.red("Error:"), err instanceof Error ? err.message : String(err));
|
|
@@ -158,7 +175,8 @@ export function registerFilesCommand(program) {
|
|
|
158
175
|
const data = await res.json();
|
|
159
176
|
const acl = data.acl;
|
|
160
177
|
const aclStatus = acl.open ? "open" : "restricted";
|
|
161
|
-
|
|
178
|
+
const aclPrefix = acl.path ?? acl.prefix ?? canonicalPrefix;
|
|
179
|
+
console.log(chalk.green(`ACL for ${aclPrefix} (${aclStatus})`));
|
|
162
180
|
console.log(`Creator: ${acl.creatorUid}`);
|
|
163
181
|
if (acl.effectivePermission) {
|
|
164
182
|
console.log(`Your effective permission: ${acl.effectivePermission}`);
|
|
@@ -203,4 +221,4 @@ export function registerFilesCommand(program) {
|
|
|
203
221
|
});
|
|
204
222
|
}
|
|
205
223
|
//# sourceMappingURL=files.js.map
|
|
206
|
-
//# debugId=
|
|
224
|
+
//# debugId=3d902660-a8aa-5671-ab69-21ffc0143c60
|
package/dist/index.js
CHANGED
|
@@ -30,7 +30,7 @@ const program = new Command();
|
|
|
30
30
|
program
|
|
31
31
|
.name("hq")
|
|
32
32
|
.description("HQ management CLI — modules, packages, and cloud sync")
|
|
33
|
-
.version("5.8.
|
|
33
|
+
.version("5.8.4");
|
|
34
34
|
// Module management subcommand group
|
|
35
35
|
const modulesCmd = program
|
|
36
36
|
.command("modules")
|
package/package.json
CHANGED
package/src/commands/files.ts
CHANGED
|
@@ -38,13 +38,30 @@ export function registerFilesCommand(program: Command): void {
|
|
|
38
38
|
const companySlug = files.opts().company as string | undefined;
|
|
39
39
|
const companyUid = await getCompanyUid(token, companySlug);
|
|
40
40
|
|
|
41
|
-
|
|
41
|
+
let res = await vaultApiFetch({
|
|
42
42
|
token,
|
|
43
43
|
path: `/files/${encodeURIComponent(companyUid)}/acl/grant`,
|
|
44
44
|
method: "POST",
|
|
45
45
|
body: { prefix: canonicalPrefix, granteeType, granteeId, permission: opts.permission },
|
|
46
46
|
});
|
|
47
47
|
|
|
48
|
+
// No ACL row exists yet for this prefix. Auto-create one with this
|
|
49
|
+
// grant as its first entry, then report success — saves the caller
|
|
50
|
+
// from needing a separate "create" step.
|
|
51
|
+
let autoCreated = false;
|
|
52
|
+
if (res.status === 404) {
|
|
53
|
+
res = await vaultApiFetch({
|
|
54
|
+
token,
|
|
55
|
+
path: `/files/${encodeURIComponent(companyUid)}/acl`,
|
|
56
|
+
method: "POST",
|
|
57
|
+
body: {
|
|
58
|
+
prefix: canonicalPrefix,
|
|
59
|
+
entries: [{ granteeType, granteeId, permission: opts.permission }],
|
|
60
|
+
},
|
|
61
|
+
});
|
|
62
|
+
autoCreated = res.ok;
|
|
63
|
+
}
|
|
64
|
+
|
|
48
65
|
if (!res.ok) {
|
|
49
66
|
const body = await res.json().catch(() => ({})) as Record<string, string>;
|
|
50
67
|
if (res.status === 401) {
|
|
@@ -63,9 +80,10 @@ export function registerFilesCommand(program: Command): void {
|
|
|
63
80
|
process.exit(1);
|
|
64
81
|
}
|
|
65
82
|
|
|
66
|
-
const data = await res.json() as { acl?: { prefix?: string } };
|
|
67
|
-
const printedPrefix = data.acl?.prefix ?? canonicalPrefix;
|
|
68
|
-
|
|
83
|
+
const data = await res.json() as { acl?: { path?: string; prefix?: string } };
|
|
84
|
+
const printedPrefix = data.acl?.path ?? data.acl?.prefix ?? canonicalPrefix;
|
|
85
|
+
const verb = autoCreated ? "Created ACL and granted" : "Granted";
|
|
86
|
+
console.log(chalk.green(`${verb} ${opts.permission} on ${printedPrefix} to ${granteeId}`));
|
|
69
87
|
} catch (err) {
|
|
70
88
|
console.error(chalk.red("Error:"), err instanceof Error ? err.message : String(err));
|
|
71
89
|
process.exit(1);
|
|
@@ -162,7 +180,10 @@ export function registerFilesCommand(program: Command): void {
|
|
|
162
180
|
acl: {
|
|
163
181
|
itemType: string;
|
|
164
182
|
companyUid: string;
|
|
165
|
-
|
|
183
|
+
// Server returns `path` (the FileAcl field name); older builds
|
|
184
|
+
// used `prefix`. Read both so the CLI works against either.
|
|
185
|
+
path?: string;
|
|
186
|
+
prefix?: string;
|
|
166
187
|
creatorUid: string;
|
|
167
188
|
open?: boolean;
|
|
168
189
|
entries: Array<{
|
|
@@ -180,8 +201,9 @@ export function registerFilesCommand(program: Command): void {
|
|
|
180
201
|
|
|
181
202
|
const acl = data.acl;
|
|
182
203
|
const aclStatus = acl.open ? "open" : "restricted";
|
|
204
|
+
const aclPrefix = acl.path ?? acl.prefix ?? canonicalPrefix;
|
|
183
205
|
|
|
184
|
-
console.log(chalk.green(`ACL for ${
|
|
206
|
+
console.log(chalk.green(`ACL for ${aclPrefix} (${aclStatus})`));
|
|
185
207
|
console.log(`Creator: ${acl.creatorUid}`);
|
|
186
208
|
if (acl.effectivePermission) {
|
|
187
209
|
console.log(`Your effective permission: ${acl.effectivePermission}`);
|
package/src/index.ts
CHANGED