@brickkit/effect 0.0.0-placeholder.0 → 0.16.0-beta.10
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 +41 -3
- package/dist/index.d.ts +1216 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +2626 -0
- package/dist/index.js.map +1 -0
- package/dist/server-BlvtUhSB.js +8784 -0
- package/dist/server-BlvtUhSB.js.map +1 -0
- package/dist/server-TbtxT_Ag.d.ts +4868 -0
- package/dist/server-TbtxT_Ag.d.ts.map +1 -0
- package/dist/testing.d.ts +11 -0
- package/dist/testing.d.ts.map +1 -0
- package/dist/testing.js +17 -0
- package/dist/testing.js.map +1 -0
- package/package.json +61 -4
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,1216 @@
|
|
|
1
|
+
import { $ as ApiDocument, $i as DatabaseHandle, $n as WorkflowScheduleRun, $r as runStages, $t as ResourcePluginTypes, A as FinishedSpan, Aa as StandardErrorCode, Ai as CallFiles, An as Resource, Ar as crudEventName, At as Service, B as recordWebhook, Bi as StorageUnavailableError, Bn as loadRecord, Br as AnySchema, Bt as isTool, C as OutboxStatus, Ca as markDashboardArrival, Ci as StorageOf, Cn as ChildChanges, Cr as WebhookConfig, Ct as getActionRoute, D as ScheduleRunRecord, Da as DuplicateNameError, Di as redis, Dn as CommandDecision, Dr as CrudEventOperation, Dt as ActionFeatures, E as ScheduleState, Ea as BrickError, Ei as memory, En as CommandConfig, Er as isWebhook, Et as ActionAccessPolicy, F as SpanStartRecord, Fa as toWireError, Fi as S3StorageOptions, Fn as ResourceConfig, Fr as ActionConfig, Ft as Tool, G as DASHBOARD_MCP_ROUTE, Gi as defineSecret, Gn as EventListener, Gr as ErrorHelpers, Gt as PluginRouteMethod, H as telemetryLayer, Hi as SecretRef, Hn as DispatchOptions, Hr as Call, Ht as InstalledPlugin, I as SpanStore, Ii as ScopedFiles, In as ResourceIdentity, Ir as ActionConfigBase, It as ToolAnnotations, J as DashboardOptions, Ji as overrideSecret, Jn as RetryDecision, Jr as HttpMethod, Jt as PluginRoutes, K as DASHBOARD_MCP_TOOLS, Ki as envSource, Kn as EventsOptions, Kr as ExecuteParams, Kt as PluginRouteRegistrar, L as Telemetry, Li as StoredFile, Ln as ResourceTypeOptions, Lr as ActionContext, Lt as ToolContext, M as SpanAttributes, Ma as ValidationIssue, Mi as FileStorage, Mn as ResourceActionConfig, Mr as defineEvents, Mt as ServiceOptions, N as SpanEndRecord, Na as WireError, Ni as LOCAL_FILES_ROUTE, Nn as ResourceActionInput, Nr as isCrudEvent, Nt as defineService, O as ScheduleTable, Oa as ErrorEnvelope, Oi as storageKey, On as CommandErrors, Or as EventRef, Ot as AnyService, P as SpanEventRecord, Pa as toErrorResponse, Pi as RawDeps, Pn as ResourceChild, Pr as Action, Pt as AnyTool, Q as requestLoggingPlugin, Qi as DatabaseConnection, Qn as ScheduleRun, Qr as Wire, Qt as ResourcePluginContext, R as TelemetryOptions, Ri as s3, Rn as defineResource, Rr as ActionParams, Rt as ToolOptions, S as OutboxRow, Sa as dashboardUser, Si as StorageDriver, Sn as AnyResource, Sr as SocketSchemas, St as actionOwners, T as outboxTable, Ta as signDashboardMcp, Ti as frameworkStorage, Tn as CommandChildren, Tr as WebhookVerifier, Tt as ActionAccessInfo, U as traceRoute, Ui as SecretSource, Un as EventDelivery, Ur as ErrorDefinition, Ut as PLUGIN_KIND, V as spanStore, Vi as SecretOptions, Vn as CrudEventPayload, Vr as AuthorizedActionConfig, Vt as ContextOf, W as traceScheduleRun, Wi as SecretValidator, Wn as EventEnvelope, Wr as ErrorDefinitions, Wt as PluginEndpointContext, X as normalizeDashboard, Xi as resolveSecrets, Xn as Schedule, Xr as PluginActionChecks, Xt as ResourcePlugin, Y as DashboardPeer, Yi as resetSecrets, Yn as WorkflowEvent, Yr as Next, Yt as RequirementOf, Z as RequestLoggingOptions, Zi as AnyDatabaseHandle, Zn as ScheduleConfig, Zr as Stage, Zt as ResourcePluginAPI, _ as EventsDefinition, _a as DashboardMcpCaller, _i as FrameworkStorage, _n as HostHooks, _r as SocketEmitOptions, _t as ServiceSchema, a as Activity, aa as createPostgresDatabase, ai as ClientIp, an as PluginInfo, ar as RawSocketHandle, at as EndpointContext, b as stopAllEvents, ba as dashboardKey, bi as PutIfAbsentResult, bn as addHostHooks, br as SocketReplay, bt as DEFAULT_PREFIX, c as Workflow, ca as isDatabaseHandle, ci as clientAddress, cn as PluginLifecycleContext, cr as RawSocketStats, ct as ErrorHookContext, d as workflowEngine, da as CallContext, di as PostgresAuditTable, dn as PluginSetupContext, dr as BrickSocketSender, dt as ResponseHookContext, ea as DatabaseService, ei as stagesOf, en as ServicePlugin, er as defineSchedule, et as DocumentationOptions, f as WORKFLOW_TABLE, fa as Logger, fi as SQLiteAuditTable, fn as definePlugin, fr as RegisteredSocket, ft as CorsOptions, g as Events, ga as DashboardIdentity, gi as Counter, gn as HookResult, gr as SocketEmitArgs, gt as ArchitectureSchema, h as EventRecorder, ha as DASHBOARD_KEY_ENV, hi as recordAudit, hn as HOOK_NAMES, hr as SocketConfig, ht as ArchitectureApplication, i as brick, ia as SQLiteOptions, ii as redact, in as PluginFactory, ir as RawSocketFrame, it as scalarDocsHTML, j as OtlpOptions, ja as ValidationError, ji as FileDriver, jn as ResourceActionAccess, jr as crudEventSource, jt as ServiceContext, k as scheduleTable, ka as STANDARD_ERRORS, ki as CallDeps, kn as CommandRow, kr as EventRefs, kt as NoIdentity, l as WorkflowEngine, la as timestamptzText, li as AuditOptions, ln as PluginManifest, lr as SocketsOptions, lt as OnError, m as EventContext, ma as DASHBOARD_IDENTITY_HEADER, mi as isAuditTable, mn as pluginOwner, mr as SocketBrokerMessage, mt as ActionSchema, n as BrickOptions, na as PostgresOptions, ni as Sensitive, nn as PluginAppContext, nr as RawSocket, nt as ReferenceDocument, o as DurableClock, oa as createSQLiteDatabase, oi as RateLimit, on as PluginInstallOptions, or as RawSocketMessage, ot as EndpointDefinition, p as AppEvents, pa as createLogger, pi as auditTable, pn as PluginTableBuilders, pr as SocketBroker, pt as CorsOrigin, q as DashboardAuth, qi as listSecrets, qn as ListenerFailure, qr as HTTP_METHODS, qt as PluginRouteScope, r as ListeningServer, ra as SQLiteDatabaseConfig, ri as hasSensitive, rn as PluginContext, rr as RawSocketConfig, rt as ReferenceOptions, s as DurableDeferred, sa as defineDatabase, si as RateLimits, sn as PluginInstance, sr as RawSocketPhase, st as EndpointMethod, t as BrickApp, ta as PostgresDatabaseConfig, ti as Reveal, tn as ServicePluginContext, tr as CronExpression, tt as OpenApiDocument, u as WorkflowEngineOptions, ua as BaseContext, ui as AuditTable, un as PluginServiceContext, ur as BrickSocketHandle, ut as OnResponse, v as EventsHub, va as DashboardUser, vi as KeyValueDriver, vn as PluginHookArgs, vr as SocketEventArgs, vt as exportArchitecture, w as OutboxTable, wa as signDashboardIdentity, wi as defineStorage, wn as Command, wr as WebhookRequest, wt as kebabCase, x as OutboxCounts, xa as dashboardMcpCaller, xi as RedisStorageOptions, xn as getHostHooks, xr as SocketSchema, xt as RouteIR, y as ScheduleControl, ya as dashboardIdentity, yi as KeyValueStorage, yn as PluginHooks, yr as SocketPayloads, yt as ActionRoute, z as TelemetryRecord, zi as StorageError, zn as idSchema, zr as AnyAction, zt as defineTool } from "./server-TbtxT_Ag.js";
|
|
2
|
+
import { Effect, Redacted, Schema } from "effect";
|
|
3
|
+
import { Column, GetColumnData, InferInsertModel, InferSelectModel, SQL, Table } from "drizzle-orm";
|
|
4
|
+
/**
|
|
5
|
+
* Apply the migrations in a folder that have not run yet, in order, and record
|
|
6
|
+
* them in the database's `__drizzle_migrations` table. The folder is the one
|
|
7
|
+
* `drizzle-kit generate` writes for drizzle 1.0: a folder per migration, each
|
|
8
|
+
* holding a `migration.sql`. A folder with a `meta/_journal.json` was written by
|
|
9
|
+
* an older drizzle-kit and is refused: run `drizzle-kit up` on it first.
|
|
10
|
+
*
|
|
11
|
+
* On Postgres a migration may hold several statements with no
|
|
12
|
+
* `--> statement-breakpoint` between them, as a hand-written one often does.
|
|
13
|
+
* Drizzle's own Effect migrator fails on such a file with "cannot insert
|
|
14
|
+
* multiple commands into a prepared statement". Its recorded hash is the
|
|
15
|
+
* file's, as ever. `SELECT ... INTO` in such a file fails with a message that
|
|
16
|
+
* names `CREATE TABLE ... AS`; a lone one runs as written.
|
|
17
|
+
*
|
|
18
|
+
* Migrations run without the database's `statementTimeout`: on Postgres each
|
|
19
|
+
* transaction sets `statement_timeout` to 0 for itself.
|
|
20
|
+
*
|
|
21
|
+
* @param database - A handle from `defineDatabase`.
|
|
22
|
+
* @param migrationsFolder - The folder of migrations.
|
|
23
|
+
* @example
|
|
24
|
+
* yield* migrateDatabase(database, "./drizzle/pages");
|
|
25
|
+
*/
|
|
26
|
+
export declare const migrateDatabase: (database: AnyDatabaseHandle, migrationsFolder: string) => Effect.Effect<void, unknown, DatabaseService<unknown>>;
|
|
27
|
+
/**
|
|
28
|
+
* Generates an idempotent SQLite CREATE TABLE IF NOT EXISTS definition
|
|
29
|
+
* directly from a Drizzle table schema.
|
|
30
|
+
*/
|
|
31
|
+
export declare function generateSQLiteTableDdl(table: any): string;
|
|
32
|
+
/**
|
|
33
|
+
* Generates idempotent secondary index DDL for a Drizzle table.
|
|
34
|
+
* Covers owner scoping, sort columns, and exact-match filters.
|
|
35
|
+
* UNIQUE columns already carry an implicit index, so they are skipped here.
|
|
36
|
+
* FTS and trigram indexes are handled separately by the search layer.
|
|
37
|
+
*/
|
|
38
|
+
export declare function generateSQLiteIndexDdl(table: any, opts?: {
|
|
39
|
+
ownerField?: string;
|
|
40
|
+
sortFields?: string[];
|
|
41
|
+
}): string[];
|
|
42
|
+
/**
|
|
43
|
+
* Ensures secondary indexes exist for a resource table.
|
|
44
|
+
* SQLite: B-tree indexes for owner scope + sort + composite hot path.
|
|
45
|
+
* Postgres: the same B-trees plus pg_trgm GIN indexes for substring search,
|
|
46
|
+
* created one after another (each GIN index needs the extension).
|
|
47
|
+
* Best-effort: a failed statement warns and the rest still run (a read-only
|
|
48
|
+
* replica, or no right to create pg_trgm); queries still work, only slower.
|
|
49
|
+
*
|
|
50
|
+
* @param db - A drizzle database, such as `ctx.db`.
|
|
51
|
+
* @param table - The resource's table.
|
|
52
|
+
* @param opts - The `ownerField`, `sortFields` and (Postgres) `searchFields` of the resource.
|
|
53
|
+
*/
|
|
54
|
+
export declare function ensureResourceIndexes(db: any, table: any, opts?: {
|
|
55
|
+
ownerField?: string;
|
|
56
|
+
sortFields?: string[];
|
|
57
|
+
searchFields?: string[];
|
|
58
|
+
}): Effect.Effect<void>;
|
|
59
|
+
/**
|
|
60
|
+
* Creates the FTS5 sidecar table + sync triggers + backfills existing rows.
|
|
61
|
+
* Idempotent; safe to call on every resource registration.
|
|
62
|
+
* No-op on Postgres (relies on pg_trgm instead) and when searchCols is empty.
|
|
63
|
+
* Best-effort: a failure warns, and search without FTS still works.
|
|
64
|
+
*
|
|
65
|
+
* @param db - A drizzle SQLite database, such as `ctx.db`.
|
|
66
|
+
* @param table - The resource's table.
|
|
67
|
+
* @param searchCols - The fields to search.
|
|
68
|
+
*/
|
|
69
|
+
export declare function ensureSQLiteFts(db: any, table: any, searchCols: string[]): Effect.Effect<void>;
|
|
70
|
+
/**
|
|
71
|
+
* Builds an FTS5 MATCH condition for a resource search term.
|
|
72
|
+
* Returns null when the term has no usable tokens; the caller falls back to LIKE.
|
|
73
|
+
*/
|
|
74
|
+
export declare function buildFtsMatchQuery(search: string): string | null;
|
|
75
|
+
/**
|
|
76
|
+
* Create the declared tables that do not exist yet. A development and test
|
|
77
|
+
* helper: never called by services or server startup, and never changes a table
|
|
78
|
+
* that exists. Use drizzle-kit migrations (`migrateDatabase`) for production
|
|
79
|
+
* schema changes.
|
|
80
|
+
*
|
|
81
|
+
* SQLite: `CREATE TABLE IF NOT EXISTS` per table, from its columns.
|
|
82
|
+
* Postgres: the missing tables, their enums, schemas, foreign keys and indexes,
|
|
83
|
+
* created in one transaction.
|
|
84
|
+
*
|
|
85
|
+
* @param source - A handle from `defineDatabase` (its tables, on the `Database` service it provides), or the tables as an array or record, with `db`.
|
|
86
|
+
* @param db - The drizzle database, when `source` is tables.
|
|
87
|
+
* @example
|
|
88
|
+
* yield* syncSchema(database);
|
|
89
|
+
*/
|
|
90
|
+
export declare function syncSchema<TDb>(source: DatabaseHandle<TDb, any>): Effect.Effect<void, unknown, DatabaseService<TDb>>;
|
|
91
|
+
export declare function syncSchema(source: readonly Table[] | Record<string, unknown>, db: unknown): Effect.Effect<void, unknown>;
|
|
92
|
+
/**
|
|
93
|
+
* A JSON value as its column stores it: an ISO string becomes a Date for a date
|
|
94
|
+
* column, an integer string a BigInt for a bigint column.
|
|
95
|
+
*
|
|
96
|
+
* @returns `undefined` when the string can't be a value of the column.
|
|
97
|
+
*/
|
|
98
|
+
export declare function columnValue(column: Column, value: unknown): unknown;
|
|
99
|
+
/**
|
|
100
|
+
* Define an action outside a service, to register with `service.action(action)`
|
|
101
|
+
* or to share between apps. It takes the same configuration as
|
|
102
|
+
* `service.action`; until a service takes it, `ctx` is only the request fields
|
|
103
|
+
* and `user`. Call it directly with `action.run(input, ctx)`.
|
|
104
|
+
*
|
|
105
|
+
* @example
|
|
106
|
+
* export const getPage = defineAction({
|
|
107
|
+
* name: "get",
|
|
108
|
+
* method: "GET",
|
|
109
|
+
* input: Schema.Struct({ id: Schema.String }),
|
|
110
|
+
* output: Page,
|
|
111
|
+
* execute: ({ input, error }) => findPage(input.id).pipe(Effect.flatMap((page) => page ?? error.NOT_FOUND())),
|
|
112
|
+
* });
|
|
113
|
+
* pages.action(getPage);
|
|
114
|
+
*/
|
|
115
|
+
export declare function defineAction<TInput extends AnySchema | undefined = undefined, TOutput extends AnySchema | undefined = undefined, const TErrors extends ErrorDefinitions = {}, TCtx = ActionContext, A = never, E = never, R = never, RA = never>(config: AuthorizedActionConfig<TInput, TOutput, TErrors, TCtx, A, E, R, RA> & ActionFeatures<TInput, TOutput, TCtx>): Action<TInput, TOutput, TErrors, A, R | RA>;
|
|
116
|
+
export declare function defineAction<TInput extends AnySchema | undefined = undefined, TOutput extends AnySchema | undefined = undefined, const TErrors extends ErrorDefinitions = {}, TCtx = ActionContext, A = never, E = never, R = never>(config: ActionConfig<TInput, TOutput, TErrors, TCtx, A, E, R> & ActionFeatures<TInput, TOutput, TCtx>): Action<TInput, TOutput, TErrors, A, R>;
|
|
117
|
+
/**
|
|
118
|
+
* Record how an action is protected, for tools that cannot read it from the
|
|
119
|
+
* configuration: plugins such as `crud` enforce access inside `execute`, so the
|
|
120
|
+
* action has no `authorize` to find. Introspection and the dashboard read what
|
|
121
|
+
* is recorded here.
|
|
122
|
+
*
|
|
123
|
+
* @param action - The action to describe.
|
|
124
|
+
* @param info - Whether it checks authorization and whether it scopes queries,
|
|
125
|
+
* and the resulting policy.
|
|
126
|
+
*/
|
|
127
|
+
export declare function setActionAccess(action: object, info: ActionAccessInfo): void;
|
|
128
|
+
/**
|
|
129
|
+
* How an action is protected: `"public"` when nothing checks the caller,
|
|
130
|
+
* `"authorized"` when an `authorize` does, and `"scoped"` when the action also
|
|
131
|
+
* limits what rows the caller can reach. It reads what a plugin recorded with
|
|
132
|
+
* `setActionAccess`, else the action's own `authorize`, and keeps the policy
|
|
133
|
+
* consistent with the flags.
|
|
134
|
+
*
|
|
135
|
+
* @param action - An action, or any object a plugin described.
|
|
136
|
+
* @returns `hasAuthorize`, `hasScope`, and `policy`.
|
|
137
|
+
*/
|
|
138
|
+
export declare function getActionAccess(action: AnyAction | object): ActionAccessInfo;
|
|
139
|
+
/**
|
|
140
|
+
* Say how the audit log records an action a plugin owns: `"inline"` when the
|
|
141
|
+
* plugin writes in its own transaction and records the write there with a
|
|
142
|
+
* host hook, `"none"` when it never writes. Without this, an action that is not
|
|
143
|
+
* a `GET` is recorded after it runs, as a plain action is. An action with
|
|
144
|
+
* `audit: false` stays unrecorded either way.
|
|
145
|
+
*/
|
|
146
|
+
export declare function setActionAudit(action: object, mode: "inline" | "none"): void;
|
|
147
|
+
/** The actions of a service by name, with a resource's actions under the resource's name: what `useService` is typed from. */
|
|
148
|
+
type ServiceActions = {
|
|
149
|
+
readonly [name: string]: AnyAction | ServiceActions;
|
|
150
|
+
};
|
|
151
|
+
/**
|
|
152
|
+
* What `useService` returns: the service's actions as methods that return
|
|
153
|
+
* Effects. Each takes its input, then an optional call context.
|
|
154
|
+
*/
|
|
155
|
+
type ServiceClient<T> = { readonly [K in keyof T]: T[K] extends AnyAction ? T[K]["run"] : ServiceClient<T[K]>; };
|
|
156
|
+
/**
|
|
157
|
+
* The contract of each service by name, which types `useService(service)`. The
|
|
158
|
+
* generated contract (`_brick/contract.ts`, which `brick dev` and `brick gen
|
|
159
|
+
* client` keep current) fills it in; nothing needs to be written by hand.
|
|
160
|
+
*/
|
|
161
|
+
interface BrickServices {}
|
|
162
|
+
type ContractCaller<Types> = Types extends {
|
|
163
|
+
input: infer I;
|
|
164
|
+
output: infer O;
|
|
165
|
+
} ? undefined extends I ? (input?: I, ctx?: CallContext) => Effect.Effect<O, BrickError | ValidationError> : (input: I, ctx?: CallContext) => Effect.Effect<O, BrickError | ValidationError> : never;
|
|
166
|
+
/**
|
|
167
|
+
* What `useService(service)` returns once the contract describes the service:
|
|
168
|
+
* its actions as methods that return Effects, a resource's actions under the
|
|
169
|
+
* resource's name. Sockets are left out.
|
|
170
|
+
*/
|
|
171
|
+
type ContractServiceClient<T> = { readonly [K in keyof T as T[K] extends {
|
|
172
|
+
kind: "socket";
|
|
173
|
+
} ? never : K]: T[K] extends {
|
|
174
|
+
kind: "action";
|
|
175
|
+
__types?: infer Types;
|
|
176
|
+
} ? ContractCaller<NonNullable<Types>> : ContractServiceClient<T[K]>; };
|
|
177
|
+
/** What `useService` returns while it is not told the service's actions: anything goes, and nothing is checked. */
|
|
178
|
+
type UntypedServiceClient = {
|
|
179
|
+
readonly [name: string]: any;
|
|
180
|
+
};
|
|
181
|
+
/** What `useService` takes beside the service. */
|
|
182
|
+
interface ProxyOptions {
|
|
183
|
+
/** The name of the calling service. It becomes `ctx.caller` in the target and cannot be spoofed: a `caller` given in `context` or per call is ignored. */
|
|
184
|
+
from?: string;
|
|
185
|
+
/** Defaults for every call. A per-call context is merged over it. */
|
|
186
|
+
context?: CallContext;
|
|
187
|
+
}
|
|
188
|
+
/**
|
|
189
|
+
* Call another service's actions in-process, as Effects. Each action is a
|
|
190
|
+
* method, and a resource's actions sit under the resource's name:
|
|
191
|
+
* `billing.charge(input)`, `billing.invoice.list()`.
|
|
192
|
+
*
|
|
193
|
+
* A call runs through the target's own validation and authorization, with the
|
|
194
|
+
* target's database, context, identity and deps (never the caller's), and shows
|
|
195
|
+
* as an `rpc` span in the trace. The caller's `user`, trace ids and client
|
|
196
|
+
* address carry over.
|
|
197
|
+
*
|
|
198
|
+
* `useService(service)` is typed from the app's generated contract
|
|
199
|
+
* (`_brick/contract.ts`, which `brick dev` and `brick gen client` keep
|
|
200
|
+
* current), as in `@brickkit/core`: renaming an action or changing its input
|
|
201
|
+
* is a compile error at every caller. Until the contract describes the
|
|
202
|
+
* service, the client is untyped. To type the methods without the contract,
|
|
203
|
+
* name the actions: `useService<{ charge: typeof charge }>(billing)`.
|
|
204
|
+
*
|
|
205
|
+
* A service that is not registered, or an action it does not have, is a
|
|
206
|
+
* defect when the Effect runs.
|
|
207
|
+
*
|
|
208
|
+
* @param service - The service to call, as `defineService` returned it.
|
|
209
|
+
* @param options - `from` (the calling service's name, which becomes
|
|
210
|
+
* `ctx.caller` in the target) and `context` (defaults for every call).
|
|
211
|
+
* @example
|
|
212
|
+
* const billing = useService(billingService, { from: "orders" });
|
|
213
|
+
* const receipt = yield* billing.charge({ orderId, amountCents });
|
|
214
|
+
*/
|
|
215
|
+
export declare function useService<const N extends string = string>(service: {
|
|
216
|
+
readonly name: N;
|
|
217
|
+
}, options?: ProxyOptions): N extends keyof BrickServices ? ContractServiceClient<BrickServices[N]> : UntypedServiceClient;
|
|
218
|
+
export declare function useService<T extends ServiceActions>(service: {
|
|
219
|
+
readonly name: string;
|
|
220
|
+
}, options?: ProxyOptions): ServiceClient<T>;
|
|
221
|
+
/**
|
|
222
|
+
* The deps of a service, for code that has no `ctx`: a listener, a schedule or
|
|
223
|
+
* a workflow step. Actions, tools and socket handlers read `ctx.deps` instead.
|
|
224
|
+
* File storages come as they were declared, so name the tenant with `in(tenant)`.
|
|
225
|
+
*
|
|
226
|
+
* `useDeps(service)` returns that service's deps, typed from it, anywhere.
|
|
227
|
+
* Without an argument it is an Effect that returns what the running listener
|
|
228
|
+
* or schedule sees: in one a plugin added, the deps of that install; in the
|
|
229
|
+
* app's own, the deps of all the app's services by name, for code that cannot
|
|
230
|
+
* import the service. A name two services give different values has no single
|
|
231
|
+
* answer, so reading it throws.
|
|
232
|
+
*
|
|
233
|
+
* @param service - The service whose deps to return.
|
|
234
|
+
* @returns The deps, typed from the service. Without `service`, an Effect of
|
|
235
|
+
* them that dies outside a listener or schedule of a Brick app.
|
|
236
|
+
* @example
|
|
237
|
+
* const book = (orderId: string) => useDeps(orders).carrier.book(orderId);
|
|
238
|
+
* const bookHere = (orderId: string) =>
|
|
239
|
+
* Effect.map(useDeps<{ carrier: Carrier }>(), (deps) => deps.carrier.book(orderId));
|
|
240
|
+
*/
|
|
241
|
+
export declare function useDeps<S extends AnyService>(service: S): S["deps"];
|
|
242
|
+
export declare function useDeps<T = Record<string, unknown>>(): Effect.Effect<T>;
|
|
243
|
+
/** The services every `defineService` adds to, by name. */
|
|
244
|
+
declare class ServiceRegistry {
|
|
245
|
+
private _revision;
|
|
246
|
+
private services;
|
|
247
|
+
private sites;
|
|
248
|
+
/** Changes whenever a definition does, so what was built from them (OpenAPI, the architecture) is rebuilt. */
|
|
249
|
+
get revision(): number;
|
|
250
|
+
touch(): void;
|
|
251
|
+
/** @throws When a different file already registered a service with this name. */
|
|
252
|
+
register(service: AnyService, site?: string | undefined): void;
|
|
253
|
+
get(name: string): AnyService | undefined;
|
|
254
|
+
has(name: string): boolean;
|
|
255
|
+
list(): AnyService[];
|
|
256
|
+
/**
|
|
257
|
+
* The architecture of an app (`app.definition`): its mounted routes. Without
|
|
258
|
+
* one, every registered service with its default routes under `/api`.
|
|
259
|
+
*/
|
|
260
|
+
exportArchitecture(application?: ArchitectureApplication): ArchitectureSchema;
|
|
261
|
+
}
|
|
262
|
+
/**
|
|
263
|
+
* The registry every `defineService` adds to: `brick()` serves its services
|
|
264
|
+
* when it is given none, and `useService` finds services by name in it.
|
|
265
|
+
*
|
|
266
|
+
* @returns The current global registry.
|
|
267
|
+
*/
|
|
268
|
+
export declare function getGlobalRegistry(): ServiceRegistry;
|
|
269
|
+
/**
|
|
270
|
+
* Start over with an empty global registry. For tests, which define the same
|
|
271
|
+
* services again in each case; an application never needs it.
|
|
272
|
+
*/
|
|
273
|
+
export declare function resetGlobalRegistry(): void;
|
|
274
|
+
/** What `UploadedFile` accepts. */
|
|
275
|
+
interface FileOptions {
|
|
276
|
+
/** The largest file accepted, in bytes. Also caps the request body before it is read. */
|
|
277
|
+
maxSize?: number;
|
|
278
|
+
/**
|
|
279
|
+
* The content types accepted, such as `"application/pdf"` or `"image/*"`;
|
|
280
|
+
* `"*\/*"` accepts any. Over HTTP, Bun takes a file's type from the
|
|
281
|
+
* extension of its file name, not from the part's `Content-Type`.
|
|
282
|
+
*/
|
|
283
|
+
accept?: readonly string[];
|
|
284
|
+
description?: string;
|
|
285
|
+
}
|
|
286
|
+
/**
|
|
287
|
+
* A file from a `multipart/form-data` body: a `File` (a `Blob`), at most
|
|
288
|
+
* `maxSize` bytes, of a type in `accept`. The counterpart of core's `t.File()`.
|
|
289
|
+
* A call to it over HTTP is read as multipart; OpenAPI describes the field as
|
|
290
|
+
* binary. A tool cannot take one.
|
|
291
|
+
*
|
|
292
|
+
* @example
|
|
293
|
+
* input: Schema.Struct({ file: UploadedFile({ maxSize: 5_000_000, accept: ["image/*"] }), folder: Schema.String })
|
|
294
|
+
*/
|
|
295
|
+
export declare function UploadedFile(options?: FileOptions): Schema.declare<File>;
|
|
296
|
+
/** Several files under one form field: the counterpart of core's `t.Files()`. A lone file is read as a list of one. */
|
|
297
|
+
export declare function UploadedFiles(options?: FileOptions & {
|
|
298
|
+
minItems?: number;
|
|
299
|
+
maxItems?: number;
|
|
300
|
+
}): Schema.$Array<Schema.declare<File>>;
|
|
301
|
+
/** Who a call comes from, as the audit log and `per: "actor"` rate limits see the service's `identity`. */
|
|
302
|
+
interface Actor {
|
|
303
|
+
/** Who: the rate-limit key and the audit actor. */
|
|
304
|
+
readonly id: string;
|
|
305
|
+
/** A display name for the audit log. */
|
|
306
|
+
readonly label?: string;
|
|
307
|
+
/** Which tenant: recorded in the audit log. */
|
|
308
|
+
readonly tenant?: string;
|
|
309
|
+
}
|
|
310
|
+
/**
|
|
311
|
+
* The actor of `user`, the value of the service's `identity`: `null` for no
|
|
312
|
+
* user.
|
|
313
|
+
*
|
|
314
|
+
* @throws When the user is not an object with a non-empty string `id`, and optional string `label` and `tenant`.
|
|
315
|
+
*/
|
|
316
|
+
export declare function actorOf(service: string, user: unknown): Actor | null;
|
|
317
|
+
/** The OpenAPI document's defaults, shared by `brick()` and `generateOpenApiSpec`. */
|
|
318
|
+
export declare const OPENAPI_DEFAULTS: Readonly<{
|
|
319
|
+
title: "Brick API";
|
|
320
|
+
version: "1.0.0";
|
|
321
|
+
path: "/openapi.json";
|
|
322
|
+
}>;
|
|
323
|
+
/** What `generateOpenApiSpec` describes, and how the document names it. */
|
|
324
|
+
interface OpenApiOptions {
|
|
325
|
+
title?: string;
|
|
326
|
+
version?: string;
|
|
327
|
+
description?: string;
|
|
328
|
+
prefix?: string;
|
|
329
|
+
services: readonly AnyService[];
|
|
330
|
+
}
|
|
331
|
+
type Json$1 = Record<string, any>;
|
|
332
|
+
/**
|
|
333
|
+
* Build the OpenAPI 3.1 document for the services: one path per action route,
|
|
334
|
+
* with request and response schemas from the actions' Schemas, their declared
|
|
335
|
+
* errors, tags by service, and a bearer security scheme where an action
|
|
336
|
+
* authorizes. `brick()` serves it at `/openapi.json`.
|
|
337
|
+
*/
|
|
338
|
+
export declare function generateOpenApiSpec({ title, version, description, prefix, services }: OpenApiOptions): Json$1;
|
|
339
|
+
type SecretInput = string | Redacted.Redacted<string> | SecretRef<string>;
|
|
340
|
+
/** One secret, or several so a secret can be rotated: any one that verifies accepts. A `Redacted` keeps it out of logs; a `SecretRef` (from `defineSecret`) is read at each delivery. */
|
|
341
|
+
type WebhookSecret = SecretInput | readonly SecretInput[];
|
|
342
|
+
interface HmacSignatureOptions {
|
|
343
|
+
/** The secret the provider signs with; a list accepts any of them, to rotate. */
|
|
344
|
+
secret: WebhookSecret;
|
|
345
|
+
/** The header that carries the signature, such as `x-hub-signature-256`. */
|
|
346
|
+
header: string;
|
|
347
|
+
/** What the header puts before the signature, such as `sha256=`. A header without it is refused. */
|
|
348
|
+
prefix?: string;
|
|
349
|
+
/** Default `"sha256"`. */
|
|
350
|
+
algorithm?: "sha1" | "sha256" | "sha384" | "sha512";
|
|
351
|
+
/** How the signature is written in the header: default `"hex"`. */
|
|
352
|
+
encoding?: "hex" | "base64";
|
|
353
|
+
}
|
|
354
|
+
/**
|
|
355
|
+
* Verifies an HMAC of the raw body, compared in constant time with a header.
|
|
356
|
+
* It signs the body alone and checks no timestamp. Give the webhook an
|
|
357
|
+
* `eventId`: it stops a replayed capture only when it comes from the signed body.
|
|
358
|
+
*
|
|
359
|
+
* @example
|
|
360
|
+
* verify: hmacSignature({ secret: hookSecret, header: "x-hub-signature-256", prefix: "sha256=" })
|
|
361
|
+
*/
|
|
362
|
+
export declare function hmacSignature(options: HmacSignatureOptions): WebhookVerifier;
|
|
363
|
+
interface StandardWebhooksOptions {
|
|
364
|
+
/** The `whsec_…` secret; a list accepts any of them, to rotate. */
|
|
365
|
+
secret: WebhookSecret;
|
|
366
|
+
/** How far the timestamp may be from now, either way. Default 5 minutes. */
|
|
367
|
+
toleranceMs?: number;
|
|
368
|
+
}
|
|
369
|
+
/**
|
|
370
|
+
* Verifies the Standard Webhooks scheme (standardwebhooks.com): a base64
|
|
371
|
+
* HMAC-SHA256 of `id.timestamp.body` in `webhook-signature`, as `v1,<signature>`
|
|
372
|
+
* entries separated by spaces, with the timestamp in `webhook-timestamp`.
|
|
373
|
+
* Svix's `svix-id`, `svix-timestamp` and `svix-signature` are read the same way.
|
|
374
|
+
* The id header is the event id, so the webhook needs no `eventId`.
|
|
375
|
+
*
|
|
376
|
+
* @example
|
|
377
|
+
* verify: standardWebhooks({ secret: billingSecret })
|
|
378
|
+
*/
|
|
379
|
+
export declare function standardWebhooks(options: StandardWebhooksOptions): WebhookVerifier;
|
|
380
|
+
interface TwilioSignatureOptions {
|
|
381
|
+
/** The account's auth token; a list accepts any of them, to rotate. */
|
|
382
|
+
authToken: WebhookSecret;
|
|
383
|
+
/**
|
|
384
|
+
* The URL Twilio called, exactly as Twilio signed it (the scheme, host,
|
|
385
|
+
* path and query). The server cannot know it behind a proxy, so the app says.
|
|
386
|
+
* Twilio drops the port from the URL it signs for HTTPS voice callbacks.
|
|
387
|
+
*/
|
|
388
|
+
url: string | ((request: WebhookRequest) => Effect.Effect<string>);
|
|
389
|
+
}
|
|
390
|
+
/**
|
|
391
|
+
* Verifies Twilio's `X-Twilio-Signature`: a base64 HMAC-SHA1, keyed with the
|
|
392
|
+
* auth token, of the URL followed by the form parameters sorted by name, each
|
|
393
|
+
* as name and value. For a JSON body, Twilio signs the URL alone and puts the
|
|
394
|
+
* body's SHA-256 (hex) in its `bodySHA256` query parameter, which is checked
|
|
395
|
+
* against the body. For a GET, it signs the URL alone, and a request whose
|
|
396
|
+
* query is not the signed URL's is refused. It supplies no event id: give the
|
|
397
|
+
* webhook an `eventId`.
|
|
398
|
+
*
|
|
399
|
+
* @example
|
|
400
|
+
* verify: twilioSignature({ authToken, url: "https://api.example.com/api/telephony/voice-status" })
|
|
401
|
+
*/
|
|
402
|
+
export declare function twilioSignature(options: TwilioSignatureOptions): WebhookVerifier;
|
|
403
|
+
declare const SocketDenied_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").VoidIfEmpty<{ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }>) => import("effect/Cause").YieldableError & {
|
|
404
|
+
readonly _tag: "SocketDenied";
|
|
405
|
+
} & Readonly<A>;
|
|
406
|
+
/** A socket refused the call: the upgrade, a message, or a join with a bad room. The connection is closed with 1008. */
|
|
407
|
+
export declare class SocketDenied extends SocketDenied_base {}
|
|
408
|
+
/** Delivers within this process. The default broker of every app. */
|
|
409
|
+
export declare function localBroker(): SocketBroker;
|
|
410
|
+
interface RedisBrokerOptions {
|
|
411
|
+
/** Defaults to `REDIS_URL`, then `redis://localhost:6379`. */
|
|
412
|
+
url?: string;
|
|
413
|
+
/** Emits held while Redis is unreachable; older ones are dropped. Default 1000. */
|
|
414
|
+
queue?: number;
|
|
415
|
+
}
|
|
416
|
+
/**
|
|
417
|
+
* Fans socket emits and kicks out across processes through Redis pub/sub, one
|
|
418
|
+
* channel per room topic. An emit is a PUBLISH only: every process, the emitting
|
|
419
|
+
* one included, delivers it once to its own connections. Uses Bun's built-in
|
|
420
|
+
* Redis client and two connections, one to publish and one to subscribe.
|
|
421
|
+
*/
|
|
422
|
+
export declare function redisBroker(options?: RedisBrokerOptions): SocketBroker;
|
|
423
|
+
/**
|
|
424
|
+
* Record an event of your own from an action, a tool or a hook. Listeners get it
|
|
425
|
+
* as they get a generated CRUD event, with the payload you give.
|
|
426
|
+
*
|
|
427
|
+
* The event is committed in a transaction of its own, unless you are inside one
|
|
428
|
+
* (`runInTransaction`, or drizzle's `db.transaction`): then it joins that one and
|
|
429
|
+
* is committed, or rolled back, with your writes. Nothing is recorded when no
|
|
430
|
+
* listener wants the event.
|
|
431
|
+
*
|
|
432
|
+
* Needs the app's `events` option. It fails as a defect when `ctx.db` is not the
|
|
433
|
+
* database of a service with an outbox table, when the app has no `events`, or
|
|
434
|
+
* when the payload does not match the schema of a declared event.
|
|
435
|
+
*
|
|
436
|
+
* @param ctx - The action context: its `db` finds the service's outbox, and its
|
|
437
|
+
* `traceId` follows the event to its listeners.
|
|
438
|
+
* @param event - A declared event, such as `orderEvents.shipped`, whose payload
|
|
439
|
+
* is typed and checked against its schema; or an event name such as
|
|
440
|
+
* `orders.refunded`.
|
|
441
|
+
* @param payload - JSON data for the listeners.
|
|
442
|
+
* @param options - `source`: what emitted it, shown to listeners.
|
|
443
|
+
* @example
|
|
444
|
+
* refund: orders.action({
|
|
445
|
+
* name: "refund",
|
|
446
|
+
* execute: ({ ctx, input }) =>
|
|
447
|
+
* Effect.gen(function* () {
|
|
448
|
+
* yield* ctx.db.update(orders).set({ status: "refunded" }).where(eq(orders.id, input.id));
|
|
449
|
+
* yield* emitEvent(ctx, orderEvents.refunded, { id: input.id });
|
|
450
|
+
* }),
|
|
451
|
+
* });
|
|
452
|
+
*/
|
|
453
|
+
export declare function emitEvent<TPayload>(ctx: {
|
|
454
|
+
db?: unknown;
|
|
455
|
+
traceId?: string;
|
|
456
|
+
}, event: EventRef<TPayload>, payload: NoInfer<TPayload>, options?: {
|
|
457
|
+
source?: string;
|
|
458
|
+
}): Effect.Effect<void>;
|
|
459
|
+
export declare function emitEvent(ctx: {
|
|
460
|
+
db?: unknown;
|
|
461
|
+
traceId?: string;
|
|
462
|
+
}, name: string, payload: unknown, options?: {
|
|
463
|
+
source?: string;
|
|
464
|
+
}): Effect.Effect<void>;
|
|
465
|
+
type EventOn = EventRef<any> | readonly EventRef<any>[];
|
|
466
|
+
type PayloadOf<O> = O extends EventRef<infer P> ? P : O extends readonly EventRef<infer P>[] ? P : never;
|
|
467
|
+
type ListenerConfig<TPayload, TOn = string | readonly string[], TErrors extends ErrorDefinitions = {}> = {
|
|
468
|
+
name: string;
|
|
469
|
+
on: TOn;
|
|
470
|
+
maxAttempts?: number;
|
|
471
|
+
/** Errors `run` may fail with through `error.CODE()`. */
|
|
472
|
+
errors?: TErrors;
|
|
473
|
+
/** Decides what a failure does next. Without it every failure retries until `maxAttempts`. */
|
|
474
|
+
retry?: (error: ListenerFailure<TErrors>) => RetryDecision;
|
|
475
|
+
} & ({
|
|
476
|
+
run: (delivery: EventDelivery<TPayload>, helpers: {
|
|
477
|
+
error: ErrorHelpers<TErrors>;
|
|
478
|
+
}) => Effect.Effect<void, unknown, any>;
|
|
479
|
+
workflow?: false;
|
|
480
|
+
} | {
|
|
481
|
+
/** `run` is a durable workflow: see `EventListener.workflow`. */
|
|
482
|
+
workflow: true;
|
|
483
|
+
run: (event: WorkflowEvent<TPayload>, helpers: {
|
|
484
|
+
error: ErrorHelpers<TErrors>;
|
|
485
|
+
}) => Effect.Effect<void, unknown, any>;
|
|
486
|
+
});
|
|
487
|
+
/**
|
|
488
|
+
* Define a listener: an Effect that runs for each event it listens for, after
|
|
489
|
+
* the write that caused the event has been committed. Pass it to
|
|
490
|
+
* `brick({ events: { listeners } })`.
|
|
491
|
+
*
|
|
492
|
+
* It runs in the process that delivers events, with the services of the app's
|
|
493
|
+
* layer. Delivery is at least once. A listener that fails is retried later with
|
|
494
|
+
* a growing delay, then parked as dead, so it can run again for the same event:
|
|
495
|
+
* use `delivery.deliveryId` to make its work idempotent.
|
|
496
|
+
*
|
|
497
|
+
* With `workflow: true`, `run` is a durable workflow on the app's
|
|
498
|
+
* `WorkflowEngine` (put `workflowEngine(database)` in the app's `layer`): it
|
|
499
|
+
* receives the delivery without `attempt`, may use `Activity`, `DurableClock`
|
|
500
|
+
* and `DurableDeferred`, and a restart resumes it where it stopped. A delivery
|
|
501
|
+
* counts as done once its run has started, and starts one run however often it
|
|
502
|
+
* is tried: the run is named after the delivery id. The workflow retries its
|
|
503
|
+
* own steps, so a failure of `run` is logged and does not retry the delivery.
|
|
504
|
+
*
|
|
505
|
+
* A listener can declare `errors`, as an action does, and fail with them through
|
|
506
|
+
* `error.CODE()`. `retry(error)` then picks `"retry"` or `"dead"` from the typed
|
|
507
|
+
* `error.code`; anything not declared arrives as `{ code: "UNKNOWN", cause }`.
|
|
508
|
+
*
|
|
509
|
+
* @param config - `name` (unique; it is part of each delivery's id), `on` (a
|
|
510
|
+
* declared event such as `orders.shipped`, which types the payload, or an event
|
|
511
|
+
* name; or a list of either; a trailing `*` matches a prefix, as in `user.*`),
|
|
512
|
+
* `run`, and optionally `maxAttempts`, `errors` and `retry`.
|
|
513
|
+
* @returns The listener.
|
|
514
|
+
* @throws When the name is empty or contains `:`, `on` is empty, or
|
|
515
|
+
* `maxAttempts` is not a positive integer.
|
|
516
|
+
* @example
|
|
517
|
+
* const welcome = defineListener({
|
|
518
|
+
* name: "welcome-email",
|
|
519
|
+
* on: "user.create",
|
|
520
|
+
* run: ({ payload, deliveryId }) =>
|
|
521
|
+
* Mailer.use((mailer) => mailer.sendWelcome(payload.email, deliveryId)),
|
|
522
|
+
* });
|
|
523
|
+
*
|
|
524
|
+
* export default brick({ services, layer, events: { listeners: [welcome] } });
|
|
525
|
+
*/
|
|
526
|
+
export declare function defineListener<const TOn extends EventOn, const TErrors extends ErrorDefinitions = {}>(config: ListenerConfig<PayloadOf<TOn>, TOn, TErrors>): EventListener<PayloadOf<TOn>>;
|
|
527
|
+
export declare function defineListener<TPayload = any, const TErrors extends ErrorDefinitions = {}>(config: ListenerConfig<TPayload, string | EventRef<any> | readonly (string | EventRef<any>)[], TErrors>): EventListener<TPayload>;
|
|
528
|
+
/**
|
|
529
|
+
* Run `fn` in a database transaction: everything it writes through `db` or the
|
|
530
|
+
* `tx` it is given is committed together when it returns, or undone if it
|
|
531
|
+
* fails. A transaction opened inside `fn` (by `runInTransaction`, `emitEvent` or
|
|
532
|
+
* drizzle's own `db.transaction`) joins it as a savepoint: a nested failure
|
|
533
|
+
* undoes only the nested work, and the outer transaction decides the commit.
|
|
534
|
+
* Both drivers keep one connection per transaction, so a write made elsewhere
|
|
535
|
+
* waits for it.
|
|
536
|
+
*
|
|
537
|
+
* @param db - A drizzle database, such as `ctx.db`.
|
|
538
|
+
* @param fn - Receives the transaction handle to run queries on.
|
|
539
|
+
*/
|
|
540
|
+
export declare const runInTransaction: <A, E, R>(db: any, fn: (tx: any) => Effect.Effect<A, E, R>) => Effect.Effect<A, E | unknown, R>;
|
|
541
|
+
/**
|
|
542
|
+
* Run `effect` once the transaction opened by `runInTransaction` has committed,
|
|
543
|
+
* or now when there is none. It never runs when that transaction, or the
|
|
544
|
+
* savepoint it was queued in, rolls back. A failure of it reaches the caller of
|
|
545
|
+
* the outermost `runInTransaction`, after the commit and after the other
|
|
546
|
+
* callbacks have run.
|
|
547
|
+
*/
|
|
548
|
+
export declare const onTransactionCommit: <E, R>(effect: Effect.Effect<void, E, R>) => Effect.Effect<void, E, R>;
|
|
549
|
+
/** Every filter operator: the `FilterOperator` type, validation and SQL all come from here. */
|
|
550
|
+
declare const OPERATORS: {
|
|
551
|
+
readonly eq: {
|
|
552
|
+
readonly operand: "one";
|
|
553
|
+
readonly build: (c: Column<import("drizzle-orm").ColumnBaseConfig<import("drizzle-orm").ColumnType>, object>, v: any, bind: (value: unknown) => any) => SQL<unknown>;
|
|
554
|
+
};
|
|
555
|
+
readonly ne: {
|
|
556
|
+
readonly operand: "one";
|
|
557
|
+
readonly build: (c: Column<import("drizzle-orm").ColumnBaseConfig<import("drizzle-orm").ColumnType>, object>, v: any, bind: (value: unknown) => any) => SQL<unknown>;
|
|
558
|
+
};
|
|
559
|
+
readonly in: {
|
|
560
|
+
readonly operand: "list";
|
|
561
|
+
readonly build: (c: Column<import("drizzle-orm").ColumnBaseConfig<import("drizzle-orm").ColumnType>, object>, v: any, bind: (value: unknown) => any) => SQL<unknown>;
|
|
562
|
+
};
|
|
563
|
+
readonly notIn: {
|
|
564
|
+
readonly operand: "list";
|
|
565
|
+
readonly build: (c: Column<import("drizzle-orm").ColumnBaseConfig<import("drizzle-orm").ColumnType>, object>, v: any, bind: (value: unknown) => any) => SQL<unknown>;
|
|
566
|
+
};
|
|
567
|
+
readonly gt: {
|
|
568
|
+
readonly operand: "one";
|
|
569
|
+
readonly ordered: true;
|
|
570
|
+
readonly build: (c: Column<import("drizzle-orm").ColumnBaseConfig<import("drizzle-orm").ColumnType>, object>, v: any, bind: (value: unknown) => any) => SQL<unknown>;
|
|
571
|
+
};
|
|
572
|
+
readonly gte: {
|
|
573
|
+
readonly operand: "one";
|
|
574
|
+
readonly ordered: true;
|
|
575
|
+
readonly build: (c: Column<import("drizzle-orm").ColumnBaseConfig<import("drizzle-orm").ColumnType>, object>, v: any, bind: (value: unknown) => any) => SQL<unknown>;
|
|
576
|
+
};
|
|
577
|
+
readonly lt: {
|
|
578
|
+
readonly operand: "one";
|
|
579
|
+
readonly ordered: true;
|
|
580
|
+
readonly build: (c: Column<import("drizzle-orm").ColumnBaseConfig<import("drizzle-orm").ColumnType>, object>, v: any, bind: (value: unknown) => any) => SQL<unknown>;
|
|
581
|
+
};
|
|
582
|
+
readonly lte: {
|
|
583
|
+
readonly operand: "one";
|
|
584
|
+
readonly ordered: true;
|
|
585
|
+
readonly build: (c: Column<import("drizzle-orm").ColumnBaseConfig<import("drizzle-orm").ColumnType>, object>, v: any, bind: (value: unknown) => any) => SQL<unknown>;
|
|
586
|
+
};
|
|
587
|
+
readonly between: {
|
|
588
|
+
readonly operand: "pair";
|
|
589
|
+
readonly ordered: true;
|
|
590
|
+
readonly build: (c: Column<import("drizzle-orm").ColumnBaseConfig<import("drizzle-orm").ColumnType>, object>, v: any, bind: (value: unknown) => any) => SQL<unknown>;
|
|
591
|
+
};
|
|
592
|
+
readonly contains: {
|
|
593
|
+
readonly operand: "one";
|
|
594
|
+
readonly text: true;
|
|
595
|
+
readonly build: (c: Column<import("drizzle-orm").ColumnBaseConfig<import("drizzle-orm").ColumnType>, object>, v: any, bind: (value: unknown) => any) => SQL<unknown>;
|
|
596
|
+
};
|
|
597
|
+
readonly startsWith: {
|
|
598
|
+
readonly operand: "one";
|
|
599
|
+
readonly text: true;
|
|
600
|
+
readonly build: (c: Column<import("drizzle-orm").ColumnBaseConfig<import("drizzle-orm").ColumnType>, object>, v: any, bind: (value: unknown) => any) => SQL<unknown>;
|
|
601
|
+
};
|
|
602
|
+
readonly endsWith: {
|
|
603
|
+
readonly operand: "one";
|
|
604
|
+
readonly text: true;
|
|
605
|
+
readonly build: (c: Column<import("drizzle-orm").ColumnBaseConfig<import("drizzle-orm").ColumnType>, object>, v: any, bind: (value: unknown) => any) => SQL<unknown>;
|
|
606
|
+
};
|
|
607
|
+
readonly isNull: {
|
|
608
|
+
readonly operand: "none";
|
|
609
|
+
readonly build: (c: Column<import("drizzle-orm").ColumnBaseConfig<import("drizzle-orm").ColumnType>, object>) => SQL<unknown>;
|
|
610
|
+
};
|
|
611
|
+
readonly isNotNull: {
|
|
612
|
+
readonly operand: "none";
|
|
613
|
+
readonly build: (c: Column<import("drizzle-orm").ColumnBaseConfig<import("drizzle-orm").ColumnType>, object>) => SQL<unknown>;
|
|
614
|
+
};
|
|
615
|
+
};
|
|
616
|
+
type FilterOperator = keyof typeof OPERATORS;
|
|
617
|
+
/** One column of the table, and what a caller may do with it. Nothing is allowed until it says so. */
|
|
618
|
+
interface ColumnFieldPolicy<TCtx = any> {
|
|
619
|
+
read?: boolean;
|
|
620
|
+
create?: boolean;
|
|
621
|
+
update?: boolean;
|
|
622
|
+
filter?: readonly FilterOperator[];
|
|
623
|
+
sort?: boolean;
|
|
624
|
+
/** The JSON value of the field. It replaces the schema the column gives. */
|
|
625
|
+
schema?: AnySchema;
|
|
626
|
+
resolve?: never;
|
|
627
|
+
/** Replaces the value a caller reads, per row. */
|
|
628
|
+
scrub?: (args: {
|
|
629
|
+
value: any;
|
|
630
|
+
ctx: TCtx;
|
|
631
|
+
}) => Effect.Effect<unknown, any, any>;
|
|
632
|
+
}
|
|
633
|
+
/** A field with no column: computed for the authorized rows, and read only when `include` asks. */
|
|
634
|
+
interface DerivedFieldPolicy<TCtx = any> {
|
|
635
|
+
read: true;
|
|
636
|
+
schema: AnySchema;
|
|
637
|
+
/** One value per authorized parent row, in the same order. */
|
|
638
|
+
resolve: (args: {
|
|
639
|
+
rows: readonly Readonly<Record<string, unknown>>[];
|
|
640
|
+
ctx: TCtx;
|
|
641
|
+
}) => Effect.Effect<readonly unknown[], any, any>;
|
|
642
|
+
create?: false;
|
|
643
|
+
update?: false;
|
|
644
|
+
filter?: readonly [];
|
|
645
|
+
sort?: false;
|
|
646
|
+
scrub?: ColumnFieldPolicy<TCtx>["scrub"];
|
|
647
|
+
}
|
|
648
|
+
type FieldPolicy<TCtx = any> = ColumnFieldPolicy<TCtx> | DerivedFieldPolicy<TCtx>;
|
|
649
|
+
type Fields<TCtx = any> = Readonly<Record<string, FieldPolicy<TCtx>>>;
|
|
650
|
+
type Operation = "list" | "get" | "create" | "update" | "delete" | "findOne" | "count" | "exists";
|
|
651
|
+
/** Batch writes. Off unless `operations` sets them to `true`. */
|
|
652
|
+
type BulkOperation = "bulkCreate" | "bulkUpdate" | "bulkDelete";
|
|
653
|
+
type Operations = false | Partial<Record<Operation | BulkOperation, boolean>>;
|
|
654
|
+
/** The table of a resource, as hooks see it. */
|
|
655
|
+
interface CrudResource {
|
|
656
|
+
readonly name: string;
|
|
657
|
+
readonly table: Table;
|
|
658
|
+
readonly id: Column;
|
|
659
|
+
readonly idField: string;
|
|
660
|
+
}
|
|
661
|
+
interface HookBase<TCtx> {
|
|
662
|
+
ctx: TCtx;
|
|
663
|
+
error: ErrorHelpers<{}>;
|
|
664
|
+
/** The write's open transaction: write other tables through it. */
|
|
665
|
+
tx: any;
|
|
666
|
+
resource: CrudResource;
|
|
667
|
+
}
|
|
668
|
+
/** What `afterCommit` receives for each written row. */
|
|
669
|
+
type CrudCommitArgs<TCtx> = {
|
|
670
|
+
id: unknown;
|
|
671
|
+
ctx: TCtx;
|
|
672
|
+
} & ({
|
|
673
|
+
operation: "create" | "update";
|
|
674
|
+
row: Record<string, unknown>;
|
|
675
|
+
} | {
|
|
676
|
+
operation: "delete";
|
|
677
|
+
row?: undefined;
|
|
678
|
+
});
|
|
679
|
+
type HookResult$1<R> = Effect.Effect<unknown, any, R>;
|
|
680
|
+
/**
|
|
681
|
+
* Write hooks run inside the operation's transaction, once per row (bulk
|
|
682
|
+
* operations included): a hook that fails rolls the whole operation back.
|
|
683
|
+
* `afterCommit` runs after the commit, for side effects that must not happen
|
|
684
|
+
* when the write is undone; a failure of it is logged, not returned.
|
|
685
|
+
*/
|
|
686
|
+
interface CrudHooks<TCtx = any> {
|
|
687
|
+
beforeCreate?: (args: HookBase<TCtx> & {
|
|
688
|
+
data: Record<string, unknown>;
|
|
689
|
+
}) => HookResult$1<any>;
|
|
690
|
+
afterCreate?: (args: HookBase<TCtx> & {
|
|
691
|
+
row: Record<string, unknown>;
|
|
692
|
+
}) => HookResult$1<any>;
|
|
693
|
+
beforeUpdate?: (args: HookBase<TCtx> & {
|
|
694
|
+
id: unknown;
|
|
695
|
+
data: Record<string, unknown>;
|
|
696
|
+
}) => HookResult$1<any>;
|
|
697
|
+
afterUpdate?: (args: HookBase<TCtx> & {
|
|
698
|
+
id: unknown;
|
|
699
|
+
row: Record<string, unknown>;
|
|
700
|
+
}) => HookResult$1<any>;
|
|
701
|
+
beforeDelete?: (args: HookBase<TCtx> & {
|
|
702
|
+
id: unknown;
|
|
703
|
+
}) => HookResult$1<any>;
|
|
704
|
+
afterDelete?: (args: HookBase<TCtx> & {
|
|
705
|
+
id: unknown;
|
|
706
|
+
}) => HookResult$1<any>;
|
|
707
|
+
afterCommit?: (args: CrudCommitArgs<TCtx>) => HookResult$1<any>;
|
|
708
|
+
}
|
|
709
|
+
type Keys<F, P extends string> = { [K in keyof F]: F[K] extends Record<P, true> ? K : never; }[keyof F];
|
|
710
|
+
type IncludeKeys<F> = { [K in keyof F]: F[K] extends {
|
|
711
|
+
resolve: (...args: any[]) => any;
|
|
712
|
+
schema: AnySchema;
|
|
713
|
+
} ? K : never; }[keyof F];
|
|
714
|
+
type AllowedOps<F, K extends keyof F> = F[K] extends {
|
|
715
|
+
filter: readonly (infer O)[];
|
|
716
|
+
} ? O : never;
|
|
717
|
+
type Row<T extends Table> = InferSelectModel<T>;
|
|
718
|
+
type Insert<T extends Table> = InferInsertModel<T>;
|
|
719
|
+
type JsonOf<V> = V extends Date ? string : V extends bigint ? string : V;
|
|
720
|
+
type ReadKeys<T extends Table, F> = Extract<Keys<F, "read">, keyof Row<T>>;
|
|
721
|
+
type FieldValue<T extends Table, F, K extends keyof F> = F[K] extends {
|
|
722
|
+
schema: infer S extends AnySchema;
|
|
723
|
+
} ? S["Type"] : F[K] extends {
|
|
724
|
+
scrub: (...args: any[]) => Effect.Effect<infer V, any, any>;
|
|
725
|
+
} ? V : K extends keyof Row<T> ? JsonOf<Row<T>[K]> : never;
|
|
726
|
+
/** A row as `read: true` fields show it. */
|
|
727
|
+
type ReadRow<T extends Table, F> = { [K in ReadKeys<T, F>]: FieldValue<T, F, K>; };
|
|
728
|
+
type IncludedRow<T extends Table, F, I> = I extends readonly (infer K)[] ? { [P in Extract<K, IncludeKeys<F> & keyof F>]: FieldValue<T, F, P>; } : {};
|
|
729
|
+
type WriteKeys<T extends Table, F, P extends string> = Extract<Keys<F, P>, keyof Insert<T>>;
|
|
730
|
+
type WriteRow<T extends Table, F, P extends string> = { [K in WriteKeys<T, F, P>]: K extends keyof F ? F[K] extends {
|
|
731
|
+
schema: infer S extends AnySchema;
|
|
732
|
+
} ? S["Type"] : JsonOf<Insert<T>[K]> : never; };
|
|
733
|
+
type Operand<V, O extends FilterOperator> = {
|
|
734
|
+
none: {};
|
|
735
|
+
one: {
|
|
736
|
+
value: NonNullable<V>;
|
|
737
|
+
};
|
|
738
|
+
list: {
|
|
739
|
+
value: readonly NonNullable<V>[];
|
|
740
|
+
};
|
|
741
|
+
pair: {
|
|
742
|
+
value: readonly [NonNullable<V>, NonNullable<V>];
|
|
743
|
+
};
|
|
744
|
+
}[(typeof OPERATORS)[O]["operand"]];
|
|
745
|
+
type Leaf<F, V> = { [K in Extract<keyof F, keyof V>]: { [O in Extract<AllowedOps<F, K>, FilterOperator>]: {
|
|
746
|
+
field: K;
|
|
747
|
+
op: O;
|
|
748
|
+
} & Operand<V[K], O>; }[Extract<AllowedOps<F, K>, FilterOperator>]; }[Extract<keyof F, keyof V>];
|
|
749
|
+
type FilterWhere<F, V> = Leaf<F, V> | {
|
|
750
|
+
and: readonly FilterWhere<F, V>[];
|
|
751
|
+
} | {
|
|
752
|
+
or: readonly FilterWhere<F, V>[];
|
|
753
|
+
};
|
|
754
|
+
type Where<T extends Table, F> = FilterWhere<F, Row<T>>;
|
|
755
|
+
interface Query<T extends Table, F, S extends readonly ReadKeys<T, F>[] | undefined = undefined, I extends readonly IncludeKeys<F>[] | undefined = undefined> {
|
|
756
|
+
select?: S;
|
|
757
|
+
include?: I;
|
|
758
|
+
where?: Where<T, F>;
|
|
759
|
+
orderBy?: readonly {
|
|
760
|
+
field: Extract<Keys<F, "sort">, keyof Row<T>>;
|
|
761
|
+
direction: "asc" | "desc";
|
|
762
|
+
}[];
|
|
763
|
+
limit?: number;
|
|
764
|
+
offset?: number;
|
|
765
|
+
includeTotal?: boolean;
|
|
766
|
+
}
|
|
767
|
+
/** `list` input: a query, plus keyset pagination. */
|
|
768
|
+
type ListQuery<T extends Table, F, S extends readonly ReadKeys<T, F>[] | undefined = undefined, I extends readonly IncludeKeys<F>[] | undefined = undefined> = Query<T, F, S, I> & {
|
|
769
|
+
/** `null` for the first page, then the previous page's `nextCursor`. */
|
|
770
|
+
cursor?: string | null;
|
|
771
|
+
};
|
|
772
|
+
type KindQuery<T extends Table, F, S, I, Kind> = Kind extends "list" ? ListQuery<T, F, Extract<S, readonly ReadKeys<T, F>[] | undefined>, Extract<I, readonly IncludeKeys<F>[] | undefined>> : Query<T, F, Extract<S, readonly ReadKeys<T, F>[] | undefined>, Extract<I, readonly IncludeKeys<F>[] | undefined>>;
|
|
773
|
+
type AuthorizeKeys<F, P extends string> = string extends keyof F ? keyof F : Keys<F, P>;
|
|
774
|
+
type AuthorizeValues<F> = { [K in keyof F]: F[K] extends {
|
|
775
|
+
schema: infer S extends AnySchema;
|
|
776
|
+
} ? S["Type"] : unknown; };
|
|
777
|
+
type AuthorizeWrite<F, P extends string> = { [K in Extract<AuthorizeKeys<F, P>, keyof F>]?: AuthorizeValues<F>[K]; };
|
|
778
|
+
type AuthorizeQuery<F> = {
|
|
779
|
+
select?: readonly Exclude<AuthorizeKeys<F, "read">, IncludeKeys<F>>[];
|
|
780
|
+
include?: readonly IncludeKeys<F>[];
|
|
781
|
+
where?: string extends keyof F ? FilterWhere<Record<string, {
|
|
782
|
+
filter: readonly FilterOperator[];
|
|
783
|
+
}>, Record<string, unknown>> : FilterWhere<F, AuthorizeValues<F>>;
|
|
784
|
+
orderBy?: readonly {
|
|
785
|
+
field: AuthorizeKeys<F, "sort">;
|
|
786
|
+
direction: "asc" | "desc";
|
|
787
|
+
}[];
|
|
788
|
+
limit?: number;
|
|
789
|
+
offset?: number;
|
|
790
|
+
includeTotal?: boolean;
|
|
791
|
+
};
|
|
792
|
+
/** Validated authorization inputs, indexed by CRUD operation. */
|
|
793
|
+
type CrudInputs<F extends Fields = Fields> = {
|
|
794
|
+
list: { [K in keyof AuthorizeQuery<F>]: AuthorizeQuery<F>[K]; } & {
|
|
795
|
+
cursor?: string | null;
|
|
796
|
+
};
|
|
797
|
+
findOne: { [K in keyof AuthorizeQuery<F>]: AuthorizeQuery<F>[K]; };
|
|
798
|
+
get: {
|
|
799
|
+
id: unknown;
|
|
800
|
+
select?: readonly Exclude<AuthorizeKeys<F, "read">, IncludeKeys<F>>[];
|
|
801
|
+
include?: readonly IncludeKeys<F>[];
|
|
802
|
+
};
|
|
803
|
+
create: AuthorizeWrite<F, "create">;
|
|
804
|
+
update: {
|
|
805
|
+
id: unknown;
|
|
806
|
+
data: AuthorizeWrite<F, "update">;
|
|
807
|
+
};
|
|
808
|
+
delete: {
|
|
809
|
+
id: unknown;
|
|
810
|
+
};
|
|
811
|
+
count: {
|
|
812
|
+
where?: AuthorizeQuery<F>["where"];
|
|
813
|
+
};
|
|
814
|
+
exists: {
|
|
815
|
+
where?: AuthorizeQuery<F>["where"];
|
|
816
|
+
};
|
|
817
|
+
};
|
|
818
|
+
/** Narrow operation and input together in an `authorize` callback. */
|
|
819
|
+
type CrudAuthorizeArgs<F extends Fields = Fields, TCtx = any> = { [K in Operation]: {
|
|
820
|
+
operation: K;
|
|
821
|
+
input: CrudInputs<F>[K];
|
|
822
|
+
ctx: TCtx;
|
|
823
|
+
}; }[Operation];
|
|
824
|
+
/** Who may do what: `"public"`, or `authorize` (a call is refused unless it returns true) and `scope` (the rows a call can see). */
|
|
825
|
+
interface CrudAccess<F extends Fields = Fields, TCtx = any> {
|
|
826
|
+
authorize?: (args: CrudAuthorizeArgs<F, TCtx>) => Effect.Effect<boolean, any, any>;
|
|
827
|
+
/** A condition every statement of the call carries. A create takes none. */
|
|
828
|
+
scope?: (args: {
|
|
829
|
+
operation: Operation;
|
|
830
|
+
ctx: TCtx;
|
|
831
|
+
}) => Effect.Effect<SQL | undefined, any, any>;
|
|
832
|
+
}
|
|
833
|
+
interface CrudOptions<T extends Table, TCtx, F extends Fields<TCtx>, O extends Operations, A extends CrudAccess<F, TCtx>, H extends CrudHooks<TCtx>, TId extends Column | undefined> {
|
|
834
|
+
/** The resource's name: its routes are under `/<service>/<name>` and its actions are `<name>.<operation>`. */
|
|
835
|
+
name: string;
|
|
836
|
+
table: T;
|
|
837
|
+
/** The id column (default: the table's only primary key). */
|
|
838
|
+
id?: TId;
|
|
839
|
+
fields: F;
|
|
840
|
+
/** Switch operations off, or the batch ones on. `false` creates nothing. */
|
|
841
|
+
operations?: O;
|
|
842
|
+
defaultLimit?: number;
|
|
843
|
+
maxLimit?: number;
|
|
844
|
+
/** Most items one bulk call accepts. Default 100. */
|
|
845
|
+
maxBatchSize?: number;
|
|
846
|
+
/** Deny by default: `"public"`, or an `authorize` that allows. */
|
|
847
|
+
access: "public" | A;
|
|
848
|
+
hooks?: H;
|
|
849
|
+
/**
|
|
850
|
+
* Move or switch off routes, by operation name: `{ list: { path: "/search" },
|
|
851
|
+
* delete: false }`. `false` switches them all off. A route that is off still
|
|
852
|
+
* has its action, callable in-process. A route may also change `scope`:
|
|
853
|
+
* `"service"` mounts it under the service, `"app"` under the app prefix.
|
|
854
|
+
*/
|
|
855
|
+
routes?: PluginRoutes;
|
|
856
|
+
/**
|
|
857
|
+
* Whether a create, update or delete records a `<name>.create`, `.update` or
|
|
858
|
+
* `.delete` event in the same transaction, when the database has an outbox
|
|
859
|
+
* table and a listener wants it. Default true.
|
|
860
|
+
*/
|
|
861
|
+
events?: boolean;
|
|
862
|
+
}
|
|
863
|
+
/** The services a callback needs. A callback that was not given reads as `any` (the constraint), which needs none. */
|
|
864
|
+
type Req<T> = T extends ((...args: any[]) => Effect.Effect<any, any, infer R>) ? 0 extends 1 & R ? never : R : never;
|
|
865
|
+
type CallbackReq<T> = { [K in keyof T]-?: Req<NonNullable<T[K]>>; }[keyof T];
|
|
866
|
+
type FieldReq<F> = { [K in keyof F]: (F[K] extends {
|
|
867
|
+
scrub: infer S;
|
|
868
|
+
} ? Req<S> : never) | (F[K] extends {
|
|
869
|
+
resolve: infer S;
|
|
870
|
+
} ? Req<S> : never); }[keyof F];
|
|
871
|
+
/** The services the callbacks of the options need. */
|
|
872
|
+
type CrudRequirements<F, A, H> = FieldReq<F> | (A extends object ? CallbackReq<A> : never) | (H extends object ? CallbackReq<H> : never);
|
|
873
|
+
type Failure = BrickError | ValidationError;
|
|
874
|
+
type CrudCall<I, O, R> = Omit<AnyAction, "run" | "execute"> & {
|
|
875
|
+
run(input: I, ctx?: CallContext): Effect.Effect<O, Failure, R>;
|
|
876
|
+
execute(params: {
|
|
877
|
+
input?: I;
|
|
878
|
+
ctx?: CallContext;
|
|
879
|
+
wire?: "json" | "query";
|
|
880
|
+
}): Effect.Effect<O, Failure, R>;
|
|
881
|
+
};
|
|
882
|
+
type ListResult<R> = {
|
|
883
|
+
items: R[];
|
|
884
|
+
total?: number;
|
|
885
|
+
limit: number;
|
|
886
|
+
offset: number;
|
|
887
|
+
nextCursor?: string | null;
|
|
888
|
+
};
|
|
889
|
+
type QueryResult<Kind, R> = Kind extends "list" ? ListResult<R> : R | null;
|
|
890
|
+
type Selected<T extends Table, F, S, I = undefined> = (S extends readonly (infer K)[] ? Pick<ReadRow<T, F>, Extract<K, keyof ReadRow<T, F>>> : ReadRow<T, F>) & IncludedRow<T, F, I>;
|
|
891
|
+
/** `list` and `findOne`: `select` and `include` narrow the rows they return. */
|
|
892
|
+
interface QueryAction<T extends Table, F, Kind extends "list" | "findOne", R> extends Omit<AnyAction, "run" | "execute"> {
|
|
893
|
+
run<const S extends readonly ReadKeys<T, F>[] | undefined = undefined, const I extends readonly IncludeKeys<F>[] | undefined = undefined>(input: KindQuery<T, F, S, I, Kind>, ctx?: CallContext): Effect.Effect<QueryResult<Kind, Selected<T, F, S, I>>, Failure, R>;
|
|
894
|
+
execute<const S extends readonly ReadKeys<T, F>[] | undefined = undefined, const I extends readonly IncludeKeys<F>[] | undefined = undefined>(params: {
|
|
895
|
+
input?: KindQuery<T, F, S, I, Kind>;
|
|
896
|
+
ctx?: CallContext;
|
|
897
|
+
wire?: "json" | "query";
|
|
898
|
+
}): Effect.Effect<QueryResult<Kind, Selected<T, F, S, I>>, Failure, R>;
|
|
899
|
+
}
|
|
900
|
+
interface GetAction<T extends Table, F, ID, R> extends Omit<AnyAction, "run" | "execute"> {
|
|
901
|
+
run<const S extends readonly ReadKeys<T, F>[] | undefined = undefined, const I extends readonly IncludeKeys<F>[] | undefined = undefined>(input: {
|
|
902
|
+
id: ID;
|
|
903
|
+
select?: S;
|
|
904
|
+
include?: I;
|
|
905
|
+
}, ctx?: CallContext): Effect.Effect<Selected<T, F, S, I>, Failure, R>;
|
|
906
|
+
execute<const S extends readonly ReadKeys<T, F>[] | undefined = undefined, const I extends readonly IncludeKeys<F>[] | undefined = undefined>(params: {
|
|
907
|
+
input?: {
|
|
908
|
+
id: ID;
|
|
909
|
+
select?: S;
|
|
910
|
+
include?: I;
|
|
911
|
+
};
|
|
912
|
+
ctx?: CallContext;
|
|
913
|
+
wire?: "json" | "query";
|
|
914
|
+
}): Effect.Effect<Selected<T, F, S, I>, Failure, R>;
|
|
915
|
+
}
|
|
916
|
+
type AllAPI<T extends Table, F, ID, R> = {
|
|
917
|
+
list: QueryAction<T, F, "list", R>;
|
|
918
|
+
findOne: QueryAction<T, F, "findOne", R>;
|
|
919
|
+
get: GetAction<T, F, ID, R>;
|
|
920
|
+
create: CrudCall<WriteRow<T, F, "create">, ReadRow<T, F>, R>;
|
|
921
|
+
update: CrudCall<{
|
|
922
|
+
id: ID;
|
|
923
|
+
data: Partial<WriteRow<T, F, "update">>;
|
|
924
|
+
}, ReadRow<T, F>, R>;
|
|
925
|
+
delete: CrudCall<{
|
|
926
|
+
id: ID;
|
|
927
|
+
}, {
|
|
928
|
+
success: true;
|
|
929
|
+
}, R>;
|
|
930
|
+
count: CrudCall<{
|
|
931
|
+
where?: Where<T, F>;
|
|
932
|
+
}, {
|
|
933
|
+
count: number;
|
|
934
|
+
}, R>;
|
|
935
|
+
exists: CrudCall<{
|
|
936
|
+
where?: Where<T, F>;
|
|
937
|
+
}, {
|
|
938
|
+
exists: boolean;
|
|
939
|
+
}, R>;
|
|
940
|
+
bulkCreate: CrudCall<{
|
|
941
|
+
items: WriteRow<T, F, "create">[];
|
|
942
|
+
}, {
|
|
943
|
+
items: ReadRow<T, F>[];
|
|
944
|
+
}, R>;
|
|
945
|
+
bulkUpdate: CrudCall<{
|
|
946
|
+
items: {
|
|
947
|
+
id: ID;
|
|
948
|
+
data: Partial<WriteRow<T, F, "update">>;
|
|
949
|
+
}[];
|
|
950
|
+
}, {
|
|
951
|
+
items: ReadRow<T, F>[];
|
|
952
|
+
}, R>;
|
|
953
|
+
bulkDelete: CrudCall<{
|
|
954
|
+
ids: ID[];
|
|
955
|
+
}, {
|
|
956
|
+
count: number;
|
|
957
|
+
}, R>;
|
|
958
|
+
};
|
|
959
|
+
/** The actions `crud` declares: those `operations` leaves on, batch ones only when asked for. */
|
|
960
|
+
type CrudAPI<T extends Table, F, O, ID, R> = [O] extends [false] ? {} : Pick<AllAPI<T, F, ID, R>, { [K in Operation]: O extends Record<K, false> ? never : K; }[Operation] | { [K in BulkOperation]: O extends Record<K, true> ? K : never; }[BulkOperation]>;
|
|
961
|
+
type IdOf<TId> = TId extends Column ? GetColumnData<TId, "raw"> : string | number;
|
|
962
|
+
/**
|
|
963
|
+
* Give a table its CRUD actions on a service: `list`, `get`, `create`,
|
|
964
|
+
* `update`, `delete`, `findOne`, `count` and `exists`, with validated input and
|
|
965
|
+
* output, filters and sorting, paging, and access rules. The actions are named
|
|
966
|
+
* `<name>.<operation>` and routed under `/<service>/<name>`:
|
|
967
|
+
* `POST /query`, `GET /:id`, `POST /`, `PATCH /:id`, `DELETE /:id`,
|
|
968
|
+
* `POST /find-one`, `/count` and `/exists`, and `POST /bulk-create`,
|
|
969
|
+
* `/bulk-update` and `/bulk-delete` when `operations` turns them on.
|
|
970
|
+
*
|
|
971
|
+
* It denies by default: `access` is required. A column is hidden from reads,
|
|
972
|
+
* writes and filters until its `fields` entry allows it.
|
|
973
|
+
*
|
|
974
|
+
* @param service - A service with a database.
|
|
975
|
+
* @param options - `fields` (per column: `read`, `create`, `update`, `filter`
|
|
976
|
+
* operators, `sort`, and `schema`, `scrub` and `resolve`), `access` (`"public"`,
|
|
977
|
+
* or `{ authorize, scope }`), `operations` to switch some off, `hooks` around
|
|
978
|
+
* writes, and `defaultLimit`, `maxLimit` and `maxBatchSize`.
|
|
979
|
+
* @returns The actions, which run in-process with `action.run`.
|
|
980
|
+
* @throws When a field is unknown, a filter does not fit its column, or the
|
|
981
|
+
* resource has no id column.
|
|
982
|
+
* @example
|
|
983
|
+
* export const page = crud(pages, {
|
|
984
|
+
* name: "page",
|
|
985
|
+
* table: tables.pages,
|
|
986
|
+
* access: "public",
|
|
987
|
+
* fields: {
|
|
988
|
+
* id: { read: true, filter: ["eq", "in"] },
|
|
989
|
+
* title: { read: true, create: true, update: true, sort: true },
|
|
990
|
+
* },
|
|
991
|
+
* });
|
|
992
|
+
* const created = yield* page.create.run({ title: "Hello" });
|
|
993
|
+
*/
|
|
994
|
+
export declare function crud<TCtx extends {
|
|
995
|
+
db: any;
|
|
996
|
+
}, TReq, T extends Table, const F extends Fields<TCtx>, A extends CrudAccess<F, TCtx>, H extends CrudHooks<TCtx>, const O extends Operations = {}, TId extends Column | undefined = undefined>(service: Service<string, TCtx, TReq>, options: CrudOptions<T, TCtx, F, O, A, H, TId>): CrudAPI<T, F, O, IdOf<TId>, TReq | CrudRequirements<F, A, H>>;
|
|
997
|
+
type Json = Record<string, any>;
|
|
998
|
+
interface McpToolDefinition {
|
|
999
|
+
name: string;
|
|
1000
|
+
title?: string;
|
|
1001
|
+
description: string;
|
|
1002
|
+
/** The JSON Schema of the tool's `input`. */
|
|
1003
|
+
inputSchema: Json;
|
|
1004
|
+
/** The JSON Schema of the tool's `output`; a non-object one is wrapped as `{ result }`. */
|
|
1005
|
+
outputSchema?: Json;
|
|
1006
|
+
annotations: ToolAnnotations;
|
|
1007
|
+
}
|
|
1008
|
+
interface McpRegistryOptions {
|
|
1009
|
+
services?: readonly Pick<AnyService, "listTools">[];
|
|
1010
|
+
tools?: readonly AnyTool[];
|
|
1011
|
+
}
|
|
1012
|
+
interface McpRegistry<R = any> {
|
|
1013
|
+
listTools(): McpToolDefinition[];
|
|
1014
|
+
/** Runs the tool as an MCP client would: arguments are JSON, and the result is its JSON form. */
|
|
1015
|
+
callTool(name: string, args?: Record<string, unknown>, ctx?: CallContext): Effect.Effect<unknown, BrickError | ValidationError | UnknownToolError, R>;
|
|
1016
|
+
}
|
|
1017
|
+
export declare class UnknownToolError extends Error {
|
|
1018
|
+
readonly name = "UnknownToolError";
|
|
1019
|
+
constructor(name: string);
|
|
1020
|
+
}
|
|
1021
|
+
/** Collect only explicitly defined tools, without exposing ordinary actions. */
|
|
1022
|
+
export declare function createMcpRegistry(options: McpRegistryOptions): McpRegistry;
|
|
1023
|
+
interface McpHandlerOptions<R = any> {
|
|
1024
|
+
registry: McpRegistry<R>;
|
|
1025
|
+
serverInfo: {
|
|
1026
|
+
name: string;
|
|
1027
|
+
version: string;
|
|
1028
|
+
title?: string;
|
|
1029
|
+
};
|
|
1030
|
+
/** Versions supported by this transport, newest first. */
|
|
1031
|
+
protocolVersions?: readonly string[];
|
|
1032
|
+
}
|
|
1033
|
+
/**
|
|
1034
|
+
* A stateless MCP JSON-RPC handler over HTTP POST. It does no authentication:
|
|
1035
|
+
* wrap it with your own, and pass what the tools should see in `ctx` (the
|
|
1036
|
+
* `request` is added).
|
|
1037
|
+
*/
|
|
1038
|
+
export declare function createMcpHandler<R = any>(options: McpHandlerOptions<R>): (request: Request, ctx?: CallContext) => Effect.Effect<Response, never, R>;
|
|
1039
|
+
/**
|
|
1040
|
+
* Define a plugin that installs onto a service with `service.use(plugin)`. Its
|
|
1041
|
+
* `setup` receives the service and a `routes` registrar for adding actions and
|
|
1042
|
+
* raw HTTP endpoints, and returns the typed API that `service.use` hands back.
|
|
1043
|
+
*
|
|
1044
|
+
* @param definition - A unique `name`, optional `routes` controls that let the
|
|
1045
|
+
* user move or switch off the plugin's routes, and `setup`, which must be
|
|
1046
|
+
* synchronous.
|
|
1047
|
+
* @returns The plugin descriptor, frozen.
|
|
1048
|
+
* @throws When the name is empty or has surrounding whitespace.
|
|
1049
|
+
* @example
|
|
1050
|
+
* export const greeting = (salutation = "Hello") =>
|
|
1051
|
+
* defineServicePlugin({
|
|
1052
|
+
* name: "example/greeting",
|
|
1053
|
+
* setup({ routes }) {
|
|
1054
|
+
* const hello = routes.action({
|
|
1055
|
+
* name: "hello",
|
|
1056
|
+
* method: "POST",
|
|
1057
|
+
* path: "/hello",
|
|
1058
|
+
* input: Schema.Struct({ name: Schema.String }),
|
|
1059
|
+
* output: Schema.String,
|
|
1060
|
+
* execute: ({ input }) => Effect.succeed(`${salutation}, ${input.name}!`),
|
|
1061
|
+
* });
|
|
1062
|
+
* return { hello };
|
|
1063
|
+
* },
|
|
1064
|
+
* });
|
|
1065
|
+
*
|
|
1066
|
+
* const api = greeterService.use(greeting("Welcome"));
|
|
1067
|
+
* await Effect.runPromise(api.hello.run({ name: "Ada" }));
|
|
1068
|
+
*/
|
|
1069
|
+
export declare function defineServicePlugin<S extends AnyService = AnyService, A = unknown>(definition: Omit<ServicePlugin<S, A>, typeof PLUGIN_KIND> & {
|
|
1070
|
+
setup: (context: ServicePluginContext<S>) => A & (A extends PromiseLike<unknown> ? never : unknown);
|
|
1071
|
+
}): ServicePlugin<S, A>;
|
|
1072
|
+
/**
|
|
1073
|
+
* Define a plugin that installs onto a resource (a table and its entity) with
|
|
1074
|
+
* `resource.use(plugin)`. Its `setup` receives the service, the resource, and a
|
|
1075
|
+
* `routes` registrar, whose routes mount under `${prefix}/${service}/${resource}`, and
|
|
1076
|
+
* returns the typed API that `resource.use` hands back. `crud` is built this way.
|
|
1077
|
+
*
|
|
1078
|
+
* @param definition - A unique `name`, optional `routes` controls, and `setup`,
|
|
1079
|
+
* which must be synchronous.
|
|
1080
|
+
* @returns The plugin descriptor, frozen.
|
|
1081
|
+
* @throws When the name is empty or has surrounding whitespace.
|
|
1082
|
+
*/
|
|
1083
|
+
export declare function defineResourcePlugin<S extends AnyService = AnyService, R extends AnyResource = Resource<any, ContextOf<S>, any>, A extends object = object>(definition: Omit<ResourcePlugin<S, R, A>, typeof PLUGIN_KIND> & {
|
|
1084
|
+
setup: (context: ResourcePluginContext<S, R>) => A & (A extends PromiseLike<unknown> ? never : unknown);
|
|
1085
|
+
}): ResourcePlugin<S, R, A>;
|
|
1086
|
+
/** A raw HTTP endpoint a plugin registered, ready to mount on the app. */
|
|
1087
|
+
interface PluginEndpoint {
|
|
1088
|
+
path: string;
|
|
1089
|
+
method: PluginRouteMethod;
|
|
1090
|
+
service: AnyService;
|
|
1091
|
+
plugin: string;
|
|
1092
|
+
summary?: string | undefined;
|
|
1093
|
+
description?: string | undefined;
|
|
1094
|
+
tags?: string[] | undefined;
|
|
1095
|
+
/** Resolves the service's context (from `call`), then runs the plugin's handler. */
|
|
1096
|
+
handler(context: Omit<PluginEndpointContext, "ctx">, call?: CallContext): Effect.Effect<unknown, unknown, any>;
|
|
1097
|
+
}
|
|
1098
|
+
/**
|
|
1099
|
+
* The raw HTTP endpoints plugins registered on a service, ready to mount on the
|
|
1100
|
+
* application. Each handler resolves the service's context before it runs.
|
|
1101
|
+
*
|
|
1102
|
+
* @param service - The service plugins were installed on.
|
|
1103
|
+
* @param prefix - The application's route prefix (default `/api`).
|
|
1104
|
+
* @returns The enabled endpoints.
|
|
1105
|
+
*/
|
|
1106
|
+
export declare function getPluginEndpoints(service: AnyService, prefix?: string): PluginEndpoint[];
|
|
1107
|
+
/**
|
|
1108
|
+
* Where a plugin mounted an action over HTTP, for OpenAPI and the typed client.
|
|
1109
|
+
*
|
|
1110
|
+
* @returns `undefined` when no plugin bound the action (it uses its own route),
|
|
1111
|
+
* `false` when the plugin's route was switched off, otherwise the route's
|
|
1112
|
+
* `path`, `method`, the `clientPath` the typed client uses, and the owning
|
|
1113
|
+
* `plugin` and `resource`.
|
|
1114
|
+
*/
|
|
1115
|
+
export declare function getPluginActionRoute(action: AnyAction, prefix?: string): false | {
|
|
1116
|
+
path: string;
|
|
1117
|
+
method: "DELETE" | "GET" | "PATCH" | "POST" | "PUT";
|
|
1118
|
+
clientPath: string[] | undefined;
|
|
1119
|
+
plugin: string;
|
|
1120
|
+
resource: string | undefined;
|
|
1121
|
+
} | undefined;
|
|
1122
|
+
/**
|
|
1123
|
+
* Whether `version` is in a semver `range`: `^0.11.0`, `~0.11.2`, `>=0.11 <0.13`,
|
|
1124
|
+
* `0.11.x`, `*`, and `||` between alternatives. Prerelease tags are ignored.
|
|
1125
|
+
*/
|
|
1126
|
+
export declare function satisfiesRange(version: string, range: string): boolean;
|
|
1127
|
+
/**
|
|
1128
|
+
* Whether a value is an app made by `brick()`. It checks for the methods and
|
|
1129
|
+
* `definition` a `BrickApp` has, so it also recognizes one built by another copy
|
|
1130
|
+
* of the package.
|
|
1131
|
+
*
|
|
1132
|
+
* @param app - Anything, such as the default export of an entry file.
|
|
1133
|
+
*/
|
|
1134
|
+
export declare function isBrickApp(app: unknown): app is BrickApp;
|
|
1135
|
+
/**
|
|
1136
|
+
* Check that a module's default export is an app ready to be served, for tools
|
|
1137
|
+
* that load an entry file.
|
|
1138
|
+
*
|
|
1139
|
+
* @throws When it is not a `BrickApp`, or it already called `.listen()`: the
|
|
1140
|
+
* entry must only build the app, and leave listening to the server bootstrap.
|
|
1141
|
+
*/
|
|
1142
|
+
export declare function requireBrickApp(app: unknown): BrickApp;
|
|
1143
|
+
export declare const SPAN: {
|
|
1144
|
+
/** `action <service>.<action>` */
|
|
1145
|
+
readonly actionPrefix: "action ";
|
|
1146
|
+
/** `rpc <service>.<action>` */
|
|
1147
|
+
readonly rpcPrefix: "rpc ";
|
|
1148
|
+
/** `socket <service>.<name>`: a raw socket connection, from upgrade to close. */
|
|
1149
|
+
readonly socketPrefix: "socket ";
|
|
1150
|
+
readonly exceptionEvent: "exception";
|
|
1151
|
+
/** The span event a `ctx.logger` line becomes. */
|
|
1152
|
+
readonly logEvent: "log";
|
|
1153
|
+
};
|
|
1154
|
+
export declare const ATTR: {
|
|
1155
|
+
readonly httpMethod: "http.request.method";
|
|
1156
|
+
readonly httpRoute: "http.route";
|
|
1157
|
+
readonly httpStatus: "http.response.status_code";
|
|
1158
|
+
readonly urlPath: "url.path";
|
|
1159
|
+
/** An outbound request's scheme, host and path. Never the query, credentials, headers or body. */
|
|
1160
|
+
readonly urlFull: "url.full";
|
|
1161
|
+
readonly serverAddress: "server.address";
|
|
1162
|
+
readonly service: "brick.service";
|
|
1163
|
+
readonly action: "brick.action";
|
|
1164
|
+
/** A webhook delivery: the webhook's name, its event id and what became of it. Never the body or the signature. */
|
|
1165
|
+
readonly webhook: "brick.webhook";
|
|
1166
|
+
readonly webhookEventId: "brick.webhook.event_id";
|
|
1167
|
+
readonly webhookOutcome: "brick.webhook.outcome";
|
|
1168
|
+
/** A schedule run: the schedule's name, what started it, which try, its due time and how it ended. */
|
|
1169
|
+
readonly schedule: "brick.schedule";
|
|
1170
|
+
readonly scheduleTrigger: "brick.schedule.trigger";
|
|
1171
|
+
readonly scheduleAttempt: "brick.schedule.attempt";
|
|
1172
|
+
readonly scheduleSlot: "brick.schedule.slot";
|
|
1173
|
+
readonly scheduleOutcome: "brick.schedule.outcome";
|
|
1174
|
+
/** A raw socket connection: its route name, id, frames and bytes received, and close code. */
|
|
1175
|
+
readonly socketName: "brick.socket.name";
|
|
1176
|
+
readonly socketId: "brick.socket.id";
|
|
1177
|
+
readonly socketMessages: "brick.socket.messages";
|
|
1178
|
+
readonly socketBytes: "brick.socket.bytes";
|
|
1179
|
+
readonly socketCloseCode: "brick.socket.close_code";
|
|
1180
|
+
readonly traceId: "brick.trace_id";
|
|
1181
|
+
readonly errorCode: "brick.error.code";
|
|
1182
|
+
readonly errorMessage: "brick.error.message";
|
|
1183
|
+
readonly errorStatus: "brick.error.status";
|
|
1184
|
+
readonly logsDropped: "brick.logs.dropped";
|
|
1185
|
+
readonly dbStatement: "db.statement";
|
|
1186
|
+
readonly dbSystem: "db.system";
|
|
1187
|
+
readonly dbOperation: "db.operation";
|
|
1188
|
+
readonly exceptionMessage: "exception.message";
|
|
1189
|
+
readonly exceptionStack: "exception.stacktrace";
|
|
1190
|
+
readonly logLevel: "log.level";
|
|
1191
|
+
readonly logMessage: "log.message";
|
|
1192
|
+
};
|
|
1193
|
+
/**
|
|
1194
|
+
* `Symbol.for` names shared through globalThis, because the CLI and the app may
|
|
1195
|
+
* each hold their own copy of Brick.
|
|
1196
|
+
*/
|
|
1197
|
+
export declare const GLOBAL_SYMBOL: {
|
|
1198
|
+
/** Set by the CLI while a dashboard collects logs. */
|
|
1199
|
+
readonly logsCapture: "brickkit.logs.capture";
|
|
1200
|
+
/** Brick's function that records a log line on the running span. */
|
|
1201
|
+
readonly logsRecord: "brickkit.logs.record";
|
|
1202
|
+
/** The set of running event hubs, so the CLI can stop them all. */
|
|
1203
|
+
readonly eventsStarted: "brickkit.events.started";
|
|
1204
|
+
/** The key the dashboard signs `/app/*` identities with. */
|
|
1205
|
+
readonly dashboardKey: "brickkit.dashboard.key";
|
|
1206
|
+
/** The in-memory store of finished spans. Under this package's own namespace: core has no such key. */
|
|
1207
|
+
readonly spans: "brickkit.effect.telemetry.spans";
|
|
1208
|
+
/**
|
|
1209
|
+
* A `Set` of functions that the CLI fills before the app loads: each gets the
|
|
1210
|
+
* start and end records of every span, as `SpanStore.subscribe` does. Under
|
|
1211
|
+
* this package's namespace, so a copy of core never reads it.
|
|
1212
|
+
*/
|
|
1213
|
+
readonly spanListeners: "brickkit.effect.telemetry.listeners";
|
|
1214
|
+
};
|
|
1215
|
+
export { type Action, type ActionAccessInfo, type ActionAccessPolicy, type ActionConfig, type ActionConfigBase, type ActionContext, type ActionParams, type ActionRoute, type ActionSchema, Activity, type Actor, type AnyAction, type AnyDatabaseHandle, type AnyResource, type AnySchema, type AnyService, type AnyTool, type ApiDocument, type AppEvents, type ArchitectureApplication, type ArchitectureSchema, type AuditOptions, type AuditTable, type AuthorizedActionConfig, type BaseContext, type BrickApp, BrickError, type BrickOptions, type BrickServices, type BrickSocketHandle, type BrickSocketSender, type Call, type CallContext, type CallDeps, type CallFiles, type ChildChanges, type ClientIp, type ColumnFieldPolicy, type Command, type CommandChildren, type CommandConfig, type CommandDecision, type CommandErrors, type CommandRow, type ContextOf, type ContractServiceClient, type CorsOptions, type CorsOrigin, type Counter, type CronExpression, type CrudAPI, type CrudAccess, type CrudAuthorizeArgs, type BulkOperation as CrudBulkOperation, type CrudCommitArgs, type CrudEventOperation, type CrudEventPayload, type Fields as CrudFields, type FilterOperator as CrudFilterOperator, type CrudHooks, type Operation as CrudOperation, type CrudOptions, type ReadRow as CrudReadRow, type CrudResource, type Where as CrudWhere, DASHBOARD_IDENTITY_HEADER, DASHBOARD_KEY_ENV, DASHBOARD_MCP_ROUTE, DASHBOARD_MCP_TOOLS, DEFAULT_PREFIX, type DashboardAuth, type DashboardIdentity, type DashboardMcpCaller, type DashboardOptions, type DashboardPeer, type DashboardUser, type DatabaseConnection, type DatabaseHandle, type DatabaseService, type DerivedFieldPolicy, type DispatchOptions, type DocumentationOptions, DuplicateNameError, DurableClock, DurableDeferred, type EndpointContext, type EndpointDefinition, type EndpointMethod, type ErrorDefinition, type ErrorDefinitions, type ErrorEnvelope, type ErrorHelpers, type ErrorHookContext, type EventContext, type EventDelivery, type EventEnvelope, type EventListener, type EventRecorder, type EventRef, type EventRefs, Events, type EventsDefinition, type EventsHub, type EventsOptions, type ExecuteParams, type FileDriver, type FileOptions, type FileStorage, type FinishedSpan, type FrameworkStorage, type GetAction, HOOK_NAMES, HTTP_METHODS, type HmacSignatureOptions, type HookResult, type HostHooks, type HttpMethod, type InstalledPlugin, type KeyValueDriver, type KeyValueStorage, LOCAL_FILES_ROUTE, type ListenerFailure, type ListeningServer, type Logger, type McpHandlerOptions, type McpRegistry, type McpRegistryOptions, type McpToolDefinition, type Next, type NoIdentity, type OnError, type OnResponse, type OpenApiDocument, type OpenApiOptions, type OtlpOptions, type OutboxCounts, type OutboxRow, type OutboxStatus, type OutboxTable, type PluginActionChecks, type PluginAppContext, type PluginContext, type PluginEndpoint, type PluginEndpointContext, type PluginFactory, type PluginHookArgs, type PluginHooks, type PluginInfo, type PluginInstallOptions, type PluginInstance, type PluginLifecycleContext, type PluginManifest, type PluginRouteMethod, type PluginRouteRegistrar, type PluginRouteScope, type PluginRoutes, type PluginServiceContext, type PluginSetupContext, type PluginTableBuilders, type PostgresAuditTable, type PostgresDatabaseConfig, type PostgresOptions, type ProxyOptions, type PutIfAbsentResult, type QueryAction, type RateLimit, type RateLimits, type RawDeps, type RawSocket, type RawSocketConfig, type RawSocketFrame, type RawSocketHandle, type RawSocketMessage, type RawSocketPhase, type RawSocketStats, type RedisBrokerOptions, type RedisStorageOptions, type ReferenceDocument, type ReferenceOptions, type RegisteredSocket, type RequestLoggingOptions, type RequirementOf, type Resource, type ResourceActionAccess, type ResourceActionConfig, type ResourceActionInput, type ResourceChild, type ResourceConfig, type ResourceIdentity, type ResourcePlugin, type ResourcePluginAPI, type ResourcePluginContext, type ResourcePluginTypes, type ResourceTypeOptions, type ResponseHookContext, type RetryDecision, type Reveal, type RouteIR, type S3StorageOptions, type SQLiteAuditTable, type SQLiteDatabaseConfig, type SQLiteOptions, STANDARD_ERRORS, type Schedule, type ScheduleConfig, type ScheduleControl, type ScheduleRun, type ScheduleRunRecord, type ScheduleState, type ScheduleTable, type ScopedFiles, type SecretOptions, SecretRef, type SecretSource, type SecretValidator, Sensitive, type Service, type ServiceActions, type ServiceClient, type ServiceContext, type ServiceOptions, type ServicePlugin, type ServicePluginContext, type ServiceRegistry, type ServiceSchema, type SocketBroker, type SocketBrokerMessage, type SocketConfig, type SocketEmitArgs, type SocketEmitOptions, type SocketEventArgs, type SocketPayloads, type SocketReplay, type SocketSchema, type SocketSchemas, type SocketsOptions, type SpanAttributes, type SpanEndRecord, type SpanEventRecord, type SpanStartRecord, SpanStore, type Stage, type StandardErrorCode, type StandardWebhooksOptions, type StorageDriver, StorageError, type StorageOf, StorageUnavailableError, type StoredFile, Telemetry, type TelemetryOptions, type TelemetryRecord, type Tool, type ToolAnnotations, type ToolContext, type ToolOptions, type TwilioSignatureOptions, type UntypedServiceClient, ValidationError, type ValidationIssue, WORKFLOW_TABLE, type WebhookConfig, type WebhookRequest, type WebhookSecret, type WebhookVerifier, type Wire, type WireError, Workflow, WorkflowEngine, type WorkflowEngineOptions, type WorkflowEvent, type WorkflowScheduleRun, actionOwners, addHostHooks, auditTable, brick, clientAddress, createLogger, createPostgresDatabase, createSQLiteDatabase, crudEventName, crudEventSource, dashboardIdentity, dashboardKey, dashboardMcpCaller, dashboardUser, defineDatabase, defineEvents, definePlugin, defineResource, defineSchedule, defineSecret, defineService, defineStorage, defineTool, envSource, exportArchitecture, frameworkStorage, getActionRoute, getHostHooks, hasSensitive, idSchema, isAuditTable, isCrudEvent, isDatabaseHandle, isTool, isWebhook, kebabCase, listSecrets, loadRecord, markDashboardArrival, memory, normalizeDashboard, outboxTable, overrideSecret, pluginOwner, recordAudit, recordWebhook, redact, redis, requestLoggingPlugin, resetSecrets, resolveSecrets, runStages, s3, scalarDocsHTML, scheduleTable, signDashboardIdentity, signDashboardMcp, spanStore, stagesOf, stopAllEvents, storageKey, telemetryLayer, timestamptzText, toErrorResponse, toWireError, traceRoute, traceScheduleRun, workflowEngine };
|
|
1216
|
+
//# sourceMappingURL=index.d.ts.map
|