@djvlc/contracts-types 1.3.0 → 1.5.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
@@ -223,6 +223,246 @@ type GenericStatus = 'active' | 'inactive' | 'pending' | 'archived';
223
223
  * 审计状态
224
224
  */
225
225
  type AuditStatus = 'pending' | 'approved' | 'rejected';
226
+ /**
227
+ * 基础上下文(所有场景共用)
228
+ * ActionContext/DataQueryContext/RuntimeContext 继承此接口
229
+ */
230
+ interface BaseContext {
231
+ /** 页面版本 ID */
232
+ pageVersionId?: string;
233
+ /** 用户 ID */
234
+ uid?: string;
235
+ /** 设备 ID */
236
+ deviceId?: string;
237
+ /** 渠道 */
238
+ channel?: string;
239
+ /** 追踪 ID */
240
+ traceId?: string;
241
+ }
242
+ /**
243
+ * 灰度规则类型
244
+ */
245
+ type RolloutRuleType = 'user' | 'ip' | 'device' | 'header' | 'cookie' | 'percentage' | 'custom';
246
+ /**
247
+ * 灰度规则
248
+ */
249
+ interface RolloutRule {
250
+ /** 规则 ID */
251
+ id: string;
252
+ /** 规则名称 */
253
+ name: string;
254
+ /** 规则类型 */
255
+ type: RolloutRuleType;
256
+ /** 匹配条件/值 */
257
+ value: string | number | string[];
258
+ /** 是否启用 */
259
+ enabled: boolean;
260
+ /** 优先级(数字越小优先级越高) */
261
+ priority?: number;
262
+ }
263
+ /**
264
+ * 灰度配置(统一版本)
265
+ * 用于页面发布灰度、功能开关等场景
266
+ */
267
+ interface RolloutConfig {
268
+ /** 是否启用灰度 */
269
+ enabled: boolean;
270
+ /** 灰度百分比 (0-100),与规则并行生效 */
271
+ percentage?: number;
272
+ /** 白名单用户 UID */
273
+ whitelistUsers?: string[];
274
+ /** 黑名单用户 UID */
275
+ blacklistUsers?: string[];
276
+ /** 白名单 IP */
277
+ whitelistIps?: string[];
278
+ /** 黑名单 IP */
279
+ blacklistIps?: string[];
280
+ /** 自定义规则 */
281
+ rules?: RolloutRule[];
282
+ /** 开始时间 */
283
+ startAt?: string;
284
+ /** 结束时间 */
285
+ endAt?: string;
286
+ }
287
+ /**
288
+ * Kill-Switch 配置项
289
+ */
290
+ interface KillSwitchConfig {
291
+ /** 开关 ID */
292
+ id: string;
293
+ /** 开关名称 */
294
+ name: string;
295
+ /** 目标类型 */
296
+ targetType: 'action' | 'component' | 'feature' | 'page';
297
+ /** 目标标识(actionType / componentName / featureKey / pageUid) */
298
+ targetId: string;
299
+ /** 是否启用 */
300
+ enabled: boolean;
301
+ /** 原因 */
302
+ reason: string;
303
+ /** 启用时间 */
304
+ enabledAt?: string;
305
+ /** 启用者 */
306
+ enabledBy?: string;
307
+ /** 影响范围(可选:特定租户/全局) */
308
+ scope?: 'global' | 'tenant';
309
+ /** 租户 ID(scope 为 tenant 时) */
310
+ tenantId?: string;
311
+ }
312
+ /**
313
+ * 租户配置
314
+ */
315
+ interface TenantConfig {
316
+ /** 租户 ID */
317
+ tenantId: string;
318
+ /** 租户名称 */
319
+ name: string;
320
+ /** 租户状态 */
321
+ status: 'active' | 'suspended' | 'deleted';
322
+ /** 域名列表 */
323
+ domains?: string[];
324
+ /** API Key */
325
+ apiKey?: string;
326
+ /** 功能开关 */
327
+ features?: Record<string, boolean>;
328
+ /** 配额限制 */
329
+ quotas?: TenantQuotas;
330
+ /** 创建时间 */
331
+ createdAt: string;
332
+ }
333
+ /**
334
+ * 租户配额
335
+ */
336
+ interface TenantQuotas {
337
+ /** 最大页面数 */
338
+ maxPages?: number;
339
+ /** 最大组件数 */
340
+ maxComponents?: number;
341
+ /** 最大活动数 */
342
+ maxActivities?: number;
343
+ /** API 请求限制(每分钟) */
344
+ apiRateLimit?: number;
345
+ }
346
+ /**
347
+ * App 配置
348
+ */
349
+ interface AppConfig {
350
+ /** App ID */
351
+ appId: string;
352
+ /** App 名称 */
353
+ name: string;
354
+ /** App Key */
355
+ appKey: string;
356
+ /** 所属租户 */
357
+ tenantId: string;
358
+ /** App 状态 */
359
+ status: 'active' | 'inactive';
360
+ /** 运行时版本要求 */
361
+ runtimeVersion?: string;
362
+ /** CDN 域名 */
363
+ cdnDomain?: string;
364
+ /** 环境 */
365
+ environment: 'development' | 'staging' | 'production';
366
+ /** 创建时间 */
367
+ createdAt: string;
368
+ }
369
+ /**
370
+ * 预览 Token
371
+ */
372
+ interface PreviewToken {
373
+ /** Token 值 */
374
+ token: string;
375
+ /** 页面 UID */
376
+ pageUid: string;
377
+ /** 页面版本 ID */
378
+ pageVersionId: string;
379
+ /** 创建者 */
380
+ createdBy: string;
381
+ /** 过期时间 */
382
+ expiresAt: string;
383
+ /** 创建时间 */
384
+ createdAt: string;
385
+ /** 是否已使用 */
386
+ used?: boolean;
387
+ }
388
+ /**
389
+ * 预览 Token 创建请求
390
+ */
391
+ interface CreatePreviewTokenRequest {
392
+ /** 页面 UID */
393
+ pageUid: string;
394
+ /** 页面版本 ID(可选,默认使用草稿) */
395
+ pageVersionId?: string;
396
+ /** 有效期(秒),默认 3600 */
397
+ ttl?: number;
398
+ }
399
+ /**
400
+ * Bootstrap 配置
401
+ * 页面静态导出产物之一,用于运行时初始化
402
+ */
403
+ interface BootstrapConfig {
404
+ /** 版本 */
405
+ version: string;
406
+ /** 页面 UID */
407
+ pageUid: string;
408
+ /** 页面版本 ID */
409
+ pageVersionId: string;
410
+ /** 运行时版本 */
411
+ runtimeVersion: string;
412
+ /** 运行时入口 URL */
413
+ runtimeEntryUrl: string;
414
+ /** 页面 JSON URL */
415
+ pageJsonUrl: string;
416
+ /** Manifest URL */
417
+ manifestUrl: string;
418
+ /** CDN 基础路径 */
419
+ cdnBaseUrl: string;
420
+ /** API 基础路径 */
421
+ apiBaseUrl: string;
422
+ /** 功能开关 */
423
+ features?: Record<string, boolean>;
424
+ /** 生成时间 */
425
+ generatedAt: string;
426
+ }
427
+ /**
428
+ * 变更类型
429
+ */
430
+ type ChangeType = 'create' | 'update' | 'delete' | 'publish' | 'rollback' | 'status_change' | 'config_change';
431
+ /**
432
+ * 字段变更记录
433
+ */
434
+ interface FieldChange {
435
+ /** 字段路径 */
436
+ path: string;
437
+ /** 旧值 */
438
+ oldValue: unknown;
439
+ /** 新值 */
440
+ newValue: unknown;
441
+ /** 变更类型 */
442
+ changeType: 'added' | 'modified' | 'removed';
443
+ }
444
+ /**
445
+ * 变更摘要(统一版本)
446
+ * 用于审计日志、版本对比、操作记录等场景
447
+ */
448
+ interface ChangeSummary {
449
+ /** 变更类型 */
450
+ type: ChangeType;
451
+ /** 变更前快照(关键字段) */
452
+ before?: Record<string, unknown>;
453
+ /** 变更后快照(关键字段) */
454
+ after?: Record<string, unknown>;
455
+ /** 变更字段列表(简单版本) */
456
+ changedFields?: string[];
457
+ /** 变更字段详情(详细版本) */
458
+ fieldChanges?: FieldChange[];
459
+ /** 变更数量(批量操作) */
460
+ affectedCount?: number;
461
+ /** 人类可读的变更描述 */
462
+ description?: string;
463
+ }
464
+ /** @deprecated 使用 ChangeSummary 替代 */
465
+ type ChangeRecord = ChangeSummary;
226
466
  /**
227
467
  * 深度只读类型
228
468
  */
@@ -424,32 +664,7 @@ interface EventAction {
424
664
  enabled?: boolean;
425
665
  delay?: number;
426
666
  }
427
- /**
428
- * 灰度规则
429
- */
430
- interface GrayRule {
431
- /** 规则名称 */
432
- name: string;
433
- /** 规则类型 */
434
- type: 'user' | 'ip' | 'header' | 'cookie' | 'custom';
435
- /** 匹配条件 */
436
- condition: string;
437
- /** 是否启用 */
438
- enabled: boolean;
439
- }
440
- /**
441
- * 灰度发布配置
442
- */
443
- interface GrayPublishConfig {
444
- /** 灰度比例 (0-100) */
445
- percentage?: number;
446
- /** 白名单用户 UID */
447
- whitelistUsers?: string[];
448
- /** 白名单 IP */
449
- whitelistIps?: string[];
450
- /** 自定义规则 */
451
- rules?: GrayRule[];
452
- }
667
+
453
668
  /**
454
669
  * 发布配置
455
670
  */
@@ -459,12 +674,15 @@ interface PublishConfig {
459
674
  /** 发布描述 */
460
675
  description?: string;
461
676
  /** 灰度配置(仅 gray 渠道) */
462
- grayConfig?: GrayPublishConfig;
677
+ rolloutConfig?: RolloutConfig;
463
678
  /** 是否自动发布(跳过审核) */
464
679
  autoPublish?: boolean;
465
680
  /** 定时发布时间 */
466
681
  scheduledAt?: string;
467
682
  }
683
+ /** @deprecated 使用 RolloutConfig 替代 */
684
+ type GrayPublishConfig = RolloutConfig;
685
+
468
686
  /**
469
687
  * 版本信息
470
688
  */
