Skip to content

Commit

Permalink
feat: workflow rules
Browse files Browse the repository at this point in the history
  • Loading branch information
catalandres committed Dec 18, 2023
1 parent 72807e4 commit f8f2771
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/shared/XmlParser.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import * as xml2js from 'xml2js';
import * as Metadata from '../types/metadata.js';
import { Named, FullNamed, ObjectNamed } from '../types/metadata-addon.js';
import { arraynge } from './arraynge.js';

const nameRegEx = new RegExp('.+/([^.]*)');
const parserOptions: xml2js.ParserOptions = {
Expand Down Expand Up @@ -74,7 +75,7 @@ export class XmlParser {
const objectName = nameRegEx.exec(fileName)?.[1] as string;
// eslint-disable-next-line @typescript-eslint/no-unsafe-call, @typescript-eslint/no-unsafe-member-access
xml2js.parseString(xml, parserOptions, (err, result: { Workflow: Metadata.Workflow }) => {
for (const thisRule of result.Workflow.rules as Array<ObjectNamed<FullNamed<Metadata.WorkflowRule>>>) {
for (const thisRule of arraynge(result.Workflow.rules) as Array<ObjectNamed<FullNamed<Metadata.WorkflowRule>>>) {
thisRule.objectName = objectName;
workflowRules.push(thisRule);
}
Expand Down
7 changes: 7 additions & 0 deletions src/shared/arraynge.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
export function arraynge<Type>(input: Type | Type[] | undefined): Type[] {
if (input === undefined) {
return [];
}

return Array.isArray(input) ? input : [input];
}

0 comments on commit f8f2771

Please sign in to comment.