@vcp-dev/site-edit-engine 0.6.0 → 0.6.2

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.
@@ -31,6 +31,7 @@ export interface RenderEntry {
31
31
  childKeys: string[];
32
32
  pageCompositionUnitKey?: string;
33
33
  operationSummary: OperationSummary;
34
+ dynamicDataSummary?: DynamicDataSummaryView;
34
35
  }
35
36
  /**
36
37
  * 能力概要 —— 标记该节点支持的四个核心操作。
@@ -42,6 +43,40 @@ export interface OperationSummary {
42
43
  canMove: boolean;
43
44
  canRemove: boolean;
44
45
  }
46
+ export type DynamicSourceKindView = "vcp-cms-collection" | "vcp-cms-form" | "vcp-cms-settings" | "vcp-cms-navigation" | "site-api-route" | "external-api" | "unknown-api";
47
+ export type DynamicSourceTypeView = "cms-field" | "api-field";
48
+ export type DynamicTargetKindView = "text" | "attribute" | "richtext" | "repeat-region" | "component-prop";
49
+ export type DynamicConfidenceView = "exact" | "safe-derived" | "partial" | "unknown";
50
+ export interface DynamicEvidenceView {
51
+ file: string;
52
+ symbol?: string;
53
+ reason: string;
54
+ }
55
+ export interface DynamicDataBindingView {
56
+ sourceKind: DynamicSourceKindView;
57
+ sourceType: DynamicSourceTypeView;
58
+ endpointPattern?: string;
59
+ operation?: string;
60
+ collection?: string;
61
+ fieldPath?: string;
62
+ valuePath?: string;
63
+ targetKind: DynamicTargetKindView;
64
+ targetName: string;
65
+ confidence: DynamicConfidenceView;
66
+ readonly: true;
67
+ evidence: DynamicEvidenceView[];
68
+ }
69
+ export interface DynamicDataDetailView {
70
+ hasDynamicData: boolean;
71
+ bindings: DynamicDataBindingView[];
72
+ }
73
+ export interface DynamicDataSummaryView {
74
+ hasDynamicData: boolean;
75
+ sourceKinds: DynamicSourceKindView[];
76
+ primaryEndpoint?: string;
77
+ primaryCollection?: string;
78
+ primaryFieldPath?: string;
79
+ }
45
80
  /**
46
81
  * 选中节点的详细信息 —— 按需加载。
47
82
  * 包含完整 capability、text segments、boundary 信息、邻接关系。
@@ -62,6 +97,7 @@ export interface RenderObjectDetail {
62
97
  mediaModel?: MediaModelView;
63
98
  styleSource?: StyleSourceView;
64
99
  conditional?: ConditionalDetailView;
100
+ dynamicData?: DynamicDataDetailView;
65
101
  textSegments: TextSegmentView[];
66
102
  boundaryKind: BoundaryKind | null;
67
103
  isOpaque: boolean;
@@ -69,6 +105,30 @@ export interface RenderObjectDetail {
69
105
  children: RenderEntryRef[];
70
106
  siblings: RenderEntryRef[];
71
107
  }
108
+ /**
109
+ * 面向 get-object-edit-context 的紧凑投影。
110
+ * 只包含 Wire DTO 实际消费的字段,避免为了选中态读取并构造 children / siblings
111
+ * 以及完整 provenance chain、文本值等 detail-only 数据。
112
+ */
113
+ export interface RenderObjectEditContext {
114
+ key: string;
115
+ tag: string;
116
+ componentName: string;
117
+ sourceFile: string;
118
+ sourceLocator?: SourceLocatorView;
119
+ label: string;
120
+ capabilities: NodeCapabilitySnapshot;
121
+ provenanceChain?: Pick<ProvenanceChainView, "editMode" | "diagnostics">;
122
+ dynamicData?: DynamicDataDetailView;
123
+ textSegments: Array<{
124
+ index: number;
125
+ editable: boolean;
126
+ source: Pick<TextSourceView, "kind"> | null;
127
+ }>;
128
+ boundaryKind: BoundaryKind | null;
129
+ isOpaque: boolean;
130
+ ancestors: RenderEntryRef[];
131
+ }
72
132
  export interface SourceLocatorRangeView {
73
133
  startLine: number;
74
134
  startColumn: number;
@@ -6,4 +6,4 @@ export type { DesignerEvent } from "./protocol/event.js";
6
6
  export type { OperationError } from "./protocol/error.js";
7
7
  export type { SourceIdentity } from "./protocol/identity.js";
8
8
  export type { InsertableTag, InsertNodeSpec, MoveTarget, OperationParams, OperationRequest, OperationResult, OperationSelectionRef, OperationTarget, OperationType, OperationValue, StyleBreakpoint, StyleProperty, StyleStateMode, } from "./protocol/operation.js";
9
- export type { ComponentSemanticDescriptor, ConditionalDetailView, ContentModelView, EffectiveWriteTargetView, MediaModelView, OperationSummary, ProvenanceChainView, ProvenanceHopView, RenderDocument, RenderEntry, RenderEntryRef, RenderObjectDetail, SemanticSourceView, SourceLocatorRangeView, SourceLocatorView, StyleSourceOperation, StyleSourceView, TextSegmentView, TextSourceView, WriteTargetView, } from "./protocol/render.js";
9
+ export type { ComponentSemanticDescriptor, ConditionalDetailView, DynamicConfidenceView, DynamicDataBindingView, DynamicDataDetailView, DynamicDataSummaryView, DynamicEvidenceView, DynamicSourceKindView, DynamicSourceTypeView, DynamicTargetKindView, ContentModelView, EffectiveWriteTargetView, MediaModelView, OperationSummary, ProvenanceChainView, ProvenanceHopView, RenderDocument, RenderEntry, RenderEntryRef, RenderObjectEditContext, RenderObjectDetail, SemanticSourceView, SourceLocatorRangeView, SourceLocatorView, StyleSourceOperation, StyleSourceView, TextSegmentView, TextSourceView, WriteTargetView, } from "./protocol/render.js";
@@ -25,6 +25,13 @@ export declare class PreviewFileSystemSiteEditEngineRuntime implements PreviewSi
25
25
  canRemove: boolean;
26
26
  };
