@droz-js/sdk 0.5.7 → 0.5.9

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.5.7",
4
+ "version": "0.5.9",
5
5
  "private": false,
6
6
  "exports": {
7
7
  ".": "./src/index.js",
@@ -32,4 +32,4 @@
32
32
  "src/**/*.d.ts",
33
33
  "README.md"
34
34
  ]
35
- }
35
+ }
@@ -4,6 +4,7 @@ export declare const Casasbahia: new (options?: import("./client/http").HttpClie
4
4
  forTenant(tenant: string): any;
5
5
  withAuthorization(authorization: import("./client/helpers").AuthorizationProvider): any;
6
6
  withCustomHeaders(headers: () => Record<string, string>): any;
7
+ withHttpRequestExecutor(httpRequestExecutor: import("./client/http").HttpRequestExecutor): any;
7
8
  } & {
8
9
  getCasasBahiaInstance(variables: import("./sdks/casasbahia").Exact<{
9
10
  id: string;
@@ -4,6 +4,7 @@ export declare const ChatWidget: new (options?: import("./client/http").HttpClie
4
4
  forTenant(tenant: string): any;
5
5
  withAuthorization(authorization: import("./client/helpers").AuthorizationProvider): any;
6
6
  withCustomHeaders(headers: () => Record<string, string>): any;
7
+ withHttpRequestExecutor(httpRequestExecutor: import("./client/http").HttpRequestExecutor): any;
7
8
  } & {
8
9
  getChatWidget(variables: import("./sdks/chatwidget").Exact<{
9
10
  id: string;
@@ -42,6 +42,11 @@ function toAuthorizationProvider(type, ...values) {
42
42
  if (type == 'Bearer') {
43
43
  return `Bearer ${values[0]}`;
44
44
  }
45
+ // used on zendesk where it uses a proxy to authenticate
46
+ // and the authentication header is like `Basic {{settings.token}}`
47
+ if (type === 'BasicRaw') {
48
+ return `Basic ${values.join(':')}`;
49
+ }
45
50
  throw new SdkConfigurationError(`Invalid authentication type '${type}'`);
46
51
  }
47
52
  exports.toAuthorizationProvider = toAuthorizationProvider;
@@ -3,10 +3,23 @@ type HeadersProvider = () => Record<string, string>;
3
3
  export interface HttpClientOptions {
4
4
  debug?: boolean;
5
5
  }
6
+ export interface HttpRequest {
7
+ url: string;
8
+ method: string;
9
+ headers: Record<string, string>;
10
+ body: string;
11
+ }
12
+ export interface HttpResponse {
13
+ status: number;
14
+ json: () => Promise<any>;
15
+ text: () => Promise<string>;
16
+ }
17
+ export type HttpRequestExecutor = (request: HttpRequest) => Promise<HttpResponse>;
6
18
  export declare function HttpClientBuilder<Sdk>(serviceName: string, getSdk: GetSdk<Sdk>): new (options?: HttpClientOptions) => {
7
19
  readonly http: any;
8
20
  forTenant(tenant: string): any;
9
21
  withAuthorization(authorization: AuthorizationProvider): any;
10
22
  withCustomHeaders(headers: HeadersProvider): any;
23
+ withHttpRequestExecutor(httpRequestExecutor: HttpRequestExecutor): any;
11
24
  } & Sdk;
12
25
  export {};
@@ -24,6 +24,13 @@ function emptyAsyncIterator() {
24
24
  }
25
25
  };
26
26
  }
27
+ async function fetchHttpRequestExecutor(request) {
28
+ return await fetch(request.url, {
29
+ method: request.method,
30
+ headers: request.headers,
31
+ body: request.body
32
+ });
33
+ }
27
34
  function buildArgs(req) {
28
35
  const names = [].concat(req).map(each => each.operationName);
29
36
  const uniques = [...new Set(names)].join(',');
@@ -35,6 +42,7 @@ class HttpRequester {
35
42
  tenant;
36
43
  authorization;
37
44
  customHeaders;
45
+ httpRequestExecutor = fetchHttpRequestExecutor;
38
46
  constructor(serviceName, options) {
39
47
  this.serviceName = serviceName;
40
48
  this.options = options;
@@ -48,6 +56,9 @@ class HttpRequester {
48
56
  withCustomHeaders(headers) {
49
57
  this.customHeaders = headers;
50
58
  }
59
+ withHttpRequestExecutor(httpRequestExecutor) {
60
+ this.httpRequestExecutor = httpRequestExecutor;
61
+ }
51
62
  build() {
52
63
  return this.requester.bind(this);
53
64
  }
@@ -89,7 +100,8 @@ class HttpRequester {
89
100
  console.log('[Droz SDK]:batch', { args, endpoint, headers, body });
90
101
  }
91
102
  // make POST request
92
- const response = await fetch(`${endpoint}?${args}`, {
103
+ const response = await this.httpRequestExecutor({
104
+ url: `${endpoint}?${args}`,
93
105
  method: 'POST',
94
106
  headers,
95
107
  body
@@ -127,6 +139,10 @@ function HttpClientBuilder(serviceName, getSdk) {
127
139
  this.http.withCustomHeaders(headers);
128
140
  return this;
129
141
  }
142
+ withHttpRequestExecutor(httpRequestExecutor) {
143
+ this.http.withHttpRequestExecutor(httpRequestExecutor);
144
+ return this;
145
+ }
130
146
  }
131
147
  return Client;
132
148
  }
@@ -4,6 +4,7 @@ export declare const DrozAdmin: new (options?: import("./client/http").HttpClien
4
4
  forTenant(tenant: string): any;
5
5
  withAuthorization(authorization: import("./client/helpers").AuthorizationProvider): any;
6
6
  withCustomHeaders(headers: () => Record<string, string>): any;
7
+ withHttpRequestExecutor(httpRequestExecutor: import("./client/http").HttpRequestExecutor): any;
7
8
  } & {
8
9
  getAmplifyConfig(variables?: import("./sdks/drozcommons").Exact<{
9
10
  forDev?: boolean;
package/src/drozbot.d.ts CHANGED
@@ -4,6 +4,7 @@ export declare const DrozBot: new (options?: import("./client/http").HttpClientO
4
4
  forTenant(tenant: string): any;
5
5
  withAuthorization(authorization: import("./client/helpers").AuthorizationProvider): any;
6
6
  withCustomHeaders(headers: () => Record<string, string>): any;
7
+ withHttpRequestExecutor(httpRequestExecutor: import("./client/http").HttpRequestExecutor): any;
7
8
  } & {
8
9
  getDrozBotInstance(variables: import("./sdks/drozbot").Exact<{
9
10
  id: string;
@@ -35,6 +35,7 @@ export declare const DrozChatWs: new () => {
35
35
  }>, options?: unknown): Promise<import("./sdks/drozchat").GetTicketQuery>;
36
36
  listTickets(variables: import("./sdks/drozchat").Exact<{
37
37
  state: import("./sdks/drozchat").TicketState;
38
+ status?: import("./sdks/drozchat").TicketStatus | import("./sdks/drozchat").TicketStatus[];
38
39
  assigneeId?: string;
39
40
  next?: object;
40
41
  }>, options?: unknown): Promise<import("./sdks/drozchat").ListTicketsQuery>;
package/src/drozchat.d.ts CHANGED
@@ -4,6 +4,7 @@ export declare const DrozChat: new (options?: import("./client/http").HttpClient
4
4
  forTenant(tenant: string): any;
5
5
  withAuthorization(authorization: import("./client/helpers").AuthorizationProvider): any;
6
6
  withCustomHeaders(headers: () => Record<string, string>): any;
7
+ withHttpRequestExecutor(httpRequestExecutor: import("./client/http").HttpRequestExecutor): any;
7
8
  } & {
8
9
  getDrozChatChannel(variables: import("./sdks/drozchat").Exact<{
9
10
  id: string;
@@ -37,6 +38,7 @@ export declare const DrozChat: new (options?: import("./client/http").HttpClient
37
38
  }>, options?: unknown): Promise<import("./sdks/drozchat").GetTicketQuery>;
38
39
  listTickets(variables: import("./sdks/drozchat").Exact<{
39
40
  state: import("./sdks/drozchat").TicketState;
41
+ status?: import("./sdks/drozchat").TicketStatus | import("./sdks/drozchat").TicketStatus[];
40
42
  assigneeId?: string;
41
43
  next?: object;
42
44
  }>, options?: unknown): Promise<import("./sdks/drozchat").ListTicketsQuery>;
package/src/droznexo.d.ts CHANGED
@@ -4,6 +4,7 @@ export declare const DrozNexo: new (options?: import("./client/http").HttpClient
4
4
  forTenant(tenant: string): any;
5
5
  withAuthorization(authorization: import("./client/helpers").AuthorizationProvider): any;
6
6
  withCustomHeaders(headers: () => Record<string, string>): any;
7
+ withHttpRequestExecutor(httpRequestExecutor: import("./client/http").HttpRequestExecutor): any;
7
8
  } & {
8
9
  listDrozNexoSuggestions(variables?: import("./sdks/droznexo").Exact<{
9
10
  [key: string]: never;
@@ -4,6 +4,7 @@ export declare const MercadoLivre: new (options?: import("./client/http").HttpCl
4
4
  forTenant(tenant: string): any;
5
5
  withAuthorization(authorization: import("./client/helpers").AuthorizationProvider): any;
6
6
  withCustomHeaders(headers: () => Record<string, string>): any;
7
+ withHttpRequestExecutor(httpRequestExecutor: import("./client/http").HttpRequestExecutor): any;
7
8
  } & {
8
9
  getMercadoLivreInstance(variables: import("./sdks/mercadolivre").Exact<{
9
10
  id: string;
package/src/nucleus.d.ts CHANGED
@@ -6,6 +6,7 @@ declare const Nucleus_base: new (options?: import("./client/http").HttpClientOpt
6
6
  forTenant(tenant: string): any;
7
7
  withAuthorization(authorization: import("./client/helpers").AuthorizationProvider): any;
8
8
  withCustomHeaders(headers: () => Record<string, string>): any;
9
+ withHttpRequestExecutor(httpRequestExecutor: import("./client/http").HttpRequestExecutor): any;
9
10
  } & {
10
11
  getMe(variables?: import("./sdks/nucleus").Exact<{
11
12
  [key: string]: never;
@@ -4,6 +4,7 @@ export declare const Reclameaqui: new (options?: import("./client/http").HttpCli
4
4
  forTenant(tenant: string): any;
5
5
  withAuthorization(authorization: import("./client/helpers").AuthorizationProvider): any;
6
6
  withCustomHeaders(headers: () => Record<string, string>): any;
7
+ withHttpRequestExecutor(httpRequestExecutor: import("./client/http").HttpRequestExecutor): any;
7
8
  } & {
8
9
  getReclameAquiInstance(variables: import("./sdks/reclameaqui").Exact<{
9
10
  id: string;
@@ -254,6 +254,7 @@ export type QueryListTicketsArgs = {
254
254
  assigneeId?: InputMaybe<Scalars['ID']['input']>;
255
255
  next?: InputMaybe<Scalars['Base64']['input']>;
256
256
  state: TicketState;
257
+ status?: InputMaybe<Array<TicketStatus>>;
257
258
  };
258
259
  export type QueryListTicketsInProgressMineArgs = {
259
260
  next?: InputMaybe<Scalars['Base64']['input']>;
@@ -484,6 +485,7 @@ export type GetTicketQuery = {
484
485
  };
485
486
  export type ListTicketsQueryVariables = Exact<{
486
487
  state: TicketState;
488
+ status?: InputMaybe<Array<TicketStatus> | TicketStatus>;
487
489
  assigneeId?: InputMaybe<Scalars['ID']['input']>;
488
490
  next?: InputMaybe<Scalars['Base64']['input']>;
489
491
  }>;
@@ -607,7 +609,7 @@ export declare const EnableDrozChatChannelDocument = "\n mutation enableDrozC
607
609
  export declare const AddDrozChatChannelAgentDocument = "\n mutation addDrozChatChannelAgent($input: AddDrozChatChannelAgentInput!) {\n addDrozChatChannelAgent(input: $input) {\n ...drozChatChannel\n }\n}\n \n fragment drozChatChannel on DrozChatChannel {\n id\n name\n agentIds\n createdAt\n updatedAt\n}\n ";
608
610
  export declare const RemoveDrozChatChannelAgentDocument = "\n mutation removeDrozChatChannelAgent($input: RemoveDrozChatChannelAgentInput!) {\n removeDrozChatChannelAgent(input: $input) {\n ...drozChatChannel\n }\n}\n \n fragment drozChatChannel on DrozChatChannel {\n id\n name\n agentIds\n createdAt\n updatedAt\n}\n ";
609
611
  export declare const GetTicketDocument = "\n query getTicket($id: ID!) {\n getTicket(id: $id) {\n ...ticketWithSession\n }\n}\n \n fragment ticketWithSession on Ticket {\n ...ticket\n sessionAttributes {\n ...sessionAttributes\n }\n}\n \n fragment ticket on Ticket {\n channelId\n id\n state\n status\n priority\n externalProviderId\n externalId\n assignee {\n ...drozChatAgent\n }\n customer {\n ...customer\n }\n triggerApp {\n ...ticketTriggerApp\n }\n channel {\n ...drozChatChannel\n }\n messagesCount\n lastMessage\n lastMessageAt\n unreadMessagesCount\n createdAt\n updatedAt\n}\n \n fragment drozChatAgent on DrozChatAgent {\n id\n name\n}\n \n\n fragment customer on DrozChatCustomer {\n id\n name\n email\n phone\n document\n createdAt\n updatedAt\n}\n \n\n fragment ticketTriggerApp on TicketTriggerApp {\n drn\n name\n appId\n appName\n appColor\n channels {\n id\n main\n readonly\n hidden\n sources\n unreadMessagesCount\n }\n}\n \n\n fragment drozChatChannel on DrozChatChannel {\n id\n name\n agentIds\n createdAt\n updatedAt\n}\n \n\n fragment sessionAttributes on TicketSessionAttributes {\n organization\n source\n order\n products\n review\n tags\n}\n ";
610
- export declare const ListTicketsDocument = "\n query listTickets($state: TicketState!, $assigneeId: ID, $next: Base64) {\n listTickets(state: $state, assigneeId: $assigneeId, next: $next) {\n nodes {\n ...ticket\n }\n pageInfo {\n hasNext\n next\n }\n }\n}\n \n fragment ticket on Ticket {\n channelId\n id\n state\n status\n priority\n externalProviderId\n externalId\n assignee {\n ...drozChatAgent\n }\n customer {\n ...customer\n }\n triggerApp {\n ...ticketTriggerApp\n }\n channel {\n ...drozChatChannel\n }\n messagesCount\n lastMessage\n lastMessageAt\n unreadMessagesCount\n createdAt\n updatedAt\n}\n \n fragment drozChatAgent on DrozChatAgent {\n id\n name\n}\n \n\n fragment customer on DrozChatCustomer {\n id\n name\n email\n phone\n document\n createdAt\n updatedAt\n}\n \n\n fragment ticketTriggerApp on TicketTriggerApp {\n drn\n name\n appId\n appName\n appColor\n channels {\n id\n main\n readonly\n hidden\n sources\n unreadMessagesCount\n }\n}\n \n\n fragment drozChatChannel on DrozChatChannel {\n id\n name\n agentIds\n createdAt\n updatedAt\n}\n ";
612
+ export declare const ListTicketsDocument = "\n query listTickets($state: TicketState!, $status: [TicketStatus!], $assigneeId: ID, $next: Base64) {\n listTickets(\n state: $state\n status: $status\n assigneeId: $assigneeId\n next: $next\n ) {\n nodes {\n ...ticket\n }\n pageInfo {\n hasNext\n next\n }\n }\n}\n \n fragment ticket on Ticket {\n channelId\n id\n state\n status\n priority\n externalProviderId\n externalId\n assignee {\n ...drozChatAgent\n }\n customer {\n ...customer\n }\n triggerApp {\n ...ticketTriggerApp\n }\n channel {\n ...drozChatChannel\n }\n messagesCount\n lastMessage\n lastMessageAt\n unreadMessagesCount\n createdAt\n updatedAt\n}\n \n fragment drozChatAgent on DrozChatAgent {\n id\n name\n}\n \n\n fragment customer on DrozChatCustomer {\n id\n name\n email\n phone\n document\n createdAt\n updatedAt\n}\n \n\n fragment ticketTriggerApp on TicketTriggerApp {\n drn\n name\n appId\n appName\n appColor\n channels {\n id\n main\n readonly\n hidden\n sources\n unreadMessagesCount\n }\n}\n \n\n fragment drozChatChannel on DrozChatChannel {\n id\n name\n agentIds\n createdAt\n updatedAt\n}\n ";
611
613
  export declare const ListTicketsInProgressMineDocument = "\n query listTicketsInProgressMine($next: Base64) {\n listTicketsInProgressMine(next: $next) {\n nodes {\n ...ticket\n }\n pageInfo {\n hasNext\n next\n }\n }\n}\n \n fragment ticket on Ticket {\n channelId\n id\n state\n status\n priority\n externalProviderId\n externalId\n assignee {\n ...drozChatAgent\n }\n customer {\n ...customer\n }\n triggerApp {\n ...ticketTriggerApp\n }\n channel {\n ...drozChatChannel\n }\n messagesCount\n lastMessage\n lastMessageAt\n unreadMessagesCount\n createdAt\n updatedAt\n}\n \n fragment drozChatAgent on DrozChatAgent {\n id\n name\n}\n \n\n fragment customer on DrozChatCustomer {\n id\n name\n email\n phone\n document\n createdAt\n updatedAt\n}\n \n\n fragment ticketTriggerApp on TicketTriggerApp {\n drn\n name\n appId\n appName\n appColor\n channels {\n id\n main\n readonly\n hidden\n sources\n unreadMessagesCount\n }\n}\n \n\n fragment drozChatChannel on DrozChatChannel {\n id\n name\n agentIds\n createdAt\n updatedAt\n}\n ";
612
614
  export declare const ListTicketMessagesDocument = "\n query listTicketMessages($ticketId: ID!, $channelId: ID!, $next: Base64) {\n listTicketMessages(ticketId: $ticketId, channelId: $channelId, next: $next) {\n pageInfo {\n hasNext\n next\n }\n nodes {\n ...ticketMessage\n }\n }\n}\n \n fragment ticketMessage on TicketMessage {\n id\n ticketId\n from\n to\n channelId\n contentType\n content\n filename\n size\n createdAt\n updatedAt\n}\n ";
613
615
  export declare const CreateTicketDocument = "\n mutation createTicket($input: CreateTicketInput!) {\n createTicket(input: $input) {\n ...ticketWithSession\n }\n}\n \n fragment ticketWithSession on Ticket {\n ...ticket\n sessionAttributes {\n ...sessionAttributes\n }\n}\n \n fragment ticket on Ticket {\n channelId\n id\n state\n status\n priority\n externalProviderId\n externalId\n assignee {\n ...drozChatAgent\n }\n customer {\n ...customer\n }\n triggerApp {\n ...ticketTriggerApp\n }\n channel {\n ...drozChatChannel\n }\n messagesCount\n lastMessage\n lastMessageAt\n unreadMessagesCount\n createdAt\n updatedAt\n}\n \n fragment drozChatAgent on DrozChatAgent {\n id\n name\n}\n \n\n fragment customer on DrozChatCustomer {\n id\n name\n email\n phone\n document\n createdAt\n updatedAt\n}\n \n\n fragment ticketTriggerApp on TicketTriggerApp {\n drn\n name\n appId\n appName\n appColor\n channels {\n id\n main\n readonly\n hidden\n sources\n unreadMessagesCount\n }\n}\n \n\n fragment drozChatChannel on DrozChatChannel {\n id\n name\n agentIds\n createdAt\n updatedAt\n}\n \n\n fragment sessionAttributes on TicketSessionAttributes {\n organization\n source\n order\n products\n review\n tags\n}\n ";
@@ -233,8 +233,13 @@ exports.GetTicketDocument = `
233
233
  }
234
234
  ${exports.TicketWithSessionFragmentDoc}`;
235
235
  exports.ListTicketsDocument = `
236
- query listTickets($state: TicketState!, $assigneeId: ID, $next: Base64) {
237
- listTickets(state: $state, assigneeId: $assigneeId, next: $next) {
236
+ query listTickets($state: TicketState!, $status: [TicketStatus!], $assigneeId: ID, $next: Base64) {
237
+ listTickets(
238
+ state: $state
239
+ status: $status
240
+ assigneeId: $assigneeId
241
+ next: $next
242
+ ) {
238
243
  nodes {
239
244
  ...ticket
240
245
  }
package/src/zendesk.d.ts CHANGED
@@ -4,6 +4,7 @@ export declare const Zendesk: new (options?: import("./client/http").HttpClientO
4
4
  forTenant(tenant: string): any;
5
5
  withAuthorization(authorization: import("./client/helpers").AuthorizationProvider): any;
6
6
  withCustomHeaders(headers: () => Record<string, string>): any;
7
+ withHttpRequestExecutor(httpRequestExecutor: import("./client/http").HttpRequestExecutor): any;
7
8
  } & {
8
9
  getZendeskInstance(variables: import("./sdks/zendesk").Exact<{
9
10
  id: string;