@composio/client 2.0.0-rc.17 → 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 +136 -40
- package/dist/{api-key-revocation-lc3308Ao.mjs → api-key-revocation-DMCgun-A.mjs} +1 -1
- package/dist/{auth-DkGiEaxg.mjs → auth-D-U9Aq8C.mjs} +1 -1
- package/dist/{auth-configs-DbxqGahP.mjs → auth-configs-DAG5mMeH.mjs} +1 -1
- package/dist/{clanker-fK9cAkTz.mjs → clanker-Yomp86hJ.mjs} +1 -1
- package/dist/{cli-K1MskpaR.mjs → cli-zihiw3aI.mjs} +4 -5
- package/dist/{connected-accounts-Bfl7_SY_.mjs → connected-accounts-Bd4AbWoH.mjs} +1 -1
- package/dist/{consumer-5o2zMQwr.mjs → consumer-Bk0cyIii.mjs} +6 -7
- package/dist/{custom-8rs-sHnb.mjs → custom-Ce8G2c11.mjs} +1 -1
- package/dist/{custom-wEkSiPHn.mjs → custom-DWT3cCog.mjs} +1 -1
- package/dist/effect.d.mts +29 -42
- package/dist/effect.mjs +217 -192
- package/dist/{error-D9cG225M.mjs → error-Bw7_G2NZ.mjs} +1 -1
- package/dist/{files-BPKJXlpc.mjs → files-DRp_J4zH.mjs} +1 -1
- package/dist/{files-BjPFzRnM.mjs → files-ZxEVlE_y.mjs} +1 -1
- package/dist/{generate-DDHNgbPS.mjs → generate-Du9XUrlx.mjs} +1 -1
- package/dist/{generated-deprecated-inputs--L5LHDO_.mjs → generated-deprecated-inputs-Dy_lBver.mjs} +2 -2
- package/dist/{generated-operations-D1e__yar.mjs → generated-operations-Dv7pAKDT.mjs} +354 -226
- package/dist/index.d.mts +3 -3
- package/dist/index.mjs +104 -154
- package/dist/{keyring-Dkm6DQIp.mjs → keyring-CgOIS5x7.mjs} +1 -1
- package/dist/{link-BBU-J5L_.mjs → link-CW1ts4pm.mjs} +1 -1
- package/dist/{logs-CuuysWk1.mjs → logs-DFdH5DoT.mjs} +3 -3
- package/dist/{manage-B1R7I3ZM.mjs → manage-CeB03gO8.mjs} +1 -1
- package/dist/{mcp-C3beSy48.mjs → mcp-DNRMWWum.mjs} +3 -3
- package/dist/{org-B13XOuKh.mjs → org-HuYaKgVf.mjs} +6 -6
- package/dist/{owner-BAr5uwk3.mjs → owner-I9fXmIO_.mjs} +1 -1
- package/dist/{pagination-rules-uMUdPq_7.mjs → pagination-rules-CMnBwktJ.mjs} +1 -1
- package/dist/pagination.mjs +1 -1
- package/dist/{project-CDm8tjUw.mjs → project-CxQ2H8UB.mjs} +1 -1
- package/dist/{project-DF5KclHm.mjs → project-DcV01umC.mjs} +4 -7
- package/dist/{project-BbCgXD83.mjs → project-Dwblmpw8.mjs} +1 -1
- package/dist/{project-C30H_5b6.mjs → project-FuP5k9R1.mjs} +1 -1
- package/dist/{realtime-6LigMh83.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-Dm8WtF4I.mjs → session-B-ifOjVv.mjs} +1 -1
- package/dist/{session-DEfDnHZZ.mjs → session-CpwJh7Hn.mjs} +2 -2
- package/dist/{session-configs-nA6TL_i4.d.mts → session-configs-BLy_O6bX.d.mts} +131 -134
- package/dist/{tool-router-6l_dREjC.mjs → tool-router-jNsaldKV.mjs} +1 -1
- package/dist/{toolkits-Mn_uLV98.mjs → toolkits-DK4My9FW.mjs} +1 -1
- package/dist/{tools-z-PjBsf7.mjs → tools-DNkimllW.mjs} +1 -1
- package/dist/{tools-btk0mzFP.mjs → tools-Gun_2We6.mjs} +1 -1
- package/dist/{trigger-instances-PQaObQQy.mjs → trigger-instances-vvKswQSW.mjs} +2 -2
- package/dist/{triggers-y0mi0XzT.mjs → triggers-CfrGxKIo.mjs} +1 -1
- package/dist/{triggers-types-KoRbT0k5.mjs → triggers-types-DYW2Mr8z.mjs} +1 -1
- package/dist/{usage-DvjkSmpI.mjs → usage-YIBYNpVF.mjs} +1 -1
- package/dist/{usage-B2Z947BK.mjs → usage-vt9HmnNf.mjs} +1 -1
- package/dist/version-DB98yI2B.d.mts +4 -0
- package/dist/{webhook-endpoints-kf4Jj2Mz.mjs → webhook-endpoints-HqLteVW6.mjs} +1 -1
- package/dist/{webhook-subscriptions-DcYN8qo1.mjs → webhook-subscriptions-CXhNXIOM.mjs} +1 -1
- package/package.json +2 -2
- package/dist/version-DUxhnnPj.d.mts +0 -4
package/dist/effect.mjs
CHANGED
|
@@ -1,79 +1,17 @@
|
|
|
1
|
-
import { h as makeAPIErrorMessage, m as errorDetails, s as ComposioError } from "./error-
|
|
2
|
-
import {
|
|
3
|
-
import { r as classifySuccessBody, t as GENERATED_DEPRECATED_INPUTS } from "./generated-deprecated-inputs
|
|
4
|
-
import { i as standardNextCursor, n as assertPageItems, r as isFinalCursor, t as assertCursorAdvanced } from "./pagination-rules-
|
|
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";
|
|
1
|
+
import { h as makeAPIErrorMessage, m as errorDetails, s as ComposioError } from "./error-Bw7_G2NZ.mjs";
|
|
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
|
+
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, 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";
|
|
13
13
|
import * as UrlParams from "effect/http/UrlParams";
|
|
14
14
|
|
|
15
|
-
//#region src/effect/credentials.ts
|
|
16
|
-
/**
|
|
17
|
-
* How the Effect kernel holds credentials, and how it keeps them out of what
|
|
18
|
-
* the transport records.
|
|
19
|
-
*
|
|
20
|
-
* Which credential a request carries, and where it may go, is decided by the
|
|
21
|
-
* compat kernel's own functions (`../compat/credentials.ts`); nothing here
|
|
22
|
-
* restates a rule. What is specific to this surface is the wrapping — a
|
|
23
|
-
* credential is a `Redacted` for as long as the client holds it — and Effect's
|
|
24
|
-
* redaction list, which knows `x-api-key` and not the other two schemes.
|
|
25
|
-
*/
|
|
26
|
-
const reveal = (credential) => credential === null ? null : Redacted.value(credential);
|
|
27
|
-
/** The credentials in the plain form the compat functions take. Never stored. */
|
|
28
|
-
const revealCredentials = (held) => ({
|
|
29
|
-
apiKey: reveal(held.apiKey),
|
|
30
|
-
userApiKey: reveal(held.userApiKey),
|
|
31
|
-
orgApiKey: reveal(held.orgApiKey)
|
|
32
|
-
});
|
|
33
|
-
const OPTION_HEADERS = {
|
|
34
|
-
apiKey: SCHEME_HEADERS.ApiKeyAuth,
|
|
35
|
-
userApiKey: SCHEME_HEADERS.UserApiKeyAuth,
|
|
36
|
-
orgApiKey: SCHEME_HEADERS.OrgApiKeyAuth
|
|
37
|
-
};
|
|
38
|
-
const CREDENTIAL_OPTIONS = Object.keys(OPTION_HEADERS);
|
|
39
|
-
/** Whether the platform's `Headers` takes `value` under `name`. Its refusal quotes the value, so it stays here. */
|
|
40
|
-
const isSendable = (name, value) => {
|
|
41
|
-
try {
|
|
42
|
-
new globalThis.Headers().set(name, value);
|
|
43
|
-
return true;
|
|
44
|
-
} catch {
|
|
45
|
-
return false;
|
|
46
|
-
}
|
|
47
|
-
};
|
|
48
|
-
/**
|
|
49
|
-
* The option naming a credential no header can carry (an interior CR, LF or
|
|
50
|
-
* NUL, or a character outside Latin-1), or `undefined` when all of them can be
|
|
51
|
-
* sent. The answer is the option's name and never the value.
|
|
52
|
-
*/
|
|
53
|
-
const unsendableCredential = (held) => CREDENTIAL_OPTIONS.find((option) => {
|
|
54
|
-
const credential = held[option];
|
|
55
|
-
return credential !== null && !isSendable(OPTION_HEADERS[option], Redacted.value(credential));
|
|
56
|
-
});
|
|
57
|
-
const CREDENTIAL_HEADER_NAMES = Object.values(SCHEME_HEADERS);
|
|
58
|
-
/** The extended list for each list seen, so a request does not rebuild it. */
|
|
59
|
-
const extended = /* @__PURE__ */ new WeakMap();
|
|
60
|
-
/**
|
|
61
|
-
* Effect's redaction list with every credential header name on it, so a span
|
|
62
|
-
* attribute or a rendering of the request made while the transport handles it
|
|
63
|
-
* shows `<redacted>` for all three.
|
|
64
|
-
*
|
|
65
|
-
* The list in context is extended, not replaced: an application that added
|
|
66
|
-
* names of its own keeps them.
|
|
67
|
-
*/
|
|
68
|
-
const withCredentialHeaderNames = (names) => {
|
|
69
|
-
const known = extended.get(names);
|
|
70
|
-
if (known !== void 0) return known;
|
|
71
|
-
const all = [...names, ...CREDENTIAL_HEADER_NAMES.filter((name) => !Headers.isRedactedName(name, names))];
|
|
72
|
-
extended.set(names, all);
|
|
73
|
-
return all;
|
|
74
|
-
};
|
|
75
|
-
|
|
76
|
-
//#endregion
|
|
77
15
|
//#region src/effect/errors.ts
|
|
78
16
|
/**
|
|
79
17
|
* The failure model of the Effect surface: flat tagged errors, one per status
|
|
@@ -178,6 +116,67 @@ const isAPIError = (value) => kindOf(value) === "status";
|
|
|
178
116
|
/** Whether a value is any error this surface produces. Structural, like {@link isAPIError}. */
|
|
179
117
|
const isComposioError = (value) => kindOf(value) !== void 0;
|
|
180
118
|
|
|
119
|
+
//#endregion
|
|
120
|
+
//#region src/effect/credentials.ts
|
|
121
|
+
/**
|
|
122
|
+
* How the Effect kernel holds credentials, and how it keeps them out of what
|
|
123
|
+
* the transport records.
|
|
124
|
+
*
|
|
125
|
+
* Which credential a request carries, and where it may go, is decided by the
|
|
126
|
+
* compat kernel's own functions (`../compat/credentials.ts`); nothing here
|
|
127
|
+
* restates a rule. What is specific to this surface is the wrapping — a
|
|
128
|
+
* credential is a `Redacted` for as long as the client holds it — and Effect's
|
|
129
|
+
* redaction list, which knows `x-api-key` and not the other two schemes.
|
|
130
|
+
*/
|
|
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;
|
|
139
|
+
};
|
|
140
|
+
const holdAuth = (auth) => ({
|
|
141
|
+
mode: auth.mode,
|
|
142
|
+
credentials: Object.fromEntries(Object.entries(auth.credentials).map(([scheme, credential]) => [scheme, hold(credential)]))
|
|
143
|
+
});
|
|
144
|
+
const providerFailed = () => new ConfigurationError({ message: "The `auth` credential provider failed." });
|
|
145
|
+
const keyOf = (credential) => {
|
|
146
|
+
if (typeof credential !== "function") return Effect.succeed(reveal(credential));
|
|
147
|
+
return Effect.tryPromise({
|
|
148
|
+
try: async () => reveal(await credential()),
|
|
149
|
+
catch: providerFailed
|
|
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
|
+
};
|
|
161
|
+
const CREDENTIAL_HEADER_NAMES = Object.values(SCHEME_HEADERS);
|
|
162
|
+
/** The extended list for each list seen, so a request does not rebuild it. */
|
|
163
|
+
const extended = /* @__PURE__ */ new WeakMap();
|
|
164
|
+
/**
|
|
165
|
+
* Effect's redaction list with every credential header name on it, so a span
|
|
166
|
+
* attribute or a rendering of the request made while the transport handles it
|
|
167
|
+
* shows `<redacted>` for all three.
|
|
168
|
+
*
|
|
169
|
+
* The list in context is extended, not replaced: an application that added
|
|
170
|
+
* names of its own keeps them.
|
|
171
|
+
*/
|
|
172
|
+
const withCredentialHeaderNames = (names) => {
|
|
173
|
+
const known = extended.get(names);
|
|
174
|
+
if (known !== void 0) return known;
|
|
175
|
+
const all = [...names, ...CREDENTIAL_HEADER_NAMES.filter((name) => !Headers.isRedactedName(name, names))];
|
|
176
|
+
extended.set(names, all);
|
|
177
|
+
return all;
|
|
178
|
+
};
|
|
179
|
+
|
|
181
180
|
//#endregion
|
|
182
181
|
//#region src/effect/decode.ts
|
|
183
182
|
/**
|
|
@@ -251,6 +250,45 @@ const responseIssues = (loaders, key, body) => {
|
|
|
251
250
|
}), (schema) => issuesOf(schema, body));
|
|
252
251
|
};
|
|
253
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
|
+
|
|
254
292
|
//#endregion
|
|
255
293
|
//#region src/effect/deprecation.ts
|
|
256
294
|
/**
|
|
@@ -262,27 +300,30 @@ const responseIssues = (loaders, key, body) => {
|
|
|
262
300
|
* notice is a `Warn` record on Effect's logger, so the application's logger
|
|
263
301
|
* and minimum log level decide what becomes of it.
|
|
264
302
|
*/
|
|
265
|
-
const
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
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));
|
|
269
309
|
/** The compat inspectors report through a callback; this collects what one of them said. */
|
|
270
310
|
const warnings = (inspect) => {
|
|
271
311
|
const messages = [];
|
|
272
312
|
inspect((message) => messages.push(message));
|
|
273
|
-
return messages.length === 0 ? Effect.void : Effect.forEach(messages,
|
|
313
|
+
return messages.length === 0 ? Effect.void : Effect.forEach(messages, logNotice, { discard: true });
|
|
274
314
|
};
|
|
275
315
|
/**
|
|
276
316
|
* The notice for inputs the spec marks deprecated, decided from the request
|
|
277
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.
|
|
278
319
|
*/
|
|
279
|
-
const noticeDeprecatedInputs = (
|
|
320
|
+
const noticeDeprecatedInputs = (seen, input) => input.operation === null ? Effect.void : Effect.suspend(() => warnings((warn) => inspectDeprecatedInputs({
|
|
280
321
|
operation: input.operation,
|
|
281
322
|
query: input.query,
|
|
282
323
|
body: input.body,
|
|
283
324
|
headers: input.headers(),
|
|
284
325
|
table: GENERATED_DEPRECATED_INPUTS,
|
|
285
|
-
seen
|
|
326
|
+
seen,
|
|
286
327
|
warn
|
|
287
328
|
})));
|
|
288
329
|
/**
|
|
@@ -290,7 +331,7 @@ const noticeDeprecatedInputs = (record, input) => record.mode === "off" || input
|
|
|
290
331
|
* fields. Given for the response a call ends with, never for one that is
|
|
291
332
|
* discarded and retried or for a hop of a redirect chain.
|
|
292
333
|
*/
|
|
293
|
-
const noticeDeprecatedResponse = (
|
|
334
|
+
const noticeDeprecatedResponse = (seen, input) => Effect.suspend(() => warnings((warn) => inspectDeprecation({
|
|
294
335
|
response: {
|
|
295
336
|
headers: new globalThis.Headers(input.headers),
|
|
296
337
|
url: input.url
|
|
@@ -300,49 +341,10 @@ const noticeDeprecatedResponse = (record, input) => record.mode === "off" || inp
|
|
|
300
341
|
operation: input.operation ?? void 0,
|
|
301
342
|
baseURL: input.baseURL,
|
|
302
343
|
operations: GENERATED_OPERATIONS,
|
|
303
|
-
seen
|
|
344
|
+
seen,
|
|
304
345
|
warn
|
|
305
346
|
})));
|
|
306
347
|
|
|
307
|
-
//#endregion
|
|
308
|
-
//#region src/effect/pagination.ts
|
|
309
|
-
/**
|
|
310
|
-
* Cursor pagination as a `Stream`: the items of a standard `items` /
|
|
311
|
-
* `next_cursor` operation, one page requested at a time and only when the
|
|
312
|
-
* stream is pulled that far, so a consumer that stops — or is interrupted —
|
|
313
|
-
* causes no further request.
|
|
314
|
-
*
|
|
315
|
-
* The cursor rules are the ones `./pagination` traverses by, called rather
|
|
316
|
-
* than restated: an absent, null or empty `next_cursor` ends the stream, a
|
|
317
|
-
* cursor the server repeats fails it, and so does a page-number envelope that
|
|
318
|
-
* leaves `next_cursor` out before its last page.
|
|
319
|
-
*/
|
|
320
|
-
/**
|
|
321
|
-
* One page's items and the position after it, or the reason the traversal
|
|
322
|
-
* cannot go on. No request would change that reason, so it is a
|
|
323
|
-
* {@link ConfigurationError} carrying the message `./pagination` throws.
|
|
324
|
-
*/
|
|
325
|
-
const advance = (page, seen) => Result.try({
|
|
326
|
-
try: () => {
|
|
327
|
-
const items = page.items;
|
|
328
|
-
assertPageItems(items);
|
|
329
|
-
const cursor = standardNextCursor(page);
|
|
330
|
-
if (isFinalCursor(cursor)) return [items, Option.none()];
|
|
331
|
-
assertCursorAdvanced(seen, cursor);
|
|
332
|
-
seen.add(cursor);
|
|
333
|
-
return [items, Option.some(cursor)];
|
|
334
|
-
},
|
|
335
|
-
catch: configurationErrorFrom
|
|
336
|
-
});
|
|
337
|
-
/**
|
|
338
|
-
* The items of every page `fetchPage` returns, in order. `fetchPage` is first
|
|
339
|
-
* called with no cursor, then with each `next_cursor` in turn.
|
|
340
|
-
*/
|
|
341
|
-
const cursorStream = (fetchPage) => Stream.suspend(() => {
|
|
342
|
-
const seen = /* @__PURE__ */ new Set();
|
|
343
|
-
return Stream.paginate(void 0, (cursor) => Effect.flatMap(fetchPage(cursor), (page) => Effect.fromResult(advance(page, seen))));
|
|
344
|
-
});
|
|
345
|
-
|
|
346
348
|
//#endregion
|
|
347
349
|
//#region src/effect/request.ts
|
|
348
350
|
/**
|
|
@@ -380,10 +382,11 @@ const substitute = (template, params) => {
|
|
|
380
382
|
const statics = template.split(PLACEHOLDER);
|
|
381
383
|
return path(Object.assign(statics, { raw: statics }), ...params);
|
|
382
384
|
};
|
|
383
|
-
const hopHeaders = (prepared, hop) => buildRequestHeaders(prepared.headerConfig, { headers: prepared.callHeaders }, hop.url, hop.bodyHeaders, hop.withdrawn, prepared.
|
|
384
|
-
const
|
|
385
|
+
const hopHeaders = (prepared, hop) => buildRequestHeaders(prepared.headerConfig, { headers: prepared.callHeaders }, hop.url, hop.bodyHeaders, hop.withdrawn, prepared.call);
|
|
386
|
+
const check = (kernel, call) => {
|
|
385
387
|
const callHeaders = call.headers();
|
|
386
|
-
assertNoReservedHeaders(callHeaders, kernel.
|
|
388
|
+
assertNoReservedHeaders(callHeaders, kernel.reserved, "headers");
|
|
389
|
+
if (!call.recovered) assertRequiredOperationHeaders(call.operation, call.operationHeaders);
|
|
387
390
|
const path = call.path();
|
|
388
391
|
if (call.options?.timeout !== void 0) validatePositiveInteger("timeout", call.options.timeout);
|
|
389
392
|
const resolvedRetries = call.options?.maxRetries ?? kernel.maxRetries;
|
|
@@ -400,8 +403,7 @@ const prepare = (kernel, call) => {
|
|
|
400
403
|
query: call.query
|
|
401
404
|
});
|
|
402
405
|
const { body, bodyHeaders } = buildBody({ body: call.body });
|
|
403
|
-
|
|
404
|
-
const shared = {
|
|
406
|
+
return {
|
|
405
407
|
method: call.method,
|
|
406
408
|
path,
|
|
407
409
|
label: printableURL(url, call.operation),
|
|
@@ -409,22 +411,33 @@ const prepare = (kernel, call) => {
|
|
|
409
411
|
query,
|
|
410
412
|
headerConfig: {
|
|
411
413
|
baseURL: kernel.baseURL,
|
|
412
|
-
credentials,
|
|
413
414
|
allowedHTTPOrigin: kernel.allowedHTTPOrigin,
|
|
414
415
|
userAgent: kernel.userAgent,
|
|
415
416
|
defaultHeaders: kernel.defaultHeaders,
|
|
416
417
|
identity: kernel.identity
|
|
417
418
|
},
|
|
418
419
|
callHeaders,
|
|
419
|
-
|
|
420
|
-
callerPlaced: callerPlacedCredential([kernel.defaultHeaders, callHeaders]),
|
|
420
|
+
scope: scopeForCall(kernel.scope, call.operationHeaders),
|
|
421
421
|
maxRetries,
|
|
422
422
|
timeout: call.options?.timeout ?? kernel.timeout,
|
|
423
|
-
schemas: decode ? kernel.schemas : void 0
|
|
423
|
+
schemas: decode ? kernel.schemas : void 0,
|
|
424
|
+
url,
|
|
425
|
+
body,
|
|
426
|
+
bodyHeaders
|
|
427
|
+
};
|
|
428
|
+
};
|
|
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
|
+
}
|
|
424
437
|
};
|
|
425
438
|
const first = {
|
|
426
439
|
url,
|
|
427
|
-
method:
|
|
440
|
+
method: checked.method.toUpperCase(),
|
|
428
441
|
body,
|
|
429
442
|
bodyHeaders,
|
|
430
443
|
withdrawn: false,
|
|
@@ -438,6 +451,17 @@ const prepare = (kernel, call) => {
|
|
|
438
451
|
}
|
|
439
452
|
};
|
|
440
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({
|
|
456
|
+
try: () => check(kernel, call),
|
|
457
|
+
catch: configurationErrorFrom
|
|
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),
|
|
463
|
+
catch: configurationErrorFrom
|
|
464
|
+
})));
|
|
441
465
|
/**
|
|
442
466
|
* Built from its parts rather than through `HttpClientRequest.make`: the URL
|
|
443
467
|
* already carries its query, serialized by the compat rules, and must reach
|
|
@@ -721,11 +745,8 @@ const parse = (prepared, response, headers) => {
|
|
|
721
745
|
catch: () => invalidJSON(prepared, response)
|
|
722
746
|
}), (body) => validated(prepared, response, body)));
|
|
723
747
|
};
|
|
724
|
-
const dispatch = (kernel, call) => Effect.
|
|
725
|
-
|
|
726
|
-
catch: configurationErrorFrom
|
|
727
|
-
}).pipe(Effect.flatMap((prepared) => {
|
|
728
|
-
const noticed = call.recovered || prepared.operation?.hasDeprecatedInputs === true ? noticeDeprecatedInputs(kernel.notices, {
|
|
748
|
+
const dispatch = (kernel, call) => prepare(kernel, call).pipe(Effect.flatMap((prepared) => {
|
|
749
|
+
const noticed = call.recovered || prepared.operation?.hasDeprecatedInputs === true ? noticeDeprecatedInputs(kernel.deprecationSeen, {
|
|
729
750
|
operation: prepared.operation,
|
|
730
751
|
query: prepared.query,
|
|
731
752
|
body: call.body,
|
|
@@ -734,8 +755,8 @@ const dispatch = (kernel, call) => Effect.try({
|
|
|
734
755
|
const exchanged = withRetries(kernel, prepared, 0);
|
|
735
756
|
return Effect.flatMap(noticed === void 0 ? exchanged : Effect.andThen(noticed, exchanged), (response) => {
|
|
736
757
|
const headers = response.headers;
|
|
737
|
-
if (
|
|
738
|
-
return Effect.flatMap(noticeDeprecatedResponse(kernel.
|
|
758
|
+
if (headers["deprecation"] === void 0) return parse(prepared, response, headers);
|
|
759
|
+
return Effect.flatMap(noticeDeprecatedResponse(kernel.deprecationSeen, {
|
|
739
760
|
method: prepared.method,
|
|
740
761
|
path: prepared.path,
|
|
741
762
|
operation: prepared.operation,
|
|
@@ -756,6 +777,7 @@ const executeOperation = (kernel, operation, args, options) => dispatch(kernel,
|
|
|
756
777
|
query: args.query,
|
|
757
778
|
body: args.body,
|
|
758
779
|
headers: () => args.headers === void 0 ? options?.headers : mergeHeaders([args.headers, options?.headers]),
|
|
780
|
+
operationHeaders: args.operationHeaders,
|
|
759
781
|
operation,
|
|
760
782
|
recovered: false,
|
|
761
783
|
options
|
|
@@ -772,6 +794,7 @@ const executeRaw = (kernel, method, path, options) => dispatch(kernel, {
|
|
|
772
794
|
query: options?.query,
|
|
773
795
|
body: options?.body,
|
|
774
796
|
headers: () => options?.headers,
|
|
797
|
+
operationHeaders: void 0,
|
|
775
798
|
operation: matchOperation(method, path, GENERATED_OPERATIONS),
|
|
776
799
|
recovered: true,
|
|
777
800
|
options
|
|
@@ -1206,7 +1229,7 @@ const makeCli = (kernel) => ({
|
|
|
1206
1229
|
const { "x-user-api-key": xUserApiKey, ...body } = params;
|
|
1207
1230
|
return executeOperation(kernel, OP_CREATE_CODACT_FAILURE, {
|
|
1208
1231
|
body,
|
|
1209
|
-
|
|
1232
|
+
operationHeaders: { "x-user-api-key": xUserApiKey }
|
|
1210
1233
|
}, options);
|
|
1211
1234
|
},
|
|
1212
1235
|
createSession: (body = {}, options) => executeOperation(kernel, OP_CREATE_SESSION, { body }, options),
|
|
@@ -1337,9 +1360,9 @@ const makeOwner = (kernel) => ({ project: makeProject$2(kernel) });
|
|
|
1337
1360
|
const OP_RESOLVE = generatedOperation("org.consumer.project.resolve");
|
|
1338
1361
|
const makeProject$1 = (kernel) => ({ resolve: (params, options) => {
|
|
1339
1362
|
const { "x-user-api-key": xUserApiKey, "x-org-id": xOrgId } = params;
|
|
1340
|
-
return executeOperation(kernel, OP_RESOLVE, {
|
|
1341
|
-
|
|
1342
|
-
|
|
1363
|
+
return executeOperation(kernel, OP_RESOLVE, { operationHeaders: {
|
|
1364
|
+
"x-user-api-key": xUserApiKey,
|
|
1365
|
+
"x-org-id": xOrgId
|
|
1343
1366
|
} }, options);
|
|
1344
1367
|
} });
|
|
1345
1368
|
|
|
@@ -1352,9 +1375,9 @@ const makeConsumer = (kernel) => ({
|
|
|
1352
1375
|
const { "x-user-api-key": xUserApiKey, "x-org-id": xOrgId, ...query } = params;
|
|
1353
1376
|
return executeOperation(kernel, OP_LIST_CONNECTED_TOOLKITS, {
|
|
1354
1377
|
query,
|
|
1355
|
-
|
|
1356
|
-
|
|
1357
|
-
|
|
1378
|
+
operationHeaders: {
|
|
1379
|
+
"x-user-api-key": xUserApiKey,
|
|
1380
|
+
"x-org-id": xOrgId
|
|
1358
1381
|
}
|
|
1359
1382
|
}, options);
|
|
1360
1383
|
}
|
|
@@ -1473,58 +1496,58 @@ const createClientResources = (kernel) => ({
|
|
|
1473
1496
|
//#region src/effect/client.ts
|
|
1474
1497
|
/**
|
|
1475
1498
|
* The Effect client: a `Context.Service`, layers that build it from the
|
|
1476
|
-
* `HttpClient` in context
|
|
1499
|
+
* `HttpClient` in context, and a plain
|
|
1477
1500
|
* constructor for callers who already hold one.
|
|
1478
1501
|
*
|
|
1479
1502
|
* Options are fixed at construction. Nothing here reads the environment except
|
|
1480
1503
|
* {@link layerConfig}, which reads the `COMPOSIO_*` settings through Effect's
|
|
1481
1504
|
* `Config` — so the `ConfigProvider` in context decides where they come from.
|
|
1482
1505
|
*/
|
|
1506
|
+
const Auth = authConstructors();
|
|
1483
1507
|
var ComposioClient = class extends Context.Service()("@composio/client/effect/ComposioClient") {};
|
|
1484
1508
|
const DEFAULT_BASE_URL = "https://backend.composio.dev";
|
|
1485
1509
|
const DEFAULT_MAX_RETRIES = 2;
|
|
1486
1510
|
const DEFAULT_TIMEOUT = 6e4;
|
|
1487
|
-
const
|
|
1488
|
-
|
|
1489
|
-
|
|
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
|
+
};
|
|
1490
1530
|
};
|
|
1491
1531
|
const resolveKernel = (options, httpClient) => {
|
|
1492
1532
|
const baseURL = options.baseURL || DEFAULT_BASE_URL;
|
|
1493
1533
|
if (options.decode === true && options.schemas === void 0) return Result.fail(new ConfigurationError({ message: SCHEMAS_MISSING }));
|
|
1494
|
-
const
|
|
1495
|
-
try: () =>
|
|
1496
|
-
const resolved = resolveIdentity(options.identity);
|
|
1497
|
-
assertNoReservedHeaders(options.defaultHeaders, resolved, "defaultHeaders");
|
|
1498
|
-
return resolved;
|
|
1499
|
-
},
|
|
1534
|
+
const resolved = Result.try({
|
|
1535
|
+
try: () => resolveAccess(options, baseURL),
|
|
1500
1536
|
catch: configurationErrorFrom
|
|
1501
1537
|
});
|
|
1502
|
-
if (Result.isFailure(
|
|
1503
|
-
|
|
1538
|
+
if (Result.isFailure(resolved)) return Result.fail(resolved.failure);
|
|
1539
|
+
return Result.succeed({
|
|
1504
1540
|
httpClient,
|
|
1505
1541
|
baseURL,
|
|
1506
|
-
|
|
1507
|
-
userApiKey: hold(options.userApiKey),
|
|
1508
|
-
orgApiKey: hold(options.orgApiKey),
|
|
1509
|
-
allowedHTTPOrigin: options.allowInsecureHTTP ? parseHTTPURL(baseURL)?.origin ?? null : null,
|
|
1542
|
+
...resolved.success,
|
|
1510
1543
|
userAgent: `Composio/JS ${VERSION}`,
|
|
1511
1544
|
defaultHeaders: options.defaultHeaders,
|
|
1512
|
-
identity: identity.success,
|
|
1513
1545
|
maxRetries: options.maxRetries ?? DEFAULT_MAX_RETRIES,
|
|
1514
1546
|
timeout: options.timeout ?? DEFAULT_TIMEOUT,
|
|
1515
1547
|
tracing: options.tracing ?? "off",
|
|
1516
1548
|
decode: options.decode ?? false,
|
|
1517
1549
|
schemas: options.schemas,
|
|
1518
|
-
|
|
1519
|
-
};
|
|
1520
|
-
const unsendable = unsendableCredential(kernel);
|
|
1521
|
-
if (unsendable !== void 0) return Result.fail(new ConfigurationError({ message: `The \`${unsendable}\` option cannot be sent as a header: it contains a line break, a NUL or a character outside Latin-1.` }));
|
|
1522
|
-
return Result.try({
|
|
1523
|
-
try: () => {
|
|
1524
|
-
assertCredentialTransport(baseURL, revealCredentials(kernel), kernel.allowedHTTPOrigin);
|
|
1525
|
-
return kernel;
|
|
1526
|
-
},
|
|
1527
|
-
catch: configurationErrorFrom
|
|
1550
|
+
deprecationSeen: /* @__PURE__ */ new Set()
|
|
1528
1551
|
});
|
|
1529
1552
|
};
|
|
1530
1553
|
const fromKernel = (kernel) => ({
|
|
@@ -1559,43 +1582,45 @@ const make = (options, httpClient) => fromKernel(makeKernel(options, httpClient)
|
|
|
1559
1582
|
* Provides the client from explicit options and the `HttpClient` in context.
|
|
1560
1583
|
* Reads no environment variable.
|
|
1561
1584
|
*/
|
|
1562
|
-
const layer = (options
|
|
1563
|
-
/**
|
|
1564
|
-
* {@link layer} over a fetch-backed `HttpClient`, for an application that has
|
|
1565
|
-
* no transport of its own to supply. `fetch` is the platform's, or whatever
|
|
1566
|
-
* the `FetchHttpClient.Fetch` reference in context names.
|
|
1567
|
-
*/
|
|
1568
|
-
const layerFetch = (options = {}) => Layer.provide(layer(options), FetchHttpClient.layer);
|
|
1569
|
-
/** A setting as the compat client reads one: trimmed, and absent when empty. */
|
|
1585
|
+
const layer = (options) => Layer.effect(ComposioClient, Effect.flatMap(HttpClient.HttpClient, (httpClient) => Effect.map(Effect.fromResult(resolveKernel(options, httpClient)), fromKernel)));
|
|
1586
|
+
/** A setting as `Composio.fromEnv` reads one: trimmed, and absent when empty. */
|
|
1570
1587
|
const setting = (name) => Config.map(Config.option(Config.String(name)), (value) => Option.getOrUndefined(Option.filter(Option.map(value, (text) => text.trim()), (text) => text !== "")));
|
|
1588
|
+
const trimmedKey = (key) => {
|
|
1589
|
+
const trimmed = Redacted.value(key).trim();
|
|
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)));
|
|
1571
1594
|
const settings = Config.all({
|
|
1572
|
-
|
|
1573
|
-
|
|
1574
|
-
|
|
1595
|
+
project: secret("COMPOSIO_API_KEY"),
|
|
1596
|
+
user: secret("COMPOSIO_USER_API_KEY"),
|
|
1597
|
+
organization: secret("COMPOSIO_ORG_API_KEY"),
|
|
1575
1598
|
baseURL: setting("COMPOSIO_BASE_URL"),
|
|
1576
1599
|
allowInsecureHTTP: setting("COMPOSIO_ALLOW_INSECURE_HTTP")
|
|
1577
1600
|
});
|
|
1578
1601
|
/**
|
|
1579
|
-
* Provides the client from the `COMPOSIO_*` settings
|
|
1580
|
-
* `
|
|
1581
|
-
*
|
|
1582
|
-
* context, which is the process environment unless the application says
|
|
1583
|
-
* otherwise. An option given here wins over its setting; `null` for a
|
|
1584
|
-
* credential means "none", 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.
|
|
1585
1605
|
*/
|
|
1586
|
-
const layerConfig = (
|
|
1606
|
+
const layerConfig = (overrides = {}) => Layer.effect(ComposioClient, Effect.gen(function* () {
|
|
1587
1607
|
const httpClient = yield* HttpClient.HttpClient;
|
|
1588
1608
|
const env = yield* Effect.mapError(settings, () => new ConfigurationError({ message: "The COMPOSIO_* configuration could not be read." }));
|
|
1609
|
+
const mapped = {
|
|
1610
|
+
auth: authFromCredentials({
|
|
1611
|
+
project: env.project,
|
|
1612
|
+
user: env.user,
|
|
1613
|
+
organization: env.organization
|
|
1614
|
+
}),
|
|
1615
|
+
baseURL: env.baseURL,
|
|
1616
|
+
allowInsecureHTTP: env.allowInsecureHTTP === "1"
|
|
1617
|
+
};
|
|
1589
1618
|
const kernel = yield* Effect.fromResult(resolveKernel({
|
|
1590
|
-
...
|
|
1591
|
-
|
|
1592
|
-
userApiKey: options.userApiKey !== void 0 ? options.userApiKey : env.userApiKey,
|
|
1593
|
-
orgApiKey: options.orgApiKey !== void 0 ? options.orgApiKey : env.orgApiKey,
|
|
1594
|
-
baseURL: options.baseURL ?? env.baseURL,
|
|
1595
|
-
allowInsecureHTTP: options.allowInsecureHTTP ?? env.allowInsecureHTTP === "1"
|
|
1619
|
+
...mapped,
|
|
1620
|
+
...overrides
|
|
1596
1621
|
}, httpClient));
|
|
1597
1622
|
return fromKernel(kernel);
|
|
1598
1623
|
}));
|
|
1599
1624
|
|
|
1600
1625
|
//#endregion
|
|
1601
|
-
export { APIConnectionError, APIConnectionTimeoutError, APIError, 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 };
|
|
@@ -51,7 +51,7 @@ var APIError = class APIError extends ComposioError {
|
|
|
51
51
|
* `errors[]` and `suggested_fix` are reachable without casting `error`.
|
|
52
52
|
*
|
|
53
53
|
* Not part of the Stainless surface: a sanctioned superset, like
|
|
54
|
-
* `ClientOptions.
|
|
54
|
+
* `ClientOptions.identity`.
|
|
55
55
|
*/
|
|
56
56
|
details;
|
|
57
57
|
/**
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
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 {
|
|
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 {
|
|
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--L5LHDO_.mjs → generated-deprecated-inputs-Dy_lBver.mjs}
RENAMED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { r as APIError } from "./error-
|
|
2
|
-
import { g as safeJSON, l as castToError } from "./generated-operations-
|
|
1
|
+
import { r as APIError } from "./error-Bw7_G2NZ.mjs";
|
|
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
|
/**
|