Skip to content

Commit

Permalink
feat: replace ajv usage [INS-145] (#371)
Browse files Browse the repository at this point in the history
* Feat: replace custom har-validator with hard-validator-compiled package

* test(http-snippet): update casing

* fix: linting
  • Loading branch information
vaibhavrajsingh2001 authored Sep 30, 2024
1 parent 723581e commit 08aec7b
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 49 deletions.
19 changes: 10 additions & 9 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 @@ -89,7 +89,7 @@
"chalk": "^4.1.2",
"event-stream": "4.0.1",
"form-data": "4.0.0",
"har-schema": "^2.0.0",
"har-validator-compiled": "^1.0.0",
"stringify-object": "3.3.0",
"yargs": "^17.4.0"
}
Expand Down
31 changes: 0 additions & 31 deletions src/helpers/har-validator.ts

This file was deleted.

2 changes: 1 addition & 1 deletion src/httpsnippet.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ describe('hTTPSnippet', () => {
// @ts-expect-error intentionally incorrect
const attempt = () => new HTTPSnippet({ ziltoid: 'the omniscient' });

expect(attempt).toThrow('validation failed');
expect(attempt).toThrow('Validation Failed');
});

it('should parse HAR file with multiple entries', () => {
Expand Down
4 changes: 2 additions & 2 deletions src/httpsnippet.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { map as eventStreamMap } from 'event-stream';
import FormData from 'form-data';
import { Param, PostDataCommon, Request as NpmHarRequest } from 'har-format';
import { validateRequest } from 'har-validator-compiled';
import { stringify as queryStringify } from 'querystring';
import { format as urlFormat, parse as urlParse, UrlWithParsedQuery } from 'url';

import { formDataIterator, isBlob } from './helpers/form-data';
import { validateHarRequest } from './helpers/har-validator';
import { getHeaderName } from './helpers/headers';
import { ReducedHelperObject, reducer } from './helpers/reducer';
import { ClientId, TargetId, targets } from './targets/targets';
Expand Down Expand Up @@ -106,7 +106,7 @@ export class HTTPSnippet {
},
};

if (validateHarRequest(req)) {
if (validateRequest(req)) {
this.requests.push(this.prepare(req));
}
});
Expand Down
1 change: 0 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
export { CodeBuilder, CodeBuilderOptions, PostProcessor } from './helpers/code-builder';
export { EscapeOptions, escapeString } from './helpers/escape';
export { HARError, validateHarRequest } from './helpers/har-validator';
export { getHeader, getHeaderName } from './helpers/headers';
export { AvailableTarget, availableTargets, extname } from './helpers/utils';
export {
Expand Down
4 changes: 0 additions & 4 deletions src/targets/har-schema.d.ts

This file was deleted.

0 comments on commit 08aec7b

Please sign in to comment.