@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.
Files changed (53) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +22 -10
  3. package/dist/commonjs/__tests__/adminsearch.test.js +1783 -12
  4. package/dist/commonjs/__tests__/adminsearch.test.js.map +1 -1
  5. package/dist/commonjs/__tests__/announcements.test.js +3922 -2
  6. package/dist/commonjs/__tests__/announcements.test.js.map +1 -1
  7. package/dist/commonjs/__tests__/answers.test.js +1315 -30
  8. package/dist/commonjs/__tests__/answers.test.js.map +1 -1
  9. package/dist/commonjs/__tests__/chat.test.js +19803 -1532
  10. package/dist/commonjs/__tests__/chat.test.js.map +1 -1
  11. package/dist/commonjs/__tests__/clientsearch.test.js +3850 -142
  12. package/dist/commonjs/__tests__/clientsearch.test.js.map +1 -1
  13. package/dist/commonjs/__tests__/clientshortcuts.test.js +1051 -8
  14. package/dist/commonjs/__tests__/clientshortcuts.test.js.map +1 -1
  15. package/dist/commonjs/__tests__/collections.test.js +1053 -8
  16. package/dist/commonjs/__tests__/collections.test.js.map +1 -1
  17. package/dist/commonjs/lib/config.d.ts +6 -6
  18. package/dist/commonjs/lib/config.d.ts.map +1 -1
  19. package/dist/commonjs/lib/config.js +5 -5
  20. package/dist/commonjs/lib/config.js.map +1 -1
  21. package/dist/esm/__tests__/adminsearch.test.js +1783 -12
  22. package/dist/esm/__tests__/adminsearch.test.js.map +1 -1
  23. package/dist/esm/__tests__/announcements.test.js +3922 -2
  24. package/dist/esm/__tests__/announcements.test.js.map +1 -1
  25. package/dist/esm/__tests__/answers.test.js +1315 -30
  26. package/dist/esm/__tests__/answers.test.js.map +1 -1
  27. package/dist/esm/__tests__/chat.test.js +19803 -1532
  28. package/dist/esm/__tests__/chat.test.js.map +1 -1
  29. package/dist/esm/__tests__/clientsearch.test.js +3850 -142
  30. package/dist/esm/__tests__/clientsearch.test.js.map +1 -1
  31. package/dist/esm/__tests__/clientshortcuts.test.js +1051 -8
  32. package/dist/esm/__tests__/clientshortcuts.test.js.map +1 -1
  33. package/dist/esm/__tests__/collections.test.js +1053 -8
  34. package/dist/esm/__tests__/collections.test.js.map +1 -1
  35. package/dist/esm/lib/config.d.ts +6 -6
  36. package/dist/esm/lib/config.d.ts.map +1 -1
  37. package/dist/esm/lib/config.js +5 -5
  38. package/dist/esm/lib/config.js.map +1 -1
  39. package/docs/sdks/announcements/README.md +7846 -4
  40. package/docs/sdks/answers/README.md +2910 -340
  41. package/docs/sdks/clientshortcuts/README.md +2120 -34
  42. package/docs/sdks/collections/README.md +2124 -34
  43. package/docs/sdks/search/README.md +11601 -643
  44. package/jsr.json +1 -1
  45. package/package.json +2 -1
  46. package/src/__tests__/adminsearch.test.ts +1790 -12
  47. package/src/__tests__/announcements.test.ts +3936 -2
  48. package/src/__tests__/answers.test.ts +1324 -30
  49. package/src/__tests__/chat.test.ts +20119 -1599
  50. package/src/__tests__/clientsearch.test.ts +3867 -146
  51. package/src/__tests__/clientshortcuts.test.ts +1061 -8
  52. package/src/__tests__/collections.test.ts +1062 -8
  53. 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({ apiToken: "client-token" });
17
- await glean.client.search.query({ query: "search term" });
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({ apiToken: "indexing-token" });
21
- await glean.indexing.documents.index({ /* document data */ });
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://{domain}-be.glean.com` contains variables and is set to `https://domain-be.glean.com` by default. To override default values, the following parameters are available when initializing the SDK client instance:
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 | Parameter | Default | Description |
872
- | -------- | ---------------- | ---------- | ------------------------------------------------------------------------ |
873
- | `domain` | `domain: string` | `"domain"` | Email domain (without extension) that determines the deployment backend. |
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
- domain: "scared-pearl.biz",
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://domain-be.glean.com",
937
+ serverURL: "https://instance-name-be.glean.com",
926
938
  apiToken: process.env["GLEAN_API_TOKEN"] ?? "",
927
939
  });
928
940