@microverse.ts/host-surface 0.1.0 → 0.3.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.
Files changed (53) hide show
  1. package/README.md +53 -22
  2. package/dist/application/ports/ScriptReferenceResolverPort.d.ts +13 -0
  3. package/dist/application/ports/ScriptReferenceResolverPort.d.ts.map +1 -0
  4. package/dist/application/useCases/compileBridgeDeclarationsFromHostSurfaceSpec.d.ts +4 -4
  5. package/dist/application/useCases/compileBridgeDeclarationsFromHostSurfaceSpec.d.ts.map +1 -1
  6. package/dist/application/useCases/compileHostSurface.d.ts +7 -6
  7. package/dist/application/useCases/compileHostSurface.d.ts.map +1 -1
  8. package/dist/domain/componentSlotPrelude.d.ts +11 -0
  9. package/dist/domain/componentSlotPrelude.d.ts.map +1 -0
  10. package/dist/domain/componentTypeSpec.d.ts +12 -0
  11. package/dist/domain/componentTypeSpec.d.ts.map +1 -0
  12. package/dist/domain/hostSurfaceManifest.d.ts +3 -2
  13. package/dist/domain/hostSurfaceManifest.d.ts.map +1 -1
  14. package/dist/domain/hostSurfaceSpecTypes.d.ts +89 -0
  15. package/dist/domain/hostSurfaceSpecTypes.d.ts.map +1 -0
  16. package/dist/domain/hostSurfaceTypes.d.ts +16 -92
  17. package/dist/domain/hostSurfaceTypes.d.ts.map +1 -1
  18. package/dist/domain/luaGlobalHook.d.ts +1 -1
  19. package/dist/domain/safeObjectKey.d.ts +1 -1
  20. package/dist/domain/safeObjectKey.d.ts.map +1 -1
  21. package/dist/domain/scriptCatalogManifest.d.ts +14 -0
  22. package/dist/domain/scriptCatalogManifest.d.ts.map +1 -0
  23. package/dist/domain/scriptContextSymbol.d.ts +6 -0
  24. package/dist/domain/scriptContextSymbol.d.ts.map +1 -0
  25. package/dist/domain/scriptProfileSpec.d.ts +31 -0
  26. package/dist/domain/scriptProfileSpec.d.ts.map +1 -0
  27. package/dist/domain/scriptPropertyMergeEnv.d.ts +6 -0
  28. package/dist/domain/scriptPropertyMergeEnv.d.ts.map +1 -0
  29. package/dist/domain/surfaceCapabilities.d.ts +1 -1
  30. package/dist/domain/surfaceCapabilities.d.ts.map +1 -1
  31. package/dist/domain/surfaceMethodDef.d.ts +1 -1
  32. package/dist/domain/surfaceMethodDef.d.ts.map +1 -1
  33. package/dist/index.d.ts +30 -14
  34. package/dist/index.d.ts.map +1 -1
  35. package/dist/index.js +846 -258
  36. package/dist/index.js.map +1 -1
  37. package/dist/infrastructure/adapters/augmentHostWithCapabilityRegistry.d.ts +1 -1
  38. package/dist/infrastructure/adapters/augmentHostWithCapabilityRegistry.d.ts.map +1 -1
  39. package/dist/infrastructure/adapters/augmentHostWithScriptContext.d.ts +4 -0
  40. package/dist/infrastructure/adapters/augmentHostWithScriptContext.d.ts.map +1 -0
  41. package/dist/infrastructure/adapters/zodSchemaValidationAdapter.d.ts +1 -1
  42. package/dist/infrastructure/adapters/zodSchemaValidationAdapter.d.ts.map +1 -1
  43. package/dist/infrastructure/builders/bridgeMergeEnv.d.ts +6 -8
  44. package/dist/infrastructure/builders/bridgeMergeEnv.d.ts.map +1 -1
  45. package/dist/infrastructure/builders/defineHostSurfaceFacade.d.ts +5 -5
  46. package/dist/infrastructure/builders/defineHostSurfaceFacade.d.ts.map +1 -1
  47. package/dist/infrastructure/builders/filterBridgeDeclarations.d.ts +11 -0
  48. package/dist/infrastructure/builders/filterBridgeDeclarations.d.ts.map +1 -0
  49. package/dist/infrastructure/builders/surfaceBuilder.d.ts +16 -11
  50. package/dist/infrastructure/builders/surfaceBuilder.d.ts.map +1 -1
  51. package/dist/infrastructure/components/hostScriptSession.d.ts +42 -72
  52. package/dist/infrastructure/components/hostScriptSession.d.ts.map +1 -1
  53. package/package.json +10 -9
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # `@microverse.ts/host-surface`
2
2
 
3
- Declare a **host surface** in TypeScript: Zod schemas, capabilities, and handlers that compile into:
3
+ Declare a **host surface** in TypeScript: Zod schemas, capabilities, component types, and handlers that compile into:
4
4
 
5
5
  1. **Runtime bridge tables** for `mergeEnv` (what Lua calls at execution time).
6
6
  2. A **`LuaDefManifest`** for `@microverse.ts/lua-defs` (`.d.lua` stubs for LuaLS).
@@ -16,6 +16,19 @@ import { defineHostSurfaceFor } from '@microverse.ts/microverse-lua';
16
16
  import { z } from 'zod';
17
17
 
18
18
  export default defineHostSurfaceFor<MyHost>()
19
+ .componentType('OrderEcho', {
20
+ extends: 'AuditOnly',
21
+ capabilities: ['orders:read', 'notifications:send'],
22
+ props: z.object({ label: z.string().optional() }),
23
+ state: z.object({}),
24
+ hooks: ['OrderPlaced'],
25
+ })
26
+ .componentType('AuditOnly', {
27
+ capabilities: ['audit:record'],
28
+ props: z.object({}),
29
+ state: z.object({}),
30
+ hooks: ['OrderPlaced'],
31
+ })
19
32
  .bridge('orders')
20
33
  .method('get', {
21
34
  requires: 'orders:read',
@@ -24,37 +37,48 @@ export default defineHostSurfaceFor<MyHost>()
24
37
  description: 'Load order by id',
25
38
  handler: ({ host }, { orderId }) => host.orders.get(orderId),
26
39
  })
27
- .workflowHooks(workflowHooks) // optional
40
+ .componentHooks(componentHooks) // optional
28
41
  .build();
