@molecule/api-resource-article 1.0.5 → 1.0.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 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-16T01:58:33.609Z
6
+ Generated: 2026-10-16T15:23:40.659Z
7
7
  -->
8
8
 
9
9
  # @molecule/api-resource-article
@@ -21,6 +21,11 @@ docs site. Favorites are `@molecule/api-resource-reaction` reactions and the
21
21
  feed reads `@molecule/api-resource-follow`'s follows, so they are the same
22
22
  favorites and follows the rest of the app sees.
23
23
 
24
+ **Tables this package owns: `articles` and `article_tags`.** The join between them is
25
+ `article_tags.articleId` = `articles.id` (a declared FK, `ON DELETE CASCADE`; `("articleId", "tag")` is
26
+ unique, and `article_tags.position` is the order the tags were given in). It also ships
27
+ `reactions.sql` and `follows.sql`, which create the `reactions` and `follows` tables it reads by name.
28
+
24
29
  ## Quick Start
25
30
 
26
31
  ```typescript
@@ -613,11 +618,20 @@ Peer dependencies:
613
618
  - `@molecule/api-slug`
614
619
  - `zod`
615
620
 
616
- - **Migration required.** `src/__setup__/articles.sql` creates `articles` and
617
- `article_tags`; the reaction and follow packages bring `reactions` and
618
- `follows`. Scaffolded apps apply all of them on boot.
619
- `src/__setup__/articles_position.sql` adds `article_tags.position` to a
620
- database whose table predates the column.
621
+ - **Migration required: this package ships every table it reads, four in
622
+ all.** `articles.sql` creates the `articles` and `article_tags` tables;
623
+ `articles_position.sql` adds the `position` column to a database whose
624
+ `article_tags` predates it; `reactions.sql` and `follows.sql` create the
625
+ `reactions` and `follows` tables, which this package reads directly by name
626
+ on every response (favorites) and on its feed (who a reader follows). Those
627
+ last two are copies of `@molecule/api-resource-reaction`'s and
628
+ `@molecule/api-resource-follow`'s own setup files, statement for statement,
629
+ and each creates its table only if it is not there yet, so an app that also
630
+ installs those packages runs both copies harmlessly. A scaffold copies the
631
+ tables a package's registry entry declares, and this one declares all four,
632
+ so a project that installs only this package gets every table its endpoints
633
+ need. Applying `articles.sql` alone leaves every article response failing
634
+ with `no such table: reactions`.
621
635
  - **`article_tags` keeps the order the tags were given in**, in its `position`
622
636
  column (0-based). An app that reads the join table itself must order by
623
637
  `position` — a submission-order assertion (`tagList[0]`, `tagList[1]`) reads
package/dist/index.d.ts CHANGED
@@ -8,6 +8,11 @@
8
8
  * feed reads `@molecule/api-resource-follow`'s follows, so they are the same
9
9
  * favorites and follows the rest of the app sees.
10
10
  *
11
+ * **Tables this package owns: `articles` and `article_tags`.** The join between them is
12
+ * `article_tags.articleId` = `articles.id` (a declared FK, `ON DELETE CASCADE`; `("articleId", "tag")` is
13
+ * unique, and `article_tags.position` is the order the tags were given in). It also ships
14
+ * `reactions.sql` and `follows.sql`, which create the `reactions` and `follows` tables it reads by name.
15
+ *
11
16
  * @module
12
17
  * @example
13
18
  * ```typescript
@@ -41,11 +46,20 @@
41
46
  * ```
42
47
  *
43
48
  * @remarks
44
- * - **Migration required.** `src/__setup__/articles.sql` creates `articles` and
45
- * `article_tags`; the reaction and follow packages bring `reactions` and
46
- * `follows`. Scaffolded apps apply all of them on boot.
47
- * `src/__setup__/articles_position.sql` adds `article_tags.position` to a
48
- * database whose table predates the column.
49
+ * - **Migration required: this package ships every table it reads, four in
50
+ * all.** `articles.sql` creates the `articles` and `article_tags` tables;
51
+ * `articles_position.sql` adds the `position` column to a database whose
52
+ * `article_tags` predates it; `reactions.sql` and `follows.sql` create the
53
+ * `reactions` and `follows` tables, which this package reads directly by name
54
+ * on every response (favorites) and on its feed (who a reader follows). Those
55
+ * last two are copies of `@molecule/api-resource-reaction`'s and
56
+ * `@molecule/api-resource-follow`'s own setup files, statement for statement,
57
+ * and each creates its table only if it is not there yet, so an app that also
58
+ * installs those packages runs both copies harmlessly. A scaffold copies the
59
+ * tables a package's registry entry declares, and this one declares all four,
60
+ * so a project that installs only this package gets every table its endpoints
61
+ * need. Applying `articles.sql` alone leaves every article response failing
62
+ * with `no such table: reactions`.
49
63
  * - **`article_tags` keeps the order the tags were given in**, in its `position`
50
64
  * column (0-based). An app that reads the join table itself must order by
51
65
  * `position` — a submission-order assertion (`tagList[0]`, `tagList[1]`) reads
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkFG;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"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgGG;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
@@ -8,6 +8,11 @@
8
8
  * feed reads `@molecule/api-resource-follow`'s follows, so they are the same
9
9
  * favorites and follows the rest of the app sees.
10
10
  *
11
+ * **Tables this package owns: `articles` and `article_tags`.** The join between them is
12
+ * `article_tags.articleId` = `articles.id` (a declared FK, `ON DELETE CASCADE`; `("articleId", "tag")` is
13
+ * unique, and `article_tags.position` is the order the tags were given in). It also ships
14
+ * `reactions.sql` and `follows.sql`, which create the `reactions` and `follows` tables it reads by name.
15
+ *
11
16
  * @module
12
17
  * @example
13
18
  * ```typescript