27
27
  pageCompositionUnitKey?: string | undefined;
28
+ dynamicDataSummary?: {
29
+ hasDynamicData: boolean;
30
+ sourceKinds: ("vcp-cms-collection" | "vcp-cms-form" | "vcp-cms-settings" | "vcp-cms-navigation" | "site-api-route" | "external-api" | "unknown-api")[];
31
+ primaryEndpoint?: string | undefined;
32
+ primaryCollection?: string | undefined;
33
+ primaryFieldPath?: string | undefined;
34
+ } | undefined;
28
35
  }[];
29
36
  pageComposition: {
30
37
  status: "supported";
@@ -131,6 +138,27 @@ export declare class PreviewFileSystemSiteEditEngineRuntime implements PreviewSi
131
138
  message: string;
132
139
  }[];
133
140
  } | undefined;
141
+ dynamicData?: {
142
+ hasDynamicData: boolean;
143
+ bindings: {
144
+ sourceKind: "vcp-cms-collection" | "vcp-cms-form" | "vcp-cms-settings" | "vcp-cms-navigation" | "site-api-route" | "external-api" | "unknown-api";
145
+ sourceType: "api-field" | "cms-field";
146
+ targetKind: "repeat-region" | "text" | "attribute" | "richtext" | "component-prop";
147
+ targetName: string;
148
+ confidence: "exact" | "safe-derived" | "partial" | "unknown";
149
+ readonly: true;
150
+ evidence: {
151
+ file: string;
152
+ reason: string;
153
+ symbol?: string | undefined;
154
+ }[];
155
+ endpointPattern?: string | undefined;
156
+ operation?: string | undefined;
157
+ collection?: string | undefined;
158
+ fieldPath?: string | undefined;
159
+ valuePath?: string | undefined;
160
+ }[];
161
+ } | undefined;
134
162
  };
135
163
  };