@@ -505,290 +723,81 @@ interface ChangeLogItem {
505
723
  type ChangeLog = Record<string, ChangeLogItem>;
506
724
 
507
725
  /**
508
- * 组件 Meta Schema 类型定义
509
- * 定义每个组件版本必须包含的元数据
726
+ * Action 规范类型定义
727
+ * 用于 Action Gateway 的动作执行
510
728
  */
511
- /** JSON Schema 类型定义 */
512
- interface JsonSchema {
513
- type: 'string' | 'number' | 'boolean' | 'object' | 'array' | 'null';
514
- title?: string;
515
- description?: string;
516
- default?: unknown;
517
- enum?: unknown[];
518
- properties?: Record<string, JsonSchema>;
519
- items?: JsonSchema;
520
- required?: string[];
521
- minimum?: number;
522
- maximum?: number;
523
- minLength?: number;
524
- maxLength?: number;
525
- pattern?: string;
526
- format?: string;
527
- $ref?: string;
729
+ /** 内置动作类型 */
730
+ type BuiltinActionType = 'claim' | 'signin' | 'lottery' | 'reserve' | 'share' | 'navigate' | 'track' | 'custom';
731
+ /** 动作执行请求 */
732
+ interface ActionExecuteRequest {
733
+ /** 动作类型 */
734
+ actionType: string;
735
+ /** 动作参数 */
736
+ params: Record<string, unknown>;
737
+ /** 上下文 */
738
+ context: ActionContext;
739
+ /** 幂等键 */
740
+ idempotencyKey?: string;
528
741
  }
529
- /** Props Schema - 组件属性定义 */
530
- interface PropsSchema {
531
- $schema?: string;
532
- type: 'object';
533
- title: string;
534
- description?: string;
535
- properties: Record<string, JsonSchema & {
536
- /** 属性分组 */
537
- group?: string;
538
- /** 编辑器中的控件类型 */
539
- 'x-editor-widget'?: string;
540
- /** 是否支持表达式绑定 */
541
- 'x-expression-enabled'?: boolean;
542
- }>;
543
- required?: string[];
742
+
743
+ /** 动作上下文(扩展自 BaseContext) */
744
+ interface ActionContext extends BaseContext {
745
+ /** 组件版本 */
746
+ componentVersion?: string;
747
+ /** 组件 ID */
748
+ componentId?: string;
749
+ /** 动作 ID */
750
+ actionId?: string;
751
+ /** 扩展数据 */
752
+ extra?: Record<string, unknown>;
544
753
  }
545
- /** 事件定义 */
546
- interface EventDefinition {
547
- /** 事件名称 */
754
+ /** 动作执行响应 */
755
+ interface ActionExecuteResponse<T = unknown> {
756
+ /** 是否成功 */
757
+ success: boolean;
758
+ /** 响应数据 */
759
+ data?: T;
760
+ /** 错误码 */
761
+ code?: number;
762
+ /** 错误信息 */
763
+ message?: string;
764
+ /** 追踪 ID */
765
+ traceId?: string;
766
+ }
767
+ /** 动作定义状态 */
768
+ type ActionDefinitionStatus = 'active' | 'deprecated' | 'disabled';
769
+ /** 动作定义 */
770
+ interface ActionDefinition {
771
+ /** 动作 ID */
772
+ id: string;
773
+ /** 动作名称 */
548
774
  name: string;
549
- /** 事件显示名 */
550
- label: string;
551
- /** 事件描述 */
775
+ /** 动作类型 */
776
+ actionType: string;
777
+ /** 描述 */
552
778
  description?: string;
553
- /** 事件参数 Schema */
554
- payload?: JsonSchema;
555
- }
556
- /** 组件事件列表 */
557
- interface EventsDefinition {
558
- /** 事件版本 */
779
+ /** 参数 Schema */
780
+ paramsSchema: Record<string, unknown>;
781
+ /** 响应 Schema */
782
+ responseSchema?: Record<string, unknown>;
783
+ /** 是否需要认证 */
784
+ requiresAuth: boolean;
785
+ /** 幂等规则 */
786
+ idempotencyRule?: IdempotencyRule;
787
+ /** 频控规则 */
788
+ rateLimitRule?: RateLimitRule;
789
+ /** 版本 */
559
790
  version: string;
560
- /** 事件列表 */
561
- events: EventDefinition[];
791
+ /** 状态 */
792
+ status: ActionDefinitionStatus;
562
793
  }
563
- /** 组件能力声明 */
564
- interface CapabilitiesDefinition {
565
- /** 能力版本 */
566
- version: string;
567
- /** 是否需要用户登录态 */
568
- requiresAuth?: boolean;
569
- /** 是否需要执行 Action */
570
- requiresAction?: boolean;
571
- /** 需要的 Action 类型 */
572
- actionTypes?: string[];
573
- /** 是否需要 Data Query */
574
- requiresDataQuery?: boolean;
575
- /** 需要的 Query 类型 */
576
- queryTypes?: string[];
577
- /** 是否需要导航能力 */
578
- requiresNavigation?: boolean;
579
- /** 是否需要埋点能力 */
580
- requiresTrack?: boolean;
581
- /** 是否需要对话框能力 */
582
- requiresDialog?: boolean;
583
- /** 是否需要剪贴板能力 */
584
- requiresClipboard?: boolean;
585
- /** 自定义能力 */
586
- custom?: string[];
587
- }
588
- /** 兼容性定义 */
589
- interface CompatDefinition {
590
- /** 兼容版本 */
591
- version: string;
592
- /** 最低运行时版本 */
593
- minRuntime: string;
594
- /** 最高运行时版本(可选) */
595
- maxRuntime?: string;
596
- /** 是否有破坏性变更 */
597
- breaking?: boolean;
598
- /** 破坏性变更说明 */
599
- breakingChanges?: string[];
600
- /** 从哪个版本可以无缝升级 */
601
- upgradeFrom?: string[];
602
- }
603
- /** 组件分类 */
604
- type ComponentCategory = 'basic' | 'form' | 'layout' | 'navigation' | 'feedback' | 'display' | 'data' | 'business' | 'chart' | 'other';
605
- /** 组件分类列表(用于校验和 UI) */
606
- declare const COMPONENT_CATEGORIES: ComponentCategory[];
607
- /** SRI 完整性校验 */
608
- interface IntegrityDefinition {
609
- /** 完整性版本 */
610
- version: string;
611
- /** 主入口文件哈希 */
612
- main: string;
613
- /** 所有文件哈希 */
614
- files: Record<string, string>;
615
- /** 生成时间 */
616
- generatedAt: string;
617
- /** 哈希算法 */
618
- algorithm: 'sha256' | 'sha384' | 'sha512';
619
- }
620
- /** 组件状态 */
621
- type ComponentStatus = 'draft' | 'canary' | 'stable' | 'deprecated' | 'blocked';
622
- /** 组件版本元数据(完整) */
623
- interface ComponentMeta {
624
- /** 组件名称 */
625
- name: string;
626
- /** 组件版本 */
627
- version: string;
628
- /** 显示名称 */
629
- label: string;
630
- /** 组件描述 */
631
- description?: string;
632
- /** 组件图标 */
633
- icon?: string;
634
- /** 组件分类 */
635
- category: ComponentCategory;
636
- /** 组件标签 */
637
- tags?: string[];
638
- /** 组件作者 */
639
- author?: string;
640
- /** 属性定义 */
641
- props: PropsSchema;
642
- /** 事件定义 */
643
- events: EventsDefinition;
644
- /** 能力声明 */
645
- capabilities: CapabilitiesDefinition;
646
- /** 兼容性 */
647
- compat: CompatDefinition;
648
- /** 完整性校验 */
649
- integrity: IntegrityDefinition;
650
- /** 组件状态 */
651
- status: ComponentStatus;
652
- /** 预览图 */
653
- preview?: string;
654
- /** 入口文件(相对路径) */
655
- entry: string;
656
- /** 样式文件(相对路径) */
657
- styles?: string[];
658
- }
659
- /** Registry 中的组件版本记录 */
660
- interface ComponentVersionRecord {
661
- /** 组件 ID */
662
- componentId: string;
663
- /** 组件名称 */
664
- name: string;
665
- /** 版本号 */
666
- version: string;
667
- /** CDN 入口 URL */
668
- entryUrl: string;
669
- /** 元数据 */
670
- meta: ComponentMeta;
671
- /** 状态 */
672
- status: ComponentStatus;
673
- /** 发布时间 */
674
- publishedAt: string;
675
- /** 发布者 */
676
- publishedBy: string;
677
- /** 阻断信息(如果被阻断) */
678
- blockInfo?: {
679
- reason: string;
680
- blockedAt: string;
681
- blockedBy: string;
682
- };
683
- }
684
- /** Manifest 中的组件引用 */
685
- interface ManifestItem {
686
- /** 组件名称 */
687
- name: string;
688
- /** 组件版本 */
689
- version: string;
690
- /** 入口 URL */
691
- entryUrl: string;
692
- /** SRI 哈希 */
693
- integrity: string;
694
- /** 是否必须成功加载 */
695
- critical?: boolean;
696
- }
697
- /** 页面 Manifest */
698
- interface PageManifest {
699
- /** Manifest 版本 */
700
- manifestVersion: string;
701
- /** 内容哈希 */
702
- contentHash: string;
703
- /** 运行时版本 */
704
- runtimeVersion: string;
705
- /** 组件清单 */
706
- components: ManifestItem[];
707
- /** 生成时间 */
708
- generatedAt: string;
709
- }
710
-
711
- /**
712
- * Action 规范类型定义
713
- * 用于 Action Gateway 的动作执行
714
- */
715
- /** 内置动作类型 */
716
- type BuiltinActionType = 'claim' | 'signin' | 'lottery' | 'reserve' | 'share' | 'navigate' | 'track' | 'custom';
717
- /** 动作执行请求 */
718
- interface ActionExecuteRequest {
719
- /** 动作类型 */
720
- actionType: string;
721
- /** 动作参数 */
722
- params: Record<string, unknown>;
723
- /** 上下文 */
724
- context: ActionContext;
725
- /** 幂等键 */
726
- idempotencyKey?: string;
727
- }
728
- /** 动作上下文 */
729
- interface ActionContext {
730
- /** 页面版本 ID */
731
- pageVersionId?: string;
732
- /** 组件版本 */
733
- componentVersion?: string;
734
- /** 用户 ID */
735
- uid?: string;
736
- /** 设备 ID */
737
- deviceId?: string;
738
- /** 渠道 */
739
- channel?: string;
740
- /** 追踪 ID */
741
- traceId?: string;
742
- /** 扩展数据 */
743
- extra?: Record<string, unknown>;
744
- }
745
- /** 动作执行响应 */
746
- interface ActionExecuteResponse<T = unknown> {
747
- /** 是否成功 */
748
- success: boolean;
749
- /** 响应数据 */
750
- data?: T;
751
- /** 错误码 */
752
- code?: number;
753
- /** 错误信息 */
754
- message?: string;
755
- /** 追踪 ID */
756
- traceId?: string;
757
- }
758
- /** 动作定义状态 */
759
- type ActionDefinitionStatus = 'active' | 'deprecated' | 'disabled';
760
- /** 动作定义 */
761
- interface ActionDefinition {
762
- /** 动作 ID */
763
- id: string;
764
- /** 动作名称 */
765
- name: string;
766
- /** 动作类型 */
767
- actionType: string;
768
- /** 描述 */
769
- description?: string;
770
- /** 参数 Schema */
771
- paramsSchema: Record<string, unknown>;
772
- /** 响应 Schema */
773
- responseSchema?: Record<string, unknown>;
774
- /** 是否需要认证 */
775
- requiresAuth: boolean;
776
- /** 幂等规则 */
777
- idempotencyRule?: IdempotencyRule;
778
- /** 频控规则 */
779
- rateLimitRule?: RateLimitRule;
780
- /** 版本 */
781
- version: string;
782
- /** 状态 */
783
- status: ActionDefinitionStatus;
784
- }
785
- /** 动作定义版本(不可变) */
786
- interface ActionDefinitionVersion {
787
- /** 版本 ID */
788
- id: string;
789
- /** 所属定义 ID */
790
- definitionId: string;
791
- /** 版本号 */
794
+ /** 动作定义版本(不可变) */
795
+ interface ActionDefinitionVersion {
796
+ /** 版本 ID */
797
+ id: string;
798
+ /** 所属定义 ID */
799
+ definitionId: string;
800
+ /** 版本号 */
792
801
  version: string;
793
802
  /** 定义快照 */
794
803
  spec: ActionDefinition;
@@ -843,12 +852,17 @@ interface RiskCheckResult {
843
852
  /** 拒绝原因 */
844
853
  rejectReason?: string;
845
854
  }
846
- /** 动作审计日志 */
847
- interface ActionAuditLog {
855
+ /**
856
+ * 动作执行日志
857
+ * 记录动作执行的请求/响应详情,用于问题排查和性能分析
858
+ */
859
+ interface ActionExecutionLog {
848
860
  /** 日志 ID */
849
861
  id: string;
850
862
  /** 动作类型 */
851
863
  actionType: string;
864
+ /** 动作定义版本 ID */
865
+ actionDefVersionId?: string;
852
866
  /** 请求参数 */
853
867
  params: Record<string, unknown>;
854
868
  /** 上下文 */
@@ -866,6 +880,8 @@ interface ActionAuditLog {
866
880
  /** 创建时间 */
867
881
  createdAt: string;
868
882
  }
883
+ /** @deprecated 使用 ActionExecutionLog 替代 */
884
+ type ActionAuditLog = ActionExecutionLog;
869
885
 
870
886
  /**
871
887
  * Data Query 规范类型定义
@@ -880,14 +896,13 @@ interface DataQueryRequest {
880
896
  /** 上下文 */
881
897
  context?: DataQueryContext;
882
898
  }
883
- /** 查询上下文 */
884
- interface DataQueryContext {
885
- /** 页面版本 ID */
886
- pageVersionId?: string;
887
- /** 用户 ID */
888
- uid?: string;
889
- /** 追踪 ID */
890
- traceId?: string;
899
+
900
+ /** 查询上下文(扩展自 BaseContext) */
901
+ interface DataQueryContext extends BaseContext {
902
+ /** 来源组件 ID */
903
+ sourceComponentId?: string;
904
+ /** 来源组件类型 */
905
+ sourceComponentType?: string;
891
906
  }
892
907
  /** 数据查询响应 */
893
908
  interface DataQueryResponse<T = unknown> {
@@ -1009,8 +1024,11 @@ interface QueryPermissionConfig {
1009
1024
  /** 字段权限 */
1010
1025
  fieldPermissions?: FieldPermission[];
1011
1026
  }
1012
- /** 查询审计日志 */
1013
- interface QueryAuditLog {
1027
+ /**
1028
+ * 查询执行日志
1029
+ * 记录查询执行的请求/响应详情,用于问题排查和性能分析
1030
+ */
1031
+ interface QueryExecutionLog {
1014
1032
  /** 日志 ID */
1015
1033
  id: string;
1016
1034
  /** 查询版本 ID */
@@ -1025,6 +1043,8 @@ interface QueryAuditLog {
1025
1043
  fromCache?: boolean;
1026
1044
  /** 错误码 */
1027
1045
  code?: number;
1046
+ /** 错误信息 */
1047
+ message?: string;
1028
1048
  /** 耗时(ms) */
1029
1049
  duration: number;
1030
1050
  /** 追踪 ID */
@@ -1032,6 +1052,8 @@ interface QueryAuditLog {
1032
1052
  /** 创建时间 */
1033
1053
  createdAt: string;
1034
1054
  }
1055
+ /** @deprecated 使用 QueryExecutionLog 替代 */
1056
+ type QueryAuditLog = QueryExecutionLog;
1035
1057
 
1036
1058
  /**
1037
1059
  * HostAPI 类型定义
@@ -1186,690 +1208,3404 @@ interface HostAPI {
1186
1208
  */
1187
1209
  getContext(): RuntimeContext;
1188
1210
  }
1189
- /** 运行时上下文 */
1190
- interface RuntimeContext {
1211
+
1212
+ /** 运行时上下文(扩展自 BaseContext) */
1213
+ interface RuntimeContext extends BaseContext {
1191
1214
  /** 页面 UID */
1192
1215
  pageUid: string;
1193
- /** 页面版本 ID */
1216
+ /** 页面版本 ID(重写为必填) */
1194
1217
  pageVersionId: string;
1195
1218
  /** 运行时版本 */
1196
1219
  runtimeVersion: string;
1197
- /** 用户 ID */
1220
+ /** 用户 ID(别名,与 uid 同义) */
1198
1221
  userId?: string;
1199
- /** 设备 ID */
1200
- deviceId?: string;
1201
- /** 渠道 */
1202
- channel?: string;
1203
1222
  /** 是否编辑模式 */
1204
1223
  isEditMode: boolean;
1205
1224
  /** 是否预览模式 */
1206
1225
  isPreviewMode: boolean;
1226
+ /** 会话 ID */
1227
+ sessionId?: string;
1207
1228
  }
1208
1229
 
1209
1230
  /**
1210
- * 资源相关类型定义
1211
- * 用于管理图片、视频、文档等资源
1231
+ * Web Component 开发相关类型定义
1232
+ * 组件必须遵循这些接口规范
1212
1233
  */
1234
+
1213
1235
  /**
1214
- * 资源状态
1215
- * - active: 活跃
1216
- * - archived: 已归档
1236
+ * 组件生命周期阶段
1217
1237
  */
1218
- type AssetStatus = 'active' | 'archived';
1238
+ type ComponentLifecyclePhase = 'created' | 'connected' | 'ready' | 'updated' | 'disconnected' | 'error';
1219
1239
  /**
1220
- * 资源类型
1221
- * - image: 图片
1222
- * - video: 视频
1223
- * - audio: 音频
1224
- * - document: 文档
1225
- * - other: 其他
1240
+ * 组件生命周期回调
1226
1241
  */
1227
- type AssetType = 'image' | 'video' | 'audio' | 'document' | 'other';
1242
+ interface ComponentLifecycleCallbacks {
1243
+ /** 组件创建时调用 */
1244
+ onCreated?: () => void;
1245
+ /** 组件挂载到 DOM 时调用 */
1246
+ onConnected?: () => void;
1247
+ /** 组件首次渲染完成时调用 */
1248
+ onReady?: () => void;
1249
+ /** 组件属性更新时调用 */
1250
+ onUpdated?: (changedProps: string[]) => void;
1251
+ /** 组件从 DOM 移除时调用 */
1252
+ onDisconnected?: () => void;
1253
+ /** 组件发生错误时调用 */
1254
+ onError?: (error: Error) => void;
1255
+ }
1228
1256
  /**
1229
- * 资源排序字段
1257
+ * DJV 组件基础接口
1258
+ * 所有低代码组件必须实现此接口
1230
1259
  */
1231
- type AssetSortField = 'id' | 'createdAt' | 'size' | 'filename';
1260
+ interface DjvComponent extends HTMLElement {
1261
+ /** 组件名称 */
1262
+ readonly componentName: string;
1263
+ /** 组件版本 */
1264
+ readonly componentVersion: string;
1265
+ /** HostAPI 引用(由运行时注入) */
1266
+ hostApi?: HostAPI;
1267
+ /** 组件配置属性 */
1268
+ props: Record<string, unknown>;
1269
+ /** 组件内部状态 */
1270
+ state?: Record<string, unknown>;
1271
+ /** 组件初始化 */
1272
+ init?(): void;
1273
+ /** 组件销毁清理 */
1274
+ destroy?(): void;
1275
+ /** 属性变化回调 */
1276
+ onPropsChange?(changedProps: Record<string, {
1277
+ oldValue: unknown;
1278
+ newValue: unknown;
1279
+ }>): void;
1280
+ }
1232
1281
  /**
1233
- * 资源元数据
1282
+ * 组件构造器类型
1234
1283
  */
1235
- interface AssetMeta {
1236
- /** 原始文件名 */
1237
- originalName: string;
1238
- /** MIME 类型 */
1239
- mimeType: string;
1240
- /** 文件大小(字节) */
1241
- size: number;
1242
- /** 宽度(仅图片/视频) */
1243
- width?: number;
1244
- /** 高度(仅图片/视频) */
1245
- height?: number;
1246
- /** 时长(仅音频/视频,秒) */
1247
- duration?: number;
1248
- /** 扩展信息 */
1249
- extra?: Record<string, unknown>;
1250
- }
1284
+ type DjvComponentConstructor = {
1285
+ new (): DjvComponent;
1286
+ /** 观察的属性列表(用于属性反射) */
1287
+ observedAttributes?: string[];
1288
+ /** 组件元数据 */
1289
+ componentMeta?: ComponentMetaLite;
1290
+ };
1251
1291
  /**
1252
- * 资源信息
1292
+ * 组件元数据精简版(用于运行时)
1253
1293
  */
1254
- interface Asset {
1255
- /** 资源 ID */
1256
- id: string;
1257
- /** 资源名称 */
1294
+ interface ComponentMetaLite {
1258
1295
  name: string;
1259
- /** 资源类型 */
1260
- type: AssetType;
1261
- /** 资源状态 */
1262
- status: AssetStatus;
1263
- /** 存储路径/URL */
1264
- url: string;
1265
- /** 缩略图 URL */
1266
- thumbnailUrl?: string;
1267
- /** 元数据 */
1268
- meta: AssetMeta;
1269
- /** 标签 */
1270
- tags?: string[];
1271
- /** 所属目录 */
1272
- folderId?: string;
1273
- /** 创建时间 */
1274
- createdAt: string;
1275
- /** 创建者 */
1276
- createdBy: string;
1277
- /** 更新时间 */
1278
- updatedAt?: string;
1296
+ version: string;
1297
+ label: string;
1298
+ category: string;
1279
1299
  }
1280
-
1281
1300
  /**
1282
- * 运行时相关类型定义
1283
- * 包括页面解析结果、运行时配置、Manifest 等
1301
+ * 属性变更事件
1284
1302
  */
1285
-
1303
+ interface PropChangeEvent {
1304
+ /** 属性名 */
1305
+ propName: string;
1306
+ /** 旧值 */
1307
+ oldValue: unknown;
1308
+ /** 新值 */
1309
+ newValue: unknown;
1310
+ /** 变更时间 */
1311
+ timestamp: number;
1312
+ }
1286
1313
  /**
1287
- * 运行时配置
1288
- * 控制运行时行为的动态配置
1314
+ * 属性观察器配置
1289
1315
  */
1290
- interface RuntimeConfig {
1291
- /** Kill Switch 列表(紧急禁用的 actionType) */
1292
- killSwitches?: string[];
1293
- /** 被阻断的组件版本列表 */
1294
- blockedComponents?: BlockedComponent[];
1295
- /** 功能开关 */
1296
- features?: Record<string, boolean>;
1297
- /** 灰度配置 */
1298
- rollout?: RolloutConfig;
1299
- /** 调试模式 */
1300
- debug?: boolean;
1316
+ interface PropObserverConfig {
1317
+ /** 属性名 */
1318
+ propName: string;
1319
+ /** 是否深度监听 */
1320
+ deep?: boolean;
1321
+ /** 是否立即触发 */
1322
+ immediate?: boolean;
1323
+ /** 防抖时间(ms) */
1324
+ debounce?: number;
1301
1325
  }
1302
1326
  /**
1303
- * 被阻断的组件信息
1327
+ * 插槽类型
1304
1328
  */
1305
- interface BlockedComponent {
1306
- /** 组件名称 */
1307
- name: string;
1308
- /** 被阻断的版本(支持 semver range) */
1309
- version: string;
1310
- /** 阻断原因 */
1311
- reason: string;
1312
- /** 阻断时间 */
1313
- blockedAt: string;
1314
- }
1329
+ type SlotType = 'default' | 'named';
1315
1330
  /**
1316
- * 灰度配置
1331
+ * 插槽定义
1317
1332
  */
1318
- interface RolloutConfig {
1319
- /** 是否启用 */
1320
- enabled: boolean;
1321
- /** 灰度百分比 (0-100) */
1322
- percentage?: number;
1323
- /** 白名单用户 */
1324
- whitelistUsers?: string[];
1325
- /** 黑名单用户 */
1326
- blacklistUsers?: string[];
1333
+ interface SlotDefinition {
1334
+ /** 插槽名称(default 为默认插槽) */
1335
+ name: string;
1336
+ /** 插槽显示名 */
1337
+ label: string;
1338
+ /** 插槽描述 */
1339
+ description?: string;
1340
+ /** 是否必填 */
1341
+ required?: boolean;
1342
+ /** 允许的子组件类型(空数组表示允许所有) */
1343
+ allowedComponents?: string[];
1344
+ /** 最大子组件数量 */
1345
+ maxChildren?: number;
1346
+ /** 最小子组件数量 */
1347
+ minChildren?: number;
1327
1348
  }
1328
1349
  /**
1329
- * 页面解析请求
1330
- * GET /page/resolve
1350
+ * 组件插槽配置
1331
1351
  */
1332
- interface PageResolveRequest {
1333
- /** 页面 UID */
1334
- pageUid: string;
1335
- /** 渠道 */
1336
- channel?: string;
1337
- /** 用户 ID(用于灰度) */
1338
- uid?: string;
1339
- /** 设备 ID */
1340
- deviceId?: string;
1341
- /** 预览 Token */
1342
- previewToken?: string;
1352
+ interface SlotsDefinition {
1353
+ /** 版本 */
1354
+ version: string;
1355
+ /** 插槽列表 */
1356
+ slots: SlotDefinition[];
1357
+ /** 是否支持任意插槽 */
1358
+ allowCustomSlots?: boolean;
1343
1359
  }
1344
1360
  /**
1345
- * 页面解析结果
1346
- * GET /page/resolve 的响应数据
1361
+ * 组件渲染上下文
1362
+ * 运行时传递给组件的上下文信息
1347
1363
  */
1348
- interface PageResolveResult {
1349
- /** 页面 UID */
1350
- pageUid: string;
1364
+ interface ComponentRenderContext {
1365
+ /** 组件实例 ID */
1366
+ instanceId: string;
1351
1367
  /** 页面版本 ID */
1352
1368
  pageVersionId: string;
1353
- /** 页面 JSON */
1354
- pageJson: PageSchema;
1355
- /** 组件清单 */
1356
- manifest: PageManifest;
1357
- /** 运行时配置 */
1358
- runtimeConfig: RuntimeConfig;
1359
- /** 运行时版本要求 */
1369
+ /** 运行时版本 */
1360
1370
  runtimeVersion: string;
1371
+ /** 是否编辑模式 */
1372
+ isEditMode: boolean;
1361
1373
  /** 是否预览模式 */
1362
- isPreview?: boolean;
1374
+ isPreviewMode: boolean;
1375
+ /** 父组件 ID */
1376
+ parentId?: string;
1377
+ /** 在父组件中的位置索引 */
1378
+ index?: number;
1379
+ /** 循环渲染时的数据项 */
1380
+ loopItem?: unknown;
1381
+ /** 循环渲染时的索引 */
1382
+ loopIndex?: number;
1363
1383
  }
1364
1384
  /**
1365
- * 组件加载状态
1385
+ * 组件事件发射器接口
1366
1386
  */
1367
- type ComponentLoadStatus = 'pending' | 'loading' | 'loaded' | 'failed' | 'blocked';
1387
+ interface ComponentEventEmitter {
1388
+ /**
1389
+ * 发射组件事件
1390
+ * @param eventName 事件名称(需在 events.json 中声明)
1391
+ * @param payload 事件数据
1392
+ */
1393
+ emit(eventName: string, payload?: Record<string, unknown>): void;
1394
+ }
1368
1395
  /**
1369
- * 组件加载结果
1396
+ * 组件事件详情
1370
1397
  */
1371
- interface ComponentLoadResult {
1372
- /** 组件名称 */
1373
- name: string;
1374
- /** 组件版本 */
1375
- version: string;
1376
- /** 加载状态 */
1377
- status: ComponentLoadStatus;
1378
- /** 组件类/构造函数 */
1379
- component?: unknown;
1380
- /** 错误信息 */
1381
- error?: string;
1382
- /** 加载耗时(ms) */
1383
- loadTime?: number;
1398
+ interface ComponentEventDetail<T = unknown> {
1399
+ /** 事件来源组件 ID */
1400
+ sourceComponentId: string;
1401
+ /** 事件来源组件类型 */
1402
+ sourceComponentType: string;
1403
+ /** 事件来源组件版本 */
1404
+ sourceComponentVersion: string;
1405
+ /** 事件数据 */
1406
+ payload: T;
1407
+ /** 事件时间戳 */
1408
+ timestamp: number;
1384
1409
  }
1385
1410
  /**
1386
- * 组件注册表
1411
+ * 样式隔离模式
1387
1412
  */
1388
- interface ComponentRegistry {
1389
- /** 已注册的组件 */
1390
- components: Map<string, ComponentLoadResult>;
1391
- /** 注册组件 */
1392
- register(name: string, component: unknown): void;
1393
- /** 获取组件 */
1394
- get(name: string): ComponentLoadResult | undefined;
1395
- /** 检查组件是否已加载 */
1396
- has(name: string): boolean;
1397
- }
1413
+ type StyleIsolationMode = 'shadow' | 'scoped' | 'none';
1398
1414
  /**
1399
- * 运行时错误类型
1415
+ * Shadow DOM 配置
1400
1416
  */
1401
- type RuntimeErrorType = 'LOAD_ERROR' | 'RENDER_ERROR' | 'ACTION_ERROR' | 'QUERY_ERROR' | 'EXPRESSION_ERROR' | 'INTEGRITY_ERROR' | 'BLOCKED_ERROR';
1417
+ interface ShadowDomConfig {
1418
+ /** 模式 */
1419
+ mode: 'open' | 'closed';
1420
+ /** 是否可委托焦点 */
1421
+ delegatesFocus?: boolean;
1422
+ /** 插槽分配模式 */
1423
+ slotAssignment?: 'named' | 'manual';
1424
+ }
1402
1425
  /**
1403
- * 运行时错误
1426
+ * 组件注册选项
1404
1427
  */
1405
- interface RuntimeError {
1406
- /** 错误类型 */
1407
- type: RuntimeErrorType;
1408
- /** 错误消息 */
1409
- message: string;
1410
- /** 组件 ID */
1411
- componentId?: string;
1412
- /** 组件类型 */
1413
- componentType?: string;
1414
- /** 组件版本 */
1415
- componentVersion?: string;
1416
- /** 动作 ID */
1417
- actionId?: string;
1418
- /** 堆栈 */
1419
- stack?: string;
1420
- /** 追踪 ID */
1421
- traceId?: string;
1422
- /** 发生时间 */
1423
- timestamp: number;
1428
+ interface ComponentRegisterOptions {
1429
+ /** 自定义元素名称 */
1430
+ tagName: string;
1431
+ /** 组件构造器 */
1432
+ constructor: DjvComponentConstructor;
1433
+ /** 样式隔离模式 */
1434
+ styleIsolation?: StyleIsolationMode;
1435
+ /** Shadow DOM 配置 */
1436
+ shadowConfig?: ShadowDomConfig;
1437
+ /** 是否延迟注册 */
1438
+ lazy?: boolean;
1424
1439
  }
1425
1440
  /**
1426
- * 错误边界处理器
1441
+ * 组件注册结果
1427
1442
  */
1428
- interface ErrorBoundaryHandler {
1429
- /** 处理错误 */
1430
- handleError(error: RuntimeError): void;
1431
- /** 渲染 fallback */
1432
- renderFallback(error: RuntimeError): unknown;
1443
+ interface ComponentRegisterResult {
1444
+ /** 是否成功 */
1445
+ success: boolean;
1446
+ /** 注册的标签名 */
1447
+ tagName?: string;
1448
+ /** 错误信息 */
1449
+ error?: string;
1433
1450
  }
1451
+
1434
1452
  /**
1435
- * 性能指标类型
1453
+ * 编辑器控件类型定义
1454
+ * 定义属性面板中可用的编辑控件
1436
1455
  */
1437
- type PerformanceMetricType = 'page_resolve' | 'component_load' | 'first_render' | 'action_execute' | 'query_execute';
1438
1456
  /**
1439
- * 性能指标
1457
+ * 编辑器控件类型枚举
1458
+ * 对应属性 Schema 中的 x-editor-widget 字段
1440
1459
  */
1441
- interface PerformanceMetric {
1442
- /** 指标类型 */
1443
- type: PerformanceMetricType;
1444
- /** 名称/标识 */
1445
- name: string;
1446
- /** 耗时(ms) */
1447
- duration: number;
1448
- /** 开始时间 */
1449
- startTime: number;
1450
- /** 额外数据 */
1451
- extra?: Record<string, unknown>;
1460
+ type EditorWidgetType = 'input' | 'textarea' | 'number' | 'slider' | 'switch' | 'checkbox' | 'radio' | 'select' | 'multi-select' | 'color' | 'color-palette' | 'gradient' | 'size' | 'spacing' | 'border' | 'border-radius' | 'position' | 'alignment' | 'image' | 'video' | 'icon' | 'file' | 'rich-text' | 'markdown' | 'code' | 'json' | 'expression' | 'data-binding' | 'action' | 'event' | 'flex' | 'grid' | 'array' | 'object' | 'condition' | 'formula' | 'link' | 'page-link' | 'date' | 'time' | 'datetime' | 'date-range' | 'custom';
1461
+ /**
1462
+ * 控件基础配置
1463
+ */
1464
+ interface WidgetBaseConfig {
1465
+ /** 控件类型 */
1466
+ type: EditorWidgetType;
1467
+ /** 是否禁用 */
1468
+ disabled?: boolean;
1469
+ /** 占位文本 */
1470
+ placeholder?: string;
1471
+ /** 帮助文本 */
1472
+ help?: string;
1473
+ /** 是否隐藏 */
1474
+ hidden?: boolean;
1475
+ /** 显示条件(表达式) */
1476
+ showWhen?: string;
1452
1477
  }
1453
1478
  /**
1454
- * 运行时事件类型
1479
+ * 文本输入控件配置
1455
1480
  */
1456
- type RuntimeEventType = 'page:loaded' | 'page:error' | 'component:mounted' | 'component:unmounted' | 'component:error' | 'action:start' | 'action:success' | 'action:error' | 'query:start' | 'query:success' | 'query:error';
1481
+ interface InputWidgetConfig extends WidgetBaseConfig {
1482
+ type: 'input' | 'textarea';
1483
+ /** 最大长度 */
1484
+ maxLength?: number;
1485
+ /** 最小长度 */
1486
+ minLength?: number;
1487
+ /** 输入模式 */
1488
+ inputMode?: 'text' | 'email' | 'url' | 'tel' | 'numeric';
1489
+ /** 前缀 */
1490
+ prefix?: string;
1491
+ /** 后缀 */
1492
+ suffix?: string;
1493
+ /** 是否显示字数统计 */
1494
+ showCount?: boolean;
1495
+ /** 行数(仅 textarea) */
1496
+ rows?: number;
1497
+ }
1457
1498
  /**
1458
- * 运行时事件
1499
+ * 数字输入控件配置
1459
1500
  */
1460
- interface RuntimeEvent<T = unknown> {
1461
- /** 事件类型 */
1462
- type: RuntimeEventType;
1463
- /** 事件数据 */
1464
- data: T;
1465
- /** 时间戳 */
1466
- timestamp: number;
1467
- /** 追踪 ID */
1468
- traceId?: string;
1501
+ interface NumberWidgetConfig extends WidgetBaseConfig {
1502
+ type: 'number' | 'slider';
1503
+ /** 最小值 */
1504
+ min?: number;
1505
+ /** 最大值 */
1506
+ max?: number;
1507
+ /** 步长 */
1508
+ step?: number;
1509
+ /** 精度 */
1510
+ precision?: number;
1511
+ /** 单位 */
1512
+ unit?: string;
1513
+ /** 是否显示增减按钮 */
1514
+ showButtons?: boolean;
1469
1515
  }
1470
1516
  /**
1471
- * 事件总线接口
1517
+ * 选择控件配置
1472
1518
  */
1473
- interface EventBus {
1474
- /** 发送事件 */
1475
- emit<T>(event: RuntimeEvent<T>): void;
1476
- /** 订阅事件 */
1477
- on<T>(type: RuntimeEventType, handler: (event: RuntimeEvent<T>) => void): () => void;
1478
- /** 取消订阅 */
1479
- off<T>(type: RuntimeEventType, handler: (event: RuntimeEvent<T>) => void): void;
1519
+ interface SelectWidgetConfig extends WidgetBaseConfig {
1520
+ type: 'select' | 'multi-select' | 'radio' | 'checkbox';
1521
+ /** 选项列表 */
1522
+ options: SelectOption[];
1523
+ /** 是否可搜索 */
1524
+ searchable?: boolean;
1525
+ /** 是否可清除 */
1526
+ clearable?: boolean;
1527
+ /** 是否允许创建新选项 */
1528
+ allowCreate?: boolean;
1529
+ /** 最大选择数量(多选) */
1530
+ maxSelect?: number;
1531
+ /** 选项来源(动态选项) */
1532
+ optionsSource?: OptionsSource;
1480
1533
  }
1481
-
1482
1534
  /**
1483
- * 统一 API 响应类型定义
1484
- * 所有 API 响应遵循统一格式
1535
+ * 选择选项
1485
1536
  */
1486
-
1537
+ interface SelectOption {
1538
+ /** 选项值 */
1539
+ value: string | number | boolean;
1540
+ /** 显示标签 */
1541
+ label: string;
1542
+ /** 是否禁用 */
1543
+ disabled?: boolean;
1544
+ /** 图标 */
1545
+ icon?: string;
1546
+ /** 描述 */
1547
+ description?: string;
1548
+ /** 分组 */
1549
+ group?: string;
1550
+ }
1487
1551
  /**
1488
- * 统一 API 响应格式
1552
+ * 动态选项来源
1489
1553
  */
1490
- interface ApiResponse<T = unknown> {
1491
- /** 是否成功 */
1492
- success: boolean;
1493
- /** 响应数据 */
1494
- data?: T;
1495
- /** 错误码 */
1496
- code?: ErrorCode | number;
1497
- /** 错误信息 */
1498
- message?: string;
1499
- /** 追踪 ID */
1500
- traceId?: string;
1501
- /** 请求 ID */
1502
- requestId?: string;
1503
- /** 时间戳 */
1504
- timestamp?: number;
1554
+ interface OptionsSource {
1555
+ /** 来源类型 */
1556
+ type: 'static' | 'api' | 'query';
1557
+ /** API URL(api 类型) */
1558
+ url?: string;
1559
+ /** Query ID(query 类型) */
1560
+ queryId?: string;
1561
+ /** 值字段路径 */
1562
+ valuePath?: string;
1563
+ /** 标签字段路径 */
1564
+ labelPath?: string;
1565
+ /** 依赖的属性 */
1566
+ dependsOn?: string[];
1505
1567
  }
1506
1568
  /**
1507
- * 分页 API 响应格式
1569
+ * 颜色控件配置
1508
1570
  */
1509
- interface PaginatedApiResponse<T> extends ApiResponse<T[]> {
1510
- /** 分页信息 */
1511
- pagination?: {
1512
- /** 当前页码 */
1513
- page: number;
1514
- /** 每页数量 */
1515
- pageSize: number;
1516
- /** 总数量 */
1517
- total: number;
1518
- /** 总页数 */
1519
- totalPages: number;
1520
- };
1571
+ interface ColorWidgetConfig extends WidgetBaseConfig {
1572
+ type: 'color' | 'color-palette' | 'gradient';
1573
+ /** 预设颜色 */
1574
+ presets?: string[];
1575
+ /** 是否支持透明度 */
1576
+ allowAlpha?: boolean;
1577
+ /** 颜色格式 */
1578
+ format?: 'hex' | 'rgb' | 'hsl';
1579
+ /** 是否使用设计系统变量 */
1580
+ useDesignTokens?: boolean;
1521
1581
  }
1522
1582
  /**
1523
- * 标准请求头
1583
+ * 尺寸控件配置
1524
1584
  */
1525
- interface StandardRequestHeaders {
1526
- /** 追踪 ID */
1527
- 'x-trace-id'?: string;
1528
- /** 请求 ID */
1529
- 'x-request-id'?: string;
1530
- /** 页面版本 ID */
1531
- 'x-page-version-id'?: string;
1532
- /** 组件版本 */
1533
- 'x-component-version'?: string;
1534
- /** 用户 ID */
1535
- 'x-user-id'?: string;
1536
- /** 设备 ID */
1537
- 'x-device-id'?: string;
1538
- /** 渠道 */
1539
- 'x-channel'?: string;
1540
- /** 应用 ID */
1541
- 'x-app-id'?: string;
1585
+ interface SizeWidgetConfig extends WidgetBaseConfig {
1586
+ type: 'size' | 'spacing' | 'border-radius';
1587
+ /** 允许的单位 */
1588
+ units?: ('px' | 'rem' | 'em' | '%' | 'vw' | 'vh' | 'auto')[];
1589
+ /** 是否联动 */
1590
+ linked?: boolean;
1591
+ /** 最小值 */
1592
+ min?: number;
1593
+ /** 最大值 */
1594
+ max?: number;
1542
1595
  }
1543
1596
  /**
1544
- * 标准响应头
1597
+ * 媒体控件配置
1545
1598
  */
1546
- interface StandardResponseHeaders {
1599
+ interface MediaWidgetConfig extends WidgetBaseConfig {
1600
+ type: 'image' | 'video' | 'file';
1601
+ /** 接受的文件类型 */
1602
+ accept?: string;
1603
+ /** 最大文件大小(字节) */
1604
+ maxSize?: number;
1605
+ /** 是否支持多选 */
1606
+ multiple?: boolean;
1607
+ /** 是否显示裁剪器 */
1608
+ crop?: boolean;
1609
+ /** 裁剪比例 */
1610
+ aspectRatio?: number;
1611
+ }
1612
+ /**
1613
+ * 代码控件配置
1614
+ */
1615
+ interface CodeWidgetConfig extends WidgetBaseConfig {
1616
+ type: 'code' | 'json' | 'expression';
1617
+ /** 代码语言 */
1618
+ language?: 'javascript' | 'typescript' | 'json' | 'css' | 'html';
1619
+ /** 是否显示行号 */
1620
+ lineNumbers?: boolean;
1621
+ /** 主题 */
1622
+ theme?: 'light' | 'dark' | 'auto';
1623
+ /** 最大高度 */
1624
+ maxHeight?: number;
1625
+ }
1626
+ /**
1627
+ * 数组控件配置
1628
+ */
1629
+ interface ArrayWidgetConfig extends WidgetBaseConfig {
1630
+ type: 'array';
1631
+ /** 子项 Schema */
1632
+ itemSchema: Record<string, unknown>;
1633
+ /** 最小数量 */
1634
+ minItems?: number;
1635
+ /** 最大数量 */
1636
+ maxItems?: number;
1637
+ /** 是否可排序 */
1638
+ sortable?: boolean;
1639
+ /** 是否可折叠 */
1640
+ collapsible?: boolean;
1641
+ /** 默认折叠 */
1642
+ defaultCollapsed?: boolean;
1643
+ /** 项标题模板 */
1644
+ itemTitleTemplate?: string;
1645
+ }
1646
+ /**
1647
+ * 对象控件配置
1648
+ */
1649
+ interface ObjectWidgetConfig extends WidgetBaseConfig {
1650
+ type: 'object';
1651
+ /** 属性 Schema */
1652
+ properties: Record<string, unknown>;
1653
+ /** 是否可折叠 */
1654
+ collapsible?: boolean;
1655
+ /** 默认折叠 */
1656
+ defaultCollapsed?: boolean;
1657
+ /** 布局模式 */
1658
+ layout?: 'vertical' | 'horizontal' | 'inline';
1659
+ }
1660
+ /**
1661
+ * 自定义控件配置
1662
+ */
1663
+ interface CustomWidgetConfig extends WidgetBaseConfig {
1664
+ type: 'custom';
1665
+ /** 自定义控件组件名 */
1666
+ component: string;
1667
+ /** 传递给自定义控件的额外属性 */
1668
+ componentProps?: Record<string, unknown>;
1669
+ }
1670
+ /**
1671
+ * 所有控件配置联合类型
1672
+ */
1673
+ type WidgetConfig = InputWidgetConfig | NumberWidgetConfig | SelectWidgetConfig | ColorWidgetConfig | SizeWidgetConfig | MediaWidgetConfig | CodeWidgetConfig | ArrayWidgetConfig | ObjectWidgetConfig | CustomWidgetConfig | WidgetBaseConfig;
1674
+ /**
1675
+ * 属性分组定义
1676
+ */
1677
+ interface PropertyGroup {
1678
+ /** 分组 ID */
1679
+ id: string;
1680
+ /** 分组名称 */
1681
+ label: string;
1682
+ /** 分组图标 */
1683
+ icon?: string;
1684
+ /** 排序权重 */
1685
+ order?: number;
1686
+ /** 是否默认展开 */
1687
+ defaultExpanded?: boolean;
1688
+ /** 包含的属性名列表 */
1689
+ properties?: string[];
1690
+ }
1691
+ /**
1692
+ * 属性面板配置
1693
+ */
1694
+ interface PropertyPanelConfig {
1695
+ /** 分组列表 */
1696
+ groups: PropertyGroup[];
1697
+ /** 默认分组(未指定分组的属性归入) */
1698
+ defaultGroup?: string;
1699
+ /** 是否显示高级属性 */
1700
+ showAdvanced?: boolean;
1701
+ }
1702
+ /**
1703
+ * 内置属性分组
1704
+ */
1705
+ declare const BUILTIN_PROPERTY_GROUPS: PropertyGroup[];
1706
+
1707
+ /**
1708
+ * 组件 Registry 相关类型定义
1709
+ * 用于组件版本解析、搜索筛选
1710
+ */
1711
+
1712
+ /**
1713
+ * 版本解析请求
1714
+ */
1715
+ interface ResolveVersionsRequest {
1716
+ /** 需要解析的组件列表 */
1717
+ components: ComponentVersionQuery[];
1718
+ /** 运行时版本(用于兼容性检查) */
1719
+ runtimeVersion?: string;
1720
+ /** 是否包含预发布版本 */
1721
+ includePrerelease?: boolean;
1722
+ /** 是否跳过被阻断的版本 */
1723
+ skipBlocked?: boolean;
1724
+ }
1725
+ /**
1726
+ * 组件版本查询
1727
+ */
1728
+ interface ComponentVersionQuery {
1729
+ /** 组件名称 */
1730
+ name: string;
1731
+ /** 版本范围(semver range),如 "^1.0.0", "~1.2.0", ">=1.0.0 <2.0.0" */
1732
+ versionRange: string;
1733
+ }
1734
+ /**
1735
+ * 版本解析响应
1736
+ */
1737
+ interface ResolveVersionsResponse {
1738
+ /** 解析成功的组件 */
1739
+ resolved: ResolvedComponent[];
1740
+ /** 解析失败的组件 */
1741
+ failed: FailedComponent[];
1742
+ /** 有警告的组件(如使用了 deprecated 版本) */
1743
+ warnings: ComponentWarning[];
1744
+ }
1745
+ /**
1746
+ * 解析成功的组件
1747
+ */
1748
+ interface ResolvedComponent {
1749
+ /** 组件名称 */
1750
+ name: string;
1751
+ /** 请求的版本范围 */
1752
+ requestedRange: string;
1753
+ /** 解析到的版本 */
1754
+ resolvedVersion: string;
1755
+ /** 组件入口 URL */
1756
+ entryUrl: string;
1757
+ /** SRI 完整性哈希 */
1758
+ integrity: string;
1759
+ /** 样式 URL */
1760
+ styleUrl?: string;
1761
+ /** 组件状态 */
1762
+ status: ComponentStatus;
1763
+ /** 是否有更新版本可用 */
1764
+ hasNewerVersion?: boolean;
1765
+ /** 最新稳定版本 */
1766
+ latestStableVersion?: string;
1767
+ }
1768
+ /**
1769
+ * 解析失败的组件
1770
+ */
1771
+ interface FailedComponent {
1772
+ /** 组件名称 */
1773
+ name: string;
1774
+ /** 请求的版本范围 */
1775
+ requestedRange: string;
1776
+ /** 失败原因 */
1777
+ reason: ResolveFailReason;
1778
+ /** 详细错误信息 */
1779
+ message: string;
1780
+ /** 建议的版本(如有) */
1781
+ suggestedVersion?: string;
1782
+ }
1783
+ /**
1784
+ * 解析失败原因
1785
+ */
1786
+ type ResolveFailReason = 'NOT_FOUND' | 'VERSION_NOT_FOUND' | 'ALL_BLOCKED' | 'INCOMPATIBLE' | 'INVALID_RANGE' | 'ACCESS_DENIED';
1787
+ /**
1788
+ * 组件警告信息
1789
+ */
1790
+ interface ComponentWarning {
1791
+ /** 组件名称 */
1792
+ name: string;
1793
+ /** 版本 */
1794
+ version: string;
1795
+ /** 警告类型 */
1796
+ type: ComponentWarningType;
1797
+ /** 警告信息 */
1798
+ message: string;
1799
+ }
1800
+ /**
1801
+ * 组件警告类型
1802
+ */
1803
+ type ComponentWarningType = 'DEPRECATED' | 'SECURITY' | 'BREAKING_CHANGE' | 'NEAR_EOL';
1804
+ /**
1805
+ * 组件搜索请求
1806
+ */
1807
+ interface SearchComponentsRequest extends PaginationParams {
1808
+ /** 搜索关键词 */
1809
+ keyword?: string;
1810
+ /** 分类筛选 */
1811
+ categories?: ComponentCategory[];
1812
+ /** 状态筛选 */
1813
+ statuses?: ComponentStatus[];
1814
+ /** 标签筛选 */
1815
+ tags?: string[];
1816
+ /** 作者筛选 */
1817
+ author?: string;
1818
+ /** 排序字段 */
1819
+ sortBy?: ComponentSortField;
1820
+ /** 排序方向 */
1821
+ sortOrder?: SortOrder;
1822
+ /** 是否只返回最新版本 */
1823
+ latestOnly?: boolean;
1824
+ /** 最低运行时版本兼容 */
1825
+ minRuntimeVersion?: string;
1826
+ }
1827
+ /**
1828
+ * 组件排序字段
1829
+ */
1830
+ type ComponentSortField = 'name' | 'publishedAt' | 'updatedAt' | 'downloadCount' | 'version';
1831
+ /**
1832
+ * 组件搜索响应
1833
+ */
1834
+ interface SearchComponentsResponse {
1835
+ /** 组件列表 */
1836
+ items: ComponentSearchItem[];
1837
+ /** 分页信息 */
1838
+ meta: PaginationMeta;
1839
+ /** 筛选聚合 */
1840
+ aggregations?: ComponentAggregations;
1841
+ }
1842
+ /**
1843
+ * 组件搜索结果项
1844
+ */
1845
+ interface ComponentSearchItem {
1846
+ /** 组件 ID */
1847
+ id: string;
1848
+ /** 组件名称 */
1849
+ name: string;
1850
+ /** 最新版本 */
1851
+ latestVersion: string;
1852
+ /** 显示名称 */
1853
+ label: string;
1854
+ /** 描述 */
1855
+ description?: string;
1856
+ /** 分类 */
1857
+ category: ComponentCategory;
1858
+ /** 标签 */
1859
+ tags?: string[];
1860
+ /** 作者 */
1861
+ author?: string;
1862
+ /** 状态 */
1863
+ status: ComponentStatus;
1864
+ /** 预览图 */
1865
+ previewUrl?: string;
1866
+ /** 下载次数 */
1867
+ downloadCount?: number;
1868
+ /** 发布时间 */
1869
+ publishedAt: string;
1870
+ /** 版本数量 */
1871
+ versionCount: number;
1872
+ }
1873
+ /**
1874
+ * 筛选聚合结果
1875
+ */
1876
+ interface ComponentAggregations {
1877
+ /** 分类分布 */
1878
+ categories: AggregationBucket[];
1879
+ /** 状态分布 */
1880
+ statuses: AggregationBucket[];
1881
+ /** 标签分布 */
1882
+ tags: AggregationBucket[];
1883
+ /** 作者分布 */
1884
+ authors: AggregationBucket[];
1885
+ }
1886
+ /**
1887
+ * 聚合桶
1888
+ */
1889
+ interface AggregationBucket {
1890
+ /** 值 */
1891
+ key: string;
1892
+ /** 数量 */
1893
+ count: number;
1894
+ }
1895
+ /**
1896
+ * 获取组件版本列表请求
1897
+ */
1898
+ interface ListComponentVersionsRequest extends PaginationParams {
1899
+ /** 组件名称 */
1900
+ name: string;
1901
+ /** 状态筛选 */
1902
+ statuses?: ComponentStatus[];
1903
+ /** 是否包含预发布版本 */
1904
+ includePrerelease?: boolean;
1905
+ }
1906
+ /**
1907
+ * 组件版本列表响应
1908
+ */
1909
+ interface ListComponentVersionsResponse {
1910
+ /** 版本列表 */
1911
+ items: ComponentVersionInfo[];
1912
+ /** 分页信息 */
1913
+ meta: PaginationMeta;
1914
+ }
1915
+ /**
1916
+ * 组件版本信息
1917
+ */
1918
+ interface ComponentVersionInfo {
1919
+ /** 版本 ID */
1920
+ id: string;
1921
+ /** 版本号 */
1922
+ version: string;
1923
+ /** 状态 */
1924
+ status: ComponentStatus;
1925
+ /** 是否预发布 */
1926
+ prerelease: boolean;
1927
+ /** 变更日志 */
1928
+ changelog?: string;
1929
+ /** 发布时间 */
1930
+ publishedAt: string;
1931
+ /** 发布者 */
1932
+ publishedBy: string;
1933
+ /** 下载次数 */
1934
+ downloadCount?: number;
1935
+ /** 兼容性信息 */
1936
+ compat?: {
1937
+ minRuntime: string;
1938
+ maxRuntime?: string;
1939
+ breaking?: boolean;
1940
+ };
1941
+ /** 阻断信息 */
1942
+ blockInfo?: {
1943
+ reason: string;
1944
+ blockedAt: string;
1945
+ blockedBy: string;
1946
+ };
1947
+ }
1948
+ /**
1949
+ * 注册组件版本请求
1950
+ */
1951
+ interface RegisterComponentVersionRequest {
1952
+ /** 组件名称 */
1953
+ name: string;
1954
+ /** 版本号 */
1955
+ version: string;
1956
+ /** 组件元数据 */
1957
+ meta: ComponentMeta;
1958
+ /** CDN 资源 URL 前缀 */
1959
+ assetsBaseUrl: string;
1960
+ /** 变更日志 */
1961
+ changelog?: string;
1962
+ /** 是否自动发布(跳过 draft 状态) */
1963
+ autoPublish?: boolean;
1964
+ }
1965
+ /**
1966
+ * 注册组件版本响应
1967
+ */
1968
+ interface RegisterComponentVersionResponse {
1969
+ /** 是否成功 */
1970
+ success: boolean;
1971
+ /** 版本 ID */
1972
+ versionId?: string;
1973
+ /** 组件 ID */
1974
+ componentId?: string;
1975
+ /** 当前状态 */
1976
+ status?: ComponentStatus;
1977
+ /** 错误信息 */
1978
+ error?: string;
1979
+ }
1980
+ /**
1981
+ * 变更组件版本状态请求
1982
+ */
1983
+ interface ChangeComponentStatusRequest {
1984
+ /** 组件名称 */
1985
+ name: string;
1986
+ /** 版本号 */
1987
+ version: string;
1988
+ /** 目标状态 */
1989
+ targetStatus: ComponentStatus;
1990
+ /** 变更原因 */
1991
+ reason?: string;
1992
+ }
1993
+ /**
1994
+ * 阻断组件请求
1995
+ */
1996
+ interface BlockComponentRequest {
1997
+ /** 组件名称 */
1998
+ name: string;
1999
+ /** 版本范围(支持 semver range) */
2000
+ versionRange: string;
2001
+ /** 阻断原因 */
2002
+ reason: string;
2003
+ /** 是否紧急阻断(跳过确认) */
2004
+ urgent?: boolean;
2005
+ }
2006
+ /**
2007
+ * 解除阻断请求
2008
+ */
2009
+ interface UnblockComponentRequest {
2010
+ /** 组件名称 */
2011
+ name: string;
2012
+ /** 版本范围 */
2013
+ versionRange: string;
2014
+ /** 解除原因 */
2015
+ reason: string;
2016
+ }
2017
+
2018
+ /**
2019
+ * 运行时相关类型定义
2020
+ * 包括页面解析结果、运行时配置、Manifest 等
2021
+ *
2022
+ * 注意:以下接口属于运行时实现,已移至 @djvlc/runtime-core:
2023
+ * - ComponentRegistry(组件注册表实现)
2024
+ * - EventBus(事件总线实现)
2025
+ * - ErrorBoundaryHandler(错误边界处理实现)
2026
+ *
2027
+ * contracts 只定义协议与数据结构,不定义实现接口。
2028
+ */
2029
+
2030
+ /**
2031
+ * Manifest 中的组件引用
2032
+ */
2033
+ interface ManifestItem {
2034
+ /** 组件名称 */
2035
+ name: string;
2036
+ /** 组件版本 */
2037
+ version: string;
2038
+ /** 入口 URL */
2039
+ entryUrl: string;
2040
+ /** 样式 URL */
2041
+ styleUrl?: string;
2042
+ /** SRI 哈希 */
2043
+ integrity: string;
2044
+ /** 是否必须成功加载 */
2045
+ critical?: boolean;
2046
+ /** 预加载优先级 */
2047
+ preloadPriority?: 'high' | 'low' | 'auto';
2048
+ }
2049
+ /**
2050
+ * 页面 Manifest
2051
+ * 记录页面使用的组件版本及其加载信息
2052
+ */
2053
+ interface PageManifest {
2054
+ /** Manifest 版本 */
2055
+ manifestVersion: string;
2056
+ /** 内容哈希 */
2057
+ contentHash: string;
2058
+ /** 运行时版本 */
2059
+ runtimeVersion: string;
2060
+ /** 组件清单 */
2061
+ components: ManifestItem[];
2062
+ /** 生成时间 */
2063
+ generatedAt: string;
2064
+ }
2065
+ /**
2066
+ * 被阻断的组件信息
2067
+ */
2068
+ interface BlockedComponent {
2069
+ /** 组件名称 */
2070
+ name: string;
2071
+ /** 被阻断的版本(支持 semver range) */
2072
+ version: string;
2073
+ /** 阻断原因 */
2074
+ reason: string;
2075
+ /** 阻断时间 */
2076
+ blockedAt: string;
2077
+ /** 阻断者 */
2078
+ blockedBy?: string;
2079
+ }
2080
+ /**
2081
+ * 运行时配置
2082
+ * 控制运行时行为的动态配置
2083
+ */
2084
+ interface RuntimeConfig {
2085
+ /** Kill Switch 列表(紧急禁用的 actionType) */
2086
+ killSwitches?: string[];
2087
+ /** Kill Switch 详细配置 */
2088
+ killSwitchConfigs?: KillSwitchConfig[];
2089
+ /** 被阻断的组件版本列表 */
2090
+ blockedComponents?: BlockedComponent[];
2091
+ /** 功能开关 */
2092
+ features?: Record<string, boolean>;
2093
+ /** 灰度配置 */
2094
+ rollout?: RolloutConfig;
2095
+ /** 调试模式 */
2096
+ debug?: boolean;
2097
+ /** API 基础路径覆盖 */
2098
+ apiBaseUrl?: string;
2099
+ /** CDN 基础路径覆盖 */
2100
+ cdnBaseUrl?: string;
2101
+ }
2102
+ /**
2103
+ * 页面解析请求
2104
+ * GET /page/resolve
2105
+ */
2106
+ interface PageResolveRequest {
2107
+ /** 页面 UID */
2108
+ pageUid: string;
2109
+ /** 渠道 */
2110
+ channel?: string;
2111
+ /** 用户 ID(用于灰度) */
2112
+ uid?: string;
2113
+ /** 设备 ID */
2114
+ deviceId?: string;
2115
+ /** 预览 Token */
2116
+ previewToken?: string;
2117
+ }
2118
+ /**
2119
+ * 页面解析结果
2120
+ * GET /page/resolve 的响应数据
2121
+ */
2122
+ interface PageResolveResult {
2123
+ /** 页面 UID */
2124
+ pageUid: string;
2125
+ /** 页面版本 ID */
2126
+ pageVersionId: string;
2127
+ /** 页面 JSON */
2128
+ pageJson: PageSchema;
2129
+ /** 组件清单 */
2130
+ manifest: PageManifest;
2131
+ /** 运行时配置 */
2132
+ runtimeConfig: RuntimeConfig;
2133
+ /** 运行时版本要求 */
2134
+ runtimeVersion: string;
2135
+ /** 是否预览模式 */
2136
+ isPreview?: boolean;
2137
+ }
2138
+ /**
2139
+ * 组件加载状态
2140
+ */
2141
+ type ComponentLoadStatus = 'pending' | 'loading' | 'loaded' | 'failed' | 'blocked';
2142
+ /**
2143
+ * 组件加载结果
2144
+ */
2145
+ interface ComponentLoadResult {
2146
+ /** 组件名称 */
2147
+ name: string;
2148
+ /** 组件版本 */
2149
+ version: string;
2150
+ /** 加载状态 */
2151
+ status: ComponentLoadStatus;
2152
+ /** 组件类/构造函数 */
2153
+ component?: unknown;
2154
+ /** 错误信息 */
2155
+ error?: string;
2156
+ /** 加载耗时(ms) */
2157
+ loadTime?: number;
2158
+ }
2159
+ /**
2160
+ * 运行时错误类型
2161
+ */
2162
+ type RuntimeErrorType = 'LOAD_ERROR' | 'RENDER_ERROR' | 'ACTION_ERROR' | 'QUERY_ERROR' | 'EXPRESSION_ERROR' | 'INTEGRITY_ERROR' | 'BLOCKED_ERROR';
2163
+ /**
2164
+ * 运行时错误
2165
+ */
2166
+ interface RuntimeError {
2167
+ /** 错误类型 */
2168
+ type: RuntimeErrorType;
2169
+ /** 错误消息 */
2170
+ message: string;
2171
+ /** 组件 ID */
2172
+ componentId?: string;
2173
+ /** 组件类型 */
2174
+ componentType?: string;
2175
+ /** 组件版本 */
2176
+ componentVersion?: string;
2177
+ /** 动作 ID */
2178
+ actionId?: string;
2179
+ /** 堆栈 */
2180
+ stack?: string;
2181
+ /** 追踪 ID */
2182
+ traceId?: string;
2183
+ /** 发生时间 */
2184
+ timestamp: number;
2185
+ }
2186
+ /**
2187
+ * 性能指标类型
2188
+ */
2189
+ type PerformanceMetricType = 'page_resolve' | 'component_load' | 'first_render' | 'action_execute' | 'query_execute';
2190
+ /**
2191
+ * 性能指标
2192
+ */
2193
+ interface PerformanceMetric {
2194
+ /** 指标类型 */
2195
+ type: PerformanceMetricType;
2196
+ /** 名称/标识 */
2197
+ name: string;
2198
+ /** 耗时(ms) */
2199
+ duration: number;
2200
+ /** 开始时间 */
2201
+ startTime: number;
2202
+ /** 额外数据 */
2203
+ extra?: Record<string, unknown>;
2204
+ }
2205
+ /**
2206
+ * 运行时事件类型
2207
+ */
2208
+ type RuntimeEventType = 'page:loaded' | 'page:error' | 'component:mounted' | 'component:unmounted' | 'component:error' | 'action:start' | 'action:success' | 'action:error' | 'query:start' | 'query:success' | 'query:error';
2209
+ /**
2210
+ * 运行时事件
2211
+ */
2212
+ interface RuntimeEvent<T = unknown> {
2213
+ /** 事件类型 */
2214
+ type: RuntimeEventType;
2215
+ /** 事件数据 */
2216
+ data: T;
2217
+ /** 时间戳 */
2218
+ timestamp: number;
2219
+ /** 追踪 ID */
2220
+ traceId?: string;
2221
+ }
2222
+ /**
2223
+ * 埋点事件类型
2224
+ */
2225
+ type TrackEventType = 'page_view' | 'component_view' | 'component_click' | 'action_trigger' | 'action_success' | 'action_fail' | 'error' | 'performance' | 'custom';
2226
+ /**
2227
+ * 埋点请求
2228
+ */
2229
+ interface TrackRequest {
2230
+ /** 事件类型 */
2231
+ eventType: TrackEventType;
2232
+ /** 事件名称 */
2233
+ eventName: string;
2234
+ /** 事件参数 */
2235
+ params?: Record<string, unknown>;
2236
+ /** 页面上下文 */
2237
+ context: TrackContext;
2238
+ /** 客户端时间戳 */
2239
+ clientTimestamp: number;
2240
+ }
2241
+ /**
2242
+ * 埋点上下文(继承 RuntimeContext)
2243
+ * 扩展运行时上下文,添加埋点特有的字段
2244
+ */
2245
+ interface TrackContext extends RuntimeContext {
2246
+ /** 设备 ID(必填,重写为必填) */
2247
+ deviceId: string;
2248
+ /** 组件 ID */
2249
+ componentId?: string;
2250
+ /** 组件类型 */
2251
+ componentType?: string;
2252
+ /** 组件版本 */
2253
+ componentVersion?: string;
2254
+ /** 用户代理 */
2255
+ userAgent?: string;
2256
+ /** 屏幕分辨率 */
2257
+ screenResolution?: string;
2258
+ /** 页面 URL */
2259
+ pageUrl?: string;
2260
+ /** 来源页面 */
2261
+ referrer?: string;
2262
+ }
2263
+ /**
2264
+ * 批量埋点请求
2265
+ */
2266
+ interface BatchTrackRequest {
2267
+ /** 事件列表 */
2268
+ events: TrackRequest[];
2269
+ /** 公共上下文 */
2270
+ commonContext?: Partial<TrackContext>;
2271
+ }
2272
+ /**
2273
+ * 埋点响应
2274
+ */
2275
+ interface TrackResponse {
2276
+ /** 是否成功 */
2277
+ success: boolean;
2278
+ /** 接收的事件数量 */
2279
+ received: number;
2280
+ /** 服务器时间戳 */
2281
+ serverTimestamp: number;
2282
+ }
2283
+
2284
+ /**
2285
+ * 组件 Meta Schema 类型定义
2286
+ * 定义每个组件版本必须包含的元数据
2287
+ */
2288
+
2289
+ /** JSON Schema 类型定义 */
2290
+ interface JsonSchema {
2291
+ type: 'string' | 'number' | 'boolean' | 'object' | 'array' | 'null';
2292
+ title?: string;
2293
+ description?: string;
2294
+ default?: unknown;
2295
+ enum?: unknown[];
2296
+ properties?: Record<string, JsonSchema>;
2297
+ items?: JsonSchema;
2298
+ required?: string[];
2299
+ minimum?: number;
2300
+ maximum?: number;
2301
+ minLength?: number;
2302
+ maxLength?: number;
2303
+ pattern?: string;
2304
+ format?: string;
2305
+ $ref?: string;
2306
+ }
2307
+ /** Props Schema - 组件属性定义 */
2308
+ interface PropsSchema {
2309
+ $schema?: string;
2310
+ type: 'object';
2311
+ title: string;
2312
+ description?: string;
2313
+ properties: Record<string, JsonSchema & {
2314
+ /** 属性分组 */
2315
+ group?: string;
2316
+ /** 编辑器中的控件类型 */
2317
+ 'x-editor-widget'?: string;
2318
+ /** 是否支持表达式绑定 */
2319
+ 'x-expression-enabled'?: boolean;
2320
+ }>;
2321
+ required?: string[];
2322
+ }
2323
+ /** 事件定义 */
2324
+ interface EventDefinition {
2325
+ /** 事件名称 */
2326
+ name: string;
2327
+ /** 事件显示名 */
2328
+ label: string;
2329
+ /** 事件描述 */
2330
+ description?: string;
2331
+ /** 事件参数 Schema */
2332
+ payload?: JsonSchema;
2333
+ }
2334
+ /** 组件事件列表 */
2335
+ interface EventsDefinition {
2336
+ /** 事件版本 */
2337
+ version: string;
2338
+ /** 事件列表 */
2339
+ events: EventDefinition[];
2340
+ }
2341
+ /** 组件能力声明 */
2342
+ interface CapabilitiesDefinition {
2343
+ /** 能力版本 */
2344
+ version: string;
2345
+ /** 是否需要用户登录态 */
2346
+ requiresAuth?: boolean;
2347
+ /** 是否需要执行 Action */
2348
+ requiresAction?: boolean;
2349
+ /** 需要的 Action 类型 */
2350
+ actionTypes?: string[];
2351
+ /** 是否需要 Data Query */
2352
+ requiresDataQuery?: boolean;
2353
+ /** 需要的 Query 类型 */
2354
+ queryTypes?: string[];
2355
+ /** 是否需要导航能力 */
2356
+ requiresNavigation?: boolean;
2357
+ /** 是否需要埋点能力 */
2358
+ requiresTrack?: boolean;
2359
+ /** 是否需要对话框能力 */
2360
+ requiresDialog?: boolean;
2361
+ /** 是否需要剪贴板能力 */
2362
+ requiresClipboard?: boolean;
2363
+ /** 自定义能力 */
2364
+ custom?: string[];
2365
+ }
2366
+ /** 兼容性定义 */
2367
+ interface CompatDefinition {
2368
+ /** 兼容版本 */
2369
+ version: string;
2370
+ /** 最低运行时版本 */
2371
+ minRuntime: string;
2372
+ /** 最高运行时版本(可选) */
2373
+ maxRuntime?: string;
2374
+ /** 是否有破坏性变更 */
2375
+ breaking?: boolean;
2376
+ /** 破坏性变更说明 */
2377
+ breakingChanges?: string[];
2378
+ /** 从哪个版本可以无缝升级 */
2379
+ upgradeFrom?: string[];
2380
+ }
2381
+ /** 组件分类 */
2382
+ type ComponentCategory = 'basic' | 'form' | 'layout' | 'navigation' | 'feedback' | 'display' | 'data' | 'business' | 'chart' | 'other';
2383
+ /** 组件分类列表(用于校验和 UI) */
2384
+ declare const COMPONENT_CATEGORIES: ComponentCategory[];
2385
+ /** SRI 完整性校验 */
2386
+ interface IntegrityDefinition {
2387
+ /** 完整性版本 */
2388
+ version: string;
2389
+ /** 主入口文件哈希 */
2390
+ main: string;
2391
+ /** 所有文件哈希 */
2392
+ files: Record<string, string>;
2393
+ /** 生成时间 */
2394
+ generatedAt: string;
2395
+ /** 哈希算法 */
2396
+ algorithm: 'sha256' | 'sha384' | 'sha512';
2397
+ }
2398
+ /** 组件状态 */
2399
+ type ComponentStatus = 'draft' | 'canary' | 'stable' | 'deprecated' | 'blocked';
2400
+ /** 组件版本元数据(完整) */
2401
+ interface ComponentMeta {
2402
+ /** 组件名称 */
2403
+ name: string;
2404
+ /** 组件版本 */
2405
+ version: string;
2406
+ /** 显示名称 */
2407
+ label: string;
2408
+ /** 组件描述 */
2409
+ description?: string;
2410
+ /** 组件图标 */
2411
+ icon?: string;
2412
+ /** 组件分类 */
2413
+ category: ComponentCategory;
2414
+ /** 组件标签 */
2415
+ tags?: string[];
2416
+ /** 组件作者 */
2417
+ author?: string;
2418
+ /** 属性定义 */
2419
+ props: PropsSchema;
2420
+ /** 事件定义 */
2421
+ events: EventsDefinition;
2422
+ /** 插槽定义 */
2423
+ slots?: SlotsDefinition;
2424
+ /** 能力声明 */
2425
+ capabilities: CapabilitiesDefinition;
2426
+ /** 兼容性 */
2427
+ compat: CompatDefinition;
2428
+ /** 完整性校验 */
2429
+ integrity: IntegrityDefinition;
2430
+ /** 组件状态 */
2431
+ status: ComponentStatus;
2432
+ /** 预览图 */
2433
+ preview?: string;
2434
+ /** 入口文件(相对路径) */
2435
+ entry: string;
2436
+ /** 样式文件(相对路径) */
2437
+ styles?: string[];
2438
+ }
2439
+
2440
+ /**
2441
+ * 资源相关类型定义
2442
+ * 用于管理图片、视频、文档等资源
2443
+ */
2444
+ /**
2445
+ * 资源状态
2446
+ * - active: 活跃
2447
+ * - archived: 已归档
2448
+ */
2449
+ type AssetStatus = 'active' | 'archived';
2450
+ /**
2451
+ * 资源类型
2452
+ * - image: 图片
2453
+ * - video: 视频
2454
+ * - audio: 音频
2455
+ * - document: 文档
2456
+ * - other: 其他
2457
+ */
2458
+ type AssetType = 'image' | 'video' | 'audio' | 'document' | 'other';
2459
+ /**
2460
+ * 资源排序字段
2461
+ */
2462
+ type AssetSortField = 'id' | 'createdAt' | 'size' | 'filename';
2463
+ /**
2464
+ * 资源元数据
2465
+ */
2466
+ interface AssetMeta {
2467
+ /** 原始文件名 */
2468
+ originalName: string;
2469
+ /** MIME 类型 */
2470
+ mimeType: string;
2471
+ /** 文件大小(字节) */
2472
+ size: number;
2473
+ /** 宽度(仅图片/视频) */
2474
+ width?: number;
2475
+ /** 高度(仅图片/视频) */
2476
+ height?: number;
2477
+ /** 时长(仅音频/视频,秒) */
2478
+ duration?: number;
2479
+ /** 扩展信息 */
2480
+ extra?: Record<string, unknown>;
2481
+ }
2482
+ /**
2483
+ * 资源信息
2484
+ */
2485
+ interface Asset {
2486
+ /** 资源 ID */
2487
+ id: string;
2488
+ /** 资源名称 */
2489
+ name: string;
2490
+ /** 资源类型 */
2491
+ type: AssetType;
2492
+ /** 资源状态 */
2493
+ status: AssetStatus;
2494
+ /** 存储路径/URL */
2495
+ url: string;
2496
+ /** 缩略图 URL */
2497
+ thumbnailUrl?: string;
2498
+ /** 元数据 */
2499
+ meta: AssetMeta;
2500
+ /** 标签 */
2501
+ tags?: string[];
2502
+ /** 所属目录 */
2503
+ folderId?: string;
2504
+ /** 创建时间 */
2505
+ createdAt: string;
2506
+ /** 创建者 */
2507
+ createdBy: string;
2508
+ /** 更新时间 */
2509
+ updatedAt?: string;
2510
+ }
2511
+
2512
+ /**
2513
+ * 统一 API 响应类型定义
2514
+ * 所有 API 响应遵循统一格式
2515
+ */
2516
+
2517
+ /**
2518
+ * 统一 API 响应格式
2519
+ */
2520
+ interface ApiResponse<T = unknown> {
2521
+ /** 是否成功 */
2522
+ success: boolean;
2523
+ /** 响应数据 */
2524
+ data?: T;
2525
+ /** 错误码 */
2526
+ code?: ErrorCode | number;
2527
+ /** 错误信息 */
2528
+ message?: string;
2529
+ /** 追踪 ID */
2530
+ traceId?: string;
2531
+ /** 请求 ID */
2532
+ requestId?: string;
2533
+ /** 时间戳 */
2534
+ timestamp?: number;
2535
+ }
2536
+ /**
2537
+ * 分页 API 响应格式
2538
+ */
2539
+ interface PaginatedApiResponse<T> extends ApiResponse<T[]> {
2540
+ /** 分页信息 */
2541
+ pagination?: {
2542
+ /** 当前页码 */
2543
+ page: number;
2544
+ /** 每页数量 */
2545
+ pageSize: number;
2546
+ /** 总数量 */
2547
+ total: number;
2548
+ /** 总页数 */
2549
+ totalPages: number;
2550
+ };
2551
+ }
2552
+ /**
2553
+ * 标准请求头
2554
+ */
2555
+ interface StandardRequestHeaders {
2556
+ /** 追踪 ID */
2557
+ 'x-trace-id'?: string;
2558
+ /** 请求 ID */
2559
+ 'x-request-id'?: string;
2560
+ /** 页面版本 ID */
2561
+ 'x-page-version-id'?: string;
2562
+ /** 组件版本 */
2563
+ 'x-component-version'?: string;
2564
+ /** 用户 ID */
2565
+ 'x-user-id'?: string;
2566
+ /** 设备 ID */
2567
+ 'x-device-id'?: string;
2568
+ /** 渠道 */
2569
+ 'x-channel'?: string;
2570
+ /** 应用 ID */
2571
+ 'x-app-id'?: string;
2572
+ }
2573
+ /**
2574
+ * 标准响应头
2575
+ */
2576
+ interface StandardResponseHeaders {
2577
+ /** 追踪 ID */
2578
+ 'x-trace-id'?: string;
2579
+ /** 请求 ID */
2580
+ 'x-request-id'?: string;
2581
+ /** 服务器时间戳 */
2582
+ 'x-server-time'?: string;
2583
+ /** 缓存状态 */
2584
+ 'x-cache-status'?: 'HIT' | 'MISS' | 'BYPASS';
2585
+ }
2586
+ /**
2587
+ * 健康检查响应
2588
+ */
2589
+ interface HealthCheckResponse {
2590
+ /** 状态 */
2591
+ status: 'healthy' | 'degraded' | 'unhealthy';
2592
+ /** 版本 */
2593
+ version: string;
2594
+ /** 服务名 */
2595
+ service: string;
2596
+ /** 依赖服务状态 */
2597
+ dependencies?: Record<string, DependencyHealth>;
2598
+ /** 时间戳 */
2599
+ timestamp: number;
2600
+ }
2601
+ /**
2602
+ * 依赖服务健康状态
2603
+ */
2604
+ interface DependencyHealth {
2605
+ /** 状态 */
2606
+ status: 'up' | 'down';
2607
+ /** 延迟(ms) */
2608
+ latency?: number;
2609
+ /** 错误信息 */
2610
+ error?: string;
2611
+ }
2612
+ /**
2613
+ * 批量操作请求
2614
+ */
2615
+ interface BatchRequest<T> {
2616
+ /** 操作列表 */
2617
+ items: T[];
2618
+ /** 是否原子操作(全部成功或全部失败) */
2619
+ atomic?: boolean;
2620
+ }
2621
+ /**
2622
+ * 批量操作结果
2623
+ */
2624
+ interface BatchResult<T> {
2625
+ /** 成功数量 */
2626
+ successCount: number;
2627
+ /** 失败数量 */
2628
+ failedCount: number;
2629
+ /** 结果列表 */
2630
+ results: BatchItemResult<T>[];
2631
+ }
2632
+ /**
2633
+ * 单个批量操作项结果
2634
+ */
2635
+ interface BatchItemResult<T> {
2636
+ /** 索引 */
2637
+ index: number;
2638
+ /** 是否成功 */
2639
+ success: boolean;
2640
+ /** 数据 */
2641
+ data?: T;
2642
+ /** 错误码 */
2643
+ code?: number;
2644
+ /** 错误信息 */
2645
+ message?: string;
2646
+ }
2647
+ /**
2648
+ * 上传凭证请求
2649
+ */
2650
+ interface UploadCredentialRequest {
2651
+ /** 文件名 */
2652
+ filename: string;
2653
+ /** 文件类型 */
2654
+ contentType: string;
2655
+ /** 文件大小 */
2656
+ size: number;
2657
+ /** 目录 */
2658
+ directory?: string;
2659
+ }
2660
+ /**
2661
+ * 上传凭证响应
2662
+ */
2663
+ interface UploadCredentialResponse {
2664
+ /** 上传 URL */
2665
+ uploadUrl: string;
2666
+ /** 上传方法 */
2667
+ method: 'PUT' | 'POST';
2668
+ /** 需要的请求头 */
2669
+ headers: Record<string, string>;
2670
+ /** 表单字段(POST multipart 时) */
2671
+ formFields?: Record<string, string>;
2672
+ /** 最终文件 URL */
2673
+ fileUrl: string;
2674
+ /** 凭证过期时间 */
2675
+ expiresAt: string;
2676
+ }
2677
+ /**
2678
+ * WebSocket 消息类型
2679
+ */
2680
+ type WsMessageType = 'ping' | 'pong' | 'subscribe' | 'unsubscribe' | 'publish' | 'error';
2681
+ /**
2682
+ * WebSocket 消息
2683
+ */
2684
+ interface WsMessage<T = unknown> {
2685
+ /** 消息类型 */
2686
+ type: WsMessageType;
2687
+ /** 频道 */
2688
+ channel?: string;
2689
+ /** 消息数据 */
2690
+ data?: T;
2691
+ /** 消息 ID */
2692
+ id?: string;
2693
+ /** 时间戳 */
2694
+ timestamp: number;
2695
+ }
2696
+
2697
+ /**
2698
+ * 表达式引擎类型定义
2699
+ * 无 eval 的安全 DSL,支持发布期校验
2700
+ */
2701
+ /**
2702
+ * 表达式类型
2703
+ */
2704
+ type ExpressionType = 'literal' | 'identifier' | 'member' | 'index' | 'call' | 'binary' | 'unary' | 'conditional' | 'array' | 'object';
2705
+ /**
2706
+ * 表达式 AST 节点基类
2707
+ */
2708
+ interface ExpressionNode {
2709
+ /** 节点类型 */
2710
+ type: ExpressionType;
2711
+ /** 原始表达式 */
2712
+ raw?: string;
2713
+ /** 起始位置 */
2714
+ start?: number;
2715
+ /** 结束位置 */
2716
+ end?: number;
2717
+ }
2718
+ /**
2719
+ * 字面量节点
2720
+ */
2721
+ interface LiteralNode extends ExpressionNode {
2722
+ type: 'literal';
2723
+ value: string | number | boolean | null;
2724
+ }
2725
+ /**
2726
+ * 标识符节点
2727
+ */
2728
+ interface IdentifierNode extends ExpressionNode {
2729
+ type: 'identifier';
2730
+ name: string;
2731
+ }
2732
+ /**
2733
+ * 成员访问节点
2734
+ */
2735
+ interface MemberNode extends ExpressionNode {
2736
+ type: 'member';
2737
+ object: ExpressionNode;
2738
+ property: string;
2739
+ }
2740
+ /**
2741
+ * 函数调用节点
2742
+ */
2743
+ interface CallNode extends ExpressionNode {
2744
+ type: 'call';
2745
+ callee: string;
2746
+ arguments: ExpressionNode[];
2747
+ }
2748
+ /**
2749
+ * 二元运算节点
2750
+ */
2751
+ interface BinaryNode extends ExpressionNode {
2752
+ type: 'binary';
2753
+ operator: BinaryOperator;
2754
+ left: ExpressionNode;
2755
+ right: ExpressionNode;
2756
+ }
2757
+ /**
2758
+ * 二元运算符
2759
+ */
2760
+ type BinaryOperator = '+' | '-' | '*' | '/' | '%' | '==' | '!=' | '>' | '<' | '>=' | '<=' | '&&' | '||' | '??';
2761
+ /**
2762
+ * 一元运算符
2763
+ */
2764
+ type UnaryOperator = '!' | '-' | '+';
2765
+ /**
2766
+ * 内置函数定义
2767
+ */
2768
+ interface BuiltinFunction {
2769
+ /** 函数名 */
2770
+ name: string;
2771
+ /** 描述 */
2772
+ description: string;
2773
+ /** 参数定义 */
2774
+ params: FunctionParam[];
2775
+ /** 返回类型 */
2776
+ returnType: ValueType;
2777
+ /** 示例 */
2778
+ examples?: string[];
2779
+ }
2780
+ /**
2781
+ * 函数参数定义
2782
+ */
2783
+ interface FunctionParam {
2784
+ /** 参数名 */
2785
+ name: string;
2786
+ /** 参数类型 */
2787
+ type: ValueType;
2788
+ /** 是否必填 */
2789
+ required: boolean;
2790
+ /** 默认值 */
2791
+ defaultValue?: unknown;
2792
+ /** 描述 */
2793
+ description?: string;
2794
+ }
2795
+ /**
2796
+ * 值类型
2797
+ */
2798
+ type ValueType = 'string' | 'number' | 'boolean' | 'array' | 'object' | 'null' | 'any' | 'void';
2799
+ /**
2800
+ * 内置函数白名单
2801
+ * 表达式中只能调用这些函数
2802
+ */
2803
+ declare const BUILTIN_FUNCTIONS: BuiltinFunction[];
2804
+ /**
2805
+ * 内置函数名称集合(用于快速校验)
2806
+ */
2807
+ declare const BUILTIN_FUNCTION_NAMES: Set<string>;
2808
+ /**
2809
+ * 表达式上下文
2810
+ * 表达式执行时可访问的变量
2811
+ */
2812
+ interface ExpressionContext {
2813
+ /** 页面状态 */
2814
+ state: Record<string, unknown>;
2815
+ /** 查询结果 */
2816
+ query: Record<string, unknown>;
2817
+ /** 运行时上下文 */
2818
+ context: {
2819
+ userId?: string;
2820
+ deviceId?: string;
2821
+ channel?: string;
2822
+ pageVersionId?: string;
2823
+ [key: string]: unknown;
2824
+ };
2825
+ /** 事件参数 */
2826
+ event?: Record<string, unknown>;
2827
+ /** 循环变量 */
2828
+ item?: unknown;
2829
+ /** 循环索引 */
2830
+ index?: number;
2831
+ }
2832
+ /**
2833
+ * 表达式允许访问的根变量
2834
+ */
2835
+ declare const ALLOWED_ROOT_VARIABLES: readonly ["state", "query", "context", "event", "item", "index"];
2836
+ /**
2837
+ * 表达式校验结果
2838
+ */
2839
+ interface ExpressionValidationResult {
2840
+ /** 是否有效 */
2841
+ valid: boolean;
2842
+ /** 错误列表 */
2843
+ errors: ExpressionError[];
2844
+ /** 警告列表 */
2845
+ warnings: ExpressionWarning[];
2846
+ /** 引用的变量路径 */
2847
+ referencedPaths: string[];
2848
+ /** 调用的函数 */
2849
+ calledFunctions: string[];
2850
+ }
2851
+ /**
2852
+ * 表达式错误
2853
+ */
2854
+ interface ExpressionError {
2855
+ /** 错误类型 */
2856
+ type: ExpressionErrorType;
2857
+ /** 错误消息 */
2858
+ message: string;
2859
+ /** 位置 */
2860
+ position?: {
2861
+ start: number;
2862
+ end: number;
2863
+ };
2864
+ }
2865
+ /**
2866
+ * 表达式错误类型
2867
+ */
2868
+ type ExpressionErrorType = 'SYNTAX_ERROR' | 'UNKNOWN_FUNCTION' | 'INVALID_ARGUMENT' | 'UNKNOWN_VARIABLE' | 'TYPE_MISMATCH' | 'ACCESS_DENIED';
2869
+ /**
2870
+ * 表达式警告
2871
+ */
2872
+ interface ExpressionWarning {
2873
+ /** 警告类型 */
2874
+ type: 'DEPRECATED' | 'PERFORMANCE' | 'NULLABLE';
2875
+ /** 警告消息 */
2876
+ message: string;
2877
+ /** 位置 */
2878
+ position?: {
2879
+ start: number;
2880
+ end: number;
2881
+ };
2882
+ }
2883
+ /**
2884
+ * 表达式绑定
2885
+ * 用于属性值的动态绑定
2886
+ */
2887
+ interface ExpressionBinding {
2888
+ /** 是否为表达式 */
2889
+ __isExpression: true;
2890
+ /** 表达式字符串 */
2891
+ expression: string;
2892
+ /** 默认值(表达式失败时使用) */
2893
+ fallback?: unknown;
2894
+ }
2895
+ /**
2896
+ * 检查是否为表达式绑定
2897
+ */
2898
+ declare function isExpressionBinding(value: unknown): value is ExpressionBinding;
2899
+ /**
2900
+ * 创建表达式绑定
2901
+ */
2902
+ declare function createExpressionBinding(expression: string, fallback?: unknown): ExpressionBinding;
2903
+
2904
+ /**
2905
+ * 活动业务类型定义
2906
+ * 领取、签到、抽奖、预约等活动规则配置
2907
+ */
2908
+ /**
2909
+ * 活动类型
2910
+ */
2911
+ type ActivityType = 'claim' | 'signin' | 'lottery' | 'reserve' | 'task' | 'bind' | 'survey' | 'share' | 'invite' | 'custom';
2912
+ /**
2913
+ * 活动状态
2914
+ */
2915
+ type ActivityStatus = 'draft' | 'pending' | 'active' | 'paused' | 'ended' | 'cancelled';
2916
+ /**
2917
+ * 活动基础信息
2918
+ */
2919
+ interface Activity {
2920
+ /** 活动 ID */
2921
+ id: string;
2922
+ /** 活动名称 */
2923
+ name: string;
2924
+ /** 活动类型 */
2925
+ type: ActivityType;
2926
+ /** 活动描述 */
2927
+ description?: string;
2928
+ /** 活动状态 */
2929
+ status: ActivityStatus;
2930
+ /** 开始时间 */
2931
+ startAt: string;
2932
+ /** 结束时间 */
2933
+ endAt: string;
2934
+ /** 活动规则 */
2935
+ rules: ActivityRules;
2936
+ /** 关联的页面 UID */
2937
+ pageUid?: string;
2938
+ /** 创建时间 */
2939
+ createdAt: string;
2940
+ /** 创建者 */
2941
+ createdBy: string;
2942
+ /** 更新时间 */
2943
+ updatedAt?: string;
2944
+ }
2945
+ /**
2946
+ * 活动规则(通用)
2947
+ */
2948
+ interface ActivityRules {
2949
+ /** 参与条件 */
2950
+ eligibility?: EligibilityRules;
2951
+ /** 限制规则 */
2952
+ limits?: LimitRules;
2953
+ /** 奖励规则 */
2954
+ rewards?: RewardRules;
2955
+ /** 风控规则 */
2956
+ risk?: RiskRules;
2957
+ /** 扩展配置(不同活动类型特有) */
2958
+ extra?: Record<string, unknown>;
2959
+ }
2960
+ /**
2961
+ * 参与条件
2962
+ */
2963
+ interface EligibilityRules {
2964
+ /** 是否需要登录 */
2965
+ requireLogin?: boolean;
2966
+ /** 是否需要实名 */
2967
+ requireRealName?: boolean;
2968
+ /** 是否需要绑定手机 */
2969
+ requirePhone?: boolean;
2970
+ /** 会员等级要求 */
2971
+ minMemberLevel?: number;
2972
+ /** 用户白名单 */
2973
+ whitelistUsers?: string[];
2974
+ /** 用户黑名单 */
2975
+ blacklistUsers?: string[];
2976
+ /** 渠道限制 */
2977
+ allowedChannels?: string[];
2978
+ /** 地区限制 */
2979
+ allowedRegions?: string[];
2980
+ /** 自定义条件表达式 */
2981
+ customCondition?: string;
2982
+ }
2983
+ /**
2984
+ * 限制规则
2985
+ */
2986
+ interface LimitRules {
2987
+ /** 总参与次数限制 */
2988
+ totalLimit?: number;
2989
+ /** 每用户参与次数限制 */
2990
+ perUserLimit?: number;
2991
+ /** 每日参与次数限制 */
2992
+ dailyLimit?: number;
2993
+ /** 每用户每日限制 */
2994
+ perUserDailyLimit?: number;
2995
+ /** 库存限制(奖品数量) */
2996
+ stockLimit?: number;
2997
+ /** 并发限制 */
2998
+ concurrentLimit?: number;
2999
+ /** 时段限制 */
3000
+ timeSlots?: TimeSlot[];
3001
+ }
3002
+ /**
3003
+ * 时段定义
3004
+ */
3005
+ interface TimeSlot {
3006
+ /** 开始时间(HH:mm 格式) */
3007
+ startTime: string;
3008
+ /** 结束时间 */
3009
+ endTime: string;
3010
+ /** 生效的星期几(0-6,0 为周日) */
3011
+ daysOfWeek?: number[];
3012
+ }
3013
+ /**
3014
+ * 奖励规则
3015
+ */
3016
+ interface RewardRules {
3017
+ /** 奖励类型 */
3018
+ type: RewardType;
3019
+ /** 奖励配置 */
3020
+ config: RewardConfig;
3021
+ /** 发放方式 */
3022
+ deliveryMethod: RewardDeliveryMethod;
3023
+ /** 发放延迟(秒) */
3024
+ deliveryDelay?: number;
3025
+ }
3026
+ /**
3027
+ * 奖励类型
3028
+ */
3029
+ type RewardType = 'coupon' | 'points' | 'virtual' | 'physical' | 'balance' | 'membership' | 'custom';
3030
+ /**
3031
+ * 奖励配置
3032
+ */
3033
+ interface RewardConfig {
3034
+ /** 奖励 ID */
3035
+ rewardId?: string;
3036
+ /** 奖励名称 */
3037
+ name: string;
3038
+ /** 奖励数量/金额 */
3039
+ amount?: number;
3040
+ /** 奖励单位 */
3041
+ unit?: string;
3042
+ /** 有效期(天) */
3043
+ validDays?: number;
3044
+ /** 额外配置 */
3045
+ extra?: Record<string, unknown>;
3046
+ }
3047
+ /**
3048
+ * 奖励发放方式
3049
+ */
3050
+ type RewardDeliveryMethod = 'instant' | 'async' | 'manual' | 'scheduled';
3051
+ /**
3052
+ * 风控规则
3053
+ */
3054
+ interface RiskRules {
3055
+ /** 是否启用风控 */
3056
+ enabled?: boolean;
3057
+ /** 频控(每分钟) */
3058
+ rateLimit?: number;
3059
+ /** 设备指纹校验 */
3060
+ deviceCheck?: boolean;
3061
+ /** IP 限制 */
3062
+ ipLimit?: number;
3063
+ /** 需要验证码的阈值 */
3064
+ captchaThreshold?: number;
3065
+ /** 黑名单 IP */
3066
+ blacklistIps?: string[];
3067
+ }
3068
+ /**
3069
+ * 领取活动规则
3070
+ */
3071
+ interface ClaimActivityRules extends ActivityRules {
3072
+ extra: {
3073
+ /** 领取类型 */
3074
+ claimType: 'single' | 'multiple' | 'choice';
3075
+ /** 可选奖品列表(choice 类型) */
3076
+ rewardOptions?: RewardOption[];
3077
+ /** 是否需要填写收货地址(实物奖品) */
3078
+ requireAddress?: boolean;
3079
+ /** 是否需要确认协议 */
3080
+ requireAgreement?: boolean;
3081
+ };
3082
+ }
3083
+ /**
3084
+ * 奖品选项
3085
+ */
3086
+ interface RewardOption {
3087
+ /** 选项 ID */
3088
+ id: string;
3089
+ /** 选项名称 */
3090
+ name: string;
3091
+ /** 奖励配置 */
3092
+ reward: RewardConfig;
3093
+ /** 库存 */
3094
+ stock?: number;
3095
+ /** 排序 */
3096
+ order?: number;
3097
+ }
3098
+ /**
3099
+ * 签到活动规则
3100
+ */
3101
+ interface SigninActivityRules extends ActivityRules {
3102
+ extra: {
3103
+ /** 签到周期类型 */
3104
+ cycleType: 'daily' | 'weekly' | 'monthly' | 'custom';
3105
+ /** 自定义周期天数 */
3106
+ cycleDays?: number;
3107
+ /** 是否允许补签 */
3108
+ allowMakeup?: boolean;
3109
+ /** 补签扣除的积分/次数 */
3110
+ makeupCost?: number;
3111
+ /** 最大补签次数 */
3112
+ maxMakeupCount?: number;
3113
+ /** 连续签到奖励 */
3114
+ streakRewards?: StreakReward[];
3115
+ /** 累计签到奖励 */
3116
+ accumulateRewards?: AccumulateReward[];
3117
+ /** 每日基础奖励 */
3118
+ dailyReward?: RewardConfig;
3119
+ };
3120
+ }
3121
+ /**
3122
+ * 连续签到奖励
3123
+ */
3124
+ interface StreakReward {
3125
+ /** 连续天数 */
3126
+ days: number;
3127
+ /** 奖励配置 */
3128
+ reward: RewardConfig;
3129
+ }
3130
+ /**
3131
+ * 累计签到奖励
3132
+ */
3133
+ interface AccumulateReward {
3134
+ /** 累计天数 */
3135
+ days: number;
3136
+ /** 奖励配置 */
3137
+ reward: RewardConfig;
3138
+ }
3139
+ /**
3140
+ * 抽奖活动规则
3141
+ */
3142
+ interface LotteryActivityRules extends ActivityRules {
3143
+ extra: {
3144
+ /** 抽奖类型 */
3145
+ lotteryType: 'wheel' | 'box' | 'card' | 'scratch' | 'slot';
3146
+ /** 奖池配置 */
3147
+ prizePool: PrizePoolConfig;
3148
+ /** 抽奖消耗 */
3149
+ cost?: LotteryCost;
3150
+ /** 保底规则 */
3151
+ guarantee?: GuaranteeRule;
3152
+ /** 是否显示中奖记录 */
3153
+ showWinners?: boolean;
3154
+ /** 中奖公示数量 */
3155
+ winnersDisplayCount?: number;
3156
+ };
3157
+ }
3158
+ /**
3159
+ * 奖池配置
3160
+ */
3161
+ interface PrizePoolConfig {
3162
+ /** 奖品列表 */
3163
+ prizes: PrizeConfig[];
3164
+ /** 是否启用概率调整 */
3165
+ dynamicProbability?: boolean;
3166
+ /** 概率模式 */
3167
+ probabilityMode: 'fixed' | 'weight' | 'stock';
3168
+ }
3169
+ /**
3170
+ * 奖品配置
3171
+ */
3172
+ interface PrizeConfig {
3173
+ /** 奖品 ID */
3174
+ id: string;
3175
+ /** 奖品名称 */
3176
+ name: string;
3177
+ /** 奖品图片 */
3178
+ image?: string;
3179
+ /** 奖励配置 */
3180
+ reward: RewardConfig;
3181
+ /** 概率/权重 */
3182
+ probability: number;
3183
+ /** 库存 */
3184
+ stock?: number;
3185
+ /** 已发放数量 */
3186
+ issued?: number;
3187
+ /** 每日发放上限 */
3188
+ dailyLimit?: number;
3189
+ /** 每用户中奖上限 */
3190
+ perUserLimit?: number;
3191
+ /** 是否为谢谢参与 */
3192
+ isDefault?: boolean;
3193
+ /** 排序(显示用) */
3194
+ order?: number;
3195
+ }
3196
+ /**
3197
+ * 抽奖消耗
3198
+ */
3199
+ interface LotteryCost {
3200
+ /** 消耗类型 */
3201
+ type: 'free' | 'points' | 'times' | 'token';
3202
+ /** 消耗数量 */
3203
+ amount: number;
3204
+ /** 免费次数 */
3205
+ freeCount?: number;
3206
+ /** 每日免费次数 */
3207
+ dailyFreeCount?: number;
3208
+ }
3209
+ /**
3210
+ * 保底规则
3211
+ */
3212
+ interface GuaranteeRule {
3213
+ /** 是否启用 */
3214
+ enabled: boolean;
3215
+ /** 保底次数 */
3216
+ count: number;
3217
+ /** 保底奖品 ID */
3218
+ prizeId: string;
3219
+ /** 是否重置计数(获得保底后) */
3220
+ resetAfterHit?: boolean;
3221
+ }
3222
+ /**
3223
+ * 预约活动规则
3224
+ */
3225
+ interface ReserveActivityRules extends ActivityRules {
3226
+ extra: {
3227
+ /** 预约类型 */
3228
+ reserveType: 'product' | 'event' | 'service';
3229
+ /** 预约需要的信息 */
3230
+ requiredFields: ReserveField[];
3231
+ /** 提醒设置 */
3232
+ reminder?: ReminderConfig;
3233
+ /** 预约生效时间 */
3234
+ effectiveAt?: string;
3235
+ /** 是否可取消 */
3236
+ cancelable?: boolean;
3237
+ /** 取消截止时间(相对于生效时间的秒数) */
3238
+ cancelDeadline?: number;
3239
+ };
3240
+ }
3241
+ /**
3242
+ * 预约信息字段
3243
+ */
3244
+ interface ReserveField {
3245
+ /** 字段名 */
3246
+ name: string;
3247
+ /** 字段标签 */
3248
+ label: string;
3249
+ /** 字段类型 */
3250
+ type: 'text' | 'phone' | 'email' | 'date' | 'time' | 'select' | 'address';
3251
+ /** 是否必填 */
3252
+ required: boolean;
3253
+ /** 选项(select 类型) */
3254
+ options?: string[];
3255
+ /** 校验规则 */
3256
+ validation?: string;
3257
+ }
3258
+ /**
3259
+ * 提醒配置
3260
+ */
3261
+ interface ReminderConfig {
3262
+ /** 是否启用 */
3263
+ enabled: boolean;
3264
+ /** 提醒方式 */
3265
+ methods: ('sms' | 'push' | 'email')[];
3266
+ /** 提前提醒时间(分钟) */
3267
+ advanceMinutes: number[];
3268
+ }
3269
+ /**
3270
+ * 任务活动规则
3271
+ */
3272
+ interface TaskActivityRules extends ActivityRules {
3273
+ extra: {
3274
+ /** 任务列表 */
3275
+ tasks: TaskConfig[];
3276
+ /** 是否按顺序完成 */
3277
+ sequential?: boolean;
3278
+ /** 全部完成奖励 */
3279
+ completionReward?: RewardConfig;
3280
+ };
3281
+ }
3282
+ /**
3283
+ * 任务配置
3284
+ */
3285
+ interface TaskConfig {
3286
+ /** 任务 ID */
3287
+ id: string;
3288
+ /** 任务名称 */
3289
+ name: string;
3290
+ /** 任务描述 */
3291
+ description?: string;
3292
+ /** 任务类型 */
3293
+ type: TaskType;
3294
+ /** 目标值 */
3295
+ target: number;
3296
+ /** 任务奖励 */
3297
+ reward: RewardConfig;
3298
+ /** 任务条件配置 */
3299
+ condition: TaskCondition;
3300
+ /** 是否可重复 */
3301
+ repeatable?: boolean;
3302
+ /** 重复周期 */
3303
+ repeatCycle?: 'daily' | 'weekly' | 'monthly';
3304
+ }
3305
+ /**
3306
+ * 任务类型
3307
+ */
3308
+ type TaskType = 'visit' | 'share' | 'invite' | 'purchase' | 'browse' | 'interact' | 'bind' | 'profile' | 'custom';
3309
+ /**
3310
+ * 任务条件
3311
+ */
3312
+ interface TaskCondition {
3313
+ /** 条件类型 */
3314
+ type: string;
3315
+ /** 条件参数 */
3316
+ params: Record<string, unknown>;
3317
+ /** 自定义检查表达式 */
3318
+ expression?: string;
3319
+ }
3320
+ /**
3321
+ * 用户活动状态
3322
+ */
3323
+ interface UserActivityState {
3324
+ /** 活动 ID */
3325
+ activityId: string;
3326
+ /** 用户 ID */
3327
+ userId: string;
3328
+ /** 参与次数 */
3329
+ participationCount: number;
3330
+ /** 今日参与次数 */
3331
+ todayCount: number;
3332
+ /** 剩余次数(如有限制) */
3333
+ remainingCount?: number;
3334
+ /** 是否已领取/完成 */
3335
+ completed: boolean;
3336
+ /** 最后参与时间 */
3337
+ lastParticipatedAt?: string;
3338
+ /** 扩展状态数据 */
3339
+ extra?: Record<string, unknown>;
3340
+ }
3341
+ /**
3342
+ * 签到状态(扩展)
3343
+ */
3344
+ interface SigninState extends UserActivityState {
3345
+ extra: {
3346
+ /** 当前周期签到记录 */
3347
+ signedDays: string[];
3348
+ /** 连续签到天数 */
3349
+ streakDays: number;
3350
+ /** 累计签到天数 */
3351
+ totalDays: number;
3352
+ /** 补签剩余次数 */
3353
+ makeupRemaining: number;
3354
+ /** 下一个奖励 */
3355
+ nextReward?: {
3356
+ type: 'streak' | 'accumulate';
3357
+ days: number;
3358
+ reward: RewardConfig;
3359
+ };
3360
+ };
3361
+ }
3362
+ /**
3363
+ * 抽奖状态(扩展)
3364
+ */
3365
+ interface LotteryState extends UserActivityState {
3366
+ extra: {
3367
+ /** 免费次数剩余 */
3368
+ freeRemaining: number;
3369
+ /** 保底进度 */
3370
+ guaranteeProgress?: number;
3371
+ /** 今日中奖记录 */
3372
+ todayWins?: string[];
3373
+ };
3374
+ }
3375
+ /**
3376
+ * 任务状态(扩展)
3377
+ */
3378
+ interface TaskState extends UserActivityState {
3379
+ extra: {
3380
+ /** 各任务进度 */
3381
+ taskProgress: Record<string, {
3382
+ current: number;
3383
+ target: number;
3384
+ completed: boolean;
3385
+ claimedReward: boolean;
3386
+ }>;
3387
+ /** 已完成任务数 */
3388
+ completedTaskCount: number;
3389
+ /** 总任务数 */
3390
+ totalTaskCount: number;
3391
+ };
3392
+ }
3393
+
3394
+ /**
3395
+ * Outbox 和 Worker 事件类型定义
3396
+ * 用于异步任务处理、事件驱动架构
3397
+ */
3398
+ /**
3399
+ * Outbox 事件状态
3400
+ */
3401
+ type OutboxEventStatus = 'pending' | 'processing' | 'completed' | 'failed' | 'dead' | 'cancelled';
3402
+ /**
3403
+ * Outbox 事件基础结构
3404
+ */
3405
+ interface OutboxEvent<T = unknown> {
3406
+ /** 事件 ID(用于幂等) */
3407
+ id: string;
3408
+ /** 事件类型 */
3409
+ type: OutboxEventType;
3410
+ /** 事件数据 */
3411
+ payload: T;
3412
+ /** 事件状态 */
3413
+ status: OutboxEventStatus;
3414
+ /** 重试次数 */
3415
+ retryCount: number;
3416
+ /** 最大重试次数 */
3417
+ maxRetries: number;
3418
+ /** 下次重试时间 */
3419
+ nextRetryAt?: string;
3420
+ /** 最后错误信息 */
3421
+ lastError?: string;
3422
+ /** 创建时间 */
3423
+ createdAt: string;
3424
+ /** 更新时间 */
3425
+ updatedAt?: string;
3426
+ /** 完成时间 */
3427
+ completedAt?: string;
1547
3428
  /** 追踪 ID */
1548
- 'x-trace-id'?: string;
1549
- /** 请求 ID */
1550
- 'x-request-id'?: string;
1551
- /** 服务器时间戳 */
1552
- 'x-server-time'?: string;
1553
- /** 缓存状态 */
1554
- 'x-cache-status'?: 'HIT' | 'MISS' | 'BYPASS';
3429
+ traceId?: string;
3430
+ /** 优先级(数字越小优先级越高) */
3431
+ priority?: number;
3432
+ /** 聚合 ID(用于确保同一聚合的事件顺序处理) */
3433
+ aggregateId?: string;
3434
+ }
3435
+ /**
3436
+ * Outbox 事件类型
3437
+ */
3438
+ type OutboxEventType = 'page.published' | 'page.rolled_back' | 'page.static_export' | 'page.cdn_refresh' | 'page.cdn_preheat' | 'component.registered' | 'component.blocked' | 'component.unblocked' | 'component.deprecated' | 'activity.started' | 'activity.ended' | 'activity.reward_deliver' | 'activity.stock_alert' | 'audit.log' | 'audit.alert' | 'notification.send' | 'notification.batch' | 'analytics.aggregate' | 'analytics.report' | 'sync.external' | 'sync.cache' | `custom.${string}`;
3439
+ /**
3440
+ * 页面发布事件 Payload
3441
+ */
3442
+ interface PagePublishedPayload {
3443
+ /** 页面 UID */
3444
+ pageUid: string;
3445
+ /** 页面版本 ID */
3446
+ pageVersionId: string;
3447
+ /** 发布渠道 */
3448
+ channel: 'preview' | 'prod' | 'gray';
3449
+ /** 发布者 */
3450
+ publishedBy: string;
3451
+ /** 变更摘要 */
3452
+ changeSummary?: string;
3453
+ /** 需要刷新的 CDN URL */
3454
+ cdnUrls?: string[];
3455
+ }
3456
+ /**
3457
+ * 页面回滚事件 Payload
3458
+ */
3459
+ interface PageRolledBackPayload {
3460
+ /** 页面 UID */
3461
+ pageUid: string;
3462
+ /** 原版本 ID */
3463
+ fromVersionId: string;
3464
+ /** 目标版本 ID */
3465
+ toVersionId: string;
3466
+ /** 回滚者 */
3467
+ rolledBackBy: string;
3468
+ /** 回滚原因 */
3469
+ reason: string;
3470
+ }
3471
+ /**
3472
+ * 静态导出事件 Payload
3473
+ */
3474
+ interface StaticExportPayload {
3475
+ /** 页面 UID */
3476
+ pageUid: string;
3477
+ /** 页面版本 ID */
3478
+ pageVersionId: string;
3479
+ /** 导出目标路径 */
3480
+ targetPath: string;
3481
+ /** 包含的文件类型 */
3482
+ fileTypes: ('page.json' | 'manifest.json' | 'bootstrap.json')[];
3483
+ /** 是否预热 CDN */
3484
+ preheatCdn?: boolean;
1555
3485
  }
1556
3486
  /**
1557
- * 健康检查响应
3487
+ * CDN 刷新事件 Payload
1558
3488
  */
1559
- interface HealthCheckResponse {
1560
- /** 状态 */
1561
- status: 'healthy' | 'degraded' | 'unhealthy';
1562
- /** 版本 */
1563
- version: string;
1564
- /** 服务名 */
1565
- service: string;
1566
- /** 依赖服务状态 */
1567
- dependencies?: Record<string, DependencyHealth>;
1568
- /** 时间戳 */
1569
- timestamp: number;
3489
+ interface CdnRefreshPayload {
3490
+ /** 刷新类型 */
3491
+ type: 'url' | 'directory';
3492
+ /** URL 列表或目录路径 */
3493
+ targets: string[];
3494
+ /** CDN 提供商 */
3495
+ provider?: string;
1570
3496
  }
1571
3497
  /**
1572
- * 依赖服务健康状态
3498
+ * 组件阻断事件 Payload
1573
3499
  */
1574
- interface DependencyHealth {
1575
- /** 状态 */
1576
- status: 'up' | 'down';
1577
- /** 延迟(ms) */
1578
- latency?: number;
3500
+ interface ComponentBlockedPayload {
3501
+ /** 组件名称 */
3502
+ componentName: string;
3503
+ /** 版本范围 */
3504
+ versionRange: string;
3505
+ /** 阻断原因 */
3506
+ reason: string;
3507
+ /** 阻断者 */
3508
+ blockedBy: string;
3509
+ /** 是否紧急 */
3510
+ urgent: boolean;
3511
+ /** 受影响的页面数量 */
3512
+ affectedPageCount?: number;
3513
+ }
3514
+ /**
3515
+ * 奖励发放事件 Payload
3516
+ */
3517
+ interface RewardDeliverPayload {
3518
+ /** 活动 ID */
3519
+ activityId: string;
3520
+ /** 用户 ID */
3521
+ userId: string;
3522
+ /** 奖励类型 */
3523
+ rewardType: string;
3524
+ /** 奖励 ID */
3525
+ rewardId: string;
3526
+ /** 奖励数量 */
3527
+ amount: number;
3528
+ /** 发放原因 */
3529
+ reason: string;
3530
+ /** 幂等键 */
3531
+ idempotencyKey: string;
3532
+ /** 过期时间 */
3533
+ expiresAt?: string;
3534
+ }
3535
+ /**
3536
+ * 通知发送事件 Payload
3537
+ */
3538
+ interface NotificationSendPayload {
3539
+ /** 接收者 ID */
3540
+ recipientId: string;
3541
+ /** 通知渠道 */
3542
+ channels: ('push' | 'sms' | 'email' | 'wechat')[];
3543
+ /** 通知模板 ID */
3544
+ templateId: string;
3545
+ /** 模板参数 */
3546
+ templateParams: Record<string, string>;
3547
+ /** 优先级 */
3548
+ priority?: 'high' | 'normal' | 'low';
3549
+ /** 发送时间(定时发送) */
3550
+ scheduledAt?: string;
3551
+ }
3552
+ /**
3553
+ * Worker 任务状态
3554
+ */
3555
+ type WorkerTaskStatus = 'queued' | 'running' | 'completed' | 'failed' | 'timeout' | 'cancelled';
3556
+ /**
3557
+ * Worker 任务基础结构
3558
+ */
3559
+ interface WorkerTask<T = unknown> {
3560
+ /** 任务 ID */
3561
+ id: string;
3562
+ /** 任务类型 */
3563
+ type: string;
3564
+ /** 任务数据 */
3565
+ data: T;
3566
+ /** 任务状态 */
3567
+ status: WorkerTaskStatus;
3568
+ /** Worker ID */
3569
+ workerId?: string;
3570
+ /** 开始时间 */
3571
+ startedAt?: string;
3572
+ /** 完成时间 */
3573
+ completedAt?: string;
3574
+ /** 执行时长(ms) */
3575
+ duration?: number;
1579
3576
  /** 错误信息 */
1580
3577
  error?: string;
3578
+ /** 进度(0-100) */
3579
+ progress?: number;
3580
+ /** 创建时间 */
3581
+ createdAt: string;
1581
3582
  }
1582
3583
  /**
1583
- * 批量操作请求
3584
+ * Worker 任务结果
1584
3585
  */
1585
- interface BatchRequest<T> {
1586
- /** 操作列表 */
1587
- items: T[];
1588
- /** 是否原子操作(全部成功或全部失败) */
1589
- atomic?: boolean;
3586
+ interface WorkerTaskResult<T = unknown> {
3587
+ /** 任务 ID */
3588
+ taskId: string;
3589
+ /** 是否成功 */
3590
+ success: boolean;
3591
+ /** 结果数据 */
3592
+ data?: T;
3593
+ /** 错误码 */
3594
+ errorCode?: string;
3595
+ /** 错误信息 */
3596
+ errorMessage?: string;
3597
+ /** 执行时长(ms) */
3598
+ duration: number;
1590
3599
  }
1591
3600
  /**
1592
- * 批量操作结果
3601
+ * 事件消费配置
1593
3602
  */
1594
- interface BatchResult<T> {
1595
- /** 成功数量 */
1596
- successCount: number;
1597
- /** 失败数量 */
1598
- failedCount: number;
1599
- /** 结果列表 */
1600
- results: BatchItemResult<T>[];
3603
+ interface EventConsumerConfig {
3604
+ /** 消费者 ID */
3605
+ consumerId: string;
3606
+ /** 监听的事件类型 */
3607
+ eventTypes: OutboxEventType[];
3608
+ /** 批量大小 */
3609
+ batchSize: number;
3610
+ /** 并发数 */
3611
+ concurrency: number;
3612
+ /** 轮询间隔(ms) */
3613
+ pollInterval: number;
3614
+ /** 可见性超时(秒) */
3615
+ visibilityTimeout: number;
3616
+ /** 重试策略 */
3617
+ retryStrategy: RetryStrategy;
1601
3618
  }
1602
3619
  /**
1603
- * 单个批量操作项结果
3620
+ * 重试策略
1604
3621
  */
1605
- interface BatchItemResult<T> {
1606
- /** 索引 */
1607
- index: number;
3622
+ interface RetryStrategy {
3623
+ /** 最大重试次数 */
3624
+ maxRetries: number;
3625
+ /** 基础延迟(ms) */
3626
+ baseDelay: number;
3627
+ /** 最大延迟(ms) */
3628
+ maxDelay: number;
3629
+ /** 是否使用指数退避 */
3630
+ exponentialBackoff: boolean;
3631
+ /** 退避因子 */
3632
+ backoffFactor?: number;
3633
+ /** 可重试的错误类型 */
3634
+ retryableErrors?: string[];
3635
+ }
3636
+ /**
3637
+ * 死信事件
3638
+ */
3639
+ interface DeadLetterEvent extends OutboxEvent {
3640
+ /** 进入死信队列时间 */
3641
+ deadAt: string;
3642
+ /** 进入原因 */
3643
+ deadReason: 'max_retries' | 'manual' | 'timeout' | 'poison';
3644
+ /** 错误历史 */
3645
+ errorHistory: ErrorHistoryItem[];
3646
+ /** 是否已处理 */
3647
+ resolved: boolean;
3648
+ /** 处理时间 */
3649
+ resolvedAt?: string;
3650
+ /** 处理者 */
3651
+ resolvedBy?: string;
3652
+ /** 处理备注 */
3653
+ resolveNote?: string;
3654
+ }
3655
+ /**
3656
+ * 错误历史项
3657
+ */
3658
+ interface ErrorHistoryItem {
3659
+ /** 尝试次数 */
3660
+ attempt: number;
3661
+ /** 错误信息 */
3662
+ error: string;
3663
+ /** 错误时间 */
3664
+ timestamp: string;
3665
+ /** Worker ID */
3666
+ workerId?: string;
3667
+ }
3668
+ /**
3669
+ * 发布事件请求
3670
+ */
3671
+ interface PublishEventRequest<T = unknown> {
3672
+ /** 事件类型 */
3673
+ type: OutboxEventType;
3674
+ /** 事件数据 */
3675
+ payload: T;
3676
+ /** 优先级 */
3677
+ priority?: number;
3678
+ /** 延迟执行(秒) */
3679
+ delaySeconds?: number;
3680
+ /** 聚合 ID */
3681
+ aggregateId?: string;
3682
+ /** 去重键 */
3683
+ deduplicationId?: string;
3684
+ /** 追踪 ID */
3685
+ traceId?: string;
3686
+ }
3687
+ /**
3688
+ * 发布事件响应
3689
+ */
3690
+ interface PublishEventResponse {
3691
+ /** 事件 ID */
3692
+ eventId: string;
3693
+ /** 是否去重 */
3694
+ deduplicated: boolean;
3695
+ /** 预计处理时间 */
3696
+ estimatedProcessAt?: string;
3697
+ }
3698
+
3699
+ /**
3700
+ * 审计日志类型定义
3701
+ * 用于操作记录、变更追踪、合规审计
3702
+ */
3703
+
3704
+ /**
3705
+ * 审计日志级别
3706
+ */
3707
+ type AuditLogLevel = 'info' | 'warning' | 'critical' | 'security';
3708
+ /**
3709
+ * 审计目标类型
3710
+ */
3711
+ type AuditTargetType = 'page' | 'page_version' | 'component' | 'component_version' | 'activity' | 'action_definition' | 'query_definition' | 'user' | 'role' | 'permission' | 'config' | 'system';
3712
+ /**
3713
+ * 审计日志
3714
+ */
3715
+ interface AuditLog {
3716
+ /** 日志 ID */
3717
+ id: string;
3718
+ /** 日志级别 */
3719
+ level: AuditLogLevel;
3720
+ /** 操作类型 */
3721
+ action: LowcodeAction;
3722
+ /** 操作描述 */
3723
+ description: string;
3724
+ /** 目标类型 */
3725
+ targetType: AuditTargetType;
3726
+ /** 目标 ID */
3727
+ targetId: string;
3728
+ /** 目标名称 */
3729
+ targetName?: string;
3730
+ /** 操作者信息 */
3731
+ operator: OperatorInfo;
3732
+ /** 操作来源 */
3733
+ source: AuditSource;
3734
+ /** 变更摘要 */
3735
+ changeSummary?: ChangeSummary;
3736
+ /** 请求上下文 */
3737
+ context: AuditContext;
3738
+ /** 操作结果 */
3739
+ result: AuditResult;
3740
+ /** 创建时间 */
3741
+ createdAt: string;
3742
+ }
3743
+ /**
3744
+ * 操作来源
3745
+ */
3746
+ interface AuditSource {
3747
+ /** 来源类型 */
3748
+ type: 'web' | 'api' | 'cli' | 'scheduler' | 'system';
3749
+ /** IP 地址 */
3750
+ ip?: string;
3751
+ /** 用户代理 */
3752
+ userAgent?: string;
3753
+ /** 设备 ID */
3754
+ deviceId?: string;
3755
+ /** 应用 ID */
3756
+ appId?: string;
3757
+ /** API Key ID */
3758
+ apiKeyId?: string;
3759
+ }
3760
+ /**
3761
+ * 审计上下文
3762
+ */
3763
+ interface AuditContext {
3764
+ /** 追踪 ID */
3765
+ traceId: string;
3766
+ /** 请求 ID */
3767
+ requestId: string;
3768
+ /** 会话 ID */
3769
+ sessionId?: string;
3770
+ /** 环境 */
3771
+ environment?: 'development' | 'staging' | 'production';
3772
+ /** 服务名 */
3773
+ service?: string;
3774
+ /** 额外上下文 */
3775
+ extra?: Record<string, unknown>;
3776
+ }
3777
+ /**
3778
+ * 操作结果
3779
+ */
3780
+ interface AuditResult {
1608
3781
  /** 是否成功 */
1609
3782
  success: boolean;
1610
- /** 数据 */
1611
- data?: T;
1612
3783
  /** 错误码 */
1613
- code?: number;
3784
+ errorCode?: string;
1614
3785
  /** 错误信息 */
1615
- message?: string;
3786
+ errorMessage?: string;
3787
+ /** 执行时长(ms) */
3788
+ duration?: number;
3789
+ }
3790
+ /**
3791
+ * 页面发布审计详情
3792
+ */
3793
+ interface PagePublishAuditDetails {
3794
+ /** 页面 UID */
3795
+ pageUid: string;
3796
+ /** 页面版本 ID */
3797
+ pageVersionId: string;
3798
+ /** 发布渠道 */
3799
+ channel: 'preview' | 'prod' | 'gray';
3800
+ /** 之前的发布版本 */
3801
+ previousVersionId?: string;
3802
+ /** Manifest 内容哈希 */
3803
+ manifestHash: string;
3804
+ /** 包含的组件版本 */
3805
+ componentVersions: Array<{
3806
+ name: string;
3807
+ version: string;
3808
+ }>;
3809
+ /** 灰度配置 */
3810
+ grayConfig?: Record<string, unknown>;
3811
+ /** 审批信息 */
3812
+ approval?: ApprovalInfo;
3813
+ }
3814
+ /**
3815
+ * 页面回滚审计详情
3816
+ */
3817
+ interface PageRollbackAuditDetails {
3818
+ /** 页面 UID */
3819
+ pageUid: string;
3820
+ /** 原版本 ID */
3821
+ fromVersionId: string;
3822
+ /** 目标版本 ID */
3823
+ toVersionId: string;
3824
+ /** 回滚原因 */
3825
+ reason: string;
3826
+ /** 回滚时长(ms) */
3827
+ rollbackDuration: number;
3828
+ /** 是否紧急回滚 */
3829
+ isEmergency: boolean;
3830
+ }
3831
+ /**
3832
+ * 组件阻断审计详情
3833
+ */
3834
+ interface ComponentBlockAuditDetails {
3835
+ /** 组件名称 */
3836
+ componentName: string;
3837
+ /** 阻断版本范围 */
3838
+ versionRange: string;
3839
+ /** 阻断原因 */
3840
+ reason: string;
3841
+ /** 是否紧急 */
3842
+ isUrgent: boolean;
3843
+ /** 受影响页面 */
3844
+ affectedPages: Array<{
3845
+ pageUid: string;
3846
+ pageName: string;
3847
+ componentVersion: string;
3848
+ }>;
3849
+ /** 受影响页面数量 */
3850
+ affectedPageCount: number;
3851
+ }
3852
+ /**
3853
+ * 审批信息
3854
+ */
3855
+ interface ApprovalInfo {
3856
+ /** 审批 ID */
3857
+ approvalId: string;
3858
+ /** 审批状态 */
3859
+ status: 'pending' | 'approved' | 'rejected';
3860
+ /** 审批者 */
3861
+ approvers: ApproverInfo[];
3862
+ /** 审批时间 */
3863
+ approvedAt?: string;
3864
+ /** 审批备注 */
3865
+ comment?: string;
3866
+ }
3867
+ /**
3868
+ * 审批者信息
3869
+ */
3870
+ interface ApproverInfo {
3871
+ /** 用户 ID */
3872
+ uid: string;
3873
+ /** 用户名 */
3874
+ username: string;
3875
+ /** 审批决定 */
3876
+ decision: 'approved' | 'rejected' | 'pending';
3877
+ /** 审批时间 */
3878
+ decidedAt?: string;
3879
+ /** 备注 */
3880
+ comment?: string;
3881
+ }
3882
+ /**
3883
+ * 安全审计日志
3884
+ */
3885
+ interface SecurityAuditLog extends AuditLog {
3886
+ level: 'security';
3887
+ /** 安全事件类型 */
3888
+ securityEventType: SecurityEventType;
3889
+ /** 风险评分 */
3890
+ riskScore?: number;
3891
+ /** 威胁指标 */
3892
+ threatIndicators?: ThreatIndicator[];
3893
+ /** 是否已处理 */
3894
+ handled: boolean;
3895
+ /** 处理结果 */
3896
+ handlingResult?: string;
3897
+ }
3898
+ /**
3899
+ * 安全事件类型
3900
+ */
3901
+ type SecurityEventType = 'unauthorized_access' | 'permission_escalation' | 'suspicious_activity' | 'rate_limit_exceeded' | 'integrity_violation' | 'config_tampering' | 'sensitive_data_access' | 'login_anomaly' | 'api_abuse';
3902
+ /**
3903
+ * 威胁指标
3904
+ */
3905
+ interface ThreatIndicator {
3906
+ /** 指标类型 */
3907
+ type: 'ip' | 'user' | 'device' | 'behavior' | 'pattern';
3908
+ /** 指标值 */
3909
+ value: string;
3910
+ /** 风险等级 */
3911
+ riskLevel: 'low' | 'medium' | 'high' | 'critical';
3912
+ /** 描述 */
3913
+ description?: string;
3914
+ }
3915
+ /**
3916
+ * 审计日志查询请求
3917
+ */
3918
+ interface AuditLogQueryRequest {
3919
+ /** 时间范围 - 开始 */
3920
+ startTime?: string;
3921
+ /** 时间范围 - 结束 */
3922
+ endTime?: string;
3923
+ /** 操作类型 */
3924
+ actions?: string[];
3925
+ /** 目标类型 */
3926
+ targetTypes?: AuditTargetType[];
3927
+ /** 目标 ID */
3928
+ targetId?: string;
3929
+ /** 操作者 UID */
3930
+ operatorUid?: string;
3931
+ /** 日志级别 */
3932
+ levels?: AuditLogLevel[];
3933
+ /** 是否仅失败 */
3934
+ failedOnly?: boolean;
3935
+ /** 关键词搜索 */
3936
+ keyword?: string;
3937
+ /** 追踪 ID */
3938
+ traceId?: string;
3939
+ /** 页码 */
3940
+ page?: number;
3941
+ /** 每页数量 */
3942
+ pageSize?: number;
3943
+ /** 排序字段 */
3944
+ sortBy?: 'createdAt' | 'level' | 'action';
3945
+ /** 排序方向 */
3946
+ sortOrder?: 'asc' | 'desc';
3947
+ }
3948
+ /**
3949
+ * 审计统计
3950
+ */
3951
+ interface AuditStatistics {
3952
+ /** 统计周期 */
3953
+ period: {
3954
+ start: string;
3955
+ end: string;
3956
+ };
3957
+ /** 总操作数 */
3958
+ totalOperations: number;
3959
+ /** 成功操作数 */
3960
+ successCount: number;
3961
+ /** 失败操作数 */
3962
+ failedCount: number;
3963
+ /** 各级别分布 */
3964
+ levelDistribution: Record<AuditLogLevel, number>;
3965
+ /** 各操作类型分布 */
3966
+ actionDistribution: Record<string, number>;
3967
+ /** 各目标类型分布 */
3968
+ targetTypeDistribution: Record<AuditTargetType, number>;
3969
+ /** 活跃操作者 Top N */
3970
+ topOperators: Array<{
3971
+ operator: OperatorInfo;
3972
+ count: number;
3973
+ }>;
3974
+ /** 高危操作统计 */
3975
+ criticalOperations: number;
3976
+ }
3977
+ /**
3978
+ * 审计导出格式
3979
+ */
3980
+ type AuditExportFormat = 'json' | 'csv' | 'excel';
3981
+ /**
3982
+ * 审计导出请求
3983
+ */
3984
+ interface AuditExportRequest extends AuditLogQueryRequest {
3985
+ /** 导出格式 */
3986
+ format: AuditExportFormat;
3987
+ /** 是否包含详情 */
3988
+ includeDetails?: boolean;
3989
+ /** 字段选择 */
3990
+ fields?: string[];
3991
+ /** 时区 */
3992
+ timezone?: string;
3993
+ }
3994
+ /**
3995
+ * 审计导出响应
3996
+ */
3997
+ interface AuditExportResponse {
3998
+ /** 导出任务 ID */
3999
+ taskId: string;
4000
+ /** 状态 */
4001
+ status: 'pending' | 'processing' | 'completed' | 'failed';
4002
+ /** 下载 URL(完成后) */
4003
+ downloadUrl?: string;
4004
+ /** 过期时间 */
4005
+ expiresAt?: string;
4006
+ /** 记录数量 */
4007
+ recordCount?: number;
4008
+ }
4009
+
4010
+ /**
4011
+ * RBAC 权限模型类型定义
4012
+ * 用于角色、权限、访问控制
4013
+ *
4014
+ * 设计原则:MVP 最小闭环
4015
+ * - 发布/回滚/阻断属于高危权限
4016
+ * - 支持 global/tenant/app 三级作用域
4017
+ */
4018
+ /**
4019
+ * 权限作用域
4020
+ */
4021
+ type PermissionScope = 'global' | 'tenant' | 'app';
4022
+ /**
4023
+ * 资源类型
4024
+ */
4025
+ type ResourceType = 'page' | 'page_version' | 'component' | 'component_version' | 'activity' | 'action_definition' | 'query_definition' | 'user' | 'role' | 'config' | '*';
4026
+ /**
4027
+ * 操作类型
4028
+ */
4029
+ type PermissionAction = 'read' | 'create' | 'update' | 'delete' | 'publish' | 'unpublish' | 'rollback' | 'block' | 'unblock' | 'approve' | 'reject' | '*';
4030
+ /**
4031
+ * 权限定义
4032
+ */
4033
+ interface Permission {
4034
+ /** 权限 ID */
4035
+ id: string;
4036
+ /** 权限名称 */
4037
+ name: string;
4038
+ /** 权限描述 */
4039
+ description?: string;
4040
+ /** 资源类型 */
4041
+ resource: ResourceType;
4042
+ /** 操作类型 */
4043
+ action: PermissionAction;
4044
+ /** 是否为高危权限 */
4045
+ dangerous?: boolean;
4046
+ /** 创建时间 */
4047
+ createdAt: string;
4048
+ }
4049
+ /**
4050
+ * 内置权限常量
4051
+ */
4052
+ declare const BUILTIN_PERMISSIONS: {
4053
+ readonly PAGE_READ: "page:read";
4054
+ readonly PAGE_CREATE: "page:create";
4055
+ readonly PAGE_UPDATE: "page:update";
4056
+ readonly PAGE_DELETE: "page:delete";
4057
+ readonly PAGE_PUBLISH: "page:publish";
4058
+ readonly PAGE_ROLLBACK: "page:rollback";
4059
+ readonly COMPONENT_READ: "component:read";
4060
+ readonly COMPONENT_CREATE: "component:create";
4061
+ readonly COMPONENT_BLOCK: "component:block";
4062
+ readonly COMPONENT_UNBLOCK: "component:unblock";
4063
+ readonly ACTIVITY_READ: "activity:read";
4064
+ readonly ACTIVITY_CREATE: "activity:create";
4065
+ readonly ACTIVITY_UPDATE: "activity:update";
4066
+ readonly DEFINITION_READ: "definition:read";
4067
+ readonly DEFINITION_CREATE: "definition:create";
4068
+ readonly DEFINITION_UPDATE: "definition:update";
4069
+ readonly ADMIN_ALL: "*:*";
4070
+ };
4071
+ /**
4072
+ * 角色状态
4073
+ */
4074
+ type RoleStatus = 'active' | 'inactive' | 'deleted';
4075
+ /**
4076
+ * 角色定义
4077
+ */
4078
+ interface Role {
4079
+ /** 角色 ID */
4080
+ id: string;
4081
+ /** 角色名称 */
4082
+ name: string;
4083
+ /** 角色显示名 */
4084
+ label: string;
4085
+ /** 角色描述 */
4086
+ description?: string;
4087
+ /** 权限列表 */
4088
+ permissions: string[];
4089
+ /** 作用域 */
4090
+ scope: PermissionScope;
4091
+ /** 作用域 ID(tenant/app ID) */
4092
+ scopeId?: string;
4093
+ /** 是否为系统角色(不可删除) */
4094
+ isSystem?: boolean;
4095
+ /** 状态 */
4096
+ status: RoleStatus;
4097
+ /** 创建时间 */
4098
+ createdAt: string;
4099
+ /** 更新时间 */
4100
+ updatedAt?: string;
4101
+ }
4102
+ /**
4103
+ * 内置角色
4104
+ */
4105
+ declare const BUILTIN_ROLES: {
4106
+ /** 超级管理员 */
4107
+ readonly SUPER_ADMIN: "super_admin";
4108
+ /** 租户管理员 */
4109
+ readonly TENANT_ADMIN: "tenant_admin";
4110
+ /** 应用管理员 */
4111
+ readonly APP_ADMIN: "app_admin";
4112
+ /** 编辑者 */
4113
+ readonly EDITOR: "editor";
4114
+ /** 发布者 */
4115
+ readonly PUBLISHER: "publisher";
4116
+ /** 审核者 */
4117
+ readonly REVIEWER: "reviewer";
4118
+ /** 查看者 */
4119
+ readonly VIEWER: "viewer";
4120
+ };
4121
+ /**
4122
+ * 角色绑定
4123
+ * 将用户与角色关联
4124
+ */
4125
+ interface RoleBinding {
4126
+ /** 绑定 ID */
4127
+ id: string;
4128
+ /** 用户 ID */
4129
+ userId: string;
4130
+ /** 角色 ID */
4131
+ roleId: string;
4132
+ /** 作用域 */
4133
+ scope: PermissionScope;
4134
+ /** 作用域 ID */
4135
+ scopeId?: string;
4136
+ /** 是否启用 */
4137
+ enabled: boolean;
4138
+ /** 过期时间(可选,用于临时授权) */
4139
+ expiresAt?: string;
4140
+ /** 创建时间 */
4141
+ createdAt: string;
4142
+ /** 创建者 */
4143
+ createdBy: string;
4144
+ }
4145
+ /**
4146
+ * 权限检查请求
4147
+ */
4148
+ interface PermissionCheckRequest {
4149
+ /** 用户 ID */
4150
+ userId: string;
4151
+ /** 资源类型 */
4152
+ resource: ResourceType;
4153
+ /** 操作类型 */
4154
+ action: PermissionAction;
4155
+ /** 资源 ID(可选,用于实例级权限检查) */
4156
+ resourceId?: string;
4157
+ /** 作用域 */
4158
+ scope?: PermissionScope;
4159
+ /** 作用域 ID */
4160
+ scopeId?: string;
1616
4161
  }
1617
4162
  /**
1618
- * 上传凭证请求
4163
+ * 权限检查结果
1619
4164
  */
1620
- interface UploadCredentialRequest {
1621
- /** 文件名 */
1622
- filename: string;
1623
- /** 文件类型 */
1624
- contentType: string;
1625
- /** 文件大小 */
1626
- size: number;
1627
- /** 目录 */
1628
- directory?: string;
4165
+ interface PermissionCheckResult {
4166
+ /** 是否允许 */
4167
+ allowed: boolean;
4168
+ /** 匹配的权限 */
4169
+ matchedPermission?: string;
4170
+ /** 匹配的角色 */
4171
+ matchedRole?: string;
4172
+ /** 拒绝原因 */
4173
+ denyReason?: string;
1629
4174
  }
1630
4175
  /**
1631
- * 上传凭证响应
4176
+ * 用户权限摘要
1632
4177
  */
1633
- interface UploadCredentialResponse {
1634
- /** 上传 URL */
1635
- uploadUrl: string;
1636
- /** 上传方法 */
1637
- method: 'PUT' | 'POST';
1638
- /** 需要的请求头 */
1639
- headers: Record<string, string>;
1640
- /** 表单字段(POST multipart 时) */
1641
- formFields?: Record<string, string>;
1642
- /** 最终文件 URL */
1643
- fileUrl: string;
1644
- /** 凭证过期时间 */
1645
- expiresAt: string;
4178
+ interface UserPermissionSummary {
4179
+ /** 用户 ID */
4180
+ userId: string;
4181
+ /** 角色列表 */
4182
+ roles: RoleSummary[];
4183
+ /** 有效权限列表 */
4184
+ effectivePermissions: string[];
4185
+ /** 高危权限列表 */
4186
+ dangerousPermissions: string[];
1646
4187
  }
1647
4188
  /**
1648
- * WebSocket 消息类型
4189
+ * 角色摘要
1649
4190
  */
1650
- type WsMessageType = 'ping' | 'pong' | 'subscribe' | 'unsubscribe' | 'publish' | 'error';
4191
+ interface RoleSummary {
4192
+ /** 角色 ID */
4193
+ id: string;
4194
+ /** 角色名称 */
4195
+ name: string;
4196
+ /** 角色显示名 */
4197
+ label: string;
4198
+ /** 作用域 */
4199
+ scope: PermissionScope;
4200
+ /** 作用域 ID */
4201
+ scopeId?: string;
4202
+ }
1651
4203
  /**
1652
- * WebSocket 消息
4204
+ * 高危操作确认请求
4205
+ * 用于发布、回滚、阻断等危险操作
1653
4206
  */
1654
- interface WsMessage<T = unknown> {
1655
- /** 消息类型 */
1656
- type: WsMessageType;
1657
- /** 频道 */
1658
- channel?: string;
1659
- /** 消息数据 */
1660
- data?: T;
1661
- /** 消息 ID */
1662
- id?: string;
1663
- /** 时间戳 */
1664
- timestamp: number;
4207
+ interface DangerousOperationConfirmation {
4208
+ /** 操作类型 */
4209
+ operation: 'publish' | 'rollback' | 'block' | 'delete';
4210
+ /** 目标资源类型 */
4211
+ targetType: ResourceType;
4212
+ /** 目标资源 ID */
4213
+ targetId: string;
4214
+ /** 操作原因 */
4215
+ reason: string;
4216
+ /** 影响范围描述 */
4217
+ impactDescription?: string;
4218
+ /** 是否需要二次确认 */
4219
+ requireDoubleConfirm?: boolean;
4220
+ /** 确认码(用于二次确认) */
4221
+ confirmationCode?: string;
1665
4222
  }
1666
-
1667
4223
  /**
1668
- * 表达式引擎类型定义
1669
- * 无 eval 的安全 DSL,支持发布期校验
4224
+ * 审批节点类型
1670
4225
  */
4226
+ type ApprovalNodeType = 'single' | 'all' | 'any';
1671
4227
  /**
1672
- * 表达式类型
4228
+ * 审批节点
1673
4229
  */
1674
- type ExpressionType = 'literal' | 'identifier' | 'member' | 'index' | 'call' | 'binary' | 'unary' | 'conditional' | 'array' | 'object';
4230
+ interface ApprovalNode {
4231
+ /** 节点 ID */
4232
+ id: string;
4233
+ /** 节点名称 */
4234
+ name: string;
4235
+ /** 节点类型 */
4236
+ type: ApprovalNodeType;
4237
+ /** 审批人列表(用户 ID 或角色 ID) */
4238
+ approvers: string[];
4239
+ /** 审批人类型 */
4240
+ approverType: 'user' | 'role';
4241
+ /** 超时时间(小时) */
4242
+ timeoutHours?: number;
4243
+ /** 下一节点 ID */
4244
+ nextNodeId?: string;
4245
+ }
1675
4246
  /**
1676
- * 表达式 AST 节点基类
4247
+ * 审批工作流
1677
4248
  */
1678
- interface ExpressionNode {
1679
- /** 节点类型 */
1680
- type: ExpressionType;
1681
- /** 原始表达式 */
1682
- raw?: string;
1683
- /** 起始位置 */
1684
- start?: number;
1685
- /** 结束位置 */
1686
- end?: number;
4249
+ interface ApprovalWorkflow {
4250
+ /** 工作流 ID */
4251
+ id: string;
4252
+ /** 工作流名称 */
4253
+ name: string;
4254
+ /** 适用的操作类型 */
4255
+ applicableOperations: PermissionAction[];
4256
+ /** 适用的资源类型 */
4257
+ applicableResources: ResourceType[];
4258
+ /** 审批节点列表 */
4259
+ nodes: ApprovalNode[];
4260
+ /** 起始节点 ID */
4261
+ startNodeId: string;
4262
+ /** 是否启用 */
4263
+ enabled: boolean;
4264
+ /** 创建时间 */
4265
+ createdAt: string;
1687
4266
  }
1688
4267
  /**
1689
- * 字面量节点
4268
+ * 审批实例状态
1690
4269
  */
1691
- interface LiteralNode extends ExpressionNode {
1692
- type: 'literal';
1693
- value: string | number | boolean | null;
4270
+ type ApprovalInstanceStatus = 'pending' | 'in_progress' | 'approved' | 'rejected' | 'cancelled' | 'expired';
4271
+ /**
4272
+ * 审批实例
4273
+ */
4274
+ interface ApprovalInstance {
4275
+ /** 实例 ID */
4276
+ id: string;
4277
+ /** 工作流 ID */
4278
+ workflowId: string;
4279
+ /** 申请人 */
4280
+ applicantId: string;
4281
+ /** 申请原因 */
4282
+ reason: string;
4283
+ /** 操作类型 */
4284
+ operation: PermissionAction;
4285
+ /** 资源类型 */
4286
+ resourceType: ResourceType;
4287
+ /** 资源 ID */
4288
+ resourceId: string;
4289
+ /** 当前状态 */
4290
+ status: ApprovalInstanceStatus;
4291
+ /** 当前节点 ID */
4292
+ currentNodeId: string;
4293
+ /** 审批记录 */
4294
+ approvalRecords: ApprovalRecord[];
4295
+ /** 创建时间 */
4296
+ createdAt: string;
4297
+ /** 完成时间 */
4298
+ completedAt?: string;
1694
4299
  }
1695
4300
  /**
1696
- * 标识符节点
4301
+ * 审批记录
1697
4302
  */
1698
- interface IdentifierNode extends ExpressionNode {
1699
- type: 'identifier';
1700
- name: string;
4303
+ interface ApprovalRecord {
4304
+ /** 节点 ID */
4305
+ nodeId: string;
4306
+ /** 审批人 ID */
4307
+ approverId: string;
4308
+ /** 审批人名称 */
4309
+ approverName: string;
4310
+ /** 审批决定 */
4311
+ decision: 'approved' | 'rejected';
4312
+ /** 审批意见 */
4313
+ comment?: string;
4314
+ /** 审批时间 */
4315
+ decidedAt: string;
1701
4316
  }
4317
+
1702
4318
  /**
1703
- * 成员访问节点
4319
+ * 安全相关类型定义
4320
+ * 用于签名验证、供应链安全、CSP 配置等
4321
+ *
4322
+ * 设计原则:
4323
+ * - SRI(integrity) 校验强制
4324
+ * - Registry block 支持秒级止血
4325
+ * - CSP:script-src 限制到 CDN 域 + nonce/hash
4326
+ * - 可选:产物签名(防对象存储被替换)
1704
4327
  */
1705
- interface MemberNode extends ExpressionNode {
1706
- type: 'member';
1707
- object: ExpressionNode;
1708
- property: string;
4328
+ /**
4329
+ * 签名算法
4330
+ */
4331
+ type SignatureAlgorithm = 'ed25519' | 'rsa-sha256' | 'ecdsa-p256';
4332
+ /**
4333
+ * 资源签名
4334
+ * 用于验证组件、运行时等产物的完整性
4335
+ */
4336
+ interface ResourceSignature {
4337
+ /** 签名算法 */
4338
+ algorithm: SignatureAlgorithm;
4339
+ /** 公钥(用于验证) */
4340
+ publicKey: string;
4341
+ /** 签名值(Base64 编码) */
4342
+ signature: string;
4343
+ /** 签名时间 */
4344
+ signedAt: string;
4345
+ /** 签名者标识 */
4346
+ signedBy: string;
4347
+ /** 签名者密钥 ID */
4348
+ keyId?: string;
4349
+ /** 有效期(可选) */
4350
+ expiresAt?: string;
1709
4351
  }
1710
4352
  /**
1711
- * 函数调用节点
4353
+ * 签名验证请求
1712
4354
  */
1713
- interface CallNode extends ExpressionNode {
1714
- type: 'call';
1715
- callee: string;
1716
- arguments: ExpressionNode[];
4355
+ interface SignatureVerifyRequest {
4356
+ /** 待验证内容的哈希 */
4357
+ contentHash: string;
4358
+ /** 签名信息 */
4359
+ signature: ResourceSignature;
4360
+ /** 预期的签名者 */
4361
+ expectedSigner?: string;
1717
4362
  }
1718
4363
  /**
1719
- * 二元运算节点
4364
+ * 签名验证结果
1720
4365
  */
1721
- interface BinaryNode extends ExpressionNode {
1722
- type: 'binary';
1723
- operator: BinaryOperator;
1724
- left: ExpressionNode;
1725
- right: ExpressionNode;
4366
+ interface SignatureVerifyResult {
4367
+ /** 是否有效 */
4368
+ valid: boolean;
4369
+ /** 验证失败原因 */
4370
+ reason?: SignatureInvalidReason;
4371
+ /** 签名者信息 */
4372
+ signer?: string;
4373
+ /** 签名时间 */
4374
+ signedAt?: string;
1726
4375
  }
1727
4376
  /**
1728
- * 二元运算符
4377
+ * 签名无效原因
1729
4378
  */
1730
- type BinaryOperator = '+' | '-' | '*' | '/' | '%' | '==' | '!=' | '>' | '<' | '>=' | '<=' | '&&' | '||' | '??';
4379
+ type SignatureInvalidReason = 'SIGNATURE_MISMATCH' | 'KEY_NOT_FOUND' | 'KEY_EXPIRED' | 'SIGNATURE_EXPIRED' | 'ALGORITHM_NOT_SUPPORTED' | 'SIGNER_NOT_TRUSTED';
1731
4380
  /**
1732
- * 一元运算符
4381
+ * SRI 哈希算法
1733
4382
  */
1734
- type UnaryOperator = '!' | '-' | '+';
4383
+ type SriAlgorithm = 'sha256' | 'sha384' | 'sha512';
1735
4384
  /**
1736
- * 内置函数定义
4385
+ * SRI 完整性定义
4386
+ * 格式:algorithm-base64hash
1737
4387
  */
1738
- interface BuiltinFunction {
1739
- /** 函数名 */
1740
- name: string;
1741
- /** 描述 */
1742
- description: string;
1743
- /** 参数定义 */
1744
- params: FunctionParam[];
1745
- /** 返回类型 */
1746
- returnType: ValueType;
1747
- /** 示例 */
1748
- examples?: string[];
4388
+ interface SriIntegrity {
4389
+ /** 算法 */
4390
+ algorithm: SriAlgorithm;
4391
+ /** 哈希值(Base64 编码) */
4392
+ hash: string;
4393
+ /** 完整的 integrity 字符串 */
4394
+ value: string;
1749
4395
  }
1750
4396
  /**
1751
- * 函数参数定义
4397
+ * 完整性校验请求
1752
4398
  */
1753
- interface FunctionParam {
1754
- /** 参数名 */
1755
- name: string;
1756
- /** 参数类型 */
1757
- type: ValueType;
1758
- /** 是否必填 */
1759
- required: boolean;
1760
- /** 默认值 */
1761
- defaultValue?: unknown;
1762
- /** 描述 */
1763
- description?: string;
4399
+ interface IntegrityCheckRequest {
4400
+ /** 资源 URL */
4401
+ url: string;
4402
+ /** 预期的 integrity 值 */
4403
+ expectedIntegrity: string;
4404
+ /** 资源内容(可选,用于离线校验) */
4405
+ content?: ArrayBuffer;
1764
4406
  }
1765
4407
  /**
1766
- * 值类型
4408
+ * 完整性校验结果
1767
4409
  */
1768
- type ValueType = 'string' | 'number' | 'boolean' | 'array' | 'object' | 'null' | 'any' | 'void';
4410
+ interface IntegrityCheckResult {
4411
+ /** 是否匹配 */
4412
+ matched: boolean;
4413
+ /** 实际计算的哈希 */
4414
+ actualHash?: string;
4415
+ /** 预期的哈希 */
4416
+ expectedHash?: string;
4417
+ /** 校验时间 */
4418
+ checkedAt: string;
4419
+ }
1769
4420
  /**
1770
- * 内置函数白名单
1771
- * 表达式中只能调用这些函数
4421
+ * CSP 指令类型
1772
4422
  */
1773
- declare const BUILTIN_FUNCTIONS: BuiltinFunction[];
4423
+ type CspDirective = 'default-src' | 'script-src' | 'style-src' | 'img-src' | 'font-src' | 'connect-src' | 'frame-src' | 'object-src' | 'base-uri' | 'form-action' | 'frame-ancestors' | 'report-uri' | 'report-to';
1774
4424
  /**
1775
- * 内置函数名称集合(用于快速校验)
4425
+ * CSP 来源值
4426
+ * 使用 (string & {}) 技巧保持自动补全同时允许任意 URL
1776
4427
  */
1777
- declare const BUILTIN_FUNCTION_NAMES: Set<string>;
4428
+ type CspSourceValue = "'self'" | "'unsafe-inline'" | "'unsafe-eval'" | "'strict-dynamic'" | "'none'" | `'nonce-${string}'` | `'sha256-${string}'` | `'sha384-${string}'` | `'sha512-${string}'` | (string & NonNullable<unknown>);
1778
4429
  /**
1779
- * 表达式上下文
1780
- * 表达式执行时可访问的变量
4430
+ * CSP 配置
1781
4431
  */
1782
- interface ExpressionContext {
1783
- /** 页面状态 */
1784
- state: Record<string, unknown>;
1785
- /** 查询结果 */
1786
- query: Record<string, unknown>;
1787
- /** 运行时上下文 */
1788
- context: {
1789
- userId?: string;
1790
- deviceId?: string;
1791
- channel?: string;
1792
- pageVersionId?: string;
1793
- [key: string]: unknown;
1794
- };
1795
- /** 事件参数 */
1796
- event?: Record<string, unknown>;
1797
- /** 循环变量 */
1798
- item?: unknown;
1799
- /** 循环索引 */
1800
- index?: number;
4432
+ interface CspConfig {
4433
+ /** 是否启用 */
4434
+ enabled: boolean;
4435
+ /** 是否仅报告模式 */
4436
+ reportOnly?: boolean;
4437
+ /** 指令配置 */
4438
+ directives: Partial<Record<CspDirective, CspSourceValue[]>>;
4439
+ /** 报告端点 */
4440
+ reportUri?: string;
4441
+ /** Nonce 值(运行时生成) */
4442
+ nonce?: string;
1801
4443
  }
1802
4444
  /**
1803
- * 表达式允许访问的根变量
4445
+ * CSP 违规报告
1804
4446
  */
1805
- declare const ALLOWED_ROOT_VARIABLES: readonly ["state", "query", "context", "event", "item", "index"];
4447
+ interface CspViolationReport {
4448
+ /** 文档 URL */
4449
+ documentUri: string;
4450
+ /** 被阻止的资源 URL */
4451
+ blockedUri: string;
4452
+ /** 违规的指令 */
4453
+ violatedDirective: string;
4454
+ /** 原始策略 */
4455
+ originalPolicy: string;
4456
+ /** 来源文件 */
4457
+ sourceFile?: string;
4458
+ /** 行号 */
4459
+ lineNumber?: number;
4460
+ /** 列号 */
4461
+ columnNumber?: number;
4462
+ /** 状态码 */
4463
+ statusCode?: number;
4464
+ /** 时间戳 */
4465
+ timestamp: string;
4466
+ }
1806
4467
  /**
1807
- * 表达式校验结果
4468
+ * 受信任的签名者
1808
4469
  */
1809
- interface ExpressionValidationResult {
1810
- /** 是否有效 */
1811
- valid: boolean;
1812
- /** 错误列表 */
1813
- errors: ExpressionError[];
1814
- /** 警告列表 */
1815
- warnings: ExpressionWarning[];
1816
- /** 引用的变量路径 */
1817
- referencedPaths: string[];
1818
- /** 调用的函数 */
1819
- calledFunctions: string[];
4470
+ interface TrustedSigner {
4471
+ /** 签名者 ID */
4472
+ id: string;
4473
+ /** 签名者名称 */
4474
+ name: string;
4475
+ /** 公钥列表 */
4476
+ publicKeys: SignerPublicKey[];
4477
+ /** 信任级别 */
4478
+ trustLevel: 'full' | 'limited' | 'revoked';
4479
+ /** 创建时间 */
4480
+ createdAt: string;
4481
+ /** 吊销时间 */
4482
+ revokedAt?: string;
1820
4483
  }
1821
4484
  /**
1822
- * 表达式错误
4485
+ * 签名者公钥
1823
4486
  */
1824
- interface ExpressionError {
1825
- /** 错误类型 */
1826
- type: ExpressionErrorType;
1827
- /** 错误消息 */
1828
- message: string;
1829
- /** 位置 */
1830
- position?: {
1831
- start: number;
1832
- end: number;
1833
- };
4487
+ interface SignerPublicKey {
4488
+ /** 密钥 ID */
4489
+ keyId: string;
4490
+ /** 算法 */
4491
+ algorithm: SignatureAlgorithm;
4492
+ /** 公钥(PEM 或 Base64 编码) */
4493
+ publicKey: string;
4494
+ /** 创建时间 */
4495
+ createdAt: string;
4496
+ /** 过期时间 */
4497
+ expiresAt?: string;
4498
+ /** 是否激活 */
4499
+ active: boolean;
1834
4500
  }
1835
4501
  /**
1836
- * 表达式错误类型
4502
+ * 安全策略配置
1837
4503
  */
1838
- type ExpressionErrorType = 'SYNTAX_ERROR' | 'UNKNOWN_FUNCTION' | 'INVALID_ARGUMENT' | 'UNKNOWN_VARIABLE' | 'TYPE_MISMATCH' | 'ACCESS_DENIED';
4504
+ interface SecurityPolicy {
4505
+ /** 策略 ID */
4506
+ id: string;
4507
+ /** 策略名称 */
4508
+ name: string;
4509
+ /** 是否启用 SRI 校验 */
4510
+ requireIntegrity: boolean;
4511
+ /** 是否启用签名校验 */
4512
+ requireSignature: boolean;
4513
+ /** 受信任的签名者列表 */
4514
+ trustedSigners?: string[];
4515
+ /** CSP 配置 */
4516
+ csp?: CspConfig;
4517
+ /** 允许的 CDN 域名 */
4518
+ allowedCdnDomains: string[];
4519
+ /** 允许的 API 域名 */
4520
+ allowedApiDomains: string[];
4521
+ /** 创建时间 */
4522
+ createdAt: string;
4523
+ /** 更新时间 */
4524
+ updatedAt?: string;
4525
+ }
1839
4526
  /**
1840
- * 表达式警告
4527
+ * 资源安全事件类型
4528
+ * 用于供应链安全、完整性校验等场景
4529
+ * 注意:审计相关的安全事件类型见 audit/index.ts 中的 SecurityEventType
1841
4530
  */
1842
- interface ExpressionWarning {
1843
- /** 警告类型 */
1844
- type: 'DEPRECATED' | 'PERFORMANCE' | 'NULLABLE';
1845
- /** 警告消息 */
4531
+ type ResourceSecurityEventType = 'integrity_violation' | 'signature_invalid' | 'csp_violation' | 'unauthorized_resource' | 'blocked_component_load' | 'suspicious_behavior';
4532
+ /**
4533
+ * 资源安全事件
4534
+ * 用于运行时资源加载和供应链安全
4535
+ */
4536
+ interface ResourceSecurityEvent {
4537
+ /** 事件 ID */
4538
+ id: string;
4539
+ /** 事件类型 */
4540
+ type: ResourceSecurityEventType;
4541
+ /** 严重程度 */
4542
+ severity: 'low' | 'medium' | 'high' | 'critical';
4543
+ /** 事件描述 */
1846
4544
  message: string;
1847
- /** 位置 */
1848
- position?: {
1849
- start: number;
1850
- end: number;
4545
+ /** 相关资源 */
4546
+ resource?: {
4547
+ type: string;
4548
+ url?: string;
4549
+ name?: string;
4550
+ version?: string;
4551
+ };
4552
+ /** 上下文信息 */
4553
+ context: {
4554
+ pageVersionId?: string;
4555
+ componentVersion?: string;
4556
+ userId?: string;
4557
+ deviceId?: string;
4558
+ ip?: string;
4559
+ userAgent?: string;
1851
4560
  };
4561
+ /** 事件时间 */
4562
+ timestamp: string;
4563
+ /** 追踪 ID */
4564
+ traceId?: string;
1852
4565
  }
1853
4566
  /**
1854
- * 表达式绑定
1855
- * 用于属性值的动态绑定
4567
+ * 密钥用途
1856
4568
  */
1857
- interface ExpressionBinding {
1858
- /** 是否为表达式 */
1859
- __isExpression: true;
1860
- /** 表达式字符串 */
1861
- expression: string;
1862
- /** 默认值(表达式失败时使用) */
1863
- fallback?: unknown;
1864
- }
4569
+ type KeyPurpose = 'component_signing' | 'runtime_signing' | 'api_signing' | 'token_signing';
1865
4570
  /**
1866
- * 检查是否为表达式绑定
4571
+ * 密钥元数据
4572
+ * 注意:仅包含元数据,不包含私钥
1867
4573
  */
1868
- declare function isExpressionBinding(value: unknown): value is ExpressionBinding;
4574
+ interface KeyMetadata {
4575
+ /** 密钥 ID */
4576
+ keyId: string;
4577
+ /** 密钥用途 */
4578
+ purpose: KeyPurpose;
4579
+ /** 算法 */
4580
+ algorithm: SignatureAlgorithm;
4581
+ /** 公钥 */
4582
+ publicKey: string;
4583
+ /** 创建时间 */
4584
+ createdAt: string;
4585
+ /** 过期时间 */
4586
+ expiresAt?: string;
4587
+ /** 轮换时间 */
4588
+ rotatedAt?: string;
4589
+ /** 是否为当前活动密钥 */
4590
+ isActive: boolean;
4591
+ /** 创建者 */
4592
+ createdBy: string;
4593
+ }
1869
4594
  /**
1870
- * 创建表达式绑定
4595
+ * 密钥轮换请求
1871
4596
  */
1872
- declare function createExpressionBinding(expression: string, fallback?: unknown): ExpressionBinding;
4597
+ interface KeyRotationRequest {
4598
+ /** 当前密钥 ID */
4599
+ currentKeyId: string;
4600
+ /** 密钥用途 */
4601
+ purpose: KeyPurpose;
4602
+ /** 算法 */
4603
+ algorithm: SignatureAlgorithm;
4604
+ /** 过渡期(小时),在此期间新旧密钥都有效 */
4605
+ transitionHours?: number;
4606
+ /** 轮换原因 */
4607
+ reason: string;
4608
+ }
1873
4609
 
1874
4610
  /**
1875
4611
  * Schema 迁移脚本
@@ -1955,4 +4691,4 @@ declare function getVersionInfo(version: string): {
1955
4691
  */
1956
4692
  declare function compareVersions(a: string, b: string): number;
1957
4693
 
1958
- export { ACTION_SPEC_VERSION, ALLOWED_ROOT_VARIABLES, type ActionAuditLog, type ActionContext, type ActionDefVersionId, type ActionDefinition, type ActionDefinitionStatus, type ActionDefinitionVersion, type ActionExecuteRequest, type ActionExecuteResponse, type ApiConfig, type ApiResponse, type Asset, type AssetMeta, type AssetSortField, type AssetStatus, type AssetType, type AuditStatus, BUILTIN_FUNCTIONS, BUILTIN_FUNCTION_NAMES, type BatchItemResult, type BatchRequest, type BatchResult, type BinaryNode, type BinaryOperator, type BlockedComponent, type BuiltinActionType, type BuiltinFunction, COMPONENT_CATEGORIES, COMPONENT_META_SCHEMA_VERSION, CURRENT_SCHEMA_VERSION, type CacheConfig, type CallNode, type CanvasConfig, type CanvasType, type CapabilitiesDefinition, type ChangeLog, type ChangeLogItem, type ClipboardResult, type CompatDefinition, type ComponentCategory, type ComponentEvent, type ComponentInstance, type ComponentLayout, type ComponentLoadResult, type ComponentLoadStatus, type ComponentMeta, type ComponentRegistry, type ComponentStatus, type ComponentStyle, type ComponentVersionId, type ComponentVersionRecord, type ContractsVersion, DATA_QUERY_SPEC_VERSION, type DataQueryContext, type DataQueryDefinition, type DataQueryDefinitionStatus, type DataQueryDefinitionVersion, type DataQueryRequest, type DataQueryResponse, type DataQueryVersionId, type DataSourceConfig, type DataSourceType, type DeepReadonly, type DependencyHealth, type DialogOptions, type DjvlcError, type ErrorBoundaryHandler, ErrorCode, ErrorCodeCategory, ErrorMessages, type EventAction, type EventBus, type EventDefinition, type EventsDefinition, type ExpressionBinding, type ExpressionContext, type ExpressionError, type ExpressionErrorType, type ExpressionNode, type ExpressionType, type ExpressionValidationResult, type ExpressionWarning, type FieldPermission, type FunctionParam, type GenericStatus, type GrayPublishConfig, type GrayRule, type Guide, type HealthCheckResponse, type HostAPI, type IdempotencyRule, type IdentifierNode, type IntegrityDefinition, type JsonSchema, type KeyValuePair, type LiteralNode, type LowcodeAction, type ManifestItem, type MaskRule, type MemberNode, type Migration, type MigrationFn, type MigrationResult, type NavigateOptions, type NonNullableProperties, type OperatorInfo, PAGE_SCHEMA_VERSION, type PageConfig, type PageManifest, type PageMeta, type PageResolveRequest, type PageResolveResult, type PageSchema, type PageSortField, type PageStatus, type PageUid, type PageVersionId, type PaginatedApiResponse, type PaginatedResult, type PaginationMeta, type PaginationParams, type PartialBy, type PerformanceMetric, type PerformanceMetricType, type PropsSchema, type PublishChannel, type PublishConfig, PublishStatus, type QueryAuditLog, type QueryPermissionConfig, type RateLimitRule, type RequiredBy, type RiskCheckRequest, type RiskCheckResult, type RolloutConfig, type RuntimeConfig, type RuntimeContext, type RuntimeError, type RuntimeErrorType, type RuntimeEvent, type RuntimeEventType, SCHEMA_VERSIONS, type SchemaVersion, type SortConfig, type SortOrder, type StandardRequestHeaders, type StandardResponseHeaders, type StorageOptions, type TemplateCategory, type TemplateSortField, type TimeRange, type ToastOptions, type TraceId, type TrackEvent, type UnaryOperator, type UploadCredentialRequest, type UploadCredentialResponse, type ValueType, type VersionDiff, type VersionInfo, type WsMessage, type WsMessageType, compareVersions, createDjvlcError, createExpressionBinding, findMigrationPath, getAllMigrations, getContractsVersion, getHttpStatusFromErrorCode, getVersionInfo, isExpressionBinding, isRetryableError, isVersionCompatible, migratePageSchema, needsMigration, registerMigration };
4694
+ export { ACTION_SPEC_VERSION, ALLOWED_ROOT_VARIABLES, type AccumulateReward, type ActionAuditLog, type ActionContext, type ActionDefVersionId, type ActionDefinition, type ActionDefinitionStatus, type ActionDefinitionVersion, type ActionExecuteRequest, type ActionExecuteResponse, type ActionExecutionLog, type Activity, type ActivityRules, type ActivityStatus, type ActivityType, type AggregationBucket, type ApiConfig, type ApiResponse, type AppConfig, type ApprovalInfo, type ApprovalInstance, type ApprovalInstanceStatus, type ApprovalNode, type ApprovalNodeType, type ApprovalRecord, type ApprovalWorkflow, type ApproverInfo, type ArrayWidgetConfig, type Asset, type AssetMeta, type AssetSortField, type AssetStatus, type AssetType, type AuditContext, type AuditExportFormat, type AuditExportRequest, type AuditExportResponse, type AuditLog, type AuditLogLevel, type AuditLogQueryRequest, type AuditResult, type AuditSource, type AuditStatistics, type AuditStatus, type AuditTargetType, BUILTIN_FUNCTIONS, BUILTIN_FUNCTION_NAMES, BUILTIN_PERMISSIONS, BUILTIN_PROPERTY_GROUPS, BUILTIN_ROLES, type BaseContext, type BatchItemResult, type BatchRequest, type BatchResult, type BatchTrackRequest, type BinaryNode, type BinaryOperator, type BlockComponentRequest, type BlockedComponent, type BootstrapConfig, type BuiltinActionType, type BuiltinFunction, COMPONENT_CATEGORIES, COMPONENT_META_SCHEMA_VERSION, CURRENT_SCHEMA_VERSION, type CacheConfig, type CallNode, type CanvasConfig, type CanvasType, type CapabilitiesDefinition, type CdnRefreshPayload, type ChangeComponentStatusRequest, type ChangeLog, type ChangeLogItem, type ChangeRecord, type ChangeSummary, type ChangeType, type ClaimActivityRules, type ClipboardResult, type CodeWidgetConfig, type ColorWidgetConfig, type CompatDefinition, type ComponentAggregations, type ComponentBlockAuditDetails, type ComponentBlockedPayload, type ComponentCategory, type ComponentEvent, type ComponentEventDetail, type ComponentEventEmitter, type ComponentInstance, type ComponentLayout, type ComponentLifecycleCallbacks, type ComponentLifecyclePhase, type ComponentLoadResult, type ComponentLoadStatus, type ComponentMeta, type ComponentMetaLite, type ComponentRegisterOptions, type ComponentRegisterResult, type ComponentRenderContext, type ComponentSearchItem, type ComponentSortField, type ComponentStatus, type ComponentStyle, type ComponentVersionId, type ComponentVersionInfo, type ComponentVersionQuery, type ComponentVersionInfo as ComponentVersionRecord, type ComponentWarning, type ComponentWarningType, type ContractsVersion, type CreatePreviewTokenRequest, type CspConfig, type CspDirective, type CspSourceValue, type CspViolationReport, type CustomWidgetConfig, DATA_QUERY_SPEC_VERSION, type DangerousOperationConfirmation, type DataQueryContext, type DataQueryDefinition, type DataQueryDefinitionStatus, type DataQueryDefinitionVersion, type DataQueryRequest, type DataQueryResponse, type DataQueryVersionId, type DataSourceConfig, type DataSourceType, type DeadLetterEvent, type DeepReadonly, type DependencyHealth, type DialogOptions, type DjvComponent, type DjvComponentConstructor, type DjvlcError, type EditorWidgetType, type EligibilityRules, ErrorCode, ErrorCodeCategory, type ErrorHistoryItem, ErrorMessages, type EventAction, type EventConsumerConfig, type EventDefinition, type EventsDefinition, type ExpressionBinding, type ExpressionContext, type ExpressionError, type ExpressionErrorType, type ExpressionNode, type ExpressionType, type ExpressionValidationResult, type ExpressionWarning, type FailedComponent, type FieldChange, type FieldPermission, type FunctionParam, type GenericStatus, type GrayPublishConfig, type RolloutRule as GrayRule, type GuaranteeRule, type Guide, type HealthCheckResponse, type HostAPI, type IdempotencyRule, type IdentifierNode, type InputWidgetConfig, type IntegrityCheckRequest, type IntegrityCheckResult, type IntegrityDefinition, type JsonSchema, type KeyMetadata, type KeyPurpose, type KeyRotationRequest, type KeyValuePair, type KillSwitchConfig, type LimitRules, type ListComponentVersionsRequest, type ListComponentVersionsResponse, type LiteralNode, type LotteryActivityRules, type LotteryCost, type LotteryState, type LowcodeAction, type ManifestItem, type MaskRule, type MediaWidgetConfig, type MemberNode, type Migration, type MigrationFn, type MigrationResult, type NavigateOptions, type NonNullableProperties, type NotificationSendPayload, type NumberWidgetConfig, type ObjectWidgetConfig, type OperatorInfo, type OptionsSource, type OutboxEvent, type OutboxEventStatus, type OutboxEventType, PAGE_SCHEMA_VERSION, type PageConfig, type PageManifest, type PageMeta, type PagePublishAuditDetails, type PagePublishedPayload, type PageResolveRequest, type PageResolveResult, type PageRollbackAuditDetails, type PageRolledBackPayload, type PageSchema, type PageSortField, type PageStatus, type PageUid, type PageVersionId, type PaginatedApiResponse, type PaginatedResult, type PaginationMeta, type PaginationParams, type PartialBy, type PerformanceMetric, type PerformanceMetricType, type Permission, type PermissionAction, type PermissionCheckRequest, type PermissionCheckResult, type PermissionScope, type PreviewToken, type PrizeConfig, type PrizePoolConfig, type PropChangeEvent, type PropObserverConfig, type PropertyGroup, type PropertyPanelConfig, type PropsSchema, type PublishChannel, type PublishConfig, type PublishEventRequest, type PublishEventResponse, PublishStatus, type QueryAuditLog, type QueryExecutionLog, type QueryPermissionConfig, type RateLimitRule, type RegisterComponentVersionRequest, type RegisterComponentVersionResponse, type ReminderConfig, type RequiredBy, type ReserveActivityRules, type ReserveField, type ResolveFailReason, type ResolveVersionsRequest, type ResolveVersionsResponse, type ResolvedComponent, type ResourceSecurityEvent, type ResourceSecurityEventType, type ResourceSignature, type ResourceType, type RetryStrategy, type RewardConfig, type RewardDeliverPayload, type RewardDeliveryMethod, type RewardOption, type RewardRules, type RewardType, type RiskCheckRequest, type RiskCheckResult, type RiskRules, type Role, type RoleBinding, type RoleStatus, type RoleSummary, type RolloutConfig, type RolloutRule, type RolloutRuleType, type RuntimeConfig, type RuntimeContext, type RuntimeError, type RuntimeErrorType, type RuntimeEvent, type RuntimeEventType, SCHEMA_VERSIONS, type SchemaVersion, type SearchComponentsRequest, type SearchComponentsResponse, type SecurityAuditLog, type SecurityEventType, type SecurityPolicy, type SelectOption, type SelectWidgetConfig, type ShadowDomConfig, type SignatureAlgorithm, type SignatureInvalidReason, type SignatureVerifyRequest, type SignatureVerifyResult, type SignerPublicKey, type SigninActivityRules, type SigninState, type SizeWidgetConfig, type SlotDefinition, type SlotType, type SlotsDefinition, type SortConfig, type SortOrder, type SriAlgorithm, type SriIntegrity, type StandardRequestHeaders, type StandardResponseHeaders, type StaticExportPayload, type StorageOptions, type StreakReward, type StyleIsolationMode, type TaskActivityRules, type TaskCondition, type TaskConfig, type TaskState, type TaskType, type TemplateCategory, type TemplateSortField, type TenantConfig, type TenantQuotas, type ThreatIndicator, type TimeRange, type TimeSlot, type ToastOptions, type TraceId, type TrackContext, type TrackEvent, type TrackEventType, type TrackRequest, type TrackResponse, type TrustedSigner, type UnaryOperator, type UnblockComponentRequest, type UploadCredentialRequest, type UploadCredentialResponse, type UserActivityState, type UserPermissionSummary, type ValueType, type VersionDiff, type VersionInfo, type WidgetBaseConfig, type WidgetConfig, type WorkerTask, type WorkerTaskResult, type WorkerTaskStatus, type WsMessage, type WsMessageType, compareVersions, createDjvlcError, createExpressionBinding, findMigrationPath, getAllMigrations, getContractsVersion, getHttpStatusFromErrorCode, getVersionInfo, isExpressionBinding, isRetryableError, isVersionCompatible, migratePageSchema, needsMigration, registerMigration };