29
42
  ```
30
43
 
31
44
  | Step | Role |
32
45
  |------|------|
33
46
  | `defineHostSurfaceFor<THost>()` | Start builder; `handler` receives typed `host`. |
34
- | `.bridge('orders')` | Lua global table name. |
47
+ | `.componentType(name, …)` | Declares props, state, capability set, and hook subset for Lua `Name:extend()`. |
48
+ | `.bridge('orders')` | Bridge table on `self.bridges` after `OrderEcho:extend()` (only bridges allowed by the active type). |
35
49
  | `.method('get', { … })` | One bridge method: `requires`, `input`, `output`, `handler`. |
36
- | `.workflowHooks(…)` | Optional Zod map → `on*` hooks in Lua. |
37
- | `.build()` | Compiled {@link HostSurface}. |
50
+ | `.componentHooks(…)` | Optional Zod map → `on*` domain events; each type lists which hooks it implements. |
51
+ | `.build()` | Compiled {@link HostSurface} with `componentTypes` registry. |
38
52
 
39
- `requires` is a `domain:action` capability string. `async` is inferred from `async function` handlers.
53
+ `requires` is a `domain:action` capability string on each bridge method. Each **component type** lists which capabilities its instances may use; runtime mounts only those bridges/methods on `self.bridges`. Disallowed bridges are **absent** (`nil` in Lua), not denied at call time.
40
54
 
41
- Bridge names become **Lua global tables** (`orders`, `billing`, …). Do not use `workflow` as a bridge name when workflow hooks are enabled—that name is reserved for the injected `workflow:extend()` helper.
55
+ Bridges are **not** global in the slot: use `self.bridges.orders:get(…)` from component methods after `YourType:extend()`.
42
56
 
43
57
  ### Host object
44
58
 
45
59
  The **host** is your engine context (services, repos, config). It is not generated here—you construct it in your app and pass it to `MicroverseLua.create({ host, surface })` or `HostScriptSession`.
46
60
 
47
- ### Workflow hooks
61
+ ### Component domain events
62
+
63
+ Call `.componentHooks({ OrderPlaced: z.object({ … }), … })` before `.build()`.
64
+
65
+ - TypeScript emits via `emitToAllInstances('OrderPlaced', payload)`.
66
+ - Lua implements `onOrderPlaced` on the table from `OrderEcho:extend()` (when that type’s `hooks` includes `OrderPlaced`).
67
+ - Manifest emits `MicroverseEvt_*` payload classes and per-type `on*` fields on `OrderEchoComponent` in `.d.lua`.
48
68
 
49
- Call `.workflowHooks({ OrderPlaced: z.object({ … }), … })` before `.build()`.
69
+ ### Component types and inheritance
50
70
 
51
- - TypeScript emits via `emitToAllScripts('OrderPlaced', payload)`.
52
- - Lua implements `onOrderPlaced` on the table from `workflow:extend()`.
53
- - Manifest includes `MicroverseWorkflowEvt_*` classes in `.d.lua`.
71
+ | Field | Rule |
72
+ |-------|------|
73
+ | `capabilities` | Union of parent + child (deduplicated). |
74
+ | `props` / `state` | Zod `parent.extend(childShape)`. |
75
+ | `hooks` | Union of parent + child hook names. |
76
+
77
+ `extends` must reference another type on the same surface. Names must be unique; cycles are rejected at `build()`.
54
78
 
55
79
  ## `HostScriptSession`
56
80
 
57
- Lower-level API when you manage slots yourself (one session = one env slot + capability allowlist):
81
+ Lower-level API when you manage slots yourself (one session = one env slot):
58
82
 
59
83
  ```ts
