@distilled.cloud/n8n 0.0.0 → 1.0.0-rc.22
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/LICENSE +201 -0
- package/README.md +89 -4
- package/lib/.lazy.json +1 -0
- package/lib/_bundle/lazy.js +4 -0
- package/lib/_bundle/sdk.js +2 -0
- package/lib/_bundle/sdk.js.map +1 -0
- package/lib/credentials.d.ts +27 -0
- package/lib/credentials.d.ts.map +1 -0
- package/lib/credentials.js +1 -0
- package/lib/errors.d.ts +47 -0
- package/lib/errors.d.ts.map +1 -0
- package/lib/errors.js +1 -0
- package/lib/index.d.ts +27 -0
- package/lib/index.d.ts.map +1 -0
- package/lib/index.js +8 -0
- package/lib/index.lazy.js +8 -0
- package/lib/index.lazy.js.map +1 -0
- package/lib/pagination.d.ts +11 -0
- package/lib/pagination.d.ts.map +1 -0
- package/lib/pagination.js +1 -0
- package/lib/protocol.d.ts +19 -0
- package/lib/protocol.d.ts.map +1 -0
- package/lib/protocol.js +1 -0
- package/lib/retry.d.ts +50 -0
- package/lib/retry.d.ts.map +1 -0
- package/lib/retry.js +1 -0
- package/lib/services/index.d.ts +2 -0
- package/lib/services/index.d.ts.map +1 -0
- package/lib/services/index.js +1 -0
- package/lib/services/n8n.d.ts +10867 -0
- package/lib/services/n8n.d.ts.map +1 -0
- package/lib/services/n8n.js +273 -0
- package/lib/services/n8n.js.map +1 -0
- package/lib/services.lazy/index.js +3 -0
- package/lib/services.lazy/n8n.js +4 -0
- package/lib/traits.d.ts +11 -0
- package/lib/traits.d.ts.map +1 -0
- package/lib/traits.js +1 -0
- package/package.json +84 -2
- package/src/credentials.ts +67 -0
- package/src/errors.ts +60 -0
- package/src/index.ts +28 -0
- package/src/pagination.ts +10 -0
- package/src/protocol.ts +48 -0
- package/src/retry.ts +69 -0
- package/src/services/index.ts +2 -0
- package/src/services/n8n.ts +22131 -0
- package/src/traits.ts +48 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright [yyyy] [name of copyright owner]
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
package/README.md
CHANGED
|
@@ -1,9 +1,94 @@
|
|
|
1
1
|
# @distilled.cloud/n8n
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Effect-native [n8n Public API](https://docs.n8n.io/api/) SDK, generated from
|
|
4
|
+
n8n's own OpenAPI description,
|
|
5
|
+
[`n8n-openapi-dfb.pages.dev/v1/openapi.yml`](https://n8n-openapi-dfb.pages.dev/v1/openapi.yml).
|
|
6
|
+
n8n's release workflow builds that document from the API's routes and
|
|
7
|
+
publishes it, and the [API reference](https://docs.n8n.io/api/api-reference/)
|
|
8
|
+
on docs.n8n.io loads it.
|
|
4
9
|
|
|
5
|
-
|
|
10
|
+
Every operation of the spec is here, exported from the package root:
|
|
11
|
+
workflows (create, update, publish, archive, transfer, history, tags, test
|
|
12
|
+
runs), executions, credentials, data tables and their rows, projects and
|
|
13
|
+
folders, tags, variables, users and roles, agents, source control,
|
|
14
|
+
promotions, packages, security audit, insights and the instance settings
|
|
15
|
+
(LDAP, SAML, OIDC, log streaming, OpenTelemetry, rate limits). The three
|
|
16
|
+
operations the spec marks deprecated (`activateWorkflow`,
|
|
17
|
+
`deactivateWorkflow` and the old `GET /workflows/{id}/{versionId}`) are left
|
|
18
|
+
out: use `publishWorkflow`, `unpublishWorkflow` and `getWorkflowVersion`.
|
|
6
19
|
|
|
7
|
-
|
|
20
|
+
## Installation
|
|
8
21
|
|
|
9
|
-
|
|
22
|
+
```bash
|
|
23
|
+
npm install @distilled.cloud/n8n effect
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
## Quick start
|
|
27
|
+
|
|
28
|
+
Publish a workflow by name, then list its failed executions.
|
|
29
|
+
|
|
30
|
+
```ts
|
|
31
|
+
import { Effect, Layer, Stream } from "effect";
|
|
32
|
+
import * as FetchHttpClient from "effect/http/FetchHttpClient";
|
|
33
|
+
import * as N8n from "@distilled.cloud/n8n";
|
|
34
|
+
|
|
35
|
+
const program = Effect.gen(function* () {
|
|
36
|
+
// 1. Find the workflow, fetching more pages as the stream needs them.
|
|
37
|
+
const workflows = yield* N8n.getWorkflows
|
|
38
|
+
.items({ name: "Nightly sync" })
|
|
39
|
+
.pipe(Stream.runCollect);
|
|
40
|
+
const workflow = workflows[0];
|
|
41
|
+
if (workflow === undefined) return yield* Effect.logWarning("No workflow named Nightly sync");
|
|
42
|
+
|
|
43
|
+
// 2. Publish its current version, so its triggers run.
|
|
44
|
+
const published = yield* N8n.publishWorkflow({ workflowId: workflow.id });
|
|
45
|
+
yield* Effect.log(`Published ${published.name} (${published.activeVersionId})`);
|
|
46
|
+
|
|
47
|
+
// 3. List the executions that failed.
|
|
48
|
+
const failed = yield* N8n.getExecutions
|
|
49
|
+
.items({ workflowId: workflow.id, status: "error", limit: 50 })
|
|
50
|
+
.pipe(Stream.runCollect);
|
|
51
|
+
for (const execution of failed) {
|
|
52
|
+
yield* Effect.log(`Execution ${execution.id} failed at ${execution.stoppedAt}`);
|
|
53
|
+
}
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
const Live = Layer.mergeAll(FetchHttpClient.layer, N8n.CredentialsFromEnv);
|
|
57
|
+
|
|
58
|
+
program.pipe(Effect.provide(Live), Effect.runPromise);
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
## Auth
|
|
62
|
+
|
|
63
|
+
`N8N_API_KEY` is sent as the `X-N8N-API-KEY` header. Create the key in your
|
|
64
|
+
instance under Settings → n8n API; its scopes decide which operations it
|
|
65
|
+
may call.
|
|
66
|
+
|
|
67
|
+
`N8N_BASE_URL` is the origin of your instance, such as
|
|
68
|
+
`https://acme.app.n8n.cloud` or `http://localhost:5678`. It has no default:
|
|
69
|
+
every n8n Cloud or self-hosted instance has its own. The SDK adds `/api/v1`.
|
|
70
|
+
`N8n.fromApiKey({ apiKey: Redacted.make(key), baseUrl })` builds the same
|
|
71
|
+
layer from values. An instance served under a path (`N8N_PATH`) needs its
|
|
72
|
+
own `N8n.Credentials` layer whose `baseUrl` includes that path.
|
|
73
|
+
|
|
74
|
+
## Pagination
|
|
75
|
+
|
|
76
|
+
Lists that answer `{ data, nextCursor }` are paginated: `.pages(input)`
|
|
77
|
+
streams each response and `.items(input)` streams the entries of `data`,
|
|
78
|
+
passing `nextCursor` back as `cursor` until it is null. `limit` sets the
|
|
79
|
+
page size (default 100, at most 250).
|
|
80
|
+
|
|
81
|
+
## Packages
|
|
82
|
+
|
|
83
|
+
`exportPackage` answers the `.n8np` archive (gzip) as a byte stream, with
|
|
84
|
+
its `contentType`. `importPackage` and `importPackageSelection` take the
|
|
85
|
+
archive as `package` (a `Blob`, `Uint8Array` or `ArrayBuffer`) and send it as
|
|
86
|
+
a multipart upload.
|
|
87
|
+
|
|
88
|
+
## Errors
|
|
89
|
+
|
|
90
|
+
n8n answers a failed call with `{ message }`. 400, 403, 404, 409 and 422
|
|
91
|
+
fail with this package's `BadRequest`, `Forbidden`, `NotFound`, `Conflict`
|
|
92
|
+
and `UnprocessableEntity`; 401, 423, 429 and the 5xx fail with core's
|
|
93
|
+
`Unauthorized`, `Locked`, `TooManyRequests` and server error classes. Any
|
|
94
|
+
other status fails with `UnknownN8nError`.
|
package/lib/.lazy.json
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"serviceDirs":["services"],"twins":["index.js"]}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{api$D as e,api$call as t,api$error as n,api$named as r,api$newError as i,api$op as a,api$opPaginated as o,category$withAuthError as ee,category$withBadRequestError as te,category$withConflictError as ne,category$withParseError as re,config$Redacted as ie,config$String as s,config$all as c,pagination$paginateCursor as l,retry$capped as u,retry$jittered as d,retry$makeDefault as f,retry$throttlingFactory as p,retry$throttlingOptions as m,retry$transientFactory as h,retry$transientOptions as g,schema_lite_typed$TaggedError as _,schema_lite_typed$Unknown as v,trait$Body as y,trait$FormDataFile as b,trait$Header as x,trait$Http as S,trait$HttpBody as C,trait$IdempotencyToken as w,trait$KeyDictionary as T,trait$Label as E,trait$Query as D,trait$ResponseCode as O,trait$StringEncoded as k,trait$UnionCases as A,trait$applyErrorMatchers as j,trait$bodySymbol as M,trait$errorMatchersSymbol as N,trait$formDataFileSymbol as P,trait$getErrorMatchers as F,trait$headerSymbol as I,trait$httpBodySymbol as L,trait$httpSymbol as R,trait$keyDictionarySymbol as z,trait$labelSymbol as B,trait$querySymbol as V,trait$responseCodeSymbol as H,trait$unionCasesSymbol as U}from"@distilled.cloud/core/_bundle/base";import{errors$API_ERRORS as W,errors$BadGateway as G,errors$BadRequest as K,errors$ConfigError as q,errors$Conflict as J,errors$DEFAULT_ERRORS as Y,errors$Forbidden as ae,errors$GatewayTimeout as oe,errors$HTTP_STATUS_MAP as se,errors$InternalServerError as ce,errors$Locked as X,errors$NotFound as le,errors$ServiceUnavailable as ue,errors$TooManyRequests as de,errors$Unauthorized as fe,errors$UnknownErrorFields as pe,errors$UnprocessableEntity as me,protocol_http$originFromConfig as he,protocol_rest$BinaryResponse as ge,protocol_rest$BinaryStream as _e,protocol_rest$RawResponse as ve,protocol_rest$RawResponseRoot as ye,protocol_rest$SensitiveValue as be,protocol_rest$rawResponseRootSymbol as xe,protocol_rest$rawResponseSymbol as Se,protocol_rest$restProtocol as Ce,protocol_rest$sensitiveValueSymbol as we,protocol_rest$unknownErrorProps as Te,schema_lite$Array as Ee,schema_lite$Boolean as De,schema_lite$NullOr as Oe,schema_lite$Number as ke,schema_lite$Record as Ae,schema_lite$String as je,schema_lite$Struct as Me,schema_lite$StructWithRest as Ne,schema_lite$TaggedError as Pe,schema_lite$Union as Fe,schema_lite$Unknown as Ie,schema_lite$at as Le,schema_lite$instanceOf as Re,schema_lite$optional as ze,schema_lite$suspend as Be}from"@distilled.cloud/core/_bundle/rest";import*as Z from"effect/Context";import*as Q from"effect/Effect";import*as $ from"effect/Layer";import*as Ve from"effect/Redacted";var Credentials=class extends (/*@__PURE__*/ Z.Service()(`N8nCredentials`)){};const check=(e,t)=>{const n=he(`n8n base URL`,t);return typeof n===`string`?Q.succeed(Q.succeed({apiKey:e,baseUrl:n})):Q.fail(n)};const He=/*@__PURE__*/ $.effect(Credentials,/*@__PURE__*/ c({apiKey:/*@__PURE__*/ ie(`N8N_API_KEY`),baseUrl:/*@__PURE__*/ s(`N8N_BASE_URL`)}).pipe(/*@__PURE__*/ Q.mapError(()=>new q({message:`N8N_API_KEY and N8N_BASE_URL environment variables are required`})),/*@__PURE__*/ Q.flatMap(({apiKey:e,baseUrl:t})=>check(e,t))));const fromApiKey=e=>$.effect(Credentials,check(e.apiKey,e.baseUrl));var UnknownN8nError=class extends (/*@__PURE__*/ _()(`UnknownN8nError`,pe)){};var N8nParseError=class extends (/*@__PURE__*/ _()(`N8nParseError`,{body:v,cause:v}).pipe(re)){};const Ue=W;const We=/*@__PURE__*/ Ce({credentials:/*@__PURE__*/ Q.flatten(Credentials),baseUrl:e=>`${e.baseUrl}/api/v1`,headers:e=>({"X-N8N-API-KEY":Ve.value(e.apiKey)}),unknownError:e=>new UnknownN8nError(Te(e)),parseError:({body:e,cause:t})=>new N8nParseError({body:e,cause:t})});var Retry=class extends (/*@__PURE__*/ Z.Service()(`N8nRetry`)){};const policy=e=>Q.provide($.succeed(Retry,e));const Ge=/*@__PURE__*/ Q.provide(/*@__PURE__*/ $.succeed(Retry,{while:()=>false}));const Ke=f;const qe=d;const Je=u;const Ye=m;const Xe=/*@__PURE__*/ policy(p);const Ze=g;const Qe=/*@__PURE__*/ policy(h);export{ne as Ca,Ee as Xc,De as Yc,e as a,t as b,Credentials as credentials$Credentials,He as credentials$CredentialsFromEnv,fromApiKey as credentials$fromApiKey,W as errors$API_ERRORS,G as errors$BadGateway,K as errors$BadRequest,q as errors$ConfigError,J as errors$Conflict,Y as errors$DEFAULT_ERRORS,ae as errors$Forbidden,oe as errors$GatewayTimeout,se as errors$HTTP_STATUS_MAP,ce as errors$InternalServerError,X as errors$Locked,N8nParseError as errors$N8nParseError,Ue as errors$N8nServiceErrors,le as errors$NotFound,ue as errors$ServiceUnavailable,de as errors$TooManyRequests,fe as errors$Unauthorized,UnknownN8nError as errors$UnknownN8nError,me as errors$UnprocessableEntity,n as f,Oe as fd,ke as gd,Ae as hd,je as jd,_e as kc,Me as kd,r as l,Ne as ld,i as m,Pe as md,a as n,o,Fe as od,l as pagination$paginateCursor,Ie as pd,We as protocol$N8nProtocol,Le as rd,Retry as retry$Retry,Je as retry$capped,qe as retry$jittered,Ke as retry$makeDefault,Ge as retry$none,policy as retry$policy,Xe as retry$throttling,Ye as retry$throttlingOptions,Qe as retry$transient,Ze as retry$transientOptions,ge as traits$BinaryResponse,y as traits$Body,b as traits$FormDataFile,x as traits$Header,S as traits$Http,C as traits$HttpBody,w as traits$IdempotencyToken,T as traits$KeyDictionary,E as traits$Label,D as traits$Query,ve as traits$RawResponse,ye as traits$RawResponseRoot,O as traits$ResponseCode,be as traits$SensitiveValue,k as traits$StringEncoded,A as traits$UnionCases,j as traits$applyErrorMatchers,M as traits$bodySymbol,N as traits$errorMatchersSymbol,P as traits$formDataFileSymbol,F as traits$getErrorMatchers,I as traits$headerSymbol,L as traits$httpBodySymbol,R as traits$httpSymbol,z as traits$keyDictionarySymbol,B as traits$labelSymbol,V as traits$querySymbol,xe as traits$rawResponseRootSymbol,Se as traits$rawResponseSymbol,H as traits$responseCodeSymbol,we as traits$sensitiveValueSymbol,U as traits$unionCasesSymbol,Re as ud,ze as wd,Be as xd,ee as ya,te as za};
|
|
2
|
+
//# sourceMappingURL=sdk.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sdk.js","names":["Schema.Unknown","Category.withParseError","Retries.makeDefault","Retries.jittered","Retries.capped","Retries.throttlingOptions","Retries.throttlingFactory","Retries.transientOptions","Retries.transientFactory","D","call","error","named","newError","op","opPaginated","withAuthError","withBadRequestError","withConflictError","withParseError","Redacted$3","String$2","all$1","paginateCursor","capped$1","jittered$1","makeDefault$1","throttlingFactory","throttlingOptions$1","transientFactory","transientOptions$1","TaggedError$1","Unknown$1","Body","FormDataFile","Header","Http","HttpBody","IdempotencyToken","KeyDictionary","Label","Query","ResponseCode","StringEncoded","UnionCases","applyErrorMatchers","bodySymbol","errorMatchersSymbol","formDataFileSymbol","getErrorMatchers","headerSymbol","httpBodySymbol","httpSymbol","keyDictionarySymbol","labelSymbol","querySymbol","responseCodeSymbol","unionCasesSymbol","API_ERRORS","BadGateway","BadRequest","ConfigError","Conflict","DEFAULT_ERRORS","Forbidden","GatewayTimeout","HTTP_STATUS_MAP","InternalServerError","Locked","NotFound","ServiceUnavailable","TooManyRequests","Unauthorized","UnknownErrorFields","UnprocessableEntity","originFromConfig","BinaryResponse","BinaryStream","RawResponse","RawResponseRoot","SensitiveValue","rawResponseRootSymbol","rawResponseSymbol","restProtocol","sensitiveValueSymbol","unknownErrorProps","Array","Boolean","NullOr","Number","Record","String","Struct","StructWithRest","TaggedError","Union","Unknown","at","instanceOf","optional","suspend","Context","Effect","Layer","Redacted","origin","baseUrl","CredentialsFromEnv","apiKey","config","N8nServiceErrors","N8nProtocol","creds","info","optionsOrFactory","none","makeDefault","jittered","capped","throttlingOptions","throttling","transientOptions","transient"],"sources":["../../src/credentials.ts","../../src/errors.ts","../../src/protocol.ts","../../src/retry.ts"],"mappings":"mkFA0BA,IAAa,YAAb,eACwB,gBAAQ,QAA4C,CAAC,CAAC,gBAAgB,EAAA,AAAE,CAAC,EAGjG,MAAM,OACJ,EACA,IACsD,CACtD,MAAMyG,EAAS9B,GAAiB,eAAgB+B,CAAO,EACvD,OAAO,OAAOD,IAAW,SACrBH,EAAO,QAAQA,EAAO,QAAQ,CAAE,SAAQ,QAASG,CAAO,CAAC,CAAC,EAC1DH,EAAO,KAAKG,CAAM,CACxB,EAOA,MAAaE,GAA0E,gBAAM,OAC3F,YACc,gBAAiB,CAC7B,OAAsB,iBAAsB,aAAa,EACzD,QAAuB,gBAAoB,cAAc,CAC3D,CAAC,CAAC,CAAC,KACa,gBAAO,aAEjB,IAAI9C,EAAY,CACd,QAAS,iEACX,CAAC,CACL,EACc,gBAAO,SAAS,CAAE,SAAQ,aAAc,MAAM+C,EAAQF,CAAO,CAAC,CAC9E,CACF,EAGA,MAAa,WAAc,GAIzBH,EAAM,OAAO,YAAa,MAAMM,EAAO,OAAQA,EAAO,OAAO,CAAC,EC3BhE,IAAa,gBAAb,eACwB,gBAAoC,CAAC,CACzD,kBACApC,EACF,EAAA,AAAE,CAAC,EAGL,IAAa,cAAb,eACwB,gBAAkC,CAAC,CAAC,gBAAiB,CACzE,KAAMzE,EACN,MAAOA,CACT,CAAC,CAAC,CAAC,KAAKC,EAAuB,EAAA,AAAE,CAAC,EAQpC,MAAa6G,GAAmBpD,ECtBhC,MAAaqD,GAA4B,iBAAa,CAGpD,YAA2B,gBAAO,QAAQ,WAAW,EAErD,QAAU,GAAU,GAAGC,EAAM,QAAQ,SACrC,QAAU,IAAW,CACnB,gBAAiBR,GAAS,MAAMQ,EAAM,MAAM,CAC9C,GACA,aAAe,GAAS,IAAI,gBAAgB3B,GAAkB4B,CAAI,CAAC,EACnE,YAAa,CAAE,OAAM,WAAY,IAAI,cAAc,CAAE,OAAM,OAAM,CAAC,CACpE,CAAC,ECtBD,IAAa,MAAb,eAAyC,gBAAQ,QAAuB,CAAC,CAAC,UAAU,EAAA,AAAE,CAAC,EAGvF,MAAa,OAOR,GAAwCX,EAAO,QAAQC,EAAM,QAAQ,MAAOW,CAAgB,CAAC,EAGlG,MAAaC,GAE+C,gBAAO,QACnD,gBAAM,QAAQ,MAAO,CAAE,UAAa,KAAM,CAAC,CAC3D,EAOA,MAAaC,GAAuBlH,EAEpC,MAAamH,GAAWlH,EACxB,MAAamH,GAASlH,EAGtB,MAAamH,GAA6BlH,EAG1C,MAAamH,GAE+C,qBAAOlH,CAAyB,EAG5F,MAAamH,GAA4BlH,EAGzC,MAAamH,GAE+C,qBAAOlH,CAAwB"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { ConfigError } from "@distilled.cloud/core/errors";
|
|
2
|
+
import * as Context from "effect/Context";
|
|
3
|
+
import * as Effect from "effect/Effect";
|
|
4
|
+
import * as Layer from "effect/Layer";
|
|
5
|
+
import * as Redacted from "effect/Redacted";
|
|
6
|
+
export interface Config {
|
|
7
|
+
/** n8n API key, sent as `X-N8N-API-KEY`. */
|
|
8
|
+
readonly apiKey: Redacted.Redacted<string>;
|
|
9
|
+
/** Instance origin, without a trailing slash. The protocol adds `/api/v1`. */
|
|
10
|
+
readonly baseUrl: string;
|
|
11
|
+
}
|
|
12
|
+
declare const Credentials_base: Context.ServiceClass<Credentials, "N8nCredentials", Effect.Effect<Config, never, never>>;
|
|
13
|
+
export declare class Credentials extends /*@__PURE__*/ Credentials_base {
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Reads `N8N_API_KEY` and `N8N_BASE_URL` (both required), once: when the
|
|
17
|
+
* layer is built. A missing value or a bad base URL fails the layer with
|
|
18
|
+
* `ConfigError`.
|
|
19
|
+
*/
|
|
20
|
+
export declare const CredentialsFromEnv: Layer.Layer<Credentials, ConfigError>;
|
|
21
|
+
/** Credentials from a redacted API key and the instance's base URL. */
|
|
22
|
+
export declare const fromApiKey: (config: {
|
|
23
|
+
readonly apiKey: Redacted.Redacted<string>;
|
|
24
|
+
readonly baseUrl: string;
|
|
25
|
+
}) => Layer.Layer<Credentials, ConfigError>;
|
|
26
|
+
export {};
|
|
27
|
+
//# sourceMappingURL=credentials.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"credentials.d.ts","sources":["../src/credentials.ts"],"names":[],"mappings":"AAYA,OAAO,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAC;AAE3D,OAAO,KAAK,OAAO,MAAM,gBAAgB,CAAC;AAC1C,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AACxC,OAAO,KAAK,KAAK,MAAM,cAAc,CAAC;AACtC,OAAO,KAAK,QAAQ,MAAM,iBAAiB,CAAC;AAE5C,MAAM,WAAW,MAAM;IACrB,4CAA4C;IAC5C,QAAQ,CAAC,MAAM,EAAE,QAAQ,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;IAC3C,8EAA8E;IAC9E,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;CAC1B;;AAED,qBAAa,WACX,SAAQ,aAAa,CAAC,gBAAuE;CAAG;AAalG;;;;GAIG;AACH,eAAO,MAAM,kBAAkB,EAAE,KAAK,CAAC,KAAK,CAAC,WAAW,EAAE,WAAW,CAcpE,CAAC;AAEF,uEAAuE;AACvE,eAAO,MAAM,UAAU,WAAY;IACjC,QAAQ,CAAC,MAAM,EAAE,QAAQ,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;IAC3C,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;CAC1B,KAAG,KAAK,CAAC,KAAK,CAAC,WAAW,EAAE,WAAW,CACyB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { credentials$Credentials as Credentials, credentials$CredentialsFromEnv as CredentialsFromEnv, credentials$fromApiKey as fromApiKey } from "./_bundle/sdk.js";
|
package/lib/errors.d.ts
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* n8n-specific error types.
|
|
3
|
+
*
|
|
4
|
+
* Re-exports the shared HTTP status errors from core and adds the n8n
|
|
5
|
+
* fallback and parse errors.
|
|
6
|
+
*
|
|
7
|
+
* n8n answers a failed call with `{ message }` (some 403s and 409s add
|
|
8
|
+
* fields such as `reason` or `conflicts`). 400, 403, 404, 409 and 422 are
|
|
9
|
+
* generated per operation as service-local classes; 401, 423, 429 and the
|
|
10
|
+
* 5xx map to core's status classes; any other status (402, 413, 415) is an
|
|
11
|
+
* {@link UnknownN8nError}.
|
|
12
|
+
*/
|
|
13
|
+
export { BadGateway, BadRequest, Conflict, ConfigError, Forbidden, GatewayTimeout, InternalServerError, Locked, NotFound, ServiceUnavailable, TooManyRequests, Unauthorized, UnprocessableEntity, HTTP_STATUS_MAP, DEFAULT_ERRORS, API_ERRORS, } from "@distilled.cloud/core/errors";
|
|
14
|
+
export type { DefaultErrors } from "@distilled.cloud/core/errors";
|
|
15
|
+
import * as Schema from "@distilled.cloud/core/schema-lite-typed";
|
|
16
|
+
declare const UnknownN8nError_base: Schema.TaggedErrorClass<"UnknownN8nError", {
|
|
17
|
+
status: import("effect/Schema").Number;
|
|
18
|
+
code: import("effect/Schema").optional<import("effect/Schema").String>;
|
|
19
|
+
message: import("effect/Schema").optional<import("effect/Schema").String>;
|
|
20
|
+
body: import("effect/Schema").Unknown;
|
|
21
|
+
}>;
|
|
22
|
+
/**
|
|
23
|
+
* Unknown n8n error -- returned when an error response matches neither an
|
|
24
|
+
* operation's typed errors nor a shared HTTP status class.
|
|
25
|
+
*/
|
|
26
|
+
export declare class UnknownN8nError extends /*@__PURE__*/ UnknownN8nError_base {
|
|
27
|
+
}
|
|
28
|
+
declare const N8nParseError_base: Schema.TaggedErrorClass<"N8nParseError", {
|
|
29
|
+
readonly body: import("effect/Schema").Unknown;
|
|
30
|
+
readonly cause: import("effect/Schema").Unknown;
|
|
31
|
+
}> & (new (...args: any[]) => {
|
|
32
|
+
"@distilled.cloud/error/categories": {
|
|
33
|
+
ParseError: true;
|
|
34
|
+
};
|
|
35
|
+
});
|
|
36
|
+
/** A 2xx response that does not match the operation's output schema. */
|
|
37
|
+
export declare class N8nParseError extends /*@__PURE__*/ N8nParseError_base {
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* The errors declared on the n8n service: any operation can return them,
|
|
41
|
+
* and every generated operation lists them as its `serviceErrors`. Today that
|
|
42
|
+
* is each of core's status classes (400, 401, 403, 404, 409, 423, 429, the
|
|
43
|
+
* 5xx ...).
|
|
44
|
+
*/
|
|
45
|
+
export declare const N8nServiceErrors: readonly [typeof import("@distilled.cloud/core/errors").Unauthorized, typeof import("@distilled.cloud/core/errors").Forbidden, typeof import("@distilled.cloud/core/errors").NotFound, typeof import("@distilled.cloud/core/errors").BadRequest, typeof import("@distilled.cloud/core/errors").Conflict, typeof import("@distilled.cloud/core/errors").UnprocessableEntity, typeof import("@distilled.cloud/core/errors").TooManyRequests, typeof import("@distilled.cloud/core/errors").Locked, typeof import("@distilled.cloud/core/errors").InternalServerError, typeof import("@distilled.cloud/core/errors").BadGateway, typeof import("@distilled.cloud/core/errors").ServiceUnavailable, typeof import("@distilled.cloud/core/errors").GatewayTimeout];
|
|
46
|
+
export type N8nServiceError = InstanceType<(typeof N8nServiceErrors)[number]>;
|
|
47
|
+
//# sourceMappingURL=errors.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,OAAO,EACL,UAAU,EACV,UAAU,EACV,QAAQ,EACR,WAAW,EACX,SAAS,EACT,cAAc,EACd,mBAAmB,EACnB,MAAM,EACN,QAAQ,EACR,kBAAkB,EAClB,eAAe,EACf,YAAY,EACZ,mBAAmB,EACnB,eAAe,EACf,cAAc,EACd,UAAU,GACX,MAAM,8BAA8B,CAAC;AACtC,YAAY,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;AAGlE,OAAO,KAAK,MAAM,MAAM,yCAAyC,CAAC;;;;;;;AAElE;;;GAGG;AACH,qBAAa,eACX,SAAQ,aAAa,CAAC,oBAGrB;CAAG;;;;;;;;;AAEN,wEAAwE;AACxE,qBAAa,aACX,SAAQ,aAAa,CAAC,kBAGU;CAAG;AAErC;;;;;GAKG;AACH,eAAO,MAAM,gBAAgB,+tBAAa,CAAC;AAC3C,MAAM,MAAM,eAAe,GAAG,YAAY,CAAC,CAAC,OAAO,gBAAgB,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC"}
|
package/lib/errors.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { errors$API_ERRORS as API_ERRORS, errors$BadGateway as BadGateway, errors$BadRequest as BadRequest, errors$ConfigError as ConfigError, errors$Conflict as Conflict, errors$DEFAULT_ERRORS as DEFAULT_ERRORS, errors$Forbidden as Forbidden, errors$GatewayTimeout as GatewayTimeout, errors$HTTP_STATUS_MAP as HTTP_STATUS_MAP, errors$InternalServerError as InternalServerError, errors$Locked as Locked, errors$N8nParseError as N8nParseError, errors$N8nServiceErrors as N8nServiceErrors, errors$NotFound as NotFound, errors$ServiceUnavailable as ServiceUnavailable, errors$TooManyRequests as TooManyRequests, errors$Unauthorized as Unauthorized, errors$UnknownN8nError as UnknownN8nError, errors$UnprocessableEntity as UnprocessableEntity } from "./_bundle/sdk.js";
|
package/lib/index.d.ts
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @distilled.cloud/n8n -- n8n Public API SDK for Effect.
|
|
3
|
+
*
|
|
4
|
+
* `./services` is generated by `scripts/generate.ts` from the Smithy model
|
|
5
|
+
* that `scripts/convert.ts` converts from the OpenAPI document mirrored at
|
|
6
|
+
* `specs/spec-mirror-n8n/specs/openapi.yml`. Everything else in this folder
|
|
7
|
+
* is hand-written.
|
|
8
|
+
*
|
|
9
|
+
* The n8n Public API is one service, so its operations are exported
|
|
10
|
+
* straight off the package root.
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* ```ts
|
|
14
|
+
* import * as N8n from "@distilled.cloud/n8n";
|
|
15
|
+
*
|
|
16
|
+
* const workflow = yield* N8n.getWorkflow({ workflowId: "2tUt1wbLX592XDdX" });
|
|
17
|
+
* ```
|
|
18
|
+
*/
|
|
19
|
+
export * from "./credentials.ts";
|
|
20
|
+
export * from "./errors.ts";
|
|
21
|
+
export * as T from "./traits.ts";
|
|
22
|
+
export { N8nProtocol, type N8nOpError, type N8nOpContext } from "./protocol.ts";
|
|
23
|
+
export { paginateCursor } from "./pagination.ts";
|
|
24
|
+
export * as Retry from "./retry.ts";
|
|
25
|
+
export * from "./services/n8n.ts";
|
|
26
|
+
export { BadRequest, Conflict, Forbidden, NotFound, UnprocessableEntity } from "./services/n8n.ts";
|
|
27
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AACH,cAAc,kBAAkB,CAAC;AACjC,cAAc,aAAa,CAAC;AAC5B,OAAO,KAAK,CAAC,MAAM,aAAa,CAAC;AACjC,OAAO,EAAE,WAAW,EAAE,KAAK,UAAU,EAAE,KAAK,YAAY,EAAE,MAAM,eAAe,CAAC;AAChF,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AACjD,OAAO,KAAK,KAAK,MAAM,YAAY,CAAC;AACpC,cAAc,mBAAmB,CAAC;AAGlC,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,SAAS,EAAE,QAAQ,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC"}
|
package/lib/index.js
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export * from "./credentials.js";
|
|
2
|
+
export * from "./errors.js";
|
|
3
|
+
export * as T from "./traits.js";
|
|
4
|
+
export { N8nProtocol } from "./protocol.js";
|
|
5
|
+
export { paginateCursor } from "./pagination.js";
|
|
6
|
+
export * as Retry from "./retry.js";
|
|
7
|
+
export * from "./services/n8n.js";
|
|
8
|
+
export { BadRequest, Conflict, Forbidden, NotFound, UnprocessableEntity } from "./services/n8n.js";
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export * from "./credentials.js";
|
|
2
|
+
export * from "./errors.js";
|
|
3
|
+
export * as T from "./traits.js";
|
|
4
|
+
export { N8nProtocol } from "./protocol.js";
|
|
5
|
+
export { paginateCursor } from "./pagination.js";
|
|
6
|
+
export * as Retry from "./retry.js";
|
|
7
|
+
export * from "./services.lazy/n8n.js";
|
|
8
|
+
export { BadRequest, Conflict, Forbidden, NotFound, UnprocessableEntity } from "./services.lazy/n8n.js";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AACH,cAAc,kBAAkB,CAAC;AACjC,cAAc,aAAa,CAAC;AAC5B,OAAO,KAAK,CAAC,MAAM,aAAa,CAAC;AACjC,OAAO,EAAE,WAAW,EAAsC,MAAM,eAAe,CAAC;AAChF,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AACjD,OAAO,KAAK,KAAK,MAAM,YAAY,CAAC;AACpC,cAAc,mBAAmB,CAAC;AAClC,0EAA0E;AAC1E,sEAAsE;AACtE,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,SAAS,EAAE,QAAQ,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* n8n pagination -- hand-written.
|
|
3
|
+
*
|
|
4
|
+
* n8n Public API lists answer `{ data, nextCursor }` and take `nextCursor`
|
|
5
|
+
* back as the `cursor` query parameter; `nextCursor` is null on the last
|
|
6
|
+
* page. `patches/pagination.json` stamps that on each list, and generated
|
|
7
|
+
* operations pass core's {@link paginateCursor} strategy to
|
|
8
|
+
* `API.makePaginated`.
|
|
9
|
+
*/
|
|
10
|
+
export { paginateCursor } from "@distilled.cloud/core/pagination";
|
|
11
|
+
//# sourceMappingURL=pagination.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pagination.d.ts","sources":["../src/pagination.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,OAAO,EAAE,cAAc,EAAE,MAAM,kCAAkC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { pagination$paginateCursor as paginateCursor } from "./_bundle/sdk.js";
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { ErrorOf } from "@distilled.cloud/core/protocol";
|
|
2
|
+
import type * as HttpClient from "effect/http/HttpClient";
|
|
3
|
+
import { Credentials } from "./credentials.ts";
|
|
4
|
+
import { N8nParseError, UnknownN8nError, type N8nServiceError } from "./errors.ts";
|
|
5
|
+
/**
|
|
6
|
+
* What every generated n8n operation fails with besides its own errors: the
|
|
7
|
+
* errors declared on the service, and the errors declared on the protocol.
|
|
8
|
+
* Nobody lists the protocol's: its type carries what its code fails with (a
|
|
9
|
+
* response that does not match its schema, a failed response nothing
|
|
10
|
+
* declares, core's REST errors, and what resolving the credentials fails
|
|
11
|
+
* with). Generated service files annotate operations with
|
|
12
|
+
* `API.OperationMethod<I, O, N8nOpError, N8nOpContext>` explicitly so the
|
|
13
|
+
* compiler never infers these back out of the schema generics.
|
|
14
|
+
*/
|
|
15
|
+
export type N8nOpError = N8nServiceError | ErrorOf<typeof N8nProtocol>;
|
|
16
|
+
/** Context (requirements) shared by every generated n8n operation. */
|
|
17
|
+
export type N8nOpContext = Credentials | HttpClient.HttpClient;
|
|
18
|
+
export declare const N8nProtocol: import("@distilled.cloud/core/protocol").Protocol<N8nParseError | UnknownN8nError | import("@distilled.cloud/core/protocol-rest").RestProtocolError, Credentials>;
|
|
19
|
+
//# sourceMappingURL=protocol.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"protocol.d.ts","sources":["../src/protocol.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,gCAAgC,CAAC;AAgB9D,OAAO,KAAK,KAAK,UAAU,MAAM,wBAAwB,CAAC;AAE1D,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAE,aAAa,EAAE,eAAe,EAAE,KAAK,eAAe,EAAE,MAAM,aAAa,CAAC;AAEnF;;;;;;;;;GASG;AACH,MAAM,MAAM,UAAU,GAAG,eAAe,GAAG,OAAO,CAAC,OAAO,WAAW,CAAC,CAAC;AAEvE,sEAAsE;AACtE,MAAM,MAAM,YAAY,GAAG,WAAW,GAAG,UAAU,CAAC,UAAU,CAAC;AAE/D,eAAO,MAAM,WAAW,mKAWtB,CAAC"}
|
package/lib/protocol.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { protocol$N8nProtocol as N8nProtocol } from "./_bundle/sdk.js";
|
package/lib/retry.d.ts
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import * as Retries from "@distilled.cloud/core/retry";
|
|
2
|
+
/**
|
|
3
|
+
* n8n retry surface -- a veneer over `@distilled.cloud/core/retry`.
|
|
4
|
+
*
|
|
5
|
+
* The `Retry` service tag is threaded into every generated operation via
|
|
6
|
+
* `API.make({ retry: Retry })`, so a caller-installed policy applies to all
|
|
7
|
+
* n8n calls below it and core's `makeDefault` is the fallback when none is
|
|
8
|
+
* provided.
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* ```ts
|
|
12
|
+
* import * as N8n from "@distilled.cloud/n8n";
|
|
13
|
+
*
|
|
14
|
+
* myEffect.pipe(N8n.Retry.transient);
|
|
15
|
+
* ```
|
|
16
|
+
*/
|
|
17
|
+
import * as Context from "effect/Context";
|
|
18
|
+
import * as Effect from "effect/Effect";
|
|
19
|
+
export type Options = Retries.Options;
|
|
20
|
+
export type Factory = Retries.Factory;
|
|
21
|
+
export type Policy = Retries.Policy;
|
|
22
|
+
declare const Retry_base: Context.ServiceClass<Retry, "N8nRetry", Retries.Policy>;
|
|
23
|
+
/** Context tag for configuring retry behavior of n8n API calls. */
|
|
24
|
+
export declare class Retry extends /*@__PURE__*/ Retry_base {
|
|
25
|
+
}
|
|
26
|
+
/** Provides a custom retry policy to every n8n API call below it. */
|
|
27
|
+
export declare const policy: {
|
|
28
|
+
(options: Options): <A, E, R>(effect: Effect.Effect<A, E, R>) => Effect.Effect<A, E, Exclude<R, Retry>>;
|
|
29
|
+
(factory: Factory): <A, E, R>(effect: Effect.Effect<A, E, R>) => Effect.Effect<A, E, Exclude<R, Retry>>;
|
|
30
|
+
};
|
|
31
|
+
/** Disables all automatic retries. */
|
|
32
|
+
export declare const none: <A, E, R>(effect: Effect.Effect<A, E, R>) => Effect.Effect<A, E, Exclude<R, Retry>>;
|
|
33
|
+
/**
|
|
34
|
+
* The default retry policy (core's): transient/throttling/retryable errors,
|
|
35
|
+
* capped exponential backoff with jitter, server `retryAfter` hints honored
|
|
36
|
+
* with precedence.
|
|
37
|
+
*/
|
|
38
|
+
export declare const makeDefault: Factory;
|
|
39
|
+
export declare const jittered: <Error, Env>(self: import("effect/Schedule").Schedule<unknown, unknown, Error, Env>) => import("effect/Schedule").Schedule<unknown, unknown, Error, Env>;
|
|
40
|
+
export declare const capped: (max: import("effect/Duration").Duration) => <Error, Env>(self: import("effect/Schedule").Schedule<unknown, unknown, Error, Env>) => import("effect/Schedule").Schedule<unknown, unknown, Error, Env>;
|
|
41
|
+
/** Retry options that retry all throttling errors indefinitely. */
|
|
42
|
+
export declare const throttlingOptions: Options;
|
|
43
|
+
/** Retries all throttling errors indefinitely (honoring server hints). */
|
|
44
|
+
export declare const throttling: <A, E, R>(effect: Effect.Effect<A, E, R>) => Effect.Effect<A, E, Exclude<R, Retry>>;
|
|
45
|
+
/** Retry options that retry all transient errors indefinitely. */
|
|
46
|
+
export declare const transientOptions: Options;
|
|
47
|
+
/** Retries all transient errors indefinitely. */
|
|
48
|
+
export declare const transient: <A, E, R>(effect: Effect.Effect<A, E, R>) => Effect.Effect<A, E, Exclude<R, Retry>>;
|
|
49
|
+
export {};
|
|
50
|
+
//# sourceMappingURL=retry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"retry.d.ts","sources":["../src/retry.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,OAAO,MAAM,6BAA6B,CAAC;AACvD;;;;;;;;;;;;;;GAcG;AACH,OAAO,KAAK,OAAO,MAAM,gBAAgB,CAAC;AAC1C,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AAGxC,MAAM,MAAM,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC;AACtC,MAAM,MAAM,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC;AACtC,MAAM,MAAM,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;;AAEpC,mEAAmE;AACnE,qBAAa,KAAM,SAAQ,aAAa,CAAC,UAA4C;CAAG;AAExF,qEAAqE;AACrE,eAAO,MAAM,MAAM,EAAE;IACnB,CACE,OAAO,EAAE,OAAO,GACf,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,MAAM,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,KAAK,MAAM,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,EAAE,OAAO,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC,CAAC;IACvF,CACE,OAAO,EAAE,OAAO,GACf,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,MAAM,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,KAAK,MAAM,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,EAAE,OAAO,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC,CAAC;CACU,CAAC;AAEpG,sCAAsC;AACtC,eAAO,MAAM,IAAI,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EACzB,MAAM,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,KAC3B,MAAM,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,EAAE,OAAO,CAAC,CAAC,EAAE,KAAK,CAAC,CAEzC,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,WAAW,EAAE,OAA6B,CAAC;AAExD,eAAO,MAAM,QAAQ,0JAAmB,CAAC;AACzC,eAAO,MAAM,MAAM,uMAAiB,CAAC;AAErC,mEAAmE;AACnE,eAAO,MAAM,iBAAiB,EAAE,OAAmC,CAAC;AAEpE,0EAA0E;AAC1E,eAAO,MAAM,UAAU,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAC/B,MAAM,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,KAC3B,MAAM,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,EAAE,OAAO,CAAC,CAAC,EAAE,KAAK,CAAC,CAAmD,CAAC;AAE9F,kEAAkE;AAClE,eAAO,MAAM,gBAAgB,EAAE,OAAkC,CAAC;AAElE,iDAAiD;AACjD,eAAO,MAAM,SAAS,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAC9B,MAAM,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,KAC3B,MAAM,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,EAAE,OAAO,CAAC,CAAC,EAAE,KAAK,CAAC,CAAkD,CAAC"}
|
package/lib/retry.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { retry$Retry as Retry, retry$capped as capped, retry$jittered as jittered, retry$makeDefault as makeDefault, retry$none as none, retry$policy as policy, retry$throttling as throttling, retry$throttlingOptions as throttlingOptions, retry$transient as transient, retry$transientOptions as transientOptions } from "./_bundle/sdk.js";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sources":["../../src/services/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,GAAG,MAAM,UAAU,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * as n8n from "./n8n.js";
|