@n8n-as-code/sync 0.12.0 → 0.14.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 +2 -0
- package/dist/assets/n8n-workflows.d.ts +320 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/services/sync-engine.d.ts +1 -1
- package/dist/services/sync-engine.d.ts.map +1 -1
- package/dist/services/sync-engine.js +51 -25
- package/dist/services/sync-engine.js.map +1 -1
- package/dist/services/sync-manager.d.ts.map +1 -1
- package/dist/services/sync-manager.js +18 -1
- package/dist/services/sync-manager.js.map +1 -1
- package/dist/services/watcher.d.ts +2 -1
- package/dist/services/watcher.d.ts.map +1 -1
- package/dist/services/watcher.js +160 -49
- package/dist/services/watcher.js.map +1 -1
- package/dist/services/workflow-transformer-adapter.d.ts +87 -0
- package/dist/services/workflow-transformer-adapter.d.ts.map +1 -0
- package/dist/services/workflow-transformer-adapter.js +234 -0
- package/dist/services/workflow-transformer-adapter.js.map +1 -0
- package/dist/services/workspace-setup-service.d.ts +36 -0
- package/dist/services/workspace-setup-service.d.ts.map +1 -0
- package/dist/services/workspace-setup-service.js +107 -0
- package/dist/services/workspace-setup-service.js.map +1 -0
- package/package.json +4 -2
package/README.md
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
# <img src="https://raw.githubusercontent.com/EtienneLescot/n8n-as-code/main/res/logo.png" alt="n8n-as-code logo" width="32" height="32"> @n8n-as-code/sync
|
|
2
2
|
|
|
3
|
+
> **⚠️ BREAKING CHANGE (v0.13.0)**: This package now handles workflows as **TypeScript files** (`.workflow.ts`) instead of JSON, using the `@n8n-as-code/transformer` package for bidirectional conversion.
|
|
4
|
+
|
|
3
5
|
The logical sync of the **n8n-as-code** ecosystem.
|
|
4
6
|
|
|
5
7
|
## 🛠 Purpose
|
|
@@ -0,0 +1,320 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* n8n-as-code Type Stubs
|
|
3
|
+
*
|
|
4
|
+
* Auto-generated by the n8n-as-code VS Code extension / CLI.
|
|
5
|
+
* DO NOT EDIT - this file is regenerated automatically.
|
|
6
|
+
*
|
|
7
|
+
* Provides TypeScript types for .workflow.ts files without requiring
|
|
8
|
+
* a local installation of @n8n-as-code/transformer.
|
|
9
|
+
*
|
|
10
|
+
* Mapped as the @n8n-as-code/transformer module via tsconfig "paths".
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
// =========================================================================
|
|
14
|
+
// GLOBAL AUGMENTATION
|
|
15
|
+
// Adds .out(), .in(), .uses(), .output to every object so that node
|
|
16
|
+
// properties (typed from their literal values) get full IntelliSense
|
|
17
|
+
// inside defineRouting() without explicit type casts.
|
|
18
|
+
// =========================================================================
|
|
19
|
+
export {};
|
|
20
|
+
|
|
21
|
+
declare global {
|
|
22
|
+
interface Object {
|
|
23
|
+
/** Regular output connector (index = output slot, default 0) */
|
|
24
|
+
out(index?: number): OutputConnection;
|
|
25
|
+
/** Regular input connector (index = input slot, default 0) */
|
|
26
|
+
in(index?: number): InputConnection;
|
|
27
|
+
/** Error output connector */
|
|
28
|
+
error(): OutputConnection;
|
|
29
|
+
/** Declare AI/LangChain sub-node dependencies */
|
|
30
|
+
uses(dependencies: AIDependencyMap): void;
|
|
31
|
+
/** Output reference used as target of .uses() values */
|
|
32
|
+
readonly output: any;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
// =========================================================================
|
|
37
|
+
// WORKFLOW SETTINGS
|
|
38
|
+
// =========================================================================
|
|
39
|
+
|
|
40
|
+
export interface WorkflowSettings {
|
|
41
|
+
executionOrder?: 'v0' | 'v1' | 'v2';
|
|
42
|
+
timeSavedMode?: 'fixed' | 'calculated';
|
|
43
|
+
errorWorkflow?: string;
|
|
44
|
+
timezone?: string;
|
|
45
|
+
saveManualExecutions?: boolean;
|
|
46
|
+
saveDataErrorExecution?: 'all' | 'none';
|
|
47
|
+
saveExecutionProgress?: boolean;
|
|
48
|
+
callerPolicy?: 'workflowsFromSameOwner' | 'any' | 'none';
|
|
49
|
+
availableInMCP?: boolean;
|
|
50
|
+
[key: string]: any;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
// =========================================================================
|
|
54
|
+
// DECORATOR METADATA
|
|
55
|
+
// =========================================================================
|
|
56
|
+
|
|
57
|
+
export interface WorkflowDecoratorOptions {
|
|
58
|
+
/** Workflow ID (assigned by n8n) */
|
|
59
|
+
id: string;
|
|
60
|
+
/** Human-readable name */
|
|
61
|
+
name: string;
|
|
62
|
+
/** Whether the workflow is active */
|
|
63
|
+
active: boolean;
|
|
64
|
+
/** Workflow execution settings */
|
|
65
|
+
settings?: WorkflowSettings;
|
|
66
|
+
/** Project ID for organization */
|
|
67
|
+
projectId?: string;
|
|
68
|
+
/** Project name */
|
|
69
|
+
projectName?: string;
|
|
70
|
+
/** Whether the workflow is archived */
|
|
71
|
+
isArchived?: boolean;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
export interface NodeDecoratorOptions {
|
|
75
|
+
/** Display name shown in n8n UI */
|
|
76
|
+
name: string;
|
|
77
|
+
/** Node type identifier (e.g. "n8n-nodes-base.httpRequest") */
|
|
78
|
+
type: string;
|
|
79
|
+
/** Node version */
|
|
80
|
+
version: number;
|
|
81
|
+
/** Position [x, y] on the canvas */
|
|
82
|
+
position?: [number, number];
|
|
83
|
+
/** Credential references */
|
|
84
|
+
credentials?: Record<string, { id: string; name: string }>;
|
|
85
|
+
/** Error handling mode */
|
|
86
|
+
onError?: 'continueErrorOutput' | 'continueRegularOutput' | 'stopWorkflow';
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
// =========================================================================
|
|
90
|
+
// AI / LANGCHAIN DEPENDENCY MAP (.uses())
|
|
91
|
+
// =========================================================================
|
|
92
|
+
|
|
93
|
+
export interface AIDependencyMap {
|
|
94
|
+
ai_languageModel?: any;
|
|
95
|
+
ai_memory?: any;
|
|
96
|
+
ai_outputParser?: any;
|
|
97
|
+
ai_tool?: any[];
|
|
98
|
+
ai_agent?: any;
|
|
99
|
+
ai_chain?: any;
|
|
100
|
+
ai_document?: any[];
|
|
101
|
+
ai_textSplitter?: any;
|
|
102
|
+
ai_embedding?: any;
|
|
103
|
+
ai_retriever?: any;
|
|
104
|
+
ai_reranker?: any;
|
|
105
|
+
ai_vectorStore?: any;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
// =========================================================================
|
|
109
|
+
// FLUENT CONNECTION API
|
|
110
|
+
// =========================================================================
|
|
111
|
+
|
|
112
|
+
export interface InputConnection {
|
|
113
|
+
readonly _to: { node: string; input: number };
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
export interface OutputConnection {
|
|
117
|
+
readonly _from: { node: string; output: number; isError?: boolean };
|
|
118
|
+
to(input: InputConnection): void;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
// =========================================================================
|
|
122
|
+
// DECORATORS
|
|
123
|
+
// =========================================================================
|
|
124
|
+
|
|
125
|
+
/**
|
|
126
|
+
* Marks a class as an n8n workflow.
|
|
127
|
+
*
|
|
128
|
+
* @example
|
|
129
|
+
* ```ts
|
|
130
|
+
* @workflow({ id: 'abc123', name: 'My Workflow', active: false })
|
|
131
|
+
* export class MyWorkflow { ... }
|
|
132
|
+
* ```
|
|
133
|
+
*/
|
|
134
|
+
export declare function workflow(options: WorkflowDecoratorOptions): ClassDecorator;
|
|
135
|
+
|
|
136
|
+
/**
|
|
137
|
+
* Marks a class property as an n8n node.
|
|
138
|
+
* The property value is used as node parameters.
|
|
139
|
+
*
|
|
140
|
+
* @example
|
|
141
|
+
* ```ts
|
|
142
|
+
* @node({ name: 'HTTP Request', type: 'n8n-nodes-base.httpRequest', version: 4.2, position: [300, 200] })
|
|
143
|
+
* MyHttp = { url: 'https://api.example.com' };
|
|
144
|
+
* ```
|
|
145
|
+
*/
|
|
146
|
+
export declare function node(options: NodeDecoratorOptions): PropertyDecorator;
|
|
147
|
+
|
|
148
|
+
/**
|
|
149
|
+
* Marks a method as the routing/connections definition.
|
|
150
|
+
*
|
|
151
|
+
* @example
|
|
152
|
+
* ```ts
|
|
153
|
+
* @links()
|
|
154
|
+
* defineRouting() {
|
|
155
|
+
* this.Trigger.out(0).to(this.Agent.in(0));
|
|
156
|
+
* this.Agent.uses({ ai_languageModel: this.Model.output });
|
|
157
|
+
* }
|
|
158
|
+
* ```
|
|
159
|
+
*/
|
|
160
|
+
export declare function links(): MethodDecorator;
|
|
161
|
+
|
|
162
|
+
|
|
163
|
+
// =========================================================================
|
|
164
|
+
// WORKFLOW SETTINGS
|
|
165
|
+
// =========================================================================
|
|
166
|
+
|
|
167
|
+
export interface WorkflowSettings {
|
|
168
|
+
executionOrder?: 'v0' | 'v1' | 'v2';
|
|
169
|
+
timeSavedMode?: 'fixed' | 'calculated';
|
|
170
|
+
errorWorkflow?: string;
|
|
171
|
+
timezone?: string;
|
|
172
|
+
saveManualExecutions?: boolean;
|
|
173
|
+
saveDataErrorExecution?: 'all' | 'none';
|
|
174
|
+
saveExecutionProgress?: boolean;
|
|
175
|
+
callerPolicy?: 'workflowsFromSameOwner' | 'any' | 'none';
|
|
176
|
+
availableInMCP?: boolean;
|
|
177
|
+
[key: string]: any;
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
// =========================================================================
|
|
181
|
+
// DECORATOR METADATA
|
|
182
|
+
// =========================================================================
|
|
183
|
+
|
|
184
|
+
export interface WorkflowDecoratorOptions {
|
|
185
|
+
/** Workflow ID (assigned by n8n) */
|
|
186
|
+
id: string;
|
|
187
|
+
/** Human-readable name */
|
|
188
|
+
name: string;
|
|
189
|
+
/** Whether the workflow is active */
|
|
190
|
+
active: boolean;
|
|
191
|
+
/** Workflow execution settings */
|
|
192
|
+
settings?: WorkflowSettings;
|
|
193
|
+
/** Project ID for organization */
|
|
194
|
+
projectId?: string;
|
|
195
|
+
/** Project name */
|
|
196
|
+
projectName?: string;
|
|
197
|
+
/** Whether the workflow is archived */
|
|
198
|
+
isArchived?: boolean;
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
export interface NodeDecoratorOptions {
|
|
202
|
+
/** Display name shown in n8n UI */
|
|
203
|
+
name: string;
|
|
204
|
+
/** Node type identifier (e.g. "n8n-nodes-base.httpRequest") */
|
|
205
|
+
type: string;
|
|
206
|
+
/** Node version */
|
|
207
|
+
version: number;
|
|
208
|
+
/** Position [x, y] on the canvas */
|
|
209
|
+
position?: [number, number];
|
|
210
|
+
/** Credential references */
|
|
211
|
+
credentials?: Record<string, { id: string; name: string }>;
|
|
212
|
+
/** Error handling mode */
|
|
213
|
+
onError?: 'continueErrorOutput' | 'continueRegularOutput' | 'stopWorkflow';
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
// =========================================================================
|
|
217
|
+
// AI / LANGCHAIN DEPENDENCY MAP (.uses())
|
|
218
|
+
// =========================================================================
|
|
219
|
+
|
|
220
|
+
/** Proxy object with an `.output` accessor (returned by AI/LangChain nodes) */
|
|
221
|
+
export interface NodeOutput {
|
|
222
|
+
readonly output: NodeOutput;
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
export interface AIDependencyMap {
|
|
226
|
+
/** Language model (e.g. OpenAI, Anthropic) */
|
|
227
|
+
ai_languageModel?: NodeOutput;
|
|
228
|
+
/** Conversation memory */
|
|
229
|
+
ai_memory?: NodeOutput;
|
|
230
|
+
/** Structured output parser */
|
|
231
|
+
ai_outputParser?: NodeOutput;
|
|
232
|
+
/** Tool nodes (can be multiple) */
|
|
233
|
+
ai_tool?: NodeOutput[];
|
|
234
|
+
/** Sub-agent */
|
|
235
|
+
ai_agent?: NodeOutput;
|
|
236
|
+
/** LangChain chain */
|
|
237
|
+
ai_chain?: NodeOutput;
|
|
238
|
+
/** Document loaders (can be multiple) */
|
|
239
|
+
ai_document?: NodeOutput[];
|
|
240
|
+
/** Text splitter */
|
|
241
|
+
ai_textSplitter?: NodeOutput;
|
|
242
|
+
/** Embedding model */
|
|
243
|
+
ai_embedding?: NodeOutput;
|
|
244
|
+
/** Vector store retriever */
|
|
245
|
+
ai_retriever?: NodeOutput;
|
|
246
|
+
/** Result reranker */
|
|
247
|
+
ai_reranker?: NodeOutput;
|
|
248
|
+
/** Vector store */
|
|
249
|
+
ai_vectorStore?: NodeOutput;
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
// =========================================================================
|
|
253
|
+
// FLUENT CONNECTION API (.out().to(), .uses())
|
|
254
|
+
// =========================================================================
|
|
255
|
+
|
|
256
|
+
export interface InputConnection {
|
|
257
|
+
readonly _to: { node: string; input: number };
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
export interface OutputConnection {
|
|
261
|
+
readonly _from: { node: string; output: number; isError?: boolean };
|
|
262
|
+
/** Connect this output to a node input */
|
|
263
|
+
to(input: InputConnection): void;
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
/** Proxy wrapping each class property in defineRouting() */
|
|
267
|
+
export interface NodeProxy extends NodeOutput {
|
|
268
|
+
/** Regular output connector (index = output index, default 0) */
|
|
269
|
+
out(index?: number): OutputConnection;
|
|
270
|
+
/** Regular input connector (index = input index, default 0) */
|
|
271
|
+
in(index?: number): InputConnection;
|
|
272
|
+
/** Error output connector */
|
|
273
|
+
error(): OutputConnection;
|
|
274
|
+
/** Declare AI/LangChain sub-node dependencies */
|
|
275
|
+
uses(dependencies: AIDependencyMap): void;
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
// =========================================================================
|
|
279
|
+
// DECORATORS
|
|
280
|
+
// =========================================================================
|
|
281
|
+
|
|
282
|
+
/**
|
|
283
|
+
* Marks a class as an n8n workflow.
|
|
284
|
+
*
|
|
285
|
+
* @example
|
|
286
|
+
* ```ts
|
|
287
|
+
* @workflow({ id: 'abc123', name: 'My Workflow', active: false })
|
|
288
|
+
* export class MyWorkflow { ... }
|
|
289
|
+
* ```
|
|
290
|
+
*/
|
|
291
|
+
export function workflow(options: WorkflowDecoratorOptions): ClassDecorator;
|
|
292
|
+
|
|
293
|
+
/**
|
|
294
|
+
* Marks a class property as an n8n node.
|
|
295
|
+
* The property value is used as node parameters.
|
|
296
|
+
*
|
|
297
|
+
* @example
|
|
298
|
+
* ```ts
|
|
299
|
+
* @node({ name: 'HTTP Request', type: 'n8n-nodes-base.httpRequest', version: 4.2, position: [300, 200] })
|
|
300
|
+
* MyHttp = { url: 'https://api.example.com' };
|
|
301
|
+
* ```
|
|
302
|
+
*/
|
|
303
|
+
export function node(options: NodeDecoratorOptions): PropertyDecorator;
|
|
304
|
+
|
|
305
|
+
/**
|
|
306
|
+
* Marks a method as the routing/connections definition.
|
|
307
|
+
* Inside this method, use `.out().to()` for regular connections
|
|
308
|
+
* and `.uses()` for AI/LangChain sub-node connections.
|
|
309
|
+
*
|
|
310
|
+
* @example
|
|
311
|
+
* ```ts
|
|
312
|
+
* @links()
|
|
313
|
+
* defineRouting() {
|
|
314
|
+
* this.Trigger.out(0).to(this.Agent.in(0));
|
|
315
|
+
* this.Agent.uses({ ai_languageModel: this.Model.output });
|
|
316
|
+
* }
|
|
317
|
+
* ```
|
|
318
|
+
*/
|
|
319
|
+
export function links(): MethodDecorator;
|
|
320
|
+
}
|
package/dist/index.d.ts
CHANGED
|
@@ -7,5 +7,6 @@ export * from './services/watcher.js';
|
|
|
7
7
|
export * from './services/resolution-manager.js';
|
|
8
8
|
export * from './services/state-manager.js';
|
|
9
9
|
export * from './services/directory-utils.js';
|
|
10
|
+
export * from './services/workspace-setup-service.js';
|
|
10
11
|
export * from './helpers/index.js';
|
|
11
12
|
//# 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,cAAc,YAAY,CAAC;AAC3B,cAAc,8BAA8B,CAAC;AAC7C,cAAc,kCAAkC,CAAC;AACjD,cAAc,4BAA4B,CAAC;AAC3C,cAAc,2BAA2B,CAAC;AAC1C,cAAc,uBAAuB,CAAC;AACtC,cAAc,kCAAkC,CAAC;AACjD,cAAc,6BAA6B,CAAC;AAC5C,cAAc,+BAA+B,CAAC;AAC9C,cAAc,oBAAoB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,cAAc,8BAA8B,CAAC;AAC7C,cAAc,kCAAkC,CAAC;AACjD,cAAc,4BAA4B,CAAC;AAC3C,cAAc,2BAA2B,CAAC;AAC1C,cAAc,uBAAuB,CAAC;AACtC,cAAc,kCAAkC,CAAC;AACjD,cAAc,6BAA6B,CAAC;AAC5C,cAAc,+BAA+B,CAAC;AAC9C,cAAc,uCAAuC,CAAC;AACtD,cAAc,oBAAoB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -7,5 +7,6 @@ export * from './services/watcher.js';
|
|
|
7
7
|
export * from './services/resolution-manager.js';
|
|
8
8
|
export * from './services/state-manager.js';
|
|
9
9
|
export * from './services/directory-utils.js';
|
|
10
|
+
export * from './services/workspace-setup-service.js';
|
|
10
11
|
export * from './helpers/index.js';
|
|
11
12
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,cAAc,8BAA8B,CAAC;AAC7C,cAAc,kCAAkC,CAAC;AACjD,cAAc,4BAA4B,CAAC;AAC3C,cAAc,2BAA2B,CAAC;AAC1C,cAAc,uBAAuB,CAAC;AACtC,cAAc,kCAAkC,CAAC;AACjD,cAAc,6BAA6B,CAAC;AAC5C,cAAc,+BAA+B,CAAC;AAC9C,cAAc,oBAAoB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"A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OAGG;IACU,YAAY,CAAC,UAAU,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAkB9E;;;;OAIG;IACU,kBAAkB,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;YAyBrD,WAAW;YA6BX,aAAa;YA0Cb,aAAa;IAwCd,OAAO,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAQrD,OAAO,CAAC,kBAAkB;CAO7B"}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import fs from 'fs';
|
|
2
2
|
import path from 'path';
|
|
3
|
-
import {
|
|
4
|
-
import { HashUtils } from './hash-utils.js';
|
|
3
|
+
import { WorkflowTransformerAdapter } from './workflow-transformer-adapter.js';
|
|
5
4
|
import { WorkflowSyncStatus } from '../types.js';
|
|
6
5
|
/**
|
|
7
6
|
* Sync Engine - State Mutation Component
|
|
@@ -244,53 +243,80 @@ export class SyncEngine {
|
|
|
244
243
|
}
|
|
245
244
|
throw new Error(`Remote workflow ${workflowId} not found during pull`);
|
|
246
245
|
}
|
|
247
|
-
|
|
246
|
+
// Convert to TypeScript
|
|
247
|
+
const tsCode = await WorkflowTransformerAdapter.convertToTypeScript(fullWf, {
|
|
248
|
+
format: true,
|
|
249
|
+
commentStyle: 'verbose'
|
|
250
|
+
});
|
|
248
251
|
const filePath = path.join(this.directory, filename);
|
|
249
|
-
fs.writeFileSync(filePath,
|
|
252
|
+
fs.writeFileSync(filePath, tsCode, 'utf-8');
|
|
250
253
|
// Update Watcher's remote hash cache since we just fetched the workflow
|
|
251
254
|
// This ensures finalizeSync has the remote hash
|
|
252
|
-
const hash =
|
|
255
|
+
const hash = await WorkflowTransformerAdapter.hashWorkflow(tsCode);
|
|
253
256
|
this.watcher.setRemoteHash(workflowId, hash);
|
|
254
257
|
}
|
|
255
258
|
async executeUpdate(workflowId, filename) {
|
|
256
259
|
const filePath = path.join(this.directory, filename);
|
|
257
|
-
const
|
|
258
|
-
if (!
|
|
260
|
+
const tsContent = this.readTypeScriptFile(filePath);
|
|
261
|
+
if (!tsContent) {
|
|
259
262
|
throw new Error('Local file not found during push');
|
|
260
263
|
}
|
|
261
|
-
|
|
262
|
-
const
|
|
264
|
+
// Compile TypeScript to JSON for API
|
|
265
|
+
const localWf = await WorkflowTransformerAdapter.compileToJson(tsContent);
|
|
266
|
+
// Guard against empty compile result caused by parse errors (e.g. non-ASCII
|
|
267
|
+
// characters like → in the class name cause ts-morph to silently drop the
|
|
268
|
+
// class body, resulting in a 0-node workflow that would wipe the remote).
|
|
269
|
+
if (!localWf.nodes || localWf.nodes.length === 0) {
|
|
270
|
+
throw new Error(`Refusing to push "${filename}": the compiled workflow has 0 nodes. ` +
|
|
271
|
+
`This usually means the TypeScript class name contains an invalid character ` +
|
|
272
|
+
`(e.g. → U+2192 is not a valid identifier). ` +
|
|
273
|
+
`Rename the class to a plain ASCII identifier and try again.`);
|
|
274
|
+
}
|
|
275
|
+
const updatedWf = await this.client.updateWorkflow(workflowId, localWf);
|
|
263
276
|
if (!updatedWf) {
|
|
264
277
|
throw new Error('Failed to update remote workflow');
|
|
265
278
|
}
|
|
266
279
|
// CRITICAL: Write the API response back to local file to ensure consistency
|
|
267
280
|
// This ensures local and remote have identical content after push
|
|
268
|
-
//
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
281
|
+
// Convert the updated workflow back to TypeScript
|
|
282
|
+
const tsCode = await WorkflowTransformerAdapter.convertToTypeScript(updatedWf, {
|
|
283
|
+
format: true,
|
|
284
|
+
commentStyle: 'verbose'
|
|
285
|
+
});
|
|
286
|
+
fs.writeFileSync(filePath, tsCode, 'utf-8');
|
|
272
287
|
// Update Watcher's remote hash cache with the updated workflow
|
|
273
|
-
const hash =
|
|
288
|
+
const hash = await WorkflowTransformerAdapter.hashWorkflow(tsCode);
|
|
274
289
|
this.watcher.setRemoteHash(workflowId, hash);
|
|
275
290
|
}
|
|
276
291
|
async executeCreate(filename) {
|
|
277
292
|
const filePath = path.join(this.directory, filename);
|
|
278
|
-
const
|
|
279
|
-
if (!
|
|
293
|
+
const tsContent = this.readTypeScriptFile(filePath);
|
|
294
|
+
if (!tsContent) {
|
|
280
295
|
throw new Error('Local file not found during creation');
|
|
281
296
|
}
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
297
|
+
// Compile TypeScript to JSON for API
|
|
298
|
+
const localWf = await WorkflowTransformerAdapter.compileToJson(tsContent);
|
|
299
|
+
// Guard: refuse to create a workflow with 0 nodes (parse error protection)
|
|
300
|
+
if (!localWf.nodes || localWf.nodes.length === 0) {
|
|
301
|
+
throw new Error(`Refusing to create "${filename}": the compiled workflow has 0 nodes. ` +
|
|
302
|
+
`This usually means the TypeScript class name contains an invalid character ` +
|
|
303
|
+
`(e.g. → U+2192 is not a valid identifier). ` +
|
|
304
|
+
`Rename the class to a plain ASCII identifier and try again.`);
|
|
305
|
+
}
|
|
306
|
+
if (!localWf.name) {
|
|
307
|
+
localWf.name = path.parse(filename).name.replace('.workflow', '');
|
|
285
308
|
}
|
|
286
|
-
const newWf = await this.client.createWorkflow(
|
|
309
|
+
const newWf = await this.client.createWorkflow(localWf);
|
|
287
310
|
if (!newWf || !newWf.id) {
|
|
288
311
|
throw new Error('Failed to create remote workflow');
|
|
289
312
|
}
|
|
290
313
|
// Update local file with new ID and clean metadata
|
|
291
|
-
//
|
|
292
|
-
const
|
|
293
|
-
|
|
314
|
+
// Convert the new workflow back to TypeScript
|
|
315
|
+
const tsCode = await WorkflowTransformerAdapter.convertToTypeScript(newWf, {
|
|
316
|
+
format: true,
|
|
317
|
+
commentStyle: 'verbose'
|
|
318
|
+
});
|
|
319
|
+
fs.writeFileSync(filePath, tsCode, 'utf-8');
|
|
294
320
|
return newWf.id;
|
|
295
321
|
}
|
|
296
322
|
async archive(filename) {
|
|
@@ -300,9 +326,9 @@ export class SyncEngine {
|
|
|
300
326
|
fs.renameSync(filePath, archivePath);
|
|
301
327
|
}
|
|
302
328
|
}
|
|
303
|
-
|
|
329
|
+
readTypeScriptFile(filePath) {
|
|
304
330
|
try {
|
|
305
|
-
return
|
|
331
|
+
return fs.readFileSync(filePath, 'utf8');
|
|
306
332
|
}
|
|
307
333
|
catch {
|
|
308
334
|
return null;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sync-engine.js","sourceRoot":"","sources":["../../src/services/sync-engine.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"sync-engine.js","sourceRoot":"","sources":["../../src/services/sync-engine.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,OAAO,EAAE,0BAA0B,EAAE,MAAM,mCAAmC,CAAC;AAG/E,OAAO,EAAE,kBAAkB,EAAa,MAAM,aAAa,CAAC;AAE5D;;;;;;;;;GASG;AACH,MAAM,OAAO,UAAU;IACX,MAAM,CAAe;IACrB,OAAO,CAAU;IACjB,SAAS,CAAS;IAClB,cAAc,CAAS;IAE/B,YACI,MAAoB,EACpB,OAAgB,EAChB,SAAiB;QAEjB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;QAC3B,IAAI,CAAC,cAAc,GAAG,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,QAAQ,CAAC,CAAC;QAErD,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,IAAI,CAAC,cAAc,CAAC,EAAE,CAAC;YACtC,EAAE,CAAC,SAAS,CAAC,IAAI,CAAC,cAAc,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;QAC3D,CAAC;IACL,CAAC;IAED;;;OAGG;IACI,KAA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CAAC,OAAO,CAAC;IAgBpE,eAAe,CAAC,EAAE,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAa5D,qBAAqB,CAAC,EAAE,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;CAI7E"}
|
|
@@ -7,6 +7,7 @@ import { SyncEngine } from './sync-engine.js';
|
|
|
7
7
|
import { ResolutionManager } from './resolution-manager.js';
|
|
8
8
|
import { WorkflowSyncStatus } from '../types.js';
|
|
9
9
|
import { createProjectSlug } from './directory-utils.js';
|
|
10
|
+
import { WorkspaceSetupService } from './workspace-setup-service.js';
|
|
10
11
|
export class SyncManager extends EventEmitter {
|
|
11
12
|
client;
|
|
12
13
|
config;
|
|
@@ -31,6 +32,14 @@ export class SyncManager extends EventEmitter {
|
|
|
31
32
|
if (!fs.existsSync(instanceDir)) {
|
|
32
33
|
fs.mkdirSync(instanceDir, { recursive: true });
|
|
33
34
|
}
|
|
35
|
+
// Write TypeScript support files (.d.ts + tsconfig.json) so .workflow.ts
|
|
36
|
+
// files have no red errors without requiring a local npm install.
|
|
37
|
+
try {
|
|
38
|
+
WorkspaceSetupService.ensureWorkspaceFiles(instanceDir);
|
|
39
|
+
}
|
|
40
|
+
catch (err) {
|
|
41
|
+
console.warn('[SyncManager] Could not write workspace TypeScript stubs:', err.message);
|
|
42
|
+
}
|
|
34
43
|
this.stateManager = new StateManager(instanceDir);
|
|
35
44
|
this.watcher = new Watcher(this.client, {
|
|
36
45
|
directory: instanceDir,
|
|
@@ -42,6 +51,7 @@ export class SyncManager extends EventEmitter {
|
|
|
42
51
|
this.syncEngine = new SyncEngine(this.client, this.watcher, instanceDir);
|
|
43
52
|
this.resolutionManager = new ResolutionManager(this.syncEngine, this.watcher, this.client);
|
|
44
53
|
this.watcher.on('statusChange', (data) => {
|
|
54
|
+
console.log(`[SyncManager] 📨 Received statusChange event:`, data);
|
|
45
55
|
this.emit('change', data);
|
|
46
56
|
// Emit specific events for deletions and conflicts
|
|
47
57
|
if (data.status === WorkflowSyncStatus.DELETED_LOCALLY && data.workflowId) {
|
|
@@ -64,11 +74,15 @@ export class SyncManager extends EventEmitter {
|
|
|
64
74
|
}
|
|
65
75
|
// Auto-sync in auto mode
|
|
66
76
|
if (this.config.syncMode === 'auto') {
|
|
77
|
+
console.log(`[SyncManager] Auto mode enabled, calling handleAutoSync...`);
|
|
67
78
|
this.handleAutoSync(data).catch(err => {
|
|
68
79
|
console.error('[SyncManager] Auto-sync error:', err);
|
|
69
80
|
this.emit('error', `Auto-sync failed: ${err.message}`);
|
|
70
81
|
});
|
|
71
82
|
}
|
|
83
|
+
else {
|
|
84
|
+
console.log(`[SyncManager] Manual mode, skipping auto-sync`);
|
|
85
|
+
}
|
|
72
86
|
});
|
|
73
87
|
this.watcher.on('error', (err) => {
|
|
74
88
|
this.emit('error', err);
|
|
@@ -80,7 +94,7 @@ export class SyncManager extends EventEmitter {
|
|
|
80
94
|
async getWorkflowsStatus() {
|
|
81
95
|
await this.ensureInitialized();
|
|
82
96
|
// Return status from watcher
|
|
83
|
-
return this.watcher.getStatusMatrix();
|
|
97
|
+
return await this.watcher.getStatusMatrix();
|
|
84
98
|
}
|
|
85
99
|
/**
|
|
86
100
|
* Get full workflows with organization metadata for display purposes.
|
|
@@ -148,14 +162,17 @@ export class SyncManager extends EventEmitter {
|
|
|
148
162
|
*/
|
|
149
163
|
async handleAutoSync(data) {
|
|
150
164
|
const { filename, workflowId, status } = data;
|
|
165
|
+
console.log(`[SyncManager] 🤖 handleAutoSync called for ${filename}, status: ${status}`);
|
|
151
166
|
try {
|
|
152
167
|
switch (status) {
|
|
153
168
|
case WorkflowSyncStatus.MODIFIED_LOCALLY:
|
|
154
169
|
case WorkflowSyncStatus.EXIST_ONLY_LOCALLY:
|
|
155
170
|
// Auto-push local changes
|
|
156
171
|
this.emit('log', `🔄 Auto-sync: Pushing "${filename}"...`);
|
|
172
|
+
console.log(`[SyncManager] Pushing ${filename}...`);
|
|
157
173
|
await this.syncEngine.push(filename, workflowId, status);
|
|
158
174
|
this.emit('log', `✅ Auto-sync: Pushed "${filename}"`);
|
|
175
|
+
console.log(`[SyncManager] ✅ Push complete for ${filename}`);
|
|
159
176
|
// Emit event to notify that remote was updated (for webview reload)
|
|
160
177
|
if (workflowId) {
|
|
161
178
|
this.emit('remote-updated', { workflowId, filename });
|