ondc-code-generator 1.0.0 → 1.0.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.
Files changed (32) hide show
  1. package/alpha/docs/rag-docs/confirm.md +301 -0
  2. package/alpha/docs/rag-docs/init.md +422 -0
  3. package/alpha/docs/rag-docs/on_confirm.md +921 -0
  4. package/alpha/docs/rag-docs/on_init.md +823 -0
  5. package/alpha/docs/rag-docs/on_search.md +897 -0
  6. package/alpha/docs/rag-docs/on_select.md +522 -0
  7. package/alpha/docs/rag-docs/on_status.md +854 -0
  8. package/alpha/docs/rag-docs/on_update.md +921 -0
  9. package/alpha/docs/rag-docs/search.md +678 -0
  10. package/alpha/docs/rag-docs/select.md +344 -0
  11. package/alpha/docs/rag-docs/status.md +178 -0
  12. package/alpha/docs/rag-docs/update.md +229 -0
  13. package/alpha/docs/rag-table-docs/confirm.md +63 -0
  14. package/alpha/docs/rag-table-docs/init.md +81 -0
  15. package/alpha/docs/rag-table-docs/on_confirm.md +164 -0
  16. package/alpha/docs/rag-table-docs/on_init.md +146 -0
  17. package/alpha/docs/rag-table-docs/on_search.md +163 -0
  18. package/alpha/docs/rag-table-docs/on_select.md +99 -0
  19. package/alpha/docs/rag-table-docs/on_status.md +153 -0
  20. package/alpha/docs/rag-table-docs/on_update.md +164 -0
  21. package/alpha/docs/rag-table-docs/raw_table.json +11198 -0
  22. package/alpha/docs/rag-table-docs/search.md +128 -0
  23. package/alpha/docs/rag-table-docs/select.md +70 -0
  24. package/alpha/docs/rag-table-docs/status.md +44 -0
  25. package/alpha/docs/rag-table-docs/update.md +51 -0
  26. package/alpha/docs/validPaths.json +34134 -0
  27. package/dist/generator/generators/documentation/markdown-message-generator.js +4 -1
  28. package/dist/generator/generators/rag/rag-generator.d.ts +39 -28
  29. package/dist/generator/generators/rag/rag-generator.js +149 -103
  30. package/dist/generator/generators/rag/rag-table-generator.d.ts +6 -0
  31. package/dist/generator/generators/rag/rag-table-generator.js +16 -6
  32. package/package.json +1 -1
