every-plugin 2.9.3 → 2.9.4

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.
@@ -21,7 +21,7 @@ function getInstalledPackageVersion(packageName, fallbackRange) {
21
21
  return match ? match[0] : fallbackRange.replace(/^[\^~>=<\s]+/, "");
22
22
  }
23
23
  }
24
- const PLUGIN_VERSION = "2.9.3";
24
+ const PLUGIN_VERSION = "2.9.4";
25
25
  const SHARE_CONFIG = {
26
26
  singleton: true,
27
27
  requiredVersion: false,
@@ -19,7 +19,7 @@ function getInstalledPackageVersion(packageName, fallbackRange) {
19
19
  return match ? match[0] : fallbackRange.replace(/^[\^~>=<\s]+/, "");
20
20
  }
21
21
  }
22
- const PLUGIN_VERSION = "2.9.3";
22
+ const PLUGIN_VERSION = "2.9.4";
23
23
  const SHARE_CONFIG = {
24
24
  singleton: true,
25
25
  requiredVersion: false,
@@ -63,18 +63,18 @@ var PluginLoaderService = class extends effect.Effect.Service()("PluginLoaderSer
63
63
  retryable: false
64
64
  }));
65
65
  const resolvedUrl = resolveUrl(url);
66
- yield* moduleFederationService.registerRemote(pluginId, resolvedUrl).pipe(effect.Effect.tapError((_error) => effect.Effect.logError(`Plugin ${pluginId} failed during register-remote`)), effect.Effect.mapError((error) => require_errors.toPluginRuntimeError(error, pluginId, void 0, "register-remote", true)));
66
+ yield* moduleFederationService.registerRemote(pluginId, resolvedUrl).pipe(effect.Effect.tapError((error) => effect.Effect.logError(`Plugin ${pluginId} failed during register-remote: ${error}`)), effect.Effect.mapError((error) => require_errors.toPluginRuntimeError(error, pluginId, void 0, "register-remote", true)));
67
67
  yield* effect.Effect.logDebug("Loading plugin from remote", {
68
68
  pluginId,
69
69
  url: resolvedUrl
70
70
  });
71
71
  return {
72
- ctor: yield* moduleFederationService.loadRemoteConstructor(pluginId, resolvedUrl).pipe(effect.Effect.tapError((_error) => effect.Effect.logError(`Plugin ${pluginId} failed during load-remote`)), effect.Effect.mapError((error) => require_errors.toPluginRuntimeError(error, pluginId, void 0, "load-remote", false))),
72
+ ctor: yield* moduleFederationService.loadRemoteConstructor(pluginId, resolvedUrl).pipe(effect.Effect.tapError((error) => effect.Effect.logError(`Plugin ${pluginId} failed during load-remote: ${error}`)), effect.Effect.mapError((error) => require_errors.toPluginRuntimeError(error, pluginId, void 0, "load-remote", false))),
73
73
  metadata: entry.metadata
74
74
  };
75
75
  }),
