every-plugin 0.0.5 → 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.
- package/README.md +320 -6
- package/dist/errors.d.ts +4 -4
- package/dist/errors.d.ts.map +1 -1
- package/dist/errors.js +10 -10
- package/dist/index.d.ts +4 -4
- package/dist/index.js +3 -3
- package/dist/plugin.d.ts +99 -54
- package/dist/plugin.d.ts.map +1 -1
- package/dist/plugin.js +18 -16
- package/dist/runtime/errors.d.ts +62 -0
- package/dist/runtime/errors.d.ts.map +1 -0
- package/dist/runtime/errors.js +9 -0
- package/dist/runtime/index.d.ts +73 -0
- package/dist/runtime/index.d.ts.map +1 -0
- package/dist/runtime/index.js +133 -0
- package/dist/runtime/mf.test.d.ts +2 -0
- package/dist/runtime/mf.test.d.ts.map +1 -0
- package/dist/runtime/mf.test.js +135 -0
- package/dist/runtime/runtime.test.d.ts +2 -0
- package/dist/runtime/runtime.test.d.ts.map +1 -0
- package/dist/runtime/runtime.test.js +378 -0
- package/dist/runtime/services/module-federation.service.d.ts +44 -0
- package/dist/runtime/services/module-federation.service.d.ts.map +1 -0
- package/dist/runtime/services/module-federation.service.js +131 -0
- package/dist/runtime/services/plugin.service.d.ts +75 -0
- package/dist/runtime/services/plugin.service.d.ts.map +1 -0
- package/dist/runtime/services/plugin.service.js +338 -0
- package/dist/runtime/services/secrets.service.d.ts +37 -0
- package/dist/runtime/services/secrets.service.d.ts.map +1 -0
- package/dist/runtime/services/secrets.service.js +36 -0
- package/dist/runtime/services.d.ts +4 -0
- package/dist/runtime/services.d.ts.map +1 -0
- package/dist/runtime/services.js +3 -0
- package/dist/runtime/streaming.d.ts +29 -0
- package/dist/runtime/streaming.d.ts.map +1 -0
- package/dist/runtime/streaming.js +59 -0
- package/dist/runtime/streaming.test.d.ts +2 -0
- package/dist/runtime/streaming.test.d.ts.map +1 -0
- package/dist/runtime/streaming.test.js +271 -0
- package/dist/runtime/test-utils.d.ts +3 -0
- package/dist/runtime/test-utils.d.ts.map +1 -0
- package/dist/runtime/test-utils.js +13 -0
- package/dist/runtime/types.d.ts +40 -0
- package/dist/runtime/types.d.ts.map +1 -0
- package/dist/runtime/types.js +1 -0
- package/dist/runtime/validation.d.ts +10 -0
- package/dist/runtime/validation.d.ts.map +1 -0
- package/dist/runtime/validation.js +16 -0
- package/dist/source.d.ts +63 -191
- package/dist/source.d.ts.map +1 -1
- package/dist/source.js +33 -70
- package/package.json +44 -22
package/dist/source.js
CHANGED
|
@@ -1,74 +1,37 @@
|
|
|
1
|
-
import { z } from
|
|
2
|
-
import { ErrorDetailsSchema } from './plugin';
|
|
1
|
+
import { z } from "zod";
|
|
3
2
|
/**
|
|
4
|
-
*
|
|
3
|
+
* Source-specific schema creators for contract-based plugins
|
|
5
4
|
*/
|
|
6
|
-
export
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
});
|
|
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
|
+
}
|
|
12
26
|
/**
|
|
13
|
-
*
|
|
27
|
+
* Contract-based output schema creator that infers from oRPC contract
|
|
14
28
|
*/
|
|
15
|
-
export
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
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
|
-
};
|
|
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
|
+
}
|
package/package.json
CHANGED
|
@@ -1,24 +1,46 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
2
|
+
"name": "every-plugin",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"main": "dist/index.js",
|
|
5
|
+
"types": "dist/index.d.ts",
|
|
6
|
+
"exports": {
|
|
7
|
+
".": {
|
|
8
|
+
"types": "./dist/index.d.ts",
|
|
9
|
+
"default": "./dist/index.js"
|
|
10
|
+
},
|
|
11
|
+
"./runtime": {
|
|
12
|
+
"types": "./dist/runtime/index.d.ts",
|
|
13
|
+
"default": "./dist/runtime/index.js"
|
|
14
|
+
}
|
|
15
|
+
},
|
|
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
|
+
"@orpc/server": ">=0.0.1"
|
|
29
|
+
},
|
|
30
|
+
"devDependencies": {
|
|
31
|
+
"@effect/vitest": "^0.25.1",
|
|
32
|
+
"@module-federation/enhanced": "^0.18.3",
|
|
33
|
+
"@module-federation/runtime-core": "^0.18.3",
|
|
34
|
+
"@types/bun": "^1.2.21",
|
|
35
|
+
"@vitest/ui": "3.2.4",
|
|
36
|
+
"bun-types": "^1.2.21",
|
|
37
|
+
"effect": "^3.17.7",
|
|
38
|
+
"typescript": "^5.0.0",
|
|
39
|
+
"vitest": "^3.2.4",
|
|
40
|
+
"zod": "^4.0.8"
|
|
41
|
+
},
|
|
42
|
+
"dependencies": {
|
|
43
|
+
"@better-fetch/fetch": "^1.1.18",
|
|
44
|
+
"@orpc/contract": "^1.8.6"
|
|
45
|
+
}
|
|
24
46
|
}
|