@aloudata/can-components-for-nova
v0.1.4
Published
CAN components for Nova
Downloads
806
Keywords
Readme
CAN components for Nova
This package provides CAN components for Nova consumers. React 18 or 19, React DOM with the matching major, and React DnD 16 must resolve to the same copies used by the host.
import { configureNovaComponents, EQueryEngineType } from '@aloudata/can-components-for-nova/config';
import { useRef } from 'react';
import { MqlEditor, type MqlEditorRef } from '@aloudata/can-components-for-nova/mqlEditor';
import '@aloudata/can-components-for-nova/style.css';
import '@aloudata/can-components-for-nova/mqlEditor/style.css';
configureNovaComponents({
request: {
baseUrl: window.location.origin,
headers: { 'X-Host-Route': 'target-a' },
},
tenantId: 'your-tenant',
queryEngineType: EQueryEngineType.AIR,
// 临时开关:Nova 对接旧版 CAN 后端时启用。
enableNovaLegacyCanCompatibility: true,
});
function QueryDrawer({
dsl,
onRerun,
}: {
dsl: string | null;
onRerun: (dsl: string) => void;
}) {
const editorRef = useRef<MqlEditorRef>(null);
const rerun = () => {
const result = editorRef.current?.exportDsl();
if (result?.ok) onRerun(result.dsl);
};
return (
<>
<MqlEditor ref={editorRef} dsl={dsl} />
<button onClick={rerun}>重新查询</button>
</>
);
}Configure once, before rendering. request.baseUrl accepts an HTTP(S) origin or an absolute path prefix; optional static request.headers are sent only by the embedded runtime. Component-maintained protocol and identity headers take precedence over host headers. Configuration changes require a new document. Import shared styles before component styles. Each editor receives dsl plus optional onStatusChange, className and getPopupContainer. The host owns the action button, persistence, query execution, loading, errors, closing, authentication and proxy forwarding.
enableNovaLegacyCanCompatibility is independent from Nova feature extensions and defaults to false. Remove it after the CAN backend paired with Nova upgrades beyond the legacy API surface.
Rollback
Pin the host to the previously verified package version and rebuild the host application. Downgrading the package does not restore DSL documents that were already saved with newer syntax. Preserve the original DSL through the host's version or draft mechanism before editing; when no history is available, restore the previous DSL manually and validate it with the target editor version before completing the rollback.
共享 ALD 宿主契约(0.1.4)
宿主安装 @aloudata/[email protected],页面单次导入
@aloudata/aloudata-design/css,并以同一个 ConfigProvider(locale 与
configureNovaComponents.locale 一致)及 App 包围编辑器。
继续导入 CAN 的 style.css 和 mqlEditor/style.css。
ALD 根入口和公开子路径由宿主提供,CAN 包不内嵌 ALD 或它的全量 CSS。
通知生命周期属于宿主页面,关闭所有编辑器后仍可显示延迟请求和复制反馈。
CAN 的 Apollo、DnD manager 复用、Portal 和自定义内容样式作用域仍由包管理。
ALD 的容器 props 只保证类型正确,不保证库内部实际挂载位置。
迁移时成套更新 CAN 包、宿主 Provider、ALD/CSS 和锁文件。
React 19 的严格声明消费夹具使用 ALD 公开子路径:
dist/App/index、dist/ConfigProvider/index、dist/locale/zh_CN。
它们与根入口提供同一实现,且保留 skipLibCheck: false。
ALD 3.1.7 根 barrel 声明存在 Steps/theme 及 rc-field-form/rc-picker 的上游类型错误;
当前独立验证不承诺根 barrel 声明在 React 19 下无错误。需要根导入的宿主应自行处理这一库限制。
ALD 3.1.7 运行时依赖 tailwind-merge,其发布清单未将此依赖列入正式 dependencies。
CAN 因此明确声明 [email protected] 宿主 peer,宿主需同时安装;消费夹具对真实依赖做生产构建验证。
同一 ALD 根运行时还直接导入但未声明 [email protected] 和
@aloudata/[email protected]。这两项同样列为 CAN 宿主 peer 并在隔离夹具显式安装。
