akanjs 3.2.0-rc.21 → 3.2.0-rc.22

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/CHANGELOG.md CHANGED
@@ -80,7 +80,7 @@
80
80
  - **MCP Apps.** A rendered view may still call an `mcp: "agent"` entry, as it may call an `mcp: false` one.
81
81
  - **Types.** `McpShelf` (`boolean | "agent"`) and `narrowestMcpShelf` are new in `akanjs/common`. `SerializedSignalShelf` is new in `akanjs/signal`. `McpDocumentOptions` and `McpExposureOption` gain `agent`.
82
82
 
83
- Upgrade: code that reads `SliceCls.mcp`, a serialized endpoint's `mcp` or a serialized signal's `mcp` map as a boolean must now compare it with `false` or `true`. `"agent"` is truthy, and it means "not on `/mcp`". Code that only declares `mcp: false` or `mcp: true` needs no change.
83
+ Upgrade: code that reads `mcp` (an endpoint's `signalOption.mcp`, `SliceCls.mcp`, a serialized endpoint's `mcp` or a serialized signal's `mcp` map) to decide whether an entry is on `/mcp` must test for listed, `(mcp ?? true) === true`. A check of `mcp !== false`, or a truthiness test, now lets `"agent"` through as listed. A workspace's copied `libs/shared` `AccountMiddleware` had exactly that check, which let an MCP client's OAuth token reach an `mcp: "agent"` endpoint over HTTP, so port its fix. Code that only declares `mcp: false` or `mcp: true` needs no change.
84
84
 
85
85
  - eb88032: A service can now run the `/mcp` tool catalogue in-process, as a given account, with `plug(AgentToolsRole)`.
86
86
 
@@ -251,6 +251,10 @@
251
251
  - **The `akan-service` skill** carries a recipe for pages backed by an external HTTP API: an `adapt()` adapter in `srvkit/` that reads its base URL at boot, a `lib/_<service>` service, a `Public` `query(Any, { nullable: true })` endpoint and its dictionary label, and the page that calls it.
252
252
  - **The README's "Inside an existing repository"** runs the creator through `npx -y bun@1.4.4 x …` on a host with only Node and npm, so nothing global is written. It also gives copy-ready `build` and `start` scripts, says a fresh clone builds without a committed env file, and says which environment a `.env`-less build is for and what a deployed host sets instead.
253
253
 
254
+ - cc59b93: A slice's per-verb `mcp` value now reaches the endpoints it generates. `mcp: { cru: false }` or `mcp: { get: "agent" }` used to be read only where `/mcp` builds its listing. Each generated `get`, `create`, `update` and `remove` endpoint now carries its own verb's value in its `signalOption.mcp`, as a slice's list already did. This lets server code that reads `signalOption.mcp`, such as `libs/shared`'s `AccountMiddleware`, refuse an MCP client's OAuth token there over HTTP as well.
255
+
256
+ `libs/shared`'s `AccountMiddleware` now refuses such a token at an `mcp: "agent"` endpoint, as it does at an `mcp: false` one. A workspace that copied `libs/shared` should port the one-line check in `srvkit/accountMiddleware.ts` (`(signalOption?.mcp ?? true) === true`).
257
+
254
258
  - 61fbd7d: `get_graph` takes `since`, a git revision, and returns the Change Map: the Akan Graph of what changed since HEAD forked from that revision, working tree and untracked files included. Every node, field and edge is marked `added`, `removed` or `changed`. The unchanged nodes a changed one calls, or is called by, stay in as context, and `unmapped` lists the changed files under `apps/` or `libs/` that no node covers, each marked the same way. `since: "HEAD"` maps uncommitted work only. Files `.gitignore` covers stay out, a renamed file reads as removed and added, and a CRLF checkout of an unchanged file reads as unchanged. A revision git does not know returns a `graph-since-unknown` diagnostic, and so does one HEAD shares no commit with (a shallow clone, say) instead of comparing with its tip. A revision that starts with `-` also returns it and never reaches git.
255
259
 
256
260
  - **`AkanGraphDiff.between(base, head)`** in `@akanjs/language` diffs two graphs. `index.graph(readText, { digests: true })` gives each member, query, component and field a hash of its body text, so an edit inside a method, or to a field's options, marks it changed and moving it does not.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "akanjs",
3
- "version": "3.2.0-rc.21",
3
+ "version": "3.2.0-rc.22",
4
4
  "sourceType": "module",
5
5
  "type": "module",
6
6
  "publishConfig": {
@@ -14,7 +14,7 @@ import {
14
14
  type PromiseOrObject,
15
15
  SLICE_META,
16
16
  } from "akanjs/base";
17
- import { capitalize, Logger, modelNames, moduleNames, sliceNames } from "akanjs/common";
17
+ import { capitalize, Logger, moduleNames, sliceNames } from "akanjs/common";
18
18
  import {
19
19
  type ConstantField,
20
20
  deserialize,
@@ -34,7 +34,6 @@ import type {
34
34
  LiveRegistry,
35
35
  WebsocketAdaptor,
36
36
  } from "akanjs/service";
37
- import { ByIdRead } from "../../signal/byIdRead";
38
37
  import { type Endpoint, type EndpointCls, sliceEndpoint } from "../../signal/endpoint";
39
38
  import { EndpointErrorContract } from "../../signal/endpointErrorContract";
40
39
  import type { EndpointInfo } from "../../signal/endpointInfo";
@@ -60,6 +59,7 @@ import type { HttpRoutes, LocalPublish, SignalRoutes, WebsocketRoutes } from "..
60
59
  import { invalidSignal as invalid } from "./invalidSignal";
61
60
  import { LivePause } from "./livePause";
62
61
  import { PendingSubscribes } from "./PendingSubscribes";
62
+ import { SliceCrud } from "./sliceCrud";
63
63
  import { websocketOf } from "./websocketOf";
64
64
 
65
65
  type LiveChangeListener = (doc: unknown, type: unknown, previous?: unknown) => void;
@@ -391,7 +391,6 @@ export class SignalResolver {
391
391
  if (!cnst) throw invalid("Constant is not set for slice");
392
392
  const refName = cnst.refName;
393
393
  const serviceName = moduleNames(refName).service;
394
- const names = modelNames(refName);
395
394
 
396
395
  const assertSliceQuery = (query: unknown, key: string) => {
397
396
  if (Array.isArray(query))
@@ -489,42 +488,7 @@ export class SignalResolver {
489
488
  });
490
489
  });
491
490
 
492
- if (sliceCls.crud.get)
493
- for (const key of [names.model, names.lightModel])
494
- endpointObj[key] = ByIdRead.mark(
495
- refName,
496
- (builder as any)
497
- .query(key === names.model ? cnst.full : cnst.light, { guards: sliceCls.getGuards })
498
- .param(names.modelId, ID)
499
- .exec(async function (this: any, id: string) {
500
- return await this[serviceName][names.getModel](id);
501
- }),
502
- );
503
-
504
- if (sliceCls.crud.create)
505
- endpointObj[names.createModel] = (builder as any)
506
- .mutation(cnst.full, { guards: sliceCls.createGuards })
507
- .body("data", cnst.input)
508
- .exec(async function (this: any, data: any) {
509
- return await this[serviceName].__create(data);
510
- });
511
-
512
- if (sliceCls.crud.update)
513
- endpointObj[names.updateModel] = (builder as any)
514
- .mutation(cnst.full, { guards: sliceCls.updateGuards })
515
- .param(names.modelId, ID)
516
- .body("data", cnst.input)
517
- .exec(async function (this: any, id: string, data: any) {
518
- return await this[serviceName].__update(id, data);
519
- });
520
-
521
- if (sliceCls.crud.remove)
522
- endpointObj[names.removeModel] = (builder as any)
523
- .mutation(cnst.full, { guards: sliceCls.removeGuards })
524
- .param(names.modelId, ID)
525
- .exec(async function (this: any, id: string) {
526
- return await this[serviceName].__remove(id);
527
- });
491
+ Object.assign(endpointObj, SliceCrud.endpoints(builder, sliceCls, cnst));
528
492
  return endpointObj;
529
493
  }) {}
