@droz-js/sdk 0.2.4 → 0.2.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/package.json +1 -1
- package/src/client/http.js +6 -4
- package/src/client/ws.d.ts +1 -1
- package/src/client/ws.js +2 -2
- package/src/drozchat-ws.d.ts +1 -1
package/package.json
CHANGED
package/src/client/http.js
CHANGED
|
@@ -24,9 +24,10 @@ function emptyAsyncIterator() {
|
|
|
24
24
|
}
|
|
25
25
|
};
|
|
26
26
|
}
|
|
27
|
-
function
|
|
28
|
-
const
|
|
29
|
-
|
|
27
|
+
function buildArgs(req) {
|
|
28
|
+
const names = [].concat(req).map(each => each.operationName);
|
|
29
|
+
const uniques = [...new Set(names)].join(',');
|
|
30
|
+
return `_=${uniques}`;
|
|
30
31
|
}
|
|
31
32
|
class HttpRequester {
|
|
32
33
|
serviceName;
|
|
@@ -61,13 +62,14 @@ class HttpRequester {
|
|
|
61
62
|
const heads = new Headers();
|
|
62
63
|
heads.set('Authorization', authorization);
|
|
63
64
|
heads.set('Content-Type', 'application/json');
|
|
65
|
+
heads.set('Accept', 'application/json');
|
|
64
66
|
const headers = Object.fromEntries(heads.entries());
|
|
65
67
|
return { endpoint, headers };
|
|
66
68
|
}
|
|
67
69
|
async inbatches(request) {
|
|
68
70
|
const { endpoint, headers } = await this.buildRequest();
|
|
69
71
|
const body = JSON.stringify(request);
|
|
70
|
-
const args =
|
|
72
|
+
const args = buildArgs(request);
|
|
71
73
|
// make POST request
|
|
72
74
|
const response = await fetch(`${endpoint}?${args}`, {
|
|
73
75
|
method: 'POST',
|
package/src/client/ws.d.ts
CHANGED
package/src/client/ws.js
CHANGED
|
@@ -32,7 +32,7 @@ class WsRequester {
|
|
|
32
32
|
}
|
|
33
33
|
requester(query, variables) {
|
|
34
34
|
if (!this.client)
|
|
35
|
-
throw new Error('
|
|
35
|
+
throw new Error('ws client not connected, you must call await client.connect(); first');
|
|
36
36
|
const isSubscription = query.trim().startsWith('subscription ');
|
|
37
37
|
const operation = { query, variables };
|
|
38
38
|
const iterable = this.client.iterate(operation);
|
|
@@ -56,7 +56,7 @@ function WsClientBuilder(serviceName, getSdk) {
|
|
|
56
56
|
Object.assign(this, sdk);
|
|
57
57
|
}
|
|
58
58
|
async connect() {
|
|
59
|
-
|
|
59
|
+
await this.ws.connect();
|
|
60
60
|
}
|
|
61
61
|
}
|
|
62
62
|
return Client;
|
package/src/drozchat-ws.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export * from './sdks/drozchat';
|
|
2
2
|
export declare const DrozChatWs: new () => {
|
|
3
3
|
readonly ws: any;
|
|
4
|
-
connect(): Promise<
|
|
4
|
+
connect(): Promise<void>;
|
|
5
5
|
} & {
|
|
6
6
|
createCustomer(variables: import("./sdks/drozchat").Exact<{
|
|
7
7
|
input: import("./sdks/drozchat").CreateCustomerInput;
|