@flowgram.ai/variable-core 0.1.17 → 0.1.21

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
@@ -896,9 +896,48 @@ declare namespace ASTFactory {
896
896
  } & JSON_1;
897
897
  }
898
898
 
899
+ declare namespace ASTMatch {
900
+ /**
901
+ * 类型相关
902
+ * @returns
903
+ */
904
+ const isString: (node?: ASTNode) => node is StringType;
905
+ const isNumber: (node?: ASTNode) => node is NumberType;
906
+ const isBoolean: (node?: ASTNode) => node is BooleanType;
907
+ const isInteger: (node?: ASTNode) => node is IntegerType;
908
+ const isObject: (node?: ASTNode) => node is ObjectType;
909
+ const isArray: (node?: ASTNode) => node is ArrayType;
910
+ const isMap: (node?: ASTNode) => node is MapType;
911
+ const isCustomType: (node?: ASTNode) => node is CustomType;
912
+ /**
913
+ * 声明相关
914
+ */
915
+ const isVariableDeclaration: <VariableMeta = any>(node?: ASTNode) => node is VariableDeclaration<VariableMeta>;
916
+ const isProperty: <VariableMeta = any>(node?: ASTNode) => node is Property<VariableMeta>;
917
+ const isVariableDeclarationList: (node?: ASTNode) => node is VariableDeclarationList;
918
+ /**
919
+ * 表达式相关
920
+ */
921
+ const isEnumerateExpression: (node?: ASTNode) => node is EnumerateExpression;
922
+ const isKeyPathExpression: (node?: ASTNode) => node is KeyPathExpression<KeyPathExpressionJSON$1>;
923
+ /**
924
+ * Check AST Match by ASTClass
925
+ */
926
+ function is<TargetASTNode extends ASTNode>(node?: ASTNode, targetType?: {
927
+ kind: string;
928
+ new (...args: any[]): TargetASTNode;
929
+ }): node is TargetASTNode;
930
+ }
931
+
899
932
  declare const injectToAST: (serviceIdentifier: interfaces.ServiceIdentifier) => (target: any, propertyKey: string) => any;
900
933
  declare const postConstructAST: () => (target: any, propertyKey: string) => void;
901
934
 
