@chronicle.app/hackernews 0.4.0 → 0.5.0

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
@@ -23,7 +23,7 @@ Upvotes, favorites, and hidden items aren't read: Hacker News records no time fo
23
23
 
24
24
  | Hacker News activity | Chronicle action | `object` | `result` |
25
25
  | --------------------------------------- | ---------------- | ------------------------------ | --------- |
26
- | You submitted a story, poll, or job | `PublishAction` | `Post` | |
26
+ | You submitted a story, poll, or job | `PublishAction` | | `Post` |
27
27
  | You commented | `RespondAction` | the parent `Post` or `Comment` | `Comment` |
28
28
  | Someone replied to your post or comment | `RespondAction` | your `Post` or `Comment` | `Comment` |
29
29
 
@@ -1,6 +1,8 @@
1
1
  import { ChronicleTransformer, htmlToText, selfAgent } from '@chronicle.app/etl';
2
2
  const SOURCE = 'hackernews';
3
3
  const KEY = ['@type', 'source', 'sourceId'];
4
+ /** An action is keyed by the post or comment it made, which has the item's ID. */
5
+ const MADE_KEY = ['@type', 'source', 'result.sourceId'];
4
6
  function itemUrl(id) {
5
7
  return `https://news.ycombinator.com/item?id=${id}`;
6
8
  }
@@ -34,12 +36,11 @@ export default class HackerNewsTransformer extends ChronicleTransformer {
34
36
  buildPublish(item) {
35
37
  return {
36
38
  '@type': 'PublishAction',
37
- '@key': KEY,
39
+ '@key': MADE_KEY,
38
40
  source: SOURCE,
39
- sourceId: String(item.id),
40
41
  timestamp: time(item),
41
42
  ...(item.by && { agent: this.buildUser(item.by) }),
42
- object: this.buildPost(item),
43
+ result: this.buildPost(item),
43
44
  };
44
45
  }
45
46
  /**
@@ -50,9 +51,8 @@ export default class HackerNewsTransformer extends ChronicleTransformer {
50
51
  buildRespond(item, parent, root) {
51
52
  return {
52
53
  '@type': 'RespondAction',
53
- '@key': KEY,
54
+ '@key': MADE_KEY,
54
55
  source: SOURCE,
55
- sourceId: String(item.id),
56
56
  timestamp: time(item),
57
57
  ...(item.by && { agent: this.buildUser(item.by) }),
58
58
  ...(parent && { object: this.buildItem(parent, root) }),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@chronicle.app/hackernews",
3
- "version": "0.4.0",
3
+ "version": "0.5.0",
4
4
  "main": "./dist/index.js",
5
5
  "types": "./dist/index.d.ts",
6
6
  "files": [
@@ -23,9 +23,9 @@
23
23
  "type": "module",
24
24
  "description": "Chronicle plugin for Hacker News submissions, comments, and replies",
25
25
  "devDependencies": {
26
- "@chronicle.app/etl": "0.4.0",
27
- "@chronicle.app/schema": "0.4.0",
28
- "@chronicle.app/tsconfig": "0.4.0",
26
+ "@chronicle.app/etl": "0.5.0",
27
+ "@chronicle.app/schema": "0.5.0",
28
+ "@chronicle.app/tsconfig": "0.5.0",
29
29
  "@types/node": "^22.10.1",
30
30
  "typescript": "^5.7.2"
31
31
  },