@heybox/hb-sdk 0.6.8 → 0.6.9-alpha.0
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/CHANGELOG.md +14 -0
- package/dist/cli-chunks/{build-D4crgajb.cjs → build-9hbhrRbU.cjs} +4 -4
- package/dist/cli-chunks/{context-fRWWSXDj.cjs → context-7rmakzS_.cjs} +3 -3
- package/dist/cli-chunks/{create-BU_EFgDz.cjs → create-BkX4rtRP.cjs} +1 -1
- package/dist/cli-chunks/{dev-BrkChQ7v.cjs → dev-DiZGT4FQ.cjs} +6 -6
- package/dist/cli-chunks/{doctor-DZXVO4rL.cjs → doctor-BcpqXVRh.cjs} +1 -1
- package/dist/cli-chunks/{index-DxH41nsb.cjs → index-6HfcwZ_r.cjs} +2 -2
- package/dist/cli-chunks/{index-CSjJrnkO.cjs → index-DofTxdoX.cjs} +14 -14
- package/dist/cli-chunks/{login-DLVozxrs.cjs → login-DUiejZcD.cjs} +2 -2
- package/dist/cli-chunks/{project-vite-CwmMfCk3.cjs → project-vite-CfD8Bp1K.cjs} +1 -1
- package/dist/cli-chunks/{remote-CfpkkC9I.cjs → remote-A4-PKgOn.cjs} +456 -202
- package/dist/cli-chunks/{runtime-gate-CgN_v4Te.cjs → runtime-gate-BWlU-R4h.cjs} +1 -1
- package/dist/cli-chunks/{runtime-permission-env-B0jK9Rt1.cjs → runtime-permission-env-DKrhgVM3.cjs} +205 -49
- package/dist/cli-chunks/{session-DB7ARwm4.cjs → session-D5u3XzHN.cjs} +1 -1
- package/dist/cli.cjs +1 -1
- package/dist/index.cjs.js +1 -1
- package/dist/index.esm.js +1 -1
- package/dist/miniapp-publish.cjs.js +205 -0
- package/dist/miniapp-publish.esm.js +201 -1
- package/dist/vite.cjs.js +1 -1
- package/dist/vite.esm.js +1 -1
- package/package.json +2 -2
- package/skill/references/api-root.md +1 -1
- package/skill/references/cli.md +8 -0
- package/skill/skill.json +4 -4
- package/types/miniapp-publish/index.d.ts +77 -0
|
@@ -2834,6 +2834,10 @@ const UPDATE_SQUARE_DISPLAY_API_PATH = '/mall/developer/user_miniprogram/square_
|
|
|
2834
2834
|
const LIST_USER_MINIPROGRAM_VERSION_API_PATH = '/mall/developer/user_miniprogram/version/list';
|
|
2835
2835
|
const FNV_OFFSET = 0x811c9dc5;
|
|
2836
2836
|
const FNV_PRIME = 0x01000193;
|
|
2837
|
+
const MINIAPP_UPLOAD_SESSION_REF_LENGTH = 10;
|
|
2838
|
+
const MINIAPP_ARTIFACT_SIGNATURE_MAGIC = 'heybox-user-miniprogram-artifact\0v1\0';
|
|
2839
|
+
const UNPAIRED_SURROGATE_PATTERN = /[\ud800-\udbff](?![\udc00-\udfff])|(^|[^\ud800-\udbff])[\udc00-\udfff]/;
|
|
2840
|
+
const textEncoder = new TextEncoder();
|
|
2837
2841
|
function normalizeRelativePath(relativePath) {
|
|
2838
2842
|
return String(relativePath || '')
|
|
2839
2843
|
.replace(/\\/g, '/')
|
|
@@ -2927,5 +2931,201 @@ function shouldUploadDistFile(relativePath) {
|
|
|
2927
2931
|
}
|
|
2928
2932
|
return true;
|
|
2929
2933
|
}
|
|
2934
|
+
/**
|
|
2935
|
+
* 校验构建产物路径和大小,并按路径 UTF-8 字节序排序。
|
|
2936
|
+
*
|
|
2937
|
+
* @param files 待处理的构建产物文件。
|
|
2938
|
+
* @returns 保留输入附加字段的有序文件列表。
|
|
2939
|
+
* @throws 路径不规范、路径重复或文件大小非法时抛出错误。
|
|
2940
|
+
*/
|
|
2941
|
+
function prepareMiniappArtifactFiles(files) {
|
|
2942
|
+
if (files.length > 0xffffffff) {
|
|
2943
|
+
throw new Error('构建产物文件数量超出签名协议上限');
|
|
2944
|
+
}
|
|
2945
|
+
const usedPaths = new Set();
|
|
2946
|
+
const prepared = files.map(file => {
|
|
2947
|
+
const relativePath = normalizeMiniappArtifactRelativePath(file.relativePath);
|
|
2948
|
+
if (usedPaths.has(relativePath)) {
|
|
2949
|
+
throw new Error(`构建产物包含重复文件路径:${relativePath}`);
|
|
2950
|
+
}
|
|
2951
|
+
usedPaths.add(relativePath);
|
|
2952
|
+
validateArtifactFileSize(file.size, relativePath);
|
|
2953
|
+
return { ...file, relativePath };
|
|
2954
|
+
});
|
|
2955
|
+
return prepared.sort((left, right) => compareBytes(textEncoder.encode(left.relativePath), textEncoder.encode(right.relativePath)));
|
|
2956
|
+
}
|
|
2957
|
+
/**
|
|
2958
|
+
* 按服务端 session key 前缀校验最终上传路径的 UTF-8 字节长度。
|
|
2959
|
+
*
|
|
2960
|
+
* @param files 待上传的构建产物文件。
|
|
2961
|
+
* @param options 小程序和长度限制配置。
|
|
2962
|
+
* @returns 第一个超长路径的错误提示;全部合法时返回 `undefined`。
|
|
2963
|
+
*/
|
|
2964
|
+
function validateMiniappUploadPathLengths(files, options) {
|
|
2965
|
+
const maxLength = options.maxLength ?? ACTIVITY_UPLOAD_KEY_MAX_LENGTH;
|
|
2966
|
+
const prefix = `/u/${getMiniProgramUploadAlias(options.miniProgramId)}/${'x'.repeat(MINIAPP_UPLOAD_SESSION_REF_LENGTH)}/`;
|
|
2967
|
+
const prefixLength = textEncoder.encode(prefix).length;
|
|
2968
|
+
const tooLongFile = files.find(file => {
|
|
2969
|
+
const relativePath = normalizeMiniappArtifactRelativePath(file.relativePath);
|
|
2970
|
+
return prefixLength + textEncoder.encode(relativePath).length > maxLength;
|
|
2971
|
+
});
|
|
2972
|
+
return tooLongFile ? `文件路径过长,请缩短构建产物文件名或目录层级:${tooLongFile.relativePath}` : undefined;
|
|
2973
|
+
}
|
|
2974
|
+
/**
|
|
2975
|
+
* 创建 v1 整包签名头。
|
|
2976
|
+
*
|
|
2977
|
+
* @param fileCount 参与签名的文件数量。
|
|
2978
|
+
* @returns 包含协议标识和文件数量的字节数组。
|
|
2979
|
+
* @throws 文件数量超出协议范围时抛出错误。
|
|
2980
|
+
*/
|
|
2981
|
+
function createMiniappArtifactSignatureHeader(fileCount) {
|
|
2982
|
+
if (!Number.isInteger(fileCount) || fileCount < 0 || fileCount > 0xffffffff) {
|
|
2983
|
+
throw new Error('构建产物文件数量超出签名协议上限');
|
|
2984
|
+
}
|
|
2985
|
+
return concatBytes(textEncoder.encode(MINIAPP_ARTIFACT_SIGNATURE_MAGIC), encodeUint32BE(fileCount));
|
|
2986
|
+
}
|
|
2987
|
+
/**
|
|
2988
|
+
* 创建单个文件的 v1 framing header。
|
|
2989
|
+
*
|
|
2990
|
+
* @param file 已规范化或待校验的构建产物文件。
|
|
2991
|
+
* @returns 包含路径长度、路径和文件大小的字节数组。
|
|
2992
|
+
* @throws 文件路径或大小非法时抛出错误。
|
|
2993
|
+
*/
|
|
2994
|
+
function createMiniappArtifactFileHeader(file) {
|
|
2995
|
+
const relativePath = normalizeMiniappArtifactRelativePath(file.relativePath);
|
|
2996
|
+
validateArtifactFileSize(file.size, relativePath);
|
|
2997
|
+
const pathBytes = textEncoder.encode(relativePath);
|
|
2998
|
+
return concatBytes(encodeUint32BE(pathBytes.length), pathBytes, encodeUint64BE(file.size));
|
|
2999
|
+
}
|
|
3000
|
+
/**
|
|
3001
|
+
* 校验服务端 session 文件映射,并计算仍需上传的文件。
|
|
3002
|
+
*
|
|
3003
|
+
* @param localFiles 本地构建产物文件。
|
|
3004
|
+
* @param serverFiles 服务端签发的文件映射。
|
|
3005
|
+
* @param uploadedKeys 服务端已确认上传成功的 key。
|
|
3006
|
+
* @returns 完整映射、待上传文件和已确认 key。
|
|
3007
|
+
* @throws 服务端映射与本地产物不一致时抛出错误。
|
|
3008
|
+
*/
|
|
3009
|
+
function resolveMiniappUploadSessionFiles(localFiles, serverFiles, uploadedKeys) {
|
|
3010
|
+
const preparedFiles = prepareMiniappArtifactFiles(localFiles);
|
|
3011
|
+
if (serverFiles.length !== preparedFiles.length) {
|
|
3012
|
+
throw new Error(`上传会话文件数量异常:期望 ${preparedFiles.length},实际 ${serverFiles.length}`);
|
|
3013
|
+
}
|
|
3014
|
+
const mappings = new Map();
|
|
3015
|
+
const serverSizes = new Map();
|
|
3016
|
+
const knownKeys = new Set();
|
|
3017
|
+
for (const serverFile of serverFiles) {
|
|
3018
|
+
const relativePath = normalizeMiniappArtifactRelativePath(serverFile.relative_path);
|
|
3019
|
+
if (mappings.has(relativePath)) {
|
|
3020
|
+
throw new Error(`上传会话返回重复文件路径:${relativePath}`);
|
|
3021
|
+
}
|
|
3022
|
+
const key = String(serverFile.key || '');
|
|
3023
|
+
if (!key) {
|
|
3024
|
+
throw new Error(`上传会话未返回文件 key:${relativePath}`);
|
|
3025
|
+
}
|
|
3026
|
+
if (knownKeys.has(key)) {
|
|
3027
|
+
throw new Error(`上传会话返回重复文件 key:${relativePath}`);
|
|
3028
|
+
}
|
|
3029
|
+
const size = Number(serverFile.size);
|
|
3030
|
+
if (!Number.isSafeInteger(size) || size < 0) {
|
|
3031
|
+
throw new Error(`上传会话返回文件大小异常:${relativePath}`);
|
|
3032
|
+
}
|
|
3033
|
+
mappings.set(relativePath, key);
|
|
3034
|
+
serverSizes.set(relativePath, size);
|
|
3035
|
+
knownKeys.add(key);
|
|
3036
|
+
}
|
|
3037
|
+
const files = preparedFiles.map(file => {
|
|
3038
|
+
const key = mappings.get(file.relativePath);
|
|
3039
|
+
if (!key) {
|
|
3040
|
+
throw new Error(`上传会话缺少文件映射:${file.relativePath}`);
|
|
3041
|
+
}
|
|
3042
|
+
if (serverSizes.get(file.relativePath) !== file.size) {
|
|
3043
|
+
throw new Error(`上传会话文件大小与本地构建不一致:${file.relativePath}`);
|
|
3044
|
+
}
|
|
3045
|
+
return { file, key };
|
|
3046
|
+
});
|
|
3047
|
+
const completed = new Set();
|
|
3048
|
+
for (const rawKey of uploadedKeys) {
|
|
3049
|
+
const key = String(rawKey || '');
|
|
3050
|
+
if (!knownKeys.has(key)) {
|
|
3051
|
+
throw new Error('上传会话返回了不属于当前产物的已上传文件');
|
|
3052
|
+
}
|
|
3053
|
+
completed.add(key);
|
|
3054
|
+
}
|
|
3055
|
+
return {
|
|
3056
|
+
files,
|
|
3057
|
+
missingFiles: files.filter(file => !completed.has(file.key)),
|
|
3058
|
+
uploadedKeys: [...completed],
|
|
3059
|
+
};
|
|
3060
|
+
}
|
|
3061
|
+
function normalizeMiniappArtifactRelativePath(relativePath) {
|
|
3062
|
+
const value = String(relativePath || '');
|
|
3063
|
+
if (!value) {
|
|
3064
|
+
throw new Error('构建产物包含空文件路径');
|
|
3065
|
+
}
|
|
3066
|
+
if (value.includes('\\')) {
|
|
3067
|
+
throw new Error(`构建产物路径不能包含反斜杠:${value}`);
|
|
3068
|
+
}
|
|
3069
|
+
if (value.startsWith('/') || value.endsWith('/') || /^[a-zA-Z]:\//.test(value)) {
|
|
3070
|
+
throw new Error(`构建产物必须使用相对文件路径:${value}`);
|
|
3071
|
+
}
|
|
3072
|
+
if (containsControlCharacter(value) || UNPAIRED_SURROGATE_PATTERN.test(value)) {
|
|
3073
|
+
throw new Error(`构建产物路径包含非法字符:${value}`);
|
|
3074
|
+
}
|
|
3075
|
+
if (value.split('/').some(segment => !segment || segment === '.' || segment === '..')) {
|
|
3076
|
+
throw new Error(`构建产物路径包含非法目录段:${value}`);
|
|
3077
|
+
}
|
|
3078
|
+
if (value.includes(',')) {
|
|
3079
|
+
throw new Error(`构建产物路径不能包含逗号:${value}`);
|
|
3080
|
+
}
|
|
3081
|
+
if (value.includes('*') || value.includes('?')) {
|
|
3082
|
+
throw new Error(`构建产物路径不能包含通配符:${value}`);
|
|
3083
|
+
}
|
|
3084
|
+
return value;
|
|
3085
|
+
}
|
|
3086
|
+
function containsControlCharacter(value) {
|
|
3087
|
+
for (const character of value) {
|
|
3088
|
+
const code = character.charCodeAt(0);
|
|
3089
|
+
if (code <= 0x1f || (code >= 0x7f && code <= 0x9f)) {
|
|
3090
|
+
return true;
|
|
3091
|
+
}
|
|
3092
|
+
}
|
|
3093
|
+
return false;
|
|
3094
|
+
}
|
|
3095
|
+
function validateArtifactFileSize(size, relativePath) {
|
|
3096
|
+
if (!Number.isSafeInteger(size) || size < 0) {
|
|
3097
|
+
throw new Error(`构建产物文件大小无效:${relativePath}`);
|
|
3098
|
+
}
|
|
3099
|
+
}
|
|
3100
|
+
function encodeUint32BE(value) {
|
|
3101
|
+
const bytes = new Uint8Array(4);
|
|
3102
|
+
new DataView(bytes.buffer).setUint32(0, value, false);
|
|
3103
|
+
return bytes;
|
|
3104
|
+
}
|
|
3105
|
+
function encodeUint64BE(value) {
|
|
3106
|
+
const bytes = new Uint8Array(8);
|
|
3107
|
+
const view = new DataView(bytes.buffer);
|
|
3108
|
+
view.setUint32(0, Math.floor(value / 0x100000000), false);
|
|
3109
|
+
view.setUint32(4, value % 0x100000000, false);
|
|
3110
|
+
return bytes;
|
|
3111
|
+
}
|
|
3112
|
+
function concatBytes(...parts) {
|
|
3113
|
+
const result = new Uint8Array(parts.reduce((total, part) => total + part.length, 0));
|
|
3114
|
+
let offset = 0;
|
|
3115
|
+
for (const part of parts) {
|
|
3116
|
+
result.set(part, offset);
|
|
3117
|
+
offset += part.length;
|
|
3118
|
+
}
|
|
3119
|
+
return result;
|
|
3120
|
+
}
|
|
3121
|
+
function compareBytes(left, right) {
|
|
3122
|
+
const length = Math.min(left.length, right.length);
|
|
3123
|
+
for (let index = 0; index < length; index += 1) {
|
|
3124
|
+
if (left[index] !== right[index]) {
|
|
3125
|
+
return left[index] - right[index];
|
|
3126
|
+
}
|
|
3127
|
+
}
|
|
3128
|
+
return left.length - right.length;
|
|
3129
|
+
}
|
|
2930
3130
|
|
|
2931
|
-
export { ACTIVITY_UPLOAD_KEY_MAX_LENGTH, CREATE_USER_MINIPROGRAM_API_PATH, CREATE_USER_MINIPROGRAM_LEADERBOARD_API_PATH, DELETE_USER_MINIPROGRAM_LEADERBOARD_API_PATH, DETAIL_USER_MINIPROGRAM_API_PATH, DETAIL_USER_MINIPROGRAM_LEADERBOARD_API_PATH, DEVELOPER_ENTITY_LIST_API_PATH, DEVELOPER_ENTITY_SWITCH_API_PATH, LIST_USER_MINIPROGRAM_API_PATH, LIST_USER_MINIPROGRAM_LEADERBOARD_API_PATH, LIST_USER_MINIPROGRAM_VERSION_API_PATH, MINIAPP_UPLOAD_BATCH_SIZE, MINIAPP_UPLOAD_SCOPE, MINIAPP_UPLOAD_TOTAL_SIZE_LIMIT_BYTES, PRECHECK_USER_MINIPROGRAM_VERSION_API_PATH, RELEASE_USER_MINIPROGRAM_VERSION_API_PATH, REOPEN_USER_MINIPROGRAM_API_PATH, SUBMIT_USER_MINIPROGRAM_AUDIT_API_PATH, TAKE_DOWN_USER_MINIPROGRAM_API_PATH, UPDATE_SQUARE_DISPLAY_API_PATH, UPDATE_USER_MINIPROGRAM_PREVIEW_ALLOWLIST_API_PATH, USER_MINIPROGRAM_ACCESS_STATUS_API_PATH, USER_MINIPROGRAM_PREVIEW_ALLOWLIST_API_PATH, USER_MINIPROGRAM_VERSION_PREVIEW_INFO_API_PATH, WITHDRAW_USER_MINIPROGRAM_VERSION_API_PATH, getMiniProgramUploadAlias, getMiniappUploadKey, isValidMiniappManifestVersion as isValidVersion, normalizeRelativePath, relativePathContainsNodeModulesSegment, shouldUploadDistFile, validateUploadPaths, validateUploadTotalSize };
|
|
3131
|
+
export { ACTIVITY_UPLOAD_KEY_MAX_LENGTH, CREATE_USER_MINIPROGRAM_API_PATH, CREATE_USER_MINIPROGRAM_LEADERBOARD_API_PATH, DELETE_USER_MINIPROGRAM_LEADERBOARD_API_PATH, DETAIL_USER_MINIPROGRAM_API_PATH, DETAIL_USER_MINIPROGRAM_LEADERBOARD_API_PATH, DEVELOPER_ENTITY_LIST_API_PATH, DEVELOPER_ENTITY_SWITCH_API_PATH, LIST_USER_MINIPROGRAM_API_PATH, LIST_USER_MINIPROGRAM_LEADERBOARD_API_PATH, LIST_USER_MINIPROGRAM_VERSION_API_PATH, MINIAPP_UPLOAD_BATCH_SIZE, MINIAPP_UPLOAD_SCOPE, MINIAPP_UPLOAD_TOTAL_SIZE_LIMIT_BYTES, PRECHECK_USER_MINIPROGRAM_VERSION_API_PATH, RELEASE_USER_MINIPROGRAM_VERSION_API_PATH, REOPEN_USER_MINIPROGRAM_API_PATH, SUBMIT_USER_MINIPROGRAM_AUDIT_API_PATH, TAKE_DOWN_USER_MINIPROGRAM_API_PATH, UPDATE_SQUARE_DISPLAY_API_PATH, UPDATE_USER_MINIPROGRAM_PREVIEW_ALLOWLIST_API_PATH, USER_MINIPROGRAM_ACCESS_STATUS_API_PATH, USER_MINIPROGRAM_PREVIEW_ALLOWLIST_API_PATH, USER_MINIPROGRAM_VERSION_PREVIEW_INFO_API_PATH, WITHDRAW_USER_MINIPROGRAM_VERSION_API_PATH, createMiniappArtifactFileHeader, createMiniappArtifactSignatureHeader, getMiniProgramUploadAlias, getMiniappUploadKey, isValidMiniappManifestVersion as isValidVersion, normalizeRelativePath, prepareMiniappArtifactFiles, relativePathContainsNodeModulesSegment, resolveMiniappUploadSessionFiles, shouldUploadDistFile, validateMiniappUploadPathLengths, validateUploadPaths, validateUploadTotalSize };
|
package/dist/vite.cjs.js
CHANGED
package/dist/vite.esm.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@heybox/hb-sdk",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.9-alpha.0",
|
|
4
4
|
"sideEffects": [
|
|
5
5
|
"./src/index.ts",
|
|
6
6
|
"./src/core/singleton.ts",
|
|
@@ -95,7 +95,7 @@
|
|
|
95
95
|
"vue": "^2.7.16",
|
|
96
96
|
"vite": "^8.0.12",
|
|
97
97
|
"vitest": "^3.2.4",
|
|
98
|
-
"@heybox/hb-api": "~1.25.
|
|
98
|
+
"@heybox/hb-api": "~1.25.11"
|
|
99
99
|
},
|
|
100
100
|
"publishConfig": {
|
|
101
101
|
"registry": "https://registry.npmjs.org/",
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
## Package metadata
|
|
24
24
|
|
|
25
25
|
- Package: `@heybox/hb-sdk`
|
|
26
|
-
- Version at generation time: `0.6.
|
|
26
|
+
- Version at generation time: `0.6.9-alpha.0`
|
|
27
27
|
- Public root export: `@heybox/hb-sdk`
|
|
28
28
|
- Protocol export: `@heybox/hb-sdk/protocol`
|
|
29
29
|
- Vite plugin export: `@heybox/hb-sdk/vite`
|
package/skill/references/cli.md
CHANGED
|
@@ -196,6 +196,14 @@ hb-sdk remote deploy --release-note "修复登录状态展示"
|
|
|
196
196
|
|
|
197
197
|
这条命令会完成检查、执行项目的 `scripts.build`、上传和提交审核,因此项目定义的类型检查仍会执行。默认在审核通过后等待手动发布;普通低风险版本可以追加 `--auto-publish`。完整命令见 `hb-sdk remote --help`,提交要求见[小程序工坊上架规则](https://docs.xiaoheihe.cn/hb_sdk/guide/mini-program-publishing-rules)。
|
|
198
198
|
|
|
199
|
+
构建产物上传从 `0.6.8` 起强制使用服务端上传 session,`0.6.7` 及更早版本不能继续部署,请先升级 `@heybox/hb-sdk`。deploy 从整包签名开始到上传结束都把 `dist/` 视为稳定输出,不要在此期间由其他进程修改构建目录;上传中断后可重新执行 deploy,服务端会按已确认回执恢复缺失文件。
|
|
200
|
+
|
|
201
|
+
普通 deploy 会按 API 环境、`miniProgramId` 和版本在本机缓存目录获取短文件锁,避免两个 CLI 进程同时构建并上传同一版本。进程异常退出后锁可按 PID 回收;缓存目录不可用时会降级为无锁执行,不影响上传主流程。`--from-version` 不执行本地构建和上传,因此不会获取该锁。
|
|
202
|
+
|
|
203
|
+
上传信息、上传凭证和上传回调按每批最多 50 个文件串行处理,批内保持 4 并发。CLI 每批获取一次仅授权当前 session 目录前缀的凭证,并校验服务端返回的 key 和 size 与本地文件完全一致;任何异常都会停止后续上传且不会提交审核。
|
|
204
|
+
|
|
205
|
+
普通构建上传时,CLI 会计算整包签名,并把相对路径和文件大小一起提交给服务端创建或恢复上传会话;同一账号下签名和文件清单一致时,服务端返回已有 session 与 `uploaded_keys`,CLI 只上传缺失文件。CLI 不保存本地上传会话缓存。构建产物变化时服务端会创建新的隔离目录,并尽力清理旧目录。上传回调在当前命令内失败会重试;仍失败时可重新执行 deploy,服务端根据 `uploaded_keys` 继续恢复,同 key 的 COS 重传是幂等的。
|
|
206
|
+
|
|
199
207
|
Before publishing, `hb-sdk remote deploy` verifies that the bound mini-program belongs to the current developer account. If it does not, the command stops and asks the user to switch accounts.
|
|
200
208
|
|
|
201
209
|
Agent rules:
|
package/skill/skill.json
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "hb-sdk",
|
|
3
|
-
"skillVersion": "0.6.
|
|
3
|
+
"skillVersion": "0.6.9-alpha.0+skill.a578097b3a33",
|
|
4
4
|
"sdk": {
|
|
5
5
|
"package": "@heybox/hb-sdk",
|
|
6
|
-
"version": "0.6.
|
|
7
|
-
"compatibility": "0.6.
|
|
6
|
+
"version": "0.6.9-alpha.0",
|
|
7
|
+
"compatibility": "0.6.9-alpha.0"
|
|
8
8
|
},
|
|
9
9
|
"source": "https://open.xiaoheihe.cn/agent-skills/hb-sdk",
|
|
10
|
-
"integrity": "sha256-
|
|
10
|
+
"integrity": "sha256-a578097b3a3302d8149c3a09107a71516d84861022ddc4adb6ef1d465a423bfa"
|
|
11
11
|
}
|
|
@@ -51,3 +51,80 @@ export interface ValidateUploadTotalSizeOptions {
|
|
|
51
51
|
}
|
|
52
52
|
export declare function validateUploadTotalSize(items: UploadSizeItem[], options?: ValidateUploadTotalSizeOptions): "构建产物总大小超过 100MB,请删除未引用资源或压缩图片后重新 deploy" | undefined;
|
|
53
53
|
export declare function shouldUploadDistFile(relativePath: string): boolean;
|
|
54
|
+
/** 参与整包签名和上传会话映射的构建产物文件。 */
|
|
55
|
+
export interface MiniappArtifactFile {
|
|
56
|
+
/** 使用 `/` 分隔的构建产物相对路径。 */
|
|
57
|
+
relativePath: string;
|
|
58
|
+
/** 文件字节数。 */
|
|
59
|
+
size: number;
|
|
60
|
+
}
|
|
61
|
+
/** 服务端上传会话返回的文件映射。 */
|
|
62
|
+
export interface MiniappUploadSessionFile {
|
|
63
|
+
/** 与创建会话时提交值一致的相对路径。 */
|
|
64
|
+
relative_path: string;
|
|
65
|
+
/** 服务端签发的完整上传 key。 */
|
|
66
|
+
key: string;
|
|
67
|
+
/** 服务端记录的文件字节数。 */
|
|
68
|
+
size: number;
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* 校验构建产物路径和大小,并按路径 UTF-8 字节序排序。
|
|
72
|
+
*
|
|
73
|
+
* @param files 待处理的构建产物文件。
|
|
74
|
+
* @returns 保留输入附加字段的有序文件列表。
|
|
75
|
+
* @throws 路径不规范、路径重复或文件大小非法时抛出错误。
|
|
76
|
+
*/
|
|
77
|
+
export declare function prepareMiniappArtifactFiles<T extends MiniappArtifactFile>(files: readonly T[]): (T & {
|
|
78
|
+
relativePath: string;
|
|
79
|
+
})[];
|
|
80
|
+
/**
|
|
81
|
+
* 按服务端 session key 前缀校验最终上传路径的 UTF-8 字节长度。
|
|
82
|
+
*
|
|
83
|
+
* @param files 待上传的构建产物文件。
|
|
84
|
+
* @param options 小程序和长度限制配置。
|
|
85
|
+
* @returns 第一个超长路径的错误提示;全部合法时返回 `undefined`。
|
|
86
|
+
*/
|
|
87
|
+
export declare function validateMiniappUploadPathLengths(files: readonly Pick<MiniappArtifactFile, 'relativePath'>[], options: {
|
|
88
|
+
miniProgramId: string;
|
|
89
|
+
maxLength?: number;
|
|
90
|
+
}): string | undefined;
|
|
91
|
+
/**
|
|
92
|
+
* 创建 v1 整包签名头。
|
|
93
|
+
*
|
|
94
|
+
* @param fileCount 参与签名的文件数量。
|
|
95
|
+
* @returns 包含协议标识和文件数量的字节数组。
|
|
96
|
+
* @throws 文件数量超出协议范围时抛出错误。
|
|
97
|
+
*/
|
|
98
|
+
export declare function createMiniappArtifactSignatureHeader(fileCount: number): Uint8Array<ArrayBuffer>;
|
|
99
|
+
/**
|
|
100
|
+
* 创建单个文件的 v1 framing header。
|
|
101
|
+
*
|
|
102
|
+
* @param file 已规范化或待校验的构建产物文件。
|
|
103
|
+
* @returns 包含路径长度、路径和文件大小的字节数组。
|
|
104
|
+
* @throws 文件路径或大小非法时抛出错误。
|
|
105
|
+
*/
|
|
106
|
+
export declare function createMiniappArtifactFileHeader(file: MiniappArtifactFile): Uint8Array<ArrayBuffer>;
|
|
107
|
+
/**
|
|
108
|
+
* 校验服务端 session 文件映射,并计算仍需上传的文件。
|
|
109
|
+
*
|
|
110
|
+
* @param localFiles 本地构建产物文件。
|
|
111
|
+
* @param serverFiles 服务端签发的文件映射。
|
|
112
|
+
* @param uploadedKeys 服务端已确认上传成功的 key。
|
|
113
|
+
* @returns 完整映射、待上传文件和已确认 key。
|
|
114
|
+
* @throws 服务端映射与本地产物不一致时抛出错误。
|
|
115
|
+
*/
|
|
116
|
+
export declare function resolveMiniappUploadSessionFiles<T extends MiniappArtifactFile>(localFiles: readonly T[], serverFiles: readonly MiniappUploadSessionFile[], uploadedKeys: readonly string[]): {
|
|
117
|
+
files: {
|
|
118
|
+
file: T & {
|
|
119
|
+
relativePath: string;
|
|
120
|
+
};
|
|
121
|
+
key: string;
|
|
122
|
+
}[];
|
|
123
|
+
missingFiles: {
|
|
124
|
+
file: T & {
|
|
125
|
+
relativePath: string;
|
|
126
|
+
};
|
|
127
|
+
key: string;
|
|
128
|
+
}[];
|
|
129
|
+
uploadedKeys: string[];
|
|
130
|
+
};
|