@djvlc/contracts-types 1.6.0 → 1.7.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/dist/index.d.mts CHANGED
@@ -40,6 +40,39 @@ type JsonObject = Record<string, JsonValue>;
40
40
  * 上下文类型定义
41
41
  */
42
42
 
43
+ /**
44
+ * 操作者信息
45
+ *
46
+ * @description
47
+ * 用于审计日志、操作记录等场景,标识执行操作的用户。
48
+ * 适用于管理后台操作、API 调用等需要追踪操作者的场景。
49
+ */
50
+ interface OperatorInfo {
51
+ /** 用户唯一标识 */
52
+ uid: string;
53
+ /** 用户名(显示名称) */
54
+ username: string;
55
+ /** 用户角色列表 */
56
+ roles?: string[];
57
+ /** 操作来源 IP */
58
+ ip?: string;
59
+ /** User Agent */
60
+ userAgent?: string;
61
+ }
62
+ /**
63
+ * 部署环境类型
64
+ *
65
+ * @description
66
+ * 用于区分不同的部署环境,影响配置、日志级别、功能开关等。
67
+ */
68
+ type Environment = 'development' | 'staging' | 'production';
69
+ /**
70
+ * 发布环境类型(页面发布使用)
71
+ *
72
+ * @description
73
+ * 页面可以发布到不同的环境,支持预览、灰度、正式等场景。
74
+ */
75
+ type PublishEnvironment = 'preview' | 'staging' | 'prod';
43
76
  /**
44
77
  * 应用上下文
45
78
  */
@@ -178,6 +211,36 @@ declare enum ErrorCode {
178
211
  * 错误码到 HTTP 状态码映射
179
212
  */
180
213
  declare const ErrorCodeToHttpStatus: Record<ErrorCode, number>;
214
+ /**
215
+ * 错误码到消息映射
216
+ */
217
+ declare const ErrorMessages: Record<ErrorCode, string>;
218
+ /**
219
+ * DJVLC 错误接口
220
+ */
221
+ interface DjvlcError extends Error {
222
+ /** 错误码 */
223
+ code: ErrorCode | string;
224
+ /** HTTP 状态码 */
225
+ httpStatus: number;
226
+ /** 错误详情 */
227
+ details?: Record<string, unknown>;
228
+ /** 追踪 ID */
229
+ traceId?: string;
230
+ }
231
+ /**
232
+ * 创建 DJVLC 错误
233
+ *
234
+ * @param code 错误码
235
+ * @param message 错误消息(可选,默认使用 ErrorMessages 中的消息)
236
+ * @param details 错误详情
237
+ * @returns DjvlcError 错误对象
238
+ */
239
+ declare function createDjvlcError(code: ErrorCode, message?: string, details?: Record<string, unknown>): DjvlcError;
240
+ /**
241
+ * 判断是否为 DJVLC 错误
242
+ */
243
+ declare function isDjvlcError(error: unknown): error is DjvlcError;
181
244
 
182
245
  /**
183
246
  * API 响应格式
@@ -286,6 +349,36 @@ declare enum VersionStatus {
286
349
  /** 已阻断(禁止使用) */
287
350
  BLOCKED = "blocked"
288
351
  }
352
+ /**
353
+ * 版本状态类型(字符串字面量版本,用于 JSON/数据库存储)
354
+ */
355
+ type VersionStatusType = 'draft' | 'stable' | 'deprecated' | 'blocked';
356
+ /**
357
+ * 页面状态枚举
358
+ */
359
+ declare enum PageStatus {
360
+ /** 草稿状态 */
361
+ DRAFT = "draft",
362
+ /** 已发布 */
363
+ PUBLISHED = "published",
364
+ /** 已归档 */
365
+ ARCHIVED = "archived"
366
+ }
367
+ /**
368
+ * 页面状态类型(字符串字面量版本)
369
+ */
370
+ type PageStatusType = 'draft' | 'published' | 'archived';
371
+ /**
372
+ * 组件状态类型
373
+ *
374
+ * @description
375
+ * 用于组件版本的生命周期管理。
376
+ * - draft: 开发中,仅内部可见
377
+ * - stable: 稳定版,推荐使用
378
+ * - deprecated: 已废弃,不推荐使用,但仍可用
379
+ * - blocked: 已阻断,禁止使用(安全原因)
380
+ */
381
+ type ComponentStatus = 'draft' | 'stable' | 'deprecated' | 'blocked';
289
382
  /**
290
383
  * 发布渠道
291
384
  */
@@ -1086,13 +1179,12 @@ declare const CURRENT_SCHEMA_VERSION = "2.0.0";
1086
1179
  */
1087
1180
  type SchemaVersion = typeof CURRENT_SCHEMA_VERSION | '1.0.0' | '0.9.0';
1088
1181
  /**
1089
- * 页面 Schema V2 Runtime Core(不可变版本的核心结构)
1182
+ * 页面 Schema Runtime Core(不可变版本的核心结构)
1090
1183
  *
1091
1184
  * @description
1092
1185
  * 发布后的 pageVersion 中存储的完整页面定义。
1093
1186
  * 一旦发布,此结构永不修改(只能新发版本)。
1094
1187
  *
1095
- * V2 版本核心变化:
1096
1188
  * - 新增 pageId/pageVersion 独立标识
1097
1189
  * - 新增 runtime 运行时规格
1098
1190
  * - 状态管理扁平化(仅页面级状态)
@@ -4052,231 +4144,76 @@ interface LotteryState {
4052
4144
  }
4053
4145
 
4054
4146
  /**
4055
- * @djvlc/contracts-types - Outbox 事件类型定义
4147
+ * @djvlc/contracts-types - 版本管理核心类型
4056
4148
  *
4057
- * Outbox 模式用于可靠的异步事件处理:
4058
- * - 审计日志
4059
- * - CDN 刷新
4060
- * - 静态发布
4061
- * - 通知推送
4062
- * - 数据同步
4149
+ * 定义版本对比、变更日志等公共类型
4150
+ * 注意:API 请求/响应类型由 OpenAPI 生成,不在此定义
4063
4151
  *
4064
4152
  * @packageDocumentation
4065
4153
  */
4066
4154
 
4067
4155
  /**
4068
- * Outbox 事件类型
4156
+ * 变更日志项
4157
+ *
4158
+ * @description
4159
+ * 记录单个字段的变更,用于版本对比和审计
4069
4160
  */
4070
- type OutboxEventType = 'page.published' | 'page.rolled_back' | 'page.deleted' | 'component.registered' | 'component.blocked' | 'component.deprecated' | 'action.executed' | 'action.failed' | 'activity.created' | 'activity.started' | 'activity.ended' | 'claim.succeeded' | 'signin.succeeded' | 'lottery.drawn' | 'audit.high_risk_action' | 'cdn.invalidate' | 'cdn.prefetch' | 'notification.send' | 'custom';
4161
+ interface ChangeLogItem {
4162
+ /** 旧值 */
4163
+ old: unknown;
4164
+ /** 新值 */
4165
+ new: unknown;
4166
+ /** 摘要描述 */
4167
+ summary?: string;
4168
+ }
4071
4169
  /**
4072
- * Outbox 事件状态
4170
+ * 变更日志
4171
+ *
4172
+ * @description
4173
+ * 以字段路径为 key 的变更记录集合
4073
4174
  */
4074
- type OutboxEventStatus = 'pending' | 'processing' | 'completed' | 'failed' | 'dead_letter';
4175
+ type ChangeLog = Record<string, ChangeLogItem>;
4075
4176
  /**
4076
- * Outbox 事件基础结构
4177
+ * 版本信息
4178
+ *
4179
+ * @description
4180
+ * 页面/组件等资源的版本记录基础信息
4077
4181
  */
