@relayfile/adapter-reddit 0.1.3 → 0.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/discovery/reddit/.adapter.md +65 -0
- package/discovery/reddit/subreddits/.create.example.json +3 -0
- package/discovery/reddit/subreddits/.schema.json +82 -0
- package/discovery/reddit/subreddits/{subreddit}/posts/.create.example.json +5 -0
- package/discovery/reddit/subreddits/{subreddit}/posts/.schema.json +110 -0
- package/package.json +4 -3
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
# Reddit adapter
|
|
2
|
+
|
|
3
|
+
The Reddit adapter exposes tracked subreddits and posts under `/reddit`, with writeback routes for tracking subreddits and creating posts.
|
|
4
|
+
|
|
5
|
+
Read-only mounts:
|
|
6
|
+
- `/reddit/subreddits/<subreddit>.json` - Tracked subreddit records.
|
|
7
|
+
- `/reddit/subreddits/<subreddit>/posts/<title>__<postId>.json` - Post records scoped by subreddit.
|
|
8
|
+
- `/reddit/posts/by-id/<subreddit>__<postId>.json` - Post lookup aliases.
|
|
9
|
+
- `/reddit/posts/by-status/<status>/<subreddit>__<postId>.json` - Post status aliases.
|
|
10
|
+
|
|
11
|
+
Resources:
|
|
12
|
+
|
|
13
|
+
| Resource | Schema | Create example | ID pattern | What it does |
|
|
14
|
+
|---|---|---|---|---|
|
|
15
|
+
| `/reddit/subreddits/<id>.json` | `/reddit/subreddits/.schema.json` | `/reddit/subreddits/.create.example.json` | `^[A-Za-z0-9_][A-Za-z0-9_-]{1,63}$` | Starts tracking a subreddit so its posts sync under `/reddit`. |
|
|
16
|
+
| `/reddit/subreddits/{subreddit}/posts/<id>.json` | `/reddit/subreddits/{subreddit}/posts/.schema.json` | `/reddit/subreddits/{subreddit}/posts/.create.example.json` | `^[A-Za-z0-9_/-]+$` | Submits a post to the subreddit named by the path. |
|
|
17
|
+
|
|
18
|
+
## Operations
|
|
19
|
+
|
|
20
|
+
| To... | Do... |
|
|
21
|
+
|---|---|
|
|
22
|
+
| Read | `cat <canonical-resource-path>` after listing the resource directory or following an alias when one is available. Use the resource table and ID patterns below to determine whether a resource uses a bare id, an adapter-specific slug/id filename, or an exact sidecar path such as `content.md`. |
|
|
23
|
+
| Edit | Write the resource update payload to the canonical resource path. For JSON resources, included mutable fields PATCH; fields marked `readOnly` in `.schema.json` are rejected. |
|
|
24
|
+
| Create | Write JSON to any non-canonical filename such as `create request.json`. The adapter creates the record at its canonical resource path and rewrites the draft as `{ "created": "<real-id>", "path": "<canonical-resource-path>", "url": "<provider-url>" }`. |
|
|
25
|
+
| Ignore | Editor scratch files named `partial.json`, `.tmp.json`, `.partial.json`, `*.tmp.json`, or `*.partial.json` are ignored and never treated as create drafts. |
|
|
26
|
+
| Delete | `rm <canonical-resource-path>` for canonical records. |
|
|
27
|
+
|
|
28
|
+
## ID Patterns
|
|
29
|
+
- `/reddit/subreddits/<id>.json`: `^[A-Za-z0-9_][A-Za-z0-9_-]{1,63}$`. Filenames that do not match this pattern are treated as create drafts.
|
|
30
|
+
- `/reddit/subreddits/{subreddit}/posts/<id>.json`: `^[A-Za-z0-9_/-]+$`. Filenames that do not match this pattern are treated as create drafts.
|
|
31
|
+
|
|
32
|
+
## Write field contracts
|
|
33
|
+
|
|
34
|
+
### Track Reddit subreddit
|
|
35
|
+
|
|
36
|
+
Resource: `/reddit/subreddits/<id>.json`
|
|
37
|
+
Schema: `/reddit/subreddits/.schema.json`
|
|
38
|
+
Create example: `/reddit/subreddits/.create.example.json`
|
|
39
|
+
Required fields: `name`.
|
|
40
|
+
Optional fields: none.
|
|
41
|
+
|
|
42
|
+
Fields:
|
|
43
|
+
|
|
44
|
+
- `name` (required, string) - Subreddit name without the `r/` prefix.
|
|
45
|
+
|
|
46
|
+
### Create Reddit post
|
|
47
|
+
|
|
48
|
+
Resource: `/reddit/subreddits/{subreddit}/posts/<id>.json`
|
|
49
|
+
Schema: `/reddit/subreddits/{subreddit}/posts/.schema.json`
|
|
50
|
+
Create example: `/reddit/subreddits/{subreddit}/posts/.create.example.json`
|
|
51
|
+
Required fields: `title`.
|
|
52
|
+
Optional fields: `text`, `link_url`, `kind`, `flair_id`, `nsfw`, `spoiler`.
|
|
53
|
+
|
|
54
|
+
Fields:
|
|
55
|
+
|
|
56
|
+
- `title` (required, string) - Post title.
|
|
57
|
+
- `text` (optional, string) - Self-post body. Used when `kind` is `self`.
|
|
58
|
+
- `link_url` (optional, string, uri) - External URL for link posts. Used when `kind` is `link`.
|
|
59
|
+
- `kind` (optional, enum) - Post kind. Defaults to `link` when `link_url` is provided, otherwise `self`. Allowed values: `self`, `link`.
|
|
60
|
+
- `flair_id` (optional, string) - Subreddit flair template id.
|
|
61
|
+
- `nsfw` (optional, boolean) - Whether the post is marked NSFW.
|
|
62
|
+
- `spoiler` (optional, boolean) - Whether the post is marked as a spoiler.
|
|
63
|
+
|
|
64
|
+
## Create Examples
|
|
65
|
+
Read the resource `.schema.json` first, then use the sibling `.create.example.json` as a minimal create document. The example intentionally omits read-only fields.
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
3
|
+
"title": "Track Reddit subreddit",
|
|
4
|
+
"type": "object",
|
|
5
|
+
"required": [
|
|
6
|
+
"name"
|
|
7
|
+
],
|
|
8
|
+
"properties": {
|
|
9
|
+
"name": {
|
|
10
|
+
"type": "string",
|
|
11
|
+
"description": "Subreddit name without the `r/` prefix.",
|
|
12
|
+
"minLength": 1
|
|
13
|
+
},
|
|
14
|
+
"id": {
|
|
15
|
+
"type": "string",
|
|
16
|
+
"description": "Provider canonical record id.",
|
|
17
|
+
"readOnly": true
|
|
18
|
+
},
|
|
19
|
+
"createdAt": {
|
|
20
|
+
"type": "string",
|
|
21
|
+
"format": "date-time",
|
|
22
|
+
"description": "Provider creation timestamp.",
|
|
23
|
+
"readOnly": true
|
|
24
|
+
},
|
|
25
|
+
"updatedAt": {
|
|
26
|
+
"type": "string",
|
|
27
|
+
"format": "date-time",
|
|
28
|
+
"description": "Provider last update timestamp.",
|
|
29
|
+
"readOnly": true
|
|
30
|
+
},
|
|
31
|
+
"url": {
|
|
32
|
+
"type": "string",
|
|
33
|
+
"format": "uri",
|
|
34
|
+
"description": "Provider URL for the record.",
|
|
35
|
+
"readOnly": true
|
|
36
|
+
},
|
|
37
|
+
"identifier": {
|
|
38
|
+
"type": "string",
|
|
39
|
+
"description": "Provider human-readable identifier or key.",
|
|
40
|
+
"readOnly": true
|
|
41
|
+
},
|
|
42
|
+
"provider": {
|
|
43
|
+
"type": "string",
|
|
44
|
+
"description": "Relayfile provider name.",
|
|
45
|
+
"readOnly": true
|
|
46
|
+
},
|
|
47
|
+
"objectType": {
|
|
48
|
+
"type": "string",
|
|
49
|
+
"description": "Relayfile object type.",
|
|
50
|
+
"readOnly": true
|
|
51
|
+
},
|
|
52
|
+
"objectId": {
|
|
53
|
+
"type": "string",
|
|
54
|
+
"description": "Relayfile object id.",
|
|
55
|
+
"readOnly": true
|
|
56
|
+
},
|
|
57
|
+
"workspaceId": {
|
|
58
|
+
"type": "string",
|
|
59
|
+
"description": "Relayfile workspace id.",
|
|
60
|
+
"readOnly": true
|
|
61
|
+
},
|
|
62
|
+
"connectionId": {
|
|
63
|
+
"type": "string",
|
|
64
|
+
"description": "Relayfile connection id.",
|
|
65
|
+
"readOnly": true
|
|
66
|
+
},
|
|
67
|
+
"_webhook": {
|
|
68
|
+
"type": "object",
|
|
69
|
+
"description": "Provider webhook metadata captured during sync.",
|
|
70
|
+
"readOnly": true,
|
|
71
|
+
"additionalProperties": true
|
|
72
|
+
},
|
|
73
|
+
"_connection": {
|
|
74
|
+
"type": "object",
|
|
75
|
+
"description": "Relayfile connection metadata captured during sync.",
|
|
76
|
+
"readOnly": true,
|
|
77
|
+
"additionalProperties": true
|
|
78
|
+
}
|
|
79
|
+
},
|
|
80
|
+
"additionalProperties": false,
|
|
81
|
+
"description": "Full resource record schema. Fields marked readOnly are synced from the provider and cannot be written by agents."
|
|
82
|
+
}
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
3
|
+
"title": "Reddit post",
|
|
4
|
+
"type": "object",
|
|
5
|
+
"required": [
|
|
6
|
+
"title"
|
|
7
|
+
],
|
|
8
|
+
"properties": {
|
|
9
|
+
"title": {
|
|
10
|
+
"type": "string",
|
|
11
|
+
"description": "Post title.",
|
|
12
|
+
"minLength": 1
|
|
13
|
+
},
|
|
14
|
+
"text": {
|
|
15
|
+
"type": "string",
|
|
16
|
+
"description": "Self-post body. Used when `kind` is `self`."
|
|
17
|
+
},
|
|
18
|
+
"link_url": {
|
|
19
|
+
"type": "string",
|
|
20
|
+
"format": "uri",
|
|
21
|
+
"description": "External URL for link posts. Used when `kind` is `link`."
|
|
22
|
+
},
|
|
23
|
+
"kind": {
|
|
24
|
+
"enum": [
|
|
25
|
+
"self",
|
|
26
|
+
"link"
|
|
27
|
+
],
|
|
28
|
+
"description": "Post kind. Defaults to `link` when `link_url` is provided, otherwise `self`."
|
|
29
|
+
},
|
|
30
|
+
"flair_id": {
|
|
31
|
+
"type": "string",
|
|
32
|
+
"description": "Subreddit flair template id."
|
|
33
|
+
},
|
|
34
|
+
"nsfw": {
|
|
35
|
+
"type": "boolean",
|
|
36
|
+
"description": "Whether the post is marked NSFW."
|
|
37
|
+
},
|
|
38
|
+
"spoiler": {
|
|
39
|
+
"type": "boolean",
|
|
40
|
+
"description": "Whether the post is marked as a spoiler."
|
|
41
|
+
},
|
|
42
|
+
"id": {
|
|
43
|
+
"type": "string",
|
|
44
|
+
"description": "Provider canonical record id.",
|
|
45
|
+
"readOnly": true
|
|
46
|
+
},
|
|
47
|
+
"createdAt": {
|
|
48
|
+
"type": "string",
|
|
49
|
+
"format": "date-time",
|
|
50
|
+
"description": "Provider creation timestamp.",
|
|
51
|
+
"readOnly": true
|
|
52
|
+
},
|
|
53
|
+
"updatedAt": {
|
|
54
|
+
"type": "string",
|
|
55
|
+
"format": "date-time",
|
|
56
|
+
"description": "Provider last update timestamp.",
|
|
57
|
+
"readOnly": true
|
|
58
|
+
},
|
|
59
|
+
"url": {
|
|
60
|
+
"type": "string",
|
|
61
|
+
"format": "uri",
|
|
62
|
+
"description": "Provider URL for the record.",
|
|
63
|
+
"readOnly": true
|
|
64
|
+
},
|
|
65
|
+
"identifier": {
|
|
66
|
+
"type": "string",
|
|
67
|
+
"description": "Provider human-readable identifier or key.",
|
|
68
|
+
"readOnly": true
|
|
69
|
+
},
|
|
70
|
+
"provider": {
|
|
71
|
+
"type": "string",
|
|
72
|
+
"description": "Relayfile provider name.",
|
|
73
|
+
"readOnly": true
|
|
74
|
+
},
|
|
75
|
+
"objectType": {
|
|
76
|
+
"type": "string",
|
|
77
|
+
"description": "Relayfile object type.",
|
|
78
|
+
"readOnly": true
|
|
79
|
+
},
|
|
80
|
+
"objectId": {
|
|
81
|
+
"type": "string",
|
|
82
|
+
"description": "Relayfile object id.",
|
|
83
|
+
"readOnly": true
|
|
84
|
+
},
|
|
85
|
+
"workspaceId": {
|
|
86
|
+
"type": "string",
|
|
87
|
+
"description": "Relayfile workspace id.",
|
|
88
|
+
"readOnly": true
|
|
89
|
+
},
|
|
90
|
+
"connectionId": {
|
|
91
|
+
"type": "string",
|
|
92
|
+
"description": "Relayfile connection id.",
|
|
93
|
+
"readOnly": true
|
|
94
|
+
},
|
|
95
|
+
"_webhook": {
|
|
96
|
+
"type": "object",
|
|
97
|
+
"description": "Provider webhook metadata captured during sync.",
|
|
98
|
+
"readOnly": true,
|
|
99
|
+
"additionalProperties": true
|
|
100
|
+
},
|
|
101
|
+
"_connection": {
|
|
102
|
+
"type": "object",
|
|
103
|
+
"description": "Relayfile connection metadata captured during sync.",
|
|
104
|
+
"readOnly": true,
|
|
105
|
+
"additionalProperties": true
|
|
106
|
+
}
|
|
107
|
+
},
|
|
108
|
+
"additionalProperties": false,
|
|
109
|
+
"description": "Full resource record schema. Fields marked readOnly are synced from the provider and cannot be written by agents."
|
|
110
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@relayfile/adapter-reddit",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.5",
|
|
4
4
|
"description": "Reddit adapter package for Relayfile",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -28,7 +28,8 @@
|
|
|
28
28
|
}
|
|
29
29
|
},
|
|
30
30
|
"files": [
|
|
31
|
-
"dist"
|
|
31
|
+
"dist",
|
|
32
|
+
"discovery"
|
|
32
33
|
],
|
|
33
34
|
"scripts": {
|
|
34
35
|
"typecheck": "tsc --noEmit -p tsconfig.json",
|
|
@@ -54,7 +55,7 @@
|
|
|
54
55
|
"directory": "packages/reddit"
|
|
55
56
|
},
|
|
56
57
|
"dependencies": {
|
|
57
|
-
"@relayfile/adapter-core": "^0.3.
|
|
58
|
+
"@relayfile/adapter-core": "^0.3.38"
|
|
58
59
|
},
|
|
59
60
|
"peerDependencies": {
|
|
60
61
|
"@relayfile/sdk": ">=0.6.0 <1"
|