136
164
  getClassNameSource(key: string, routeId?: string): {
@@ -140,7 +168,7 @@ export declare class PreviewFileSystemSiteEditEngineRuntime implements PreviewSi
140
168
  routeId: string;
141
169
  filePath: string;
142
170
  componentName: string;
143
- sourceKind: "missing" | "expression" | "stringLiteral";
171
+ sourceKind: "expression" | "missing" | "stringLiteral";
144
172
  attrRaw: string | null;
145
173
  valueRaw: string | null;
146
174
  attrRange: {
@@ -218,8 +246,8 @@ export declare class PreviewFileSystemSiteEditEngineRuntime implements PreviewSi
218
246
  };
219
247
  };
220
248
  refreshSourceForKey(key: string, routeId?: string): Promise<void>;
221
- executeOperation(request: Parameters<PreviewSiteEditEngineRuntime["executeOperation"]>[0], mutationContext: SiteEditMutationContext): Promise<SiteEditOperationCommandResult>;
222
- undo(mutationContext: SiteEditMutationContext): Promise<{
249
+ executeOperation(request: Parameters<PreviewSiteEditEngineRuntime["executeOperation"]>[0], mutationContext?: SiteEditMutationContext): Promise<SiteEditOperationCommandResult>;
250
+ undo(_mutationContext?: SiteEditMutationContext): Promise<{
223
251
  ok: false;
224
252
  error: {
225
253
  code: "VERSION_STALE" | "RECOVERY_REQUIRED" | "NODE_NOT_FOUND" | "ROUTE_NOT_FOUND" | "CAPABILITY_REJECTED" | "CONSTRAINT_VIOLATED" | "INVALID_PARAMS" | "PLAN_FAILED" | "TRANSACTION_PREFLIGHT_FAILED" | "ROUTE_REBUILD_FAILED" | "HISTORY_COMMIT_FAILED" | "MATERIALIZATION_CONFLICT" | "MATERIALIZATION_REJECTED" | "MUTATION_ASSERTION_REQUIRED" | "MUTATION_ASSERTION_INVALID" | "AST_PARSE_ERROR" | "UNSUPPORTED_OPERATION" | "LOCATOR_FAILED" | "INVALID_TARGET" | "WRITE_IO_ERROR" | "CONCURRENT_MODIFIED" | "ROLLBACK_FAILED" | "RECOVERY_PERSIST_FAILED" | "MUTATION_SESSION_REQUIRED" | "LEASE_ASSERTION_INVALID" | "LEASE_ASSERTION_EXPIRED" | "LEASE_ASSERTION_SCOPE_MISMATCH" | "CROSS_PAGE_MOVE_UNSUPPORTED" | "INTERNAL_ERROR";
@@ -279,7 +307,7 @@ export declare class PreviewFileSystemSiteEditEngineRuntime implements PreviewSi
279
307
  };
280
308
  error?: undefined;
281
309
  }>;
282
- redo(mutationContext: SiteEditMutationContext): Promise<{
310
+ redo(_mutationContext?: SiteEditMutationContext): Promise<{
283
311
  ok: false;
284
312
  error: {
285
313
  code: "VERSION_STALE" | "RECOVERY_REQUIRED" | "NODE_NOT_FOUND" | "ROUTE_NOT_FOUND" | "CAPABILITY_REJECTED" | "CONSTRAINT_VIOLATED" | "INVALID_PARAMS" | "PLAN_FAILED" | "TRANSACTION_PREFLIGHT_FAILED" | "ROUTE_REBUILD_FAILED" | "HISTORY_COMMIT_FAILED" | "MATERIALIZATION_CONFLICT" | "MATERIALIZATION_REJECTED" | "MUTATION_ASSERTION_REQUIRED" | "MUTATION_ASSERTION_INVALID" | "AST_PARSE_ERROR" | "UNSUPPORTED_OPERATION" | "LOCATOR_FAILED" | "INVALID_TARGET" | "WRITE_IO_ERROR" | "CONCURRENT_MODIFIED" | "ROLLBACK_FAILED" | "RECOVERY_PERSIST_FAILED" | "MUTATION_SESSION_REQUIRED" | "LEASE_ASSERTION_INVALID" | "LEASE_ASSERTION_EXPIRED" | "LEASE_ASSERTION_SCOPE_MISMATCH" | "CROSS_PAGE_MOVE_UNSUPPORTED" | "INTERNAL_ERROR";
package/dist/runtime.d.ts CHANGED
@@ -21,6 +21,13 @@ export declare class SnapshotSiteEditEngineRuntime implements SiteEditEngineRunt
21
21
  canRemove: boolean;
22
22
  };
23
23
  pageCompositionUnitKey?: string | undefined;
24
+ dynamicDataSummary?: {
25
+ hasDynamicData: boolean;
26
+ sourceKinds: ("vcp-cms-collection" | "vcp-cms-form" | "vcp-cms-settings" | "vcp-cms-navigation" | "site-api-route" | "external-api" | "unknown-api")[];
27
+ primaryEndpoint?: string | undefined;
28
+ primaryCollection?: string | undefined;
29
+ primaryFieldPath?: string | undefined;
30
+ } | undefined;
24
31
  }[];
25
32
  pageComposition: {
26
33
  status: "supported";
@@ -120,13 +127,34 @@ export declare class SnapshotSiteEditEngineRuntime implements SiteEditEngineRunt
120
127
  message: string;
121
128
  }[];
122
129
  } | undefined;
130
+ dynamicData?: {
131
+ hasDynamicData: boolean;
132
+ bindings: {
133
+ sourceKind: "vcp-cms-collection" | "vcp-cms-form" | "vcp-cms-settings" | "vcp-cms-navigation" | "site-api-route" | "external-api" | "unknown-api";
134
+ sourceType: "api-field" | "cms-field";
135
+ targetKind: "repeat-region" | "text" | "attribute" | "richtext" | "component-prop";
136
+ targetName: string;
137
+ confidence: "exact" | "safe-derived" | "partial" | "unknown";
138
+ readonly: true;
139
+ evidence: {
140
+ file: string;
141
+ reason: string;
142
+ symbol?: string | undefined;
143
+ }[];
144
+ endpointPattern?: string | undefined;
145
+ operation?: string | undefined;
146
+ collection?: string | undefined;
147
+ fieldPath?: string | undefined;
148
+ valuePath?: string | undefined;
149
+ }[];
150
+ } | undefined;
123
151
  };
