@gleanwork/api-client 0.1.0-beta.2 → 0.1.0-beta.4

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 (110) hide show
  1. package/README.md +34 -28
  2. package/dist/commonjs/__tests__/chat.test.js +233 -414
  3. package/dist/commonjs/__tests__/chat.test.js.map +1 -1
  4. package/dist/commonjs/funcs/chatChatStream.d.ts +16 -0
  5. package/dist/commonjs/funcs/chatChatStream.d.ts.map +1 -0
  6. package/dist/commonjs/funcs/chatChatStream.js +121 -0
  7. package/dist/commonjs/funcs/chatChatStream.js.map +1 -0
  8. package/dist/commonjs/funcs/clientChatStart.d.ts +1 -1
  9. package/dist/commonjs/funcs/clientChatStart.d.ts.map +1 -1
  10. package/dist/commonjs/funcs/clientChatStart.js +3 -3
  11. package/dist/commonjs/funcs/clientChatStart.js.map +1 -1
  12. package/dist/commonjs/lib/config.d.ts +3 -3
  13. package/dist/commonjs/lib/config.js +3 -3
  14. package/dist/commonjs/models/operations/chatstream.d.ts +38 -0
  15. package/dist/commonjs/models/operations/chatstream.d.ts.map +1 -0
  16. package/dist/commonjs/models/operations/chatstream.js +81 -0
  17. package/dist/commonjs/models/operations/chatstream.js.map +1 -0
  18. package/dist/commonjs/models/operations/index.d.ts +1 -0
  19. package/dist/commonjs/models/operations/index.d.ts.map +1 -1
  20. package/dist/commonjs/models/operations/index.js +1 -0
  21. package/dist/commonjs/models/operations/index.js.map +1 -1
  22. package/dist/commonjs/react-query/chatChatStream.d.ts +24 -0
  23. package/dist/commonjs/react-query/chatChatStream.d.ts.map +1 -0
  24. package/dist/commonjs/react-query/chatChatStream.js +47 -0
  25. package/dist/commonjs/react-query/chatChatStream.js.map +1 -0
  26. package/dist/commonjs/react-query/clientChatStart.d.ts +1 -1
  27. package/dist/commonjs/react-query/clientChatStart.d.ts.map +1 -1
  28. package/dist/commonjs/react-query/index.d.ts +1 -0
  29. package/dist/commonjs/react-query/index.d.ts.map +1 -1
  30. package/dist/commonjs/react-query/index.js +1 -0
  31. package/dist/commonjs/react-query/index.js.map +1 -1
  32. package/dist/commonjs/sdk/chat.d.ts +1 -57
  33. package/dist/commonjs/sdk/chat.d.ts.map +1 -1
  34. package/dist/commonjs/sdk/chat.js +3 -83
  35. package/dist/commonjs/sdk/chat.js.map +1 -1
  36. package/dist/commonjs/sdk/client.d.ts +2 -2
  37. package/dist/commonjs/sdk/client.d.ts.map +1 -1
  38. package/dist/commonjs/sdk/client.js +2 -2
  39. package/dist/commonjs/sdk/client.js.map +1 -1
  40. package/dist/commonjs/sdk/clientchat.d.ts +68 -0
  41. package/dist/commonjs/sdk/clientchat.d.ts.map +1 -0
  42. package/dist/commonjs/sdk/clientchat.js +102 -0
  43. package/dist/commonjs/sdk/clientchat.js.map +1 -0
  44. package/dist/commonjs/sdk/sdk.d.ts +3 -0
  45. package/dist/commonjs/sdk/sdk.d.ts.map +1 -1
  46. package/dist/commonjs/sdk/sdk.js +4 -0
  47. package/dist/commonjs/sdk/sdk.js.map +1 -1
  48. package/dist/esm/__tests__/chat.test.js +234 -415
  49. package/dist/esm/__tests__/chat.test.js.map +1 -1
  50. package/dist/esm/funcs/chatChatStream.d.ts +16 -0
  51. package/dist/esm/funcs/chatChatStream.d.ts.map +1 -0
  52. package/dist/esm/funcs/chatChatStream.js +85 -0
  53. package/dist/esm/funcs/chatChatStream.js.map +1 -0
  54. package/dist/esm/funcs/clientChatStart.d.ts +1 -1
  55. package/dist/esm/funcs/clientChatStart.d.ts.map +1 -1
  56. package/dist/esm/funcs/clientChatStart.js +3 -3
  57. package/dist/esm/funcs/clientChatStart.js.map +1 -1
  58. package/dist/esm/lib/config.d.ts +3 -3
  59. package/dist/esm/lib/config.js +3 -3
  60. package/dist/esm/models/operations/chatstream.d.ts +38 -0
  61. package/dist/esm/models/operations/chatstream.d.ts.map +1 -0
  62. package/dist/esm/models/operations/chatstream.js +43 -0
  63. package/dist/esm/models/operations/chatstream.js.map +1 -0
  64. package/dist/esm/models/operations/index.d.ts +1 -0
  65. package/dist/esm/models/operations/index.d.ts.map +1 -1
  66. package/dist/esm/models/operations/index.js +1 -0
  67. package/dist/esm/models/operations/index.js.map +1 -1
  68. package/dist/esm/react-query/chatChatStream.d.ts +24 -0
  69. package/dist/esm/react-query/chatChatStream.d.ts.map +1 -0
  70. package/dist/esm/react-query/chatChatStream.js +42 -0
  71. package/dist/esm/react-query/chatChatStream.js.map +1 -0
  72. package/dist/esm/react-query/clientChatStart.d.ts +1 -1
  73. package/dist/esm/react-query/clientChatStart.d.ts.map +1 -1
  74. package/dist/esm/react-query/index.d.ts +1 -0
  75. package/dist/esm/react-query/index.d.ts.map +1 -1
  76. package/dist/esm/react-query/index.js +1 -0
  77. package/dist/esm/react-query/index.js.map +1 -1
  78. package/dist/esm/sdk/chat.d.ts +1 -57
  79. package/dist/esm/sdk/chat.d.ts.map +1 -1
  80. package/dist/esm/sdk/chat.js +3 -83
  81. package/dist/esm/sdk/chat.js.map +1 -1
  82. package/dist/esm/sdk/client.d.ts +2 -2
  83. package/dist/esm/sdk/client.d.ts.map +1 -1
  84. package/dist/esm/sdk/client.js +2 -2
  85. package/dist/esm/sdk/client.js.map +1 -1
  86. package/dist/esm/sdk/clientchat.d.ts +68 -0
  87. package/dist/esm/sdk/clientchat.d.ts.map +1 -0
  88. package/dist/esm/sdk/clientchat.js +98 -0
  89. package/dist/esm/sdk/clientchat.js.map +1 -0
  90. package/dist/esm/sdk/sdk.d.ts +3 -0
  91. package/dist/esm/sdk/sdk.d.ts.map +1 -1
  92. package/dist/esm/sdk/sdk.js +4 -0
  93. package/dist/esm/sdk/sdk.js.map +1 -1
  94. package/docs/sdks/chat/README.md +8 -768
  95. package/docs/sdks/clientchat/README.md +878 -0
  96. package/jsr.json +1 -1
  97. package/package.json +1 -1
  98. package/src/__tests__/chat.test.ts +292 -457
  99. package/src/funcs/chatChatStream.ts +169 -0
  100. package/src/funcs/clientChatStart.ts +5 -6
  101. package/src/lib/config.ts +3 -3
  102. package/src/models/operations/chatstream.ts +86 -0
  103. package/src/models/operations/index.ts +1 -0
  104. package/src/react-query/chatChatStream.ts +91 -0
  105. package/src/react-query/clientChatStart.ts +1 -1
  106. package/src/react-query/index.ts +1 -0
  107. package/src/sdk/chat.ts +3 -159
  108. package/src/sdk/client.ts +4 -4
  109. package/src/sdk/clientchat.ts +185 -0
  110. package/src/sdk/sdk.ts +6 -0
