figmanage 1.0.1 → 1.2.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/completion.d.ts +7 -0
- package/dist/cli/completion.js +160 -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/format.js +147 -2
- package/dist/cli/helpers.d.ts +7 -0
- package/dist/cli/helpers.js +43 -0
- package/dist/cli/index.js +68 -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/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,38 @@
|
|
|
1
|
+
import { publicClient } from '../clients/public-api.js';
|
|
2
|
+
export async function listWebhooks(config, params) {
|
|
3
|
+
const res = await publicClient(config).get(`/v2/teams/${params.team_id}/webhooks`);
|
|
4
|
+
return res.data?.webhooks || [];
|
|
5
|
+
}
|
|
6
|
+
export async function createWebhook(config, params) {
|
|
7
|
+
const body = {
|
|
8
|
+
team_id: params.team_id,
|
|
9
|
+
event_type: params.event_type,
|
|
10
|
+
endpoint: params.endpoint,
|
|
11
|
+
passcode: params.passcode,
|
|
12
|
+
};
|
|
13
|
+
if (params.description)
|
|
14
|
+
body.description = params.description;
|
|
15
|
+
const res = await publicClient(config).post('/v2/webhooks', body);
|
|
16
|
+
const { passcode: _, ...safe } = res.data || {};
|
|
17
|
+
return safe;
|
|
18
|
+
}
|
|
19
|
+
export async function updateWebhook(config, params) {
|
|
20
|
+
const body = {};
|
|
21
|
+
if (params.event_type)
|
|
22
|
+
body.event_type = params.event_type;
|
|
23
|
+
if (params.endpoint)
|
|
24
|
+
body.endpoint = params.endpoint;
|
|
25
|
+
if (params.passcode)
|
|
26
|
+
body.passcode = params.passcode;
|
|
27
|
+
if (params.description)
|
|
28
|
+
body.description = params.description;
|
|
29
|
+
if (params.status)
|
|
30
|
+
body.status = params.status;
|
|
31
|
+
const res = await publicClient(config).put(`/v2/webhooks/${params.webhook_id}`, body);
|
|
32
|
+
const { passcode: _, ...safe } = res.data || {};
|
|
33
|
+
return safe;
|
|
34
|
+
}
|
|
35
|
+
export async function deleteWebhook(config, params) {
|
|
36
|
+
await publicClient(config).delete(`/v2/webhooks/${params.webhook_id}`);
|
|
37
|
+
}
|
|
38
|
+
//# sourceMappingURL=webhooks.js.map
|
package/dist/tools/analytics.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
2
|
+
import { defineTool, toolResult, toolError, figmaId } from './register.js';
|
|
3
|
+
import { libraryUsage, componentUsage } from '../operations/analytics.js';
|
|
4
4
|
// -- library_usage --
|
|
5
5
|
defineTool({
|
|
6
6
|
toolset: 'analytics',
|
|
@@ -14,11 +14,8 @@ defineTool({
|
|
|
14
14
|
},
|
|
15
15
|
}, async ({ library_file_key, days }) => {
|
|
16
16
|
try {
|
|
17
|
-
const
|
|
18
|
-
|
|
19
|
-
const start_ts = end_ts - (lookback * 86400);
|
|
20
|
-
const res = await internalClient(config).get(`/api/dsa/library/${library_file_key}/team_usage`, { params: { start_ts, end_ts } });
|
|
21
|
-
return toolResult(JSON.stringify(res.data, null, 2));
|
|
17
|
+
const result = await libraryUsage(config, { library_file_key, days });
|
|
18
|
+
return toolResult(JSON.stringify(result, null, 2));
|
|
22
19
|
}
|
|
23
20
|
catch (e) {
|
|
24
21
|
return toolError(`Failed to fetch library usage: ${e.response?.status || e.message}`);
|
|
@@ -39,15 +36,8 @@ defineTool({
|
|
|
39
36
|
},
|
|
40
37
|
}, async ({ component_key, org_id }) => {
|
|
41
38
|
try {
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
orgId = requireOrgId(config, org_id);
|
|
45
|
-
}
|
|
46
|
-
catch (e) {
|
|
47
|
-
return toolError(e.message);
|
|
48
|
-
}
|
|
49
|
-
const res = await internalClient(config).get(`/api/design_systems/component/${component_key}/file_usage`, { params: { org_id: orgId, fv: 4 } });
|
|
50
|
-
return toolResult(JSON.stringify(res.data, null, 2));
|
|
39
|
+
const result = await componentUsage(config, { component_key, org_id });
|
|
40
|
+
return toolResult(JSON.stringify(result, null, 2));
|
|
51
41
|
}
|
|
52
42
|
catch (e) {
|
|
53
43
|
return toolError(`Failed to fetch component usage: ${e.response?.status || e.message}`);
|
package/dist/tools/branching.js
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
-
import { hasCookie } from '../auth/client.js';
|
|
3
|
-
import { publicClient } from '../clients/public-api.js';
|
|
4
|
-
import { internalClient } from '../clients/internal-api.js';
|
|
5
2
|
import { defineTool, toolResult, toolError, figmaId } from './register.js';
|
|
3
|
+
import { listBranches, createBranch, deleteBranch } from '../operations/branching.js';
|
|
6
4
|
// -- list_branches --
|
|
7
5
|
defineTool({
|
|
8
6
|
toolset: 'branching',
|
|
@@ -15,28 +13,10 @@ defineTool({
|
|
|
15
13
|
},
|
|
16
14
|
}, async ({ file_key }) => {
|
|
17
15
|
try {
|
|
18
|
-
|
|
19
|
-
if (
|
|
20
|
-
const res = await internalClient(config).get(`/api/files/${file_key}`);
|
|
21
|
-
const f = res.data?.meta || res.data;
|
|
22
|
-
branches = f.branches || [];
|
|
23
|
-
}
|
|
24
|
-
else {
|
|
25
|
-
const res = await publicClient(config).get(`/v1/files/${file_key}`, {
|
|
26
|
-
params: { branch_data: 'true', depth: '0' },
|
|
27
|
-
});
|
|
28
|
-
branches = res.data?.branches || [];
|
|
29
|
-
}
|
|
30
|
-
if (branches.length === 0)
|
|
16
|
+
const result = await listBranches(config, { file_key });
|
|
17
|
+
if (result.length === 0)
|
|
31
18
|
return toolResult('No branches found.');
|
|
32
|
-
|
|
33
|
-
key: b.key,
|
|
34
|
-
name: b.name,
|
|
35
|
-
thumbnail_url: b.thumbnail_url || null,
|
|
36
|
-
last_modified: b.last_modified || null,
|
|
37
|
-
link_access: b.link_access || null,
|
|
38
|
-
}));
|
|
39
|
-
return toolResult(JSON.stringify(mapped, null, 2));
|
|
19
|
+
return toolResult(JSON.stringify(result, null, 2));
|
|
40
20
|
}
|
|
41
21
|
catch (e) {
|
|
42
22
|
return toolError(`Failed to list branches: ${e.response?.status || e.message}`);
|
|
@@ -58,15 +38,8 @@ defineTool({
|
|
|
58
38
|
},
|
|
59
39
|
}, async ({ file_key, name }) => {
|
|
60
40
|
try {
|
|
61
|
-
const
|
|
62
|
-
|
|
63
|
-
const file = meta.file || meta;
|
|
64
|
-
const branchKey = file.key || file.file_key || null;
|
|
65
|
-
return toolResult(JSON.stringify({
|
|
66
|
-
key: branchKey,
|
|
67
|
-
name,
|
|
68
|
-
main_file_key: file_key,
|
|
69
|
-
}, null, 2));
|
|
41
|
+
const result = await createBranch(config, { file_key, name });
|
|
42
|
+
return toolResult(JSON.stringify(result, null, 2));
|
|
70
43
|
}
|
|
71
44
|
catch (e) {
|
|
72
45
|
return toolError(`Failed to create branch: ${e.response?.status || e.message}`);
|
|
@@ -89,9 +62,7 @@ defineTool({
|
|
|
89
62
|
},
|
|
90
63
|
}, async ({ branch_key }) => {
|
|
91
64
|
try {
|
|
92
|
-
await
|
|
93
|
-
data: { files: [{ key: branch_key }], trashed: true },
|
|
94
|
-
});
|
|
65
|
+
await deleteBranch(config, { branch_key });
|
|
95
66
|
return toolResult(`Archived branch ${branch_key}`);
|
|
96
67
|
}
|
|
97
68
|
catch (e) {
|
package/dist/tools/comments.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
-
import { publicClient } from '../clients/public-api.js';
|
|
3
2
|
import { defineTool, toolResult, toolError, figmaId } from './register.js';
|
|
3
|
+
import { listComments, formatCommentsAsMarkdown, postComment, deleteComment, listCommentReactions, } from '../operations/comments.js';
|
|
4
4
|
// -- list_comments --
|
|
5
5
|
defineTool({
|
|
6
6
|
toolset: 'comments',
|
|
@@ -14,40 +14,11 @@ defineTool({
|
|
|
14
14
|
},
|
|
15
15
|
}, async ({ file_key, as_md }) => {
|
|
16
16
|
try {
|
|
17
|
-
const
|
|
18
|
-
const comments = res.data?.comments || [];
|
|
17
|
+
const comments = await listComments(config, { file_key });
|
|
19
18
|
if (as_md) {
|
|
20
|
-
|
|
21
|
-
for (const c of comments) {
|
|
22
|
-
const parentId = c.parent_id || c.id;
|
|
23
|
-
if (!threads.has(parentId))
|
|
24
|
-
threads.set(parentId, []);
|
|
25
|
-
threads.get(parentId).push(c);
|
|
26
|
-
}
|
|
27
|
-
const lines = [];
|
|
28
|
-
for (const [, thread] of threads) {
|
|
29
|
-
thread.sort((a, b) => new Date(a.created_at).getTime() - new Date(b.created_at).getTime());
|
|
30
|
-
for (const c of thread) {
|
|
31
|
-
const indent = c.parent_id ? ' ' : '';
|
|
32
|
-
const resolved = c.resolved_at ? ' [resolved]' : '';
|
|
33
|
-
lines.push(`${indent}- **${c.user.handle}** (${c.created_at})${resolved}: ${c.message}`);
|
|
34
|
-
}
|
|
35
|
-
lines.push('');
|
|
36
|
-
}
|
|
37
|
-
return toolResult(lines.join('\n'));
|
|
19
|
+
return toolResult(formatCommentsAsMarkdown(comments));
|
|
38
20
|
}
|
|
39
|
-
|
|
40
|
-
id: c.id,
|
|
41
|
-
parent_id: c.parent_id || null,
|
|
42
|
-
message: c.message,
|
|
43
|
-
author: c.user?.handle,
|
|
44
|
-
author_id: c.user?.id,
|
|
45
|
-
created_at: c.created_at,
|
|
46
|
-
resolved_at: c.resolved_at || null,
|
|
47
|
-
node_id: c.client_meta?.node_id || c.client_meta?.node_offset?.node_id || null,
|
|
48
|
-
order_id: c.order_id,
|
|
49
|
-
}));
|
|
50
|
-
return toolResult(JSON.stringify(mapped, null, 2));
|
|
21
|
+
return toolResult(JSON.stringify(comments, null, 2));
|
|
51
22
|
}
|
|
52
23
|
catch (e) {
|
|
53
24
|
return toolError(`Failed to list comments: ${e.response?.status || e.message}`);
|
|
@@ -71,20 +42,8 @@ defineTool({
|
|
|
71
42
|
},
|
|
72
43
|
}, async ({ file_key, message, comment_id, node_id }) => {
|
|
73
44
|
try {
|
|
74
|
-
const
|
|
75
|
-
|
|
76
|
-
body.comment_id = comment_id;
|
|
77
|
-
if (node_id)
|
|
78
|
-
body.client_meta = { node_id, node_offset: { x: 0, y: 0 } };
|
|
79
|
-
const res = await publicClient(config).post(`/v1/files/${file_key}/comments`, body);
|
|
80
|
-
const c = res.data;
|
|
81
|
-
return toolResult(JSON.stringify({
|
|
82
|
-
id: c.id,
|
|
83
|
-
message: c.message,
|
|
84
|
-
author: c.user?.handle,
|
|
85
|
-
created_at: c.created_at,
|
|
86
|
-
parent_id: c.parent_id || null,
|
|
87
|
-
}, null, 2));
|
|
45
|
+
const result = await postComment(config, { file_key, message, comment_id, node_id });
|
|
46
|
+
return toolResult(JSON.stringify(result, null, 2));
|
|
88
47
|
}
|
|
89
48
|
catch (e) {
|
|
90
49
|
return toolError(`Failed to post comment: ${e.response?.status || e.message}`);
|
|
@@ -107,7 +66,7 @@ defineTool({
|
|
|
107
66
|
},
|
|
108
67
|
}, async ({ file_key, comment_id }) => {
|
|
109
68
|
try {
|
|
110
|
-
await
|
|
69
|
+
await deleteComment(config, { file_key, comment_id });
|
|
111
70
|
return toolResult(`Deleted comment ${comment_id}`);
|
|
112
71
|
}
|
|
113
72
|
catch (e) {
|
|
@@ -129,14 +88,8 @@ defineTool({
|
|
|
129
88
|
},
|
|
130
89
|
}, async ({ file_key, comment_id }) => {
|
|
131
90
|
try {
|
|
132
|
-
const
|
|
133
|
-
|
|
134
|
-
const mapped = reactions.map((r) => ({
|
|
135
|
-
emoji: r.emoji,
|
|
136
|
-
user: r.user?.handle,
|
|
137
|
-
created_at: r.created_at,
|
|
138
|
-
}));
|
|
139
|
-
return toolResult(JSON.stringify(mapped, null, 2));
|
|
91
|
+
const reactions = await listCommentReactions(config, { file_key, comment_id });
|
|
92
|
+
return toolResult(JSON.stringify(reactions, null, 2));
|
|
140
93
|
}
|
|
141
94
|
catch (e) {
|
|
142
95
|
return toolError(`Failed to list reactions: ${e.response?.status || e.message}`);
|
package/dist/tools/components.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
-
import { publicClient } from '../clients/public-api.js';
|
|
3
2
|
import { defineTool, toolResult, toolError, figmaId } from './register.js';
|
|
3
|
+
import { listFileComponents, listFileStyles, listTeamComponents, listTeamStyles, } from '../operations/components.js';
|
|
4
4
|
// -- list_file_components --
|
|
5
5
|
defineTool({
|
|
6
6
|
toolset: 'components',
|
|
@@ -13,8 +13,7 @@ defineTool({
|
|
|
13
13
|
},
|
|
14
14
|
}, async ({ file_key }) => {
|
|
15
15
|
try {
|
|
16
|
-
const
|
|
17
|
-
const components = res.data?.meta?.components || [];
|
|
16
|
+
const components = await listFileComponents(config, { file_key });
|
|
18
17
|
return toolResult(JSON.stringify(components, null, 2));
|
|
19
18
|
}
|
|
20
19
|
catch (e) {
|
|
@@ -35,8 +34,7 @@ defineTool({
|
|
|
35
34
|
},
|
|
36
35
|
}, async ({ file_key }) => {
|
|
37
36
|
try {
|
|
38
|
-
const
|
|
39
|
-
const styles = res.data?.meta?.styles || [];
|
|
37
|
+
const styles = await listFileStyles(config, { file_key });
|
|
40
38
|
return toolResult(JSON.stringify(styles, null, 2));
|
|
41
39
|
}
|
|
42
40
|
catch (e) {
|
|
@@ -59,13 +57,8 @@ defineTool({
|
|
|
59
57
|
},
|
|
60
58
|
}, async ({ team_id, page_size, cursor }) => {
|
|
61
59
|
try {
|
|
62
|
-
const
|
|
63
|
-
|
|
64
|
-
params.after = cursor;
|
|
65
|
-
const res = await publicClient(config).get(`/v1/teams/${team_id}/components`, { params });
|
|
66
|
-
const components = res.data?.meta?.components || [];
|
|
67
|
-
const pagination = res.data?.pagination || null;
|
|
68
|
-
return toolResult(JSON.stringify({ components, pagination }, null, 2));
|
|
60
|
+
const result = await listTeamComponents(config, { team_id, page_size, cursor });
|
|
61
|
+
return toolResult(JSON.stringify(result, null, 2));
|
|
69
62
|
}
|
|
70
63
|
catch (e) {
|
|
71
64
|
return toolError(`Failed to list team components: ${e.response?.status || e.message}`);
|
|
@@ -87,13 +80,8 @@ defineTool({
|
|
|
87
80
|
},
|
|
88
81
|
}, async ({ team_id, page_size, cursor }) => {
|
|
89
82
|
try {
|
|
90
|
-
const
|
|
91
|
-
|
|
92
|
-
params.after = cursor;
|
|
93
|
-
const res = await publicClient(config).get(`/v1/teams/${team_id}/styles`, { params });
|
|
94
|
-
const styles = res.data?.meta?.styles || [];
|
|
95
|
-
const pagination = res.data?.pagination || null;
|
|
96
|
-
return toolResult(JSON.stringify({ styles, pagination }, null, 2));
|
|
83
|
+
const result = await listTeamStyles(config, { team_id, page_size, cursor });
|
|
84
|
+
return toolResult(JSON.stringify(result, null, 2));
|
|
97
85
|
}
|
|
98
86
|
catch (e) {
|
|
99
87
|
return toolError(`Failed to list team styles: ${e.response?.status || e.message}`);
|