@molecule/api-resource-article 1.2.5 → 1.2.7
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 +11 -8
- package/dist/service.d.ts +4 -4
- package/dist/service.d.ts.map +1 -1
- package/dist/service.js +2 -2
- package/dist/types.d.ts +6 -3
- package/dist/types.d.ts.map +1 -1
- package/package.json +1 -1
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-15T03:10:10.469Z
|
|
7
7
|
-->
|
|
8
8
|
|
|
9
9
|
# @molecule/api-resource-article
|
|
@@ -138,7 +138,10 @@ npm install @molecule/api-resource-article @molecule/api-database @molecule/api-
|
|
|
138
138
|
|
|
139
139
|
#### `ArticleRow`
|
|
140
140
|
|
|
141
|
-
An article row as stored. `tagList` is a JSON array of tag names
|
|
141
|
+
An article row as stored. `tagList` is a JSON array of tag names, in the order they were
|
|
142
|
+
given, and it is what every article response returns. The `article_tags` table holds the same
|
|
143
|
+
tags one row each, for the tag filter and the tag lists. `createArticle` and `updateArticle`
|
|
144
|
+
write both, so an app that goes through this package never keeps them in step itself.
|
|
142
145
|
|
|
143
146
|
```typescript
|
|
144
147
|
interface ArticleRow {
|
|
@@ -245,8 +248,8 @@ interface ListArticlesOptions {
|
|
|
245
248
|
limit?: number
|
|
246
249
|
/** Rows to skip. */
|
|
247
250
|
offset?: number
|
|
248
|
-
/** The viewing user, for `favorited
|
|
249
|
-
viewerId?: string
|
|
251
|
+
/** The viewing user, for `favorited`; null or omitted means an anonymous reader. */
|
|
252
|
+
viewerId?: string | null
|
|
250
253
|
}
|
|
251
254
|
```
|
|
252
255
|
|
|
@@ -325,11 +328,11 @@ Turn stored rows into {@link Article}s: decoded tags, favorite counts and the
|
|
|
325
328
|
viewer's own favorites, in two queries for the whole page.
|
|
326
329
|
|
|
327
330
|
```typescript
|
|
328
|
-
function hydrateArticles(rows: ArticleRow[], viewerId?: string): Promise<Article[]>
|
|
331
|
+
function hydrateArticles(rows: ArticleRow[], viewerId?: string | null): Promise<Article[]>
|
|
329
332
|
```
|
|
330
333
|
|
|
331
334
|
- `rows` — Article rows.
|
|
332
|
-
- `viewerId` — The viewing user, if any.
|
|
335
|
+
- `viewerId` — The viewing user, if any; null and undefined are anonymous.
|
|
333
336
|
|
|
334
337
|
**Returns:** The articles, in the order given.
|
|
335
338
|
|
|
@@ -367,11 +370,11 @@ function findArticleRow(slug: string): Promise<ArticleRow | null>
|
|
|
367
370
|
An article by slug.
|
|
368
371
|
|
|
369
372
|
```typescript
|
|
370
|
-
function getArticleBySlug(slug: string, viewerId?: string): Promise<Article | null>
|
|
373
|
+
function getArticleBySlug(slug: string, viewerId?: string | null): Promise<Article | null>
|
|
371
374
|
```
|
|
372
375
|
|
|
373
376
|
- `slug` — The article slug.
|
|
374
|
-
- `viewerId` — The viewing user, for `favorited
|
|
377
|
+
- `viewerId` — The viewing user, for `favorited`; null or omitted is anonymous.
|
|
375
378
|
|
|
376
379
|
**Returns:** The article, or null.
|
|
377
380
|
|
package/dist/service.d.ts
CHANGED
|
@@ -27,10 +27,10 @@ export declare const MAX_ARTICLES_PAGE = 100;
|
|
|
27
27
|
* viewer's own favorites, in two queries for the whole page.
|
|
28
28
|
*
|
|
29
29
|
* @param rows - Article rows.
|
|
30
|
-
* @param viewerId - The viewing user, if any.
|
|
30
|
+
* @param viewerId - The viewing user, if any; null and undefined are anonymous.
|
|
31
31
|
* @returns The articles, in the order given.
|
|
32
32
|
*/
|
|
33
|
-
export declare function hydrateArticles(rows: ArticleRow[], viewerId?: string): Promise<Article[]>;
|
|
33
|
+
export declare function hydrateArticles(rows: ArticleRow[], viewerId?: string | null): Promise<Article[]>;
|
|
34
34
|
/**
|
|
35
35
|
* Create an article with a unique slug derived from its title.
|
|
36
36
|
*
|
|
@@ -54,10 +54,10 @@ export declare function findArticleRow(slug: string): Promise<ArticleRow | null>
|
|
|
54
54
|
* An article by slug.
|
|
55
55
|
*
|
|
56
56
|
* @param slug - The article slug.
|
|
57
|
-
* @param viewerId - The viewing user, for `favorited
|
|
57
|
+
* @param viewerId - The viewing user, for `favorited`; null or omitted is anonymous.
|
|
58
58
|
* @returns The article, or null.
|
|
59
59
|
*/
|
|
60
|
-
export declare function getArticleBySlug(slug: string, viewerId?: string): Promise<Article | null>;
|
|
60
|
+
export declare function getArticleBySlug(slug: string, viewerId?: string | null): Promise<Article | null>;
|
|
61
61
|
/**
|
|
62
62
|
* Articles newest first, filtered by tag, author and who favorited them.
|
|
63
63
|
*
|
package/dist/service.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"service.d.ts","sourceRoot":"","sources":["../src/service.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAeH,OAAO,KAAK,EACV,OAAO,EACP,UAAU,EACV,kBAAkB,EAClB,mBAAmB,EACnB,iBAAiB,EACjB,QAAQ,EACR,kBAAkB,EACnB,MAAM,YAAY,CAAA;AAOnB,6EAA6E;AAC7E,eAAO,MAAM,qBAAqB,YAAY,CAAA;AAE9C,iDAAiD;AACjD,eAAO,MAAM,iBAAiB,aAAa,CAAA;AAE3C;;;GAGG;AACH,eAAO,MAAM,sBAAsB,EAAE,WAAW,CAAC,MAAM,CAA6B,CAAA;AA0CpF,mCAAmC;AACnC,eAAO,MAAM,iBAAiB,MAAM,CAAA;AAyBpC;;;;;;;GAOG;AACH,wBAAsB,eAAe,
|
|
1
|
+
{"version":3,"file":"service.d.ts","sourceRoot":"","sources":["../src/service.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAeH,OAAO,KAAK,EACV,OAAO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7D,MAAM,MAAM,YAAY,CAAC,CAAC,IACxB;IAAE,MAAM,EAAE,IAAI,CAAC;IAAC,OAAO,EAAE,CAAC,CAAA;CAAE,GAAG;IAAE,MAAM,EAAE,WAAW,CAAA;CAAE,GAAG;IAAE,MAAM,EAAE,WAAW,CAAA;CAAE,CAAA;AAElF;;;;;;;;;;;GAWG;AACH,wBAAsB,aAAa,CACjC,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,MAAM,EACd,KAAK,EAAE,kBAAkB,GACxB,OAAO,CAAC,YAAY,CAAC,OAAO,CAAC,CAAC,CAkBhC;AAED;;;;;;GAMG;AACH,wBAAsB,aAAa,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC,CAW7F;AAED;;;;;;;GAOG;AACH,wBAAsB,WAAW,CAC/B,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,MAAM,EACd,QAAQ,EAAE,OAAO,GAChB,OAAO,CAAC,OAAO,GAAG,IAAI,CAAC,CAOzB;AAED;;;;;;;;;;GAUG;AACH,wBAAsB,OAAO,IAAI,OAAO,CAAC,QAAQ,EAAE,CAAC,CAEnD;AAED;;;;;;;;;;;;GAYG;AACH,wBAAsB,WAAW,CAAC,KAAK,SAAK,GAAG,OAAO,CAAC,QAAQ,EAAE,CAAC,CAEjE"}
|
package/dist/service.js
CHANGED
|
@@ -83,7 +83,7 @@ const cleanTags = (tags) => [
|
|
|
83
83
|
* viewer's own favorites, in two queries for the whole page.
|
|
84
84
|
*
|
|
85
85
|
* @param rows - Article rows.
|
|
86
|
-
* @param viewerId - The viewing user, if any.
|
|
86
|
+
* @param viewerId - The viewing user, if any; null and undefined are anonymous.
|
|
87
87
|
* @returns The articles, in the order given.
|
|
88
88
|
*/
|
|
89
89
|
export async function hydrateArticles(rows, viewerId) {
|
|
@@ -183,7 +183,7 @@ export async function findArticleRow(slug) {
|
|
|
183
183
|
* An article by slug.
|
|
184
184
|
*
|
|
185
185
|
* @param slug - The article slug.
|
|
186
|
-
* @param viewerId - The viewing user, for `favorited
|
|
186
|
+
* @param viewerId - The viewing user, for `favorited`; null or omitted is anonymous.
|
|
187
187
|
* @returns The article, or null.
|
|
188
188
|
*/
|
|
189
189
|
export async function getArticleBySlug(slug, viewerId) {
|
package/dist/types.d.ts
CHANGED
|
@@ -4,7 +4,10 @@
|
|
|
4
4
|
* @module
|
|
5
5
|
*/
|
|
6
6
|
/**
|
|
7
|
-
* An article row as stored. `tagList` is a JSON array of tag names
|
|
7
|
+
* An article row as stored. `tagList` is a JSON array of tag names, in the order they were
|
|
8
|
+
* given, and it is what every article response returns. The `article_tags` table holds the same
|
|
9
|
+
* tags one row each, for the tag filter and the tag lists. `createArticle` and `updateArticle`
|
|
10
|
+
* write both, so an app that goes through this package never keeps them in step itself.
|
|
8
11
|
*/
|
|
9
12
|
export interface ArticleRow {
|
|
10
13
|
/** Unique article identifier. */
|
|
@@ -94,8 +97,8 @@ export interface ListArticlesOptions {
|
|
|
94
97
|
limit?: number;
|
|
95
98
|
/** Rows to skip. */
|
|
96
99
|
offset?: number;
|
|
97
|
-
/** The viewing user, for `favorited
|
|
98
|
-
viewerId?: string;
|
|
100
|
+
/** The viewing user, for `favorited`; null or omitted means an anonymous reader. */
|
|
101
|
+
viewerId?: string | null;
|
|
99
102
|
}
|
|
100
103
|
/**
|
|
101
104
|
* A page of articles.
|
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH;;;;;GAKG;AACH,MAAM,WAAW,UAAU;IACzB,iCAAiC;IACjC,EAAE,EAAE,MAAM,CAAA;IACV,wCAAwC;IACxC,IAAI,EAAE,MAA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