@@ -0,0 +1,169 @@
1
+ /*
2
+ * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
3
+ */
4
+
5
+ import * as z from "zod";
6
+ import { GleanCore } from "../core.js";
7
+ import { encodeFormQuery, encodeJSON } from "../lib/encodings.js";
8
+ import * as M from "../lib/matchers.js";
9
+ import { compactMap } from "../lib/primitives.js";
10
+ import { safeParse } from "../lib/schemas.js";
11
+ import { RequestOptions } from "../lib/sdks.js";
12
+ import { extractSecurity, resolveGlobalSecurity } from "../lib/security.js";
13
+ import { pathToFunc } from "../lib/url.js";
14
+ import * as components from "../models/components/index.js";
15
+ import { GleanError } from "../models/errors/gleanerror.js";
16
+ import {
17
+ ConnectionError,
18
+ InvalidRequestError,
19
+ RequestAbortedError,
20
+ RequestTimeoutError,
21
+ UnexpectedClientError,
22
+ } from "../models/errors/httpclienterrors.js";
23
+ import { SDKValidationError } from "../models/errors/sdkvalidationerror.js";
24
+ import * as operations from "../models/operations/index.js";
25
+ import { APICall, APIPromise } from "../types/async.js";
26
+ import { Result } from "../types/fp.js";
27
+
28
+ /**
29
+ * Chat
30
+ *
31
+ * @remarks
32
+ * Have a conversation with Glean AI.
33
+ */
34
+ export function chatChatStream(
35
+ client: GleanCore,
36
+ chatRequest: components.ChatRequest,
37
+ timezoneOffset?: number | undefined,
38
+ options?: RequestOptions,
39
+ ): APIPromise<
40
+ Result<
41
+ string,
42
+ | GleanError
43
+ | SDKValidationError
44
+ | UnexpectedClientError
45
+ | InvalidRequestError
46
+ | RequestAbortedError
47
+ | RequestTimeoutError
48
+ | ConnectionError
49
+ >
50
+ > {
51
+ return new APIPromise($do(
52
+ client,
53
+ chatRequest,
54
+ timezoneOffset,
55
+ options,
56
+ ));
57
+ }
58
+
59
+ async function $do(
60
+ client: GleanCore,
61
+ chatRequest: components.ChatRequest,
62
+ timezoneOffset?: number | undefined,
63
+ options?: RequestOptions,
64
+ ): Promise<
65
+ [
66
+ Result<
67
+ string,
68
+ | GleanError
69
+ | SDKValidationError
70
+ | UnexpectedClientError
71
+ | InvalidRequestError
72
+ | RequestAbortedError
73
+ | RequestTimeoutError
74
+ | ConnectionError
75
+ >,
76
+ APICall,
77
+ ]
78
+ > {
79
+ const input: operations.ChatStreamRequest = {
80
+ chatRequest: chatRequest,
81
+ timezoneOffset: timezoneOffset,
82
+ };
83
+
84
+ const parsed = safeParse(
85
+ input,
86
+ (value) => operations.ChatStreamRequest$outboundSchema.parse(value),
87
+ "Input validation failed",
88
+ );
89
+ if (!parsed.ok) {
90
+ return [parsed, { status: "invalid" }];
91
+ }
92
+ const payload = parsed.value;
93
+ const body = encodeJSON("body", payload.ChatRequest, { explode: true });
94
+
95
+ const path = pathToFunc("/rest/api/v1/chat#stream")();
96
+
97
+ const query = encodeFormQuery({
98
+ "timezoneOffset": payload.timezoneOffset,
99
+ });
100
+
101
+ const headers = new Headers(compactMap({
102
+ "Content-Type": "application/json",
103
+ Accept: "text/plain",
104
+ }));
105
+
106
+ const secConfig = await extractSecurity(client._options.bearerAuth);
107
+ const securityInput = secConfig == null ? {} : { bearerAuth: secConfig };
108
+ const requestSecurity = resolveGlobalSecurity(securityInput);
109
+
110
+ const context = {
111
+ baseURL: options?.serverURL ?? client._baseURL ?? "",
112
+ operationID: "chatStream",
113
+ oAuth2Scopes: [],
114
+
115
+ resolvedSecurity: requestSecurity,
116
+
117
+ securitySource: client._options.bearerAuth,
118
+ retryConfig: options?.retries
119
+ || client._options.retryConfig
120
+ || { strategy: "none" },
121
+ retryCodes: options?.retryCodes || ["429", "500", "502", "503", "504"],
122
+ };
123
+
124
+ const requestRes = client._createRequest(context, {
125
+ security: requestSecurity,
126
+ method: "POST",
127
+ baseURL: options?.serverURL,
128
+ path: path,
129
+ headers: headers,
130
+ query: query,
131
+ body: body,
132
+ timeoutMs: options?.timeoutMs || client._options.timeoutMs || -1,
133
+ }, options);
134
+ if (!requestRes.ok) {
135
+ return [requestRes, { status: "invalid" }];
136
+ }
137
+ const req = requestRes.value;
138
+
139
+ const doResult = await client._do(req, {
140
+ context,
141
+ errorCodes: ["400", "401", "408", "429", "4XX", "5XX"],
142
+ retryConfig: context.retryConfig,
143
+ retryCodes: context.retryCodes,
144
+ });
145
+ if (!doResult.ok) {
146
+ return [doResult, { status: "request-error", request: req }];
147
+ }
148
+ const response = doResult.value;
149
+
150
+ const [result] = await M.match<
151
+ string,
152
+ | GleanError
153
+ | SDKValidationError
154
+ | UnexpectedClientError
155
+ | InvalidRequestError
156
+ | RequestAbortedError
157
+ | RequestTimeoutError
158
+ | ConnectionError
159
+ >(
160
+ M.text(200, z.string()),
161
+ M.fail([400, 401, 408, 429, "4XX"]),
162
+ M.fail("5XX"),
163
+ )(response);
164
+ if (!result.ok) {
165
+ return [result, { status: "complete", request: req, response }];
166
+ }
167
+
168
+ return [result, { status: "complete", request: req, response }];
169
+ }
@@ -2,7 +2,6 @@
2
2
  * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
