openxiangda 1.0.41 → 1.0.43
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 +60 -0
- package/package.json +1 -1
- package/packages/sdk/dist/components/index.cjs +2 -0
- package/packages/sdk/dist/components/index.cjs.map +1 -1
- package/packages/sdk/dist/components/index.d.mts +4 -1071
- package/packages/sdk/dist/components/index.d.ts +4 -1071
- package/packages/sdk/dist/components/index.mjs +2 -0
- package/packages/sdk/dist/components/index.mjs.map +1 -1
- package/packages/sdk/dist/runtime/index.cjs +47838 -93
- package/packages/sdk/dist/runtime/index.cjs.map +1 -1
- package/packages/sdk/dist/runtime/index.css +5313 -0
- package/packages/sdk/dist/runtime/index.css.map +1 -0
- package/packages/sdk/dist/runtime/index.d.mts +165 -1
- package/packages/sdk/dist/runtime/index.d.ts +165 -1
- package/packages/sdk/dist/runtime/index.mjs +47018 -103
- package/packages/sdk/dist/runtime/index.mjs.map +1 -1
- package/packages/sdk/dist/types-U26h_FIh.d.mts +1073 -0
- package/packages/sdk/dist/types-U26h_FIh.d.ts +1073 -0
- package/templates/sy-lowcode-app-workspace/src/dev/App.tsx +780 -28
- package/templates/sy-lowcode-app-workspace/src/runtime/builtin-overrides.tsx +8 -0
- package/templates/sy-lowcode-app-workspace/tsconfig.app.json +17 -1
- package/templates/sy-lowcode-app-workspace/vite.config.ts +81 -28
package/README.md
CHANGED
|
@@ -93,6 +93,54 @@ Create a new publishable app workspace with `openxiangda workspace init <dir>`.
|
|
|
93
93
|
|
|
94
94
|
New OpenXiangda code pages and form custom pages publish with `cssIsolation: "none"` by default, so Tailwind utilities and normal Ant Design styles apply without a `.sy-app-workspace` prefix. Explicit `namespace` and `shadow` settings are kept only for legacy compatibility.
|
|
95
95
|
|
|
96
|
+
OpenXiangda workspaces include a lightweight runtime preview for new user pages. `/view` remains the user-facing URL prefix, but local development does not enter the legacy `sy-lowcode-view` workbench checks; the Vite dev host mounts `src/pages/*` directly and sends SDK requests through the configured service proxy.
|
|
97
|
+
|
|
98
|
+
```env
|
|
99
|
+
OPENXIANGDA_BASE_URL=https://dev-lowcode.example.com
|
|
100
|
+
OPENXIANGDA_APP_TYPE=APP_XXXX
|
|
101
|
+
OPENXIANGDA_DEV_HOST=myapp.local
|
|
102
|
+
OPENXIANGDA_DEV_PORT=5174
|
|
103
|
+
APP_SERVICE_PREFIX=/service
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
```bash
|
|
107
|
+
npm run dev
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
When `OPENXIANGDA_BASE_URL` or `APP_PLATFORM_URL` is set, the workspace Vite server proxies `/service/*` to the platform backend with `changeOrigin`, `cookieDomainRewrite: ""`, and `cookiePathRewrite: "/"`. This keeps local browser requests same-origin and lets HttpOnly `access_token` / `refresh_token` cookies be saved on the local dev domain.
|
|
111
|
+
|
|
112
|
+
The dev host also calls the backend runtime route resolver for the current `/view/...` URL. Workbench code-page routes select and mount the matching local `src/pages/<page>/index.tsx`; built-in routes such as form submit, detail, process detail, data list, and file preview render the SDK default pages directly instead of accidentally mounting the first local page.
|
|
113
|
+
|
|
114
|
+
Built-in route defaults come from the `openxiangda` SDK: `StandardFormPage`, `FormSubmitTemplate`, `FormDetailTemplate`, `ProcessDetailTemplate`, and `DataManagementList`. Workspaces can override whole built-in pages from `src/runtime/builtin-overrides.tsx`; exact `formUuid` entries win before the `*` fallback.
|
|
115
|
+
|
|
116
|
+
```tsx
|
|
117
|
+
import type { BuiltinRouteOverrides } from "openxiangda/runtime"
|
|
118
|
+
|
|
119
|
+
export const runtimeRouteOverrides: BuiltinRouteOverrides = {
|
|
120
|
+
"form-submit": {
|
|
121
|
+
customer: CustomerSubmitPage,
|
|
122
|
+
"*": SubmitShell,
|
|
123
|
+
},
|
|
124
|
+
"form-detail": {},
|
|
125
|
+
"process-detail": {},
|
|
126
|
+
"data-manage-list": {},
|
|
127
|
+
}
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
AI / Playwright verification should use real user identity, not a bypass mode. The backend exposes `POST /openxiangda-api/v1/apps/:appType/verification-login-links` for platform admins to create a short-lived, single-use `loginUrl` for a target user and redirect URI. Playwright can open the returned URL directly; the backend writes cookies and redirects back to the local or tenant `/view/...` page. Test users can be created with `POST /openxiangda-api/v1/apps/:appType/test-users`; they use the `__ox_ai_test__:<appType>:<key>` ID prefix and are intended to be used through verification login links.
|
|
131
|
+
|
|
132
|
+
An independent production user shell can call `resolveBrowserRuntimeRoute()` from `openxiangda/runtime` first. It posts the current `/view/...` path to `/openxiangda-api/v1/apps/:appType/runtime/routes/resolve`; the backend classifies the route as `custom-page`, `builtin-route`, `legacy-fallback`, or `not-found`. Code pages return backend-authorized bootstrap data directly, so the shell can pass that to `mountBrowserPageRuntime()` or mount with `createBrowserPageContext()` without reusing the legacy view workbench logic. Built-in routes can be rendered with `BuiltinRouteRenderer`, which loads form schema through the same `/service` proxy and keeps backend permission checks authoritative.
|
|
133
|
+
|
|
134
|
+
```ts
|
|
135
|
+
import { resolveBrowserRuntimeRoute } from "openxiangda/runtime"
|
|
136
|
+
|
|
137
|
+
const route = await resolveBrowserRuntimeRoute({
|
|
138
|
+
appType: "APP_XXXX",
|
|
139
|
+
path: window.location.pathname,
|
|
140
|
+
search: window.location.search,
|
|
141
|
+
})
|
|
142
|
+
```
|
|
143
|
+
|
|
96
144
|
Local workspace state is authoritative. If the current folder has no `.openxiangda/state.json` app binding, create a new app instead of searching the platform for a similar app name:
|
|
97
145
|
|
|
98
146
|
```bash
|
|
@@ -108,6 +156,18 @@ openxiangda workspace bind --profile dev --app-type APP_XXXX
|
|
|
108
156
|
|
|
109
157
|
表单页、流程表单页和自定义代码页都应在 `sy-lowcode-app-workspace` 中实现,由 `openxiangda workspace publish --profile <name>` 统一构建、上传 OSS 并注册到平台。`openxiangda form create`、`form publish`、`page publish` 只作为底层修复/诊断命令,不作为 AI 生成页面的主入口。
|
|
110
158
|
|
|
159
|
+
运行时页面读取当前用户信息时,优先使用 `sdk.user.getCurrent<PageUserRecord>()`。用户对象会返回常规组织成员关系 `departments`,也会返回系统维护的所属单位字段 `affiliatedDepartmentId` / `affiliatedDepartment`。`departments` 表示用户真实所在的部门、班级、专业等成员关系;`affiliatedDepartment` 表示业务上用于统计、筛选和展示的归属单位,通常是学院、单位或在源单位缺失时可用的具体部门节点,不用于替代权限部门成员关系。
|
|
160
|
+
|
|
161
|
+
```ts
|
|
162
|
+
import type { PageUserRecord } from "openxiangda/runtime"
|
|
163
|
+
|
|
164
|
+
const currentUser = await sdk.user.getCurrent<PageUserRecord>()
|
|
165
|
+
const user = currentUser.result
|
|
166
|
+
|
|
167
|
+
const affiliatedDepartmentName = user?.affiliatedDepartment?.name
|
|
168
|
+
const affiliatedDepartmentExternalId = user?.affiliatedDepartment?.externalId
|
|
169
|
+
```
|
|
170
|
+
|
|
111
171
|
工程化资源放在工作区 `src/resources/` 下,由 `openxiangda resource validate|plan|publish|pull` 管理。`workspace publish` 会先构建并注册 workspace 表单/页面,再执行非破坏性资源 upsert,这样菜单、权限组、流程和表单设置可以解析最新的 profile-local ID。需要删除平台中 manifest 未声明的资源时,显式传 `--prune`。连接器页面运行时通过 `sdk.connector.invoke()` / `sdk.connector.call("connector.api")` 调用平台运行时接口,第三方密钥只保存在后端连接器配置中。
|
|
112
172
|
|
|
113
173
|
多表只读查询和固定口径统计优先声明 `src/resources/data-views/*.json` 数据视图,而不是在页面里手写多次单表查询再拼数据。默认数据视图是行级联表视图,适合工单+客户、订单+商品、项目+成员、报表列表、跨页面复用查询等读多写少场景;`viewType: "aggregate"` 是统计聚合视图,适合按客户、状态、月份等维度预聚合 count/sum/avg/min/max。发布时 CLI 会把 `formCode` 解析为当前 profile 的 `formUuid`,平台创建 PostgreSQL materialized view;页面通过 `sdk.dataView.query(code, params)` 查询行级视图,通过 `sdk.dataView.stats(code, params)` 查询聚合视图,也可以用 `sdk.dataSource.run()` 路由 `dataView.query` / `dataView.stats`。发布前应为常用筛选、排序、统计维度和时间桶声明 `indexes`,并确认用户能接受的刷新延迟;默认不要设置低于 5 分钟的定时刷新。数据视图只读,刷新后才反映源表变化,不适合单表 CRUD、写回源表、强实时状态、临时 BI 查询或简单 linkedForm 下拉。
|
package/package.json
CHANGED
|
@@ -48407,6 +48407,7 @@ var DataManagementList = ({
|
|
|
48407
48407
|
appType,
|
|
48408
48408
|
formUuid,
|
|
48409
48409
|
formInstanceId: String(getRecordId(activeRecord)),
|
|
48410
|
+
api,
|
|
48410
48411
|
inDrawer: true
|
|
48411
48412
|
}
|
|
48412
48413
|
) : /* @__PURE__ */ (0, import_jsx_runtime101.jsx)(import_antd39.Empty, { description: "\u8BF7\u901A\u8FC7 detailRenderer \u63A5\u5165\u8BE6\u60C5\u6A21\u677F" })
|
|
@@ -48435,6 +48436,7 @@ var DataManagementList = ({
|
|
|
48435
48436
|
mode: "submit",
|
|
48436
48437
|
appType,
|
|
48437
48438
|
formUuid,
|
|
48439
|
+
api,
|
|
48438
48440
|
inDrawer: true,
|
|
48439
48441
|
onSubmitSuccess: () => {
|
|
48440
48442
|
setSubmitOpen(false);
|