@edenapp/types 0.2.1 → 0.3.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/AppManifest.d.ts CHANGED
@@ -86,6 +86,72 @@ export interface FileHandlerConfig {
86
86
  icon?: string;
87
87
  }
88
88
 
89
+ /**
90
+ * Supported setting input types
91
+ */
92
+ export type SettingType =
93
+ | "text"
94
+ | "number"
95
+ | "checkbox"
96
+ | "radio"
97
+ | "select"
98
+ | "toggle"
99
+ | "textarea"
100
+ | "color"
101
+ | "range";
102
+
103
+ /**
104
+ * Option for radio/select settings
105
+ */
106
+ export interface SettingOption {
107
+ /** Value stored when this option is selected */
108
+ value: string;
109
+ /** Display label for this option */
110
+ label: string;
111
+ /** Optional description for this option */
112
+ description?: string;
113
+ }
114
+
115
+ /**
116
+ * Individual setting definition
117
+ */
118
+ export interface SettingDefinition {
119
+ /** Unique key for this setting */
120
+ key: string;
121
+ /** Display label */
122
+ label: string;
123
+ /** Description shown as help text */
124
+ description?: string;
125
+ /** Input type */
126
+ type: SettingType;
127
+ /** Default value (as string, will be parsed based on type) */
128
+ defaultValue?: string;
129
+ /** Options for radio/select types */
130
+ options?: SettingOption[];
131
+ /** Placeholder for text/textarea */
132
+ placeholder?: string;
133
+ /** Min value for number/range */
134
+ min?: number;
135
+ /** Max value for number/range */
136
+ max?: number;
137
+ /** Step for number/range */
138
+ step?: number;
139
+ }
140
+
141
+ /**
142
+ * Settings category (group of related settings)
143
+ */
144
+ export interface SettingsCategory {
145
+ /** Category ID */
146
+ id: string;
147
+ /** Display name */
148
+ name: string;
149
+ /** Category icon (optional) */
150
+ icon?: string;
151
+ /** Settings in this category */
152
+ settings: SettingDefinition[];
153
+ }
154
+
89
155
  /**
90
156
  * App Manifest Interface
91
157
  *
@@ -195,4 +261,10 @@ export interface AppManifest {
195
261
  * optional access control via allowedClients.
196
262
  */
197
263
  services?: ServiceDeclaration[];
264
+
265
+ /**
266
+ * App settings configuration.
267
+ * Defines settings categories and individual settings that can be configured.
268
+ */
269
+ settings?: SettingsCategory[];
198
270
  }
@@ -243,7 +243,7 @@ export interface FsCommands {
243
243
  "fs/read": {
244
244
  args: {
245
245
  path: string;
246
- encoding?: BufferEncoding };
246
+ encoding?: string };
247
247
  response: string;
248
248
  };
249
249
  /**
@@ -253,7 +253,7 @@ export interface FsCommands {
253
253
  args: {
254
254
  path: string;
255
255
  content: string;
256
- encoding?: BufferEncoding };
256
+ encoding?: string };
257
257
  response: void;
258
258
  };
259
259
  /**
@@ -427,6 +427,104 @@ export interface ProcessCommands {
427
427
  };
428
428
  }
429
429
 
430
+ /**
431
+ * SettingsCommands - Commands for the "settings" namespace
432
+ */
433
+ export interface SettingsCommands {
434
+ /**
435
+ * Get a setting value (scoped to caller's app)
436
+ */
437
+ "settings/get": {
438
+ args: {
439
+ key: string };
440
+ response: { value: string | undefined };
441
+ };
442
+ /**
443
+ * Set a setting value (scoped to caller's app)
444
+ */
445
+ "settings/set": {
446
+ args: {
447
+ key: string;
448
+ value: string };
449
+ response: { success: boolean };
450
+ };
451
+ /**
452
+ * List all settings keys (scoped to caller's app)
453
+ */
454
+ "settings/list": {
455
+ args: { };
456
+ response: { keys: string[] };
457
+ };
458
+ /**
459
+ * Get all settings with values (scoped to caller's app)
460
+ */
461
+ "settings/get-all": {
462
+ args: { };
463
+ response: { settings: Record<string, string> };
464
+ };
465
+ /**
466
+ * Reset a setting to default (scoped to caller's app)
467
+ */
468
+ "settings/reset": {
469
+ args: {
470
+ key: string;
471
+ schema?: import("./index").SettingsCategory[] };
472
+ response: { success: boolean };
473
+ };
474
+ /**
475
+ * Get a setting from any app's namespace (superuser only)
476
+ */
477
+ "settings/get/su": {
478
+ args: {
479
+ appId: string;
480
+ key: string };
481
+ response: { value: string | undefined };
482
+ };
483
+ /**
484
+ * Set a setting in any app's namespace (superuser only)
485
+ */
486
+ "settings/set/su": {
487
+ args: {
488
+ appId: string;
489
+ key: string;
490
+ value: string };
491
+ response: { success: boolean };
492
+ };
493
+ /**
494
+ * List all settings in any app's namespace (superuser only)
495
+ */
496
+ "settings/list/su": {
497
+ args: {
498
+ appId: string };
499
+ response: { keys: string[] };
500
+ };
501
+ /**
502
+ * Get all settings with values for any app (superuser only)
503
+ */
504
+ "settings/get-all/su": {
505
+ args: {
506
+ appId: string };
507
+ response: { settings: Record<string, string> };
508
+ };
509
+ /**
510
+ * Reset a setting for any app (superuser only)
511
+ */
512
+ "settings/reset/su": {
513
+ args: {
514
+ appId: string;
515
+ key: string;
516
+ schema?: import("./index").SettingsCategory[] };
517
+ response: { success: boolean };
518
+ };
519
+ /**
520
+ * Get the Eden settings schema
521
+ */
522
+ "settings/schema": {
523
+ args: Record<string, never>;
524
+ response: { schema: import("./index").SettingsCategory[] };
525
+ };
526
+ }
527
+
430
528
  /**
431
529
  * ViewCommands - Commands for the "view" namespace
432
530
  */