530
494
  return SliceEndpoint;
@@ -0,0 +1,63 @@
1
+ import { ID } from "akanjs/base";
2
+ import { type McpShelf, modelNames, moduleNames } from "akanjs/common";
3
+ import { ByIdRead } from "../../signal/byIdRead";
4
+ import type { EndpointInfo } from "../../signal/endpointInfo";
5
+ import type { SliceCls } from "../../signal/slice";
6
+
7
+ export class SliceCrud {
8
+
9
+ static #shelf(mcp: McpShelf) {
10
+ return mcp === true ? {} : { mcp };
11
+ }
12
+
13
+ static endpoints(
14
+ builder: unknown,
15
+ sliceCls: SliceCls,
16
+ cnst: NonNullable<SliceCls["srv"]["cnst"]>,
17
+ ): { [key: string]: EndpointInfo } {
18
+ const refName = cnst.refName;
19
+ const serviceName = moduleNames(refName).service;
20
+ const names = modelNames(refName);
21
+ const endpointObj: { [key: string]: EndpointInfo } = {};
22
+ if (sliceCls.crud.get)
23
+ for (const key of [names.model, names.lightModel])
24
+ endpointObj[key] = ByIdRead.mark(
25
+ refName,
26
+ (builder as any)
27
+ .query(key === names.model ? cnst.full : cnst.light, {
28
+ guards: sliceCls.getGuards,
29
+ ...SliceCrud.#shelf(sliceCls.mcp.get),
30
+ })
31
+ .param(names.modelId, ID)
32
+ .exec(async function (this: any, id: string) {
33
+ return await this[serviceName][names.getModel](id);
34
+ }),
35
+ );
36
+
37
+ if (sliceCls.crud.create)
38
+ endpointObj[names.createModel] = (builder as any)
39
+ .mutation(cnst.full, { guards: sliceCls.createGuards, ...SliceCrud.#shelf(sliceCls.mcp.create) })
40
+ .body("data", cnst.input)
41
+ .exec(async function (this: any, data: any) {
42
+ return await this[serviceName].__create(data);
43
+ });
44
+
45
+ if (sliceCls.crud.update)
46
+ endpointObj[names.updateModel] = (builder as any)
47
+ .mutation(cnst.full, { guards: sliceCls.updateGuards, ...SliceCrud.#shelf(sliceCls.mcp.update) })
48
+ .param(names.modelId, ID)
49
+ .body("data", cnst.input)
50
+ .exec(async function (this: any, id: string, data: any) {
51
+ return await this[serviceName].__update(id, data);
52
+ });
53
+
54
+ if (sliceCls.crud.remove)
55
+ endpointObj[names.removeModel] = (builder as any)
56
+ .mutation(cnst.full, { guards: sliceCls.removeGuards, ...SliceCrud.#shelf(sliceCls.mcp.remove) })
57
+ .param(names.modelId, ID)
58
+ .exec(async function (this: any, id: string) {
59
+ return await this[serviceName].__remove(id);
60
+ });
61
+ return endpointObj;
62
+ }
63
+ }
@@ -0,0 +1,8 @@
1
+ import type { EndpointInfo } from "../../signal/endpointInfo.d.ts";
2
+ import type { SliceCls } from "../../signal/slice.d.ts";
3
+ export declare class SliceCrud {
4
+ #private;
5
+ static endpoints(builder: unknown, sliceCls: SliceCls, cnst: NonNullable<SliceCls["srv"]["cnst"]>): {
6
+ [key: string]: EndpointInfo;
7
+ };
8
+ }