@mistralai/mistralai 2.6.2 → 2.6.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 (162) hide show
  1. package/README.md +11 -2
  2. package/esm/funcs/betaUsersListOrganizations.d.ts +23 -0
  3. package/esm/funcs/betaUsersListOrganizations.d.ts.map +1 -0
  4. package/esm/funcs/betaUsersListOrganizations.js +128 -0
  5. package/esm/funcs/betaUsersListOrganizations.js.map +1 -0
  6. package/esm/funcs/betaUsersListWorkspaces.d.ts +21 -0
  7. package/esm/funcs/betaUsersListWorkspaces.d.ts.map +1 -0
  8. package/esm/funcs/betaUsersListWorkspaces.js +126 -0
  9. package/esm/funcs/betaUsersListWorkspaces.js.map +1 -0
  10. package/esm/funcs/realtimeSessionsCreate.d.ts +16 -0
  11. package/esm/funcs/realtimeSessionsCreate.d.ts.map +1 -0
  12. package/esm/funcs/realtimeSessionsCreate.js +82 -0
  13. package/esm/funcs/realtimeSessionsCreate.js.map +1 -0
  14. package/esm/funcs/workflowsDeploymentsGetDeployment.js +5 -1
  15. package/esm/funcs/workflowsDeploymentsGetDeployment.js.map +1 -1
  16. package/esm/lib/config.d.ts +2 -2
  17. package/esm/lib/config.js +2 -2
  18. package/esm/models/components/authenticationmethodcreateorupdaterequest.d.ts +10 -0
  19. package/esm/models/components/authenticationmethodcreateorupdaterequest.d.ts.map +1 -1
  20. package/esm/models/components/authenticationmethodcreateorupdaterequest.js +4 -0
  21. package/esm/models/components/authenticationmethodcreateorupdaterequest.js.map +1 -1
  22. package/esm/models/components/clientsecret.d.ts +11 -0
  23. package/esm/models/components/clientsecret.d.ts.map +1 -0
  24. package/esm/models/components/clientsecret.js +21 -0
  25. package/esm/models/components/clientsecret.js.map +1 -0
  26. package/esm/models/components/clientsessionpurpose.d.ts +15 -0
  27. package/esm/models/components/clientsessionpurpose.d.ts.map +1 -0
  28. package/esm/models/components/clientsessionpurpose.js +14 -0
  29. package/esm/models/components/clientsessionpurpose.js.map +1 -0
  30. package/esm/models/components/createconnectorrequest.d.ts +10 -0
  31. package/esm/models/components/createconnectorrequest.d.ts.map +1 -1
  32. package/esm/models/components/createconnectorrequest.js +4 -0
  33. package/esm/models/components/createconnectorrequest.js.map +1 -1
  34. package/esm/models/components/createingestionpipelineconfigurationrequest.d.ts +3 -0
  35. package/esm/models/components/createingestionpipelineconfigurationrequest.d.ts.map +1 -1
  36. package/esm/models/components/createingestionpipelineconfigurationrequest.js +3 -0
  37. package/esm/models/components/createingestionpipelineconfigurationrequest.js.map +1 -1
  38. package/esm/models/components/createrealtimesessionrequest.d.ts +17 -0
  39. package/esm/models/components/createrealtimesessionrequest.d.ts.map +1 -0
  40. package/esm/models/components/createrealtimesessionrequest.js +14 -0
  41. package/esm/models/components/createrealtimesessionrequest.js.map +1 -0
  42. package/esm/models/components/createrealtimesessionresponse.d.ts +18 -0
  43. package/esm/models/components/createrealtimesessionresponse.d.ts.map +1 -0
  44. package/esm/models/components/createrealtimesessionresponse.js +25 -0
  45. package/esm/models/components/createrealtimesessionresponse.js.map +1 -0
  46. package/esm/models/components/deploymentdetailresponse.d.ts +2 -0
  47. package/esm/models/components/deploymentdetailresponse.d.ts.map +1 -1
  48. package/esm/models/components/deploymentdetailresponse.js.map +1 -1
  49. package/esm/models/components/deploymentresponse.d.ts +2 -0
  50. package/esm/models/components/deploymentresponse.d.ts.map +1 -1
  51. package/esm/models/components/deploymentresponse.js.map +1 -1
  52. package/esm/models/components/extendedoauthservermetadata.d.ts +8 -0
  53. package/esm/models/components/extendedoauthservermetadata.d.ts.map +1 -1
  54. package/esm/models/components/extendedoauthservermetadata.js +65 -0
  55. package/esm/models/components/extendedoauthservermetadata.js.map +1 -1
  56. package/esm/models/components/globalheadervalue.d.ts +26 -0
  57. package/esm/models/components/globalheadervalue.d.ts.map +1 -0
  58. package/esm/models/components/globalheadervalue.js +32 -0
  59. package/esm/models/components/globalheadervalue.js.map +1 -0
  60. package/esm/models/components/index.d.ts +11 -0
  61. package/esm/models/components/index.d.ts.map +1 -1
  62. package/esm/models/components/index.js +11 -0
  63. package/esm/models/components/index.js.map +1 -1
  64. package/esm/models/components/ingestionpipelinetargetindexref.d.ts +14 -0
  65. package/esm/models/components/ingestionpipelinetargetindexref.d.ts.map +1 -0
  66. package/esm/models/components/ingestionpipelinetargetindexref.js +14 -0
  67. package/esm/models/components/ingestionpipelinetargetindexref.js.map +1 -0
  68. package/esm/models/components/listorganizationsresponse.d.ts +14 -0
  69. package/esm/models/components/listorganizationsresponse.d.ts.map +1 -0
  70. package/esm/models/components/listorganizationsresponse.js +15 -0
  71. package/esm/models/components/listorganizationsresponse.js.map +1 -0
  72. package/esm/models/components/listworkspacesresponse.d.ts +14 -0
  73. package/esm/models/components/listworkspacesresponse.d.ts.map +1 -0
  74. package/esm/models/components/listworkspacesresponse.js +15 -0
  75. package/esm/models/components/listworkspacesresponse.js.map +1 -0
  76. package/esm/models/components/oauthmetadatasource.d.ts +18 -0
  77. package/esm/models/components/oauthmetadatasource.d.ts.map +1 -0
  78. package/esm/models/components/oauthmetadatasource.js +17 -0
  79. package/esm/models/components/oauthmetadatasource.js.map +1 -0
  80. package/esm/models/components/publicauthenticationmethod.d.ts +6 -0
  81. package/esm/models/components/publicauthenticationmethod.d.ts.map +1 -1
  82. package/esm/models/components/publicauthenticationmethod.js +8 -0
  83. package/esm/models/components/publicauthenticationmethod.js.map +1 -1
  84. package/esm/models/components/userorganization.d.ts +17 -0
  85. package/esm/models/components/userorganization.d.ts.map +1 -0
  86. package/esm/models/components/userorganization.js +15 -0
  87. package/esm/models/components/userorganization.js.map +1 -0
  88. package/esm/models/components/userworkspace.d.ts +21 -0
  89. package/esm/models/components/userworkspace.d.ts.map +1 -0
  90. package/esm/models/components/userworkspace.js +22 -0
  91. package/esm/models/components/userworkspace.js.map +1 -0
  92. package/esm/models/operations/createclientsessionv1clientsessionspost.d.ts +9 -0
  93. package/esm/models/operations/createclientsessionv1clientsessionspost.d.ts.map +1 -0
  94. package/esm/models/operations/createclientsessionv1clientsessionspost.js +11 -0
  95. package/esm/models/operations/createclientsessionv1clientsessionspost.js.map +1 -0
  96. package/esm/models/operations/getdeploymentv1workflowsdeploymentsnameget.d.ts +5 -0
  97. package/esm/models/operations/getdeploymentv1workflowsdeploymentsnameget.d.ts.map +1 -1
  98. package/esm/models/operations/getdeploymentv1workflowsdeploymentsnameget.js +6 -0
  99. package/esm/models/operations/getdeploymentv1workflowsdeploymentsnameget.js.map +1 -1
  100. package/esm/models/operations/index.d.ts +3 -0
  101. package/esm/models/operations/index.d.ts.map +1 -1
  102. package/esm/models/operations/index.js +3 -0
  103. package/esm/models/operations/index.js.map +1 -1
  104. package/esm/models/operations/usersapilistorganizations.d.ts +39 -0
  105. package/esm/models/operations/usersapilistorganizations.d.ts.map +1 -0
  106. package/esm/models/operations/usersapilistorganizations.js +39 -0
  107. package/esm/models/operations/usersapilistorganizations.js.map +1 -0
  108. package/esm/models/operations/usersapilistworkspaces.d.ts +44 -0
  109. package/esm/models/operations/usersapilistworkspaces.d.ts.map +1 -0
  110. package/esm/models/operations/usersapilistworkspaces.js +44 -0
  111. package/esm/models/operations/usersapilistworkspaces.js.map +1 -0
  112. package/esm/sdk/realtime.d.ts +7 -0
  113. package/esm/sdk/realtime.d.ts.map +1 -0
  114. package/esm/sdk/realtime.js +13 -0
  115. package/esm/sdk/realtime.js.map +1 -0
  116. package/esm/sdk/sdk.d.ts +3 -0
  117. package/esm/sdk/sdk.d.ts.map +1 -1
  118. package/esm/sdk/sdk.js +5 -0
  119. package/esm/sdk/sdk.js.map +1 -1
  120. package/esm/sdk/sessions.d.ts +10 -0
  121. package/esm/sdk/sessions.d.ts.map +1 -0
  122. package/esm/sdk/sessions.js +16 -0
  123. package/esm/sdk/sessions.js.map +1 -0
  124. package/esm/sdk/users.d.ts +23 -0
  125. package/esm/sdk/users.d.ts.map +1 -1
  126. package/esm/sdk/users.js +25 -0
  127. package/esm/sdk/users.js.map +1 -1
  128. package/jsr.json +1 -1
  129. package/package.json +1 -1
  130. package/src/funcs/betaUsersListOrganizations.ts +257 -0
  131. package/src/funcs/betaUsersListWorkspaces.ts +257 -0
  132. package/src/funcs/realtimeSessionsCreate.ts +170 -0
  133. package/src/funcs/workflowsDeploymentsGetDeployment.ts +6 -1
  134. package/src/lib/config.ts +2 -2
  135. package/src/models/components/authenticationmethodcreateorupdaterequest.ts +13 -0
  136. package/src/models/components/clientsecret.ts +36 -0
  137. package/src/models/components/clientsessionpurpose.ts +23 -0
  138. package/src/models/components/createconnectorrequest.ts +13 -0
  139. package/src/models/components/createingestionpipelineconfigurationrequest.ts +14 -0
  140. package/src/models/components/createrealtimesessionrequest.ts +39 -0
  141. package/src/models/components/createrealtimesessionresponse.ts +51 -0
  142. package/src/models/components/deploymentdetailresponse.ts +2 -0
  143. package/src/models/components/deploymentresponse.ts +2 -0
  144. package/src/models/components/extendedoauthservermetadata.ts +95 -0
  145. package/src/models/components/globalheadervalue.ts +70 -0
  146. package/src/models/components/index.ts +11 -0
  147. package/src/models/components/ingestionpipelinetargetindexref.ts +36 -0
  148. package/src/models/components/listorganizationsresponse.ts +38 -0
  149. package/src/models/components/listworkspacesresponse.ts +35 -0
  150. package/src/models/components/oauthmetadatasource.ts +31 -0
  151. package/src/models/components/publicauthenticationmethod.ts +16 -0
  152. package/src/models/components/userorganization.ts +39 -0
  153. package/src/models/components/userworkspace.ts +47 -0
  154. package/src/models/operations/createclientsessionv1clientsessionspost.ts +20 -0
  155. package/src/models/operations/getdeploymentv1workflowsdeploymentsnameget.ts +11 -0
  156. package/src/models/operations/index.ts +3 -0
  157. package/src/models/operations/usersapilistorganizations.ts +104 -0
  158. package/src/models/operations/usersapilistworkspaces.ts +114 -0
  159. package/src/sdk/realtime.ts +14 -0
  160. package/src/sdk/sdk.ts +6 -0
  161. package/src/sdk/sessions.ts +26 -0
  162. package/src/sdk/users.ts +52 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mistralai/mistralai",