124
152
  getClassNameSource(key: string, routeId?: string): {
125
153
  key: string;
126
154
  routeId: string;
127
155
  filePath: string;
128
156
  componentName: string;
129
- sourceKind: "missing" | "expression" | "stringLiteral";
157
+ sourceKind: "expression" | "missing" | "stringLiteral";
130
158
  attrRaw: string | null;
131
159
  valueRaw: string | null;
132
160
  attrRange: {
package/dist/types.d.ts CHANGED
@@ -1,7 +1,6 @@
1
1
  import type { SiteEditCommandSuccess, SiteEditEvent, SiteEditGetClassNameSourceCommandResult, SiteEditGetClassNameSourceResult, SiteEditClassNameSourceStyleContext, SiteEditObjectEditContext, SiteEditOperationCommandResult, SiteEditMutationContext, SiteEditOperationRequest, SiteEditPatchPlan, SiteEditRenderDocument, SiteEditResolveSourceLocationInput, SiteEditSourceFileResponse, SiteEditSourceLocation, SiteEditSourceTreeResponse } from "@vcp-dev/contracts";
2
2
  import type { SiteEditProjectFileSystem } from "./public-file-system.js";
3
3
  import type { FileHistoryStore } from "./history/file-history-store.js";
4
- import type { SiteEditMutationContextVerifier } from "./mutation-context-verifier.js";
5
4
  export type { SiteEditProjectFileSystem } from "./public-file-system.js";
6
5
  export interface SiteEditSnapshotFile {
7
6
  path: string;
@@ -21,7 +20,6 @@ export interface SiteEditEngineRuntimeOptions {
21
20
  onEvent?: (event: SiteEditEvent) => void;
22
21
  dev?: boolean;
23
22
  historyStore?: FileHistoryStore;
24
- mutationContextVerifier?: SiteEditMutationContextVerifier;
25
23
  }
26
24
  export interface SiteEditPlanOperationResult {
27
25
  result: SiteEditOperationCommandResult;
@@ -59,7 +57,6 @@ export interface PreviewSiteEditEngineRuntimeOptions {
59
57
  dev?: boolean;
60
58
  fileSystem?: SiteEditProjectFileSystem;
61
59
  historyStore?: FileHistoryStore;
62
- mutationContextVerifier?: SiteEditMutationContextVerifier;
63
60
  /** Preserves monotonic document versions when a Bridge swaps runtimes. */
64
61
  initialDocumentVersion?: number;
65
62
  }
@@ -79,9 +76,9 @@ export interface PreviewSiteEditEngineRuntime {
79
76
  }): Promise<SiteEditCommandSuccess<SiteEditSourceFileResponse>>;
80
77
  resolveSourceLocation(input: SiteEditResolveSourceLocationInput): SiteEditCommandSuccess<SiteEditSourceLocation>;
81
78
  refreshSourceForKey(key: string, routeId?: string): Promise<void>;
82
- executeOperation(request: SiteEditOperationRequest, mutationContext: SiteEditMutationContext): Promise<SiteEditOperationCommandResult>;
83
- undo(mutationContext: SiteEditMutationContext): Promise<SiteEditOperationCommandResult>;
84
- redo(mutationContext: SiteEditMutationContext): Promise<SiteEditOperationCommandResult>;
79
+ executeOperation(request: SiteEditOperationRequest, mutationContext?: SiteEditMutationContext): Promise<SiteEditOperationCommandResult>;
80
+ undo(mutationContext?: SiteEditMutationContext): Promise<SiteEditOperationCommandResult>;
81
+ redo(mutationContext?: SiteEditMutationContext): Promise<SiteEditOperationCommandResult>;
85
82
  notifyFileChanged(file: string): void;
86
83
  subscribe(listener: (event: SiteEditEvent) => void): () => void;
87
84
  dispose(): void;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vcp-dev/site-edit-engine",
3
- "version": "0.6.0",
3
+ "version": "0.6.2",
4
4
  "type": "module",
5
5
  "license": "UNLICENSED",
6
6
  "repository": {
@@ -60,7 +60,7 @@
60
60
  "@babel/parser": "^7.29.3",
61
61
  "@babel/traverse": "^7.29.0",
62
62
  "@babel/types": "^7.29.0",
63
- "@vcp-dev/contracts": "0.6.0",
63
+ "@vcp-dev/contracts": "0.6.2",
64
64
  "yaml": "^2.9.0"
65
65
  },
66
66
  "devDependencies": {
@@ -1,30 +0,0 @@
1
- import { type KeyObject } from "node:crypto";
2
- import type { SiteEditMutationContext, SiteEditOperationErrorCode } from "@vcp-dev/contracts";
3
- export type SiteEditMutationVerificationFailureCode = Extract<SiteEditOperationErrorCode, "MUTATION_SESSION_REQUIRED" | "LEASE_ASSERTION_INVALID" | "LEASE_ASSERTION_EXPIRED" | "LEASE_ASSERTION_SCOPE_MISMATCH">;
4
- export type SiteEditMutationVerificationResult = {
5
- ok: true;
6
- } | {
7
- ok: false;
8
- code: SiteEditMutationVerificationFailureCode;
9
- message: string;
10
- };
11
- export interface SiteEditMutationAssertionExpected {
12
- tenantId: string;
13
- siteId: string;
14
- snapshotId: string;
15
- editingSessionId: string;
16
- lockId: string;
17
- ownerId: string;
18
- }
19
- export interface SiteEditMutationContextVerifier {
20
- verify(context: SiteEditMutationContext, expected: SiteEditMutationAssertionExpected): Promise<SiteEditMutationVerificationResult>;
21
- }
22
- export interface Ed25519MutationContextVerifierOptions {
23
- publicKey: string | KeyObject;
24
- issuer?: string;
25
- audience?: string;
26
- keyId: string;
27
- now?: () => number;
28
- clockSkewSeconds?: number;
29
- }
30
- export declare function createEd25519MutationContextVerifier(options: Ed25519MutationContextVerifierOptions): SiteEditMutationContextVerifier;