@turinhub/tale-js-sdk 1.3.0

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 (59) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +56 -0
  3. package/dist/acl/index.d.ts +295 -0
  4. package/dist/acl/index.js +653 -0
  5. package/dist/acl/types.d.ts +142 -0
  6. package/dist/acl/types.js +1 -0
  7. package/dist/auth/index.d.ts +166 -0
  8. package/dist/auth/index.js +522 -0
  9. package/dist/auth/types.d.ts +127 -0
  10. package/dist/auth/types.js +1 -0
  11. package/dist/cms/file.d.ts +398 -0
  12. package/dist/cms/file.js +800 -0
  13. package/dist/cms/folder.d.ts +128 -0
  14. package/dist/cms/folder.js +294 -0
  15. package/dist/cms/index.d.ts +3 -0
  16. package/dist/cms/index.js +6 -0
  17. package/dist/cms/types.d.ts +157 -0
  18. package/dist/cms/types.js +1 -0
  19. package/dist/common/types.d.ts +91 -0
  20. package/dist/common/types.js +2 -0
  21. package/dist/errors.d.ts +52 -0
  22. package/dist/errors.js +109 -0
  23. package/dist/index.d.ts +13 -0
  24. package/dist/index.js +12 -0
  25. package/dist/rbac/acl.d.ts +152 -0
  26. package/dist/rbac/acl.js +723 -0
  27. package/dist/rbac/index.d.ts +464 -0
  28. package/dist/rbac/index.js +1121 -0
  29. package/dist/rbac/rbac.d.ts +198 -0
  30. package/dist/rbac/rbac.js +984 -0
  31. package/dist/rbac/types.d.ts +125 -0
  32. package/dist/rbac/types.js +1 -0
  33. package/dist/rbac/user-group.d.ts +122 -0
  34. package/dist/rbac/user-group.js +570 -0
  35. package/dist/status.d.ts +40 -0
  36. package/dist/status.js +56 -0
  37. package/dist/task/index.d.ts +163 -0
  38. package/dist/task/index.js +495 -0
  39. package/dist/task/types.d.ts +116 -0
  40. package/dist/task/types.js +1 -0
  41. package/dist/task-type/index.d.ts +92 -0
  42. package/dist/task-type/index.js +256 -0
  43. package/dist/task-type/types.d.ts +54 -0
  44. package/dist/task-type/types.js +1 -0
  45. package/dist/token.d.ts +21 -0
  46. package/dist/token.js +114 -0
  47. package/dist/user/index.d.ts +267 -0
  48. package/dist/user/index.js +786 -0
  49. package/dist/user/types.d.ts +145 -0
  50. package/dist/user/types.js +1 -0
  51. package/dist/user-attribute/index.d.ts +186 -0
  52. package/dist/user-attribute/index.js +615 -0
  53. package/dist/user-attribute/types.d.ts +109 -0
  54. package/dist/user-attribute/types.js +1 -0
  55. package/dist/user-group/index.d.ts +231 -0
  56. package/dist/user-group/index.js +566 -0
  57. package/dist/user-group/types.d.ts +50 -0
  58. package/dist/user-group/types.js +1 -0
  59. package/package.json +50 -0
