@republicroad/seal-appshell 1.1.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/LICENSE +21 -0
- package/README.md +74 -0
- package/dist/assets/custom-node-schema.json.d.ts +549 -0
- package/dist/components/__tests__/skinned-decision-graph.test.d.ts +1 -0
- package/dist/components/__tests__/skinned-header.test.d.ts +1 -0
- package/dist/components/__tests__/skinned-panels.test.d.ts +1 -0
- package/dist/components/__tests__/skinned-simulator-panel.test.d.ts +1 -0
- package/dist/components/__tests__/skinned-simulator.test.d.ts +1 -0
- package/dist/components/custom-node/__tests__/custom-node-button.test.d.ts +1 -0
- package/dist/components/custom-node/__tests__/schema-container-tab.test.d.ts +1 -0
- package/dist/components/custom-node/crypto-node.d.ts +5 -0
- package/dist/components/custom-node/current-date-node.d.ts +8 -0
- package/dist/components/custom-node/http-request-node.d.ts +5 -0
- package/dist/components/custom-node/key-value-editor.d.ts +16 -0
- package/dist/components/custom-node/locked-corner-badge.d.ts +2 -0
- package/dist/components/custom-node/query-list-node.d.ts +5 -0
- package/dist/components/custom-node/schema-container-tab.d.ts +13 -0
- package/dist/components/icons/code.d.ts +3 -0
- package/dist/components/icons/flash-circle.d.ts +3 -0
- package/dist/components/reui/alert.d.ts +9 -0
- package/dist/components/reui/autocomplete.d.ts +40 -0
- package/dist/components/reui/badge.d.ts +14 -0
- package/dist/components/reui/cascader/cascader-async.d.ts +86 -0
- package/dist/components/reui/cascader/cascader-columns.d.ts +26 -0
- package/dist/components/reui/cascader/cascader-context.d.ts +190 -0
- package/dist/components/reui/cascader/cascader-footer.d.ts +83 -0
- package/dist/components/reui/cascader/cascader-i18n.d.ts +13 -0
- package/dist/components/reui/cascader/cascader-item.d.ts +112 -0
- package/dist/components/reui/cascader/cascader-lib.d.ts +137 -0
- package/dist/components/reui/cascader/cascader-nav.d.ts +56 -0
- package/dist/components/reui/cascader/cascader-types.d.ts +179 -0
- package/dist/components/reui/cascader/cascader-virtual.d.ts +62 -0
- package/dist/components/reui/cascader/cascader.d.ts +325 -0
- package/dist/components/shell-header.d.ts +20 -0
- package/dist/components/skinned-decision-graph.d.ts +19 -0
- package/dist/components/ui/alert-dialog.d.ts +20 -0
- package/dist/components/ui/avatar.d.ts +5 -0
- package/dist/components/ui/badge.d.ts +9 -0
- package/dist/components/ui/button.d.ts +11 -0
- package/dist/components/ui/dropdown-menu.d.ts +27 -0
- package/dist/components/ui/field.d.ts +24 -0
- package/dist/components/ui/input.d.ts +3 -0
- package/dist/components/ui/label.d.ts +4 -0
- package/dist/components/ui/scroll-area.d.ts +4 -0
- package/dist/components/ui/select.d.ts +13 -0
- package/dist/components/ui/separator.d.ts +3 -0
- package/dist/components/ui/sheet.d.ts +23 -0
- package/dist/components/ui/sonner.d.ts +5 -0
- package/dist/components/ui/spinner.d.ts +2 -0
- package/dist/components/ui/switch.d.ts +3 -0
- package/dist/components/ui/tabs.d.ts +6 -0
- package/dist/components/ui/toggle-group.d.ts +13 -0
- package/dist/components/ui/toggle.d.ts +12 -0
- package/dist/components/ui/tooltip.d.ts +7 -0
- package/dist/components/version-history/__tests__/version-history-panel.test.d.ts +1 -0
- package/dist/components/version-history/version-history-panel.d.ts +40 -0
- package/dist/context/theme.provider.d.ts +29 -0
- package/dist/hooks/useCustomNodes.d.ts +16 -0
- package/dist/index.d.ts +24 -0
- package/dist/index.js +121959 -0
- package/dist/integration/decision-graph-appshell.stories.d.ts +10 -0
- package/dist/lib/__tests__/crypto-protocol.test.d.ts +1 -0
- package/dist/lib/__tests__/custom-node-registry.test.d.ts +1 -0
- package/dist/lib/__tests__/http-request-protocol.test.d.ts +1 -0
- package/dist/lib/__tests__/json-path-protocol.test.d.ts +1 -0
- package/dist/lib/__tests__/storage-key.test.d.ts +1 -0
- package/dist/lib/auth/__tests__/adapter.test.d.ts +1 -0
- package/dist/lib/auth/adapter.d.ts +7 -0
- package/dist/lib/auth-client.d.ts +3 -0
- package/dist/lib/crypto-protocol.d.ts +28 -0
- package/dist/lib/custom-node-plans.d.ts +24 -0
- package/dist/lib/custom-node-registry.d.ts +13 -0
- package/dist/lib/custom-node-schema-source.d.ts +6 -0
- package/dist/lib/custom-node-types.d.ts +73 -0
- package/dist/lib/http-request-protocol.d.ts +47 -0
- package/dist/lib/json-path-protocol.d.ts +11 -0
- package/dist/lib/roster-source.d.ts +12 -0
- package/dist/lib/storage-key.d.ts +5 -0
- package/dist/lib/user-resolver.d.ts +6 -0
- package/dist/lib/utils.d.ts +2 -0
- package/dist/reui/icons/animated/duotone/lock.d.ts +3 -0
- package/dist/reui/icons/animated/outline/play-circle.d.ts +3 -0
- package/dist/reui/icons/default/outline/plus-circle.d.ts +3 -0
- package/dist/reui/icons/default/outline/shield-search.d.ts +3 -0
- package/dist/reui/icons/default/outline/trash-square.d.ts +3 -0
- package/dist/setupTests.d.ts +0 -0
- package/dist/shell/__tests__/default-simulate.test.d.ts +1 -0
- package/dist/shell/__tests__/graphs-http-adapter.test.d.ts +1 -0
- package/dist/shell/__tests__/indexed-db-adapter.test.d.ts +0 -0
- package/dist/shell/__tests__/restore.test.d.ts +0 -0
- package/dist/shell/default-simulate.d.ts +3 -0
- package/dist/shell/editor-shell.context.d.ts +22 -0
- package/dist/shell/execute-simulate.d.ts +8 -0
- package/dist/shell/graphs-http-adapter.d.ts +7 -0
- package/dist/shell/index.d.ts +10 -0
- package/dist/shell/indexed-db-adapter.d.ts +16 -0
- package/dist/shell/persistence.d.ts +89 -0
- package/dist/shell/restore.d.ts +21 -0
- package/dist/shell/types.d.ts +20 -0
- package/dist/skin/__tests__/apply.test.d.ts +1 -0
- package/dist/skin/apply.d.ts +7 -0
- package/dist/skin/layout.d.ts +17 -0
- package/dist/skin/types.d.ts +73 -0
- package/dist/style.css +2 -0
- package/package.json +73 -0
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Meta, StoryObj } from '@storybook/react-vite';
|
|
2
|
+
/**
|
|
3
|
+
* Cross-package integration: kernel DecisionGraph + appshell custom nodes
|
|
4
|
+
* (useCustomNodes) + an in-memory GraphPersistenceAdapter — the scheme D
|
|
5
|
+
* kernel/shell contract exercised end to end.
|
|
6
|
+
*/
|
|
7
|
+
declare const meta: Meta;
|
|
8
|
+
export default meta;
|
|
9
|
+
type Story = StoryObj;
|
|
10
|
+
export declare const KernelPlusAppshell: Story;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { CustomNodeExpression } from './custom-node-types';
|
|
2
|
+
export declare const CRYPTO_UDF = "crypto";
|
|
3
|
+
export declare const CRYPTO_ALGORITHMS: readonly ["md5", "sha1", "sha256", "sha512"];
|
|
4
|
+
export type CryptoAlgorithm = (typeof CRYPTO_ALGORITHMS)[number];
|
|
5
|
+
export declare const CRYPTO_ENCODINGS: readonly ["hex", "base64", "base64url"];
|
|
6
|
+
export type CryptoEncoding = (typeof CRYPTO_ENCODINGS)[number];
|
|
7
|
+
export interface CryptoFields {
|
|
8
|
+
inputExpr: string;
|
|
9
|
+
algorithm: CryptoAlgorithm;
|
|
10
|
+
secretExpr: string;
|
|
11
|
+
encoding: CryptoEncoding;
|
|
12
|
+
upperExpr: string;
|
|
13
|
+
}
|
|
14
|
+
export type CryptoMode = 'plain' | 'hmac';
|
|
15
|
+
/** 密钥槽位非空即 HMAC(旧图兼容的隐式约定) */
|
|
16
|
+
export declare const deriveCryptoMode: (secretExpr: string) => CryptoMode;
|
|
17
|
+
/** 显式模式归一:普通摘要强制清空密钥槽位,HMAC 保留原表达式 */
|
|
18
|
+
export declare const applyCryptoMode: (fields: CryptoFields, mode: CryptoMode) => CryptoFields;
|
|
19
|
+
export declare const normalizeAlgorithm: (value: string) => CryptoAlgorithm;
|
|
20
|
+
export declare const normalizeEncoding: (value: string) => CryptoEncoding;
|
|
21
|
+
/** upper 槽位仅接受布尔字面量 true(其余一律视为未勾选) */
|
|
22
|
+
export declare const isUpperChecked: (expr: string) => boolean;
|
|
23
|
+
export declare const parseCrypto: (expr?: CustomNodeExpression) => CryptoFields;
|
|
24
|
+
/**
|
|
25
|
+
* 变长序列化:固定前缀 [crypto, input, "algorithm"],可选尾参(secret/encoding/upper)
|
|
26
|
+
* 末尾连续空值截断省略,中段空串占位保证槽位对齐;后端对缺省/空值回退默认。
|
|
27
|
+
*/
|
|
28
|
+
export declare const toCryptoValue: (fields: CryptoFields) => string[];
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { CustomFunctionTool, CustomNodeConfig, CustomNodeNamespace } from './custom-node-types';
|
|
2
|
+
export declare const uid: () => string;
|
|
3
|
+
export declare const LEGACY_UDF_KIND = "UDF";
|
|
4
|
+
export declare const CUSTOM_FUNCTION_GROUP = "\u81EA\u5B9A\u4E49\u51FD\u6570";
|
|
5
|
+
export declare const EMPTY_EXPRESSIONS_CONFIG: CustomNodeConfig;
|
|
6
|
+
/** 纯数据节点计划:kind 约定与播种逻辑在此(可测),React/jdm-editor 组装在 registry */
|
|
7
|
+
export type CustomNodePlan = {
|
|
8
|
+
kind: string;
|
|
9
|
+
displayName: string;
|
|
10
|
+
group: string;
|
|
11
|
+
shortDescription?: string;
|
|
12
|
+
/** 命名空间工具集:存在时节点挂 schema 感知编辑面板(函数下拉 + 位置参数) */
|
|
13
|
+
tools?: CustomFunctionTool[];
|
|
14
|
+
seed: (params: {
|
|
15
|
+
index: number;
|
|
16
|
+
}) => {
|
|
17
|
+
name: string;
|
|
18
|
+
config: CustomNodeConfig;
|
|
19
|
+
};
|
|
20
|
+
};
|
|
21
|
+
export declare const containerPlan: (namespace: CustomNodeNamespace) => CustomNodePlan;
|
|
22
|
+
export declare const legacyUdfPlan: () => CustomNodePlan;
|
|
23
|
+
/** schema → 节点计划:每个命名空间一个集合容器节点(kind = 命名空间名,函数限定集合内) */
|
|
24
|
+
export declare function schemaToNodePlans(schema: CustomNodeNamespace[]): CustomNodePlan[];
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { CustomNodeSpecification, createJdmNode } from '@republicroad/seal-editor';
|
|
2
|
+
import { CustomNodeNamespace } from './custom-node-types';
|
|
3
|
+
export type CustomNodeSpec = CustomNodeSpecification<object, any>;
|
|
4
|
+
type SpecExtras = Pick<CustomNodeSpec, 'renderTab' | 'calculateDiff' | 'inferTypes'>;
|
|
5
|
+
type CreateSpecNodeOptions = Parameters<typeof createJdmNode>[0] & SpecExtras;
|
|
6
|
+
/** createJdmNode 只收 BaseNode 画布字段;spec 级 renderTab/calculateDiff/inferTypes 由本组合器附加 */
|
|
7
|
+
export declare const createSpecNode: (options: CreateSpecNodeOptions) => CustomNodeSpec;
|
|
8
|
+
export { CUSTOM_FUNCTION_GROUP, LEGACY_UDF_KIND, uid } from './custom-node-plans';
|
|
9
|
+
export { parseOperatorArgs } from './http-request-protocol';
|
|
10
|
+
/** 每个命名空间生成一个集合容器节点(kind = 命名空间名) */
|
|
11
|
+
export declare function schemaToCustomNodes(schema: CustomNodeNamespace[]): ReturnType<typeof createJdmNode>[];
|
|
12
|
+
export declare function createLegacyUdfNode(): ReturnType<typeof createJdmNode>;
|
|
13
|
+
export { DEFAULT_SCHEMA_URL, fetchCustomNodeSchema, parseCustomNodeSchemaPayload, type CustomNodeSchemaSource, } from './custom-node-schema-source';
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { CustomNodeNamespace } from './custom-node-types';
|
|
2
|
+
export type CustomNodeSchemaSource = string | (() => Promise<CustomNodeNamespace[]> | CustomNodeNamespace[]);
|
|
3
|
+
export declare const DEFAULT_SCHEMA_URL = "/api/custom-nodes/schema";
|
|
4
|
+
/** 校验并收窄 schema 载荷;非法结构抛错,由调用方决定回退策略 */
|
|
5
|
+
export declare function parseCustomNodeSchemaPayload(payload: unknown): CustomNodeNamespace[];
|
|
6
|
+
export declare function fetchCustomNodeSchema(source?: CustomNodeSchemaSource): Promise<CustomNodeNamespace[]>;
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
export interface JsonSchemaProperty {
|
|
2
|
+
type?: string;
|
|
3
|
+
title?: string;
|
|
4
|
+
description?: string;
|
|
5
|
+
default?: unknown;
|
|
6
|
+
anyOf?: JsonSchemaProperty[];
|
|
7
|
+
items?: JsonSchemaProperty;
|
|
8
|
+
properties?: Record<string, JsonSchemaProperty>;
|
|
9
|
+
required?: string[];
|
|
10
|
+
additionalProperties?: boolean | JsonSchemaProperty;
|
|
11
|
+
$ref?: string;
|
|
12
|
+
$defs?: Record<string, JsonSchemaProperty>;
|
|
13
|
+
enum?: unknown[];
|
|
14
|
+
format?: string;
|
|
15
|
+
[key: string]: unknown;
|
|
16
|
+
}
|
|
17
|
+
export interface JsonSchema {
|
|
18
|
+
type?: string;
|
|
19
|
+
title?: string;
|
|
20
|
+
description?: string;
|
|
21
|
+
default?: unknown;
|
|
22
|
+
anyOf?: JsonSchema[];
|
|
23
|
+
items?: JsonSchema;
|
|
24
|
+
properties?: Record<string, JsonSchemaProperty>;
|
|
25
|
+
required?: string[];
|
|
26
|
+
additionalProperties?: boolean | JsonSchemaProperty;
|
|
27
|
+
$ref?: string;
|
|
28
|
+
$defs?: Record<string, JsonSchemaProperty>;
|
|
29
|
+
[key: string]: unknown;
|
|
30
|
+
}
|
|
31
|
+
export interface CustomFunctionTool {
|
|
32
|
+
name: string;
|
|
33
|
+
title: string;
|
|
34
|
+
type: 'function';
|
|
35
|
+
description?: string;
|
|
36
|
+
parameters: {
|
|
37
|
+
properties: Record<string, JsonSchemaProperty>;
|
|
38
|
+
required?: string[];
|
|
39
|
+
title?: string;
|
|
40
|
+
type?: 'object';
|
|
41
|
+
};
|
|
42
|
+
returns: JsonSchema;
|
|
43
|
+
namespace: string;
|
|
44
|
+
kind: string;
|
|
45
|
+
}
|
|
46
|
+
export interface CustomNodeNamespace {
|
|
47
|
+
/** 恒为 'namespace'(集合容器档;契约字段保留供未来场景) */
|
|
48
|
+
type?: 'namespace';
|
|
49
|
+
title: string;
|
|
50
|
+
name: string;
|
|
51
|
+
description?: string;
|
|
52
|
+
tools: CustomFunctionTool[];
|
|
53
|
+
}
|
|
54
|
+
export type CustomNodeExpression = {
|
|
55
|
+
id: string;
|
|
56
|
+
key: string;
|
|
57
|
+
/**
|
|
58
|
+
* 调用形态三模(JSON-RPC 式类型判别):
|
|
59
|
+
* - 数组(默认)= 位置调用 [fn, arg1, ..., argn]
|
|
60
|
+
* - 字符串 = legacy `;;` 拼接(旧图兼容)
|
|
61
|
+
* - 对象 = 命名调用 { $call: fn, ...具名实参 }(实参值为 zen 表达式或字面量)
|
|
62
|
+
*/
|
|
63
|
+
value: string | string[] | Record<string, unknown>;
|
|
64
|
+
};
|
|
65
|
+
export type CustomNodeConfig = {
|
|
66
|
+
/** 锁定节点 UI 标记:true 表示此节点有专属页面设计(数据侧显式声明,缺省=通用锁定表格 UI) */
|
|
67
|
+
locked?: true;
|
|
68
|
+
inputField?: string | null;
|
|
69
|
+
outputPath?: string | null;
|
|
70
|
+
passThrough?: boolean;
|
|
71
|
+
expressions: CustomNodeExpression[];
|
|
72
|
+
__meta__?: Record<string, unknown>;
|
|
73
|
+
};
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { CustomNodeExpression } from './custom-node-types';
|
|
2
|
+
export declare const UDF_FUNC = "http_request";
|
|
3
|
+
export declare const HTTP_METHODS: readonly ["GET", "POST", "PUT", "PATCH", "DELETE", "HEAD", "OPTIONS"];
|
|
4
|
+
export type HttpMethod = (typeof HTTP_METHODS)[number];
|
|
5
|
+
export interface HttpRequestFields {
|
|
6
|
+
urlExpr: string;
|
|
7
|
+
method: HttpMethod;
|
|
8
|
+
headersExpr: string;
|
|
9
|
+
bodyExpr: string;
|
|
10
|
+
paramsExpr: string;
|
|
11
|
+
timeoutExpr: string;
|
|
12
|
+
retryExpr: string;
|
|
13
|
+
authExpr: string;
|
|
14
|
+
}
|
|
15
|
+
export interface KeyValueRow {
|
|
16
|
+
key: string;
|
|
17
|
+
valueExpr: string;
|
|
18
|
+
}
|
|
19
|
+
export type AuthMode = 'none' | 'basic' | 'bearer';
|
|
20
|
+
export interface AuthState {
|
|
21
|
+
mode: AuthMode;
|
|
22
|
+
username: string;
|
|
23
|
+
passwordExpr: string;
|
|
24
|
+
tokenExpr: string;
|
|
25
|
+
}
|
|
26
|
+
export declare const EMPTY_AUTH: AuthState;
|
|
27
|
+
export declare const unquote: (value: string) => string;
|
|
28
|
+
export declare const quote: (value: string) => string;
|
|
29
|
+
/** 表达式实参拆分:数组原样(仅 trim);旧 `;;` 字符串按引号感知切分 */
|
|
30
|
+
export declare const parseOperatorArgs: (expr: string | string[]) => string[];
|
|
31
|
+
export declare const normalizeMethod: (value: string) => HttpMethod;
|
|
32
|
+
export declare const isIdentKey: (key: string) => boolean;
|
|
33
|
+
export declare const serializeHeaderKey: (key: string) => string;
|
|
34
|
+
export declare const splitTopLevel: (text: string, separator: string) => string[];
|
|
35
|
+
export declare const findTopLevelColon: (text: string) => number;
|
|
36
|
+
/** `{ k: expr, ... }` 对象字面量 ⇄ 行数组;无法拆行时返回 null(交由原始表达式模式) */
|
|
37
|
+
export declare const parseObjectLiteralRows: (expr: string) => KeyValueRow[] | null;
|
|
38
|
+
export declare const serializeObjectLiteralRows: (rows: KeyValueRow[]) => string;
|
|
39
|
+
export declare const parseHttpRequest: (expr?: CustomNodeExpression) => HttpRequestFields;
|
|
40
|
+
/**
|
|
41
|
+
* 变长序列化:可选尾部参数(params/timeout/retry/auth)按位置占位,末尾连续空值截断省略;
|
|
42
|
+
* 中段空值保留空串占位以保证后续参数位置正确,后端对空串回退默认值。
|
|
43
|
+
*/
|
|
44
|
+
export declare const toHttpRequestValue: (fields: HttpRequestFields) => string[];
|
|
45
|
+
/** 解析 auth 表达式为结构化状态;非对象字面量或无法识别的 type 返回 null(交由界面提示保留原文) */
|
|
46
|
+
export declare const parseAuthState: (expr: string) => AuthState | null;
|
|
47
|
+
export declare const serializeAuthExpr: (state: AuthState) => string;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { CustomNodeExpression } from './custom-node-types';
|
|
2
|
+
export declare const JSON_PATH_UDF = "json_path";
|
|
3
|
+
export interface JsonPathFields {
|
|
4
|
+
inputExpr: string;
|
|
5
|
+
pathExpr: string;
|
|
6
|
+
defaultExpr: string;
|
|
7
|
+
}
|
|
8
|
+
export declare const normalizeJsonPath: (value: string) => string;
|
|
9
|
+
export declare const parseJsonPath: (expr?: CustomNodeExpression) => JsonPathFields;
|
|
10
|
+
/** 变长尾参:default 末尾空值截断;路径槽位恒以字符串字面量序列化 */
|
|
11
|
+
export declare const toJsonPathValue: (fields: JsonPathFields) => string[];
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* roster 名单数据源(可注入):默认同源 `/api/rosters`(宿主后端实现名单列表契约,
|
|
3
|
+
* 返回 `[{ name, size }]`)。跨源后端/本地夹具经 setRosterSource 注入。
|
|
4
|
+
*/
|
|
5
|
+
export interface RosterOption {
|
|
6
|
+
name: string;
|
|
7
|
+
size: number;
|
|
8
|
+
}
|
|
9
|
+
export type RosterSource = (query: string) => Promise<RosterOption[]>;
|
|
10
|
+
export declare const getRosterSource: () => RosterSource;
|
|
11
|
+
/** 宿主注入名单来源(跨源后端/本地夹具等);与 setRosterSource 对应的恢复用 resetRosterSource */
|
|
12
|
+
export declare const setRosterSource: (source: RosterSource) => void;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export declare const storageKey: (key: string) => string;
|
|
2
|
+
/** 读取命名空间键;新键缺失时回退读历史无前缀键(一次性兼容),均缺失或存储不可用返回 null */
|
|
3
|
+
export declare const readStorage: (key: string) => string | null;
|
|
4
|
+
/** 写入命名空间键;存储不可用时静默忽略 */
|
|
5
|
+
export declare const writeStorage: (key: string, value: string) => void;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { AuthAdapter } from './auth/adapter';
|
|
2
|
+
export type UserResolver = () => Promise<{
|
|
3
|
+
user?: string;
|
|
4
|
+
}> | null;
|
|
5
|
+
export declare const createUserResolver: (adapter: AuthAdapter) => UserResolver;
|
|
6
|
+
export declare const createBetterAuthResolver: () => UserResolver;
|
|
File without changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { CustomNodeSpecification } from '@republicroad/seal-editor';
|
|
2
|
+
import { default as React } from 'react';
|
|
3
|
+
import { CustomNodeNamespace } from '../lib/custom-node-types';
|
|
4
|
+
import { UserResolver } from '../lib/user-resolver';
|
|
5
|
+
import { GraphPersistenceAdapter } from './persistence';
|
|
6
|
+
import { EditorShellOptions, SimulateHandler } from './types';
|
|
7
|
+
type CustomNodeSpec = CustomNodeSpecification<object, any>;
|
|
8
|
+
export interface EditorShellContextValue {
|
|
9
|
+
customNodes: CustomNodeSpec[];
|
|
10
|
+
schema: CustomNodeNamespace[] | null;
|
|
11
|
+
ready: boolean;
|
|
12
|
+
userResolver: UserResolver;
|
|
13
|
+
runSimulate: SimulateHandler;
|
|
14
|
+
/** 图持久化适配器:注入后页面打开/另存走宿主存储;未注入则回退浏览器本地文件 */
|
|
15
|
+
persistence?: GraphPersistenceAdapter;
|
|
16
|
+
}
|
|
17
|
+
export declare const EditorShellProvider: React.FC<{
|
|
18
|
+
options?: EditorShellOptions;
|
|
19
|
+
children: React.ReactNode;
|
|
20
|
+
}>;
|
|
21
|
+
export declare const useEditorShell: () => EditorShellContextValue;
|
|
22
|
+
export {};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { SimulateHandler } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* 模拟实现:POST {baseUrl}/v1/execute(demo-server / verdict 执行方言),
|
|
4
|
+
* `{ model, input, trace: true }` → `{ result, performance, trace }`,
|
|
5
|
+
* 映射为 kernel Simulation 信封(错误不抛出,经 errorMessage 传达)。
|
|
6
|
+
* 与 createDefaultSimulate(/api/simulate 方言)并列,按宿主引擎二选一。
|
|
7
|
+
*/
|
|
8
|
+
export declare const createExecuteSimulate: (baseUrl?: string) => SimulateHandler;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { GraphPersistenceAdapter } from './persistence';
|
|
2
|
+
/**
|
|
3
|
+
* 将 /api/graphs 参考实现封装为 GraphPersistenceAdapter。
|
|
4
|
+
* 宿主可原样复用,或照此实现自己的后端(契约见 persistence.ts)。
|
|
5
|
+
* 404 → load 返回 null / delete 返回 false;409 CONFLICT → 抛 GraphPersistenceError。
|
|
6
|
+
*/
|
|
7
|
+
export declare const createGraphsHttpAdapter: (baseUrl?: string) => GraphPersistenceAdapter;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export { EditorShellProvider, useEditorShell, type EditorShellContextValue } from './editor-shell.context';
|
|
2
|
+
export { ThemeContextProvider, useTheme, type ThemePreference } from '../context/theme.provider';
|
|
3
|
+
export { createDefaultSimulate } from './default-simulate';
|
|
4
|
+
export { createExecuteSimulate } from './execute-simulate';
|
|
5
|
+
export type { EditorShellOptions, SimulateHandler, ShellSimulateResult } from './types';
|
|
6
|
+
export { GraphPersistenceError } from './persistence';
|
|
7
|
+
export { createGraphsHttpAdapter } from './graphs-http-adapter';
|
|
8
|
+
export { createIndexedDbAdapter, AUTO_VERSIONS_KEEP } from './indexed-db-adapter';
|
|
9
|
+
export { restoreVersion } from './restore';
|
|
10
|
+
export type { GraphPersistenceAdapter, GraphRecord, GraphRecordMeta, PersistenceErrorCode } from './persistence';
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { GraphPersistenceAdapter } from './persistence';
|
|
2
|
+
/**
|
|
3
|
+
* 本地图多版本持久化适配器(IndexedDB)。
|
|
4
|
+
*
|
|
5
|
+
* 为无后端的宿主提供与 HTTP 适配器同构的版本能力:
|
|
6
|
+
* head + 版本归档 + auto/manual 标记 + 保留策略(全部 manual + 最近 AUTO_VERSIONS_KEEP 条 auto)。
|
|
7
|
+
*
|
|
8
|
+
* 语义差异(本地单用户):无 owner 隔离、无 CONFLICT——save 恒成功,baseRevision 忽略。
|
|
9
|
+
*
|
|
10
|
+
* 存储模型:object store "graphs",双键——
|
|
11
|
+
* head::{id} → { meta, content }
|
|
12
|
+
* ver::{id}::{revision} → { meta, content }(归档)
|
|
13
|
+
*/
|
|
14
|
+
export declare const AUTO_VERSIONS_KEEP = 20;
|
|
15
|
+
/** 本地图多版本持久化适配器(IndexedDB)——无后端宿主的完整版本能力 */
|
|
16
|
+
export declare function createIndexedDbAdapter(): GraphPersistenceAdapter;
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import { TabSnapshot } from '@republicroad/seal-editor';
|
|
2
|
+
export interface GraphRecordMeta {
|
|
3
|
+
/** 宿主侧唯一标识(UUID/slug,由宿主生成) */
|
|
4
|
+
id: string;
|
|
5
|
+
name: string;
|
|
6
|
+
description?: string;
|
|
7
|
+
/** 缺省=共享(复用名单 owner 语义);宿主服务端注入,客户端传值被剥离 */
|
|
8
|
+
owner?: string;
|
|
9
|
+
tags?: string[];
|
|
10
|
+
/** 图+配置打包:宿主可挂载调度、环境绑定等非图数据 */
|
|
11
|
+
extensions?: Record<string, unknown>;
|
|
12
|
+
/** 当前 head 版本号(宿主/适配器生成,单调递增)。save 调用方可省略——由适配器分配新版本号;load/list 场景恒有 */
|
|
13
|
+
revision?: string;
|
|
14
|
+
/** 自动保存条目(与手动保存区分显示/治理策略),缺省 = 手动 */
|
|
15
|
+
auto?: boolean;
|
|
16
|
+
/**
|
|
17
|
+
* 版本命名("named version")。保存时携带 → 该版本归档后按名显示;
|
|
18
|
+
* 命名版本不受 auto 保留策略治理(见各适配器实现)。
|
|
19
|
+
*/
|
|
20
|
+
versionName?: string;
|
|
21
|
+
/** 钉住标记(S007):钉住的版本(含 auto)同样豁免 auto 保留策略治理。 */
|
|
22
|
+
pinned?: boolean;
|
|
23
|
+
createdAt?: string;
|
|
24
|
+
updatedAt?: string;
|
|
25
|
+
}
|
|
26
|
+
export interface GraphRecord extends GraphRecordMeta {
|
|
27
|
+
/** DecisionGraphType(nodes/edges/meta),由消费方解包 */
|
|
28
|
+
content: unknown;
|
|
29
|
+
/**
|
|
30
|
+
* UI 会话现场(GraphRef.serialize() 的快照:viewport/打开页签/各页签 slice)。
|
|
31
|
+
* 与 content 兄弟存储——历史条目=完整现场快照(1a+4b);缺省=旧记录降级(跳过 restore)。
|
|
32
|
+
*/
|
|
33
|
+
session?: TabSnapshot;
|
|
34
|
+
}
|
|
35
|
+
export type PersistenceErrorCode = 'NOT_FOUND' | 'CONFLICT' | 'FORBIDDEN';
|
|
36
|
+
export declare class GraphPersistenceError extends Error {
|
|
37
|
+
code: PersistenceErrorCode;
|
|
38
|
+
constructor(code: PersistenceErrorCode, message?: string);
|
|
39
|
+
}
|
|
40
|
+
export interface GraphPersistenceAdapter {
|
|
41
|
+
/** 列出当前用户可见的图元数据(head 版本);未实现则 shell 隐藏「打开」面板 */
|
|
42
|
+
list?(query?: {
|
|
43
|
+
q?: string;
|
|
44
|
+
}): Promise<GraphRecordMeta[]>;
|
|
45
|
+
/**
|
|
46
|
+
* 加载指定图。
|
|
47
|
+
* @param opts.revision 指定历史版本号;省略则加载 head。
|
|
48
|
+
* @returns null = 不可见或不存在(返回 404 语义,不暴露是否存在)
|
|
49
|
+
*/
|
|
50
|
+
load(id: string, opts?: {
|
|
51
|
+
revision?: string;
|
|
52
|
+
}): Promise<GraphRecord | null>;
|
|
53
|
+
/**
|
|
54
|
+
* 保存(upsert)。
|
|
55
|
+
* @param opts.baseRevision 乐观锁:提供时校验 head 是否匹配,不匹配抛 CONFLICT。
|
|
56
|
+
* @returns 包含分配的 id 与新 revision。
|
|
57
|
+
*/
|
|
58
|
+
save(record: GraphRecord, opts?: {
|
|
59
|
+
baseRevision?: string;
|
|
60
|
+
}): Promise<{
|
|
61
|
+
id: string;
|
|
62
|
+
revision: string;
|
|
63
|
+
}>;
|
|
64
|
+
/** 删除指定图;返回 false = 不可见或不存在(404 语义) */
|
|
65
|
+
delete?(id: string): Promise<boolean>;
|
|
66
|
+
/** 列出指定图的所有历史版本(可选;未实现则 shell 不展示版本历史面板) */
|
|
67
|
+
listVersions?(id: string): Promise<Array<{
|
|
68
|
+
revision: string;
|
|
69
|
+
versionName?: string;
|
|
70
|
+
pinned?: boolean;
|
|
71
|
+
updatedAt?: string;
|
|
72
|
+
auto?: boolean;
|
|
73
|
+
}>>;
|
|
74
|
+
/**
|
|
75
|
+
* 更新指定历史版本的元数据(钉住/命名,S007):可选方法;未实现则 shell 隐藏
|
|
76
|
+
* 对应入口。部分更新语义:仅显式给出的键被更新(undefined = 保留现值,
|
|
77
|
+
* null = 清除),未提及的兄弟键必须原样保留。
|
|
78
|
+
* @throws GraphPersistenceError('NOT_FOUND') 版本不存在时(本地适配器语义)。
|
|
79
|
+
*/
|
|
80
|
+
updateVersionMeta?(id: string, revision: string, meta: {
|
|
81
|
+
pinned?: boolean;
|
|
82
|
+
versionName?: string | null;
|
|
83
|
+
}): Promise<void>;
|
|
84
|
+
/**
|
|
85
|
+
* 重命名(或清除,传 null)指定历史版本的 versionName。兼容别名:
|
|
86
|
+
* 等价于 updateVersionMeta(id, revision, { versionName })。
|
|
87
|
+
*/
|
|
88
|
+
renameVersion?(id: string, revision: string, versionName: string | null): Promise<void>;
|
|
89
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { GraphPersistenceAdapter } from './persistence';
|
|
2
|
+
/**
|
|
3
|
+
* 恢复即前进(restore-is-forward):将指定历史版本的内容固化为新的 head。
|
|
4
|
+
*
|
|
5
|
+
* 语义:load(revision) 取回历史条目 → 以其 content/session/meta 为基础 save()。
|
|
6
|
+
* 两个适配器的 save 恒定「bump head + 归档旧 head」,因此恢复只追加历史、
|
|
7
|
+
* 永不覆盖其后版本;被恢复的源版本自身也完好保留(本函数不再为其建档)。
|
|
8
|
+
*
|
|
9
|
+
* 宿主的 VersionHistoryPanel.onRestore 可直接调用本函数,无需自行编排。
|
|
10
|
+
*
|
|
11
|
+
* @param opts.versionName 可选:为恢复产生的新 head 命名(透传给 save,
|
|
12
|
+
* 命名版本不受 auto 保留策略治理)。
|
|
13
|
+
* @returns 新 head 的 id 与 revision。
|
|
14
|
+
* @throws GraphPersistenceError('NOT_FOUND') 图或版本不存在时。
|
|
15
|
+
*/
|
|
16
|
+
export declare function restoreVersion(adapter: GraphPersistenceAdapter, id: string, revision: string, opts?: {
|
|
17
|
+
versionName?: string;
|
|
18
|
+
}): Promise<{
|
|
19
|
+
id: string;
|
|
20
|
+
revision: string;
|
|
21
|
+
}>;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { DecisionGraphType, Simulation } from '@republicroad/seal-editor';
|
|
2
|
+
import { AuthAdapter } from '../lib/auth/adapter';
|
|
3
|
+
import { CustomNodeSchemaSource } from '../lib/custom-node-schema-source';
|
|
4
|
+
import { GraphPersistenceAdapter } from './persistence';
|
|
5
|
+
export interface ShellSimulateResult {
|
|
6
|
+
simulation: Simulation;
|
|
7
|
+
/** 失败时的人类可读错误摘要(供宿主 toast/提示);成功时为 undefined */
|
|
8
|
+
errorMessage?: string;
|
|
9
|
+
}
|
|
10
|
+
export type SimulateHandler = (graph: DecisionGraphType, context: unknown) => Promise<ShellSimulateResult>;
|
|
11
|
+
export interface EditorShellOptions {
|
|
12
|
+
/** 自定义节点 schema 来源:默认同源 /api/custom-nodes/schema,可传 URL 或加载函数 */
|
|
13
|
+
schemaSource?: CustomNodeSchemaSource;
|
|
14
|
+
/** 鉴权适配器:默认 anonymous(无用户) */
|
|
15
|
+
authAdapter?: AuthAdapter;
|
|
16
|
+
/** 模拟执行实现:默认同源 POST /api/simulate;宿主可注入本地 WASM 引擎或远程服务 */
|
|
17
|
+
simulate?: SimulateHandler;
|
|
18
|
+
/** 图持久化适配器:未提供时 shell 回退到浏览器本地文件(File System Access API) */
|
|
19
|
+
persistence?: GraphPersistenceAdapter;
|
|
20
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { CustomNodeSpec } from '../lib/custom-node-registry';
|
|
2
|
+
import { NodeUiOverride } from './types';
|
|
3
|
+
/**
|
|
4
|
+
* 按节点 kind 应用 UI 槽位覆写:仅替换显式给出的槽位,其余字段(kind/displayName/
|
|
5
|
+
* generateNode/inferTypes…)与未命中 kind 的节点保持原样。纯函数,不改入参。
|
|
6
|
+
*/
|
|
7
|
+
export declare function applyNodeOverrides(nodes: CustomNodeSpec[], overrides?: Record<string, NodeUiOverride>): CustomNodeSpec[];
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { ToolbarItem } from '@republicroad/seal-editor';
|
|
2
|
+
import { SkinSlotHostContext, SkinToolbarLayout } from './types';
|
|
3
|
+
/** 槽位排序:order 数组序优先,未列出者按字典序排后(toolbar/panels 共用语义) */
|
|
4
|
+
export declare const orderSlotEntries: <T>(entries: [string, T][], order: string[] | undefined) => [string, T][];
|
|
5
|
+
/** 裸名槽位 id dev-warn 并补 host: 前缀(规格稿 §6-2 命名空间) */
|
|
6
|
+
export declare const ensureHostPrefix: (id: string) => string;
|
|
7
|
+
/**
|
|
8
|
+
* skin.toolbar 槽位 → kernel ToolbarItem[](S005 P1 映射纯函数)。
|
|
9
|
+
*
|
|
10
|
+
* - 无槽位返回 undefined(零注入透传,SkinnedDecisionGraph 不改写宿主 props)
|
|
11
|
+
* - 裸名 id dev-warn 并自动补 `host:` 前缀(规格稿 §6-2 命名空间)
|
|
12
|
+
* - order 数组序优先,未列出者按字典序排在之后(规格稿 §4)
|
|
13
|
+
* - 注入项全部落在缺省独立组:聚在最右分隔线后(规格稿 §10-1 宿主裁决)
|
|
14
|
+
*/
|
|
15
|
+
export declare function mapToolbarSlots(layout: SkinToolbarLayout | undefined, host: SkinSlotHostContext): ToolbarItem[] | undefined;
|
|
16
|
+
/** 右缘面板槽位的有序 id 列表(无槽位返回 undefined;裸名同样 dev-warn 补前缀) */
|
|
17
|
+
export declare function mapPanelSlotIds(layout: SkinToolbarLayout | undefined): string[] | undefined;
|