@arcote.tech/arc-chat 0.5.6 → 0.5.7

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/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@arcote.tech/arc-chat",
3
3
  "type": "module",
4
- "version": "0.5.6",
4
+ "version": "0.5.7",
5
5
  "private": false,
6
6
  "description": "Chat module with AI integration for Arc framework",
7
7
  "main": "./src/index.ts",
@@ -10,11 +10,11 @@
10
10
  "type-check": "tsc --noEmit"
11
11
  },
12
12
  "peerDependencies": {
13
- "@arcote.tech/arc": "^0.5.6",
14
- "@arcote.tech/arc-ai": "^0.5.6",
15
- "@arcote.tech/arc-auth": "^0.5.6",
16
- "@arcote.tech/arc-ds": "^0.5.6",
17
- "@arcote.tech/platform": "^0.5.6",
13
+ "@arcote.tech/arc": "^0.5.7",
14
+ "@arcote.tech/arc-ai": "^0.5.7",
15
+ "@arcote.tech/arc-auth": "^0.5.7",
16
+ "@arcote.tech/arc-ds": "^0.5.7",
17
+ "@arcote.tech/platform": "^0.5.7",
18
18
  "lucide-react": ">=0.400.0",
19
19
  "react": ">=18.0.0",
20
20
  "typescript": "^5.0.0"
@@ -12,7 +12,7 @@ import type { AccountId, Token } from "@arcote.tech/arc-auth";
12
12
  import type { AIConfig, ArcToolAny } from "@arcote.tech/arc-ai";
13
13
  import { tool as createToolFactory } from "@arcote.tech/arc-ai";
14
14
  import type { ArcTokenAny } from "@arcote.tech/arc";
15
- import type { FnProtection, FnProtectionCheck } from "@arcote.tech/arc";
15
+ import type { ViewProtectionFn } from "@arcote.tech/arc";
16
16
  import { createMessageId, createMessageAggregate } from "./aggregates/message";
17
17
  import { createAiGenerationListener, createAiResumeListener } from "./listeners/ai-generation-listener";
18
18
  import { createChatStreamRoute } from "./routes/chat-stream-route";
@@ -105,7 +105,17 @@ export class ArcChat<const Data extends ArcChatData = DefaultChatData> {
105
105
  } as any);
106
106
  }
107
107
 
108
- protectBy<T extends ArcTokenAny>(token: T, check: FnProtectionCheck<T>) {
108
+ /**
109
+ * Restrict chat access by token + read filter on token params.
110
+ *
111
+ * The callback receives **raw token params** (not a `TokenInstance`),
112
+ * mirroring `aggregate.protectBy` semantics — the chat's underlying
113
+ * Message aggregate is filtered by the returned WHERE clause. This
114
+ * matches the runtime behaviour in `build()` below where
115
+ * `protectByCheck` is forwarded directly into the message aggregate's
116
+ * view protection.
117
+ */
118
+ protectBy<T extends ArcTokenAny>(token: T, check: ViewProtectionFn<T>) {
109
119
  return new ArcChat<Merge<Data, { protectBy: T; protectByCheck: typeof check }>>({
110
120
  ...this.data,
111
121
  protectBy: token,