@openfn/project 0.7.2 → 0.8.1

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
@@ -258,7 +258,7 @@ function to_json_default(project) {
258
258
  }
259
259
 
260
260
  // src/serialize/to-app-state.ts
261
- import { pick, omitBy, isNil } from "lodash-es";
261
+ import { pick, omitBy, isNil, sortBy } from "lodash-es";
262
262
  import { randomUUID } from "node:crypto";
263
263
 
264
264
  // src/util/rename-keys.ts
@@ -327,7 +327,7 @@ var mapWorkflow = (workflow) => {
327
327
  obj[next.id] = next.openfn.uuid;
328
328
  return obj;
329
329
  }, {});
330
- workflow.steps.forEach((s) => {
330
+ sortBy(workflow.steps, "name").forEach((s) => {
331
331
  let isTrigger = false;
332
332
  let node;
333
333
  if (s.type && !s.expression) {
@@ -374,6 +374,7 @@ var mapWorkflow = (workflow) => {
374
374
  wfState.edges.push(e);
375
375
  });
376
376
  });
377
+ wfState.edges = sortBy(wfState.edges, "id");
377
378
  return wfState;
378
379
  };
379
380
 
@@ -544,7 +545,7 @@ var handleOutput = (data, filePath, format) => {
544
545
  };
545
546
 
546
547
  // src/parse/from-app-state.ts
547
- var from_app_state_default = (state, meta, config = {}) => {
548
+ var from_app_state_default = (state, meta = {}, config = {}) => {
548
549
  let stateJson;
549
550
  if (typeof state === "string") {
550
551
  if (config.format === "yaml") {
@@ -1397,7 +1398,7 @@ import { randomUUID as randomUUID2 } from "node:crypto";
1397
1398
  import path4 from "node:path";
1398
1399
  import { readFileSync as readFileSync2 } from "node:fs";
1399
1400
  import { grammar } from "ohm-js";
1400
- import { isNil as isNil3 } from "lodash-es";
1401
+ import { isNil as isNil3, set } from "lodash-es";
1401
1402
  var parser;
1402
1403
  var initOperations = (options = {}) => {
1403
1404
  let nodes = {};
@@ -1427,7 +1428,7 @@ var initOperations = (options = {}) => {
1427
1428
  const steps = Object.values(nodes);
1428
1429
  const attributes = attrs.children.map((c) => c.buildWorkflow()).reduce((obj, next) => {
1429
1430
  const [key, value] = next;
1430
- obj[key] = value;
1431
+ set(obj, key, value);
1431
1432
  return obj;
1432
1433
  }, {});
1433
1434
  return { ...attributes, steps };
@@ -1436,7 +1437,19 @@ var initOperations = (options = {}) => {
1436
1437
  return null;
1437
1438
  },
1438
1439
  attribute(_, name, _space, value) {
1439
- return [name.sourceString, value.sourceString];
1440
+ return [
1441
+ name.sourceString,
1442
+ value.isTerminal() ? value.sourceString : value.buildWorkflow()
1443
+ ];
1444
+ },
1445
+ attr_value(n) {
1446
+ return n.isTerminal() ? n.sourceString : n.buildWorkflow();
1447
+ },
1448
+ bool(value) {
1449
+ return value.sourceString === "true";
1450
+ },
1451
+ int(value) {
1452
+ return parseInt(value.sourceString);
1440
1453
  },
1441
1454
  Pair(parent, edge, child) {
1442
1455
  const n1 = parent.buildWorkflow();
@@ -1475,18 +1488,27 @@ var initOperations = (options = {}) => {
1475
1488
  },
1476
1489
  // Bit flaky - we need this to handle quoted props
1477
1490
  _iter(...items) {
1478
- return items.map((i) => i.buildWorkflow()).join("");
1491
+ return items.map((i) => i.isTerminal() ? i.sourceString : i.buildWorkflow()).join("");
1479
1492
  },
1480
1493
  alnum(a) {
1481
1494
  return a.sourceString;
1482
1495
  },
1483
- quotedProp(_left, value, _right) {
1496
+ quoted_prop(_left, value, _right) {
1484
1497
  return value.sourceString;
1485
1498
  },
1486
1499
  edge(_) {
1487
1500
  return {
1488
1501
  openfn: {}
1489
1502
  };
1503
+ },
1504
+ edge_with_props(_, props, __) {
1505
+ const edge = {
1506
+ openfn: {}
1507
+ };
1508
+ props.buildWorkflow().forEach(([key, value]) => {
1509
+ edge[key] = value;
1510
+ });
1511
+ return edge;
1490
1512
  }
1491
1513
  };
1492
1514
  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
 
@@ -25,13 +27,21 @@ Workflow {
25
27
 
26
28
  props = "(" listOf<prop, ","> ")"
27
29
 
28
- prop = alnum+ "=" propValue
30
+ prop = (alnum | "-" | "_")+ "=" propValue
31
+
32
+ propValue = quoted_prop | bool | int | alnum+
29
33
 
30
- propValue = alnum+ | quotedProp
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.1",
4
4
  "description": "Read, serialize, replicate and sync OpenFn projects",
5
5
  "type": "module",
6
6
  "exports": {
@@ -34,8 +34,8 @@
34
34
  "lodash-es": "^4.17.21",
35
35
  "ohm-js": "^17.2.1",
36
36
  "yaml": "^2.2.2",
37
- "@openfn/logger": "1.0.6",
38
- "@openfn/lexicon": "^1.2.6"
37
+ "@openfn/lexicon": "^1.2.6",
38
+ "@openfn/logger": "1.0.6"
39
39
  },
40
40
  "files": [
41
41
  "dist",