-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathusers.ts
194 lines (164 loc) · 5.02 KB
/
users.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
import { APIResource } from '../../../resource';
import * as Core from '../../../core';
import * as MetamessagesAPI from './metamessages';
import { MetamessageListParams, Metamessages } from './metamessages';
import * as CollectionsAPI from './collections/collections';
import {
Collection,
CollectionCreateParams,
CollectionDeleteResponse,
CollectionListParams,
CollectionUpdateParams,
Collections,
CollectionsPage,
PageCollection,
} from './collections/collections';
import * as SessionsAPI from './sessions/sessions';
import {
AgentChat,
PageSession,
Session,
SessionChatParams,
SessionCloneParams,
SessionCreateParams,
SessionDeleteResponse,
SessionListParams,
SessionStreamParams,
SessionStreamResponse,
SessionUpdateParams,
Sessions,
SessionsPage,
} from './sessions/sessions';
import { Page, type PageParams } from '../../../pagination';
export class Users extends APIResource {
metamessages: MetamessagesAPI.Metamessages = new MetamessagesAPI.Metamessages(this._client);
sessions: SessionsAPI.Sessions = new SessionsAPI.Sessions(this._client);
collections: CollectionsAPI.Collections = new CollectionsAPI.Collections(this._client);
/**
* Create a new User
*/
create(appId: string, body: UserCreateParams, options?: Core.RequestOptions): Core.APIPromise<User> {
return this._client.post(`/v1/apps/${appId}/users`, { body, ...options });
}
/**
* Update a User's name and/or metadata
*/
update(
appId: string,
userId: string,
body: UserUpdateParams,
options?: Core.RequestOptions,
): Core.APIPromise<User> {
return this._client.put(`/v1/apps/${appId}/users/${userId}`, { body, ...options });
}
/**
* Get All Users for an App
*/
list(
appId: string,
params: UserListParams,
options?: Core.RequestOptions,
): Core.PagePromise<UsersPage, User> {
const { page, reverse, size, ...body } = params;
return this._client.getAPIList(`/v1/apps/${appId}/users/list`, UsersPage, {
query: { page, reverse, size },
body,
method: 'post',
...options,
});
}
/**
* Get a User by ID
*/
get(appId: string, userId: string, options?: Core.RequestOptions): Core.APIPromise<User> {
return this._client.get(`/v1/apps/${appId}/users/${userId}`, options);
}
/**
* Get a User by name
*/
getByName(appId: string, name: string, options?: Core.RequestOptions): Core.APIPromise<User> {
return this._client.get(`/v1/apps/${appId}/users/name/${name}`, options);
}
/**
* Get a User or create a new one by the input name
*/
getOrCreate(appId: string, name: string, options?: Core.RequestOptions): Core.APIPromise<User> {
return this._client.get(`/v1/apps/${appId}/users/get_or_create/${name}`, options);
}
}
export class UsersPage extends Page<User> {}
export interface PageUser {
items: Array<User>;
page: number;
size: number;
total: number;
pages?: number;
}
export interface User {
id: string;
app_id: string;
created_at: string;
metadata: Record<string, unknown>;
name: string;
}
export interface UserCreateParams {
name: string;
metadata?: Record<string, unknown>;
}
export interface UserUpdateParams {
metadata?: Record<string, unknown> | null;
name?: string | null;
}
export interface UserListParams extends PageParams {
/**
* Query param:
*/
reverse?: boolean;
/**
* Body param:
*/
filter?: Record<string, unknown> | null;
}
Users.UsersPage = UsersPage;
Users.Metamessages = Metamessages;
Users.Sessions = Sessions;
Users.SessionsPage = SessionsPage;
Users.Collections = Collections;
Users.CollectionsPage = CollectionsPage;
export declare namespace Users {
export {
type PageUser as PageUser,
type User as User,
UsersPage as UsersPage,
type UserCreateParams as UserCreateParams,
type UserUpdateParams as UserUpdateParams,
type UserListParams as UserListParams,
};
export { Metamessages as Metamessages, type MetamessageListParams as MetamessageListParams };
export {
Sessions as Sessions,
type AgentChat as AgentChat,
type PageSession as PageSession,
type Session as Session,
type SessionDeleteResponse as SessionDeleteResponse,
type SessionStreamResponse as SessionStreamResponse,
SessionsPage as SessionsPage,
type SessionCreateParams as SessionCreateParams,
type SessionUpdateParams as SessionUpdateParams,
type SessionListParams as SessionListParams,
type SessionChatParams as SessionChatParams,
type SessionCloneParams as SessionCloneParams,
type SessionStreamParams as SessionStreamParams,
};
export {
Collections as Collections,
type Collection as Collection,
type PageCollection as PageCollection,
type CollectionDeleteResponse as CollectionDeleteResponse,
CollectionsPage as CollectionsPage,
type CollectionCreateParams as CollectionCreateParams,
type CollectionUpdateParams as CollectionUpdateParams,
type CollectionListParams as CollectionListParams,
};
}