apps 0.0.1-beta.10 → 0.0.1-beta.101
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 +60 -42
- package/framework-reference.json +1 -1
- package/js/{chunk-Z5M2LQOZ.js → chunk-2CURR5Y7.js} +113 -58
- package/js/{chunk-72JNVHPK.js → chunk-2LSGC7XY.js} +4 -3
- package/js/{chunk-JU7VHODU.js → chunk-4PIQKACY.js} +65 -10
- package/js/chunk-4UPC36ZL.js +5185 -0
- package/js/{chunk-VFZKSM3T.js → chunk-4X2UI4R2.js} +3 -3
- package/js/chunk-5C6RAGAS.js +335 -0
- package/js/{chunk-KUMBKVJD.js → chunk-62NVUKED.js} +2 -2
- package/js/chunk-74H25C4X.js +95 -0
- package/js/chunk-7HG422GB.js +90 -0
- package/js/chunk-7STIP5CS.js +171 -0
- package/js/{chunk-UK573G7W.js → chunk-ACQXVKVQ.js} +87 -51
- package/js/{chunk-IJX4CYZO.js → chunk-DILSCQPJ.js} +228 -264
- package/js/chunk-ILYCJ3HV.js +449 -0
- package/js/chunk-K6TSCYAO.js +712 -0
- package/js/{chunk-M3B3DE4K.js → chunk-KLSEU35Y.js} +463 -218
- package/js/chunk-OD3KFKZD.js +1617 -0
- package/js/chunk-OWN3DP2W.js +88 -0
- package/js/{chunk-IPI4MFSN.js → chunk-PBGPES67.js} +2 -2
- package/js/{chunk-FL2QR3XW.js → chunk-QI66R4FP.js} +355 -76
- package/js/{chunk-V5KNQVCT.js → chunk-RN4YB4JT.js} +931 -289
- package/js/{chunk-ODEIDRGW.js → chunk-URKOTNDA.js} +795 -176
- package/js/{chunk-5T57N25Q.js → chunk-VAI3EVCS.js} +643 -69
- package/js/chunk-VCYWAA4N.js +49 -0
- package/js/{chunk-57RKNWL2.js → chunk-YDW7DX3A.js} +4 -4
- package/js/{chunk-RFVIONFX.js → chunk-YWVISRZD.js} +123 -44
- package/js/{chunk-CDL5PM2Q.js → chunk-ZKDXML77.js} +19239 -18404
- package/js/client.js +148 -84
- package/js/contracts.js +150 -21
- package/js/effect.js +18 -19
- package/js/{es-APDZKREY.js → es-DIULA3ZF.js} +62 -1659
- package/js/graphql.js +49 -40
- package/js/host.js +85 -62
- package/js/index.js +212 -98
- package/js/mcp/effect.js +21 -21
- package/js/mcp.js +84 -57
- package/js/openapi.js +4331 -1415
- package/js/react.js +2 -3
- package/js/skills/effect.js +6 -3
- package/js/skills.js +208 -81
- 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 +9 -8
- package/js/ui/serving.js +8609 -228
- package/package.json +3 -8
- package/runtime.json +1 -1
- package/types/app-cache/src/contracts/cache.d.ts +18 -0
- package/types/app-cache/src/index.d.ts +34 -2
- package/types/apps/src/contracts/api-response-error.d.ts +4 -0
- package/types/apps/src/contracts/app.d.ts +56 -11
- package/types/apps/src/contracts/cache.d.ts +20 -0
- package/types/apps/src/contracts/context.d.ts +60 -17
- package/types/apps/src/contracts/elicitation.d.ts +23 -7
- package/types/apps/src/contracts/events.d.ts +94 -0
- package/types/apps/src/contracts/failure.d.ts +30 -1
- package/types/apps/src/contracts/graphql.d.ts +2 -1
- package/types/apps/src/contracts/host.d.ts +1456 -20
- package/types/apps/src/contracts/icons.d.ts +28 -0
- package/types/apps/src/contracts/live.d.ts +2 -0
- package/types/apps/src/contracts/mcp.d.ts +81 -20
- package/types/apps/src/contracts/network.d.ts +120 -0
- package/types/apps/src/contracts/openapi-compile.d.ts +82 -3
- package/types/apps/src/contracts/openapi-document.d.ts +1 -1
- package/types/apps/src/contracts/openapi.d.ts +41 -9
- package/types/apps/src/contracts/operations.d.ts +14 -7
- package/types/apps/src/contracts/placement.d.ts +102 -0
- package/types/apps/src/contracts/protocol-version.d.ts +2 -2
- package/types/apps/src/contracts/protocols/1.d.ts +733 -81
- package/types/apps/src/contracts/protocols/10.d.ts +1450 -0
- package/types/apps/src/contracts/protocols/11.d.ts +1149 -0
- package/types/apps/src/contracts/protocols/12.d.ts +3310 -0
- package/types/apps/src/contracts/protocols/2.d.ts +69 -26
- package/types/apps/src/contracts/protocols/3.d.ts +133 -33
- package/types/apps/src/contracts/protocols/4.d.ts +122 -45
- package/types/apps/src/contracts/protocols/5.d.ts +157 -47
- package/types/apps/src/contracts/protocols/6.d.ts +1629 -0
- package/types/apps/src/contracts/protocols/7.d.ts +1785 -0
- package/types/apps/src/contracts/protocols/8.d.ts +1182 -0
- package/types/apps/src/contracts/protocols/9.d.ts +1104 -0
- package/types/apps/src/contracts/protocols/current.d.ts +6857 -0
- package/types/apps/src/contracts/protocols/oauth-6.d.ts +74 -0
- package/types/apps/src/contracts/protocols/oauth.d.ts +134 -0
- package/types/apps/src/contracts/provider-error.d.ts +9 -0
- package/types/apps/src/contracts/provider.d.ts +90 -6
- package/types/apps/src/contracts/schedules.d.ts +7 -1
- package/types/apps/src/contracts/schema.d.ts +21 -0
- package/types/apps/src/contracts/shared-catalog.d.ts +11 -0
- package/types/apps/src/contracts/skills.d.ts +50 -13
- package/types/apps/src/contracts/sql.d.ts +63 -0
- package/types/apps/src/contracts/ui.d.ts +70 -30
- package/types/apps/src/contracts/webhooks.d.ts +24 -7
- package/types/apps/src/contracts/workflows.d.ts +56 -34
- package/types/apps/src/facet.d.ts +4 -5
- package/types/apps/src/host.d.ts +5 -0
- package/types/apps/src/implementation/account-router.d.ts +4 -3
- package/types/apps/src/implementation/app.d.ts +41 -14
- package/types/apps/src/implementation/authoring.d.ts +25 -5
- package/types/apps/src/implementation/browser-scripts.gen.d.ts +6 -0
- package/types/apps/src/implementation/cache.d.ts +29 -2
- package/types/apps/src/implementation/catalog-cache.d.ts +35 -4
- package/types/apps/src/implementation/elicitation.d.ts +18 -15
- package/types/apps/src/implementation/events.d.ts +64 -0
- package/types/apps/src/implementation/failure-detail.d.ts +28 -5
- package/types/apps/src/implementation/graphql-catalog.d.ts +3 -3
- package/types/apps/src/implementation/graphql.d.ts +4 -3
- package/types/apps/src/implementation/input-problems.d.ts +6 -2
- package/types/apps/src/implementation/invocation-timing.d.ts +18 -0
- 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 +6 -4
- package/types/apps/src/implementation/mcp-client.d.ts +17 -9
- package/types/apps/src/implementation/mcp-tools.d.ts +2 -1
- package/types/apps/src/implementation/mcp.d.ts +20 -9
- package/types/apps/src/implementation/network.d.ts +16 -0
- package/types/apps/src/implementation/openapi-compile.d.ts +38 -7
- package/types/apps/src/implementation/openapi-document.d.ts +50 -20
- 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 +23 -1
- package/types/apps/src/implementation/openapi-upgrade.d.ts +4 -0
- package/types/apps/src/implementation/operations.d.ts +58 -7
- package/types/apps/src/implementation/optimistic.d.ts +1 -1
- package/types/apps/src/implementation/placement.d.ts +60 -0
- package/types/apps/src/implementation/protocol-operations.d.ts +3 -0
- package/types/apps/src/implementation/provider-error.d.ts +28 -1
- package/types/apps/src/implementation/provider.d.ts +19 -4
- package/types/apps/src/implementation/query-commit.d.ts +1 -1
- package/types/apps/src/implementation/router-catalog.d.ts +20 -18
- package/types/apps/src/implementation/router.d.ts +24 -5
- package/types/apps/src/implementation/runtime-yield.d.ts +7 -0
- package/types/apps/src/implementation/schedules.d.ts +39 -8
- package/types/apps/src/implementation/schema.d.ts +108 -11
- package/types/apps/src/implementation/skills.d.ts +18 -24
- package/types/apps/src/implementation/sql.d.ts +71 -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 +3 -3
- 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 +28 -11
- 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 +15 -6
- package/types/apps/src/implementation/workflow-context.d.ts +6 -2
- package/types/apps/src/implementation/workflows.d.ts +11 -4
- package/types/apps/src/index.d.ts +68 -19
- package/types/apps/src/mcp.d.ts +20 -1
- package/types/apps/src/openapi.d.ts +22 -1
- package/types/apps/src/react.d.ts +1 -1
- package/types/apps/src/skills.d.ts +10 -8
- package/types/apps/src/ui-serving.d.ts +1 -1
- package/types/telemetry/src/app-records.d.ts +42 -0
- package/types/telemetry/src/browser-operations.d.ts +2 -2
- package/types/telemetry/src/browser.d.ts +8 -3
- package/types/telemetry/src/config.d.ts +2 -2
- package/types/telemetry/src/index.d.ts +2 -1
- package/types/telemetry/src/layer.d.ts +10 -4
- package/types/telemetry/src/measurements.d.ts +1 -1
- package/types/telemetry/src/ownership.d.ts +60 -0
- package/types/telemetry/src/recorded-failure.d.ts +29 -0
- package/types/telemetry/src/relay.d.ts +16 -6
- package/types/telemetry/src/span-attributes.d.ts +17 -1
- package/types/telemetry/src/transport.d.ts +8 -1
- package/types/utils/src/api-error.d.ts +55 -0
- package/types/utils/src/connection-failure.d.ts +33 -0
- package/types/utils/src/legacy-keys.d.ts +20 -0
- package/types/utils/src/recorded-message.d.ts +18 -0
- package/types/utils/src/schema-definitions.d.ts +13 -0
- package/types/utils/src/user-facing-error.d.ts +83 -0
- package/js/chunk-27F7W2LG.js +0 -34
- package/js/chunk-CRDWFA74.js +0 -299
- package/js/chunk-EPT3ZP52.js +0 -224
- package/js/chunk-MKWZPDR6.js +0 -63
- package/js/chunk-N7YDVXYJ.js +0 -186
- package/js/chunk-NKLWZJLE.js +0 -172
- package/js/chunk-PJJ24GU7.js +0 -877
- package/js/chunk-PZB6T6KU.js +0 -19
- package/js/chunk-R3EV5FTO.js +0 -97
- package/js/chunk-WLE7WX2U.js +0 -2645
- package/js/chunk-YXQHV65J.js +0 -242
- package/js/chunk-ZQINWV4W.js +0 -630
- package/js/mcp/stdio.js +0 -128
- 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 -18
- 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/storage.d.ts +0 -68
- package/types/apps/src/implementation/mcp-stdio.d.ts +0 -4
- package/types/apps/src/implementation/storage.d.ts +0 -15
- package/types/apps/src/mcp-stdio.d.ts +0 -5
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* App-owned SQLite. An app with migrations in `migrations/` reads and writes its own database with
|
|
3
|
+
* plain SQL. The author API mirrors Cloudflare's `SqlStorage`, so tools built for Durable Object
|
|
4
|
+
* SQLite fit it.
|
|
5
|
+
*/
|
|
6
|
+
/** A value SQLite stores or returns. */
|
|
7
|
+
export type SqlValue = string | number | null | ArrayBuffer;
|
|
8
|
+
/** One result row, keyed by column name. */
|
|
9
|
+
export type SqlRow = Record<string, SqlValue>;
|
|
10
|
+
/** The rows of one statement, already read, and what the statement read and wrote. */
|
|
11
|
+
export interface SqlCursor<Row extends SqlRow = SqlRow> extends Iterable<Row> {
|
|
12
|
+
readonly columnNames: readonly string[];
|
|
13
|
+
readonly rowsRead: number;
|
|
14
|
+
readonly rowsWritten: number;
|
|
15
|
+
toArray(): Row[];
|
|
16
|
+
/** The only row. Throws unless the statement returned exactly one. */
|
|
17
|
+
one(): Row;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Read-only SQL. Query tools receive this. A query runs in a transaction that is always rolled
|
|
21
|
+
* back, so nothing it changes commits; one that changes rows fails.
|
|
22
|
+
*/
|
|
23
|
+
export interface SqlReader {
|
|
24
|
+
exec<Row extends SqlRow = SqlRow>(query: string, ...bindings: SqlValue[]): SqlCursor<Row>;
|
|
25
|
+
}
|
|
26
|
+
/** SQL inside one transaction. */
|
|
27
|
+
export type SqlTransaction = SqlReader;
|
|
28
|
+
/**
|
|
29
|
+
* Writable SQL. Outside a transaction every statement commits on its own. `transaction` runs its
|
|
30
|
+
* callback synchronously in one SQLite transaction, so no transaction can stay open while the app
|
|
31
|
+
* waits on anything else; throwing rolls it back. Apps call outside services between transactions.
|
|
32
|
+
*/
|
|
33
|
+
export interface Sql extends SqlReader {
|
|
34
|
+
transaction<T>(work: (tx: SqlTransaction) => Synchronous<T>): T;
|
|
35
|
+
}
|
|
36
|
+
/** A transaction callback's result: a Promise means the callback awaited, which is refused. */
|
|
37
|
+
export type Synchronous<T> = T extends PromiseLike<unknown> ? never : T;
|
|
38
|
+
/** The Durable Object storage a data facet hands its app. App code never receives it. */
|
|
39
|
+
export interface AppSqlStorage {
|
|
40
|
+
readonly sql: {
|
|
41
|
+
exec(query: string, ...bindings: SqlValue[]): {
|
|
42
|
+
readonly columnNames: string[];
|
|
43
|
+
readonly rowsRead: number;
|
|
44
|
+
readonly rowsWritten: number;
|
|
45
|
+
toArray(): Record<string, SqlValue>[];
|
|
46
|
+
};
|
|
47
|
+
};
|
|
48
|
+
transactionSync<T>(work: () => T): T;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Tables Executor keeps in an app's database: applied migrations, workflow step receipts, and
|
|
52
|
+
* `_executor_legacy_rows (table_name, id, body)`, the rows of the document API apps used before
|
|
53
|
+
* SQL, with JSON bodies (empty for apps that never stored any). Apps should only read them; a
|
|
54
|
+
* changed migration history fails the next deploy.
|
|
55
|
+
*/
|
|
56
|
+
export declare const reservedTablePrefix = "_executor_";
|
|
57
|
+
/** Where an app keeps its migrations: `0001_create_notes.sql`, applied in number order. */
|
|
58
|
+
export declare const migrationsDirectory = "migrations";
|
|
59
|
+
/**
|
|
60
|
+
* The most values one statement may bind. Durable Object SQLite sets `SQLITE_LIMIT_VARIABLE_NUMBER`
|
|
61
|
+
* to 100 on every host; `ctx.sql` checks it first so the error names the limit.
|
|
62
|
+
*/
|
|
63
|
+
export declare const sqlBindingsLimit = 100;
|
|
@@ -1,24 +1,58 @@
|
|
|
1
1
|
/** Browser-to-host operations bind identity and authentication outside authored app code. */
|
|
2
|
-
import { Schema } from "effect";
|
|
3
|
-
import { HttpApi, HttpApiEndpoint, HttpApiGroup, HttpApiSchema } from "effect/
|
|
4
|
-
|
|
5
|
-
export declare const UiContext: Schema.Struct<{
|
|
6
|
-
readonly
|
|
7
|
-
readonly
|
|
8
|
-
|
|
2
|
+
import { Schema, type Effect, type Stream } from "effect";
|
|
3
|
+
import { HttpApi, HttpApiEndpoint, HttpApiGroup, HttpApiSchema } from "effect/http-api";
|
|
4
|
+
import { withLegacyKeys } from "../../../utils/src/legacy-keys.js";
|
|
5
|
+
export declare const UiContext: withLegacyKeys<Schema.Struct<{
|
|
6
|
+
readonly version: Schema.NonEmptyString;
|
|
7
|
+
readonly accounts: Schema.optional<Schema.$Record<Schema.NonEmptyString, Schema.$Array<Schema.NonEmptyString>>>;
|
|
8
|
+
}>, {
|
|
9
|
+
readonly version: "deployment";
|
|
9
10
|
}>;
|
|
11
|
+
/** A problem with one of the page's accounts, from stored state. Labels are the owner's own names. */
|
|
12
|
+
export type UiAccountProblem = {
|
|
13
|
+
readonly provider: string;
|
|
14
|
+
readonly reason: "missing" | "removed" | "incompatible";
|
|
15
|
+
} | {
|
|
16
|
+
readonly provider: string;
|
|
17
|
+
readonly account: string;
|
|
18
|
+
readonly reason: "credentials_rejected" | "forbidden" | "upstream_unavailable" | "check_failed";
|
|
19
|
+
};
|
|
20
|
+
/** Account problems found when the page opened, with dashboard links that resolve them. */
|
|
21
|
+
export interface UiAccountNotice {
|
|
22
|
+
readonly app: string;
|
|
23
|
+
readonly problems: readonly UiAccountProblem[];
|
|
24
|
+
/** The app's accounts in the dashboard. */
|
|
25
|
+
readonly fix: string;
|
|
26
|
+
}
|
|
10
27
|
/** Retained browser bytes. Hosts authorize access before reading or rendering them. */
|
|
11
|
-
export interface
|
|
28
|
+
export interface AppUiFile {
|
|
12
29
|
readonly body: Uint8Array;
|
|
13
30
|
readonly contentType: string;
|
|
14
31
|
}
|
|
15
|
-
/**
|
|
16
|
-
export
|
|
32
|
+
/** One byte range of a stored file, already within its size. */
|
|
33
|
+
export interface AppUiRange {
|
|
34
|
+
readonly offset: number;
|
|
35
|
+
readonly length: number;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* A public file the version's source served from `ui/public/`, which the host copied to its
|
|
39
|
+
* own store. `etag` names its exact bytes. Hosts authorize access before reading it.
|
|
40
|
+
*/
|
|
41
|
+
export interface AppUiStoredFile {
|
|
42
|
+
readonly contentType: string;
|
|
43
|
+
readonly size: number;
|
|
44
|
+
readonly etag: string;
|
|
45
|
+
readonly read: (range: AppUiRange | undefined) => Effect.Effect<Stream.Stream<Uint8Array, UiFailed>, UiFailed>;
|
|
46
|
+
}
|
|
47
|
+
export type AppUiAsset = AppUiFile | AppUiStoredFile;
|
|
48
|
+
/** Requests name an operation on this app and the page's version, never another app or account. */
|
|
49
|
+
export declare const UiOperation: withLegacyKeys<Schema.Struct<{
|
|
17
50
|
readonly name: Schema.NonEmptyString;
|
|
18
51
|
readonly input: Schema.Codec<Schema.Json, Schema.Json, never, never>;
|
|
19
|
-
readonly
|
|
20
|
-
readonly
|
|
21
|
-
|
|
52
|
+
readonly version: Schema.NonEmptyString;
|
|
53
|
+
readonly accounts: Schema.optional<Schema.$Record<Schema.NonEmptyString, Schema.$Array<Schema.NonEmptyString>>>;
|
|
54
|
+
}>, {
|
|
55
|
+
readonly version: "deployment";
|
|
22
56
|
}>;
|
|
23
57
|
declare const UiUnauthorized_base: Schema.Class<UiUnauthorized, Schema.TaggedStruct<"UiUnauthorized", {}>, import("effect/Cause").YieldableError>;
|
|
24
58
|
/** The app session is absent or its parent login was revoked. */
|
|
@@ -28,9 +62,12 @@ declare const UiForbidden_base: Schema.Class<UiForbidden, Schema.TaggedStruct<"U
|
|
|
28
62
|
/** The request did not originate from the configured app. */
|
|
29
63
|
export declare class UiForbidden extends UiForbidden_base {
|
|
30
64
|
}
|
|
31
|
-
declare const
|
|
32
|
-
/**
|
|
33
|
-
|
|
65
|
+
declare const UiVersionChanged_base: Schema.Class<UiVersionChanged, Schema.TaggedStruct<"UiDeploymentChanged", {}>, import("effect/Cause").YieldableError>;
|
|
66
|
+
/**
|
|
67
|
+
* The page should reload before starting another operation. The tag keeps its former name: pages
|
|
68
|
+
* built with earlier framework releases reload on it.
|
|
69
|
+
*/
|
|
70
|
+
export declare class UiVersionChanged extends UiVersionChanged_base {
|
|
34
71
|
}
|
|
35
72
|
declare const UiFailed_base: Schema.Class<UiFailed, Schema.TaggedStruct<"UiFailed", {
|
|
36
73
|
readonly reason: Schema.Literals<readonly ["unavailable", "operation_failed", "account_required"]>;
|
|
@@ -50,24 +87,27 @@ export declare const UiSnapshot: Schema.Union<readonly [Schema.Struct<{
|
|
|
50
87
|
readonly type: Schema.Literal<"heartbeat">;
|
|
51
88
|
}>]>;
|
|
52
89
|
/** Portable serving contract; the host authenticates and resolves the configured app. */
|
|
53
|
-
export declare const AppUiApi: HttpApi.HttpApi<"app-ui", HttpApiGroup.HttpApiGroup<"ui", HttpApiEndpoint.HttpApiEndpoint<"query", "POST", "/_executor/api/query", never, never, Schema.toCodecJson<Schema.Struct<{
|
|
90
|
+
export declare const AppUiApi: HttpApi.HttpApi<"app-ui", HttpApiGroup.HttpApiGroup<"ui", HttpApiEndpoint.HttpApiEndpoint<"query", "POST", "/_executor/api/query", never, never, Schema.toCodecJson<withLegacyKeys<Schema.Struct<{
|
|
54
91
|
readonly name: Schema.NonEmptyString;
|
|
55
92
|
readonly input: Schema.Codec<Schema.Json, Schema.Json, never, never>;
|
|
56
|
-
readonly
|
|
57
|
-
readonly
|
|
58
|
-
|
|
59
|
-
|
|
93
|
+
readonly version: Schema.NonEmptyString;
|
|
94
|
+
readonly accounts: Schema.optional<Schema.$Record<Schema.NonEmptyString, Schema.$Array<Schema.NonEmptyString>>>;
|
|
95
|
+
}>, {
|
|
96
|
+
readonly version: "deployment";
|
|
97
|
+
}>>, never, Schema.toCodecJson<Schema.Codec<Schema.Json, Schema.Json, never, never>>, Schema.toCodecJson<typeof UiUnauthorized | typeof UiForbidden | typeof UiVersionChanged | typeof UiFailed>, never, never> | HttpApiEndpoint.HttpApiEndpoint<"mutate", "POST", "/_executor/api/mutate", never, never, Schema.toCodecJson<withLegacyKeys<Schema.Struct<{
|
|
60
98
|
readonly name: Schema.NonEmptyString;
|
|
61
99
|
readonly input: Schema.Codec<Schema.Json, Schema.Json, never, never>;
|
|
62
|
-
readonly
|
|
63
|
-
readonly
|
|
64
|
-
|
|
65
|
-
|
|
100
|
+
readonly version: Schema.NonEmptyString;
|
|
101
|
+
readonly accounts: Schema.optional<Schema.$Record<Schema.NonEmptyString, Schema.$Array<Schema.NonEmptyString>>>;
|
|
102
|
+
}>, {
|
|
103
|
+
readonly version: "deployment";
|
|
104
|
+
}>>, never, Schema.toCodecJson<Schema.Codec<Schema.Json, Schema.Json, never, never>>, Schema.toCodecJson<typeof UiUnauthorized | typeof UiForbidden | typeof UiVersionChanged | typeof UiFailed>, never, never> | HttpApiEndpoint.HttpApiEndpoint<"subscribe", "POST", "/_executor/api/subscribe", never, never, Schema.toCodecJson<withLegacyKeys<Schema.Struct<{
|
|
66
105
|
readonly name: Schema.NonEmptyString;
|
|
67
106
|
readonly input: Schema.Codec<Schema.Json, Schema.Json, never, never>;
|
|
68
|
-
readonly
|
|
69
|
-
readonly
|
|
70
|
-
|
|
107
|
+
readonly version: Schema.NonEmptyString;
|
|
108
|
+
readonly accounts: Schema.optional<Schema.$Record<Schema.NonEmptyString, Schema.$Array<Schema.NonEmptyString>>>;
|
|
109
|
+
}>, {
|
|
110
|
+
readonly version: "deployment";
|
|
71
111
|
}>>, never, HttpApiSchema.StreamSse<HttpApiSchema.SseEventFromData<Schema.Union<readonly [Schema.Struct<{
|
|
72
112
|
readonly type: Schema.Literal<"snapshot">;
|
|
73
113
|
readonly value: Schema.Codec<Schema.Json, Schema.Json, never, never>;
|
|
@@ -77,7 +117,7 @@ export declare const AppUiApi: HttpApi.HttpApi<"app-ui", HttpApiGroup.HttpApiGro
|
|
|
77
117
|
readonly error: typeof UiFailed;
|
|
78
118
|
}>, Schema.Struct<{
|
|
79
119
|
readonly type: Schema.Literal<"heartbeat">;
|
|
80
|
-
}>]>>, Schema.Union<readonly [typeof UiUnauthorized, typeof UiForbidden, typeof
|
|
120
|
+
}>]>>, Schema.Union<readonly [typeof UiUnauthorized, typeof UiForbidden, typeof UiVersionChanged, typeof UiFailed]>, {
|
|
81
121
|
readonly value: Schema.Json;
|
|
82
122
|
readonly type: "snapshot";
|
|
83
123
|
readonly trace?: unknown;
|
|
@@ -86,5 +126,5 @@ export declare const AppUiApi: HttpApi.HttpApi<"app-ui", HttpApiGroup.HttpApiGro
|
|
|
86
126
|
readonly error: UiFailed;
|
|
87
127
|
} | {
|
|
88
128
|
readonly type: "heartbeat";
|
|
89
|
-
}>, Schema.toCodecJson<typeof UiUnauthorized | typeof UiForbidden | typeof
|
|
129
|
+
}>, Schema.toCodecJson<typeof UiUnauthorized | typeof UiForbidden | typeof UiVersionChanged | typeof UiFailed>, never, never>, false>>;
|
|
90
130
|
export {};
|
|
@@ -1,17 +1,34 @@
|
|
|
1
1
|
/** Account-bound webhook lifecycle. Register and unregister must be idempotent for subscriptionId. */
|
|
2
2
|
import type { Effect, Schema } from "effect";
|
|
3
3
|
import type { ManualWebhookSetup } from "./webhook-protocol.js";
|
|
4
|
-
import type {
|
|
5
|
-
|
|
6
|
-
type
|
|
7
|
-
|
|
8
|
-
|
|
4
|
+
import type { AccountScope, BoundContext, ScopedSlots } from "./app.js";
|
|
5
|
+
/** What every webhook context provides; a context with `user` serves user-account webhooks. */
|
|
6
|
+
type HookContext = Pick<BoundContext<ScopedSlots, AccountScope>, "app" | "fetch" | "signal">;
|
|
7
|
+
/**
|
|
8
|
+
* The accounts of the webhook's scope. A context with `user` names a user requirement; one of the
|
|
9
|
+
* `"app"` scope, which has no `user`, an app requirement.
|
|
10
|
+
*/
|
|
11
|
+
type ScopeAccounts<Context extends HookContext> = Context extends {
|
|
12
|
+
readonly user: {
|
|
13
|
+
readonly accounts: infer Accounts;
|
|
14
|
+
};
|
|
15
|
+
} ? Accounts : Context["app"]["accounts"];
|
|
16
|
+
type SourceAccount<Context extends HookContext> = Context extends {
|
|
17
|
+
readonly user: unknown;
|
|
18
|
+
} ? {
|
|
19
|
+
readonly user: keyof ScopeAccounts<Context> & string;
|
|
20
|
+
} : {
|
|
21
|
+
readonly app: keyof ScopeAccounts<Context> & string;
|
|
22
|
+
};
|
|
23
|
+
type SelectedAccount<Context extends HookContext> = {
|
|
24
|
+
[Slot in keyof ScopeAccounts<Context>]: ScopeAccounts<Context>[Slot] extends readonly (infer Account)[] ? Account : ScopeAccounts<Context>[Slot];
|
|
25
|
+
}[keyof ScopeAccounts<Context>];
|
|
9
26
|
/**
|
|
10
27
|
* Registration, delivery and cleanup share the selected accounts.
|
|
11
28
|
* The host stores account IDs and parsed state, never credentials.
|
|
12
29
|
* Register runs when enabling a subscription, not on every app evaluation.
|
|
13
30
|
*/
|
|
14
|
-
interface WebhookLifecycle<Context extends
|
|
31
|
+
interface WebhookLifecycle<Context extends HookContext, Config extends Schema.Decoder<unknown>, State extends Schema.Decoder<unknown>, Error = unknown> {
|
|
15
32
|
readonly account: SourceAccount<Context>;
|
|
16
33
|
readonly config: Config;
|
|
17
34
|
readonly state: State;
|
|
@@ -43,7 +60,7 @@ interface WebhookLifecycle<Context extends Pick<BoundContext<AccountSlots>, "acc
|
|
|
43
60
|
}) => Effect.Effect<void, Error>;
|
|
44
61
|
}
|
|
45
62
|
/** Manual subscriptions collect the state schema in a private browser form instead of invoking provider APIs. */
|
|
46
|
-
export type Webhook<Context extends
|
|
63
|
+
export type Webhook<Context extends HookContext, Config extends Schema.Decoder<unknown>, State extends Schema.Decoder<unknown>, Error = unknown> = (WebhookLifecycle<Context, Config, State, Error> & {
|
|
47
64
|
readonly setup?: never;
|
|
48
65
|
}) | (Omit<WebhookLifecycle<Context, Config, State, Error>, "register" | "unregister"> & {
|
|
49
66
|
readonly setup: typeof ManualWebhookSetup.Type;
|
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
/** Portable workflow declarations, run views and durable execution capabilities. */
|
|
2
|
+
import { withLegacyKeys } from "../../../utils/src/legacy-keys.js";
|
|
2
3
|
import { Schema, type Effect } from "effect";
|
|
4
|
+
import { RecordedMessage } from "../../../utils/src/recorded-message.js";
|
|
3
5
|
import { JsonValue } from "./schema.js";
|
|
4
6
|
import type { AppContext, AppRequirements, QueryContext, MutationContext } from "./context.js";
|
|
7
|
+
import type { AccountScope } from "./app.js";
|
|
5
8
|
import type { Operation } from "../implementation/operations.js";
|
|
6
9
|
import type { HostContext } from "./host.js";
|
|
7
10
|
/** Run identity is opaque and shared by author and SDK interfaces. */
|
|
@@ -49,6 +52,11 @@ declare const WorkflowFailure_base: Schema.Class<WorkflowFailure, Schema.TaggedS
|
|
|
49
52
|
}>, import("effect/Cause").YieldableError>;
|
|
50
53
|
/** Failures cross host boundaries as reason codes plus the app's own bounded error detail. */
|
|
51
54
|
export declare class WorkflowFailure extends WorkflowFailure_base {
|
|
55
|
+
/**
|
|
56
|
+
* The step name and error detail are the app's. Its run's owner reads them; telemetry records
|
|
57
|
+
* only the reason, however the failure was built or decoded.
|
|
58
|
+
*/
|
|
59
|
+
get [RecordedMessage](): string | undefined;
|
|
52
60
|
}
|
|
53
61
|
/** Explicitly stop retrying an authored step. Its message is reported like any step error. */
|
|
54
62
|
export declare class NonRetryableError extends Error {
|
|
@@ -64,25 +72,30 @@ export declare const HostedWorkflow: Schema.Struct<{
|
|
|
64
72
|
readonly outputSchema: Schema.optionalKey<Schema.$Record<Schema.String, Schema.Codec<Schema.Json, Schema.Json, never, never>>>;
|
|
65
73
|
}>;
|
|
66
74
|
export type HostedWorkflow = typeof HostedWorkflow.Type;
|
|
67
|
-
/**
|
|
68
|
-
|
|
75
|
+
/**
|
|
76
|
+
* Results are available only on completed runs; failures carry a reason code and app error detail.
|
|
77
|
+
* Runs name their version under its former name too, for apps and callers written before the rename.
|
|
78
|
+
*/
|
|
79
|
+
export declare const WorkflowRun: Schema.Union<readonly [withLegacyKeys<Schema.Struct<{
|
|
69
80
|
readonly status: Schema.Literals<readonly ["queued", "running", "waiting", "paused", "waitingForPause"]>;
|
|
70
|
-
readonly profile: Schema.optionalKey<Schema.NonEmptyString>;
|
|
71
81
|
readonly id: Schema.brand<Schema.NonEmptyString, "wfr">;
|
|
72
82
|
readonly app: Schema.NonEmptyString;
|
|
73
|
-
readonly
|
|
83
|
+
readonly version: Schema.NonEmptyString;
|
|
74
84
|
readonly workflow: Schema.NonEmptyString;
|
|
75
85
|
readonly createdAt: Schema.String;
|
|
76
|
-
}>,
|
|
86
|
+
}>, {
|
|
87
|
+
readonly version: "deployment";
|
|
88
|
+
}>, withLegacyKeys<Schema.Struct<{
|
|
77
89
|
readonly status: Schema.Literal<"complete">;
|
|
78
90
|
readonly output: Schema.Codec<Schema.Json, Schema.Json, never, never>;
|
|
79
|
-
readonly profile: Schema.optionalKey<Schema.NonEmptyString>;
|
|
80
91
|
readonly id: Schema.brand<Schema.NonEmptyString, "wfr">;
|
|
81
92
|
readonly app: Schema.NonEmptyString;
|
|
82
|
-
readonly
|
|
93
|
+
readonly version: Schema.NonEmptyString;
|
|
83
94
|
readonly workflow: Schema.NonEmptyString;
|
|
84
95
|
readonly createdAt: Schema.String;
|
|
85
|
-
}>,
|
|
96
|
+
}>, {
|
|
97
|
+
readonly version: "deployment";
|
|
98
|
+
}>, withLegacyKeys<Schema.Struct<{
|
|
86
99
|
readonly status: Schema.Literal<"errored">;
|
|
87
100
|
readonly error: Schema.Literals<readonly ["unavailable", "not_found", "input", "output", "operation", "approval", "credentials", "terminated", "execution", "conflict", "engine"]>;
|
|
88
101
|
/** The failing step and the app's own error, when the run recorded them. */
|
|
@@ -91,42 +104,46 @@ export declare const WorkflowRun: Schema.Union<readonly [Schema.Struct<{
|
|
|
91
104
|
errorName: Schema.optionalKey<Schema.String>;
|
|
92
105
|
message: Schema.optionalKey<Schema.String>;
|
|
93
106
|
}>>;
|
|
94
|
-
readonly profile: Schema.optionalKey<Schema.NonEmptyString>;
|
|
95
107
|
readonly id: Schema.brand<Schema.NonEmptyString, "wfr">;
|
|
96
108
|
readonly app: Schema.NonEmptyString;
|
|
97
|
-
readonly
|
|
109
|
+
readonly version: Schema.NonEmptyString;
|
|
98
110
|
readonly workflow: Schema.NonEmptyString;
|
|
99
111
|
readonly createdAt: Schema.String;
|
|
100
|
-
}>,
|
|
112
|
+
}>, {
|
|
113
|
+
readonly version: "deployment";
|
|
114
|
+
}>, withLegacyKeys<Schema.Struct<{
|
|
101
115
|
readonly status: Schema.Literal<"terminated">;
|
|
102
|
-
readonly profile: Schema.optionalKey<Schema.NonEmptyString>;
|
|
103
116
|
readonly id: Schema.brand<Schema.NonEmptyString, "wfr">;
|
|
104
117
|
readonly app: Schema.NonEmptyString;
|
|
105
|
-
readonly
|
|
118
|
+
readonly version: Schema.NonEmptyString;
|
|
106
119
|
readonly workflow: Schema.NonEmptyString;
|
|
107
120
|
readonly createdAt: Schema.String;
|
|
121
|
+
}>, {
|
|
122
|
+
readonly version: "deployment";
|
|
108
123
|
}>]>;
|
|
109
124
|
export type WorkflowRun = typeof WorkflowRun.Type;
|
|
110
125
|
/** A bounded run-history page, already scoped to an authorized configured app. */
|
|
111
126
|
export declare const WorkflowRunPage: Schema.Struct<{
|
|
112
|
-
readonly items: Schema.$Array<Schema.Union<readonly [Schema.Struct<{
|
|
127
|
+
readonly items: Schema.$Array<Schema.Union<readonly [withLegacyKeys<Schema.Struct<{
|
|
113
128
|
readonly status: Schema.Literals<readonly ["queued", "running", "waiting", "paused", "waitingForPause"]>;
|
|
114
|
-
readonly profile: Schema.optionalKey<Schema.NonEmptyString>;
|
|
115
129
|
readonly id: Schema.brand<Schema.NonEmptyString, "wfr">;
|
|
116
130
|
readonly app: Schema.NonEmptyString;
|
|
117
|
-
readonly
|
|
131
|
+
readonly version: Schema.NonEmptyString;
|
|
118
132
|
readonly workflow: Schema.NonEmptyString;
|
|
119
133
|
readonly createdAt: Schema.String;
|
|
120
|
-
}>,
|
|
134
|
+
}>, {
|
|
135
|
+
readonly version: "deployment";
|
|
136
|
+
}>, withLegacyKeys<Schema.Struct<{
|
|
121
137
|
readonly status: Schema.Literal<"complete">;
|
|
122
138
|
readonly output: Schema.Codec<Schema.Json, Schema.Json, never, never>;
|
|
123
|
-
readonly profile: Schema.optionalKey<Schema.NonEmptyString>;
|
|
124
139
|
readonly id: Schema.brand<Schema.NonEmptyString, "wfr">;
|
|
125
140
|
readonly app: Schema.NonEmptyString;
|
|
126
|
-
readonly
|
|
141
|
+
readonly version: Schema.NonEmptyString;
|
|
127
142
|
readonly workflow: Schema.NonEmptyString;
|
|
128
143
|
readonly createdAt: Schema.String;
|
|
129
|
-
}>,
|
|
144
|
+
}>, {
|
|
145
|
+
readonly version: "deployment";
|
|
146
|
+
}>, withLegacyKeys<Schema.Struct<{
|
|
130
147
|
readonly status: Schema.Literal<"errored">;
|
|
131
148
|
readonly error: Schema.Literals<readonly ["unavailable", "not_found", "input", "output", "operation", "approval", "credentials", "terminated", "execution", "conflict", "engine"]>;
|
|
132
149
|
/** The failing step and the app's own error, when the run recorded them. */
|
|
@@ -135,20 +152,22 @@ export declare const WorkflowRunPage: Schema.Struct<{
|
|
|
135
152
|
errorName: Schema.optionalKey<Schema.String>;
|
|
136
153
|
message: Schema.optionalKey<Schema.String>;
|
|
137
154
|
}>>;
|
|
138
|
-
readonly profile: Schema.optionalKey<Schema.NonEmptyString>;
|
|
139
155
|
readonly id: Schema.brand<Schema.NonEmptyString, "wfr">;
|
|
140
156
|
readonly app: Schema.NonEmptyString;
|
|
141
|
-
readonly
|
|
157
|
+
readonly version: Schema.NonEmptyString;
|
|
142
158
|
readonly workflow: Schema.NonEmptyString;
|
|
143
159
|
readonly createdAt: Schema.String;
|
|
144
|
-
}>,
|
|
160
|
+
}>, {
|
|
161
|
+
readonly version: "deployment";
|
|
162
|
+
}>, withLegacyKeys<Schema.Struct<{
|
|
145
163
|
readonly status: Schema.Literal<"terminated">;
|
|
146
|
-
readonly profile: Schema.optionalKey<Schema.NonEmptyString>;
|
|
147
164
|
readonly id: Schema.brand<Schema.NonEmptyString, "wfr">;
|
|
148
165
|
readonly app: Schema.NonEmptyString;
|
|
149
|
-
readonly
|
|
166
|
+
readonly version: Schema.NonEmptyString;
|
|
150
167
|
readonly workflow: Schema.NonEmptyString;
|
|
151
168
|
readonly createdAt: Schema.String;
|
|
169
|
+
}>, {
|
|
170
|
+
readonly version: "deployment";
|
|
152
171
|
}>]>>;
|
|
153
172
|
readonly next: Schema.optionalKey<Schema.brand<Schema.NonEmptyString, "wfr">>;
|
|
154
173
|
}>;
|
|
@@ -175,25 +194,28 @@ export interface WorkflowControls extends WorkflowReads {
|
|
|
175
194
|
readonly run: string;
|
|
176
195
|
}) => Promise<WorkflowRun>;
|
|
177
196
|
}
|
|
178
|
-
/**
|
|
179
|
-
|
|
197
|
+
/**
|
|
198
|
+
* External steps get fresh credentials and cancellation, without storage or live elicitation. A run
|
|
199
|
+
* started by app-scope work, such as an app schedule, has the `"app"` scope: no `user`.
|
|
200
|
+
*/
|
|
201
|
+
export type WorkflowStepContext<Requirements extends AppRequirements = AppRequirements, Scope extends AccountScope = "user"> = Omit<AppContext<Requirements, Scope>, "elicit" | "workflows"> & {
|
|
180
202
|
readonly runId: WorkflowRunId;
|
|
181
203
|
readonly stepId: string;
|
|
182
204
|
readonly idempotencyKey: string;
|
|
183
205
|
};
|
|
184
206
|
/** Explicit durable boundaries; database access passes through registered app operations. */
|
|
185
|
-
export interface WorkflowStep<Requirements extends AppRequirements = AppRequirements> {
|
|
186
|
-
do<Output>(name: string, run: (context: WorkflowStepContext<Requirements>) => Promise<Output>): Promise<Output>;
|
|
187
|
-
do<Output>(name: string, options: WorkflowStepOptions, run: (context: WorkflowStepContext<Requirements>) => Promise<Output>): Promise<Output>;
|
|
188
|
-
runQuery<Input, Output>(name: string, operation: Operation<Input, Output, "query", QueryContext<Requirements>>, input: NoInfer<Input>, options?: WorkflowStepOptions): Promise<Output>;
|
|
189
|
-
runMutation<Input, Output>(name: string, operation: Operation<Input, Output, "mutation", MutationContext<Requirements>>, input: NoInfer<Input>, options?: WorkflowStepOptions): Promise<Output>;
|
|
207
|
+
export interface WorkflowStep<Requirements extends AppRequirements = AppRequirements, Scope extends AccountScope = "user"> {
|
|
208
|
+
do<Output>(name: string, run: (context: WorkflowStepContext<Requirements, Scope>) => Promise<Output>): Promise<Output>;
|
|
209
|
+
do<Output>(name: string, options: WorkflowStepOptions, run: (context: WorkflowStepContext<Requirements, Scope>) => Promise<Output>): Promise<Output>;
|
|
210
|
+
runQuery<Input, Output>(name: string, operation: Operation<Input, Output, "query", QueryContext<Requirements, Scope>>, input: NoInfer<Input>, options?: WorkflowStepOptions): Promise<Output>;
|
|
211
|
+
runMutation<Input, Output>(name: string, operation: Operation<Input, Output, "mutation", MutationContext<Requirements, Scope>>, input: NoInfer<Input>, options?: WorkflowStepOptions): Promise<Output>;
|
|
190
212
|
readonly sleep: (name: string, duration: WorkflowDuration) => Promise<void>;
|
|
191
213
|
readonly sleepUntil: (name: string, timestamp: number | Date) => Promise<void>;
|
|
192
214
|
}
|
|
193
215
|
/** The orchestration body gets no account, database or interactive capabilities. */
|
|
194
|
-
export interface WorkflowContext<Requirements extends AppRequirements = AppRequirements> {
|
|
216
|
+
export interface WorkflowContext<Requirements extends AppRequirements = AppRequirements, Scope extends AccountScope = "user"> {
|
|
195
217
|
readonly runId: WorkflowRunId;
|
|
196
|
-
readonly step: WorkflowStep<Requirements>;
|
|
218
|
+
readonly step: WorkflowStep<Requirements, Scope>;
|
|
197
219
|
}
|
|
198
220
|
/** Framework-owned native declaration; only the callback crosses the author Promise boundary. */
|
|
199
221
|
export interface AppWorkflow<Input = unknown, Output = unknown> {
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
/**
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
export declare const facetStorage: (storage: NonNullable<Sqlite.SqliteClientConfig["storage"]>) => AppStorage;
|
|
1
|
+
/** The data facet's storage capability; used only by the generated data facet, never browser bundles. */
|
|
2
|
+
import type { AppSqlStorage } from "./contracts/sql.js";
|
|
3
|
+
/** Bind one facet's storage at the runtime edge. App code receives `ctx.sql` over it, never the storage. */
|
|
4
|
+
export declare const facetStorage: (storage: AppSqlStorage) => AppSqlStorage;
|
package/types/apps/src/host.d.ts
CHANGED
|
@@ -6,6 +6,11 @@ export { isolatedCacheSession } from "./implementation/cache-session.js";
|
|
|
6
6
|
export declare const hostContext: (accounts: ResolvedAccountsInput, approval?: unknown) => HostContext;
|
|
7
7
|
/** Portable Promise handler. Invoke only after the host has authorized and resolved accounts. */
|
|
8
8
|
export declare const createAppHandler: (app: unknown) => ((request: Request, context: HostContext) => Promise<Response>);
|
|
9
|
+
/**
|
|
10
|
+
* The clock this framework's spans read, in nanoseconds. The runtime's bridge times the isolate's
|
|
11
|
+
* whole dispatch with it, so that time and the invocation's own timing share one clock.
|
|
12
|
+
*/
|
|
13
|
+
export declare const isolatedClock: () => bigint;
|
|
9
14
|
/** Isolates return bounded, telemetry beside the protocol result; no exporter secret enters app code. */
|
|
10
15
|
export declare const createIsolatedAppHandler: (app: unknown) => (request: Request, context: HostContext) => Promise<Response>;
|
|
11
16
|
/**
|
|
@@ -3,10 +3,11 @@ import { type RouterDeclaration } from "./router.js";
|
|
|
3
3
|
* Discover each selected account's router and combine matching names.
|
|
4
4
|
* Calls take { accountId, input }; each branch retains its account's input schema,
|
|
5
5
|
* credentials, approval and output validation. Empty selections expose no operations.
|
|
6
|
-
* Discovery is sequential and cancellation follows the caller's signal.
|
|
6
|
+
* Discovery is sequential and cancellation follows the caller's signal. `discover` may return the
|
|
7
|
+
* router or a Promise of it, and the combined router keeps its operations' handler contexts.
|
|
7
8
|
*/
|
|
8
9
|
export declare const accountRouter: <Account extends {
|
|
9
10
|
readonly id: string;
|
|
10
|
-
}>(accounts: readonly Account[], discover: (account: Account) => Promise<RouterDeclaration
|
|
11
|
+
}, Query = unknown, Mutation = unknown>(accounts: readonly Account[], discover: (account: Account) => RouterDeclaration<Query, Mutation> | Promise<RouterDeclaration<Query, Mutation>>, options: {
|
|
11
12
|
readonly signal: AbortSignal;
|
|
12
|
-
}) => Promise<RouterDeclaration
|
|
13
|
+
}) => Promise<RouterDeclaration<Query, Mutation>>;
|
|
@@ -1,41 +1,68 @@
|
|
|
1
1
|
import type { ScheduleDeclaration } from "./schedules.js";
|
|
2
|
-
import type { App as NativeApp, AppDefinition as NativeDefinition } from "../contracts/app.js";
|
|
3
|
-
import type { AppRequirements,
|
|
2
|
+
import type { App as NativeApp, AccountScope, AppDefinition as NativeDefinition, EvaluationContext } from "../contracts/app.js";
|
|
3
|
+
import type { AppRequirements, QueryContext, MutationContext, RequirementSlots, WebhookContext } from "../contracts/context.js";
|
|
4
4
|
import { type PromiseMethods } from "./authoring.js";
|
|
5
5
|
import { type WorkflowDeclaration } from "./workflows.js";
|
|
6
6
|
import type { WorkflowContext } from "../contracts/workflows.js";
|
|
7
7
|
import { type RouterDeclaration } from "./router.js";
|
|
8
8
|
import { type Schema } from "./schema.js";
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
9
|
+
/** One native webhook definition with the given handler context. */
|
|
10
|
+
type NativeWebhook<Context> = NonNullable<NativeDefinition<Context>["webhooks"]>[string];
|
|
11
|
+
/** A webhook as authors write it: Promise handlers, author schemas and its source requirement. */
|
|
12
|
+
type AuthorWebhook<Context, Account> = {
|
|
13
|
+
readonly [Key in keyof NativeWebhook<Context>]: Key extends "config" | "state" ? Schema<unknown, boolean> : Key extends "account" ? Account : PromiseMethods<NativeWebhook<Context>>[Key];
|
|
14
|
+
};
|
|
15
|
+
/**
|
|
16
|
+
* A user-account webhook gets the caller-shaped context; an app-account webhook runs without a
|
|
17
|
+
* caller, so its context has no `user`.
|
|
18
|
+
*/
|
|
19
|
+
type AuthorWebhooks<Requirements extends AppRequirements> = Readonly<Record<string, AuthorWebhook<WebhookContext<Requirements>, {
|
|
20
|
+
readonly user: keyof RequirementSlots<Requirements>["user"] & string;
|
|
21
|
+
}> | AuthorWebhook<WebhookContext<Requirements, "app">, {
|
|
22
|
+
readonly app: keyof RequirementSlots<Requirements>["app"] & string;
|
|
23
|
+
}>>>;
|
|
24
|
+
/**
|
|
25
|
+
* User schedules run as each member who enables them; app schedules run without a caller, so their
|
|
26
|
+
* mutation takes a context of the `"app"` scope.
|
|
27
|
+
*/
|
|
28
|
+
type AuthorSchedules<Requirements extends AppRequirements> = Readonly<Record<string, ScheduleDeclaration<MutationContext<Requirements>, "user"> | ScheduleDeclaration<MutationContext<Requirements, "app">, "app">>>;
|
|
29
|
+
/**
|
|
30
|
+
* A run started by a caller binds its accounts; one started without a caller, such as by an app
|
|
31
|
+
* schedule, has no `user`, so its workflow declares a context of the `"app"` scope.
|
|
32
|
+
*/
|
|
33
|
+
type AuthorWorkflows<Requirements extends AppRequirements> = Readonly<Record<string, WorkflowDeclaration<WorkflowContext<Requirements>> | WorkflowDeclaration<WorkflowContext<Requirements, "app">>>>;
|
|
14
34
|
/** Author definition projected from native capabilities. Excluding callable objects keeps
|
|
15
35
|
* factories from being inferred as definitions and preserves contextual handler inference. */
|
|
16
36
|
export type AppDefinition<Requirements extends AppRequirements> = {
|
|
17
|
-
readonly [Key in keyof NativeDefinition<WebhookContext<Requirements>>]: Key extends "workflows" ?
|
|
37
|
+
readonly [Key in keyof NativeDefinition<WebhookContext<Requirements>>]: Key extends "workflows" ? AuthorWorkflows<Requirements> : Key extends "schedules" ? AuthorSchedules<Requirements> : Key extends "tools" ? RouterDeclaration<QueryContext<Requirements>, MutationContext<Requirements>> : Key extends "webhooks" ? AuthorWebhooks<Requirements> : NativeDefinition<WebhookContext<Requirements>>[Key];
|
|
18
38
|
} & {
|
|
19
39
|
readonly name?: never;
|
|
20
40
|
readonly queries?: never;
|
|
21
41
|
readonly mutations?: never;
|
|
22
42
|
readonly call?: never;
|
|
23
43
|
};
|
|
44
|
+
/** A webhook context as the host builds it: an app-account hook's has no `user`. */
|
|
45
|
+
type HostWebhookContext = WebhookContext<AppRequirements, AccountScope> & Partial<Pick<WebhookContext, "user">>;
|
|
24
46
|
/** Adapt operation and webhook catalogs without evaluating their handlers. */
|
|
25
47
|
export type EffectDefinition<Def> = {
|
|
26
|
-
readonly [Key in keyof Def]: Key extends "tools" ? NonNullable<NativeDefinition<unknown>["tools"]> : Key extends "workflows" ? Readonly<Record<string, import("../contracts/workflows.js").AppWorkflow>> : Key extends "schedules" ? NonNullable<NativeDefinition<unknown>["schedules"]> : Key extends "webhooks" ? NonNullable<NativeDefinition<
|
|
48
|
+
readonly [Key in keyof Def]: Key extends "tools" ? NonNullable<NativeDefinition<unknown>["tools"]> : Key extends "workflows" ? Readonly<Record<string, import("../contracts/workflows.js").AppWorkflow>> : Key extends "schedules" ? NonNullable<NativeDefinition<unknown>["schedules"]> : Key extends "webhooks" ? NonNullable<NativeDefinition<HostWebhookContext>["webhooks"]> : Key extends "skills" ? NonNullable<NativeDefinition<unknown>["skills"]> : Key extends "dynamicSkills" ? NonNullable<NativeDefinition<unknown>["dynamicSkills"]> : Def[Key];
|
|
27
49
|
};
|
|
28
50
|
declare const InternalApp: unique symbol;
|
|
29
51
|
/** Recognize a declaration from this framework instance before host adaptation. */
|
|
30
52
|
export declare const isApp: (value: unknown) => value is App<AppRequirements, AppDefinition<AppRequirements>>;
|
|
31
53
|
/** Public app handle; the native app is retained for host use without an async round trip. */
|
|
32
54
|
export interface App<Requirements extends AppRequirements, Def extends AppDefinition<Requirements>> {
|
|
33
|
-
readonly [InternalApp]: NativeApp<Requirements
|
|
34
|
-
readonly accounts: Requirements
|
|
35
|
-
readonly evaluate: (context:
|
|
55
|
+
readonly [InternalApp]: NativeApp<RequirementSlots<Requirements>, EffectDefinition<Def>>;
|
|
56
|
+
readonly accounts: RequirementSlots<Requirements>;
|
|
57
|
+
readonly evaluate: (context: AppFactoryContext<Requirements>) => Promise<Def>;
|
|
36
58
|
}
|
|
59
|
+
/**
|
|
60
|
+
* What a dynamic definition's factory receives. App-scope work, such as an app schedule, evaluates
|
|
61
|
+
* the app without a caller, so `user` is absent then.
|
|
62
|
+
*/
|
|
63
|
+
export type AppFactoryContext<Requirements extends AppRequirements> = EvaluationContext<RequirementSlots<Requirements>>;
|
|
37
64
|
/** Retrieve the same declaration for an Effect host. No evaluation or I/O occurs. */
|
|
38
|
-
export declare const toEffectApp: <Requirements extends AppRequirements, Def extends AppDefinition<Requirements>>(app: App<Requirements, Def>) => NativeApp<Requirements
|
|
65
|
+
export declare const toEffectApp: <Requirements extends AppRequirements, Def extends AppDefinition<Requirements>>(app: App<Requirements, Def>) => NativeApp<RequirementSlots<Requirements>, EffectDefinition<Def>>;
|
|
39
66
|
/** Assemble app behavior. Package names belong in package.json; hosts name installed copies. */
|
|
40
|
-
export declare const defineApp: <const Requirements extends AppRequirements, Def extends AppDefinition<Requirements>>(requirements: Requirements, definition: (Def & AppDefinition<Requirements>) | ((context:
|
|
67
|
+
export declare const defineApp: <const Requirements extends AppRequirements, Def extends AppDefinition<Requirements>>(requirements: Requirements, definition: (Def & AppDefinition<Requirements>) | ((context: AppFactoryContext<Requirements>) => Promise<Def & AppDefinition<Requirements>>)) => App<Requirements, Def>;
|
|
41
68
|
export {};
|
|
@@ -1,12 +1,32 @@
|
|
|
1
1
|
/** Small, explicit adapters between authored callbacks and native Effect operations. */
|
|
2
|
-
import { Effect } from "effect";
|
|
2
|
+
import { Effect, type Context } from "effect";
|
|
3
3
|
/** Project one Effect operation into its author-facing Promise signature. */
|
|
4
4
|
export type PromiseMethod<Method> = Method extends (...args: infer Args) => Effect.Effect<infer A, infer _E> ? (...args: Args) => Promise<A> : Method;
|
|
5
5
|
/** Project only an object's methods; data and schema types are not recursively rewritten. */
|
|
6
6
|
export type PromiseMethods<T> = {
|
|
7
7
|
readonly [Key in keyof T]: PromiseMethod<T[Key]>;
|
|
8
8
|
};
|
|
9
|
-
/**
|
|
10
|
-
export
|
|
11
|
-
/**
|
|
12
|
-
|
|
9
|
+
/** Which of the app's callbacks runs, recorded on the `app.code` span around it. */
|
|
10
|
+
export type AppCode = "factory" | "router" | "approval" | "handler" | "loader" | "cache" | "webhook" | "check" | "skills" | "elicitation" | "workflow" | "step";
|
|
11
|
+
/**
|
|
12
|
+
* Run `effect` as the app's own code. Its time is the app's, except for work it starts for
|
|
13
|
+
* Executor, an upstream or a person, which opens its own boundary inside.
|
|
14
|
+
*/
|
|
15
|
+
export declare const appCode: (code: AppCode) => <A, E, R>(effect: Effect.Effect<A, E, R>) => Effect.Effect<A, E, Exclude<R, import("effect/Tracer").ParentSpan>>;
|
|
16
|
+
/**
|
|
17
|
+
* Reuse a framework callback's cancellation-bound Effect, or run an ordinary async callback as the
|
|
18
|
+
* app's code. Every callback an app supplies enters the framework here, so its time is the app's.
|
|
19
|
+
*/
|
|
20
|
+
export declare const fromPromise: <Args extends readonly unknown[], A>(callback: (...args: Args) => Promise<A>, code: AppCode) => ((...args: Args) => Effect.Effect<A, unknown>);
|
|
21
|
+
/**
|
|
22
|
+
* `target[key]`, called on `target`. A method read off its object as a bare value loses its
|
|
23
|
+
* receiver, so an app's method, such as one of its cache's, enters `fromPromise` through this.
|
|
24
|
+
*/
|
|
25
|
+
export declare const method: <K extends PropertyKey, T extends { readonly [P in K]: (...args: never) => unknown; }>(target: T, key: K) => T[K];
|
|
26
|
+
/**
|
|
27
|
+
* Bind cancellation once so Promise callers and native framework callers run the same operation.
|
|
28
|
+
* `signalOf` is the signal, or reads it from each call's arguments, such as a loader's `context.signal`.
|
|
29
|
+
*/
|
|
30
|
+
export declare const toPromise: <Args extends readonly unknown[], A, E>(operation: (...args: Args) => Effect.Effect<A, E>, signalOf?: AbortSignal | ((...args: Args) => AbortSignal),
|
|
31
|
+
/** Services a Promise call runs with, such as its invocation's telemetry. */
|
|
32
|
+
services?: Context.Context<never>) => ((...args: Args) => Promise<A>);
|