every-plugin 0.4.16 → 0.5.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/dist/build/rspack/index.cjs +1 -1
- package/dist/build/rspack/index.mjs +1 -1
- package/dist/{index-Coz54d1B.d.mts → index-Bu2wtZrA.d.mts} +111 -35
- package/dist/index-Bu2wtZrA.d.mts.map +1 -0
- package/dist/{index-G63gBZIY.d.cts → index-DtTqwV4f.d.cts} +111 -35
- package/dist/index-DtTqwV4f.d.cts.map +1 -0
- package/dist/index.cjs +2 -2
- package/dist/index.d.cts +1 -1
- package/dist/index.d.mts +1 -1
- package/dist/index.mjs +2 -2
- package/dist/{package-ClznSERE.mjs → package-CaRYwbRi.mjs} +2 -2
- package/dist/package-CaRYwbRi.mjs.map +1 -0
- package/dist/{package-DqhszuHi.cjs → package-DyTuSutr.cjs} +2 -2
- package/dist/package-DyTuSutr.cjs.map +1 -0
- package/dist/runtime/index.cjs +2 -2
- package/dist/runtime/index.d.cts +1 -1
- package/dist/runtime/index.d.mts +1 -1
- package/dist/runtime/index.mjs +2 -2
- package/dist/{runtime-BNKZYYMG.cjs → runtime-BNcFgWDG.cjs} +91 -74
- package/dist/runtime-BNcFgWDG.cjs.map +1 -0
- package/dist/{runtime-Da94Fyvr.mjs → runtime-CAWcnrAk.mjs} +92 -21
- package/dist/runtime-CAWcnrAk.mjs.map +1 -0
- package/dist/testing/index.cjs +34 -54
- package/dist/testing/index.cjs.map +1 -1
- package/dist/testing/index.d.cts +25 -30
- package/dist/testing/index.d.cts.map +1 -1
- package/dist/testing/index.d.mts +25 -30
- package/dist/testing/index.d.mts.map +1 -1
- package/dist/testing/index.mjs +35 -53
- package/dist/testing/index.mjs.map +1 -1
- package/package.json +1 -1
- package/dist/index-Coz54d1B.d.mts.map +0 -1
- package/dist/index-G63gBZIY.d.cts.map +0 -1
- package/dist/package-ClznSERE.mjs.map +0 -1
- package/dist/package-DqhszuHi.cjs.map +0 -1
- package/dist/runtime-BNKZYYMG.cjs.map +0 -1
- package/dist/runtime-Da94Fyvr.mjs.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"runtime-CAWcnrAk.mjs","names":["pkg","entryUrl: string","hydrated: Record<string, unknown>","hydrated","runtime: ManagedRuntime.ManagedRuntime<PluginService, never>","registry: PluginRegistry","pluginMap: Record<string, AnyPluginConstructor>","normalized: Record<string, PluginRegistryEntry>"],"sources":["../src/runtime/errors.ts","../src/runtime/services/module-federation.service.ts","../src/runtime/services/plugin-lifecycle.service.ts","../src/runtime/validation.ts","../src/runtime/services/secrets.service.ts","../src/runtime/services/plugin-loader.service.ts","../src/runtime/services/plugin.service.ts","../src/runtime/index.ts"],"sourcesContent":["import { ORPCError } from \"@orpc/contract\";\nimport { Data } from \"effect\";\nimport type { z } from \"zod\";\n\nexport class PluginRuntimeError extends Data.TaggedError(\"PluginRuntimeError\")<{\n\treadonly pluginId?: string;\n\treadonly operation?: string;\n\treadonly procedureName?: string;\n\treadonly cause?: Error;\n\treadonly retryable: boolean;\n}> { }\n\nexport class ModuleFederationError extends Data.TaggedError(\n\t\"ModuleFederationError\",\n)<{\n\treadonly pluginId: string;\n\treadonly remoteUrl: string;\n\treadonly cause?: Error;\n}> { }\n\nexport class ValidationError extends Data.TaggedError(\"ValidationError\")<{\n\treadonly pluginId: string;\n\treadonly stage: \"config\" | \"input\" | \"output\" | \"state\";\n\treadonly zodError: z.ZodError;\n}> { }\n\n// Helper to determine if an oRPC error code is retryable\nexport const isRetryableORPCCode = (code: string): boolean => {\n\tswitch (code) {\n\t\tcase 'TOO_MANY_REQUESTS':\n\t\tcase 'SERVICE_UNAVAILABLE':\n\t\tcase 'BAD_GATEWAY':\n\t\tcase 'GATEWAY_TIMEOUT':\n\t\tcase 'TIMEOUT':\n\t\t\treturn true;\n\t\tdefault:\n\t\t\treturn false;\n\t}\n};\n\n// Convert ORPC errors from plugin procedures to PluginRuntimeError\nexport const wrapORPCError = (\n\torpcError: ORPCError<string, unknown>,\n\tpluginId?: string,\n\tprocedureName?: string,\n\toperation?: string\n): PluginRuntimeError => {\n\treturn new PluginRuntimeError({\n\t\tpluginId,\n\t\toperation,\n\t\tprocedureName,\n\t\tretryable: isRetryableORPCCode(orpcError.code),\n\t\tcause: orpcError as Error\n\t});\n};\n\n// Universal error converter for the runtime\nexport const toPluginRuntimeError = (\n\terror: unknown,\n\tpluginId?: string,\n\tprocedureName?: string,\n\toperation?: string,\n\tdefaultRetryable = false\n): PluginRuntimeError => {\n\tif (error instanceof ORPCError) {\n\t\treturn wrapORPCError(error, pluginId, procedureName, operation);\n\t}\n\n\tif (error instanceof PluginRuntimeError) {\n\t\treturn error; // Already converted\n\t}\n\n\treturn new PluginRuntimeError({\n\t\tpluginId,\n\t\toperation,\n\t\tprocedureName,\n\t\tretryable: defaultRetryable,\n\t\tcause: error instanceof Error ? error : new Error(String(error))\n\t});\n};\n","import { betterFetch } from \"@better-fetch/fetch\";\nimport {\n\tcreateInstance,\n\tgetInstance,\n} from \"@module-federation/enhanced/runtime\";\nimport { setGlobalFederationInstance } from \"@module-federation/runtime-core\";\nimport { Effect } from \"effect\";\nimport type { AnyPlugin } from \"../../types\";\nimport { ModuleFederationError } from \"../errors\";\nimport { getNormalizedRemoteName } from \"./normalize\";\n\ntype RemoteModule = \n | (new () => AnyPlugin)\n | { default: new () => AnyPlugin };\n\nimport pkg from \"../../../package.json\";\n\nconst createModuleFederationInstance = Effect.cached(\n\tEffect.sync(() => {\n\t\ttry {\n\t\t\tlet instance = getInstance();\n\n\t\t\tif (!instance) {\n\t\t\t\tinstance = createInstance({\n\t\t\t\t\tname: \"host\",\n\t\t\t\t\tremotes: [],\n\t\t\t\t\tshared: {\n\t\t\t\t\t\t\"every-plugin\": {\n\t\t\t\t\t\t\tversion: pkg.version,\n\t\t\t\t\t\t\tshareConfig: {\n\t\t\t\t\t\t\t\tsingleton: true,\n\t\t\t\t\t\t\t\trequiredVersion: `^${pkg.version}`,\n\t\t\t\t\t\t\t\teager: true,\n\t\t\t\t\t\t\t\tstrictVersion: false, // Allow bidirectional version compatibility\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t},\n\t\t\t\t\t\teffect: {\n\t\t\t\t\t\t\tversion: pkg.dependencies.effect,\n\t\t\t\t\t\t\tshareConfig: {\n\t\t\t\t\t\t\t\tsingleton: true,\n\t\t\t\t\t\t\t\trequiredVersion: \"^3.18.0\", // Allow any 3.18.x patch version\n\t\t\t\t\t\t\t\teager: true,\n\t\t\t\t\t\t\t\tstrictVersion: false, // Allow version flexibility for compatibility\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t},\n\t\t\t\t\t\tzod: {\n\t\t\t\t\t\t\tversion: pkg.dependencies.zod,\n\t\t\t\t\t\t\tshareConfig: {\n\t\t\t\t\t\t\t\tsingleton: true,\n\t\t\t\t\t\t\t\trequiredVersion: \"^4.1.0\", // Allow any 4.1.x patch version\n\t\t\t\t\t\t\t\teager: true,\n\t\t\t\t\t\t\t\tstrictVersion: false, // Allow version flexibility for compatibility\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t},\n\t\t\t\t\t\t\"@orpc/contract\": {\n\t\t\t\t\t\t\tversion: pkg.dependencies[\"@orpc/contract\"],\n\t\t\t\t\t\t\tshareConfig: {\n\t\t\t\t\t\t\t\tsingleton: true,\n\t\t\t\t\t\t\t\trequiredVersion: \"^1.8.0\", // Allow any 1.8.x patch version\n\t\t\t\t\t\t\t\teager: true,\n\t\t\t\t\t\t\t\tstrictVersion: false, // Allow version flexibility for compatibility\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t},\n\t\t\t\t\t\t\"@orpc/server\": {\n\t\t\t\t\t\t\tversion: pkg.dependencies[\"@orpc/server\"],\n\t\t\t\t\t\t\tshareConfig: {\n\t\t\t\t\t\t\t\tsingleton: true,\n\t\t\t\t\t\t\t\trequiredVersion: \"^1.8.0\", // Allow any 1.8.x patch version\n\t\t\t\t\t\t\t\teager: true,\n\t\t\t\t\t\t\t\tstrictVersion: false, // Allow version flexibility for compatibility\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t}\n\t\t\t\t\t},\n\t\t\t\t});\n\n\t\t\t\tsetGlobalFederationInstance(instance);\n\t\t\t}\n\n\t\t\treturn instance;\n\t\t} catch (error) {\n\t\t\tthrow new Error(`Failed to initialize Module Federation: ${error}`);\n\t\t}\n\t}),\n);\n\nexport class ModuleFederationService extends Effect.Service<ModuleFederationService>()(\"ModuleFederationService\", {\n\teffect: Effect.gen(function* () {\n\t\tconst mf = yield* Effect.flatten(createModuleFederationInstance);\n\n\t\treturn {\n\t\t\tregisterRemote: (pluginId: string, url: string) =>\n\t\t\t\tEffect.gen(function* () {\n\t\t\t\t\tconsole.log(`[MF] Registering ${pluginId}`);\n\n\t\t\t\t\tconst manifestUrl = url.endsWith('/')\n\t\t\t\t\t\t? `${url}mf-manifest.json`\n\t\t\t\t\t\t: `${url}/mf-manifest.json`;\n\n\t\t\t\t\t// Check if manifest is available (MF 2.0 with manifests)\n\t\t\t\t\tconst { error: manifestError } = yield* Effect.tryPromise({\n\t\t\t\t\t\ttry: () => betterFetch(manifestUrl, { method: \"HEAD\" }),\n\t\t\t\t\t\tcatch: (error) => error, // Don't fail yet, try fallback\n\t\t\t\t\t});\n\n\t\t\t\t\tlet entryUrl: string;\n\t\t\t\t\tlet isManifestMode = false;\n\n\t\t\t\t\tif (!manifestError) {\n\t\t\t\t\t\t// MF 2.0 manifest mode - use manifest URL\n\t\t\t\t\t\tentryUrl = manifestUrl;\n\t\t\t\t\t\tisManifestMode = true;\n\t\t\t\t\t\tconsole.log(`[MF] Using MF 2.0 manifest mode for ${pluginId}`);\n\t\t\t\t\t} else {\n\t\t\t\t\t\t// Fallback to MF 1.5 direct mode - assume URL points to remoteEntry.js\n\t\t\t\t\t\tconsole.log(`[MF] ⚠️ Manifest not found, falling back to MF 1.5 mode for ${pluginId}`);\n\t\t\t\t\t\tentryUrl = url;\n\t\t\t\t\t\tisManifestMode = false;\n\t\t\t\t\t}\n\n\t\t\t\t\t// For MF 2.0, the name can be the pluginId (alias)\n\t\t\t\t\t// The manifest will contain the actual container name\n\t\t\t\t\tconst remoteName = isManifestMode ? pluginId : getNormalizedRemoteName(pluginId);\n\n\t\t\t\t\tyield* Effect.try({\n\t\t\t\t\t\ttry: () => mf.registerRemotes([{\n\t\t\t\t\t\t\tname: remoteName,\n\t\t\t\t\t\t\tentry: entryUrl,\n\t\t\t\t\t\t\t...(isManifestMode && { alias: pluginId }) // Explicit alias for clarity\n\t\t\t\t\t\t}]),\n\t\t\t\t\t\tcatch: (error): ModuleFederationError =>\n\t\t\t\t\t\t\tnew ModuleFederationError({\n\t\t\t\t\t\t\t\tpluginId,\n\t\t\t\t\t\t\t\tremoteUrl: url,\n\t\t\t\t\t\t\t\tcause:\n\t\t\t\t\t\t\t\t\terror instanceof Error ? error : new Error(String(error)),\n\t\t\t\t\t\t\t}),\n\t\t\t\t\t});\n\n\t\t\t\t\tconsole.log(`[MF] ✅ Registered ${pluginId} (${isManifestMode ? 'MF 2.0' : 'MF 1.5'})`);\n\t\t\t\t}),\n\n\t\t\tloadRemoteConstructor: (pluginId: string, url: string) =>\n\t\t\t\tEffect.gen(function* () {\n\t\t\t\t\tconst remoteName = getNormalizedRemoteName(pluginId);\n\t\t\t\t\tconsole.log(`[MF] Loading remote ${remoteName}`);\n\t\t\t\t\tconst modulePath = `${remoteName}/plugin`;\n\n\t\t\t\t\treturn yield* Effect.tryPromise({\n\t\t\t\t\t\ttry: async () => {\n\n\t\t\t\t\t\t\tconst container = await mf.loadRemote<RemoteModule>(modulePath);\n\t\t\t\t\t\t\tif (!container) {\n\t\t\t\t\t\t\t\tthrow new Error(`No container returned for ${modulePath}`);\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t// Support multiple export patterns: direct function, default export, named exports\n\t\t\t\t\t\t\tconst Constructor =\n\t\t\t\t\t\t\t\ttypeof container === \"function\"\n\t\t\t\t\t\t\t\t\t? container // Direct function export\n\t\t\t\t\t\t\t\t\t: container.default\n\t\t\t\t\t\t\t\t\t? container.default // Default export\n\t\t\t\t\t\t\t\t\t: Object.values(container).find( // Named export fallback\n\t\t\t\t\t\t\t\t\t\t\t(exp) => typeof exp === \"function\" && exp.prototype?.constructor === exp\n\t\t\t\t\t\t\t\t\t\t);\n\n\t\t\t\t\t\t\tif (!Constructor || typeof Constructor !== \"function\") {\n\t\t\t\t\t\t\t\tconst containerInfo = typeof container === \"object\"\n\t\t\t\t\t\t\t\t\t? `Available exports: ${Object.keys(container).join(', ')}`\n\t\t\t\t\t\t\t\t\t: `Container type: ${typeof container}`;\n\n\t\t\t\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\t\t\t\t`No valid plugin constructor found for '${pluginId}'.\\n` +\n\t\t\t\t\t\t\t\t\t`Supported patterns:\\n` +\n\t\t\t\t\t\t\t\t\t` - export const YourPlugin = createPlugin({...})\\n` +\n\t\t\t\t\t\t\t\t\t` - export default createPlugin({...})\\n` +\n\t\t\t\t\t\t\t\t\t`${containerInfo}`,\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t// Validate it looks like a plugin constructor (has binding property)\n\t\t\t\t\t\t\tif (!(Constructor as any).binding) {\n\t\t\t\t\t\t\t\tconst containerInfo = typeof container === \"object\"\n\t\t\t\t\t\t\t\t\t? `Found exports: ${Object.keys(container).join(', ')}`\n\t\t\t\t\t\t\t\t\t: `Container type: ${typeof container}`;\n\n\t\t\t\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\t\t\t\t`Invalid plugin constructor for '${pluginId}'. ` +\n\t\t\t\t\t\t\t\t\t`The exported value must be created with createPlugin(). ` +\n\t\t\t\t\t\t\t\t\t`Found a function but it's missing the required 'binding' property.\\n` +\n\t\t\t\t\t\t\t\t\t`${containerInfo}`,\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\tconsole.log(`[MF] ✅ Loaded constructor for ${pluginId}`);\n\t\t\t\t\t\t\treturn Constructor;\n\t\t\t\t\t\t},\n\t\t\t\t\t\tcatch: (error): ModuleFederationError =>\n\t\t\t\t\t\t\tnew ModuleFederationError({\n\t\t\t\t\t\t\t\tpluginId,\n\t\t\t\t\t\t\t\tremoteUrl: url,\n\t\t\t\t\t\t\t\tcause:\n\t\t\t\t\t\t\t\t\terror instanceof Error ? error : new Error(String(error)),\n\t\t\t\t\t\t\t}),\n\t\t\t\t\t});\n\t\t\t\t}),\n\t\t};\n\t}),\n}) {}\n","import { Effect, Ref } from \"effect\";\nimport type { AnyPlugin, InitializedPlugin } from \"../../types\";\nimport { toPluginRuntimeError } from \"../errors\";\n\nexport class PluginLifecycleService extends Effect.Service<PluginLifecycleService>()(\"PluginLifecycleService\", {\n effect: Effect.gen(function* () {\n const activePlugins = yield* Ref.make(new Set<InitializedPlugin<AnyPlugin>>());\n\n return {\n register: <T extends AnyPlugin>(plugin: InitializedPlugin<T>) =>\n Ref.update(activePlugins, plugins =>\n new Set(plugins).add(plugin as InitializedPlugin<AnyPlugin>)\n ),\n\n unregister: (plugin: InitializedPlugin<AnyPlugin>) =>\n Ref.update(activePlugins, plugins => {\n const newSet = new Set(plugins);\n newSet.delete(plugin);\n return newSet;\n }),\n\n shutdown: (plugin: InitializedPlugin<AnyPlugin>) =>\n Effect.gen(function* () {\n // Remove from active plugins\n yield* Ref.update(activePlugins, plugins => {\n const newSet = new Set(plugins);\n newSet.delete(plugin);\n return newSet;\n });\n\n // Shutdown the plugin\n yield* plugin.plugin.shutdown().pipe(\n Effect.mapError(error =>\n toPluginRuntimeError(error, plugin.plugin.id, undefined, \"shutdown-plugin\", false)\n )\n );\n }),\n\n cleanup: () =>\n Effect.gen(function* () {\n const plugins = yield* Ref.get(activePlugins);\n\n // Shutdown all active plugins concurrently\n yield* Effect.forEach(\n plugins,\n plugin =>\n plugin.plugin.shutdown().pipe(\n Effect.mapError(error =>\n toPluginRuntimeError(error, plugin.plugin.id, undefined, \"cleanup-shutdown\", false)\n ),\n Effect.catchAll(error =>\n Effect.logError(\n `Failed to shutdown plugin ${plugin.plugin.id} during cleanup`,\n error,\n { pluginId: plugin.plugin.id }\n )\n )\n ),\n { concurrency: \"unbounded\" }\n );\n\n // Clear the active plugins set\n yield* Ref.set(activePlugins, new Set());\n }).pipe(\n Effect.catchAll(() => Effect.void) // Convert errors to void for cleanup\n ),\n };\n }),\n}) { }\n","import { Effect } from \"effect\";\nimport type { z } from \"zod\";\nimport { ValidationError } from \"./errors\";\n\nexport const validate = <T>(\n\tschema: z.ZodSchema<T>,\n\tdata: unknown,\n\tpluginId: string,\n\tstage: \"config\" | \"input\" | \"output\" | \"state\",\n): Effect.Effect<T, ValidationError> =>\n\tEffect.gen(function* () {\n\t\tconst result = schema.safeParse(data);\n\t\tif (result.success) {\n\t\t\treturn result.data;\n\t\t}\n\t\treturn yield* Effect.fail(\n\t\t\tnew ValidationError({\n\t\t\t\tpluginId,\n\t\t\t\tstage,\n\t\t\t\tzodError: result.error,\n\t\t\t}),\n\t\t);\n\t});\n","import { Context, Effect } from \"effect\";\nimport { z } from \"zod\";\nimport type { SecretsConfig } from \"../../types\";\nimport { PluginRuntimeError } from \"../errors\";\n\nconst configSchema = z.object({\n\tsecrets: z.record(z.string(), z.unknown())\n}).loose();\n\nexport class SecretsConfigTag extends Context.Tag(\"SecretsConfig\")<\n\tSecretsConfigTag,\n\tSecretsConfig\n>() { }\n\nexport class SecretsService extends Effect.Service<SecretsService>()(\"SecretsService\", {\n\teffect: Effect.gen(function* () {\n\t\tconst secrets = yield* SecretsConfigTag;\n\n\t\tconst hydrateValue = (value: unknown): unknown => {\n\t\t\tif (typeof value === 'string') {\n\t\t\t\tlet result = value;\n\t\t\t\tfor (const [key, secretValue] of Object.entries(secrets)) {\n\t\t\t\t\tconst pattern = new RegExp(`{{${key}}}`, \"g\");\n\t\t\t\t\tresult = result.replace(pattern, String(secretValue));\n\t\t\t\t}\n\t\t\t\treturn result;\n\t\t\t}\n\n\t\t\tif (Array.isArray(value)) {\n\t\t\t\treturn value.map(hydrateValue);\n\t\t\t}\n\n\t\t\tif (value && typeof value === 'object') {\n\t\t\t\tconst isPlainObject = value.constructor === Object || value.constructor === undefined;\n\t\t\t\t\n\t\t\t\tif (isPlainObject) {\n\t\t\t\t\tconst hydrated: Record<string, unknown> = {};\n\t\t\t\t\tfor (const [key, val] of Object.entries(value)) {\n\t\t\t\t\t\thydrated[key] = hydrateValue(val);\n\t\t\t\t\t}\n\t\t\t\t\treturn hydrated;\n\t\t\t\t}\n\n\t\t\t\tconst hydrated = Object.create(Object.getPrototypeOf(value));\n\t\t\t\tfor (const [key, val] of Object.entries(value)) {\n\t\t\t\t\thydrated[key] = hydrateValue(val);\n\t\t\t\t}\n\t\t\t\treturn hydrated;\n\t\t\t}\n\n\t\t\treturn value;\n\t\t};\n\n\t\treturn {\n\t\t\thydrateSecrets: <T>(config: T) =>\n\t\t\t\tEffect.gen(function* () {\n\t\t\t\t\tconst parseResult = configSchema.parse(config);\n\t\t\t\t\ttry {\n\t\t\t\t\t\treturn hydrateValue(parseResult) as T;\n\t\t\t\t\t} catch (error) {\n\t\t\t\t\t\treturn yield* Effect.fail(\n\t\t\t\t\t\t\tnew PluginRuntimeError({\n\t\t\t\t\t\t\t\toperation: \"hydrate-secrets\",\n\t\t\t\t\t\t\t\tcause:\n\t\t\t\t\t\t\t\t\terror instanceof Error ? error : new Error(String(error)),\n\t\t\t\t\t\t\t\tretryable: false,\n\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t}),\n\t\t};\n\t}),\n}) { }\n","import type { InferSchemaInput, InferSchemaOutput } from \"@orpc/contract\";\nimport { Context, Effect, Scope } from \"effect\";\nimport type { z } from \"zod\";\nimport type {\n\tAnyPlugin,\n\tAnyPluginConstructor,\n\tInitializedPlugin,\n\tLoadedPlugin,\n\tPluginInstance,\n\tPluginMetadata,\n\tPluginRegistry\n} from \"../../types\";\nimport { PluginRuntimeError, toPluginRuntimeError } from \"../errors\";\nimport { validate } from \"../validation\";\nimport { ModuleFederationService } from \"./module-federation.service\";\nimport { SecretsService } from \"./secrets.service\";\n\nexport class PluginRegistryTag extends Context.Tag(\"PluginRegistry\")<\n\tPluginRegistryTag,\n\tPluginRegistry\n>() { }\n\nexport class PluginMapTag extends Context.Tag(\"PluginMap\")<\n\tPluginMapTag,\n\tRecord<string, AnyPluginConstructor>\n>() { }\n\nexport class RegistryService extends Effect.Service<RegistryService>()(\"RegistryService\", {\n\teffect: Effect.gen(function* () {\n\t\tconst registry = yield* PluginRegistryTag;\n\t\tconst pluginMap = yield* PluginMapTag;\n\n\t\treturn {\n\t\t\tget: (pluginId: string) =>\n\t\t\t\tEffect.gen(function* () {\n\t\t\t\t\tconst entry = registry[pluginId];\n\t\t\t\t\t\n\t\t\t\t\tif (!entry) {\n\t\t\t\t\t\treturn yield* Effect.fail(\n\t\t\t\t\t\t\tnew PluginRuntimeError({\n\t\t\t\t\t\t\t\tpluginId,\n\t\t\t\t\t\t\t\toperation: \"validate-plugin-id\",\n\t\t\t\t\t\t\t\tcause: new Error(`Plugin ${pluginId} not found in registry`),\n\t\t\t\t\t\t\t\tretryable: false,\n\t\t\t\t\t\t\t})\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\n\t\t\t\t\tif (\"module\" in entry) {\n\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\tconstructor: entry.module,\n\t\t\t\t\t\t\tmetadata: {\n\t\t\t\t\t\t\t\tremoteUrl: entry.remote || \"\",\n\t\t\t\t\t\t\t\tversion: entry.version,\n\t\t\t\t\t\t\t\tdescription: entry.description,\n\t\t\t\t\t\t\t} as PluginMetadata,\n\t\t\t\t\t\t};\n\t\t\t\t\t}\n\n\t\t\t\t\treturn {\n\t\t\t\t\t\tconstructor: null,\n\t\t\t\t\t\tmetadata: {\n\t\t\t\t\t\t\tremoteUrl: entry.remote,\n\t\t\t\t\t\t\tversion: entry.version,\n\t\t\t\t\t\t\tdescription: entry.description,\n\t\t\t\t\t\t} as PluginMetadata,\n\t\t\t\t\t};\n\t\t\t\t}),\n\n\t\t\tgetModule: (pluginId: string) =>\n\t\t\t\tEffect.succeed(pluginMap[pluginId] || null),\n\t\t};\n\t}),\n}) { }\n\nexport class PluginLoaderService extends Effect.Service<PluginLoaderService>()(\"PluginLoaderService\", {\n\teffect: Effect.gen(function* () {\n\t\tconst moduleFederationService = yield* ModuleFederationService;\n\t\tconst secretsService = yield* SecretsService;\n\t\tconst registryService = yield* RegistryService;\n\n\t\tconst resolveUrl = (baseUrl: string, version?: string): string =>\n\t\t\tversion && version !== \"latest\"\n\t\t\t\t? baseUrl.replace(\"@latest\", `@${version}`)\n\t\t\t\t: baseUrl;\n\n\t\treturn {\n\t\t\tloadPlugin: (pluginId: string) =>\n\t\t\t\tEffect.gen(function* () {\n\t\t\t\t\tconst entry = yield* registryService.get(pluginId);\n\n\t\t\t\t\tif (entry.constructor) {\n\t\t\t\t\t\tyield* Effect.logDebug(\"Loading plugin from direct module\", { pluginId });\n\t\t\t\t\t\t\n\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\tctor: entry.constructor,\n\t\t\t\t\t\t\tmetadata: entry.metadata,\n\t\t\t\t\t\t} satisfies LoadedPlugin;\n\t\t\t\t\t}\n\n\t\t\t\t\tconst url = resolveUrl(entry.metadata.remoteUrl);\n\n\t\t\t\t\tyield* moduleFederationService.registerRemote(pluginId, url).pipe(\n\t\t\t\t\t\tEffect.mapError((error) =>\n\t\t\t\t\t\t\ttoPluginRuntimeError(error, pluginId, undefined, \"register-remote\", true),\n\t\t\t\t\t\t),\n\t\t\t\t\t);\n\n\t\t\t\t\tyield* Effect.logDebug(\"Loading plugin from remote\", { pluginId, url });\n\n\t\t\t\t\tconst ctor = yield* moduleFederationService.loadRemoteConstructor(pluginId, url).pipe(\n\t\t\t\t\t\tEffect.mapError((error) =>\n\t\t\t\t\t\t\ttoPluginRuntimeError(error, pluginId, undefined, \"load-remote\", false),\n\t\t\t\t\t\t),\n\t\t\t\t\t);\n\n\t\t\t\t\treturn {\n\t\t\t\t\t\tctor,\n\t\t\t\t\t\tmetadata: entry.metadata,\n\t\t\t\t\t} satisfies LoadedPlugin;\n\t\t\t\t}),\n\n\t\t\tinstantiatePlugin: <T extends AnyPlugin>(\n\t\t\t\tpluginId: string,\n\t\t\t\tloadedPlugin: LoadedPlugin<T>,\n\t\t\t) =>\n\t\t\t\tEffect.gen(function* () {\n\t\t\t\t\tconst instance = yield* Effect.try(() => new loadedPlugin.ctor()).pipe(\n\t\t\t\t\t\tEffect.mapError((error) =>\n\t\t\t\t\t\t\ttoPluginRuntimeError(\n\t\t\t\t\t\t\t\terror,\n\t\t\t\t\t\t\t\tpluginId,\n\t\t\t\t\t\t\t\tundefined,\n\t\t\t\t\t\t\t\t\"instantiate-plugin\",\n\t\t\t\t\t\t\t\tfalse,\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t),\n\t\t\t\t\t);\n\n\t\t\t\t\t(instance.id as string) = pluginId;\n\n\t\t\t\t\treturn {\n\t\t\t\t\t\tplugin: instance,\n\t\t\t\t\t\tmetadata: loadedPlugin.metadata,\n\t\t\t\t\t} satisfies PluginInstance<T>;\n\t\t\t\t}),\n\n\t\t\tinitializePlugin: <T extends AnyPlugin>(\n\t\t\t\tpluginInstance: PluginInstance<T>,\n\t\t\t\tconfig: { variables: InferSchemaInput<T[\"configSchema\"][\"variables\"]>; secrets: InferSchemaInput<T[\"configSchema\"][\"secrets\"]> },\n\t\t\t) =>\n\t\t\t\tEffect.gen(function* () {\n\t\t\t\t\tconst { plugin } = pluginInstance;\n\n\t\t\t\t\t// Validate and hydrate config\n\t\t\t\t\tconst validatedVariables = yield* validate(\n\t\t\t\t\t\tplugin.configSchema.variables as z.ZodSchema<InferSchemaOutput<T[\"configSchema\"][\"variables\"]>>,\n\t\t\t\t\t\tconfig.variables,\n\t\t\t\t\t\tplugin.id,\n\t\t\t\t\t\t\"config\",\n\t\t\t\t\t).pipe(\n\t\t\t\t\t\tEffect.mapError((validationError) =>\n\t\t\t\t\t\t\tnew PluginRuntimeError({\n\t\t\t\t\t\t\t\tpluginId: plugin.id,\n\t\t\t\t\t\t\t\toperation: \"validate-config\",\n\t\t\t\t\t\t\t\tcause: validationError.zodError,\n\t\t\t\t\t\t\t\tretryable: false,\n\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t),\n\t\t\t\t\t);\n\n\t\t\t\t\t// Validate secrets\n\t\t\t\t\tconst validatedSecrets = yield* validate(\n\t\t\t\t\t\tplugin.configSchema.secrets as z.ZodSchema<InferSchemaOutput<T[\"configSchema\"][\"secrets\"]>>,\n\t\t\t\t\t\tconfig.secrets,\n\t\t\t\t\t\tplugin.id,\n\t\t\t\t\t\t\"config\",\n\t\t\t\t\t).pipe(\n\t\t\t\t\t\tEffect.mapError((validationError) =>\n\t\t\t\t\t\t\tnew PluginRuntimeError({\n\t\t\t\t\t\t\t\tpluginId: plugin.id,\n\t\t\t\t\t\t\t\toperation: \"validate-secrets\",\n\t\t\t\t\t\t\t\tcause: validationError.zodError,\n\t\t\t\t\t\t\t\tretryable: false,\n\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t),\n\t\t\t\t\t);\n\n\t\t\t\t\t// Hydrate secrets in variables\n\t\t\t\t\tconst hydratedConfig = yield* secretsService.hydrateSecrets({\n\t\t\t\t\t\tvariables: validatedVariables,\n\t\t\t\t\t\tsecrets: validatedSecrets,\n\t\t\t\t\t});\n\n\t\t\t\t\tconst _variables = yield* validate(\n\t\t\t\t\t\tplugin.configSchema.variables as z.ZodSchema<InferSchemaOutput<T[\"configSchema\"][\"variables\"]>>,\n\t\t\t\t\t\thydratedConfig.variables,\n\t\t\t\t\t\tplugin.id,\n\t\t\t\t\t\t\"config\",\n\t\t\t\t\t).pipe(\n\t\t\t\t\t\tEffect.mapError((validationError) =>\n\t\t\t\t\t\t\tnew PluginRuntimeError({\n\t\t\t\t\t\t\t\tpluginId: plugin.id,\n\t\t\t\t\t\t\t\toperation: \"validate-hydrated-config\",\n\t\t\t\t\t\t\t\tcause: validationError.zodError,\n\t\t\t\t\t\t\t\tretryable: false,\n\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t),\n\t\t\t\t\t);\n\n\t\t\t\t\t// Create a long-lived scope for this plugin instance\n\t\t\t\t\tconst scope = yield* Scope.make();\n\n\t\t\t\t\t// Initialize plugin within the scope\n\t\t\t\t\tconst context = yield* plugin.initialize({ variables: _variables, secrets: hydratedConfig.secrets }).pipe(\n\t\t\t\t\t\tEffect.provideService(Scope.Scope, scope),\n\t\t\t\t\t\tEffect.mapError((error) =>\n\t\t\t\t\t\t\ttoPluginRuntimeError(error, plugin.id, undefined, \"initialize-plugin\", false),\n\t\t\t\t\t\t)\n\t\t\t\t\t);\n\n\t\t\t\t\treturn {\n\t\t\t\t\t\tplugin,\n\t\t\t\t\t\tmetadata: pluginInstance.metadata,\n\t\t\t\t\t\tconfig: { variables: _variables, secrets: hydratedConfig.secrets },\n\t\t\t\t\t\tcontext,\n\t\t\t\t\t\tscope,\n\t\t\t\t\t} satisfies InitializedPlugin<T>;\n\t\t\t\t}),\n\t\t};\n\t}),\n}) {\n}\n","import { Effect, Exit, Layer, Scope } from \"effect\";\nimport type {\n\tAnyPlugin,\n\tAnyPluginConstructor,\n\tInitializedPlugin,\n\tPluginRegistry,\n\tSecretsConfig\n} from \"../../types\";\nimport { ModuleFederationService } from \"./module-federation.service\";\nimport { PluginLifecycleService } from \"./plugin-lifecycle.service\";\nimport { PluginLoaderService, PluginMapTag, PluginRegistryTag, RegistryService } from \"./plugin-loader.service\";\nimport { SecretsConfigTag, SecretsService } from \"./secrets.service\";\n\nexport class PluginService extends Effect.Service<PluginService>()(\"PluginService\", {\n\tscoped: Effect.gen(function* () {\n\t\tconst loader = yield* PluginLoaderService;\n\t\tconst lifecycle = yield* PluginLifecycleService;\n\n\t\treturn {\n\t\t\tloadPlugin: loader.loadPlugin,\n\t\t\tinstantiatePlugin: loader.instantiatePlugin,\n\t\t\tinitializePlugin: loader.initializePlugin,\n\t\t\tshutdownPlugin: (plugin: InitializedPlugin<AnyPlugin>) =>\n\t\t\t\tEffect.gen(function* () {\n\t\t\t\t\t// Shutdown the plugin first (graceful cleanup)\n\t\t\t\t\tyield* plugin.plugin.shutdown().pipe(\n\t\t\t\t\t\tEffect.catchAll(() => Effect.void)\n\t\t\t\t\t);\n\n\t\t\t\t\t// Close the plugin scope to interrupt fibers and release resources\n\t\t\t\t\tyield* Scope.close(plugin.scope, Exit.succeed(undefined));\n\n\t\t\t\t\t// Unregister from lifecycle tracking\n\t\t\t\t\tyield* lifecycle.unregister(plugin);\n\t\t\t\t}),\n\t\t\tcleanup: lifecycle.cleanup,\n\t\t};\n\t}),\n}) {\n\tstatic Live = (registry: PluginRegistry, secrets: SecretsConfig, pluginMap: Record<string, AnyPluginConstructor> = {}) => {\n\t\tconst contextLayer = Layer.mergeAll(\n\t\t\tLayer.succeed(PluginRegistryTag, registry),\n\t\t\tLayer.succeed(SecretsConfigTag, secrets),\n\t\t\tLayer.succeed(PluginMapTag, pluginMap),\n\t\t);\n\n\t\tconst servicesLayer = Layer.mergeAll(\n\t\t\tModuleFederationService.Default,\n\t\t\tSecretsService.Default,\n\t\t\tRegistryService.Default,\n\t\t\tPluginLifecycleService.Default,\n\t\t).pipe(\n\t\t\tLayer.provide(contextLayer)\n\t\t);\n\n\t\treturn PluginService.Default.pipe(\n\t\t\tLayer.provide(PluginLoaderService.Default),\n\t\t\tLayer.provide(servicesLayer)\n\t\t);\n\t}\n}\n","import { createRouterClient } from \"@orpc/server\";\nimport { Cause, Effect, Exit, Hash, ManagedRuntime, Option } from \"effect\";\nimport type {\n\tAnyPlugin,\n\tAnyPluginConstructor,\n\tInferRegistryFromEntries,\n\tInitializedPlugin,\n\tLoadedPlugin,\n\tPluginClientType,\n\tPluginConfigInput,\n\tPluginInstance,\n\tPluginRegistry,\n\tPluginRegistryEntry,\n\tPluginRouterType,\n\tPluginRuntimeConfig,\n\tRegisteredPlugin,\n\tRegisteredPlugins,\n\tUsePluginResult\n} from \"../types\";\nimport { PluginRuntimeError } from \"./errors\";\nimport { PluginService } from \"./services/plugin.service\";\n\nexport class PluginRuntime<R = RegisteredPlugins> {\n\treadonly ['__registryType']?: R;\n\t\n\tprivate pluginCache = new Map<string, Effect.Effect<InitializedPlugin<AnyPlugin>, PluginRuntimeError>>();\n\n\tconstructor(\n\t\tprivate runtime: ManagedRuntime.ManagedRuntime<PluginService, never>,\n\t\tprivate registry: PluginRegistry\n\t) { }\n\n\tprivate generateCacheKey(pluginId: string, config: unknown): string {\n\t\tconst configHash = Hash.structure(config as object).toString();\n\t\treturn `${pluginId}:${configHash}`;\n\t}\n\n\tprivate validatePluginId(\n\t\tpluginId: string\n\t): Effect.Effect<string, PluginRuntimeError> {\n\t\tif (!(pluginId in this.registry)) {\n\t\t\treturn Effect.fail(new PluginRuntimeError({\n\t\t\t\tpluginId: String(pluginId),\n\t\t\t\toperation: \"validate-plugin-id\",\n\t\t\t\tcause: new Error(`Plugin ID '${String(pluginId)}' not found in registry.`),\n\t\t\t\tretryable: false,\n\t\t\t}));\n\t\t}\n\t\treturn Effect.succeed(String(pluginId));\n\t}\n\n\tprivate async runPromise<A, E>(\n\t\teffect: Effect.Effect<A, E, PluginService>\n\t): Promise<A> {\n\t\tconst exit = await this.runtime.runPromiseExit(effect);\n\n\t\tif (Exit.isFailure(exit)) {\n\t\t\tconst error = Cause.failureOption(exit.cause);\n\t\t\tif (Option.isSome(error)) {\n\t\t\t\tthrow error.value;\n\t\t\t}\n\t\t\tthrow Cause.squash(exit.cause);\n\t\t}\n\n\t\treturn exit.value;\n\t}\n\n\tasync usePlugin<K extends keyof R & string>(\n\t\tpluginId: K,\n\t\tconfig: PluginConfigInput<R[K]>\n\t): Promise<UsePluginResult<K, R>> {\n\t\tconst cacheKey = this.generateCacheKey(pluginId, config);\n\n\t\tlet cachedPlugin = this.pluginCache.get(cacheKey);\n\t\tif (!cachedPlugin) {\n\t\t\tconst operation = Effect.gen(this, function* () {\n\t\t\t\tconst pluginService = yield* PluginService;\n\t\t\t\tconst validatedId = yield* this.validatePluginId(pluginId);\n\n\t\t\t\t// Load → Instantiate → Initialize\n\t\t\t\tconst ctor = yield* pluginService.loadPlugin(validatedId);\n\t\t\t\tconst instance = yield* pluginService.instantiatePlugin(pluginId, ctor);\n\t\t\t\tconst initialized = yield* pluginService.initializePlugin(instance, config);\n\n\t\t\t\treturn initialized;\n\t\t\t}).pipe(Effect.provide(this.runtime));\n\n\t\t\tcachedPlugin = Effect.cached(operation).pipe(Effect.flatten);\n\t\t\tthis.pluginCache.set(cacheKey, cachedPlugin);\n\t\t}\n\n\t\tconst initialized = await this.runPromise(cachedPlugin);\n\t\tconst router = initialized.plugin.createRouter(initialized.context);\n\t\tconst client = createRouterClient(router);\n\n\t\treturn {\n\t\t\trouter: router as PluginRouterType<R[K]>,\n\t\t\tclient: client as PluginClientType<R[K]>,\n\t\t\tmetadata: initialized.metadata,\n\t\t\tinitialized: initialized as InitializedPlugin<RegisteredPlugin<K, R>>\n\t\t} as UsePluginResult<K, R>;\n\t}\n\n\tasync loadPlugin<K extends keyof R & string>(\n\t\tpluginId: K\n\t): Promise<LoadedPlugin<RegisteredPlugin<K, R>>> {\n\t\tconst effect = Effect.gen(function* () {\n\t\t\tconst pluginService = yield* PluginService;\n\t\t\treturn yield* pluginService.loadPlugin(pluginId);\n\t\t});\n\t\treturn this.runPromise(effect) as Promise<LoadedPlugin<RegisteredPlugin<K, R>>>;\n\t}\n\n\tasync instantiatePlugin<K extends keyof R & string>(\n\t\tpluginId: K,\n\t\tloadedPlugin: LoadedPlugin<RegisteredPlugin<K, R>>\n\t): Promise<PluginInstance<RegisteredPlugin<K, R>>> {\n\t\tconst effect = Effect.gen(function* () {\n\t\t\tconst pluginService = yield* PluginService;\n\t\t\treturn yield* pluginService.instantiatePlugin(pluginId, loadedPlugin);\n\t\t});\n\t\treturn this.runPromise(effect) as Promise<PluginInstance<RegisteredPlugin<K, R>>>;\n\t}\n\n\tasync initializePlugin<T extends AnyPlugin>(\n\t\tinstance: PluginInstance<T>,\n\t\tconfig: any\n\t): Promise<InitializedPlugin<T>> {\n\t\tconst effect = Effect.gen(function* () {\n\t\t\tconst pluginService = yield* PluginService;\n\t\t\treturn yield* pluginService.initializePlugin(instance, config);\n\t\t});\n\t\treturn this.runPromise(effect);\n\t}\n\n\tasync shutdown(): Promise<void> {\n\t\tconst effect = Effect.gen(function* () {\n\t\t\tconst pluginService = yield* PluginService;\n\t\t\tyield* pluginService.cleanup();\n\t\t});\n\t\treturn this.runPromise(effect);\n\t}\n\n\tasync evictPlugin<K extends keyof R & string>(\n\t\tpluginId: K,\n\t\tconfig: PluginConfigInput<R[K]>\n\t): Promise<void> {\n\t\tconst cacheKey = this.generateCacheKey(pluginId, config);\n\n\t\tconst effect = Effect.gen(this, function* () {\n\t\t\tconst pluginService = yield* PluginService;\n\t\t\tconst cachedPlugin = this.pluginCache.get(cacheKey);\n\n\t\t\tif (cachedPlugin) {\n\t\t\t\tthis.pluginCache.delete(cacheKey);\n\n\t\t\t\tconst pluginResult = yield* cachedPlugin.pipe(\n\t\t\t\t\tEffect.catchAll(() => Effect.succeed(null))\n\t\t\t\t);\n\n\t\t\t\tif (pluginResult) {\n\t\t\t\t\tyield* pluginService.shutdownPlugin(pluginResult).pipe(\n\t\t\t\t\t\tEffect.catchAll(() => Effect.void)\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t}\n\t\t}).pipe(Effect.catchAll(() => Effect.void));\n\n\t\treturn this.runPromise(effect);\n\t}\n}\n\n/**\n * Normalizes a remote URL to ensure it points to remoteEntry.js\n * If the URL doesn't end with a file extension, appends /remoteEntry.js\n */\nfunction normalizeRemoteUrl(url: string): string {\n\tif (!url) return url;\n\tif (url.endsWith('.js')) return url;\n\treturn `${url.endsWith('/') ? url.slice(0, -1) : url}/remoteEntry.js`;\n}\n\n/**\n * Extract plugin map (module constructors) from registry entries\n */\nfunction extractPluginMap(registry: Record<string, PluginRegistryEntry>): Record<string, AnyPluginConstructor> {\n\tconst pluginMap: Record<string, AnyPluginConstructor> = {};\n\t\n\tfor (const [pluginId, entry] of Object.entries(registry)) {\n\t\tif (\"module\" in entry && entry.module) {\n\t\t\tpluginMap[pluginId] = entry.module;\n\t\t}\n\t}\n\t\n\treturn pluginMap;\n}\n\n/**\n * Normalize registry entries - ensure remote URLs are properly formatted\n */\nfunction normalizeRegistry(registry: Record<string, PluginRegistryEntry>): PluginRegistry {\n\tconst normalized: Record<string, PluginRegistryEntry> = {};\n\t\n\tfor (const [pluginId, entry] of Object.entries(registry)) {\n\t\tif (\"module\" in entry) {\n\t\t\tnormalized[pluginId] = {\n\t\t\t\t...entry,\n\t\t\t\tremote: entry.remote ? normalizeRemoteUrl(entry.remote) : undefined,\n\t\t\t};\n\t\t} else {\n\t\t\tnormalized[pluginId] = {\n\t\t\t\t...entry,\n\t\t\t\tremote: normalizeRemoteUrl(entry.remote),\n\t\t\t};\n\t\t}\n\t}\n\t\n\treturn normalized as PluginRegistry;\n}\n\n/**\n * Creates a plugin runtime with support for both module and remote plugin entries.\n * \n * @example\n * ```typescript\n * // With module entries (types inferred automatically)\n * const runtime = createPluginRuntime({\n * registry: {\n * telegram: { module: TelegramPlugin },\n * gopher: { remote: \"https://cdn.example.com/gopher/remoteEntry.js\" }\n * },\n * secrets: { API_KEY: \"...\" }\n * });\n * \n * // Types are automatically inferred from module entries!\n * const { client } = await runtime.usePlugin(\"telegram\", config);\n * ```\n */\nexport function createPluginRuntime<\n\tTRegistry extends Record<string, PluginRegistryEntry>\n>(\n\tconfig: PluginRuntimeConfig<TRegistry>\n): PluginRuntime<InferRegistryFromEntries<TRegistry>> {\n\tconst secrets = config.secrets || {};\n\tconst normalizedRegistry = normalizeRegistry(config.registry);\n\tconst pluginMap = extractPluginMap(config.registry);\n\n\tconst layer = PluginService.Live(normalizedRegistry, secrets, pluginMap);\n\tconst runtime = ManagedRuntime.make(layer);\n\n\treturn new PluginRuntime(runtime, normalizedRegistry) as PluginRuntime<InferRegistryFromEntries<TRegistry>>;\n}\n"],"mappings":";;;;;;;;;;;;AAIA,IAAa,qBAAb,cAAwC,KAAK,YAAY,qBAAqB,CAM3E;AAEH,IAAa,wBAAb,cAA2C,KAAK,YAC/C,wBACA,CAIE;AAEH,IAAa,kBAAb,cAAqC,KAAK,YAAY,kBAAkB,CAIrE;AAGH,MAAa,uBAAuB,SAA0B;AAC7D,SAAQ,MAAR;EACC,KAAK;EACL,KAAK;EACL,KAAK;EACL,KAAK;EACL,KAAK,UACJ,QAAO;EACR,QACC,QAAO;;;AAKV,MAAa,iBACZ,WACA,UACA,eACA,cACwB;AACxB,QAAO,IAAI,mBAAmB;EAC7B;EACA;EACA;EACA,WAAW,oBAAoB,UAAU,KAAK;EAC9C,OAAO;EACP,CAAC;;AAIH,MAAa,wBACZ,OACA,UACA,eACA,WACA,mBAAmB,UACK;AACxB,KAAI,iBAAiB,UACpB,QAAO,cAAc,OAAO,UAAU,eAAe,UAAU;AAGhE,KAAI,iBAAiB,mBACpB,QAAO;AAGR,QAAO,IAAI,mBAAmB;EAC7B;EACA;EACA;EACA,WAAW;EACX,OAAO,iBAAiB,QAAQ,QAAQ,IAAI,MAAM,OAAO,MAAM,CAAC;EAChE,CAAC;;;;;;AC7DH,MAAM,iCAAiC,OAAO,OAC7C,OAAO,WAAW;AACjB,KAAI;EACH,IAAI,WAAW,aAAa;AAE5B,MAAI,CAAC,UAAU;AACd,cAAW,eAAe;IACzB,MAAM;IACN,SAAS,EAAE;IACX,QAAQ;KACP,gBAAgB;MACf,SAASA,uBAAI;MACb,aAAa;OACZ,WAAW;OACX,iBAAiB,IAAIA,uBAAI;OACzB,OAAO;OACP,eAAe;OACf;MACD;KACD,QAAQ;MACP,SAASA,uBAAI,aAAa;MAC1B,aAAa;OACZ,WAAW;OACX,iBAAiB;OACjB,OAAO;OACP,eAAe;OACf;MACD;KACD,KAAK;MACJ,SAASA,uBAAI,aAAa;MAC1B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,MAAM,qBAAqB,kBAAkB,OAAO,SAAS;CAC7D,MAAM,YAAY,iBAAiB,OAAO,SAAS;CAEnD,MAAM,QAAQ,cAAc,KAAK,oBAAoB,SAAS,UAAU;AAGxE,QAAO,IAAI,cAFK,eAAe,KAAK,MAAM,EAER,mBAAmB"}
|
package/dist/testing/index.cjs
CHANGED
|
@@ -1,78 +1,58 @@
|
|
|
1
|
-
const
|
|
2
|
-
const require_runtime = require('../runtime-BNKZYYMG.cjs');
|
|
1
|
+
const require_runtime = require('../runtime-BNcFgWDG.cjs');
|
|
3
2
|
require('../normalize-D4Qh0wVk.cjs');
|
|
4
|
-
require('../package-
|
|
5
|
-
let effect = require("effect");
|
|
3
|
+
require('../package-DyTuSutr.cjs');
|
|
6
4
|
|
|
7
|
-
//#region src/testing/mocks/module-federation.service.ts
|
|
8
|
-
const createMockModuleFederationServiceLayer = (pluginMap) => effect.Layer.succeed(require_runtime.ModuleFederationService, {
|
|
9
|
-
registerRemote: (pluginId, url) => effect.Effect.gen(function* () {
|
|
10
|
-
console.log(`[MOCK] registerRemote called for ${pluginId}`);
|
|
11
|
-
if (!(pluginId in pluginMap)) return yield* effect.Effect.fail(new require_runtime.ModuleFederationError({
|
|
12
|
-
pluginId,
|
|
13
|
-
remoteUrl: url,
|
|
14
|
-
cause: /* @__PURE__ */ new Error(`Mock: Plugin ${pluginId} not available in test plugin map`)
|
|
15
|
-
}));
|
|
16
|
-
console.log(`[MOCK] registerRemote succeeded for ${pluginId}`);
|
|
17
|
-
}),
|
|
18
|
-
loadRemoteConstructor: (pluginId, url) => effect.Effect.gen(function* () {
|
|
19
|
-
console.log(`[MOCK] loadRemoteConstructor called for ${pluginId}`);
|
|
20
|
-
const PluginConstructor = pluginMap[pluginId];
|
|
21
|
-
if (!PluginConstructor) return yield* effect.Effect.fail(new require_runtime.ModuleFederationError({
|
|
22
|
-
pluginId,
|
|
23
|
-
remoteUrl: url,
|
|
24
|
-
cause: /* @__PURE__ */ new Error(`Mock: Constructor for ${pluginId} not found in test plugin map`)
|
|
25
|
-
}));
|
|
26
|
-
console.log(`[MOCK] loadRemoteConstructor succeeded for ${pluginId}`);
|
|
27
|
-
return PluginConstructor;
|
|
28
|
-
})
|
|
29
|
-
});
|
|
30
|
-
|
|
31
|
-
//#endregion
|
|
32
5
|
//#region src/testing/index.ts
|
|
33
6
|
/**
|
|
34
|
-
*
|
|
35
|
-
* This mirrors PluginService.Live() but uses mock ModuleFederationService.
|
|
7
|
+
* Converts old pluginMap format to new registry format
|
|
36
8
|
*/
|
|
37
|
-
|
|
38
|
-
const
|
|
39
|
-
const
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
9
|
+
function convertPluginMapToRegistry(oldRegistry, pluginMap) {
|
|
10
|
+
const registry = {};
|
|
11
|
+
for (const [pluginId, ctor] of Object.entries(pluginMap)) {
|
|
12
|
+
const oldEntry = oldRegistry[pluginId];
|
|
13
|
+
registry[pluginId] = {
|
|
14
|
+
module: ctor,
|
|
15
|
+
remote: oldEntry?.remoteUrl,
|
|
16
|
+
version: oldEntry?.version,
|
|
17
|
+
description: oldEntry?.description
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
return registry;
|
|
21
|
+
}
|
|
44
22
|
/**
|
|
45
23
|
* Creates a plugin runtime for locally available plugins (non-remote).
|
|
46
24
|
* Automatically infers type bindings from the plugin map, eliminating
|
|
47
25
|
* the need for manual RegistryBindings definitions.
|
|
48
26
|
*
|
|
49
|
-
*
|
|
50
|
-
* - Unit and integration tests
|
|
51
|
-
* - Local development and debugging
|
|
52
|
-
* - Monorepo setups where all plugins are in the same workspace
|
|
53
|
-
*
|
|
54
|
-
* For production with remote Module Federation plugins, use createPluginRuntime().
|
|
55
|
-
*
|
|
27
|
+
* @deprecated Use `createPluginRuntime` with module entries directly instead.
|
|
56
28
|
* @example
|
|
57
29
|
* ```ts
|
|
58
|
-
*
|
|
59
|
-
* const runtime = createLocalPluginRuntime(
|
|
60
|
-
*
|
|
61
|
-
*
|
|
62
|
-
*
|
|
30
|
+
* // Old API (deprecated)
|
|
31
|
+
* const runtime = createLocalPluginRuntime(
|
|
32
|
+
* { registry: { "my-plugin": { remoteUrl: "..." } }, secrets },
|
|
33
|
+
* { "my-plugin": MyPlugin }
|
|
34
|
+
* );
|
|
35
|
+
*
|
|
36
|
+
* // New API (recommended)
|
|
37
|
+
* const runtime = createPluginRuntime({
|
|
38
|
+
* registry: { "my-plugin": { module: MyPlugin } },
|
|
39
|
+
* secrets
|
|
40
|
+
* });
|
|
63
41
|
* ```
|
|
64
42
|
*/
|
|
65
43
|
function createLocalPluginRuntime(config, pluginMap) {
|
|
66
|
-
|
|
67
|
-
|
|
44
|
+
return require_runtime.createPluginRuntime({
|
|
45
|
+
registry: convertPluginMapToRegistry(config.registry, pluginMap),
|
|
46
|
+
secrets: config.secrets,
|
|
47
|
+
options: config.options
|
|
48
|
+
});
|
|
68
49
|
}
|
|
69
50
|
/**
|
|
70
|
-
* @deprecated Use `createLocalPluginRuntime`
|
|
51
|
+
* @deprecated Use `createLocalPluginRuntime` or `createPluginRuntime` instead.
|
|
71
52
|
*/
|
|
72
53
|
const createTestPluginRuntime = createLocalPluginRuntime;
|
|
73
54
|
|
|
74
55
|
//#endregion
|
|
75
56
|
exports.createLocalPluginRuntime = createLocalPluginRuntime;
|
|
76
|
-
exports.createTestLayer = createTestLayer;
|
|
77
57
|
exports.createTestPluginRuntime = createTestPluginRuntime;
|
|
78
58
|
//# sourceMappingURL=index.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","names":["
|
|
1
|
+
{"version":3,"file":"index.cjs","names":["registry: Record<string, PluginRegistryEntry>","createPluginRuntime"],"sources":["../../src/testing/index.ts"],"sourcesContent":["import type { AnyPluginConstructor, InferRegistryFromEntries, PluginRegistryEntry, PluginRuntimeConfig } from \"../types\";\nimport { createPluginRuntime } from \"../runtime\";\nimport type { LoadedPluginWithBinding } from \"../plugin\";\n\nexport type PluginMap = Record<string, LoadedPluginWithBinding<any, any, any, any>>;\n\n/**\n * Simplified type inference for local plugin maps.\n * Just use the constructor types directly.\n *\n * @example\n * ```ts\n * const pluginMap = { \"my-plugin\": MyPlugin } as const;\n * type MyBindings = InferBindingsFromMap<typeof pluginMap>;\n * ```\n */\nexport type InferBindingsFromMap<T extends PluginMap> = {\n\t[K in keyof T]: T[K]\n};\n\n/**\n * Converts old pluginMap format to new registry format\n */\nfunction convertPluginMapToRegistry<T extends PluginMap>(\n\toldRegistry: Record<string, { remoteUrl: string; version?: string; description?: string }>,\n\tpluginMap: T\n): Record<keyof T, PluginRegistryEntry> {\n\tconst registry: Record<string, PluginRegistryEntry> = {};\n\t\n\tfor (const [pluginId, ctor] of Object.entries(pluginMap)) {\n\t\tconst oldEntry = oldRegistry[pluginId];\n\t\tregistry[pluginId] = {\n\t\t\tmodule: ctor as AnyPluginConstructor,\n\t\t\tremote: oldEntry?.remoteUrl,\n\t\t\tversion: oldEntry?.version,\n\t\t\tdescription: oldEntry?.description,\n\t\t};\n\t}\n\t\n\treturn registry as Record<keyof T, PluginRegistryEntry>;\n}\n\n/**\n * Creates a plugin runtime for locally available plugins (non-remote).\n * Automatically infers type bindings from the plugin map, eliminating\n * the need for manual RegistryBindings definitions.\n *\n * @deprecated Use `createPluginRuntime` with module entries directly instead.\n * @example\n * ```ts\n * // Old API (deprecated)\n * const runtime = createLocalPluginRuntime(\n * { registry: { \"my-plugin\": { remoteUrl: \"...\" } }, secrets },\n * { \"my-plugin\": MyPlugin }\n * );\n * \n * // New API (recommended)\n * const runtime = createPluginRuntime({\n * registry: { \"my-plugin\": { module: MyPlugin } },\n * secrets\n * });\n * ```\n */\nexport function createLocalPluginRuntime<TMap extends PluginMap>(\n\tconfig: {\n\t\tregistry: Record<string, { remoteUrl: string; version?: string; description?: string }>;\n\t\tsecrets?: Record<string, string>;\n\t\toptions?: any;\n\t},\n\tpluginMap: TMap\n) {\n\tconst newRegistry = convertPluginMapToRegistry(config.registry, pluginMap);\n\t\n\treturn createPluginRuntime({\n\t\tregistry: newRegistry,\n\t\tsecrets: config.secrets,\n\t\toptions: config.options,\n\t});\n}\n\n/**\n * @deprecated Use `createLocalPluginRuntime` or `createPluginRuntime` instead.\n */\nexport const createTestPluginRuntime = createLocalPluginRuntime;\n\nexport type { EveryPlugin, PluginRegistry, RegisteredPlugins } from \"../types\";\nexport type { PluginRuntimeConfig };\n"],"mappings":";;;;;;;;AAuBA,SAAS,2BACR,aACA,WACuC;CACvC,MAAMA,WAAgD,EAAE;AAExD,MAAK,MAAM,CAAC,UAAU,SAAS,OAAO,QAAQ,UAAU,EAAE;EACzD,MAAM,WAAW,YAAY;AAC7B,WAAS,YAAY;GACpB,QAAQ;GACR,QAAQ,UAAU;GAClB,SAAS,UAAU;GACnB,aAAa,UAAU;GACvB;;AAGF,QAAO;;;;;;;;;;;;;;;;;;;;;;;AAwBR,SAAgB,yBACf,QAKA,WACC;AAGD,QAAOC,oCAAoB;EAC1B,UAHmB,2BAA2B,OAAO,UAAU,UAAU;EAIzE,SAAS,OAAO;EAChB,SAAS,OAAO;EAChB,CAAC;;;;;AAMH,MAAa,0BAA0B"}
|
package/dist/testing/index.d.cts
CHANGED
|
@@ -1,18 +1,10 @@
|
|
|
1
1
|
import "../zod-A7Pti5IV.cjs";
|
|
2
2
|
import "../errors-DKPPPYYT.cjs";
|
|
3
|
-
import {
|
|
3
|
+
import { S as LoadedPluginWithBinding, _ as PluginRuntimeConfig, a as InferRegistryFromEntries, b as RegisteredPlugins, h as PluginRegistryEntry, i as EveryPlugin, m as PluginRegistry, t as PluginRuntime } from "../index-DtTqwV4f.cjs";
|
|
4
4
|
import "../normalize-BW7kk8Lk.cjs";
|
|
5
|
-
import { Layer } from "effect";
|
|
6
5
|
|
|
7
|
-
//#region src/testing/mocks/module-federation.service.d.ts
|
|
8
|
-
type PluginMap = Record<string, LoadedPluginWithBinding<any, any, any, any>>;
|
|
9
|
-
//#endregion
|
|
10
6
|
//#region src/testing/index.d.ts
|
|
11
|
-
|
|
12
|
-
* Validates that all plugin map keys exist in RegisteredPlugins.
|
|
13
|
-
* This ensures proper type inference for client methods.
|
|
14
|
-
*/
|
|
15
|
-
type ValidatePluginMap<T extends PluginMap> = { [K in keyof T]: K extends keyof RegisteredPlugins ? T[K] : `❌ Plugin key "${K & string}" not registered in RegisteredPlugins. Add it to your types.d.ts file.` };
|
|
7
|
+
type PluginMap = Record<string, LoadedPluginWithBinding<any, any, any, any>>;
|
|
16
8
|
/**
|
|
17
9
|
* Simplified type inference for local plugin maps.
|
|
18
10
|
* Just use the constructor types directly.
|
|
@@ -23,38 +15,41 @@ type ValidatePluginMap<T extends PluginMap> = { [K in keyof T]: K extends keyof
|
|
|
23
15
|
* type MyBindings = InferBindingsFromMap<typeof pluginMap>;
|
|
24
16
|
* ```
|
|
25
17
|
*/
|
|
26
|
-
type InferBindingsFromMap<T extends PluginMap> = { [K in keyof T]: T[K] }
|
|
27
|
-
/**
|
|
28
|
-
* Creates a test layer with mock ModuleFederationService for unit testing.
|
|
29
|
-
* This mirrors PluginService.Live() but uses mock ModuleFederationService.
|
|
30
|
-
*/
|
|
31
|
-
declare const createTestLayer: <R extends RegisteredPlugins = RegisteredPlugins>(config: PluginRuntimeConfig<R>, pluginMap: PluginMap) => Layer.Layer<PluginService, never, never>;
|
|
18
|
+
type InferBindingsFromMap<T extends PluginMap> = { [K in keyof T]: T[K] };
|
|
32
19
|
/**
|
|
33
20
|
* Creates a plugin runtime for locally available plugins (non-remote).
|
|
34
21
|
* Automatically infers type bindings from the plugin map, eliminating
|
|
35
22
|
* the need for manual RegistryBindings definitions.
|
|
36
23
|
*
|
|
37
|
-
*
|
|
38
|
-
* - Unit and integration tests
|
|
39
|
-
* - Local development and debugging
|
|
40
|
-
* - Monorepo setups where all plugins are in the same workspace
|
|
41
|
-
*
|
|
42
|
-
* For production with remote Module Federation plugins, use createPluginRuntime().
|
|
43
|
-
*
|
|
24
|
+
* @deprecated Use `createPluginRuntime` with module entries directly instead.
|
|
44
25
|
* @example
|
|
45
26
|
* ```ts
|
|
46
|
-
*
|
|
47
|
-
* const runtime = createLocalPluginRuntime(
|
|
27
|
+
* // Old API (deprecated)
|
|
28
|
+
* const runtime = createLocalPluginRuntime(
|
|
29
|
+
* { registry: { "my-plugin": { remoteUrl: "..." } }, secrets },
|
|
30
|
+
* { "my-plugin": MyPlugin }
|
|
31
|
+
* );
|
|
48
32
|
*
|
|
49
|
-
* //
|
|
50
|
-
* const
|
|
33
|
+
* // New API (recommended)
|
|
34
|
+
* const runtime = createPluginRuntime({
|
|
35
|
+
* registry: { "my-plugin": { module: MyPlugin } },
|
|
36
|
+
* secrets
|
|
37
|
+
* });
|
|
51
38
|
* ```
|
|
52
39
|
*/
|
|
53
|
-
declare function createLocalPluginRuntime<TMap extends PluginMap
|
|
40
|
+
declare function createLocalPluginRuntime<TMap extends PluginMap>(config: {
|
|
41
|
+
registry: Record<string, {
|
|
42
|
+
remoteUrl: string;
|
|
43
|
+
version?: string;
|
|
44
|
+
description?: string;
|
|
45
|
+
}>;
|
|
46
|
+
secrets?: Record<string, string>;
|
|
47
|
+
options?: any;
|
|
48
|
+
}, pluginMap: TMap): PluginRuntime<InferRegistryFromEntries<Record<keyof TMap, PluginRegistryEntry>>>;
|
|
54
49
|
/**
|
|
55
|
-
* @deprecated Use `createLocalPluginRuntime`
|
|
50
|
+
* @deprecated Use `createLocalPluginRuntime` or `createPluginRuntime` instead.
|
|
56
51
|
*/
|
|
57
52
|
declare const createTestPluginRuntime: typeof createLocalPluginRuntime;
|
|
58
53
|
//#endregion
|
|
59
|
-
export { type EveryPlugin, InferBindingsFromMap,
|
|
54
|
+
export { type EveryPlugin, InferBindingsFromMap, PluginMap, type PluginRegistry, type PluginRuntimeConfig, type RegisteredPlugins, createLocalPluginRuntime, createTestPluginRuntime };
|
|
60
55
|
//# sourceMappingURL=index.d.cts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.cts","names":[],"sources":["../../src/testing/
|
|
1
|
+
{"version":3,"file":"index.d.cts","names":[],"sources":["../../src/testing/index.ts"],"sourcesContent":[],"mappings":";;;;;;KAIY,SAAA,GAAY,eAAe;;;;AAAvC;AAYA;;;;;;AA+CgB,KA/CJ,oBA+C4B,CAAA,UA/CG,SA+CH,CAAA,GAAA,QAAc,MA9CzC,CA8CyC,GA9CrC,CA8CqC,CA9CnC,CA8CmC,CAAA,EAE1C;;;;;;;;;AAkBZ;;;;;;;;;;;;;iBApBgB,sCAAsC;YAE1C;;;;;YACA;;cAGA,OAAI,cAAA,yBAAA,aAAA,MAAA;;;;cAcH,gCAAuB"}
|
package/dist/testing/index.d.mts
CHANGED
|
@@ -1,18 +1,10 @@
|
|
|
1
1
|
import "../zod-Zw8dlP3j.mjs";
|
|
2
2
|
import "../errors-9sNpYLv5.mjs";
|
|
3
|
-
import {
|
|
3
|
+
import { S as LoadedPluginWithBinding, _ as PluginRuntimeConfig, a as InferRegistryFromEntries, b as RegisteredPlugins, h as PluginRegistryEntry, i as EveryPlugin, m as PluginRegistry, t as PluginRuntime } from "../index-Bu2wtZrA.mjs";
|
|
4
4
|
import "../normalize-eB_j86fm.mjs";
|
|
5
|
-
import { Layer } from "effect";
|
|
6
5
|
|
|
7
|
-
//#region src/testing/mocks/module-federation.service.d.ts
|
|
8
|
-
type PluginMap = Record<string, LoadedPluginWithBinding<any, any, any, any>>;
|
|
9
|
-
//#endregion
|
|
10
6
|
//#region src/testing/index.d.ts
|
|
11
|
-
|
|
12
|
-
* Validates that all plugin map keys exist in RegisteredPlugins.
|
|
13
|
-
* This ensures proper type inference for client methods.
|
|
14
|
-
*/
|
|
15
|
-
type ValidatePluginMap<T extends PluginMap> = { [K in keyof T]: K extends keyof RegisteredPlugins ? T[K] : `❌ Plugin key "${K & string}" not registered in RegisteredPlugins. Add it to your types.d.ts file.` };
|
|
7
|
+
type PluginMap = Record<string, LoadedPluginWithBinding<any, any, any, any>>;
|
|
16
8
|
/**
|
|
17
9
|
* Simplified type inference for local plugin maps.
|
|
18
10
|
* Just use the constructor types directly.
|
|
@@ -23,38 +15,41 @@ type ValidatePluginMap<T extends PluginMap> = { [K in keyof T]: K extends keyof
|
|
|
23
15
|
* type MyBindings = InferBindingsFromMap<typeof pluginMap>;
|
|
24
16
|
* ```
|
|
25
17
|
*/
|
|
26
|
-
type InferBindingsFromMap<T extends PluginMap> = { [K in keyof T]: T[K] }
|
|
27
|
-
/**
|
|
28
|
-
* Creates a test layer with mock ModuleFederationService for unit testing.
|
|
29
|
-
* This mirrors PluginService.Live() but uses mock ModuleFederationService.
|
|
30
|
-
*/
|
|
31
|
-
declare const createTestLayer: <R extends RegisteredPlugins = RegisteredPlugins>(config: PluginRuntimeConfig<R>, pluginMap: PluginMap) => Layer.Layer<PluginService, never, never>;
|
|
18
|
+
type InferBindingsFromMap<T extends PluginMap> = { [K in keyof T]: T[K] };
|
|
32
19
|
/**
|
|
33
20
|
* Creates a plugin runtime for locally available plugins (non-remote).
|
|
34
21
|
* Automatically infers type bindings from the plugin map, eliminating
|
|
35
22
|
* the need for manual RegistryBindings definitions.
|
|
36
23
|
*
|
|
37
|
-
*
|
|
38
|
-
* - Unit and integration tests
|
|
39
|
-
* - Local development and debugging
|
|
40
|
-
* - Monorepo setups where all plugins are in the same workspace
|
|
41
|
-
*
|
|
42
|
-
* For production with remote Module Federation plugins, use createPluginRuntime().
|
|
43
|
-
*
|
|
24
|
+
* @deprecated Use `createPluginRuntime` with module entries directly instead.
|
|
44
25
|
* @example
|
|
45
26
|
* ```ts
|
|
46
|
-
*
|
|
47
|
-
* const runtime = createLocalPluginRuntime(
|
|
27
|
+
* // Old API (deprecated)
|
|
28
|
+
* const runtime = createLocalPluginRuntime(
|
|
29
|
+
* { registry: { "my-plugin": { remoteUrl: "..." } }, secrets },
|
|
30
|
+
* { "my-plugin": MyPlugin }
|
|
31
|
+
* );
|
|
48
32
|
*
|
|
49
|
-
* //
|
|
50
|
-
* const
|
|
33
|
+
* // New API (recommended)
|
|
34
|
+
* const runtime = createPluginRuntime({
|
|
35
|
+
* registry: { "my-plugin": { module: MyPlugin } },
|
|
36
|
+
* secrets
|
|
37
|
+
* });
|
|
51
38
|
* ```
|
|
52
39
|
*/
|
|
53
|
-
declare function createLocalPluginRuntime<TMap extends PluginMap
|
|
40
|
+
declare function createLocalPluginRuntime<TMap extends PluginMap>(config: {
|
|
41
|
+
registry: Record<string, {
|
|
42
|
+
remoteUrl: string;
|
|
43
|
+
version?: string;
|
|
44
|
+
description?: string;
|
|
45
|
+
}>;
|
|
46
|
+
secrets?: Record<string, string>;
|
|
47
|
+
options?: any;
|
|
48
|
+
}, pluginMap: TMap): PluginRuntime<InferRegistryFromEntries<Record<keyof TMap, PluginRegistryEntry>>>;
|
|
54
49
|
/**
|
|
55
|
-
* @deprecated Use `createLocalPluginRuntime`
|
|
50
|
+
* @deprecated Use `createLocalPluginRuntime` or `createPluginRuntime` instead.
|
|
56
51
|
*/
|
|
57
52
|
declare const createTestPluginRuntime: typeof createLocalPluginRuntime;
|
|
58
53
|
//#endregion
|
|
59
|
-
export { type EveryPlugin, InferBindingsFromMap,
|
|
54
|
+
export { type EveryPlugin, InferBindingsFromMap, PluginMap, type PluginRegistry, type PluginRuntimeConfig, type RegisteredPlugins, createLocalPluginRuntime, createTestPluginRuntime };
|
|
60
55
|
//# sourceMappingURL=index.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.mts","names":[],"sources":["../../src/testing/
|
|
1
|
+
{"version":3,"file":"index.d.mts","names":[],"sources":["../../src/testing/index.ts"],"sourcesContent":[],"mappings":";;;;;;KAIY,SAAA,GAAY,eAAe;;;;AAAvC;AAYA;;;;;;AA+CgB,KA/CJ,oBA+C4B,CAAA,UA/CG,SA+CH,CAAA,GAAA,QAAc,MA9CzC,CA8CyC,GA9CrC,CA8CqC,CA9CnC,CA8CmC,CAAA,EAE1C;;;;;;;;;AAkBZ;;;;;;;;;;;;;iBApBgB,sCAAsC;YAE1C;;;;;YACA;;cAGA,OAAI,cAAA,yBAAA,aAAA,MAAA;;;;cAcH,gCAAuB"}
|
package/dist/testing/index.mjs
CHANGED
|
@@ -1,75 +1,57 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { n as createPluginRuntime } from "../runtime-CAWcnrAk.mjs";
|
|
2
2
|
import "../normalize-D7nae0Hn.mjs";
|
|
3
|
-
import "../package-
|
|
4
|
-
import { Effect, Layer, ManagedRuntime } from "effect";
|
|
3
|
+
import "../package-CaRYwbRi.mjs";
|
|
5
4
|
|
|
6
|
-
//#region src/testing/mocks/module-federation.service.ts
|
|
7
|
-
const createMockModuleFederationServiceLayer = (pluginMap) => Layer.succeed(ModuleFederationService, {
|
|
8
|
-
registerRemote: (pluginId, url) => Effect.gen(function* () {
|
|
9
|
-
console.log(`[MOCK] registerRemote called for ${pluginId}`);
|
|
10
|
-
if (!(pluginId in pluginMap)) return yield* Effect.fail(new ModuleFederationError({
|
|
11
|
-
pluginId,
|
|
12
|
-
remoteUrl: url,
|
|
13
|
-
cause: /* @__PURE__ */ new Error(`Mock: Plugin ${pluginId} not available in test plugin map`)
|
|
14
|
-
}));
|
|
15
|
-
console.log(`[MOCK] registerRemote succeeded for ${pluginId}`);
|
|
16
|
-
}),
|
|
17
|
-
loadRemoteConstructor: (pluginId, url) => Effect.gen(function* () {
|
|
18
|
-
console.log(`[MOCK] loadRemoteConstructor called for ${pluginId}`);
|
|
19
|
-
const PluginConstructor = pluginMap[pluginId];
|
|
20
|
-
if (!PluginConstructor) return yield* Effect.fail(new ModuleFederationError({
|
|
21
|
-
pluginId,
|
|
22
|
-
remoteUrl: url,
|
|
23
|
-
cause: /* @__PURE__ */ new Error(`Mock: Constructor for ${pluginId} not found in test plugin map`)
|
|
24
|
-
}));
|
|
25
|
-
console.log(`[MOCK] loadRemoteConstructor succeeded for ${pluginId}`);
|
|
26
|
-
return PluginConstructor;
|
|
27
|
-
})
|
|
28
|
-
});
|
|
29
|
-
|
|
30
|
-
//#endregion
|
|
31
5
|
//#region src/testing/index.ts
|
|
32
6
|
/**
|
|
33
|
-
*
|
|
34
|
-
* This mirrors PluginService.Live() but uses mock ModuleFederationService.
|
|
7
|
+
* Converts old pluginMap format to new registry format
|
|
35
8
|
*/
|
|
36
|
-
|
|
37
|
-
const
|
|
38
|
-
const
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
9
|
+
function convertPluginMapToRegistry(oldRegistry, pluginMap) {
|
|
10
|
+
const registry = {};
|
|
11
|
+
for (const [pluginId, ctor] of Object.entries(pluginMap)) {
|
|
12
|
+
const oldEntry = oldRegistry[pluginId];
|
|
13
|
+
registry[pluginId] = {
|
|
14
|
+
module: ctor,
|
|
15
|
+
remote: oldEntry?.remoteUrl,
|
|
16
|
+
version: oldEntry?.version,
|
|
17
|
+
description: oldEntry?.description
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
return registry;
|
|
21
|
+
}
|
|
43
22
|
/**
|
|
44
23
|
* Creates a plugin runtime for locally available plugins (non-remote).
|
|
45
24
|
* Automatically infers type bindings from the plugin map, eliminating
|
|
46
25
|
* the need for manual RegistryBindings definitions.
|
|
47
26
|
*
|
|
48
|
-
*
|
|
49
|
-
* - Unit and integration tests
|
|
50
|
-
* - Local development and debugging
|
|
51
|
-
* - Monorepo setups where all plugins are in the same workspace
|
|
52
|
-
*
|
|
53
|
-
* For production with remote Module Federation plugins, use createPluginRuntime().
|
|
54
|
-
*
|
|
27
|
+
* @deprecated Use `createPluginRuntime` with module entries directly instead.
|
|
55
28
|
* @example
|
|
56
29
|
* ```ts
|
|
57
|
-
*
|
|
58
|
-
* const runtime = createLocalPluginRuntime(
|
|
59
|
-
*
|
|
60
|
-
*
|
|
61
|
-
*
|
|
30
|
+
* // Old API (deprecated)
|
|
31
|
+
* const runtime = createLocalPluginRuntime(
|
|
32
|
+
* { registry: { "my-plugin": { remoteUrl: "..." } }, secrets },
|
|
33
|
+
* { "my-plugin": MyPlugin }
|
|
34
|
+
* );
|
|
35
|
+
*
|
|
36
|
+
* // New API (recommended)
|
|
37
|
+
* const runtime = createPluginRuntime({
|
|
38
|
+
* registry: { "my-plugin": { module: MyPlugin } },
|
|
39
|
+
* secrets
|
|
40
|
+
* });
|
|
62
41
|
* ```
|
|
63
42
|
*/
|
|
64
43
|
function createLocalPluginRuntime(config, pluginMap) {
|
|
65
|
-
|
|
66
|
-
|
|
44
|
+
return createPluginRuntime({
|
|
45
|
+
registry: convertPluginMapToRegistry(config.registry, pluginMap),
|
|
46
|
+
secrets: config.secrets,
|
|
47
|
+
options: config.options
|
|
48
|
+
});
|
|
67
49
|
}
|
|
68
50
|
/**
|
|
69
|
-
* @deprecated Use `createLocalPluginRuntime`
|
|
51
|
+
* @deprecated Use `createLocalPluginRuntime` or `createPluginRuntime` instead.
|
|
70
52
|
*/
|
|
71
53
|
const createTestPluginRuntime = createLocalPluginRuntime;
|
|
72
54
|
|
|
73
55
|
//#endregion
|
|
74
|
-
export { createLocalPluginRuntime,
|
|
56
|
+
export { createLocalPluginRuntime, createTestPluginRuntime };
|
|
75
57
|
//# sourceMappingURL=index.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","names":[],"sources":["../../src/testing/
|
|
1
|
+
{"version":3,"file":"index.mjs","names":["registry: Record<string, PluginRegistryEntry>"],"sources":["../../src/testing/index.ts"],"sourcesContent":["import type { AnyPluginConstructor, InferRegistryFromEntries, PluginRegistryEntry, PluginRuntimeConfig } from \"../types\";\nimport { createPluginRuntime } from \"../runtime\";\nimport type { LoadedPluginWithBinding } from \"../plugin\";\n\nexport type PluginMap = Record<string, LoadedPluginWithBinding<any, any, any, any>>;\n\n/**\n * Simplified type inference for local plugin maps.\n * Just use the constructor types directly.\n *\n * @example\n * ```ts\n * const pluginMap = { \"my-plugin\": MyPlugin } as const;\n * type MyBindings = InferBindingsFromMap<typeof pluginMap>;\n * ```\n */\nexport type InferBindingsFromMap<T extends PluginMap> = {\n\t[K in keyof T]: T[K]\n};\n\n/**\n * Converts old pluginMap format to new registry format\n */\nfunction convertPluginMapToRegistry<T extends PluginMap>(\n\toldRegistry: Record<string, { remoteUrl: string; version?: string; description?: string }>,\n\tpluginMap: T\n): Record<keyof T, PluginRegistryEntry> {\n\tconst registry: Record<string, PluginRegistryEntry> = {};\n\t\n\tfor (const [pluginId, ctor] of Object.entries(pluginMap)) {\n\t\tconst oldEntry = oldRegistry[pluginId];\n\t\tregistry[pluginId] = {\n\t\t\tmodule: ctor as AnyPluginConstructor,\n\t\t\tremote: oldEntry?.remoteUrl,\n\t\t\tversion: oldEntry?.version,\n\t\t\tdescription: oldEntry?.description,\n\t\t};\n\t}\n\t\n\treturn registry as Record<keyof T, PluginRegistryEntry>;\n}\n\n/**\n * Creates a plugin runtime for locally available plugins (non-remote).\n * Automatically infers type bindings from the plugin map, eliminating\n * the need for manual RegistryBindings definitions.\n *\n * @deprecated Use `createPluginRuntime` with module entries directly instead.\n * @example\n * ```ts\n * // Old API (deprecated)\n * const runtime = createLocalPluginRuntime(\n * { registry: { \"my-plugin\": { remoteUrl: \"...\" } }, secrets },\n * { \"my-plugin\": MyPlugin }\n * );\n * \n * // New API (recommended)\n * const runtime = createPluginRuntime({\n * registry: { \"my-plugin\": { module: MyPlugin } },\n * secrets\n * });\n * ```\n */\nexport function createLocalPluginRuntime<TMap extends PluginMap>(\n\tconfig: {\n\t\tregistry: Record<string, { remoteUrl: string; version?: string; description?: string }>;\n\t\tsecrets?: Record<string, string>;\n\t\toptions?: any;\n\t},\n\tpluginMap: TMap\n) {\n\tconst newRegistry = convertPluginMapToRegistry(config.registry, pluginMap);\n\t\n\treturn createPluginRuntime({\n\t\tregistry: newRegistry,\n\t\tsecrets: config.secrets,\n\t\toptions: config.options,\n\t});\n}\n\n/**\n * @deprecated Use `createLocalPluginRuntime` or `createPluginRuntime` instead.\n */\nexport const createTestPluginRuntime = createLocalPluginRuntime;\n\nexport type { EveryPlugin, PluginRegistry, RegisteredPlugins } from \"../types\";\nexport type { PluginRuntimeConfig };\n"],"mappings":";;;;;;;;AAuBA,SAAS,2BACR,aACA,WACuC;CACvC,MAAMA,WAAgD,EAAE;AAExD,MAAK,MAAM,CAAC,UAAU,SAAS,OAAO,QAAQ,UAAU,EAAE;EACzD,MAAM,WAAW,YAAY;AAC7B,WAAS,YAAY;GACpB,QAAQ;GACR,QAAQ,UAAU;GAClB,SAAS,UAAU;GACnB,aAAa,UAAU;GACvB;;AAGF,QAAO;;;;;;;;;;;;;;;;;;;;;;;AAwBR,SAAgB,yBACf,QAKA,WACC;AAGD,QAAO,oBAAoB;EAC1B,UAHmB,2BAA2B,OAAO,UAAU,UAAU;EAIzE,SAAS,OAAO;EAChB,SAAS,OAAO;EAChB,CAAC;;;;;AAMH,MAAa,0BAA0B"}
|