3
3
  */
4
4
 
5
- import * as z from "zod";
6
5
  import { GleanCore } from "../core.js";
7
6
  import { encodeFormQuery, encodeJSON } from "../lib/encodings.js";
8
7
  import * as M from "../lib/matchers.js";
@@ -38,7 +37,7 @@ export function clientChatStart(
38
37
  options?: RequestOptions,
39
38
  ): APIPromise<
40
39
  Result<
41
- string,
40
+ components.ChatResponse,
42
41
  | GleanError
43
42
  | SDKValidationError
44
43
  | UnexpectedClientError
@@ -64,7 +63,7 @@ async function $do(
64
63
  ): Promise<
65
64
  [
66
65
  Result<
67
- string,
66
+ components.ChatResponse,
68
67
  | GleanError
69
68
  | SDKValidationError
70
69
  | UnexpectedClientError
@@ -100,7 +99,7 @@ async function $do(
100
99
 
101
100
  const headers = new Headers(compactMap({
102
101
  "Content-Type": "application/json",
103
- Accept: "text/plain",
102
+ Accept: "application/json",
104
103
  }));
105
104
 
106
105
  const secConfig = await extractSecurity(client._options.bearerAuth);
@@ -148,7 +147,7 @@ async function $do(
148
147
  const response = doResult.value;
149
148
 
150
149
  const [result] = await M.match<
151
- string,
150
+ components.ChatResponse,
152
151
  | GleanError
153
152
  | SDKValidationError
154
153
  | UnexpectedClientError
@@ -157,7 +156,7 @@ async function $do(
157
156
  | RequestTimeoutError
158
157
  | ConnectionError
159
158
  >(
160
- M.text(200, z.string()),
159
+ M.json(200, components.ChatResponse$inboundSchema),
161
160
  M.fail([400, 401, 408, 429, "4XX"]),
162
161
  M.fail("5XX"),
163
162
  )(response);
package/src/lib/config.ts CHANGED
@@ -64,8 +64,8 @@ export function serverURLFromOptions(options: SDKOptions): URL | null {
64
64
  export const SDK_METADATA = {
65
65
  language: "typescript",
66
66
  openapiDocVersion: "0.9.0",
67
- sdkVersion: "0.1.0-beta.2",
68
- genVersion: "2.595.4",
67
+ sdkVersion: "0.1.0-beta.4",
68
+ genVersion: "2.596.2",
69
69
  userAgent:
70
- "speakeasy-sdk/typescript 0.1.0-beta.2 2.595.4 0.9.0 @gleanwork/api-client",
70
+ "speakeasy-sdk/typescript 0.1.0-beta.4 2.596.2 0.9.0 @gleanwork/api-client",
71
71
  } as const;
@@ -0,0 +1,86 @@
1
+ /*
2
+ * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
3
+ */
4
+
5
+ import * as z from "zod";
6
+ import { remap as remap$ } from "../../lib/primitives.js";
7
+ import { safeParse } from "../../lib/schemas.js";
8
+ import { Result as SafeParseResult } from "../../types/fp.js";
9
+ import * as components from "../components/index.js";
10
+ import { SDKValidationError } from "../errors/sdkvalidationerror.js";
11
+
12
+ export type ChatStreamRequest = {
13
+ /**
14
+ * The offset of the client's timezone in minutes from UTC. e.g. PDT is -420 because it's 7 hours behind UTC.
15
+ */
16
+ timezoneOffset?: number | undefined;
17
+ /**
18
+ * Includes chat history for Glean AI to respond to.
19
+ */
20
+ chatRequest: components.ChatRequest;
21
+ };
22
+
23
+ /** @internal */
24
+ export const ChatStreamRequest$inboundSchema: z.ZodType<
25
+ ChatStreamRequest,
26
+ z.ZodTypeDef,
27
+ unknown
28
+ > = z.object({
29
+ timezoneOffset: z.number().int().optional(),
30
+ ChatRequest: components.ChatRequest$inboundSchema,
31
+ }).transform((v) => {
32
+ return remap$(v, {
33
+ "ChatRequest": "chatRequest",
34
+ });
35
+ });
36
+
37
+ /** @internal */
38
+ export type ChatStreamRequest$Outbound = {
39
+ timezoneOffset?: number | undefined;
40
+ ChatRequest: components.ChatRequest$Outbound;
41
+ };
42
+
43
+ /** @internal */
44
+ export const ChatStreamRequest$outboundSchema: z.ZodType<
45
+ ChatStreamRequest$Outbound,
46
+ z.ZodTypeDef,
47
+ ChatStreamRequest
48
+ > = z.object({
49
+ timezoneOffset: z.number().int().optional(),
50
+ chatRequest: components.ChatRequest$outboundSchema,
51
+ }).transform((v) => {
52
+ return remap$(v, {
53
+ chatRequest: "ChatRequest",
54
+ });
55
+ });
56
+
57
+ /**
58
+ * @internal
59
+ * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module.
60
+ */
61
+ export namespace ChatStreamRequest$ {
62
+ /** @deprecated use `ChatStreamRequest$inboundSchema` instead. */
63
+ export const inboundSchema = ChatStreamRequest$inboundSchema;
64
+ /** @deprecated use `ChatStreamRequest$outboundSchema` instead. */
65
+ export const outboundSchema = ChatStreamRequest$outboundSchema;
66
+ /** @deprecated use `ChatStreamRequest$Outbound` instead. */
67
+ export type Outbound = ChatStreamRequest$Outbound;
68
+ }
69
+
70
+ export function chatStreamRequestToJSON(
71
+ chatStreamRequest: ChatStreamRequest,
72
+ ): string {
73
+ return JSON.stringify(
74
+ ChatStreamRequest$outboundSchema.parse(chatStreamRequest),
75
+ );
76
+ }
77
+
78
+ export function chatStreamRequestFromJSON(
79
+ jsonString: string,
80
+ ): SafeParseResult<ChatStreamRequest, SDKValidationError> {
81
+ return safeParse(
82
+ jsonString,
83
+ (x) => ChatStreamRequest$inboundSchema.parse(JSON.parse(x)),
84
+ `Failed to parse 'ChatStreamRequest' from JSON`,
85
+ );
86
+ }
@@ -3,6 +3,7 @@
3
3
  */
4
4
 
5
5
  export * from "./chat.js";
6
+ export * from "./chatstream.js";
6
7
  export * from "./deleteallchats.js";
7
8
  export * from "./deletechatfiles.js";
8
9
  export * from "./deletechats.js";
@@ -0,0 +1,91 @@
1
+ /*
2
+ * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
3
+ */
4
+
5
+ import {
6
+ MutationKey,
7
+ useMutation,
8
+ UseMutationResult,
9
+ } from "@tanstack/react-query";
10
+ import { GleanCore } from "../core.js";
11
+ import { chatChatStream } from "../funcs/chatChatStream.js";
12
+ import { combineSignals } from "../lib/primitives.js";
13
+ import { RequestOptions } from "../lib/sdks.js";
14
+ import * as components from "../models/components/index.js";
15
+ import { unwrapAsync } from "../types/fp.js";
16
+ import { useGleanContext } from "./_context.js";
17
+ import { MutationHookOptions } from "./_types.js";
18
+
19
+ export type ChatChatStreamMutationVariables = {
20
+ chatRequest: components.ChatRequest;
21
+ timezoneOffset?: number | undefined;
22
+ options?: RequestOptions;
23
+ };
24
+
25
+ export type ChatChatStreamMutationData = string;
26
+
27
+ /**
28
+ * Chat
29
+ *
30
+ * @remarks
31
+ * Have a conversation with Glean AI.
32
+ */
33
+ export function useChatChatStreamMutation(
34
+ options?: MutationHookOptions<
35
+ ChatChatStreamMutationData,
36
+ Error,
37
+ ChatChatStreamMutationVariables
38
+ >,
39
+ ): UseMutationResult<
40
+ ChatChatStreamMutationData,
41
+ Error,
42
+ ChatChatStreamMutationVariables
43
+ > {
44
+ const client = useGleanContext();
45
+ return useMutation({
46
+ ...buildChatChatStreamMutation(client, options),
47
+ ...options,
48
+ });
49
+ }
50
+
51
+ export function mutationKeyChatChatStream(): MutationKey {
52
+ return ["@gleanwork/api-client", "Chat", "chatStream"];
53
+ }
54
+
55
+ export function buildChatChatStreamMutation(
56
+ client$: GleanCore,
57
+ hookOptions?: RequestOptions,
58
+ ): {
59
+ mutationKey: MutationKey;
60
+ mutationFn: (
61
+ variables: ChatChatStreamMutationVariables,
62
+ ) => Promise<ChatChatStreamMutationData>;
63
+ } {
64
+ return {
65
+ mutationKey: mutationKeyChatChatStream(),
66
+ mutationFn: function chatChatStreamMutationFn({
67
+ chatRequest,
68
+ timezoneOffset,
69
+ options,
70
+ }): Promise<ChatChatStreamMutationData> {
71
+ const mergedOptions = {
72
+ ...hookOptions,
73
+ ...options,
74
+ fetchOptions: {
75
+ ...hookOptions?.fetchOptions,
76
+ ...options?.fetchOptions,
77
+ signal: combineSignals(
78
+ hookOptions?.fetchOptions?.signal,
79
+ options?.fetchOptions?.signal,
80
+ ),
81
+ },
82
+ };
83
+ return unwrapAsync(chatChatStream(
84
+ client$,
85
+ chatRequest,
86
+ timezoneOffset,
87
+ mergedOptions,
88
+ ));
89
+ },
90
+ };
91
+ }
@@ -22,7 +22,7 @@ export type ClientChatStartMutationVariables = {
22
22
  options?: RequestOptions;
23
23
  };
24
24
 
25
- export type ClientChatStartMutationData = string;
25
+ export type ClientChatStartMutationData = components.ChatResponse;
26
26
 
27
27
  /**
28
28
  * Chat
@@ -8,6 +8,7 @@ export * from "./_types.js";
8
8
  export * from "./agentsGetagentinputs.js";
9
9
  export * from "./agentsListagents.js";
10
10
  export * from "./agentsRunagent.js";
11
+ export * from "./chatChatStream.js";
11
12
  export * from "./clientActivitiesReportActivity.js";
12
13
  export * from "./clientActivityReport.js";
13
14
  export * from "./clientAnnouncementsCreate.js";
package/src/sdk/chat.ts CHANGED
@@ -2,15 +2,7 @@
2
2
  * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
3
3
  */
4
4
 
5
- import { clientChatDelete } from "../funcs/clientChatDelete.js";
6
- import { clientChatDeleteAll } from "../funcs/clientChatDeleteAll.js";
7
- import { clientChatDeleteFiles } from "../funcs/clientChatDeleteFiles.js";
8
- import { clientChatGet } from "../funcs/clientChatGet.js";
9
- import { clientChatGetApplication } from "../funcs/clientChatGetApplication.js";
10
- import { clientChatGetFiles } from "../funcs/clientChatGetFiles.js";
11
- import { clientChatList } from "../funcs/clientChatList.js";
12
- import { clientChatStart } from "../funcs/clientChatStart.js";
13
- import { clientChatUploadFiles } from "../funcs/clientChatUploadFiles.js";
5
+ import { chatChatStream } from "../funcs/chatChatStream.js";
14
6
  import { ClientSDK, RequestOptions } from "../lib/sdks.js";
15
7
  import * as components from "../models/components/index.js";
16
8
  import { unwrapAsync } from "../types/fp.js";
@@ -22,164 +14,16 @@ export class Chat extends ClientSDK {
22
14
  * @remarks
23
15
  * Have a conversation with Glean AI.
24
16
  */
25
- async start(
17
+ async chatStream(
26
18
  chatRequest: components.ChatRequest,
27
19
  timezoneOffset?: number | undefined,
28
20
  options?: RequestOptions,
29
21
  ): Promise<string> {
30
- return unwrapAsync(clientChatStart(
22
+ return unwrapAsync(chatChatStream(
31
23
  this,
32
24
  chatRequest,
33
25
  timezoneOffset,
34
26
  options,
35
27
  ));
36
28
  }
37
-
38
- /**
39
- * Deletes all saved Chats owned by a user
40
- *
41
- * @remarks
42
- * Deletes all saved Chats a user has had and all their contained conversational content.
43
- */
44
- async deleteAll(
45
- timezoneOffset?: number | undefined,
46
- options?: RequestOptions,
47
- ): Promise<void> {
48
- return unwrapAsync(clientChatDeleteAll(
49
- this,
50
- timezoneOffset,
51
- options,
52
- ));
53
- }
54
-
55
- /**
56
- * Deletes saved Chats
57
- *
58
- * @remarks
59
- * Deletes saved Chats and all their contained conversational content.
60
- */
61
- async delete(
62
- deleteChatsRequest: components.DeleteChatsRequest,
63
- timezoneOffset?: number | undefined,
64
- options?: RequestOptions,
65
- ): Promise<void> {
66
- return unwrapAsync(clientChatDelete(
67
- this,
68
- deleteChatsRequest,
69
- timezoneOffset,
70
- options,
71
- ));
72
- }
73
-
74
- /**
75
- * Retrieves a Chat
76
- *
77
- * @remarks
78
- * Retrieves the chat history between Glean Assistant and the user for a given Chat.
79
- */
80
- async get(
81
- getChatRequest: components.GetChatRequest,
82
- timezoneOffset?: number | undefined,
83
- options?: RequestOptions,
84
- ): Promise<components.GetChatResponse> {
85
- return unwrapAsync(clientChatGet(
86
- this,
87
- getChatRequest,
88
- timezoneOffset,
89
- options,
90
- ));
91
- }
92
-
93
- /**
94
- * Retrieves all saved Chats
95
- *
96
- * @remarks
97
- * Retrieves all the saved Chats between Glean Assistant and the user. The returned Chats contain only metadata and no conversational content.
98
- */
99
- async list(
100
- timezoneOffset?: number | undefined,
101
- options?: RequestOptions,
102
- ): Promise<components.ListChatsResponse> {
103
- return unwrapAsync(clientChatList(
104
- this,
105
- timezoneOffset,
106
- options,
107
- ));
108
- }
109
-
110
- /**
111
- * Gets the metadata for a custom Chat application
112
- *
113
- * @remarks
114
- * Gets the Chat application details for the specified application ID.
115
- */
116
- async getApplication(
117
- getChatApplicationRequest: components.GetChatApplicationRequest,
118
- timezoneOffset?: number | undefined,
119
- options?: RequestOptions,
120
- ): Promise<components.GetChatApplicationResponse> {
121
- return unwrapAsync(clientChatGetApplication(
122
- this,
123
- getChatApplicationRequest,
124
- timezoneOffset,
125
- options,
126
- ));
127
- }
128
-
129
- /**
130
- * Upload files for Chat.
131
- *
132
- * @remarks
133
- * Upload files for Chat.
134
- */
135
- async uploadFiles(
136
- uploadChatFilesRequest: components.UploadChatFilesRequest,
137
- timezoneOffset?: number | undefined,
138
- options?: RequestOptions,
139
- ): Promise<components.UploadChatFilesResponse> {
140
- return unwrapAsync(clientChatUploadFiles(
141
- this,
142
- uploadChatFilesRequest,
143
- timezoneOffset,
144
- options,
145
- ));
146
- }
147
-
148
- /**
149
- * Get files uploaded by a user for Chat.
150
- *
151
- * @remarks
152
- * Get files uploaded by a user for Chat.
153
- */
154
- async getFiles(
155
- getChatFilesRequest: components.GetChatFilesRequest,
156
- timezoneOffset?: number | undefined,
157
- options?: RequestOptions,
158
- ): Promise<components.GetChatFilesResponse> {
159
- return unwrapAsync(clientChatGetFiles(
160
- this,
161
- getChatFilesRequest,
162
- timezoneOffset,
163
- options,
164
- ));
165
- }
166
-
167
- /**
168
- * Delete files uploaded by a user for chat.
169
- *
170
- * @remarks
171
- * Delete files uploaded by a user for Chat.
172
- */
173
- async deleteFiles(
174
- deleteChatFilesRequest: components.DeleteChatFilesRequest,
175
- timezoneOffset?: number | undefined,
176
- options?: RequestOptions,
177
- ): Promise<void> {
178
- return unwrapAsync(clientChatDeleteFiles(
179
- this,
180
- deleteChatFilesRequest,
181
- timezoneOffset,
182
- options,
183
- ));
184
- }
185
29
  }
package/src/sdk/client.ts CHANGED
@@ -7,8 +7,8 @@ import { Activities } from "./activities.js";
7
7
  import { Activity } from "./activity.js";
8
8
  import { Announcements } from "./announcements.js";
9
9
  import { Answers } from "./answers.js";
10
- import { Chat } from "./chat.js";
11
10
  import { ClientAuthentication } from "./clientauthentication.js";
11
+ import { ClientChat } from "./clientchat.js";
12
12
  import { ClientDocuments } from "./clientdocuments.js";
13
13
  import { ClientShortcuts } from "./clientshortcuts.js";
14
14
  import { Collections } from "./collections.js";
@@ -46,9 +46,9 @@ export class Client extends ClientSDK {
46
46
  return (this._authentication ??= new ClientAuthentication(this._options));
47
47
  }
48
48
 
49
- private _chat?: Chat;
50
- get chat(): Chat {
51
- return (this._chat ??= new Chat(this._options));
49
+ private _chat?: ClientChat;
50
+ get chat(): ClientChat {
51
+ return (this._chat ??= new ClientChat(this._options));
52
52
  }
53
53
 
54
54
  private _collections?: Collections;