@weave-kit/engine 2.0.0 → 2.1.1
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/CHANGELOG.md +50 -1
- package/README.md +3 -3
- package/dist/adapters/events/index.js +2 -2
- package/dist/adapters/events/index.js.map +1 -1
- package/dist/adapters/mcp/http.d.ts +7 -0
- package/dist/adapters/mcp/http.d.ts.map +1 -1
- package/dist/adapters/mcp/http.js +56 -20
- package/dist/adapters/mcp/http.js.map +1 -1
- package/dist/adapters/mcp/index.d.ts +6 -0
- package/dist/adapters/mcp/index.d.ts.map +1 -1
- package/dist/adapters/mcp/index.js +1 -0
- package/dist/adapters/mcp/index.js.map +1 -1
- package/dist/adapters/rest/audit.js +2 -2
- package/dist/adapters/rest/audit.js.map +1 -1
- package/dist/cli/commands/deploy.js +1 -1
- package/dist/cli/commands/deploy.js.map +1 -1
- package/dist/cli/commands/doctor.d.ts.map +1 -1
- package/dist/cli/commands/doctor.js +7 -4
- package/dist/cli/commands/doctor.js.map +1 -1
- package/dist/core/i18n/ar.js +1 -1
- package/dist/core/i18n/ar.js.map +1 -1
- package/dist/core/i18n/de.js +1 -1
- package/dist/core/i18n/de.js.map +1 -1
- package/dist/core/i18n/es.js +1 -1
- package/dist/core/i18n/es.js.map +1 -1
- package/dist/core/i18n/fr.js +1 -1
- package/dist/core/i18n/fr.js.map +1 -1
- package/dist/core/i18n/hi.js +1 -1
- package/dist/core/i18n/hi.js.map +1 -1
- package/dist/core/i18n/id.js +1 -1
- package/dist/core/i18n/ja.js +1 -1
- package/dist/core/i18n/ko.js +1 -1
- package/dist/core/i18n/ko.js.map +1 -1
- package/dist/core/i18n/pt.js +1 -1
- package/dist/core/i18n/pt.js.map +1 -1
- package/dist/core/i18n/ru.js +1 -1
- package/dist/core/i18n/ru.js.map +1 -1
- package/dist/core/i18n/vi.js +1 -1
- package/dist/core/i18n/vi.js.map +1 -1
- package/dist/core/i18n/zh-hant.js +1 -1
- package/dist/core/i18n/zh.js +1 -1
- package/dist/core/i18n/zh.js.map +1 -1
- package/dist/core/limiter/index.d.ts +1 -1
- package/dist/core/limiter/index.d.ts.map +1 -1
- package/dist/core/limiter/index.js +1 -1
- package/dist/core/limiter/index.js.map +1 -1
- package/dist/core/limiter/quota.d.ts +1 -3
- package/dist/core/limiter/quota.d.ts.map +1 -1
- package/dist/core/limiter/quota.js +1 -3
- package/dist/core/limiter/quota.js.map +1 -1
- package/dist/core/rbac/rls.d.ts +1 -1
- package/dist/core/rbac/rls.d.ts.map +1 -1
- package/dist/core/rbac/rls.js +5 -3
- package/dist/core/rbac/rls.js.map +1 -1
- package/dist/core/rbac/rowScope.d.ts.map +1 -1
- package/dist/core/rbac/rowScope.js +2 -3
- package/dist/core/rbac/rowScope.js.map +1 -1
- package/dist/core/storage/pool.d.ts +13 -4
- package/dist/core/storage/pool.d.ts.map +1 -1
- package/dist/core/storage/pool.js +27 -5
- package/dist/core/storage/pool.js.map +1 -1
- package/dist/core/storage/schema-scope.d.ts +7 -4
- package/dist/core/storage/schema-scope.d.ts.map +1 -1
- package/dist/core/storage/schema-scope.js +7 -4
- package/dist/core/storage/schema-scope.js.map +1 -1
- package/dist/experimental.d.ts +1 -0
- package/dist/experimental.d.ts.map +1 -1
- package/dist/experimental.js +1 -0
- package/dist/experimental.js.map +1 -1
- package/dist/runtime/config-types.d.ts +434 -0
- package/dist/runtime/config-types.d.ts.map +1 -0
- package/dist/runtime/config-types.js +2 -0
- package/dist/runtime/config-types.js.map +1 -0
- package/dist/runtime/data-access/query-helpers.d.ts +74 -0
- package/dist/runtime/data-access/query-helpers.d.ts.map +1 -0
- package/dist/runtime/data-access/query-helpers.js +238 -0
- package/dist/runtime/data-access/query-helpers.js.map +1 -0
- package/dist/runtime/data-access/query.d.ts.map +1 -1
- package/dist/runtime/data-access/query.js +4 -232
- package/dist/runtime/data-access/query.js.map +1 -1
- package/dist/runtime/engine.d.ts +4 -452
- package/dist/runtime/engine.d.ts.map +1 -1
- package/dist/runtime/engine.js +22 -195
- package/dist/runtime/engine.js.map +1 -1
- package/dist/runtime/guards.d.ts +31 -0
- package/dist/runtime/guards.d.ts.map +1 -0
- package/dist/runtime/guards.js +70 -0
- package/dist/runtime/guards.js.map +1 -0
- package/dist/runtime/register-http-routes.d.ts +40 -0
- package/dist/runtime/register-http-routes.d.ts.map +1 -0
- package/dist/runtime/register-http-routes.js +138 -0
- package/dist/runtime/register-http-routes.js.map +1 -0
- package/dist/subsystems/audit/store.js +3 -3
- package/dist/subsystems/audit/store.js.map +1 -1
- package/dist/subsystems/script/bridge.d.ts.map +1 -1
- package/dist/subsystems/script/bridge.js +1 -2
- package/dist/subsystems/script/bridge.js.map +1 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,434 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Engine assembly configuration types — extracted from `engine.ts` (2.1
|
|
3
|
+
* maintainability). The runtime assembly and start-up guards live in
|
|
4
|
+
* `engine.ts` / `guards.ts`; these are pure declarations (no runtime imports).
|
|
5
|
+
*/
|
|
6
|
+
import type { FastifyInstance } from 'fastify';
|
|
7
|
+
import type { Pool } from 'pg';
|
|
8
|
+
import type { AuditMode, CounterStore, EngineScriptConfig, EngineWorkflowConfig, EventPublisher, FieldTypeRegistration, GuardrailPolicy, Locale, MetricsSink, ObjectRegistry, ProxyTargetResolver, ScriptDispatcher, ToolDefinition, TraceSink } from '../core/index.js';
|
|
9
|
+
import type { IngressConfig } from '../core/provider/event/index.js';
|
|
10
|
+
import type { CapabilitiesProvider } from '../core/provider/capabilities/index.js';
|
|
11
|
+
import type { IdentitySource, IdentityStore } from '../core/provider/identity/index.js';
|
|
12
|
+
import type { PgIdentitySourceConfig } from './identity/sources/pg.js';
|
|
13
|
+
import type { ObjectDataAccess, QueryBudget, TotalMode } from './data-access/index.js';
|
|
14
|
+
import type { ProxyForwarder } from './proxy/index.js';
|
|
15
|
+
import type { AuthSource, AuthVerifier, Authenticator, OidcConfig } from '../adapters/auth/index.js';
|
|
16
|
+
import type { EngineMcpConfig, McpServerHandle } from '../adapters/mcp/index.js';
|
|
17
|
+
import type { EngineGraphQLConfig, GraphQLServerHandle } from '../adapters/graphql/index.js';
|
|
18
|
+
import type { PrincipalResolver } from '../adapters/rest/index.js';
|
|
19
|
+
import type { ProjectType } from '../cli/types/index.js';
|
|
20
|
+
import type { ApprovalsQueue, ToolExecutor } from './tools/index.js';
|
|
21
|
+
import type { AuditEngine } from '../subsystems/audit/index.js';
|
|
22
|
+
import type { WorkflowTimerScheduler } from '../subsystems/workflow/index.js';
|
|
23
|
+
/** REST interface configuration */
|
|
24
|
+
export interface EngineRestConfig {
|
|
25
|
+
enabled?: boolean;
|
|
26
|
+
/** URL prefix for object routes; defaults to `/api` */
|
|
27
|
+
prefix?: string;
|
|
28
|
+
/** per-agent-key sliding-window rate limiting; disabled when absent */
|
|
29
|
+
rateLimit?: {
|
|
30
|
+
windowMs?: number;
|
|
31
|
+
max?: number;
|
|
32
|
+
};
|
|
33
|
+
/** CORS settings (passed to @fastify/cors); disabled when absent */
|
|
34
|
+
cors?: {
|
|
35
|
+
origin?: string | string[] | boolean;
|
|
36
|
+
methods?: string[];
|
|
37
|
+
allowedHeaders?: string[];
|
|
38
|
+
maxAge?: number;
|
|
39
|
+
};
|
|
40
|
+
/** maximum request body size in bytes; defaults to 1 MiB */
|
|
41
|
+
bodyLimit?: number;
|
|
42
|
+
/** roles allowed to query the full audit trail and use admin script-source read/write routes */
|
|
43
|
+
adminRoles?: string[];
|
|
44
|
+
/**
|
|
45
|
+
* maps an authenticated request to the data-access principal (see
|
|
46
|
+
* `PrincipalResolver`). A control plane injects this to run requests under a
|
|
47
|
+
* **system/admin scope** (cross-tenant global views, D32); absent = `userPrincipal`.
|
|
48
|
+
*/
|
|
49
|
+
principalFor?: PrincipalResolver;
|
|
50
|
+
}
|
|
51
|
+
/** audit subsystem config (optional; disabled = not loaded = zero overhead) */
|
|
52
|
+
export interface EngineAuditConfig {
|
|
53
|
+
enabled?: boolean;
|
|
54
|
+
/**
|
|
55
|
+
* Durability mode (default `best-effort`): `best-effort` = fire-and-forget
|
|
56
|
+
* process buffer; `transactional` = audit row written in the business
|
|
57
|
+
* transaction; `durable` = transactional outbox + relay (crash-safe,
|
|
58
|
+
* at-least-once).
|
|
59
|
+
*/
|
|
60
|
+
mode?: AuditMode;
|
|
61
|
+
/**
|
|
62
|
+
* Accept a best-effort fallback when `mode` is `transactional`/`durable` but
|
|
63
|
+
* the resolved sink cannot write in-transaction (`recordInTx`). Default
|
|
64
|
+
* `false` = fail-closed at startup (a misconfigured sink would otherwise drop
|
|
65
|
+
* events on crash). Built-in sinks always satisfy the requirement.
|
|
66
|
+
*/
|
|
67
|
+
allowBestEffortFallback?: boolean;
|
|
68
|
+
/** audit diff replay: attach before/after row snapshots to update/delete audit events (default off; table always has the columns) */
|
|
69
|
+
replay?: boolean;
|
|
70
|
+
/** L1 buffered-sink parameters */
|
|
71
|
+
batch?: {
|
|
72
|
+
batchSize?: number;
|
|
73
|
+
flushMs?: number;
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Engine-level tool mechanism config (open contract, protocol-agnostic —
|
|
78
|
+
* lives at the top level, not under `adapters.*`). Disabled when absent.
|
|
79
|
+
*/
|
|
80
|
+
export interface EngineToolsConfig {
|
|
81
|
+
/** custom tool directory (relative to schemaDir, like `objects/`); default `tools` */
|
|
82
|
+
toolsDir?: string;
|
|
83
|
+
/** guardrail policies: inline array or a policies directory path (loaded by the assembly layer) */
|
|
84
|
+
guardrails?: {
|
|
85
|
+
policies?: GuardrailPolicy[] | string;
|
|
86
|
+
};
|
|
87
|
+
/**
|
|
88
|
+
* approval queue persistence (release-grade). Absent → PG-backed when the
|
|
89
|
+
* tool executor is created; `backend: 'memory'` opts into the single-process
|
|
90
|
+
* in-memory queue (tests). No Redis backend is implemented.
|
|
91
|
+
*/
|
|
92
|
+
approvals?: {
|
|
93
|
+
backend?: 'pg' | 'memory';
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
/** live event channel config (optional; disabled = not created = zero overhead) */
|
|
97
|
+
export interface EngineEventsConfig {
|
|
98
|
+
enabled?: boolean;
|
|
99
|
+
/** URL prefix for the SSE endpoint; defaults to `/api` */
|
|
100
|
+
prefix?: string;
|
|
101
|
+
/** roles allowed to see every actor's audit events (mirrors adapters.rest.adminRoles) */
|
|
102
|
+
adminRoles?: string[];
|
|
103
|
+
/** replay ring buffer size + heartbeat tuning */
|
|
104
|
+
replay?: {
|
|
105
|
+
maxEvents?: number;
|
|
106
|
+
heartbeatMs?: number;
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* Generic engine proxy. Configured with `proxy.resolver`
|
|
111
|
+
* only → otherwise (absent) the proxy is not wired (zero overhead). The engine
|
|
112
|
+
* provides the mechanism (contract + forwarder + routes); the resolver carries
|
|
113
|
+
* the application semantics (which connection a subject may reach).
|
|
114
|
+
*/
|
|
115
|
+
export interface EngineProxyConfig {
|
|
116
|
+
/** inject application layer: resolve connection → target (id/url/key/keyScope). */
|
|
117
|
+
resolver?: ProxyTargetResolver | ProxyTargetResolverBuilder;
|
|
118
|
+
/** injectable fetch (tests / custom transport). */
|
|
119
|
+
fetchImpl?: typeof fetch;
|
|
120
|
+
/**
|
|
121
|
+
* custom outbound forwarder, e.g. a tunnel-aware one that routes
|
|
122
|
+
* `transport: 'tunnel'` targets over a live connector. Builder form receives
|
|
123
|
+
* the runtime deps so the host can read its own metadata. Default = fetch.
|
|
124
|
+
*/
|
|
125
|
+
forwarder?: ProxyForwarder | ((deps: ProxyResolverDeps) => ProxyForwarder);
|
|
126
|
+
enabled?: boolean;
|
|
127
|
+
}
|
|
128
|
+
/** runtime deps handed to a {@link ProxyTargetResolverBuilder} so the app can read its own metadata. */
|
|
129
|
+
export interface ProxyResolverDeps {
|
|
130
|
+
dataAccess: ObjectDataAccess;
|
|
131
|
+
pool: Pool;
|
|
132
|
+
registry: ObjectRegistry;
|
|
133
|
+
authenticator: Authenticator;
|
|
134
|
+
locale: Locale;
|
|
135
|
+
}
|
|
136
|
+
/**
|
|
137
|
+
* Factory form of `resolver`: built by the engine at assembly time with the real
|
|
138
|
+
* runtime deps, so the app can read its metadata (e.g. the governance engine's
|
|
139
|
+
* own `connections` object) server-side without a second pool. A plain
|
|
140
|
+
* `ProxyTargetResolver` instance is also accepted.
|
|
141
|
+
*/
|
|
142
|
+
export type ProxyTargetResolverBuilder = (deps: ProxyResolverDeps) => ProxyTargetResolver;
|
|
143
|
+
/** engine assembly configuration — the single wiring point (see AGENTS.md) */
|
|
144
|
+
/** a host-level background service returned by a service's `start`. */
|
|
145
|
+
export interface EngineServiceHandle {
|
|
146
|
+
/** tear the service down (abort streams, clear timers); called on engine close. */
|
|
147
|
+
stop(): Promise<void>;
|
|
148
|
+
}
|
|
149
|
+
/** host-app service factory the engine starts once assembled, stops on close. */
|
|
150
|
+
export interface EngineService {
|
|
151
|
+
name: string;
|
|
152
|
+
start(engine: WeaveKitEngine): Promise<EngineServiceHandle> | EngineServiceHandle;
|
|
153
|
+
}
|
|
154
|
+
/** identity directory wiring (see `core/provider/identity`) */
|
|
155
|
+
export interface EngineIdentityConfig {
|
|
156
|
+
/**
|
|
157
|
+
* provisioning source: an `IdentitySource` instance (has `pull`) or a
|
|
158
|
+
* declarative `PgIdentitySourceConfig`. Absent → greenfield (the engine owns
|
|
159
|
+
* `weavekit_user`/`weavekit_department` directly).
|
|
160
|
+
*/
|
|
161
|
+
source?: IdentitySource | PgIdentitySourceConfig;
|
|
162
|
+
/** replaceable local directory store; defaults to PG over `weavekit_*` */
|
|
163
|
+
store?: IdentityStore;
|
|
164
|
+
/**
|
|
165
|
+
* credential verifier (OIDC/JWT/SAML); when set the engine authenticates via
|
|
166
|
+
* `verifier → directory → subject` and `auth.source` may be omitted.
|
|
167
|
+
*/
|
|
168
|
+
verifier?: AuthVerifier;
|
|
169
|
+
/** reject subjects with no local identity for scoped access (default false) */
|
|
170
|
+
required?: boolean;
|
|
171
|
+
sync?: {
|
|
172
|
+
/** run the source sync on engine start (fail-closed) */
|
|
173
|
+
onStart?: boolean;
|
|
174
|
+
/** soft-disable local rows absent from the source snapshot */
|
|
175
|
+
deactivateMissing?: boolean;
|
|
176
|
+
};
|
|
177
|
+
}
|
|
178
|
+
export interface EngineConfig {
|
|
179
|
+
/** postgres connection string; defaults to process.env.DATABASE_URL */
|
|
180
|
+
databaseUrl?: string;
|
|
181
|
+
/**
|
|
182
|
+
* connection string used only for schema migration/DDL by the CLI (`weave
|
|
183
|
+
* migrate`/`weave dev`). Defaults to `databaseUrl`. **Same database, a
|
|
184
|
+
* separate account** — a PostgreSQL role with DDL rights (usually the owner),
|
|
185
|
+
* so the runtime account can be least-privileged (no DDL/DROP/TRUNCATE).
|
|
186
|
+
* Pointing it at a *different* database is a misconfiguration (migrations
|
|
187
|
+
* would land where the runtime cannot see them). The engine itself never runs
|
|
188
|
+
* DDL at runtime.
|
|
189
|
+
*/
|
|
190
|
+
migrationDatabaseUrl?: string;
|
|
191
|
+
/**
|
|
192
|
+
* runtime database account guard. The engine only ever runs DML, so its
|
|
193
|
+
* account should be least-privileged (no schema `CREATE`); DDL is an explicit
|
|
194
|
+
* `weave migrate` using `migrationDatabaseUrl`. When `requireRestrictedAccount`
|
|
195
|
+
* is true (the default) the engine **fails to start** if its account can
|
|
196
|
+
* create objects in the current schema. Set false for a single-account setup
|
|
197
|
+
* (`weave dev` does this by default), or override with the
|
|
198
|
+
* `WEAVEKIT_REQUIRE_RESTRICTED_ACCOUNT` env var.
|
|
199
|
+
*/
|
|
200
|
+
runtime?: {
|
|
201
|
+
requireRestrictedAccount?: boolean;
|
|
202
|
+
};
|
|
203
|
+
/** runtime message locale; resolution: config → env WEAVEKIT_LOCALE → 'en' */
|
|
204
|
+
locale?: Locale;
|
|
205
|
+
/**
|
|
206
|
+
* project starting preset (agent/governance/service/business) — persisted by
|
|
207
|
+
* the scaffolder. Used as CLI context (e.g. `weave object:create` scaffolds a
|
|
208
|
+
* `client.js` template only for `business` projects). Not required at runtime.
|
|
209
|
+
*/
|
|
210
|
+
projectType?: ProjectType;
|
|
211
|
+
/**
|
|
212
|
+
* project root whose `objects/<name>/schema.json` files are the metadata source.
|
|
213
|
+
* The engine loads the schema on startup; it never touches the database unless
|
|
214
|
+
* `migrate.auto` is true (default false — DDL is an explicit `weave migrate`).
|
|
215
|
+
*/
|
|
216
|
+
schemaDir?: string;
|
|
217
|
+
/**
|
|
218
|
+
* migration behavior:
|
|
219
|
+
* - `auto` — run the schema→PG migration (CREATE/ALTER) on engine startup.
|
|
220
|
+
* Default false: WeaveKit is a headless bridge to your database — building/
|
|
221
|
+
* altering tables is an explicit `weave migrate`. Enable for greenfield/
|
|
222
|
+
* business projects that want the schema to drive DDL automatically.
|
|
223
|
+
* Additive DDL on existing tables is governed per object by
|
|
224
|
+
* `schema.alter: true`.
|
|
225
|
+
*/
|
|
226
|
+
migrate?: {
|
|
227
|
+
auto?: boolean;
|
|
228
|
+
};
|
|
229
|
+
/**
|
|
230
|
+
* git behavior for engine startup syncs:
|
|
231
|
+
* - `meta` — git-commit the metadata tree (`objects/`) after a `migrate.auto` sync
|
|
232
|
+
* - `identity` — commit identity; falls back to a local weavekit identity
|
|
233
|
+
*/
|
|
234
|
+
commit?: {
|
|
235
|
+
meta?: boolean;
|
|
236
|
+
identity?: {
|
|
237
|
+
name: string;
|
|
238
|
+
email: string;
|
|
239
|
+
};
|
|
240
|
+
};
|
|
241
|
+
/**
|
|
242
|
+
* Authentication: a static key map / custom resolver (`source`), a built-in
|
|
243
|
+
* OIDC/JWT verifier (`oidc`), or `identity.verifier` for a custom protocol
|
|
244
|
+
* verifier. At least one is required. `oidc` requires a resolvable identity
|
|
245
|
+
* directory (run `weave sync:identity`).
|
|
246
|
+
*/
|
|
247
|
+
auth?: {
|
|
248
|
+
source?: AuthSource;
|
|
249
|
+
oidc?: OidcConfig;
|
|
250
|
+
};
|
|
251
|
+
/** protocol adapters (REST/MCP/events/GraphQL), closable via config */
|
|
252
|
+
adapters?: {
|
|
253
|
+
rest?: EngineRestConfig;
|
|
254
|
+
mcp?: EngineMcpConfig;
|
|
255
|
+
events?: EngineEventsConfig;
|
|
256
|
+
graphql?: EngineGraphQLConfig;
|
|
257
|
+
};
|
|
258
|
+
/** engine-level tool mechanism: custom tools + guardrail policies; disabled when absent */
|
|
259
|
+
tools?: EngineToolsConfig;
|
|
260
|
+
/** optional subsystems, dynamically loaded when enabled (audit/script; workflow is declaration-driven; unknown keys error out) */
|
|
261
|
+
subsystems?: {
|
|
262
|
+
audit?: EngineAuditConfig;
|
|
263
|
+
script?: EngineScriptConfig;
|
|
264
|
+
workflow?: EngineWorkflowConfig;
|
|
265
|
+
};
|
|
266
|
+
/**
|
|
267
|
+
* durable fixed-period counters / usage budgets (optional; disabled when
|
|
268
|
+
* absent). Backed by PostgreSQL (`weavekit_counters`) and exposed as
|
|
269
|
+
* `engine.quotas`; the host consumes it around its own integration calls via
|
|
270
|
+
* `core/limiter` `consumeQuota` / `assertQuota`.
|
|
271
|
+
*/
|
|
272
|
+
quotas?: {
|
|
273
|
+
backend?: 'pg';
|
|
274
|
+
};
|
|
275
|
+
/**
|
|
276
|
+
* Agent-native query budget: caps rows/filters/sorts (data-access), joins /
|
|
277
|
+
* SQL length / statement timeout (restricted SQL) and GraphQL depth. Absent =
|
|
278
|
+
* defaults (see `QUERY_BUDGET_DEFAULTS`).
|
|
279
|
+
*/
|
|
280
|
+
queryBudget?: Partial<QueryBudget>;
|
|
281
|
+
/**
|
|
282
|
+
* List-query defaults for every read surface (REST / GraphQL / MCP).
|
|
283
|
+
* `query.total` selects how a page's `total` is computed: `exact` (default,
|
|
284
|
+
* `COUNT(*)`), `estimate` (`pg_class.reltuples` — approximate, cheap on large
|
|
285
|
+
* tables) or `none` (skip counting; `total` omitted). A per-request `total`
|
|
286
|
+
* argument overrides this.
|
|
287
|
+
*/
|
|
288
|
+
query?: {
|
|
289
|
+
total?: TotalMode;
|
|
290
|
+
};
|
|
291
|
+
/**
|
|
292
|
+
* Dedicated schema for the engine's own tables (`weavekit_*` system tables,
|
|
293
|
+
* `weavekit_record__<object>` side tables, `weavekit_m2m__*` link tables), so
|
|
294
|
+
* a DBA reviewing the customer schema does not see engine plumbing. Default
|
|
295
|
+
* (absent) keeps them in the object schema (legacy). Set the same value on
|
|
296
|
+
* `weave migrate`; the runtime appends it to `search_path`. Only affects new
|
|
297
|
+
* databases (existing installs need a manual `ALTER TABLE … SET SCHEMA`).
|
|
298
|
+
*/
|
|
299
|
+
systemSchema?: string;
|
|
300
|
+
/**
|
|
301
|
+
* Object-path row-level security (defense in depth; default off in 1.x).
|
|
302
|
+
* With `enforce`, the engine runs user-principal customer-table reads /
|
|
303
|
+
* updates / deletes under `role` (default `weavekit_object`), so PostgreSQL
|
|
304
|
+
* policies generated from the same permission matrix re-check the RBAC row
|
|
305
|
+
* scope. `weave migrate` provisions the role/policies; the engine refuses to
|
|
306
|
+
* start when they are missing. Inserts and system principals run as the owner.
|
|
307
|
+
*/
|
|
308
|
+
rls?: {
|
|
309
|
+
enforce?: boolean;
|
|
310
|
+
role?: string;
|
|
311
|
+
};
|
|
312
|
+
/**
|
|
313
|
+
* Execution evidence capture (optional; disabled when absent). When enabled,
|
|
314
|
+
* every data-access write / workflow transition / tool call records one
|
|
315
|
+
* `weavekit_evidence` row with its full stage timeline and real outcome
|
|
316
|
+
* (best-effort: a failed evidence write never blocks the execution). Capture
|
|
317
|
+
* only — export/retention belong to the enterprise E2 layer.
|
|
318
|
+
*/
|
|
319
|
+
evidence?: {
|
|
320
|
+
enabled?: boolean;
|
|
321
|
+
};
|
|
322
|
+
/**
|
|
323
|
+
* Row-scope / multi-tenancy (row mode). When enabled, a subject without a
|
|
324
|
+
* scope is stamped with `defaultScope`, and objects declaring a `scope` field
|
|
325
|
+
* are scoped to the subject's scope (RBAC row scope + RLS GUC + audit). Absent
|
|
326
|
+
* = single-scope (unchanged). Lifecycle / schema-per-tenant are out of scope
|
|
327
|
+
* (enterprise).
|
|
328
|
+
*/
|
|
329
|
+
scope?: {
|
|
330
|
+
enabled?: boolean;
|
|
331
|
+
defaultScope?: string;
|
|
332
|
+
};
|
|
333
|
+
/** generic outbound proxy route wiring (applications provide the resolver) */
|
|
334
|
+
proxy?: EngineProxyConfig;
|
|
335
|
+
/**
|
|
336
|
+
* inbound external-event entry point (first-class ingress seam; disabled when
|
|
337
|
+
* absent). The app provides provider verification + handling; the engine
|
|
338
|
+
* preserves the raw body, rate-limits per source and audits the receipt.
|
|
339
|
+
*/
|
|
340
|
+
ingress?: IngressConfig;
|
|
341
|
+
/**
|
|
342
|
+
* low-level observability sinks (optional; absent = no-op = zero overhead).
|
|
343
|
+
* The engine emits request latency/status, RBAC denials, query-budget rejects
|
|
344
|
+
* and finished spans; a host injects the telemetry backend. Labels must stay
|
|
345
|
+
* low-cardinality and PII-free (see `core/observability`).
|
|
346
|
+
*/
|
|
347
|
+
observability?: {
|
|
348
|
+
metrics?: MetricsSink;
|
|
349
|
+
trace?: TraceSink;
|
|
350
|
+
};
|
|
351
|
+
/**
|
|
352
|
+
* capability feature switches (declarative gating). `features.fieldTypes` is
|
|
353
|
+
* a whitelist of field types a schema may declare; a field outside the list is
|
|
354
|
+
* rejected by the validator (fail-closed). Defaults to the engine primitives
|
|
355
|
+
* plus every semantic type (no gating) unless a project narrows it.
|
|
356
|
+
*/
|
|
357
|
+
features?: {
|
|
358
|
+
fieldTypes?: string[];
|
|
359
|
+
};
|
|
360
|
+
/**
|
|
361
|
+
* project-local field-type registrations (open registration): a directory of
|
|
362
|
+
* modules (each default-exporting a `FieldTypeRegistration` or array) and/or
|
|
363
|
+
* inline entries. Compiled with the built-ins into an immutable effective
|
|
364
|
+
* registry passed through validation + consumers (no mutable global).
|
|
365
|
+
*/
|
|
366
|
+
fieldTypes?: {
|
|
367
|
+
dir?: string;
|
|
368
|
+
entries?: FieldTypeRegistration[];
|
|
369
|
+
};
|
|
370
|
+
/**
|
|
371
|
+
* engine-owned identity directory (see `core/provider/identity`). `source`
|
|
372
|
+
* imports an external user/department directory (a `pg` descriptor or an
|
|
373
|
+
* `IdentitySource`); `weave sync:identity` provisions it into `weavekit_user`
|
|
374
|
+
* / `weavekit_department` before the engine serves scoped access.
|
|
375
|
+
*/
|
|
376
|
+
identity?: EngineIdentityConfig;
|
|
377
|
+
/**
|
|
378
|
+
* capabilities (feature/entitlement) read-only seam (see
|
|
379
|
+
* `core/provider/capabilities`). The engine **never judges licensing** — a host
|
|
380
|
+
* (e.g. `@weave-kit/enterprise` E0) injects a `CapabilitiesProvider`; absent =
|
|
381
|
+
* baseline (no features). Surfaced at `GET {prefix}/capabilities`.
|
|
382
|
+
*/
|
|
383
|
+
capabilities?: {
|
|
384
|
+
provider?: CapabilitiesProvider;
|
|
385
|
+
};
|
|
386
|
+
/**
|
|
387
|
+
* host-level background services (e.g. an instance-liveness monitor). Started
|
|
388
|
+
* after the engine is assembled and stopped in `close()`, so both `weave dev`
|
|
389
|
+
* and production `main.ts` manage them identically. A service gets the whole
|
|
390
|
+
* engine (data-access/pool/events) to orchestrate app-specific work.
|
|
391
|
+
*/
|
|
392
|
+
services?: EngineService[];
|
|
393
|
+
}
|
|
394
|
+
/** a running engine: fastify app + pool + RBAC-decorated data access */
|
|
395
|
+
export interface WeaveKitEngine {
|
|
396
|
+
app: FastifyInstance;
|
|
397
|
+
registry: ObjectRegistry;
|
|
398
|
+
pool: Pool;
|
|
399
|
+
dataAccess: ObjectDataAccess;
|
|
400
|
+
authenticator: Authenticator;
|
|
401
|
+
/** MCP adapter handle (present unless adapters.mcp.enabled is false) */
|
|
402
|
+
mcp?: McpServerHandle;
|
|
403
|
+
/** GraphQL adapter handle (present when adapters.graphql.enabled is true) */
|
|
404
|
+
graphql?: GraphQLServerHandle;
|
|
405
|
+
/** tool mechanism (present when config.tools.toolsDir is set): executor + approval queue */
|
|
406
|
+
tools?: {
|
|
407
|
+
defs: ToolDefinition[];
|
|
408
|
+
executor: ToolExecutor;
|
|
409
|
+
};
|
|
410
|
+
/** live event publisher (present when adapters.events.enabled): emits committed writes / audit / schema changes */
|
|
411
|
+
events?: EventPublisher;
|
|
412
|
+
/** generic proxy handle (present when config.proxy.resolver is set): forwarder + resolver */
|
|
413
|
+
proxy?: {
|
|
414
|
+
forwarder: ProxyForwarder;
|
|
415
|
+
resolver: ProxyTargetResolver;
|
|
416
|
+
};
|
|
417
|
+
/** audit subsystem (present when enabled); buffered sink is flushed on close */
|
|
418
|
+
audit?: AuditEngine;
|
|
419
|
+
/** durable counter store (present when `config.quotas` is set): quota/budget primitive */
|
|
420
|
+
quotas?: CounterStore;
|
|
421
|
+
/** script subsystem (present when enabled); workers are terminated on close */
|
|
422
|
+
script?: ScriptDispatcher;
|
|
423
|
+
/** approval queue (present when config.tools is set): shared by tools and workflow transitions */
|
|
424
|
+
approvals?: ApprovalsQueue;
|
|
425
|
+
/** workflow timer scheduler (present when `subsystems.workflow.enabled`): fires `onTimeout` */
|
|
426
|
+
workflow?: WorkflowTimerScheduler;
|
|
427
|
+
/** observability sinks (no-op unless `config.observability` injects one) */
|
|
428
|
+
observability: {
|
|
429
|
+
metrics: MetricsSink;
|
|
430
|
+
trace: TraceSink;
|
|
431
|
+
};
|
|
432
|
+
close(): Promise<void>;
|
|
433
|
+
}
|
|
434
|
+
//# sourceMappingURL=config-types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config-types.d.ts","sourceRoot":"","sources":["../../src/runtime/config-types.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAC/C,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,IAAI,CAAC;AAC/B,OAAO,KAAK,EACV,SAAS,EACT,YAAY,EACZ,kBAAkB,EAClB,oBAAoB,EACpB,cAAc,EACd,qBAAqB,EACrB,eAAe,EACf,MAAM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AC;QAAC,KAAK,EAAE,SAAS,CAAA;KAAE,CAAC;IAC1D,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CACxB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config-types.js","sourceRoot":"","sources":["../../src/runtime/config-types.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import type { PoolClient } from 'pg';
|
|
2
|
+
import type { ObjectDefinition, ObjectRegistry } from '../../core/index.js';
|
|
3
|
+
import { type Locale, type ScriptUser, type ToolDataAccess } from '../../core/index.js';
|
|
4
|
+
import type { AuditSink } from '../../core/audit/index.js';
|
|
5
|
+
import type { BuildContext } from './builder.js';
|
|
6
|
+
import type { FormulaAuth } from './formula.js';
|
|
7
|
+
import { type DataAccessContext, type FindOptions, type ObjectDataAccess } from './types.js';
|
|
8
|
+
/**
|
|
9
|
+
* Pure helpers for the object data-access layer — extracted from `query.ts` so
|
|
10
|
+
* the `DefaultObjectDataAccess` class stays focused on orchestration. None of
|
|
11
|
+
* these touch instance state; they operate on their arguments only.
|
|
12
|
+
*/
|
|
13
|
+
export declare const q: (id: string) => string;
|
|
14
|
+
/** cross-object formula authorization derived from the request context */
|
|
15
|
+
export declare function formulaAuth(ctx: DataAccessContext): FormulaAuth;
|
|
16
|
+
/** pg QueryResult shape the drift wrapper needs */
|
|
17
|
+
export interface QueryResultLike {
|
|
18
|
+
rows: unknown[];
|
|
19
|
+
rowCount?: number | null;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Run a SQL statement against an object's table, mapping PG `undefined_column`
|
|
23
|
+
* (42703) — a schema/DB drift (schema declares a field the table lacks) — to an
|
|
24
|
+
* actionable error instead of a raw 500.
|
|
25
|
+
*/
|
|
26
|
+
export declare function runTableQuery(q: {
|
|
27
|
+
query(sql: string, params: unknown[]): Promise<QueryResultLike>;
|
|
28
|
+
}, objectName: string, sql: string, params: unknown[], locale?: Locale): Promise<QueryResultLike>;
|
|
29
|
+
/** emit a write-audit event (transaction-aware: in-tx when a tx-capable sink is active) */
|
|
30
|
+
export declare function auditWrite(sink: AuditSink | undefined, ctx: DataAccessContext, action: string, objectName: string, objectId: string | undefined, changes: unknown, error?: unknown, before?: unknown, after?: unknown, client?: PoolClient): Promise<void>;
|
|
31
|
+
/** rebuild `this.user` for hooks from the authenticated subject */
|
|
32
|
+
export declare function scriptUserOf(ctx: DataAccessContext): ScriptUser;
|
|
33
|
+
/** details child auto columns (`parent_id`/`parent_type`/`parent_idx`) */
|
|
34
|
+
export declare const PARENT_COLUMNS: Set<string>;
|
|
35
|
+
export declare function isDetailsChild(registry: ObjectRegistry, name: string): boolean;
|
|
36
|
+
export declare function requireDef(ctx: DataAccessContext, objectName: string): ObjectDefinition;
|
|
37
|
+
export declare function bctx(ctx: DataAccessContext, objectName: string): BuildContext;
|
|
38
|
+
/** hidden select column carrying the SQL-computed record_key for a fetched row */
|
|
39
|
+
export declare const META_KEY_COL = "__weave_record_key";
|
|
40
|
+
/** select expression for the SQL-computed record_key (lossless for temporal keys) */
|
|
41
|
+
export declare function recordKeySelect(def: ObjectDefinition): string;
|
|
42
|
+
/** the record_key of a row, from its declared primary fields (declaration order) */
|
|
43
|
+
export declare function recordKeyOfRow(def: ObjectDefinition, record: Record<string, unknown>): string;
|
|
44
|
+
/** declared primary field names, in declaration order */
|
|
45
|
+
export declare function primaryNames(def: ObjectDefinition): string[];
|
|
46
|
+
/** decode an external id (the record_key, for single and composite keys alike) into primary values */
|
|
47
|
+
export declare function pkValuesOf(def: ObjectDefinition, id: string, ctx: DataAccessContext): string[];
|
|
48
|
+
/** reject a malformed external id up front (keyed objects only; key-less objects 404 later) */
|
|
49
|
+
export declare function validateId(def: ObjectDefinition, id: string, ctx: DataAccessContext): void;
|
|
50
|
+
/** primary-key filter object for `find` (declared names zipped with values) */
|
|
51
|
+
export declare function pkFilter(def: ObjectDefinition, values: readonly string[]): Record<string, unknown>;
|
|
52
|
+
/** `"a" = $1 AND "b" = $2` predicate for the primary names, starting at `startIndex` */
|
|
53
|
+
export declare function pkWhereSql(def: ObjectDefinition, startIndex: number): string;
|
|
54
|
+
/** the external id of a record: always its record_key (single and composite keys alike) */
|
|
55
|
+
export declare function externalIdOf(def: ObjectDefinition, record: Record<string, unknown>): string;
|
|
56
|
+
/** true when the query references a side-table virtual field (`weave_*` minus the derived `weave_id`) */
|
|
57
|
+
export declare function needsSideTable(opts: FindOptions): boolean;
|
|
58
|
+
/**
|
|
59
|
+
* Narrow `ToolDataAccess` over this data-access for guardrail policies: a policy
|
|
60
|
+
* calls `ctx.dataAccess.find(obj, opts, { subject? })` with no pool/registry, so
|
|
61
|
+
* those are injected from the execution context (mirrors the tool executor's
|
|
62
|
+
* wrapper; `...c` lets a policy override the subject per call).
|
|
63
|
+
*/
|
|
64
|
+
export declare function toolDataAccessOver(inner: ObjectDataAccess, base: DataAccessContext): ToolDataAccess;
|
|
65
|
+
/**
|
|
66
|
+
* Serialize a value for binding to a DB column. pg (node-postgres) auto-stringifies
|
|
67
|
+
* JSON *objects* but serializes JSON *arrays* as a PG array literal (`{"a"}`) which
|
|
68
|
+
* is invalid as `json` — so we explicitly `JSON.stringify` non-string json values
|
|
69
|
+
* (arrays/objects/numbers/booleans) to valid JSON text. `null` stays SQL NULL.
|
|
70
|
+
*/
|
|
71
|
+
export declare function dbJsonValue(field: {
|
|
72
|
+
type?: string;
|
|
73
|
+
} | undefined, value: unknown): unknown;
|
|
74
|
+
//# sourceMappingURL=query-helpers.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"query-helpers.d.ts","sourceRoot":"","sources":["../../../src/runtime/data-access/query-helpers.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,IAAI,CAAC;AACrC,OAAO,KAAK,EAAE,gBAAgB,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAC5E,OAAO,EAWL,KAAK,MAAM,EACX,KAAK,UAA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