@gleanwork/api-client 0.13.1 → 0.13.3

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 (76) hide show
  1. package/README.md +2 -1
  2. package/dist/commonjs/__tests__/messages.test.js +1 -1
  3. package/dist/commonjs/__tests__/messages.test.js.map +1 -1
  4. package/dist/commonjs/__tests__/summarize.test.js +4 -3
  5. package/dist/commonjs/__tests__/summarize.test.js.map +1 -1
  6. package/dist/commonjs/lib/config.d.ts +3 -3
  7. package/dist/commonjs/lib/config.js +3 -3
  8. package/dist/commonjs/models/components/agentsinsightsv2response.d.ts +4 -0
  9. package/dist/commonjs/models/components/agentsinsightsv2response.d.ts.map +1 -1
  10. package/dist/commonjs/models/components/agentsinsightsv2response.js +4 -0
  11. package/dist/commonjs/models/components/agentsinsightsv2response.js.map +1 -1
  12. package/dist/commonjs/models/components/chatmessagefragment.d.ts +1 -1
  13. package/dist/commonjs/models/components/debugdatasourcestatusresponse.d.ts +3 -1
  14. package/dist/commonjs/models/components/debugdatasourcestatusresponse.d.ts.map +1 -1
  15. package/dist/commonjs/models/components/debugdatasourcestatusresponse.js.map +1 -1
  16. package/dist/commonjs/models/components/peragentinsight.d.ts +10 -0
  17. package/dist/commonjs/models/components/peragentinsight.d.ts.map +1 -1
  18. package/dist/commonjs/models/components/peragentinsight.js +4 -0
  19. package/dist/commonjs/models/components/peragentinsight.js.map +1 -1
  20. package/dist/esm/__tests__/messages.test.js +1 -1
  21. package/dist/esm/__tests__/messages.test.js.map +1 -1
  22. package/dist/esm/__tests__/summarize.test.js +4 -3
  23. package/dist/esm/__tests__/summarize.test.js.map +1 -1
  24. package/dist/esm/lib/config.d.ts +3 -3
  25. package/dist/esm/lib/config.js +3 -3
  26. package/dist/esm/models/components/agentsinsightsv2response.d.ts +4 -0
  27. package/dist/esm/models/components/agentsinsightsv2response.d.ts.map +1 -1
  28. package/dist/esm/models/components/agentsinsightsv2response.js +4 -0
  29. package/dist/esm/models/components/agentsinsightsv2response.js.map +1 -1
  30. package/dist/esm/models/components/chatmessagefragment.d.ts +1 -1
  31. package/dist/esm/models/components/debugdatasourcestatusresponse.d.ts +3 -1
  32. package/dist/esm/models/components/debugdatasourcestatusresponse.d.ts.map +1 -1
  33. package/dist/esm/models/components/debugdatasourcestatusresponse.js.map +1 -1
  34. package/dist/esm/models/components/peragentinsight.d.ts +10 -0
  35. package/dist/esm/models/components/peragentinsight.d.ts.map +1 -1
  36. package/dist/esm/models/components/peragentinsight.js +4 -0
  37. package/dist/esm/models/components/peragentinsight.js.map +1 -1
  38. package/examples/package-lock.json +1 -1
  39. package/jsr.json +1 -1
  40. package/package.json +1 -1
  41. package/src/__tests__/messages.test.ts +1 -1
  42. package/src/__tests__/summarize.test.ts +4 -3
  43. package/src/lib/config.ts +3 -3
  44. package/src/models/components/agentsinsightsv2response.ts +8 -0
  45. package/src/models/components/chatmessagefragment.ts +1 -1
  46. package/src/models/components/debugdatasourcestatusresponse.ts +3 -1
  47. package/src/models/components/peragentinsight.ts +14 -0
  48. package/.devcontainer/README.md +0 -35
  49. package/docs/sdks/activity/README.md +0 -242
  50. package/docs/sdks/agents/README.md +0 -498
  51. package/docs/sdks/announcements/README.md +0 -137560
  52. package/docs/sdks/answers/README.md +0 -4966
  53. package/docs/sdks/chat/README.md +0 -967
  54. package/docs/sdks/clientauthentication/README.md +0 -98
  55. package/docs/sdks/clientdocuments/README.md +0 -457
  56. package/docs/sdks/clientshortcuts/README.md +0 -9340
  57. package/docs/sdks/collections/README.md +0 -4148
  58. package/docs/sdks/datasource/README.md +0 -98
  59. package/docs/sdks/datasources/README.md +0 -211
  60. package/docs/sdks/entities/README.md +0 -225
  61. package/docs/sdks/indexingauthentication/README.md +0 -93
  62. package/docs/sdks/indexingdocuments/README.md +0 -983
  63. package/docs/sdks/indexingshortcuts/README.md +0 -251
  64. package/docs/sdks/insights/README.md +0 -94
  65. package/docs/sdks/messages/README.md +0 -102
  66. package/docs/sdks/people/README.md +0 -1052
  67. package/docs/sdks/permissions/README.md +0 -1198
  68. package/docs/sdks/pins/README.md +0 -506
  69. package/docs/sdks/policies/README.md +0 -478
  70. package/docs/sdks/reports/README.md +0 -290
  71. package/docs/sdks/search/README.md +0 -986
  72. package/docs/sdks/tools/README.md +0 -208
  73. package/docs/sdks/verification/README.md +0 -276
  74. package/docs/sdks/visibilityoverrides/README.md +0 -192
  75. package/examples/README.md +0 -31
  76. package/src/__tests__/mockserver/README.md +0 -52
