@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 CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@droz-js/sdk",
3
3
  "description": "Droz SDK",
4
- "version": "0.2.4",
4
+ "version": "0.2.6",
5
5
  "private": false,
6
6
  "exports": {
7
7
  ".": "./src/index.js",
@@ -24,9 +24,10 @@ function emptyAsyncIterator() {
24
24
  }
25
25
  };
26
26
  }
27
- function buildRequestInfo(req) {
28
- const operationNames = Array.isArray(req) ? req.map(r => r.operationName) : [req.operationName];
29
- return [...new Set(operationNames)].join(',');
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 = buildRequestInfo(request);
72
+ const args = buildArgs(request);
71
73
  // make POST request
72
74
  const response = await fetch(`${endpoint}?${args}`, {
73
75
  method: 'POST',
@@ -1,5 +1,5 @@
1
1
  import { GetSdk } from './helpers';
2
2
  export declare function WsClientBuilder<Sdk>(serviceName: string, getSdk: GetSdk<Sdk>): new () => {
3
3
  readonly ws: any;
4
- connect(): Promise<any>;
4
+ connect(): Promise<void>;
5
5
  } & Sdk;
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('Client not connected, you must call await client.connect(); first');
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
- return this.ws.connect();
59
+ await this.ws.connect();
60
60
  }
61
61
  }
62
62
  return Client;
@@ -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<any>;
4
+ connect(): Promise<void>;
5
5
  } & {
6
6
  createCustomer(variables: import("./sdks/drozchat").Exact<{
7
7
  input: import("./sdks/drozchat").CreateCustomerInput;