@open-dy/ai_coding_sdk 1.0.21 → 1.0.23

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.
@@ -39,6 +39,7 @@ function getAIPlatformGatewayOrigin(appEnv = getAIPlatformAppEnv()) {
39
39
  if (appEnv === 'DEV') {
40
40
  return `https://${OPENAPI_ORIGIN}`;
41
41
  }
42
+ // 抖音云环境统一走云代理域名,避免业务侧直连 open.douyin.com。
42
43
  const mappedDomain = CLOUD_CALL_DOMAIN_MAP[OPENAPI_ORIGIN] ?? OPENAPI_ORIGIN;
43
44
  return `http://${mappedDomain}`;
44
45
  }
package/dist/auth/core.js CHANGED
@@ -1,8 +1,24 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.callAuthAPI = callAuthAPI;
4
+ const CLOUD_CALL_DOMAIN_MAP = {
5
+ 'open.douyin.com': 'open-douyin-com.openapi.dyc.ivolces.com',
6
+ };
7
+ function getCloudEnv() {
8
+ const cloudEnv = process.env.CLOUD_ENV?.trim();
9
+ return cloudEnv ? cloudEnv : undefined;
10
+ }
11
+ function isCloudEnvironment() {
12
+ return process.env.APP_ENV !== 'DEV' || Boolean(getCloudEnv());
13
+ }
14
+ function getCloudCallDomain(originalDomain) {
15
+ return CLOUD_CALL_DOMAIN_MAP[originalDomain] || originalDomain;
16
+ }
4
17
  function buildUrl(path, domain = 'open.douyin.com') {
5
- return new URL(`https://${domain}${path}`).toString();
18
+ const useCloudCall = isCloudEnvironment() && domain in CLOUD_CALL_DOMAIN_MAP;
19
+ const finalDomain = useCloudCall ? getCloudCallDomain(domain) : domain;
20
+ const protocol = useCloudCall ? 'http' : 'https';
21
+ return new URL(`${protocol}://${finalDomain}${path}`).toString();
6
22
  }
