@almadar/shell-runtime 0.0.0-stage → 0.1.0
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/dist/chunk-2JU7Y4KU.js +21 -0
- package/dist/chunk-46RWK2B5.js +28 -0
- package/dist/chunk-4J2QEIUV.js +78 -0
- package/dist/chunk-4SEK5ER2.js +8 -0
- package/dist/chunk-4ZICQ5PM.js +192 -0
- package/dist/chunk-53IPZXDP.js +76 -0
- package/dist/chunk-5D63EMO5.js +16 -0
- package/dist/chunk-64IH2SMY.js +22 -0
- package/dist/chunk-7SDV3QWR.js +67 -0
- package/dist/chunk-CPSQXEJ6.js +55 -0
- package/dist/chunk-CQP5XAX6.js +173 -0
- package/dist/chunk-CROS2GEX.js +49 -0
- package/dist/chunk-D4XJTBLB.js +217 -0
- package/dist/chunk-D5USD2EX.js +232 -0
- package/dist/chunk-DYOJGLIX.js +25 -0
- package/dist/chunk-ELBLT2HZ.js +1 -0
- package/dist/chunk-EV56K4GB.js +63 -0
- package/dist/chunk-EZZYLTWY.js +1 -0
- package/dist/chunk-FQ6IZMIU.js +10 -0
- package/dist/chunk-FWA5K7Q2.js +48 -0
- package/dist/chunk-HC6ERSAH.js +55 -0
- package/dist/chunk-HLOUDLPI.js +48 -0
- package/dist/chunk-HMK6YMQS.js +135 -0
- package/dist/chunk-HNOAZWFH.js +19 -0
- package/dist/chunk-IHQLE5M7.js +62 -0
- package/dist/chunk-IOPUS6Q5.js +15 -0
- package/dist/chunk-JFWFDUTR.js +35 -0
- package/dist/chunk-LZIOTBFX.js +1 -0
- package/dist/chunk-MHYSHSRG.js +54 -0
- package/dist/chunk-MLKGABMK.js +7 -0
- package/dist/chunk-MZKIL5IN.js +74 -0
- package/dist/chunk-NAECVIAR.js +322 -0
- package/dist/chunk-NATGCIVM.js +583 -0
- package/dist/chunk-O57GKTYU.js +30 -0
- package/dist/chunk-ODJCZ27I.js +50 -0
- package/dist/chunk-P53CKOME.js +1 -0
- package/dist/chunk-Q2H75UYT.js +92 -0
- package/dist/chunk-Q7JK4KY7.js +9 -0
- package/dist/chunk-QELZ6TEJ.js +208 -0
- package/dist/chunk-QQRDUMB2.js +40 -0
- package/dist/chunk-RBUMDYFS.js +681 -0
- package/dist/chunk-REPX5QPI.js +57 -0
- package/dist/chunk-SAS5KKCR.js +43 -0
- package/dist/chunk-SKLMWHQD.js +109 -0
- package/dist/chunk-SOQDEPME.js +131 -0
- package/dist/chunk-SWPDU752.js +28 -0
- package/dist/chunk-T775TUCD.js +18 -0
- package/dist/chunk-UBN5JJKZ.js +26 -0
- package/dist/chunk-UJHOUZAL.js +36 -0
- package/dist/chunk-UP6GGGAN.js +34 -0
- package/dist/chunk-VMOBW7RK.js +21 -0
- package/dist/chunk-VNMG7NKY.js +69 -0
- package/dist/chunk-WNPNNYXY.js +22 -0
- package/dist/chunk-XB5GYODW.js +28 -0
- package/dist/chunk-XXWNMJI6.js +15 -0
- package/dist/chunk-YL2SO5TP.js +334 -0
- package/dist/chunk-YO4LWS3I.js +606 -0
- package/dist/chunk-ZAQSS47X.js +157 -0
- package/dist/chunk-ZCQUUJIF.js +129 -0
- package/dist/client/EventTransport.d.ts +131 -0
- package/dist/client/EventTransport.js +2 -0
- package/dist/client/ServerBridge.d.ts +126 -0
- package/dist/client/ServerBridge.js +3 -0
- package/dist/client/awaiting.d.ts +28 -0
- package/dist/client/awaiting.js +2 -0
- package/dist/client/channel-transport.d.ts +69 -0
- package/dist/client/channel-transport.js +2 -0
- package/dist/client/circuit-store.d.ts +76 -0
- package/dist/client/circuit-store.js +4 -0
- package/dist/client/client-kernel.d.ts +113 -0
- package/dist/client/client-kernel.js +1 -0
- package/dist/client/declared-input-dispatch.d.ts +5 -0
- package/dist/client/declared-input-dispatch.js +2 -0
- package/dist/client/inbound-dispatch.d.ts +5 -0
- package/dist/client/inbound-dispatch.js +2 -0
- package/dist/client/local-fold.d.ts +26 -0
- package/dist/client/local-fold.js +2 -0
- package/dist/client/render-sigils.d.ts +24 -0
- package/dist/client/render-sigils.js +2 -0
- package/dist/client/state-book.d.ts +37 -0
- package/dist/client/state-book.js +2 -0
- package/dist/client/trait-mount-error.d.ts +9 -0
- package/dist/client/trait-mount-error.js +2 -0
- package/dist/client/trait-types.d.ts +67 -0
- package/dist/client/trait-types.js +1 -0
- package/dist/credentials/env-vars.d.ts +14 -0
- package/dist/credentials/env-vars.js +3 -0
- package/dist/credentials/scope.d.ts +50 -0
- package/dist/credentials/scope.js +2 -0
- package/dist/credentials/seed.d.ts +21 -0
- package/dist/credentials/seed.js +2 -0
- package/dist/credentials/store.d.ts +110 -0
- package/dist/credentials/store.js +2 -0
- package/dist/effects/in-flight-calls.d.ts +36 -0
- package/dist/effects/in-flight-calls.js +2 -0
- package/dist/effects/on-device-model.d.ts +22 -0
- package/dist/effects/on-device-model.js +2 -0
- package/dist/events/EventBus.d.ts +90 -0
- package/dist/events/EventBus.js +2 -0
- package/dist/events/emit-stamp.d.ts +47 -0
- package/dist/events/emit-stamp.js +2 -0
- package/dist/index-hT1xCdTq.d.ts +46 -0
- package/dist/index.d.ts +60 -0
- package/dist/index.js +59 -0
- package/dist/kernel/beacon.d.ts +32 -0
- package/dist/kernel/beacon.js +2 -0
- package/dist/kernel/decode.d.ts +15 -0
- package/dist/kernel/decode.js +2 -0
- package/dist/kernel/engine.d.ts +94 -0
- package/dist/kernel/engine.js +11 -0
- package/dist/kernel/frame-applier.d.ts +43 -0
- package/dist/kernel/frame-applier.js +2 -0
- package/dist/kernel/host.d.ts +95 -0
- package/dist/kernel/host.js +9 -0
- package/dist/kernel/http.d.ts +302 -0
- package/dist/kernel/http.js +6 -0
- package/dist/kernel/lane.d.ts +28 -0
- package/dist/kernel/lane.js +2 -0
- package/dist/kernel/oauth-effects.d.ts +25 -0
- package/dist/kernel/oauth-effects.js +7 -0
- package/dist/kernel/oauth-port.d.ts +31 -0
- package/dist/kernel/oauth-port.js +2 -0
- package/dist/kernel/os-port.d.ts +133 -0
- package/dist/kernel/os-port.js +2 -0
- package/dist/kernel/program-effects.d.ts +65 -0
- package/dist/kernel/program-effects.js +2 -0
- package/dist/kernel/wire.d.ts +66 -0
- package/dist/kernel/wire.js +1 -0
- package/dist/loader/http-loader.d.ts +111 -0
- package/dist/loader/http-loader.js +2 -0
- package/dist/loader/lazy-page.d.ts +12 -0
- package/dist/loader/lazy-page.js +2 -0
- package/dist/loader/schema-loader.d.ts +160 -0
- package/dist/loader/schema-loader.js +1 -0
- package/dist/persistence/native-memory.d.ts +28 -0
- package/dist/persistence/native-memory.js +2 -0
- package/dist/runtime/effects/composition/compose-behaviors.d.ts +58 -0
- package/dist/runtime/effects/composition/compose-behaviors.js +4 -0
- package/dist/runtime/effects/composition/event-wiring.d.ts +38 -0
- package/dist/runtime/effects/composition/event-wiring.js +2 -0
- package/dist/runtime/effects/composition/index.d.ts +5 -0
- package/dist/runtime/effects/composition/index.js +6 -0
- package/dist/runtime/effects/composition/layout-strategy.d.ts +35 -0
- package/dist/runtime/effects/composition/layout-strategy.js +2 -0
- package/dist/runtime/effects/composition/pipe.d.ts +25 -0
- package/dist/runtime/effects/composition/pipe.js +2 -0
- package/dist/runtime/entities/mockStoreSeed.d.ts +56 -0
- package/dist/runtime/entities/mockStoreSeed.js +3 -0
- package/dist/runtime/entities/seedBrowserStore.d.ts +28 -0
- package/dist/runtime/entities/seedBrowserStore.js +2 -0
- package/dist/runtime/entities/std-mock-seed.d.ts +87 -0
- package/dist/runtime/entities/std-mock-seed.js +2 -0
- package/dist/runtime/evaluation/local-store-transport.d.ts +68 -0
- package/dist/runtime/evaluation/local-store-transport.js +18 -0
- package/dist/runtime/evaluation/residence-transport.d.ts +15 -0
- package/dist/runtime/evaluation/residence-transport.js +2 -0
- package/dist/runtime/evaluation/routed-persistence.d.ts +9 -0
- package/dist/runtime/evaluation/routed-persistence.js +2 -0
- package/dist/runtime/events/identity/routing.d.ts +84 -0
- package/dist/runtime/events/identity/routing.js +2 -0
- package/dist/runtime/time/TickScheduler.d.ts +77 -0
- package/dist/runtime/time/TickScheduler.js +3 -0
- package/dist/runtime/time/cron.d.ts +25 -0
- package/dist/runtime/time/cron.js +2 -0
- package/dist/runtime/time/duration.d.ts +20 -0
- package/dist/runtime/time/duration.js +2 -0
- package/dist/runtime/traits/OrbitalTraitParsing.d.ts +34 -0
- package/dist/runtime/traits/OrbitalTraitParsing.js +2 -0
- package/dist/runtime/traits/listen-targets.d.ts +16 -0
- package/dist/runtime/traits/listen-targets.js +3 -0
- package/dist/runtime/traits/trait-index.d.ts +35 -0
- package/dist/runtime/traits/trait-index.js +3 -0
- package/dist/runtime/types.d.ts +574 -0
- package/dist/runtime/types.js +2 -0
- package/dist/service/default-call-service.d.ts +23 -0
- package/dist/service/default-call-service.js +3 -0
- package/dist/service/service-provider.d.ts +37 -0
- package/dist/service/service-provider.js +2 -0
- package/package.json +46 -3
- package/README.md +0 -3
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { ProgramInspection, CatalogEntry, TraitDescription, BehaviorDescription, OrbitalSchema, EvaluatedProgram, ProgramValidationIssue, DependencyGraph, EventPayload, CircuitStepResult } from '@almadar/core';
|
|
2
|
+
|
|
3
|
+
/** The effects the language trio routes to this host. */
|
|
4
|
+
declare const PROGRAM_EFFECTS: readonly ["behavior/catalog", "behavior/describe", "behavior/source", "behavior/resolve", "behavior/dependencies", "program/read", "program/print", "program/eval", "program/validate", "program/compose", "program/step"];
|
|
5
|
+
type ProgramEffectName = (typeof PROGRAM_EFFECTS)[number];
|
|
6
|
+
/** Narrow an effect head to one this host runs. */
|
|
7
|
+
declare function isProgramEffect(name: string): name is ProgramEffectName;
|
|
8
|
+
/** What `program/validate` returns. */
|
|
9
|
+
interface ProgramValidationReport {
|
|
10
|
+
readonly valid: boolean;
|
|
11
|
+
readonly errors: readonly ProgramValidationIssue[];
|
|
12
|
+
readonly warnings: readonly ProgramValidationIssue[];
|
|
13
|
+
}
|
|
14
|
+
/** One transition a host asks to play: the trait, the state it plays from, and the event with its payload. */
|
|
15
|
+
interface StepRequest {
|
|
16
|
+
orbital: string;
|
|
17
|
+
trait: string;
|
|
18
|
+
from: string;
|
|
19
|
+
event: string;
|
|
20
|
+
payload: EventPayload;
|
|
21
|
+
/** Fields merged into the trait's entity row before the event. */
|
|
22
|
+
entity?: EventPayload;
|
|
23
|
+
/** Knob values over the trait's declared config defaults, for this request's trait only. */
|
|
24
|
+
config?: EventPayload;
|
|
25
|
+
/** The ms-epoch `@now` the step's dispatch reads, in place of the wall clock. */
|
|
26
|
+
now?: number;
|
|
27
|
+
/** A live call's cutoff: an open call still running after this many ms is cancelled. */
|
|
28
|
+
settleMs?: number;
|
|
29
|
+
/** The user the request dispatches as (`@user`); null or absent is nobody. */
|
|
30
|
+
viewer?: EventPayload | null;
|
|
31
|
+
}
|
|
32
|
+
/** One trait the step's dispatch cascade moved, in dispatch order. */
|
|
33
|
+
interface CascadeOutcome {
|
|
34
|
+
orbital: string;
|
|
35
|
+
trait: string;
|
|
36
|
+
/** The event this trait handled (a listener's own triggered event). */
|
|
37
|
+
event: string;
|
|
38
|
+
from: string;
|
|
39
|
+
to: string;
|
|
40
|
+
/** The arm that fired; null when none did. */
|
|
41
|
+
arm: number | null;
|
|
42
|
+
fired: boolean;
|
|
43
|
+
/** The effects of the arm this trait fired, as the top-level `effects` report them. */
|
|
44
|
+
effects: CircuitStepResult['effects'];
|
|
45
|
+
emitted: CircuitStepResult['emitted'];
|
|
46
|
+
}
|
|
47
|
+
/** A played request: the request as asked, and the circuit it ran, with every trait its cascade moved. */
|
|
48
|
+
type PlayedStep = StepRequest & {
|
|
49
|
+
result: CircuitStepResult & {
|
|
50
|
+
outcomes: CascadeOutcome[];
|
|
51
|
+
entityAfter: EventPayload | null;
|
|
52
|
+
};
|
|
53
|
+
};
|
|
54
|
+
/** The outcome of one program effect: the value for `{ result }`, or the failure (`errors` for eval's validator issues). */
|
|
55
|
+
type ProgramEffectOutcome = {
|
|
56
|
+
readonly ok: true;
|
|
57
|
+
readonly result: ProgramInspection | CatalogEntry[] | TraitDescription | BehaviorDescription | OrbitalSchema | string | EvaluatedProgram | ProgramValidationReport | DependencyGraph | PlayedStep[];
|
|
58
|
+
} | {
|
|
59
|
+
readonly ok: false;
|
|
60
|
+
readonly error: string;
|
|
61
|
+
readonly errors?: readonly ProgramValidationIssue[];
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
export { PROGRAM_EFFECTS, isProgramEffect };
|
|
65
|
+
export type { CascadeOutcome, PlayedStep, ProgramEffectName, ProgramEffectOutcome, ProgramValidationReport, StepRequest };
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { KernelEvaluatorExports } from '@almadar/core';
|
|
2
|
+
export { CallRoutesWire, CallSiteWire, CallerWire, HttpBody, HttpFailureWire, HttpRequestWire, HttpResponseWire, IoAnswerWire, IoReplyWire, IoRequestWire, PendingRequestWire, ResolveProgressWire, ServerProgressWire, Settled, SubstrateFailureWire } from '@almadar/core/kernel-wire';
|
|
3
|
+
|
|
4
|
+
/** The `Server` class of `@almadar/kernel` (wasm-bindgen), as the runtime uses it. */
|
|
5
|
+
interface KernelServerHandle {
|
|
6
|
+
start(orbital: string, requestJson: string): string;
|
|
7
|
+
resume(flight: number, repliesJson: string): string;
|
|
8
|
+
dispatchStream(): string;
|
|
9
|
+
liveItemDelivered(itemJson: string, viewerJson: string, clientId?: string): boolean;
|
|
10
|
+
/** A row-set reference resolved for a viewer through the host-answered store; a `ResolveProgressWire` as JSON. */
|
|
11
|
+
resolveRows(refJson: string, viewerJson: string): string;
|
|
12
|
+
resumeResolve(flight: number, repliesJson: string): string;
|
|
13
|
+
abandon(flight: number): boolean;
|
|
14
|
+
/** `OsGrants::allows` over the grants the registered program declares; `requirementJson` is an `OsRequirement`. */
|
|
15
|
+
osAllows(requirementJson: string): boolean;
|
|
16
|
+
/** Place the program's anchored grants and arguments under the host's anchors; answers `[{ path, message }]` for what grants nothing. */
|
|
17
|
+
setOsAnchors(anchorsJson: string): string;
|
|
18
|
+
/** An `os/` call's arguments with its anchored parts resolved; a `Settled<args, OsError>` as JSON. */
|
|
19
|
+
osResolveArgs(op: string, argsJson: string): string;
|
|
20
|
+
inFlight(): number;
|
|
21
|
+
getState(traitName: string, entityId?: string): string;
|
|
22
|
+
setDefaultUser(userJson: string): void;
|
|
23
|
+
/** The kernel's mounts for a host start on `side` (`client|server|process|start`): `MountSeed[]` as JSON. */
|
|
24
|
+
bootMounts(side: string): string;
|
|
25
|
+
/** The kernel's mounts for a client opening `routePath`: `MountSeed[]` as JSON. */
|
|
26
|
+
routeMounts(routePath: string): string;
|
|
27
|
+
mount(traitsJson: string): void;
|
|
28
|
+
remount(traitsJson: string): void;
|
|
29
|
+
setTickMount(traitsJson: string): void;
|
|
30
|
+
/** Mock-seed the `[runtime]` entities the kernel holds itself, owner columns stamped with `viewerId` (a preview host). */
|
|
31
|
+
seedRuntimeMock(viewerId?: string): void;
|
|
32
|
+
setCapabilities(entityType: string, queryJson: string, writeJson: string): void;
|
|
33
|
+
setMessages(localesJson: string, catalogsJson: string): void;
|
|
34
|
+
/** The program (as JSON) whose declared credentials this server's credential effects manage beside its own. */
|
|
35
|
+
setManagedProgram(programJson: string): void;
|
|
36
|
+
lastError(): string;
|
|
37
|
+
/** A server holding this one's registered program and none of its session (a stateless request's kernel). */
|
|
38
|
+
fork(): KernelServerHandle;
|
|
39
|
+
forkProgram(programJson: string): KernelServerHandle;
|
|
40
|
+
free(): void;
|
|
41
|
+
}
|
|
42
|
+
/** The `Server` constructor of a kernel module. */
|
|
43
|
+
interface KernelServerClass {
|
|
44
|
+
new (resolvedSchemaJson: string): KernelServerHandle;
|
|
45
|
+
}
|
|
46
|
+
/** An initialised `@almadar/kernel` module: what `OrbitalServerRuntime({ engine: 'kernel' })` is handed. */
|
|
47
|
+
interface KernelModule extends KernelEvaluatorExports {
|
|
48
|
+
Server: KernelServerClass;
|
|
49
|
+
/** Whether the absolute `glob` matches `path`, as the one-grant matcher `os/glob` filters with. */
|
|
50
|
+
osGlobMatches(glob: string, path: string): boolean;
|
|
51
|
+
/** `is_public_address`: the rule an outbound host name must pass. */
|
|
52
|
+
isPublicAddress(ip: string): boolean;
|
|
53
|
+
/** The `os/` operations whose keyed call may defer its completion (`OsOp::defers_completion`), as a JSON array of names. */
|
|
54
|
+
osDeferringOps(): string;
|
|
55
|
+
/** The `os/` operations whose keyed call is a stream (`OsOp::is_stream`), as a JSON array of names. */
|
|
56
|
+
osStreamOps(): string;
|
|
57
|
+
/** The `{ event, payload }` JSON a deferred keyed `os/` call's outcome fires on its call site, or `null` when it declares no route. */
|
|
58
|
+
osCompletionEvent(siteJson: string, key: string, outcomeJson: string): string;
|
|
59
|
+
substrateCompletionEvent(siteJson: string, key: string, op: string, argsJson: string, outcomeJson: string): string;
|
|
60
|
+
/** Whether the Chrome match pattern matches the URL: the one rule a browser-tab host filters tabs with. */
|
|
61
|
+
tabUrlMatches(pattern: string, url: string): boolean;
|
|
62
|
+
/** Installs the language data (`@almadar/core/language-data` `LanguageBundle` as JSON) for a host with no `node_modules`; the first install wins. */
|
|
63
|
+
installLanguage(bundleJson: string): void;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
export type { KernelModule, KernelServerClass, KernelServerHandle };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import '../chunk-EZZYLTWY.js';
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import { ImportChainLike, SchemaLoader, HttpLoaderOptions, LoadResult, LoadedSchema, LoadedOrbital } from './schema-loader.js';
|
|
2
|
+
import '@almadar/core';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* HTTP Schema Loader
|
|
6
|
+
*
|
|
7
|
+
* Loads OrbitalSchema files via HTTP/fetch for browser environments.
|
|
8
|
+
* Also works in Node.js with the fetch API.
|
|
9
|
+
*
|
|
10
|
+
* @packageDocumentation
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
declare class HttpImportChain implements ImportChainLike {
|
|
14
|
+
private chain;
|
|
15
|
+
/**
|
|
16
|
+
* Try to add a path to the chain.
|
|
17
|
+
* @returns Error message if circular, null if OK
|
|
18
|
+
*/
|
|
19
|
+
push(absolutePath: string): string | null;
|
|
20
|
+
/**
|
|
21
|
+
* Remove the last path from the chain.
|
|
22
|
+
*/
|
|
23
|
+
pop(): void;
|
|
24
|
+
/**
|
|
25
|
+
* Clone the chain for nested loading.
|
|
26
|
+
*/
|
|
27
|
+
clone(): HttpImportChain;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* HttpLoader - Loads OrbitalSchema files via HTTP/fetch.
|
|
31
|
+
*
|
|
32
|
+
* Designed for browser environments where file system access is not available.
|
|
33
|
+
* Uses the fetch API for loading schemas.
|
|
34
|
+
*
|
|
35
|
+
* Path Resolution:
|
|
36
|
+
* - Relative paths: `./health.orb` -> base URL + path
|
|
37
|
+
* - Standard library: `std/behaviors/game-core` -> std lib URL + path
|
|
38
|
+
* - Scoped packages: `@scope/pkg.orb` -> scoped URL + path
|
|
39
|
+
* - Absolute URLs: `https://...` -> used directly
|
|
40
|
+
*
|
|
41
|
+
* @example
|
|
42
|
+
* ```typescript
|
|
43
|
+
* const loader = new HttpLoader({
|
|
44
|
+
* basePath: "/api/schemas",
|
|
45
|
+
* stdLibPath: "https://cdn.example.com/orbital-std",
|
|
46
|
+
* });
|
|
47
|
+
*
|
|
48
|
+
* // Load from relative path
|
|
49
|
+
* const result = await loader.load("./my-schema.orb");
|
|
50
|
+
*
|
|
51
|
+
* // Load from std library
|
|
52
|
+
* const stdResult = await loader.load("std/behaviors/game-core");
|
|
53
|
+
* ```
|
|
54
|
+
*/
|
|
55
|
+
declare class HttpLoader implements SchemaLoader {
|
|
56
|
+
private options;
|
|
57
|
+
private cache;
|
|
58
|
+
constructor(options: HttpLoaderOptions);
|
|
59
|
+
/**
|
|
60
|
+
* Load a schema from an import path.
|
|
61
|
+
*/
|
|
62
|
+
load(importPath: string, fromPath?: string, chain?: ImportChainLike): Promise<LoadResult<LoadedSchema>>;
|
|
63
|
+
/**
|
|
64
|
+
* Load a specific orbital from a schema by name.
|
|
65
|
+
*/
|
|
66
|
+
loadOrbital(importPath: string, orbitalName?: string, fromPath?: string, chain?: ImportChainLike): Promise<LoadResult<LoadedOrbital>>;
|
|
67
|
+
/**
|
|
68
|
+
* Resolve an import path to an absolute URL.
|
|
69
|
+
*/
|
|
70
|
+
resolvePath(importPath: string, fromPath?: string): LoadResult<string>;
|
|
71
|
+
/**
|
|
72
|
+
* Resolve a standard library path.
|
|
73
|
+
*/
|
|
74
|
+
private resolveStdPath;
|
|
75
|
+
/**
|
|
76
|
+
* Resolve a scoped package path.
|
|
77
|
+
*/
|
|
78
|
+
private resolveScopedPath;
|
|
79
|
+
/**
|
|
80
|
+
* Resolve a relative path.
|
|
81
|
+
*/
|
|
82
|
+
private resolveRelativePath;
|
|
83
|
+
/**
|
|
84
|
+
* Fetch and parse an OrbitalSchema from a URL.
|
|
85
|
+
*/
|
|
86
|
+
private fetchSchema;
|
|
87
|
+
/**
|
|
88
|
+
* Join URL parts, handling relative paths and trailing slashes.
|
|
89
|
+
*/
|
|
90
|
+
private joinUrl;
|
|
91
|
+
/**
|
|
92
|
+
* Get parent URL (directory) from a URL.
|
|
93
|
+
*/
|
|
94
|
+
private getParentUrl;
|
|
95
|
+
/**
|
|
96
|
+
* Clear the cache.
|
|
97
|
+
*/
|
|
98
|
+
clearCache(): void;
|
|
99
|
+
/**
|
|
100
|
+
* Get cache statistics.
|
|
101
|
+
*/
|
|
102
|
+
getCacheStats(): {
|
|
103
|
+
size: number;
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Create an HTTP loader with sensible defaults.
|
|
108
|
+
*/
|
|
109
|
+
declare function createHttpLoader(basePath: string, options?: Partial<HttpLoaderOptions>): HttpLoader;
|
|
110
|
+
|
|
111
|
+
export { HttpImportChain, HttpLoader, createHttpLoader };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { LazyPage, OrbitalSchema } from '@almadar/core';
|
|
2
|
+
import { SchemaLoader, LoadResult } from './schema-loader.js';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* `uses lazy`: the behavior behind a lazy page lives in its own `.orb`, at the
|
|
6
|
+
* page's `orbRef` relative to the importer's `.orb`, and is loaded when the
|
|
7
|
+
* page is opened.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
declare function loadLazyPage(loader: SchemaLoader, page: LazyPage, importerPath?: string): Promise<LoadResult<OrbitalSchema>>;
|
|
11
|
+
|
|
12
|
+
export { loadLazyPage };
|
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
import { OrbitalSchema, Orbital, DeclaredTraitConfig } from '@almadar/core';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* SchemaLoader Interface
|
|
5
|
+
*
|
|
6
|
+
* Abstract interface for loading OrbitalSchema files from various sources.
|
|
7
|
+
* Implementations exist for:
|
|
8
|
+
* - FileSystemLoader (Node.js) - uses fs module
|
|
9
|
+
* - HttpLoader (Browser) - uses fetch API
|
|
10
|
+
* - UnifiedLoader (Auto-detect) - routes to appropriate loader
|
|
11
|
+
*
|
|
12
|
+
* @packageDocumentation
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Result of loading a schema.
|
|
17
|
+
*/
|
|
18
|
+
interface LoadedSchema {
|
|
19
|
+
/** The loaded schema */
|
|
20
|
+
schema: OrbitalSchema;
|
|
21
|
+
/** Source path/URL (resolved) */
|
|
22
|
+
sourcePath: string;
|
|
23
|
+
/** Original import path */
|
|
24
|
+
importPath: string;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Result of loading a single orbital from a schema.
|
|
28
|
+
*/
|
|
29
|
+
interface LoadedOrbital {
|
|
30
|
+
/** The loaded orbital — the named one when requested, else the first. */
|
|
31
|
+
orbital: Orbital;
|
|
32
|
+
/**
|
|
33
|
+
* EVERY orbital in the loaded schema. `Alias.traits.X` carries no orbital
|
|
34
|
+
* segment, so a multi-orbital behavior's traits and pages must all stay
|
|
35
|
+
* reachable; resolving against `orbital` alone silently loses everything
|
|
36
|
+
* outside it. Mirrors the compiled path's `AliasEntry.orbitals`.
|
|
37
|
+
*/
|
|
38
|
+
orbitals?: Orbital[];
|
|
39
|
+
/**
|
|
40
|
+
* The loaded schema's own app-level `config`, when it declares one.
|
|
41
|
+
* Traits from this orbital must resolve against THIS config, not the
|
|
42
|
+
* consumer's — omitted (never `undefined`) when the schema declares none.
|
|
43
|
+
*/
|
|
44
|
+
schemaConfig?: DeclaredTraitConfig;
|
|
45
|
+
/** Source path/URL (resolved) */
|
|
46
|
+
sourcePath: string;
|
|
47
|
+
/** Original import path */
|
|
48
|
+
importPath: string;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Loader result with error handling.
|
|
52
|
+
*/
|
|
53
|
+
type LoadResult<T> = {
|
|
54
|
+
success: true;
|
|
55
|
+
data: T;
|
|
56
|
+
} | {
|
|
57
|
+
success: false;
|
|
58
|
+
error: string;
|
|
59
|
+
};
|
|
60
|
+
/**
|
|
61
|
+
* Base options for all loaders.
|
|
62
|
+
*/
|
|
63
|
+
interface BaseLoaderOptions {
|
|
64
|
+
/** Base path/URL for resolving relative imports */
|
|
65
|
+
basePath: string;
|
|
66
|
+
/** Standard library root path/URL */
|
|
67
|
+
stdLibPath?: string;
|
|
68
|
+
/** Scoped package roots (e.g., { "@game-lib": "/path/to/lib" }) */
|
|
69
|
+
scopedPaths?: Record<string, string>;
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Options for HTTP loading.
|
|
73
|
+
*/
|
|
74
|
+
interface HttpLoaderOptions extends BaseLoaderOptions {
|
|
75
|
+
/** Default fetch options */
|
|
76
|
+
fetchOptions?: RequestInit;
|
|
77
|
+
/** Request timeout in milliseconds */
|
|
78
|
+
timeout?: number;
|
|
79
|
+
/** Whether to use credentials (cookies, auth headers) */
|
|
80
|
+
credentials?: RequestCredentials;
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Abstract interface for schema loaders.
|
|
84
|
+
*
|
|
85
|
+
* All loaders must implement:
|
|
86
|
+
* - load() - Load a schema from an import path
|
|
87
|
+
* - resolvePath() - Resolve an import path to absolute path/URL
|
|
88
|
+
*
|
|
89
|
+
* @example
|
|
90
|
+
* ```typescript
|
|
91
|
+
* // Using FileSystemLoader (Node.js)
|
|
92
|
+
* const loader: SchemaLoader = new FileSystemLoader({ basePath: "/schemas" });
|
|
93
|
+
* const result = await loader.load("./my-schema.orb");
|
|
94
|
+
*
|
|
95
|
+
* // Using HttpLoader (Browser)
|
|
96
|
+
* const loader: SchemaLoader = new HttpLoader({ basePath: "/api/schemas" });
|
|
97
|
+
* const result = await loader.load("./my-schema.orb");
|
|
98
|
+
*
|
|
99
|
+
* // Using UnifiedLoader (auto-detect)
|
|
100
|
+
* const loader: SchemaLoader = createUnifiedLoader({ basePath: "/schemas" });
|
|
101
|
+
* const result = await loader.load("./my-schema.orb");
|
|
102
|
+
* ```
|
|
103
|
+
*/
|
|
104
|
+
interface SchemaLoader {
|
|
105
|
+
/**
|
|
106
|
+
* Load a schema from an import path.
|
|
107
|
+
*
|
|
108
|
+
* @param importPath - The import path (e.g., "./health.orb", "std/behaviors/game-core")
|
|
109
|
+
* @param fromPath - The path of the file doing the import (for relative resolution)
|
|
110
|
+
* @param chain - Import chain for circular detection (optional)
|
|
111
|
+
*/
|
|
112
|
+
load(importPath: string, fromPath?: string, chain?: ImportChainLike): Promise<LoadResult<LoadedSchema>>;
|
|
113
|
+
/**
|
|
114
|
+
* Load a specific orbital from a schema by name.
|
|
115
|
+
*
|
|
116
|
+
* @param importPath - The import path
|
|
117
|
+
* @param orbitalName - The orbital name (optional, defaults to first orbital)
|
|
118
|
+
* @param fromPath - The path of the file doing the import
|
|
119
|
+
* @param chain - Import chain for circular detection (optional)
|
|
120
|
+
*/
|
|
121
|
+
loadOrbital(importPath: string, orbitalName?: string, fromPath?: string, chain?: ImportChainLike): Promise<LoadResult<LoadedOrbital>>;
|
|
122
|
+
/**
|
|
123
|
+
* Resolve an import path to an absolute path/URL.
|
|
124
|
+
*
|
|
125
|
+
* @param importPath - The import path
|
|
126
|
+
* @param fromPath - The path of the file doing the import (optional)
|
|
127
|
+
*/
|
|
128
|
+
resolvePath(importPath: string, fromPath?: string): LoadResult<string>;
|
|
129
|
+
/**
|
|
130
|
+
* Clear the loader's cache.
|
|
131
|
+
*/
|
|
132
|
+
clearCache(): void;
|
|
133
|
+
/**
|
|
134
|
+
* Get cache statistics.
|
|
135
|
+
*/
|
|
136
|
+
getCacheStats(): {
|
|
137
|
+
size: number;
|
|
138
|
+
};
|
|
139
|
+
}
|
|
140
|
+
/**
|
|
141
|
+
* Interface for import chain (circular detection).
|
|
142
|
+
* This allows different implementations to interoperate.
|
|
143
|
+
*/
|
|
144
|
+
interface ImportChainLike {
|
|
145
|
+
/**
|
|
146
|
+
* Try to add a path to the chain.
|
|
147
|
+
* @returns Error message if circular, null if OK
|
|
148
|
+
*/
|
|
149
|
+
push(absolutePath: string): string | null;
|
|
150
|
+
/**
|
|
151
|
+
* Remove the last path from the chain.
|
|
152
|
+
*/
|
|
153
|
+
pop(): void;
|
|
154
|
+
/**
|
|
155
|
+
* Clone the chain for nested loading.
|
|
156
|
+
*/
|
|
157
|
+
clone(): ImportChainLike;
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
export type { BaseLoaderOptions, HttpLoaderOptions, ImportChainLike, LoadResult, LoadedOrbital, LoadedSchema, SchemaLoader };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import '../chunk-ELBLT2HZ.js';
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { PersistenceAdapter, KernelMemoryStoreWire, EntityRow, RowQuery, RowQueryPage, RowIdPage, QueryCapabilities, RowWriteOp, RowWriteOutcome, RowWriteBatch, WriteCapabilities } from '@almadar/core';
|
|
2
|
+
|
|
3
|
+
declare class NativeMemoryWriteError extends Error {
|
|
4
|
+
readonly outcome: RowWriteOutcome;
|
|
5
|
+
constructor(outcome: RowWriteOutcome);
|
|
6
|
+
}
|
|
7
|
+
declare class NativeMemoryPersistenceAdapter implements PersistenceAdapter {
|
|
8
|
+
readonly store: KernelMemoryStoreWire;
|
|
9
|
+
constructor(store: KernelMemoryStoreWire);
|
|
10
|
+
getById(entityType: string, id: string): Promise<EntityRow | null>;
|
|
11
|
+
list(entityType: string): Promise<EntityRow[]>;
|
|
12
|
+
create(entityType: string, data: EntityRow): Promise<{
|
|
13
|
+
id: string;
|
|
14
|
+
}>;
|
|
15
|
+
update(entityType: string, id: string, data: EntityRow): Promise<void>;
|
|
16
|
+
delete(entityType: string, id: string): Promise<void>;
|
|
17
|
+
queryPage(entityType: string, query: RowQuery): Promise<RowQueryPage>;
|
|
18
|
+
queryIds(entityType: string, query: RowQuery): Promise<RowIdPage>;
|
|
19
|
+
queryCapabilities(_entityType: string): QueryCapabilities;
|
|
20
|
+
writeWhere(op: RowWriteOp): Promise<RowWriteOutcome>;
|
|
21
|
+
writeBatch(batch: RowWriteBatch): Promise<RowWriteOutcome[]>;
|
|
22
|
+
writeCapabilities(_entityType: string): WriteCapabilities;
|
|
23
|
+
bindCollection(entityType: string, collection: string): void;
|
|
24
|
+
clear(): void;
|
|
25
|
+
snapshot(): Record<string, EntityRow[]>;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export { NativeMemoryPersistenceAdapter, NativeMemoryWriteError };
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { OrbitalDefinition, OrbitalSchema } from '@almadar/core';
|
|
2
|
+
import { EventWiringEntry } from './event-wiring.js';
|
|
3
|
+
import { LayoutStrategy } from './layout-strategy.js';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Compose Behaviors
|
|
7
|
+
*
|
|
8
|
+
* Main entry point for composing multiple orbital definitions into
|
|
9
|
+
* a single OrbitalSchema application. Handles event wiring, layout
|
|
10
|
+
* strategy detection, and page generation.
|
|
11
|
+
*
|
|
12
|
+
* @packageDocumentation
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Input for composing behaviors into an application.
|
|
17
|
+
*/
|
|
18
|
+
interface ComposeBehaviorsInput {
|
|
19
|
+
/** Application name */
|
|
20
|
+
appName: string;
|
|
21
|
+
/** Orbital definitions (or schemas) to compose */
|
|
22
|
+
orbitals: (OrbitalDefinition | OrbitalSchema)[];
|
|
23
|
+
/** Layout strategy override, or 'auto' to detect */
|
|
24
|
+
layoutStrategy?: LayoutStrategy | 'auto';
|
|
25
|
+
/** Cross-orbital event wiring */
|
|
26
|
+
eventWiring?: EventWiringEntry[];
|
|
27
|
+
/** Optional entity name mappings (original -> renamed) */
|
|
28
|
+
entityMappings?: Record<string, string>;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Result of composing behaviors.
|
|
32
|
+
*/
|
|
33
|
+
interface ComposeBehaviorsResult {
|
|
34
|
+
/** The composed OrbitalSchema */
|
|
35
|
+
schema: OrbitalSchema;
|
|
36
|
+
/** Layout metadata */
|
|
37
|
+
layout: {
|
|
38
|
+
strategy: LayoutStrategy;
|
|
39
|
+
pageCount: number;
|
|
40
|
+
};
|
|
41
|
+
/** Wiring metadata */
|
|
42
|
+
wiring: {
|
|
43
|
+
connections: number;
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Compose multiple orbital definitions into a single application schema.
|
|
48
|
+
*
|
|
49
|
+
* Steps:
|
|
50
|
+
* 1. Apply event wiring (adds emits/listens to traits)
|
|
51
|
+
* 2. Detect or use provided layout strategy
|
|
52
|
+
* 3. Generate pages based on the strategy
|
|
53
|
+
* 4. Build the final OrbitalSchema
|
|
54
|
+
*/
|
|
55
|
+
declare function composeBehaviors(input: ComposeBehaviorsInput): ComposeBehaviorsResult;
|
|
56
|
+
|
|
57
|
+
export { composeBehaviors };
|
|
58
|
+
export type { ComposeBehaviorsInput, ComposeBehaviorsResult };
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { OrbitalDefinition } from '@almadar/core';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Event Wiring
|
|
5
|
+
*
|
|
6
|
+
* Applies cross-orbital event wiring to orbital definitions.
|
|
7
|
+
* Adds emits/listens declarations to traits so they can communicate
|
|
8
|
+
* across orbital boundaries.
|
|
9
|
+
*
|
|
10
|
+
* @packageDocumentation
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* A single event wiring entry connecting two traits across orbitals.
|
|
15
|
+
*/
|
|
16
|
+
interface EventWiringEntry {
|
|
17
|
+
/** Source trait name or orbital name */
|
|
18
|
+
from: string;
|
|
19
|
+
/** Event name (UPPER_SNAKE_CASE) */
|
|
20
|
+
event: string;
|
|
21
|
+
/** Target trait name or orbital name */
|
|
22
|
+
to: string;
|
|
23
|
+
/** Event to trigger on the listener side */
|
|
24
|
+
triggers: string;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Apply event wiring to orbital definitions.
|
|
28
|
+
*
|
|
29
|
+
* For each wiring entry:
|
|
30
|
+
* 1. Find the source trait and add an external emit (if not already present)
|
|
31
|
+
* 2. Find the target trait and add an external listen (if not already present)
|
|
32
|
+
*
|
|
33
|
+
* Returns a new array of orbitals with wiring applied (deep-cloned).
|
|
34
|
+
*/
|
|
35
|
+
declare function applyEventWiring(orbitals: OrbitalDefinition[], wiring: EventWiringEntry[]): OrbitalDefinition[];
|
|
36
|
+
|
|
37
|
+
export { applyEventWiring };
|
|
38
|
+
export type { EventWiringEntry };
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { ComposeBehaviorsInput, ComposeBehaviorsResult, composeBehaviors } from './compose-behaviors.js';
|
|
2
|
+
export { EventWiringEntry, applyEventWiring } from './event-wiring.js';
|
|
3
|
+
export { LayoutStrategy, detectLayoutStrategy } from './layout-strategy.js';
|
|
4
|
+
export { PipeStep, pipeBehaviors } from './pipe.js';
|
|
5
|
+
import '@almadar/core';
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import '../../../chunk-5D63EMO5.js';
|
|
2
|
+
export { pipeBehaviors } from '../../../chunk-FQ6IZMIU.js';
|
|
3
|
+
export { composeBehaviors } from '../../../chunk-ZCQUUJIF.js';
|
|
4
|
+
export { detectLayoutStrategy } from '../../../chunk-EV56K4GB.js';
|
|
5
|
+
export { applyEventWiring } from '../../../chunk-MHYSHSRG.js';
|
|
6
|
+
import '../../../chunk-MLKGABMK.js';
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { OrbitalDefinition } from '@almadar/core';
|
|
2
|
+
import { EventWiringEntry } from './event-wiring.js';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Layout Strategy Detection
|
|
6
|
+
*
|
|
7
|
+
* Auto-detects the best layout strategy for a composed application
|
|
8
|
+
* based on the number of orbitals and their event wiring topology.
|
|
9
|
+
*
|
|
10
|
+
* @packageDocumentation
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Layout strategy for the composed application.
|
|
15
|
+
*
|
|
16
|
+
* - 'single': One orbital, one page
|
|
17
|
+
* - 'tabs': 2-4 orbitals with no sequential chain
|
|
18
|
+
* - 'sidebar': 5+ orbitals (navigation-heavy)
|
|
19
|
+
* - 'dashboard': Single page with all orbitals visible
|
|
20
|
+
* - 'wizard-flow': Sequential event chain detected (A -> B -> C)
|
|
21
|
+
*/
|
|
22
|
+
type LayoutStrategy = 'sidebar' | 'tabs' | 'dashboard' | 'wizard-flow' | 'single';
|
|
23
|
+
/**
|
|
24
|
+
* Detect the best layout strategy based on orbital count and event wiring.
|
|
25
|
+
*
|
|
26
|
+
* Heuristic:
|
|
27
|
+
* 1. Sequential event chain detected -> 'wizard-flow'
|
|
28
|
+
* 2. 1 orbital -> 'single'
|
|
29
|
+
* 3. 2-4 orbitals -> 'tabs'
|
|
30
|
+
* 4. 5+ orbitals -> 'sidebar'
|
|
31
|
+
*/
|
|
32
|
+
declare function detectLayoutStrategy(orbitals: OrbitalDefinition[], eventWiring?: EventWiringEntry[]): LayoutStrategy;
|
|
33
|
+
|
|
34
|
+
export { detectLayoutStrategy };
|
|
35
|
+
export type { LayoutStrategy };
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pipe Behaviors
|
|
3
|
+
*
|
|
4
|
+
* Left-to-right composition. Each step receives the previous result as its
|
|
5
|
+
* first argument and returns the value handed to the next step.
|
|
6
|
+
*
|
|
7
|
+
* @packageDocumentation
|
|
8
|
+
*/
|
|
9
|
+
/**
|
|
10
|
+
* A single step in a behavior pipeline.
|
|
11
|
+
*/
|
|
12
|
+
type PipeStep<I, O> = (input: I) => O;
|
|
13
|
+
/**
|
|
14
|
+
* Apply a series of transformation steps to a seed value, left to right.
|
|
15
|
+
* Each step receives the previous step's output as its first argument.
|
|
16
|
+
*
|
|
17
|
+
* @example
|
|
18
|
+
* ```ts
|
|
19
|
+
* pipeBehaviors(1, (n) => n + 1, (n) => n * 10); // -> 20
|
|
20
|
+
* ```
|
|
21
|
+
*/
|
|
22
|
+
declare function pipeBehaviors<T>(seed: T, ...steps: Array<PipeStep<T, T>>): T;
|
|
23
|
+
|
|
24
|
+
export { pipeBehaviors };
|
|
25
|
+
export type { PipeStep };
|