@openapi-flow/n8n 0.0.0-stage → 0.2.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 (237) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +101 -2
  3. package/THIRD_PARTY_NOTICES.md +9 -0
  4. package/dist/legacy/workflow/common/plan-validation.d.ts +1 -0
  5. package/dist/legacy/workflow/common/plan-validation.js +11 -0
  6. package/dist/legacy/workflow/common/workflow-id.d.ts +1 -0
  7. package/dist/legacy/workflow/common/workflow-id.js +8 -0
  8. package/dist/legacy/workflow/inbound/build-inbound-workflow.d.ts +2 -0
  9. package/dist/legacy/workflow/inbound/build-inbound-workflow.js +60 -0
  10. package/dist/legacy/workflow/inbound/compile-inbound-workflow.d.ts +2 -0
  11. package/dist/legacy/workflow/inbound/compile-inbound-workflow.js +25 -0
  12. package/dist/legacy/workflow/inbound/inbound-response.d.ts +2 -0
  13. package/dist/legacy/workflow/inbound/inbound-response.js +51 -0
  14. package/dist/legacy/workflow/request/base-url.d.ts +1 -0
  15. package/dist/legacy/workflow/request/base-url.js +14 -0
  16. package/dist/legacy/workflow/request/build-request-workflow.d.ts +3 -0
  17. package/dist/legacy/workflow/request/build-request-workflow.js +47 -0
  18. package/dist/legacy/workflow/request/build-sequence-workflow.d.ts +3 -0
  19. package/dist/legacy/workflow/request/build-sequence-workflow.js +53 -0
  20. package/dist/legacy/workflow/request/compile-catalog-sequence.d.ts +2 -0
  21. package/dist/legacy/workflow/request/compile-catalog-sequence.js +122 -0
  22. package/dist/legacy/workflow/request/compile-sequence.d.ts +2 -0
  23. package/dist/legacy/workflow/request/compile-sequence.js +41 -0
  24. package/dist/legacy/workflow/request/compile-workflow.d.ts +4 -0
  25. package/dist/legacy/workflow/request/compile-workflow.js +93 -0
  26. package/dist/legacy/workflow/request/credential-binding.d.ts +5 -0
  27. package/dist/legacy/workflow/request/credential-binding.js +31 -0
  28. package/dist/legacy/workflow/request/effect-policy.d.ts +4 -0
  29. package/dist/legacy/workflow/request/effect-policy.js +16 -0
  30. package/dist/legacy/workflow/request/http-request-node.d.ts +2 -0
  31. package/dist/legacy/workflow/request/http-request-node.js +69 -0
  32. package/dist/legacy/workflow/request/prepare-sequence.d.ts +4 -0
  33. package/dist/legacy/workflow/request/prepare-sequence.js +103 -0
  34. package/dist/legacy/workflow/request/request-body.d.ts +4 -0
  35. package/dist/legacy/workflow/request/request-body.js +64 -0
  36. package/dist/legacy/workflow/request/request-headers.d.ts +4 -0
  37. package/dist/legacy/workflow/request/request-headers.js +30 -0
  38. package/dist/legacy/workflow/request/request-url.d.ts +4 -0
  39. package/dist/legacy/workflow/request/request-url.js +34 -0
  40. package/dist/legacy/workflow/request/response-assertion-code.d.ts +3 -0
  41. package/dist/legacy/workflow/request/response-assertion-code.js +28 -0
  42. package/dist/legacy/workflow/request/sequence-url.d.ts +4 -0
  43. package/dist/legacy/workflow/request/sequence-url.js +104 -0
  44. package/dist/legacy-api.d.ts +25 -0
  45. package/dist/legacy-api.js +20 -0
  46. package/dist/nodes/common/validation/compile-standalone-validator.d.ts +3 -0
  47. package/dist/nodes/common/validation/compile-standalone-validator.js +44 -0
  48. package/dist/nodes/gap/create-gap-node.d.ts +3 -0
  49. package/dist/nodes/gap/create-gap-node.js +35 -0
  50. package/dist/nodes/native/arrays/create-array-node-fragment.d.ts +4 -0
  51. package/dist/nodes/native/arrays/create-array-node-fragment.js +42 -0
  52. package/dist/nodes/native/arrays/create-array-reader-code.d.ts +3 -0
  53. package/dist/nodes/native/arrays/create-array-reader-code.js +12 -0
  54. package/dist/nodes/native/arrays/create-native-array-capability.d.ts +3 -0
  55. package/dist/nodes/native/arrays/create-native-array-capability.js +64 -0
  56. package/dist/nodes/native/common/create-native-fragment.d.ts +2 -0
  57. package/dist/nodes/native/common/create-native-fragment.js +10 -0
  58. package/dist/nodes/native/common/response-references.d.ts +3 -0
  59. package/dist/nodes/native/common/response-references.js +5 -0
  60. package/dist/nodes/native/create-exclusive-branch-merge-capability.d.ts +3 -0
  61. package/dist/nodes/native/create-exclusive-branch-merge-capability.js +33 -0
  62. package/dist/nodes/native/create-json-output-capability.d.ts +3 -0
  63. package/dist/nodes/native/create-json-output-capability.js +38 -0
  64. package/dist/nodes/native/create-native-capabilities.d.ts +2 -0
  65. package/dist/nodes/native/create-native-capabilities.js +14 -0
  66. package/dist/nodes/native/create-pass-through-capability.d.ts +3 -0
  67. package/dist/nodes/native/create-pass-through-capability.js +30 -0
  68. package/dist/nodes/native/create-response-array-capability.d.ts +3 -0
  69. package/dist/nodes/native/create-response-array-capability.js +73 -0
  70. package/dist/nodes/native/create-response-collection-capability.d.ts +3 -0
  71. package/dist/nodes/native/create-response-collection-capability.js +132 -0
  72. package/dist/nodes/native/if-capability.d.ts +2 -0
  73. package/dist/nodes/native/if-capability.js +76 -0
  74. package/dist/nodes/native/item-join/create-item-join-capability.d.ts +3 -0
  75. package/dist/nodes/native/item-join/create-item-join-capability.js +153 -0
  76. package/dist/nodes/native/item-join/create-item-join-reader-code.d.ts +2 -0
  77. package/dist/nodes/native/item-join/create-item-join-reader-code.js +18 -0
  78. package/dist/nodes/native/item-join/runtime/item-join-runtime.bundle.js +24 -0
  79. package/dist/nodes/native/item-join/runtime/join-api-items.d.ts +3 -0
  80. package/dist/nodes/native/item-join/runtime/join-api-items.js +37 -0
  81. package/dist/nodes/native/merge-append-capability.d.ts +2 -0
  82. package/dist/nodes/native/merge-append-capability.js +31 -0
  83. package/dist/nodes/native/response-assertion-capability.d.ts +2 -0
  84. package/dist/nodes/native/response-assertion-capability.js +53 -0
  85. package/dist/nodes/native/response-check-code.d.ts +3 -0
  86. package/dist/nodes/native/response-check-code.js +59 -0
  87. package/dist/nodes/native/response-checks/create-response-check-guard.d.ts +4 -0
  88. package/dist/nodes/native/response-checks/create-response-check-guard.js +22 -0
  89. package/dist/nodes/native/response-checks/create-response-check-reader.d.ts +3 -0
  90. package/dist/nodes/native/response-checks/create-response-check-reader.js +23 -0
  91. package/dist/nodes/native/stop-and-error-capability.d.ts +2 -0
  92. package/dist/nodes/native/stop-and-error-capability.js +29 -0
  93. package/dist/nodes/request/authentication/credential-field-name.d.ts +1 -0
  94. package/dist/nodes/request/authentication/credential-field-name.js +3 -0
  95. package/dist/nodes/request/authentication/resolve-http-request-authentication.d.ts +2 -0
  96. package/dist/nodes/request/authentication/resolve-http-request-authentication.js +42 -0
  97. package/dist/nodes/request/bindings/compile-native-output-validators.d.ts +3 -0
  98. package/dist/nodes/request/bindings/compile-native-output-validators.js +12 -0
  99. package/dist/nodes/request/bindings/compile-request-validator.d.ts +3 -0
  100. package/dist/nodes/request/bindings/compile-request-validator.js +13 -0
  101. package/dist/nodes/request/bindings/compile-source-response-validators.d.ts +2 -0
  102. package/dist/nodes/request/bindings/compile-source-response-validators.js +12 -0
  103. package/dist/nodes/request/bindings/create-bound-request-fragment.d.ts +3 -0
  104. package/dist/nodes/request/bindings/create-bound-request-fragment.js +77 -0
  105. package/dist/nodes/request/bindings/create-output-reader-code.d.ts +3 -0
  106. package/dist/nodes/request/bindings/create-output-reader-code.js +26 -0
  107. package/dist/nodes/request/bindings/resolve-output-binding-sources.d.ts +3 -0
  108. package/dist/nodes/request/bindings/resolve-output-binding-sources.js +36 -0
  109. package/dist/nodes/request/create-http-request-node.d.ts +2 -0
  110. package/dist/nodes/request/create-http-request-node.js +94 -0
  111. package/dist/nodes/request/deployment/create-request-deployment-notes.d.ts +2 -0
  112. package/dist/nodes/request/deployment/create-request-deployment-notes.js +3 -0
  113. package/dist/nodes/request/deployment/resolve-http-request-deployment.d.ts +2 -0
  114. package/dist/nodes/request/deployment/resolve-http-request-deployment.js +33 -0
  115. package/dist/nodes/request/response/create-http-response-decoder.d.ts +4 -0
  116. package/dist/nodes/request/response/create-http-response-decoder.js +56 -0
  117. package/dist/nodes/request/response/decode-http-response.d.ts +3 -0
  118. package/dist/nodes/request/response/decode-http-response.js +42 -0
  119. package/dist/nodes/request/response/http-response-media.d.ts +2 -0
  120. package/dist/nodes/request/response/http-response-media.js +32 -0
  121. package/dist/nodes/request/response/response-runtime.bundle.js +24 -0
  122. package/dist/nodes/request/runtime/materialize-http-request.d.ts +3 -0
  123. package/dist/nodes/request/runtime/materialize-http-request.js +17 -0
  124. package/dist/nodes/request/runtime/request-runtime.bundle.js +24 -0
  125. package/dist/nodes/request/serialization/create-serialized-http-request-node.d.ts +3 -0
  126. package/dist/nodes/request/serialization/create-serialized-http-request-node.js +17 -0
  127. package/dist/nodes/request/serialization/serialize-http-request.d.ts +5 -0
  128. package/dist/nodes/request/serialization/serialize-http-request.js +70 -0
  129. package/dist/public-api.d.ts +30 -0
  130. package/dist/public-api.js +17 -0
  131. package/dist/schemas/batch-execution-schema.d.ts +15 -0
  132. package/dist/schemas/batch-execution-schema.js +14 -0
  133. package/dist/schemas/create-native-comparison-planning-schema.d.ts +81 -0
  134. package/dist/schemas/create-native-comparison-planning-schema.js +36 -0
  135. package/dist/schemas/exclusive-branch-merge-schema.d.ts +4 -0
  136. package/dist/schemas/exclusive-branch-merge-schema.js +7 -0
  137. package/dist/schemas/item-join-schema.d.ts +13 -0
  138. package/dist/schemas/item-join-schema.js +26 -0
  139. package/dist/schemas/native-array-schema.d.ts +11 -0
  140. package/dist/schemas/native-array-schema.js +19 -0
  141. package/dist/schemas/native-capability-schemas.d.ts +100 -0
  142. package/dist/schemas/native-capability-schemas.js +62 -0
  143. package/dist/schemas/request-deployment-schema.d.ts +9 -0
  144. package/dist/schemas/request-deployment-schema.js +27 -0
  145. package/dist/schemas/response-array-schema.d.ts +11 -0
  146. package/dist/schemas/response-array-schema.js +19 -0
  147. package/dist/schemas/response-collection-schema.d.ts +11 -0
  148. package/dist/schemas/response-collection-schema.js +19 -0
  149. package/dist/types/array-iteration.d.ts +8 -0
  150. package/dist/types/array-iteration.js +1 -0
  151. package/dist/types/array-split.d.ts +13 -0
  152. package/dist/types/array-split.js +1 -0
  153. package/dist/types/authentication.d.ts +14 -0
  154. package/dist/types/authentication.js +1 -0
  155. package/dist/types/batch-execution.d.ts +23 -0
  156. package/dist/types/batch-execution.js +1 -0
  157. package/dist/types/http-response-decoding.d.ts +16 -0
  158. package/dist/types/http-response-decoding.js +1 -0
  159. package/dist/types/item-join.d.ts +40 -0
  160. package/dist/types/item-join.js +1 -0
  161. package/dist/types/legacy/catalog-workflow.d.ts +37 -0
  162. package/dist/types/legacy/catalog-workflow.js +1 -0
  163. package/dist/types/legacy/inbound-workflow.d.ts +27 -0
  164. package/dist/types/legacy/inbound-workflow.js +1 -0
  165. package/dist/types/legacy/request-node.d.ts +23 -0
  166. package/dist/types/legacy/request-node.js +1 -0
  167. package/dist/types/legacy/request-workflow.d.ts +43 -0
  168. package/dist/types/legacy/request-workflow.js +1 -0
  169. package/dist/types/legacy/sequence-workflow.d.ts +57 -0
  170. package/dist/types/legacy/sequence-workflow.js +1 -0
  171. package/dist/types/native-array.d.ts +8 -0
  172. package/dist/types/native-array.js +1 -0
  173. package/dist/types/native-capability.d.ts +37 -0
  174. package/dist/types/native-capability.js +1 -0
  175. package/dist/types/node-fragment.d.ts +51 -0
  176. package/dist/types/node-fragment.js +1 -0
  177. package/dist/types/output-binding-source.d.ts +22 -0
  178. package/dist/types/output-binding-source.js +1 -0
  179. package/dist/types/request-deployment.d.ts +17 -0
  180. package/dist/types/request-deployment.js +1 -0
  181. package/dist/types/request-materialization.d.ts +22 -0
  182. package/dist/types/request-materialization.js +1 -0
  183. package/dist/types/response-check-compilation.d.ts +11 -0
  184. package/dist/types/response-check-compilation.js +1 -0
  185. package/dist/types/response-check-guard.d.ts +6 -0
  186. package/dist/types/response-check-guard.js +1 -0
  187. package/dist/types/response-collection.d.ts +7 -0
  188. package/dist/types/response-collection.js +1 -0
  189. package/dist/types/reviewable-workflow.d.ts +27 -0
  190. package/dist/types/reviewable-workflow.js +1 -0
  191. package/dist/types/schema-compilation.d.ts +5 -0
  192. package/dist/types/schema-compilation.js +1 -0
  193. package/dist/types/serialized-http-request.d.ts +4 -0
  194. package/dist/types/serialized-http-request.js +1 -0
  195. package/dist/types/workflow-compilation.d.ts +36 -0
  196. package/dist/types/workflow-compilation.js +1 -0
  197. package/dist/utils/bundled-license-banner.d.ts +3 -0
  198. package/dist/utils/bundled-license-banner.js +32 -0
  199. package/dist/utils/javascript-json-literal.d.ts +2 -0
  200. package/dist/utils/javascript-json-literal.js +10 -0
  201. package/dist/utils/json-values-equal.cjs +24 -0
  202. package/dist/utils/json-values-equal.d.cts +1 -0
  203. package/dist/workflow/assemble-n8n-workflow.d.ts +2 -0
  204. package/dist/workflow/assemble-n8n-workflow.js +11 -0
  205. package/dist/workflow/batch/compile-batched-n8n-workflow.d.ts +3 -0
  206. package/dist/workflow/batch/compile-batched-n8n-workflow.js +18 -0
  207. package/dist/workflow/batch/create-batch-execution-scopes.d.ts +3 -0
  208. package/dist/workflow/batch/create-batch-execution-scopes.js +59 -0
  209. package/dist/workflow/batch/validate-batch-exclusive-rejoin.d.ts +3 -0
  210. package/dist/workflow/batch/validate-batch-exclusive-rejoin.js +49 -0
  211. package/dist/workflow/batch/validate-batch-item-flow.d.ts +3 -0
  212. package/dist/workflow/batch/validate-batch-item-flow.js +98 -0
  213. package/dist/workflow/build-n8n-workflow.d.ts +2 -0
  214. package/dist/workflow/build-n8n-workflow.js +143 -0
  215. package/dist/workflow/compile-native-workflow-nodes.d.ts +3 -0
  216. package/dist/workflow/compile-native-workflow-nodes.js +26 -0
  217. package/dist/workflow/compile-planned-n8n-workflow.d.ts +3 -0
  218. package/dist/workflow/compile-planned-n8n-workflow.js +17 -0
  219. package/dist/workflow/compile-reviewable-n8n-workflow.d.ts +3 -0
  220. package/dist/workflow/compile-reviewable-n8n-workflow.js +70 -0
  221. package/dist/workflow/compile-validated-workflow-fragments.d.ts +3 -0
  222. package/dist/workflow/compile-validated-workflow-fragments.js +20 -0
  223. package/dist/workflow/create-n8n-native-output-sources.d.ts +3 -0
  224. package/dist/workflow/create-n8n-native-output-sources.js +17 -0
  225. package/dist/workflow/review/create-gap-review-content.d.ts +2 -0
  226. package/dist/workflow/review/create-gap-review-content.js +28 -0
  227. package/dist/workflow/review/create-gap-review-region.d.ts +2 -0
  228. package/dist/workflow/review/create-gap-review-region.js +23 -0
  229. package/dist/workflow/review/escape-review-markdown.d.ts +1 -0
  230. package/dist/workflow/review/escape-review-markdown.js +7 -0
  231. package/dist/workflow/review/gap-review-region-layout.d.ts +4 -0
  232. package/dist/workflow/review/gap-review-region-layout.js +21 -0
  233. package/dist/workflow/validate-compiled-binding-sources.d.ts +4 -0
  234. package/dist/workflow/validate-compiled-binding-sources.js +40 -0
  235. package/dist/workflow/validate-node-fragments.d.ts +3 -0
  236. package/dist/workflow/validate-node-fragments.js +58 -0
  237. package/package.json +54 -4
