every-plugin 0.0.5 → 0.0.6

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 (46) hide show
  1. package/README.md +256 -6
  2. package/dist/errors.d.ts +4 -4
  3. package/dist/errors.d.ts.map +1 -1
  4. package/dist/errors.js +2 -2
  5. package/dist/index.d.ts +4 -4
  6. package/dist/index.js +3 -3
  7. package/dist/plugin.d.ts +4 -13
  8. package/dist/plugin.d.ts.map +1 -1
  9. package/dist/plugin.js +1 -1
  10. package/dist/runtime/errors.d.ts +41 -0
  11. package/dist/runtime/errors.d.ts.map +1 -0
  12. package/dist/runtime/errors.js +7 -0
  13. package/dist/runtime/index.d.ts +21 -0
  14. package/dist/runtime/index.d.ts.map +1 -0
  15. package/dist/runtime/index.js +34 -0
  16. package/dist/runtime/runtime.d.ts +58 -0
  17. package/dist/runtime/runtime.d.ts.map +1 -0
  18. package/dist/runtime/runtime.js +75 -0
  19. package/dist/runtime/runtime.test.d.ts +2 -0
  20. package/dist/runtime/runtime.test.d.ts.map +1 -0
  21. package/dist/runtime/runtime.test.js +308 -0
  22. package/dist/runtime/services/module-federation.service.d.ts +17 -0
  23. package/dist/runtime/services/module-federation.service.d.ts.map +1 -0
  24. package/dist/runtime/services/module-federation.service.js +108 -0
  25. package/dist/runtime/services/plugin-cache.service.d.ts +18 -0
  26. package/dist/runtime/services/plugin-cache.service.d.ts.map +1 -0
  27. package/dist/runtime/services/plugin-cache.service.js +55 -0
  28. package/dist/runtime/services/plugin.service.d.ts +22 -0
  29. package/dist/runtime/services/plugin.service.d.ts.map +1 -0
  30. package/dist/runtime/services/plugin.service.js +130 -0
  31. package/dist/runtime/services/secrets.service.d.ts +17 -0
  32. package/dist/runtime/services/secrets.service.d.ts.map +1 -0
  33. package/dist/runtime/services/secrets.service.js +32 -0
  34. package/dist/runtime/services.d.ts +5 -0
  35. package/dist/runtime/services.d.ts.map +1 -0
  36. package/dist/runtime/services.js +4 -0
  37. package/dist/runtime/types.d.ts +40 -0
  38. package/dist/runtime/types.d.ts.map +1 -0
  39. package/dist/runtime/types.js +1 -0
  40. package/dist/runtime/validation.d.ts +10 -0
  41. package/dist/runtime/validation.d.ts.map +1 -0
  42. package/dist/runtime/validation.js +13 -0
  43. package/dist/source.d.ts +7 -7
  44. package/dist/source.d.ts.map +1 -1
  45. package/dist/source.js +35 -19
  46. package/package.json +40 -22
