@every-app/sdk 0.3.0-rc.8 → 0.3.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 +75 -74
- package/dist/cloudflare/catalogSettings.generated.d.ts +20 -6
- package/dist/cloudflare/catalogSettings.generated.d.ts.map +1 -1
- package/dist/cloudflare/catalogSettings.generated.js +45 -14
- package/dist/cloudflare/index.d.ts +1 -1
- package/dist/cloudflare/index.d.ts.map +1 -1
- package/dist/cloudflare/sentinel.d.ts +3 -0
- package/dist/cloudflare/sentinel.d.ts.map +1 -1
- package/dist/cloudflare/sentinel.js +10 -0
- package/dist/cloudflare/worker.d.ts +67 -23
- package/dist/cloudflare/worker.d.ts.map +1 -1
- package/dist/cloudflare/worker.js +68 -32
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/internal/aiDefault.d.ts +36 -79
- package/dist/internal/aiDefault.d.ts.map +1 -1
- package/dist/internal/aiDefault.js +47 -149
- package/dist/internal/aiProviders.d.ts +1 -1
- package/dist/internal/aiProviders.d.ts.map +1 -1
- package/dist/internal/aiProviders.js +2 -2
- package/dist/internal/appSettings.d.ts +140 -89
- package/dist/internal/appSettings.d.ts.map +1 -1
- package/dist/internal/appSettings.js +264 -156
- package/dist/internal/capabilities.d.ts +145 -503
- package/dist/internal/capabilities.d.ts.map +1 -1
- package/dist/internal/capabilities.js +29 -550
- package/dist/internal/catalog/commerce.js +1 -1
- package/dist/internal/catalog/comms.d.ts +37 -0
- package/dist/internal/catalog/comms.d.ts.map +1 -1
- package/dist/internal/catalog/comms.js +43 -0
- package/dist/internal/catalog/index.d.ts +72 -0
- package/dist/internal/catalog/index.d.ts.map +1 -1
- package/dist/internal/catalog/infra.d.ts +35 -0
- package/dist/internal/catalog/infra.d.ts.map +1 -1
- package/dist/internal/catalog/infra.js +65 -0
- package/dist/internal/devProviders.d.ts +1 -19
- package/dist/internal/devProviders.d.ts.map +1 -1
- package/dist/internal/devProviders.js +7 -1
- package/dist/internal/events.d.ts +52 -1
- package/dist/internal/events.d.ts.map +1 -1
- package/dist/internal/events.js +66 -2
- package/dist/internal/gatewaySettings.d.ts +6 -16
- package/dist/internal/gatewaySettings.d.ts.map +1 -1
- package/dist/internal/gatewaySettings.js +6 -24
- package/dist/internal/index.d.ts +1 -0
- package/dist/internal/index.d.ts.map +1 -1
- package/dist/internal/index.js +1 -0
- package/dist/internal/mcpOAuth.d.ts +210 -0
- package/dist/internal/mcpOAuth.d.ts.map +1 -0
- package/dist/internal/mcpOAuth.js +735 -0
- package/dist/internal/oauthClient.d.ts +7 -47
- package/dist/internal/oauthClient.d.ts.map +1 -1
- package/dist/internal/oauthClient.js +1 -115
- package/dist/internal/oauthPresets.d.ts +356 -20
- package/dist/internal/oauthPresets.d.ts.map +1 -1
- package/dist/internal/oauthPresets.js +183 -861
- package/dist/internal/oauthScopes.d.ts +43 -155
- package/dist/internal/oauthScopes.d.ts.map +1 -1
- package/dist/internal/oauthScopes.js +82 -475
- package/dist/internal/oauthSpec.d.ts +28 -71
- package/dist/internal/oauthSpec.d.ts.map +1 -1
- package/dist/internal/oauthSpec.js +172 -448
- package/dist/internal/protocol.d.ts +39 -15
- package/dist/internal/protocol.d.ts.map +1 -1
- package/dist/internal/protocol.js +40 -7
- package/dist/internal/providerApps.d.ts +2 -2
- package/dist/internal/providerApps.js +2 -2
- package/dist/internal/providerRegistry.d.ts +5 -64
- package/dist/internal/providerRegistry.d.ts.map +1 -1
- package/dist/internal/providerRegistry.js +19 -118
- package/dist/internal/providerSpec.d.ts.map +1 -1
- package/dist/internal/providerSpec.js +14 -36
- package/dist/internal/remoteMcp.d.ts +191 -47
- package/dist/internal/remoteMcp.d.ts.map +1 -1
- package/dist/internal/remoteMcp.js +338 -133
- package/dist/internal/signInProviders.d.ts +1 -1
- package/dist/internal/signInProviders.d.ts.map +1 -1
- package/dist/internal/tools.d.ts +15 -8
- package/dist/internal/tools.d.ts.map +1 -1
- package/dist/internal/tools.js +9 -8
- package/dist/manifest.d.ts +96 -28
- package/dist/manifest.d.ts.map +1 -1
- package/dist/manifest.js +1 -1
- package/dist/server/ai.d.ts +1 -93
- package/dist/server/ai.d.ts.map +1 -1
- package/dist/server/ai.js +17 -111
- package/dist/server/attribution.d.ts +10 -1
- package/dist/server/attribution.d.ts.map +1 -1
- package/dist/server/attribution.js +7 -1
- package/dist/server/connectUrl.d.ts +4 -9
- package/dist/server/connectUrl.d.ts.map +1 -1
- package/dist/server/connectUrl.js +17 -14
- package/dist/server/context.d.ts +12 -14
- package/dist/server/context.d.ts.map +1 -1
- package/dist/server/context.js +23 -25
- package/dist/server/emit.d.ts.map +1 -1
- package/dist/server/emit.js +2 -2
- package/dist/server/env.d.ts +3 -0
- package/dist/server/env.d.ts.map +1 -1
- package/dist/server/eventsEndpoint.d.ts +48 -0
- package/dist/server/eventsEndpoint.d.ts.map +1 -0
- package/dist/server/eventsEndpoint.js +145 -0
- package/dist/server/everyApp.d.ts +16 -26
- package/dist/server/everyApp.d.ts.map +1 -1
- package/dist/server/everyApp.js +22 -46
- package/dist/server/gatewayFetch.d.ts +19 -1
- package/dist/server/gatewayFetch.d.ts.map +1 -1
- package/dist/server/gatewayFetch.js +45 -3
- package/dist/server/index.d.ts +6 -9
- package/dist/server/index.d.ts.map +1 -1
- package/dist/server/index.js +4 -8
- package/dist/server/integrationFetch.d.ts +60 -72
- package/dist/server/integrationFetch.d.ts.map +1 -1
- package/dist/server/integrationFetch.js +124 -397
- package/dist/server/listMembers.d.ts.map +1 -1
- package/dist/server/listMembers.js +2 -2
- package/dist/server/refusal.d.ts +0 -9
- package/dist/server/refusal.d.ts.map +1 -1
- package/dist/server/refusal.js +0 -22
- package/dist/server/sendEmail.d.ts.map +1 -1
- package/dist/server/sendEmail.js +2 -2
- package/dist/server/tools.d.ts +17 -6
- package/dist/server/tools.d.ts.map +1 -1
- package/dist/server/tools.js +14 -4
- package/dist/server/toolsEndpoint.d.ts +2 -1
- package/dist/server/toolsEndpoint.d.ts.map +1 -1
- package/dist/server/toolsEndpoint.js +4 -3
- package/dist/server/webhooks.d.ts +56 -0
- package/dist/server/webhooks.d.ts.map +1 -0
- package/dist/server/webhooks.js +205 -0
- package/dist/testing/index.d.ts +2 -3
- package/dist/testing/index.d.ts.map +1 -1
- package/dist/testing/index.js +2 -6
- package/package.json +6 -1
- package/dist/server/aiBinding.d.ts +0 -68
- package/dist/server/aiBinding.d.ts.map +0 -1
- package/dist/server/aiBinding.js +0 -294
- package/dist/server/authorizeUrl.d.ts +0 -43
- package/dist/server/authorizeUrl.d.ts.map +0 -1
- package/dist/server/authorizeUrl.js +0 -106
- package/dist/server/emailBinding.d.ts +0 -72
- package/dist/server/emailBinding.d.ts.map +0 -1
- package/dist/server/emailBinding.js +0 -124
- package/dist/server/fromMcpTools.d.ts +0 -89
- package/dist/server/fromMcpTools.d.ts.map +0 -1
- package/dist/server/fromMcpTools.js +0 -192
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"everyApp.d.ts","sourceRoot":"","sources":["../../src/server/everyApp.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,OAAO,EAGL,kBAAkB,
|
|
1
|
+
{"version":3,"file":"everyApp.d.ts","sourceRoot":"","sources":["../../src/server/everyApp.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,OAAO,EAGL,kBAAkB,EAQlB,OAAO,EACP,KAAK,YAAY,EACjB,KAAK,cAAc,EACnB,KAAK,OAAO,EAEb,MAAM,sBAAsB,CAAC;AAE9B,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAE1C,OAAO,EAEL,KAAK,gBAAgB,EACtB,MAAM,qBAAqB,CAAC;AAE7B,OAAO,EAAE,kBAAkB,EAAE,OAAO,EAAE,CAAC;AACvC,YAAY,EAAE,YAAY,EAAE,cAAc,EAAE,OAAO,EAAE,CAAC;AAEtD;;;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AG,EAAE,MAAM,GACV,OAAO,CAAC,YAAY,CAAC,CAevB;AA0BD,wBAAgB,QAAQ,CAAC,IAAI,EAAE,YAAY,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAEnE;AAED,wEAAwE;AACxE,wBAAgB,QAAQ,CACtB,IAAI,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC9B,IAAI,SAAS,oBAAoB,GAAG,gBAAgB,EAEpD,OAAO,EAAE,eAAe,CAAC,IAAI,EAAE,IAAI,CAAC,EACpC,OAAO,GAAE,eAAe,CAAC,IAAI,CAAM,GAClC,cAAc,CAAC,IAAI,EAAE,IAAI,CAAC,CA2D5B"}
|
package/dist/server/everyApp.js
CHANGED
|
@@ -13,12 +13,12 @@
|
|
|
13
13
|
* `everyapp.config.ts` (the Cloudflare Vite plugin hides every file
|
|
14
14
|
* `cloudflare.config.ts` imports from the Worker in dev).
|
|
15
15
|
* It also answers the gateway's internal tools contract
|
|
16
|
-
* (`/__everyapp/tools/*`) for the app's `defineTools()` catalog
|
|
16
|
+
* (`/__everyapp/tools/*`) for the app's `defineTools()` catalog, and the
|
|
17
|
+
* event sink's deliveries (`/__everyapp/events`) for `events: { on }`.
|
|
17
18
|
*
|
|
18
19
|
* Around the handler and around each tool call it opens the request
|
|
19
|
-
* context (context.ts):
|
|
20
|
-
*
|
|
21
|
-
* `for`. A deployed Worker is pinned to its organization
|
|
20
|
+
* context (context.ts): every call back to the Gateway is attributed to
|
|
21
|
+
* the request without a `for`. A deployed Worker is pinned to its organization
|
|
22
22
|
* (`EVERY_APP_ORG_ID`), and an identity for any other is refused on both
|
|
23
23
|
* paths. The response leaves without `Set-Cookie`: the perimeter strips
|
|
24
24
|
* every `Cookie` before a request reaches the app, so a cookie the app's
|
|
@@ -28,7 +28,8 @@
|
|
|
28
28
|
import { APP_ID_ENV, AUDIENCE_ENV, ConfigurationError, DEV_ENV, IdentityError, IDENTITY_HEADER, ISSUER_ENV, ORG_ID_ENV, PUBLIC_KEYS_ENV, getIdentityFromRequest, isAdmin, } from "../internal/index.js";
|
|
29
29
|
import { currentUser, serveRequest } from "./context.js";
|
|
30
30
|
import { handleToolsRequest } from "./toolsEndpoint.js";
|
|
31
|
-
|
|
31
|
+
import { handleEventsRequest, } from "./eventsEndpoint.js";
|
|
32
|
+
export { ConfigurationError, isAdmin };
|
|
32
33
|
const requestIdentities = new WeakMap();
|
|
33
34
|
function envValue(env, key) {
|
|
34
35
|
if (!env || typeof env !== "object")
|
|
@@ -36,9 +37,8 @@ function envValue(env, key) {
|
|
|
36
37
|
const value = env[key];
|
|
37
38
|
return typeof value === "string" && value.length > 0 ? value : undefined;
|
|
38
39
|
}
|
|
39
|
-
function configFrom(
|
|
40
|
+
function configFrom(options) {
|
|
40
41
|
return {
|
|
41
|
-
manifestAppId: manifest?.id,
|
|
42
42
|
issuer: options.issuer,
|
|
43
43
|
keysEnvVar: options.keysEnvVar ?? PUBLIC_KEYS_ENV,
|
|
44
44
|
publicKeys: options.publicKeys,
|
|
@@ -46,16 +46,9 @@ function configFrom(manifest, options = {}) {
|
|
|
46
46
|
now: options.now,
|
|
47
47
|
};
|
|
48
48
|
}
|
|
49
|
-
/**
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
*/
|
|
53
|
-
function appIdFor(env, config) {
|
|
54
|
-
const fromEnv = envValue(env, APP_ID_ENV);
|
|
55
|
-
if (fromEnv && config.manifestAppId && fromEnv !== config.manifestAppId) {
|
|
56
|
-
throw new ConfigurationError(`${APP_ID_ENV} ("${fromEnv}") does not match the manifest id ("${config.manifestAppId}").`);
|
|
57
|
-
}
|
|
58
|
-
return fromEnv ?? config.manifestAppId;
|
|
49
|
+
/** The app id, from EVERYAPP_APP_ID (which `everyAppWorker()` sets). */
|
|
50
|
+
function appIdFor(env) {
|
|
51
|
+
return envValue(env, APP_ID_ENV);
|
|
59
52
|
}
|
|
60
53
|
function devIdentitiesAllowed(env, config) {
|
|
61
54
|
const devEnv = envValue(env, DEV_ENV);
|
|
@@ -71,7 +64,7 @@ function devIdentitiesAllowed(env, config) {
|
|
|
71
64
|
* app id stand in when EVERYAPP_AUDIENCE is unset.
|
|
72
65
|
*/
|
|
73
66
|
function audienceFor(env, config) {
|
|
74
|
-
const appId = appIdFor(env
|
|
67
|
+
const appId = appIdFor(env);
|
|
75
68
|
const audience = envValue(env, AUDIENCE_ENV);
|
|
76
69
|
if (audience)
|
|
77
70
|
return audience;
|
|
@@ -153,7 +146,6 @@ const servedRequests = new WeakMap();
|
|
|
153
146
|
* (a framework that hands out headers alone needs no made-up Request).
|
|
154
147
|
* Answers from the request context or the per-request cache first, then
|
|
155
148
|
* verifies the identity headers from the audience and public keys in env.
|
|
156
|
-
* Inside a handler `everyApp()` serves, `currentUser()` is the shorter way.
|
|
157
149
|
*/
|
|
158
150
|
export async function getEveryAppUser(request, env) {
|
|
159
151
|
const cached = requestIdentities.get(request);
|
|
@@ -187,19 +179,6 @@ export async function requireEveryAppUser(request, env) {
|
|
|
187
179
|
throw error;
|
|
188
180
|
}
|
|
189
181
|
}
|
|
190
|
-
/**
|
|
191
|
-
* The user of the request being served (`currentUser()`), or throw the
|
|
192
|
-
* same 401 JSON Response as `requireEveryAppUser()` on a public route.
|
|
193
|
-
* Outside a request (`withOrganization()` work, a handler not under
|
|
194
|
-
* `everyApp()`) it throws `RequestContextError`, as `currentUser()` does.
|
|
195
|
-
*/
|
|
196
|
-
export function requireCurrentUser() {
|
|
197
|
-
const user = currentUser();
|
|
198
|
-
if (!user) {
|
|
199
|
-
throw unauthorized("this request does not have an authenticated user");
|
|
200
|
-
}
|
|
201
|
-
return user;
|
|
202
|
-
}
|
|
203
182
|
/**
|
|
204
183
|
* `response` without `Set-Cookie`: the perimeter strips every `Cookie`
|
|
205
184
|
* before a request reaches the app, so no cookie the app sets ever comes
|
|
@@ -224,26 +203,16 @@ function withoutCookies(response) {
|
|
|
224
203
|
export function hasScope(user, scope) {
|
|
225
204
|
return user.scopes.includes("*") || user.scopes.includes(scope);
|
|
226
205
|
}
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
typeof value.id === "string");
|
|
231
|
-
}
|
|
232
|
-
export function everyApp(handler, manifestOrOptions, legacyOptions = {}) {
|
|
233
|
-
const manifest = isManifest(manifestOrOptions)
|
|
234
|
-
? manifestOrOptions
|
|
235
|
-
: undefined;
|
|
236
|
-
const options = manifest || manifestOrOptions === undefined
|
|
237
|
-
? legacyOptions
|
|
238
|
-
: manifestOrOptions;
|
|
239
|
-
const config = configFrom(manifest, options);
|
|
206
|
+
/** Wrap a Worker fetch handler with Every App identity verification. */
|
|
207
|
+
export function everyApp(handler, options = {}) {
|
|
208
|
+
const config = configFrom(options);
|
|
240
209
|
return {
|
|
241
210
|
async fetch(request, env, ctx) {
|
|
242
211
|
let audience;
|
|
243
212
|
let appId;
|
|
244
213
|
try {
|
|
245
214
|
audience = audienceFor(env, config);
|
|
246
|
-
appId = appIdFor(env
|
|
215
|
+
appId = appIdFor(env) ?? audience;
|
|
247
216
|
}
|
|
248
217
|
catch (err) {
|
|
249
218
|
if (err instanceof ConfigurationError) {
|
|
@@ -261,6 +230,13 @@ export function everyApp(handler, manifestOrOptions, legacyOptions = {}) {
|
|
|
261
230
|
});
|
|
262
231
|
if (toolsResponse)
|
|
263
232
|
return toolsResponse;
|
|
233
|
+
// So does the event sink's delivery path (`/__everyapp/events`).
|
|
234
|
+
const eventsResponse = await handleEventsRequest(request, env, ctx, {
|
|
235
|
+
events: options.events,
|
|
236
|
+
identity: identityOptions(env, config, audience),
|
|
237
|
+
});
|
|
238
|
+
if (eventsResponse)
|
|
239
|
+
return eventsResponse;
|
|
264
240
|
let identity;
|
|
265
241
|
try {
|
|
266
242
|
identity = await getIdentityFromRequest(request, identityOptions(env, config, audience));
|
|
@@ -3,6 +3,24 @@ export declare const BINDING_ORIGIN = "http://every-app-gateway.internal";
|
|
|
3
3
|
export interface GatewayServiceBinding {
|
|
4
4
|
fetch(input: RequestInfo | URL, init?: RequestInit): Promise<Response>;
|
|
5
5
|
}
|
|
6
|
+
/**
|
|
7
|
+
* The Gateway the SDK's services call: the `EVERY_APP_GATEWAY` service
|
|
8
|
+
* binding when deployed; under `everyapp dev --gateway` (linked dev,
|
|
9
|
+
* docs/design/linked-dev.md) a `{ fetch }` that sends the same requests to
|
|
10
|
+
* the gateway-lite's loopback forwarder, which adds the person's token and
|
|
11
|
+
* forwards them to the real Gateway's `/linked-dev/<app>` route. Undefined
|
|
12
|
+
* with neither (stub and mirror modes: the `.dev.vars` fallbacks). A value
|
|
13
|
+
* under the binding's name that isn't one is answered as before by each
|
|
14
|
+
* caller (`ConfigurationError`).
|
|
15
|
+
*/
|
|
16
|
+
export declare function gatewayBinding(env: object): GatewayServiceBinding | undefined;
|
|
17
|
+
/**
|
|
18
|
+
* The linked dev shim: a request to the binding's origin goes to the
|
|
19
|
+
* forwarder's URL with the same path and query, the run's nonce on it. The
|
|
20
|
+
* forwarder answers as the Gateway did, refusals included; nothing here
|
|
21
|
+
* falls back to a local key.
|
|
22
|
+
*/
|
|
23
|
+
export declare function linkedDevBinding(forwarderUrl: string, nonce: string): GatewayServiceBinding;
|
|
6
24
|
export interface CreateGatewayFetchOptions {
|
|
7
25
|
/**
|
|
8
26
|
* The Worker env, as it is: the EVERY_APP_GATEWAY binding when deployed,
|
|
@@ -13,7 +31,7 @@ export interface CreateGatewayFetchOptions {
|
|
|
13
31
|
/**
|
|
14
32
|
* Whom the call is for. Left out, the request `everyApp()` is serving
|
|
15
33
|
* (its user, while the identity is good) or the organization
|
|
16
|
-
*
|
|
34
|
+
* an event delivery runs under; outside both, `RequestContextError`.
|
|
17
35
|
* Explicitly: the inbound request, or `{ background: true,
|
|
18
36
|
* organizationId }` for work no person started (crons, Workflows,
|
|
19
37
|
* queues). A shared app's Worker must end up with one or the other
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"gatewayFetch.d.ts","sourceRoot":"","sources":["../../src/server/gatewayFetch.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"gatewayFetch.d.ts","sourceRoot":"","sources":["../../src/server/gatewayFetch.ts"],"names":[],"mappings":"AAiBA,OAAO,EAGL,KAAK,cAAc,EACpB,MAAM,kBAAkB,CAAC;AAE1B,eAAO,MAAM,cAAc,sCAAsC,CAAC;AAGlE,MAAM,WAAW,qBAAqB;IACpC,KAAK,CAAC,KAAK,EAAE,WAAW,GAAG,GAAG,EAAE,IAAI,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAC;CACxE;AAED;;;;;;;;;GASG;AACH,wBAAgB,cAAc,CAAC,GAAG,EAAE,MAAM,GAAG,qBAAqB,GAAG,SAAS,CAW7E;AAED;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAC9B,YAAY,EAAE,MAAM,EACpB,KAAK,EAAE,MAAM,GACZ,qBAAqB,CAiBvB;AAeD,MAAM,WAAW,yBAAyB;IACxC;;;;OAIG;IACH,GAAG,EAAE,MAAM,CAAC;IACZ;;;;;;;;OAQG;IACH,GAAG,CAAC,EAAE,cAAc,CAAC;IACrB;;;;;OAKG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAED;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAChC,OAAO,EAAE,yBAAyB,GAAG;IAAE,QAAQ,EAAE,IAAI,CAAA;CAAE,GACtD,OAAO,KAAK,GAAG,IAAI,CAAC;AACvB,wBAAgB,kBAAkB,CAChC,OAAO,EAAE,yBAAyB,GACjC,OAAO,KAAK,CAAC;AA2HhB,sFAAsF;AACtF,wBAAgB,gBAAgB,CAC9B,GAAG,EAAE,MAAM,EACX,MAAM,EAAE,OAAO,EACf,OAAO,EAAE,OAAO,GACf,OAAO,CAUT"}
|
|
@@ -1,13 +1,55 @@
|
|
|
1
|
-
import { AI_DEFAULT_MODEL, AI_DEFAULT_PROVIDER, AI_DEFAULT_ROUTES, aiProviderSettings, authorizationOf, ConfigurationError, DEV_AI_PROVIDERS, devAiProvider, joinProviderUrl, resolveAiDefault, } from "../internal/index.js";
|
|
1
|
+
import { AI_DEFAULT_MODEL, AI_DEFAULT_PROVIDER, AI_DEFAULT_ROUTES, aiProviderSettings, authorizationOf, ConfigurationError, DEV_AI_PROVIDERS, DEV_ENV, devAiProvider, joinProviderUrl, LINKED_DEV_HEADER, LINKED_DEV_NONCE_ENV, LINKED_DEV_URL_ENV, resolveAiDefault, } from "../internal/index.js";
|
|
2
2
|
import { applyAttribution, attributionFor, } from "./attribution.js";
|
|
3
3
|
export const BINDING_ORIGIN = "http://every-app-gateway.internal";
|
|
4
4
|
const AI_PROXY_PREFIX = "/api/ai/";
|
|
5
|
+
/**
|
|
6
|
+
* The Gateway the SDK's services call: the `EVERY_APP_GATEWAY` service
|
|
7
|
+
* binding when deployed; under `everyapp dev --gateway` (linked dev,
|
|
8
|
+
* docs/design/linked-dev.md) a `{ fetch }` that sends the same requests to
|
|
9
|
+
* the gateway-lite's loopback forwarder, which adds the person's token and
|
|
10
|
+
* forwards them to the real Gateway's `/linked-dev/<app>` route. Undefined
|
|
11
|
+
* with neither (stub and mirror modes: the `.dev.vars` fallbacks). A value
|
|
12
|
+
* under the binding's name that isn't one is answered as before by each
|
|
13
|
+
* caller (`ConfigurationError`).
|
|
14
|
+
*/
|
|
15
|
+
export function gatewayBinding(env) {
|
|
16
|
+
const values = env;
|
|
17
|
+
const binding = values["EVERY_APP_GATEWAY"];
|
|
18
|
+
if (binding)
|
|
19
|
+
return binding;
|
|
20
|
+
if (!values[DEV_ENV])
|
|
21
|
+
return undefined;
|
|
22
|
+
const url = values[LINKED_DEV_URL_ENV];
|
|
23
|
+
const nonce = values[LINKED_DEV_NONCE_ENV];
|
|
24
|
+
if (typeof url !== "string" || !url.trim() || typeof nonce !== "string") {
|
|
25
|
+
return undefined;
|
|
26
|
+
}
|
|
27
|
+
return linkedDevBinding(url.trim(), nonce);
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* The linked dev shim: a request to the binding's origin goes to the
|
|
31
|
+
* forwarder's URL with the same path and query, the run's nonce on it. The
|
|
32
|
+
* forwarder answers as the Gateway did, refusals included; nothing here
|
|
33
|
+
* falls back to a local key.
|
|
34
|
+
*/
|
|
35
|
+
export function linkedDevBinding(forwarderUrl, nonce) {
|
|
36
|
+
const base = forwarderUrl.replace(/\/+$/, "");
|
|
37
|
+
return {
|
|
38
|
+
fetch(input, init) {
|
|
39
|
+
const outbound = new Request(input, init);
|
|
40
|
+
const url = new URL(outbound.url);
|
|
41
|
+
const headers = new Headers(outbound.headers);
|
|
42
|
+
headers.set(LINKED_DEV_HEADER, nonce);
|
|
43
|
+
return fetch(streamingRequest(`${base}${url.pathname}${url.search}`, outbound, headers));
|
|
44
|
+
},
|
|
45
|
+
};
|
|
46
|
+
}
|
|
5
47
|
export function createGatewayFetch({ env: workerEnv, for: explicitTarget, optional = false, }) {
|
|
6
48
|
const env = workerEnv;
|
|
7
49
|
// Checked now, so a call nobody's fails where the fetch is made; and
|
|
8
50
|
// again per call, where an identity may since have neared its expiry.
|
|
9
51
|
attributionFor(env, explicitTarget, "createGatewayFetch");
|
|
10
|
-
const binding = env
|
|
52
|
+
const binding = gatewayBinding(env);
|
|
11
53
|
const devProviders = env.EVERYAPP_DEV ? localProviders(env) : {};
|
|
12
54
|
if (binding && typeof binding.fetch !== "function") {
|
|
13
55
|
throw new ConfigurationError("EVERY_APP_GATEWAY is configured but is not a valid service binding.");
|
|
@@ -137,7 +179,7 @@ function directProviderPath(input, env) {
|
|
|
137
179
|
// names a model sends it as it is).
|
|
138
180
|
const values = env;
|
|
139
181
|
const resolution = resolveAiDefault({
|
|
140
|
-
|
|
182
|
+
choice: null,
|
|
141
183
|
isSet: (name) => typeof values[name] === "string" &&
|
|
142
184
|
values[name].trim().length > 0,
|
|
143
185
|
});
|
package/dist/server/index.d.ts
CHANGED
|
@@ -3,27 +3,24 @@
|
|
|
3
3
|
*
|
|
4
4
|
* There is intentionally no client-side export.
|
|
5
5
|
*/
|
|
6
|
-
export { ConfigurationError,
|
|
7
|
-
export { OrganizationMismatchError, RequestContextError, currentUser, withOrganization, } from "./context.js";
|
|
6
|
+
export { ConfigurationError, everyApp, getEveryAppUser, hasScope, isAdmin, requireEveryAppUser, type EveryAppOptions, type EveryAppHandler, type EveryAppUser, type IdentityResult, type OrgRole, } from "./everyApp.js";
|
|
8
7
|
export { AttributionError, type GatewayCallFor } from "./attribution.js";
|
|
9
8
|
export { gatewayUrl } from "./gatewayUrl.js";
|
|
10
9
|
export type { EveryAppEnv } from "./env.js";
|
|
11
10
|
/** The header a Gateway refusal carries its code in; `gatewayRefusal()` reads the rest. */
|
|
12
11
|
export { GATEWAY_ERROR_HEADER } from "../internal/protocol.js";
|
|
13
|
-
export { authorizeUrl, type AuthorizeUrlOptions } from "./authorizeUrl.js";
|
|
14
12
|
export { connectPath, connectUrl, type ConnectUrlOptions, } from "./connectUrl.js";
|
|
15
13
|
export { createGatewayFetch, type CreateGatewayFetchOptions, } from "./gatewayFetch.js";
|
|
16
|
-
export {
|
|
17
|
-
export {
|
|
14
|
+
export { aiBaseUrl, providerBaseUrl } from "./ai.js";
|
|
15
|
+
export { GatewayRefusalError, gatewayRefusal, refusalFromError, type GatewayRefusal, type SetupInfo, } from "./refusal.js";
|
|
18
16
|
export { devAccessTokenName, integrationFetch, integrationStatus, type EmailIntegrationStatus, type IntegrationFetchOptions, type IntegrationStatus, type IntegrationStatusOf, type OAuthClientIntegrationStatus, } from "./integrationFetch.js";
|
|
19
17
|
export { nodeServerHandler, type NodeServer, type NodeServerHandlerOptions, } from "./nodeServer.js";
|
|
20
18
|
export { sendEmail, type SendEmailOptions } from "./sendEmail.js";
|
|
21
|
-
export { gatewayAiBinding, type GatewayAiBindingOptions } from "./aiBinding.js";
|
|
22
|
-
export { gatewayEmailBinding, type GatewayEmailBindingMessage, type GatewayEmailBindingOptions, } from "./emailBinding.js";
|
|
23
19
|
export { listMembers, type ListMembersOptions } from "./listMembers.js";
|
|
24
20
|
export { emit, type EmitOptions } from "./emit.js";
|
|
25
|
-
export
|
|
21
|
+
export { WEBHOOK_MAX_BYTES_DEFAULT, verifyWebhook, type VerifyWebhookOptions, type WebhookProvider, type WebhookRefusalReason, type WebhookVerification, } from "./webhooks.js";
|
|
22
|
+
export type { AppEvent, AppEventHandler, AppEventsOptions, } from "./eventsEndpoint.js";
|
|
23
|
+
export type { ApiKeyCapabilityId, CapabilityId, OAuthPresetId, EmailAddressInput, EmailAttachmentInput, SendEmailMessage, SendEmailResult, ListMembersResult, OrganizationMember, OrganizationMemberRole, EmitEventResult, } from "../internal/index.js";
|
|
26
24
|
export { ToolError, defineTools, toolResult, type DefineToolsOptions, type PlainToolSchema, type StandardSchemaWithJSON, type ToolContext, type ToolDefinition, type ToolResult, type ToolSchema, type ToolSet, } from "./tools.js";
|
|
27
25
|
export type { ToolRisk } from "../internal/index.js";
|
|
28
|
-
export { fromMcpTools, type FromMcpToolsOptions, type McpToolAnnotationsLike, type McpToolLike, type McpToolResultLike, type McpToolSchemaLike, } from "./fromMcpTools.js";
|
|
29
26
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/server/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,EACL,kBAAkB,EAClB,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/server/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,EACL,kBAAkB,EAClB,QAAQ,EACR,eAAe,EACf,QAAQ,EACR,OAAO,EACP,mBAAmB,EACnB,KAAK,eAAe,EACpB,KAAK,eAAe,EACpB,KAAK,YAAY,EACjB,KAAK,cAAc,EACnB,KAAK,OAAO,GACb,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,gBAAgB,EAAE,KAAK,cAAc,EAAE,MAAM,kBAAkB,CAAC;AACzE,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AA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,EAChB,eAAe,EACf,iBAAiB,EACjB,kBAAkB,EAClB,sBAAsB,EACtB,eAAe,GAChB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EACL,SAAS,EACT,WAAW,EACX,UAAU,EACV,KAAK,kBAAkB,EACvB,KAAK,eAAe,EACpB,KAAK,sBAAsB,EAC3B,KAAK,WAAW,EAChB,KAAK,cAAc,EACnB,KAAK,UAAU,EACf,KAAK,UAAU,EACf,KAAK,OAAO,GACb,MAAM,YAAY,CAAC;AACpB,YAAY,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC"}
|
package/dist/server/index.js
CHANGED
|
@@ -3,23 +3,19 @@
|
|
|
3
3
|
*
|
|
4
4
|
* There is intentionally no client-side export.
|
|
5
5
|
*/
|
|
6
|
-
export { ConfigurationError,
|
|
7
|
-
export { OrganizationMismatchError, RequestContextError, currentUser, withOrganization, } from "./context.js";
|
|
6
|
+
export { ConfigurationError, everyApp, getEveryAppUser, hasScope, isAdmin, requireEveryAppUser, } from "./everyApp.js";
|
|
8
7
|
export { AttributionError } from "./attribution.js";
|
|
9
8
|
export { gatewayUrl } from "./gatewayUrl.js";
|
|
10
9
|
/** The header a Gateway refusal carries its code in; `gatewayRefusal()` reads the rest. */
|
|
11
10
|
export { GATEWAY_ERROR_HEADER } from "../internal/protocol.js";
|
|
12
|
-
export { authorizeUrl } from "./authorizeUrl.js";
|
|
13
11
|
export { connectPath, connectUrl, } from "./connectUrl.js";
|
|
14
12
|
export { createGatewayFetch, } from "./gatewayFetch.js";
|
|
15
|
-
export {
|
|
16
|
-
export {
|
|
13
|
+
export { aiBaseUrl, providerBaseUrl } from "./ai.js";
|
|
14
|
+
export { GatewayRefusalError, gatewayRefusal, refusalFromError, } from "./refusal.js";
|
|
17
15
|
export { devAccessTokenName, integrationFetch, integrationStatus, } from "./integrationFetch.js";
|
|
18
16
|
export { nodeServerHandler, } from "./nodeServer.js";
|
|
19
17
|
export { sendEmail } from "./sendEmail.js";
|
|
20
|
-
export { gatewayAiBinding } from "./aiBinding.js";
|
|
21
|
-
export { gatewayEmailBinding, } from "./emailBinding.js";
|
|
22
18
|
export { listMembers } from "./listMembers.js";
|
|
23
19
|
export { emit } from "./emit.js";
|
|
20
|
+
export { WEBHOOK_MAX_BYTES_DEFAULT, verifyWebhook, } from "./webhooks.js";
|
|
24
21
|
export { ToolError, defineTools, toolResult, } from "./tools.js";
|
|
25
|
-
export { fromMcpTools, } from "./fromMcpTools.js";
|
|
@@ -1,45 +1,47 @@
|
|
|
1
|
-
import { type ApiKeyCapabilityId, type CapabilityId, type
|
|
1
|
+
import { type ApiKeyCapabilityId, type CapabilityId, type EmailCapabilityStatus, type OAuthPresetId } from "../internal/index.js";
|
|
2
2
|
import { type GatewayCallFor } from "./attribution.js";
|
|
3
3
|
import type { SetupInfo } from "./refusal.js";
|
|
4
4
|
export interface IntegrationFetchOptions {
|
|
5
5
|
/**
|
|
6
6
|
* The Worker env: the EVERY_APP_GATEWAY binding when deployed, or in local
|
|
7
7
|
* dev EVERYAPP_DEV and the provider's key (e.g. DATAFORSEO_API_KEY in
|
|
8
|
-
* `.dev.vars`)
|
|
8
|
+
* `.dev.vars`), or for an OAuth provider a token you obtained yourself
|
|
9
|
+
* (`GOOGLE_WORKSPACE_ACCESS_TOKEN`, {@link devAccessTokenName}).
|
|
9
10
|
*/
|
|
10
11
|
env: object;
|
|
11
12
|
/**
|
|
12
13
|
* A provider the app lists in its manifest's `capabilities`: one whose
|
|
13
|
-
* key the gateway holds, or
|
|
14
|
-
*
|
|
15
|
-
* registered on the gateway (
|
|
14
|
+
* key the gateway holds, or an OAuth provider whose connections it
|
|
15
|
+
* holds. The catalog's ids and the OAuth presets' complete; a provider
|
|
16
|
+
* registered on the gateway (an OAuth preset's row among them) is
|
|
16
17
|
* reached through the binding, which checks it. The `email` capability
|
|
17
18
|
* is sent with `sendEmail()` instead.
|
|
18
19
|
*/
|
|
19
|
-
provider: ApiKeyCapabilityId |
|
|
20
|
+
provider: ApiKeyCapabilityId | OAuthPresetId | (string & {});
|
|
20
21
|
/**
|
|
21
22
|
* Whom the call is for. Left out, the request `everyApp()` is serving
|
|
22
|
-
* (its
|
|
23
|
-
*
|
|
23
|
+
* (its person, while the identity is good) or the organization
|
|
24
|
+
* an event delivery runs under; outside both, `RequestContextError`.
|
|
24
25
|
* Explicitly: the inbound request, or `{ background: true,
|
|
25
26
|
* organizationId }` for work no person started (crons, Workflows,
|
|
26
27
|
* queues). A shared app's Worker must end up with one or the other
|
|
27
28
|
* ({@link AttributionError}).
|
|
29
|
+
*
|
|
30
|
+
* For an OAuth provider the call uses the connection the person behind
|
|
31
|
+
* it made in this app. `{ background: true, userId }` names another
|
|
32
|
+
* member's connection to this app instead, at any time, even while
|
|
33
|
+
* serving a different person: the call then carries that member and
|
|
34
|
+
* not the person being served. Only an organization's own app may.
|
|
28
35
|
*/
|
|
29
36
|
for?: GatewayCallFor;
|
|
30
|
-
/**
|
|
31
|
-
* For an OAuth provider the gateway holds connections for: whose
|
|
32
|
-
* connection the call uses, the person's (`user`, the default when a
|
|
33
|
-
* person is behind the call) or the organization's (`organization`,
|
|
34
|
-
* the default for background work). Sent as `x-everyapp-account`.
|
|
35
|
-
*/
|
|
36
|
-
account?: ConnectionAccount;
|
|
37
37
|
/**
|
|
38
38
|
* `true`: answer null instead of throwing `ConfigurationError` when the
|
|
39
39
|
* provider is unavailable (no binding, and in local dev not its
|
|
40
40
|
* settings in `.dev.vars`), so a feature that can do without it checks
|
|
41
41
|
* for null. A wrong provider id, a binding that isn't one, and an
|
|
42
|
-
* attribution mistake still throw.
|
|
42
|
+
* attribution mistake still throw. An OAuth provider is never
|
|
43
|
+
* unavailable this way: without a connection its calls answer
|
|
44
|
+
* `integration_not_connected`.
|
|
43
45
|
*/
|
|
44
46
|
optional?: boolean;
|
|
45
47
|
}
|
|
@@ -51,19 +53,19 @@ export interface IntegrationFetchOptions {
|
|
|
51
53
|
* sees the key. A refusal the gateway makes itself comes back as a response
|
|
52
54
|
* {@link gatewayRefusal} recognizes; anything else is the provider's answer.
|
|
53
55
|
*
|
|
54
|
-
* For an OAuth
|
|
55
|
-
*
|
|
56
|
-
*
|
|
57
|
-
* `
|
|
58
|
-
* {@link
|
|
59
|
-
* token directly.
|
|
56
|
+
* For an OAuth provider (`google-workspace`, `github`, ...) the gateway
|
|
57
|
+
* puts the token of the person's connection in this app on the call, to
|
|
58
|
+
* the provider's API hosts only. Without one the answer is a 409
|
|
59
|
+
* `integration_not_connected` refusal with the `connectPath` to send the
|
|
60
|
+
* person to ({@link connectUrl}).
|
|
60
61
|
*
|
|
61
|
-
* In local dev only, with no binding, the developer's own key
|
|
62
|
-
*
|
|
62
|
+
* In local dev only, with no binding, the developer's own key from
|
|
63
|
+
* `.dev.vars` reaches the provider directly, under the gateway's names:
|
|
63
64
|
* a catalog provider's from the catalog, a provider registered on the
|
|
64
65
|
* gateway from its spec in `.everyapp/providers/<id>.json` (`everyapp
|
|
65
66
|
* provider show <id> --save` writes it), put on the call as the gateway's
|
|
66
|
-
* spec says.
|
|
67
|
+
* spec says. An OAuth provider's calls carry a token you obtained
|
|
68
|
+
* yourself ({@link devAccessTokenName}), to its API hosts only.
|
|
67
69
|
*/
|
|
68
70
|
export declare function integrationFetch(options: IntegrationFetchOptions & {
|
|
69
71
|
optional: true;
|
|
@@ -92,70 +94,56 @@ export interface IntegrationStatus extends SetupInfo {
|
|
|
92
94
|
*/
|
|
93
95
|
export type EmailIntegrationStatus = IntegrationStatus & Pick<EmailCapabilityStatus, "sender" | "senders" | "provider">;
|
|
94
96
|
/**
|
|
95
|
-
* An OAuth
|
|
96
|
-
*
|
|
97
|
-
*
|
|
97
|
+
* An OAuth provider's status: as {@link IntegrationStatus}, plus the
|
|
98
|
+
* scopes the app's manifest lists, where the person connects in this app,
|
|
99
|
+
* and their connection to this app. `configured` means the gateway holds
|
|
100
|
+
* the client; `ready` that a call for this person would go through.
|
|
98
101
|
*/
|
|
99
|
-
export
|
|
100
|
-
/** The
|
|
101
|
-
|
|
102
|
-
/**
|
|
103
|
-
* For a client with scope sets (`google-workspace`, `microsoft-365`): the
|
|
104
|
-
* set names the app's manifest entry declares, `[]` when the entry voids
|
|
105
|
-
* its grant (no `scopes`, or a set this gateway doesn't offer), in which
|
|
106
|
-
* case `ready` is false and no token call can complete.
|
|
107
|
-
*/
|
|
108
|
-
scopeSets?: readonly string[];
|
|
102
|
+
export type OAuthClientIntegrationStatus = IntegrationStatus & {
|
|
103
|
+
/** The provider's scopes as the app's `everyapp.config.ts` lists them. */
|
|
104
|
+
scopes: readonly string[];
|
|
109
105
|
/**
|
|
110
|
-
*
|
|
111
|
-
*
|
|
112
|
-
*
|
|
113
|
-
*
|
|
106
|
+
* Where the person connects the provider in this app:
|
|
107
|
+
* `/connect/<id>?app=<app>` on the Gateway ({@link connectUrl} builds
|
|
108
|
+
* the absolute URL); null when the app can't connect (the manifest
|
|
109
|
+
* doesn't list it, or the gateway holds no client).
|
|
114
110
|
*/
|
|
115
|
-
|
|
116
|
-
/** Slack's `user_scope` strings, when the sets name any. */
|
|
117
|
-
userScopes?: readonly string[];
|
|
111
|
+
connectPath: string | null;
|
|
118
112
|
/**
|
|
119
|
-
*
|
|
120
|
-
*
|
|
121
|
-
*
|
|
122
|
-
* `
|
|
123
|
-
*
|
|
113
|
+
* The connection the call would use (the person's in this app, or the
|
|
114
|
+
* member's `for: { background: true, userId }` names), or null when there
|
|
115
|
+
* is none. `ready` false with `missingScopes` when it lacks a scope the
|
|
116
|
+
* app now lists, and `reconnect` when the person has to connect again
|
|
117
|
+
* (missing scopes, or it expired).
|
|
124
118
|
*/
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
connectPath?: string;
|
|
128
|
-
/**
|
|
129
|
-
* The connection the caller's account would use (the person's, or the
|
|
130
|
-
* organization's for background work), or null when there is none yet;
|
|
131
|
-
* `reconnect` when it exists but lacks a set the app declares or has
|
|
132
|
-
* expired, so the person has to connect again.
|
|
133
|
-
*/
|
|
134
|
-
connection?: {
|
|
135
|
-
account: ConnectionAccount;
|
|
119
|
+
connection: {
|
|
120
|
+
/** The account's name at the provider (an email address, a login). */
|
|
136
121
|
label: string | null;
|
|
137
|
-
|
|
122
|
+
/** The scopes it holds, canonical. */
|
|
123
|
+
scopes: readonly string[];
|
|
138
124
|
ready: boolean;
|
|
139
|
-
|
|
125
|
+
missingScopes?: readonly string[];
|
|
126
|
+
reconnect?: true;
|
|
140
127
|
} | null;
|
|
141
|
-
}
|
|
142
|
-
/** The status of a capability: email's carries its senders, an OAuth
|
|
143
|
-
export type IntegrationStatusOf<P extends string> = P extends "email" ? EmailIntegrationStatus : P extends
|
|
128
|
+
};
|
|
129
|
+
/** The status of a capability: email's carries its senders, an OAuth provider's the connection. */
|
|
130
|
+
export type IntegrationStatusOf<P extends string> = P extends "email" ? EmailIntegrationStatus : P extends OAuthPresetId ? OAuthClientIntegrationStatus : IntegrationStatus;
|
|
144
131
|
/**
|
|
145
132
|
* Whether the app can use an integration right now, without calling the
|
|
146
133
|
* provider: show "an admin needs to set up DataForSEO" (or "sending isn't
|
|
147
|
-
* set up") up front instead of failing mid-task. An
|
|
148
|
-
* carries
|
|
134
|
+
* set up", or "connect Google") up front instead of failing mid-task. An
|
|
135
|
+
* OAuth provider's status carries the person's connection in this app and
|
|
136
|
+
* where to connect.
|
|
149
137
|
*/
|
|
150
138
|
export declare function integrationStatus<P extends CapabilityId | (string & {})>({ env, provider, for: explicitTarget, }: {
|
|
151
139
|
env: object;
|
|
152
140
|
provider: P;
|
|
153
141
|
/**
|
|
154
142
|
* Whom the status is for: the request being served (its person), so an
|
|
155
|
-
* OAuth provider's `connection` is that person's;
|
|
156
|
-
*
|
|
157
|
-
*
|
|
158
|
-
*
|
|
143
|
+
* OAuth provider's `connection` is that person's in this app; `{
|
|
144
|
+
* background: true, userId }` that member's. Explicitly the inbound
|
|
145
|
+
* request or `{ background: true, organizationId, userId? }`, as on
|
|
146
|
+
* every call.
|
|
159
147
|
*/
|
|
160
148
|
for?: GatewayCallFor;
|
|
161
149
|
}): Promise<IntegrationStatusOf<P>>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"integrationFetch.d.ts","sourceRoot":"","sources":["../../src/server/integrationFetch.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"integrationFetch.d.ts","sourceRoot":"","sources":["../../src/server/integrationFetch.ts"],"names":[],"mappings":"AAAA,OAAO,EAeL,KAAK,kBAAkB,EACvB,KAAK,YAAY,EACjB,KAAK,qBAAqB,EAE1B,KAAK,aAAa,EAKnB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAGL,KAAK,cAAc,EACpB,MAAM,kBAAkB,CAAC;AAE1B,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAO9C,MAAM,WAAW,uBAAuB;IACtC;;;;;OAKG;IACH,GAAG,EAAE,MAAM,CAAC;IACZ;;;;;;;OAOG;IACH,QAAQ,EAAE,kBAAkB,GAAG,aAAa,GAAG,CAAC,MAAM,GAAG,EAAE,CAAC,CAAC;IAC7D;;;;;;;;;;;;;;OAcG;IACH,GAAG,CAAC,EAAE,cAAc,CAAC;IACrB;;;;;;;;OAQG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAED;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAgB,gBAAgB,CAC9B,OAAO,EAAE,uBAAuB,GAAG;IAAE,QAAQ,EAAE,IAAI,CAAA;CAAE,GACpD,OAAO,KAAK,GAAG,IAAI,CAAC;AACvB,wBAAgB,gBAAgB,CAC9B,OAAO,EAAE,uBAAuB,GAC/B,OAAO,KAAK,CAAC;AAgHhB;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAE3D;AAsLD,MAAM,WAAW,iBAAkB,SAAQ,SAAS;IAClD,+CAA+C;IAC/C,SAAS,EAAE,OAAO,CAAC;IACnB,2EAA2E;IAC3E,UAAU,EAAE,OAAO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