@jam-nodes/core 0.2.8 โ 0.2.10
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 +147 -0
- package/dist/types/node.d.ts +26 -0
- package/dist/types/node.d.ts.map +1 -1
- package/package.json +2 -1
package/README.md
ADDED
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
# jam-nodes
|
|
2
|
+
|
|
3
|
+
Extensible workflow node framework for building automation pipelines. Define, register, and execute typed nodes with Zod validation.
|
|
4
|
+
|
|
5
|
+
๐ **[Documentation](https://docs.spreadjam.com)** ยท ๐ฎ **[Playground](https://docs.spreadjam.com/playground/overview)**
|
|
6
|
+
|
|
7
|
+
## Packages
|
|
8
|
+
|
|
9
|
+
- **[@jam-nodes/core](./packages/core)** - Core framework with types, registry, and execution context
|
|
10
|
+
- **[@jam-nodes/nodes](./packages/nodes)** - Built-in nodes (conditional, delay, filter, map, http-request)
|
|
11
|
+
- **[@jam-nodes/playground](./packages/playground)** - CLI tool for testing nodes interactively
|
|
12
|
+
|
|
13
|
+
## Installation
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
npm install @jam-nodes/core @jam-nodes/nodes zod
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
## Quick Start
|
|
20
|
+
|
|
21
|
+
```typescript
|
|
22
|
+
import { NodeRegistry, defineNode, ExecutionContext } from "@jam-nodes/core";
|
|
23
|
+
import { conditionalNode, endNode, builtInNodes } from "@jam-nodes/nodes";
|
|
24
|
+
import { z } from "zod";
|
|
25
|
+
|
|
26
|
+
// Create a registry and register built-in nodes
|
|
27
|
+
const registry = new NodeRegistry();
|
|
28
|
+
registry.registerAll(builtInNodes);
|
|
29
|
+
|
|
30
|
+
// Define a custom node
|
|
31
|
+
const greetNode = defineNode({
|
|
32
|
+
type: "greet",
|
|
33
|
+
name: "Greet",
|
|
34
|
+
description: "Generate a greeting message",
|
|
35
|
+
category: "action",
|
|
36
|
+
inputSchema: z.object({
|
|
37
|
+
name: z.string(),
|
|
38
|
+
}),
|
|
39
|
+
outputSchema: z.object({
|
|
40
|
+
message: z.string(),
|
|
41
|
+
}),
|
|
42
|
+
executor: async (input) => ({
|
|
43
|
+
success: true,
|
|
44
|
+
output: { message: `Hello, ${input.name}!` },
|
|
45
|
+
}),
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
// Register custom node
|
|
49
|
+
registry.register(greetNode);
|
|
50
|
+
|
|
51
|
+
// Execute a node
|
|
52
|
+
const context = new ExecutionContext({ userName: "World" });
|
|
53
|
+
const executor = registry.getExecutor("greet");
|
|
54
|
+
const result = await executor(
|
|
55
|
+
{ name: context.interpolate("{{userName}}") },
|
|
56
|
+
context.toNodeContext("user-123", "workflow-456"),
|
|
57
|
+
);
|
|
58
|
+
|
|
59
|
+
console.log(result.output?.message); // "Hello, World!"
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
## Creating Custom Nodes
|
|
63
|
+
|
|
64
|
+
```typescript
|
|
65
|
+
import { defineNode } from "@jam-nodes/core";
|
|
66
|
+
import { z } from "zod";
|
|
67
|
+
|
|
68
|
+
export const myNode = defineNode({
|
|
69
|
+
type: "my_custom_node",
|
|
70
|
+
name: "My Custom Node",
|
|
71
|
+
description: "Does something awesome",
|
|
72
|
+
category: "action", // 'action' | 'logic' | 'integration' | 'transform'
|
|
73
|
+
|
|
74
|
+
inputSchema: z.object({
|
|
75
|
+
input1: z.string(),
|
|
76
|
+
input2: z.number().optional(),
|
|
77
|
+
}),
|
|
78
|
+
|
|
79
|
+
outputSchema: z.object({
|
|
80
|
+
result: z.string(),
|
|
81
|
+
}),
|
|
82
|
+
|
|
83
|
+
capabilities: {
|
|
84
|
+
supportsRerun: true,
|
|
85
|
+
supportsCancel: true,
|
|
86
|
+
},
|
|
87
|
+
|
|
88
|
+
executor: async (input, context) => {
|
|
89
|
+
// Access workflow variables
|
|
90
|
+
const previousData = context.resolveNestedPath("someNode.output");
|
|
91
|
+
|
|
92
|
+
// Your logic here
|
|
93
|
+
const result = `Processed: ${input.input1}`;
|
|
94
|
+
|
|
95
|
+
return {
|
|
96
|
+
success: true,
|
|
97
|
+
output: { result },
|
|
98
|
+
// Optional: send notification
|
|
99
|
+
notification: {
|
|
100
|
+
title: "Node Complete",
|
|
101
|
+
message: "Processing finished",
|
|
102
|
+
},
|
|
103
|
+
};
|
|
104
|
+
},
|
|
105
|
+
});
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
## Built-in Nodes
|
|
109
|
+
|
|
110
|
+
### Logic
|
|
111
|
+
|
|
112
|
+
- **conditional** - Branch workflow based on conditions
|
|
113
|
+
- **end** - Mark end of workflow branch
|
|
114
|
+
- **delay** - Wait for specified duration
|
|
115
|
+
|
|
116
|
+
### Transform
|
|
117
|
+
|
|
118
|
+
- **map** - Extract property from array items
|
|
119
|
+
- **filter** - Filter array based on conditions
|
|
120
|
+
|
|
121
|
+
### Examples
|
|
122
|
+
|
|
123
|
+
- **http_request** - Make HTTP requests to external APIs
|
|
124
|
+
|
|
125
|
+
## Variable Interpolation
|
|
126
|
+
|
|
127
|
+
The `ExecutionContext` supports powerful variable interpolation:
|
|
128
|
+
|
|
129
|
+
```typescript
|
|
130
|
+
const ctx = new ExecutionContext({
|
|
131
|
+
user: { name: "Alice", email: "alice@example.com" },
|
|
132
|
+
items: [1, 2, 3],
|
|
133
|
+
});
|
|
134
|
+
|
|
135
|
+
// Simple interpolation
|
|
136
|
+
ctx.interpolate("Hello {{user.name}}"); // "Hello Alice"
|
|
137
|
+
|
|
138
|
+
// Direct value (returns actual type)
|
|
139
|
+
ctx.interpolate("{{items}}"); // [1, 2, 3]
|
|
140
|
+
|
|
141
|
+
// JSONPath
|
|
142
|
+
ctx.evaluateJsonPath("$.user.email"); // "alice@example.com"
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
## License
|
|
146
|
+
|
|
147
|
+
MIT
|
package/dist/types/node.d.ts
CHANGED
|
@@ -15,10 +15,26 @@ export interface NodeCredentials {
|
|
|
15
15
|
};
|
|
16
16
|
/** Twitter/X API credentials */
|
|
17
17
|
twitter?: {
|
|
18
|
+
/** OAuth2 client ID for PKCE flow */
|
|
19
|
+
clientId?: string;
|
|
20
|
+
/** OAuth2 client secret for token exchange/refresh */
|
|
21
|
+
clientSecret?: string;
|
|
22
|
+
/** OAuth2 access token used for Twitter API v2 operations */
|
|
23
|
+
accessToken?: string;
|
|
24
|
+
/** OAuth2 refresh token */
|
|
25
|
+
refreshToken?: string;
|
|
26
|
+
/** Access token expiration timestamp (unix ms) */
|
|
27
|
+
expiresAt?: number;
|
|
18
28
|
/** Official Twitter API v2 Bearer Token */
|
|
19
29
|
bearerToken?: string;
|
|
20
30
|
/** TwitterAPI.io API key (third-party, simpler) */
|
|
21
31
|
twitterApiIoKey?: string;
|
|
32
|
+
/** OAuth 1.0a Consumer Key (API Key) */
|
|
33
|
+
consumerKey?: string;
|
|
34
|
+
/** OAuth 1.0a Consumer Secret (API Secret) */
|
|
35
|
+
consumerSecret?: string;
|
|
36
|
+
/** OAuth 1.0a Access Token Secret */
|
|
37
|
+
accessTokenSecret?: string;
|
|
22
38
|
};
|
|
23
39
|
/** ForumScout API credentials (for LinkedIn monitoring) */
|
|
24
40
|
forumScout?: {
|
|
@@ -45,6 +61,16 @@ export interface NodeCredentials {
|
|
|
45
61
|
discordWebhook?: {
|
|
46
62
|
webhookUrl: string;
|
|
47
63
|
};
|
|
64
|
+
/** Dev.to API credentials */
|
|
65
|
+
devto?: {
|
|
66
|
+
apiKey: string;
|
|
67
|
+
};
|
|
68
|
+
/** WordPress Application Password credentials */
|
|
69
|
+
wordpress?: {
|
|
70
|
+
siteUrl: string;
|
|
71
|
+
username: string;
|
|
72
|
+
applicationPassword: string;
|
|
73
|
+
};
|
|
48
74
|
}
|
|
49
75
|
/**
|
|
50
76
|
* Base execution context passed to all node executors.
|
package/dist/types/node.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"node.d.ts","sourceRoot":"","sources":["../../src/types/node.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,CAAC,EAAE,MAAM,KAAK,
|
|
1
|
+
{"version":3,"file":"node.d.ts","sourceRoot":"","sources":["../../src/types/node.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAC5B,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,eAAe,CAAA;AAEjD;;;GAGG;AACH,MAAM,WAAW,eAAe;IAC9B,gCAAgC;IAChC,MAAM,CAAC,EAAE;QACP,MAAM,EAAE,MAAM,CAAA;KACf,CAAA;IACD,iCAAiC;IACjC,SAAS,CAAC,EAAE;QACV,WAAW,CAAC,EAAE,MAAM,CAAA;KACrB,CAAA;IACD,gCAAgC;IAChC,OAAO,CAAC,EAAE;QACR,qCAAqC;QACrC,QAAQ,CAAC,EAAE,MAAM,CAAC;QAClB,sDAAsD;QACtD,YAAY,CAAC,EAAE,MAAM,CAAC;QACtB,6DAA6D;QAC7D,WAAW,CAAC,EAAE,MAAM,CAAC;QACrB,2BAA2B;QAC3B,YAAY,CAAC,EAAE,MAAM,CAAC;QACtB,kDAAkD;QAClD,SAAS,CAAC,EAAE,MAAM,CAAC;QACnB,2CAA2C;QAC3C,WAAW,CAAC,EAAE,MAAM,CAAA;QACpB,mDAAmD;QACnD,eAAe,CAAC,EAAE,MAAM,CAAA;QACxB,wCAAwC;QACxC,WAAW,CAAC,EAAE,MAAM,CAAA;QACpB,8CAA8C;QAC9C,cAAc,CAAC,EAAE,MAAM,CAAA;QACvB,qCAAqC;QACrC,iBAAiB,CAAC,EAAE,MAAM,CAAA;KAC3B,CAAA;IACD,2DAA2D;IAC3D,UAAU,CAAC,EAAE;QACX,MAAM,EAAE,MAAM,CAAA;KACf,CAAA;IACD,iCAAiC;IACjC,UAAU,CAAC,EAAE;QACX,oCAAoC;QACpC,QAAQ,EAAE,MAAM,CAAA;KACjB,CAAA;IACD,6BAA6B;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E,MAAM,CAAA;IACnB,4BAA4B;IAC5B,QAAQ,EAAE,YAAY,CAAA;IACtB,oCAAoC;IACpC,iBAAiB,CAAC,EAAE,MAAM,CAAA;IAC1B,wBAAwB;IACxB,YAAY,CAAC,EAAE,gBAAgB,CAAA;CAChC;AAED;;;;GAIG;AACH,MAAM,WAAW,cAAc,CAC7B,MAAM,GAAG,OAAO,EAChB,OAAO,GAAG,OAAO,CACjB,SAAQ,YAAY;IACpB,sCAAsC;IACtC,WAAW,EAAE,CAAC,CAAC,SAAS,CAAC,MAAM,CAAC,CAAA;IAChC,uCAAuC;IACvC,YAAY,EAAE,CAAC,CAAC,SAAS,CAAC,OAAO,CAAC,CAAA;IAClC,wBAAwB;IACxB,QAAQ,EAAE,YAAY,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;CACxC"}
|
package/package.json
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jam-nodes/core",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.10",
|
|
4
4
|
"description": "Core framework for building workflow nodes with type-safe executors and Zod validation",
|
|
5
5
|
"type": "module",
|
|
6
|
+
"sideEffects": false,
|
|
6
7
|
"main": "./dist/index.js",
|
|
7
8
|
"types": "./dist/index.d.ts",
|
|
8
9
|
"exports": {
|