everything-dev 1.50.0 → 1.51.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli/parse.cjs +4 -1
- package/dist/cli/parse.cjs.map +1 -1
- package/dist/cli/parse.mjs +4 -1
- package/dist/cli/parse.mjs.map +1 -1
- package/dist/cli/sync.cjs +16 -1
- package/dist/cli/sync.cjs.map +1 -1
- package/dist/cli/sync.mjs +16 -1
- package/dist/cli/sync.mjs.map +1 -1
- package/dist/cli/upgrade.cjs +51 -1
- package/dist/cli/upgrade.cjs.map +1 -1
- package/dist/cli/upgrade.mjs +51 -1
- package/dist/cli/upgrade.mjs.map +1 -1
- package/dist/config.cjs +8 -4
- package/dist/config.cjs.map +1 -1
- package/dist/config.d.cts.map +1 -1
- package/dist/config.d.mts.map +1 -1
- package/dist/config.mjs +8 -4
- package/dist/config.mjs.map +1 -1
- package/dist/contract.d.cts +16 -16
- package/dist/contract.d.mts +16 -16
- package/dist/infra/planner.cjs +7 -0
- package/dist/infra/planner.cjs.map +1 -1
- package/dist/infra/planner.mjs +7 -0
- package/dist/infra/planner.mjs.map +1 -1
- package/dist/plugin.cjs +7 -7
- package/dist/plugin.cjs.map +1 -1
- package/dist/plugin.d.cts +7 -7
- package/dist/plugin.d.mts +7 -7
- package/dist/plugin.mjs +7 -7
- package/dist/plugin.mjs.map +1 -1
- package/dist/types.d.cts +2 -2
- package/dist/types.d.mts +2 -2
- package/package.json +2 -2
- package/skills/api-and-auth/SKILL.md +38 -16
- package/skills/plugin-development/SKILL.md +8 -4
|
@@ -17,17 +17,22 @@ export default createPlugin.withPlugins<PluginsClient>()({
|
|
|
17
17
|
secrets: z.object({ /* typed env vars, defaults for dev */ }),
|
|
18
18
|
context: z.object({ /* per-request context injected by host */ }),
|
|
19
19
|
contract,
|
|
20
|
-
initialize: (config, plugins
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
20
|
+
initialize: (config, plugins, tools) =>
|
|
21
|
+
Effect.gen(function* () {
|
|
22
|
+
const registry = yield* tools.buildService(
|
|
23
|
+
RegistryTag,
|
|
24
|
+
RegistryLive.pipe(Layer.provide(DatabaseLive(config.secrets.API_DATABASE_URL))),
|
|
25
|
+
);
|
|
26
|
+
return { registry, publisher, auth: plugins.auth, plugins };
|
|
27
|
+
}),
|
|
28
|
+
shutdown: (deps) => Effect.promise(async () => { /* cleanup */ }),
|
|
29
|
+
createRouter: (deps, builder) => ({
|
|
25
30
|
ping: builder.ping.handler(async () => ({ status: "ok", timestamp })),
|
|
26
31
|
}),
|
|
27
32
|
});
|
|
28
33
|
```
|
|
29
34
|
|
|
30
|
-
Fields: `variables` (public config), `secrets` (private env), `context` (per-request host context), `contract` (oRPC router), `initialize` (startup, returns services), `createRouter` (maps procedures to handlers), `shutdown` (cleanup). `plugins` in `initialize` gives typed factories for all other plugins.
|
|
35
|
+
Fields: `variables` (public config), `secrets` (private env), `context` (per-request host context), `contract` (oRPC router), `initialize` (startup, returns services; third arg `tools` for scoped resources), `createRouter` (maps procedures to handlers), `shutdown` (cleanup). `plugins` in `initialize` gives typed factories for all other plugins. Use `tools.buildService(tag, layer)` for DB-backed services, caches, and other scoped resources.
|
|
31
36
|
|
|
32
37
|
## oRPC Contract Design
|
|
33
38
|
|
|
@@ -193,10 +198,11 @@ export function buildPluginContext(c) {
|
|
|
193
198
|
The API plugin receives `auth` in `initialize`:
|
|
194
199
|
|
|
195
200
|
```ts
|
|
196
|
-
initialize: (config, plugins
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
}
|
|
201
|
+
initialize: (config, plugins, _tools) =>
|
|
202
|
+
Effect.gen(function* () {
|
|
203
|
+
const { auth, ...restPlugins } = plugins;
|
|
204
|
+
return { auth, plugins: restPlugins, ... };
|
|
205
|
+
})
|
|
200
206
|
```
|
|
201
207
|
|
|
202
208
|
Use `getAuthClient()` for in-process calls:
|
|
@@ -279,11 +285,12 @@ const baseApi = await loadPluginEntry(runtime, apiEntry, integrityRegistry, plug
|
|
|
279
285
|
The API plugin receives `plugins` in `initialize`:
|
|
280
286
|
|
|
281
287
|
```ts
|
|
282
|
-
initialize: (config, plugins
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
}
|
|
288
|
+
initialize: (config, plugins, _tools) =>
|
|
289
|
+
Effect.gen(function* () {
|
|
290
|
+
const authClient = plugins.auth({ reqHeaders: someHeaders });
|
|
291
|
+
const session = await authClient.getSession();
|
|
292
|
+
return { auth: plugins.auth, plugins, ... };
|
|
293
|
+
})
|
|
287
294
|
```
|
|
288
295
|
|
|
289
296
|
### API-Owned Registry Pattern
|
|
@@ -309,7 +316,22 @@ import { runEffect } from "@/lib/context";
|
|
|
309
316
|
const result = await runEffect(services.myService.doSomething(input));
|
|
310
317
|
```
|
|
311
318
|
|
|
312
|
-
Best practices: Keep service interfaces Effect-native, bridge to async only at the handler boundary via `runEffect()`. Use `Context.Tag` for DI between services.
|
|
319
|
+
Best practices: Keep service interfaces Effect-native, bridge to async only at the handler boundary via `runEffect()`. Use `Context.Tag` for DI between services.
|
|
320
|
+
|
|
321
|
+
**Scoped resources** — For DB pools, caches, publishers, or any resource that must live for the plugin's lifetime, build them inside `initialize` using `tools.buildService(tag, layer)`. This binds the resource to the plugin lifecycle scope — it persists until plugin shutdown and is automatically released.
|
|
322
|
+
|
|
323
|
+
```ts
|
|
324
|
+
initialize: (config, plugins, tools) =>
|
|
325
|
+
Effect.gen(function* () {
|
|
326
|
+
const repo = yield* tools.buildService(
|
|
327
|
+
MyRepoTag,
|
|
328
|
+
MyRepoLive.pipe(Layer.provide(DatabaseLive(config.secrets.MY_DATABASE_URL))),
|
|
329
|
+
);
|
|
330
|
+
return { repo, plugins };
|
|
331
|
+
}),
|
|
332
|
+
```
|
|
333
|
+
|
|
334
|
+
Do **not** use `Effect.provide(Tag, Layer.scoped(...))` inside `initialize` for long-lived resources — it creates a transient scope that closes immediately. `tools.buildService(...)` uses the plugin's lifecycle scope instead.
|
|
313
335
|
|
|
314
336
|
### SSR Proxy Client
|
|
315
337
|
|
|
@@ -159,20 +159,23 @@ export default createPlugin.withPlugins<PluginsClient>()({
|
|
|
159
159
|
|
|
160
160
|
contract,
|
|
161
161
|
|
|
162
|
-
initialize: (config) =>
|
|
162
|
+
initialize: (config, _plugins, tools) =>
|
|
163
163
|
Effect.gen(function* () {
|
|
164
164
|
const service = new TemplateService(config.variables.baseUrl, config.secrets.apiKey, config.variables.timeout);
|
|
165
165
|
yield* service.ping(); // health check on startup
|
|
166
166
|
|
|
167
167
|
const publisher = new MemoryPublisher({ resumeRetentionSeconds: 120 });
|
|
168
168
|
|
|
169
|
+
// For scoped resources (DB pools, caches, repositories):
|
|
170
|
+
// const repo = yield* tools.buildService(MyRepoTag, MyRepoLive.pipe(...))
|
|
171
|
+
|
|
169
172
|
return { service, publisher };
|
|
170
173
|
}),
|
|
171
174
|
|
|
172
175
|
shutdown: () => Effect.void,
|
|
173
176
|
|
|
174
|
-
createRouter: (
|
|
175
|
-
const { service, publisher } =
|
|
177
|
+
createRouter: (deps, builder) => {
|
|
178
|
+
const { service, publisher } = deps;
|
|
176
179
|
const requireAuth = builder.middleware(async ({ context, next }) => {
|
|
177
180
|
if (!context.userId) throw new ORPCError("UNAUTHORIZED", { message: "User ID required" });
|
|
178
181
|
return next({ context: { ...context, userId: context.userId } });
|
|
@@ -236,7 +239,8 @@ Good practice:
|
|
|
236
239
|
**`variables`** — Public config exposed in `bos.config.json` (typed, with defaults).
|
|
237
240
|
**`secrets`** — Private values from `process.env` (typed, dev defaults).
|
|
238
241
|
**`context`** — Per-request context injected by the host. See "Request Context Reference" below for all available fields.
|
|
239
|
-
**`initialize`** — Effect-based startup. Create services, publishers, DB connections. Return value is passed as `
|
|
242
|
+
**`initialize`** — Effect-based startup. Create services, publishers, DB connections. Receives an optional third argument `tools` for building scoped resources. Return value is passed as `deps` to `createRouter`.
|
|
243
|
+
**`tools`** — Framework-provided third argument in `initialize(config, plugins, tools)`. Use `tools.buildService(tag, layer)` to build scoped resources (DB pools, caches, repositories) that live for the plugin's lifetime.
|
|
240
244
|
**`createRouter`** — Maps contract procedures to handlers. Receives the value returned by `initialize` plus a pre-configured `builder`.
|
|
241
245
|
|
|
242
246
|
## Request Context Reference
|