7
23
  function toFormBody(body) {
8
24
  if (body instanceof URLSearchParams) {
@@ -43,6 +59,7 @@ async function callAuthAPI(params, options) {
43
59
  console.log(`[Auth] ${method} ${url}`);
44
60
  console.log('[Auth] Headers:', headers);
45
61
  console.log('[Auth] Body:', maskBody(requestBody));
62
+ console.log('[Auth] Is Cloud Environment:', isCloudEnvironment());
46
63
  try {
47
64
  const response = await fetch(url, {
48
65
  method,
@@ -18,3 +18,5 @@ export { getUserPublicInfo } from './public-info';
18
18
  export type { UserPublicInfo, UserPublicInfoParams, UserPublicInfoResponse } from './public-info';
19
19
  export { getRealNameInfo } from './realname';
20
20
  export type { AgeRange, RealNameInfoData, RealNameInfoParams } from './realname';
21
+ export { getUserInterest } from './user-interest';
22
+ export type { UserInterestParams, UserInterestResponse } from './user-interest';
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getRealNameInfo = exports.getUserPublicInfo = exports.getUserConstellation = exports.getUserHashMobile = exports.getRelatedId = exports.getAffiliateId = exports.getUserShareData = exports.getUserProfileData = exports.getUserLikeData = exports.getUserItemData = exports.getUserFansData = exports.getUserCommentData = exports.getUserCertLabelsInfo = exports.getAIUserProfile = exports.getAIUserItemList = exports.getAIUserDataInfo = void 0;
3
+ exports.getUserInterest = exports.getRealNameInfo = exports.getUserPublicInfo = exports.getUserConstellation = exports.getUserHashMobile = exports.getRelatedId = exports.getAffiliateId = exports.getUserShareData = exports.getUserProfileData = exports.getUserLikeData = exports.getUserItemData = exports.getUserFansData = exports.getUserCommentData = exports.getUserCertLabelsInfo = exports.getAIUserProfile = exports.getAIUserItemList = exports.getAIUserDataInfo = void 0;
4
4
  var ai_data_1 = require("./ai_data");
5
5
  Object.defineProperty(exports, "getAIUserDataInfo", { enumerable: true, get: function () { return ai_data_1.getAIUserDataInfo; } });
6
6
  var ai_items_1 = require("./ai_items");
@@ -27,3 +27,5 @@ var public_info_1 = require("./public-info");
27
27
  Object.defineProperty(exports, "getUserPublicInfo", { enumerable: true, get: function () { return public_info_1.getUserPublicInfo; } });
28
28
  var realname_1 = require("./realname");
29
29
  Object.defineProperty(exports, "getRealNameInfo", { enumerable: true, get: function () { return realname_1.getRealNameInfo; } });
30
+ var user_interest_1 = require("./user-interest");
31
+ Object.defineProperty(exports, "getUserInterest", { enumerable: true, get: function () { return user_interest_1.getUserInterest; } });
@@ -0,0 +1,20 @@
1
+ import type { CallOptions, OpenAPIResponse } from '../core';
2
+ export interface UserInterestParams {
3
+ /** 抖音 user_id */
4
+ uid: string;
5
+ }
6
+ export interface UserInterestResponse {
7
+ /** 长期兴趣标签 */
8
+ long_interest?: string;
9
+ /** 短期兴趣标签 */
10
+ short_interest?: string;
11
+ }
12
+ /**
13
+ * 获取用户兴趣标签
14
+ *
15
+ * - Path: `/dy_open_api/ai_platform/data/query_user_interest/`
16
+ * - Capability: `dy.open.aweme.dy.user_interest`
17
+ * - Scope: `aweme.dy.user_interest`
18
+ * - 需要用户授权: 否(按表格 F 列配置)
19
+ */
20
+ export declare function getUserInterest(params: UserInterestParams, options?: CallOptions): Promise<OpenAPIResponse<UserInterestResponse>>;
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getUserInterest = getUserInterest;
4
+ const core_1 = require("../core");
5
+ /**
6
+ * 获取用户兴趣标签
7
+ *
8
+ * - Path: `/dy_open_api/ai_platform/data/query_user_interest/`
9
+ * - Capability: `dy.open.aweme.dy.user_interest`
10
+ * - Scope: `aweme.dy.user_interest`
11
+ * - 需要用户授权: 否(按表格 F 列配置)
12
+ */
13
+ async function getUserInterest(params, options) {
14
+ return (0, core_1.callOpenAPI)({
15
+ path: '/dy_open_api/ai_platform/data/query_user_interest/',
16
+ method: 'POST',
17
+ body: params,
18
+ domain: 'open.douyin.com',
19
+ }, options);
20
+ }
@@ -9,7 +9,7 @@ export interface CallOpenAPIParams {
9
9
  *
10
10
  * @remarks
11
11
  * 当该值为 `true` 时:
12
- * - SDK 会请求 `open.douyin.com`
12
+ * - 云环境下仍然统一走抖音云代理域名
13
13
  * - 需要在 header 中传入用户授权后的 `access-token`
14
14
  *
15
15
  * 注意这里的 `access-token` 不是 SDK 自动生成的,必须先调用 `auth` 模块
@@ -37,7 +37,7 @@ export interface CallOptions {
37
37
  * `accessToken` 的兼容别名。
38
38
  *
39
39
  * @deprecated 请改用 `accessToken`。对于需要用户授权的 OpenAPI,这里传入的值本质上也应当是
40
- * 用户授权后的 `access_token`,而不是任意上游透传 token。
40
+ * 用户授权后的 `access_token`,或封闭域入口已获取的 `x-dy-delegatetoken`。
41
41
  */
42
42
  delegateToken?: string;
43
43
  logid?: string;
@@ -17,11 +17,11 @@ function isCloudEnvironment() {
17
17
  function getCloudCallDomain(originalDomain) {
18
18
  return CLOUD_CALL_DOMAIN_MAP[originalDomain] || originalDomain;
19
19
  }
20
- function shouldUseCloudCall(domain, requiresUserAuth) {
21
- return isCloudEnvironment() && !requiresUserAuth && domain in CLOUD_CALL_DOMAIN_MAP;
20
+ function shouldUseCloudCall(domain) {
21
+ return isCloudEnvironment() && domain in CLOUD_CALL_DOMAIN_MAP;
22
22
  }
23
- function buildUrl(path, queryParams, domain = 'open.douyin.com', requiresUserAuth) {
24
- const useCloudCall = shouldUseCloudCall(domain, requiresUserAuth);
23
+ function buildUrl(path, queryParams, domain = 'open.douyin.com') {
24
+ const useCloudCall = shouldUseCloudCall(domain);
25
25
  const finalDomain = useCloudCall ? getCloudCallDomain(domain) : domain;
26
26
  const protocol = useCloudCall ? 'http' : 'https';
27
27
  const url = new URL(`${protocol}://${finalDomain}${path}`);
@@ -42,11 +42,11 @@ function buildUrl(path, queryParams, domain = 'open.douyin.com', requiresUserAut
42
42
  function isFormDataBody(body) {
43
43
  return typeof FormData !== 'undefined' && body instanceof FormData;
44
44
  }
45
- function buildHeaders(accessToken, ppeEnv, extraHeaders = {}, body, requiresUserAuth) {
45
+ function buildHeaders(accessToken, ppeEnv, extraHeaders = {}, body) {
46
46
  const headers = isFormDataBody(body)
47
47
  ? { ...extraHeaders }
48
48
  : { 'Content-Type': 'application/json', ...extraHeaders };
49
- if (accessToken && (!isCloudEnvironment() || requiresUserAuth)) {
49
+ if (accessToken) {
50
50
  headers['access-token'] = accessToken;
51
51
  }
52
52
  if (ppeEnv) {
@@ -98,11 +98,11 @@ async function callOpenAPI(params, options) {
98
98
  const envPpeEnv = process.env.APP_ENV?.startsWith('ppe_') ? process.env.APP_ENV : undefined;
99
99
  const ppeEnv = options?.ppeEnv || envPpeEnv;
100
100
  const extraHeaders = options?.logid ? { 'x-tt-logid': options.logid } : {};
101
- const url = buildUrl(path, queryParams, domain, requiresUserAuth);
102
- const headers = buildHeaders(accessToken, ppeEnv, extraHeaders, body, requiresUserAuth);
101
+ const url = buildUrl(path, queryParams, domain);
102
+ const headers = buildHeaders(accessToken, ppeEnv, extraHeaders, body);
103
103
  console.log(`[OpenAPI] ${method} ${url}`);
104
104
  console.log('[OpenAPI] Headers:', maskHeaders(headers), body);
105
- console.log('[OpenAPI] Is Cloud Environment:', isCloudEnvironment(), 'Requires User Auth:', Boolean(requiresUserAuth));
105
+ console.log('[OpenAPI] Is Cloud Environment:', isCloudEnvironment(), 'Requires User Auth:', Boolean(requiresUserAuth), 'Has Access Token:', Boolean(accessToken));
106
106
  const requestOptions = {
107
107
  method,
108
108
  headers,
@@ -1,5 +1,5 @@
1
- export { getAffiliateId, getAIUserDataInfo, getAIUserItemList, getAIUserProfile, getRealNameInfo, getRelatedId, getUserCertLabelsInfo, getUserCommentData, getUserConstellation, getUserFansData, getUserHashMobile, getUserItemData, getUserLikeData, getUserProfileData, getUserPublicInfo, getUserShareData } from './account';
2
- export type { AIUserBase, AIUserDataInfoParams, AIUserDataInfoResponse, AIUserInfo, AIUserItem, AIUserItemListParams, AIUserItemListResponse, AIUserProfileParams, AIUserProfileResponse, AgeRange, ConstellationResponse, GetRelatedIdRequest, GetRelatedIdResponse, HomepageDailyResult, HomepageDataParams, HomepageDateType, HomepageItemParams, HomepageResultResponse, RealNameInfoData, RealNameInfoParams, UserCertLabelInfo, UserCertLabelsInfoParams, UserCertLabelsInfoResponse, UserCertLabelStyle, UserHashMobileParams, UserHashMobileResponse, UserPublicInfo, UserPublicInfoParams, UserPublicInfoResponse } from './account';
1
+ export { getAffiliateId, getAIUserDataInfo, getAIUserItemList, getAIUserProfile, getRealNameInfo, getRelatedId, getUserCertLabelsInfo, getUserCommentData, getUserConstellation, getUserFansData, getUserHashMobile, getUserInterest, getUserItemData, getUserLikeData, getUserProfileData, getUserPublicInfo, getUserShareData } from './account';
2
+ export type { AIUserBase, AIUserDataInfoParams, AIUserDataInfoResponse, AIUserInfo, AIUserItem, AIUserItemListParams, AIUserItemListResponse, AIUserProfileParams, AIUserProfileResponse, AgeRange, ConstellationResponse, GetRelatedIdRequest, GetRelatedIdResponse, HomepageDailyResult, HomepageDataParams, HomepageDateType, HomepageItemParams, HomepageResultResponse, RealNameInfoData, RealNameInfoParams, UserCertLabelInfo, UserCertLabelsInfoParams, UserCertLabelsInfoResponse, UserCertLabelStyle, UserHashMobileParams, UserHashMobileResponse, UserInterestParams, UserInterestResponse, UserPublicInfo, UserPublicInfoParams, UserPublicInfoResponse } from './account';
3
3
  export { createActivity, modifyActivity, queryActivityInfo, queryActivityUserCompletionStatus } from './business';
4
4
  export type { ActivityTaskInfo, ActivityUserTaskStatus, CreateActivityRequest, CreateActivityResponse, ModifyActivityRequest, ModifyActivityResponse, QueryActivityInfoRequest, QueryActivityInfoResponse, QueryActivityUserCompletionStatusRequest, QueryActivityUserCompletionStatusResponse } from './business';
5
5
  export { getVideoCommentList, searchComment } from './comment';
@@ -14,8 +14,8 @@ export { getRoomRealTimeData, queryRoomData } from './live';
14
14
  export type { RoomDataQueryParams, RoomDataQueryRequest, RoomDataQueryResponse, RoomRealTimeQueryParams, RoomRealTimeRequest, RoomRealTimeResponse } from './live';
15
15
  export { getMusicCollectionList } from './music';
16
16
  export type { MusicCollectionItem, MusicCollectionListParams, MusicCollectionListResponse } from './music';
17
- export { getUserBasicData, getUserFollowing, topicSearch } from './platform';
18
- export type { FollowingListData, FollowingListParams, FollowingListResponse, FollowingUser, TopicSearchParams, TopicSearchResponse, UserBasicDataParams, UserBasicDataResponse, UserInfo } from './platform';
17
+ export { censorImage, censorText, getUserBasicData, getUserFollowing, topicSearch } from './platform';
18
+ export type { FollowingListData, FollowingListParams, FollowingListResponse, FollowingUser, ImageCensorParams, ImageCensorPredict, ImageCensorResponse, TextCensorParams, TextCensorPredict, TextCensorResponse, TextCensorResult, TopicSearchParams, TopicSearchResponse, UserBasicDataParams, UserBasicDataResponse, UserInfo } from './platform';
19
19
  export { checkFans, getFansFavourite, getFansProfile, getFansSource, getFriendList, getUserFansProfile } from './relation';
20
20
  export type { DistributionItem, FansCheckParams, FansCheckResponse, FansDataParams, FansFavouriteItem, FansFavouriteResponse, FansProfileResponse, FansSourceResponse, FriendListParams, FriendListResponse, FriendUser } from './relation';
21
21
  export { searchExperience, searchGeneral, searchLive, searchMusic, searchPoi, searchUser, searchVideo, searchVision } from './search';
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.searchVision = exports.searchVideo = exports.searchUser = exports.searchPoi = exports.searchMusic = exports.searchLive = exports.searchGeneral = exports.searchExperience = exports.getUserFansProfile = exports.getFriendList = exports.getFansSource = exports.getFansProfile = exports.getFansFavourite = exports.checkFans = exports.topicSearch = exports.getUserFollowing = exports.getUserBasicData = exports.getMusicCollectionList = exports.queryRoomData = exports.getRoomRealTimeData = exports.getHotList = exports.callOpenAPI = exports.getVideoPack = exports.getRecommend = exports.getHighQualityText = exports.getFollowHotWord = exports.getFollowFeed = exports.getFeed = exports.searchComment = exports.getVideoCommentList = exports.queryActivityUserCompletionStatus = exports.queryActivityInfo = exports.modifyActivity = exports.createActivity = exports.getUserShareData = exports.getUserPublicInfo = exports.getUserProfileData = exports.getUserLikeData = exports.getUserItemData = exports.getUserHashMobile = exports.getUserFansData = exports.getUserConstellation = exports.getUserCommentData = exports.getUserCertLabelsInfo = exports.getRelatedId = exports.getRealNameInfo = exports.getAIUserProfile = exports.getAIUserItemList = exports.getAIUserDataInfo = exports.getAffiliateId = void 0;
3
+ exports.searchPoi = exports.searchMusic = exports.searchLive = exports.searchGeneral = exports.searchExperience = exports.getUserFansProfile = exports.getFriendList = exports.getFansSource = exports.getFansProfile = exports.getFansFavourite = exports.checkFans = exports.topicSearch = exports.getUserFollowing = exports.getUserBasicData = exports.censorText = exports.censorImage = exports.getMusicCollectionList = exports.queryRoomData = exports.getRoomRealTimeData = exports.getHotList = exports.callOpenAPI = exports.getVideoPack = exports.getRecommend = exports.getHighQualityText = exports.getFollowHotWord = exports.getFollowFeed = exports.getFeed = exports.searchComment = exports.getVideoCommentList = exports.queryActivityUserCompletionStatus = exports.queryActivityInfo = exports.modifyActivity = exports.createActivity = exports.getUserShareData = exports.getUserPublicInfo = exports.getUserProfileData = exports.getUserLikeData = exports.getUserItemData = exports.getUserInterest = exports.getUserHashMobile = exports.getUserFansData = exports.getUserConstellation = exports.getUserCommentData = exports.getUserCertLabelsInfo = exports.getRelatedId = exports.getRealNameInfo = exports.getAIUserProfile = exports.getAIUserItemList = exports.getAIUserDataInfo = exports.getAffiliateId = void 0;
4
+ exports.searchVision = exports.searchVideo = exports.searchUser = void 0;
4
5
  var account_1 = require("./account");
5
6
  Object.defineProperty(exports, "getAffiliateId", { enumerable: true, get: function () { return account_1.getAffiliateId; } });
6
7
  Object.defineProperty(exports, "getAIUserDataInfo", { enumerable: true, get: function () { return account_1.getAIUserDataInfo; } });
@@ -13,6 +14,7 @@ Object.defineProperty(exports, "getUserCommentData", { enumerable: true, get: fu
13
14
  Object.defineProperty(exports, "getUserConstellation", { enumerable: true, get: function () { return account_1.getUserConstellation; } });
14
15
  Object.defineProperty(exports, "getUserFansData", { enumerable: true, get: function () { return account_1.getUserFansData; } });
15
16
  Object.defineProperty(exports, "getUserHashMobile", { enumerable: true, get: function () { return account_1.getUserHashMobile; } });
17
+ Object.defineProperty(exports, "getUserInterest", { enumerable: true, get: function () { return account_1.getUserInterest; } });
16
18
  Object.defineProperty(exports, "getUserItemData", { enumerable: true, get: function () { return account_1.getUserItemData; } });
17
19
  Object.defineProperty(exports, "getUserLikeData", { enumerable: true, get: function () { return account_1.getUserLikeData; } });
18
20
  Object.defineProperty(exports, "getUserProfileData", { enumerable: true, get: function () { return account_1.getUserProfileData; } });
@@ -43,6 +45,8 @@ Object.defineProperty(exports, "queryRoomData", { enumerable: true, get: functio
43
45
  var music_1 = require("./music");
44
46
  Object.defineProperty(exports, "getMusicCollectionList", { enumerable: true, get: function () { return music_1.getMusicCollectionList; } });
45
47
  var platform_1 = require("./platform");
48
+ Object.defineProperty(exports, "censorImage", { enumerable: true, get: function () { return platform_1.censorImage; } });
49
+ Object.defineProperty(exports, "censorText", { enumerable: true, get: function () { return platform_1.censorText; } });
46
50
  Object.defineProperty(exports, "getUserBasicData", { enumerable: true, get: function () { return platform_1.getUserBasicData; } });
47
51
  Object.defineProperty(exports, "getUserFollowing", { enumerable: true, get: function () { return platform_1.getUserFollowing; } });
48
52
  Object.defineProperty(exports, "topicSearch", { enumerable: true, get: function () { return platform_1.topicSearch; } });
@@ -0,0 +1,73 @@
1
+ import type { CallOptions, OpenAPIResponse } from '../core';
2
+ export interface ImageCensorParams {
3
+ /** 小程序 app_id */
4
+ app_id: string;
5
+ /** 图片链接,与 `image_data` 二选一 */
6
+ image?: string;
7
+ /** base64 编码图片数据,与 `image` 二选一 */
8
+ image_data?: string;
9
+ }
10
+ export interface ImageCensorPredict {
11
+ /** 模型名称 */
12
+ model_name?: string;
13
+ /** 是否命中 */
14
+ hit?: boolean;
15
+ }
16
+ export interface ImageCensorResponse {
17
+ /** 日志 ID */
18
+ log_id?: string;
19
+ /** 图片审核结果 */
20
+ predicts?: ImageCensorPredict[];
21
+ }
22
+ /**
23
+ * 检测图片是否包含违法违规内容 V2
24
+ *
25
+ * - Path: `/api/apps/v1/censor/image/`
26
+ * - Capability: `ma.openapi.pictureDetectV2`
27
+ * - Scope: `apps.cencor.image`
28
+ * - 需要用户授权: 否(按表格 F 列配置)
29
+ */
30
+ export declare function censorImage(params: ImageCensorParams, options?: CallOptions): Promise<OpenAPIResponse<ImageCensorResponse>>;
31
+ export interface TextCensorParams {
32
+ /** 小程序 app_id */
33
+ app_id: string;
34
+ /** 待检测文本列表 */
35
+ content: string[];
36
+ }
37
+ export interface TextCensorPredict {
38
+ /** 命中目标 */
39
+ target?: string;
40
+ /** 置信度 */
41
+ prob?: number;
42
+ /** 是否命中 */
43
+ hit?: boolean;
44
+ /** 模型名称 */
45
+ model_name?: string;
46
+ }
47
+ export interface TextCensorResult {
48
+ /** 结果码 */
49
+ code?: number;
50
+ /** 数据 ID */
51
+ data_id?: string;
52
+ /** 结果描述 */
53
+ msg?: string;
54
+ /** 任务 ID */
55
+ task_id?: string;
56
+ /** 审核命中结果 */
57
+ predicts?: TextCensorPredict[];
58
+ }
59
+ export interface TextCensorResponse {
60
+ /** 日志 ID */
61
+ log_id?: string;
62
+ /** 文本审核结果列表 */
63
+ data?: TextCensorResult[];
64
+ }
65
+ /**
66
+ * 检测文本是否包含违法违规内容 V2
67
+ *
68
+ * - Path: `/api/apps/v1/censor/text/`
69
+ * - Capability: `dy.open.ma.openapi.textDetectV2`
70
+ * - Scope: `apps.censor.text`
71
+ * - 需要用户授权: 否(按表格 F 列配置)
72
+ */
73
+ export declare function censorText(params: TextCensorParams, options?: CallOptions): Promise<OpenAPIResponse<TextCensorResponse>>;
@@ -0,0 +1,37 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.censorImage = censorImage;
4
+ exports.censorText = censorText;
5
+ const core_1 = require("../core");
6
+ /**
7
+ * 检测图片是否包含违法违规内容 V2
8
+ *
9
+ * - Path: `/api/apps/v1/censor/image/`
10
+ * - Capability: `ma.openapi.pictureDetectV2`
11
+ * - Scope: `apps.cencor.image`
12
+ * - 需要用户授权: 否(按表格 F 列配置)
13
+ */
14
+ async function censorImage(params, options) {
15
+ return (0, core_1.callOpenAPI)({
16
+ path: '/api/apps/v1/censor/image/',
17
+ method: 'POST',
18
+ body: params,
19
+ domain: 'open.douyin.com',
20
+ }, options);
21
+ }
22
+ /**
23
+ * 检测文本是否包含违法违规内容 V2
24
+ *
25
+ * - Path: `/api/apps/v1/censor/text/`
26
+ * - Capability: `dy.open.ma.openapi.textDetectV2`
27
+ * - Scope: `apps.censor.text`
28
+ * - 需要用户授权: 否(按表格 F 列配置)
29
+ */
30
+ async function censorText(params, options) {
31
+ return (0, core_1.callOpenAPI)({
32
+ path: '/api/apps/v1/censor/text/',
33
+ method: 'POST',
34
+ body: params,
35
+ domain: 'open.douyin.com',
36
+ }, options);
37
+ }
@@ -1,5 +1,7 @@
1
1
  export { topicSearch } from './topic';
2
2
  export type { TopicSearchParams, TopicSearchResponse } from './topic';
3
+ export { censorImage, censorText } from './censor';
4
+ export type { ImageCensorParams, ImageCensorPredict, ImageCensorResponse, TextCensorParams, TextCensorPredict, TextCensorResponse, TextCensorResult } from './censor';
3
5
  export { getUserFollowing } from './following';
4
6
  export type { FollowingListParams, FollowingListResponse, FollowingListData, FollowingUser } from './following';
5
7
  export { getUserBasicData } from './user-basic';
@@ -1,8 +1,11 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getUserBasicData = exports.getUserFollowing = exports.topicSearch = void 0;
3
+ exports.getUserBasicData = exports.getUserFollowing = exports.censorText = exports.censorImage = exports.topicSearch = void 0;
4
4
  var topic_1 = require("./topic");
5
5
  Object.defineProperty(exports, "topicSearch", { enumerable: true, get: function () { return topic_1.topicSearch; } });
6
+ var censor_1 = require("./censor");
7
+ Object.defineProperty(exports, "censorImage", { enumerable: true, get: function () { return censor_1.censorImage; } });
8
+ Object.defineProperty(exports, "censorText", { enumerable: true, get: function () { return censor_1.censorText; } });
6
9
  var following_1 = require("./following");
7
10
  Object.defineProperty(exports, "getUserFollowing", { enumerable: true, get: function () { return following_1.getUserFollowing; } });
8
11
  var user_basic_1 = require("./user-basic");
@@ -0,0 +1,36 @@
1
+ import type { CallOptions, OpenAPIResponse } from '../core';
2
+ export interface UploadSitemapRequest {
3
+ /** 小程序 app_id */
4
+ app_id: string;
5
+ /** 页面路径列表 */
6
+ page_paths: string[];
7
+ }
8
+ export interface DeleteIndexRequest {
9
+ /** 小程序 app_id */
10
+ app_id: string;
11
+ /** 在控制台显示的文件名称 */
12
+ name: string;
13
+ /** 待删除路径集合 */
14
+ path_list: string[];
15
+ }
16
+ export interface WebSearchOperationResponse {
17
+ err_no: number;
18
+ err_msg: string;
19
+ log_id: string;
20
+ }
21
+ /**
22
+ * 提交小程序页面路径
23
+ * - Path: `/api/apps/v1/search/upload_sitemap/`
24
+ * - Capability: `ma.web.search`
25
+ * - Scope: `ma.search`
26
+ * - 需要用户授权: `否`
27
+ */
28
+ export declare function uploadSitemap(params: UploadSitemapRequest, options?: CallOptions): Promise<OpenAPIResponse<WebSearchOperationResponse>>;
29
+ /**
30
+ * 删除索引
31
+ * - Path: `/api/apps/v1/search/delete_index/`
32
+ * - Capability: `ma.web.search`
33
+ * - Scope: `ma.search`
34
+ * - 需要用户授权: `否`
35
+ */
36
+ export declare function deleteIndex(params: DeleteIndexRequest, options?: CallOptions): Promise<OpenAPIResponse<WebSearchOperationResponse>>;
@@ -0,0 +1,35 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.uploadSitemap = uploadSitemap;
4
+ exports.deleteIndex = deleteIndex;
5
+ const core_1 = require("../core");
6
+ /**
7
+ * 提交小程序页面路径
8
+ * - Path: `/api/apps/v1/search/upload_sitemap/`
9
+ * - Capability: `ma.web.search`
10
+ * - Scope: `ma.search`
11
+ * - 需要用户授权: `否`
12
+ */
13
+ async function uploadSitemap(params, options) {
14
+ return (0, core_1.callOpenAPI)({
15
+ path: '/api/apps/v1/search/upload_sitemap/',
16
+ method: 'POST',
17
+ body: params,
18
+ domain: 'open.douyin.com',
19
+ }, options);
20
+ }
21
+ /**
22
+ * 删除索引
23
+ * - Path: `/api/apps/v1/search/delete_index/`
24
+ * - Capability: `ma.web.search`
25
+ * - Scope: `ma.search`
26
+ * - 需要用户授权: `否`
27
+ */
28
+ async function deleteIndex(params, options) {
29
+ return (0, core_1.callOpenAPI)({
30
+ path: '/api/apps/v1/search/delete_index/',
31
+ method: 'POST',
32
+ body: params,
33
+ domain: 'open.douyin.com',
34
+ }, options);
35
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@open-dy/ai_coding_sdk",
3
- "version": "1.0.21",
3
+ "version": "1.0.23",
4
4
  "description": "AI Coding SDK — 抖音开放平台 OpenAPI 客户端与工具集",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -143,4 +143,4 @@
143
143
  "default": "./dist/ai_platform_llm/*.js"
144
144
  }
145
145
  }
146
- }
146
+ }
@@ -1,15 +0,0 @@
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>;
@@ -1,44 +0,0 @@
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
- }