every-plugin 0.8.9 → 2.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (182) hide show
  1. package/dist/_virtual/{rolldown_runtime.cjs → _rolldown/runtime.cjs} +15 -1
  2. package/dist/_virtual/{rolldown_runtime.mjs → _rolldown/runtime.mjs} +15 -2
  3. package/dist/build/rspack/dev-server-middleware.cjs +15 -4
  4. package/dist/build/rspack/dev-server-middleware.cjs.map +1 -1
  5. package/dist/build/rspack/dev-server-middleware.mjs +15 -4
  6. package/dist/build/rspack/dev-server-middleware.mjs.map +1 -1
  7. package/dist/build/rspack/fix-mf-data-uri-plugin.cjs +44 -0
  8. package/dist/build/rspack/fix-mf-data-uri-plugin.cjs.map +1 -0
  9. package/dist/build/rspack/fix-mf-data-uri-plugin.d.cts +11 -0
  10. package/dist/build/rspack/fix-mf-data-uri-plugin.d.cts.map +1 -0
  11. package/dist/build/rspack/fix-mf-data-uri-plugin.d.mts +11 -0
  12. package/dist/build/rspack/fix-mf-data-uri-plugin.d.mts.map +1 -0
  13. package/dist/build/rspack/fix-mf-data-uri-plugin.mjs +43 -0
  14. package/dist/build/rspack/fix-mf-data-uri-plugin.mjs.map +1 -0
  15. package/dist/build/rspack/index.cjs +8 -6
  16. package/dist/build/rspack/index.d.cts +4 -3
  17. package/dist/build/rspack/index.d.mts +4 -3
  18. package/dist/build/rspack/index.mjs +4 -3
  19. package/dist/build/rspack/module-federation.cjs +3 -3
  20. package/dist/build/rspack/module-federation.cjs.map +1 -1
  21. package/dist/build/rspack/module-federation.mjs +1 -1
  22. package/dist/build/rspack/module-federation.mjs.map +1 -1
  23. package/dist/build/rspack/plugin.cjs +83 -5
  24. package/dist/build/rspack/plugin.cjs.map +1 -1
  25. package/dist/build/rspack/plugin.d.cts +12 -1
  26. package/dist/build/rspack/plugin.d.cts.map +1 -1
  27. package/dist/build/rspack/plugin.d.mts +12 -1
  28. package/dist/build/rspack/plugin.d.mts.map +1 -1
  29. package/dist/build/rspack/plugin.mjs +80 -5
  30. package/dist/build/rspack/plugin.mjs.map +1 -1
  31. package/dist/build/rspack/utils.cjs +5 -4
  32. package/dist/build/rspack/utils.cjs.map +1 -1
  33. package/dist/build/rspack/utils.mjs +3 -2
  34. package/dist/build/rspack/utils.mjs.map +1 -1
  35. package/dist/build/shared-deps.cjs +50 -65
  36. package/dist/build/shared-deps.cjs.map +1 -1
  37. package/dist/build/shared-deps.d.cts +27 -4
  38. package/dist/build/shared-deps.d.cts.map +1 -1
  39. package/dist/build/shared-deps.d.mts +27 -4
  40. package/dist/build/shared-deps.d.mts.map +1 -1
  41. package/dist/build/shared-deps.mjs +48 -64
  42. package/dist/build/shared-deps.mjs.map +1 -1
  43. package/dist/errors.cjs +1 -0
  44. package/dist/errors.cjs.map +1 -1
  45. package/dist/errors.d.cts.map +1 -1
  46. package/dist/errors.d.mts.map +1 -1
  47. package/dist/errors.mjs.map +1 -1
  48. package/dist/index.cjs +2 -0
  49. package/dist/index.d.cts +2 -2
  50. package/dist/index.d.mts +2 -2
  51. package/dist/index.mjs +2 -2
  52. package/dist/orpc-client.cjs +17 -0
  53. package/dist/orpc-client.d.cts +2 -0
  54. package/dist/orpc-client.d.mts +2 -0
  55. package/dist/orpc-client.mjs +5 -0
  56. package/dist/orpc-openapi.cjs +17 -0
  57. package/dist/orpc-openapi.d.cts +2 -0
  58. package/dist/orpc-openapi.d.mts +2 -0
  59. package/dist/orpc-openapi.mjs +5 -0
  60. package/dist/orpc.cjs +8 -7
  61. package/dist/plugin.cjs +10 -9
  62. package/dist/plugin.cjs.map +1 -1
  63. package/dist/plugin.d.cts +28 -29
  64. package/dist/plugin.d.cts.map +1 -1
  65. package/dist/plugin.d.mts +28 -29
  66. package/dist/plugin.d.mts.map +1 -1
  67. package/dist/plugin.mjs +10 -10
  68. package/dist/plugin.mjs.map +1 -1
  69. package/dist/runtime/errors.cjs +2 -2
  70. package/dist/runtime/errors.cjs.map +1 -1
  71. package/dist/runtime/errors.d.cts +4 -4
  72. package/dist/runtime/errors.d.cts.map +1 -1
  73. package/dist/runtime/errors.d.mts +4 -4
  74. package/dist/runtime/errors.d.mts.map +1 -1
  75. package/dist/runtime/errors.mjs +1 -1
  76. package/dist/runtime/errors.mjs.map +1 -1
  77. package/dist/runtime/index.cjs +24 -20
  78. package/dist/runtime/index.cjs.map +1 -1
  79. package/dist/runtime/index.d.cts +3 -3
  80. package/dist/runtime/index.d.cts.map +1 -1
  81. package/dist/runtime/index.d.mts +3 -3
  82. package/dist/runtime/index.d.mts.map +1 -1
  83. package/dist/runtime/index.mjs +12 -9
  84. package/dist/runtime/index.mjs.map +1 -1
  85. package/dist/runtime/mf-config.cjs +33 -0
  86. package/dist/runtime/mf-config.cjs.map +1 -0
  87. package/dist/runtime/mf-config.d.cts +41 -0
  88. package/dist/runtime/mf-config.d.cts.map +1 -0
  89. package/dist/runtime/mf-config.d.mts +41 -0
  90. package/dist/runtime/mf-config.d.mts.map +1 -0
  91. package/dist/runtime/mf-config.mjs +29 -0
  92. package/dist/runtime/mf-config.mjs.map +1 -0
  93. package/dist/runtime/services/module-federation.service.cjs +19 -56
  94. package/dist/runtime/services/module-federation.service.cjs.map +1 -1
  95. package/dist/runtime/services/module-federation.service.d.cts.map +1 -1
  96. package/dist/runtime/services/module-federation.service.d.mts.map +1 -1
  97. package/dist/runtime/services/module-federation.service.mjs +18 -55
  98. package/dist/runtime/services/module-federation.service.mjs.map +1 -1
  99. package/dist/runtime/services/normalize.cjs +3 -2
  100. package/dist/runtime/services/normalize.cjs.map +1 -1
  101. package/dist/runtime/services/normalize.d.cts.map +1 -1
  102. package/dist/runtime/services/normalize.d.mts.map +1 -1
  103. package/dist/runtime/services/normalize.mjs +2 -2
  104. package/dist/runtime/services/normalize.mjs.map +1 -1
  105. package/dist/runtime/services/plugin-lifecycle.service.cjs +1 -1
  106. package/dist/runtime/services/plugin-lifecycle.service.cjs.map +1 -1
  107. package/dist/runtime/services/plugin-lifecycle.service.d.cts.map +1 -1
  108. package/dist/runtime/services/plugin-lifecycle.service.d.mts.map +1 -1
  109. package/dist/runtime/services/plugin-lifecycle.service.mjs.map +1 -1
  110. package/dist/runtime/services/plugin-loader.service.cjs +3 -3
  111. package/dist/runtime/services/plugin-loader.service.cjs.map +1 -1
  112. package/dist/runtime/services/plugin-loader.service.d.cts +1 -1
  113. package/dist/runtime/services/plugin-loader.service.d.cts.map +1 -1
  114. package/dist/runtime/services/plugin-loader.service.d.mts +1 -1
  115. package/dist/runtime/services/plugin-loader.service.d.mts.map +1 -1
  116. package/dist/runtime/services/plugin-loader.service.mjs +2 -2
  117. package/dist/runtime/services/plugin-loader.service.mjs.map +1 -1
  118. package/dist/runtime/services/plugin.service.cjs +1 -1
  119. package/dist/runtime/services/plugin.service.cjs.map +1 -1
  120. package/dist/runtime/services/plugin.service.d.cts +6 -7
  121. package/dist/runtime/services/plugin.service.d.cts.map +1 -1
  122. package/dist/runtime/services/plugin.service.d.mts +6 -7
  123. package/dist/runtime/services/plugin.service.d.mts.map +1 -1
  124. package/dist/runtime/services/plugin.service.mjs.map +1 -1
  125. package/dist/runtime/services/secrets.service.cjs +4 -4
  126. package/dist/runtime/services/secrets.service.cjs.map +1 -1
  127. package/dist/runtime/services/secrets.service.d.cts.map +1 -1
  128. package/dist/runtime/services/secrets.service.d.mts.map +1 -1
  129. package/dist/runtime/services/secrets.service.mjs +3 -3
  130. package/dist/runtime/services/secrets.service.mjs.map +1 -1
  131. package/dist/runtime/validation.cjs +1 -1
  132. package/dist/runtime/validation.cjs.map +1 -1
  133. package/dist/runtime/validation.mjs.map +1 -1
  134. package/dist/testing/index.cjs +2 -1
  135. package/dist/testing/index.cjs.map +1 -1
  136. package/dist/testing/index.d.cts +0 -2
  137. package/dist/testing/index.d.cts.map +1 -1
  138. package/dist/testing/index.d.mts +0 -2
  139. package/dist/testing/index.d.mts.map +1 -1
  140. package/dist/testing/index.mjs +1 -1
  141. package/dist/testing/index.mjs.map +1 -1
  142. package/dist/types.d.cts +22 -22
  143. package/dist/types.d.cts.map +1 -1
  144. package/dist/types.d.mts +22 -22
  145. package/dist/types.d.mts.map +1 -1
  146. package/dist/zod.cjs +4 -3
  147. package/dist/zod.mjs +2 -2
  148. package/package.json +204 -194
  149. package/src/build/rspack/dev-server-middleware.ts +233 -0
  150. package/src/build/rspack/fix-mf-data-uri-plugin.ts +49 -0
  151. package/src/build/rspack/index.ts +14 -0
  152. package/src/build/rspack/module-federation.ts +6 -0
  153. package/src/build/rspack/plugin.ts +252 -0
  154. package/src/build/rspack/utils.ts +60 -0
  155. package/src/build/shared-deps.ts +79 -0
  156. package/src/effect.ts +1 -0
  157. package/src/errors.ts +140 -0
  158. package/src/index.ts +26 -0
  159. package/src/orpc-client.ts +2 -0
  160. package/src/orpc-openapi.ts +2 -0
  161. package/src/orpc.ts +9 -0
  162. package/src/plugin.ts +220 -0
  163. package/src/runtime/errors.ts +332 -0
  164. package/src/runtime/index.ts +258 -0
  165. package/src/runtime/mf-config.ts +29 -0
  166. package/src/runtime/services/module-federation.service.ts +181 -0
  167. package/src/runtime/services/normalize.ts +18 -0
  168. package/src/runtime/services/plugin-lifecycle.service.ts +86 -0
  169. package/src/runtime/services/plugin-loader.service.ts +254 -0
  170. package/src/runtime/services/plugin.service.ts +66 -0
  171. package/src/runtime/services/secrets.service.ts +74 -0
  172. package/src/runtime/services.ts +5 -0
  173. package/src/runtime/validation.ts +23 -0
  174. package/src/testing/index.ts +87 -0
  175. package/src/testing/mocks/module-federation.service.ts +41 -0
  176. package/src/types.ts +309 -0
  177. package/src/zod-core.ts +4 -0
  178. package/src/zod.ts +1 -0
  179. package/dist/package.cjs +0 -47
  180. package/dist/package.cjs.map +0 -1
  181. package/dist/package.mjs +0 -29
  182. package/dist/package.mjs.map +0 -1
