@molecule/api-resource-article 1.2.3 → 1.2.5
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 +4 -1
- package/dist/handlers/shared.js +1 -1
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -0
- package/dist/service.js +16 -7
- package/package.json +3 -3
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-12T17:31:34.825Z
|
|
7
7
|
-->
|
|
8
8
|
|
|
9
9
|
# @molecule/api-resource-article
|
|
@@ -753,6 +753,9 @@ Peer dependencies:
|
|
|
753
753
|
call `allTags()` for that endpoint, and pass a `limit` only where the caller
|
|
754
754
|
asked for the N most-used. The package's own `GET /articles/tags` route does
|
|
755
755
|
exactly this: no `?limit=` is the whole list.
|
|
756
|
+
Catalog counts scan bounded pages through the bonded database; a provider's
|
|
757
|
+
single-read safety cap never truncates the catalog or its popularity counts.
|
|
758
|
+
|
|
756
759
|
- **Lists are newest first and paginated** — `{ data, total, limit, offset }`,
|
|
757
760
|
at most 100 per page. `createArticle` stamps `createdAt` strictly increasing
|
|
758
761
|
and `updateArticle` always moves `updatedAt` forward, so newest-first order
|
package/dist/handlers/shared.js
CHANGED
|
@@ -19,7 +19,7 @@ export const sessionUserId = (res) => res.locals.session?.userId;
|
|
|
19
19
|
export const unauthorized = () => ({
|
|
20
20
|
statusCode: 401,
|
|
21
21
|
body: {
|
|
22
|
-
error: t('resource.error.unauthorized', undefined, { defaultValue: 'Unauthorized' }),
|
|
22
|
+
error: t('resource.error.unauthorized', undefined, { defaultValue: 'Unauthorized.' }),
|
|
23
23
|
errorKey: 'resource.error.unauthorized',
|
|
24
24
|
},
|
|
25
25
|
});
|
package/dist/index.d.ts
CHANGED
|
@@ -138,6 +138,9 @@
|
|
|
138
138
|
* call `allTags()` for that endpoint, and pass a `limit` only where the caller
|
|
139
139
|
* asked for the N most-used. The package's own `GET /articles/tags` route does
|
|
140
140
|
* exactly this: no `?limit=` is the whole list.
|
|
141
|
+
* Catalog counts scan bounded pages through the bonded database; a provider's
|
|
142
|
+
* single-read safety cap never truncates the catalog or its popularity counts.
|
|
143
|
+
*
|
|
141
144
|
* - **Lists are newest first and paginated** — `{ data, total, limit, offset }`,
|
|
142
145
|
* at most 100 per page. `createArticle` stamps `createdAt` strictly increasing
|
|
143
146
|
* and `updateArticle` always moves `updatedAt` forward, so newest-first order
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+KG;AAEH,cAAc,wBAAwB,CAAA;AACtC,cAAc,oBAAoB,CAAA;AAClC,cAAc,qBAAqB,CAAA;AACnC,cAAc,wBAAwB,CAAA;AACtC,cAAc,aAAa,CAAA;AAC3B,cAAc,cAAc,CAAA;AAC5B,cAAc,YAAY,CAAA;AAC1B,cAAc,iBAAiB,CAAA"}
|
package/dist/index.js
CHANGED
|
@@ -138,6 +138,9 @@
|
|
|
138
138
|
* call `allTags()` for that endpoint, and pass a `limit` only where the caller
|
|
139
139
|
* asked for the N most-used. The package's own `GET /articles/tags` route does
|
|
140
140
|
* exactly this: no `?limit=` is the whole list.
|
|
141
|
+
* Catalog counts scan bounded pages through the bonded database; a provider's
|
|
142
|
+
* single-read safety cap never truncates the catalog or its popularity counts.
|
|
143
|
+
*
|
|
141
144
|
* - **Lists are newest first and paginated** — `{ data, total, limit, offset }`,
|
|
142
145
|
* at most 100 per page. `createArticle` stamps `createdAt` strictly increasing
|
|
143
146
|
* and `updateArticle` always moves `updatedAt` forward, so newest-first order
|
package/dist/service.js
CHANGED
|
@@ -404,14 +404,23 @@ export async function popularTags(limit = 20) {
|
|
|
404
404
|
* @returns Every tag in use.
|
|
405
405
|
*/
|
|
406
406
|
const countTagRows = async () => {
|
|
407
|
-
const rows = await findMany(ARTICLE_TAGS, {
|
|
408
|
-
orderBy: TAGS_IN_ARTICLE_ORDER,
|
|
409
|
-
select: ['tag'],
|
|
410
|
-
limit: 50_000,
|
|
411
|
-
});
|
|
412
407
|
const counts = new Map();
|
|
413
|
-
|
|
414
|
-
|
|
408
|
+
// DataStore providers cap a single read. Count every page in a total order, so
|
|
409
|
+
// the complete catalog and leaderboard counts never silently become a prefix.
|
|
410
|
+
const pageSize = 1_000;
|
|
411
|
+
for (let offset = 0;;) {
|
|
412
|
+
const rows = await findMany(ARTICLE_TAGS, {
|
|
413
|
+
orderBy: [{ field: 'id', direction: 'asc' }],
|
|
414
|
+
select: ['tag'],
|
|
415
|
+
limit: pageSize,
|
|
416
|
+
offset,
|
|
417
|
+
});
|
|
418
|
+
for (const row of rows)
|
|
419
|
+
counts.set(row.tag, (counts.get(row.tag) ?? 0) + 1);
|
|
420
|
+
if (rows.length < pageSize)
|
|
421
|
+
break;
|
|
422
|
+
offset += rows.length;
|
|
423
|
+
}
|
|
415
424
|
return [...counts.entries()]
|
|
416
425
|
.sort((a, b) => b[1] - a[1] || a[0].localeCompare(b[0]))
|
|
417
426
|
.map(([tag, n]) => ({ tag, count: n }));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@molecule/api-resource-article",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.5",
|
|
4
4
|
"description": "Articles and blog posts: unique slugs, tags, favorites, a followed-authors feed, and filtered, paginated lists",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -35,8 +35,8 @@
|
|
|
35
35
|
"devDependencies": {
|
|
36
36
|
"@molecule/api-database": "1.2.2",
|
|
37
37
|
"@molecule/api-database-sqlite": "1.4.3",
|
|
38
|
-
"@molecule/api-resource-follow": "1.1.
|
|
39
|
-
"@molecule/api-resource-reaction": "1.0.
|
|
38
|
+
"@molecule/api-resource-follow": "1.1.1",
|
|
39
|
+
"@molecule/api-resource-reaction": "1.0.8",
|
|
40
40
|
"@molecule/api-slug": "1.0.3",
|
|
41
41
|
"@types/express": "5.0.6",
|
|
42
42
|
"@types/node": "26.6.5",
|