figmanage 1.0.0 → 1.1.0
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/README.md +74 -59
- package/dist/cli/analytics.d.ts +3 -0
- package/dist/cli/analytics.js +48 -0
- package/dist/cli/branching.d.ts +3 -0
- package/dist/cli/branching.js +56 -0
- package/dist/cli/comments.d.ts +3 -0
- package/dist/cli/comments.js +86 -0
- package/dist/cli/components.d.ts +3 -0
- package/dist/cli/components.js +82 -0
- package/dist/cli/compound-commands.d.ts +14 -0
- package/dist/cli/compound-commands.js +291 -0
- package/dist/cli/export.d.ts +3 -0
- package/dist/cli/export.js +51 -0
- package/dist/cli/files.d.ts +3 -0
- package/dist/cli/files.js +156 -0
- package/dist/cli/helpers.d.ts +7 -0
- package/dist/cli/helpers.js +43 -0
- package/dist/cli/index.js +65 -89
- package/dist/cli/libraries.d.ts +3 -0
- package/dist/cli/libraries.js +26 -0
- package/dist/cli/navigate.d.ts +3 -0
- package/dist/cli/navigate.js +192 -0
- package/dist/cli/org.d.ts +3 -0
- package/dist/cli/org.js +227 -0
- package/dist/cli/permissions.d.ts +3 -0
- package/dist/cli/permissions.js +133 -0
- package/dist/cli/projects.d.ts +3 -0
- package/dist/cli/projects.js +110 -0
- package/dist/cli/reading.d.ts +3 -0
- package/dist/cli/reading.js +51 -0
- package/dist/cli/teams.d.ts +3 -0
- package/dist/cli/teams.js +56 -0
- package/dist/cli/variables.d.ts +3 -0
- package/dist/cli/variables.js +80 -0
- package/dist/cli/versions.d.ts +3 -0
- package/dist/cli/versions.js +46 -0
- package/dist/cli/webhooks.d.ts +3 -0
- package/dist/cli/webhooks.js +100 -0
- package/dist/cli/whoami.js +3 -2
- package/dist/index.js +1 -1
- package/dist/operations/analytics.d.ts +10 -0
- package/dist/operations/analytics.js +15 -0
- package/dist/operations/branching.d.ts +24 -0
- package/dist/operations/branching.js +41 -0
- package/dist/operations/comments.d.ts +43 -0
- package/dist/operations/comments.js +65 -0
- package/dist/operations/components.d.ts +24 -0
- package/dist/operations/components.js +30 -0
- package/dist/operations/compound-manager.d.ts +101 -0
- package/dist/operations/compound-manager.js +629 -0
- package/dist/operations/compound.d.ts +102 -0
- package/dist/operations/compound.js +595 -0
- package/dist/operations/export.d.ts +19 -0
- package/dist/operations/export.js +27 -0
- package/dist/operations/files.d.ts +55 -0
- package/dist/operations/files.js +89 -0
- package/dist/operations/libraries.d.ts +5 -0
- package/dist/operations/libraries.js +10 -0
- package/dist/operations/navigate.d.ts +99 -0
- package/dist/operations/navigate.js +266 -0
- package/dist/operations/org.d.ts +95 -0
- package/dist/operations/org.js +205 -0
- package/dist/operations/permissions.d.ts +59 -0
- package/dist/operations/permissions.js +112 -0
- package/dist/operations/projects.d.ts +29 -0
- package/dist/operations/projects.js +40 -0
- package/dist/operations/reading.d.ts +12 -0
- package/dist/operations/reading.js +20 -0
- package/dist/operations/teams.d.ts +17 -0
- package/dist/operations/teams.js +17 -0
- package/dist/operations/variables.d.ts +17 -0
- package/dist/operations/variables.js +39 -0
- package/dist/operations/versions.d.ts +23 -0
- package/dist/operations/versions.js +27 -0
- package/dist/operations/webhooks.d.ts +25 -0
- package/dist/operations/webhooks.js +38 -0
- package/dist/tools/analytics.js +6 -16
- package/dist/tools/branching.js +7 -36
- package/dist/tools/comments.js +9 -56
- package/dist/tools/components.js +7 -19
- package/dist/tools/compound-manager.js +21 -644
- package/dist/tools/compound.js +32 -566
- package/dist/tools/export.js +4 -23
- package/dist/tools/files.js +21 -68
- package/dist/tools/libraries.js +4 -11
- package/dist/tools/navigate.js +23 -246
- package/dist/tools/org.js +29 -245
- package/dist/tools/permissions.js +18 -97
- package/dist/tools/projects.js +8 -27
- package/dist/tools/reading.js +5 -15
- package/dist/tools/teams.js +8 -16
- package/dist/tools/variables.js +13 -30
- package/dist/tools/versions.js +6 -24
- package/dist/tools/webhooks.js +7 -24
- package/package.json +1 -1
- package/dist/cli/commands.d.ts +0 -47
- package/dist/cli/commands.js +0 -1204
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
import { Command } from 'commander';
|
|
2
|
+
import { getPermissions, setPermissions, share, revokeAccess, listRoleRequests, approveRoleRequest, denyRoleRequest, } from '../operations/permissions.js';
|
|
3
|
+
import { output, error } from './format.js';
|
|
4
|
+
import { requireCookie } from './helpers.js';
|
|
5
|
+
export function permissionsCommand() {
|
|
6
|
+
const permissions = new Command('permissions')
|
|
7
|
+
.description('Manage file, project, and team permissions');
|
|
8
|
+
permissions
|
|
9
|
+
.command('get <resource-type> <resource-id>')
|
|
10
|
+
.description('See who has access to a file, project, or team')
|
|
11
|
+
.option('--json', 'Force JSON output')
|
|
12
|
+
.action(async (resourceType, resourceId, options) => {
|
|
13
|
+
try {
|
|
14
|
+
const config = requireCookie();
|
|
15
|
+
const result = await getPermissions(config, {
|
|
16
|
+
resource_type: resourceType,
|
|
17
|
+
resource_id: resourceId,
|
|
18
|
+
});
|
|
19
|
+
output(result, options);
|
|
20
|
+
}
|
|
21
|
+
catch (e) {
|
|
22
|
+
error(e.response?.status ? `API error: ${e.response.status}` : e.message);
|
|
23
|
+
process.exit(1);
|
|
24
|
+
}
|
|
25
|
+
});
|
|
26
|
+
permissions
|
|
27
|
+
.command('set <resource-type> <resource-id> <user-id> <role>')
|
|
28
|
+
.description('Change access level for a user on a file, project, or team')
|
|
29
|
+
.option('--json', 'Force JSON output')
|
|
30
|
+
.action(async (resourceType, resourceId, userId, role, options) => {
|
|
31
|
+
try {
|
|
32
|
+
const config = requireCookie();
|
|
33
|
+
const msg = await setPermissions(config, {
|
|
34
|
+
resource_type: resourceType,
|
|
35
|
+
resource_id: resourceId,
|
|
36
|
+
user_id: userId,
|
|
37
|
+
role,
|
|
38
|
+
});
|
|
39
|
+
output({ message: msg }, options);
|
|
40
|
+
}
|
|
41
|
+
catch (e) {
|
|
42
|
+
error(e.response?.status ? `API error: ${e.response.status}` : e.message);
|
|
43
|
+
process.exit(1);
|
|
44
|
+
}
|
|
45
|
+
});
|
|
46
|
+
permissions
|
|
47
|
+
.command('share <resource-type> <resource-id> <email>')
|
|
48
|
+
.description('Share a file or project with someone by email')
|
|
49
|
+
.option('--role <role>', 'Role to grant (editor or viewer)', 'viewer')
|
|
50
|
+
.option('--json', 'Force JSON output')
|
|
51
|
+
.action(async (resourceType, resourceId, email, options) => {
|
|
52
|
+
try {
|
|
53
|
+
const config = requireCookie();
|
|
54
|
+
const result = await share(config, {
|
|
55
|
+
resource_type: resourceType,
|
|
56
|
+
resource_id: resourceId,
|
|
57
|
+
email,
|
|
58
|
+
role: options.role,
|
|
59
|
+
});
|
|
60
|
+
output(result, options);
|
|
61
|
+
}
|
|
62
|
+
catch (e) {
|
|
63
|
+
error(e.response?.status ? `API error: ${e.response.status}` : e.message);
|
|
64
|
+
process.exit(1);
|
|
65
|
+
}
|
|
66
|
+
});
|
|
67
|
+
permissions
|
|
68
|
+
.command('revoke <resource-type> <resource-id> <user-id>')
|
|
69
|
+
.description("Remove someone's access to a file, project, or team")
|
|
70
|
+
.option('--json', 'Force JSON output')
|
|
71
|
+
.action(async (resourceType, resourceId, userId, options) => {
|
|
72
|
+
try {
|
|
73
|
+
const config = requireCookie();
|
|
74
|
+
const msg = await revokeAccess(config, {
|
|
75
|
+
resource_type: resourceType,
|
|
76
|
+
resource_id: resourceId,
|
|
77
|
+
user_id: userId,
|
|
78
|
+
});
|
|
79
|
+
output({ message: msg }, options);
|
|
80
|
+
}
|
|
81
|
+
catch (e) {
|
|
82
|
+
error(e.response?.status ? `API error: ${e.response.status}` : e.message);
|
|
83
|
+
process.exit(1);
|
|
84
|
+
}
|
|
85
|
+
});
|
|
86
|
+
permissions
|
|
87
|
+
.command('requests')
|
|
88
|
+
.description('List pending file access requests')
|
|
89
|
+
.option('--json', 'Force JSON output')
|
|
90
|
+
.action(async (options) => {
|
|
91
|
+
try {
|
|
92
|
+
const config = requireCookie();
|
|
93
|
+
const result = await listRoleRequests(config);
|
|
94
|
+
output(result, options);
|
|
95
|
+
}
|
|
96
|
+
catch (e) {
|
|
97
|
+
error(e.response?.status ? `API error: ${e.response.status}` : e.message);
|
|
98
|
+
process.exit(1);
|
|
99
|
+
}
|
|
100
|
+
});
|
|
101
|
+
permissions
|
|
102
|
+
.command('approve <notification-id>')
|
|
103
|
+
.description('Approve a pending file access request')
|
|
104
|
+
.option('--json', 'Force JSON output')
|
|
105
|
+
.action(async (notificationId, options) => {
|
|
106
|
+
try {
|
|
107
|
+
const config = requireCookie();
|
|
108
|
+
const msg = await approveRoleRequest(config, { notification_id: notificationId });
|
|
109
|
+
output({ message: msg }, options);
|
|
110
|
+
}
|
|
111
|
+
catch (e) {
|
|
112
|
+
error(e.response?.status ? `API error: ${e.response.status}` : e.message);
|
|
113
|
+
process.exit(1);
|
|
114
|
+
}
|
|
115
|
+
});
|
|
116
|
+
permissions
|
|
117
|
+
.command('deny <notification-id>')
|
|
118
|
+
.description('Decline a pending file access request')
|
|
119
|
+
.option('--json', 'Force JSON output')
|
|
120
|
+
.action(async (notificationId, options) => {
|
|
121
|
+
try {
|
|
122
|
+
const config = requireCookie();
|
|
123
|
+
const msg = await denyRoleRequest(config, { notification_id: notificationId });
|
|
124
|
+
output({ message: msg }, options);
|
|
125
|
+
}
|
|
126
|
+
catch (e) {
|
|
127
|
+
error(e.response?.status ? `API error: ${e.response.status}` : e.message);
|
|
128
|
+
process.exit(1);
|
|
129
|
+
}
|
|
130
|
+
});
|
|
131
|
+
return permissions;
|
|
132
|
+
}
|
|
133
|
+
//# sourceMappingURL=permissions.js.map
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
import { Command } from 'commander';
|
|
2
|
+
import { createProject, renameProject, moveProject, trashProject, restoreProject, setProjectDescription, } from '../operations/projects.js';
|
|
3
|
+
import { output, error } from './format.js';
|
|
4
|
+
import { requireCookie } from './helpers.js';
|
|
5
|
+
export function projectsCommand() {
|
|
6
|
+
const projects = new Command('projects')
|
|
7
|
+
.description('Manage Figma projects');
|
|
8
|
+
projects
|
|
9
|
+
.command('create <team-id>')
|
|
10
|
+
.description('Create a new project in a team')
|
|
11
|
+
.requiredOption('--name <name>', 'Project name')
|
|
12
|
+
.option('--json', 'Force JSON output')
|
|
13
|
+
.action(async (teamId, options) => {
|
|
14
|
+
try {
|
|
15
|
+
const config = requireCookie();
|
|
16
|
+
const result = await createProject(config, { team_id: teamId, name: options.name });
|
|
17
|
+
output(result, options);
|
|
18
|
+
}
|
|
19
|
+
catch (e) {
|
|
20
|
+
error(e.response?.status ? `API error: ${e.response.status}` : e.message);
|
|
21
|
+
process.exit(1);
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
projects
|
|
25
|
+
.command('rename <project-id>')
|
|
26
|
+
.description('Rename a project')
|
|
27
|
+
.requiredOption('--name <name>', 'New name')
|
|
28
|
+
.option('--json', 'Force JSON output')
|
|
29
|
+
.action(async (projectId, options) => {
|
|
30
|
+
try {
|
|
31
|
+
const config = requireCookie();
|
|
32
|
+
await renameProject(config, { project_id: projectId, name: options.name });
|
|
33
|
+
output({ renamed: projectId, name: options.name }, options);
|
|
34
|
+
}
|
|
35
|
+
catch (e) {
|
|
36
|
+
error(e.response?.status ? `API error: ${e.response.status}` : e.message);
|
|
37
|
+
process.exit(1);
|
|
38
|
+
}
|
|
39
|
+
});
|
|
40
|
+
projects
|
|
41
|
+
.command('move <project-id>')
|
|
42
|
+
.description('Move a project to a different team')
|
|
43
|
+
.requiredOption('--destination <team-id>', 'Destination team ID')
|
|
44
|
+
.option('--json', 'Force JSON output')
|
|
45
|
+
.action(async (projectId, options) => {
|
|
46
|
+
try {
|
|
47
|
+
const config = requireCookie();
|
|
48
|
+
await moveProject(config, {
|
|
49
|
+
project_id: projectId,
|
|
50
|
+
destination_team_id: options.destination,
|
|
51
|
+
});
|
|
52
|
+
output({ moved: projectId, destination_team_id: options.destination }, options);
|
|
53
|
+
}
|
|
54
|
+
catch (e) {
|
|
55
|
+
error(e.response?.status ? `API error: ${e.response.status}` : e.message);
|
|
56
|
+
process.exit(1);
|
|
57
|
+
}
|
|
58
|
+
});
|
|
59
|
+
projects
|
|
60
|
+
.command('trash <project-id>')
|
|
61
|
+
.description('Move a project to trash')
|
|
62
|
+
.option('--json', 'Force JSON output')
|
|
63
|
+
.action(async (projectId, options) => {
|
|
64
|
+
try {
|
|
65
|
+
const config = requireCookie();
|
|
66
|
+
await trashProject(config, { project_id: projectId });
|
|
67
|
+
output({ trashed: projectId }, options);
|
|
68
|
+
}
|
|
69
|
+
catch (e) {
|
|
70
|
+
error(e.response?.status ? `API error: ${e.response.status}` : e.message);
|
|
71
|
+
process.exit(1);
|
|
72
|
+
}
|
|
73
|
+
});
|
|
74
|
+
projects
|
|
75
|
+
.command('restore <project-id>')
|
|
76
|
+
.description('Restore a project from trash')
|
|
77
|
+
.option('--json', 'Force JSON output')
|
|
78
|
+
.action(async (projectId, options) => {
|
|
79
|
+
try {
|
|
80
|
+
const config = requireCookie();
|
|
81
|
+
await restoreProject(config, { project_id: projectId });
|
|
82
|
+
output({ restored: projectId }, options);
|
|
83
|
+
}
|
|
84
|
+
catch (e) {
|
|
85
|
+
error(e.response?.status ? `API error: ${e.response.status}` : e.message);
|
|
86
|
+
process.exit(1);
|
|
87
|
+
}
|
|
88
|
+
});
|
|
89
|
+
projects
|
|
90
|
+
.command('set-description <project-id>')
|
|
91
|
+
.description('Set or update a project description')
|
|
92
|
+
.requiredOption('--description <text>', 'Description text')
|
|
93
|
+
.option('--json', 'Force JSON output')
|
|
94
|
+
.action(async (projectId, options) => {
|
|
95
|
+
try {
|
|
96
|
+
const config = requireCookie();
|
|
97
|
+
await setProjectDescription(config, {
|
|
98
|
+
project_id: projectId,
|
|
99
|
+
description: options.description,
|
|
100
|
+
});
|
|
101
|
+
output({ updated: projectId }, options);
|
|
102
|
+
}
|
|
103
|
+
catch (e) {
|
|
104
|
+
error(e.response?.status ? `API error: ${e.response.status}` : e.message);
|
|
105
|
+
process.exit(1);
|
|
106
|
+
}
|
|
107
|
+
});
|
|
108
|
+
return projects;
|
|
109
|
+
}
|
|
110
|
+
//# sourceMappingURL=projects.js.map
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { Command } from 'commander';
|
|
2
|
+
import { getFile, getNodes } from '../operations/reading.js';
|
|
3
|
+
import { output, error } from './format.js';
|
|
4
|
+
import { requirePat } from './helpers.js';
|
|
5
|
+
export function readingCommand() {
|
|
6
|
+
const reading = new Command('reading')
|
|
7
|
+
.description('Read file contents and node trees');
|
|
8
|
+
reading
|
|
9
|
+
.command('get-file <file-key>')
|
|
10
|
+
.description('Read file contents as a node tree')
|
|
11
|
+
.option('--depth <n>', 'Tree depth limit (0=root, 1=pages, 2=top-level frames)')
|
|
12
|
+
.option('--node-id <id>', 'Start from a specific node instead of document root')
|
|
13
|
+
.option('--json', 'Force JSON output')
|
|
14
|
+
.action(async (fileKey, options) => {
|
|
15
|
+
try {
|
|
16
|
+
const config = requirePat();
|
|
17
|
+
const result = await getFile(config, {
|
|
18
|
+
file_key: fileKey,
|
|
19
|
+
depth: options.depth !== undefined ? parseInt(options.depth, 10) : undefined,
|
|
20
|
+
node_id: options.nodeId,
|
|
21
|
+
});
|
|
22
|
+
output(result, options);
|
|
23
|
+
}
|
|
24
|
+
catch (e) {
|
|
25
|
+
error(e.response?.status ? `API error: ${e.response.status}` : e.message);
|
|
26
|
+
process.exit(1);
|
|
27
|
+
}
|
|
28
|
+
});
|
|
29
|
+
reading
|
|
30
|
+
.command('get-nodes <file-key> <node-ids...>')
|
|
31
|
+
.description('Read specific nodes from a file')
|
|
32
|
+
.option('--depth <n>', 'Depth limit per node')
|
|
33
|
+
.option('--json', 'Force JSON output')
|
|
34
|
+
.action(async (fileKey, nodeIds, options) => {
|
|
35
|
+
try {
|
|
36
|
+
const config = requirePat();
|
|
37
|
+
const result = await getNodes(config, {
|
|
38
|
+
file_key: fileKey,
|
|
39
|
+
node_ids: nodeIds,
|
|
40
|
+
depth: options.depth !== undefined ? parseInt(options.depth, 10) : undefined,
|
|
41
|
+
});
|
|
42
|
+
output(result, options);
|
|
43
|
+
}
|
|
44
|
+
catch (e) {
|
|
45
|
+
error(e.response?.status ? `API error: ${e.response.status}` : e.message);
|
|
46
|
+
process.exit(1);
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
return reading;
|
|
50
|
+
}
|
|
51
|
+
//# sourceMappingURL=reading.js.map
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { Command } from 'commander';
|
|
2
|
+
import { createTeam, renameTeam, deleteTeam } from '../operations/teams.js';
|
|
3
|
+
import { output, error } from './format.js';
|
|
4
|
+
import { requireCookie } from './helpers.js';
|
|
5
|
+
export function teamsCommand() {
|
|
6
|
+
const teams = new Command('teams')
|
|
7
|
+
.description('Create, rename, and delete teams');
|
|
8
|
+
teams
|
|
9
|
+
.command('create <name>')
|
|
10
|
+
.description('Create a new team in the org')
|
|
11
|
+
.option('--org-id <id>', 'Org ID override')
|
|
12
|
+
.option('--json', 'Force JSON output')
|
|
13
|
+
.action(async (name, options) => {
|
|
14
|
+
try {
|
|
15
|
+
const config = requireCookie();
|
|
16
|
+
const result = await createTeam(config, { name, org_id: options.orgId });
|
|
17
|
+
output(result, options);
|
|
18
|
+
}
|
|
19
|
+
catch (e) {
|
|
20
|
+
error(e.response?.status ? `API error: ${e.response.status}` : e.message);
|
|
21
|
+
process.exit(1);
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
teams
|
|
25
|
+
.command('rename <team-id> <name>')
|
|
26
|
+
.description('Rename an existing team')
|
|
27
|
+
.option('--json', 'Force JSON output')
|
|
28
|
+
.action(async (teamId, name, options) => {
|
|
29
|
+
try {
|
|
30
|
+
const config = requireCookie();
|
|
31
|
+
const msg = await renameTeam(config, { team_id: teamId, name });
|
|
32
|
+
output({ message: msg }, options);
|
|
33
|
+
}
|
|
34
|
+
catch (e) {
|
|
35
|
+
error(e.response?.status ? `API error: ${e.response.status}` : e.message);
|
|
36
|
+
process.exit(1);
|
|
37
|
+
}
|
|
38
|
+
});
|
|
39
|
+
teams
|
|
40
|
+
.command('delete <team-id>')
|
|
41
|
+
.description('Delete a team (destructive, cannot be undone)')
|
|
42
|
+
.option('--json', 'Force JSON output')
|
|
43
|
+
.action(async (teamId, options) => {
|
|
44
|
+
try {
|
|
45
|
+
const config = requireCookie();
|
|
46
|
+
const msg = await deleteTeam(config, { team_id: teamId });
|
|
47
|
+
output({ message: msg }, options);
|
|
48
|
+
}
|
|
49
|
+
catch (e) {
|
|
50
|
+
error(e.response?.status ? `API error: ${e.response.status}` : e.message);
|
|
51
|
+
process.exit(1);
|
|
52
|
+
}
|
|
53
|
+
});
|
|
54
|
+
return teams;
|
|
55
|
+
}
|
|
56
|
+
//# sourceMappingURL=teams.js.map
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { Command } from 'commander';
|
|
2
|
+
import { listLocalVariables, listPublishedVariables, updateVariables, isEnterpriseScopeError, ENTERPRISE_ERROR, } from '../operations/variables.js';
|
|
3
|
+
import { output, error } from './format.js';
|
|
4
|
+
import { requirePat } from './helpers.js';
|
|
5
|
+
export function variablesCommand() {
|
|
6
|
+
const variables = new Command('variables')
|
|
7
|
+
.description('Manage file variables (Enterprise)');
|
|
8
|
+
variables
|
|
9
|
+
.command('list-local <file-key>')
|
|
10
|
+
.description('List local variables and variable collections in a file')
|
|
11
|
+
.option('--json', 'Force JSON output')
|
|
12
|
+
.action(async (fileKey, options) => {
|
|
13
|
+
try {
|
|
14
|
+
const config = requirePat();
|
|
15
|
+
const result = await listLocalVariables(config, { file_key: fileKey });
|
|
16
|
+
output(result, options);
|
|
17
|
+
}
|
|
18
|
+
catch (e) {
|
|
19
|
+
if (isEnterpriseScopeError(e)) {
|
|
20
|
+
error(ENTERPRISE_ERROR);
|
|
21
|
+
}
|
|
22
|
+
else {
|
|
23
|
+
error(e.response?.status ? `API error: ${e.response.status}` : e.message);
|
|
24
|
+
}
|
|
25
|
+
process.exit(1);
|
|
26
|
+
}
|
|
27
|
+
});
|
|
28
|
+
variables
|
|
29
|
+
.command('list-published <file-key>')
|
|
30
|
+
.description('List published variables from a library file')
|
|
31
|
+
.option('--json', 'Force JSON output')
|
|
32
|
+
.action(async (fileKey, options) => {
|
|
33
|
+
try {
|
|
34
|
+
const config = requirePat();
|
|
35
|
+
const result = await listPublishedVariables(config, { file_key: fileKey });
|
|
36
|
+
output(result, options);
|
|
37
|
+
}
|
|
38
|
+
catch (e) {
|
|
39
|
+
if (isEnterpriseScopeError(e)) {
|
|
40
|
+
error(ENTERPRISE_ERROR);
|
|
41
|
+
}
|
|
42
|
+
else {
|
|
43
|
+
error(e.response?.status ? `API error: ${e.response.status}` : e.message);
|
|
44
|
+
}
|
|
45
|
+
process.exit(1);
|
|
46
|
+
}
|
|
47
|
+
});
|
|
48
|
+
variables
|
|
49
|
+
.command('update <file-key>')
|
|
50
|
+
.description('Bulk create, update, or delete variables, collections, modes, and mode values')
|
|
51
|
+
.option('--variable-collections <json>', 'Collection operations as JSON array')
|
|
52
|
+
.option('--variable-modes <json>', 'Mode operations as JSON array')
|
|
53
|
+
.option('--variables <json>', 'Variable operations as JSON array')
|
|
54
|
+
.option('--variable-mode-values <json>', 'Value assignments as JSON array')
|
|
55
|
+
.option('--json', 'Force JSON output')
|
|
56
|
+
.action(async (fileKey, options) => {
|
|
57
|
+
try {
|
|
58
|
+
const config = requirePat();
|
|
59
|
+
const result = await updateVariables(config, {
|
|
60
|
+
file_key: fileKey,
|
|
61
|
+
variable_collections: options.variableCollections ? JSON.parse(options.variableCollections) : undefined,
|
|
62
|
+
variable_modes: options.variableModes ? JSON.parse(options.variableModes) : undefined,
|
|
63
|
+
variables: options.variables ? JSON.parse(options.variables) : undefined,
|
|
64
|
+
variable_mode_values: options.variableModeValues ? JSON.parse(options.variableModeValues) : undefined,
|
|
65
|
+
});
|
|
66
|
+
output(result, options);
|
|
67
|
+
}
|
|
68
|
+
catch (e) {
|
|
69
|
+
if (isEnterpriseScopeError(e)) {
|
|
70
|
+
error(ENTERPRISE_ERROR);
|
|
71
|
+
}
|
|
72
|
+
else {
|
|
73
|
+
error(e.response?.status ? `API error: ${e.response.status}` : e.message);
|
|
74
|
+
}
|
|
75
|
+
process.exit(1);
|
|
76
|
+
}
|
|
77
|
+
});
|
|
78
|
+
return variables;
|
|
79
|
+
}
|
|
80
|
+
//# sourceMappingURL=variables.js.map
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { Command } from 'commander';
|
|
2
|
+
import { listVersions, createVersion } from '../operations/versions.js';
|
|
3
|
+
import { output, error } from './format.js';
|
|
4
|
+
import { requirePat, requireCookie } from './helpers.js';
|
|
5
|
+
export function versionsCommand() {
|
|
6
|
+
const versions = new Command('versions')
|
|
7
|
+
.description('Manage file version history');
|
|
8
|
+
versions
|
|
9
|
+
.command('list <file-key>')
|
|
10
|
+
.description('List version history for a file')
|
|
11
|
+
.option('--json', 'Force JSON output')
|
|
12
|
+
.action(async (fileKey, options) => {
|
|
13
|
+
try {
|
|
14
|
+
const config = requirePat();
|
|
15
|
+
const result = await listVersions(config, { file_key: fileKey });
|
|
16
|
+
output(result, options);
|
|
17
|
+
}
|
|
18
|
+
catch (e) {
|
|
19
|
+
error(e.response?.status ? `API error: ${e.response.status}` : e.message);
|
|
20
|
+
process.exit(1);
|
|
21
|
+
}
|
|
22
|
+
});
|
|
23
|
+
versions
|
|
24
|
+
.command('create <file-key>')
|
|
25
|
+
.description('Create a named version (checkpoint)')
|
|
26
|
+
.requiredOption('--title <title>', 'Version title/label')
|
|
27
|
+
.option('--description <text>', 'Version description')
|
|
28
|
+
.option('--json', 'Force JSON output')
|
|
29
|
+
.action(async (fileKey, options) => {
|
|
30
|
+
try {
|
|
31
|
+
const config = requireCookie();
|
|
32
|
+
const result = await createVersion(config, {
|
|
33
|
+
file_key: fileKey,
|
|
34
|
+
title: options.title,
|
|
35
|
+
description: options.description,
|
|
36
|
+
});
|
|
37
|
+
output(result, options);
|
|
38
|
+
}
|
|
39
|
+
catch (e) {
|
|
40
|
+
error(e.response?.status ? `API error: ${e.response.status}` : e.message);
|
|
41
|
+
process.exit(1);
|
|
42
|
+
}
|
|
43
|
+
});
|
|
44
|
+
return versions;
|
|
45
|
+
}
|
|
46
|
+
//# sourceMappingURL=versions.js.map
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import { Command } from 'commander';
|
|
2
|
+
import { listWebhooks, createWebhook, updateWebhook, deleteWebhook, } from '../operations/webhooks.js';
|
|
3
|
+
import { output, error } from './format.js';
|
|
4
|
+
import { requirePat } from './helpers.js';
|
|
5
|
+
const VALID_EVENT_TYPES = [
|
|
6
|
+
'FILE_UPDATE',
|
|
7
|
+
'FILE_DELETE',
|
|
8
|
+
'FILE_VERSION_UPDATE',
|
|
9
|
+
'LIBRARY_PUBLISH',
|
|
10
|
+
'FILE_COMMENT',
|
|
11
|
+
'PING',
|
|
12
|
+
];
|
|
13
|
+
export function webhooksCommand() {
|
|
14
|
+
const webhooks = new Command('webhooks')
|
|
15
|
+
.description('Manage team webhooks');
|
|
16
|
+
webhooks
|
|
17
|
+
.command('list <team-id>')
|
|
18
|
+
.description('List webhooks for a team')
|
|
19
|
+
.option('--json', 'Force JSON output')
|
|
20
|
+
.action(async (teamId, options) => {
|
|
21
|
+
try {
|
|
22
|
+
const config = requirePat();
|
|
23
|
+
const result = await listWebhooks(config, { team_id: teamId });
|
|
24
|
+
output(result, options);
|
|
25
|
+
}
|
|
26
|
+
catch (e) {
|
|
27
|
+
error(e.response?.status ? `API error: ${e.response.status}` : e.message);
|
|
28
|
+
process.exit(1);
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
webhooks
|
|
32
|
+
.command('create <team-id>')
|
|
33
|
+
.description('Create a webhook subscription for a team')
|
|
34
|
+
.requiredOption('--event-type <type>', `Event type (${VALID_EVENT_TYPES.join(', ')})`)
|
|
35
|
+
.requiredOption('--endpoint <url>', 'URL to receive webhook payloads')
|
|
36
|
+
.requiredOption('--passcode <secret>', 'Secret for signature verification')
|
|
37
|
+
.option('--description <text>', 'Webhook description')
|
|
38
|
+
.option('--json', 'Force JSON output')
|
|
39
|
+
.action(async (teamId, options) => {
|
|
40
|
+
try {
|
|
41
|
+
const config = requirePat();
|
|
42
|
+
const result = await createWebhook(config, {
|
|
43
|
+
team_id: teamId,
|
|
44
|
+
event_type: options.eventType,
|
|
45
|
+
endpoint: options.endpoint,
|
|
46
|
+
passcode: options.passcode,
|
|
47
|
+
description: options.description,
|
|
48
|
+
});
|
|
49
|
+
output(result, options);
|
|
50
|
+
}
|
|
51
|
+
catch (e) {
|
|
52
|
+
error(e.response?.status ? `API error: ${e.response.status}` : e.message);
|
|
53
|
+
process.exit(1);
|
|
54
|
+
}
|
|
55
|
+
});
|
|
56
|
+
webhooks
|
|
57
|
+
.command('update <webhook-id>')
|
|
58
|
+
.description('Update a webhook')
|
|
59
|
+
.option('--event-type <type>', `Event type (${VALID_EVENT_TYPES.join(', ')})`)
|
|
60
|
+
.option('--endpoint <url>', 'URL to receive webhook payloads')
|
|
61
|
+
.option('--passcode <secret>', 'Secret for signature verification')
|
|
62
|
+
.option('--description <text>', 'Webhook description')
|
|
63
|
+
.option('--status <status>', 'Webhook status (ACTIVE, PAUSED)')
|
|
64
|
+
.option('--json', 'Force JSON output')
|
|
65
|
+
.action(async (webhookId, options) => {
|
|
66
|
+
try {
|
|
67
|
+
const config = requirePat();
|
|
68
|
+
const result = await updateWebhook(config, {
|
|
69
|
+
webhook_id: webhookId,
|
|
70
|
+
event_type: options.eventType,
|
|
71
|
+
endpoint: options.endpoint,
|
|
72
|
+
passcode: options.passcode,
|
|
73
|
+
description: options.description,
|
|
74
|
+
status: options.status,
|
|
75
|
+
});
|
|
76
|
+
output(result, options);
|
|
77
|
+
}
|
|
78
|
+
catch (e) {
|
|
79
|
+
error(e.response?.status ? `API error: ${e.response.status}` : e.message);
|
|
80
|
+
process.exit(1);
|
|
81
|
+
}
|
|
82
|
+
});
|
|
83
|
+
webhooks
|
|
84
|
+
.command('delete <webhook-id>')
|
|
85
|
+
.description('Delete a webhook')
|
|
86
|
+
.option('--json', 'Force JSON output')
|
|
87
|
+
.action(async (webhookId, options) => {
|
|
88
|
+
try {
|
|
89
|
+
const config = requirePat();
|
|
90
|
+
await deleteWebhook(config, { webhook_id: webhookId });
|
|
91
|
+
output({ deleted: webhookId }, options);
|
|
92
|
+
}
|
|
93
|
+
catch (e) {
|
|
94
|
+
error(e.response?.status ? `API error: ${e.response.status}` : e.message);
|
|
95
|
+
process.exit(1);
|
|
96
|
+
}
|
|
97
|
+
});
|
|
98
|
+
return webhooks;
|
|
99
|
+
}
|
|
100
|
+
//# sourceMappingURL=webhooks.js.map
|
package/dist/cli/whoami.js
CHANGED
|
@@ -11,7 +11,7 @@ export async function handleWhoami() {
|
|
|
11
11
|
if (hasCookie(config)) {
|
|
12
12
|
authMethods.push('cookie');
|
|
13
13
|
try {
|
|
14
|
-
const res = await axios.get('https://www.figma.com/api/
|
|
14
|
+
const res = await axios.get('https://www.figma.com/api/user/state', {
|
|
15
15
|
headers: {
|
|
16
16
|
'Cookie': `__Host-figma.authn=${config.cookie}`,
|
|
17
17
|
'X-CSRF-Bypass': 'yes',
|
|
@@ -19,7 +19,8 @@ export async function handleWhoami() {
|
|
|
19
19
|
},
|
|
20
20
|
timeout: 15000,
|
|
21
21
|
});
|
|
22
|
-
const
|
|
22
|
+
const meta = res.data?.meta || res.data || {};
|
|
23
|
+
const user = meta.user || meta;
|
|
23
24
|
console.log(`User: ${user.handle || user.email || config.userId}`);
|
|
24
25
|
if (user.email)
|
|
25
26
|
console.log(`Email: ${user.email}`);
|
package/dist/index.js
CHANGED
|
@@ -21,7 +21,7 @@ else {
|
|
|
21
21
|
program
|
|
22
22
|
.name('figmanage')
|
|
23
23
|
.description('Figma workspace management CLI')
|
|
24
|
-
.version('
|
|
24
|
+
.version(JSON.parse((await import('node:fs')).readFileSync(new URL('../package.json', import.meta.url), 'utf-8')).version);
|
|
25
25
|
registerCliCommands(program);
|
|
26
26
|
// No subcommand given -- show help
|
|
27
27
|
if (process.argv.length <= 2) {
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { AuthConfig } from '../auth/client.js';
|
|
2
|
+
export declare function libraryUsage(config: AuthConfig, params: {
|
|
3
|
+
library_file_key: string;
|
|
4
|
+
days?: number;
|
|
5
|
+
}): Promise<any>;
|
|
6
|
+
export declare function componentUsage(config: AuthConfig, params: {
|
|
7
|
+
component_key: string;
|
|
8
|
+
org_id?: string;
|
|
9
|
+
}): Promise<any>;
|
|
10
|
+
//# sourceMappingURL=analytics.d.ts.map
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { internalClient } from '../clients/internal-api.js';
|
|
2
|
+
import { requireOrgId } from '../tools/register.js';
|
|
3
|
+
export async function libraryUsage(config, params) {
|
|
4
|
+
const lookback = params.days ?? 30;
|
|
5
|
+
const end_ts = Math.floor(Date.now() / 1000);
|
|
6
|
+
const start_ts = end_ts - lookback * 86400;
|
|
7
|
+
const res = await internalClient(config).get(`/api/dsa/library/${params.library_file_key}/team_usage`, { params: { start_ts, end_ts } });
|
|
8
|
+
return res.data;
|
|
9
|
+
}
|
|
10
|
+
export async function componentUsage(config, params) {
|
|
11
|
+
const orgId = requireOrgId(config, params.org_id);
|
|
12
|
+
const res = await internalClient(config).get(`/api/design_systems/component/${params.component_key}/file_usage`, { params: { org_id: orgId, fv: 4 } });
|
|
13
|
+
return res.data;
|
|
14
|
+
}
|
|
15
|
+
//# sourceMappingURL=analytics.js.map
|