@owlmeans/server-app 0.1.18-rc.4 → 0.1.18-rc.41
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/README.md +274 -55
- package/agent-meta/manifest.json +2 -2
- package/agent-meta/skills/server-app/SKILL.md +30 -63
- package/build/context.d.ts.map +1 -1
- package/build/context.js +0 -1
- package/build/context.js.map +1 -1
- package/build/entrypoints.d.ts +3 -0
- package/build/entrypoints.d.ts.map +1 -0
- package/build/entrypoints.js +5 -0
- package/build/entrypoints.js.map +1 -0
- package/build/exports.d.ts +12 -8
- package/build/exports.d.ts.map +1 -1
- package/build/exports.js +8 -5
- package/build/exports.js.map +1 -1
- package/build/index.d.ts +1 -1
- package/build/index.d.ts.map +1 -1
- package/build/index.js +1 -1
- package/build/index.js.map +1 -1
- package/build/main.d.ts +1 -1
- package/build/main.d.ts.map +1 -1
- package/build/main.js +2 -2
- package/build/main.js.map +1 -1
- package/package.json +16 -16
- package/src/context.ts +0 -2
- package/src/entrypoints.ts +5 -0
- package/src/exports.ts +12 -8
- package/src/index.ts +1 -1
- package/src/main.ts +2 -2
- package/build/.gitkeep +0 -0
- package/build/modules.d.ts +0 -2
- package/build/modules.d.ts.map +0 -1
- package/build/modules.js +0 -4
- package/build/modules.js.map +0 -1
- package/src/modules.ts +0 -4
package/README.md
CHANGED
|
@@ -1,87 +1,306 @@
|
|
|
1
1
|
# @owlmeans/server-app
|
|
2
2
|
|
|
3
|
-
The
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
-
|
|
3
|
+
The bootstrap package for an OwlMeans backend process. An application uses it in every HTTP or
|
|
4
|
+
WebSocket API service: `makeContext` builds the base server context (Fastify API server, API
|
|
5
|
+
client, socket service, static resources and the Ed25519 auth guard), `main` registers the
|
|
6
|
+
entrypoints, initializes the context and starts listening, and the package re-exports the server
|
|
7
|
+
vocabulary (`bind`, `handlers`, `config`, `sservice`, `route`, ...) so backend code has one import
|
|
8
|
+
target. Do not use it in a shared `common` package that only declares protocols (depend on
|
|
9
|
+
`@owlmeans/entrypoint` and `@owlmeans/route` there), in the auth manager process (use
|
|
10
|
+
`@owlmeans/server-auth/manager`, which has its own `makeContext` and `main`), or in a browser app
|
|
11
|
+
(use `@owlmeans/web-panel`).
|
|
11
12
|
|
|
12
13
|
## Installation
|
|
13
14
|
|
|
14
15
|
```bash
|
|
15
|
-
bun add @owlmeans/server-app
|
|
16
|
+
bun add @owlmeans/server-app@^0.1.18-rc.41
|
|
16
17
|
```
|
|
17
18
|
|
|
19
|
+
## Concepts
|
|
20
|
+
|
|
21
|
+
- **Application context** — one per process, built by the app's own factory that calls
|
|
22
|
+
`makeContext(cfg)` and then adds its own resources and services with idempotent `append*` mixins.
|
|
23
|
+
`AppConfig` / `AppContext` are the types that factory extends.
|
|
24
|
+
- **`customize` flag** — `makeContext(cfg, true)` skips the default in-process `AUTH_CACHE` and
|
|
25
|
+
`appendAuthService`, so the app can register a shared cache (Redis) and the auth guard itself.
|
|
26
|
+
- **Framework entrypoints** — `entrypoints` is the list of bindings every service carries: the
|
|
27
|
+
`@owlmeans/server-auth` dispatcher bindings and the `@owlmeans/api-config-server` config endpoint.
|
|
28
|
+
- **Bindings** — the app's server-local list of `bind(protocol, handler)` results, materialized from
|
|
29
|
+
the shared protocol tree and passed to `main`.
|
|
30
|
+
- **Port hold** — `holdApiPort` answers on the service port while the context initializes, so a
|
|
31
|
+
slow or failing boot answers 503 instead of a connection error.
|
|
32
|
+
|
|
18
33
|
## Usage
|
|
19
34
|
|
|
20
|
-
|
|
35
|
+
### 1. Config
|
|
36
|
+
|
|
37
|
+
`config(service, base?)` creates a backend config for the named service; `sservice` declares a
|
|
38
|
+
backend service route and `service` any other (frontend) one. A service with `opened: true` listens
|
|
39
|
+
on `0.0.0.0`, otherwise on `127.0.0.1`.
|
|
40
|
+
|
|
41
|
+
```ts
|
|
42
|
+
import { AppType, config, service, sservice } from '@owlmeans/server-app'
|
|
43
|
+
import type { AppConfig } from '@owlmeans/server-app'
|
|
44
|
+
import { MY_APP_API, MY_APP_WEB, commonConfig } from 'my-app-common'
|
|
21
45
|
|
|
22
|
-
|
|
23
|
-
import { makeContext, main, modules, config, service, AppType, Layer } from '@owlmeans/server-app'
|
|
46
|
+
export interface Config extends AppConfig { }
|
|
24
47
|
|
|
25
|
-
const
|
|
26
|
-
AppType.Backend,
|
|
27
|
-
'manager-api',
|
|
28
|
-
service({ service: 'mongo', host: process.env.MONGO_HOST!, port: 27017 }),
|
|
29
|
-
{ layer: Layer.Service, port: 3000 }
|
|
30
|
-
)
|
|
48
|
+
const cfg = config<Config>(MY_APP_API, commonConfig as Config)
|
|
31
49
|
|
|
32
|
-
|
|
33
|
-
|
|
50
|
+
sservice({ service: MY_APP_API, internalHost: 'localhost', internalPort: 3000 }, cfg)
|
|
51
|
+
cfg.services[MY_APP_API].opened = true
|
|
52
|
+
|
|
53
|
+
service({ type: AppType.Frontend, service: MY_APP_WEB, host: 'localhost', port: 5173 }, cfg)
|
|
54
|
+
|
|
55
|
+
export default cfg
|
|
34
56
|
```
|
|
35
57
|
|
|
36
|
-
|
|
58
|
+
### 2. Context factory
|
|
59
|
+
|
|
60
|
+
The app's factory composes the base context and adds its own resources. For development or a
|
|
61
|
+
single replica the defaults are enough:
|
|
62
|
+
|
|
63
|
+
```ts
|
|
64
|
+
import { makeContext as makeAppContext } from '@owlmeans/server-app'
|
|
65
|
+
import type { AppContext } from '@owlmeans/server-app'
|
|
66
|
+
import { appendStaticResource } from '@owlmeans/static-resource'
|
|
67
|
+
import type { StaticResourceAppend } from '@owlmeans/static-resource'
|
|
68
|
+
import type { Resource } from '@owlmeans/resource'
|
|
69
|
+
import type { Project } from 'my-app-common'
|
|
70
|
+
import type { Config } from './config.js'
|
|
71
|
+
|
|
72
|
+
export const PROJECTS = 'my-app:projects'
|
|
73
|
+
|
|
74
|
+
export interface Context<C extends Config = Config> extends AppContext<C>, StaticResourceAppend {
|
|
75
|
+
project: () => Resource<Project>
|
|
76
|
+
}
|
|
37
77
|
|
|
38
|
-
|
|
39
|
-
|
|
78
|
+
export const makeContext = <C extends Config, T extends Context<C>>(cfg: C): T => {
|
|
79
|
+
const context = makeAppContext<C, T>(cfg)
|
|
40
80
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
81
|
+
appendStaticResource<C, T>(context, PROJECTS)
|
|
82
|
+
context.project = () => context.getStaticResource<Project>(PROJECTS)
|
|
83
|
+
|
|
84
|
+
return context
|
|
85
|
+
}
|
|
44
86
|
```
|
|
45
87
|
|
|
46
|
-
|
|
88
|
+
A scaled deployment passes `customize: true` and registers a shared auth cache before the guard:
|
|
89
|
+
|
|
90
|
+
```ts
|
|
91
|
+
import { klusterize, makeContext as makeAppContext } from '@owlmeans/server-app'
|
|
92
|
+
import { appendMongo } from '@owlmeans/mongo'
|
|
93
|
+
import { appendRedis } from '@owlmeans/redis'
|
|
94
|
+
import { makeRedisResource } from '@owlmeans/redis-resource'
|
|
95
|
+
import { appendAuthService, AUTH_CACHE } from '@owlmeans/server-auth'
|
|
96
|
+
import { appendAuthIdentityResources } from '@owlmeans/server-auth-identity'
|
|
47
97
|
|
|
48
|
-
|
|
98
|
+
export const makeContext = <C extends Config, T extends Context<C>>(cfg: C): T => {
|
|
99
|
+
const context = makeAppContext<C, T>(cfg, true)
|
|
100
|
+
klusterize<C, T>(context)
|
|
101
|
+
appendMongo<C, T>(context)
|
|
102
|
+
appendRedis<C, T>(context)
|
|
49
103
|
|
|
50
|
-
|
|
104
|
+
context.registerResource(makeRedisResource(AUTH_CACHE))
|
|
105
|
+
appendAuthService<C, T>(context)
|
|
106
|
+
appendAuthIdentityResources(context)
|
|
107
|
+
|
|
108
|
+
// app-local Mongo resource factory, same `project()` accessor as above
|
|
109
|
+
context.registerResource(makeProjectResource(PROJECTS))
|
|
110
|
+
context.project = () => context.resource(PROJECTS)
|
|
111
|
+
|
|
112
|
+
return context
|
|
113
|
+
}
|
|
114
|
+
```
|
|
51
115
|
|
|
52
|
-
###
|
|
116
|
+
### 3. Handlers bound to shared protocols
|
|
117
|
+
|
|
118
|
+
Protocols live in the shared package; guards and gates on a parent are inherited by its children.
|
|
119
|
+
|
|
120
|
+
```ts
|
|
121
|
+
// my-app-common/src/protocols.ts
|
|
122
|
+
import { contract, openProtocol, protocol, typed } from '@owlmeans/entrypoint'
|
|
123
|
+
import { route, RouteMethod, socket } from '@owlmeans/route'
|
|
124
|
+
import { DEFAULT_GUARD } from '@owlmeans/auth-common'
|
|
125
|
+
|
|
126
|
+
const projectBase = openProtocol(route('my-app:api:project', '/project'), {
|
|
127
|
+
guards: DEFAULT_GUARD,
|
|
128
|
+
gate: { alias: MY_APP_GATE, params: ['my-app-project-{entity}'] },
|
|
129
|
+
})
|
|
130
|
+
|
|
131
|
+
export const projectProtocols = {
|
|
132
|
+
base: projectBase,
|
|
133
|
+
list: protocol(
|
|
134
|
+
route('my-app:api:project:list', '/', { parent: projectBase, method: RouteMethod.GET }),
|
|
135
|
+
contract(typed<Project[]>()),
|
|
136
|
+
),
|
|
137
|
+
create: protocol(
|
|
138
|
+
route('my-app:api:project:create', '/', { parent: projectBase, method: RouteMethod.POST }),
|
|
139
|
+
contract.request({ body: typed<CreateProject>(CreateProjectSchema) }, typed<Project>()),
|
|
140
|
+
),
|
|
141
|
+
get: protocol(
|
|
142
|
+
route('my-app:api:project:get', '/:id', { parent: projectBase, method: RouteMethod.GET }),
|
|
143
|
+
contract.request({ params: typed<ProjectParams>(ProjectParamsSchema) }, typed<Project>()),
|
|
144
|
+
),
|
|
145
|
+
watch: protocol(
|
|
146
|
+
route('my-app:api:project:watch', '/:id/watch', socket({ parent: projectBase })),
|
|
147
|
+
contract.request({ params: typed<ProjectParams>(ProjectParamsSchema) }, typed<void>()),
|
|
148
|
+
),
|
|
149
|
+
}
|
|
150
|
+
```
|
|
53
151
|
|
|
54
|
-
|
|
152
|
+
```ts
|
|
153
|
+
// my-app-api/src/app/project.ts
|
|
154
|
+
import { handlers } from '@owlmeans/server-app'
|
|
155
|
+
import { requireEntityKey } from '@owlmeans/auth-common'
|
|
156
|
+
import { projectProtocols } from 'my-app-common'
|
|
157
|
+
import type { Context } from '../context.js'
|
|
55
158
|
|
|
56
|
-
|
|
159
|
+
const api = handlers<Context>()
|
|
57
160
|
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
| `celevate` | `@owlmeans/client-entrypoint` |
|
|
63
|
-
| `route` | `@owlmeans/route` |
|
|
64
|
-
| `broute` | `@owlmeans/server-route` |
|
|
65
|
-
| `filter`, `body`, `params`, `parent`, `EntrypointOutcome` | `@owlmeans/entrypoint` |
|
|
66
|
-
| `config`, `service`, `sservice`, `toConfigRecord` | various config packages |
|
|
67
|
-
| `AppType`, `Layer`, `BASE`, `assertContext` | `@owlmeans/context` |
|
|
68
|
-
| `DAUTH_GUARD` | `@owlmeans/server-auth` |
|
|
69
|
-
| `GUARD_ED25519`, `BED255_CASHE_RESOURCE` | `@owlmeans/auth-common` |
|
|
70
|
-
| `klusterize` | `@owlmeans/kluster` |
|
|
71
|
-
| `Request`, `Response`, `CommonEntrypoint`, `ClientEntrypoint` | type re-exports |
|
|
161
|
+
export const list = api.request(projectProtocols.list, async (request, context) => {
|
|
162
|
+
const { items } = await context.project().list({ entityId: requireEntityKey(request) })
|
|
163
|
+
return items
|
|
164
|
+
})
|
|
72
165
|
|
|
73
|
-
|
|
166
|
+
export const create = api.body(projectProtocols.create, async (body, context, request) =>
|
|
167
|
+
context.project().create({ ...body, entityId: requireEntityKey(request) }))
|
|
74
168
|
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
await main(context, [...modules, ...myModules])
|
|
169
|
+
export const get = api.params(projectProtocols.get, async ({ id }, context, request) =>
|
|
170
|
+
context.project().load({ id, entityId: requireEntityKey(request) }))
|
|
78
171
|
```
|
|
79
172
|
|
|
80
|
-
|
|
173
|
+
### 4. Entrypoint list and `main`
|
|
174
|
+
|
|
175
|
+
```ts
|
|
176
|
+
// my-app-api/src/entrypoints.ts
|
|
177
|
+
import { bind, entrypoints } from '@owlmeans/server-app'
|
|
178
|
+
import { connection } from '@owlmeans/server-socket'
|
|
179
|
+
import { projectProtocols } from 'my-app-common'
|
|
180
|
+
import * as project from './app/project.js'
|
|
181
|
+
|
|
182
|
+
export const appEntrypoints = [
|
|
183
|
+
...entrypoints,
|
|
184
|
+
bind(projectProtocols.base),
|
|
185
|
+
bind(projectProtocols.list, project.list),
|
|
186
|
+
bind(projectProtocols.create, project.create),
|
|
187
|
+
bind(projectProtocols.get, project.get),
|
|
188
|
+
// socket protocols bind the same way; see @owlmeans/server-socket
|
|
189
|
+
bind(projectProtocols.watch, connection(projectProtocols.watch, async (conn, context, request) => {
|
|
190
|
+
await conn.notify('project:ready', { id: request.params.id })
|
|
191
|
+
})),
|
|
192
|
+
]
|
|
193
|
+
|
|
194
|
+
// my-app-api/src/index.ts
|
|
195
|
+
import { main } from '@owlmeans/server-app'
|
|
196
|
+
import config from './config.js'
|
|
197
|
+
import { makeContext } from './context.js'
|
|
198
|
+
import { appEntrypoints } from './entrypoints.js'
|
|
199
|
+
|
|
200
|
+
await main(makeContext(config), appEntrypoints)
|
|
201
|
+
```
|
|
202
|
+
|
|
203
|
+
### 5. A boot that holds the port
|
|
204
|
+
|
|
205
|
+
`main` is `registerEntrypoints` + `configure().init()` + `getApiServer().listen()`. Write it out when
|
|
206
|
+
something must run between init and listen, or when the port must answer during a long boot:
|
|
207
|
+
|
|
208
|
+
```ts
|
|
209
|
+
import { holdApiPort } from '@owlmeans/server-app'
|
|
210
|
+
import type { ApiPortHold } from '@owlmeans/server-app'
|
|
211
|
+
|
|
212
|
+
const boot = async () => {
|
|
213
|
+
let hold: ApiPortHold
|
|
214
|
+
try {
|
|
215
|
+
hold = await holdApiPort(config, { okPath: '/healthz', payload: () => ({ status: 'booting' }) })
|
|
216
|
+
} catch (error) {
|
|
217
|
+
console.error('port is taken', error)
|
|
218
|
+
process.exit(1) // a failed bind must be fatal
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
const context = makeContext(config)
|
|
222
|
+
context.registerEntrypoints(appEntrypoints)
|
|
223
|
+
try {
|
|
224
|
+
await context.configure().init()
|
|
225
|
+
await seed(context)
|
|
226
|
+
} catch (error) {
|
|
227
|
+
console.error('boot failed', error) // the hold keeps answering 503
|
|
228
|
+
return
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
await hold.release()
|
|
232
|
+
await context.getApiServer().listen()
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
await boot()
|
|
236
|
+
```
|
|
237
|
+
|
|
238
|
+
## API
|
|
239
|
+
|
|
240
|
+
### Bootstrap
|
|
241
|
+
|
|
242
|
+
| Symbol | Kind | Purpose |
|
|
243
|
+
|---|---|---|
|
|
244
|
+
| `makeContext<C, T>(cfg, customize = false)` | function | Server context with API server, API client, socket service and middleware, default static resource; unless `customize`, also a static `AUTH_CACHE` and `appendAuthService` |
|
|
245
|
+
| `main<R, C, T>(ctx, entrypoints)` | function | Register entrypoints, `configure().init()`, then `getApiServer().listen()` |
|
|
246
|
+
| `entrypoints` | const | Framework bindings: `@owlmeans/server-auth` dispatcher + `@owlmeans/api-config-server` |
|
|
247
|
+
| `AppConfig` | type | `ServerConfig & KlusterConfig` with `services: Record<string, ServiceRoute>` |
|
|
248
|
+
| `AppContext<C>` | type | `ServerContext<C> & AuthServiceAppend & ApiServerAppend` |
|
|
249
|
+
|
|
250
|
+
### Re-exports
|
|
251
|
+
|
|
252
|
+
| Symbol | Kind | Source |
|
|
253
|
+
|---|---|---|
|
|
254
|
+
| `config` | function | `@owlmeans/server-context` — `config(service, cfg?)` |
|
|
255
|
+
| `sservice` | function | `@owlmeans/server-config` — declare a backend service route |
|
|
256
|
+
| `service`, `toConfigRecord`, `PLUGINS` | function / const | `@owlmeans/config` |
|
|
257
|
+
| `PluginConfig` | type | `@owlmeans/config` |
|
|
258
|
+
| `addWebService` | function | `@owlmeans/client-config` |
|
|
259
|
+
| `contract`, `protocol`, `typed`, `EntrypointOutcome` | function / enum | `@owlmeans/entrypoint` |
|
|
260
|
+
| `Request`, `Response` | type | `AbstractRequest`, `AbstractResponse` from `@owlmeans/entrypoint` |
|
|
261
|
+
| `bind`, `bindAll` | function | `@owlmeans/server-entrypoint` |
|
|
262
|
+
| `handlers`, `holdApiPort` | function | `@owlmeans/server-api` |
|
|
263
|
+
| `handleBody`, `handleParams`, `handleRequest`, `handleIntermediate` | function | `@owlmeans/server-api` — unbound compatibility wrappers |
|
|
264
|
+
| `ApiPortHold`, `ApiPortHoldOptions` | type | `@owlmeans/server-api` |
|
|
265
|
+
| `route` | function | `@owlmeans/route` |
|
|
266
|
+
| `broute` | function | `route` from `@owlmeans/server-route` |
|
|
267
|
+
| `ClientEntrypoint` | type | `@owlmeans/client-entrypoint` |
|
|
268
|
+
| `AppType`, `BASE`, `assertContext` | enum / const / function | `@owlmeans/context` |
|
|
269
|
+
| `DAUTH_GUARD` | const | `DEFAULT_ALIAS` (`'auth'`) from `@owlmeans/server-auth` |
|
|
270
|
+
| `GUARD_ED25519`, `BED255_CASHE_RESOURCE` | const | `@owlmeans/auth-common` |
|
|
271
|
+
| `klusterize` | function | `@owlmeans/kluster` |
|
|
272
|
+
| `createListSchema`, `filterObject` | function | `@owlmeans/resource` |
|
|
273
|
+
| `Criteria`, `ListOptions`, `ListQuery`, `ListResult`, `Sort` | type | `@owlmeans/resource` |
|
|
274
|
+
|
|
275
|
+
## Common pitfalls
|
|
276
|
+
|
|
277
|
+
- Keep `protocol()` declarations in the shared package; a server supplies implementations with
|
|
278
|
+
`bind()` and `handlers()` and never changes a declaration or finds it by alias.
|
|
279
|
+
- Bind parent and group declarations (`bind(projectProtocols.base)`) as well as leaves — parents
|
|
280
|
+
establish inherited paths, guards and gates.
|
|
281
|
+
- `entrypoints` holds framework registrations. Spread it into a new local array; do not mutate it.
|
|
282
|
+
- The default `makeContext(cfg)` backs `AUTH_CACHE` with an in-process static resource, correct for
|
|
283
|
+
one replica only. A scaled service passes `customize: true` and registers a Redis resource under
|
|
284
|
+
`AUTH_CACHE` before `appendAuthService`.
|
|
285
|
+
- Validation belongs in `contract()` with `typed()` or `schema()`, not in a wrapper around a handler.
|
|
286
|
+
Prefer `handlers<Context>()` over the unbound `handleBody` / `handleParams` / `handleRequest`.
|
|
287
|
+
- Key organization-scoped records on `requireEntityKey(request)` / `requireEntity(request)`; never
|
|
288
|
+
read an organization id from the token — `entitySlug` is the only organization value on the wire.
|
|
289
|
+
- Reference other services' entrypoints with `context.entrypoint(protocol)` and the protocol object,
|
|
290
|
+
without a caller-side response generic.
|
|
291
|
+
- A `holdApiPort` bind failure (`EADDRINUSE`) must end the process with a non-zero exit.
|
|
292
|
+
|
|
293
|
+
## Related packages
|
|
81
294
|
|
|
82
|
-
- [`@owlmeans/server-context`](../server-context) — `makeServerContext
|
|
83
|
-
- [`@owlmeans/server-api`](../server-api) —
|
|
84
|
-
- [`@owlmeans/server-entrypoint`](../server-entrypoint) — `
|
|
295
|
+
- [`@owlmeans/server-context`](../server-context) — `makeServerContext`, called by `makeContext`
|
|
296
|
+
- [`@owlmeans/server-api`](../server-api) — the Fastify API server and `handlers`
|
|
297
|
+
- [`@owlmeans/server-entrypoint`](../server-entrypoint) — `bind` / `bindAll`
|
|
298
|
+
- [`@owlmeans/server-socket`](../server-socket) — WebSocket bindings
|
|
299
|
+
- [`@owlmeans/server-auth`](../server-auth) — the Ed25519 guard and `AUTH_CACHE`
|
|
300
|
+
- [`@owlmeans/server-auth-identity`](../server-auth-identity) — local identity and entity resolver
|
|
301
|
+
- [`@owlmeans/entrypoint`](../entrypoint) and [`@owlmeans/route`](../route) — shared protocol declarations
|
|
302
|
+
- [`@owlmeans/static-resource`](../static-resource) — in-memory resources
|
|
303
|
+
- [`@owlmeans/kluster`](../kluster) — `klusterize`
|
|
85
304
|
|
|
86
305
|
<!-- owlmeans:agent-guidance:start -->
|
|
87
306
|
## Agent guidance
|
|
@@ -91,7 +310,7 @@ This package ships embedded agent skills under `agent-meta/`. After installing y
|
|
|
91
310
|
your project's skill store (`.agents/skills/`):
|
|
92
311
|
|
|
93
312
|
```sh
|
|
94
|
-
npx @owlmeans/agent-skills
|
|
313
|
+
npx @owlmeans/agent-skills@^0.1.18-rc.36
|
|
95
314
|
```
|
|
96
315
|
|
|
97
316
|
The embedded files are version-matched to this package release. Do not edit them
|
package/agent-meta/manifest.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"schemaVersion": 2,
|
|
3
3
|
"package": "@owlmeans/server-app",
|
|
4
|
-
"version": "0.1.18-rc.
|
|
5
|
-
"generatedAt": "2026-
|
|
4
|
+
"version": "0.1.18-rc.41",
|
|
5
|
+
"generatedAt": "2026-09-22T22:22:19.441Z",
|
|
6
6
|
"canonicalRepo": "https://github.com/owlmeans/common",
|
|
7
7
|
"entries": [
|
|
8
8
|
{
|
|
@@ -1,78 +1,45 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: server-app
|
|
3
|
-
description:
|
|
4
|
-
user-invocable: false
|
|
3
|
+
description: Build OwlMeans server applications from immutable entrypoint protocol declarations. Use when starting a server, binding endpoint implementations, configuring services, or registering server entrypoints.
|
|
5
4
|
---
|
|
6
5
|
<!-- AUTO-GENERATED — do not edit. Regenerate via sync-agent-meta. -->
|
|
7
6
|
|
|
8
|
-
#
|
|
7
|
+
# Server application entrypoints
|
|
9
8
|
|
|
10
|
-
**
|
|
11
|
-
**Install:** `"@owlmeans/server-app": "^0.1.18-rc.0"` in `dependencies`
|
|
9
|
+
**Install:** `bun add @owlmeans/server-app@^0.1.18-rc.41`
|
|
12
10
|
|
|
13
|
-
|
|
11
|
+
Declare routes and request/response contracts in a shared package with `protocol()` or
|
|
12
|
+
`openProtocol()`. A server package supplies local implementations with `bind()` and `handlers()`;
|
|
13
|
+
it never changes a shared declaration by alias.
|
|
14
14
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
| `handleBody<T>(fn)` | Wrap an async function with validated body — `(payload, context, req) => result` |
|
|
20
|
-
| `elevate(modules, alias, handler)` | Attach a handler to an entrypoint declaration |
|
|
21
|
-
| `celevate(modules, alias, handler)` | Conditional elevate — only if entrypoint exists |
|
|
22
|
-
| `sservice(options, cfg)` | Register a server-side service entry in the config |
|
|
23
|
-
| `modules` | Built-in system entrypoints — spread into `appModules` |
|
|
24
|
-
| `Context`, `Config`, `ClientEntrypoint` re-exports | Common types |
|
|
15
|
+
```ts
|
|
16
|
+
import { bind, entrypoints, handlers } from '@owlmeans/server-app'
|
|
17
|
+
import { projectProtocols } from 'project-common'
|
|
18
|
+
import { createProject } from './app/project.js'
|
|
25
19
|
|
|
26
|
-
|
|
20
|
+
const api = handlers<Context>()
|
|
27
21
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
import { makeContext } from './context.js'
|
|
34
|
-
import { appModules } from './modules.js'
|
|
35
|
-
|
|
36
|
-
const context = makeContext(config)
|
|
37
|
-
main<{}, Config, Context>(context, appModules)
|
|
22
|
+
export const serverBindings = [
|
|
23
|
+
...entrypoints,
|
|
24
|
+
bind(projectProtocols.base),
|
|
25
|
+
bind(projectProtocols.create, api.body(projectProtocols.create, createProject)),
|
|
26
|
+
]
|
|
38
27
|
```
|
|
39
28
|
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
import { AuthUnknown } from '@owlmeans/auth'
|
|
44
|
-
import type { ClientEntrypoint } from '@owlmeans/server-app'
|
|
45
|
-
|
|
46
|
-
export const list = handleRequest(async (req, context) => {
|
|
47
|
-
if (req.auth?.entityId == null) throw new AuthUnknown('entity')
|
|
48
|
-
const ctx = context as Context
|
|
49
|
-
const { items } = await ctx.project().list({ entityId: req.auth.entityId })
|
|
50
|
-
return items
|
|
51
|
-
})
|
|
52
|
-
|
|
53
|
-
export const create = handleBody<CreateProject>(async (payload, context, req) => {
|
|
54
|
-
const ctx = context as Context
|
|
55
|
-
const [result] = await ctx.entrypoint<ClientEntrypoint<Project>>(agent.project.create).call({
|
|
56
|
-
body: { prompt: payload.prompt, entity: req.auth?.entityId }
|
|
57
|
-
})
|
|
58
|
-
return result
|
|
59
|
-
})
|
|
60
|
-
```
|
|
29
|
+
`handlers<Context>().body`, `.params` and `.request` infer request sections and response values
|
|
30
|
+
from the declaration. Use `.request` for a transport-level handler that needs the complete request
|
|
31
|
+
boundary.
|
|
61
32
|
|
|
62
|
-
|
|
63
|
-
```typescript
|
|
64
|
-
import { elevate, modules } from '@owlmeans/server-app'
|
|
65
|
-
import { managerModules } from 'my-common'
|
|
66
|
-
import { create, list } from './app/project/index.js'
|
|
67
|
-
|
|
68
|
-
elevate(managerModules, manager.back.project.create, create)
|
|
69
|
-
elevate(managerModules, manager.back.project.list, list)
|
|
70
|
-
|
|
71
|
-
export const appModules = [...modules, ...paymentModules, ...managerModules]
|
|
72
|
-
```
|
|
33
|
+
## Rules
|
|
73
34
|
|
|
74
|
-
|
|
35
|
+
- Keep `protocol()` declarations in the common package shared by callers and servers.
|
|
36
|
+
- Bind parent/group declarations as well as leaves; parents establish inherited paths and access.
|
|
37
|
+
- Use direct protocol references in `context.entrypoint(protocol)`; do not supply a caller-side
|
|
38
|
+
response generic.
|
|
39
|
+
- Model validation belongs in `contract()` with `typed()` or `schema()`, not in a wrapper around a
|
|
40
|
+
handler.
|
|
41
|
+
- `entrypoints` contains framework registrations. Add local entrypoints to a new array and register
|
|
42
|
+
that array during context initialization.
|
|
75
43
|
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
- `express` / `fastify` (server runtime)
|
|
44
|
+
`holdApiPort`, `config`, `sservice`, `service`, `AppType` and the context bootstrap exports remain
|
|
45
|
+
available from this package for process wiring.
|
package/build/context.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../src/context.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,YAAY,CAAA;AAMvD,eAAO,MAAM,WAAW,GAAI,CAAC,SAAS,SAAS,EAAE,CAAC,SAAS,UAAU,CAAC,CAAC,CAAC,OAAO,CAAC,cAAa,OAAO,
|
|
1
|
+
{"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../src/context.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,YAAY,CAAA;AAMvD,eAAO,MAAM,WAAW,GAAI,CAAC,SAAS,SAAS,EAAE,CAAC,SAAS,UAAU,CAAC,CAAC,CAAC,OAAO,CAAC,cAAa,OAAO,MAgBnG,CAAA"}
|
package/build/context.js
CHANGED
|
@@ -15,7 +15,6 @@ export const makeContext = (cfg, customize = false) => {
|
|
|
15
15
|
appendStaticResource(context, AUTH_CACHE);
|
|
16
16
|
appendAuthService(context);
|
|
17
17
|
}
|
|
18
|
-
context.makeContext = cfg => makeContext(cfg, customize);
|
|
19
18
|
return context;
|
|
20
19
|
};
|
|
21
20
|
//# sourceMappingURL=context.js.map
|
package/build/context.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"context.js","sourceRoot":"","sources":["../src/context.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAA;AACrE,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAA;AAE5D,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAA;AACtD,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAA;AAC/C,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAA;AAChE,OAAO,EAAE,mBAAmB,EAAE,sBAAsB,EAAE,MAAM,yBAAyB,CAAA;AAErF,MAAM,CAAC,MAAM,WAAW,GAAG,CAA+C,GAAM,EAAE,SAAS,GAAY,KAAK,EAAE,EAAE;IAC9G,MAAM,OAAO,GAAG,iBAAiB,CAAC,GAAG,CAAM,CAAA;IAE3C,eAAe,CAAO,OAAO,CAAC,CAAA;IAC9B,eAAe,CAAO,OAAO,CAAC,CAAA;IAC9B,mBAAmB,CAAO,OAAO,CAAC,CAAA;IAElC,OAAO,CAAC,kBAAkB,CAAC,sBAAsB,EAAE,CAAC,CAAA;IAEpD,oBAAoB,CAAO,OAAO,CAAC,CAAA;IACnC,IAAI,CAAC,SAAS,IAAI,CAAC,OAAO,CAAC,WAAW,CAAC,UAAU,CAAC,EAAE,CAAC;QACnD,oBAAoB,CAAO,OAAO,EAAE,UAAU,CAAC,CAAA;QAC/C,iBAAiB,CAAO,OAAO,CAAC,CAAA;IAClC,CAAC;IAED,OAAO,
|
|
1
|
+
{"version":3,"file":"context.js","sourceRoot":"","sources":["../src/context.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAA;AACrE,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAA;AAE5D,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAA;AACtD,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAA;AAC/C,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAA;AAChE,OAAO,EAAE,mBAAmB,EAAE,sBAAsB,EAAE,MAAM,yBAAyB,CAAA;AAErF,MAAM,CAAC,MAAM,WAAW,GAAG,CAA+C,GAAM,EAAE,SAAS,GAAY,KAAK,EAAE,EAAE;IAC9G,MAAM,OAAO,GAAG,iBAAiB,CAAC,GAAG,CAAM,CAAA;IAE3C,eAAe,CAAO,OAAO,CAAC,CAAA;IAC9B,eAAe,CAAO,OAAO,CAAC,CAAA;IAC9B,mBAAmB,CAAO,OAAO,CAAC,CAAA;IAElC,OAAO,CAAC,kBAAkB,CAAC,sBAAsB,EAAE,CAAC,CAAA;IAEpD,oBAAoB,CAAO,OAAO,CAAC,CAAA;IACnC,IAAI,CAAC,SAAS,IAAI,CAAC,OAAO,CAAC,WAAW,CAAC,UAAU,CAAC,EAAE,CAAC;QACnD,oBAAoB,CAAO,OAAO,EAAE,UAAU,CAAC,CAAA;QAC/C,iBAAiB,CAAO,OAAO,CAAC,CAAA;IAClC,CAAC;IAED,OAAO,OAAO,CAAA;AAChB,CAAC,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"entrypoints.d.ts","sourceRoot":"","sources":["../src/entrypoints.ts"],"names":[],"mappings":"AAGA,+DAA+D;AAC/D,eAAO,MAAM,WAAW,gIAA0C,CAAA"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { entrypoints as apiConfigBindings } from '@owlmeans/api-config-server';
|
|
2
|
+
import { entrypoints as authBindings } from '@owlmeans/server-auth';
|
|
3
|
+
/** Framework server entrypoints every application receives. */
|
|
4
|
+
export const entrypoints = [...authBindings, ...apiConfigBindings];
|
|
5
|
+
//# sourceMappingURL=entrypoints.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"entrypoints.js","sourceRoot":"","sources":["../src/entrypoints.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,IAAI,iBAAiB,EAAE,MAAM,6BAA6B,CAAA;AAC9E,OAAO,EAAE,WAAW,IAAI,YAAY,EAAE,MAAM,uBAAuB,CAAA;AAEnE,+DAA+D;AAC/D,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,GAAG,YAAY,EAAE,GAAG,iBAAiB,CAAC,CAAA"}
|
package/build/exports.d.ts
CHANGED
|
@@ -1,21 +1,25 @@
|
|
|
1
1
|
export { config } from '@owlmeans/server-context';
|
|
2
|
+
export { makeContext } from './context.js';
|
|
3
|
+
export { main } from './main.js';
|
|
4
|
+
export type { AppConfig, AppContext } from './types.js';
|
|
2
5
|
export { sservice } from '@owlmeans/server-config';
|
|
3
6
|
export { addWebService } from '@owlmeans/client-config';
|
|
4
7
|
export { service, toConfigRecord, PLUGINS } from '@owlmeans/config';
|
|
5
|
-
export {
|
|
8
|
+
export { contract, protocol, typed, EntrypointOutcome } from '@owlmeans/entrypoint';
|
|
6
9
|
export type { AbstractRequest as Request, AbstractResponse as Response } from '@owlmeans/entrypoint';
|
|
7
10
|
export { createListSchema, filterObject } from '@owlmeans/resource';
|
|
8
|
-
export type { ListResult } from '@owlmeans/resource';
|
|
9
|
-
export { AppType, BASE,
|
|
10
|
-
export {
|
|
11
|
-
export { elevate as celevate } from '@owlmeans/client-entrypoint';
|
|
12
|
-
export type { ServerEntrypoint as Module, RefedEntrypointHandler } from '@owlmeans/server-entrypoint';
|
|
13
|
-
export type { ClientEntrypoint } from '@owlmeans/client-entrypoint';
|
|
11
|
+
export type { Criteria, ListOptions, ListQuery, ListResult, Sort } from '@owlmeans/resource';
|
|
12
|
+
export { AppType, BASE, assertContext } from '@owlmeans/context';
|
|
13
|
+
export { bind, bindAll } from '@owlmeans/server-entrypoint';
|
|
14
14
|
export { route as broute } from '@owlmeans/server-route';
|
|
15
|
-
export {
|
|
15
|
+
export { handlers, holdApiPort } from '@owlmeans/server-api';
|
|
16
|
+
export { handleIntermediate, handleBody, handleRequest, handleParams } from '@owlmeans/server-api';
|
|
17
|
+
export type { ApiPortHold, ApiPortHoldOptions } from '@owlmeans/server-api';
|
|
18
|
+
export type { ClientEntrypoint } from '@owlmeans/client-entrypoint';
|
|
16
19
|
export { route } from '@owlmeans/route';
|
|
17
20
|
export { DEFAULT_ALIAS as DAUTH_GUARD } from '@owlmeans/server-auth';
|
|
18
21
|
export { klusterize } from '@owlmeans/kluster';
|
|
19
22
|
export type { PluginConfig } from '@owlmeans/config';
|
|
20
23
|
export { GUARD_ED25519, BED255_CASHE_RESOURCE } from '@owlmeans/auth-common';
|
|
24
|
+
export { entrypoints } from './entrypoints.js';
|
|
21
25
|
//# sourceMappingURL=exports.d.ts.map
|
package/build/exports.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"exports.d.ts","sourceRoot":"","sources":["../src/exports.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,0BAA0B,CAAA;AACjD,OAAO,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAA;AAClD,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAA;AACvD,OAAO,EAAE,OAAO,EAAE,cAAc,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAA;AACnE,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"exports.d.ts","sourceRoot":"","sources":["../src/exports.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,0BAA0B,CAAA;AACjD,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAA;AAC1C,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AAChC,YAAY,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,YAAY,CAAA;AACvD,OAAO,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAA;AAClD,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAA;AACvD,OAAO,EAAE,OAAO,EAAE,cAAc,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAA;AACnE,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,KAAK,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAA;AACnF,YAAY,EAAE,eAAe,IAAI,OAAO,EAAE,gBAAgB,IAAI,QAAQ,EAAE,MAAM,sBAAsB,CAAA;AACpG,OAAO,EAAE,gBAAgB,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAA;AACnE,YAAY,EAAE,QAAQ,EAAE,WAAW,EAAE,SAAS,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,oBAAoB,CAAA;AAC5F,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAA;AAChE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,6BAA6B,CAAA;AAC3D,OAAO,EAAE,KAAK,IAAI,MAAM,EAAE,MAAM,wBAAwB,CAAA;AACxD,OAAO,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAA;AAC5D,OAAO,EAAE,kBAAkB,EAAE,UAAU,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAA;AAClG,YAAY,EAAE,WAAW,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAA;AAC3E,YAAY,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAA;AACnE,OAAO,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAA;AACvC,OAAO,EAAE,aAAa,IAAI,WAAW,EAAE,MAAM,uBAAuB,CAAA;AACpE,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAA;AAC9C,YAAY,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAA;AACpD,OAAO,EAAE,aAAa,EAAE,qBAAqB,EAAE,MAAM,uBAAuB,CAAA;AAC5E,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAA"}
|
package/build/exports.js
CHANGED
|
@@ -1,16 +1,19 @@
|
|
|
1
1
|
export { config } from '@owlmeans/server-context';
|
|
2
|
+
export { makeContext } from './context.js';
|
|
3
|
+
export { main } from './main.js';
|
|
2
4
|
export { sservice } from '@owlmeans/server-config';
|
|
3
5
|
export { addWebService } from '@owlmeans/client-config';
|
|
4
6
|
export { service, toConfigRecord, PLUGINS } from '@owlmeans/config';
|
|
5
|
-
export {
|
|
7
|
+
export { contract, protocol, typed, EntrypointOutcome } from '@owlmeans/entrypoint';
|
|
6
8
|
export { createListSchema, filterObject } from '@owlmeans/resource';
|
|
7
|
-
export { AppType, BASE,
|
|
8
|
-
export {
|
|
9
|
-
export { elevate as celevate } from '@owlmeans/client-entrypoint';
|
|
9
|
+
export { AppType, BASE, assertContext } from '@owlmeans/context';
|
|
10
|
+
export { bind, bindAll } from '@owlmeans/server-entrypoint';
|
|
10
11
|
export { route as broute } from '@owlmeans/server-route';
|
|
11
|
-
export {
|
|
12
|
+
export { handlers, holdApiPort } from '@owlmeans/server-api';
|
|
13
|
+
export { handleIntermediate, handleBody, handleRequest, handleParams } from '@owlmeans/server-api';
|
|
12
14
|
export { route } from '@owlmeans/route';
|
|
13
15
|
export { DEFAULT_ALIAS as DAUTH_GUARD } from '@owlmeans/server-auth';
|
|
14
16
|
export { klusterize } from '@owlmeans/kluster';
|
|
15
17
|
export { GUARD_ED25519, BED255_CASHE_RESOURCE } from '@owlmeans/auth-common';
|
|
18
|
+
export { entrypoints } from './entrypoints.js';
|
|
16
19
|
//# sourceMappingURL=exports.js.map
|
package/build/exports.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"exports.js","sourceRoot":"","sources":["../src/exports.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,0BAA0B,CAAA;AACjD,OAAO,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAA;AAClD,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAA;AACvD,OAAO,EAAE,OAAO,EAAE,cAAc,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAA;AACnE,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"exports.js","sourceRoot":"","sources":["../src/exports.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,0BAA0B,CAAA;AACjD,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAA;AAC1C,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AAEhC,OAAO,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAA;AAClD,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAA;AACvD,OAAO,EAAE,OAAO,EAAE,cAAc,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAA;AACnE,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,KAAK,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAA;AAEnF,OAAO,EAAE,gBAAgB,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAA;AAEnE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAA;AAChE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,6BAA6B,CAAA;AAC3D,OAAO,EAAE,KAAK,IAAI,MAAM,EAAE,MAAM,wBAAwB,CAAA;AACxD,OAAO,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAA;AAC5D,OAAO,EAAE,kBAAkB,EAAE,UAAU,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAA;AAGlG,OAAO,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAA;AACvC,OAAO,EAAE,aAAa,IAAI,WAAW,EAAE,MAAM,uBAAuB,CAAA;AACpE,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAA;AAE9C,OAAO,EAAE,aAAa,EAAE,qBAAqB,EAAE,MAAM,uBAAuB,CAAA;AAC5E,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAA"}
|
package/build/index.d.ts
CHANGED
package/build/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,cAAc,cAAc,CAAA;AAC5B,cAAc,WAAW,CAAA;AACzB,mBAAmB,YAAY,CAAA;AAC/B,cAAc,cAAc,CAAA;AAC5B,cAAc,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,cAAc,cAAc,CAAA;AAC5B,cAAc,WAAW,CAAA;AACzB,mBAAmB,YAAY,CAAA;AAC/B,cAAc,cAAc,CAAA;AAC5B,cAAc,kBAAkB,CAAA"}
|
package/build/index.js
CHANGED
package/build/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,cAAc,cAAc,CAAA;AAC5B,cAAc,WAAW,CAAA;AAEzB,cAAc,cAAc,CAAA;AAC5B,cAAc,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,cAAc,cAAc,CAAA;AAC5B,cAAc,WAAW,CAAA;AAEzB,cAAc,cAAc,CAAA;AAC5B,cAAc,kBAAkB,CAAA"}
|
package/build/main.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { ServerEntrypoint } from '@owlmeans/server-entrypoint';
|
|
2
2
|
import type { CommonEntrypoint } from '@owlmeans/entrypoint';
|
|
3
3
|
import type { AppContext, AppConfig } from './types.js';
|
|
4
|
-
export declare const main: <R, C extends AppConfig, T extends AppContext<C>>(ctx: T,
|
|
4
|
+
export declare const main: <R, C extends AppConfig, T extends AppContext<C>>(ctx: T, entrypoints: (CommonEntrypoint | ServerEntrypoint<R>)[]) => Promise<void>;
|
|
5
5
|
//# sourceMappingURL=main.d.ts.map
|
package/build/main.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"main.d.ts","sourceRoot":"","sources":["../src/main.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAA;AACnE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAA;AAC5D,OAAO,KAAK,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,YAAY,CAAA;AAIvD,eAAO,MAAM,IAAI,GAAU,CAAC,EAAE,CAAC,SAAS,SAAS,EAAE,CAAC,SAAS,UAAU,CAAC,CAAC,CAAC,OACnE,CAAC,
|
|
1
|
+
{"version":3,"file":"main.d.ts","sourceRoot":"","sources":["../src/main.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAA;AACnE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAA;AAC5D,OAAO,KAAK,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,YAAY,CAAA;AAIvD,eAAO,MAAM,IAAI,GAAU,CAAC,EAAE,CAAC,SAAS,SAAS,EAAE,CAAC,SAAS,UAAU,CAAC,CAAC,CAAC,OACnE,CAAC,eAAe,CAAC,gBAAgB,GAAG,gBAAgB,CAAC,CAAC,CAAC,CAAC,EAAE,kBAKhE,CAAA"}
|
package/build/main.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// @TODO Remove or refactor request types. We actually don't use them and this make
|
|
2
2
|
// a mess with <R
|
|
3
|
-
export const main = async (ctx,
|
|
4
|
-
ctx.registerEntrypoints(
|
|
3
|
+
export const main = async (ctx, entrypoints) => {
|
|
4
|
+
ctx.registerEntrypoints(entrypoints);
|
|
5
5
|
await ctx.configure().init();
|
|
6
6
|
await ctx.getApiServer().listen();
|
|
7
7
|
};
|
package/build/main.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"main.js","sourceRoot":"","sources":["../src/main.ts"],"names":[],"mappings":"AAMA,mFAAmF;AACnF,iBAAiB;AACjB,MAAM,CAAC,MAAM,IAAI,GAAG,KAAK,EACvB,GAAM,EAAE,
|
|
1
|
+
{"version":3,"file":"main.js","sourceRoot":"","sources":["../src/main.ts"],"names":[],"mappings":"AAMA,mFAAmF;AACnF,iBAAiB;AACjB,MAAM,CAAC,MAAM,IAAI,GAAG,KAAK,EACvB,GAAM,EAAE,WAAuD,EAC/D,EAAE;IACF,GAAG,CAAC,mBAAmB,CAAC,WAAW,CAAC,CAAA;IACpC,MAAM,GAAG,CAAC,SAAS,EAAE,CAAC,IAAI,EAAE,CAAA;IAC5B,MAAM,GAAG,CAAC,YAAY,EAAE,CAAC,MAAM,EAAE,CAAA;AACnC,CAAC,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@owlmeans/server-app",
|
|
3
|
-
"version": "0.1.18-rc.
|
|
3
|
+
"version": "0.1.18-rc.41",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"scripts": {
|
|
@@ -21,21 +21,21 @@
|
|
|
21
21
|
}
|
|
22
22
|
},
|
|
23
23
|
"dependencies": {
|
|
24
|
-
"@owlmeans/api": "^0.1.18-rc.
|
|
25
|
-
"@owlmeans/client-config": "^0.1.18-rc.
|
|
26
|
-
"@owlmeans/client-entrypoint": "^0.1.18-rc.
|
|
27
|
-
"@owlmeans/config": "^0.1.18-rc.
|
|
28
|
-
"@owlmeans/context": "^0.1.18-rc.
|
|
29
|
-
"@owlmeans/kluster": "^0.1.18-rc.
|
|
30
|
-
"@owlmeans/entrypoint": "^0.1.18-rc.
|
|
31
|
-
"@owlmeans/route": "^0.1.18-rc.
|
|
32
|
-
"@owlmeans/server-api": "^0.1.18-rc.
|
|
33
|
-
"@owlmeans/server-auth": "^0.1.18-rc.
|
|
34
|
-
"@owlmeans/server-context": "^0.1.18-rc.
|
|
35
|
-
"@owlmeans/server-entrypoint": "^0.1.18-rc.
|
|
36
|
-
"@owlmeans/server-route": "^0.1.18-rc.
|
|
37
|
-
"@owlmeans/server-socket": "^0.1.18-rc.
|
|
38
|
-
"@owlmeans/static-resource": "^0.1.18-rc.
|
|
24
|
+
"@owlmeans/api": "^0.1.18-rc.36",
|
|
25
|
+
"@owlmeans/client-config": "^0.1.18-rc.36",
|
|
26
|
+
"@owlmeans/client-entrypoint": "^0.1.18-rc.36",
|
|
27
|
+
"@owlmeans/config": "^0.1.18-rc.36",
|
|
28
|
+
"@owlmeans/context": "^0.1.18-rc.32",
|
|
29
|
+
"@owlmeans/kluster": "^0.1.18-rc.35",
|
|
30
|
+
"@owlmeans/entrypoint": "^0.1.18-rc.35",
|
|
31
|
+
"@owlmeans/route": "^0.1.18-rc.33",
|
|
32
|
+
"@owlmeans/server-api": "^0.1.18-rc.40",
|
|
33
|
+
"@owlmeans/server-auth": "^0.1.18-rc.43",
|
|
34
|
+
"@owlmeans/server-context": "^0.1.18-rc.35",
|
|
35
|
+
"@owlmeans/server-entrypoint": "^0.1.18-rc.34",
|
|
36
|
+
"@owlmeans/server-route": "^0.1.18-rc.32",
|
|
37
|
+
"@owlmeans/server-socket": "^0.1.18-rc.43",
|
|
38
|
+
"@owlmeans/static-resource": "^0.1.18-rc.33"
|
|
39
39
|
},
|
|
40
40
|
"devDependencies": {
|
|
41
41
|
"@owlmeans/dep-config": "workspace:*",
|
package/src/context.ts
CHANGED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { entrypoints as apiConfigBindings } from '@owlmeans/api-config-server'
|
|
2
|
+
import { entrypoints as authBindings } from '@owlmeans/server-auth'
|
|
3
|
+
|
|
4
|
+
/** Framework server entrypoints every application receives. */
|
|
5
|
+
export const entrypoints = [...authBindings, ...apiConfigBindings]
|
package/src/exports.ts
CHANGED
|
@@ -1,21 +1,25 @@
|
|
|
1
1
|
|
|
2
2
|
export { config } from '@owlmeans/server-context'
|
|
3
|
+
export { makeContext } from './context.js'
|
|
4
|
+
export { main } from './main.js'
|
|
5
|
+
export type { AppConfig, AppContext } from './types.js'
|
|
3
6
|
export { sservice } from '@owlmeans/server-config'
|
|
4
7
|
export { addWebService } from '@owlmeans/client-config'
|
|
5
8
|
export { service, toConfigRecord, PLUGINS } from '@owlmeans/config'
|
|
6
|
-
export {
|
|
9
|
+
export { contract, protocol, typed, EntrypointOutcome } from '@owlmeans/entrypoint'
|
|
7
10
|
export type { AbstractRequest as Request, AbstractResponse as Response } from '@owlmeans/entrypoint'
|
|
8
11
|
export { createListSchema, filterObject } from '@owlmeans/resource'
|
|
9
|
-
export type { ListResult } from '@owlmeans/resource'
|
|
10
|
-
export { AppType, BASE,
|
|
11
|
-
export {
|
|
12
|
-
export { elevate as celevate } from '@owlmeans/client-entrypoint'
|
|
13
|
-
export type { ServerEntrypoint as Module, RefedEntrypointHandler } from '@owlmeans/server-entrypoint'
|
|
14
|
-
export type { ClientEntrypoint } from '@owlmeans/client-entrypoint'
|
|
12
|
+
export type { Criteria, ListOptions, ListQuery, ListResult, Sort } from '@owlmeans/resource'
|
|
13
|
+
export { AppType, BASE, assertContext } from '@owlmeans/context'
|
|
14
|
+
export { bind, bindAll } from '@owlmeans/server-entrypoint'
|
|
15
15
|
export { route as broute } from '@owlmeans/server-route'
|
|
16
|
-
export {
|
|
16
|
+
export { handlers, holdApiPort } from '@owlmeans/server-api'
|
|
17
|
+
export { handleIntermediate, handleBody, handleRequest, handleParams } from '@owlmeans/server-api'
|
|
18
|
+
export type { ApiPortHold, ApiPortHoldOptions } from '@owlmeans/server-api'
|
|
19
|
+
export type { ClientEntrypoint } from '@owlmeans/client-entrypoint'
|
|
17
20
|
export { route } from '@owlmeans/route'
|
|
18
21
|
export { DEFAULT_ALIAS as DAUTH_GUARD } from '@owlmeans/server-auth'
|
|
19
22
|
export { klusterize } from '@owlmeans/kluster'
|
|
20
23
|
export type { PluginConfig } from '@owlmeans/config'
|
|
21
24
|
export { GUARD_ED25519, BED255_CASHE_RESOURCE } from '@owlmeans/auth-common'
|
|
25
|
+
export { entrypoints } from './entrypoints.js'
|
package/src/index.ts
CHANGED
package/src/main.ts
CHANGED
|
@@ -7,9 +7,9 @@ import type { AppContext, AppConfig } from './types.js'
|
|
|
7
7
|
// @TODO Remove or refactor request types. We actually don't use them and this make
|
|
8
8
|
// a mess with <R
|
|
9
9
|
export const main = async <R, C extends AppConfig, T extends AppContext<C>>(
|
|
10
|
-
ctx: T,
|
|
10
|
+
ctx: T, entrypoints: (CommonEntrypoint | ServerEntrypoint<R>)[]
|
|
11
11
|
) => {
|
|
12
|
-
ctx.registerEntrypoints(
|
|
12
|
+
ctx.registerEntrypoints(entrypoints)
|
|
13
13
|
await ctx.configure().init()
|
|
14
14
|
await ctx.getApiServer().listen()
|
|
15
15
|
}
|
package/build/.gitkeep
DELETED
|
File without changes
|
package/build/modules.d.ts
DELETED
package/build/modules.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"modules.d.ts","sourceRoot":"","sources":["../src/modules.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,OAAO,mEAA0B,CAAA"}
|
package/build/modules.js
DELETED
package/build/modules.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"modules.js","sourceRoot":"","sources":["../src/modules.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,SAAS,EAAE,MAAM,6BAA6B,CAAA;AAClE,OAAO,EAAE,OAAO,IAAI,IAAI,EAAE,MAAM,uBAAuB,CAAA;AAEvD,MAAM,CAAC,MAAM,OAAO,GAAG,CAAC,GAAG,IAAI,EAAE,GAAG,SAAS,CAAC,CAAA"}
|
package/src/modules.ts
DELETED