@micklsm/dot-workspace-components-sdk 0.1.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/package.json +32 -0
- package/src/index.d.ts +308 -0
- package/src/index.js +0 -0
package/package.json
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@micklsm/dot-workspace-components-sdk",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"main": "./src/index.js",
|
|
5
|
+
"types": "./src/index.d.ts",
|
|
6
|
+
"keywords": [
|
|
7
|
+
"sdk",
|
|
8
|
+
"dot workspace"
|
|
9
|
+
],
|
|
10
|
+
"author": "micklsm",
|
|
11
|
+
"license": "MIT",
|
|
12
|
+
"description": "SDK for dot workspace component development",
|
|
13
|
+
"peerDependencies": {
|
|
14
|
+
"react": "^19.2.6",
|
|
15
|
+
"reactflow": "^11.11.4"
|
|
16
|
+
},
|
|
17
|
+
"devDependencies": {
|
|
18
|
+
"typescript": "^6.0.3"
|
|
19
|
+
},
|
|
20
|
+
"files": [
|
|
21
|
+
"./src/index.d.ts",
|
|
22
|
+
"./src/index.js"
|
|
23
|
+
],
|
|
24
|
+
"scripts": {
|
|
25
|
+
"build": ""
|
|
26
|
+
},
|
|
27
|
+
"exports": {
|
|
28
|
+
".": {
|
|
29
|
+
"types": "./src/index.d.ts"
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
}
|
package/src/index.d.ts
ADDED
|
@@ -0,0 +1,308 @@
|
|
|
1
|
+
export interface WorkspaceAPIs {
|
|
2
|
+
node: {
|
|
3
|
+
create: (type: string, data: any, x: number, y: number) => NodeRuntime;
|
|
4
|
+
findById: (id: string) => NodeRuntime;
|
|
5
|
+
list: () => NodeRuntime[];
|
|
6
|
+
};
|
|
7
|
+
operations: {
|
|
8
|
+
create: (
|
|
9
|
+
name: string,
|
|
10
|
+
validate: OperationValidateDelegate,
|
|
11
|
+
execute: OperationExecuteDelegate,
|
|
12
|
+
) => OperationRuntime;
|
|
13
|
+
findById: (id: string) => OperationRuntime;
|
|
14
|
+
list: () => OperationRuntime[];
|
|
15
|
+
};
|
|
16
|
+
functions: {
|
|
17
|
+
create: <TFunction extends AnyFunctionHandlerDelegate>(
|
|
18
|
+
name: string,
|
|
19
|
+
handler: TFunction,
|
|
20
|
+
tags: FunctionCapabilities[],
|
|
21
|
+
description: string,
|
|
22
|
+
) => FunctionRuntime<TFunction>;
|
|
23
|
+
findByName: <TFunction extends AnyFunctionHandlerDelegate>(
|
|
24
|
+
id: string,
|
|
25
|
+
) => FunctionRuntime<TFunction>;
|
|
26
|
+
list: () => FunctionRuntime<AnyFunctionHandlerDelegate>[];
|
|
27
|
+
};
|
|
28
|
+
workspace: {
|
|
29
|
+
saveNodes: () => Promise<void>;
|
|
30
|
+
saveConfigs: () => Promise<void>;
|
|
31
|
+
|
|
32
|
+
reloadComponents: () => Promise<void>;
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
// findFormById: (id: string) => FormRuntime;
|
|
36
|
+
// findComponentById: (id: string) => ComponentRuntime;
|
|
37
|
+
configs: ConfigurationRuntime;
|
|
38
|
+
}
|
|
39
|
+
export type NodeRendererDelegate = (
|
|
40
|
+
props: import("reactflow").NodeProps,
|
|
41
|
+
) => import("react").JSX.Element;
|
|
42
|
+
|
|
43
|
+
export interface RendererAPIs {
|
|
44
|
+
registerNodeRenderer(key: string, renderer: NodeRendererDelegate): void;
|
|
45
|
+
callFunction<TFunction extends AnyFunctionHandlerDelegate>(
|
|
46
|
+
key: string,
|
|
47
|
+
...args: GetParameters<TFunction>
|
|
48
|
+
): Promise<GetReturn<TFunction>>;
|
|
49
|
+
}
|
|
50
|
+
export interface NodeModel {
|
|
51
|
+
id: string;
|
|
52
|
+
x: number;
|
|
53
|
+
y: number;
|
|
54
|
+
data: any; //always a json object
|
|
55
|
+
type: string;
|
|
56
|
+
}
|
|
57
|
+
export interface WorkspaceModel {
|
|
58
|
+
nodes: NodeModel[];
|
|
59
|
+
}
|
|
60
|
+
export interface ConfigurationModel {
|
|
61
|
+
[name: string]: any;
|
|
62
|
+
}
|
|
63
|
+
export interface NodeRuntime {
|
|
64
|
+
get id(): string;
|
|
65
|
+
get data(): any;
|
|
66
|
+
set data(v: any);
|
|
67
|
+
get type(): string;
|
|
68
|
+
set type(v: string);
|
|
69
|
+
get x(): number;
|
|
70
|
+
set x(v: number);
|
|
71
|
+
get y(): number;
|
|
72
|
+
set y(v: number);
|
|
73
|
+
|
|
74
|
+
destroy(): void;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
export interface ComponentMainProcessModule {
|
|
78
|
+
enable(apis: WorkspaceAPIs): void;
|
|
79
|
+
disable(apis: WorkspaceAPIs): void;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
export interface OperationRuntime {
|
|
83
|
+
get id(): string;
|
|
84
|
+
get name(): string;
|
|
85
|
+
get namespace(): string;
|
|
86
|
+
validate: OperationValidateDelegate;
|
|
87
|
+
execute: OperationExecuteDelegate;
|
|
88
|
+
destroy(): void;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
export interface ComponentRuntime {
|
|
92
|
+
get runtimeId(): string;
|
|
93
|
+
get name(): string;
|
|
94
|
+
get version(): string;
|
|
95
|
+
get requiredHostVersion(): string;
|
|
96
|
+
get description(): string;
|
|
97
|
+
get iconData(): string;
|
|
98
|
+
get readMe(): string;
|
|
99
|
+
get rendererCode(): string;
|
|
100
|
+
get isEnabled(): boolean;
|
|
101
|
+
enable(apis: WorkspaceAPIs): void;
|
|
102
|
+
disable(): void;
|
|
103
|
+
destroy(): void;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
export interface FunctionRuntime<THandler extends AnyFunctionHandlerDelegate> {
|
|
107
|
+
get id(): string;
|
|
108
|
+
get name(): string;
|
|
109
|
+
get namespace(): string;
|
|
110
|
+
get capabilities(): string[];
|
|
111
|
+
get description(): string;
|
|
112
|
+
|
|
113
|
+
invoke(...args: GetParameters<THandler>): GetReturn<THandler>;
|
|
114
|
+
destroy(): void;
|
|
115
|
+
}
|
|
116
|
+
export interface FormRuntime {
|
|
117
|
+
get id(): string;
|
|
118
|
+
get name(): string;
|
|
119
|
+
get formSchema(): FormObjectSchema;
|
|
120
|
+
reply(response: FormResponse): void;
|
|
121
|
+
destroy(): void;
|
|
122
|
+
}
|
|
123
|
+
export interface WorkspaceRuntime {
|
|
124
|
+
loadNode(model: NodeModel): NodeRuntime;
|
|
125
|
+
get configurations(): ConfigurationRuntime;
|
|
126
|
+
createNode(type: string, data: any, x: number, y: number): NodeRuntime;
|
|
127
|
+
createOperation(
|
|
128
|
+
name: string,
|
|
129
|
+
namespace: string,
|
|
130
|
+
validate: OperationValidateDelegate,
|
|
131
|
+
execute: OperationExecuteDelegate,
|
|
132
|
+
): OperationRuntime;
|
|
133
|
+
createFunction<TFunction extends AnyFunctionHandlerDelegate>(
|
|
134
|
+
name: string,
|
|
135
|
+
namespace: string,
|
|
136
|
+
handler: TFunction,
|
|
137
|
+
tags: string[],
|
|
138
|
+
description: string,
|
|
139
|
+
): FunctionRuntime<TFunction>;
|
|
140
|
+
getAllNodes(): NodeRuntime[];
|
|
141
|
+
getAllOperations(): OperationRuntime[];
|
|
142
|
+
getAllFunctions(): FunctionRuntime[];
|
|
143
|
+
findNodeById(id: string): NodeRuntime;
|
|
144
|
+
findOperationById(id: string): OperationRuntime;
|
|
145
|
+
findFunctionByName<TFunction extends AnyFunctionHandlerDelegate>(
|
|
146
|
+
name: string,
|
|
147
|
+
): FunctionRuntime<TFunction>;
|
|
148
|
+
|
|
149
|
+
saveWorkspace(): Promise<void>;
|
|
150
|
+
saveConfigurations(): Promise<void>;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
export interface ConfigurationRuntime {
|
|
154
|
+
get data(): ConfigurationModel;
|
|
155
|
+
set data(): ConfigurationModel;
|
|
156
|
+
}
|
|
157
|
+
export type OperationValidateDelegate = (
|
|
158
|
+
client: WorkspaceUI,
|
|
159
|
+
nodes: NodeRuntime[],
|
|
160
|
+
) => Promise<boolean>;
|
|
161
|
+
export type OperationExecuteDelegate = (
|
|
162
|
+
client: WorkspaceUI,
|
|
163
|
+
nodes: NodeRuntime[],
|
|
164
|
+
x: number,
|
|
165
|
+
y: number,
|
|
166
|
+
) => Promise<void>;
|
|
167
|
+
export type WorkspaceFunctionHandlerDelegate<
|
|
168
|
+
TParameters extends any[],
|
|
169
|
+
TReturn extends any,
|
|
170
|
+
> = (...args: TParameters) => TReturn;
|
|
171
|
+
export type AnyFunctionHandlerDelegate = WorkspaceFunctionHandlerDelegate<
|
|
172
|
+
any[],
|
|
173
|
+
any
|
|
174
|
+
>;
|
|
175
|
+
export type GetParameters<T> =
|
|
176
|
+
T extends WorkspaceFunctionHandlerDelegate<infer P, any> ? P : never;
|
|
177
|
+
export type GetReturn<T> =
|
|
178
|
+
T extends WorkspaceFunctionHandlerDelegate<any, infer R> ? R : never;
|
|
179
|
+
|
|
180
|
+
export type UpdateNodeFunction = WorkspaceFunctionHandlerDelegate<
|
|
181
|
+
[node: NodeModel],
|
|
182
|
+
void
|
|
183
|
+
>;
|
|
184
|
+
export type ListNodesFunction = WorkspaceFunctionHandlerDelegate<
|
|
185
|
+
[],
|
|
186
|
+
NodeModel[]
|
|
187
|
+
>;
|
|
188
|
+
export type ReadNodeFunction = WorkspaceFunctionHandlerDelegate<
|
|
189
|
+
[nodeId: string],
|
|
190
|
+
NodeModel
|
|
191
|
+
>;
|
|
192
|
+
export type DeleteNodeFunction = WorkspaceFunctionHandlerDelegate<
|
|
193
|
+
[nodeId: string],
|
|
194
|
+
void
|
|
195
|
+
>;
|
|
196
|
+
export type SaveWorkspaceFunction = WorkspaceFunctionHandlerDelegate<[], void>;
|
|
197
|
+
export type ReadConfigsFunction = WorkspaceFunctionHandlerDelegate<
|
|
198
|
+
[],
|
|
199
|
+
ConfigurationModel
|
|
200
|
+
>;
|
|
201
|
+
export type UpdateConfigsFunction = WorkspaceFunctionHandlerDelegate<
|
|
202
|
+
[newValue: ConfigurationModel],
|
|
203
|
+
void
|
|
204
|
+
>;
|
|
205
|
+
|
|
206
|
+
export type FunctionCapabilities =
|
|
207
|
+
| "incur-expenses"
|
|
208
|
+
| "sensitive-data"
|
|
209
|
+
| "dangerous";
|
|
210
|
+
export interface IFormService {
|
|
211
|
+
sendForm(
|
|
212
|
+
name: string,
|
|
213
|
+
schema: FormObjectSchema,
|
|
214
|
+
listener: FormListenerDelegate,
|
|
215
|
+
): void;
|
|
216
|
+
}
|
|
217
|
+
export interface INotificationService {
|
|
218
|
+
sendNotification(message: string): void;
|
|
219
|
+
}
|
|
220
|
+
export interface IUINodesService {
|
|
221
|
+
createNodeView(node: NodeModel): void;
|
|
222
|
+
updateNodeView(newValue: NodeModel): void;
|
|
223
|
+
deleteNodeView(id: string): void;
|
|
224
|
+
}
|
|
225
|
+
export interface ConfirmDialogOptions {
|
|
226
|
+
title: string;
|
|
227
|
+
message: string;
|
|
228
|
+
detail?: string;
|
|
229
|
+
|
|
230
|
+
options?: string[];
|
|
231
|
+
|
|
232
|
+
isDangerous: boolean;
|
|
233
|
+
}
|
|
234
|
+
export interface IDialogService {
|
|
235
|
+
confirm(options: ConfirmDialogOptions);
|
|
236
|
+
}
|
|
237
|
+
export interface IWindow {
|
|
238
|
+
get id(): number;
|
|
239
|
+
get type(): "workspace" | "configs-editor" | "components-manager";
|
|
240
|
+
}
|
|
241
|
+
export interface WorkspaceUI
|
|
242
|
+
extends INotificationService, IFormService, IDialogService {}
|
|
243
|
+
export type WorkspaceNotification = NotificationMessage | NotificationProgress;
|
|
244
|
+
export interface NotificationMessage {
|
|
245
|
+
type: "message";
|
|
246
|
+
id: string;
|
|
247
|
+
message: string;
|
|
248
|
+
state: "normal" | "success" | "fail" | "warning";
|
|
249
|
+
}
|
|
250
|
+
export interface NotificationProgress {
|
|
251
|
+
type: "progress";
|
|
252
|
+
id: string;
|
|
253
|
+
title: string;
|
|
254
|
+
message: string;
|
|
255
|
+
progress: {
|
|
256
|
+
current: number;
|
|
257
|
+
max: number;
|
|
258
|
+
};
|
|
259
|
+
}
|
|
260
|
+
export type FormResponse = FormCancelledResponse | FormRepliedResponse;
|
|
261
|
+
export interface FormCancelledResponse {
|
|
262
|
+
action: "cancelled";
|
|
263
|
+
}
|
|
264
|
+
export interface FormRepliedResponse {
|
|
265
|
+
action: "replied";
|
|
266
|
+
data: any;
|
|
267
|
+
}
|
|
268
|
+
export type FormPropertiesSchema =
|
|
269
|
+
| FormStringSchema
|
|
270
|
+
| FormObjectSchema
|
|
271
|
+
| FormNumberSchema
|
|
272
|
+
| FormBooleanSchema;
|
|
273
|
+
|
|
274
|
+
export interface FormStringSchema {
|
|
275
|
+
type: "string";
|
|
276
|
+
enums?: string[];
|
|
277
|
+
}
|
|
278
|
+
export interface FormNumberSchema {
|
|
279
|
+
type: "number";
|
|
280
|
+
max: number;
|
|
281
|
+
min: number;
|
|
282
|
+
}
|
|
283
|
+
export interface FormBooleanSchema {
|
|
284
|
+
type: "boolean";
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
export interface FormObjectSchema {
|
|
288
|
+
type: "object";
|
|
289
|
+
properties: {
|
|
290
|
+
[name: string]: FormPropertiesSchema;
|
|
291
|
+
};
|
|
292
|
+
}
|
|
293
|
+
export type FormListenerDelegate = (response: FormResponse) => void;
|
|
294
|
+
export interface ComponentsManager {
|
|
295
|
+
loadComponentFor: (
|
|
296
|
+
name: string,
|
|
297
|
+
workspace: WorkspaceRuntime,
|
|
298
|
+
) => Promise<ComponentRuntime>;
|
|
299
|
+
listAllLoadedComponents: () => ComponentRuntime[];
|
|
300
|
+
listAllInstalledComponentName: () => string[];
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
export interface ComponentManifest {
|
|
304
|
+
name: string;
|
|
305
|
+
version: string;
|
|
306
|
+
hostVersion: string;
|
|
307
|
+
description: string;
|
|
308
|
+
}
|
package/src/index.js
ADDED
|
File without changes
|