4078
- interface OutboxEventBase {
4079
- /** 事件 ID */
4080
- id: UniqueId;
4081
- /** 事件类型 */
4082
- eventType: OutboxEventType;
4083
- /** 聚合类型 */
4084
- aggregateType: 'page' | 'component' | 'action' | 'activity' | 'audit' | 'cdn' | 'notification';
4085
- /** 聚合 ID */
4086
- aggregateId: UniqueId;
4087
- /** 事件版本(用于乐观锁) */
4088
- version: number;
4089
- /** 链路追踪 ID */
4090
- traceId: string;
4091
- /** 请求 ID */
4092
- requestId: string;
4093
- /** 操作者 */
4094
- actor: EventActor;
4095
- /** 事件状态 */
4096
- status: OutboxEventStatus;
4097
- /** 重试次数 */
4098
- retryCount: number;
4099
- /** 最大重试次数 */
4100
- maxRetries: number;
4101
- /** 下次重试时间 */
4102
- nextRetryAt?: ISODateTime;
4182
+ interface VersionInfo {
4183
+ /** 版本唯一标识 */
4184
+ uid: UniqueId;
4185
+ /** 版本序号(自增) */
4186
+ versionNumber: number;
4187
+ /** 版本标签(如 v1.0.0) */
4188
+ versionLabel?: string;
4189
+ /** 版本描述 */
4190
+ description?: string;
4191
+ /** 是否自动保存的版本 */
4192
+ isAutoSave: boolean;
4193
+ /** 是否已发布 */
4194
+ isPublished: boolean;
4103
4195
  /** 创建时间 */
4104
4196
  createdAt: ISODateTime;
4105
- /** 处理时间 */
4106
- processedAt?: ISODateTime;
4107
- /** 失败原因 */
4108
- failureReason?: string;
4109
- /** 处理结果 */
4110
- result?: Record<string, unknown>;
4111
- }
4112
- /**
4113
- * 事件操作者
4114
- */
4115
- interface EventActor {
4116
- /** 操作者类型 */
4117
- type: 'user' | 'system' | 'scheduler' | 'api';
4118
- /** 操作者 ID */
4119
- id: string;
4120
- /** 操作者名称 */
4121
- name?: string;
4122
- /** IP 地址 */
4123
- ip?: string;
4124
- /** 用户代理 */
4125
- userAgent?: string;
4126
- }
4127
- /**
4128
- * 页面发布事件
4129
- */
4130
- interface PagePublishedEvent extends OutboxEventBase {
4131
- eventType: 'page.published';
4132
- aggregateType: 'page';
4133
- payload: {
4134
- pageId: UniqueId;
4135
- pageVersionId: UniqueId;
4136
- manifestId: UniqueId;
4137
- publishedBy: string;
4138
- channel?: string;
4139
- rolloutConfig?: Record<string, unknown>;
4140
- };
4141
- }
4142
- /**
4143
- * 页面回滚事件
4144
- */
4145
- interface PageRolledBackEvent extends OutboxEventBase {
4146
- eventType: 'page.rolled_back';
4147
- aggregateType: 'page';
4148
- payload: {
4149
- pageId: UniqueId;
4150
- fromVersionId: UniqueId;
4151
- toVersionId: UniqueId;
4152
- reason: string;
4153
- rolledBackBy: string;
4154
- };
4155
- }
4156
- /**
4157
- * 组件阻断事件
4158
- */
4159
- interface ComponentBlockedEvent extends OutboxEventBase {
4160
- eventType: 'component.blocked';
4161
- aggregateType: 'component';
4162
- payload: {
4163
- componentId: UniqueId;
4164
- version: string;
4165
- reason: string;
4166
- blockedBy: string;
4167
- urgent: boolean;
4168
- affectedPages: UniqueId[];
4169
- };
4170
- }
4171
- /**
4172
- * 动作执行事件
4173
- */
4174
- interface ActionExecutedEvent extends OutboxEventBase {
4175
- eventType: 'action.executed';
4176
- aggregateType: 'action';
4177
- payload: {
4178
- actionType: string;
4179
- actionId?: UniqueId;
4180
- pageVersionId: UniqueId;
4181
- componentVersionId?: UniqueId;
4182
- userId: string;
4183
- params: Record<string, unknown>;
4184
- result: Record<string, unknown>;
4185
- durationMs: number;
4186
- };
4187
- }
4188
- /**
4189
- * CDN 失效事件
4190
- */
4191
- interface CdnInvalidateEvent extends OutboxEventBase {
4192
- eventType: 'cdn.invalidate';
4193
- aggregateType: 'cdn';
4194
- payload: {
4195
- urls: string[];
4196
- patterns?: string[];
4197
- reason: string;
4198
- priority: 'high' | 'normal' | 'low';
4199
- };
4200
- }
4201
- /**
4202
- * 审计高危动作事件
4203
- */
4204
- interface AuditHighRiskEvent extends OutboxEventBase {
4205
- eventType: 'audit.high_risk_action';
4206
- aggregateType: 'audit';
4207
- payload: {
4208
- action: string;
4209
- targetType: string;
4210
- targetId: UniqueId;
4211
- summary: Record<string, unknown>;
4212
- riskLevel: 'high' | 'critical';
4213
- requiresReview: boolean;
4214
- };
4215
- }
4216
- /**
4217
- * Outbox 事件(联合类型)
4218
- */
4219
- type OutboxEvent = PagePublishedEvent | PageRolledBackEvent | ComponentBlockedEvent | ActionExecutedEvent | CdnInvalidateEvent | AuditHighRiskEvent;
4220
- /**
4221
- * 创建 Outbox 事件请求
4222
- */
4223
- interface CreateOutboxEventRequest<T = Record<string, unknown>> {
4224
- /** 事件类型 */
4225
- eventType: OutboxEventType;
4226
- /** 聚合类型 */
4227
- aggregateType: string;
4228
- /** 聚合 ID */
4229
- aggregateId: UniqueId;
4230
- /** 事件负载 */
4231
- payload: T;
4232
- /** 链路追踪 ID */
4233
- traceId: string;
4234
- /** 请求 ID */
4235
- requestId: string;
4236
- /** 操作者 */
4237
- actor: EventActor;
4238
- /** 延迟执行(秒) */
4239
- delaySeconds?: number;
4240
- /** 最大重试次数 */
4241
- maxRetries?: number;
4197
+ /** 创建者 UID */
4198
+ createdBy: string;
4199
+ /** 创建者用户名 */
4200
+ createdByUsername: string;
4242
4201
  }
4243
4202
  /**
4244
- * Outbox 事件处理结果
4245
- */
4246
- interface OutboxProcessResult {
4247
- /** 事件 ID */
4248
- eventId: UniqueId;
4249
- /** 是否成功 */
4250
- success: boolean;
4251
- /** 处理时间 */
4252
- processedAt: ISODateTime;
4253
- /** 处理耗时(毫秒) */
4254
- durationMs: number;
4255
- /** 错误信息(失败时) */
4256
- error?: string;
4257
- /** 处理结果 */
4258
- result?: Record<string, unknown>;
4259
- /** 是否需要重试 */
4260
- shouldRetry?: boolean;
4261
- }
4262
- /**
4263
- * Outbox 统计信息
4264
- */
4265
- interface OutboxStats {
4266
- /** 待处理数量 */
4267
- pending: number;
4268
- /** 处理中数量 */
4269
- processing: number;
4270
- /** 失败数量 */
4271
- failed: number;
4272
- /** 死信数量 */
4273
- deadLetter: number;
4274
- /** 最近 1 小时完成数量 */
4275
- completedLastHour: number;
4276
- /** 最近 1 小时失败数量 */
4277
- failedLastHour: number;
4278
- /** 平均处理时间(毫秒) */
4279
- avgProcessingTimeMs: number;
4203
+ * 版本对比结果
4204
+ *
4205
+ * @description
4206
+ * 两个版本之间的差异摘要
4207
+ */
4208
+ interface VersionDiff {
4209
+ /** 新增的内容(ID 或路径列表) */
4210
+ added: string[];
4211
+ /** 删除的内容 */
4212
+ removed: string[];
4213
+ /** 修改的内容 */
4214
+ modified: string[];
4215
+ /** 详细变更日志 */
4216
+ changeLog: ChangeLog;
4280
4217
  }
4281
4218
 
4282
4219
  /**
@@ -4293,10 +4230,26 @@ interface OutboxStats {
4293
4230
  /**
4294
4231
  * 包版本号
4295
4232
  */
4296
- declare const VERSION = "2.0.0";
4233
+ declare const VERSION = "2.1.0";
4297
4234
  /**
4298
4235
  * 协议版本号
4299
4236
  */
4300
4237
  declare const PROTOCOL_VERSION = "2.0.0";
4238
+ /**
4239
+ * PageSchema 当前版本
4240
+ */
4241
+ declare const PAGE_SCHEMA_VERSION = "2.0.0";
4242
+ /**
4243
+ * ComponentMeta 当前版本
4244
+ */
4245
+ declare const COMPONENT_META_SCHEMA_VERSION = "2.0.0";
4246
+ /**
4247
+ * ActionSpec 当前版本
4248
+ */
4249
+ declare const ACTION_SPEC_VERSION = "2.0.0";
4250
+ /**
4251
+ * DataQuerySpec 当前版本
4252
+ */
4253
+ declare const DATA_QUERY_SPEC_VERSION = "2.0.0";
4301
4254
 
4302
- export { type ABTestRolloutConfig, ALLOWED_FUNCTION_NAMES, ALL_BUILTIN_FUNCTIONS, ARRAY_FUNCTIONS, type ActionClientContext, type ActionDefinition, type ActionDefinitionVersion, type ActionExecuteRequest, type ActionExecuteResponse, type ActionExecutedEvent, type ActionExecutor, type ActionPolicy, type ActionRef, type ActionResult, type ActionSheetItem, type ActionSheetOptions, type ActionSheetResult, type ActionSpec, ActionType, type Activity, type ActivityPrecondition, type ActivityRule, type ActivityStatus, type ActivityType, type AggregationDataSourceConfig, type AggregationQueryItem, type AnyValueOrExpression, type ApiErrorDetail, type ApiErrorResponse, type ApiResponse, type ApiSuccessResponse, type AppContext, AuditAction, type AuditConfig, type AuditHighRiskEvent, type AuditLogEntry, type BackgroundConfig, type BaseActivityRule, type BlacklistRolloutConfig, type BlockedComponentInfo, type BrowserCompat, type BuiltinActionType, CURRENT_ACTION_SPEC_VERSION, CURRENT_COMPONENT_META_VERSION, CURRENT_DATA_QUERY_SPEC_VERSION, CURRENT_SCHEMA_VERSION, type CacheConfig, type CacheLevel, type CanaryHealthCheck, type CanaryRolloutConfig, type CanaryStage, type CanvasType, type CapabilityDeclaration, type CapabilityName, type CdnInvalidateEvent, type ClaimActivityRule, type ClaimPrize, type ClaimRecord, type ClaimState, type ClipboardApi, type CompatInfo, type Component, type ComponentBlockedEvent, type ComponentCategory, type ComponentContext, type ComponentDependency, type ComponentIntegrity, type ComponentMeta, type ComponentNode, type ComponentQueryParams, type ComponentRegisterRequest, type ComponentStatusChangeRequest, type ComponentVersion, type ConfirmOptions, type ConsecutiveReward, type CreateManifestRequest, type CreateOutboxEventRequest, type CumulativeReward, DATE_FUNCTIONS, DEFAULT_EXPRESSION_VALIDATION_CONFIG, type DataBinding, type DataBindingErrorConfig, type DataLoadStrategy, type DataQueryDefinition, type DataQueryDefinitionVersion, type DataQueryRequest, type DataQueryResponse, type DataQuerySpec, type DataSourceConfig, type DataSourceType, type DatabaseDataSourceConfig, type DialogOptions, type DialogResult, type EditorComponent, ErrorCategory, ErrorCode, ErrorCodeToHttpStatus, type ErrorMapping, type EventActor, type EventDeclaration, type EventHandler, type ExecutorContext, type ExecutorResult, type Expression, type ExpressionFunctionCategory, type ExpressionFunctionDefinition, type ExpressionType, type ExpressionValidationConfig, type ExpressionValidationError, type ExpressionValidationResult, type ExpressionValidationWarning, FORMAT_FUNCTIONS, type FallbackCondition, type FallbackConfig, type FeatureCondition, type FeatureRolloutConfig, type FieldPermission, type FieldPolicy, type FieldTransform, type FileIntegrity, type FunctionParamDefinition, type GraphQLDataSourceConfig, type HostApi, type HttpDataSourceConfig, type HttpRetryConfig, type I18nDetectionStrategy, type ISODateTime, type IdempotencyKeyStrategy, type IdempotencyRule, type IntegrityHash, type InternalDataSourceConfig, type InventoryConfig, type JsonObject, type JsonValue, LOGIC_FUNCTIONS, type LayoutConfig, type LayoutValues, type LoopConfig, type LotteryActivityRule, type LotteryCost, type LotteryPrize, type LotteryState, type Manifest, type ManifestEntry, type ManifestItem, type ManifestValidationError, type ManifestValidationResult, type ManifestValidationWarning, type MaskingConfig, type MaskingRule, type MaskingType, type MethodCategory, type MethodDeclaration, type MethodParam, NUMBER_FUNCTIONS, type NavigateOptions, type NodeStyleConfig, type OrderByItem, type OutboxEvent, type OutboxEventBase, type OutboxEventStatus, type OutboxEventType, type OutboxProcessResult, type OutboxStats, PROTOCOL_VERSION, type PageConfig, type PageDraft, type PageI18nConfig, type PageLifecycle, type PageManifest, type PageMeta, type PagePublishedEvent, type PageResolveResponse, type PageRolledBackEvent, type PageSEO, type PageSchema, type PageState, type PageVersion, type PaginatedResponse, type PaginationMeta, type PaginationParams, type ParamPermission, type ParticipationLimit, type PercentageRolloutConfig, type PityConfig, type Precondition, type PreconditionType, type PreviewImageOptions, type ProbabilityConfig, type PropDefinition, type PropFormat, type PropGroup, type PropType, type PropValue, type PropsSchema, type PublishCdnConfig, PublishChannel, type PublishConfig, type PublishNotificationConfig, type PublishRecord, type PublishRolloutConfig, PublishStatus, type QueryPermissions, type RateLimitDimension, type RateLimitItem, type RateLimitRule, type RequestContext, type ResolvedManifest, type ResponsiveBreakpoints, type RetryPolicy, type RiskControlConfig, type RolloutConfig, type RolloutMatchRequest, type RolloutMatchResult, type RolloutStrategy, type RolloutStrategyConfig, type RolloutStrategyType, type RuntimeConfig, type RuntimeContext, type RuntimeSpec, type SHAIntegrity, STRING_FUNCTIONS, type ScanCodeResult, type SchemaVersion, type SemVer, type ShareOptions, type ShareResult, type SigninActivityRule, type SigninRecord, type SigninRewardRecord, type SigninState, type SlotCategory, type SlotDeclaration, type StateFieldDefinition, type StorageApi, type StorageOptions, type StyleConfig, type StyleIsolation, type TimeWindowRolloutConfig, type ToastOptions, type TrackEvent, type URLString, UTILITY_FUNCTIONS, type UniqueId, type UpsertRolloutRequest, type UserActivityState, type UserContext, VERSION, type ValidationRule, VersionStatus, type WhitelistRolloutConfig, bindingRef, literal, queryRef, stateRef, template };
4255
+ export { type ABTestRolloutConfig, ACTION_SPEC_VERSION, ALLOWED_FUNCTION_NAMES, ALL_BUILTIN_FUNCTIONS, ARRAY_FUNCTIONS, type ActionClientContext, type ActionDefinition, type ActionDefinitionVersion, type ActionExecuteRequest, type ActionExecuteResponse, type ActionExecutor, type ActionPolicy, type ActionRef, type ActionResult, type ActionSheetItem, type ActionSheetOptions, type ActionSheetResult, type ActionSpec, ActionType, type Activity, type ActivityPrecondition, type ActivityRule, type ActivityStatus, type ActivityType, type AggregationDataSourceConfig, type AggregationQueryItem, type AnyValueOrExpression, type ApiErrorDetail, type ApiErrorResponse, type ApiResponse, type ApiSuccessResponse, type AppContext, AuditAction, type AuditConfig, type AuditLogEntry, type BackgroundConfig, type BaseActivityRule, type BlacklistRolloutConfig, type BlockedComponentInfo, type BrowserCompat, type BuiltinActionType, COMPONENT_META_SCHEMA_VERSION, CURRENT_ACTION_SPEC_VERSION, CURRENT_COMPONENT_META_VERSION, CURRENT_DATA_QUERY_SPEC_VERSION, CURRENT_SCHEMA_VERSION, type CacheConfig, type CacheLevel, type CanaryHealthCheck, type CanaryRolloutConfig, type CanaryStage, type CanvasType, type CapabilityDeclaration, type CapabilityName, type ChangeLog, type ChangeLogItem, type ClaimActivityRule, type ClaimPrize, type ClaimRecord, type ClaimState, type ClipboardApi, type CompatInfo, type Component, type ComponentCategory, type ComponentContext, type ComponentDependency, type ComponentIntegrity, type ComponentMeta, type ComponentNode, type ComponentQueryParams, type ComponentRegisterRequest, type ComponentStatus, type ComponentStatusChangeRequest, type ComponentVersion, type ConfirmOptions, type ConsecutiveReward, type CreateManifestRequest, type CumulativeReward, DATA_QUERY_SPEC_VERSION, DATE_FUNCTIONS, DEFAULT_EXPRESSION_VALIDATION_CONFIG, type DataBinding, type DataBindingErrorConfig, type DataLoadStrategy, type DataQueryDefinition, type DataQueryDefinitionVersion, type DataQueryRequest, type DataQueryResponse, type DataQuerySpec, type DataSourceConfig, type DataSourceType, type DatabaseDataSourceConfig, type DialogOptions, type DialogResult, type DjvlcError, type EditorComponent, type Environment, ErrorCategory, ErrorCode, ErrorCodeToHttpStatus, type ErrorMapping, ErrorMessages, type EventDeclaration, type EventHandler, type ExecutorContext, type ExecutorResult, type Expression, type ExpressionFunctionCategory, type ExpressionFunctionDefinition, type ExpressionType, type ExpressionValidationConfig, type ExpressionValidationError, type ExpressionValidationResult, type ExpressionValidationWarning, FORMAT_FUNCTIONS, type FallbackCondition, type FallbackConfig, type FeatureCondition, type FeatureRolloutConfig, type FieldPermission, type FieldPolicy, type FieldTransform, type FileIntegrity, type FunctionParamDefinition, type GraphQLDataSourceConfig, type HostApi, type HttpDataSourceConfig, type HttpRetryConfig, type I18nDetectionStrategy, type ISODateTime, type IdempotencyKeyStrategy, type IdempotencyRule, type IntegrityHash, type InternalDataSourceConfig, type InventoryConfig, type JsonObject, type JsonValue, LOGIC_FUNCTIONS, type LayoutConfig, type LayoutValues, type LoopConfig, type LotteryActivityRule, type LotteryCost, type LotteryPrize, type LotteryState, type Manifest, type ManifestEntry, type ManifestItem, type ManifestValidationError, type ManifestValidationResult, type ManifestValidationWarning, type MaskingConfig, type MaskingRule, type MaskingType, type MethodCategory, type MethodDeclaration, type MethodParam, NUMBER_FUNCTIONS, type NavigateOptions, type NodeStyleConfig, type OperatorInfo, type OrderByItem, PAGE_SCHEMA_VERSION, PROTOCOL_VERSION, type PageConfig, type PageDraft, type PageI18nConfig, type PageLifecycle, type PageManifest, type PageMeta, type PageResolveResponse, type PageSEO, type PageSchema, type PageState, PageStatus, type PageStatusType, type PageVersion, type PaginatedResponse, type PaginationMeta, type PaginationParams, type ParamPermission, type ParticipationLimit, type PercentageRolloutConfig, type PityConfig, type Precondition, type PreconditionType, type PreviewImageOptions, type ProbabilityConfig, type PropDefinition, type PropFormat, type PropGroup, type PropType, type PropValue, type PropsSchema, type PublishCdnConfig, PublishChannel, type PublishConfig, type PublishEnvironment, type PublishNotificationConfig, type PublishRecord, type PublishRolloutConfig, PublishStatus, type QueryPermissions, type RateLimitDimension, type RateLimitItem, type RateLimitRule, type RequestContext, type ResolvedManifest, type ResponsiveBreakpoints, type RetryPolicy, type RiskControlConfig, type RolloutConfig, type RolloutMatchRequest, type RolloutMatchResult, type RolloutStrategy, type RolloutStrategyConfig, type RolloutStrategyType, type RuntimeConfig, type RuntimeContext, type RuntimeSpec, type SHAIntegrity, STRING_FUNCTIONS, type ScanCodeResult, type SchemaVersion, type SemVer, type ShareOptions, type ShareResult, type SigninActivityRule, type SigninRecord, type SigninRewardRecord, type SigninState, type SlotCategory, type SlotDeclaration, type StateFieldDefinition, type StorageApi, type StorageOptions, type StyleConfig, type StyleIsolation, type TimeWindowRolloutConfig, type ToastOptions, type TrackEvent, type URLString, UTILITY_FUNCTIONS, type UniqueId, type UpsertRolloutRequest, type UserActivityState, type UserContext, VERSION, type ValidationRule, type VersionDiff, type VersionInfo, VersionStatus, type VersionStatusType, type WhitelistRolloutConfig, bindingRef, createDjvlcError, isDjvlcError, literal, queryRef, stateRef, template };
package/dist/index.d.ts CHANGED
@@ -40,6 +40,39 @@ type JsonObject = Record<string, JsonValue>;
40
40
  * 上下文类型定义
41
41
  */
42
42
 
43
+ /**
44
+ * 操作者信息
45
+ *
46
+ * @description
47
+ * 用于审计日志、操作记录等场景,标识执行操作的用户。
48
+ * 适用于管理后台操作、API 调用等需要追踪操作者的场景。
49
+ */
50
+ interface OperatorInfo {
51
+ /** 用户唯一标识 */
52
+ uid: string;
53
+ /** 用户名(显示名称) */
54
+ username: string;
55
+ /** 用户角色列表 */
56
+ roles?: string[];
57
+ /** 操作来源 IP */
58
+ ip?: string;
59
+ /** User Agent */
60
+ userAgent?: string;
61
+ }
62
+ /**
63
+ * 部署环境类型
64
+ *
65
+ * @description
66
+ * 用于区分不同的部署环境,影响配置、日志级别、功能开关等。
67
+ */
68
+ type Environment = 'development' | 'staging' | 'production';
69
+ /**
70
+ * 发布环境类型(页面发布使用)
71
+ *
72
+ * @description
73
+ * 页面可以发布到不同的环境,支持预览、灰度、正式等场景。
74
+ */
75
+ type PublishEnvironment = 'preview' | 'staging' | 'prod';
43
76
  /**
44
77
  * 应用上下文
45
78
  */
@@ -178,6 +211,36 @@ declare enum ErrorCode {
178
211
  * 错误码到 HTTP 状态码映射
179
212
  */
180
213
  declare const ErrorCodeToHttpStatus: Record<ErrorCode, number>;
214
+ /**
215
+ * 错误码到消息映射
216
+ */
217
+ declare const ErrorMessages: Record<ErrorCode, string>;
218
+ /**
219
+ * DJVLC 错误接口
220
+ */
221
+ interface DjvlcError extends Error {
222
+ /** 错误码 */
223
+ code: ErrorCode | string;
224
+ /** HTTP 状态码 */
225
+ httpStatus: number;
226
+ /** 错误详情 */
227
+ details?: Record<string, unknown>;
228
+ /** 追踪 ID */
229
+ traceId?: string;
230
+ }
231
+ /**
232
+ * 创建 DJVLC 错误
233
+ *
234
+ * @param code 错误码
235
+ * @param message 错误消息(可选,默认使用 ErrorMessages 中的消息)
236
+ * @param details 错误详情
237
+ * @returns DjvlcError 错误对象
238
+ */
239
+ declare function createDjvlcError(code: ErrorCode, message?: string, details?: Record<string, unknown>): DjvlcError;
240
+ /**
241
+ * 判断是否为 DJVLC 错误
242
+ */
243
+ declare function isDjvlcError(error: unknown): error is DjvlcError;
181
244
 
182
245
  /**
183
246
  * API 响应格式
@@ -286,6 +349,36 @@ declare enum VersionStatus {
286
349
  /** 已阻断(禁止使用) */
287
350
  BLOCKED = "blocked"
288
351
  }
352
+ /**
353
+ * 版本状态类型(字符串字面量版本,用于 JSON/数据库存储)
354
+ */
355
+ type VersionStatusType = 'draft' | 'stable' | 'deprecated' | 'blocked';
356
+ /**
357
+ * 页面状态枚举
358
+ */
359
+ declare enum PageStatus {
360
+ /** 草稿状态 */
361
+ DRAFT = "draft",
362
+ /** 已发布 */
363
+ PUBLISHED = "published",
364
+ /** 已归档 */
365
+ ARCHIVED = "archived"
366
+ }
367
+ /**
368
+ * 页面状态类型(字符串字面量版本)
369
+ */
370
+ type PageStatusType = 'draft' | 'published' | 'archived';
371
+ /**
372
+ * 组件状态类型
373
+ *
374
+ * @description
375
+ * 用于组件版本的生命周期管理。
376
+ * - draft: 开发中,仅内部可见
377
+ * - stable: 稳定版,推荐使用
378
+ * - deprecated: 已废弃,不推荐使用,但仍可用
379
+ * - blocked: 已阻断,禁止使用(安全原因)
380
+ */
381
+ type ComponentStatus = 'draft' | 'stable' | 'deprecated' | 'blocked';
289
382
  /**
290
383
  * 发布渠道
291
384
  */
@@ -1086,13 +1179,12 @@ declare const CURRENT_SCHEMA_VERSION = "2.0.0";
1086
1179
  */
1087
1180
  type SchemaVersion = typeof CURRENT_SCHEMA_VERSION | '1.0.0' | '0.9.0';
1088
1181
  /**
1089
- * 页面 Schema V2 Runtime Core(不可变版本的核心结构)
1182
+ * 页面 Schema Runtime Core(不可变版本的核心结构)
1090
1183
  *
1091
1184
  * @description
1092
1185
  * 发布后的 pageVersion 中存储的完整页面定义。
1093
1186
  * 一旦发布,此结构永不修改(只能新发版本)。
1094
1187
  *
1095
- * V2 版本核心变化:
1096
1188
  * - 新增 pageId/pageVersion 独立标识
1097
1189
  * - 新增 runtime 运行时规格
1098
1190
  * - 状态管理扁平化(仅页面级状态)
@@ -4052,231 +4144,76 @@ interface LotteryState {
4052
4144
  }
4053
4145
 
4054
4146
  /**
4055
- * @djvlc/contracts-types - Outbox 事件类型定义
4147
+ * @djvlc/contracts-types - 版本管理核心类型
4056
4148
  *
4057
- * Outbox 模式用于可靠的异步事件处理:
4058
- * - 审计日志
4059
- * - CDN 刷新
4060
- * - 静态发布
4061
- * - 通知推送
4062
- * - 数据同步
4149
+ * 定义版本对比、变更日志等公共类型
4150
+ * 注意:API 请求/响应类型由 OpenAPI 生成,不在此定义
4063
4151
  *
4064
4152
  * @packageDocumentation
4065
4153
  */
4066
4154
 
4067
4155
  /**
4068
- * Outbox 事件类型
4156
+ * 变更日志项
4157
+ *
4158
+ * @description
4159
+ * 记录单个字段的变更,用于版本对比和审计
4069
4160
  */
4070
- type OutboxEventType = 'page.published' | 'page.rolled_back' | 'page.deleted' | 'component.registered' | 'component.blocked' | 'component.deprecated' | 'action.executed' | 'action.failed' | 'activity.created' | 'activity.started' | 'activity.ended' | 'claim.succeeded' | 'signin.succeeded' | 'lottery.drawn' | 'audit.high_risk_action' | 'cdn.invalidate' | 'cdn.prefetch' | 'notification.send' | 'custom';
4161
+ interface ChangeLogItem {
4162
+ /** 旧值 */
4163
+ old: unknown;
4164
+ /** 新值 */
4165
+ new: unknown;
4166
+ /** 摘要描述 */
4167
+ summary?: string;
4168
+ }
4071
4169
  /**
4072
- * Outbox 事件状态
4170
+ * 变更日志
4171
+ *
4172
+ * @description
4173
+ * 以字段路径为 key 的变更记录集合
4073
4174
  */
4074
- type OutboxEventStatus = 'pending' | 'processing' | 'completed' | 'failed' | 'dead_letter';
4175
+ type ChangeLog = Record<string, ChangeLogItem>;
4075
4176
  /**
4076
- * Outbox 事件基础结构
4177
+ * 版本信息
4178
+ *
4179
+ * @description
4180
+ * 页面/组件等资源的版本记录基础信息
4077
4181
  */
4078
- interface OutboxEventBase {
4079
- /** 事件 ID */
4080
- id: UniqueId;
4081
- /** 事件类型 */
4082
- eventType: OutboxEventType;
4083
- /** 聚合类型 */
4084
- aggregateType: 'page' | 'component' | 'action' | 'activity' | 'audit' | 'cdn' | 'notification';
4085
- /** 聚合 ID */
4086
- aggregateId: UniqueId;
4087
- /** 事件版本(用于乐观锁) */
4088
- version: number;
4089
- /** 链路追踪 ID */
4090
- traceId: string;
4091
- /** 请求 ID */
4092
- requestId: string;
4093
- /** 操作者 */
4094
- actor: EventActor;
4095
- /** 事件状态 */
4096
- status: OutboxEventStatus;
4097
- /** 重试次数 */
4098
- retryCount: number;
4099
- /** 最大重试次数 */
4100
- maxRetries: number;
4101
- /** 下次重试时间 */
4102
- nextRetryAt?: ISODateTime;
4182
+ interface VersionInfo {
4183
+ /** 版本唯一标识 */
4184
+ uid: UniqueId;
4185
+ /** 版本序号(自增) */
4186
+ versionNumber: number;
4187
+ /** 版本标签(如 v1.0.0) */
4188
+ versionLabel?: string;
4189
+ /** 版本描述 */
4190
+ description?: string;
4191
+ /** 是否自动保存的版本 */
4192
+ isAutoSave: boolean;
4193
+ /** 是否已发布 */
4194
+ isPublished: boolean;
4103
4195
  /** 创建时间 */
4104
4196
  createdAt: ISODateTime;
4105
- /** 处理时间 */
4106
- processedAt?: ISODateTime;
4107
- /** 失败原因 */
4108
- failureReason?: string;
4109
- /** 处理结果 */
4110
- result?: Record<string, unknown>;
4111
- }
4112
- /**
4113
- * 事件操作者
4114
- */
4115
- interface EventActor {
4116
- /** 操作者类型 */
4117
- type: 'user' | 'system' | 'scheduler' | 'api';
4118
- /** 操作者 ID */
4119
- id: string;
4120
- /** 操作者名称 */
4121
- name?: string;
4122
- /** IP 地址 */
4123
- ip?: string;
4124
- /** 用户代理 */
4125
- userAgent?: string;
4126
- }
4127
- /**
4128
- * 页面发布事件
4129
- */
4130
- interface PagePublishedEvent extends OutboxEventBase {
4131
- eventType: 'page.published';
4132
- aggregateType: 'page';
4133
- payload: {
4134
- pageId: UniqueId;
4135
- pageVersionId: UniqueId;
4136
- manifestId: UniqueId;
4137
- publishedBy: string;
4138
- channel?: string;
4139
- rolloutConfig?: Record<string, unknown>;
4140
- };
4141
- }
4142
- /**
4143
- * 页面回滚事件
4144
- */
4145
- interface PageRolledBackEvent extends OutboxEventBase {
4146
- eventType: 'page.rolled_back';
4147
- aggregateType: 'page';
4148
- payload: {
4149
- pageId: UniqueId;
4150
- fromVersionId: UniqueId;
4151
- toVersionId: UniqueId;
4152
- reason: string;
4153
- rolledBackBy: string;
4154
- };
4155
- }
4156
- /**
4157
- * 组件阻断事件
4158
- */
4159
- interface ComponentBlockedEvent extends OutboxEventBase {
4160
- eventType: 'component.blocked';
4161
- aggregateType: 'component';
4162
- payload: {
4163
- componentId: UniqueId;
4164
- version: string;
4165
- reason: string;
4166
- blockedBy: string;
4167
- urgent: boolean;
4168
- affectedPages: UniqueId[];
4169
- };
4170
- }
4171
- /**
4172
- * 动作执行事件
4173
- */
4174
- interface ActionExecutedEvent extends OutboxEventBase {
4175
- eventType: 'action.executed';
4176
- aggregateType: 'action';
4177
- payload: {
4178
- actionType: string;
4179
- actionId?: UniqueId;
4180
- pageVersionId: UniqueId;
4181
- componentVersionId?: UniqueId;
4182
- userId: string;
4183
- params: Record<string, unknown>;
4184
- result: Record<string, unknown>;
4185
- durationMs: number;
4186
- };
4187
- }
4188
- /**
4189
- * CDN 失效事件
4190
- */
4191
- interface CdnInvalidateEvent extends OutboxEventBase {
4192
- eventType: 'cdn.invalidate';
4193
- aggregateType: 'cdn';
4194
- payload: {
4195
- urls: string[];
4196
- patterns?: string[];
4197
- reason: string;
4198
- priority: 'high' | 'normal' | 'low';
4199
- };
4200
- }
4201
- /**
4202
- * 审计高危动作事件
4203
- */
4204
- interface AuditHighRiskEvent extends OutboxEventBase {
4205
- eventType: 'audit.high_risk_action';
4206
- aggregateType: 'audit';
4207
- payload: {
4208
- action: string;
4209
- targetType: string;
4210
- targetId: UniqueId;
4211
- summary: Record<string, unknown>;
4212
- riskLevel: 'high' | 'critical';
4213
- requiresReview: boolean;
4214
- };
4215
- }
4216
- /**
4217
- * Outbox 事件(联合类型)
4218
- */
4219
- type OutboxEvent = PagePublishedEvent | PageRolledBackEvent | ComponentBlockedEvent | ActionExecutedEvent | CdnInvalidateEvent | AuditHighRiskEvent;
4220
- /**
4221
- * 创建 Outbox 事件请求
4222
- */
4223
- interface CreateOutboxEventRequest<T = Record<string, unknown>> {
4224
- /** 事件类型 */
4225
- eventType: OutboxEventType;
4226
- /** 聚合类型 */
4227
- aggregateType: string;
4228
- /** 聚合 ID */
4229
- aggregateId: UniqueId;
4230
- /** 事件负载 */
4231
- payload: T;
4232
- /** 链路追踪 ID */
4233
- traceId: string;
4234
- /** 请求 ID */
4235
- requestId: string;
4236
- /** 操作者 */
4237
- actor: EventActor;
4238
- /** 延迟执行(秒) */
4239
- delaySeconds?: number;
4240
- /** 最大重试次数 */
4241
- maxRetries?: number;
4197
+ /** 创建者 UID */
4198
+ createdBy: string;
4199
+ /** 创建者用户名 */
4200
+ createdByUsername: string;
4242
4201
  }
4243
4202
  /**
4244
- * Outbox 事件处理结果
4245
- */
4246
- interface OutboxProcessResult {
4247
- /** 事件 ID */
4248
- eventId: UniqueId;
4249
- /** 是否成功 */
4250
- success: boolean;
4251
- /** 处理时间 */
4252
- processedAt: ISODateTime;
4253
- /** 处理耗时(毫秒) */
4254
- durationMs: number;
4255
- /** 错误信息(失败时) */
4256
- error?: string;
4257
- /** 处理结果 */
4258
- result?: Record<string, unknown>;
4259
- /** 是否需要重试 */
4260
- shouldRetry?: boolean;
4261
- }
4262
- /**
4263
- * Outbox 统计信息
4264
- */
4265
- interface OutboxStats {
4266
- /** 待处理数量 */
4267
- pending: number;
4268
- /** 处理中数量 */
4269
- processing: number;
4270
- /** 失败数量 */
4271
- failed: number;
4272
- /** 死信数量 */
4273
- deadLetter: number;
4274
- /** 最近 1 小时完成数量 */
4275
- completedLastHour: number;
4276
- /** 最近 1 小时失败数量 */
4277
- failedLastHour: number;
4278
- /** 平均处理时间(毫秒) */
4279
- avgProcessingTimeMs: number;
4203
+ * 版本对比结果
4204
+ *
4205
+ * @description
4206
+ * 两个版本之间的差异摘要
4207
+ */
4208
+ interface VersionDiff {
4209
+ /** 新增的内容(ID 或路径列表) */
4210
+ added: string[];
4211
+ /** 删除的内容 */
4212
+ removed: string[];
4213
+ /** 修改的内容 */
4214
+ modified: string[];
4215
+ /** 详细变更日志 */
4216
+ changeLog: ChangeLog;
4280
4217
  }
4281
4218
 
4282
4219
  /**
@@ -4293,10 +4230,26 @@ interface OutboxStats {
4293
4230
  /**
4294
4231
  * 包版本号
4295
4232
  */
4296
- declare const VERSION = "2.0.0";
4233
+ declare const VERSION = "2.1.0";
4297
4234
  /**
4298
4235
  * 协议版本号
4299
4236
  */
4300
4237
  declare const PROTOCOL_VERSION = "2.0.0";
4238
+ /**
4239
+ * PageSchema 当前版本
4240
+ */
4241
+ declare const PAGE_SCHEMA_VERSION = "2.0.0";
4242
+ /**
4243
+ * ComponentMeta 当前版本
4244
+ */
4245
+ declare const COMPONENT_META_SCHEMA_VERSION = "2.0.0";
4246
+ /**
4247
+ * ActionSpec 当前版本
4248
+ */
4249
+ declare const ACTION_SPEC_VERSION = "2.0.0";
4250
+ /**
4251
+ * DataQuerySpec 当前版本
4252
+ */
4253
+ declare const DATA_QUERY_SPEC_VERSION = "2.0.0";
4301
4254
 
4302
- export { type ABTestRolloutConfig, ALLOWED_FUNCTION_NAMES, ALL_BUILTIN_FUNCTIONS, ARRAY_FUNCTIONS, type ActionClientContext, type ActionDefinition, type ActionDefinitionVersion, type ActionExecuteRequest, type ActionExecuteResponse, type ActionExecutedEvent, type ActionExecutor, type ActionPolicy, type ActionRef, type ActionResult, type ActionSheetItem, type ActionSheetOptions, type ActionSheetResult, type ActionSpec, ActionType, type Activity, type ActivityPrecondition, type ActivityRule, type ActivityStatus, type ActivityType, type AggregationDataSourceConfig, type AggregationQueryItem, type AnyValueOrExpression, type ApiErrorDetail, type ApiErrorResponse, type ApiResponse, type ApiSuccessResponse, type AppContext, AuditAction, type AuditConfig, type AuditHighRiskEvent, type AuditLogEntry, type BackgroundConfig, type BaseActivityRule, type BlacklistRolloutConfig, type BlockedComponentInfo, type BrowserCompat, type BuiltinActionType, CURRENT_ACTION_SPEC_VERSION, CURRENT_COMPONENT_META_VERSION, CURRENT_DATA_QUERY_SPEC_VERSION, CURRENT_SCHEMA_VERSION, type CacheConfig, type CacheLevel, type CanaryHealthCheck, type CanaryRolloutConfig, type CanaryStage, type CanvasType, type CapabilityDeclaration, type CapabilityName, type CdnInvalidateEvent, type ClaimActivityRule, type ClaimPrize, type ClaimRecord, type ClaimState, type ClipboardApi, type CompatInfo, type Component, type ComponentBlockedEvent, type ComponentCategory, type ComponentContext, type ComponentDependency, type ComponentIntegrity, type ComponentMeta, type ComponentNode, type ComponentQueryParams, type ComponentRegisterRequest, type ComponentStatusChangeRequest, type ComponentVersion, type ConfirmOptions, type ConsecutiveReward, type CreateManifestRequest, type CreateOutboxEventRequest, type CumulativeReward, DATE_FUNCTIONS, DEFAULT_EXPRESSION_VALIDATION_CONFIG, type DataBinding, type DataBindingErrorConfig, type DataLoadStrategy, type DataQueryDefinition, type DataQueryDefinitionVersion, type DataQueryRequest, type DataQueryResponse, type DataQuerySpec, type DataSourceConfig, type DataSourceType, type DatabaseDataSourceConfig, type DialogOptions, type DialogResult, type EditorComponent, ErrorCategory, ErrorCode, ErrorCodeToHttpStatus, type ErrorMapping, type EventActor, type EventDeclaration, type EventHandler, type ExecutorContext, type ExecutorResult, type Expression, type ExpressionFunctionCategory, type ExpressionFunctionDefinition, type ExpressionType, type ExpressionValidationConfig, type ExpressionValidationError, type ExpressionValidationResult, type ExpressionValidationWarning, FORMAT_FUNCTIONS, type FallbackCondition, type FallbackConfig, type FeatureCondition, type FeatureRolloutConfig, type FieldPermission, type FieldPolicy, type FieldTransform, type FileIntegrity, type FunctionParamDefinition, type GraphQLDataSourceConfig, type HostApi, type HttpDataSourceConfig, type HttpRetryConfig, type I18nDetectionStrategy, type ISODateTime, type IdempotencyKeyStrategy, type IdempotencyRule, type IntegrityHash, type InternalDataSourceConfig, type InventoryConfig, type JsonObject, type JsonValue, LOGIC_FUNCTIONS, type LayoutConfig, type LayoutValues, type LoopConfig, type LotteryActivityRule, type LotteryCost, type LotteryPrize, type LotteryState, type Manifest, type ManifestEntry, type ManifestItem, type ManifestValidationError, type ManifestValidationResult, type ManifestValidationWarning, type MaskingConfig, type MaskingRule, type MaskingType, type MethodCategory, type MethodDeclaration, type MethodParam, NUMBER_FUNCTIONS, type NavigateOptions, type NodeStyleConfig, type OrderByItem, type OutboxEvent, type OutboxEventBase, type OutboxEventStatus, type OutboxEventType, type OutboxProcessResult, type OutboxStats, PROTOCOL_VERSION, type PageConfig, type PageDraft, type PageI18nConfig, type PageLifecycle, type PageManifest, type PageMeta, type PagePublishedEvent, type PageResolveResponse, type PageRolledBackEvent, type PageSEO, type PageSchema, type PageState, type PageVersion, type PaginatedResponse, type PaginationMeta, type PaginationParams, type ParamPermission, type ParticipationLimit, type PercentageRolloutConfig, type PityConfig, type Precondition, type PreconditionType, type PreviewImageOptions, type ProbabilityConfig, type PropDefinition, type PropFormat, type PropGroup, type PropType, type PropValue, type PropsSchema, type PublishCdnConfig, PublishChannel, type PublishConfig, type PublishNotificationConfig, type PublishRecord, type PublishRolloutConfig, PublishStatus, type QueryPermissions, type RateLimitDimension, type RateLimitItem, type RateLimitRule, type RequestContext, type ResolvedManifest, type ResponsiveBreakpoints, type RetryPolicy, type RiskControlConfig, type RolloutConfig, type RolloutMatchRequest, type RolloutMatchResult, type RolloutStrategy, type RolloutStrategyConfig, type RolloutStrategyType, type RuntimeConfig, type RuntimeContext, type RuntimeSpec, type SHAIntegrity, STRING_FUNCTIONS, type ScanCodeResult, type SchemaVersion, type SemVer, type ShareOptions, type ShareResult, type SigninActivityRule, type SigninRecord, type SigninRewardRecord, type SigninState, type SlotCategory, type SlotDeclaration, type StateFieldDefinition, type StorageApi, type StorageOptions, type StyleConfig, type StyleIsolation, type TimeWindowRolloutConfig, type ToastOptions, type TrackEvent, type URLString, UTILITY_FUNCTIONS, type UniqueId, type UpsertRolloutRequest, type UserActivityState, type UserContext, VERSION, type ValidationRule, VersionStatus, type WhitelistRolloutConfig, bindingRef, literal, queryRef, stateRef, template };
4255
+ export { type ABTestRolloutConfig, ACTION_SPEC_VERSION, ALLOWED_FUNCTION_NAMES, ALL_BUILTIN_FUNCTIONS, ARRAY_FUNCTIONS, type ActionClientContext, type ActionDefinition, type ActionDefinitionVersion, type ActionExecuteRequest, type ActionExecuteResponse, type ActionExecutor, type ActionPolicy, type ActionRef, type ActionResult, type ActionSheetItem, type ActionSheetOptions, type ActionSheetResult, type ActionSpec, ActionType, type Activity, type ActivityPrecondition, type ActivityRule, type ActivityStatus, type ActivityType, type AggregationDataSourceConfig, type AggregationQueryItem, type AnyValueOrExpression, type ApiErrorDetail, type ApiErrorResponse, type ApiResponse, type ApiSuccessResponse, type AppContext, AuditAction, type AuditConfig, type AuditLogEntry, type BackgroundConfig, type BaseActivityRule, type BlacklistRolloutConfig, type BlockedComponentInfo, type BrowserCompat, type BuiltinActionType, COMPONENT_META_SCHEMA_VERSION, CURRENT_ACTION_SPEC_VERSION, CURRENT_COMPONENT_META_VERSION, CURRENT_DATA_QUERY_SPEC_VERSION, CURRENT_SCHEMA_VERSION, type CacheConfig, type CacheLevel, type CanaryHealthCheck, type CanaryRolloutConfig, type CanaryStage, type CanvasType, type CapabilityDeclaration, type CapabilityName, type ChangeLog, type ChangeLogItem, type ClaimActivityRule, type ClaimPrize, type ClaimRecord, type ClaimState, type ClipboardApi, type CompatInfo, type Component, type ComponentCategory, type ComponentContext, type ComponentDependency, type ComponentIntegrity, type ComponentMeta, type ComponentNode, type ComponentQueryParams, type ComponentRegisterRequest, type ComponentStatus, type ComponentStatusChangeRequest, type ComponentVersion, type ConfirmOptions, type ConsecutiveReward, type CreateManifestRequest, type CumulativeReward, DATA_QUERY_SPEC_VERSION, DATE_FUNCTIONS, DEFAULT_EXPRESSION_VALIDATION_CONFIG, type DataBinding, type DataBindingErrorConfig, type DataLoadStrategy, type DataQueryDefinition, type DataQueryDefinitionVersion, type DataQueryRequest, type DataQueryResponse, type DataQuerySpec, type DataSourceConfig, type DataSourceType, type DatabaseDataSourceConfig, type DialogOptions, type DialogResult, type DjvlcError, type EditorComponent, type Environment, ErrorCategory, ErrorCode, ErrorCodeToHttpStatus, type ErrorMapping, ErrorMessages, type EventDeclaration, type EventHandler, type ExecutorContext, type ExecutorResult, type Expression, type ExpressionFunctionCategory, type ExpressionFunctionDefinition, type ExpressionType, type ExpressionValidationConfig, type ExpressionValidationError, type ExpressionValidationResult, type ExpressionValidationWarning, FORMAT_FUNCTIONS, type FallbackCondition, type FallbackConfig, type FeatureCondition, type FeatureRolloutConfig, type FieldPermission, type FieldPolicy, type FieldTransform, type FileIntegrity, type FunctionParamDefinition, type GraphQLDataSourceConfig, type HostApi, type HttpDataSourceConfig, type HttpRetryConfig, type I18nDetectionStrategy, type ISODateTime, type IdempotencyKeyStrategy, type IdempotencyRule, type IntegrityHash, type InternalDataSourceConfig, type InventoryConfig, type JsonObject, type JsonValue, LOGIC_FUNCTIONS, type LayoutConfig, type LayoutValues, type LoopConfig, type LotteryActivityRule, type LotteryCost, type LotteryPrize, type LotteryState, type Manifest, type ManifestEntry, type ManifestItem, type ManifestValidationError, type ManifestValidationResult, type ManifestValidationWarning, type MaskingConfig, type MaskingRule, type MaskingType, type MethodCategory, type MethodDeclaration, type MethodParam, NUMBER_FUNCTIONS, type NavigateOptions, type NodeStyleConfig, type OperatorInfo, type OrderByItem, PAGE_SCHEMA_VERSION, PROTOCOL_VERSION, type PageConfig, type PageDraft, type PageI18nConfig, type PageLifecycle, type PageManifest, type PageMeta, type PageResolveResponse, type PageSEO, type PageSchema, type PageState, PageStatus, type PageStatusType, type PageVersion, type PaginatedResponse, type PaginationMeta, type PaginationParams, type ParamPermission, type ParticipationLimit, type PercentageRolloutConfig, type PityConfig, type Precondition, type PreconditionType, type PreviewImageOptions, type ProbabilityConfig, type PropDefinition, type PropFormat, type PropGroup, type PropType, type PropValue, type PropsSchema, type PublishCdnConfig, PublishChannel, type PublishConfig, type PublishEnvironment, type PublishNotificationConfig, type PublishRecord, type PublishRolloutConfig, PublishStatus, type QueryPermissions, type RateLimitDimension, type RateLimitItem, type RateLimitRule, type RequestContext, type ResolvedManifest, type ResponsiveBreakpoints, type RetryPolicy, type RiskControlConfig, type RolloutConfig, type RolloutMatchRequest, type RolloutMatchResult, type RolloutStrategy, type RolloutStrategyConfig, type RolloutStrategyType, type RuntimeConfig, type RuntimeContext, type RuntimeSpec, type SHAIntegrity, STRING_FUNCTIONS, type ScanCodeResult, type SchemaVersion, type SemVer, type ShareOptions, type ShareResult, type SigninActivityRule, type SigninRecord, type SigninRewardRecord, type SigninState, type SlotCategory, type SlotDeclaration, type StateFieldDefinition, type StorageApi, type StorageOptions, type StyleConfig, type StyleIsolation, type TimeWindowRolloutConfig, type ToastOptions, type TrackEvent, type URLString, UTILITY_FUNCTIONS, type UniqueId, type UpsertRolloutRequest, type UserActivityState, type UserContext, VERSION, type ValidationRule, type VersionDiff, type VersionInfo, VersionStatus, type VersionStatusType, type WhitelistRolloutConfig, bindingRef, createDjvlcError, isDjvlcError, literal, queryRef, stateRef, template };
package/dist/index.js CHANGED
@@ -111,6 +111,73 @@ var ErrorCodeToHttpStatus = {
111
111
  ["PUBLISH_VALIDATION_FAILED" /* PUBLISH_VALIDATION_FAILED */]: 400,
112
112
  ["PUBLISH_ROLLBACK_FAILED" /* PUBLISH_ROLLBACK_FAILED */]: 500
113
113
  };
114
+ var ErrorMessages = {
115
+ // 系统错误
116
+ ["SYSTEM_INTERNAL_ERROR" /* SYSTEM_INTERNAL_ERROR */]: "\u7CFB\u7EDF\u5185\u90E8\u9519\u8BEF",
117
+ ["SYSTEM_SERVICE_UNAVAILABLE" /* SYSTEM_SERVICE_UNAVAILABLE */]: "\u670D\u52A1\u6682\u65F6\u4E0D\u53EF\u7528",
118
+ ["SYSTEM_TIMEOUT" /* SYSTEM_TIMEOUT */]: "\u8BF7\u6C42\u8D85\u65F6",
119
+ ["SYSTEM_DATABASE_ERROR" /* SYSTEM_DATABASE_ERROR */]: "\u6570\u636E\u5E93\u9519\u8BEF",
120
+ ["SYSTEM_REDIS_ERROR" /* SYSTEM_REDIS_ERROR */]: "\u7F13\u5B58\u670D\u52A1\u9519\u8BEF",
121
+ // 认证错误
122
+ ["AUTH_TOKEN_MISSING" /* AUTH_TOKEN_MISSING */]: "\u7F3A\u5C11\u8BA4\u8BC1\u4EE4\u724C",
123
+ ["AUTH_TOKEN_INVALID" /* AUTH_TOKEN_INVALID */]: "\u8BA4\u8BC1\u4EE4\u724C\u65E0\u6548",
124
+ ["AUTH_TOKEN_EXPIRED" /* AUTH_TOKEN_EXPIRED */]: "\u8BA4\u8BC1\u4EE4\u724C\u5DF2\u8FC7\u671F",
125
+ ["AUTH_SIGNATURE_INVALID" /* AUTH_SIGNATURE_INVALID */]: "\u7B7E\u540D\u65E0\u6548",
126
+ ["AUTH_SESSION_EXPIRED" /* AUTH_SESSION_EXPIRED */]: "\u4F1A\u8BDD\u5DF2\u8FC7\u671F",
127
+ // 权限错误
128
+ ["PERMISSION_DENIED" /* PERMISSION_DENIED */]: "\u6743\u9650\u4E0D\u8DB3",
129
+ ["PERMISSION_RESOURCE_FORBIDDEN" /* PERMISSION_RESOURCE_FORBIDDEN */]: "\u65E0\u6743\u8BBF\u95EE\u8BE5\u8D44\u6E90",
130
+ ["PERMISSION_ACTION_FORBIDDEN" /* PERMISSION_ACTION_FORBIDDEN */]: "\u65E0\u6743\u6267\u884C\u8BE5\u64CD\u4F5C",
131
+ // 资源错误
132
+ ["RESOURCE_NOT_FOUND" /* RESOURCE_NOT_FOUND */]: "\u8D44\u6E90\u4E0D\u5B58\u5728",
133
+ ["RESOURCE_PAGE_NOT_FOUND" /* RESOURCE_PAGE_NOT_FOUND */]: "\u9875\u9762\u4E0D\u5B58\u5728",
134
+ ["RESOURCE_COMPONENT_NOT_FOUND" /* RESOURCE_COMPONENT_NOT_FOUND */]: "\u7EC4\u4EF6\u4E0D\u5B58\u5728",
135
+ ["RESOURCE_ACTION_NOT_FOUND" /* RESOURCE_ACTION_NOT_FOUND */]: "\u52A8\u4F5C\u4E0D\u5B58\u5728",
136
+ ["RESOURCE_VERSION_NOT_FOUND" /* RESOURCE_VERSION_NOT_FOUND */]: "\u7248\u672C\u4E0D\u5B58\u5728",
137
+ // 参数错误
138
+ ["VALIDATION_INVALID_PARAMS" /* VALIDATION_INVALID_PARAMS */]: "\u53C2\u6570\u65E0\u6548",
139
+ ["VALIDATION_SCHEMA_MISMATCH" /* VALIDATION_SCHEMA_MISMATCH */]: "Schema \u4E0D\u5339\u914D",
140
+ ["VALIDATION_EXPRESSION_ERROR" /* VALIDATION_EXPRESSION_ERROR */]: "\u8868\u8FBE\u5F0F\u9519\u8BEF",
141
+ ["VALIDATION_FIELD_REQUIRED" /* VALIDATION_FIELD_REQUIRED */]: "\u5FC5\u586B\u5B57\u6BB5\u7F3A\u5931",
142
+ ["VALIDATION_FIELD_TYPE_ERROR" /* VALIDATION_FIELD_TYPE_ERROR */]: "\u5B57\u6BB5\u7C7B\u578B\u9519\u8BEF",
143
+ // 业务错误
144
+ ["BUSINESS_ACTIVITY_NOT_STARTED" /* BUSINESS_ACTIVITY_NOT_STARTED */]: "\u6D3B\u52A8\u672A\u5F00\u59CB",
145
+ ["BUSINESS_ACTIVITY_ENDED" /* BUSINESS_ACTIVITY_ENDED */]: "\u6D3B\u52A8\u5DF2\u7ED3\u675F",
146
+ ["BUSINESS_ALREADY_CLAIMED" /* BUSINESS_ALREADY_CLAIMED */]: "\u5DF2\u7ECF\u9886\u53D6\u8FC7",
147
+ ["BUSINESS_ALREADY_SIGNED" /* BUSINESS_ALREADY_SIGNED */]: "\u4ECA\u65E5\u5DF2\u7B7E\u5230",
148
+ ["BUSINESS_STOCK_EXHAUSTED" /* BUSINESS_STOCK_EXHAUSTED */]: "\u5E93\u5B58\u4E0D\u8DB3",
149
+ ["BUSINESS_QUOTA_EXCEEDED" /* BUSINESS_QUOTA_EXCEEDED */]: "\u8D85\u51FA\u914D\u989D\u9650\u5236",
150
+ ["BUSINESS_PREREQUISITE_NOT_MET" /* BUSINESS_PREREQUISITE_NOT_MET */]: "\u524D\u7F6E\u6761\u4EF6\u672A\u6EE1\u8DB3",
151
+ // 风控错误
152
+ ["RISK_RATE_LIMITED" /* RISK_RATE_LIMITED */]: "\u8BF7\u6C42\u8FC7\u4E8E\u9891\u7E41",
153
+ ["RISK_BLOCKED" /* RISK_BLOCKED */]: "\u8BF7\u6C42\u88AB\u963B\u65AD",
154
+ ["RISK_CAPTCHA_REQUIRED" /* RISK_CAPTCHA_REQUIRED */]: "\u9700\u8981\u9A8C\u8BC1\u7801\u9A8C\u8BC1",
155
+ ["RISK_DEVICE_ABNORMAL" /* RISK_DEVICE_ABNORMAL */]: "\u8BBE\u5907\u5F02\u5E38",
156
+ ["RISK_IDEMPOTENCY_CONFLICT" /* RISK_IDEMPOTENCY_CONFLICT */]: "\u91CD\u590D\u8BF7\u6C42",
157
+ // 组件错误
158
+ ["COMPONENT_LOAD_FAILED" /* COMPONENT_LOAD_FAILED */]: "\u7EC4\u4EF6\u52A0\u8F7D\u5931\u8D25",
159
+ ["COMPONENT_INTEGRITY_MISMATCH" /* COMPONENT_INTEGRITY_MISMATCH */]: "\u7EC4\u4EF6\u5B8C\u6574\u6027\u6821\u9A8C\u5931\u8D25",
160
+ ["COMPONENT_BLOCKED" /* COMPONENT_BLOCKED */]: "\u7EC4\u4EF6\u5DF2\u88AB\u963B\u65AD",
161
+ ["COMPONENT_DEPRECATED" /* COMPONENT_DEPRECATED */]: "\u7EC4\u4EF6\u5DF2\u5E9F\u5F03",
162
+ ["COMPONENT_INCOMPATIBLE" /* COMPONENT_INCOMPATIBLE */]: "\u7EC4\u4EF6\u7248\u672C\u4E0D\u517C\u5BB9",
163
+ // 发布错误
164
+ ["PUBLISH_VERSION_CONFLICT" /* PUBLISH_VERSION_CONFLICT */]: "\u7248\u672C\u51B2\u7A81",
165
+ ["PUBLISH_VALIDATION_FAILED" /* PUBLISH_VALIDATION_FAILED */]: "\u53D1\u5E03\u6821\u9A8C\u5931\u8D25",
166
+ ["PUBLISH_ROLLBACK_FAILED" /* PUBLISH_ROLLBACK_FAILED */]: "\u56DE\u6EDA\u5931\u8D25"
167
+ };
168
+ function createDjvlcError(code, message, details) {
169
+ const errorMessage = message || ErrorMessages[code] || "\u672A\u77E5\u9519\u8BEF";
170
+ const httpStatus = ErrorCodeToHttpStatus[code] || 500;
171
+ const error = new Error(errorMessage);
172
+ error.name = "DjvlcError";
173
+ error.code = code;
174
+ error.httpStatus = httpStatus;
175
+ error.details = details;
176
+ return error;
177
+ }
178
+ function isDjvlcError(error) {
179
+ return error instanceof Error && "code" in error && "httpStatus" in error && error.name === "DjvlcError";
180
+ }
114
181
 
115
182
  // src/common/status.ts
116
183
  var VersionStatus = /* @__PURE__ */ ((VersionStatus2) => {
@@ -120,6 +187,12 @@ var VersionStatus = /* @__PURE__ */ ((VersionStatus2) => {
120
187
  VersionStatus2["BLOCKED"] = "blocked";
121
188
  return VersionStatus2;
122
189
  })(VersionStatus || {});
190
+ var PageStatus = /* @__PURE__ */ ((PageStatus2) => {
191
+ PageStatus2["DRAFT"] = "draft";
192
+ PageStatus2["PUBLISHED"] = "published";
193
+ PageStatus2["ARCHIVED"] = "archived";
194
+ return PageStatus2;
195
+ })(PageStatus || {});
123
196
  var PublishChannel = /* @__PURE__ */ ((PublishChannel2) => {
124
197
  PublishChannel2["PREVIEW"] = "preview";
125
198
  PublishChannel2["GRAY"] = "gray";
@@ -993,27 +1066,37 @@ var CURRENT_ACTION_SPEC_VERSION = "2.0.0";
993
1066
  var CURRENT_DATA_QUERY_SPEC_VERSION = "2.0.0";
994
1067
 
995
1068
  // src/index.ts
996
- var VERSION = "2.0.0";
1069
+ var VERSION = "2.1.0";
997
1070
  var PROTOCOL_VERSION = "2.0.0";
1071
+ var PAGE_SCHEMA_VERSION = "2.0.0";
1072
+ var COMPONENT_META_SCHEMA_VERSION = "2.0.0";
1073
+ var ACTION_SPEC_VERSION = "2.0.0";
1074
+ var DATA_QUERY_SPEC_VERSION = "2.0.0";
998
1075
 
1076
+ exports.ACTION_SPEC_VERSION = ACTION_SPEC_VERSION;
999
1077
  exports.ALLOWED_FUNCTION_NAMES = ALLOWED_FUNCTION_NAMES;
1000
1078
  exports.ALL_BUILTIN_FUNCTIONS = ALL_BUILTIN_FUNCTIONS;
1001
1079
  exports.ARRAY_FUNCTIONS = ARRAY_FUNCTIONS;
1002
1080
  exports.ActionType = ActionType;
1003
1081
  exports.AuditAction = AuditAction;
1082
+ exports.COMPONENT_META_SCHEMA_VERSION = COMPONENT_META_SCHEMA_VERSION;
1004
1083
  exports.CURRENT_ACTION_SPEC_VERSION = CURRENT_ACTION_SPEC_VERSION;
1005
1084
  exports.CURRENT_COMPONENT_META_VERSION = CURRENT_COMPONENT_META_VERSION;
1006
1085
  exports.CURRENT_DATA_QUERY_SPEC_VERSION = CURRENT_DATA_QUERY_SPEC_VERSION;
1007
1086
  exports.CURRENT_SCHEMA_VERSION = CURRENT_SCHEMA_VERSION;
1087
+ exports.DATA_QUERY_SPEC_VERSION = DATA_QUERY_SPEC_VERSION;
1008
1088
  exports.DATE_FUNCTIONS = DATE_FUNCTIONS;
1009
1089
  exports.DEFAULT_EXPRESSION_VALIDATION_CONFIG = DEFAULT_EXPRESSION_VALIDATION_CONFIG;
1010
1090
  exports.ErrorCategory = ErrorCategory;
1011
1091
  exports.ErrorCode = ErrorCode;
1012
1092
  exports.ErrorCodeToHttpStatus = ErrorCodeToHttpStatus;
1093
+ exports.ErrorMessages = ErrorMessages;
1013
1094
  exports.FORMAT_FUNCTIONS = FORMAT_FUNCTIONS;
1014
1095
  exports.LOGIC_FUNCTIONS = LOGIC_FUNCTIONS;
1015
1096
  exports.NUMBER_FUNCTIONS = NUMBER_FUNCTIONS;
1097
+ exports.PAGE_SCHEMA_VERSION = PAGE_SCHEMA_VERSION;
1016
1098
  exports.PROTOCOL_VERSION = PROTOCOL_VERSION;
1099
+ exports.PageStatus = PageStatus;
1017
1100
  exports.PublishChannel = PublishChannel;
1018
1101
  exports.PublishStatus = PublishStatus;
1019
1102
  exports.STRING_FUNCTIONS = STRING_FUNCTIONS;
@@ -1021,6 +1104,8 @@ exports.UTILITY_FUNCTIONS = UTILITY_FUNCTIONS;
1021
1104
  exports.VERSION = VERSION;
1022
1105
  exports.VersionStatus = VersionStatus;
1023
1106
  exports.bindingRef = bindingRef;
1107
+ exports.createDjvlcError = createDjvlcError;
1108
+ exports.isDjvlcError = isDjvlcError;
1024
1109
  exports.literal = literal;
1025
1110
  exports.queryRef = queryRef;
1026
1111
  exports.stateRef = stateRef;
package/dist/index.mjs CHANGED
@@ -109,6 +109,73 @@ var ErrorCodeToHttpStatus = {
109
109
  ["PUBLISH_VALIDATION_FAILED" /* PUBLISH_VALIDATION_FAILED */]: 400,
110
110
  ["PUBLISH_ROLLBACK_FAILED" /* PUBLISH_ROLLBACK_FAILED */]: 500
111
111
  };
112
+ var ErrorMessages = {
113
+ // 系统错误
114
+ ["SYSTEM_INTERNAL_ERROR" /* SYSTEM_INTERNAL_ERROR */]: "\u7CFB\u7EDF\u5185\u90E8\u9519\u8BEF",
115
+ ["SYSTEM_SERVICE_UNAVAILABLE" /* SYSTEM_SERVICE_UNAVAILABLE */]: "\u670D\u52A1\u6682\u65F6\u4E0D\u53EF\u7528",
116
+ ["SYSTEM_TIMEOUT" /* SYSTEM_TIMEOUT */]: "\u8BF7\u6C42\u8D85\u65F6",
117
+ ["SYSTEM_DATABASE_ERROR" /* SYSTEM_DATABASE_ERROR */]: "\u6570\u636E\u5E93\u9519\u8BEF",
118
+ ["SYSTEM_REDIS_ERROR" /* SYSTEM_REDIS_ERROR */]: "\u7F13\u5B58\u670D\u52A1\u9519\u8BEF",
119
+ // 认证错误
120
+ ["AUTH_TOKEN_MISSING" /* AUTH_TOKEN_MISSING */]: "\u7F3A\u5C11\u8BA4\u8BC1\u4EE4\u724C",
121
+ ["AUTH_TOKEN_INVALID" /* AUTH_TOKEN_INVALID */]: "\u8BA4\u8BC1\u4EE4\u724C\u65E0\u6548",
122
+ ["AUTH_TOKEN_EXPIRED" /* AUTH_TOKEN_EXPIRED */]: "\u8BA4\u8BC1\u4EE4\u724C\u5DF2\u8FC7\u671F",
123
+ ["AUTH_SIGNATURE_INVALID" /* AUTH_SIGNATURE_INVALID */]: "\u7B7E\u540D\u65E0\u6548",
124
+ ["AUTH_SESSION_EXPIRED" /* AUTH_SESSION_EXPIRED */]: "\u4F1A\u8BDD\u5DF2\u8FC7\u671F",
125
+ // 权限错误
126
+ ["PERMISSION_DENIED" /* PERMISSION_DENIED */]: "\u6743\u9650\u4E0D\u8DB3",
127
+ ["PERMISSION_RESOURCE_FORBIDDEN" /* PERMISSION_RESOURCE_FORBIDDEN */]: "\u65E0\u6743\u8BBF\u95EE\u8BE5\u8D44\u6E90",
128
+ ["PERMISSION_ACTION_FORBIDDEN" /* PERMISSION_ACTION_FORBIDDEN */]: "\u65E0\u6743\u6267\u884C\u8BE5\u64CD\u4F5C",
129
+ // 资源错误
130
+ ["RESOURCE_NOT_FOUND" /* RESOURCE_NOT_FOUND */]: "\u8D44\u6E90\u4E0D\u5B58\u5728",
131
+ ["RESOURCE_PAGE_NOT_FOUND" /* RESOURCE_PAGE_NOT_FOUND */]: "\u9875\u9762\u4E0D\u5B58\u5728",
132
+ ["RESOURCE_COMPONENT_NOT_FOUND" /* RESOURCE_COMPONENT_NOT_FOUND */]: "\u7EC4\u4EF6\u4E0D\u5B58\u5728",
133
+ ["RESOURCE_ACTION_NOT_FOUND" /* RESOURCE_ACTION_NOT_FOUND */]: "\u52A8\u4F5C\u4E0D\u5B58\u5728",
134
+ ["RESOURCE_VERSION_NOT_FOUND" /* RESOURCE_VERSION_NOT_FOUND */]: "\u7248\u672C\u4E0D\u5B58\u5728",
135
+ // 参数错误
136
+ ["VALIDATION_INVALID_PARAMS" /* VALIDATION_INVALID_PARAMS */]: "\u53C2\u6570\u65E0\u6548",
137
+ ["VALIDATION_SCHEMA_MISMATCH" /* VALIDATION_SCHEMA_MISMATCH */]: "Schema \u4E0D\u5339\u914D",
138
+ ["VALIDATION_EXPRESSION_ERROR" /* VALIDATION_EXPRESSION_ERROR */]: "\u8868\u8FBE\u5F0F\u9519\u8BEF",
139
+ ["VALIDATION_FIELD_REQUIRED" /* VALIDATION_FIELD_REQUIRED */]: "\u5FC5\u586B\u5B57\u6BB5\u7F3A\u5931",
140
+ ["VALIDATION_FIELD_TYPE_ERROR" /* VALIDATION_FIELD_TYPE_ERROR */]: "\u5B57\u6BB5\u7C7B\u578B\u9519\u8BEF",
141
+ // 业务错误
142
+ ["BUSINESS_ACTIVITY_NOT_STARTED" /* BUSINESS_ACTIVITY_NOT_STARTED */]: "\u6D3B\u52A8\u672A\u5F00\u59CB",
143
+ ["BUSINESS_ACTIVITY_ENDED" /* BUSINESS_ACTIVITY_ENDED */]: "\u6D3B\u52A8\u5DF2\u7ED3\u675F",
144
+ ["BUSINESS_ALREADY_CLAIMED" /* BUSINESS_ALREADY_CLAIMED */]: "\u5DF2\u7ECF\u9886\u53D6\u8FC7",
145
+ ["BUSINESS_ALREADY_SIGNED" /* BUSINESS_ALREADY_SIGNED */]: "\u4ECA\u65E5\u5DF2\u7B7E\u5230",
146
+ ["BUSINESS_STOCK_EXHAUSTED" /* BUSINESS_STOCK_EXHAUSTED */]: "\u5E93\u5B58\u4E0D\u8DB3",
147
+ ["BUSINESS_QUOTA_EXCEEDED" /* BUSINESS_QUOTA_EXCEEDED */]: "\u8D85\u51FA\u914D\u989D\u9650\u5236",
148
+ ["BUSINESS_PREREQUISITE_NOT_MET" /* BUSINESS_PREREQUISITE_NOT_MET */]: "\u524D\u7F6E\u6761\u4EF6\u672A\u6EE1\u8DB3",
149
+ // 风控错误
150
+ ["RISK_RATE_LIMITED" /* RISK_RATE_LIMITED */]: "\u8BF7\u6C42\u8FC7\u4E8E\u9891\u7E41",
151
+ ["RISK_BLOCKED" /* RISK_BLOCKED */]: "\u8BF7\u6C42\u88AB\u963B\u65AD",
152
+ ["RISK_CAPTCHA_REQUIRED" /* RISK_CAPTCHA_REQUIRED */]: "\u9700\u8981\u9A8C\u8BC1\u7801\u9A8C\u8BC1",
153
+ ["RISK_DEVICE_ABNORMAL" /* RISK_DEVICE_ABNORMAL */]: "\u8BBE\u5907\u5F02\u5E38",
154
+ ["RISK_IDEMPOTENCY_CONFLICT" /* RISK_IDEMPOTENCY_CONFLICT */]: "\u91CD\u590D\u8BF7\u6C42",
155
+ // 组件错误
156
+ ["COMPONENT_LOAD_FAILED" /* COMPONENT_LOAD_FAILED */]: "\u7EC4\u4EF6\u52A0\u8F7D\u5931\u8D25",
157
+ ["COMPONENT_INTEGRITY_MISMATCH" /* COMPONENT_INTEGRITY_MISMATCH */]: "\u7EC4\u4EF6\u5B8C\u6574\u6027\u6821\u9A8C\u5931\u8D25",
158
+ ["COMPONENT_BLOCKED" /* COMPONENT_BLOCKED */]: "\u7EC4\u4EF6\u5DF2\u88AB\u963B\u65AD",
159
+ ["COMPONENT_DEPRECATED" /* COMPONENT_DEPRECATED */]: "\u7EC4\u4EF6\u5DF2\u5E9F\u5F03",
160
+ ["COMPONENT_INCOMPATIBLE" /* COMPONENT_INCOMPATIBLE */]: "\u7EC4\u4EF6\u7248\u672C\u4E0D\u517C\u5BB9",
161
+ // 发布错误
162
+ ["PUBLISH_VERSION_CONFLICT" /* PUBLISH_VERSION_CONFLICT */]: "\u7248\u672C\u51B2\u7A81",
163
+ ["PUBLISH_VALIDATION_FAILED" /* PUBLISH_VALIDATION_FAILED */]: "\u53D1\u5E03\u6821\u9A8C\u5931\u8D25",
164
+ ["PUBLISH_ROLLBACK_FAILED" /* PUBLISH_ROLLBACK_FAILED */]: "\u56DE\u6EDA\u5931\u8D25"
165
+ };
166
+ function createDjvlcError(code, message, details) {
167
+ const errorMessage = message || ErrorMessages[code] || "\u672A\u77E5\u9519\u8BEF";
168
+ const httpStatus = ErrorCodeToHttpStatus[code] || 500;
169
+ const error = new Error(errorMessage);
170
+ error.name = "DjvlcError";
171
+ error.code = code;
172
+ error.httpStatus = httpStatus;
173
+ error.details = details;
174
+ return error;
175
+ }
176
+ function isDjvlcError(error) {
177
+ return error instanceof Error && "code" in error && "httpStatus" in error && error.name === "DjvlcError";
178
+ }
112
179
 
113
180
  // src/common/status.ts
114
181
  var VersionStatus = /* @__PURE__ */ ((VersionStatus2) => {
@@ -118,6 +185,12 @@ var VersionStatus = /* @__PURE__ */ ((VersionStatus2) => {
118
185
  VersionStatus2["BLOCKED"] = "blocked";
119
186
  return VersionStatus2;
120
187
  })(VersionStatus || {});
188
+ var PageStatus = /* @__PURE__ */ ((PageStatus2) => {
189
+ PageStatus2["DRAFT"] = "draft";
190
+ PageStatus2["PUBLISHED"] = "published";
191
+ PageStatus2["ARCHIVED"] = "archived";
192
+ return PageStatus2;
193
+ })(PageStatus || {});
121
194
  var PublishChannel = /* @__PURE__ */ ((PublishChannel2) => {
122
195
  PublishChannel2["PREVIEW"] = "preview";
123
196
  PublishChannel2["GRAY"] = "gray";
@@ -991,7 +1064,11 @@ var CURRENT_ACTION_SPEC_VERSION = "2.0.0";
991
1064
  var CURRENT_DATA_QUERY_SPEC_VERSION = "2.0.0";
992
1065
 
993
1066
  // src/index.ts
994
- var VERSION = "2.0.0";
1067
+ var VERSION = "2.1.0";
995
1068
  var PROTOCOL_VERSION = "2.0.0";
1069
+ var PAGE_SCHEMA_VERSION = "2.0.0";
1070
+ var COMPONENT_META_SCHEMA_VERSION = "2.0.0";
1071
+ var ACTION_SPEC_VERSION = "2.0.0";
1072
+ var DATA_QUERY_SPEC_VERSION = "2.0.0";
996
1073
 
997
- export { ALLOWED_FUNCTION_NAMES, ALL_BUILTIN_FUNCTIONS, ARRAY_FUNCTIONS, ActionType, AuditAction, CURRENT_ACTION_SPEC_VERSION, CURRENT_COMPONENT_META_VERSION, CURRENT_DATA_QUERY_SPEC_VERSION, CURRENT_SCHEMA_VERSION, DATE_FUNCTIONS, DEFAULT_EXPRESSION_VALIDATION_CONFIG, ErrorCategory, ErrorCode, ErrorCodeToHttpStatus, FORMAT_FUNCTIONS, LOGIC_FUNCTIONS, NUMBER_FUNCTIONS, PROTOCOL_VERSION, PublishChannel, PublishStatus, STRING_FUNCTIONS, UTILITY_FUNCTIONS, VERSION, VersionStatus, bindingRef, literal, queryRef, stateRef, template };
1074
+ export { ACTION_SPEC_VERSION, ALLOWED_FUNCTION_NAMES, ALL_BUILTIN_FUNCTIONS, ARRAY_FUNCTIONS, ActionType, AuditAction, COMPONENT_META_SCHEMA_VERSION, CURRENT_ACTION_SPEC_VERSION, CURRENT_COMPONENT_META_VERSION, CURRENT_DATA_QUERY_SPEC_VERSION, CURRENT_SCHEMA_VERSION, DATA_QUERY_SPEC_VERSION, DATE_FUNCTIONS, DEFAULT_EXPRESSION_VALIDATION_CONFIG, ErrorCategory, ErrorCode, ErrorCodeToHttpStatus, ErrorMessages, FORMAT_FUNCTIONS, LOGIC_FUNCTIONS, NUMBER_FUNCTIONS, PAGE_SCHEMA_VERSION, PROTOCOL_VERSION, PageStatus, PublishChannel, PublishStatus, STRING_FUNCTIONS, UTILITY_FUNCTIONS, VERSION, VersionStatus, bindingRef, createDjvlcError, isDjvlcError, literal, queryRef, stateRef, template };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@djvlc/contracts-types",
3
- "version": "1.6.0",
3
+ "version": "1.7.0",
4
4
  "description": "DJV Low-code Platform - TypeScript 类型定义包",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.mjs",