@pikku/inspector 0.11.0 → 0.11.2
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/CHANGELOG.md +32 -2
- package/dist/add/add-channel.js +11 -10
- package/dist/add/add-file-with-factory.js +10 -10
- package/dist/add/add-forge-credential.d.ts +8 -0
- package/dist/add/add-forge-credential.js +77 -0
- package/dist/add/add-forge-node.d.ts +7 -0
- package/dist/add/add-forge-node.js +77 -0
- package/dist/add/add-functions.js +158 -51
- package/dist/add/add-http-route.js +28 -4
- package/dist/add/add-mcp-prompt.js +6 -5
- package/dist/add/add-mcp-resource.js +6 -5
- package/dist/add/add-mcp-tool.js +6 -5
- package/dist/add/add-middleware.js +1 -1
- package/dist/add/add-permission.js +1 -1
- package/dist/add/add-queue-worker.js +6 -5
- package/dist/add/add-rpc-invocations.d.ts +3 -0
- package/dist/add/add-rpc-invocations.js +51 -25
- package/dist/add/add-schedule.js +5 -4
- package/dist/add/add-workflow-graph.d.ts +6 -0
- package/dist/add/add-workflow-graph.js +659 -0
- package/dist/add/add-workflow.d.ts +1 -1
- package/dist/add/add-workflow.js +191 -69
- package/dist/error-codes.d.ts +3 -0
- package/dist/error-codes.js +3 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.js +3 -0
- package/dist/inspector.js +29 -9
- package/dist/types.d.ts +47 -8
- package/dist/utils/extract-function-name.js +7 -7
- package/dist/utils/extract-function-node.d.ts +10 -0
- package/dist/utils/extract-function-node.js +38 -0
- package/dist/utils/extract-node-value.d.ts +8 -0
- package/dist/utils/extract-node-value.js +24 -0
- package/dist/utils/extract-service-metadata.d.ts +19 -0
- package/dist/utils/extract-service-metadata.js +244 -0
- package/dist/utils/get-files-and-methods.d.ts +3 -3
- package/dist/utils/get-files-and-methods.js +3 -3
- package/dist/utils/get-property-value.d.ts +14 -6
- package/dist/utils/get-property-value.js +55 -43
- package/dist/utils/post-process.d.ts +9 -0
- package/dist/utils/post-process.js +30 -3
- package/dist/utils/serialize-inspector-state.d.ts +42 -6
- package/dist/utils/serialize-inspector-state.js +36 -10
- package/dist/utils/workflow/dsl/deserialize-dsl-workflow.d.ts +24 -0
- package/dist/utils/workflow/dsl/deserialize-dsl-workflow.js +898 -0
- package/dist/utils/workflow/dsl/extract-dsl-workflow.d.ts +17 -0
- package/dist/utils/workflow/dsl/extract-dsl-workflow.js +1284 -0
- package/dist/utils/workflow/dsl/index.d.ts +7 -0
- package/dist/utils/workflow/dsl/index.js +7 -0
- package/dist/utils/workflow/dsl/patterns.d.ts +60 -0
- package/dist/utils/workflow/dsl/patterns.js +218 -0
- package/dist/utils/workflow/dsl/validation.d.ts +30 -0
- package/dist/utils/workflow/dsl/validation.js +142 -0
- package/dist/utils/workflow/graph/convert-dsl-to-graph.d.ts +13 -0
- package/dist/utils/workflow/graph/convert-dsl-to-graph.js +316 -0
- package/dist/utils/workflow/graph/index.d.ts +6 -0
- package/dist/utils/workflow/graph/index.js +6 -0
- package/dist/utils/workflow/graph/serialize-workflow-graph.d.ts +43 -0
- package/dist/utils/workflow/graph/serialize-workflow-graph.js +152 -0
- package/dist/utils/workflow/graph/workflow-graph.types.d.ts +229 -0
- package/dist/utils/workflow/graph/workflow-graph.types.js +38 -0
- package/dist/utils/write-service-metadata.d.ts +13 -0
- package/dist/utils/write-service-metadata.js +37 -0
- package/dist/visit.js +8 -2
- package/package.json +16 -4
- package/src/add/add-channel.ts +37 -17
- package/src/add/add-file-with-factory.ts +10 -10
- package/src/add/add-forge-credential.ts +119 -0
- package/src/add/add-forge-node.ts +132 -0
- package/src/add/add-functions.ts +199 -69
- package/src/add/add-http-route.ts +34 -5
- package/src/add/add-mcp-prompt.ts +11 -7
- package/src/add/add-mcp-resource.ts +11 -7
- package/src/add/add-mcp-tool.ts +11 -7
- package/src/add/add-middleware.ts +1 -1
- package/src/add/add-permission.ts +1 -1
- package/src/add/add-queue-worker.ts +11 -12
- package/src/add/add-rpc-invocations.ts +61 -31
- package/src/add/add-schedule.ts +10 -5
- package/src/add/add-workflow-graph.ts +864 -0
- package/src/add/add-workflow.ts +212 -116
- package/src/error-codes.ts +3 -0
- package/src/index.ts +12 -0
- package/src/inspector.ts +36 -10
- package/src/types.ts +43 -9
- package/src/utils/extract-function-name.ts +7 -7
- package/src/utils/extract-function-node.ts +58 -0
- package/src/utils/extract-node-value.ts +31 -0
- package/src/utils/extract-service-metadata.ts +353 -0
- package/src/utils/filter-inspector-state.test.ts +3 -3
- package/src/utils/filter-utils.test.ts +45 -51
- package/src/utils/get-files-and-methods.ts +11 -11
- package/src/utils/get-property-value.ts +67 -53
- package/src/utils/permissions.test.ts +3 -3
- package/src/utils/post-process.ts +56 -3
- package/src/utils/serialize-inspector-state.ts +67 -19
- package/src/utils/test-data/inspector-state.json +9 -9
- package/src/utils/workflow/dsl/deserialize-dsl-workflow.ts +1180 -0
- package/src/utils/workflow/dsl/extract-dsl-workflow.ts +1608 -0
- package/src/utils/workflow/dsl/index.ts +11 -0
- package/src/utils/workflow/dsl/patterns.ts +279 -0
- package/src/utils/workflow/dsl/validation.ts +180 -0
- package/src/utils/workflow/graph/convert-dsl-to-graph.ts +415 -0
- package/src/utils/workflow/graph/index.ts +6 -0
- package/src/utils/workflow/graph/serialize-workflow-graph.ts +223 -0
- package/src/utils/workflow/graph/workflow-graph.types.ts +280 -0
- package/src/utils/write-service-metadata.ts +51 -0
- package/src/visit.ts +9 -3
- package/tsconfig.tsbuildinfo +1 -1
|
@@ -0,0 +1,229 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Serialized types for workflow graphs
|
|
3
|
+
* These are extracted by the inspector and stored as JSON
|
|
4
|
+
* Can be created from code (wireWorkflow) or UI
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Reference to data from another node or trigger
|
|
8
|
+
*/
|
|
9
|
+
export interface DataRef {
|
|
10
|
+
/** Source: 'trigger' for trigger input, or node ID for node output */
|
|
11
|
+
$ref: string;
|
|
12
|
+
/** Optional path into the data (dot notation: 'body.orderId') */
|
|
13
|
+
path?: string;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Check if value is a DataRef
|
|
17
|
+
*/
|
|
18
|
+
export declare const isDataRef: (value: unknown) => value is DataRef;
|
|
19
|
+
/**
|
|
20
|
+
* Reference to a context/state variable
|
|
21
|
+
*/
|
|
22
|
+
export interface StateRef {
|
|
23
|
+
/** Context variable name */
|
|
24
|
+
$state: string;
|
|
25
|
+
/** Optional path into the value (dot notation for nested objects) */
|
|
26
|
+
path?: string;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Check if value is a StateRef
|
|
30
|
+
*/
|
|
31
|
+
export declare const isStateRef: (value: unknown) => value is StateRef;
|
|
32
|
+
/**
|
|
33
|
+
* Helper functions for building input mappings
|
|
34
|
+
*/
|
|
35
|
+
export declare const ref: (nodeId: string, path?: string) => DataRef;
|
|
36
|
+
export declare const state: (name: string, path?: string) => StateRef;
|
|
37
|
+
/**
|
|
38
|
+
* Condition for branching
|
|
39
|
+
*/
|
|
40
|
+
export interface BranchCondition {
|
|
41
|
+
/** Expression to evaluate (uses node output references) */
|
|
42
|
+
expression: string;
|
|
43
|
+
/** Target node(s) if condition is true */
|
|
44
|
+
target: string | string[];
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Next node configuration
|
|
48
|
+
*/
|
|
49
|
+
export type SerializedNext = string | string[] | {
|
|
50
|
+
/** Conditions evaluated in order, first match wins */
|
|
51
|
+
conditions: BranchCondition[];
|
|
52
|
+
/** Default target if no conditions match */
|
|
53
|
+
default?: string | string[];
|
|
54
|
+
};
|
|
55
|
+
/**
|
|
56
|
+
* Node execution options
|
|
57
|
+
*/
|
|
58
|
+
export interface NodeOptions {
|
|
59
|
+
/** Number of retry attempts on failure */
|
|
60
|
+
retries?: number;
|
|
61
|
+
/** Delay between retries (e.g., '1s', '5s') */
|
|
62
|
+
retryDelay?: string;
|
|
63
|
+
/** Timeout for node execution (e.g., '30s', '5m') */
|
|
64
|
+
timeout?: string;
|
|
65
|
+
/** If true, execute via queue (async). Default: false (inline) */
|
|
66
|
+
async?: boolean;
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Flow node types for control flow (no RPC call)
|
|
70
|
+
*/
|
|
71
|
+
export type FlowType = 'sleep' | 'branch' | 'parallel' | 'fanout' | 'inline' | 'switch' | 'filter' | 'arrayPredicate' | 'return' | 'cancel' | 'set';
|
|
72
|
+
import type { ContextVariable, WorkflowContext } from '@pikku/core/workflow';
|
|
73
|
+
export type { ContextVariable, WorkflowContext };
|
|
74
|
+
/**
|
|
75
|
+
* Base node properties shared by all node types
|
|
76
|
+
*/
|
|
77
|
+
interface BaseNode {
|
|
78
|
+
/** Node ID */
|
|
79
|
+
nodeId: string;
|
|
80
|
+
/** Step name/description */
|
|
81
|
+
stepName?: string;
|
|
82
|
+
/** Next node(s) - simple, parallel, or conditional */
|
|
83
|
+
next?: SerializedNext;
|
|
84
|
+
/** Error routing - node(s) to execute on error */
|
|
85
|
+
onError?: string | string[];
|
|
86
|
+
/** Execution options */
|
|
87
|
+
options?: NodeOptions;
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Function node - calls an RPC
|
|
91
|
+
*/
|
|
92
|
+
export interface FunctionNode extends BaseNode {
|
|
93
|
+
/** RPC function name */
|
|
94
|
+
rpcName: string;
|
|
95
|
+
/** Input mapping - values can be literals or DataRefs */
|
|
96
|
+
input?: Record<string, unknown | DataRef>;
|
|
97
|
+
/** Output variable name for storing result */
|
|
98
|
+
outputVar?: string;
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Flow node - control flow only, no RPC call
|
|
102
|
+
*/
|
|
103
|
+
export interface FlowNode extends BaseNode {
|
|
104
|
+
/** Flow type */
|
|
105
|
+
flow: FlowType;
|
|
106
|
+
/** Flow-specific properties */
|
|
107
|
+
[key: string]: unknown;
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* Serialized graph node - either a function node or flow node
|
|
111
|
+
*/
|
|
112
|
+
export type SerializedGraphNode = FunctionNode | FlowNode;
|
|
113
|
+
/**
|
|
114
|
+
* Type guard for function nodes
|
|
115
|
+
*/
|
|
116
|
+
export declare const isFunctionNode: (node: SerializedGraphNode) => node is FunctionNode;
|
|
117
|
+
/**
|
|
118
|
+
* Type guard for flow nodes
|
|
119
|
+
*/
|
|
120
|
+
export declare const isFlowNode: (node: SerializedGraphNode) => node is FlowNode;
|
|
121
|
+
/**
|
|
122
|
+
* HTTP wire configuration with startNode
|
|
123
|
+
*/
|
|
124
|
+
export interface HttpWire {
|
|
125
|
+
route: string;
|
|
126
|
+
method: 'get' | 'post' | 'put' | 'patch' | 'delete';
|
|
127
|
+
startNode: string;
|
|
128
|
+
}
|
|
129
|
+
/**
|
|
130
|
+
* Channel wire configuration
|
|
131
|
+
*/
|
|
132
|
+
export interface ChannelWire {
|
|
133
|
+
name: string;
|
|
134
|
+
onConnect?: string;
|
|
135
|
+
onDisconnect?: string;
|
|
136
|
+
onMessage?: string;
|
|
137
|
+
}
|
|
138
|
+
/**
|
|
139
|
+
* Queue wire configuration
|
|
140
|
+
*/
|
|
141
|
+
export interface QueueWire {
|
|
142
|
+
name: string;
|
|
143
|
+
startNode: string;
|
|
144
|
+
}
|
|
145
|
+
/**
|
|
146
|
+
* CLI wire configuration
|
|
147
|
+
*/
|
|
148
|
+
export interface CliWire {
|
|
149
|
+
command: string;
|
|
150
|
+
startNode: string;
|
|
151
|
+
}
|
|
152
|
+
/**
|
|
153
|
+
* MCP wire configurations
|
|
154
|
+
*/
|
|
155
|
+
export interface McpWires {
|
|
156
|
+
tool?: Array<{
|
|
157
|
+
name: string;
|
|
158
|
+
startNode: string;
|
|
159
|
+
}>;
|
|
160
|
+
prompt?: Array<{
|
|
161
|
+
name: string;
|
|
162
|
+
startNode: string;
|
|
163
|
+
}>;
|
|
164
|
+
resource?: Array<{
|
|
165
|
+
uri: string;
|
|
166
|
+
startNode: string;
|
|
167
|
+
}>;
|
|
168
|
+
}
|
|
169
|
+
/**
|
|
170
|
+
* Schedule wire configuration
|
|
171
|
+
*/
|
|
172
|
+
export interface ScheduleWire {
|
|
173
|
+
cron?: string;
|
|
174
|
+
interval?: string;
|
|
175
|
+
startNode: string;
|
|
176
|
+
}
|
|
177
|
+
/**
|
|
178
|
+
* Trigger wire configuration
|
|
179
|
+
*/
|
|
180
|
+
export interface TriggerWire {
|
|
181
|
+
name: string;
|
|
182
|
+
startNode: string;
|
|
183
|
+
}
|
|
184
|
+
/**
|
|
185
|
+
* All wire configurations for workflows
|
|
186
|
+
*/
|
|
187
|
+
export interface WorkflowWiresConfig {
|
|
188
|
+
http?: HttpWire[];
|
|
189
|
+
channel?: ChannelWire[];
|
|
190
|
+
queue?: QueueWire[];
|
|
191
|
+
cli?: CliWire[];
|
|
192
|
+
mcp?: McpWires;
|
|
193
|
+
schedule?: ScheduleWire[];
|
|
194
|
+
trigger?: TriggerWire[];
|
|
195
|
+
}
|
|
196
|
+
/**
|
|
197
|
+
* Workflow source type
|
|
198
|
+
* - 'dsl': Pure DSL workflow (pikkuWorkflowFunc) - can be round-tripped to code
|
|
199
|
+
* - 'complex': Complex workflow (pikkuWorkflowComplexFunc) - contains inline steps, not serializable
|
|
200
|
+
* - 'graph': Graph-based workflow (pikkuWorkflowGraph)
|
|
201
|
+
*/
|
|
202
|
+
export type WorkflowSourceType = 'dsl' | 'complex' | 'graph';
|
|
203
|
+
/**
|
|
204
|
+
* Serialized workflow graph - the canonical JSON format
|
|
205
|
+
*/
|
|
206
|
+
export interface SerializedWorkflowGraph {
|
|
207
|
+
/** Workflow name */
|
|
208
|
+
name: string;
|
|
209
|
+
/** Pikku function name (for runtime registration) */
|
|
210
|
+
pikkuFuncName: string;
|
|
211
|
+
/** Source type: 'dsl' for pikkuWorkflowFunc, 'graph' for pikkuWorkflowGraph */
|
|
212
|
+
source: WorkflowSourceType;
|
|
213
|
+
/** Optional description */
|
|
214
|
+
description?: string;
|
|
215
|
+
/** Tags for organization */
|
|
216
|
+
tags?: string[];
|
|
217
|
+
/** Workflow context/state variables (from Zod schema) */
|
|
218
|
+
context?: WorkflowContext;
|
|
219
|
+
/** Wires - how the workflow is triggered */
|
|
220
|
+
wires: WorkflowWiresConfig;
|
|
221
|
+
/** Serialized nodes */
|
|
222
|
+
nodes: Record<string, SerializedGraphNode>;
|
|
223
|
+
/** Entry node(s) - first nodes to execute */
|
|
224
|
+
entryNodeIds: string[];
|
|
225
|
+
}
|
|
226
|
+
/**
|
|
227
|
+
* All workflow graphs (serialized)
|
|
228
|
+
*/
|
|
229
|
+
export type SerializedWorkflowGraphs = Record<string, SerializedWorkflowGraph>;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Serialized types for workflow graphs
|
|
3
|
+
* These are extracted by the inspector and stored as JSON
|
|
4
|
+
* Can be created from code (wireWorkflow) or UI
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Check if value is a DataRef
|
|
8
|
+
*/
|
|
9
|
+
export const isDataRef = (value) => typeof value === 'object' &&
|
|
10
|
+
value !== null &&
|
|
11
|
+
'$ref' in value &&
|
|
12
|
+
typeof value.$ref === 'string';
|
|
13
|
+
/**
|
|
14
|
+
* Check if value is a StateRef
|
|
15
|
+
*/
|
|
16
|
+
export const isStateRef = (value) => typeof value === 'object' &&
|
|
17
|
+
value !== null &&
|
|
18
|
+
'$state' in value &&
|
|
19
|
+
typeof value.$state === 'string';
|
|
20
|
+
/**
|
|
21
|
+
* Helper functions for building input mappings
|
|
22
|
+
*/
|
|
23
|
+
export const ref = (nodeId, path) => ({
|
|
24
|
+
$ref: nodeId,
|
|
25
|
+
path,
|
|
26
|
+
});
|
|
27
|
+
export const state = (name, path) => ({
|
|
28
|
+
$state: name,
|
|
29
|
+
path,
|
|
30
|
+
});
|
|
31
|
+
/**
|
|
32
|
+
* Type guard for function nodes
|
|
33
|
+
*/
|
|
34
|
+
export const isFunctionNode = (node) => 'rpcName' in node;
|
|
35
|
+
/**
|
|
36
|
+
* Type guard for flow nodes
|
|
37
|
+
*/
|
|
38
|
+
export const isFlowNode = (node) => 'flow' in node;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { ServiceMetadata } from './extract-service-metadata.js';
|
|
2
|
+
/**
|
|
3
|
+
* Write service metadata to a JSON file in .pikku/services directory
|
|
4
|
+
*/
|
|
5
|
+
export declare function writeServiceMetadata(serviceMeta: ServiceMetadata, outDir: string): void;
|
|
6
|
+
/**
|
|
7
|
+
* Write all service metadata files
|
|
8
|
+
*/
|
|
9
|
+
export declare function writeAllServiceMetadata(servicesMetadata: ServiceMetadata[], outDir: string): void;
|
|
10
|
+
/**
|
|
11
|
+
* Clean up services directory (remove old service JSON files)
|
|
12
|
+
*/
|
|
13
|
+
export declare function cleanServicesDirectory(outDir: string): void;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import * as fs from 'fs';
|
|
2
|
+
import * as path from 'path';
|
|
3
|
+
/**
|
|
4
|
+
* Write service metadata to a JSON file in .pikku/services directory
|
|
5
|
+
*/
|
|
6
|
+
export function writeServiceMetadata(serviceMeta, outDir) {
|
|
7
|
+
const servicesDir = path.join(outDir, 'services');
|
|
8
|
+
if (!fs.existsSync(servicesDir)) {
|
|
9
|
+
fs.mkdirSync(servicesDir, { recursive: true });
|
|
10
|
+
}
|
|
11
|
+
const fileName = `${serviceMeta.name}.gen.json`;
|
|
12
|
+
const filePath = path.join(servicesDir, fileName);
|
|
13
|
+
const jsonContent = JSON.stringify(serviceMeta, null, 2);
|
|
14
|
+
fs.writeFileSync(filePath, jsonContent, 'utf-8');
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Write all service metadata files
|
|
18
|
+
*/
|
|
19
|
+
export function writeAllServiceMetadata(servicesMetadata, outDir) {
|
|
20
|
+
for (const serviceMeta of servicesMetadata) {
|
|
21
|
+
writeServiceMetadata(serviceMeta, outDir);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Clean up services directory (remove old service JSON files)
|
|
26
|
+
*/
|
|
27
|
+
export function cleanServicesDirectory(outDir) {
|
|
28
|
+
const servicesDir = path.join(outDir, 'services');
|
|
29
|
+
if (fs.existsSync(servicesDir)) {
|
|
30
|
+
const files = fs.readdirSync(servicesDir);
|
|
31
|
+
for (const file of files) {
|
|
32
|
+
if (file.endsWith('.gen.json')) {
|
|
33
|
+
fs.unlinkSync(path.join(servicesDir, file));
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
}
|
package/dist/visit.js
CHANGED
|
@@ -14,13 +14,16 @@ import { addRPCInvocations } from './add/add-rpc-invocations.js';
|
|
|
14
14
|
import { addMiddleware } from './add/add-middleware.js';
|
|
15
15
|
import { addPermission } from './add/add-permission.js';
|
|
16
16
|
import { addCLI, addCLIRenderers } from './add/add-cli.js';
|
|
17
|
+
import { addForgeNode } from './add/add-forge-node.js';
|
|
18
|
+
import { addForgeCredential } from './add/add-forge-credential.js';
|
|
19
|
+
import { addWorkflowGraph } from './add/add-workflow-graph.js';
|
|
17
20
|
export const visitSetup = (logger, checker, node, state, options) => {
|
|
18
21
|
addFileExtendsCoreType(node, checker, state.singletonServicesTypeImportMap, 'CoreSingletonServices', state);
|
|
19
|
-
addFileExtendsCoreType(node, checker, state.
|
|
22
|
+
addFileExtendsCoreType(node, checker, state.wireServicesTypeImportMap, 'CoreServices', state);
|
|
20
23
|
addFileExtendsCoreType(node, checker, state.userSessionTypeImportMap, 'CoreUserSession', state);
|
|
21
24
|
addFileExtendsCoreType(node, checker, state.configTypeImportMap, 'CoreConfig', state);
|
|
22
25
|
addFileWithFactory(node, checker, state.singletonServicesFactories, 'CreateSingletonServices');
|
|
23
|
-
addFileWithFactory(node, checker, state.
|
|
26
|
+
addFileWithFactory(node, checker, state.wireServicesFactories, 'CreateWireServices', state);
|
|
24
27
|
addFileWithFactory(node, checker, state.configFactories, 'CreateConfig');
|
|
25
28
|
addRPCInvocations(node, state, logger);
|
|
26
29
|
addMiddleware(logger, node, checker, state, options);
|
|
@@ -39,5 +42,8 @@ export const visitRoutes = (logger, checker, node, state, options) => {
|
|
|
39
42
|
addMCPResource(logger, node, checker, state, options);
|
|
40
43
|
addMCPTool(logger, node, checker, state, options);
|
|
41
44
|
addMCPPrompt(logger, node, checker, state, options);
|
|
45
|
+
addForgeNode(logger, node, checker, state, options);
|
|
46
|
+
addForgeCredential(logger, node, checker, state, options);
|
|
47
|
+
addWorkflowGraph(logger, node, checker, state, options);
|
|
42
48
|
ts.forEachChild(node, (child) => visitRoutes(logger, checker, child, state, options));
|
|
43
49
|
};
|
package/package.json
CHANGED
|
@@ -1,11 +1,23 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pikku/inspector",
|
|
3
|
-
"version": "0.11.
|
|
3
|
+
"version": "0.11.2",
|
|
4
4
|
"author": "yasser.fadl@gmail.com",
|
|
5
|
-
"license": "
|
|
5
|
+
"license": "BUSL-1.1",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"module": "dist/index.js",
|
|
8
8
|
"main": "dist/index.js",
|
|
9
|
+
"exports": {
|
|
10
|
+
".": {
|
|
11
|
+
"types": "./dist/index.d.ts",
|
|
12
|
+
"import": "./dist/index.js",
|
|
13
|
+
"default": "./dist/index.js"
|
|
14
|
+
},
|
|
15
|
+
"./workflow-graph": {
|
|
16
|
+
"types": "./dist/utils/workflow/graph/index.d.ts",
|
|
17
|
+
"import": "./dist/utils/workflow/graph/index.js",
|
|
18
|
+
"default": "./dist/utils/workflow/graph/index.js"
|
|
19
|
+
}
|
|
20
|
+
},
|
|
9
21
|
"scripts": {
|
|
10
22
|
"tsc": "tsc",
|
|
11
23
|
"build": "tsc -b",
|
|
@@ -16,12 +28,12 @@
|
|
|
16
28
|
"test:coverage": "bash run-tests.sh --coverage"
|
|
17
29
|
},
|
|
18
30
|
"dependencies": {
|
|
19
|
-
"@pikku/core": "^0.11.
|
|
31
|
+
"@pikku/core": "^0.11.2",
|
|
20
32
|
"path-to-regexp": "^8.3.0",
|
|
21
33
|
"typescript": "^5.9"
|
|
22
34
|
},
|
|
23
35
|
"devDependencies": {
|
|
24
|
-
"@types/node": "^24.
|
|
36
|
+
"@types/node": "^24.10.1"
|
|
25
37
|
},
|
|
26
38
|
"engines": {
|
|
27
39
|
"node": ">=18"
|
package/src/add/add-channel.ts
CHANGED
|
@@ -2,10 +2,9 @@ import * as ts from 'typescript'
|
|
|
2
2
|
import { ErrorCode } from '../error-codes.js'
|
|
3
3
|
import {
|
|
4
4
|
getPropertyValue,
|
|
5
|
-
|
|
5
|
+
getCommonWireMetaData,
|
|
6
6
|
} from '../utils/get-property-value.js'
|
|
7
7
|
import { pathToRegexp } from 'path-to-regexp'
|
|
8
|
-
import { PikkuDocs } from '@pikku/core'
|
|
9
8
|
import { extractFunctionName } from '../utils/extract-function-name.js'
|
|
10
9
|
import { getPropertyAssignmentInitializer } from '../utils/type-utils.js'
|
|
11
10
|
import type { ChannelMessageMeta, ChannelMeta } from '@pikku/core/channel'
|
|
@@ -206,7 +205,12 @@ export function addMessagesRoutes(
|
|
|
206
205
|
if (fnMeta) {
|
|
207
206
|
// Resolve middleware for this route
|
|
208
207
|
const routeTags = ts.isObjectLiteralExpression(init)
|
|
209
|
-
?
|
|
208
|
+
? getCommonWireMetaData(
|
|
209
|
+
init,
|
|
210
|
+
'Channel message',
|
|
211
|
+
routeKey,
|
|
212
|
+
logger
|
|
213
|
+
).tags
|
|
210
214
|
: undefined
|
|
211
215
|
const routeMiddleware = ts.isObjectLiteralExpression(init)
|
|
212
216
|
? resolveMiddleware(state, init, routeTags, checker)
|
|
@@ -233,7 +237,12 @@ export function addMessagesRoutes(
|
|
|
233
237
|
if (fnMeta) {
|
|
234
238
|
// Resolve middleware for this route
|
|
235
239
|
const routeTags = ts.isObjectLiteralExpression(init)
|
|
236
|
-
?
|
|
240
|
+
? getCommonWireMetaData(
|
|
241
|
+
init,
|
|
242
|
+
'Channel message',
|
|
243
|
+
routeKey,
|
|
244
|
+
logger
|
|
245
|
+
).tags
|
|
237
246
|
: undefined
|
|
238
247
|
const routeMiddleware = ts.isObjectLiteralExpression(init)
|
|
239
248
|
? resolveMiddleware(state, init, routeTags, checker)
|
|
@@ -277,12 +286,12 @@ export function addMessagesRoutes(
|
|
|
277
286
|
if (fnMeta) {
|
|
278
287
|
// Resolve middleware for this route
|
|
279
288
|
const routeTags = ts.isObjectLiteralExpression(init)
|
|
280
|
-
?
|
|
289
|
+
? getCommonWireMetaData(
|
|
281
290
|
init,
|
|
282
|
-
'
|
|
283
|
-
|
|
291
|
+
'Channel message',
|
|
292
|
+
routeKey,
|
|
284
293
|
logger
|
|
285
|
-
)
|
|
294
|
+
).tags
|
|
286
295
|
: undefined
|
|
287
296
|
const routeMiddleware = ts.isObjectLiteralExpression(
|
|
288
297
|
init
|
|
@@ -308,12 +317,12 @@ export function addMessagesRoutes(
|
|
|
308
317
|
if (fnMeta) {
|
|
309
318
|
// Resolve middleware for this route
|
|
310
319
|
const routeTags = ts.isObjectLiteralExpression(init)
|
|
311
|
-
?
|
|
320
|
+
? getCommonWireMetaData(
|
|
312
321
|
init,
|
|
313
|
-
'
|
|
314
|
-
|
|
322
|
+
'Channel message',
|
|
323
|
+
routeKey,
|
|
315
324
|
logger
|
|
316
|
-
)
|
|
325
|
+
).tags
|
|
317
326
|
: undefined
|
|
318
327
|
const routeMiddleware = ts.isObjectLiteralExpression(
|
|
319
328
|
init
|
|
@@ -396,7 +405,12 @@ export function addMessagesRoutes(
|
|
|
396
405
|
if (fnMeta) {
|
|
397
406
|
// Resolve middleware for this route
|
|
398
407
|
const routeTags = ts.isObjectLiteralExpression(init)
|
|
399
|
-
?
|
|
408
|
+
? getCommonWireMetaData(
|
|
409
|
+
init,
|
|
410
|
+
'Channel message',
|
|
411
|
+
routeKey,
|
|
412
|
+
logger
|
|
413
|
+
).tags
|
|
400
414
|
: undefined
|
|
401
415
|
const routeMiddleware = ts.isObjectLiteralExpression(init)
|
|
402
416
|
? resolveMiddleware(state, init, routeTags, checker)
|
|
@@ -438,7 +452,7 @@ export function addMessagesRoutes(
|
|
|
438
452
|
// Resolve middleware and permissions for this route
|
|
439
453
|
// Check if the route config is an object literal with middleware/permissions
|
|
440
454
|
const routeTags = ts.isObjectLiteralExpression(init)
|
|
441
|
-
?
|
|
455
|
+
? getCommonWireMetaData(init, 'Channel message', routeKey, logger).tags
|
|
442
456
|
: undefined
|
|
443
457
|
const routeMiddleware = ts.isObjectLiteralExpression(init)
|
|
444
458
|
? resolveMiddleware(state, init, routeTags, checker)
|
|
@@ -487,8 +501,12 @@ export const addChannel: AddWiring = (
|
|
|
487
501
|
.map((k) => k.name)
|
|
488
502
|
: []
|
|
489
503
|
|
|
490
|
-
const
|
|
491
|
-
|
|
504
|
+
const { tags, summary, description, errors } = getCommonWireMetaData(
|
|
505
|
+
obj,
|
|
506
|
+
'Channel',
|
|
507
|
+
name,
|
|
508
|
+
logger
|
|
509
|
+
)
|
|
492
510
|
const query = getPropertyValue(obj, 'query') as string[] | []
|
|
493
511
|
|
|
494
512
|
const connect = getPropertyAssignmentInitializer(
|
|
@@ -602,7 +620,9 @@ export const addChannel: AddWiring = (
|
|
|
602
620
|
: null,
|
|
603
621
|
message,
|
|
604
622
|
messageWirings,
|
|
605
|
-
|
|
623
|
+
summary,
|
|
624
|
+
description,
|
|
625
|
+
errors,
|
|
606
626
|
tags: tags ?? undefined,
|
|
607
627
|
middleware,
|
|
608
628
|
}
|
|
@@ -6,7 +6,7 @@ import { extractServicesFromFunction } from '../utils/extract-services.js'
|
|
|
6
6
|
const wrapperFunctionMap: Record<string, string> = {
|
|
7
7
|
pikkuConfig: 'CreateConfig',
|
|
8
8
|
pikkuServices: 'CreateSingletonServices',
|
|
9
|
-
|
|
9
|
+
pikkuWireServices: 'CreateWireServices',
|
|
10
10
|
}
|
|
11
11
|
|
|
12
12
|
export const addFileWithFactory = (
|
|
@@ -54,9 +54,9 @@ export const addFileWithFactory = (
|
|
|
54
54
|
})
|
|
55
55
|
methods.set(fileName, variables)
|
|
56
56
|
|
|
57
|
-
// Extract singleton services for
|
|
57
|
+
// Extract singleton services for CreateWireServices factories
|
|
58
58
|
if (
|
|
59
|
-
expectedTypeName === '
|
|
59
|
+
expectedTypeName === 'CreateWireServices' &&
|
|
60
60
|
state &&
|
|
61
61
|
callExpression.arguments.length > 0
|
|
62
62
|
) {
|
|
@@ -74,7 +74,7 @@ export const addFileWithFactory = (
|
|
|
74
74
|
|
|
75
75
|
if (functionNode) {
|
|
76
76
|
const servicesMeta = extractServicesFromFunction(functionNode)
|
|
77
|
-
state.
|
|
77
|
+
state.wireServicesMeta.set(variableName, servicesMeta.services)
|
|
78
78
|
}
|
|
79
79
|
}
|
|
80
80
|
|
|
@@ -109,9 +109,9 @@ export const addFileWithFactory = (
|
|
|
109
109
|
})
|
|
110
110
|
methods.set(fileName, variables)
|
|
111
111
|
|
|
112
|
-
// Extract singleton services for
|
|
112
|
+
// Extract singleton services for CreateWireServices factories
|
|
113
113
|
if (
|
|
114
|
-
expectedTypeName === '
|
|
114
|
+
expectedTypeName === 'CreateWireServices' &&
|
|
115
115
|
state &&
|
|
116
116
|
node.initializer
|
|
117
117
|
) {
|
|
@@ -124,7 +124,7 @@ export const addFileWithFactory = (
|
|
|
124
124
|
|
|
125
125
|
if (functionNode) {
|
|
126
126
|
const servicesMeta = extractServicesFromFunction(functionNode)
|
|
127
|
-
state.
|
|
127
|
+
state.wireServicesMeta.set(variableName, servicesMeta.services)
|
|
128
128
|
}
|
|
129
129
|
}
|
|
130
130
|
}
|
|
@@ -149,9 +149,9 @@ export const addFileWithFactory = (
|
|
|
149
149
|
})
|
|
150
150
|
methods.set(fileName, variables)
|
|
151
151
|
|
|
152
|
-
// Extract singleton services for
|
|
152
|
+
// Extract singleton services for CreateWireServices factories
|
|
153
153
|
if (
|
|
154
|
-
expectedTypeName === '
|
|
154
|
+
expectedTypeName === 'CreateWireServices' &&
|
|
155
155
|
state &&
|
|
156
156
|
node.initializer
|
|
157
157
|
) {
|
|
@@ -167,7 +167,7 @@ export const addFileWithFactory = (
|
|
|
167
167
|
|
|
168
168
|
if (functionNode) {
|
|
169
169
|
const servicesMeta = extractServicesFromFunction(functionNode)
|
|
170
|
-
state.
|
|
170
|
+
state.wireServicesMeta.set(variableName, servicesMeta.services)
|
|
171
171
|
}
|
|
172
172
|
}
|
|
173
173
|
}
|