|
2 | 2 | title: 'Node-Side API' |
3 | 3 | navigation: |
4 | 4 | icon: i-lucide-server-cog |
5 | | -description: 'Lookup tables for the node side: DevframeDefinition fields, CLI options, storage scopes, RPC function types, broadcast options, streaming lifecycle, remote assets, diagnostics prefixes, and the auth surface.' |
| 5 | +description: 'Lookup tables for the node side: DevframeDefinition fields, CLI options, storage scopes, RPC function types, broadcast options, streaming lifecycle, remote assets, the cross-devframe services surface, diagnostics prefixes, and the auth surface.' |
6 | 6 | --- |
7 | 7 |
|
8 | 8 | Lookup tables for a devframe's node side. Each section links the guide page that teaches the concept. |
@@ -102,6 +102,65 @@ The fields of a `RemoteAssets` source for `clientAssets` and `hostStatic` — [R |
102 | 102 | | `provider` | `'jsdelivr'` (default), `'unpkg'`, or a custom provider (internal mirror). | |
103 | 103 | | `offline` | `true` serves only from local install or cache, never network. | |
104 | 104 |
|
| 105 | +## `DevframeServicesHost` |
| 106 | + |
| 107 | +The methods on `ctx.services` — [Cross-Devframe Services](/guide/services#the-devframeserviceshost-api). |
| 108 | + |
| 109 | +| Method | Signature | Role | |
| 110 | +|--------|-----------|------| |
| 111 | +| `provide` | `(id, service) => revoke` | Publish an in-process service under a namespaced id. Throws [`DF0037`](/errors/DF0037) if the id is taken. | |
| 112 | +| `get` | `(id) => service \| undefined` | The service currently provided under `id` (augmented type, else `unknown`). | |
| 113 | +| `has` | `(id) => boolean` | Whether a service is provided under `id`. | |
| 114 | +| `whenAvailable` | `(id, cb) => unsubscribe` | Run `cb` as soon as the service exists — now if provided, else on `provide` — and re-fire on revoke/re-provide. | |
| 115 | +| `keys` | `() => string[]` | Ids of every currently-provided service. | |
| 116 | +| `install` | `(input, options?) => Promise<api \| undefined>` | Install a [wire service](#wire-service-definition-fields) at runtime (the dynamic escape hatch; the common path is declarative). `options.resolveFrom` is the descriptor's resolution base. | |
| 117 | +| `ready` | `() => Promise<void>` | **Internal.** Construct every queued wire service before any `setup` runs. Adapters call it; application code uses declarative `services`. | |
| 118 | + |
| 119 | +## Service tiers |
| 120 | + |
| 121 | +The two tiers a service can take — [Cross-Devframe Services](/guide/services). |
| 122 | + |
| 123 | +| Tier | Shared how | Registers RPC | Advertised to clients | |
| 124 | +|------|-----------|---------------|-----------------------| |
| 125 | +| In-process service (`provide`/`get`) | live object, node side only | No | No | |
| 126 | +| [Wire service](/guide/services#wire-services) (`install` / declarative `services`) | npm package, node API + RPC | Yes, under its `scope` | Yes, via `devframe:services` shared state | |
| 127 | + |
| 128 | +## Wire-service definition fields |
| 129 | + |
| 130 | +The fields of a `DevframeServiceDefinition` returned by a service package's `create<X>Service` factory — [Shipping a wire service](/guide/services#shipping-one). |
| 131 | + |
| 132 | +| Field | Type | Description | |
| 133 | +|-------|------|-------------| |
| 134 | +| `package` | `string` | **Required.** npm package name — also its registry key (`ctx.services.has(pkg)`). | |
| 135 | +| `version` | `string` | **Required.** Semver; advertised to clients, checked against declared ranges. | |
| 136 | +| `scope` | `string` | **Required.** RPC namespace its functions register under (e.g. `devframes:service:open`); `setup` gets a context pre-scoped to it. | |
| 137 | +| `meta` | `Record<string, unknown>` | Extra advertised metadata (feature flags, defaults). Must be JSON-serializable. | |
| 138 | +| `options` | `Options` | This instance's own option set, baked in by its factory; joins the merge. | |
| 139 | +| `mergeOptions` | `(sets: Options[]) => Options` | Merge multiple installers' option sets. Default: shallow, later wins. | |
| 140 | +| `setup` | `(ctx, info) => api` | **Required.** Register RPC on the pre-scoped context; return the node API served from `ctx.services.get(package)`. | |
| 141 | + |
| 142 | +## Wire-service descriptor fields |
| 143 | + |
| 144 | +The declarative reference form on `DevframeDefinition.services` / `initHub({ services })` — [Declaring services](/guide/services#declaring). |
| 145 | + |
| 146 | +| Field | Type | Description | |
| 147 | +|-------|------|-------------| |
| 148 | +| `package` | `string` | **Required.** npm package name; its default export is the factory the host imports. | |
| 149 | +| `version` | `string` | Accepted semver range. Unsatisfied warns ([`DF0069`](/errors/DF0069)), or throws ([`DF0068`](/errors/DF0068)) when `required`. | |
| 150 | +| `required` | `boolean` | Fail hard on a missing package ([`DF0067`](/errors/DF0067)) or unsatisfied range. Default `false` — a missing service is skipped and clients see `has() === false`. | |
| 151 | +| `options` | `Options` | Option set this installer contributes to the merge. | |
| 152 | + |
| 153 | +## Advertised service meta |
| 154 | + |
| 155 | +Each installed service's entry in the `devframe:services` [shared state](/guide/shared-state), mirrored to RPC clients as `rpc.services` — [Feature-detecting on the RPC client](/guide/services#feature-detecting-on-the-rpc-client). |
| 156 | + |
| 157 | +| Field | Description | |
| 158 | +|-------|-------------| |
| 159 | +| `package` | npm package name — the registry key. | |
| 160 | +| `version` | Installed version of the service. | |
| 161 | +| `scope` | RPC namespace its functions live under. | |
| 162 | +| `meta` | Extra service-declared metadata. | |
| 163 | + |
105 | 164 | ## Diagnostic code prefixes |
106 | 165 |
|
107 | 166 | Prefixes in use across the ecosystem — [Structured Diagnostics](/guide/diagnostics#code-conventions). |
|
0 commit comments