every-plugin 0.3.1 → 0.4.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/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/plugin.d.ts +27 -31
- package/dist/plugin.d.ts.map +1 -1
- package/dist/plugin.js +8 -5
- package/dist/runtime/index.d.ts +8 -20
- package/dist/runtime/index.d.ts.map +1 -1
- package/dist/runtime/index.js +63 -52
- package/dist/runtime/services/module-federation.service.d.ts.map +1 -1
- package/dist/runtime/services/module-federation.service.js +24 -3
- package/dist/runtime/services/plugin-loader.service.d.ts +11 -8
- package/dist/runtime/services/plugin-loader.service.d.ts.map +1 -1
- package/dist/runtime/services/plugin-loader.service.js +18 -15
- package/dist/runtime/services/plugin.service.d.ts +10 -7
- package/dist/runtime/services/plugin.service.d.ts.map +1 -1
- package/dist/testing/index.d.ts +15 -9
- package/dist/testing/index.d.ts.map +1 -1
- package/dist/types.d.ts +100 -71
- package/dist/types.d.ts.map +1 -1
- package/package.json +103 -103
- package/dist/client/index.d.ts +0 -17
- package/dist/client/index.d.ts.map +0 -1
- package/dist/client/index.js +0 -33
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.service.d.ts","sourceRoot":"","sources":["../../../src/runtime/services/plugin.service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAQ,KAAK,EAAE,KAAK,EAAE,MAAM,QAAQ,CAAC;AACpD,OAAO,KAAK,EACX,SAAS,EACT,iBAAiB,EACjB,cAAc,EACd,aAAa,EACb,MAAM,aAAa,CAAC;AAErB,OAAO,EAAE,sBAAsB,EAAE,MAAM,4BAA4B,CAAC;AACpE,OAAO,EAAE,mBAAmB,EAAsC,MAAM,yBAAyB,CAAC
|
|
1
|
+
{"version":3,"file":"plugin.service.d.ts","sourceRoot":"","sources":["../../../src/runtime/services/plugin.service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAQ,KAAK,EAAE,KAAK,EAAE,MAAM,QAAQ,CAAC;AACpD,OAAO,KAAK,EACX,SAAS,EACT,iBAAiB,EACjB,cAAc,EACd,aAAa,EACb,MAAM,aAAa,CAAC;AAErB,OAAO,EAAE,sBAAsB,EAAE,MAAM,4BAA4B,CAAC;AACpE,OAAO,EAAE,mBAAmB,EAAsC,MAAM,yBAAyB,CAAC;;;;;;;;;;;;;;;;;;;;;;;;iCAYtE,iBAAiB,CAAC,SAAS,CAAC;;;;AATxD,qBAAa,aAAc,SAAQ,kBAyBjC;IACD,MAAM,CAAC,IAAI,GAAI,UAAU,cAAc,EAAE,SAAS,aAAa,8CAmB9D;CACD"}
|
package/dist/testing/index.d.ts
CHANGED
|
@@ -1,12 +1,18 @@
|
|
|
1
1
|
import { Layer } from "effect";
|
|
2
|
-
import type { PluginBinding } from "../plugin";
|
|
3
2
|
import { PluginRuntime } from "../runtime";
|
|
4
3
|
import { PluginService } from "../runtime/services";
|
|
5
|
-
import type { PluginRuntimeConfig,
|
|
4
|
+
import type { PluginRuntimeConfig, RegisteredPlugins } from "../types";
|
|
6
5
|
import { type PluginMap } from "./mocks/module-federation.service";
|
|
7
6
|
/**
|
|
8
|
-
*
|
|
9
|
-
*
|
|
7
|
+
* Validates that all plugin map keys exist in RegisteredPlugins.
|
|
8
|
+
* This ensures proper type inference for client methods.
|
|
9
|
+
*/
|
|
10
|
+
type ValidatePluginMap<T extends PluginMap> = {
|
|
11
|
+
[K in keyof T]: K extends keyof RegisteredPlugins ? T[K] : `❌ Plugin key "${K & string}" not registered in RegisteredPlugins. Add it to your types.d.ts file.`;
|
|
12
|
+
};
|
|
13
|
+
/**
|
|
14
|
+
* Simplified type inference for local plugin maps.
|
|
15
|
+
* Just use the constructor types directly.
|
|
10
16
|
*
|
|
11
17
|
* @example
|
|
12
18
|
* ```ts
|
|
@@ -15,13 +21,13 @@ import { type PluginMap } from "./mocks/module-federation.service";
|
|
|
15
21
|
* ```
|
|
16
22
|
*/
|
|
17
23
|
export type InferBindingsFromMap<T extends PluginMap> = {
|
|
18
|
-
[K in keyof T]:
|
|
19
|
-
} &
|
|
24
|
+
[K in keyof T]: T[K];
|
|
25
|
+
} & RegisteredPlugins;
|
|
20
26
|
/**
|
|
21
27
|
* Creates a test layer with mock ModuleFederationService for unit testing.
|
|
22
28
|
* This mirrors PluginService.Live() but uses mock ModuleFederationService.
|
|
23
29
|
*/
|
|
24
|
-
export declare const createTestLayer: <R extends
|
|
30
|
+
export declare const createTestLayer: <R extends RegisteredPlugins = RegisteredPlugins>(config: PluginRuntimeConfig<R>, pluginMap: PluginMap) => Layer.Layer<PluginService, never, never>;
|
|
25
31
|
/**
|
|
26
32
|
* Creates a plugin runtime for locally available plugins (non-remote).
|
|
27
33
|
* Automatically infers type bindings from the plugin map, eliminating
|
|
@@ -43,11 +49,11 @@ export declare const createTestLayer: <R extends RegistryBindings = RegistryBind
|
|
|
43
49
|
* const plugin = await runtime.usePlugin("my-plugin", config);
|
|
44
50
|
* ```
|
|
45
51
|
*/
|
|
46
|
-
export declare function createLocalPluginRuntime<
|
|
52
|
+
export declare function createLocalPluginRuntime<TMap extends PluginMap & ValidatePluginMap<TMap>>(config: PluginRuntimeConfig, pluginMap: TMap): PluginRuntime<InferBindingsFromMap<TMap>>;
|
|
47
53
|
/**
|
|
48
54
|
* @deprecated Use `createLocalPluginRuntime` instead. This alias is kept for backward compatibility.
|
|
49
55
|
*/
|
|
50
56
|
export declare const createTestPluginRuntime: typeof createLocalPluginRuntime;
|
|
51
|
-
export type { PluginRegistry,
|
|
57
|
+
export type { EveryPlugin, PluginRegistry, RegisteredPlugins } from "../types";
|
|
52
58
|
export type { PluginMap, PluginRuntimeConfig };
|
|
53
59
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/testing/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAkB,MAAM,QAAQ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AiB,EAAE,MAAM,UAAU,CAAC;AAC/E,YAAY,EAAE,SAAS,EAAE,mBAAmB,EAAE,CAAC"}
|
package/dist/types.d.ts
CHANGED
|
@@ -1,50 +1,76 @@
|
|
|
1
|
-
import type { AnyContractRouter } from "@orpc/contract";
|
|
1
|
+
import type { AnyContractRouter, AnySchema, InferSchemaInput, InferSchemaOutput } from "@orpc/contract";
|
|
2
2
|
import type { Context, Router, RouterClient } from "@orpc/server";
|
|
3
3
|
import type { Scope } from "effect";
|
|
4
|
-
import type {
|
|
5
|
-
|
|
6
|
-
|
|
4
|
+
import type { Plugin } from "./plugin";
|
|
5
|
+
/**
|
|
6
|
+
* Registry bindings interface - populated via module augmentation
|
|
7
|
+
* @example
|
|
8
|
+
* ```typescript
|
|
9
|
+
* declare module "every-plugin" {
|
|
10
|
+
* interface RegisteredPlugins {
|
|
11
|
+
* "my-plugin": typeof MyPlugin;
|
|
12
|
+
* }
|
|
13
|
+
* }
|
|
14
|
+
* ```
|
|
15
|
+
*/
|
|
16
|
+
export interface RegisteredPlugins {
|
|
17
|
+
}
|
|
7
18
|
/**
|
|
8
19
|
* Base type for any plugin instance.
|
|
9
|
-
* This is the foundation that enables type inference across the entire plugin system.
|
|
10
|
-
* Uses 'any' for context to allow plugins with custom context types.
|
|
11
|
-
*/
|
|
12
|
-
export type AnyPlugin = Plugin<AnyContractRouter, z.ZodTypeAny, z.ZodTypeAny, any>;
|
|
13
|
-
/**
|
|
14
|
-
* Registry bindings define the compile-time shape of available plugins.
|
|
15
|
-
* This is a type-only construct that enables full IDE autocomplete and type safety
|
|
16
|
-
* without requiring runtime plugin imports.
|
|
17
|
-
*/
|
|
18
|
-
export type RegistryBindings = Record<string, {
|
|
19
|
-
contract: AnyContractRouter;
|
|
20
|
-
config: PluginConfigFor<z.ZodTypeAny, z.ZodTypeAny>;
|
|
21
|
-
}>;
|
|
22
|
-
/**
|
|
23
|
-
* Extracts the Plugin type from a binding definition.
|
|
24
|
-
* This enables type inference: Binding → Plugin → Router → Client
|
|
25
|
-
*/
|
|
26
|
-
export type PluginOf<B> = B extends {
|
|
27
|
-
contract: infer C;
|
|
28
|
-
config: infer Conf;
|
|
29
|
-
} ? Conf extends PluginConfigFor<infer V, infer S> ? C extends AnyContractRouter ? Plugin<C, V, S, Context> : never : never : never;
|
|
30
|
-
/**
|
|
31
|
-
* Extracts the config type from a binding definition.
|
|
32
|
-
* This provides strongly-typed configuration based on the plugin's zod schema.
|
|
33
|
-
*/
|
|
34
|
-
export type ConfigOf<B> = z.infer<PluginOf<B>["configSchema"]>;
|
|
35
|
-
/**
|
|
36
|
-
* The actual router type returned by plugins (with procedures implemented)
|
|
37
|
-
* Supports host context composition via THostContext type parameter
|
|
38
20
|
*/
|
|
39
|
-
export type
|
|
21
|
+
export type AnyPlugin = Plugin<AnyContractRouter, AnySchema, AnySchema, any>;
|
|
22
|
+
/**
|
|
23
|
+
* Extract plugin type from registered plugins by key
|
|
24
|
+
*/
|
|
25
|
+
export type RegisteredPlugin<K extends keyof RegisteredPlugins> = RegisteredPlugins[K] extends {
|
|
26
|
+
binding: infer B;
|
|
27
|
+
} ? B extends {
|
|
28
|
+
contract: infer C extends AnyContractRouter;
|
|
29
|
+
variables: infer V extends AnySchema;
|
|
30
|
+
secrets: infer S extends AnySchema;
|
|
31
|
+
context: infer TContext extends Context;
|
|
32
|
+
} ? Plugin<C, V, S, TContext> : never : never;
|
|
33
|
+
/**
|
|
34
|
+
* Extract router type from plugin binding
|
|
35
|
+
*/
|
|
36
|
+
export type PluginRouterType<T> = Router<PluginContract<T>, PluginContext<T>>;
|
|
37
|
+
/**
|
|
38
|
+
* Extract client type from plugin binding
|
|
39
|
+
*/
|
|
40
|
+
export type PluginClientType<T> = RouterClient<Router<PluginContract<T>, PluginContext<T>>>;
|
|
41
|
+
export type PluginContract<T> = T extends {
|
|
42
|
+
binding: {
|
|
43
|
+
contract: infer C extends AnyContractRouter;
|
|
44
|
+
};
|
|
45
|
+
} ? C : never;
|
|
46
|
+
export type PluginVariables<T> = T extends {
|
|
47
|
+
binding: {
|
|
48
|
+
variables: infer V extends AnySchema;
|
|
49
|
+
};
|
|
50
|
+
} ? V : never;
|
|
51
|
+
export type PluginSecrets<T> = T extends {
|
|
52
|
+
binding: {
|
|
53
|
+
secrets: infer S extends AnySchema;
|
|
54
|
+
};
|
|
55
|
+
} ? S : never;
|
|
56
|
+
export type PluginContext<T> = T extends {
|
|
57
|
+
binding: {
|
|
58
|
+
context: infer C extends Context;
|
|
59
|
+
};
|
|
60
|
+
} ? C : never;
|
|
61
|
+
/**
|
|
62
|
+
* Extract config input type from plugin binding
|
|
63
|
+
*/
|
|
64
|
+
export type PluginConfigInput<T> = {
|
|
65
|
+
variables: InferSchemaInput<PluginVariables<T>>;
|
|
66
|
+
secrets: InferSchemaInput<PluginSecrets<T>>;
|
|
67
|
+
};
|
|
40
68
|
/**
|
|
41
|
-
*
|
|
42
|
-
* This is used for typing the router client context parameter.
|
|
69
|
+
* Extract context type from plugin instance
|
|
43
70
|
*/
|
|
44
|
-
export type ContextOf<T extends AnyPlugin> = T extends Plugin<AnyContractRouter,
|
|
71
|
+
export type ContextOf<T extends AnyPlugin> = T extends Plugin<AnyContractRouter, AnySchema, AnySchema, infer TContext> ? TContext : never;
|
|
45
72
|
/**
|
|
46
73
|
* Runtime registry configuration.
|
|
47
|
-
* Maps plugin IDs to their remote URLs and metadata.
|
|
48
74
|
*/
|
|
49
75
|
export type PluginRegistry = Record<string, PluginMetadata>;
|
|
50
76
|
/**
|
|
@@ -55,8 +81,7 @@ export interface SecretsConfig {
|
|
|
55
81
|
[key: string]: string;
|
|
56
82
|
}
|
|
57
83
|
/**
|
|
58
|
-
*
|
|
59
|
-
* Contains information about the plugin that persists across different stages.
|
|
84
|
+
* Plugin metadata
|
|
60
85
|
*/
|
|
61
86
|
export type PluginMetadata = {
|
|
62
87
|
readonly remoteUrl: string;
|
|
@@ -64,82 +89,86 @@ export type PluginMetadata = {
|
|
|
64
89
|
readonly description?: string;
|
|
65
90
|
};
|
|
66
91
|
/**
|
|
67
|
-
* Loaded plugin
|
|
92
|
+
* Loaded plugin
|
|
68
93
|
*/
|
|
69
94
|
export interface LoadedPlugin<T extends AnyPlugin = AnyPlugin> {
|
|
70
95
|
readonly ctor: new () => T;
|
|
71
96
|
readonly metadata: PluginMetadata;
|
|
72
97
|
}
|
|
73
98
|
/**
|
|
74
|
-
* Instantiated plugin
|
|
99
|
+
* Instantiated plugin
|
|
75
100
|
*/
|
|
76
101
|
export interface PluginInstance<T extends AnyPlugin = AnyPlugin> {
|
|
77
102
|
readonly plugin: T;
|
|
78
103
|
readonly metadata: PluginMetadata;
|
|
79
104
|
}
|
|
80
105
|
/**
|
|
81
|
-
* Fully initialized plugin ready for use
|
|
82
|
-
* Contains the plugin instance, validated config, execution context, and scope.
|
|
106
|
+
* Fully initialized plugin ready for use
|
|
83
107
|
*/
|
|
84
108
|
export interface InitializedPlugin<T extends AnyPlugin = AnyPlugin> {
|
|
85
109
|
readonly plugin: T;
|
|
86
110
|
readonly metadata: PluginMetadata;
|
|
87
|
-
readonly config:
|
|
111
|
+
readonly config: {
|
|
112
|
+
variables: InferSchemaOutput<T["configSchema"]["variables"]>;
|
|
113
|
+
secrets: InferSchemaOutput<T["configSchema"]["secrets"]>;
|
|
114
|
+
};
|
|
88
115
|
readonly context: ContextOf<T>;
|
|
89
116
|
readonly scope: Scope.CloseableScope;
|
|
90
117
|
}
|
|
91
118
|
/**
|
|
92
|
-
*
|
|
119
|
+
* Helper type to detect type errors when looking up RegisteredPlugins
|
|
120
|
+
*/
|
|
121
|
+
type VerifyPluginBinding<K extends keyof RegisteredPlugins> = RegisteredPlugins[K] extends {
|
|
122
|
+
binding: infer B;
|
|
123
|
+
} ? B extends {
|
|
124
|
+
contract: AnyContractRouter;
|
|
125
|
+
variables: AnySchema;
|
|
126
|
+
secrets: AnySchema;
|
|
127
|
+
context: Context;
|
|
128
|
+
} ? true : `❌ Plugin "${K & string}" is not properly registered. Ensure it extends plugin binding layout { contract, variables, secrets, context }.` : `❌ Plugin "${K & string}" is not properly registered. Missing binding property.`;
|
|
129
|
+
/**
|
|
130
|
+
* Result of runtime.usePlugin() call
|
|
131
|
+
*/
|
|
132
|
+
export type UsePluginResult<K extends keyof RegisteredPlugins> = VerifyPluginBinding<K> extends true ? {
|
|
133
|
+
readonly client: PluginClientType<RegisteredPlugins[K]>;
|
|
134
|
+
readonly router: PluginRouterType<RegisteredPlugins[K]>;
|
|
135
|
+
readonly metadata: PluginMetadata;
|
|
136
|
+
readonly initialized: InitializedPlugin<RegisteredPlugin<K>>;
|
|
137
|
+
} : VerifyPluginBinding<K>;
|
|
138
|
+
/**
|
|
139
|
+
* Runtime options
|
|
93
140
|
*/
|
|
94
141
|
export interface RuntimeOptions {
|
|
95
|
-
/** Resource isolation level for plugins */
|
|
96
142
|
isolation?: "strict" | "shared" | "none";
|
|
97
|
-
/** Memory limit per plugin instance */
|
|
98
143
|
memoryLimit?: string;
|
|
99
|
-
/** Maximum concurrent plugin operations */
|
|
100
144
|
concurrency?: number;
|
|
101
|
-
/** Resource timeout for plugin operations */
|
|
102
145
|
resourceTimeout?: string;
|
|
103
|
-
/** Enable debug logging */
|
|
104
146
|
debug?: boolean;
|
|
105
|
-
/** Enable metrics collection */
|
|
106
147
|
metrics?: boolean;
|
|
107
148
|
}
|
|
108
|
-
/**
|
|
109
|
-
* Enhanced plugin result containing client, router, and metadata.
|
|
110
|
-
* Router is typed as ContractRouter for encapsulation, but runtime compatible with oRPC routers.
|
|
111
|
-
* Supports host context composition through THostContext type parameter.
|
|
112
|
-
*/
|
|
113
|
-
export interface EveryPlugin<T extends AnyPlugin = AnyPlugin, THostContext extends Context = Record<never, never>> {
|
|
114
|
-
readonly client: RouterClient<PluginRouter<T, THostContext>, THostContext>;
|
|
115
|
-
readonly router: PluginRouter<T, THostContext>;
|
|
116
|
-
readonly metadata: PluginMetadata;
|
|
117
|
-
readonly initialized: InitializedPlugin<T>;
|
|
118
|
-
}
|
|
119
149
|
/**
|
|
120
150
|
* Namespace containing type utilities for working with plugin results.
|
|
121
151
|
*/
|
|
122
152
|
export declare namespace EveryPlugin {
|
|
123
153
|
/**
|
|
124
|
-
* Extract
|
|
154
|
+
* Extract plugin runtime instance type from registered plugins.
|
|
125
155
|
* Provides full type safety for plugin clients, routers, and metadata.
|
|
126
156
|
*
|
|
127
157
|
* @example
|
|
128
158
|
* ```ts
|
|
129
|
-
*
|
|
130
|
-
*
|
|
131
|
-
* plugin = await runtime.usePlugin("my-plugin", config);
|
|
159
|
+
* type Plugin = EveryPlugin.Infer<"my-plugin">;
|
|
160
|
+
* const plugin: Plugin = await runtime.usePlugin("my-plugin", config);
|
|
132
161
|
* ```
|
|
133
162
|
*/
|
|
134
|
-
type Infer<
|
|
163
|
+
type Infer<K extends keyof RegisteredPlugins> = UsePluginResult<K>;
|
|
135
164
|
}
|
|
136
165
|
/**
|
|
137
|
-
*
|
|
138
|
-
* The generic R parameter enables compile-time type safety when provided.
|
|
166
|
+
* Plugin runtime configuration
|
|
139
167
|
*/
|
|
140
|
-
export interface PluginRuntimeConfig<R extends
|
|
168
|
+
export interface PluginRuntimeConfig<R extends RegisteredPlugins = RegisteredPlugins> {
|
|
141
169
|
registry: PluginRegistry;
|
|
142
170
|
secrets?: SecretsConfig;
|
|
143
171
|
options?: RuntimeOptions;
|
|
144
172
|
}
|
|
173
|
+
export {};
|
|
145
174
|
//# sourceMappingURL=types.d.ts.map
|
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,SAAS,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AACxG,OAAO,K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-
|
|
2
|
+
"name": "every-plugin",
|
|
3
|
+
"version": "0.4.0",
|
|
4
|
+
"main": "dist/index.js",
|
|
5
|
+
"types": "dist/index.d.ts",
|
|
6
|
+
"exports": {
|
|
7
|
+
".": {
|
|
8
|
+
"types": "./dist/index.d.ts",
|
|
9
|
+
"default": "./dist/index.js"
|
|
10
|
+
},
|
|
11
|
+
"./runtime": {
|
|
12
|
+
"types": "./dist/runtime/index.d.ts",
|
|
13
|
+
"default": "./dist/runtime/index.js"
|
|
14
|
+
},
|
|
15
|
+
"./client": {
|
|
16
|
+
"types": "./dist/client/index.d.ts",
|
|
17
|
+
"default": "./dist/client/index.js"
|
|
18
|
+
},
|
|
19
|
+
"./testing": {
|
|
20
|
+
"types": "./dist/testing/index.d.ts",
|
|
21
|
+
"default": "./dist/testing/index.js"
|
|
22
|
+
},
|
|
23
|
+
"./normalize": {
|
|
24
|
+
"types": "./dist/runtime/services/normalize.d.ts",
|
|
25
|
+
"require": "./dist/runtime/services/normalize.js",
|
|
26
|
+
"default": "./dist/runtime/services/normalize.js"
|
|
27
|
+
},
|
|
28
|
+
"./effect": {
|
|
29
|
+
"types": "./dist/effect.d.ts",
|
|
30
|
+
"default": "./dist/effect.js"
|
|
31
|
+
},
|
|
32
|
+
"./zod": {
|
|
33
|
+
"types": "./dist/zod.d.ts",
|
|
34
|
+
"default": "./dist/zod.js"
|
|
35
|
+
},
|
|
36
|
+
"./orpc": {
|
|
37
|
+
"types": "./dist/orpc.d.ts",
|
|
38
|
+
"default": "./dist/orpc.js"
|
|
39
|
+
},
|
|
40
|
+
"./package.json": "./package.json"
|
|
41
|
+
},
|
|
42
|
+
"files": [
|
|
43
|
+
"dist"
|
|
44
|
+
],
|
|
45
|
+
"scripts": {
|
|
46
|
+
"build": "tsc -b tsconfig.build.json",
|
|
47
|
+
"build:test": "cd tests/fixtures/test-plugin && bun run build",
|
|
48
|
+
"test": "vitest run --config vitest.config.ts",
|
|
49
|
+
"test:unit": "vitest run --config vitest.config.ts",
|
|
50
|
+
"test:integration": "bun run build:test && vitest run --config vitest.integration.config.ts",
|
|
51
|
+
"test:all": "bun run test:unit && bun run test:integration",
|
|
52
|
+
"test:watch": "vitest --config vitest.config.ts --watch",
|
|
53
|
+
"typecheck": "tsc --noEmit"
|
|
54
|
+
},
|
|
55
|
+
"peerDependencies": {
|
|
56
|
+
"typescript": "^5.6.0"
|
|
57
|
+
},
|
|
58
|
+
"devDependencies": {
|
|
59
|
+
"@effect/language-service": "^0.38.4",
|
|
60
|
+
"@effect/vitest": "^0.25.1",
|
|
61
|
+
"@orpc/client": "^1.10.0",
|
|
62
|
+
"@orpc/openapi": "^1.10.0",
|
|
63
|
+
"@orpc/zod": "^1.10.0",
|
|
64
|
+
"@rspack/cli": "^1.5.8",
|
|
65
|
+
"@rspack/core": "^1.5.8",
|
|
66
|
+
"@types/bun": "^1.3.0",
|
|
67
|
+
"@types/node": "^24.9.0",
|
|
68
|
+
"@vitest/ui": "3.2.4",
|
|
69
|
+
"bun-types": "^1.3.0",
|
|
70
|
+
"sirv": "^3.0.2",
|
|
71
|
+
"vite-tsconfig-paths": "^5.1.4",
|
|
72
|
+
"vitest": "^3.2.4"
|
|
73
|
+
},
|
|
74
|
+
"dependencies": {
|
|
75
|
+
"@better-fetch/fetch": "^1.1.18",
|
|
76
|
+
"@module-federation/enhanced": "^0.19.1",
|
|
77
|
+
"@module-federation/node": "^2.7.15",
|
|
78
|
+
"@module-federation/runtime-core": "^0.19.1",
|
|
79
|
+
"@orpc/contract": "^1.10.0",
|
|
80
|
+
"@orpc/experimental-publisher": "^1.10.0",
|
|
81
|
+
"@orpc/server": "^1.10.0",
|
|
82
|
+
"effect": "3.18.1",
|
|
83
|
+
"zod": "4.1.5"
|
|
84
|
+
},
|
|
85
|
+
"keywords": [
|
|
86
|
+
"plugin",
|
|
87
|
+
"module-federation",
|
|
88
|
+
"orpc",
|
|
89
|
+
"zod",
|
|
90
|
+
"typescript"
|
|
91
|
+
],
|
|
92
|
+
"author": "plugin.every.near",
|
|
93
|
+
"license": "MIT",
|
|
94
|
+
"repository": {
|
|
95
|
+
"type": "git",
|
|
96
|
+
"url": "https://github.com/near-everything/every-plugin.git"
|
|
97
|
+
},
|
|
98
|
+
"bugs": {
|
|
99
|
+
"url": "https://github.com/near-everything/every-plugin/issues"
|
|
100
|
+
},
|
|
101
|
+
"homepage": "https://plugin.everything.dev",
|
|
102
|
+
"workspaces": [
|
|
103
|
+
"tests/fixtures/*"
|
|
104
|
+
]
|
|
105
105
|
}
|
package/dist/client/index.d.ts
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { type ClientContext, type CreateProcedureClientOptions, type ErrorMap, type InferRouterInitialContext, type Meta, type RouterClient, type Schema } from "@orpc/server";
|
|
2
|
-
import type { AnyPlugin, InitializedPlugin, PluginRouter } from "../types";
|
|
3
|
-
/**
|
|
4
|
-
* Extracts the oRPC router from an initialized plugin.
|
|
5
|
-
* The router type is precisely inferred from the plugin's contract.
|
|
6
|
-
* Useful for mounting into HTTP frameworks or direct router usage.
|
|
7
|
-
*/
|
|
8
|
-
export declare function getPluginRouter<T extends AnyPlugin>(initialized: InitializedPlugin<T>): PluginRouter<T>;
|
|
9
|
-
/**
|
|
10
|
-
* Creates a fully type-safe client for calling plugin procedures as methods.
|
|
11
|
-
* The client type is precisely inferred from the plugin's contract, providing
|
|
12
|
-
* complete autocomplete and type safety for all procedures, inputs, and outputs.
|
|
13
|
-
*
|
|
14
|
-
* Type safety flows: Plugin Contract → Router → RouterClient with full procedure autocomplete
|
|
15
|
-
*/
|
|
16
|
-
export declare function createPluginClient<T extends AnyPlugin, TClientContext extends ClientContext = Record<never, never>>(initialized: InitializedPlugin<T>, options?: CreateProcedureClientOptions<InferRouterInitialContext<PluginRouter<T>>, Schema<unknown, unknown>, ErrorMap, Meta, TClientContext>): RouterClient<PluginRouter<T>, TClientContext>;
|
|
17
|
-
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/client/index.ts"],"names":[],"mappings":"AACA,OAAO,EACL,KAAK,aAAa,EAClB,KAAK,4BAA4B,EAEjC,KAAK,QAAQ,EACb,KAAK,yBAAyB,EAC9B,KAAK,IAAI,EAET,KAAK,YAAY,EACjB,KAAK,MAAM,EACZ,MAAM,cAAc,CAAC;AACtB,OAAO,KAAK,EAAE,SAAS,EAAa,iBAAiB,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAEtF;;;;GAIG;AACH,wBAAgB,eAAe,CAAC,CAAC,SAAS,SAAS,EACjD,WAAW,EAAE,iBAAiB,CAAC,CAAC,CAAC,GAChC,YAAY,CAAC,CAAC,CAAC,CAmBjB;AAED;;;;;;GAMG;AACH,wBAAgB,kBAAkB,CAChC,CAAC,SAAS,SAAS,EACnB,cAAc,SAAS,aAAa,GAAG,MAAM,CAAC,KAAK,EAAE,KAAK,CAAC,EAE3D,WAAW,EAAE,iBAAiB,CAAC,CAAC,CAAC,EACjC,OAAO,CAAC,EAAE,4BAA4B,CACpC,yBAAyB,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,EAC1C,MAAM,CAAC,OAAO,EAAE,OAAO,CAAC,EACxB,QAAQ,EACR,IAAI,EACJ,cAAc,CACf,GACA,YAAY,CAAC,YAAY,CAAC,CAAC,CAAC,EAAE,cAAc,CAAC,CAS/C"}
|
package/dist/client/index.js
DELETED
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import { createRouterClient } from "@orpc/server";
|
|
2
|
-
/**
|
|
3
|
-
* Extracts the oRPC router from an initialized plugin.
|
|
4
|
-
* The router type is precisely inferred from the plugin's contract.
|
|
5
|
-
* Useful for mounting into HTTP frameworks or direct router usage.
|
|
6
|
-
*/
|
|
7
|
-
export function getPluginRouter(initialized) {
|
|
8
|
-
if (!initialized) {
|
|
9
|
-
throw new Error("InitializedPlugin is undefined - plugin initialization failed");
|
|
10
|
-
}
|
|
11
|
-
if (!initialized.plugin) {
|
|
12
|
-
throw new Error("Plugin instance is undefined - check service layer dependencies (ModuleFederationService, SecretsService)");
|
|
13
|
-
}
|
|
14
|
-
if (typeof initialized.plugin.createRouter !== "function") {
|
|
15
|
-
throw new Error(`Plugin ${initialized.plugin.id || 'unknown'} does not have a createRouter method`);
|
|
16
|
-
}
|
|
17
|
-
if (!initialized.context) {
|
|
18
|
-
throw new Error("Plugin context is undefined - plugin initialization incomplete");
|
|
19
|
-
}
|
|
20
|
-
const router = initialized.plugin.createRouter(initialized.context);
|
|
21
|
-
return router;
|
|
22
|
-
}
|
|
23
|
-
/**
|
|
24
|
-
* Creates a fully type-safe client for calling plugin procedures as methods.
|
|
25
|
-
* The client type is precisely inferred from the plugin's contract, providing
|
|
26
|
-
* complete autocomplete and type safety for all procedures, inputs, and outputs.
|
|
27
|
-
*
|
|
28
|
-
* Type safety flows: Plugin Contract → Router → RouterClient with full procedure autocomplete
|
|
29
|
-
*/
|
|
30
|
-
export function createPluginClient(initialized, options) {
|
|
31
|
-
const router = getPluginRouter(initialized);
|
|
32
|
-
return createRouterClient(router, options);
|
|
33
|
-
}
|