every-plugin 0.0.1 → 0.0.3
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/errors.d.ts +8 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +15 -0
- package/dist/index.d.ts +4 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -3
- package/dist/plugin.d.ts +106 -50
- package/dist/source.d.ts +198 -0
- package/dist/source.d.ts.map +1 -1
- package/dist/source.js +74 -0
- package/package.json +1 -1
package/dist/errors.d.ts
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export declare class PluginExecutionError extends Error {
|
|
2
|
+
readonly retryable: boolean;
|
|
3
|
+
constructor(message: string, retryable?: boolean);
|
|
4
|
+
}
|
|
5
|
+
export declare class ConfigurationError extends PluginExecutionError {
|
|
6
|
+
constructor(message: string);
|
|
7
|
+
}
|
|
8
|
+
//# sourceMappingURL=errors.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AACA,qBAAa,oBAAqB,SAAQ,KAAK;aACA,SAAS,EAAE,OAAO;gBAAnD,OAAO,EAAE,MAAM,EAAkB,SAAS,GAAE,OAAc;CAIvE;AAED,qBAAa,kBAAmB,SAAQ,oBAAoB;gBAC9C,OAAO,EAAE,MAAM;CAI5B"}
|
package/dist/errors.js
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
// Plugin execution errors
|
|
2
|
+
export class PluginExecutionError extends Error {
|
|
3
|
+
retryable;
|
|
4
|
+
constructor(message, retryable = true) {
|
|
5
|
+
super(message);
|
|
6
|
+
this.retryable = retryable;
|
|
7
|
+
this.name = 'PluginExecutionError';
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
export class ConfigurationError extends PluginExecutionError {
|
|
11
|
+
constructor(message) {
|
|
12
|
+
super(message, false); // Configuration errors are not retryable
|
|
13
|
+
this.name = 'ConfigurationError';
|
|
14
|
+
}
|
|
15
|
+
}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export { Effect } from "effect";
|
|
2
2
|
export { z } from "zod";
|
|
3
|
-
export * from
|
|
4
|
-
export * from
|
|
5
|
-
export * from
|
|
6
|
-
//# sourceMappingURL=index.d.ts.map
|
|
3
|
+
export * from "./errors";
|
|
4
|
+
export * from "./plugin";
|
|
5
|
+
export * from "./source";
|
|
6
|
+
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChC,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,cAAc,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChC,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC"}
|
package/dist/index.js
CHANGED
package/dist/plugin.d.ts
CHANGED
|
@@ -1,66 +1,122 @@
|
|
|
1
1
|
import type { JSONSchemaType } from "ajv/dist/2020";
|
|
2
2
|
import { Context, type Effect } from "effect";
|
|
3
|
-
import { z } from
|
|
3
|
+
import { z } from "zod";
|
|
4
4
|
import type { ConfigurationError, PluginExecutionError } from "./errors";
|
|
5
|
-
export declare const createOutputSchema: <T extends z.ZodTypeAny>(
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
5
|
+
export declare const createOutputSchema: <T extends z.ZodTypeAny>(
|
|
6
|
+
dataSchema: T,
|
|
7
|
+
) => z.ZodObject<
|
|
8
|
+
{
|
|
9
|
+
success: z.ZodBoolean;
|
|
10
|
+
data: z.ZodOptional<T>;
|
|
11
|
+
errors: z.ZodOptional<
|
|
12
|
+
z.ZodArray<
|
|
13
|
+
z.ZodObject<
|
|
14
|
+
{
|
|
15
|
+
message: z.ZodString;
|
|
16
|
+
details: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
17
|
+
stack: z.ZodOptional<z.ZodString>;
|
|
18
|
+
},
|
|
19
|
+
z.core.$strip
|
|
20
|
+
>
|
|
21
|
+
>
|
|
22
|
+
>;
|
|
23
|
+
},
|
|
24
|
+
z.core.$strip
|
|
25
|
+
>;
|
|
14
26
|
export declare function createConfigSchema(): z.ZodObject<{
|
|
15
|
-
|
|
16
|
-
|
|
27
|
+
variables: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
28
|
+
secrets: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
17
29
|
}>;
|
|
18
|
-
export declare function createConfigSchema<V extends z.ZodTypeAny>(
|
|
19
|
-
|
|
20
|
-
|
|
30
|
+
export declare function createConfigSchema<V extends z.ZodTypeAny>(
|
|
31
|
+
variablesSchema?: V,
|
|
32
|
+
): z.ZodObject<{
|
|
33
|
+
variables: z.ZodOptional<V>;
|
|
34
|
+
secrets: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
21
35
|
}>;
|
|
22
|
-
export declare function createConfigSchema<
|
|
23
|
-
|
|
24
|
-
|
|
36
|
+
export declare function createConfigSchema<
|
|
37
|
+
V extends z.ZodTypeAny,
|
|
38
|
+
S extends z.ZodTypeAny,
|
|
39
|
+
>(
|
|
40
|
+
variablesSchema?: V,
|
|
41
|
+
secretsSchema?: S,
|
|
42
|
+
): z.ZodObject<{
|
|
43
|
+
variables: z.ZodOptional<V>;
|
|
44
|
+
secrets: z.ZodOptional<S>;
|
|
25
45
|
}>;
|
|
26
|
-
export declare function createInputSchema<I extends z.ZodTypeAny>(
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
46
|
+
export declare function createInputSchema<I extends z.ZodTypeAny>(
|
|
47
|
+
inputSchema: I,
|
|
48
|
+
): I;
|
|
49
|
+
export declare const ErrorDetailsSchema: z.ZodObject<
|
|
50
|
+
{
|
|
51
|
+
message: z.ZodString;
|
|
52
|
+
details: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
53
|
+
stack: z.ZodOptional<z.ZodString>;
|
|
54
|
+
},
|
|
55
|
+
z.core.$strip
|
|
56
|
+
>;
|
|
32
57
|
export type ErrorDetails = z.infer<typeof ErrorDetailsSchema>;
|
|
33
|
-
export type Config<
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
58
|
+
export type Config<
|
|
59
|
+
V extends z.ZodTypeAny = z.ZodRecord<z.ZodString, z.ZodUnknown>,
|
|
60
|
+
S extends z.ZodTypeAny = z.ZodRecord<z.ZodString, z.ZodUnknown>,
|
|
61
|
+
> = z.infer<ReturnType<typeof createConfigSchema<V, S>>>;
|
|
62
|
+
export type Input<I extends z.ZodTypeAny> = z.infer<
|
|
63
|
+
ReturnType<typeof createInputSchema<I>>
|
|
64
|
+
>;
|
|
65
|
+
export type Output<T extends z.ZodTypeAny> = z.infer<
|
|
66
|
+
ReturnType<typeof createOutputSchema<T>>
|
|
67
|
+
>;
|
|
68
|
+
export interface Plugin<
|
|
69
|
+
TInputSchema extends z.ZodTypeAny,
|
|
70
|
+
TOutputSchema extends z.ZodTypeAny,
|
|
71
|
+
TConfigSchema extends z.ZodTypeAny,
|
|
72
|
+
> {
|
|
73
|
+
readonly id: string;
|
|
74
|
+
readonly type: PluginType;
|
|
75
|
+
initialize(
|
|
76
|
+
config?: z.infer<TConfigSchema>,
|
|
77
|
+
): Effect.Effect<void, ConfigurationError, PluginLoggerTag>;
|
|
78
|
+
execute(
|
|
79
|
+
input: z.infer<TInputSchema>,
|
|
80
|
+
): Effect.Effect<
|
|
81
|
+
z.infer<TOutputSchema>,
|
|
82
|
+
PluginExecutionError,
|
|
83
|
+
PluginLoggerTag
|
|
84
|
+
>;
|
|
85
|
+
shutdown(): Effect.Effect<void, never, PluginLoggerTag>;
|
|
42
86
|
}
|
|
43
87
|
export type PluginType = "transformer" | "distributor" | "source";
|
|
44
88
|
export interface PluginMetadata {
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
89
|
+
remoteUrl: string;
|
|
90
|
+
type?: PluginType;
|
|
91
|
+
configSchema: JSONSchemaType<any>;
|
|
92
|
+
inputSchema: JSONSchemaType<any>;
|
|
93
|
+
outputSchema: JSONSchemaType<any>;
|
|
94
|
+
version?: string;
|
|
95
|
+
description?: string;
|
|
52
96
|
}
|
|
53
97
|
export interface PluginRegistry {
|
|
54
|
-
|
|
98
|
+
[pluginId: string]: PluginMetadata;
|
|
55
99
|
}
|
|
56
100
|
export interface PluginLogger {
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
101
|
+
readonly logInfo: (message: string, context?: unknown) => Effect.Effect<void>;
|
|
102
|
+
readonly logWarning: (
|
|
103
|
+
message: string,
|
|
104
|
+
context?: unknown,
|
|
105
|
+
) => Effect.Effect<void>;
|
|
106
|
+
readonly logError: (
|
|
107
|
+
message: string,
|
|
108
|
+
error?: unknown,
|
|
109
|
+
context?: unknown,
|
|
110
|
+
) => Effect.Effect<void>;
|
|
111
|
+
readonly logDebug: (
|
|
112
|
+
message: string,
|
|
113
|
+
context?: unknown,
|
|
114
|
+
) => Effect.Effect<void>;
|
|
61
115
|
}
|
|
62
|
-
declare const PluginLoggerTag_base: Context.TagClass<
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
116
|
+
declare const PluginLoggerTag_base: Context.TagClass<
|
|
117
|
+
PluginLoggerTag,
|
|
118
|
+
"PluginLogger",
|
|
119
|
+
PluginLogger
|
|
120
|
+
>;
|
|
121
|
+
export declare class PluginLoggerTag extends PluginLoggerTag_base {}
|
|
122
|
+
//# sourceMappingURL=plugin.d.ts.map
|
package/dist/source.d.ts
ADDED
|
@@ -0,0 +1,198 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import type { Config, Input, Output, Plugin } from './plugin';
|
|
3
|
+
/**
|
|
4
|
+
* Zod schema for the Author interface
|
|
5
|
+
*/
|
|
6
|
+
export declare const authorSchema: z.ZodObject<{
|
|
7
|
+
id: z.ZodOptional<z.ZodString>;
|
|
8
|
+
username: z.ZodOptional<z.ZodString>;
|
|
9
|
+
displayName: z.ZodOptional<z.ZodString>;
|
|
10
|
+
url: z.ZodOptional<z.ZodString>;
|
|
11
|
+
}, z.core.$strip>;
|
|
12
|
+
/**
|
|
13
|
+
* Zod schema for PluginSourceItem - defines the structure that plugins must return
|
|
14
|
+
*/
|
|
15
|
+
export declare const pluginSourceItemSchema: z.ZodObject<{
|
|
16
|
+
externalId: z.ZodString;
|
|
17
|
+
content: z.ZodString;
|
|
18
|
+
contentType: z.ZodOptional<z.ZodString>;
|
|
19
|
+
createdAt: z.ZodOptional<z.ZodString>;
|
|
20
|
+
url: z.ZodOptional<z.ZodString>;
|
|
21
|
+
authors: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
22
|
+
id: z.ZodOptional<z.ZodString>;
|
|
23
|
+
username: z.ZodOptional<z.ZodString>;
|
|
24
|
+
displayName: z.ZodOptional<z.ZodString>;
|
|
25
|
+
url: z.ZodOptional<z.ZodString>;
|
|
26
|
+
}, z.core.$strip>>>;
|
|
27
|
+
raw: z.ZodUnknown;
|
|
28
|
+
}, z.core.$strip>;
|
|
29
|
+
/**
|
|
30
|
+
* Standard content types supported by the system.
|
|
31
|
+
* Plugins can extend this with custom types.
|
|
32
|
+
*/
|
|
33
|
+
export declare const ContentType: {
|
|
34
|
+
readonly POST: "post";
|
|
35
|
+
readonly ARTICLE: "article";
|
|
36
|
+
readonly VIDEO: "video";
|
|
37
|
+
readonly PODCAST: "podcast";
|
|
38
|
+
readonly WEBSITE: "website";
|
|
39
|
+
readonly FEED: "feed";
|
|
40
|
+
readonly DATABASE_ENTRY: "database-entry";
|
|
41
|
+
readonly UNKNOWN: "unknown";
|
|
42
|
+
};
|
|
43
|
+
export type ContentType = typeof ContentType[keyof typeof ContentType];
|
|
44
|
+
/**
|
|
45
|
+
* Represents a single author - derived from the authorSchema
|
|
46
|
+
*/
|
|
47
|
+
export type Author = z.infer<typeof authorSchema>;
|
|
48
|
+
/**
|
|
49
|
+
* Base PluginSourceItem type derived from schema (with unknown raw type)
|
|
50
|
+
*/
|
|
51
|
+
export type BasePluginSourceItem = z.infer<typeof pluginSourceItemSchema>;
|
|
52
|
+
/**
|
|
53
|
+
* This is the data structure a plugin is responsible for creating.
|
|
54
|
+
* It's generic over the raw data type.
|
|
55
|
+
*/
|
|
56
|
+
export interface PluginSourceItem<TRaw = Record<string, any>> extends Omit<BasePluginSourceItem, 'raw'> {
|
|
57
|
+
raw: TRaw;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* This is the final, canonical data structure used within the system.
|
|
61
|
+
* It extends PluginSourceItem with system-generated fields.
|
|
62
|
+
*/
|
|
63
|
+
export interface SourceItem<TRaw = Record<string, any>> extends PluginSourceItem<TRaw> {
|
|
64
|
+
id: string;
|
|
65
|
+
createdAt: string;
|
|
66
|
+
metadata: {
|
|
67
|
+
sourcePlugin: string;
|
|
68
|
+
workflowId: string;
|
|
69
|
+
runId: string;
|
|
70
|
+
[key: string]: any;
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Defines the progress of a job submitted to an external asynchronous service (e.g., Masa).
|
|
75
|
+
*/
|
|
76
|
+
export interface AsyncJobProgress {
|
|
77
|
+
workflowId: string;
|
|
78
|
+
status: "submitted" | "pending" | "processing" | "done" | "error" | "timeout";
|
|
79
|
+
submittedAt: string;
|
|
80
|
+
lastCheckedAt?: string;
|
|
81
|
+
errorMessage?: string;
|
|
82
|
+
}
|
|
83
|
+
export declare const AsyncJobProgressSchema: z.ZodObject<{
|
|
84
|
+
workflowId: z.ZodString;
|
|
85
|
+
status: z.ZodEnum<{
|
|
86
|
+
error: "error";
|
|
87
|
+
submitted: "submitted";
|
|
88
|
+
pending: "pending";
|
|
89
|
+
processing: "processing";
|
|
90
|
+
done: "done";
|
|
91
|
+
timeout: "timeout";
|
|
92
|
+
}>;
|
|
93
|
+
submittedAt: z.ZodString;
|
|
94
|
+
lastCheckedAt: z.ZodOptional<z.ZodString>;
|
|
95
|
+
errorMessage: z.ZodOptional<z.ZodString>;
|
|
96
|
+
}, z.core.$strip>;
|
|
97
|
+
/**
|
|
98
|
+
* Generic platform-specific state for managing resumable searches and long-running jobs.
|
|
99
|
+
*/
|
|
100
|
+
export interface PlatformState {
|
|
101
|
+
latestProcessedId?: string | number | Record<string, any>;
|
|
102
|
+
currentAsyncJob?: AsyncJobProgress | null;
|
|
103
|
+
[key: string]: any;
|
|
104
|
+
}
|
|
105
|
+
export declare const PlatformStateSchema: z.ZodObject<{
|
|
106
|
+
latestProcessedId: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodRecord<z.ZodString, z.ZodAny>]>>;
|
|
107
|
+
currentAsyncJob: z.ZodOptional<z.ZodNullable<z.ZodObject<{
|
|
108
|
+
workflowId: z.ZodString;
|
|
109
|
+
status: z.ZodEnum<{
|
|
110
|
+
error: "error";
|
|
111
|
+
submitted: "submitted";
|
|
112
|
+
pending: "pending";
|
|
113
|
+
processing: "processing";
|
|
114
|
+
done: "done";
|
|
115
|
+
timeout: "timeout";
|
|
116
|
+
}>;
|
|
117
|
+
submittedAt: z.ZodString;
|
|
118
|
+
lastCheckedAt: z.ZodOptional<z.ZodString>;
|
|
119
|
+
errorMessage: z.ZodOptional<z.ZodString>;
|
|
120
|
+
}, z.core.$strip>>>;
|
|
121
|
+
}, z.core.$catchall<z.ZodAny>>;
|
|
122
|
+
/**
|
|
123
|
+
* State passed between search calls to enable resumption.
|
|
124
|
+
* TData is expected to be an object conforming to PlatformState or a derivative.
|
|
125
|
+
*/
|
|
126
|
+
export interface LastProcessedState<TData extends PlatformState = PlatformState> {
|
|
127
|
+
data: TData;
|
|
128
|
+
}
|
|
129
|
+
export type SourceConfig<V extends z.ZodTypeAny = z.ZodRecord<z.ZodString, z.ZodUnknown>, S extends z.ZodTypeAny = z.ZodRecord<z.ZodString, z.ZodUnknown>> = Config<V, S>;
|
|
130
|
+
export interface SourceInput<TSearchOptions extends z.ZodTypeAny = z.ZodTypeAny> extends Input<z.ZodAny> {
|
|
131
|
+
searchOptions: TSearchOptions;
|
|
132
|
+
lastProcessedState?: LastProcessedState<PlatformState> | null;
|
|
133
|
+
}
|
|
134
|
+
export interface PluginSourceInput<TSearchOptions = Record<string, unknown>> extends Input<z.ZodAny> {
|
|
135
|
+
searchOptions: TSearchOptions;
|
|
136
|
+
lastProcessedState?: LastProcessedState<PlatformState> | null;
|
|
137
|
+
}
|
|
138
|
+
export interface PluginSourceOutputData<TItem extends PluginSourceItem = PluginSourceItem> {
|
|
139
|
+
items: TItem[];
|
|
140
|
+
nextLastProcessedState?: PlatformState | null;
|
|
141
|
+
}
|
|
142
|
+
export interface PluginSourceOutput<TItem extends PluginSourceItem = PluginSourceItem> extends Output<z.ZodAny> {
|
|
143
|
+
success: boolean;
|
|
144
|
+
data?: PluginSourceOutputData<TItem>;
|
|
145
|
+
errors?: Array<{
|
|
146
|
+
message: string;
|
|
147
|
+
details?: Record<string, unknown>;
|
|
148
|
+
stack?: string;
|
|
149
|
+
}>;
|
|
150
|
+
}
|
|
151
|
+
export interface SourceOutputData {
|
|
152
|
+
items: SourceItem[];
|
|
153
|
+
nextLastProcessedState?: PlatformState | null;
|
|
154
|
+
}
|
|
155
|
+
export interface SourceOutput extends Output<z.ZodAny> {
|
|
156
|
+
success: boolean;
|
|
157
|
+
data?: SourceOutputData;
|
|
158
|
+
errors?: Array<{
|
|
159
|
+
message: string;
|
|
160
|
+
details?: Record<string, unknown>;
|
|
161
|
+
stack?: string;
|
|
162
|
+
}>;
|
|
163
|
+
}
|
|
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';
|
|
166
|
+
}
|
|
167
|
+
export declare const createSourceInputSchema: <TSearchOptions extends z.ZodTypeAny, TState extends z.ZodTypeAny>(searchOptionsSchema: TSearchOptions, stateSchema: TState) => z.ZodObject<{
|
|
168
|
+
searchOptions: TSearchOptions;
|
|
169
|
+
lastProcessedState: z.ZodNullable<z.ZodOptional<z.ZodObject<{
|
|
170
|
+
data: z.ZodNullable<z.ZodOptional<TState>>;
|
|
171
|
+
}, z.core.$strip>>>;
|
|
172
|
+
}, z.core.$strip>;
|
|
173
|
+
export declare const createSourceOutputSchema: <TItem extends z.ZodTypeAny, TState extends z.ZodTypeAny>(itemData: TItem, stateSchema: TState) => z.ZodObject<{
|
|
174
|
+
success: z.ZodBoolean;
|
|
175
|
+
data: z.ZodOptional<z.ZodObject<{
|
|
176
|
+
items: z.ZodArray<z.ZodObject<{
|
|
177
|
+
externalId: z.ZodString;
|
|
178
|
+
content: z.ZodString;
|
|
179
|
+
contentType: z.ZodOptional<z.ZodString>;
|
|
180
|
+
createdAt: z.ZodOptional<z.ZodString>;
|
|
181
|
+
url: z.ZodOptional<z.ZodString>;
|
|
182
|
+
authors: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
183
|
+
id: z.ZodOptional<z.ZodString>;
|
|
184
|
+
username: z.ZodOptional<z.ZodString>;
|
|
185
|
+
displayName: z.ZodOptional<z.ZodString>;
|
|
186
|
+
url: z.ZodOptional<z.ZodString>;
|
|
187
|
+
}, z.core.$strip>>>;
|
|
188
|
+
raw: TItem;
|
|
189
|
+
}, z.core.$strip>>;
|
|
190
|
+
nextLastProcessedState: z.ZodNullable<z.ZodOptional<TState>>;
|
|
191
|
+
}, z.core.$strip>>;
|
|
192
|
+
errors: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
193
|
+
message: z.ZodString;
|
|
194
|
+
details: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
195
|
+
stack: z.ZodOptional<z.ZodString>;
|
|
196
|
+
}, z.core.$strip>>>;
|
|
197
|
+
}, z.core.$strip>;
|
|
198
|
+
//# sourceMappingURL=source.d.ts.map
|
package/dist/source.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"source.d.ts","sourceRoot":"","sources":["../src/source.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"source.d.ts","sourceRoot":"","sources":["../src/source.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAG9D;;GAEG;AACH,eAAO,MAAM,YAAY;;;;;iBAKvB,CAAC;AAEH;;GAEG;AACH,eAAO,MAAM,sBAAsB;;;;;;;;;;;;;iBAQjC,CAAC;AAEH;;;GAGG;AACH,eAAO,MAAM,WAAW;;;;;;;;;CASd,CAAC;AAEX,MAAM,MAAM,WAAW,GAAG,OAAO,WAAW,CAAC,MAAM,OAAO,WAAW,CAAC,CAAC;A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,aAAa,MAAM;;;;;iBAOjB,CAAC;AAEL,eAAO,MAAM,wBAAwB,GACnC,KAAK,SAAS,CAAC,CAAC,UAAU,EAC1B,MAAM,SAAS,CAAC,CAAC,UAAU,EAE3B,UAAU,KAAK,EACf,aAAa,MAAM;;;;;;;;;;;;;;;;;;;;;;;;iBAoBpB,CAAC"}
|
package/dist/source.js
ADDED
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { ErrorDetailsSchema } from './plugin';
|
|
3
|
+
/**
|
|
4
|
+
* Zod schema for the Author interface
|
|
5
|
+
*/
|
|
6
|
+
export const authorSchema = z.object({
|
|
7
|
+
id: z.string().optional(),
|
|
8
|
+
username: z.string().optional(),
|
|
9
|
+
displayName: z.string().optional(),
|
|
10
|
+
url: z.string().optional(),
|
|
11
|
+
});
|
|
12
|
+
/**
|
|
13
|
+
* Zod schema for PluginSourceItem - defines the structure that plugins must return
|
|
14
|
+
*/
|
|
15
|
+
export const pluginSourceItemSchema = z.object({
|
|
16
|
+
externalId: z.string(),
|
|
17
|
+
content: z.string(),
|
|
18
|
+
contentType: z.string().optional(),
|
|
19
|
+
createdAt: z.string().optional(),
|
|
20
|
+
url: z.string().optional(),
|
|
21
|
+
authors: z.array(authorSchema).optional(),
|
|
22
|
+
raw: z.unknown(),
|
|
23
|
+
});
|
|
24
|
+
/**
|
|
25
|
+
* Standard content types supported by the system.
|
|
26
|
+
* Plugins can extend this with custom types.
|
|
27
|
+
*/
|
|
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',
|
|
37
|
+
};
|
|
38
|
+
export const AsyncJobProgressSchema = z.object({
|
|
39
|
+
workflowId: z.string(),
|
|
40
|
+
status: z.enum(["submitted", "pending", "processing", "done", "error", "timeout"]),
|
|
41
|
+
submittedAt: z.string(), // ISO timestamp
|
|
42
|
+
lastCheckedAt: z.string().optional(), // ISO timestamp
|
|
43
|
+
errorMessage: z.string().optional(),
|
|
44
|
+
});
|
|
45
|
+
export const PlatformStateSchema = z.object({
|
|
46
|
+
latestProcessedId: z.union([z.string(), z.number(), z.record(z.string(), z.any())]).optional(),
|
|
47
|
+
currentAsyncJob: AsyncJobProgressSchema.nullable().optional(),
|
|
48
|
+
}).catchall(z.any());
|
|
49
|
+
// Source-specific schema creators
|
|
50
|
+
export const createSourceInputSchema = (searchOptionsSchema, stateSchema) => z.object({
|
|
51
|
+
searchOptions: searchOptionsSchema,
|
|
52
|
+
lastProcessedState: z.object({
|
|
53
|
+
data: stateSchema.optional().nullable()
|
|
54
|
+
}).optional().nullable(),
|
|
55
|
+
});
|
|
56
|
+
export const createSourceOutputSchema = (itemData, stateSchema) => {
|
|
57
|
+
const pluginSourceItemSchema = z.object({
|
|
58
|
+
externalId: z.string(),
|
|
59
|
+
content: z.string(),
|
|
60
|
+
contentType: z.string().optional(),
|
|
61
|
+
createdAt: z.string().optional(),
|
|
62
|
+
url: z.string().optional(),
|
|
63
|
+
authors: z.array(authorSchema).optional(),
|
|
64
|
+
raw: itemData,
|
|
65
|
+
});
|
|
66
|
+
return z.object({
|
|
67
|
+
success: z.boolean(),
|
|
68
|
+
data: z.object({
|
|
69
|
+
items: z.array(pluginSourceItemSchema),
|
|
70
|
+
nextLastProcessedState: stateSchema.optional().nullable(),
|
|
71
|
+
}).optional(),
|
|
72
|
+
errors: z.array(ErrorDetailsSchema).optional(),
|
|
73
|
+
});
|
|
74
|
+
};
|