60
84
  const session = new HostScriptSession({
@@ -62,13 +86,13 @@ const session = new HostScriptSession({
62
86
  surface,
63
87
  host,
64
88
  slotKey: createLuaEnvSlotKey('script:my-id'),
65
- allowedCapabilities: surface.pickCapabilities('orders:read'),
66
89
  });
67
90
  await session.openSession();
68
- await session.runChunk(luaSource);
91
+ await session.runChunk(luaSource); // script must call YourType:extend() first
92
+ await session.setProps({ … }); // validated against active type’s props schema
69
93
  ```
70
94
 
71
- `MicroverseLua` in `@microverse.ts/microverse-lua` wraps this for the common case (shared VM, `registerScript`, broadcast hooks).
95
+ `MicroverseLua` in `@microverse.ts/microverse-lua` wraps this for the common case (shared VM, script catalog + instances, broadcast hooks).
72
96
 
73
97
  ## Generating `.d.lua`
74
98
 
@@ -76,18 +100,25 @@ await session.runChunk(luaSource);
76
100
  microverse generate-lua-defs --surface src/mySurface.ts
77
101
  ```
78
102
 
79
- Requires `export default` of the compiled surface (`.build()` result). See [`@microverse.ts/cli`](../cli/README.md) and [`@microverse.ts/lua-defs`](../lua-defs/README.md).
103
+ Requires `export default` of the compiled surface (`.build()` result). The manifest emits, per component type:
104
+
105
+ - `AuditOnlyProps`, `AuditOnlyState`, `AuditOnlyBridges`
106
+ - `AuditOnlyComponent` (with `on*` only for that type’s hooks)
107
+ - `AuditOnly:extend() → AuditOnlyComponent` singleton stub
108
+
109
+ See [`@microverse.ts/cli`](../cli/README.md) and [`@microverse.ts/lua-defs`](../lua-defs/README.md).
80
110
 
81
- Optional **Lua type names** on Zod schemas (`luaType('OrderDto', z.object({ … }))`) improve stub names—see `examples/business-scripting-engine/src/schemas/surface/bridgePayloads.ts`.
111
+ Optional **Lua type names** on Zod schemas (`luaType('OrderDto', z.object({ … }))`) improve stub names—see bridge payload patterns in consumer surfaces (e.g. `examples/sorting-lab`).
82
112
 
83
113
  ## Async bridges and Lua patterns
84
114
 
85
- Bridge handlers are **synchronous at the Lua boundary**; Wasmoon does not auto-resolve `Promise` into Lua values. For async TypeScript work, use the async bridge pattern (`:await()` or `onComplete` callback) documented in:
115
+ Bridge handlers are **synchronous at the Lua boundary**; Wasmoon does not auto-resolve `Promise` into Lua values. For async TypeScript work, use an `async` handler on the surface; Lua calls the bridge with `:await()` or an `onComplete` callback. See:
86
116
 
87
- - [docs/async-subroutines-components.md](docs/async-subroutines-components.md)
88
- - [examples/business-scripting-engine/docs/COMPONENT_PATTERN.md](../../examples/business-scripting-engine/docs/COMPONENT_PATTERN.md)
117
+ - [Async bridges — `@microverse.ts/microverse-lua`](../microverse-lua/README.md#async-bridges)
118
+ - [Lua authoring (components)](../microverse-lua/README.md#lua-authoring)
119
+ - Example: [`bubble_sort.lua`](../../examples/sorting-lab/lua/bubble_sort.lua)
89
120
 
90
121
  ## Reference
91
122
 
92
- - Example surface: [`examples/business-scripting-engine/src/businessSurface.ts`](../../examples/business-scripting-engine/src/businessSurface.ts)
123
+ - Example surface: [`examples/sorting-lab/src/engine/sortingSurface.ts`](../../examples/sorting-lab/src/engine/sortingSurface.ts)
93
124
  - Tests: `src/domain/`, `src/application/`, `src/infrastructure/`
@@ -0,0 +1,13 @@
1
+ import { ScriptReferenceKind } from '@microverse.ts/runtime-core';
2
+ export type ScriptReferenceWrapContext = {
3
+ readonly slotKey: string;
4
+ readonly field: string;
5
+ readonly raw: string | null;
6
+ readonly kind: ScriptReferenceKind;
7
+ readonly componentType?: string | undefined;
8
+ };
9
+ /** Host-provided wrapper for `self.references.*` (opaque Lua userdata/table). */
10
+ export type ScriptReferenceResolverPort = {
11
+ readonly wrap: (ctx: ScriptReferenceWrapContext) => unknown;
12
+ };
13
+ //# sourceMappingURL=ScriptReferenceResolverPort.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ScriptReferenceResolverPort.d.ts","sourceRoot":"","sources":["../../../src/application/ports/ScriptReferenceResolverPort.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,6BAA6B,CAAC;AAEvE,MAAM,MAAM,0BAA0B,GAAG;IACvC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,CAAC;IAC5B,QAAQ,CAAC,IAAI,EAAE,mBAAmB,CAAC;IACnC,QAAQ,CAAC,aAAa,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;CAC7C,CAAC;AAEF,iFAAiF;AACjF,MAAM,MAAM,2BAA2B,GAAG;IACxC,QAAQ,CAAC,IAAI,EAAE,CAAC,GAAG,EAAE,0BAA0B,KAAK,OAAO,CAAC;CAC7D,CAAC"}
@@ -1,9 +1,9 @@
1
1
  import { DeclarativeBridgeDeclaration } from '@microverse.ts/runtime-bridge';
2
- import { WithMicroverseCapabilityRegistry } from '../../domain/capabilityRegistrySymbol.js';
3
- import { HostSurfaceSpec } from '../../domain/hostSurfaceTypes.js';
4
- import { SchemaValidationPort } from '../ports/SchemaValidationPort.js';
2
+ import { WithMicroverseScriptContext } from '../../domain/scriptContextSymbol';
3
+ import { HostSurfaceSpec } from '../../domain/hostSurfaceSpecTypes';
4
+ import { SchemaValidationPort } from '../ports/SchemaValidationPort';
5
5
  /**
6
6
  * Builds declarative bridge declarations from a host surface spec, using the schema validation port for Lua ↔ host payloads.
7
7
  */
8
- export declare function createBridgeDeclarationsFromHostSurfaceSpec<TSpec extends HostSurfaceSpec>(schemaValidation: SchemaValidationPort, spec: TSpec): ReadonlyArray<DeclarativeBridgeDeclaration<WithMicroverseCapabilityRegistry, string>>;
8
+ export declare function createBridgeDeclarationsFromHostSurfaceSpec<TSpec extends HostSurfaceSpec>(schemaValidation: SchemaValidationPort, spec: TSpec): ReadonlyArray<DeclarativeBridgeDeclaration<WithMicroverseScriptContext, string>>;
9
9
  //# sourceMappingURL=compileBridgeDeclarationsFromHostSurfaceSpec.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"compileBridgeDeclarationsFromHostSurfaceSpec.d.ts","sourceRoot":"","sources":["../../../src/application/useCases/compileBridgeDeclarationsFromHostSurfaceSpec.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,4BAA4B,EAAE,MAAM,+BAA+B,CAAC;AAGlF,OAAO,EAAkC,KAAK,gCAAgC,EAAE,MAAM,0CAA0C,CAAC;AAGjI,OAAO,KAAK,EAAwB,eAAe,EAAE,MAAM,kCAAkC,CAAC;AAC9F,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,kCAAkC,CAAC;AAa7E;;GAEG;AACH,wBAAgB,2CAA2C,CAAC,KAAK,SAAS,eAAe,EACvF,gBAAgB,EAAE,oBAAoB,EACtC,IAAI,EAAE,KAAK,GACV,aAAa,CAAC,4BAA4B,CAAC,gCAAgC,EAAE,MAAM,CAAC,CAAC,CA+CvF"}
1
+ {"version":3,"file":"compileBridgeDeclarationsFromHostSurfaceSpec.d.ts","sourceRoot":"","sources":["../../../src/application/useCases/compileBridgeDeclarationsFromHostSurfaceSpec.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,4BAA4B,EAAE,MAAM,+BAA+B,CAAC;AAKlF,OAAO,EAA6B,KAAK,2BAA2B,EAAE,MAAM,kCAAkC,CAAC;AAE/G,OAAO,KAAK,EAAwB,eAAe,EAAE,MAAM,mCAAmC,CAAC;AAC/F,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,+BAA+B,CAAC;AAa1E;;GAEG;AACH,wBAAgB,2CAA2C,CAAC,KAAK,SAAS,eAAe,EACvF,gBAAgB,EAAE,oBAAoB,EACtC,IAAI,EAAE,KAAK,GACV,aAAa,CAAC,4BAA4B,CAAC,2BAA2B,EAAE,MAAM,CAAC,CAAC,CAoDlF"}
@@ -1,13 +1,14 @@
1
- import { InferSurfaceCapabilities } from '../../domain/surfaceCapabilities.js';
2
- import { HostSurface, HostSurfaceSpec, HostWorkflowHooksSpec } from '../../domain/hostSurfaceTypes.js';
3
- import { SchemaValidationPort } from '../ports/SchemaValidationPort.js';
1
+ import { ComponentTypeDefRegistry } from '../../domain/componentTypeSpec';
2
+ import { InferSurfaceCapabilities } from '../../domain/surfaceCapabilities';
3
+ import { HostSurface, HostSurfaceSpec, HostComponentHooksSpec } from '../../domain/hostSurfaceTypes';
4
+ import { SchemaValidationPort } from '../ports/SchemaValidationPort';
4
5
  /**
5
6
  * Compiles a host surface using the injected schema validation port (tuple matches `UseCase` conventions in `@microverse.ts/shared`).
6
7
  */
7
- export declare function compileHostSurface<const TSpec extends HostSurfaceSpec>(ports: readonly [SchemaValidationPort], spec: TSpec): HostSurface<undefined, InferSurfaceCapabilities<TSpec>>;
8
- export declare function compileHostSurface<const TSpec extends HostSurfaceSpec, const THooks extends HostWorkflowHooksSpec>(ports: readonly [SchemaValidationPort], spec: TSpec, workflowHooks: THooks): HostSurface<THooks, InferSurfaceCapabilities<TSpec>>;
8
+ export declare function compileHostSurface<const TSpec extends HostSurfaceSpec>(ports: readonly [SchemaValidationPort], spec: TSpec, componentTypeRegistry: ComponentTypeDefRegistry): HostSurface<undefined, InferSurfaceCapabilities<TSpec>>;
9
+ export declare function compileHostSurface<const TSpec extends HostSurfaceSpec, const THooks extends HostComponentHooksSpec>(ports: readonly [SchemaValidationPort], spec: TSpec, componentTypeRegistry: ComponentTypeDefRegistry, componentHooks: THooks): HostSurface<THooks, InferSurfaceCapabilities<TSpec>>;
9
10
  /**
10
11
  * Same as {@link compileHostSurface}, but requires every bridge method to be typed with the same `THost`.
11
12
  */
12
- export declare function compileHostSurfaceFor<const TSpec extends HostSurfaceSpec, const THooks extends HostWorkflowHooksSpec | undefined = undefined>(ports: readonly [SchemaValidationPort], spec: TSpec, workflowHooks?: THooks): THooks extends HostWorkflowHooksSpec ? HostSurface<THooks, InferSurfaceCapabilities<TSpec>> : HostSurface<undefined, InferSurfaceCapabilities<TSpec>>;
13
+ export declare function compileHostSurfaceFor<const TSpec extends HostSurfaceSpec, const THooks extends HostComponentHooksSpec | undefined = undefined>(ports: readonly [SchemaValidationPort], spec: TSpec, componentTypeRegistry: ComponentTypeDefRegistry, componentHooks?: THooks): THooks extends HostComponentHooksSpec ? HostSurface<THooks, InferSurfaceCapabilities<TSpec>> : HostSurface<undefined, InferSurfaceCapabilities<TSpec>>;
13
14
  //# sourceMappingURL=compileHostSurface.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"compileHostSurface.d.ts","sourceRoot":"","sources":["../../../src/application/useCases/compileHostSurface.ts"],"names":[],"mappings":"AACA,OAAO,EAGL,KAAK,wBAAwB,EAC9B,MAAM,qCAAqC,CAAC;AAC7C,OAAO,KAAK,EACV,WAAW,EAEX,eAAe,EACf,qBAAqB,EACtB,MAAM,kCAAkC,CAAC;AAC1C,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,kCAAkC,CAAC;AAoB7E;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,KAAK,CAAC,KAAK,SAAS,eAAe,EACpE,KAAK,EAAE,SAAS,CAAC,oBAAoB,CAAC,EACtC,IAAI,EAAE,KAAK,GACV,WAAW,CAAC,SAAS,EAAE,wBAAwB,CAAC,KAAK,CAAC,CAAC,CAAC;AAC3D,wBAAgB,kBAAkB,CAChC,KAAK,CAAC,KAAK,SAAS,eAAe,EACnC,KAAK,CAAC,MAAM,SAAS,qBAAqB,EAE1C,KAAK,EAAE,SAAS,CAAC,oBAAoB,CAAC,EACtC,IAAI,EAAE,KAAK,EACX,aAAa,EAAE,MAAM,GACpB,WAAW,CAAC,MAAM,EAAE,wBAAwB,CAAC,KAAK,CAAC,CAAC,CAAC;AAcxD;;GAEG;AACH,wBAAgB,qBAAqB,CACnC,KAAK,CAAC,KAAK,SAAS,eAAe,EACnC,KAAK,CAAC,MAAM,SAAS,qBAAqB,GAAG,SAAS,GAAG,SAAS,EAElE,KAAK,EAAE,SAAS,CAAC,oBAAoB,CAAC,EACtC,IAAI,EAAE,KAAK,EACX,aAAa,CAAC,EAAE,MAAM,GACrB,MAAM,SAAS,qBAAqB,GACnC,WAAW,CAAC,MAAM,EAAE,wBAAwB,CAAC,KAAK,CAAC,CAAC,GACpD,WAAW,CAAC,SAAS,EAAE,wBAAwB,CAAC,KAAK,CAAC,CAAC,CAQ1D"}
1
+ {"version":3,"file":"compileHostSurface.d.ts","sourceRoot":"","sources":["../../../src/application/useCases/compileHostSurface.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,gCAAgC,CAAC;AAK/E,OAAO,EAGL,KAAK,wBAAwB,EAC9B,MAAM,kCAAkC,CAAC;AAC1C,OAAO,KAAK,EACV,WAAW,EAEX,eAAe,EACf,sBAAsB,EACvB,MAAM,+BAA+B,CAAC;AACvC,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,+BAA+B,CAAC;AAoC1E;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,KAAK,CAAC,KAAK,SAAS,eAAe,EACpE,KAAK,EAAE,SAAS,CAAC,oBAAoB,CAAC,EACtC,IAAI,EAAE,KAAK,EACX,qBAAqB,EAAE,wBAAwB,GAC9C,WAAW,CAAC,SAAS,EAAE,wBAAwB,CAAC,KAAK,CAAC,CAAC,CAAC;AAC3D,wBAAgB,kBAAkB,CAChC,KAAK,CAAC,KAAK,SAAS,eAAe,EACnC,KAAK,CAAC,MAAM,SAAS,sBAAsB,EAE3C,KAAK,EAAE,SAAS,CAAC,oBAAoB,CAAC,EACtC,IAAI,EAAE,KAAK,EACX,qBAAqB,EAAE,wBAAwB,EAC/C,cAAc,EAAE,MAAM,GACrB,WAAW,CAAC,MAAM,EAAE,wBAAwB,CAAC,KAAK,CAAC,CAAC,CAAC;AAexD;;GAEG;AACH,wBAAgB,qBAAqB,CACnC,KAAK,CAAC,KAAK,SAAS,eAAe,EACnC,KAAK,CAAC,MAAM,SAAS,sBAAsB,GAAG,SAAS,GAAG,SAAS,EAEnE,KAAK,EAAE,SAAS,CAAC,oBAAoB,CAAC,EACtC,IAAI,EAAE,KAAK,EACX,qBAAqB,EAAE,wBAAwB,EAC/C,cAAc,CAAC,EAAE,MAAM,GACtB,MAAM,SAAS,sBAAsB,GACpC,WAAW,CAAC,MAAM,EAAE,wBAAwB,CAAC,KAAK,CAAC,CAAC,GACpD,WAAW,CAAC,SAAS,EAAE,wBAAwB,CAAC,KAAK,CAAC,CAAC,CAQ1D"}
@@ -0,0 +1,11 @@
1
+ import { ResolvedScriptProfileRegistry } from './scriptProfileSpec';
2
+ /** @see MICROVERSE_LUA_COMPONENT_SLOT_PRELUDE */
3
+ export declare const MICROVERSE_LUA_COMPONENT_SLOT_PRELUDE: string;
4
+ /** Lua prelude that registers `TypeName:extend()` singletons for each component type. */
5
+ export declare function profileBridgeSlotKey(typeName: string, bridgeName: string): string;
6
+ export declare function profileBridgeNamesMergeEnvKey(typeName: string): string;
7
+ export declare function buildComponentTypeBridgeNamesPreludeLua(componentTypes: ResolvedScriptProfileRegistry): string;
8
+ export declare function buildComponentTypeSingletonsPreludeLua(typeNames: readonly string[]): string;
9
+ /** Applies host-selected profile (same as `Type:extend()` without requiring Lua to call it). */
10
+ export declare function buildApplyHostScriptProfileChunkLua(profileName: string): string;
11
+ //# sourceMappingURL=componentSlotPrelude.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"componentSlotPrelude.d.ts","sourceRoot":"","sources":["../../src/domain/componentSlotPrelude.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,6BAA6B,EAAE,MAAM,qBAAqB,CAAC;AAEzE,iDAAiD;AACjD,eAAO,MAAM,qCAAqC,QAiF1C,CAAC;AAET,yFAAyF;AACzF,wBAAgB,oBAAoB,CAAC,QAAQ,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,MAAM,CAEjF;AAED,wBAAgB,6BAA6B,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAEtE;AAED,wBAAgB,uCAAuC,CACrD,cAAc,EAAE,6BAA6B,GAC5C,MAAM,CAaR;AAED,wBAAgB,sCAAsC,CAAC,SAAS,EAAE,SAAS,MAAM,EAAE,GAAG,MAAM,CAuC3F;AAED,gGAAgG;AAChG,wBAAgB,mCAAmC,CAAC,WAAW,EAAE,MAAM,GAAG,MAAM,CAU/E"}
@@ -0,0 +1,12 @@
1
+ import { ScriptProfileDefInput } from '@microverse.ts/runtime-core';
2
+ import { z } from 'zod';
3
+ import { HostComponentHooksSpec, HostSurfaceSpec } from './hostSurfaceSpecTypes';
4
+ import { ScriptProfileDefRegistry } from './scriptProfileSpec';
5
+ /** Fluent input for {@link SurfaceBuilder.componentType} (requires `state`; catalog profiles may omit it). */
6
+ export type ComponentTypeDefInput<TCap extends `${string}:${string}` = `${string}:${string}`, THooks extends HostComponentHooksSpec | undefined = undefined> = ScriptProfileDefInput<TCap> & {
7
+ readonly state: z.ZodObject<z.ZodRawShape>;
8
+ readonly hooks?: THooks extends HostComponentHooksSpec ? readonly (keyof THooks & string)[] : readonly string[] | undefined;
9
+ };
10
+ export type ComponentTypeDefRegistry = ScriptProfileDefRegistry;
11
+ export declare function validateComponentTypeRegistry(registry: ComponentTypeDefRegistry, spec: HostSurfaceSpec, componentHooks?: HostComponentHooksSpec): void;
12
+ //# sourceMappingURL=componentTypeSpec.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"componentTypeSpec.d.ts","sourceRoot":"","sources":["../../src/domain/componentTypeSpec.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,6BAA6B,CAAC;AACzE,OAAO,KAAK,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAE7B,OAAO,KAAK,EAAE,sBAAsB,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AACtF,OAAO,EAEL,KAAK,wBAAwB,EAC9B,MAAM,qBAAqB,CAAC;AAE7B,8GAA8G;AAC9G,MAAM,MAAM,qBAAqB,CAC/B,IAAI,SAAS,GAAG,MAAM,IAAI,MAAM,EAAE,GAAG,GAAG,MAAM,IAAI,MAAM,EAAE,EAC1D,MAAM,SAAS,sBAAsB,GAAG,SAAS,GAAG,SAAS,IAC3D,qBAAqB,CAAC,IAAI,CAAC,GAAG;IAChC,QAAQ,CAAC,KAAK,EAAE,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC;IAC3C,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,SAAS,sBAAsB,GAClD,SAAS,CAAC,MAAM,MAAM,GAAG,MAAM,CAAC,EAAE,GAClC,SAAS,MAAM,EAAE,GAAG,SAAS,CAAC;CACnC,CAAC;AAEF,MAAM,MAAM,wBAAwB,GAAG,wBAAwB,CAAC;AAEhE,wBAAgB,6BAA6B,CAC3C,QAAQ,EAAE,wBAAwB,EAClC,IAAI,EAAE,eAAe,EACrB,cAAc,CAAC,EAAE,sBAAsB,GACtC,IAAI,CAEN"}
@@ -1,8 +1,9 @@
1
1
  import { LuaDefManifest } from '@microverse.ts/lua-defs';
2
- import { HostSurfaceSpec, HostWorkflowHooksSpec } from './hostSurfaceTypes.js';
2
+ import { ResolvedScriptProfileRegistry } from './scriptProfileSpec';
3
+ import { HostComponentHooksSpec, HostSurfaceSpec } from './hostSurfaceSpecTypes';
3
4
  export declare function buildLuaDefManifestFromHostSurfaceSpec(spec: HostSurfaceSpec, opts: {
4
5
  readonly output: string;
5
6
  readonly headerNote?: string | undefined;
6
7
  readonly luaTypeAliases?: Readonly<Record<string, string>> | undefined;
7
- }, workflowHooks?: HostWorkflowHooksSpec): LuaDefManifest;
8
+ }, componentHooks?: HostComponentHooksSpec, componentTypes?: ResolvedScriptProfileRegistry): LuaDefManifest;
8
9
  //# sourceMappingURL=hostSurfaceManifest.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"hostSurfaceManifest.d.ts","sourceRoot":"","sources":["../../src/domain/hostSurfaceManifest.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,cAAc,EAMf,MAAM,yBAAyB,CAAC;AAGjC,OAAO,KAAK,EAAE,eAAe,EAAE,qBAAqB,EAAE,MAAM,uBAAuB,CAAC;AA0DpF,wBAAgB,sCAAsC,CACpD,IAAI,EAAE,eAAe,EACrB,IAAI,EAAE;IACJ,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IACzC,QAAQ,CAAC,cAAc,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,GAAG,SAAS,CAAC;CACxE,EACD,aAAa,CAAC,EAAE,qBAAqB,GACpC,cAAc,CAiGhB"}
1
+ {"version":3,"file":"hostSurfaceManifest.d.ts","sourceRoot":"","sources":["../../src/domain/hostSurfaceManifest.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,cAAc,EAMf,MAAM,yBAAyB,CAAC;AAGjC,OAAO,EAML,KAAK,6BAA6B,EACnC,MAAM,qBAAqB,CAAC;AAC7B,OAAO,KAAK,EAAE,sBAAsB,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAkMtF,wBAAgB,sCAAsC,CACpD,IAAI,EAAE,eAAe,EACrB,IAAI,EAAE;IACJ,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IACzC,QAAQ,CAAC,cAAc,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,GAAG,SAAS,CAAC;CACxE,EACD,cAAc,CAAC,EAAE,sBAAsB,EACvC,cAAc,CAAC,EAAE,6BAA6B,GAC7C,cAAc,CAuEhB"}
@@ -0,0 +1,89 @@
1
+ import { ScriptInstanceContext } from '@microverse.ts/runtime-core';
2
+ import { CapabilityId } from '@microverse.ts/runtime-capabilities';
3
+ import { z } from 'zod';
4
+ /**
5
+ * Context passed to every surface `handler`: your typed host plus the active Lua **slot key** (string form).
6
+ *
7
+ * @typeParam THost - Host services / world object you declare for bridge handlers.
8
+ */
9
+ export type HostFnContext<THost> = {
10
+ readonly host: THost;
11
+ /** Stable slot identifier for this sandbox (same convention as `DeclarativeBridgeDeclaration`). */
12
+ readonly slotKey: string;
13
+ /** Mounted script instance identity (audit, logging). */
14
+ readonly script: ScriptInstanceContext;
15
+ };
16
+ /**
17
+ * Strongly typed description of one bridge method (produced by the fluent `.method(…)` builder).
18
+ * TypeScript checks `handler` against `input` / `output` schemas.
19
+ *
20
+ * @typeParam THost - Host type available as `ctx.host` inside `handler`.
21
+ * @typeParam TIn - Payload type after Zod `input` parsing (Lua calls the bridge with one table argument).
22
+ * @typeParam TOut - Return type validated by Zod `output` before crossing back to Lua.
23
+ * @typeParam TCap - Capability id for this method (from fluent `requires: 'domain:action'`).
24
+ */
25
+ export type HostSurfaceMethodEntry<THost, TIn, TOut, TCap extends CapabilityId = CapabilityId> = {
26
+ /** Capability required to invoke this method; checked against the session registry before the handler runs. */
27
+ readonly capability: TCap;
28
+ /** Zod schema for the single payload object from Lua (e.g. `z.object({ id: z.string() })`). */
29
+ readonly input: z.ZodType<TIn>;
30
+ /** Zod schema for the value returned to Lua. */
31
+ readonly output: z.ZodType<TOut>;
32
+ /**
33
+ * Host logic at the Lua↔JS boundary. May return `Promise<TOut>`; Lua must use `:await()` on the returned handle
34
+ * or pass an `onComplete` callback as the second argument (see `MICROVERSE_LUA_SLOT_VM_BOOTSTRAP` in `@microverse.ts/runtime-wasm`).
35
+ */
36
+ readonly handler: (ctx: HostFnContext<THost>, input: TIn) => TOut | Promise<TOut>;
37
+ /**
38
+ * When true, manifest and Lua runtime treat this method as async (`MethodHandle` + optional `onComplete`).
39
+ * Set automatically for `async function` handlers in the fluent builder.
40
+ */
41
+ readonly async?: boolean | undefined;
42
+ /** Optional description emitted into the LuaCATS manifest. */
43
+ readonly description?: string | undefined;
44
+ /**
45
+ * Advanced escape hatch for manifest emission. Prefer registering Zod schemas with {@link luaType}
46
+ * (see `bridgePayloads` in the business example) so `.d.lua` stays inferred from `input` / `output`.
47
+ * Does not replace async bridge typing (`async: true` emits handle + `onComplete` in `.d.lua`).
48
+ * `paramTypes` keys must match `input` object keys (or `value` for non-object inputs).
49
+ */
50
+ readonly lua?: {
51
+ readonly paramTypes?: Partial<Record<string, string>> | undefined;
52
+ readonly returns?: string | undefined;
53
+ };
54
+ };
55
+ /**
56
+ * Erased method entry stored inside a {@link HostSurfaceSpec}. Assignability widens at the spec boundary.
57
+ */
58
+ export type AnyHostSurfaceMethod = {
59
+ readonly capability: CapabilityId;
60
+ readonly input: z.ZodTypeAny;
61
+ readonly output: z.ZodTypeAny;
62
+ readonly handler: (ctx: HostFnContext<any>, input: any) => unknown;
63
+ readonly async?: boolean | undefined;
64
+ readonly description?: string | undefined;
65
+ readonly lua?: {
66
+ readonly paramTypes?: Partial<Record<string, string>> | undefined;
67
+ readonly returns?: string | undefined;
68
+ };
69
+ };
70
+ /**
71
+ * Tree shape accepted by {@link defineHostSurface}: top-level keys become Lua global bridge **tables**
72
+ * (e.g. `orders`, `billing`); inner keys become **methods** on that table.
73
+ */
74
+ export type HostSurfaceSpec = Readonly<Record<string, Readonly<Record<string, AnyHostSurfaceMethod | HostSurfaceMethodEntry<any, any, any, any>>>>>;
75
+ /**
76
+ * Surface spec where every method entry uses the same host type as your engine context
77
+ * (the `THost` you pass as `host` into {@link HostScriptSession}).
78
+ */
79
+ export type HostSurfaceSpecForHost<THost> = Readonly<{
80
+ readonly [bridge: string]: Readonly<{
81
+ readonly [method: string]: HostSurfaceMethodEntry<THost, any, any, any>;
82
+ }>;
83
+ }>;
84
+ /**
85
+ * Zod object schemas keyed by PascalCase event kind (`OrderPlaced` → Lua method `onOrderPlaced` on the component from `component:extend()`).
86
+ * Passed to {@link SurfaceBuilder.componentHooks} to emit domain event typings into `.d.lua`.
87
+ */
88
+ export type HostComponentHooksSpec = Readonly<Record<string, z.ZodObject<any>>>;
89
+ //# sourceMappingURL=hostSurfaceSpecTypes.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hostSurf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AAsB,CAAC,KAAK,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC;KACzE,CAAC,CAAC;CACJ,CAAC,CAAC;AAGH;;;GAGG;AAEH,MAAM,MAAM,sBAAsB,GAAG,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC"}
@@ -1,103 +1,27 @@
1
1
  import { LuaDefManifest } from '@microverse.ts/lua-defs';
2
2
  import { DeclarativeBridgeDeclaration } from '@microverse.ts/runtime-bridge';
3
3
  import { CapabilityId } from '@microverse.ts/runtime-capabilities';
4
- import { z } from 'zod';
5
- import { SurfaceCapabilityString } from './surfaceCapabilityString.js';
6
- import { WithMicroverseCapabilityRegistry } from './capabilityRegistrySymbol.js';
7
- /**
8
- * Context passed to every surface `handler`: your typed host plus the active Lua **slot key** (string form).
9
- *
10
- * @typeParam THost - Host services / world object you declare for bridge handlers.
11
- */
12
- export type HostFnContext<THost> = {
13
- readonly host: THost;
14
- /** Stable slot identifier for this sandbox (same convention as `DeclarativeBridgeDeclaration`). */
15
- readonly slotKey: string;
16
- };
17
- /**
18
- * Strongly typed description of one bridge method (produced by the fluent `.method(…)` builder).
19
- * TypeScript checks `handler` against `input` / `output` schemas.
20
- *
21
- * @typeParam THost - Host type available as `ctx.host` inside `handler`.
22
- * @typeParam TIn - Payload type after Zod `input` parsing (Lua calls the bridge with one table argument).
23
- * @typeParam TOut - Return type validated by Zod `output` before crossing back to Lua.
24
- * @typeParam TCap - Capability id for this method (from fluent `requires: 'domain:action'`).
25
- */
26
- export type HostSurfaceMethodEntry<THost, TIn, TOut, TCap extends CapabilityId = CapabilityId> = {
27
- /** Capability required to invoke this method; checked against the session registry before the handler runs. */
28
- readonly capability: TCap;
29
- /** Zod schema for the single payload object from Lua (e.g. `z.object({ id: z.string() })`). */
30
- readonly input: z.ZodType<TIn>;
31
- /** Zod schema for the value returned to Lua. */
32
- readonly output: z.ZodType<TOut>;
33
- /**
34
- * Host logic at the Lua↔JS boundary. May return `Promise<TOut>`; Lua must use `:await()` on the returned handle
35
- * or pass an `onComplete` callback as the second argument (see `MICROVERSE_LUA_SLOT_VM_BOOTSTRAP` in `@microverse.ts/runtime-wasm`).
36
- */
37
- readonly handler: (ctx: HostFnContext<THost>, input: TIn) => TOut | Promise<TOut>;
38
- /**
39
- * When true, manifest and Lua runtime treat this method as async (`MethodHandle` + optional `onComplete`).
40
- * Set automatically for `async function` handlers in the fluent builder.
41
- */
42
- readonly async?: boolean | undefined;
43
- /** Optional description emitted into the LuaCATS manifest. */
44
- readonly description?: string | undefined;
45
- /**
46
- * Advanced escape hatch for manifest emission. Prefer registering Zod schemas with {@link luaType}
47
- * (see `bridgePayloads` in the business example) so `.d.lua` stays inferred from `input` / `output`.
48
- * Does not replace async bridge typing (`async: true` emits handle + `onComplete` in `.d.lua`).
49
- * `paramTypes` keys must match `input` object keys (or `value` for non-object inputs).
50
- */
51
- readonly lua?: {
52
- readonly paramTypes?: Partial<Record<string, string>> | undefined;
53
- readonly returns?: string | undefined;
54
- };
55
- };
56
- /**
57
- * Erased method entry stored inside a {@link HostSurfaceSpec}. Assignability widens at the spec boundary.
58
- */
59
- export type AnyHostSurfaceMethod = {
60
- readonly capability: CapabilityId;
61
- readonly input: z.ZodTypeAny;
62
- readonly output: z.ZodTypeAny;
63
- readonly handler: (ctx: HostFnContext<any>, input: any) => unknown;
64
- readonly async?: boolean | undefined;
65
- readonly description?: string | undefined;
66
- readonly lua?: {
67
- readonly paramTypes?: Partial<Record<string, string>> | undefined;
68
- readonly returns?: string | undefined;
69
- };
70
- };
71
- /**
72
- * Tree shape accepted by {@link defineHostSurface}: top-level keys become Lua global bridge **tables**
73
- * (e.g. `orders`, `billing`); inner keys become **methods** on that table.
74
- */
75
- export type HostSurfaceSpec = Readonly<Record<string, Readonly<Record<string, AnyHostSurfaceMethod | HostSurfaceMethodEntry<any, any, any, any>>>>>;
76
- /**
77
- * Surface spec where every method entry uses the same host type as your engine context
78
- * (the `THost` you pass as `host` into {@link HostScriptSession}).
79
- */
80
- export type HostSurfaceSpecForHost<THost> = Readonly<{
81
- readonly [bridge: string]: Readonly<{
82
- readonly [method: string]: HostSurfaceMethodEntry<THost, any, any, any>;
83
- }>;
84
- }>;
85
- /**
86
- * Zod object schemas keyed by PascalCase event kind (`OrderPlaced` → Lua method `onOrderPlaced` on the handler from `workflow:extend()`).
87
- * Passed as the second argument to {@link defineHostSurface} to emit workflow hook typings into `.d.lua`.
88
- */
89
- export type HostWorkflowHooksSpec = Readonly<Record<string, z.ZodObject<any>>>;
4
+ import { ResolvedScriptProfile, ResolvedScriptProfileRegistry } from './scriptProfileSpec';
5
+ import { SurfaceCapabilityString } from './surfaceCapabilityString';
6
+ import { WithMicroverseScriptContext } from './scriptContextSymbol';
7
+ import { HostComponentHooksSpec, HostSurfaceSpec } from './hostSurfaceSpecTypes';
8
+ export type { AnyHostSurfaceMethod, HostComponentHooksSpec, HostFnContext, HostSurfaceMethodEntry, HostSurfaceSpec, HostSurfaceSpecForHost, } from './hostSurfaceSpecTypes';
90
9
  /**
91
10
  * Bridge + manifest API shared by every {@link HostSurface} (with or without workflow hooks).
92
11
  *
93
12
  * @typeParam TCapabilities - Union of capability ids declared on the surface spec (see {@link InferSurfaceCapabilities}).
94
13
  */
95
14
  export type HostSurfaceCore<TCapabilities extends CapabilityId = CapabilityId> = {
15
+ /** Internal bridge/method tree (for profile filtering and manifest). */
16
+ readonly getHostSurfaceSpec: () => HostSurfaceSpec;
96
17
  /**
97
18
  * Declarative bridge declarations compatible with {@link buildDeclarativeBridgeTable}.
98
- * The host must satisfy {@link WithMicroverseCapabilityRegistry} (see {@link HostScriptSession}).
99
19
  */
100
- readonly toBridgeDeclarations: () => ReadonlyArray<DeclarativeBridgeDeclaration<WithMicroverseCapabilityRegistry, string>>;
20
+ readonly toBridgeDeclarations: () => ReadonlyArray<DeclarativeBridgeDeclaration<WithMicroverseScriptContext, string>>;
21
+ /** Resolved script profiles declared via `.componentType()`. */
22
+ readonly componentTypes: ResolvedScriptProfileRegistry;
23
+ /** Lookup a script profile by name (throws if unknown). */
24
+ readonly getComponentType: (name: string) => ResolvedScriptProfile;
101
25
  /**
102
26
  * Builds a `LuaDefManifest` for `@microverse.ts/lua-defs` (`buildLuaCatsDocument`, `generateDefs`, CLI).
103
27
  *
@@ -123,12 +47,12 @@ export type HostSurfaceCore<TCapabilities extends CapabilityId = CapabilityId> =
123
47
  /**
124
48
  * Compiled host surface: bridge factories for `mergeEnv` plus manifest builder for `.d.lua` generation.
125
49
  *
126
- * @typeParam THooks - When you pass `workflowHooks` to {@link defineHostSurface}, the returned surface includes
127
- * `workflowHooks` so callers can type workflow events from the surface object alone.
50
+ * @typeParam THooks - When you pass `componentHooks` to {@link defineHostSurface}, the returned surface includes
51
+ * `componentHooks` so callers can type domain events from the surface object alone.
128
52
  * @typeParam TCapabilities - Capability ids declared on the surface (for script allowlists).
129
53
  */
130
- export type HostSurface<THooks extends HostWorkflowHooksSpec | undefined = undefined, TCapabilities extends CapabilityId = CapabilityId> = [undefined] extends [THooks] ? HostSurfaceCore<TCapabilities> : HostSurfaceCore<TCapabilities> & {
131
- readonly workflowHooks: THooks;
54
+ export type HostSurface<THooks extends HostComponentHooksSpec | undefined = undefined, TCapabilities extends CapabilityId = CapabilityId> = [undefined] extends [THooks] ? HostSurfaceCore<TCapabilities> : HostSurfaceCore<TCapabilities> & {
55
+ readonly componentHooks: THooks;
132
56
  };
133
57
  /** Options passed to {@link HostSurfaceCore.toLuaDefManifest}. */
134
58
  export type LuaDefManifestGeneratorOpts = Parameters<HostSurfaceCore['toLuaDefManifest']>[0];
@@ -1 +1 @@
1
- {"version":3,"file":"hostSurfaceTypes.d.ts","sourceRoot":"","sources":["../../src/domain/hostSurfaceTypes.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AAC9D,OAAO,KAAK,EAAE,4BAA4B,EAAE,MA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AK,qBAAqB,CAAC;IACnE;;;;;;OAMG;IACH,QAAQ,CAAC,gBAAgB,EAAE,CAAC,IAAI,EAAE;QAChC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;QACxB,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;QACzC;;WAEG;QACH,QAAQ,CAAC,cAAc,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,GAAG,SAAS,CAAC;KACxE,KAAK,cAAc,CAAC;IACrB,iFAAiF;IACjF,QAAQ,CAAC,YAAY,EAAE,SAAS,aAAa,EAAE,CAAC;IAChD;;OAEG;IACH,gBAAgB,CAAC,KAAK,CAAC,CAAC,SAAS,SAAS,uBAAuB,CAAC,aAAa,CAAC,EAAE,EAChF,GAAG,YAAY,EAAE,CAAC,GACjB,aAAa,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,EAAE,aAAa,CAAC,CAAC,CAAC;CACrD,CAAC;AAEF;;;;;;GAMG;AACH,MAAM,MAAM,WAAW,CACrB,MAAM,SAAS,sBAAsB,GAAG,SAAS,GAAG,SAAS,EAC7D,aAAa,SAAS,YAAY,GAAG,YAAY,IAC/C,CAAC,SAAS,CAAC,SAAS,CAAC,MAAM,CAAC,GAC5B,eAAe,CAAC,aAAa,CAAC,GAC9B,eAAe,CAAC,aAAa,CAAC,GAAG;IAAE,QAAQ,CAAC,cAAc,EAAE,MAAM,CAAA;CAAE,CAAC;AAEzE,kEAAkE;AAClE,MAAM,MAAM,2BAA2B,GAAG,UAAU,CAAC,eAAe,CAAC,kBAAkB,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC"}
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * Lua convention for domain hooks: PascalCase event kind → method name `on{Kind}` on the workflow
3
- * handler table from `workflow:extend()` in each Lua slot (e.g. `OrderPlaced` → `onOrderPlaced`).
3
+ * component table from `component:extend()` in each Lua slot (e.g. `OrderPlaced` → `onOrderPlaced`).
4
4
  */
5
5
  export type LuaGlobalHookName<Kind extends string> = `on${Kind}`;
6
6
  /**
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * Rejects bridge/method names that could trigger prototype pollution when used as object keys.
3
3
  */
4
- export declare function assertSafeObjectKey(kind: 'bridge' | 'method', name: string): void;
4
+ export declare function assertSafeObjectKey(kind: 'bridge' | 'method' | 'componentType', name: string): void;
5
5
  /** Record with no inherited prototype — safe for dynamic string keys at runtime. */
6
6
  export declare function createNullPrototypeRecord<T extends object>(): T;
7
7
  //# sourceMappingURL=safeObjectKey.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"safeObjectKey.d.ts","sourceRoot":"","sources":["../../src/domain/safeObjectKey.ts"],"names":[],"mappings":"AAGA;;GAEG;AACH,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,QAAQ,GAAG,QAAQ,EAAE,IAAI,EAAE,MAAM,GAAG,IAAI,CAIjF;AAED,oFAAoF;AACpF,wBAAgB,yBAAyB,CAAC,CAAC,SAAS,MAAM,KAAK,CAAC,CAE/D"}
1
+ {"version":3,"file":"safeObjectKey.d.ts","sourceRoot":"","sources":["../../src/domain/safeObjectKey.ts"],"names":[],"mappings":"AAGA;;GAEG;AACH,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,QAAQ,GAAG,QAAQ,GAAG,eAAe,EAAE,IAAI,EAAE,MAAM,GAAG,IAAI,CAInG;AAED,oFAAoF;AACpF,wBAAgB,yBAAyB,CAAC,CAAC,SAAS,MAAM,KAAK,CAAC,CAE/D"}
@@ -0,0 +1,14 @@
1
+ import { LuaDefManifest } from '@microverse.ts/lua-defs';
2
+ export type ScriptCatalogEntry = {
3
+ readonly scriptId: string;
4
+ readonly profileId: string;
5
+ /**
6
+ * When true, the script's `.lua` file defines `---@class …ScriptComponent` (e.g. script-local methods).
7
+ * Omit the catalog `---@alias` so LuaLS does not report duplicate-doc-alias.
8
+ */
9
+ readonly localComponentClass?: boolean | undefined;
10
+ };
11
+ /** LuaCATS aliases per catalog scriptId → resolved component class (for `---@type` in `.lua` files). */
12
+ export declare function buildScriptCatalogLuaDefManifest(entries: readonly ScriptCatalogEntry[]): LuaDefManifest;
13
+ export declare function scriptCatalogComponentAlias(scriptId: string): string;
14
+ //# sourceMappingURL=scriptCatalogManifest.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"scriptCatalogManifest.d.ts","sourceRoot":"","sources":["../../src/domain/scriptCatalogManifest.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAiB,MAAM,yBAAyB,CAAC;AAI7E,MAAM,MAAM,kBAAkB,GAAG;IAC/B,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B;;;OAGG;IACH,QAAQ,CAAC,mBAAmB,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;CACpD,CAAC;AAEF,wGAAwG;AACxG,wBAAgB,gCAAgC,CAC9C,OAAO,EAAE,SAAS,kBAAkB,EAAE,GACrC,cAAc,CAsBhB;AAED,wBAAgB,2BAA2B,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAGpE"}
@@ -0,0 +1,6 @@
1
+ import { ScriptInstanceContext } from '@microverse.ts/runtime-core';
2
+ export declare const MICROVERSE_SCRIPT_CONTEXT: unique symbol;
3
+ export type WithMicroverseScriptContext = {
4
+ readonly [MICROVERSE_SCRIPT_CONTEXT]?: ScriptInstanceContext | undefined;
5
+ };
6
+ //# sourceMappingURL=scriptContextSymbol.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"scriptContextSymbol.d.ts","sourceRoot":"","sources":["../../src/domain/scriptContextSymbol.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,6BAA6B,CAAC;AAEzE,eAAO,MAAM,yBAAyB,eAAqC,CAAC;AAE5E,MAAM,MAAM,2BAA2B,GAAG;IACxC,QAAQ,CAAC,CAAC,yBAAyB,CAAC,CAAC,EAAE,qBAAqB,GAAG,SAAS,CAAC;CAC1E,CAAC"}
@@ -0,0 +1,31 @@
1
+ import { CapabilityId } from '@microverse.ts/runtime-capabilities';
2
+ import { ScriptProfileDefInput } from '@microverse.ts/runtime-core';
3
+ import { z } from 'zod';
4
+ import { HostComponentHooksSpec, HostSurfaceSpec } from './hostSurfaceSpecTypes';
5
+ export type ScriptProfileDefRegistry = Readonly<Record<string, ScriptProfileDefInput>>;
6
+ export type ResolvedScriptProfile = {
7
+ readonly name: string;
8
+ readonly extends?: string | undefined;
9
+ readonly capabilities: readonly CapabilityId[];
10
+ readonly props: z.ZodObject<z.ZodRawShape>;
11
+ readonly state: z.ZodObject<z.ZodRawShape>;
12
+ readonly hooks: readonly string[];
13
+ readonly bridgeNames: readonly string[];
14
+ readonly references?: ScriptProfileDefInput['references'];
15
+ };
16
+ export type ResolvedScriptProfileRegistry = Readonly<Record<string, ResolvedScriptProfile>>;
17
+ declare const EMPTY_PROPS: z.ZodObject<z.ZodRawShape>;
18
+ declare const EMPTY_STATE: z.ZodObject<z.ZodRawShape>;
19
+ export declare function scriptProfileComponentClassName(profileName: string): string;
20
+ export declare function scriptProfilePropsAlias(profileName: string): string;
21
+ export declare function scriptProfileStateAlias(profileName: string): string;
22
+ export declare function scriptProfileBridgesClassName(profileName: string): string;
23
+ /** Bridge table names whose methods include at least one capability from the profile. */
24
+ export declare function bridgeNamesForCapabilities(spec: HostSurfaceSpec, capabilities: readonly CapabilityId[]): readonly string[];
25
+ export declare function resolveScriptProfile(registry: ScriptProfileDefRegistry, name: string, spec: HostSurfaceSpec): ResolvedScriptProfile;
26
+ export declare function buildResolvedScriptProfileRegistry(registry: ScriptProfileDefRegistry, spec: HostSurfaceSpec): ResolvedScriptProfileRegistry;
27
+ export declare function validateScriptProfileRegistry(registry: ScriptProfileDefRegistry, spec: HostSurfaceSpec, componentHooks?: HostComponentHooksSpec, opts?: {
28
+ readonly requireAtLeastOne?: boolean | undefined;
29
+ }): void;
30
+ export { EMPTY_PROPS, EMPTY_STATE };
31
+ //# sourceMappingURL=scriptProfileSpec.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"scriptProfileSpec.d.ts","sourceRoot":"","sources":["../../src/domain/scriptProfileSpec.ts"],"names":[],"mappings":"AAAA,OAAO,EAAsB,KAAK,YAAY,EAAE,MAAM,qCAAqC,CAAC;AAC5F,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,6BAA6B,CAAC;AACzE,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,KAAK,EAAE,sBAAsB,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAItF,MAAM,MAAM,wBAAwB,GAAG,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,qBAAqB,CAAC,CAAC,CAAC;AAEvF,MAAM,MAAM,qBAAqB,GAAG;IAClC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IACtC,QAAQ,CAAC,YAAY,EAAE,SAAS,YAAY,EAAE,CAAC;IAC/C,QAAQ,CAAC,KAAK,EAAE,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC;IAC3C,QAAQ,CAAC,KAAK,EAAE,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC;IAC3C,QAAQ,CAAC,KAAK,EAAE,SAAS,MAAM,EAAE,CAAC;IAClC,QAAQ,CAAC,WAAW,EAAE,SAAS,MAAM,EAAE,CAAC;IACxC,QAAQ,CAAC,UAAU,CAAC,EAAE,qBAAqB,CAAC,YAAY,CAAC,CAAC;CAC3D,CAAC;AAEF,MAAM,MAAM,6BAA6B,GAAG,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,qBAAqB,CAAC,CAAC,CAAC;AAE5F,QAAA,MAAM,WAAW,EAAmB,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