76
76
  instantiatePlugin: (pluginId, loadedPlugin) => effect.Effect.gen(function* () {
77
- const instance = yield* effect.Effect.try(() => new loadedPlugin.ctor()).pipe(effect.Effect.tapError((_error) => effect.Effect.logError(`Plugin ${pluginId} failed during instantiate-plugin`)), effect.Effect.mapError((error) => require_errors.toPluginRuntimeError(error, pluginId, void 0, "instantiate-plugin", false)));
77
+ const instance = yield* effect.Effect.try(() => new loadedPlugin.ctor()).pipe(effect.Effect.tapError((error) => effect.Effect.logError(`Plugin ${pluginId} failed during instantiate-plugin: ${error}`)), effect.Effect.mapError((error) => require_errors.toPluginRuntimeError(error, pluginId, void 0, "instantiate-plugin", false)));
78
78
  instance.id = pluginId;
79
79
  return {
80
80
  plugin: instance,
@@ -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((_error) => effect.Effect.logError(`Plugin ${plugin.id} failed during initialize-plugin`)), 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(effect.Scope.Scope, scope), 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"],"sources":["../../../src/runtime/services/plugin-loader.service.ts"],"sourcesContent":["import type { InferSchemaInput, InferSchemaOutput } from \"@orpc/contract\";\nimport { Context, Effect, Context as EffectContext, 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`),\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`),\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`),\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 // The plugin's initialize method handles:\n // 1. Building services (DB pools, caches) via tools.buildService\n // 2. Shaping final deps via initialize\n // Any Layer.scoped resources built through tools.buildService are\n // bound to the plugin scope and persist until the plugin is shutdown.\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((_error) =>\n Effect.logError(`Plugin ${plugin.id} failed during initialize-plugin`),\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;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BACC,IAAIC,kCAAmB;IACrB,UAAU,OAAO;IACjB,WAAW;IACX,OAAO,gBAAgB;IACvB,WAAW;IACZ,CAAC,CACL,CACF;GAGD,MAAM,iBAAiB,OAAO,eAAe,eAAe;IAC1D,WAAW;IACX,SAAS;IACV,CAAC;GAEF,MAAM,aAAa,OAAOI,4BACxB,OAAO,aAAa,WAGpB,eAAe,WACf,OAAO,IACP,SACD,CAAC,KACAL,cAAO,UACJ,oBACC,IAAIC,kCAAmB;IACrB,UAAU,OAAO;IACjB,WAAW;IACX,OAAO,gBAAgB;IACvB,WAAW;IACZ,CAAC,CACL,CACF;GAGD,MAAM,QAAQ,OAAOK,aAAM,MAAM;GAGjC,MAAM,UAAU,OAAOC,aAAM;GAe7B,MAAM,UAAU,OAAO,OACpB,WACC;IAAE,WAAW;IAAY,SAAS,eAAe;IAAS,EAC1D,WAAW,EAAE,EACb,EAhBF,eAAe,KAAU,UACtBA,aAAM,iBAAiB,OAAO,SAAS,MAAM,CAAS,KACrDP,cAAO,KAAK,QAAaQ,eAAc,IAAI,KAAK,IAAI,CAAC,CACtD,EAaI,CACN,CACA,KACCR,cAAO,eAAeM,aAAM,OAAO,MAAM,EACzCN,cAAO,UAAU,WACfA,cAAO,SAAS,UAAU,OAAO,GAAG,kCAAkC,CACvE,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"],"sources":["../../../src/runtime/services/plugin-loader.service.ts"],"sourcesContent":["import type { InferSchemaInput, InferSchemaOutput } from \"@orpc/contract\";\nimport { Context, Effect, Context as EffectContext, 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 // The plugin's initialize method handles:\n // 1. Building services (DB pools, caches) via tools.buildService\n // 2. Shaping final deps via initialize\n // Any Layer.scoped resources built through tools.buildService are\n // bound to the plugin scope and persist until the plugin is shutdown.\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((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,UA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D,MAAM,QAAQ,OAAOK,aAAM,MAAM;GAGjC,MAAM,UAAU,OAAOC,aAAM;GAe7B,MAAM,UAAU,OAAO,OACpB,WACC;IAAE,WAAW;IAAY,SAAS,eAAe;IAAS,EAC1D,WAAW,EAAE,EACb,EAhBF,eAAe,KAAU,UACtBA,aAAM,iBAAiB,OAAO,SAAS,MAAM,CAAS,KACrDP,cAAO,KAAK,QAAaQ,eAAc,IAAI,KAAK,IAAI,CAAC,CACtD,EAaI,CACN,CACA,KACCR,cAAO,eAAeM,aAAM,OAAO,MAAM,EACzCN,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"}
@@ -62,18 +62,18 @@ var PluginLoaderService = class extends Effect.Service()("PluginLoaderService",
62
62
  retryable: false
63
63
  }));
64
64
  const resolvedUrl = resolveUrl(url);
