every-plugin 0.1.0 → 0.1.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 (65) hide show
  1. package/README.md +1 -329
  2. package/dist/errors.d.ts +11 -7
  3. package/dist/errors.d.ts.map +1 -1
  4. package/dist/errors.js +3 -14
  5. package/dist/index.d.ts +2 -4
  6. package/dist/index.d.ts.map +1 -1
  7. package/dist/index.js +1 -3
  8. package/dist/plugin.d.ts +149 -103
  9. package/dist/plugin.d.ts.map +1 -1
  10. package/dist/plugin.js +155 -23
  11. package/dist/runtime/errors.d.ts +41 -53
  12. package/dist/runtime/errors.d.ts.map +1 -1
  13. package/dist/runtime/errors.js +48 -8
  14. package/dist/runtime/index.d.ts +17 -66
  15. package/dist/runtime/index.d.ts.map +1 -1
  16. package/dist/runtime/index.js +22 -126
  17. package/dist/runtime/services/module-federation.service.d.ts +10 -38
  18. package/dist/runtime/services/module-federation.service.d.ts.map +1 -1
  19. package/dist/runtime/services/module-federation.service.js +131 -124
  20. package/dist/runtime/services/plugin.service.d.ts +21 -67
  21. package/dist/runtime/services/plugin.service.d.ts.map +1 -1
  22. package/dist/runtime/services/plugin.service.js +265 -328
  23. package/dist/runtime/services/secrets.service.d.ts +9 -29
  24. package/dist/runtime/services/secrets.service.js +26 -30
  25. package/dist/runtime/services.d.ts +1 -1
  26. package/dist/runtime/streaming/index.d.ts +4 -0
  27. package/dist/runtime/streaming/index.d.ts.map +1 -0
  28. package/dist/runtime/streaming/index.js +2 -0
  29. package/dist/runtime/streaming/state-effects.d.ts +28 -0
  30. package/dist/runtime/streaming/state-effects.d.ts.map +1 -0
  31. package/dist/runtime/streaming/state-effects.js +30 -0
  32. package/dist/runtime/streaming/streaming.d.ts +8 -0
  33. package/dist/runtime/streaming/streaming.d.ts.map +1 -0
  34. package/dist/runtime/streaming/streaming.js +113 -0
  35. package/dist/runtime/streaming/types.d.ts +19 -0
  36. package/dist/runtime/streaming/types.d.ts.map +1 -0
  37. package/dist/runtime/streaming/types.js +1 -0
  38. package/dist/runtime/test-utils.d.ts +1 -1
  39. package/dist/runtime/test-utils.js +4 -10
  40. package/dist/runtime/types.d.ts +28 -28
  41. package/dist/runtime/types.d.ts.map +1 -1
  42. package/dist/runtime/validation.d.ts +2 -7
  43. package/dist/runtime/validation.js +11 -14
  44. package/dist/testing/index.d.ts +25 -0
  45. package/dist/testing/index.d.ts.map +1 -0
  46. package/dist/testing/index.js +40 -0
  47. package/dist/testing/mocks/module-federation.service.d.ts +8 -0
  48. package/dist/testing/mocks/module-federation.service.d.ts.map +1 -0
  49. package/dist/testing/mocks/module-federation.service.js +35 -0
  50. package/package.json +27 -14
  51. package/dist/runtime/mf.test.d.ts +0 -2
  52. package/dist/runtime/mf.test.d.ts.map +0 -1
  53. package/dist/runtime/mf.test.js +0 -135
  54. package/dist/runtime/runtime.test.d.ts +0 -2
  55. package/dist/runtime/runtime.test.d.ts.map +0 -1
  56. package/dist/runtime/runtime.test.js +0 -378
  57. package/dist/runtime/streaming.d.ts +0 -29
  58. package/dist/runtime/streaming.d.ts.map +0 -1
  59. package/dist/runtime/streaming.js +0 -59
  60. package/dist/runtime/streaming.test.d.ts +0 -2
  61. package/dist/runtime/streaming.test.d.ts.map +0 -1
  62. package/dist/runtime/streaming.test.js +0 -271
  63. package/dist/source.d.ts +0 -70
  64. package/dist/source.d.ts.map +0 -1
  65. package/dist/source.js +0 -37
