Repository navigation
Expand file tree
/
Copy pathindex.ts
More file actions
406 lines (384 loc) · 17.9 KB
/
Copy pathindex.ts
File metadata and controls
406 lines (384 loc) · 17.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
// Copyright (c) 2025 ObjectStack. Licensed under the Apache-2.0 license.
// Export Kernels
export { ObjectKernel } from '@objectstack/core';
// Export Runtime
export { Runtime } from './runtime.js';
export type { RuntimeConfig } from './runtime.js';
// Export Standalone Stack
export { createStandaloneStack, resolveObjectStackHome, resolveStandaloneDatabase, sqliteFilenameFromUrl } from './standalone-stack.js';
export type { StandaloneStackConfig, StandaloneStackResult, ResolvedStandaloneDatabase } from './standalone-stack.js';
// [#30962] The host seam for package lifecycle state (module enable/disable):
// a host whose `OS_HOME` does not outlive its container supplies the store,
// and every kernel without one keeps the file under `OS_HOME`.
export {
PACKAGE_STATE_STORE_SERVICE,
PACKAGE_STATE_STORE_PLUGIN_NAME,
PackageStateStorePlugin,
createPackageStateStorePlugin,
} from './package-state-host-store.js';
export type { PackageStateStore } from './package-state-host-store.js';
// The dev schema self-heal decision (#21733) — public because `@objectstack/cli`
// is a reader, not a second home: its config-load fallback and its `telemetry`
// sibling read the SAME answer the standalone stack's `default` datasource does.
export { devAutoMigrateConfig } from './dev-auto-migrate.js';
export type { DevAutoMigrateConfig } from './dev-auto-migrate.js';
// [ADR-0025 §3.5 M1] The local plugin install loop's two stores — public because
// `@objectstack/cli` writes them (`os plugin trust`, `os plugin install`,
// `os plugin disable | enable | uninstall`) and the runtime's boot-time loader
// below reads the same ones.
export {
TRUSTED_KEY_OBJECT,
TRUSTED_KEY_ID_PATTERN,
publicKeyFingerprint,
readPublisherPublicKey,
listTrustedKeys,
addTrustedKey,
revokeTrustedKey,
resolveTrustedKey,
} from './plugin-trusted-keys.js';
export type {
TrustedKeyRow,
TrustedKeyStatus,
TrustedKeySource,
TrustedKeyEngine,
PublisherKeyRead,
PublisherKeyRefusal,
AddTrustedKeyResult,
AddTrustedKeyRefusal,
RevokeTrustedKeyResult,
TrustedKeyResolution,
} from './plugin-trusted-keys.js';
export {
DEFAULT_PLUGIN_ENVIRONMENT_ID,
INSTALLED_ARTIFACT_FILE,
INSTALLED_SIGNATURE_FILE,
INSTALLATIONS_LOCK_WAIT_MS,
INSTALLATIONS_LOCK_STALE_MS,
PluginInstallationsLockedError,
pluginsHome,
pluginInstallDir,
pluginInstallationsFile,
loadPluginInstallations,
recordPluginInstallation,
withPluginInstallationsLock,
markPluginUninstall,
dropPluginInstallation,
installedPluginDisabledIds,
setInstalledPluginDisabled,
} from './plugin-installation-store.js';
export type { PluginInstallationRecord } from './plugin-installation-store.js';
// The boot-time loader and its tier dispatch point (ADR-0025 §3.5 / §3.6, M1):
// `os serve` calls it before the kernel bootstraps and `kernel.use`s what it
// answers.
export {
dispatchPluginRuntime,
verifyInstalledPlugins,
loadInstalledPlugins,
} from './installed-plugin-loader.js';
// The one read of an artifact's compiled manifest, through `ManifestSchema`:
// `os plugin install` and the boot-time loader both ask it.
export { readCompiledPluginManifest } from './compiled-plugin-manifest.js';
export type { CompiledPluginManifestRead } from './compiled-plugin-manifest.js';
export type {
InstalledPluginRefusalCode,
InstalledPluginRefusal,
VerifiedInstalledPlugin,
InstalledPluginsVerdict,
VerifyInstalledPluginsInput,
LoadedInstalledPlugin,
InstalledPluginsLoad,
LoadInstalledPluginsInput,
} from './installed-plugin-loader.js';
// The ONE libSQL/Turso loader (commit 68f5eccb1). Public because `@objectstack/cli` is a
// consumer, not a second implementation: `utils/storage-driver.ts` delegates to
// `loadTursoDriverFactory` and RE-EXPORTS `MissingDriverPackageError`, so
// `serve.ts`'s `e instanceof MissingDriverPackageError` fatal branch tests one
// class identity rather than one of two same-named twins.
//
// Since #7314 that class — and the package / install-command pair — is DECLARED
// one layer down, in `@objectstack/service-datasource`, so the open-core loader
// can raise it too. This export surface is deliberately unchanged: that is what
// keeps every importer written against `@objectstack/runtime` compiling, and
// against the same class object.
export {
loadTursoDriverFactory,
isTursoDriverId,
MissingDriverPackageError,
TURSO_DRIVER_PACKAGE,
TURSO_DRIVER_INSTALL_COMMAND,
} from './turso-driver-factory.js';
export type { LoadTursoDriverFactoryOptions } from './turso-driver-factory.js';
// The ONE default-database resolution shared by `os dev` / `os start` /
// `os migrate` (#6469) — commands map their flags onto it; no command carries
// its own fallback filename.
export {
resolveProjectDatabaseUrl,
normalizeDatabaseUrl,
UNIFIED_DEFAULT_DB_FILENAME,
LEGACY_DEFAULT_DB_FILENAMES,
// The in-memory engine's retirement as a boot store: one predicate and one
// sentence, so the CLI's legacy `os serve` resolver refuses it exactly as
// this package's own doors do.
namesRetiredMemoryEngine,
retiredMemoryEngineMessage,
} from './resolve-project-database.js';
export type {
ResolveProjectDatabaseUrlOptions,
ResolvedProjectDatabaseUrl,
ProjectDatabaseUrlSource,
} from './resolve-project-database.js';
// Export Default Host (artifact-first, no objectstack.config.ts required)
export { createDefaultHostConfig, resolveDefaultArtifactPath } from './default-host.js';
export type { DefaultHostConfigOptions, DefaultHostConfigResult } from './default-host.js';
// Export Plugins
export { DriverPlugin } from './driver-plugin.js';
// Boot reconciliation for the ADR-0119 D2 migration journal (#4617) — surfaces
// runs that started and never concluded, and owns the `migration-plans`
// registry `os migrate resume` looks plans up in.
export { MigrationRecoveryPlugin, describeInterruptedRun } from './migration-recovery-plugin.js';
export {
OrganizationOwnershipBootGuardPlugin,
OrganizationOwnershipBirthMarkerPlugin,
ORGANIZATION_OWNERSHIP_BIRTH_MARKER_PLUGIN_NAME,
recordOrganizationOwnershipBirth,
OrganizationOwnershipBootRefusal,
ORGANIZATION_OWNERSHIP_BOOT_REFUSAL_CODE,
assertOrganizationOwnershipMigrated,
findV17ShapeTables,
isOrganizationOwnershipBootRefusal,
organizationOwnershipRefusalMessage,
} from './organization-ownership-boot-guard.js';
export type { OrganizationOwnershipBootGuardOptions, OrganizationOwnershipMarkerState } from './organization-ownership-boot-guard.js';
export { DefaultDatasourcePlugin } from './default-datasource-plugin.js';
export type { DefaultDatasourceDefinition, DefaultDatasourcePluginOptions } from './default-datasource-plugin.js';
export { AppPlugin, collectBundleHooks, collectBundleFunctions, collectBundleFunctionEntries, collectBundleActions } from './app-plugin.js';
// [#21321] The ONE binder of an app artifact's script-action bodies and body
// hooks, under the owner `app:<appId>` — called by `AppPlugin.start` and by the
// install-local plugin (`@objectstack/cloud-connection`) on install and rehydrate.
// [#21489] …and its job half: `scheduleAppArtifactJobs` schedules a package's
// jobs (a `body` runs sandboxed on every door), and `collectJobsWithoutBody`
// names the enabled jobs no JSON door can run (no `body`, or a `body` or `pull`
// that does not bind), which install-local refuses.
// [#21585] `collectHooksWithoutBody` names the hooks whose code is only a
// function-name `handler`: install-local refuses them, and withholds them on a
// rehydrate (`withholdHooksWithoutBody`).
export {
bindAppArtifactHandlers,
appArtifactHandlerOwner,
scheduleAppArtifactJobs,
collectJobsWithoutBody,
collectHooksWithoutBody,
} from './app-artifact-handlers.js';
export type {
AppArtifactHandlerBinding,
AppArtifactHandlerBindingOptions,
AppArtifactJobScheduling,
AppArtifactJobSchedulingOptions,
JobWithoutBody,
HookWithoutBody,
} from './app-artifact-handlers.js';
// [#28039] The ONE path that registers, records and connects the datasources a
// package declares — called by `AppPlugin.start` and by the install-local plugin
// (`@objectstack/cloud-connection`) on install and rehydrate — and [#28143] the
// ONE judge of who holds a datasource name, which the install door refuses on.
export { connectPackageDatasources, datasourceNameHolder } from './declared-datasources.js';
export type {
DatasourceNameHolding,
DeclaredDatasourceOwner,
OwnedDatasources,
PackageDatasourceOptions,
PackageDatasourceVerdict,
} from './declared-datasources.js';
// #14094 — what a DECLARATIVE job's handler is invoked with. A job has no graph,
// so unlike a flow `script` node it is given data reach (`ql`) instead of being a
// pure value-returner whose I/O the surrounding graph performs.
export type { JobHandlerContext } from './job-handler-context.js';
export { SeedLoaderService } from './seed-loader.js';
// Boot-summary seed outcome accumulator (#3415/#3430) — the single writer
// contract shared by AppPlugin and the marketplace rehydrate/heal path.
export { recordSeedOutcome } from './seed-summary.js';
export type { SeedSourceOutcome } from './seed-summary.js';
// Multi-tenant seed-replay registry (#3453) — the register-once-then-mutate
// contract shared by AppPlugin and the marketplace install path so a new org
// replays the UNION of every seed source, not just the first one.
export { mergeSeedDatasets, readSeedDatasets, registerSeedReplayerOnce } from './seed-datasets.js';
export { declareSeedSource, readSeedSettlement } from './seed-settlement.js';
// Per-organization seed locale (#30281) — the producer of `Seed.locale` that the
// marketplace install, reseed, rehydrate heal and per-org replay share.
export { appDefaultSeedLocale, describeSeedLocale, resolveSeedLocaleForLoad, seedsDeclareLocale } from './seed-locale.js';
export type { ResolvedSeedLocale, SeedLocaleQuestion, SeedLocaleSource } from './seed-locale.js';
export type { SeedSourceHandle } from './seed-settlement.js';
// External Datasource Federation — boot-validation gate (ADR-0015, Gate 2)
export { ExternalValidationPlugin, createExternalValidationPlugin } from './external-validation-plugin.js';
export type { ExternalSchemaDriftEvent } from './external-validation-plugin.js';
// NOTE: the runtime-UI datasource lifecycle host glue (ADR-0015 Addendum —
// default driver factory + secret binder) was extracted into the private
// `@objectstack/datasource-admin` package and no longer ships here.
export { createDispatcherPlugin } from './dispatcher-plugin.js';
export type { DispatcherPluginConfig } from './dispatcher-plugin.js';
export { createSystemEnvironmentPlugin, SYSTEM_ENVIRONMENT_ID } from './system-environment-plugin.js';
export type { SystemEnvironmentPluginConfig } from './system-environment-plugin.js';
// Export HTTP Server Components
// NOTE: the `HttpServer` delegating wrapper (`./http-server.ts`) is RETIRED
// (#5122, #4939 precedent). It declared `implements IHttpServer` but forwarded
// only the REQUIRED members, so every optional one — `getPort`, `getRawApp`
// and above all `setFallbackHandler`, the single seam declarative `apis:`
// endpoints enter through since #5111 — read as absent to the `typeof x ===
// 'function'` probe the contract tells consumers to use. Do not reintroduce a
// same-shaped wrapper: a host composes the framework by registering an
// `IHttpServer` ADAPTER INSTANCE as `http.server`, which is what every real
// host already does. Absence is held by `http-server-retirement.test.ts`.
export { HttpDispatcher } from './http-dispatcher.js';
export type { HttpProtocolContext, HttpDispatcherResult } from './http-dispatcher.js';
// ADR-0006 generic kernel-resolution seam (retained framework contract; the
// multi-tenant implementation lives in cloud `@objectstack/objectos-runtime`).
export type { KernelResolver } from './http-dispatcher.js';
// ADR-0076 D11 step ③ — thin domain-handler registry seam; owning service
// packages register normalized handlers via HttpDispatcher.registerDomainHandler.
export { DomainHandlerRegistry } from './domain-handler-registry.js';
export type { DomainRoute, DomainHandler, DomainRequest, DomainHandlerDeps } from './domain-handler-registry.js';
export { MiddlewareManager } from './middleware.js';
// The package disable door's dependent-rule verdict and its sentence, for a
// host door that takes a package out of service another way: the validation
// rules a disable would leave reading a withheld `objectExtensions` field, and
// the `409 PACKAGE_DISABLE_RESTRICTED_BY_VALIDATION_RULE` message naming them.
// The same two functions `PATCH /packages/:id/disable` asks: one scan, one
// sentence. ⛔ Never re-spell either in a host.
export {
readDisableDependentRules as readPackageDisableDependents,
disableDependentRulesMessage as formatPackageDisableDependents,
} from './domains/packages.js';
export type { DisableDependentRule } from './domains/packages.js';
// ── Security primitives ───────────────────────────────────────────────
// Adapter-agnostic helpers for response hardening (CSP/HSTS/XCTO/…) and
// token-bucket rate limiting.
//
// The dispatcher plugin wires BOTH automatically: security headers on
// every response it mounts, and — when the stack declares
// `server.security.rateLimit` — the inbound limiter as global middleware
// on the `http.server` service (#4910). The pieces stay exported because
// a host that composes its own transport still needs them; they are not
// exported *instead* of being wired, which is what the previous version
// of this comment claimed while pointing at a guide that did not exist
// (#4937).
export {
buildSecurityHeaders,
type SecurityHeadersOptions,
RateLimiter,
DEFAULT_RATE_LIMITS,
applyTokenBucket,
bucketIdleTtlSeconds,
type BucketState,
type RateLimitBucketConfig,
type RateLimitDecision,
type RateLimitDefaults,
type RateLimitStore,
createInboundRateLimitMiddleware,
deriveBucketConfig,
resolveRateLimitKey,
SharedTokenBucketLimiter,
type InboundRateLimitBudget,
type InboundRateLimitOptions,
type RateLimitKeyInput,
type RateLimitKeyKind,
type RateLimitLogger,
type ActorUser,
carriedPackageIds,
resolveArtifactGrantBinding,
registerArtifactGrantedPermissions,
type ArtifactGrantBinding,
} from './security/index.js';
// ── Observability primitives ──────────────────────────────────────────
// Request-id propagation (X-Request-Id + W3C traceparent), pluggable
// MetricsRegistry, and pluggable ErrorReporter. The dispatcher plugin
// wraps every route with instrumentation when these are configured;
// see `docs/guide/observability.md`.
export {
extractRequestId,
generateRequestId,
resolveRequestId,
parseTraceparent,
formatTraceparent,
type TraceContext,
NoopMetricsRegistry,
InMemoryMetricsRegistry,
RUNTIME_METRICS,
type MetricsRegistry,
type MetricSample,
NoopErrorReporter,
InMemoryErrorReporter,
type ErrorReporter,
type CapturedError,
ObservabilityServicePlugin,
OBSERVABILITY_METRICS_SERVICE,
OBSERVABILITY_ERRORS_SERVICE,
resolveMetrics,
resolveErrorReporter,
type ObservabilityServicePluginOptions,
} from './observability/index.js';
// Export Artifact Loader
export { loadArtifactBundle, mergeRuntimeModule, isHttpUrl, readArtifactSource } from './load-artifact-bundle.js';
export type { LoadArtifactBundleOptions } from './load-artifact-bundle.js';
// Artifact-pinned boot (#8368) — `OS_ARTIFACT_URL`, the SRI-style `#sha256=`
// fragment pin, and the verified local materialisation the boot reads.
export {
OS_ARTIFACT_URL_ENV,
DEFAULT_ARTIFACT_FETCH_TIMEOUT_MS,
ArtifactReferenceError,
parseArtifactReference,
resolveArtifactReference,
resolveArtifactFetchTimeoutMs,
assertArtifactProtocolCompatible,
redactArtifactUrl,
makeArtifactUrlScrubber,
sha256Hex,
artifactCacheDir,
pinnedCachePath,
stagedArtifactPath,
} from './artifact-reference.js';
export type {
ArtifactOrigin,
ArtifactReferenceErrorCode,
ArtifactReferenceKind,
ParsedArtifactReference,
ResolveArtifactReferenceOptions,
ResolvedArtifactReference,
} from './artifact-reference.js';
// ── ObjectOS Cloud Runtime (artifact-fetching shared multi-tenant host) ───────
// Multi-tenant / cloud-operations code is NOT part of the framework
// (ADR-0006). The MULTI-TENANT runtime — createObjectOSStack, the kernel
// manager, environment registries, artifact fetching, the auth proxy,
// per-environment kernel construction, platform SSO, marketplace
// browse/install, the runtime-config endpoint — lives in the cloud
// distribution (`@objectstack/objectos-runtime`). Phase 4 removed the
// framework's duplicate cloud plugins (= cloud ADR-0007 ⑤); Phase 5
// converged the dispatcher's environment resolution + kernel routing into
// the single generic `KernelResolver` seam (exported above with
// HttpDispatcher) — the only multi-tenant contract the framework retains.
// Export Sandbox (script body runner) — engine choice is quickjs-emscripten.
// See packages/runtime/src/sandbox/script-runner.ts for the decision rationale.
export { UnimplementedScriptRunner, QuickJSScriptRunner, SandboxError, hookBodyRunnerFactory, actionBodyRunnerFactory } from './sandbox/index.js';
export type {
ScriptRunner,
ScriptContext,
ScriptOrigin,
ScriptResult,
ScriptRunOptions,
ScriptSession,
ScriptUser,
QuickJSScriptRunnerOptions,
} from './sandbox/index.js';
// Re-export from @objectstack/rest
export {
RestServer,
RouteManager,
RouteGroupBuilder,
createRestApiPlugin,
} from '@objectstack/rest';
export type {
RouteEntry,
RestApiPluginConfig,
} from '@objectstack/rest';
// Export Types
export * from '@objectstack/core';
export { readEnvWithDeprecation, _resetEnvDeprecationWarnings } from '@objectstack/types';