@mauroandre/velojs 0.0.56 → 0.0.58
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 +126 -26
- package/agent/AGENTS.md +86 -17
- package/agent/skills/velojs-live-loader/SKILL.md +108 -25
- package/agent/skills/velojs-production-deploy/SKILL.md +7 -1
- package/dist/channels.d.ts +109 -28
- package/dist/channels.js +285 -192
- package/dist/client.js +8 -7
- package/dist/live-loader.d.ts +40 -7
- package/dist/live-loader.js +91 -81
- package/dist/server.d.ts +1 -1
- package/dist/server.js +94 -92
- package/dist/testing/index.d.ts +1 -1
- package/dist/testing/index.js +231 -228
- package/dist/testing/types.d.ts +21 -4
- package/package.json +1 -1
package/dist/testing/types.d.ts
CHANGED
|
@@ -95,6 +95,18 @@ export interface SubscribeOptions extends RequestOptions {
|
|
|
95
95
|
/** Channel ID — sent as `?channel=...`. */
|
|
96
96
|
channel?: string;
|
|
97
97
|
}
|
|
98
|
+
/**
|
|
99
|
+
* Options of a live-loader channel connection.
|
|
100
|
+
*
|
|
101
|
+
* `params` are the route params the connection declares — the same ones the
|
|
102
|
+
* browser extracts from the URL and sends in `?_route=`. The server-side
|
|
103
|
+
* validation of the declared path runs for real: a key the module's path does
|
|
104
|
+
* not declare rejects the subscription (400), never silently ignores the input.
|
|
105
|
+
*/
|
|
106
|
+
export interface ChannelSubscribeOptions extends SubscribeOptions {
|
|
107
|
+
/** Route params the connection declares (serialized into `?_route=`). */
|
|
108
|
+
params?: Params;
|
|
109
|
+
}
|
|
98
110
|
export interface NextOptions {
|
|
99
111
|
/** Reject if no event arrives within this many ms. */
|
|
100
112
|
timeoutMs: number;
|
|
@@ -219,23 +231,28 @@ export interface TestApp {
|
|
|
219
231
|
* read) or a moduleId string. Cookies (and therefore the principal) come
|
|
220
232
|
* from the options or from `app.as(user)`; the route node's middlewares run
|
|
221
233
|
* for real, so an unauthenticated subscription is denied exactly as in
|
|
222
|
-
* production.
|
|
234
|
+
* production. `params` are the route params the connection declares — the
|
|
235
|
+
* server validates their keys against the module's path.
|
|
223
236
|
*
|
|
224
237
|
* ```ts
|
|
225
238
|
* const sub = await app.as({ id: 7 }).channel(Expenses, "teamExpenses");
|
|
226
239
|
* await sub.next({ timeoutMs: 1000 }); // snapshot on connect
|
|
227
|
-
* await emit("teamExpenses", { teamId: 7 });
|
|
240
|
+
* await emit("teamExpenses", { user: { teamId: 7 } });
|
|
228
241
|
* expect(await sub.next({ timeoutMs: 1000 })).toEqual({ teamTotal: 2 });
|
|
229
242
|
*
|
|
243
|
+
* // A route with `:params`: the connection declares them and the loader
|
|
244
|
+
* // re-executes with them.
|
|
245
|
+
* const project = await app.channel(Project, "projectFiles", { params: { id: "7" } });
|
|
246
|
+
*
|
|
230
247
|
* // The same arrivals discriminated: nextEvent() tells a snapshot from a slice.
|
|
231
|
-
* await emit(Expenses, "teamExpenses", { teamId: 7 }, { teamTotal: 880 });
|
|
248
|
+
* await emit(Expenses, "teamExpenses", { user: { teamId: 7 } }, { teamTotal: 880 });
|
|
232
249
|
* expect(await sub.nextEvent({ timeoutMs: 1000 })).toEqual({
|
|
233
250
|
* type: "slice",
|
|
234
251
|
* data: { teamTotal: 880 },
|
|
235
252
|
* });
|
|
236
253
|
* ```
|
|
237
254
|
*/
|
|
238
|
-
channel<T = any>(module: ChannelModuleRef, name: string, opts?:
|
|
255
|
+
channel<T = any>(module: ChannelModuleRef, name: string, opts?: ChannelSubscribeOptions): Promise<TestChannelSubscription<T>>;
|
|
239
256
|
/**
|
|
240
257
|
* Open an in-memory session against a `socket_*` handler.
|
|
241
258
|
*
|