@open-dy/ai_coding_sdk 1.0.15 → 1.0.16

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.
@@ -0,0 +1,15 @@
1
+ import type { AIPlatformCallOptions, CheckMiniProgramModelPermissionRequest, CheckMiniProgramModelPermissionResponse } from './types';
2
+ /**
3
+ * 判断小程序是否有目标模型权限。
4
+ * 这里保留原始响应,避免在未知响应结构上做过度假设。
5
+ */
6
+ export declare function checkMiniProgramModelPermission(req: CheckMiniProgramModelPermissionRequest, options?: AIPlatformCallOptions): Promise<CheckMiniProgramModelPermissionResponse>;
7
+ /**
8
+ * 基于常见布尔字段做轻量归一化。
9
+ * 如果接口未返回这些字段,则返回 null,让上层自行读取原始响应。
10
+ */
11
+ export declare function getMiniProgramModelPermissionStatus(response: CheckMiniProgramModelPermissionResponse): boolean | null;
12
+ /**
13
+ * 权限明确为 false 时抛错;响应里没有标准布尔字段时,只返回原始响应。
14
+ */
15
+ export declare function assertMiniProgramModelPermission(req: CheckMiniProgramModelPermissionRequest, options?: AIPlatformCallOptions): Promise<CheckMiniProgramModelPermissionResponse>;
@@ -0,0 +1,44 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.checkMiniProgramModelPermission = checkMiniProgramModelPermission;
4
+ exports.getMiniProgramModelPermissionStatus = getMiniProgramModelPermissionStatus;
5
+ exports.assertMiniProgramModelPermission = assertMiniProgramModelPermission;
6
+ const core_1 = require("./core");
7
+ /**
8
+ * 判断小程序是否有目标模型权限。
9
+ * 这里保留原始响应,避免在未知响应结构上做过度假设。
10
+ */
11
+ async function checkMiniProgramModelPermission(req, options) {
12
+ return (0, core_1.postMiniProgramModelPermission)(req, options);
13
+ }
14
+ /**
15
+ * 基于常见布尔字段做轻量归一化。
16
+ * 如果接口未返回这些字段,则返回 null,让上层自行读取原始响应。
17
+ */
18
+ function getMiniProgramModelPermissionStatus(response) {
19
+ const candidates = [
20
+ response.data?.allowed,
21
+ response.data?.allow,
22
+ response.data?.has_permission,
23
+ response.data?.can_use,
24
+ ];
25
+ for (const candidate of candidates) {
26
+ if (typeof candidate === 'boolean') {
27
+ return candidate;
28
+ }
29
+ }
30
+ return null;
31
+ }
32
+ /**
33
+ * 权限明确为 false 时抛错;响应里没有标准布尔字段时,只返回原始响应。
34
+ */
35
+ async function assertMiniProgramModelPermission(req, options) {
36
+ const response = await checkMiniProgramModelPermission(req, options);
37
+ const granted = getMiniProgramModelPermissionStatus(response);
38
+ if (granted === false) {
39
+ throw new Error(response.message ||
40
+ response.err_msg ||
41
+ 'mini_program_model_permission_denied');
42
+ }
43
+ return response;
44
+ }
@@ -60,6 +60,7 @@ export interface StreamGenerateRequest {
60
60
  parameters: string;
61
61
  }>;
62
62
  extra?: Record<string, string>;
63
+ source: number;
63
64
  }
64
65
  export interface GenerateMessage {
65
66
  Role: Role;
@@ -108,6 +109,7 @@ export interface GenerateRequest {
108
109
  Parameters: string;
109
110
  }>;
110
111
  Extra?: Record<string, string>;
112
+ Source: number;
111
113
  }
112
114
  /**
113
115
  * 图片生成请求。
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@open-dy/ai_coding_sdk",
3
- "version": "1.0.15",
3
+ "version": "1.0.16",
4
4
  "description": "AI Coding SDK — 抖音开放平台 OpenAPI 客户端与工具集",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",