@molecule/api-resource-comment 1.3.0 → 1.4.1
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 +25 -2
- package/dist/authorizers/index.d.ts +3 -1
- package/dist/authorizers/index.d.ts.map +1 -1
- package/dist/authorizers/index.js +8 -3
- package/dist/handlers/list.js +1 -1
- package/dist/handlers/replies.js +1 -1
- package/dist/service.d.ts.map +1 -1
- package/dist/service.js +45 -6
- package/dist/types.d.ts +15 -0
- package/dist/types.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/__setup__/comments.sql +1 -0
package/README.md
CHANGED
|
@@ -3,7 +3,7 @@ AUTO-GENERATED — DO NOT EDIT THIS FILE.
|
|
|
3
3
|
Generated by `mlcl sync-docs` from the package's src/index.ts JSDoc + mlcl/registry.json.
|
|
4
4
|
Edits here are overwritten on the next commit (molecule's pre-commit hook regenerates).
|
|
5
5
|
To change this document, edit the module-level JSDoc in src/index.ts.
|
|
6
|
-
Generated: 2026-11-
|
|
6
|
+
Generated: 2026-11-30T00:33:26.456Z
|
|
7
7
|
-->
|
|
8
8
|
|
|
9
9
|
# @molecule/api-resource-comment
|
|
@@ -69,6 +69,25 @@ interface CommentResourceAccessContext {
|
|
|
69
69
|
}
|
|
70
70
|
```
|
|
71
71
|
|
|
72
|
+
#### `CommentAuthor`
|
|
73
|
+
|
|
74
|
+
Public display profile attached to a comment when `@molecule/api-resource-user` is loaded.
|
|
75
|
+
|
|
76
|
+
```typescript
|
|
77
|
+
interface CommentAuthor {
|
|
78
|
+
/** The user's canonical id. */
|
|
79
|
+
id: string
|
|
80
|
+
/** The public username, when set. */
|
|
81
|
+
username: string | null
|
|
82
|
+
/** The public display name, when set. */
|
|
83
|
+
name: string | null
|
|
84
|
+
/** The public biography, when set. */
|
|
85
|
+
bio: string | null
|
|
86
|
+
/** The public avatar URL, when set. */
|
|
87
|
+
avatar: string | null
|
|
88
|
+
}
|
|
89
|
+
```
|
|
90
|
+
|
|
72
91
|
#### `Comment`
|
|
73
92
|
|
|
74
93
|
A comment attached to a resource, with optional threading via `parentId`.
|
|
@@ -85,6 +104,8 @@ interface Comment {
|
|
|
85
104
|
resourceId: string
|
|
86
105
|
/** The ID of the user who created this comment. */
|
|
87
106
|
userId: string
|
|
107
|
+
/** Hydrated public author profile when `@molecule/api-resource-user` is loaded. */
|
|
108
|
+
author?: CommentAuthor | null
|
|
88
109
|
/** The parent comment ID for threaded replies, or `null` for top-level comments. */
|
|
89
110
|
parentId: string | null
|
|
90
111
|
/** The comment body text. */
|
|
@@ -273,7 +294,9 @@ function hasResourceAccessPolicies(): boolean
|
|
|
273
294
|
#### `canAccessCommentResource(resourceType, resourceId, action, viewerId)`
|
|
274
295
|
|
|
275
296
|
Evaluates the registered access policy for `(resourceType, resourceId)`.
|
|
276
|
-
|
|
297
|
+
When no policies are registered at all, returns `true`. Once any resource
|
|
298
|
+
access policy is registered, unregistered resource types fail closed (`false`)
|
|
299
|
+
unless a `'*'` wildcard policy explicitly allows them.
|
|
277
300
|
|
|
278
301
|
```typescript
|
|
279
302
|
function canAccessCommentResource(
|
|
@@ -89,7 +89,9 @@ export declare function getResourceAccessPolicy(resourceType: string): CommentRe
|
|
|
89
89
|
export declare function hasResourceAccessPolicies(): boolean;
|
|
90
90
|
/**
|
|
91
91
|
* Evaluates the registered access policy for `(resourceType, resourceId)`.
|
|
92
|
-
*
|
|
92
|
+
* When no policies are registered at all, returns `true`. Once any resource
|
|
93
|
+
* access policy is registered, unregistered resource types fail closed (`false`)
|
|
94
|
+
* unless a `'*'` wildcard policy explicitly allows them.
|
|
93
95
|
*
|
|
94
96
|
* @param resourceType - Canonical resource type slug.
|
|
95
97
|
* @param resourceId - The parent resource identifier.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/authorizers/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH;;GAEG;AACH,MAAM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AwB,CAC5C,YAAY,EAAE,MAAM,EACpB,UAAU,EAAE,MAAM,EAClB,MAAM,EAAE,qBAAqB,EAC7B,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,GACvB,OAAO,CAAC,OAAO,CAAC,CAMlB"}
|
|
@@ -98,7 +98,9 @@ export function hasResourceAccessPolicies() {
|
|
|
98
98
|
}
|
|
99
99
|
/**
|
|
100
100
|
* Evaluates the registered access policy for `(resourceType, resourceId)`.
|
|
101
|
-
*
|
|
101
|
+
* When no policies are registered at all, returns `true`. Once any resource
|
|
102
|
+
* access policy is registered, unregistered resource types fail closed (`false`)
|
|
103
|
+
* unless a `'*'` wildcard policy explicitly allows them.
|
|
102
104
|
*
|
|
103
105
|
* @param resourceType - Canonical resource type slug.
|
|
104
106
|
* @param resourceId - The parent resource identifier.
|
|
@@ -107,8 +109,11 @@ export function hasResourceAccessPolicies() {
|
|
|
107
109
|
* @returns Whether access is permitted.
|
|
108
110
|
*/
|
|
109
111
|
export async function canAccessCommentResource(resourceType, resourceId, action, viewerId) {
|
|
110
|
-
const
|
|
111
|
-
if (
|
|
112
|
+
const policies = getPolicyMap();
|
|
113
|
+
if (policies.size === 0)
|
|
112
114
|
return true;
|
|
115
|
+
const policy = policies.get(resourceType) ?? policies.get('*');
|
|
116
|
+
if (!policy)
|
|
117
|
+
return false;
|
|
113
118
|
return Boolean(await policy({ resourceType, resourceId, action, viewerId }));
|
|
114
119
|
}
|
package/dist/handlers/list.js
CHANGED
|
@@ -27,7 +27,7 @@ export async function list(req, res) {
|
|
|
27
27
|
return;
|
|
28
28
|
}
|
|
29
29
|
const limit = Math.min(MAX_LIST_LIMIT, Math.max(1, parseInt(req.query.limit, 10) || 20));
|
|
30
|
-
const offset = parseInt(req.query.offset, 10) || 0;
|
|
30
|
+
const offset = Math.max(0, parseInt(req.query.offset, 10) || 0);
|
|
31
31
|
const viewerId = res.locals.session?.userId;
|
|
32
32
|
try {
|
|
33
33
|
if (!(await canAccessCommentResource(resourceType, resourceId, 'read', viewerId))) {
|
package/dist/handlers/replies.js
CHANGED
|
@@ -25,7 +25,7 @@ export async function replies(req, res) {
|
|
|
25
25
|
return;
|
|
26
26
|
}
|
|
27
27
|
const limit = Math.min(MAX_LIST_LIMIT, Math.max(1, parseInt(req.query.limit, 10) || 20));
|
|
28
|
-
const offset = parseInt(req.query.offset, 10) || 0;
|
|
28
|
+
const offset = Math.max(0, parseInt(req.query.offset, 10) || 0);
|
|
29
29
|
const viewerId = res.locals.session?.userId;
|
|
30
30
|
try {
|
|
31
31
|
if (hasResourceAccessPolicies()) {
|
package/dist/service.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"service.d.ts","sourceRoot":"","sources":["../src/service.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;
|
|
1
|
+
{"version":3,"file":"service.d.ts","sourceRoot":"","sources":["../src/service.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAqBH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,cAAc,CAAA;AACnD,OAAO,KAAK,EACV,OAAO,EAEP,kBAAkB,EAClB,eAAe,EACf,iBAAiB,EACjB,kBAAkB,EACnB,MAAM,YAAY,CAAA;AAqCnB;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAsB,aAAa,CACjC,YAAY,EAAE,MAAM,EACpB,UAAU,EAAE,MAAM,EAClB,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,kBAAkB,GACvB,OAAO,CAAC,eAAe,CAAC,CAoE1B;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAsB,qBAAqB,CACzC,YAAY,EAAE,MAAM,EACpB,UAAU,EAAE,MAAM,EAClB,OAAO,GAAE,iBAAsB,GAC9B,OAAO,CAAC,eAAe,CAAC,OAAO,CAAC,CAAC,CAqBnC;AAED;;;;;;GAMG;AACH,wBAAsB,cAAc,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,GAAG,IAAI,CAAC,CAK/E;AAED;;;;;;;;GAQG;AACH,wBAAsB,aAAa,CACjC,SAAS,EAAE,MAAM,EACjB,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,kBAAkB,GACvB,OAAO,CAAC,OAAO,GAAG,IAAI,CAAC,CAgBzB;AAED;;;;;;;;GAQG;AACH,wBAAsB,aAAa,CAAC,SAAS,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAMvF;AAED;;;;;;;GAOG;AACH,wBAAsB,UAAU,CAC9B,SAAS,EAAE,MAAM,EACjB,OAAO,GAAE,iBAAsB,GAC9B,OAAO,CAAC,eAAe,CAAC,OAAO,CAAC,CAAC,CAiBnC;AAED;;;;;;GAMG;AACH,wBAAsB,eAAe,CAAC,YAAY,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAK/F"}
|
package/dist/service.js
CHANGED
|
@@ -7,16 +7,39 @@
|
|
|
7
7
|
* @module
|
|
8
8
|
*/
|
|
9
9
|
import { count, create as dbCreate, deleteById, findById, findMany, getActiveTransaction, getPool, hasPool, updateById, withTransaction, } from '@molecule/api-database';
|
|
10
|
-
import { CommentResourceAccessError, getResourceAccessPolicy } from './authorizers/index.js';
|
|
10
|
+
import { CommentResourceAccessError, getResourceAccessPolicy, hasResourceAccessPolicies, } from './authorizers/index.js';
|
|
11
11
|
import { allocateCommentNumber, numbersForComments } from './numbering.js';
|
|
12
12
|
const TABLE = 'comments';
|
|
13
|
+
const PUBLIC_PROFILES_KEY = Symbol.for('@molecule/api-resource/public-profiles');
|
|
14
|
+
/** Load public author profiles in one batch query when `@molecule/api-resource-user` is loaded. */
|
|
15
|
+
async function withAuthors(comments) {
|
|
16
|
+
if (comments.length === 0)
|
|
17
|
+
return comments;
|
|
18
|
+
const loader = globalThis[PUBLIC_PROFILES_KEY];
|
|
19
|
+
if (!loader)
|
|
20
|
+
return comments;
|
|
21
|
+
try {
|
|
22
|
+
const profiles = await loader(comments.map((comment) => comment.userId));
|
|
23
|
+
if (profiles.size === 0)
|
|
24
|
+
return comments;
|
|
25
|
+
return comments.map((comment) => {
|
|
26
|
+
const author = profiles.get(comment.userId);
|
|
27
|
+
return author ? { ...comment, author } : comment;
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
catch (_error) {
|
|
31
|
+
// Users table may be absent in isolated comment-only unit tests.
|
|
32
|
+
return comments;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
13
35
|
/** Keep a page's stable integer identities beside its UUIDs without allocating on read. */
|
|
14
36
|
async function withNumbers(comments) {
|
|
15
37
|
const numbers = await numbersForComments(comments.map((comment) => comment.id));
|
|
16
|
-
|
|
38
|
+
const numbered = comments.map((comment) => {
|
|
17
39
|
const number = numbers.get(comment.id);
|
|
18
40
|
return number === undefined ? comment : { ...comment, number };
|
|
19
41
|
});
|
|
42
|
+
return withAuthors(numbered);
|
|
20
43
|
}
|
|
21
44
|
/**
|
|
22
45
|
* Creates a new comment on a resource, with its sequential number.
|
|
@@ -41,9 +64,13 @@ async function withNumbers(comments) {
|
|
|
41
64
|
* removed again so the caller is not told a create failed while it exists.
|
|
42
65
|
*/
|
|
43
66
|
export async function createComment(resourceType, resourceId, userId, data) {
|
|
67
|
+
const hasPolicies = hasResourceAccessPolicies();
|
|
44
68
|
const policy = getResourceAccessPolicy(resourceType);
|
|
45
69
|
const execute = async () => {
|
|
46
|
-
if (
|
|
70
|
+
if (hasPolicies) {
|
|
71
|
+
if (!policy) {
|
|
72
|
+
throw new CommentResourceAccessError(resourceType, resourceId);
|
|
73
|
+
}
|
|
47
74
|
const allowed = await policy({
|
|
48
75
|
resourceType,
|
|
49
76
|
resourceId,
|
|
@@ -64,7 +91,12 @@ export async function createComment(resourceType, resourceId, userId, data) {
|
|
|
64
91
|
});
|
|
65
92
|
const comment = result.data;
|
|
66
93
|
try {
|
|
67
|
-
|
|
94
|
+
const numbered = {
|
|
95
|
+
...comment,
|
|
96
|
+
number: await allocateCommentNumber(comment.id),
|
|
97
|
+
};
|
|
98
|
+
const [hydrated] = await withAuthors([numbered]);
|
|
99
|
+
return hydrated;
|
|
68
100
|
}
|
|
69
101
|
catch (error) {
|
|
70
102
|
// Inside a transaction, throwing rolls back the inserted row automatically.
|
|
@@ -133,7 +165,11 @@ export async function getCommentsByResource(resourceType, resourceId, options =
|
|
|
133
165
|
* @returns The comment or `null` if not found.
|
|
134
166
|
*/
|
|
135
167
|
export async function getCommentById(commentId) {
|
|
136
|
-
|
|
168
|
+
const comment = await findById(TABLE, commentId);
|
|
169
|
+
if (!comment)
|
|
170
|
+
return null;
|
|
171
|
+
const [hydrated] = await withAuthors([comment]);
|
|
172
|
+
return hydrated ?? comment;
|
|
137
173
|
}
|
|
138
174
|
/**
|
|
139
175
|
* Updates a comment. Only the comment owner can update.
|
|
@@ -155,7 +191,10 @@ export async function updateComment(commentId, userId, data) {
|
|
|
155
191
|
// still shows a changed updatedAt.
|
|
156
192
|
updatedAt: new Date(Math.max(Date.now(), (Date.parse(String(existing.updatedAt ?? '')) || 0) + 1)).toISOString(),
|
|
157
193
|
});
|
|
158
|
-
|
|
194
|
+
if (!result.data)
|
|
195
|
+
return null;
|
|
196
|
+
const [hydrated] = await withAuthors([result.data]);
|
|
197
|
+
return hydrated ?? result.data;
|
|
159
198
|
}
|
|
160
199
|
/**
|
|
161
200
|
* Deletes a comment. Only the comment owner can delete.
|
package/dist/types.d.ts
CHANGED
|
@@ -6,6 +6,19 @@
|
|
|
6
6
|
*
|
|
7
7
|
* @module
|
|
8
8
|
*/
|
|
9
|
+
/** Public display profile attached to a comment when `@molecule/api-resource-user` is loaded. */
|
|
10
|
+
export interface CommentAuthor {
|
|
11
|
+
/** The user's canonical id. */
|
|
12
|
+
id: string;
|
|
13
|
+
/** The public username, when set. */
|
|
14
|
+
username: string | null;
|
|
15
|
+
/** The public display name, when set. */
|
|
16
|
+
name: string | null;
|
|
17
|
+
/** The public biography, when set. */
|
|
18
|
+
bio: string | null;
|
|
19
|
+
/** The public avatar URL, when set. */
|
|
20
|
+
avatar: string | null;
|
|
21
|
+
}
|
|
9
22
|
/**
|
|
10
23
|
* A comment attached to a resource, with optional threading via `parentId`.
|
|
11
24
|
*/
|
|
@@ -20,6 +33,8 @@ export interface Comment {
|
|
|
20
33
|
resourceId: string;
|
|
21
34
|
/** The ID of the user who created this comment. */
|
|
22
35
|
userId: string;
|
|
36
|
+
/** Hydrated public author profile when `@molecule/api-resource-user` is loaded. */
|
|
37
|
+
author?: CommentAuthor | null;
|
|
23
38
|
/** The parent comment ID for threaded replies, or `null` for top-level comments. */
|
|
24
39
|
parentId: string | null;
|
|
25
40
|
/** The comment body text. */
|
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH;;GAEG;AACH,MAAM,WAAW,OAAO;IACtB,iCAAiC;IACjC,EAAE,EAAE,MAAM,CAAA;IACV,4FAA4F;IAC5F,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,iFAAiF;IACjF,YAAY,EAAE,MAAM,CAAA;IACpB,0DAA0D;IAC1D,UAAU,EAAE,MAAM,CAAA;IAClB,mDAAmD;IACnD,MAAM,EAAE,MAAM,CAAA;IACd,oFAAoF;IACpF,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAA;IACvB,6BAA6B;IAC7B,IAAI,EAAE,MAAM,CAAA;IACZ,mEAAmE;IACnE,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAA;IACvB,+CAA+C;IAC/C,SAAS,EAAE,MAAM,CAAA;IACjB,oDAAoD;IACpD,SAAS,EAAE,MAAM,CAAA;CAClB;AAED;;GAEG;AACH,MAAM,WAAW,kBAAkB;IACjC,6BAA6B;IAC7B,IAAI,EAAE,MAAM,CAAA;IACZ,uDAAuD;IACvD,QAAQ,CAAC,EAAE,MAAM,CAAA;CAClB;AAED;;GAEG;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AAG,IAAI,CAAA;IACvB,6BAA6B;IAC7B,IAAI,EAAE,MAAM,CAAA;IACZ,mEAAmE;IACnE,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAA;IACvB,+CAA+C;IAC/C,SAAS,EAAE,MAAM,CAAA;IACjB,oDAAoD;IACpD,SAAS,EAAE,MAAM,CAAA;CAClB;AAED;;GAEG;AACH,MAAM,WAAW,kBAAkB;IACjC,6BAA6B;IAC7B,IAAI,EAAE,MAAM,CAAA;IACZ,uDAAuD;IACvD,QAAQ,CAAC,EAAE,MAAM,CAAA;CAClB;AAED;;GAEG;AACH,MAAM,WAAW,kBAAkB;IACjC,qCAAqC;IACrC,IAAI,EAAE,MAAM,CAAA;CACb;AAED;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC,2CAA2C;IAC3C,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,iCAAiC;IACjC,MAAM,CAAC,EAAE,MAAM,CAAA;CAChB;AAED;;GAEG;AACH,MAAM,WAAW,eAAe,CAAC,CAAC;IAChC,6CAA6C;IAC7C,IAAI,EAAE,CAAC,EAAE,CAAA;IACT,uDAAuD;IACvD,KAAK,EAAE,MAAM,CAAA;IACb,0CAA0C;IAC1C,KAAK,EAAE,MAAM,CAAA;IACb,iCAAiC;IACjC,MAAM,EAAE,MAAM,CAAA;CACf"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@molecule/api-resource-comment",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.4.1",
|
|
4
4
|
"description": "Threaded comments on any resource with polymorphic attachment, pagination and sequential integer comment numbers (createNumberedComment)",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -11,5 +11,6 @@ CREATE TABLE IF NOT EXISTS "comments" (
|
|
|
11
11
|
);
|
|
12
12
|
|
|
13
13
|
CREATE INDEX IF NOT EXISTS "idx_comments_resource" ON "comments" ("resourceType", "resourceId");
|
|
14
|
+
CREATE INDEX IF NOT EXISTS "idx_comments_resource_created" ON "comments" ("resourceType", "resourceId", "createdAt");
|
|
14
15
|
CREATE INDEX IF NOT EXISTS "idx_comments_parent" ON "comments" ("parentId");
|
|
15
16
|
CREATE INDEX IF NOT EXISTS "idx_comments_user" ON "comments" ("userId");
|