@@ -0,0 +1,23 @@
1
+ import { Effect } from "effect";
2
+ import type { z } from "zod";
3
+ import { ValidationError } from "./errors";
4
+
5
+ export const validate = <T>(
6
+ schema: z.ZodSchema<T>,
7
+ data: unknown,
8
+ pluginId: string,
9
+ stage: "config" | "input" | "output" | "state",
10
+ ): Effect.Effect<T, ValidationError> =>
11
+ Effect.gen(function* () {
12
+ const result = schema.safeParse(data);
13
+ if (result.success) {
14
+ return result.data;
15
+ }
16
+ return yield* Effect.fail(
17
+ new ValidationError({
18
+ pluginId,
19
+ stage,
20
+ zodError: result.error,
21
+ }),
22
+ );
23
+ });
@@ -0,0 +1,87 @@
1
+ import type { LoadedPluginWithBinding } from "../plugin";
2
+ import { createPluginRuntime } from "../runtime";
3
+ import type { AnyPluginConstructor, PluginRegistryEntry, PluginRuntimeConfig } from "../types";
4
+
5
+ export type PluginMap = Record<string, LoadedPluginWithBinding<any, any, any, any>>;
6
+
7
+ /**
8
+ * Simplified type inference for local plugin maps.
9
+ * Just use the constructor types directly.
10
+ *
11
+ * @example
12
+ * ```ts
13
+ * const pluginMap = { "my-plugin": MyPlugin } as const;
14
+ * type MyBindings = InferBindingsFromMap<typeof pluginMap>;
15
+ * ```
16
+ */
17
+ export type InferBindingsFromMap<T extends PluginMap> = {
18
+ [K in keyof T]: T[K];
19
+ };
20
+
21
+ /**
22
+ * Converts old pluginMap format to new registry format
23
+ */
24
+ function convertPluginMapToRegistry<T extends PluginMap>(
25
+ oldRegistry: Record<string, { remoteUrl: string; version?: string; description?: string }>,
26
+ pluginMap: T,
27
+ ): Record<keyof T, PluginRegistryEntry> {
28
+ const registry: Record<string, PluginRegistryEntry> = {};
29
+
30
+ for (const [pluginId, ctor] of Object.entries(pluginMap)) {
31
+ const oldEntry = oldRegistry[pluginId];
32
+ registry[pluginId] = {
33
+ module: ctor as AnyPluginConstructor,
34
+ remote: oldEntry?.remoteUrl,
35
+ version: oldEntry?.version,
36
+ description: oldEntry?.description,
37
+ };
38
+ }
39
+
40
+ return registry as Record<keyof T, PluginRegistryEntry>;
41
+ }
42
+
43
+ /**
44
+ * Creates a plugin runtime for locally available plugins (non-remote).
45
+ * Automatically infers type bindings from the plugin map, eliminating
46
+ * the need for manual RegistryBindings definitions.
47
+ *
48
+ * @deprecated Use `createPluginRuntime` with module entries directly instead.
49
+ * @example
50
+ * ```ts
51
+ * // Old API (deprecated)
52
+ * const runtime = createLocalPluginRuntime(
53
+ * { registry: { "my-plugin": { remoteUrl: "..." } }, secrets },
54
+ * { "my-plugin": MyPlugin }
55
+ * );
56
+ *
57
+ * // New API (recommended)
58
+ * const runtime = createPluginRuntime({
59
+ * registry: { "my-plugin": { module: MyPlugin } },
60
+ * secrets
61
+ * });
62
+ * ```
63
+ */
64
+ export function createLocalPluginRuntime<TMap extends PluginMap>(
65
+ config: {
66
+ registry: Record<string, { remoteUrl: string; version?: string; description?: string }>;
67
+ secrets?: Record<string, string>;
68
+ options?: any;
69
+ },
70
+ pluginMap: TMap,
71
+ ) {
72
+ const newRegistry = convertPluginMapToRegistry(config.registry, pluginMap);
73
+
74
+ return createPluginRuntime({
75
+ registry: newRegistry,
76
+ secrets: config.secrets,
77
+ options: config.options,
78
+ });
79
+ }
80
+
81
+ /**
82
+ * @deprecated Use `createLocalPluginRuntime` or `createPluginRuntime` instead.
83
+ */
84
+ export const createTestPluginRuntime = createLocalPluginRuntime;
85
+
86
+ export type { EveryPlugin, PluginRegistry, RegisteredPlugins } from "../types";
87
+ export type { PluginRuntimeConfig };
@@ -0,0 +1,41 @@
1
+ import { Effect, Layer } from "effect";
2
+ import type { LoadedPluginWithBinding } from "../../plugin";
3
+ import { ModuleFederationError } from "../../runtime/errors";
4
+ import { ModuleFederationService } from "../../runtime/services/module-federation.service";
5
+
6
+ export type PluginMap = Record<string, LoadedPluginWithBinding<any, any, any, any>>;
7
+
8
+ export const createMockModuleFederationServiceLayer = (pluginMap: PluginMap) =>
9
+ Layer.succeed(ModuleFederationService, {
10
+ registerRemote: (pluginId: string, url: string) =>
11
+ Effect.gen(function* () {
12
+ console.log(`[MOCK] registerRemote called for ${pluginId}`);
13
+ if (!(pluginId in pluginMap)) {
14
+ return yield* Effect.fail(
15
+ new ModuleFederationError({
16
+ pluginId,
17
+ remoteUrl: url,
18
+ cause: new Error(`Mock: Plugin ${pluginId} not available in test plugin map`),
19
+ }),
20
+ );
21
+ }
22
+ console.log(`[MOCK] registerRemote succeeded for ${pluginId}`);
23
+ }),
24
+
25
+ loadRemoteConstructor: (pluginId: string, url: string) =>
26
+ Effect.gen(function* () {
27
+ console.log(`[MOCK] loadRemoteConstructor called for ${pluginId}`);
28
+ const PluginConstructor = pluginMap[pluginId];
29
+ if (!PluginConstructor) {
30
+ return yield* Effect.fail(
31
+ new ModuleFederationError({
32
+ pluginId,
33
+ remoteUrl: url,
34
+ cause: new Error(`Mock: Constructor for ${pluginId} not found in test plugin map`),
35
+ }),
36
+ );
37
+ }
38
+ console.log(`[MOCK] loadRemoteConstructor succeeded for ${pluginId}`);
39
+ return PluginConstructor;
40
+ }),
41
+ } as any);
package/src/types.ts ADDED
@@ -0,0 +1,309 @@
1
+ import type {
2
+ AnyContractRouter,
3
+ AnySchema,
4
+ InferSchemaInput,
5
+ InferSchemaOutput,
6
+ } from "@orpc/contract";
7
+ import type { Router, RouterClient } from "@orpc/server";
8
+ import type { Scope } from "effect";
9
+ import type { Plugin } from "./plugin";
10
+
11
+ /**
12
+ * Registry bindings interface - populated via module augmentation
13
+ * Only needed for remote-only plugin entries.
14
+ * @example
15
+ * ```typescript
16
+ * declare module "every-plugin" {
17
+ * interface RegisteredPlugins {
18
+ * "my-plugin": typeof MyPlugin;
19
+ * }
20
+ * }
21
+ * ```
22
+ */
23
+ // biome-ignore lint/suspicious/noEmptyInterface: required for module augmentation pattern
24
+ export interface RegisteredPlugins {}
25
+
26
+ /**
27
+ * Base type for any plugin instance.
28
+ */
29
+ export type AnyPlugin = Plugin<AnyContractRouter, AnySchema, AnySchema, AnySchema | undefined, any>;
30
+
31
+ /**
32
+ * Loaded plugin constructor with binding information
33
+ */
34
+ export type AnyPluginConstructor = {
35
+ new (): AnyPlugin;
36
+ binding: {
37
+ contract: AnyContractRouter;
38
+ variables: AnySchema;
39
+ secrets: AnySchema;
40
+ context: AnySchema | undefined;
41
+ };
42
+ };
43
+
44
+ /**
45
+ * Registry entry that supports both direct module imports and remote URLs
46
+ */
47
+ export type PluginRegistryEntry =
48
+ | { module: AnyPluginConstructor; remote?: string; version?: string; description?: string }
49
+ | { remote: string; version?: string; description?: string };
50
+
51
+ /**
52
+ * Extract plugin constructor type from registry entry
53
+ */
54
+ export type ExtractPluginType<E> = E extends { module: infer M } ? M : never;
55
+
56
+ /**
57
+ * Infer registry types from plugin entries with module constructors
58
+ */
59
+ export type InferRegistryFromEntries<R extends Record<string, PluginRegistryEntry>> = {
60
+ [K in keyof R]: R[K] extends { module: infer M }
61
+ ? M
62
+ : K extends keyof RegisteredPlugins
63
+ ? RegisteredPlugins[K]
64
+ : never;
65
+ };
66
+
67
+ /**
68
+ * Extract contract type from plugin binding
69
+ */
70
+ export type PluginContract<T> = T extends {
71
+ binding: { contract: infer C extends AnyContractRouter };
72
+ }
73
+ ? C
74
+ : never;
75
+
76
+ /**
77
+ * Extract variables type from plugin binding
78
+ */
79
+ export type PluginVariables<T> = T extends { binding: { variables: infer V extends AnySchema } }
80
+ ? V
81
+ : never;
82
+
83
+ /**
84
+ * Extract secrets type from plugin binding
85
+ */
86
+ export type PluginSecrets<T> = T extends { binding: { secrets: infer S extends AnySchema } }
87
+ ? S
88
+ : never;
89
+
90
+ /**
91
+ * Extract context schema type from plugin binding
92
+ */
93
+ export type PluginContext<T> = T extends {
94
+ binding: { context: infer C extends AnySchema | undefined };
95
+ }
96
+ ? C
97
+ : never;
98
+
99
+ /**
100
+ * Extract router type from plugin binding
101
+ * Uses 'any' for context to support nested router compositions
102
+ */
103
+ export type PluginRouterType<T> = Router<PluginContract<T>, any>;
104
+
105
+ /**
106
+ * Extract client type from plugin binding
107
+ */
108
+ export type PluginClientType<T> = RouterClient<PluginRouterType<T>>;
109
+
110
+ /**
111
+ * Extract plugin type from registered plugins by key
112
+ * @param K - The plugin key
113
+ * @param R - The registry type (defaults to RegisteredPlugins for module augmentation pattern)
114
+ */
115
+ export type RegisteredPlugin<K extends keyof R, R = RegisteredPlugins> = R[K] extends {
116
+ binding: infer B;
117
+ }
118
+ ? B extends {
119
+ contract: infer C extends AnyContractRouter;
120
+ variables: infer V extends AnySchema;
121
+ secrets: infer S extends AnySchema;
122
+ context: infer TRequestContext extends AnySchema | undefined;
123
+ }
124
+ ? Plugin<C, V, S, TRequestContext, any>
125
+ : never
126
+ : never;
127
+
128
+ /**
129
+ * Extract plugin constructor type from registry entry
130
+ */
131
+ export type PluginConstructor<K extends keyof R, R = RegisteredPlugins> = RegisteredPlugin<K, R>;
132
+
133
+ /**
134
+ * Extract context input type from plugin binding (for client creation)
135
+ */
136
+ export type PluginContextInput<T> =
137
+ PluginContext<T> extends AnySchema ? InferSchemaInput<PluginContext<T>> : never;
138
+
139
+ /**
140
+ * Extract config input type from plugin binding
141
+ */
142
+ export type PluginConfigInput<T> = {
143
+ variables: InferSchemaInput<PluginVariables<T>>;
144
+ secrets: InferSchemaInput<PluginSecrets<T>>;
145
+ };
146
+
147
+ /**
148
+ * Extract deps context type from plugin instance (used for initialization)
149
+ */
150
+ export type ContextOf<T extends AnyPlugin> =
151
+ T extends Plugin<AnyContractRouter, AnySchema, AnySchema, AnySchema | undefined, infer TDeps>
152
+ ? TDeps
153
+ : never;
154
+
155
+ /**
156
+ * Plugin metadata for remote loading
157
+ */
158
+ export type PluginMetadata = {
159
+ readonly remoteUrl: string;
160
+ readonly version?: string;
161
+ readonly description?: string;
162
+ };
163
+
164
+ /**
165
+ * Runtime registry configuration supporting both module and remote entries
166
+ */
167
+ export type PluginRegistry = Record<string, PluginRegistryEntry>;
168
+
169
+ /**
170
+ * Legacy metadata-only registry (for backwards compatibility)
171
+ */
172
+ export type PluginMetadataRegistry = Record<string, PluginMetadata>;
173
+
174
+ /**
175
+ * Configuration for secrets injection.
176
+ * Secrets are hydrated into plugin configs using template replacement.
177
+ */
178
+ export interface SecretsConfig {
179
+ [key: string]: string;
180
+ }
181
+
182
+ /**
183
+ * Loaded plugin
184
+ */
185
+ export interface LoadedPlugin<T extends AnyPlugin = AnyPlugin> {
186
+ readonly ctor: new () => T;
187
+ readonly metadata: PluginMetadata;
188
+ }
189
+
190
+ /**
191
+ * Instantiated plugin
192
+ */
193
+ export interface PluginInstance<T extends AnyPlugin = AnyPlugin> {
194
+ readonly plugin: T;
195
+ readonly metadata: PluginMetadata;
196
+ }
197
+
198
+ /**
199
+ * Fully initialized plugin ready for use
200
+ */
201
+ export interface InitializedPlugin<T extends AnyPlugin = AnyPlugin> {
202
+ readonly plugin: T;
203
+ readonly metadata: PluginMetadata;
204
+ readonly config: {
205
+ variables: InferSchemaOutput<T["configSchema"]["variables"]>;
206
+ secrets: InferSchemaOutput<T["configSchema"]["secrets"]>;
207
+ };
208
+ readonly context: ContextOf<T>;
209
+ readonly scope: Scope.CloseableScope;
210
+ }
211
+
212
+ /**
213
+ * Helper type to detect type errors when looking up RegisteredPlugins
214
+ */
215
+ type VerifyPluginBinding<K extends keyof R, R = RegisteredPlugins> = R[K] extends {
216
+ binding: infer B;
217
+ }
218
+ ? B extends {
219
+ contract: AnyContractRouter;
220
+ variables: AnySchema;
221
+ secrets: AnySchema;
222
+ context: AnySchema | undefined;
223
+ }
224
+ ? true
225
+ : `❌ Plugin "${K & string}" is not properly registered. Ensure it extends plugin binding layout { contract, variables, secrets, context }.`
226
+ : `❌ Plugin "${K & string}" is not properly registered. Missing binding property.`;
227
+
228
+ /**
229
+ * Result of runtime.usePlugin() call
230
+ * @param K - The plugin key
231
+ * @param R - The registry type (defaults to RegisteredPlugins for module augmentation pattern)
232
+ */
233
+ export type UsePluginResult<K extends keyof R, R = RegisteredPlugins> =
234
+ VerifyPluginBinding<K, R> extends true
235
+ ? {
236
+ readonly createClient: (context?: PluginContextInput<R[K]>) => PluginClientType<R[K]>;
237
+ readonly router: PluginRouterType<R[K]>;
238
+ readonly metadata: PluginMetadata;
239
+ readonly initialized: InitializedPlugin<RegisteredPlugin<K, R>>;
240
+ }
241
+ : VerifyPluginBinding<K, R>;
242
+
243
+ /**
244
+ * Runtime options
245
+ */
246
+ export interface RuntimeOptions {
247
+ isolation?: "strict" | "shared" | "none";
248
+ memoryLimit?: string;
249
+ concurrency?: number;
250
+ resourceTimeout?: string;
251
+ debug?: boolean;
252
+ metrics?: boolean;
253
+ }
254
+
255
+ /**
256
+ * Extract registry type from runtime instance or use type directly
257
+ * This allows EveryPlugin.Infer to work with both:
258
+ * - typeof runtime (extracts registry from PluginRuntime<R> via __registryType)
259
+ * - Registry types directly
260
+ */
261
+ type RegistryOf<T> = T extends { __registryType?: infer R } ? R : T;
262
+
263
+ /**
264
+ * Namespace containing type utilities for working with plugin results.
265
+ */
266
+ export namespace EveryPlugin {
267
+ /**
268
+ * Extract plugin runtime instance type from registered plugins or runtime.
269
+ * Provides full type safety for plugin clients, routers, and metadata.
270
+ *
271
+ * @example
272
+ * ```ts
273
+ * // From RegisteredPlugins (module augmentation)
274
+ * type Plugin = EveryPlugin.Infer<"my-plugin">;
275
+ *
276
+ * // From runtime instance (when using module entries)
277
+ * const runtime = createPluginRuntime({ registry: { "my-plugin": { module: MyPlugin } } });
278
+ * type Plugin = EveryPlugin.Infer<"my-plugin", typeof runtime>;
279
+ *
280
+ * // From explicit registry type
281
+ * type Plugin = EveryPlugin.Infer<"my-plugin", MyRegistryType>;
282
+ * ```
283
+ */
284
+ export type Infer<
285
+ K extends string,
286
+ Source = RegisteredPlugins,
287
+ > = K extends keyof RegistryOf<Source> ? UsePluginResult<K, RegistryOf<Source>> : never;
288
+ }
289
+
290
+ /**
291
+ * Plugin runtime configuration with support for both module and remote entries
292
+ */
293
+ export interface PluginRuntimeConfig<
294
+ R extends Record<string, PluginRegistryEntry> = Record<string, PluginRegistryEntry>,
295
+ > {
296
+ registry: R;
297
+ secrets?: SecretsConfig;
298
+ options?: RuntimeOptions;
299
+ }
300
+
301
+ /**
302
+ * Legacy plugin runtime configuration (metadata-only registry)
303
+ * @deprecated Use PluginRuntimeConfig with module/remote entries instead
304
+ */
305
+ export interface LegacyPluginRuntimeConfig {
306
+ registry: PluginMetadataRegistry;
307
+ secrets?: SecretsConfig;
308
+ options?: RuntimeOptions;
309
+ }
@@ -0,0 +1,4 @@
1
+ /**
2
+ * necessary for portable type annotations
3
+ */
4
+ export * from "zod/v4/core";
package/src/zod.ts ADDED
@@ -0,0 +1 @@
1
+ export * from "zod";
package/dist/package.cjs DELETED
@@ -1,47 +0,0 @@
1
-
2
- //#region package.json
3
- var version = "0.8.8";
4
- var dependencies = {
5
- "@module-federation/enhanced": "^0.22.1",
6
- "@module-federation/node": "^2.7.27",
7
- "@module-federation/runtime-core": "^0.22.1",
8
- "@orpc/client": "^1.12.3",
9
- "@orpc/contract": "^1.13.4",
10
- "@orpc/experimental-publisher": "^1.13.4",
11
- "@orpc/openapi": "^1.12.3",
12
- "@orpc/react-query": "^1.13.4",
13
- "@orpc/server": "^1.13.4",
14
- "@orpc/tanstack-query": "^1.13.4",
15
- "@orpc/zod": "^1.13.4",
16
- "effect": "3.19.14",
17
- "zod": "4.3.5"
18
- };
19
- var sharedDependencies = { "ui": {
20
- "react": "^19.2.3",
21
- "react-dom": "^19.2.3",
22
- "@tanstack/react-query": "^5.90.11",
23
- "@tanstack/react-router": "^1.153.2",
24
- "@hot-labs/near-connect": "^0.8.2",
25
- "near-kit": "^0.7.0"
26
- } };
27
-
28
- //#endregion
29
- Object.defineProperty(exports, 'dependencies', {
30
- enumerable: true,
31
- get: function () {
32
- return dependencies;
33
- }
34
- });
35
- Object.defineProperty(exports, 'sharedDependencies', {
36
- enumerable: true,
37
- get: function () {
38
- return sharedDependencies;
39
- }
40
- });
41
- Object.defineProperty(exports, 'version', {
42
- enumerable: true,
43
- get: function () {
44
- return version;
45
- }
46
- });
47
- //# sourceMappingURL=package.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"package.cjs","names":[],"sources":["../package.json"],"sourcesContent":[""],"mappings":""}
package/dist/package.mjs DELETED
@@ -1,29 +0,0 @@
1
- //#region package.json
2
- var version = "0.8.9";
3
- var dependencies = {
4
- "@module-federation/enhanced": "^0.22.1",
5
- "@module-federation/node": "^2.7.27",
6
- "@module-federation/runtime-core": "^0.22.1",
7
- "@orpc/client": "^1.12.3",
8
- "@orpc/contract": "^1.13.4",
9
- "@orpc/experimental-publisher": "^1.13.4",
10
- "@orpc/openapi": "^1.12.3",
11
- "@orpc/react-query": "^1.13.4",
12
- "@orpc/server": "^1.13.4",
13
- "@orpc/tanstack-query": "^1.13.4",
14
- "@orpc/zod": "^1.13.4",
15
- "effect": "3.19.14",
16
- "zod": "4.3.5"
17
- };
18
- var sharedDependencies = { "ui": {
19
- "react": "^19.2.3",
20
- "react-dom": "^19.2.3",
21
- "@tanstack/react-query": "^5.90.11",
22
- "@tanstack/react-router": "^1.153.2",
23
- "@hot-labs/near-connect": "^0.8.2",
24
- "near-kit": "^0.7.0"
25
- } };
26
-
27
- //#endregion
28
- export { dependencies, sharedDependencies, version };
29
- //# sourceMappingURL=package.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"package.mjs","names":[],"sources":["../package.json"],"sourcesContent":[""],"mappings":""}