every-plugin 2.9.6 → 2.10.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/_virtual/_rolldown/runtime.mjs +1 -1
- package/dist/build/rspack/dev-server-middleware.cjs.map +1 -1
- package/dist/build/rspack/dev-server-middleware.mjs.map +1 -1
- package/dist/build/rspack/fix-mf-data-uri-plugin.cjs.map +1 -1
- package/dist/build/rspack/fix-mf-data-uri-plugin.d.cts +0 -1
- package/dist/build/rspack/fix-mf-data-uri-plugin.d.cts.map +1 -1
- package/dist/build/rspack/fix-mf-data-uri-plugin.d.mts +0 -1
- package/dist/build/rspack/fix-mf-data-uri-plugin.d.mts.map +1 -1
- package/dist/build/rspack/fix-mf-data-uri-plugin.mjs.map +1 -1
- package/dist/build/rspack/module-federation.cjs.map +1 -1
- package/dist/build/rspack/module-federation.mjs.map +1 -1
- package/dist/build/rspack/plugin.cjs +2 -0
- package/dist/build/rspack/plugin.cjs.map +1 -1
- package/dist/build/rspack/plugin.d.cts +1 -2
- package/dist/build/rspack/plugin.d.cts.map +1 -1
- package/dist/build/rspack/plugin.d.mts +1 -2
- package/dist/build/rspack/plugin.d.mts.map +1 -1
- package/dist/build/rspack/plugin.mjs +2 -0
- package/dist/build/rspack/plugin.mjs.map +1 -1
- package/dist/build/rspack/utils.cjs.map +1 -1
- package/dist/build/rspack/utils.mjs.map +1 -1
- package/dist/build/shared-deps.cjs +0 -1
- package/dist/build/shared-deps.cjs.map +1 -1
- package/dist/build/shared-deps.d.cts.map +1 -1
- package/dist/build/shared-deps.d.mts.map +1 -1
- package/dist/build/shared-deps.mjs.map +1 -1
- package/dist/errors.cjs +0 -1
- package/dist/errors.cjs.map +1 -1
- package/dist/errors.d.cts +0 -1
- package/dist/errors.d.cts.map +1 -1
- package/dist/errors.d.mts +0 -1
- package/dist/errors.d.mts.map +1 -1
- package/dist/errors.mjs.map +1 -1
- package/dist/index.cjs +1 -0
- package/dist/index.d.cts +2 -2
- package/dist/index.d.mts +2 -2
- package/dist/index.mjs +2 -2
- package/dist/orpc.cjs +0 -1
- package/dist/plugin.cjs +2 -1
- package/dist/plugin.cjs.map +1 -1
- package/dist/plugin.d.cts +3 -2
- package/dist/plugin.d.cts.map +1 -1
- package/dist/plugin.d.mts +3 -2
- package/dist/plugin.d.mts.map +1 -1
- package/dist/plugin.mjs +3 -2
- package/dist/plugin.mjs.map +1 -1
- package/dist/runtime/errors.cjs +0 -1
- package/dist/runtime/errors.cjs.map +1 -1
- package/dist/runtime/errors.d.cts +3 -5
- package/dist/runtime/errors.d.cts.map +1 -1
- package/dist/runtime/errors.d.mts +3 -5
- package/dist/runtime/errors.d.mts.map +1 -1
- package/dist/runtime/errors.mjs.map +1 -1
- package/dist/runtime/index.cjs +4 -2
- package/dist/runtime/index.cjs.map +1 -1
- package/dist/runtime/index.d.cts +0 -1
- package/dist/runtime/index.d.cts.map +1 -1
- package/dist/runtime/index.d.mts +0 -1
- package/dist/runtime/index.d.mts.map +1 -1
- package/dist/runtime/index.mjs +4 -1
- package/dist/runtime/index.mjs.map +1 -1
- package/dist/runtime/mf-config.cjs +1 -2
- package/dist/runtime/mf-config.cjs.map +1 -1
- package/dist/runtime/mf-config.d.cts.map +1 -1
- package/dist/runtime/mf-config.d.mts.map +1 -1
- package/dist/runtime/mf-config.mjs +1 -1
- package/dist/runtime/mf-config.mjs.map +1 -1
- package/dist/runtime/services/module-federation.service.cjs +0 -1
- package/dist/runtime/services/module-federation.service.cjs.map +1 -1
- package/dist/runtime/services/module-federation.service.d.cts +0 -1
- package/dist/runtime/services/module-federation.service.d.cts.map +1 -1
- package/dist/runtime/services/module-federation.service.d.mts +0 -1
- package/dist/runtime/services/module-federation.service.d.mts.map +1 -1
- package/dist/runtime/services/module-federation.service.mjs.map +1 -1
- package/dist/runtime/services/normalize.cjs.map +1 -1
- package/dist/runtime/services/normalize.d.cts.map +1 -1
- package/dist/runtime/services/normalize.d.mts.map +1 -1
- package/dist/runtime/services/normalize.mjs.map +1 -1
- package/dist/runtime/services/plugin-lifecycle.service.cjs +0 -1
- package/dist/runtime/services/plugin-lifecycle.service.cjs.map +1 -1
- package/dist/runtime/services/plugin-lifecycle.service.d.cts +0 -1
- package/dist/runtime/services/plugin-lifecycle.service.d.cts.map +1 -1
- package/dist/runtime/services/plugin-lifecycle.service.d.mts +0 -1
- package/dist/runtime/services/plugin-lifecycle.service.d.mts.map +1 -1
- package/dist/runtime/services/plugin-lifecycle.service.mjs.map +1 -1
- package/dist/runtime/services/plugin-loader.service.cjs +2 -2
- package/dist/runtime/services/plugin-loader.service.cjs.map +1 -1
- package/dist/runtime/services/plugin-loader.service.d.cts +1 -2
- package/dist/runtime/services/plugin-loader.service.d.cts.map +1 -1
- package/dist/runtime/services/plugin-loader.service.d.mts +1 -2
- package/dist/runtime/services/plugin-loader.service.d.mts.map +1 -1
- package/dist/runtime/services/plugin-loader.service.mjs +2 -1
- package/dist/runtime/services/plugin-loader.service.mjs.map +1 -1
- package/dist/runtime/services/plugin.service.cjs +0 -1
- package/dist/runtime/services/plugin.service.cjs.map +1 -1
- package/dist/runtime/services/plugin.service.d.cts +5 -6
- package/dist/runtime/services/plugin.service.d.cts.map +1 -1
- package/dist/runtime/services/plugin.service.d.mts +5 -6
- package/dist/runtime/services/plugin.service.d.mts.map +1 -1
- package/dist/runtime/services/plugin.service.mjs.map +1 -1
- package/dist/runtime/services/secrets.service.cjs.map +1 -1
- package/dist/runtime/services/secrets.service.d.cts +1 -2
- package/dist/runtime/services/secrets.service.d.cts.map +1 -1
- package/dist/runtime/services/secrets.service.d.mts +1 -2
- package/dist/runtime/services/secrets.service.d.mts.map +1 -1
- package/dist/runtime/services/secrets.service.mjs.map +1 -1
- package/dist/runtime/validation.cjs +0 -1
- package/dist/runtime/validation.cjs.map +1 -1
- package/dist/runtime/validation.mjs.map +1 -1
- package/dist/testing/index.cjs.map +1 -1
- package/dist/testing/index.d.cts +2 -1
- package/dist/testing/index.d.cts.map +1 -1
- package/dist/testing/index.d.mts +2 -1
- package/dist/testing/index.d.mts.map +1 -1
- package/dist/testing/index.mjs.map +1 -1
- package/dist/types.d.cts +1 -2
- package/dist/types.d.cts.map +1 -1
- package/dist/types.d.mts +1 -2
- package/dist/types.d.mts.map +1 -1
- package/package.json +5 -5
- package/src/plugin.ts +3 -1
- package/src/runtime/services/plugin-loader.service.ts +2 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin-lifecycle.service.cjs","names":["Effect","Ref","toPluginRuntimeError","Scope","Exit"],"sources":["../../../src/runtime/services/plugin-lifecycle.service.ts"],"sourcesContent":["import { Effect, Exit, Ref, Scope } from \"effect\";\nimport type { AnyPlugin, InitializedPlugin } from \"../../types\";\nimport { toPluginRuntimeError } from \"../errors\";\n\nexport class PluginLifecycleService extends Effect.Service<PluginLifecycleService>()(\n \"PluginLifecycleService\",\n {\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\n .shutdown()\n .pipe(\n Effect.mapError((error) =>\n toPluginRuntimeError(\n error,\n plugin.plugin.id,\n undefined,\n \"shutdown-plugin\",\n false,\n ),\n ),\n );\n }),\n\n cleanup: () =>\n Effect.gen(function* () {\n const plugins = yield* Ref.get(activePlugins);\n if (typeof process !== \"undefined\" && process.env?.EVERY_PLUGIN_DEBUG_SCOPES === \"1\") {\n yield* Effect.logWarning(\n `[PluginLifecycle] cleaning up ${plugins.size} active plugin(s)`,\n );\n }\n\n yield* Effect.forEach(\n plugins,\n (plugin) =>\n Effect.gen(function* () {\n yield* plugin.plugin\n .shutdown()\n .pipe(\n Effect.catchAll((error) =>\n Effect.logWarning(`Failed to shutdown plugin ${plugin.plugin.id}`, error),\n ),\n );\n yield* Scope.close(plugin.scope, Exit.succeed(undefined)).pipe(\n Effect.catchAll((error) =>\n Effect.logWarning(\n `Failed to close scope for plugin ${plugin.plugin.id}`,\n error,\n ),\n ),\n );\n }),\n { concurrency: \"unbounded\" },\n );\n\n yield* Ref.set(activePlugins, new Set());\n }).pipe(Effect.catchAll((error) => Effect.logWarning(\"Plugin cleanup failed\", error))),\n };\n }),\n },\n) {}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"plugin-lifecycle.service.cjs","names":["Effect","Ref","toPluginRuntimeError","Scope","Exit"],"sources":["../../../src/runtime/services/plugin-lifecycle.service.ts"],"sourcesContent":["import { Effect, Exit, Ref, Scope } from \"effect\";\nimport type { AnyPlugin, InitializedPlugin } from \"../../types\";\nimport { toPluginRuntimeError } from \"../errors\";\n\nexport class PluginLifecycleService extends Effect.Service<PluginLifecycleService>()(\n \"PluginLifecycleService\",\n {\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\n .shutdown()\n .pipe(\n Effect.mapError((error) =>\n toPluginRuntimeError(\n error,\n plugin.plugin.id,\n undefined,\n \"shutdown-plugin\",\n false,\n ),\n ),\n );\n }),\n\n cleanup: () =>\n Effect.gen(function* () {\n const plugins = yield* Ref.get(activePlugins);\n if (typeof process !== \"undefined\" && process.env?.EVERY_PLUGIN_DEBUG_SCOPES === \"1\") {\n yield* Effect.logWarning(\n `[PluginLifecycle] cleaning up ${plugins.size} active plugin(s)`,\n );\n }\n\n yield* Effect.forEach(\n plugins,\n (plugin) =>\n Effect.gen(function* () {\n yield* plugin.plugin\n .shutdown()\n .pipe(\n Effect.catchAll((error) =>\n Effect.logWarning(`Failed to shutdown plugin ${plugin.plugin.id}`, error),\n ),\n );\n yield* Scope.close(plugin.scope, Exit.succeed(undefined)).pipe(\n Effect.catchAll((error) =>\n Effect.logWarning(\n `Failed to close scope for plugin ${plugin.plugin.id}`,\n error,\n ),\n ),\n );\n }),\n { concurrency: \"unbounded\" },\n );\n\n yield* Ref.set(activePlugins, new Set());\n }).pipe(Effect.catchAll((error) => Effect.logWarning(\"Plugin cleanup failed\", error))),\n };\n }),\n },\n) {}\n"],"mappings":";;;;AAIA,IAAa,yBAAb,cAA4CA,cAAO,QAAgC,CAAC,CAClF,0BACA,EACE,QAAQA,cAAO,IAAI,aAAa;CAC9B,MAAM,gBAAgB,OAAOC,WAAI,qBAAK,IAAI,IAAkC,CAAC;CAE7E,OAAO;EACL,WAAgC,WAC9BA,WAAI,OAAO,gBAAgB,YACzB,IAAI,IAAI,OAAO,CAAC,CAAC,IAAI,MAAsC,CAC7D;EAEF,aAAa,WACXA,WAAI,OAAO,gBAAgB,YAAY;GACrC,MAAM,SAAS,IAAI,IAAI,OAAO;GAC9B,OAAO,OAAO,MAAM;GACpB,OAAO;EACT,CAAC;EAEH,WAAW,WACTD,cAAO,IAAI,aAAa;GAEtB,OAAOC,WAAI,OAAO,gBAAgB,YAAY;IAC5C,MAAM,SAAS,IAAI,IAAI,OAAO;IAC9B,OAAO,OAAO,MAAM;IACpB,OAAO;GACT,CAAC;GAGD,OAAO,OAAO,OACX,SAAS,CAAC,CACV,KACCD,cAAO,UAAU,UACfE,oCACE,OACA,OAAO,OAAO,IACd,QACA,mBACA,KACF,CACF,CACF;EACJ,CAAC;EAEH,eACEF,cAAO,IAAI,aAAa;GACtB,MAAM,UAAU,OAAOC,WAAI,IAAI,aAAa;GAC5C,IAAI,OAAO,YAAY,eAAe,QAAQ,KAAK,8BAA8B,KAC/E,OAAOD,cAAO,WACZ,iCAAiC,QAAQ,KAAK,kBAChD;GAGF,OAAOA,cAAO,QACZ,UACC,WACCA,cAAO,IAAI,aAAa;IACtB,OAAO,OAAO,OACX,SAAS,CAAC,CACV,KACCA,cAAO,UAAU,UACfA,cAAO,WAAW,6BAA6B,OAAO,OAAO,MAAM,KAAK,CAC1E,CACF;IACF,OAAOG,aAAM,MAAM,OAAO,OAAOC,YAAK,QAAQ,MAAS,CAAC,CAAC,CAAC,KACxDJ,cAAO,UAAU,UACfA,cAAO,WACL,oCAAoC,OAAO,OAAO,MAClD,KACF,CACF,CACF;GACF,CAAC,GACH,EAAE,aAAa,YAAY,CAC7B;GAEA,OAAOC,WAAI,IAAI,+BAAe,IAAI,IAAI,CAAC;EACzC,CAAC,CAAC,CAAC,KAAKD,cAAO,UAAU,UAAUA,cAAO,WAAW,yBAAyB,KAAK,CAAC,CAAC;CACzF;AACF,CAAC,EACH,CACF,CAAC,CAAC,CAAC"}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { PluginRuntimeError } from "../errors.cjs";
|
|
2
2
|
import { AnyPlugin, InitializedPlugin } from "../../types.cjs";
|
|
3
3
|
import { Effect } from "effect";
|
|
4
|
-
|
|
5
4
|
//#region src/runtime/services/plugin-lifecycle.service.d.ts
|
|
6
5
|
declare const PluginLifecycleService_base: Effect.Service.Class<PluginLifecycleService, "PluginLifecycleService", {
|
|
7
6
|
readonly effect: Effect.Effect<{
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin-lifecycle.service.d.cts","names":[],"sources":["../../../src/runtime/services/plugin-lifecycle.service.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"plugin-lifecycle.service.d.cts","names":[],"sources":["../../../src/runtime/services/plugin-lifecycle.service.ts"],"mappings":";;;;;;IAWmB,WAAA,UAAU,WAAS,QAAU,kBAAkB,OAAE,OAAA;IAKvC,aAAA,QAAA,kBAAkB,eAAU,OAAA;IAO9B,WAAA,QAAA,kBAAkB,eAAU,OAAA,aAA5B;;;;cAnBd,+BAA+B"}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { PluginRuntimeError } from "../errors.mjs";
|
|
2
2
|
import { AnyPlugin, InitializedPlugin } from "../../types.mjs";
|
|
3
3
|
import { Effect } from "effect";
|
|
4
|
-
|
|
5
4
|
//#region src/runtime/services/plugin-lifecycle.service.d.ts
|
|
6
5
|
declare const PluginLifecycleService_base: Effect.Service.Class<PluginLifecycleService, "PluginLifecycleService", {
|
|
7
6
|
readonly effect: Effect.Effect<{
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin-lifecycle.service.d.mts","names":[],"sources":["../../../src/runtime/services/plugin-lifecycle.service.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"plugin-lifecycle.service.d.mts","names":[],"sources":["../../../src/runtime/services/plugin-lifecycle.service.ts"],"mappings":";;;;;;IAWmB,WAAA,UAAU,WAAS,QAAU,kBAAkB,OAAE,OAAA;IAKvC,aAAA,QAAA,kBAAkB,eAAU,OAAA;IAO9B,WAAA,QAAA,kBAAkB,eAAU,OAAA,aAA5B;;;;cAnBd,+BAA+B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin-lifecycle.service.mjs","names":[],"sources":["../../../src/runtime/services/plugin-lifecycle.service.ts"],"sourcesContent":["import { Effect, Exit, Ref, Scope } from \"effect\";\nimport type { AnyPlugin, InitializedPlugin } from \"../../types\";\nimport { toPluginRuntimeError } from \"../errors\";\n\nexport class PluginLifecycleService extends Effect.Service<PluginLifecycleService>()(\n \"PluginLifecycleService\",\n {\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\n .shutdown()\n .pipe(\n Effect.mapError((error) =>\n toPluginRuntimeError(\n error,\n plugin.plugin.id,\n undefined,\n \"shutdown-plugin\",\n false,\n ),\n ),\n );\n }),\n\n cleanup: () =>\n Effect.gen(function* () {\n const plugins = yield* Ref.get(activePlugins);\n if (typeof process !== \"undefined\" && process.env?.EVERY_PLUGIN_DEBUG_SCOPES === \"1\") {\n yield* Effect.logWarning(\n `[PluginLifecycle] cleaning up ${plugins.size} active plugin(s)`,\n );\n }\n\n yield* Effect.forEach(\n plugins,\n (plugin) =>\n Effect.gen(function* () {\n yield* plugin.plugin\n .shutdown()\n .pipe(\n Effect.catchAll((error) =>\n Effect.logWarning(`Failed to shutdown plugin ${plugin.plugin.id}`, error),\n ),\n );\n yield* Scope.close(plugin.scope, Exit.succeed(undefined)).pipe(\n Effect.catchAll((error) =>\n Effect.logWarning(\n `Failed to close scope for plugin ${plugin.plugin.id}`,\n error,\n ),\n ),\n );\n }),\n { concurrency: \"unbounded\" },\n );\n\n yield* Ref.set(activePlugins, new Set());\n }).pipe(Effect.catchAll((error) => Effect.logWarning(\"Plugin cleanup failed\", error))),\n };\n }),\n },\n) {}\n"],"mappings":";;;;AAIA,IAAa,yBAAb,cAA4C,OAAO,
|
|
1
|
+
{"version":3,"file":"plugin-lifecycle.service.mjs","names":[],"sources":["../../../src/runtime/services/plugin-lifecycle.service.ts"],"sourcesContent":["import { Effect, Exit, Ref, Scope } from \"effect\";\nimport type { AnyPlugin, InitializedPlugin } from \"../../types\";\nimport { toPluginRuntimeError } from \"../errors\";\n\nexport class PluginLifecycleService extends Effect.Service<PluginLifecycleService>()(\n \"PluginLifecycleService\",\n {\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\n .shutdown()\n .pipe(\n Effect.mapError((error) =>\n toPluginRuntimeError(\n error,\n plugin.plugin.id,\n undefined,\n \"shutdown-plugin\",\n false,\n ),\n ),\n );\n }),\n\n cleanup: () =>\n Effect.gen(function* () {\n const plugins = yield* Ref.get(activePlugins);\n if (typeof process !== \"undefined\" && process.env?.EVERY_PLUGIN_DEBUG_SCOPES === \"1\") {\n yield* Effect.logWarning(\n `[PluginLifecycle] cleaning up ${plugins.size} active plugin(s)`,\n );\n }\n\n yield* Effect.forEach(\n plugins,\n (plugin) =>\n Effect.gen(function* () {\n yield* plugin.plugin\n .shutdown()\n .pipe(\n Effect.catchAll((error) =>\n Effect.logWarning(`Failed to shutdown plugin ${plugin.plugin.id}`, error),\n ),\n );\n yield* Scope.close(plugin.scope, Exit.succeed(undefined)).pipe(\n Effect.catchAll((error) =>\n Effect.logWarning(\n `Failed to close scope for plugin ${plugin.plugin.id}`,\n error,\n ),\n ),\n );\n }),\n { concurrency: \"unbounded\" },\n );\n\n yield* Ref.set(activePlugins, new Set());\n }).pipe(Effect.catchAll((error) => Effect.logWarning(\"Plugin cleanup failed\", error))),\n };\n }),\n },\n) {}\n"],"mappings":";;;;AAIA,IAAa,yBAAb,cAA4C,OAAO,QAAgC,CAAC,CAClF,0BACA,EACE,QAAQ,OAAO,IAAI,aAAa;CAC9B,MAAM,gBAAgB,OAAO,IAAI,qBAAK,IAAI,IAAkC,CAAC;CAE7E,OAAO;EACL,WAAgC,WAC9B,IAAI,OAAO,gBAAgB,YACzB,IAAI,IAAI,OAAO,CAAC,CAAC,IAAI,MAAsC,CAC7D;EAEF,aAAa,WACX,IAAI,OAAO,gBAAgB,YAAY;GACrC,MAAM,SAAS,IAAI,IAAI,OAAO;GAC9B,OAAO,OAAO,MAAM;GACpB,OAAO;EACT,CAAC;EAEH,WAAW,WACT,OAAO,IAAI,aAAa;GAEtB,OAAO,IAAI,OAAO,gBAAgB,YAAY;IAC5C,MAAM,SAAS,IAAI,IAAI,OAAO;IAC9B,OAAO,OAAO,MAAM;IACpB,OAAO;GACT,CAAC;GAGD,OAAO,OAAO,OACX,SAAS,CAAC,CACV,KACC,OAAO,UAAU,UACf,qBACE,OACA,OAAO,OAAO,IACd,QACA,mBACA,KACF,CACF,CACF;EACJ,CAAC;EAEH,eACE,OAAO,IAAI,aAAa;GACtB,MAAM,UAAU,OAAO,IAAI,IAAI,aAAa;GAC5C,IAAI,OAAO,YAAY,eAAe,QAAQ,KAAK,8BAA8B,KAC/E,OAAO,OAAO,WACZ,iCAAiC,QAAQ,KAAK,kBAChD;GAGF,OAAO,OAAO,QACZ,UACC,WACC,OAAO,IAAI,aAAa;IACtB,OAAO,OAAO,OACX,SAAS,CAAC,CACV,KACC,OAAO,UAAU,UACf,OAAO,WAAW,6BAA6B,OAAO,OAAO,MAAM,KAAK,CAC1E,CACF;IACF,OAAO,MAAM,MAAM,OAAO,OAAO,KAAK,QAAQ,MAAS,CAAC,CAAC,CAAC,KACxD,OAAO,UAAU,UACf,OAAO,WACL,oCAAoC,OAAO,OAAO,MAClD,KACF,CACF,CACF;GACF,CAAC,GACH,EAAE,aAAa,YAAY,CAC7B;GAEA,OAAO,IAAI,IAAI,+BAAe,IAAI,IAAI,CAAC;EACzC,CAAC,CAAC,CAAC,KAAK,OAAO,UAAU,UAAU,OAAO,WAAW,yBAAyB,KAAK,CAAC,CAAC;CACzF;AACF,CAAC,EACH,CACF,CAAC,CAAC,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
const require_runtime = require('../../_virtual/_rolldown/runtime.cjs');
|
|
2
1
|
const require_errors = require('../errors.cjs');
|
|
2
|
+
const require_plugin = require('../../plugin.cjs');
|
|
3
3
|
const require_module_federation_service = require('./module-federation.service.cjs');
|
|
4
4
|
const require_validation = require('../validation.cjs');
|
|
5
5
|
const require_secrets_service = require('./secrets.service.cjs');
|
|
@@ -110,7 +110,7 @@ var PluginLoaderService = class extends effect.Effect.Service()("PluginLoaderSer
|
|
|
110
110
|
const context = yield* plugin.initialize({
|
|
111
111
|
variables: _variables,
|
|
112
112
|
secrets: hydratedConfig.secrets
|
|
113
|
-
}, plugins ?? {}, { buildService: (tag, layer) => effect.Layer.buildWithMemoMap(layer, memoMap, scope).pipe(effect.Effect.map((ctx) => effect.Context.get(ctx, tag))) }).pipe(effect.Effect.provideService(effect.Scope.Scope, scope), effect.Effect.tapError(() => effect.Scope.close(scope, effect.Exit.succeed(void 0)).pipe(effect.Effect.catchAll((closeError) => effect.Effect.logWarning(`Failed to close scope for plugin ${plugin.id} after initialize error`, closeError)))), effect.Effect.tapError((error) => effect.Effect.logError(`Plugin ${plugin.id} failed during initialize-plugin: ${error}`)), effect.Effect.mapError((error) => require_errors.toPluginRuntimeError(error, plugin.id, void 0, "initialize-plugin", false)));
|
|
113
|
+
}, plugins ?? {}, { buildService: (tag, layer) => effect.Layer.buildWithMemoMap(layer, memoMap, scope).pipe(effect.Effect.map((ctx) => effect.Context.get(ctx, tag))) }).pipe(effect.Effect.provideService(require_plugin.PluginIdTag, plugin.id), effect.Effect.provideService(effect.Scope.Scope, scope), effect.Effect.tapError(() => effect.Scope.close(scope, effect.Exit.succeed(void 0)).pipe(effect.Effect.catchAll((closeError) => effect.Effect.logWarning(`Failed to close scope for plugin ${plugin.id} after initialize error`, closeError)))), effect.Effect.tapError((error) => effect.Effect.logError(`Plugin ${plugin.id} failed during initialize-plugin: ${error}`)), effect.Effect.mapError((error) => require_errors.toPluginRuntimeError(error, plugin.id, void 0, "initialize-plugin", false)));
|
|
114
114
|
return {
|
|
115
115
|
plugin,
|
|
116
116
|
metadata: pluginInstance.metadata,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin-loader.service.cjs","names":["Context","Effect","PluginRuntimeError","ModuleFederationService","SecretsService","toPluginRuntimeError","validate","Scope","Layer","EffectContext","Exit"],"sources":["../../../src/runtime/services/plugin-loader.service.ts"],"sourcesContent":["import type { InferSchemaInput, InferSchemaOutput } from \"@orpc/contract\";\nimport { Context, Effect, Context as EffectContext, Exit, Layer, Scope } from \"effect\";\nimport type { z } from \"zod\";\nimport type { PluginServicesTools } from \"../../plugin\";\nimport type {\n AnyPlugin,\n AnyPluginConstructor,\n InitializedPlugin,\n LoadedPlugin,\n PluginInstance,\n PluginMetadata,\n PluginRegistry,\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 PluginRegistryTag,\n PluginRegistry\n>() {}\n\nexport class PluginMapTag extends Context.Tag(\"PluginMap\")<\n PluginMapTag,\n Record<string, AnyPluginConstructor>\n>() {}\n\nexport class RegistryService extends Effect.Service<RegistryService>()(\"RegistryService\", {\n effect: Effect.gen(function* () {\n const registry = yield* PluginRegistryTag;\n const pluginMap = yield* PluginMapTag;\n\n return {\n get: (pluginId: string) =>\n Effect.gen(function* () {\n const entry = registry[pluginId];\n\n if (!entry) {\n return yield* Effect.fail(\n new PluginRuntimeError({\n pluginId,\n operation: \"validate-plugin-id\",\n cause: new Error(`Plugin ${pluginId} not found in registry`),\n retryable: false,\n }),\n );\n }\n\n if (\"module\" in entry) {\n return {\n constructor: entry.module,\n metadata: {\n remoteUrl: entry.remote || \"\",\n version: entry.version,\n description: entry.description,\n } as PluginMetadata,\n };\n }\n\n return {\n constructor: null,\n metadata: {\n remoteUrl: entry.remote,\n version: entry.version,\n description: entry.description,\n } as PluginMetadata,\n };\n }),\n\n getModule: (pluginId: string) => Effect.succeed(pluginMap[pluginId] || null),\n };\n }),\n}) {}\n\nexport class PluginLoaderService extends Effect.Service<PluginLoaderService>()(\n \"PluginLoaderService\",\n {\n effect: Effect.gen(function* () {\n const moduleFederationService = yield* ModuleFederationService;\n const secretsService = yield* SecretsService;\n const registryService = yield* RegistryService;\n\n const resolveUrl = (baseUrl: string, version?: string): string =>\n version && version !== \"latest\" ? baseUrl.replace(\"@latest\", `@${version}`) : baseUrl;\n\n return {\n loadPlugin: (pluginId: string) =>\n Effect.gen(function* () {\n const entry = yield* registryService.get(pluginId);\n\n if (entry.constructor) {\n yield* Effect.logDebug(\"Loading plugin from direct module\", { pluginId });\n\n return {\n ctor: entry.constructor,\n metadata: entry.metadata,\n } satisfies LoadedPlugin;\n }\n\n const url = entry.metadata.remoteUrl;\n if (!url) {\n return yield* Effect.fail(\n new PluginRuntimeError({\n pluginId,\n operation: \"load-plugin\",\n cause: new Error(`Plugin ${pluginId} has no module or remote URL configured`),\n retryable: false,\n }),\n );\n }\n\n const resolvedUrl = resolveUrl(url);\n\n yield* moduleFederationService.registerRemote(pluginId, resolvedUrl).pipe(\n Effect.tapError((error) =>\n Effect.logError(`Plugin ${pluginId} failed during register-remote: ${error}`),\n ),\n Effect.mapError((error) =>\n toPluginRuntimeError(error, pluginId, undefined, \"register-remote\", true),\n ),\n );\n\n yield* Effect.logDebug(\"Loading plugin from remote\", { pluginId, url: resolvedUrl });\n\n const ctor = yield* moduleFederationService\n .loadRemoteConstructor(pluginId, resolvedUrl)\n .pipe(\n Effect.tapError((error) =>\n Effect.logError(`Plugin ${pluginId} failed during load-remote: ${error}`),\n ),\n Effect.mapError((error) =>\n toPluginRuntimeError(error, pluginId, undefined, \"load-remote\", false),\n ),\n );\n\n return {\n ctor,\n metadata: entry.metadata,\n } satisfies LoadedPlugin;\n }),\n\n instantiatePlugin: <T extends AnyPlugin>(pluginId: string, loadedPlugin: LoadedPlugin<T>) =>\n Effect.gen(function* () {\n const instance = yield* Effect.try(() => new loadedPlugin.ctor()).pipe(\n Effect.tapError((error) =>\n Effect.logError(`Plugin ${pluginId} failed during instantiate-plugin: ${error}`),\n ),\n Effect.mapError((error) =>\n toPluginRuntimeError(error, pluginId, undefined, \"instantiate-plugin\", false),\n ),\n );\n\n (instance.id as string) = pluginId;\n\n return {\n plugin: instance,\n metadata: loadedPlugin.metadata,\n } satisfies PluginInstance<T>;\n }),\n\n initializePlugin: <T extends AnyPlugin>(\n pluginInstance: PluginInstance<T>,\n config: {\n variables: InferSchemaInput<T[\"configSchema\"][\"variables\"]>;\n secrets: InferSchemaInput<T[\"configSchema\"][\"secrets\"]>;\n },\n plugins?: Record<string, unknown>,\n ) =>\n Effect.gen(function* () {\n const { plugin } = pluginInstance;\n\n // Validate and hydrate config\n const validatedVariables = yield* validate(\n plugin.configSchema.variables as z.ZodSchema<\n InferSchemaOutput<T[\"configSchema\"][\"variables\"]>\n >,\n config.variables,\n plugin.id,\n \"config\",\n ).pipe(\n Effect.mapError(\n (validationError) =>\n new PluginRuntimeError({\n pluginId: plugin.id,\n operation: \"validate-config\",\n cause: validationError.zodError,\n retryable: false,\n }),\n ),\n );\n\n // Validate secrets\n const validatedSecrets = yield* validate(\n plugin.configSchema.secrets as z.ZodSchema<\n InferSchemaOutput<T[\"configSchema\"][\"secrets\"]>\n >,\n config.secrets,\n plugin.id,\n \"config\",\n ).pipe(\n Effect.mapError(\n (validationError) =>\n new PluginRuntimeError({\n pluginId: plugin.id,\n operation: \"validate-secrets\",\n cause: validationError.zodError,\n retryable: false,\n }),\n ),\n );\n\n // Hydrate secrets in variables\n const hydratedConfig = yield* secretsService.hydrateSecrets({\n variables: validatedVariables,\n secrets: validatedSecrets,\n });\n\n const _variables = yield* validate(\n plugin.configSchema.variables as z.ZodSchema<\n InferSchemaOutput<T[\"configSchema\"][\"variables\"]>\n >,\n hydratedConfig.variables,\n plugin.id,\n \"config\",\n ).pipe(\n Effect.mapError(\n (validationError) =>\n new PluginRuntimeError({\n pluginId: plugin.id,\n operation: \"validate-hydrated-config\",\n cause: validationError.zodError,\n retryable: false,\n }),\n ),\n );\n\n // Create a long-lived scope for this plugin instance\n const scope = yield* Scope.make();\n\n // Create a per-plugin MemoMap so tool-built layers are memoized\n const memoMap = yield* Layer.makeMemoMap;\n\n const tools: PluginServicesTools = {\n buildService: (tag: any, layer: any) =>\n (Layer.buildWithMemoMap(layer, memoMap, scope) as any).pipe(\n Effect.map((ctx: any) => EffectContext.get(ctx, tag)) as any,\n ),\n };\n\n // Initialize plugin within the scope.\n // If initialize fails, close the scope immediately so scoped\n // resources (DB pools, caches) are released — otherwise every\n // failed initialization leaks until the process exits.\n const context = yield* plugin\n .initialize(\n { variables: _variables, secrets: hydratedConfig.secrets },\n plugins ?? {},\n tools,\n )\n .pipe(\n Effect.provideService(Scope.Scope, scope),\n Effect.tapError(() =>\n Scope.close(scope, Exit.succeed(undefined)).pipe(\n Effect.catchAll((closeError) =>\n Effect.logWarning(\n `Failed to close scope for plugin ${plugin.id} after initialize error`,\n closeError,\n ),\n ),\n ),\n ),\n Effect.tapError((error) =>\n Effect.logError(`Plugin ${plugin.id} failed during initialize-plugin: ${error}`),\n ),\n Effect.mapError((error) =>\n toPluginRuntimeError(error, plugin.id, undefined, \"initialize-plugin\", false),\n ),\n );\n\n return {\n plugin,\n metadata: pluginInstance.metadata,\n config: { variables: _variables, secrets: hydratedConfig.secrets },\n context,\n scope,\n } satisfies InitializedPlugin<T>;\n }),\n };\n }),\n },\n) {}\n"],"mappings":";;;;;;;;AAkBA,IAAa,oBAAb,cAAuCA,eAAQ,IAAI,iBAAiB,EAGjE,CAAC;AAEJ,IAAa,eAAb,cAAkCA,eAAQ,IAAI,YAAY,EAGvD,CAAC;AAEJ,IAAa,kBAAb,cAAqCC,cAAO,SAA0B,CAAC,mBAAmB,EACxF,QAAQA,cAAO,IAAI,aAAa;CAC9B,MAAM,WAAW,OAAO;CACxB,MAAM,YAAY,OAAO;AAEzB,QAAO;EACL,MAAM,aACJA,cAAO,IAAI,aAAa;GACtB,MAAM,QAAQ,SAAS;AAEvB,OAAI,CAAC,MACH,QAAO,OAAOA,cAAO,KACnB,IAAIC,kCAAmB;IACrB;IACA,WAAW;IACX,uBAAO,IAAI,MAAM,UAAU,SAAS,wBAAwB;IAC5D,WAAW;IACZ,CAAC,CACH;AAGH,OAAI,YAAY,MACd,QAAO;IACL,aAAa,MAAM;IACnB,UAAU;KACR,WAAW,MAAM,UAAU;KAC3B,SAAS,MAAM;KACf,aAAa,MAAM;KACpB;IACF;AAGH,UAAO;IACL,aAAa;IACb,UAAU;KACR,WAAW,MAAM;KACjB,SAAS,MAAM;KACf,aAAa,MAAM;KACpB;IACF;IACD;EAEJ,YAAY,aAAqBD,cAAO,QAAQ,UAAU,aAAa,KAAK;EAC7E;EACD,EACH,CAAC,CAAC;AAEH,IAAa,sBAAb,cAAyCA,cAAO,SAA8B,CAC5E,uBACA,EACE,QAAQA,cAAO,I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,KACrDP,cAAO,KAAK,QAAaQ,eAAc,IAAI,KAAK,IAAI,CAAC,CACtD,EAWI,CACN,CACA,KACCR,cAAO,eAAeM,aAAM,OAAO,MAAM,EACzCN,cAAO,eACLM,aAAM,MAAM,OAAOG,YAAK,QAAQ,OAAU,CAAC,CAAC,KAC1CT,cAAO,UAAU,eACfA,cAAO,WACL,oCAAoC,OAAO,GAAG,0BAC9C,WACD,CACF,CACF,CACF,EACDA,cAAO,UAAU,UACfA,cAAO,SAAS,UAAU,OAAO,GAAG,oCAAoC,QAAQ,CACjF,EACDA,cAAO,UAAU,UACfI,oCAAqB,OAAO,OAAO,IAAI,QAAW,qBAAqB,MAAM,CAC9E,CACF;AAEH,UAAO;IACL;IACA,UAAU,eAAe;IACzB,QAAQ;KAAE,WAAW;KAAY,SAAS,eAAe;KAAS;IAClE;IACA;IACD;IACD;EACL;EACD,EACH,CACF,CAAC"}
|
|
1
|
+
{"version":3,"file":"plugin-loader.service.cjs","names":["Context","Effect","PluginRuntimeError","ModuleFederationService","SecretsService","toPluginRuntimeError","validate","Scope","Layer","EffectContext","PluginIdTag","Exit"],"sources":["../../../src/runtime/services/plugin-loader.service.ts"],"sourcesContent":["import type { InferSchemaInput, InferSchemaOutput } from \"@orpc/contract\";\nimport { Context, Effect, Context as EffectContext, Exit, Layer, Scope } from \"effect\";\nimport type { z } from \"zod\";\nimport { PluginIdTag, type PluginServicesTools } from \"../../plugin\";\nimport type {\n AnyPlugin,\n AnyPluginConstructor,\n InitializedPlugin,\n LoadedPlugin,\n PluginInstance,\n PluginMetadata,\n PluginRegistry,\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 PluginRegistryTag,\n PluginRegistry\n>() {}\n\nexport class PluginMapTag extends Context.Tag(\"PluginMap\")<\n PluginMapTag,\n Record<string, AnyPluginConstructor>\n>() {}\n\nexport class RegistryService extends Effect.Service<RegistryService>()(\"RegistryService\", {\n effect: Effect.gen(function* () {\n const registry = yield* PluginRegistryTag;\n const pluginMap = yield* PluginMapTag;\n\n return {\n get: (pluginId: string) =>\n Effect.gen(function* () {\n const entry = registry[pluginId];\n\n if (!entry) {\n return yield* Effect.fail(\n new PluginRuntimeError({\n pluginId,\n operation: \"validate-plugin-id\",\n cause: new Error(`Plugin ${pluginId} not found in registry`),\n retryable: false,\n }),\n );\n }\n\n if (\"module\" in entry) {\n return {\n constructor: entry.module,\n metadata: {\n remoteUrl: entry.remote || \"\",\n version: entry.version,\n description: entry.description,\n } as PluginMetadata,\n };\n }\n\n return {\n constructor: null,\n metadata: {\n remoteUrl: entry.remote,\n version: entry.version,\n description: entry.description,\n } as PluginMetadata,\n };\n }),\n\n getModule: (pluginId: string) => Effect.succeed(pluginMap[pluginId] || null),\n };\n }),\n}) {}\n\nexport class PluginLoaderService extends Effect.Service<PluginLoaderService>()(\n \"PluginLoaderService\",\n {\n effect: Effect.gen(function* () {\n const moduleFederationService = yield* ModuleFederationService;\n const secretsService = yield* SecretsService;\n const registryService = yield* RegistryService;\n\n const resolveUrl = (baseUrl: string, version?: string): string =>\n version && version !== \"latest\" ? baseUrl.replace(\"@latest\", `@${version}`) : baseUrl;\n\n return {\n loadPlugin: (pluginId: string) =>\n Effect.gen(function* () {\n const entry = yield* registryService.get(pluginId);\n\n if (entry.constructor) {\n yield* Effect.logDebug(\"Loading plugin from direct module\", { pluginId });\n\n return {\n ctor: entry.constructor,\n metadata: entry.metadata,\n } satisfies LoadedPlugin;\n }\n\n const url = entry.metadata.remoteUrl;\n if (!url) {\n return yield* Effect.fail(\n new PluginRuntimeError({\n pluginId,\n operation: \"load-plugin\",\n cause: new Error(`Plugin ${pluginId} has no module or remote URL configured`),\n retryable: false,\n }),\n );\n }\n\n const resolvedUrl = resolveUrl(url);\n\n yield* moduleFederationService.registerRemote(pluginId, resolvedUrl).pipe(\n Effect.tapError((error) =>\n Effect.logError(`Plugin ${pluginId} failed during register-remote: ${error}`),\n ),\n Effect.mapError((error) =>\n toPluginRuntimeError(error, pluginId, undefined, \"register-remote\", true),\n ),\n );\n\n yield* Effect.logDebug(\"Loading plugin from remote\", { pluginId, url: resolvedUrl });\n\n const ctor = yield* moduleFederationService\n .loadRemoteConstructor(pluginId, resolvedUrl)\n .pipe(\n Effect.tapError((error) =>\n Effect.logError(`Plugin ${pluginId} failed during load-remote: ${error}`),\n ),\n Effect.mapError((error) =>\n toPluginRuntimeError(error, pluginId, undefined, \"load-remote\", false),\n ),\n );\n\n return {\n ctor,\n metadata: entry.metadata,\n } satisfies LoadedPlugin;\n }),\n\n instantiatePlugin: <T extends AnyPlugin>(pluginId: string, loadedPlugin: LoadedPlugin<T>) =>\n Effect.gen(function* () {\n const instance = yield* Effect.try(() => new loadedPlugin.ctor()).pipe(\n Effect.tapError((error) =>\n Effect.logError(`Plugin ${pluginId} failed during instantiate-plugin: ${error}`),\n ),\n Effect.mapError((error) =>\n toPluginRuntimeError(error, pluginId, undefined, \"instantiate-plugin\", false),\n ),\n );\n\n (instance.id as string) = pluginId;\n\n return {\n plugin: instance,\n metadata: loadedPlugin.metadata,\n } satisfies PluginInstance<T>;\n }),\n\n initializePlugin: <T extends AnyPlugin>(\n pluginInstance: PluginInstance<T>,\n config: {\n variables: InferSchemaInput<T[\"configSchema\"][\"variables\"]>;\n secrets: InferSchemaInput<T[\"configSchema\"][\"secrets\"]>;\n },\n plugins?: Record<string, unknown>,\n ) =>\n Effect.gen(function* () {\n const { plugin } = pluginInstance;\n\n // Validate and hydrate config\n const validatedVariables = yield* validate(\n plugin.configSchema.variables as z.ZodSchema<\n InferSchemaOutput<T[\"configSchema\"][\"variables\"]>\n >,\n config.variables,\n plugin.id,\n \"config\",\n ).pipe(\n Effect.mapError(\n (validationError) =>\n new PluginRuntimeError({\n pluginId: plugin.id,\n operation: \"validate-config\",\n cause: validationError.zodError,\n retryable: false,\n }),\n ),\n );\n\n // Validate secrets\n const validatedSecrets = yield* validate(\n plugin.configSchema.secrets as z.ZodSchema<\n InferSchemaOutput<T[\"configSchema\"][\"secrets\"]>\n >,\n config.secrets,\n plugin.id,\n \"config\",\n ).pipe(\n Effect.mapError(\n (validationError) =>\n new PluginRuntimeError({\n pluginId: plugin.id,\n operation: \"validate-secrets\",\n cause: validationError.zodError,\n retryable: false,\n }),\n ),\n );\n\n // Hydrate secrets in variables\n const hydratedConfig = yield* secretsService.hydrateSecrets({\n variables: validatedVariables,\n secrets: validatedSecrets,\n });\n\n const _variables = yield* validate(\n plugin.configSchema.variables as z.ZodSchema<\n InferSchemaOutput<T[\"configSchema\"][\"variables\"]>\n >,\n hydratedConfig.variables,\n plugin.id,\n \"config\",\n ).pipe(\n Effect.mapError(\n (validationError) =>\n new PluginRuntimeError({\n pluginId: plugin.id,\n operation: \"validate-hydrated-config\",\n cause: validationError.zodError,\n retryable: false,\n }),\n ),\n );\n\n // Create a long-lived scope for this plugin instance\n const scope = yield* Scope.make();\n\n // Create a per-plugin MemoMap so tool-built layers are memoized\n const memoMap = yield* Layer.makeMemoMap;\n\n const tools: PluginServicesTools = {\n buildService: (tag: any, layer: any) =>\n (Layer.buildWithMemoMap(layer, memoMap, scope) as any).pipe(\n Effect.map((ctx: any) => EffectContext.get(ctx, tag)) as any,\n ),\n };\n\n // Initialize plugin within the scope.\n // If initialize fails, close the scope immediately so scoped\n // resources (DB pools, caches) are released — otherwise every\n // failed initialization leaks until the process exits.\n const context = yield* plugin\n .initialize(\n { variables: _variables, secrets: hydratedConfig.secrets },\n plugins ?? {},\n tools,\n )\n .pipe(\n Effect.provideService(PluginIdTag, plugin.id),\n Effect.provideService(Scope.Scope, scope),\n Effect.tapError(() =>\n Scope.close(scope, Exit.succeed(undefined)).pipe(\n Effect.catchAll((closeError) =>\n Effect.logWarning(\n `Failed to close scope for plugin ${plugin.id} after initialize error`,\n closeError,\n ),\n ),\n ),\n ),\n Effect.tapError((error) =>\n Effect.logError(`Plugin ${plugin.id} failed during initialize-plugin: ${error}`),\n ),\n Effect.mapError((error) =>\n toPluginRuntimeError(error, plugin.id, undefined, \"initialize-plugin\", false),\n ),\n );\n\n return {\n plugin,\n metadata: pluginInstance.metadata,\n config: { variables: _variables, secrets: hydratedConfig.secrets },\n context,\n scope,\n } satisfies InitializedPlugin<T>;\n }),\n };\n }),\n },\n) {}\n"],"mappings":";;;;;;;;AAkBA,IAAa,oBAAb,cAAuCA,eAAQ,IAAI,gBAAgB,CAAC,CAGlE,CAAC,CAAC,CAAC;AAEL,IAAa,eAAb,cAAkCA,eAAQ,IAAI,WAAW,CAAC,CAGxD,CAAC,CAAC,CAAC;AAEL,IAAa,kBAAb,cAAqCC,cAAO,QAAyB,CAAC,CAAC,mBAAmB,EACxF,QAAQA,cAAO,IAAI,aAAa;CAC9B,MAAM,WAAW,OAAO;CACxB,MAAM,YAAY,OAAO;CAEzB,OAAO;EACL,MAAM,aACJA,cAAO,IAAI,aAAa;GACtB,MAAM,QAAQ,SAAS;GAEvB,IAAI,CAAC,OACH,OAAO,OAAOA,cAAO,KACnB,IAAIC,kCAAmB;IACrB;IACA,WAAW;IACX,uBAAO,IAAI,MAAM,UAAU,SAAS,uBAAuB;IAC3D,WAAW;GACb,CAAC,CACH;GAGF,IAAI,YAAY,OACd,OAAO;IACL,aAAa,MAAM;IACnB,UAAU;KACR,WAAW,MAAM,UAAU;KAC3B,SAAS,MAAM;KACf,aAAa,MAAM;IACrB;GACF;GAGF,OAAO;IACL,aAAa;IACb,UAAU;KACR,WAAW,MAAM;KACjB,SAAS,MAAM;KACf,aAAa,MAAM;IACrB;GACF;EACF,CAAC;EAEH,YAAY,aAAqBD,cAAO,QAAQ,UAAU,aAAa,IAAI;CAC7E;AACF,CAAC,EACH,CAAC,CAAC,CAAC,CAAC;AAEJ,IAAa,sBAAb,cAAyCA,cAAO,QAA6B,CAAC,CAC5E,uBACA,EACE,QAAQA,cAAO,IAAI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BA,aAAM,iBAAiB,OAAO,SAAS,KAAK,CAAC,CAAS,KACrDP,cAAO,KAAK,QAAaQ,eAAc,IAAI,KAAK,GAAG,CAAC,CACtD,EAWI,CACN,CAAC,CACA,KACCR,cAAO,eAAeS,4BAAa,OAAO,EAAE,GAC5CT,cAAO,eAAeM,aAAM,OAAO,KAAK,GACxCN,cAAO,eACLM,aAAM,MAAM,OAAOI,YAAK,QAAQ,MAAS,CAAC,CAAC,CAAC,KAC1CV,cAAO,UAAU,eACfA,cAAO,WACL,oCAAoC,OAAO,GAAG,0BAC9C,UACF,CACF,CACF,CACF,GACAA,cAAO,UAAU,UACfA,cAAO,SAAS,UAAU,OAAO,GAAG,oCAAoC,OAAO,CACjF,GACAA,cAAO,UAAU,UACfI,oCAAqB,OAAO,OAAO,IAAI,QAAW,qBAAqB,KAAK,CAC9E,CACF;GAEF,OAAO;IACL;IACA,UAAU,eAAe;IACzB,QAAQ;KAAE,WAAW;KAAY,SAAS,eAAe;IAAQ;IACjE;IACA;GACF;EACF,CAAC;CACL;AACF,CAAC,EACH,CACF,CAAC,CAAC,CAAC"}
|
|
@@ -4,7 +4,6 @@ import { ModuleFederationService } from "./module-federation.service.cjs";
|
|
|
4
4
|
import { SecretsService } from "./secrets.service.cjs";
|
|
5
5
|
import { Context, Effect, Scope } from "effect";
|
|
6
6
|
import { InferSchemaInput, InferSchemaOutput } from "@orpc/contract";
|
|
7
|
-
|
|
8
7
|
//#region src/runtime/services/plugin-loader.service.d.ts
|
|
9
8
|
declare const PluginRegistryTag_base: Context.TagClass<PluginRegistryTag, "PluginRegistry", PluginRegistry>;
|
|
10
9
|
declare class PluginRegistryTag extends PluginRegistryTag_base {}
|
|
@@ -50,5 +49,5 @@ declare const PluginLoaderService_base: Effect.Service.Class<PluginLoaderService
|
|
|
50
49
|
}>;
|
|
51
50
|
declare class PluginLoaderService extends PluginLoaderService_base {}
|
|
52
51
|
//#endregion
|
|
53
|
-
export { PluginLoaderService };
|
|
52
|
+
export { PluginLoaderService, PluginMapTag, PluginRegistryTag, RegistryService };
|
|
54
53
|
//# sourceMappingURL=plugin-loader.service.d.cts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin-loader.service.d.cts","names":[],"sources":["../../../src/runtime/services/plugin-loader.service.ts"],"mappings":";;;;;;;;
|
|
1
|
+
{"version":3,"file":"plugin-loader.service.d.cts","names":[],"sources":["../../../src/runtime/services/plugin-loader.service.ts"],"mappings":";;;;;;;;cAkBa,0BAA0B;;cAK1B,qBAAqB;;;IAWZ,MAAA,qBAAM,OAAA;;MAsBT,UAAA;;;MAUF,UAAA;;IAIW,YAAA,qBAAM,OAAA,OAAA;;;cA1CrB,wBAAwB;;;IA2DN,aAAA,qBAAM,OAAA;;;;IAuDT,oBAAA,UAAU,WAAS,kBAAkB,cAAgB,aAAa,OAAE,OAAA;;;;IAmBrE,mBAAA,UAAU,WAAS,gBACpB,eAAe,IAAE;MAE/B,WAAW,iBAAiB;MAC5B,SAAS,iBAAiB;OAC3B,UACS,4BAAuB,OAAA;;;;;;;;;;;;cA5F9B,4BAA4B"}
|
|
@@ -4,7 +4,6 @@ import { ModuleFederationService } from "./module-federation.service.mjs";
|
|
|
4
4
|
import { SecretsService } from "./secrets.service.mjs";
|
|
5
5
|
import { InferSchemaInput, InferSchemaOutput } from "@orpc/contract";
|
|
6
6
|
import { Context, Effect, Scope } from "effect";
|
|
7
|
-
|
|
8
7
|
//#region src/runtime/services/plugin-loader.service.d.ts
|
|
9
8
|
declare const PluginRegistryTag_base: Context.TagClass<PluginRegistryTag, "PluginRegistry", PluginRegistry>;
|
|
10
9
|
declare class PluginRegistryTag extends PluginRegistryTag_base {}
|
|
@@ -50,5 +49,5 @@ declare const PluginLoaderService_base: Effect.Service.Class<PluginLoaderService
|
|
|
50
49
|
}>;
|
|
51
50
|
declare class PluginLoaderService extends PluginLoaderService_base {}
|
|
52
51
|
//#endregion
|
|
53
|
-
export { PluginLoaderService };
|
|
52
|
+
export { PluginLoaderService, PluginMapTag, PluginRegistryTag, RegistryService };
|
|
54
53
|
//# sourceMappingURL=plugin-loader.service.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin-loader.service.d.mts","names":[],"sources":["../../../src/runtime/services/plugin-loader.service.ts"],"mappings":";;;;;;;;
|
|
1
|
+
{"version":3,"file":"plugin-loader.service.d.mts","names":[],"sources":["../../../src/runtime/services/plugin-loader.service.ts"],"mappings":";;;;;;;;cAkBa,0BAA0B;;cAK1B,qBAAqB;;;IAWZ,MAAA,qBAAM,OAAA;;MAsBT,UAAA;;;MAUF,UAAA;;IAIW,YAAA,qBAAM,OAAA,OAAA;;;cA1CrB,wBAAwB;;;IA2DN,aAAA,qBAAM,OAAA;;;;IAuDT,oBAAA,UAAU,WAAS,kBAAkB,cAAgB,aAAa,OAAE,OAAA;;;;IAmBrE,mBAAA,UAAU,WAAS,gBACpB,eAAe,IAAE;MAE/B,WAAW,iBAAiB;MAC5B,SAAS,iBAAiB;OAC3B,UACS,4BAAuB,OAAA;;;;;;;;;;;;cA5F9B,4BAA4B"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { PluginRuntimeError, toPluginRuntimeError } from "../errors.mjs";
|
|
2
|
+
import { PluginIdTag } from "../../plugin.mjs";
|
|
2
3
|
import { ModuleFederationService } from "./module-federation.service.mjs";
|
|
3
4
|
import { validate } from "../validation.mjs";
|
|
4
5
|
import { SecretsService } from "./secrets.service.mjs";
|
|
@@ -109,7 +110,7 @@ var PluginLoaderService = class extends Effect.Service()("PluginLoaderService",
|
|
|
109
110
|
const context = yield* plugin.initialize({
|
|
110
111
|
variables: _variables,
|
|
111
112
|
secrets: hydratedConfig.secrets
|
|
112
|
-
}, plugins ?? {}, { buildService: (tag, layer) => Layer.buildWithMemoMap(layer, memoMap, scope).pipe(Effect.map((ctx) => Context.get(ctx, tag))) }).pipe(Effect.provideService(Scope.Scope, scope), Effect.tapError(() => Scope.close(scope, Exit.succeed(void 0)).pipe(Effect.catchAll((closeError) => Effect.logWarning(`Failed to close scope for plugin ${plugin.id} after initialize error`, closeError)))), Effect.tapError((error) => Effect.logError(`Plugin ${plugin.id} failed during initialize-plugin: ${error}`)), Effect.mapError((error) => toPluginRuntimeError(error, plugin.id, void 0, "initialize-plugin", false)));
|
|
113
|
+
}, plugins ?? {}, { buildService: (tag, layer) => Layer.buildWithMemoMap(layer, memoMap, scope).pipe(Effect.map((ctx) => Context.get(ctx, tag))) }).pipe(Effect.provideService(PluginIdTag, plugin.id), Effect.provideService(Scope.Scope, scope), Effect.tapError(() => Scope.close(scope, Exit.succeed(void 0)).pipe(Effect.catchAll((closeError) => Effect.logWarning(`Failed to close scope for plugin ${plugin.id} after initialize error`, closeError)))), Effect.tapError((error) => Effect.logError(`Plugin ${plugin.id} failed during initialize-plugin: ${error}`)), Effect.mapError((error) => toPluginRuntimeError(error, plugin.id, void 0, "initialize-plugin", false)));
|
|
113
114
|
return {
|
|
114
115
|
plugin,
|
|
115
116
|
metadata: pluginInstance.metadata,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin-loader.service.mjs","names":["EffectContext"],"sources":["../../../src/runtime/services/plugin-loader.service.ts"],"sourcesContent":["import type { InferSchemaInput, InferSchemaOutput } from \"@orpc/contract\";\nimport { Context, Effect, Context as EffectContext, Exit, Layer, Scope } from \"effect\";\nimport type { z } from \"zod\";\nimport type { PluginServicesTools } from \"../../plugin\";\nimport type {\n AnyPlugin,\n AnyPluginConstructor,\n InitializedPlugin,\n LoadedPlugin,\n PluginInstance,\n PluginMetadata,\n PluginRegistry,\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 PluginRegistryTag,\n PluginRegistry\n>() {}\n\nexport class PluginMapTag extends Context.Tag(\"PluginMap\")<\n PluginMapTag,\n Record<string, AnyPluginConstructor>\n>() {}\n\nexport class RegistryService extends Effect.Service<RegistryService>()(\"RegistryService\", {\n effect: Effect.gen(function* () {\n const registry = yield* PluginRegistryTag;\n const pluginMap = yield* PluginMapTag;\n\n return {\n get: (pluginId: string) =>\n Effect.gen(function* () {\n const entry = registry[pluginId];\n\n if (!entry) {\n return yield* Effect.fail(\n new PluginRuntimeError({\n pluginId,\n operation: \"validate-plugin-id\",\n cause: new Error(`Plugin ${pluginId} not found in registry`),\n retryable: false,\n }),\n );\n }\n\n if (\"module\" in entry) {\n return {\n constructor: entry.module,\n metadata: {\n remoteUrl: entry.remote || \"\",\n version: entry.version,\n description: entry.description,\n } as PluginMetadata,\n };\n }\n\n return {\n constructor: null,\n metadata: {\n remoteUrl: entry.remote,\n version: entry.version,\n description: entry.description,\n } as PluginMetadata,\n };\n }),\n\n getModule: (pluginId: string) => Effect.succeed(pluginMap[pluginId] || null),\n };\n }),\n}) {}\n\nexport class PluginLoaderService extends Effect.Service<PluginLoaderService>()(\n \"PluginLoaderService\",\n {\n effect: Effect.gen(function* () {\n const moduleFederationService = yield* ModuleFederationService;\n const secretsService = yield* SecretsService;\n const registryService = yield* RegistryService;\n\n const resolveUrl = (baseUrl: string, version?: string): string =>\n version && version !== \"latest\" ? baseUrl.replace(\"@latest\", `@${version}`) : baseUrl;\n\n return {\n loadPlugin: (pluginId: string) =>\n Effect.gen(function* () {\n const entry = yield* registryService.get(pluginId);\n\n if (entry.constructor) {\n yield* Effect.logDebug(\"Loading plugin from direct module\", { pluginId });\n\n return {\n ctor: entry.constructor,\n metadata: entry.metadata,\n } satisfies LoadedPlugin;\n }\n\n const url = entry.metadata.remoteUrl;\n if (!url) {\n return yield* Effect.fail(\n new PluginRuntimeError({\n pluginId,\n operation: \"load-plugin\",\n cause: new Error(`Plugin ${pluginId} has no module or remote URL configured`),\n retryable: false,\n }),\n );\n }\n\n const resolvedUrl = resolveUrl(url);\n\n yield* moduleFederationService.registerRemote(pluginId, resolvedUrl).pipe(\n Effect.tapError((error) =>\n Effect.logError(`Plugin ${pluginId} failed during register-remote: ${error}`),\n ),\n Effect.mapError((error) =>\n toPluginRuntimeError(error, pluginId, undefined, \"register-remote\", true),\n ),\n );\n\n yield* Effect.logDebug(\"Loading plugin from remote\", { pluginId, url: resolvedUrl });\n\n const ctor = yield* moduleFederationService\n .loadRemoteConstructor(pluginId, resolvedUrl)\n .pipe(\n Effect.tapError((error) =>\n Effect.logError(`Plugin ${pluginId} failed during load-remote: ${error}`),\n ),\n Effect.mapError((error) =>\n toPluginRuntimeError(error, pluginId, undefined, \"load-remote\", false),\n ),\n );\n\n return {\n ctor,\n metadata: entry.metadata,\n } satisfies LoadedPlugin;\n }),\n\n instantiatePlugin: <T extends AnyPlugin>(pluginId: string, loadedPlugin: LoadedPlugin<T>) =>\n Effect.gen(function* () {\n const instance = yield* Effect.try(() => new loadedPlugin.ctor()).pipe(\n Effect.tapError((error) =>\n Effect.logError(`Plugin ${pluginId} failed during instantiate-plugin: ${error}`),\n ),\n Effect.mapError((error) =>\n toPluginRuntimeError(error, pluginId, undefined, \"instantiate-plugin\", false),\n ),\n );\n\n (instance.id as string) = pluginId;\n\n return {\n plugin: instance,\n metadata: loadedPlugin.metadata,\n } satisfies PluginInstance<T>;\n }),\n\n initializePlugin: <T extends AnyPlugin>(\n pluginInstance: PluginInstance<T>,\n config: {\n variables: InferSchemaInput<T[\"configSchema\"][\"variables\"]>;\n secrets: InferSchemaInput<T[\"configSchema\"][\"secrets\"]>;\n },\n plugins?: Record<string, unknown>,\n ) =>\n Effect.gen(function* () {\n const { plugin } = pluginInstance;\n\n // Validate and hydrate config\n const validatedVariables = yield* validate(\n plugin.configSchema.variables as z.ZodSchema<\n InferSchemaOutput<T[\"configSchema\"][\"variables\"]>\n >,\n config.variables,\n plugin.id,\n \"config\",\n ).pipe(\n Effect.mapError(\n (validationError) =>\n new PluginRuntimeError({\n pluginId: plugin.id,\n operation: \"validate-config\",\n cause: validationError.zodError,\n retryable: false,\n }),\n ),\n );\n\n // Validate secrets\n const validatedSecrets = yield* validate(\n plugin.configSchema.secrets as z.ZodSchema<\n InferSchemaOutput<T[\"configSchema\"][\"secrets\"]>\n >,\n config.secrets,\n plugin.id,\n \"config\",\n ).pipe(\n Effect.mapError(\n (validationError) =>\n new PluginRuntimeError({\n pluginId: plugin.id,\n operation: \"validate-secrets\",\n cause: validationError.zodError,\n retryable: false,\n }),\n ),\n );\n\n // Hydrate secrets in variables\n const hydratedConfig = yield* secretsService.hydrateSecrets({\n variables: validatedVariables,\n secrets: validatedSecrets,\n });\n\n const _variables = yield* validate(\n plugin.configSchema.variables as z.ZodSchema<\n InferSchemaOutput<T[\"configSchema\"][\"variables\"]>\n >,\n hydratedConfig.variables,\n plugin.id,\n \"config\",\n ).pipe(\n Effect.mapError(\n (validationError) =>\n new PluginRuntimeError({\n pluginId: plugin.id,\n operation: \"validate-hydrated-config\",\n cause: validationError.zodError,\n retryable: false,\n }),\n ),\n );\n\n // Create a long-lived scope for this plugin instance\n const scope = yield* Scope.make();\n\n // Create a per-plugin MemoMap so tool-built layers are memoized\n const memoMap = yield* Layer.makeMemoMap;\n\n const tools: PluginServicesTools = {\n buildService: (tag: any, layer: any) =>\n (Layer.buildWithMemoMap(layer, memoMap, scope) as any).pipe(\n Effect.map((ctx: any) => EffectContext.get(ctx, tag)) as any,\n ),\n };\n\n // Initialize plugin within the scope.\n // If initialize fails, close the scope immediately so scoped\n // resources (DB pools, caches) are released — otherwise every\n // failed initialization leaks until the process exits.\n const context = yield* plugin\n .initialize(\n { variables: _variables, secrets: hydratedConfig.secrets },\n plugins ?? {},\n tools,\n )\n .pipe(\n Effect.provideService(Scope.Scope, scope),\n Effect.tapError(() =>\n Scope.close(scope, Exit.succeed(undefined)).pipe(\n Effect.catchAll((closeError) =>\n Effect.logWarning(\n `Failed to close scope for plugin ${plugin.id} after initialize error`,\n closeError,\n ),\n ),\n ),\n ),\n Effect.tapError((error) =>\n Effect.logError(`Plugin ${plugin.id} failed during initialize-plugin: ${error}`),\n ),\n Effect.mapError((error) =>\n toPluginRuntimeError(error, plugin.id, undefined, \"initialize-plugin\", false),\n ),\n );\n\n return {\n plugin,\n metadata: pluginInstance.metadata,\n config: { variables: _variables, secrets: hydratedConfig.secrets },\n context,\n scope,\n } satisfies InitializedPlugin<T>;\n }),\n };\n }),\n },\n) {}\n"],"mappings":";;;;;;;AAkBA,IAAa,oBAAb,cAAuC,QAAQ,IAAI,iBAAiB,EAGjE,CAAC;AAEJ,IAAa,eAAb,cAAkC,QAAQ,IAAI,YAAY,EAGvD,CAAC;AAEJ,IAAa,kBAAb,cAAqC,OAAO,SAA0B,CAAC,mBAAmB,EACxF,QAAQ,OAAO,IAAI,aAAa;CAC9B,MAAM,WAAW,OAAO;CACxB,MAAM,YAAY,OAAO;AAEzB,QAAO;EACL,MAAM,aACJ,OAAO,IAAI,aAAa;GACtB,MAAM,QAAQ,SAAS;AAEvB,OAAI,CAAC,MACH,QAAO,OAAO,OAAO,KACnB,IAAI,mBAAmB;IACrB;IACA,WAAW;IACX,uBAAO,IAAI,MAAM,UAAU,SAAS,wBAAwB;IAC5D,WAAW;IACZ,CAAC,CACH;AAGH,OAAI,YAAY,MACd,QAAO;IACL,aAAa,MAAM;IACnB,UAAU;KACR,WAAW,MAAM,UAAU;KAC3B,SAAS,MAAM;KACf,aAAa,MAAM;KACpB;IACF;AAGH,UAAO;IACL,aAAa;IACb,UAAU;KACR,WAAW,MAAM;KACjB,SAAS,MAAM;KACf,aAAa,MAAM;KACpB;IACF;IACD;EAEJ,YAAY,aAAqB,OAAO,QAAQ,UAAU,aAAa,KAAK;EAC7E;EACD,EACH,CAAC,CAAC;AAEH,IAAa,sBAAb,cAAyC,OAAO,SAA8B,CAC5E,uBACA,EACE,QAAQ,OAAO,IAAI,aAAa;CAC9B,MAAM,0BAA0B,OAAO;CACvC,MAAM,iBAAiB,OAAO;CAC9B,MAAM,kBAAkB,OAAO;CAE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AAO,KAAK,QAAQ,OAAU,CAAC,CAAC,KAC1C,OAAO,UAAU,eACf,OAAO,WACL,oCAAoC,OAAO,GAAG,0BAC9C,WACD,CACF,CACF,CACF,EACD,OAAO,UAAU,UACf,OAAO,SAAS,UAAU,OAAO,GAAG,oCAAoC,QAAQ,CACjF,EACD,OAAO,UAAU,UACf,qBAAqB,OAAO,OAAO,IAAI,QAAW,qBAAqB,MAAM,CAC9E,CACF;AAEH,UAAO;IACL;IACA,UAAU,eAAe;IACzB,QAAQ;KAAE,WAAW;KAAY,SAAS,eAAe;KAAS;IAClE;IACA;IACD;IACD;EACL;EACD,EACH,CACF,CAAC"}
|
|
1
|
+
{"version":3,"file":"plugin-loader.service.mjs","names":["EffectContext"],"sources":["../../../src/runtime/services/plugin-loader.service.ts"],"sourcesContent":["import type { InferSchemaInput, InferSchemaOutput } from \"@orpc/contract\";\nimport { Context, Effect, Context as EffectContext, Exit, Layer, Scope } from \"effect\";\nimport type { z } from \"zod\";\nimport { PluginIdTag, type PluginServicesTools } from \"../../plugin\";\nimport type {\n AnyPlugin,\n AnyPluginConstructor,\n InitializedPlugin,\n LoadedPlugin,\n PluginInstance,\n PluginMetadata,\n PluginRegistry,\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 PluginRegistryTag,\n PluginRegistry\n>() {}\n\nexport class PluginMapTag extends Context.Tag(\"PluginMap\")<\n PluginMapTag,\n Record<string, AnyPluginConstructor>\n>() {}\n\nexport class RegistryService extends Effect.Service<RegistryService>()(\"RegistryService\", {\n effect: Effect.gen(function* () {\n const registry = yield* PluginRegistryTag;\n const pluginMap = yield* PluginMapTag;\n\n return {\n get: (pluginId: string) =>\n Effect.gen(function* () {\n const entry = registry[pluginId];\n\n if (!entry) {\n return yield* Effect.fail(\n new PluginRuntimeError({\n pluginId,\n operation: \"validate-plugin-id\",\n cause: new Error(`Plugin ${pluginId} not found in registry`),\n retryable: false,\n }),\n );\n }\n\n if (\"module\" in entry) {\n return {\n constructor: entry.module,\n metadata: {\n remoteUrl: entry.remote || \"\",\n version: entry.version,\n description: entry.description,\n } as PluginMetadata,\n };\n }\n\n return {\n constructor: null,\n metadata: {\n remoteUrl: entry.remote,\n version: entry.version,\n description: entry.description,\n } as PluginMetadata,\n };\n }),\n\n getModule: (pluginId: string) => Effect.succeed(pluginMap[pluginId] || null),\n };\n }),\n}) {}\n\nexport class PluginLoaderService extends Effect.Service<PluginLoaderService>()(\n \"PluginLoaderService\",\n {\n effect: Effect.gen(function* () {\n const moduleFederationService = yield* ModuleFederationService;\n const secretsService = yield* SecretsService;\n const registryService = yield* RegistryService;\n\n const resolveUrl = (baseUrl: string, version?: string): string =>\n version && version !== \"latest\" ? baseUrl.replace(\"@latest\", `@${version}`) : baseUrl;\n\n return {\n loadPlugin: (pluginId: string) =>\n Effect.gen(function* () {\n const entry = yield* registryService.get(pluginId);\n\n if (entry.constructor) {\n yield* Effect.logDebug(\"Loading plugin from direct module\", { pluginId });\n\n return {\n ctor: entry.constructor,\n metadata: entry.metadata,\n } satisfies LoadedPlugin;\n }\n\n const url = entry.metadata.remoteUrl;\n if (!url) {\n return yield* Effect.fail(\n new PluginRuntimeError({\n pluginId,\n operation: \"load-plugin\",\n cause: new Error(`Plugin ${pluginId} has no module or remote URL configured`),\n retryable: false,\n }),\n );\n }\n\n const resolvedUrl = resolveUrl(url);\n\n yield* moduleFederationService.registerRemote(pluginId, resolvedUrl).pipe(\n Effect.tapError((error) =>\n Effect.logError(`Plugin ${pluginId} failed during register-remote: ${error}`),\n ),\n Effect.mapError((error) =>\n toPluginRuntimeError(error, pluginId, undefined, \"register-remote\", true),\n ),\n );\n\n yield* Effect.logDebug(\"Loading plugin from remote\", { pluginId, url: resolvedUrl });\n\n const ctor = yield* moduleFederationService\n .loadRemoteConstructor(pluginId, resolvedUrl)\n .pipe(\n Effect.tapError((error) =>\n Effect.logError(`Plugin ${pluginId} failed during load-remote: ${error}`),\n ),\n Effect.mapError((error) =>\n toPluginRuntimeError(error, pluginId, undefined, \"load-remote\", false),\n ),\n );\n\n return {\n ctor,\n metadata: entry.metadata,\n } satisfies LoadedPlugin;\n }),\n\n instantiatePlugin: <T extends AnyPlugin>(pluginId: string, loadedPlugin: LoadedPlugin<T>) =>\n Effect.gen(function* () {\n const instance = yield* Effect.try(() => new loadedPlugin.ctor()).pipe(\n Effect.tapError((error) =>\n Effect.logError(`Plugin ${pluginId} failed during instantiate-plugin: ${error}`),\n ),\n Effect.mapError((error) =>\n toPluginRuntimeError(error, pluginId, undefined, \"instantiate-plugin\", false),\n ),\n );\n\n (instance.id as string) = pluginId;\n\n return {\n plugin: instance,\n metadata: loadedPlugin.metadata,\n } satisfies PluginInstance<T>;\n }),\n\n initializePlugin: <T extends AnyPlugin>(\n pluginInstance: PluginInstance<T>,\n config: {\n variables: InferSchemaInput<T[\"configSchema\"][\"variables\"]>;\n secrets: InferSchemaInput<T[\"configSchema\"][\"secrets\"]>;\n },\n plugins?: Record<string, unknown>,\n ) =>\n Effect.gen(function* () {\n const { plugin } = pluginInstance;\n\n // Validate and hydrate config\n const validatedVariables = yield* validate(\n plugin.configSchema.variables as z.ZodSchema<\n InferSchemaOutput<T[\"configSchema\"][\"variables\"]>\n >,\n config.variables,\n plugin.id,\n \"config\",\n ).pipe(\n Effect.mapError(\n (validationError) =>\n new PluginRuntimeError({\n pluginId: plugin.id,\n operation: \"validate-config\",\n cause: validationError.zodError,\n retryable: false,\n }),\n ),\n );\n\n // Validate secrets\n const validatedSecrets = yield* validate(\n plugin.configSchema.secrets as z.ZodSchema<\n InferSchemaOutput<T[\"configSchema\"][\"secrets\"]>\n >,\n config.secrets,\n plugin.id,\n \"config\",\n ).pipe(\n Effect.mapError(\n (validationError) =>\n new PluginRuntimeError({\n pluginId: plugin.id,\n operation: \"validate-secrets\",\n cause: validationError.zodError,\n retryable: false,\n }),\n ),\n );\n\n // Hydrate secrets in variables\n const hydratedConfig = yield* secretsService.hydrateSecrets({\n variables: validatedVariables,\n secrets: validatedSecrets,\n });\n\n const _variables = yield* validate(\n plugin.configSchema.variables as z.ZodSchema<\n InferSchemaOutput<T[\"configSchema\"][\"variables\"]>\n >,\n hydratedConfig.variables,\n plugin.id,\n \"config\",\n ).pipe(\n Effect.mapError(\n (validationError) =>\n new PluginRuntimeError({\n pluginId: plugin.id,\n operation: \"validate-hydrated-config\",\n cause: validationError.zodError,\n retryable: false,\n }),\n ),\n );\n\n // Create a long-lived scope for this plugin instance\n const scope = yield* Scope.make();\n\n // Create a per-plugin MemoMap so tool-built layers are memoized\n const memoMap = yield* Layer.makeMemoMap;\n\n const tools: PluginServicesTools = {\n buildService: (tag: any, layer: any) =>\n (Layer.buildWithMemoMap(layer, memoMap, scope) as any).pipe(\n Effect.map((ctx: any) => EffectContext.get(ctx, tag)) as any,\n ),\n };\n\n // Initialize plugin within the scope.\n // If initialize fails, close the scope immediately so scoped\n // resources (DB pools, caches) are released — otherwise every\n // failed initialization leaks until the process exits.\n const context = yield* plugin\n .initialize(\n { variables: _variables, secrets: hydratedConfig.secrets },\n plugins ?? {},\n tools,\n )\n .pipe(\n Effect.provideService(PluginIdTag, plugin.id),\n Effect.provideService(Scope.Scope, scope),\n Effect.tapError(() =>\n Scope.close(scope, Exit.succeed(undefined)).pipe(\n Effect.catchAll((closeError) =>\n Effect.logWarning(\n `Failed to close scope for plugin ${plugin.id} after initialize error`,\n closeError,\n ),\n ),\n ),\n ),\n Effect.tapError((error) =>\n Effect.logError(`Plugin ${plugin.id} failed during initialize-plugin: ${error}`),\n ),\n Effect.mapError((error) =>\n toPluginRuntimeError(error, plugin.id, undefined, \"initialize-plugin\", false),\n ),\n );\n\n return {\n plugin,\n metadata: pluginInstance.metadata,\n config: { variables: _variables, secrets: hydratedConfig.secrets },\n context,\n scope,\n } satisfies InitializedPlugin<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,eACf,OAAO,WACL,oCAAoC,OAAO,GAAG,0BAC9C,UACF,CACF,CACF,CACF,GACA,OAAO,UAAU,UACf,OAAO,SAAS,UAAU,OAAO,GAAG,oCAAoC,OAAO,CACjF,GACA,OAAO,UAAU,UACf,qBAAqB,OAAO,OAAO,IAAI,QAAW,qBAAqB,KAAK,CAC9E,CACF;GAEF,OAAO;IACL;IACA,UAAU,eAAe;IACzB,QAAQ;KAAE,WAAW;KAAY,SAAS,eAAe;IAAQ;IACjE;IACA;GACF;EACF,CAAC;CACL;AACF,CAAC,EACH,CACF,CAAC,CAAC,CAAC"}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
const require_runtime = require('../../_virtual/_rolldown/runtime.cjs');
|
|
2
1
|
const require_module_federation_service = require('./module-federation.service.cjs');
|
|
3
2
|
const require_plugin_lifecycle_service = require('./plugin-lifecycle.service.cjs');
|
|
4
3
|
const require_secrets_service = require('./secrets.service.cjs');
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.service.cjs","names":["Effect","PluginLoaderService","PluginLifecycleService","Scope","Exit","Layer","PluginRegistryTag","SecretsConfigTag","PluginMapTag","ModuleFederationService","SecretsService","RegistryService"],"sources":["../../../src/runtime/services/plugin.service.ts"],"sourcesContent":["import { Effect, Exit, Layer, Scope } from \"effect\";\nimport type {\n AnyPlugin,\n AnyPluginConstructor,\n InitializedPlugin,\n PluginRegistry,\n SecretsConfig,\n} from \"../../types\";\nimport { ModuleFederationService } from \"./module-federation.service\";\nimport { PluginLifecycleService } from \"./plugin-lifecycle.service\";\nimport {\n PluginLoaderService,\n PluginMapTag,\n PluginRegistryTag,\n RegistryService,\n} from \"./plugin-loader.service\";\nimport { SecretsConfigTag, SecretsService } from \"./secrets.service\";\n\nexport class PluginService extends Effect.Service<PluginService>()(\"PluginService\", {\n scoped: Effect.gen(function* () {\n const loader = yield* PluginLoaderService;\n const lifecycle = yield* PluginLifecycleService;\n\n return {\n loadPlugin: loader.loadPlugin,\n instantiatePlugin: loader.instantiatePlugin,\n initializePlugin: loader.initializePlugin,\n registerPlugin: (plugin: InitializedPlugin<AnyPlugin>) => lifecycle.register(plugin),\n shutdownPlugin: (plugin: InitializedPlugin<AnyPlugin>) =>\n Effect.gen(function* () {\n yield* plugin.plugin\n .shutdown()\n .pipe(\n Effect.catchAll((error) =>\n Effect.logWarning(`Failed to shutdown plugin ${plugin.plugin.id}`, error),\n ),\n );\n\n yield* Scope.close(plugin.scope, Exit.succeed(undefined));\n\n yield* lifecycle.unregister(plugin);\n }),\n cleanup: lifecycle.cleanup,\n };\n }),\n}) {\n static Live = (\n registry: PluginRegistry,\n secrets: SecretsConfig,\n pluginMap: Record<string, AnyPluginConstructor> = {},\n ) => {\n const contextLayer = Layer.mergeAll(\n Layer.succeed(PluginRegistryTag, registry),\n Layer.succeed(SecretsConfigTag, secrets),\n Layer.succeed(PluginMapTag, pluginMap),\n );\n\n const servicesLayer = Layer.mergeAll(\n ModuleFederationService.Default,\n SecretsService.Default,\n RegistryService.Default,\n PluginLifecycleService.Default,\n ).pipe(Layer.provide(contextLayer));\n\n return PluginService.Default.pipe(\n Layer.provide(PluginLoaderService.Default),\n Layer.provide(servicesLayer),\n );\n };\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"plugin.service.cjs","names":["Effect","PluginLoaderService","PluginLifecycleService","Scope","Exit","Layer","PluginRegistryTag","SecretsConfigTag","PluginMapTag","ModuleFederationService","SecretsService","RegistryService"],"sources":["../../../src/runtime/services/plugin.service.ts"],"sourcesContent":["import { Effect, Exit, Layer, Scope } from \"effect\";\nimport type {\n AnyPlugin,\n AnyPluginConstructor,\n InitializedPlugin,\n PluginRegistry,\n SecretsConfig,\n} from \"../../types\";\nimport { ModuleFederationService } from \"./module-federation.service\";\nimport { PluginLifecycleService } from \"./plugin-lifecycle.service\";\nimport {\n PluginLoaderService,\n PluginMapTag,\n PluginRegistryTag,\n RegistryService,\n} from \"./plugin-loader.service\";\nimport { SecretsConfigTag, SecretsService } from \"./secrets.service\";\n\nexport class PluginService extends Effect.Service<PluginService>()(\"PluginService\", {\n scoped: Effect.gen(function* () {\n const loader = yield* PluginLoaderService;\n const lifecycle = yield* PluginLifecycleService;\n\n return {\n loadPlugin: loader.loadPlugin,\n instantiatePlugin: loader.instantiatePlugin,\n initializePlugin: loader.initializePlugin,\n registerPlugin: (plugin: InitializedPlugin<AnyPlugin>) => lifecycle.register(plugin),\n shutdownPlugin: (plugin: InitializedPlugin<AnyPlugin>) =>\n Effect.gen(function* () {\n yield* plugin.plugin\n .shutdown()\n .pipe(\n Effect.catchAll((error) =>\n Effect.logWarning(`Failed to shutdown plugin ${plugin.plugin.id}`, error),\n ),\n );\n\n yield* Scope.close(plugin.scope, Exit.succeed(undefined));\n\n yield* lifecycle.unregister(plugin);\n }),\n cleanup: lifecycle.cleanup,\n };\n }),\n}) {\n static Live = (\n registry: PluginRegistry,\n secrets: SecretsConfig,\n pluginMap: Record<string, AnyPluginConstructor> = {},\n ) => {\n const contextLayer = Layer.mergeAll(\n Layer.succeed(PluginRegistryTag, registry),\n Layer.succeed(SecretsConfigTag, secrets),\n Layer.succeed(PluginMapTag, pluginMap),\n );\n\n const servicesLayer = Layer.mergeAll(\n ModuleFederationService.Default,\n SecretsService.Default,\n RegistryService.Default,\n PluginLifecycleService.Default,\n ).pipe(Layer.provide(contextLayer));\n\n return PluginService.Default.pipe(\n Layer.provide(PluginLoaderService.Default),\n Layer.provide(servicesLayer),\n );\n };\n}\n"],"mappings":";;;;;;;AAkBA,IAAa,gBAAb,MAAa,sBAAsBA,cAAO,QAAuB,CAAC,CAAC,iBAAiB,EAClF,QAAQA,cAAO,IAAI,aAAa;CAC9B,MAAM,SAAS,OAAOC;CACtB,MAAM,YAAY,OAAOC;CAEzB,OAAO;EACL,YAAY,OAAO;EACnB,mBAAmB,OAAO;EAC1B,kBAAkB,OAAO;EACzB,iBAAiB,WAAyC,UAAU,SAAS,MAAM;EACnF,iBAAiB,WACfF,cAAO,IAAI,aAAa;GACtB,OAAO,OAAO,OACX,SAAS,CAAC,CACV,KACCA,cAAO,UAAU,UACfA,cAAO,WAAW,6BAA6B,OAAO,OAAO,MAAM,KAAK,CAC1E,CACF;GAEF,OAAOG,aAAM,MAAM,OAAO,OAAOC,YAAK,QAAQ,MAAS,CAAC;GAExD,OAAO,UAAU,WAAW,MAAM;EACpC,CAAC;EACH,SAAS,UAAU;CACrB;AACF,CAAC,EACH,CAAC,CAAC,CAAC;CACD,OAAO,QACL,UACA,SACA,YAAkD,CAAC,MAChD;EACH,MAAM,eAAeC,aAAM,SACzBA,aAAM,QAAQC,iDAAmB,QAAQ,GACzCD,aAAM,QAAQE,0CAAkB,OAAO,GACvCF,aAAM,QAAQG,4CAAc,SAAS,CACvC;EAEA,MAAM,gBAAgBH,aAAM,SAC1BI,0DAAwB,SACxBC,uCAAe,SACfC,8CAAgB,SAChBT,wDAAuB,OACzB,CAAC,CAAC,KAAKG,aAAM,QAAQ,YAAY,CAAC;EAElC,OAAO,cAAc,QAAQ,KAC3BA,aAAM,QAAQJ,kDAAoB,OAAO,GACzCI,aAAM,QAAQ,aAAa,CAC7B;CACF;AACF"}
|
|
@@ -2,9 +2,8 @@ import { PluginRuntimeError } from "../errors.cjs";
|
|
|
2
2
|
import { AnyPlugin, AnyPluginConstructor, InitializedPlugin, LoadedPlugin, PluginInstance, PluginMetadata, PluginRegistry, SecretsConfig } from "../../types.cjs";
|
|
3
3
|
import { PluginLifecycleService } from "./plugin-lifecycle.service.cjs";
|
|
4
4
|
import { PluginLoaderService } from "./plugin-loader.service.cjs";
|
|
5
|
+
import "../../index.cjs";
|
|
5
6
|
import { Effect, Layer, Scope } from "effect";
|
|
6
|
-
import * as _$_orpc_contract0 from "@orpc/contract";
|
|
7
|
-
|
|
8
7
|
//#region src/runtime/services/plugin.service.d.ts
|
|
9
8
|
declare const PluginService_base: Effect.Service.Class<PluginService, "PluginService", {
|
|
10
9
|
readonly scoped: Effect.Effect<{
|
|
@@ -17,14 +16,14 @@ declare const PluginService_base: Effect.Service.Class<PluginService, "PluginSer
|
|
|
17
16
|
metadata: PluginMetadata;
|
|
18
17
|
}, PluginRuntimeError, never>;
|
|
19
18
|
initializePlugin: <T extends AnyPlugin>(pluginInstance: PluginInstance<T>, config: {
|
|
20
|
-
variables:
|
|
21
|
-
secrets:
|
|
19
|
+
variables: import("@orpc/contract").InferSchemaInput<T["configSchema"]["variables"]>;
|
|
20
|
+
secrets: import("@orpc/contract").InferSchemaInput<T["configSchema"]["secrets"]>;
|
|
22
21
|
}, plugins?: Record<string, unknown>) => Effect.Effect<{
|
|
23
22
|
plugin: T;
|
|
24
23
|
metadata: PluginMetadata;
|
|
25
24
|
config: {
|
|
26
|
-
variables:
|
|
27
|
-
secrets:
|
|
25
|
+
variables: import("@orpc/contract").InferSchemaOutput<T["configSchema"]["variables"]>;
|
|
26
|
+
secrets: import("@orpc/contract").InferSchemaOutput<T["configSchema"]["secrets"]>;
|
|
28
27
|
};
|
|
29
28
|
context: any;
|
|
30
29
|
scope: Scope.CloseableScope;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.service.d.cts","names":[],"sources":["../../../src/runtime/services/plugin.service.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"plugin.service.d.cts","names":[],"sources":["../../../src/runtime/services/plugin.service.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IA2B+B,iBAAA,QAAA,kBAAkB,eAAU,OAAA;IAC5B,iBAAA,QAAA,kBAAkB,eAAU,OAAA;;;;cAV9C,sBAAsB;SA4B1B,OACL,UAAU,gBACV,SAAS,eACT,YAAW,eAAe,0BAA0B,MAAA,MAAA"}
|
|
@@ -2,9 +2,8 @@ import { PluginRuntimeError } from "../errors.mjs";
|
|
|
2
2
|
import { AnyPlugin, AnyPluginConstructor, InitializedPlugin, LoadedPlugin, PluginInstance, PluginMetadata, PluginRegistry, SecretsConfig } from "../../types.mjs";
|
|
3
3
|
import { PluginLifecycleService } from "./plugin-lifecycle.service.mjs";
|
|
4
4
|
import { PluginLoaderService } from "./plugin-loader.service.mjs";
|
|
5
|
-
import
|
|
5
|
+
import "../../index.mjs";
|
|
6
6
|
import { Effect, Layer, Scope } from "effect";
|
|
7
|
-
|
|
8
7
|
//#region src/runtime/services/plugin.service.d.ts
|
|
9
8
|
declare const PluginService_base: Effect.Service.Class<PluginService, "PluginService", {
|
|
10
9
|
readonly scoped: Effect.Effect<{
|
|
@@ -17,14 +16,14 @@ declare const PluginService_base: Effect.Service.Class<PluginService, "PluginSer
|
|
|
17
16
|
metadata: PluginMetadata;
|
|
18
17
|
}, PluginRuntimeError, never>;
|
|
19
18
|
initializePlugin: <T extends AnyPlugin>(pluginInstance: PluginInstance<T>, config: {
|
|
20
|
-
variables:
|
|
21
|
-
secrets:
|
|
19
|
+
variables: import("@orpc/contract").InferSchemaInput<T["configSchema"]["variables"]>;
|
|
20
|
+
secrets: import("@orpc/contract").InferSchemaInput<T["configSchema"]["secrets"]>;
|
|
22
21
|
}, plugins?: Record<string, unknown>) => Effect.Effect<{
|
|
23
22
|
plugin: T;
|
|
24
23
|
metadata: PluginMetadata;
|
|
25
24
|
config: {
|
|
26
|
-
variables:
|
|
27
|
-
secrets:
|
|
25
|
+
variables: import("@orpc/contract").InferSchemaOutput<T["configSchema"]["variables"]>;
|
|
26
|
+
secrets: import("@orpc/contract").InferSchemaOutput<T["configSchema"]["secrets"]>;
|
|
28
27
|
};
|
|
29
28
|
context: any;
|
|
30
29
|
scope: Scope.CloseableScope;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.service.d.mts","names":[],"sources":["../../../src/runtime/services/plugin.service.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"plugin.service.d.mts","names":[],"sources":["../../../src/runtime/services/plugin.service.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IA2B+B,iBAAA,QAAA,kBAAkB,eAAU,OAAA;IAC5B,iBAAA,QAAA,kBAAkB,eAAU,OAAA;;;;cAV9C,sBAAsB;SA4B1B,OACL,UAAU,gBACV,SAAS,eACT,YAAW,eAAe,0BAA0B,MAAA,MAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.service.mjs","names":[],"sources":["../../../src/runtime/services/plugin.service.ts"],"sourcesContent":["import { Effect, Exit, Layer, Scope } from \"effect\";\nimport type {\n AnyPlugin,\n AnyPluginConstructor,\n InitializedPlugin,\n PluginRegistry,\n SecretsConfig,\n} from \"../../types\";\nimport { ModuleFederationService } from \"./module-federation.service\";\nimport { PluginLifecycleService } from \"./plugin-lifecycle.service\";\nimport {\n PluginLoaderService,\n PluginMapTag,\n PluginRegistryTag,\n RegistryService,\n} from \"./plugin-loader.service\";\nimport { SecretsConfigTag, SecretsService } from \"./secrets.service\";\n\nexport class PluginService extends Effect.Service<PluginService>()(\"PluginService\", {\n scoped: Effect.gen(function* () {\n const loader = yield* PluginLoaderService;\n const lifecycle = yield* PluginLifecycleService;\n\n return {\n loadPlugin: loader.loadPlugin,\n instantiatePlugin: loader.instantiatePlugin,\n initializePlugin: loader.initializePlugin,\n registerPlugin: (plugin: InitializedPlugin<AnyPlugin>) => lifecycle.register(plugin),\n shutdownPlugin: (plugin: InitializedPlugin<AnyPlugin>) =>\n Effect.gen(function* () {\n yield* plugin.plugin\n .shutdown()\n .pipe(\n Effect.catchAll((error) =>\n Effect.logWarning(`Failed to shutdown plugin ${plugin.plugin.id}`, error),\n ),\n );\n\n yield* Scope.close(plugin.scope, Exit.succeed(undefined));\n\n yield* lifecycle.unregister(plugin);\n }),\n cleanup: lifecycle.cleanup,\n };\n }),\n}) {\n static Live = (\n registry: PluginRegistry,\n secrets: SecretsConfig,\n pluginMap: Record<string, AnyPluginConstructor> = {},\n ) => {\n const contextLayer = Layer.mergeAll(\n Layer.succeed(PluginRegistryTag, registry),\n Layer.succeed(SecretsConfigTag, secrets),\n Layer.succeed(PluginMapTag, pluginMap),\n );\n\n const servicesLayer = Layer.mergeAll(\n ModuleFederationService.Default,\n SecretsService.Default,\n RegistryService.Default,\n PluginLifecycleService.Default,\n ).pipe(Layer.provide(contextLayer));\n\n return PluginService.Default.pipe(\n Layer.provide(PluginLoaderService.Default),\n Layer.provide(servicesLayer),\n );\n };\n}\n"],"mappings":";;;;;;;AAkBA,IAAa,gBAAb,MAAa,sBAAsB,OAAO,
|
|
1
|
+
{"version":3,"file":"plugin.service.mjs","names":[],"sources":["../../../src/runtime/services/plugin.service.ts"],"sourcesContent":["import { Effect, Exit, Layer, Scope } from \"effect\";\nimport type {\n AnyPlugin,\n AnyPluginConstructor,\n InitializedPlugin,\n PluginRegistry,\n SecretsConfig,\n} from \"../../types\";\nimport { ModuleFederationService } from \"./module-federation.service\";\nimport { PluginLifecycleService } from \"./plugin-lifecycle.service\";\nimport {\n PluginLoaderService,\n PluginMapTag,\n PluginRegistryTag,\n RegistryService,\n} from \"./plugin-loader.service\";\nimport { SecretsConfigTag, SecretsService } from \"./secrets.service\";\n\nexport class PluginService extends Effect.Service<PluginService>()(\"PluginService\", {\n scoped: Effect.gen(function* () {\n const loader = yield* PluginLoaderService;\n const lifecycle = yield* PluginLifecycleService;\n\n return {\n loadPlugin: loader.loadPlugin,\n instantiatePlugin: loader.instantiatePlugin,\n initializePlugin: loader.initializePlugin,\n registerPlugin: (plugin: InitializedPlugin<AnyPlugin>) => lifecycle.register(plugin),\n shutdownPlugin: (plugin: InitializedPlugin<AnyPlugin>) =>\n Effect.gen(function* () {\n yield* plugin.plugin\n .shutdown()\n .pipe(\n Effect.catchAll((error) =>\n Effect.logWarning(`Failed to shutdown plugin ${plugin.plugin.id}`, error),\n ),\n );\n\n yield* Scope.close(plugin.scope, Exit.succeed(undefined));\n\n yield* lifecycle.unregister(plugin);\n }),\n cleanup: lifecycle.cleanup,\n };\n }),\n}) {\n static Live = (\n registry: PluginRegistry,\n secrets: SecretsConfig,\n pluginMap: Record<string, AnyPluginConstructor> = {},\n ) => {\n const contextLayer = Layer.mergeAll(\n Layer.succeed(PluginRegistryTag, registry),\n Layer.succeed(SecretsConfigTag, secrets),\n Layer.succeed(PluginMapTag, pluginMap),\n );\n\n const servicesLayer = Layer.mergeAll(\n ModuleFederationService.Default,\n SecretsService.Default,\n RegistryService.Default,\n PluginLifecycleService.Default,\n ).pipe(Layer.provide(contextLayer));\n\n return PluginService.Default.pipe(\n Layer.provide(PluginLoaderService.Default),\n Layer.provide(servicesLayer),\n );\n };\n}\n"],"mappings":";;;;;;;AAkBA,IAAa,gBAAb,MAAa,sBAAsB,OAAO,QAAuB,CAAC,CAAC,iBAAiB,EAClF,QAAQ,OAAO,IAAI,aAAa;CAC9B,MAAM,SAAS,OAAO;CACtB,MAAM,YAAY,OAAO;CAEzB,OAAO;EACL,YAAY,OAAO;EACnB,mBAAmB,OAAO;EAC1B,kBAAkB,OAAO;EACzB,iBAAiB,WAAyC,UAAU,SAAS,MAAM;EACnF,iBAAiB,WACf,OAAO,IAAI,aAAa;GACtB,OAAO,OAAO,OACX,SAAS,CAAC,CACV,KACC,OAAO,UAAU,UACf,OAAO,WAAW,6BAA6B,OAAO,OAAO,MAAM,KAAK,CAC1E,CACF;GAEF,OAAO,MAAM,MAAM,OAAO,OAAO,KAAK,QAAQ,MAAS,CAAC;GAExD,OAAO,UAAU,WAAW,MAAM;EACpC,CAAC;EACH,SAAS,UAAU;CACrB;AACF,CAAC,EACH,CAAC,CAAC,CAAC;CACD,OAAO,QACL,UACA,SACA,YAAkD,CAAC,MAChD;EACH,MAAM,eAAe,MAAM,SACzB,MAAM,QAAQ,mBAAmB,QAAQ,GACzC,MAAM,QAAQ,kBAAkB,OAAO,GACvC,MAAM,QAAQ,cAAc,SAAS,CACvC;EAEA,MAAM,gBAAgB,MAAM,SAC1B,wBAAwB,SACxB,eAAe,SACf,gBAAgB,SAChB,uBAAuB,OACzB,CAAC,CAAC,KAAK,MAAM,QAAQ,YAAY,CAAC;EAElC,OAAO,cAAc,QAAQ,KAC3B,MAAM,QAAQ,oBAAoB,OAAO,GACzC,MAAM,QAAQ,aAAa,CAC7B;CACF;AACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"secrets.service.cjs","names":["z","Context","Effect","PluginRuntimeError"],"sources":["../../../src/runtime/services/secrets.service.ts"],"sourcesContent":["import { Context, Effect } from \"effect\";\nimport * as z from \"zod\";\nimport type { SecretsConfig } from \"../../types\";\nimport { PluginRuntimeError } from \"../errors\";\n\nconst configSchema = z\n .object({\n secrets: z.record(z.string(), z.unknown()),\n })\n .passthrough();\n\nexport class SecretsConfigTag extends Context.Tag(\"SecretsConfig\")<\n SecretsConfigTag,\n SecretsConfig\n>() {}\n\nexport class SecretsService extends Effect.Service<SecretsService>()(\"SecretsService\", {\n effect: Effect.gen(function* () {\n const secrets = yield* SecretsConfigTag;\n\n const hydrateValue = (value: unknown): unknown => {\n if (typeof value === \"string\") {\n let result = value;\n for (const [key, secretValue] of Object.entries(secrets)) {\n const pattern = new RegExp(`{{${key}}}`, \"g\");\n result = result.replace(pattern, String(secretValue));\n }\n return result;\n }\n\n if (Array.isArray(value)) {\n return value.map(hydrateValue);\n }\n\n if (value && typeof value === \"object\") {\n const isPlainObject = value.constructor === Object || value.constructor === undefined;\n\n if (isPlainObject) {\n const hydrated: Record<string, unknown> = {};\n for (const [key, val] of Object.entries(value)) {\n hydrated[key] = hydrateValue(val);\n }\n return hydrated;\n }\n\n const hydrated = Object.create(Object.getPrototypeOf(value));\n for (const [key, val] of Object.entries(value)) {\n hydrated[key] = hydrateValue(val);\n }\n return hydrated;\n }\n\n return value;\n };\n\n return {\n hydrateSecrets: <T>(config: T) =>\n Effect.gen(function* () {\n const parseResult = configSchema.parse(config);\n try {\n return hydrateValue(parseResult) as T;\n } catch (error) {\n return yield* Effect.fail(\n new PluginRuntimeError({\n operation: \"hydrate-secrets\",\n cause: error instanceof Error ? error : new Error(String(error)),\n retryable: false,\n }),\n );\n }\n }),\n };\n }),\n}) {}\n"],"mappings":";;;;;;;AAKA,MAAM,eAAeA,IAClB,OAAO,EACN,SAASA,IAAE,OAAOA,IAAE,
|
|
1
|
+
{"version":3,"file":"secrets.service.cjs","names":["z","Context","Effect","PluginRuntimeError"],"sources":["../../../src/runtime/services/secrets.service.ts"],"sourcesContent":["import { Context, Effect } from \"effect\";\nimport * as z from \"zod\";\nimport type { SecretsConfig } from \"../../types\";\nimport { PluginRuntimeError } from \"../errors\";\n\nconst configSchema = z\n .object({\n secrets: z.record(z.string(), z.unknown()),\n })\n .passthrough();\n\nexport class SecretsConfigTag extends Context.Tag(\"SecretsConfig\")<\n SecretsConfigTag,\n SecretsConfig\n>() {}\n\nexport class SecretsService extends Effect.Service<SecretsService>()(\"SecretsService\", {\n effect: Effect.gen(function* () {\n const secrets = yield* SecretsConfigTag;\n\n const hydrateValue = (value: unknown): unknown => {\n if (typeof value === \"string\") {\n let result = value;\n for (const [key, secretValue] of Object.entries(secrets)) {\n const pattern = new RegExp(`{{${key}}}`, \"g\");\n result = result.replace(pattern, String(secretValue));\n }\n return result;\n }\n\n if (Array.isArray(value)) {\n return value.map(hydrateValue);\n }\n\n if (value && typeof value === \"object\") {\n const isPlainObject = value.constructor === Object || value.constructor === undefined;\n\n if (isPlainObject) {\n const hydrated: Record<string, unknown> = {};\n for (const [key, val] of Object.entries(value)) {\n hydrated[key] = hydrateValue(val);\n }\n return hydrated;\n }\n\n const hydrated = Object.create(Object.getPrototypeOf(value));\n for (const [key, val] of Object.entries(value)) {\n hydrated[key] = hydrateValue(val);\n }\n return hydrated;\n }\n\n return value;\n };\n\n return {\n hydrateSecrets: <T>(config: T) =>\n Effect.gen(function* () {\n const parseResult = configSchema.parse(config);\n try {\n return hydrateValue(parseResult) as T;\n } catch (error) {\n return yield* Effect.fail(\n new PluginRuntimeError({\n operation: \"hydrate-secrets\",\n cause: error instanceof Error ? error : new Error(String(error)),\n retryable: false,\n }),\n );\n }\n }),\n };\n }),\n}) {}\n"],"mappings":";;;;;;;AAKA,MAAM,eAAeA,IACl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AAO,iBAAiB,QAAQ,QAAQ,IAAI,MAAM,OAAO,KAAK,CAAC;IAC/D,WAAW;GACb,CAAC,CACH;EACF;CACF,CAAC,EACL;AACF,CAAC,EACH,CAAC,CAAC,CAAC,CAAC"}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { PluginRuntimeError } from "../errors.cjs";
|
|
2
2
|
import { SecretsConfig } from "../../types.cjs";
|
|
3
3
|
import { Context, Effect } from "effect";
|
|
4
|
-
|
|
5
4
|
//#region src/runtime/services/secrets.service.d.ts
|
|
6
5
|
declare const SecretsConfigTag_base: Context.TagClass<SecretsConfigTag, "SecretsConfig", SecretsConfig>;
|
|
7
6
|
declare class SecretsConfigTag extends SecretsConfigTag_base {}
|
|
@@ -12,5 +11,5 @@ declare const SecretsService_base: Effect.Service.Class<SecretsService, "Secrets
|
|
|
12
11
|
}>;
|
|
13
12
|
declare class SecretsService extends SecretsService_base {}
|
|
14
13
|
//#endregion
|
|
15
|
-
export { SecretsService };
|
|
14
|
+
export { SecretsConfigTag, SecretsService };
|
|
16
15
|
//# sourceMappingURL=secrets.service.d.cts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"secrets.service.d.cts","names":[],"sources":["../../../src/runtime/services/secrets.service.ts"],"mappings":";;;;;
|
|
1
|
+
{"version":3,"file":"secrets.service.d.cts","names":[],"sources":["../../../src/runtime/services/secrets.service.ts"],"mappings":";;;;;cAWa,yBAAyB;;;IA6Cf,iBAAA,GAAC,QAAU,MAAC,OAAA,OAAA,GAAA;;;cAxCtB,uBAAuB"}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { PluginRuntimeError } from "../errors.mjs";
|
|
2
2
|
import { SecretsConfig } from "../../types.mjs";
|
|
3
3
|
import { Context, Effect } from "effect";
|
|
4
|
-
|
|
5
4
|
//#region src/runtime/services/secrets.service.d.ts
|
|
6
5
|
declare const SecretsConfigTag_base: Context.TagClass<SecretsConfigTag, "SecretsConfig", SecretsConfig>;
|
|
7
6
|
declare class SecretsConfigTag extends SecretsConfigTag_base {}
|
|
@@ -12,5 +11,5 @@ declare const SecretsService_base: Effect.Service.Class<SecretsService, "Secrets
|
|
|
12
11
|
}>;
|
|
13
12
|
declare class SecretsService extends SecretsService_base {}
|
|
14
13
|
//#endregion
|
|
15
|
-
export { SecretsService };
|
|
14
|
+
export { SecretsConfigTag, SecretsService };
|
|
16
15
|
//# sourceMappingURL=secrets.service.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"secrets.service.d.mts","names":[],"sources":["../../../src/runtime/services/secrets.service.ts"],"mappings":";;;;;
|
|
1
|
+
{"version":3,"file":"secrets.service.d.mts","names":[],"sources":["../../../src/runtime/services/secrets.service.ts"],"mappings":";;;;;cAWa,yBAAyB;;;IA6Cf,iBAAA,GAAC,QAAU,MAAC,OAAA,OAAA,GAAA;;;cAxCtB,uBAAuB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"secrets.service.mjs","names":["z"],"sources":["../../../src/runtime/services/secrets.service.ts"],"sourcesContent":["import { Context, Effect } from \"effect\";\nimport * as z from \"zod\";\nimport type { SecretsConfig } from \"../../types\";\nimport { PluginRuntimeError } from \"../errors\";\n\nconst configSchema = z\n .object({\n secrets: z.record(z.string(), z.unknown()),\n })\n .passthrough();\n\nexport class SecretsConfigTag extends Context.Tag(\"SecretsConfig\")<\n SecretsConfigTag,\n SecretsConfig\n>() {}\n\nexport class SecretsService extends Effect.Service<SecretsService>()(\"SecretsService\", {\n effect: Effect.gen(function* () {\n const secrets = yield* SecretsConfigTag;\n\n const hydrateValue = (value: unknown): unknown => {\n if (typeof value === \"string\") {\n let result = value;\n for (const [key, secretValue] of Object.entries(secrets)) {\n const pattern = new RegExp(`{{${key}}}`, \"g\");\n result = result.replace(pattern, String(secretValue));\n }\n return result;\n }\n\n if (Array.isArray(value)) {\n return value.map(hydrateValue);\n }\n\n if (value && typeof value === \"object\") {\n const isPlainObject = value.constructor === Object || value.constructor === undefined;\n\n if (isPlainObject) {\n const hydrated: Record<string, unknown> = {};\n for (const [key, val] of Object.entries(value)) {\n hydrated[key] = hydrateValue(val);\n }\n return hydrated;\n }\n\n const hydrated = Object.create(Object.getPrototypeOf(value));\n for (const [key, val] of Object.entries(value)) {\n hydrated[key] = hydrateValue(val);\n }\n return hydrated;\n }\n\n return value;\n };\n\n return {\n hydrateSecrets: <T>(config: T) =>\n Effect.gen(function* () {\n const parseResult = configSchema.parse(config);\n try {\n return hydrateValue(parseResult) as T;\n } catch (error) {\n return yield* Effect.fail(\n new PluginRuntimeError({\n operation: \"hydrate-secrets\",\n cause: error instanceof Error ? error : new Error(String(error)),\n retryable: false,\n }),\n );\n }\n }),\n };\n }),\n}) {}\n"],"mappings":";;;;;AAKA,MAAM,eAAeA,IAClB,OAAO,EACN,SAASA,IAAE,OAAOA,IAAE,
|
|
1
|
+
{"version":3,"file":"secrets.service.mjs","names":["z"],"sources":["../../../src/runtime/services/secrets.service.ts"],"sourcesContent":["import { Context, Effect } from \"effect\";\nimport * as z from \"zod\";\nimport type { SecretsConfig } from \"../../types\";\nimport { PluginRuntimeError } from \"../errors\";\n\nconst configSchema = z\n .object({\n secrets: z.record(z.string(), z.unknown()),\n })\n .passthrough();\n\nexport class SecretsConfigTag extends Context.Tag(\"SecretsConfig\")<\n SecretsConfigTag,\n SecretsConfig\n>() {}\n\nexport class SecretsService extends Effect.Service<SecretsService>()(\"SecretsService\", {\n effect: Effect.gen(function* () {\n const secrets = yield* SecretsConfigTag;\n\n const hydrateValue = (value: unknown): unknown => {\n if (typeof value === \"string\") {\n let result = value;\n for (const [key, secretValue] of Object.entries(secrets)) {\n const pattern = new RegExp(`{{${key}}}`, \"g\");\n result = result.replace(pattern, String(secretValue));\n }\n return result;\n }\n\n if (Array.isArray(value)) {\n return value.map(hydrateValue);\n }\n\n if (value && typeof value === \"object\") {\n const isPlainObject = value.constructor === Object || value.constructor === undefined;\n\n if (isPlainObject) {\n const hydrated: Record<string, unknown> = {};\n for (const [key, val] of Object.entries(value)) {\n hydrated[key] = hydrateValue(val);\n }\n return hydrated;\n }\n\n const hydrated = Object.create(Object.getPrototypeOf(value));\n for (const [key, val] of Object.entries(value)) {\n hydrated[key] = hydrateValue(val);\n }\n return hydrated;\n }\n\n return value;\n };\n\n return {\n hydrateSecrets: <T>(config: T) =>\n Effect.gen(function* () {\n const parseResult = configSchema.parse(config);\n try {\n return hydrateValue(parseResult) as T;\n } catch (error) {\n return yield* Effect.fail(\n new PluginRuntimeError({\n operation: \"hydrate-secrets\",\n cause: error instanceof Error ? error : new Error(String(error)),\n retryable: false,\n }),\n );\n }\n }),\n };\n }),\n}) {}\n"],"mappings":";;;;;AAKA,MAAM,eAAeA,IAClB,OAAO,EACN,SAASA,IAAE,OAAOA,IAAE,OAAO,GAAGA,IAAE,QAAQ,CAAC,EAC3C,CAAC,CAAC,CACD,YAAY;AAEf,IAAa,mBAAb,cAAsC,QAAQ,IAAI,eAAe,CAAC,CAGhE,CAAC,CAAC,CAAC;AAEL,IAAa,iBAAb,cAAoC,OAAO,QAAwB,CAAC,CAAC,kBAAkB,EACrF,QAAQ,OAAO,IAAI,aAAa;CAC9B,MAAM,UAAU,OAAO;CAEvB,MAAM,gBAAgB,UAA4B;EAChD,IAAI,OAAO,UAAU,UAAU;GAC7B,IAAI,SAAS;GACb,KAAK,MAAM,CAAC,KAAK,gBAAgB,OAAO,QAAQ,OAAO,GAAG;IACxD,MAAM,UAAU,IAAI,OAAO,KAAK,IAAI,KAAK,GAAG;IAC5C,SAAS,OAAO,QAAQ,SAAS,OAAO,WAAW,CAAC;GACtD;GACA,OAAO;EACT;EAEA,IAAI,MAAM,QAAQ,KAAK,GACrB,OAAO,MAAM,IAAI,YAAY;EAG/B,IAAI,SAAS,OAAO,UAAU,UAAU;GAGtC,IAFsB,MAAM,gBAAgB,UAAU,MAAM,gBAAgB,QAEzD;IACjB,MAAM,WAAoC,CAAC;IAC3C,KAAK,MAAM,CAAC,KAAK,QAAQ,OAAO,QAAQ,KAAK,GAC3C,SAAS,OAAO,aAAa,GAAG;IAElC,OAAO;GACT;GAEA,MAAM,WAAW,OAAO,OAAO,OAAO,eAAe,KAAK,CAAC;GAC3D,KAAK,MAAM,CAAC,KAAK,QAAQ,OAAO,QAAQ,KAAK,GAC3C,SAAS,OAAO,aAAa,GAAG;GAElC,OAAO;EACT;EAEA,OAAO;CACT;CAEA,OAAO,EACL,iBAAoB,WAClB,OAAO,IAAI,aAAa;EACtB,MAAM,cAAc,aAAa,MAAM,MAAM;EAC7C,IAAI;GACF,OAAO,aAAa,WAAW;EACjC,SAAS,OAAO;GACd,OAAO,OAAO,OAAO,KACnB,IAAI,mBAAmB;IACrB,WAAW;IACX,OAAO,iBAAiB,QAAQ,QAAQ,IAAI,MAAM,OAAO,KAAK,CAAC;IAC/D,WAAW;GACb,CAAC,CACH;EACF;CACF,CAAC,EACL;AACF,CAAC,EACH,CAAC,CAAC,CAAC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validation.cjs","names":["Effect","ValidationError"],"sources":["../../src/runtime/validation.ts"],"sourcesContent":["import { Effect } from \"effect\";\nimport type { z } from \"zod\";\nimport { ValidationError } from \"./errors\";\n\nexport const validate = <T>(\n schema: z.ZodSchema<T>,\n data: unknown,\n pluginId: string,\n stage: \"config\" | \"input\" | \"output\" | \"state\",\n): Effect.Effect<T, ValidationError> =>\n Effect.gen(function* () {\n const result = schema.safeParse(data);\n if (result.success) {\n return result.data;\n }\n return yield* Effect.fail(\n new ValidationError({\n pluginId,\n stage,\n zodError: result.error,\n }),\n );\n });\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"validation.cjs","names":["Effect","ValidationError"],"sources":["../../src/runtime/validation.ts"],"sourcesContent":["import { Effect } from \"effect\";\nimport type { z } from \"zod\";\nimport { ValidationError } from \"./errors\";\n\nexport const validate = <T>(\n schema: z.ZodSchema<T>,\n data: unknown,\n pluginId: string,\n stage: \"config\" | \"input\" | \"output\" | \"state\",\n): Effect.Effect<T, ValidationError> =>\n Effect.gen(function* () {\n const result = schema.safeParse(data);\n if (result.success) {\n return result.data;\n }\n return yield* Effect.fail(\n new ValidationError({\n pluginId,\n stage,\n zodError: result.error,\n }),\n );\n });\n"],"mappings":";;;;AAIA,MAAa,YACX,QACA,MACA,UACA,UAEAA,cAAO,IAAI,aAAa;CACtB,MAAM,SAAS,OAAO,UAAU,IAAI;CACpC,IAAI,OAAO,SACT,OAAO,OAAO;CAEhB,OAAO,OAAOA,cAAO,KACnB,IAAIC,+BAAgB;EAClB;EACA;EACA,UAAU,OAAO;CACnB,CAAC,CACH;AACF,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validation.mjs","names":[],"sources":["../../src/runtime/validation.ts"],"sourcesContent":["import { Effect } from \"effect\";\nimport type { z } from \"zod\";\nimport { ValidationError } from \"./errors\";\n\nexport const validate = <T>(\n schema: z.ZodSchema<T>,\n data: unknown,\n pluginId: string,\n stage: \"config\" | \"input\" | \"output\" | \"state\",\n): Effect.Effect<T, ValidationError> =>\n Effect.gen(function* () {\n const result = schema.safeParse(data);\n if (result.success) {\n return result.data;\n }\n return yield* Effect.fail(\n new ValidationError({\n pluginId,\n stage,\n zodError: result.error,\n }),\n );\n });\n"],"mappings":";;;;AAIA,MAAa,YACX,QACA,MACA,UACA,UAEA,OAAO,IAAI,aAAa;CACtB,MAAM,SAAS,OAAO,UAAU,
|
|
1
|
+
{"version":3,"file":"validation.mjs","names":[],"sources":["../../src/runtime/validation.ts"],"sourcesContent":["import { Effect } from \"effect\";\nimport type { z } from \"zod\";\nimport { ValidationError } from \"./errors\";\n\nexport const validate = <T>(\n schema: z.ZodSchema<T>,\n data: unknown,\n pluginId: string,\n stage: \"config\" | \"input\" | \"output\" | \"state\",\n): Effect.Effect<T, ValidationError> =>\n Effect.gen(function* () {\n const result = schema.safeParse(data);\n if (result.success) {\n return result.data;\n }\n return yield* Effect.fail(\n new ValidationError({\n pluginId,\n stage,\n zodError: result.error,\n }),\n );\n });\n"],"mappings":";;;;AAIA,MAAa,YACX,QACA,MACA,UACA,UAEA,OAAO,IAAI,aAAa;CACtB,MAAM,SAAS,OAAO,UAAU,IAAI;CACpC,IAAI,OAAO,SACT,OAAO,OAAO;CAEhB,OAAO,OAAO,OAAO,KACnB,IAAI,gBAAgB;EAClB;EACA;EACA,UAAU,OAAO;CACnB,CAAC,CACH;AACF,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","names":["createPluginRuntime"],"sources":["../../src/testing/index.ts"],"sourcesContent":["import type { LoadedPluginWithBinding } from \"../plugin\";\nimport { createPluginRuntime } from \"../runtime\";\nimport type { AnyPluginConstructor, PluginRegistryEntry, PluginRuntimeConfig } from \"../types\";\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 [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 oldRegistry: Record<string, { remoteUrl: string; version?: string; description?: string }>,\n pluginMap: T,\n): Record<keyof T, PluginRegistryEntry> {\n const registry: Record<string, PluginRegistryEntry> = {};\n\n for (const [pluginId, ctor] of Object.entries(pluginMap)) {\n const oldEntry = oldRegistry[pluginId];\n registry[pluginId] = {\n module: ctor as AnyPluginConstructor,\n remote: oldEntry?.remoteUrl,\n version: oldEntry?.version,\n description: oldEntry?.description,\n };\n }\n\n return 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 config: {\n registry: Record<string, { remoteUrl: string; version?: string; description?: string }>;\n secrets?: Record<string, string>;\n options?: any;\n },\n pluginMap: TMap,\n) {\n const newRegistry = convertPluginMapToRegistry(config.registry, pluginMap);\n\n return createPluginRuntime({\n registry: newRegistry,\n secrets: config.secrets,\n options: config.options,\n });\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,2BACP,aACA,WACsC;CACtC,MAAM,WAAgD,
|
|
1
|
+
{"version":3,"file":"index.cjs","names":["createPluginRuntime"],"sources":["../../src/testing/index.ts"],"sourcesContent":["import type { LoadedPluginWithBinding } from \"../plugin\";\nimport { createPluginRuntime } from \"../runtime\";\nimport type { AnyPluginConstructor, PluginRegistryEntry, PluginRuntimeConfig } from \"../types\";\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 [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 oldRegistry: Record<string, { remoteUrl: string; version?: string; description?: string }>,\n pluginMap: T,\n): Record<keyof T, PluginRegistryEntry> {\n const registry: Record<string, PluginRegistryEntry> = {};\n\n for (const [pluginId, ctor] of Object.entries(pluginMap)) {\n const oldEntry = oldRegistry[pluginId];\n registry[pluginId] = {\n module: ctor as AnyPluginConstructor,\n remote: oldEntry?.remoteUrl,\n version: oldEntry?.version,\n description: oldEntry?.description,\n };\n }\n\n return 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 config: {\n registry: Record<string, { remoteUrl: string; version?: string; description?: string }>;\n secrets?: Record<string, string>;\n options?: any;\n },\n pluginMap: TMap,\n) {\n const newRegistry = convertPluginMapToRegistry(config.registry, pluginMap);\n\n return createPluginRuntime({\n registry: newRegistry,\n secrets: config.secrets,\n options: config.options,\n });\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,2BACP,aACA,WACsC;CACtC,MAAM,WAAgD,CAAC;CAEvD,KAAK,MAAM,CAAC,UAAU,SAAS,OAAO,QAAQ,SAAS,GAAG;EACxD,MAAM,WAAW,YAAY;EAC7B,SAAS,YAAY;GACnB,QAAQ;GACR,QAAQ,UAAU;GAClB,SAAS,UAAU;GACnB,aAAa,UAAU;EACzB;CACF;CAEA,OAAO;AACT;;;;;;;;;;;;;;;;;;;;;;AAuBA,SAAgB,yBACd,QAKA,WACA;CAGA,OAAOA,0CAAoB;EACzB,UAHkB,2BAA2B,OAAO,UAAU,SAG1C;EACpB,SAAS,OAAO;EAChB,SAAS,OAAO;CAClB,CAAC;AACH;;;;AAKA,MAAa,0BAA0B"}
|