@flowgram.ai/variable-core 0.2.27 → 0.2.29

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
@@ -28,7 +28,7 @@ declare class ScopeOutputData {
28
28
  protected variableTable: IVariableTable;
29
29
  protected memo: {
30
30
  <T>(key: string | symbol, fn: () => T): T;
31
- clear: (key?: (string | symbol) | undefined) => void;
31
+ clear: (key?: string | symbol) => void;
32
32
  };
33
33
  get variableEngine(): VariableEngine;
34
34
  get globalVariableTable(): IVariableTable;
@@ -39,11 +39,11 @@ declare class ScopeOutputData {
39
39
  /**
40
40
  * listen to variable list change
41
41
  */
42
- get onVariableListChange(): (observer: (variables: VariableDeclaration<any>[]) => void) => _flowgram_ai_utils.Disposable;
42
+ get onVariableListChange(): (observer: (variables: VariableDeclaration[]) => void) => _flowgram_ai_utils.Disposable;
43
43
  /**
44
44
  * listen to any variable update in list
45
45
  */
46
- get onAnyVariableChange(): (observer: (changedVariable: VariableDeclaration<any>) => void) => _flowgram_ai_utils.Disposable;
46
+ get onAnyVariableChange(): (observer: (changedVariable: VariableDeclaration) => void) => _flowgram_ai_utils.Disposable;
47
47
  /**
48
48
  * listen to variable list change + any variable update in list
49
49
  */
@@ -74,7 +74,7 @@ declare class ScopeAvailableData {
74
74
  readonly scope: Scope;
75
75
  protected memo: {
76
76
  <T>(key: string | symbol, fn: () => T): T;
77
- clear: (key?: (string | symbol) | undefined) => void;
77
+ clear: (key?: string | symbol) => void;
78
78
  };
79
79
  get globalVariableTable(): IVariableTable;
80
80
  protected refresh$: Subject<void>;
@@ -195,7 +195,7 @@ declare class Scope<ScopeMeta extends Record<string, any> = Record<string, any>>
195
195
  */
196
196
  protected memo: {
197
197
  <T>(key: string | symbol, fn: () => T): T;
198
- clear: (key?: (string | symbol) | undefined) => void;
198
+ clear: (key?: string | symbol) => void;
199
199
  };
200
200
  toDispose: DisposableCollection;
201
201
  constructor(options: {
@@ -417,33 +417,33 @@ declare enum ASTKind {
417
417
  * 类型相关
418
418
  * - 内部默认实现一套基于 JSON 类型的类型 AST 节点
419
419
  */
420
- String = "String",
421
- Number = "Number",
422
- Integer = "Integer",
423
- Boolean = "Boolean",
424
- Object = "Object",
425
- Array = "Array",
426
- Map = "Map",
427
- Union = "Union",
428
- Any = "Any",
429
- CustomType = "CustomType",
420
+ String = "String",// 字符串
421
+ Number = "Number",// 数字
422
+ Integer = "Integer",// 整数
423
+ Boolean = "Boolean",// 布尔值
424
+ Object = "Object",// Object
425
+ Array = "Array",// Array
426
+ Map = "Map",// Map
427
+ Union = "Union",// 联合类型,常用于类型判断,一般不对业务透出
428
+ Any = "Any",// 任意类型,常用于业务判断
429
+ CustomType = "CustomType",// 自定义类型,用于业务自定义类型
430
430
  /**
431
431
  * 声明
432
432
  */
433
- Property = "Property",
434
- VariableDeclaration = "VariableDeclaration",
435
- VariableDeclarationList = "VariableDeclarationList",
433
+ Property = "Property",// Object 下钻的字段定义
434
+ VariableDeclaration = "VariableDeclaration",// 变量声明
435
+ VariableDeclarationList = "VariableDeclarationList",// 变量声明
436
436
  /**
437
437
  * 表达式
438
438
  */
439
- KeyPathExpression = "KeyPathExpression",
440
- EnumerateExpression = "EnumerateExpression",
441
- WrapArrayExpression = "WrapArrayExpression",
439
+ KeyPathExpression = "KeyPathExpression",// 通过路径系统访问变量上的字段
440
+ EnumerateExpression = "EnumerateExpression",// 对指定的数据进行遍历
441
+ WrapArrayExpression = "WrapArrayExpression",// Wrap with Array Type
442
442
  /**
443
443
  * 通用 AST 节点
444
444
  */
445
- ListNode = "ListNode",
446
- DataNode = "DataNode",
445
+ ListNode = "ListNode",// 通用 List<ASTNode> 存储节点
446
+ DataNode = "DataNode",// 通用的数据存储节点
447
447
  MapNode = "MapNode"
448
448
  }
449
449
  interface CreateASTParams {
@@ -522,10 +522,10 @@ declare enum ASTNodeFlags {
522
522
  /**
523
523
  * 变量类型
524
524
  */
525
- BasicType = 8,
526
- DrilldownType = 16,
527
- EnumerateType = 32,
528
- UnionType = 64,
525
+ BasicType = 8,// 基础类型
526
+ DrilldownType = 16,// 可下钻的变量类型
527
+ EnumerateType = 32,// 可遍历的变量类型
528
+ UnionType = 64,// 复合类型,暂时不存在
529
529
  VariableType = 120
530
530
  }
531
531
 
@@ -1049,16 +1049,16 @@ declare namespace ASTFactory {
1049
1049
  kind: ASTKind;
1050
1050
  };
1051
1051
  const createArray: (json: ArrayJSON) => {
1052
- items?: ASTNodeJSONOrKind | undefined;
1052
+ items?: ASTNodeJSONOrKind;
1053
1053
  kind: ASTKind;
1054
1054
  };
1055
1055
  const createMap: (json: MapJSON) => {
1056
- keyType?: ASTNodeJSONOrKind | undefined;
1057
- valueType?: ASTNodeJSONOrKind | undefined;
1056
+ keyType?: ASTNodeJSONOrKind;
1057
+ valueType?: ASTNodeJSONOrKind;
1058
1058
  kind: ASTKind;
1059
1059
  };
1060
1060
  const createUnion: (json: UnionJSON) => {
1061
- types?: ASTNodeJSONOrKind[] | undefined;
1061
+ types?: ASTNodeJSONOrKind[];
1062
1062
  kind: ASTKind;
1063
1063
  };
1064
1064
  const createCustomType: (json: CustomTypeJSON) => {
@@ -1069,23 +1069,23 @@ declare namespace ASTFactory {
1069
1069
  * 声明相关
1070
1070
  */
1071
1071
  const createVariableDeclaration: <VariableMeta = any>(json: VariableDeclarationJSON<VariableMeta>) => {
1072
- key?: string | undefined;
1073
- type?: ASTNodeJSONOrKind | undefined;
1074
- initializer?: ASTNodeJSON | undefined;
1072
+ key?: Identifier;
1073
+ type?: ASTNodeJSONOrKind;
1074
+ initializer?: ASTNodeJSON;
1075
1075
  meta?: VariableMeta | undefined;
1076
- order?: number | undefined;
1076
+ order?: number;
1077
1077
  kind: ASTKind;
1078
1078
  };
1079
1079
  const createProperty: <VariableMeta = any>(json: PropertyJSON<VariableMeta>) => {
1080
- key: string;
1081
- type?: ASTNodeJSONOrKind | undefined;
1082
- initializer?: ASTNodeJSON | undefined;
1080
+ key: Identifier;
1081
+ type?: ASTNodeJSONOrKind;
1082
+ initializer?: ASTNodeJSON;
1083
1083
  meta?: VariableMeta | undefined;
1084
1084
  kind: ASTKind;
1085
1085
  };
1086
1086
  const createVariableDeclarationList: (json: VariableDeclarationListJSON) => {
1087
1087
  declarations?: VariableDeclarationJSON<any>[] | undefined;
1088
- startOrder?: number | undefined;
1088
+ startOrder?: number;
1089
1089
  kind: ASTKind;
1090
1090
  };
1091
1091
  /**
@@ -1106,14 +1106,19 @@ declare namespace ASTFactory {
1106
1106
  /**
1107
1107
  * 通过 AST Class 创建
1108
1108
  */
1109
- const create: <JSON_1 extends ASTNodeJSON>(targetType: {
1110
- new (...args: any[]): ASTNode<JSON_1, any>;
1109
+ const create: <JSON extends ASTNodeJSON>(targetType: {
1111
1110
  kind: string;
1112
- }, json: JSON_1) => {
1111
+ new (...args: any[]): ASTNode<JSON>;
1112
+ }, json: JSON) => {
1113
1113
  kind: string;
1114
- } & JSON_1;
1114
+ } & JSON;
1115
1115
  }
1116
1116
 
1117
+ /**
1118
+ * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
1119
+ * SPDX-License-Identifier: MIT
1120
+ */
1121
+
1117
1122
  declare namespace ASTMatch {
1118
1123
  /**
1119
1124
  * 类型相关
@@ -1137,7 +1142,7 @@ declare namespace ASTMatch {
1137
1142
  * 表达式相关
1138
1143
  */
1139
1144
  const isEnumerateExpression: (node?: ASTNode) => node is EnumerateExpression;
1140
- const isKeyPathExpression: (node?: ASTNode) => node is KeyPathExpression<KeyPathExpressionJSON$1>;
1145
+ const isKeyPathExpression: (node?: ASTNode) => node is KeyPathExpression;
1141
1146
  /**
1142
1147
  * Check AST Match by ASTClass
1143
1148
  */
@@ -1201,7 +1206,7 @@ declare class VariableEngine implements Disposable {
1201
1206
  protected toDispose: DisposableCollection;
1202
1207
  protected memo: {
1203
1208
  <T>(key: string | symbol, fn: () => T): T;
1204
- clear: (key?: (string | symbol) | undefined) => void;
1209
+ clear: (key?: string | symbol) => void;
1205
1210
  };
1206
1211
  protected scopeMap: Map<string | symbol, Scope<Record<string, any>>>;
1207
1212
  globalEvent$: Subject<GlobalEventActionType>;
package/dist/index.d.ts CHANGED
@@ -28,7 +28,7 @@ declare class ScopeOutputData {
28
28
  protected variableTable: IVariableTable;
29
29
  protected memo: {
30
30
  <T>(key: string | symbol, fn: () => T): T;
31
- clear: (key?: (string | symbol) | undefined) => void;
31
+ clear: (key?: string | symbol) => void;
32
32
  };
33
33
  get variableEngine(): VariableEngine;
34
34
  get globalVariableTable(): IVariableTable;
@@ -39,11 +39,11 @@ declare class ScopeOutputData {
39
39
  /**
40
40
  * listen to variable list change
41
41
  */
42
- get onVariableListChange(): (observer: (variables: VariableDeclaration<any>[]) => void) => _flowgram_ai_utils.Disposable;
42
+ get onVariableListChange(): (observer: (variables: VariableDeclaration[]) => void) => _flowgram_ai_utils.Disposable;
43
43
  /**
44
44
  * listen to any variable update in list
45
45
  */
46
- get onAnyVariableChange(): (observer: (changedVariable: VariableDeclaration<any>) => void) => _flowgram_ai_utils.Disposable;
46
+ get onAnyVariableChange(): (observer: (changedVariable: VariableDeclaration) => void) => _flowgram_ai_utils.Disposable;
47
47
  /**
48
48
  * listen to variable list change + any variable update in list
49
49
  */
@@ -74,7 +74,7 @@ declare class ScopeAvailableData {
74
74
  readonly scope: Scope;
75
75
  protected memo: {
76
76
  <T>(key: string | symbol, fn: () => T): T;
77
- clear: (key?: (string | symbol) | undefined) => void;
77
+ clear: (key?: string | symbol) => void;
78
78
  };
79
79
  get globalVariableTable(): IVariableTable;
80
80
  protected refresh$: Subject<void>;
@@ -195,7 +195,7 @@ declare class Scope<ScopeMeta extends Record<string, any> = Record<string, any>>
195
195
  */
196
196
  protected memo: {
197
197
  <T>(key: string | symbol, fn: () => T): T;
198
- clear: (key?: (string | symbol) | undefined) => void;
198
+ clear: (key?: string | symbol) => void;
199
199
  };
200
200
  toDispose: DisposableCollection;
201
201
  constructor(options: {
@@ -417,33 +417,33 @@ declare enum ASTKind {
417
417
  * 类型相关
418
418
  * - 内部默认实现一套基于 JSON 类型的类型 AST 节点
419
419
  */
420
- String = "String",
421
- Number = "Number",
422
- Integer = "Integer",
423
- Boolean = "Boolean",
424
- Object = "Object",
425
- Array = "Array",
426
- Map = "Map",
427
- Union = "Union",
428
- Any = "Any",
429
- CustomType = "CustomType",
420
+ String = "String",// 字符串
421
+ Number = "Number",// 数字
422
+ Integer = "Integer",// 整数
423
+ Boolean = "Boolean",// 布尔值
424
+ Object = "Object",// Object
425
+ Array = "Array",// Array
426
+ Map = "Map",// Map
427
+ Union = "Union",// 联合类型,常用于类型判断,一般不对业务透出
428
+ Any = "Any",// 任意类型,常用于业务判断
429
+ CustomType = "CustomType",// 自定义类型,用于业务自定义类型
430
430
  /**
431
431
  * 声明
432
432
  */
433
- Property = "Property",
434
- VariableDeclaration = "VariableDeclaration",
435
- VariableDeclarationList = "VariableDeclarationList",
433
+ Property = "Property",// Object 下钻的字段定义
434
+ VariableDeclaration = "VariableDeclaration",// 变量声明
435
+ VariableDeclarationList = "VariableDeclarationList",// 变量声明
436
436
  /**
437
437
  * 表达式
438
438
  */
439
- KeyPathExpression = "KeyPathExpression",
440
- EnumerateExpression = "EnumerateExpression",
441
- WrapArrayExpression = "WrapArrayExpression",
439
+ KeyPathExpression = "KeyPathExpression",// 通过路径系统访问变量上的字段
440
+ EnumerateExpression = "EnumerateExpression",// 对指定的数据进行遍历
441
+ WrapArrayExpression = "WrapArrayExpression",// Wrap with Array Type
442
442
  /**
443
443
  * 通用 AST 节点
444
444
  */
445
- ListNode = "ListNode",
446
- DataNode = "DataNode",
445
+ ListNode = "ListNode",// 通用 List<ASTNode> 存储节点
446
+ DataNode = "DataNode",// 通用的数据存储节点
447
447
  MapNode = "MapNode"
448
448
  }
449
449
  interface CreateASTParams {
@@ -522,10 +522,10 @@ declare enum ASTNodeFlags {
522
522
  /**
523
523
  * 变量类型
524
524
  */
525
- BasicType = 8,
526
- DrilldownType = 16,
527
- EnumerateType = 32,
528
- UnionType = 64,
525
+ BasicType = 8,// 基础类型
526
+ DrilldownType = 16,// 可下钻的变量类型
527
+ EnumerateType = 32,// 可遍历的变量类型
528
+ UnionType = 64,// 复合类型,暂时不存在
529
529
  VariableType = 120
530
530
  }
531
531
 
@@ -1049,16 +1049,16 @@ declare namespace ASTFactory {
1049
1049
  kind: ASTKind;
1050
1050
  };
1051
1051
  const createArray: (json: ArrayJSON) => {
1052
- items?: ASTNodeJSONOrKind | undefined;
1052
+ items?: ASTNodeJSONOrKind;
1053
1053
  kind: ASTKind;
1054
1054
  };
1055
1055
  const createMap: (json: MapJSON) => {
1056
- keyType?: ASTNodeJSONOrKind | undefined;
1057
- valueType?: ASTNodeJSONOrKind | undefined;
1056
+ keyType?: ASTNodeJSONOrKind;
1057
+ valueType?: ASTNodeJSONOrKind;
1058
1058
  kind: ASTKind;
1059
1059
  };
1060
1060
  const createUnion: (json: UnionJSON) => {
1061
- types?: ASTNodeJSONOrKind[] | undefined;
1061
+ types?: ASTNodeJSONOrKind[];
1062
1062
  kind: ASTKind;
1063
1063
  };
1064
1064
  const createCustomType: (json: CustomTypeJSON) => {
@@ -1069,23 +1069,23 @@ declare namespace ASTFactory {
1069
1069
  * 声明相关
1070
1070
  */
1071
1071
  const createVariableDeclaration: <VariableMeta = any>(json: VariableDeclarationJSON<VariableMeta>) => {
1072
- key?: string | undefined;
1073
- type?: ASTNodeJSONOrKind | undefined;
1074
- initializer?: ASTNodeJSON | undefined;
1072
+ key?: Identifier;
1073
+ type?: ASTNodeJSONOrKind;
1074
+ initializer?: ASTNodeJSON;
1075
1075
  meta?: VariableMeta | undefined;
1076
- order?: number | undefined;
1076
+ order?: number;
1077
1077
  kind: ASTKind;
1078
1078
  };
1079
1079
  const createProperty: <VariableMeta = any>(json: PropertyJSON<VariableMeta>) => {
1080
- key: string;
1081
- type?: ASTNodeJSONOrKind | undefined;
1082
- initializer?: ASTNodeJSON | undefined;
1080
+ key: Identifier;
1081
+ type?: ASTNodeJSONOrKind;
1082
+ initializer?: ASTNodeJSON;
1083
1083
  meta?: VariableMeta | undefined;
1084
1084
  kind: ASTKind;
1085
1085
  };
1086
1086
  const createVariableDeclarationList: (json: VariableDeclarationListJSON) => {
1087
1087
  declarations?: VariableDeclarationJSON<any>[] | undefined;
1088
- startOrder?: number | undefined;
1088
+ startOrder?: number;
1089
1089
  kind: ASTKind;
1090
1090
  };
1091
1091
  /**
@@ -1106,14 +1106,19 @@ declare namespace ASTFactory {
1106
1106
  /**
1107
1107
  * 通过 AST Class 创建
1108
1108
  */
1109
- const create: <JSON_1 extends ASTNodeJSON>(targetType: {
1110
- new (...args: any[]): ASTNode<JSON_1, any>;
1109
+ const create: <JSON extends ASTNodeJSON>(targetType: {
1111
1110
  kind: string;
1112
- }, json: JSON_1) => {
1111
+ new (...args: any[]): ASTNode<JSON>;
1112
+ }, json: JSON) => {
1113
1113
  kind: string;
1114
- } & JSON_1;
1114
+ } & JSON;
1115
1115
  }
1116
1116
 
1117
+ /**
1118
+ * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
1119
+ * SPDX-License-Identifier: MIT
1120
+ */
1121
+
1117
1122
  declare namespace ASTMatch {
1118
1123
  /**
1119
1124
  * 类型相关
@@ -1137,7 +1142,7 @@ declare namespace ASTMatch {
1137
1142
  * 表达式相关
1138
1143
  */
1139
1144
  const isEnumerateExpression: (node?: ASTNode) => node is EnumerateExpression;
1140
- const isKeyPathExpression: (node?: ASTNode) => node is KeyPathExpression<KeyPathExpressionJSON$1>;
1145
+ const isKeyPathExpression: (node?: ASTNode) => node is KeyPathExpression;
1141
1146
  /**
1142
1147
  * Check AST Match by ASTClass
1143
1148
  */
@@ -1201,7 +1206,7 @@ declare class VariableEngine implements Disposable {
1201
1206
  protected toDispose: DisposableCollection;
1202
1207
  protected memo: {
1203
1208
  <T>(key: string | symbol, fn: () => T): T;
1204
- clear: (key?: (string | symbol) | undefined) => void;
1209
+ clear: (key?: string | symbol) => void;
1205
1210
  };
1206
1211
  protected scopeMap: Map<string | symbol, Scope<Record<string, any>>>;
1207
1212
  globalEvent$: Subject<GlobalEventActionType>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@flowgram.ai/variable-core",
3
- "version": "0.2.27",
3
+ "version": "0.2.29",
4
4
  "description": "variable engine based on scope",
5
5
  "keywords": [
6
6
  "flow",
@@ -29,8 +29,8 @@
29
29
  "nanoid": "^4.0.2",
30
30
  "reflect-metadata": "~0.2.2",
31
31
  "rxjs": "^7.8.1",
32
- "@flowgram.ai/core": "0.2.27",
33
- "@flowgram.ai/utils": "0.2.27"
32
+ "@flowgram.ai/core": "0.2.29",
33
+ "@flowgram.ai/utils": "0.2.29"
34
34
  },
35
35
  "devDependencies": {
36
36
  "@types/lodash": "^4.14.137",
@@ -39,10 +39,10 @@
39
39
  "@vitest/coverage-v8": "^0.32.0",
40
40
  "eslint": "^8.54.0",
41
41
  "tsup": "^8.0.1",
42
- "typescript": "^5.0.4",
42
+ "typescript": "^5.8.3",
43
43
  "vitest": "^0.34.6",
44
- "@flowgram.ai/eslint-config": "0.2.27",
45
- "@flowgram.ai/ts-config": "0.2.27"
44
+ "@flowgram.ai/ts-config": "0.2.29",
45
+ "@flowgram.ai/eslint-config": "0.2.29"
46
46
  },
47
47
  "peerDependencies": {
48
48
  "react": ">=16.8",