@saplingai/sapling-js 1.0.24 → 1.0.26

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,6 +1,6 @@
1
1
  {
2
2
  "name": "@saplingai/sapling-js",
3
- "version": "1.0.24",
3
+ "version": "1.0.26",
4
4
  "description": "JavaScript library for using the Sapling.ai API.",
5
5
  "type": "module",
6
6
  "dependencies": {
package/sapling/client.js CHANGED
@@ -26,7 +26,7 @@ export class Client {
26
26
  });
27
27
  }
28
28
 
29
- edits(text, sessionId, options = {}) {
29
+ edits(text, sessionId, options = {}, userDetails = {}) {
30
30
  const url = `${this.urlEndpoint}edits`;
31
31
  sessionId = sessionId || this.defaultSessionId;
32
32
 
@@ -56,10 +56,16 @@ export class Client {
56
56
  data.advanced_edits = options.advancedEdits;
57
57
  }
58
58
 
59
+ if (userDetails) {
60
+ const { userId, anonUser } = userDetails;
61
+ data.user_id = userId;
62
+ data.is_anon_user = anonUser || false;
63
+ }
64
+
59
65
  return this.axiosPromise(url, 'post', data);
60
66
  }
61
67
 
62
- acceptEdit(editUUID, sessionId) {
68
+ acceptEdit(editUUID, sessionId, userId) {
63
69
  const url = `${this.urlEndpoint}edits/${editUUID}/accept`;
64
70
  sessionId = sessionId || this.defaultSessionId;
65
71
  let data = {
@@ -67,10 +73,14 @@ export class Client {
67
73
  session_id: sessionId,
68
74
  }
69
75
 
76
+ if (userId) {
77
+ data.user_id = userId;
78
+ }
79
+
70
80
  return this.axiosPromise(url, 'post', data);
71
81
  }
72
82
 
73
- rejectEdit(editUUID, sessionId) {
83
+ rejectEdit(editUUID, sessionId, userId) {
74
84
  const url = `${this.urlEndpoint}edits/${editUUID}/reject`;
75
85
  sessionId = sessionId || this.defaultSessionId;
76
86
  let data = {
@@ -78,10 +88,14 @@ export class Client {
78
88
  session_id: sessionId,
79
89
  }
80
90
 
91
+ if (userId) {
92
+ data.user_id = userId;
93
+ }
94
+
81
95
  return this.axiosPromise(url, 'post', data);
82
96
  }
83
97
 
84
- spellcheck(text, sessionId, options = {}) {
98
+ spellcheck(text, sessionId, options = {}, userDetails = {}) {
85
99
  const url = `${this.urlEndpoint}spellcheck`;
86
100
  sessionId = sessionId || this.defaultSessionId;
87
101
 
@@ -115,6 +129,12 @@ export class Client {
115
129
  data.user_data = userData;
116
130
  }
117
131
 
132
+ if (userDetails) {
133
+ const { userId, anonUser } = userDetails;
134
+ data.user_id = userId;
135
+ data.is_anon_user = anonUser || false;
136
+ }
137
+
118
138
  return this.axiosPromise(url, 'post', data);
119
139
  }
120
140