every-plugin 0.0.6 → 0.1.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/README.md +1 -265
- package/dist/errors.d.ts +4 -4
- package/dist/index.d.ts +2 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -3
- package/dist/plugin.d.ts +74 -34
- package/dist/plugin.d.ts.map +1 -1
- package/dist/plugin.js +100 -17
- package/dist/runtime/errors.d.ts +38 -34
- package/dist/runtime/errors.d.ts.map +1 -1
- package/dist/runtime/errors.js +2 -0
- package/dist/runtime/index.d.ts +7 -4
- package/dist/runtime/index.d.ts.map +1 -1
- package/dist/runtime/index.js +5 -10
- package/dist/runtime/services/module-federation.service.d.ts +5 -6
- package/dist/runtime/services/module-federation.service.d.ts.map +1 -1
- package/dist/runtime/services/module-federation.service.js +53 -15
- package/dist/runtime/services/plugin.service.d.ts +13 -6
- package/dist/runtime/services/plugin.service.d.ts.map +1 -1
- package/dist/runtime/services/plugin.service.js +237 -94
- package/dist/runtime/services/secrets.service.d.ts.map +1 -1
- package/dist/runtime/services.d.ts +0 -1
- package/dist/runtime/services.d.ts.map +1 -1
- package/dist/runtime/services.js +0 -1
- package/dist/runtime/streaming/index.d.ts +4 -0
- package/dist/runtime/streaming/index.d.ts.map +1 -0
- package/dist/runtime/streaming/index.js +2 -0
- package/dist/runtime/streaming/state-effects.d.ts +28 -0
- package/dist/runtime/streaming/state-effects.d.ts.map +1 -0
- package/dist/runtime/streaming/state-effects.js +30 -0
- package/dist/runtime/streaming/streaming.d.ts +8 -0
- package/dist/runtime/streaming/streaming.d.ts.map +1 -0
- package/dist/runtime/streaming/streaming.js +107 -0
- package/dist/runtime/streaming/types.d.ts +19 -0
- package/dist/runtime/streaming/types.d.ts.map +1 -0
- package/dist/runtime/streaming/types.js +1 -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 +7 -0
- package/dist/runtime/types.d.ts +1 -1
- package/dist/runtime/types.d.ts.map +1 -1
- package/dist/runtime/validation.d.ts +2 -7
- package/dist/runtime/validation.d.ts.map +1 -1
- package/dist/testing/index.d.ts +25 -0
- package/dist/testing/index.d.ts.map +1 -0
- package/dist/testing/index.js +40 -0
- package/dist/testing/mocks/module-federation.service.d.ts +8 -0
- package/dist/testing/mocks/module-federation.service.d.ts.map +1 -0
- package/dist/testing/mocks/module-federation.service.js +35 -0
- package/package.json +27 -6
- 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/runtime.test.d.ts +0 -2
- package/dist/runtime/runtime.test.d.ts.map +0 -1
- package/dist/runtime/runtime.test.js +0 -308
- 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/dist/source.d.ts +0 -198
- package/dist/source.d.ts.map +0 -1
- package/dist/source.js +0 -90
package/dist/runtime/types.d.ts
CHANGED
|
@@ -8,7 +8,7 @@ export interface PluginRuntimeConfig {
|
|
|
8
8
|
export interface SecretsConfig {
|
|
9
9
|
[key: string]: string;
|
|
10
10
|
}
|
|
11
|
-
export type AnyPlugin = Plugin<
|
|
11
|
+
export type AnyPlugin = Plugin<any, z.ZodTypeAny, z.ZodTypeAny>;
|
|
12
12
|
export interface PluginConstructor {
|
|
13
13
|
readonly ctor: new () => AnyPlugin;
|
|
14
14
|
readonly metadata: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/runtime/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAC7B,OAAO,KAAK,EAAE,MAAM,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAGtE,MAAM,WAAW,mBAA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B,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;QAC1B,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC;QAC1B,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,CAAC;QAC9B,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;KACvB,CAAC;CACF;AAED,MAAM,WAAW,iBAAiB,CAAC,CAAC,SAAS,SAAS,GAAG,SAAS;IACjE,QAAQ,CAAC,MAAM,EAAE,CAAC,CAAA;IAClB,QAAQ,CAAC,QAAQ,EAAE;QAClB,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;QAC1B,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC;QAC1B,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,CAAC;QAC9B,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;KACvB,CAAC;IACF,QAAQ,CAAC,MAAM,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,cAAc,CAAC,CAAC,CAAC;CAC5C"}
|
|
@@ -1,10 +1,5 @@
|
|
|
1
1
|
import { Effect } from "effect";
|
|
2
2
|
import type { z } from "zod";
|
|
3
3
|
import { ValidationError } from "./errors";
|
|
4
|
-
export declare const validate: <T>(
|
|
5
|
-
|
|
6
|
-
data: unknown,
|
|
7
|
-
pluginId: string,
|
|
8
|
-
stage: "config" | "input" | "output",
|
|
9
|
-
) => Effect.Effect<T, ValidationError>;
|
|
10
|
-
//# sourceMappingURL=validation.d.ts.map
|
|
4
|
+
export declare const validate: <T>(schema: z.ZodSchema<T>, data: unknown, pluginId: string, stage: "config" | "input" | "output" | "state") => Effect.Effect<T, ValidationError>;
|
|
5
|
+
//# sourceMappingURL=validation.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validation.d.ts","sourceRoot":"","sources":["../../src/runtime/validation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChC,OAAO,KAAK,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAC7B,OAAO,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAE3C,eAAO,MAAM,QAAQ,GAAI,CAAC,EACzB,QAAQ,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,EACtB,MAAM,OAAO,EACb,UAAU,MAAM,EAChB,OAAO,QAAQ,GAAG,OAAO,GAAG,QAAQ,
|
|
1
|
+
{"version":3,"file":"validation.d.ts","sourceRoot":"","sources":["../../src/runtime/validation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChC,OAAO,KAAK,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAC7B,OAAO,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAE3C,eAAO,MAAM,QAAQ,GAAI,CAAC,EACzB,QAAQ,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,EACtB,MAAM,OAAO,EACb,UAAU,MAAM,EAChB,OAAO,QAAQ,GAAG,OAAO,GAAG,QAAQ,GAAG,OAAO,KAC5C,MAAM,CAAC,MAAM,CAAC,CAAC,EAAE,eAAe,CAahC,CAAC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { Effect, Layer, ManagedRuntime } from "effect";
|
|
2
|
+
import { type PluginRegistry } from "../plugin";
|
|
3
|
+
import { PluginRuntime } from "../runtime";
|
|
4
|
+
import type { PluginRuntimeConfig } from "../runtime/types";
|
|
5
|
+
import { type TestPluginMap } from "./mocks/module-federation.service";
|
|
6
|
+
export declare const createTestLogger: () => {
|
|
7
|
+
logInfo: (message: string, context?: unknown) => Effect.Effect<void, never, never>;
|
|
8
|
+
logWarning: (message: string, context?: unknown) => Effect.Effect<void, never, never>;
|
|
9
|
+
logError: (message: string, error?: unknown, context?: unknown) => Effect.Effect<void, never, never>;
|
|
10
|
+
logDebug: (message: string, context?: unknown) => Effect.Effect<void, never, never>;
|
|
11
|
+
};
|
|
12
|
+
/**
|
|
13
|
+
* Creates a test layer with mock ModuleFederationService for unit testing.
|
|
14
|
+
* This layer provides all the necessary services for testing plugin runtime
|
|
15
|
+
* without requiring real module federation infrastructure.
|
|
16
|
+
*/
|
|
17
|
+
export declare const createTestLayer: (config: PluginRuntimeConfig, pluginMap: TestPluginMap) => Layer.Layer<PluginRuntime, never, never>;
|
|
18
|
+
/**
|
|
19
|
+
* Creates a test plugin runtime using mock services.
|
|
20
|
+
* This is similar to createPluginRuntime but uses MockModuleFederationService
|
|
21
|
+
* instead of the real one, making it suitable for unit tests.
|
|
22
|
+
*/
|
|
23
|
+
export declare const createTestPluginRuntime: (config: PluginRuntimeConfig, pluginMap: TestPluginMap) => ManagedRuntime.ManagedRuntime<PluginRuntime, never>;
|
|
24
|
+
export type { PluginRegistry, PluginRuntimeConfig, TestPluginMap };
|
|
25
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/testing/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,cAAc,EAAE,MAAM,QAAQ,CAAC;AACvD,OAAO,EAAmB,KAAK,cAAc,EAAE,MAAM,WAAW,CAAC;AACjE,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAE3C,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AAG5D,OAAO,EAA0C,KAAK,aAAa,EAAE,MAAM,mCAAmC,CAAC;AAG/G,eAAO,MAAM,gBAAgB;uBACR,MAAM,YAAY,OAAO;0BAEtB,MAAM,YAAY,OAAO;wBAE3B,MAAM,UAAU,OAAO,YAAY,OAAO;wBAE1C,MAAM,YAAY,OAAO;CAE7C,CAAC;AAEH;;;;GAIG;AACH,eAAO,MAAM,eAAe,GAAI,QAAQ,mBAAmB,EAAE,WAAW,aAAa,6CAgCpF,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,uBAAuB,GAAI,QAAQ,mBAAmB,EAAE,WAAW,aAAa,wDACpC,CAAC;AAG1D,YAAY,EAAE,cAAc,EAAE,mBAAmB,EAAE,aAAa,EAAE,CAAC"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { Effect, Layer, ManagedRuntime } from "effect";
|
|
2
|
+
import { PluginLoggerTag } from "../plugin";
|
|
3
|
+
import { PluginRuntime } from "../runtime";
|
|
4
|
+
import { PluginService, SecretsService } from "../runtime/services";
|
|
5
|
+
// Import the mock service factory and types
|
|
6
|
+
import { createMockModuleFederationServiceLayer } from "./mocks/module-federation.service";
|
|
7
|
+
// Create test logger
|
|
8
|
+
export const createTestLogger = () => ({
|
|
9
|
+
logInfo: (message, context) => Effect.sync(() => console.log(`[INFO] ${message}`, context || '')),
|
|
10
|
+
logWarning: (message, context) => Effect.sync(() => console.warn(`[WARNING] ${message}`, context || '')),
|
|
11
|
+
logError: (message, error, context) => Effect.sync(() => console.error(`[ERROR] ${message}`, error, context || '')),
|
|
12
|
+
logDebug: (message, context) => Effect.sync(() => console.log(`[DEBUG] ${message}`, context || '')),
|
|
13
|
+
});
|
|
14
|
+
/**
|
|
15
|
+
* Creates a test layer with mock ModuleFederationService for unit testing.
|
|
16
|
+
* This layer provides all the necessary services for testing plugin runtime
|
|
17
|
+
* without requiring real module federation infrastructure.
|
|
18
|
+
*/
|
|
19
|
+
export const createTestLayer = (config, pluginMap) => {
|
|
20
|
+
const secrets = config.secrets || {};
|
|
21
|
+
const logger = config.logger || createTestLogger();
|
|
22
|
+
return Layer.effect(PluginRuntime, Effect.gen(function* () {
|
|
23
|
+
const pluginService = yield* PluginService;
|
|
24
|
+
return {
|
|
25
|
+
loadPlugin: pluginService.loadPlugin,
|
|
26
|
+
instantiatePlugin: pluginService.instantiatePlugin,
|
|
27
|
+
initializePlugin: pluginService.initializePlugin,
|
|
28
|
+
executePlugin: pluginService.executePlugin,
|
|
29
|
+
usePlugin: pluginService.usePlugin,
|
|
30
|
+
streamPlugin: pluginService.streamPlugin,
|
|
31
|
+
shutdown: () => pluginService.cleanup(),
|
|
32
|
+
};
|
|
33
|
+
})).pipe(Layer.provide(PluginService.Live(config.registry, secrets).pipe(Layer.provide(Layer.mergeAll(createMockModuleFederationServiceLayer(pluginMap), SecretsService.Live(secrets), Layer.succeed(PluginLoggerTag, logger))))));
|
|
34
|
+
};
|
|
35
|
+
/**
|
|
36
|
+
* Creates a test plugin runtime using mock services.
|
|
37
|
+
* This is similar to createPluginRuntime but uses MockModuleFederationService
|
|
38
|
+
* instead of the real one, making it suitable for unit tests.
|
|
39
|
+
*/
|
|
40
|
+
export const createTestPluginRuntime = (config, pluginMap) => ManagedRuntime.make(createTestLayer(config, pluginMap));
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { Layer } from "effect";
|
|
2
|
+
import { ModuleFederationService } from "../../runtime/services/module-federation.service";
|
|
3
|
+
import type { AnyPlugin } from "../../runtime/types";
|
|
4
|
+
export interface TestPluginMap {
|
|
5
|
+
[pluginId: string]: new () => AnyPlugin;
|
|
6
|
+
}
|
|
7
|
+
export declare const createMockModuleFederationServiceLayer: (pluginMap: TestPluginMap) => Layer.Layer<ModuleFederationService, never, never>;
|
|
8
|
+
//# sourceMappingURL=module-federation.service.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"module-federation.service.d.ts","sourceRoot":"","sources":["../../../src/testing/mocks/module-federation.service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAU,KAAK,EAAE,MAAM,QAAQ,CAAC;AAGvC,OAAO,EAAE,uBAAuB,EAAE,MAAM,kDAAkD,CAAC;AAC3F,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAErD,MAAM,WAAW,aAAa;IAC5B,CAAC,QAAQ,EAAE,MAAM,GAAG,UAAU,SAAS,CAAC;CACzC;AA6CD,eAAO,MAAM,sCAAsC,GAAI,WAAW,aAAa,uDACT,CAAC"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { Effect, Layer } from "effect";
|
|
2
|
+
import { ModuleFederationError } from "../../runtime/errors";
|
|
3
|
+
import { ModuleFederationService } from "../../runtime/services/module-federation.service";
|
|
4
|
+
// Create the mock service implementation
|
|
5
|
+
const createMockService = (pluginMap) => ({
|
|
6
|
+
registerRemote: (pluginId, url) => Effect.gen(function* () {
|
|
7
|
+
// Mock registration - succeeds if plugin is in the map
|
|
8
|
+
// Use original pluginId as key since TestPluginMap uses original plugin IDs
|
|
9
|
+
if (pluginId in pluginMap) {
|
|
10
|
+
return;
|
|
11
|
+
}
|
|
12
|
+
// Fail for plugins not in the map
|
|
13
|
+
return yield* Effect.fail(new ModuleFederationError({
|
|
14
|
+
pluginId,
|
|
15
|
+
remoteUrl: url,
|
|
16
|
+
cause: new Error(`Mock: Plugin ${pluginId} not available in test plugin map`),
|
|
17
|
+
}));
|
|
18
|
+
}),
|
|
19
|
+
loadRemoteConstructor: (pluginId, url) => Effect.gen(function* () {
|
|
20
|
+
// Return the plugin constructor from the map
|
|
21
|
+
// Use original pluginId as key since TestPluginMap uses original plugin IDs
|
|
22
|
+
const PluginConstructor = pluginMap[pluginId];
|
|
23
|
+
if (PluginConstructor) {
|
|
24
|
+
return PluginConstructor;
|
|
25
|
+
}
|
|
26
|
+
// Fail for plugins not in the map
|
|
27
|
+
return yield* Effect.fail(new ModuleFederationError({
|
|
28
|
+
pluginId,
|
|
29
|
+
remoteUrl: url,
|
|
30
|
+
cause: new Error(`Mock: Constructor for ${pluginId} not found in test plugin map`),
|
|
31
|
+
}));
|
|
32
|
+
}),
|
|
33
|
+
});
|
|
34
|
+
// Create a Layer that provides the mock ModuleFederationService
|
|
35
|
+
export const createMockModuleFederationServiceLayer = (pluginMap) => Layer.succeed(ModuleFederationService, createMockService(pluginMap));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "every-plugin",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.1.1",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"types": "dist/index.d.ts",
|
|
6
6
|
"exports": {
|
|
@@ -11,6 +11,10 @@
|
|
|
11
11
|
"./runtime": {
|
|
12
12
|
"types": "./dist/runtime/index.d.ts",
|
|
13
13
|
"default": "./dist/runtime/index.js"
|
|
14
|
+
},
|
|
15
|
+
"./testing": {
|
|
16
|
+
"types": "./dist/testing/index.d.ts",
|
|
17
|
+
"default": "./dist/testing/index.js"
|
|
14
18
|
}
|
|
15
19
|
},
|
|
16
20
|
"files": [
|
|
@@ -18,25 +22,42 @@
|
|
|
18
22
|
],
|
|
19
23
|
"scripts": {
|
|
20
24
|
"build": "tsc -b",
|
|
21
|
-
"test": "vitest"
|
|
25
|
+
"test": "vitest run --config vitest.unit.config.ts",
|
|
26
|
+
"test:unit": "vitest run --config vitest.unit.config.ts",
|
|
27
|
+
"test:integration": "npm run test:build-plugin && vitest run --config vitest.integration.config.ts",
|
|
28
|
+
"test:all": "npm run test:unit && npm run test:integration",
|
|
29
|
+
"test:watch": "vitest --config vitest.unit.config.ts --watch",
|
|
30
|
+
"test:watch:integration": "vitest --config vitest.integration.config.ts --watch",
|
|
31
|
+
"test:ui": "vitest --ui",
|
|
32
|
+
"test:build-plugin": "cd __tests__/test-plugin && NODE_ENV=test npm run build"
|
|
22
33
|
},
|
|
23
34
|
"peerDependencies": {
|
|
24
35
|
"effect": ">=3.17.0 <4.0.0",
|
|
25
36
|
"zod": ">=4.0.0",
|
|
26
37
|
"@module-federation/enhanced": ">=0.18.0",
|
|
27
|
-
"@module-federation/runtime-core": ">=0.18.0"
|
|
38
|
+
"@module-federation/runtime-core": ">=0.18.0",
|
|
39
|
+
"@orpc/server": ">=0.0.1"
|
|
28
40
|
},
|
|
29
41
|
"devDependencies": {
|
|
42
|
+
"@effect/language-service": "^0.38.1",
|
|
30
43
|
"@effect/vitest": "^0.25.1",
|
|
31
44
|
"@module-federation/enhanced": "^0.18.3",
|
|
45
|
+
"@module-federation/node": "^2.7.15",
|
|
32
46
|
"@module-federation/runtime-core": "^0.18.3",
|
|
33
|
-
"
|
|
47
|
+
"@rspack/cli": "^1.5.2",
|
|
48
|
+
"@rspack/core": "^1.5.2",
|
|
49
|
+
"@types/bun": "^1.2.21",
|
|
50
|
+
"@types/node": "^24.3.1",
|
|
51
|
+
"@vitest/ui": "3.2.4",
|
|
52
|
+
"bun-types": "^1.2.21",
|
|
53
|
+
"effect": "^3.17.13",
|
|
54
|
+
"sirv": "^3.0.2",
|
|
34
55
|
"typescript": "^5.0.0",
|
|
35
56
|
"vitest": "^3.2.4",
|
|
36
|
-
"zod": "^4.
|
|
57
|
+
"zod": "^4.1.5"
|
|
37
58
|
},
|
|
38
59
|
"dependencies": {
|
|
39
60
|
"@better-fetch/fetch": "^1.1.18",
|
|
40
|
-
"
|
|
61
|
+
"@orpc/contract": "^1.8.6"
|
|
41
62
|
}
|
|
42
63
|
}
|
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
import { Effect, Layer, ManagedRuntime } from "effect";
|
|
2
|
-
import { z } from "zod";
|
|
3
|
-
import { PluginRuntimeError } from "./errors";
|
|
4
|
-
import type {
|
|
5
|
-
AnyPlugin,
|
|
6
|
-
InitializedPlugin,
|
|
7
|
-
PluginConstructor,
|
|
8
|
-
PluginInstance,
|
|
9
|
-
PluginRuntimeConfig,
|
|
10
|
-
} from "./types";
|
|
11
|
-
export interface IPluginRuntime {
|
|
12
|
-
readonly loadPlugin: (
|
|
13
|
-
pluginId: string,
|
|
14
|
-
) => Effect.Effect<PluginConstructor, PluginRuntimeError>;
|
|
15
|
-
readonly instantiatePlugin: <T extends AnyPlugin>(
|
|
16
|
-
ctor: PluginConstructor,
|
|
17
|
-
) => Effect.Effect<PluginInstance<T>, PluginRuntimeError>;
|
|
18
|
-
readonly initializePlugin: <T extends AnyPlugin>(
|
|
19
|
-
instance: PluginInstance<T>,
|
|
20
|
-
config: z.infer<T["configSchema"]>,
|
|
21
|
-
) => Effect.Effect<InitializedPlugin<T>, PluginRuntimeError>;
|
|
22
|
-
readonly executePlugin: <T extends AnyPlugin>(
|
|
23
|
-
initializedPlugin: InitializedPlugin<T>,
|
|
24
|
-
input: z.infer<T["inputSchema"]>,
|
|
25
|
-
) => Effect.Effect<z.infer<T["outputSchema"]>, PluginRuntimeError>;
|
|
26
|
-
readonly createPlugin: <T extends AnyPlugin>(
|
|
27
|
-
pluginId: string,
|
|
28
|
-
config: z.infer<T["configSchema"]>,
|
|
29
|
-
) => Effect.Effect<InitializedPlugin<T>, PluginRuntimeError>;
|
|
30
|
-
readonly shutdown: () => Effect.Effect<void, never>;
|
|
31
|
-
}
|
|
32
|
-
declare const PluginRuntime_base: import("effect/Context").TagClass<
|
|
33
|
-
PluginRuntime,
|
|
34
|
-
"PluginRuntime",
|
|
35
|
-
IPluginRuntime
|
|
36
|
-
> &
|
|
37
|
-
Effect.Tag.Proxy<PluginRuntime, IPluginRuntime> & {
|
|
38
|
-
use: <X>(
|
|
39
|
-
body: (_: IPluginRuntime) => X,
|
|
40
|
-
) => [X] extends [Effect.Effect<infer A, infer E, infer R>]
|
|
41
|
-
? Effect.Effect<A, E, R | PluginRuntime>
|
|
42
|
-
: [X] extends [PromiseLike<infer A_1>]
|
|
43
|
-
? Effect.Effect<
|
|
44
|
-
A_1,
|
|
45
|
-
import("effect/Cause").UnknownException,
|
|
46
|
-
PluginRuntime
|
|
47
|
-
>
|
|
48
|
-
: Effect.Effect<X, never, PluginRuntime>;
|
|
49
|
-
};
|
|
50
|
-
export declare class PluginRuntime extends PluginRuntime_base {
|
|
51
|
-
static Live: (
|
|
52
|
-
config: PluginRuntimeConfig,
|
|
53
|
-
) => Layer.Layer<PluginRuntime, never, never>;
|
|
54
|
-
}
|
|
55
|
-
export declare const createManagedPluginRuntime: (
|
|
56
|
-
config: PluginRuntimeConfig,
|
|
57
|
-
) => ManagedRuntime.ManagedRuntime<PluginRuntime, never>;
|
|
58
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C,CAAC,cAAc,CAAC,CAAC,EAAE,kBAAkB,CAAC,CAAC;IACnE,QAAQ,CAAC,YAAY,EAAE,CAAC,CAAC,SAAS,SAAS,EAC1C,QAAQ,EAAE,MAAM,EAChB,MAAM,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,cAAc,CAAC,CAAC,KAC9B,MAAM,CAAC,MAAM,CAAC,iBAAiB,CAAC,CAAC,CAAC,EAAE,kBAAkB,CAAC,CAAC;IAC7D,QAAQ,CAAC,QAAQ,EAAE,MAAM,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;CACpD;;;;AAGD,qBAAa,aAAc,SAAQ,kBAGhC;IACF,MAAM,CAAC,IAAI,GAAI,QAAQ,mBAAmB,8CA4CxC;CACF;AAGD,eAAO,MAAM,0BAA0B,GAAI,QAAQ,mBAAmB,wDACtB,CAAC"}
|
package/dist/runtime/runtime.js
DELETED
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
import { Effect, Layer, ManagedRuntime } from "effect";
|
|
2
|
-
import { PluginLoggerTag } from "../plugin";
|
|
3
|
-
import {
|
|
4
|
-
ModuleFederationService,
|
|
5
|
-
PluginCacheService,
|
|
6
|
-
PluginService,
|
|
7
|
-
SecretsService,
|
|
8
|
-
} from "./services";
|
|
9
|
-
|
|
10
|
-
// Default logger implementation
|
|
11
|
-
const createDefaultLogger = () => ({
|
|
12
|
-
logInfo: (message, context) =>
|
|
13
|
-
Effect.logInfo(message).pipe(
|
|
14
|
-
Effect.annotateLogs({ source: "plugin", context }),
|
|
15
|
-
),
|
|
16
|
-
logWarning: (message, context) =>
|
|
17
|
-
Effect.logWarning(message).pipe(
|
|
18
|
-
Effect.annotateLogs({ source: "plugin", context }),
|
|
19
|
-
),
|
|
20
|
-
logError: (message, error, context) =>
|
|
21
|
-
Effect.logError(message, error).pipe(
|
|
22
|
-
Effect.annotateLogs({ source: "plugin", error, context }),
|
|
23
|
-
),
|
|
24
|
-
logDebug: (message, context) =>
|
|
25
|
-
Effect.logDebug(message).pipe(
|
|
26
|
-
Effect.annotateLogs({ source: "plugin", context }),
|
|
27
|
-
),
|
|
28
|
-
});
|
|
29
|
-
// Main PluginRuntime service using Effect.Tag pattern
|
|
30
|
-
export class PluginRuntime extends Effect.Tag("PluginRuntime")() {
|
|
31
|
-
static Live = (config) => {
|
|
32
|
-
const secrets = config.secrets || {};
|
|
33
|
-
const logger = config.logger || createDefaultLogger();
|
|
34
|
-
return Layer.effect(
|
|
35
|
-
PluginRuntime,
|
|
36
|
-
Effect.gen(function* () {
|
|
37
|
-
const pluginService = yield* PluginService;
|
|
38
|
-
return {
|
|
39
|
-
loadPlugin: pluginService.loadPlugin,
|
|
40
|
-
instantiatePlugin: pluginService.instantiatePlugin,
|
|
41
|
-
initializePlugin: pluginService.initializePlugin,
|
|
42
|
-
executePlugin: pluginService.executePlugin,
|
|
43
|
-
createPlugin: (pluginId, config) =>
|
|
44
|
-
Effect.gen(function* () {
|
|
45
|
-
const ctor = yield* pluginService.loadPlugin(pluginId);
|
|
46
|
-
const instance = yield* pluginService.instantiatePlugin(ctor);
|
|
47
|
-
return yield* pluginService.initializePlugin(instance, config);
|
|
48
|
-
}),
|
|
49
|
-
shutdown: () =>
|
|
50
|
-
Effect.sync(() => {
|
|
51
|
-
// Cleanup handled by Layer disposal
|
|
52
|
-
}),
|
|
53
|
-
};
|
|
54
|
-
}),
|
|
55
|
-
).pipe(
|
|
56
|
-
Layer.provide(
|
|
57
|
-
PluginService.Live(config.registry, secrets).pipe(
|
|
58
|
-
Layer.provide(
|
|
59
|
-
Layer.mergeAll(
|
|
60
|
-
ModuleFederationService.Live,
|
|
61
|
-
PluginCacheService.Live.pipe(
|
|
62
|
-
Layer.provide(ModuleFederationService.Live),
|
|
63
|
-
),
|
|
64
|
-
SecretsService.Live(secrets),
|
|
65
|
-
Layer.succeed(PluginLoggerTag, logger),
|
|
66
|
-
),
|
|
67
|
-
),
|
|
68
|
-
),
|
|
69
|
-
),
|
|
70
|
-
);
|
|
71
|
-
};
|
|
72
|
-
}
|
|
73
|
-
// ManagedRuntime factory function
|
|
74
|
-
export const createManagedPluginRuntime = (config) =>
|
|
75
|
-
ManagedRuntime.make(PluginRuntime.Live(config));
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"runtime.test.d.ts","sourceRoot":"","sources":["../../src/runtime/runtime.test.ts"],"names":[],"mappings":""}
|