@absolutejs/sync-pack-comments 0.2.0 → 0.4.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/dist/index.d.ts CHANGED
@@ -122,7 +122,51 @@ export type CommentsPackConfig<Ctx = CollectionContext, AuthorRow = unknown> = {
122
122
  * the configured name.
123
123
  */
124
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
+ * When set, register a `comment_reactions` table + matching collection
137
+ * + react / unreact / toggleReaction mutations. Each row is one
138
+ * actor's reaction with a single emoji on a single comment, deterministic
139
+ * id `${commentId}:${actorId}:${emoji}` for idempotent toggling.
140
+ */
141
+ reactions?: ReactionsConfig;
125
142
  };
143
+ /** Config for the optional reactions surface. */
144
+ export type ReactionsConfig = {
145
+ /**
146
+ * Allowed emojis. Setting this filters react mutations — anything
147
+ * outside the list is rejected. Empty array (default) means any
148
+ * single-character or grapheme string is accepted.
149
+ */
150
+ allowedEmojis?: string[];
151
+ /**
152
+ * Custom row id generator for reaction rows. Default
153
+ * `(commentId, actorId, emoji) => \`${commentId}:${actorId}:${emoji}\``.
154
+ */
155
+ newId?: (commentId: string, actorId: string, emoji: string) => string;
156
+ };
157
+ /** A reaction row — one per (comment, actor, emoji). */
158
+ export type CommentReactionRow = {
159
+ id: string;
160
+ commentId: string;
161
+ actorId: string;
162
+ emoji: string;
163
+ createdAt: number;
164
+ };
165
+ /** Thrown when a react mutation supplies an emoji outside `allowedEmojis`. */
166
+ export declare class CommentReactionNotAllowedError extends Error {
167
+ readonly emoji: string;
168
+ constructor(emoji: string);
169
+ }
126
170
  /**
127
171
  * Config for the optional `comments-with-author` join collection.
128
172
  *
package/dist/index.js CHANGED
@@ -1,10 +1,12 @@
1
1
  // @bun
2
2
  // src/index.ts
3
3
  import {
4
+ createTextIndex,
4
5
  defineCollection,
5
6
  defineJoinCollection,
6
7
  defineMutation,
7
8
  defineSchema,
9
+ defineSearchCollection,
8
10
  defineSyncPack,
9
11
  field,
10
12
  UnauthorizedError
@@ -53,6 +55,15 @@ class CommentParentMismatchError extends Error {
53
55
  this.parentCommentId = parentCommentId;
54
56
  }
55
57
  }
58
+
59
+ class CommentReactionNotAllowedError extends Error {
60
+ emoji;
61
+ constructor(emoji) {
62
+ super(`Comment reaction "${emoji}" is not in the configured allowedEmojis`);
63
+ this.name = "CommentReactionNotAllowedError";
64
+ this.emoji = emoji;
65
+ }
66
+ }
56
67
  var DEFAULT_MAX_DEPTH = 8;
57
68
  var DEFAULT_USER_TABLE = "users";
58
69
  var resolveActor = (getActorId, ctx) => {
@@ -80,11 +91,38 @@ var createCommentsPack = (config) => {
80
91
  const userTable = joinUsers?.table ?? DEFAULT_USER_TABLE;
81
92
  const joinCollectionName = `${prefix}comments-with-author`;
82
93
  const userKey = joinUsers?.key ?? ((row) => row.id);
94
+ const search = config.search;
95
+ const searchCollectionName = `${prefix}comments-search`;
96
+ const searchTopK = search?.topK ?? 20;
97
+ const reactionsConfig = config.reactions;
98
+ const reactionsTable = `${prefix}comment_reactions`;
99
+ const reactionsCollectionName = reactionsTable;
100
+ const reactMutationName = `${prefix}comments:react`;
101
+ const unreactMutationName = `${prefix}comments:unreact`;
102
+ const toggleReactionMutationName = `${prefix}comments:toggleReaction`;
103
+ const reactionId = reactionsConfig?.newId ?? ((commentId, actorId, emoji) => `${commentId}:${actorId}:${emoji}`);
104
+ const reactionStore = new Map;
105
+ const reactionReader = {
106
+ all: () => [...reactionStore.values()]
107
+ };
108
+ const reactionWriter = {
109
+ delete: (row) => {
110
+ reactionStore.delete(row.id);
111
+ },
112
+ insert: (data) => {
113
+ reactionStore.set(data.id, data);
114
+ return data;
115
+ },
116
+ update: (data) => {
117
+ reactionStore.set(data.id, data);
118
+ return data;
119
+ }
120
+ };
83
121
  const pack = {
84
122
  name: "@absolutejs/sync-pack-comments",
85
- ownsTables: [table],
123
+ ownsTables: reactionsConfig === undefined ? [table] : [table, reactionsTable],
86
124
  readsTables: joinUsers === undefined ? [] : [userTable],
87
- version: "0.2.0",
125
+ version: "0.4.0",
88
126
  schemas: defineSchema({
89
127
  [table]: {
90
128
  fields: {
@@ -210,6 +248,21 @@ var createCommentsPack = (config) => {
210
248
  if (config.bodyCrdt !== undefined) {
211
249
  pack.crdt = { [table]: { body: config.bodyCrdt } };
212
250
  }
251
+ if (search !== undefined) {
252
+ pack.searchCollections = [
253
+ defineSearchCollection({
254
+ name: searchCollectionName,
255
+ table,
256
+ index: () => createTextIndex({
257
+ fields: ["body"],
258
+ key: (row) => row.id
259
+ }),
260
+ key: (row) => row.id,
261
+ limit: searchTopK,
262
+ source: () => store.reader.all({})
263
+ })
264
+ ];
265
+ }
213
266
  if (joinUsers !== undefined) {
214
267
  const usersHydrate = joinUsers.hydrate;
215
268
  pack.joinCollections = [
@@ -234,14 +287,167 @@ var createCommentsPack = (config) => {
234
287
  })
235
288
  ];
236
289
  }
290
+ if (reactionsConfig !== undefined) {
291
+ const allowed = reactionsConfig.allowedEmojis;
292
+ const isAllowed = (emoji) => allowed === undefined || allowed.length === 0 ? true : allowed.includes(emoji);
293
+ pack.schemas = {
294
+ ...pack.schemas ?? {},
295
+ [reactionsTable]: {
296
+ fields: {
297
+ actorId: field.string,
298
+ commentId: field.string,
299
+ createdAt: field.number,
300
+ emoji: field.string,
301
+ id: field.string
302
+ }
303
+ }
304
+ };
305
+ pack.readers = {
306
+ ...pack.readers ?? {},
307
+ [reactionsTable]: reactionReader
308
+ };
309
+ pack.writers = {
310
+ ...pack.writers ?? {},
311
+ [reactionsTable]: reactionWriter
312
+ };
313
+ pack.permissions = {
314
+ ...pack.permissions ?? {},
315
+ [reactionsTable]: {
316
+ read: (ctx, row) => {
317
+ const comment = store.getById(row.commentId);
318
+ if (comment === undefined)
319
+ return false;
320
+ return canReadResource(comment.resourceId, ctx);
321
+ },
322
+ insert: (ctx, row) => {
323
+ const callerId = getActorId(ctx);
324
+ return callerId !== undefined && row.actorId === callerId;
325
+ },
326
+ update: (ctx, row) => {
327
+ const callerId = getActorId(ctx);
328
+ return callerId !== undefined && row.actorId === callerId;
329
+ },
330
+ delete: (ctx, row) => {
331
+ const callerId = getActorId(ctx);
332
+ if (callerId === undefined)
333
+ return false;
334
+ if (row.actorId !== undefined) {
335
+ return row.actorId === callerId;
336
+ }
337
+ const id = row.id;
338
+ if (id === undefined)
339
+ return false;
340
+ return reactionStore.get(id)?.actorId === callerId;
341
+ }
342
+ }
343
+ };
344
+ pack.collections = [
345
+ ...pack.collections ?? [],
346
+ defineCollection({
347
+ name: reactionsCollectionName,
348
+ tables: [reactionsTable],
349
+ key: (row) => row.id,
350
+ hydrate: (params, ctx) => {
351
+ const comment = store.getById(params.commentId);
352
+ if (comment === undefined || !canReadResource(comment.resourceId, ctx)) {
353
+ return [];
354
+ }
355
+ return reactionReader.all(ctx).filter((row) => row.commentId === params.commentId);
356
+ },
357
+ match: (row, params, ctx) => {
358
+ if (row.commentId !== params.commentId)
359
+ return false;
360
+ const comment = store.getById(params.commentId);
361
+ return comment !== undefined && canReadResource(comment.resourceId, ctx);
362
+ },
363
+ authorize: (params, ctx) => {
364
+ const comment = store.getById(params.commentId);
365
+ return comment !== undefined && canReadResource(comment.resourceId, ctx);
366
+ }
367
+ })
368
+ ];
369
+ pack.mutations = [
370
+ ...pack.mutations ?? [],
371
+ defineMutation({
372
+ name: reactMutationName,
373
+ handler: async (args, ctx, actions) => {
374
+ if (!isAllowed(args.emoji)) {
375
+ throw new CommentReactionNotAllowedError(args.emoji);
376
+ }
377
+ const actorId = resolveActor(getActorId, ctx);
378
+ const comment = store.getById(args.commentId);
379
+ if (comment === undefined) {
380
+ throw new UnauthorizedError(`comments:react on missing comment "${args.commentId}"`);
381
+ }
382
+ if (!canReadResource(comment.resourceId, ctx)) {
383
+ throw new UnauthorizedError(`comments:react on comment "${args.commentId}" (no read access)`);
384
+ }
385
+ const id = reactionId(args.commentId, actorId, args.emoji);
386
+ const existing = reactionStore.get(id);
387
+ if (existing !== undefined)
388
+ return existing;
389
+ const row = {
390
+ actorId,
391
+ commentId: args.commentId,
392
+ createdAt: now(),
393
+ emoji: args.emoji,
394
+ id
395
+ };
396
+ return await actions.insert(reactionsTable, row);
397
+ }
398
+ }),
399
+ defineMutation({
400
+ name: unreactMutationName,
401
+ handler: async (args, ctx, actions) => {
402
+ const actorId = resolveActor(getActorId, ctx);
403
+ const id = reactionId(args.commentId, actorId, args.emoji);
404
+ if (reactionStore.get(id) === undefined)
405
+ return;
406
+ await actions.delete(reactionsTable, { id });
407
+ }
408
+ }),
409
+ defineMutation({
410
+ name: toggleReactionMutationName,
411
+ handler: async (args, ctx, actions) => {
412
+ if (!isAllowed(args.emoji)) {
413
+ throw new CommentReactionNotAllowedError(args.emoji);
414
+ }
415
+ const actorId = resolveActor(getActorId, ctx);
416
+ const comment = store.getById(args.commentId);
417
+ if (comment === undefined) {
418
+ throw new UnauthorizedError(`comments:toggleReaction on missing comment "${args.commentId}"`);
419
+ }
420
+ if (!canReadResource(comment.resourceId, ctx)) {
421
+ throw new UnauthorizedError(`comments:toggleReaction on comment "${args.commentId}" (no read access)`);
422
+ }
423
+ const id = reactionId(args.commentId, actorId, args.emoji);
424
+ const existing = reactionStore.get(id);
425
+ if (existing === undefined) {
426
+ const row = {
427
+ actorId,
428
+ commentId: args.commentId,
429
+ createdAt: now(),
430
+ emoji: args.emoji,
431
+ id
432
+ };
433
+ await actions.insert(reactionsTable, row);
434
+ return { reacted: true };
435
+ }
436
+ await actions.delete(reactionsTable, { id });
437
+ return { reacted: false };
438
+ }
439
+ })
440
+ ];
441
+ }
237
442
  return defineSyncPack(pack);
238
443
  };
239
444
  export {
240
445
  createInMemoryCommentsStore,
241
446
  createCommentsPack,
447
+ CommentReactionNotAllowedError,
242
448
  CommentParentMismatchError,
243
449
  CommentDepthExceededError
244
450
  };
245
451
 
246
- //# debugId=477C714EB1737B7764756E2164756E21
452
+ //# debugId=E866CDC5A3F3646264756E2164756E21
247
453
  //# 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. 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\tdefineCollection,\n\tdefineJoinCollection,\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<\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};\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\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.2.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 (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"
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\t/**\n\t * When set, register a `comment_reactions` table + matching collection\n\t * + react / unreact / toggleReaction mutations. Each row is one\n\t * actor's reaction with a single emoji on a single comment, deterministic\n\t * id `${commentId}:${actorId}:${emoji}` for idempotent toggling.\n\t */\n\treactions?: ReactionsConfig;\n};\n\n/** Config for the optional reactions surface. */\nexport type ReactionsConfig = {\n\t/**\n\t * Allowed emojis. Setting this filters react mutations — anything\n\t * outside the list is rejected. Empty array (default) means any\n\t * single-character or grapheme string is accepted.\n\t */\n\tallowedEmojis?: string[];\n\t/**\n\t * Custom row id generator for reaction rows. Default\n\t * `(commentId, actorId, emoji) => \\`${commentId}:${actorId}:${emoji}\\``.\n\t */\n\tnewId?: (\n\t\tcommentId: string,\n\t\tactorId: string,\n\t\temoji: string\n\t) => string;\n};\n\n/** A reaction row — one per (comment, actor, emoji). */\nexport type CommentReactionRow = {\n\tid: string;\n\tcommentId: string;\n\tactorId: string;\n\temoji: string;\n\tcreatedAt: number;\n};\n\n/** Thrown when a react mutation supplies an emoji outside `allowedEmojis`. */\nexport class CommentReactionNotAllowedError extends Error {\n\treadonly emoji: string;\n\tconstructor(emoji: string) {\n\t\tsuper(\n\t\t\t`Comment reaction \"${emoji}\" is not in the configured allowedEmojis`\n\t\t);\n\t\tthis.name = 'CommentReactionNotAllowedError';\n\t\tthis.emoji = emoji;\n\t}\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\tconst reactionsConfig = config.reactions;\n\tconst reactionsTable = `${prefix}comment_reactions`;\n\tconst reactionsCollectionName = reactionsTable;\n\tconst reactMutationName = `${prefix}comments:react`;\n\tconst unreactMutationName = `${prefix}comments:unreact`;\n\tconst toggleReactionMutationName = `${prefix}comments:toggleReaction`;\n\tconst reactionId =\n\t\treactionsConfig?.newId ??\n\t\t((commentId: string, actorId: string, emoji: string) =>\n\t\t\t`${commentId}:${actorId}:${emoji}`);\n\tconst reactionStore = new Map<string, CommentReactionRow>();\n\tconst reactionReader: TableReader<CollectionContext> = {\n\t\tall: () => [...reactionStore.values()]\n\t};\n\tconst reactionWriter: TableWriter<\n\t\tCommentReactionRow,\n\t\tCollectionContext,\n\t\tunknown\n\t> = {\n\t\tdelete: (row) => {\n\t\t\treactionStore.delete((row as { id: string }).id);\n\t\t},\n\t\tinsert: (data) => {\n\t\t\treactionStore.set(data.id, data);\n\t\t\treturn data;\n\t\t},\n\t\tupdate: (data) => {\n\t\t\treactionStore.set(data.id, data);\n\t\t\treturn data;\n\t\t}\n\t};\n\n\tconst pack: SyncPack = {\n\t\tname: '@absolutejs/sync-pack-comments',\n\t\townsTables:\n\t\t\treactionsConfig === undefined ? [table] : [table, reactionsTable],\n\t\treadsTables: joinUsers === undefined ? [] : [userTable],\n\t\tversion: '0.4.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\tif (reactionsConfig !== undefined) {\n\t\tconst allowed = reactionsConfig.allowedEmojis;\n\t\tconst isAllowed = (emoji: string): boolean =>\n\t\t\tallowed === undefined || allowed.length === 0\n\t\t\t\t? true\n\t\t\t\t: allowed.includes(emoji);\n\n\t\tpack.schemas = {\n\t\t\t...(pack.schemas ?? {}),\n\t\t\t[reactionsTable]: {\n\t\t\t\tfields: {\n\t\t\t\t\tactorId: field.string,\n\t\t\t\t\tcommentId: field.string,\n\t\t\t\t\tcreatedAt: field.number,\n\t\t\t\t\temoji: field.string,\n\t\t\t\t\tid: field.string\n\t\t\t\t}\n\t\t\t}\n\t\t};\n\t\tpack.readers = {\n\t\t\t...(pack.readers ?? {}),\n\t\t\t[reactionsTable]: reactionReader\n\t\t};\n\t\tpack.writers = {\n\t\t\t...(pack.writers ?? {}),\n\t\t\t[reactionsTable]: reactionWriter\n\t\t};\n\t\tpack.permissions = {\n\t\t\t...(pack.permissions ?? {}),\n\t\t\t[reactionsTable]: {\n\t\t\t\t// Reactions are visible to anyone who can read the comment's\n\t\t\t\t// resource. We look the comment up to gate on canReadResource.\n\t\t\t\tread: (ctx: unknown, row: CommentReactionRow) => {\n\t\t\t\t\tconst comment = store.getById(row.commentId);\n\t\t\t\t\tif (comment === undefined) return false;\n\t\t\t\t\treturn canReadResource(\n\t\t\t\t\t\tcomment.resourceId,\n\t\t\t\t\t\tctx as CollectionContext\n\t\t\t\t\t);\n\t\t\t\t},\n\t\t\t\t// Per-row writes: the row's actorId must match the caller.\n\t\t\t\tinsert: (ctx: unknown, row: CommentReactionRow) => {\n\t\t\t\t\tconst callerId = getActorId(ctx as CollectionContext);\n\t\t\t\t\treturn callerId !== undefined && row.actorId === callerId;\n\t\t\t\t},\n\t\t\t\tupdate: (ctx: unknown, row: CommentReactionRow) => {\n\t\t\t\t\tconst callerId = getActorId(ctx as CollectionContext);\n\t\t\t\t\treturn callerId !== undefined && row.actorId === callerId;\n\t\t\t\t},\n\t\t\t\tdelete: (ctx: unknown, row: CommentReactionRow) => {\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\tif (\n\t\t\t\t\t\t(row as { actorId?: string }).actorId !== undefined\n\t\t\t\t\t) {\n\t\t\t\t\t\treturn (row as { actorId: string }).actorId === callerId;\n\t\t\t\t\t}\n\t\t\t\t\tconst id = (row as { id?: string }).id;\n\t\t\t\t\tif (id === undefined) return false;\n\t\t\t\t\treturn reactionStore.get(id)?.actorId === callerId;\n\t\t\t\t}\n\t\t\t}\n\t\t};\n\n\t\tpack.collections = [\n\t\t\t...(pack.collections ?? []),\n\t\t\tdefineCollection<\n\t\t\t\tCommentReactionRow,\n\t\t\t\t{ commentId: string },\n\t\t\t\tCollectionContext\n\t\t\t>({\n\t\t\t\tname: reactionsCollectionName,\n\t\t\t\ttables: [reactionsTable],\n\t\t\t\tkey: (row) => row.id,\n\t\t\t\thydrate: (params, ctx) => {\n\t\t\t\t\tconst comment = store.getById(params.commentId);\n\t\t\t\t\tif (\n\t\t\t\t\t\tcomment === undefined ||\n\t\t\t\t\t\t!canReadResource(comment.resourceId, ctx)\n\t\t\t\t\t) {\n\t\t\t\t\t\treturn [];\n\t\t\t\t\t}\n\t\t\t\t\treturn (\n\t\t\t\t\t\treactionReader.all(ctx) as CommentReactionRow[]\n\t\t\t\t\t).filter((row) => row.commentId === params.commentId);\n\t\t\t\t},\n\t\t\t\tmatch: (row, params, ctx) => {\n\t\t\t\t\tif (row.commentId !== params.commentId) return false;\n\t\t\t\t\tconst comment = store.getById(params.commentId);\n\t\t\t\t\treturn (\n\t\t\t\t\t\tcomment !== undefined &&\n\t\t\t\t\t\tcanReadResource(comment.resourceId, ctx)\n\t\t\t\t\t);\n\t\t\t\t},\n\t\t\t\tauthorize: (params, ctx) => {\n\t\t\t\t\tconst comment = store.getById(params.commentId);\n\t\t\t\t\treturn (\n\t\t\t\t\t\tcomment !== undefined &&\n\t\t\t\t\t\tcanReadResource(comment.resourceId, ctx)\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t})\n\t\t];\n\n\t\tpack.mutations = [\n\t\t\t...(pack.mutations ?? []),\n\t\t\tdefineMutation<\n\t\t\t\t{ commentId: string; emoji: string },\n\t\t\t\tCollectionContext,\n\t\t\t\tCommentReactionRow\n\t\t\t>({\n\t\t\t\tname: reactMutationName,\n\t\t\t\thandler: async (args, ctx, actions) => {\n\t\t\t\t\tif (!isAllowed(args.emoji)) {\n\t\t\t\t\t\tthrow new CommentReactionNotAllowedError(args.emoji);\n\t\t\t\t\t}\n\t\t\t\t\tconst actorId = resolveActor(getActorId, ctx);\n\t\t\t\t\tconst comment = store.getById(args.commentId);\n\t\t\t\t\tif (comment === undefined) {\n\t\t\t\t\t\tthrow new UnauthorizedError(\n\t\t\t\t\t\t\t`comments:react on missing comment \"${args.commentId}\"`\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t\tif (!canReadResource(comment.resourceId, ctx)) {\n\t\t\t\t\t\tthrow new UnauthorizedError(\n\t\t\t\t\t\t\t`comments:react on comment \"${args.commentId}\" (no read access)`\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t\tconst id = reactionId(args.commentId, actorId, args.emoji);\n\t\t\t\t\tconst existing = reactionStore.get(id);\n\t\t\t\t\tif (existing !== undefined) return existing;\n\t\t\t\t\tconst row: CommentReactionRow = {\n\t\t\t\t\t\tactorId,\n\t\t\t\t\t\tcommentId: args.commentId,\n\t\t\t\t\t\tcreatedAt: now(),\n\t\t\t\t\t\temoji: args.emoji,\n\t\t\t\t\t\tid\n\t\t\t\t\t};\n\t\t\t\t\treturn (await actions.insert(\n\t\t\t\t\t\treactionsTable,\n\t\t\t\t\t\trow\n\t\t\t\t\t)) as CommentReactionRow;\n\t\t\t\t}\n\t\t\t}),\n\t\t\tdefineMutation<\n\t\t\t\t{ commentId: string; emoji: string },\n\t\t\t\tCollectionContext,\n\t\t\t\tvoid\n\t\t\t>({\n\t\t\t\tname: unreactMutationName,\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 id = reactionId(args.commentId, actorId, args.emoji);\n\t\t\t\t\tif (reactionStore.get(id) === undefined) return;\n\t\t\t\t\tawait actions.delete(reactionsTable, { id });\n\t\t\t\t}\n\t\t\t}),\n\t\t\tdefineMutation<\n\t\t\t\t{ commentId: string; emoji: string },\n\t\t\t\tCollectionContext,\n\t\t\t\t{ reacted: boolean }\n\t\t\t>({\n\t\t\t\tname: toggleReactionMutationName,\n\t\t\t\thandler: async (args, ctx, actions) => {\n\t\t\t\t\tif (!isAllowed(args.emoji)) {\n\t\t\t\t\t\tthrow new CommentReactionNotAllowedError(args.emoji);\n\t\t\t\t\t}\n\t\t\t\t\tconst actorId = resolveActor(getActorId, ctx);\n\t\t\t\t\tconst comment = store.getById(args.commentId);\n\t\t\t\t\tif (comment === undefined) {\n\t\t\t\t\t\tthrow new UnauthorizedError(\n\t\t\t\t\t\t\t`comments:toggleReaction on missing comment \"${args.commentId}\"`\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t\tif (!canReadResource(comment.resourceId, ctx)) {\n\t\t\t\t\t\tthrow new UnauthorizedError(\n\t\t\t\t\t\t\t`comments:toggleReaction on comment \"${args.commentId}\" (no read access)`\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t\tconst id = reactionId(args.commentId, actorId, args.emoji);\n\t\t\t\t\tconst existing = reactionStore.get(id);\n\t\t\t\t\tif (existing === undefined) {\n\t\t\t\t\t\tconst row: CommentReactionRow = {\n\t\t\t\t\t\t\tactorId,\n\t\t\t\t\t\t\tcommentId: args.commentId,\n\t\t\t\t\t\t\tcreatedAt: now(),\n\t\t\t\t\t\t\temoji: args.emoji,\n\t\t\t\t\t\t\tid\n\t\t\t\t\t\t};\n\t\t\t\t\t\tawait actions.insert(reactionsTable, row);\n\t\t\t\t\t\treturn { reacted: true };\n\t\t\t\t\t}\n\t\t\t\t\tawait actions.delete(reactionsTable, { id });\n\t\t\t\t\treturn { reacted: false };\n\t\t\t\t}\n\t\t\t})\n\t\t];\n\t}\n\n\treturn defineSyncPack(pack);\n};\n"
6
6
  ],
7
- "mappings": ";;AA0BA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAyCO,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;AAA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MAAM,QAAQ,KAAK,SAAS;AAAA,UAC5C,IAAI,YAAY,WAAW;AAAA,YAC1B,MAAM,IAAI,kBACT,+CAA+C,KAAK,YACrD;AAAA,UACD;AAAA,UACA,IAAI,CAAC,gBAAgB,QAAQ,YAAY,GAAG,GAAG;AAAA,YAC9C,MAAM,IAAI,kBACT,uCAAuC,KAAK,6BAC7C;AAAA,UACD;AAAA,UACA,MAAM,KAAK,WAAW,KAAK,WAAW,SAAS,KAAK,KAAK;AAAA,UACzD,MAAM,WAAW,cAAc,IAAI,EAAE;AAAA,UACrC,IAAI,aAAa,WAAW;AAAA,YAC3B,MAAM,MAA0B;AAAA,cAC/B;AAAA,cACA,WAAW,KAAK;AAAA,cAChB,WAAW,IAAI;AAAA,cACf,OAAO,KAAK;AAAA,cACZ;AAAA,YACD;AAAA,YACA,MAAM,QAAQ,OAAO,gBAAgB,GAAG;AAAA,YACxC,OAAO,EAAE,SAAS,KAAK;AAAA,UACxB;AAAA,UACA,MAAM,QAAQ,OAAO,gBAAgB,EAAE,GAAG,CAAC;AAAA,UAC3C,OAAO,EAAE,SAAS,MAAM;AAAA;AAAA,MAE1B,CAAC;AAAA,IACF;AAAA,EACD;AAAA,EAEA,OAAO,eAAe,IAAI;AAAA;",
8
+ "debugId": "E866CDC5A3F3646264756E2164756E21",
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.2.0",
3
+ "version": "0.4.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",