@openfn/project 0.7.2 → 0.8.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.js CHANGED
@@ -1397,7 +1397,7 @@ import { randomUUID as randomUUID2 } from "node:crypto";
1397
1397
  import path4 from "node:path";
1398
1398
  import { readFileSync as readFileSync2 } from "node:fs";
1399
1399
  import { grammar } from "ohm-js";
1400
- import { isNil as isNil3 } from "lodash-es";
1400
+ import { isNil as isNil3, set } from "lodash-es";
1401
1401
  var parser;
1402
1402
  var initOperations = (options = {}) => {
1403
1403
  let nodes = {};
@@ -1427,7 +1427,7 @@ var initOperations = (options = {}) => {
1427
1427
  const steps = Object.values(nodes);
1428
1428
  const attributes = attrs.children.map((c) => c.buildWorkflow()).reduce((obj, next) => {
1429
1429
  const [key, value] = next;
1430
- obj[key] = value;
1430
+ set(obj, key, value);
1431
1431
  return obj;
1432
1432
  }, {});
1433
1433
  return { ...attributes, steps };
@@ -1436,7 +1436,19 @@ var initOperations = (options = {}) => {
1436
1436
  return null;
1437
1437
  },
1438
1438
  attribute(_, name, _space, value) {
1439
- return [name.sourceString, value.sourceString];
1439
+ return [
1440
+ name.sourceString,
1441
+ value.isTerminal() ? value.sourceString : value.buildWorkflow()
1442
+ ];
1443
+ },
1444
+ attr_value(n) {
1445
+ return n.isTerminal() ? n.sourceString : n.buildWorkflow();
1446
+ },
1447
+ bool(value) {
1448
+ return value.sourceString === "true";
1449
+ },
1450
+ int(value) {
1451
+ return parseInt(value.sourceString);
1440
1452
  },
1441
1453
  Pair(parent, edge, child) {
1442
1454
  const n1 = parent.buildWorkflow();
@@ -1475,18 +1487,27 @@ var initOperations = (options = {}) => {
1475
1487
  },
1476
1488
  // Bit flaky - we need this to handle quoted props
1477
1489
  _iter(...items) {
1478
- return items.map((i) => i.buildWorkflow()).join("");
1490
+ return items.map((i) => i.isTerminal() ? i.sourceString : i.buildWorkflow()).join("");
1479
1491
  },
1480
1492
  alnum(a) {
1481
1493
  return a.sourceString;
1482
1494
  },
1483
- quotedProp(_left, value, _right) {
1495
+ quoted_prop(_left, value, _right) {
1484
1496
  return value.sourceString;
1485
1497
  },
1486
1498
  edge(_) {
1487
1499
  return {
1488
1500
  openfn: {}
1489
1501
  };
1502
+ },
1503
+ edge_with_props(_, props, __) {
1504
+ const edge = {
1505
+ openfn: {}
1506
+ };
1507
+ props.buildWorkflow().forEach(([key, value]) => {
1508
+ edge[key] = value;
1509
+ });
1510
+ return edge;
1490
1511
  }
1491
1512
  };
1492
1513
  return operations;
package/dist/workflow.ohm CHANGED
@@ -5,11 +5,13 @@
5
5
  Workflow {
6
6
  Workflow = attribute* Pair*
7
7
 
8
- attribute = "@" attr_name space attr_name
8
+ attribute = "@" chained_attr_name space (attr_value | quoted_prop)
9
9
 
10
- attr_name = (alnum | "_" | "-")+
10
+ attr_value = int | bool | (alnum | "_" | "-" | ":")+
11
11
 
12
- Pair = node edge node
12
+ chained_attr_name = (alnum | "_" | "-" | ".")+
13
+
14
+ Pair = node (edge_with_props | edge) node
13
15
 
14
16
  comment = "#" (~lineTerminator any)*
15
17
 
@@ -27,11 +29,19 @@ Workflow {
27
29
 
28
30
  prop = alnum+ "=" propValue
29
31
 
30
- propValue = alnum+ | quotedProp
32
+ propValue = quoted_prop | bool | int | alnum+
33
+
34
+ // TODO we only parse numbers as positive ints right now
35
+ // fine for tests
36
+ int = digit+
37
+
38
+ bool = "false" | "true"
31
39
 
32
- quotedProp = "\"" (~"\"" any)* "\""
40
+ quoted_prop = "\"" (~"\"" any)* "\""
33
41
 
34
42
  edge = "-"
43
+
44
+ edge_with_props = "-" props "-"
35
45
 
36
46
  lineTerminator = "\n" | "\r"
37
47
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openfn/project",
3
- "version": "0.7.2",
3
+ "version": "0.8.0",
4
4
  "description": "Read, serialize, replicate and sync OpenFn projects",
5
5
  "type": "module",
6
6
  "exports": {