@@ -0,0 +1,130 @@
1
+ import { Duration, Effect, Layer, Schedule } from "effect";
2
+ import { PluginLoggerTag } from "../../plugin";
3
+ import { PluginRuntimeError } from "../errors";
4
+ import { validate } from "../validation";
5
+ import { PluginCacheService } from "./plugin-cache.service";
6
+ import { SecretsService } from "./secrets.service";
7
+ export class PluginService extends Effect.Tag("PluginService")() {
8
+ static Live = (registry, secrets) => Layer.effect(PluginService, Effect.gen(function* () {
9
+ const cacheService = yield* PluginCacheService;
10
+ const secretsService = yield* SecretsService;
11
+ const logger = yield* PluginLoggerTag;
12
+ const retrySchedule = Schedule.exponential(Duration.millis(100)).pipe(Schedule.compose(Schedule.recurs(2)));
13
+ const resolveUrl = (baseUrl, version) => version && version !== "latest"
14
+ ? baseUrl.replace("@latest", `@${version}`)
15
+ : baseUrl;
16
+ return {
17
+ loadPlugin: (pluginId) => Effect.gen(function* () {
18
+ const metadata = registry[pluginId];
19
+ if (!metadata) {
20
+ return yield* Effect.fail(new PluginRuntimeError({
21
+ pluginId,
22
+ operation: "load-plugin",
23
+ cause: new Error(`Plugin ${pluginId} not found in registry`),
24
+ retryable: false,
25
+ }));
26
+ }
27
+ const url = resolveUrl(metadata.remoteUrl);
28
+ const cacheKey = `${pluginId}:${url}`;
29
+ const cachedConstructor = yield* cacheService.getCachedConstructor(cacheKey);
30
+ return {
31
+ ctor: cachedConstructor.ctor,
32
+ metadata: {
33
+ pluginId,
34
+ version: metadata.version,
35
+ description: metadata.description,
36
+ type: metadata.type,
37
+ },
38
+ };
39
+ }),
40
+ instantiatePlugin: (pluginConstructor) => Effect.gen(function* () {
41
+ const instance = yield* Effect.try({
42
+ try: () => new pluginConstructor.ctor(),
43
+ catch: (error) => new PluginRuntimeError({
44
+ pluginId: pluginConstructor.metadata.pluginId,
45
+ operation: "instantiate-plugin",
46
+ cause: error instanceof Error ? error : new Error(String(error)),
47
+ retryable: false,
48
+ }),
49
+ });
50
+ // Validate plugin ID matches
51
+ if (instance.id !== pluginConstructor.metadata.pluginId) {
52
+ return yield* Effect.fail(new PluginRuntimeError({
53
+ pluginId: pluginConstructor.metadata.pluginId,
54
+ operation: "validate-plugin-id",
55
+ cause: new Error(`Plugin ID mismatch: expected ${pluginConstructor.metadata.pluginId}, got ${instance.id}`),
56
+ retryable: false,
57
+ }));
58
+ }
59
+ return {
60
+ plugin: instance,
61
+ metadata: pluginConstructor.metadata,
62
+ };
63
+ }),
64
+ initializePlugin: (pluginInstance, config) => Effect.gen(function* () {
65
+ const { plugin } = pluginInstance;
66
+ // Validate raw config using plugin's Zod schema
67
+ const validatedConfig = yield* validate(plugin.configSchema, config, plugin.id, "config").pipe(Effect.mapError((validationError) => new PluginRuntimeError({
68
+ pluginId: plugin.id,
69
+ operation: "validate-config",
70
+ cause: validationError.zodError,
71
+ retryable: false,
72
+ })));
73
+ // Hydrate secrets
74
+ const hydratedConfig = yield* secretsService.hydrateSecrets(validatedConfig, secrets);
75
+ // Validate hydrated config
76
+ const finalConfig = yield* validate(plugin.configSchema, hydratedConfig, plugin.id, "config").pipe(Effect.mapError((validationError) => new PluginRuntimeError({
77
+ pluginId: plugin.id,
78
+ operation: "validate-hydrated-config",
79
+ cause: validationError.zodError,
80
+ retryable: false,
81
+ })));
82
+ // Initialize plugin with retry logic
83
+ const pluginLayer = Layer.succeed(PluginLoggerTag, logger);
84
+ yield* plugin
85
+ .initialize(finalConfig)
86
+ .pipe(Effect.mapError((error) => new PluginRuntimeError({
87
+ pluginId: plugin.id,
88
+ operation: "initialize-plugin",
89
+ cause: error,
90
+ retryable: error.retryable ?? false,
91
+ })), Effect.retry(retrySchedule.pipe(Schedule.whileInput((error) => error.retryable))), Effect.provide(pluginLayer));
92
+ return {
93
+ plugin,
94
+ metadata: pluginInstance.metadata,
95
+ config: finalConfig, // TODO: config type
96
+ };
97
+ }),
98
+ executePlugin: (initializedPlugin, input) => Effect.gen(function* () {
99
+ const { plugin } = initializedPlugin;
100
+ // Validate input
101
+ const validatedInput = yield* validate(plugin.inputSchema, input, plugin.id, "input").pipe(Effect.mapError((validationError) => new PluginRuntimeError({
102
+ pluginId: plugin.id,
103
+ operation: "validate-input",
104
+ cause: validationError.zodError,
105
+ retryable: false,
106
+ })));
107
+ // Execute plugin
108
+ const pluginLayer = Layer.succeed(PluginLoggerTag, logger);
109
+ const output = yield* plugin
110
+ .execute(validatedInput)
111
+ .pipe(Effect.mapError((error) => new PluginRuntimeError({
112
+ pluginId: plugin.id,
113
+ operation: "execute-plugin",
114
+ cause: error,
115
+ retryable: error.retryable ?? false,
116
+ })), Effect.retry(retrySchedule.pipe(Schedule.whileInput((error) => error.retryable))), Effect.provide(pluginLayer));
117
+ // Validate output
118
+ const validatedOutput = yield* validate(plugin.outputSchema, output, plugin.id, "output").pipe(Effect.mapError((validationError) => new PluginRuntimeError({
119
+ pluginId: plugin.id,
120
+ operation: "validate-output",
121
+ cause: validationError.zodError,
122
+ retryable: false,
123
+ })));
124
+ return validatedOutput;
125
+ }),
126
+ };
127
+ }));
128
+ }
129
+ export const PluginServiceTag = PluginService;
130
+ export const PluginServiceLive = PluginService.Live;
@@ -0,0 +1,17 @@
1
+ import { Effect, Layer } from "effect";
2
+ import { PluginRuntimeError } from "../errors";
3
+ import type { SecretsConfig } from "../types";
4
+ export interface ISecretsService {
5
+ readonly hydrateSecrets: (config: any, // TODO:
6
+ secretsConfig: SecretsConfig) => Effect.Effect<any, PluginRuntimeError>;
7
+ }
8
+ declare const SecretsService_base: import("effect/Context").TagClass<SecretsService, "SecretsService", ISecretsService> & Effect.Tag.Proxy<SecretsService, ISecretsService> & {
9
+ use: <X>(body: (_: ISecretsService) => X) => [X] extends [Effect.Effect<infer A, infer E, infer R>] ? Effect.Effect<A, E, R | SecretsService> : [X] extends [PromiseLike<infer A_1>] ? Effect.Effect<A_1, import("effect/Cause").UnknownException, SecretsService> : Effect.Effect<X, never, SecretsService>;
10
+ };
11
+ export declare class SecretsService extends SecretsService_base {
12
+ static Live: (secrets: SecretsConfig) => Layer.Layer<SecretsService, never, never>;
13
+ }
14
+ export declare const SecretsServiceTag: typeof SecretsService;
15
+ export declare const SecretsServiceLive: (secrets: SecretsConfig) => Layer.Layer<SecretsService, never, never>;
16
+ export {};
17
+ //# sourceMappingURL=secrets.service.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"secrets.service.d.ts","sourceRoot":"","sources":["../../../src/runtime/services/secrets.service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,QAAQ,CAAC;AACvC,OAAO,EAAE,kBAAkB,EAAE,MAAM,WAAW,CAAC;AAC/C,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAE9C,MAAM,WAAW,eAAe;IAC9B,QAAQ,CAAC,cAAc,EAAE,CACvB,MAAM,EAAE,GAAG,EAAE,QAAQ;IACrB,aAAa,EAAE,aAAa,KACzB,MAAM,CAAC,MAAM,CAAC,GAAG,EAAE,kBAAkB,CAAC,CAAC;CAC7C;;;;AAED,qBAAa,cAAe,SAAQ,mBAGjC;IACD,MAAM,CAAC,IAAI,GAAI,SAAS,aAAa,+CAgChC;CACN;AAED,eAAO,MAAM,iBAAiB,uBAAiB,CAAC;AAChD,eAAO,MAAM,kBAAkB,YApCL,aAAa,8CAoCc,CAAC"}
@@ -0,0 +1,32 @@
1
+ import { Effect, Layer } from "effect";
2
+ import { PluginRuntimeError } from "../errors";
3
+ export class SecretsService extends Effect.Tag("SecretsService")() {
4
+ static Live = (secrets) => Layer.succeed(SecretsService, {
5
+ hydrateSecrets: (config, secretsConfig) => Effect.gen(function* () {
6
+ if (!config || typeof config !== "object" || !config.secrets) {
7
+ return config;
8
+ }
9
+ try {
10
+ const configString = JSON.stringify(config);
11
+ let hydratedString = configString;
12
+ // Use provided secrets or fallback to secretsConfig
13
+ const effectiveSecrets = { ...secretsConfig, ...secrets };
14
+ // Simple template replacement for {{SECRET_NAME}} patterns
15
+ for (const [key, value] of Object.entries(effectiveSecrets)) {
16
+ const pattern = new RegExp(`{{${key}}}`, "g");
17
+ hydratedString = hydratedString.replace(pattern, value);
18
+ }
19
+ return JSON.parse(hydratedString);
20
+ }
21
+ catch (error) {
22
+ return yield* Effect.fail(new PluginRuntimeError({
23
+ operation: "hydrate-secrets",
24
+ cause: error instanceof Error ? error : new Error(String(error)),
25
+ retryable: false,
26
+ }));
27
+ }
28
+ }),
29
+ });
30
+ }
31
+ export const SecretsServiceTag = SecretsService;
32
+ export const SecretsServiceLive = SecretsService.Live;
@@ -0,0 +1,5 @@
1
+ export * from "./services/module-federation.service";
2
+ export * from "./services/plugin.service";
3
+ export * from "./services/plugin-cache.service";
4
+ export * from "./services/secrets.service";
5
+ //# sourceMappingURL=services.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"services.d.ts","sourceRoot":"","sources":["../../src/runtime/services.ts"],"names":[],"mappings":"AAAA,cAAc,sCAAsC,CAAC;AACrD,cAAc,2BAA2B,CAAC;AAC1C,cAAc,iCAAiC,CAAC;AAChD,cAAc,4BAA4B,CAAC"}
@@ -0,0 +1,4 @@
1
+ export * from "./services/module-federation.service";
2
+ export * from "./services/plugin.service";
3
+ export * from "./services/plugin-cache.service";
4
+ export * from "./services/secrets.service";
@@ -0,0 +1,40 @@
1
+ import type { z } from "zod";
2
+ import type { Plugin, PluginLogger, PluginRegistry } from "../plugin";
3
+ export interface PluginRuntimeConfig {
4
+ registry: PluginRegistry;
5
+ secrets?: SecretsConfig;
6
+ logger?: PluginLogger;
7
+ }
8
+ export interface SecretsConfig {
9
+ [key: string]: string;
10
+ }
11
+ export type AnyPlugin = Plugin<z.ZodTypeAny, z.ZodTypeAny, z.ZodTypeAny>;
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
+ };
20
+ }
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
+ };
29
+ }
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"]>;
39
+ }
40
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/runtime/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAC7B,OAAO,KAAK,EAAE,MAAM,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAGtE,MAAM,WAAW,mBAAmB;IACnC,QAAQ,EAAE,cAAc,CAAC;IACzB,OAAO,CAAC,EAAE,aAAa,CAAC;IACxB,MAAM,CAAC,EAAE,YAAY,CAAC;CACtB;AAED,MAAM,WAAW,aAAa;IAC7B,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAC;CACtB;AAGD,MAAM,MAAM,SAAS,GAAG,MAAM,CAAC,CAAC,CAAC,UAAU,EAAE,CAAC,CAAC,UAAU,EAAE,CAAC,CAAC,UAAU,CAAC,CAAC;AAEzE,MAAM,WAAW,iBAAiB;IACjC,QAAQ,CAAC,IAAI,EAAE,UAAU,SAAS,CAAC;IACnC,QAAQ,CAAC,QAAQ,EAAE;QAClB,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;QAC1B,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC;QAC1B,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,CAAC;QAC9B,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;KACvB,CAAC;CACF;AAED,MAAM,WAAW,cAAc,CAAC,CAAC,SAAS,SAAS,GAAG,SAAS;IAC9D,QAAQ,CAAC,MAAM,EAAE,CAAC,CAAC;IACnB,QAAQ,CAAC,QAAQ,EAAE;QAClB,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;QAC1B,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC;QAC1B,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,CAAC;QAC9B,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;KACvB,CAAC;CACF;AAED,MAAM,WAAW,iBAAiB,CAAC,CAAC,SAAS,SAAS,GAAG,SAAS;IACjE,QAAQ,CAAC,MAAM,EAAE,CAAC,CAAC;IACnB,QAAQ,CAAC,QAAQ,EAAE;QAClB,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;QAC1B,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC;QAC1B,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,CAAC;QAC9B,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;KACvB,CAAC;IACF,QAAQ,CAAC,MAAM,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,cAAc,CAAC,CAAC,CAAC;CAC5C"}
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,10 @@
1
+ import { Effect } from "effect";
2
+ import type { z } from "zod";
3
+ import { ValidationError } from "./errors";
4
+ export declare const validate: <T>(
5
+ schema: z.ZodSchema<T>,
6
+ data: unknown,
7
+ pluginId: string,
8
+ stage: "config" | "input" | "output",
9
+ ) => Effect.Effect<T, ValidationError>;
10
+ //# sourceMappingURL=validation.d.ts.map
@@ -0,0 +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"}
@@ -0,0 +1,13 @@
1
+ import { Effect } from "effect";
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
+ });
package/dist/source.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { z } from 'zod';
2
- import type { Config, Input, Output, Plugin } from './plugin';
1
+ import { z } from "zod";
2
+ import type { Config, Input, Output, Plugin } from "./plugin";
3
3
  /**
4
4
  * Zod schema for the Author interface
5
5
  */