@@ -0,0 +1,17 @@
1
+ import type { CredentialBindings } from './legacy/request-workflow.js';
2
+ import type { HttpRequestAuthenticationMapping } from './authentication.js';
3
+ export interface HttpRequestDeploymentOptions {
4
+ baseUrl?: string;
5
+ credentialBindings?: CredentialBindings;
6
+ securityRequirementIndex?: number;
7
+ }
8
+ export interface ResolveHttpRequestDeploymentInput extends HttpRequestDeploymentOptions {
9
+ documentId: string;
10
+ authentication?: HttpRequestAuthenticationMapping;
11
+ }
12
+ export interface ResolvedHttpRequestDeployment {
13
+ baseUrl: string;
14
+ credentialBindings: CredentialBindings;
15
+ pendingFields: string[];
16
+ authentication?: HttpRequestAuthenticationMapping;
17
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,22 @@
1
+ import type { ApiCallArguments, ApiOperationContract, JsonValue } from '@openapi-flow/core';
2
+ import type { Operation } from '@openapi-flow/core/internal';
3
+ import type { PreparedRequestBody, RequestHeader } from './legacy/request-node.js';
4
+ export interface RequestMaterializationConfig {
5
+ contract: ApiOperationContract;
6
+ operation: Operation;
7
+ arguments: ApiCallArguments;
8
+ templateUrl: string;
9
+ }
10
+ export interface MaterializedHttpRequest {
11
+ url: string;
12
+ headers: RequestHeader[];
13
+ body?: PreparedRequestBody;
14
+ }
15
+ export type ResponseBodies = Record<string, JsonValue>;
16
+ export interface RuntimeHttpRequest extends MaterializedHttpRequest {
17
+ headersJson: string;
18
+ }
19
+ export interface RuntimeRequestValidator {
20
+ (value: unknown): boolean;
21
+ errors?: unknown;
22
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,11 @@
1
+ import type { CompileNativeNodeInput, NativeCheck } from './native-capability.js';
2
+ import type { N8nApiResponseSource } from './output-binding-source.js';
3
+ export interface CreateResponseCheckReaderInput extends Pick<CompileNativeNodeInput, 'apiNodeNames' | 'apiResponseContracts'> {
4
+ nodeId: string;
5
+ checks: NativeCheck[];
6
+ linked: boolean;
7
+ }
8
+ export interface CompiledResponseCheckReader {
9
+ code: string;
10
+ bindingSources: N8nApiResponseSource[];
11
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,6 @@
1
+ export interface CreateResponseCheckGuardInput {
2
+ nodeId: string;
3
+ readerCode: string;
4
+ linked: boolean;
5
+ position: [number, number];
6
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,7 @@
1
+ import type { ApiBindingMaterial } from '@openapi-flow/core';
2
+ import type { z } from 'zod';
3
+ import type { responseCollectionParametersSchema } from '../schemas/response-collection-schema.js';
4
+ export type ResponseCollectionParameters = z.infer<typeof responseCollectionParametersSchema>;
5
+ export interface CreateResponseCollectionCapabilityInput {
6
+ materials: ApiBindingMaterial[];
7
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,27 @@
1
+ import type { ReviewableWorkflowGraphPlan, ReviewableWorkflowApiMaterial, WorkflowReviewGap, ApiOperationContract } from '@openapi-flow/core';
2
+ import type { N8nNativeCapability } from './native-capability.js';
3
+ import type { N8nNodeFragment, N8nSdkNode } from './node-fragment.js';
4
+ export interface CompileReviewableN8nWorkflowInput {
5
+ id: string;
6
+ name: string;
7
+ plan: ReviewableWorkflowGraphPlan;
8
+ materials: ReviewableWorkflowApiMaterial[];
9
+ apiNodes: N8nNodeFragment[];
10
+ capabilities: N8nNativeCapability[];
11
+ }
12
+ export interface CreateGapNodeInput {
13
+ nodeId: string;
14
+ gaps: WorkflowReviewGap[];
15
+ position: [number, number];
16
+ operation?: ApiOperationContract;
17
+ }
18
+ export interface GapReviewRegionLayout {
19
+ nodePosition: [number, number];
20
+ notePosition: [number, number];
21
+ width: number;
22
+ height: number;
23
+ }
24
+ export interface GapReviewRegion {
25
+ fragment: N8nNodeFragment;
26
+ annotation: N8nSdkNode;
27
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,5 @@
1
+ import type { BindingSchema } from '@openapi-flow/core';
2
+ export interface CompileStandaloneValidatorInput {
3
+ schema: BindingSchema;
4
+ globalName: string;
5
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,4 @@
1
+ import type { HttpRequestNodeInput } from './legacy/request-node.js';
2
+ export interface SerializedHttpRequestNodeInput extends HttpRequestNodeInput {
3
+ bodySource: 'literal' | 'materialized';
4
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,36 @@
1
+ import type { WorkflowJSON } from '@n8n/workflow-sdk';
2
+ import type { N8nNodeFragment } from './node-fragment.js';
3
+ import type { N8nSdkNode } from './node-fragment.js';
4
+ import type { WorkflowReviewGap } from '@openapi-flow/core';
5
+ import type { N8nBatchExecutionScope } from './batch-execution.js';
6
+ export interface N8nGraphEdge {
7
+ from: string;
8
+ output: string;
9
+ to: string;
10
+ input: string;
11
+ }
12
+ export interface AssembleN8nWorkflowInput {
13
+ id: string;
14
+ name: string;
15
+ nodes: N8nNodeFragment[];
16
+ edges: N8nGraphEdge[];
17
+ starts: string[];
18
+ }
19
+ export interface N8nCompileResult {
20
+ status: 'complete';
21
+ workflow: WorkflowJSON;
22
+ }
23
+ export interface BuildN8nWorkflowInput extends AssembleN8nWorkflowInput {
24
+ triggerConnections: 'connected' | 'detached';
25
+ annotations: N8nSdkNode[];
26
+ batchScopes?: N8nBatchExecutionScope[];
27
+ }
28
+ export interface N8nWorkflowJSON extends WorkflowJSON {
29
+ active?: false;
30
+ }
31
+ export interface N8nNeedsReviewResult {
32
+ status: 'needs-review';
33
+ workflow: N8nWorkflowJSON;
34
+ diagnostics: WorkflowReviewGap[];
35
+ }
36
+ export type N8nWorkflowResult = N8nCompileResult | N8nNeedsReviewResult;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,3 @@
1
+ import type { Metafile } from 'esbuild';
2
+ /** Preserve bundled dependencies' license notices in generated workflow code. */
3
+ export declare function bundledLicenseBanner(metadata: Metafile, generatedFrom: string[]): string;
@@ -0,0 +1,32 @@
1
+ import { existsSync, readFileSync } from 'node:fs';
2
+ import { dirname, join, resolve } from 'node:path';
3
+ /** Preserve bundled dependencies' license notices in generated workflow code. */
4
+ export function bundledLicenseBanner(metadata, generatedFrom) {
5
+ const packages = new Set(generatedFrom);
6
+ const notices = [];
7
+ for (const input of Object.keys(metadata.inputs)) {
8
+ if (input === '<stdin>')
9
+ continue;
10
+ let directory = dirname(resolve(input));
11
+ while (!existsSync(join(directory, 'package.json'))) {
12
+ const parent = dirname(directory);
13
+ if (parent === directory)
14
+ throw new Error(`Bundled input ${input} has no owning package`);
15
+ directory = parent;
16
+ }
17
+ packages.add(directory);
18
+ }
19
+ for (const directory of packages) {
20
+ const file = ['LICENSE', 'LICENSE.md', 'LICENSE.txt']
21
+ .map((name) => join(directory, name))
22
+ .find(existsSync);
23
+ if (!file)
24
+ throw new Error(`Bundled package ${directory} has no license notice`);
25
+ notices.push(readFileSync(file, 'utf8'));
26
+ }
27
+ return notices.length
28
+ ? '/*! Bundled dependency licenses\n' +
29
+ notices.join('\n\n').replaceAll('*/', '* /') +
30
+ '\n*/\n'
31
+ : '';
32
+ }
@@ -0,0 +1,2 @@
1
+ /** Encode data as a JS string, avoiding n8n's delimiter scan even inside strings. */
2
+ export declare function javascriptJsonLiteral(value: unknown): string;
@@ -0,0 +1,10 @@
1
+ /** Encode data as a JS string, avoiding n8n's delimiter scan even inside strings. */
2
+ export function javascriptJsonLiteral(value) {
3
+ const json = JSON.stringify(value);
4
+ if (json === undefined)
5
+ throw new Error('Runtime data must be JSON-serializable');
6
+ const literal = JSON.stringify(json)
7
+ .replaceAll('{', '\\u007b')
8
+ .replaceAll('}', '\\u007d');
9
+ return `JSON.parse(${literal})`;
10
+ }
@@ -0,0 +1,24 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ /** JSON Schema equality is structural; JavaScript prototypes are not JSON data. */
4
+ function jsonValuesEqual(left, right) {
5
+ if (left === right)
6
+ return true;
7
+ if (left === null ||
8
+ right === null ||
9
+ typeof left !== 'object' ||
10
+ typeof right !== 'object')
11
+ return false;
12
+ if (Array.isArray(left) !== Array.isArray(right))
13
+ return false;
14
+ if (Array.isArray(left) &&
15
+ Array.isArray(right) &&
16
+ left.length !== right.length)
17
+ return false;
18
+ const keys = Object.keys(left);
19
+ return (keys.length === Object.keys(right).length &&
20
+ keys.every((key) => Object.hasOwn(right, key) &&
21
+ jsonValuesEqual(Reflect.get(left, key), Reflect.get(right, key))));
22
+ }
23
+ // Ajv standalone requires a CommonJS module's plain default field.
24
+ module.exports = { default: jsonValuesEqual };
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,2 @@
1
+ import type { AssembleN8nWorkflowInput, N8nCompileResult } from '../types/workflow-compilation.js';
2
+ export declare function assembleN8nWorkflow(input: AssembleN8nWorkflowInput): N8nCompileResult;
@@ -0,0 +1,11 @@
1
+ import { buildN8nWorkflow } from './build-n8n-workflow.js';
2
+ export function assembleN8nWorkflow(input) {
3
+ return {
4
+ status: 'complete',
5
+ workflow: buildN8nWorkflow({
6
+ ...input,
7
+ triggerConnections: 'connected',
8
+ annotations: [],
9
+ }),
10
+ };
11
+ }
@@ -0,0 +1,3 @@
1
+ import type { CompileBatchedN8nWorkflowInput } from '../../types/batch-execution.js';
2
+ import type { N8nCompileResult } from '../../types/workflow-compilation.js';
3
+ export declare function compileBatchedN8nWorkflow(input: CompileBatchedN8nWorkflowInput): N8nCompileResult;
@@ -0,0 +1,18 @@
1
+ import { batchExecutionScopesSchema } from '../../schemas/batch-execution-schema.js';
2
+ import { compileValidatedWorkflowFragments } from '../compile-validated-workflow-fragments.js';
3
+ import { buildN8nWorkflow } from '../build-n8n-workflow.js';
4
+ export function compileBatchedN8nWorkflow(input) {
5
+ const batchScopes = batchExecutionScopesSchema.parse(input.batchScopes);
6
+ const workflow = buildN8nWorkflow({
7
+ id: input.id,
8
+ name: input.name,
9
+ nodes: compileValidatedWorkflowFragments(input),
10
+ edges: input.plan.edges,
11
+ starts: input.plan.starts,
12
+ triggerConnections: 'connected',
13
+ annotations: [],
14
+ batchScopes,
15
+ });
16
+ workflow.settings = { ...workflow.settings, executionOrder: 'v1' };
17
+ return { status: 'complete', workflow };
18
+ }
@@ -0,0 +1,3 @@
1
+ import type { CreateBatchExecutionScopesInput, CompiledN8nBatchExecutionScope } from '../../types/batch-execution.js';
2
+ /** Lower explicitly bounded, cardinality-preserving paths; never allow arbitrary cycles. */
3
+ export declare function createBatchExecutionScopes(input: CreateBatchExecutionScopesInput): CompiledN8nBatchExecutionScope[];
@@ -0,0 +1,59 @@
1
+ import { node } from '@n8n/workflow-sdk';
2
+ import { batchExecutionScopesSchema } from '../../schemas/batch-execution-schema.js';
3
+ import { validateBatchItemFlow } from './validate-batch-item-flow.js';
4
+ /** Lower explicitly bounded, cardinality-preserving paths; never allow arbitrary cycles. */
5
+ export function createBatchExecutionScopes(input) {
6
+ const scopes = batchExecutionScopesSchema.parse(input.batchScopes);
7
+ const fragments = new Map(input.nodes.map((fragment) => [fragment.nodeId, fragment]));
8
+ const owners = new Set();
9
+ const ids = new Set();
10
+ return scopes.map((scope) => {
11
+ const members = new Set(scope.nodeIds);
12
+ if (ids.has(scope.id) ||
13
+ members.size !== scope.nodeIds.length ||
14
+ !members.has(scope.entryNodeId) ||
15
+ !members.has(scope.exitNodeId))
16
+ throw new Error(`batch ${scope.id}: duplicate scope/member identity or missing entry/exit member`);
17
+ ids.add(scope.id);
18
+ for (const id of members) {
19
+ const fragment = fragments.get(id);
20
+ if (!fragment || owners.has(id))
21
+ throw new Error(`batch ${scope.id}: missing or overlapping member ${id}`);
22
+ owners.add(id);
23
+ const incoming = input.edges.filter((edge) => edge.to === id);
24
+ const outgoing = input.edges.filter((edge) => edge.from === id);
25
+ if (incoming.some((edge) => !members.has(edge.from) && id !== scope.entryNodeId) ||
26
+ outgoing.some((edge) => !members.has(edge.to) && id !== scope.exitNodeId))
27
+ throw new Error(`batch ${scope.id}: member ${id} crosses the entry/exit boundary`);
28
+ if (id !== scope.entryNodeId && input.starts.includes(id))
29
+ throw new Error(`batch ${scope.id}: only its entry may be a workflow start`);
30
+ }
31
+ validateBatchItemFlow({
32
+ scope,
33
+ fragments,
34
+ edges: input.edges,
35
+ otherBatchNodeIds: new Set(scopes
36
+ .filter((other) => other.id !== scope.id)
37
+ .flatMap((other) => other.nodeIds)),
38
+ });
39
+ const entry = fragments.get(scope.entryNodeId);
40
+ const position = entry.entry.config.position;
41
+ if (!Array.isArray(position) ||
42
+ position.length !== 2 ||
43
+ position.some((coordinate) => typeof coordinate !== 'number' || !Number.isFinite(coordinate)))
44
+ throw new Error(`batch ${scope.id}: entry ${scope.entryNodeId} requires config.position with two finite coordinates`);
45
+ return {
46
+ scope,
47
+ controller: node({
48
+ type: 'n8n-nodes-base.splitInBatches',
49
+ version: 3,
50
+ config: {
51
+ id: scope.id,
52
+ name: scope.id,
53
+ position: [position[0] - 220, position[1]],
54
+ parameters: { batchSize: scope.batchSize, options: { reset: false } },
55
+ },
56
+ }),
57
+ };
58
+ });
59
+ }
@@ -0,0 +1,3 @@
1
+ import type { ValidateBatchItemFlowInput } from '../../types/batch-execution.js';
2
+ /** Verify complete one-to-one paths, rather than interpreting item values or IDs. */
3
+ export declare function validateBatchExclusiveRejoin(input: ValidateBatchItemFlowInput, nodeId: string): void;
@@ -0,0 +1,49 @@
1
+ /** Verify complete one-to-one paths, rather than interpreting item values or IDs. */
2
+ export function validateBatchExclusiveRejoin(input, nodeId) {
3
+ const { scope, fragments, edges } = input;
4
+ const sourceId = fragments.get(nodeId).rejoinsExclusiveOutputs;
5
+ const source = fragments.get(sourceId);
6
+ const target = fragments.get(nodeId);
7
+ const incoming = edges.filter((edge) => edge.to === nodeId);
8
+ if (!scope.nodeIds.includes(sourceId) ||
9
+ !source?.partitionsInputItems ||
10
+ target.preservesInputItems ||
11
+ target.joinsInputItemsByAncestry ||
12
+ Object.keys(target.outputPorts).join() !== 'main' ||
13
+ target.inputEndpoints ||
14
+ incoming.length !== Object.keys(target.inputPorts).length)
15
+ throw new Error(`batch ${scope.id}: rejoin ${nodeId} requires a complete partition in the same scope`);
16
+ const covered = new Set();
17
+ for (const port of Object.keys(target.inputPorts)) {
18
+ const paths = incoming.filter((edge) => edge.input === port);
19
+ if (paths.length !== 1)
20
+ throw new Error(`batch ${scope.id}: rejoin ${nodeId} requires exactly one path per input`);
21
+ let edge = paths[0];
22
+ const visited = new Set();
23
+ while (edge.from !== sourceId) {
24
+ const step = fragments.get(edge.from);
25
+ const predecessors = edges.filter((item) => item.to === edge.from);
26
+ if (!scope.nodeIds.includes(edge.from) ||
27
+ visited.has(edge.from) ||
28
+ !step ||
29
+ step.preservesInputItems !== true ||
30
+ step.joinsInputItemsByAncestry ||
31
+ step.partitionsInputItems ||
32
+ step.rejoinsExclusiveOutputs ||
33
+ step.inputEndpoints ||
34
+ Object.keys(step.inputPorts).join() !== 'main' ||
35
+ Object.keys(step.outputPorts).join() !== 'main' ||
36
+ predecessors.length !== 1 ||
37
+ edges.filter((item) => item.from === edge.from).length !== 1)
38
+ throw new Error(`batch ${scope.id}: rejoin ${nodeId} requires item-preserving paths from ${sourceId}`);
39
+ visited.add(edge.from);
40
+ edge = predecessors[0];
41
+ }
42
+ if (!Object.hasOwn(source.outputPorts, edge.output) ||
43
+ covered.has(edge.output))
44
+ throw new Error(`batch ${scope.id}: rejoin ${nodeId} repeats or omits an alternative of ${sourceId}`);
45
+ covered.add(edge.output);
46
+ }
47
+ if (covered.size !== Object.keys(source.outputPorts).length)
48
+ throw new Error(`batch ${scope.id}: rejoin ${nodeId} must return every alternative of ${sourceId}`);
49
+ }
@@ -0,0 +1,3 @@
1
+ import type { ValidateBatchItemFlowInput } from '../../types/batch-execution.js';
2
+ /** Prove one result per entry item through declared preservation and ancestry joins. */
3
+ export declare function validateBatchItemFlow({ scope, fragments, edges, otherBatchNodeIds, }: ValidateBatchItemFlowInput): void;
@@ -0,0 +1,98 @@
1
+ import { validateBatchExclusiveRejoin } from './validate-batch-exclusive-rejoin.js';
2
+ /** Prove one result per entry item through declared preservation and ancestry joins. */
3
+ export function validateBatchItemFlow({ scope, fragments, edges, otherBatchNodeIds, }) {
4
+ const members = new Set(scope.nodeIds);
5
+ const incoming = (id) => edges.filter((edge) => edge.to === id);
6
+ const outgoing = (id) => edges.filter((edge) => edge.from === id);
7
+ const upstream = incoming(scope.entryNodeId).filter((edge) => !members.has(edge.from));
8
+ if (upstream.length > 1)
9
+ throw new Error(`batch ${scope.id}: entry requires one upstream stream`);
10
+ const entryAncestors = new Set();
11
+ let preceding = upstream.map((edge) => edge.from);
12
+ while (preceding.length) {
13
+ const id = preceding.pop();
14
+ if (otherBatchNodeIds.has(id))
15
+ break;
16
+ if (entryAncestors.has(id))
17
+ throw new Error(`batch ${scope.id}: upstream item flow has a cycle`);
18
+ entryAncestors.add(id);
19
+ const fragment = fragments.get(id);
20
+ const sources = incoming(id);
21
+ if (fragment.preservesInputItems === true &&
22
+ !fragment.joinsInputItemsByAncestry &&
23
+ Object.keys(fragment.inputPorts).join() === 'main' &&
24
+ Object.keys(fragment.outputPorts).join() === 'main' &&
25
+ !fragment.inputEndpoints &&
26
+ sources.length === 1)
27
+ preceding = [sources[0].from];
28
+ }
29
+ const ancestors = new Map();
30
+ const pending = [...members];
31
+ while (pending.length) {
32
+ const index = pending.findIndex((id) => incoming(id)
33
+ .filter((edge) => members.has(edge.from))
34
+ .every((edge) => ancestors.has(edge.from)));
35
+ if (index === -1)
36
+ throw new Error(`batch ${scope.id}: item flow has a cycle`);
37
+ const id = pending.splice(index, 1)[0];
38
+ const fragment = fragments.get(id);
39
+ const innerIncoming = incoming(id).filter((edge) => members.has(edge.from));
40
+ const innerOutgoing = outgoing(id).filter((edge) => members.has(edge.to));
41
+ if ((id === scope.entryNodeId
42
+ ? innerIncoming.length !== 0
43
+ : innerIncoming.length === 0) ||
44
+ (id === scope.exitNodeId
45
+ ? innerOutgoing.length !== 0
46
+ : innerOutgoing.length === 0))
47
+ throw new Error(`batch ${scope.id}: every member must lie between its entry and exit`);
48
+ const join = fragment.joinsInputItemsByAncestry;
49
+ const rejoin = fragment.rejoinsExclusiveOutputs;
50
+ const partition = fragment.partitionsInputItems;
51
+ if (partition &&
52
+ (fragment.preservesInputItems ||
53
+ join ||
54
+ rejoin ||
55
+ Object.keys(fragment.inputPorts).join() !== 'main' ||
56
+ fragment.inputEndpoints ||
57
+ Object.keys(fragment.outputPorts).length < 2 ||
58
+ Object.keys(fragment.outputPorts).some((port) => innerOutgoing.filter((edge) => edge.output === port).length !== 1)))
59
+ throw new Error(`batch ${scope.id}: item-preserving main path contract requires every partition output of ${id} to return exactly once`);
60
+ if ((!partition && Object.keys(fragment.outputPorts).join() !== 'main') ||
61
+ (!join &&
62
+ !partition &&
63
+ !rejoin &&
64
+ (fragment.preservesInputItems !== true ||
65
+ Object.keys(fragment.inputPorts).join() !== 'main' ||
66
+ fragment.inputEndpoints)) ||
67
+ (join && fragment.preservesInputItems === true))
68
+ throw new Error(`batch ${scope.id}: member ${id} requires an item-preserving main path contract or an explicit ancestry join`);
69
+ let inherited;
70
+ if (rejoin) {
71
+ validateBatchExclusiveRejoin({ scope, fragments, edges, otherBatchNodeIds }, id);
72
+ const branches = innerIncoming.map((edge) => ancestors.get(edge.from));
73
+ inherited = new Set([...branches[0]].filter((ancestor) => branches.every((branch) => branch.has(ancestor))));
74
+ }
75
+ else if (join) {
76
+ const ports = Object.keys(fragment.inputPorts);
77
+ if (id === scope.entryNodeId ||
78
+ ports.length < 2 ||
79
+ ports.some((port) => innerIncoming.filter((edge) => edge.input === port).length !== 1) ||
80
+ innerIncoming.length !== ports.length)
81
+ throw new Error(`batch ${scope.id}: join ${id} requires exactly one branch per declared input`);
82
+ const branchAncestors = innerIncoming.map((edge) => ancestors.get(edge.from));
83
+ if (!fragment.bindingSources?.some((source) => source.kind === 'native-json' && source.nodeId === join.scopeNodeId) ||
84
+ branchAncestors.some((branch) => !branch.has(join.scopeNodeId)))
85
+ throw new Error(`batch ${scope.id}: join ${id} scope ${join.scopeNodeId} must identify each entry item on every branch`);
86
+ inherited = new Set([...branchAncestors[0]].filter((ancestor) => branchAncestors.every((branch) => branch.has(ancestor))));
87
+ }
88
+ else {
89
+ if (id !== scope.entryNodeId && innerIncoming.length !== 1)
90
+ throw new Error(`batch ${scope.id}: member ${id} requires one incoming item stream; use an explicit ancestry join for branches`);
91
+ inherited =
92
+ id === scope.entryNodeId
93
+ ? entryAncestors
94
+ : ancestors.get(innerIncoming[0].from);
95
+ }
96
+ ancestors.set(id, new Set([...inherited, id]));
97
+ }
98
+ }
@@ -0,0 +1,2 @@
1
+ import type { BuildN8nWorkflowInput, N8nWorkflowJSON } from '../types/workflow-compilation.js';
2
+ export declare function buildN8nWorkflow({ id, name, nodes, edges, starts, triggerConnections, annotations, batchScopes, }: BuildN8nWorkflowInput): N8nWorkflowJSON;