65
- yield* moduleFederationService.registerRemote(pluginId, resolvedUrl).pipe(Effect.tapError((_error) => Effect.logError(`Plugin ${pluginId} failed during register-remote`)), Effect.mapError((error) => toPluginRuntimeError(error, pluginId, void 0, "register-remote", true)));
65
+ yield* moduleFederationService.registerRemote(pluginId, resolvedUrl).pipe(Effect.tapError((error) => Effect.logError(`Plugin ${pluginId} failed during register-remote: ${error}`)), Effect.mapError((error) => toPluginRuntimeError(error, pluginId, void 0, "register-remote", true)));
66
66
  yield* Effect.logDebug("Loading plugin from remote", {
67
67
  pluginId,
68
68
  url: resolvedUrl
69
69
  });
70
70
  return {
71
- ctor: yield* moduleFederationService.loadRemoteConstructor(pluginId, resolvedUrl).pipe(Effect.tapError((_error) => Effect.logError(`Plugin ${pluginId} failed during load-remote`)), Effect.mapError((error) => toPluginRuntimeError(error, pluginId, void 0, "load-remote", false))),
71
+ ctor: yield* moduleFederationService.loadRemoteConstructor(pluginId, resolvedUrl).pipe(Effect.tapError((error) => Effect.logError(`Plugin ${pluginId} failed during load-remote: ${error}`)), Effect.mapError((error) => toPluginRuntimeError(error, pluginId, void 0, "load-remote", false))),
72
72
  metadata: entry.metadata
73
73
  };
74
74
  }),