3
- "version": "2.6.2",
3
+ "version": "2.6.3",
4
4
  "author": "Mistral AI",
5
5
  "description": "TypeScript client library for the Mistral AI API",
6
6
  "license": "Apache-2.0",
@@ -0,0 +1,257 @@
1
+ /*
2
+ * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
3
+ * @generated-id: dd2b1c2b32df
4
+ */
5
+
6
+ import { MistralCore } from "../core.js";
7
+ import { dlv } from "../lib/dlv.js";
8
+ import { encodeFormQuery } from "../lib/encodings.js";
9
+ import { matchStatusCode } from "../lib/http.js";
10
+ import * as M from "../lib/matchers.js";
11
+ import { compactMap } from "../lib/primitives.js";
12
+ import { safeParse } from "../lib/schemas.js";
13
+ import { RequestOptions } from "../lib/sdks.js";
14
+ import { resolveSecurity } from "../lib/security.js";
15
+ import { pathToFunc } from "../lib/url.js";
16
+ import {
17
+ ConnectionError,
18
+ InvalidRequestError,
19
+ RequestAbortedError,
20
+ RequestTimeoutError,
21
+ UnexpectedClientError,
22
+ } from "../models/errors/httpclienterrors.js";
23
+ import { MistralError } from "../models/errors/mistralerror.js";
24
+ import { ResponseValidationError } from "../models/errors/responsevalidationerror.js";
25
+ import { SDKValidationError } from "../models/errors/sdkvalidationerror.js";
26
+ import * as operations from "../models/operations/index.js";
27
+ import { APICall, APIPromise } from "../types/async.js";
28
+ import { Result } from "../types/fp.js";
29
+ import {
30
+ createPageIterator,
31
+ haltIterator,
32
+ PageIterator,
33
+ Paginator,
34
+ } from "../types/operations.js";
35
+
36
+ /**
37
+ * List Organizations
38
+ *
39
+ * @remarks
40
+ * List every organization the authenticated user is a member of.
41
+ *
42
+ * Identity-only: the caller need not have selected an organization, so this
43
+ * reads only the user and never scopes by the active org.
44
+ */
45
+ export function betaUsersListOrganizations(
46
+ client: MistralCore,
47
+ security: operations.UsersApiListOrganizationsSecurity,
48
+ request?: operations.UsersApiListOrganizationsRequest | undefined,
49
+ options?: RequestOptions,
50
+ ): APIPromise<
51
+ PageIterator<
52
+ Result<
53
+ operations.UsersApiListOrganizationsResponse,
54
+ | MistralError
55
+ | ResponseValidationError
56
+ | ConnectionError
57
+ | RequestAbortedError
58
+ | RequestTimeoutError
59
+ | InvalidRequestError
60
+ | UnexpectedClientError
61
+ | SDKValidationError
62
+ >,
63
+ { offset: number }
64
+ >
65
+ > {
66
+ return new APIPromise($do(
67
+ client,
68
+ security,
69
+ request,
70
+ options,
71
+ ));
72
+ }
73
+
74
+ async function $do(
75
+ client: MistralCore,
76
+ security: operations.UsersApiListOrganizationsSecurity,
77
+ request?: operations.UsersApiListOrganizationsRequest | undefined,
78
+ options?: RequestOptions,
79
+ ): Promise<
80
+ [
81
+ PageIterator<
82
+ Result<
83
+ operations.UsersApiListOrganizationsResponse,
84
+ | MistralError
85
+ | ResponseValidationError
86
+ | ConnectionError
87
+ | RequestAbortedError
88
+ | RequestTimeoutError
89
+ | InvalidRequestError
90
+ | UnexpectedClientError
91
+ | SDKValidationError
92
+ >,
93
+ { offset: number }
94
+ >,
95
+ APICall,
96
+ ]
97
+ > {
98
+ const parsed = safeParse(
99
+ request,
100
+ (value) =>
101
+ operations.UsersApiListOrganizationsRequest$outboundSchema.optional()
102
+ .parse(value),
103
+ "Input validation failed",
104
+ );
105
+ if (!parsed.ok) {
106
+ return [haltIterator(parsed), { status: "invalid" }];
107
+ }
108
+ const payload = parsed.value;
109
+ const body = null;
110
+
111
+ const path = pathToFunc("/v1/users/me/organizations")();
112
+
113
+ const query = encodeFormQuery({
114
+ "limit": payload?.limit,
115
+ "offset": payload?.offset,
116
+ });
117
+
118
+ const headers = new Headers(compactMap({
119
+ Accept: "application/json",
120
+ }));
121
+
122
+ const requestSecurity = resolveSecurity(
123
+ [
124
+ {
125
+ fieldName: "x-api-key",
126
+ type: "apiKey:header",
127
+ value: security?.dashboardUserContextAuth,
128
+ },
129
+ ],
130
+ );
131
+
132
+ const context = {
133
+ options: client._options,
134
+ baseURL: options?.serverURL ?? client._baseURL ?? "",
135
+ operationID: "users_api_list_organizations",
136
+ oAuth2Scopes: null,
137
+
138
+ resolvedSecurity: requestSecurity,
139
+
140
+ securitySource: security,
141
+ retryConfig: options?.retries
142
+ || client._options.retryConfig
143
+ || { strategy: "none" },
144
+ retryCodes: options?.retryCodes || ["429", "500", "502", "503", "504"],
145
+ };
146
+
147
+ const requestRes = client._createRequest(context, {
148
+ security: requestSecurity,
149
+ method: "GET",
150
+ baseURL: options?.serverURL,
151
+ path: path,
152
+ headers: headers,
153
+ query: query,
154
+ body: body,
155
+ userAgent: client._options.userAgent,
156
+ timeoutMs: options?.timeoutMs || client._options.timeoutMs || 300000,
157
+ }, options);
158
+ if (!requestRes.ok) {
159
+ return [haltIterator(requestRes), { status: "invalid" }];
160
+ }
161
+ const req = requestRes.value;
162
+
163
+ const doResult = await client._do(req, {
164
+ context,
165
+ isErrorStatusCode: (statusCode: number) =>
166
+ matchStatusCode({ status: statusCode } as Response, ["4XX", "5XX"]),
167
+ retryConfig: context.retryConfig,
168
+ retryCodes: context.retryCodes,
169
+ });
170
+ if (!doResult.ok) {
171
+ return [haltIterator(doResult), { status: "request-error", request: req }];
172
+ }
173
+ const response = doResult.value;
174
+
175
+ const responseFields = {
176
+ HttpMeta: { Response: response, Request: req },
177
+ };
178
+
179
+ const [result, raw] = await M.match<
180
+ operations.UsersApiListOrganizationsResponse,
181
+ | MistralError
182
+ | ResponseValidationError
183
+ | ConnectionError
184
+ | RequestAbortedError
185
+ | RequestTimeoutError
186
+ | InvalidRequestError
187
+ | UnexpectedClientError
188
+ | SDKValidationError
189
+ >(
190
+ M.json(200, operations.UsersApiListOrganizationsResponse$inboundSchema, {
191
+ key: "Result",
192
+ }),
193
+ M.fail("4XX"),
194
+ M.fail("5XX"),
195
+ )(response, req, { extraFields: responseFields });
196
+ if (!result.ok) {
197
+ return [haltIterator(result), {
198
+ status: "complete",
199
+ request: req,
200
+ response,
201
+ }];
202
+ }
203
+
204
+ const nextFunc = (
205
+ responseData: unknown,
206
+ ): {
207
+ next: Paginator<
208
+ Result<
209
+ operations.UsersApiListOrganizationsResponse,
210
+ | MistralError
211
+ | ResponseValidationError
212
+ | ConnectionError
213
+ | RequestAbortedError
214
+ | RequestTimeoutError
215
+ | InvalidRequestError
216
+ | UnexpectedClientError
217
+ | SDKValidationError
218
+ >
219
+ >;
220
+ "~next"?: { offset: number };
221
+ } => {
222
+ const offset = request?.offset ?? 0;
223
+
224
+ if (!responseData) {
225
+ return { next: () => null };
226
+ }
227
+ const results = dlv(responseData, "organizations");
228
+ if (!Array.isArray(results) || !results.length) {
229
+ return { next: () => null };
230
+ }
231
+ const limit = request?.limit ?? 100;
232
+ if (results.length < limit) {
233
+ return { next: () => null };
234
+ }
235
+ const nextOffset = offset + results.length;
236
+
237
+ const nextVal = () =>
238
+ betaUsersListOrganizations(
239
+ client,
240
+ security,
241
+ {
242
+ ...request!,
243
+ offset: nextOffset,
244
+ },
245
+ options,
246
+ );
247
+
248
+ return { next: nextVal, "~next": { offset: nextOffset } };
249
+ };
250
+
251
+ const page = { ...result, ...nextFunc(raw) };
252
+ return [{ ...page, ...createPageIterator(page, (v) => !v.ok) }, {
253
+ status: "complete",
254
+ request: req,
255
+ response,
256
+ }];
257
+ }
@@ -0,0 +1,257 @@
1
+ /*
2
+ * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
3
+ * @generated-id: 8709b463047a
4
+ */
5
+
6
+ import { MistralCore } from "../core.js";
7
+ import { dlv } from "../lib/dlv.js";
8
+ import { encodeFormQuery } from "../lib/encodings.js";
9
+ import { matchStatusCode } from "../lib/http.js";
10
+ import * as M from "../lib/matchers.js";
11
+ import { compactMap } from "../lib/primitives.js";
12
+ import { safeParse } from "../lib/schemas.js";
13
+ import { RequestOptions } from "../lib/sdks.js";
14
+ import { resolveSecurity } from "../lib/security.js";
15
+ import { pathToFunc } from "../lib/url.js";
16
+ import {
17
+ ConnectionError,
18
+ InvalidRequestError,
19
+ RequestAbortedError,
20
+ RequestTimeoutError,
21
+ UnexpectedClientError,
22
+ } from "../models/errors/httpclienterrors.js";
23
+ import { MistralError } from "../models/errors/mistralerror.js";
24
+ import { ResponseValidationError } from "../models/errors/responsevalidationerror.js";
25
+ import { SDKValidationError } from "../models/errors/sdkvalidationerror.js";
26
+ import * as operations from "../models/operations/index.js";
27
+ import { APICall, APIPromise } from "../types/async.js";
28
+ import { Result } from "../types/fp.js";
29
+ import {
30
+ createPageIterator,
31
+ haltIterator,
32
+ PageIterator,
33
+ Paginator,
34
+ } from "../types/operations.js";
35
+
36
+ /**
37
+ * List Workspaces
38
+ *
39
+ * @remarks
40
+ * List every workspace the authenticated user is a member of, across all
41
+ * their organizations, each tagged with the organization it belongs to.
42
+ */
43
+ export function betaUsersListWorkspaces(
44
+ client: MistralCore,
45
+ security: operations.UsersApiListWorkspacesSecurity,
46
+ request?: operations.UsersApiListWorkspacesRequest | undefined,
47
+ options?: RequestOptions,
48
+ ): APIPromise<
49
+ PageIterator<
50
+ Result<
51
+ operations.UsersApiListWorkspacesResponse,
52
+ | MistralError
53
+ | ResponseValidationError
54
+ | ConnectionError
55
+ | RequestAbortedError
56
+ | RequestTimeoutError
57
+ | InvalidRequestError
58
+ | UnexpectedClientError
59
+ | SDKValidationError
60
+ >,
61
+ { offset: number }
62
+ >
63
+ > {
64
+ return new APIPromise($do(
65
+ client,
66
+ security,
67
+ request,
68
+ options,
69
+ ));
70
+ }
71
+
72
+ async function $do(
73
+ client: MistralCore,
74
+ security: operations.UsersApiListWorkspacesSecurity,
75
+ request?: operations.UsersApiListWorkspacesRequest | undefined,
76
+ options?: RequestOptions,
77
+ ): Promise<
78
+ [
79
+ PageIterator<
80
+ Result<
81
+ operations.UsersApiListWorkspacesResponse,
82
+ | MistralError
83
+ | ResponseValidationError
84
+ | ConnectionError
85
+ | RequestAbortedError
86
+ | RequestTimeoutError
87
+ | InvalidRequestError
88
+ | UnexpectedClientError
89
+ | SDKValidationError
90
+ >,
91
+ { offset: number }
92
+ >,
93
+ APICall,
94
+ ]
95
+ > {
96
+ const parsed = safeParse(
97
+ request,
98
+ (value) =>
99
+ operations.UsersApiListWorkspacesRequest$outboundSchema.optional().parse(
100
+ value,
101
+ ),
102
+ "Input validation failed",
103
+ );
104
+ if (!parsed.ok) {
105
+ return [haltIterator(parsed), { status: "invalid" }];
106
+ }
107
+ const payload = parsed.value;
108
+ const body = null;
109
+
110
+ const path = pathToFunc("/v1/users/me/workspaces")();
111
+
112
+ const query = encodeFormQuery({
113
+ "limit": payload?.limit,
114
+ "offset": payload?.offset,
115
+ "organization_id": payload?.organization_id,
116
+ });
117
+
118
+ const headers = new Headers(compactMap({
119
+ Accept: "application/json",
120
+ }));
121
+
122
+ const requestSecurity = resolveSecurity(
123
+ [
124
+ {
125
+ fieldName: "x-api-key",
126
+ type: "apiKey:header",
127
+ value: security?.dashboardUserContextAuth,
128
+ },
129
+ ],
130
+ );
131
+
132
+ const context = {
133
+ options: client._options,
134
+ baseURL: options?.serverURL ?? client._baseURL ?? "",
135
+ operationID: "users_api_list_workspaces",
136
+ oAuth2Scopes: null,
137
+
138
+ resolvedSecurity: requestSecurity,
139
+
140
+ securitySource: security,
141
+ retryConfig: options?.retries
142
+ || client._options.retryConfig
143
+ || { strategy: "none" },
144
+ retryCodes: options?.retryCodes || ["429", "500", "502", "503", "504"],
145
+ };
146
+
147
+ const requestRes = client._createRequest(context, {
148
+ security: requestSecurity,
149
+ method: "GET",
150
+ baseURL: options?.serverURL,
151
+ path: path,
152
+ headers: headers,
153
+ query: query,
154
+ body: body,
155
+ userAgent: client._options.userAgent,
156
+ timeoutMs: options?.timeoutMs || client._options.timeoutMs || 300000,
157
+ }, options);
158
+ if (!requestRes.ok) {
159
+ return [haltIterator(requestRes), { status: "invalid" }];
160
+ }
161
+ const req = requestRes.value;
162
+
163
+ const doResult = await client._do(req, {
164
+ context,
165
+ isErrorStatusCode: (statusCode: number) =>
166
+ matchStatusCode({ status: statusCode } as Response, ["4XX", "5XX"]),
167
+ retryConfig: context.retryConfig,
168
+ retryCodes: context.retryCodes,
169
+ });
170
+ if (!doResult.ok) {
171
+ return [haltIterator(doResult), { status: "request-error", request: req }];
172
+ }
173
+ const response = doResult.value;
174
+
175
+ const responseFields = {
176
+ HttpMeta: { Response: response, Request: req },
177
+ };
178
+
179
+ const [result, raw] = await M.match<
180
+ operations.UsersApiListWorkspacesResponse,
181
+ | MistralError
182
+ | ResponseValidationError
183
+ | ConnectionError
184
+ | RequestAbortedError
185
+ | RequestTimeoutError
186
+ | InvalidRequestError
187
+ | UnexpectedClientError
188
+ | SDKValidationError
189
+ >(
190
+ M.json(200, operations.UsersApiListWorkspacesResponse$inboundSchema, {
191
+ key: "Result",
192
+ }),
193
+ M.fail("4XX"),
194
+ M.fail("5XX"),
195
+ )(response, req, { extraFields: responseFields });
196
+ if (!result.ok) {
197
+ return [haltIterator(result), {
198
+ status: "complete",
199
+ request: req,
200
+ response,
201
+ }];
202
+ }
203
+
204
+ const nextFunc = (
205
+ responseData: unknown,
206
+ ): {
207
+ next: Paginator<
208
+ Result<
209
+ operations.UsersApiListWorkspacesResponse,
210
+ | MistralError
211
+ | ResponseValidationError
212
+ | ConnectionError
213
+ | RequestAbortedError
214
+ | RequestTimeoutError
215
+ | InvalidRequestError
216
+ | UnexpectedClientError
217
+ | SDKValidationError
218
+ >
219
+ >;
220
+ "~next"?: { offset: number };
221
+ } => {
222
+ const offset = request?.offset ?? 0;
223
+
224
+ if (!responseData) {
225
+ return { next: () => null };
226
+ }
227
+ const results = dlv(responseData, "workspaces");
228
+ if (!Array.isArray(results) || !results.length) {
229
+ return { next: () => null };
230
+ }
231
+ const limit = request?.limit ?? 100;
232
+ if (results.length < limit) {
233
+ return { next: () => null };
234
+ }
235
+ const nextOffset = offset + results.length;
236
+
237
+ const nextVal = () =>
238
+ betaUsersListWorkspaces(
239
+ client,
240
+ security,
241
+ {
242
+ ...request!,
243
+ offset: nextOffset,
244
+ },
245
+ options,
246
+ );
247
+
248
+ return { next: nextVal, "~next": { offset: nextOffset } };
249
+ };
250
+
251
+ const page = { ...result, ...nextFunc(raw) };
252
+ return [{ ...page, ...createPageIterator(page, (v) => !v.ok) }, {
253
+ status: "complete",
254
+ request: req,
255
+ response,
256
+ }];
257
+ }
@@ -0,0 +1,170 @@
1
+ /*
2
+ * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
3
+ * @generated-id: 7d77adefc594
4
+ */
5
+
6
+ import { MistralCore } from "../core.js";
7
+ import { encodeJSON } from "../lib/encodings.js";
8
+ import { matchStatusCode } from "../lib/http.js";
9
+ import * as M from "../lib/matchers.js";
10
+ import { compactMap } from "../lib/primitives.js";
11
+ import { safeParse } from "../lib/schemas.js";
12
+ import { RequestOptions } from "../lib/sdks.js";
13
+ import { extractSecurity, resolveGlobalSecurity } from "../lib/security.js";
14
+ import { pathToFunc } from "../lib/url.js";
15
+ import * as components from "../models/components/index.js";
16
+ import {
17
+ ConnectionError,
18
+ InvalidRequestError,
19
+ RequestAbortedError,
20
+ RequestTimeoutError,
21
+ UnexpectedClientError,
22
+ } from "../models/errors/httpclienterrors.js";
23
+ import * as errors from "../models/errors/index.js";
24
+ import { MistralError } from "../models/errors/mistralerror.js";
25
+ import { ResponseValidationError } from "../models/errors/responsevalidationerror.js";
26
+ import { SDKValidationError } from "../models/errors/sdkvalidationerror.js";
27
+ import * as operations from "../models/operations/index.js";
28
+ import { APICall, APIPromise } from "../types/async.js";
29
+ import { Result } from "../types/fp.js";
30
+
31
+ /**
32
+ * Create Client Session
33
+ */
34
+ export function realtimeSessionsCreate(
35
+ client: MistralCore,
36
+ request: operations.Body,
37
+ options?: RequestOptions,
38
+ ): APIPromise<
39
+ Result<
40
+ components.CreateRealtimeSessionResponse,
41
+ | errors.HTTPValidationError
42
+ | MistralError
43
+ | ResponseValidationError
44
+ | ConnectionError
45
+ | RequestAbortedError
46
+ | RequestTimeoutError
47
+ | InvalidRequestError
48
+ | UnexpectedClientError
49
+ | SDKValidationError
50
+ >
51
+ > {
52
+ return new APIPromise($do(
53
+ client,
54
+ request,
55
+ options,
56
+ ));
57
+ }
58
+
59
+ async function $do(
60
+ client: MistralCore,
61
+ request: operations.Body,
62
+ options?: RequestOptions,
63
+ ): Promise<
64
+ [
65
+ Result<
66
+ components.CreateRealtimeSessionResponse,
67
+ | errors.HTTPValidationError
68
+ | MistralError
69
+ | ResponseValidationError
70
+ | ConnectionError
71
+ | RequestAbortedError
72
+ | RequestTimeoutError
73
+ | InvalidRequestError
74
+ | UnexpectedClientError
75
+ | SDKValidationError
76
+ >,
77
+ APICall,
78
+ ]
79
+ > {
80
+ const parsed = safeParse(
81
+ request,
82
+ (value) => operations.Body$outboundSchema.parse(value),
83
+ "Input validation failed",
84
+ );
85
+ if (!parsed.ok) {
86
+ return [parsed, { status: "invalid" }];
87
+ }
88
+ const payload = parsed.value;
89
+ const body = encodeJSON("body", payload, { explode: true });
90
+
91
+ const path = pathToFunc("/v1/client/sessions")();
92
+
93
+ const headers = new Headers(compactMap({
94
+ "Content-Type": "application/json",
95
+ Accept: "application/json",
96
+ }));
97
+
98
+ const secConfig = await extractSecurity(client._options.apiKey);
99
+ const securityInput = secConfig == null ? {} : { apiKey: secConfig };
100
+ const requestSecurity = resolveGlobalSecurity(securityInput);
101
+
102
+ const context = {
103
+ options: client._options,
104
+ baseURL: options?.serverURL ?? client._baseURL ?? "",
105
+ operationID: "create_client_session_v1_client_sessions_post",
106
+ oAuth2Scopes: null,
107
+
108
+ resolvedSecurity: requestSecurity,
109
+
110
+ securitySource: client._options.apiKey,
111
+ retryConfig: options?.retries
112
+ || client._options.retryConfig
113
+ || { strategy: "none" },
114
+ retryCodes: options?.retryCodes || ["429", "500", "502", "503", "504"],
115
+ };
116
+
117
+ const requestRes = client._createRequest(context, {
118
+ security: requestSecurity,
119
+ method: "POST",
120
+ baseURL: options?.serverURL,
121
+ path: path,
122
+ headers: headers,
123
+ body: body,
124
+ userAgent: client._options.userAgent,
125
+ timeoutMs: options?.timeoutMs || client._options.timeoutMs || 300000,
126
+ }, options);
127
+ if (!requestRes.ok) {
128
+ return [requestRes, { status: "invalid" }];
129
+ }
130
+ const req = requestRes.value;
131
+
132
+ const doResult = await client._do(req, {
133
+ context,
134
+ isErrorStatusCode: (statusCode: number) =>
135
+ matchStatusCode({ status: statusCode } as Response, ["4XX", "5XX"]),
136
+ retryConfig: context.retryConfig,
137
+ retryCodes: context.retryCodes,
138
+ });
139
+ if (!doResult.ok) {
140
+ return [doResult, { status: "request-error", request: req }];
141
+ }
142
+ const response = doResult.value;
143
+
144
+ const responseFields = {
145
+ HttpMeta: { Response: response, Request: req },
146
+ };
147
+
148
+ const [result] = await M.match<
149
+ components.CreateRealtimeSessionResponse,
150
+ | errors.HTTPValidationError
151
+ | MistralError
152
+ | ResponseValidationError
153
+ | ConnectionError
154
+ | RequestAbortedError
155
+ | RequestTimeoutError
156
+ | InvalidRequestError
157
+ | UnexpectedClientError
158
+ | SDKValidationError
159
+ >(
160
+ M.json(201, components.CreateRealtimeSessionResponse$inboundSchema),
161
+ M.jsonErr(422, errors.HTTPValidationError$inboundSchema),
162
+ M.fail("4XX"),
163
+ M.fail("5XX"),
164
+ )(response, req, { extraFields: responseFields });
165
+ if (!result.ok) {
166
+ return [result, { status: "complete", request: req, response }];
167
+ }
168
+
169
+ return [result, { status: "complete", request: req, response }];
170
+ }