@amaster.ai/client 1.1.72 → 1.1.74
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 +57 -0
- package/dist/index.cjs +897 -27
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +13 -4
- package/dist/index.d.ts +13 -4
- package/dist/index.js +897 -30
- package/dist/index.js.map +1 -1
- package/package.json +11 -11
- package/types/auth/index.d.ts +1 -0
- package/types/common.d.ts +3 -0
- package/types/http.d.ts +8 -130
- package/types/index.d.ts +40 -12
package/types/http.d.ts
CHANGED
|
@@ -1,130 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
type
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
};
|
|
9
|
-
type ClientResult<T> = {
|
|
10
|
-
data: T | null;
|
|
11
|
-
error: ClientError | null;
|
|
12
|
-
status: number;
|
|
13
|
-
headers?: unknown;
|
|
14
|
-
};
|
|
15
|
-
type RequestConfig = AxiosRequestConfig & {
|
|
16
|
-
url: string;
|
|
17
|
-
method: NonNullable<AxiosRequestConfig["method"]> | string;
|
|
18
|
-
};
|
|
19
|
-
type AdapterResponse = {
|
|
20
|
-
status: number;
|
|
21
|
-
data: unknown;
|
|
22
|
-
headers?: unknown;
|
|
23
|
-
};
|
|
24
|
-
type HttpAdapter = (_config: RequestConfig) => Promise<AdapterResponse>;
|
|
25
|
-
type MiniProgramRequest = (_opts: any) => any;
|
|
26
|
-
type MiniProgramRuntime = {
|
|
27
|
-
Taro?: {
|
|
28
|
-
request?: (_opts: any) => any;
|
|
29
|
-
login?: (_opts?: any) => any;
|
|
30
|
-
getEnv?: () => unknown;
|
|
31
|
-
ENV_TYPE?: Record<string, unknown>;
|
|
32
|
-
miniGlobal?: unknown;
|
|
33
|
-
options?: {
|
|
34
|
-
miniGlobal?: unknown;
|
|
35
|
-
};
|
|
36
|
-
};
|
|
37
|
-
};
|
|
38
|
-
type HttpClientOptions = {
|
|
39
|
-
/**
|
|
40
|
-
* HTTP adapter to use:
|
|
41
|
-
* - undefined: auto-detect (taro if mini-program APIs exist, otherwise axios)
|
|
42
|
-
* - "taro": force mini-program request (wx/tt/my/...) or global Taro.request
|
|
43
|
-
* - "axios": force axios
|
|
44
|
-
* - AxiosInstance: use provided axios instance
|
|
45
|
-
* - function: custom adapter
|
|
46
|
-
*/
|
|
47
|
-
adapter?: "taro" | "axios" | AxiosInstance | HttpAdapter;
|
|
48
|
-
/**
|
|
49
|
-
* Base URL to prefix when `config.url` is relative (e.g. "/api/...").
|
|
50
|
-
*
|
|
51
|
-
* If not provided:
|
|
52
|
-
* - Taro/mini-program: auto-reads from process.env.TARO_APP_API_BASE_URL or process.env.VITE_API_BASE_URL
|
|
53
|
-
* - H5/Browser: no baseURL (expects dev proxy or absolute URLs)
|
|
54
|
-
*/
|
|
55
|
-
baseURL?: string;
|
|
56
|
-
/** Default headers merged into each request */
|
|
57
|
-
headers?: Record<string, string>;
|
|
58
|
-
/**
|
|
59
|
-
* Custom response transform function to extract/modify data from backend response
|
|
60
|
-
* If not provided, uses default transform logic for { status: 0/1, data: {...} }
|
|
61
|
-
*
|
|
62
|
-
* Similar to axios's transformResponse option
|
|
63
|
-
*
|
|
64
|
-
* @example
|
|
65
|
-
* ```typescript
|
|
66
|
-
* // For backend that returns: { statusCode: 200, data: {...} }
|
|
67
|
-
* const client = createHttpClient({
|
|
68
|
-
* transformResponse: (response) => {
|
|
69
|
-
* if (response && typeof response === 'object' && 'data' in response) {
|
|
70
|
-
* return response.data;
|
|
71
|
-
* }
|
|
72
|
-
* return response;
|
|
73
|
-
* }
|
|
74
|
-
* });
|
|
75
|
-
* ```
|
|
76
|
-
*/
|
|
77
|
-
transformResponse?: <T>(responseData: unknown) => T;
|
|
78
|
-
/**
|
|
79
|
-
* Whether to log errors to console (default: true)
|
|
80
|
-
* Set to false to disable automatic error logging
|
|
81
|
-
*/
|
|
82
|
-
logErrors?: boolean;
|
|
83
|
-
/**
|
|
84
|
-
* Explicitly provide the Taro runtime object when it is not exposed on `globalThis`.
|
|
85
|
-
*/
|
|
86
|
-
runtime?: Partial<MiniProgramRuntime>;
|
|
87
|
-
};
|
|
88
|
-
type HttpClient = {
|
|
89
|
-
request<T>(_config: RequestConfig): Promise<ClientResult<T>>;
|
|
90
|
-
};
|
|
91
|
-
declare function resolveMiniProgramGlobals(): any;
|
|
92
|
-
declare function getMiniProgramRequest(): MiniProgramRequest | null;
|
|
93
|
-
/**
|
|
94
|
-
* Create an HTTP client instance
|
|
95
|
-
*
|
|
96
|
-
* @param axiosInstance - Optional axios instance to use (defaults to a basic axios instance)
|
|
97
|
-
* @returns HttpClient with request method
|
|
98
|
-
*
|
|
99
|
-
* @example
|
|
100
|
-
* ```typescript
|
|
101
|
-
* import axios from "axios";
|
|
102
|
-
* import { createHttpClient } from "@amaster.ai/http-client";
|
|
103
|
-
*
|
|
104
|
-
* const instance = axios.create({ baseURL: "https://api.example.com" });
|
|
105
|
-
* const client = createHttpClient(instance);
|
|
106
|
-
*
|
|
107
|
-
* const result = await client.request({
|
|
108
|
-
* url: "/users",
|
|
109
|
-
* method: "get",
|
|
110
|
-
* });
|
|
111
|
-
* ```
|
|
112
|
-
*/
|
|
113
|
-
declare function createHttpClient(
|
|
114
|
-
axiosInstanceOrOptions?: AxiosInstance | HttpClientOptions
|
|
115
|
-
): HttpClient;
|
|
116
|
-
|
|
117
|
-
export {
|
|
118
|
-
type AdapterResponse,
|
|
119
|
-
type ClientError,
|
|
120
|
-
type ClientResult,
|
|
121
|
-
type HttpAdapter,
|
|
122
|
-
type HttpClient,
|
|
123
|
-
type HttpClientOptions,
|
|
124
|
-
type MiniProgramRequest,
|
|
125
|
-
type MiniProgramRuntime,
|
|
126
|
-
type RequestConfig,
|
|
127
|
-
createHttpClient,
|
|
128
|
-
getMiniProgramRequest,
|
|
129
|
-
resolveMiniProgramGlobals,
|
|
130
|
-
};
|
|
1
|
+
/** Shared transport declarations follow the public HTTP package. */
|
|
2
|
+
import type { getMiniProgramRequest } from "@amaster.ai/http-client";
|
|
3
|
+
export type MiniProgramRequest = NonNullable<ReturnType<typeof getMiniProgramRequest>>;
|
|
4
|
+
export type {
|
|
5
|
+
AdapterResponse, ClientError, ClientResult, HttpAdapter, HttpClient,
|
|
6
|
+
HttpClientOptions, MiniProgramRuntime, RequestConfig,
|
|
7
|
+
} from "@amaster.ai/http-client";
|
|
8
|
+
export { createHttpClient, getMiniProgramRequest, resolveMiniProgramGlobals } from "@amaster.ai/http-client";
|
package/types/index.d.ts
CHANGED
|
@@ -56,14 +56,29 @@ import type { FunctionClientAPI } from "./function";
|
|
|
56
56
|
import type { TTSClientAPI, TTSClientConfig } from "./tts";
|
|
57
57
|
import type { S3ClientAPI } from "./s3";
|
|
58
58
|
import type { HttpClient, MiniProgramRuntime } from "./http";
|
|
59
|
+
import type { TenancyClient } from "@amaster.ai/auth-client/tenancy";
|
|
60
|
+
export type {
|
|
61
|
+
TenancyClient,
|
|
62
|
+
TenancyAccount,
|
|
63
|
+
TenancyCurrent,
|
|
64
|
+
TenancyDecision,
|
|
65
|
+
TenancyDepartmentScope,
|
|
66
|
+
TenancyNode,
|
|
67
|
+
} from "@amaster.ai/auth-client/tenancy";
|
|
68
|
+
export type {
|
|
69
|
+
RequestScopeOptions,
|
|
70
|
+
RequestScopeCapture,
|
|
71
|
+
RequestSubject,
|
|
72
|
+
} from "@amaster.ai/http-client";
|
|
73
|
+
export { TenancyCapabilityError } from "@amaster.ai/auth-client/tenancy";
|
|
59
74
|
|
|
60
75
|
/**
|
|
61
76
|
* Configuration options for creating an Amaster client
|
|
62
77
|
*
|
|
63
78
|
*/
|
|
64
79
|
export interface AmasterClientOptions {
|
|
65
|
-
|
|
66
|
-
|
|
80
|
+
storage?: import("@amaster.ai/auth-client").StorageAdapter;
|
|
81
|
+
withCredentials?: boolean;
|
|
67
82
|
/**
|
|
68
83
|
* Base URL for the Amaster API
|
|
69
84
|
*
|
|
@@ -163,6 +178,9 @@ export interface AmasterClientOptions {
|
|
|
163
178
|
*
|
|
164
179
|
*/
|
|
165
180
|
export interface AmasterClient {
|
|
181
|
+
/** Wait for authoritative application mode; API and instance execution wait automatically. Local UI hints/factory construction remain synchronous. */
|
|
182
|
+
ready(): Promise<void>;
|
|
183
|
+
tenancy?: TenancyClient;
|
|
166
184
|
/**
|
|
167
185
|
* Authentication module
|
|
168
186
|
*
|
|
@@ -331,18 +349,22 @@ export interface AmasterClient {
|
|
|
331
349
|
clearAuth(): void;
|
|
332
350
|
}
|
|
333
351
|
|
|
334
|
-
|
|
335
|
-
|
|
352
|
+
/**
|
|
353
|
+
* Factory function to create a unified Amaster client
|
|
354
|
+
*
|
|
355
|
+
* This is the main entry point for using the Amaster client library.
|
|
356
|
+
* It returns a client instance that provides access to all Amaster services.
|
|
357
|
+
*
|
|
358
|
+
* @param options - Configuration options for the client
|
|
359
|
+
* @returns A configured Amaster client instance
|
|
360
|
+
*
|
|
361
|
+
*/
|
|
362
|
+
export interface TenancyAmasterClient extends AmasterClient {
|
|
363
|
+
tenancy: TenancyClient;
|
|
336
364
|
}
|
|
337
|
-
|
|
338
|
-
export
|
|
339
|
-
{ storage: import("@amaster.ai/auth-client").StorageAdapter } | { withCredentials: boolean }
|
|
340
|
-
);
|
|
341
|
-
|
|
342
|
-
/** Explicit browser settings expose session methods; default calls retain AmasterClient. */
|
|
343
|
-
export declare function createClient(options: BrowserAmasterClientOptions): BrowserAmasterClient;
|
|
365
|
+
export declare function createClient(options: BrowserAmasterClientOptions): BrowserAmasterClient & TenancyAmasterClient;
|
|
366
|
+
export declare function createClient(options?: AmasterClientOptions): TenancyAmasterClient;
|
|
344
367
|
export declare function createClient(options?: AmasterClientOptions): AmasterClient;
|
|
345
|
-
export { createMemoryStorage, completeOAuthPopup, type StorageAdapter } from "@amaster.ai/auth-client";
|
|
346
368
|
|
|
347
369
|
export { createAutoVoiceReplyController, createCopilotFileManager } from "./copilot";
|
|
348
370
|
export { createTTSSpeakController, preprocessTTSContent, splitTextIntoFragments } from "./tts";
|
|
@@ -544,3 +566,9 @@ export type { HttpClient, MiniProgramRuntime, RequestConfig } from "./http";
|
|
|
544
566
|
// import type { Task, ProcessInstance } from '@amaster.ai/client/bpm'
|
|
545
567
|
// import type { WorkflowRunRequest } from '@amaster.ai/client/workflow'
|
|
546
568
|
// import type { ServerToClientMessage } from '@amaster.ai/client/copilot'
|
|
569
|
+
|
|
570
|
+
|
|
571
|
+
|
|
572
|
+
export interface BrowserAmasterClient extends AmasterClient { auth: BrowserAuthClientAPI; }
|
|
573
|
+
export type BrowserAmasterClientOptions = AmasterClientOptions & ({ storage: import("@amaster.ai/auth-client").StorageAdapter } | { withCredentials: boolean });
|
|
574
|
+
export { createMemoryStorage, completeOAuthPopup, type StorageAdapter } from "@amaster.ai/auth-client";
|