@gleanwork/api-client 0.2.0 → 0.3.0
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/LICENSE +21 -0
- package/README.md +22 -10
- package/dist/commonjs/__tests__/adminsearch.test.js +1783 -12
- package/dist/commonjs/__tests__/adminsearch.test.js.map +1 -1
- package/dist/commonjs/__tests__/announcements.test.js +3922 -2
- package/dist/commonjs/__tests__/announcements.test.js.map +1 -1
- package/dist/commonjs/__tests__/answers.test.js +1315 -30
- package/dist/commonjs/__tests__/answers.test.js.map +1 -1
- package/dist/commonjs/__tests__/chat.test.js +19803 -1532
- package/dist/commonjs/__tests__/chat.test.js.map +1 -1
- package/dist/commonjs/__tests__/clientsearch.test.js +3850 -142
- package/dist/commonjs/__tests__/clientsearch.test.js.map +1 -1
- package/dist/commonjs/__tests__/clientshortcuts.test.js +1051 -8
- package/dist/commonjs/__tests__/clientshortcuts.test.js.map +1 -1
- package/dist/commonjs/__tests__/collections.test.js +1053 -8
- package/dist/commonjs/__tests__/collections.test.js.map +1 -1
- package/dist/commonjs/lib/config.d.ts +6 -6
- package/dist/commonjs/lib/config.d.ts.map +1 -1
- package/dist/commonjs/lib/config.js +5 -5
- package/dist/commonjs/lib/config.js.map +1 -1
- package/dist/esm/__tests__/adminsearch.test.js +1783 -12
- package/dist/esm/__tests__/adminsearch.test.js.map +1 -1
- package/dist/esm/__tests__/announcements.test.js +3922 -2
- package/dist/esm/__tests__/announcements.test.js.map +1 -1
- package/dist/esm/__tests__/answers.test.js +1315 -30
- package/dist/esm/__tests__/answers.test.js.map +1 -1
- package/dist/esm/__tests__/chat.test.js +19803 -1532
- package/dist/esm/__tests__/chat.test.js.map +1 -1
- package/dist/esm/__tests__/clientsearch.test.js +3850 -142
- package/dist/esm/__tests__/clientsearch.test.js.map +1 -1
- package/dist/esm/__tests__/clientshortcuts.test.js +1051 -8
- package/dist/esm/__tests__/clientshortcuts.test.js.map +1 -1
- package/dist/esm/__tests__/collections.test.js +1053 -8
- package/dist/esm/__tests__/collections.test.js.map +1 -1
- package/dist/esm/lib/config.d.ts +6 -6
- package/dist/esm/lib/config.d.ts.map +1 -1
- package/dist/esm/lib/config.js +5 -5
- package/dist/esm/lib/config.js.map +1 -1
- package/docs/sdks/announcements/README.md +7846 -4
- package/docs/sdks/answers/README.md +2910 -340
- package/docs/sdks/clientshortcuts/README.md +2120 -34
- package/docs/sdks/collections/README.md +2124 -34
- package/docs/sdks/search/README.md +11601 -643
- package/jsr.json +1 -1
- package/package.json +2 -1
- package/src/__tests__/adminsearch.test.ts +1790 -12
- package/src/__tests__/announcements.test.ts +3936 -2
- package/src/__tests__/answers.test.ts +1324 -30
- package/src/__tests__/chat.test.ts +20119 -1599
- package/src/__tests__/clientsearch.test.ts +3867 -146
- package/src/__tests__/clientshortcuts.test.ts +1061 -8
- package/src/__tests__/collections.test.ts +1062 -8
- package/src/lib/config.ts +7 -7
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025, Glean Technologies Inc.
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -13,12 +13,24 @@ Each namespace has its own authentication requirements and access patterns. Whil
|
|
|
13
13
|
|
|
14
14
|
```typescript
|
|
15
15
|
// Example of accessing Client namespace
|
|
16
|
-
const glean = new Glean({
|
|
17
|
-
|
|
16
|
+
const glean = new Glean({
|
|
17
|
+
instance: 'instance-name',
|
|
18
|
+
apiToken: 'client-token'
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
await glean.client.search.query({
|
|
22
|
+
query: 'search term'
|
|
23
|
+
});
|
|
18
24
|
|
|
19
25
|
// Example of accessing Indexing namespace
|
|
20
|
-
const glean = new Glean({
|
|
21
|
-
|
|
26
|
+
const glean = new Glean({
|
|
27
|
+
instance: 'instance-name',
|
|
28
|
+
apiToken: 'indexing-token'
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
await glean.indexing.documents.index({
|
|
32
|
+
/* document data */
|
|
33
|
+
});
|
|
22
34
|
```
|
|
23
35
|
|
|
24
36
|
Remember that each namespace requires its own authentication token type as described in the [Authentication Methods](#authentication-methods) section.
|
|
@@ -866,11 +878,11 @@ In some rare cases, the SDK can fail to get a response from the server or even m
|
|
|
866
878
|
|
|
867
879
|
### Server Variables
|
|
868
880
|
|
|
869
|
-
The default server `https://{
|
|
881
|
+
The default server `https://{instance}-be.glean.com` contains variables and is set to `https://instance-name-be.glean.com` by default. To override default values, the following parameters are available when initializing the SDK client instance:
|
|
870
882
|
|
|
871
|
-
| Variable
|
|
872
|
-
|
|
|
873
|
-
| `
|
|
883
|
+
| Variable | Parameter | Default | Description |
|
|
884
|
+
| ---------- | ------------------ | ----------------- | ------------------------------------------------------------------------------------------------------------ |
|
|
885
|
+
| `instance` | `instance: string` | `"instance-name"` | The instance name (typically the email domain without the extension) that determines the deployment backend. |
|
|
874
886
|
|
|
875
887
|
#### Example
|
|
876
888
|
|
|
@@ -878,7 +890,7 @@ The default server `https://{domain}-be.glean.com` contains variables and is set
|
|
|
878
890
|
import { Glean } from "@gleanwork/api-client";
|
|
879
891
|
|
|
880
892
|
const glean = new Glean({
|
|
881
|
-
|
|
893
|
+
instance: "<value>",
|
|
882
894
|
apiToken: process.env["GLEAN_API_TOKEN"] ?? "",
|
|
883
895
|
});
|
|
884
896
|
|
|
@@ -922,7 +934,7 @@ The default server can be overridden globally by passing a URL to the `serverURL
|
|
|
922
934
|
import { Glean } from "@gleanwork/api-client";
|
|
923
935
|
|
|
924
936
|
const glean = new Glean({
|
|
925
|
-
serverURL: "https://
|
|
937
|
+
serverURL: "https://instance-name-be.glean.com",
|
|
926
938
|
apiToken: process.env["GLEAN_API_TOKEN"] ?? "",
|
|
927
939
|
});
|
|
928
940
|
|