@vcp-dev/site-edit-engine 0.11.24 → 0.11.25

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 CHANGED
@@ -25,6 +25,8 @@ npm install @vcp-dev/contracts @vcp-dev/site-edit-engine
25
25
  - `scanSiteEditThemeStyleViolations` / `SITE_EDIT_RAW_COLOR_LITERAL_RE`
26
26
  - `parseSourceModule` / `resolveImportBase`:复用引擎的 TSX 解析与本地 import 路径规则,公开类型由独立 facade 定义,不暴露 `internal/*` 模块路径。
27
27
  - `provenRecordThumbnailRanges`:只读 AST 分析,返回可证明来自 `record.thumbnail` 数组的 JSX 表达式范围(`start:end`)。调用方仍须验证集合视图身份和完整记录媒体覆盖;范围集合不授予执行、写入或媒体下载权限。
28
+ - `generateCollectionAdapter` / `cmsFieldAccessor`:Workspace 与可移植源码分析共用的确定性集合 adapter 生成器和字段映射。生成器本身不证明 CMS schema、宿主或文件归属;托管源码的省略仍须校验可信 schema、实际调用和原始字节。
29
+ - `discoverPortableExistingCollectionRelation`:安装复用时检查现有列表容器与详情页的集合关联,即使列表页面已被定制也可保留已证明的详情页。结果不声称列表页面仍渲染该容器,也不授予选区源码、CMS 样例或 ZIP 完整性证明;所追踪记录的未知变异或逃逸仍会拒绝。
28
30
  - `openFileHistoryStore` / `FileHistoryStoreError`
29
31
  - 相关 runtime、style policy 与 file history public types
30
32
 
package/dist/index.d.ts CHANGED
@@ -1763,6 +1763,34 @@ export interface PortableDependencyAuditResult {
1763
1763
  readonly errors: readonly PortableDependencyAuditError[];
1764
1764
  }
1765
1765
  export declare function auditPortableDependencies(input: PortableDependencyAuditInput): PortableDependencyAuditResult;