935
+ /**
936
+ * isMatchAST is same as ASTMatch.is
937
+ * @param node
938
+ * @param targetType
939
+ * @returns
940
+ */
902
941
  declare function isMatchAST<TargetASTNode extends ASTNode>(node?: ASTNode, targetType?: {
903
942
  kind: string;
904
943
  new (...args: any[]): TargetASTNode;
@@ -1023,4 +1062,4 @@ declare class VariableFieldKeyRenameService {
1023
1062
  dispose(): void;
1024
1063
  }
1025
1064
 
1026
- export { ASTFactory, ASTKind, ASTNode, ASTNodeFlags, type ASTNodeJSON, type ASTNodeRegistry, ASTRegisters, ArrayType, BaseExpression, BaseType, BaseVariableField, BooleanType, type CreateASTParams, CustomType, type CustomTypeJSON, DataNode, EnumerateExpression, type EnumerateExpressionJSON, ExpressionList, type ExpressionListJSON, type GetKindJSON, type GetKindJSONOrKind, type GlobalEventActionType, IntegerType, KeyPathExpression, type KeyPathExpressionJSON$1 as KeyPathExpressionJSON, KeyPathExpressionV2, ListNode, type ListNodeJSON, MapNode, type MapNodeJSON, MapType, NumberType, type ObjectJSON, type ObjectPropertiesChangeAction, ObjectType, Property, type PropertyJSON, Scope, ScopeChain, ScopeOutputData, ScopeProvider, StringType, type UnionJSON, VariableContainerModule, VariableDeclaration, type VariableDeclarationJSON, VariableDeclarationList, type VariableDeclarationListChangeAction, type VariableDeclarationListJSON, VariableEngine, VariableEngineProvider, VariableFieldKeyRenameService, VariableTable, injectToAST, isMatchAST, postConstructAST, useAvailableVariables, useCurrentScope, useScopeAvailable, useScopeContext };
1065
+ export { ASTFactory, ASTKind, ASTMatch, ASTNode, ASTNodeFlags, type ASTNodeJSON, type ASTNodeRegistry, ASTRegisters, ArrayType, BaseExpression, BaseType, BaseVariableField, BooleanType, type CreateASTParams, CustomType, type CustomTypeJSON, DataNode, EnumerateExpression, type EnumerateExpressionJSON, ExpressionList, type ExpressionListJSON, type GetKindJSON, type GetKindJSONOrKind, type GlobalEventActionType, IntegerType, KeyPathExpression, type KeyPathExpressionJSON$1 as KeyPathExpressionJSON, KeyPathExpressionV2, ListNode, type ListNodeJSON, MapNode, type MapNodeJSON, MapType, NumberType, type ObjectJSON, type ObjectPropertiesChangeAction, ObjectType, Property, type PropertyJSON, Scope, ScopeChain, ScopeOutputData, ScopeProvider, StringType, type UnionJSON, VariableContainerModule, VariableDeclaration, type VariableDeclarationJSON, VariableDeclarationList, type VariableDeclarationListChangeAction, type VariableDeclarationListJSON, VariableEngine, VariableEngineProvider, VariableFieldKeyRenameService, VariableTable, injectToAST, isMatchAST, postConstructAST, useAvailableVariables, useCurrentScope, useScopeAvailable, useScopeContext };
package/dist/index.d.ts CHANGED
@@ -896,9 +896,48 @@ declare namespace ASTFactory {
896
896
  } & JSON_1;
897
897
  }
898
898
 
899
+ declare namespace ASTMatch {
900
+ /**
901
+ * 类型相关
902
+ * @returns
903
+ */
904
+ const isString: (node?: ASTNode) => node is StringType;
905
+ const isNumber: (node?: ASTNode) => node is NumberType;
906
+ const isBoolean: (node?: ASTNode) => node is BooleanType;
907
+ const isInteger: (node?: ASTNode) => node is IntegerType;
908
+ const isObject: (node?: ASTNode) => node is ObjectType;
909
+ const isArray: (node?: ASTNode) => node is ArrayType;
910
+ const isMap: (node?: ASTNode) => node is MapType;
911
+ const isCustomType: (node?: ASTNode) => node is CustomType;
912
+ /**
913
+ * 声明相关
914
+ */
915
+ const isVariableDeclaration: <VariableMeta = any>(node?: ASTNode) => node is VariableDeclaration<VariableMeta>;
916
+ const isProperty: <VariableMeta = any>(node?: ASTNode) => node is Property<VariableMeta>;
917
+ const isVariableDeclarationList: (node?: ASTNode) => node is VariableDeclarationList;
918
+ /**
919
+ * 表达式相关
920
+ */
921
+ const isEnumerateExpression: (node?: ASTNode) => node is EnumerateExpression;
922
+ const isKeyPathExpression: (node?: ASTNode) => node is KeyPathExpression<KeyPathExpressionJSON$1>;
923
+ /**
924
+ * Check AST Match by ASTClass
925
+ */
926
+ function is<TargetASTNode extends ASTNode>(node?: ASTNode, targetType?: {
927
+ kind: string;
928
+ new (...args: any[]): TargetASTNode;
929
+ }): node is TargetASTNode;
930
+ }
931
+
899
932
  declare const injectToAST: (serviceIdentifier: interfaces.ServiceIdentifier) => (target: any, propertyKey: string) => any;
900
933
  declare const postConstructAST: () => (target: any, propertyKey: string) => void;
901
934
 
935
+ /**
936
+ * isMatchAST is same as ASTMatch.is
937
+ * @param node
938
+ * @param targetType
939
+ * @returns
940
+ */
902
941
  declare function isMatchAST<TargetASTNode extends ASTNode>(node?: ASTNode, targetType?: {
903
942
  kind: string;
904
943
  new (...args: any[]): TargetASTNode;
@@ -1023,4 +1062,4 @@ declare class VariableFieldKeyRenameService {
1023
1062
  dispose(): void;
1024
1063
  }
1025
1064
 
1026
- export { ASTFactory, ASTKind, ASTNode, ASTNodeFlags, type ASTNodeJSON, type ASTNodeRegistry, ASTRegisters, ArrayType, BaseExpression, BaseType, BaseVariableField, BooleanType, type CreateASTParams, CustomType, type CustomTypeJSON, DataNode, EnumerateExpression, type EnumerateExpressionJSON, ExpressionList, type ExpressionListJSON, type GetKindJSON, type GetKindJSONOrKind, type GlobalEventActionType, IntegerType, KeyPathExpression, type KeyPathExpressionJSON$1 as KeyPathExpressionJSON, KeyPathExpressionV2, ListNode, type ListNodeJSON, MapNode, type MapNodeJSON, MapType, NumberType, type ObjectJSON, type ObjectPropertiesChangeAction, ObjectType, Property, type PropertyJSON, Scope, ScopeChain, ScopeOutputData, ScopeProvider, StringType, type UnionJSON, VariableContainerModule, VariableDeclaration, type VariableDeclarationJSON, VariableDeclarationList, type VariableDeclarationListChangeAction, type VariableDeclarationListJSON, VariableEngine, VariableEngineProvider, VariableFieldKeyRenameService, VariableTable, injectToAST, isMatchAST, postConstructAST, useAvailableVariables, useCurrentScope, useScopeAvailable, useScopeContext };
1065
+ export { ASTFactory, ASTKind, ASTMatch, ASTNode, ASTNodeFlags, type ASTNodeJSON, type ASTNodeRegistry, ASTRegisters, ArrayType, BaseExpression, BaseType, BaseVariableField, BooleanType, type CreateASTParams, CustomType, type CustomTypeJSON, DataNode, EnumerateExpression, type EnumerateExpressionJSON, ExpressionList, type ExpressionListJSON, type GetKindJSON, type GetKindJSONOrKind, type GlobalEventActionType, IntegerType, KeyPathExpression, type KeyPathExpressionJSON$1 as KeyPathExpressionJSON, KeyPathExpressionV2, ListNode, type ListNodeJSON, MapNode, type MapNodeJSON, MapType, NumberType, type ObjectJSON, type ObjectPropertiesChangeAction, ObjectType, Property, type PropertyJSON, Scope, ScopeChain, ScopeOutputData, ScopeProvider, StringType, type UnionJSON, VariableContainerModule, VariableDeclaration, type VariableDeclarationJSON, VariableDeclarationList, type VariableDeclarationListChangeAction, type VariableDeclarationListJSON, VariableEngine, VariableEngineProvider, VariableFieldKeyRenameService, VariableTable, injectToAST, isMatchAST, postConstructAST, useAvailableVariables, useCurrentScope, useScopeAvailable, useScopeContext };
package/dist/index.js CHANGED
@@ -31,6 +31,7 @@ var src_exports = {};
31
31
  __export(src_exports, {
32
32
  ASTFactory: () => ASTFactory,
33
33
  ASTKind: () => ASTKind,
34
+ ASTMatch: () => ASTMatch,
34
35
  ASTNode: () => ASTNode,
35
36
  ASTNodeFlags: () => ASTNodeFlags,
36
37
  ASTRegisters: () => ASTRegisters,
@@ -212,6 +213,28 @@ var postConstructAST = () => (target, propertyKey) => {
212
213
  }
213
214
  };
214
215
 
216
+ // src/ast/match.ts
217
+ var ASTMatch;
218
+ ((ASTMatch2) => {
219
+ ASTMatch2.isString = (node) => node?.kind === "String" /* String */;
220
+ ASTMatch2.isNumber = (node) => node?.kind === "Number" /* Number */;
221
+ ASTMatch2.isBoolean = (node) => node?.kind === "Boolean" /* Boolean */;
222
+ ASTMatch2.isInteger = (node) => node?.kind === "Integer" /* Integer */;
223
+ ASTMatch2.isObject = (node) => node?.kind === "Object" /* Object */;
224
+ ASTMatch2.isArray = (node) => node?.kind === "Array" /* Array */;
225
+ ASTMatch2.isMap = (node) => node?.kind === "Map" /* Map */;
226
+ ASTMatch2.isCustomType = (node) => node?.kind === "CustomType" /* CustomType */;
227
+ ASTMatch2.isVariableDeclaration = (node) => node?.kind === "VariableDeclaration" /* VariableDeclaration */;
228
+ ASTMatch2.isProperty = (node) => node?.kind === "Property" /* Property */;
229
+ ASTMatch2.isVariableDeclarationList = (node) => node?.kind === "VariableDeclarationList" /* VariableDeclarationList */;
230
+ ASTMatch2.isEnumerateExpression = (node) => node?.kind === "EnumerateExpression" /* EnumerateExpression */;
231
+ ASTMatch2.isKeyPathExpression = (node) => node?.kind === "KeyPathExpression" /* KeyPathExpression */;
232
+ function is(node, targetType) {
233
+ return node?.kind === targetType?.kind;
234
+ }
235
+ ASTMatch2.is = is;
236
+ })(ASTMatch || (ASTMatch = {}));
237
+
215
238
  // src/ast/utils/helpers.ts
216
239
  function updateChildNodeHelper({
217
240
  getChildNode,
@@ -247,7 +270,7 @@ function getAllChildren(ast) {
247
270
  return [...ast.children, ...ast.children.map((_child) => getAllChildren(_child)).flat()];
248
271
  }
249
272
  function isMatchAST(node, targetType) {
250
- return node?.kind === targetType?.kind;
273
+ return ASTMatch.is(node, targetType);
251
274
  }
252
275
 
253
276
  // src/ast/flags.ts
@@ -2060,6 +2083,7 @@ function useAvailableVariables() {
2060
2083
  0 && (module.exports = {
2061
2084
  ASTFactory,
2062
2085
  ASTKind,
2086
+ ASTMatch,
2063
2087
  ASTNode,
2064
2088
  ASTNodeFlags,
2065
2089
  ASTRegisters,