every-plugin 0.0.6 → 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/README.md +77 -13
- package/dist/errors.js +10 -10
- package/dist/plugin.d.ts +98 -44
- package/dist/plugin.js +17 -15
- package/dist/runtime/errors.d.ts +22 -1
- package/dist/runtime/errors.d.ts.map +1 -1
- package/dist/runtime/errors.js +8 -6
- package/dist/runtime/index.d.ts +68 -16
- package/dist/runtime/index.d.ts.map +1 -1
- package/dist/runtime/index.js +126 -27
- package/dist/runtime/mf.test.d.ts +2 -0
- package/dist/runtime/mf.test.d.ts.map +1 -0
- package/dist/runtime/mf.test.js +135 -0
- package/dist/runtime/runtime.test.d.ts +1 -1
- package/dist/runtime/runtime.test.js +366 -296
- package/dist/runtime/services/module-federation.service.d.ts +36 -9
- package/dist/runtime/services/module-federation.service.d.ts.map +1 -1
- package/dist/runtime/services/module-federation.service.js +122 -99
- package/dist/runtime/services/plugin.service.d.ts +66 -13
- package/dist/runtime/services/plugin.service.d.ts.map +1 -1
- package/dist/runtime/services/plugin.service.js +330 -122
- package/dist/runtime/services/secrets.service.d.ts +29 -9
- package/dist/runtime/services/secrets.service.d.ts.map +1 -1
- package/dist/runtime/services/secrets.service.js +30 -26
- package/dist/runtime/services.d.ts +1 -2
- package/dist/runtime/services.d.ts.map +1 -1
- package/dist/runtime/services.js +0 -1
- package/dist/runtime/streaming.d.ts +29 -0
- package/dist/runtime/streaming.d.ts.map +1 -0
- package/dist/runtime/streaming.js +59 -0
- package/dist/runtime/streaming.test.d.ts +2 -0
- package/dist/runtime/streaming.test.d.ts.map +1 -0
- package/dist/runtime/streaming.test.js +271 -0
- package/dist/runtime/test-utils.d.ts +3 -0
- package/dist/runtime/test-utils.d.ts.map +1 -0
- package/dist/runtime/test-utils.js +13 -0
- package/dist/runtime/types.d.ts +27 -27
- package/dist/runtime/validation.d.ts +1 -1
- package/dist/runtime/validation.d.ts.map +1 -1
- package/dist/runtime/validation.js +14 -11
- package/dist/source.d.ts +62 -190
- package/dist/source.d.ts.map +1 -1
- package/dist/source.js +32 -85
- package/package.json +7 -3
- package/dist/runtime/runtime.d.ts +0 -58
- package/dist/runtime/runtime.d.ts.map +0 -1
- package/dist/runtime/runtime.js +0 -75
- package/dist/runtime/services/plugin-cache.service.d.ts +0 -18
- package/dist/runtime/services/plugin-cache.service.d.ts.map +0 -1
- package/dist/runtime/services/plugin-cache.service.js +0 -55
package/README.md
CHANGED
|
@@ -15,11 +15,11 @@ bun add every-plugin
|
|
|
15
15
|
### Basic Plugin Usage
|
|
16
16
|
|
|
17
17
|
```typescript
|
|
18
|
-
import { Effect
|
|
19
|
-
import { PluginRuntime } from "every-plugin/runtime";
|
|
18
|
+
import { Effect } from "effect";
|
|
19
|
+
import { createPluginRuntime, PluginRuntime } from "every-plugin/runtime";
|
|
20
20
|
|
|
21
21
|
// Create a managed runtime (do this once per application/worker)
|
|
22
|
-
const runtime =
|
|
22
|
+
const runtime = createPluginRuntime({
|
|
23
23
|
registry: {
|
|
24
24
|
"@my-org/data-processor": {
|
|
25
25
|
version: "1.0.0",
|
|
@@ -33,14 +33,14 @@ const runtime = ManagedRuntime.make(PluginRuntime.Live({
|
|
|
33
33
|
DATABASE_URL: "postgresql://..."
|
|
34
34
|
},
|
|
35
35
|
logger: customLogger // optional
|
|
36
|
-
})
|
|
36
|
+
});
|
|
37
37
|
|
|
38
38
|
// Use the runtime to execute plugins
|
|
39
39
|
const result = await runtime.runPromise(
|
|
40
40
|
Effect.gen(function* () {
|
|
41
41
|
const pluginRuntime = yield* PluginRuntime;
|
|
42
42
|
|
|
43
|
-
//
|
|
43
|
+
// Load, instantiate and initialize a plugin
|
|
44
44
|
const plugin = yield* pluginRuntime.usePlugin("@my-org/data-processor", {
|
|
45
45
|
apiKey: "{{API_KEY}}", // Will be hydrated from secrets
|
|
46
46
|
batchSize: 100
|
|
@@ -60,23 +60,25 @@ console.log(result);
|
|
|
60
60
|
await runtime.dispose();
|
|
61
61
|
```
|
|
62
62
|
|
|
63
|
-
### Alternative:
|
|
63
|
+
### Alternative: Direct Layer Construction
|
|
64
64
|
|
|
65
|
-
If you prefer
|
|
65
|
+
If you prefer more explicit control over the runtime construction:
|
|
66
66
|
|
|
67
67
|
```typescript
|
|
68
|
-
import {
|
|
68
|
+
import { Effect, ManagedRuntime } from "effect";
|
|
69
|
+
import { PluginRuntime } from "every-plugin/runtime";
|
|
69
70
|
|
|
70
|
-
// This is equivalent to
|
|
71
|
-
const runtime =
|
|
71
|
+
// This is equivalent to createPluginRuntime(config)
|
|
72
|
+
const runtime = ManagedRuntime.make(PluginRuntime.Live({
|
|
72
73
|
registry: { /* ... */ },
|
|
73
74
|
secrets: { /* ... */ }
|
|
74
|
-
});
|
|
75
|
+
}));
|
|
75
76
|
|
|
76
77
|
const result = await runtime.runPromise(
|
|
77
78
|
Effect.gen(function* () {
|
|
78
79
|
const pluginRuntime = yield* PluginRuntime;
|
|
79
|
-
|
|
80
|
+
const plugin = yield* pluginRuntime.usePlugin(pluginId, config);
|
|
81
|
+
return yield* pluginRuntime.executePlugin(plugin, input);
|
|
80
82
|
})
|
|
81
83
|
);
|
|
82
84
|
```
|
|
@@ -139,6 +141,68 @@ process.on("SIGTERM", async () => {
|
|
|
139
141
|
});
|
|
140
142
|
```
|
|
141
143
|
|
|
144
|
+
```typescript
|
|
145
|
+
import { Effect } from "effect";
|
|
146
|
+
import { createPluginRuntime, PluginRuntime } from "every-plugin/runtime";
|
|
147
|
+
|
|
148
|
+
// Create a managed runtime (do this once per application/worker)
|
|
149
|
+
const runtime = createPluginRuntime({
|
|
150
|
+
registry: {
|
|
151
|
+
"@my-org/data-processor": {
|
|
152
|
+
version: "1.0.0",
|
|
153
|
+
remoteUrl: "https://cdn.example.com/plugins/data-processor@latest/remoteEntry.js",
|
|
154
|
+
description: "Processes data items",
|
|
155
|
+
type: "pipeline"
|
|
156
|
+
}
|
|
157
|
+
},
|
|
158
|
+
secrets: {
|
|
159
|
+
API_KEY: "your-secret-key",
|
|
160
|
+
DATABASE_URL: "postgresql://..."
|
|
161
|
+
},
|
|
162
|
+
logger: customLogger // optional
|
|
163
|
+
});
|
|
164
|
+
|
|
165
|
+
// Use the runtime to execute plugins
|
|
166
|
+
const result = await runtime.runPromise(
|
|
167
|
+
Effect.gen(function* () {
|
|
168
|
+
const pluginRuntime = yield* PluginRuntime;
|
|
169
|
+
|
|
170
|
+
return yield* pluginRuntime.streamPlugin(
|
|
171
|
+
"test-source-plugin",
|
|
172
|
+
TEST_CONFIG,
|
|
173
|
+
TEST_SEARCH_INPUT,
|
|
174
|
+
).pipe(
|
|
175
|
+
Effect.flatMap(stream => stream.pipe(Stream.runCollect)),
|
|
176
|
+
Effect.catchAll((error: unknown) => {
|
|
177
|
+
// Should handle callback errors
|
|
178
|
+
expect(error).toBeDefined();
|
|
179
|
+
return Effect.succeed("callback-error-handled");
|
|
180
|
+
}),
|
|
181
|
+
);
|
|
182
|
+
|
|
183
|
+
// Load, instantiate and initialize a plugin
|
|
184
|
+
const plugin = yield* pluginRuntime.usePlugin("@my-org/data-processor", {
|
|
185
|
+
apiKey: "{{API_KEY}}", // Will be hydrated from secrets
|
|
186
|
+
batchSize: 100
|
|
187
|
+
});
|
|
188
|
+
|
|
189
|
+
// I want to do this in the source stream
|
|
190
|
+
const output = yield* pluginRuntime.executePlugin(plugin, {
|
|
191
|
+
items: ["item1", "item2", "item3"]
|
|
192
|
+
});
|
|
193
|
+
|
|
194
|
+
|
|
195
|
+
|
|
196
|
+
return output;
|
|
197
|
+
})
|
|
198
|
+
);
|
|
199
|
+
|
|
200
|
+
console.log(result);
|
|
201
|
+
|
|
202
|
+
// Clean up when done
|
|
203
|
+
await runtime.dispose();
|
|
204
|
+
```
|
|
205
|
+
|
|
142
206
|
### React/Next.js Integration
|
|
143
207
|
|
|
144
208
|
```typescript
|
|
@@ -245,7 +309,7 @@ Effect service tag for accessing the plugin runtime within Effect workflows.
|
|
|
245
309
|
- `instantiatePlugin(constructor)`: Create plugin instance
|
|
246
310
|
- `initializePlugin(instance, config)`: Initialize with config and secrets
|
|
247
311
|
- `executePlugin(plugin, input)`: Execute plugin with input
|
|
248
|
-
- `usePlugin(pluginId, config)`: Load + instantiate + initialize in one step
|
|
312
|
+
- `usePlugin(pluginId, config)`: Load + instantiate + initialize in one step (does not execute)
|
|
249
313
|
|
|
250
314
|
## Development
|
|
251
315
|
|
package/dist/errors.js
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
// Plugin execution errors
|
|
2
2
|
export class PluginExecutionError extends Error {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
3
|
+
retryable;
|
|
4
|
+
constructor(message, retryable = true) {
|
|
5
|
+
super(message);
|
|
6
|
+
this.retryable = retryable;
|
|
7
|
+
this.name = "PluginExecutionError";
|
|
8
|
+
}
|
|
9
9
|
}
|
|
10
10
|
export class ConfigurationError extends PluginExecutionError {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
11
|
+
constructor(message) {
|
|
12
|
+
super(message, false); // Configuration errors are not retryable
|
|
13
|
+
this.name = "ConfigurationError";
|
|
14
|
+
}
|
|
15
15
|
}
|
package/dist/plugin.d.ts
CHANGED
|
@@ -1,57 +1,111 @@
|
|
|
1
1
|
import { Context, type Effect } from "effect";
|
|
2
2
|
import { z } from "zod";
|
|
3
3
|
import type { ConfigurationError, PluginExecutionError } from "./errors";
|
|
4
|
-
export declare const createOutputSchema: <T extends z.ZodTypeAny>(
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
4
|
+
export declare const createOutputSchema: <T extends z.ZodTypeAny>(
|
|
5
|
+
dataSchema: T,
|
|
6
|
+
) => z.ZodObject<
|
|
7
|
+
{
|
|
8
|
+
success: z.ZodBoolean;
|
|
9
|
+
data: z.ZodOptional<T>;
|
|
10
|
+
errors: z.ZodOptional<
|
|
11
|
+
z.ZodArray<
|
|
12
|
+
z.ZodObject<
|
|
13
|
+
{
|
|
14
|
+
message: z.ZodString;
|
|
15
|
+
details: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
16
|
+
stack: z.ZodOptional<z.ZodString>;
|
|
17
|
+
},
|
|
18
|
+
z.core.$strip
|
|
19
|
+
>
|
|
20
|
+
>
|
|
21
|
+
>;
|
|
22
|
+
},
|
|
23
|
+
z.core.$strip
|
|
24
|
+
>;
|
|
25
|
+
export declare function createConfigSchema<
|
|
26
|
+
V extends z.ZodTypeAny,
|
|
27
|
+
S extends z.ZodTypeAny,
|
|
28
|
+
>(
|
|
29
|
+
variablesSchema?: V,
|
|
30
|
+
secretsSchema?: S,
|
|
31
|
+
): z.ZodObject<{
|
|
32
|
+
variables: z.ZodOptional<V>;
|
|
33
|
+
secrets: z.ZodOptional<S>;
|
|
16
34
|
}>;
|
|
17
|
-
export declare function createInputSchema<I extends z.ZodTypeAny>(
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
35
|
+
export declare function createInputSchema<I extends z.ZodTypeAny>(
|
|
36
|
+
inputSchema: I,
|
|
37
|
+
): I;
|
|
38
|
+
export declare const ErrorDetailsSchema: z.ZodObject<
|
|
39
|
+
{
|
|
40
|
+
message: z.ZodString;
|
|
41
|
+
details: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
42
|
+
stack: z.ZodOptional<z.ZodString>;
|
|
43
|
+
},
|
|
44
|
+
z.core.$strip
|
|
45
|
+
>;
|
|
23
46
|
export type ErrorDetails = z.infer<typeof ErrorDetailsSchema>;
|
|
24
|
-
export type Config<
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
47
|
+
export type Config<
|
|
48
|
+
V extends z.ZodTypeAny = z.ZodRecord<z.ZodString, z.ZodUnknown>,
|
|
49
|
+
S extends z.ZodTypeAny = z.ZodRecord<z.ZodString, z.ZodUnknown>,
|
|
50
|
+
> = z.infer<ReturnType<typeof createConfigSchema<V, S>>>;
|
|
51
|
+
export type Input<I extends z.ZodTypeAny> = z.infer<
|
|
52
|
+
ReturnType<typeof createInputSchema<I>>
|
|
53
|
+
>;
|
|
54
|
+
export type Output<T extends z.ZodTypeAny> = z.infer<
|
|
55
|
+
ReturnType<typeof createOutputSchema<T>>
|
|
56
|
+
>;
|
|
57
|
+
export interface Plugin<
|
|
58
|
+
TInputSchema extends z.ZodTypeAny,
|
|
59
|
+
TOutputSchema extends z.ZodTypeAny,
|
|
60
|
+
TConfigSchema extends z.ZodTypeAny,
|
|
61
|
+
> {
|
|
62
|
+
readonly id: string;
|
|
63
|
+
readonly type: PluginType;
|
|
64
|
+
readonly inputSchema: TInputSchema;
|
|
65
|
+
readonly outputSchema: TOutputSchema;
|
|
66
|
+
readonly configSchema: TConfigSchema;
|
|
67
|
+
initialize(
|
|
68
|
+
config?: z.infer<TConfigSchema>,
|
|
69
|
+
): Effect.Effect<void, ConfigurationError, PluginLoggerTag>;
|
|
70
|
+
execute(
|
|
71
|
+
input: z.infer<TInputSchema>,
|
|
72
|
+
): Effect.Effect<
|
|
73
|
+
z.infer<TOutputSchema>,
|
|
74
|
+
PluginExecutionError,
|
|
75
|
+
PluginLoggerTag
|
|
76
|
+
>;
|
|
77
|
+
shutdown(): Effect.Effect<void, never, PluginLoggerTag>;
|
|
36
78
|
}
|
|
37
79
|
export type PluginType = "transformer" | "distributor" | "source";
|
|
38
80
|
export interface PluginMetadata {
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
81
|
+
remoteUrl: string;
|
|
82
|
+
type?: PluginType;
|
|
83
|
+
version?: string;
|
|
84
|
+
description?: string;
|
|
43
85
|
}
|
|
44
86
|
export interface PluginRegistry {
|
|
45
|
-
|
|
87
|
+
[pluginId: string]: PluginMetadata;
|
|
46
88
|
}
|
|
47
89
|
export interface PluginLogger {
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
90
|
+
readonly logInfo: (message: string, context?: unknown) => Effect.Effect<void>;
|
|
91
|
+
readonly logWarning: (
|
|
92
|
+
message: string,
|
|
93
|
+
context?: unknown,
|
|
94
|
+
) => Effect.Effect<void>;
|
|
95
|
+
readonly logError: (
|
|
96
|
+
message: string,
|
|
97
|
+
error?: unknown,
|
|
98
|
+
context?: unknown,
|
|
99
|
+
) => Effect.Effect<void>;
|
|
100
|
+
readonly logDebug: (
|
|
101
|
+
message: string,
|
|
102
|
+
context?: unknown,
|
|
103
|
+
) => Effect.Effect<void>;
|
|
52
104
|
}
|
|
53
|
-
declare const PluginLoggerTag_base: Context.TagClass<
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
105
|
+
declare const PluginLoggerTag_base: Context.TagClass<
|
|
106
|
+
PluginLoggerTag,
|
|
107
|
+
"PluginLogger",
|
|
108
|
+
PluginLogger
|
|
109
|
+
>;
|
|
110
|
+
export declare class PluginLoggerTag extends PluginLoggerTag_base {}
|
|
111
|
+
//# sourceMappingURL=plugin.d.ts.map
|
package/dist/plugin.js
CHANGED
|
@@ -1,25 +1,27 @@
|
|
|
1
1
|
import { Context } from "effect";
|
|
2
2
|
import { z } from "zod";
|
|
3
3
|
// Helpers
|
|
4
|
-
export const createOutputSchema = (dataSchema) =>
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
4
|
+
export const createOutputSchema = (dataSchema) =>
|
|
5
|
+
z.object({
|
|
6
|
+
success: z.boolean(),
|
|
7
|
+
data: dataSchema.optional(),
|
|
8
|
+
errors: z.array(ErrorDetailsSchema).optional(),
|
|
9
|
+
});
|
|
9
10
|
export function createConfigSchema(variablesSchema, secretsSchema) {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
11
|
+
return z.object({
|
|
12
|
+
variables: (
|
|
13
|
+
variablesSchema ?? z.record(z.string(), z.unknown())
|
|
14
|
+
).optional(),
|
|
15
|
+
secrets: (secretsSchema ?? z.record(z.string(), z.unknown())).optional(),
|
|
16
|
+
});
|
|
14
17
|
}
|
|
15
18
|
export function createInputSchema(inputSchema) {
|
|
16
|
-
|
|
19
|
+
return inputSchema;
|
|
17
20
|
}
|
|
18
21
|
// Core schemas
|
|
19
22
|
export const ErrorDetailsSchema = z.object({
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
+
message: z.string(),
|
|
24
|
+
details: z.record(z.string(), z.unknown()).optional(),
|
|
25
|
+
stack: z.string().optional(),
|
|
23
26
|
});
|
|
24
|
-
export class PluginLoggerTag extends Context.Tag("PluginLogger")() {
|
|
25
|
-
}
|
|
27
|
+
export class PluginLoggerTag extends Context.Tag("PluginLogger")() {}
|
package/dist/runtime/errors.d.ts
CHANGED
|
@@ -35,7 +35,28 @@ declare const ValidationError_base: new <A extends Record<string, any> = {}>(
|
|
|
35
35
|
} & Readonly<A>;
|
|
36
36
|
export declare class ValidationError extends ValidationError_base<{
|
|
37
37
|
readonly pluginId: string;
|
|
38
|
-
readonly stage: "config" | "input" | "output";
|
|
38
|
+
readonly stage: "config" | "input" | "output" | "state";
|
|
39
39
|
readonly zodError: z.ZodError;
|
|
40
40
|
}> {}
|
|
41
|
+
declare const StreamError_base: new <A extends Record<string, any> = {}>(
|
|
42
|
+
args: import("effect/Types").Equals<A, {}> extends true
|
|
43
|
+
? void
|
|
44
|
+
: { readonly [P in keyof A as P extends "_tag" ? never : P]: A[P] },
|
|
45
|
+
) => import("effect/Cause").YieldableError & {
|
|
46
|
+
readonly _tag: "StreamError";
|
|
47
|
+
} & Readonly<A>;
|
|
48
|
+
export declare class StreamError extends StreamError_base<{
|
|
49
|
+
readonly pluginId: string;
|
|
50
|
+
readonly operation:
|
|
51
|
+
| "callback"
|
|
52
|
+
| "state-extraction"
|
|
53
|
+
| "item-extraction"
|
|
54
|
+
| "stream-termination";
|
|
55
|
+
readonly cause?: Error;
|
|
56
|
+
readonly context?: {
|
|
57
|
+
readonly iteration?: number;
|
|
58
|
+
readonly itemsProcessed?: number;
|
|
59
|
+
readonly procedureName?: string;
|
|
60
|
+
};
|
|
61
|
+
}> {}
|
|
41
62
|
//# sourceMappingURL=errors.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/runtime/errors.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;;;;AAE7B,qBAAa,kBAAmB,SAAQ,wBAAuC;
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/runtime/errors.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;;;;AAE7B,qBAAa,kBAAmB,SAAQ,wBAAuC;IAC9E,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,KAAK,CAAC,EAAE,KAAK,CAAC;IACvB,QAAQ,CAAC,SAAS,EAAE,OAAO,CAAC;CAC5B,CAAC;CAAG;;;;AAEL,qBAAa,qBAAsB,SAAQ,2BAEzC;IACD,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,KAAK,CAAC,EAAE,KAAK,CAAC;CACvB,CAAC;CAAG;;;;AAEL,qBAAa,eAAgB,SAAQ,qBAAoC;IACxE,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,KAAK,EAAE,QAAQ,GAAG,OAAO,GAAG,QAAQ,GAAG,OAAO,CAAC;IACxD,QAAQ,CAAC,QAAQ,EAAE,CAAC,CAAC,QAAQ,CAAC;CAC9B,CAAC;CAAG;;;;AAEL,qBAAa,WAAY,SAAQ,iBAAgC;IAChE,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,SAAS,EAAE,UAAU,GAAG,kBAAkB,GAAG,iBAAiB,GAAG,oBAAoB,CAAC;IAC/F,QAAQ,CAAC,KAAK,CAAC,EAAE,KAAK,CAAC;IACvB,QAAQ,CAAC,OAAO,CAAC,EAAE;QAClB,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;QAC5B,QAAQ,CAAC,cAAc,CAAC,EAAE,MAAM,CAAC;QACjC,QAAQ,CAAC,aAAa,CAAC,EAAE,MAAM,CAAC;KAChC,CAAC;CACF,CAAC;CAAG"}
|
package/dist/runtime/errors.js
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { Data } from "effect";
|
|
2
|
-
export class PluginRuntimeError extends Data.TaggedError(
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
}
|
|
2
|
+
export class PluginRuntimeError extends Data.TaggedError(
|
|
3
|
+
"PluginRuntimeError",
|
|
4
|
+
) {}
|
|
5
|
+
export class ModuleFederationError extends Data.TaggedError(
|
|
6
|
+
"ModuleFederationError",
|
|
7
|
+
) {}
|
|
8
|
+
export class ValidationError extends Data.TaggedError("ValidationError") {}
|
|
9
|
+
export class StreamError extends Data.TaggedError("StreamError") {}
|
package/dist/runtime/index.d.ts
CHANGED
|
@@ -1,21 +1,73 @@
|
|
|
1
|
-
import { Effect, Layer, ManagedRuntime } from "effect";
|
|
1
|
+
import { Effect, Layer, ManagedRuntime, type Stream } from "effect";
|
|
2
2
|
import type { z } from "zod";
|
|
3
|
-
import type {
|
|
4
|
-
import
|
|
3
|
+
import type { SourcePlugin } from "../source";
|
|
4
|
+
import { PluginRuntimeError } from "./errors";
|
|
5
|
+
import { type SourceStreamOptions } from "./streaming";
|
|
6
|
+
import type {
|
|
7
|
+
AnyPlugin,
|
|
8
|
+
InitializedPlugin,
|
|
9
|
+
PluginConstructor,
|
|
10
|
+
PluginInstance,
|
|
11
|
+
PluginRuntimeConfig,
|
|
12
|
+
} from "./types";
|
|
5
13
|
export interface IPluginRuntime {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
14
|
+
readonly loadPlugin: (
|
|
15
|
+
pluginId: string,
|
|
16
|
+
) => Effect.Effect<PluginConstructor, PluginRuntimeError>;
|
|
17
|
+
readonly instantiatePlugin: <T extends AnyPlugin>(
|
|
18
|
+
ctor: PluginConstructor,
|
|
19
|
+
) => Effect.Effect<PluginInstance<T>, PluginRuntimeError>;
|
|
20
|
+
readonly initializePlugin: <T extends AnyPlugin>(
|
|
21
|
+
instance: PluginInstance<T>,
|
|
22
|
+
config: z.infer<T["configSchema"]>,
|
|
23
|
+
) => Effect.Effect<InitializedPlugin<T>, PluginRuntimeError>;
|
|
24
|
+
readonly executePlugin: <T extends AnyPlugin>(
|
|
25
|
+
initializedPlugin: InitializedPlugin<T>,
|
|
26
|
+
input: z.infer<T["inputSchema"]>,
|
|
27
|
+
) => Effect.Effect<z.infer<T["outputSchema"]>, PluginRuntimeError>;
|
|
28
|
+
readonly usePlugin: <T extends AnyPlugin>(
|
|
29
|
+
pluginId: string,
|
|
30
|
+
config: z.infer<T["configSchema"]>,
|
|
31
|
+
) => Effect.Effect<InitializedPlugin<T>, PluginRuntimeError>;
|
|
32
|
+
readonly streamPlugin: <
|
|
33
|
+
T extends SourcePlugin,
|
|
34
|
+
TInput extends z.infer<T["inputSchema"]> = z.infer<T["inputSchema"]>,
|
|
35
|
+
TItem = unknown,
|
|
36
|
+
>(
|
|
37
|
+
pluginId: string,
|
|
38
|
+
config: z.infer<T["configSchema"]>,
|
|
39
|
+
input: TInput,
|
|
40
|
+
options?: SourceStreamOptions<TItem>,
|
|
41
|
+
) => Effect.Effect<
|
|
42
|
+
Stream.Stream<TItem, PluginRuntimeError>,
|
|
43
|
+
PluginRuntimeError
|
|
44
|
+
>;
|
|
45
|
+
readonly shutdown: () => Effect.Effect<void, never, never>;
|
|
12
46
|
}
|
|
13
|
-
declare const PluginRuntime_base: import("effect/Context").TagClass<
|
|
14
|
-
|
|
15
|
-
|
|
47
|
+
declare const PluginRuntime_base: import("effect/Context").TagClass<
|
|
48
|
+
PluginRuntime,
|
|
49
|
+
"PluginRuntime",
|
|
50
|
+
IPluginRuntime
|
|
51
|
+
> &
|
|
52
|
+
Effect.Tag.Proxy<PluginRuntime, IPluginRuntime> & {
|
|
53
|
+
use: <X>(
|
|
54
|
+
body: (_: IPluginRuntime) => X,
|
|
55
|
+
) => [X] extends [Effect.Effect<infer A, infer E, infer R>]
|
|
56
|
+
? Effect.Effect<A, E, PluginRuntime | R>
|
|
57
|
+
: [X] extends [PromiseLike<infer A_1>]
|
|
58
|
+
? Effect.Effect<
|
|
59
|
+
A_1,
|
|
60
|
+
import("effect/Cause").UnknownException,
|
|
61
|
+
PluginRuntime
|
|
62
|
+
>
|
|
63
|
+
: Effect.Effect<X, never, PluginRuntime>;
|
|
64
|
+
};
|
|
16
65
|
export declare class PluginRuntime extends PluginRuntime_base {
|
|
17
|
-
|
|
66
|
+
static Live: (
|
|
67
|
+
config: PluginRuntimeConfig,
|
|
68
|
+
) => Layer.Layer<PluginRuntime, never, never>;
|
|
18
69
|
}
|
|
19
|
-
export declare const createPluginRuntime: (
|
|
20
|
-
|
|
21
|
-
|
|
70
|
+
export declare const createPluginRuntime: (
|
|
71
|
+
config: PluginRuntimeConfig,
|
|
72
|
+
) => ManagedRuntime.ManagedRuntime<PluginRuntime, never>;
|
|
73
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/runtime/index.ts"],"names":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