@@ -40,7 +40,7 @@ export declare const ContentType: {
40
40
  readonly DATABASE_ENTRY: "database-entry";
41
41
  readonly UNKNOWN: "unknown";
42
42
  };
43
- export type ContentType = typeof ContentType[keyof typeof ContentType];
43
+ export type ContentType = (typeof ContentType)[keyof typeof ContentType];
44
44
  /**
45
45
  * Represents a single author - derived from the authorSchema
46
46
  */
@@ -53,7 +53,7 @@ export type BasePluginSourceItem = z.infer<typeof pluginSourceItemSchema>;
53
53
  * This is the data structure a plugin is responsible for creating.
54
54
  * It's generic over the raw data type.
55
55
  */
56
- export interface PluginSourceItem<TRaw = Record<string, any>> extends Omit<BasePluginSourceItem, 'raw'> {
56
+ export interface PluginSourceItem<TRaw = Record<string, any>> extends Omit<BasePluginSourceItem, "raw"> {
57
57
  raw: TRaw;
58
58
  }
59
59
  /**
@@ -84,11 +84,11 @@ export declare const AsyncJobProgressSchema: z.ZodObject<{
84
84
  workflowId: z.ZodString;
85
85
  status: z.ZodEnum<{
86
86
  error: "error";
87
+ timeout: "timeout";
87
88
  submitted: "submitted";
88
89
  pending: "pending";
89
90
  processing: "processing";
90
91
  done: "done";
91
- timeout: "timeout";
92
92
  }>;
93
93
  submittedAt: z.ZodString;
94
94
  lastCheckedAt: z.ZodOptional<z.ZodString>;
@@ -108,11 +108,11 @@ export declare const PlatformStateSchema: z.ZodObject<{
108
108
  workflowId: z.ZodString;
109
109
  status: z.ZodEnum<{
110
110
  error: "error";
111
+ timeout: "timeout";
111
112
  submitted: "submitted";
112
113
  pending: "pending";
113
114
  processing: "processing";
114
115
  done: "done";
115
- timeout: "timeout";
116
116
  }>;
117
117
  submittedAt: z.ZodString;
118
118
  lastCheckedAt: z.ZodOptional<z.ZodString>;
@@ -162,7 +162,7 @@ export interface SourceOutput extends Output<z.ZodAny> {
162
162
  }>;
163
163
  }
164
164
  export interface SourcePlugin<TInputSchema extends z.ZodTypeAny = z.ZodTypeAny, TOutputSchema extends z.ZodTypeAny = z.ZodTypeAny, TConfigSchema extends z.ZodTypeAny = z.ZodTypeAny> extends Plugin<TInputSchema, TOutputSchema, TConfigSchema> {
165
- readonly type: 'source';
165
+ readonly type: "source";
166
166
  }
167
167
  export declare const createSourceInputSchema: <TSearchOptions extends z.ZodTypeAny, TState extends z.ZodTypeAny>(searchOptionsSchema: TSearchOptions, stateSchema: TState) => z.ZodObject<{
168
168
  searchOptions: TSearchOptions;
@@ -1 +1 @@
1
- {"version":3,"file":"source.d.ts","sourceRoot":"","sources":["../src/source.ts"],"names":[],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B,UAAU,KAAK,EACf,aAAa,MAAM;;;;;;;;;;;;;;;;;;;;;;;;iBAsBnB,CAAC"}
package/dist/source.js CHANGED
@@ -1,5 +1,5 @@
1
- import { z } from 'zod';
2
- import { ErrorDetailsSchema } from './plugin';
1
+ import { z } from "zod";
2
+ import { ErrorDetailsSchema } from "./plugin";
3
3
  /**
4
4
  * Zod schema for the Author interface
5
5
  */
@@ -26,32 +26,46 @@ export const pluginSourceItemSchema = z.object({
26
26
  * Plugins can extend this with custom types.
27
27
  */
28
28
  export const ContentType = {
29
- POST: 'post',
30
- ARTICLE: 'article',
31
- VIDEO: 'video',
32
- PODCAST: 'podcast',
33
- WEBSITE: 'website',
34
- FEED: 'feed',
35
- DATABASE_ENTRY: 'database-entry',
36
- UNKNOWN: 'unknown',
29
+ POST: "post",
30
+ ARTICLE: "article",
31
+ VIDEO: "video",
32
+ PODCAST: "podcast",
33
+ WEBSITE: "website",
34
+ FEED: "feed",
35
+ DATABASE_ENTRY: "database-entry",
36
+ UNKNOWN: "unknown",
37
37
  };
38
38
  export const AsyncJobProgressSchema = z.object({
39
39
  workflowId: z.string(),
40
- status: z.enum(["submitted", "pending", "processing", "done", "error", "timeout"]),
40
+ status: z.enum([
41
+ "submitted",
42
+ "pending",
43
+ "processing",
44
+ "done",
45
+ "error",
46
+ "timeout",
47
+ ]),
41
48
  submittedAt: z.string(), // ISO timestamp
42
49
  lastCheckedAt: z.string().optional(), // ISO timestamp
43
50
  errorMessage: z.string().optional(),
44
51
  });
45
- export const PlatformStateSchema = z.object({
46
- latestProcessedId: z.union([z.string(), z.number(), z.record(z.string(), z.any())]).optional(),
52
+ export const PlatformStateSchema = z
53
+ .object({
54
+ latestProcessedId: z
55
+ .union([z.string(), z.number(), z.record(z.string(), z.any())])
56
+ .optional(),
47
57
  currentAsyncJob: AsyncJobProgressSchema.nullable().optional(),
48
- }).catchall(z.any());
58
+ })
59
+ .catchall(z.any());
49
60
  // Source-specific schema creators
50
61
  export const createSourceInputSchema = (searchOptionsSchema, stateSchema) => z.object({
51
62
  searchOptions: searchOptionsSchema,
52
- lastProcessedState: z.object({
53
- data: stateSchema.optional().nullable()
54
- }).optional().nullable(),
63
+ lastProcessedState: z
64
+ .object({
65
+ data: stateSchema.optional().nullable(),
66
+ })
67
+ .optional()
68
+ .nullable(),
55
69
  });
56
70
  export const createSourceOutputSchema = (itemData, stateSchema) => {
57
71
  const pluginSourceItemSchema = z.object({
@@ -65,10 +79,12 @@ export const createSourceOutputSchema = (itemData, stateSchema) => {
65
79
  });
66
80
  return z.object({
67
81
  success: z.boolean(),
68
- data: z.object({
82
+ data: z
83
+ .object({
69
84
  items: z.array(pluginSourceItemSchema),
70
85
  nextLastProcessedState: stateSchema.optional().nullable(),
71
- }).optional(),
86
+ })
87
+ .optional(),
72
88
  errors: z.array(ErrorDetailsSchema).optional(),
73
89
  });
74
90
  };
package/package.json CHANGED
@@ -1,24 +1,42 @@
1
1
  {
2
- "name": "every-plugin",
3
- "version": "0.0.5",
4
- "main": "dist/index.js",
5
- "types": "dist/index.d.ts",
6
- "files": [
7
- "dist"
8
- ],
9
- "scripts": {
10
- "build": "tsc -b"
11
- },
12
- "peerDependencies": {
13
- "effect": ">=3.17.0 <4.0.0",
14
- "zod": ">=4.0.0"
15
- },
16
- "devDependencies": {
17
- "effect": "^3.17.7",
18
- "zod": "^4.0.8",
19
- "typescript": "^5.0.0"
20
- },
21
- "dependencies": {
22
- "ajv": "^8.17.1"
23
- }
2
+ "name": "every-plugin",
3
+ "version": "0.0.6",
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
+ },
16
+ "files": [
17
+ "dist"
18
+ ],
19
+ "scripts": {
20
+ "build": "tsc -b",
21
+ "test": "vitest"
22
+ },
23
+ "peerDependencies": {
24
+ "effect": ">=3.17.0 <4.0.0",
25
+ "zod": ">=4.0.0",
26
+ "@module-federation/enhanced": ">=0.18.0",
27
+ "@module-federation/runtime-core": ">=0.18.0"
28
+ },
29
+ "devDependencies": {
30
+ "@effect/vitest": "^0.25.1",
31
+ "@module-federation/enhanced": "^0.18.3",
32
+ "@module-federation/runtime-core": "^0.18.3",
33
+ "effect": "^3.17.7",
34
+ "typescript": "^5.0.0",
35
+ "vitest": "^3.2.4",
36
+ "zod": "^4.0.8"
37
+ },
38
+ "dependencies": {
39
+ "@better-fetch/fetch": "^1.1.18",
40
+ "ajv": "^8.17.1"
41
+ }
24
42
  }