@molecule/api-resource-article 1.1.3 → 1.1.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 +13 -3
- package/dist/index.d.ts +4 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -2
- package/dist/service.d.ts +8 -0
- package/dist/service.d.ts.map +1 -1
- package/dist/service.js +8 -0
- package/package.json +9 -9
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-10-
|
|
6
|
+
Generated: 2026-10-25T00:22:04.478Z
|
|
7
7
|
-->
|
|
8
8
|
|
|
9
9
|
# @molecule/api-resource-article
|
|
@@ -337,6 +337,10 @@ function hydrateArticles(rows: ArticleRow[], viewerId?: string): Promise<Article
|
|
|
337
337
|
|
|
338
338
|
Create an article with a unique slug derived from its title.
|
|
339
339
|
|
|
340
|
+
`createdAt` and `updatedAt` are stamped by this call and strictly increase
|
|
341
|
+
within the process, so two articles created in the same millisecond still
|
|
342
|
+
list newest first — callers never write these columns.
|
|
343
|
+
|
|
340
344
|
```typescript
|
|
341
345
|
function createArticle(authorId: string, input: CreateArticleInput): Promise<Article>
|
|
342
346
|
```
|
|
@@ -411,6 +415,10 @@ function getFeed(
|
|
|
411
415
|
|
|
412
416
|
Update an article. Only its author may; a changed title gives it a new slug.
|
|
413
417
|
|
|
418
|
+
`updatedAt` always moves strictly past the stored value — even an edit in the
|
|
419
|
+
same millisecond as the create shows a changed `updatedAt` — so callers never
|
|
420
|
+
set it themselves.
|
|
421
|
+
|
|
414
422
|
```typescript
|
|
415
423
|
function updateArticle(
|
|
416
424
|
slug: string,
|
|
@@ -690,8 +698,10 @@ Peer dependencies:
|
|
|
690
698
|
asked for the N most-used. The package's own `GET /articles/tags` route does
|
|
691
699
|
exactly this: no `?limit=` is the whole list.
|
|
692
700
|
- **Lists are newest first and paginated** — `{ data, total, limit, offset }`,
|
|
693
|
-
at most 100 per page. `
|
|
694
|
-
|
|
701
|
+
at most 100 per page. `createArticle` stamps `createdAt` strictly increasing
|
|
702
|
+
and `updateArticle` always moves `updatedAt` forward, so newest-first order
|
|
703
|
+
and a changed `updatedAt` hold even within one millisecond — an app never
|
|
704
|
+
re-stamps these columns itself.
|
|
695
705
|
- **Slugs are unique and stable.** The first "Hello World" is `hello-world`,
|
|
696
706
|
the next `hello-world-2`; `feed` and `tags` are never used (they are routes).
|
|
697
707
|
Changing the title changes the slug — link with the slug the response returns.
|
package/dist/index.d.ts
CHANGED
|
@@ -85,8 +85,10 @@
|
|
|
85
85
|
* asked for the N most-used. The package's own `GET /articles/tags` route does
|
|
86
86
|
* exactly this: no `?limit=` is the whole list.
|
|
87
87
|
* - **Lists are newest first and paginated** — `{ data, total, limit, offset }`,
|
|
88
|
-
* at most 100 per page. `
|
|
89
|
-
*
|
|
88
|
+
* at most 100 per page. `createArticle` stamps `createdAt` strictly increasing
|
|
89
|
+
* and `updateArticle` always moves `updatedAt` forward, so newest-first order
|
|
90
|
+
* and a changed `updatedAt` hold even within one millisecond — an app never
|
|
91
|
+
* re-stamps these columns itself.
|
|
90
92
|
* - **Slugs are unique and stable.** The first "Hello World" is `hello-world`,
|
|
91
93
|
* the next `hello-world-2`; `feed` and `tags` are never used (they are routes).
|
|
92
94
|
* Changing the title changes the slug — link with the slug the response returns.
|
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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsHG;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
|
@@ -85,8 +85,10 @@
|
|
|
85
85
|
* asked for the N most-used. The package's own `GET /articles/tags` route does
|
|
86
86
|
* exactly this: no `?limit=` is the whole list.
|
|
87
87
|
* - **Lists are newest first and paginated** — `{ data, total, limit, offset }`,
|
|
88
|
-
* at most 100 per page. `
|
|
89
|
-
*
|
|
88
|
+
* at most 100 per page. `createArticle` stamps `createdAt` strictly increasing
|
|
89
|
+
* and `updateArticle` always moves `updatedAt` forward, so newest-first order
|
|
90
|
+
* and a changed `updatedAt` hold even within one millisecond — an app never
|
|
91
|
+
* re-stamps these columns itself.
|
|
90
92
|
* - **Slugs are unique and stable.** The first "Hello World" is `hello-world`,
|
|
91
93
|
* the next `hello-world-2`; `feed` and `tags` are never used (they are routes).
|
|
92
94
|
* Changing the title changes the slug — link with the slug the response returns.
|
package/dist/service.d.ts
CHANGED
|
@@ -34,6 +34,10 @@ export declare function hydrateArticles(rows: ArticleRow[], viewerId?: string):
|
|
|
34
34
|
/**
|
|
35
35
|
* Create an article with a unique slug derived from its title.
|
|
36
36
|
*
|
|
37
|
+
* `createdAt` and `updatedAt` are stamped by this call and strictly increase
|
|
38
|
+
* within the process, so two articles created in the same millisecond still
|
|
39
|
+
* list newest first — callers never write these columns.
|
|
40
|
+
*
|
|
37
41
|
* @param authorId - The writing user.
|
|
38
42
|
* @param input - Title, body, optional description and tags.
|
|
39
43
|
* @returns The created article.
|
|
@@ -92,6 +96,10 @@ export type AuthorChange<T> = {
|
|
|
92
96
|
/**
|
|
93
97
|
* Update an article. Only its author may; a changed title gives it a new slug.
|
|
94
98
|
*
|
|
99
|
+
* `updatedAt` always moves strictly past the stored value — even an edit in the
|
|
100
|
+
* same millisecond as the create shows a changed `updatedAt` — so callers never
|
|
101
|
+
* set it themselves.
|
|
102
|
+
*
|
|
95
103
|
* @param slug - The article slug.
|
|
96
104
|
* @param userId - The requesting user.
|
|
97
105
|
* @param input - The fields to change.
|
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,CAAC,IAAI,EAAE,UAAU,EAAE,EAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,EAAE,CAAC,CA6B/F;AAsBD
|
|
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;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AE,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
|
@@ -139,6 +139,10 @@ const writeTags = async (articleId, tags) => {
|
|
|
139
139
|
/**
|
|
140
140
|
* Create an article with a unique slug derived from its title.
|
|
141
141
|
*
|
|
142
|
+
* `createdAt` and `updatedAt` are stamped by this call and strictly increase
|
|
143
|
+
* within the process, so two articles created in the same millisecond still
|
|
144
|
+
* list newest first — callers never write these columns.
|
|
145
|
+
*
|
|
142
146
|
* @param authorId - The writing user.
|
|
143
147
|
* @param input - Title, body, optional description and tags.
|
|
144
148
|
* @returns The created article.
|
|
@@ -290,6 +294,10 @@ export async function getFeed(userId, options = {}) {
|
|
|
290
294
|
/**
|
|
291
295
|
* Update an article. Only its author may; a changed title gives it a new slug.
|
|
292
296
|
*
|
|
297
|
+
* `updatedAt` always moves strictly past the stored value — even an edit in the
|
|
298
|
+
* same millisecond as the create shows a changed `updatedAt` — so callers never
|
|
299
|
+
* set it themselves.
|
|
300
|
+
*
|
|
293
301
|
* @param slug - The article slug.
|
|
294
302
|
* @param userId - The requesting user.
|
|
295
303
|
* @param input - The fields to change.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@molecule/api-resource-article",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.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",
|
|
@@ -33,15 +33,15 @@
|
|
|
33
33
|
],
|
|
34
34
|
"license": "Apache-2.0",
|
|
35
35
|
"devDependencies": {
|
|
36
|
-
"@molecule/api-database": "1.
|
|
37
|
-
"@molecule/api-database-sqlite": "1.
|
|
38
|
-
"@molecule/api-resource-follow": "1.0.
|
|
39
|
-
"@molecule/api-resource-reaction": "1.0.
|
|
40
|
-
"@molecule/api-slug": "1.0.
|
|
41
|
-
"@types/node": "26.
|
|
36
|
+
"@molecule/api-database": "1.2.0",
|
|
37
|
+
"@molecule/api-database-sqlite": "1.4.0",
|
|
38
|
+
"@molecule/api-resource-follow": "1.0.10",
|
|
39
|
+
"@molecule/api-resource-reaction": "1.0.6",
|
|
40
|
+
"@molecule/api-slug": "1.0.2",
|
|
41
|
+
"@types/node": "26.6.5",
|
|
42
42
|
"typescript": "6.0.3",
|
|
43
|
-
"vitest": "4.1.
|
|
44
|
-
"zod": "4.
|
|
43
|
+
"vitest": "4.1.12",
|
|
44
|
+
"zod": "4.6.7"
|
|
45
45
|
},
|
|
46
46
|
"peerDependencies": {
|
|
47
47
|
"@molecule/api-database": "^1.0.1",
|