@egose/n8n-client 0.1.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.
- package/CHANGELOG.md +11 -0
- package/LICENSE +202 -0
- package/README.md +400 -0
- package/chunk-3SBD4UJS.js +15 -0
- package/chunk-4AODYIOB.cjs +36 -0
- package/chunk-4FXZT5HT.js +27 -0
- package/chunk-5DYA4LAX.cjs +110 -0
- package/chunk-5FIB7YIT.js +24 -0
- package/chunk-5PHEDSSO.cjs +27 -0
- package/chunk-5SY4KM4Q.js +15 -0
- package/chunk-7B5DLJYY.cjs +30 -0
- package/chunk-BWLFUF76.js +36 -0
- package/chunk-CES6KIG5.cjs +36 -0
- package/chunk-CUO2M75Z.js +29 -0
- package/chunk-DJCG37LZ.js +32 -0
- package/chunk-DK5NLZ6U.js +110 -0
- package/chunk-DURH6QOX.js +30 -0
- package/chunk-FHAZIAHR.js +15 -0
- package/chunk-FZX275Y3.js +24 -0
- package/chunk-I7NGIQIM.cjs +51 -0
- package/chunk-JR7A75YV.js +15 -0
- package/chunk-M7GX3MEN.cjs +15 -0
- package/chunk-MNL65GQB.js +51 -0
- package/chunk-NAZ5MLBL.cjs +32 -0
- package/chunk-NM6A7DX4.cjs +15 -0
- package/chunk-NSCKTOQK.cjs +15 -0
- package/chunk-OOMGKLOT.cjs +24 -0
- package/chunk-QLAAM7TG.cjs +27 -0
- package/chunk-QYAIEIF5.js +36 -0
- package/chunk-RATHO5IW.cjs +15 -0
- package/chunk-SK4VCTMD.js +27 -0
- package/chunk-TCPZWXKM.js +54 -0
- package/chunk-TRHGCMFH.cjs +29 -0
- package/chunk-U7PGEXKS.cjs +36 -0
- package/chunk-YPK2BDPO.cjs +54 -0
- package/chunk-ZAZJHB3O.cjs +24 -0
- package/chunk-ZEQL5KU2.js +36 -0
- package/handles/audit.cjs +7 -0
- package/handles/audit.d.cts +11 -0
- package/handles/audit.d.ts +11 -0
- package/handles/audit.js +7 -0
- package/handles/community-package.cjs +7 -0
- package/handles/community-package.d.cts +17 -0
- package/handles/community-package.d.ts +17 -0
- package/handles/community-package.js +7 -0
- package/handles/credential.cjs +7 -0
- package/handles/credential.d.cts +18 -0
- package/handles/credential.d.ts +18 -0
- package/handles/credential.js +7 -0
- package/handles/data-table.cjs +7 -0
- package/handles/data-table.d.cts +38 -0
- package/handles/data-table.d.ts +38 -0
- package/handles/data-table.js +7 -0
- package/handles/discover.cjs +7 -0
- package/handles/discover.d.cts +15 -0
- package/handles/discover.d.ts +15 -0
- package/handles/discover.js +7 -0
- package/handles/execution.cjs +7 -0
- package/handles/execution.d.cts +29 -0
- package/handles/execution.d.ts +29 -0
- package/handles/execution.js +7 -0
- package/handles/folder.cjs +7 -0
- package/handles/folder.d.cts +23 -0
- package/handles/folder.d.ts +23 -0
- package/handles/folder.js +7 -0
- package/handles/insights.cjs +7 -0
- package/handles/insights.d.cts +15 -0
- package/handles/insights.d.ts +15 -0
- package/handles/insights.js +7 -0
- package/handles/n8n-package.cjs +7 -0
- package/handles/n8n-package.d.cts +18 -0
- package/handles/n8n-package.d.ts +18 -0
- package/handles/n8n-package.js +7 -0
- package/handles/project.cjs +7 -0
- package/handles/project.d.cts +25 -0
- package/handles/project.d.ts +25 -0
- package/handles/project.js +7 -0
- package/handles/source-control.cjs +7 -0
- package/handles/source-control.d.cts +11 -0
- package/handles/source-control.d.ts +11 -0
- package/handles/source-control.js +7 -0
- package/handles/tag.cjs +7 -0
- package/handles/tag.d.cts +19 -0
- package/handles/tag.d.ts +19 -0
- package/handles/tag.js +7 -0
- package/handles/user.cjs +7 -0
- package/handles/user.d.cts +21 -0
- package/handles/user.d.ts +21 -0
- package/handles/user.js +7 -0
- package/handles/variable.cjs +7 -0
- package/handles/variable.d.cts +17 -0
- package/handles/variable.d.ts +17 -0
- package/handles/variable.js +7 -0
- package/handles/workflow.cjs +7 -0
- package/handles/workflow.d.cts +35 -0
- package/handles/workflow.d.ts +35 -0
- package/handles/workflow.js +7 -0
- package/http-client.cjs +10 -0
- package/http-client.d.cts +43 -0
- package/http-client.d.ts +43 -0
- package/http-client.js +10 -0
- package/index.cjs +127 -0
- package/index.d.cts +58 -0
- package/index.d.ts +58 -0
- package/index.js +127 -0
- package/package.json +42 -0
- package/pagination.cjs +1 -0
- package/pagination.d.cts +11 -0
- package/pagination.d.ts +11 -0
- package/pagination.js +1 -0
- package/types.cjs +1 -0
- package/types.d.cts +578 -0
- package/types.d.ts +578 -0
- package/types.js +1 -0
- package/utils/retry.cjs +7 -0
- package/utils/retry.d.cts +3 -0
- package/utils/retry.d.ts +3 -0
- package/utils/retry.js +7 -0
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
// src/handles/tag.ts
|
|
2
|
+
var TagHandle = class {
|
|
3
|
+
http;
|
|
4
|
+
constructor(http) {
|
|
5
|
+
this.http = http;
|
|
6
|
+
}
|
|
7
|
+
async list(params) {
|
|
8
|
+
return this.http.get("/tags", params);
|
|
9
|
+
}
|
|
10
|
+
async get(id) {
|
|
11
|
+
return this.http.get(`/tags/${id}`);
|
|
12
|
+
}
|
|
13
|
+
async create(data) {
|
|
14
|
+
return this.http.post("/tags", data);
|
|
15
|
+
}
|
|
16
|
+
async update(id, data) {
|
|
17
|
+
return this.http.put(`/tags/${id}`, data);
|
|
18
|
+
}
|
|
19
|
+
async delete(id) {
|
|
20
|
+
return this.http.delete(`/tags/${id}`);
|
|
21
|
+
}
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
export {
|
|
25
|
+
TagHandle
|
|
26
|
+
};
|
|
27
|
+
//# sourceMappingURL=chunk-4FXZT5HT.js.map
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
|
|
2
|
+
|
|
3
|
+
var _chunk7B5DLJYYcjs = require('./chunk-7B5DLJYY.cjs');
|
|
4
|
+
|
|
5
|
+
// src/http-client.ts
|
|
6
|
+
var HttpError = class extends Error {
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
constructor(status, message, data) {
|
|
10
|
+
super(message);
|
|
11
|
+
this.name = "HttpError";
|
|
12
|
+
this.status = status;
|
|
13
|
+
this.data = data;
|
|
14
|
+
}
|
|
15
|
+
};
|
|
16
|
+
var HttpClient = class {
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
constructor(config) {
|
|
21
|
+
if (!config.apiKey && !config.bearerToken) {
|
|
22
|
+
throw new Error("Either apiKey or bearerToken must be provided");
|
|
23
|
+
}
|
|
24
|
+
if (config.apiKey && config.bearerToken) {
|
|
25
|
+
throw new Error("Provide either apiKey or bearerToken, not both");
|
|
26
|
+
}
|
|
27
|
+
this.baseUrl = config.baseUrl.replace(/\/+$/, "");
|
|
28
|
+
this.apiKey = config.apiKey;
|
|
29
|
+
this.bearerToken = config.bearerToken;
|
|
30
|
+
}
|
|
31
|
+
buildHeaders() {
|
|
32
|
+
const headers = {
|
|
33
|
+
"Content-Type": "application/json",
|
|
34
|
+
Accept: "application/json"
|
|
35
|
+
};
|
|
36
|
+
if (this.bearerToken) {
|
|
37
|
+
headers["Authorization"] = `Bearer ${this.bearerToken}`;
|
|
38
|
+
} else if (this.apiKey) {
|
|
39
|
+
headers["X-N8N-API-KEY"] = this.apiKey;
|
|
40
|
+
}
|
|
41
|
+
return headers;
|
|
42
|
+
}
|
|
43
|
+
async parseResponseData(response) {
|
|
44
|
+
const contentType = response.headers.get("content-type") || "";
|
|
45
|
+
if (contentType.includes("application/json")) {
|
|
46
|
+
return response.json();
|
|
47
|
+
}
|
|
48
|
+
if (contentType.includes("application/gzip") || contentType.includes("application/octet-stream")) {
|
|
49
|
+
return response.arrayBuffer();
|
|
50
|
+
}
|
|
51
|
+
const text = await response.text();
|
|
52
|
+
try {
|
|
53
|
+
return JSON.parse(text);
|
|
54
|
+
} catch (e) {
|
|
55
|
+
return text;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
async request(options) {
|
|
59
|
+
const { method, path, body, query, headers: extraHeaders } = options;
|
|
60
|
+
const queryString = query ? "?" + Object.entries(query).filter(([, v]) => v !== void 0 && v !== null).map(([k, v]) => `${encodeURIComponent(k)}=${encodeURIComponent(String(v))}`).join("&") : "";
|
|
61
|
+
const url = `${this.baseUrl}/api/v1${path}${queryString}`;
|
|
62
|
+
const headers = {
|
|
63
|
+
...this.buildHeaders(),
|
|
64
|
+
...extraHeaders
|
|
65
|
+
};
|
|
66
|
+
const response = await _chunk7B5DLJYYcjs.retryTransientError.call(void 0, async () => {
|
|
67
|
+
const init = { method, headers };
|
|
68
|
+
if (body !== void 0 && method !== "GET") {
|
|
69
|
+
if (body instanceof FormData) {
|
|
70
|
+
init.body = body;
|
|
71
|
+
delete headers["Content-Type"];
|
|
72
|
+
} else {
|
|
73
|
+
init.body = JSON.stringify(body);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
const response2 = await fetch(url, init);
|
|
77
|
+
if (!response2.ok && response2.status !== 204) {
|
|
78
|
+
const data = await this.parseResponseData(response2);
|
|
79
|
+
const message = _optionalChain([data, 'optionalAccess', _ => _.message]) || `HTTP ${response2.status}`;
|
|
80
|
+
throw new HttpError(response2.status, message, data);
|
|
81
|
+
}
|
|
82
|
+
return response2;
|
|
83
|
+
});
|
|
84
|
+
if (response.status === 204) {
|
|
85
|
+
return void 0;
|
|
86
|
+
}
|
|
87
|
+
return await this.parseResponseData(response);
|
|
88
|
+
}
|
|
89
|
+
async get(path, query, headers) {
|
|
90
|
+
return this.request({ method: "GET", path, query, headers });
|
|
91
|
+
}
|
|
92
|
+
async post(path, body, query, headers) {
|
|
93
|
+
return this.request({ method: "POST", path, body, query, headers });
|
|
94
|
+
}
|
|
95
|
+
async put(path, body, query, headers) {
|
|
96
|
+
return this.request({ method: "PUT", path, body, query, headers });
|
|
97
|
+
}
|
|
98
|
+
async patch(path, body, query, headers) {
|
|
99
|
+
return this.request({ method: "PATCH", path, body, query, headers });
|
|
100
|
+
}
|
|
101
|
+
async delete(path, query, headers) {
|
|
102
|
+
return this.request({ method: "DELETE", path, query, headers });
|
|
103
|
+
}
|
|
104
|
+
};
|
|
105
|
+
|
|
106
|
+
|
|
107
|
+
|
|
108
|
+
|
|
109
|
+
exports.HttpError = HttpError; exports.HttpClient = HttpClient;
|
|
110
|
+
//# sourceMappingURL=chunk-5DYA4LAX.cjs.map
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
// src/handles/community-package.ts
|
|
2
|
+
var CommunityPackageHandle = class {
|
|
3
|
+
http;
|
|
4
|
+
constructor(http) {
|
|
5
|
+
this.http = http;
|
|
6
|
+
}
|
|
7
|
+
async list() {
|
|
8
|
+
return this.http.get("/community-packages");
|
|
9
|
+
}
|
|
10
|
+
async install(data) {
|
|
11
|
+
return this.http.post("/community-packages", data);
|
|
12
|
+
}
|
|
13
|
+
async update(name, data) {
|
|
14
|
+
return this.http.patch(`/community-packages/${name}`, data);
|
|
15
|
+
}
|
|
16
|
+
async uninstall(name) {
|
|
17
|
+
await this.http.delete(`/community-packages/${name}`);
|
|
18
|
+
}
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
export {
|
|
22
|
+
CommunityPackageHandle
|
|
23
|
+
};
|
|
24
|
+
//# sourceMappingURL=chunk-5FIB7YIT.js.map
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});// src/handles/tag.ts
|
|
2
|
+
var TagHandle = class {
|
|
3
|
+
|
|
4
|
+
constructor(http) {
|
|
5
|
+
this.http = http;
|
|
6
|
+
}
|
|
7
|
+
async list(params) {
|
|
8
|
+
return this.http.get("/tags", params);
|
|
9
|
+
}
|
|
10
|
+
async get(id) {
|
|
11
|
+
return this.http.get(`/tags/${id}`);
|
|
12
|
+
}
|
|
13
|
+
async create(data) {
|
|
14
|
+
return this.http.post("/tags", data);
|
|
15
|
+
}
|
|
16
|
+
async update(id, data) {
|
|
17
|
+
return this.http.put(`/tags/${id}`, data);
|
|
18
|
+
}
|
|
19
|
+
async delete(id) {
|
|
20
|
+
return this.http.delete(`/tags/${id}`);
|
|
21
|
+
}
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
exports.TagHandle = TagHandle;
|
|
27
|
+
//# sourceMappingURL=chunk-5PHEDSSO.cjs.map
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
// src/handles/insights.ts
|
|
2
|
+
var InsightsHandle = class {
|
|
3
|
+
http;
|
|
4
|
+
constructor(http) {
|
|
5
|
+
this.http = http;
|
|
6
|
+
}
|
|
7
|
+
async getSummary(params) {
|
|
8
|
+
return this.http.get("/insights/summary", params);
|
|
9
|
+
}
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
export {
|
|
13
|
+
InsightsHandle
|
|
14
|
+
};
|
|
15
|
+
//# sourceMappingURL=chunk-5SY4KM4Q.js.map
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});// src/utils/retry.ts
|
|
2
|
+
var RETRYABLE_STATUS_CODES = /* @__PURE__ */ new Set([408, 429, 500, 502, 503, 504]);
|
|
3
|
+
function isTransientError(error) {
|
|
4
|
+
if (error instanceof Error && "status" in error) {
|
|
5
|
+
return RETRYABLE_STATUS_CODES.has(error.status);
|
|
6
|
+
}
|
|
7
|
+
if (error instanceof TypeError && error.message.includes("fetch")) {
|
|
8
|
+
return true;
|
|
9
|
+
}
|
|
10
|
+
return false;
|
|
11
|
+
}
|
|
12
|
+
async function retryTransientError(operation, attempts = 3) {
|
|
13
|
+
for (let attempt = 0; attempt < attempts; attempt++) {
|
|
14
|
+
try {
|
|
15
|
+
return await operation();
|
|
16
|
+
} catch (error) {
|
|
17
|
+
if (!isTransientError(error) || attempt === attempts - 1) {
|
|
18
|
+
throw error;
|
|
19
|
+
}
|
|
20
|
+
const delay = Math.min(1e3 * 2 ** attempt, 1e4);
|
|
21
|
+
await new Promise((resolve) => setTimeout(resolve, delay));
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
throw new Error("Unreachable");
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
exports.retryTransientError = retryTransientError;
|
|
30
|
+
//# sourceMappingURL=chunk-7B5DLJYY.cjs.map
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
// src/handles/credential.ts
|
|
2
|
+
var CredentialHandle = class {
|
|
3
|
+
http;
|
|
4
|
+
constructor(http) {
|
|
5
|
+
this.http = http;
|
|
6
|
+
}
|
|
7
|
+
async list(params) {
|
|
8
|
+
return this.http.get("/credentials", params);
|
|
9
|
+
}
|
|
10
|
+
async get(id) {
|
|
11
|
+
return this.http.get(`/credentials/${id}`);
|
|
12
|
+
}
|
|
13
|
+
async create(data) {
|
|
14
|
+
return this.http.post("/credentials", data);
|
|
15
|
+
}
|
|
16
|
+
async update(id, data) {
|
|
17
|
+
return this.http.patch(`/credentials/${id}`, data);
|
|
18
|
+
}
|
|
19
|
+
async delete(id) {
|
|
20
|
+
return this.http.delete(`/credentials/${id}`);
|
|
21
|
+
}
|
|
22
|
+
async test(id) {
|
|
23
|
+
return this.http.post(`/credentials/${id}/test`);
|
|
24
|
+
}
|
|
25
|
+
async transfer(id, destinationProjectId) {
|
|
26
|
+
await this.http.put(`/credentials/${id}/transfer`, { destinationProjectId });
|
|
27
|
+
}
|
|
28
|
+
async getSchema(credentialTypeName) {
|
|
29
|
+
return this.http.get(`/credentials/schema/${credentialTypeName}`);
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
export {
|
|
34
|
+
CredentialHandle
|
|
35
|
+
};
|
|
36
|
+
//# sourceMappingURL=chunk-BWLFUF76.js.map
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});// src/handles/credential.ts
|
|
2
|
+
var CredentialHandle = class {
|
|
3
|
+
|
|
4
|
+
constructor(http) {
|
|
5
|
+
this.http = http;
|
|
6
|
+
}
|
|
7
|
+
async list(params) {
|
|
8
|
+
return this.http.get("/credentials", params);
|
|
9
|
+
}
|
|
10
|
+
async get(id) {
|
|
11
|
+
return this.http.get(`/credentials/${id}`);
|
|
12
|
+
}
|
|
13
|
+
async create(data) {
|
|
14
|
+
return this.http.post("/credentials", data);
|
|
15
|
+
}
|
|
16
|
+
async update(id, data) {
|
|
17
|
+
return this.http.patch(`/credentials/${id}`, data);
|
|
18
|
+
}
|
|
19
|
+
async delete(id) {
|
|
20
|
+
return this.http.delete(`/credentials/${id}`);
|
|
21
|
+
}
|
|
22
|
+
async test(id) {
|
|
23
|
+
return this.http.post(`/credentials/${id}/test`);
|
|
24
|
+
}
|
|
25
|
+
async transfer(id, destinationProjectId) {
|
|
26
|
+
await this.http.put(`/credentials/${id}/transfer`, { destinationProjectId });
|
|
27
|
+
}
|
|
28
|
+
async getSchema(credentialTypeName) {
|
|
29
|
+
return this.http.get(`/credentials/schema/${credentialTypeName}`);
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
exports.CredentialHandle = CredentialHandle;
|
|
36
|
+
//# sourceMappingURL=chunk-CES6KIG5.cjs.map
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
// src/handles/n8n-package.ts
|
|
2
|
+
var N8nPackageHandle = class {
|
|
3
|
+
http;
|
|
4
|
+
constructor(http) {
|
|
5
|
+
this.http = http;
|
|
6
|
+
}
|
|
7
|
+
async exportWorkflows(data) {
|
|
8
|
+
return this.http.post("/n8n-packages/export", data, void 0, { Accept: "application/gzip" });
|
|
9
|
+
}
|
|
10
|
+
async importPackage(pkg, options) {
|
|
11
|
+
const formData = new FormData();
|
|
12
|
+
formData.append("package", pkg);
|
|
13
|
+
if (options?.projectId) formData.append("projectId", options.projectId);
|
|
14
|
+
if (options?.folderId) formData.append("folderId", options.folderId);
|
|
15
|
+
if (options?.credentialMatchingMode) formData.append("credentialMatchingMode", options.credentialMatchingMode);
|
|
16
|
+
if (options?.credentialMissingMode) formData.append("credentialMissingMode", options.credentialMissingMode);
|
|
17
|
+
formData.append("workflowConflictPolicy", options.workflowConflictPolicy);
|
|
18
|
+
return this.http.request({
|
|
19
|
+
method: "POST",
|
|
20
|
+
path: "/n8n-packages/import",
|
|
21
|
+
body: formData
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
export {
|
|
27
|
+
N8nPackageHandle
|
|
28
|
+
};
|
|
29
|
+
//# sourceMappingURL=chunk-CUO2M75Z.js.map
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
// src/handles/folder.ts
|
|
2
|
+
var FolderHandle = class {
|
|
3
|
+
http;
|
|
4
|
+
projectId;
|
|
5
|
+
constructor(http, projectId) {
|
|
6
|
+
this.http = http;
|
|
7
|
+
this.projectId = projectId;
|
|
8
|
+
}
|
|
9
|
+
async list(params) {
|
|
10
|
+
return this.http.get(`/projects/${this.projectId}/folders`, params);
|
|
11
|
+
}
|
|
12
|
+
async get(folderId) {
|
|
13
|
+
return this.http.get(`/projects/${this.projectId}/folders/${folderId}`);
|
|
14
|
+
}
|
|
15
|
+
async create(data) {
|
|
16
|
+
return this.http.post(`/projects/${this.projectId}/folders`, data);
|
|
17
|
+
}
|
|
18
|
+
async update(folderId, data) {
|
|
19
|
+
return this.http.patch(`/projects/${this.projectId}/folders/${folderId}`, data);
|
|
20
|
+
}
|
|
21
|
+
async delete(folderId, transferToFolderId) {
|
|
22
|
+
await this.http.delete(
|
|
23
|
+
`/projects/${this.projectId}/folders/${folderId}`,
|
|
24
|
+
transferToFolderId ? { transferToFolderId } : void 0
|
|
25
|
+
);
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
export {
|
|
30
|
+
FolderHandle
|
|
31
|
+
};
|
|
32
|
+
//# sourceMappingURL=chunk-DJCG37LZ.js.map
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
import {
|
|
2
|
+
retryTransientError
|
|
3
|
+
} from "./chunk-DURH6QOX.js";
|
|
4
|
+
|
|
5
|
+
// src/http-client.ts
|
|
6
|
+
var HttpError = class extends Error {
|
|
7
|
+
status;
|
|
8
|
+
data;
|
|
9
|
+
constructor(status, message, data) {
|
|
10
|
+
super(message);
|
|
11
|
+
this.name = "HttpError";
|
|
12
|
+
this.status = status;
|
|
13
|
+
this.data = data;
|
|
14
|
+
}
|
|
15
|
+
};
|
|
16
|
+
var HttpClient = class {
|
|
17
|
+
baseUrl;
|
|
18
|
+
apiKey;
|
|
19
|
+
bearerToken;
|
|
20
|
+
constructor(config) {
|
|
21
|
+
if (!config.apiKey && !config.bearerToken) {
|
|
22
|
+
throw new Error("Either apiKey or bearerToken must be provided");
|
|
23
|
+
}
|
|
24
|
+
if (config.apiKey && config.bearerToken) {
|
|
25
|
+
throw new Error("Provide either apiKey or bearerToken, not both");
|
|
26
|
+
}
|
|
27
|
+
this.baseUrl = config.baseUrl.replace(/\/+$/, "");
|
|
28
|
+
this.apiKey = config.apiKey;
|
|
29
|
+
this.bearerToken = config.bearerToken;
|
|
30
|
+
}
|
|
31
|
+
buildHeaders() {
|
|
32
|
+
const headers = {
|
|
33
|
+
"Content-Type": "application/json",
|
|
34
|
+
Accept: "application/json"
|
|
35
|
+
};
|
|
36
|
+
if (this.bearerToken) {
|
|
37
|
+
headers["Authorization"] = `Bearer ${this.bearerToken}`;
|
|
38
|
+
} else if (this.apiKey) {
|
|
39
|
+
headers["X-N8N-API-KEY"] = this.apiKey;
|
|
40
|
+
}
|
|
41
|
+
return headers;
|
|
42
|
+
}
|
|
43
|
+
async parseResponseData(response) {
|
|
44
|
+
const contentType = response.headers.get("content-type") || "";
|
|
45
|
+
if (contentType.includes("application/json")) {
|
|
46
|
+
return response.json();
|
|
47
|
+
}
|
|
48
|
+
if (contentType.includes("application/gzip") || contentType.includes("application/octet-stream")) {
|
|
49
|
+
return response.arrayBuffer();
|
|
50
|
+
}
|
|
51
|
+
const text = await response.text();
|
|
52
|
+
try {
|
|
53
|
+
return JSON.parse(text);
|
|
54
|
+
} catch {
|
|
55
|
+
return text;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
async request(options) {
|
|
59
|
+
const { method, path, body, query, headers: extraHeaders } = options;
|
|
60
|
+
const queryString = query ? "?" + Object.entries(query).filter(([, v]) => v !== void 0 && v !== null).map(([k, v]) => `${encodeURIComponent(k)}=${encodeURIComponent(String(v))}`).join("&") : "";
|
|
61
|
+
const url = `${this.baseUrl}/api/v1${path}${queryString}`;
|
|
62
|
+
const headers = {
|
|
63
|
+
...this.buildHeaders(),
|
|
64
|
+
...extraHeaders
|
|
65
|
+
};
|
|
66
|
+
const response = await retryTransientError(async () => {
|
|
67
|
+
const init = { method, headers };
|
|
68
|
+
if (body !== void 0 && method !== "GET") {
|
|
69
|
+
if (body instanceof FormData) {
|
|
70
|
+
init.body = body;
|
|
71
|
+
delete headers["Content-Type"];
|
|
72
|
+
} else {
|
|
73
|
+
init.body = JSON.stringify(body);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
const response2 = await fetch(url, init);
|
|
77
|
+
if (!response2.ok && response2.status !== 204) {
|
|
78
|
+
const data = await this.parseResponseData(response2);
|
|
79
|
+
const message = data?.message || `HTTP ${response2.status}`;
|
|
80
|
+
throw new HttpError(response2.status, message, data);
|
|
81
|
+
}
|
|
82
|
+
return response2;
|
|
83
|
+
});
|
|
84
|
+
if (response.status === 204) {
|
|
85
|
+
return void 0;
|
|
86
|
+
}
|
|
87
|
+
return await this.parseResponseData(response);
|
|
88
|
+
}
|
|
89
|
+
async get(path, query, headers) {
|
|
90
|
+
return this.request({ method: "GET", path, query, headers });
|
|
91
|
+
}
|
|
92
|
+
async post(path, body, query, headers) {
|
|
93
|
+
return this.request({ method: "POST", path, body, query, headers });
|
|
94
|
+
}
|
|
95
|
+
async put(path, body, query, headers) {
|
|
96
|
+
return this.request({ method: "PUT", path, body, query, headers });
|
|
97
|
+
}
|
|
98
|
+
async patch(path, body, query, headers) {
|
|
99
|
+
return this.request({ method: "PATCH", path, body, query, headers });
|
|
100
|
+
}
|
|
101
|
+
async delete(path, query, headers) {
|
|
102
|
+
return this.request({ method: "DELETE", path, query, headers });
|
|
103
|
+
}
|
|
104
|
+
};
|
|
105
|
+
|
|
106
|
+
export {
|
|
107
|
+
HttpError,
|
|
108
|
+
HttpClient
|
|
109
|
+
};
|
|
110
|
+
//# sourceMappingURL=chunk-DK5NLZ6U.js.map
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
// src/utils/retry.ts
|
|
2
|
+
var RETRYABLE_STATUS_CODES = /* @__PURE__ */ new Set([408, 429, 500, 502, 503, 504]);
|
|
3
|
+
function isTransientError(error) {
|
|
4
|
+
if (error instanceof Error && "status" in error) {
|
|
5
|
+
return RETRYABLE_STATUS_CODES.has(error.status);
|
|
6
|
+
}
|
|
7
|
+
if (error instanceof TypeError && error.message.includes("fetch")) {
|
|
8
|
+
return true;
|
|
9
|
+
}
|
|
10
|
+
return false;
|
|
11
|
+
}
|
|
12
|
+
async function retryTransientError(operation, attempts = 3) {
|
|
13
|
+
for (let attempt = 0; attempt < attempts; attempt++) {
|
|
14
|
+
try {
|
|
15
|
+
return await operation();
|
|
16
|
+
} catch (error) {
|
|
17
|
+
if (!isTransientError(error) || attempt === attempts - 1) {
|
|
18
|
+
throw error;
|
|
19
|
+
}
|
|
20
|
+
const delay = Math.min(1e3 * 2 ** attempt, 1e4);
|
|
21
|
+
await new Promise((resolve) => setTimeout(resolve, delay));
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
throw new Error("Unreachable");
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export {
|
|
28
|
+
retryTransientError
|
|
29
|
+
};
|
|
30
|
+
//# sourceMappingURL=chunk-DURH6QOX.js.map
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
// src/handles/discover.ts
|
|
2
|
+
var DiscoverHandle = class {
|
|
3
|
+
http;
|
|
4
|
+
constructor(http) {
|
|
5
|
+
this.http = http;
|
|
6
|
+
}
|
|
7
|
+
async get(params) {
|
|
8
|
+
return this.http.get("/discover", params);
|
|
9
|
+
}
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
export {
|
|
13
|
+
DiscoverHandle
|
|
14
|
+
};
|
|
15
|
+
//# sourceMappingURL=chunk-FHAZIAHR.js.map
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
// src/handles/variable.ts
|
|
2
|
+
var VariableHandle = class {
|
|
3
|
+
http;
|
|
4
|
+
constructor(http) {
|
|
5
|
+
this.http = http;
|
|
6
|
+
}
|
|
7
|
+
async list(params) {
|
|
8
|
+
return this.http.get("/variables", params);
|
|
9
|
+
}
|
|
10
|
+
async create(data) {
|
|
11
|
+
await this.http.post("/variables", data);
|
|
12
|
+
}
|
|
13
|
+
async update(id, data) {
|
|
14
|
+
await this.http.put(`/variables/${id}`, data);
|
|
15
|
+
}
|
|
16
|
+
async delete(id) {
|
|
17
|
+
await this.http.delete(`/variables/${id}`);
|
|
18
|
+
}
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
export {
|
|
22
|
+
VariableHandle
|
|
23
|
+
};
|
|
24
|
+
//# sourceMappingURL=chunk-FZX275Y3.js.map
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});// src/handles/workflow.ts
|
|
2
|
+
var WorkflowHandle = class {
|
|
3
|
+
|
|
4
|
+
constructor(http) {
|
|
5
|
+
this.http = http;
|
|
6
|
+
}
|
|
7
|
+
async list(params) {
|
|
8
|
+
return this.http.get("/workflows", params);
|
|
9
|
+
}
|
|
10
|
+
async get(id, params) {
|
|
11
|
+
return this.http.get(`/workflows/${id}`, params);
|
|
12
|
+
}
|
|
13
|
+
async create(data) {
|
|
14
|
+
return this.http.post("/workflows", data);
|
|
15
|
+
}
|
|
16
|
+
async update(id, data) {
|
|
17
|
+
return this.http.put(`/workflows/${id}`, data);
|
|
18
|
+
}
|
|
19
|
+
async delete(id) {
|
|
20
|
+
return this.http.delete(`/workflows/${id}`);
|
|
21
|
+
}
|
|
22
|
+
async activate(id, data) {
|
|
23
|
+
return this.http.post(`/workflows/${id}/activate`, data);
|
|
24
|
+
}
|
|
25
|
+
async deactivate(id) {
|
|
26
|
+
return this.http.post(`/workflows/${id}/deactivate`);
|
|
27
|
+
}
|
|
28
|
+
async archive(id) {
|
|
29
|
+
return this.http.post(`/workflows/${id}/archive`);
|
|
30
|
+
}
|
|
31
|
+
async unarchive(id) {
|
|
32
|
+
return this.http.post(`/workflows/${id}/unarchive`);
|
|
33
|
+
}
|
|
34
|
+
async transfer(id, destinationProjectId) {
|
|
35
|
+
await this.http.put(`/workflows/${id}/transfer`, { destinationProjectId });
|
|
36
|
+
}
|
|
37
|
+
async getTags(id) {
|
|
38
|
+
return this.http.get(`/workflows/${id}/tags`);
|
|
39
|
+
}
|
|
40
|
+
async updateTags(id, tags) {
|
|
41
|
+
return this.http.put(`/workflows/${id}/tags`, tags);
|
|
42
|
+
}
|
|
43
|
+
async getVersion(id, versionId) {
|
|
44
|
+
return this.http.get(`/workflows/${id}/${versionId}`);
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
exports.WorkflowHandle = WorkflowHandle;
|
|
51
|
+
//# sourceMappingURL=chunk-I7NGIQIM.cjs.map
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
// src/handles/source-control.ts
|
|
2
|
+
var SourceControlHandle = class {
|
|
3
|
+
http;
|
|
4
|
+
constructor(http) {
|
|
5
|
+
this.http = http;
|
|
6
|
+
}
|
|
7
|
+
async pull(data) {
|
|
8
|
+
return this.http.post("/source-control/pull", data);
|
|
9
|
+
}
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
export {
|
|
13
|
+
SourceControlHandle
|
|
14
|
+
};
|
|
15
|
+
//# sourceMappingURL=chunk-JR7A75YV.js.map
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});// src/handles/audit.ts
|
|
2
|
+
var AuditHandle = class {
|
|
3
|
+
|
|
4
|
+
constructor(http) {
|
|
5
|
+
this.http = http;
|
|
6
|
+
}
|
|
7
|
+
async generate(data) {
|
|
8
|
+
return this.http.post("/audit", data);
|
|
9
|
+
}
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
exports.AuditHandle = AuditHandle;
|
|
15
|
+
//# sourceMappingURL=chunk-M7GX3MEN.cjs.map
|