@edenapp/types 0.13.0 → 0.15.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.
@@ -1,11 +1,8 @@
1
1
  import type { UserProfile } from "./User";
2
2
 
3
- /** Text that can be localized by the Settings renderer. */
4
3
  export type SettingsPanelLocalizedText =
5
4
  | string
6
5
  | Readonly<Record<string, string>>;
7
-
8
- /** JSON-compatible values accepted by panel state and action inputs. */
9
6
  export type SettingsPanelValue =
10
7
  | string
11
8
  | number
@@ -13,25 +10,19 @@ export type SettingsPanelValue =
13
10
  | null
14
11
  | SettingsPanelValue[]
15
12
  | { [key: string]: SettingsPanelValue };
16
-
17
13
  export type SettingsPanelBadgeTone =
18
14
  | "neutral"
19
15
  | "info"
20
16
  | "success"
21
17
  | "warning"
22
18
  | "danger";
23
-
24
- /** Fully-qualified active-user grant required to discover a panel. */
25
19
  export type SettingsPanelGrant = string;
26
-
27
- /** Additional active-user grant required to invoke one panel action. */
28
20
  export type SettingsPanelActionGrant = string;
29
21
 
30
22
  export interface SettingsPanelBadge {
31
23
  label: SettingsPanelLocalizedText;
32
24
  tone?: SettingsPanelBadgeTone;
33
25
  }
