-
-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathfeatureSets.ts
More file actions
173 lines (154 loc) · 4.32 KB
/
Copy pathfeatureSets.ts
File metadata and controls
173 lines (154 loc) · 4.32 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
import { invoke } from '@tauri-apps/api/core';
/**
* FeatureSet type.
*
* - `default`: auto-created per Space. Fallback when no WorkspaceBinding matches.
* - `custom`: user-defined.
*/
/**
* `starter` is the auto-seeded FS that comes with each Space. It's the
* default fallback the resolver routes unmapped folders / rootless sessions
* to, so it's builtin: its members are editable (change which tools it
* includes, or empty it), but it can't be renamed or deleted. The legacy
* `'default'` value is accepted on read because migration 013 rewrites stored
* rows lazily and a stale fetch could still surface it; new writes use
* `'starter'`.
*/
export type FeatureSetType = 'starter' | 'default' | 'custom';
/**
* Is this FeatureSet the auto-seeded "Starter" for its Space? Returns
* `true` for both the new `'starter'` value and the legacy `'default'`
* — migration 013 rewrites rows in-place but a stale read could still
* surface the old value. Use this everywhere instead of comparing the
* type literal directly so the transition window is invisible to UI.
*/
export function isStarterFeatureSet(fs: { feature_set_type: FeatureSetType }): boolean {
return fs.feature_set_type === 'starter' || fs.feature_set_type === 'default';
}
/**
* Member type in a feature set.
*/
export type MemberType = 'feature' | 'feature_set';
/**
* Mode for including/excluding members.
*/
export type MemberMode = 'include' | 'exclude';
/**
* A member of a feature set.
*/
export interface FeatureSetMember {
id: string;
feature_set_id: string;
member_type: MemberType;
member_id: string;
mode: MemberMode;
}
/**
* A FeatureSet defines which tools are available to clients.
*/
export interface FeatureSet {
id: string;
name: string;
description: string | null;
icon: string | null;
space_id: string | null;
feature_set_type: FeatureSetType;
server_id: string | null;
is_builtin: boolean;
is_deleted: boolean;
members: FeatureSetMember[];
}
/**
* Input for creating a feature set.
*/
export interface CreateFeatureSetInput {
name: string;
space_id: string;
description?: string;
icon?: string;
}
/**
* Input for updating a feature set.
*/
export interface UpdateFeatureSetInput {
name?: string;
description?: string;
icon?: string;
}
/**
* Input for adding a member to a feature set.
*/
export interface AddMemberInput {
member_type: MemberType;
member_id: string;
mode?: MemberMode;
}
/**
* List all feature sets.
*/
export async function listFeatureSets(): Promise<FeatureSet[]> {
return invoke('list_feature_sets');
}
/**
* List feature sets for a specific space.
*/
export async function listFeatureSetsBySpace(spaceId: string): Promise<FeatureSet[]> {
return invoke('list_feature_sets_by_space', { spaceId });
}
/**
* Get a feature set by ID.
*/
export async function getFeatureSet(id: string): Promise<FeatureSet | null> {
return invoke('get_feature_set', { id });
}
/**
* Create a new feature set.
*/
export async function createFeatureSet(input: CreateFeatureSetInput): Promise<FeatureSet> {
return invoke('create_feature_set', { input });
}
/**
* Delete a feature set.
*/
export async function deleteFeatureSet(id: string): Promise<void> {
return invoke('delete_feature_set', { id });
}
/**
* Get a feature set with its members.
*/
export async function getFeatureSetWithMembers(id: string): Promise<FeatureSet | null> {
return invoke('get_feature_set_with_members', { id });
}
/**
* Update a feature set.
*/
export async function updateFeatureSet(id: string, input: UpdateFeatureSetInput): Promise<FeatureSet> {
return invoke('update_feature_set', { id, input });
}
/**
* Add a member to a feature set.
*/
export async function addFeatureSetMember(
featureSetId: string,
input: AddMemberInput
): Promise<FeatureSet> {
return invoke('add_feature_set_member', { featureSetId, input });
}
/**
* Remove a member from a feature set.
*/
export async function removeFeatureSetMember(
featureSetId: string,
memberId: string
): Promise<FeatureSet> {
return invoke('remove_feature_set_member', { featureSetId, memberId });
}
/**
* Set all members for a feature set (replaces existing).
*/
export async function setFeatureSetMembers(
featureSetId: string,
members: AddMemberInput[]
): Promise<FeatureSet> {
return invoke('set_feature_set_members', { featureSetId, members });
}