feat: manually mirror opencoze's code from bytedance

Change-Id: I09a73aadda978ad9511264a756b2ce51f5761adf
This commit is contained in:
fanlv
2025-07-20 17:36:12 +08:00
commit 890153324f
14811 changed files with 1923430 additions and 0 deletions

View File

@@ -0,0 +1,55 @@
/*
* Copyright 2025 coze-dev Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/** bot详情页来源目前只有bot和explore列表 */
export enum BotPageFromEnum {
Bot = 'bot', //bot列表
Explore = 'explore', //explore列表
Store = 'store',
Template = 'template',
}
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- 不得不 any
export type Obj = Record<string, any>;
/**
* 展示完整类型
*
* @example
* type Intersection = { a: string } & { b: number };
* type Result = Expand<Intersection>;
* // Result: { a: string; b: number }
*/
export type Expand<T extends Obj> = T extends infer U
? { [K in keyof U]: U[K] }
: never;
/**
* 只对特定字段做 required常用于修正服务端类型声明错误
*
* @example
* interface Agent {
* id?: string;
* name?: string;
* desc?: string
* }
* type Result = PartialRequired<Agent, 'id' | 'name'>;
*/
export type PartialRequired<T extends Obj, K extends keyof T> = Expand<
{
[P in K]-?: T[P];
} & Pick<T, Exclude<keyof T, K>>
>;

View File

@@ -0,0 +1,231 @@
/*
* Copyright 2025 coze-dev Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
declare namespace DataItem {
interface UserConnectItem {
platform: string;
profile_image_url: string;
expired_time: number;
expires_in: number;
platform_screen_name: string;
user_id: number;
platform_uid: string;
sec_platform_uid: string;
platform_app_id: number;
modify_time: number;
access_token: string;
open_id: string;
}
interface UserInfo {
app_id: number;
/**
* @deprecated 会因为溢出丢失精度,使用 user_id_str
*/
user_id: number;
user_id_str: string;
odin_user_type: number;
name: string;
screen_name: string;
avatar_url: string;
user_verified: boolean;
email?: string;
email_collected: boolean;
expend_attrs?: Record<string, unknown>;
phone_collected: boolean;
verified_content: string;
verified_agency: string;
is_blocked: number;
is_blocking: number;
bg_img_url: string;
gender: number;
media_id: number;
user_auth_info: string;
industry: string;
area: string;
can_be_found_by_phone: number;
mobile: string;
birthday: string;
description: string;
status: number;
new_user: number;
first_login_app: number;
session_key: string;
is_recommend_allowed: number;
recommend_hint_message: string;
followings_count: number;
followers_count: number;
visit_count_recent: number;
skip_edit_profile: number;
is_manual_set_user_info: boolean;
device_id: number;
country_code: number;
has_password: number;
share_to_repost: number;
user_decoration: string;
user_privacy_extend: number;
old_user_id: number;
old_user_id_str: string;
sec_user_id: string;
sec_old_user_id: string;
vcd_account: number;
vcd_relation: number;
can_bind_visitor_account: boolean;
is_visitor_account: boolean;
is_only_bind_ins: boolean;
user_device_record_status: number;
is_kids_mode: number;
source: string;
is_employee: boolean;
passport_enterprise_user_type: number;
need_device_create: number;
need_ttwid_migration: number;
user_auth_status: number;
user_safe_mobile_2fa: string;
safe_mobile_country_code: number;
lite_user_info_string: string;
lite_user_info_demotion: number;
app_user_info: {
user_unique_name?: string;
};
need_check_bind_status: boolean;
bui_audit_info?: {
audit_info: {
user_unique_name?: string;
avatar_url?: string;
name?: string;
[key: string]: unknown;
}; // Record<string, unknown>;
// int值。1审核中2审核通过3审核不通过
audit_status: 1 | 2 | 3;
details: Record<string, unknown>;
is_auditing: boolean;
last_update_time: number;
unpass_reason: string;
};
}
/**
* 发送验证码的返回数据结构
*/
interface SendCodeData {
mobile: string;
mobile_ticket: string;
retry_time: number;
}
interface bindWithEmailLoginParams {
access_token?: string;
access_token_secret?: string;
code?: string;
openid?: number;
profile_key?: string;
platform_app_id: number;
redirect_uri?: string;
extra_params?: object;
}
interface UserCheckResponse {
app_user_info?: null;
authType: number;
error_code?: number;
in_old_process?: boolean;
oauth_platforms?: string[] | null;
platform_user_names?: Record<string, unknown>;
userType?: number;
value_ticket: string;
}
interface ValidateCodeResponse {
ticket: string;
}
interface AuthorizeResponse {
token: string;
user_info: {
user_id: number;
app_id: number;
user_name: string;
screen_name: string;
mobile: string;
email: string;
avatar_url: string;
description: string;
create_time: number;
is_new_user: boolean;
is_new_connect: boolean;
session_key: string;
session_app_id: number;
safe_mobile: string;
};
}
interface AuthLoginParams {
platform_app_id: number;
code?: string;
access_token?: string;
access_token_secret?: string;
openid?: string;
profile_key?: string;
login_only?: boolean;
extra_params?: object;
}
interface bindWithEmailLoginParams {
access_token?: string;
access_token_secret?: string;
code?: string;
openid?: number;
profile_key?: string;
platform_app_id: number;
redirect_uri?: string;
extra_params?: object;
}
interface bindWithMobileLoginParams {
code?: string;
profile_key?: string;
access_token?: string;
platform_app_id: number;
platform: string;
need_mobile?: number;
check_mobile?: number;
change_bind?: number;
extra_params?: object;
}
interface ResetByEmailTicket {
ticket: string;
}
interface AuditItem {
pass: boolean;
title: string;
text: string[];
reason: string[] | null;
}
interface CancelCheckResponse {
business_audit: AuditItem;
cancel_ticket: string;
common_audit: AuditItem;
error_code: number;
protocol: string;
punish_audit: AuditItem;
user_permission_audit: AuditItem;
}
interface UploadAvatarResponse {
web_uri: string;
}
}

