@engini/sdk 0.19.0 → 0.20.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +57 -0
- package/dist/client.d.ts +2 -0
- package/dist/client.js +3 -0
- package/dist/errors.d.ts +56 -9
- package/dist/errors.js +46 -13
- package/dist/http.d.ts +17 -0
- package/dist/http.js +39 -4
- package/dist/index.d.ts +5 -3
- package/dist/index.js +2 -2
- package/dist/resources/index.d.ts +2 -0
- package/dist/resources/index.js +1 -0
- package/dist/resources/triggers.d.ts +355 -0
- package/dist/resources/triggers.js +851 -0
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -96,6 +96,63 @@ which replaces its whole field map. Settings you omit take the server's defaults
|
|
|
96
96
|
minimums come from the connector's own declared metadata rather than the client. Agents are
|
|
97
97
|
not connections: `client.connections` never returns them.
|
|
98
98
|
|
|
99
|
+
`client.triggers` is the event side of the platform: a trigger instance (`ti_…`) watches a
|
|
100
|
+
connected system and captures events, which Engini POSTs to a destination you register.
|
|
101
|
+
|
|
102
|
+
```ts
|
|
103
|
+
// What can be triggered, then one instance of it
|
|
104
|
+
const types = await client.triggers.types.list({ applicationSlug: "monday" });
|
|
105
|
+
const trigger = await client.triggers.create({
|
|
106
|
+
triggerSlug: "monday_item_created",
|
|
107
|
+
connectionName: "prod",
|
|
108
|
+
});
|
|
109
|
+
await client.triggers.enable(trigger.id!);
|
|
110
|
+
|
|
111
|
+
// Where events are delivered. The secret is shown once - store it, never log it.
|
|
112
|
+
const created = await client.triggers.destinations.create({
|
|
113
|
+
name: "primary",
|
|
114
|
+
url: "https://acme.test/hooks/engini",
|
|
115
|
+
});
|
|
116
|
+
const signingSecret = created.signing_secret;
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
Verify a delivery in your HTTP handler. `verifyWebhook` **throws** rather than returning a
|
|
120
|
+
boolean — a boolean is silently ignorable, which is the one failure mode a signature check
|
|
121
|
+
cannot afford — and hands back the parsed event so it is one call, not two:
|
|
122
|
+
|
|
123
|
+
```ts
|
|
124
|
+
import { verifyWebhook, EnginiWebhookSignatureError } from "@engini/sdk";
|
|
125
|
+
|
|
126
|
+
try {
|
|
127
|
+
// The raw body, not a re-serialised one. Node lower-cases header names and types
|
|
128
|
+
// them `string | string[] | undefined`, so narrow before passing.
|
|
129
|
+
const signature = req.headers["x-engini-signature"];
|
|
130
|
+
const event = verifyWebhook(
|
|
131
|
+
rawBody,
|
|
132
|
+
Array.isArray(signature) ? signature[0] : signature,
|
|
133
|
+
signingSecret,
|
|
134
|
+
);
|
|
135
|
+
// … dedupe on the X-Engini-Event-Id header
|
|
136
|
+
} catch (err) {
|
|
137
|
+
if (err instanceof EnginiWebhookSignatureError) return res.status(400).end();
|
|
138
|
+
throw err;
|
|
139
|
+
}
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
For local development `subscribe()` reads the same events as an async iterator. It resumes
|
|
143
|
+
by itself, which is not a nicety: the gateway caps every connection at one hour of
|
|
144
|
+
wall-clock time, and the cut arrives as a truncated body with no goodbye. It reconnects
|
|
145
|
+
from the last event you saw, and stops hard only where a gap would otherwise go unnoticed —
|
|
146
|
+
a revoked stream, or a cursor the server has already pruned.
|
|
147
|
+
|
|
148
|
+
```ts
|
|
149
|
+
for await (const event of client.triggers.subscribe({ triggerId: trigger.id })) {
|
|
150
|
+
console.log(event.id, event.payload);
|
|
151
|
+
// `event.delivery` is always "pending" on the stream - it is not a delivery state.
|
|
152
|
+
// Use client.triggers.events.get(event.id!) for the real one.
|
|
153
|
+
}
|
|
154
|
+
```
|
|
155
|
+
|
|
99
156
|
`client.toolset(...)` builds a local toolset (no I/O until used) or loads a server one via
|
|
100
157
|
`client.toolset({ toolsetId })`.
|
|
101
158
|
|
package/dist/client.d.ts
CHANGED
|
@@ -6,6 +6,7 @@ import { ConnectionsResource } from "./resources/connections.js";
|
|
|
6
6
|
import { ToolsetsResource } from "./resources/toolsets.js";
|
|
7
7
|
import { McpResource } from "./resources/mcp.js";
|
|
8
8
|
import { OpaResource } from "./resources/opa.js";
|
|
9
|
+
import { TriggersResource } from "./resources/triggers.js";
|
|
9
10
|
import { ApplicationsResource } from "./resources/applications.js";
|
|
10
11
|
import { AuthResource } from "./resources/auth.js";
|
|
11
12
|
import { Toolset, type ConnectionBinding } from "./toolset.js";
|
|
@@ -51,6 +52,7 @@ export declare class Engini {
|
|
|
51
52
|
readonly toolsets: ToolsetsResource;
|
|
52
53
|
readonly mcp: McpResource;
|
|
53
54
|
readonly opa: OpaResource;
|
|
55
|
+
readonly triggers: TriggersResource;
|
|
54
56
|
readonly applications: ApplicationsResource;
|
|
55
57
|
readonly auth: AuthResource;
|
|
56
58
|
readonly provider: Provider;
|
package/dist/client.js
CHANGED
|
@@ -7,6 +7,7 @@ import { ConnectionsResource } from "./resources/connections.js";
|
|
|
7
7
|
import { ToolsetsResource } from "./resources/toolsets.js";
|
|
8
8
|
import { McpResource } from "./resources/mcp.js";
|
|
9
9
|
import { OpaResource } from "./resources/opa.js";
|
|
10
|
+
import { TriggersResource } from "./resources/triggers.js";
|
|
10
11
|
import { ApplicationsResource } from "./resources/applications.js";
|
|
11
12
|
import { AuthResource } from "./resources/auth.js";
|
|
12
13
|
import { Toolset } from "./toolset.js";
|
|
@@ -18,6 +19,7 @@ export class Engini {
|
|
|
18
19
|
toolsets;
|
|
19
20
|
mcp;
|
|
20
21
|
opa;
|
|
22
|
+
triggers;
|
|
21
23
|
applications;
|
|
22
24
|
auth;
|
|
23
25
|
provider;
|
|
@@ -72,6 +74,7 @@ export class Engini {
|
|
|
72
74
|
this.toolsets = new ToolsetsResource(this);
|
|
73
75
|
this.mcp = new McpResource(this);
|
|
74
76
|
this.opa = new OpaResource(this);
|
|
77
|
+
this.triggers = new TriggersResource(this);
|
|
75
78
|
this.applications = new ApplicationsResource(this);
|
|
76
79
|
this.auth = new AuthResource(this);
|
|
77
80
|
}
|
package/dist/errors.d.ts
CHANGED
|
@@ -19,14 +19,21 @@ export declare class EnginiNetworkError extends EnginiError {
|
|
|
19
19
|
* `OPA_APPLICATION_AMBIGUOUS` carries its candidate slugs in `details` — the only
|
|
20
20
|
* place a caller can learn them. `message` is unchanged, so code reading it is
|
|
21
21
|
* unaffected.
|
|
22
|
+
*
|
|
23
|
+
* `retryAfter` is the response's `Retry-After` header in seconds, or `undefined`
|
|
24
|
+
* when it was absent or unparseable. Only 429s set it in practice; it lives on
|
|
25
|
+
* the base so every mapped class shares one constructor signature.
|
|
22
26
|
*/
|
|
27
|
+
export interface EnginiAPIErrorOptions {
|
|
28
|
+
errorCode?: string;
|
|
29
|
+
details?: unknown[];
|
|
30
|
+
retryAfter?: number;
|
|
31
|
+
}
|
|
23
32
|
export declare class EnginiAPIError extends EnginiError {
|
|
24
33
|
readonly errorCode: string | undefined;
|
|
25
34
|
readonly details: unknown[];
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
details?: unknown[];
|
|
29
|
-
});
|
|
35
|
+
readonly retryAfter: number | undefined;
|
|
36
|
+
constructor(message: string, options?: EnginiAPIErrorOptions);
|
|
30
37
|
}
|
|
31
38
|
/** 401 or 403 — token missing, invalid, expired, or lacking permission. */
|
|
32
39
|
export declare class EnginiAuthError extends EnginiAPIError {
|
|
@@ -37,7 +44,7 @@ export declare class EnginiNotFoundError extends EnginiAPIError {
|
|
|
37
44
|
/** 400 or 422 — request rejected; exposes field-level details (Phase 3). */
|
|
38
45
|
export declare class EnginiValidationError extends EnginiAPIError {
|
|
39
46
|
}
|
|
40
|
-
/** 429 — rate limited
|
|
47
|
+
/** 429 — rate limited. `retryAfter` carries the `Retry-After` header in seconds. */
|
|
41
48
|
export declare class EnginiRateLimitError extends EnginiAPIError {
|
|
42
49
|
}
|
|
43
50
|
/** 409 — the request conflicts with current resource state. */
|
|
@@ -111,10 +118,7 @@ export declare class EnginiOpaAgentOfflineError extends EnginiConflictError {
|
|
|
111
118
|
*/
|
|
112
119
|
export declare class EnginiOpaApplicationAmbiguousError extends EnginiConflictError {
|
|
113
120
|
readonly candidateSlugs: string[];
|
|
114
|
-
constructor(message: string, candidateSlugs: string[], options?:
|
|
115
|
-
errorCode?: string;
|
|
116
|
-
details?: unknown[];
|
|
117
|
-
});
|
|
121
|
+
constructor(message: string, candidateSlugs: string[], options?: EnginiAPIErrorOptions);
|
|
118
122
|
}
|
|
119
123
|
/**
|
|
120
124
|
* The agent did not answer a live round-trip within the server's bound (wire code
|
|
@@ -130,3 +134,46 @@ export declare class EnginiOpaAgentTimeoutError extends EnginiServerError {
|
|
|
130
134
|
*/
|
|
131
135
|
export declare class EnginiOpaAgentDispatchError extends EnginiServerError {
|
|
132
136
|
}
|
|
137
|
+
/**
|
|
138
|
+
* The `since` cursor is older than the server's retained event window
|
|
139
|
+
* (wire code `SINCE_PRUNED`, 410).
|
|
140
|
+
*
|
|
141
|
+
* A hard stop for `triggers.subscribe`, never a silent restart: the whole point of
|
|
142
|
+
* `since` is that a gap in the stream is visible to the caller, so resuming from
|
|
143
|
+
* "now" would reintroduce exactly the invisible data loss the cursor exists to
|
|
144
|
+
* prevent. Recover by reading the missed events with `triggers.events.list` and
|
|
145
|
+
* subscribing again.
|
|
146
|
+
*
|
|
147
|
+
* 410 is the one trigger status with no row in `STATUS_TO_ERROR`; the retype
|
|
148
|
+
* happens on `errorCode` like the rest of this family.
|
|
149
|
+
*/
|
|
150
|
+
export declare class EnginiTriggerGapError extends EnginiAPIError {
|
|
151
|
+
}
|
|
152
|
+
/**
|
|
153
|
+
* Engini could not establish the upstream subscription with the provider
|
|
154
|
+
* (wire code `TRIGGER_SUBSCRIBE_FAILED`, 502). The trigger exists but is not
|
|
155
|
+
* receiving events; the provider rejected or dropped the registration.
|
|
156
|
+
*/
|
|
157
|
+
export declare class EnginiTriggerSubscribeFailedError extends EnginiServerError {
|
|
158
|
+
}
|
|
159
|
+
/**
|
|
160
|
+
* Too many concurrent SSE streams are open for this account (wire code
|
|
161
|
+
* `TRIGGER_STREAM_LIMIT_EXCEEDED`, 429). `retryAfter` carries the server's
|
|
162
|
+
* `Retry-After` in seconds, which `triggers.subscribe` honours before it retries.
|
|
163
|
+
*/
|
|
164
|
+
export declare class EnginiTriggerStreamLimitError extends EnginiRateLimitError {
|
|
165
|
+
}
|
|
166
|
+
/**
|
|
167
|
+
* A delivered webhook failed signature verification.
|
|
168
|
+
*
|
|
169
|
+
* Thrown by `verifyWebhook` for every rejection — a bad or absent signature, a
|
|
170
|
+
* malformed header, an unknown scheme version, or a timestamp outside the replay
|
|
171
|
+
* tolerance. Deliberately outside the `EnginiAPIError` tree: nothing here came
|
|
172
|
+
* from an Engini API response.
|
|
173
|
+
*
|
|
174
|
+
* It is an exception rather than a `false` return because a boolean is silently
|
|
175
|
+
* ignorable, and an ignored signature check is the one failure mode a webhook
|
|
176
|
+
* receiver cannot afford.
|
|
177
|
+
*/
|
|
178
|
+
export declare class EnginiWebhookSignatureError extends EnginiError {
|
|
179
|
+
}
|
package/dist/errors.js
CHANGED
|
@@ -11,25 +11,15 @@ export class EnginiError extends Error {
|
|
|
11
11
|
/** Transport-level failure before a response was received. */
|
|
12
12
|
export class EnginiNetworkError extends EnginiError {
|
|
13
13
|
}
|
|
14
|
-
/**
|
|
15
|
-
* Any non-2xx API response with a parseable body.
|
|
16
|
-
*
|
|
17
|
-
* `errorCode` is the wire `ErrorResponse.errorCode` when the body parsed, else
|
|
18
|
-
* `undefined`; `details` is the wire `details[]`, else `[]`.
|
|
19
|
-
*
|
|
20
|
-
* Both exist because a status code stopped being enough to describe an error:
|
|
21
|
-
* three OPA conditions share 409/5xx and differ only by `errorCode`, and
|
|
22
|
-
* `OPA_APPLICATION_AMBIGUOUS` carries its candidate slugs in `details` — the only
|
|
23
|
-
* place a caller can learn them. `message` is unchanged, so code reading it is
|
|
24
|
-
* unaffected.
|
|
25
|
-
*/
|
|
26
14
|
export class EnginiAPIError extends EnginiError {
|
|
27
15
|
errorCode;
|
|
28
16
|
details;
|
|
17
|
+
retryAfter;
|
|
29
18
|
constructor(message, options) {
|
|
30
19
|
super(message);
|
|
31
20
|
this.errorCode = options?.errorCode;
|
|
32
21
|
this.details = options?.details ?? [];
|
|
22
|
+
this.retryAfter = options?.retryAfter;
|
|
33
23
|
}
|
|
34
24
|
}
|
|
35
25
|
/** 401 or 403 — token missing, invalid, expired, or lacking permission. */
|
|
@@ -41,7 +31,7 @@ export class EnginiNotFoundError extends EnginiAPIError {
|
|
|
41
31
|
/** 400 or 422 — request rejected; exposes field-level details (Phase 3). */
|
|
42
32
|
export class EnginiValidationError extends EnginiAPIError {
|
|
43
33
|
}
|
|
44
|
-
/** 429 — rate limited
|
|
34
|
+
/** 429 — rate limited. `retryAfter` carries the `Retry-After` header in seconds. */
|
|
45
35
|
export class EnginiRateLimitError extends EnginiAPIError {
|
|
46
36
|
}
|
|
47
37
|
/** 409 — the request conflicts with current resource state. */
|
|
@@ -136,3 +126,46 @@ export class EnginiOpaAgentTimeoutError extends EnginiServerError {
|
|
|
136
126
|
*/
|
|
137
127
|
export class EnginiOpaAgentDispatchError extends EnginiServerError {
|
|
138
128
|
}
|
|
129
|
+
/**
|
|
130
|
+
* The `since` cursor is older than the server's retained event window
|
|
131
|
+
* (wire code `SINCE_PRUNED`, 410).
|
|
132
|
+
*
|
|
133
|
+
* A hard stop for `triggers.subscribe`, never a silent restart: the whole point of
|
|
134
|
+
* `since` is that a gap in the stream is visible to the caller, so resuming from
|
|
135
|
+
* "now" would reintroduce exactly the invisible data loss the cursor exists to
|
|
136
|
+
* prevent. Recover by reading the missed events with `triggers.events.list` and
|
|
137
|
+
* subscribing again.
|
|
138
|
+
*
|
|
139
|
+
* 410 is the one trigger status with no row in `STATUS_TO_ERROR`; the retype
|
|
140
|
+
* happens on `errorCode` like the rest of this family.
|
|
141
|
+
*/
|
|
142
|
+
export class EnginiTriggerGapError extends EnginiAPIError {
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
* Engini could not establish the upstream subscription with the provider
|
|
146
|
+
* (wire code `TRIGGER_SUBSCRIBE_FAILED`, 502). The trigger exists but is not
|
|
147
|
+
* receiving events; the provider rejected or dropped the registration.
|
|
148
|
+
*/
|
|
149
|
+
export class EnginiTriggerSubscribeFailedError extends EnginiServerError {
|
|
150
|
+
}
|
|
151
|
+
/**
|
|
152
|
+
* Too many concurrent SSE streams are open for this account (wire code
|
|
153
|
+
* `TRIGGER_STREAM_LIMIT_EXCEEDED`, 429). `retryAfter` carries the server's
|
|
154
|
+
* `Retry-After` in seconds, which `triggers.subscribe` honours before it retries.
|
|
155
|
+
*/
|
|
156
|
+
export class EnginiTriggerStreamLimitError extends EnginiRateLimitError {
|
|
157
|
+
}
|
|
158
|
+
/**
|
|
159
|
+
* A delivered webhook failed signature verification.
|
|
160
|
+
*
|
|
161
|
+
* Thrown by `verifyWebhook` for every rejection — a bad or absent signature, a
|
|
162
|
+
* malformed header, an unknown scheme version, or a timestamp outside the replay
|
|
163
|
+
* tolerance. Deliberately outside the `EnginiAPIError` tree: nothing here came
|
|
164
|
+
* from an Engini API response.
|
|
165
|
+
*
|
|
166
|
+
* It is an exception rather than a `false` return because a boolean is silently
|
|
167
|
+
* ignorable, and an ignored signature check is the one failure mode a webhook
|
|
168
|
+
* receiver cannot afford.
|
|
169
|
+
*/
|
|
170
|
+
export class EnginiWebhookSignatureError extends EnginiError {
|
|
171
|
+
}
|
package/dist/http.d.ts
CHANGED
|
@@ -56,6 +56,23 @@ type Operation<O, R> = (options: O & {
|
|
|
56
56
|
error?: unknown;
|
|
57
57
|
response?: Response;
|
|
58
58
|
}>;
|
|
59
|
+
/**
|
|
60
|
+
* Parse a `Retry-After` header into whole seconds, or `undefined`.
|
|
61
|
+
*
|
|
62
|
+
* RFC 9110 allows either a delay in seconds or an HTTP-date, and both are
|
|
63
|
+
* accepted here: a caller that backs off on the parsed value would otherwise
|
|
64
|
+
* silently fall back to its own guess against a server that answered in the date
|
|
65
|
+
* form. A past date clamps to 0 (retry now) rather than going negative.
|
|
66
|
+
*/
|
|
67
|
+
export declare function parseRetryAfter(value: string | null | undefined): number | undefined;
|
|
68
|
+
/**
|
|
69
|
+
* Shared helper: map an HTTP status to the appropriate error constructor.
|
|
70
|
+
*
|
|
71
|
+
* Exported because the triggers SSE stream never goes through a generated
|
|
72
|
+
* operation: it reads the error body off a raw `Response` and still has to land
|
|
73
|
+
* on exactly the same error classes as every other call.
|
|
74
|
+
*/
|
|
75
|
+
export declare function errorForStatus(status: number, error: unknown, headers?: Headers): Error;
|
|
59
76
|
/** Run a generated operation, map errors, return parsed success data. */
|
|
60
77
|
export declare function call<O extends object, R>(operation: Operation<O, R>, options: O): Promise<R>;
|
|
61
78
|
export {};
|
package/dist/http.js
CHANGED
|
@@ -95,8 +95,42 @@ export function buildClient(baseUrl, auth, companyToken, options = {}) {
|
|
|
95
95
|
});
|
|
96
96
|
return client;
|
|
97
97
|
}
|
|
98
|
-
/**
|
|
99
|
-
|
|
98
|
+
/**
|
|
99
|
+
* Parse a `Retry-After` header into whole seconds, or `undefined`.
|
|
100
|
+
*
|
|
101
|
+
* RFC 9110 allows either a delay in seconds or an HTTP-date, and both are
|
|
102
|
+
* accepted here: a caller that backs off on the parsed value would otherwise
|
|
103
|
+
* silently fall back to its own guess against a server that answered in the date
|
|
104
|
+
* form. A past date clamps to 0 (retry now) rather than going negative.
|
|
105
|
+
*/
|
|
106
|
+
export function parseRetryAfter(value) {
|
|
107
|
+
if (value === null || value === undefined)
|
|
108
|
+
return undefined;
|
|
109
|
+
const text = value.trim();
|
|
110
|
+
// RFC 9110's delay-seconds is `1*DIGIT` — unsigned — and Python's parser agrees, so
|
|
111
|
+
// both SDKs accept exactly this.
|
|
112
|
+
if (/^\d+$/.test(text))
|
|
113
|
+
return Number(text);
|
|
114
|
+
// Only try the date form on something that actually looks like one. `Date.parse` is
|
|
115
|
+
// lax enough to read "-5" as a date in 2001, which would silently turn a malformed
|
|
116
|
+
// header into a real (and wrong) delay; Python's `parsedate_to_datetime` rejects it.
|
|
117
|
+
if (!/^[A-Za-z]{3}/.test(text))
|
|
118
|
+
return undefined;
|
|
119
|
+
const when = Date.parse(text);
|
|
120
|
+
if (Number.isNaN(when))
|
|
121
|
+
return undefined;
|
|
122
|
+
// Rounded up, never down: honouring a `Retry-After` a fraction early is the one
|
|
123
|
+
// direction that defeats the point of the header.
|
|
124
|
+
return Math.max(0, Math.ceil((when - Date.now()) / 1000));
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* Shared helper: map an HTTP status to the appropriate error constructor.
|
|
128
|
+
*
|
|
129
|
+
* Exported because the triggers SSE stream never goes through a generated
|
|
130
|
+
* operation: it reads the error body off a raw `Response` and still has to land
|
|
131
|
+
* on exactly the same error classes as every other call.
|
|
132
|
+
*/
|
|
133
|
+
export function errorForStatus(status, error, headers) {
|
|
100
134
|
const message = errorMessage(error, status);
|
|
101
135
|
const Ctor = STATUS_TO_ERROR[status] ?? (status >= 500 ? EnginiServerError : EnginiAPIError);
|
|
102
136
|
// Carry the parsed body, not just its rendered message: callers need to tell
|
|
@@ -106,6 +140,7 @@ function errorForStatus(status, error) {
|
|
|
106
140
|
return new Ctor(message, {
|
|
107
141
|
errorCode: typeof body.errorCode === "string" ? body.errorCode : undefined,
|
|
108
142
|
details: Array.isArray(body.details) ? body.details : [],
|
|
143
|
+
retryAfter: parseRetryAfter(headers?.get("retry-after")),
|
|
109
144
|
});
|
|
110
145
|
}
|
|
111
146
|
/** Run a generated operation, map errors, return parsed success data. */
|
|
@@ -118,7 +153,7 @@ export async function call(operation, options) {
|
|
|
118
153
|
// Check if the thrown value carries a response (e.g. hey-api throws on empty-body parse errors)
|
|
119
154
|
const errWithResponse = err;
|
|
120
155
|
if (errWithResponse.response instanceof Response) {
|
|
121
|
-
throw errorForStatus(errWithResponse.response.status, undefined);
|
|
156
|
+
throw errorForStatus(errWithResponse.response.status, undefined, errWithResponse.response.headers);
|
|
122
157
|
}
|
|
123
158
|
throw new EnginiNetworkError(err instanceof Error ? err.message : String(err));
|
|
124
159
|
}
|
|
@@ -130,7 +165,7 @@ export async function call(operation, options) {
|
|
|
130
165
|
if (status >= 200 && status < 300) {
|
|
131
166
|
return data;
|
|
132
167
|
}
|
|
133
|
-
throw errorForStatus(status, error);
|
|
168
|
+
throw errorForStatus(status, error, response.headers);
|
|
134
169
|
}
|
|
135
170
|
function errorMessage(error, status) {
|
|
136
171
|
if (error && typeof error === "object") {
|
package/dist/index.d.ts
CHANGED
|
@@ -5,9 +5,10 @@ export type { Auth } from "./auth.js";
|
|
|
5
5
|
export { composeUserAgent } from "./http.js";
|
|
6
6
|
export type { Verify } from "./http.js";
|
|
7
7
|
export { VERSION } from "./version.js";
|
|
8
|
-
export { EnginiError, EnginiNetworkError, EnginiAPIError, EnginiAuthError, EnginiNotFoundError, EnginiValidationError, EnginiRateLimitError, EnginiConflictError, EnginiServerError, EnginiClientError, EnginiConnectionError, EnginiToolsetError, EnginiToolsetNotFoundError, EnginiMcpServerNotFoundError, EnginiTimeoutError, EnginiToolExecutionError, EnginiOpaAgentNotFoundError, EnginiOpaAgentOfflineError, EnginiOpaApplicationAmbiguousError, EnginiOpaAgentTimeoutError, EnginiOpaAgentDispatchError, } from "./errors.js";
|
|
9
|
-
export {
|
|
10
|
-
export
|
|
8
|
+
export { EnginiError, EnginiNetworkError, EnginiAPIError, EnginiAuthError, EnginiNotFoundError, EnginiValidationError, EnginiRateLimitError, EnginiConflictError, EnginiServerError, EnginiClientError, EnginiConnectionError, EnginiToolsetError, EnginiToolsetNotFoundError, EnginiMcpServerNotFoundError, EnginiTimeoutError, EnginiToolExecutionError, EnginiOpaAgentNotFoundError, EnginiOpaAgentOfflineError, EnginiOpaApplicationAmbiguousError, EnginiOpaAgentTimeoutError, EnginiOpaAgentDispatchError, EnginiTriggerGapError, EnginiTriggerSubscribeFailedError, EnginiTriggerStreamLimitError, EnginiWebhookSignatureError, } from "./errors.js";
|
|
9
|
+
export type { EnginiAPIErrorOptions } from "./errors.js";
|
|
10
|
+
export { ToolsResource, ConnectionsResource, ToolsetsResource, McpResource, OpaResource, TriggersResource, ApplicationsResource, refreshFailed, verifyWebhook, } from "./resources/index.js";
|
|
11
|
+
export type { ToolsGetOptions, ToolsExecuteOptions, ApplicationsListOptions, TriggersClient, TriggerWebhookEvent, } from "./resources/index.js";
|
|
11
12
|
export { Toolset } from "./toolset.js";
|
|
12
13
|
export type { ConnectionBinding, ToolsetExecuteOptions } from "./toolset.js";
|
|
13
14
|
export { File } from "./files.js";
|
|
@@ -15,6 +16,7 @@ export type { FileWire } from "./files.js";
|
|
|
15
16
|
export type { ToolSchema, Filter, Sort, ToolExecuteResult, Application, ApplicationDetail, Connection, ConnectionDetail, ConnectionObject, WhoAmI, } from "./types.js";
|
|
16
17
|
export type { ToolsetConnectionDto, ToolsetConnectionRequest, ToolsetDto } from "@engini/client";
|
|
17
18
|
export type { OpaAgentListItem, OpaAgentDetail, OpaAgentSettings, OpaAgentTokenResponse, OpaAgentCreateResponse, OpaReleaseManifest, CreateOpaAgentRequest, UpdateOpaAgentRequest, } from "@engini/client";
|
|
19
|
+
export type { TriggerTypeDto, TriggerTypeDetailDto, TriggerParametersDto, TriggerInstanceView, TriggerInstanceStatus, TriggerKind, TriggerStatusReason, TriggerScheduleDto, TriggerScheduleFrequency, TriggerTimeFrameDto, TriggerEventView, TriggerEventDetailView, TriggerEventDeliveryStateDto, TriggerDeliveryAttemptView, TriggerDestinationView, TriggerDestinationCreated, TriggerDestinationStatusDto, CreateTriggerRequest, PatchTriggerRequest, CreateTriggerDestinationRequest, PatchTriggerDestinationRequest, PutDefaultDestinationRequest, } from "@engini/client";
|
|
18
20
|
export type { McpServerPublicDto, McpServerConnectionDto, McpServerConnectionRequest, McpServerWorkflowDto, McpServerWorkflowRequest, McpAvailableToolDto, } from "@engini/client";
|
|
19
21
|
export type { Provider, ToolCall, ToolResultOptions } from "./providers/base.js";
|
|
20
22
|
export { OpenAIProvider } from "./providers/openai.js";
|
package/dist/index.js
CHANGED
|
@@ -2,8 +2,8 @@ export { Engini, DEFAULT_BASE_URL } from "./client.js";
|
|
|
2
2
|
export { ApiKeyAuth, BearerAuth, ENV_API_KEY_VAR, ENV_TOKEN_VAR, ENV_COMPANY_TOKEN_VAR, } from "./auth.js";
|
|
3
3
|
export { composeUserAgent } from "./http.js";
|
|
4
4
|
export { VERSION } from "./version.js";
|
|
5
|
-
export { EnginiError, EnginiNetworkError, EnginiAPIError, EnginiAuthError, EnginiNotFoundError, EnginiValidationError, EnginiRateLimitError, EnginiConflictError, EnginiServerError, EnginiClientError, EnginiConnectionError, EnginiToolsetError, EnginiToolsetNotFoundError, EnginiMcpServerNotFoundError, EnginiTimeoutError, EnginiToolExecutionError, EnginiOpaAgentNotFoundError, EnginiOpaAgentOfflineError, EnginiOpaApplicationAmbiguousError, EnginiOpaAgentTimeoutError, EnginiOpaAgentDispatchError, } from "./errors.js";
|
|
6
|
-
export { ToolsResource, ConnectionsResource, ToolsetsResource, McpResource, OpaResource, ApplicationsResource, refreshFailed, } from "./resources/index.js";
|
|
5
|
+
export { EnginiError, EnginiNetworkError, EnginiAPIError, EnginiAuthError, EnginiNotFoundError, EnginiValidationError, EnginiRateLimitError, EnginiConflictError, EnginiServerError, EnginiClientError, EnginiConnectionError, EnginiToolsetError, EnginiToolsetNotFoundError, EnginiMcpServerNotFoundError, EnginiTimeoutError, EnginiToolExecutionError, EnginiOpaAgentNotFoundError, EnginiOpaAgentOfflineError, EnginiOpaApplicationAmbiguousError, EnginiOpaAgentTimeoutError, EnginiOpaAgentDispatchError, EnginiTriggerGapError, EnginiTriggerSubscribeFailedError, EnginiTriggerStreamLimitError, EnginiWebhookSignatureError, } from "./errors.js";
|
|
6
|
+
export { ToolsResource, ConnectionsResource, ToolsetsResource, McpResource, OpaResource, TriggersResource, ApplicationsResource, refreshFailed, verifyWebhook, } from "./resources/index.js";
|
|
7
7
|
export { Toolset } from "./toolset.js";
|
|
8
8
|
export { File } from "./files.js";
|
|
9
9
|
export { OpenAIProvider } from "./providers/openai.js";
|
|
@@ -5,5 +5,7 @@ export { ToolsetsResource } from "./toolsets.js";
|
|
|
5
5
|
export { McpResource } from "./mcp.js";
|
|
6
6
|
export { OpaResource } from "./opa.js";
|
|
7
7
|
export type { OpaClient } from "./opa.js";
|
|
8
|
+
export { TriggersResource, verifyWebhook } from "./triggers.js";
|
|
9
|
+
export type { TriggersClient, TriggerWebhookEvent } from "./triggers.js";
|
|
8
10
|
export { ApplicationsResource } from "./applications.js";
|
|
9
11
|
export type { ApplicationsListOptions } from "./applications.js";
|
package/dist/resources/index.js
CHANGED
|
@@ -3,4 +3,5 @@ export { ConnectionsResource, refreshFailed } from "./connections.js";
|
|
|
3
3
|
export { ToolsetsResource } from "./toolsets.js";
|
|
4
4
|
export { McpResource } from "./mcp.js";
|
|
5
5
|
export { OpaResource } from "./opa.js";
|
|
6
|
+
export { TriggersResource, verifyWebhook } from "./triggers.js";
|
|
6
7
|
export { ApplicationsResource } from "./applications.js";
|