@absolutejs/sync-pack-comments 0.1.0 → 0.3.0
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 +49 -6
- package/dist/index.d.ts +64 -9
- package/dist/index.js +53 -3
- package/dist/index.js.map +3 -3
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -125,12 +125,55 @@ subscribe to `comments` and `presence` separately — it should NOT call
|
|
|
125
125
|
`comments:*` from inside its own handler. See the design doc rules in
|
|
126
126
|
[`syncPacks.design.md`](https://github.com/absolutejs/sync/blob/main/src/engine/syncPacks.design.md).
|
|
127
127
|
|
|
128
|
-
##
|
|
128
|
+
## Optional: `comments-with-author` join collection (0.2+)
|
|
129
|
+
|
|
130
|
+
Set `joinUsers` to additionally register a `comments-with-author` join
|
|
131
|
+
collection that pairs each comment with the host's user row. The pack does
|
|
132
|
+
NOT own the users table; it adds it to `readsTables` so the engine knows
|
|
133
|
+
the dependency and your devtools see the full graph.
|
|
134
|
+
|
|
135
|
+
```ts
|
|
136
|
+
type Author = { id: string; displayName: string; avatarUrl?: string };
|
|
137
|
+
|
|
138
|
+
engine.registerReader('users', { all: () => db.users.list() });
|
|
139
|
+
engine.registerWriter('users', { /* ... */ });
|
|
140
|
+
|
|
141
|
+
engine.registerPack(
|
|
142
|
+
createCommentsPack<MyCtx, Author>({
|
|
143
|
+
canReadResource,
|
|
144
|
+
getActorId,
|
|
145
|
+
joinUsers: {
|
|
146
|
+
// Default 'users'; pass another name if your table differs.
|
|
147
|
+
table: 'users',
|
|
148
|
+
// Default (u) => u.id; override if your user id key isn't `id`.
|
|
149
|
+
// key: (user) => user.userId,
|
|
150
|
+
// Required: host supplies the users-side hydrate.
|
|
151
|
+
hydrate: () => db.users.list(),
|
|
152
|
+
},
|
|
153
|
+
}),
|
|
154
|
+
);
|
|
155
|
+
|
|
156
|
+
// Subscribe with the same params shape as the base collection.
|
|
157
|
+
const subscription = await engine.subscribe<
|
|
158
|
+
CommentRow & { author: Author },
|
|
159
|
+
{ resourceId: string }
|
|
160
|
+
>({
|
|
161
|
+
collection: 'comments-with-author',
|
|
162
|
+
params: { resourceId },
|
|
163
|
+
ctx,
|
|
164
|
+
onDiff: rerender,
|
|
165
|
+
});
|
|
166
|
+
// subscription.initial[0] === { ...comment, author: { id, displayName, ... } }
|
|
167
|
+
```
|
|
168
|
+
|
|
169
|
+
The engine inner-joins on `comment.authorId === user.id`; comments
|
|
170
|
+
whose author is missing from the users table are excluded from the join
|
|
171
|
+
(but still appear in the base `comments` collection). `canReadResource`
|
|
172
|
+
gates the join the same way it gates the base.
|
|
173
|
+
|
|
174
|
+
## Planned for 0.3+
|
|
129
175
|
|
|
130
|
-
- **`comments-with-author` join collection** — a `defineJoinCollection`
|
|
131
|
-
variant that includes display info from the host's user table. The
|
|
132
|
-
pack would `readsTables: [userTable]` and require the host to register
|
|
133
|
-
a reader for it. Deferred until a real consumer wants it, so we don't
|
|
134
|
-
over-engineer the right-side hydrate.
|
|
135
176
|
- **In-thread full-text search** via `registerSearch` on the comments
|
|
136
177
|
table.
|
|
178
|
+
- **Reactions** — a `reactionsTable` config that adds an emoji-reaction
|
|
179
|
+
side table with create/remove/list mutations.
|
package/dist/index.d.ts
CHANGED
|
@@ -2,13 +2,12 @@
|
|
|
2
2
|
* `@absolutejs/sync-pack-comments` — threaded comments on host-side resources
|
|
3
3
|
* as a sync pack.
|
|
4
4
|
*
|
|
5
|
-
* Owns a single `comments` table
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
* `
|
|
10
|
-
*
|
|
11
|
-
* through `registerCrdt` for conflict-free editing.
|
|
5
|
+
* Owns a single `comments` table. Per-resource read access is gated through
|
|
6
|
+
* host-injected `canReadResource(resourceId, ctx)`. Edits are author-only;
|
|
7
|
+
* deletes are author or moderator. Optional `bodyCrdt` config wires the
|
|
8
|
+
* body field through `registerCrdt` for conflict-free editing. Optional
|
|
9
|
+
* `joinUsers` config registers a `comments-with-author` join collection
|
|
10
|
+
* that pairs each comment with the host's user row.
|
|
12
11
|
*
|
|
13
12
|
* @example
|
|
14
13
|
* ```ts
|
|
@@ -62,7 +61,7 @@ export declare class CommentParentMismatchError extends Error {
|
|
|
62
61
|
constructor(parentCommentId: string);
|
|
63
62
|
}
|
|
64
63
|
/** Factory config. `canReadResource` is the only required field. */
|
|
65
|
-
export type CommentsPackConfig<Ctx = CollectionContext> = {
|
|
64
|
+
export type CommentsPackConfig<Ctx = CollectionContext, AuthorRow = unknown> = {
|
|
66
65
|
/**
|
|
67
66
|
* Prefix applied to the owned table name AND every collection/mutation
|
|
68
67
|
* the pack exposes. Default `""`. Use a non-empty prefix when
|
|
@@ -115,9 +114,65 @@ export type CommentsPackConfig<Ctx = CollectionContext> = {
|
|
|
115
114
|
* scheme.
|
|
116
115
|
*/
|
|
117
116
|
newId?: () => string;
|
|
117
|
+
/**
|
|
118
|
+
* When set, the pack additionally registers a `comments-with-author`
|
|
119
|
+
* join collection. The host's user table must have a registered
|
|
120
|
+
* reader/writer (so user-row changes propagate into the join). The
|
|
121
|
+
* pack itself does NOT own the users table; it only `readsTables`
|
|
122
|
+
* the configured name.
|
|
123
|
+
*/
|
|
124
|
+
joinUsers?: JoinUsersConfig<Ctx, AuthorRow>;
|
|
125
|
+
/**
|
|
126
|
+
* When set, register a `comments-search` full-text search collection
|
|
127
|
+
* over the body field. The subscription's `params` is the query string;
|
|
128
|
+
* results are the ranked top-K, re-ranked live as comments are added,
|
|
129
|
+
* edited, or removed. Per-row read permission (which routes through
|
|
130
|
+
* `canReadResource`) still filters hits per caller.
|
|
131
|
+
*/
|
|
132
|
+
search?: {
|
|
133
|
+
topK?: number;
|
|
134
|
+
};
|
|
135
|
+
};
|
|
136
|
+
/**
|
|
137
|
+
* Config for the optional `comments-with-author` join collection.
|
|
138
|
+
*
|
|
139
|
+
* The pack does not own the host's user table. The host supplies the
|
|
140
|
+
* right-side hydrate (typically reading from its registered reader) and
|
|
141
|
+
* the join key. The engine maintains the join incrementally — changes to
|
|
142
|
+
* either side fan in through `engine.applyChange`.
|
|
143
|
+
*/
|
|
144
|
+
export type JoinUsersConfig<Ctx, AuthorRow = unknown> = {
|
|
145
|
+
/**
|
|
146
|
+
* The host's user table name. Surfaced in `readsTables` so the
|
|
147
|
+
* dependency graph is reviewable. Default `"users"`.
|
|
148
|
+
*/
|
|
149
|
+
table?: string;
|
|
150
|
+
/**
|
|
151
|
+
* Get the user's id (the join field). Default `(user) => user.id`.
|
|
152
|
+
*/
|
|
153
|
+
key?: (user: AuthorRow) => string;
|
|
154
|
+
/**
|
|
155
|
+
* Host-side hydrate for the users side of the join. The pack passes
|
|
156
|
+
* the subscription params + ctx; this returns the candidate users.
|
|
157
|
+
* Returning all users (small set) or just the authors referenced by
|
|
158
|
+
* the comments are both fine — the engine inner-joins on `authorId
|
|
159
|
+
* === id` after hydrate.
|
|
160
|
+
*/
|
|
161
|
+
hydrate: (params: {
|
|
162
|
+
resourceId: string;
|
|
163
|
+
}, ctx: Ctx) => Iterable<AuthorRow> | Promise<Iterable<AuthorRow>>;
|
|
164
|
+
};
|
|
165
|
+
/** A joined row emitted by the `comments-with-author` collection. */
|
|
166
|
+
export type CommentWithAuthor<AuthorRow = unknown> = CommentRow & {
|
|
167
|
+
author: AuthorRow;
|
|
118
168
|
};
|
|
119
169
|
/**
|
|
120
170
|
* Build a {@link SyncPack} that exposes threaded comments. Each call returns
|
|
121
171
|
* a fresh pack with its own store (unless a custom `store` is supplied).
|
|
172
|
+
*
|
|
173
|
+
* The `AuthorRow` generic is only consulted by the
|
|
174
|
+
* `comments-with-author` join collection (when `joinUsers` is set); pass
|
|
175
|
+
* it to recover types for the joined output. With no `joinUsers`, default
|
|
176
|
+
* `unknown` is fine.
|
|
122
177
|
*/
|
|
123
|
-
export declare const createCommentsPack: <Ctx = CollectionContext>(config: CommentsPackConfig<Ctx>) => SyncPack;
|
|
178
|
+
export declare const createCommentsPack: <Ctx = CollectionContext, AuthorRow = unknown>(config: CommentsPackConfig<Ctx, AuthorRow>) => SyncPack;
|
package/dist/index.js
CHANGED
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
// @bun
|
|
2
2
|
// src/index.ts
|
|
3
3
|
import {
|
|
4
|
+
createTextIndex,
|
|
4
5
|
defineCollection,
|
|
6
|
+
defineJoinCollection,
|
|
5
7
|
defineMutation,
|
|
6
8
|
defineSchema,
|
|
9
|
+
defineSearchCollection,
|
|
7
10
|
defineSyncPack,
|
|
8
11
|
field,
|
|
9
12
|
UnauthorizedError
|
|
@@ -53,6 +56,7 @@ class CommentParentMismatchError extends Error {
|
|
|
53
56
|
}
|
|
54
57
|
}
|
|
55
58
|
var DEFAULT_MAX_DEPTH = 8;
|
|
59
|
+
var DEFAULT_USER_TABLE = "users";
|
|
56
60
|
var resolveActor = (getActorId, ctx) => {
|
|
57
61
|
const actorId = getActorId(ctx);
|
|
58
62
|
if (actorId === undefined || actorId === "") {
|
|
@@ -74,11 +78,18 @@ var createCommentsPack = (config) => {
|
|
|
74
78
|
const getActorId = config.getActorId ?? ((ctx) => ctx.userId);
|
|
75
79
|
const canReadResource = config.canReadResource;
|
|
76
80
|
const canModerate = config.canModerate ?? (() => false);
|
|
81
|
+
const joinUsers = config.joinUsers;
|
|
82
|
+
const userTable = joinUsers?.table ?? DEFAULT_USER_TABLE;
|
|
83
|
+
const joinCollectionName = `${prefix}comments-with-author`;
|
|
84
|
+
const userKey = joinUsers?.key ?? ((row) => row.id);
|
|
85
|
+
const search = config.search;
|
|
86
|
+
const searchCollectionName = `${prefix}comments-search`;
|
|
87
|
+
const searchTopK = search?.topK ?? 20;
|
|
77
88
|
const pack = {
|
|
78
89
|
name: "@absolutejs/sync-pack-comments",
|
|
79
90
|
ownsTables: [table],
|
|
80
|
-
readsTables: [],
|
|
81
|
-
version: "0.
|
|
91
|
+
readsTables: joinUsers === undefined ? [] : [userTable],
|
|
92
|
+
version: "0.3.0",
|
|
82
93
|
schemas: defineSchema({
|
|
83
94
|
[table]: {
|
|
84
95
|
fields: {
|
|
@@ -204,6 +215,45 @@ var createCommentsPack = (config) => {
|
|
|
204
215
|
if (config.bodyCrdt !== undefined) {
|
|
205
216
|
pack.crdt = { [table]: { body: config.bodyCrdt } };
|
|
206
217
|
}
|
|
218
|
+
if (search !== undefined) {
|
|
219
|
+
pack.searchCollections = [
|
|
220
|
+
defineSearchCollection({
|
|
221
|
+
name: searchCollectionName,
|
|
222
|
+
table,
|
|
223
|
+
index: () => createTextIndex({
|
|
224
|
+
fields: ["body"],
|
|
225
|
+
key: (row) => row.id
|
|
226
|
+
}),
|
|
227
|
+
key: (row) => row.id,
|
|
228
|
+
limit: searchTopK,
|
|
229
|
+
source: () => store.reader.all({})
|
|
230
|
+
})
|
|
231
|
+
];
|
|
232
|
+
}
|
|
233
|
+
if (joinUsers !== undefined) {
|
|
234
|
+
const usersHydrate = joinUsers.hydrate;
|
|
235
|
+
pack.joinCollections = [
|
|
236
|
+
defineJoinCollection({
|
|
237
|
+
name: joinCollectionName,
|
|
238
|
+
key: (out) => out.id,
|
|
239
|
+
left: {
|
|
240
|
+
table,
|
|
241
|
+
hydrate: (params, ctx) => store.reader.all(ctx).filter((row) => row.resourceId === params.resourceId && canReadResource(row.resourceId, ctx)),
|
|
242
|
+
key: (row) => row.id,
|
|
243
|
+
on: (row) => row.authorId,
|
|
244
|
+
match: (row, params, ctx) => row.resourceId === params.resourceId && canReadResource(row.resourceId, ctx)
|
|
245
|
+
},
|
|
246
|
+
right: {
|
|
247
|
+
table: userTable,
|
|
248
|
+
hydrate: (params, ctx) => usersHydrate(params, ctx),
|
|
249
|
+
key: (user) => userKey(user),
|
|
250
|
+
on: (user) => userKey(user)
|
|
251
|
+
},
|
|
252
|
+
select: (comment, author) => ({ ...comment, author }),
|
|
253
|
+
authorize: (params, ctx) => canReadResource(params.resourceId, ctx)
|
|
254
|
+
})
|
|
255
|
+
];
|
|
256
|
+
}
|
|
207
257
|
return defineSyncPack(pack);
|
|
208
258
|
};
|
|
209
259
|
export {
|
|
@@ -213,5 +263,5 @@ export {
|
|
|
213
263
|
CommentDepthExceededError
|
|
214
264
|
};
|
|
215
265
|
|
|
216
|
-
//# debugId=
|
|
266
|
+
//# debugId=04A2B1840A2D711C64756E2164756E21
|
|
217
267
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/index.ts"],
|
|
4
4
|
"sourcesContent": [
|
|
5
|
-
"/**\n * `@absolutejs/sync-pack-comments` — threaded comments on host-side resources\n * as a sync pack.\n *\n * Owns a single `comments` table; reads no host tables of its own (the join\n * to the host's user table is the pack's planned 0.2 feature — for now the\n * `comments` collection emits `authorId` and the client looks up display\n * info). Per-resource read access is gated through host-injected\n * `canReadResource(resourceId, ctx)`. Edits are author-only; deletes are\n * author or moderator. Optional `bodyCrdt` config wires the body field\n * through `registerCrdt` for conflict-free editing.\n *\n * @example\n * ```ts\n * import { createSyncEngine } from '@absolutejs/sync/engine';\n * import { createCommentsPack } from '@absolutejs/sync-pack-comments';\n *\n * const engine = createSyncEngine();\n * engine.registerPack(createCommentsPack({\n * getActorId: (ctx) => ctx.session.userId,\n * canReadResource: (resourceId, ctx) =>\n * hostAcl.canRead(resourceId, ctx.session.userId),\n * maxDepth: 8,\n * }));\n * ```\n */\n\nimport {\n\tdefineCollection,\n\tdefineMutation,\n\tdefineSchema,\n\tdefineSyncPack,\n\tfield,\n\tUnauthorizedError,\n\ttype CollectionContext,\n\ttype CrdtMergeable,\n\ttype SyncPack,\n\ttype TableReader,\n\ttype TableWriter\n} from '@absolutejs/sync/engine';\n\n/** A comment row stored in the pack's owned table. */\nexport type CommentRow = {\n\tid: string;\n\tresourceId: string;\n\t/** Null on top-level comments, the parent's id on replies. */\n\tparentCommentId: string | null;\n\tauthorId: string;\n\tbody: string;\n\t/** Depth in the thread (0 for top-level, parent.depth + 1 for replies). */\n\tdepth: number;\n\tcreatedAt: number;\n\t/** Null until the comment is edited; otherwise the timestamp of the most\n\t * recent edit. */\n\teditedAt: number | null;\n};\n\n/** Storage adapter the pack uses for the comments table. */\nexport type CommentsStore = {\n\treader: TableReader<CollectionContext>;\n\twriter: TableWriter<CommentRow, CollectionContext, unknown>;\n\t/** Lookup by row id; used by edit + delete mutations to verify ownership\n\t * and by create to walk the parent chain for depth math. */\n\tgetById: (id: string) => CommentRow | undefined;\n};\n\n/** Default in-memory store. Each pack instance creates its own. */\nexport const createInMemoryCommentsStore = (): CommentsStore => {\n\tconst rows = new Map<string, CommentRow>();\n\treturn {\n\t\tgetById: (id) => rows.get(id),\n\t\treader: {\n\t\t\tall: () => [...rows.values()]\n\t\t},\n\t\twriter: {\n\t\t\tdelete: (row) => {\n\t\t\t\trows.delete((row as { id: string }).id);\n\t\t\t},\n\t\t\tinsert: (data) => {\n\t\t\t\trows.set(data.id, data);\n\t\t\t\treturn data;\n\t\t\t},\n\t\t\tupdate: (data) => {\n\t\t\t\tconst prior = rows.get(data.id);\n\t\t\t\tconst merged = { ...(prior ?? {}), ...data } as CommentRow;\n\t\t\t\trows.set(data.id, merged);\n\t\t\t\treturn merged;\n\t\t\t}\n\t\t}\n\t};\n};\n\n/** Thrown when a reply would exceed the configured `maxDepth`. */\nexport class CommentDepthExceededError extends Error {\n\treadonly maxDepth: number;\n\treadonly attemptedDepth: number;\n\tconstructor(maxDepth: number, attemptedDepth: number) {\n\t\tsuper(\n\t\t\t`Comment reply rejected: depth ${attemptedDepth} exceeds maxDepth ${maxDepth}`\n\t\t);\n\t\tthis.name = 'CommentDepthExceededError';\n\t\tthis.maxDepth = maxDepth;\n\t\tthis.attemptedDepth = attemptedDepth;\n\t}\n}\n\n/** Thrown when the requested parent comment doesn't exist or doesn't match. */\nexport class CommentParentMismatchError extends Error {\n\treadonly parentCommentId: string;\n\tconstructor(parentCommentId: string) {\n\t\tsuper(\n\t\t\t`Parent comment ${parentCommentId} not found, or its resourceId doesn't match the reply's resourceId`\n\t\t);\n\t\tthis.name = 'CommentParentMismatchError';\n\t\tthis.parentCommentId = parentCommentId;\n\t}\n}\n\n/** Factory config. `canReadResource` is the only required field. */\nexport type CommentsPackConfig<Ctx = CollectionContext> = {\n\t/**\n\t * Prefix applied to the owned table name AND every collection/mutation\n\t * the pack exposes. Default `\"\"`. Use a non-empty prefix when\n\t * registering multiple comments packs on one engine (e.g. one per\n\t * product surface).\n\t */\n\tprefix?: string;\n\t/**\n\t * Extract the current actor id from the app's ctx. Default:\n\t * `(ctx) => ctx.userId`. **This is the only contract the pack assumes\n\t * about the app's ctx**, alongside `canReadResource` / `canModerate`.\n\t */\n\tgetActorId?: (ctx: Ctx) => string | undefined;\n\t/**\n\t * Gate read access on a resource. The host knows which resources a\n\t * given ctx can read — the pack does NOT duplicate the host's ACL.\n\t * Required: pack reads return zero rows otherwise.\n\t */\n\tcanReadResource: (resourceId: string, ctx: Ctx) => boolean;\n\t/**\n\t * Optional moderation predicate. Used by `comments:delete` — author OR\n\t * moderator can delete. Default `() => false` (only authors delete).\n\t */\n\tcanModerate?: (ctx: Ctx) => boolean;\n\t/**\n\t * Maximum thread depth (top-level = 0, first reply = 1, ...). Replies\n\t * past this depth reject with {@link CommentDepthExceededError}.\n\t * Default `8`.\n\t */\n\tmaxDepth?: number;\n\t/**\n\t * When provided, register the comment row's `body` field as a CRDT via\n\t * `engine.registerCrdt`. The engine then merges concurrent edits\n\t * instead of overwriting. Typically `yjsText` from\n\t * `@absolutejs/sync-yjs` — the pack does NOT import Yjs; the host\n\t * provides the mergeable.\n\t */\n\tbodyCrdt?: CrdtMergeable<unknown>;\n\t/**\n\t * Override the storage adapter. Default: a per-instance in-memory\n\t * store. Pass your own for a persistent backend (Drizzle, Postgres,\n\t * Redis, ...).\n\t */\n\tstore?: CommentsStore;\n\t/** Wall-clock function. Default `Date.now`. */\n\tnow?: () => number;\n\t/**\n\t * Generate a fresh row id. Default `crypto.randomUUID()`. Override for\n\t * deterministic ids in tests, or to route through your existing id\n\t * scheme.\n\t */\n\tnewId?: () => string;\n};\n\nconst DEFAULT_MAX_DEPTH = 8;\n\nconst resolveActor = (\n\tgetActorId: NonNullable<CommentsPackConfig['getActorId']>,\n\tctx: unknown\n): string => {\n\tconst actorId = getActorId(ctx as CollectionContext);\n\tif (actorId === undefined || actorId === '') {\n\t\tthrow new UnauthorizedError('comments mutation (no actor id)');\n\t}\n\treturn actorId;\n};\n\n/**\n * Build a {@link SyncPack} that exposes threaded comments. Each call returns\n * a fresh pack with its own store (unless a custom `store` is supplied).\n */\nexport const createCommentsPack = <Ctx = CollectionContext>(\n\tconfig: CommentsPackConfig<Ctx>\n): SyncPack => {\n\tconst prefix = config.prefix ?? '';\n\tconst table = `${prefix}comments`;\n\tconst collectionName = table;\n\tconst createMutationName = `${prefix}comments:create`;\n\tconst editMutationName = `${prefix}comments:edit`;\n\tconst deleteMutationName = `${prefix}comments:delete`;\n\tconst maxDepth = config.maxDepth ?? DEFAULT_MAX_DEPTH;\n\tconst store = config.store ?? createInMemoryCommentsStore();\n\tconst now = config.now ?? Date.now;\n\tconst newId =\n\t\tconfig.newId ?? (() => globalThis.crypto.randomUUID());\n\tconst getActorId = (config.getActorId ??\n\t\t((ctx: CollectionContext) =>\n\t\t\t(ctx as { userId?: string }).userId)) as (\n\t\tctx: CollectionContext\n\t) => string | undefined;\n\tconst canReadResource = config.canReadResource as (\n\t\tresourceId: string,\n\t\tctx: CollectionContext\n\t) => boolean;\n\tconst canModerate = (config.canModerate ?? (() => false)) as (\n\t\tctx: CollectionContext\n\t) => boolean;\n\n\ttype Params = { resourceId: string };\n\n\tconst pack: SyncPack = {\n\t\tname: '@absolutejs/sync-pack-comments',\n\t\townsTables: [table],\n\t\treadsTables: [],\n\t\tversion: '0.1.0',\n\n\t\tschemas: defineSchema({\n\t\t\t[table]: {\n\t\t\t\tfields: {\n\t\t\t\t\tid: field.string,\n\t\t\t\t\tresourceId: field.string,\n\t\t\t\t\tparentCommentId: (value) =>\n\t\t\t\t\t\tvalue === null || typeof value === 'string',\n\t\t\t\t\tauthorId: field.string,\n\t\t\t\t\tbody: field.string,\n\t\t\t\t\tdepth: field.number,\n\t\t\t\t\tcreatedAt: field.number,\n\t\t\t\t\teditedAt: (value) =>\n\t\t\t\t\t\tvalue === null || typeof value === 'number'\n\t\t\t\t}\n\t\t\t}\n\t\t}),\n\n\t\treaders: { [table]: store.reader },\n\t\twriters: { [table]: store.writer },\n\n\t\tpermissions: {\n\t\t\t[table]: {\n\t\t\t\tread: (ctx: unknown, row: CommentRow) =>\n\t\t\t\t\tcanReadResource(row.resourceId, ctx as CollectionContext),\n\t\t\t\t// The pack's own create handler stamps `authorId` from the\n\t\t\t\t// resolved actor, so this check passes inside the pack.\n\t\t\t\t// A host-side `actions.insert(\"comments\", { ... })` that\n\t\t\t\t// tried to forge an `authorId` would be rejected here.\n\t\t\t\tinsert: (ctx: unknown, row: CommentRow) => {\n\t\t\t\t\tconst callerId = getActorId(ctx as CollectionContext);\n\t\t\t\t\treturn callerId !== undefined && row.authorId === callerId;\n\t\t\t\t},\n\t\t\t\t// Edits: author only. Same row-level check as insert.\n\t\t\t\tupdate: (ctx: unknown, row: CommentRow) => {\n\t\t\t\t\tconst callerId = getActorId(ctx as CollectionContext);\n\t\t\t\t\treturn callerId !== undefined && row.authorId === callerId;\n\t\t\t\t},\n\t\t\t\t// Deletes: author OR moderator. `actions.delete` may pass\n\t\t\t\t// the full row or just the key; if `authorId` isn't in the\n\t\t\t\t// supplied subject we look it up from the store.\n\t\t\t\tdelete: (ctx: unknown, row: CommentRow) => {\n\t\t\t\t\tconst callerId = getActorId(ctx as CollectionContext);\n\t\t\t\t\tif (callerId === undefined) return false;\n\t\t\t\t\tconst authorId =\n\t\t\t\t\t\t(row as { authorId?: string }).authorId ??\n\t\t\t\t\t\t(() => {\n\t\t\t\t\t\t\tconst id = (row as { id?: string }).id;\n\t\t\t\t\t\t\treturn id === undefined\n\t\t\t\t\t\t\t\t? undefined\n\t\t\t\t\t\t\t\t: store.getById(id)?.authorId;\n\t\t\t\t\t\t})();\n\t\t\t\t\tif (authorId === undefined) return false;\n\t\t\t\t\tif (authorId === callerId) return true;\n\t\t\t\t\treturn canModerate(ctx as CollectionContext);\n\t\t\t\t}\n\t\t\t}\n\t\t},\n\n\t\tcollections: [\n\t\t\tdefineCollection<CommentRow, Params, CollectionContext>({\n\t\t\t\tname: collectionName,\n\t\t\t\ttables: [table],\n\t\t\t\tkey: (row) => row.id,\n\t\t\t\thydrate: (params, ctx) =>\n\t\t\t\t\t(store.reader.all(ctx) as CommentRow[]).filter(\n\t\t\t\t\t\t(row) =>\n\t\t\t\t\t\t\trow.resourceId === params.resourceId &&\n\t\t\t\t\t\t\tcanReadResource(row.resourceId, ctx)\n\t\t\t\t\t),\n\t\t\t\tmatch: (row, params, ctx) =>\n\t\t\t\t\trow.resourceId === params.resourceId &&\n\t\t\t\t\tcanReadResource(row.resourceId, ctx),\n\t\t\t\tauthorize: (params, ctx) =>\n\t\t\t\t\tcanReadResource(params.resourceId, ctx)\n\t\t\t})\n\t\t],\n\n\t\tmutations: [\n\t\t\tdefineMutation<\n\t\t\t\t{\n\t\t\t\t\tresourceId: string;\n\t\t\t\t\tbody: string;\n\t\t\t\t\tparentCommentId?: string | null;\n\t\t\t\t},\n\t\t\t\tCollectionContext,\n\t\t\t\tCommentRow\n\t\t\t>({\n\t\t\t\tname: createMutationName,\n\t\t\t\thandler: async (args, ctx, actions) => {\n\t\t\t\t\tif (!canReadResource(args.resourceId, ctx)) {\n\t\t\t\t\t\tthrow new UnauthorizedError(\n\t\t\t\t\t\t\t`comments:create on resource \"${args.resourceId}\"`\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t\tconst actorId = resolveActor(getActorId, ctx);\n\t\t\t\t\tlet depth = 0;\n\t\t\t\t\tif (\n\t\t\t\t\t\targs.parentCommentId !== undefined &&\n\t\t\t\t\t\targs.parentCommentId !== null\n\t\t\t\t\t) {\n\t\t\t\t\t\tconst parent = store.getById(args.parentCommentId);\n\t\t\t\t\t\tif (\n\t\t\t\t\t\t\tparent === undefined ||\n\t\t\t\t\t\t\tparent.resourceId !== args.resourceId\n\t\t\t\t\t\t) {\n\t\t\t\t\t\t\tthrow new CommentParentMismatchError(\n\t\t\t\t\t\t\t\targs.parentCommentId\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\t\t\t\t\t\tdepth = parent.depth + 1;\n\t\t\t\t\t\tif (depth > maxDepth) {\n\t\t\t\t\t\t\tthrow new CommentDepthExceededError(\n\t\t\t\t\t\t\t\tmaxDepth,\n\t\t\t\t\t\t\t\tdepth\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tconst row: CommentRow = {\n\t\t\t\t\t\tid: newId(),\n\t\t\t\t\t\tresourceId: args.resourceId,\n\t\t\t\t\t\tparentCommentId: args.parentCommentId ?? null,\n\t\t\t\t\t\tauthorId: actorId,\n\t\t\t\t\t\tbody: args.body,\n\t\t\t\t\t\tdepth,\n\t\t\t\t\t\tcreatedAt: now(),\n\t\t\t\t\t\teditedAt: null\n\t\t\t\t\t};\n\t\t\t\t\treturn (await actions.insert(table, row)) as CommentRow;\n\t\t\t\t}\n\t\t\t}),\n\t\t\tdefineMutation<\n\t\t\t\t{ commentId: string; body: string },\n\t\t\t\tCollectionContext,\n\t\t\t\tCommentRow\n\t\t\t>({\n\t\t\t\tname: editMutationName,\n\t\t\t\thandler: async (args, ctx, actions) => {\n\t\t\t\t\tconst actorId = resolveActor(getActorId, ctx);\n\t\t\t\t\tconst existing = store.getById(args.commentId);\n\t\t\t\t\tif (existing === undefined) {\n\t\t\t\t\t\tthrow new UnauthorizedError(\n\t\t\t\t\t\t\t`comments:edit on missing comment \"${args.commentId}\"`\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t\tif (existing.authorId !== actorId) {\n\t\t\t\t\t\tthrow new UnauthorizedError(\n\t\t\t\t\t\t\t`comments:edit on \"${args.commentId}\" (not author)`\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t\tconst updated: CommentRow = {\n\t\t\t\t\t\t...existing,\n\t\t\t\t\t\tbody: args.body,\n\t\t\t\t\t\teditedAt: now()\n\t\t\t\t\t};\n\t\t\t\t\treturn (await actions.update(table, updated)) as CommentRow;\n\t\t\t\t}\n\t\t\t}),\n\t\t\tdefineMutation<{ commentId: string }, CollectionContext, void>({\n\t\t\t\tname: deleteMutationName,\n\t\t\t\thandler: async (args, ctx, actions) => {\n\t\t\t\t\tconst actorId = resolveActor(getActorId, ctx);\n\t\t\t\t\tconst existing = store.getById(args.commentId);\n\t\t\t\t\tif (existing === undefined) {\n\t\t\t\t\t\tthrow new UnauthorizedError(\n\t\t\t\t\t\t\t`comments:delete on missing comment \"${args.commentId}\"`\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t\tconst isAuthor = existing.authorId === actorId;\n\t\t\t\t\tconst isModerator = canModerate(ctx);\n\t\t\t\t\tif (!isAuthor && !isModerator) {\n\t\t\t\t\t\tthrow new UnauthorizedError(\n\t\t\t\t\t\t\t`comments:delete on \"${args.commentId}\" (not author, not moderator)`\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t\tawait actions.delete(table, { id: args.commentId });\n\t\t\t\t}\n\t\t\t})\n\t\t]\n\t};\n\n\tif (config.bodyCrdt !== undefined) {\n\t\tpack.crdt = { [table]: { body: config.bodyCrdt } };\n\t}\n\n\treturn defineSyncPack(pack);\n};\n"
|
|
5
|
+
"/**\n * `@absolutejs/sync-pack-comments` — threaded comments on host-side resources\n * as a sync pack.\n *\n * Owns a single `comments` table. Per-resource read access is gated through\n * host-injected `canReadResource(resourceId, ctx)`. Edits are author-only;\n * deletes are author or moderator. Optional `bodyCrdt` config wires the\n * body field through `registerCrdt` for conflict-free editing. Optional\n * `joinUsers` config registers a `comments-with-author` join collection\n * that pairs each comment with the host's user row.\n *\n * @example\n * ```ts\n * import { createSyncEngine } from '@absolutejs/sync/engine';\n * import { createCommentsPack } from '@absolutejs/sync-pack-comments';\n *\n * const engine = createSyncEngine();\n * engine.registerPack(createCommentsPack({\n * getActorId: (ctx) => ctx.session.userId,\n * canReadResource: (resourceId, ctx) =>\n * hostAcl.canRead(resourceId, ctx.session.userId),\n * maxDepth: 8,\n * }));\n * ```\n */\n\nimport {\n\tcreateTextIndex,\n\tdefineCollection,\n\tdefineJoinCollection,\n\tdefineMutation,\n\tdefineSchema,\n\tdefineSearchCollection,\n\tdefineSyncPack,\n\tfield,\n\tUnauthorizedError,\n\ttype CollectionContext,\n\ttype CrdtMergeable,\n\ttype SyncPack,\n\ttype TableReader,\n\ttype TableWriter\n} from '@absolutejs/sync/engine';\n\n/** A comment row stored in the pack's owned table. */\nexport type CommentRow = {\n\tid: string;\n\tresourceId: string;\n\t/** Null on top-level comments, the parent's id on replies. */\n\tparentCommentId: string | null;\n\tauthorId: string;\n\tbody: string;\n\t/** Depth in the thread (0 for top-level, parent.depth + 1 for replies). */\n\tdepth: number;\n\tcreatedAt: number;\n\t/** Null until the comment is edited; otherwise the timestamp of the most\n\t * recent edit. */\n\teditedAt: number | null;\n};\n\n/** Storage adapter the pack uses for the comments table. */\nexport type CommentsStore = {\n\treader: TableReader<CollectionContext>;\n\twriter: TableWriter<CommentRow, CollectionContext, unknown>;\n\t/** Lookup by row id; used by edit + delete mutations to verify ownership\n\t * and by create to walk the parent chain for depth math. */\n\tgetById: (id: string) => CommentRow | undefined;\n};\n\n/** Default in-memory store. Each pack instance creates its own. */\nexport const createInMemoryCommentsStore = (): CommentsStore => {\n\tconst rows = new Map<string, CommentRow>();\n\treturn {\n\t\tgetById: (id) => rows.get(id),\n\t\treader: {\n\t\t\tall: () => [...rows.values()]\n\t\t},\n\t\twriter: {\n\t\t\tdelete: (row) => {\n\t\t\t\trows.delete((row as { id: string }).id);\n\t\t\t},\n\t\t\tinsert: (data) => {\n\t\t\t\trows.set(data.id, data);\n\t\t\t\treturn data;\n\t\t\t},\n\t\t\tupdate: (data) => {\n\t\t\t\tconst prior = rows.get(data.id);\n\t\t\t\tconst merged = { ...(prior ?? {}), ...data } as CommentRow;\n\t\t\t\trows.set(data.id, merged);\n\t\t\t\treturn merged;\n\t\t\t}\n\t\t}\n\t};\n};\n\n/** Thrown when a reply would exceed the configured `maxDepth`. */\nexport class CommentDepthExceededError extends Error {\n\treadonly maxDepth: number;\n\treadonly attemptedDepth: number;\n\tconstructor(maxDepth: number, attemptedDepth: number) {\n\t\tsuper(\n\t\t\t`Comment reply rejected: depth ${attemptedDepth} exceeds maxDepth ${maxDepth}`\n\t\t);\n\t\tthis.name = 'CommentDepthExceededError';\n\t\tthis.maxDepth = maxDepth;\n\t\tthis.attemptedDepth = attemptedDepth;\n\t}\n}\n\n/** Thrown when the requested parent comment doesn't exist or doesn't match. */\nexport class CommentParentMismatchError extends Error {\n\treadonly parentCommentId: string;\n\tconstructor(parentCommentId: string) {\n\t\tsuper(\n\t\t\t`Parent comment ${parentCommentId} not found, or its resourceId doesn't match the reply's resourceId`\n\t\t);\n\t\tthis.name = 'CommentParentMismatchError';\n\t\tthis.parentCommentId = parentCommentId;\n\t}\n}\n\n/** Factory config. `canReadResource` is the only required field. */\nexport type CommentsPackConfig<\n\tCtx = CollectionContext,\n\tAuthorRow = unknown\n> = {\n\t/**\n\t * Prefix applied to the owned table name AND every collection/mutation\n\t * the pack exposes. Default `\"\"`. Use a non-empty prefix when\n\t * registering multiple comments packs on one engine (e.g. one per\n\t * product surface).\n\t */\n\tprefix?: string;\n\t/**\n\t * Extract the current actor id from the app's ctx. Default:\n\t * `(ctx) => ctx.userId`. **This is the only contract the pack assumes\n\t * about the app's ctx**, alongside `canReadResource` / `canModerate`.\n\t */\n\tgetActorId?: (ctx: Ctx) => string | undefined;\n\t/**\n\t * Gate read access on a resource. The host knows which resources a\n\t * given ctx can read — the pack does NOT duplicate the host's ACL.\n\t * Required: pack reads return zero rows otherwise.\n\t */\n\tcanReadResource: (resourceId: string, ctx: Ctx) => boolean;\n\t/**\n\t * Optional moderation predicate. Used by `comments:delete` — author OR\n\t * moderator can delete. Default `() => false` (only authors delete).\n\t */\n\tcanModerate?: (ctx: Ctx) => boolean;\n\t/**\n\t * Maximum thread depth (top-level = 0, first reply = 1, ...). Replies\n\t * past this depth reject with {@link CommentDepthExceededError}.\n\t * Default `8`.\n\t */\n\tmaxDepth?: number;\n\t/**\n\t * When provided, register the comment row's `body` field as a CRDT via\n\t * `engine.registerCrdt`. The engine then merges concurrent edits\n\t * instead of overwriting. Typically `yjsText` from\n\t * `@absolutejs/sync-yjs` — the pack does NOT import Yjs; the host\n\t * provides the mergeable.\n\t */\n\tbodyCrdt?: CrdtMergeable<unknown>;\n\t/**\n\t * Override the storage adapter. Default: a per-instance in-memory\n\t * store. Pass your own for a persistent backend (Drizzle, Postgres,\n\t * Redis, ...).\n\t */\n\tstore?: CommentsStore;\n\t/** Wall-clock function. Default `Date.now`. */\n\tnow?: () => number;\n\t/**\n\t * Generate a fresh row id. Default `crypto.randomUUID()`. Override for\n\t * deterministic ids in tests, or to route through your existing id\n\t * scheme.\n\t */\n\tnewId?: () => string;\n\t/**\n\t * When set, the pack additionally registers a `comments-with-author`\n\t * join collection. The host's user table must have a registered\n\t * reader/writer (so user-row changes propagate into the join). The\n\t * pack itself does NOT own the users table; it only `readsTables`\n\t * the configured name.\n\t */\n\tjoinUsers?: JoinUsersConfig<Ctx, AuthorRow>;\n\t/**\n\t * When set, register a `comments-search` full-text search collection\n\t * over the body field. The subscription's `params` is the query string;\n\t * results are the ranked top-K, re-ranked live as comments are added,\n\t * edited, or removed. Per-row read permission (which routes through\n\t * `canReadResource`) still filters hits per caller.\n\t */\n\tsearch?: { topK?: number };\n};\n\n/**\n * Config for the optional `comments-with-author` join collection.\n *\n * The pack does not own the host's user table. The host supplies the\n * right-side hydrate (typically reading from its registered reader) and\n * the join key. The engine maintains the join incrementally — changes to\n * either side fan in through `engine.applyChange`.\n */\nexport type JoinUsersConfig<Ctx, AuthorRow = unknown> = {\n\t/**\n\t * The host's user table name. Surfaced in `readsTables` so the\n\t * dependency graph is reviewable. Default `\"users\"`.\n\t */\n\ttable?: string;\n\t/**\n\t * Get the user's id (the join field). Default `(user) => user.id`.\n\t */\n\tkey?: (user: AuthorRow) => string;\n\t/**\n\t * Host-side hydrate for the users side of the join. The pack passes\n\t * the subscription params + ctx; this returns the candidate users.\n\t * Returning all users (small set) or just the authors referenced by\n\t * the comments are both fine — the engine inner-joins on `authorId\n\t * === id` after hydrate.\n\t */\n\thydrate: (\n\t\tparams: { resourceId: string },\n\t\tctx: Ctx\n\t) => Iterable<AuthorRow> | Promise<Iterable<AuthorRow>>;\n};\n\n/** A joined row emitted by the `comments-with-author` collection. */\nexport type CommentWithAuthor<AuthorRow = unknown> = CommentRow & {\n\tauthor: AuthorRow;\n};\n\nconst DEFAULT_MAX_DEPTH = 8;\nconst DEFAULT_USER_TABLE = 'users';\n\nconst resolveActor = (\n\tgetActorId: NonNullable<CommentsPackConfig['getActorId']>,\n\tctx: unknown\n): string => {\n\tconst actorId = getActorId(ctx as CollectionContext);\n\tif (actorId === undefined || actorId === '') {\n\t\tthrow new UnauthorizedError('comments mutation (no actor id)');\n\t}\n\treturn actorId;\n};\n\n/**\n * Build a {@link SyncPack} that exposes threaded comments. Each call returns\n * a fresh pack with its own store (unless a custom `store` is supplied).\n *\n * The `AuthorRow` generic is only consulted by the\n * `comments-with-author` join collection (when `joinUsers` is set); pass\n * it to recover types for the joined output. With no `joinUsers`, default\n * `unknown` is fine.\n */\nexport const createCommentsPack = <\n\tCtx = CollectionContext,\n\tAuthorRow = unknown\n>(\n\tconfig: CommentsPackConfig<Ctx, AuthorRow>\n): SyncPack => {\n\tconst prefix = config.prefix ?? '';\n\tconst table = `${prefix}comments`;\n\tconst collectionName = table;\n\tconst createMutationName = `${prefix}comments:create`;\n\tconst editMutationName = `${prefix}comments:edit`;\n\tconst deleteMutationName = `${prefix}comments:delete`;\n\tconst maxDepth = config.maxDepth ?? DEFAULT_MAX_DEPTH;\n\tconst store = config.store ?? createInMemoryCommentsStore();\n\tconst now = config.now ?? Date.now;\n\tconst newId =\n\t\tconfig.newId ?? (() => globalThis.crypto.randomUUID());\n\tconst getActorId = (config.getActorId ??\n\t\t((ctx: CollectionContext) =>\n\t\t\t(ctx as { userId?: string }).userId)) as (\n\t\tctx: CollectionContext\n\t) => string | undefined;\n\tconst canReadResource = config.canReadResource as (\n\t\tresourceId: string,\n\t\tctx: CollectionContext\n\t) => boolean;\n\tconst canModerate = (config.canModerate ?? (() => false)) as (\n\t\tctx: CollectionContext\n\t) => boolean;\n\n\ttype Params = { resourceId: string };\n\n\tconst joinUsers = config.joinUsers;\n\tconst userTable = joinUsers?.table ?? DEFAULT_USER_TABLE;\n\tconst joinCollectionName = `${prefix}comments-with-author`;\n\tconst userKey = (joinUsers?.key ?? ((row: unknown) =>\n\t\t(row as { id: string }).id)) as (user: unknown) => string;\n\tconst search = config.search;\n\tconst searchCollectionName = `${prefix}comments-search`;\n\tconst searchTopK = search?.topK ?? 20;\n\n\tconst pack: SyncPack = {\n\t\tname: '@absolutejs/sync-pack-comments',\n\t\townsTables: [table],\n\t\treadsTables: joinUsers === undefined ? [] : [userTable],\n\t\tversion: '0.3.0',\n\n\t\tschemas: defineSchema({\n\t\t\t[table]: {\n\t\t\t\tfields: {\n\t\t\t\t\tid: field.string,\n\t\t\t\t\tresourceId: field.string,\n\t\t\t\t\tparentCommentId: (value) =>\n\t\t\t\t\t\tvalue === null || typeof value === 'string',\n\t\t\t\t\tauthorId: field.string,\n\t\t\t\t\tbody: field.string,\n\t\t\t\t\tdepth: field.number,\n\t\t\t\t\tcreatedAt: field.number,\n\t\t\t\t\teditedAt: (value) =>\n\t\t\t\t\t\tvalue === null || typeof value === 'number'\n\t\t\t\t}\n\t\t\t}\n\t\t}),\n\n\t\treaders: { [table]: store.reader },\n\t\twriters: { [table]: store.writer },\n\n\t\tpermissions: {\n\t\t\t[table]: {\n\t\t\t\tread: (ctx: unknown, row: CommentRow) =>\n\t\t\t\t\tcanReadResource(row.resourceId, ctx as CollectionContext),\n\t\t\t\t// The pack's own create handler stamps `authorId` from the\n\t\t\t\t// resolved actor, so this check passes inside the pack.\n\t\t\t\t// A host-side `actions.insert(\"comments\", { ... })` that\n\t\t\t\t// tried to forge an `authorId` would be rejected here.\n\t\t\t\tinsert: (ctx: unknown, row: CommentRow) => {\n\t\t\t\t\tconst callerId = getActorId(ctx as CollectionContext);\n\t\t\t\t\treturn callerId !== undefined && row.authorId === callerId;\n\t\t\t\t},\n\t\t\t\t// Edits: author only. Same row-level check as insert.\n\t\t\t\tupdate: (ctx: unknown, row: CommentRow) => {\n\t\t\t\t\tconst callerId = getActorId(ctx as CollectionContext);\n\t\t\t\t\treturn callerId !== undefined && row.authorId === callerId;\n\t\t\t\t},\n\t\t\t\t// Deletes: author OR moderator. `actions.delete` may pass\n\t\t\t\t// the full row or just the key; if `authorId` isn't in the\n\t\t\t\t// supplied subject we look it up from the store.\n\t\t\t\tdelete: (ctx: unknown, row: CommentRow) => {\n\t\t\t\t\tconst callerId = getActorId(ctx as CollectionContext);\n\t\t\t\t\tif (callerId === undefined) return false;\n\t\t\t\t\tconst authorId =\n\t\t\t\t\t\t(row as { authorId?: string }).authorId ??\n\t\t\t\t\t\t(() => {\n\t\t\t\t\t\t\tconst id = (row as { id?: string }).id;\n\t\t\t\t\t\t\treturn id === undefined\n\t\t\t\t\t\t\t\t? undefined\n\t\t\t\t\t\t\t\t: store.getById(id)?.authorId;\n\t\t\t\t\t\t})();\n\t\t\t\t\tif (authorId === undefined) return false;\n\t\t\t\t\tif (authorId === callerId) return true;\n\t\t\t\t\treturn canModerate(ctx as CollectionContext);\n\t\t\t\t}\n\t\t\t}\n\t\t},\n\n\t\tcollections: [\n\t\t\tdefineCollection<CommentRow, Params, CollectionContext>({\n\t\t\t\tname: collectionName,\n\t\t\t\ttables: [table],\n\t\t\t\tkey: (row) => row.id,\n\t\t\t\thydrate: (params, ctx) =>\n\t\t\t\t\t(store.reader.all(ctx) as CommentRow[]).filter(\n\t\t\t\t\t\t(row) =>\n\t\t\t\t\t\t\trow.resourceId === params.resourceId &&\n\t\t\t\t\t\t\tcanReadResource(row.resourceId, ctx)\n\t\t\t\t\t),\n\t\t\t\tmatch: (row, params, ctx) =>\n\t\t\t\t\trow.resourceId === params.resourceId &&\n\t\t\t\t\tcanReadResource(row.resourceId, ctx),\n\t\t\t\tauthorize: (params, ctx) =>\n\t\t\t\t\tcanReadResource(params.resourceId, ctx)\n\t\t\t})\n\t\t],\n\n\t\tmutations: [\n\t\t\tdefineMutation<\n\t\t\t\t{\n\t\t\t\t\tresourceId: string;\n\t\t\t\t\tbody: string;\n\t\t\t\t\tparentCommentId?: string | null;\n\t\t\t\t},\n\t\t\t\tCollectionContext,\n\t\t\t\tCommentRow\n\t\t\t>({\n\t\t\t\tname: createMutationName,\n\t\t\t\thandler: async (args, ctx, actions) => {\n\t\t\t\t\tif (!canReadResource(args.resourceId, ctx)) {\n\t\t\t\t\t\tthrow new UnauthorizedError(\n\t\t\t\t\t\t\t`comments:create on resource \"${args.resourceId}\"`\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t\tconst actorId = resolveActor(getActorId, ctx);\n\t\t\t\t\tlet depth = 0;\n\t\t\t\t\tif (\n\t\t\t\t\t\targs.parentCommentId !== undefined &&\n\t\t\t\t\t\targs.parentCommentId !== null\n\t\t\t\t\t) {\n\t\t\t\t\t\tconst parent = store.getById(args.parentCommentId);\n\t\t\t\t\t\tif (\n\t\t\t\t\t\t\tparent === undefined ||\n\t\t\t\t\t\t\tparent.resourceId !== args.resourceId\n\t\t\t\t\t\t) {\n\t\t\t\t\t\t\tthrow new CommentParentMismatchError(\n\t\t\t\t\t\t\t\targs.parentCommentId\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\t\t\t\t\t\tdepth = parent.depth + 1;\n\t\t\t\t\t\tif (depth > maxDepth) {\n\t\t\t\t\t\t\tthrow new CommentDepthExceededError(\n\t\t\t\t\t\t\t\tmaxDepth,\n\t\t\t\t\t\t\t\tdepth\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tconst row: CommentRow = {\n\t\t\t\t\t\tid: newId(),\n\t\t\t\t\t\tresourceId: args.resourceId,\n\t\t\t\t\t\tparentCommentId: args.parentCommentId ?? null,\n\t\t\t\t\t\tauthorId: actorId,\n\t\t\t\t\t\tbody: args.body,\n\t\t\t\t\t\tdepth,\n\t\t\t\t\t\tcreatedAt: now(),\n\t\t\t\t\t\teditedAt: null\n\t\t\t\t\t};\n\t\t\t\t\treturn (await actions.insert(table, row)) as CommentRow;\n\t\t\t\t}\n\t\t\t}),\n\t\t\tdefineMutation<\n\t\t\t\t{ commentId: string; body: string },\n\t\t\t\tCollectionContext,\n\t\t\t\tCommentRow\n\t\t\t>({\n\t\t\t\tname: editMutationName,\n\t\t\t\thandler: async (args, ctx, actions) => {\n\t\t\t\t\tconst actorId = resolveActor(getActorId, ctx);\n\t\t\t\t\tconst existing = store.getById(args.commentId);\n\t\t\t\t\tif (existing === undefined) {\n\t\t\t\t\t\tthrow new UnauthorizedError(\n\t\t\t\t\t\t\t`comments:edit on missing comment \"${args.commentId}\"`\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t\tif (existing.authorId !== actorId) {\n\t\t\t\t\t\tthrow new UnauthorizedError(\n\t\t\t\t\t\t\t`comments:edit on \"${args.commentId}\" (not author)`\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t\tconst updated: CommentRow = {\n\t\t\t\t\t\t...existing,\n\t\t\t\t\t\tbody: args.body,\n\t\t\t\t\t\teditedAt: now()\n\t\t\t\t\t};\n\t\t\t\t\treturn (await actions.update(table, updated)) as CommentRow;\n\t\t\t\t}\n\t\t\t}),\n\t\t\tdefineMutation<{ commentId: string }, CollectionContext, void>({\n\t\t\t\tname: deleteMutationName,\n\t\t\t\thandler: async (args, ctx, actions) => {\n\t\t\t\t\tconst actorId = resolveActor(getActorId, ctx);\n\t\t\t\t\tconst existing = store.getById(args.commentId);\n\t\t\t\t\tif (existing === undefined) {\n\t\t\t\t\t\tthrow new UnauthorizedError(\n\t\t\t\t\t\t\t`comments:delete on missing comment \"${args.commentId}\"`\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t\tconst isAuthor = existing.authorId === actorId;\n\t\t\t\t\tconst isModerator = canModerate(ctx);\n\t\t\t\t\tif (!isAuthor && !isModerator) {\n\t\t\t\t\t\tthrow new UnauthorizedError(\n\t\t\t\t\t\t\t`comments:delete on \"${args.commentId}\" (not author, not moderator)`\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t\tawait actions.delete(table, { id: args.commentId });\n\t\t\t\t}\n\t\t\t})\n\t\t]\n\t};\n\n\tif (config.bodyCrdt !== undefined) {\n\t\tpack.crdt = { [table]: { body: config.bodyCrdt } };\n\t}\n\n\tif (search !== undefined) {\n\t\tpack.searchCollections = [\n\t\t\tdefineSearchCollection<CommentRow>({\n\t\t\t\tname: searchCollectionName,\n\t\t\t\ttable,\n\t\t\t\tindex: () =>\n\t\t\t\t\tcreateTextIndex<CommentRow>({\n\t\t\t\t\t\tfields: ['body'],\n\t\t\t\t\t\tkey: (row) => row.id\n\t\t\t\t\t}),\n\t\t\t\tkey: (row) => row.id,\n\t\t\t\tlimit: searchTopK,\n\t\t\t\tsource: () =>\n\t\t\t\t\tstore.reader.all({}) as Iterable<CommentRow>\n\t\t\t})\n\t\t];\n\t}\n\n\tif (joinUsers !== undefined) {\n\t\tconst usersHydrate = joinUsers.hydrate;\n\t\tpack.joinCollections = [\n\t\t\tdefineJoinCollection<\n\t\t\t\tCommentRow,\n\t\t\t\tunknown,\n\t\t\t\tCommentWithAuthor,\n\t\t\t\tParams,\n\t\t\t\tCollectionContext\n\t\t\t>({\n\t\t\t\tname: joinCollectionName,\n\t\t\t\tkey: (out) => out.id,\n\t\t\t\tleft: {\n\t\t\t\t\ttable,\n\t\t\t\t\thydrate: (params, ctx) =>\n\t\t\t\t\t\t(store.reader.all(ctx) as CommentRow[]).filter(\n\t\t\t\t\t\t\t(row) =>\n\t\t\t\t\t\t\t\trow.resourceId === params.resourceId &&\n\t\t\t\t\t\t\t\tcanReadResource(row.resourceId, ctx)\n\t\t\t\t\t\t),\n\t\t\t\t\tkey: (row) => row.id,\n\t\t\t\t\ton: (row) => row.authorId,\n\t\t\t\t\t// Per-resource read gate, also applied to incoming changes.\n\t\t\t\t\tmatch: (row, params, ctx) =>\n\t\t\t\t\t\trow.resourceId === params.resourceId &&\n\t\t\t\t\t\tcanReadResource(row.resourceId, ctx)\n\t\t\t\t},\n\t\t\t\tright: {\n\t\t\t\t\ttable: userTable,\n\t\t\t\t\thydrate: (params, ctx) =>\n\t\t\t\t\t\tusersHydrate(params, ctx as Ctx) as Iterable<unknown>,\n\t\t\t\t\tkey: (user) => userKey(user),\n\t\t\t\t\ton: (user) => userKey(user)\n\t\t\t\t},\n\t\t\t\tselect: (comment, author) => ({ ...comment, author }),\n\t\t\t\tauthorize: (params, ctx) =>\n\t\t\t\t\tcanReadResource(params.resourceId, ctx)\n\t\t\t})\n\t\t];\n\t}\n\n\treturn defineSyncPack(pack);\n};\n"
|
|
6
6
|
],
|
|
7
|
-
"mappings": ";;
|
|
8
|
-
"debugId": "
|
|
7
|
+
"mappings": ";;AA0BA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AA2CO,IAAM,8BAA8B,MAAqB;AAAA,EAC/D,MAAM,OAAO,IAAI;AAAA,EACjB,OAAO;AAAA,IACN,SAAS,CAAC,OAAO,KAAK,IAAI,EAAE;AAAA,IAC5B,QAAQ;AAAA,MACP,KAAK,MAAM,CAAC,GAAG,KAAK,OAAO,CAAC;AAAA,IAC7B;AAAA,IACA,QAAQ;AAAA,MACP,QAAQ,CAAC,QAAQ;AAAA,QAChB,KAAK,OAAQ,IAAuB,EAAE;AAAA;AAAA,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CAAC,QAAQ,IAAI;AAAA,QAClB,MAAM;AAAA,UACL;AAAA,UACA,SAAS,CAAC,QAAQ,QAChB,MAAM,OAAO,IAAI,GAAG,EAAmB,OACvC,CAAC,QACA,IAAI,eAAe,OAAO,cAC1B,gBAAgB,IAAI,YAAY,GAAG,CACrC;AAAA,UACD,KAAK,CAAC,QAAQ,IAAI;AAAA,UAClB,IAAI,CAAC,QAAQ,IAAI;AAAA,UAEjB,OAAO,CAAC,KAAK,QAAQ,QACpB,IAAI,eAAe,OAAO,cAC1B,gBAAgB,IAAI,YAAY,GAAG;AAAA,QACrC;AAAA,QACA,OAAO;AAAA,UACN,OAAO;AAAA,UACP,SAAS,CAAC,QAAQ,QACjB,aAAa,QAAQ,GAAU;AAAA,UAChC,KAAK,CAAC,SAAS,QAAQ,IAAI;AAAA,UAC3B,IAAI,CAAC,SAAS,QAAQ,IAAI;AAAA,QAC3B;AAAA,QACA,QAAQ,CAAC,SAAS,YAAY,KAAK,SAAS,OAAO;AAAA,QACnD,WAAW,CAAC,QAAQ,QACnB,gBAAgB,OAAO,YAAY,GAAG;AAAA,MACxC,CAAC;AAAA,IACF;AAAA,EACD;AAAA,EAEA,OAAO,eAAe,IAAI;AAAA;",
|
|
8
|
+
"debugId": "04A2B1840A2D711C64756E2164756E21",
|
|
9
9
|
"names": []
|
|
10
10
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@absolutejs/sync-pack-comments",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"description": "Threaded comments pack for @absolutejs/sync — per-resource ACL-scoped, author/moderator gates, optional CRDT bodies",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
"@absolutejs/sync": ">= 1.9.1"
|
|
36
36
|
},
|
|
37
37
|
"devDependencies": {
|
|
38
|
-
"@absolutejs/sync": "^1.9.
|
|
38
|
+
"@absolutejs/sync": "^1.9.2",
|
|
39
39
|
"@types/bun": "1.3.14",
|
|
40
40
|
"prettier": "3.5.3",
|
|
41
41
|
"typescript": "5.8.3"
|