### Start Mock Server with Go Source: https://github.com/gleanwork/api-client-typescript/blob/main/src/__tests__/mockserver/README.md Use this command to start the mock server directly if you have the Go programming language toolchain installed. ```shell go run . ``` -------------------------------- ### Running the Example Source: https://github.com/gleanwork/api-client-typescript/blob/main/docs/sdks/collections/README.md A simple function to run the API client example and log the output. ```typescript async function run() { const result = await client.search({ query: "George Clooney", pageSize: 10, fields: [ "title", "url", "nativeAppUrl", "snippets", "metadata", "role", ], filters: [ { fieldName: "type", values: [ { value: "Person", relationType: "EQUALS", }, ], }, ], shortcuts: [ { inputAlias: "", }, { inputAlias: "", }, ], customData: { "someCustomField": {}, }, }); console.log(result); } run(); ``` -------------------------------- ### Create Collection Example Source: https://github.com/gleanwork/api-client-typescript/blob/main/docs/sdks/collections/README.md This example demonstrates how to create a new collection using the API client. It includes setting various properties for the collection, such as roles, filters, and custom fields. Ensure you have the necessary authentication and client setup. ```typescript import { RFCDate } from "@gleanwork/api-client/dist/rfc_date.js"; async function run() { const res = await client.clientCollectionsCreate({ collection: { name: "My Collection", description: "A collection of my favorite things.", roles: [ { person: { name: "George Clooney", obfuscatedId: "abc123", metadata: { type: "FULL_TIME", title: "Actor", department: "Movies", email: "george@example.com", location: "Hollywood, CA", phone: "6505551234", photoUrl: "https://example.com/george.jpg", startDate: new RFCDate("2000-01-23"), datasourceProfile: [ { datasource: "github", handle: "", }, { datasource: "github", handle: "", }, ], querySuggestions: { suggestions: [ { query: "app:github type:pull author:mortimer", label: "Mortimer's PRs", datasource: "github", }, ], }, inviteInfo: { invites: [ {}, {}, ], }, customFields: [ { label: "", values: [ {}, {}, {}, ], }, { label: "", values: [ {}, {}, {}, ], }, ], badges: [ { key: "deployment_name_new_hire", displayName: "New hire", iconConfig: { color: "#343CED", key: "person_icon", iconType: "GLYPH", name: "user", }, }, ], }, }, role: "VERIFIER", }, ], removedRoles: [ { person: { name: "George Clooney", obfuscatedId: "abc123", metadata: { type: "FULL_TIME", title: "Actor", department: "Movies", email: "george@example.com", location: "Hollywood, CA", phone: "6505551234", photoUrl: "https://example.com/george.jpg", startDate: new RFCDate("2000-01-23"), datasourceProfile: [ { datasource: "github", handle: "", }, { datasource: "github", handle: "", }, ], querySuggestions: { suggestions: [ { query: "app:github type:pull author:mortimer", label: "Mortimer's PRs", datasource: "github", }, ], }, inviteInfo: { invites: [ {}, {}, ], }, badges: [ { key: "deployment_name_new_hire", displayName: "New hire", iconConfig: { color: "#343CED", key: "person_icon", iconType: "GLYPH", name: "user", }, }, ], }, }, role: "VIEWER", }, ], audienceFilters: [ { fieldName: "type", values: [ { value: "Spreadsheet", relationType: "EQUALS", }, { value: "Presentation", relationType: "EQUALS", }, ], }, ], }, }); if (res.ok) { const { value: result } = res; console.log(result); } else { console.log("clientCollectionsCreate failed:", res.error); } } run(); ``` -------------------------------- ### Code Snippet Example Source: https://github.com/gleanwork/api-client-typescript/blob/main/docs/sdks/clientchat/README.md Example for specifying code repository name and file name. ```json code: { repoName: "scio", fileName: "README.md", } ``` -------------------------------- ### Customer Information Example Source: https://github.com/gleanwork/api-client-typescript/blob/main/docs/sdks/clientchat/README.md Example of customer object with ID, company details, POC, and notes. ```typescript customer: { id: "", company: { name: "", location: "New York City", industry: "Finances", about: "Financial, software, data, and media company headquartered in Midtown Manhattan, New York City", }, poc: [ { name: "George Clooney", obfuscatedId: "abc123", }, ], notes: "CIO is interested in trying out the product.", } ``` -------------------------------- ### Chat Get File Example Source: https://github.com/gleanwork/api-client-typescript/blob/main/README.md Example of how to download a chat file using the Glean API client. ```APIDOC ## GET /chat/files/{fileId} ### Description Downloads a chat file. ### Method GET ### Endpoint /chat/files/{fileId} ### Parameters #### Path Parameters - **fileId** (string) - Required - The ID of the file to download. ### Response #### Success Response (200) - **file** (binary) - The content of the chat file. ``` -------------------------------- ### DebugDatasourceStatusResponse Example Source: https://github.com/gleanwork/api-client-typescript/blob/main/docs/models/components/debugdatasourcestatusresponse.md This example demonstrates how to import and use the DebugDatasourceStatusResponse type in TypeScript. Ensure the @gleanwork/api-client is installed. ```typescript import { DebugDatasourceStatusResponse } from "@gleanwork/api-client/models/components"; let value: DebugDatasourceStatusResponse = { documents: { bulkUploadHistory: [ { uploadId: "upload-id-content-1707403081", startTime: "2021-08-06T17:58:01.000Z", endTime: "2021-08-06T18:58:01.000Z", status: "SUCCESSFUL", processingState: "UPLOAD COMPLETED", }, ], counts: { uploaded: [ { objectType: "Article", count: 15, }, ], indexed: [ { objectType: "Article", count: 15, }, ], }, processingHistory: [ { startTime: "2021-08-06T17:58:01.000Z", endTime: "2021-08-06T18:58:01.000Z", }, ], }, identity: { processingHistory: [ { startTime: "2021-08-06T17:58:01.000Z", endTime: "2021-08-06T18:58:01.000Z", }, ], users: { bulkUploadHistory: [ { uploadId: "upload-id-content-1707403081", startTime: "2021-08-06T17:58:01.000Z", endTime: "2021-08-06T18:58:01.000Z", status: "SUCCESSFUL", processingState: "UPLOAD COMPLETED", }, ], counts: { uploaded: 15, }, }, groups: { bulkUploadHistory: [ { uploadId: "upload-id-content-1707403081", startTime: "2021-08-06T17:58:01.000Z", endTime: "2021-08-06T18:58:01.000Z", status: "SUCCESSFUL", processingState: "UPLOAD COMPLETED", }, ], counts: { uploaded: 15, }, }, memberships: { bulkUploadHistory: [ { uploadId: "upload-id-content-1707403081", startTime: "2021-08-06T17:58:01.000Z", endTime: "2021-08-06T18:58:01.000Z", status: "SUCCESSFUL", processingState: "UPLOAD COMPLETED", }, ], counts: { uploaded: 15, }, }, }, datasourceVisibility: "ENABLED_FOR_ALL", }; ``` -------------------------------- ### Shortcut Configuration Example Source: https://github.com/gleanwork/api-client-typescript/blob/main/docs/sdks/announcements/README.md Shows how to configure shortcuts, which can include input aliases and creator/updater information with associated metadata. This is useful for defining quick access actions. ```typescript shortcuts: [ { inputAlias: "", createdBy: { name: "George Clooney", obfuscatedId: "abc123", metadata: { type: "FULL_TIME", title: "Actor", department: "Movies", email: "george@example.com", location: "Hollywood, CA", phone: "6505551234", photoUrl: "https://example.com/george.jpg", startDate: new RFCDate("2000-01-23"), datasourceProfile: [ { datasource: "github", handle: "", }, ], querySuggestions: { suggestions: [ { query: "app:github type:pull author:mortimer", label: "Mortimer's PRs", datasource: "github", }, ], }, inviteInfo: { invites: [ {}, {}, {}, ], }, badges: [ { key: "deployment_name_new_hire", displayName: "New hire", iconConfig: { color: "#343CED", key: "person_icon", iconType: "GLYPH", name: "user", }, }, ], }, }, updatedBy: { name: "George Clooney", obfuscatedId: "abc123", metadata: { type: "FULL_TIME", title: "Actor", department: "Movies", ``` -------------------------------- ### Person Metadata Example Source: https://github.com/gleanwork/api-client-typescript/blob/main/docs/sdks/announcements/README.md Example of person metadata including type, title, department, contact information, and start date. ```typescript { type: "FULL_TIME", title: "Actor", department: "Movies", email: "george@example.com", location: "Hollywood, CA", phone: "6505551234", photoUrl: "https://example.com/george.jpg", startDate: new RFCDate("2000-01-23"), datasourceProfile: [ { datasource: "github", handle: "", }, { datasource: "github", handle: "", }, ], querySuggestions: { suggestions: [ { query: "app:github type:pull author:mortimer", label: "Mortimer's PRs", datasource: "github", }, ], }, inviteInfo: { invites: [ {}, {}, {}, ], }, badges: [ { key: "deployment_name_new_hire", displayName: "New hire", iconConfig: { color: "#343CED", key: "person_icon", iconType: "GLYPH", name: "user", }, }, ], } ``` -------------------------------- ### Icon Configuration Example Source: https://github.com/gleanwork/api-client-typescript/blob/main/docs/models/components/agentsusagebydepartmentinsight.md Defines how to render an icon with color, key, type, and name. ```json { "color": "#343CED", "key": "person_icon", "iconType": "GLYPH", "name": "user" } ``` -------------------------------- ### Configure Query Suggestions Source: https://github.com/gleanwork/api-client-typescript/blob/main/docs/sdks/announcements/README.md Example of setting up query suggestions with a query, label, and datasource. ```typescript { query: "app:github type:pull author:mortimer", label: "Mortimer's PRs", datasource: "github", } ``` -------------------------------- ### Instantiate FeedRequest Source: https://github.com/gleanwork/api-client-typescript/blob/main/docs/models/operations/feedrequest.md Example of how to import and instantiate a FeedRequest object. Ensure the @gleanwork/api-client library is installed. ```typescript import { FeedRequest } from "@gleanwork/api-client/models/operations"; let value: FeedRequest = { feedRequest: { timeoutMillis: 5000, }, }; ``` -------------------------------- ### Example EditCollectionItemResponse Usage Source: https://github.com/gleanwork/api-client-typescript/blob/main/docs/models/components/editcollectionitemresponse.md Demonstrates how to create an instance of EditCollectionItemResponse in TypeScript. Ensure the @gleanwork/api-client is installed. ```typescript import { EditCollectionItemResponse } from "@gleanwork/api-client/models/components"; let value: EditCollectionItemResponse = { collection: { name: "", description: "impanel importance pale parody towards wildly elementary unbearably", audienceFilters: [ { fieldName: "type", values: [ { value: "Spreadsheet", relationType: "EQUALS", }, { value: "Presentation", relationType: "EQUALS", }, ], }, ], id: 390864, creator: { name: "George Clooney", obfuscatedId: "abc123", }, updatedBy: { name: "George Clooney", obfuscatedId: "abc123", }, children: [ { name: "", description: "viciously creator incidentally hole pecan", audienceFilters: [ { fieldName: "type", values: [ { value: "Spreadsheet", relationType: "EQUALS", }, { value: "Presentation", relationType: "EQUALS", }, ], }, ], id: 581341, creator: { name: "George Clooney", obfuscatedId: "abc123", }, updatedBy: { name: "George Clooney", obfuscatedId: "abc123", }, }, ], }, }; ``` -------------------------------- ### Build and Start Mock Server with Docker Source: https://github.com/gleanwork/api-client-typescript/blob/main/src/__tests__/mockserver/README.md Build the mock server image and run it using Docker. The server will be accessible on port 18080. ```shell docker build -t mockserver . docker run -i -p 18080:18080 -t --rm mockserver ``` -------------------------------- ### Shortcut Example Source: https://github.com/gleanwork/api-client-typescript/blob/main/docs/sdks/clientchat/README.md Example for defining a shortcut with input alias, creator, updater, and destination document details. ```json shortcut: { inputAlias: "", createdBy: { name: "George Clooney", obfuscatedId: "abc123", }, updatedBy: { name: "George Clooney", obfuscatedId: "abc123", }, destinationDocument: { metadata: { datasource: "datasource", objectType: "Feature Request", container: "container", parentId: "JIRA_EN-1337", mimeType: "mimeType", documentId: "documentId", createTime: new Date("2000-01-23T04:56:07.000Z"), updateTime: new Date("2000-01-23T04:56:07.000Z"), author: { name: "name", obfuscatedId: "", }, components: [ "Backend", "Networking", ], status: "[\"Done\"]", customData: { "someCustomField": {}, }, }, }, } ``` -------------------------------- ### AutocompleteResponse Model Usage Source: https://github.com/gleanwork/api-client-typescript/blob/main/docs/models/components/autocompleteresponse.md Example of how to import and instantiate the AutocompleteResponse model. Ensure the @gleanwork/api-client is installed. ```typescript import { AutocompleteResponse } from "@gleanwork/api-client/models/components"; let value: AutocompleteResponse = { trackingToken: "trackingToken", }; ``` -------------------------------- ### Build and Run TypeScript Example Source: https://github.com/gleanwork/api-client-typescript/blob/main/examples/README.md Build the project and execute an example TypeScript file using tsx. ```bash npm run build && npx tsx example.ts ``` -------------------------------- ### Instantiate AnswerLikes Model Source: https://github.com/gleanwork/api-client-typescript/blob/main/docs/models/components/answerlikes.md Example of how to create an instance of the AnswerLikes model. Ensure the @gleanwork/api-client is installed. ```typescript import { AnswerLikes } from "@gleanwork/api-client/models/components"; let value: AnswerLikes = { likedBy: [], likedByUser: true, numLikes: 82246, }; ``` -------------------------------- ### Server Selection Example Source: https://github.com/gleanwork/api-client-typescript/blob/main/README.md Demonstrates how to initialize the Glean client with custom server configurations, specifically overriding the default instance name. ```APIDOC ## Server Selection ### Server Variables 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: | Variable | Parameter | Default | Description | | ---------- | ------------------ | ----------------- | ------------------------------------------------------------------------------------------------------ | | `instance` | `instance: string` | `"instance-name"` | The instance name (typically the email domain without the TLD) that determines the deployment backend. | #### Example ```typescript import { Glean } from "@gleanwork/api-client"; const glean = new Glean({ serverIdx: 0, instance: "instance-name", apiToken: process.env["GLEAN_API_TOKEN"] ?? "", }); async function run() { await glean.client.activity.report({ events: [ { action: "HISTORICAL_VIEW", timestamp: new Date("2000-01-23T04:56:07.000Z"), url: "https://example.com/", }, { action: "SEARCH", params: { query: "query", }, timestamp: new Date("2000-01-23T04:56:07.000Z"), url: "https://example.com/search?q=query", }, { action: "VIEW", params: { duration: 20, referrer: "https://example.com/document", }, timestamp: new Date("2000-01-23T04:56:07.000Z"), url: "https://example.com/", }, ], }); } run(); ``` ``` -------------------------------- ### WorkflowResult Example Usage Source: https://github.com/gleanwork/api-client-typescript/blob/main/docs/models/components/workflowresult.md Demonstrates how to import and instantiate the WorkflowResult model in TypeScript. Ensure the @gleanwork/api-client library is installed. ```typescript import { WorkflowResult } from "@gleanwork/api-client/models/components"; let value: WorkflowResult = { workflow: { author: { name: "George Clooney", obfuscatedId: "abc123", }, lastDraftSavedBy: { name: "George Clooney", obfuscatedId: "abc123", }, lastUpdatedBy: { name: "George Clooney", obfuscatedId: "abc123", }, }, }; ``` -------------------------------- ### Example Usage of DeleteCollectionItemResponse Source: https://github.com/gleanwork/api-client-typescript/blob/main/docs/models/components/deletecollectionitemresponse.md This snippet demonstrates how to instantiate and use the DeleteCollectionItemResponse model. Ensure the @gleanwork/api-client library is installed. ```typescript import { DeleteCollectionItemResponse } from "@gleanwork/api-client/models/components"; let value: DeleteCollectionItemResponse = { collection: { name: "", description: "impanel importance pale parody towards wildly elementary unbearably", audienceFilters: [ { fieldName: "type", values: [ { value: "Spreadsheet", relationType: "EQUALS", }, { value: "Presentation", relationType: "EQUALS", }, ], }, ], id: 390864, creator: { name: "George Clooney", obfuscatedId: "abc123", }, updatedBy: { name: "George Clooney", obfuscatedId: "abc123", }, children: [ { name: "", description: "viciously creator incidentally hole pecan", audienceFilters: [ { fieldName: "type", values: [ { value: "Spreadsheet", relationType: "EQUALS", }, { value: "Presentation", relationType: "EQUALS", }, ], }, ], id: 581341, creator: { name: "George Clooney", obfuscatedId: "abc123", }, updatedBy: { name: "George Clooney", obfuscatedId: "abc123", }, }, ], }, }; ``` -------------------------------- ### Shortcut Creation Example Source: https://github.com/gleanwork/api-client-typescript/blob/main/docs/sdks/clientchat/README.md Demonstrates how to define a shortcut, including input alias, creator, updater, and destination document details. ```typescript shortcut: { inputAlias: "", createdBy: { name: "George Clooney", obfuscatedId: "abc123", }, updatedBy: { name: "George Clooney", obfuscatedId: "abc123", }, destinationDocument: { metadata: { datasource: "datasource", objectType: "Feature Request", container: "container", parentId: "JIRA_EN-1337", mimeType: "mimeType", documentId: "documentId", createTime: new Date("2000-01-23T04:56:07.000Z"), updateTime: new Date("2000-01-23T04:56:07.000Z"), author: { name: "name", obfuscatedId: "", }, components: [ "Backend", "Networking", ], status: "[\"Done\"]", customData: { "someCustomField": {}, }, }, }, }, ``` -------------------------------- ### Configure Query Suggestions Source: https://github.com/gleanwork/api-client-typescript/blob/main/docs/sdks/announcements/README.md Example of setting up query suggestions for a specific datasource. This allows for predefined search queries. ```typescript querySuggestions: { suggestions: [ { query: "app:github type:pull author:mortimer", label: "Mortimer's PRs", datasource: "github", }, ], } ``` -------------------------------- ### Specify Date Ranges Source: https://github.com/gleanwork/api-client-typescript/blob/main/docs/sdks/announcements/README.md The 'ranges' array allows for specifying start and end points for data retrieval. This example sets a 'startIndex'. ```typescript ranges: [ { startIndex: 804377, }, ], ``` -------------------------------- ### Configure Invite Info Source: https://github.com/gleanwork/api-client-typescript/blob/main/docs/sdks/announcements/README.md Example of setting up invite information, which includes an array of invite objects. ```typescript inviteInfo: { invites: [ {}, {}, {}, ], }, ``` -------------------------------- ### Configure Query Suggestions Source: https://github.com/gleanwork/api-client-typescript/blob/main/docs/sdks/announcements/README.md Example of setting up query suggestions for a datasource. This allows for predefined search queries with labels. ```typescript querySuggestions: { suggestions: [ { query: "app:github type:pull author:mortimer", label: "Mortimer's PRs", datasource: "github", }, ], }, ``` -------------------------------- ### Configure User Metadata Source: https://github.com/gleanwork/api-client-typescript/blob/main/docs/sdks/announcements/README.md Example of user metadata, including type, title, department, contact information, start date, and datasource profiles. ```typescript metadata: { type: "FULL_TIME", title: "Actor", department: "Movies", email: "george@example.com", location: "Hollywood, CA", phone: "6505551234", photoUrl: "https://example.com/george.jpg", startDate: new RFCDate("2000-01-23"), datasourceProfile: [ { datasource: "github", handle: "", }, { datasource: "github", handle: "", }, { datasource: "github", handle: "", }, ], querySuggestions: { suggestions: [ { query: "app:github type:pull author:mortimer", label: "Mortimer's PRs", datasource: "github", }, ], }, inviteInfo: { invites: [ {}, {}, {}, ], }, badges: [ { key: "deployment_name_new_hire", displayName: "New hire", iconConfig: { color: "#343CED", key: "person_icon", iconType: "GLYPH", name: "user", }, }, ], }, ``` -------------------------------- ### Configure Person Metadata Source: https://github.com/gleanwork/api-client-typescript/blob/main/docs/sdks/announcements/README.md Example of configuring metadata for a person object, including type, title, department, contact information, and start date. ```typescript metadata: { type: "FULL_TIME", title: "Actor", department: "Movies", email: "george@example.com", location: "Hollywood, CA", phone: "6505551234", photoUrl: "https://example.com/george.jpg", startDate: new RFCDate("2000-01-23"), datasourceProfile: [ { datasource: "github", handle: "", }, ], querySuggestions: { suggestions: [ { query: "app:github type:pull author:mortimer", label: "Mortimer's PRs", datasource: "github", }, ], }, inviteInfo: { invites: [ {}, {}, {}, ], }, badges: [ { key: "deployment_name_new_hire", displayName: "New hire", iconConfig: { color: "#343CED", key: "person_icon", iconType: "GLYPH", name: "user", }, }, ], }, ``` -------------------------------- ### Shortcut Example Source: https://github.com/gleanwork/api-client-typescript/blob/main/docs/sdks/clientchat/README.md Example of a shortcut object, including input alias and creator/updater information for the destination document. ```json { "shortcut": { "inputAlias": "", "createdBy": { "name": "George Clooney", "obfuscatedId": "abc123" }, "updatedBy": { "name": "George Clooney", "obfuscatedId": "abc123" }, "destinationDocument": { "metadata": { "datasource": "datasource" } } } } ``` -------------------------------- ### Run API Client Query Source: https://github.com/gleanwork/api-client-typescript/blob/main/docs/sdks/announcements/README.md This example demonstrates how to construct and execute a query using the API Client. It includes setting up query suggestions and audience filters. ```typescript import { RFCDate, SearchClient, SearchResponse, } from "@glean/api-client-typescript"; async function run() { const client = new SearchClient({ // Replace with your actual Glean domain domain: "your-glean-domain.glean.com", }); const result: SearchResponse = await client.search({ query: "test", pageSize: 10, audienceFilters: [ { fieldName: "type", values: [ { value: "Spreadsheet", relationType: "EQUALS", }, { value: "Presentation", relationType: "EQUALS", }, ], }, ], id: 602589, }); console.log(result); } run(); ``` -------------------------------- ### React Query Hook for indexingPeopleDeleteTeam Source: https://github.com/gleanwork/api-client-typescript/blob/main/docs/sdks/people/README.md Import the mutation hook for use in React components. Refer to the linked guide for detailed utility information and setup. ```tsx import { // Mutation hook for triggering the API call. useIndexingPeopleDeleteTeamMutation } from "@gleanwork/api-client/react-query/indexingPeopleDeleteTeam.js"; ``` -------------------------------- ### Generated QnA Ranges Example Source: https://github.com/gleanwork/api-client-typescript/blob/main/docs/models/components/answerresult.md This snippet shows the structure for generated QnA (Question and Answer) pairs, including the start index and the associated document information. ```typescript generatedQna: { ranges: [ { startIndex: 635422, document: { containerDocument: { metadata: { datasource: "datasource", objectType: "Feature Request", container: "container", parentId: "JIRA_EN-1337", mimeType: "mimeType", documentId: "documentId", createTime: new Date("2000-01-23T04:56:07.000Z"), updateTime: new Date("2000-01-23T04:56:07.000Z"), author: { name: "name", obfuscatedId: "", }, components: [ "Backend", "Networking", ], status: "[\"Done\"]", customData: { "someCustomField": {}, }, }, }, parentDocument: { metadata: { datasource: "datasource", objectType: "Feature Request", container: "container", parentId: "JIRA_EN-1337", mimeType: "mimeType", documentId: "documentId", createTime: new Date("2000-01-23T04:56:07.000Z"), updateTime: new Date("2000-01-23T04:56:07.000Z"), author: { name: "name", obfuscatedId: "", }, components: [ "Backend", "Networking", ], status: "[\"Done\"]", customData: { "someCustomField": {}, }, }, }, metadata: { datasource: "datasource", objectType: "Feature Request", container: "container", parentId: "JIRA_EN-1337", mimeType: "mimeType", documentId: "documentId", createTime: new Date("2000-01-23T04:56:07.000Z"), updateTime: new Date("2000-01-23T04:56:07.000Z"), author: { name: "name", obfuscatedId: "", }, components: [ "Backend", "Networking", ], status: "[\"Done\"]", customData: { "someCustomField": {}, }, }, }, }, ], } ``` -------------------------------- ### Streaming Example with Item Creation Source: https://github.com/gleanwork/api-client-typescript/blob/main/docs/sdks/clientchat/README.md Demonstrates how to use the streaming functionality to create items within the SDK. This example shows the structure of data required for creating documents and shortcuts. ```typescript streamingExample({ obfuscatedId: "abc123", }, items: [ { collectionId: 765696, createdBy: { name: "George Clooney", obfuscatedId: "abc123", }, document: { metadata: { datasource: "datasource", objectType: "Feature Request", container: "container", parentId: "JIRA_EN-1337", mimeType: "mimeType", documentId: "documentId", createTime: new Date("2000-01-23T04:56:07.000Z"), updateTime: new Date("2000-01-23T04:56:07.000Z"), author: { name: "name", obfuscatedId: "", }, components: [ "Backend", "Networking", ], status: "[\"Done\"]", customData: { "someCustomField": {}, }, }, }, shortcut: { inputAlias: "", createdBy: { name: "George Clooney", obfuscatedId: "abc123", }, updatedBy: { name: "George Clooney", obfuscatedId: "abc123", }, destinationDocument: { metadata: { datasource: "datasource", objectType: "Feature Request", container: "container", parentId: "JIRA_EN-1337", mimeType: "mimeType", documentId: "documentId", createTime: new Date("2000-01-23T04:56:07.000Z"), updateTime: new Date("2000-01-23T04:56:07.000Z"), author: { name: "name", obfuscatedId: "", }, components: [ "Backend", "Networking", ], status: "[\"Done\"]", customData: { "someCustomField": {}, }, }, }, }, itemType: "URL", }, { collectionId: 765696, createdBy: { name: "George Clooney", obfuscatedId: "abc123", }, document: { metadata: { datasource: "datasource", objectType: "Feature Request", container: "container", parentId: "JIRA_EN-1337", mimeType: "mimeType", documentId: "documentId", createTime: new Date("2000-01-23T04:56:07.000Z"), updateTime: new Date("2000-01-23T04:56:07.000Z"), author: { name: "name", obfuscatedId: "", }, components: [ "Backend", "Networking", ], status: "[\"Done\"]", customData: { "someCustomField": {}, }, }, }, shortcut: { inputAlias: "", createdBy: { name: "George Clooney", obfuscatedId: "abc123", }, }, }, ]) ``` -------------------------------- ### Create Chat Stream (Citation Response Example) Source: https://github.com/gleanwork/api-client-typescript/blob/main/docs/sdks/clientchat/README.md Initiates a chat stream with an empty message history. Useful for starting a new conversation or when no prior context is needed. ```typescript import { Glean } from "@gleanwork/api-client"; const glean = new Glean({ apiToken: process.env["GLEAN_API_TOKEN"] ?? "", }); async function run() { const result = await glean.client.chat.createStream({ messages: [], timeoutMillis: 30000, }); console.log(result); } run(); ``` ```typescript import { GleanCore } from "@gleanwork/api-client/core.js"; import { clientChatCreateStream } from "@gleanwork/api-client/funcs/clientChatCreateStream.js"; // Use `GleanCore` for best tree-shaking performance. // You can create one instance of it to use across an application. const glean = new GleanCore({ apiToken: process.env["GLEAN_API_TOKEN"] ?? "", }); async function run() { const res = await clientChatCreateStream(glean, { messages: [], timeoutMillis: 30000, }); if (res.ok) { const { value: result } = res; console.log(result); } else { console.log("clientChatCreateStream failed:", res.error); } } run(); ``` ```tsx import { // Mutation hook for triggering the API call. useClientChatCreateStreamMutation } from "@gleanwork/api-client/react-query/clientChatCreateStream.js"; ``` -------------------------------- ### Quicklink Example Usage Source: https://github.com/gleanwork/api-client-typescript/blob/main/docs/models/components/quicklink.md Demonstrates how to import and use the Quicklink model in TypeScript. ```APIDOC ## Example Usage ```typescript import { Quicklink } from "@gleanwork/api-client/models/components"; let value: Quicklink = { iconConfig: { color: "#343CED", key: "person_icon", iconType: "GLYPH", name: "user", }, }; ``` ``` -------------------------------- ### Create Shortcut Request Example Source: https://github.com/gleanwork/api-client-typescript/blob/main/docs/models/components/createshortcutrequest.md Demonstrates how to instantiate and populate a CreateShortcutRequest object. Ensure the necessary types are imported. ```typescript import { CreateShortcutRequest } from "@gleanwork/api-client/models/components"; let value: CreateShortcutRequest = { data: { addedRoles: [ { person: { name: "George Clooney", obfuscatedId: "abc123", }, role: "VIEWER", }, ], removedRoles: [ { person: { name: "George Clooney", obfuscatedId: "abc123", }, role: "VERIFIER", }, ], }, }; ``` -------------------------------- ### Configure Person Metadata Source: https://github.com/gleanwork/api-client-typescript/blob/main/docs/sdks/announcements/README.md Example of person metadata including type, title, department, email, location, phone, photo URL, start date, and datasource profiles. ```typescript { type: "FULL_TIME", title: "Actor", department: "Movies", email: "george@example.com", location: "Hollywood, CA", phone: "6505551234", photoUrl: "https://example.com/george.jpg", startDate: new RFCDate("2000-01-23"), datasourceProfile: [ { datasource: "github", handle: "", }, { datasource: "github", handle: "", }, { datasource: "github", handle: "", }, ], querySuggestions: { suggestions: [ { query: "app:github type:pull author:mortimer", label: "Mortimer's PRs", datasource: "github", }, ], }, inviteInfo: { invites: [ {}, {}, {}, ], }, badges: [ { key: "deployment_name_new_hire", displayName: "New hire", iconConfig: { color: "#343CED", key: "person_icon", iconType: "GLYPH", name: "user", }, }, ], } ``` -------------------------------- ### Query Suggestions Configuration Source: https://github.com/gleanwork/api-client-typescript/blob/main/docs/sdks/clientchat/README.md Example of setting up query suggestions, including query text, label, datasource, and associated person. ```typescript querySuggestions: { suggestions: [ { query: "app:github type:pull author:mortimer", label: "Mortimer's PRs", datasource: "github", }, ], person: { name: "George Clooney", obfuscatedId: "abc123", }, }, ``` -------------------------------- ### Configure User Profile Metadata Source: https://github.com/gleanwork/api-client-typescript/blob/main/docs/sdks/announcements/README.md Example of setting user profile details including contact information, start date, and datasource profiles. Use RFCDate for date objects. ```typescript location: "Hollywood, CA", phone: "6505551234", photoUrl: "https://example.com/george.jpg", startDate: new RFCDate("2000-01-23"), datasourceProfile: [ { datasource: "github", handle: "", }, { datasource: "github", handle: "", }, ], querySuggestions: { suggestions: [ { query: "app:github type:pull author:mortimer", label: "Mortimer's PRs", datasource: "github", }, ], }, inviteInfo: { invites: [ {}, {}, {}, ], }, badges: [ { key: "deployment_name_new_hire", displayName: "New hire", iconConfig: { color: "#343CED", key: "person_icon", iconType: "GLYPH", name: "user", }, }, ], ``` -------------------------------- ### Person Metadata Example Source: https://github.com/gleanwork/api-client-typescript/blob/main/docs/sdks/announcements/README.md Illustrates the structure of person metadata, including employment type, title, department, contact information, and start date. This is useful for representing detailed employee information. ```typescript { type: "FULL_TIME", title: "Actor", department: "Movies", email: "george@example.com", location: "Hollywood, CA", phone: "6505551234", photoUrl: "https://example.com/george.jpg", startDate: new RFCDate("2000-01-23"), } ``` -------------------------------- ### streamingExample Source: https://github.com/gleanwork/api-client-typescript/blob/main/docs/sdks/clientchat/README.md An example demonstrating how to use the `create` method of the chat client to send messages with citations and retrieve a streaming response. ```APIDOC ## POST /rest/api/v1/chat ### Description Creates a chat message with optional citations and returns a streaming response. ### Method POST ### Endpoint /rest/api/v1/chat ### Parameters #### Request Body - **messages** (array) - Required - An array of message objects to send in the chat. - **citations** (array) - Optional - A list of citations associated with the message. - **sourceDocument** (object) - Optional - Information about the source document. - **metadata** (object) - Optional - Metadata of the source document. - **datasource** (string) - Optional - The datasource of the document. - **objectType** (string) - Optional - The type of the object. - **container** (string) - Optional - The container of the document. - **parentId** (string) - Optional - The parent ID of the document. - **mimeType** (string) - Optional - The MIME type of the document. - **documentId** (string) - Optional - The ID of the document. - **createTime** (Date) - Optional - The creation time of the document. - **updateTime** (Date) - Optional - The update time of the document. - **author** (object) - Optional - The author of the document. - **name** (string) - Optional - The name of the author. - **obfuscatedId** (string) - Optional - The obfuscated ID of the author. - **components** (array) - Optional - Components of the document. - **status** (string) - Optional - The status of the document. - **customData** (object) - Optional - Custom data associated with the document. - **sourceFile** (object) - Optional - Information about the source file. - **id** (string) - Optional - The ID of the source file. - **url** (string) - Optional - The URL of the source file. - **name** (string) - Optional - The name of the source file. - **sourcePerson** (object) - Optional - Information about the source person. - **name** (string) - Optional - The name of the person. - **obfuscatedId** (string) - Optional - The obfuscated ID of the person. - **referenceRanges** (array) - Optional - Ranges within the document. - **textRange** (object) - Optional - The text range within the document. - **startIndex** (number) - Optional - The start index of the text range. - **document** (object) - Optional - The document containing the text range. - **snippets** (array) - Optional - Snippets from the text range. - **mimeType** (string) - Optional - The MIME type of the snippet. - **snippet** (string) - Optional - The content of the snippet. ### Request Example ```json { "messages": [ { "citations": [ { "sourceDocument": { "metadata": { "datasource": "datasource", "objectType": "Feature Request", "container": "container", "parentId": "JIRA_EN-1337", "mimeType": "mimeType", "documentId": "documentId", "createTime": "2000-01-23T04:56:07.000Z", "updateTime": "2000-01-23T04:56:07.000Z", "author": { "name": "name", "obfuscatedId": "" }, "components": [ "Backend", "Networking" ], "status": "[\"Done\"]", "customData": { "someCustomField": {} } } }, "sourceFile": { "id": "FILE_1234", "url": "www.google.com", "name": "sample.pdf" }, "sourcePerson": { "name": "George Clooney", "obfuscatedId": "abc123" }, "referenceRanges": [ { "textRange": { "startIndex": 260313, "document": { "metadata": { "datasource": "datasource", "objectType": "Feature Request", "container": "container", "parentId": "JIRA_EN-1337", "mimeType": "mimeType", "documentId": "documentId", "createTime": "2000-01-23T04:56:07.000Z", "updateTime": "2000-01-23T04:56:07.000Z", "author": { "name": "name", "obfuscatedId": "" }, "components": [ "Backend", "Networking" ], "status": "[\"Done\"]", "customData": { "someCustomField": {} } } } }, "snippets": [ { "mimeType": "mimeType", "snippet": "snippet" } ] } ] } ] } ] } ``` ``` -------------------------------- ### Retrieve Chat Files Example Usage Source: https://github.com/gleanwork/api-client-typescript/blob/main/docs/sdks/clientchat/README.md Demonstrates how to use the retrieveFiles method from the Glean API client to get uploaded chat files. Ensure you have initialized the Glean client with your API token. ```typescript import { Glean } from "@gleanwork/api-client"; const glean = new Glean({ apiToken: process.env["GLEAN_API_TOKEN"] ?? "", }); async function run() { const result = await glean.client.chat.retrieveFiles({ fileIds: [ "", ], }); console.log(result); } run(); ```