apps 0.0.1-beta.4 → 0.0.1-beta.40
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-QKHR7BMF.js → chunk-3MMG2H6M.js} +89 -53
- package/js/chunk-4TLZGG4B.js +729 -0
- package/js/chunk-6KABJTDO.js +255 -0
- package/js/{chunk-FDNTX5QJ.js → chunk-CQD3WSYH.js} +2 -2
- package/js/{chunk-EQB7JMAL.js → chunk-DHX2OI2X.js} +146 -31
- package/js/{chunk-EVJUVWN2.js → chunk-DKUEYTYD.js} +463 -218
- package/js/chunk-EM4UL26F.js +118 -0
- package/js/{chunk-WFSQXYUT.js → chunk-GHXRRFZA.js} +418 -52
- package/js/{chunk-5MQZEB6Y.js → chunk-KANDIVIH.js} +40 -12
- package/js/chunk-KAQD3DTI.js +16 -0
- package/js/chunk-KIM5HXNK.js +49 -0
- package/js/{chunk-FW5HBOIK.js → chunk-MXDKXAY4.js} +19117 -18309
- package/js/{chunk-2VPJHFOU.js → chunk-MYF7KWUB.js} +128 -24
- package/js/{chunk-T2LAZCAD.js → chunk-NKWWPJYX.js} +3 -3
- package/js/chunk-OD3KFKZD.js +1617 -0
- package/js/{chunk-3M2MEDNL.js → chunk-OTCLXFLL.js} +1337 -188
- package/js/chunk-P7MGDPFD.js +240 -0
- package/js/chunk-PDS2E2OZ.js +42 -0
- package/js/{chunk-ZCAMUXSG.js → chunk-PNVCCB4L.js} +432 -79
- package/js/{chunk-D47C7KG5.js → chunk-RIXVGVA6.js} +2 -2
- package/js/{chunk-6VRYO2BG.js → chunk-SALJXSS3.js} +779 -251
- package/js/{chunk-NQ3OMCA5.js → chunk-TT6OU4UG.js} +2 -2
- package/js/{chunk-YEJOQEII.js → chunk-UOZMSUJ2.js} +61 -9
- package/js/{chunk-G7ZIRKMK.js → chunk-VIU2XXA7.js} +228 -264
- package/js/{chunk-HDJH3RPR.js → chunk-VJQXXOQ3.js} +4 -4
- package/js/chunk-XDGUGB2A.js +156 -0
- package/js/{chunk-SATWJKN6.js → chunk-YQ35E7KS.js} +2 -2
- package/js/chunk-ZUKBIHMK.js +92 -0
- package/js/client.js +122 -88
- package/js/contracts.js +116 -25
- package/js/effect.js +19 -20
- package/js/{es-APDZKREY.js → es-DIULA3ZF.js} +62 -1659
- package/js/graphql.js +57 -55
- package/js/host.js +19 -20
- package/js/index.js +245 -212
- package/js/mcp/effect.js +23 -22
- package/js/mcp/stdio.js +34 -30
- package/js/mcp.js +104 -68
- package/js/openapi.js +4087 -1503
- package/js/react.js +2 -3
- package/js/skills/effect.js +6 -3
- package/js/skills.js +147 -65
- package/js/storage/facet.js +1 -540
- package/js/ui/auth/contracts.js +2 -2
- package/js/ui/auth.js +5 -5
- package/js/ui/contracts.js +5 -4
- package/js/ui/serving.js +8517 -214
- package/package.json +2 -3
- package/runtime.json +1 -1
- package/types/app-data/src/contracts/database.d.ts +33 -6
- package/types/apps/src/contracts/api-response-error.d.ts +4 -0
- package/types/apps/src/contracts/app.d.ts +7 -8
- package/types/apps/src/contracts/cache.d.ts +14 -0
- package/types/apps/src/contracts/context.d.ts +12 -11
- package/types/apps/src/contracts/elicitation.d.ts +6 -6
- package/types/apps/src/contracts/failure.d.ts +54 -0
- package/types/apps/src/contracts/graphql.d.ts +2 -1
- package/types/apps/src/contracts/host.d.ts +44 -17
- package/types/apps/src/contracts/live.d.ts +2 -0
- package/types/apps/src/contracts/mcp.d.ts +96 -10
- package/types/apps/src/contracts/network.d.ts +84 -0
- package/types/apps/src/contracts/openapi-compile.d.ts +32 -3
- package/types/apps/src/contracts/openapi.d.ts +45 -9
- package/types/apps/src/contracts/operations.d.ts +8 -9
- package/types/apps/src/contracts/protocol-version.d.ts +2 -2
- package/types/apps/src/contracts/protocols/1.d.ts +263 -74
- package/types/apps/src/contracts/protocols/10.d.ts +1450 -0
- package/types/apps/src/contracts/protocols/2.d.ts +66 -24
- package/types/apps/src/contracts/protocols/3.d.ts +715 -0
- package/types/apps/src/contracts/protocols/4.d.ts +1297 -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/8.d.ts +1130 -0
- package/types/apps/src/contracts/protocols/9.d.ts +1106 -0
- package/types/apps/src/contracts/protocols/oauth.d.ts +89 -0
- package/types/apps/src/contracts/provider-error.d.ts +9 -0
- package/types/apps/src/contracts/provider.d.ts +115 -10
- package/types/apps/src/contracts/router.d.ts +59 -0
- package/types/apps/src/contracts/skills.d.ts +39 -9
- package/types/apps/src/contracts/sql.d.ts +58 -0
- package/types/apps/src/contracts/ui.d.ts +19 -1
- package/types/apps/src/contracts/workflows.d.ts +40 -3
- package/types/apps/src/facet.d.ts +4 -5
- 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 +32 -5
- package/types/apps/src/implementation/elicitation.d.ts +9 -9
- package/types/apps/src/implementation/failure-detail.d.ts +47 -0
- package/types/apps/src/implementation/graphql-catalog.d.ts +4 -7
- package/types/apps/src/implementation/graphql.d.ts +4 -3
- package/types/apps/src/implementation/input-problems.d.ts +4 -1
- package/types/apps/src/implementation/live.d.ts +2 -2
- package/types/apps/src/implementation/mcp-call.d.ts +6 -5
- package/types/apps/src/implementation/mcp-catalog.d.ts +7 -8
- package/types/apps/src/implementation/mcp-client.d.ts +49 -25
- package/types/apps/src/implementation/mcp-stdio.d.ts +1 -1
- package/types/apps/src/implementation/mcp-tools.d.ts +2 -1
- package/types/apps/src/implementation/mcp.d.ts +52 -25
- package/types/apps/src/implementation/network.d.ts +16 -0
- package/types/apps/src/implementation/openapi-compile.d.ts +27 -6
- package/types/apps/src/implementation/openapi-document.d.ts +46 -19
- package/types/apps/src/implementation/openapi-names.d.ts +9 -4
- package/types/apps/src/implementation/openapi-request.d.ts +10 -2
- package/types/apps/src/implementation/openapi-source.d.ts +8 -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/optimistic.d.ts +1 -1
- package/types/apps/src/implementation/protocol-operations.d.ts +6 -4
- package/types/apps/src/implementation/provider-error.d.ts +28 -1
- package/types/apps/src/implementation/provider.d.ts +19 -5
- package/types/apps/src/implementation/query-commit.d.ts +1 -1
- package/types/apps/src/implementation/router-catalog.d.ts +223 -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 +86 -11
- package/types/apps/src/implementation/skills.d.ts +18 -24
- package/types/apps/src/implementation/sql.d.ts +66 -0
- package/types/apps/src/implementation/ui-account-notice.d.ts +9 -0
- package/types/apps/src/implementation/ui-auth.d.ts +1 -1
- package/types/apps/src/implementation/ui-client.d.ts +2 -2
- package/types/apps/src/implementation/ui-document.d.ts +5 -0
- package/types/apps/src/implementation/ui-errors.d.ts +1 -1
- package/types/apps/src/implementation/ui-serving.d.ts +11 -5
- package/types/apps/src/implementation/ui-watch.d.ts +1 -1
- package/types/apps/src/implementation/upstream-error.d.ts +7 -0
- 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 +30 -13
- package/types/apps/src/mcp-stdio.d.ts +2 -5
- package/types/apps/src/mcp.d.ts +25 -5
- package/types/apps/src/openapi.d.ts +6 -6
- package/types/apps/src/react.d.ts +1 -1
- package/types/apps/src/skills.d.ts +10 -8
- package/types/telemetry/src/app-records.d.ts +42 -0
- package/types/telemetry/src/browser-operations.d.ts +6 -3
- package/types/telemetry/src/browser.d.ts +2 -2
- package/types/telemetry/src/config.d.ts +2 -2
- package/types/telemetry/src/layer.d.ts +2 -2
- package/types/telemetry/src/recorded-failure.d.ts +20 -0
- package/types/telemetry/src/relay.d.ts +2 -2
- package/types/telemetry/src/transport.d.ts +8 -1
- package/types/utils/src/api-error.d.ts +53 -0
- package/types/utils/src/recorded-message.d.ts +15 -0
- package/js/chunk-BMOIAIVR.js +0 -138
- package/js/chunk-DHUDODG5.js +0 -213
- package/js/chunk-FZJOYIZO.js +0 -19
- package/js/chunk-LGIYBDWA.js +0 -85
- package/js/chunk-M6ZRRIBI.js +0 -877
- package/js/chunk-PLCMJREA.js +0 -590
- package/js/chunk-PYUYJRSK.js +0 -93
- package/js/chunk-SWPD52J7.js +0 -35
- package/js/chunk-W7D7WVSY.js +0 -18
- package/js/chunk-Z5NMEGJN.js +0 -29
- package/js/chunk-ZJWDMTE3.js +0 -63
- package/types/app-data/src/implementation/cursor.d.ts +0 -10
- package/types/app-data/src/implementation/index-key.d.ts +0 -7
- package/types/app-data/src/implementation/promise.d.ts +0 -68
- package/types/app-data/src/implementation/range.d.ts +0 -8
- package/types/app-data/src/implementation/schema.d.ts +0 -33
- package/types/app-data/src/implementation/sqlite.d.ts +0 -11
- package/types/app-data/src/index.d.ts +0 -4
- package/types/apps/src/contracts/dynamic-tools.d.ts +0 -13
- package/types/apps/src/contracts/storage.d.ts +0 -68
- package/types/apps/src/implementation/account-operations.d.ts +0 -151
- package/types/apps/src/implementation/dynamic-tools.d.ts +0 -8
- package/types/apps/src/implementation/storage.d.ts +0 -13
|
@@ -4,7 +4,7 @@ import {
|
|
|
4
4
|
fromWeb,
|
|
5
5
|
layerMergedContext,
|
|
6
6
|
make2 as make
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-3MMG2H6M.js";
|
|
8
8
|
import {
|
|
9
9
|
Reference,
|
|
10
10
|
Service,
|
|
@@ -13,16 +13,16 @@ import {
|
|
|
13
13
|
getOrUndefined2 as getOrUndefined,
|
|
14
14
|
map3 as map,
|
|
15
15
|
merge3 as merge,
|
|
16
|
-
|
|
16
|
+
remove2 as remove,
|
|
17
17
|
succeed4 as succeed,
|
|
18
18
|
toReadableStreamEffect,
|
|
19
19
|
tryPromise
|
|
20
|
-
} from "./chunk-
|
|
20
|
+
} from "./chunk-MXDKXAY4.js";
|
|
21
21
|
import {
|
|
22
22
|
__export
|
|
23
23
|
} from "./chunk-CZ7CSFO4.js";
|
|
24
24
|
|
|
25
|
-
// ../../node_modules/.bun/effect@
|
|
25
|
+
// ../../node_modules/.bun/effect@4.0.1/node_modules/effect/dist/http/FetchHttpClient.js
|
|
26
26
|
var FetchHttpClient_exports = {};
|
|
27
27
|
__export(FetchHttpClient_exports, {
|
|
28
28
|
Fetch: () => Fetch,
|
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
import {
|
|
2
|
+
declaredOperations,
|
|
3
|
+
fromPromise,
|
|
4
|
+
nativeOperation,
|
|
5
|
+
nativeRouter
|
|
6
|
+
} from "./chunk-6KABJTDO.js";
|
|
7
|
+
import {
|
|
8
|
+
ScheduleTiming
|
|
9
|
+
} from "./chunk-OTCLXFLL.js";
|
|
10
|
+
import {
|
|
11
|
+
decoderOf,
|
|
12
|
+
isSchema,
|
|
13
|
+
schemaArgument
|
|
14
|
+
} from "./chunk-GHXRRFZA.js";
|
|
15
|
+
import {
|
|
16
|
+
JsonValue
|
|
17
|
+
} from "./chunk-YQ35E7KS.js";
|
|
18
|
+
import {
|
|
19
|
+
Effect_exports,
|
|
20
|
+
Schema_exports
|
|
21
|
+
} from "./chunk-MXDKXAY4.js";
|
|
22
|
+
|
|
23
|
+
// src/contracts/http.ts
|
|
24
|
+
var ResponseStatusError = class extends Schema_exports.TaggedError()(
|
|
25
|
+
"ResponseStatusError",
|
|
26
|
+
{ status: Schema_exports.Number }
|
|
27
|
+
) {
|
|
28
|
+
get message() {
|
|
29
|
+
return `Request failed with status ${this.status}`;
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
var ResponseDecodeError = class extends Schema_exports.TaggedError()(
|
|
33
|
+
"ResponseDecodeError",
|
|
34
|
+
{}
|
|
35
|
+
) {
|
|
36
|
+
get message() {
|
|
37
|
+
return "Response body did not match the expected schema";
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
// src/implementation/workflows.ts
|
|
42
|
+
var NativeWorkflow = /* @__PURE__ */ Symbol("apps.Workflow");
|
|
43
|
+
var workflow = (options, run) => ({
|
|
44
|
+
[NativeWorkflow]: {
|
|
45
|
+
input: decoderOf(schemaArgument(options.input, "The workflow input")),
|
|
46
|
+
...options.output === void 0 ? {} : { output: decoderOf(schemaArgument(options.output, "The workflow output")) },
|
|
47
|
+
...options.description === void 0 ? {} : { description: options.description },
|
|
48
|
+
run: (context, input) => Effect_exports.tryPromise({
|
|
49
|
+
// SAFETY: defineApp checks required context; the host supplies the pinned run's capabilities.
|
|
50
|
+
try: () => run(context, input),
|
|
51
|
+
catch: (error) => error
|
|
52
|
+
})
|
|
53
|
+
}
|
|
54
|
+
});
|
|
55
|
+
var nativeWorkflow = (value) => {
|
|
56
|
+
if (typeof value !== "object" || value === null || !(NativeWorkflow in value)) return void 0;
|
|
57
|
+
return value[NativeWorkflow];
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
// src/implementation/app.ts
|
|
61
|
+
var InternalApp = /* @__PURE__ */ Symbol("apps.App");
|
|
62
|
+
var isApp = (value) => typeof value === "object" && value !== null && InternalApp in value;
|
|
63
|
+
var toEffectApp = (app) => app[InternalApp];
|
|
64
|
+
function rejectCatalogs(definition) {
|
|
65
|
+
if ("queries" in definition || "mutations" in definition)
|
|
66
|
+
throw new Error("Put queries and mutations in a router under tools");
|
|
67
|
+
}
|
|
68
|
+
function adaptDefinition(definition) {
|
|
69
|
+
rejectCatalogs(definition);
|
|
70
|
+
const webhooks = definition.webhooks === void 0 ? {} : {
|
|
71
|
+
webhooks: Object.fromEntries(
|
|
72
|
+
Object.entries(definition.webhooks).map(([name, webhook]) => [
|
|
73
|
+
name,
|
|
74
|
+
{
|
|
75
|
+
...webhook,
|
|
76
|
+
...webhook.register === void 0 ? {} : { register: fromPromise(webhook.register) },
|
|
77
|
+
handle: fromPromise(webhook.handle),
|
|
78
|
+
...webhook.unregister === void 0 ? {} : { unregister: fromPromise(webhook.unregister) },
|
|
79
|
+
..."config" in webhook && isSchema(webhook.config) ? { config: decoderOf(webhook.config) } : {},
|
|
80
|
+
..."state" in webhook && isSchema(webhook.state) ? { state: decoderOf(webhook.state) } : {}
|
|
81
|
+
}
|
|
82
|
+
])
|
|
83
|
+
)
|
|
84
|
+
};
|
|
85
|
+
const workflows = definition.workflows === void 0 ? {} : {
|
|
86
|
+
workflows: Object.fromEntries(
|
|
87
|
+
Object.entries(definition.workflows).map(([name, value]) => {
|
|
88
|
+
const declared2 = nativeWorkflow(value);
|
|
89
|
+
if (declared2 === void 0) throw new Error("Invalid workflow declaration");
|
|
90
|
+
return [name, declared2];
|
|
91
|
+
})
|
|
92
|
+
)
|
|
93
|
+
};
|
|
94
|
+
const root = definition.tools === void 0 ? void 0 : nativeRouter(definition.tools);
|
|
95
|
+
if (definition.tools !== void 0 && root === void 0)
|
|
96
|
+
throw new Error("tools must be a router");
|
|
97
|
+
const data = root === void 0 ? {} : { tools: root };
|
|
98
|
+
const declared = root?.kind === "router" ? declaredOperations(root) : [];
|
|
99
|
+
const mutations = /* @__PURE__ */ new Set();
|
|
100
|
+
for (const { operation } of declared) {
|
|
101
|
+
if (operation.kind !== "mutation") continue;
|
|
102
|
+
if (mutations.has(operation))
|
|
103
|
+
throw new Error("A mutation can be mounted at only one path in tools");
|
|
104
|
+
mutations.add(operation);
|
|
105
|
+
}
|
|
106
|
+
const schedules = definition.schedules === void 0 ? {} : {
|
|
107
|
+
schedules: Object.fromEntries(
|
|
108
|
+
Object.entries(definition.schedules).map(([name, schedule]) => {
|
|
109
|
+
const target = nativeOperation(schedule.operation);
|
|
110
|
+
const match = declared.find(
|
|
111
|
+
({ operation }) => operation === target && operation.kind === "mutation"
|
|
112
|
+
);
|
|
113
|
+
if (match === void 0)
|
|
114
|
+
throw new Error("A schedule must reference a mutation in this app's tools");
|
|
115
|
+
return [
|
|
116
|
+
name,
|
|
117
|
+
{
|
|
118
|
+
timing: Schema_exports.decodeUnknownSync(ScheduleTiming)(schedule.timing),
|
|
119
|
+
input: Schema_exports.decodeUnknownSync(JsonValue)(schedule.input),
|
|
120
|
+
tool: match.name
|
|
121
|
+
}
|
|
122
|
+
];
|
|
123
|
+
})
|
|
124
|
+
)
|
|
125
|
+
};
|
|
126
|
+
return {
|
|
127
|
+
...definition,
|
|
128
|
+
...webhooks,
|
|
129
|
+
...workflows,
|
|
130
|
+
...data,
|
|
131
|
+
...schedules
|
|
132
|
+
};
|
|
133
|
+
}
|
|
134
|
+
var defineApp = (requirements, definition) => {
|
|
135
|
+
if (typeof definition !== "function") rejectCatalogs(definition);
|
|
136
|
+
const evaluate = typeof definition === "function" ? definition : async () => definition;
|
|
137
|
+
const factory = fromPromise(evaluate);
|
|
138
|
+
const native = {
|
|
139
|
+
accounts: requirements.accounts,
|
|
140
|
+
evaluate: (context) => factory(context).pipe(Effect_exports.map((value) => adaptDefinition(value)))
|
|
141
|
+
};
|
|
142
|
+
return {
|
|
143
|
+
[InternalApp]: native,
|
|
144
|
+
accounts: native.accounts,
|
|
145
|
+
evaluate: (context) => Effect_exports.runPromise(factory(context))
|
|
146
|
+
};
|
|
147
|
+
};
|
|
148
|
+
|
|
149
|
+
export {
|
|
150
|
+
ResponseStatusError,
|
|
151
|
+
ResponseDecodeError,
|
|
152
|
+
workflow,
|
|
153
|
+
isApp,
|
|
154
|
+
toEffectApp,
|
|
155
|
+
defineApp
|
|
156
|
+
};
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import {
|
|
2
2
|
Schema_exports
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-MXDKXAY4.js";
|
|
4
4
|
|
|
5
5
|
// src/contracts/schema.ts
|
|
6
6
|
var JsonValue = Schema_exports.Json;
|
|
7
7
|
var JsonObject = Schema_exports.Record(Schema_exports.String, JsonValue);
|
|
8
8
|
var AccountId = Schema_exports.String.pipe(
|
|
9
|
-
Schema_exports.check(Schema_exports.
|
|
9
|
+
Schema_exports.check(Schema_exports.isStartingWith("acc_"), Schema_exports.isMinLength(5)),
|
|
10
10
|
Schema_exports.brand("acc")
|
|
11
11
|
);
|
|
12
12
|
var HttpUrl = Schema_exports.String.check(
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import {
|
|
2
|
+
JsonValue
|
|
3
|
+
} from "./chunk-YQ35E7KS.js";
|
|
4
|
+
import {
|
|
5
|
+
HttpApiEndpoint_exports,
|
|
6
|
+
HttpApiGroup_exports,
|
|
7
|
+
HttpApiSchema_exports,
|
|
8
|
+
HttpApi_exports
|
|
9
|
+
} from "./chunk-VIU2XXA7.js";
|
|
10
|
+
import {
|
|
11
|
+
Schema_exports
|
|
12
|
+
} from "./chunk-MXDKXAY4.js";
|
|
13
|
+
|
|
14
|
+
// src/contracts/ui.ts
|
|
15
|
+
var UiContext = Schema_exports.Struct({
|
|
16
|
+
deployment: Schema_exports.NonEmptyString,
|
|
17
|
+
profile: Schema_exports.optional(Schema_exports.NonEmptyString),
|
|
18
|
+
expectedProfileRevision: Schema_exports.optional(Schema_exports.Int)
|
|
19
|
+
});
|
|
20
|
+
var UiOperation = Schema_exports.Struct({
|
|
21
|
+
...UiContext.fields,
|
|
22
|
+
name: Schema_exports.NonEmptyString,
|
|
23
|
+
input: JsonValue
|
|
24
|
+
});
|
|
25
|
+
var UiUnauthorized = class extends Schema_exports.TaggedError()(
|
|
26
|
+
"UiUnauthorized",
|
|
27
|
+
{},
|
|
28
|
+
{ httpApiStatus: 401 }
|
|
29
|
+
) {
|
|
30
|
+
};
|
|
31
|
+
var UiForbidden = class extends Schema_exports.TaggedError()(
|
|
32
|
+
"UiForbidden",
|
|
33
|
+
{},
|
|
34
|
+
{ httpApiStatus: 403 }
|
|
35
|
+
) {
|
|
36
|
+
};
|
|
37
|
+
var UiDeploymentChanged = class extends Schema_exports.TaggedError()(
|
|
38
|
+
"UiDeploymentChanged",
|
|
39
|
+
{},
|
|
40
|
+
{ httpApiStatus: 409 }
|
|
41
|
+
) {
|
|
42
|
+
};
|
|
43
|
+
var UiFailed = class extends Schema_exports.TaggedError()(
|
|
44
|
+
"UiFailed",
|
|
45
|
+
{
|
|
46
|
+
reason: Schema_exports.Literals(["unavailable", "operation_failed", "account_required"])
|
|
47
|
+
},
|
|
48
|
+
{ httpApiStatus: 422 }
|
|
49
|
+
) {
|
|
50
|
+
};
|
|
51
|
+
var UiSnapshot = Schema_exports.Union([
|
|
52
|
+
Schema_exports.Struct({
|
|
53
|
+
type: Schema_exports.Literal("snapshot"),
|
|
54
|
+
value: JsonValue,
|
|
55
|
+
trace: Schema_exports.optional(Schema_exports.Unknown)
|
|
56
|
+
}),
|
|
57
|
+
Schema_exports.Struct({ type: Schema_exports.Literal("failure"), error: UiFailed }),
|
|
58
|
+
Schema_exports.Struct({ type: Schema_exports.Literal("heartbeat") })
|
|
59
|
+
]);
|
|
60
|
+
var errors = [UiUnauthorized, UiForbidden, UiDeploymentChanged, UiFailed];
|
|
61
|
+
var AppUiApi = HttpApi_exports.make("app-ui").add(
|
|
62
|
+
HttpApiGroup_exports.make("ui").add(
|
|
63
|
+
HttpApiEndpoint_exports.post("query", "/_executor/api/query", {
|
|
64
|
+
payload: UiOperation,
|
|
65
|
+
success: JsonValue,
|
|
66
|
+
error: errors
|
|
67
|
+
})
|
|
68
|
+
).add(
|
|
69
|
+
HttpApiEndpoint_exports.post("mutate", "/_executor/api/mutate", {
|
|
70
|
+
payload: UiOperation,
|
|
71
|
+
success: JsonValue,
|
|
72
|
+
error: errors
|
|
73
|
+
})
|
|
74
|
+
).add(
|
|
75
|
+
HttpApiEndpoint_exports.post("subscribe", "/_executor/api/subscribe", {
|
|
76
|
+
payload: UiOperation,
|
|
77
|
+
success: HttpApiSchema_exports.StreamSse({ data: UiSnapshot, error: Schema_exports.Union(errors) }),
|
|
78
|
+
error: errors
|
|
79
|
+
})
|
|
80
|
+
)
|
|
81
|
+
);
|
|
82
|
+
|
|
83
|
+
export {
|
|
84
|
+
UiContext,
|
|
85
|
+
UiOperation,
|
|
86
|
+
UiUnauthorized,
|
|
87
|
+
UiForbidden,
|
|
88
|
+
UiDeploymentChanged,
|
|
89
|
+
UiFailed,
|
|
90
|
+
UiSnapshot,
|
|
91
|
+
AppUiApi
|
|
92
|
+
};
|
package/js/client.js
CHANGED
|
@@ -1,40 +1,38 @@
|
|
|
1
1
|
import {
|
|
2
2
|
AppUiApi,
|
|
3
|
-
HttpApiClient_exports,
|
|
4
3
|
UiContext,
|
|
5
4
|
UiDeploymentChanged,
|
|
6
5
|
UiFailed
|
|
7
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-ZUKBIHMK.js";
|
|
8
7
|
import {
|
|
9
8
|
AsyncResult_exports,
|
|
10
9
|
AtomRegistry_exports,
|
|
11
10
|
Atom_exports,
|
|
12
11
|
queryResult
|
|
13
|
-
} from "./chunk-
|
|
14
|
-
import "./chunk-M6ZRRIBI.js";
|
|
12
|
+
} from "./chunk-DKUEYTYD.js";
|
|
15
13
|
import {
|
|
16
14
|
OtlpExporter_exports,
|
|
17
|
-
TraceContext,
|
|
18
15
|
externalTrace,
|
|
19
16
|
pendingSpan,
|
|
20
17
|
telemetryLayer,
|
|
21
18
|
traceLinks
|
|
22
|
-
} from "./chunk-
|
|
19
|
+
} from "./chunk-PNVCCB4L.js";
|
|
23
20
|
import {
|
|
24
21
|
FetchHttpClient_exports
|
|
25
|
-
} from "./chunk-
|
|
26
|
-
import {
|
|
27
|
-
HttpClientError_exports
|
|
28
|
-
} from "./chunk-QKHR7BMF.js";
|
|
22
|
+
} from "./chunk-VJQXXOQ3.js";
|
|
29
23
|
import {
|
|
30
24
|
decoderOf
|
|
31
|
-
} from "./chunk-
|
|
32
|
-
import
|
|
33
|
-
StorageName
|
|
34
|
-
} from "./chunk-FZJOYIZO.js";
|
|
25
|
+
} from "./chunk-GHXRRFZA.js";
|
|
26
|
+
import "./chunk-KAQD3DTI.js";
|
|
35
27
|
import {
|
|
36
28
|
JsonValue
|
|
37
|
-
} from "./chunk-
|
|
29
|
+
} from "./chunk-YQ35E7KS.js";
|
|
30
|
+
import {
|
|
31
|
+
HttpApiClient_exports
|
|
32
|
+
} from "./chunk-VIU2XXA7.js";
|
|
33
|
+
import {
|
|
34
|
+
HttpClientError_exports
|
|
35
|
+
} from "./chunk-3MMG2H6M.js";
|
|
38
36
|
import {
|
|
39
37
|
Cause_exports,
|
|
40
38
|
Clock_exports,
|
|
@@ -47,25 +45,27 @@ import {
|
|
|
47
45
|
Logger_exports,
|
|
48
46
|
ManagedRuntime_exports,
|
|
49
47
|
Option_exports,
|
|
48
|
+
Queue_exports,
|
|
50
49
|
Schedule_exports,
|
|
51
50
|
Schema_exports,
|
|
52
51
|
Semaphore_exports,
|
|
53
52
|
Stream_exports,
|
|
54
53
|
Tracer_exports
|
|
55
|
-
} from "./chunk-
|
|
54
|
+
} from "./chunk-MXDKXAY4.js";
|
|
56
55
|
import "./chunk-CZ7CSFO4.js";
|
|
57
56
|
|
|
58
57
|
// src/contracts/live.ts
|
|
58
|
+
var OperationName = Schema_exports.NonEmptyString.check(Schema_exports.isMaxLength(200));
|
|
59
59
|
var AppQueryFailed = class extends Schema_exports.TaggedError()("AppQueryFailed", {}) {
|
|
60
60
|
};
|
|
61
61
|
|
|
62
62
|
// src/implementation/live.ts
|
|
63
63
|
var queryReference = (name) => ({
|
|
64
|
-
name: Schema_exports.decodeUnknownSync(
|
|
64
|
+
name: Schema_exports.decodeUnknownSync(OperationName)(name),
|
|
65
65
|
kind: "query"
|
|
66
66
|
});
|
|
67
67
|
var mutationReference = (name) => ({
|
|
68
|
-
name: Schema_exports.decodeUnknownSync(
|
|
68
|
+
name: Schema_exports.decodeUnknownSync(OperationName)(name),
|
|
69
69
|
kind: "mutation"
|
|
70
70
|
});
|
|
71
71
|
var liveQueryAtom = (reference, input, options) => Atom_exports.make(
|
|
@@ -448,21 +448,6 @@ var observeBrowserPerformance = Effect_exports.gen(function* () {
|
|
|
448
448
|
};
|
|
449
449
|
});
|
|
450
450
|
|
|
451
|
-
// ../telemetry/src/browser-operations.ts
|
|
452
|
-
var BrowserOperationFailure = Schema_exports.Struct({
|
|
453
|
-
error_type: Schema_exports.Literals([
|
|
454
|
-
"BrowserDecodeFailed",
|
|
455
|
-
"BrowserTransportFailed",
|
|
456
|
-
"BrowserOperationFailed"
|
|
457
|
-
]),
|
|
458
|
-
trace_id: TraceContext.fields.traceId,
|
|
459
|
-
span_id: TraceContext.fields.spanId,
|
|
460
|
-
page_id: Schema_exports.String
|
|
461
|
-
});
|
|
462
|
-
var ResponseTrace = Context_exports.Reference("telemetry/ResponseTrace", {
|
|
463
|
-
defaultValue: () => void 0
|
|
464
|
-
});
|
|
465
|
-
|
|
466
451
|
// ../telemetry/src/browser.ts
|
|
467
452
|
var BrowserTelemetry = class extends Context_exports.Service()("executor/BrowserTelemetry") {
|
|
468
453
|
};
|
|
@@ -809,6 +794,33 @@ var makeOptimisticClient = (transport) => {
|
|
|
809
794
|
};
|
|
810
795
|
|
|
811
796
|
// src/implementation/ui-client.ts
|
|
797
|
+
var resubscribeDelay = Schedule_exports.min([
|
|
798
|
+
Schedule_exports.exponential("1 second"),
|
|
799
|
+
Schedule_exports.spaced("1 minute")
|
|
800
|
+
]).pipe(Schedule_exports.jittered);
|
|
801
|
+
var appFailure = (error) => Schema_exports.is(UiFailed)(error) && error.reason === "operation_failed";
|
|
802
|
+
var resubscribes = (error) => HttpClientError_exports.isHttpClientError(error) || Cause_exports.isTimeoutError(error) || Schema_exports.is(UiFailed)(error) && error.reason !== "account_required";
|
|
803
|
+
var Retrying = class {
|
|
804
|
+
constructor(error, previous) {
|
|
805
|
+
this.error = error;
|
|
806
|
+
this.previous = previous;
|
|
807
|
+
}
|
|
808
|
+
error;
|
|
809
|
+
previous;
|
|
810
|
+
};
|
|
811
|
+
var visibleResult = (result) => {
|
|
812
|
+
const current = AsyncResult_exports.value(result);
|
|
813
|
+
if (Option_exports.isNone(current) || !(current.value instanceof Retrying)) {
|
|
814
|
+
return result;
|
|
815
|
+
}
|
|
816
|
+
const previous = Option_exports.map(
|
|
817
|
+
Option_exports.fromUndefinedOr(current.value.previous),
|
|
818
|
+
AsyncResult_exports.success
|
|
819
|
+
);
|
|
820
|
+
return AsyncResult_exports.isSuccess(result) ? AsyncResult_exports.failureWithPrevious(Cause_exports.fail(current.value.error), { previous, waiting: true }) : AsyncResult_exports.failureWithPrevious(AsyncResult_exports.isFailure(result) ? result.cause : Cause_exports.empty, {
|
|
821
|
+
previous
|
|
822
|
+
});
|
|
823
|
+
};
|
|
812
824
|
var createAppClient = () => {
|
|
813
825
|
const { runtime, atoms } = makeBrowserTelemetry(
|
|
814
826
|
browserSettings("/_executor/api/telemetry", "executor-app-web")
|
|
@@ -863,7 +875,8 @@ var createAppClient = () => {
|
|
|
863
875
|
Stream_exports.suspend(() => {
|
|
864
876
|
let previous;
|
|
865
877
|
let attempts = 0;
|
|
866
|
-
|
|
878
|
+
let latest;
|
|
879
|
+
const subscription = Stream_exports.unwrap(
|
|
867
880
|
Effect_exports.gen(function* () {
|
|
868
881
|
const attempt = attempts++;
|
|
869
882
|
const first = yield* pendingSpan("ui.app.first_result", {
|
|
@@ -911,53 +924,55 @@ var createAppClient = () => {
|
|
|
911
924
|
Stream_exports.timeout("45 seconds"),
|
|
912
925
|
Stream_exports.concat(Stream_exports.fail(new UiFailed({ reason: "unavailable" }))),
|
|
913
926
|
Stream_exports.filter((frame) => frame.type !== "heartbeat"),
|
|
914
|
-
Stream_exports.mapEffect(
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
Effect_exports.
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
927
|
+
Stream_exports.mapEffect(
|
|
928
|
+
(frame) => {
|
|
929
|
+
if (frame.type === "failure") return Effect_exports.fail(frame.error);
|
|
930
|
+
const server = externalTrace(frame.trace);
|
|
931
|
+
return Effect_exports.gen(function* () {
|
|
932
|
+
const value = yield* Schema_exports.decodeUnknownEffect(decoderOf(output))(
|
|
933
|
+
frame.value
|
|
934
|
+
).pipe(Effect_exports.mapError(() => new AppQueryFailed()));
|
|
935
|
+
const received = yield* Effect_exports.currentSpan;
|
|
936
|
+
const receivedAt = clock.currentTimeMillisUnsafe();
|
|
937
|
+
const currentRevision = revision++;
|
|
938
|
+
yield* Effect_exports.annotateCurrentSpan({
|
|
939
|
+
"executor.operation.name": name,
|
|
940
|
+
"executor.snapshot.revision": currentRevision,
|
|
941
|
+
"browser.query.elapsed_ms": receivedAt - started,
|
|
942
|
+
"executor.trace.context_valid": Option_exports.isSome(server)
|
|
943
|
+
});
|
|
944
|
+
yield* first.finish(Exit_exports.void);
|
|
945
|
+
let committed = false;
|
|
946
|
+
return {
|
|
947
|
+
value,
|
|
948
|
+
commit: () => {
|
|
949
|
+
if (committed) return;
|
|
950
|
+
committed = true;
|
|
951
|
+
const committedAt = clock.currentTimeMillisUnsafe();
|
|
952
|
+
runtime.runFork(
|
|
953
|
+
Effect_exports.void.pipe(
|
|
954
|
+
Effect_exports.withSpan("ui.app.result.commit", {
|
|
955
|
+
parent: received,
|
|
956
|
+
attributes: {
|
|
957
|
+
"executor.operation.name": name,
|
|
958
|
+
"executor.snapshot.revision": currentRevision,
|
|
959
|
+
"browser.query.elapsed_ms": committedAt - started,
|
|
960
|
+
"browser.query.receive_to_commit_ms": committedAt - receivedAt,
|
|
961
|
+
"browser.page.hidden": document.visibilityState === "hidden"
|
|
962
|
+
}
|
|
963
|
+
})
|
|
964
|
+
)
|
|
965
|
+
);
|
|
966
|
+
}
|
|
967
|
+
};
|
|
968
|
+
}).pipe(
|
|
969
|
+
Effect_exports.withSpan("ui.app.result.receive", {
|
|
970
|
+
parent: Option_exports.isSome(server) ? server.value : first.span,
|
|
971
|
+
kind: "consumer"
|
|
972
|
+
})
|
|
973
|
+
);
|
|
974
|
+
}
|
|
975
|
+
),
|
|
961
976
|
Stream_exports.onExit(finish),
|
|
962
977
|
Stream_exports.provideService(Tracer_exports.ParentSpan, first.span)
|
|
963
978
|
);
|
|
@@ -968,16 +983,35 @@ var createAppClient = () => {
|
|
|
968
983
|
Stream_exports.catch(
|
|
969
984
|
(error) => Schema_exports.is(UiDeploymentChanged)(error) ? Stream_exports.unwrap(deploymentChanged.pipe(Effect_exports.as(Stream_exports.never))) : Stream_exports.fail(error)
|
|
970
985
|
),
|
|
971
|
-
Stream_exports.
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
)
|
|
976
|
-
)
|
|
986
|
+
Stream_exports.tap(
|
|
987
|
+
(value) => Effect_exports.sync(() => {
|
|
988
|
+
latest = value;
|
|
989
|
+
})
|
|
977
990
|
)
|
|
978
991
|
);
|
|
992
|
+
return Stream_exports.unwrap(
|
|
993
|
+
Effect_exports.gen(function* () {
|
|
994
|
+
const retrying = yield* Queue_exports.unbounded();
|
|
995
|
+
return Stream_exports.merge(
|
|
996
|
+
subscription.pipe(
|
|
997
|
+
Stream_exports.retry(
|
|
998
|
+
resubscribeDelay.pipe(
|
|
999
|
+
Schedule_exports.while(
|
|
1000
|
+
({ input: input2 }) => !resubscribes(input2) ? false : appFailure(input2) ? Queue_exports.offer(retrying, new Retrying(input2, latest)).pipe(
|
|
1001
|
+
Effect_exports.as(true)
|
|
1002
|
+
) : true
|
|
1003
|
+
)
|
|
1004
|
+
)
|
|
1005
|
+
)
|
|
1006
|
+
),
|
|
1007
|
+
// Shown outside the retried stream, so they do not reset its delay.
|
|
1008
|
+
Stream_exports.fromQueue(retrying),
|
|
1009
|
+
{ haltStrategy: "left" }
|
|
1010
|
+
);
|
|
1011
|
+
})
|
|
1012
|
+
);
|
|
979
1013
|
})
|
|
980
|
-
).pipe(Atom_exports.map(queryResult));
|
|
1014
|
+
).pipe(Atom_exports.map((result) => queryResult(visibleResult(result))));
|
|
981
1015
|
const optimistic = makeOptimisticClient({
|
|
982
1016
|
source,
|
|
983
1017
|
read: (name, input, output) => request("query", name, input, output),
|