@@ -1,986 +0,0 @@
1
- # Search
2
- (*client.search*)
3
-
4
- ## Overview
5
-
6
- ### Available Operations
7
-
8
- * [queryAsAdmin](#queryasadmin) - Search the index (admin)
9
- * [autocomplete](#autocomplete) - Autocomplete
10
- * [retrieveFeed](#retrievefeed) - Feed of documents and events
11
- * [recommendations](#recommendations) - Recommend documents
12
- * [query](#query) - Search
13
-
14
- ## queryAsAdmin
15
-
16
- Retrieves results for search query without respect for permissions. This is available only to privileged users.
17
-
18
- ### Example Usage
19
-
20
- <!-- UsageSnippet language="typescript" operationID="adminsearch" method="post" path="/rest/api/v1/adminsearch" -->
21
- ```typescript
22
- import { Glean } from "@gleanwork/api-client";
23
-
24
- const glean = new Glean({
25
- apiToken: process.env["GLEAN_API_TOKEN"] ?? "",
26
- });
27
-
28
- async function run() {
29
- const result = await glean.client.search.queryAsAdmin({
30
- trackingToken: "trackingToken",
31
- pageSize: 10,
32
- query: "vacation policy",
33
- requestOptions: {
34
- facetFilters: [
35
- {
36
- fieldName: "type",
37
- values: [
38
- {
39
- value: "article",
40
- relationType: "EQUALS",
41
- },
42
- {
43
- value: "document",
44
- relationType: "EQUALS",
45
- },
46
- ],
47
- },
48
- {
49
- fieldName: "department",
50
- values: [
51
- {
52
- value: "engineering",
53
- relationType: "EQUALS",
54
- },
55
- ],
56
- },
57
- ],
58
- facetBucketSize: 421489,
59
- },
60
- });
61
-
62
- console.log(result);
63
- }
64
-
65
- run();
66
- ```
67
-
68
- ### Standalone function
69
-
70
- The standalone function version of this method:
71
-
72
- ```typescript
73
- import { GleanCore } from "@gleanwork/api-client/core.js";
74
- import { clientSearchQueryAsAdmin } from "@gleanwork/api-client/funcs/clientSearchQueryAsAdmin.js";
75
-
76
- // Use `GleanCore` for best tree-shaking performance.
77
- // You can create one instance of it to use across an application.
78
- const glean = new GleanCore({
79
- apiToken: process.env["GLEAN_API_TOKEN"] ?? "",
80
- });
81
-
82
- async function run() {
83
- const res = await clientSearchQueryAsAdmin(glean, {
84
- trackingToken: "trackingToken",
85
- pageSize: 10,
86
- query: "vacation policy",
87
- requestOptions: {
88
- facetFilters: [
89
- {
90
- fieldName: "type",
91
- values: [
92
- {
93
- value: "article",
94
- relationType: "EQUALS",
95
- },
96
- {
97
- value: "document",
98
- relationType: "EQUALS",
99
- },
100
- ],
101
- },
102
- {
103
- fieldName: "department",
104
- values: [
105
- {
106
- value: "engineering",
107
- relationType: "EQUALS",
108
- },
109
- ],
110
- },
111
- ],
112
- facetBucketSize: 421489,
113
- },
114
- });
115
- if (res.ok) {
116
- const { value: result } = res;
117
- console.log(result);
118
- } else {
119
- console.log("clientSearchQueryAsAdmin failed:", res.error);
120
- }
121
- }
122
-
123
- run();
124
- ```
125
-
126
- ### React hooks and utilities
127
-
128
- This method can be used in React components through the following hooks and
129
- associated utilities.
130
-
131
- > Check out [this guide][hook-guide] for information about each of the utilities
132
- > below and how to get started using React hooks.
133
-
134
- [hook-guide]: ../../../REACT_QUERY.md
135
-
136
- ```tsx
137
- import {
138
- // Mutation hook for triggering the API call.
139
- useClientSearchQueryAsAdminMutation
140
- } from "@gleanwork/api-client/react-query/clientSearchQueryAsAdmin.js";
141
- ```
142
-
143
- ### Parameters
144
-
145
- | Parameter | Type | Required | Description |
146
- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
147
- | `request` | [components.SearchRequest](../../models/components/searchrequest.md) | :heavy_check_mark: | The request object to use for the request. |
148
- | `options` | RequestOptions | :heavy_minus_sign: | Used to set various options for making HTTP requests. |
149
- | `options.fetchOptions` | [RequestInit](https://developer.mozilla.org/en-US/docs/Web/API/Request/Request#options) | :heavy_minus_sign: | Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All `Request` options, except `method` and `body`, are allowed. |
150
- | `options.retries` | [RetryConfig](../../lib/utils/retryconfig.md) | :heavy_minus_sign: | Enables retrying HTTP requests under certain failure conditions. |
151
-
152
- ### Response
153
-
154
- **Promise\<[components.SearchResponse](../../models/components/searchresponse.md)\>**
155
-
156
- ### Errors
157
-
158
- | Error Type | Status Code | Content Type |
159
- | --------------------- | --------------------- | --------------------- |
160
- | errors.GleanDataError | 403, 422 | application/json |
161
- | errors.GleanError | 4XX, 5XX | \*/\* |
162
-
163
- ## autocomplete
164
-
165
- Retrieve query suggestions, operators and documents for the given partially typed query.
166
-
167
- ### Example Usage
168
-
169
- <!-- UsageSnippet language="typescript" operationID="autocomplete" method="post" path="/rest/api/v1/autocomplete" -->
170
- ```typescript
171
- import { Glean } from "@gleanwork/api-client";
172
-
173
- const glean = new Glean({
174
- apiToken: process.env["GLEAN_API_TOKEN"] ?? "",
175
- });
176
-
177
- async function run() {
178
- const result = await glean.client.search.autocomplete({
179
- trackingToken: "trackingToken",
180
- query: "what is a que",
181
- datasource: "GDRIVE",
182
- resultSize: 10,
183
- });
184
-
185
- console.log(result);
186
- }
187
-
188
- run();
189
- ```
190
-
191
- ### Standalone function
192
-
193
- The standalone function version of this method:
194
-
195
- ```typescript
196
- import { GleanCore } from "@gleanwork/api-client/core.js";
197
- import { clientSearchAutocomplete } from "@gleanwork/api-client/funcs/clientSearchAutocomplete.js";
198
-
199
- // Use `GleanCore` for best tree-shaking performance.
200
- // You can create one instance of it to use across an application.
201
- const glean = new GleanCore({
202
- apiToken: process.env["GLEAN_API_TOKEN"] ?? "",
203
- });
204
-
205
- async function run() {
206
- const res = await clientSearchAutocomplete(glean, {
207
- trackingToken: "trackingToken",
208
- query: "what is a que",
209
- datasource: "GDRIVE",
210
- resultSize: 10,
211
- });
212
- if (res.ok) {
213
- const { value: result } = res;
214
- console.log(result);
215
- } else {
216
- console.log("clientSearchAutocomplete failed:", res.error);
217
- }
218
- }
219
-
220
- run();
221
- ```
222
-
223
- ### React hooks and utilities
224
-
225
- This method can be used in React components through the following hooks and
226
- associated utilities.
227
-
228
- > Check out [this guide][hook-guide] for information about each of the utilities
229
- > below and how to get started using React hooks.
230
-
231
- [hook-guide]: ../../../REACT_QUERY.md
232
-
233
- ```tsx
234
- import {
235
- // Mutation hook for triggering the API call.
236
- useClientSearchAutocompleteMutation
237
- } from "@gleanwork/api-client/react-query/clientSearchAutocomplete.js";
238
- ```
239
-
240
- ### Parameters
241
-
242
- | Parameter | Type | Required | Description |
243
- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
244
- | `request` | [components.AutocompleteRequest](../../models/components/autocompleterequest.md) | :heavy_check_mark: | The request object to use for the request. |
245
- | `options` | RequestOptions | :heavy_minus_sign: | Used to set various options for making HTTP requests. |
246
- | `options.fetchOptions` | [RequestInit](https://developer.mozilla.org/en-US/docs/Web/API/Request/Request#options) | :heavy_minus_sign: | Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All `Request` options, except `method` and `body`, are allowed. |
247
- | `options.retries` | [RetryConfig](../../lib/utils/retryconfig.md) | :heavy_minus_sign: | Enables retrying HTTP requests under certain failure conditions. |
248
-
249
- ### Response
250
-
251
- **Promise\<[components.AutocompleteResponse](../../models/components/autocompleteresponse.md)\>**
252
-
253
- ### Errors
254
-
255
- | Error Type | Status Code | Content Type |
256
- | ----------------- | ----------------- | ----------------- |
257
- | errors.GleanError | 4XX, 5XX | \*/\* |
258
-
259
- ## retrieveFeed
260
-
261
- The personalized feed/home includes different types of contents including suggestions, recents, calendar events and many more.
262
-
263
- ### Example Usage
264
-
265
- <!-- UsageSnippet language="typescript" operationID="feed" method="post" path="/rest/api/v1/feed" -->
266
- ```typescript
267
- import { Glean } from "@gleanwork/api-client";
268
-
269
- const glean = new Glean({
270
- apiToken: process.env["GLEAN_API_TOKEN"] ?? "",
271
- });
272
-
273
- async function run() {
274
- const result = await glean.client.search.retrieveFeed({
275
- timeoutMillis: 5000,
276
- });
277
-
278
- console.log(result);
279
- }
280
-
281
- run();
282
- ```
283
-
284
- ### Standalone function
285
-
286
- The standalone function version of this method:
287
-
288
- ```typescript
289
- import { GleanCore } from "@gleanwork/api-client/core.js";
290
- import { clientSearchRetrieveFeed } from "@gleanwork/api-client/funcs/clientSearchRetrieveFeed.js";
291
-
292
- // Use `GleanCore` for best tree-shaking performance.
293
- // You can create one instance of it to use across an application.
294
- const glean = new GleanCore({
295
- apiToken: process.env["GLEAN_API_TOKEN"] ?? "",
296
- });
297
-
298
- async function run() {
299
- const res = await clientSearchRetrieveFeed(glean, {
300
- timeoutMillis: 5000,
301
- });
302
- if (res.ok) {
303
- const { value: result } = res;
304
- console.log(result);
305
- } else {
306
- console.log("clientSearchRetrieveFeed failed:", res.error);
307
- }
308
- }
309
-
310
- run();
311
- ```
312
-
313
- ### React hooks and utilities
314
-
315
- This method can be used in React components through the following hooks and
316
- associated utilities.
317
-
318
- > Check out [this guide][hook-guide] for information about each of the utilities
319
- > below and how to get started using React hooks.
320
-
321
- [hook-guide]: ../../../REACT_QUERY.md
322
-
323
- ```tsx
324
- import {
325
- // Mutation hook for triggering the API call.
326
- useClientSearchRetrieveFeedMutation
327
- } from "@gleanwork/api-client/react-query/clientSearchRetrieveFeed.js";
328
- ```
329
-
330
- ### Parameters
331
-
332
- | Parameter | Type | Required | Description |
333
- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
334
- | `request` | [components.FeedRequest](../../models/components/feedrequest.md) | :heavy_check_mark: | The request object to use for the request. |
335
- | `options` | RequestOptions | :heavy_minus_sign: | Used to set various options for making HTTP requests. |
336
- | `options.fetchOptions` | [RequestInit](https://developer.mozilla.org/en-US/docs/Web/API/Request/Request#options) | :heavy_minus_sign: | Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All `Request` options, except `method` and `body`, are allowed. |
337
- | `options.retries` | [RetryConfig](../../lib/utils/retryconfig.md) | :heavy_minus_sign: | Enables retrying HTTP requests under certain failure conditions. |
338
-
339
- ### Response
340
-
341
- **Promise\<[components.FeedResponse](../../models/components/feedresponse.md)\>**
342
-
343
- ### Errors
344
-
345
- | Error Type | Status Code | Content Type |
346
- | ----------------- | ----------------- | ----------------- |
347
- | errors.GleanError | 4XX, 5XX | \*/\* |
348
-
349
- ## recommendations
350
-
351
- Retrieve recommended documents for the given URL or Glean Document ID.
352
-
353
- ### Example Usage
354
-
355
- <!-- UsageSnippet language="typescript" operationID="recommendations" method="post" path="/rest/api/v1/recommendations" -->
356
- ```typescript
357
- import { Glean } from "@gleanwork/api-client";
358
-
359
- const glean = new Glean({
360
- apiToken: process.env["GLEAN_API_TOKEN"] ?? "",
361
- });
362
-
363
- async function run() {
364
- const result = await glean.client.search.recommendations({
365
- sourceDocument: {
366
- containerDocument: {
367
- metadata: {
368
- datasource: "datasource",
369
- objectType: "Feature Request",
370
- container: "container",
371
- parentId: "JIRA_EN-1337",
372
- mimeType: "mimeType",
373
- documentId: "documentId",
374
- createTime: new Date("2000-01-23T04:56:07.000Z"),
375
- updateTime: new Date("2000-01-23T04:56:07.000Z"),
376
- author: {
377
- name: "name",
378
- obfuscatedId: "<id>",
379
- },
380
- components: [
381
- "Backend",
382
- "Networking",
383
- ],
384
- status: "[\"Done\"]",
385
- customData: {
386
- "someCustomField": {},
387
- },
388
- },
389
- },
390
- parentDocument: {
391
- metadata: {
392
- datasource: "datasource",
393
- objectType: "Feature Request",
394
- container: "container",
395
- parentId: "JIRA_EN-1337",
396
- mimeType: "mimeType",
397
- documentId: "documentId",
398
- createTime: new Date("2000-01-23T04:56:07.000Z"),
399
- updateTime: new Date("2000-01-23T04:56:07.000Z"),
400
- author: {
401
- name: "name",
402
- obfuscatedId: "<id>",
403
- },
404
- components: [
405
- "Backend",
406
- "Networking",
407
- ],
408
- status: "[\"Done\"]",
409
- customData: {
410
- "someCustomField": {},
411
- },
412
- },
413
- },
414
- metadata: {
415
- datasource: "datasource",
416
- objectType: "Feature Request",
417
- container: "container",
418
- parentId: "JIRA_EN-1337",
419
- mimeType: "mimeType",
420
- documentId: "documentId",
421
- createTime: new Date("2000-01-23T04:56:07.000Z"),
422
- updateTime: new Date("2000-01-23T04:56:07.000Z"),
423
- author: {
424
- name: "name",
425
- obfuscatedId: "abc123",
426
- },
427
- components: [
428
- "Backend",
429
- "Networking",
430
- ],
431
- status: "[\"Done\"]",
432
- customData: {
433
- "someCustomField": {},
434
- },
435
- },
436
- },
437
- pageSize: 100,
438
- maxSnippetSize: 400,
439
- requestOptions: {
440
- facetFilterSets: [
441
- {
442
- filters: [
443
- {
444
- fieldName: "type",
445
- values: [
446
- {
447
- value: "Spreadsheet",
448
- relationType: "EQUALS",
449
- },
450
- {
451
- value: "Presentation",
452
- relationType: "EQUALS",
453
- },
454
- ],
455
- },
456
- ],
457
- },
458
- {
459
- filters: [
460
- {
461
- fieldName: "type",
462
- values: [
463
- {
464
- value: "Spreadsheet",
465
- relationType: "EQUALS",
466
- },
467
- {
468
- value: "Presentation",
469
- relationType: "EQUALS",
470
- },
471
- ],
472
- },
473
- ],
474
- },
475
- {
476
- filters: [
477
- {
478
- fieldName: "type",
479
- values: [
480
- {
481
- value: "Spreadsheet",
482
- relationType: "EQUALS",
483
- },
484
- {
485
- value: "Presentation",
486
- relationType: "EQUALS",
487
- },
488
- ],
489
- },
490
- ],
491
- },
492
- ],
493
- context: {
494
- containerDocument: {
495
- metadata: {
496
- datasource: "datasource",
497
- objectType: "Feature Request",
498
- container: "container",
499
- parentId: "JIRA_EN-1337",
500
- mimeType: "mimeType",
501
- documentId: "documentId",
502
- createTime: new Date("2000-01-23T04:56:07.000Z"),
503
- updateTime: new Date("2000-01-23T04:56:07.000Z"),
504
- author: {
505
- name: "name",
506
- obfuscatedId: "<id>",
507
- },
508
- components: [
509
- "Backend",
510
- "Networking",
511
- ],
512
- status: "[\"Done\"]",
513
- customData: {
514
- "someCustomField": {},
515
- },
516
- },
517
- },
518
- parentDocument: {
519
- metadata: {
520
- datasource: "datasource",
521
- objectType: "Feature Request",
522
- container: "container",
523
- parentId: "JIRA_EN-1337",
524
- mimeType: "mimeType",
525
- documentId: "documentId",
526
- createTime: new Date("2000-01-23T04:56:07.000Z"),
527
- updateTime: new Date("2000-01-23T04:56:07.000Z"),
528
- author: {
529
- name: "name",
530
- obfuscatedId: "<id>",
531
- },
532
- components: [
533
- "Backend",
534
- "Networking",
535
- ],
536
- status: "[\"Done\"]",
537
- customData: {
538
- "someCustomField": {},
539
- },
540
- },
541
- },
542
- metadata: {
543
- datasource: "datasource",
544
- objectType: "Feature Request",
545
- container: "container",
546
- parentId: "JIRA_EN-1337",
547
- mimeType: "mimeType",
548
- documentId: "documentId",
549
- createTime: new Date("2000-01-23T04:56:07.000Z"),
550
- updateTime: new Date("2000-01-23T04:56:07.000Z"),
551
- author: {
552
- name: "name",
553
- obfuscatedId: "abc123",
554
- },
555
- components: [
556
- "Backend",
557
- "Networking",
558
- ],
559
- status: "[\"Done\"]",
560
- customData: {
561
- "someCustomField": {},
562
- },
563
- },
564
- },
565
- },
566
- });
567
-
568
- console.log(result);
569
- }
570
-
571
- run();
572
- ```
573
-
574
- ### Standalone function
575
-
576
- The standalone function version of this method:
577
-
578
- ```typescript
579
- import { GleanCore } from "@gleanwork/api-client/core.js";
580
- import { clientSearchRecommendations } from "@gleanwork/api-client/funcs/clientSearchRecommendations.js";
581
-
582
- // Use `GleanCore` for best tree-shaking performance.
583
- // You can create one instance of it to use across an application.
584
- const glean = new GleanCore({
585
- apiToken: process.env["GLEAN_API_TOKEN"] ?? "",
586
- });
587
-
588
- async function run() {
589
- const res = await clientSearchRecommendations(glean, {
590
- sourceDocument: {
591
- containerDocument: {
592
- metadata: {
593
- datasource: "datasource",
594
- objectType: "Feature Request",
595
- container: "container",
596
- parentId: "JIRA_EN-1337",
597
- mimeType: "mimeType",
598
- documentId: "documentId",
599
- createTime: new Date("2000-01-23T04:56:07.000Z"),
600
- updateTime: new Date("2000-01-23T04:56:07.000Z"),
601
- author: {
602
- name: "name",
603
- obfuscatedId: "<id>",
604
- },
605
- components: [
606
- "Backend",
607
- "Networking",
608
- ],
609
- status: "[\"Done\"]",
610
- customData: {
611
- "someCustomField": {},
612
- },
613
- },
614
- },
615
- parentDocument: {
616
- metadata: {
617
- datasource: "datasource",
618
- objectType: "Feature Request",
619
- container: "container",
620
- parentId: "JIRA_EN-1337",
621
- mimeType: "mimeType",
622
- documentId: "documentId",
623
- createTime: new Date("2000-01-23T04:56:07.000Z"),
624
- updateTime: new Date("2000-01-23T04:56:07.000Z"),
625
- author: {
626
- name: "name",
627
- obfuscatedId: "<id>",
628
- },
629
- components: [
630
- "Backend",
631
- "Networking",
632
- ],
633
- status: "[\"Done\"]",
634
- customData: {
635
- "someCustomField": {},
636
- },
637
- },
638
- },
639
- metadata: {
640
- datasource: "datasource",
641
- objectType: "Feature Request",
642
- container: "container",
643
- parentId: "JIRA_EN-1337",
644
- mimeType: "mimeType",
645
- documentId: "documentId",
646
- createTime: new Date("2000-01-23T04:56:07.000Z"),
647
- updateTime: new Date("2000-01-23T04:56:07.000Z"),
648
- author: {
649
- name: "name",
650
- obfuscatedId: "abc123",
651
- },
652
- components: [
653
- "Backend",
654
- "Networking",
655
- ],
656
- status: "[\"Done\"]",
657
- customData: {
658
- "someCustomField": {},
659
- },
660
- },
661
- },
662
- pageSize: 100,
663
- maxSnippetSize: 400,
664
- requestOptions: {
665
- facetFilterSets: [
666
- {
667
- filters: [
668
- {
669
- fieldName: "type",
670
- values: [
671
- {
672
- value: "Spreadsheet",
673
- relationType: "EQUALS",
674
- },
675
- {
676
- value: "Presentation",
677
- relationType: "EQUALS",
678
- },
679
- ],
680
- },
681
- ],
682
- },
683
- {
684
- filters: [
685
- {
686
- fieldName: "type",
687
- values: [
688
- {
689
- value: "Spreadsheet",
690
- relationType: "EQUALS",
691
- },
692
- {
693
- value: "Presentation",
694
- relationType: "EQUALS",
695
- },
696
- ],
697
- },
698
- ],
699
- },
700
- {
701
- filters: [
702
- {
703
- fieldName: "type",
704
- values: [
705
- {
706
- value: "Spreadsheet",
707
- relationType: "EQUALS",
708
- },
709
- {
710
- value: "Presentation",
711
- relationType: "EQUALS",
712
- },
713
- ],
714
- },
715
- ],
716
- },
717
- ],
718
- context: {
719
- containerDocument: {
720
- metadata: {
721
- datasource: "datasource",
722
- objectType: "Feature Request",
723
- container: "container",
724
- parentId: "JIRA_EN-1337",
725
- mimeType: "mimeType",
726
- documentId: "documentId",
727
- createTime: new Date("2000-01-23T04:56:07.000Z"),
728
- updateTime: new Date("2000-01-23T04:56:07.000Z"),
729
- author: {
730
- name: "name",
731
- obfuscatedId: "<id>",
732
- },
733
- components: [
734
- "Backend",
735
- "Networking",
736
- ],
737
- status: "[\"Done\"]",
738
- customData: {
739
- "someCustomField": {},
740
- },
741
- },
742
- },
743
- parentDocument: {
744
- metadata: {
745
- datasource: "datasource",
746
- objectType: "Feature Request",
747
- container: "container",
748
- parentId: "JIRA_EN-1337",
749
- mimeType: "mimeType",
750
- documentId: "documentId",
751
- createTime: new Date("2000-01-23T04:56:07.000Z"),
752
- updateTime: new Date("2000-01-23T04:56:07.000Z"),
753
- author: {
754
- name: "name",
755
- obfuscatedId: "<id>",
756
- },
757
- components: [
758
- "Backend",
759
- "Networking",
760
- ],
761
- status: "[\"Done\"]",
762
- customData: {
763
- "someCustomField": {},
764
- },
765
- },
766
- },
767
- metadata: {
768
- datasource: "datasource",
769
- objectType: "Feature Request",
770
- container: "container",
771
- parentId: "JIRA_EN-1337",
772
- mimeType: "mimeType",
773
- documentId: "documentId",
774
- createTime: new Date("2000-01-23T04:56:07.000Z"),
775
- updateTime: new Date("2000-01-23T04:56:07.000Z"),
776
- author: {
777
- name: "name",
778
- obfuscatedId: "abc123",
779
- },
780
- components: [
781
- "Backend",
782
- "Networking",
783
- ],
784
- status: "[\"Done\"]",
785
- customData: {
786
- "someCustomField": {},
787
- },
788
- },
789
- },
790
- },
791
- });
792
- if (res.ok) {
793
- const { value: result } = res;
794
- console.log(result);
795
- } else {
796
- console.log("clientSearchRecommendations failed:", res.error);
797
- }
798
- }
799
-
800
- run();
801
- ```
802
-
803
- ### React hooks and utilities
804
-
805
- This method can be used in React components through the following hooks and
806
- associated utilities.
807
-
808
- > Check out [this guide][hook-guide] for information about each of the utilities
809
- > below and how to get started using React hooks.
810
-
811
- [hook-guide]: ../../../REACT_QUERY.md
812
-
813
- ```tsx
814
- import {
815
- // Mutation hook for triggering the API call.
816
- useClientSearchRecommendationsMutation
817
- } from "@gleanwork/api-client/react-query/clientSearchRecommendations.js";
818
- ```
819
-
820
- ### Parameters
821
-
822
- | Parameter | Type | Required | Description |
823
- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
824
- | `request` | [components.RecommendationsRequest](../../models/components/recommendationsrequest.md) | :heavy_check_mark: | The request object to use for the request. |
825
- | `options` | RequestOptions | :heavy_minus_sign: | Used to set various options for making HTTP requests. |
826
- | `options.fetchOptions` | [RequestInit](https://developer.mozilla.org/en-US/docs/Web/API/Request/Request#options) | :heavy_minus_sign: | Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All `Request` options, except `method` and `body`, are allowed. |
827
- | `options.retries` | [RetryConfig](../../lib/utils/retryconfig.md) | :heavy_minus_sign: | Enables retrying HTTP requests under certain failure conditions. |
828
-
829
- ### Response
830
-
831
- **Promise\<[components.ResultsResponse](../../models/components/resultsresponse.md)\>**
832
-
833
- ### Errors
834
-
835
- | Error Type | Status Code | Content Type |
836
- | ----------------- | ----------------- | ----------------- |
837
- | errors.GleanError | 4XX, 5XX | \*/\* |
838
-
839
- ## query
840
-
841
- Retrieve results from the index for the given query and filters.
842
-
843
- ### Example Usage
844
-
845
- <!-- UsageSnippet language="typescript" operationID="search" method="post" path="/rest/api/v1/search" -->
846
- ```typescript
847
- import { Glean } from "@gleanwork/api-client";
848
-
849
- const glean = new Glean({
850
- apiToken: process.env["GLEAN_API_TOKEN"] ?? "",
851
- });
852
-
853
- async function run() {
854
- const result = await glean.client.search.query({
855
- trackingToken: "trackingToken",
856
- pageSize: 10,
857
- query: "vacation policy",
858
- requestOptions: {
859
- facetFilters: [
860
- {
861
- fieldName: "type",
862
- values: [
863
- {
864
- value: "article",
865
- relationType: "EQUALS",
866
- },
867
- {
868
- value: "document",
869
- relationType: "EQUALS",
870
- },
871
- ],
872
- },
873
- {
874
- fieldName: "department",
875
- values: [
876
- {
877
- value: "engineering",
878
- relationType: "EQUALS",
879
- },
880
- ],
881
- },
882
- ],
883
- facetBucketSize: 400611,
884
- },
885
- });
886
-
887
- console.log(result);
888
- }
889
-
890
- run();
891
- ```
892
-
893
- ### Standalone function
894
-
895
- The standalone function version of this method:
896
-
897
- ```typescript
898
- import { GleanCore } from "@gleanwork/api-client/core.js";
899
- import { clientSearchQuery } from "@gleanwork/api-client/funcs/clientSearchQuery.js";
900
-
901
- // Use `GleanCore` for best tree-shaking performance.
902
- // You can create one instance of it to use across an application.
903
- const glean = new GleanCore({
904
- apiToken: process.env["GLEAN_API_TOKEN"] ?? "",
905
- });
906
-
907
- async function run() {
908
- const res = await clientSearchQuery(glean, {
909
- trackingToken: "trackingToken",
910
- pageSize: 10,
911
- query: "vacation policy",
912
- requestOptions: {
913
- facetFilters: [
914
- {
915
- fieldName: "type",
916
- values: [
917
- {
918
- value: "article",
919
- relationType: "EQUALS",
920
- },
921
- {
922
- value: "document",
923
- relationType: "EQUALS",
924
- },
925
- ],
926
- },
927
- {
928
- fieldName: "department",
929
- values: [
930
- {
931
- value: "engineering",
932
- relationType: "EQUALS",
933
- },
934
- ],
935
- },
936
- ],
937
- facetBucketSize: 400611,
938
- },
939
- });
940
- if (res.ok) {
941
- const { value: result } = res;
942
- console.log(result);
943
- } else {
944
- console.log("clientSearchQuery failed:", res.error);
945
- }
946
- }
947
-
948
- run();
949
- ```
950
-
951
- ### React hooks and utilities
952
-
953
- This method can be used in React components through the following hooks and
954
- associated utilities.
955
-
956
- > Check out [this guide][hook-guide] for information about each of the utilities
957
- > below and how to get started using React hooks.
958
-
959
- [hook-guide]: ../../../REACT_QUERY.md
960
-
961
- ```tsx
962
- import {
963
- // Mutation hook for triggering the API call.
964
- useClientSearchQueryMutation
965
- } from "@gleanwork/api-client/react-query/clientSearchQuery.js";
966
- ```
967
-
968
- ### Parameters
969
-
970
- | Parameter | Type | Required | Description |
971
- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
972
- | `request` | [components.SearchRequest](../../models/components/searchrequest.md) | :heavy_check_mark: | The request object to use for the request. |
973
- | `options` | RequestOptions | :heavy_minus_sign: | Used to set various options for making HTTP requests. |
974
- | `options.fetchOptions` | [RequestInit](https://developer.mozilla.org/en-US/docs/Web/API/Request/Request#options) | :heavy_minus_sign: | Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All `Request` options, except `method` and `body`, are allowed. |
975
- | `options.retries` | [RetryConfig](../../lib/utils/retryconfig.md) | :heavy_minus_sign: | Enables retrying HTTP requests under certain failure conditions. |
976
-
977
- ### Response
978
-
979
- **Promise\<[components.SearchResponse](../../models/components/searchresponse.md)\>**
980
-
981
- ### Errors
982
-
983
- | Error Type | Status Code | Content Type |
984
- | --------------------- | --------------------- | --------------------- |
985
- | errors.GleanDataError | 403, 422 | application/json |
986
- | errors.GleanError | 4XX, 5XX | \*/\* |