@kestra-io/ui-libs 0.0.192 → 0.0.194

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.
@@ -13,6 +13,11 @@ export declare function extractBlockWithPath({ source, path }: {
13
13
  source: string;
14
14
  path: string;
15
15
  }): string | undefined;
16
+ export declare function replaceBlockWithPath({ source, path, newContent }: {
17
+ source: string;
18
+ path: string;
19
+ newContent: string;
20
+ }): string;
16
21
  export declare function replaceBlockInDocument({ source, section, keyName, key, newContent }: {
17
22
  source: string;
18
23
  section: string;
@@ -50,7 +55,7 @@ export declare function deleteBlock({ source, section, key, keyName }: {
50
55
  section: string;
51
56
  key: string;
52
57
  keyName?: string;
53
- }): any;
58
+ }): string;
54
59
  export declare function deleteBlockWithPath({ source, path }: {
55
60
  source: string;
56
61
  path: string;
@@ -87,7 +92,7 @@ export declare function deleteMetadata(source: any, metadata: any): any;
87
92
  export declare function flowHaveTasks(source: string): boolean;
88
93
  export declare function extractPluginDefault(source: string, pluginType: string): string | undefined;
89
94
  export declare function replacePluginDefaultsInDocument(source: string, pluginType: string, newContent: string): string | undefined;
90
- export declare function deletePluginDefaults(source: string, pluginType: string): any;
95
+ export declare function deletePluginDefaults(source: string, pluginType: string): string;
91
96
  export declare function insertErrorInFlowable(source: string, errorTask: string, flowableTask: string): any;
92
97
  /**
93
98
  * Specify a source yaml doc, the field to extract recursively in every map of the doc and optionally
@@ -95,7 +100,7 @@ export declare function insertErrorInFlowable(source: string, errorTask: string,
95
100
  * will take a single argument which is the path of each parent property starting from the root doc (joined with ".")
96
101
  * "my.parent.task" will mean that the field was retrieved in my -> parent -> task path.
97
102
  */
98
- export declare function extractFieldFromMaps<T extends string>(source: string, fieldName: T, parentPathPredicate?: (_: any, __?: any) => boolean, valuePredicate?: (_: any) => boolean): (Record<T, any> & {
103
+ export declare function extractFieldFromMaps<T extends string>(source: string, fieldName: T, parentPathPredicate?: (_: any, __?: any) => boolean, valuePredicate?: (_: any) => boolean, keepEmptyFields?: boolean): (Record<T, any> & {
99
104
  range: Range;
100
105
  })[];
101
106
  /**
@@ -106,6 +111,14 @@ export declare function getTypeAtPosition(source: string, position: {
106
111
  lineNumber: number;
107
112
  column: number;
108
113
  }, validTypes: any): any;
114
+ /**
115
+ * Get task version at cursor position.
116
+ * Useful to display/update the live docs
117
+ */
118
+ export declare function getVersionAtPosition(source: string, position: {
119
+ lineNumber: number;
120
+ column: number;
121
+ }): any;
109
122
  export type YamlElement = {
110
123
  key?: string;
111
124
  value: Record<string, any>;
@@ -1 +1 @@
1
- {"version":3,"file":"FlowYamlUtils.d.ts","sourceRoot":"","sources":["../../src/utils/FlowYamlUtils.ts"],"names":[],"mappings":"AACA,OAAO,EAEH,OAAO,EAWP,KAAK,EACR,MAAM,MAAM,CAAC;AAGd,wBAAgB,KAAK,CAAC,CAAC,GAAG,GAAG,EAAE,IAAI,CAAC,EAAE,MAAM,EAAE,YAAY,UAAO,GAAG,CAAC,GAAG,SAAS,CAShF;AAED,wBAAgB,SAAS,CAAC,IAAI,EAAE,GAAG,UAWlC;AAiBD,wBAAgB,IAAI,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,YAU9C;AAED,wBAAgB,UAAU,CAAC,KAAK,CAAC,EAAE,GAAG,EAAE,6BAUvC;AA0CD,wBAAgB,YAAY,CAAC,EAAC,MAAM,EAAE,OAAO,EAAE,GAAG,EAAE,OAAO,EAAC,EAAE;IAC1D,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,CAAC;IAChB,GAAG,EAAE,MAAM,CAAC;IACZ,OAAO,CAAC,EAAE,MAAM,CAAA;CACnB,sBAkBA;AAyDD,wBAAgB,oBAAoB,CAAC,EAAC,MAAM,EAAE,IAAI,EAAC,EAAE;IACjD,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAA;CACf,sBASA;AAoBD,wBAAgB,sBAAsB,CAAC,EAAC,MAAM,EAAE,OA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M,EAAE,MAAM,CAAC,CAAC;CACpC,CAAC;AAEF,wBAAgB,sBAAsB,CAAC,MAAM,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,GAAG,WAAW,CAiDzF;AAID,wBAAgB,YAAY,CAAC,MAAM,EAAE,MAAM,YAmB1C;AAED,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE;IAAE,UAAU,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,OA+BlG"}
@@ -1,5 +1,5 @@
1
1
  import yaml from "yaml";
2
- import { cleanMetadata, deleteMetadata, deletePluginDefaults, extractPluginDefault, flowHaveTasks, getAllCharts, getChartAtPosition, getMetadata, getTypeAtPosition as getTaskType, insertErrorInFlowable, localizeElementAtIndex, pairsToMap, parse, replaceIdAndNamespace, replacePluginDefaultsInDocument, sort, stringify, updateMetadata, extractFieldFromMaps } from "./FlowYamlUtils";
2
+ import { cleanMetadata, deleteMetadata, deletePluginDefaults, extractPluginDefault, flowHaveTasks, getAllCharts, getChartAtPosition, getMetadata, getVersionAtPosition, getTypeAtPosition as getTaskType, insertErrorInFlowable, localizeElementAtIndex, pairsToMap, parse, replaceIdAndNamespace, replacePluginDefaultsInDocument, sort, stringify, updateMetadata, extractFieldFromMaps } from "./FlowYamlUtils";
3
3
  export type YamlElement = {
4
4
  key?: string;
5
5
  value: Record<string, any>;
@@ -32,7 +32,7 @@ export declare const YamlUtils: {
32
32
  * @param id the id of the item to delete
33
33
  * @returns yaml (source) without the item
34
34
  */
35
- deleteSection(source: string, section: string, id: string): any;
35
+ deleteSection(source: string, section: string, id: string): string;
36
36
  deleteTask(source: string, taskId: string, section: string): string;
37
37
  getLastTask(source: string, parentTaskId?: string): string | undefined;
38
38
  checkTaskAlreadyExist(source: string, taskYaml: string): any;
@@ -47,5 +47,6 @@ export declare const YamlUtils: {
47
47
  replacePluginDefaultsInDocument: typeof replacePluginDefaultsInDocument;
48
48
  deletePluginDefaults: typeof deletePluginDefaults;
49
49
  extractFieldFromMaps: typeof extractFieldFromMaps;
50
+ getVersionAtPosition: typeof getVersionAtPosition;
50
51
  };
51
52
  //# sourceMappingURL=YamlUtilsLegacy.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"YamlUtilsLegacy.d.ts","sourceRoot":"","sources":["../../src/utils/YamlUtilsLegacy.ts"],"names":[],"mappings":"AAAA,OAAO,IAGN,MAAM,MAAM,CAAC;AAEd,OAAO,EAEH,aAAa,EAAE,cAAc,EAC7B,oBAAoB,EAEpB,oBAAoB,EAEpB,aAAa,EAAE,YAAY,EAAE,kBAAkB,EAAgB,WAAW,EAC1E,iBAAiB,IAAI,WAAW,EAChC,qBAAqB,EAGrB,sBAAsB,EACtB,UAAU,EAAE,KAAK,EACjB,qBAAqB,EACrB,+BAA+B,EAE/B,IAAI,EAAE,SAAS,EAAE,cAAc,EAC/B,oBAAoB,EACvB,MAAM,iBAAiB,CAAC;AAEzB,MAAM,MAAM,WAAW,GAAG;IACtB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAC3B,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAAE,CAAC;IAC/B,KAAK,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;CACpC,CAAC;AAYF;;GAEG;AACH,eAAO,MAAM,SAAS;;;;wBAIE,MAAM,UAAU,MAAM;0BAY7B,UAAU,CAAC,OAAO,IAAI,CAAC,aAAa,CAAC,UACtC,MAAM,aACH,CAAC,OAAO,EAAE,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,GAAG,CAAC,KAAK,IAAI;kCAoD1B,MAAM,UAAU,MAAM,cAAc,MAAM,UAAS,MAAM,YAAqB,MAAM;;;;;;sBAoBhG,MAAM,WAAW,MAAM,WAAW,MAAM;uBA2B9C,MAAM,UACN,MAAM,WACL,MAAM,kBACC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AAG,CAAC,KAAK,IAAI;kCAoD1B,MAAM,UAAU,MAAM,cAAc,MAAM,UAAS,MAAM,YAAqB,MAAM;;;;;;sBAoBhG,MAAM,WAAW,MAAM,WAAW,MAAM;uBA2B9C,MAAM,UACN,MAAM,WACL,MAAM,kBACC,QAAQ,GAAG,OAAO,iBACnB,MAAM;+BAME,MAAM,UAAU,MAAM,QAAQ,MAAM;;IAM/D;;;;;;OAMG;0BACmB,MAAM,WAAW,MAAM,MAAM,MAAM;uBAItC,MAAM,UAAU,MAAM,WAAW,MAAM;wBAMtC,MAAM,iBAAiB,MAAM,GAAG,MAAM,GAAG,SAAS;kCAIxC,MAAM,YAAY,MAAM;qCASrB,MAAM,SAAS,MAAM,SAAS,MAAM;;;;;;;;;;;;CAgCxE,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kestra-io/ui-libs",
3
- "version": "0.0.192",
3
+ "version": "0.0.194",
4
4
  "type": "module",
5
5
  "files": [
6
6
  "dist",
@@ -596,6 +596,56 @@ describe("extractFieldFromMaps", () => {
596
596
  `;
597
597
  const result = YamlUtils.extractFieldFromMaps(yaml, "labels");
598
598
  expect(result).toEqual([]);
599
+ });
600
+ test("extract fields given keepEmptyFields equals true", () => {
601
+ const yaml = `
602
+ tasks:
603
+ - id: task1
604
+ type: io.kestra.plugin.core.log.Log
605
+ version: 0.0.1
606
+ - id: task2
607
+ type: io.kestra.plugin.core.log.Log
608
+ - id: task3
609
+ type: io.kestra.plugin.core.log.Log
610
+ version: 0.0.2
611
+ `;
612
+ const result = YamlUtils.extractFieldFromMaps(yaml, "version", () => true, () => true, true);
613
+ expect(result).toMatchInlineSnapshot(`
614
+ [
615
+ {
616
+ "range": [
617
+ 9,
618
+ 280,
619
+ 280,
620
+ ],
621
+ "version": undefined,
622
+ },
623
+ {
624
+ "range": [
625
+ 28,
626
+ 113,
627
+ 113,
628
+ ],
629
+ "version": "0.0.1",
630
+ },
631
+ {
632
+ "range": [
633
+ 125,
634
+ 183,
635
+ 183,
636
+ ],
637
+ "version": undefined,
638
+ },
639
+ {
640
+ "range": [
641
+ 195,
642
+ 280,
643
+ 280,
644
+ ],
645
+ "version": "0.0.2",
646
+ },
647
+ ]
648
+ `);
599
649
  })
600
650
  })
601
651
 
@@ -930,6 +980,20 @@ describe("deleteBlockWithPath", () => {
930
980
  });
931
981
  expect(result).not.toContain("- type: type1");
932
982
  })
983
+
984
+ test("deleting a section when empty", () => {
985
+ const yamlString = `
986
+ tasks:
987
+ - type: type1
988
+ name: Plugin 1
989
+ `;
990
+ const result = YamlUtils.deleteBlockWithPath({
991
+ source: yamlString,
992
+ path:"tasks[0]",
993
+ });
994
+ expect(result).not.toContain("tasks:");
995
+ })
996
+
933
997
  })
934
998
 
935
999
  describe("extractBlockWithPath", () => {
@@ -989,3 +1053,156 @@ describe("extractBlockWithPath", () => {
989
1053
  `)
990
1054
  })
991
1055
  })
1056
+
1057
+ describe("replaceBlockWithPath", () => {
1058
+ test("replacing a trigger", () => {
1059
+ const yamlString = `
1060
+ triggers:
1061
+ - id: plugin1
1062
+ type: type1
1063
+ name: Plugin 1
1064
+ - id: plugin2
1065
+ type: type2
1066
+ name: Plugin 2
1067
+ `;
1068
+
1069
+ const newValue = `
1070
+ id: plugin3
1071
+ type: type3
1072
+ name: Plugin 3
1073
+ `;
1074
+
1075
+ const result = YamlUtils.replaceBlockWithPath({
1076
+ source: yamlString,
1077
+ path: "triggers[1]",
1078
+ newContent: newValue
1079
+ })
1080
+ expect(result).toMatchInlineSnapshot(`
1081
+ "triggers:
1082
+ - id: plugin1
1083
+ type: type1
1084
+ name: Plugin 1
1085
+ - id: plugin3
1086
+ type: type3
1087
+ name: Plugin 3
1088
+ "
1089
+ `);
1090
+ })
1091
+ test("replacing a task", () => {
1092
+ const yamlString = `
1093
+ tasks:
1094
+ - id: plugin1
1095
+ type: type1
1096
+ name: Plugin 1
1097
+ - id: plugin2
1098
+ type: type2
1099
+ name: Plugin 2
1100
+ `;
1101
+
1102
+ const newValue = `
1103
+ id: plugin3
1104
+ type: type3
1105
+ name: Plugin 3
1106
+ `;
1107
+
1108
+ const result = YamlUtils.replaceBlockWithPath({
1109
+ source: yamlString,
1110
+ path: "tasks[1]",
1111
+ newContent: newValue
1112
+ })
1113
+ expect(result).toMatchInlineSnapshot(`
1114
+ "tasks:
1115
+ - id: plugin1
1116
+ type: type1
1117
+ name: Plugin 1
1118
+ - id: plugin3
1119
+ type: type3
1120
+ name: Plugin 3
1121
+ "
1122
+ `)
1123
+ })
1124
+
1125
+ test("replacing a task with subtask", () => {
1126
+ const yamlString = `
1127
+ tasks:
1128
+ - id: plugin1
1129
+ type: type1
1130
+ name: Plugin 1
1131
+ tasks:
1132
+ - id: plugin2
1133
+ type: type2
1134
+ name: Plugin 2
1135
+ - id: plugin3
1136
+ type: type3
1137
+ name: Plugin 3
1138
+ `;
1139
+
1140
+ const newValue = `
1141
+ id: plugin4
1142
+ type: type4
1143
+ name: Plugin 4
1144
+ `;
1145
+
1146
+ const result = YamlUtils.replaceBlockWithPath({
1147
+ source: yamlString,
1148
+ path: "tasks[0].tasks[1]",
1149
+ newContent: newValue
1150
+ })
1151
+ expect(result).toMatchInlineSnapshot(`
1152
+ "tasks:
1153
+ - id: plugin1
1154
+ type: type1
1155
+ name: Plugin 1
1156
+ tasks:
1157
+ - id: plugin2
1158
+ type: type2
1159
+ name: Plugin 2
1160
+ - id: plugin4
1161
+ type: type4
1162
+ name: Plugin 4
1163
+ "
1164
+ `)
1165
+ })
1166
+
1167
+ test("replace a condition in a trigger", () => {
1168
+ const yamlString = `
1169
+ triggers:
1170
+ - id: plugin1
1171
+ type: type1
1172
+ name: Plugin 1
1173
+ conditions:
1174
+ - id: plugin2
1175
+ type: type2
1176
+ name: Plugin 2
1177
+ - id: plugin3
1178
+ type: type3
1179
+ name: Plugin 3
1180
+ `;
1181
+
1182
+ const newValue = `
1183
+ id: plugin4
1184
+ type: type4
1185
+ name: Plugin 4
1186
+ `;
1187
+
1188
+ const result = YamlUtils.replaceBlockWithPath({
1189
+ source: yamlString,
1190
+ path: "triggers[0].conditions[1]",
1191
+ newContent: newValue
1192
+ })
1193
+ expect(result).toMatchInlineSnapshot(`
1194
+ "triggers:
1195
+ - id: plugin1
1196
+ type: type1
1197
+ name: Plugin 1
1198
+ conditions:
1199
+ - id: plugin2
1200
+ type: type2
1201
+ name: Plugin 2
1202
+ - id: plugin4
1203
+ type: type4
1204
+ name: Plugin 4
1205
+ "
1206
+ `)
1207
+ })
1208
+ })
@@ -103,17 +103,21 @@ function getSectionNodeAndDocumentFromSource({source, section}: {
103
103
  source: string,
104
104
  section: string
105
105
  }) {
106
- const yamlDoc = parseDocument(source) as Document<YAMLMap<{ value: string }, Node>>;
106
+ const yamlDoc = parseDocumentTyped(source);
107
107
  const sectionNode = getSectionFromDocument({yamlDoc, section});
108
108
  return {yamlDoc, sectionNode};
109
109
  }
110
110
 
111
+ function parseDocumentTyped(source: string) {
112
+ return parseDocument(source) as Document<YAMLMap<{ value: string }, Node>>;
113
+ }
114
+
111
115
  function getSectionFromDocument({yamlDoc, section}:
112
116
  {
113
117
  yamlDoc: Document<YAMLMap<{ value: string }, Node>>,
114
118
  section: string
115
119
  }) {
116
- const sectionNode = yamlDoc.contents?.items.find(
120
+ const sectionNode = yamlDoc.contents?.items?.find(
117
121
  (e) => e.key.value === section
118
122
  ) as { value: YAMLSeq<YAMLMap<{ value: string }, Node>> } | undefined;
119
123
  return sectionNode?.value;
@@ -204,7 +208,7 @@ export function extractBlockWithPath({source, path}: {
204
208
  path: string
205
209
  }) {
206
210
  const doc = extractBlockWithPathFromDocument({
207
- yamlDoc: parseDocument(source) as Document<YAMLMap<{ value: string }, Node>>,
211
+ yamlDoc: parseDocumentTyped(source),
208
212
  path
209
213
  });
210
214
  if (!doc) {
@@ -231,6 +235,19 @@ function extractBlockWithPathFromDocument({yamlDoc, path, callback}: {
231
235
  return new Document(element);
232
236
  }
233
237
 
238
+ export function replaceBlockWithPath({source, path, newContent}: {
239
+ source: string,
240
+ path: string,
241
+ newContent: string
242
+ }) {
243
+ const yamlDoc = parseDocumentTyped(source);
244
+ const newItem = yamlDoc.createNode(parseDocument(newContent));
245
+
246
+ yamlDoc.setIn(parsePath(path), newItem);
247
+
248
+ return yamlDoc.toString(TOSTRING_OPTIONS);
249
+ }
250
+
234
251
  export function replaceBlockInDocument({source, section, keyName, key, newContent}: {
235
252
  source: string,
236
253
  section: string,
@@ -462,7 +479,7 @@ export function insertBlockWithPath({
462
479
  if (!position) {
463
480
  position = "after";
464
481
  }
465
- const yamlDoc = parseDocument(source) as Document<YAMLMap<{ value: string }, Node>>;
482
+ const yamlDoc = parseDocumentTyped(source);
466
483
  const newPropNode = yamlDoc.createNode(parseDocument(newBlock)) as any;
467
484
 
468
485
  const parsedPath = parsePath(parentPath);
@@ -506,7 +523,7 @@ export function deleteBlock({source, section, key, keyName}: {
506
523
  if (!keyName) {
507
524
  keyName = "id";
508
525
  }
509
- const yamlDoc = parseDocument(source) as any;
526
+ const yamlDoc = parseDocumentTyped(source);
510
527
  visit(yamlDoc, {
511
528
  Pair(_, pair: any) {
512
529
  if (pair.key.value === section) {
@@ -537,14 +554,19 @@ export function deleteBlockWithPath({source, path}: {
537
554
  source: string,
538
555
  path: string,
539
556
  }) {
540
- const yamlDoc = parseDocument(source) as Document<YAMLMap<{ value: string }, Node>>;
557
+ const yamlDoc = parseDocumentTyped(source);
541
558
  const parsedPath = parsePath(path)
542
- const parentNode = yamlDoc.getIn(parsedPath.slice(0, -1)) as YAMLMap<{ value: string }, Node>;
559
+ const parsedParentPath = parsedPath.slice(0, -1);
560
+ const parentNode = yamlDoc.getIn(parsedParentPath) as YAMLMap<{ value: string }, Node>;
543
561
  if (!parentNode) {
544
562
  return source;
545
563
  }
546
564
  const index = getNodeIndexInParent(yamlDoc, parentNode, parsedPath.slice(0, -1), parsedPath[parsedPath.length - 1]);
547
- parentNode.items.splice(index, 1);
565
+ if (parentNode.items.length === 1) {
566
+ yamlDoc.deleteIn(parsedParentPath);
567
+ } else {
568
+ parentNode.items.splice(index, 1);
569
+ }
548
570
  return yamlDoc.toString(TOSTRING_OPTIONS);
549
571
  }
550
572
 
@@ -728,7 +750,7 @@ function cleanMetadataDocument(yamlDoc: Document<YAMLMap<{ value: string }, Node
728
750
  }
729
751
 
730
752
  export function cleanMetadata(source: string) {
731
- const yamlDoc = parseDocument(source) as Document<YAMLMap<{ value: string }, Node>>;
753
+ const yamlDoc = parseDocumentTyped(source);
732
754
  const cleanedYamlDoc = cleanMetadataDocument(yamlDoc);
733
755
  return cleanedYamlDoc.toString(TOSTRING_OPTIONS);
734
756
  }
@@ -821,7 +843,8 @@ export function extractFieldFromMaps<T extends string>(
821
843
  source: string,
822
844
  fieldName: T,
823
845
  parentPathPredicate = (_: any, __?: any) => true,
824
- valuePredicate = (_: any) => true
846
+ valuePredicate = (_: any) => true,
847
+ keepEmptyFields: boolean = false,
825
848
  ): (Record<T, any> & {range: Range})[] {
826
849
  const yamlDoc = parseDocument(source) as any;
827
850
  const maps: any[] = [];
@@ -836,6 +859,7 @@ export function extractFieldFromMaps<T extends string>(
836
859
  ) &&
837
860
  map.items
838
861
  ) {
862
+ let matched = false;
839
863
  for (const item of map.items as any[]) {
840
864
  if (item?.key?.value === fieldName) {
841
865
  const fieldValue = item?.value?.value ?? item.value?.items;
@@ -844,9 +868,17 @@ export function extractFieldFromMaps<T extends string>(
844
868
  [fieldName]: fieldValue,
845
869
  range: map.range,
846
870
  });
871
+ matched = true;
847
872
  }
848
873
  }
849
874
  }
875
+ if (!matched && keepEmptyFields) {
876
+ // add an empty entry if the field cannot be matched (i.e., optional property).
877
+ maps.push({
878
+ [fieldName]: undefined,
879
+ range: map.range,
880
+ });
881
+ }
850
882
  }
851
883
  },
852
884
  });
@@ -884,6 +916,32 @@ export function getTypeAtPosition(
884
916
  return null;
885
917
  }
886
918
 
919
+ /**
920
+ * Get task version at cursor position.
921
+ * Useful to display/update the live docs
922
+ */
923
+ export function getVersionAtPosition(
924
+ source: string,
925
+ position: { lineNumber: number; column: number }
926
+ ) {
927
+ const versions = extractAllVersions(source);
928
+ const lineCounter = new LineCounter();
929
+ parseDocument(source, {lineCounter});
930
+ const cursorIndex =
931
+ lineCounter.lineStarts[position.lineNumber - 1] + position.column;
932
+
933
+ for (const version of versions.reverse()) {
934
+ if (cursorIndex >= version.range[0]) {
935
+ return version.version;
936
+ }
937
+ }
938
+ return null;
939
+ }
940
+
941
+ function extractAllVersions(source: string){
942
+ return extractFieldFromMaps(source, "version", () => true, () => true, true);
943
+ }
944
+
887
945
  const TOSTRING_OPTIONS = {lineWidth: 0};
888
946
 
889
947
  const yamlKeyCapture = "([^:\\n]+): *";
@@ -10,7 +10,7 @@ import {
10
10
  deleteBlock,
11
11
  extractPluginDefault,
12
12
  extractBlock,
13
- flowHaveTasks, getAllCharts, getChartAtPosition, getLastBlock, getMetadata,
13
+ flowHaveTasks, getAllCharts, getChartAtPosition, getLastBlock, getMetadata, getVersionAtPosition,
14
14
  getTypeAtPosition as getTaskType,
15
15
  insertErrorInFlowable,
16
16
  insertBlock,
@@ -236,4 +236,7 @@ export const YamlUtils = {
236
236
  deletePluginDefaults,
237
237
 
238
238
  extractFieldFromMaps,
239
+
240
+ getVersionAtPosition
241
+
239
242
  };