@amaster.ai/client 1.1.21 → 1.1.22
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.
- package/README.md +10 -5
- package/dist/index.d.cts +6 -4
- package/dist/index.d.ts +6 -4
- package/package.json +11 -11
- package/types/__tests__/type-checks.test-d.ts +19 -0
- package/types/index.d.ts +9 -1
- package/types/s3.d.ts +46 -2
package/README.md
CHANGED
|
@@ -574,7 +574,10 @@ File upload, download, and metadata lookup.
|
|
|
574
574
|
|
|
575
575
|
```typescript
|
|
576
576
|
// Upload file
|
|
577
|
-
await client.s3.upload(file
|
|
577
|
+
await client.s3.upload(file, {
|
|
578
|
+
category: "documents",
|
|
579
|
+
onProgress: ({ percentage }) => console.log(`Uploading: ${percentage}%`),
|
|
580
|
+
});
|
|
578
581
|
|
|
579
582
|
// Download file
|
|
580
583
|
await client.s3.download("path/to/file");
|
|
@@ -764,11 +767,12 @@ Workflow execution API from `@amaster.ai/workflow-client`:
|
|
|
764
767
|
|
|
765
768
|
S3 storage API:
|
|
766
769
|
|
|
767
|
-
- `upload(file)` - Upload file
|
|
770
|
+
- `upload(file, options?)` - Upload file
|
|
768
771
|
- `download(path)` - Download file as a blob
|
|
769
772
|
- `getMetadata(key)` - Read object metadata
|
|
770
773
|
|
|
771
|
-
`upload(file)` automatically switches to multipart upload for large
|
|
774
|
+
`upload(file, options?)` automatically switches to multipart upload for large
|
|
775
|
+
files and can report progress via `options.onProgress`.
|
|
772
776
|
|
|
773
777
|
### `client.asr`
|
|
774
778
|
|
|
@@ -813,10 +817,11 @@ Function invocation API:
|
|
|
813
817
|
|
|
814
818
|
S3 storage API:
|
|
815
819
|
|
|
816
|
-
- `upload(file)` - Upload file
|
|
820
|
+
- `upload(file, options?)` - Upload file
|
|
817
821
|
- `download(path)` - Download file
|
|
818
822
|
|
|
819
|
-
`upload(file)` automatically switches to multipart upload for large
|
|
823
|
+
`upload(file, options?)` automatically switches to multipart upload for large
|
|
824
|
+
files and can report progress via `options.onProgress`.
|
|
820
825
|
|
|
821
826
|
## 🔐 Token Management Flow
|
|
822
827
|
|
package/dist/index.d.cts
CHANGED
|
@@ -15,7 +15,7 @@ export { FunctionClient, FunctionInvocationResult } from '@amaster.ai/function-c
|
|
|
15
15
|
import { TTSClientConfig, TTSClient } from '@amaster.ai/tts-client';
|
|
16
16
|
export { TTSClient, TTSClientConfig, TTSRuntime, TTSSnapshot, TTSSpeakController, TTSSpeakControllerOptions, TTSSpeakOptions, TTSStorageAdapter, createTTSSpeakController, preprocessTTSContent, splitTextIntoFragments } from '@amaster.ai/tts-client';
|
|
17
17
|
import { S3Client } from '@amaster.ai/s3-client';
|
|
18
|
-
export { S3Client, S3Metadata, UploadRes } from '@amaster.ai/s3-client';
|
|
18
|
+
export { S3Client, S3Metadata, S3UploadOptions, S3UploadProgress, S3UploadProgressPhase, UploadRes } from '@amaster.ai/s3-client';
|
|
19
19
|
import { MiniProgramRuntime, HttpClient } from '@amaster.ai/http-client';
|
|
20
20
|
export { ClientError, ClientResult, HttpClient, RequestConfig } from '@amaster.ai/http-client';
|
|
21
21
|
|
|
@@ -301,10 +301,12 @@ interface AmasterClient {
|
|
|
301
301
|
* @example
|
|
302
302
|
* ```typescript
|
|
303
303
|
* // Upload file
|
|
304
|
-
* await client.s3.upload(file
|
|
304
|
+
* await client.s3.upload(file, {
|
|
305
|
+
* onProgress: ({ percentage }) => console.log(`Uploading: ${percentage}%`),
|
|
306
|
+
* });
|
|
305
307
|
*
|
|
306
|
-
|
|
307
|
-
|
|
308
|
+
* // Download file
|
|
309
|
+
* await client.s3.download('path/to/file');
|
|
308
310
|
*
|
|
309
311
|
* // Read metadata
|
|
310
312
|
* await client.s3.getMetadata('path/to/file');
|
package/dist/index.d.ts
CHANGED
|
@@ -15,7 +15,7 @@ export { FunctionClient, FunctionInvocationResult } from '@amaster.ai/function-c
|
|
|
15
15
|
import { TTSClientConfig, TTSClient } from '@amaster.ai/tts-client';
|
|
16
16
|
export { TTSClient, TTSClientConfig, TTSRuntime, TTSSnapshot, TTSSpeakController, TTSSpeakControllerOptions, TTSSpeakOptions, TTSStorageAdapter, createTTSSpeakController, preprocessTTSContent, splitTextIntoFragments } from '@amaster.ai/tts-client';
|
|
17
17
|
import { S3Client } from '@amaster.ai/s3-client';
|
|
18
|
-
export { S3Client, S3Metadata, UploadRes } from '@amaster.ai/s3-client';
|
|
18
|
+
export { S3Client, S3Metadata, S3UploadOptions, S3UploadProgress, S3UploadProgressPhase, UploadRes } from '@amaster.ai/s3-client';
|
|
19
19
|
import { MiniProgramRuntime, HttpClient } from '@amaster.ai/http-client';
|
|
20
20
|
export { ClientError, ClientResult, HttpClient, RequestConfig } from '@amaster.ai/http-client';
|
|
21
21
|
|
|
@@ -301,10 +301,12 @@ interface AmasterClient {
|
|
|
301
301
|
* @example
|
|
302
302
|
* ```typescript
|
|
303
303
|
* // Upload file
|
|
304
|
-
* await client.s3.upload(file
|
|
304
|
+
* await client.s3.upload(file, {
|
|
305
|
+
* onProgress: ({ percentage }) => console.log(`Uploading: ${percentage}%`),
|
|
306
|
+
* });
|
|
305
307
|
*
|
|
306
|
-
|
|
307
|
-
|
|
308
|
+
* // Download file
|
|
309
|
+
* await client.s3.download('path/to/file');
|
|
308
310
|
*
|
|
309
311
|
* // Read metadata
|
|
310
312
|
* await client.s3.getMetadata('path/to/file');
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@amaster.ai/client",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.22",
|
|
4
4
|
"description": "Unified API client for Amaster platform - All services in one package",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.cjs",
|
|
@@ -72,16 +72,16 @@
|
|
|
72
72
|
"registry": "https://registry.npmjs.org/"
|
|
73
73
|
},
|
|
74
74
|
"dependencies": {
|
|
75
|
-
"@amaster.ai/asr-client": "1.1.
|
|
76
|
-
"@amaster.ai/
|
|
77
|
-
"@amaster.ai/
|
|
78
|
-
"@amaster.ai/copilot-client": "1.1.
|
|
79
|
-
"@amaster.ai/entity-client": "1.1.
|
|
80
|
-
"@amaster.ai/function-client": "1.1.
|
|
81
|
-
"@amaster.ai/
|
|
82
|
-
"@amaster.ai/
|
|
83
|
-
"@amaster.ai/tts-client": "1.1.
|
|
84
|
-
"@amaster.ai/workflow-client": "1.1.
|
|
75
|
+
"@amaster.ai/asr-client": "1.1.22",
|
|
76
|
+
"@amaster.ai/auth-client": "1.1.22",
|
|
77
|
+
"@amaster.ai/bpm-client": "1.1.22",
|
|
78
|
+
"@amaster.ai/copilot-client": "1.1.22",
|
|
79
|
+
"@amaster.ai/entity-client": "1.1.22",
|
|
80
|
+
"@amaster.ai/function-client": "1.1.22",
|
|
81
|
+
"@amaster.ai/s3-client": "1.1.22",
|
|
82
|
+
"@amaster.ai/http-client": "1.1.22",
|
|
83
|
+
"@amaster.ai/tts-client": "1.1.22",
|
|
84
|
+
"@amaster.ai/workflow-client": "1.1.22"
|
|
85
85
|
},
|
|
86
86
|
"peerDependencies": {
|
|
87
87
|
"axios": "^1.11.0"
|
|
@@ -16,6 +16,7 @@ import type {
|
|
|
16
16
|
User,
|
|
17
17
|
Task,
|
|
18
18
|
ProcessInstance,
|
|
19
|
+
S3UploadOptions,
|
|
19
20
|
} from '../index';
|
|
20
21
|
|
|
21
22
|
describe('Type Tests', () => {
|
|
@@ -112,6 +113,24 @@ describe('Type Tests', () => {
|
|
|
112
113
|
expectTypeOf<AmasterClient['function']>().toHaveProperty('invoke');
|
|
113
114
|
expectTypeOf<AmasterClient['s3']>().toHaveProperty('upload');
|
|
114
115
|
});
|
|
116
|
+
|
|
117
|
+
it('should accept S3 upload options', () => {
|
|
118
|
+
const options: S3UploadOptions = {
|
|
119
|
+
fileName: 'report.pdf',
|
|
120
|
+
category: 'documents',
|
|
121
|
+
onProgress: (progress) => {
|
|
122
|
+
expectTypeOf(progress.percentage).toEqualTypeOf<number>();
|
|
123
|
+
expectTypeOf(progress.phase).toEqualTypeOf<
|
|
124
|
+
'preparing' | 'uploading' | 'completing' | 'completed'
|
|
125
|
+
>();
|
|
126
|
+
},
|
|
127
|
+
};
|
|
128
|
+
|
|
129
|
+
expectTypeOf<AmasterClient['s3']['upload']>().parameters.toMatchTypeOf<
|
|
130
|
+
[File | Blob, S3UploadOptions?]
|
|
131
|
+
>();
|
|
132
|
+
expectTypeOf(options).toMatchTypeOf<S3UploadOptions>();
|
|
133
|
+
});
|
|
115
134
|
});
|
|
116
135
|
|
|
117
136
|
describe('LoginParams', () => {
|
package/types/index.d.ts
CHANGED
|
@@ -467,7 +467,15 @@ export type {
|
|
|
467
467
|
TTSRuntime,
|
|
468
468
|
TTSStorageAdapter,
|
|
469
469
|
} from "./tts";
|
|
470
|
-
export type {
|
|
470
|
+
export type {
|
|
471
|
+
S3ClientAPI,
|
|
472
|
+
UploadRes,
|
|
473
|
+
S3Metadata,
|
|
474
|
+
S3UploadOptions,
|
|
475
|
+
S3UploadProgress,
|
|
476
|
+
S3UploadProgressPhase,
|
|
477
|
+
S3ClientAPI as S3Client,
|
|
478
|
+
} from "./s3";
|
|
471
479
|
export type { HttpClient, MiniProgramRuntime, RequestConfig } from "./http";
|
|
472
480
|
|
|
473
481
|
// For detailed types, import directly from submodules:
|
package/types/s3.d.ts
CHANGED
|
@@ -29,6 +29,44 @@ export interface S3Metadata {
|
|
|
29
29
|
[key: string]: any;
|
|
30
30
|
}
|
|
31
31
|
|
|
32
|
+
export type S3UploadProgressPhase =
|
|
33
|
+
| "preparing"
|
|
34
|
+
| "uploading"
|
|
35
|
+
| "completing"
|
|
36
|
+
| "completed";
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Upload progress event emitted by client.s3.upload.
|
|
40
|
+
*
|
|
41
|
+
*/
|
|
42
|
+
export interface S3UploadProgress {
|
|
43
|
+
/** Uploaded bytes across the whole file */
|
|
44
|
+
loaded: number;
|
|
45
|
+
/** Total file bytes */
|
|
46
|
+
total: number;
|
|
47
|
+
/** Upload percentage from 0 to 100 */
|
|
48
|
+
percentage: number;
|
|
49
|
+
/** Current upload phase */
|
|
50
|
+
phase: S3UploadProgressPhase;
|
|
51
|
+
/** Multipart part currently reporting progress */
|
|
52
|
+
partNumber?: number;
|
|
53
|
+
/** Total multipart part count */
|
|
54
|
+
totalParts?: number;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Upload options.
|
|
59
|
+
*
|
|
60
|
+
*/
|
|
61
|
+
export interface S3UploadOptions {
|
|
62
|
+
/** Override the uploaded filename */
|
|
63
|
+
fileName?: string;
|
|
64
|
+
/** Optional storage category metadata */
|
|
65
|
+
category?: string;
|
|
66
|
+
/** Receives upload progress events */
|
|
67
|
+
onProgress?: (progress: S3UploadProgress) => void;
|
|
68
|
+
}
|
|
69
|
+
|
|
32
70
|
// ==================== S3 Client API ====================
|
|
33
71
|
|
|
34
72
|
/**
|
|
@@ -78,13 +116,16 @@ export interface S3ClientAPI {
|
|
|
78
116
|
* Upload a file
|
|
79
117
|
*
|
|
80
118
|
* @param file - The file to upload (File or Blob)
|
|
119
|
+
* @param options - Optional filename/category and progress callback
|
|
81
120
|
* @returns Upload result containing key and URL
|
|
82
121
|
*
|
|
83
122
|
* @example
|
|
84
123
|
* const fileInput = document.querySelector('input[type="file"]');
|
|
85
124
|
* const file = fileInput.files[0];
|
|
86
125
|
*
|
|
87
|
-
* const result = await client.s3.upload(file
|
|
126
|
+
* const result = await client.s3.upload(file, {
|
|
127
|
+
* onProgress: ({ percentage }) => console.log(`Uploaded ${percentage}%`),
|
|
128
|
+
* });
|
|
88
129
|
* if (result.data) {
|
|
89
130
|
* console.log('File uploaded:', result.data.url);
|
|
90
131
|
* console.log('File key:', result.data.key);
|
|
@@ -92,5 +133,8 @@ export interface S3ClientAPI {
|
|
|
92
133
|
*
|
|
93
134
|
* @since 1.0.0
|
|
94
135
|
*/
|
|
95
|
-
upload(
|
|
136
|
+
upload(
|
|
137
|
+
file: File | Blob,
|
|
138
|
+
options?: S3UploadOptions,
|
|
139
|
+
): Promise<ClientResult<UploadRes>>;
|
|
96
140
|
}
|