34
-
35
26
  export interface SettingsPanelValidation {
36
27
  required?: boolean;
37
28
  minLength?: number;
@@ -41,98 +32,12 @@ export interface SettingsPanelValidation {
41
32
  max?: number;
42
33
  step?: number;
43
34
  }
44
-
45
35
  export interface SettingsPanelOption {
46
36
  value: string;
47
37
  label: SettingsPanelLocalizedText;
48
38
  description?: SettingsPanelLocalizedText;
49
39
  }
50
40
 
51
- export type SettingsPanelInputType =
52
- | "text"
53
- | "password"
54
- | "number"
55
- | "checkbox"
56
- | "radio"
57
- | "select"
58
- | "textarea"
59
- | "color"
60
- | "range";
61
-
62
- export interface SettingsPanelFormField {
63
- id: string;
64
- label: SettingsPanelLocalizedText;
65
- description?: SettingsPanelLocalizedText;
66
- input: SettingsPanelInputType;
67
- placeholder?: SettingsPanelLocalizedText;
68
- options?: SettingsPanelOption[];
69
- validation?: SettingsPanelValidation;
70
- autocomplete?: string;
71
- }
72
-
73
- export interface SettingsPanelControlBase {
74
- id: string;
75
- label: SettingsPanelLocalizedText;
76
- description?: SettingsPanelLocalizedText;
77
- }
78
-
79
- export interface SettingsPanelStatusRow extends SettingsPanelControlBase {
80
- kind: "status";
81
- stateKey: string;
82
- }
83
-
84
- export interface SettingsPanelToggle extends SettingsPanelControlBase {
85
- kind: "toggle";
86
- stateKey: string;
87
- actionId: string;
88
- }
89
-
90
- export interface SettingsPanelButton extends SettingsPanelControlBase {
91
- kind: "button";
92
- actionId: string;
93
- tone?: SettingsPanelBadgeTone;
94
- confirmation?: SettingsPanelLocalizedText;
95
- }
96
-
97
- export interface SettingsPanelInput extends SettingsPanelControlBase {
98
- kind: "input";
99
- stateKey: string;
100
- actionId: string;
101
- input: SettingsPanelInputType;
102
- placeholder?: SettingsPanelLocalizedText;
103
- options?: SettingsPanelOption[];
104
- validation?: SettingsPanelValidation;
105
- }
106
-
107
- export interface SettingsPanelDialogContent {
108
- title: SettingsPanelLocalizedText;
109
- description?: SettingsPanelLocalizedText;
110
- fields: SettingsPanelFormField[];
111
- submitLabel: SettingsPanelLocalizedText;
112
- cancelLabel: SettingsPanelLocalizedText;
113
- }
114
-
115
- export interface SettingsPanelDialog extends SettingsPanelControlBase {
116
- kind: "dialog";
117
- actionId: string;
118
- buttonLabel: SettingsPanelLocalizedText;
119
- dialog: SettingsPanelDialogContent;
120
- }
121
-
122
- export type SettingsPanelControl =
123
- | SettingsPanelStatusRow
124
- | SettingsPanelToggle
125
- | SettingsPanelButton
126
- | SettingsPanelInput
127
- | SettingsPanelDialog;
128
-
129
- export interface SettingsPanelSection {
130
- id: string;
131
- title?: SettingsPanelLocalizedText;
132
- description?: SettingsPanelLocalizedText;
133
- controls: SettingsPanelControl[];
134
- }
135
-
136
41
  export type SettingsPanelActionInputSchema =
137
42
  | {
138
43
  type: "string";
@@ -155,106 +60,257 @@ export type SettingsPanelActionInputSchema =
155
60
  required?: boolean;
156
61
  items?: SettingsPanelActionInputSchema;
157
62
  }
158
- | {
159
- type: "object";
160
- required?: boolean;
161
- properties?: Record<string, SettingsPanelActionInputSchema>;
162
- additionalProperties?: boolean;
163
- }
63
+ | SettingsPanelObjectInputSchema
164
64
  | { type: "any"; required?: boolean };
165
65
 
66
+ export interface SettingsPanelObjectInputSchema {
67
+ type: "object";
68
+ required?: boolean;
69
+ properties?: Record<string, SettingsPanelActionInputSchema>;
70
+ additionalProperties?: boolean;
71
+ }
72
+
166
73
  export interface SettingsPanelActionDefinition {
167
74
  id: string;
168
75
  label?: SettingsPanelLocalizedText;
169
76
  description?: SettingsPanelLocalizedText;
170
- /** An additional active-user grant required for this action. */
171
77
  grant?: SettingsPanelActionGrant;
172
- input?: SettingsPanelActionInputSchema;
78
+ params?: SettingsPanelObjectInputSchema;
79
+ value?: SettingsPanelActionInputSchema;
80
+ fields?: SettingsPanelObjectInputSchema;
173
81
  }
174
82
 
175
- /**
176
- * Serializable panel declaration. Callbacks belong in the separate provider.
177
- *
178
- * IDs beginning with `eden.` and `app.` are reserved by Eden.
179
- */
83
+ /** Serializable metadata that remains stable for a registration's lifetime. */
180
84
  export interface SettingsPanelDefinition {
181
85
  id: string;
86
+ parentId?: string;
182
87
  title: SettingsPanelLocalizedText;
183
88
  description?: SettingsPanelLocalizedText;
184
89
  icon?: string;
185
- /** Active-user grant required before the panel can be discovered or loaded. */
186
- grant: SettingsPanelGrant;
187
- sections: SettingsPanelSection[];
90
+ /** Omit to add no grant requirement beyond the parent panel, if any. */
91
+ grant?: SettingsPanelGrant;
188
92
  actions?: SettingsPanelActionDefinition[];
189
93
  }
190
94
 
191
- export interface SettingsPanelControlState {
95
+ export interface SettingsPanelActionBinding {
96
+ actionId: string;
97
+ /** Public, client-visible parameters. Handlers must reauthorize resources. */
98
+ params?: Record<string, SettingsPanelValue>;
99
+ }
100
+
101
+ export interface SettingsPanelActionInvocation {
102
+ params?: Record<string, SettingsPanelValue>;
192
103
  value?: SettingsPanelValue;
104
+ fields?: Record<string, SettingsPanelValue>;
105
+ }
106
+
107
+ interface SettingsPanelNodeBase {
108
+ id: string;
109
+ label: SettingsPanelLocalizedText;
110
+ description?: SettingsPanelLocalizedText;
111
+ }
112
+ interface SettingsPanelInteractiveNode extends SettingsPanelNodeBase {
113
+ action: SettingsPanelActionBinding;
114
+ disabled?: boolean;
115
+ }
116
+
117
+ export interface SettingsPanelStatusNode extends SettingsPanelNodeBase {
118
+ kind: "status";
119
+ value?: SettingsPanelLocalizedText;
193
120
  detail?: SettingsPanelLocalizedText;
194
121
  badge?: SettingsPanelBadge;
195
- disabled?: boolean;
196
- hidden?: boolean;
122
+ }
123
+ export interface SettingsPanelToggleNode extends SettingsPanelInteractiveNode {
124
+ kind: "toggle";
125
+ value: boolean;
126
+ }
127
+ export interface SettingsPanelButtonNode extends SettingsPanelInteractiveNode {
128
+ kind: "button";
129
+ tone?: SettingsPanelBadgeTone;
130
+ confirmation?: SettingsPanelLocalizedText;
197
131
  }
198
132
 
199
- export interface SettingsPanelState {
200
- controls?: Record<string, SettingsPanelControlState>;
201
- /** Renderer-specific, JSON-compatible state for Eden-owned custom views. */
202
- data?: SettingsPanelValue;
133
+ interface SettingsPanelInputNodeBase extends SettingsPanelInteractiveNode {
134
+ kind: "input";
135
+ placeholder?: SettingsPanelLocalizedText;
136
+ validation?: SettingsPanelValidation;
137
+ }
138
+ export interface SettingsPanelStringInputNode
139
+ extends SettingsPanelInputNodeBase {
140
+ input: "text" | "textarea" | "color";
141
+ value: string;
203
142
  }
143
+ export interface SettingsPanelChoiceInputNode
144
+ extends SettingsPanelInputNodeBase {
145
+ input: "select" | "radio";
146
+ value: string;
147
+ options: SettingsPanelOption[];
148
+ }
149
+ export interface SettingsPanelNumberInputNode
150
+ extends SettingsPanelInputNodeBase {
151
+ input: "number" | "range";
152
+ value: number;
153
+ }
154
+ export interface SettingsPanelCheckboxInputNode
155
+ extends SettingsPanelInputNodeBase {
156
+ input: "checkbox";
157
+ value: boolean;
158
+ }
159
+ export type SettingsPanelInputNode =
160
+ | SettingsPanelStringInputNode
161
+ | SettingsPanelChoiceInputNode
162
+ | SettingsPanelNumberInputNode
163
+ | SettingsPanelCheckboxInputNode;
204
164
 
205
- export interface SettingsPanelProviderContext {
206
- panelId: string;
207
- sessionId: string;
208
- user: UserProfile;
165
+ interface SettingsPanelDialogFieldBase {
166
+ id: string;
167
+ label: SettingsPanelLocalizedText;
168
+ description?: SettingsPanelLocalizedText;
169
+ placeholder?: SettingsPanelLocalizedText;
170
+ validation?: SettingsPanelValidation;
171
+ autocomplete?: string;
172
+ }
173
+ export interface SettingsPanelStringDialogField
174
+ extends SettingsPanelDialogFieldBase {
175
+ input: "text" | "textarea" | "color";
176
+ value?: string;
209
177
  }
178
+ export interface SettingsPanelChoiceDialogField
179
+ extends SettingsPanelDialogFieldBase {
180
+ input: "select" | "radio";
181
+ value?: string;
182
+ options: SettingsPanelOption[];
183
+ }
184
+ export interface SettingsPanelNumberDialogField
185
+ extends SettingsPanelDialogFieldBase {
186
+ input: "number" | "range";
187
+ value?: number;
188
+ }
189
+ export interface SettingsPanelCheckboxDialogField
190
+ extends SettingsPanelDialogFieldBase {
191
+ input: "checkbox";
192
+ value?: boolean;
193
+ }
194
+ export interface SettingsPanelPasswordDialogField
195
+ extends SettingsPanelDialogFieldBase {
196
+ input: "password";
197
+ value?: never;
198
+ }
199
+ export type SettingsPanelDialogField =
200
+ | SettingsPanelStringDialogField
201
+ | SettingsPanelChoiceDialogField
202
+ | SettingsPanelNumberDialogField
203
+ | SettingsPanelCheckboxDialogField
204
+ | SettingsPanelPasswordDialogField;
210
205
 
211
- export type SettingsPanelLoader = (
212
- context: SettingsPanelProviderContext,
213
- ) => SettingsPanelState | Promise<SettingsPanelState>;
206
+ export interface SettingsPanelDialogContent {
207
+ title: SettingsPanelLocalizedText;
208
+ description?: SettingsPanelLocalizedText;
209
+ fields: SettingsPanelDialogField[];
210
+ submitLabel: SettingsPanelLocalizedText;
211
+ cancelLabel: SettingsPanelLocalizedText;
212
+ }
213
+ export interface SettingsPanelDialogNode extends SettingsPanelInteractiveNode {
214
+ kind: "dialog";
215
+ buttonLabel: SettingsPanelLocalizedText;
216
+ dialog: SettingsPanelDialogContent;
217
+ }
218
+ export type SettingsPanelRowNode =
219
+ | SettingsPanelStatusNode
220
+ | SettingsPanelButtonNode
221
+ | SettingsPanelToggleNode
222
+ | SettingsPanelDialogNode;
214
223
 
215
- export type SettingsPanelActionHandler = (
216
- input: SettingsPanelValue | undefined,
217
- context: SettingsPanelProviderContext,
218
- ) => void | Promise<void>;
224
+ export interface SettingsPanelCollectionItem {
225
+ id: string;
226
+ title: SettingsPanelLocalizedText;
227
+ description?: SettingsPanelLocalizedText;
228
+ detail?: SettingsPanelLocalizedText;
229
+ badge?: SettingsPanelBadge;
230
+ disabled?: boolean;
231
+ nodes: SettingsPanelRowNode[];
232
+ }
233
+ export interface SettingsPanelCollectionNode extends SettingsPanelNodeBase {
234
+ kind: "collection";
235
+ emptyLabel?: SettingsPanelLocalizedText;
236
+ items: SettingsPanelCollectionItem[];
237
+ }
238
+ export type SettingsPanelNode =
239
+ | SettingsPanelStatusNode
240
+ | SettingsPanelToggleNode
241
+ | SettingsPanelButtonNode
242
+ | SettingsPanelInputNode
243
+ | SettingsPanelDialogNode
244
+ | SettingsPanelCollectionNode;
219
245
 
220
- /** Trusted main-process callbacks for a registered panel. */
221
- export interface SettingsPanelProvider {
222
- load: SettingsPanelLoader;
223
- actions?: Record<string, SettingsPanelActionHandler>;
246
+ export interface SettingsPanelSection {
247
+ id: string;
248
+ title?: SettingsPanelLocalizedText;
249
+ description?: SettingsPanelLocalizedText;
250
+ nodes: SettingsPanelNode[];
251
+ }
252
+ export interface SettingsPanelView {
253
+ sections: SettingsPanelSection[];
224
254
  }
225
255
 
256
+ export interface SettingsPanelProviderContext {
257
+ panelId: string;
258
+ sessionId: string;
259
+ user: UserProfile;
260
+ }
226
261
  export interface SettingsPanelRegistrationOptions {
227
- /** Whether the panel is initially included in the Settings catalog. */
228
262
  visible?: boolean;
229
263
  }
230
-
231
264
  export interface SettingsPanelRegistration {
232
265
  readonly panelId: string;
266
+ /** Reload the selected panel's complete resolved snapshot. */
267
+ invalidate(): void;
233
268
  setVisible(visible: boolean): void;
234
269
  unregister(): void;
235
270
  }
236
271
 
237
272
  export type SettingsPanelSource = "eden" | "application" | "host";
238
-
239
273
  export interface SettingsPanelSummary {
240
274
  id: string;
275
+ parentId?: string;
241
276
  title: SettingsPanelLocalizedText;
242
277
  description?: SettingsPanelLocalizedText;
243
278
  icon?: string;
244
279
  source: SettingsPanelSource;
245
280
  }
246
-
247
281
  export interface SettingsPanelActionAuthorization {
248
282
  id: string;
249
283
  authorized: boolean;
250
284
  }
251
-
252
- export interface SettingsPanelDeclaration extends SettingsPanelSummary {
253
- sections: SettingsPanelSection[];
285
+ interface SettingsPanelSnapshotBase extends SettingsPanelSummary {
254
286
  actions: SettingsPanelActionAuthorization[];
255
- /** Eden-owned renderer ID. Third-party registrations always use `generic`. */
256
- renderer: "generic" | "appearance" | "apps" | "daemons";
257
287
  }
288
+ export interface SettingsPanelGenericSnapshot
289
+ extends SettingsPanelSnapshotBase {
290
+ renderer: "generic";
291
+ view: SettingsPanelView;
292
+ }
293
+ export interface SettingsPanelAppearanceSnapshot
294
+ extends SettingsPanelSnapshotBase {
295
+ renderer: "appearance";
296
+ data?: SettingsPanelValue;
297
+ }
298
+ export interface SettingsPanelAppsSnapshot extends SettingsPanelSnapshotBase {
299
+ renderer: "apps";
300
+ data?: SettingsPanelValue;
301
+ }
302
+ export interface SettingsPanelDaemonsSnapshot
303
+ extends SettingsPanelSnapshotBase {
304
+ renderer: "daemons";
305
+ data?: SettingsPanelValue;
306
+ }
307
+ export type SettingsPanelCustomSnapshot =
308
+ | SettingsPanelAppearanceSnapshot
309
+ | SettingsPanelAppsSnapshot
310
+ | SettingsPanelDaemonsSnapshot;
311
+ export type SettingsPanelSnapshot =
312
+ | SettingsPanelGenericSnapshot
313
+ | SettingsPanelCustomSnapshot;
258
314
 
259
315
  export interface SettingsPanelError {
260
316
  code:
@@ -267,13 +323,10 @@ export interface SettingsPanelError {
267
323
  message: string;
268
324
  fields?: Record<string, string>;
269
325
  }
270
-
271
326
  export interface SettingsPanelResponse {
272
- panel?: SettingsPanelDeclaration;
273
- state?: SettingsPanelState;
327
+ panel?: SettingsPanelSnapshot;
274
328
  error?: SettingsPanelError;
275
329
  }
276
-
277
330
  export interface SettingsPanelActionResponse {
278
331
  success: boolean;
279
332
  error?: SettingsPanelError;
package/Streams.d.ts ADDED
@@ -0,0 +1,35 @@
1
+ import type { CommandChunk, CommandName } from "./commands";
2
+
3
+ export interface StreamHandle<C extends string = string> {
4
+ command: C;
5
+ id: string;
6
+ }
7
+
8
+ export interface StreamCommand<A, T, C extends string = string> {
9
+ mode: "stream";
10
+ args: A;
11
+ response: StreamHandle<C>;
12
+ chunk: T;
13
+ }
14
+
15
+ /** Known commands retain their chunk type; other handles read unknown values. */
16
+ export type StreamChunk<C extends string> = C extends CommandName
17
+ ? CommandChunk<C>
18
+ : unknown;
19
+
20
+ /** App-side reader for one stream command. Read chunks in order, or cancel. */
21
+ export interface StreamReader<C extends string = string> {
22
+ readonly handle: StreamHandle<C>;
23
+ /**
24
+ * Resolve with the next chunk, or with `done` after the stream ends or is cancelled.
25
+ * Reject when the stream fails.
26
+ */
27
+ next(): Promise<IteratorResult<StreamChunk<C>, undefined>>;
28
+ /** Stop the stream. Waiting and later `next()` calls resolve with `done`. */
29
+ cancel(): Promise<void>;
30
+ }
31
+
32
+ /** A stream reader that `for await` can consume. Leaving the loop early cancels it. */
33
+ export interface CommandStream<C extends string = string>
34
+ extends StreamReader<C>,
35
+ AsyncIterable<StreamChunk<C>, undefined> {}
package/User.d.ts CHANGED
@@ -4,19 +4,25 @@ export interface UserProfile {
4
4
  username: string;
5
5
  name: string;
6
6
  role: UserRole;
7
- /** Writable filesystem root relative to EdenConfig.userDirectory. */
8
- homeDirectory?: string;
7
+ /** Optional accessible folder relative to the Home volume root. */
8
+ directoryRestriction?: string;
9
9
  grants: string[];
10
10
  createdAt: number;
11
11
  updatedAt: number;
12
12
  }
13
13
 
14
+ export interface SessionChange {
15
+ currentUser: UserProfile | null;
16
+ previousUsername: string | null;
17
+ reason: "login" | "logout" | "system";
18
+ }
19
+
14
20
  export interface EdenUserConfig {
15
21
  username: string;
16
22
  name: string;
17
23
  role?: UserRole;
18
- /** Writable filesystem root relative to EdenConfig.userDirectory. */
19
- homeDirectory?: string;
24
+ /** Optional accessible folder relative to the Home volume root. */
25
+ directoryRestriction?: string;
20
26
  password?: string;
21
27
  passwordHash?: string;
22
28
  passwordSalt?: string;
package/commands.d.ts CHANGED
@@ -15,6 +15,8 @@
15
15
  export * from "./commands.generated";
16
16
 
17
17
  import { CommandMap } from "./commands.generated";
18
+ import type { Operation } from "./Operations";
19
+ import type { StreamReader } from "./Streams";
18
20
 
19
21
  /**
20
22
  * Type-safe command name
@@ -27,6 +29,29 @@ export type CommandName = keyof CommandMap;
27
29
  export type CommandArgs<T extends CommandName> = CommandMap[T]["args"];
28
30
 
29
31
  /**
30
- * Get command result type
32
+ * Serializable command response before app-side operation or stream controls are attached.
31
33
  */
32
- export type CommandResult<T extends CommandName> = CommandMap[T]["response"];
34
+ export type CommandResponse<T extends CommandName> = CommandMap[T]["response"];
35
+
36
+ /** App-facing result: operation and stream commands expose controls bound to their handle. */
37
+ export type CommandResult<T extends CommandName> = T extends CommandName
38
+ ? CommandMap[T]["mode"] extends "operation"
39
+ ? Operation<T>
40
+ : CommandMap[T]["mode"] extends "stream"
41
+ ? StreamReader<T>
42
+ : CommandResponse<T>
43
+ : never;
44
+
45
+ /** Eventual completion; result commands have no separate completion. */
46
+ export type CommandCompletion<T extends CommandName> = CommandMap[T] extends {
47
+ completion: infer R;
48
+ }
49
+ ? R
50
+ : never;
51
+
52
+ /** Value type of each chunk that a stream command sends. */
53
+ export type CommandChunk<T extends CommandName> = CommandMap[T] extends {
54
+ chunk: infer R;
55
+ }
56
+ ? R
57
+ : never;