Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(deps): npm up #905

Merged
merged 9 commits into from
Oct 17, 2024
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
7,693 changes: 4,105 additions & 3,588 deletions package-lock.json

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,12 @@
],
"devDependencies": {
"@readme/eslint-config": "^14.0.0",
"@vitest/coverage-v8": "^1.6.0",
"@vitest/coverage-v8": "^2.1.3",
"alex": "^11.0.1",
"eslint": "^8.57.0",
"lerna": "^8.1.2",
"prettier": "^3.2.5",
"vitest": "^1.6.0"
"vitest": "^2.1.3"
},
"prettier": "@readme/eslint-config/prettier"
}
2 changes: 1 addition & 1 deletion packages/oas-normalize/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@
"nock": "^14.0.0-beta.12",
"tsup": "^8.0.2",
"typescript": "^5.1.6",
"vitest": "^1.6.0"
"vitest": "^2.1.3"
},
"prettier": "@readme/eslint-config/prettier"
}
1 change: 1 addition & 0 deletions packages/oas-normalize/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,7 @@ export default class OASNormalize {
* is valid or not we need to clone it before passing it over to `openapi-parser` so as to
* not run into pass-by-reference problems.
*/
// eslint-disable-next-line try-catch-failsafe/json-parse
const clonedSchema = JSON.parse(JSON.stringify(schema));

return openapiParser
Expand Down
1 change: 1 addition & 0 deletions packages/oas-normalize/src/lib/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ export function stringToJSON(string: Record<string, unknown> | string): Record<s
if (typeof string === 'object') {
return string;
} else if (string.match(/^\s*{/)) {
// eslint-disable-next-line try-catch-failsafe/json-parse
return JSON.parse(string);
}

Expand Down
2 changes: 1 addition & 1 deletion packages/oas-to-har/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
"tsup": "^8.0.2",
"type-fest": "^4.18.3",
"typescript": "^5.2.2",
"vitest": "^1.6.0"
"vitest": "^2.1.3"
},
"prettier": "@readme/eslint-config/prettier"
}
4 changes: 4 additions & 0 deletions packages/oas-to-har/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -411,6 +411,7 @@ export default function oasToHar(

if (operation.isFormUrlEncoded()) {
if (Object.keys(formData.formData || {}).length) {
// eslint-disable-next-line try-catch-failsafe/json-parse
const cleanFormData = removeUndefinedObjects(JSON.parse(JSON.stringify(formData.formData)));
if (cleanFormData !== undefined) {
const postData: PostData = { params: [], mimeType: 'application/x-www-form-urlencoded' };
Expand Down Expand Up @@ -539,6 +540,7 @@ export default function oasToHar(
jsonTypes.forEach((prop: boolean | string) => {
try {
set(cleanBody, String(prop), JSON.parse(get(cleanBody, String(prop))));
// eslint-disable-next-line @typescript-eslint/no-unused-vars
} catch (e) {
// leave the prop as a string value
}
Expand All @@ -551,6 +553,7 @@ export default function oasToHar(
}

har.postData.text = JSON.stringify(cleanBody);
// eslint-disable-next-line @typescript-eslint/no-unused-vars
} catch (e) {
har.postData.text = stringify(formData.body);
}
Expand All @@ -559,6 +562,7 @@ export default function oasToHar(
}
}
}
// eslint-disable-next-line @typescript-eslint/no-unused-vars
} catch (e) {
// If anything above fails for whatever reason, assume that whatever we had is invalid
// JSON and just treat it as raw text.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ const isRfc3986Unreserved = (char: string) => /^[a-z0-9\-._~]+$/i.test(char);
function isURIEncoded(value: string) {
try {
return decodeURIComponent(value) !== value;
// eslint-disable-next-line @typescript-eslint/no-unused-vars
} catch (err) {
// `decodeURIComponent` will throw an exception if a string that has an un-encoded percent sign
// in it (like 20%), o if it's throwing we can just assume that the value hasn't been encoded.
Expand Down Expand Up @@ -59,6 +60,7 @@ export function encodeDisallowedCharacters(
}

if (parse) {
// eslint-disable-next-line try-catch-failsafe/json-parse
return JSON.parse(str);
}

Expand Down
1 change: 1 addition & 0 deletions packages/oas-to-har/src/lib/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ export function getTypedFormatsInSchema(
})
.flat()
.filter(Boolean);
// eslint-disable-next-line @typescript-eslint/no-unused-vars
} catch (err) {
// If this fails for whatever reason then we should act as if we didn't find any `format`'d
// schemas.
Expand Down
4 changes: 2 additions & 2 deletions packages/oas-to-snippet/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
"test": "echo 'Please run tests from the root!' && exit 1"
},
"dependencies": {
"@readme/httpsnippet": "^10.1.0",
"@readme/httpsnippet": "^11.0.0",
"@readme/oas-to-har": "file:../oas-to-har"
},
"devDependencies": {
Expand All @@ -63,7 +63,7 @@
"tsup": "^8.0.2",
"type-fest": "^4.18.3",
"typescript": "^5.2.2",
"vitest": "^1.6.0"
"vitest": "^2.1.3"
},
"prettier": "@readme/eslint-config/prettier"
}
1 change: 1 addition & 0 deletions packages/oas-to-snippet/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ export default function oasToSnippet(

try {
({ config, language, target } = getLanguageConfig(languages, lang));
// eslint-disable-next-line @typescript-eslint/no-unused-vars
} catch (err) {
if (!language || !target) {
return { code: '', highlightMode: false, install: false };
Expand Down
1 change: 1 addition & 0 deletions packages/oas-to-snippet/src/languages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,7 @@ export function getSupportedLanguages(
plugins?: ClientPlugin<any>[];
} = { plugins: [] },
) {
// eslint-disable-next-line try-catch-failsafe/json-parse
const languages: SupportedLanguages = JSON.parse(JSON.stringify(DEFAULT_LANGUAGES));

Object.entries(targets).forEach(([target, { clientsById }]) => {
Expand Down
8 changes: 4 additions & 4 deletions packages/oas-to-snippet/test/__snapshots__/index.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -493,19 +493,19 @@ developers.loginUser({username: 'woof', password: 'barkbarkbark'})
.then(({ data }) => console.log(data))
.catch(err => console.error(err));",
"highlightMode": "javascript",
"install": "npx api install @developers/v2.0#17273l2glm9fq4l5",
"install": "npx api install "@developers/v2.0#17273l2glm9fq4l5"",
}
`;

exports[`oas-to-snippet > supported languages > node > targets > api > should support snippet generation 1`] = `
{
"code": "import sdk from '@api/developers';
"code": "import developers from '@api/developers';

sdk.loginUser({username: 'woof', password: 'barkbarkbark'})
developers.loginUser({username: 'woof', password: 'barkbarkbark'})
.then(({ data }) => console.log(data))
.catch(err => console.error(err));",
"highlightMode": "javascript",
"install": "npx api install @developers/v2.0#17273l2glm9fq4l5",
"install": "npx api install "@developers/v2.0#17273l2glm9fq4l5"",
}
`;

Expand Down
4 changes: 2 additions & 2 deletions packages/oas-to-snippet/test/languages.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ describe('#getSupportedLanguages', () => {

expect(languages.node.httpsnippet.targets.api).toStrictEqual({
name: 'API',
install: 'npx api install {packageName}',
install: 'npx api install "{packageName}"',
});
});
});
Expand All @@ -43,7 +43,7 @@ describe('#getClientInstallationInstructions', () => {
});

expect(getClientInstallationInstructions(languages, ['node', 'api'], '@developers/v2.0#17273l2glm9fq4l5')).toBe(
'npx api install @developers/v2.0#17273l2glm9fq4l5',
'npx api install "@developers/v2.0#17273l2glm9fq4l5"',
);
});

Expand Down
1 change: 1 addition & 0 deletions packages/oas/.eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"rules": {
"@typescript-eslint/no-explicit-any": "off",
"@typescript-eslint/no-use-before-define": ["error", { "classes": false }],
"@typescript-eslint/no-unused-vars": "error",

"camelcase": "off",

Expand Down
2 changes: 1 addition & 1 deletion packages/oas/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@
"@types/node": "^20.12.13",
"tsup": "^8.0.2",
"typescript": "^5.4.4",
"vitest": "^1.6.0"
"vitest": "^2.1.3"
},
"prettier": "@readme/eslint-config/prettier"
}
1 change: 1 addition & 0 deletions packages/oas/src/analyzer/queries/openapi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ export function callbacks(definition: OASDocument) {
export async function circularRefs(definition: OASDocument) {
// Dereferencing will update the passed in variable, which we don't want to do, so we
// instantiated `Oas` with a clone.
// eslint-disable-next-line try-catch-failsafe/json-parse
const oas = new Oas(JSON.parse(JSON.stringify(definition)));
await oas.dereference();

Expand Down
4 changes: 4 additions & 0 deletions packages/oas/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ function normalizedUrl(api: RMOAS.OASDocument, selected: number) {
urlWithOrigin.pathname = url;
url = urlWithOrigin.href;
}
// eslint-disable-next-line @typescript-eslint/no-unused-vars
} catch (e) {
url = exampleDotCom;
}
Expand Down Expand Up @@ -167,6 +168,7 @@ function generatePathMatches(paths: RMOAS.PathsObject, pathName: string, origin:
try {
const matchStatement = match(cleanedPath, { decode: decodeURIComponent });
matchResult = matchStatement(prunedPathName);
// eslint-disable-next-line @typescript-eslint/no-unused-vars
} catch (err) {
// If path matching fails for whatever reason (maybe they have a malformed path parameter)
// then we shouldn't also fail.
Expand Down Expand Up @@ -281,6 +283,7 @@ export default class Oas {
*/
constructor(oas: RMOAS.OASDocument | string, user?: RMOAS.User) {
if (typeof oas === 'string') {
// eslint-disable-next-line try-catch-failsafe/json-parse
oas = JSON.parse(oas) as RMOAS.OASDocument;
}
// @todo throw an exception here instead of allowing an empty oas
Expand Down Expand Up @@ -337,6 +340,7 @@ export default class Oas {
try {
variables = this.api.servers[selected].variables;
if (!variables) throw new Error('no variables');
// eslint-disable-next-line @typescript-eslint/no-unused-vars
} catch (e) {
variables = {};
}
Expand Down
1 change: 1 addition & 0 deletions packages/oas/src/lib/clone-object.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@ export default function cloneObject<T>(obj: T): T {
return undefined;
}

// eslint-disable-next-line try-catch-failsafe/json-parse
return JSON.parse(JSON.stringify(obj));
}
3 changes: 3 additions & 0 deletions packages/oas/src/lib/openapi-to-json-schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,7 @@ function searchForValueByPropAndPointer(

try {
foundValue = jsonpointer.get(schema, pointers[i]);
// eslint-disable-next-line @typescript-eslint/no-unused-vars
} catch (err) {
// If the schema we're looking at is `{obj: null}` and our pointer is `/obj/propertyName`
// `jsonpointer` will throw an error. If that happens, we should silently catch and toss it
Expand Down Expand Up @@ -329,6 +330,7 @@ export function toJSONSchema(data: RMOAS.SchemaObject | boolean, opts: toJSONSch
defaultResolver: mergeJSONSchemaAllOf.options.resolvers.title,
} as unknown,
}) as RMOAS.SchemaObject;
// eslint-disable-next-line @typescript-eslint/no-unused-vars
} catch (e) {
// If we can't merge the `allOf` for whatever reason (like if one item is a `string` and
// the other is a `object`) then we should completely remove it from the schema and continue
Expand Down Expand Up @@ -780,6 +782,7 @@ export function toJSONSchema(data: RMOAS.SchemaObject | boolean, opts: toJSONSch
if (userJwtDefault) {
schema.default = userJwtDefault;
}
// eslint-disable-next-line @typescript-eslint/no-unused-vars
} catch (err) {
// If jsonpointer returns an error, we won't show any defaults for that path.
}
Expand Down
6 changes: 4 additions & 2 deletions packages/oas/src/operation/index.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import type { Extensions } from '../extensions.js';
import type { SecurityType } from '../types.js';
import type { CallbackExamples } from './lib/get-callback-examples.js';
import type { getParametersAsJSONSchemaOptions } from './lib/get-parameters-as-json-schema.js';
import type { RequestBodyExamples } from './lib/get-requestbody-examples.js';
import type { ResponseExamples } from './lib/get-response-examples.js';
import type { Extensions } from '../extensions.js';
import type { SecurityType } from '../types.js';
import type { OpenAPIV3, OpenAPIV3_1 } from 'openapi-types';

import findSchemaDefinition from '../lib/find-schema-definition.js';
Expand Down Expand Up @@ -194,6 +194,7 @@ export class Operation {
let keys;
try {
keys = Object.keys(requirement);
// eslint-disable-next-line @typescript-eslint/no-unused-vars
} catch (e) {
return false;
}
Expand All @@ -203,6 +204,7 @@ export class Operation {
try {
// Remove the reference type, because we know this will be dereferenced
security = this.api.components.securitySchemes[key] as RMOAS.KeyedSecuritySchemeObject;
// eslint-disable-next-line @typescript-eslint/no-unused-vars
} catch (e) {
return false;
}
Expand Down
1 change: 1 addition & 0 deletions packages/oas/src/operation/lib/get-mediatype-examples.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ export function getMediaTypeExamples(
if (!matchesMimeType.xml(mediaType)) {
return [
{
// eslint-disable-next-line try-catch-failsafe/json-parse
value: sampleFromSchema(JSON.parse(JSON.stringify(mediaTypeObject.schema)), opts),
},
];
Expand Down
1 change: 1 addition & 0 deletions packages/oas/src/reducer/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ export default function reducer(definition: OASDocument, opts: ReducerOptions =
}

// Stringify and parse so we get a full non-reference clone of the API definition to work with.
// eslint-disable-next-line try-catch-failsafe/json-parse
const reduced = JSON.parse(JSON.stringify(definition)) as OASDocument;

// Retain any root-level security definitions.
Expand Down
1 change: 1 addition & 0 deletions packages/oas/src/samples/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ function sampleFromSchema(
}),
opts,
);
// eslint-disable-next-line @typescript-eslint/no-unused-vars
} catch (error) {
return undefined;
}
Expand Down
2 changes: 1 addition & 1 deletion packages/oas/src/samples/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export function normalizeArray(arr: (number | string)[] | number | string) {
return [arr];
}

// eslint-disable-next-line @typescript-eslint/ban-types
// eslint-disable-next-line @typescript-eslint/no-unsafe-function-type
export function isFunc(thing: unknown): thing is Function {
return typeof thing === 'function';
}
Expand Down
1 change: 1 addition & 0 deletions packages/oas/test/analyzer/queries/openapi.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ describe('analyzer queries (OpenAPI)', () => {
describe('discriminators', () => {
it('should discover `discriminator` usage within a definition that has it', () => {
expect(QUERIES.discriminators(discriminators)).toStrictEqual([
'#/components/schemas/BaseVehicle/discriminator',
'#/components/schemas/Pet/discriminator',
'#/paths/~1discriminator-with-mapping/patch/requestBody/content/application~1json/schema/discriminator',
'#/paths/~1discriminator-with-no-mapping/patch/requestBody/content/application~1json/schema/discriminator',
Expand Down
1 change: 1 addition & 0 deletions packages/postman-types/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ export namespace PostmanV2 {
variable?: VariableListObject;
}

// eslint-disable-next-line @typescript-eslint/no-empty-object-type
export interface ProtocolProfileBehaviorObject {}

export interface ProxyConfigObject {
Expand Down