@egose/n8n-client 0.1.2 → 0.2.1

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 (266) hide show
  1. package/CHANGELOG.md +18 -0
  2. package/README.md +194 -47
  3. package/chunk-2R6A6NJE.js +38 -0
  4. package/chunk-3FDDCKAY.js +95 -0
  5. package/chunk-3YWWR6UD.cjs +98 -0
  6. package/chunk-4M2HGY3F.cjs +12 -0
  7. package/chunk-4VK7K4IF.js +29 -0
  8. package/chunk-54MX3Y2M.cjs +15 -0
  9. package/{chunk-NMKH2J77.js → chunk-54N6YD4R.js} +28 -6
  10. package/{chunk-2H3GEKKO.js → chunk-5DDMSYH2.js} +25 -6
  11. package/chunk-5ZRUF6XZ.cjs +15 -0
  12. package/chunk-6JJ6RA5B.cjs +32 -0
  13. package/chunk-7H75UBMH.cjs +29 -0
  14. package/chunk-B7CINZ27.cjs +43 -0
  15. package/chunk-BA4KTRMX.cjs +15 -0
  16. package/{chunk-DO5OI6ZU.js → chunk-BQ2OTUXQ.js} +25 -6
  17. package/chunk-C3JBYESS.cjs +35 -0
  18. package/chunk-C6W6ERQD.js +53 -0
  19. package/{chunk-5WH4FOE2.cjs → chunk-CCS5ALTN.cjs} +5 -5
  20. package/chunk-DTDNBA7W.cjs +59 -0
  21. package/chunk-ETVDSJLY.js +48 -0
  22. package/chunk-F5RPJMNK.js +15 -0
  23. package/chunk-FIKGC2EL.cjs +29 -0
  24. package/{chunk-YONLN7XM.cjs → chunk-FTIVM52X.cjs} +24 -5
  25. package/chunk-GEWLPVNV.cjs +48 -0
  26. package/{chunk-75AXCCWF.cjs → chunk-GZ3POWDP.cjs} +27 -5
  27. package/chunk-HISH4ORK.js +59 -0
  28. package/chunk-I4MMTW33.js +98 -0
  29. package/chunk-KRPRS2E5.cjs +46 -0
  30. package/chunk-L2FFL3BY.js +35 -0
  31. package/chunk-LQULSPET.cjs +55 -0
  32. package/chunk-LTYQTCHM.js +196 -0
  33. package/chunk-MMN2UKTI.cjs +41 -0
  34. package/chunk-NBLW25ME.cjs +67 -0
  35. package/chunk-NS2RDZ7W.js +15 -0
  36. package/chunk-OUOWDGL7.js +15 -0
  37. package/chunk-PT5DDLHC.js +46 -0
  38. package/chunk-Q6FSREKN.js +12 -0
  39. package/chunk-QJR4WFNV.js +55 -0
  40. package/chunk-RPB226OX.cjs +54 -0
  41. package/chunk-S4ZASMBT.js +43 -0
  42. package/chunk-T62VHXNY.js +67 -0
  43. package/chunk-TLBDBRPJ.js +29 -0
  44. package/chunk-TY76RTXQ.cjs +32 -0
  45. package/chunk-USTEEQQG.js +43 -0
  46. package/chunk-W5P34RYO.cjs +196 -0
  47. package/chunk-XJP6FPN3.js +41 -0
  48. package/chunk-YBMEMKCN.cjs +53 -0
  49. package/chunk-YE2OS2KS.js +32 -0
  50. package/chunk-YHSDCE3I.js +32 -0
  51. package/chunk-YSWBOCXJ.cjs +38 -0
  52. package/chunk-YUCX7HE3.js +15 -0
  53. package/chunk-Z3D4URRD.cjs +43 -0
  54. package/chunk-ZIIR24GM.cjs +95 -0
  55. package/chunk-ZPU6PQES.cjs +15 -0
  56. package/{chunk-6L3JVMUK.js → chunk-ZVZIMJRM.js} +6 -6
  57. package/clients/audit.cjs +8 -0
  58. package/{handles → clients}/audit.d.cts +3 -3
  59. package/{handles → clients}/audit.d.ts +3 -3
  60. package/clients/audit.js +8 -0
  61. package/clients/base.cjs +7 -0
  62. package/{handles → clients}/base.d.cts +2 -2
  63. package/{handles → clients}/base.d.ts +2 -2
  64. package/clients/base.js +7 -0
  65. package/clients/community-package.cjs +12 -0
  66. package/clients/community-package.d.cts +6 -0
  67. package/clients/community-package.d.ts +6 -0
  68. package/clients/community-package.js +12 -0
  69. package/clients/credential.cjs +10 -0
  70. package/clients/credential.d.cts +6 -0
  71. package/clients/credential.d.ts +6 -0
  72. package/clients/credential.js +10 -0
  73. package/clients/data-table.cjs +10 -0
  74. package/clients/data-table.d.cts +6 -0
  75. package/clients/data-table.d.ts +6 -0
  76. package/clients/data-table.js +10 -0
  77. package/clients/discover.cjs +8 -0
  78. package/{handles → clients}/discover.d.cts +3 -3
  79. package/{handles → clients}/discover.d.ts +3 -3
  80. package/clients/discover.js +8 -0
  81. package/clients/execution.cjs +10 -0
  82. package/clients/execution.d.cts +6 -0
  83. package/clients/execution.d.ts +6 -0
  84. package/clients/execution.js +10 -0
  85. package/clients/folder.cjs +10 -0
  86. package/clients/folder.d.cts +6 -0
  87. package/clients/folder.d.ts +6 -0
  88. package/clients/folder.js +10 -0
  89. package/clients/insights.cjs +8 -0
  90. package/{handles → clients}/insights.d.cts +3 -3
  91. package/{handles → clients}/insights.d.ts +3 -3
  92. package/clients/insights.js +8 -0
  93. package/clients/n8n-package.cjs +8 -0
  94. package/{handles → clients}/n8n-package.d.cts +3 -3
  95. package/{handles → clients}/n8n-package.d.ts +3 -3
  96. package/clients/n8n-package.js +8 -0
  97. package/clients/project.cjs +22 -0
  98. package/clients/project.d.cts +11 -0
  99. package/clients/project.d.ts +11 -0
  100. package/clients/project.js +22 -0
  101. package/clients/source-control.cjs +8 -0
  102. package/{handles → clients}/source-control.d.cts +3 -3
  103. package/{handles → clients}/source-control.d.ts +3 -3
  104. package/clients/source-control.js +8 -0
  105. package/clients/tag.cjs +10 -0
  106. package/clients/tag.d.cts +6 -0
  107. package/clients/tag.d.ts +6 -0
  108. package/clients/tag.js +10 -0
  109. package/clients/user.cjs +10 -0
  110. package/clients/user.d.cts +6 -0
  111. package/clients/user.d.ts +6 -0
  112. package/clients/user.js +10 -0
  113. package/clients/variable.cjs +12 -0
  114. package/clients/variable.d.cts +6 -0
  115. package/clients/variable.d.ts +6 -0
  116. package/clients/variable.js +12 -0
  117. package/clients/workflow.cjs +14 -0
  118. package/clients/workflow.d.cts +7 -0
  119. package/clients/workflow.d.ts +7 -0
  120. package/clients/workflow.js +14 -0
  121. package/community-package-CyzAqqwH.d.ts +26 -0
  122. package/community-package-DBpReCPV.d.cts +26 -0
  123. package/credential-BWcrGfqd.d.ts +34 -0
  124. package/credential-CEH7XbGn.d.cts +34 -0
  125. package/data-table-CHGUClGF.d.ts +60 -0
  126. package/data-table-CzR5kl9T.d.cts +60 -0
  127. package/execution-BjR6z5Vu.d.ts +33 -0
  128. package/execution-C0c9utwa.d.cts +33 -0
  129. package/folder-DvgIxSea.d.cts +31 -0
  130. package/folder-bjRPcy2j.d.ts +31 -0
  131. package/index.cjs +85 -44
  132. package/index.d.cts +42 -31
  133. package/index.d.ts +42 -31
  134. package/index.js +98 -57
  135. package/package.json +1 -1
  136. package/project-BS1fXSLW.d.cts +94 -0
  137. package/project-uws9k24H.d.ts +94 -0
  138. package/resources/base.cjs +7 -0
  139. package/resources/base.d.cts +11 -0
  140. package/resources/base.d.ts +11 -0
  141. package/resources/base.js +7 -0
  142. package/resources/community-package.cjs +8 -0
  143. package/resources/community-package.d.cts +6 -0
  144. package/resources/community-package.d.ts +6 -0
  145. package/resources/community-package.js +8 -0
  146. package/resources/credential.cjs +8 -0
  147. package/resources/credential.d.cts +6 -0
  148. package/resources/credential.d.ts +6 -0
  149. package/resources/credential.js +8 -0
  150. package/resources/data-table.cjs +8 -0
  151. package/resources/data-table.d.cts +6 -0
  152. package/resources/data-table.d.ts +6 -0
  153. package/resources/data-table.js +8 -0
  154. package/resources/execution.cjs +8 -0
  155. package/resources/execution.d.cts +6 -0
  156. package/resources/execution.d.ts +6 -0
  157. package/resources/execution.js +8 -0
  158. package/resources/folder.cjs +8 -0
  159. package/resources/folder.d.cts +6 -0
  160. package/resources/folder.d.ts +6 -0
  161. package/resources/folder.js +8 -0
  162. package/resources/project.cjs +11 -0
  163. package/resources/project.d.cts +11 -0
  164. package/resources/project.d.ts +11 -0
  165. package/resources/project.js +11 -0
  166. package/resources/tag.cjs +8 -0
  167. package/resources/tag.d.cts +6 -0
  168. package/resources/tag.d.ts +6 -0
  169. package/resources/tag.js +8 -0
  170. package/resources/user.cjs +8 -0
  171. package/resources/user.d.cts +6 -0
  172. package/resources/user.d.ts +6 -0
  173. package/resources/user.js +8 -0
  174. package/resources/variable.cjs +8 -0
  175. package/resources/variable.d.cts +6 -0
  176. package/resources/variable.d.ts +6 -0
  177. package/resources/variable.js +8 -0
  178. package/resources/workflow.cjs +10 -0
  179. package/resources/workflow.d.cts +7 -0
  180. package/resources/workflow.d.ts +7 -0
  181. package/resources/workflow.js +10 -0
  182. package/tag-CzazpR40.d.cts +27 -0
  183. package/tag-lmf8obZe.d.ts +27 -0
  184. package/user-B0WdVahA.d.ts +27 -0
  185. package/user-CBa2VjYj.d.cts +27 -0
  186. package/variable-C2LmlaTx.d.ts +29 -0
  187. package/variable-CuCiwy0G.d.cts +29 -0
  188. package/workflow-8pMj_fR_.d.ts +56 -0
  189. package/workflow-B2nxUmWq.d.cts +56 -0
  190. package/chunk-2DSU5F3J.js +0 -37
  191. package/chunk-2JBRCS53.js +0 -27
  192. package/chunk-4QPHBRTA.js +0 -15
  193. package/chunk-ACVK7R2L.cjs +0 -12
  194. package/chunk-BI6R6RFB.js +0 -36
  195. package/chunk-CDYFI72K.js +0 -28
  196. package/chunk-FKHPF5R5.cjs +0 -37
  197. package/chunk-GYCE5P4Y.js +0 -24
  198. package/chunk-HDN3VTQ4.cjs +0 -15
  199. package/chunk-HYJ7KYNG.cjs +0 -35
  200. package/chunk-IDD662MQ.js +0 -15
  201. package/chunk-JUWY746V.cjs +0 -15
  202. package/chunk-JWSD43W3.js +0 -36
  203. package/chunk-L36NK3EC.cjs +0 -27
  204. package/chunk-LBBJ6MTN.cjs +0 -36
  205. package/chunk-OHQBXLTJ.js +0 -12
  206. package/chunk-ONBMQHLH.cjs +0 -28
  207. package/chunk-R3HQQ6JP.cjs +0 -15
  208. package/chunk-RXHHER7R.js +0 -24
  209. package/chunk-THVPKRZ6.js +0 -15
  210. package/chunk-UKWCRX4F.cjs +0 -36
  211. package/chunk-UPL3BYDO.js +0 -15
  212. package/chunk-UU6H6FNY.cjs +0 -15
  213. package/chunk-VS6V3PD6.cjs +0 -24
  214. package/chunk-XHPNV55G.cjs +0 -24
  215. package/handles/audit.cjs +0 -8
  216. package/handles/audit.js +0 -8
  217. package/handles/base.cjs +0 -7
  218. package/handles/base.js +0 -7
  219. package/handles/community-package.cjs +0 -8
  220. package/handles/community-package.d.cts +0 -13
  221. package/handles/community-package.d.ts +0 -13
  222. package/handles/community-package.js +0 -8
  223. package/handles/credential.cjs +0 -8
  224. package/handles/credential.d.cts +0 -17
  225. package/handles/credential.d.ts +0 -17
  226. package/handles/credential.js +0 -8
  227. package/handles/data-table.cjs +0 -8
  228. package/handles/data-table.d.cts +0 -30
  229. package/handles/data-table.d.ts +0 -30
  230. package/handles/data-table.js +0 -8
  231. package/handles/discover.cjs +0 -8
  232. package/handles/discover.js +0 -8
  233. package/handles/execution.cjs +0 -8
  234. package/handles/execution.d.cts +0 -17
  235. package/handles/execution.d.ts +0 -17
  236. package/handles/execution.js +0 -8
  237. package/handles/folder.cjs +0 -8
  238. package/handles/folder.d.cts +0 -16
  239. package/handles/folder.d.ts +0 -16
  240. package/handles/folder.js +0 -8
  241. package/handles/insights.cjs +0 -8
  242. package/handles/insights.js +0 -8
  243. package/handles/n8n-package.cjs +0 -8
  244. package/handles/n8n-package.js +0 -8
  245. package/handles/project.cjs +0 -8
  246. package/handles/project.d.cts +0 -17
  247. package/handles/project.d.ts +0 -17
  248. package/handles/project.js +0 -8
  249. package/handles/source-control.cjs +0 -8
  250. package/handles/source-control.js +0 -8
  251. package/handles/tag.cjs +0 -8
  252. package/handles/tag.d.cts +0 -14
  253. package/handles/tag.d.ts +0 -14
  254. package/handles/tag.js +0 -8
  255. package/handles/user.cjs +0 -8
  256. package/handles/user.d.cts +0 -14
  257. package/handles/user.d.ts +0 -14
  258. package/handles/user.js +0 -8
  259. package/handles/variable.cjs +0 -8
  260. package/handles/variable.d.cts +0 -13
  261. package/handles/variable.d.ts +0 -13
  262. package/handles/variable.js +0 -8
  263. package/handles/workflow.cjs +0 -8
  264. package/handles/workflow.d.cts +0 -22
  265. package/handles/workflow.d.ts +0 -22
  266. package/handles/workflow.js +0 -8
