@droz-js/sdk 0.2.12 → 0.2.14

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.12",
4
+ "version": "0.2.14",
5
5
  "private": false,
6
6
  "exports": {
7
7
  ".": "./src/index.js",
@@ -3,6 +3,7 @@ export declare const ChatWidget: new (options?: import("./client/http").HttpClie
3
3
  readonly http: any;
4
4
  forTenant(tenant: string): any;
5
5
  withAuthorization(authorization: import("./client/helpers").AuthorizationProvider): any;
6
+ withCustomHeaders(headers: () => Record<string, string>): any;
6
7
  } & {
7
8
  getChatWidget(variables: import("./sdks/chatwidget").Exact<{
8
9
  id: string;
@@ -66,7 +66,10 @@ class DrozSdk {
66
66
  async function promise() {
67
67
  // fetch instances from discovery service
68
68
  const data = await fetch(`${helpers_1.serviceDiscoveryEndpoint}/discover/${tenant}`);
69
- const json = await data.json();
69
+ const json = await data.json().catch(error => {
70
+ console.error(error);
71
+ return {};
72
+ });
70
73
  const instances = json.instances ?? [];
71
74
  // validate it's a valid tenant
72
75
  if (instances.length === 0) {
@@ -1,4 +1,5 @@
1
1
  import { AuthorizationProvider, GetSdk } from './helpers';
2
+ type HeadersProvider = () => Record<string, string>;
2
3
  export interface HttpClientOptions {
3
4
  debug?: boolean;
4
5
  }
@@ -6,4 +7,6 @@ export declare function HttpClientBuilder<Sdk>(serviceName: string, getSdk: GetS
6
7
  readonly http: any;
7
8
  forTenant(tenant: string): any;
8
9
  withAuthorization(authorization: AuthorizationProvider): any;
10
+ withCustomHeaders(headers: HeadersProvider): any;
9
11
  } & Sdk;
12
+ export {};
@@ -34,6 +34,7 @@ class HttpRequester {
34
34
  options;
35
35
  tenant;
36
36
  authorization;
37
+ customHeaders;
37
38
  constructor(serviceName, options) {
38
39
  this.serviceName = serviceName;
39
40
  this.options = options;
@@ -44,6 +45,9 @@ class HttpRequester {
44
45
  withAuthorization(authorization) {
45
46
  this.authorization = authorization;
46
47
  }
48
+ withCustomHeaders(headers) {
49
+ this.customHeaders = headers;
50
+ }
47
51
  build() {
48
52
  return this.requester.bind(this);
49
53
  }
@@ -69,6 +73,11 @@ class HttpRequester {
69
73
  heads.set('Authorization', authorization);
70
74
  heads.set('Content-Type', 'application/json');
71
75
  heads.set('Accept', 'application/json');
76
+ if (this.customHeaders) {
77
+ const custom = this.customHeaders();
78
+ for (const [key, value] of Object.entries(custom))
79
+ heads.set(key, value);
80
+ }
72
81
  const headers = Object.fromEntries(heads.entries());
73
82
  return { endpoint, headers };
74
83
  }
@@ -110,6 +119,10 @@ function HttpClientBuilder(serviceName, getSdk) {
110
119
  this.http.withAuthorization(authorization);
111
120
  return this;
112
121
  }
122
+ withCustomHeaders(headers) {
123
+ this.http.withCustomHeaders(headers);
124
+ return this;
125
+ }
113
126
  }
114
127
  return Client;
115
128
  }
package/src/drozbot.d.ts CHANGED
@@ -3,6 +3,7 @@ export declare const DrozBot: new (options?: import("./client/http").HttpClientO
3
3
  readonly http: any;
4
4
  forTenant(tenant: string): any;
5
5
  withAuthorization(authorization: import("./client/helpers").AuthorizationProvider): any;
6
+ withCustomHeaders(headers: () => Record<string, string>): any;
6
7
  } & {
7
8
  getDrozBotInstance(variables: import("./sdks/drozbot").Exact<{
8
9
  id: string;
@@ -12,18 +12,6 @@ export declare const DrozChatWs: new () => {
12
12
  getDrozChatAgent(variables: import("./sdks/drozchat").Exact<{
13
13
  id: string;
14
14
  }>, options?: unknown): Promise<import("./sdks/drozchat").GetDrozChatAgentQuery>;
15
- createCustomer(variables: import("./sdks/drozchat").Exact<{
16
- input: import("./sdks/drozchat").CreateCustomerInput;
17
- }>, options?: unknown): Promise<import("./sdks/drozchat").CreateCustomerMutation>;
18
- updateCustomer(variables: import("./sdks/drozchat").Exact<{
19
- input: import("./sdks/drozchat").UpdateCustomerInput;
20
- }>, options?: unknown): Promise<import("./sdks/drozchat").UpdateCustomerMutation>;
21
- listCustomers(variables?: import("./sdks/drozchat").Exact<{
22
- next?: object;
23
- }>, options?: unknown): Promise<import("./sdks/drozchat").ListCustomersQuery>;
24
- getCustomer(variables: import("./sdks/drozchat").Exact<{
25
- id: string;
26
- }>, options?: unknown): Promise<import("./sdks/drozchat").GetCustomerQuery>;
27
15
  getTicket(variables: import("./sdks/drozchat").Exact<{
28
16
  id: string;
29
17
  }>, options?: unknown): Promise<import("./sdks/drozchat").GetTicketQuery>;
package/src/drozchat.d.ts CHANGED
@@ -3,6 +3,7 @@ export declare const DrozChat: new (options?: import("./client/http").HttpClient
3
3
  readonly http: any;
4
4
  forTenant(tenant: string): any;
5
5
  withAuthorization(authorization: import("./client/helpers").AuthorizationProvider): any;
6
+ withCustomHeaders(headers: () => Record<string, string>): any;
6
7
  } & {
7
8
  createDrozChatAgent(variables: import("./sdks/drozchat").Exact<{
8
9
  input: import("./sdks/drozchat").CreateDrozChatAgentInput;
@@ -13,18 +14,6 @@ export declare const DrozChat: new (options?: import("./client/http").HttpClient
13
14
  getDrozChatAgent(variables: import("./sdks/drozchat").Exact<{
14
15
  id: string;
15
16
  }>, options?: unknown): Promise<import("./sdks/drozchat").GetDrozChatAgentQuery>;
16
- createCustomer(variables: import("./sdks/drozchat").Exact<{
17
- input: import("./sdks/drozchat").CreateCustomerInput;
18
- }>, options?: unknown): Promise<import("./sdks/drozchat").CreateCustomerMutation>;
19
- updateCustomer(variables: import("./sdks/drozchat").Exact<{
20
- input: import("./sdks/drozchat").UpdateCustomerInput;
21
- }>, options?: unknown): Promise<import("./sdks/drozchat").UpdateCustomerMutation>;
22
- listCustomers(variables?: import("./sdks/drozchat").Exact<{
23
- next?: object;
24
- }>, options?: unknown): Promise<import("./sdks/drozchat").ListCustomersQuery>;
25
- getCustomer(variables: import("./sdks/drozchat").Exact<{
26
- id: string;
27
- }>, options?: unknown): Promise<import("./sdks/drozchat").GetCustomerQuery>;
28
17
  getTicket(variables: import("./sdks/drozchat").Exact<{
29
18
  id: string;
30
19
  }>, options?: unknown): Promise<import("./sdks/drozchat").GetTicketQuery>;
package/src/droznexo.d.ts CHANGED
@@ -3,6 +3,7 @@ export declare const DrozNexo: new (options?: import("./client/http").HttpClient
3
3
  readonly http: any;
4
4
  forTenant(tenant: string): any;
5
5
  withAuthorization(authorization: import("./client/helpers").AuthorizationProvider): any;
6
+ withCustomHeaders(headers: () => Record<string, string>): any;
6
7
  } & {
7
8
  createDrozNexoAgent(variables: import("./sdks/droznexo").Exact<{
8
9
  input: import("./sdks/droznexo").CreateDrozNexoAgentInput;
@@ -3,6 +3,7 @@ export declare const MercadoLivre: new (options?: import("./client/http").HttpCl
3
3
  readonly http: any;
4
4
  forTenant(tenant: string): any;
5
5
  withAuthorization(authorization: import("./client/helpers").AuthorizationProvider): any;
6
+ withCustomHeaders(headers: () => Record<string, string>): any;
6
7
  } & {
7
8
  getMercadoLivreInstance(variables: import("./sdks/mercadolivre").Exact<{
8
9
  id: string;
package/src/nucleus.d.ts CHANGED
@@ -3,6 +3,7 @@ export declare const Nucleus: new (options?: import("./client/http").HttpClientO
3
3
  readonly http: any;
4
4
  forTenant(tenant: string): any;
5
5
  withAuthorization(authorization: import("./client/helpers").AuthorizationProvider): any;
6
+ withCustomHeaders(headers: () => Record<string, string>): any;
6
7
  } & {
7
8
  getAgent(variables: import("./sdks/nucleus").Exact<{
8
9
  id: string;
@@ -35,6 +36,12 @@ export declare const Nucleus: new (options?: import("./client/http").HttpClientO
35
36
  appType?: import("./sdks/nucleus").AppType;
36
37
  withApp?: boolean;
37
38
  }>, options?: unknown): Promise<import("./sdks/nucleus").ListAppInstancesQuery>;
39
+ registerAppInstance(variables: import("./sdks/nucleus").Exact<{
40
+ input: import("./sdks/nucleus").RegisterAppInstanceInput;
41
+ }>, options?: unknown): Promise<import("./sdks/nucleus").RegisterAppInstanceMutation>;
42
+ unregisterAppInstance(variables: import("./sdks/nucleus").Exact<{
43
+ input: import("./sdks/nucleus").UnregisterAppInstanceInput;
44
+ }>, options?: unknown): Promise<import("./sdks/nucleus").UnregisterAppInstanceMutation>;
38
45
  getAmplifyConfig(variables?: import("./sdks/nucleus").Exact<{
39
46
  [key: string]: never;
40
47
  }>, options?: unknown): Promise<import("./sdks/nucleus").GetAmplifyConfigQuery>;
@@ -59,6 +66,15 @@ export declare const Nucleus: new (options?: import("./client/http").HttpClientO
59
66
  removeCredentials(variables: import("./sdks/nucleus").Exact<{
60
67
  input: import("./sdks/nucleus").RemoveCredentialsInput;
61
68
  }>, options?: unknown): Promise<import("./sdks/nucleus").RemoveCredentialsMutation>;
69
+ getCustomer(variables: import("./sdks/nucleus").Exact<{
70
+ identifier: string;
71
+ }>, options?: unknown): Promise<import("./sdks/nucleus").GetCustomerQuery>;
72
+ listCustomers(variables?: import("./sdks/nucleus").Exact<{
73
+ next?: object;
74
+ }>, options?: unknown): Promise<import("./sdks/nucleus").ListCustomersQuery>;
75
+ getOrCreateCustomer(variables: import("./sdks/nucleus").Exact<{
76
+ input: import("./sdks/nucleus").GetOrCreateCustomerInput;
77
+ }>, options?: unknown): Promise<import("./sdks/nucleus").GetOrCreateCustomerMutation>;
62
78
  getCronJob(variables: import("./sdks/nucleus").Exact<{
63
79
  id: string;
64
80
  }>, options?: unknown): Promise<import("./sdks/nucleus").GetCronJobQuery>;
@@ -74,21 +90,21 @@ export declare const Nucleus: new (options?: import("./client/http").HttpClientO
74
90
  removeCronJob(variables: import("./sdks/nucleus").Exact<{
75
91
  input: import("./sdks/nucleus").RemoveCronJobInput;
76
92
  }>, options?: unknown): Promise<import("./sdks/nucleus").RemoveCronJobMutation>;
77
- resolveSession(variables: import("./sdks/nucleus").Exact<{
78
- sessionId?: string;
79
- userId?: string;
80
- triggerDrn: string;
81
- }>, options?: unknown): Promise<import("./sdks/nucleus").ResolveSessionQuery>;
82
- getSessionData(variables: import("./sdks/nucleus").Exact<{
93
+ startSession(variables: import("./sdks/nucleus").Exact<{
94
+ input: import("./sdks/nucleus").StartSessionInput;
95
+ withCustomer?: boolean;
96
+ }>, options?: unknown): Promise<import("./sdks/nucleus").StartSessionMutation>;
97
+ getSession(variables: import("./sdks/nucleus").Exact<{
83
98
  sessionId: string;
84
- namespace?: string;
85
- }>, options?: unknown): Promise<import("./sdks/nucleus").GetSessionDataQuery>;
86
- setSessionData(variables: import("./sdks/nucleus").Exact<{
87
- input: import("./sdks/nucleus").SetSessionDataInput;
88
- }>, options?: unknown): Promise<import("./sdks/nucleus").SetSessionDataMutation>;
89
- patchSessionData(variables: import("./sdks/nucleus").Exact<{
90
- input: import("./sdks/nucleus").PatchSessionDataInput;
91
- }>, options?: unknown): Promise<import("./sdks/nucleus").PatchSessionDataMutation>;
99
+ withCustomer?: boolean;
100
+ withAttributes?: boolean;
101
+ }>, options?: unknown): Promise<import("./sdks/nucleus").GetSessionQuery>;
102
+ setSessionAttribute(variables: import("./sdks/nucleus").Exact<{
103
+ input: import("./sdks/nucleus").SetSessionAttributeInput;
104
+ }>, options?: unknown): Promise<import("./sdks/nucleus").SetSessionAttributeMutation>;
105
+ patchSessionAttributes(variables: import("./sdks/nucleus").Exact<{
106
+ input: import("./sdks/nucleus").PatchSessionAttributesInput;
107
+ }>, options?: unknown): Promise<import("./sdks/nucleus").PatchSessionAttributesMutation>;
92
108
  getStateMachine(variables: import("./sdks/nucleus").Exact<{
93
109
  id: string;
94
110
  versionId: string;
@@ -3,6 +3,7 @@ export declare const Reclameaqui: new (options?: import("./client/http").HttpCli
3
3
  readonly http: any;
4
4
  forTenant(tenant: string): any;
5
5
  withAuthorization(authorization: import("./client/helpers").AuthorizationProvider): any;
6
+ withCustomHeaders(headers: () => Record<string, string>): any;
6
7
  } & {
7
8
  getReclameAquiInstance(variables: import("./sdks/reclameaqui").Exact<{
8
9
  id: string;
@@ -69,6 +69,10 @@ export type Scalars = {
69
69
  input: any;
70
70
  output: any;
71
71
  };
72
+ PhoneNumber: {
73
+ input: string;
74
+ output: string;
75
+ };
72
76
  Set: {
73
77
  input: Set<any>;
74
78
  output: any[];
@@ -82,6 +86,11 @@ export type Scalars = {
82
86
  output: void;
83
87
  };
84
88
  };
89
+ export declare enum AppInstanceStatus {
90
+ Active = "Active",
91
+ Failing = "Failing",
92
+ Inactive = "Inactive"
93
+ }
85
94
  export type ChatWidget = {
86
95
  id: Scalars['ID']['output'];
87
96
  name: Scalars['String']['output'];
@@ -89,6 +98,7 @@ export type ChatWidget = {
89
98
  export type ChatWidgetMessage = {
90
99
  id: Scalars['ID']['output'];
91
100
  payload: Array<ChatWidgetMessagePayload>;
101
+ sessionClosed: Scalars['Boolean']['output'];
92
102
  };
93
103
  export type ChatWidgetMessagePayload = {
94
104
  content: Scalars['String']['output'];
@@ -149,6 +159,7 @@ export type SendMessageToChatWidgetInput = {
149
159
  };
150
160
  export type StartChatWidgetSessionInput = {
151
161
  chatId: Scalars['ID']['input'];
162
+ userIdentifier: Scalars['ID']['input'];
152
163
  };
153
164
  export type Subscription = {
154
165
  onChatWidgetMessage: ChatWidgetMessage;
@@ -1,7 +1,13 @@
1
1
  "use strict";
2
2
  /* istanbul ignore file */
3
3
  Object.defineProperty(exports, "__esModule", { value: true });
4
- exports.serviceName = exports.getSdk = exports.OnChatWidgetMessageDocument = exports.SendMessageToChatWidgetDocument = exports.StartChatWidgetSessionDocument = exports.RemoveChatWidgetDocument = exports.UpdateChatWidgetDocument = exports.CreateChatWidgetDocument = exports.ListChatWidgetsDocument = exports.GetChatWidgetDocument = exports.ChatWidgetMessageFragmentDoc = exports.ChatWidgetFragmentDoc = exports.Typenames = exports.SubscriptionAction = void 0;
4
+ exports.serviceName = exports.getSdk = exports.OnChatWidgetMessageDocument = exports.SendMessageToChatWidgetDocument = exports.StartChatWidgetSessionDocument = exports.RemoveChatWidgetDocument = exports.UpdateChatWidgetDocument = exports.CreateChatWidgetDocument = exports.ListChatWidgetsDocument = exports.GetChatWidgetDocument = exports.ChatWidgetMessageFragmentDoc = exports.ChatWidgetFragmentDoc = exports.Typenames = exports.SubscriptionAction = exports.AppInstanceStatus = void 0;
5
+ var AppInstanceStatus;
6
+ (function (AppInstanceStatus) {
7
+ AppInstanceStatus["Active"] = "Active";
8
+ AppInstanceStatus["Failing"] = "Failing";
9
+ AppInstanceStatus["Inactive"] = "Inactive";
10
+ })(AppInstanceStatus || (exports.AppInstanceStatus = AppInstanceStatus = {}));
5
11
  var SubscriptionAction;
6
12
  (function (SubscriptionAction) {
7
13
  SubscriptionAction["Created"] = "CREATED";
@@ -69,6 +69,10 @@ export type Scalars = {
69
69
  input: any;
70
70
  output: any;
71
71
  };
72
+ PhoneNumber: {
73
+ input: string;
74
+ output: string;
75
+ };
72
76
  Set: {
73
77
  input: Set<any>;
74
78
  output: any[];
@@ -82,6 +86,11 @@ export type Scalars = {
82
86
  output: void;
83
87
  };
84
88
  };
89
+ export declare enum AppInstanceStatus {
90
+ Active = "Active",
91
+ Failing = "Failing",
92
+ Inactive = "Inactive"
93
+ }
85
94
  export type CreateDrozBotInstanceInput = {
86
95
  credentialsId: Scalars['ID']['input'];
87
96
  isTest?: InputMaybe<Scalars['Boolean']['input']>;
@@ -102,7 +111,7 @@ export type CreateDrozBotTicketProfileInput = {
102
111
  email?: InputMaybe<Scalars['String']['input']>;
103
112
  identifier?: InputMaybe<Scalars['ID']['input']>;
104
113
  name?: InputMaybe<Scalars['String']['input']>;
105
- phone?: InputMaybe<Scalars['String']['input']>;
114
+ phone?: InputMaybe<Scalars['PhoneNumber']['input']>;
106
115
  };
107
116
  export type DrozBotInstance = {
108
117
  credentialsId: Scalars['ID']['output'];
@@ -1,7 +1,13 @@
1
1
  "use strict";
2
2
  /* istanbul ignore file */
3
3
  Object.defineProperty(exports, "__esModule", { value: true });
4
- exports.serviceName = exports.getSdk = exports.CreateDrozBotTicketCommentDocument = exports.CreateDrozBotTicketDocument = exports.RemoveDrozBotInstanceDocument = exports.UpdateDrozBotInstanceDocument = exports.CreateDrozBotInstanceDocument = exports.ListDrozBotInstancesDocument = exports.GetDrozBotInstanceDocument = exports.DrozbotFragmentDoc = exports.Typenames = void 0;
4
+ exports.serviceName = exports.getSdk = exports.CreateDrozBotTicketCommentDocument = exports.CreateDrozBotTicketDocument = exports.RemoveDrozBotInstanceDocument = exports.UpdateDrozBotInstanceDocument = exports.CreateDrozBotInstanceDocument = exports.ListDrozBotInstancesDocument = exports.GetDrozBotInstanceDocument = exports.DrozbotFragmentDoc = exports.Typenames = exports.AppInstanceStatus = void 0;
5
+ var AppInstanceStatus;
6
+ (function (AppInstanceStatus) {
7
+ AppInstanceStatus["Active"] = "Active";
8
+ AppInstanceStatus["Failing"] = "Failing";
9
+ AppInstanceStatus["Inactive"] = "Inactive";
10
+ })(AppInstanceStatus || (exports.AppInstanceStatus = AppInstanceStatus = {}));
5
11
  var Typenames;
6
12
  (function (Typenames) {
7
13
  Typenames["Any"] = "Any";