@@ -1,59 +0,0 @@
1
- import { Duration, Effect, Option, Stream } from "effect";
2
- const extractDelayFromState = (state) => {
3
- return state?.nextPollMs ? Duration.millis(state.nextPollMs) : null;
4
- };
5
- /**
6
- * Create a stream from a source plugin
7
- * Note: Validation is handled at the runtime level before this function is called
8
- */
9
- export const createSourceStream = (initializedPlugin, executePlugin, input, options = {}, isStreamable) => {
10
- // For non-streamable procedures, execute once and return items
11
- if (!isStreamable) {
12
- return Stream.fromEffect(executePlugin(initializedPlugin, input).pipe(Effect.map((result) => {
13
- const resultObj = result;
14
- const items = Array.isArray(resultObj.items)
15
- ? resultObj.items
16
- : resultObj.item
17
- ? [resultObj.item]
18
- : [];
19
- return items;
20
- }))).pipe(Stream.flatMap(items => Stream.fromIterable(items)));
21
- }
22
- const initialState = input.state;
23
- const stream = Stream.unfoldEffect({ state: initialState, invocations: 0 }, ({ state: currentState, invocations }) => Effect.gen(function* () {
24
- console.log(`[STREAM] Invocation ${invocations}:`);
25
- console.log(`[STREAM] - Current state:`, JSON.stringify(currentState, null, 2));
26
- console.log(`[STREAM] - Input:`, JSON.stringify(input, null, 2));
27
- // Check invocation limit if specified
28
- if (options.maxInvocations && invocations >= options.maxInvocations) {
29
- console.log(`[STREAM] - Stopping: maxInvocations (${options.maxInvocations}) reached`);
30
- return Option.none();
31
- }
32
- // Extract timing from plugin state (nextPollMs)
33
- const nextDelay = extractDelayFromState(currentState) || Duration.minutes(1); // 1min default
34
- yield* Effect.sleep(nextDelay);
35
- // Execute plugin
36
- const pluginInput = { ...input, state: currentState };
37
- console.log(`[STREAM] - Plugin input:`, JSON.stringify(pluginInput, null, 2));
38
- const result = yield* executePlugin(initializedPlugin, pluginInput);
39
- const resultObj = result;
40
- const items = Array.isArray(resultObj.items)
41
- ? resultObj.items
42
- : [];
43
- const nextState = resultObj.nextState;
44
- console.log(`[STREAM] - Plugin output:`, JSON.stringify(resultObj, null, 2));
45
- console.log(`[STREAM] - Items count: ${items.length}`);
46
- console.log(`[STREAM] - Next state:`, JSON.stringify(nextState, null, 2));
47
- // Check stop conditions ONLY
48
- if (options.stopWhenEmpty && items.length === 0) {
49
- console.log(`[STREAM] - Stopping: stopWhenEmpty=true and items.length=0`);
50
- return Option.none();
51
- }
52
- console.log(`[STREAM] - Continuing to next iteration`);
53
- return Option.some([items, { state: nextState, invocations: invocations + 1 }]);
54
- })).pipe(
55
- // Flatten items from each iteration
56
- Stream.flatMap(items => Stream.fromIterable(items)));
57
- // Apply maxItems limit if specified
58
- return options.maxItems ? stream.pipe(Stream.take(options.maxItems)) : stream;
59
- };
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=streaming.test.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"streaming.test.d.ts","sourceRoot":"","sources":["../../src/runtime/streaming.test.ts"],"names":[],"mappings":""}
@@ -1,271 +0,0 @@
1
- import { Effect, Stream } from "effect";
2
- import { afterEach, beforeEach, describe, expect, it } from "vitest";
3
- import { createPluginRuntime, PluginRuntime } from "./index";
4
- // Test registry with our example source plugin
5
- const TEST_REGISTRY = {
6
- "test-source-plugin": {
7
- remoteUrl: "http://localhost:3001/remoteEntry.js",
8
- type: "source",
9
- version: "0.0.1",
10
- description: "Example source plugin for streaming tests",
11
- },
12
- "test-plugin": {
13
- remoteUrl: "http://localhost:3000/remoteEntry.js",
14
- type: "transformer",
15
- version: "0.0.1",
16
- description: "Local template plugin for testing",
17
- },
18
- };
19
- const TEST_CONFIG = {
20
- variables: {
21
- baseUrl: "http://localhost:1337",
22
- timeout: 5000,
23
- },
24
- secrets: {
25
- apiKey: "test-api-key-value",
26
- },
27
- };
28
- // Contract-based input for search procedure
29
- const TEST_SEARCH_INPUT = {
30
- procedure: "search",
31
- input: {
32
- query: "test query",
33
- limit: 10,
34
- },
35
- state: null,
36
- };
37
- // Contract-based input for getById procedure
38
- const TEST_GETBYID_INPUT = {
39
- procedure: "getById",
40
- input: {
41
- id: "test-id-123",
42
- },
43
- state: null,
44
- };
45
- // Contract-based input for getBulk procedure
46
- const TEST_GETBULK_INPUT = {
47
- procedure: "getBulk",
48
- input: {
49
- ids: ["id1", "id2", "id3"],
50
- },
51
- state: null,
52
- };
53
- const SECRETS_CONFIG = {
54
- API_KEY: "test-api-key-value",
55
- };
56
- describe("Plugin Streaming", () => {
57
- let runtime;
58
- beforeEach(() => {
59
- runtime = createPluginRuntime({
60
- registry: TEST_REGISTRY,
61
- secrets: SECRETS_CONFIG,
62
- });
63
- });
64
- afterEach(async () => {
65
- if (runtime) {
66
- await runtime.dispose();
67
- }
68
- });
69
- it("should respect maxItems limit", async () => {
70
- const result = await runtime.runPromise(Effect.gen(function* () {
71
- const pluginRuntime = yield* PluginRuntime;
72
- // Start from Phase 3 state that immediately produces items
73
- const inputWithProductiveState = {
74
- ...TEST_SEARCH_INPUT,
75
- state: { phase: "historical", status: "processing", nextPollMs: 10 }
76
- };
77
- const stream = yield* pluginRuntime.streamPlugin("test-source-plugin", TEST_CONFIG, inputWithProductiveState, {
78
- maxItems: 3, // Strict limit
79
- maxInvocations: 3
80
- });
81
- const items = yield* stream.pipe(Stream.runCollect);
82
- return Array.from(items);
83
- }));
84
- expect(result.length).toBeLessThanOrEqual(3);
85
- expect(result.length).toBeGreaterThan(0);
86
- }, 4000);
87
- it("should validate invalid state and fail with proper error", async () => {
88
- const result = await runtime.runPromise(Effect.gen(function* () {
89
- const pluginRuntime = yield* PluginRuntime;
90
- // Use invalid state that doesn't match plugin's stateSchema
91
- const inputWithInvalidState = {
92
- ...TEST_SEARCH_INPUT,
93
- state: {
94
- pageNumber: 10, // Invalid - plugin expects { phase, status?, jobId?, lastId?, nextPollMs? }
95
- invalidField: "should not be here",
96
- },
97
- };
98
- // The error should occur when creating the stream, not when running it
99
- return yield* pluginRuntime.streamPlugin("test-source-plugin", TEST_CONFIG, inputWithInvalidState, {
100
- stopWhenEmpty: true,
101
- }).pipe(Effect.flatMap(() =>
102
- // If we get here, validation didn't work
103
- Effect.succeed("validation-should-have-failed")), Effect.catchTag("PluginRuntimeError", (error) => {
104
- // Should catch state validation error
105
- expect(error.operation).toBe("validate-state");
106
- expect(error.retryable).toBe(false);
107
- expect(error.pluginId).toBe("test-source-plugin");
108
- expect(error.cause).toBeDefined();
109
- console.debug("Caught expected state validation error:", {
110
- operation: error.operation,
111
- pluginId: error.pluginId,
112
- retryable: error.retryable,
113
- cause: error.cause?.message,
114
- });
115
- return Effect.succeed("state-validation-error-handled");
116
- }), Effect.catchAll((unexpectedError) => {
117
- console.error("Unexpected error type:", unexpectedError);
118
- expect.fail(`Expected PluginRuntimeError but got: ${unexpectedError._tag || typeof unexpectedError}`);
119
- return Effect.succeed("should-not-reach-here");
120
- }));
121
- }));
122
- expect(result).toBe("state-validation-error-handled");
123
- }, 4000);
124
- it("should handle stopWhenEmpty option", async () => {
125
- const result = await runtime.runPromise(Effect.gen(function* () {
126
- const pluginRuntime = yield* PluginRuntime;
127
- // Use the deterministic "empty" phase that always returns 0 items
128
- const inputWithEmptyState = {
129
- ...TEST_SEARCH_INPUT,
130
- state: {
131
- phase: "empty",
132
- nextPollMs: 10,
133
- },
134
- };
135
- const stream = yield* pluginRuntime.streamPlugin("test-source-plugin", TEST_CONFIG, inputWithEmptyState, {
136
- stopWhenEmpty: true,
137
- maxInvocations: 3, // Allow a few iterations to verify it stops
138
- });
139
- const items = yield* stream.pipe(Stream.runCollect);
140
- return Array.from(items);
141
- }));
142
- // Should stop immediately when no items are returned from empty phase
143
- expect(Array.isArray(result)).toBe(true);
144
- expect(result.length).toBe(0); // Empty phase always returns 0 items
145
- }, 4000);
146
- it("should validate plugin type", async () => {
147
- const result = await runtime.runPromise(Effect.gen(function* () {
148
- const pluginRuntime = yield* PluginRuntime;
149
- return yield* pluginRuntime.streamPlugin("test-plugin", TEST_CONFIG, TEST_SEARCH_INPUT).pipe(Effect.catchTag("PluginRuntimeError", (error) => {
150
- expect(error.operation).toBe("stream-plugin-validate");
151
- expect(error.cause?.message).toContain("not a source plugin");
152
- return Effect.succeed("validation-error-handled");
153
- }));
154
- }));
155
- expect(result).toBe("validation-error-handled");
156
- });
157
- it("should handle workflow phases correctly", async () => {
158
- const pluginRuntime = await runtime.runPromise(PluginRuntime);
159
- const plugin = await runtime.runPromise(pluginRuntime.usePlugin("test-source-plugin", TEST_CONFIG));
160
- // Phase 1: null state -> historical job (empty items)
161
- const phase1 = await runtime.runPromise(pluginRuntime.executePlugin(plugin, TEST_SEARCH_INPUT));
162
- const phase1Result = phase1;
163
- expect(phase1Result.items).toHaveLength(0);
164
- expect(phase1Result.nextState.phase).toBe("historical");
165
- expect(phase1Result.nextState.jobId).toMatch(/^hist_\d+$/);
166
- expect(phase1Result.nextState.nextPollMs).toBe(10);
167
- // Phase 2: historical job -> processing (empty items)
168
- const phase2Input = { ...TEST_SEARCH_INPUT, state: phase1Result.nextState };
169
- const phase2 = await runtime.runPromise(pluginRuntime.executePlugin(plugin, phase2Input));
170
- const phase2Result = phase2;
171
- expect(phase2Result.items).toHaveLength(0);
172
- expect(phase2Result.nextState.phase).toBe("historical");
173
- expect(phase2Result.nextState.status).toBe("processing");
174
- expect(phase2Result.nextState.nextPollMs).toBe(10);
175
- // Phase 3: processing -> historical items + realtime transition
176
- const phase3Input = { ...TEST_SEARCH_INPUT, state: phase2Result.nextState };
177
- const phase3 = await runtime.runPromise(pluginRuntime.executePlugin(plugin, phase3Input));
178
- const phase3Result = phase3;
179
- expect(phase3Result.items.length).toBeGreaterThan(0);
180
- expect(phase3Result.items[0]?.content).toContain("Historical");
181
- expect(phase3Result.nextState.phase).toBe("realtime");
182
- expect(phase3Result.nextState.lastId).toMatch(/^hist_end_\d+$/);
183
- expect(phase3Result.nextState.nextPollMs).toBe(10);
184
- // Phase 4: realtime polling (may have items)
185
- const phase4Input = { ...TEST_SEARCH_INPUT, state: phase3Result.nextState };
186
- const phase4 = await runtime.runPromise(pluginRuntime.executePlugin(plugin, phase4Input));
187
- const phase4Result = phase4;
188
- expect(phase4Result.nextState.phase).toBe("realtime");
189
- // Items may be empty or contain real-time items (random)
190
- if (phase4Result.items.length > 0) {
191
- expect(phase4Result.items[0]?.content).toContain("Real-time");
192
- }
193
- }, 4000);
194
- describe("Contract-based Procedures", () => {
195
- it("should execute getById procedure", async () => {
196
- const result = await runtime.runPromise(Effect.gen(function* () {
197
- const pluginRuntime = yield* PluginRuntime;
198
- const plugin = yield* pluginRuntime.usePlugin("test-source-plugin", TEST_CONFIG);
199
- const output = yield* pluginRuntime.executePlugin(plugin, TEST_GETBYID_INPUT);
200
- return output;
201
- }));
202
- expect(result).toBeDefined();
203
- const typedResult = result;
204
- expect(typedResult.item).toBeDefined();
205
- expect(typedResult.item.externalId).toBe("test-id-123");
206
- expect(typedResult.item.content).toContain("Content for item test-id-123");
207
- });
208
- it("should execute getBulk procedure", async () => {
209
- const result = await runtime.runPromise(Effect.gen(function* () {
210
- const pluginRuntime = yield* PluginRuntime;
211
- const plugin = yield* pluginRuntime.usePlugin("test-source-plugin", TEST_CONFIG);
212
- const output = yield* pluginRuntime.executePlugin(plugin, TEST_GETBULK_INPUT);
213
- return output;
214
- }));
215
- expect(result).toBeDefined();
216
- const typedResult = result;
217
- expect(typedResult.items).toBeDefined();
218
- expect(Array.isArray(typedResult.items)).toBe(true);
219
- expect(typedResult.items.length).toBe(3);
220
- expect(typedResult.items[0].externalId).toBe("id1");
221
- expect(typedResult.items[1].externalId).toBe("id2");
222
- expect(typedResult.items[2].externalId).toBe("id3");
223
- });
224
- it("should execute search procedure", async () => {
225
- const result = await runtime.runPromise(Effect.gen(function* () {
226
- const pluginRuntime = yield* PluginRuntime;
227
- const plugin = yield* pluginRuntime.usePlugin("test-source-plugin", TEST_CONFIG);
228
- // Use Phase 3 state to get historical items
229
- const searchInputWithState = {
230
- ...TEST_SEARCH_INPUT,
231
- state: { phase: "historical", status: "processing" }
232
- };
233
- const output = yield* pluginRuntime.executePlugin(plugin, searchInputWithState);
234
- return output;
235
- }));
236
- expect(result).toBeDefined();
237
- const typedResult = result;
238
- expect(typedResult.items).toBeDefined();
239
- expect(Array.isArray(typedResult.items)).toBe(true);
240
- expect(typedResult.items.length).toBeGreaterThan(0);
241
- expect(typedResult.items[0].content).toContain("test query");
242
- expect(typedResult.nextState).toBeDefined();
243
- });
244
- it("should stream getById procedure (single item)", async () => {
245
- const result = await runtime.runPromise(Effect.gen(function* () {
246
- const pluginRuntime = yield* PluginRuntime;
247
- const stream = yield* pluginRuntime.streamPlugin("test-source-plugin", TEST_CONFIG, TEST_GETBYID_INPUT, {
248
- maxItems: 5, // Safety limit
249
- });
250
- const items = yield* stream.pipe(Stream.runCollect);
251
- return Array.from(items);
252
- }));
253
- expect(result).toBeDefined();
254
- expect(result.length).toBe(1);
255
- expect(result[0].externalId).toBe("test-id-123");
256
- });
257
- it("should stream getBulk procedure", async () => {
258
- const result = await runtime.runPromise(Effect.gen(function* () {
259
- const pluginRuntime = yield* PluginRuntime;
260
- const stream = yield* pluginRuntime.streamPlugin("test-source-plugin", TEST_CONFIG, TEST_GETBULK_INPUT, {
261
- maxItems: 5, // Safety limit
262
- });
263
- const items = yield* stream.pipe(Stream.runCollect);
264
- return Array.from(items);
265
- }));
266
- expect(result).toBeDefined();
267
- expect(result.length).toBe(3);
268
- expect(result.map(item => item.externalId)).toEqual(["id1", "id2", "id3"]);
269
- });
270
- });
271
- });
package/dist/source.d.ts DELETED
@@ -1,70 +0,0 @@
1
- import type { Effect } from "effect";
2
- import { z } from "zod";
3
- import type { ConfigurationError, PluginExecutionError } from "./errors";
4
- import type { PluginLoggerTag } from "./plugin";
5
- /**
6
- * Source-specific schema creators for contract-based plugins
7
- */
8
- export declare function createSourceInputSchema<
9
- TContract,
10
- TStateSchema extends z.ZodTypeAny,
11
- >(
12
- contract: TContract,
13
- stateSchema: TStateSchema,
14
- ): z.ZodDiscriminatedUnion<
15
- [z.ZodObject<any, z.core.$strip>, ...z.ZodObject<any, z.core.$strip>[]],
16
- "procedure"
17
- >;
18
- /**
19
- * Contract-based output schema creator that infers from oRPC contract
20
- */
21
- export declare function createSourceOutputSchema<
22
- TContract,
23
- TStateSchema extends z.ZodTypeAny,
24
- >(
25
- contract: TContract,
26
- stateSchema: TStateSchema,
27
- ): z.ZodUnion<
28
- [
29
- z.ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>,
30
- ...z.ZodType<
31
- unknown,
32
- unknown,
33
- z.core.$ZodTypeInternals<unknown, unknown>
34
- >[],
35
- ]
36
- >;
37
- /**
38
- * Contract-first source plugin interface following the Plugin pattern
39
- */
40
- export interface SourcePlugin<
41
- TContract = Record<string, any>,
42
- TConfigSchema extends z.ZodTypeAny = z.ZodTypeAny,
43
- TStateSchema extends z.ZodTypeAny = z.ZodTypeAny,
44
- > {
45
- readonly id: string;
46
- readonly type: "source";
47
- readonly contract: TContract;
48
- readonly configSchema: TConfigSchema;
49
- readonly stateSchema: TStateSchema;
50
- readonly inputSchema: ReturnType<
51
- typeof createSourceInputSchema<TContract, TStateSchema>
52
- >;
53
- readonly outputSchema: ReturnType<
54
- typeof createSourceOutputSchema<TContract, TStateSchema>
55
- >;
56
- initialize(
57
- config?: z.infer<TConfigSchema>,
58
- ): Effect.Effect<void, ConfigurationError, PluginLoggerTag>;
59
- execute(
60
- input: z.infer<this["inputSchema"]>,
61
- ): Effect.Effect<
62
- z.infer<this["outputSchema"]>,
63
- PluginExecutionError,
64
- PluginLoggerTag
65
- >;
66
- shutdown(): Effect.Effect<void, never, PluginLoggerTag>;
67
- createRouter(): any;
68
- isStreamable(procedureName: string): boolean;
69
- }
70
- //# sourceMappingURL=source.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"source.d.ts","sourceRoot":"","sources":["../src/source.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AACrC,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,KAAK,EAAE,kBAAkB,EAAE,oBAAoB,EAAE,MAAM,UAAU,CAAC;AACzE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAEhD;;GAEG;AACH,wBAAgB,uBAAuB,CACtC,SAAS,EACT,YAAY,SAAS,CAAC,CAAC,UAAU,EAEjC,QAAQ,EAAE,SAAS,EACnB,WAAW,EAAE,YAAY,iHAwBzB;AAED;;GAEG;AACH,wBAAgB,wBAAwB,CACvC,SAAS,EACT,YAAY,SAAS,CAAC,CAAC,UAAU,EAEjC,QAAQ,EAAE,SAAS,EACnB,WAAW,EAAE,YAAY,uKAWzB;AAED;;GAEG;AACH,MAAM,WAAW,YAAY,CAC5B,SAAS,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAC/B,aAAa,SAAS,CAAC,CAAC,UAAU,GAAG,CAAC,CAAC,UAAU,EACjD,YAAY,SAAS,CAAC,CAAC,UAAU,GAAG,CAAC,CAAC,UAAU;IAEhD,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAC;IACxB,QAAQ,CAAC,QAAQ,EAAE,SAAS,CAAC;IAC7B,QAAQ,CAAC,YAAY,EAAE,aAAa,CAAC;IACrC,QAAQ,CAAC,WAAW,EAAE,YAAY,CAAC;IACnC,QAAQ,CAAC,WAAW,EAAE,UAAU,CAAC,OAAO,uBAAuB,CAAC,SAAS,EAAE,YAAY,CAAC,CAAC,CAAC;IAC1F,QAAQ,CAAC,YAAY,EAAE,UAAU,CAAC,OAAO,wBAAwB,CAAC,SAAS,EAAE,YAAY,CAAC,CAAC,CAAC;IAE5F,UAAU,CACT,MAAM,CAAC,EAAE,CAAC,CAAC,KAAK,CAAC,aAAa,CAAC,GAC7B,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,kBAAkB,EAAE,eAAe,CAAC,CAAC;IAE5D,OAAO,CACN,KAAK,EAAE,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC,GACjC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC,EAAE,oBAAoB,EAAE,eAAe,CAAC,CAAC;IAEvF,QAAQ,IAAI,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,KAAK,EAAE,eAAe,CAAC,CAAC;IAExD,YAAY,IAAI,GAAG,CAAC;IAEpB,YAAY,CAAC,aAAa,EAAE,MAAM,GAAG,OAAO,CAAC;CAC7C"}
package/dist/source.js DELETED
@@ -1,37 +0,0 @@
1
- import { z } from "zod";
2
- /**
3
- * Source-specific schema creators for contract-based plugins
4
- */
5
- export function createSourceInputSchema(contract, stateSchema) {
6
- const contractEntries = Object.entries(contract);
7
- const procedureSchemas = contractEntries.map(
8
- ([procedureName, procedureSpec]) => {
9
- // Extract input and output schemas from oRPC contract procedure
10
- const inputSchema = procedureSpec["~orpc"]?.inputSchema || z.object({});
11
- const outputSchema = procedureSpec["~orpc"]?.outputSchema || z.object({});
12
- // Check if this procedure is streamable (has nextState in output)
13
- const isStreamable = outputSchema._def?.shape?.nextState !== undefined;
14
- const baseSchema = z.object({
15
- procedure: z.literal(procedureName),
16
- input: inputSchema,
17
- });
18
- // Only add state field for streamable procedures
19
- return isStreamable
20
- ? baseSchema.extend({ state: stateSchema })
21
- : baseSchema;
22
- },
23
- );
24
- return z.discriminatedUnion("procedure", procedureSchemas);
25
- }
26
- /**
27
- * Contract-based output schema creator that infers from oRPC contract
28
- */
29
- export function createSourceOutputSchema(contract, stateSchema) {
30
- const contractEntries = Object.entries(contract);
31
- const procedureOutputSchemas = contractEntries.map(([_, procedureSpec]) => {
32
- // Extract output schema from oRPC contract procedure
33
- return procedureSpec["~orpc"]?.outputSchema || z.object({});
34
- });
35
- // Return union of all procedure output schemas
36
- return z.union(procedureOutputSchemas);
37
- }