@composio/client 2.0.0-rc.18 → 2.0.0-rc.19
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 +36 -14
- package/dist/{api-key-revocation-JkA4sOGH.mjs → api-key-revocation-DMCgun-A.mjs} +1 -1
- package/dist/{auth-B_K-wdMm.mjs → auth-D-U9Aq8C.mjs} +1 -1
- package/dist/{auth-configs-RAgN782Z.mjs → auth-configs-DAG5mMeH.mjs} +1 -1
- package/dist/{clanker-Pgyyh95r.mjs → clanker-Yomp86hJ.mjs} +1 -1
- package/dist/{cli-Ca5bRiEN.mjs → cli-zihiw3aI.mjs} +2 -2
- package/dist/{connected-accounts-D6NTwvbi.mjs → connected-accounts-Bd4AbWoH.mjs} +1 -1
- package/dist/{consumer-BP4OyJS0.mjs → consumer-Bk0cyIii.mjs} +2 -2
- package/dist/{custom-DA3ABHnI.mjs → custom-Ce8G2c11.mjs} +1 -1
- package/dist/{custom-BBr7KbCv.mjs → custom-DWT3cCog.mjs} +1 -1
- package/dist/effect.d.mts +16 -60
- package/dist/effect.mjs +146 -182
- package/dist/{files-CeBs4ZE1.mjs → files-DRp_J4zH.mjs} +1 -1
- package/dist/{files-DLRmNLRD.mjs → files-ZxEVlE_y.mjs} +1 -1
- package/dist/{generate-16uLPwUU.mjs → generate-Du9XUrlx.mjs} +1 -1
- package/dist/{generated-deprecated-inputs-zx6ml908.mjs → generated-deprecated-inputs-Dy_lBver.mjs} +1 -1
- package/dist/{generated-operations-DKgGT6Dg.mjs → generated-operations-Dv7pAKDT.mjs} +150 -250
- package/dist/index.d.mts +3 -3
- package/dist/index.mjs +60 -140
- package/dist/{keyring-Q8GSieAv.mjs → keyring-CgOIS5x7.mjs} +1 -1
- package/dist/{link-D4dY_eaN.mjs → link-CW1ts4pm.mjs} +1 -1
- package/dist/{logs-Dc63Ju74.mjs → logs-DFdH5DoT.mjs} +3 -3
- package/dist/{manage-ByF6b3OD.mjs → manage-CeB03gO8.mjs} +1 -1
- package/dist/{mcp-Cw7-Mtkm.mjs → mcp-DNRMWWum.mjs} +3 -3
- package/dist/{org-RRUxKfRw.mjs → org-HuYaKgVf.mjs} +6 -6
- package/dist/{owner-GZX-sp-h.mjs → owner-I9fXmIO_.mjs} +1 -1
- package/dist/{project-Cj9ULE0a.mjs → project-CxQ2H8UB.mjs} +1 -1
- package/dist/{project-C_YZ-eLI.mjs → project-DcV01umC.mjs} +1 -1
- package/dist/{project-BsKmk9T7.mjs → project-Dwblmpw8.mjs} +1 -1
- package/dist/{project-C1uq7bV_.mjs → project-FuP5k9R1.mjs} +1 -1
- package/dist/{realtime-W-lJ0Vcs.mjs → realtime-F_sGuTd8.mjs} +1 -1
- package/dist/resources/api-key-revocation.d.mts +1 -1
- package/dist/resources/api-key-revocation.mjs +1 -1
- package/dist/resources/auth/auth.d.mts +1 -1
- package/dist/resources/auth/auth.mjs +1 -1
- package/dist/resources/auth/index.d.mts +1 -1
- package/dist/resources/auth/index.mjs +2 -2
- package/dist/resources/auth/session.d.mts +1 -1
- package/dist/resources/auth/session.mjs +1 -1
- package/dist/resources/auth-configs.d.mts +1 -1
- package/dist/resources/auth-configs.mjs +1 -1
- package/dist/resources/auth.d.mts +1 -1
- package/dist/resources/auth.mjs +2 -2
- package/dist/resources/cli/cli.d.mts +1 -1
- package/dist/resources/cli/cli.mjs +1 -1
- package/dist/resources/cli/index.d.mts +1 -1
- package/dist/resources/cli/index.mjs +2 -2
- package/dist/resources/cli/realtime.d.mts +1 -1
- package/dist/resources/cli/realtime.mjs +1 -1
- package/dist/resources/cli.d.mts +1 -1
- package/dist/resources/cli.mjs +2 -2
- package/dist/resources/connected-accounts.d.mts +1 -1
- package/dist/resources/connected-accounts.mjs +1 -1
- package/dist/resources/custom.d.mts +1 -1
- package/dist/resources/custom.mjs +1 -1
- package/dist/resources/files.d.mts +1 -1
- package/dist/resources/files.mjs +1 -1
- package/dist/resources/index.d.mts +1 -1
- package/dist/resources/index.mjs +13 -13
- package/dist/resources/keyring.d.mts +1 -1
- package/dist/resources/keyring.mjs +1 -1
- package/dist/resources/link.d.mts +1 -1
- package/dist/resources/link.mjs +1 -1
- package/dist/resources/logs/index.d.mts +1 -1
- package/dist/resources/logs/index.mjs +3 -3
- package/dist/resources/logs/logs.d.mts +1 -1
- package/dist/resources/logs/logs.mjs +1 -1
- package/dist/resources/logs/tools.d.mts +1 -1
- package/dist/resources/logs/tools.mjs +1 -1
- package/dist/resources/logs/triggers.d.mts +1 -1
- package/dist/resources/logs/triggers.mjs +1 -1
- package/dist/resources/logs.d.mts +1 -1
- package/dist/resources/logs.mjs +3 -3
- package/dist/resources/mcp/custom.d.mts +1 -1
- package/dist/resources/mcp/custom.mjs +1 -1
- package/dist/resources/mcp/generate.d.mts +1 -1
- package/dist/resources/mcp/generate.mjs +1 -1
- package/dist/resources/mcp/index.d.mts +1 -1
- package/dist/resources/mcp/index.mjs +3 -3
- package/dist/resources/mcp/mcp.d.mts +1 -1
- package/dist/resources/mcp/mcp.mjs +1 -1
- package/dist/resources/mcp.d.mts +1 -1
- package/dist/resources/mcp.mjs +3 -3
- package/dist/resources/org/clanker.d.mts +1 -1
- package/dist/resources/org/clanker.mjs +1 -1
- package/dist/resources/org/consumer/consumer.d.mts +1 -1
- package/dist/resources/org/consumer/consumer.mjs +1 -1
- package/dist/resources/org/consumer/index.d.mts +1 -1
- package/dist/resources/org/consumer/index.mjs +2 -2
- package/dist/resources/org/consumer/project.d.mts +1 -1
- package/dist/resources/org/consumer/project.mjs +1 -1
- package/dist/resources/org/consumer.d.mts +1 -1
- package/dist/resources/org/consumer.mjs +2 -2
- package/dist/resources/org/index.d.mts +1 -1
- package/dist/resources/org/index.mjs +6 -6
- package/dist/resources/org/org.d.mts +1 -1
- package/dist/resources/org/org.mjs +1 -1
- package/dist/resources/org/owner/index.d.mts +1 -1
- package/dist/resources/org/owner/index.mjs +2 -2
- package/dist/resources/org/owner/owner.d.mts +1 -1
- package/dist/resources/org/owner/owner.mjs +1 -1
- package/dist/resources/org/owner/project.d.mts +1 -1
- package/dist/resources/org/owner/project.mjs +1 -1
- package/dist/resources/org/owner.d.mts +1 -1
- package/dist/resources/org/owner.mjs +2 -2
- package/dist/resources/org/project.d.mts +1 -1
- package/dist/resources/org/project.mjs +1 -1
- package/dist/resources/org/usage.d.mts +1 -1
- package/dist/resources/org/usage.mjs +1 -1
- package/dist/resources/org.d.mts +1 -1
- package/dist/resources/org.mjs +6 -6
- package/dist/resources/project/index.d.mts +1 -1
- package/dist/resources/project/index.mjs +1 -1
- package/dist/resources/project/project.d.mts +1 -1
- package/dist/resources/project/project.mjs +1 -1
- package/dist/resources/project/usage.d.mts +1 -1
- package/dist/resources/project/usage.mjs +1 -1
- package/dist/resources/project.d.mts +1 -1
- package/dist/resources/project.mjs +1 -1
- package/dist/resources/session-configs.d.mts +1 -1
- package/dist/resources/session-configs.mjs +1 -1
- package/dist/resources/tool-router/index.d.mts +1 -1
- package/dist/resources/tool-router/index.mjs +2 -2
- package/dist/resources/tool-router/session/files.d.mts +1 -1
- package/dist/resources/tool-router/session/files.mjs +1 -1
- package/dist/resources/tool-router/session/index.d.mts +1 -1
- package/dist/resources/tool-router/session/index.mjs +2 -2
- package/dist/resources/tool-router/session/session.d.mts +1 -1
- package/dist/resources/tool-router/session/session.mjs +1 -1
- package/dist/resources/tool-router/session.d.mts +1 -1
- package/dist/resources/tool-router/session.mjs +2 -2
- package/dist/resources/tool-router/tool-router.d.mts +1 -1
- package/dist/resources/tool-router/tool-router.mjs +1 -1
- package/dist/resources/tool-router.d.mts +1 -1
- package/dist/resources/tool-router.mjs +2 -2
- package/dist/resources/toolkits.d.mts +1 -1
- package/dist/resources/toolkits.mjs +1 -1
- package/dist/resources/tools.d.mts +1 -1
- package/dist/resources/tools.mjs +1 -1
- package/dist/resources/trigger-instances/index.d.mts +1 -1
- package/dist/resources/trigger-instances/index.mjs +2 -2
- package/dist/resources/trigger-instances/manage.d.mts +1 -1
- package/dist/resources/trigger-instances/manage.mjs +1 -1
- package/dist/resources/trigger-instances/trigger-instances.d.mts +1 -1
- package/dist/resources/trigger-instances/trigger-instances.mjs +1 -1
- package/dist/resources/trigger-instances.d.mts +1 -1
- package/dist/resources/trigger-instances.mjs +2 -2
- package/dist/resources/triggers-types.d.mts +1 -1
- package/dist/resources/triggers-types.mjs +1 -1
- package/dist/resources/webhook-endpoints.d.mts +1 -1
- package/dist/resources/webhook-endpoints.mjs +1 -1
- package/dist/resources/webhook-subscriptions.d.mts +1 -1
- package/dist/resources/webhook-subscriptions.mjs +1 -1
- package/dist/{session-BT5NJfbm.mjs → session-B-ifOjVv.mjs} +1 -1
- package/dist/{session-BmXeclWC.mjs → session-CpwJh7Hn.mjs} +2 -2
- package/dist/{session-configs-x3OA4CSe.d.mts → session-configs-BLy_O6bX.d.mts} +21 -101
- package/dist/{tool-router-DYPUf-fN.mjs → tool-router-jNsaldKV.mjs} +1 -1
- package/dist/{toolkits-DZOZDm-4.mjs → toolkits-DK4My9FW.mjs} +1 -1
- package/dist/{tools-C0GjPEpP.mjs → tools-DNkimllW.mjs} +1 -1
- package/dist/{tools-BDCRk80t.mjs → tools-Gun_2We6.mjs} +1 -1
- package/dist/{trigger-instances-J5frdgzO.mjs → trigger-instances-vvKswQSW.mjs} +2 -2
- package/dist/{triggers-CnvE7y0L.mjs → triggers-CfrGxKIo.mjs} +1 -1
- package/dist/{triggers-types-DLVCtuwC.mjs → triggers-types-DYW2Mr8z.mjs} +1 -1
- package/dist/{usage-DjQg9WIV.mjs → usage-YIBYNpVF.mjs} +1 -1
- package/dist/{usage-DPxuivP6.mjs → usage-vt9HmnNf.mjs} +1 -1
- package/dist/version-DB98yI2B.d.mts +4 -0
- package/dist/{webhook-endpoints-BrSjXOf0.mjs → webhook-endpoints-HqLteVW6.mjs} +1 -1
- package/dist/{webhook-subscriptions-HT1acmwH.mjs → webhook-subscriptions-CXhNXIOM.mjs} +1 -1
- package/package.json +2 -2
- package/dist/version-DEAhxVwC.d.mts +0 -4
package/dist/effect.mjs
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { h as makeAPIErrorMessage, m as errorDetails, s as ComposioError } from "./error-Bw7_G2NZ.mjs";
|
|
2
|
-
import { B as
|
|
3
|
-
import { r as classifySuccessBody, t as GENERATED_DEPRECATED_INPUTS } from "./generated-deprecated-inputs-
|
|
2
|
+
import { B as SCHEME_HEADERS, C as resolveIdentity, D as inspectDeprecatedInputs, E as mergeHeaders, F as chooseCredential, H as carriesCredentials, I as credentialHeader, L as resolveAuth, M as assertRequiredOperationHeaders, N as authConstructors, O as inspectDeprecation, P as authFromCredentials, R as resolveScope, S as reservedHeaders, T as buildHeaders, U as parseHTTPURL, V as assertCredentialTransport, W as resolveHTTPURL, _ as shouldRetryResponse, a as TOO_MANY_REDIRECTS, c as buildURL, d as path, f as printableURL, g as safeJSON, h as rewriteForRedirect, i as REDIRECT_STATUSES, j as assertNoRemovedCredentialOptions, k as matchOperation, m as retryDelayMillis, n as generatedOperation, o as buildBody, r as OPAQUE_REDIRECT, s as buildRequestHeaders, t as GENERATED_OPERATIONS, v as validatePositiveInteger, w as VERSION, x as assertNoReservedHeaders, z as scopeForCall } from "./generated-operations-Dv7pAKDT.mjs";
|
|
3
|
+
import { r as classifySuccessBody, t as GENERATED_DEPRECATED_INPUTS } from "./generated-deprecated-inputs-Dy_lBver.mjs";
|
|
4
4
|
import { i as standardNextCursor, n as assertPageItems, r as isFinalCursor, t as assertCursorAdvanced } from "./pagination-rules-CMnBwktJ.mjs";
|
|
5
|
-
import { Config, Context, Data, Effect, Exit, Layer, Match, Option, Predicate, Redacted, Result, Stream, Tracer } from "effect";
|
|
6
|
-
import * as FetchHttpClient from "effect/http/FetchHttpClient";
|
|
5
|
+
import { Config, Context, Data, Effect, Exit, Layer, Match, Option, Predicate, Redacted, References, Result, Stream, Tracer } from "effect";
|
|
7
6
|
import * as HttpClient from "effect/http/HttpClient";
|
|
8
7
|
import * as Headers from "effect/http/Headers";
|
|
9
8
|
import * as Schema from "effect/Schema";
|
|
9
|
+
import * as FetchHttpClient from "effect/http/FetchHttpClient";
|
|
10
10
|
import * as HttpBody from "effect/http/HttpBody";
|
|
11
11
|
import { StatusCodeError, isHttpClientError } from "effect/http/HttpClientError";
|
|
12
12
|
import * as HttpClientRequest from "effect/http/HttpClientRequest";
|
|
@@ -128,57 +128,36 @@ const isComposioError = (value) => kindOf(value) !== void 0;
|
|
|
128
128
|
* credential is a `Redacted` for as long as the client holds it — and Effect's
|
|
129
129
|
* redaction list, which knows `x-api-key` and not the other two schemes.
|
|
130
130
|
*/
|
|
131
|
-
const
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
if (
|
|
131
|
+
const reveal = (key) => typeof key === "string" ? key : Redacted.value(key);
|
|
132
|
+
const EFFECT_CREDENTIAL = {
|
|
133
|
+
is: (value) => typeof value === "function" || typeof value === "string" || Redacted.isRedacted(value),
|
|
134
|
+
keyOf: (credential) => typeof credential === "function" ? void 0 : reveal(credential)
|
|
135
|
+
};
|
|
136
|
+
const hold = (credential) => {
|
|
137
|
+
if (typeof credential === "string") return Redacted.make(credential);
|
|
138
|
+
return credential;
|
|
138
139
|
};
|
|
139
|
-
/** Wraps every key `auth` holds, so the kernel never keeps one in the clear. */
|
|
140
140
|
const holdAuth = (auth) => ({
|
|
141
141
|
mode: auth.mode,
|
|
142
|
-
credentials: Object.fromEntries(Object.entries(auth.credentials).map(([scheme, credential]) => [scheme,
|
|
142
|
+
credentials: Object.fromEntries(Object.entries(auth.credentials).map(([scheme, credential]) => [scheme, hold(credential)]))
|
|
143
143
|
});
|
|
144
|
-
const reveal = (key) => typeof key === "string" ? key : Redacted.value(key);
|
|
145
144
|
const providerFailed = () => new ConfigurationError({ message: "The `auth` credential provider failed." });
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
* any network work; the rule is the compat kernel's `resolveCallCredential`.
|
|
149
|
-
* A configured credential is asked for only when the call starts on the API
|
|
150
|
-
* origin. A provider that fails, or returns something no header can carry,
|
|
151
|
-
* fails the call with a `ConfigurationError` that holds neither the
|
|
152
|
-
* provider's error nor the value.
|
|
153
|
-
*/
|
|
154
|
-
const resolveCallCredential = (auth, baseURL, operation, supplied, requestURL) => Effect.suspend(() => {
|
|
155
|
-
let choice;
|
|
156
|
-
try {
|
|
157
|
-
choice = chooseCredential(auth, operation, supplied);
|
|
158
|
-
} catch (cause) {
|
|
159
|
-
return Effect.fail(configurationErrorFrom(cause));
|
|
160
|
-
}
|
|
161
|
-
if (choice === null) return Effect.succeed(null);
|
|
162
|
-
const name = schemeHeader(choice.scheme);
|
|
163
|
-
if (choice.kind === "operation") return Effect.succeed({
|
|
164
|
-
name,
|
|
165
|
-
value: choice.key
|
|
166
|
-
});
|
|
167
|
-
if (!sameOrigin(baseURL, requestURL)) return Effect.succeed(null);
|
|
168
|
-
const credential = choice.credential;
|
|
169
|
-
if (typeof credential !== "function") return Effect.succeed({
|
|
170
|
-
name,
|
|
171
|
-
value: Redacted.value(credential)
|
|
172
|
-
});
|
|
173
|
-
const scheme = choice.scheme;
|
|
145
|
+
const keyOf = (credential) => {
|
|
146
|
+
if (typeof credential !== "function") return Effect.succeed(reveal(credential));
|
|
174
147
|
return Effect.tryPromise({
|
|
175
148
|
try: async () => reveal(await credential()),
|
|
176
149
|
catch: providerFailed
|
|
177
|
-
})
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
150
|
+
});
|
|
151
|
+
};
|
|
152
|
+
/** The compat kernel's rule, with failures as `ConfigurationError`s that hold neither the provider's error nor a key. */
|
|
153
|
+
const resolveCallCredential = (auth, baseURL, requestURL, operation, supplied) => {
|
|
154
|
+
const choice = chooseCredential(auth, baseURL, requestURL, operation, supplied);
|
|
155
|
+
if (choice === null) return Effect.succeed(null);
|
|
156
|
+
return Effect.flatMap(keyOf(choice.credential), (key) => Effect.try({
|
|
157
|
+
try: () => credentialHeader(choice.scheme, key),
|
|
158
|
+
catch: configurationErrorFrom
|
|
159
|
+
}));
|
|
160
|
+
};
|
|
182
161
|
const CREDENTIAL_HEADER_NAMES = Object.values(SCHEME_HEADERS);
|
|
183
162
|
/** The extended list for each list seen, so a request does not rebuild it. */
|
|
184
163
|
const extended = /* @__PURE__ */ new WeakMap();
|
|
@@ -271,6 +250,45 @@ const responseIssues = (loaders, key, body) => {
|
|
|
271
250
|
}), (schema) => issuesOf(schema, body));
|
|
272
251
|
};
|
|
273
252
|
|
|
253
|
+
//#endregion
|
|
254
|
+
//#region src/effect/pagination.ts
|
|
255
|
+
/**
|
|
256
|
+
* Cursor pagination as a `Stream`: the items of a standard `items` /
|
|
257
|
+
* `next_cursor` operation, one page requested at a time and only when the
|
|
258
|
+
* stream is pulled that far, so a consumer that stops — or is interrupted —
|
|
259
|
+
* causes no further request.
|
|
260
|
+
*
|
|
261
|
+
* The cursor rules are the ones `./pagination` traverses by, called rather
|
|
262
|
+
* than restated: an absent, null or empty `next_cursor` ends the stream, a
|
|
263
|
+
* cursor the server repeats fails it, and so does a page-number envelope that
|
|
264
|
+
* leaves `next_cursor` out before its last page.
|
|
265
|
+
*/
|
|
266
|
+
/**
|
|
267
|
+
* One page's items and the position after it, or the reason the traversal
|
|
268
|
+
* cannot go on. No request would change that reason, so it is a
|
|
269
|
+
* {@link ConfigurationError} carrying the message `./pagination` throws.
|
|
270
|
+
*/
|
|
271
|
+
const advance = (page, seen) => Result.try({
|
|
272
|
+
try: () => {
|
|
273
|
+
const items = page.items;
|
|
274
|
+
assertPageItems(items);
|
|
275
|
+
const cursor = standardNextCursor(page);
|
|
276
|
+
if (isFinalCursor(cursor)) return [items, Option.none()];
|
|
277
|
+
assertCursorAdvanced(seen, cursor);
|
|
278
|
+
seen.add(cursor);
|
|
279
|
+
return [items, Option.some(cursor)];
|
|
280
|
+
},
|
|
281
|
+
catch: configurationErrorFrom
|
|
282
|
+
});
|
|
283
|
+
/**
|
|
284
|
+
* The items of every page `fetchPage` returns, in order. `fetchPage` is first
|
|
285
|
+
* called with no cursor, then with each `next_cursor` in turn.
|
|
286
|
+
*/
|
|
287
|
+
const cursorStream = (fetchPage) => Stream.suspend(() => {
|
|
288
|
+
const seen = /* @__PURE__ */ new Set();
|
|
289
|
+
return Stream.paginate(void 0, (cursor) => Effect.flatMap(fetchPage(cursor), (page) => Effect.fromResult(advance(page, seen))));
|
|
290
|
+
});
|
|
291
|
+
|
|
274
292
|
//#endregion
|
|
275
293
|
//#region src/effect/deprecation.ts
|
|
276
294
|
/**
|
|
@@ -282,27 +300,30 @@ const responseIssues = (loaders, key, body) => {
|
|
|
282
300
|
* notice is a `Warn` record on Effect's logger, so the application's logger
|
|
283
301
|
* and minimum log level decide what becomes of it.
|
|
284
302
|
*/
|
|
285
|
-
const
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
303
|
+
const NOTICE_ANNOTATION = "composio.client.notice";
|
|
304
|
+
const DEPRECATION = "deprecation";
|
|
305
|
+
const noticeAnnotation = (options) => options.fiber.getRef(References.CurrentLogAnnotations)[NOTICE_ANNOTATION];
|
|
306
|
+
/** Whether a log record is one of this client's deprecation notices, for a `Logger` that drops or routes them. */
|
|
307
|
+
const isDeprecationNotice = Predicate.mapInput((value) => value === DEPRECATION, noticeAnnotation);
|
|
308
|
+
const logNotice = (message) => Effect.logWarning(message).pipe(Effect.annotateLogs(NOTICE_ANNOTATION, DEPRECATION));
|
|
289
309
|
/** The compat inspectors report through a callback; this collects what one of them said. */
|
|
290
310
|
const warnings = (inspect) => {
|
|
291
311
|
const messages = [];
|
|
292
312
|
inspect((message) => messages.push(message));
|
|
293
|
-
return messages.length === 0 ? Effect.void : Effect.forEach(messages,
|
|
313
|
+
return messages.length === 0 ? Effect.void : Effect.forEach(messages, logNotice, { discard: true });
|
|
294
314
|
};
|
|
295
315
|
/**
|
|
296
316
|
* The notice for inputs the spec marks deprecated, decided from the request
|
|
297
317
|
* alone — so it is given before dispatch, whatever the transport then does.
|
|
318
|
+
* `seen` is the client's (operation, notice) record, so one client warns once.
|
|
298
319
|
*/
|
|
299
|
-
const noticeDeprecatedInputs = (
|
|
320
|
+
const noticeDeprecatedInputs = (seen, input) => input.operation === null ? Effect.void : Effect.suspend(() => warnings((warn) => inspectDeprecatedInputs({
|
|
300
321
|
operation: input.operation,
|
|
301
322
|
query: input.query,
|
|
302
323
|
body: input.body,
|
|
303
324
|
headers: input.headers(),
|
|
304
325
|
table: GENERATED_DEPRECATED_INPUTS,
|
|
305
|
-
seen
|
|
326
|
+
seen,
|
|
306
327
|
warn
|
|
307
328
|
})));
|
|
308
329
|
/**
|
|
@@ -310,7 +331,7 @@ const noticeDeprecatedInputs = (record, input) => record.mode === "off" || input
|
|
|
310
331
|
* fields. Given for the response a call ends with, never for one that is
|
|
311
332
|
* discarded and retried or for a hop of a redirect chain.
|
|
312
333
|
*/
|
|
313
|
-
const noticeDeprecatedResponse = (
|
|
334
|
+
const noticeDeprecatedResponse = (seen, input) => Effect.suspend(() => warnings((warn) => inspectDeprecation({
|
|
314
335
|
response: {
|
|
315
336
|
headers: new globalThis.Headers(input.headers),
|
|
316
337
|
url: input.url
|
|
@@ -320,49 +341,10 @@ const noticeDeprecatedResponse = (record, input) => record.mode === "off" || inp
|
|
|
320
341
|
operation: input.operation ?? void 0,
|
|
321
342
|
baseURL: input.baseURL,
|
|
322
343
|
operations: GENERATED_OPERATIONS,
|
|
323
|
-
seen
|
|
344
|
+
seen,
|
|
324
345
|
warn
|
|
325
346
|
})));
|
|
326
347
|
|
|
327
|
-
//#endregion
|
|
328
|
-
//#region src/effect/pagination.ts
|
|
329
|
-
/**
|
|
330
|
-
* Cursor pagination as a `Stream`: the items of a standard `items` /
|
|
331
|
-
* `next_cursor` operation, one page requested at a time and only when the
|
|
332
|
-
* stream is pulled that far, so a consumer that stops — or is interrupted —
|
|
333
|
-
* causes no further request.
|
|
334
|
-
*
|
|
335
|
-
* The cursor rules are the ones `./pagination` traverses by, called rather
|
|
336
|
-
* than restated: an absent, null or empty `next_cursor` ends the stream, a
|
|
337
|
-
* cursor the server repeats fails it, and so does a page-number envelope that
|
|
338
|
-
* leaves `next_cursor` out before its last page.
|
|
339
|
-
*/
|
|
340
|
-
/**
|
|
341
|
-
* One page's items and the position after it, or the reason the traversal
|
|
342
|
-
* cannot go on. No request would change that reason, so it is a
|
|
343
|
-
* {@link ConfigurationError} carrying the message `./pagination` throws.
|
|
344
|
-
*/
|
|
345
|
-
const advance = (page, seen) => Result.try({
|
|
346
|
-
try: () => {
|
|
347
|
-
const items = page.items;
|
|
348
|
-
assertPageItems(items);
|
|
349
|
-
const cursor = standardNextCursor(page);
|
|
350
|
-
if (isFinalCursor(cursor)) return [items, Option.none()];
|
|
351
|
-
assertCursorAdvanced(seen, cursor);
|
|
352
|
-
seen.add(cursor);
|
|
353
|
-
return [items, Option.some(cursor)];
|
|
354
|
-
},
|
|
355
|
-
catch: configurationErrorFrom
|
|
356
|
-
});
|
|
357
|
-
/**
|
|
358
|
-
* The items of every page `fetchPage` returns, in order. `fetchPage` is first
|
|
359
|
-
* called with no cursor, then with each `next_cursor` in turn.
|
|
360
|
-
*/
|
|
361
|
-
const cursorStream = (fetchPage) => Stream.suspend(() => {
|
|
362
|
-
const seen = /* @__PURE__ */ new Set();
|
|
363
|
-
return Stream.paginate(void 0, (cursor) => Effect.flatMap(fetchPage(cursor), (page) => Effect.fromResult(advance(page, seen))));
|
|
364
|
-
});
|
|
365
|
-
|
|
366
348
|
//#endregion
|
|
367
349
|
//#region src/effect/request.ts
|
|
368
350
|
/**
|
|
@@ -444,41 +426,40 @@ const check = (kernel, call) => {
|
|
|
444
426
|
bodyHeaders
|
|
445
427
|
};
|
|
446
428
|
};
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
429
|
+
const withFirstHop = (checked, credential) => {
|
|
430
|
+
const { scope, url, body, bodyHeaders, ...rest } = checked;
|
|
431
|
+
const shared = {
|
|
432
|
+
...rest,
|
|
433
|
+
call: {
|
|
434
|
+
credential,
|
|
435
|
+
scope
|
|
436
|
+
}
|
|
437
|
+
};
|
|
438
|
+
const first = {
|
|
439
|
+
url,
|
|
440
|
+
method: checked.method.toUpperCase(),
|
|
441
|
+
body,
|
|
442
|
+
bodyHeaders,
|
|
443
|
+
withdrawn: false,
|
|
444
|
+
index: 0
|
|
445
|
+
};
|
|
446
|
+
return {
|
|
447
|
+
...shared,
|
|
448
|
+
first: {
|
|
449
|
+
...first,
|
|
450
|
+
headers: hopHeaders(shared, first)
|
|
451
|
+
}
|
|
452
|
+
};
|
|
453
|
+
};
|
|
454
|
+
/** Checks the call, resolves its credential once for every attempt and hop, and builds its first hop. */
|
|
455
|
+
const prepare = (kernel, call) => Effect.try({
|
|
454
456
|
try: () => check(kernel, call),
|
|
455
457
|
catch: configurationErrorFrom
|
|
456
|
-
})
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
call: {
|
|
462
|
-
credential,
|
|
463
|
-
scope
|
|
464
|
-
}
|
|
465
|
-
};
|
|
466
|
-
const first = {
|
|
467
|
-
url,
|
|
468
|
-
method: call.method.toUpperCase(),
|
|
469
|
-
body,
|
|
470
|
-
bodyHeaders,
|
|
471
|
-
withdrawn: false,
|
|
472
|
-
index: 0
|
|
473
|
-
};
|
|
474
|
-
return {
|
|
475
|
-
...shared,
|
|
476
|
-
first: {
|
|
477
|
-
...first,
|
|
478
|
-
headers: hopHeaders(shared, first)
|
|
479
|
-
}
|
|
480
|
-
};
|
|
481
|
-
},
|
|
458
|
+
}).pipe(Effect.flatMap((checked) => Effect.map(resolveCallCredential(kernel.auth, kernel.baseURL, checked.url, call.operation, call.operationHeaders), (credential) => ({
|
|
459
|
+
checked,
|
|
460
|
+
credential
|
|
461
|
+
}))), Effect.flatMap(({ checked, credential }) => Effect.try({
|
|
462
|
+
try: () => withFirstHop(checked, credential),
|
|
482
463
|
catch: configurationErrorFrom
|
|
483
464
|
})));
|
|
484
465
|
/**
|
|
@@ -765,7 +746,7 @@ const parse = (prepared, response, headers) => {
|
|
|
765
746
|
}), (body) => validated(prepared, response, body)));
|
|
766
747
|
};
|
|
767
748
|
const dispatch = (kernel, call) => prepare(kernel, call).pipe(Effect.flatMap((prepared) => {
|
|
768
|
-
const noticed = call.recovered || prepared.operation?.hasDeprecatedInputs === true ? noticeDeprecatedInputs(kernel.
|
|
749
|
+
const noticed = call.recovered || prepared.operation?.hasDeprecatedInputs === true ? noticeDeprecatedInputs(kernel.deprecationSeen, {
|
|
769
750
|
operation: prepared.operation,
|
|
770
751
|
query: prepared.query,
|
|
771
752
|
body: call.body,
|
|
@@ -774,8 +755,8 @@ const dispatch = (kernel, call) => prepare(kernel, call).pipe(Effect.flatMap((pr
|
|
|
774
755
|
const exchanged = withRetries(kernel, prepared, 0);
|
|
775
756
|
return Effect.flatMap(noticed === void 0 ? exchanged : Effect.andThen(noticed, exchanged), (response) => {
|
|
776
757
|
const headers = response.headers;
|
|
777
|
-
if (
|
|
778
|
-
return Effect.flatMap(noticeDeprecatedResponse(kernel.
|
|
758
|
+
if (headers["deprecation"] === void 0) return parse(prepared, response, headers);
|
|
759
|
+
return Effect.flatMap(noticeDeprecatedResponse(kernel.deprecationSeen, {
|
|
779
760
|
method: prepared.method,
|
|
780
761
|
path: prepared.path,
|
|
781
762
|
operation: prepared.operation,
|
|
@@ -1515,48 +1496,43 @@ const createClientResources = (kernel) => ({
|
|
|
1515
1496
|
//#region src/effect/client.ts
|
|
1516
1497
|
/**
|
|
1517
1498
|
* The Effect client: a `Context.Service`, layers that build it from the
|
|
1518
|
-
* `HttpClient` in context
|
|
1499
|
+
* `HttpClient` in context, and a plain
|
|
1519
1500
|
* constructor for callers who already hold one.
|
|
1520
1501
|
*
|
|
1521
1502
|
* Options are fixed at construction. Nothing here reads the environment except
|
|
1522
1503
|
* {@link layerConfig}, which reads the `COMPOSIO_*` settings through Effect's
|
|
1523
1504
|
* `Config` — so the `ConfigProvider` in context decides where they come from.
|
|
1524
1505
|
*/
|
|
1525
|
-
/**
|
|
1526
|
-
* The constructors of {@link Auth}, the same as the root entry's: `Auth.project(key)`,
|
|
1527
|
-
* `Auth.user(key)`, `Auth.organization(key)`, `Auth.auto({ ... })` and
|
|
1528
|
-
* `Auth.none()`. A key may be a string, a `Redacted<string>`, or a function
|
|
1529
|
-
* that returns either.
|
|
1530
|
-
*/
|
|
1531
1506
|
const Auth = authConstructors();
|
|
1532
1507
|
var ComposioClient = class extends Context.Service()("@composio/client/effect/ComposioClient") {};
|
|
1533
1508
|
const DEFAULT_BASE_URL = "https://backend.composio.dev";
|
|
1534
1509
|
const DEFAULT_MAX_RETRIES = 2;
|
|
1535
1510
|
const DEFAULT_TIMEOUT = 6e4;
|
|
1511
|
+
const resolveAccess = (options, baseURL) => {
|
|
1512
|
+
assertNoRemovedCredentialOptions(options);
|
|
1513
|
+
const auth = resolveAuth(options.auth, EFFECT_CREDENTIAL);
|
|
1514
|
+
const scope = resolveScope(options.scope);
|
|
1515
|
+
const identity = resolveIdentity(options.identity);
|
|
1516
|
+
const reserved = reservedHeaders(identity, {
|
|
1517
|
+
auth: auth.mode !== "none",
|
|
1518
|
+
scope: scope !== void 0
|
|
1519
|
+
});
|
|
1520
|
+
assertNoReservedHeaders(options.defaultHeaders, reserved, "defaultHeaders");
|
|
1521
|
+
const allowedHTTPOrigin = options.allowInsecureHTTP ? parseHTTPURL(baseURL)?.origin ?? null : null;
|
|
1522
|
+
assertCredentialTransport(baseURL, auth.mode !== "none", allowedHTTPOrigin);
|
|
1523
|
+
return {
|
|
1524
|
+
auth: holdAuth(auth),
|
|
1525
|
+
scope,
|
|
1526
|
+
identity,
|
|
1527
|
+
reserved,
|
|
1528
|
+
allowedHTTPOrigin
|
|
1529
|
+
};
|
|
1530
|
+
};
|
|
1536
1531
|
const resolveKernel = (options, httpClient) => {
|
|
1537
1532
|
const baseURL = options.baseURL || DEFAULT_BASE_URL;
|
|
1538
1533
|
if (options.decode === true && options.schemas === void 0) return Result.fail(new ConfigurationError({ message: SCHEMAS_MISSING }));
|
|
1539
1534
|
const resolved = Result.try({
|
|
1540
|
-
try: () =>
|
|
1541
|
-
assertNoRemovedCredentialOptions(options);
|
|
1542
|
-
const auth = resolveAuth(options.auth, isEffectCredential, checkEffectKey);
|
|
1543
|
-
const scope = resolveScope(options.scope);
|
|
1544
|
-
const identity = resolveIdentity(options.identity);
|
|
1545
|
-
const reserved = reservedHeaders(identity, {
|
|
1546
|
-
auth: auth.mode !== "none",
|
|
1547
|
-
scope: scope !== void 0
|
|
1548
|
-
});
|
|
1549
|
-
assertNoReservedHeaders(options.defaultHeaders, reserved, "defaultHeaders");
|
|
1550
|
-
const allowedHTTPOrigin = options.allowInsecureHTTP ? parseHTTPURL(baseURL)?.origin ?? null : null;
|
|
1551
|
-
assertCredentialTransport(baseURL, auth.mode !== "none", allowedHTTPOrigin);
|
|
1552
|
-
return {
|
|
1553
|
-
auth: holdAuth(auth),
|
|
1554
|
-
scope,
|
|
1555
|
-
identity,
|
|
1556
|
-
reserved,
|
|
1557
|
-
allowedHTTPOrigin
|
|
1558
|
-
};
|
|
1559
|
-
},
|
|
1535
|
+
try: () => resolveAccess(options, baseURL),
|
|
1560
1536
|
catch: configurationErrorFrom
|
|
1561
1537
|
});
|
|
1562
1538
|
if (Result.isFailure(resolved)) return Result.fail(resolved.failure);
|
|
@@ -1571,7 +1547,7 @@ const resolveKernel = (options, httpClient) => {
|
|
|
1571
1547
|
tracing: options.tracing ?? "off",
|
|
1572
1548
|
decode: options.decode ?? false,
|
|
1573
1549
|
schemas: options.schemas,
|
|
1574
|
-
|
|
1550
|
+
deprecationSeen: /* @__PURE__ */ new Set()
|
|
1575
1551
|
});
|
|
1576
1552
|
};
|
|
1577
1553
|
const fromKernel = (kernel) => ({
|
|
@@ -1607,19 +1583,14 @@ const make = (options, httpClient) => fromKernel(makeKernel(options, httpClient)
|
|
|
1607
1583
|
* Reads no environment variable.
|
|
1608
1584
|
*/
|
|
1609
1585
|
const layer = (options) => Layer.effect(ComposioClient, Effect.flatMap(HttpClient.HttpClient, (httpClient) => Effect.map(Effect.fromResult(resolveKernel(options, httpClient)), fromKernel)));
|
|
1610
|
-
/**
|
|
1611
|
-
* {@link layer} over a fetch-backed `HttpClient`, for an application that has
|
|
1612
|
-
* no transport of its own to supply. `fetch` is the platform's, or whatever
|
|
1613
|
-
* the `FetchHttpClient.Fetch` reference in context names.
|
|
1614
|
-
*/
|
|
1615
|
-
const layerFetch = (options) => Layer.provide(layer(options), FetchHttpClient.layer);
|
|
1616
1586
|
/** A setting as `Composio.fromEnv` reads one: trimmed, and absent when empty. */
|
|
1617
1587
|
const setting = (name) => Config.map(Config.option(Config.String(name)), (value) => Option.getOrUndefined(Option.filter(Option.map(value, (text) => text.trim()), (text) => text !== "")));
|
|
1618
|
-
|
|
1619
|
-
const secret = (name) => Config.map(Config.option(Config.Redacted(name)), (value) => Option.getOrUndefined(Option.flatMap(value, (key) => {
|
|
1588
|
+
const trimmedKey = (key) => {
|
|
1620
1589
|
const trimmed = Redacted.value(key).trim();
|
|
1621
|
-
|
|
1622
|
-
|
|
1590
|
+
if (trimmed === "") return Option.none();
|
|
1591
|
+
return Option.some(Redacted.make(trimmed));
|
|
1592
|
+
};
|
|
1593
|
+
const secret = (name) => Config.map(Config.option(Config.Redacted(name)), (value) => Option.getOrUndefined(Option.flatMap(value, trimmedKey)));
|
|
1623
1594
|
const settings = Config.all({
|
|
1624
1595
|
project: secret("COMPOSIO_API_KEY"),
|
|
1625
1596
|
user: secret("COMPOSIO_USER_API_KEY"),
|
|
@@ -1628,16 +1599,9 @@ const settings = Config.all({
|
|
|
1628
1599
|
allowInsecureHTTP: setting("COMPOSIO_ALLOW_INSECURE_HTTP")
|
|
1629
1600
|
});
|
|
1630
1601
|
/**
|
|
1631
|
-
* Provides the client from the `COMPOSIO_*` settings
|
|
1632
|
-
* `ConfigProvider` in context,
|
|
1633
|
-
*
|
|
1634
|
-
* `COMPOSIO_ORG_API_KEY` become `auth` by the rule `Composio.fromEnv` applies
|
|
1635
|
-
* (one set: that fixed mode; several: `Auth.auto`; none: `Auth.none()`), each
|
|
1636
|
-
* key `Redacted` throughout; `COMPOSIO_BASE_URL` and
|
|
1637
|
-
* `COMPOSIO_ALLOW_INSECURE_HTTP=1` are read too. `COMPOSIO_ORG_ID` and
|
|
1638
|
-
* `COMPOSIO_PROJECT_ID` are not: `scope` is an argument. An option given here
|
|
1639
|
-
* replaces the whole setting it names, so `{ auth: Auth.none() }` means none
|
|
1640
|
-
* whatever is configured.
|
|
1602
|
+
* Provides the client from the `COMPOSIO_*` settings through the
|
|
1603
|
+
* `ConfigProvider` in context, by `Composio.fromEnv`'s rules. Each override
|
|
1604
|
+
* replaces the setting it names.
|
|
1641
1605
|
*/
|
|
1642
1606
|
const layerConfig = (overrides = {}) => Layer.effect(ComposioClient, Effect.gen(function* () {
|
|
1643
1607
|
const httpClient = yield* HttpClient.HttpClient;
|
|
@@ -1648,8 +1612,8 @@ const layerConfig = (overrides = {}) => Layer.effect(ComposioClient, Effect.gen(
|
|
|
1648
1612
|
user: env.user,
|
|
1649
1613
|
organization: env.organization
|
|
1650
1614
|
}),
|
|
1651
|
-
|
|
1652
|
-
|
|
1615
|
+
baseURL: env.baseURL,
|
|
1616
|
+
allowInsecureHTTP: env.allowInsecureHTTP === "1"
|
|
1653
1617
|
};
|
|
1654
1618
|
const kernel = yield* Effect.fromResult(resolveKernel({
|
|
1655
1619
|
...mapped,
|
|
@@ -1659,4 +1623,4 @@ const layerConfig = (overrides = {}) => Layer.effect(ComposioClient, Effect.gen(
|
|
|
1659
1623
|
}));
|
|
1660
1624
|
|
|
1661
1625
|
//#endregion
|
|
1662
|
-
export { APIConnectionError, APIConnectionTimeoutError, APIError, Auth, AuthenticationError, BadRequestError, ComposioClient, ConfigurationError, ConflictError, DecodeError, InternalServerError, NotFoundError, PermissionDeniedError, RateLimitError, UnprocessableEntityError, VERSION, isAPIError, isComposioError, layer, layerConfig,
|
|
1626
|
+
export { APIConnectionError, APIConnectionTimeoutError, APIError, Auth, AuthenticationError, BadRequestError, ComposioClient, ConfigurationError, ConflictError, DecodeError, InternalServerError, NotFoundError, PermissionDeniedError, RateLimitError, UnprocessableEntityError, VERSION, isAPIError, isComposioError, isDeprecationNotice, layer, layerConfig, make };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { d as path, n as generatedOperation, y as withOperation } from "./generated-operations-
|
|
1
|
+
import { d as path, n as generatedOperation, y as withOperation } from "./generated-operations-Dv7pAKDT.mjs";
|
|
2
2
|
|
|
3
3
|
//#region src/compat/resources/tool-router/session/files.ts
|
|
4
4
|
const OP_LIST = generatedOperation("toolRouter.session.files.list");
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { n as generatedOperation, y as withOperation } from "./generated-operations-
|
|
1
|
+
import { n as generatedOperation, y as withOperation } from "./generated-operations-Dv7pAKDT.mjs";
|
|
2
2
|
|
|
3
3
|
//#region src/compat/resources/files.ts
|
|
4
4
|
const OP_LIST = generatedOperation("files.list");
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { n as generatedOperation, y as withOperation } from "./generated-operations-
|
|
1
|
+
import { n as generatedOperation, y as withOperation } from "./generated-operations-Dv7pAKDT.mjs";
|
|
2
2
|
|
|
3
3
|
//#region src/compat/resources/mcp/generate.ts
|
|
4
4
|
const OP_URL = generatedOperation("mcp.generate.url");
|
package/dist/{generated-deprecated-inputs-zx6ml908.mjs → generated-deprecated-inputs-Dy_lBver.mjs}
RENAMED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { r as APIError } from "./error-Bw7_G2NZ.mjs";
|
|
2
|
-
import { g as safeJSON, l as castToError } from "./generated-operations-
|
|
2
|
+
import { g as safeJSON, l as castToError } from "./generated-operations-Dv7pAKDT.mjs";
|
|
3
3
|
|
|
4
4
|
//#region src/compat/api-promise.ts
|
|
5
5
|
/**
|