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.
Files changed (52) hide show
  1. package/README.md +320 -6
  2. package/dist/errors.d.ts +4 -4
  3. package/dist/errors.d.ts.map +1 -1
  4. package/dist/errors.js +10 -10
  5. package/dist/index.d.ts +4 -4
  6. package/dist/index.js +3 -3
  7. package/dist/plugin.d.ts +99 -54
  8. package/dist/plugin.d.ts.map +1 -1
  9. package/dist/plugin.js +18 -16
  10. package/dist/runtime/errors.d.ts +62 -0
  11. package/dist/runtime/errors.d.ts.map +1 -0
  12. package/dist/runtime/errors.js +9 -0
  13. package/dist/runtime/index.d.ts +73 -0
  14. package/dist/runtime/index.d.ts.map +1 -0
  15. package/dist/runtime/index.js +133 -0
  16. package/dist/runtime/mf.test.d.ts +2 -0
  17. package/dist/runtime/mf.test.d.ts.map +1 -0
  18. package/dist/runtime/mf.test.js +135 -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 +378 -0
  22. package/dist/runtime/services/module-federation.service.d.ts +44 -0
  23. package/dist/runtime/services/module-federation.service.d.ts.map +1 -0
  24. package/dist/runtime/services/module-federation.service.js +131 -0
  25. package/dist/runtime/services/plugin.service.d.ts +75 -0
  26. package/dist/runtime/services/plugin.service.d.ts.map +1 -0
  27. package/dist/runtime/services/plugin.service.js +338 -0
  28. package/dist/runtime/services/secrets.service.d.ts +37 -0
  29. package/dist/runtime/services/secrets.service.d.ts.map +1 -0
  30. package/dist/runtime/services/secrets.service.js +36 -0
  31. package/dist/runtime/services.d.ts +4 -0
  32. package/dist/runtime/services.d.ts.map +1 -0
  33. package/dist/runtime/services.js +3 -0
  34. package/dist/runtime/streaming.d.ts +29 -0
  35. package/dist/runtime/streaming.d.ts.map +1 -0
  36. package/dist/runtime/streaming.js +59 -0
  37. package/dist/runtime/streaming.test.d.ts +2 -0
  38. package/dist/runtime/streaming.test.d.ts.map +1 -0
  39. package/dist/runtime/streaming.test.js +271 -0
  40. package/dist/runtime/test-utils.d.ts +3 -0
  41. package/dist/runtime/test-utils.d.ts.map +1 -0
  42. package/dist/runtime/test-utils.js +13 -0
  43. package/dist/runtime/types.d.ts +40 -0
  44. package/dist/runtime/types.d.ts.map +1 -0
  45. package/dist/runtime/types.js +1 -0
  46. package/dist/runtime/validation.d.ts +10 -0
  47. package/dist/runtime/validation.d.ts.map +1 -0
  48. package/dist/runtime/validation.js +16 -0
  49. package/dist/source.d.ts +63 -191
  50. package/dist/source.d.ts.map +1 -1
  51. package/dist/source.js +33 -70
  52. package/package.json +44 -22
package/dist/source.js CHANGED
@@ -1,74 +1,37 @@
1
- import { z } from 'zod';
2
- import { ErrorDetailsSchema } from './plugin';
1
+ import { z } from "zod";
3
2
  /**
4
- * Zod schema for the Author interface
3
+ * Source-specific schema creators for contract-based plugins
5
4
  */
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
- });
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
- * Zod schema for PluginSourceItem - defines the structure that plugins must return
27
+ * Contract-based output schema creator that infers from oRPC contract
14
28
  */
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
- };
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
- "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.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
  }