@vcp-dev/contracts 0.4.0 → 0.4.1

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.
@@ -0,0 +1,170 @@
1
+ import { z } from "zod";
2
+ export declare const SITE_EDIT_SOURCE_ALLOWED_ROOT_FILES: readonly ["design.md", "DESIGN.md"];
3
+ export declare const SITE_EDIT_SOURCE_ALLOWED_DIRS: readonly ["components/site", "src/components/site", "lib/generated", "src/lib/generated", "public"];
4
+ export declare const SITE_EDIT_SOURCE_ALLOWED_APP_FILES: readonly ["app/globals.css", "src/app/globals.css"];
5
+ export declare const SITE_EDIT_TEXT_SOURCE_EXTENSIONS: readonly [".cjs", ".css", ".cts", ".html", ".js", ".json", ".jsx", ".md", ".mdx", ".mjs", ".mts", ".ts", ".tsx", ".txt", ".yaml", ".yml"];
6
+ export declare const SITE_EDIT_SOURCE_DELETE_CAPABILITY: "source-delete";
7
+ export declare const SiteEditSourceDeleteCapabilitySchema: z.ZodLiteral<"source-delete">;
8
+ export type SiteEditSourceDeleteCapability = z.infer<typeof SiteEditSourceDeleteCapabilitySchema>;
9
+ export type SiteEditSourceDeleteProtectionReason = "design-document" | "route-entry" | "app-global-style" | "generated-media-manifest";
10
+ export declare const SiteEditSourcePathSchema: z.ZodString;
11
+ export type SiteEditSourcePath = z.infer<typeof SiteEditSourcePathSchema>;
12
+ export declare const SiteEditSourceDirectoryPathSchema: z.ZodString;
13
+ export type SiteEditSourceDirectoryPath = z.infer<typeof SiteEditSourceDirectoryPathSchema>;
14
+ export declare const SiteEditSourceFileKindSchema: z.ZodEnum<{
15
+ text: "text";
16
+ binary: "binary";
17
+ }>;
18
+ export type SiteEditSourceFileKind = z.infer<typeof SiteEditSourceFileKindSchema>;
19
+ export declare const SiteEditSourceFileListItemSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
20
+ path: z.ZodString;
21
+ sizeBytes: z.ZodNumber;
22
+ contentHash: z.ZodOptional<z.ZodString>;
23
+ kind: z.ZodLiteral<"text">;
24
+ language: z.ZodString;
25
+ readonly: z.ZodDefault<z.ZodBoolean>;
26
+ }, z.core.$strip>, z.ZodObject<{
27
+ path: z.ZodString;
28
+ sizeBytes: z.ZodNumber;
29
+ contentHash: z.ZodOptional<z.ZodString>;
30
+ kind: z.ZodLiteral<"binary">;
31
+ language: z.ZodNull;
32
+ mimeType: z.ZodOptional<z.ZodString>;
33
+ readonly: z.ZodLiteral<true>;
34
+ }, z.core.$strip>], "kind">;
35
+ export type SiteEditSourceFileListItem = z.infer<typeof SiteEditSourceFileListItemSchema>;
36
+ export type SiteEditSourceFileTreeNode = {
37
+ kind: "file";
38
+ name: string;
39
+ path: SiteEditSourcePath;
40
+ file: SiteEditSourceFileListItem;
41
+ };
42
+ export type SiteEditSourceDirectoryTreeNode = {
43
+ kind: "directory";
44
+ name: string;
45
+ path: SiteEditSourceDirectoryPath;
46
+ children: SiteEditSourceTreeNode[];
47
+ };
48
+ export type SiteEditSourceTreeNode = SiteEditSourceFileTreeNode | SiteEditSourceDirectoryTreeNode;
49
+ export declare const SiteEditSourceTreeNodeSchema: z.ZodType<SiteEditSourceTreeNode>;
50
+ export declare const SiteEditSourceTreeTruncationReasonSchema: z.ZodEnum<{
51
+ "max-files": "max-files";
52
+ "max-depth": "max-depth";
53
+ "max-total-bytes": "max-total-bytes";
54
+ }>;
55
+ export type SiteEditSourceTreeTruncationReason = z.infer<typeof SiteEditSourceTreeTruncationReasonSchema>;
56
+ export declare const SiteEditSourceTreeTruncationSchema: z.ZodObject<{
57
+ reasons: z.ZodArray<z.ZodEnum<{
58
+ "max-files": "max-files";
59
+ "max-depth": "max-depth";
60
+ "max-total-bytes": "max-total-bytes";
61
+ }>>;
62
+ maxFiles: z.ZodNumber;
63
+ maxDepth: z.ZodNumber;
64
+ maxTotalBytes: z.ZodNumber;
65
+ }, z.core.$strip>;
66
+ export type SiteEditSourceTreeTruncation = z.infer<typeof SiteEditSourceTreeTruncationSchema>;
67
+ export declare const SiteEditSourceTreeResponseSchema: z.ZodObject<{
68
+ nodes: z.ZodArray<z.ZodType<SiteEditSourceTreeNode, unknown, z.core.$ZodTypeInternals<SiteEditSourceTreeNode, unknown>>>;
69
+ defaultPath: z.ZodOptional<z.ZodString>;
70
+ totalFiles: z.ZodNumber;
71
+ truncated: z.ZodOptional<z.ZodObject<{
72
+ reasons: z.ZodArray<z.ZodEnum<{
73
+ "max-files": "max-files";
74
+ "max-depth": "max-depth";
75
+ "max-total-bytes": "max-total-bytes";
76
+ }>>;
77
+ maxFiles: z.ZodNumber;
78
+ maxDepth: z.ZodNumber;
79
+ maxTotalBytes: z.ZodNumber;
80
+ }, z.core.$strip>>;
81
+ }, z.core.$strip>;
82
+ export type SiteEditSourceTreeResponse = z.infer<typeof SiteEditSourceTreeResponseSchema>;
83
+ export declare const SiteEditSourceFileTextResponseSchema: z.ZodObject<{
84
+ path: z.ZodString;
85
+ sizeBytes: z.ZodNumber;
86
+ contentHash: z.ZodOptional<z.ZodString>;
87
+ kind: z.ZodLiteral<"text">;
88
+ language: z.ZodString;
89
+ readonly: z.ZodDefault<z.ZodBoolean>;
90
+ content: z.ZodString;
91
+ }, z.core.$strip>;
92
+ export type SiteEditSourceFileTextResponse = z.infer<typeof SiteEditSourceFileTextResponseSchema>;
93
+ export declare const SiteEditSourceFileBinaryPreviewUnavailableReasonSchema: z.ZodEnum<{
94
+ "too-large": "too-large";
95
+ "unsupported-mime": "unsupported-mime";
96
+ "bytes-unavailable": "bytes-unavailable";
97
+ }>;
98
+ export type SiteEditSourceFileBinaryPreviewUnavailableReason = z.infer<typeof SiteEditSourceFileBinaryPreviewUnavailableReasonSchema>;
99
+ export declare const SiteEditSourceFileBinaryResponseSchema: z.ZodObject<{
100
+ path: z.ZodString;
101
+ sizeBytes: z.ZodNumber;
102
+ contentHash: z.ZodOptional<z.ZodString>;
103
+ kind: z.ZodLiteral<"binary">;
104
+ language: z.ZodNull;
105
+ readonly: z.ZodLiteral<true>;
106
+ mimeType: z.ZodString;
107
+ contentBase64: z.ZodOptional<z.ZodString>;
108
+ previewUnavailableReason: z.ZodOptional<z.ZodEnum<{
109
+ "too-large": "too-large";
110
+ "unsupported-mime": "unsupported-mime";
111
+ "bytes-unavailable": "bytes-unavailable";
112
+ }>>;
113
+ }, z.core.$strip>;
114
+ export type SiteEditSourceFileBinaryResponse = z.infer<typeof SiteEditSourceFileBinaryResponseSchema>;
115
+ export declare const SiteEditSourceFileResponseSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
116
+ path: z.ZodString;
117
+ sizeBytes: z.ZodNumber;
118
+ contentHash: z.ZodOptional<z.ZodString>;
119
+ kind: z.ZodLiteral<"text">;
120
+ language: z.ZodString;
121
+ readonly: z.ZodDefault<z.ZodBoolean>;
122
+ content: z.ZodString;
123
+ }, z.core.$strip>, z.ZodObject<{
124
+ path: z.ZodString;
125
+ sizeBytes: z.ZodNumber;
126
+ contentHash: z.ZodOptional<z.ZodString>;
127
+ kind: z.ZodLiteral<"binary">;
128
+ language: z.ZodNull;
129
+ readonly: z.ZodLiteral<true>;
130
+ mimeType: z.ZodString;
131
+ contentBase64: z.ZodOptional<z.ZodString>;
132
+ previewUnavailableReason: z.ZodOptional<z.ZodEnum<{
133
+ "too-large": "too-large";
134
+ "unsupported-mime": "unsupported-mime";
135
+ "bytes-unavailable": "bytes-unavailable";
136
+ }>>;
137
+ }, z.core.$strip>], "kind">;
138
+ export type SiteEditSourceFileResponse = z.infer<typeof SiteEditSourceFileResponseSchema>;
139
+ export declare const SiteEditResolveSourceLocationInputSchema: z.ZodObject<{
140
+ key: z.ZodString;
141
+ routeId: z.ZodOptional<z.ZodString>;
142
+ }, z.core.$strip>;
143
+ export type SiteEditResolveSourceLocationInput = z.infer<typeof SiteEditResolveSourceLocationInputSchema>;
144
+ export declare const SiteEditSourceLocationRangeSchema: z.ZodObject<{
145
+ startLine: z.ZodNumber;
146
+ startColumn: z.ZodNumber;
147
+ endLine: z.ZodNumber;
148
+ endColumn: z.ZodNumber;
149
+ }, z.core.$strip>;
150
+ export type SiteEditSourceLocationRange = z.infer<typeof SiteEditSourceLocationRangeSchema>;
151
+ export declare const SiteEditSourceLocationSchema: z.ZodObject<{
152
+ key: z.ZodString;
153
+ routeId: z.ZodOptional<z.ZodString>;
154
+ sourceFile: z.ZodString;
155
+ componentName: z.ZodString;
156
+ openingElementRange: z.ZodObject<{
157
+ startLine: z.ZodNumber;
158
+ startColumn: z.ZodNumber;
159
+ endLine: z.ZodNumber;
160
+ endColumn: z.ZodNumber;
161
+ }, z.core.$strip>;
162
+ structuralPath: z.ZodString;
163
+ textPreview: z.ZodOptional<z.ZodString>;
164
+ }, z.core.$strip>;
165
+ export type SiteEditSourceLocation = z.infer<typeof SiteEditSourceLocationSchema>;
166
+ export declare function isSiteEditSourcePath(path: string): boolean;
167
+ export declare function isSiteEditTextSourcePath(path: string): boolean;
168
+ export declare function isSiteEditSourceDirectoryPath(path: string): boolean;
169
+ export declare function getSiteEditSourceDeleteProtectionReason(path: string): SiteEditSourceDeleteProtectionReason | null;
170
+ export declare function isSiteEditSourceDeleteProtectedPath(path: string): boolean;
@@ -5,7 +5,7 @@
5
5
  *
