@molecule/api-resource-article 1.0.5 → 1.0.6

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-16T11:26:11.412Z
7
7
  -->
8
8
 
9
9
  # @molecule/api-resource-article
@@ -613,11 +613,20 @@ Peer dependencies:
613
613
  - `@molecule/api-slug`
614
614
  - `zod`
615
615
 
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.
616
+ - **Migration required: this package ships every table it reads, four in
617
+ all.** `articles.sql` creates the `articles` and `article_tags` tables;
618
+ `articles_position.sql` adds the `position` column to a database whose
619
+ `article_tags` predates it; `reactions.sql` and `follows.sql` create the
620
+ `reactions` and `follows` tables, which this package reads directly by name
621
+ on every response (favorites) and on its feed (who a reader follows). Those
622
+ last two are copies of `@molecule/api-resource-reaction`'s and
623
+ `@molecule/api-resource-follow`'s own setup files, statement for statement,
624
+ and each creates its table only if it is not there yet, so an app that also
625
+ installs those packages runs both copies harmlessly. A scaffold copies the
626
+ tables a package's registry entry declares, and this one declares all four,
627
+ so a project that installs only this package gets every table its endpoints
628
+ need. Applying `articles.sql` alone leaves every article response failing
629
+ with `no such table: reactions`.
621
630
  - **`article_tags` keeps the order the tags were given in**, in its `position`
622
631
  column (0-based). An app that reads the join table itself must order by
623
632
  `position` — a submission-order assertion (`tagList[0]`, `tagList[1]`) reads
package/dist/index.d.ts CHANGED
@@ -41,11 +41,20 @@
41
41
  * ```
42
42
  *
43
43
  * @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.
44
+ * - **Migration required: this package ships every table it reads, four in
45
+ * all.** `articles.sql` creates the `articles` and `article_tags` tables;
46
+ * `articles_position.sql` adds the `position` column to a database whose
47
+ * `article_tags` predates it; `reactions.sql` and `follows.sql` create the
48
+ * `reactions` and `follows` tables, which this package reads directly by name
49
+ * on every response (favorites) and on its feed (who a reader follows). Those
50
+ * last two are copies of `@molecule/api-resource-reaction`'s and
51
+ * `@molecule/api-resource-follow`'s own setup files, statement for statement,
52
+ * and each creates its table only if it is not there yet, so an app that also
53
+ * installs those packages runs both copies harmlessly. A scaffold copies the
54
+ * tables a package's registry entry declares, and this one declares all four,
55
+ * so a project that installs only this package gets every table its endpoints
56
+ * need. Applying `articles.sql` alone leaves every article response failing
57
+ * with `no such table: reactions`.
49
58
  * - **`article_tags` keeps the order the tags were given in**, in its `position`
50
59
  * column (0-based). An app that reads the join table itself must order by
51
60
  * `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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2FG;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
@@ -41,11 +41,20 @@
41
41
  * ```
42
42
  *
43
43
  * @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.
44
+ * - **Migration required: this package ships every table it reads, four in
45
+ * all.** `articles.sql` creates the `articles` and `article_tags` tables;
46
+ * `articles_position.sql` adds the `position` column to a database whose
47
+ * `article_tags` predates it; `reactions.sql` and `follows.sql` create the
48
+ * `reactions` and `follows` tables, which this package reads directly by name
49
+ * on every response (favorites) and on its feed (who a reader follows). Those
50
+ * last two are copies of `@molecule/api-resource-reaction`'s and
51
+ * `@molecule/api-resource-follow`'s own setup files, statement for statement,
52
+ * and each creates its table only if it is not there yet, so an app that also
53
+ * installs those packages runs both copies harmlessly. A scaffold copies the
54
+ * tables a package's registry entry declares, and this one declares all four,
55
+ * so a project that installs only this package gets every table its endpoints
56
+ * need. Applying `articles.sql` alone leaves every article response failing
57
+ * with `no such table: reactions`.
49
58
  * - **`article_tags` keeps the order the tags were given in**, in its `position`
50
59
  * column (0-based). An app that reads the join table itself must order by
51
60
  * `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.6",
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");