@@ -13,7 +13,10 @@ export function markdownMessageGenerator(returnInput, variableValues, startingPo
13
13
  const ast = buildAstFromInput(returnInput);
14
14
  const returnTemplate = variableValues[TestObjectSyntax.Description]
15
15
  ? variableValues[TestObjectSyntax.Description]
16
- : CompileToMarkdown(ast, /*topLevel*/ true, /*depth*/ 0, /*forNot*/ false);
16
+ : CompileToMarkdown(ast,
17
+ /*topLevel*/ true,
18
+ /*depth*/ 0,
19
+ /*forNot*/ false);
17
20
  let finalReturn = `#### **${startingPointer}**\n\n` +
18
21
  Mustache.render(returnTemplate, ConvertArrayToStringsInTestObject(variableValues));
19
22
  if (skipInput && skipInput.length > 0) {
@@ -1,18 +1,23 @@
1
1
  import { CodeGenerator, CodeGeneratorProps } from "../classes/abstract-generator.js";
2
2
  /**
3
- * RagGenerator — produces one Markdown file per API action under ./rag-docs/.
3
+ * RagGenerator — produces one richly structured Markdown file per API action
4
+ * under `./rag-docs/`, designed for direct RAG pipeline ingestion.
4
5
  *
5
- * Each file is a self-contained, richly structured document intended to be
6
- * fed directly into a Retrieval-Augmented Generation (RAG) pipeline.
7
- *
8
- * Layout per file:
6
+ * Format:
7
+ * ---
8
+ * YAML frontmatter (action, codeName, numTests, generated, domain, version)
9
9
  * ---
10
- * YAML frontmatter (action, codeName, numTests, generated date)
10
+ * # Heading + context paragraph
11
+ *
12
+ * ## TOP_LEVEL_GROUP
13
+ * Prose intro listing child names, scope, skip condition.
11
14
  * ---
12
- * # <codeName> — <action> Validations
13
- * Short context paragraph
14
- * Numbered list of every test with its human-readable description,
15
- * error code, scope, and (indented) skip condition when present.
15
+ * ### CHILD_GROUP
16
+ * **LEAF_NAME**
17
+ * `group: PATH | type: leaf | error_code: X`
18
+ *
19
+ * - bullet description lines
20
+ * - Skipped if ...
16
21
  */
17
22
  export declare class RagGenerator extends CodeGenerator {
18
23
  generateSessionDataCode(): Promise<void>;
@@ -20,29 +25,35 @@ export declare class RagGenerator extends CodeGenerator {
20
25
  generateValidationCode: () => Promise<void>;
21
26
  generateCode: (codeConfig: CodeGeneratorProps) => Promise<void>;
22
27
  private buildActionMarkdown;
23
- /** Count only leaf (non-group) tests recursively. */
28
+ /** Counts leaf (non-group) tests recursively. */
24
29
  private countLeafTests;
30
+ /** Formats a list of names as English prose: "A, B, and C". */
31
+ private englishList;
25
32
  /**
26
- * Renders a numbered top-level section (##) for a test object.
27
- *
28
- * - Leaf test full human-readable description + metadata badges
29
- * - Group node → brief intro line + all children rendered as ### sub-sections
30
- * (recursing further for deeply nested groups)
31
- *
32
- * This preserves the parent→child relationship in the output so RAG
33
- * consumers can see exactly which sub-validations belong to which group.
33
+ * Top-level `##` section.
34
+ * - Leaf → `## NAME` + metadata line + body
35
+ * - Group`## NAME` + prose intro + `---` + children
36
+ */
37
+ private buildTopLevelSection;
38
+ /**
39
+ * Renders a group section recursively.
40
+ * @param headingLevel Markdown heading for this group node (e.g. "##")
41
+ * @param childLevel Markdown heading for its direct children (e.g. "###")
42
+ * @param ancestorPath Names of ancestor groups, used to build breadcrumbs
34
43
  */
35
- private buildTestSection;
44
+ private renderGroupSection;
36
45
  /**
37
- * Renders a child/nested section at the given heading level.
38
- * Recurses deeper (####, #####, …) for nested groups.
46
+ * Renders a leaf node's full content block:
47
+ * **NAME**
48
+ * `group: PATH | type: leaf | error_code: X`
49
+ *
50
+ * - bullet description lines
51
+ * - Skipped if ... (inline, from markdownMessageGenerator)
39
52
  */
40
- private renderChildSection;
53
+ private renderLeafBody;
41
54
  /**
42
- * Renders the skip block for a group node as a blockquote.
43
- * Returns an empty string when there is no _CONTINUE_ on this node.
55
+ * Renders a group's skip condition as a blockquote paragraph.
56
+ * Uses markdownMessageGenerator to compile the JVAL expression.
44
57
  */
45
- private renderSkipBlock;
46
- /** Renders a leaf test's heading, metadata badges, and compiled description. */
47
- private renderLeaf;
58
+ private renderSkipInlineBullet;
48
59
  }
@@ -2,184 +2,230 @@ import { ConfigSyntax, TestObjectSyntax } from "../../../constants/syntax.js";
2
2
  import { CodeGenerator, } from "../classes/abstract-generator.js";
3
3
  import { writeFileWithFsExtra } from "../../../utils/fs-utils.js";
4
4
  import { markdownMessageGenerator } from "../documentation/markdown-message-generator.js";
5
- import { buildAstFromInput } from "../../../services/return-complier/combined.js";
6
- import { CompileToMarkdownForSkip } from "../../../services/return-complier/ast-functions/compile-to-markdown.js";
7
- import { addBlockquoteToMarkdown, ConvertArrayToStringsInTestObject, } from "../../../utils/general-utils/string-utils.js";
8
- import Mustache from "mustache";
9
5
  /**
10
- * RagGenerator — produces one Markdown file per API action under ./rag-docs/.
6
+ * RagGenerator — produces one richly structured Markdown file per API action
7
+ * under `./rag-docs/`, designed for direct RAG pipeline ingestion.
11
8
  *
12
- * Each file is a self-contained, richly structured document intended to be
13
- * fed directly into a Retrieval-Augmented Generation (RAG) pipeline.
14
- *
15
- * Layout per file:
9
+ * Format:
10
+ * ---
11
+ * YAML frontmatter (action, codeName, numTests, generated, domain, version)
16
12
  * ---
17
- * YAML frontmatter (action, codeName, numTests, generated date)
13
+ * # Heading + context paragraph
14
+ *
15
+ * ## TOP_LEVEL_GROUP
16
+ * Prose intro listing child names, scope, skip condition.
18
17
  * ---
19
- * # <codeName> — <action> Validations
20
- * Short context paragraph
21
- * Numbered list of every test with its human-readable description,
22
- * error code, scope, and (indented) skip condition when present.
18
+ * ### CHILD_GROUP
19
+ * **LEAF_NAME**
20
+ * `group: PATH | type: leaf | error_code: X`
21
+ *
22
+ * - bullet description lines
23
+ * - Skipped if ...
23
24
  */
24
25
  export class RagGenerator extends CodeGenerator {
25
26
  constructor() {
26
27
  super(...arguments);
27
- this.generateValidationCode = async () => {
28
- // Driven by generateCode
29
- };
28
+ this.generateValidationCode = async () => { };
30
29
  this.generateCode = async (codeConfig) => {
31
30
  const testConfig = this.validationConfig[ConfigSyntax.Tests];
32
31
  const { codeName } = codeConfig;
33
32
  for (const action of Object.keys(testConfig)) {
34
33
  const testArray = testConfig[action];
35
- const md = this.buildActionMarkdown(action, codeName, testArray);
34
+ const md = this.buildActionMarkdown(action, codeName, testArray, codeConfig);
36
35
  writeFileWithFsExtra(this.rootPath, `./rag-docs/${action}.md`, md);
37
36
  }
38
37
  };
39
38
  }
40
39
  generateSessionDataCode() {
41
- // Session-data code not needed for RAG output
42
40
  return Promise.resolve();
43
41
  }
44
42
  generateUnitTestingCode() {
45
- // Unit-test code not needed for RAG output
46
43
  return Promise.resolve();
47
44
  }
48
45
  // -------------------------------------------------------------------------
49
46
  // Private helpers
50
47
  // -------------------------------------------------------------------------
51
- buildActionMarkdown(action, codeName, testArray) {
48
+ buildActionMarkdown(action, codeName, testArray, codeConfig) {
52
49
  const leafCount = this.countLeafTests(testArray);
50
+ const topCount = testArray.length;
53
51
  const dateStr = new Date().toISOString().split("T")[0];
54
- // YAML front-matter — picked up as metadata by most RAG loaders
55
- const frontmatter = [
52
+ const domainText = Array.isArray(codeConfig.domain)
53
+ ? codeConfig.domain.join(", ")
54
+ : (codeConfig.domain ?? "");
55
+ const fmLines = [
56
56
  "---",
57
57
  `action: ${action}`,
58
58
  `codeName: ${codeName}`,
59
59
  `numTests: ${leafCount}`,
60
60
  `generated: ${dateStr}`,
61
- "---",
62
- ].join("\n");
63
- // Human-readable header
61
+ ];
62
+ if (domainText)
63
+ fmLines.push(`domain: ${domainText}`);
64
+ if (codeConfig.version)
65
+ fmLines.push(`version: ${codeConfig.version}`);
66
+ fmLines.push("---");
67
+ const frontmatter = fmLines.join("\n");
64
68
  const header = [
65
69
  `# ${codeName} — \`${action}\` Validations`,
66
70
  "",
67
- `This document describes the **${leafCount}** validation rule(s) that are`,
68
- `applied when the \`${action}\` API call is processed in the **${codeName}** flow.`,
69
- `Each rule maps to a single test object and is evaluated sequentially against the`,
70
- `request/response payload.`,
71
+ `These are the validation rules applied when processing the \`${action}\` API call in the ${codeName} flow.`,
72
+ `There are **${leafCount}** validation rules organized into **${topCount}** top-level group(s).`,
71
73
  "",
72
74
  "---",
73
75
  "",
74
76
  ].join("\n");
75
- // One numbered ## section per top-level test object only.
76
- // Group nodes embed their children as ### sub-sections inside themselves.
77
77
  const sections = testArray
78
- .map((test, idx) => this.buildTestSection(test, idx + 1))
79
- .join("\n\n");
78
+ .map((test) => this.buildTopLevelSection(test))
79
+ .join("\n\n---\n\n");
80
80
  return `${frontmatter}\n\n${header}${sections}\n`;
81
81
  }
82
- /** Count only leaf (non-group) tests recursively. */
82
+ /** Counts leaf (non-group) tests recursively. */
83
83
  countLeafTests(tests) {
84
84
  let count = 0;
85
- for (const test of tests) {
86
- const ret = test[TestObjectSyntax.Return];
87
- if (typeof ret === "string") {
88
- count++;
89
- }
90
- else {
91
- count += this.countLeafTests(ret);
92
- }
85
+ for (const t of tests) {
86
+ const ret = t[TestObjectSyntax.Return];
87
+ count +=
88
+ typeof ret === "string"
89
+ ? 1
90
+ : this.countLeafTests(ret);
93
91
  }
94
92
  return count;
95
93
  }
94
+ /** Formats a list of names as English prose: "A, B, and C". */
95
+ englishList(names) {
96
+ if (names.length === 0)
97
+ return "";
98
+ if (names.length === 1)
99
+ return names[0];
100
+ if (names.length === 2)
101
+ return `${names[0]} and ${names[1]}`;
102
+ return (names.slice(0, -1).join(", ") + ", and " + names[names.length - 1]);
103
+ }
96
104
  /**
97
- * Renders a numbered top-level section (##) for a test object.
98
- *
99
- * - Leaf test full human-readable description + metadata badges
100
- * - Group node → brief intro line + all children rendered as ### sub-sections
101
- * (recursing further for deeply nested groups)
102
- *
103
- * This preserves the parent→child relationship in the output so RAG
104
- * consumers can see exactly which sub-validations belong to which group.
105
+ * Top-level `##` section.
106
+ * - Leaf → `## NAME` + metadata line + body
107
+ * - Group`## NAME` + prose intro + `---` + children
105
108
  */
106
- buildTestSection(test, index) {
107
- const name = test[TestObjectSyntax.Name] ?? `test_${index}`;
109
+ buildTopLevelSection(test) {
110
+ const name = test[TestObjectSyntax.Name] ?? "unknown";
108
111
  const ret = test[TestObjectSyntax.Return];
109
112
  if (typeof ret === "string") {
110
- return this.renderLeaf(test, name, `## ${index}. ${name}`);
113
+ const body = this.renderLeafBody(test, "top-level", false);
114
+ return [`## ${name}`, "", body].join("\n");
111
115
  }
112
- // Group node render intro + skip (before children) then nest children
113
- const childSections = ret
114
- .map((child, i) => this.renderChildSection(child, i + 1, "###"))
115
- .join("\n\n");
116
- const groupSkip = this.renderSkipBlock(test);
117
- return [
118
- `## ${index}. ${name}`,
119
- "",
120
- `Group of **${ret.length}** sub-validation(s). **All** of the following must pass:`,
121
- ...(groupSkip ? ["", groupSkip] : []),
122
- "",
123
- childSections,
124
- ].join("\n");
116
+ return this.renderGroupSection(test, name, "##", "###", []);
125
117
  }
126
118
  /**
127
- * Renders a child/nested section at the given heading level.
128
- * Recurses deeper (####, #####, …) for nested groups.
119
+ * Renders a group section recursively.
120
+ * @param headingLevel Markdown heading for this group node (e.g. "##")
121
+ * @param childLevel Markdown heading for its direct children (e.g. "###")
122
+ * @param ancestorPath Names of ancestor groups, used to build breadcrumbs
129
123
  */
130
- renderChildSection(test, index, headingLevel) {
131
- const name = test[TestObjectSyntax.Name] ?? `sub_test_${index}`;
124
+ renderGroupSection(test, name, headingLevel, childLevel, ancestorPath) {
132
125
  const ret = test[TestObjectSyntax.Return];
133
- const heading = `${headingLevel} ${index}. ${name}`;
134
- if (typeof ret === "string") {
135
- return this.renderLeaf(test, name, heading);
126
+ const skip = test[TestObjectSyntax.Continue];
127
+ const scope = test[TestObjectSyntax.Scope];
128
+ const childNames = ret.map((c) => c[TestObjectSyntax.Name] ?? "?");
129
+ const leafCount = this.countLeafTests(ret);
130
+ const allLeaves = ret.every((c) => typeof c[TestObjectSyntax.Return] === "string");
131
+ // Prose intro sentence
132
+ const introParts = [];
133
+ if (allLeaves) {
134
+ introParts.push(`This is a group of **${leafCount}** sub-validation(s) that all must pass: ` +
135
+ `${this.englishList(childNames)}.`);
136
+ }
137
+ else {
138
+ introParts.push(`This group contains **${ret.length}** sub-group(s)/validation(s): ` +
139
+ `${this.englishList(childNames)}.`);
140
+ }
141
+ if (scope) {
142
+ introParts.push(`It validates the \`${scope}\` path in the payload.`);
136
143
  }
137
- // Nested group go one heading level deeper
138
- const nextLevel = headingLevel + "#";
144
+ const introLine = introParts.join(" ");
145
+ // Skip block for the group itself (blockquote, before children)
146
+ let skipBlock = "";
147
+ if (skip) {
148
+ skipBlock = this.renderSkipInlineBullet(test, skip);
149
+ }
150
+ // Render children
151
+ const currentPath = [...ancestorPath, name];
152
+ const grandChildLevel = childLevel + "#";
139
153
  const childSections = ret
140
- .map((child, i) => this.renderChildSection(child, i + 1, nextLevel))
154
+ .map((child) => {
155
+ const childName = child[TestObjectSyntax.Name] ?? "unknown";
156
+ const childRet = child[TestObjectSyntax.Return];
157
+ if (typeof childRet === "string") {
158
+ return this.renderLeafBody(child, currentPath.join(" > "));
159
+ }
160
+ return this.renderGroupSection(child, childName, childLevel, grandChildLevel, currentPath);
161
+ })
141
162
  .join("\n\n");
142
- const groupSkip = this.renderSkipBlock(test);
143
163
  return [
144
- heading,
164
+ `${headingLevel} ${name}`,
145
165
  "",
146
- `Group of **${ret.length}** sub-validation(s). **All** of the following must pass:`,
147
- ...(groupSkip ? ["", groupSkip] : []),
166
+ introLine,
167
+ ...(skipBlock ? ["", skipBlock] : []),
168
+ "",
169
+ "---",
148
170
  "",
149
171
  childSections,
150
172
  ].join("\n");
151
173
  }
152
174
  /**
153
- * Renders the skip block for a group node as a blockquote.
154
- * Returns an empty string when there is no _CONTINUE_ on this node.
175
+ * Renders a leaf node's full content block:
176
+ * **NAME**
177
+ * `group: PATH | type: leaf | error_code: X`
178
+ *
179
+ * - bullet description lines
180
+ * - Skipped if ... (inline, from markdownMessageGenerator)
155
181
  */
156
- renderSkipBlock(test) {
157
- const skip = test[TestObjectSyntax.Continue];
158
- if (!skip)
159
- return "";
160
- let skipMarkdown = `**Skip if:**\n`;
161
- const skAst = buildAstFromInput(skip);
162
- const skBlock = CompileToMarkdownForSkip(skAst, false, 2, false);
163
- skipMarkdown += `\n${skBlock}`;
164
- const rendered = Mustache.render(skipMarkdown, ConvertArrayToStringsInTestObject(test));
165
- return addBlockquoteToMarkdown(rendered);
166
- }
167
- /** Renders a leaf test's heading, metadata badges, and compiled description. */
168
- renderLeaf(test, name, heading) {
182
+ renderLeafBody(test, groupPath, showBoldName = true) {
183
+ const name = test[TestObjectSyntax.Name] ?? "unknown";
169
184
  const scope = test[TestObjectSyntax.Scope];
170
185
  const errorCode = test[TestObjectSyntax.ErrorCode];
171
186
  const successCode = test[TestObjectSyntax.SuccessCode];
172
187
  const skip = test[TestObjectSyntax.Continue];
173
188
  const ret = test[TestObjectSyntax.Return];
174
- const badges = [];
189
+ // Metadata inline-code line
190
+ const metaParts = [`group: ${groupPath}`, `type: leaf`];
175
191
  if (scope)
176
- badges.push(`**Scope:** \`${scope}\``);
192
+ metaParts.push(`scope: ${scope}`);
177
193
  if (errorCode !== undefined)
178
- badges.push(`**Error Code:** \`${errorCode}\``);
194
+ metaParts.push(`error_code: ${errorCode}`);
179
195
  if (successCode !== undefined)
180
- badges.push(`**Success Code:** \`${successCode}\``);
181
- const badgeLine = badges.length > 0 ? badges.join(" · ") + "\n\n" : "";
182
- const body = markdownMessageGenerator(ret, test, name, skip ? [skip] : undefined);
183
- return `${heading}\n\n${badgeLine}${body}`;
196
+ metaParts.push(`success_code: ${successCode}`);
197
+ const metaLine = `\`${metaParts.join(" | ")}\``;
198
+ // Get bullet-point body from compiler; strip the "#### **name**\n\n" heading.
199
+ let bodyContent;
200
+ try {
201
+ const full = markdownMessageGenerator(ret, test, name, skip ? [skip] : undefined);
202
+ bodyContent = full
203
+ .replace(/^#{1,6}\s+\*\*[^*]+\*\*\s*\n\n?/, "")
204
+ .trim();
205
+ }
206
+ catch {
207
+ bodyContent = `- ${ret}`;
208
+ if (skip)
209
+ bodyContent += `\n- Skipped if: ${skip}`;
210
+ }
211
+ return showBoldName
212
+ ? [`**${name}**`, metaLine, "", bodyContent].join("\n")
213
+ : [metaLine, "", bodyContent].join("\n");
214
+ }
215
+ /**
216
+ * Renders a group's skip condition as a blockquote paragraph.
217
+ * Uses markdownMessageGenerator to compile the JVAL expression.
218
+ */
219
+ renderSkipInlineBullet(test, skip) {
220
+ try {
221
+ const full = markdownMessageGenerator(skip, test, "skip", undefined);
222
+ const body = full
223
+ .replace(/^#{1,6}\s+\*\*[^*]+\*\*\s*\n\n?/, "")
224
+ .trim();
225
+ return `> **Skip if:**\n> ${body.replace(/\n/g, "\n> ")}`;
226
+ }
227
+ catch {
228
+ return `> **Skip if:** ${skip}`;
229
+ }
184
230
  }
185
231
  }
@@ -45,6 +45,12 @@ export declare class RagTableGenerator extends CodeGenerator {
45
45
  * - `Scope`, `Skip If`, `Error Code`, `Success Code` similarly pruned
46
46
  */
47
47
  private renderTable;
48
+ /**
49
+ * Compiles a JVAL skip expression to plain text suitable for a table cell.
50
+ * Uses CompileToMarkdownForSkip (not CompileToMarkdown) so the output
51
+ * correctly renders conditional/negation skip logic.
52
+ */
53
+ private compileSkipToText;
48
54
  /**
49
55
  * Sanitises a string for safe use inside a GFM table cell:
50
56
  * - Collapses newlines and excess whitespace to a single space
@@ -2,6 +2,10 @@ import { ConfigSyntax, TestObjectSyntax } from "../../../constants/syntax.js";
2
2
  import { CodeGenerator, } from "../classes/abstract-generator.js";
3
3
  import { writeFileWithFsExtra } from "../../../utils/fs-utils.js";
4
4
  import { markdownMessageGenerator } from "../documentation/markdown-message-generator.js";
5
+ import { buildAstFromInput } from "../../../services/return-complier/combined.js";
6
+ import { CompileToMarkdownForSkip } from "../../../services/return-complier/ast-functions/compile-to-markdown.js";
7
+ import { ConvertArrayToStringsInTestObject } from "../../../utils/general-utils/string-utils.js";
8
+ import Mustache from "mustache";
5
9
  /**
6
10
  * RagTableGenerator — produces one Markdown **table** file per API action
7
11
  * under `./rag-table-docs/`.
@@ -126,9 +130,7 @@ export class RagTableGenerator extends CodeGenerator {
126
130
  let skipText = "";
127
131
  if (ownSkip) {
128
132
  try {
129
- skipText = markdownMessageGenerator(ownSkip, test, name, undefined)
130
- .replace(/^#{1,6}\s+\*\*[^*]+\*\*\s*\n\n?/, "")
131
- .trim();
133
+ skipText = this.compileSkipToText(ownSkip, test);
132
134
  }
133
135
  catch {
134
136
  skipText = ownSkip;
@@ -154,9 +156,7 @@ export class RagTableGenerator extends CodeGenerator {
154
156
  let skipText = "";
155
157
  if (ownSkip) {
156
158
  try {
157
- skipText = markdownMessageGenerator(ownSkip, test, name, undefined)
158
- .replace(/^#{1,6}\s+\*\*[^*]+\*\*\s*\n\n?/, "")
159
- .trim();
159
+ skipText = this.compileSkipToText(ownSkip, test);
160
160
  }
161
161
  catch {
162
162
  skipText = ownSkip;
@@ -253,6 +253,16 @@ export class RagTableGenerator extends CodeGenerator {
253
253
  const dataRows = rows.map((r) => `| ${cols.map((c) => c.value(r) || "—").join(" | ")} |`);
254
254
  return [headerRow, sepRow, ...dataRows].join("\n");
255
255
  }
256
+ /**
257
+ * Compiles a JVAL skip expression to plain text suitable for a table cell.
258
+ * Uses CompileToMarkdownForSkip (not CompileToMarkdown) so the output
259
+ * correctly renders conditional/negation skip logic.
260
+ */
261
+ compileSkipToText(skipExpr, test) {
262
+ const skAst = buildAstFromInput(skipExpr);
263
+ const skBlock = CompileToMarkdownForSkip(skAst, false, 2, false);
264
+ return Mustache.render(skBlock, ConvertArrayToStringsInTestObject(test));
265
+ }
256
266
  /**
257
267
  * Sanitises a string for safe use inside a GFM table cell:
258
268
  * - Collapses newlines and excess whitespace to a single space
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ondc-code-generator",
3
- "version": "1.0.0",
3
+ "version": "1.0.1",
4
4
  "description": "generate code from build.yaml ",
5
5
  "main": "dist/index.js",
6
6
  "type": "module",