@openloaf-saas/sdk 0.1.34 → 0.1.37
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/dist/index.d.ts +67 -2
- package/dist/index.js +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -741,11 +741,13 @@ declare class SaaSContract {
|
|
|
741
741
|
variant: string;
|
|
742
742
|
inputs?: Record<string, unknown> | undefined;
|
|
743
743
|
params?: Record<string, unknown> | undefined;
|
|
744
|
+
stream?: boolean | undefined;
|
|
744
745
|
}, {
|
|
745
746
|
success: true;
|
|
746
747
|
data: {
|
|
747
748
|
text: string;
|
|
748
749
|
creditsConsumed?: number | undefined;
|
|
750
|
+
taskId?: string | undefined;
|
|
749
751
|
};
|
|
750
752
|
}>;
|
|
751
753
|
readonly v3Generate: Endpoint<{
|
|
@@ -755,6 +757,7 @@ declare class SaaSContract {
|
|
|
755
757
|
inputs?: Record<string, unknown> | undefined;
|
|
756
758
|
params?: Record<string, unknown> | undefined;
|
|
757
759
|
count?: number | undefined;
|
|
760
|
+
stream?: boolean | undefined;
|
|
758
761
|
}, {
|
|
759
762
|
success: true;
|
|
760
763
|
data: {
|
|
@@ -1275,6 +1278,8 @@ type BaseSaaSClientOptions<TContract> = {
|
|
|
1275
1278
|
fetcher?: typeof fetch;
|
|
1276
1279
|
headers?: HeaderInput;
|
|
1277
1280
|
contract: TContract;
|
|
1281
|
+
/** Default locale for APIs that support i18n (e.g. "zh-CN", "en-US"). */
|
|
1282
|
+
locale?: string;
|
|
1278
1283
|
};
|
|
1279
1284
|
declare class BaseSaaSClient<TContract> {
|
|
1280
1285
|
/** Contract definitions used by the client. */
|
|
@@ -1287,6 +1292,8 @@ declare class BaseSaaSClient<TContract> {
|
|
|
1287
1292
|
private readonly fetcher;
|
|
1288
1293
|
/** Static headers injected into every request. */
|
|
1289
1294
|
private readonly headers?;
|
|
1295
|
+
/** Default locale for i18n-aware APIs. */
|
|
1296
|
+
private locale?;
|
|
1290
1297
|
/** Create a base client instance. */
|
|
1291
1298
|
constructor(options: BaseSaaSClientOptions<TContract>);
|
|
1292
1299
|
/** Send a typed request to the SaaS server. */
|
|
@@ -1299,6 +1306,10 @@ declare class BaseSaaSClient<TContract> {
|
|
|
1299
1306
|
buildAuthHeader(): Promise<Record<string, string>>;
|
|
1300
1307
|
/** Return the configured base URL. */
|
|
1301
1308
|
getBaseUrl(): string;
|
|
1309
|
+
/** Return the configured default locale. */
|
|
1310
|
+
getLocale(): string | undefined;
|
|
1311
|
+
/** Update the default locale at runtime. */
|
|
1312
|
+
setLocale(locale: string | undefined): void;
|
|
1302
1313
|
}
|
|
1303
1314
|
|
|
1304
1315
|
/** Request function signature shared by SDK clients. */
|
|
@@ -1317,6 +1328,8 @@ type SdkHost<TContract> = {
|
|
|
1317
1328
|
getBaseUrl: () => string;
|
|
1318
1329
|
/** Build Authorization header for authenticated calls. */
|
|
1319
1330
|
buildAuthHeader: () => Promise<Record<string, string>>;
|
|
1331
|
+
/** Resolve the configured default locale (e.g. "zh-CN"). */
|
|
1332
|
+
getLocale: () => string | undefined;
|
|
1320
1333
|
};
|
|
1321
1334
|
|
|
1322
1335
|
declare const aiEndpoints: {
|
|
@@ -2020,17 +2033,19 @@ declare const aiEndpoints: {
|
|
|
2020
2033
|
updatedAt?: string | undefined;
|
|
2021
2034
|
};
|
|
2022
2035
|
}>;
|
|
2023
|
-
/** Submit a v3 text generate request (sync
|
|
2036
|
+
/** Submit a v3 text generate request (sync JSON or streaming SSE). */
|
|
2024
2037
|
readonly v3TextGenerate: Endpoint<{
|
|
2025
2038
|
feature: string;
|
|
2026
2039
|
variant: string;
|
|
2027
2040
|
inputs?: Record<string, unknown> | undefined;
|
|
2028
2041
|
params?: Record<string, unknown> | undefined;
|
|
2042
|
+
stream?: boolean | undefined;
|
|
2029
2043
|
}, {
|
|
2030
2044
|
success: true;
|
|
2031
2045
|
data: {
|
|
2032
2046
|
text: string;
|
|
2033
2047
|
creditsConsumed?: number | undefined;
|
|
2048
|
+
taskId?: string | undefined;
|
|
2034
2049
|
};
|
|
2035
2050
|
}>;
|
|
2036
2051
|
/** Submit a v3 generate request. */
|
|
@@ -2041,6 +2056,7 @@ declare const aiEndpoints: {
|
|
|
2041
2056
|
inputs?: Record<string, unknown> | undefined;
|
|
2042
2057
|
params?: Record<string, unknown> | undefined;
|
|
2043
2058
|
count?: number | undefined;
|
|
2059
|
+
stream?: boolean | undefined;
|
|
2044
2060
|
}, {
|
|
2045
2061
|
success: true;
|
|
2046
2062
|
data: {
|
|
@@ -3705,6 +3721,7 @@ declare const v3GenerateRequestSchema: z.ZodObject<{
|
|
|
3705
3721
|
inputs: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
3706
3722
|
params: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
3707
3723
|
count: z.ZodOptional<z.ZodNumber>;
|
|
3724
|
+
stream: z.ZodOptional<z.ZodBoolean>;
|
|
3708
3725
|
}, z.core.$strip>;
|
|
3709
3726
|
/** v3 text generate request body. */
|
|
3710
3727
|
declare const v3TextGenerateRequestSchema: z.ZodObject<{
|
|
@@ -3712,6 +3729,7 @@ declare const v3TextGenerateRequestSchema: z.ZodObject<{
|
|
|
3712
3729
|
variant: z.ZodString;
|
|
3713
3730
|
inputs: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
3714
3731
|
params: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
3732
|
+
stream: z.ZodOptional<z.ZodBoolean>;
|
|
3715
3733
|
}, z.core.$strip>;
|
|
3716
3734
|
/** v3 text generate response. */
|
|
3717
3735
|
declare const v3TextGenerateResponseSchema: z.ZodObject<{
|
|
@@ -3719,6 +3737,7 @@ declare const v3TextGenerateResponseSchema: z.ZodObject<{
|
|
|
3719
3737
|
data: z.ZodObject<{
|
|
3720
3738
|
text: z.ZodString;
|
|
3721
3739
|
creditsConsumed: z.ZodOptional<z.ZodNumber>;
|
|
3740
|
+
taskId: z.ZodOptional<z.ZodString>;
|
|
3722
3741
|
}, z.core.$strip>;
|
|
3723
3742
|
}, z.core.$strip>;
|
|
3724
3743
|
/** Individual task item within a v3 response. */
|
|
@@ -4651,8 +4670,15 @@ declare class AiClient {
|
|
|
4651
4670
|
updatedAt?: string | undefined;
|
|
4652
4671
|
};
|
|
4653
4672
|
}>;
|
|
4654
|
-
/** Submit a v3 text generate request (sync,
|
|
4673
|
+
/** Submit a v3 text generate request (sync mode, returns parsed JSON). */
|
|
4655
4674
|
v3TextGenerate(payload: V3TextGenerateRequest): Promise<V3TextGenerateResponse>;
|
|
4675
|
+
/**
|
|
4676
|
+
* Submit a v3 text generate request in streaming mode.
|
|
4677
|
+
* 返回原始 Response,调用方通过 response.body (ReadableStream) 消费 SSE 事件。
|
|
4678
|
+
* 每个 SSE event 的 data 字段是 OpenAI chat completions chunk 格式。
|
|
4679
|
+
* taskId 通过响应头 x-task-id 返回。
|
|
4680
|
+
*/
|
|
4681
|
+
v3TextGenerateStream(payload: Omit<V3TextGenerateRequest, "stream">): Promise<Response>;
|
|
4656
4682
|
/** Submit a v3 generate request (unified for all media types). */
|
|
4657
4683
|
v3Generate(payload: V3GenerateRequest): Promise<{
|
|
4658
4684
|
success: true;
|
|
@@ -4663,6 +4689,13 @@ declare class AiClient {
|
|
|
4663
4689
|
taskIds: string[];
|
|
4664
4690
|
};
|
|
4665
4691
|
}>;
|
|
4692
|
+
/**
|
|
4693
|
+
* Submit a v3 generate request in streaming mode.
|
|
4694
|
+
* 返回原始 Response,调用方通过 response.body (ReadableStream) 消费 SSE 事件。
|
|
4695
|
+
* 每个 SSE event 的 data 字段是 OpenAI chat completions chunk 格式。
|
|
4696
|
+
* taskId 通过响应头 x-task-id 返回。
|
|
4697
|
+
*/
|
|
4698
|
+
v3GenerateStream(payload: Omit<V3GenerateRequest, "stream" | "count">): Promise<Response>;
|
|
4666
4699
|
/** Get v3 task details by ID. */
|
|
4667
4700
|
v3Task(taskId: string): Promise<{
|
|
4668
4701
|
success: true;
|
|
@@ -5178,6 +5211,21 @@ declare const MEDIA_FEATURES: {
|
|
|
5178
5211
|
readonly ja: "画像内のテキストを認識";
|
|
5179
5212
|
};
|
|
5180
5213
|
};
|
|
5214
|
+
readonly audioRecognize: {
|
|
5215
|
+
readonly id: "audioRecognize";
|
|
5216
|
+
readonly label: {
|
|
5217
|
+
readonly zh: "音频识别";
|
|
5218
|
+
readonly "zh-TW": "音訊辨識";
|
|
5219
|
+
readonly en: "Audio Recognition";
|
|
5220
|
+
readonly ja: "音声認識";
|
|
5221
|
+
};
|
|
5222
|
+
readonly description: {
|
|
5223
|
+
readonly zh: "识别音频中的语音内容并转录为文字";
|
|
5224
|
+
readonly "zh-TW": "辨識音訊中的語音內容並轉錄為文字";
|
|
5225
|
+
readonly en: "Recognize speech in audio and transcribe to text";
|
|
5226
|
+
readonly ja: "音声の内容を認識してテキストに書き起こす";
|
|
5227
|
+
};
|
|
5228
|
+
};
|
|
5181
5229
|
readonly imageCaption: {
|
|
5182
5230
|
readonly id: "imageCaption";
|
|
5183
5231
|
readonly label: {
|
|
@@ -5193,6 +5241,21 @@ declare const MEDIA_FEATURES: {
|
|
|
5193
5241
|
readonly ja: "画像のテキスト説明を自動生成";
|
|
5194
5242
|
};
|
|
5195
5243
|
};
|
|
5244
|
+
readonly videoCaption: {
|
|
5245
|
+
readonly id: "videoCaption";
|
|
5246
|
+
readonly label: {
|
|
5247
|
+
readonly zh: "视频描述";
|
|
5248
|
+
readonly "zh-TW": "影片描述";
|
|
5249
|
+
readonly en: "Video Caption";
|
|
5250
|
+
readonly ja: "動画キャプション";
|
|
5251
|
+
};
|
|
5252
|
+
readonly description: {
|
|
5253
|
+
readonly zh: "自动生成视频的文字描述";
|
|
5254
|
+
readonly "zh-TW": "自動生成影片的文字描述";
|
|
5255
|
+
readonly en: "Automatically generate text descriptions for videos";
|
|
5256
|
+
readonly ja: "動画のテキスト説明を自動生成";
|
|
5257
|
+
};
|
|
5258
|
+
};
|
|
5196
5259
|
readonly musicGenerate: {
|
|
5197
5260
|
readonly id: "musicGenerate";
|
|
5198
5261
|
readonly label: {
|
|
@@ -7070,6 +7133,8 @@ declare class SkillMarketClient {
|
|
|
7070
7133
|
constructor(sdk: SkillMarketSdkHost);
|
|
7071
7134
|
/** Build URL query string from params (skip undefined/null values). */
|
|
7072
7135
|
private buildQuery;
|
|
7136
|
+
/** Resolve effective lang: explicit param > global locale > undefined (server default). */
|
|
7137
|
+
private resolveLang;
|
|
7073
7138
|
/**
|
|
7074
7139
|
* List marketplace skills with optional filters.
|
|
7075
7140
|
* @remarks Public endpoint — no authentication required.
|