@amaster.ai/client 1.1.71 → 1.1.73

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/types/http.d.ts CHANGED
@@ -1,130 +1,8 @@
1
- import { AxiosRequestConfig, AxiosInstance } from "axios";
2
-
3
- type ClientError = {
4
- message: string;
5
- status?: number;
6
- code?: string;
7
- details?: unknown;
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
@@ -45,7 +45,7 @@
45
45
  * - `@amaster.ai/client/auth/profile` - Profile management (100 lines)
46
46
  * */
47
47
 
48
- import type { AuthClientAPI } from "./auth/index";
48
+ import type { AuthClientAPI, BrowserAuthClientAPI } from "./auth/index";
49
49
  import type { EntityClientAPI } from "./entity";
50
50
  import type { BpmClientAPI } from "./bpm";
51
51
  import type { WorkflowClientAPI } from "./workflow";
@@ -56,12 +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 {
80
+ storage?: import("@amaster.ai/auth-client").StorageAdapter;
81
+ withCredentials?: boolean;
65
82
  /**
66
83
  * Base URL for the Amaster API
67
84
  *
@@ -161,6 +178,9 @@ export interface AmasterClientOptions {
161
178
  *
162
179
  */
163
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;
164
184
  /**
165
185
  * Authentication module
166
186
  *
@@ -339,6 +359,11 @@ export interface AmasterClient {
339
359
  * @returns A configured Amaster client instance
340
360
  *
341
361
  */
362
+ export interface TenancyAmasterClient extends AmasterClient {
363
+ tenancy: TenancyClient;
364
+ }
365
+ export declare function createClient(options: BrowserAmasterClientOptions): BrowserAmasterClient & TenancyAmasterClient;
366
+ export declare function createClient(options?: AmasterClientOptions): TenancyAmasterClient;
342
367
  export declare function createClient(options?: AmasterClientOptions): AmasterClient;
343
368
 
344
369
  export { createAutoVoiceReplyController, createCopilotFileManager } from "./copilot";
@@ -348,7 +373,12 @@ export { createTTSSpeakController, preprocessTTSContent, splitTextIntoFragments
348
373
  export type { ClientError, ClientResult } from "./common";
349
374
 
350
375
  // Re-export main client interfaces
351
- export type { AuthClientAPI, AuthClientAPI as AuthClient } from "./auth";
376
+ export type {
377
+ AuthClientAPI,
378
+ AuthClientAPI as AuthClient,
379
+ BrowserAuthClientAPI,
380
+ BrowserAuthClientAPI as BrowserAuthClient,
381
+ } from "./auth";
352
382
  export type {
353
383
  AuthEvent,
354
384
  EventHandler,
@@ -536,3 +566,9 @@ export type { HttpClient, MiniProgramRuntime, RequestConfig } from "./http";
536
566
  // import type { Task, ProcessInstance } from '@amaster.ai/client/bpm'
537
567
  // import type { WorkflowRunRequest } from '@amaster.ai/client/workflow'
538
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";