@sockethub/platform-metadata 1.0.1-alpha.6 → 1.0.1-alpha.8
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 +51 -9
- package/dist/index.d.ts +134 -0
- package/dist/index.js +55994 -55750
- package/dist/index.js.map +116 -114
- package/dist/schema.d.ts +115 -0
- package/package.json +8 -7
- package/src/index.ts +0 -63
- package/src/schema.ts +0 -22
package/dist/schema.d.ts
ADDED
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
export declare const PlatformMetadataSchema: {
|
|
2
|
+
name: string;
|
|
3
|
+
version: string;
|
|
4
|
+
contextUrl: string;
|
|
5
|
+
contextVersion: string;
|
|
6
|
+
schemaVersion: string;
|
|
7
|
+
messages: {
|
|
8
|
+
required: string[];
|
|
9
|
+
properties: {
|
|
10
|
+
type: {
|
|
11
|
+
type: string;
|
|
12
|
+
enum: string[];
|
|
13
|
+
};
|
|
14
|
+
object: boolean;
|
|
15
|
+
};
|
|
16
|
+
};
|
|
17
|
+
responses: {
|
|
18
|
+
type: string;
|
|
19
|
+
required: string[];
|
|
20
|
+
additionalProperties: boolean;
|
|
21
|
+
properties: {
|
|
22
|
+
"@context": {
|
|
23
|
+
type: string;
|
|
24
|
+
items: {
|
|
25
|
+
type: string;
|
|
26
|
+
};
|
|
27
|
+
};
|
|
28
|
+
id: {
|
|
29
|
+
type: string;
|
|
30
|
+
};
|
|
31
|
+
type: {
|
|
32
|
+
enum: string[];
|
|
33
|
+
};
|
|
34
|
+
actor: {
|
|
35
|
+
type: string;
|
|
36
|
+
required: string[];
|
|
37
|
+
additionalProperties: boolean;
|
|
38
|
+
properties: {
|
|
39
|
+
id: {
|
|
40
|
+
type: string;
|
|
41
|
+
};
|
|
42
|
+
type: {
|
|
43
|
+
enum: string[];
|
|
44
|
+
};
|
|
45
|
+
name: {
|
|
46
|
+
type: string;
|
|
47
|
+
};
|
|
48
|
+
};
|
|
49
|
+
};
|
|
50
|
+
object: {
|
|
51
|
+
$ref: string;
|
|
52
|
+
};
|
|
53
|
+
};
|
|
54
|
+
definitions: {
|
|
55
|
+
responses: {
|
|
56
|
+
page: {
|
|
57
|
+
type: string;
|
|
58
|
+
required: string[];
|
|
59
|
+
additionalProperties: boolean;
|
|
60
|
+
properties: {
|
|
61
|
+
type: {
|
|
62
|
+
enum: string[];
|
|
63
|
+
};
|
|
64
|
+
language: {
|
|
65
|
+
type: string;
|
|
66
|
+
};
|
|
67
|
+
title: {
|
|
68
|
+
type: string;
|
|
69
|
+
};
|
|
70
|
+
name: {
|
|
71
|
+
type: string;
|
|
72
|
+
};
|
|
73
|
+
description: {
|
|
74
|
+
type: string;
|
|
75
|
+
};
|
|
76
|
+
image: {
|
|
77
|
+
$ref: string;
|
|
78
|
+
};
|
|
79
|
+
url: {
|
|
80
|
+
type: string;
|
|
81
|
+
};
|
|
82
|
+
favicon: {
|
|
83
|
+
type: string;
|
|
84
|
+
};
|
|
85
|
+
charset: {
|
|
86
|
+
type: string;
|
|
87
|
+
};
|
|
88
|
+
};
|
|
89
|
+
};
|
|
90
|
+
ogImage: {
|
|
91
|
+
type: string;
|
|
92
|
+
items: {
|
|
93
|
+
type: string;
|
|
94
|
+
required: string[];
|
|
95
|
+
additionalProperties: boolean;
|
|
96
|
+
properties: {
|
|
97
|
+
url: {
|
|
98
|
+
type: string;
|
|
99
|
+
};
|
|
100
|
+
type: {
|
|
101
|
+
type: string;
|
|
102
|
+
};
|
|
103
|
+
width: {
|
|
104
|
+
type: string[];
|
|
105
|
+
};
|
|
106
|
+
height: {
|
|
107
|
+
type: string[];
|
|
108
|
+
};
|
|
109
|
+
};
|
|
110
|
+
};
|
|
111
|
+
};
|
|
112
|
+
};
|
|
113
|
+
};
|
|
114
|
+
};
|
|
115
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sockethub/platform-metadata",
|
|
3
|
-
"version": "1.0.1-alpha.
|
|
3
|
+
"version": "1.0.1-alpha.8",
|
|
4
4
|
"description": "Fetch metadata from a given URL",
|
|
5
5
|
"author": "Nick Jennings <nick@silverbucket.net>",
|
|
6
6
|
"license": "LGPL-3.0+",
|
|
@@ -11,17 +11,16 @@
|
|
|
11
11
|
"main": "dist/index.js",
|
|
12
12
|
"exports": {
|
|
13
13
|
".": {
|
|
14
|
-
"
|
|
14
|
+
"types": "./dist/index.d.ts",
|
|
15
15
|
"import": "./dist/index.js",
|
|
16
16
|
"default": "./dist/index.js"
|
|
17
17
|
}
|
|
18
18
|
},
|
|
19
19
|
"files": [
|
|
20
|
-
"src/",
|
|
21
20
|
"dist/"
|
|
22
21
|
],
|
|
23
22
|
"engines": {
|
|
24
|
-
"
|
|
23
|
+
"node": ">=20"
|
|
25
24
|
},
|
|
26
25
|
"keywords": [
|
|
27
26
|
"sockethub",
|
|
@@ -43,13 +42,15 @@
|
|
|
43
42
|
"clean:deps": "rm -rf node_modules"
|
|
44
43
|
},
|
|
45
44
|
"dependencies": {
|
|
45
|
+
"@sockethub/util": "^1.0.0-alpha.1",
|
|
46
46
|
"open-graph-scraper": "^6.11.0"
|
|
47
47
|
},
|
|
48
48
|
"devDependencies": {
|
|
49
|
-
"@sockethub/schemas": "^3.0.0-alpha.
|
|
49
|
+
"@sockethub/schemas": "^3.0.0-alpha.13"
|
|
50
50
|
},
|
|
51
51
|
"peerDependencies": {
|
|
52
|
-
"@sockethub/server": "^5.0.0-alpha.
|
|
52
|
+
"@sockethub/server": "^5.0.0-alpha.13"
|
|
53
53
|
},
|
|
54
|
-
"gitHead": "
|
|
54
|
+
"gitHead": "864733e5b34449ef39542eceb4ff11aa308081bc",
|
|
55
|
+
"types": "./dist/index.d.ts"
|
|
55
56
|
}
|
package/src/index.ts
DELETED
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
ActivityStream,
|
|
3
|
-
Logger,
|
|
4
|
-
PlatformCallback,
|
|
5
|
-
PlatformConfig,
|
|
6
|
-
PlatformInterface,
|
|
7
|
-
PlatformSession,
|
|
8
|
-
} from "@sockethub/schemas";
|
|
9
|
-
import ogs from "open-graph-scraper";
|
|
10
|
-
import { PlatformMetadataSchema } from "./schema";
|
|
11
|
-
|
|
12
|
-
export default class Metadata implements PlatformInterface {
|
|
13
|
-
private readonly log: Logger;
|
|
14
|
-
config: PlatformConfig = {
|
|
15
|
-
persist: false,
|
|
16
|
-
};
|
|
17
|
-
constructor(session: PlatformSession) {
|
|
18
|
-
this.log = session.log;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
get schema() {
|
|
22
|
-
return PlatformMetadataSchema;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
/**
|
|
26
|
-
* Stateless platforms are always ready to handle jobs.
|
|
27
|
-
*/
|
|
28
|
-
isInitialized(): boolean {
|
|
29
|
-
return true;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
fetch(job: ActivityStream, cb: PlatformCallback) {
|
|
33
|
-
this.log.debug(`fetching ${job.actor.id}`);
|
|
34
|
-
ogs({
|
|
35
|
-
url: job.actor.id,
|
|
36
|
-
})
|
|
37
|
-
.then((data) => {
|
|
38
|
-
const { result } = data;
|
|
39
|
-
job.actor.id = result.ogUrl || job.actor.id;
|
|
40
|
-
job.actor.name = result.ogSiteName || job.actor.name || "";
|
|
41
|
-
job.object = {
|
|
42
|
-
type: "page",
|
|
43
|
-
language: result.ogLocale,
|
|
44
|
-
title: result.ogTitle,
|
|
45
|
-
name: result.ogSiteName,
|
|
46
|
-
description: result.ogDescription || "",
|
|
47
|
-
image: result.ogImage,
|
|
48
|
-
url: result.ogUrl,
|
|
49
|
-
favicon: result.favicon,
|
|
50
|
-
charset: result.charset,
|
|
51
|
-
};
|
|
52
|
-
cb(null, job);
|
|
53
|
-
})
|
|
54
|
-
.catch((data) => {
|
|
55
|
-
const { result } = data;
|
|
56
|
-
cb(result.error);
|
|
57
|
-
});
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
cleanup(cb: PlatformCallback) {
|
|
61
|
-
cb();
|
|
62
|
-
}
|
|
63
|
-
}
|
package/src/schema.ts
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import packageJson from "../package.json" with { type: "json" };
|
|
2
|
-
const version = packageJson.version;
|
|
3
|
-
|
|
4
|
-
export const PlatformMetadataSchema = {
|
|
5
|
-
name: "metadata",
|
|
6
|
-
version: version,
|
|
7
|
-
messages: {
|
|
8
|
-
required: ["type"],
|
|
9
|
-
properties: {
|
|
10
|
-
type: {
|
|
11
|
-
type: "string",
|
|
12
|
-
enum: ["fetch"],
|
|
13
|
-
},
|
|
14
|
-
object: {
|
|
15
|
-
type: "object",
|
|
16
|
-
oneOf: [
|
|
17
|
-
{ $ref: "#/definitions/objectTypes/feed-parameters-url" },
|
|
18
|
-
],
|
|
19
|
-
},
|
|
20
|
-
},
|
|
21
|
-
},
|
|
22
|
-
};
|