every-plugin 0.0.5 → 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.
Files changed (52) hide show
  1. package/README.md +320 -6
  2. package/dist/errors.d.ts +4 -4
  3. package/dist/errors.d.ts.map +1 -1
  4. package/dist/errors.js +10 -10
  5. package/dist/index.d.ts +4 -4
  6. package/dist/index.js +3 -3
  7. package/dist/plugin.d.ts +99 -54
  8. package/dist/plugin.d.ts.map +1 -1
  9. package/dist/plugin.js +18 -16
  10. package/dist/runtime/errors.d.ts +62 -0
  11. package/dist/runtime/errors.d.ts.map +1 -0
  12. package/dist/runtime/errors.js +9 -0
  13. package/dist/runtime/index.d.ts +73 -0
  14. package/dist/runtime/index.d.ts.map +1 -0
  15. package/dist/runtime/index.js +133 -0
  16. package/dist/runtime/mf.test.d.ts +2 -0
  17. package/dist/runtime/mf.test.d.ts.map +1 -0
  18. package/dist/runtime/mf.test.js +135 -0
  19. package/dist/runtime/runtime.test.d.ts +2 -0
  20. package/dist/runtime/runtime.test.d.ts.map +1 -0
  21. package/dist/runtime/runtime.test.js +378 -0
  22. package/dist/runtime/services/module-federation.service.d.ts +44 -0
  23. package/dist/runtime/services/module-federation.service.d.ts.map +1 -0
  24. package/dist/runtime/services/module-federation.service.js +131 -0
  25. package/dist/runtime/services/plugin.service.d.ts +75 -0
  26. package/dist/runtime/services/plugin.service.d.ts.map +1 -0
  27. package/dist/runtime/services/plugin.service.js +338 -0
  28. package/dist/runtime/services/secrets.service.d.ts +37 -0
  29. package/dist/runtime/services/secrets.service.d.ts.map +1 -0
  30. package/dist/runtime/services/secrets.service.js +36 -0
  31. package/dist/runtime/services.d.ts +4 -0
  32. package/dist/runtime/services.d.ts.map +1 -0
  33. package/dist/runtime/services.js +3 -0
  34. package/dist/runtime/streaming.d.ts +29 -0
  35. package/dist/runtime/streaming.d.ts.map +1 -0
  36. package/dist/runtime/streaming.js +59 -0
  37. package/dist/runtime/streaming.test.d.ts +2 -0
  38. package/dist/runtime/streaming.test.d.ts.map +1 -0
  39. package/dist/runtime/streaming.test.js +271 -0
  40. package/dist/runtime/test-utils.d.ts +3 -0
  41. package/dist/runtime/test-utils.d.ts.map +1 -0
  42. package/dist/runtime/test-utils.js +13 -0
  43. package/dist/runtime/types.d.ts +40 -0
  44. package/dist/runtime/types.d.ts.map +1 -0
  45. package/dist/runtime/types.js +1 -0
  46. package/dist/runtime/validation.d.ts +10 -0
  47. package/dist/runtime/validation.d.ts.map +1 -0
  48. package/dist/runtime/validation.js +16 -0
  49. package/dist/source.d.ts +63 -191
  50. package/dist/source.d.ts.map +1 -1
  51. package/dist/source.js +33 -70
  52. package/package.json +44 -22