@@ -41,11 +46,20 @@
41
46
  * ```
42
47
  *
43
48
  * @remarks
44
- * - **Migration required.** `src/__setup__/articles.sql` creates `articles` and
45
- * `article_tags`; the reaction and follow packages bring `reactions` and
46
- * `follows`. Scaffolded apps apply all of them on boot.
47
- * `src/__setup__/articles_position.sql` adds `article_tags.position` to a
48
- * database whose table predates the column.
49
+ * - **Migration required: this package ships every table it reads, four in
50
+ * all.** `articles.sql` creates the `articles` and `article_tags` tables;
51
+ * `articles_position.sql` adds the `position` column to a database whose
52
+ * `article_tags` predates it; `reactions.sql` and `follows.sql` create the
53
+ * `reactions` and `follows` tables, which this package reads directly by name
54
+ * on every response (favorites) and on its feed (who a reader follows). Those
55
+ * last two are copies of `@molecule/api-resource-reaction`'s and
56
+ * `@molecule/api-resource-follow`'s own setup files, statement for statement,
57
+ * and each creates its table only if it is not there yet, so an app that also
58
+ * installs those packages runs both copies harmlessly. A scaffold copies the
59
+ * tables a package's registry entry declares, and this one declares all four,
60
+ * so a project that installs only this package gets every table its endpoints
61
+ * need. Applying `articles.sql` alone leaves every article response failing
62
+ * with `no such table: reactions`.
49
63
  * - **`article_tags` keeps the order the tags were given in**, in its `position`
50
64
  * column (0-based). An app that reads the join table itself must order by
51
65
  * `position` — a submission-order assertion (`tagList[0]`, `tagList[1]`) reads
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@molecule/api-resource-article",
3
- "version": "1.0.5",
3
+ "version": "1.0.7",
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,10 +33,10 @@
33
33
  ],
34
34
  "license": "Apache-2.0",
35
35
  "devDependencies": {
36
- "@molecule/api-database": "1.1.1",
37
- "@molecule/api-database-sqlite": "1.2.2",
38
- "@molecule/api-resource-follow": "1.0.6",
39
- "@molecule/api-resource-reaction": "1.0.3",
36
+ "@molecule/api-database": "1.1.3",
37
+ "@molecule/api-database-sqlite": "1.2.4",
38
+ "@molecule/api-resource-follow": "1.0.7",
39
+ "@molecule/api-resource-reaction": "1.0.4",
40
40
  "@molecule/api-slug": "1.0.1",
41
41
  "@types/node": "26.1.2",
42
42
  "typescript": "6.0.3",
@@ -0,0 +1,12 @@
1
+ CREATE TABLE IF NOT EXISTS "follows" (
2
+ "id" UUID PRIMARY KEY DEFAULT gen_random_uuid(),
3
+ "followerId" UUID NOT NULL,
4
+ "targetType" VARCHAR(255) NOT NULL,
5
+ "targetId" VARCHAR(255) NOT NULL,
6
+ "createdAt" TIMESTAMPTZ NOT NULL DEFAULT now(),
7
+ "updatedAt" TIMESTAMPTZ NOT NULL DEFAULT now(),
8
+ UNIQUE ("followerId", "targetType", "targetId")
9
+ );
10
+
11
+ CREATE INDEX IF NOT EXISTS "idx_follows_follower" ON "follows" ("followerId");
12
+ CREATE INDEX IF NOT EXISTS "idx_follows_target" ON "follows" ("targetType", "targetId");
@@ -0,0 +1,13 @@
1
+ CREATE TABLE IF NOT EXISTS "reactions" (
2
+ "id" UUID PRIMARY KEY DEFAULT gen_random_uuid(),
3
+ "resourceType" VARCHAR(255) NOT NULL,
4
+ "resourceId" VARCHAR(255) NOT NULL,
5
+ "userId" UUID NOT NULL,
6
+ "type" VARCHAR(50) NOT NULL,
7
+ "createdAt" TIMESTAMPTZ NOT NULL DEFAULT now(),
8
+ "updatedAt" TIMESTAMPTZ NOT NULL DEFAULT now(),
9
+ UNIQUE ("resourceType", "resourceId", "userId", "type")
10
+ );
11
+
12
+ CREATE INDEX IF NOT EXISTS "idx_reactions_resource" ON "reactions" ("resourceType", "resourceId");
13
+ CREATE INDEX IF NOT EXISTS "idx_reactions_user" ON "reactions" ("userId");