package/CHANGELOG.md CHANGED
@@ -1,3 +1,21 @@
1
+ ## [0.2.1](https://github.com/egose/n8n-client/compare/v0.2.0...v0.2.1) (2026-06-14)
2
+
3
+ ### Docs
4
+
5
+ * **website:** document resource classes and update api examples ([1863152](https://github.com/egose/n8n-client/commit/1863152e2fa31f8028bd45482027c150c196916b))
6
+
7
+ ## [0.2.0](https://github.com/egose/n8n-client/compare/v0.1.2...v0.2.0) (2026-06-13)
8
+
9
+ ### Features
10
+
11
+ * **website:** add bound resource clients and resource helpers across website API ([06929b2](https://github.com/egose/n8n-client/commit/06929b242b5bca3d81b2a2ffc5b3a54dca127121))
12
+ * **website:** rename resource handles to clients and update factory methods ([cd551cc](https://github.com/egose/n8n-client/commit/cd551cc860cbc0ee3a1b8fbb28985a56704f0c77))
13
+
14
+ ### Docs
15
+
16
+ * **website:** document raw versus resource client usage patterns ([1015838](https://github.com/egose/n8n-client/commit/101583834502dd253d705dc5dcad55c4ad68d9d8))
17
+ * **website:** refresh website docs and examples for client naming ([bf646e5](https://github.com/egose/n8n-client/commit/bf646e51b3c95f3e7a94414a8196e1336e2f9037))
18
+
1
19
  ## [0.1.2](https://github.com/egose/n8n-client/compare/v0.1.1...v0.1.2) (2026-06-13)
2
20
 
3
21
  ### Docs
package/README.md CHANGED
@@ -12,7 +12,7 @@
12
12
  </p>
13
13
 
14
14
  <p align="center">
15
- TypeScript client for the n8n Public API with cursor-based pagination and typed resource handles.
15
+ TypeScript client for the n8n Public API with cursor-based pagination and typed resource clients.
16
16
  </p>
17
17
 
18
18
  <p align="center">
@@ -25,14 +25,14 @@
25
25
 
26
26
  ## What It Is
27
27
 
28
- `@egose/n8n-client` provides a TypeScript client for the [n8n Public API](https://docs.n8n.io/api/). Instead of manually constructing HTTP requests and parsing responses, you work through resource handles:
28
+ `@egose/n8n-client` provides a TypeScript client for the [n8n Public API](https://docs.n8n.io/api/). Instead of manually constructing HTTP requests and parsing responses, you work through resource clients:
29
29
 
30
30
  ```ts
31
31
  const client = new N8nClient({ baseUrl: 'http://localhost:5678', apiKey: 'your-api-key' }); // pragma: allowlist secret
32
32
 
33
- const workflows = await client.workflow().list({ limit: 10 });
34
- const workflow = await client.workflow().get('wf-1');
35
- const executions = await client.execution().list({ workflowId: 'wf-1', status: 'success' });
33
+ const workflows = await client.workflows().list({ limit: 10 });
34
+ const workflow = await client.workflows().get('wf-1');
35
+ const executions = await client.executions().list({ workflowId: 'wf-1', status: 'success' });
36
36
  ```
37
37
 
38
38
  ## Why Use It
@@ -40,7 +40,7 @@ const executions = await client.execution().list({ workflowId: 'wf-1', status: '
40
40
  - Typed request/response objects for all n8n API endpoints
41
41
  - Cursor-based pagination built in
42
42
  - Automatic retry on transient server errors (5xx, 429, 408)
43
- - Consistent resource handle pattern across all resource types
43
+ - Consistent resource client pattern across all resource types
44
44
  - Supports both API key and Bearer token authentication
45
45
 
46
46
  ## Installation
@@ -64,38 +64,46 @@ const client = new N8nClient({
64
64
  });
65
65
 
66
66
  // List workflows
67
- const { data: workflows, nextCursor } = await client.workflow().list({ limit: 10 });
67
+ const { data: workflows, nextCursor } = await client.workflows().list({ limit: 10 });
68
68
 
69
69
  // Create a workflow
70
- const workflow = await client.workflow().create({
70
+ const workflow = await client.workflows().create({
71
71
  name: 'My Workflow',
72
72
  nodes: [{ name: 'Start', type: 'n8n-nodes-base.start', position: [250, 300] }],
73
73
  connections: {},
74
+ settings: {},
74
75
  });
75
76
 
76
77
  // Activate it
77
- await client.workflow().activate(workflow.id);
78
+ await client.workflows().activate(workflow.id);
78
79
 
79
80
  // List executions
80
- const { data: executions } = await client.execution().list({ workflowId: workflow.id });
81
+ const { data: executions } = await client.executions().list({ workflowId: workflow.id });
81
82
 
82
83
  // Create a credential
83
- const credential = await client.credential().create({
84
+ const credential = await client.credentials().create({
84
85
  name: 'My GitHub Token',
85
86
  type: 'githubApi',
86
87
  data: { accessToken: 'ghp_xxx' },
87
88
  });
88
89
 
89
90
  // Test the credential
90
- const testResult = await client.credential().test(credential.id);
91
+ const testResult = await client.credentials().test(credential.id);
91
92
 
92
93
  // Manage tags
93
- const tag = await client.tag().create({ name: 'production' });
94
- await client.workflow().updateTags(workflow.id, [{ id: tag.id }]);
94
+ const tag = await client.tags().create({ name: 'production' });
95
+ await client.workflows().updateTags(workflow.id, [{ id: tag.id }]);
95
96
 
96
97
  // Manage projects
97
- const projects = await client.project().list();
98
- await client.project().addMembers(projects.data[0].id, [{ userId: 'user-1', role: 'project:editor' }]);
98
+ const projects = await client.projects().list();
99
+ await client.projects().addMembers(projects.data[0].id, [{ userId: 'user-1', role: 'project:editor' }]);
100
+
101
+ // Opt into bound resource objects when you want instance methods
102
+ const project = await client.projects().getResource(projects.data[0].id);
103
+ await project.update({ name: 'Production' });
104
+
105
+ const workflow = await client.workflows().getResource('wf-1');
106
+ await workflow.activate();
99
107
 
100
108
  // Insights
101
109
  const summary = await client.insights().getSummary({
@@ -126,12 +134,131 @@ const client = new N8nClient({
126
134
  });
127
135
  ```
128
136
 
129
- ## Resource Handles
137
+ ## Resource Clients
138
+
139
+ Raw collection methods like `list()` and `get()` return plain API response objects.
140
+
141
+ Opt into bound resource objects when you want instance methods:
142
+
143
+ ```ts
144
+ const project = await client.projects().getResource('proj-1');
145
+ await project.update({ name: 'Ops' });
146
+
147
+ const workflows = await project.workflows().listResources();
148
+ await workflows.data[0]?.archive();
149
+
150
+ const folders = await project.folders().listResources({ take: '10' });
151
+ await folders.data[0]?.update({ name: 'Archived Workflows' });
152
+
153
+ const renamedFolder = await project.folders().updateResource('folder-id', { name: 'Archived Workflows' });
154
+
155
+ await project.variables().create({ key: 'API_URL', value: 'https://example.com' });
156
+
157
+ const createdWorkflow = await project.workflows().create({
158
+ name: 'Sync',
159
+ nodes: [],
160
+ connections: {},
161
+ settings: {},
162
+ });
163
+
164
+ const createdFolder = await project.folders().create({ name: 'Operations' });
165
+
166
+ const table = await project.dataTables().createResource({
167
+ name: 'Users',
168
+ columns: [{ name: 'email', type: 'string' }],
169
+ });
170
+
171
+ await table.createColumn({ name: 'active', type: 'boolean' });
172
+
173
+ const recentRuns = await project.executions().listResources({ limit: 10, status: 'success' });
174
+ await recentRuns.data[0]?.getTags();
175
+
176
+ const workflowResource = await client.workflows().getResource('wf-1');
177
+ const workflowRuns = await workflowResource.executions().listResources({ limit: 10 });
178
+ ```
179
+
180
+ Nested collections follow the same pairing pattern when the API can support it:
181
+
182
+ ```ts
183
+ const rawWorkflow = await project.workflows().get('wf-1');
184
+ const workflowResource = await project.workflows().getResource('wf-1');
185
+
186
+ const rawFolder = await project.folders().update('folder-id', { name: 'Archive' });
187
+ const folderResource = await project.folders().updateResource('folder-id', { name: 'Archive' });
188
+ ```
189
+
190
+ The same rule applies at the top-level clients: use `get()` for raw API objects and `getResource()` for bound instances.
191
+
192
+ The current resource layer covers projects, workflows, credentials, folders, tags, and users:
193
+
194
+ ```ts
195
+ const credential = await client.credentials().getResource('cred-1');
196
+ await credential.test();
197
+
198
+ const folder = await client.folders('proj-1').getResource('folder-1');
199
+ await folder.update({ name: 'Archived Workflows' });
200
+
201
+ const user = await client.users().getResource('user-1', { includeRole: true });
202
+ await user.changeRole('global:admin');
203
+ ```
204
+
205
+ It also includes resources for executions, variables, and data tables:
206
+
207
+ ```ts
208
+ const execution = await client.executions().getResource(42, { includeData: true });
209
+ await execution.stop();
210
+
211
+ const variable = await client.variables().getResource('var-1');
212
+ await variable.update({ key: 'API_URL', value: 'https://example.com' });
213
+
214
+ const dataTable = await client.dataTables().createResource({
215
+ name: 'Users',
216
+ columns: [{ name: 'email', type: 'string' }],
217
+ });
218
+
219
+ await dataTable.createColumn({ name: 'active', type: 'boolean' });
220
+ ```
221
+
222
+ Community packages use install/uninstall terminology instead of create/delete:
223
+
224
+ ```ts
225
+ const pkg = await client.communityPackages().installResource({
226
+ name: 'n8n-nodes-foo',
227
+ });
228
+
229
+ await pkg.update({ version: '2.0.0' });
230
+ await pkg.uninstall();
231
+ ```
232
+
233
+ When the create endpoint returns the created entity, the client also exposes `createResource()`:
234
+
235
+ ```ts
236
+ const workflow = await client.workflows().createResource({
237
+ name: 'Sync',
238
+ nodes: [],
239
+ connections: {},
240
+ settings: {},
241
+ });
242
+
243
+ const credential = await client.credentials().createResource({
244
+ name: 'Internal API Token',
245
+ type: 'httpHeaderAuth',
246
+ data: { name: 'Authorization', value: 'Bearer token' },
247
+ });
248
+ ```
249
+
250
+ Rule of thumb:
251
+
252
+ - `create()` mirrors the underlying API/client return type
253
+ - `createResource()` returns a bound resource instance when the API returns the created entity
254
+ - `updateResource()` returns a bound resource instance when the updated result can be represented honestly, either from the update response itself or from a verified follow-up fetch
255
+
256
+ `projects().createResource()` is intentionally not available because `POST /projects` returns no entity or identifier.
130
257
 
131
258
  ### Workflow
132
259
 
133
260
  ```ts
134
- const workflowApi = client.workflow();
261
+ const workflowApi = client.workflows();
135
262
 
136
263
  // List with filters
137
264
  const { data, nextCursor } = await workflowApi.list({
@@ -144,8 +271,20 @@ const { data, nextCursor } = await workflowApi.list({
144
271
 
145
272
  // CRUD
146
273
  const workflow = await workflowApi.get('wf-1');
147
- const created = await workflowApi.create({ name: 'New', nodes: [], connections: {} });
148
- const updated = await workflowApi.update('wf-1', { name: 'Updated' });
274
+ const workflowResource = await workflowApi.getResource('wf-1');
275
+ const created = await workflowApi.create({ name: 'New', nodes: [], connections: {}, settings: {} });
276
+ const updated = await workflowApi.update('wf-1', {
277
+ name: 'Updated',
278
+ nodes: workflow.nodes,
279
+ connections: workflow.connections,
280
+ settings: workflow.settings ?? {},
281
+ });
282
+ const updatedResource = await workflowApi.updateResource('wf-1', {
283
+ name: 'Updated Again',
284
+ nodes: [],
285
+ connections: {},
286
+ settings: {},
287
+ });
149
288
  await workflowApi.delete('wf-1');
150
289
 
151
290
  // Actions
@@ -161,12 +300,15 @@ await workflowApi.updateTags('wf-1', [{ id: 'tag-1' }]);
161
300
 
162
301
  // Versioning
163
302
  const version = await workflowApi.getVersion('wf-1', 'v-1');
303
+
304
+ // Nested executions
305
+ const runs = await workflowResource.executions().listResources({ limit: 10 });
164
306
  ```
165
307
 
166
308
  ### Execution
167
309
 
168
310
  ```ts
169
- const executionApi = client.execution();
311
+ const executionApi = client.executions();
170
312
 
171
313
  const { data } = await executionApi.list({ status: 'success', workflowId: 'wf-1' });
172
314
  const execution = await executionApi.get(1, { includeData: true });
@@ -182,7 +324,7 @@ await executionApi.updateTags(1, [{ id: 'tag-1' }]);
182
324
  ### Credential
183
325
 
184
326
  ```ts
185
- const credentialApi = client.credential();
327
+ const credentialApi = client.credentials();
186
328
 
187
329
  const { data } = await credentialApi.list({ limit: 10 });
188
330
  const credential = await credentialApi.get('c-1');
@@ -192,6 +334,7 @@ const created = await credentialApi.create({
192
334
  data: { accessToken: 'ghp_xxx' },
193
335
  });
194
336
  const updated = await credentialApi.update('c-1', { name: 'GitHub Updated' });
337
+ const updatedResource = await credentialApi.updateResource('c-1', { name: 'GitHub Updated Again' });
195
338
  await credentialApi.delete('c-1');
196
339
  await credentialApi.test('c-1');
197
340
  await credentialApi.transfer('c-1', 'proj-2');
@@ -201,19 +344,20 @@ const schema = await credentialApi.getSchema('githubApi');
201
344
  ### Tag
202
345
 
203
346
  ```ts
204
- const tagApi = client.tag();
347
+ const tagApi = client.tags();
205
348
 
206
349
  const { data } = await tagApi.list({ limit: 10 });
207
350
  const tag = await tagApi.get('t-1');
208
351
  const created = await tagApi.create({ name: 'production' });
209
352
  const updated = await tagApi.update('t-1', { name: 'prod' });
353
+ const updatedResource = await tagApi.updateResource('t-1', { name: 'production' });
210
354
  await tagApi.delete('t-1');
211
355
  ```
212
356
 
213
357
  ### User
214
358
 
215
359
  ```ts
216
- const userApi = client.user();
360
+ const userApi = client.users();
217
361
 
218
362
  const { data } = await userApi.list({ limit: 10 });
219
363
  const user = await userApi.get('u-1');
@@ -225,7 +369,7 @@ await userApi.changeRole('u-1', 'global:admin');
225
369
  ### Variable
226
370
 
227
371
  ```ts
228
- const variableApi = client.variable();
372
+ const variableApi = client.variables();
229
373
 
230
374
  const { data } = await variableApi.list({ projectId: 'proj-1' });
231
375
  await variableApi.create({ key: 'MY_VAR', value: 'hello', projectId: 'proj-1' });
@@ -236,7 +380,7 @@ await variableApi.delete('v-1');
236
380
  ### Project
237
381
 
238
382
  ```ts
239
- const projectApi = client.project();
383
+ const projectApi = client.projects();
240
384
 
241
385
  const { data } = await projectApi.list({ limit: 10 });
242
386
  await projectApi.create({ name: 'New Project' });
@@ -253,7 +397,7 @@ await projectApi.removeMember('p-1', 'u-1');
253
397
  ### DataTable
254
398
 
255
399
  ```ts
256
- const dataTableApi = client.dataTable();
400
+ const dataTableApi = client.dataTables();
257
401
 
258
402
  const { data } = await dataTableApi.list({ limit: 10 });
259
403
  const table = await dataTableApi.get('dt-1');
@@ -265,6 +409,7 @@ const created = await dataTableApi.create({
265
409
  ],
266
410
  });
267
411
  await dataTableApi.update('dt-1', { name: 'Users Updated' });
412
+ const updatedTable = await dataTableApi.updateResource('dt-1', { name: 'Users Final' });
268
413
  await dataTableApi.delete('dt-1');
269
414
 
270
415
  // Rows
@@ -281,23 +426,25 @@ await dataTableApi.deleteColumn('dt-1', 'col-1');
281
426
  ### Folder
282
427
 
283
428
  ```ts
284
- const folderApi = client.folder('proj-1');
429
+ const folderApi = client.folders('proj-1');
285
430
 
286
431
  const { data } = await folderApi.list({ take: '10' });
287
432
  const folder = await folderApi.get('f-1');
288
433
  const created = await folderApi.create({ name: 'My Folder' });
289
434
  const updated = await folderApi.update('f-1', { name: 'Renamed' });
435
+ const updatedResource = await folderApi.updateResource('f-1', { name: 'Renamed Again' });
290
436
  await folderApi.delete('f-1', 'f-2'); // transfer contents to f-2
291
437
  ```
292
438
 
293
439
  ### Community Package
294
440
 
295
441
  ```ts
296
- const pkgApi = client.communityPackage();
442
+ const pkgApi = client.communityPackages();
297
443
 
298
444
  const packages = await pkgApi.list();
299
445
  const installed = await pkgApi.install({ name: 'n8n-nodes-foo' });
300
446
  await pkgApi.update('n8n-nodes-foo', { version: '2.0.0' });
447
+ const updatedResource = await pkgApi.updateResource('n8n-nodes-foo', { version: '2.1.0' });
301
448
  await pkgApi.uninstall('n8n-nodes-foo');
302
449
  ```
303
450
 
@@ -340,7 +487,7 @@ const capabilities = await client.discover().get({ include: 'schemas' });
340
487
  import { HttpError } from '@egose/n8n-client';
341
488
 
342
489
  try {
343
- await client.workflow().get('nonexistent');
490
+ await client.workflows().get('nonexistent');
344
491
  } catch (error) {
345
492
  if (error instanceof HttpError) {
346
493
  console.log(error.status); // 404
@@ -356,23 +503,23 @@ Transient errors (408, 429, 5xx) are automatically retried up to 3 times with ex
356
503
 
357
504
  ### N8nClient
358
505
 
359
- | Method | Returns | Description |
360
- | -------------------- | ------------------------ | ------------------------------------------------ |
361
- | `workflow()` | `WorkflowHandle` | Workflow CRUD + activate/deactivate/archive/tags |
362
- | `execution()` | `ExecutionHandle` | Execution list/get/delete/retry/stop/tags |
363
- | `credential()` | `CredentialHandle` | Credential CRUD + test/transfer/schema |
364
- | `tag()` | `TagHandle` | Tag CRUD |
365
- | `user()` | `UserHandle` | User list/get/create/delete/changeRole |
366
- | `variable()` | `VariableHandle` | Variable CRUD |
367
- | `project()` | `ProjectHandle` | Project CRUD + member management |
368
- | `dataTable()` | `DataTableHandle` | DataTable CRUD + rows/columns |
369
- | `folder(projectId)` | `FolderHandle` | Folder CRUD scoped to project |
370
- | `communityPackage()` | `CommunityPackageHandle` | Package install/update/uninstall |
371
- | `audit()` | `AuditHandle` | Generate security audit |
372
- | `insights()` | `InsightsHandle` | Execution insights summary |
373
- | `sourceControl()` | `SourceControlHandle` | Git-based source control pull |
374
- | `discover()` | `DiscoverHandle` | API capability discovery |
375
- | `n8nPackage()` | `N8nPackageHandle` | Package export/import (beta) |
506
+ | Method | Returns | Description |
507
+ | --------------------- | ------------------------ | ------------------------------------------------ |
508
+ | `workflows()` | `WorkflowClient` | Workflow CRUD + activate/deactivate/archive/tags |
509
+ | `executions()` | `ExecutionClient` | Execution list/get/delete/retry/stop/tags |
510
+ | `credentials()` | `CredentialClient` | Credential CRUD + test/transfer/schema |
511
+ | `tags()` | `TagClient` | Tag CRUD |
512
+ | `users()` | `UserClient` | User list/get/create/delete/changeRole |
513
+ | `variables()` | `VariableClient` | Variable CRUD |
514
+ | `projects()` | `ProjectClient` | Project CRUD + member management |
515
+ | `dataTables()` | `DataTableClient` | DataTable CRUD + rows/columns |
516
+ | `folders(projectId)` | `FolderClient` | Folder CRUD scoped to project |
517
+ | `communityPackages()` | `CommunityPackageClient` | Package install/update/uninstall |
518
+ | `audit()` | `AuditClient` | Generate security audit |
519
+ | `insights()` | `InsightsClient` | Execution insights summary |
520
+ | `sourceControl()` | `SourceControlClient` | Git-based source control pull |
521
+ | `discover()` | `DiscoverClient` | API capability discovery |
522
+ | `n8nPackage()` | `N8nPackageClient` | Package export/import (beta) |
376
523
 
377
524
  ## Documentation
378
525
 
@@ -0,0 +1,38 @@
1
+ import {
2
+ BaseResource
3
+ } from "./chunk-TLBDBRPJ.js";
4
+
5
+ // src/resources/variable.ts
6
+ var VariableResource = class extends BaseResource {
7
+ constructor(variables, variable, params) {
8
+ super(variable);
9
+ this.variables = variables;
10
+ this.params = params;
11
+ }
12
+ variables;
13
+ params;
14
+ get id() {
15
+ return this.data.id;
16
+ }
17
+ get key() {
18
+ return this.data.key;
19
+ }
20
+ get value() {
21
+ return this.data.value;
22
+ }
23
+ async refresh() {
24
+ return this.replaceSnapshot((await this.variables.getResource(this.id, this.params)).data);
25
+ }
26
+ async update(data) {
27
+ await this.variables.update(this.id, data);
28
+ return this.mergeSnapshot(data);
29
+ }
30
+ async delete() {
31
+ await this.variables.delete(this.id);
32
+ }
33
+ };
34
+
35
+ export {
36
+ VariableResource
37
+ };
38
+ //# sourceMappingURL=chunk-2R6A6NJE.js.map
@@ -0,0 +1,95 @@
1
+ import {
2
+ ProjectResource
3
+ } from "./chunk-LTYQTCHM.js";
4
+ import {
5
+ VariableClient
6
+ } from "./chunk-HISH4ORK.js";
7
+ import {
8
+ WorkflowClient
9
+ } from "./chunk-54N6YD4R.js";
10
+ import {
11
+ DataTableClient
12
+ } from "./chunk-BQ2OTUXQ.js";
13
+ import {
14
+ ExecutionClient
15
+ } from "./chunk-C6W6ERQD.js";
16
+ import {
17
+ FolderClient
18
+ } from "./chunk-5DDMSYH2.js";
19
+ import {
20
+ HttpError
21
+ } from "./chunk-RMEH2UPX.js";
22
+ import {
23
+ BaseClient
24
+ } from "./chunk-Q6FSREKN.js";
25
+
26
+ // src/clients/project.ts
27
+ var ProjectClient = class extends BaseClient {
28
+ async list(params) {
29
+ return this.http.get("/projects", params);
30
+ }
31
+ async getResource(id) {
32
+ const project = await this.findProject(id);
33
+ if (!project) {
34
+ throw new HttpError(404, `Project not found: ${id}`, { id });
35
+ }
36
+ return this.createResource(project);
37
+ }
38
+ async listResources(params) {
39
+ const response = await this.list(params);
40
+ return {
41
+ data: response.data.map((project) => this.createResource(project)),
42
+ nextCursor: response.nextCursor
43
+ };
44
+ }
45
+ async create(data) {
46
+ await this.http.post("/projects", data);
47
+ }
48
+ async update(id, data) {
49
+ await this.http.put(`/projects/${id}`, data);
50
+ }
51
+ async delete(id) {
52
+ await this.http.delete(`/projects/${id}`);
53
+ }
54
+ async listMembers(projectId, params) {
55
+ return this.http.get(`/projects/${projectId}/users`, params);
56
+ }
57
+ async addMembers(projectId, relations) {
58
+ await this.http.post(`/projects/${projectId}/users`, { relations });
59
+ }
60
+ async removeMember(projectId, userId) {
61
+ await this.http.delete(`/projects/${projectId}/users/${userId}`);
62
+ }
63
+ async changeMemberRole(projectId, userId, role) {
64
+ const data = { role };
65
+ await this.http.patch(`/projects/${projectId}/users/${userId}`, data);
66
+ }
67
+ createResource(project) {
68
+ return new ProjectResource(
69
+ this,
70
+ new WorkflowClient(this.http),
71
+ new FolderClient(this.http, project.id),
72
+ new VariableClient(this.http),
73
+ new DataTableClient(this.http),
74
+ new ExecutionClient(this.http),
75
+ project
76
+ );
77
+ }
78
+ async findProject(id) {
79
+ let cursor;
80
+ do {
81
+ const response = await this.list(cursor ? { cursor } : void 0);
82
+ const project = response.data.find((entry) => entry.id === id);
83
+ if (project) {
84
+ return project;
85
+ }
86
+ cursor = response.nextCursor;
87
+ } while (cursor);
88
+ return void 0;
89
+ }
90
+ };
91
+
92
+ export {
93
+ ProjectClient
94
+ };
95
+ //# sourceMappingURL=chunk-3FDDCKAY.js.map
@@ -0,0 +1,98 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
+
3
+ var _chunkLC3TKRMXcjs = require('./chunk-LC3TKRMX.cjs');
4
+
5
+
6
+ var _chunkFIKGC2ELcjs = require('./chunk-FIKGC2EL.cjs');
7
+
8
+ // src/resources/workflow.ts
9
+ var WorkflowResource = class extends _chunkFIKGC2ELcjs.BaseResource {
10
+ constructor(workflows, executionsClient, workflow) {
11
+ super(workflow);
12
+ this.workflows = workflows;
13
+ this.executionsClient = executionsClient;
14
+ }
15
+
16
+
17
+ get id() {
18
+ return this.data.id;
19
+ }
20
+ get name() {
21
+ return this.data.name;
22
+ }
23
+ get active() {
24
+ return this.data.active;
25
+ }
26
+ get isArchived() {
27
+ return this.data.isArchived;
28
+ }
29
+ get versionId() {
30
+ return this.data.versionId;
31
+ }
32
+ async update(data) {
33
+ return this.replaceSnapshot(await this.workflows.update(this.id, data));
34
+ }
35
+ async delete() {
36
+ return this.workflows.delete(this.id);
37
+ }
38
+ async activate(data) {
39
+ return this.replaceSnapshot(await this.workflows.activate(this.id, data));
40
+ }
41
+ async deactivate() {
42
+ return this.replaceSnapshot(await this.workflows.deactivate(this.id));
43
+ }
44
+ async archive() {
45
+ return this.replaceSnapshot(await this.workflows.archive(this.id));
46
+ }
47
+ async unarchive() {
48
+ return this.replaceSnapshot(await this.workflows.unarchive(this.id));
49
+ }
50
+ async transfer(destinationProjectId) {
51
+ await this.workflows.transfer(this.id, destinationProjectId);
52
+ }
53
+ async getTags() {
54
+ return this.workflows.getTags(this.id);
55
+ }
56
+ async updateTags(tags) {
57
+ const updatedTags = await this.workflows.updateTags(this.id, tags);
58
+ this.mergeSnapshot({ tags: updatedTags });
59
+ return updatedTags;
60
+ }
61
+ async getVersion(versionId) {
62
+ return this.workflows.getVersion(this.id, versionId);
63
+ }
64
+ executions() {
65
+ return {
66
+ list: (params) => this.executionsClient.list({ ...params, workflowId: this.id }),
67
+ listResources: (params) => this.executionsClient.listResources({ ...params, workflowId: this.id }),
68
+ get: async (id, params) => {
69
+ if (!await this.hasExecutionInWorkflow(id)) {
70
+ throw new (0, _chunkLC3TKRMXcjs.HttpError)(404, `Execution not found in workflow: ${id}`, { id, workflowId: this.id });
71
+ }
72
+ return this.executionsClient.get(id, params);
73
+ },
74
+ getResource: async (id, params) => {
75
+ if (!await this.hasExecutionInWorkflow(id)) {
76
+ throw new (0, _chunkLC3TKRMXcjs.HttpError)(404, `Execution not found in workflow: ${id}`, { id, workflowId: this.id });
77
+ }
78
+ return this.executionsClient.getResource(id, params);
79
+ }
80
+ };
81
+ }
82
+ async hasExecutionInWorkflow(id) {
83
+ let cursor;
84
+ do {
85
+ const response = await this.executionsClient.list({ workflowId: this.id, cursor });
86
+ if (response.data.some((execution) => execution.id === id)) {
87
+ return true;
88
+ }
89
+ cursor = response.nextCursor;
90
+ } while (cursor);
91
+ return false;
92
+ }
93
+ };
94
+
95
+
96
+
97
+ exports.WorkflowResource = WorkflowResource;
98
+ //# sourceMappingURL=chunk-3YWWR6UD.cjs.map
@@ -0,0 +1,12 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});// src/clients/base.ts
2
+ var BaseClient = class {
3
+ constructor(http) {
4
+ this.http = http;
5
+ }
6
+
7
+ };
8
+
9
+
10
+
11
+ exports.BaseClient = BaseClient;
12
+ //# sourceMappingURL=chunk-4M2HGY3F.cjs.map