@@ -528,4 +626,4 @@ export interface ViewCommands {
528
626
  /**
529
627
  * Global command map - merge all command namespaces
530
628
  */
531
- export interface CommandMap extends SystemCommands, AppbusCommands, DbCommands, FileCommands, FsCommands, EventCommands, NotificationCommands, PackageCommands, ProcessCommands, ViewCommands {}
629
+ export interface CommandMap extends SystemCommands, AppbusCommands, DbCommands, FileCommands, FsCommands, EventCommands, NotificationCommands, PackageCommands, ProcessCommands, SettingsCommands, ViewCommands {}
@@ -38,6 +38,13 @@ export interface ProcessEvents {
38
38
  "process/exited": { appId: string; code: number };
39
39
  }
40
40
 
41
+ /**
42
+ * SettingsEvents - Events for the "settings" namespace
43
+ */
44
+ export interface SettingsEvents {
45
+ "settings/changed": { appId: string; key: string; value: string };
46
+ }
47
+
41
48
  /**
42
49
  * ViewEvents - Events for the "view" namespace
43
50
  */
@@ -60,4 +67,4 @@ export interface ViewEvents {
60
67
  /**
61
68
  * Global event map - merge all event namespaces
62
69
  */
63
- export interface AppEvents extends FileEvents, NotificationEvents, PackageEvents, ProcessEvents, ViewEvents {}
70
+ export interface AppEvents extends FileEvents, NotificationEvents, PackageEvents, ProcessEvents, SettingsEvents, ViewEvents {}
package/package.json CHANGED
@@ -1,13 +1,12 @@
1
1
  {
2
2
  "name": "@edenapp/types",
3
- "version": "0.2.1",
3
+ "version": "0.3.1",
4
4
  "description": "TypeScript type definitions for the Eden platform",
5
5
  "types": "index.d.ts",
6
6
  "author": "Dariusz Majnert",
7
7
  "license": "MIT",
8
8
  "files": [
9
9
  "*.d.ts",
10
- "ipc/",
11
10
  "README.md"
12
11
  ],
13
12
  "keywords": [
@@ -21,4 +20,4 @@
21
20
  "url": "https://github.com/b0czek/eden.git",
22
21
  "directory": "src/types"
23
22
  }
24
- }
23
+ }
package/ipc/appbus.d.ts DELETED
@@ -1,232 +0,0 @@
1
- /**
2
- * AppBus Type Definitions
3
- *
4
- * Interface for app-to-app communication.
5
- * Used by both frontend (window.appBus) and backend (worker.appBus).
6
- */
7
-
8
- /**
9
- * Schema for fire-and-forget messages (send/on/once)
10
- * Keys are method names, values are the payload types
11
- */
12
- export type MessageSchema = Record<string, any>;
13
-
14
- /**
15
- * Schema for request/response (request/handle)
16
- * Keys are method names, values are { args, result } types
17
- */
18
- export type RequestSchema = Record<string, { args: any; result: any }>;
19
-
20
- /**
21
- * Defines a bidirectional communication protocol between two sides.
22
- * Use "host" for the side that exposes the service (exposeService).
23
- * Use "peer" for the side that connects to the service (connect).
24
- *
25
- * @example
26
- * type ChatProtocol = {
27
- * // Messages the host sends, peer receives
28
- * hostMessages: {
29
- * 'welcome': { text: string };
30
- * 'userJoined': { nickname: string };
31
- * };
32
- * // Messages the peer sends, host receives
33
- * peerMessages: {
34
- * 'typing': { isTyping: boolean };
35
- * };
36
- * // Requests the host handles (peer calls request, host calls handle)
37
- * hostHandles: {
38
- * 'join': { args: { nickname: string }; result: { success: boolean } };
39
- * 'sendMessage': { args: { text: string }; result: void };
40
- * };
41
- * // Requests the peer handles (host calls request, peer calls handle)
42
- * peerHandles: {
43
- * 'ping': { args: {}; result: { pong: boolean } };
44
- * };
45
- * };
46
- */
47
- export interface ChannelProtocol {
48
- /** Messages sent by host, received by peer */
49
- hostMessages: MessageSchema;
50
- /** Messages sent by peer, received by host */
51
- peerMessages: MessageSchema;
52
- /** Requests that peer sends, host handles */
53
- hostHandles: RequestSchema;
54
- /** Requests that host sends, peer handles */
55
- peerHandles: RequestSchema;
56
- }
57
-
58
- /**
59
- * Default empty protocol (all any)
60
- */
61
- type DefaultProtocol = {
62
- hostMessages: MessageSchema;
63
- peerMessages: MessageSchema;
64
- hostHandles: RequestSchema;
65
- peerHandles: RequestSchema;
66
- };
67
-
68
- /**
69
- * AppBus connection from the HOST perspective (the side that exposes the service).
70
- * - send() sends hostMessages
71
- * - on()/once() receives peerMessages
72
- * - request() calls peerHandles
73
- * - handle() implements hostHandles
74
- */
75
- export type HostConnection<P extends ChannelProtocol> = AppBusConnection<
76
- P["hostMessages"],
77
- P["peerMessages"],
78
- P["peerHandles"],
79
- P["hostHandles"]
80
- >;
81
-
82
- /**
83
- * AppBus connection from the PEER perspective (the side that connects).
84
- * - send() sends peerMessages
85
- * - on()/once() receives hostMessages
86
- * - request() calls hostHandles
87
- * - handle() implements peerHandles
88
- */
89
- export type PeerConnection<P extends ChannelProtocol> = AppBusConnection<
90
- P["peerMessages"],
91
- P["hostMessages"],
92
- P["hostHandles"],
93
- P["peerHandles"]
94
- >;
95
-
96
- /**
97
- * AppBus connection returned by connect()
98
- * Also used for frontend<->backend communication (appAPI)
99
- *
100
- * @typeParam TSend - Messages this side sends
101
- * @typeParam TReceive - Messages this side receives
102
- * @typeParam TRequest - Requests this side makes (other side handles)
103
- * @typeParam THandle - Requests this side handles (other side makes)
104
- *
105
- * For typed connections, use HostConnection<Protocol> or PeerConnection<Protocol>
106
- * which automatically flip the perspective.
107
- */
108
- export interface AppBusConnection<
109
- TSend extends MessageSchema = MessageSchema,
110
- TReceive extends MessageSchema = MessageSchema,
111
- TRequest extends RequestSchema = RequestSchema,
112
- THandle extends RequestSchema = RequestSchema,
113
- > {
114
- /** Send a fire-and-forget message */
115
- send<K extends keyof TSend>(method: K, args?: TSend[K]): void;
116
-
117
- /** Listen for messages from the other side */
118
- on<K extends keyof TReceive>(
119
- method: K,
120
- callback: (args: TReceive[K]) => void
121
- ): void;
122
- /** Listen for messages only once, then auto-remove */
123
- once<K extends keyof TReceive>(
124
- method: K,
125
- callback: (args: TReceive[K]) => void
126
- ): void;
127
- /** Remove a listener */
128
- off<K extends keyof TReceive>(
129
- method: K,
130
- callback: (args: TReceive[K]) => void
131
- ): void;
132
-
133
- /** Send a request and wait for response (other side handles) */
134
- request<K extends keyof TRequest>(
135
- method: K,
136
- args?: TRequest[K]["args"]
137
- ): Promise<TRequest[K]["result"]>;
138
-
139
- /** Register a handler for requests from the other side */
140
- handle<K extends keyof THandle>(
141
- method: K,
142
- handler: (
143
- args: THandle[K]["args"]
144
- ) => THandle[K]["result"] | Promise<THandle[K]["result"]>
145
- ): void;
146
- /** Remove a handler */
147
- removeHandler<K extends keyof THandle>(method: K): void;
148
-
149
- /** Check if the connection is active */
150
- isConnected: () => boolean;
151
- /** Register a callback for when the connection closes */
152
- onClose: (callback: () => void) => void;
153
- /** Close the connection */
154
- close: () => void;
155
- }
156
-
157
- /**
158
- * Information about a connecting client
159
- */
160
- export interface ClientInfo {
161
- appId: string;
162
- }
163
-
164
- /**
165
- * Callback invoked when a client connects to a service
166
- */
167
- export type ServiceConnectCallback = (
168
- connection: AppBusConnection,
169
- clientInfo: ClientInfo
170
- ) => void;
171
-
172
- /**
173
- * Service registration options
174
- */
175
- export interface ServiceOptions {
176
- description?: string;
177
- allowedClients?: string[];
178
- }
179
-
180
- /**
181
- * Service info returned by listServices
182
- */
183
- export interface ServiceInfo {
184
- appId: string;
185
- serviceName: string;
186
- description?: string;
187
- }
188
-
189
- /**
190
- * AppBus API - app-to-app communication
191
- */
192
- export interface AppBusAPI {
193
- /**
194
- * Register a service that other apps can connect to.
195
- * When a client connects, onConnect is called with their AppBusConnection.
196
- * @param serviceName - Name of the service
197
- * @param onConnect - Callback invoked for each connecting client with their bidirectional connection
198
- * @param options - Optional configuration
199
- */
200
- exposeService(
201
- serviceName: string,
202
- onConnect: ServiceConnectCallback,
203
- options?: ServiceOptions
204
- ): Promise<{ success: boolean; error?: string }>;
205
-
206
- /**
207
- * Unregister a service
208
- * @param serviceName - Name of the service to unregister
209
- */
210
- unexposeService(serviceName: string): Promise<{ success: boolean }>;
211
-
212
- /**
213
- * Connect to another app's service
214
- * @param targetAppId - App ID of the target app
215
- * @param serviceName - Name of the service to connect to
216
- */
217
- connect(
218
- targetAppId: string,
219
- serviceName: string
220
- ): Promise<AppBusConnection | { error: string }>;
221
-
222
- /**
223
- * List all available services
224
- */
225
- listServices(): Promise<{ services: ServiceInfo[] }>;
226
-
227
- /**
228
- * List services exposed by a specific app
229
- * @param appId - App ID to query
230
- */
231
- listServicesByApp(appId: string): Promise<{ services: ServiceInfo[] }>;
232
- }
package/ipc/edenapi.d.ts DELETED
@@ -1,61 +0,0 @@
1
- /**
2
- * Eden API Type Definitions
3
- *
4
- * Interface for shell commands and event subscriptions.
5
- * Used by both frontend (window.edenAPI) and backend (worker.edenAPI).
6
- */
7
-
8
- import type { CommandName, CommandArgs, CommandResult } from "../commands";
9
- import type { EventName, EventData } from "../events";
10
-
11
- /**
12
- * Eden API - shell commands and event subscriptions
13
- */
14
- export interface EdenAPI {
15
- /**
16
- * Execute a shell command with type-safe arguments
17
- * @param command - The command name (e.g., "process/launch")
18
- * @param args - Type-safe arguments for the command
19
- * @returns Promise with the command result
20
- *
21
- * @example
22
- * ```typescript
23
- * await edenAPI.shellCommand("process/launch", {
24
- * appId: "my-app",
25
- * bounds: { x: 0, y: 0, width: 800, height: 600 }
26
- * });
27
- * ```
28
- */
29
- shellCommand<T extends CommandName>(
30
- command: T,
31
- args: CommandArgs<T>
32
- ): Promise<CommandResult<T>>;
33
-
34
- /**
35
- * Subscribe to a system event
36
- * @param event - The event name
37
- * @param callback - Callback function receiving typed event data
38
- */
39
- subscribe<T extends EventName>(
40
- event: T,
41
- callback: (data: EventData<T>) => void
42
- ): Promise<void>;
43
-
44
- /**
45
- * Unsubscribe from a system event
46
- */
47
- unsubscribe<T extends EventName>(
48
- event: T,
49
- callback: (data: EventData<T>) => void
50
- ): void;
51
-
52
- /**
53
- * Check if an event is supported by the system
54
- */
55
- isEventSupported(event: string): Promise<boolean>;
56
-
57
- /**
58
- * Get the launch arguments passed to this app.
59
- */
60
- getLaunchArgs(): string[];
61
- }
package/ipc/index.d.ts DELETED
@@ -1,6 +0,0 @@
1
- /**
2
- * IPC Type Definitions
3
- */
4
-
5
- export * from "./edenapi";
6
- export * from "./appbus";
@@ -1,13 +0,0 @@
1
- /**
2
- * AUTO-GENERATED FILE - DO NOT EDIT
3
- *
4
- * Type declarations for runtime arrays.
5
- * Generated by scripts/generate-commands.ts
6
- * Run 'pnpm run codegen' to regenerate.
7
- */
8
-
9
- // Command names array
10
- export declare const COMMAND_NAMES: readonly string[];
11
-
12
- // Event names array
13
- export declare const APP_EVENT_NAMES: readonly string[];