View File

@@ -0,0 +1,67 @@
/*
* Copyright 2025 coze-dev Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/// <reference types='./data_item' />
/// <reference types='./navigator' />
/// <reference types='./window' />
/// <reference types='@coze-arch/bot-env/typings' />
declare module '*.jpeg' {
const value: string;
export default value;
}
declare module '*.jpg' {
const value: string;
export default value;
}
declare module '*.webp' {
const value: string;
export default value;
}
declare module '*.gif' {
const value: string;
export default value;
}
declare module '*.png' {
const value: string;
export default value;
}
declare module '*.less' {
const resource: { [key: string]: string };
export = resource;
}
declare module '*.css' {
const resource: { [key: string]: string };
export = resource;
}
declare module '*.svg' {
export const ReactComponent: React.FunctionComponent<
React.SVGProps<SVGSVGElement>
>;
/**
* The default export type depends on the svgDefaultExport config,
* it can be a string or a ReactComponent
* */
const content: any;
export default content;
}

View File

@@ -0,0 +1,19 @@
/*
* Copyright 2025 coze-dev Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
interface Navigator {
standalone: boolean;
}

View File

@@ -0,0 +1,36 @@
/*
* Copyright 2025 coze-dev Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// copy from packages/arch/bot-typings/src/teamspace.ts
export interface DynamicParams extends Record<string, string | undefined> {
space_id?: string;
bot_id?: string;
plugin_id?: string;
workflow_id?: string;
dataset_id?: string;
doc_id?: string;
tool_id?: string;
invite_key?: string;
product_id?: string;
mock_set_id?: string;
conversation_id: string;
commit_version?: string;
/** 社会场景 */
scene_id?: string;
post_id?: string;
project_id?: string;
}

View File

@@ -0,0 +1,68 @@
/*
* Copyright 2025 coze-dev Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
declare type MicroComponentsMapItem = {
version: string;
cdnUrl: string;
};
interface Window {
/**
* IDE plugin iframe 中挂载的用于卸载的方法
*/
editorDispose?: any;
MonacoEnvironment?: any;
tt?: {
miniProgram: {
postMessage: (param: {
data?: any;
success?: (res) => void;
fail?: (err) => void;
}) => void;
redirectTo: (param: {
url?: string;
success?: (res) => void;
fail?: (err) => void;
}) => void;
navigateTo: (param: {
url?: string;
success?: (res) => void;
fail?: (err) => void;
}) => void;
reLaunch: (param: {
url?: string;
success?: (res) => void;
fail?: (err) => void;
}) => void;
navigateBack: (param?: {
delta?: number;
success?: (res) => void;
fail?: (err) => void;
}) => void;
getEnv: (res) => void;
};
};
__cozeapp__?: {
props: Record<string, unknown>;
setLoading?: (loading: boolean) => void;
};
}
declare namespace process {
const env: {
[key: string]: string;
};
}