75
75
  instantiatePlugin: (pluginId, loadedPlugin) => Effect.gen(function* () {
76
- const instance = yield* Effect.try(() => new loadedPlugin.ctor()).pipe(Effect.tapError((_error) => Effect.logError(`Plugin ${pluginId} failed during instantiate-plugin`)), Effect.mapError((error) => toPluginRuntimeError(error, pluginId, void 0, "instantiate-plugin", false)));
76
+ const instance = yield* Effect.try(() => new loadedPlugin.ctor()).pipe(Effect.tapError((error) => Effect.logError(`Plugin ${pluginId} failed during instantiate-plugin: ${error}`)), Effect.mapError((error) => toPluginRuntimeError(error, pluginId, void 0, "instantiate-plugin", false)));
77
77
  instance.id = pluginId;
78
78
  return {
79
79
  plugin: instance,
@@ -109,7 +109,7 @@ var PluginLoaderService = class extends Effect.Service()("PluginLoaderService",
109
109
  const context = yield* plugin.initialize({
110
110
  variables: _variables,
111
111
  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((_error) => Effect.logError(`Plugin ${plugin.id} failed during initialize-plugin`)), Effect.mapError((error) => toPluginRuntimeError(error, plugin.id, void 0, "initialize-plugin", false)));
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((error) => Effect.logError(`Plugin ${plugin.id} failed during initialize-plugin: ${error}`)), Effect.mapError((error) => toPluginRuntimeError(error, plugin.id, void 0, "initialize-plugin", false)));
113
113
  return {
114
114
  plugin,
115
115
  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, 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`),\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`),\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`),\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 // The plugin's initialize method handles:\n // 1. Building services (DB pools, caches) via tools.buildService\n // 2. Shaping final deps via initialize\n // Any Layer.scoped resources built through tools.buildService are\n // bound to the plugin scope and persist until the plugin is shutdown.\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((_error) =>\n Effect.logError(`Plugin ${plugin.id} failed during initialize-plugin`),\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,MA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O,IACP,SACD,CAAC,KACA,OAAO,UACJ,oBACC,IAAI,mBAAmB;IACrB,UAAU,OAAO;IACjB,WAAW;IACX,OAAO,gBAAgB;IACvB,WAAW;IACZ,CAAC,CACL,CACF;GAGD,MAAM,QAAQ,OAAO,MAAM,MAAM;GAGjC,MAAM,UAAU,OAAO,MAAM;GAe7B,MAAM,UAAU,OAAO,OACpB,WACC;IAAE,WAAW;IAAY,SAAS,eAAe;IAAS,EAC1D,WAAW,EAAE,EACb,EAhBF,eAAe,KAAU,UACtB,MAAM,iBAAiB,OAAO,SAAS,MAAM,CAAS,KACrD,OAAO,KAAK,QAAaA,QAAc,IAAI,KAAK,IAAI,CAAC,CACtD,EAaI,CACN,CACA,KACC,OAAO,eAAe,MAAM,OAAO,MAAM,EACzC,OAAO,UAAU,WACf,OAAO,SAAS,UAAU,OAAO,GAAG,kCAAkC,CACvE,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, 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 // The plugin's initialize method handles:\n // 1. Building services (DB pools, caches) via tools.buildService\n // 2. Shaping final deps via initialize\n // Any Layer.scoped resources built through tools.buildService are\n // bound to the plugin scope and persist until the plugin is shutdown.\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((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/B,MAAM,c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,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"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "every-plugin",
3
- "version": "2.9.3",
3
+ "version": "2.9.4",
4
4
  "type": "module",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -113,8 +113,8 @@ export class PluginLoaderService extends Effect.Service<PluginLoaderService>()(
113
113
  const resolvedUrl = resolveUrl(url);
114
114
 
115
115
  yield* moduleFederationService.registerRemote(pluginId, resolvedUrl).pipe(
116
- Effect.tapError((_error) =>
117
- Effect.logError(`Plugin ${pluginId} failed during register-remote`),
116
+ Effect.tapError((error) =>
117
+ Effect.logError(`Plugin ${pluginId} failed during register-remote: ${error}`),
118
118
  ),
119
119
  Effect.mapError((error) =>
120
120
  toPluginRuntimeError(error, pluginId, undefined, "register-remote", true),
@@ -126,8 +126,8 @@ export class PluginLoaderService extends Effect.Service<PluginLoaderService>()(
126
126
  const ctor = yield* moduleFederationService
127
127
  .loadRemoteConstructor(pluginId, resolvedUrl)
128
128
  .pipe(
129
- Effect.tapError((_error) =>
130
- Effect.logError(`Plugin ${pluginId} failed during load-remote`),
129
+ Effect.tapError((error) =>
130
+ Effect.logError(`Plugin ${pluginId} failed during load-remote: ${error}`),
131
131
  ),
132
132
  Effect.mapError((error) =>
133
133
  toPluginRuntimeError(error, pluginId, undefined, "load-remote", false),
@@ -143,8 +143,8 @@ export class PluginLoaderService extends Effect.Service<PluginLoaderService>()(
143
143
  instantiatePlugin: <T extends AnyPlugin>(pluginId: string, loadedPlugin: LoadedPlugin<T>) =>
144
144
  Effect.gen(function* () {
145
145
  const instance = yield* Effect.try(() => new loadedPlugin.ctor()).pipe(
146
- Effect.tapError((_error) =>
147
- Effect.logError(`Plugin ${pluginId} failed during instantiate-plugin`),
146
+ Effect.tapError((error) =>
147
+ Effect.logError(`Plugin ${pluginId} failed during instantiate-plugin: ${error}`),
148
148
  ),
149
149
  Effect.mapError((error) =>
150
150
  toPluginRuntimeError(error, pluginId, undefined, "instantiate-plugin", false),
@@ -262,8 +262,8 @@ export class PluginLoaderService extends Effect.Service<PluginLoaderService>()(
262
262
  )
263
263
  .pipe(
264
264
  Effect.provideService(Scope.Scope, scope),
265
- Effect.tapError((_error) =>
266
- Effect.logError(`Plugin ${plugin.id} failed during initialize-plugin`),
265
+ Effect.tapError((error) =>
266
+ Effect.logError(`Plugin ${plugin.id} failed during initialize-plugin: ${error}`),
267
267
  ),
268
268
  Effect.mapError((error) =>
269
269
  toPluginRuntimeError(error, plugin.id, undefined, "initialize-plugin", false),