@sockethub/platform-dummy 3.0.0-alpha.3 → 3.0.0-alpha.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
@@ -1,3 +1,55 @@
1
1
  # @sockethub/platform-dummy
2
2
 
3
- A Sockethub test platform, not intended for actual use.
3
+ A Sockethub test platform for development and testing purposes.
4
+
5
+ ## About
6
+
7
+ This platform provides basic testing functionality for Sockethub development. It implements
8
+ simple verbs that can be used to test ActivityStreams message flow, error handling, and
9
+ platform communication without requiring external service connections.
10
+
11
+ ## Implemented Verbs (`@type`)
12
+
13
+ * **echo** - Returns the received message unchanged
14
+ * **fail** - Intentionally fails with an error message
15
+ * **throw** - Throws an exception for testing error handling
16
+ * **greet** - Returns a greeting message
17
+
18
+ ## Usage
19
+
20
+ ### Echo Example
21
+
22
+ ```json
23
+ {
24
+ "@type": "echo",
25
+ "context": "dummy",
26
+ "actor": {
27
+ "@id": "test-user"
28
+ },
29
+ "object": {
30
+ "content": "Hello World"
31
+ }
32
+ }
33
+ ```
34
+
35
+ ### Response
36
+
37
+ ```json
38
+ {
39
+ "@type": "echo",
40
+ "context": "dummy",
41
+ "actor": {
42
+ "@id": "test-user"
43
+ },
44
+ "object": {
45
+ "content": "Hello World"
46
+ }
47
+ }
48
+ ```
49
+
50
+ ## Use Cases
51
+
52
+ * **Development testing**: Test ActivityStreams message processing
53
+ * **Integration testing**: Verify platform loading and communication
54
+ * **Error handling**: Test error scenarios and exception handling
55
+ * **Learning**: Understand Sockethub platform structure and ActivityStreams format
package/package.json CHANGED
@@ -1,32 +1,39 @@
1
1
  {
2
2
  "name": "@sockethub/platform-dummy",
3
3
  "description": "A sockethub platform dummy module",
4
- "version": "3.0.0-alpha.3",
4
+ "version": "3.0.0-alpha.6",
5
+ "type": "module",
5
6
  "private": false,
6
7
  "author": "Nick Jennings <nick@silverbucket.net>",
7
8
  "license": "LGPL-3.0+",
8
- "main": "index.js",
9
+ "publishConfig": {
10
+ "access": "public"
11
+ },
12
+ "main": "src/index.ts",
13
+ "engines": {
14
+ "bun": ">=1.2"
15
+ },
9
16
  "keywords": [
10
17
  "sockethub",
11
18
  "dummy"
12
19
  ],
20
+ "devDependencies": {
21
+ "@sockethub/schemas": "3.0.0-alpha.6",
22
+ "@types/bun": "latest"
23
+ },
13
24
  "peerDependencies": {
14
- "@sockethub/server": ">=5.0.0-alpha.2"
25
+ "@sockethub/server": "5.0.0-alpha.6"
15
26
  },
16
27
  "peerDependenciesMeta": {
17
28
  "@sockethub/server": {
18
29
  "optional": true
19
30
  }
20
31
  },
21
- "scripts": {
22
- "clean:deps": "npx rimraf node_modules",
23
- "test": "exit 0"
24
- },
25
32
  "repository": {
26
33
  "type": "git",
27
34
  "url": "git+https://github.com/sockethub/sockethub.git",
28
35
  "directory": "packages/platform-dummy"
29
36
  },
30
37
  "homepage": "https://github.com/sockethub/sockethub/tree/master/packages/platform-dummy",
31
- "gitHead": "f02238a478b7ffd3f31d8deea292eb67e630a86b"
38
+ "gitHead": "f8a937e071e7a209f94b94f63e68faa27784e00e"
32
39
  }
package/src/index.ts ADDED
@@ -0,0 +1,74 @@
1
+ import type {
2
+ ActivityStream,
3
+ Logger,
4
+ PlatformCallback,
5
+ PlatformInterface,
6
+ PlatformSchemaStruct,
7
+ PlatformSession,
8
+ StatelessPlatformConfig,
9
+ } from "@sockethub/schemas";
10
+
11
+ import packageJSON from "../package.json" with { type: "json" };
12
+
13
+ interface DummyPlatformConfig extends StatelessPlatformConfig {
14
+ greeting: string;
15
+ }
16
+
17
+ export default class Dummy implements PlatformInterface {
18
+ debug: Logger;
19
+ config: DummyPlatformConfig = {
20
+ persist: false,
21
+ greeting: "Hello",
22
+ };
23
+
24
+ constructor(session: PlatformSession) {
25
+ this.debug = session.debug;
26
+ }
27
+
28
+ get schema(): PlatformSchemaStruct {
29
+ return {
30
+ name: "dummy",
31
+ version: packageJSON.version,
32
+ messages: {
33
+ required: ["type"],
34
+ properties: {
35
+ type: {
36
+ enum: ["echo", "fail", "throw", "greet"],
37
+ },
38
+ },
39
+ },
40
+ credentials: {},
41
+ };
42
+ }
43
+
44
+ echo(job: ActivityStream, cb: PlatformCallback) {
45
+ job.target = job.actor;
46
+ job.actor = {
47
+ id: "dummy",
48
+ type: "platform",
49
+ };
50
+ cb(undefined, job);
51
+ }
52
+
53
+ fail(job: ActivityStream, cb: PlatformCallback) {
54
+ cb(new Error(job.object.content));
55
+ }
56
+
57
+ throw(job: ActivityStream, cb: PlatformCallback) {
58
+ throw new Error(job.object.content);
59
+ }
60
+
61
+ greet(job: ActivityStream, cb: PlatformCallback) {
62
+ job.target = job.actor;
63
+ job.actor = {
64
+ id: "dummy",
65
+ type: "platform",
66
+ };
67
+ job.object.content = `${this.config.greeting} ${job.object.content}`;
68
+ cb(undefined, job);
69
+ }
70
+
71
+ cleanup(cb: PlatformCallback) {
72
+ cb();
73
+ }
74
+ }
package/index.js DELETED
@@ -1,46 +0,0 @@
1
- class Dummy {
2
- constructor(cfg) {
3
- cfg = (typeof cfg === 'object') ? cfg : {};
4
- this.id = cfg.id;
5
- this.debug = cfg.debug;
6
- this.sendToClient = cfg.sendToClient;
7
- }
8
-
9
- get schema() {
10
- return {
11
- name: "dummy",
12
- version: require('./package.json').version,
13
- messages: {
14
- "required": ["type"],
15
- "properties": {
16
- "type": {
17
- "enum": ["echo", "fail"]
18
- }
19
- }
20
- },
21
- credentials: {}
22
- };
23
- }
24
-
25
- get config() {
26
- return {
27
- persist: false,
28
- requireCredentials: []
29
- };
30
- };
31
-
32
- echo(job, cb) {
33
- this.sendToClient(job.object.content);
34
- cb();
35
- };
36
-
37
- fail(job, cb) {
38
- cb(new Error(job.object.content));
39
- };
40
-
41
- cleanup(cb) {
42
- cb();
43
- };
44
- }
45
-
46
- module.exports = Dummy;