@@ -0,0 +1,62 @@
1
+ import type { z } from "zod";
2
+ declare const PluginRuntimeError_base: new <A extends Record<string, any> = {}>(
3
+ args: import("effect/Types").Equals<A, {}> extends true
4
+ ? void
5
+ : { readonly [P in keyof A as P extends "_tag" ? never : P]: A[P] },
6
+ ) => import("effect/Cause").YieldableError & {
7
+ readonly _tag: "PluginRuntimeError";
8
+ } & Readonly<A>;
9
+ export declare class PluginRuntimeError extends PluginRuntimeError_base<{
10
+ readonly pluginId?: string;
11
+ readonly operation: string;
12
+ readonly cause?: Error;
13
+ readonly retryable: boolean;
14
+ }> {}
15
+ declare const ModuleFederationError_base: new <
16
+ A extends Record<string, any> = {},
17
+ >(
18
+ args: import("effect/Types").Equals<A, {}> extends true
19
+ ? void
20
+ : { readonly [P in keyof A as P extends "_tag" ? never : P]: A[P] },
21
+ ) => import("effect/Cause").YieldableError & {
22
+ readonly _tag: "ModuleFederationError";
23
+ } & Readonly<A>;
24
+ export declare class ModuleFederationError extends ModuleFederationError_base<{
25
+ readonly pluginId: string;
26
+ readonly remoteUrl: string;
27
+ readonly cause?: Error;
28
+ }> {}
29
+ declare const ValidationError_base: new <A extends Record<string, any> = {}>(
30
+ args: import("effect/Types").Equals<A, {}> extends true
31
+ ? void
32
+ : { readonly [P in keyof A as P extends "_tag" ? never : P]: A[P] },
33
+ ) => import("effect/Cause").YieldableError & {
34
+ readonly _tag: "ValidationError";
35
+ } & Readonly<A>;
36
+ export declare class ValidationError extends ValidationError_base<{
37
+ readonly pluginId: string;
38
+ readonly stage: "config" | "input" | "output" | "state";
39
+ readonly zodError: z.ZodError;
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
+ }> {}
62
+ //# sourceMappingURL=errors.d.ts.map
@@ -0,0 +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;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"}
@@ -0,0 +1,9 @@
1
+ import { Data } from "effect";
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") {}
@@ -0,0 +1,73 @@
1
+ import { Effect, Layer, ManagedRuntime, type Stream } from "effect";
2
+ import type { z } from "zod";
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";
13
+ export interface IPluginRuntime {
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>;
46
+ }
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
+ };
65
+ export declare class PluginRuntime extends PluginRuntime_base {
66
+ static Live: (
67
+ config: PluginRuntimeConfig,
68
+ ) => Layer.Layer<PluginRuntime, never, never>;
69
+ }
70
+ export declare const createPluginRuntime: (
71
+ config: PluginRuntimeConfig,
72
+ ) => ManagedRuntime.ManagedRuntime<PluginRuntime, never>;
73
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/runtime/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,cAAc,EAAE,KAAK,MAAM,EAAE,MAAM,QAAQ,CAAC;AACpE,OAAO,KAAK,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAE7B,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AAC9C,OAAO,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAC;AAM9C,OAAO,EAAsB,KAAK,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAC3E,OAAO,KAAK,EACX,SAAS,EACT,iBAAiB,EACjB,iBAAiB,EACjB,cAAc,EACd,mBAAmB,EACnB,MAAM,SAAS,CAAC;AAwBjB,MAAM,WAAW,cAAc;IAC9B,QAAQ,CAAC,UAAU,EAAE,CACpB,QAAQ,EAAE,MAAM,KACZ,MAAM,CAAC,MAAM,CAAC,iBAAiB,EAAE,kBAAkB,CAAC,CAAC;IAC1D,QAAQ,CAAC,iBAAiB,EAAE,CAAC,CAAC,SAAS,SAAS,EAC/C,IAAI,EAAE,iBAAiB,KACnB,MAAM,CAAC,MAAM,CAAC,cAAc,CAAC,CAAC,CAAC,EAAE,kBAAkB,CAAC,CAAC;IAC1D,QAAQ,CAAC,gBAAgB,EAAE,CAAC,CAAC,SAAS,SAAS,EAC9C,QAAQ,EAAE,cAAc,CAAC,CAAC,CAAC,EAC3B,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,aAAa,EAAE,CAAC,CAAC,SAAS,SAAS,EAC3C,iBAAiB,EAAE,iBAAiB,CAAC,CAAC,CAAC,EACvC,KAAK,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC,KAC5B,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,cAAc,CAAC,CAAC,EAAE,kBAAkB,CAAC,CAAC;IACnE,QAAQ,CAAC,SAAS,EAAE,CAAC,CAAC,SAAS,SAAS,EACvC,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,YAAY,EAAE,CACtB,CAAC,SAAS,YAAY,EACtB,MAAM,SAAS,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC,GAAG,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC,EACpE,KAAK,GAAG,OAAO,EAEf,QAAQ,EAAE,MAAM,EAChB,MAAM,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,cAAc,CAAC,CAAC,EAClC,KAAK,EAAE,MAAM,EACb,OAAO,CAAC,EAAE,mBAAmB,CAAC,KAAK,CAAC,KAChC,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,KAAK,EAAE,kBAAkB,CAAC,EAAE,kBAAkB,CAAC,CAAC;IACjF,QAAQ,CAAC,QAAQ,EAAE,MAAM,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,KAAK,EAAE,KAAK,CAAC,CAAC;CAC3D;;;;AAED,qBAAa,aAAc,SAAQ,kBAGhC;IACF,MAAM,CAAC,IAAI,GAAI,QAAQ,mBAAmB,8CAyGzC;CACD;AAED,eAAO,MAAM,mBAAmB,GAAI,QAAQ,mBAAmB,wDACf,CAAC"}
@@ -0,0 +1,133 @@
1
+ import { Effect, Layer, ManagedRuntime } from "effect";
2
+ import { PluginLoggerTag } from "../plugin";
3
+ import { PluginRuntimeError } from "./errors";
4
+ import {
5
+ ModuleFederationService,
6
+ PluginService,
7
+ SecretsService,
8
+ } from "./services";
9
+ import { createSourceStream } from "./streaming";
10
+ import { validate } from "./validation";
11
+
12
+ // Default logger implementation
13
+ const createDefaultLogger = () => ({
14
+ logInfo: (message, context) =>
15
+ Effect.logInfo(message).pipe(
16
+ Effect.annotateLogs({ source: "plugin", context }),
17
+ ),
18
+ logWarning: (message, context) =>
19
+ Effect.logWarning(message).pipe(
20
+ Effect.annotateLogs({ source: "plugin", context }),
21
+ ),
22
+ logError: (message, error, context) =>
23
+ Effect.logError(message, error).pipe(
24
+ Effect.annotateLogs({ source: "plugin", error, context }),
25
+ ),
26
+ logDebug: (message, context) =>
27
+ Effect.logDebug(message).pipe(
28
+ Effect.annotateLogs({ source: "plugin", context }),
29
+ ),
30
+ });
31
+ export class PluginRuntime extends Effect.Tag("PluginRuntime")() {
32
+ static Live = (config) => {
33
+ const secrets = config.secrets || {};
34
+ const logger = config.logger || createDefaultLogger();
35
+ return Layer.effect(
36
+ PluginRuntime,
37
+ Effect.gen(function* () {
38
+ const pluginService = yield* PluginService;
39
+ return {
40
+ loadPlugin: pluginService.loadPlugin,
41
+ instantiatePlugin: pluginService.instantiatePlugin,
42
+ initializePlugin: pluginService.initializePlugin,
43
+ executePlugin: pluginService.executePlugin,
44
+ usePlugin: (pluginId, config) =>
45
+ pluginService.usePlugin(pluginId, config),
46
+ streamPlugin: (pluginId, config, input, options) =>
47
+ Effect.gen(function* () {
48
+ // Get initialized plugin (benefits from caching)
49
+ const initializedPlugin = yield* pluginService.usePlugin(
50
+ pluginId,
51
+ config,
52
+ );
53
+ // Validate plugin type
54
+ if (initializedPlugin.plugin.type !== "source") {
55
+ return yield* Effect.fail(
56
+ new PluginRuntimeError({
57
+ pluginId,
58
+ operation: "stream-plugin-validate",
59
+ cause: new Error(
60
+ `Plugin ${pluginId} is not a source plugin (type: ${initializedPlugin.plugin.type})`,
61
+ ),
62
+ retryable: false,
63
+ }),
64
+ );
65
+ }
66
+ // Check if procedure is streamable and validate state
67
+ const procedureName = input.procedure;
68
+ const isStreamable =
69
+ initializedPlugin.plugin.isStreamable(procedureName);
70
+ if (isStreamable) {
71
+ // Check stateSchema exists
72
+ if (
73
+ !("stateSchema" in initializedPlugin.plugin) ||
74
+ !initializedPlugin.plugin.stateSchema
75
+ ) {
76
+ return yield* Effect.fail(
77
+ new PluginRuntimeError({
78
+ pluginId: initializedPlugin.plugin.id,
79
+ operation: "validate-state",
80
+ cause: new Error(
81
+ `Streamable plugin ${initializedPlugin.plugin.id} must have a stateSchema`,
82
+ ),
83
+ retryable: false,
84
+ }),
85
+ );
86
+ }
87
+ // Validate initial state
88
+ yield* validate(
89
+ initializedPlugin.plugin.stateSchema,
90
+ input.state,
91
+ initializedPlugin.plugin.id,
92
+ "state",
93
+ ).pipe(
94
+ Effect.mapError(
95
+ (validationError) =>
96
+ new PluginRuntimeError({
97
+ pluginId: initializedPlugin.plugin.id,
98
+ operation: "validate-state",
99
+ cause: validationError.zodError,
100
+ retryable: false,
101
+ }),
102
+ ),
103
+ );
104
+ }
105
+ // Create and return the stream
106
+ return createSourceStream(
107
+ initializedPlugin,
108
+ pluginService.executePlugin,
109
+ input,
110
+ options,
111
+ isStreamable,
112
+ );
113
+ }),
114
+ shutdown: () => pluginService.cleanup(),
115
+ };
116
+ }),
117
+ ).pipe(
118
+ Layer.provide(
119
+ PluginService.Live(config.registry, secrets).pipe(
120
+ Layer.provide(
121
+ Layer.mergeAll(
122
+ ModuleFederationService.Live,
123
+ SecretsService.Live(secrets),
124
+ Layer.succeed(PluginLoggerTag, logger),
125
+ ),
126
+ ),
127
+ ),
128
+ ),
129
+ );
130
+ };
131
+ }
132
+ export const createPluginRuntime = (config) =>
133
+ ManagedRuntime.make(PluginRuntime.Live(config));
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=mf.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mf.test.d.ts","sourceRoot":"","sources":["../../src/runtime/mf.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,135 @@
1
+ import { Effect, Layer } from "effect";
2
+ import { describe, expect, it } from "vitest";
3
+ import { PluginLoggerTag } from "../plugin";
4
+ import { ModuleFederationService } from "./services/module-federation.service";
5
+ import { createTestLogger } from "./test-utils";
6
+
7
+ // Test registry for diagnostics
8
+ const TEST_PLUGIN_ID = "test-plugin";
9
+ const TEST_REMOTE_URL = "http://localhost:3000/remoteEntry.js";
10
+ const testLayer = Layer.succeed(PluginLoggerTag, createTestLogger());
11
+ describe("Module Federation Diagnostics", () => {
12
+ it("should verify remote URL is accessible (sanity check)", async () => {
13
+ console.log("=== Testing Remote URL Accessibility ===");
14
+ try {
15
+ const response = await fetch(TEST_REMOTE_URL, { method: "HEAD" });
16
+ console.log(`Remote URL status: ${response.status}`);
17
+ console.log(
18
+ `Remote URL headers:`,
19
+ Object.fromEntries(response.headers.entries()),
20
+ );
21
+ expect(response.ok).toBe(true);
22
+ } catch (error) {
23
+ console.error("Failed to access remote URL:", error);
24
+ throw error;
25
+ }
26
+ });
27
+ it("should test name transformation logic", async () => {
28
+ console.log("=== Testing Name Transformation ===");
29
+ // Test the same logic used in module-federation.service.ts
30
+ const remoteName = TEST_PLUGIN_ID.toLowerCase()
31
+ .replace("@", "")
32
+ .replace("/", "_");
33
+ const modulePath = `${remoteName}/plugin`;
34
+ console.log(`Original plugin ID: ${TEST_PLUGIN_ID}`);
35
+ console.log(`Transformed remote name: ${remoteName}`);
36
+ console.log(`Module path: ${modulePath}`);
37
+ expect(remoteName).toBe("test-plugin");
38
+ expect(modulePath).toBe("test-plugin/plugin");
39
+ });
40
+ it("should register remote successfully", async () => {
41
+ console.log("=== Testing Remote Registration ===");
42
+ const result = await Effect.runPromise(
43
+ Effect.gen(function* () {
44
+ const mfService = yield* ModuleFederationService;
45
+ console.log("Attempting to register remote...");
46
+ yield* mfService.registerRemote(TEST_PLUGIN_ID, TEST_REMOTE_URL);
47
+ console.log("Remote registration completed successfully");
48
+ return "success";
49
+ }).pipe(
50
+ Effect.provide(ModuleFederationService.Live),
51
+ Effect.provide(testLayer),
52
+ Effect.catchAll((error) => {
53
+ console.error("Remote registration failed:", error);
54
+ return Effect.succeed(`failed: ${error}`);
55
+ }),
56
+ ),
57
+ );
58
+ console.log(`Registration result: ${result}`);
59
+ expect(result).toBe("success");
60
+ });
61
+ it.skip("should inspect module federation instance", async () => {
62
+ console.log("=== Inspecting Module Federation Instance ===");
63
+ const result = await Effect.runPromise(
64
+ Effect.gen(function* () {
65
+ const mfService = yield* ModuleFederationService;
66
+ // First register the remote
67
+ yield* mfService.registerRemote(TEST_PLUGIN_ID, TEST_REMOTE_URL);
68
+ // Access the internal MF instance to inspect it
69
+ // Note: This is a bit hacky but needed for diagnostics
70
+ const mfInstance = mfService.mf || globalThis.__FEDERATION__;
71
+ console.log("Module Federation instance:", typeof mfInstance);
72
+ console.log(
73
+ "Available methods:",
74
+ Object.getOwnPropertyNames(mfInstance || {}),
75
+ );
76
+ if (mfInstance && mfInstance.options) {
77
+ console.log("MF options:", mfInstance.options);
78
+ }
79
+ return "inspected";
80
+ }).pipe(
81
+ Effect.provide(ModuleFederationService.Live),
82
+ Effect.provide(testLayer),
83
+ Effect.catchAll((error) => {
84
+ console.error("MF instance inspection failed:", error);
85
+ return Effect.succeed(`failed: ${error}`);
86
+ }),
87
+ ),
88
+ );
89
+ expect(result).toBe("inspected");
90
+ });
91
+ it.skip("should attempt to load remote container with detailed logging", async () => {
92
+ console.log("=== Testing Remote Container Loading ===");
93
+ const result = await Effect.runPromise(
94
+ Effect.gen(function* () {
95
+ const mfService = yield* ModuleFederationService;
96
+ // Register remote first
97
+ console.log("Step 1: Registering remote...");
98
+ yield* mfService.registerRemote(TEST_PLUGIN_ID, TEST_REMOTE_URL);
99
+ console.log("Step 1: ✓ Remote registered");
100
+ // Now try to load the constructor
101
+ console.log("Step 2: Loading remote constructor...");
102
+ const ctor = yield* mfService.loadRemoteConstructor(
103
+ TEST_PLUGIN_ID,
104
+ TEST_REMOTE_URL,
105
+ );
106
+ console.log("Step 2: ✓ Constructor loaded:", typeof ctor);
107
+ // Try to instantiate it
108
+ console.log("Step 3: Attempting to instantiate constructor...");
109
+ const instance = new ctor();
110
+ console.log("Step 3: ✓ Instance created:", typeof instance);
111
+ console.log(
112
+ "Instance properties:",
113
+ Object.getOwnPropertyNames(instance),
114
+ );
115
+ console.log("Instance id:", instance.id);
116
+ return "success";
117
+ }).pipe(
118
+ Effect.provide(ModuleFederationService.Live),
119
+ Effect.provide(testLayer),
120
+ Effect.catchAll((error) => {
121
+ console.error("Container loading failed at some step:", error);
122
+ console.error("Error details:", {
123
+ message: error.message,
124
+ cause: error.cause,
125
+ stack: error.stack,
126
+ });
127
+ return Effect.succeed(`failed: ${error.message}`);
128
+ }),
129
+ ),
130
+ );
131
+ console.log(`Final result: ${result}`);
132
+ // Don't fail the test - we want to see what happens
133
+ expect(typeof result).toBe("string");
134
+ });
135
+ });
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=runtime.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"runtime.test.d.ts","sourceRoot":"","sources":["../../src/runtime/runtime.test.ts"],"names":[],"mappings":""}