1766
+ /** CMS 原生字段类型 → 生成站点 view 的 cms.field.* 归一 helper + view TS 类型。
1767
+ * Shared by the generator and its portable source verifier. */
1768
+ export type FieldHelper = "text" | "richtext" | "num" | "bool" | "selected" | "list" | "image" | "images" | "category" | "url" | "phone" | "dateRange";
1769
+ /** importName 指向 lib/cms/field 既有 view 类型(仅 image/images/category 用)。 */
1770
+ export interface FieldAccessor {
1771
+ helper: FieldHelper;
1772
+ tsType: string;
1773
+ importName?: "MediaItem" | "CategoryItem";
1774
+ }
1775
+ /**
1776
+ * cms 字段类型 + 字段名(+ CMS value_shape)→ 该字段在 toXView adapter 里用的 helper 与 view 类型。
1777
+ * D4:value_shape 命中词表时为形态权威(无视 cms_type);缺失/unknown/词表外才走本地 cms_type 映射,
1778
+ * 避免 CMS 新增 cms_type 时本地映射漂移回 text 兜底。唯一例外:media_list 再看 cms_type=Image
1779
+ * 判定图片组(形态都是数组,单/多图语义只有 cms_type 能给)。
1780
+ */
1781
+ export declare function cmsFieldAccessor(cmsType: string, fieldName: string, valueShape?: string): FieldAccessor;
1782
+ export interface CollectionAdapterOpts {
1783
+ /**
1784
+ * 强制按多图生成的字段名。cms_type=Image + value_shape=media_list 已由 cmsFieldAccessor
1785
+ * 判为图片组;本选项兜住 schema 缺 value_shape 等仍走字段名 heuristic 的情形
1786
+ * (搬家产品骨架的 thumbnail 名为单数但实际是图片组),否则只渲染第一张、其余静默丢弃。
1787
+ */
1788
+ readonly forceMultiMedia?: ReadonlySet<string>;
1789
+ /** Portable instance adapters depend only on the trusted public cms entry. */
1790
+ readonly inferFieldTypesFromCms?: boolean;
1791
+ }
1792
+ /** schema → lib/cms/generated/{slug}.ts:干净 XView 类型 + toXView adapter(取 rec.fields 经 cms.field.* 归一)。 */
1793
+ export declare function generateCollectionAdapter(slug: string, fields: ResolvedField[], opts?: CollectionAdapterOpts): string;
1766
1794
  type Location$1 = {
1767
1795
  readonly line: number;
1768
1796
  readonly column: number;
@@ -1788,13 +1816,132 @@ interface PortableCmsSourcesResult {
1788
1816
  readonly complete: boolean;
1789
1817
  readonly dependencies: readonly PortableCmsSourceDependency[];
1790
1818
  readonly unresolved: readonly PortableCmsSourceUnresolved[];
1819
+ /** Non-authoritative request namespaces, present only on incomplete analysis. */
1820
+ readonly candidates?: readonly string[];
1791
1821
  }
1822
+ export type PortableRelatedEntryPurpose = "collection-detail-view" | "i18n-companion" | "client-importer";
1823
+ export interface PortableRelatedEntry {
1824
+ readonly key: string;
1825
+ readonly pathTemplate: string;
1826
+ readonly export: {
1827
+ readonly kind: "default";
1828
+ } | {
1829
+ readonly kind: "named";
1830
+ readonly name: string;
1831
+ };
1832
+ readonly purpose: PortableRelatedEntryPurpose;
1833
+ readonly requirementKey: string;
1834
+ }
1835
+ export type PortableManagedRequirementKind = "route" | "adapter";
1836
+ export interface PortableManagedRequirement {
1837
+ readonly path: string;
1838
+ readonly kind: PortableManagedRequirementKind;
1839
+ readonly requirementKey: string;
1840
+ }
1841
+ export interface PortableCollectionSourceRelation {
1842
+ readonly slug: string;
1843
+ readonly requirement_key: string;
1844
+ readonly list_entry_file: string;
1845
+ readonly detail_entry_file: string;
1846
+ readonly detail_view_file: string;
1847
+ readonly detail_view_export: "default" | string;
1848
+ }
1849
+ export interface PortableCollectionSourceDiscoveryInput {
1850
+ readonly files: PortableSourceFileMap;
1851
+ readonly list_entry_file: string;
1852
+ readonly selected_component_source: string;
1853
+ /** Validated target prefix when proving already installed collection routes. */
1854
+ readonly detail_prefix?: string;
1855
+ }
1856
+ export interface PortableCollectionSourceDiscoveryResult {
1857
+ readonly complete: boolean;
1858
+ readonly relation: PortableCollectionSourceRelation | null;
1859
+ readonly errors: readonly PortableRelatedEntriesError[];
1860
+ }
1861
+ export interface PortableExistingCollectionRelationResult {
1862
+ readonly complete: boolean;
1863
+ /** A preservation fact only: it does not assert that a page renders the list. */
1864
+ readonly relation: Omit<PortableCollectionSourceRelation, "list_entry_file"> | null;
1865
+ readonly errors: readonly PortableRelatedEntriesError[];
1866
+ }
1867
+ export interface PortablePageTemplateRoot {
1868
+ readonly entry_file: string;
1869
+ readonly component_source?: string;
1870
+ readonly component_export?: string;
1871
+ }
1872
+ export interface PortableRelatedEntriesInput {
1873
+ readonly files: PortableSourceFileMap;
1874
+ readonly source_closure: PortableSourceClosure;
1875
+ readonly collection: PortableCollectionSourceRelation;
1876
+ /** False only when a rendered invocation proves an embedded collection. */
1877
+ readonly list_route_required?: boolean;
1878
+ readonly page_template?: PortablePageTemplateRoot;
1879
+ /** Trusted runtime host contract and signed Snapshot provenance, never browser input. */
1880
+ readonly host_capabilities?: unknown;
1881
+ readonly trusted_host_file_hashes?: ReadonlyMap<string, string>;
1882
+ /** Schema read from the trusted CMS application projection, never inferred from TS. */
1883
+ readonly trusted_schema?: PortableTrustedCollectionSchema;
1884
+ readonly required_fields?: readonly string[];
1885
+ readonly force_multi_media?: readonly string[];
1886
+ }
1887
+ export interface PortableTrustedCollectionSchema {
1888
+ readonly source_slug: string;
1889
+ readonly evidence_path: string;
1890
+ readonly fields: readonly ResolvedField[];
1891
+ }
1892
+ export type PortableRelatedEntriesErrorCode = "RELATED_SOURCE_CLOSURE_INCOMPLETE" | "RELATED_LIST_ENTRY_MISSING" | "RELATED_LIST_ROUTE_UNPROVEN" | "RELATED_DETAIL_ENTRY_MISSING" | "RELATED_DETAIL_ROUTE_UNPROVEN" | "RELATED_DETAIL_VIEW_MISSING" | "RELATED_DETAIL_VIEW_NOT_REACHED" | "RELATED_DETAIL_SOURCE_INCOMPLETE" | "RELATED_HOST_CAPABILITIES_INVALID" | "RELATED_HOST_IMPLEMENTATION_UNPROVEN" | "RELATED_MANAGED_SOURCE_UNPROVEN" | "RELATED_DETAIL_VIEW_NOT_PRIVATE" | "RELATED_COLLECTION_SCHEMA_UNPROVEN" | "RELATED_COLLECTION_LIST_CONTAINER_UNPROVEN" | "RELATED_COLLECTION_LIST_VIEW_UNPROVEN" | "RELATED_COLLECTION_DETAIL_CONSUMER_UNPROVEN" | "RELATED_COLLECTION_ADAPTER_UNPROVEN" | "RELATED_COLLECTION_FIELD_UNPROVEN" | "RELATED_COLLECTION_BREADCRUMB_UNPROVEN" | "RELATED_PAGE_TEMPLATE_PARSE_FAILED" | "RELATED_PAGE_TEMPLATE_NOT_SEPARABLE";
1893
+ export interface PortableRelatedEntriesError {
1894
+ readonly code: PortableRelatedEntriesErrorCode;
1895
+ readonly path: string;
1896
+ readonly message: string;
1897
+ }
1898
+ export interface PortableThinEntryPlan {
1899
+ readonly kind: "managed-root-thin-entry";
1900
+ readonly source_file: string;
1901
+ readonly component_source: string;
1902
+ readonly component_export: string;
1903
+ readonly adds_dom: false;
1904
+ }
1905
+ export interface PortableRelatedEntriesResult {
1906
+ readonly complete: boolean;
1907
+ readonly entries: readonly PortableRelatedEntry[];
1908
+ readonly managed_requirements: readonly PortableManagedRequirement[];
1909
+ readonly thin_entry_plan: PortableThinEntryPlan | null;
1910
+ readonly collection_wiring: PortableCollectionWiringFacts | null;
1911
+ readonly errors: readonly PortableRelatedEntriesError[];
1912
+ }
1913
+ export interface PortableCollectionWiringFacts {
1914
+ readonly source_slug: string;
1915
+ readonly detail_prefix: string;
1916
+ readonly schema: readonly ResolvedField[];
1917
+ readonly schema_evidence_path: string;
1918
+ readonly list_container_file: string;
1919
+ readonly list_view: PortableCollectionViewReference;
1920
+ readonly detail_view: PortableCollectionViewReference;
1921
+ readonly title?: string;
1922
+ readonly breadcrumb?: {
1923
+ readonly homeLabel: string;
1924
+ readonly collectionLabel: string;
1925
+ };
1926
+ readonly required_fields?: readonly string[];
1927
+ readonly force_multi_media?: readonly string[];
1928
+ }
1929
+ /** Discover collection identity only from the selected list call and matching route wiring. */
1930
+ export declare function discoverPortableCollectionSourceRelation(input: PortableCollectionSourceDiscoveryInput): PortableCollectionSourceDiscoveryResult;
1931
+ /** Installation can retain an existing detail route even after the list page
1932
+ * was customized. This is not evidence that the list belongs to a selection. */
1933
+ export declare function discoverPortableExistingCollectionRelation(input: {
1934
+ readonly files: PortableSourceFileMap;
1935
+ readonly list_container_file: string;
1936
+ readonly detail_prefix: string;
1937
+ }): PortableExistingCollectionRelationResult;
1938
+ export declare function analyzePortableRelatedEntries(input: PortableRelatedEntriesInput): PortableRelatedEntriesResult;
1792
1939
  interface PortableRouteReference {
1793
1940
  readonly kind: "host-route";
1794
1941
  readonly href: string;
1795
1942
  }
1796
- export type PortableMediaReferenceKind = "src" | "srcset" | "poster" | "thumbnail" | "object" | "array-item" | "import" | "manifest";
1797
- export type PortableMediaReferenceSource = "jsx-attribute" | "object-property" | "array-item" | "import" | "media-manifest";
1943
+ export type PortableMediaReferenceKind = "src" | "srcset" | "poster" | "thumbnail" | "object" | "array-item" | "import" | "manifest" | "host-fallback";
1944
+ export type PortableMediaReferenceSource = "jsx-attribute" | "object-property" | "array-item" | "import" | "media-manifest" | "host-fallback";
1798
1945
  export interface PortableMediaSourceRange {
1799
1946
  readonly start_offset: number;
1800
1947
  readonly end_offset: number;
@@ -1815,6 +1962,16 @@ export interface PortableMediaReference {
1815
1962
  /** Digest of the original AST/source occurrence, not downloaded bytes. */
1816
1963
  readonly content_digest: string;
1817
1964
  readonly complete: boolean;
1965
+ readonly host_fallback?: {
1966
+ readonly file_path: string;
1967
+ readonly digest_sha256: string;
1968
+ };
1969
+ readonly cms_field?: {
1970
+ readonly sources: readonly {
1971
+ readonly slug: string;
1972
+ readonly field_path: string;
1973
+ }[];
1974
+ };
1818
1975
  }
1819
1976
  export type PortableMediaReferenceScanErrorCode = "MEDIA_SOURCE_PARSE_FAILED" | "MEDIA_VALUE_UNKNOWN" | "MEDIA_MANIFEST_KEY_UNKNOWN";
1820
1977
  export interface PortableMediaReferenceScanError {
@@ -1849,6 +2006,8 @@ export interface PortableBlockExportInput {
1849
2006
  readonly host_capabilities: GeneratedSiteCapabilities;
1850
2007
  /** Supplied by trusted host provenance, never by a browser or Snapshot file. */
1851
2008
  readonly trusted_host_file_hashes?: ReadonlyMap<string, string>;
2009
+ /** CMS attestations verified by the trusted boundary, never raw browser data. */
2010
+ readonly trusted_cms_schemas?: readonly PortableTrustedCollectionSchema[];
1852
2011
  /** Must be obtained from an authoritative, site-scoped Snapshot reader. */
1853
2012
  readonly snapshot: {
1854
2013
  readonly site_id: string;
@@ -1891,16 +2050,30 @@ export type PortableBlockExportResult = {
1891
2050
  readonly source_closure: PortableSourceClosure;
1892
2051
  readonly dependency_audit: PortableDependencyAuditResult;
1893
2052
  readonly cms: PortableCmsSourcesResult;
2053
+ /** Related private sources only; not a route, media or ZIP completeness proof. */
2054
+ readonly collection_analysis?: {
2055
+ readonly kind: "related-source-only";
2056
+ readonly collections: readonly {
2057
+ readonly requirement_key: string;
2058
+ readonly collection_recipe: PortableCollectionRecipeFacts;
2059
+ readonly related_entries: readonly PortableRelatedEntry[];
2060
+ }[];
2061
+ };
1894
2062
  readonly media: readonly PortableMediaReference[];
1895
2063
  readonly invocation_bindings: readonly PortableInvocationBinding[];
1896
2064
  readonly host_contract_digest: string;
1897
2065
  readonly route_dependencies?: readonly PortableRouteReference[];
1898
2066
  readonly cms_sample_proof?: {
1899
- readonly kind: "first-page-no-host-routes";
2067
+ readonly kind: "first-page-no-host-routes" | "application-first-page-example";
1900
2068
  };
1901
2069
  } | {
1902
2070
  readonly complete: false;
1903
2071
  readonly unresolved: readonly PortableBlockExportError[];
2072
+ /** Hints for schema lookup only, not a complete selected CMS source set. */
2073
+ readonly cms_candidates?: {
2074
+ readonly kind: "partial-unproven";
2075
+ readonly slugs: readonly string[];
2076
+ };
1904
2077
  };
1905
2078
  type PortableBlockLocalAssetChunk = {
1906
2079
  readonly complete: true;
@@ -1908,7 +2081,7 @@ type PortableBlockLocalAssetChunk = {
1908
2081
  readonly file_path: string;
1909
2082
  readonly occurrence: number;
1910
2083
  readonly path: string;
1911
- readonly mime_type: "image/png" | "image/jpeg" | "image/gif" | "image/webp";
2084
+ readonly mime_type: "image/png" | "image/jpeg" | "image/gif" | "image/webp" | "image/svg+xml";
1912
2085
  readonly byte_size: number;
1913
2086
  readonly digest_sha256: string;
1914
2087
  readonly offset: number;
@@ -1943,110 +2116,6 @@ export declare function readPortableBlockLocalAssetChunk(input: {
1943
2116
  * read authority and deliberately returns no partial source on failure.
1944
2117
  */
1945
2118
  export declare function exportPortableBlockFromSnapshot(input: PortableBlockExportInput): Promise<PortableBlockExportResult>;
1946
- export type PortableRelatedEntryPurpose = "collection-detail-view" | "i18n-companion" | "client-importer";
1947
- export interface PortableRelatedEntry {
1948
- readonly key: string;
1949
- readonly pathTemplate: string;
1950
- readonly export: {
1951
- readonly kind: "default";
1952
- } | {
1953
- readonly kind: "named";
1954
- readonly name: string;
1955
- };
1956
- readonly purpose: PortableRelatedEntryPurpose;
1957
- readonly requirementKey: string;
1958
- }
1959
- export type PortableManagedRequirementKind = "route" | "adapter";
1960
- export interface PortableManagedRequirement {
1961
- readonly path: string;
1962
- readonly kind: PortableManagedRequirementKind;
1963
- readonly requirementKey: string;
1964
- }
1965
- export interface PortableCollectionSourceRelation {
1966
- readonly slug: string;
1967
- readonly requirement_key: string;
1968
- readonly list_entry_file: string;
1969
- readonly detail_entry_file: string;
1970
- readonly detail_view_file: string;
1971
- readonly detail_view_export: "default" | string;
1972
- }
1973
- export interface PortableCollectionSourceDiscoveryInput {
1974
- readonly files: PortableSourceFileMap;
1975
- readonly list_entry_file: string;
1976
- readonly selected_component_source: string;
1977
- /** Validated target prefix when proving already installed collection routes. */
1978
- readonly detail_prefix?: string;
1979
- }
1980
- export interface PortableCollectionSourceDiscoveryResult {
1981
- readonly complete: boolean;
1982
- readonly relation: PortableCollectionSourceRelation | null;
1983
- readonly errors: readonly PortableRelatedEntriesError[];
1984
- }
1985
- export interface PortablePageTemplateRoot {
1986
- readonly entry_file: string;
1987
- readonly component_source?: string;
1988
- readonly component_export?: string;
1989
- }
1990
- export interface PortableRelatedEntriesInput {
1991
- readonly files: PortableSourceFileMap;
1992
- readonly source_closure: PortableSourceClosure;
1993
- readonly collection: PortableCollectionSourceRelation;
1994
- /** False only when a rendered invocation proves an embedded collection. */
1995
- readonly list_route_required?: boolean;
1996
- readonly page_template?: PortablePageTemplateRoot;
1997
- /** Trusted runtime host contract and signed Snapshot provenance, never browser input. */
1998
- readonly host_capabilities?: unknown;
1999
- readonly trusted_host_file_hashes?: ReadonlyMap<string, string>;
2000
- /** Schema read from the trusted CMS application projection, never inferred from TS. */
2001
- readonly trusted_schema?: PortableTrustedCollectionSchema;
2002
- readonly required_fields?: readonly string[];
2003
- readonly force_multi_media?: readonly string[];
2004
- }
2005
- export interface PortableTrustedCollectionSchema {
2006
- readonly source_slug: string;
2007
- readonly evidence_path: string;
2008
- readonly fields: readonly ResolvedField[];
2009
- }
2010
- export type PortableRelatedEntriesErrorCode = "RELATED_SOURCE_CLOSURE_INCOMPLETE" | "RELATED_LIST_ENTRY_MISSING" | "RELATED_LIST_ROUTE_UNPROVEN" | "RELATED_DETAIL_ENTRY_MISSING" | "RELATED_DETAIL_ROUTE_UNPROVEN" | "RELATED_DETAIL_VIEW_MISSING" | "RELATED_DETAIL_VIEW_NOT_REACHED" | "RELATED_DETAIL_SOURCE_INCOMPLETE" | "RELATED_HOST_CAPABILITIES_INVALID" | "RELATED_HOST_IMPLEMENTATION_UNPROVEN" | "RELATED_MANAGED_SOURCE_UNPROVEN" | "RELATED_DETAIL_VIEW_NOT_PRIVATE" | "RELATED_COLLECTION_SCHEMA_UNPROVEN" | "RELATED_COLLECTION_LIST_CONTAINER_UNPROVEN" | "RELATED_COLLECTION_LIST_VIEW_UNPROVEN" | "RELATED_COLLECTION_DETAIL_CONSUMER_UNPROVEN" | "RELATED_COLLECTION_ADAPTER_UNPROVEN" | "RELATED_COLLECTION_FIELD_UNPROVEN" | "RELATED_COLLECTION_BREADCRUMB_UNPROVEN" | "RELATED_PAGE_TEMPLATE_PARSE_FAILED" | "RELATED_PAGE_TEMPLATE_NOT_SEPARABLE";
2011
- export interface PortableRelatedEntriesError {
2012
- readonly code: PortableRelatedEntriesErrorCode;
2013
- readonly path: string;
2014
- readonly message: string;
2015
- }
2016
- export interface PortableThinEntryPlan {
2017
- readonly kind: "managed-root-thin-entry";
2018
- readonly source_file: string;
2019
- readonly component_source: string;
2020
- readonly component_export: string;
2021
- readonly adds_dom: false;
2022
- }
2023
- export interface PortableRelatedEntriesResult {
2024
- readonly complete: boolean;
2025
- readonly entries: readonly PortableRelatedEntry[];
2026
- readonly managed_requirements: readonly PortableManagedRequirement[];
2027
- readonly thin_entry_plan: PortableThinEntryPlan | null;
2028
- readonly collection_wiring: PortableCollectionWiringFacts | null;
2029
- readonly errors: readonly PortableRelatedEntriesError[];
2030
- }
2031
- export interface PortableCollectionWiringFacts {
2032
- readonly source_slug: string;
2033
- readonly detail_prefix: string;
2034
- readonly schema: readonly ResolvedField[];
2035
- readonly schema_evidence_path: string;
2036
- readonly list_container_file: string;
2037
- readonly list_view: PortableCollectionViewReference;
2038
- readonly detail_view: PortableCollectionViewReference;
2039
- readonly title?: string;
2040
- readonly breadcrumb?: {
2041
- readonly homeLabel: string;
2042
- readonly collectionLabel: string;
2043
- };
2044
- readonly required_fields?: readonly string[];
2045
- readonly force_multi_media?: readonly string[];
2046
- }
2047
- /** Discover collection identity only from the selected list call and matching route wiring. */
2048
- export declare function discoverPortableCollectionSourceRelation(input: PortableCollectionSourceDiscoveryInput): PortableCollectionSourceDiscoveryResult;
2049
- export declare function analyzePortableRelatedEntries(input: PortableRelatedEntriesInput): PortableRelatedEntriesResult;
2050
2119
  export interface PortableInvocationAnalyzerInput {
2051
2120
  readonly file_path: string;
2052
2121
  readonly source: string;
@@ -2480,6 +2549,7 @@ export interface PortableInvocationPlan {
2480
2549
  readonly targetBlockId: string;
2481
2550
  readonly targetOrder: number | null;
2482
2551
  readonly requiresRouteSearchParams: boolean;
2552
+ readonly requiresRouteParams: boolean;
2483
2553
  readonly searchParamsIdentifier: string | null;
2484
2554
  }
2485
2555
  export type PortableInvocationErrorCode = "INVOCATION_INPUT_INVALID" | "INVOCATION_COMPONENT_INVALID" | "INVOCATION_TARGET_BLOCK_INVALID" | "INVOCATION_TARGET_ORDER_INVALID" | "INVOCATION_DUPLICATE_PROP" | "INVOCATION_VALUE_UNRESOLVED" | "INVOCATION_SOURCE_METADATA";