-
Notifications
You must be signed in to change notification settings - Fork 84
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Snyk] Security upgrade mongoose from 5.11.10 to 5.12.3 (#1538)
* fix: package.json & package-lock.json to reduce vulnerabilities The following vulnerabilities are fixed with an upgrade: - https://snyk.io/vuln/SNYK-JS-MQUERY-1089718 * refactor(mongoose): rework type defs * refactor(models): rework form.server.model for mongoose - recast FormSchema as FormDocumentSchema so that we can register methods specific to the handling of IFormDocument - declare Schema.Types.DocumentArrayWithLooseDiscriminator so that we can more easily register our sub-schema TODO - submit a patch to mongoose to loosen the type def for `DocumentArray.discriminator()` Co-authored-by: LoneRifle <LoneRifle@users.noreply.github.com>
- Loading branch information
Showing
15 changed files
with
95 additions
and
47 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
/** | ||
* Additional type declarations for mongoose to fit our use case, | ||
* to accommodate the non-standard but compatible use of types | ||
* in schema registration | ||
*/ | ||
declare module 'mongoose' { | ||
namespace Schema { | ||
namespace Types { | ||
/** | ||
* A DocumentArray with a discriminator function that takes in a | ||
* type-generic Schema. | ||
*/ | ||
class DocumentArrayWithLooseDiscriminator extends DocumentArray { | ||
/** | ||
* In the built-in type declarations in | ||
* version 5.12 of mongoose, discriminator() expects a Schema | ||
* (and hence Schema<Document>). This does not work; a Schema | ||
* for a subtype of Document is not a Schema for a Document, as | ||
* Schema.methods expect to operate on the Schema's document type, | ||
* which is not necessarily a Document. | ||
* | ||
* Address this by overriding the definition and provide a type-generic | ||
* Schema argument. | ||
*/ | ||
discriminator<T extends Document>( | ||
name: string, | ||
schema: Schema<T>, | ||
tag?: string, | ||
): unknown | ||
} | ||
} | ||
} | ||
} |