6
6
  * 由 release-edit-engine-packages.ts 在 bump 版本时自动更新。
7
7
  */
8
- export declare const CURRENT_EDIT_ENGINE_VERSION = "0.4.0";
8
+ export declare const CURRENT_EDIT_ENGINE_VERSION = "0.4.1";
9
9
  export declare const EDIT_ENGINE_VERSION_HEADER = "x-vcp-edit-engine-version";
10
10
  export declare const EDIT_ENGINE_VERSION_SOURCE_HEADER = "x-vcp-edit-engine-version-source";
11
11
  export type EditEngineVersionSource = "explicit" | "fallback_current" | "system_current";
@@ -1,10 +1,7 @@
1
1
  import { z } from "zod";
2
- /**
3
- * 白名单 BCP-47 code(与 {@link SUPPORTED_SITE_LOCALES} 同序同值)。
4
- * 显式 literal tuple 以便 `z.enum` 推导出精确联合类型。
5
- */
6
- export declare const SITE_LOCALE_CODES: readonly ["zh-CN", "en", "ja", "es", "fr", "de", "zh-TW", "ko", "pt", "pt-BR", "it", "ru", "ar", "hi", "id", "vi", "th", "tr", "nl", "pl", "uk", "sv", "da", "fi", "no", "cs", "el", "hu", "ro", "he", "ms", "fil", "bn", "ta", "ca", "sk", "hr", "bg", "lt", "lv", "et", "fa", "sw", "sr", "is"];
2
+ export { DEFAULT_SITE_LOCALE, ISO_639_3_TO_SITE_LOCALE, SITE_LOCALE_CODES, SUPPORTED_SITE_LOCALES, resolveSiteLocaleFromIso6393, type SiteLocale, type SiteLocaleOption, } from "@vcp-dev/i18n/site-locale";
7
3
  export declare const SiteLocaleSchema: z.ZodEnum<{
4
+ id: "id";
8
5
  "zh-CN": "zh-CN";
9
6
  en: "en";
10
7
  ja: "ja";
@@ -19,7 +16,6 @@ export declare const SiteLocaleSchema: z.ZodEnum<{
19
16
  ru: "ru";
20
17
  ar: "ar";
21
18
  hi: "hi";
22
- id: "id";
23
19
  vi: "vi";
24
20
  th: "th";
25
21
  tr: "tr";
@@ -51,44 +47,3 @@ export declare const SiteLocaleSchema: z.ZodEnum<{
51
47
  sr: "sr";
52
48
  is: "is";
53
49
  }>;
54
- export type SiteLocale = z.infer<typeof SiteLocaleSchema>;
55
- /**
56
- * 站点产出语种(访客看到的语言)的事实源白名单。
57
- *
58
- * - `code`:BCP-47 标签,持久化进 `SiteRecord.default_locale`,并直接用于
59
- * 生成站点产物的 `<html lang>`。
60
- * - `label`:语种自称(endonym,如 `日本語` / `Español`),**不随界面语言变**,
61
- * 控件主显示。
62
- * - `common`:是否常用,控件浮层默认置顶展示。
63
- *
64
- * 语种在当前界面语言下的释义(exonym,如「日语」/「Japanese」)**不放这里**——
65
- * 它随界面语言变化,由前端 i18n(`clarify` 命名空间 `siteLanguage.names.<code>`)
66
- * 提供,避免界面切到英文时右侧仍显示中文。
67
- *
68
- * `default_locale` 为 NOT NULL:Step 1 创建站点时由后端轻量语言检测写入
69
- * (识别不出兜底 {@link DEFAULT_SITE_LOCALE}),用户可在 Step 2 覆盖。
70
- */
71
- export interface SiteLocaleOption {
72
- code: SiteLocale;
73
- label: string;
74
- common?: boolean;
75
- }
76
- /**
77
- * 控件展示用元数据(前 6 项为常用,控件默认置顶)。code 必须落在白名单内。
78
- * `label` 是语种自称(endonym),不随界面语言变;释义(exonym)走前端 i18n。
79
- */
80
- export declare const SUPPORTED_SITE_LOCALES: readonly SiteLocaleOption[];
81
- /**
82
- * 识别不确定 / 失败时的兜底语种。`default_locale` 不可为空,故必须有终极兜底。
83
- */
84
- export declare const DEFAULT_SITE_LOCALE: SiteLocale;
85
- /**
86
- * 轻量语言检测库(franc 系)输出的 ISO 639-3 → 白名单 BCP-47。
87
- * 映射未命中时由调用方兜底为 {@link DEFAULT_SITE_LOCALE}。
88
- * 注:franc 不区分简繁,`cmn` 统一归 `zh-CN`,繁体靠用户在 Step 2 手选。
89
- */
90
- export declare const ISO_639_3_TO_SITE_LOCALE: Readonly<Record<string, SiteLocale>>;
91
- /**
92
- * 把检测库输出的 ISO 639-3 归一到白名单 BCP-47;未命中返回 {@link DEFAULT_SITE_LOCALE}。
93
- */
94
- export declare function resolveSiteLocaleFromIso6393(iso6393: string): SiteLocale;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vcp-dev/contracts",
3
- "version": "0.4.0",
3
+ "version": "0.4.1",
4
4
  "type": "module",
5
5
  "license": "UNLICENSED",
6
6
  "repository": {
@@ -51,6 +51,7 @@
51
51
  "typecheck": "tsc -p tsconfig.json --noEmit"
52
52
  },
53
53
  "dependencies": {
54
+ "@vcp-dev/i18n": "0.0.0",
54
55
  "culori": "^4.0.2",
55
56
  "zod": "^4.0.0"
56
57
  },