@@ -0,0 +1,128 @@
1
+ import type { PageResponse } from "../common/types.js";
2
+ import type { Folder, CreateFolderRequest, UpdateFolderRequest, FolderOptions, ListFoldersRequest } from "./types.js";
3
+ /**
4
+ * Gets a folder by ID.
5
+ *
6
+ * @param folderId - Folder ID (UUID)
7
+ * @param options - Optional configuration
8
+ * @returns Promise resolving to folder information
9
+ * @throws {ConfigurationError} When required environment variables are missing
10
+ * @throws {ApiError} When API request fails
11
+ * @throws {NetworkError} When network request fails
12
+ *
13
+ * @example
14
+ * ```typescript
15
+ * import { getFolder } from '@tale/client';
16
+ *
17
+ * try {
18
+ * const folder = await getFolder('folder_id_here');
19
+ * console.log('Folder name:', folder.folder_name);
20
+ * } catch (error) {
21
+ * console.error('Failed to get folder:', error.message);
22
+ * }
23
+ * ```
24
+ */
25
+ export declare function getFolder(folderId: string, options?: FolderOptions): Promise<Folder>;
26
+ /**
27
+ * Lists folders with pagination.
28
+ *
29
+ * @param options - Optional parameters for pagination
30
+ * @returns Promise resolving to paginated folder list
31
+ * @throws {ConfigurationError} When required environment variables are missing
32
+ * @throws {ApiError} When API request fails
33
+ * @throws {NetworkError} When network request fails
34
+ *
35
+ * @example
36
+ * ```typescript
37
+ * import { listFolders } from '@tale/client';
38
+ *
39
+ * try {
40
+ * const result = await listFolders({
41
+ * page: 0,
42
+ * size: 20,
43
+ * sort_by: 'createdAt'
44
+ * });
45
+ * console.log(`Found ${result.total} folders`);
46
+ * } catch (error) {
47
+ * console.error('Failed to list folders:', error.message);
48
+ * }
49
+ * ```
50
+ */
51
+ export declare function listFolders(options?: ListFoldersRequest & FolderOptions): Promise<PageResponse<Folder>>;
52
+ /**
53
+ * Creates a new folder.
54
+ *
55
+ * @param request - Folder creation request
56
+ * @param options - Optional configuration
57
+ * @returns Promise resolving to created folder
58
+ * @throws {ConfigurationError} When required environment variables are missing
59
+ * @throws {ApiError} When API request fails
60
+ * @throws {NetworkError} When network request fails
61
+ *
62
+ * @example
63
+ * ```typescript
64
+ * import { createFolder } from '@tale/client';
65
+ *
66
+ * try {
67
+ * const folder = await createFolder({
68
+ * folder_name: 'Images',
69
+ * folder_type: ['IMAGE', 'VIDEO'],
70
+ * remark: 'Image and video files'
71
+ * });
72
+ * console.log('Folder created:', folder.id);
73
+ * } catch (error) {
74
+ * console.error('Failed to create folder:', error.message);
75
+ * }
76
+ * ```
77
+ */
78
+ export declare function createFolder(request: CreateFolderRequest, options?: FolderOptions): Promise<Folder>;
79
+ /**
80
+ * Updates an existing folder.
81
+ *
82
+ * @param folderId - Folder ID to update
83
+ * @param request - Update request with fields to modify
84
+ * @param options - Optional configuration
85
+ * @returns Promise resolving to updated folder
86
+ * @throws {ConfigurationError} When required environment variables are missing
87
+ * @throws {ApiError} When API request fails
88
+ * @throws {NetworkError} When network request fails
89
+ *
90
+ * @example
91
+ * ```typescript
92
+ * import { updateFolder } from '@tale/client';
93
+ *
94
+ * try {
95
+ * const folder = await updateFolder('folder_id_here', {
96
+ * folder_name: 'Updated Name',
97
+ * remark: 'Updated remark'
98
+ * });
99
+ * console.log('Folder updated:', folder.folder_name);
100
+ * } catch (error) {
101
+ * console.error('Failed to update folder:', error.message);
102
+ * }
103
+ * ```
104
+ */
105
+ export declare function updateFolder(folderId: string, request: UpdateFolderRequest, options?: FolderOptions): Promise<Folder>;
106
+ /**
107
+ * Deletes a folder.
108
+ *
109
+ * @param folderId - Folder ID to delete
110
+ * @param options - Optional configuration
111
+ * @returns Promise that resolves when deletion is successful
112
+ * @throws {ConfigurationError} When required environment variables are missing
113
+ * @throws {ApiError} When API request fails
114
+ * @throws {NetworkError} When network request fails
115
+ *
116
+ * @example
117
+ * ```typescript
118
+ * import { deleteFolder } from '@tale/client';
119
+ *
120
+ * try {
121
+ * await deleteFolder('folder_id_here');
122
+ * console.log('Folder deleted successfully');
123
+ * } catch (error) {
124
+ * console.error('Failed to delete folder:', error.message);
125
+ * }
126
+ * ```
127
+ */
128
+ export declare function deleteFolder(folderId: string, options?: FolderOptions): Promise<void>;
@@ -0,0 +1,294 @@
1
+ import { getAppToken } from "../token.js";
2
+ import { ApiError, ConfigurationError, NetworkError } from "../errors.js";
3
+ // ==================== Helper Functions ====================
4
+ /**
5
+ * Parses standard API response format: { code, msg, data }
6
+ */
7
+ function parseApiResponse(json, errorMessage, statusCode) {
8
+ if (typeof json !== "object" || json === null) {
9
+ throw new ApiError(`Invalid response: ${errorMessage} - not an object`, statusCode);
10
+ }
11
+ const response = json;
12
+ if (response.code !== 200) {
13
+ const errorMsg = typeof response.msg === "string" ? response.msg : errorMessage;
14
+ throw new ApiError(errorMsg, statusCode, response.code);
15
+ }
16
+ if (!response.data) {
17
+ throw new ApiError(`Invalid response: ${errorMessage} - missing data`, statusCode);
18
+ }
19
+ return response.data;
20
+ }
21
+ // ==================== Folder API Functions ====================
22
+ /**
23
+ * Gets a folder by ID.
24
+ *
25
+ * @param folderId - Folder ID (UUID)
26
+ * @param options - Optional configuration
27
+ * @returns Promise resolving to folder information
28
+ * @throws {ConfigurationError} When required environment variables are missing
29
+ * @throws {ApiError} When API request fails
30
+ * @throws {NetworkError} When network request fails
31
+ *
32
+ * @example
33
+ * ```typescript
34
+ * import { getFolder } from '@tale/client';
35
+ *
36
+ * try {
37
+ * const folder = await getFolder('folder_id_here');
38
+ * console.log('Folder name:', folder.folder_name);
39
+ * } catch (error) {
40
+ * console.error('Failed to get folder:', error.message);
41
+ * }
42
+ * ```
43
+ */
44
+ export async function getFolder(folderId, options) {
45
+ if (!folderId || folderId.trim() === "") {
46
+ throw new ApiError("folderId is required", 400, "9400");
47
+ }
48
+ const token = options?.appToken ?? (await getAppToken(options));
49
+ const env = globalThis?.process?.env ?? import.meta?.env ?? undefined;
50
+ const base = options?.baseUrl ?? env?.TALE_BASE_URL ?? undefined;
51
+ if (!base) {
52
+ throw new ConfigurationError("Missing required environment variable: TALE_BASE_URL");
53
+ }
54
+ const url = String(base).replace(/\/+$/, "") +
55
+ `/cms/v1/folders/${encodeURIComponent(folderId)}`;
56
+ let response;
57
+ try {
58
+ response = await globalThis.fetch(url, {
59
+ method: "GET",
60
+ headers: {
61
+ "Content-Type": "application/json",
62
+ "x-t-token": token,
63
+ },
64
+ });
65
+ }
66
+ catch (error) {
67
+ throw new NetworkError(`Failed to get folder: ${error instanceof Error ? error.message : "Unknown error"}`);
68
+ }
69
+ const json = await response.json();
70
+ return parseApiResponse(json, "Failed to get folder", response.status);
71
+ }
72
+ /**
73
+ * Lists folders with pagination.
74
+ *
75
+ * @param options - Optional parameters for pagination
76
+ * @returns Promise resolving to paginated folder list
77
+ * @throws {ConfigurationError} When required environment variables are missing
78
+ * @throws {ApiError} When API request fails
79
+ * @throws {NetworkError} When network request fails
80
+ *
81
+ * @example
82
+ * ```typescript
83
+ * import { listFolders } from '@tale/client';
84
+ *
85
+ * try {
86
+ * const result = await listFolders({
87
+ * page: 0,
88
+ * size: 20,
89
+ * sort_by: 'createdAt'
90
+ * });
91
+ * console.log(`Found ${result.total} folders`);
92
+ * } catch (error) {
93
+ * console.error('Failed to list folders:', error.message);
94
+ * }
95
+ * ```
96
+ */
97
+ export async function listFolders(options) {
98
+ const token = options?.appToken ?? (await getAppToken(options));
99
+ const env = globalThis?.process?.env ?? import.meta?.env ?? undefined;
100
+ const base = options?.baseUrl ?? env?.TALE_BASE_URL ?? undefined;
101
+ if (!base) {
102
+ throw new ConfigurationError("Missing required environment variable: TALE_BASE_URL");
103
+ }
104
+ const url = new URL(String(base).replace(/\/+$/, "") + "/cms/v1/folders");
105
+ const { appToken, baseUrl, ...requestParams } = options || {};
106
+ const queryParams = {
107
+ page: 0,
108
+ size: 10,
109
+ sort_by: "createdAt",
110
+ ...requestParams,
111
+ };
112
+ Object.entries(queryParams).forEach(([key, value]) => {
113
+ if (value !== undefined) {
114
+ url.searchParams.append(key, String(value));
115
+ }
116
+ });
117
+ let response;
118
+ try {
119
+ response = await globalThis.fetch(url.toString(), {
120
+ method: "GET",
121
+ headers: {
122
+ "Content-Type": "application/json",
123
+ "x-t-token": token,
124
+ },
125
+ });
126
+ }
127
+ catch (error) {
128
+ throw new NetworkError(`Failed to list folders: ${error instanceof Error ? error.message : "Unknown error"}`);
129
+ }
130
+ const json = await response.json();
131
+ return parseApiResponse(json, "Failed to list folders", response.status);
132
+ }
133
+ /**
134
+ * Creates a new folder.
135
+ *
136
+ * @param request - Folder creation request
137
+ * @param options - Optional configuration
138
+ * @returns Promise resolving to created folder
139
+ * @throws {ConfigurationError} When required environment variables are missing
140
+ * @throws {ApiError} When API request fails
141
+ * @throws {NetworkError} When network request fails
142
+ *
143
+ * @example
144
+ * ```typescript
145
+ * import { createFolder } from '@tale/client';
146
+ *
147
+ * try {
148
+ * const folder = await createFolder({
149
+ * folder_name: 'Images',
150
+ * folder_type: ['IMAGE', 'VIDEO'],
151
+ * remark: 'Image and video files'
152
+ * });
153
+ * console.log('Folder created:', folder.id);
154
+ * } catch (error) {
155
+ * console.error('Failed to create folder:', error.message);
156
+ * }
157
+ * ```
158
+ */
159
+ export async function createFolder(request, options) {
160
+ if (!request.folder_name || request.folder_name.trim() === "") {
161
+ throw new ApiError("folder_name is required", 400, "9400");
162
+ }
163
+ const token = options?.appToken ?? (await getAppToken(options));
164
+ const env = globalThis?.process?.env ?? import.meta?.env ?? undefined;
165
+ const base = options?.baseUrl ?? env?.TALE_BASE_URL ?? undefined;
166
+ if (!base) {
167
+ throw new ConfigurationError("Missing required environment variable: TALE_BASE_URL");
168
+ }
169
+ const url = String(base).replace(/\/+$/, "") + "/cms/v1/folders";
170
+ let response;
171
+ try {
172
+ response = await globalThis.fetch(url, {
173
+ method: "POST",
174
+ headers: {
175
+ "Content-Type": "application/json",
176
+ "x-t-token": token,
177
+ },
178
+ body: JSON.stringify(request),
179
+ });
180
+ }
181
+ catch (error) {
182
+ throw new NetworkError(`Failed to create folder: ${error instanceof Error ? error.message : "Unknown error"}`);
183
+ }
184
+ const json = await response.json();
185
+ return parseApiResponse(json, "Failed to create folder", response.status);
186
+ }
187
+ /**
188
+ * Updates an existing folder.
189
+ *
190
+ * @param folderId - Folder ID to update
191
+ * @param request - Update request with fields to modify
192
+ * @param options - Optional configuration
193
+ * @returns Promise resolving to updated folder
194
+ * @throws {ConfigurationError} When required environment variables are missing
195
+ * @throws {ApiError} When API request fails
196
+ * @throws {NetworkError} When network request fails
197
+ *
198
+ * @example
199
+ * ```typescript
200
+ * import { updateFolder } from '@tale/client';
201
+ *
202
+ * try {
203
+ * const folder = await updateFolder('folder_id_here', {
204
+ * folder_name: 'Updated Name',
205
+ * remark: 'Updated remark'
206
+ * });
207
+ * console.log('Folder updated:', folder.folder_name);
208
+ * } catch (error) {
209
+ * console.error('Failed to update folder:', error.message);
210
+ * }
211
+ * ```
212
+ */
213
+ export async function updateFolder(folderId, request, options) {
214
+ if (!folderId || folderId.trim() === "") {
215
+ throw new ApiError("folderId is required", 400, "9400");
216
+ }
217
+ const token = options?.appToken ?? (await getAppToken(options));
218
+ const env = globalThis?.process?.env ?? import.meta?.env ?? undefined;
219
+ const base = options?.baseUrl ?? env?.TALE_BASE_URL ?? undefined;
220
+ if (!base) {
221
+ throw new ConfigurationError("Missing required environment variable: TALE_BASE_URL");
222
+ }
223
+ const url = String(base).replace(/\/+$/, "") +
224
+ `/cms/v1/folders/${encodeURIComponent(folderId)}`;
225
+ let response;
226
+ try {
227
+ response = await globalThis.fetch(url, {
228
+ method: "PUT",
229
+ headers: {
230
+ "Content-Type": "application/json",
231
+ "x-t-token": token,
232
+ },
233
+ body: JSON.stringify(request),
234
+ });
235
+ }
236
+ catch (error) {
237
+ throw new NetworkError(`Failed to update folder: ${error instanceof Error ? error.message : "Unknown error"}`);
238
+ }
239
+ const json = await response.json();
240
+ return parseApiResponse(json, "Failed to update folder", response.status);
241
+ }
242
+ /**
243
+ * Deletes a folder.
244
+ *
245
+ * @param folderId - Folder ID to delete
246
+ * @param options - Optional configuration
247
+ * @returns Promise that resolves when deletion is successful
248
+ * @throws {ConfigurationError} When required environment variables are missing
249
+ * @throws {ApiError} When API request fails
250
+ * @throws {NetworkError} When network request fails
251
+ *
252
+ * @example
253
+ * ```typescript
254
+ * import { deleteFolder } from '@tale/client';
255
+ *
256
+ * try {
257
+ * await deleteFolder('folder_id_here');
258
+ * console.log('Folder deleted successfully');
259
+ * } catch (error) {
260
+ * console.error('Failed to delete folder:', error.message);
261
+ * }
262
+ * ```
263
+ */
264
+ export async function deleteFolder(folderId, options) {
265
+ if (!folderId || folderId.trim() === "") {
266
+ throw new ApiError("folderId is required", 400, "9400");
267
+ }
268
+ const token = options?.appToken ?? (await getAppToken(options));
269
+ const env = globalThis?.process?.env ?? import.meta?.env ?? undefined;
270
+ const base = options?.baseUrl ?? env?.TALE_BASE_URL ?? undefined;
271
+ if (!base) {
272
+ throw new ConfigurationError("Missing required environment variable: TALE_BASE_URL");
273
+ }
274
+ const url = String(base).replace(/\/+$/, "") +
275
+ `/cms/v1/folders/${encodeURIComponent(folderId)}`;
276
+ let response;
277
+ try {
278
+ response = await globalThis.fetch(url, {
279
+ method: "DELETE",
280
+ headers: {
281
+ "Content-Type": "application/json",
282
+ "x-t-token": token,
283
+ },
284
+ });
285
+ }
286
+ catch (error) {
287
+ throw new NetworkError(`Failed to delete folder: ${error instanceof Error ? error.message : "Unknown error"}`);
288
+ }
289
+ const json = (await response.json());
290
+ if (json.code !== 200) {
291
+ const errorMsg = typeof json.msg === "string" ? json.msg : "Failed to delete folder";
292
+ throw new ApiError(errorMsg, response.status, json.code);
293
+ }
294
+ }
@@ -0,0 +1,3 @@
1
+ export * from "./folder.js";
2
+ export * from "./file.js";
3
+ export * from "./types.js";
@@ -0,0 +1,6 @@
1
+ // ==================== Folder API ====================
2
+ export * from "./folder.js";
3
+ // ==================== File API ====================
4
+ export * from "./file.js";
5
+ // ==================== Types ====================
6
+ export * from "./types.js";
@@ -0,0 +1,157 @@
1
+ import type { CommonOptions } from "../common/types.js";
2
+ /**
3
+ * File type enumeration
4
+ */
5
+ export type FileType = "IMAGE" | "LINK" | "MARKDOWN" | "PDF" | "DOC" | "VIDEO" | "AUDIO" | "ZIP" | "OTHER";
6
+ /**
7
+ * Folder information
8
+ */
9
+ export interface Folder {
10
+ /** Folder ID (UUID) */
11
+ id: string;
12
+ /** Application key */
13
+ app_key: string;
14
+ /** Folder name */
15
+ folder_name: string;
16
+ /** Folder types (array of file types allowed in this folder) */
17
+ folder_type: FileType[];
18
+ /** Folder attributes (custom metadata) */
19
+ folder_attr: Record<string, unknown> | null;
20
+ /** Remark/note */
21
+ remark: string | null;
22
+ /** Creation timestamp */
23
+ created_at: string;
24
+ /** Last update timestamp */
25
+ updated_at: string;
26
+ }
27
+ /**
28
+ * Request to create a folder
29
+ */
30
+ export interface CreateFolderRequest {
31
+ /** Folder name (required) */
32
+ folder_name: string;
33
+ /** Folder types (optional) */
34
+ folder_type?: FileType[];
35
+ /** Folder attributes (optional) */
36
+ folder_attr?: Record<string, unknown>;
37
+ /** Remark (optional) */
38
+ remark?: string;
39
+ }
40
+ /**
41
+ * Request to update a folder
42
+ */
43
+ export interface UpdateFolderRequest {
44
+ /** Folder name (optional) */
45
+ folder_name?: string;
46
+ /** Folder types (optional) */
47
+ folder_type?: FileType[];
48
+ /** Folder attributes (optional) */
49
+ folder_attr?: Record<string, unknown>;
50
+ /** Remark (optional) */
51
+ remark?: string;
52
+ }
53
+ /**
54
+ * Options for folder operations
55
+ */
56
+ export interface FolderOptions extends CommonOptions {
57
+ }
58
+ /**
59
+ * Options for file operations
60
+ */
61
+ export interface FileOptions extends CommonOptions {
62
+ }
63
+ /**
64
+ * Request to list folders with pagination
65
+ */
66
+ export interface ListFoldersRequest {
67
+ /** Page number (0-based, default: 0) */
68
+ page?: number;
69
+ /** Page size (default: 10) */
70
+ size?: number;
71
+ /** Sort field (default: "createdAt") */
72
+ sort_by?: string;
73
+ }
74
+ /**
75
+ * File information
76
+ */
77
+ export interface File {
78
+ /** File ID (UUID) */
79
+ id: string;
80
+ /** Application key */
81
+ app_key: string;
82
+ /** Folder ID (UUID) */
83
+ folder_id: string;
84
+ /** File name */
85
+ file_name: string;
86
+ /** File type */
87
+ file_type: FileType;
88
+ /** File attributes (custom metadata) */
89
+ file_attr: Record<string, unknown> | null;
90
+ /** Link URL (for LINK type files) */
91
+ link_url: string | null;
92
+ /** OSS URL (for uploaded files) */
93
+ oss_url: string | null;
94
+ /** Content (for MARKDOWN type files) */
95
+ content: string | null;
96
+ /** Remark/note */
97
+ remark: string | null;
98
+ /** Preview image URL (presigned) */
99
+ preview_image_url: string | null;
100
+ /** Creation timestamp */
101
+ created_at: string;
102
+ /** Last update timestamp */
103
+ updated_at: string;
104
+ }
105
+ /**
106
+ * Request to create a file
107
+ */
108
+ export interface CreateFileRequest {
109
+ /** Folder ID (UUID, required) */
110
+ folder_id: string;
111
+ /** File name (required) */
112
+ file_name: string;
113
+ /** File type (required) */
114
+ file_type: FileType;
115
+ /** File attributes (optional) */
116
+ file_attr?: Record<string, unknown>;
117
+ /** Link URL (for LINK type, optional) */
118
+ link_url?: string;
119
+ /** Content (for MARKDOWN type, optional) */
120
+ content?: string;
121
+ /** Remark (optional) */
122
+ remark?: string;
123
+ }
124
+ /**
125
+ * Request to update a file
126
+ */
127
+ export interface UpdateFileRequest {
128
+ /** Folder ID (optional) */
129
+ folder_id?: string;
130
+ /** File name (optional) */
131
+ file_name?: string;
132
+ /** File type (optional) */
133
+ file_type?: FileType;
134
+ /** File attributes (optional) */
135
+ file_attr?: Record<string, unknown>;
136
+ /** Link URL (optional) */
137
+ link_url?: string;
138
+ /** Content (optional) */
139
+ content?: string;
140
+ /** Remark (optional) */
141
+ remark?: string;
142
+ }
143
+ /**
144
+ * Request to list files with pagination
145
+ */
146
+ export interface ListFilesRequest {
147
+ /** Folder ID (optional, filters by folder if provided) */
148
+ folder_id?: string;
149
+ /** Page number (0-based, default: 0) */
150
+ page?: number;
151
+ /** Page size (default: 10) */
152
+ size?: number;
153
+ /** Sort field (default: "createdAt") */
154
+ sort_by?: string;
155
+ /** Include attachments in response (default: false) */
156
+ include_attachments?: boolean;
157
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,91 @@
1
+ export interface CommonOptions {
2
+ baseUrl?: string;
3
+ appToken?: string;
4
+ }
5
+ /**
6
+ * Pagination response format used by Tale backend
7
+ *
8
+ * This matches the actual backend response format with simplified pagination metadata
9
+ */
10
+ export interface PageResponse<T> {
11
+ /** Page content */
12
+ content: T[];
13
+ /** Total number of elements across all pages */
14
+ total: number;
15
+ /** Pagination information */
16
+ pageable: {
17
+ /** Current page number (0-based) */
18
+ pageNumber: number;
19
+ /** Page size */
20
+ pageSize: number;
21
+ /** Sort information */
22
+ sort?: {
23
+ orders?: Array<{
24
+ direction: "ASC" | "DESC";
25
+ property: string;
26
+ ignoreCase: boolean;
27
+ nullHandling: string;
28
+ }>;
29
+ };
30
+ };
31
+ }
32
+ export interface UserGroup {
33
+ group_id: string;
34
+ group_name: string;
35
+ description?: string;
36
+ remark?: string;
37
+ }
38
+ export interface Role {
39
+ role_id: string;
40
+ role_name: string;
41
+ role_type?: string;
42
+ role_property?: Record<string, unknown>;
43
+ role_privileges?: Privilege[];
44
+ privilege_ids?: string[];
45
+ resource_ids?: string[];
46
+ expired_at?: string;
47
+ remark?: string;
48
+ }
49
+ export interface Privilege {
50
+ privilege_id: string;
51
+ privilege_name: string;
52
+ privilege_type?: string;
53
+ privilege_property?: Record<string, unknown>;
54
+ resource_ids?: string[];
55
+ expired_at?: string;
56
+ remark?: string;
57
+ }
58
+ export interface AppInfo {
59
+ app_id: string;
60
+ app_key: string;
61
+ app_name: string;
62
+ }
63
+ export interface User {
64
+ user_id: string;
65
+ open_id: string;
66
+ username: string;
67
+ nick_name: string;
68
+ email: string;
69
+ phone: string;
70
+ avatar_url?: string;
71
+ is_frozen: boolean;
72
+ created_at: string;
73
+ updated_at: string;
74
+ remark?: string;
75
+ }
76
+ /**
77
+ * Attachment data (common type used across modules)
78
+ */
79
+ export interface Attachment {
80
+ attachment_id: string;
81
+ app_id: string;
82
+ attachment_type_id: string;
83
+ ref_id: string;
84
+ file_name: string;
85
+ file_url: string;
86
+ file_size: number;
87
+ mime_type: string;
88
+ remark?: string;
89
+ created_at: string;
90
+ updated_at: string;
91
+ }
@@ -0,0 +1,2 @@
1
+ // ==================== Common Types ====================
2
+ export {};