webpipe-js 0.1.3 → 0.1.4

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.cjs CHANGED
@@ -579,26 +579,6 @@ var ParseFailure = class extends Error {
579
579
  };
580
580
  function prettyPrint(program) {
581
581
  const lines = [];
582
- program.configs.forEach((config) => {
583
- lines.push(`config ${config.name} {`);
584
- config.properties.forEach((prop) => {
585
- const value = formatConfigValue(prop.value);
586
- lines.push(` ${prop.key}: ${value}`);
587
- });
588
- lines.push("}");
589
- lines.push("");
590
- });
591
- program.variables.forEach((variable) => {
592
- lines.push(`${variable.varType} ${variable.name} = \`${variable.value}\``);
593
- });
594
- if (program.variables.length > 0) lines.push("");
595
- program.pipelines.forEach((pipeline) => {
596
- lines.push(`pipeline ${pipeline.name} =`);
597
- pipeline.pipeline.steps.forEach((step) => {
598
- lines.push(formatPipelineStep(step));
599
- });
600
- lines.push("");
601
- });
602
582
  program.routes.forEach((route) => {
603
583
  lines.push(`${route.method} ${route.path}`);
604
584
  const pipelineLines = formatPipelineRef(route.pipeline);
@@ -623,11 +603,35 @@ function prettyPrint(program) {
623
603
  test.conditions.forEach((condition) => {
624
604
  const condType = condition.conditionType.toLowerCase();
625
605
  const jqPart = condition.jqExpr ? ` \`${condition.jqExpr}\`` : "";
626
- lines.push(` ${condType} ${condition.field}${jqPart} ${condition.comparison} ${condition.value}`);
606
+ const value = condition.value.startsWith("`") ? condition.value : condition.value.includes("\n") || condition.value.includes("{") || condition.value.includes("[") ? `\`${condition.value}\`` : condition.value;
607
+ lines.push(` ${condType} ${condition.field}${jqPart} ${condition.comparison} ${value}`);
627
608
  });
628
609
  lines.push("");
629
610
  });
630
611
  });
612
+ if (program.configs.length > 0) {
613
+ lines.push("## Config");
614
+ program.configs.forEach((config) => {
615
+ lines.push(`config ${config.name} {`);
616
+ config.properties.forEach((prop) => {
617
+ const value = formatConfigValue(prop.value);
618
+ lines.push(` ${prop.key}: ${value}`);
619
+ });
620
+ lines.push("}");
621
+ lines.push("");
622
+ });
623
+ }
624
+ program.pipelines.forEach((pipeline) => {
625
+ lines.push(`pipeline ${pipeline.name} =`);
626
+ pipeline.pipeline.steps.forEach((step) => {
627
+ lines.push(formatPipelineStep(step));
628
+ });
629
+ lines.push("");
630
+ });
631
+ program.variables.forEach((variable) => {
632
+ lines.push(`${variable.varType} ${variable.name} = \`${variable.value}\``);
633
+ });
634
+ if (program.variables.length > 0) lines.push("");
631
635
  return lines.join("\n").trim();
632
636
  }
633
637
  function formatConfigValue(value) {
@@ -658,9 +662,9 @@ function formatPipelineStep(step, indent = " ") {
658
662
  }
659
663
  }
660
664
  function formatStepConfig(config) {
661
- if (config.includes("`")) {
665
+ if (config.includes("\n") || config.includes("{") || config.includes("[") || config.includes(".") || config.includes("(")) {
662
666
  return `\`${config}\``;
663
- } else if (config.includes(" ") || config.includes("\n")) {
667
+ } else if (config.includes(" ")) {
664
668
  return `"${config}"`;
665
669
  } else {
666
670
  return config;
package/dist/index.mjs CHANGED
@@ -549,26 +549,6 @@ var ParseFailure = class extends Error {
549
549
  };
550
550
  function prettyPrint(program) {
551
551
  const lines = [];
552
- program.configs.forEach((config) => {
553
- lines.push(`config ${config.name} {`);
554
- config.properties.forEach((prop) => {
555
- const value = formatConfigValue(prop.value);
556
- lines.push(` ${prop.key}: ${value}`);
557
- });
558
- lines.push("}");
559
- lines.push("");
560
- });
561
- program.variables.forEach((variable) => {
562
- lines.push(`${variable.varType} ${variable.name} = \`${variable.value}\``);
563
- });
564
- if (program.variables.length > 0) lines.push("");
565
- program.pipelines.forEach((pipeline) => {
566
- lines.push(`pipeline ${pipeline.name} =`);
567
- pipeline.pipeline.steps.forEach((step) => {
568
- lines.push(formatPipelineStep(step));
569
- });
570
- lines.push("");
571
- });
572
552
  program.routes.forEach((route) => {
573
553
  lines.push(`${route.method} ${route.path}`);
574
554
  const pipelineLines = formatPipelineRef(route.pipeline);
@@ -593,11 +573,35 @@ function prettyPrint(program) {
593
573
  test.conditions.forEach((condition) => {
594
574
  const condType = condition.conditionType.toLowerCase();
595
575
  const jqPart = condition.jqExpr ? ` \`${condition.jqExpr}\`` : "";
596
- lines.push(` ${condType} ${condition.field}${jqPart} ${condition.comparison} ${condition.value}`);
576
+ const value = condition.value.startsWith("`") ? condition.value : condition.value.includes("\n") || condition.value.includes("{") || condition.value.includes("[") ? `\`${condition.value}\`` : condition.value;
577
+ lines.push(` ${condType} ${condition.field}${jqPart} ${condition.comparison} ${value}`);
597
578
  });
598
579
  lines.push("");
599
580
  });
600
581
  });
582
+ if (program.configs.length > 0) {
583
+ lines.push("## Config");
584
+ program.configs.forEach((config) => {
585
+ lines.push(`config ${config.name} {`);
586
+ config.properties.forEach((prop) => {
587
+ const value = formatConfigValue(prop.value);
588
+ lines.push(` ${prop.key}: ${value}`);
589
+ });
590
+ lines.push("}");
591
+ lines.push("");
592
+ });
593
+ }
594
+ program.pipelines.forEach((pipeline) => {
595
+ lines.push(`pipeline ${pipeline.name} =`);
596
+ pipeline.pipeline.steps.forEach((step) => {
597
+ lines.push(formatPipelineStep(step));
598
+ });
599
+ lines.push("");
600
+ });
601
+ program.variables.forEach((variable) => {
602
+ lines.push(`${variable.varType} ${variable.name} = \`${variable.value}\``);
603
+ });
604
+ if (program.variables.length > 0) lines.push("");
601
605
  return lines.join("\n").trim();
602
606
  }
603
607
  function formatConfigValue(value) {
@@ -628,9 +632,9 @@ function formatPipelineStep(step, indent = " ") {
628
632
  }
629
633
  }
630
634
  function formatStepConfig(config) {
631
- if (config.includes("`")) {
635
+ if (config.includes("\n") || config.includes("{") || config.includes("[") || config.includes(".") || config.includes("(")) {
632
636
  return `\`${config}\``;
633
- } else if (config.includes(" ") || config.includes("\n")) {
637
+ } else if (config.includes(" ")) {
634
638
  return `"${config}"`;
635
639
  } else {
636
640
  return config;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "webpipe-js",
3
- "version": "0.1.3",
3
+ "version": "0.1.4",
4
4
  "description": "Web Pipe parser",
5
5
  "license": "ISC",
6
6
  "author": "William Cotton",