@flowgram.ai/variable-core 0.4.6 → 0.4.8

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
@@ -627,10 +627,21 @@ declare abstract class BaseType<JSON extends ASTNodeJSON = any, InjectOpts = any
627
627
  * SPDX-License-Identifier: MIT
628
628
  */
629
629
 
630
+ interface StringJSON {
631
+ /**
632
+ * https://json-schema.org/understanding-json-schema/reference/type#format
633
+ */
634
+ format?: string;
635
+ }
630
636
  declare class StringType extends BaseType {
631
637
  flags: ASTNodeFlags;
632
638
  static kind: string;
633
- fromJSON(): void;
639
+ protected _format?: string;
640
+ /**
641
+ * https://json-schema.org/understanding-json-schema/reference/type#format
642
+ */
643
+ get format(): string | undefined;
644
+ fromJSON(json?: StringJSON): void;
634
645
  }
635
646
 
636
647
  /**
@@ -1034,7 +1045,8 @@ declare namespace ASTFactory {
1034
1045
  * 类型相关
1035
1046
  * @returns
1036
1047
  */
1037
- const createString: () => {
1048
+ const createString: (json?: StringJSON) => {
1049
+ format?: string;
1038
1050
  kind: ASTKind;
1039
1051
  };
1040
1052
  const createNumber: () => {
package/dist/index.d.ts CHANGED
@@ -627,10 +627,21 @@ declare abstract class BaseType<JSON extends ASTNodeJSON = any, InjectOpts = any
627
627
  * SPDX-License-Identifier: MIT
628
628
  */
629
629
 
630
+ interface StringJSON {
631
+ /**
632
+ * https://json-schema.org/understanding-json-schema/reference/type#format
633
+ */
634
+ format?: string;
635
+ }
630
636
  declare class StringType extends BaseType {
631
637
  flags: ASTNodeFlags;
632
638
  static kind: string;
633
- fromJSON(): void;
639
+ protected _format?: string;
640
+ /**
641
+ * https://json-schema.org/understanding-json-schema/reference/type#format
642
+ */
643
+ get format(): string | undefined;
644
+ fromJSON(json?: StringJSON): void;
634
645
  }
635
646
 
636
647
  /**
@@ -1034,7 +1045,8 @@ declare namespace ASTFactory {
1034
1045
  * 类型相关
1035
1046
  * @returns
1036
1047
  */
1037
- const createString: () => {
1048
+ const createString: (json?: StringJSON) => {
1049
+ format?: string;
1038
1050
  kind: ASTKind;
1039
1051
  };
1040
1052
  const createNumber: () => {
package/dist/index.js CHANGED
@@ -319,7 +319,7 @@ var ASTKind = /* @__PURE__ */ ((ASTKind2) => {
319
319
  })(ASTKind || {});
320
320
 
321
321
  // src/ast/ast-registers.ts
322
- var import_lodash3 = require("lodash");
322
+ var import_lodash_es3 = require("lodash-es");
323
323
  var import_inversify3 = require("inversify");
324
324
 
325
325
  // src/ast/utils/inversify.ts
@@ -729,7 +729,17 @@ var StringType = class extends BaseType {
729
729
  super(...arguments);
730
730
  this.flags = 8 /* BasicType */;
731
731
  }
732
- fromJSON() {
732
+ /**
733
+ * https://json-schema.org/understanding-json-schema/reference/type#format
734
+ */
735
+ get format() {
736
+ return this._format;
737
+ }
738
+ fromJSON(json) {
739
+ if (json?.format !== this._format) {
740
+ this._format = json?.format;
741
+ this.fireChange();
742
+ }
733
743
  }
734
744
  };
735
745
  StringType.kind = "String" /* String */;
@@ -807,7 +817,7 @@ var MapType = class extends BaseType {
807
817
  MapType.kind = "Map" /* Map */;
808
818
 
809
819
  // src/ast/type/object.ts
810
- var import_lodash = require("lodash");
820
+ var import_lodash_es = require("lodash-es");
811
821
  var ObjectType = class extends BaseType {
812
822
  constructor() {
813
823
  super(...arguments);
@@ -887,7 +897,7 @@ var ObjectType = class extends BaseType {
887
897
  const targetProperties = targetTypeJSON.properties || [];
888
898
  const sourcePropertyKeys = Array.from(this.propertyTable.keys());
889
899
  const targetPropertyKeys = targetProperties.map((_target) => _target.key);
890
- const isKeyStrongEqual = !(0, import_lodash.xor)(sourcePropertyKeys, targetPropertyKeys).length;
900
+ const isKeyStrongEqual = !(0, import_lodash_es.xor)(sourcePropertyKeys, targetPropertyKeys).length;
891
901
  return isKeyStrongEqual && targetProperties.every((targetProperty) => {
892
902
  const sourceProperty = this.propertyTable.get(targetProperty.key);
893
903
  return sourceProperty && sourceProperty.key === targetProperty.key && sourceProperty.type?.isTypeEqual(targetProperty?.type);
@@ -1083,12 +1093,12 @@ EnumerateExpression.kind = "EnumerateExpression" /* EnumerateExpression */;
1083
1093
  var import_fast_equals4 = require("fast-equals");
1084
1094
 
1085
1095
  // src/ast/utils/expression.ts
1086
- var import_lodash2 = require("lodash");
1096
+ var import_lodash_es2 = require("lodash-es");
1087
1097
  function getAllRefs(ast) {
1088
1098
  return getAllChildren(ast).filter((_child) => _child.flags & 4 /* Expression */).map((_child) => _child.refs).flat().filter(Boolean);
1089
1099
  }
1090
1100
  function checkRefCycle(curr, refNodes) {
1091
- if ((0, import_lodash2.intersection)(curr.scope.coverScopes, refNodes.map((_ref) => _ref?.scope).filter(Boolean)).length === 0) {
1101
+ if ((0, import_lodash_es2.intersection)(curr.scope.coverScopes, refNodes.map((_ref) => _ref?.scope).filter(Boolean)).length === 0) {
1092
1102
  return false;
1093
1103
  }
1094
1104
  const visited = /* @__PURE__ */ new Set();
@@ -1100,7 +1110,7 @@ function checkRefCycle(curr, refNodes) {
1100
1110
  queue.push(ref);
1101
1111
  }
1102
1112
  }
1103
- return (0, import_lodash2.intersection)(Array.from(visited), getParentFields(curr)).length > 0;
1113
+ return (0, import_lodash_es2.intersection)(Array.from(visited), getParentFields(curr)).length > 0;
1104
1114
  }
1105
1115
 
1106
1116
  // src/ast/expression/keypath-expression-v2.ts
@@ -1553,7 +1563,7 @@ var ASTRegisters = class {
1553
1563
  injector?.() || {}
1554
1564
  );
1555
1565
  node.changeLocked = true;
1556
- node.fromJSON((0, import_lodash3.omit)(json, ["key", "kind"]));
1566
+ node.fromJSON((0, import_lodash_es3.omit)(json, ["key", "kind"]));
1557
1567
  node.changeLocked = false;
1558
1568
  node.dispatchGlobalEvent({ type: "NewAST" });
1559
1569
  if (Reflect.hasMetadata(POST_CONSTRUCT_AST_SYMBOL, node)) {
@@ -1589,7 +1599,10 @@ ASTRegisters = __decorateClass([
1589
1599
  // src/ast/factory.ts
1590
1600
  var ASTFactory;
1591
1601
  ((ASTFactory2) => {
1592
- ASTFactory2.createString = () => ({ kind: "String" /* String */ });
1602
+ ASTFactory2.createString = (json) => ({
1603
+ kind: "String" /* String */,
1604
+ ...json || {}
1605
+ });
1593
1606
  ASTFactory2.createNumber = () => ({ kind: "Number" /* Number */ });
1594
1607
  ASTFactory2.createBoolean = () => ({ kind: "Boolean" /* Boolean */ });
1595
1608
  ASTFactory2.createInteger = () => ({ kind: "Integer" /* Integer */ });
@@ -1745,7 +1758,7 @@ var ScopeOutputData = class {
1745
1758
 
1746
1759
  // src/scope/datas/scope-available-data.ts
1747
1760
  var import_rxjs4 = require("rxjs");
1748
- var import_lodash4 = require("lodash");
1761
+ var import_lodash_es4 = require("lodash-es");
1749
1762
  var import_fast_equals7 = require("fast-equals");
1750
1763
  var import_utils5 = require("@flowgram.ai/utils");
1751
1764
  var import_utils6 = require("@flowgram.ai/utils");
@@ -1761,7 +1774,7 @@ var ScopeAvailableData = class {
1761
1774
  */
1762
1775
  this.variables$ = this.refresh$.pipe(
1763
1776
  // 输出变量是否 version 发生变化
1764
- (0, import_rxjs4.map)(() => (0, import_lodash4.flatten)(this.depScopes.map((scope) => scope.output.variables || []))),
1777
+ (0, import_rxjs4.map)(() => (0, import_lodash_es4.flatten)(this.depScopes.map((scope) => scope.output.variables || []))),
1765
1778
  // 变量列表浅比较
1766
1779
  (0, import_rxjs4.distinctUntilChanged)(import_fast_equals7.shallowEqual),
1767
1780
  (0, import_rxjs4.share)()
@@ -2118,7 +2131,7 @@ VariableEngine = __decorateClass([
2118
2131
  ], VariableEngine);
2119
2132
 
2120
2133
  // src/services/variable-field-key-rename-service.ts
2121
- var import_lodash5 = require("lodash");
2134
+ var import_lodash_es5 = require("lodash-es");
2122
2135
  var import_inversify7 = require("inversify");
2123
2136
  var import_utils10 = require("@flowgram.ai/utils");
2124
2137
  var VariableFieldKeyRenameService = class {
@@ -2161,7 +2174,7 @@ var VariableFieldKeyRenameService = class {
2161
2174
  this.renameEmitter.fire(renameNodeInfo);
2162
2175
  }
2163
2176
  notifyFieldsDispose(prev, next) {
2164
- const removedFields = (0, import_lodash5.difference)(prev || [], next || []);
2177
+ const removedFields = (0, import_lodash_es5.difference)(prev || [], next || []);
2165
2178
  removedFields.forEach((_field) => this.disposeInListEmitter.fire(_field));
2166
2179
  }
2167
2180
  init() {