@saplingai/sapling-js 1.0.38 → 1.0.39
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/client/index.d.ts +1 -0
- package/package.json +37 -17
- package/sapling/client.d.ts +23 -12
- package/sapling/client.js +24 -6
- package/npmtest/package.json +0 -11
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from '../sapling/client';
|
package/package.json
CHANGED
|
@@ -1,24 +1,54 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@saplingai/sapling-js",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.39",
|
|
4
4
|
"description": "JavaScript library for using the Sapling.ai API.",
|
|
5
5
|
"type": "module",
|
|
6
|
+
"main": "./sapling/client.js",
|
|
7
|
+
"types": "./sapling/client.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"types": "./sapling/client.d.ts",
|
|
11
|
+
"default": "./sapling/client.js"
|
|
12
|
+
},
|
|
13
|
+
"./client": {
|
|
14
|
+
"types": "./sapling/client.d.ts",
|
|
15
|
+
"default": "./sapling/client.js"
|
|
16
|
+
},
|
|
17
|
+
"./observer": {
|
|
18
|
+
"types": "./sapling/observer.d.ts",
|
|
19
|
+
"default": "./sapling/observer.js"
|
|
20
|
+
}
|
|
21
|
+
},
|
|
22
|
+
"files": [
|
|
23
|
+
"sapling",
|
|
24
|
+
"client",
|
|
25
|
+
"observer",
|
|
26
|
+
"index.ts",
|
|
27
|
+
"index.d.ts",
|
|
28
|
+
"README.md",
|
|
29
|
+
"LICENSE"
|
|
30
|
+
],
|
|
31
|
+
"scripts": {
|
|
32
|
+
"test": "node --test test/client.test.js test/pack.test.js",
|
|
33
|
+
"prepublishOnly": "npm test"
|
|
34
|
+
},
|
|
6
35
|
"dependencies": {
|
|
7
|
-
"axios": "^1.
|
|
36
|
+
"axios": "^1.19.0",
|
|
8
37
|
"uuid": "^8.3.2"
|
|
9
38
|
},
|
|
10
|
-
"
|
|
11
|
-
|
|
39
|
+
"publishConfig": {
|
|
40
|
+
"access": "public"
|
|
41
|
+
},
|
|
12
42
|
"author": "Sapling Intelligence",
|
|
13
43
|
"email": "info@sapling.ai",
|
|
14
44
|
"url": "https://sapling.ai",
|
|
15
45
|
"homepage": "https://sapling.ai/docs/",
|
|
16
46
|
"repository": {
|
|
17
47
|
"type": "git",
|
|
18
|
-
"url": "https://github.com/saplingai/sapling-
|
|
48
|
+
"url": "git+https://github.com/saplingai/sapling-js.git"
|
|
19
49
|
},
|
|
20
50
|
"bugs": {
|
|
21
|
-
"url": "https://github.com/saplingai/sapling-
|
|
51
|
+
"url": "https://github.com/saplingai/sapling-js/issues",
|
|
22
52
|
"email": "support@sapling.ai"
|
|
23
53
|
},
|
|
24
54
|
"license": "Apache-2.0",
|
|
@@ -27,15 +57,5 @@
|
|
|
27
57
|
"type": "Apache-2.0",
|
|
28
58
|
"url": "http://www.apache.org/licenses/LICENSE-2.0"
|
|
29
59
|
}
|
|
30
|
-
]
|
|
31
|
-
"exports": {
|
|
32
|
-
"./client": {
|
|
33
|
-
"types": "./sapling/client.d.ts",
|
|
34
|
-
"default": "./sapling/client.js"
|
|
35
|
-
},
|
|
36
|
-
"./observer": {
|
|
37
|
-
"types": "./sapling/observer.d.ts",
|
|
38
|
-
"default": "./sapling/observer.js"
|
|
39
|
-
}
|
|
40
|
-
}
|
|
60
|
+
]
|
|
41
61
|
}
|
package/sapling/client.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { AxiosResponse } from "axios";
|
|
2
2
|
|
|
3
|
-
type AdvancedEditOptions = {
|
|
3
|
+
export type AdvancedEditOptions = {
|
|
4
4
|
advanced_edits?: boolean,
|
|
5
5
|
adverbs?: boolean,
|
|
6
6
|
simplifications?: boolean,
|
|
@@ -20,13 +20,13 @@ type AdvancedEditOptions = {
|
|
|
20
20
|
violence?: boolean,
|
|
21
21
|
}
|
|
22
22
|
|
|
23
|
-
type ConstructorOptions = {
|
|
23
|
+
export type ConstructorOptions = {
|
|
24
24
|
timeout?: number,
|
|
25
25
|
hostname?: string,
|
|
26
26
|
pathname?: string,
|
|
27
27
|
}
|
|
28
28
|
|
|
29
|
-
type EditOptions = {
|
|
29
|
+
export type EditOptions = {
|
|
30
30
|
variety?: string,
|
|
31
31
|
autoApply?: boolean,
|
|
32
32
|
lang?: string,
|
|
@@ -34,11 +34,16 @@ type EditOptions = {
|
|
|
34
34
|
advancedEdits?: AdvancedEditOptions,
|
|
35
35
|
}
|
|
36
36
|
|
|
37
|
-
type AIDetectOptions = {
|
|
37
|
+
export type AIDetectOptions = {
|
|
38
38
|
sent_scores?: boolean,
|
|
39
39
|
}
|
|
40
40
|
|
|
41
|
-
type
|
|
41
|
+
export type LangdetectOptions = {
|
|
42
|
+
top_k?: number,
|
|
43
|
+
segments?: boolean,
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export type SpellcheckOptions = {
|
|
42
47
|
minLength?: number,
|
|
43
48
|
multipleEdits?: boolean,
|
|
44
49
|
lang?: string,
|
|
@@ -47,18 +52,24 @@ type SpellcheckOptions = {
|
|
|
47
52
|
userData?: any,
|
|
48
53
|
}
|
|
49
54
|
|
|
50
|
-
|
|
55
|
+
export type UserDetails = {
|
|
56
|
+
userId?: string,
|
|
57
|
+
anonUser?: boolean,
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
export declare class Client {
|
|
51
61
|
constructor(apiKey: string, options?: ConstructorOptions);
|
|
52
62
|
|
|
53
|
-
edits(text: string, sessionId
|
|
54
|
-
acceptEdit(editUUID: string, sessionId
|
|
55
|
-
rejectEdit(editUUID: string, sessionId
|
|
63
|
+
edits(text: string, sessionId?: string, options?: EditOptions, userDetails?: UserDetails): Promise<AxiosResponse>;
|
|
64
|
+
acceptEdit(editUUID: string, sessionId?: string, userId?: string): Promise<AxiosResponse>;
|
|
65
|
+
rejectEdit(editUUID: string, sessionId?: string, userId?: string): Promise<AxiosResponse>;
|
|
56
66
|
|
|
57
|
-
spellcheck(text: string, sessionId
|
|
67
|
+
spellcheck(text: string, sessionId?: string, options?: SpellcheckOptions, userDetails?: UserDetails): Promise<AxiosResponse>;
|
|
58
68
|
|
|
59
|
-
complete(query: string, sessionId
|
|
60
|
-
acceptComplete(completeUUID: string, query: string, completion: string, sessionId
|
|
69
|
+
complete(query: string, sessionId?: string): Promise<AxiosResponse>;
|
|
70
|
+
acceptComplete(completeUUID: string, query: string, completion: string, sessionId?: string): Promise<AxiosResponse>;
|
|
61
71
|
tone(text: string): Promise<AxiosResponse>;
|
|
62
72
|
|
|
63
73
|
aidetect(text: string, options?: AIDetectOptions): Promise<AxiosResponse>;
|
|
74
|
+
langdetect(text: string, options?: LangdetectOptions): Promise<AxiosResponse>;
|
|
64
75
|
}
|
package/sapling/client.js
CHANGED
|
@@ -106,27 +106,27 @@ export class Client {
|
|
|
106
106
|
}
|
|
107
107
|
|
|
108
108
|
if (options.minLength != null) {
|
|
109
|
-
data.min_length = minLength;
|
|
109
|
+
data.min_length = options.minLength;
|
|
110
110
|
}
|
|
111
111
|
|
|
112
112
|
if (options.multipleEdits != null) {
|
|
113
|
-
data.multiple_edits = multipleEdits;
|
|
113
|
+
data.multiple_edits = options.multipleEdits;
|
|
114
114
|
}
|
|
115
115
|
|
|
116
116
|
if (options.lang != null) {
|
|
117
|
-
data.lang = lang;
|
|
117
|
+
data.lang = options.lang;
|
|
118
118
|
}
|
|
119
119
|
|
|
120
120
|
if (options.autoApply != null) {
|
|
121
|
-
data.auto_apply = autoApply;
|
|
121
|
+
data.auto_apply = options.autoApply;
|
|
122
122
|
}
|
|
123
123
|
|
|
124
124
|
if (options.variety != null) {
|
|
125
|
-
data.variety = variety;
|
|
125
|
+
data.variety = options.variety;
|
|
126
126
|
}
|
|
127
127
|
|
|
128
128
|
if (options.userData != null) {
|
|
129
|
-
data.user_data = userData;
|
|
129
|
+
data.user_data = options.userData;
|
|
130
130
|
}
|
|
131
131
|
|
|
132
132
|
if (userDetails) {
|
|
@@ -176,6 +176,24 @@ export class Client {
|
|
|
176
176
|
return this.axiosPromise(url, 'post', data);
|
|
177
177
|
}
|
|
178
178
|
|
|
179
|
+
langdetect(text, options = {}) {
|
|
180
|
+
const url = `${this.urlEndpoint}langdetect`;
|
|
181
|
+
|
|
182
|
+
let data = {
|
|
183
|
+
text,
|
|
184
|
+
key: this.apiKey,
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
if (options?.top_k != null) {
|
|
188
|
+
data.top_k = options.top_k;
|
|
189
|
+
}
|
|
190
|
+
if (options?.segments != null) {
|
|
191
|
+
data.segments = options.segments;
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
return this.axiosPromise(url, 'post', data);
|
|
195
|
+
}
|
|
196
|
+
|
|
179
197
|
aidetect(text, options = {}) {
|
|
180
198
|
const url = `${this.urlEndpoint}aidetect`;
|
|
181
199
|
|
package/npmtest/package.json
DELETED