apps 0.0.1-beta.2 → 0.0.1-beta.21
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 +68 -44
- package/framework-reference.json +1 -1
- package/js/{chunk-SATWJKN6.js → chunk-27F7W2LG.js} +1 -1
- package/js/{chunk-WFSQXYUT.js → chunk-4QQ62BVS.js} +37 -3
- package/js/{chunk-HDJH3RPR.js → chunk-57RKNWL2.js} +2 -2
- package/js/chunk-625MBYU4.js +524 -0
- package/js/{chunk-RN2MXB4R.js → chunk-BLI53LPN.js} +28 -9
- package/js/{chunk-FW5HBOIK.js → chunk-CDL5PM2Q.js} +307 -169
- package/js/{chunk-J7O55ZV7.js → chunk-CHAK4P5C.js} +317 -176
- package/js/{chunk-HDTGZWP2.js → chunk-CMRKLZZY.js} +8 -8
- package/js/{chunk-OHRT55C4.js → chunk-IJX4CYZO.js} +3 -6
- package/js/{chunk-FDNTX5QJ.js → chunk-IPI4MFSN.js} +2 -2
- package/js/{chunk-YEJOQEII.js → chunk-JU7VHODU.js} +1 -1
- package/js/chunk-KUMBKVJD.js +39 -0
- package/js/{chunk-EVJUVWN2.js → chunk-M3B3DE4K.js} +2 -2
- package/js/{chunk-ZJWDMTE3.js → chunk-MKWZPDR6.js} +3 -3
- package/js/{chunk-BMOIAIVR.js → chunk-N7YDVXYJ.js} +49 -1
- package/js/{chunk-D47C7KG5.js → chunk-NKLWZJLE.js} +2 -2
- package/js/chunk-NMKHTJOQ.js +254 -0
- package/js/chunk-OD3KFKZD.js +1617 -0
- package/js/{chunk-ZCAMUXSG.js → chunk-ODEIDRGW.js} +3 -4
- package/js/{chunk-5MQZEB6Y.js → chunk-OZ4UK3CD.js} +37 -12
- package/js/{chunk-M6ZRRIBI.js → chunk-PJJ24GU7.js} +1 -1
- package/js/{chunk-FZJOYIZO.js → chunk-PZB6T6KU.js} +1 -1
- package/js/{chunk-LGIYBDWA.js → chunk-R3EV5FTO.js} +13 -1
- package/js/{chunk-Z5NMEGJN.js → chunk-RAAPJMVZ.js} +21 -9
- package/js/{chunk-QKHR7BMF.js → chunk-UK573G7W.js} +1 -1
- package/js/{chunk-4LPG6RCH.js → chunk-VFZKSM3T.js} +5 -25
- package/js/{chunk-MYYEW3RA.js → chunk-VXWY44LE.js} +780 -55
- package/js/{chunk-JN55AYQH.js → chunk-XNCYIB4D.js} +61 -32
- package/js/{chunk-PLCMJREA.js → chunk-ZQINWV4W.js} +60 -20
- package/js/client.js +10 -26
- package/js/contracts.js +74 -16
- package/js/effect.js +19 -20
- package/js/{es-APDZKREY.js → es-DIULA3ZF.js} +62 -1659
- package/js/graphql.js +47 -49
- package/js/host.js +19 -20
- package/js/index.js +232 -201
- package/js/mcp/effect.js +21 -22
- package/js/mcp/stdio.js +25 -26
- package/js/mcp.js +74 -56
- package/js/openapi.js +3428 -1276
- package/js/react.js +3 -3
- package/js/skills/effect.js +3 -3
- package/js/skills.js +12 -13
- package/js/storage/facet.js +4 -4
- package/js/ui/auth/contracts.js +8 -9
- package/js/ui/auth.js +16 -14
- package/js/ui/contracts.js +4 -4
- package/js/ui/serving.js +71 -218
- package/package.json +1 -1
- package/runtime.json +1 -1
- package/types/app-data/src/contracts/database.d.ts +33 -6
- package/types/app-data/src/implementation/schema.d.ts +2 -17
- package/types/apps/src/contracts/app.d.ts +7 -6
- package/types/apps/src/contracts/failure.d.ts +25 -0
- package/types/apps/src/contracts/host.d.ts +31 -10
- package/types/apps/src/contracts/mcp.d.ts +16 -0
- package/types/apps/src/contracts/openapi.d.ts +5 -1
- package/types/apps/src/contracts/operations.d.ts +0 -5
- package/types/apps/src/contracts/protocol-version.d.ts +2 -2
- package/types/apps/src/contracts/protocols/1.d.ts +235 -67
- package/types/apps/src/contracts/protocols/2.d.ts +710 -0
- package/types/apps/src/contracts/protocols/3.d.ts +718 -0
- package/types/apps/src/contracts/protocols/4.d.ts +1299 -0
- package/types/apps/src/contracts/protocols/5.d.ts +1174 -0
- package/types/apps/src/contracts/protocols/6.d.ts +1620 -0
- package/types/apps/src/contracts/protocols/7.d.ts +1784 -0
- package/types/apps/src/contracts/protocols/oauth.d.ts +89 -0
- package/types/apps/src/contracts/provider.d.ts +109 -10
- package/types/apps/src/contracts/router.d.ts +59 -0
- package/types/apps/src/contracts/storage.d.ts +3 -3
- package/types/apps/src/contracts/ui-auth.d.ts +6 -14
- package/types/apps/src/contracts/ui.d.ts +18 -0
- package/types/apps/src/contracts/workflows.d.ts +34 -3
- package/types/apps/src/graphql.d.ts +1 -3
- package/types/apps/src/implementation/account-router.d.ts +12 -0
- package/types/apps/src/implementation/app.d.ts +5 -4
- package/types/apps/src/implementation/browser-scripts.gen.d.ts +6 -0
- package/types/apps/src/implementation/catalog-cache.d.ts +34 -4
- package/types/apps/src/implementation/elicitation.d.ts +2 -2
- package/types/apps/src/implementation/failure-detail.d.ts +26 -0
- package/types/apps/src/implementation/graphql-catalog.d.ts +4 -7
- package/types/apps/src/implementation/mcp-catalog.d.ts +7 -8
- package/types/apps/src/implementation/mcp-client.d.ts +35 -19
- package/types/apps/src/implementation/mcp.d.ts +35 -19
- package/types/apps/src/implementation/openapi-compile.d.ts +9 -5
- package/types/apps/src/implementation/openapi-document.d.ts +15 -2
- package/types/apps/src/implementation/openapi-request.d.ts +8 -1
- package/types/apps/src/implementation/openapi-source.d.ts +2 -6
- package/types/apps/src/implementation/openapi-upgrade.d.ts +4 -0
- package/types/apps/src/implementation/operations.d.ts +36 -3
- package/types/apps/src/implementation/protocol-operations.d.ts +3 -4
- package/types/apps/src/implementation/provider.d.ts +19 -5
- package/types/apps/src/implementation/router-catalog.d.ts +225 -0
- package/types/apps/src/implementation/router.d.ts +68 -0
- package/types/apps/src/implementation/runtime-yield.d.ts +7 -0
- package/types/apps/src/implementation/schema.d.ts +44 -1
- package/types/apps/src/implementation/storage.d.ts +5 -3
- package/types/apps/src/implementation/ui-account-notice.d.ts +9 -0
- package/types/apps/src/implementation/ui-auth.d.ts +11 -5
- package/types/apps/src/implementation/ui-errors.d.ts +1 -1
- package/types/apps/src/implementation/ui-serving.d.ts +10 -4
- package/types/apps/src/implementation/ui-watch.d.ts +1 -1
- package/types/apps/src/implementation/webhooks.d.ts +1 -1
- package/types/apps/src/implementation/workflow-context.d.ts +11 -3
- package/types/apps/src/index.d.ts +28 -11
- package/types/apps/src/mcp-stdio.d.ts +2 -5
- package/types/apps/src/mcp.d.ts +5 -4
- package/types/apps/src/openapi.d.ts +6 -6
- package/types/apps/src/ui-auth.d.ts +2 -2
- package/types/telemetry/src/browser-operations.d.ts +5 -2
- package/js/chunk-PYUYJRSK.js +0 -93
- package/js/chunk-SWPD52J7.js +0 -35
- package/js/chunk-TE4KO4HI.js +0 -47
- package/js/chunk-W7D7WVSY.js +0 -18
- package/types/apps/src/contracts/dynamic-tools.d.ts +0 -13
- package/types/apps/src/implementation/account-operations.d.ts +0 -151
- package/types/apps/src/implementation/dynamic-tools.d.ts +0 -8
|
@@ -2,36 +2,36 @@ import {
|
|
|
2
2
|
adaptMcpTools,
|
|
3
3
|
mcpClient,
|
|
4
4
|
mcpJsonSchemaValidator
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-BLI53LPN.js";
|
|
6
6
|
import {
|
|
7
7
|
accountProviderError,
|
|
8
8
|
httpProviderError
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-MKWZPDR6.js";
|
|
10
10
|
import {
|
|
11
11
|
McpError,
|
|
12
12
|
McpToolsOptions,
|
|
13
13
|
defaultMcpClientLimits
|
|
14
|
-
} from "./chunk-
|
|
14
|
+
} from "./chunk-VXWY44LE.js";
|
|
15
15
|
import {
|
|
16
16
|
ProviderError
|
|
17
|
-
} from "./chunk-
|
|
17
|
+
} from "./chunk-R3EV5FTO.js";
|
|
18
18
|
import {
|
|
19
19
|
captureTelemetry
|
|
20
|
-
} from "./chunk-
|
|
20
|
+
} from "./chunk-ODEIDRGW.js";
|
|
21
21
|
import {
|
|
22
22
|
FetchHttpClient_exports
|
|
23
|
-
} from "./chunk-
|
|
23
|
+
} from "./chunk-57RKNWL2.js";
|
|
24
24
|
import {
|
|
25
25
|
HttpClientRequest_exports,
|
|
26
26
|
HttpClient_exports
|
|
27
|
-
} from "./chunk-
|
|
27
|
+
} from "./chunk-UK573G7W.js";
|
|
28
28
|
import {
|
|
29
29
|
Deferred_exports,
|
|
30
30
|
Effect_exports,
|
|
31
31
|
Redacted_exports,
|
|
32
32
|
Schema_exports,
|
|
33
33
|
Stream_exports
|
|
34
|
-
} from "./chunk-
|
|
34
|
+
} from "./chunk-CDL5PM2Q.js";
|
|
35
35
|
|
|
36
36
|
// src/implementation/mcp.ts
|
|
37
37
|
import { UnauthorizedError } from "@modelcontextprotocol/sdk/client/auth.js";
|
|
@@ -19,10 +19,10 @@ import {
|
|
|
19
19
|
text,
|
|
20
20
|
uint8Array,
|
|
21
21
|
urlParams
|
|
22
|
-
} from "./chunk-
|
|
22
|
+
} from "./chunk-UK573G7W.js";
|
|
23
23
|
import {
|
|
24
24
|
JsonValue
|
|
25
|
-
} from "./chunk-
|
|
25
|
+
} from "./chunk-27F7W2LG.js";
|
|
26
26
|
import {
|
|
27
27
|
Cause,
|
|
28
28
|
Defect,
|
|
@@ -118,7 +118,7 @@ import {
|
|
|
118
118
|
transformEffect,
|
|
119
119
|
transformPull,
|
|
120
120
|
void_2 as void_
|
|
121
|
-
} from "./chunk-
|
|
121
|
+
} from "./chunk-CDL5PM2Q.js";
|
|
122
122
|
import {
|
|
123
123
|
__export
|
|
124
124
|
} from "./chunk-CZ7CSFO4.js";
|
|
@@ -1784,10 +1784,7 @@ var AppUiApi = HttpApi_exports.make("app-ui").add(
|
|
|
1784
1784
|
);
|
|
1785
1785
|
|
|
1786
1786
|
export {
|
|
1787
|
-
HttpApiEndpoint_exports,
|
|
1788
|
-
HttpApi_exports,
|
|
1789
1787
|
HttpApiClient_exports,
|
|
1790
|
-
HttpApiGroup_exports,
|
|
1791
1788
|
UiContext,
|
|
1792
1789
|
UiOperation,
|
|
1793
1790
|
UiUnauthorized,
|
|
@@ -5,11 +5,11 @@ import {
|
|
|
5
5
|
SkillDefinitionInvalid,
|
|
6
6
|
SkillFile,
|
|
7
7
|
SkillFilePath
|
|
8
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-JU7VHODU.js";
|
|
9
9
|
import {
|
|
10
10
|
Effect_exports,
|
|
11
11
|
Schema_exports
|
|
12
|
-
} from "./chunk-
|
|
12
|
+
} from "./chunk-CDL5PM2Q.js";
|
|
13
13
|
|
|
14
14
|
// src/implementation/skill-files.ts
|
|
15
15
|
var skillFromFiles = (input, source = {}) => Effect_exports.gen(function* () {
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import {
|
|
2
|
+
appSignInCallbackPath
|
|
3
|
+
} from "./chunk-VFZKSM3T.js";
|
|
4
|
+
import {
|
|
5
|
+
HttpServerResponse_exports
|
|
6
|
+
} from "./chunk-UK573G7W.js";
|
|
7
|
+
|
|
8
|
+
// src/implementation/ui-auth.ts
|
|
9
|
+
var appPrivateHeaders = {
|
|
10
|
+
"cache-control": "no-store",
|
|
11
|
+
"referrer-policy": "no-referrer",
|
|
12
|
+
"x-content-type-options": "nosniff",
|
|
13
|
+
"content-security-policy": "frame-ancestors 'none'"
|
|
14
|
+
};
|
|
15
|
+
var appRedirect = (url) => HttpServerResponse_exports.redirect(url, { status: 302, headers: appPrivateHeaders });
|
|
16
|
+
var appSignInCallback = (origin, request, code) => {
|
|
17
|
+
const callback = new URL(appSignInCallbackPath, origin);
|
|
18
|
+
callback.searchParams.set("request", request);
|
|
19
|
+
callback.searchParams.set("code", code);
|
|
20
|
+
return callback.href;
|
|
21
|
+
};
|
|
22
|
+
var appSignInFailed = () => HttpServerResponse_exports.text(
|
|
23
|
+
`<!doctype html><html><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1"><title>Could not open app</title></head><body><p>Could not sign in to this app. Try opening it again.</p><a href="/">Try again</a></body></html>`,
|
|
24
|
+
{
|
|
25
|
+
status: 401,
|
|
26
|
+
contentType: "text/html",
|
|
27
|
+
headers: {
|
|
28
|
+
...appPrivateHeaders,
|
|
29
|
+
"content-security-policy": "default-src 'none'; frame-ancestors 'none'; base-uri 'none'"
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
);
|
|
33
|
+
|
|
34
|
+
export {
|
|
35
|
+
appPrivateHeaders,
|
|
36
|
+
appRedirect,
|
|
37
|
+
appSignInCallback,
|
|
38
|
+
appSignInFailed
|
|
39
|
+
};
|
|
@@ -3,7 +3,7 @@ import {
|
|
|
3
3
|
invalidate,
|
|
4
4
|
layer,
|
|
5
5
|
mutation
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-PJJ24GU7.js";
|
|
7
7
|
import {
|
|
8
8
|
Boolean,
|
|
9
9
|
Cause,
|
|
@@ -158,7 +158,7 @@ import {
|
|
|
158
158
|
void_2,
|
|
159
159
|
whileLoop,
|
|
160
160
|
zipRight
|
|
161
|
-
} from "./chunk-
|
|
161
|
+
} from "./chunk-CDL5PM2Q.js";
|
|
162
162
|
import {
|
|
163
163
|
__export
|
|
164
164
|
} from "./chunk-CZ7CSFO4.js";
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import {
|
|
2
2
|
ProviderError
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-R3EV5FTO.js";
|
|
4
4
|
import {
|
|
5
5
|
AccountId
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-27F7W2LG.js";
|
|
7
7
|
import {
|
|
8
8
|
Option_exports,
|
|
9
9
|
Schema_exports
|
|
10
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-CDL5PM2Q.js";
|
|
11
11
|
|
|
12
12
|
// src/implementation/provider-error.ts
|
|
13
13
|
function parseProviderError(error) {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
Schema_exports
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-CDL5PM2Q.js";
|
|
4
4
|
|
|
5
5
|
// ../app-data/src/contracts/database.ts
|
|
6
6
|
var DataName = Schema_exports.String.check(
|
|
@@ -113,6 +113,51 @@ var defaultDatabaseLimits = {
|
|
|
113
113
|
valueBytes: 64 * 1024,
|
|
114
114
|
indexBytes: 2048
|
|
115
115
|
};
|
|
116
|
+
var DatabaseLimit = Schema_exports.Literals([
|
|
117
|
+
"scanCalls",
|
|
118
|
+
"directGets",
|
|
119
|
+
"rowsRead",
|
|
120
|
+
"rowsReturned",
|
|
121
|
+
"pageSize",
|
|
122
|
+
"bytesRead",
|
|
123
|
+
"writes",
|
|
124
|
+
"valueBytes"
|
|
125
|
+
]);
|
|
126
|
+
var count = (value) => value.toLocaleString("en-US");
|
|
127
|
+
var limitMessages = {
|
|
128
|
+
scanCalls: (maximum, requested) => `This invocation made ${count(requested)} index queries; the limit is ${count(maximum)}. Each first(), take(), collect(), count() or paginate() call on withIndex(...) counts once. Read related rows with one take() or paginate() over a shared index prefix instead of one first() per item, use get(id) for known IDs, or split the work across workflow steps.`,
|
|
129
|
+
directGets: (maximum, requested) => `This invocation made ${count(requested)} get(id) calls, including those made by update and delete; the limit is ${count(maximum)}. Split the work across workflow steps or mutations.`,
|
|
130
|
+
rowsRead: (maximum, requested) => `This invocation scanned ${count(requested)} rows; the limit is ${count(maximum)}. Narrow the index range, or page with paginate() across calls or workflow steps.`,
|
|
131
|
+
rowsReturned: (maximum, requested) => `This invocation returned ${count(requested)} rows; the limit is ${count(maximum)}. collect() fails rather than truncating. Page with paginate() across calls or workflow steps.`,
|
|
132
|
+
pageSize: (maximum, requested) => `One call asked for ${count(requested)} rows; take(n) and paginate({ numItems }) accept at most ${count(maximum)}. Page with paginate() across calls or workflow steps.`,
|
|
133
|
+
bytesRead: (maximum, requested) => `This invocation read ${count(requested)} bytes; the limit is ${count(maximum)}. Read fewer or smaller rows per call, or page with paginate() across calls or workflow steps.`,
|
|
134
|
+
writes: (maximum, requested) => `This mutation made ${count(requested)} writes; the limit is ${count(maximum)}. Split large ingests into batches, one batch per mutation or workflow step.`,
|
|
135
|
+
valueBytes: (maximum, requested) => `A row encodes to ${count(requested)} bytes; each row may use at most ${count(maximum)}. Store large content outside the row or split it across rows.`
|
|
136
|
+
};
|
|
137
|
+
var DatabaseLimitExceeded = class extends Schema_exports.TaggedError()(
|
|
138
|
+
"DatabaseLimitExceeded",
|
|
139
|
+
{
|
|
140
|
+
limit: DatabaseLimit,
|
|
141
|
+
maximum: Schema_exports.Int,
|
|
142
|
+
requested: Schema_exports.Int
|
|
143
|
+
}
|
|
144
|
+
) {
|
|
145
|
+
get message() {
|
|
146
|
+
return limitMessages[this.limit](this.maximum, this.requested);
|
|
147
|
+
}
|
|
148
|
+
};
|
|
149
|
+
var reservedFieldNames = ["id", "createdAt", "updatedAt"];
|
|
150
|
+
var DatabaseFieldReserved = class extends Schema_exports.TaggedError()(
|
|
151
|
+
"DatabaseFieldReserved",
|
|
152
|
+
{
|
|
153
|
+
table: Schema_exports.String,
|
|
154
|
+
field: Schema_exports.Literals(reservedFieldNames)
|
|
155
|
+
}
|
|
156
|
+
) {
|
|
157
|
+
get message() {
|
|
158
|
+
return `Table "${this.table}" declares "${this.field}", which is reserved: the host adds id, createdAt and updatedAt to every row. Rename the field, or use the row's own ${this.field}.`;
|
|
159
|
+
}
|
|
160
|
+
};
|
|
116
161
|
var DatabaseRuntimeLimits = Schema_exports.Struct({
|
|
117
162
|
maxCursorChars: Schema_exports.Int.check(Schema_exports.isGreaterThan(0)),
|
|
118
163
|
connectionCacheCapacity: Schema_exports.Int.check(Schema_exports.isGreaterThan(0)),
|
|
@@ -134,5 +179,8 @@ export {
|
|
|
134
179
|
AppDatabaseError,
|
|
135
180
|
DatabaseLimits,
|
|
136
181
|
defaultDatabaseLimits,
|
|
182
|
+
DatabaseLimitExceeded,
|
|
183
|
+
reservedFieldNames,
|
|
184
|
+
DatabaseFieldReserved,
|
|
137
185
|
defaultDatabaseRuntimeLimits
|
|
138
186
|
};
|
|
@@ -3,14 +3,14 @@ import {
|
|
|
3
3
|
CacheEntry,
|
|
4
4
|
CacheError,
|
|
5
5
|
cacheLimits
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-R3EV5FTO.js";
|
|
7
7
|
import {
|
|
8
8
|
Clock_exports,
|
|
9
9
|
Duration_exports,
|
|
10
10
|
Effect_exports,
|
|
11
11
|
Exit_exports,
|
|
12
12
|
Schema_exports
|
|
13
|
-
} from "./chunk-
|
|
13
|
+
} from "./chunk-CDL5PM2Q.js";
|
|
14
14
|
|
|
15
15
|
// ../app-cache/src/index.ts
|
|
16
16
|
var canonical = (value) => {
|
|
@@ -0,0 +1,254 @@
|
|
|
1
|
+
import {
|
|
2
|
+
HostedTool,
|
|
3
|
+
RouterKey,
|
|
4
|
+
RouterMeta,
|
|
5
|
+
reservedRouterKeys
|
|
6
|
+
} from "./chunk-VXWY44LE.js";
|
|
7
|
+
import {
|
|
8
|
+
decoderOf
|
|
9
|
+
} from "./chunk-4QQ62BVS.js";
|
|
10
|
+
import {
|
|
11
|
+
Effect_exports,
|
|
12
|
+
Schema_exports
|
|
13
|
+
} from "./chunk-CDL5PM2Q.js";
|
|
14
|
+
|
|
15
|
+
// src/implementation/authoring.ts
|
|
16
|
+
var NativeCallback = /* @__PURE__ */ Symbol("apps.NativeCallback");
|
|
17
|
+
var fromPromise = (callback) => (...args) => {
|
|
18
|
+
if (NativeCallback in callback) {
|
|
19
|
+
const native = callback[NativeCallback];
|
|
20
|
+
return native(...args);
|
|
21
|
+
}
|
|
22
|
+
return Effect_exports.tryPromise({ try: () => callback(...args), catch: (error) => error });
|
|
23
|
+
};
|
|
24
|
+
var toPromise = (operation, signal) => {
|
|
25
|
+
const native = (...args) => Effect_exports.suspend(() => {
|
|
26
|
+
if (signal === void 0) return operation(...args);
|
|
27
|
+
if (signal.aborted) return Effect_exports.interrupt;
|
|
28
|
+
const cancelled = Effect_exports.callback((resume) => {
|
|
29
|
+
if (signal.aborted) {
|
|
30
|
+
resume(Effect_exports.interrupt);
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
const abort = () => resume(Effect_exports.interrupt);
|
|
34
|
+
signal.addEventListener("abort", abort, { once: true });
|
|
35
|
+
return Effect_exports.sync(() => signal.removeEventListener("abort", abort));
|
|
36
|
+
});
|
|
37
|
+
return Effect_exports.raceFirst(
|
|
38
|
+
cancelled,
|
|
39
|
+
Effect_exports.suspend(() => operation(...args))
|
|
40
|
+
);
|
|
41
|
+
});
|
|
42
|
+
return Object.assign((...args) => Effect_exports.runPromise(native(...args)), {
|
|
43
|
+
[NativeCallback]: native
|
|
44
|
+
});
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
// src/implementation/operations.ts
|
|
48
|
+
var NativeOperation = /* @__PURE__ */ Symbol("apps.Operation");
|
|
49
|
+
var NativeRouterKey = /* @__PURE__ */ Symbol("apps.Router");
|
|
50
|
+
var operationDeclaration = (operation) => ({
|
|
51
|
+
kind: operation.kind,
|
|
52
|
+
[NativeOperation]: operation
|
|
53
|
+
});
|
|
54
|
+
var nativeOperation = (value) => {
|
|
55
|
+
if (typeof value !== "object" || value === null || !(NativeOperation in value)) return void 0;
|
|
56
|
+
return value[NativeOperation];
|
|
57
|
+
};
|
|
58
|
+
var operationOptions = (options) => {
|
|
59
|
+
const approval = options.approval;
|
|
60
|
+
return {
|
|
61
|
+
...options.description === void 0 ? {} : { description: options.description },
|
|
62
|
+
...options.title === void 0 ? {} : { title: options.title },
|
|
63
|
+
...options.annotations === void 0 ? {} : { annotations: options.annotations },
|
|
64
|
+
...options._meta === void 0 ? {} : { _meta: options._meta },
|
|
65
|
+
input: decoderOf(options.input),
|
|
66
|
+
...approval === void 0 ? {} : {
|
|
67
|
+
approval: (context) => Effect_exports.tryPromise({ try: async () => approval(context), catch: (error) => error })
|
|
68
|
+
}
|
|
69
|
+
};
|
|
70
|
+
};
|
|
71
|
+
var approvedOperation = (operation, approval) => {
|
|
72
|
+
const copy = Object.defineProperties({}, Object.getOwnPropertyDescriptors(operation));
|
|
73
|
+
return Object.defineProperty(copy, "approval", {
|
|
74
|
+
enumerable: true,
|
|
75
|
+
value: (context) => Effect_exports.tryPromise({ try: async () => approval(context), catch: (error) => error })
|
|
76
|
+
});
|
|
77
|
+
};
|
|
78
|
+
var withApproval = (operation, approval) => ({
|
|
79
|
+
...operation,
|
|
80
|
+
[NativeOperation]: approvedOperation(operation[NativeOperation], approval)
|
|
81
|
+
});
|
|
82
|
+
var toolAnnotations = (operation) => nativeOperation(operation)?.annotations;
|
|
83
|
+
var make = (kind, options, run) => operationDeclaration({
|
|
84
|
+
...operationOptions(options),
|
|
85
|
+
kind,
|
|
86
|
+
// The host always validates JSON serialization, even without a stronger output declaration.
|
|
87
|
+
...options.output === void 0 ? {} : { output: decoderOf(options.output) },
|
|
88
|
+
run: (context, input) => Effect_exports.tryPromise({
|
|
89
|
+
// SAFETY: defineApp checks the handler context against its requirements.
|
|
90
|
+
// The host validates account bindings and creates the matching storage facade.
|
|
91
|
+
try: () => run(context, input),
|
|
92
|
+
catch: (error) => error
|
|
93
|
+
})
|
|
94
|
+
});
|
|
95
|
+
var query = (options, run) => make("query", options, run);
|
|
96
|
+
var mutation = (options, run) => make("mutation", options, run);
|
|
97
|
+
|
|
98
|
+
// src/implementation/router.ts
|
|
99
|
+
var routerDeclaration = (node) => ({
|
|
100
|
+
[NativeRouterKey]: node
|
|
101
|
+
});
|
|
102
|
+
var nativeRouter = (value) => {
|
|
103
|
+
if (typeof value !== "object" || value === null || !(NativeRouterKey in value)) return void 0;
|
|
104
|
+
return value[NativeRouterKey];
|
|
105
|
+
};
|
|
106
|
+
var nativeNode = (value) => nativeOperation(value) ?? nativeRouter(value);
|
|
107
|
+
var metaOf = (options) => {
|
|
108
|
+
if (options === void 0) return void 0;
|
|
109
|
+
const defined = Object.fromEntries(
|
|
110
|
+
Object.entries(options).filter(([, value]) => value !== void 0)
|
|
111
|
+
);
|
|
112
|
+
return Object.keys(defined).length === 0 ? void 0 : Schema_exports.decodeUnknownSync(RouterMeta)(defined);
|
|
113
|
+
};
|
|
114
|
+
var mergeMeta = (base, override) => base === void 0 ? override : override === void 0 ? base : { ...base, ...override };
|
|
115
|
+
function router(children, options) {
|
|
116
|
+
const meta = metaOf(options);
|
|
117
|
+
const existing = nativeRouter(children);
|
|
118
|
+
if (existing !== void 0)
|
|
119
|
+
return routerDeclaration(
|
|
120
|
+
existing.kind === "router" ? { ...existing, ...withMeta(mergeMeta(existing.meta, meta)) } : { ...existing, ...withOverrides(mergeMeta(existing.overrides, meta)) }
|
|
121
|
+
);
|
|
122
|
+
const nodes = {};
|
|
123
|
+
for (const [key, value] of Object.entries(children)) {
|
|
124
|
+
if (reservedRouterKeys.has(key)) throw new Error(`Router key "${key}" is reserved`);
|
|
125
|
+
if (!Schema_exports.is(RouterKey)(key))
|
|
126
|
+
throw new Error(`Router key "${key}" must start with a letter or _ and contain no dots`);
|
|
127
|
+
const node = nativeNode(value);
|
|
128
|
+
if (node === void 0)
|
|
129
|
+
throw new Error(`Router key "${key}" must be a query, mutation or router`);
|
|
130
|
+
nodes[key] = node;
|
|
131
|
+
}
|
|
132
|
+
return routerDeclaration({ kind: "router", ...withMeta(meta), children: nodes });
|
|
133
|
+
}
|
|
134
|
+
var withMeta = (meta) => meta === void 0 ? {} : { meta };
|
|
135
|
+
var withOverrides = (overrides) => overrides === void 0 ? {} : { overrides };
|
|
136
|
+
var dynamicRouter = (source) => {
|
|
137
|
+
const meta = source.meta;
|
|
138
|
+
return routerDeclaration({
|
|
139
|
+
kind: "dynamic",
|
|
140
|
+
...meta === void 0 ? {} : {
|
|
141
|
+
meta: () => fromPromise(async () => meta())().pipe(
|
|
142
|
+
Effect_exports.flatMap((options) => Schema_exports.decodeUnknownEffect(RouterMeta)(options))
|
|
143
|
+
)
|
|
144
|
+
},
|
|
145
|
+
list: () => fromPromise(async () => source.list())().pipe(
|
|
146
|
+
Effect_exports.flatMap(Schema_exports.decodeUnknownEffect(Schema_exports.Array(HostedTool)))
|
|
147
|
+
),
|
|
148
|
+
resolve: (name) => fromPromise(async () => source.resolve(name))().pipe(
|
|
149
|
+
Effect_exports.map((value) => {
|
|
150
|
+
if (value === void 0) return void 0;
|
|
151
|
+
const operation = nativeOperation(value);
|
|
152
|
+
if (operation === void 0) throw new Error("Expected an operation declaration");
|
|
153
|
+
return operation;
|
|
154
|
+
})
|
|
155
|
+
)
|
|
156
|
+
});
|
|
157
|
+
};
|
|
158
|
+
var joinPath = (path, name) => path === "" ? name : `${path}.${name}`;
|
|
159
|
+
var locate = (root, name) => {
|
|
160
|
+
if (root?.kind === "dynamic") return { kind: "dynamic", source: root, router: "", name };
|
|
161
|
+
let current = root;
|
|
162
|
+
let path = "";
|
|
163
|
+
let rest = name;
|
|
164
|
+
while (current !== void 0) {
|
|
165
|
+
const dot = rest.indexOf(".");
|
|
166
|
+
const key = dot < 0 ? rest : rest.slice(0, dot);
|
|
167
|
+
const child = Object.hasOwn(current.children, key) ? current.children[key] : void 0;
|
|
168
|
+
if (child === void 0) return void 0;
|
|
169
|
+
const remaining = dot < 0 ? void 0 : rest.slice(dot + 1);
|
|
170
|
+
switch (child.kind) {
|
|
171
|
+
case "query":
|
|
172
|
+
case "mutation":
|
|
173
|
+
return remaining === void 0 ? { kind: "operation", operation: child, router: path } : void 0;
|
|
174
|
+
case "dynamic":
|
|
175
|
+
return remaining === void 0 || remaining === "" ? void 0 : { kind: "dynamic", source: child, router: joinPath(path, key), name: remaining };
|
|
176
|
+
case "router":
|
|
177
|
+
if (remaining === void 0) return void 0;
|
|
178
|
+
current = child;
|
|
179
|
+
path = joinPath(path, key);
|
|
180
|
+
rest = remaining;
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
return void 0;
|
|
184
|
+
};
|
|
185
|
+
var declaredOperations = (root, path = "") => Object.entries(root?.children ?? {}).flatMap(([key, child]) => {
|
|
186
|
+
const name = joinPath(path, key);
|
|
187
|
+
switch (child.kind) {
|
|
188
|
+
case "query":
|
|
189
|
+
case "mutation":
|
|
190
|
+
return [{ name, router: path, operation: child }];
|
|
191
|
+
case "router":
|
|
192
|
+
return declaredOperations(child, name);
|
|
193
|
+
case "dynamic":
|
|
194
|
+
return [];
|
|
195
|
+
}
|
|
196
|
+
});
|
|
197
|
+
var withApprovals = (source, policy) => {
|
|
198
|
+
const native = nativeRouter(source);
|
|
199
|
+
if (native === void 0) throw new Error("withApprovals expects a router");
|
|
200
|
+
const operation = (node, name) => {
|
|
201
|
+
const approval = policy(operationDeclaration(node), name);
|
|
202
|
+
return approval === void 0 ? node : approvedOperation(node, approval);
|
|
203
|
+
};
|
|
204
|
+
const child = (node, name) => {
|
|
205
|
+
switch (node.kind) {
|
|
206
|
+
case "query":
|
|
207
|
+
case "mutation":
|
|
208
|
+
return operation(node, name);
|
|
209
|
+
case "router":
|
|
210
|
+
case "dynamic":
|
|
211
|
+
return walk(node, name);
|
|
212
|
+
}
|
|
213
|
+
};
|
|
214
|
+
const walk = (node, path) => node.kind === "dynamic" ? {
|
|
215
|
+
...node,
|
|
216
|
+
resolve: (name) => node.resolve(name).pipe(
|
|
217
|
+
Effect_exports.flatMap(
|
|
218
|
+
(resolved) => resolved === void 0 ? Effect_exports.succeed(void 0) : Effect_exports.try({
|
|
219
|
+
try: () => operation(resolved, joinPath(path, name)),
|
|
220
|
+
catch: (error) => error
|
|
221
|
+
})
|
|
222
|
+
)
|
|
223
|
+
)
|
|
224
|
+
} : {
|
|
225
|
+
...node,
|
|
226
|
+
children: Object.fromEntries(
|
|
227
|
+
Object.entries(node.children).map(([key, value]) => [
|
|
228
|
+
key,
|
|
229
|
+
child(value, joinPath(path, key))
|
|
230
|
+
])
|
|
231
|
+
)
|
|
232
|
+
};
|
|
233
|
+
return routerDeclaration(walk(native, ""));
|
|
234
|
+
};
|
|
235
|
+
|
|
236
|
+
export {
|
|
237
|
+
fromPromise,
|
|
238
|
+
toPromise,
|
|
239
|
+
operationDeclaration,
|
|
240
|
+
nativeOperation,
|
|
241
|
+
withApproval,
|
|
242
|
+
toolAnnotations,
|
|
243
|
+
query,
|
|
244
|
+
mutation,
|
|
245
|
+
routerDeclaration,
|
|
246
|
+
nativeRouter,
|
|
247
|
+
mergeMeta,
|
|
248
|
+
router,
|
|
249
|
+
dynamicRouter,
|
|
250
|
+
joinPath,
|
|
251
|
+
locate,
|
|
252
|
+
declaredOperations,
|
|
253
|
+
withApprovals
|
|
254
|
+
};
|