@carto-knowledge/runner 0.1.0 → 0.2.1
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/bun.lock +4 -6
- package/package.json +4 -3
- package/src/allowlist.test.ts +50 -2
- package/src/allowlist.ts +30 -0
- package/src/runner.test.ts +26 -0
package/bun.lock
CHANGED
|
@@ -4,8 +4,8 @@
|
|
|
4
4
|
"": {
|
|
5
5
|
"name": "@carto/runner",
|
|
6
6
|
"dependencies": {
|
|
7
|
-
"@carto-knowledge/commands": "
|
|
8
|
-
"@carto-knowledge/core": "
|
|
7
|
+
"@carto-knowledge/commands": "^0.1.0",
|
|
8
|
+
"@carto-knowledge/core": "^0.1.0",
|
|
9
9
|
"clipanion": "^4.0.0-rc.4",
|
|
10
10
|
},
|
|
11
11
|
"devDependencies": {
|
|
@@ -15,9 +15,9 @@
|
|
|
15
15
|
},
|
|
16
16
|
},
|
|
17
17
|
"packages": {
|
|
18
|
-
"@carto-knowledge/commands": ["@carto-knowledge/commands@
|
|
18
|
+
"@carto-knowledge/commands": ["@carto-knowledge/commands@0.1.0", "", { "dependencies": { "@carto-knowledge/core": "^0.1.0", "clipanion": "^4.0.0-rc.4" } }, "sha512-/6JxxaDdyYsyh+Y8Bw9WN4ZMa3yowQN+TBDl8NkymcMyYHnQ6g8DHHOm0vEt0s6U45AlmHlxXn8dNJXHS96I6Q=="],
|
|
19
19
|
|
|
20
|
-
"@carto-knowledge/core": ["@carto-knowledge/core@
|
|
20
|
+
"@carto-knowledge/core": ["@carto-knowledge/core@0.1.0", "", { "dependencies": { "zod": "^3.23.0" } }, "sha512-MVYEeSWZY4uNKwVF/WvJEf4vqMNNeYnCnxaR43m4UL5PzIPRdu8+Q/0DLUAzwLktqHXpv9kXIFsVZETXfC7J3g=="],
|
|
21
21
|
|
|
22
22
|
"@types/bun": ["@types/bun@1.3.6", "", { "dependencies": { "bun-types": "1.3.6" } }, "sha512-uWCv6FO/8LcpREhenN1d1b6fcspAB+cefwD7uti8C8VffIv0Um08TKMn98FynpTiU38+y2dUO55T11NgDt8VAA=="],
|
|
23
23
|
|
|
@@ -34,7 +34,5 @@
|
|
|
34
34
|
"undici-types": ["undici-types@6.21.0", "", {}, "sha512-iwDZqg0QAGrg9Rav5H4n0M64c3mkR59cJ6wQp+7C4nI0gsmExaedaYLNO44eT4AtBBwjbTiGPMlt2Md0T9H9JQ=="],
|
|
35
35
|
|
|
36
36
|
"zod": ["zod@3.25.76", "", {}, "sha512-gzUt/qt81nXsFGKIFcC3YnfEAx5NkunCfnDlvuBSSFS02bcXu4Lmea0AFIUwbLWxWPx3d9p8S5QoaujKcNQxcQ=="],
|
|
37
|
-
|
|
38
|
-
"@carto-knowledge/commands/@carto-knowledge/core": ["@carto-knowledge/core@file:../carto-core", {}],
|
|
39
37
|
}
|
|
40
38
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@carto-knowledge/runner",
|
|
3
|
-
"version": "0.1
|
|
3
|
+
"version": "0.2.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./src/index.ts",
|
|
6
6
|
"types": "./src/index.ts",
|
|
@@ -19,12 +19,13 @@
|
|
|
19
19
|
"typecheck": "bun x tsc --noEmit"
|
|
20
20
|
},
|
|
21
21
|
"dependencies": {
|
|
22
|
-
"@carto-knowledge/core": "^0.
|
|
23
|
-
"@carto-knowledge/commands": "^0.1
|
|
22
|
+
"@carto-knowledge/core": "^0.2.0",
|
|
23
|
+
"@carto-knowledge/commands": "^0.2.1",
|
|
24
24
|
"clipanion": "^4.0.0-rc.4"
|
|
25
25
|
},
|
|
26
26
|
"devDependencies": {
|
|
27
27
|
"@types/bun": "latest",
|
|
28
|
+
"bun-types": "latest",
|
|
28
29
|
"typescript": "^5.4.0"
|
|
29
30
|
}
|
|
30
31
|
}
|
package/src/allowlist.test.ts
CHANGED
|
@@ -52,16 +52,39 @@ describe('checkAllowlist', () => {
|
|
|
52
52
|
});
|
|
53
53
|
|
|
54
54
|
describe('DEFAULT_ALLOWLIST', () => {
|
|
55
|
-
it('includes read-only operations', () => {
|
|
55
|
+
it('includes read-only folder operations', () => {
|
|
56
56
|
expect(DEFAULT_ALLOWLIST.commands).toContain('folder tree');
|
|
57
57
|
expect(DEFAULT_ALLOWLIST.commands).toContain('folder list');
|
|
58
|
+
expect(DEFAULT_ALLOWLIST.commands).toContain('folder get');
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
it('includes read-only item operations', () => {
|
|
58
62
|
expect(DEFAULT_ALLOWLIST.commands).toContain('item search');
|
|
59
63
|
expect(DEFAULT_ALLOWLIST.commands).toContain('item get');
|
|
64
|
+
expect(DEFAULT_ALLOWLIST.commands).toContain('item list');
|
|
65
|
+
expect(DEFAULT_ALLOWLIST.commands).toContain('item get-by-uri');
|
|
66
|
+
expect(DEFAULT_ALLOWLIST.commands).toContain('item segments');
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
it('includes read-only edge operations', () => {
|
|
70
|
+
expect(DEFAULT_ALLOWLIST.commands).toContain('edge list');
|
|
71
|
+
expect(DEFAULT_ALLOWLIST.commands).toContain('edge get');
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
it('includes read-only share-link operations', () => {
|
|
75
|
+
expect(DEFAULT_ALLOWLIST.commands).toContain('share-link list');
|
|
76
|
+
expect(DEFAULT_ALLOWLIST.commands).toContain('share-link analytics');
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
it('includes librarian chat', () => {
|
|
80
|
+
expect(DEFAULT_ALLOWLIST.commands).toContain('librarian chat');
|
|
60
81
|
});
|
|
61
82
|
|
|
62
83
|
it('does not include write operations', () => {
|
|
63
84
|
expect(DEFAULT_ALLOWLIST.commands).not.toContain('folder create');
|
|
64
85
|
expect(DEFAULT_ALLOWLIST.commands).not.toContain('item create');
|
|
86
|
+
expect(DEFAULT_ALLOWLIST.commands).not.toContain('edge create');
|
|
87
|
+
expect(DEFAULT_ALLOWLIST.commands).not.toContain('share-link create');
|
|
65
88
|
});
|
|
66
89
|
});
|
|
67
90
|
|
|
@@ -72,7 +95,32 @@ describe('WRITE_ALLOWLIST', () => {
|
|
|
72
95
|
}
|
|
73
96
|
});
|
|
74
97
|
|
|
75
|
-
it('includes write operations', () => {
|
|
98
|
+
it('includes folder write operations', () => {
|
|
76
99
|
expect(WRITE_ALLOWLIST.commands).toContain('folder create');
|
|
100
|
+
expect(WRITE_ALLOWLIST.commands).toContain('folder update');
|
|
101
|
+
expect(WRITE_ALLOWLIST.commands).toContain('folder delete');
|
|
102
|
+
expect(WRITE_ALLOWLIST.commands).toContain('folder move');
|
|
103
|
+
expect(WRITE_ALLOWLIST.commands).toContain('folder restructure');
|
|
104
|
+
expect(WRITE_ALLOWLIST.commands).toContain('folder create-tree');
|
|
105
|
+
});
|
|
106
|
+
|
|
107
|
+
it('includes item write operations', () => {
|
|
108
|
+
expect(WRITE_ALLOWLIST.commands).toContain('item create');
|
|
109
|
+
expect(WRITE_ALLOWLIST.commands).toContain('item update');
|
|
110
|
+
expect(WRITE_ALLOWLIST.commands).toContain('item delete');
|
|
111
|
+
expect(WRITE_ALLOWLIST.commands).toContain('item update content');
|
|
112
|
+
expect(WRITE_ALLOWLIST.commands).toContain('item upload');
|
|
113
|
+
expect(WRITE_ALLOWLIST.commands).toContain('item assign');
|
|
114
|
+
});
|
|
115
|
+
|
|
116
|
+
it('includes edge write operations', () => {
|
|
117
|
+
expect(WRITE_ALLOWLIST.commands).toContain('edge create');
|
|
118
|
+
expect(WRITE_ALLOWLIST.commands).toContain('edge update');
|
|
119
|
+
expect(WRITE_ALLOWLIST.commands).toContain('edge delete');
|
|
120
|
+
});
|
|
121
|
+
|
|
122
|
+
it('includes share-link write operations', () => {
|
|
123
|
+
expect(WRITE_ALLOWLIST.commands).toContain('share-link create');
|
|
124
|
+
expect(WRITE_ALLOWLIST.commands).toContain('share-link delete');
|
|
77
125
|
});
|
|
78
126
|
});
|
package/src/allowlist.ts
CHANGED
|
@@ -52,10 +52,23 @@ export function checkAllowlist(
|
|
|
52
52
|
*/
|
|
53
53
|
export const DEFAULT_ALLOWLIST: AllowlistConfig = {
|
|
54
54
|
commands: [
|
|
55
|
+
// Folder reads
|
|
55
56
|
'folder tree',
|
|
56
57
|
'folder list',
|
|
58
|
+
'folder get',
|
|
59
|
+
// Item reads
|
|
57
60
|
'item search',
|
|
58
61
|
'item get',
|
|
62
|
+
'item list',
|
|
63
|
+
'item get-by-uri',
|
|
64
|
+
'item segments',
|
|
65
|
+
// Edge reads
|
|
66
|
+
'edge list',
|
|
67
|
+
'edge get',
|
|
68
|
+
// Share link reads
|
|
69
|
+
'share-link list',
|
|
70
|
+
'share-link analytics',
|
|
71
|
+
// Librarian
|
|
59
72
|
'librarian chat',
|
|
60
73
|
],
|
|
61
74
|
};
|
|
@@ -67,9 +80,26 @@ export const DEFAULT_ALLOWLIST: AllowlistConfig = {
|
|
|
67
80
|
export const WRITE_ALLOWLIST: AllowlistConfig = {
|
|
68
81
|
commands: [
|
|
69
82
|
...DEFAULT_ALLOWLIST.commands,
|
|
83
|
+
// Folder writes
|
|
70
84
|
'folder create',
|
|
85
|
+
'folder update',
|
|
86
|
+
'folder delete',
|
|
71
87
|
'folder move',
|
|
88
|
+
'folder restructure',
|
|
89
|
+
'folder create-tree',
|
|
90
|
+
// Item writes
|
|
72
91
|
'item create',
|
|
92
|
+
'item update',
|
|
93
|
+
'item delete',
|
|
94
|
+
'item update content',
|
|
95
|
+
'item upload',
|
|
73
96
|
'item assign',
|
|
97
|
+
// Edge writes
|
|
98
|
+
'edge create',
|
|
99
|
+
'edge update',
|
|
100
|
+
'edge delete',
|
|
101
|
+
// Share link writes
|
|
102
|
+
'share-link create',
|
|
103
|
+
'share-link delete',
|
|
74
104
|
],
|
|
75
105
|
};
|
package/src/runner.test.ts
CHANGED
|
@@ -66,4 +66,30 @@ describe('runInProcess', () => {
|
|
|
66
66
|
});
|
|
67
67
|
expect(result.schemaVersion).toBe(1);
|
|
68
68
|
});
|
|
69
|
+
|
|
70
|
+
it('extracts folder restructure command path from disallowed command error', async () => {
|
|
71
|
+
const result = await runInProcess(
|
|
72
|
+
'folder restructure --library 00000000-0000-0000-0000-000000000001 --item-folder-map "{\\"item-1\\":\\"folder-a\\"}"',
|
|
73
|
+
{
|
|
74
|
+
...baseOptions,
|
|
75
|
+
allowlist: { commands: ['folder tree'] },
|
|
76
|
+
}
|
|
77
|
+
);
|
|
78
|
+
|
|
79
|
+
expect(result.ok).toBe(false);
|
|
80
|
+
expect(result.command).toBe('folder restructure');
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
it('extracts folder create-tree command path from disallowed command error', async () => {
|
|
84
|
+
const result = await runInProcess(
|
|
85
|
+
'folder create-tree --library 00000000-0000-0000-0000-000000000001 --spec "{\\"name\\":\\"Root\\",\\"children\\":[]}"',
|
|
86
|
+
{
|
|
87
|
+
...baseOptions,
|
|
88
|
+
allowlist: { commands: ['folder tree'] },
|
|
89
|
+
}
|
|
90
|
+
);
|
|
91
|
+
|
|
92
|
+
expect(result.ok).toBe(false);
|
|
93
|
+
expect(result.command).toBe('folder create-tree');
|
|
94
|
+
});
|
|
69
95
|
});
|