every-plugin 0.0.6 → 0.1.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.
Files changed (50) hide show
  1. package/README.md +77 -13
  2. package/dist/errors.js +10 -10
  3. package/dist/plugin.d.ts +98 -44
  4. package/dist/plugin.js +17 -15
  5. package/dist/runtime/errors.d.ts +22 -1
  6. package/dist/runtime/errors.d.ts.map +1 -1
  7. package/dist/runtime/errors.js +8 -6
  8. package/dist/runtime/index.d.ts +68 -16
  9. package/dist/runtime/index.d.ts.map +1 -1
  10. package/dist/runtime/index.js +126 -27
  11. package/dist/runtime/mf.test.d.ts +2 -0
  12. package/dist/runtime/mf.test.d.ts.map +1 -0
  13. package/dist/runtime/mf.test.js +135 -0
  14. package/dist/runtime/runtime.test.d.ts +1 -1
  15. package/dist/runtime/runtime.test.js +366 -296
  16. package/dist/runtime/services/module-federation.service.d.ts +36 -9
  17. package/dist/runtime/services/module-federation.service.d.ts.map +1 -1
  18. package/dist/runtime/services/module-federation.service.js +122 -99
  19. package/dist/runtime/services/plugin.service.d.ts +66 -13
  20. package/dist/runtime/services/plugin.service.d.ts.map +1 -1
  21. package/dist/runtime/services/plugin.service.js +330 -122
  22. package/dist/runtime/services/secrets.service.d.ts +29 -9
  23. package/dist/runtime/services/secrets.service.d.ts.map +1 -1
  24. package/dist/runtime/services/secrets.service.js +30 -26
  25. package/dist/runtime/services.d.ts +1 -2
  26. package/dist/runtime/services.d.ts.map +1 -1
  27. package/dist/runtime/services.js +0 -1
  28. package/dist/runtime/streaming.d.ts +29 -0
  29. package/dist/runtime/streaming.d.ts.map +1 -0
  30. package/dist/runtime/streaming.js +59 -0
  31. package/dist/runtime/streaming.test.d.ts +2 -0
  32. package/dist/runtime/streaming.test.d.ts.map +1 -0
  33. package/dist/runtime/streaming.test.js +271 -0
  34. package/dist/runtime/test-utils.d.ts +3 -0
  35. package/dist/runtime/test-utils.d.ts.map +1 -0
  36. package/dist/runtime/test-utils.js +13 -0
  37. package/dist/runtime/types.d.ts +27 -27
  38. package/dist/runtime/validation.d.ts +1 -1
  39. package/dist/runtime/validation.d.ts.map +1 -1
  40. package/dist/runtime/validation.js +14 -11
  41. package/dist/source.d.ts +62 -190
  42. package/dist/source.d.ts.map +1 -1
  43. package/dist/source.js +32 -85
  44. package/package.json +7 -3
  45. package/dist/runtime/runtime.d.ts +0 -58
  46. package/dist/runtime/runtime.d.ts.map +0 -1
  47. package/dist/runtime/runtime.js +0 -75
  48. package/dist/runtime/services/plugin-cache.service.d.ts +0 -18
  49. package/dist/runtime/services/plugin-cache.service.d.ts.map +0 -1
  50. package/dist/runtime/services/plugin-cache.service.js +0 -55
@@ -0,0 +1,59 @@
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
+ };
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=streaming.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"streaming.test.d.ts","sourceRoot":"","sources":["../../src/runtime/streaming.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,271 @@
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
+ });
@@ -0,0 +1,3 @@
1
+ import type { PluginLogger } from "../plugin";
2
+ export declare const createTestLogger: () => PluginLogger;
3
+ //# sourceMappingURL=test-utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"test-utils.d.ts","sourceRoot":"","sources":["../../src/runtime/test-utils.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AAE9C,eAAO,MAAM,gBAAgB,QAAO,YAYlC,CAAC"}
@@ -0,0 +1,13 @@
1
+ import { Effect } from "effect";
2
+ export const createTestLogger = () => ({
3
+ logInfo: (message, context) =>
4
+ Effect.sync(() => console.log(`[INFO] ${message}`, context || "")),
5
+ logWarning: (message, context) =>
6
+ Effect.sync(() => console.warn(`[WARNING] ${message}`, context || "")),
7
+ logError: (message, error, context) =>
8
+ Effect.sync(() =>
9
+ console.error(`[ERROR] ${message}`, error, context || ""),
10
+ ),
11
+ logDebug: (message, context) =>
12
+ Effect.sync(() => console.log(`[DEBUG] ${message}`, context || "")),
13
+ });
@@ -1,40 +1,40 @@
1
1
  import type { z } from "zod";
2
2
  import type { Plugin, PluginLogger, PluginRegistry } from "../plugin";
