@molecule/api-resource-article 1.2.1 → 1.2.3
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 +20 -1
- package/dist/index.d.ts +19 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +19 -0
- package/package.json +2 -2
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-12T13:52:29.161Z
|
|
7
7
|
-->
|
|
8
8
|
|
|
9
9
|
# @molecule/api-resource-article
|
|
@@ -30,6 +30,11 @@ and `tags` in the package.
|
|
|
30
30
|
can batch-load author profiles, omit fields from list items, rename pagination
|
|
31
31
|
keys, wrap results, or translate error statuses and bodies. It receives errors
|
|
32
32
|
and empty deletes too. Set the authenticated user on `res.locals.session.userId`.
|
|
33
|
+
For profile projection, pass the page's `authorId`s once to
|
|
34
|
+
`getPublicProfiles(ids)` from `@molecule/api-resource-user` and
|
|
35
|
+
`getFollowedIds(viewerId, 'user', ids)` from `@molecule/api-resource-follow`.
|
|
36
|
+
Join those maps while projecting the page. This keeps the page at two relationship
|
|
37
|
+
queries even when many entries share an author; per-entry lookups repeat the same work.
|
|
33
38
|
|
|
34
39
|
```typescript
|
|
35
40
|
import { createArticleHandlers } from '@molecule/api-resource-article'
|
|
@@ -48,6 +53,20 @@ create separate maps with separate options. The static `requestHandlerMap` keeps
|
|
|
48
53
|
native flat-body/raw-article format. Use service functions for a different domain workflow.
|
|
49
54
|
Read Quick Start for filter mapping and early responses.
|
|
50
55
|
|
|
56
|
+
**Need only a lookup in a custom route?** `findArticleRow(slug)` returns the stored
|
|
57
|
+
`ArticleRow` or `null`. `getArticleBySlug(slug, viewerId?)` returns an `Article` or
|
|
58
|
+
`null`, with ordered tags, favorite count and the viewer's `favorited` state.
|
|
59
|
+
Both read this package's `articles` table. Keep your route, author-profile lookup
|
|
60
|
+
and response projection local; call these functions instead of copying the slug query.
|
|
61
|
+
|
|
62
|
+
```typescript
|
|
63
|
+
import { findArticleRow } from '@molecule/api-resource-article'
|
|
64
|
+
|
|
65
|
+
const slug = 'release-notes'
|
|
66
|
+
const row = await findArticleRow(slug)
|
|
67
|
+
// Map row (or null) into this API's response. Use getArticleBySlug for hydrated fields.
|
|
68
|
+
```
|
|
69
|
+
|
|
51
70
|
> **Auto-generated, AI-first package reference** for the [molecule.dev](https://molecule.dev) ecosystem.
|
|
52
71
|
> It is written to be read by coding agents as much as by people, and is generated from this
|
|
53
72
|
> package's source — edit `src/index.ts` JSDoc, not this file.
|
package/dist/index.d.ts
CHANGED
|
@@ -21,6 +21,11 @@
|
|
|
21
21
|
* can batch-load author profiles, omit fields from list items, rename pagination
|
|
22
22
|
* keys, wrap results, or translate error statuses and bodies. It receives errors
|
|
23
23
|
* and empty deletes too. Set the authenticated user on `res.locals.session.userId`.
|
|
24
|
+
* For profile projection, pass the page's `authorId`s once to
|
|
25
|
+
* `getPublicProfiles(ids)` from `@molecule/api-resource-user` and
|
|
26
|
+
* `getFollowedIds(viewerId, 'user', ids)` from `@molecule/api-resource-follow`.
|
|
27
|
+
* Join those maps while projecting the page. This keeps the page at two relationship
|
|
28
|
+
* queries even when many entries share an author; per-entry lookups repeat the same work.
|
|
24
29
|
*
|
|
25
30
|
* ```typescript
|
|
26
31
|
* import { createArticleHandlers } from '@molecule/api-resource-article'
|
|
@@ -38,6 +43,20 @@
|
|
|
38
43
|
* native flat-body/raw-article format. Use service functions for a different domain workflow.
|
|
39
44
|
* Read Quick Start for filter mapping and early responses.
|
|
40
45
|
*
|
|
46
|
+
* **Need only a lookup in a custom route?** `findArticleRow(slug)` returns the stored
|
|
47
|
+
* `ArticleRow` or `null`. `getArticleBySlug(slug, viewerId?)` returns an `Article` or
|
|
48
|
+
* `null`, with ordered tags, favorite count and the viewer's `favorited` state.
|
|
49
|
+
* Both read this package's `articles` table. Keep your route, author-profile lookup
|
|
50
|
+
* and response projection local; call these functions instead of copying the slug query.
|
|
51
|
+
*
|
|
52
|
+
* ```typescript
|
|
53
|
+
* import { findArticleRow } from '@molecule/api-resource-article'
|
|
54
|
+
*
|
|
55
|
+
* const slug = 'release-notes'
|
|
56
|
+
* const row = await findArticleRow(slug)
|
|
57
|
+
* // Map row (or null) into this API's response. Use getArticleBySlug for hydrated fields.
|
|
58
|
+
* ```
|
|
59
|
+
*
|
|
41
60
|
* @module
|
|
42
61
|
* @example
|
|
43
62
|
* ```typescript
|
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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4KG;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
|
@@ -21,6 +21,11 @@
|
|
|
21
21
|
* can batch-load author profiles, omit fields from list items, rename pagination
|
|
22
22
|
* keys, wrap results, or translate error statuses and bodies. It receives errors
|
|
23
23
|
* and empty deletes too. Set the authenticated user on `res.locals.session.userId`.
|
|
24
|
+
* For profile projection, pass the page's `authorId`s once to
|
|
25
|
+
* `getPublicProfiles(ids)` from `@molecule/api-resource-user` and
|
|
26
|
+
* `getFollowedIds(viewerId, 'user', ids)` from `@molecule/api-resource-follow`.
|
|
27
|
+
* Join those maps while projecting the page. This keeps the page at two relationship
|
|
28
|
+
* queries even when many entries share an author; per-entry lookups repeat the same work.
|
|
24
29
|
*
|
|
25
30
|
* ```typescript
|
|
26
31
|
* import { createArticleHandlers } from '@molecule/api-resource-article'
|
|
@@ -38,6 +43,20 @@
|
|
|
38
43
|
* native flat-body/raw-article format. Use service functions for a different domain workflow.
|
|
39
44
|
* Read Quick Start for filter mapping and early responses.
|
|
40
45
|
*
|
|
46
|
+
* **Need only a lookup in a custom route?** `findArticleRow(slug)` returns the stored
|
|
47
|
+
* `ArticleRow` or `null`. `getArticleBySlug(slug, viewerId?)` returns an `Article` or
|
|
48
|
+
* `null`, with ordered tags, favorite count and the viewer's `favorited` state.
|
|
49
|
+
* Both read this package's `articles` table. Keep your route, author-profile lookup
|
|
50
|
+
* and response projection local; call these functions instead of copying the slug query.
|
|
51
|
+
*
|
|
52
|
+
* ```typescript
|
|
53
|
+
* import { findArticleRow } from '@molecule/api-resource-article'
|
|
54
|
+
*
|
|
55
|
+
* const slug = 'release-notes'
|
|
56
|
+
* const row = await findArticleRow(slug)
|
|
57
|
+
* // Map row (or null) into this API's response. Use getArticleBySlug for hydrated fields.
|
|
58
|
+
* ```
|
|
59
|
+
*
|
|
41
60
|
* @module
|
|
42
61
|
* @example
|
|
43
62
|
* ```typescript
|
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.3",
|
|
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,7 +35,7 @@
|
|
|
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.0
|
|
38
|
+
"@molecule/api-resource-follow": "1.1.0",
|
|
39
39
|
"@molecule/api-resource-reaction": "1.0.7",
|
|
40
40
|
"@molecule/api-slug": "1.0.3",
|
|
41
41
|
"@types/express": "5.0.6",
|