openxiangda 1.0.268 → 1.0.270
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/README.md +20 -1
- package/lib/cli.js +417 -24
- package/lib/config.js +60 -56
- package/lib/design-gates.js +18 -0
- package/lib/migration-advice.js +19 -0
- package/lib/release-plan.js +2 -0
- package/lib/workspace-init.js +11 -4
- package/openxiangda-skills/SKILL.md +8 -0
- package/openxiangda-skills/references/architecture-patterns.md +218 -218
- package/openxiangda-skills/references/component-guide.md +122 -122
- package/openxiangda-skills/references/openxiangda-api.md +12 -0
- package/openxiangda-skills/references/platform-data-model.md +285 -285
- package/openxiangda-skills/references/resource-manifest-cheatsheet.md +32 -2
- package/openxiangda-skills/references/troubleshooting.md +224 -224
- package/openxiangda-skills/references/webhooks.md +213 -0
- package/openxiangda-skills/references/workspace-state.md +1 -1
- package/openxiangda-skills/skills/openxiangda-core/SKILL.md +1 -1
- package/openxiangda-skills/skills/openxiangda-workflow-automation/SKILL.md +3 -0
- package/package.json +26 -23
- package/packages/sdk/dist/{ProcessPreview-Cyk6uv-w.d.mts → ProcessPreview-DSUIJi5V.d.mts} +2 -3
- package/packages/sdk/dist/{ProcessPreview-Cyk6uv-w.d.ts → ProcessPreview-DSUIJi5V.d.ts} +2 -3
- package/packages/sdk/dist/components/index.d.mts +41 -42
- package/packages/sdk/dist/components/index.d.ts +41 -42
- package/packages/sdk/dist/{dataManagementApi-CE8Zyj3a.d.ts → dataManagementApi-Ro9itwm8.d.ts} +2 -2
- package/packages/sdk/dist/{dataManagementApi-4fSaCA5t.d.mts → dataManagementApi-p_HOhQnA.d.mts} +2 -2
- package/packages/sdk/dist/runtime/index.d.mts +3 -4
- package/packages/sdk/dist/runtime/index.d.ts +3 -4
- package/packages/sdk/dist/runtime/react.d.mts +5 -5
- package/packages/sdk/dist/runtime/react.d.ts +5 -5
- package/packages/sdk/src/build-source/scripts/utils/mime-types.mjs +70 -70
- package/packages/sdk/src/build-source/scripts/utils/oss-client.mjs +128 -128
- package/packages/sdk/src/build-source/scripts/utils/progress.mjs +57 -57
- package/templates/openxiangda-react-spa/.cursor/rules/openxiangda-resources.mdc +1 -0
- package/templates/openxiangda-react-spa/.cursor/rules/openxiangda.mdc +6 -0
- package/templates/openxiangda-react-spa/.qoder/rules/openxiangda-resources.md +1 -0
- package/templates/openxiangda-react-spa/.qoder/rules/openxiangda.md +6 -0
- package/templates/openxiangda-react-spa/AGENTS.md +8 -0
- package/templates/sy-lowcode-app-workspace/.cursor/rules/openxiangda-resources.mdc +2 -0
- package/templates/sy-lowcode-app-workspace/.cursor/rules/openxiangda.mdc +7 -1
- package/templates/sy-lowcode-app-workspace/.qoder/rules/openxiangda-resources.md +1 -0
- package/templates/sy-lowcode-app-workspace/.qoder/rules/openxiangda.md +7 -1
- package/templates/sy-lowcode-app-workspace/AGENTS.md +9 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
1
2
|
import React__default, { Dispatch, SetStateAction, CSSProperties, Key, ReactNode, HTMLAttributes } from 'react';
|
|
2
|
-
import {
|
|
3
|
-
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
3
|
+
import { bg as RuntimeAuthHeadersProvider, a as FormRuntimeApi, a9 as AttachmentItem, ab as FilePreviewCapability, aa as PreparedFilePreview, o as InitiatorSelectRequirement, I as InitiatorSelectCandidate, bf as ProcessPreviewProps, an as ApprovalTimelineProps } from '../ProcessPreview-DSUIJi5V.mjs';
|
|
4
4
|
|
|
5
5
|
type PageQueryValue = string | string[];
|
|
6
6
|
type PageHttpMethod = "get" | "post" | "put" | "delete" | "patch";
|
|
@@ -2576,7 +2576,7 @@ interface AttachmentPreviewListProps {
|
|
|
2576
2576
|
className?: string;
|
|
2577
2577
|
}
|
|
2578
2578
|
/** Read-only attachment list with capability-aware preview and download actions. */
|
|
2579
|
-
declare const AttachmentPreviewList: ({ items, appType, bucketName, showPreview, showDownload, showFileSize, showFileTypeBadge, emptyText, className, }: AttachmentPreviewListProps) =>
|
|
2579
|
+
declare const AttachmentPreviewList: ({ items, appType, bucketName, showPreview, showDownload, showFileSize, showFileTypeBadge, emptyText, className, }: AttachmentPreviewListProps) => React__default.JSX.Element;
|
|
2580
2580
|
interface ImagePreviewGridProps {
|
|
2581
2581
|
items?: AttachmentItem[];
|
|
2582
2582
|
appType?: string;
|
|
@@ -2588,7 +2588,7 @@ interface ImagePreviewGridProps {
|
|
|
2588
2588
|
className?: string;
|
|
2589
2589
|
}
|
|
2590
2590
|
/** Read-only image grid that opens the current item in the shared preview gallery. */
|
|
2591
|
-
declare const ImagePreviewGrid: ({ items, appType, bucketName, showPreview, showDownload, showFileName, emptyText, className, }: ImagePreviewGridProps) =>
|
|
2591
|
+
declare const ImagePreviewGrid: ({ items, appType, bucketName, showPreview, showDownload, showFileName, emptyText, className, }: ImagePreviewGridProps) => React__default.JSX.Element;
|
|
2592
2592
|
type FilePreviewItem = AttachmentItem;
|
|
2593
2593
|
|
|
2594
2594
|
type SelectedApproverMap = Record<string, InitiatorSelectCandidate[]>;
|
|
@@ -3129,7 +3129,7 @@ interface AdminListProps<Row> {
|
|
|
3129
3129
|
onRow?: (row: Row) => HTMLAttributes<HTMLTableRowElement>;
|
|
3130
3130
|
}
|
|
3131
3131
|
|
|
3132
|
-
declare function AdminList<Row>(props: AdminListProps<Row>):
|
|
3132
|
+
declare function AdminList<Row>(props: AdminListProps<Row>): React.JSX.Element;
|
|
3133
3133
|
|
|
3134
3134
|
declare function createFormAdminListSource<Row>(options: AdminListFormSourceOptions): AdminListDataSource<Row>;
|
|
3135
3135
|
declare function createDataViewAdminListSource<Row>(options: AdminListDataViewSourceOptions): AdminListDataSource<Row>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
1
2
|
import React__default, { Dispatch, SetStateAction, CSSProperties, Key, ReactNode, HTMLAttributes } from 'react';
|
|
2
|
-
import {
|
|
3
|
-
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
3
|
+
import { bg as RuntimeAuthHeadersProvider, a as FormRuntimeApi, a9 as AttachmentItem, ab as FilePreviewCapability, aa as PreparedFilePreview, o as InitiatorSelectRequirement, I as InitiatorSelectCandidate, bf as ProcessPreviewProps, an as ApprovalTimelineProps } from '../ProcessPreview-DSUIJi5V.js';
|
|
4
4
|
|
|
5
5
|
type PageQueryValue = string | string[];
|
|
6
6
|
type PageHttpMethod = "get" | "post" | "put" | "delete" | "patch";
|
|
@@ -2576,7 +2576,7 @@ interface AttachmentPreviewListProps {
|
|
|
2576
2576
|
className?: string;
|
|
2577
2577
|
}
|
|
2578
2578
|
/** Read-only attachment list with capability-aware preview and download actions. */
|
|
2579
|
-
declare const AttachmentPreviewList: ({ items, appType, bucketName, showPreview, showDownload, showFileSize, showFileTypeBadge, emptyText, className, }: AttachmentPreviewListProps) =>
|
|
2579
|
+
declare const AttachmentPreviewList: ({ items, appType, bucketName, showPreview, showDownload, showFileSize, showFileTypeBadge, emptyText, className, }: AttachmentPreviewListProps) => React__default.JSX.Element;
|
|
2580
2580
|
interface ImagePreviewGridProps {
|
|
2581
2581
|
items?: AttachmentItem[];
|
|
2582
2582
|
appType?: string;
|
|
@@ -2588,7 +2588,7 @@ interface ImagePreviewGridProps {
|
|
|
2588
2588
|
className?: string;
|
|
2589
2589
|
}
|
|
2590
2590
|
/** Read-only image grid that opens the current item in the shared preview gallery. */
|
|
2591
|
-
declare const ImagePreviewGrid: ({ items, appType, bucketName, showPreview, showDownload, showFileName, emptyText, className, }: ImagePreviewGridProps) =>
|
|
2591
|
+
declare const ImagePreviewGrid: ({ items, appType, bucketName, showPreview, showDownload, showFileName, emptyText, className, }: ImagePreviewGridProps) => React__default.JSX.Element;
|
|
2592
2592
|
type FilePreviewItem = AttachmentItem;
|
|
2593
2593
|
|
|
2594
2594
|
type SelectedApproverMap = Record<string, InitiatorSelectCandidate[]>;
|
|
@@ -3129,7 +3129,7 @@ interface AdminListProps<Row> {
|
|
|
3129
3129
|
onRow?: (row: Row) => HTMLAttributes<HTMLTableRowElement>;
|
|
3130
3130
|
}
|
|
3131
3131
|
|
|
3132
|
-
declare function AdminList<Row>(props: AdminListProps<Row>):
|
|
3132
|
+
declare function AdminList<Row>(props: AdminListProps<Row>): React.JSX.Element;
|
|
3133
3133
|
|
|
3134
3134
|
declare function createFormAdminListSource<Row>(options: AdminListFormSourceOptions): AdminListDataSource<Row>;
|
|
3135
3135
|
declare function createDataViewAdminListSource<Row>(options: AdminListDataViewSourceOptions): AdminListDataSource<Row>;
|
|
@@ -1,70 +1,70 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* mime-types.mjs - MIME 类型映射
|
|
3
|
-
*
|
|
4
|
-
* 提供文件扩展名到 MIME 类型的映射,支持 JS/CSS/JSON/HTML、
|
|
5
|
-
* 图片、字体和其他常见静态资源类型。
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
import path from "node:path";
|
|
9
|
-
|
|
10
|
-
/** @type {Record<string, string>} 扩展名 → MIME 类型映射表 */
|
|
11
|
-
const MIME_MAP = {
|
|
12
|
-
// 脚本 & 样式
|
|
13
|
-
".js": "application/javascript",
|
|
14
|
-
".mjs": "application/javascript",
|
|
15
|
-
".css": "text/css",
|
|
16
|
-
".json": "application/json",
|
|
17
|
-
".html": "text/html",
|
|
18
|
-
// 图片
|
|
19
|
-
".png": "image/png",
|
|
20
|
-
".jpg": "image/jpeg",
|
|
21
|
-
".jpeg": "image/jpeg",
|
|
22
|
-
".gif": "image/gif",
|
|
23
|
-
".svg": "image/svg+xml",
|
|
24
|
-
".webp": "image/webp",
|
|
25
|
-
".ico": "image/x-icon",
|
|
26
|
-
".avif": "image/avif",
|
|
27
|
-
// 字体
|
|
28
|
-
".woff": "font/woff",
|
|
29
|
-
".woff2": "font/woff2",
|
|
30
|
-
".ttf": "font/ttf",
|
|
31
|
-
".eot": "application/vnd.ms-fontobject",
|
|
32
|
-
// 其他
|
|
33
|
-
".map": "application/json",
|
|
34
|
-
};
|
|
35
|
-
|
|
36
|
-
/**
|
|
37
|
-
* 根据文件路径获取对应的 MIME 类型
|
|
38
|
-
* @param {string} file - 文件路径
|
|
39
|
-
* @returns {string} MIME 类型
|
|
40
|
-
*/
|
|
41
|
-
export function getContentType(file) {
|
|
42
|
-
const ext = path.extname(file).toLowerCase();
|
|
43
|
-
return MIME_MAP[ext] || "application/octet-stream";
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
/**
|
|
47
|
-
* 判断文件名是否包含 content hash(如 logo-abc123.png)
|
|
48
|
-
* 匹配模式:name-[8+位hex hash].ext
|
|
49
|
-
* @param {string} file - 文件名或路径
|
|
50
|
-
* @returns {boolean}
|
|
51
|
-
*/
|
|
52
|
-
export function hasContentHash(file) {
|
|
53
|
-
const basename = path.basename(file);
|
|
54
|
-
return /\-[a-f0-9]{8,}\.[^.]+$/.test(basename);
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
/**
|
|
58
|
-
* 根据文件特征返回合适的 Cache-Control 头
|
|
59
|
-
* - 带 content hash 的资源 → 长期缓存 + immutable
|
|
60
|
-
* - 其他文件 → 长期缓存(依赖 buildId 路径做版本隔离)
|
|
61
|
-
* @param {string} file - 文件路径
|
|
62
|
-
* @returns {string} Cache-Control 头值
|
|
63
|
-
*/
|
|
64
|
-
export function getCacheControl(file) {
|
|
65
|
-
if (hasContentHash(file)) {
|
|
66
|
-
return "public, max-age=31536000, immutable";
|
|
67
|
-
}
|
|
68
|
-
// 入口文件依赖 buildId 路径做版本隔离,同样可以长期缓存
|
|
69
|
-
return "public, max-age=31536000";
|
|
70
|
-
}
|
|
1
|
+
/**
|
|
2
|
+
* mime-types.mjs - MIME 类型映射
|
|
3
|
+
*
|
|
4
|
+
* 提供文件扩展名到 MIME 类型的映射,支持 JS/CSS/JSON/HTML、
|
|
5
|
+
* 图片、字体和其他常见静态资源类型。
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import path from "node:path";
|
|
9
|
+
|
|
10
|
+
/** @type {Record<string, string>} 扩展名 → MIME 类型映射表 */
|
|
11
|
+
const MIME_MAP = {
|
|
12
|
+
// 脚本 & 样式
|
|
13
|
+
".js": "application/javascript",
|
|
14
|
+
".mjs": "application/javascript",
|
|
15
|
+
".css": "text/css",
|
|
16
|
+
".json": "application/json",
|
|
17
|
+
".html": "text/html",
|
|
18
|
+
// 图片
|
|
19
|
+
".png": "image/png",
|
|
20
|
+
".jpg": "image/jpeg",
|
|
21
|
+
".jpeg": "image/jpeg",
|
|
22
|
+
".gif": "image/gif",
|
|
23
|
+
".svg": "image/svg+xml",
|
|
24
|
+
".webp": "image/webp",
|
|
25
|
+
".ico": "image/x-icon",
|
|
26
|
+
".avif": "image/avif",
|
|
27
|
+
// 字体
|
|
28
|
+
".woff": "font/woff",
|
|
29
|
+
".woff2": "font/woff2",
|
|
30
|
+
".ttf": "font/ttf",
|
|
31
|
+
".eot": "application/vnd.ms-fontobject",
|
|
32
|
+
// 其他
|
|
33
|
+
".map": "application/json",
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* 根据文件路径获取对应的 MIME 类型
|
|
38
|
+
* @param {string} file - 文件路径
|
|
39
|
+
* @returns {string} MIME 类型
|
|
40
|
+
*/
|
|
41
|
+
export function getContentType(file) {
|
|
42
|
+
const ext = path.extname(file).toLowerCase();
|
|
43
|
+
return MIME_MAP[ext] || "application/octet-stream";
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* 判断文件名是否包含 content hash(如 logo-abc123.png)
|
|
48
|
+
* 匹配模式:name-[8+位hex hash].ext
|
|
49
|
+
* @param {string} file - 文件名或路径
|
|
50
|
+
* @returns {boolean}
|
|
51
|
+
*/
|
|
52
|
+
export function hasContentHash(file) {
|
|
53
|
+
const basename = path.basename(file);
|
|
54
|
+
return /\-[a-f0-9]{8,}\.[^.]+$/.test(basename);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* 根据文件特征返回合适的 Cache-Control 头
|
|
59
|
+
* - 带 content hash 的资源 → 长期缓存 + immutable
|
|
60
|
+
* - 其他文件 → 长期缓存(依赖 buildId 路径做版本隔离)
|
|
61
|
+
* @param {string} file - 文件路径
|
|
62
|
+
* @returns {string} Cache-Control 头值
|
|
63
|
+
*/
|
|
64
|
+
export function getCacheControl(file) {
|
|
65
|
+
if (hasContentHash(file)) {
|
|
66
|
+
return "public, max-age=31536000, immutable";
|
|
67
|
+
}
|
|
68
|
+
// 入口文件依赖 buildId 路径做版本隔离,同样可以长期缓存
|
|
69
|
+
return "public, max-age=31536000";
|
|
70
|
+
}
|
|
@@ -1,128 +1,128 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* oss-client.mjs - 阿里云 OSS 客户端工具
|
|
3
|
-
*
|
|
4
|
-
* 封装 OSS 客户端初始化、带重试的上传、以及 CORS 规则确保。
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
import OSS from "ali-oss";
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* 创建阿里云 OSS 客户端实例
|
|
11
|
-
* @param {object} ossConfig - OSS 配置
|
|
12
|
-
* @param {string} ossConfig.region - OSS Region
|
|
13
|
-
* @param {string} ossConfig.bucket - Bucket 名称
|
|
14
|
-
* @param {string} ossConfig.accessKeyId - AccessKey ID
|
|
15
|
-
* @param {string} ossConfig.accessKeySecret - AccessKey Secret
|
|
16
|
-
* @returns {import("ali-oss")} OSS 客户端实例
|
|
17
|
-
*/
|
|
18
|
-
export function createOSSClient(ossConfig) {
|
|
19
|
-
return new OSS({
|
|
20
|
-
region: ossConfig.region,
|
|
21
|
-
accessKeyId: ossConfig.accessKeyId,
|
|
22
|
-
accessKeySecret: ossConfig.accessKeySecret,
|
|
23
|
-
bucket: ossConfig.bucket,
|
|
24
|
-
});
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
/**
|
|
28
|
-
* 带重试机制的 OSS 上传
|
|
29
|
-
* @param {import("ali-oss")} client - OSS 客户端实例
|
|
30
|
-
* @param {string} ossKey - OSS 对象键
|
|
31
|
-
* @param {string} localPath - 本地文件路径
|
|
32
|
-
* @param {object} headers - HTTP 头(Cache-Control, Content-Type 等)
|
|
33
|
-
* @param {number} [retries=3] - 最大重试次数
|
|
34
|
-
* @returns {Promise<void>}
|
|
35
|
-
*/
|
|
36
|
-
export async function uploadWithRetry(client, ossKey, localPath, headers, retries = 3) {
|
|
37
|
-
for (let i = 0; i < retries; i++) {
|
|
38
|
-
try {
|
|
39
|
-
await client.put(ossKey, localPath, { headers });
|
|
40
|
-
return;
|
|
41
|
-
} catch (err) {
|
|
42
|
-
if (i === retries - 1) throw err;
|
|
43
|
-
console.warn(` ⚠ 重试 ${i + 1}/${retries}: ${ossKey}`);
|
|
44
|
-
await new Promise((r) => setTimeout(r, 1000 * (i + 1)));
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
/**
|
|
50
|
-
* @param {*} value
|
|
51
|
-
* @returns {string[]}
|
|
52
|
-
*/
|
|
53
|
-
function toArray(value) {
|
|
54
|
-
if (Array.isArray(value)) return value;
|
|
55
|
-
if (value === undefined || value === null || value === "") return [];
|
|
56
|
-
return [value];
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
/**
|
|
60
|
-
* 检查单条 CORS 规则是否已满足指定 origins 和 methods
|
|
61
|
-
* @param {object} rule - CORS 规则对象
|
|
62
|
-
* @param {string[]} origins - 需要允许的来源
|
|
63
|
-
* @param {string[]} methods - 需要允许的方法
|
|
64
|
-
* @returns {boolean}
|
|
65
|
-
*/
|
|
66
|
-
function corsRuleAllows(rule, origins, methods) {
|
|
67
|
-
const allowedOrigins = toArray(rule.allowedOrigin);
|
|
68
|
-
const allowedMethods = toArray(rule.allowedMethod).map((item) =>
|
|
69
|
-
String(item).toUpperCase(),
|
|
70
|
-
);
|
|
71
|
-
|
|
72
|
-
const originAllowed =
|
|
73
|
-
allowedOrigins.includes("*") ||
|
|
74
|
-
origins.every((origin) => allowedOrigins.includes(origin));
|
|
75
|
-
const methodAllowed = methods.every((method) =>
|
|
76
|
-
allowedMethods.includes(method),
|
|
77
|
-
);
|
|
78
|
-
|
|
79
|
-
return originAllowed && methodAllowed;
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
/**
|
|
83
|
-
* 确保 OSS Bucket 的 CORS 规则满足前端资源加载需求
|
|
84
|
-
* @param {import("ali-oss")} client - OSS 客户端实例
|
|
85
|
-
* @param {object} ossConfig - OSS 配置
|
|
86
|
-
* @param {string} ossConfig.bucket - Bucket 名称
|
|
87
|
-
* @param {boolean} [ossConfig.skipCors] - 是否跳过 CORS 检查
|
|
88
|
-
* @param {string[]} [ossConfig.corsOrigins] - 允许的来源列表
|
|
89
|
-
* @returns {Promise<void>}
|
|
90
|
-
*/
|
|
91
|
-
export async function ensureBucketCors(client, ossConfig) {
|
|
92
|
-
if (ossConfig.skipCors) {
|
|
93
|
-
console.log(" CORS: 跳过(APP_OSS_SKIP_CORS=1)");
|
|
94
|
-
return;
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
const origins = ossConfig.corsOrigins?.length
|
|
98
|
-
? ossConfig.corsOrigins
|
|
99
|
-
: ["*"];
|
|
100
|
-
const methods = ["GET", "HEAD"];
|
|
101
|
-
let rules = [];
|
|
102
|
-
|
|
103
|
-
try {
|
|
104
|
-
const result = await client.getBucketCORS(ossConfig.bucket);
|
|
105
|
-
rules = Array.isArray(result.rules) ? result.rules : [];
|
|
106
|
-
} catch (error) {
|
|
107
|
-
if (error?.status !== 404 && error?.code !== "NoSuchCORSConfiguration") {
|
|
108
|
-
throw error;
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
if (rules.some((rule) => corsRuleAllows(rule, origins, methods))) {
|
|
113
|
-
console.log(` CORS: 已允许 ${origins.join(", ")}`);
|
|
114
|
-
return;
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
await client.putBucketCORS(ossConfig.bucket, [
|
|
118
|
-
...rules,
|
|
119
|
-
{
|
|
120
|
-
allowedOrigin: origins,
|
|
121
|
-
allowedMethod: methods,
|
|
122
|
-
allowedHeader: "*",
|
|
123
|
-
exposeHeader: ["ETag", "Content-Length", "Content-Type"],
|
|
124
|
-
maxAgeSeconds: "3600",
|
|
125
|
-
},
|
|
126
|
-
]);
|
|
127
|
-
console.log(` CORS: 已配置 ${origins.join(", ")}`);
|
|
128
|
-
}
|
|
1
|
+
/**
|
|
2
|
+
* oss-client.mjs - 阿里云 OSS 客户端工具
|
|
3
|
+
*
|
|
4
|
+
* 封装 OSS 客户端初始化、带重试的上传、以及 CORS 规则确保。
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import OSS from "ali-oss";
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* 创建阿里云 OSS 客户端实例
|
|
11
|
+
* @param {object} ossConfig - OSS 配置
|
|
12
|
+
* @param {string} ossConfig.region - OSS Region
|
|
13
|
+
* @param {string} ossConfig.bucket - Bucket 名称
|
|
14
|
+
* @param {string} ossConfig.accessKeyId - AccessKey ID
|
|
15
|
+
* @param {string} ossConfig.accessKeySecret - AccessKey Secret
|
|
16
|
+
* @returns {import("ali-oss")} OSS 客户端实例
|
|
17
|
+
*/
|
|
18
|
+
export function createOSSClient(ossConfig) {
|
|
19
|
+
return new OSS({
|
|
20
|
+
region: ossConfig.region,
|
|
21
|
+
accessKeyId: ossConfig.accessKeyId,
|
|
22
|
+
accessKeySecret: ossConfig.accessKeySecret,
|
|
23
|
+
bucket: ossConfig.bucket,
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* 带重试机制的 OSS 上传
|
|
29
|
+
* @param {import("ali-oss")} client - OSS 客户端实例
|
|
30
|
+
* @param {string} ossKey - OSS 对象键
|
|
31
|
+
* @param {string} localPath - 本地文件路径
|
|
32
|
+
* @param {object} headers - HTTP 头(Cache-Control, Content-Type 等)
|
|
33
|
+
* @param {number} [retries=3] - 最大重试次数
|
|
34
|
+
* @returns {Promise<void>}
|
|
35
|
+
*/
|
|
36
|
+
export async function uploadWithRetry(client, ossKey, localPath, headers, retries = 3) {
|
|
37
|
+
for (let i = 0; i < retries; i++) {
|
|
38
|
+
try {
|
|
39
|
+
await client.put(ossKey, localPath, { headers });
|
|
40
|
+
return;
|
|
41
|
+
} catch (err) {
|
|
42
|
+
if (i === retries - 1) throw err;
|
|
43
|
+
console.warn(` ⚠ 重试 ${i + 1}/${retries}: ${ossKey}`);
|
|
44
|
+
await new Promise((r) => setTimeout(r, 1000 * (i + 1)));
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* @param {*} value
|
|
51
|
+
* @returns {string[]}
|
|
52
|
+
*/
|
|
53
|
+
function toArray(value) {
|
|
54
|
+
if (Array.isArray(value)) return value;
|
|
55
|
+
if (value === undefined || value === null || value === "") return [];
|
|
56
|
+
return [value];
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* 检查单条 CORS 规则是否已满足指定 origins 和 methods
|
|
61
|
+
* @param {object} rule - CORS 规则对象
|
|
62
|
+
* @param {string[]} origins - 需要允许的来源
|
|
63
|
+
* @param {string[]} methods - 需要允许的方法
|
|
64
|
+
* @returns {boolean}
|
|
65
|
+
*/
|
|
66
|
+
function corsRuleAllows(rule, origins, methods) {
|
|
67
|
+
const allowedOrigins = toArray(rule.allowedOrigin);
|
|
68
|
+
const allowedMethods = toArray(rule.allowedMethod).map((item) =>
|
|
69
|
+
String(item).toUpperCase(),
|
|
70
|
+
);
|
|
71
|
+
|
|
72
|
+
const originAllowed =
|
|
73
|
+
allowedOrigins.includes("*") ||
|
|
74
|
+
origins.every((origin) => allowedOrigins.includes(origin));
|
|
75
|
+
const methodAllowed = methods.every((method) =>
|
|
76
|
+
allowedMethods.includes(method),
|
|
77
|
+
);
|
|
78
|
+
|
|
79
|
+
return originAllowed && methodAllowed;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* 确保 OSS Bucket 的 CORS 规则满足前端资源加载需求
|
|
84
|
+
* @param {import("ali-oss")} client - OSS 客户端实例
|
|
85
|
+
* @param {object} ossConfig - OSS 配置
|
|
86
|
+
* @param {string} ossConfig.bucket - Bucket 名称
|
|
87
|
+
* @param {boolean} [ossConfig.skipCors] - 是否跳过 CORS 检查
|
|
88
|
+
* @param {string[]} [ossConfig.corsOrigins] - 允许的来源列表
|
|
89
|
+
* @returns {Promise<void>}
|
|
90
|
+
*/
|
|
91
|
+
export async function ensureBucketCors(client, ossConfig) {
|
|
92
|
+
if (ossConfig.skipCors) {
|
|
93
|
+
console.log(" CORS: 跳过(APP_OSS_SKIP_CORS=1)");
|
|
94
|
+
return;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
const origins = ossConfig.corsOrigins?.length
|
|
98
|
+
? ossConfig.corsOrigins
|
|
99
|
+
: ["*"];
|
|
100
|
+
const methods = ["GET", "HEAD"];
|
|
101
|
+
let rules = [];
|
|
102
|
+
|
|
103
|
+
try {
|
|
104
|
+
const result = await client.getBucketCORS(ossConfig.bucket);
|
|
105
|
+
rules = Array.isArray(result.rules) ? result.rules : [];
|
|
106
|
+
} catch (error) {
|
|
107
|
+
if (error?.status !== 404 && error?.code !== "NoSuchCORSConfiguration") {
|
|
108
|
+
throw error;
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
if (rules.some((rule) => corsRuleAllows(rule, origins, methods))) {
|
|
113
|
+
console.log(` CORS: 已允许 ${origins.join(", ")}`);
|
|
114
|
+
return;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
await client.putBucketCORS(ossConfig.bucket, [
|
|
118
|
+
...rules,
|
|
119
|
+
{
|
|
120
|
+
allowedOrigin: origins,
|
|
121
|
+
allowedMethod: methods,
|
|
122
|
+
allowedHeader: "*",
|
|
123
|
+
exposeHeader: ["ETag", "Content-Length", "Content-Type"],
|
|
124
|
+
maxAgeSeconds: "3600",
|
|
125
|
+
},
|
|
126
|
+
]);
|
|
127
|
+
console.log(` CORS: 已配置 ${origins.join(", ")}`);
|
|
128
|
+
}
|
|
@@ -1,57 +1,57 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* progress.mjs - 上传进度报告工具
|
|
3
|
-
*
|
|
4
|
-
* 提供文件上传进度跟踪,包括已完成数量、文件总大小、耗时统计。
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
import fs from "node:fs";
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* 创建进度跟踪器
|
|
11
|
-
* @param {number} total - 总文件数
|
|
12
|
-
* @returns {{ tick: (file: string, localPath: string) => void, summary: () => void }}
|
|
13
|
-
*/
|
|
14
|
-
export function createProgressTracker(total) {
|
|
15
|
-
let completed = 0;
|
|
16
|
-
let totalBytes = 0;
|
|
17
|
-
const startTime = Date.now();
|
|
18
|
-
|
|
19
|
-
return {
|
|
20
|
-
/**
|
|
21
|
-
* 标记一个文件上传完成
|
|
22
|
-
* @param {string} ossKey - OSS 对象键(用于日志)
|
|
23
|
-
* @param {string} localPath - 本地文件路径(用于计算大小)
|
|
24
|
-
*/
|
|
25
|
-
tick(ossKey, localPath) {
|
|
26
|
-
completed += 1;
|
|
27
|
-
try {
|
|
28
|
-
const stat = fs.statSync(localPath);
|
|
29
|
-
totalBytes += stat.size;
|
|
30
|
-
} catch {
|
|
31
|
-
// 忽略 stat 失败
|
|
32
|
-
}
|
|
33
|
-
const pct = Math.round((completed / total) * 100);
|
|
34
|
-
console.log(` ✓ [${completed}/${total} ${pct}%] ${ossKey}`);
|
|
35
|
-
},
|
|
36
|
-
|
|
37
|
-
/**
|
|
38
|
-
* 标记一个文件上传失败
|
|
39
|
-
* @param {string} ossKey - OSS 对象键
|
|
40
|
-
* @param {Error} error - 错误对象
|
|
41
|
-
*/
|
|
42
|
-
fail(ossKey, error) {
|
|
43
|
-
completed += 1;
|
|
44
|
-
const pct = Math.round((completed / total) * 100);
|
|
45
|
-
console.error(` ✗ [${completed}/${total} ${pct}%] ${ossKey}: ${error.message}`);
|
|
46
|
-
},
|
|
47
|
-
|
|
48
|
-
/**
|
|
49
|
-
* 打印上传汇总信息
|
|
50
|
-
*/
|
|
51
|
-
summary() {
|
|
52
|
-
const elapsed = ((Date.now() - startTime) / 1000).toFixed(1);
|
|
53
|
-
const sizeMB = (totalBytes / (1024 * 1024)).toFixed(2);
|
|
54
|
-
console.log(`\n📊 上传统计: ${total} 个文件, ${sizeMB} MB, 耗时 ${elapsed}s`);
|
|
55
|
-
},
|
|
56
|
-
};
|
|
57
|
-
}
|
|
1
|
+
/**
|
|
2
|
+
* progress.mjs - 上传进度报告工具
|
|
3
|
+
*
|
|
4
|
+
* 提供文件上传进度跟踪,包括已完成数量、文件总大小、耗时统计。
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import fs from "node:fs";
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* 创建进度跟踪器
|
|
11
|
+
* @param {number} total - 总文件数
|
|
12
|
+
* @returns {{ tick: (file: string, localPath: string) => void, summary: () => void }}
|
|
13
|
+
*/
|
|
14
|
+
export function createProgressTracker(total) {
|
|
15
|
+
let completed = 0;
|
|
16
|
+
let totalBytes = 0;
|
|
17
|
+
const startTime = Date.now();
|
|
18
|
+
|
|
19
|
+
return {
|
|
20
|
+
/**
|
|
21
|
+
* 标记一个文件上传完成
|
|
22
|
+
* @param {string} ossKey - OSS 对象键(用于日志)
|
|
23
|
+
* @param {string} localPath - 本地文件路径(用于计算大小)
|
|
24
|
+
*/
|
|
25
|
+
tick(ossKey, localPath) {
|
|
26
|
+
completed += 1;
|
|
27
|
+
try {
|
|
28
|
+
const stat = fs.statSync(localPath);
|
|
29
|
+
totalBytes += stat.size;
|
|
30
|
+
} catch {
|
|
31
|
+
// 忽略 stat 失败
|
|
32
|
+
}
|
|
33
|
+
const pct = Math.round((completed / total) * 100);
|
|
34
|
+
console.log(` ✓ [${completed}/${total} ${pct}%] ${ossKey}`);
|
|
35
|
+
},
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* 标记一个文件上传失败
|
|
39
|
+
* @param {string} ossKey - OSS 对象键
|
|
40
|
+
* @param {Error} error - 错误对象
|
|
41
|
+
*/
|
|
42
|
+
fail(ossKey, error) {
|
|
43
|
+
completed += 1;
|
|
44
|
+
const pct = Math.round((completed / total) * 100);
|
|
45
|
+
console.error(` ✗ [${completed}/${total} ${pct}%] ${ossKey}: ${error.message}`);
|
|
46
|
+
},
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* 打印上传汇总信息
|
|
50
|
+
*/
|
|
51
|
+
summary() {
|
|
52
|
+
const elapsed = ((Date.now() - startTime) / 1000).toFixed(1);
|
|
53
|
+
const sizeMB = (totalBytes / (1024 * 1024)).toFixed(2);
|
|
54
|
+
console.log(`\n📊 上传统计: ${total} 个文件, ${sizeMB} MB, 耗时 ${elapsed}s`);
|
|
55
|
+
},
|
|
56
|
+
};
|
|
57
|
+
}
|
|
@@ -25,6 +25,7 @@ openxiangda resource typegen --profile <name>
|
|
|
25
25
|
- Guest file upload requires a structured form grant such as `{code, actions: ["upload", "preview"], fields?: [...]}`; optional form `upload` or `grants.storage` constraints define bucket/MIME/extensions/size/visibility/path prefix.
|
|
26
26
|
- Connector secrets and third-party credentials belong in the platform backend, never in manifests or page source.
|
|
27
27
|
- App Function manifests may contain only metadata names in top-level `secretRefs`; values use the Secret CLI and runtime `ctx.secrets.get(name)` under `function_v2` / `trusted_node_v2`.
|
|
28
|
+
- Inbound callbacks use `src/resources/webhooks/*.json` with one fixed `targetFunctionCode`. Keep Secret/signature rules out of that manifest; verify `input.rawBody` before any helper call and make business writes idempotent with `input.idempotencyKey`.
|
|
28
29
|
- Formal changes should keep Git as the source of truth: edit manifests, validate, plan, then publish.
|
|
29
30
|
- Exact selectors apply before manifest/source analysis and JS_CODE build: touch only selected targets plus transitive/shared/ambient dependencies; omit selectors only for intentional full-workspace work.
|
|
30
31
|
- `resource plan` and publish dry-runs are GET/HEAD-only. On `READ_ONLY_AUTH_REQUIRED`, run `openxiangda auth refresh --profile <name>` or log in again before retrying; never refresh inside the plan.
|
|
@@ -7,6 +7,10 @@ alwaysApply: true
|
|
|
7
7
|
|
|
8
8
|
This is an OpenXiangda React SPA workspace using Delivery V2. See [DELIVERY.md](mdc:DELIVERY.md) and [AGENTS.md](mdc:AGENTS.md). Low-level V1 resource/runtime commands are compatibility tools.
|
|
9
9
|
|
|
10
|
+
## 工具升级与代际选择
|
|
11
|
+
|
|
12
|
+
建议评估升级到 OpenXiangda 2.0;新应用优先使用 V2,已有项目先确认能力覆盖、迁移成本及验收。工具更新不转换应用。Node.js 24+ 可安装 `npm install -g openxiangda@latest`,再使用新版全局入口执行 `openxiangda migrate assess --to v2`。本项目依赖继续按 `legacy-v1` 维护。CLI、Skill、MCP 说明见 https://github.com/1377385356/openxiangda/blob/master/docs/getting-started.md#upgrade 。
|
|
13
|
+
|
|
10
14
|
## Hard route
|
|
11
15
|
|
|
12
16
|
| User says | Command |
|
|
@@ -66,3 +70,5 @@ This is an OpenXiangda React SPA workspace using Delivery V2. See [DELIVERY.md](
|
|
|
66
70
|
## Parallel candidates
|
|
67
71
|
|
|
68
72
|
A candidate may cross unrelated later mainline commits only when its commit remains an ancestor of clean pushed mainline and all sealed input hashes remain unchanged. Each target allows one running or evidence-pending deployment; wait for the lease/slot, and keep emergency fixes on the narrow candidate → preproduction → production path.
|
|
73
|
+
|
|
74
|
+
平台登录态只使用当前工作区的 `.openxiangda/profiles.json`,不再读取或合并用户主目录的全局 profiles。升级后请进入每个项目运行 `openxiangda login <platform-url>`;子目录沿最近应用根目录定位,不跨嵌套应用或 Git 边界。登录文件及临时文件会自动加入忽略规则,请勿提交或打包。新项目先用 `openxiangda login <platform-url> --cwd <directory>` 在目标目录登录,再在该目录运行 `openxiangda workspace init`。
|
|
@@ -25,6 +25,7 @@ openxiangda resource typegen --profile <name>
|
|
|
25
25
|
- Guest file upload requires a structured form grant such as `{code, actions: ["upload", "preview"], fields?: [...]}`; optional form `upload` or `grants.storage` constraints define bucket/MIME/extensions/size/visibility/path prefix.
|
|
26
26
|
- Connector secrets and third-party credentials belong in the platform backend, never in manifests or page source.
|
|
27
27
|
- App Function manifests may contain only metadata names in top-level `secretRefs`; values use the Secret CLI and runtime `ctx.secrets.get(name)` under `function_v2` / `trusted_node_v2`.
|
|
28
|
+
- Inbound callbacks use `src/resources/webhooks/*.json` with one fixed `targetFunctionCode`. Keep Secret/signature rules out of that manifest; verify `input.rawBody` before any helper call and make business writes idempotent with `input.idempotencyKey`.
|
|
28
29
|
- Formal changes should keep Git as the source of truth: edit manifests, validate, plan, then publish.
|
|
29
30
|
- Exact selectors apply before manifest/source analysis and JS_CODE build: touch only selected targets plus transitive/shared/ambient dependencies; omit selectors only for intentional full-workspace work.
|
|
30
31
|
- `resource plan` and publish dry-runs are GET/HEAD-only. On `READ_ONLY_AUTH_REQUIRED`, run `openxiangda auth refresh --profile <name>` or log in again before retrying; never refresh inside the plan.
|
|
@@ -7,6 +7,10 @@ alwaysApply: true
|
|
|
7
7
|
|
|
8
8
|
This is an OpenXiangda React SPA workspace using Delivery V2. Read [DELIVERY.md](DELIVERY.md) and [AGENTS.md](AGENTS.md). Low-level V1 resource/runtime commands are compatibility tools, not the normal release entrypoint.
|
|
9
9
|
|
|
10
|
+
## 工具升级与代际选择
|
|
11
|
+
|
|
12
|
+
建议评估升级到 OpenXiangda 2.0;新应用优先使用 V2,已有项目先确认能力覆盖、迁移成本及验收。工具更新不转换应用。Node.js 24+ 可安装 `npm install -g openxiangda@latest`,再使用新版全局入口执行 `openxiangda migrate assess --to v2`。本项目依赖继续按 `legacy-v1` 维护。CLI、Skill、MCP 说明见 https://github.com/1377385356/openxiangda/blob/master/docs/getting-started.md#upgrade 。
|
|
13
|
+
|
|
10
14
|
## Hard route
|
|
11
15
|
|
|
12
16
|
| 用户说 | 必用命令 |
|
|
@@ -64,3 +68,5 @@ This is an OpenXiangda React SPA workspace using Delivery V2. Read [DELIVERY.md]
|
|
|
64
68
|
## 并行 candidate
|
|
65
69
|
|
|
66
70
|
candidate 只可跨越不相干的后续主线提交:其 commit 必须仍是干净、已推送主线的祖先,且 sealed 输入哈希全部不变。同一目标一次只允许一个 running / evidence-pending deployment;等待 lease/槽位,紧急修复也走精确 candidate → preproduction → production。
|
|
71
|
+
|
|
72
|
+
平台登录态只使用当前工作区的 `.openxiangda/profiles.json`,不再读取或合并用户主目录的全局 profiles。升级后请进入每个项目运行 `openxiangda login <platform-url>`;子目录沿最近应用根目录定位,不跨嵌套应用或 Git 边界。登录文件及临时文件会自动加入忽略规则,请勿提交或打包。新项目先用 `openxiangda login <platform-url> --cwd <directory>` 在目标目录登录,再在该目录运行 `openxiangda workspace init`。
|