3
3
  export interface PluginRuntimeConfig {
4
- registry: PluginRegistry;
5
- secrets?: SecretsConfig;
6
- logger?: PluginLogger;
4
+ registry: PluginRegistry;
5
+ secrets?: SecretsConfig;
6
+ logger?: PluginLogger;
7
7
  }
8
8
  export interface SecretsConfig {
9
- [key: string]: string;
9
+ [key: string]: string;
10
10
  }
11
11
  export type AnyPlugin = Plugin<z.ZodTypeAny, z.ZodTypeAny, z.ZodTypeAny>;
12
12
  export interface PluginConstructor {
13
- readonly ctor: new () => AnyPlugin;
14
- readonly metadata: {
15
- readonly pluginId: string;
16
- readonly version?: string;
17
- readonly description?: string;
18
- readonly type?: string;
19
- };
13
+ readonly ctor: new () => AnyPlugin;
14
+ readonly metadata: {
15
+ readonly pluginId: string;
16
+ readonly version?: string;
17
+ readonly description?: string;
18
+ readonly type?: string;
19
+ };
20
20
  }
21
21
  export interface PluginInstance<T extends AnyPlugin = AnyPlugin> {
22
- readonly plugin: T;
23
- readonly metadata: {
24
- readonly pluginId: string;
25
- readonly version?: string;
26
- readonly description?: string;
27
- readonly type?: string;
28
- };
22
+ readonly plugin: T;
23
+ readonly metadata: {
24
+ readonly pluginId: string;
25
+ readonly version?: string;
26
+ readonly description?: string;
27
+ readonly type?: string;
28
+ };
29
29
  }
30
30
  export interface InitializedPlugin<T extends AnyPlugin = AnyPlugin> {
31
- readonly plugin: T;
32
- readonly metadata: {
33
- readonly pluginId: string;
34
- readonly version?: string;
35
- readonly description?: string;
36
- readonly type?: string;
37
- };
38
- readonly config: z.infer<T["configSchema"]>;
31
+ readonly plugin: T;
32
+ readonly metadata: {
33
+ readonly pluginId: string;
34
+ readonly version?: string;
35
+ readonly description?: string;
36
+ readonly type?: string;
37
+ };
38
+ readonly config: z.infer<T["configSchema"]>;
39
39
  }
40
- //# sourceMappingURL=types.d.ts.map
40
+ //# sourceMappingURL=types.d.ts.map
@@ -5,6 +5,6 @@ export declare const validate: <T>(
5
5
  schema: z.ZodSchema<T>,
6
6
  data: unknown,
7
7
  pluginId: string,
8
- stage: "config" | "input" | "output",
8
+ stage: "config" | "input" | "output" | "state",
9
9
  ) => Effect.Effect<T, ValidationError>;
10
10
  //# sourceMappingURL=validation.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"validation.d.ts","sourceRoot":"","sources":["../../src/runtime/validation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChC,OAAO,KAAK,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAC7B,OAAO,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAE3C,eAAO,MAAM,QAAQ,GAAI,CAAC,EACzB,QAAQ,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,EACtB,MAAM,OAAO,EACb,UAAU,MAAM,EAChB,OAAO,QAAQ,GAAG,OAAO,GAAG,QAAQ,KAClC,MAAM,CAAC,MAAM,CAAC,CAAC,EAAE,eAAe,CAahC,CAAC"}
1
+ {"version":3,"file":"validation.d.ts","sourceRoot":"","sources":["../../src/runtime/validation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChC,OAAO,KAAK,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAC7B,OAAO,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAE3C,eAAO,MAAM,QAAQ,GAAI,CAAC,EACzB,QAAQ,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,EACtB,MAAM,OAAO,EACb,UAAU,MAAM,EAChB,OAAO,QAAQ,GAAG,OAAO,GAAG,QAAQ,GAAG,OAAO,KAC5C,MAAM,CAAC,MAAM,CAAC,CAAC,EAAE,eAAe,CAahC,CAAC"}
@@ -1,13 +1,16 @@
1
1
  import { Effect } from "effect";
2
2
  import { ValidationError } from "./errors";
3
- export const validate = (schema, data, pluginId, stage) => Effect.gen(function* () {
4
- const result = schema.safeParse(data);
5
- if (result.success) {
6
- return result.data;
7
- }
8
- return yield* Effect.fail(new ValidationError({
9
- pluginId,
10
- stage,
11
- zodError: result.error,
12
- }));
13
- });
3
+ export const validate = (schema, data, pluginId, stage) =>
4
+ Effect.gen(function* () {
5
+ const result = schema.safeParse(data);
6
+ if (result.success) {
7
+ return result.data;
8
+ }
9
+ return yield* Effect.fail(
10
+ new ValidationError({
11
+ pluginId,
12
+ stage,
13
+ zodError: result.error,
14
+ }),
15
+ );
16
+ });