@awsless/awsless 0.0.364 → 0.0.365
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/dist/client.d.ts +13 -1
- package/dist/client.js +21 -0
- package/package.json +5 -4
package/dist/client.d.ts
CHANGED
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
import * as _awsless_mqtt from '@awsless/mqtt';
|
|
2
|
+
import { ClientProps, QoS } from '@awsless/mqtt';
|
|
3
|
+
|
|
1
4
|
interface AuthResources {
|
|
2
5
|
}
|
|
3
6
|
declare const Auth: AuthResources;
|
|
@@ -51,4 +54,13 @@ declare const createHttpClient: <S extends Schema>(fetcher: HttpFetcher) => {
|
|
|
51
54
|
post<P_1 extends keyof S["POST"]>(routeKey: Extract<P_1, string>, props?: Props<GetRoute<S, "POST", P_1>>): Promise<GetRoute<S, "POST", P_1>["response"]>;
|
|
52
55
|
};
|
|
53
56
|
|
|
54
|
-
|
|
57
|
+
type MessageCallback = (payload: any) => void;
|
|
58
|
+
declare const createPubSubClient: (props: ClientProps) => {
|
|
59
|
+
publish(topic: string, event: string, payload: unknown, qos: QoS): Promise<void>;
|
|
60
|
+
subscribe(topic: string, event: string, callback: MessageCallback): Promise<_awsless_mqtt.Unsubscribe>;
|
|
61
|
+
connected: boolean;
|
|
62
|
+
topics: string[];
|
|
63
|
+
destroy(): Promise<void>;
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
export { Auth, type AuthResources, GraphQL, type GraphQLResources, type GraphQLSchema, type HTTP, type HttpFetcher, createHttpClient, createHttpFetcher, createPubSubClient, getAuthProps, getGraphQLProps };
|
package/dist/client.js
CHANGED
|
@@ -77,11 +77,32 @@ var createHttpClient = (fetcher) => {
|
|
|
77
77
|
}
|
|
78
78
|
};
|
|
79
79
|
};
|
|
80
|
+
|
|
81
|
+
// src/lib/client/pubsub.ts
|
|
82
|
+
import { createClient } from "@awsless/mqtt";
|
|
83
|
+
var createPubSubClient = (props) => {
|
|
84
|
+
const mqtt = createClient(props);
|
|
85
|
+
return {
|
|
86
|
+
...mqtt,
|
|
87
|
+
publish(topic, event, payload, qos) {
|
|
88
|
+
return mqtt.publish(topic, JSON.stringify([event, payload]), qos);
|
|
89
|
+
},
|
|
90
|
+
subscribe(topic, event, callback) {
|
|
91
|
+
return mqtt.subscribe(topic, (message) => {
|
|
92
|
+
const [eventName, payload] = JSON.parse(message.toString("utf8"));
|
|
93
|
+
if (event === eventName) {
|
|
94
|
+
callback(payload);
|
|
95
|
+
}
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
};
|
|
99
|
+
};
|
|
80
100
|
export {
|
|
81
101
|
Auth,
|
|
82
102
|
GraphQL,
|
|
83
103
|
createHttpClient,
|
|
84
104
|
createHttpFetcher,
|
|
105
|
+
createPubSubClient,
|
|
85
106
|
getAuthProps,
|
|
86
107
|
getGraphQLProps
|
|
87
108
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@awsless/awsless",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.365",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"sideEffects": false,
|
|
@@ -29,15 +29,16 @@
|
|
|
29
29
|
},
|
|
30
30
|
"peerDependencies": {
|
|
31
31
|
"@awsless/iot": "^0.0.2",
|
|
32
|
-
"@awsless/
|
|
32
|
+
"@awsless/open-search": "^0.0.15",
|
|
33
33
|
"@awsless/lambda": "^0.0.26",
|
|
34
34
|
"@awsless/redis": "^0.0.12",
|
|
35
|
-
"@awsless/open-search": "^0.0.15",
|
|
36
35
|
"@awsless/sns": "^0.0.7",
|
|
37
36
|
"@awsless/sqs": "^0.0.7",
|
|
38
37
|
"@awsless/ssm": "^0.0.7",
|
|
39
38
|
"@awsless/validate": "^0.0.15",
|
|
40
|
-
"@awsless/
|
|
39
|
+
"@awsless/s3": "^0.0.18",
|
|
40
|
+
"@awsless/weak-cache": "^0.0.1",
|
|
41
|
+
"@awsless/mqtt": "^0.0.2"
|
|
41
42
|
},
|
|
42
43
|
"dependencies": {
|
|
43
44
|
"@arcanyx/cidr-slicer": "^0.3.0",
|