Files
codemao-cli/src/api.js
T
codemao-cli eaf267401f feat: add blocks command, 97 known block types with descriptions
- codemao blocks [filter] - 列出所有已知积木类型
- bcm blocks now shows Chinese descriptions
- 97 种积木类型覆盖事件/动作/外观/控制/侦测/运算/变量/声音/画笔/AI/硬件
2026-05-02 23:59:57 +08:00

224 lines
14 KiB
JavaScript

/**
* 编程猫 API 端点注册表
*/
const DOMAINS = require('./domains');
const ENDPOINTS = [
// ═══════════════ 创作服务 ═══════════════
{ method: 'GET', path: '/neko/sample/list', auth: false, desc: '示例作品列表', host: 'creation', params: 'subject_id' },
{ method: 'GET', path: '/neko/sample/detail', auth: false, desc: '示例作品详情', host: 'creation', params: 'id' },
{ method: 'GET', path: '/neko/works/', auth: true, desc: '用户作品列表', host: 'creation' },
{ method: 'POST', path: '/neko/works/', auth: true, desc: '创建作品', host: 'creation' },
{ method: 'GET', path: '/neko/works/{id}', auth: true, desc: '作品详情', host: 'creation' },
{ method: 'PUT', path: '/neko/works/{id}', auth: true, desc: '更新作品', host: 'creation' },
{ method: 'GET', path: '/neko/works/archive/{id}', auth: true, desc: '作品归档', host: 'creation' },
{ method: 'POST', path: '/neko/works/{id}/publish', auth: true, desc: '发布作品', host: 'creation' },
{ method: 'GET', path: '/neko/community/work/detail/', auth: true, desc: '社区作品详情', host: 'creation', params: 'work_id' },
{ method: 'POST', path: '/neko/community/work/publish/', auth: true, desc: '发布到社区', host: 'creation' },
{ method: 'GET', path: '/neko/community/player/published-work-detail/', auth: true, desc: '已发布作品', host: 'creation', params: 'work_id' },
{ method: 'GET', path: '/neko/package/list', auth: true, desc: '积木包列表', host: 'creation' },
{ method: 'GET', path: '/neko/package/{id}', auth: true, desc: '积木包详情', host: 'creation' },
{ method: 'GET', path: '/neko/ranking-list/', auth: true, desc: '排行榜', host: 'creation' },
{ method: 'POST', path: '/neko/ranking-list/record', auth: true, desc: '提交排行记录', host: 'creation' },
{ method: 'GET', path: '/neko/ranking-list/{id}', auth: true, desc: '排行榜详情', host: 'creation' },
{ method: 'DELETE', path: '/neko/ranking-list/clear', auth: true, desc: '清空排行', host: 'creation', params: 'id' },
{ method: 'GET', path: '/neko/ranking-list/record/list', auth: true, desc: '排行记录列表', host: 'creation', params: 'id' },
{ method: 'GET', path: '/neko/ai-painting/templates', auth: true, desc: 'AI 绘画模板', host: 'creation', params: 'type' },
{ method: 'POST', path: '/neko/ai-painting/match', auth: true, desc: 'AI 绘画匹配', host: 'creation' },
{ method: 'GET', path: '/neko/inspiration-pool', auth: true, desc: '灵感池', host: 'creation' },
{ method: 'GET', path: '/neko/material/categories', auth: true, desc: '素材分类', host: 'creation', params: 'type' },
{ method: 'GET', path: '/neko/material/list', auth: true, desc: '素材列表', host: 'creation' },
{ method: 'GET', path: '/neko/user/status', auth: true, desc: '用户状态', host: 'creation' },
{ method: 'GET', path: '/neko/cv/list/variables/{id}', auth: true, desc: '云变量列表', host: 'creation' },
{ method: 'POST', path: '/neko/cv/add/variables', auth: true, desc: '添加云变量', host: 'creation' },
{ method: 'POST', path: '/neko/cv/delete/variables', auth: true, desc: '删除云变量', host: 'creation' },
{ method: 'POST', path: '/neko/cv/sync/', auth: true, desc: '同步云变量', host: 'creation' },
{ method: 'GET', path: '/neko/web/pack/status', auth: true, desc: '打包状态', host: 'creation' },
{ method: 'POST', path: '/neko/web/pack', auth: true, desc: 'Web 打包', host: 'creation' },
{ method: 'GET', path: '/neko/web/pack/limit', auth: true, desc: '打包限制', host: 'creation' },
{ method: 'POST', path: '/neko/text2img/prompt', auth: true, desc: '文生图提示词', host: 'creation' },
{ method: 'GET', path: '/neko/text2img/prompt', auth: true, desc: '获取提示词', host: 'creation' },
{ method: 'POST', path: '/neko/course/user/progress', auth: true, desc: '课程进度', host: 'creation' },
{ method: 'GET', path: '/neko/course/user/course-work', auth: true, desc: '课程作品', host: 'creation' },
{ method: 'POST', path: '/neko/teaching-plan/save/team/work', auth: true, desc: '教学计划保存', host: 'creation' },
{ method: 'POST', path: '/neko/teaching-plan/add/opr/log', auth: true, desc: '教学计划日志', host: 'creation' },
{ method: 'GET', path: '/neko/teaching-plan/list/opr/log', auth: true, desc: '教学计划日志列表', host: 'creation' },
{ method: 'GET', path: '/neko/teaching-plan/work/editing-status/{id}', auth: true, desc: '编辑状态', host: 'creation' },
{ method: 'GET', path: '/common/users/detail', auth: true, desc: '用户详情', host: 'creation' },
{ method: 'GET', path: '/common/api/neko/text2img/usage-left', auth: true, desc: '文生图剩余次数', host: 'creation' },
{ method: 'GET', path: '/coconut/clouddb/currentTime', auth: false, desc: '云数据库时间', host: 'creation' },
{ method: 'GET', path: '/public-api/cone-ai/token', auth: true, desc: 'AI Token', host: 'creation' },
// ═══════════════ 主 API ═══════════════
{ method: 'GET', path: '/tiger/v3/web/accounts/profile', auth: true, desc: '用户信息', host: 'api' },
{ method: 'POST', path: '/tiger/v3/web/accounts/logout', auth: true, desc: '退出登录', host: 'api' },
{ method: 'GET', path: '/tiger/kitten/public-course/courses/', auth: true, desc: '公开课列表', host: 'api' },
{ method: 'GET', path: '/tiger/kitten/wechat/user', auth: true, desc: '微信用户信息', host: 'api' },
{ method: 'GET', path: '/tiger/nemo/miao-codes', auth: false, desc: '喵码', host: 'api', params: 'token' },
{ method: 'GET', path: '/tiger/kitten/public-course/progress', auth: true, desc: '公开课进度', host: 'api' },
{ method: 'GET', path: '/tiger/kitten/public-course/status', auth: true, desc: '公开课状态', host: 'api' },
{ method: 'GET', path: '/kitten/work/ide/load/{id}', auth: true, desc: '加载作品(IDE)', host: 'api' },
{ method: 'GET', path: '/kitten/work/load', auth: true, desc: '加载作品', host: 'api', params: 'work_token' },
{ method: 'GET', path: '/kitten/work/key', auth: true, desc: '作品密钥', host: 'api', params: 'work_id' },
{ method: 'POST', path: '/kitten/work/bcm/decode', auth: true, desc: 'BCM 解码', host: 'api' },
{ method: 'POST', path: '/kitten/work/translate', auth: true, desc: '作品翻译', host: 'api' },
{ method: 'GET', path: '/kitten/work/checkname', auth: true, desc: '检查名称', host: 'api', params: 'name' },
{ method: 'GET', path: '/kitten/common/work/{id}', auth: true, desc: '通用作品信息', host: 'api' },
{ method: 'GET', path: '/kitten/sample/{id}', auth: true, desc: '示例详情', host: 'api' },
{ method: 'GET', path: '/kitten/activity/latest', auth: true, desc: '最新活动', host: 'api' },
{ method: 'GET', path: '/kitten/cv/dashboard/summary', auth: true, desc: '云变量概览', host: 'api' },
{ method: 'GET', path: '/kitten/cv/dashboard/capacity/correction', auth: true, desc: '容量校正', host: 'api' },
{ method: 'GET', path: '/kitten/cv/dashboard/capacity/expand', auth: true, desc: '容量扩展', host: 'api' },
{ method: 'GET', path: '/kitten/cv/dashboard/works/', auth: true, desc: '云变量作品', host: 'api' },
{ method: 'GET', path: '/kitten/cv/variables-limit/check', auth: true, desc: '变量限制检查', host: 'api' },
{ method: 'GET', path: '/kitten/materials/lesson/student/all', auth: true, desc: '学生素材', host: 'api' },
{ method: 'GET', path: '/kitten/lesson/attendance/current', auth: true, desc: '当前考勤', host: 'api' },
{ method: 'GET', path: '/kitten/v4/work/ide/list', auth: true, desc: 'IDE 作品列表', host: 'api', params: 'published_status' },
// ═══════════════ 开放服务 ═══════════════
{ method: 'GET', path: '/tiger/kitten/public-course/courses/', auth: false, desc: '公开课', host: 'open' },
{ method: 'GET', path: '/tiger/online/check', auth: false, desc: '在线检查', host: 'open' },
// ═══════════════ AI 服务 ═══════════════
{ method: 'POST', path: '/ai/tts/generate', auth: true, desc: 'TTS 语音生成', host: 'ai' },
{ method: 'GET', path: '/ai/tts/status', auth: true, desc: 'TTS 状态', host: 'ai', params: 'taskId' },
{ method: 'POST', path: '/neko/image-classify', auth: true, desc: '图像分类', host: 'socketcv' },
{ method: 'GET', path: '/neko/image-classify/list', auth: true, desc: '分类列表', host: 'socketcv' },
// ═══════════════ CDN 资源 (无认证) ═══════════════
{ method: 'GET', path: '/neko/bcm/kn-default-v-0.13.1.bcmkn', auth: false, desc: '默认竖屏模板', host: 'cdn' },
{ method: 'GET', path: '/neko/bcm/kn-default-h-0.13.1.bcmkn', auth: false, desc: '默认横屏模板', host: 'cdn' },
{ method: 'GET', path: '/neko/bcm/kn-kids-default-v-0.13.1.bcmknk', auth: false, desc: 'Kids竖屏模板', host: 'cdn' },
{ method: 'GET', path: '/neko/bcm/kn-kids-default-h-0.13.1.bcmknk', auth: false, desc: 'Kids横屏模板', host: 'cdn' },
{ method: 'GET', path: '/neko/bcm/kn-exam-default-v-0.18.0.bcmkn', auth: false, desc: '考试竖屏模板', host: 'cdn' },
{ method: 'GET', path: '/neko/bcm/kn-exam-default-h-0.18.0.bcmkn', auth: false, desc: '考试横屏模板', host: 'cdn' },
{ method: 'GET', path: '/neko/json/kitten_n_update_info.json', auth: false, desc: '更新信息', host: 'cdn' },
{ method: 'GET', path: '/neko/json/gai_text_to_image_package_id.json', auth: false, desc: '文生图配置', host: 'cdn' },
];
module.exports = { ENDPOINTS, DOMAINS };
// 已知积木类型 (从编辑器代码逆向)
const BLOCK_TYPES = {
// 事件
'sprite_on_tap': '角色点击事件',
'event_when_run': '当绿旗被点击',
'event_when_key': '当按下按键',
'event_when_receive': '当接收到广播',
'event_broadcast': '广播消息',
'event_broadcast_wait': '广播并等待',
'scene_on_tap': '场景点击事件',
'stage_on_tap': '舞台点击事件',
'self_on_start_as_clone': '当作为克隆体启动',
'self_listen_with_param': '监听事件',
// 动作
'move': '移动',
'turn_right': '右转',
'turn_left': '左转',
'goto_xy': '移到坐标',
'glide_to_xy': '滑行到坐标',
'set_x': '设置 x',
'set_y': '设置 y',
'change_x': 'x 增加',
'change_y': 'y 增加',
'point_dir': '面向方向',
'point_towards': '面向角色',
'if_on_edge_bounce': '碰边缘反弹',
'set_rotation_style': '设置旋转方式',
// 外观
'show': '显示',
'hide': '隐藏',
'say': '说话',
'say_for': '说话(限时)',
'self_prev_next_style': '切换造型',
'self_set_style': '设置造型',
'set_size': '设置大小',
'change_size': '大小增加',
'set_effect': '设置特效',
'change_effect': '特效增加',
'clear_effects': '清除特效',
'go_to_layer': '移到图层',
// 控制
'wait': '等待',
'repeat': '重复',
'forever': '重复执行',
'if': '如果',
'if_else': '如果...否则',
'repeat_until': '重复直到',
'wait_until': '等待直到',
'stop': '停止',
'clone': '克隆',
'dispose_clone': '删除克隆体',
// 侦测
'touching': '碰到角色',
'touching_color': '碰到颜色',
'color_touching_color': '颜色碰颜色',
'ask': '询问',
'get_mouse_x': '鼠标 x',
'get_mouse_y': '鼠标 y',
'is_mouse_down': '按下鼠标',
'get_timer': '计时器',
'reset_timer': '重置计时器',
// 运算
'add': '加法',
'subtract': '减法',
'multiply': '乘法',
'divide': '除法',
'random': '随机数',
'gt': '大于',
'lt': '小于',
'equals': '等于',
'and': '且',
'or': '或',
'not': '不是',
'join': '连接',
'length': '长度',
'mod': '取余',
'round': '四舍五入',
'math_op': '数学运算',
// 变量
'set_variable': '设置变量',
'change_variable': '变量增加',
'get_variable': '获取变量',
'add_to_list': '添加到列表',
'delete_of_list': '删除列表项',
'insert_at_list': '插入列表项',
'replace_at_list': '替换列表项',
'item_of_list': '列表项',
'item_num_of_list': '列表项编号',
'length_of_list': '列表长度',
'list_contains': '列表包含',
// 声音
'play_sound': '播放声音',
'stop_all_sounds': '停止所有声音',
// 画笔
'pen_down': '落笔',
'pen_up': '抬笔',
'pen_clear': '清除画笔',
'pen_set_color': '设置画笔颜色',
'pen_set_size': '设置画笔粗细',
// AI
'ai_text_actor': 'AI 文本识别(角色)',
'ai_text_photo': 'AI 拍照识别',
'ai_text_result': 'AI 识别结果',
'ai_chat_ask': 'AI 聊天提问',
'ai_chat_answer': 'AI 聊天回答',
// 硬件
'microbit_display': 'micro:bit 显示',
'microbit_get_button': 'micro:bit 按钮',
'tudao_motor': '途道电机',
'tudao_servo': '途道舵机',
};
module.exports = { ENDPOINTS, DOMAINS, BLOCK_TYPES };