Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion e2e/nx-plugin-e2e/vite.config.e2e.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export default defineConfig({
cacheDir: '../../node_modules/.vite/nx-plugin-e2e',
test: {
reporters: ['basic'],
testTimeout: 40_000,
testTimeout: 80_000,
globals: true,
alias: tsconfigPathAliases(),
pool: 'threads',
Expand Down
2 changes: 1 addition & 1 deletion e2e/plugin-lighthouse-e2e/vite.config.e2e.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export default defineConfig({
cacheDir: '../../node_modules/.vite/plugin-lighthouse-e2e',
test: {
reporters: ['basic'],
testTimeout: 40_000,
testTimeout: 80_000,
globals: true,
alias: tsconfigPathAliases(),
pool: 'threads',
Expand Down
9 changes: 5 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@
"verdaccio": "^5.32.2",
"vite": "^5.4.8",
"vitest": "1.3.1",
"zod2md": "^0.1.3"
"zod2md": "^0.1.7"
},
"optionalDependencies": {
"@esbuild/darwin-arm64": "^0.19.12",
Expand Down
133 changes: 109 additions & 24 deletions packages/models/docs/models-reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,11 @@ Detailed information

_Object containing the following properties:_

| Property | Description | Type |
| :------- | :------------------------ | :--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `issues` | List of findings | _Array of [Issue](#issue) items_ |
| `table` | Table of related findings | _Object with properties:_<ul><li>`title`: `string` - Display title for table</li><li>`columns`: _Array of [TableAlignment](#tablealignment) items_</li><li>`rows`: _Array of [TableRowPrimitive](#tablerowprimitive) items_</li></ul> _or_ _Object with properties:_<ul><li>`title`: `string` - Display title for table</li><li>`columns`: _Array of [TableAlignment](#tablealignment) items_ _or_ _Array of [TableColumnObject](#tablecolumnobject) items_</li><li>`rows`: _Array of [TableRowObject](#tablerowobject) items_</li></ul> |
| Property | Description | Type |
| :------- | :------------------------- | :--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `issues` | List of findings | _Array of [Issue](#issue) items_ |
| `table` | Table of related findings | _Object with properties:_<ul><li>`title`: `string` - Display title for table</li><li>`columns`: _Array of [TableAlignment](#tablealignment) items_</li><li>`rows`: _Array of [TableRowPrimitive](#tablerowprimitive) items_</li></ul> _or_ _Object with properties:_<ul><li>`title`: `string` - Display title for table</li><li>`columns`: _Array of [TableAlignment](#tablealignment) items_ _or_ _Array of [TableColumnObject](#tablecolumnobject) items_</li><li>`rows`: _Array of [TableRowObject](#tablerowobject) items_</li></ul> |
| `trees` | Findings in tree structure | _Array of [Tree](#tree) items_ |

_All properties are optional._

Expand Down Expand Up @@ -97,6 +98,32 @@ _Object containing the following properties:_

_(\*) Required._

## BasicTreeNode

_Object containing the following properties:_

| Property | Description | Type |
| :-------------- | :--------------------------------------------- | :----------------------------------------------- |
| **`name`** (\*) | Text label for node | `string` (_min length: 1_) |
| `values` | Additional values for node | `Record<string, number \| string>` |
| `children` | Direct descendants of this node (omit if leaf) | _Array of [BasicTreeNode](#basictreenode) items_ |

_(\*) Required._

## BasicTree

Generic tree

_Object containing the following properties:_

| Property | Description | Type |
| :-------------- | :----------- | :------------------------------ |
| `title` | Heading | `string` |
| `type` | Discriminant | `'basic'` |
| **`root`** (\*) | Root node | [BasicTreeNode](#basictreenode) |

_(\*) Required._

## CategoryConfig

_Object containing the following properties:_
Expand Down Expand Up @@ -180,6 +207,57 @@ _Object containing the following properties:_

_(\*) Required._

## CoverageTreeMissingLOC

Uncovered line of code, optionally referring to a named function/class/etc.

_Object containing the following properties:_

| Property | Description | Type |
| :------------------- | :-------------------------------- | :------------------- |
| **`startLine`** (\*) | Start line | `number` (_int, >0_) |
| `startColumn` | Start column | `number` (_int, >0_) |
| `endLine` | End line | `number` (_int, >0_) |
| `endColumn` | End column | `number` (_int, >0_) |
| `name` | Identifier of function/class/etc. | `string` |
| `kind` | E.g. "function", "class" | `string` |

_(\*) Required._

## CoverageTreeNode

_Object containing the following properties:_

| Property | Description | Type |
| :---------------- | :-------------------------------------------------------- | :---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **`name`** (\*) | File or folder name | `string` (_min length: 1_) |
| **`values`** (\*) | Coverage metrics for file/folder | _Object with properties:_<ul><li>`coverage`: `number` (_≥0, ≤1_) - Coverage ratio</li><li>`missing`: _Array of [CoverageTreeMissingLOC](#coveragetreemissingloc) items_ - Uncovered lines of code</li></ul> |
| `children` | Files and folders contained in this folder (omit if file) | _Array of [CoverageTreeNode](#coveragetreenode) items_ |

_(\*) Required._

## CoverageTree

Coverage for files and folders

_Object containing the following properties:_

| Property | Description | Type |
| :-------------- | :----------- | :------------------------------------ |
| `title` | Heading | `string` |
| **`type`** (\*) | Discriminant | `'coverage'` |
| **`root`** (\*) | Root folder | [CoverageTreeNode](#coveragetreenode) |

_(\*) Required._

## FileName

_String which matches the regular expression `/^(?!.*[ \\/:*?"<>|]).+$/` and has a minimum length of 1._

## FilePath

_String which has a minimum length of 1._

## Format

_Enum string, one of the following possible values:_
Expand Down Expand Up @@ -1137,27 +1215,15 @@ _Enum string, one of the following possible values:_

</details>

## OnProgress

_Function._

_Parameters:_

1. `unknown` (_optional & nullable_)

_Returns:_

- `void` (_optional_)

## PersistConfig

_Object containing the following properties:_

| Property | Description | Type |
| :---------- | :-------------------------------------- | :-------------------------------------------------------------- |
| `outputDir` | Artifacts folder | `string` (_min length: 1_) |
| `filename` | Artifacts file name (without extension) | `string` (_regex: `/^(?!.*[ \\/:*?"<>\|]).+$/`, min length: 1_) |
| `format` | | _Array of [Format](#format) items_ |
| Property | Description | Type |
| :---------- | :-------------------------------------- | :--------------------------------- |
| `outputDir` | Artifacts folder | [FilePath](#filepath) |
| `filename` | Artifacts file name (without extension) | [FileName](#filename) |
| `format` | | _Array of [Format](#format) items_ |

_All properties are optional._

Expand Down Expand Up @@ -1264,8 +1330,20 @@ _Object containing the following properties:_
| :-------------------- | :----------------------- | :---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **`command`** (\*) | Shell command to execute | `string` |
| `args` | | `Array<string>` |
| **`outputFile`** (\*) | Output path | `string` (_min length: 1_) |
| **`outputFile`** (\*) | Runner output path | [FilePath](#filepath) |
| `outputTransform` | | _Function:_<br /><ul><li>_parameters:_ <ol><li>`unknown` (_optional & nullable_)</li></ol></li><li>_returns:_ [AuditOutputs](#auditoutputs) _or_ _Promise of_ [AuditOutputs](#auditoutputs)</li></ul> |
| `configFile` | Runner config path | [FilePath](#filepath) |

_(\*) Required._

## RunnerFilesPaths

_Object containing the following properties:_

| Property | Description | Type |
| :-------------------------- | :----------------- | :-------------------- |
| **`runnerConfigPath`** (\*) | Runner config path | [FilePath](#filepath) |
| **`runnerOutputPath`** (\*) | Runner output path | [FilePath](#filepath) |

_(\*) Required._

Expand All @@ -1275,7 +1353,7 @@ _Function._

_Parameters:_

1. [OnProgress](#onprogress) (_optional_)
- _none_

_Returns:_

Expand All @@ -1289,7 +1367,7 @@ _Object containing the following properties:_

| Property | Description | Type |
| :-------------- | :--------------------------------------- | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **`file`** (\*) | Relative path to source file in Git repo | `string` (_min length: 1_) |
| **`file`** (\*) | Relative path to source file in Git repo | [FilePath](#filepath) |
| `position` | Location in file | _Object with properties:_<ul><li>`startLine`: `number` (_int, >0_) - Start line</li><li>`startColumn`: `number` (_int, >0_) - Start column</li><li>`endLine`: `number` (_int, >0_) - End line</li><li>`endColumn`: `number` (_int, >0_) - End column</li></ul> |

_(\*) Required._
Expand Down Expand Up @@ -1353,6 +1431,13 @@ Primitive row

_Array of [TableCellValue](#tablecellvalue) (\_optional & nullable_) items.\_

## Tree

_Union of the following possible types:_

- [BasicTree](#basictree)
- [CoverageTree](#coveragetree)

## UploadConfig

_Object containing the following properties:_
Expand Down
18 changes: 16 additions & 2 deletions packages/models/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,11 +97,11 @@ export {
} from './lib/reports-diff.js';
export {
runnerConfigSchema,
runnerFunctionSchema,
runnerFilesPathsSchema,
runnerFunctionSchema,
type RunnerConfig,
type RunnerFunction,
type RunnerFilesPaths,
type RunnerFunction,
} from './lib/runner-config.js';
export {
tableAlignmentSchema,
Expand All @@ -117,4 +117,18 @@ export {
type TableRowObject,
type TableRowPrimitive,
} from './lib/table.js';
export {
basicTreeNodeSchema,
basicTreeSchema,
coverageTreeMissingLOCSchema,
coverageTreeNodeSchema,
coverageTreeSchema,
treeSchema,
type BasicTree,
type BasicTreeNode,
type CoverageTree,
type CoverageTreeMissingLOC,
type CoverageTreeNode,
type Tree,
} from './lib/tree.js';
export { uploadConfigSchema, type UploadConfig } from './lib/upload-config.js';
4 changes: 4 additions & 0 deletions packages/models/src/lib/audit-output.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {
import { errorItems, hasDuplicateStrings } from './implementation/utils.js';
import { issueSchema } from './issue.js';
import { tableSchema } from './table.js';
import { treeSchema } from './tree.js';

export const auditValueSchema =
nonnegativeNumberSchema.describe('Raw numeric value');
Expand All @@ -20,6 +21,9 @@ export const auditDetailsSchema = z.object(
.array(issueSchema, { description: 'List of findings' })
.optional(),
table: tableSchema('Table of related findings').optional(),
trees: z
.array(treeSchema, { description: 'Findings in tree structure' })
.optional(),
},
{ description: 'Detailed information' },
);
Expand Down
10 changes: 10 additions & 0 deletions packages/models/src/lib/implementation/schemas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -223,3 +223,13 @@ type Ref = { weight: number };
function hasNonZeroWeightedRef(refs: Ref[]) {
return refs.reduce((acc, { weight }) => weight + acc, 0) !== 0;
}

export const filePositionSchema = z.object(
{
startLine: positiveIntSchema.describe('Start line'),
startColumn: positiveIntSchema.describe('Start column').optional(),
endLine: positiveIntSchema.describe('End line').optional(),
endColumn: positiveIntSchema.describe('End column').optional(),
},
{ description: 'Location in file' },
);
17 changes: 5 additions & 12 deletions packages/models/src/lib/source.ts
Original file line number Diff line number Diff line change
@@ -1,20 +1,13 @@
import { z } from 'zod';
import { filePathSchema, positiveIntSchema } from './implementation/schemas.js';
import {
filePathSchema,
filePositionSchema,
} from './implementation/schemas.js';

export const sourceFileLocationSchema = z.object(
{
file: filePathSchema.describe('Relative path to source file in Git repo'),
position: z
.object(
{
startLine: positiveIntSchema.describe('Start line'),
startColumn: positiveIntSchema.describe('Start column').optional(),
endLine: positiveIntSchema.describe('End line').optional(),
endColumn: positiveIntSchema.describe('End column').optional(),
},
{ description: 'Location in file' },
)
.optional(),
position: filePositionSchema.optional(),
},
{ description: 'Source file location' },
);
Expand Down
Loading